cogpit 2.0.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/cli.js +15978 -11502
- package/dist/web/assets/CommandPaletteHost-C-ParO8t.js +1 -0
- package/dist/web/assets/ConfigBrowser-Co4eu81Z.js +1 -0
- package/dist/web/assets/{HighlightedEditor-D4DdiaD3.js → HighlightedEditor-j81AHVZZ.js} +2 -2
- package/dist/web/assets/{KeyboardShortcutsDialog-CaqJ90ox.js → KeyboardShortcutsDialog-CluzMowK.js} +1 -1
- package/dist/web/assets/{MobileFileChanges-BjHkXuyc.js → MobileFileChanges-DiOncgtO.js} +1 -1
- package/dist/web/assets/{PreviewPanel-DVORy2rT.js → PreviewPanel-i4Yn68yV.js} +1 -1
- package/dist/web/assets/{ProjectFilesPanel-WiqiZyLW.js → ProjectFilesPanel-DPLFARWn.js} +3 -3
- package/dist/web/assets/ProjectSwitcherModal-BUXfKNzX.js +1 -0
- package/dist/web/assets/{TerminalOutput-zSNcaPSy.js → TerminalOutput-DLRMV4_Y.js} +1 -1
- package/dist/web/assets/{ThemeSelectorModal-D0yWwDku.js → ThemeSelectorModal-Cmx9maEq.js} +1 -1
- package/dist/web/assets/{WorkflowsPanel-Doy9QzhU.js → WorkflowsPanel-Cgm_kbHR.js} +1 -1
- package/dist/web/assets/WorktreePanel-h3DRRXek.js +1 -0
- package/dist/web/assets/{index-BPqm0HzF.js → index-Cgnw8FK8.js} +1 -1
- package/dist/web/assets/{index-BG9ZLZQ3.js → index-DUI5EaV5.js} +4 -4
- package/dist/web/assets/index-DocqIkvS.js +144 -0
- package/dist/web/assets/index-cjmnKg1q.js +1 -0
- package/dist/web/assets/session-parser.worker-DTq2tkdd.js +29 -0
- package/dist/web/assets/{vendor-ui-BmLOQ5Or.js → vendor-ui-CIBbYCBQ.js} +151 -146
- package/dist/web/index.html +3 -3
- package/package.json +3 -2
- package/dist/web/assets/CommandPaletteHost-CyKWHB_t.js +0 -1
- package/dist/web/assets/ConfigBrowser-CmApjOBh.js +0 -1
- package/dist/web/assets/ProjectSwitcherModal-CxLemcBj.js +0 -1
- package/dist/web/assets/WorktreePanel-CgWELvag.js +0 -1
- package/dist/web/assets/index-C3E35E2A.js +0 -138
- package/dist/web/assets/index-C4XoqTra.js +0 -1
- package/dist/web/assets/session-parser.worker-DJxJ4O8Q.js +0 -22
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalOutput-DLRMV4_Y.js","assets/vendor-react-gGw_S5I_.js","assets/vendor-ui-CIBbYCBQ.js","assets/vendor-shiki-DOn6sF-i.js","assets/vendor-markdown-BE1gYnO9.js","assets/TerminalOutput-6GBZ9nXN.css","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/CommandPaletteHost-C-ParO8t.js","assets/index-Cgnw8FK8.js","assets/KeyboardShortcutsDialog-CluzMowK.js","assets/ProjectSwitcherModal-BUXfKNzX.js","assets/ThemeSelectorModal-Cmx9maEq.js","assets/WorktreePanel-h3DRRXek.js","assets/index-cjmnKg1q.js","assets/ConfigBrowser-Co4eu81Z.js","assets/HighlightedEditor-j81AHVZZ.js","assets/PreviewPanel-i4Yn68yV.js","assets/ProjectFilesPanel-DPLFARWn.js","assets/MobileFileChanges-DiOncgtO.js","assets/index-DUI5EaV5.js","assets/WorkflowsPanel-Cgm_kbHR.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var V2=Object.defineProperty;var G2=(n,e,t)=>e in n?V2(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Wr=(n,e,t)=>G2(n,typeof e!="symbol"?e+"":e,t);import{c as U,j as r,d as be,e as Y2,r as b,a as X2,f as J2}from"./vendor-react-gGw_S5I_.js";import{at as Q2,au as Z2,av as eb,aw as Bn,a0 as rt,ax as tb,m as wn,ay as nb,aq as Un,az as $p,aA as sb,aB as ob,aC as rb,aD as Op,aE as Dp,aF as mc,aG as Lp,aH as zp,aI as Fp,aJ as ib,O as dt,aK as ab,aL as lb,aM as cb,aN as db,J as mr,ab as lo,a9 as nt,c as Qt,ah as ub,aO as Bp,aP as gi,G as bo,aQ as fb,aR as mb,aS as pb,aT as hb,aU as gb,aV as xb,aW as bb,aX as vb,aY as yb,aZ as wb,a_ as jb,a$ as Sb,b0 as kb,b1 as Nb,b2 as pr,b3 as Up,b4 as pc,b5 as hc,b6 as gc,b7 as xc,b8 as Li,X as jt,b9 as bc,ba as Cb,N as vc,bb as Wn,bc as _b,bd as Wp,be as Hp,bf as oo,bg as ys,bh as Tb,bi as Eb,bj as Pb,bk as Ab,bl as Yo,S as xn,B as co,b as Kp,bm as Ls,bn as qp,bo as Rb,bp as Mb,bq as Ib,a1 as zi,br as $b,a6 as Fi,aj as El,W as vo,bs as Ou,bt as Ob,bu as Db,bv as Lb,bw as zb,bx as Fb,by as Bb,bz as Ub,bA as yc,bB as Wb,bC as bn,D as En,bD as Xo,T as Bi,bE as Hb,bF as Kb,bG as qb,bH as Vb,bI as hr,bJ as Gb,bK as Yb,bL as Xb,bM as Jb,bN as Qb,bO as Zb,bP as ev,bQ as tv,bR as nv,bS as sv,bT as ov,C as Ze,P as _n,A as yo,g as Vp,bU as rv,bV as iv,bW as av,bX as lv,F as Jo,a2 as zs,bY as cv,bZ as Gp,a4 as wc,j as Ui,V as Wi,b_ as dv,b$ as Yp,c0 as Pl,c1 as uv,c2 as fv,c3 as mv,a3 as jc,R as Sc,c4 as pv,c5 as hv,a7 as Ms,E as Xp,c6 as gv,v as Hi,c7 as Ki,c8 as xv,c9 as bv,ca as Jp,cb as vv,cc as yv,cd as Hr,ce as Ns,a8 as La,af as Du,e as gr,cf as wv,ac as jv,cg as Sv,ar as kv,w as qi,ch as Nv,ci as Cv,cj as _v,ck as Tv,cl as Ev,cm as Pv,cn as Qp,co as Av,cp as Rv,ao as Mv,r as Lu,cq as Iv,cr as zu,p as Vi,cs as $v,ct as Zp,d as eh,I as th,cu as Ov,ad as nh,u as Dv,cv as Lv,cw as sh,L as zv,z as Fv,cx as Bv,cy as Uv,s as oh,as as rh,y as Wv,cz as Hv,cA as Kv,cB as qv,cC as Vv,cD as Gv,cE as Fu,cF as Yv,am as Xv,cG as Jv,_ as Qv,cH as Zv}from"./vendor-ui-CIBbYCBQ.js";import{c as ey,a as ty}from"./vendor-shiki-DOn6sF-i.js";import{r as Gi,M as Pn}from"./vendor-markdown-BE1gYnO9.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))s(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&s(a)}).observe(document,{childList:!0,subtree:!0});function t(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function s(o){if(o.ep)return;o.ep=!0;const i=t(o);fetch(o.href,i)}})();const ny="modulepreload",sy=function(n){return"/"+n},Bu={},Ke=function(e,t,s){let o=Promise.resolve();if(t&&t.length>0){let a=function(d){return Promise.all(d.map(f=>Promise.resolve(f).then(u=>({status:"fulfilled",value:u}),u=>({status:"rejected",reason:u}))))};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"));o=a(t.map(d=>{if(d=sy(d),d in Bu)return;Bu[d]=!0;const f=d.endsWith(".css"),u=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${u}`))return;const m=document.createElement("link");if(m.rel=f?"stylesheet":ny,f||(m.as="script"),m.crossOrigin="",m.href=d,c&&m.setAttribute("nonce",c),document.head.appendChild(m),f)return new Promise((p,h)=>{m.addEventListener("load",p),m.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${d}`)))})}))}function i(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return o.then(a=>{for(const l of a||[])l.status==="rejected"&&i(l.reason);return e().catch(i)})},Is=["codex","copilot","claude"],Al="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";function oy(n,e){const t=new TextEncoder().encode(e);let s="";for(const i of t)s+=String.fromCharCode(i);const o=btoa(s).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return`${n}${o}`}function ry(n,e){if(!e.startsWith(n))return null;try{const t=e.slice(n.length).replace(/-/g,"+").replace(/_/g,"/"),s=atob(t),o=Uint8Array.from(s,i=>i.charCodeAt(0));return new TextDecoder().decode(o)}catch{return null}}function ih(n){return{owns:e=>typeof e=="string"&&e.startsWith(n),encode:e=>oy(n,e),decode:e=>ry(n,e)}}function ah(n){const e=new RegExp(`(${Al})\\.jsonl$`,"i").exec(n);return e?e[1]:null}const lh={urlId:n=>n.replace(/\.jsonl$/,""),fileNameFromUrlId:n=>n.endsWith(".jsonl")?n:`${n}.jsonl`};function ch(n){return`'${n.replace(/'/g,"'\\''")}'`}function Qo(n,e){return e?[n,e]:[]}const dh="codex__",uh="copilot__",iy=new Set(["default","plan","acceptEdits","dontAsk","auto"]),fh={kind:"claude",displayName:"Claude Code",binName:"claude",dirName:{owns:n=>typeof n=="string"&&!n.startsWith(dh)&&!n.startsWith(uh),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,"/")}},sessionFile:{name:n=>`${n}.jsonl`,sessionId:ah,...lh},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"]:[...iy.has(n.mode)?["--permission-mode",n.mode]:[],...(n.allowedTools??[]).flatMap(e=>["--allowedTools",e]),...(n.disallowedTools??[]).flatMap(e=>["--disallowedTools",e])]:["--permission-mode","default"],model:n=>Qo("--model",n),effort:n=>Qo("--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/")},homeDirName:".claude",homeEnvVar:null,installMarker:"projects",homeIsDiscoverable:!1},config:{rootDirName:".claude",instructions:[{in:"scope",path:"CLAUDE.md",scopes:["global","project"]},{in:"root",path:"CLAUDE.md",label:".claude/CLAUDE.md",scopes:["project"]}],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"},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,sharing:!0,goals:!0,undo:!0,redo:!0,nativeRewind:!1,fileCheckpoints:!0,reasoningEffort:!0,fastTier:!0,imageInput:!0,planMode:!0,midTurnSteering:!1,stopSession:!0,ultracode:!0,contextWindow:!0,externalProcesses:!1,modelFallbackNotices:!0,autoPermissionMode:"per-model",settingsApply:"live"}},Uu={appServerValue:"priority",cliConfigValue:"fast"},ay={kind:"codex",displayName:"Codex",binName:"codex",dirName:ih(dh),sessionFile:{name:(n,e=new Date)=>{const t=String(e.getFullYear()),s=String(e.getMonth()+1).padStart(2,"0"),o=String(e.getDate()).padStart(2,"0"),i=String(e.getHours()).padStart(2,"0"),a=String(e.getMinutes()).padStart(2,"0"),l=String(e.getSeconds()).padStart(2,"0");return`${t}/${s}/${o}/rollout-${t}-${s}-${o}T${i}-${a}-${l}-${n}.jsonl`},sessionId:ah,...lh},metadataFromHead:!1,resume:{command:(n,e)=>e?`codex -C ${ch(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"]:["--sandbox",e==="plan"?"read-only":"workspace-write","-c",'approval_policy="never"']},model:n=>Qo("-m",n),effort:n=>n?["-c",`model_reasoning_effort=${JSON.stringify(n)}`]:[],fastTier:n=>n?["-c",`service_tier=${JSON.stringify(Uu.cliConfigValue)}`,"--enable","fast_mode"]:[]},serviceTier:Uu,cli:{packageName:"@openai/codex",homebrew:{name:"codex",cask:!1},wingetId:null,versionArgs:["--version"],selfUpdate:null,homeDirName:".codex",homeEnvVar:"CODEX_HOME",installMarker:"",homeIsDiscoverable:!0},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},contextWindow:{defaultLimit:272e3,limits:[],compactBuffer:0,extendedContext:null},capabilities:{worktrees:!1,mcp:!1,slashCommands:!1,workflows:!1,agentTeams:!1,subagentTranscripts:!0,sharing:!1,goals:!0,undo:!0,redo:!0,nativeRewind:!1,fileCheckpoints:!1,reasoningEffort:!0,fastTier:!0,imageInput:!0,planMode:!0,midTurnSteering:!0,stopSession:!1,ultracode:!1,contextWindow:!1,externalProcesses:!1,modelFallbackNotices:!1,autoPermissionMode:"never",settingsApply:"next-turn"}},ly={kind:"copilot",displayName:"GitHub Copilot CLI",binName:"copilot",dirName:ih(uh),sessionFile:{name:n=>`${n}/events.jsonl`,sessionId:n=>{const e=new RegExp(`^(${Al})/events\\.jsonl$`,"i").exec(n);return e?e[1]:null},urlId:n=>{const e=new RegExp(`^(${Al})/events\\.jsonl$`,"i").exec(n);return e?e[1]:n.replace(/\.jsonl$/,"")},fileNameFromUrlId:n=>n.endsWith(".jsonl")?n:`${n}/events.jsonl`},metadataFromHead:!0,resume:{command:(n,e)=>e?`copilot -C ${ch(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=>Qo("--model",n),effort:n=>Qo("--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"},homeDirName:".copilot",homeEnvVar:"COPILOT_HOME",installMarker:"session-state",homeIsDiscoverable:!0},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},contextWindow:{defaultLimit:2e5,limits:[],compactBuffer:0,extendedContext:null},capabilities:{worktrees:!1,mcp:!1,slashCommands:!1,workflows:!1,agentTeams:!1,subagentTranscripts:!1,sharing:!1,goals:!1,undo:!0,redo:!1,nativeRewind:!0,fileCheckpoints:!1,reasoningEffort:!1,fastTier:!1,imageInput:!1,planMode:!0,midTurnSteering:!0,stopSession:!0,ultracode:!1,contextWindow:!1,externalProcesses:!0,modelFallbackNotices:!1,autoPermissionMode:"always",settingsApply:"next-turn"}},Zo=Object.freeze({claude:fh,codex:ay,copilot:ly});function An(n){return Zo[n]}function cy(){return Is.map(n=>Zo[n])}function ws(n){for(const e of Is)if(e!=="claude"&&Zo[e].dirName.owns(n))return Zo[e];return fh}function St(n){return ws(n).kind}function za(n,e,t){return n==="claude"&&t?t:Zo[n].dirName.encode(e)}const Fs=ws(null).kind;function uo(n){return ws(n).capabilities}function zt(n){return An(n).capabilities}function dy(n,e){return Is.find(t=>t===n)??e}function Rl(n){for(const e of cy()){const t=e.sessionFile.sessionId(n);if(t)return t}return n.replace(/\.jsonl$/,"")}function uy(n,e){return ws(n).sessionFile.urlId(e)}function fy(n,e){return ws(n).sessionFile.fileNameFromUrlId(e)}function mh(n,e,t){return An(n).resume.command(e,t)}function my(n,e){const t=An(n);return{command:t.binName,args:[...t.resume.args(e)]}}function Wu(n){return n.replace(/\/+$/,"")||"/"}function py(n,e,t){var o;const s=Wu(e);return((o=n.find(i=>ws(i.dirName).kind===t&&Wu(i.path)===s))==null?void 0:o.dirName)??null}function G(...n){return Q2(Z2(n))}const hy=[{value:"",label:"Default"},{value:"fable",label:"Fable"},{value:"fable[1m]",label:"Fable 1M"},{value:"opus",label:"Opus"},{value:"opus[1m]",label:"Opus 1M"},{value:"sonnet",label:"Sonnet"},{value:"sonnet[1m]",label:"Sonnet 1M"},{value:"haiku",label:"Haiku"}],kc=[{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"}],ph=[...kc,{value:"ultra",label:"Ultra",description:"Maximum reasoning with automatic task delegation"}],Kr=kc.slice(0,4),Io=[{value:"priority",label:"Fast",description:"1.5× speed with increased usage"}],Hu={isDefault:!0,defaultReasoningEffort:"medium",supportedReasoningEfforts:ph,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:Io},gy=[{value:"",label:"Default",description:"Use Codex's recommended model (GPT-5.6 Sol)",resolvedModel:"gpt-5.6-sol",...Hu},{value:"gpt-5.6-sol",label:"GPT-5.6 Sol",description:"Flagship model for the most ambitious work",...Hu},{value:"gpt-5.6-terra",label:"GPT-5.6 Terra",description:"Balanced model for everyday work",defaultReasoningEffort:"medium",supportedReasoningEfforts:ph,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:Io},{value:"gpt-5.6-luna",label:"GPT-5.6 Luna",description:"Fastest, most cost-efficient model",defaultReasoningEffort:"medium",supportedReasoningEfforts:kc,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:Io},{value:"gpt-5.5",label:"GPT-5.5",description:"Frontier model for complex real-world work",defaultReasoningEffort:"medium",supportedReasoningEfforts:Kr,inputModalities:["text","image"],supportsPersonality:!0,serviceTiers:Io},{value:"gpt-5.4",label:"GPT-5.4",description:"Strong model for everyday coding",defaultReasoningEffort:"medium",supportedReasoningEfforts:Kr,inputModalities:["text","image"],supportsPersonality:!0,serviceTiers:Io},{value:"gpt-5.4-mini",label:"GPT-5.4 Mini",description:"Small, fast model for simpler tasks",defaultReasoningEffort:"medium",supportedReasoningEfforts:Kr,inputModalities:["text","image"],supportsPersonality:!0},{value:"gpt-5.3-codex-spark",label:"GPT-5.3 Codex Spark",description:"Ultra-fast text-only coding model",defaultReasoningEffort:"high",supportedReasoningEfforts:Kr,inputModalities:["text"],supportsPersonality:!0}],xy=[{value:"",label:"Default",supportsEffort:!1,inputModalities:["text"]},{value:"auto",label:"Auto",description:"Let Copilot choose the best available model",supportsEffort:!1,inputModalities:["text"]}],by={claude:hy,codex:gy,copilot:xy},hh={claude:null,codex:null,copilot:null},Ml=new Set;function Fa(n,e){!Array.isArray(e)||e.length===0||(hh[n]=e,Ml.forEach(t=>t()))}function vy(n){return Ml.add(n),()=>Ml.delete(n)}const Ba="high",yy=[{value:"low",label:"Light"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"xhigh",label:"Extra High"},{value:"max",label:"Max"}];function gh(n){return hh[n]??by[n]}function xr(n,e){const t=gh(n);return e?t.find(s=>s.value===e):t.find(s=>s.value!==""&&s.isDefault)??t.find(s=>s.value==="")??t.find(s=>s.value!=="")}function xh(n,e){const t=xr(n,e),s=t==null?void 0:t.supportedReasoningEfforts;return s&&s.length>0?s:(t==null?void 0:t.supportsEffort)===!1||!zt(n).reasoningEffort?[]:yy}function wy(n,e){var t;return((t=xr(n,e))==null?void 0:t.serviceTiers)??[]}function bh(n,e){return wy(n,e).find(t=>t.value==="fast"||t.value==="priority"||t.label.toLowerCase()==="fast")}function jy(n,e){var s;const t=(s=xr(n,e))==null?void 0:s.inputModalities;return t?t.includes("image"):zt(n).imageInput}function Sy(n,e){var s;const t=zt(n).autoPermissionMode;return t==="always"?!0:t==="never"?!1:((s=xr(n,e))==null?void 0:s.supportsAutoMode)===!0}function ky(n,e){return zt(n).ultracode?!(e??"").toLowerCase().startsWith("haiku"):!1}function Yi(n,e,t){var l,c;const s=xh(n,t);if(s.length===0)return"";const o=(l=xr(n,t))==null?void 0:l.defaultReasoningEffort,i=o&&s.some(d=>d.value===o)?o:s.some(d=>d.value===Ba)?Ba:((c=s[0])==null?void 0:c.value)??Ba,a=e||i;return s.some(d=>d.value===a)?a:i}function Ny(n){return n.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").slice(0,40).replace(/-$/,"")}async function br(n){try{return await navigator.clipboard.writeText(n),!0}catch{const e=document.createElement("textarea");e.value=n,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select();const t=document.execCommand("copy");return document.body.removeChild(e),t}}const Cy=Bn("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 X(n){const e=U.c(12);let t,s,o,i;e[0]!==n?({className:t,variant:i,size:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);let a;e[5]!==t||e[6]!==o||e[7]!==i?(a=G(Cy({variant:i,size:o,className:t})),e[5]=t,e[6]=o,e[7]=i,e[8]=a):a=e[8];let l;return e[9]!==s||e[10]!==a?(l=r.jsx(eb,{"data-slot":"button",className:a,...s}),e[9]=s,e[10]=a,e[11]=l):l=e[11],l}function Hn(n){const e=U.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 o;e[3]!==t?(o=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",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"empty",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Kn(n){const e=U.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 o;e[3]!==t?(o=G("flex max-w-sm flex-col items-center gap-2",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"empty-header",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const _y=Bn("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 js(n){const e=U.c(11);let t,s,o;e[0]!==n?({className:t,variant:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"default":o;let a;e[4]!==t||e[5]!==i?(a=G(_y({variant:i,className:t})),e[4]=t,e[5]=i,e[6]=a):a=e[6];let l;return e[7]!==s||e[8]!==a||e[9]!==i?(l=r.jsx("div",{"data-slot":"empty-icon","data-variant":i,className:a,...s}),e[7]=s,e[8]=a,e[9]=i,e[10]=l):l=e[10],l}function qn(n){const e=U.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 o;e[3]!==t?(o=G("text-sm font-medium tracking-tight",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"empty-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Vn(n){const e=U.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 o;e[3]!==t?(o=G("text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"empty-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function vh(n){const e=U.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 o;e[3]!==t?(o=G("flex w-full max-w-sm min-w-0 flex-col items-center gap-2.5 text-sm text-balance",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"empty-content",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Ty(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 Ey=n=>{switch(n){case"success":return Ry;case"info":return Iy;case"warning":return My;case"error":return $y;default:return null}},Py=Array(12).fill(0),Ay=({visible:n,className:e})=>be.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":n},be.createElement("div",{className:"sonner-spinner"},Py.map((t,s)=>be.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${s}`})))),Ry=be.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},be.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"})),My=be.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},be.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"})),Iy=be.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},be.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"})),$y=be.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},be.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"})),Oy=be.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"},be.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),be.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),Dy=()=>{const[n,e]=be.useState(document.hidden);return be.useEffect(()=>{const t=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[]),n};let Ly=1;const zy=100,Ku=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:Ly++};class Fy{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-zy;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,o=Ku(e),i=this.pendingDismissals.get(o);i!==void 0&&(cancelAnimationFrame(i),this.pendingDismissals.delete(o),this.dismissedToasts.delete(o));const a=this.dismissedToasts.has(o),l=e.dismissible===void 0?!0:e.dismissible;return a&&(this.dismissedToasts.delete(o),this.toasts=this.toasts.filter(d=>d.id!==o)),(a?void 0:this.toasts.find(d=>d.id===o))?this.toasts=this.toasts.map(d=>d.id===o?(this.publish({...d,...e,id:o,title:t}),{...d,...e,id:o,dismissible:l,title:t}):d):this.addToast({title:t,...s,dismissible:l,id:o}),o},this.dismiss=e=>{if(e==null)return this.getActiveToasts().forEach(s=>{this.dismissedToasts.add(s.id),this.subscribers.forEach(o=>o({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 o=Promise.resolve(e instanceof Function?e():e);let i=s!==void 0,a;const l=o.then(async d=>{if(a=["resolve",d],be.isValidElement(d))i=!1,this.create({id:s,type:"default",message:d});else if(Uy(d)&&!d.ok){i=!1;const u=typeof t.error=="function"?await t.error(`HTTP error! status: ${d.status}`):t.error,m=typeof t.description=="function"?await t.description(`HTTP error! status: ${d.status}`):t.description,h=typeof u=="object"&&!be.isValidElement(u)?u:{message:u};this.create({id:s,type:"error",description:m,...h})}else if(d instanceof Error){i=!1;const u=typeof t.error=="function"?await t.error(d):t.error,m=typeof t.description=="function"?await t.description(d):t.description,h=typeof u=="object"&&!be.isValidElement(u)?u:{message:u};this.create({id:s,type:"error",description:m,...h})}else if(t.success!==void 0){i=!1;const u=typeof t.success=="function"?await t.success(d):t.success,m=typeof t.description=="function"?await t.description(d):t.description,h=typeof u=="object"&&!be.isValidElement(u)?u:{message:u};this.create({id:s,type:"success",description:m,...h})}}).catch(async d=>{if(a=["reject",d],t.error!==void 0){i=!1;const f=typeof t.error=="function"?await t.error(d):t.error,u=typeof t.description=="function"?await t.description(d):t.description,p=typeof f=="object"&&!be.isValidElement(f)?f:{message:f};this.create({id:s,type:"error",description:u,...p})}}).finally(()=>{i&&(this.dismiss(s),s=void 0),t.finally==null||t.finally.call(t)}),c=()=>new Promise((d,f)=>l.then(()=>a[0]==="reject"?f(a[1]):d(a[1])).catch(f));return typeof s!="string"&&typeof s!="number"?{unwrap:c}:Object.assign(s,{unwrap:c})},this.custom=(e,t)=>{const s=Ku(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 Kt=new Fy,By=(n,e)=>Kt.message(n,e),Uy=n=>n&&typeof n=="object"&&"ok"in n&&typeof n.ok=="boolean"&&"status"in n&&typeof n.status=="number",Wy=By,Hy=()=>Kt.toasts,Ky=()=>Kt.getActiveToasts(),Cs=Object.assign(Wy,{success:Kt.success,info:Kt.info,warning:Kt.warning,error:Kt.error,custom:Kt.custom,message:Kt.message,promise:Kt.promise,dismiss:Kt.dismiss,loading:Kt.loading},{getHistory:Hy,getToasts:Ky});Ty("[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 qr(n){return n.label!==void 0}const qy=3,Vy="24px",Gy="16px",qu=4e3,Yy=356,Xy=14,Jy=45,Qy=200;function kn(...n){return n.filter(Boolean).join(" ")}function Zy(n){const[e,t]=n.split("-"),s=[];return e&&s.push(e),t&&s.push(t),s}const ew=n=>{var e,t,s,o,i,a,l,c,d;const{invert:f,toast:u,unstyled:m,interacting:p,setHeights:h,visibleToasts:g,heights:x,index:v,toasts:w,expanded:y,removeToast:j,defaultRichColors:k,closeButton:N,style:C,cancelButtonStyle:S,actionButtonStyle:_,className:P="",descriptionClassName:A="",duration:E,position:T,gap:M,expandByDefault:I,classNames:R,icons:$,closeButtonAriaLabel:D="Close toast"}=n,[O,L]=be.useState(null),[z,F]=be.useState(null),[H,B]=be.useState(!1),[W,K]=be.useState(!1),[V,Y]=be.useState(!1),[q,J]=be.useState(!1),[Z,Q]=be.useState(!1),[ee,oe]=be.useState(0),[se,re]=be.useState(0),ie=be.useRef(u.duration||E||qu),ae=be.useRef(null),te=be.useRef(null),he=v===0,me=v+1<=g,le=u.type,xe=le??"default",ge=u.dismissible!==!1,ce=u.className||"",we=u.descriptionClassName||"",pe=be.useMemo(()=>x.findIndex(ne=>ne.toastId===u.id)||0,[x,u.id]),ue=be.useMemo(()=>{var ne;return(ne=u.closeButton)!=null?ne:N},[u.closeButton,N]),je=be.useMemo(()=>u.duration||E||qu,[u.duration,E]),Ne=be.useRef(0),Re=be.useRef(0),Te=be.useRef(0),Pe=be.useRef(null),[Oe,Fe]=T.split("-"),ze=be.useMemo(()=>x.reduce((ne,fe,Se)=>Se>=pe?ne:ne+fe.height,0),[x,pe]),Be=Dy(),_e=be.useMemo(()=>{var ne;return(ne=n.swipeDirections)!=null?ne:Zy(T)},[n.swipeDirections,T]),He=u.invert||f,Ie=le==="loading";Re.current=be.useMemo(()=>pe*M+ze,[pe,ze]),be.useEffect(()=>{ie.current=je},[je]),be.useEffect(()=>{B(!0)},[]),be.useEffect(()=>{const ne=te.current;if(ne){const fe=ne.getBoundingClientRect().height;return re(fe),h(Se=>[{toastId:u.id,height:fe,position:u.position},...Se]),()=>h(Se=>Se.filter($e=>$e.toastId!==u.id))}},[h,u.id]),be.useLayoutEffect(()=>{if(!H)return;const ne=te.current,fe=ne.style.height;ne.style.height="auto";const Se=ne.getBoundingClientRect().height;ne.style.height=fe,re(Se),h($e=>$e.find(We=>We.toastId===u.id)?$e.map(We=>We.toastId===u.id?{...We,height:Se}:We):[{toastId:u.id,height:Se,position:u.position},...$e])},[H,u.title,u.description,h,u.id,u.jsx,u.action,u.cancel]);const Ce=be.useCallback(()=>{K(!0),oe(Re.current),h(ne=>ne.filter(fe=>fe.toastId!==u.id)),setTimeout(()=>{j(u)},Qy)},[u,j,h,Re]);be.useEffect(()=>{if(u.promise&&le==="loading"||u.duration===1/0||u.type==="loading")return;let ne;return y||p||Be?(()=>{if(Te.current<Ne.current){const $e=new Date().getTime()-Ne.current;ie.current=ie.current-$e}Te.current=new Date().getTime()})():(()=>{ie.current!==1/0&&(Ne.current=new Date().getTime(),ne=setTimeout(()=>{u.onAutoClose==null||u.onAutoClose.call(u,u),Ce()},ie.current))})(),()=>clearTimeout(ne)},[y,p,u,le,Be,Ce]),be.useEffect(()=>{u.delete&&(Ce(),u.onDismiss==null||u.onDismiss.call(u,u))},[Ce,u.delete]);function de(){var ne;if($!=null&&$.loading){var fe;return be.createElement("div",{className:kn(R==null?void 0:R.loader,u==null||(fe=u.classNames)==null?void 0:fe.loader,"sonner-loader"),"data-visible":le==="loading"},$.loading)}return be.createElement(Ay,{className:kn(R==null?void 0:R.loader,u==null||(ne=u.classNames)==null?void 0:ne.loader),visible:le==="loading"})}const Ee=u.icon||($==null?void 0:$[le])||Ey(le);var Ae,Le;return be.createElement("li",{tabIndex:0,ref:te,className:kn(P,ce,R==null?void 0:R.toast,u==null||(e=u.classNames)==null?void 0:e.toast,R==null?void 0:R[xe],u==null||(t=u.classNames)==null?void 0:t[xe]),"data-sonner-toast":"","data-rich-colors":(Ae=u.richColors)!=null?Ae:k,"data-styled":!(u.jsx||u.unstyled||m),"data-mounted":H,"data-promise":!!u.promise,"data-swiped":Z,"data-removed":W,"data-visible":me,"data-y-position":Oe,"data-x-position":Fe,"data-index":v,"data-front":he,"data-swiping":V,"data-dismissible":ge,"data-type":le,"data-invert":He,"data-swipe-out":q,"data-swipe-direction":z,"data-expanded":!!(y||I&&H),"data-testid":u.testId,style:{"--index":v,"--toasts-before":v,"--z-index":w.length-v,"--offset":`${W?ee:Re.current}px`,"--initial-height":I?"auto":`${se}px`,...C,...u.style},onDragEnd:()=>{Y(!1),L(null),Pe.current=null},onPointerDown:ne=>{ne.button!==2&&(Ie||!ge||(ae.current=new Date,oe(Re.current),ne.target.setPointerCapture(ne.pointerId),ne.target.tagName!=="BUTTON"&&(Y(!0),Pe.current={x:ne.clientX,y:ne.clientY})))},onPointerUp:()=>{var ne,fe,Se;if(q||!ge)return;Pe.current=null;const $e=Number(((ne=te.current)==null?void 0:ne.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Ue=Number(((fe=te.current)==null?void 0:fe.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),We=new Date().getTime()-((Se=ae.current)==null?void 0:Se.getTime()),Xe=O==="x"?$e:Ue,Je=Math.abs(Xe)/We;if((O==="x"?_e.includes($e>0?"right":"left"):_e.includes(Ue>0?"bottom":"top"))&&(Math.abs(Xe)>=Jy||Je>.11)){oe(Re.current),u.onDismiss==null||u.onDismiss.call(u,u),F(O==="x"?$e>0?"right":"left":Ue>0?"down":"up"),Ce(),J(!0);return}else{var qe,ot;(qe=te.current)==null||qe.style.setProperty("--swipe-amount-x","0px"),(ot=te.current)==null||ot.style.setProperty("--swipe-amount-y","0px")}Q(!1),Y(!1),L(null)},onPointerMove:ne=>{var fe,Se,$e;if(!Pe.current||!ge||((fe=window.getSelection())==null?void 0:fe.toString().length)>0)return;const We=ne.clientY-Pe.current.y,Xe=ne.clientX-Pe.current.x;!O&&(Math.abs(Xe)>1||Math.abs(We)>1)&&L(Math.abs(Xe)>Math.abs(We)?"x":"y");let Je={x:0,y:0};const De=qe=>1/(1.5+Math.abs(qe)/20);if(O==="y"){if(_e.includes("top")||_e.includes("bottom"))if(_e.includes("top")&&We<0||_e.includes("bottom")&&We>0)Je.y=We;else{const qe=We*De(We);Je.y=Math.abs(qe)<Math.abs(We)?qe:We}}else if(O==="x"&&(_e.includes("left")||_e.includes("right")))if(_e.includes("left")&&Xe<0||_e.includes("right")&&Xe>0)Je.x=Xe;else{const qe=Xe*De(Xe);Je.x=Math.abs(qe)<Math.abs(Xe)?qe:Xe}(Math.abs(Je.x)>0||Math.abs(Je.y)>0)&&Q(!0),(Se=te.current)==null||Se.style.setProperty("--swipe-amount-x",`${Je.x}px`),($e=te.current)==null||$e.style.setProperty("--swipe-amount-y",`${Je.y}px`)}},ue&&!u.jsx&&le!=="loading"?be.createElement("button",{"aria-label":D,"data-disabled":Ie,"data-close-button":!0,onClick:Ie||!ge?()=>{}:()=>{Ce(),u.onDismiss==null||u.onDismiss.call(u,u)},className:kn(R==null?void 0:R.closeButton,u==null||(s=u.classNames)==null?void 0:s.closeButton)},(Le=$==null?void 0:$.close)!=null?Le:Oy):null,(le||u.icon||u.promise)&&u.icon!==null&&(($==null?void 0:$[le])!==null||u.icon)?be.createElement("div",{"data-icon":"",className:kn(R==null?void 0:R.icon,u==null||(o=u.classNames)==null?void 0:o.icon)},le==="loading"?u.icon||de():u.promise?de():null,le!=="loading"?Ee:null):null,be.createElement("div",{"data-content":"",className:kn(R==null?void 0:R.content,u==null||(i=u.classNames)==null?void 0:i.content)},be.createElement("div",{"data-title":"",className:kn(R==null?void 0:R.title,u==null||(a=u.classNames)==null?void 0:a.title)},u.jsx?u.jsx:typeof u.title=="function"?u.title():u.title),u.description?be.createElement("div",{"data-description":"",className:kn(A,we,R==null?void 0:R.description,u==null||(l=u.classNames)==null?void 0:l.description)},typeof u.description=="function"?u.description():u.description):null),be.isValidElement(u.cancel)?u.cancel:u.cancel&&qr(u.cancel)?be.createElement("button",{"data-button":!0,"data-cancel":!0,style:u.cancelButtonStyle||S,onClick:ne=>{qr(u.cancel)&&ge&&(u.cancel.onClick==null||u.cancel.onClick.call(u.cancel,ne),Ce())},className:kn(R==null?void 0:R.cancelButton,u==null||(c=u.classNames)==null?void 0:c.cancelButton)},u.cancel.label):null,be.isValidElement(u.action)?u.action:u.action&&qr(u.action)?be.createElement("button",{"data-button":!0,"data-action":!0,style:u.actionButtonStyle||_,onClick:ne=>{qr(u.action)&&(u.action.onClick==null||u.action.onClick.call(u.action,ne),!ne.defaultPrevented&&Ce())},className:kn(R==null?void 0:R.actionButton,u==null||(d=u.classNames)==null?void 0:d.actionButton)},u.action.label):null)};function Vu(){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 tw(n,e){const t={};return[n,e].forEach((s,o)=>{const i=o===1,a=i?"--mobile-offset":"--offset",l=i?Gy:Vy;function c(d){["top","right","bottom","left"].forEach(f=>{t[`${a}-${f}`]=typeof d=="number"?`${d}px`:d})}typeof s=="number"||typeof s=="string"?c(s):typeof s=="object"?["top","right","bottom","left"].forEach(d=>{s[d]===void 0?t[`${a}-${d}`]=l:t[`${a}-${d}`]=typeof s[d]=="number"?`${s[d]}px`:s[d]}):c(l)}),t}const nw=be.forwardRef(function(e,t){const{id:s,invert:o,position:i="bottom-right",hotkey:a=["altKey","KeyT"],expand:l,closeButton:c,className:d,offset:f,mobileOffset:u,theme:m="light",richColors:p,duration:h,style:g,visibleToasts:x=qy,toastOptions:v,dir:w=Vu(),gap:y=Xy,icons:j,customAriaLabel:k,containerAriaLabel:N="Notifications"}=e,[C,S]=be.useState([]),_=be.useMemo(()=>s?C.filter(B=>B.toasterId===s):C.filter(B=>!B.toasterId),[C,s]),P=be.useMemo(()=>Array.from(new Set([i].concat(_.filter(B=>B.position).map(B=>B.position)))),[_,i]),[A,E]=be.useState([]),[T,M]=be.useState(!1),[I,R]=be.useState(!1),[$,D]=be.useState(m!=="system"?m:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),O=be.useRef(null),L=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),z=be.useRef(null),F=be.useRef(!1),H=be.useCallback(B=>{S(W=>{var K;return(K=W.find(V=>V.id===B.id))!=null&&K.delete||Kt.dismiss(B.id),W.filter(({id:V})=>V!==B.id)})},[]);return be.useEffect(()=>Kt.subscribe(B=>{if(B.dismiss){requestAnimationFrame(()=>{S(W=>W.map(K=>K.id===B.id?{...K,delete:!0}:K))});return}setTimeout(()=>{Y2.flushSync(()=>{S(W=>{const K=W.findIndex(V=>V.id===B.id);return K!==-1?[...W.slice(0,K),{...W[K],...B},...W.slice(K+1)]:[B,...W]})})})}),[]),be.useEffect(()=>{if(m!=="system"){D(m);return}if(m==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?D("dark"):D("light")),typeof window>"u")return;const B=window.matchMedia("(prefers-color-scheme: dark)");try{B.addEventListener("change",({matches:W})=>{D(W?"dark":"light")})}catch{B.addListener(({matches:K})=>{try{D(K?"dark":"light")}catch(V){console.error(V)}})}},[m]),be.useEffect(()=>{C.length<=1&&M(!1)},[C]),be.useEffect(()=>{const B=W=>{var K;if(a.length>0&&a.every(q=>W[q]||W.code===q)){var Y;M(!0),(Y=O.current)==null||Y.focus()}W.code==="Escape"&&(document.activeElement===O.current||(K=O.current)!=null&&K.contains(document.activeElement))&&M(!1)};return document.addEventListener("keydown",B),()=>document.removeEventListener("keydown",B)},[a]),be.useEffect(()=>{if(O.current)return()=>{z.current&&(z.current.focus({preventScroll:!0}),z.current=null,F.current=!1)}},[O.current]),be.createElement("section",{ref:t,"aria-label":k??`${N} ${L}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0,"data-react-aria-top-layer":!0},P.map((B,W)=>{var K;const[V,Y]=B.split("-");return _.length?be.createElement("ol",{key:B,dir:w==="auto"?Vu():w,tabIndex:-1,ref:O,className:d,"data-sonner-toaster":!0,"data-sonner-theme":$,"data-y-position":V,"data-x-position":Y,style:{"--front-toast-height":`${((K=A[0])==null?void 0:K.height)||0}px`,"--width":`${Yy}px`,"--gap":`${y}px`,...g,...tw(f,u)},onBlur:q=>{F.current&&!q.currentTarget.contains(q.relatedTarget)&&(F.current=!1,z.current&&(z.current.focus({preventScroll:!0}),z.current=null))},onFocus:q=>{q.target instanceof HTMLElement&&q.target.dataset.dismissible==="false"||F.current||(F.current=!0,z.current=q.relatedTarget)},onMouseEnter:()=>M(!0),onMouseMove:()=>M(!0),onMouseLeave:()=>{I||M(!1)},onDragEnd:()=>M(!1),onPointerDown:q=>{q.target instanceof HTMLElement&&q.target.dataset.dismissible==="false"||R(!0)},onPointerUp:()=>R(!1)},_.filter(q=>!q.position&&W===0||q.position===B).map((q,J)=>{var Z,Q;return be.createElement(ew,{key:q.id,icons:j,index:J,toast:q,defaultRichColors:p,duration:(Z=v==null?void 0:v.duration)!=null?Z:h,className:v==null?void 0:v.className,descriptionClassName:v==null?void 0:v.descriptionClassName,invert:o,visibleToasts:x,closeButton:(Q=v==null?void 0:v.closeButton)!=null?Q:c,interacting:I,position:B,style:v==null?void 0:v.style,unstyled:v==null?void 0:v.unstyled,classNames:v==null?void 0:v.classNames,cancelButtonStyle:v==null?void 0:v.cancelButtonStyle,actionButtonStyle:v==null?void 0:v.actionButtonStyle,closeButtonAriaLabel:v==null?void 0:v.closeButtonAriaLabel,removeToast:H,toasts:_.filter(ee=>ee.position==q.position),heights:A.filter(ee=>ee.position==q.position),setHeights:E,expandByDefault:l,gap:y,expanded:T,swipeDirections:e.swipeDirections})})):null}))}),sw=n=>{const e=U.c(6);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s,o;e[2]===Symbol.for("react.memo_cache_sentinel")?(s={success:r.jsx(Un,{className:"size-4"}),info:r.jsx(nb,{className:"size-4"}),warning:r.jsx(wn,{className:"size-4"}),error:r.jsx(tb,{className:"size-4"}),loading:r.jsx(rt,{className:"size-4 animate-spin"})},o={"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)"},e[2]=s,e[3]=o):(s=e[2],o=e[3]);let i;return e[4]!==t?(i=r.jsx(nw,{className:"toaster group",icons:s,style:o,...t}),e[4]=t,e[5]=i):i=e[5],i};function ow(n){const e=U.c(13),{activeError:t,clearActiveError:s,modelFallbackNotice:o,dismissModelFallbackNotice:i,connectionLost:a,theme:l}=n;let c,d;e[0]!==t||e[1]!==s?(c=()=>{if(!t){Cs.dismiss("app-error");return}Cs.error(t,{id:"app-error",duration:8e3,onDismiss:s,onAutoClose:s})},d=[t,s],e[0]=t,e[1]=s,e[2]=c,e[3]=d):(c=e[2],d=e[3]),b.useEffect(c,d);let f,u;e[4]!==i||e[5]!==o?(f=()=>{if(!o){Cs.dismiss("model-fallback");return}Cs.warning(o,{id:"model-fallback",duration:1/0,onDismiss:i})},u=[i,o],e[4]=i,e[5]=o,e[6]=f,e[7]=u):(f=e[6],u=e[7]),b.useEffect(f,u);let m,p;e[8]!==a?(m=()=>{if(!a){Cs.dismiss("session-connection");return}Cs.warning("Connection lost",{id:"session-connection",description:"Reconnecting to the live session…",duration:1/0})},p=[a],e[8]=a,e[9]=m,e[10]=p):(m=e[9],p=e[10]),b.useEffect(m,p);const h=l==="light"?"light":"dark";let g;return e[11]!==h?(g=r.jsx(sw,{theme:h,position:"bottom-center",closeButton:!0,visibleToasts:3}),e[11]=h,e[12]=g):g=e[12],g}const wt="local",yh="cogpit-last-path::",Il=new Map;function ht(){var t;const n=typeof window<"u"?(t=window.location)==null?void 0:t.pathname:void 0;if(!n)return wt;const e=/^\/d\/([^/]+)/.exec(n);return e?e[1]:wt}function $s(){return ht()!==wt}function wh(){const n=ht();return n===wt?"":`/hub/${n}`}function jh(n){const e=wh();return!e||n.startsWith("/api/hub/")||n.startsWith("/api/auth/")?n:n.startsWith("/api")||n.startsWith("/__pty")?`${e}${n}`:n}let er=null;function Sh(n){n!==er&&(er=n,window.dispatchEvent(new Event("cogpit-identity-changed")))}function ms(){return er}function ci(n){return n===wt?0:Il.get(n)??0}function rw(n,e){if(n===wt||!Number.isSafeInteger(e)||e<0)return!1;const t=Il.get(n);return t!==void 0&&e<=t?!1:(Il.set(n,e),window.dispatchEvent(new CustomEvent("cogpit-device-scope-changed",{detail:{deviceId:n,connectionRevision:e}})),!0)}function fn(){const n=ht(),e=ci(n);return e===0?n:`${n}@${e}`}function Lt(n){const e=ht(),t=fn();return er!==null?`${n}::${t}::${er}`:e===wt?n:`${n}::${t}`}function No(n,e){sessionStorage.setItem(`${yh}${n}`,e)}function ps(n){const t=sessionStorage.getItem(`${yh}${n}`)??(n===wt?"/":`/d/${n}/`);window.history.pushState(null,"",t),window.dispatchEvent(new Event("cogpit-device-changed"))}const Gu="cogpit-network-token",iw=new Set(["localhost","127.0.0.1","::1","0:0:0:0:0:0:0:1"]);function Xi(){const n=window.location.hostname.toLowerCase(),e=n.startsWith("[")&&n.endsWith("]")?n.slice(1,-1):n;return!iw.has(e)}function Ji(){try{localStorage.removeItem(Gu),sessionStorage.removeItem(Gu)}catch{}}typeof window<"u"&&Ji();const aw={edition:"personal",needsBootstrap:!1};let tr=null,ro=null;function kh(){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();return ro=e.edition==="team"?"team":"personal",{edition:ro,needsBootstrap:ro==="team"&&e.needsBootstrap===!0}}).catch(()=>(tr=null,aw))}function Nh(){return tr??(tr=kh()),tr}function Yu(){return tr=kh(),tr}function Ch(){return Nh().then(n=>n.edition)}async function lw(){if(!Xi()&&ro!=="team")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 cw(){try{await fetch("/api/auth/logout",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"X-Cogpit-Client":"1"}})}finally{Ji()}}function Xu(){return Ji(),window.dispatchEvent(new Event("cogpit-auth-required")),Promise.reject(new Error("Authentication required"))}function _h(n,e,t){t&&typeof n=="string"&&n.startsWith("/api")&&(n=jh(n));const s=new Headers(e==null?void 0:e.headers);return s.delete("Authorization"),s.set("X-Cogpit-Client","1"),fetch(n,{...e,headers:s,credentials:"same-origin"}).then(o=>{if(o.status===401){if(Xi()||ro==="team")return Xu();if(ro===null)return Ch().then(i=>i==="team"?Xu():o)}if(o.status===502){const i=o.headers.get("X-Cogpit-Hub-Error"),a=o.headers.get("X-Cogpit-Device");a&&(i==="DEVICE_UNREACHABLE"||i==="DEVICE_AUTH_FAILED")&&window.dispatchEvent(new CustomEvent("cogpit-device-unreachable",{detail:{deviceId:a,reason:i}}))}return o})}function ye(n,e){return _h(n,e,!0)}function rs(n,e){return _h(n,e,!1)}function vr(n){return jh(n)}let Ju=!1;function Ua(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 dw(){if(!Ju){Ju=!0;try{const n=await ye("/api/models");if(!n.ok)return;const e=await n.json();Ua(e==null?void 0:e.claude)&&Fa("claude",e.claude),Ua(e==null?void 0:e.codex)&&Fa("codex",e.codex),Ua(e==null?void 0:e.copilot)&&Fa("copilot",e.copilot)}catch{}}}function Th(n){const e=U.c(3);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0],b.useEffect(uw,t);let s;return e[1]!==n?(s=()=>gh(n),e[1]=n,e[2]=s):s=e[2],b.useSyncExternalStore(vy,s)}function uw(){dw()}function Rn(n){const e=U.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=r.jsx(ob,{"data-slot":"dropdown-menu",...t}),e[2]=t,e[3]=s):s=e[3],s}function Mn(n){const e=U.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=r.jsx(rb,{"data-slot":"dropdown-menu-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function In(n){const e=U.c(18);let t,s,o,i,a,l;e[0]!==n?({align:o,alignOffset:i,side:a,sideOffset:l,className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a,e[6]=l):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5],l=e[6]);const c=o===void 0?"start":o,d=i===void 0?0:i,f=a===void 0?"bottom":a,u=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=r.jsx(Op,{"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]!==d||e[14]!==f||e[15]!==u||e[16]!==p?(h=r.jsx(zp,{children:r.jsx(Fp,{className:"isolate z-50 outline-none",align:c,alignOffset:d,side:f,sideOffset:u,children:p})}),e[12]=c,e[13]=d,e[14]=f,e[15]=u,e[16]=p,e[17]=h):h=e[17],h}function Bt(n){const e=U.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=r.jsx(Dp,{"data-slot":"dropdown-menu-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function hs(n){const e=U.c(10);let t,s,o;e[0]!==n?({className:t,inset:s,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==t?(i=G("px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",t),e[4]=t,e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o||e[8]!==i?(a=r.jsx(Lp,{"data-slot":"dropdown-menu-label","data-inset":s,className:i,...o}),e[6]=s,e[7]=o,e[8]=i,e[9]=a):a=e[9],a}function ct(n){const e=U.c(12);let t,s,o,i;e[0]!==n?({className:t,inset:s,variant:i,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);const a=i===void 0?"default":i;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]!==o||e[9]!==l||e[10]!==a?(c=r.jsx($p,{"data-slot":"dropdown-menu-item","data-inset":s,"data-variant":a,className:l,...o}),e[7]=s,e[8]=o,e[9]=l,e[10]=a,e[11]=c):c=e[11],c}function fw(n){const e=U.c(15);let t,s,o,i,a;e[0]!==n?({className:o,children:s,checked:t,inset:i,...a}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5]);let l;e[6]!==o?(l=G("relative flex 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 focus:**:text-accent-foreground data-inset:pl-7 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",o),e[6]=o,e[7]=l):l=e[7];let c;e[8]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx("span",{className:"pointer-events-none absolute right-2 flex items-center justify-center","data-slot":"dropdown-menu-checkbox-item-indicator",children:r.jsx(cb,{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",children:r.jsx(dt,{})})}),e[8]=c):c=e[8];let d;return e[9]!==t||e[10]!==s||e[11]!==i||e[12]!==a||e[13]!==l?(d=r.jsxs(ab,{"data-slot":"dropdown-menu-checkbox-item","data-inset":i,className:l,checked:t,...a,children:[c,s]}),e[9]=t,e[10]=s,e[11]=i,e[12]=a,e[13]=l,e[14]=d):d=e[14],d}function xi(n){const e=U.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=r.jsx(lb,{"data-slot":"dropdown-menu-radio-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function Nc(n){const e=U.c(15);let t,s,o,i,a;e[0]!==n?({className:s,children:t,inset:o,closeOnClick:a,...i}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5]);const l=a===void 0?!0:a;let c;e[6]!==s?(c=G("relative flex 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 focus:**:text-accent-foreground data-inset:pl-7 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",s),e[6]=s,e[7]=c):c=e[7];let d;e[8]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx("span",{className:"pointer-events-none absolute right-2 flex items-center justify-center","data-slot":"dropdown-menu-radio-item-indicator",children:r.jsx(ib,{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",children:r.jsx(dt,{})})}),e[8]=d):d=e[8];let f;return e[9]!==t||e[10]!==l||e[11]!==o||e[12]!==i||e[13]!==c?(f=r.jsxs(sb,{"data-slot":"dropdown-menu-radio-item","data-inset":o,closeOnClick:l,className:c,...i,children:[d,t]}),e[9]=t,e[10]=l,e[11]=o,e[12]=i,e[13]=c,e[14]=f):f=e[14],f}function io(n){const e=U.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 o;e[3]!==t?(o=G("-mx-1 my-1 h-px bg-border",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(mc,{"data-slot":"dropdown-menu-separator",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const mw={claude:lo,codex:mr,copilot:db},Cc={claude:"Claude",codex:"Codex",copilot:"Copilot"},pw={claude:"Claude",codex:"Codex",copilot:"GitHub Copilot"},hw={claude:null,codex:"Codex",copilot:"Copilot"},gw={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"}},xw={claude:"var(--chart-1)",codex:"var(--chart-2)",copilot:"var(--chart-3)"},bw={claude:"Interrupt agent",codex:"Stop active turn",copilot:"Stop Copilot turn"};function Eh(n){return Cc[n]}function qM(n){return pw[n]}function vw(n){return hw[n]}function VM(n){return gw[n]}function yw(n){return bw[n]}function ww(n){return xw[n]}const Qu=ws(null).kind,Ph=[Qu,...Is.filter(n=>n!==Qu)];function jw(n){return`This ${Cc[n]} session is controlled by another process. Cogpit can only view it.`}const $l=Ph.map(n=>({value:n,label:Cc[n],Icon:mw[n]}));function Sw(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 kw(n){var t;const e=(t=n.find(s=>s.value===""))==null?void 0:t.resolvedModel;return e?_c(e,n):"Default"}function _c(n,e){const t=Sw(n,e);if(t)return t.label;const s=n.toLowerCase();if(s.includes("opus"))return"Opus";if(s.includes("sonnet"))return"Sonnet";if(s.includes("haiku"))return"Haiku";if(s.includes("fable"))return"Fable";if(s.startsWith("gpt-")){const[o,...i]=s.slice(4).split("-"),a=i.map(l=>l.charAt(0).toUpperCase()+l.slice(1)).join(" ");return`GPT-${o}${a?` ${a}`:""}`}return n}function Ah(n){const e=U.c(11),{option:t,descriptionWidth:s}=n,o=s===void 0?"max-w-64":s,i=t.menuLabel??t.label;let a;e[0]!==i?(a=r.jsx("span",{children:i}),e[0]=i,e[1]=a):a=e[1];let l;e[2]!==o||e[3]!==t.description?(l=t.description&&r.jsx("span",{className:G(o,"truncate text-xs font-normal text-muted-foreground"),children:t.description}),e[2]=o,e[3]=t.description,e[4]=l):l=e[4];let c;e[5]!==a||e[6]!==l?(c=r.jsxs("span",{className:"flex min-w-0 flex-col items-start",children:[a,l]}),e[5]=a,e[6]=l,e[7]=c):c=e[7];let d;return e[8]!==t.value||e[9]!==c?(d=r.jsx(Nc,{value:t.value,className:"items-start py-2",children:c}),e[8]=t.value,e[9]=c,e[10]=d):d=e[10],d}function Nw(n){var A,E;const e=U.c(33),{agentKind:t,onAgentKindChange:s,value:o,fallbackLabel:i,options:a,onChange:l}=n;let c;e[0]!==t?(c=((A=$l.find(T=>T.value===t))==null?void 0:A.label)??t,e[0]=t,e[1]=c):c=e[1];const d=c;let f;e[2]!==i||e[3]!==a||e[4]!==o?(f=((E=a.find(T=>T.value===o))==null?void 0:E.label)??i,e[2]=i,e[3]=a,e[4]=o,e[5]=f):f=e[5];const u=f;let m;e[6]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(X,{type:"button",variant:"ghost",size:"xs"}),e[6]=m):m=e[6];const p=`${d} / ${u}`;let h;e[7]!==p?(h=r.jsx("span",{className:"truncate",children:p}),e[7]=p,e[8]=h):h=e[8];let g;e[9]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx(nt,{"data-icon":"inline-end"}),e[9]=g):g=e[9];let x;e[10]!==h?(x=r.jsxs(Mn,{render:m,children:[h,g]}),e[10]=h,e[11]=x):x=e[11];let v;e[12]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(hs,{children:"Agent"}),e[12]=v):v=e[12];let w;e[13]!==s?(w=T=>s(T),e[13]=s,e[14]=w):w=e[14];let y;e[15]===Symbol.for("react.memo_cache_sentinel")?(y=$l.map(_w),e[15]=y):y=e[15];let j;e[16]!==t||e[17]!==w?(j=r.jsxs(Bt,{children:[v,r.jsx(xi,{value:t,onValueChange:w,children:y})]}),e[16]=t,e[17]=w,e[18]=j):j=e[18];let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(io,{}),e[19]=k):k=e[19];let N;e[20]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(hs,{children:"Model"}),e[20]=N):N=e[20];let C;e[21]!==a?(C=a.map(Cw),e[21]=a,e[22]=C):C=e[22];let S;e[23]!==l||e[24]!==C||e[25]!==o?(S=r.jsxs(Bt,{children:[N,r.jsx(xi,{value:o,onValueChange:l,children:C})]}),e[23]=l,e[24]=C,e[25]=o,e[26]=S):S=e[26];let _;e[27]!==j||e[28]!==S?(_=r.jsxs(In,{"aria-label":"Agent and model",className:"w-72",children:[j,k,S]}),e[27]=j,e[28]=S,e[29]=_):_=e[29];let P;return e[30]!==_||e[31]!==x?(P=r.jsxs(Rn,{children:[x,_]}),e[30]=_,e[31]=x,e[32]=P):P=e[32],P}function Cw(n){return r.jsx(Ah,{option:n,descriptionWidth:"max-w-72"},n.value)}function _w(n){const e=n.Icon;return r.jsxs(Nc,{value:n.value,children:[r.jsx(e,{}),n.label]},n.value)}function Tw(n){const e=U.c(44),{servers:t,selected:s,onToggle:o,onRefresh:i,loading:a,onAuth:l}=n;let c;e[0]!==t?(c=t.filter(Ew),e[0]=t,e[1]=c):c=e[1];const d=c.length;let f;e[2]!==s?(f=new Set(s),e[2]=s,e[3]=f):f=e[3];const u=f,m=b.useId();let p,h;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(X,{type:"button",variant:"ghost",size:"xs"}),h=r.jsx(ub,{"data-icon":"inline-start"}),e[4]=p,e[5]=h):(p=e[4],h=e[5]);const g=a&&t.length===0?"MCPs":`MCPs ${s.length}/${d}`;let x;e[6]!==g?(x=r.jsx("span",{className:"truncate",children:g}),e[6]=g,e[7]=x):x=e[7];let v;e[8]!==a||e[9]!==t.length?(v=a&&t.length===0?r.jsx(Qt,{"data-icon":"inline-end",className:"animate-spin"}):r.jsx(nt,{"data-icon":"inline-end"}),e[8]=a,e[9]=t.length,e[10]=v):v=e[10];let w;e[11]!==x||e[12]!==v?(w=r.jsxs(Mn,{render:p,children:[h,x,v]}),e[11]=x,e[12]=v,e[13]=w):w=e[13];let y;e[14]!==m?(y=r.jsx(hs,{id:m,children:"MCP servers"}),e[14]=m,e[15]=y):y=e[15];const j=a?"animate-spin":void 0;let k;e[16]!==j?(k=r.jsx(Qt,{"data-icon":"inline-start",className:j}),e[16]=j,e[17]=k):k=e[17];let N;e[18]!==i||e[19]!==k?(N=r.jsxs(ct,{closeOnClick:!1,onClick:i,children:[k,"Refresh status"]}),e[18]=i,e[19]=k,e[20]=N):N=e[20];let C;e[21]!==a||e[22]!==t.length?(C=t.length===0&&r.jsx(ct,{disabled:!0,children:a?"Loading...":"No MCP servers configured"}),e[21]=a,e[22]=t.length,e[23]=C):C=e[23];let S;if(e[24]!==l||e[25]!==o||e[26]!==u||e[27]!==t){let E;e[29]!==l||e[30]!==o||e[31]!==u?(E=T=>T.status!=="connected"?r.jsxs(ct,{onClick:()=>l(T.name),className:"items-center",children:[r.jsx("span",{className:"size-2 rounded-full bg-warning"}),r.jsx("span",{className:"min-w-0 flex-1 truncate",children:T.name}),r.jsx("span",{className:"text-xs text-warning",children:"Needs auth"})]},T.name):r.jsxs(fw,{checked:u.has(T.name),onCheckedChange:()=>o(T.name),children:[r.jsx("span",{className:"size-2 rounded-full bg-success"}),r.jsx("span",{className:"truncate",children:T.name})]},T.name),e[29]=l,e[30]=o,e[31]=u,e[32]=E):E=e[32],S=t.map(E),e[24]=l,e[25]=o,e[26]=u,e[27]=t,e[28]=S}else S=e[28];let _;e[33]!==N||e[34]!==C||e[35]!==S||e[36]!==y?(_=r.jsxs(Bt,{children:[y,N,C,S]}),e[33]=N,e[34]=C,e[35]=S,e[36]=y,e[37]=_):_=e[37];let P;e[38]!==m||e[39]!==_?(P=r.jsx(In,{"aria-labelledby":m,className:"w-64",children:_}),e[38]=m,e[39]=_,e[40]=P):P=e[40];let A;return e[41]!==P||e[42]!==w?(A=r.jsxs(Rn,{children:[w,P]}),e[41]=P,e[42]=w,e[43]=A):A=e[43],A}function Ew(n){return n.status==="connected"}function Zu(n){var N;const e=U.c(31),{value:t,fallbackLabel:s,options:o,onChange:i,disabled:a,title:l,ariaLabel:c}=n;let d;e[0]!==s||e[1]!==o||e[2]!==t?(d=((N=o.find(C=>C.value===t))==null?void 0:N.label)??s,e[0]=s,e[1]=o,e[2]=t,e[3]=d):d=e[3];const f=d,u=b.useId();let m;e[4]!==l?(m=r.jsx(X,{type:"button",variant:"ghost",size:"xs",title:l}),e[4]=l,e[5]=m):m=e[5];let p;e[6]!==f?(p=r.jsx("span",{className:"truncate",children:f}),e[6]=f,e[7]=p):p=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(nt,{"data-icon":"inline-end"}),e[8]=h):h=e[8];let g;e[9]!==a||e[10]!==m||e[11]!==p?(g=r.jsxs(Mn,{disabled:a,render:m,children:[p,h]}),e[9]=a,e[10]=m,e[11]=p,e[12]=g):g=e[12];let x;e[13]!==c||e[14]!==u?(x=r.jsx(hs,{id:u,className:"sr-only",children:c}),e[13]=c,e[14]=u,e[15]=x):x=e[15];let v;e[16]!==o?(v=o.map(Pw),e[16]=o,e[17]=v):v=e[17];let w;e[18]!==i||e[19]!==v||e[20]!==t?(w=r.jsx(xi,{value:t,onValueChange:i,children:v}),e[18]=i,e[19]=v,e[20]=t,e[21]=w):w=e[21];let y;e[22]!==x||e[23]!==w?(y=r.jsxs(Bt,{children:[x,w]}),e[22]=x,e[23]=w,e[24]=y):y=e[24];let j;e[25]!==u||e[26]!==y?(j=r.jsx(In,{"aria-labelledby":u,className:"w-48",children:y}),e[25]=u,e[26]=y,e[27]=j):j=e[27];let k;return e[28]!==j||e[29]!==g?(k=r.jsxs(Rn,{children:[g,j]}),e[28]=j,e[29]=g,e[30]=k):k=e[30],k}function Pw(n){return r.jsx(Ah,{option:n},n.value)}const Aw=[{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"}],Rw=[{value:"default",label:"Workspace",description:"Write inside the project sandbox"},{value:"plan",label:"Read only",description:"Inspect and plan without writing"},{value:"bypassPermissions",label:"Full access",description:"No sandbox or approval checks"}],Mw=[{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 Rh(n,e){return n==="codex"?Rw:n==="copilot"?Mw:Aw.filter(t=>t.value!=="auto"||e)}function Iw(n){const e=U.c(39),{agentKind:t,mode:s,onChange:o,autoAvailable:i}=n,a=i===void 0?!1:i;let l,c,d,f,u,m,p,h,g,x,v;if(e[0]!==t||e[1]!==a||e[2]!==s||e[3]!==o){const N=Rh(t,a),C=N.find(A=>A.value===s)??N[0];f=Rn;let S,_;e[15]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(X,{type:"button",variant:"ghost",size:"xs"}),S=r.jsx(Bp,{"data-icon":"inline-start"}),e[15]=S,e[16]=_):(S=e[15],_=e[16]);let P;e[17]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(nt,{"data-icon":"inline-end"}),e[17]=P):P=e[17],v=r.jsxs(Mn,{render:_,children:[S,r.jsx("span",{className:"truncate",children:C.label}),P]}),d=In,g="Access policy",x="w-72",c=Bt,e[18]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(hs,{children:"Permissions"}),e[18]=h):h=e[18],l=xi,u=s,e[19]!==o?(m=A=>o(A),e[19]=o,e[20]=m):m=e[20],p=N.map($w),e[0]=t,e[1]=a,e[2]=s,e[3]=o,e[4]=l,e[5]=c,e[6]=d,e[7]=f,e[8]=u,e[9]=m,e[10]=p,e[11]=h,e[12]=g,e[13]=x,e[14]=v}else l=e[4],c=e[5],d=e[6],f=e[7],u=e[8],m=e[9],p=e[10],h=e[11],g=e[12],x=e[13],v=e[14];let w;e[21]!==l||e[22]!==u||e[23]!==m||e[24]!==p?(w=r.jsx(l,{value:u,onValueChange:m,children:p}),e[21]=l,e[22]=u,e[23]=m,e[24]=p,e[25]=w):w=e[25];let y;e[26]!==c||e[27]!==h||e[28]!==w?(y=r.jsxs(c,{children:[h,w]}),e[26]=c,e[27]=h,e[28]=w,e[29]=y):y=e[29];let j;e[30]!==d||e[31]!==y||e[32]!==g||e[33]!==x?(j=r.jsx(d,{"aria-label":g,className:x,children:y}),e[30]=d,e[31]=y,e[32]=g,e[33]=x,e[34]=j):j=e[34];let k;return e[35]!==f||e[36]!==j||e[37]!==v?(k=r.jsxs(f,{children:[v,j]}),e[35]=f,e[36]=j,e[37]=v,e[38]=k):k=e[38],k}function $w(n){return r.jsx(Nc,{value:n.value,className:"items-start py-2",children:r.jsxs("span",{className:"flex min-w-0 flex-col items-start",children:[r.jsx("span",{children:n.label}),r.jsx("span",{className:"max-w-64 truncate text-xs font-normal text-muted-foreground",children:n.description})]})},n.value)}function Ow(n){const e=U.c(62),{agentKind:t,onAgentKindChange:s,selectedModel:o,resolvedDefaultName:i,modelOptions:a,onModelChange:l,selectedEffort:c,effortOptions:d,onEffortChange:f,fastTier:u,fastModeEnabled:m,onFastModeEnabledChange:p,isNewSession:h,worktreeEnabled:g,onWorktreeEnabledChange:x,ultracodeEnabled:v,onUltracodeEnabledChange:w,autoModeAvailable:y,permissionMode:j,onPermissionModeChange:k,mcpServers:N,selectedMcpServers:C,onToggleMcpServer:S,onRefreshMcpServers:_,mcpLoading:P,onMcpAuth:A,changeAndApply:E,trailingExtra:T}=n;let M;e[0]!==t?(M=zt(t),e[0]=t,e[1]=M):M=e[1];const{worktrees:I,ultracode:R,settingsApply:$}=M,D=b.useId(),O=h?void 0:$==="live"?"Changes apply live":"Changes apply next turn",L=O?D:void 0;let z;e[2]!==O||e[3]!==D?(z=O&&r.jsx("span",{id:D,className:"sr-only",children:O}),e[2]=O,e[3]=D,e[4]=z):z=e[4];let F;e[5]!==t||e[6]!==a||e[7]!==s||e[8]!==l||e[9]!==i||e[10]!==o?(F=s?r.jsx(Nw,{agentKind:t,onAgentKindChange:s,value:o,fallbackLabel:i,options:a,onChange:l}):r.jsx(Zu,{value:o,fallbackLabel:"Model",ariaLabel:"Model",options:a,onChange:l}),e[5]=t,e[6]=a,e[7]=s,e[8]=l,e[9]=i,e[10]=o,e[11]=F):F=e[11];let H;e[12]!==t||e[13]!==d||e[14]!==f||e[15]!==c||e[16]!==o||e[17]!==v?(H=d.length>0&&r.jsx(Zu,{value:Yi(t,c,o),fallbackLabel:"Effort",ariaLabel:"Reasoning effort",options:d,onChange:f,disabled:v,title:v?"Effort is pinned to XHigh while Ultracode is on":void 0}),e[12]=t,e[13]=d,e[14]=f,e[15]=c,e[16]=o,e[17]=v,e[18]=H):H=e[18];let B;e[19]!==E||e[20]!==m||e[21]!==u||e[22]!==p?(B=u&&p&&r.jsxs(X,{type:"button",variant:m?"secondary":"ghost",size:"xs","aria-pressed":!!m,onClick:()=>E(()=>p(!m)),title:u.description,children:[r.jsx(gi,{"data-icon":"inline-start",className:G(m&&"fill-current")}),m?"Fast":"Standard"]}),e[19]=E,e[20]=m,e[21]=u,e[22]=p,e[23]=B):B=e[23];let W;e[24]!==t||e[25]!==y||e[26]!==E||e[27]!==k||e[28]!==j?(W=k&&j&&r.jsx(Iw,{agentKind:t,mode:j,onChange:Z=>E(()=>k(Z)),autoAvailable:y}),e[24]=t,e[25]=y,e[26]=E,e[27]=k,e[28]=j,e[29]=W):W=e[29];let K;e[30]!==h||e[31]!==x||e[32]!==I||e[33]!==g?(K=I&&h&&x&&r.jsxs(X,{type:"button",variant:g?"secondary":"ghost",size:"xs","aria-pressed":!!g,onClick:()=>x(!g),children:[r.jsx(bo,{"data-icon":"inline-start"}),"Worktree"]}),e[30]=h,e[31]=x,e[32]=I,e[33]=g,e[34]=K):K=e[34];let V;e[35]!==E||e[36]!==w||e[37]!==R||e[38]!==v?(V=R&&w&&r.jsxs(X,{type:"button",variant:v?"secondary":"ghost",size:"xs","aria-pressed":!!v,onClick:()=>E(()=>w(!v)),title:"Ultracode: XHigh effort + standing multi-agent workflow orchestration",children:[r.jsx(gi,{"data-icon":"inline-start",className:G(v&&"fill-current")}),"Ultracode"]}),e[35]=E,e[36]=w,e[37]=R,e[38]=v,e[39]=V):V=e[39];let Y;e[40]!==E||e[41]!==P||e[42]!==N||e[43]!==A||e[44]!==_||e[45]!==S||e[46]!==C?(Y=S&&_&&A&&(P||N&&N.length>0)&&r.jsx(Tw,{servers:N??[],selected:C??[],onToggle:Z=>E(()=>S(Z)),onRefresh:_,loading:P??!1,onAuth:A}),e[40]=E,e[41]=P,e[42]=N,e[43]=A,e[44]=_,e[45]=S,e[46]=C,e[47]=Y):Y=e[47];let q;e[48]!==Y||e[49]!==F||e[50]!==H||e[51]!==B||e[52]!==W||e[53]!==K||e[54]!==V||e[55]!==T?(q=r.jsxs("div",{className:"flex w-full flex-wrap items-center gap-1.5",children:[F,H,B,W,K,V,Y,T]}),e[48]=Y,e[49]=F,e[50]=H,e[51]=B,e[52]=W,e[53]=K,e[54]=V,e[55]=T,e[56]=q):q=e[56];let J;return e[57]!==O||e[58]!==q||e[59]!==L||e[60]!==z?(J=r.jsxs("div",{className:"flex items-center pb-1.5 pl-6 pr-3",role:"group",title:O,"aria-describedby":L,children:[z,q]}),e[57]=O,e[58]=q,e[59]=L,e[60]=z,e[61]=J):J=e[61],J}function It(n){const e=U.c(10);let t,s,o;e[0]!==n?({className:t,orientation:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"horizontal":o;let a;e[4]!==t?(a=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]=a):a=e[5];let l;return e[6]!==i||e[7]!==s||e[8]!==a?(l=r.jsx(mc,{"data-slot":"separator",orientation:i,className:a,...s}),e[6]=i,e[7]=s,e[8]=a,e[9]=l):l=e[9],l}function Dw(n){const e=U.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 o;e[3]!==t?(o=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]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("label",{"data-slot":"label",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Lw(n){const e=U.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 o;e[3]!==t?(o=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]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("fieldset",{"data-slot":"field-set",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function zw(n){const e=U.c(10);let t,s,o;e[0]!==n?({className:t,variant:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"legend":o;let a;e[4]!==t?(a=G("mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base",t),e[4]=t,e[5]=a):a=e[5];let l;return e[6]!==s||e[7]!==a||e[8]!==i?(l=r.jsx("legend",{"data-slot":"field-legend","data-variant":i,className:a,...s}),e[6]=s,e[7]=a,e[8]=i,e[9]=l):l=e[9],l}function wo(n){const e=U.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 o;e[3]!==t?(o=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]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"field-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const Fw=Bn("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 gt(n){const e=U.c(11);let t,s,o;e[0]!==n?({className:t,orientation:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"vertical":o;let a;e[4]!==t||e[5]!==i?(a=G(Fw({orientation:i}),t),e[4]=t,e[5]=i,e[6]=a):a=e[6];let l;return e[7]!==i||e[8]!==s||e[9]!==a?(l=r.jsx("div",{role:"group","data-slot":"field","data-orientation":i,className:a,...s}),e[7]=i,e[8]=s,e[9]=a,e[10]=l):l=e[10],l}function GM(n){const e=U.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 o;e[3]!==t?(o=G("group/field-content flex flex-1 flex-col gap-0.5 leading-snug",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"field-content",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function xt(n){const e=U.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 o;e[3]!==t?(o=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]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Dw,{"data-slot":"field-label",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function fo(n){const e=U.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 o;e[3]!==t?(o=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]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("p",{"data-slot":"field-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function us(n){var f;const e=U.c(15);let t,s,o,i;e[0]!==n?({className:s,children:t,errors:o,...i}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);let a;e:{if(t){a=t;break e}if(!(o!=null&&o.length)){a=null;break e}let u;e[5]!==o?(u=[...new Map(o.map(Uw)).values()],e[5]=o,e[6]=u):u=e[6];const m=u;if((m==null?void 0:m.length)==1){a=(f=m[0])==null?void 0:f.message;break e}let p;e[7]!==m?(p=r.jsx("ul",{className:"ml-4 flex list-disc flex-col gap-1",children:m.map(Bw)}),e[7]=m,e[8]=p):p=e[8],a=p}const l=a;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 d;return e[11]!==l||e[12]!==i||e[13]!==c?(d=r.jsx("div",{role:"alert","data-slot":"field-error",className:c,...i,children:l}),e[11]=l,e[12]=i,e[13]=c,e[14]=d):d=e[14],d}function Bw(n,e){return(n==null?void 0:n.message)&&r.jsx("li",{children:n.message},e)}function Uw(n){return[n==null?void 0:n.message,n]}const Ww=hb;function Hw(n){const e=U.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 o;e[3]!==t?(o=G("scroll-my-1 p-1",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(vb,{"data-slot":"select-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Kw(n){const e=U.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 o;e[3]!==t?(o=G("flex flex-1 text-left",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(gb,{"data-slot":"select-value",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function qw(n){const e=U.c(13);let t,s,o,i;e[0]!==n?({className:s,size:i,children:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);const a=i===void 0?"default":i;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 bg-transparent 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 dark:bg-input/30 dark:hover:bg-input/50 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=r.jsx(yb,{render:r.jsx(nt,{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 d;return e[8]!==t||e[9]!==o||e[10]!==a||e[11]!==l?(d=r.jsxs(xb,{"data-slot":"select-trigger","data-size":a,className:l,...o,children:[t,c]}),e[8]=t,e[9]=o,e[10]=a,e[11]=l,e[12]=d):d=e[12],d}function Vw(n){const e=U.c(26);let t,s,o,i,a,l,c,d;e[0]!==n?({className:s,children:t,side:i,sideOffset:a,align:l,alignOffset:c,alignItemWithTrigger:d,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a,e[6]=l,e[7]=c,e[8]=d):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5],l=e[6],c=e[7],d=e[8]);const f=i===void 0?"bottom":i,u=a===void 0?4:a,m=l===void 0?"center":l,p=c===void 0?0:c,h=d===void 0?!0:d;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=r.jsx(Yw,{}),e[11]=x):x=e[11];let v;e[12]!==t?(v=r.jsx(wb,{children:t}),e[12]=t,e[13]=v):v=e[13];let w;e[14]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(Xw,{}),e[14]=w):w=e[14];let y;e[15]!==o||e[16]!==g||e[17]!==v?(y=r.jsxs(bb,{"data-slot":"select-content",className:g,...o,children:[x,v,w]}),e[15]=o,e[16]=g,e[17]=v,e[18]=y):y=e[18];let j;return e[19]!==m||e[20]!==h||e[21]!==p||e[22]!==f||e[23]!==u||e[24]!==y?(j=r.jsx(jb,{children:r.jsx(Sb,{side:f,sideOffset:u,align:m,alignOffset:p,alignItemWithTrigger:h,className:"isolate z-50",children:y})}),e[19]=m,e[20]=h,e[21]=p,e[22]=f,e[23]=u,e[24]=y,e[25]=j):j=e[25],j}function Gw(n){const e=U.c(13);let t,s,o;e[0]!==n?({className:s,children:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==s?(i=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]=i):i=e[5];let a;e[6]!==t?(a=r.jsx(mb,{className:"flex flex-1 shrink-0 gap-2 whitespace-nowrap",children:t}),e[6]=t,e[7]=a):a=e[7];let l;e[8]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(pb,{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:r.jsx("span",{className:"pointer-events-none absolute right-2 flex size-4 items-center justify-center"}),children:r.jsx(dt,{className:"pointer-events-none"})}),e[8]=l):l=e[8];let c;return e[9]!==o||e[10]!==i||e[11]!==a?(c=r.jsxs(fb,{"data-slot":"select-item",className:i,...o,children:[a,l]}),e[9]=o,e[10]=i,e[11]=a,e[12]=c):c=e[12],c}function Yw(n){const e=U.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 o;e[3]!==t?(o=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]=o):o=e[4];let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(pr,{}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.jsx(kb,{"data-slot":"select-scroll-up-button",className:o,...s,children:i}),e[6]=s,e[7]=o,e[8]=a):a=e[8],a}function Xw(n){const e=U.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 o;e[3]!==t?(o=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]=o):o=e[4];let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(nt,{}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.jsx(Nb,{"data-slot":"select-scroll-down-button",className:o,...s,children:i}),e[6]=s,e[7]=o,e[8]=a):a=e[8],a}function Jw(n){const e=U.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=r.jsx(Up,{"data-slot":"sheet",...t}),e[2]=t,e[3]=s):s=e[3],s}function Qw(n){const e=U.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=r.jsx(Cb,{"data-slot":"sheet-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function Zw(n){const e=U.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=r.jsx(Li,{"data-slot":"sheet-close",...t}),e[2]=t,e[3]=s):s=e[3],s}function e3(n){const e=U.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=r.jsx(xc,{"data-slot":"sheet-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function t3(n){const e=U.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 o;e[3]!==t?(o=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]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(bc,{"data-slot":"sheet-overlay",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function n3(n){const e=U.c(17);let t,s,o,i,a;e[0]!==n?({className:s,children:t,side:i,showCloseButton:a,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5]);const l=i===void 0?"right":i,c=a===void 0?!0:a;let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(t3,{}),e[6]=d):d=e[6];let f;e[7]!==s?(f=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]=f):f=e[8];let u;e[9]!==c?(u=c&&r.jsxs(Li,{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:[r.jsx(jt,{"data-icon":"inline-start",className:"size-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]}),e[9]=c,e[10]=u):u=e[10];let m;return e[11]!==t||e[12]!==o||e[13]!==l||e[14]!==f||e[15]!==u?(m=r.jsxs(e3,{children:[d,r.jsxs(pc,{"data-slot":"sheet-content","data-side":l,className:f,...o,children:[t,u]})]}),e[11]=t,e[12]=o,e[13]=l,e[14]=f,e[15]=u,e[16]=m):m=e[16],m}function s3(n){const e=U.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 o;e[3]!==t?(o=G("flex flex-col gap-1.5 border-b p-4",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"sheet-header",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function o3(n){const e=U.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 o;e[3]!==t?(o=G("text-sm font-medium",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(hc,{"data-slot":"sheet-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function r3(n){const e=U.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 o;e[3]!==t?(o=G("text-sm text-muted-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(gc,{"data-slot":"sheet-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Uo(n){const e=U.c(10),{label:t,children:s,wide:o}=n,a=(o===void 0?!1:o)&&"col-span-2";let l;e[0]!==a?(l=G("min-w-0 gap-1 py-1",a),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==t?(c=r.jsx(xt,{className:"text-xs text-muted-foreground",children:t}),e[2]=t,e[3]=c):c=e[3];let d;e[4]!==s?(d=r.jsx("div",{className:"min-w-0 [&>button]:w-full [&>button]:justify-between",children:s}),e[4]=s,e[5]=d):d=e[5];let f;return e[6]!==l||e[7]!==c||e[8]!==d?(f=r.jsxs(gt,{className:l,children:[c,d]}),e[6]=l,e[7]=c,e[8]=d,e[9]=f):f=e[9],f}function Vr(n){const e=U.c(19),{label:t,ariaLabel:s,value:o,options:i,onChange:a,disabled:l,title:c}=n;let d;e[0]!==a?(d=x=>{x!==null&&a(x)},e[0]=a,e[1]=d):d=e[1];let f;e[2]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(Kw,{}),e[2]=f):f=e[2];let u;e[3]!==s||e[4]!==c?(u=r.jsx(qw,{"aria-label":s,title:c,className:"h-10 w-full",children:f}),e[3]=s,e[4]=c,e[5]=u):u=e[5];let m;e[6]!==i?(m=i.map(i3),e[6]=i,e[7]=m):m=e[7];let p;e[8]!==m?(p=r.jsx(Vw,{children:r.jsx(Hw,{children:m})}),e[8]=m,e[9]=p):p=e[9];let h;e[10]!==l||e[11]!==d||e[12]!==u||e[13]!==p||e[14]!==o?(h=r.jsxs(Ww,{value:o,onValueChange:d,disabled:l,children:[u,p]}),e[10]=l,e[11]=d,e[12]=u,e[13]=p,e[14]=o,e[15]=h):h=e[15];let g;return e[16]!==t||e[17]!==h?(g=r.jsx(Uo,{label:t,children:h}),e[16]=t,e[17]=h,e[18]=g):g=e[18],g}function i3(n){return r.jsx(Gw,{value:n.value,children:n.menuLabel??n.label},n.value||"default")}function a3(n){const e=U.c(32),{agentKind:t,onAgentKindChange:s,selectedModel:o,onModelChange:i,modelOptions:a,selectedEffort:l,onEffortChange:c,effortOptions:d,ultracodeEnabled:f,fastTier:u,fastModeEnabled:m,onFastModeEnabledChange:p,permissionMode:h,permissionOptions:g,onPermissionModeChange:x,changeAndApply:v}=n;let w;e[0]!==t||e[1]!==l||e[2]!==o?(w=Yi(t,l,o),e[0]=t,e[1]=l,e[2]=o,e[3]=w):w=e[3];const y=w;let j;e[4]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx("h3",{id:"mobile-model-controls",className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Model and behavior"}),e[4]=j):j=e[4];let k;e[5]!==t||e[6]!==s?(k=s&&r.jsx(Vr,{label:"Agent",ariaLabel:"Agent",value:t,options:$l,onChange:A=>s(A)}),e[5]=t,e[6]=s,e[7]=k):k=e[7];let N;e[8]!==a||e[9]!==i||e[10]!==o?(N=r.jsx(Vr,{label:"Model",ariaLabel:"Model",value:o,options:a,onChange:i}),e[8]=a,e[9]=i,e[10]=o,e[11]=N):N=e[11];let C;e[12]!==d||e[13]!==y||e[14]!==c||e[15]!==f?(C=d.length>0&&r.jsx(Vr,{label:"Reasoning",ariaLabel:"Reasoning effort",value:y,options:d,onChange:c,disabled:f,title:f?"Effort is pinned to XHigh while Ultracode is on":void 0}),e[12]=d,e[13]=y,e[14]=c,e[15]=f,e[16]=C):C=e[16];let S;e[17]!==v||e[18]!==m||e[19]!==u||e[20]!==p?(S=u&&p&&r.jsx(Uo,{label:"Speed",children:r.jsxs(X,{type:"button",variant:m?"secondary":"ghost","aria-pressed":!!m,onClick:()=>v(()=>p(!m)),title:u.description,className:"h-10 justify-start",children:[r.jsx(gi,{"data-icon":"inline-start",className:G(m&&"fill-current")}),m?"Fast":"Standard"]})}),e[17]=v,e[18]=m,e[19]=u,e[20]=p,e[21]=S):S=e[21];let _;e[22]!==x||e[23]!==h||e[24]!==g?(_=x&&h&&r.jsx(Vr,{label:"Access",ariaLabel:"Access policy",value:h,options:g,onChange:A=>x(A)}),e[22]=x,e[23]=h,e[24]=g,e[25]=_):_=e[25];let P;return e[26]!==k||e[27]!==N||e[28]!==C||e[29]!==S||e[30]!==_?(P=r.jsxs("section",{"aria-labelledby":"mobile-model-controls",className:"flex flex-col gap-2",children:[j,r.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[k,N,C,S,_]})]}),e[26]=k,e[27]=N,e[28]=C,e[29]=S,e[30]=_,e[31]=P):P=e[31],P}function l3(n){const e=U.c(30),{agentKind:t,isNewSession:s,worktreeEnabled:o,onWorktreeEnabledChange:i,ultracodeEnabled:a,onUltracodeEnabledChange:l,mcpServers:c,selectedMcpServers:d,onToggleMcpServer:f,onRefreshMcpServers:u,mcpLoading:m,onMcpAuth:p,changeAndApply:h}=n;let g;e[0]!==t?(g=zt(t),e[0]=t,e[1]=g):g=e[1];const{worktrees:x,ultracode:v}=g,w=!!(f&&u&&p&&(m||c&&c.length>0)),y=!!(x&&s&&i||v&&l||w);let j;e[2]!==d?(j=d??[],e[2]=d,e[3]=j):j=e[3];let k;e[4]!==j?(k=new Set(j),e[4]=j,e[5]=k):k=e[5];const N=k;if(!y)return null;let C;e[6]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx("h3",{id:"mobile-advanced-controls",className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Advanced"}),e[6]=C):C=e[6];let S;e[7]!==s||e[8]!==i||e[9]!==x||e[10]!==o?(S=x&&s&&i&&r.jsx(Uo,{label:"Isolation",children:r.jsxs(X,{type:"button",variant:o?"secondary":"ghost","aria-pressed":!!o,onClick:()=>i(!o),className:"h-10 justify-start",children:[r.jsx(bo,{"data-icon":"inline-start"}),"Worktree"]})}),e[7]=s,e[8]=i,e[9]=x,e[10]=o,e[11]=S):S=e[11];let _;e[12]!==h||e[13]!==l||e[14]!==v||e[15]!==a?(_=v&&l&&r.jsx(Uo,{label:"Workflow",children:r.jsxs(X,{type:"button",variant:a?"secondary":"ghost","aria-pressed":!!a,onClick:()=>h(()=>l(!a)),className:"h-10 justify-start",children:[r.jsx(gi,{"data-icon":"inline-start",className:G(a&&"fill-current")}),"Ultracode"]})}),e[12]=h,e[13]=l,e[14]=v,e[15]=a,e[16]=_):_=e[16];let P;e[17]!==h||e[18]!==m||e[19]!==c||e[20]!==p||e[21]!==u||e[22]!==f||e[23]!==N||e[24]!==w?(P=w&&f&&u&&p&&r.jsx(Uo,{label:"Connections",wide:!0,children:r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsxs(X,{type:"button",variant:"ghost",onClick:u,className:"min-h-10 justify-start",children:[r.jsx(Qt,{"data-icon":"inline-start",className:G(m&&"animate-spin")}),"Refresh MCP status"]}),(c??[]).map(E=>{const T=N.has(E.name),M=E.status==="connected";return r.jsxs(X,{type:"button",variant:"ghost","aria-pressed":M?T:void 0,onClick:()=>M?h(()=>f(E.name)):p(E.name),className:"min-h-10 justify-start text-left",children:[r.jsx("span",{className:G("size-2 shrink-0 rounded-full",M&&T?"bg-success":M?"bg-muted-foreground":"bg-warning")}),r.jsx("span",{className:"min-w-0 flex-1 truncate",children:E.name}),r.jsx("span",{className:"text-xs text-muted-foreground",children:M?T?"On":"Off":"Connect"})]},E.name)})]})}),e[17]=h,e[18]=m,e[19]=c,e[20]=p,e[21]=u,e[22]=f,e[23]=N,e[24]=w,e[25]=P):P=e[25];let A;return e[26]!==S||e[27]!==_||e[28]!==P?(A=r.jsxs("section",{"aria-labelledby":"mobile-advanced-controls",className:"flex flex-col gap-2",children:[C,r.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[S,_,P]})]}),e[26]=S,e[27]=_,e[28]=P,e[29]=A):A=e[29],A}function c3(n){var he,me;const e=U.c(78),{open:t,onOpenChange:s,agentKind:o,onAgentKindChange:i,selectedModel:a,resolvedDefaultName:l,catalogOptions:c,modelOptions:d,onModelChange:f,selectedEffort:u,effortOptions:m,onEffortChange:p,fastTier:h,fastModeEnabled:g,onFastModeEnabledChange:x,isNewSession:v,worktreeEnabled:w,onWorktreeEnabledChange:y,ultracodeEnabled:j,onUltracodeEnabledChange:k,autoModeAvailable:N,permissionMode:C,onPermissionModeChange:S,mcpServers:_,selectedMcpServers:P,onToggleMcpServer:A,onRefreshMcpServers:E,mcpLoading:T,onMcpAuth:M,mobileExtra:I,changeAndApply:R}=n;let $;e[0]!==o||e[1]!==u||e[2]!==a?($=Yi(o,u,a),e[0]=o,e[1]=u,e[2]=a,e[3]=$):$=e[3];const D=$;let O,L;e[4]!==o||e[5]!==N||e[6]!==C?(O=Rh(o,N),L=(he=O.find(le=>le.value===C))==null?void 0:he.label,e[4]=o,e[5]=N,e[6]=C,e[7]=O,e[8]=L):(O=e[7],L=e[8]);const z=L;let F;e[9]!==c||e[10]!==l||e[11]!==a?(F=a?_c(a,c):l,e[9]=c,e[10]=l,e[11]=a,e[12]=F):F=e[12];let H;e[13]!==m||e[14]!==D?(H=(me=m.find(le=>le.value===D))==null?void 0:me.label,e[13]=m,e[14]=D,e[15]=H):H=e[15];let B;e[16]!==z||e[17]!==F||e[18]!==H?(B=[F,H,z].filter(Boolean),e[16]=z,e[17]=F,e[18]=H,e[19]=B):B=e[19];const W=B.join(" · ");let K;e[20]!==R||e[21]!==S?(K=le=>{S&&R(()=>S(le))},e[20]=R,e[21]=S,e[22]=K):K=e[22];const V=K;let Y;e[23]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx(Qw,{render:r.jsx(X,{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:r.jsx(vc,{})}),e[23]=Y):Y=e[23];let q;e[24]===Symbol.for("react.memo_cache_sentinel")?(q=r.jsx(o3,{children:"Session controls"}),e[24]=q):q=e[24];let J;e[25]!==W?(J=r.jsx(r3,{className:"truncate text-xs",children:W}),e[25]=W,e[26]=J):J=e[26];let Z;e[27]===Symbol.for("react.memo_cache_sentinel")?(Z=r.jsx(Zw,{render:r.jsx(X,{type:"button",variant:"ghost",size:"icon-lg",className:"absolute right-2 top-2","aria-label":"Close session controls"}),children:r.jsx(jt,{})}),e[27]=Z):Z=e[27];let Q;e[28]!==J?(Q=r.jsxs(s3,{className:"gap-1 px-4 pb-3 pt-4",children:[q,J,Z]}),e[28]=J,e[29]=Q):Q=e[29];let ee;e[30]!==o||e[31]!==R||e[32]!==V||e[33]!==m||e[34]!==g||e[35]!==h||e[36]!==d||e[37]!==i||e[38]!==p||e[39]!==x||e[40]!==f||e[41]!==C||e[42]!==O||e[43]!==u||e[44]!==a||e[45]!==j?(ee=r.jsx(a3,{agentKind:o,onAgentKindChange:i,selectedModel:a,onModelChange:f,modelOptions:d,selectedEffort:u,onEffortChange:p,effortOptions:m,ultracodeEnabled:j,fastTier:h,fastModeEnabled:g,onFastModeEnabledChange:x,permissionMode:C,permissionOptions:O,onPermissionModeChange:V,changeAndApply:R}),e[30]=o,e[31]=R,e[32]=V,e[33]=m,e[34]=g,e[35]=h,e[36]=d,e[37]=i,e[38]=p,e[39]=x,e[40]=f,e[41]=C,e[42]=O,e[43]=u,e[44]=a,e[45]=j,e[46]=ee):ee=e[46];let oe;e[47]!==o||e[48]!==R||e[49]!==v||e[50]!==T||e[51]!==_||e[52]!==M||e[53]!==E||e[54]!==A||e[55]!==k||e[56]!==y||e[57]!==P||e[58]!==j||e[59]!==w?(oe=r.jsx(l3,{agentKind:o,isNewSession:v,worktreeEnabled:w,onWorktreeEnabledChange:y,ultracodeEnabled:j,onUltracodeEnabledChange:k,mcpServers:_,selectedMcpServers:P,onToggleMcpServer:A,onRefreshMcpServers:E,mcpLoading:T,onMcpAuth:M,changeAndApply:R}),e[47]=o,e[48]=R,e[49]=v,e[50]=T,e[51]=_,e[52]=M,e[53]=E,e[54]=A,e[55]=k,e[56]=y,e[57]=P,e[58]=j,e[59]=w,e[60]=oe):oe=e[60];let se;e[61]!==I?(se=I&&r.jsxs("section",{"aria-labelledby":"mobile-goal-controls",className:"flex flex-col gap-2 pt-1",children:[r.jsx(It,{className:"mb-3"}),r.jsx("h3",{id:"mobile-goal-controls",className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Long-running goal"}),r.jsx("div",{className:"[&>*]:mx-0 [&>*]:mb-0 [&_button]:min-h-10",children:I})]}),e[61]=I,e[62]=se):se=e[62];let re;e[63]!==o||e[64]!==v?(re=!v&&r.jsx("p",{className:"text-xs text-muted-foreground",children:zt(o).settingsApply==="live"?"Changes apply live.":"Changes apply on the next turn."}),e[63]=o,e[64]=v,e[65]=re):re=e[65];let ie;e[66]!==ee||e[67]!==oe||e[68]!==se||e[69]!==re?(ie=r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-4 py-4",children:[ee,oe,se,re]}),e[66]=ee,e[67]=oe,e[68]=se,e[69]=re,e[70]=ie):ie=e[70];let ae;e[71]!==Q||e[72]!==ie?(ae=r.jsxs(n3,{side:"bottom",className:"max-h-[82dvh] overflow-hidden rounded-t-2xl pb-[env(safe-area-inset-bottom)]",showCloseButton:!1,children:[Q,ie]}),e[71]=Q,e[72]=ie,e[73]=ae):ae=e[73];let te;return e[74]!==s||e[75]!==t||e[76]!==ae?(te=r.jsx(r.Fragment,{children:r.jsxs(Jw,{open:t,onOpenChange:s,children:[Y,ae]})}),e[74]=s,e[75]=t,e[76]=ae,e[77]=te):te=e[77],te}const d3=b.memo(function(e){const t=U.c(58),{agentKind:s,onAgentKindChange:o,selectedModel:i,onModelChange:a,selectedEffort:l,onEffortChange:c,fastModeEnabled:d,onFastModeEnabledChange:f,isNewSession:u,worktreeEnabled:m,onWorktreeEnabledChange:p,ultracodeEnabled:h,onUltracodeEnabledChange:g,onApplySettings:x,activeModelId:v,mcpServers:w,selectedMcpServers:y,onToggleMcpServer:j,onRefreshMcpServers:k,mcpLoading:N,onMcpAuth:C,permissionMode:S,onPermissionModeChange:_,mobileExtra:P,trailingExtra:A,mobile:E}=e,T=s===void 0?Fs:s,M=E===void 0?!1:E,[I,R]=b.useState(!1);let $;t[0]!==u||t[1]!==x?($=te=>{te(),!u&&x&&setTimeout(()=>x(),0)},t[0]=u,t[1]=x,t[2]=$):$=t[2];const D=$;let O;t[3]!==D||t[4]!==a?(O=te=>D(()=>a(te)),t[3]=D,t[4]=a,t[5]=O):O=t[5];const L=O;let z;t[6]!==D||t[7]!==c?(z=te=>D(()=>c(te)),t[6]=D,t[7]=c,t[8]=z):z=t[8];const F=z,H=Th(T),B=(v==null?void 0:v.toLowerCase().startsWith("gpt-"))??!1,K=v&&(T==="copilot"||B===(T==="codex"))?v:void 0;let V,Y;t[9]!==H||t[10]!==K?(V=K?_c(K,H):kw(H),Y=H.map(te=>{const he=[te.description,te.availabilityMessage].filter(Boolean).join(" · ")||void 0;return te.value===""?{...te,description:he,label:V,menuLabel:te.label}:{...te,description:he}}),t[9]=H,t[10]=K,t[11]=V,t[12]=Y):(V=t[11],Y=t[12]);const q=Y;let J;t[13]!==T||t[14]!==i?(J=xh(T,i),t[13]=T,t[14]=i,t[15]=J):J=t[15];const Z=J;let Q;t[16]!==T||t[17]!==i?(Q=bh(T,i),t[16]=T,t[17]=i,t[18]=Q):Q=t[18];const ee=Q;let oe;t[19]!==T||t[20]!==i?(oe=Sy(T,i),t[19]=T,t[20]=i,t[21]=oe):oe=t[21];const se=oe;let re;t[22]!==T||t[23]!==se||t[24]!==D||t[25]!==Z||t[26]!==d||t[27]!==ee||t[28]!==F||t[29]!==L||t[30]!==u||t[31]!==N||t[32]!==w||t[33]!==q||t[34]!==o||t[35]!==f||t[36]!==C||t[37]!==_||t[38]!==k||t[39]!==j||t[40]!==g||t[41]!==p||t[42]!==S||t[43]!==V||t[44]!==l||t[45]!==y||t[46]!==i||t[47]!==h||t[48]!==m?(re={agentKind:T,onAgentKindChange:o,selectedModel:i,resolvedDefaultName:V,modelOptions:q,onModelChange:L,selectedEffort:l,effortOptions:Z,onEffortChange:F,fastTier:ee,fastModeEnabled:d,onFastModeEnabledChange:f,isNewSession:u,worktreeEnabled:m,onWorktreeEnabledChange:p,ultracodeEnabled:h,onUltracodeEnabledChange:g,autoModeAvailable:se,permissionMode:S,onPermissionModeChange:_,mcpServers:w,selectedMcpServers:y,onToggleMcpServer:j,onRefreshMcpServers:k,mcpLoading:N,onMcpAuth:C,changeAndApply:D},t[22]=T,t[23]=se,t[24]=D,t[25]=Z,t[26]=d,t[27]=ee,t[28]=F,t[29]=L,t[30]=u,t[31]=N,t[32]=w,t[33]=q,t[34]=o,t[35]=f,t[36]=C,t[37]=_,t[38]=k,t[39]=j,t[40]=g,t[41]=p,t[42]=S,t[43]=V,t[44]=l,t[45]=y,t[46]=i,t[47]=h,t[48]=m,t[49]=re):re=t[49];const ie=re;if(M){let te;return t[50]!==H||t[51]!==ie||t[52]!==P||t[53]!==I?(te=r.jsx(c3,{...ie,open:I,onOpenChange:R,catalogOptions:H,mobileExtra:P}),t[50]=H,t[51]=ie,t[52]=P,t[53]=I,t[54]=te):te=t[54],te}let ae;return t[55]!==ie||t[56]!==A?(ae=r.jsx(Ow,{...ie,trailingExtra:A}),t[55]=ie,t[56]=A,t[57]=ae):ae=t[57],ae});function Mh(n){return n.agentType==="team-lead"}function u3(n){return Mh(n)?void 0:n.color}const f3={blue:"bg-blue-500",green:"bg-green-500",yellow:"bg-yellow-500",purple:"bg-purple-500",orange:"bg-orange-500"};function m3(n){return n?f3[n]??"bg-zinc-400":"bg-zinc-400"}const p3=b.memo(function(e){const t=U.c(18),{teamName:s,members:o,currentMemberName:i,loadingMember:a,onMemberClick:l}=e;let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(Wn,{className:"size-3"}),t[0]=c):c=t[0];let d;t[1]!==s?(d=r.jsxs("div",{className:"flex shrink-0 items-center gap-1.5 text-xs font-medium text-muted-foreground",children:[c,r.jsx("span",{className:"max-w-[120px] truncate",children:s})]}),t[1]=s,t[2]=d):d=t[2];let f;t[3]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(It,{orientation:"vertical",className:"h-3.5"}),t[3]=f):f=t[3];let u;if(t[4]!==i||t[5]!==a||t[6]!==o||t[7]!==l){let h;t[9]!==i||t[10]!==a||t[11]!==l?(h=g=>{const x=g.name===i,v=g.name===a,w=m3(u3(g));return r.jsxs(X,{variant:"ghost",size:"xs",onClick:()=>l(g),disabled:v,className:G("whitespace-nowrap",x?"bg-accent text-accent-foreground":"text-muted-foreground"),children:[v?r.jsx(rt,{"data-icon":"inline-start",className:"animate-spin"}):r.jsx("span",{className:G("inline-flex size-1.5 shrink-0 rounded-full",w)}),r.jsx("span",{children:g.name}),Mh(g)&&r.jsx(_b,{"data-icon":"inline-end",className:"text-warning"})]},g.agentId)},t[9]=i,t[10]=a,t[11]=l,t[12]=h):h=t[12],u=o.map(h),t[4]=i,t[5]=a,t[6]=o,t[7]=l,t[8]=u}else u=t[8];let m;t[13]!==u?(m=r.jsx("div",{className:"flex items-center gap-1",children:u}),t[13]=u,t[14]=m):m=t[14];let p;return t[15]!==d||t[16]!==m?(p=r.jsxs("div",{className:"flex shrink-0 items-center gap-2 overflow-x-auto border-b bg-background px-3 py-2",children:[d,f,m]}),t[15]=d,t[16]=m,t[17]=p):p=t[17],p});function Ih(n){const e=U.c(3),t=b.useRef(null),[s,o]=b.useState(0);let i,a;return e[0]!==n?(i=()=>{if(!n){t.current=null,o(0);return}t.current=Date.now(),o(0);const l=setInterval(()=>{t.current!==null&&o(Math.floor((Date.now()-t.current)/1e3))},1e3);return()=>clearInterval(l)},a=[n],e[0]=n,e[1]=i,e[2]=a):(i=e[1],a=e[2]),b.useEffect(i,a),s}const $h=b.createContext(null),Oh=b.createContext(null);function di(n){const e=U.c(6),{value:t,chatValue:s,children:o}=n;let i;e[0]!==s||e[1]!==o?(i=r.jsx(Oh.Provider,{value:s,children:o}),e[0]=s,e[1]=o,e[2]=i):i=e[2];let a;return e[3]!==i||e[4]!==t?(a=r.jsx($h.Provider,{value:t,children:i}),e[3]=i,e[4]=t,e[5]=a):a=e[5],a}function it(){const n=b.useContext($h);if(!n)throw new Error("useSessionContext must be used within a SessionProvider");return n}function yr(){const n=b.useContext(Oh);if(!n)throw new Error("useSessionChatContext must be used within a SessionProvider");return n}const h3=Bn("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 Me(n){const e=U.c(13);let t,s,o,i,a;if(e[0]!==n){const{className:d,variant:f,render:u,...m}=n;t=u,a=f===void 0?"default":f,i=Hp,s="span",o=Wp({className:G(h3({variant:a}),d)},m),e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a}else t=e[1],s=e[2],o=e[3],i=e[4],a=e[5];let l;e[6]!==a?(l={slot:"badge",variant:a},e[6]=a,e[7]=l):l=e[7];let c;return e[8]!==t||e[9]!==s||e[10]!==o||e[11]!==l?(c={defaultTagName:s,props:o,render:t,state:l},e[8]=t,e[9]=s,e[10]=o,e[11]=l,e[12]=c):c=e[12],i(c)}var ef=1,g3=.9,x3=.8,b3=.17,Wa=.1,Ha=.999,v3=.9999,y3=.99,w3=/[\\\/_+.#"@\[\(\{&]/,j3=/[\\\/_+.#"@\[\(\{&]/g,S3=/[\s-]/,Dh=/[\s-]/g;function Ol(n,e,t,s,o,i,a){if(i===e.length)return o===n.length?ef:y3;var l=`${o},${i}`;if(a[l]!==void 0)return a[l];for(var c=s.charAt(i),d=t.indexOf(c,o),f=0,u,m,p,h;d>=0;)u=Ol(n,e,t,s,d+1,i+1,a),u>f&&(d===o?u*=ef:w3.test(n.charAt(d-1))?(u*=x3,p=n.slice(o,d-1).match(j3),p&&o>0&&(u*=Math.pow(Ha,p.length))):S3.test(n.charAt(d-1))?(u*=g3,h=n.slice(o,d-1).match(Dh),h&&o>0&&(u*=Math.pow(Ha,h.length))):(u*=b3,o>0&&(u*=Math.pow(Ha,d-o))),n.charAt(d)!==e.charAt(i)&&(u*=v3)),(u<Wa&&t.charAt(d-1)===s.charAt(i+1)||s.charAt(i+1)===s.charAt(i)&&t.charAt(d-1)!==s.charAt(i))&&(m=Ol(n,e,t,s,d+1,i+2,a),m*Wa>u&&(u=m*Wa)),u>f&&(f=u),d=t.indexOf(c,d+1);return a[l]=f,f}function tf(n){return n.toLowerCase().replace(Dh," ")}function k3(n,e,t){return n=t&&t.length>0?`${n+" "+t.join(" ")}`:n,Ol(n,e,tf(n),tf(e),0,0,{})}var Co='[cmdk-group=""]',Ka='[cmdk-group-items=""]',N3='[cmdk-group-heading=""]',Lh='[cmdk-item=""]',nf=`${Lh}:not([aria-disabled="true"])`,Dl="cmdk-item-select",eo="data-value",C3=(n,e,t)=>k3(n,e,t),zh=b.createContext(void 0),wr=()=>b.useContext(zh),Fh=b.createContext(void 0),Tc=()=>b.useContext(Fh),Bh=b.createContext(void 0),Uh=b.forwardRef((n,e)=>{let t=to(()=>{var F,H;return{search:"",value:(H=(F=n.value)!=null?F:n.defaultValue)!=null?H:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),s=to(()=>new Set),o=to(()=>new Map),i=to(()=>new Map),a=to(()=>new Set),l=Wh(n),{label:c,children:d,value:f,onValueChange:u,filter:m,shouldFilter:p,loop:h,disablePointerSelection:g=!1,vimBindings:x=!0,...v}=n,w=oo(),y=oo(),j=oo(),k=b.useRef(null),N=D3();Os(()=>{if(f!==void 0){let F=f.trim();t.current.value=F,C.emit()}},[f]),Os(()=>{N(6,T)},[]);let C=b.useMemo(()=>({subscribe:F=>(a.current.add(F),()=>a.current.delete(F)),snapshot:()=>t.current,setState:(F,H,B)=>{var W,K,V,Y;if(!Object.is(t.current[F],H)){if(t.current[F]=H,F==="search")E(),P(),N(1,A);else if(F==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let q=document.getElementById(j);q?q.focus():(W=document.getElementById(w))==null||W.focus()}if(N(7,()=>{var q;t.current.selectedItemId=(q=M())==null?void 0:q.id,C.emit()}),B||N(5,T),((K=l.current)==null?void 0:K.value)!==void 0){let q=H??"";(Y=(V=l.current).onValueChange)==null||Y.call(V,q);return}}C.emit()}},emit:()=>{a.current.forEach(F=>F())}}),[]),S=b.useMemo(()=>({value:(F,H,B)=>{var W;H!==((W=i.current.get(F))==null?void 0:W.value)&&(i.current.set(F,{value:H,keywords:B}),t.current.filtered.items.set(F,_(H,B)),N(2,()=>{P(),C.emit()}))},item:(F,H)=>(s.current.add(F),H&&(o.current.has(H)?o.current.get(H).add(F):o.current.set(H,new Set([F]))),N(3,()=>{E(),P(),t.current.value||A(),C.emit()}),()=>{i.current.delete(F),s.current.delete(F),t.current.filtered.items.delete(F);let B=M();N(4,()=>{E(),(B==null?void 0:B.getAttribute("id"))===F&&A(),C.emit()})}),group:F=>(o.current.has(F)||o.current.set(F,new Set),()=>{i.current.delete(F),o.current.delete(F)}),filter:()=>l.current.shouldFilter,label:c||n["aria-label"],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:w,inputId:j,labelId:y,listInnerRef:k}),[]);function _(F,H){var B,W;let K=(W=(B=l.current)==null?void 0:B.filter)!=null?W:C3;return F?K(F,t.current.search,H):0}function P(){if(!t.current.search||l.current.shouldFilter===!1)return;let F=t.current.filtered.items,H=[];t.current.filtered.groups.forEach(W=>{let K=o.current.get(W),V=0;K.forEach(Y=>{let q=F.get(Y);V=Math.max(q,V)}),H.push([W,V])});let B=k.current;I().sort((W,K)=>{var V,Y;let q=W.getAttribute("id"),J=K.getAttribute("id");return((V=F.get(J))!=null?V:0)-((Y=F.get(q))!=null?Y:0)}).forEach(W=>{let K=W.closest(Ka);K?K.appendChild(W.parentElement===K?W:W.closest(`${Ka} > *`)):B.appendChild(W.parentElement===B?W:W.closest(`${Ka} > *`))}),H.sort((W,K)=>K[1]-W[1]).forEach(W=>{var K;let V=(K=k.current)==null?void 0:K.querySelector(`${Co}[${eo}="${encodeURIComponent(W[0])}"]`);V==null||V.parentElement.appendChild(V)})}function A(){let F=I().find(B=>B.getAttribute("aria-disabled")!=="true"),H=F==null?void 0:F.getAttribute(eo);C.setState("value",H||void 0)}function E(){var F,H,B,W;if(!t.current.search||l.current.shouldFilter===!1){t.current.filtered.count=s.current.size;return}t.current.filtered.groups=new Set;let K=0;for(let V of s.current){let Y=(H=(F=i.current.get(V))==null?void 0:F.value)!=null?H:"",q=(W=(B=i.current.get(V))==null?void 0:B.keywords)!=null?W:[],J=_(Y,q);t.current.filtered.items.set(V,J),J>0&&K++}for(let[V,Y]of o.current)for(let q of Y)if(t.current.filtered.items.get(q)>0){t.current.filtered.groups.add(V);break}t.current.filtered.count=K}function T(){var F,H,B;let W=M();W&&(((F=W.parentElement)==null?void 0:F.firstChild)===W&&((B=(H=W.closest(Co))==null?void 0:H.querySelector(N3))==null||B.scrollIntoView({block:"nearest"})),W.scrollIntoView({block:"nearest"}))}function M(){var F;return(F=k.current)==null?void 0:F.querySelector(`${Lh}[aria-selected="true"]`)}function I(){var F;return Array.from(((F=k.current)==null?void 0:F.querySelectorAll(nf))||[])}function R(F){let H=I()[F];H&&C.setState("value",H.getAttribute(eo))}function $(F){var H;let B=M(),W=I(),K=W.findIndex(Y=>Y===B),V=W[K+F];(H=l.current)!=null&&H.loop&&(V=K+F<0?W[W.length-1]:K+F===W.length?W[0]:W[K+F]),V&&C.setState("value",V.getAttribute(eo))}function D(F){let H=M(),B=H==null?void 0:H.closest(Co),W;for(;B&&!W;)B=F>0?$3(B,Co):O3(B,Co),W=B==null?void 0:B.querySelector(nf);W?C.setState("value",W.getAttribute(eo)):$(F)}let O=()=>R(I().length-1),L=F=>{F.preventDefault(),F.metaKey?O():F.altKey?D(1):$(1)},z=F=>{F.preventDefault(),F.metaKey?R(0):F.altKey?D(-1):$(-1)};return b.createElement(ys.div,{ref:e,tabIndex:-1,...v,"cmdk-root":"",onKeyDown:F=>{var H;(H=v.onKeyDown)==null||H.call(v,F);let B=F.nativeEvent.isComposing||F.keyCode===229;if(!(F.defaultPrevented||B))switch(F.key){case"n":case"j":{x&&F.ctrlKey&&L(F);break}case"ArrowDown":{L(F);break}case"p":case"k":{x&&F.ctrlKey&&z(F);break}case"ArrowUp":{z(F);break}case"Home":{F.preventDefault(),R(0);break}case"End":{F.preventDefault(),O();break}case"Enter":{F.preventDefault();let W=M();if(W){let K=new Event(Dl);W.dispatchEvent(K)}}}}},b.createElement("label",{"cmdk-label":"",htmlFor:S.inputId,id:S.labelId,style:z3},c),Qi(n,F=>b.createElement(Fh.Provider,{value:C},b.createElement(zh.Provider,{value:S},F))))}),_3=b.forwardRef((n,e)=>{var t,s;let o=oo(),i=b.useRef(null),a=b.useContext(Bh),l=wr(),c=Wh(n),d=(s=(t=c.current)==null?void 0:t.forceMount)!=null?s:a==null?void 0:a.forceMount;Os(()=>{if(!d)return l.item(o,a==null?void 0:a.id)},[d]);let f=Hh(o,i,[n.value,n.children,i],n.keywords),u=Tc(),m=gs(N=>N.value&&N.value===f.current),p=gs(N=>d||l.filter()===!1?!0:N.search?N.filtered.items.get(o)>0:!0);b.useEffect(()=>{let N=i.current;if(!(!N||n.disabled))return N.addEventListener(Dl,h),()=>N.removeEventListener(Dl,h)},[p,n.onSelect,n.disabled]);function h(){var N,C;g(),(C=(N=c.current).onSelect)==null||C.call(N,f.current)}function g(){u.setState("value",f.current,!0)}if(!p)return null;let{disabled:x,value:v,onSelect:w,forceMount:y,keywords:j,...k}=n;return b.createElement(ys.div,{ref:Yo(i,e),...k,id:o,"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)}),T3=b.forwardRef((n,e)=>{let{heading:t,children:s,forceMount:o,...i}=n,a=oo(),l=b.useRef(null),c=b.useRef(null),d=oo(),f=wr(),u=gs(p=>o||f.filter()===!1?!0:p.search?p.filtered.groups.has(a):!0);Os(()=>f.group(a),[]),Hh(a,l,[n.value,n.heading,c]);let m=b.useMemo(()=>({id:a,forceMount:o}),[o]);return b.createElement(ys.div,{ref:Yo(l,e),...i,"cmdk-group":"",role:"presentation",hidden:u?void 0:!0},t&&b.createElement("div",{ref:c,"cmdk-group-heading":"","aria-hidden":!0,id:d},t),Qi(n,p=>b.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":t?d:void 0},b.createElement(Bh.Provider,{value:m},p))))}),E3=b.forwardRef((n,e)=>{let{alwaysRender:t,...s}=n,o=b.useRef(null),i=gs(a=>!a.search);return!t&&!i?null:b.createElement(ys.div,{ref:Yo(o,e),...s,"cmdk-separator":"",role:"separator"})}),P3=b.forwardRef((n,e)=>{let{onValueChange:t,...s}=n,o=n.value!=null,i=Tc(),a=gs(d=>d.search),l=gs(d=>d.selectedItemId),c=wr();return b.useEffect(()=>{n.value!=null&&i.setState("search",n.value)},[n.value]),b.createElement(ys.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:o?n.value:a,onChange:d=>{o||i.setState("search",d.target.value),t==null||t(d.target.value)}})}),A3=b.forwardRef((n,e)=>{let{children:t,label:s="Suggestions",...o}=n,i=b.useRef(null),a=b.useRef(null),l=gs(d=>d.selectedItemId),c=wr();return b.useEffect(()=>{if(a.current&&i.current){let d=a.current,f=i.current,u,m=new ResizeObserver(()=>{u=requestAnimationFrame(()=>{let p=d.offsetHeight;f.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return m.observe(d),()=>{cancelAnimationFrame(u),m.unobserve(d)}}},[]),b.createElement(ys.div,{ref:Yo(i,e),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":s,id:c.listId},Qi(n,d=>b.createElement("div",{ref:Yo(a,c.listInnerRef),"cmdk-list-sizer":""},d)))}),R3=b.forwardRef((n,e)=>{let{open:t,onOpenChange:s,overlayClassName:o,contentClassName:i,container:a,...l}=n;return b.createElement(Tb,{open:t,onOpenChange:s},b.createElement(Eb,{container:a},b.createElement(Pb,{"cmdk-overlay":"",className:o}),b.createElement(Ab,{"aria-label":n.label,"cmdk-dialog":"",className:i},b.createElement(Uh,{ref:e,...l}))))}),M3=b.forwardRef((n,e)=>gs(t=>t.filtered.count===0)?b.createElement(ys.div,{ref:e,...n,"cmdk-empty":"",role:"presentation"}):null),I3=b.forwardRef((n,e)=>{let{progress:t,children:s,label:o="Loading...",...i}=n;return b.createElement(ys.div,{ref:e,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Qi(n,a=>b.createElement("div",{"aria-hidden":!0},a)))}),jo=Object.assign(Uh,{List:A3,Item:_3,Input:P3,Group:T3,Separator:E3,Dialog:R3,Empty:M3,Loading:I3});function $3(n,e){let t=n.nextElementSibling;for(;t;){if(t.matches(e))return t;t=t.nextElementSibling}}function O3(n,e){let t=n.previousElementSibling;for(;t;){if(t.matches(e))return t;t=t.previousElementSibling}}function Wh(n){let e=b.useRef(n);return Os(()=>{e.current=n}),e}var Os=typeof window>"u"?b.useEffect:b.useLayoutEffect;function to(n){let e=b.useRef();return e.current===void 0&&(e.current=n()),e}function gs(n){let e=Tc(),t=()=>n(e.snapshot());return b.useSyncExternalStore(e.subscribe,t,t)}function Hh(n,e,t,s=[]){let o=b.useRef(),i=wr();return Os(()=>{var a;let l=(()=>{var d;for(let f of t){if(typeof f=="string")return f.trim();if(typeof f=="object"&&"current"in f)return f.current?(d=f.current.textContent)==null?void 0:d.trim():o.current}})(),c=s.map(d=>d.trim());i.value(n,l,c),(a=e.current)==null||a.setAttribute(eo,l),o.current=l}),o}var D3=()=>{let[n,e]=b.useState(),t=to(()=>new Map);return Os(()=>{t.current.forEach(s=>s()),t.current=new Map},[n]),(s,o)=>{t.current.set(s,o),e({})}};function L3(n){let e=n.type;return typeof e=="function"?e(n.props):"render"in e?e.render(n.props):n}function Qi({asChild:n,children:e},t){return n&&b.isValidElement(e)?b.cloneElement(L3(e),{ref:e.ref},t(e.props.children)):t(e)}var z3={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function Gn(n){const e=U.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=r.jsx(Up,{"data-slot":"dialog",...t}),e[2]=t,e[3]=s):s=e[3],s}function F3(n){const e=U.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=r.jsx(xc,{"data-slot":"dialog-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function B3(n){const e=U.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 o;e[3]!==t?(o=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]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(bc,{"data-slot":"dialog-overlay",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Yn(n){const e=U.c(15);let t,s,o,i;e[0]!==n?({className:s,children:t,showCloseButton:i,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);const a=i===void 0?!0:i;let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(B3,{}),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 d;e[8]!==a?(d=a&&r.jsxs(Li,{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:[r.jsx(jt,{"data-icon":"inline-start",className:"size-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]}),e[8]=a,e[9]=d):d=e[9];let f;return e[10]!==t||e[11]!==o||e[12]!==c||e[13]!==d?(f=r.jsxs(F3,{children:[l,r.jsxs(pc,{"data-slot":"dialog-content",className:c,...o,children:[t,d]})]}),e[10]=t,e[11]=o,e[12]=c,e[13]=d,e[14]=f):f=e[14],f}function Ss(n){const e=U.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 o;e[3]!==t?(o=G("flex flex-col gap-2 text-center sm:text-left",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"dialog-header",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Kh(n){const e=U.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 o;e[3]!==t?(o=G("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"dialog-footer",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Xn(n){const e=U.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 o;e[3]!==t?(o=G("text-lg leading-none font-semibold",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(hc,{"data-slot":"dialog-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Jn(n){const e=U.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 o;e[3]!==t?(o=G("text-muted-foreground text-sm",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(gc,{"data-slot":"dialog-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function qh(n){const e=U.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 o;e[3]!==t?(o=G("flex size-full flex-col overflow-hidden rounded-xl! bg-popover p-1 text-popover-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(jo,{"data-slot":"command",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function YM(n){const e=U.c(24);let t,s,o,i,a,l;e[0]!==n?({title:i,description:a,children:t,className:s,showCloseButton:l,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a,e[6]=l):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5],l=e[6]);const c=i===void 0?"Command Palette":i,d=a===void 0?"Search for a command to run...":a,f=l===void 0?!1:l;let u;e[7]!==s?(u=G("top-1/3 translate-y-0 overflow-hidden rounded-xl! p-0",s),e[7]=s,e[8]=u):u=e[8];let m;e[9]!==c?(m=r.jsx(Xn,{children:c}),e[9]=c,e[10]=m):m=e[10];let p;e[11]!==d?(p=r.jsx(Jn,{children:d}),e[11]=d,e[12]=p):p=e[12];let h;e[13]!==m||e[14]!==p?(h=r.jsxs(Ss,{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]!==f||e[18]!==u||e[19]!==h?(g=r.jsxs(Yn,{className:u,showCloseButton:f,children:[h,t]}),e[16]=t,e[17]=f,e[18]=u,e[19]=h,e[20]=g):g=e[20];let x;return e[21]!==o||e[22]!==g?(x=r.jsx(Gn,{...o,children:g}),e[21]=o,e[22]=g,e[23]=x):x=e[23],x}function XM(n){const e=U.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 o;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(xn,{className:"size-4 shrink-0 text-muted-foreground"}),e[3]=o):o=e[3];let i;e[4]!==t?(i=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]=i):i=e[5];let a;return e[6]!==s||e[7]!==i?(a=r.jsxs("div",{"data-slot":"command-input-wrapper",className:"flex h-11 items-center gap-2 border-b px-3",children:[o,r.jsx(jo.Input,{"data-slot":"command-input",className:i,...s})]}),e[6]=s,e[7]=i,e[8]=a):a=e[8],a}function Vh(n){const e=U.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 o;e[3]!==t?(o=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]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(jo.List,{"data-slot":"command-list",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function JM(n){const e=U.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 o;e[3]!==t?(o=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]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(jo.Empty,{"data-slot":"command-empty",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Gh(n){const e=U.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 o;e[3]!==t?(o=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]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(jo.Group,{"data-slot":"command-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Yh(n){const e=U.c(11);let t,s,o;e[0]!==n?({className:s,children:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==s?(i=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:bg-muted data-selected:text-foreground motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-selected:*:[svg]:text-foreground",s),e[4]=s,e[5]=i):i=e[5];let a;e[6]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(dt,{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]=a):a=e[6];let l;return e[7]!==t||e[8]!==o||e[9]!==i?(l=r.jsxs(jo.Item,{"data-slot":"command-item",className:i,...o,children:[t,a]}),e[7]=t,e[8]=o,e[9]=i,e[10]=l):l=e[10],l}function U3(n){const e=U.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 o;e[3]!==t?(o=G("ml-auto text-xs tracking-widest text-muted-foreground group-data-selected/command-item:text-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("span",{"data-slot":"command-shortcut",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function W3(n){return r.jsx(Me,{variant:n.source==="built-in"?"secondary":"outline",children:n.source})}const H3=b.memo(function(e){const t=U.c(38),{suggestions:s,filter:o,loading:i,selectedIndex:a,onSelect:l,onHover:c,onEdit:d}=e;let f;t[0]===Symbol.for("react.memo_cache_sentinel")?(f=new Map,t[0]=f):f=t[0];const u=b.useRef(f);let m,p;if(t[1]!==a?(m=()=>{var A;const P=u.current.get(a);P&&((A=P.scrollIntoView)==null||A.call(P,{block:"nearest"}))},p=[a],t[1]=a,t[2]=m,t[3]=p):(m=t[2],p=t[3]),b.useEffect(m,p),i){let P;return t[4]===Symbol.for("react.memo_cache_sentinel")?(P=r.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:r.jsxs("div",{className:"flex items-center gap-2 rounded-lg border bg-popover p-3 text-popover-foreground shadow-sm",children:[r.jsx(rt,{className:"size-3.5 animate-spin text-muted-foreground"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading suggestions..."})]})}),t[4]=P):P=t[4],P}if(s.length===0){const P=o?`No commands or skills matching "${o}"`:"No commands or skills found";let A;return t[5]!==P?(A=r.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:r.jsx("div",{className:"rounded-lg border bg-popover p-3 text-popover-foreground shadow-sm",children:r.jsx("span",{className:"text-xs text-muted-foreground",children:P})})}),t[5]=P,t[6]=A):A=t[6],A}let h,g,x,v,w,y,j,k,N;if(t[7]!==d||t[8]!==c||t[9]!==l||t[10]!==a||t[11]!==s){const P=s.filter(q3),A=[{heading:"Commands",suggestions:P,offset:0},{heading:"Skills",suggestions:s.filter(V3),offset:P.length}];x="motion-popover-in absolute bottom-full left-0 right-0 z-50 mx-auto mb-2 max-w-[var(--chat-width)]",g=qh,w="slash-suggestions",y=s[a]?`${s[a].type}-${s[a].name}`:void 0,t[21]!==c||t[22]!==s?(j=E=>{const T=s.findIndex(M=>`${M.type}-${M.name}`===E);T>=0&&c(T)},t[21]=c,t[22]=s,t[23]=j):j=t[23],k=!1,N="border shadow-sm",h=Vh,v=A.map(E=>E.suggestions.length>0&&r.jsx(Gh,{heading:E.heading,children:E.suggestions.map((T,M)=>{const I=E.offset+M;return r.jsx(K3,{suggestion:T,index:I,isSelected:I===a,onSelect:l,onHover:c,onEdit:d,itemRefs:u},`${T.type}-${T.name}`)})},E.heading)),t[7]=d,t[8]=c,t[9]=l,t[10]=a,t[11]=s,t[12]=h,t[13]=g,t[14]=x,t[15]=v,t[16]=w,t[17]=y,t[18]=j,t[19]=k,t[20]=N}else h=t[12],g=t[13],x=t[14],v=t[15],w=t[16],y=t[17],j=t[18],k=t[19],N=t[20];let C;t[24]!==h||t[25]!==v?(C=r.jsx(h,{children:v}),t[24]=h,t[25]=v,t[26]=C):C=t[26];let S;t[27]!==g||t[28]!==C||t[29]!==w||t[30]!==y||t[31]!==j||t[32]!==k||t[33]!==N?(S=r.jsx(g,{id:w,value:y,onValueChange:j,shouldFilter:k,className:N,children:C}),t[27]=g,t[28]=C,t[29]=w,t[30]=y,t[31]=j,t[32]=k,t[33]=N,t[34]=S):S=t[34];let _;return t[35]!==x||t[36]!==S?(_=r.jsx("div",{className:x,children:S}),t[35]=x,t[36]=S,t[37]=_):_=t[37],_});function K3({suggestion:n,index:e,isSelected:t,onSelect:s,onHover:o,onEdit:i,itemRefs:a}){const l=b.useCallback(c=>{c?(c.id=`slash-suggestion-${e}`,a.current.set(e,c)):a.current.delete(e)},[e,a]);return r.jsxs("div",{className:"group/suggestion relative",children:[r.jsxs(Yh,{ref:l,value:`${n.type}-${n.name}`,className:"items-start gap-2.5 px-2 py-2 pr-10",onMouseEnter:()=>o(e),onSelect:()=>s(n),onMouseDown:c=>{c.preventDefault()},children:[r.jsx("div",{className:"mt-0.5 shrink-0",children:n.type==="command"?r.jsx(co,{className:"size-4 text-muted-foreground"}):r.jsx(Kp,{className:"size-4 text-muted-foreground"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("span",{className:"font-mono text-sm font-medium text-foreground",children:["/",n.name]}),W3(n)]}),n.description&&r.jsx("p",{className:"mt-0.5 line-clamp-1 text-xs text-muted-foreground",children:n.description})]}),t&&r.jsx(U3,{className:i&&n.filePath?"mr-6":void 0,children:"Enter"})]}),i&&n.filePath&&r.jsx(X,{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(),i(n.filePath)},"aria-label":`Edit ${n.name}`,children:r.jsx(Ls,{"data-icon":"inline-start"})})]})}function q3(n){return n.type==="command"}function V3(n){return n.type==="skill"}function G3(n){const e=U.c(25),{files:t,query:s,loading:o,selectedIndex:i,onSelect:a,onHover:l}=n;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=new Map,e[0]=c):c=e[0];const d=b.useRef(c);let f,u;e[1]!==i?(f=()=>{var y,j;(j=(y=d.current.get(i))==null?void 0:y.scrollIntoView)==null||j.call(y,{block:"nearest"})},u=[i],e[1]=i,e[2]=f,e[3]=u):(f=e[2],u=e[3]),b.useEffect(f,u);const m=t[i];let p;e[4]!==t||e[5]!==l?(p=y=>{const j=t.indexOf(y);j>=0&&l(j)},e[4]=t,e[5]=l,e[6]=p):p=e[6];let h;e[7]!==o?(h=o&&r.jsx(rt,{"data-icon":"inline-end","aria-label":"Loading project files",className:"size-3.5 animate-spin"}),e[7]=o,e[8]=h):h=e[8];let g;e[9]!==h?(g=r.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]!==o||e[13]!==l||e[14]!==a||e[15]!==s||e[16]!==i?(x=!o&&t.length===0?r.jsx("p",{className:"px-2 py-3 text-xs text-muted-foreground",children:s?`No files matching “${s}”`:"No project files found"}):t.map((y,j)=>r.jsxs(Yh,{ref:k=>{k?(k.id=`file-suggestion-${j}`,d.current.set(j,k)):d.current.delete(j)},value:y,onMouseEnter:()=>l(j),onSelect:()=>a(y),onMouseDown:Y3,children:[r.jsx(qp,{"data-icon":"inline-start","aria-hidden":"true",className:"size-3.5 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:y}),j===i&&r.jsx("span",{className:"text-xs text-muted-foreground",children:"↵"})]},y)),e[11]=t,e[12]=o,e[13]=l,e[14]=a,e[15]=s,e[16]=i,e[17]=x):x=e[17];let v;e[18]!==g||e[19]!==x?(v=r.jsx(Vh,{className:"max-h-70",children:r.jsx(Gh,{heading:g,children:x})}),e[18]=g,e[19]=x,e[20]=v):v=e[20];let w;return e[21]!==m||e[22]!==p||e[23]!==v?(w=r.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:r.jsx(qh,{id:"file-suggestions",value:m,onValueChange:p,shouldFilter:!1,className:"border shadow-sm",children:v})}),e[21]=m,e[22]=p,e[23]=v,e[24]=w):w=e[24],w}function Y3(n){return n.preventDefault()}const X3=Bn("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 Ct(n){const e=U.c(10);let t,s,o;e[0]!==n?({className:t,variant:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==t||e[5]!==o?(i=G(X3({variant:o}),t),e[4]=t,e[5]=o,e[6]=i):i=e[6];let a;return e[7]!==s||e[8]!==i?(a=r.jsx("div",{"data-slot":"alert",role:"alert",className:i,...s}),e[7]=s,e[8]=i,e[9]=a):a=e[9],a}function Dt(n){const e=U.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 o;e[3]!==t?(o=G("font-medium group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"alert-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function _t(n){const e=U.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 o;e[3]!==t?(o=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",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"alert-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function xs(n){const e=U.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 o;e[3]!==t?(o=G("absolute top-2 right-2",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"alert-action",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function kt(n){const e=U.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=r.jsx(Mb,{"data-slot":"collapsible",...t}),e[2]=t,e[3]=s):s=e[3],s}function an(n){const e=U.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=r.jsx(Ib,{"data-slot":"collapsible-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function Nt(n){const e=U.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 o;e[3]!==t?(o=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",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Rb,{"data-slot":"collapsible-content",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const J3={exit_only:"Exit plan mode",interactive:"Implement interactively",autopilot:"Implement with Autopilot",autopilot_fleet:"Implement with Fleet"};function sf(n){return J3[n]??n.replaceAll("_"," ")}function Q3(n){const e=U.c(46),{allowedPrompts:t,summary:s,planContent:o,actions:i,recommendedAction:a,responding:l,responseError:c,onApprove:d,onReject:f}=n;let u,m,p,h,g,x,v,w,y,j;if(e[0]!==d||e[1]!==a||e[2]!==s||e[3]!==i||e[4]!==l){const A=i===void 0?[]:i;p=l===void 0?!1:l;const E=a??A[0],T=A.filter(R=>R!==E);m=Ct,v="mb-3 pr-44",e[15]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(zi,{}),y=r.jsx(Dt,{children:"Plan ready for review"}),e[15]=w,e[16]=y):(w=e[15],y=e[16]);const M=s||"Approve the plan or ask the agent to revise it.";e[17]!==M?(j=r.jsx(_t,{children:M}),e[17]=M,e[18]=j):j=e[18],u=xs,h="flex gap-2";let I;e[19]!==p?(I=p&&r.jsx(rt,{className:"animate-spin","data-icon":"inline-start"}),e[19]=p,e[20]=I):I=e[20],g=r.jsxs(X,{size:"sm",disabled:p,onClick:()=>d(E),children:[I,p?"Sending...":E?sf(E):"Approve"]}),x=T.length>0&&r.jsxs(Rn,{children:[r.jsx(Mn,{render:r.jsx(X,{type:"button",variant:"outline",size:"icon-sm","aria-label":"Other plan actions",disabled:p}),children:r.jsx(nt,{"data-icon":"icon"})}),r.jsx(In,{align:"end",children:r.jsx(Bt,{children:T.map(R=>r.jsx(ct,{onClick:()=>d(R),children:sf(R)},R))})})]}),e[0]=d,e[1]=a,e[2]=s,e[3]=i,e[4]=l,e[5]=u,e[6]=m,e[7]=p,e[8]=h,e[9]=g,e[10]=x,e[11]=v,e[12]=w,e[13]=y,e[14]=j}else u=e[5],m=e[6],p=e[7],h=e[8],g=e[9],x=e[10],v=e[11],w=e[12],y=e[13],j=e[14];let k;e[21]!==f||e[22]!==p?(k=r.jsx(X,{variant:"ghost",size:"sm",disabled:p,onClick:f,children:"Reject"}),e[21]=f,e[22]=p,e[23]=k):k=e[23];let N;e[24]!==u||e[25]!==k||e[26]!==h||e[27]!==g||e[28]!==x?(N=r.jsxs(u,{className:h,children:[g,x,k]}),e[24]=u,e[25]=k,e[26]=h,e[27]=g,e[28]=x,e[29]=N):N=e[29];let C;e[30]!==c?(C=c&&r.jsx("div",{role:"alert",className:"col-span-full mt-2 text-xs text-destructive",children:c}),e[30]=c,e[31]=C):C=e[31];let S;e[32]!==o?(S=o&&r.jsxs(kt,{className:"col-span-full mt-2",children:[r.jsx(an,{render:r.jsx(X,{type:"button",variant:"ghost",size:"xs"}),children:"Review full plan"}),r.jsx(Nt,{children:r.jsx("pre",{className:"mt-2 max-h-64 overflow-auto whitespace-pre-wrap rounded-md bg-muted p-3 text-xs text-foreground",children:o})})]}),e[32]=o,e[33]=S):S=e[33];let _;e[34]!==t?(_=t&&t.length>0&&r.jsxs("div",{className:"col-span-full mt-2 flex flex-wrap gap-1",children:[r.jsx("span",{className:"mr-1 self-center text-xs text-muted-foreground",children:"Permissions requested:"}),t.map(Z3)]}),e[34]=t,e[35]=_):_=e[35];let P;return e[36]!==m||e[37]!==N||e[38]!==C||e[39]!==S||e[40]!==_||e[41]!==v||e[42]!==w||e[43]!==y||e[44]!==j?(P=r.jsxs(m,{className:v,children:[w,y,j,N,C,S,_]}),e[36]=m,e[37]=N,e[38]=C,e[39]=S,e[40]=_,e[41]=v,e[42]=w,e[43]=y,e[44]=j,e[45]=P):P=e[45],P}function Z3(n,e){return r.jsx(Me,{variant:"outline",children:n.prompt},e)}const ej=["allow","allow_always","deny"];function Gr(n,e){return(n.availableDecisions??ej).includes(e)}function tj(n){switch(n){case"Bash":return{label:"Run command",icon:co,tone:"cmd"};case"Edit":return{label:"Edit file",icon:Ou,tone:"write"};case"Write":return{label:"Write file",icon:Ou,tone:"write"};case"Read":return{label:"Read file",icon:vo,tone:"read"};case"Glob":return{label:"File search",icon:xn,tone:"search"};case"Grep":return{label:"Content search",icon:xn,tone:"search"};case"WebFetch":return{label:"Fetch URL",icon:El,tone:"net"};case"WebSearch":return{label:"Web search",icon:El,tone:"net"};default:return{label:n,icon:Fi,tone:"other"}}}function nj(n,e){if(n==="Bash"&&typeof e.command=="string")return e.command;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 o=e[s],i=typeof o=="string"?o:JSON.stringify(o);return i?[i.length>160?i.slice(0,157)+"…":i]:[]}).join(" · ")}function sj({requests:n,responding:e,onRespond:t,onRespondAll:s}){var w;const o=n[0],i=n.length,a=o?Gr(o,"allow"):!1,l=o?Gr(o,"allow_always"):!1,c=o?Gr(o,"deny"):!1,d=i>1&&n.every(y=>Gr(y,"allow")),f=b.useEffectEvent(y=>{if(!o)return;const j=y.target;if(j&&(j.tagName==="INPUT"||j.tagName==="TEXTAREA"||j.isContentEditable)||y.metaKey||y.ctrlKey||y.altKey)return;const k=y.key.toLowerCase();k==="a"&&y.shiftKey&&d?(y.preventDefault(),s("allow")):k==="a"&&a?(y.preventDefault(),t(o.requestId,"allow")):k==="s"&&l?(y.preventDefault(),t(o.requestId,"allow_always")):k==="d"&&c&&(y.preventDefault(),t(o.requestId,"deny"))});b.useEffect(()=>{const y=j=>f(j);return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[]);const u=o?tj(o.toolName):null,m=o?nj(o.toolName,o.input):null,p=(o==null?void 0:o.decisionReason)||(o==null?void 0:o.description)||(o==null?void 0:o.blockedPath),h=(((w=o==null?void 0:o.suggestions)==null?void 0:w.length)??0)>0;if(!o||!u)return null;const g=u.icon,x=e.has(o.requestId),v=i>1;return r.jsx("div",{className:"motion-slide-down-in border-b border-warning/20 bg-warning/5",children:r.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[r.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r.jsx("div",{className:"flex size-7 items-center justify-center rounded-md bg-warning/10 text-warning",children:r.jsx(Bp,{className:"size-4"})}),r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(g,{className:"size-4 text-muted-foreground"}),r.jsx("span",{className:"text-sm font-medium text-foreground",children:u.label})]})]}),m&&r.jsx("div",{className:"min-w-0 flex-1",children:r.jsx("code",{className:"block truncate rounded-md border bg-muted/40 px-2 py-1 font-mono text-xs text-muted-foreground",children:m})}),p&&p!==m&&r.jsx("p",{className:"hidden max-w-64 truncate text-xs text-muted-foreground xl:block",title:p,children:p}),v&&r.jsxs(Me,{variant:"outline",className:"shrink-0 tabular-nums",children:["+",i-1," more"]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[c&&r.jsxs(X,{variant:"ghost",size:"sm",className:"text-destructive",disabled:x,onClick:()=>t(o.requestId,"deny"),title:"Deny (D)",children:[r.jsx(jt,{"data-icon":"inline-start"}),"Deny",r.jsx("kbd",{className:"ml-0.5 font-mono text-xs text-muted-foreground",children:"D"})]}),l&&r.jsxs(X,{variant:"outline",size:"sm",disabled:x,onClick:()=>t(o.requestId,"allow_always"),title:h?"Apply Claude's suggested scoped permission rule (S)":`Allow ${o.toolName} for this session (S)`,children:[r.jsx($b,{"data-icon":"inline-start"}),h?"Remember rule":"Session",r.jsx("kbd",{className:"ml-0.5 font-mono text-xs text-muted-foreground",children:"S"})]}),d&&r.jsxs(X,{variant:"secondary",size:"sm",disabled:x,onClick:()=>s("allow"),title:"Allow all pending (⇧A)",children:["Allow all",r.jsx("kbd",{className:"ml-0.5 font-mono text-xs text-muted-foreground",children:"⇧A"})]}),a&&r.jsxs(X,{size:"sm",disabled:x,onClick:()=>t(o.requestId,"allow"),title:"Allow once (A)",children:[r.jsx(dt,{"data-icon":"inline-start"}),"Allow",r.jsx("kbd",{className:"ml-0.5 font-mono text-xs opacity-70",children:"A"})]}),!a&&!l&&!c&&r.jsx("span",{className:"text-xs text-muted-foreground",children:"Resolve this approval in Codex"})]})]})})}const oj=1568,rj=.85,of=35e5;function ij(n,e){let{width:t,height:s}=n;const o=Math.min(1,oj/Math.max(t,s));t=Math.round(t*o),s=Math.round(s*o);const i=document.createElement("canvas");i.width=t,i.height=s,i.getContext("2d").drawImage(n,0,0,t,s);const l=e==="image/jpeg"||e==="image/webp",c=l?"image/jpeg":"image/png";let d=i.toDataURL(c,l?rj:void 0),f=d.split(",")[1];if(f.length>of){let u=l?.7:.8;for(;f.length>of&&u>.3;)d=i.toDataURL("image/jpeg",u),f=d.split(",")[1],u-=.1;return{dataUrl:d,base64:f,mediaType:"image/jpeg"}}return{dataUrl:d,base64:f,mediaType:c}}function aj(n){const e=U.c(24),t=n===void 0?!0:n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=[],e[0]=s):s=e[0];const[o,i]=b.useState(s),[a,l]=b.useState(!1),[c,d]=b.useState(!1),f=b.useRef(t);let u,m;e[1]!==t?(u=()=>{f.current=t},m=[t],e[1]=t,e[2]=u,e[3]=m):(u=e[2],m=e[3]),b.useEffect(u,m);let p;e[4]!==t?(p=R=>{const $=Array.from(R).filter(dj);if(!t){$.length>0&&d(!0);return}d(!1);for(const D of $){const O=new FileReader;O.onload=()=>{if(!f.current){d(!0);return}const L=O.result,z=new Image;z.onload=()=>{if(!f.current){d(!0);return}const F=ij(z,D.type);i(H=>[...H,{id:crypto.randomUUID(),file:D,preview:F.dataUrl,data:F.base64,mediaType:F.mediaType}])},z.src=L},O.onerror=()=>{console.warn(`Failed to read image file: ${D.name}`)},O.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=R=>{i($=>$.filter((D,O)=>O!==R)),d(!1)},e[6]=g):g=e[6];const x=g;let v;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{i([]),d(!1)},e[7]=v):v=e[7];const w=v;let y;e[8]===Symbol.for("react.memo_cache_sentinel")?(y=()=>d(!1),e[8]=y):y=e[8];const j=y;let k;e[9]!==t?(k=R=>{R.preventDefault(),t&&l(!0)},e[9]=t,e[10]=k):k=e[10];const N=k;let C;e[11]===Symbol.for("react.memo_cache_sentinel")?(C=R=>{R.preventDefault(),R.currentTarget.contains(R.relatedTarget)||l(!1)},e[11]=C):C=e[11];const S=C;let _;e[12]!==h?(_=R=>{R.preventDefault(),l(!1),R.dataTransfer.files.length>0&&h(R.dataTransfer.files)},e[12]=h,e[13]=_):_=e[13];const P=_;let A;e[14]!==h?(A=R=>{var L;const $=(L=R.clipboardData)==null?void 0:L.items;if(!$)return;const D=Array.from($).filter(cj);if(D.length===0)return;R.preventDefault();const O=D.map(lj).filter(Boolean);h(O)},e[14]=h,e[15]=A):A=e[15];const E=A,T=!t&&o.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,M=!t&&o.length>0;let I;return e[16]!==N||e[17]!==P||e[18]!==E||e[19]!==o||e[20]!==a||e[21]!==T||e[22]!==M?(I={images:o,isDragOver:a,imageError:T,hasUnsupportedAttachments:M,dismissImageError:j,removeImage:x,clearImages:w,handleDragOver:N,handleDragLeave:S,handleDrop:P,handlePaste:E},e[16]=N,e[17]=P,e[18]=E,e[19]=o,e[20]=a,e[21]=T,e[22]=M,e[23]=I):I=e[23],I}function lj(n){return n.getAsFile()}function cj(n){return n.type.startsWith("image/")}function dj(n){return n.type.startsWith("image/")}function uj(n){const e=U.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 o=s===void 0?0:s;let i;return e[3]!==o||e[4]!==t?(i=r.jsx(zb,{"data-slot":"tooltip-provider",delay:o,...t}),e[3]=o,e[4]=t,e[5]=i):i=e[5],i}function Et(n){const e=U.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=r.jsx(uj,{children:r.jsx(Lb,{"data-slot":"tooltip",...t})}),e[2]=t,e[3]=s):s=e[3],s}function Pt(n){const e=U.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=r.jsx(Ob,{"data-slot":"tooltip-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function At(n){const e=U.c(20);let t,s,o,i,a,l,c;e[0]!==n?({className:s,side:i,sideOffset:a,align:l,alignOffset:c,children:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a,e[6]=l,e[7]=c):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5],l=e[6],c=e[7]);const d=i===void 0?"top":i,f=a===void 0?4:a,u=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]!==o||e[12]!==p?(h=r.jsx(Db,{"data-slot":"tooltip-content",className:p,...o,children:t}),e[10]=t,e[11]=o,e[12]=p,e[13]=h):h=e[13];let g;return e[14]!==u||e[15]!==m||e[16]!==d||e[17]!==f||e[18]!==h?(g=r.jsx(Fb,{children:r.jsx(Bb,{align:u,alignOffset:m,side:d,sideOffset:f,className:"isolate z-50",children:h})}),e[14]=u,e[15]=m,e[16]=d,e[17]=f,e[18]=h,e[19]=g):g=e[19],g}An("claude").contextWindow.compactBuffer;function fj(n,e){var a;const{defaultLimit:t,limits:s,extendedContext:o}=An(e).contextWindow,i=n.trim().toLowerCase();return o&&i.includes(o.marker)?o.limit:((a=s.find(l=>i.includes(l.match)))==null?void 0:a.limit)??t}function mj(n,e,t){const s=typeof n.input_tokens=="number"?n.input_tokens:0,o=typeof n.cache_creation_input_tokens=="number"?n.cache_creation_input_tokens:0,i=typeof n.cache_read_input_tokens=="number"?n.cache_read_input_tokens:0,a=s+o+i,l=fj(e,t),c=l-An(t).contextWindow.compactBuffer;return{used:a,limit:l,compactAt:c,percent:Math.min(100,a/c*100),percentAbsolute:Math.min(100,a/l*100)}}const pj=4;function Xh(n){return Math.ceil(n/pj)}function Jh(n){let e=0;for(const t of n)e+=t.length;return e}function hj(n){let e=0;for(const t of n)e+=JSON.stringify(t.input).length;return e}function gj(n){var t,s;const e=(s=(t=n.tokenUsage)==null?void 0:t.output_tokens_details)==null?void 0:s.thinking_tokens;return typeof e=="number"?e:Xh(Jh(n.thinking.map(o=>o.thinking)))}function xj(n){return Xh(Jh(n.assistantText)+hj(n.toolCalls))}function as(n){return Number.isFinite(n)?n<.01?`$${n.toFixed(4)}`:n<1?`$${n.toFixed(3)}`:`$${n.toFixed(2)}`:"—"}function Zi(n){return n?n.includes("fable")?"fable":n.includes("mythos")?"mythos":n.includes("opus")?"opus":n.includes("sonnet")?"sonnet":n.includes("haiku")?"haiku":n.length>20?n.slice(0,20)+"...":n:"unknown"}function tt(n){return n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}k`:String(n)}function Tn(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 bj(n){if(n<60)return`${n}s`;const e=Math.floor(n/60),t=n%60;return`${e}m ${t}s`}function Qh(n){return n>=1e6?`${(n/1e6).toFixed(1)}MB`:n>=1e3?`${(n/1e3).toFixed(0)}KB`:`${n}B`}function jr(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 o=Math.floor(s/24);return o<7?`${o}d`:new Date(n).toLocaleDateString()}function Ec(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 Pc(n){if(n.durationMs!==null)return n.durationMs;if(!n.timestamp)return null;let e=0,t=n.timestamp,s="";const o=a=>{a&&a>s&&(s=a)},i=()=>{if(!s)return;const a=new Date(s).getTime()-new Date(t).getTime();a>0&&(e+=a),s=""};for(const a of n.contentBlocks){if(a.kind==="task_notification"){i(),a.timestamp&&(t=a.timestamp);continue}if(o(a.timestamp),a.kind==="tool_calls"||a.kind==="plan_mode")for(const l of a.toolCalls)o(l.timestamp)}return i(),e>0?e:null}function mn(n,e){return n.length<=e?n:n.slice(0,e)+"..."}function hn(n){return ws(n).dirName.decode(n)??n}function ea(n,e=2){const t=n.replace(/\/+$/,"").split("/").filter(Boolean);return t.length<=e?n:t.slice(-e).join("/")}function ta(n){const e="/.worktrees/",t=n.indexOf(e);if(t===-1)return null;const s=n.slice(t+e.length).split("/")[0];return s?{parentPath:n.slice(0,t),worktreeName:s}:null}function zn(n){return n.replace(/\/+$/,"").split("/").at(-1)??n}function bs(n){const e=n.match(/^([^/]+)\/subagents\/agent-([^.]+)\.jsonl$/);return e?{parentSessionId:e[1],agentId:e[2],parentFileName:`${e[1]}.jsonl`}:null}function Zh(n){for(let e=n.length-1;e>=0;e--){const t=n[e];if(t.type==="assistant")return mj(t.message.usage,t.message.model??"","claude")}return null}const Nn="rounded-full border bg-background/80 shadow-sm backdrop-blur",na=b.memo(function(e){const t=U.c(8);let s,o;t[0]!==e?({className:s,...o}=e,t[0]=e,t[1]=s,t[2]=o):(s=t[1],o=t[2]);let i;t[3]!==s?(i=G("inline-block size-2 shrink-0 rounded-full bg-success",s),t[3]=s,t[4]=i):i=t[4];let a;return t[5]!==o||t[6]!==i?(a=r.jsx("span",{className:i,...o}),t[5]=o,t[6]=i,t[7]=a):a=t[7],a}),qa=b.memo(function(e){const t=U.c(17),{icon:s,label:o,onClick:i,disabled:a,className:l,iconClassName:c,size:d}=e,u=(d===void 0?"sm":d)==="sm"?"icon-xs":"icon-sm";let m;t[0]!==l||t[1]!==a||t[2]!==o||t[3]!==i||t[4]!==u?(m=r.jsx(X,{variant:"ghost",size:u,className:l,onClick:i,disabled:a,"aria-label":o}),t[0]=l,t[1]=a,t[2]=o,t[3]=i,t[4]=u,t[5]=m):m=t[5];let p;t[6]!==s||t[7]!==c?(p=r.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=r.jsx(Pt,{render:m,children:p}),t[9]=m,t[10]=p,t[11]=h):h=t[11];let g;t[12]!==o?(g=r.jsx(At,{children:o}),t[12]=o,t[13]=g):g=t[13];let x;return t[14]!==h||t[15]!==g?(x=r.jsxs(Et,{children:[h,g]}),t[14]=h,t[15]=g,t[16]=x):x=t[16],x});function vj(n){return n<10?"critical":n<30?"warning":"healthy"}const yj={critical:"border-destructive/30 bg-destructive/10 text-destructive",warning:"border-warning/30 bg-warning/10 text-warning",healthy:"text-muted-foreground"},eg=b.memo(function(e){const t=U.c(54),{rawMessages:s,showRemaining:o,showTooltip:i,warnOnly:a}=e,l=o===void 0?!1:o,c=i===void 0?!1:i,d=a===void 0?!1:a;let f,u,m,p,h,g,x,v,w,y,j,k,N;if(t[0]!==s||t[1]!==l||t[2]!==c||t[3]!==d){x=Symbol.for("react.early_return_sentinel");e:{const P=Zh(s);if(!P){x=null;break e}const A=Math.max(0,100-P.percent),E=vj(A);if(d&&E==="healthy"){x=null;break e}const T=Math.max(0,P.compactAt-P.used);let M;t[17]!==A||t[18]!==T||t[19]!==l?(M=l?`${A.toFixed(0)}% · ${tt(T)}`:`${A.toFixed(0)}%`,t[17]=A,t[18]=T,t[19]=l,t[20]=M):M=t[20];const I=M,R=yj[E],$=l&&"gap-1";let D;t[21]!==R||t[22]!==$?(D=G("shrink-0 tabular-nums",R,$),t[21]=R,t[22]=$,t[23]=D):D=t[23];let O;t[24]!==I||t[25]!==D?(O=r.jsx(Me,{variant:"outline",className:D,children:I}),t[24]=I,t[25]=D,t[26]=O):O=t[26];const L=O;if(!c){x=L;break e}u=Et,t[27]!==L?(g=r.jsx(Pt,{render:L}),t[27]=L,t[28]=g):g=t[28],f=At,m="flex flex-col gap-1 text-xs",t[29]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx("div",{className:"font-medium",children:"Context before auto-compact"}),t[29]=p):p=t[29];let z;t[30]!==T?(z=tt(T),t[30]=T,t[31]=z):z=t[31];let F;t[32]!==A?(F=A.toFixed(1),t[32]=A,t[33]=F):F=t[33],t[34]!==z||t[35]!==F?(h=r.jsxs("div",{children:[z," remaining (",F,"%)"]}),t[34]=z,t[35]=F,t[36]=h):h=t[36],v="text-muted-foreground",w=tt(P.used),y=" / ",j=tt(P.limit),k=" tokens used (",N=P.percentAbsolute.toFixed(1)}t[0]=s,t[1]=l,t[2]=c,t[3]=d,t[4]=f,t[5]=u,t[6]=m,t[7]=p,t[8]=h,t[9]=g,t[10]=x,t[11]=v,t[12]=w,t[13]=y,t[14]=j,t[15]=k,t[16]=N}else f=t[4],u=t[5],m=t[6],p=t[7],h=t[8],g=t[9],x=t[10],v=t[11],w=t[12],y=t[13],j=t[14],k=t[15],N=t[16];if(x!==Symbol.for("react.early_return_sentinel"))return x;let C;t[37]!==v||t[38]!==w||t[39]!==y||t[40]!==j||t[41]!==k||t[42]!==N?(C=r.jsxs("div",{className:v,children:[w,y,j,k,N,"%)"]}),t[37]=v,t[38]=w,t[39]=y,t[40]=j,t[41]=k,t[42]=N,t[43]=C):C=t[43];let S;t[44]!==f||t[45]!==m||t[46]!==p||t[47]!==h||t[48]!==C?(S=r.jsxs(f,{className:m,children:[p,h,C]}),t[44]=f,t[45]=m,t[46]=p,t[47]=h,t[48]=C,t[49]=S):S=t[49];let _;return t[50]!==u||t[51]!==g||t[52]!==S?(_=r.jsxs(u,{children:[g,S]}),t[50]=u,t[51]=g,t[52]=S,t[53]=_):_=t[53],_});function wj(n){const e=U.c(7),{isPlanApproval:t,isUserQuestion:s,elapsedSec:o}=n,{isLive:i}=it(),{chat:a}=yr(),{isConnected:l}=a,c=l||i;let d;e[0]!==o||e[1]!==t||e[2]!==s||e[3]!==c?(d=c&&!t&&!s&&r.jsxs("div",{className:"motion-enter mr-1 flex items-center gap-1.5",children:[o>0&&r.jsx("span",{className:"font-mono text-xs tabular-nums text-muted-foreground",children:bj(o)}),r.jsx(na,{})]}),e[0]=o,e[1]=t,e[2]=s,e[3]=c,e[4]=d):d=e[4];let f;return e[5]!==d?(f=r.jsx(r.Fragment,{children:d}),e[5]=d,e[6]=f):f=e[6],f}function jj(n){const e=U.c(26),{hasContent:t,onSubmit:s,submitLabel:o}=n,i=o===void 0?"Send message":o,{isLive:a,sessionSource:l,actions:c}=it(),{handleStopSession:d}=c,{chat:f}=yr(),{isConnected:u,interrupt:m}=f,p=u||a;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)??St((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=yw(g),e[3]=g,e[4]=x):x=e[4];const v=x;let w;e[5]!==v||e[6]!==m||e[7]!==p?(w=p&&r.jsxs(Et,{children:[r.jsx(Pt,{render:r.jsx(X,{variant:"outline",size:"icon-sm",className:"motion-enter shrink-0 rounded-full text-warning",onClick:m,"aria-label":v,title:v}),children:r.jsx(yc,{"data-icon":"inline-start",className:"fill-current"})}),r.jsxs(At,{children:[v," (Esc)"]})]}),e[5]=v,e[6]=m,e[7]=p,e[8]=w):w=e[8];let y;e[9]!==g||e[10]!==d||e[11]!==p?(y=p&&zt(g).stopSession&&r.jsxs(Et,{children:[r.jsx(Pt,{render:r.jsx(X,{variant:"ghost",size:"icon-sm",className:"motion-enter shrink-0 rounded-full text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:d,"aria-label":"Stop session",title:"Stop session"}),children:r.jsx(Ub,{"data-icon":"inline-start"})}),r.jsx(At,{children:"Stop session"})]}),e[9]=g,e[10]=d,e[11]=p,e[12]=y):y=e[12];const j=t?"default":"secondary",k=!t&&"text-muted-foreground";let N;e[13]!==k?(N=G("shrink-0 rounded-full",k),e[13]=k,e[14]=N):N=e[14];const C=!t;let S;e[15]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx(Wb,{"data-icon":"inline-start"}),e[15]=S):S=e[15];let _;e[16]!==s||e[17]!==i||e[18]!==N||e[19]!==C||e[20]!==j?(_=r.jsx(X,{variant:j,size:"icon-sm",className:N,disabled:C,onClick:s,"aria-label":i,title:i,children:S}),e[16]=s,e[17]=i,e[18]=N,e[19]=C,e[20]=j,e[21]=_):_=e[21];let P;return e[22]!==_||e[23]!==w||e[24]!==y?(P=r.jsxs("div",{className:"flex items-center gap-1",children:[w,y,_]}),e[22]=_,e[23]=w,e[24]=y,e[25]=P):P=e[25],P}function rf(n){const e=U.c(34),{error:t}=n,[s,o]=b.useState(!1),[i,a]=b.useState(!1);let l;e[0]!==t?(l=t.split(`
|
|
3
|
+
`),e[0]=t,e[1]=l):l=e[1];const c=l[0];let d;e[2]!==t||e[3]!==c?(d=t.includes(`
|
|
4
|
+
`)||t.length>c.length,e[2]=t,e[3]=c,e[4]=d):d=e[4];const f=d;let u;e[5]!==t?(u=async()=>{try{await navigator.clipboard.writeText(t),a(!0),setTimeout(()=>a(!1),1500)}catch{}},e[5]=t,e[6]=u):u=e[6];const m=u;let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=()=>o(!0),e[7]=p):p=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(bn,{"data-icon":"inline-start"}),e[8]=h):h=e[8];let g;e[9]!==c?(g=r.jsx("span",{className:"truncate",children:c}),e[9]=c,e[10]=g):g=e[10];let x;e[11]!==f?(x=f&&r.jsx("span",{className:"shrink-0 opacity-60",children:"(details)"}),e[11]=f,e[12]=x):x=e[12];let v;e[13]!==g||e[14]!==x?(v=r.jsxs(X,{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]=v):v=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsxs(Ss,{children:[r.jsxs(Xn,{className:"flex items-center gap-2 text-destructive",children:[r.jsx(bn,{className:"size-4"}),"Error details"]}),r.jsx(Jn,{children:"The full output from the failed request, including the underlying process stderr."})]}),e[16]=w):w=e[16];let y;e[17]!==t?(y=r.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]=y):y=e[18];let j;e[19]!==i?(j=i?r.jsx(dt,{"data-icon":"inline-start"}):r.jsx(En,{"data-icon":"inline-start"}),e[19]=i,e[20]=j):j=e[20];const k=i?"Copied":"Copy";let N;e[21]!==m||e[22]!==j||e[23]!==k?(N=r.jsx("div",{className:"flex justify-end",children:r.jsxs(X,{type:"button",variant:"outline",size:"sm",onClick:m,children:[j,k]})}),e[21]=m,e[22]=j,e[23]=k,e[24]=N):N=e[24];let C;e[25]!==y||e[26]!==N?(C=r.jsxs(Yn,{className:"max-w-2xl",children:[w,y,N]}),e[25]=y,e[26]=N,e[27]=C):C=e[27];let S;e[28]!==s||e[29]!==C?(S=r.jsx(Gn,{open:s,onOpenChange:o,children:C}),e[28]=s,e[29]=C,e[30]=S):S=e[30];let _;return e[31]!==S||e[32]!==v?(_=r.jsxs(r.Fragment,{children:[v,S]}),e[31]=S,e[32]=v,e[33]=_):_=e[33],_}function Sj(n){const e=U.c(17),{suggestion:t,onAccept:s}=n,[o,i]=b.useState(null);if(!t||t===o)return null;let a;e[0]!==s||e[1]!==t?(a=()=>{i(t),s(t)},e[0]=s,e[1]=t,e[2]=a):a=e[2];let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Kp,{"data-icon":"inline-start"}),e[3]=l):l=e[3];let c;e[4]!==t?(c=r.jsx("span",{className:"truncate",children:t}),e[4]=t,e[5]=c):c=e[5];let d;e[6]!==a||e[7]!==c?(d=r.jsxs(X,{type:"button",variant:"ghost",size:"sm",title:"Put this in the composer",onClick:a,className:"min-w-0 flex-1 justify-start text-muted-foreground",children:[l,c]}),e[6]=a,e[7]=c,e[8]=d):d=e[8];let f;e[9]!==t?(f=()=>i(t),e[9]=t,e[10]=f):f=e[10];let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(jt,{}),e[11]=u):u=e[11];let m;e[12]!==f?(m=r.jsx(X,{type:"button",variant:"ghost",size:"icon","aria-label":"Dismiss suggestion",onClick:f,className:"shrink-0 text-muted-foreground",children:u}),e[12]=f,e[13]=m):m=e[13];let p;return e[14]!==d||e[15]!==m?(p=r.jsxs("div",{className:"motion-enter mb-1 flex items-center gap-1",children:[d,m]}),e[14]=d,e[15]=m,e[16]=p):p=e[16],p}function kj(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 Nj(n,e,t){return`${n.slice(0,e.start)}@${t} `}const sa={terminal:!0,configWrite:!0,hostFiles:!0,manageUsers:!0,manageWorkspaces:!0,manageDevices:!0,killAny:!0,viewAllSessions:!0,viewUsage:!0,share:!0,runFlows:!0},Sr={terminal:!1,configWrite:!1,hostFiles:!1,manageUsers:!1,manageWorkspaces:!1,manageDevices:!1,killAny:!1,viewAllSessions:!1,viewUsage:!1,share:!1,runFlows:!1};let tg=sa;const Ll=new Set;function so(n){tg=(n==null?void 0:n.capabilities)??sa;for(const e of Ll)e()}function ut(n){return tg[n]}function Cj(n){return Ll.add(n),()=>Ll.delete(n)}function vn(n){const e=U.c(3);let t,s;return e[0]!==n?(t=()=>ut(n),s=()=>ut(n),e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]),b.useSyncExternalStore(Cj,t,s)}function _j(n){const e=n.files;return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function Tj(n,e,t){const s=vn("hostFiles"),[o,i]=b.useState([]),[a,l]=b.useState(!1);return b.useEffect(()=>{if(!s||!t||!n){i([]),l(!1);return}const c=new AbortController,d=window.setTimeout(async()=>{l(!0);try{const f=await ye(`/api/project-files?cwd=${encodeURIComponent(n)}&q=${encodeURIComponent(e)}&limit=30`,{signal:c.signal});if(!f.ok)throw new Error(`Request failed (${f.status})`);const u=await f.json();c.signal.aborted||i(_j(u))}catch{c.signal.aborted||i([])}finally{c.signal.aborted||l(!1)}},120);return()=>{window.clearTimeout(d),c.abort()}},[s,n,t,e]),{files:o,loading:a}}const zl="cogpit-share-revoked";function Ej(){window.dispatchEvent(new Event(zl))}async function ng(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&&Ej(),s}function kr(n,e){return ng(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e??{})})}async function Pj(){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 Aj(n,e){return kr("/api/share/send-message",e!=null&&e.length?{message:n,images:e}:{message:n})}function Rj(){return kr("/api/share/interrupt")}function Mj(){return kr("/api/share/stop")}async function Ij(n,e){return(await kr("/api/share/permission",{requestId:n,behavior:e})).ok}async function $j(n,e){try{const t=await kr("/api/share/answer",{toolUseId:n,answers:e});return{ok:t.ok,gone:t.status===404}}catch{return{ok:!1,gone:!1}}}async function Oj(){try{const n=await ng("/api/share/pending");if(!n.ok)return null;const e=await n.json();return Array.isArray(e.permissions)?e.permissions:[]}catch{return null}}const Dj=/^\/shared\/([^/]+)\/?$/;function sg(n){const e=Dj.exec(n);if(!e)return null;try{return decodeURIComponent(e[1])||null}catch{return null}}function oa(n){return sg(n)!==null}function Lj(n){return`/shared/${encodeURIComponent(n)}`}function QM(n){return[...n].join(", ")}async function Ac(n,e,t){if(oa(window.location.pathname))return $j(e,t);try{const s=await ye("/api/ask-user-answer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:n,toolUseId:e,answers:t})});return{ok:s.ok,gone:s.status===404}}catch{return{ok:!1,gone:!1}}}async function zj(n,e,t){try{return(await ye(`/api/permissions/${encodeURIComponent(n)}/plan`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:e,...t})})).ok}catch{return!1}}function ra(n){const e=U.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 o;e[3]!==t?(o=G("flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent 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:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("textarea",{"data-slot":"textarea",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Yr(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 o;if(e){const a=n.style.width;n.style.width=`${Math.max(100,n.offsetWidth-140)}px`,o=n.scrollHeight>48,n.style.width=a}else o=s>44;return t!==s&&(n.style.height=t+"px",n.offsetHeight,n.style.transition="height 150ms ease"),n.style.height=s+"px",o}function Fj(n,e,t,s,o,i){return s?"Resolve approval to continue...":n?"Provide feedback to request changes...":e?"Type a custom response...":i?o?"Steer…":"Message…":o?"Steer the active turn… (Enter to send)":t?"Message... (Enter to send)":"Send a message... (Enter to send)"}function Bj(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"}const Fl=b.memo(b.forwardRef(function({allowImages:e=!0,agentKind:t,projectCwd:s,leadingAccessory:o,compact:i=!1},a){var Le;const l=vn("hostFiles"),{session:c,isLive:d,actions:{handleEditConfig:f},pendingInteraction:u,permissionRequests:m,permissionResponding:p,respondPermission:h,respondAllPermissions:g,slashSuggestions:x,slashSuggestionsLoading:v,turnError:w,promptSuggestion:y}=it(),{chat:{status:j,error:k,isConnected:N,sendMessage:C,interrupt:S}}=yr(),_=N||d,[P,A]=b.useState(""),[E,T]=b.useState(!1),[M,I]=b.useState(!1),[R,$]=b.useState(null),D=b.useRef(null),O=b.useRef(null),L=b.useRef(!1),z=b.useRef(""),F=b.useRef(null);b.useEffect(()=>{z.current=P},[P]);const H=b.useCallback(ne=>{L.current=ne,T(ne)},[]),{images:B,isDragOver:W,imageError:K,hasUnsupportedAttachments:V,dismissImageError:Y,removeImage:q,clearImages:J,handleDragOver:Z,handleDragLeave:Q,handleDrop:ee,handlePaste:oe}=aj(e),[se,re]=b.useState(0),[ie,ae]=b.useState(0),[te,he]=b.useState(!1),me=P.startsWith("/")&&!P.includes(" "),le=me?P.slice(1):"",xe=b.useMemo(()=>{if(!me)return[];const ne=le.toLowerCase(),fe=x.filter(Ue=>ne?Ue.name.toLowerCase().includes(ne)||Ue.description.toLowerCase().includes(ne):!0),Se=fe.filter(Ue=>Ue.type==="command"),$e=fe.filter(Ue=>Ue.type==="skill");return[...Se,...$e]},[me,le,x]),ge=b.useMemo(()=>kj(P),[P]),ce=!!(l&&ge&&s&&!te),we=Tj(s,(ge==null?void 0:ge.query)??"",ce);b.useEffect(()=>{re(0)},[le]),b.useEffect(()=>{ae(0)},[ge==null?void 0:ge.query]);const pe=Ih(N),ue=(u==null?void 0:u.type)==="plan"?u.requestId??null:null;b.useEffect(()=>{O.current=ue,D.current=null,I(!1),$(null)},[ue]);const je=b.useCallback(async ne=>{const fe=u;if(!(c!=null&&c.sessionId)||(fe==null?void 0:fe.type)!=="question")return;const Se=fe.questions[0];if(!Se||!ne.trim())return;(await Ac(c.sessionId,fe.toolUseId,{[Se.question]:ne})).ok||C(ne)},[u,c==null?void 0:c.sessionId,C]),Ne=b.useCallback(async(ne,fe,Se)=>{const $e=u;if(($e==null?void 0:$e.type)==="plan"&&$e.provider==="copilot"&&$e.requestId&&(c!=null&&c.sessionId)){const Ue=$e.requestId;if(D.current)return!1;D.current=Ue,I(!0),$(null);try{const We=await zj(c.sessionId,Ue,{approved:ne,...fe?{selectedAction:fe}:{},...Se?{feedback:Se}:{}});return!We&&O.current===Ue&&$("Couldn't send the plan response. Try again."),We}finally{D.current===Ue&&(D.current=null,I(!1))}}return C(ne?"yes":Se||"no"),!0},[u,c==null?void 0:c.sessionId,C]),Re=b.useCallback(()=>{requestAnimationFrame(()=>{const ne=F.current;ne&&(ne.focus(),ne.selectionStart=ne.selectionEnd=ne.value.length,H(Yr(ne,L.current)))})},[H]),Te=b.useCallback(ne=>{A(`/${ne.name} `),re(0),Re()},[Re]),Pe=b.useCallback(ne=>{A(ne),Re()},[Re]),Oe=b.useCallback(ne=>{if(!ge)return;const fe=Nj(P,ge,ne);A(fe),he(!0),ae(0),requestAnimationFrame(()=>{const Se=F.current;Se&&(Se.focus(),Se.selectionStart=Se.selectionEnd=Se.value.length,H(Yr(Se,L.current)))})},[ge,P,H]),Fe=b.useCallback(async()=>{const ne=P.trim();if(!ne&&B.length===0||!e&&B.length>0)return;if((u==null?void 0:u.type)==="question"){je(ne),A(""),H(!1),F.current&&(F.current.style.height="auto");return}if((u==null?void 0:u.type)==="plan"&&u.provider==="copilot"){if(!ne||!await Ne(!1,void 0,ne))return;A(""),H(!1),F.current&&(F.current.style.height="auto");return}const fe=e&&B.length>0?B.map(Se=>({data:Se.data,mediaType:Se.mediaType})):void 0;C(ne,fe),A(""),J(),H(!1),F.current&&(F.current.style.height="auto")},[P,B,e,C,J,H,u,je,Ne]),ze=b.useCallback(ne=>{if(ce&&ne.key==="Escape"){ne.preventDefault(),he(!0);return}if(ce&&we.files.length>0){if(ne.key==="ArrowDown"){ne.preventDefault(),ae(fe=>fe<we.files.length-1?fe+1:0);return}if(ne.key==="ArrowUp"){ne.preventDefault(),ae(fe=>fe>0?fe-1:we.files.length-1);return}if(ne.key==="Tab"||ne.key==="Enter"&&!ne.shiftKey){ne.preventDefault();const fe=we.files[ie];fe&&Oe(fe);return}}if(me&&xe.length>0){if(ne.key==="ArrowDown"){ne.preventDefault(),re(fe=>fe<xe.length-1?fe+1:0);return}if(ne.key==="ArrowUp"){ne.preventDefault(),re(fe=>fe>0?fe-1:xe.length-1);return}if(ne.key==="Tab"||ne.key==="Enter"&&!ne.shiftKey){ne.preventDefault();const fe=xe[se];fe&&Te(fe);return}if(ne.key==="Escape"){ne.preventDefault(),A("");return}}if(ne.key==="Escape"&&_&&S){ne.preventDefault(),S();return}ne.key==="Enter"&&!ne.shiftKey&&(ne.preventDefault(),Fe())},[Fe,_,S,ce,we.files,ie,Oe,me,xe,se,Te]),Be=b.useCallback(ne=>{A(ne.target.value),he(!1),H(Yr(ne.target,L.current))},[H]);b.useImperativeHandle(a,()=>({focus:()=>{var ne;return(ne=F.current)==null?void 0:ne.focus()},getText:()=>z.current,setText:ne=>{A(ne),he(!1),requestAnimationFrame(()=>H(Yr(F.current,L.current)))}}),[H]);const _e=(u==null?void 0:u.type)==="plan",He=(u==null?void 0:u.type)==="question",Ie=m.length>0,Ce=(P.trim().length>0||B.length>0)&&!V,de=zt(t??Fs).midTurnSteering&&_,Ee=ce?"file-suggestions":me?"slash-suggestions":void 0,Ae=ce&&we.files[ie]?`file-suggestion-${ie}`:me&&xe[se]?`slash-suggestion-${se}`:void 0;return r.jsxs("div",{className:G("relative bg-background pb-0",i?"px-2 pt-2":"px-3 pt-2",W&&"ring-2 ring-info/40 ring-inset"),onDragOver:Z,onDragLeave:Q,onDrop:ee,children:[W&&r.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:r.jsx("span",{className:"text-sm font-medium text-info",children:"Drop images here"})}),me&&r.jsx(H3,{suggestions:xe,filter:le,loading:v,selectedIndex:se,onSelect:Te,onHover:re,onEdit:f}),ce&&r.jsx(G3,{files:we.files,query:(ge==null?void 0:ge.query)??"",loading:we.loading,selectedIndex:ie,onSelect:Oe,onHover:ae}),r.jsxs("div",{children:[_e&&r.jsx(Q3,{allowedPrompts:u.allowedPrompts,summary:u.summary,planContent:u.planContent,actions:u.actions,recommendedAction:u.recommendedAction,responding:M,responseError:R,onApprove:ne=>{Ne(!0,ne)},onReject:()=>{Ne(!1)}}),r.jsx(Sj,{suggestion:y,onAccept:Pe}),B.length>0&&r.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:B.map((ne,fe)=>r.jsxs("div",{className:"motion-list-item relative group/thumb",children:[r.jsx("img",{src:ne.preview,alt:`Upload ${fe+1}`,className:"h-16 w-auto rounded-md border bg-muted object-contain"}),r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>q(fe),className:"absolute -right-1.5 -top-1.5 size-5 rounded-full border bg-background 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 ${fe+1}`,children:r.jsx(jt,{className:"size-3","data-icon":"icon"})})]},ne.id))}),K&&r.jsxs("div",{role:"status","aria-live":"polite",className:"motion-enter mb-2 flex items-center gap-2 text-xs text-warning",children:[r.jsx("span",{className:"flex-1",children:K}),!V&&r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",onClick:Y,className:"text-muted-foreground","aria-label":"Dismiss image notice",children:r.jsx(jt,{"data-icon":"icon"})})]}),r.jsxs("div",{className:G("relative overflow-hidden rounded-xl border bg-prompt-surface shadow-xs",Bj(_e,He,Ie),"focus-within:ring-3"),children:[Ie&&r.jsx(sj,{requests:m,responding:p,onRespond:h,onRespondAll:g},(Le=m[0])==null?void 0:Le.requestId),r.jsxs("div",{className:G("grid min-w-0 items-end",E?"grid-cols-[1fr_auto]":"grid-cols-[auto_minmax(0,1fr)_auto]"),children:[o&&r.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:o}),r.jsx(ra,{ref:F,value:P,onChange:Be,onKeyDown:ze,onPaste:oe,onFocus:()=>{setTimeout(()=>{var ne;return(ne=F.current)==null?void 0:ne.scrollIntoView({behavior:"smooth",block:"center"})},300)},placeholder:Fj(_e,He,N,Ie,de,i),"aria-label":"Message",role:"combobox","aria-autocomplete":"list","aria-expanded":!!Ee,"aria-controls":Ee,"aria-activedescendant":Ae,rows:1,className:G("min-h-0 w-full resize-none rounded-none border-0 bg-transparent text-foreground shadow-none placeholder:text-muted-foreground focus-visible:border-transparent focus-visible:ring-0 dark:bg-transparent",E?G("col-span-2 row-start-1",i?"py-2.5 pr-3":"py-3 pr-4"):G("col-start-2 row-start-1",i?"py-2 pr-1":"py-2.5 pr-2"),i?"pl-2 text-sm":"pl-4 text-sm")}),r.jsxs("div",{className:G("flex shrink-0 items-center justify-end",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"),children:[r.jsx(wj,{isPlanApproval:_e,isUserQuestion:He,elapsedSec:pe}),r.jsx(jj,{hasContent:Ce,onSubmit:Fe,submitLabel:de?"Steer active turn":"Send message"})]})]})]}),j==="error"&&k&&r.jsx(rf,{error:k},k),w&&r.jsx(rf,{error:w},w)]})]})}));function Uj(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)?n:null}function Wj(n){for(let e=n.length-1;e>=0;e-=1){const t=n[e];if(t.type!=="attachment")continue;const s=Uj(t.attachment);if((s==null?void 0:s.type)!=="goal_status")continue;const o=typeof s.condition=="string"?s.condition:"",i=s.met===!0,a=s.failed===!0;return s.sentinel===!0&&i||!o?null:{condition:o,status:a?"failed":i?"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}const Hj={section:null,canCreate:!1,beginEditing:()=>{}},Rc=b.createContext(Hj);function og(){return b.useContext(Rc)}const rg="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-1",ig="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-2";function Kj(n){switch(n){case"active":return"Goal active";case"achieved":return"Achieved";default:return"Needs attention"}}function qj(n){switch(n){case"failed":return"destructive";case"achieved":return"secondary";default:return"outline"}}function Vj(n){const e=U.c(80),{session:t,onSendCommand:s,children:o}=n;let i;e[0]!==t.rawMessages?(i=Wj(t.rawMessages),e[0]=t.rawMessages,e[1]=i):i=e[1];const a=i,[l,c]=b.useState(),[d,f]=b.useState(!1),[u,m]=b.useState(""),[p,h]=b.useState(null),g=a?`${a.status}\0${a.condition}`:"",[x,v]=b.useState(g);x!==g&&(v(g),c(void 0));const w=l!==void 0?l:a;let y;e[2]!==(w==null?void 0:w.condition)?(y=()=>{m((w==null?void 0:w.condition)??""),h(null),f(!0)},e[2]=w==null?void 0:w.condition,e[3]=y):y=e[3];const j=y;let k;e[4]!==u||e[5]!==s?(k=()=>{const M=u.trim();if(M){if(M.length>4e3){h("Goal conditions can be at most 4,000 characters");return}c({condition:M,status:"active",iterations:0,durationMs:0,tokens:0}),f(!1),s(`/goal ${M}`)}},e[4]=u,e[5]=s,e[6]=k):k=e[6];const N=k;let C;e[7]!==s?(C=()=>{c(null),f(!1),s("/goal clear")},e[7]=s,e[8]=C):C=e[8];const S=C;let _;if(e[9]!==j||e[10]!==S||e[11]!==u||e[12]!==d||e[13]!==p||e[14]!==w||e[15]!==N){if(_=null,d){let M;e[17]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(Xo,{className:"size-3.5","data-icon":"inline-start"}),e[17]=M):M=e[17];const I=w?"Replace goal":"Set a long-running goal";let R;e[18]!==I?(R=r.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[M,I]}),e[18]=I,e[19]=R):R=e[19];const $=!!p;let D;e[20]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(xt,{className:"sr-only",htmlFor:"claude-goal-condition",children:"Goal condition"}),e[20]=D):D=e[20];let O;e[21]===Symbol.for("react.memo_cache_sentinel")?(O=q=>m(q.target.value),e[21]=O):O=e[21];const L=!!p;let z;e[22]!==u||e[23]!==L?(z=r.jsx(ra,{id:"claude-goal-condition",value:u,onChange:O,placeholder:"A measurable condition Claude should keep working toward…",rows:2,maxLength:4e3,"aria-invalid":L,autoFocus:!0}),e[22]=u,e[23]=L,e[24]=z):z=e[24];let F;e[25]!==p?(F=r.jsx(us,{children:p}),e[25]=p,e[26]=F):F=e[26];let H;e[27]!==z||e[28]!==F||e[29]!==$?(H=r.jsxs(gt,{"data-invalid":$,children:[D,z,F]}),e[27]=z,e[28]=F,e[29]=$,e[30]=H):H=e[30];let B;e[31]===Symbol.for("react.memo_cache_sentinel")?(B=r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:()=>f(!1),children:[r.jsx(jt,{"data-icon":"inline-start"}),"Cancel"]}),e[31]=B):B=e[31];let W;e[32]!==u?(W=u.trim(),e[32]=u,e[33]=W):W=e[33];const K=!W;let V;e[34]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx(dt,{"data-icon":"inline-start"}),e[34]=V):V=e[34];let Y;e[35]!==N||e[36]!==K?(Y=r.jsxs("div",{className:"mt-2 flex items-center justify-end gap-1",children:[B,r.jsxs(X,{type:"button",size:"xs",onClick:N,disabled:K,children:[V,"Start goal"]})]}),e[35]=N,e[36]=K,e[37]=Y):Y=e[37],_=r.jsxs("section",{className:ig,"aria-label":"Claude goal editor",children:[R,H,Y]})}else if(w){let M;e[38]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(Xo,{className:"size-3.5 shrink-0 text-primary","data-icon":"inline-start"}),e[38]=M):M=e[38];let I;e[39]!==w.condition?(I=r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",title:w.condition,children:w.condition}),e[39]=w.condition,e[40]=I):I=e[40];let R;e[41]!==w.status?(R=qj(w.status),e[41]=w.status,e[42]=R):R=e[42];let $;e[43]!==w.status?($=Kj(w.status),e[43]=w.status,e[44]=$):$=e[44];let D;e[45]!==R||e[46]!==$?(D=r.jsx(Me,{variant:R,children:$}),e[45]=R,e[46]=$,e[47]=D):D=e[47];const O=w.iterations,L=w.iterations===1?"":"s";let z;e[48]!==w.tokens?(z=tt(w.tokens),e[48]=w.tokens,e[49]=z):z=e[49];let F;e[50]!==w.durationMs?(F=Math.round(w.durationMs/6e4),e[50]=w.durationMs,e[51]=F):F=e[51];const H=Math.max(0,F);let B;e[52]!==w.iterations||e[53]!==L||e[54]!==z||e[55]!==H?(B=r.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[O," turn",L," · ",z," · ",H,"m"]}),e[52]=w.iterations,e[53]=L,e[54]=z,e[55]=H,e[56]=B):B=e[56];let W;e[57]===Symbol.for("react.memo_cache_sentinel")?(W=r.jsx(Ls,{"data-icon":"icon"}),e[57]=W):W=e[57];let K;e[58]!==j?(K=r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",onClick:j,"aria-label":"Replace goal",children:W}),e[58]=j,e[59]=K):K=e[59];let V;e[60]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx(Bi,{"data-icon":"icon"}),e[60]=V):V=e[60];let Y;e[61]!==S?(Y=r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",onClick:S,"aria-label":"Clear goal",children:V}),e[61]=S,e[62]=Y):Y=e[62];let q;e[63]!==K||e[64]!==Y?(q=r.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[K,Y]}),e[63]=K,e[64]=Y,e[65]=q):q=e[65];let J;e[66]!==B||e[67]!==q||e[68]!==I||e[69]!==D?(J=r.jsxs("div",{className:"flex items-center gap-2",children:[M,I,D,B,q]}),e[66]=B,e[67]=q,e[68]=I,e[69]=D,e[70]=J):J=e[70];let Z;e[71]!==w.reason?(Z=w.reason&&r.jsx("p",{className:"line-clamp-2 pb-0.5 pl-5 text-xs text-muted-foreground",children:w.reason}),e[71]=w.reason,e[72]=Z):Z=e[72],_=r.jsxs("section",{className:rg,"aria-label":"Claude goal",children:[J,Z]})}e[9]=j,e[10]=S,e[11]=u,e[12]=d,e[13]=p,e[14]=w,e[15]=N,e[16]=_}else _=e[16];const P=!w&&!d;let A;e[73]!==j||e[74]!==_||e[75]!==P?(A={section:_,canCreate:P,beginEditing:j},e[73]=j,e[74]=_,e[75]=P,e[76]=A):A=e[76];const E=A;let T;return e[77]!==o||e[78]!==E?(T=r.jsx(Rc.Provider,{value:E,children:o}),e[77]=o,e[78]=E,e[79]=T):T=e[79],T}function Ot(n){const e=U.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 o;e[3]!==t?(o=G("h-8 w-full min-w-0 rounded-lg border border-input bg-transparent 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:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Hb,{"data-slot":"input",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Mc(n){const e=U.c(13);let t,s,o,i;e[0]!==n?({className:s,children:t,value:i,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);let a;e[5]!==s?(a=G("flex flex-wrap gap-3",s),e[5]=s,e[6]=a):a=e[6];let l;e[7]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Gj,{children:r.jsx(Yj,{})}),e[7]=l):l=e[7];let c;return e[8]!==t||e[9]!==o||e[10]!==a||e[11]!==i?(c=r.jsxs(Kb,{value:i,"data-slot":"progress",className:a,...o,children:[t,l]}),e[8]=t,e[9]=o,e[10]=a,e[11]=i,e[12]=c):c=e[12],c}function Gj(n){const e=U.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 o;e[3]!==t?(o=G("relative flex h-1 w-full items-center overflow-x-hidden rounded-full bg-muted",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(qb,{className:o,"data-slot":"progress-track",...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Yj(n){const e=U.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 o;e[3]!==t?(o=G("h-full bg-primary transition-[width] duration-150 ease-out motion-reduce:transition-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Vb,{"data-slot":"progress-indicator",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Xj(n){return n==="usageLimited"?"Usage limited":n==="budgetLimited"?"Budget limited":n.charAt(0).toUpperCase()+n.slice(1)}function Jj(n){return n==="complete"?"secondary":n==="blocked"||n.endsWith("Limited")?"destructive":n==="paused"?"outline":"default"}function Qj({threadId:n,children:e}){const[t,s]=b.useState(null),[o,i]=b.useState(!0),[a,l]=b.useState(!1),[c,d]=b.useState(""),[f,u]=b.useState(""),[m,p]=b.useState(!1),[h,g]=b.useState(null),x=b.useCallback(async S=>{try{const _=await ye(`/api/codex/goals/${encodeURIComponent(n)}`,{signal:S});if(_.status===404||_.status===501){i(!1);return}if(!_.ok)return;const P=await _.json();s(P.goal),i(!0)}catch{}},[n]);b.useEffect(()=>{const S=new AbortController;x(S.signal);const _=o?setInterval(()=>void x(),1e4):void 0;return()=>{S.abort(),_!==void 0&&clearInterval(_)}},[x,o]);const v=b.useCallback(()=>{var S;d((t==null?void 0:t.objective)??""),u(((S=t==null?void 0:t.tokenBudget)==null?void 0:S.toString())??""),g(null),l(!0)},[t]),w=async()=>{const S=c.trim();if(!S)return;const _=f.trim()?Number(f):null;if(_!==null&&(!Number.isSafeInteger(_)||_<=0)){g("Token budget must be a positive whole number");return}p(!0),g(null);try{const P=await ye(`/api/codex/goals/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({objective:S,status:(t==null?void 0:t.status)==="complete"?"active":(t==null?void 0:t.status)??"active",tokenBudget:_})}),A=await P.json();if(!P.ok)throw new Error(A.error||"Could not save goal");s(A.goal),l(!1)}catch(P){g(P instanceof Error?P.message:"Could not save goal")}finally{p(!1)}},y=async S=>{if(t){p(!0);try{const _=await ye(`/api/codex/goals/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:S})});_.ok&&s((await _.json()).goal)}finally{p(!1)}}},j=async()=>{p(!0);try{(await ye(`/api/codex/goals/${encodeURIComponent(n)}`,{method:"DELETE"})).ok&&(s(null),l(!1))}finally{p(!1)}},k=t!=null&&t.tokenBudget?Math.min(100,t.tokensUsed/t.tokenBudget*100):null;let N=null;if(o&&a)N=r.jsxs("form",{className:ig,onSubmit:S=>{S.preventDefault(),w()},children:[r.jsxs("div",{className:"mb-2 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[r.jsx(Xo,{className:"size-3.5","data-icon":"inline-start"}),t?"Edit long-running goal":"Set a long-running goal"]}),r.jsxs(wo,{className:"gap-2",children:[r.jsxs(gt,{children:[r.jsx(xt,{className:"sr-only",htmlFor:"codex-goal-objective",children:"Goal objective"}),r.jsx(ra,{id:"codex-goal-objective",value:c,onChange:S=>d(S.target.value),placeholder:"What should Codex keep working toward?",rows:2,autoFocus:!0})]}),r.jsxs(gt,{orientation:"horizontal","data-invalid":!!h,children:[r.jsx(xt,{className:"text-xs text-muted-foreground",htmlFor:"codex-goal-budget",children:"Token budget"}),r.jsx(Ot,{id:"codex-goal-budget",type:"number",min:1,step:1,value:f,onChange:S=>u(S.target.value),placeholder:"Optional",className:"ml-auto h-8 w-28","aria-invalid":!!h})]})]}),r.jsx(us,{className:"mt-1.5",children:h}),r.jsxs("div",{className:"mt-2 flex items-center justify-end gap-1",children:[r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:()=>l(!1),children:[r.jsx(jt,{"data-icon":"inline-start"}),"Cancel"]}),r.jsxs(X,{type:"submit",size:"xs",disabled:m||!c.trim(),children:[r.jsx(dt,{"data-icon":"inline-start"}),"Save goal"]})]})]});else if(o&&t){const S=t.status==="paused",_=t.status==="complete";N=r.jsxs("section",{className:rg,"aria-label":"Codex goal",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Xo,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",title:t.objective,children:t.objective}),r.jsx(Me,{variant:Jj(t.status),children:Xj(t.status)}),r.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[tt(t.tokensUsed),t.tokenBudget?` / ${tt(t.tokenBudget)}`:""," · ",Math.max(0,Math.round(t.timeUsedSeconds/60)),"m"]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[S&&r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void y("active"),disabled:m,"aria-label":"Resume goal",children:r.jsx(hr,{"data-icon":"icon"})}),!S&&!_&&r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void y("paused"),disabled:m,"aria-label":"Pause goal",children:r.jsx(Gb,{"data-icon":"icon"})}),!_&&r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void y("complete"),disabled:m,"aria-label":"Mark goal complete",children:r.jsx(dt,{"data-icon":"icon"})}),r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",onClick:v,"aria-label":"Edit goal",children:r.jsx(Ls,{"data-icon":"icon"})}),r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void j(),disabled:m,className:"text-destructive","aria-label":"Clear goal",children:r.jsx(Bi,{"data-icon":"icon"})})]})]}),k!==null&&r.jsx(Mc,{className:"mt-1 mb-0.5",value:k,"aria-label":`${k.toFixed(0)}% of goal token budget used`})]})}const C=b.useMemo(()=>({section:N,canCreate:o&&!t&&!a,beginEditing:v}),[N,o,t,a,v]);return r.jsx(Rc.Provider,{value:C,children:e})}function Zj(n){const e=U.c(7),{agentKind:t,session:s,onSendCommand:o,children:i}=n;if(!zt(t).goals)return i;if(t==="codex"){let l;return e[0]!==i||e[1]!==s.sessionId?(l=r.jsx(Qj,{threadId:s.sessionId,children:i}),e[0]=i,e[1]=s.sessionId,e[2]=l):l=e[2],l}let a;return e[3]!==i||e[4]!==o||e[5]!==s?(a=r.jsx(Vj,{session:s,onSendCommand:o,children:i}),e[3]=i,e[4]=o,e[5]=s,e[6]=a):a=e[6],a}function ag(){return og().section}function lg(){const n=U.c(3),{canCreate:e,beginEditing:t}=og();if(!e)return null;let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Xo,{"data-icon":"inline-start"}),n[0]=s):s=n[0];let o;return n[1]!==t?(o=r.jsxs(X,{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]=o):o=n[2],o}function eS(){const n=U.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs(r.Fragment,{children:[r.jsx(ag,{}),r.jsx(lg,{})]}),n[0]=e):e=n[0],e}const tS=/\x1b\].*?(?:\x07|\x1b\\)/g,nS=/\x1b\[[0-9;]*[A-Za-z]/g,sS=/\x1b[()][AB012]/g,oS=/\[2K\[1G/g;function cg(n){return n.replace(tS,"").replace(nS,"").replace(sS,"").replace(oS,`
|
|
5
|
+
`).replace(/\r/g,"")}function Nr(n){const e=U.c(14);let t,s,o;e[0]!==n?({className:s,children:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==s?(i=G("relative overflow-hidden",s),e[4]=s,e[5]=i):i=e[5];let a;e[6]!==t?(a=r.jsx(Xb,{"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:t}),e[6]=t,e[7]=a):a=e[7];let l,c;e[8]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(rS,{}),c=r.jsx(Jb,{}),e[8]=l,e[9]=c):(l=e[8],c=e[9]);let d;return e[10]!==o||e[11]!==i||e[12]!==a?(d=r.jsxs(Yb,{"data-slot":"scroll-area",className:i,...o,children:[a,l,c]}),e[10]=o,e[11]=i,e[12]=a,e[13]=d):d=e[13],d}function rS(n){const e=U.c(11);let t,s,o;e[0]!==n?({className:t,orientation:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"vertical":o;let a;e[4]!==t?(a=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",t),e[4]=t,e[5]=a):a=e[5];let l;e[6]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Zb,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"}),e[6]=l):l=e[6];let c;return e[7]!==i||e[8]!==s||e[9]!==a?(c=r.jsx(Qb,{"data-slot":"scroll-area-scrollbar","data-orientation":i,orientation:i,className:a,...s,children:l}),e[7]=i,e[8]=s,e[9]=a,e[10]=c):c=e[10],c}function dg(n){const e=U.c(10);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 o;e[3]!==t?(o=G("size-5",t),e[3]=t,e[4]=o):o=e[4];let i,a;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.2"}),a=r.jsx("path",{className:"status-icon-spin",d:"M12 2A10 10 0 0 1 22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),e[5]=i,e[6]=a):(i=e[5],a=e[6]);let l;return e[7]!==s||e[8]!==o?(l=r.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",className:o,...s,children:[i,a]}),e[7]=s,e[8]=o,e[9]=l):l=e[9],l}function iS(n){const e=U.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 o;e[3]!==t?(o=G("size-5",t),e[3]=t,e[4]=o):o=e[4];let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("path",{className:"status-icon-complete",d:"M20 6L9 17L4 12"}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.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:o,...s,children:i}),e[6]=s,e[7]=o,e[8]=a):a=e[8],a}function aS(n){const e=U.c(10);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 o;e[3]!==t?(o=G("size-5",t),e[3]=t,e[4]=o):o=e[4];let i,a;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a=r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"}),e[5]=i,e[6]=a):(i=e[5],a=e[6]);let l;return e[7]!==s||e[8]!==o?(l=r.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:o,...s,children:[i,a]}),e[7]=s,e[8]=o,e[9]=l):l=e[9],l}function lS(n){const e=U.c(11);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 o;e[3]!==t?(o=G("size-5",t),e[3]=t,e[4]=o):o=e[4];let i,a,l;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.1"}),a=r.jsx("path",{className:"status-icon-spin",d:"M12 2A10 10 0 0 1 22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),l=r.jsx("path",{className:"status-icon-spin",d:"M12 22A10 10 0 0 1 2 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),e[5]=i,e[6]=a,e[7]=l):(i=e[5],a=e[6],l=e[7]);let c;return e[8]!==s||e[9]!==o?(c=r.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",className:o,...s,children:[i,a,l]}),e[8]=s,e[9]=o,e[10]=c):c=e[10],c}function Ut(n){const e=U.c(10);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 o,i;if(e[3]!==t){const l=t==null?void 0:t.replace(/\banimate-spin\b/g,"").trim();o=dg,i=G(l),e[3]=t,e[4]=o,e[5]=i}else o=e[4],i=e[5];let a;return e[6]!==o||e[7]!==s||e[8]!==i?(a=r.jsx(o,{className:i,...s}),e[6]=o,e[7]=s,e[8]=i,e[9]=a):a=e[9],a}function cS(n){const e=vn("hostFiles"),[t,s]=b.useState([]),[o,i]=b.useState(!1),a=b.useCallback(async()=>{if(!e||!n){s([]);return}i(!0);try{const l=await ye(`/api/scripts?dir=${encodeURIComponent(n)}`);if(l.ok){const c=await l.json();s(c)}}catch{}finally{i(!1)}},[e,n]);return b.useEffect(()=>{a()},[a]),{scripts:t,loading:o,refresh:a}}const af=500,dS=5e3;function uS(n){const e=U.c(29),t=n===void 0?!0:n,[s,o]=b.useState("disconnected");let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=[],e[0]=i):i=e[0];const[a,l]=b.useState(i),c=b.useRef(null);let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=new Map,e[1]=d):d=e[1];const f=b.useRef(d),u=b.useRef(af),m=b.useRef(null),p=b.useRef(!1),h=b.useRef(fS);let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=L=>{var H;const z=L.type,F=L.id;if(z==="sessions"){l(L.sessions??[]);return}F&&((H=f.current.get(F))==null||H(z,L))},e[2]=g):g=e[2];const x=g;let v,w;e[3]!==t?(v=()=>{if(p.current=!1,!t)return()=>{p.current=!0};const L=function(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}${wh()}/__pty`},z=function(){if(p.current||c.current&&c.current.readyState!==WebSocket.CLOSED)return;o("connecting");const H=new WebSocket(L());c.current=H,H.onopen=()=>{if(p.current){H.close();return}u.current=af,o("connected"),H.send(JSON.stringify({type:"list"}))},H.onmessage=B=>{try{const W=JSON.parse(B.data);x(W)}catch{}},H.onclose=()=>{if(p.current)return;o("disconnected"),c.current=null;const B=u.current;u.current=Math.min(B*2,dS),m.current=setTimeout(()=>h.current(),B)}};return h.current=z,z(),()=>{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]=v,e[5]=w):(v=e[4],w=e[5]),b.useEffect(v,w);let y;e[6]!==t?(y=L=>{if(!t)return;const z=c.current;z&&z.readyState===WebSocket.OPEN&&z.send(JSON.stringify(L))},e[6]=t,e[7]=y):y=e[7];const j=y;let k;e[8]===Symbol.for("react.memo_cache_sentinel")?(k=(L,z)=>{f.current.set(L,z)},e[8]=k):k=e[8];const N=k;let C;e[9]===Symbol.for("react.memo_cache_sentinel")?(C=L=>{f.current.delete(L)},e[9]=C):C=e[9];const S=C;let _;e[10]!==j?(_=L=>{const z=L===void 0?{}:L,F=`pty_${crypto.randomUUID().slice(0,8)}`;return j({type:"spawn",id:F,name:z.name??"Terminal",cwd:z.cwd,metadata:{type:"terminal"}}),F},e[10]=j,e[11]=_):_=e[11];const P=_;let A;e[12]!==j?(A=L=>{const z=`script_${crypto.randomUUID().slice(0,8)}`;return j({type:"spawn",id:z,name:L.name,cwd:L.cwd,args:["run",L.scriptName],command:"bun",metadata:{type:"script",source:L.source,scriptName:L.scriptName}}),z},e[12]=j,e[13]=A):A=e[13];const E=A;let T;e[14]!==j?(T=L=>{j({type:"kill",id:L})},e[14]=j,e[15]=T):T=e[15];const M=T;let I;e[16]!==j?(I=(L,z)=>{j({type:"input",id:L,data:z})},e[16]=j,e[17]=I):I=e[17];const R=I;let $;e[18]!==j?($=(L,z,F)=>{j({type:"resize",id:L,cols:z,rows:F})},e[18]=j,e[19]=$):$=e[19];const D=$;let O;return e[20]!==M||e[21]!==D||e[22]!==j||e[23]!==a||e[24]!==E||e[25]!==P||e[26]!==s||e[27]!==R?(O={status:s,send:j,subscribe:N,unsubscribe:S,sessions:a,spawnTerminal:P,spawnScript:E,killSession:M,writeInput:R,resize:D},e[20]=M,e[21]=D,e[22]=j,e[23]=a,e[24]=E,e[25]=P,e[26]=s,e[27]=R,e[28]=O):O=e[28],O}function fS(){}const ug=b.createContext(null);function Va(n){const e=U.c(3),{children:t,enabled:s}=n,i=uS(s===void 0?!0:s);let a;return e[0]!==t||e[1]!==i?(a=r.jsx(ug.Provider,{value:i,children:t}),e[0]=t,e[1]=i,e[2]=a):a=e[2],a}function Ic(){const n=b.useContext(ug);if(!n)throw new Error("usePty must be used within a PtyProvider");return n}function mS(n){var f;const e=U.c(11),t=Ic();let s;if(e[0]!==t.sessions){s=new Map;for(const u of t.sessions)((f=u.metadata)==null?void 0:f.type)==="script"&&s.set(u.id,{id:u.id,name:u.name,cwd:u.cwd,status:u.status==="running"?"running":"stopped",source:u.metadata.source??"root/"});e[0]=t.sessions,e[1]=s}else s=e[1];const o=s;let i;e[2]!==n||e[3]!==t?(i=(u,m,p)=>{const h=t.spawnScript({name:u,cwd:m,source:p,scriptName:u}),g=p==="root/"?u:`${p.replace(/\/$/,"")}:${u}`;n==null||n({id:h,name:g,type:"script",status:"running",source:p})},e[2]=n,e[3]=t,e[4]=i):i=e[4];const a=i;let l;e[5]!==t?(l=u=>{t.killSession(u)},e[5]=t,e[6]=l):l=e[6];const c=l;let d;return e[7]!==a||e[8]!==o||e[9]!==c?(d={runningProcesses:o,runScript:a,stopScript:c},e[7]=a,e[8]=o,e[9]=c,e[10]=d):d=e[10],d}function pS(n){const e=U.c(14),{script:t,status:s,onRun:o,onStop:i}=n,a=s==="running";let l="bg-transparent";a?l="bg-primary":s==="errored"&&(l="bg-destructive");const c=a?i:o,d=a?`Stop ${t.name}`:`Run: ${t.command}`;let f;e[0]!==l?(f=G("size-1.5 shrink-0 rounded-full",l),e[0]=l,e[1]=f):f=e[1];let u;e[2]!==f?(u=r.jsx("span",{className:f}),e[2]=f,e[3]=u):u=e[3];let m;e[4]!==t.name?(m=r.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]!==a?(p=a?r.jsx(yc,{"data-icon":"inline-end",className:"fill-current text-destructive"}):r.jsx(hr,{"data-icon":"inline-end",className:"opacity-0 text-muted-foreground transition-opacity group-hover:opacity-100"}),e[6]=a,e[7]=p):p=e[7];let h;return e[8]!==c||e[9]!==d||e[10]!==u||e[11]!==m||e[12]!==p?(h=r.jsxs(X,{type:"button",variant:"ghost",size:"sm",className:"motion-list-item group w-full justify-start px-2",onClick:c,title:d,children:[u,m,p]}),e[8]=c,e[9]=d,e[10]=u,e[11]=m,e[12]=p,e[13]=h):h=e[13],h}const hS=b.memo(function(e){const t=U.c(42),{projectDir:s,onProcessStarted:o}=e,[i,a]=b.useState(!1),[l,c]=b.useState("");let d;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=new Set,t[0]=d):d=t[0];const[f,u]=b.useState(d),{scripts:m,loading:p}=cS(s),{runningProcesses:h,runScript:g,stopScript:x}=mS(o);let v;if(t[1]!==m||t[2]!==l){const z=l.trim().toLowerCase(),F=z?m.filter(H=>H.name.toLowerCase().includes(z)||H.dirLabel.toLowerCase().includes(z)):m;v=new Map;for(const H of F){const B=v.get(H.dirLabel)??[];B.push(H),v.set(H.dirLabel,B)}t[1]=m,t[2]=l,t[3]=v}else v=t[3];const w=v;let y;if(t[4]!==h){y=new Map;for(const[z,F]of h)y.set(`${F.name}:${F.cwd}`,{id:z,status:F.status});t[4]=h,t[5]=y}else y=t[5];const j=y;if(!s||!p&&m.length===0)return null;let k;t[6]===Symbol.for("react.memo_cache_sentinel")?(k=function(F){u(H=>{const B=new Set(H);return B.has(F)?B.delete(F):B.add(F),B})},t[6]=k):k=t[6];const N=k;let C;t[7]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx("span",{className:"flex-1 text-xs font-medium text-muted-foreground",children:"Scripts"}),t[7]=C):C=t[7];let S;t[8]!==p?(S=p&&r.jsx(Ut,{className:"size-3 text-muted-foreground","aria-label":"Loading scripts"}),t[8]=p,t[9]=S):S=t[9];const _=i?"Close script search":"Search scripts";let P,A;t[10]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{a(gS),c("")},A=r.jsx(xn,{}),t[10]=P,t[11]=A):(P=t[10],A=t[11]);let E;t[12]!==i||t[13]!==_?(E=r.jsx(X,{type:"button",variant:"ghost",size:"icon-sm","aria-label":_,"aria-expanded":i,onClick:P,children:A}),t[12]=i,t[13]=_,t[14]=E):E=t[14];let T;t[15]!==S||t[16]!==E?(T=r.jsxs("div",{className:"flex h-8 shrink-0 items-center gap-2 px-2",children:[C,S,E]}),t[15]=S,t[16]=E,t[17]=T):T=t[17];let M;t[18]!==i||t[19]!==l?(M=i&&r.jsx("div",{className:"motion-slide-down-in px-2 pb-2",children:r.jsx(Ot,{type:"search",value:l,onChange:z=>c(z.target.value),placeholder:"Filter scripts...","aria-label":"Filter scripts",className:"h-7",autoFocus:!0})}),t[18]=i,t[19]=l,t[20]=M):M=t[20];let I;t[21]!==f||t[22]!==w||t[23]!==g||t[24]!==j||t[25]!==l||t[26]!==x?(I=[...w.entries()].map(z=>{const[F,H]=z,B=f.has(F)||!!l,W=H.filter(xS),K=H.filter(bS),V=B?H:W.length>0?W:H.slice(0,1);return r.jsxs("div",{className:"flex flex-col gap-0.5 pb-1",children:[w.size>1&&r.jsx("div",{className:"truncate px-2 pt-1 text-xs text-muted-foreground",children:F}),V.map(Y=>{const q=j.get(`${Y.name}:${Y.dir}`);return r.jsx(pS,{script:Y,status:(q==null?void 0:q.status)??null,onRun:()=>g(Y.name,Y.dir,Y.dirLabel),onStop:()=>{q&&x(q.id)}},`${F}:${Y.name}`)}),!l&&K.length>0&&r.jsx(X,{type:"button",variant:"link",size:"sm",className:"h-auto justify-start px-2 py-1",onClick:()=>N(F),children:B?"Show less":`Show ${K.length} more`})]},F)}),t[21]=f,t[22]=w,t[23]=g,t[24]=j,t[25]=l,t[26]=x,t[27]=I):I=t[27];let R;t[28]!==w.size||t[29]!==p||t[30]!==l?(R=!p&&w.size===0&&l&&r.jsx(Hn,{className:"gap-1 p-3",children:r.jsxs(Kn,{className:"gap-1",children:[r.jsx(qn,{children:"No matching scripts"}),r.jsx(Vn,{children:"Try another name."})]})}),t[28]=w.size,t[29]=p,t[30]=l,t[31]=R):R=t[31];let $;t[32]!==I||t[33]!==R?($=r.jsxs(Nr,{className:"min-h-0 flex-1 px-1 pb-1",children:[I,R]}),t[32]=I,t[33]=R,t[34]=$):$=t[34];let D;t[35]!==M||t[36]!==$||t[37]!==T?(D=r.jsxs("section",{className:"flex w-56 shrink-0 flex-col","aria-label":"Scripts",children:[T,M,$]}),t[35]=M,t[36]=$,t[37]=T,t[38]=D):D=t[38];let O;t[39]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsx(It,{orientation:"vertical"}),t[39]=O):O=t[39];let L;return t[40]!==D?(L=r.jsxs(r.Fragment,{children:[D,O]}),t[40]=D,t[41]=L):L=t[41],L});function gS(n){return!n}function xS(n){return n.isCommon}function bS(n){return!n.isCommon}function fg(n){const e=U.c(10);let t,s,o;e[0]!==n?({className:t,orientation:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"horizontal":o;let a;e[4]!==t?(a=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",t),e[4]=t,e[5]=a):a=e[5];let l;return e[6]!==i||e[7]!==s||e[8]!==a?(l=r.jsx(nv,{"data-slot":"tabs","data-orientation":i,className:a,...s}),e[6]=i,e[7]=s,e[8]=a,e[9]=l):l=e[9],l}const vS=Bn("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 mg(n){const e=U.c(17);let t,s,o,i;e[0]!==n?({className:s,children:t,variant:i,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);const a=i===void 0?"default":i;let l;e[5]!==s||e[6]!==a?(l=G(vS({variant:a}),"relative isolate",s),e[5]=s,e[6]=a,e[7]=l):l=e[7];let c;e[8]===Symbol.for("react.memo_cache_sentinel")?(c=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"),e[8]=c):c=e[8];let d;e[9]!==a?(d=r.jsx(ov,{"data-slot":"tabs-indicator","data-variant":a,className:c}),e[9]=a,e[10]=d):d=e[10];let f;return e[11]!==t||e[12]!==o||e[13]!==l||e[14]!==d||e[15]!==a?(f=r.jsxs(tv,{"data-slot":"tabs-list","data-variant":a,className:l,...o,children:[t,d]}),e[11]=t,e[12]=o,e[13]=l,e[14]=d,e[15]=a,e[16]=f):f=e[16],f}function $o(n){const e=U.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 o;e[3]!==t?(o=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",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(sv,{"data-slot":"tabs-trigger",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Oo(n){const e=U.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 o;e[3]!==t?(o=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]",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(ev,{"data-slot":"tabs-content",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const yS=b.lazy(()=>Ke(()=>import("./TerminalOutput-DLRMV4_Y.js"),__vite__mapDeps([0,1,2,3,4,5])).then(n=>({default:n.TerminalOutput})));function wS({process:n}){const[e,t]=b.useState(""),[s,o]=b.useState(!1),i=b.useRef(null);return b.useEffect(()=>{let a;if(n.type==="task"&&n.outputPath)a=vr(`/api/task-output?path=${encodeURIComponent(n.outputPath)}`);else return;t(""),o(!1);const l=new EventSource(a);return l.onopen=()=>o(!0),l.onmessage=c=>{try{const d=JSON.parse(c.data);if(d.type==="output"&&d.text){const f=cg(d.text);f&&t(u=>{const m=u+f;return m.length>1e5?m.slice(-1e5):m})}}catch{}},l.onerror=()=>{},()=>l.close()},[n.id,n.type,n.outputPath]),b.useEffect(()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight)},[e]),r.jsx("pre",{ref:i,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||r.jsx("span",{className:"text-muted-foreground",children:s?"Waiting for output...":"Connecting..."})})}function jS(n){const e=U.c(34),{process:t,isActive:s,onSelectActive:o,onClose:i,mobile:a}=n,l=t.source??t.name,c=t.id,d=t.name;let f;e[0]!==s||e[1]!==o?(f=()=>{s&&o()},e[0]=s,e[1]=o,e[2]=f):f=e[2];const u=a?"gap-1 px-1.5":"gap-1.5 px-2";let m;e[3]!==u?(m=G("h-6 min-w-0 justify-start py-0 text-xs",u),e[3]=u,e[4]=m):m=e[4];let p;e[5]!==t.status?(p=t.status==="running"&&r.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"&&r.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=r.jsx("span",{className:"truncate max-w-[100px]",children:t.name}),e[9]=t.name,e[10]=g):g=e[10];const x=a&&"hidden";let v;e[11]!==x?(v=G("px-1 py-0 font-normal",x),e[11]=x,e[12]=v):v=e[12];let w;e[13]!==t.type||e[14]!==v?(w=r.jsx(Me,{variant:"secondary",className:v,children:t.type}),e[13]=t.type,e[14]=v,e[15]=w):w=e[15];let y;e[16]!==t.id||e[17]!==t.name||e[18]!==w||e[19]!==f||e[20]!==m||e[21]!==p||e[22]!==h||e[23]!==g?(y=r.jsxs($o,{value:c,"aria-label":d,onClick:f,className:m,children:[p,h,g,w]}),e[16]=t.id,e[17]=t.name,e[18]=w,e[19]=f,e[20]=m,e[21]=p,e[22]=h,e[23]=g,e[24]=y):y=e[24];const j=`Close ${t.name}`,k=`Close ${t.name}`;let N;e[25]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(jt,{"data-icon":"inline-start"}),e[25]=N):N=e[25];let C;e[26]!==i||e[27]!==j||e[28]!==k?(C=r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs","aria-label":j,title:k,onClick:i,className:"mr-0.5 text-muted-foreground",children:N}),e[26]=i,e[27]=j,e[28]=k,e[29]=C):C=e[29];let S;return e[30]!==l||e[31]!==y||e[32]!==C?(S=r.jsxs("div",{title:l,className:"inline-flex h-6 shrink-0 items-center",children:[y,C]}),e[30]=l,e[31]=y,e[32]=C,e[33]=S):S=e[33],S}const pg=100,hg=600,SS=200,gg="process-panel-height";function kS(){try{const n=localStorage.getItem(gg);if(n)return Math.min(hg,Math.max(pg,Number(n)))}catch{}return SS}const NS=b.memo(function(e){const t=U.c(89),{processes:s,activeProcessId:o,collapsed:i,onSetActive:a,onRemove:l,onToggleCollapse:c,onRequestTerminal:d,onAddTerminalContext:f,onUpdateStatus:u,projectDir:m,onProcessStarted:p,mobile:h}=e,g=h===void 0?!1:h,x=Ic(),[v,w]=b.useState(kS),y=b.useRef(null);let j,k;t[0]!==u||t[1]!==x.sessions?(j=()=>{for(const ce of x.sessions)ce.status==="exited"&&(u==null||u(ce.id,"stopped"))},k=[x.sessions,u],t[0]=u,t[1]=x.sessions,t[2]=j,t[3]=k):(j=t[2],k=t[3]),b.useEffect(j,k);let N;t[4]!==l||t[5]!==x?(N=ce=>{ce.type!=="task"&&x.killSession(ce.id),l(ce.id)},t[4]=l,t[5]=x,t[6]=N):N=t[6];const C=N;let S;t[7]!==v?(S=ce=>{ce.preventDefault(),y.current={startY:ce.clientY,startH:v},ce.target.setPointerCapture(ce.pointerId)},t[7]=v,t[8]=S):S=t[8];const _=S;let P;t[9]===Symbol.for("react.memo_cache_sentinel")?(P=ce=>{if(!y.current)return;const we=y.current.startY-ce.clientY,pe=Math.min(hg,Math.max(pg,y.current.startH+we));w(pe)},t[9]=P):P=t[9];const A=P;let E;t[10]!==v?(E=()=>{if(y.current){y.current=null;try{localStorage.setItem(gg,String(v))}catch{}}},t[10]=v,t[11]=E):E=t[11];const T=E;let M;t[12]!==o||t[13]!==s?(M=o?s.get(o):null,t[12]=o,t[13]=s,t[14]=M):M=t[14];const I=M;let R;t[15]!==s?(R=[...s.values()],t[15]=s,t[16]=R):R=t[16];const $=R;let D;t[17]!==a?(D=ce=>{typeof ce=="string"&&a(ce)},t[17]=a,t[18]=D):D=t[18];let O;t[19]!==I||t[20]!==i||t[21]!==g||t[22]!==_||t[23]!==T?(O=!g&&!i&&I&&r.jsx("div",{className:"h-1 cursor-row-resize transition-colors hover:bg-accent active:bg-muted-foreground/30",onPointerDown:_,onPointerMove:A,onPointerUp:T,onPointerCancel:T}),t[19]=I,t[20]=i,t[21]=g,t[22]=_,t[23]=T,t[24]=O):O=t[24];const L=g?"h-7 gap-1 px-2":"h-8 gap-2 px-3";let z;t[25]!==L?(z=G("flex shrink-0 items-center border-b bg-card",L),t[25]=L,t[26]=z):z=t[26];const F=i?"Expand terminal panel":"Collapse terminal panel",H=!i;let B;t[27]!==i?(B=i?r.jsx(Ze,{"data-icon":"inline-start"}):r.jsx(nt,{"data-icon":"inline-start"}),t[27]=i,t[28]=B):B=t[28];const W=g&&"sr-only";let K;t[29]!==W?(K=G(W),t[29]=W,t[30]=K):K=t[30];let V;t[31]!==K?(V=r.jsx("span",{className:K,children:"Terminal"}),t[31]=K,t[32]=V):V=t[32];let Y;t[33]!==c||t[34]!==F||t[35]!==H||t[36]!==B||t[37]!==V?(Y=r.jsxs(X,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2",onClick:c,"aria-label":F,"aria-expanded":H,children:[B,V]}),t[33]=c,t[34]=F,t[35]=H,t[36]=B,t[37]=V,t[38]=Y):Y=t[38];const q=!g&&"ml-2";let J;t[39]!==q?(J=G("min-w-0 flex-1 justify-start overflow-x-auto no-scrollbar",q),t[39]=q,t[40]=J):J=t[40];let Z;t[41]!==o||t[42]!==C||t[43]!==g||t[44]!==a||t[45]!==$?(Z=$.map(ce=>r.jsx(jS,{process:ce,isActive:ce.id===o,onSelectActive:()=>a(ce.id),onClose:()=>C(ce),mobile:g},ce.id)),t[41]=o,t[42]=C,t[43]=g,t[44]=a,t[45]=$,t[46]=Z):Z=t[46];let Q;t[47]!==J||t[48]!==Z?(Q=r.jsx(mg,{variant:"default","aria-label":"Open processes",className:J,children:Z}),t[47]=J,t[48]=Z,t[49]=Q):Q=t[49];let ee;t[50]!==d||t[51]!==m?(ee=d&&r.jsx(X,{type:"button",variant:"ghost",size:"icon-sm",disabled:!m,onClick:d,"aria-label":"New terminal",title:m?"New terminal":"Open a project to start a terminal",children:r.jsx(_n,{})}),t[50]=d,t[51]=m,t[52]=ee):ee=t[52];let oe;t[53]!==z||t[54]!==Y||t[55]!==Q||t[56]!==ee?(oe=r.jsxs("div",{className:z,children:[Y,Q,ee]}),t[53]=z,t[54]=Y,t[55]=Q,t[56]=ee,t[57]=oe):oe=t[57];const se=!i,re=g?"min(36dvh, 260px)":v;let ie;t[58]!==re?(ie={height:re},t[58]=re,t[59]=ie):ie=t[59];let ae;t[60]!==g||t[61]!==p||t[62]!==m?(ae=!g&&r.jsx(hS,{projectDir:m,onProcessStarted:p}),t[60]=g,t[61]=p,t[62]=m,t[63]=ae):ae=t[63];let te;t[64]!==C||t[65]!==f||t[66]!==d||t[67]!==$?(te=$.map(ce=>r.jsx(Oo,{value:ce.id,className:"col-start-1 row-start-1 flex min-h-0 flex-col",children:ce.type==="task"?r.jsx(wS,{process:ce}):r.jsx(b.Suspense,{fallback:r.jsx("div",{className:"flex size-full items-center justify-center text-xs text-muted-foreground",children:"Loading terminal…"}),children:r.jsx(yS,{processId:ce.id,autoFocus:!0,onRequestNew:d,onRequestClose:()=>C(ce),onAddContext:f})})},ce.id)),t[64]=C,t[65]=f,t[66]=d,t[67]=$,t[68]=te):te=t[68];let he;t[69]!==I||t[70]!==d||t[71]!==m?(he=!I&&r.jsxs(Hn,{className:"col-start-1 row-start-1 rounded-none",children:[r.jsxs(Kn,{children:[r.jsx(js,{variant:"icon",children:r.jsx(yo,{})}),r.jsx(qn,{children:"No terminal open"}),r.jsx(Vn,{children:"Start a terminal here or run a project script from the left."})]}),d&&m&&r.jsx(vh,{children:r.jsxs(X,{type:"button",size:"sm",onClick:d,children:[r.jsx(_n,{"data-icon":"inline-start"}),"New terminal"]})})]}),t[69]=I,t[70]=d,t[71]=m,t[72]=he):he=t[72];let me;t[73]!==te||t[74]!==he?(me=r.jsxs("div",{className:"grid min-h-0 min-w-0 flex-1 grid-cols-1",children:[te,he]}),t[73]=te,t[74]=he,t[75]=me):me=t[75];let le;t[76]!==ie||t[77]!==ae||t[78]!==me?(le=r.jsx(Nt,{children:r.jsxs("div",{className:"flex min-h-0",style:ie,children:[ae,me]})}),t[76]=ie,t[77]=ae,t[78]=me,t[79]=le):le=t[79];let xe;t[80]!==se||t[81]!==le?(xe=r.jsx(kt,{open:se,className:"min-h-0",children:le}),t[80]=se,t[81]=le,t[82]=xe):xe=t[82];let ge;return t[83]!==o||t[84]!==D||t[85]!==O||t[86]!==oe||t[87]!==xe?(ge=r.jsxs(fg,{value:o,onValueChange:D,className:"shrink-0 gap-0 border-t bg-background",children:[O,oe,xe]}),t[83]=o,t[84]=D,t[85]=O,t[86]=oe,t[87]=xe,t[88]=ge):ge=t[88],ge});function Qn(n){const e=U.c(2),{children:t}=n;let s;return e[0]!==t?(s=r.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 CS=/(?::(\d{4,5}))|(?:port\s+(\d{4,5}))|(?:localhost:(\d{4,5}))/gi;function _S(n){const e=new Set;for(const t of n.matchAll(CS)){const s=parseInt(t[1]||t[2]||t[3],10);s>0&&s<65536&&e.add(s)}return[...e]}function TS(n){var s;const e=U.c(2);let t;if(e[0]!==n){t=new Map;for(let o=0;o<n.length;o++)for(const i of n[o].toolCalls){if(i.name!=="Bash"||!i.input.run_in_background)continue;const a=i.input.command||"",l=i.input.description||"",c=((s=n[o].assistantText)==null?void 0:s.join(" "))||"",d=[a,l,i.result||"",c].join(" "),f=_S(d);if(f.length===0){const p=a.toLowerCase();(p.includes("run dev")||p.includes("next dev")||p.includes("vite"))&&f.push(3e3)}const u=(i.result||"").match(/Output is being written to:\s*(\S+)/),m=u?u[1]:null;for(const p of f)t.set(p,{description:l||a.replace(/^cd\s+"[^"]*"\s*&&\s*/,"").slice(0,60),outputPath:m})}e[0]=n,e[1]=t}else t=e[1];return t}function lf(n){var e;return((e=n.preview.split(`
|
|
6
|
+
`).find(t=>t.trim()))==null?void 0:e.trim())||`Task ${n.id}`}function ES(n){const e=U.c(10),{port:t,isActive:s}=n,o=s?"bg-success":"bg-muted-foreground/40";let i;e[0]!==o?(i=G("inline-block size-1.5 rounded-full",o),e[0]=o,e[1]=i):i=e[1];let a;e[2]!==i?(a=r.jsx("span",{className:i}),e[2]=i,e[3]=a):a=e[3];const l=s?"text-success":"text-muted-foreground";let c;e[4]!==t||e[5]!==l?(c=r.jsxs("span",{className:l,children:[":",t]}),e[4]=t,e[5]=l,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=r.jsxs(Me,{variant:"secondary",className:"font-mono",children:[a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d}function xg({cwd:n,turns:e,onToggleServer:t,onServersChanged:s}){const[o,i]=b.useState([]),a=TS(e);b.useEffect(()=>{if(!n)return;let c=!1;async function d(){try{const u=await ye(`/api/background-tasks?cwd=${encodeURIComponent(n)}`);if(c)return;if(u.ok){const h=await u.json();if(c)return;if(h.length>0){i(h);return}}if(a.size===0){i([]);return}const m=[...a.keys()],p=await ye(`/api/check-ports?ports=${m.join(",")}`);if(c)return;if(p.ok){const h=await p.json();if(c)return;const g=[],x=new Set;for(const[v,w]of a)!h[v]||x.has(v)||(x.add(v),g.push({id:`port-${v}`,outputPath:w.outputPath,ports:[v],portStatus:{[v]:!0},preview:w.description}));i(g)}}catch{}}d();const f=setInterval(d,1e4);return()=>{c=!0,clearInterval(f)}},[n,a]);const l=b.useCallback(async c=>{try{await ye("/api/kill-port",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({port:c})}),setTimeout(()=>{i(d=>d.filter(f=>!f.ports.includes(c)))},1500)}catch{}},[]);return b.useEffect(()=>{if(!s)return;const c=o.filter(d=>d.outputPath).map(d=>({id:d.id,outputPath:d.outputPath,title:lf(d)}));s(c)},[o,s]),o.length===0?null:r.jsxs("section",{children:[r.jsxs(Qn,{children:["Active Servers (",o.length,")"]}),r.jsx("div",{className:"flex flex-col gap-1.5",children:o.map(c=>{const d=c.ports.filter(u=>c.portStatus[u]),f=lf(c);return r.jsxs("div",{className:"border-b border-border px-2 py-2 last:border-b-0",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(Vp,{className:"size-3 shrink-0 text-success","data-icon":"inline-start"}),r.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:f})]}),r.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[c.ports.map(u=>r.jsx(ES,{port:u,isActive:c.portStatus[u]},u)),r.jsx("div",{className:"flex-1"}),c.outputPath&&r.jsx(X,{variant:"ghost",size:"icon-xs",onClick:()=>t==null?void 0:t(c.id,c.outputPath,f),title:"View server output","aria-label":"View server output",children:r.jsx(yo,{"data-icon":"inline-start"})}),d.length>0&&r.jsxs(X,{variant:"ghost",size:"xs",className:"text-destructive",onClick:()=>d.forEach(u=>l(u)),title:"Stop server","aria-label":"Stop server",children:[r.jsx(yc,{"data-icon":"inline-start",className:"fill-current"}),r.jsx("span",{children:"Stop"})]})]})]},c.id)})})]})}function $c(n){const e=U.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=r.jsx(rv,{"data-slot":"alert-dialog",...t}),e[2]=t,e[3]=s):s=e[3],s}function PS(n){const e=U.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=r.jsx(iv,{"data-slot":"alert-dialog-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function AS(n){const e=U.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=r.jsx(xc,{"data-slot":"alert-dialog-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function RS(n){const e=U.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 o;e[3]!==t?(o=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]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(bc,{"data-slot":"alert-dialog-overlay",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Oc(n){const e=U.c(11);let t,s,o;e[0]!==n?({className:t,size:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"default":o;let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(RS,{}),e[4]=a):a=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]!==i||e[9]!==l?(c=r.jsxs(AS,{children:[a,r.jsx(pc,{"data-slot":"alert-dialog-content","data-size":i,className:l,...s})]}),e[7]=s,e[8]=i,e[9]=l,e[10]=c):c=e[10],c}function Dc(n){const e=U.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 o;e[3]!==t?(o=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]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"alert-dialog-header",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Lc(n){const e=U.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 o;e[3]!==t?(o=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]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"alert-dialog-footer",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function MS(n){const e=U.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 o;e[3]!==t?(o=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]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"alert-dialog-media",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function zc(n){const e=U.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 o;e[3]!==t?(o=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]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(hc,{"data-slot":"alert-dialog-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Fc(n){const e=U.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 o;e[3]!==t?(o=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]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(gc,{"data-slot":"alert-dialog-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Bc(n){const e=U.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 o;e[3]!==t?(o=G(t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(X,{"data-slot":"alert-dialog-action",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Uc(n){const e=U.c(14);let t,s,o,i;e[0]!==n?({className:t,variant:o,size:i,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);const a=o===void 0?"outline":o,l=i===void 0?"default":i;let c;e[5]!==t?(c=G(t),e[5]=t,e[6]=c):c=e[6];let d;e[7]!==l||e[8]!==a?(d=r.jsx(X,{variant:a,size:l}),e[7]=l,e[8]=a,e[9]=d):d=e[9];let f;return e[10]!==s||e[11]!==c||e[12]!==d?(f=r.jsx(Li,{"data-slot":"alert-dialog-cancel",className:c,render:d,...s}),e[10]=s,e[11]=c,e[12]=d,e[13]=f):f=e[13],f}function bg(n){const e=U.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 o;e[3]!==t?(o=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 dark:bg-input/30 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 dark:data-checked:bg-primary",t),e[3]=t,e[4]=o):o=e[4];let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(lv,{"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:r.jsx(dt,{})}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.jsx(av,{"data-slot":"checkbox",className:o,...s,children:i}),e[6]=s,e[7]=o,e[8]=a):a=e[8],a}const IS={undo:"Undo turns?",redo:"Redo turns?","branch-switch":"Switch branch?"},$S={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 OS({state:n,isApplying:e,applyError:t,onConfirm:s,onCancel:o}){var u,m;const i=b.useRef(n),[a,l]=b.useState({key:"",selected:!1});b.useEffect(()=>{n&&(i.current=n)},[n]);const c=n??i.current;if(!c)return null;const d=((u=c.copilot)==null?void 0:u.eventId)??`${c.type}:${c.targetTurnIndex}:${c.branchId??""}`,f=a.key===d&&a.selected;return r.jsx($c,{open:n!==null,onOpenChange:p=>{p||o()},onOpenChangeComplete:p=>{p||(i.current=null,l({key:"",selected:!1}))},children:r.jsxs(Oc,{children:[r.jsxs(Dc,{children:[r.jsx(MS,{children:r.jsx(wn,{className:"text-warning"})}),r.jsx(zc,{children:IS[c.type]}),r.jsx(Fc,{children:c.copilot?f?"This removes the selected turn and everything after it, restoring captured files.":"This removes the selected turn and everything after it. Files stay unchanged.":$S[c.type]})]}),r.jsxs("div",{className:"flex flex-col gap-2 py-2",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsx("span",{className:"text-muted-foreground",children:"Turns affected"}),r.jsx("span",{className:"text-foreground font-mono",children:c.summary.turnCount})]}),r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsx("span",{className:"text-muted-foreground",children:"Files affected"}),r.jsx("span",{className:"text-foreground font-mono",children:c.summary.fileCount})]}),r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsx("span",{className:"text-muted-foreground",children:"Operations"}),r.jsx("span",{className:"text-foreground font-mono",children:c.summary.operationCount})]}),c.summary.filePaths.length>0&&r.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=>r.jsx("div",{className:"truncate font-mono text-xs text-muted-foreground",children:p},p))}),((m=c.copilot)==null?void 0:m.filesAvailable)&&r.jsxs("label",{className:"mt-2 flex items-center gap-2 text-sm text-foreground",children:[r.jsx(bg,{checked:f,disabled:e,onCheckedChange:p=>l({key:d,selected:p===!0})}),"Restore captured file changes"]})]}),t&&r.jsx(Ct,{variant:"destructive",children:r.jsx(_t,{children:t})}),r.jsxs(Lc,{children:[r.jsx(Uc,{onClick:o,disabled:e,children:"Cancel"}),r.jsx(Bc,{onClick:()=>s(f),disabled:e,children:e?r.jsxs(r.Fragment,{children:[r.jsx(rt,{"data-icon":"inline-start",className:"animate-spin"}),"Applying..."]}):c.type==="undo"?"Undo":c.type==="redo"?"Redo":"Switch"})]})]})})}function Xt(n){const e=U.c(10);let t,s,o;e[0]!==n?({className:t,size:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"default":o;let a;e[4]!==t?(a=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]=a):a=e[5];let l;return e[6]!==s||e[7]!==i||e[8]!==a?(l=r.jsx("div",{"data-slot":"card","data-size":i,className:a,...s}),e[6]=s,e[7]=i,e[8]=a,e[9]=l):l=e[9],l}function tn(n){const e=U.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 o;e[3]!==t?(o=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]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"card-header",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function nn(n){const e=U.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 o;e[3]!==t?(o=G("text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"card-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function sn(n){const e=U.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 o;e[3]!==t?(o=G("text-sm text-muted-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"card-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function vg(n){const e=U.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 o;e[3]!==t?(o=G("col-start-2 row-span-2 row-start-1 self-start justify-self-end",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"card-action",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Jt(n){const e=U.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 o;e[3]!==t?(o=G("px-4 group-data-[size=sm]/card:px-3",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"card-content",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function So(n){const e=U.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 o;e[3]!==t?(o=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]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"card-footer",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Zn(n){const e=U.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 o;e[3]!==t?(o=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 dark:bg-input/30 dark:has-disabled:bg-input/80 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]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"input-group",role:"group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const DS=Bn("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 yn(n){const e=U.c(11);let t,s,o;e[0]!==n?({className:t,align:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"inline-start":o;let a;e[4]!==i||e[5]!==t?(a=G(DS({align:i}),t),e[4]=i,e[5]=t,e[6]=a):a=e[6];let l;return e[7]!==i||e[8]!==s||e[9]!==a?(l=r.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":i,className:a,onClick:LS,...s}),e[7]=i,e[8]=s,e[9]=a,e[10]=l):l=e[10],l}function LS(n){var e,t;n.target.closest("button")||(t=(e=n.currentTarget.parentElement)==null?void 0:e.querySelector("input"))==null||t.focus()}const zS=Bn("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 Cr(n){const e=U.c(15);let t,s,o,i,a;e[0]!==n?({className:t,type:o,variant:i,size:a,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5]);const l=o===void 0?"button":o,c=i===void 0?"ghost":i,d=a===void 0?"xs":a;let f;e[6]!==t||e[7]!==d?(f=G(zS({size:d}),t),e[6]=t,e[7]=d,e[8]=f):f=e[8];let u;return e[9]!==s||e[10]!==d||e[11]!==f||e[12]!==l||e[13]!==c?(u=r.jsx(X,{type:l,"data-size":d,variant:c,className:f,...s}),e[9]=s,e[10]=d,e[11]=f,e[12]=l,e[13]=c,e[14]=u):u=e[14],u}function es(n){const e=U.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 o;e[3]!==t?(o=G("flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Ot,{"data-slot":"input-group-control",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function FS(){const[n,e]=b.useState("idle"),[t,s]=b.useState(null),o=b.useRef(void 0),i=b.useCallback(async d=>{if(!d.trim()){e("idle"),s(null);return}e("validating"),s(null);try{const u=await(await ye(`/api/config/validate?path=${encodeURIComponent(d)}`)).json();u.valid?(e("valid"),s(null)):(e("invalid"),s(u.error||"Invalid path"))}catch{e("invalid"),s("Failed to validate path")}},[]),a=b.useCallback(d=>{clearTimeout(o.current),o.current=setTimeout(()=>i(d),400)},[i]),l=b.useCallback(()=>{e("idle"),s(null),clearTimeout(o.current)},[]),c=b.useCallback(async(d,f)=>{try{const u=await ye("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({claudeDir:d,...f})}),m=await u.json();return u.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 b.useEffect(()=>()=>clearTimeout(o.current),[]),{status:n,error:t,debouncedValidate:a,validate:i,reset:l,save:c}}function BS(n){const e=U.c(48),{onConfigured:t}=n,[s,o]=b.useState(""),[i,a]=b.useState(!1),{status:l,error:c,debouncedValidate:d,save:f}=FS();let u;e[0]!==d?(u=z=>{const F=z.target.value;o(F),d(F)},e[0]=d,e[1]=u):u=e[1];const m=u;let p;e[2]!==t||e[3]!==s||e[4]!==f?(p=async()=>{a(!0);const z=await f(s);z.success&&z.claudeDir&&t(z.claudeDir),a(!1)},e[2]=t,e[3]=s,e[4]=f,e[5]=p):p=e[5];const h=p;let g;e[6]!==h||e[7]!==i||e[8]!==l?(g=z=>{z.preventDefault(),l==="valid"&&!i&&h()},e[6]=h,e[7]=i,e[8]=l,e[9]=g):g=e[9];let x,v;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:r.jsx(vc,{className:"size-4"})}),v=r.jsx(nn,{children:"Connect your coding agent"}),e[10]=x,e[11]=v):(x=e[10],v=e[11]);let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-xs text-foreground",children:"~/.codex"}),e[12]=w):w=e[12];let y;e[13]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-xs text-foreground",children:"~/.copilot/session-state"}),e[13]=y):y=e[13];let j;e[14]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsxs(tn,{children:[x,v,r.jsxs(sn,{children:["Cogpit detects Codex and GitHub Copilot CLI automatically. Existing histories live in"," ",w," ","and"," ",y,"."," ","For Claude Code, enter its data directory, usually"," ",r.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-xs text-foreground",children:"~/.claude"}),"."]})]}),e[14]=j):j=e[14];const k=l==="invalid";let N;e[15]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(xt,{htmlFor:"claude-data-directory",children:"Claude Code data directory"}),e[15]=N):N=e[15];let C;e[16]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(yn,{children:r.jsx(Jo,{"aria-hidden":"true"})}),e[16]=C):C=e[16];const S=l==="invalid";let _;e[17]!==m||e[18]!==s||e[19]!==S?(_=r.jsxs(Zn,{children:[C,r.jsx(es,{id:"claude-data-directory",value:s,onChange:m,placeholder:"/Users/you/.claude",autoFocus:!0,"aria-invalid":S,"aria-describedby":"claude-directory-status"})]}),e[17]=m,e[18]=s,e[19]=S,e[20]=_):_=e[20];let P;e[21]!==l?(P=l==="validating"&&r.jsxs(fo,{className:"flex items-center gap-2",children:[r.jsx(Ut,{className:"size-4"}),"Checking path..."]}),e[21]=l,e[22]=P):P=e[22];let A;e[23]!==l?(A=l==="valid"&&r.jsxs(fo,{className:"flex items-center gap-2 text-success",children:[r.jsx(zi,{className:"size-4"}),"Claude Code history found"]}),e[23]=l,e[24]=A):A=e[24];let E;e[25]!==c||e[26]!==l?(E=l==="invalid"&&c&&r.jsxs(us,{className:"flex items-center gap-2",children:[r.jsx(zs,{className:"size-4"}),c]}),e[25]=c,e[26]=l,e[27]=E):E=e[27];let T;e[28]!==P||e[29]!==A||e[30]!==E?(T=r.jsxs("div",{id:"claude-directory-status",className:"min-h-5",role:"status","aria-live":"polite",children:[P,A,E]}),e[28]=P,e[29]=A,e[30]=E,e[31]=T):T=e[31];let M;e[32]!==_||e[33]!==T||e[34]!==k?(M=r.jsx(Jt,{children:r.jsx(wo,{children:r.jsxs(gt,{"data-invalid":k,children:[N,_,T]})})}),e[32]=_,e[33]=T,e[34]=k,e[35]=M):M=e[35];const I=l!=="valid"||i;let R;e[36]!==i?(R=i&&r.jsx(Ut,{"data-icon":"inline-start"}),e[36]=i,e[37]=R):R=e[37];const $=i?"Saving...":"Connect Claude Code";let D;e[38]!==I||e[39]!==R||e[40]!==$?(D=r.jsx(So,{children:r.jsxs(X,{type:"submit",className:"w-full",disabled:I,children:[R,$]})}),e[38]=I,e[39]=R,e[40]=$,e[41]=D):D=e[41];let O;e[42]!==M||e[43]!==D?(O=r.jsxs(Xt,{children:[j,M,D]}),e[42]=M,e[43]=D,e[44]=O):O=e[44];let L;return e[45]!==O||e[46]!==g?(L=r.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-4 py-8 text-foreground",children:r.jsx("form",{className:"w-full max-w-lg",onSubmit:g,children:O})}),e[45]=O,e[46]=g,e[47]=L):L=e[47],L}const yg=/^[a-z]:[\\/]/i;function Wc(n){return(yg.test(n)?n.replace(/\\/g,"/"):n).replace(/\/+$/,"")||"/"}function cf(n){const e=Wc(n);return yg.test(n)?e.toLowerCase():e}function US(n){const e=Wc(n),t=e.lastIndexOf("/");return t<0?e:t===0?"/":e.slice(0,t)}function df(n,e){const t=cf(n),s=cf(e);if(t===s)return"";const o=t==="/"?"/":`${t}/`;return s.startsWith(o)?Wc(e).slice(o.length):null}let Hc=!1;function WS(n){Hc=n}function Kc(){return Hc}let Wo=null;function HS(n){return Wo=n,()=>{Wo===n&&(Wo=null)}}function KS(n,e){if(!n.path)return null;if(n.kind==="project")return{root:n.path,file:null,mode:"edit"};if(e){const o=df(e,n.path);if(o)return{root:e,file:o,mode:uf(n),line:n.line}}const t=US(n.path),s=df(t,n.path);return s?{root:t,file:s,mode:uf(n),line:n.line}:null}function uf(n){return n.mode==="diff"?"diff":"edit"}function wg(n){return Hc&&Wo!==null&&Wo(n)}function jg(n,e){ye(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).catch(()=>{})}function bi(n,e={}){if(ut("hostFiles")&&!wg({kind:"file",path:n,...e})){if($s()){br(n);return}jg("/api/open-in-editor",{path:n,mode:e.mode??"file",line:e.line,column:e.column})}}function Sg(n){ut("hostFiles")&&(n.path&&wg({kind:"project",path:n.path})||Ng("/api/open-in-editor",n))}function kg(n){ut("hostFiles")&&Ng("/api/reveal-in-folder",n)}function Ng(n,e){!e.path&&!e.dirName||jg(n,{path:e.path||void 0,dirName:e.dirName||void 0})}let Ga=null;const Bl=new Set,Xr=new Map,ff=["typescript","tsx","javascript","jsx","json","css","html","python","bash","yaml","markdown"],Cg={typescript:()=>Ke(()=>import("./typescript-BPQ3VLAy.js"),[]),tsx:()=>Ke(()=>import("./tsx-COt5Ahok.js"),[]),javascript:()=>Ke(()=>import("./javascript-wDzz0qaB.js"),[]),jsx:()=>Ke(()=>import("./jsx-g9-lgVsj.js"),[]),json:()=>Ke(()=>import("./json-Cp-IABpG.js"),[]),css:()=>Ke(()=>import("./css-DPfMkruS.js"),[]),html:()=>Ke(()=>import("./html-GMplVEZG.js"),__vite__mapDeps([6,7,8])),python:()=>Ke(()=>import("./python-B6aJPvgy.js"),[]),bash:()=>Ke(()=>import("./bash-Yzrsuije.js"),[]),yaml:()=>Ke(()=>import("./yaml-Buea-lGh.js"),[]),markdown:()=>Ke(()=>import("./markdown-Cvjx9yec.js"),[]),rust:()=>Ke(()=>import("./rust-B1yitclQ.js"),[]),go:()=>Ke(()=>import("./go-CxLEBnE3.js"),[]),toml:()=>Ke(()=>import("./toml-vGWfd6FD.js"),[]),sql:()=>Ke(()=>import("./sql-BLtJtn59.js"),[]),c:()=>Ke(()=>import("./c-BIGW1oBm.js"),[]),cpp:()=>Ke(()=>import("./cpp-BRuaLJcg.js"),__vite__mapDeps([9,10,11])),java:()=>Ke(()=>import("./java-CylS5w8V.js"),[]),ruby:()=>Ke(()=>import("./ruby-B0Tyh1qT.js"),__vite__mapDeps([12,6,7,8,13,14,11,15,16,17,9,10,18,19])),swift:()=>Ke(()=>import("./swift-D82vCrfD.js"),[]),kotlin:()=>Ke(()=>import("./kotlin-BdnUsdx6.js"),[]),php:()=>Ke(()=>import("./php-aq0itWAE.js"),__vite__mapDeps([20,6,7,8,13,14,11,21])),vue:()=>Ke(()=>import("./vue-DVfSmUF7.js"),__vite__mapDeps([22,8,7,15,21,6])),svelte:()=>Ke(()=>import("./svelte-DZMnMd3x.js"),__vite__mapDeps([23,7,15,8])),scss:()=>Ke(()=>import("./scss-OYdSNvt2.js"),__vite__mapDeps([24,8]))};function _g(){return Ga||(Ga=(async()=>{const[n,e,...t]=await Promise.all([Ke(()=>import("./github-dark-DHJKELXO.js"),[]).then(o=>o.default),Ke(()=>import("./github-light-DAi9KRSo.js"),[]).then(o=>o.default),...ff.map(o=>Cg[o]().then(i=>i.default))]),s=await ey({themes:[n,e],langs:t,engine:ty()});for(const o of ff)Bl.add(o);return s})()),Ga}async function Tg(n,e){if(Bl.has(e))return;if(Xr.has(e))return Xr.get(e);const t=Cg[e];if(!t)return;const s=t().then(async o=>{await n.loadLanguage(o.default),Bl.add(e)}).finally(()=>Xr.delete(e));Xr.set(e,s),await s}const qS={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 Eg(n){var t;const e=((t=n.split(".").pop())==null?void 0:t.toLowerCase())??"";return qS[e]??null}async function qc(n,e,t){try{const s=await _g();await Tg(s,e);const o=t?"github-dark":"github-light";return s.codeToTokens(n,{lang:e,theme:o}).tokens}catch{return null}}function _r(){const n=U.c(2),[e,t]=b.useState(VS);let s,o;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{const i=document.documentElement,a=()=>t(i.classList.contains("dark")),l=new MutationObserver(a);return l.observe(i,{attributes:!0,attributeFilter:["class"]}),()=>l.disconnect()},o=[],n[0]=s,n[1]=o):(s=n[0],o=n[1]),b.useEffect(s,o),e}function VS(){return typeof document<"u"&&document.documentElement.classList.contains("dark")}const GS={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 YS(n){return GS[n.toLowerCase()]??n}function XS(n){if(!n)return null;const e=n.match(/language-(\S+)/);return(e==null?void 0:e[1])??null}function JS(n){const e=U.c(10),{text:t}=n,[s,o]=b.useState(!1),i=b.useRef(null),a=b.useRef(0);let l,c;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>()=>{a.current=a.current+1,i.current&&clearTimeout(i.current)},c=[],e[0]=l,e[1]=c):(l=e[0],c=e[1]),b.useEffect(l,c);let d;e[2]!==t?(d=function(){const g=a.current=a.current+1;br(t).then(x=>{x&&g===a.current&&(i.current&&clearTimeout(i.current),o(!0),i.current=setTimeout(()=>{i.current=null,o(!1)},2e3))})},e[2]=t,e[3]=d):d=e[3];const f=d,u=s?"Copied":"Copy code";let m;e[4]!==s?(m=s?r.jsxs(r.Fragment,{children:[r.jsx(dt,{className:"text-success","data-icon":"inline-start"}),r.jsx("span",{className:"text-success",children:"Copied"})]}):r.jsx(En,{"data-icon":"icon"}),e[4]=s,e[5]=m):m=e[5];let p;return e[6]!==f||e[7]!==u||e[8]!==m?(p=r.jsx(X,{type:"button",variant:"ghost",size:"xs",onClick:f,className:"text-muted-foreground",title:"Copy code","aria-label":u,children:m}),e[6]=f,e[7]=u,e[8]=m,e[9]=p):p=e[9],p}function QS(n){const e=U.c(2),{num:t}=n;let s;return e[0]!==t?(s=r.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 ZS(n){const e=U.c(16);let t,s,o;if(e[0]!==n){const{children:m,className:p,node:h,...g}=n;t=m,s=p,o=g,e[0]=n,e[1]=t,e[2]=s,e[3]=o}else t=e[1],s=e[2],o=e[3];const i=!s&&typeof t=="string"&&!t.includes(`
|
|
7
|
+
`);let a;e[4]!==s?(a=XS(s),e[4]=s,e[5]=a):a=e[5];const l=a,c=String(t);let d;if(e[6]!==c){let m;e[8]===Symbol.for("react.memo_cache_sentinel")?(m=/\n$/,e[8]=m):m=e[8],d=c.replace(m,""),e[6]=c,e[7]=d}else d=e[7];const f=d;if(i){let m;return e[9]!==t||e[10]!==o?(m=r.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:t}),e[9]=t,e[10]=o,e[11]=m):m=e[11],m}let u;return e[12]!==f||e[13]!==l||e[14]!==o?(u=r.jsx(e5,{code:f,lang:l,...o}),e[12]=f,e[13]=l,e[14]=o,e[15]=u):u=e[15],u}function e5(n){const e=U.c(35);let t,s,o;e[0]!==n?({code:t,lang:s,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=_r(),[a,l]=b.useState(null),[c,d]=b.useState(!1),f=t.split(`
|
|
8
|
+
`),u=f.length,m=u>30,p=s?`${s}\0${i?"dark":"light"}\0${t}`:null,h=(a==null?void 0:a.key)===p?a.lines:null;let g,x;e[4]!==t||e[5]!==p||e[6]!==i||e[7]!==s?(g=()=>{if(!s||!p)return;let E=!1;return qc(t,s,i).then(T=>{E||l({key:p,lines:T})}),()=>{E=!0}},x=[t,s,i,p],e[4]=t,e[5]=p,e[6]=i,e[7]=s,e[8]=g,e[9]=x):(g=e[8],x=e[9]),b.useEffect(g,x);const v=c?Ze:nt,w="my-3 overflow-hidden rounded-lg border border-border bg-muted/20";let y;e[10]!==v||e[11]!==c||e[12]!==m?(y=m&&r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>d(!c),className:"text-muted-foreground","aria-label":c?"Expand code":"Collapse code",children:r.jsx(v,{"data-icon":"icon"})}),e[10]=v,e[11]=c,e[12]=m,e[13]=y):y=e[13];let j;e[14]!==s?(j=s&&r.jsx(Me,{variant:"ghost",className:"px-0 uppercase tracking-wide text-muted-foreground",children:YS(s)}),e[14]=s,e[15]=j):j=e[15];let k;e[16]!==m||e[17]!==u?(k=m&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:[u," lines"]}),e[16]=m,e[17]=u,e[18]=k):k=e[18];let N;e[19]!==y||e[20]!==j||e[21]!==k?(N=r.jsxs("div",{className:"flex items-center gap-2",children:[y,j,k]}),e[19]=y,e[20]=j,e[21]=k,e[22]=N):N=e[22];let C;e[23]!==t?(C=r.jsx(JS,{text:t}),e[23]=t,e[24]=C):C=e[24];let S;e[25]!==N||e[26]!==C?(S=r.jsxs("div",{className:"flex items-center justify-between border-b border-border bg-muted/40 px-3 py-1.5",children:[N,C]}),e[25]=N,e[26]=C,e[27]=S):S=e[27];const _=!c&&r.jsx("div",{className:"overflow-x-auto",children:r.jsx("pre",{className:"m-0 p-3 font-mono text-xs leading-relaxed",children:r.jsx("code",{className:G("block",!h&&"text-foreground/90"),...o,children:f.map((E,T)=>{const M=h==null?void 0:h[T];return r.jsxs("span",{className:"block",children:[r.jsx(QS,{num:T+1}),M?M.map(t5):E||" "]},T)})})})});let P;e[28]!==c||e[29]!==u?(P=c&&r.jsxs(X,{type:"button",variant:"ghost",size:"sm",onClick:()=>d(!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[28]=c,e[29]=u,e[30]=P):P=e[30];let A;return e[31]!==_||e[32]!==P||e[33]!==S?(A=r.jsxs("div",{className:w,children:[S,_,P]}),e[31]=_,e[32]=P,e[33]=S,e[34]=A):A=e[34],A}function t5(n,e){return r.jsx("span",{style:{color:n.color},children:n.content},e)}var Ps=function(n,e){return Number(n.toFixed(e))},n5=function(n,e){return e},Qe=function(n,e,t){t&&typeof t=="function"&&t(n,e)},s5=function(n){return-Math.cos(n*Math.PI)/2+.5},o5=function(n){return n},r5=function(n){return n*n},i5=function(n){return n*(2-n)},a5=function(n){return n<.5?2*n*n:-1+(4-2*n)*n},l5=function(n){return n*n*n},c5=function(n){return--n*n*n+1},d5=function(n){return n<.5?4*n*n*n:(n-1)*(2*n-2)*(2*n-2)+1},u5=function(n){return n*n*n*n},f5=function(n){return 1- --n*n*n*n},m5=function(n){return n<.5?8*n*n*n*n:1-8*--n*n*n*n},p5=function(n){return n*n*n*n*n},h5=function(n){return 1+--n*n*n*n*n},g5=function(n){return n<.5?16*n*n*n*n*n:1+16*--n*n*n*n*n},Pg={easeOut:s5,linear:o5,easeInQuad:r5,easeOutQuad:i5,easeInOutQuad:a5,easeInCubic:l5,easeOutCubic:c5,easeInOutCubic:d5,easeInQuart:u5,easeOutQuart:f5,easeInOutQuart:m5,easeInQuint:p5,easeOutQuint:h5,easeInOutQuint:g5},Ag=function(n){typeof n=="number"&&cancelAnimationFrame(n)},un=function(n){n.mounted&&(Ag(n.animation),n.isAnimating=!1,n.animation=null,n.velocity=null)};function Rg(n,e,t,s){if(n.mounted){var o=new Date().getTime(),i=1;un(n),n.animation=function(){if(!n.mounted)return Ag(n.animation);var a=new Date().getTime()-o,l=a/t,c=Pg[e],d=c(l);a>=t?(s(i),n.animation=null):n.animation&&(s(d),requestAnimationFrame(n.animation))},requestAnimationFrame(n.animation)}}function x5(n){var e=n.scale,t=n.positionX,s=n.positionY;return!(Number.isNaN(e)||Number.isNaN(t)||Number.isNaN(s))}function ks(n,e,t,s){var o=x5(e);if(!(!n.mounted||!o)){var i=n.setState,a=n.state,l=a.scale,c=a.positionX,d=a.positionY,f=e.scale-l,u=e.positionX-c,m=e.positionY-d;t===0?i(e.scale,e.positionX,e.positionY):Rg(n,s,t,function(p){p!==1?n.isAnimating=!0:n.isAnimating=!1;var h=l+f*p,g=c+u*p,x=d+m*p;i(h,g,x)})}}function b5(n,e,t){var s=n.offsetWidth,o=n.offsetHeight,i=e.offsetWidth,a=e.offsetHeight,l=i*t,c=a*t,d=s-l,f=o-c;return{wrapperWidth:s,wrapperHeight:o,newContentWidth:l,newDiffWidth:d,newContentHeight:c,newDiffHeight:f}}var v5=function(n,e,t,s,o,i,a){var l=n>e?t*(a?.5:1):0,c=s>o?i*(a?.5:1):0,d=n-e-l,f=l,u=s-o-c,m=c;return{minPositionX:d,maxPositionX:f,minPositionY:u,maxPositionY:m,scaleWidthFactor:l,scaleHeightFactor:c}},Vc=function(n,e){var t=n.wrapperComponent,s=n.contentComponent,o=n.setup,i=o.centerZoomedOut,a=o.disablePadding;if(!t||!s)throw new Error("Components are not mounted");var l=b5(t,s,e),c=l.wrapperWidth,d=l.wrapperHeight,f=l.newContentWidth,u=l.newContentHeight,m=l.newDiffWidth,p=l.newDiffHeight,h=v5(c,f,m,d,u,p,!!i),g=c>=f&&d>=u;a&&g&&!i&&(h.minPositionX=0,h.maxPositionX=0,h.minPositionY=0,h.maxPositionY=0);var x=n.setup,v=x.minPositionX,w=x.maxPositionX,y=x.minPositionY,j=x.maxPositionY;return v!=null&&(h.minPositionX=c*(1-e)+v*e),w!=null&&(h.maxPositionX=w*e),y!=null&&(h.minPositionY=d*(1-e)+y*e),j!=null&&(h.maxPositionY=j*e),h},nr=function(n,e,t,s){return s?n<e?Ps(e,2):n>t?Ps(t,2):Ps(n,2):Ps(n,2)},mo=function(n,e){var t=Vc(n,e);return n.bounds=t,t};function Tr(n,e,t,s,o,i,a){var l=t.minPositionX,c=t.minPositionY,d=t.maxPositionX,f=t.maxPositionY,u=0,m=0;a&&(u=o,m=i);var p=nr(n,l-u,d+u,s),h=nr(e,c-m,f+m,s);return{x:p,y:h}}function ia(n,e,t,s,o,i){var a=n.state,l=a.scale,c=a.positionX,d=a.positionY,f=s-l;if(!Number.isFinite(e)||!Number.isFinite(t))return console.error("Mouse X and Y position were not provided!"),{x:c,y:d};var u=c-e*f,m=d-t*f,p=Tr(u,m,o,i,0,0,null);return p}var mf=1e-7;function Er(n,e,t,s,o){var i=o?s:0,a=Math.max(e-i,mf),l=t+i;return!Number.isNaN(t)&&n>=l?l:!Number.isNaN(e)&&n<=a?a:Math.max(n,mf)}var pf=function(n,e){var t=n.setup.panning.excluded,s=n.isInitialized,o=n.wrapperComponent,i=e.target,a="shadowRoot"in i&&"composedPath"in e,l=a?e.composedPath().some(function(f){return f instanceof Element?o==null?void 0:o.contains(f):!1}):o==null?void 0:o.contains(i),c=s&&i&&l;if(!c)return!1;var d=Pr(i,t);return!(d||i.getAttribute("draggable")==="true"||i.getAttribute("contenteditable")==="true"||i.isContentEditable)},hf=function(n){var e=n.isInitialized,t=n.isPanning,s=n.setup,o=s.panning.disabled,i=e&&t&&!o;return!!i},y5=function(n,e){var t=n.state,s=t.positionX,o=t.positionY;n.isPanning=!0;var i=e.clientX,a=e.clientY;n.startCoords={x:i-s,y:a-o}},w5=function(n,e){var t=e.touches,s=n.state,o=s.positionX,i=s.positionY;n.isPanning=!0;var a=t.length===1;if(a){var l=t[0].clientX,c=t[0].clientY;n.startCoords={x:l-o,y:c-i}}};function j5(n){var e=n.state,t=e.positionX,s=e.positionY,o=e.scale,i=n.setup,a=i.disabled,l=i.limitToBounds,c=i.centerZoomedOut,d=n.wrapperComponent;if(!(a||!d||!n.bounds)){var f=n.bounds,u=f.maxPositionX,m=f.minPositionX,p=f.maxPositionY,h=f.minPositionY,g=t>u||t<m,x=s>p||s<h,v=t>u?d.offsetWidth:n.setup.minPositionX||0,w=s>p?d.offsetHeight:n.setup.minPositionY||0,y=ia(n,v,w,o,n.bounds,l||c),j=y.x,k=y.y;return{scale:o,positionX:g?j:t,positionY:x?k:s}}}function Mg(n,e,t,s,o){var i=n.setup.limitToBounds,a=n.wrapperComponent,l=n.bounds,c=n.state,d=c.scale,f=c.positionX,u=c.positionY;if(!(a===null||l===null||e===f&&t===u)){var m=Tr(e,t,l,i,s,o,a),p=m.x,h=m.y;n.setState(d,p,h)}}var S5=function(n,e,t){var s=n.startCoords,o=n.state,i=n.setup.panning,a=i.lockAxisX,l=i.lockAxisY,c=o.positionX,d=o.positionY;if(!s)return{x:c,y:d};var f=e-s.x,u=t-s.y,m=a?c:f,p=l?d:u;return{x:m,y:p}},vs=function(n,e,t){var s=n.setup,o=n.state,i=s.minScale,a=s.disablePadding,l=s.centerZoomedOut,c=t??o.scale;return e>0&&c>=i&&!a&&!l?e:0},ls;(function(n){n.TRACK_PAD="track_pad",n.MOUSE="mouse",n.TOUCH="touch"})(ls||(ls={}));var k5=function(n){var e=n.mounted,t=n.wrapperComponent,s=n.contentComponent,o=n.setup,i=o.disabled,a=o.velocityAnimation,l=o.limitToBounds,c=n.state.scale,d=a.disabled;if(d||i||!e||!t||!s)return!1;if(!l)return!0;var f=t.offsetWidth<s.offsetWidth*c||t.offsetHeight<s.offsetHeight*c;return f},N5=function(n){var e=n.mounted,t=n.velocity,s=n.bounds,o=n.setup,i=o.disabled,a=o.velocityAnimation,l=a.disabled,c=!l&&!i&&e;return!(!c||!t||!s)};function C5(n,e){var t=n.setup.velocityAnimation,s=t.animationTime,o=t.maxAnimationTime,i=t.inertia;return Math.min(s*Math.max(1,Math.abs(e/i)),o)}function gf(n,e,t,s,o,i,a,l,c,d){if(o){if(e>a&&t>a){var f=a+(n-a)*d;return f>c?c:f<a?a:f}if(e<i&&t<i){var f=i+(n-i)*d;return f<l?l:f>i?i:f}}return s?e:nr(n,i,a,o)}function _5(n){var e=1,t=n.offsetWidth/window.innerWidth;return Number.isNaN(t)?e:Math.min(e,t)}var Ya=function(n,e,t){var s=0,o=n*t;return Number.isNaN(o)?s:n<0?Math.max(o,-e):Math.min(o,e)};function T5(n,e,t){var s,o,i=k5(n);if(i){var a=n.lastMousePosition,l=n.velocityTime,c=n.setup,d=n.wrapperComponent,f=c.velocityAnimation,u=f.maxStrengthMouse,m=f.maxStrengthTouch,p=f.sensitivityTouch,h=f.sensitivityMouse,g=Date.now();if(a&&l&&d){var x=_5(d),v=(s={},s[ls.TOUCH]=p,s[ls.MOUSE]=h,s)[t],w=(o={},o[ls.TOUCH]=m,o[ls.MOUSE]=u,o)[t],y=e.x-a.x,j=e.y-a.y,k=Ya(y/x,w,v),N=Ya(j/x,w,v),C=g-l,S=y*y+j*j,_=Ya(Math.sqrt(S)/C,w,v);n.velocity={velocityX:k,velocityY:N,total:_}}n.lastMousePosition=e,n.velocityTime=g}}function E5(n){var e=n.velocity,t=n.bounds,s=n.setup,o=n.wrapperComponent,i=N5(n);if(!(!i||!e||!t||!o)){var a=e.velocityX,l=e.velocityY,c=e.total,d=t.maxPositionX,f=t.minPositionX,u=t.maxPositionY,m=t.minPositionY,p=s.limitToBounds,h=s.autoAlignment,g=s.zoomAnimation,x=s.panning,v=x.lockAxisY,w=x.lockAxisX,y=g.animationType,j=h.sizeX,k=h.sizeY,N=h.velocityAlignmentTime,C=N,S=C5(n,c),_=Math.max(S,C),P=vs(n,j),A=vs(n,k),E=P*o.offsetWidth/100,T=A*o.offsetHeight/100,M=d+E,I=f-E,R=u+T,$=m-T,D=n.state,O=new Date().getTime();Rg(n,y,_,function(L){var z=n.state,F=z.scale,H=z.positionX,B=z.positionY,W=new Date().getTime()-O,K=W/C,V=Pg[h.animationType],Y=1-V(Math.min(1,K)),q=1-L,J=H+a*q,Z=B+l*q,Q=gf(J,D.positionX,H,w,p,f,d,I,M,Y),ee=gf(Z,D.positionY,B,v,p,m,u,$,R,Y);if(H!==J||B!==Z){n.setState(F,Q,ee);var oe=n.props.onPanning;oe&&oe(Ye(n),{})}})}}function xf(n,e){var t=n.state,s=t.scale,o=t.positionX,i=t.positionY;n.panStartPosition={x:o,y:i},un(n),mo(n,s),window.TouchEvent!==void 0&&e instanceof TouchEvent?w5(n,e):y5(n,e)}function Ig(n,e){var t=n.state.scale,s=n.setup,o=s.minScale,i=s.autoAlignment,a=i.disabled,l=i.sizeX,c=i.sizeY,d=i.animationTime,f=i.animationType,u=a||t<o||!l&&!c;if(!u){var m=j5(n);m&&ks(n,m,d,f)}}function bf(n,e,t,s){var o=n.startCoords,i=n.setup,a=i.autoAlignment,l=a.sizeX,c=a.sizeY;if(o){var d=S5(n,e,t),f=d.x,u=d.y,m=vs(n,l),p=vs(n,c);T5(n,{x:f,y:u},s),Mg(n,f,u,m,p)}}function P5(n,e){if(n.isPanning){var t=n.velocity,s=n.wrapperComponent,o=n.contentComponent;n.isPanning=!1;var i=n.state,a=i.positionX,l=i.positionY,c=i.scale,d=n.panStartPosition;if(n.panStartPosition=null,d){var f=a-d.x,u=l-d.y;if(f*f+u*u<=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=((o==null?void 0:o.offsetWidth)||0)*c,g=((o==null?void 0:o.offsetHeight)||0)*c,x=!n.setup.limitToBounds||m<h||p<g,v=!e&&t&&t.total>.1&&x;v?E5(n):Ig(n)}}function Gc(n,e,t,s){var o=n.setup,i=o.minScale,a=o.maxScale,l=o.limitToBounds,c=Er(Ps(e,2),i,a,0,!1),d=mo(n,c),f=ia(n,t,s,c,d,l),u=f.x,m=f.y;return{scale:c,positionX:u,positionY:m}}function Yc(n,e,t){var s=n.state.scale,o=n.wrapperComponent,i=n.setup,a=i.minScale,l=i.maxScale,c=i.limitToBounds,d=i.zoomAnimation,f=d.disabled,u=d.animationTime,m=d.animationType,p=s>=a&&s<=l,h=f||p;if((s>=1||c)&&Ig(n),!(h||!o||!n.mounted)){var g=e||o.offsetWidth/2,x=t||o.offsetHeight/2,v=s<a?a:l,w=Gc(n,v,g,x);w&&ks(n,w,u,m)}}var on=function(){return on=Object.assign||function(e){for(var t,s=1,o=arguments.length;s<o;s++){t=arguments[s];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},on.apply(this,arguments)};function vf(n,e,t){for(var s=0,o=e.length,i;s<o;s++)(i||!(s in e))&&(i||(i=Array.prototype.slice.call(e,0,s)),i[s]=e[s]);return n.concat(i||Array.prototype.slice.call(e))}var Xa={scale:1,positionX:0,positionY:0},Es={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"}},Ul={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},$g=function(n){var e,t,s,o,i,a,l,c,d,f=Math.max((e=n.minScale)!==null&&e!==void 0?e:Es.minScale,1e-7),u=(t=n.maxScale)!==null&&t!==void 0?t:Es.maxScale,m=(s=n.initialScale)!==null&&s!==void 0?s:Xa.scale,p=Math.min(Math.max(m,f),u),h=nr((o=n.initialPositionX)!==null&&o!==void 0?o:Xa.positionX,(i=n.minPositionX)!==null&&i!==void 0?i:-1/0,(a=n.maxPositionX)!==null&&a!==void 0?a:1/0,n.minPositionX!=null||n.maxPositionX!=null),g=nr((l=n.initialPositionY)!==null&&l!==void 0?l:Xa.positionY,(c=n.minPositionY)!==null&&c!==void 0?c:-1/0,(d=n.maxPositionY)!==null&&d!==void 0?d:1/0,n.minPositionY!=null||n.maxPositionY!=null);return{previousScale:p,scale:p,positionX:h,positionY:g}},yf=function(n){var e=on({},Es);return Object.keys(n).forEach(function(t){var s=t,o=typeof n[s]<"u",i=typeof Es[s]<"u";if(i&&o){var a=Object.prototype.toString.call(Es[s]),l=a==="[object Object]",c=a==="[object Array]";l?e[s]=on(on({},Es[s]),n[s]):c?e[s]=vf(vf([],Es[s],!0),n[s]):e[s]=n[s]}}),e.minScale<=0&&(e.minScale=1e-7),e},Og=function(n,e,t){var s=n.state.scale,o=n.wrapperComponent,i=n.setup,a=i.maxScale,l=i.minScale,c=i.zoomAnimation,d=i.smooth,f=c.size;if(!o)throw new Error("Wrapper is not mounted");var u=d?s*Math.exp(e*t):s+e*t,m=Er(Ps(u,3),l,a,f,!1);return m};function Dg(n,e,t,s,o){var i,a,l=n.wrapperComponent,c=n.state,d=c.scale,f=c.positionX,u=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-f)/d,v=(g/2-u)/d,w=Og(n,e,t),y=Gc(n,w,x,v);if(!y)return console.error("Error during zoom event. New transformation state was not calculated.");var j=n.props,k=j.onZoomStart,N=j.onZoom,C=j.onZoomStop,S=new MouseEvent("mousemove",{bubbles:!0}),_=Ye(n);Qe(_,S,k),Qe(_,S,N),ks(n,y,p,o);var P=(a=(i=l.ownerDocument)===null||i===void 0?void 0:i.defaultView)!==null&&a!==void 0?a:typeof window<"u"?window:null;P&&P.setTimeout(function(){n.mounted&&Qe(Ye(n),S,C)},p)}function Lg(n,e,t,s){var o,i,a=n.setup,l=n.wrapperComponent,c=n.contentComponent,d=a.limitToBounds,f=a.centerOnInit,u=$g(n.props),m=n.state,p=m.scale,h=m.positionX,g=m.positionY;if(l){var x=u.positionX,v=u.positionY;if(f&&c){var w=Xc(u.scale,l,c);x=w.positionX,v=w.positionY}var y=Vc(n,u.scale),j=Tr(x,v,y,d,0,0,l),k={scale:u.scale,positionX:j.x,positionY:j.y};if(!(p===u.scale&&h===u.positionX&&g===u.positionY)){s==null||s();var N=n.props,C=N.onZoomStart,S=N.onZoom,_=N.onZoomStop,P=new MouseEvent("mousemove",{bubbles:!0}),A=Ye(n);Qe(A,P,C),Qe(A,P,S),ks(n,k,e,t);var E=(i=(o=l.ownerDocument)===null||o===void 0?void 0:o.defaultView)!==null&&i!==void 0?i:typeof window<"u"?window:null;E&&E.setTimeout(function(){n.mounted&&Qe(Ye(n),P,_)},e)}}}function A5(n,e,t,s){var o=n.getBoundingClientRect(),i=e.getBoundingClientRect(),a=t.getBoundingClientRect(),l=i.x*s.scale,c=i.y*s.scale;return{x:(o.x-a.x+l)/s.scale,y:(o.y-a.y+c)/s.scale}}function R5(n,e,t,s,o){s===void 0&&(s=0),o===void 0&&(o=0);var i=n.wrapperComponent,a=n.contentComponent,l=n.state,c=n.setup,d=c.limitToBounds,f=c.minScale,u=c.maxScale;if(!i||!a)return l;var m=i.getBoundingClientRect(),p=e.getBoundingClientRect(),h=A5(e,i,a,l),g=h.x,x=h.y,v=p.width/l.scale,w=p.height/l.scale,y=i.offsetWidth/v,j=i.offsetHeight/w,k=Er(t||Math.min(y,j),f,u,0,!1),N=(m.width-v*k)/2,C=(m.height-w*k)/2,S=(m.left-g)*k+N+s,_=(m.top-x)*k+C+o,P=Vc(n,k),A=Tr(S,_,P,d,0,0,i),E=A.x,T=A.y;return{positionX:E,positionY:T,scale:k}}var M5=function(n){return function(e,t,s){e===void 0&&(e=.5),t===void 0&&(t=300),s===void 0&&(s="easeOut"),Dg(n,1,e,t,s)}},I5=function(n){return function(e,t,s){e===void 0&&(e=.5),t===void 0&&(t=300),s===void 0&&(s="easeOut"),Dg(n,-1,e,t,s)}},$5=function(n){return function(e,t,s,o,i){o===void 0&&(o=300),i===void 0&&(i="easeOut");var a=n.state,l=a.positionX,c=a.positionY,d=a.scale,f=n.wrapperComponent,u=n.contentComponent,m=n.setup.disabled;if(!(m||!f||!u)){var p={positionX:Number.isNaN(e)?l:e,positionY:Number.isNaN(t)?c:t,scale:Number.isNaN(s)?d:s};ks(n,p,o,i)}}},O5=function(n){return function(e,t){e===void 0&&(e=200),t===void 0&&(t="easeOut"),Lg(n,e,t)}},D5=function(n){return function(e,t,s){t===void 0&&(t=200),s===void 0&&(s="easeOut");var o=n.state,i=n.wrapperComponent,a=n.contentComponent;if(i&&a){var l=Xc(e||o.scale,i,a);ks(n,l,t,s)}}},L5=function(n){return function(e,t,s,o,i,a){s===void 0&&(s=600),o===void 0&&(o="easeOut"),i===void 0&&(i=0),a===void 0&&(a=0),un(n);var l=n.wrapperComponent,c=typeof e=="string"?document.getElementById(e):e;if(l&&c&&l.contains(c)){var d=R5(n,c,t,i,a);ks(n,d,s,o)}}},Wl=function(n){return{instance:n,state:n.state,zoomIn:M5(n),zoomOut:I5(n),setTransform:$5(n),resetTransform:O5(n),centerView:D5(n),zoomToElement:L5(n)}},z5=function(n){return{instance:n,state:n.state}},Ye=function(n){var e={};return Object.assign(e,z5(n)),Object.assign(e,Wl(n)),e},Ja=!1;function Qa(){try{var n={get passive(){return Ja=!0,!1}};return n}catch{return Ja=!1,Ja}}var Jr=".".concat(Ul.wrapperClass),Pr=function(n,e){return e.some(function(t){return n.matches("".concat(Jr," ").concat(t,", ").concat(Jr," .").concat(t,", ").concat(Jr," ").concat(t," *, ").concat(Jr," .").concat(t," *"))})},sr=function(n){n&&clearTimeout(n)},F5=function(n){return Number.parseFloat(n.toFixed(8))},zg=function(n,e,t){var s=F5(t);return"translate(".concat(n,"px, ").concat(e,"px) scale(").concat(s,")")},Xc=function(n,e,t){var s=t.offsetWidth*n,o=t.offsetHeight*n,i=(e.offsetWidth-s)/2,a=(e.offsetHeight-o)/2;return{scale:n,positionX:i,positionY:a}};function B5(n,e){n!=null&&(typeof n=="function"?n(e):n.current=e)}function U5(n){return function(e){n.forEach(function(t){typeof t=="function"?t(e):t!=null&&(t.current=e)})}}var Fg=function(n,e){var t=n.setup.wheel,s=t.disabled,o=t.wheelDisabled,i=t.touchPadDisabled,a=t.excluded,l=n.isInitialized,c=n.isPanning,d=e.target,f=l&&!c&&!s&&d;if(!f||o&&!e.ctrlKey||i&&e.ctrlKey)return!1;var u=Pr(d,a);if(u)return!1;var m=n.isPressingKeys(n.setup.wheel.activationKeys);return!!m},W5=function(n,e){var t=n.setup,s=t.disabled,o=t.trackPadPanning,i=o.activationKeys,a=o.excluded;if(!n.wrapperComponent||!n.contentComponent||s||o.disabled||e.ctrlKey)return!1;var l=Fg(n,e);if(l)return!1;var c=e.target,d=Pr(c,a);if(d)return!1;var f=n.isPressingKeys(i);return!!f},H5=function(n){return n?n.deltaY<0?1:-1:0};function K5(n,e){var t=H5(n),s=n5(e,t);return s}function Bg(n,e,t){var s=e.getBoundingClientRect(),o=0,i=0;if("clientX"in n)o=(n.clientX-s.left)/t,i=(n.clientY-s.top)/t;else{var a=n.touches[0];o=(a.clientX-s.left)/t,i=(a.clientY-s.top)/t}return Number.isNaN(o)||Number.isNaN(i)?(console.error("No mouse or touch offset found"),{x:0,y:0}):{x:o,y:i}}var q5=function(n,e,t,s,o){var i=n.state.scale,a=n.wrapperComponent,l=n.setup,c=l.maxScale,d=l.minScale,f=l.zoomAnimation,u=l.disablePadding,m=f.size,p=f.disabled;if(!a)throw new Error("Wrapper is not mounted");var h=i+e*t,g=s?!1:!p,x=Er(h,d,c,m,g&&!u);return x},Ug=function(n,e){var t=n.previousWheelEvent,s=n.state.scale,o=n.setup,i=o.maxScale,a=o.minScale;return t?s<i||s>a||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},V5=function(n,e){var t=n.setup.pinch,s=t.disabled,o=t.excluded,i=n.isInitialized,a=e.target,l=i&&!s&&a;if(!l)return!1;var c=Pr(a,o);return!c},G5=function(n){var e=n.setup.pinch.disabled,t=n.isInitialized,s=n.pinchStartDistance,o=t&&!e&&s!==null;return!!o},Y5=function(n,e,t){var s=t.getBoundingClientRect(),o=n.touches,i=o[0].clientX-s.left,a=o[0].clientY-s.top,l=o[1].clientX-s.left,c=o[1].clientY-s.top;return{x:(i+l)/2/e,y:(a+c)/2/e}},Wg=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))},X5=5,J5=function(n,e){var t=n.pinchStartScale,s=n.pinchStartDistance,o=n.setup,i=o.maxScale,a=o.minScale,l=o.zoomAnimation,c=o.disablePadding,d=o.pinch,f=l.size,u=l.disabled,m=d.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/X5),x=t+g,v=x===1/0?0:Ps(x,10);return Er(v,a,i,f,!u&&!c)},Hg=160,Kg=100,Q5=function(n,e){var t=n.props,s=t.onWheelStart,o=t.onZoomStart;n.wheelStopEventTimer||(un(n),Qe(Ye(n),e,s),Qe(Ye(n),e,o))},Z5=function(n,e){var t=n.props,s=t.onWheel,o=t.onZoom,i=n.contentComponent,a=n.setup,l=n.state,c=l.scale,d=a.limitToBounds,f=a.centerZoomedOut,u=a.zoomAnimation,m=a.wheel,p=a.disablePadding,h=a.smooth,g=u.size,x=u.disabled,v=m.step;if(!i)throw new Error("Component not mounted");e.cancelable&&e.preventDefault(),e.stopPropagation();var w=K5(e,null),y=h?v*Math.abs(e.deltaY):v,j=q5(n,w,y,!e.ctrlKey);if(c!==j){var k=mo(n,j),N=Bg(e,i,c),C=x||g===0||f||p,S=d&&C,_=ia(n,N.x,N.y,j,k,S),P=_.x,A=_.y;n.previousWheelEvent=e,n.setState(j,P,A),Qe(Ye(n),e,s),Qe(Ye(n),e,o)}},e4=function(n,e){var t=n.props,s=t.onWheelStop,o=t.onZoomStop;sr(n.wheelAnimationTimer),n.wheelAnimationTimer=setTimeout(function(){n.mounted&&(Yc(n,e.x,e.y),n.wheelAnimationTimer=null)},Kg);var i=Ug(n,e);i&&(sr(n.wheelStopEventTimer),n.wheelStopEventTimer=setTimeout(function(){n.mounted&&(n.wheelStopEventTimer=null,Qe(Ye(n),e,s),Qe(Ye(n),e,o))},Hg))},t4=function(n,e){var t=n.props,s=t.onWheelStart,o=t.onPanningStart;n.wheelStopEventTimer||(un(n),Qe(Ye(n),e,s),Qe(Ye(n),e,o))},n4=function(n,e){var t=n.props,s=t.onWheelStop,o=t.onPanningStop;sr(n.wheelAnimationTimer),n.wheelAnimationTimer=setTimeout(function(){n.mounted&&(Yc(n,e.x,e.y),n.wheelAnimationTimer=null)},Kg);var i=Ug(n,e);i&&(sr(n.wheelStopEventTimer),n.wheelStopEventTimer=setTimeout(function(){n.mounted&&(n.wheelStopEventTimer=null,Qe(Ye(n),e,s),Qe(Ye(n),e,o))},Hg))},qg=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 o=e/2,i=t/2;return{x:o,y:i}},s4=function(n,e){var t=Wg(e);n.pinchStartDistance=t,n.lastDistance=t,n.pinchStartScale=n.state.scale,n.isPanning=!1,n.isPinching=!0,n.pinchPreviousCenter=qg(e),un(n)},o4=function(n,e){var t=n.contentComponent,s=n.pinchStartDistance,o=n.wrapperComponent,i=n.pinchPreviousCenter,a=n.state.scale,l=n.setup,c=l.limitToBounds,d=l.centerZoomedOut,f=l.zoomAnimation,u=l.autoAlignment,m=l.pinch,p=l.panning,h=f.disabled,g=f.size,x=m.allowPanning;if(!(s===null||!t)){var v=Y5(e,a,t);if(!(!Number.isFinite(v.x)||!Number.isFinite(v.y))){var w=Wg(e),y=J5(n,w),j=qg(e),k=a/y,N=(j.x-((i==null?void 0:i.x)||0))*k,C=(j.y-((i==null?void 0:i.y)||0))*k;if(!(y===a&&N===0&&C===0)){n.pinchPreviousCenter=j;var S=mo(n,y),_=h||g===0||d,P=c&&_,A=ia(n,v.x,v.y,y,S,P),E=A.x,T=A.y;if(n.pinchMidpoint=v,n.lastDistance=w,p.disabled||!x)n.setState(y,E,T);else{var M=u.sizeX,I=u.sizeY,R=vs(n,M,y),$=vs(n,I,y),D=E+N,O=T+C,L=Tr(D,O,S,c,R,$,o),z=L.x,F=L.y;n.setState(y,z,F)}}}}},r4=function(n){var e=n.pinchMidpoint;n.velocity=null,n.lastDistance=null,n.pinchMidpoint=null,n.pinchStartScale=null,n.pinchStartDistance=null,n.isPinching=!1,Yc(n,e==null?void 0:e.x,e==null?void 0:e.y)},Vg=function(n,e){var t=n.props.onZoomStop,s=n.setup.doubleClick.animationTime;sr(n.doubleClickStopEventTimer),n.doubleClickStopEventTimer=setTimeout(function(){n.doubleClickStopEventTimer=null,Qe(Ye(n),e,t)},s)},i4=function(n,e){var t=n.props,s=t.onZoomStart,o=t.onZoom,i=n.setup.doubleClick,a=i.animationTime,l=i.animationType;Qe(Ye(n),e,s),Lg(n,a,l,function(){return Qe(Ye(n),e,o)}),Vg(n,e)};function a4(n,e){return n==="toggle"?e===1?1:-1:n==="zoomOut"?-1:1}function l4(n,e){var t=n.setup,s=n.doubleClickStopEventTimer,o=n.state,i=n.contentComponent,a=o.scale,l=n.props,c=l.onZoomStart,d=l.onZoom,f=t.doubleClick,u=f.disabled,m=f.mode,p=f.step,h=f.animationTime,g=f.animationType;if(!u&&!s){if(m==="reset")return i4(n,e);if(!i)return console.error("No ContentComponent found");var x=a4(m,n.state.scale),v=Og(n,x,p);if(a!==v){Qe(Ye(n),e,c);var w=Bg(e,i,a),y=Gc(n,v,w.x,w.y);if(!y)return console.error("Error during zoom event. New transformation state was not calculated.");Qe(Ye(n),e,d),ks(n,y,h,g),Vg(n,e)}}}var c4=function(n,e){var t=n.isInitialized,s=n.setup,o=n.wrapperComponent,i=s.doubleClick,a=i.disabled,l=i.excluded,c=e.target,d=o==null?void 0:o.contains(c),f=t&&c&&d&&!a;if(!f)return!1;var u=Pr(c,l);return!u},d4=(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&&mo(t,t.state.scale),t.setup=yf(s)},this.initializeWindowEvents=function(){var s,o,i,a,l=Qa(),c=(s=t.wrapperComponent)===null||s===void 0?void 0:s.ownerDocument,d=c==null?void 0:c.defaultView;(o=t.wrapperComponent)===null||o===void 0||o.addEventListener("wheel",t.onWheelPanning,l),(i=t.wrapperComponent)===null||i===void 0||i.addEventListener("keyup",t.setKeyUnPressed,l),(a=t.wrapperComponent)===null||a===void 0||a.addEventListener("keydown",t.setKeyPressed,l),d==null||d.addEventListener("mousedown",t.onPanningStart,l),d==null||d.addEventListener("mousemove",t.onPanning,l),d==null||d.addEventListener("mouseup",t.onPanningStop,l),c==null||c.addEventListener("mouseleave",t.clearPanning,l),d==null||d.addEventListener("keyup",t.setKeyUnPressed,l),d==null||d.addEventListener("keydown",t.setKeyPressed,l),d==null||d.addEventListener("blur",t.handleWindowBlur)},this.cleanupWindowEvents=function(){var s,o,i,a,l,c=Qa(),d=(s=t.wrapperComponent)===null||s===void 0?void 0:s.ownerDocument,f=d==null?void 0:d.defaultView;f==null||f.removeEventListener("mousedown",t.onPanningStart,c),f==null||f.removeEventListener("mousemove",t.onPanning,c),f==null||f.removeEventListener("mouseup",t.onPanningStop,c),d==null||d.removeEventListener("mouseleave",t.clearPanning,c),f==null||f.removeEventListener("keyup",t.setKeyUnPressed,c),f==null||f.removeEventListener("keydown",t.setKeyPressed,c),f==null||f.removeEventListener("blur",t.handleWindowBlur),document.removeEventListener("mouseleave",t.clearPanning,c),(o=t.wrapperComponent)===null||o===void 0||o.removeEventListener("wheel",t.onWheelPanning,c),(i=t.wrapperComponent)===null||i===void 0||i.removeEventListener("keyup",t.setKeyUnPressed,c),(a=t.wrapperComponent)===null||a===void 0||a.removeEventListener("keydown",t.setKeyPressed,c),un(t),(l=t.observer)===null||l===void 0||l.disconnect()},this.handleInitializeWrapperEvents=function(s){var o=Qa();s.addEventListener("wheel",t.onWheelZoom,o),s.addEventListener("dblclick",t.onDoubleClick,o),s.addEventListener("touchstart",t.onTouchPanningStart,o),s.addEventListener("touchmove",t.onTouchPanning,o),s.addEventListener("touchend",t.onTouchPanningStop,o)},this.handleInitialize=function(s){var o=t.setup.centerOnInit;t.applyTransformation(),t.onInitCallbacks.forEach(function(i){return i(Ye(t))}),o&&(t.setCenter(),t.observer=new ResizeObserver(function(){var i,a=s.offsetWidth,l=s.offsetHeight;(a>0||l>0)&&(t.onInitCallbacks.forEach(function(c){return c(Ye(t))}),t.setCenter(),(i=t.observer)===null||i===void 0||i.disconnect())}),setTimeout(function(){var i;(i=t.observer)===null||i===void 0||i.disconnect()},5e3),t.observer.observe(s))},this.onWheelZoom=function(s){var o=t.setup.disabled;if(!o){t.syncModifierKeys(s);var i=Fg(t,s);i&&(Q5(t,s),Z5(t,s),e4(t,s))}},this.onWheelPanning=function(s){var o=t.props.onPanning,i=t.setup.trackPadPanning,a=i.lockAxisX,l=i.lockAxisY;t.syncModifierKeys(s);var c=W5(t,s);if(c){s.cancelable&&s.preventDefault(),s.stopPropagation();var d=t.state,f=d.positionX,u=d.positionY,m=f-s.deltaX,p=u-s.deltaY,h=a?f:m,g=l?u:p,x=t.setup.autoAlignment,v=x.sizeX,w=x.sizeY,y=vs(t,v),j=vs(t,w);h===f&&g===u||(t4(t,s),Mg(t,h,g,y,j),Qe(Ye(t),s,o),n4(t,s))}},this.onPanningStart=function(s){var o=t.setup.disabled,i=t.props.onPanningStart;if(!o){t.syncModifierKeys(s);var a=pf(t,s);if(a){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(),un(t),xf(t,s),Qe(Ye(t),s,i)))}}},this.onPanning=function(s){var o=t.setup.disabled,i=t.props.onPanning;if(!o){if(t.syncModifierKeys(s),t.isPanning&&s.buttons===0){t.clearPanning(s);return}var a=hf(t);if(a){var l=t.isPressingKeys(t.setup.panning.activationKeys);l&&(s.cancelable&&s.preventDefault(),s.stopPropagation(),bf(t,s.clientX,s.clientY,ls.MOUSE),Qe(Ye(t),s,i))}}},this.onPanningStop=function(s){var o=t.setup.panning.velocityDisabled,i=t.props.onPanningStop;t.isPanning&&(P5(t,o),Qe(Ye(t),s,i))},this.onPinchStart=function(s){var o=t.setup.disabled,i=t.props.onPinchStart;if(!o){var a=V5(t,s);a&&(s4(t,s),un(t),Qe(Ye(t),s,i))}},this.onPinch=function(s){var o=t.setup.disabled,i=t.props.onPinch;if(!o){var a=G5(t);a&&(s.cancelable&&s.preventDefault(),s.stopPropagation(),o4(t,s),Qe(Ye(t),s,i))}},this.onPinchStop=function(s){var o=t.props.onPinchStop;t.pinchStartScale&&(r4(t),Qe(Ye(t),s,o))},this.onTouchPanningStart=function(s){var o=t.setup,i=o.disabled,a=o.doubleClick,l=t.props.onPanningStart;if(!i){var c=!(a!=null&&a.disabled),d=t.lastTouch&&+new Date-t.lastTouch<200;if(c&&d&&s.touches.length===1)t.onDoubleClick(s);else{t.lastTouch=+new Date,un(t);var f=s.touches,u=f.length===1,m=f.length===2,p=pf(t,s);if(u){if(!p)return;un(t),xf(t,s),Qe(Ye(t),s,l)}m&&t.onPinchStart(s)}}},this.onTouchPanning=function(s){var o=t.setup.disabled,i=t.props.onPanning;if(t.isPanning&&s.touches.length===1){if(o)return;var a=hf(t);if(!a)return;s.cancelable&&s.preventDefault(),s.stopPropagation();var l=s.touches[0];bf(t,l.clientX,l.clientY,ls.TOUCH),Qe(Ye(t),s,i)}else s.touches.length>1&&t.onPinch(s)},this.onTouchPanningStop=function(s){t.onPanningStop(s),t.onPinchStop(s)},this.onDoubleClick=function(s){var o=t.setup.disabled;if(!o){var i=c4(t,s);i&&l4(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 o=s.ctrlKey,i=s.metaKey,a=s.shiftKey,l=s.altKey;typeof o=="boolean"&&(t.pressedKeys.Control=o),typeof i=="boolean"&&(t.pressedKeys.Meta=i),typeof a=="boolean"&&(t.pressedKeys.Shift=a),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(o){var i=o[1];return i}).map(function(o){var i=o[0];return i})):s.length?!!s.every(function(o){return t.pressedKeys[o]}):!0},this.setCenter=function(){if(t.wrapperComponent&&t.contentComponent){var s=Xc(t.state.scale,t.wrapperComponent,t.contentComponent);t.setState(s.scale,s.positionX,s.positionY)}},this.handleTransformStyles=function(s,o,i){return t.props.customTransform?t.props.customTransform(s,o,i):zg(s,o,i)},this.getContext=function(){return Ye(t)},this.applyTransformation=function(){if(!(!t.mounted||!t.contentComponent)){var s=t.state,o=s.scale,i=s.positionX,a=s.positionY,l=t.handleTransformStyles(i,a,o);t.props.detached||(t.contentComponent.style.transform=l),t.onTransformCallbacks.forEach(function(c){return c({scale:o,positionX:i,positionY:a,previousScale:t.state.previousScale,ref:Ye(t)})})}},this.setState=function(s,o,i){var a=t.props.onTransform;if(!Number.isNaN(s)&&!Number.isNaN(o)&&!Number.isNaN(i)){var l=Math.max(s,1e-7);l!==t.state.scale&&(t.state.previousScale=t.state.scale,t.state.scale=l),t.state.positionX=o,t.state.positionY=i,t.applyTransformation();var c=Ye(t);t.onChangeCallbacks.forEach(function(d){return d(c)}),Qe(c,{scale:t.state.scale,positionX:o,positionY:i},a)}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,o){t.cleanupWindowEvents(),t.wrapperComponent=s,t.contentComponent=o,mo(t,t.state.scale),t.handleInitializeWrapperEvents(s),t.handleInitialize(o),t.initializeWindowEvents(),t.isInitialized=!0;var i=Ye(t);Qe(i,void 0,t.props.onInit),B5(t.props.ref,i)},this.props=e,this.setup=yf(this.props),this.state=$g(this.props)}return n})(),aa=be.createContext(null),u4=function(n,e){return typeof n=="function"?n(e):n},f4=be.forwardRef(function(n,e){var t=b.useRef(new d4(n)).current,s=u4(n.children,Wl(t));return b.useImperativeHandle(e,function(){return Wl(t)},[t]),b.useEffect(function(){t.update(n)},[t,n]),r.jsx(aa.Provider,on({value:t},{children:s}))});be.forwardRef(function(n,e){var t=b.useRef(null),s=b.useContext(aa);return b.useEffect(function(){return s.onChange(function(o){if(t.current){var i=0,a=0;t.current.style.transform=s.handleTransformStyles(i,a,1/o.instance.state.scale)}})},[s]),r.jsx("div",on({},n,{ref:U5([t,e])}))});function m4(n,e){e===void 0&&(e={});var t=e.insertAt;if(!(typeof document>"u")){var s=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css",t==="top"&&s.firstChild?s.insertBefore(o,s.firstChild):s.appendChild(o),o.styleSheet?o.styleSheet.cssText=n:o.appendChild(document.createTextNode(n))}}var p4=`.transform-component-module_wrapper__SPB86 {
|
|
9
|
+
position: relative;
|
|
10
|
+
width: -moz-fit-content;
|
|
11
|
+
width: fit-content;
|
|
12
|
+
height: -moz-fit-content;
|
|
13
|
+
height: fit-content;
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
-webkit-touch-callout: none; /* iOS Safari */
|
|
16
|
+
-webkit-user-select: none; /* Safari */
|
|
17
|
+
-khtml-user-select: none; /* Konqueror HTML */
|
|
18
|
+
-moz-user-select: none; /* Firefox */
|
|
19
|
+
-ms-user-select: none; /* Internet Explorer/Edge */
|
|
20
|
+
user-select: none;
|
|
21
|
+
margin: 0;
|
|
22
|
+
padding: 0;
|
|
23
|
+
transform: translate3d(0, 0, 0);
|
|
24
|
+
}
|
|
25
|
+
.transform-component-module_content__FBWxo {
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-wrap: wrap;
|
|
28
|
+
width: -moz-fit-content;
|
|
29
|
+
width: fit-content;
|
|
30
|
+
height: -moz-fit-content;
|
|
31
|
+
height: fit-content;
|
|
32
|
+
margin: 0;
|
|
33
|
+
padding: 0;
|
|
34
|
+
transform-origin: 0% 0%;
|
|
35
|
+
}
|
|
36
|
+
.transform-component-module_content__FBWxo img {
|
|
37
|
+
pointer-events: none;
|
|
38
|
+
}
|
|
39
|
+
.transform-component-module_infiniteGrid__Z-aP3 {
|
|
40
|
+
position: absolute;
|
|
41
|
+
inset: 0;
|
|
42
|
+
pointer-events: none;
|
|
43
|
+
background-image: radial-gradient(
|
|
44
|
+
circle,
|
|
45
|
+
rgba(0, 0, 0, 0.12) 1px,
|
|
46
|
+
transparent 1px
|
|
47
|
+
);
|
|
48
|
+
background-size: 20px 20px;
|
|
49
|
+
background-position: 0 0;
|
|
50
|
+
}
|
|
51
|
+
`,Za={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo",infiniteGrid:"transform-component-module_infiniteGrid__Z-aP3"};m4(p4);var h4=function(n){var e=n.children,t=n.wrapperClass,s=t===void 0?"":t,o=n.contentClass,i=o===void 0?"":o,a=n.wrapperStyle,l=n.contentStyle,c=n.wrapperProps,d=c===void 0?{}:c,f=n.contentProps,u=f===void 0?{}:f,m=n.infinite,p=m===void 0?!1:m,h=b.useContext(aa),g=h.init,x=h.cleanupWindowEvents,v=b.useRef(null),w=b.useRef(null),y=b.useRef(null);return b.useEffect(function(){var j=v.current,k=w.current;return j!==null&&k!==null&&g&&(g==null||g(j,k)),function(){x==null||x()}},[]),b.useEffect(function(){if(p){var j=y.current;if(j){var k=function(){var N=h.state,C=N.positionX,S=N.positionY;j.style.backgroundPosition="".concat(C,"px ").concat(S,"px")};return k(),h.onChange(k)}}},[p,h]),r.jsxs("div",on({},d,{ref:v,className:"".concat(Ul.wrapperClass," ").concat(Za.wrapper," ").concat(s),style:a},{children:[p&&r.jsx("div",{ref:y,className:Za.infiniteGrid,"aria-hidden":!0}),r.jsx("div",on({},u,{ref:w,className:"".concat(Ul.contentClass," ").concat(Za.content," ").concat(i),style:on(on({},l),{transform:zg(h.state.positionX,h.state.positionY,h.state.scale)})},{children:e}))]}))};function g4(n,e){var t=Math.max(0,Math.min(n.x+n.width,e.x+e.width)-Math.max(n.x,e.x)),s=Math.max(0,Math.min(n.y+n.height,e.y+e.height)-Math.max(n.y,e.y));return t*s}function x4(n){var e=n.elementX,t=n.elementY,s=n.elementWidth,o=n.elementHeight,i=n.scale,a=n.positionX,l=n.positionY,c=n.viewportWidth,d=n.viewportHeight,f=n.margin,u=f===void 0?0:f,m=n.threshold,p=m===void 0?0:m,h={x:-u,y:-u,width:c+2*u,height:d+2*u},g={x:e*i+a,y:t*i+l,width:s*i,height:o*i};if(p<=0){var x=g.x<h.x+h.width&&g.x+g.width>h.x,v=g.y<h.y+h.height&&g.y+g.height>h.y;return x&&v}var w=g.width*g.height;if(w<=0)return!1;var y=g4(h,g);return y/w>=p}be.forwardRef(function(n,e){var t=n.x,s=n.y,o=n.width,i=n.height,a=n.margin,l=a===void 0?0:a,c=n.threshold,d=c===void 0?0:c,f=n.placeholder,u=f===void 0?null:f,m=n.onShow,p=n.onHide,h=n.children,g=n.className,x=n.style,v=b.useContext(aa),w=b.useState(!1),y=w[0],j=w[1],k=b.useRef(!1),N=b.useRef(m),C=b.useRef(p);return N.current=m,C.current=p,b.useEffect(function(){var S=function(){var A,E,T=v.wrapperComponent;if(T){var M=x4({elementX:t,elementY:s,elementWidth:o,elementHeight:i,scale:v.state.scale,positionX:v.state.positionX,positionY:v.state.positionY,viewportWidth:T.offsetWidth,viewportHeight:T.offsetHeight,margin:l,threshold:d});M!==k.current&&(k.current=M,j(M),M?(A=N.current)===null||A===void 0||A.call(N):(E=C.current)===null||E===void 0||E.call(C))}};S();var _=v.onChange(S),P;return v.wrapperComponent||(P=v.onInit(function(){return S()})),function(){_(),P==null||P()}},[v,t,s,o,i,l,d]),y?r.jsx("div",on({ref:e,className:g,style:x},{children:h})):u?r.jsx(r.Fragment,{children:u}):null});const wf=8,b4=56;function _o(n){const e=U.c(8),{label:t,disabled:s,onClick:o,children:i,className:a}=n;let l;e[0]!==a?(l=G("size-8 border border-white/10 bg-white/[0.06] text-white/75","hover:bg-white/10 hover:text-white focus-visible:ring-white/40","disabled:pointer-events-none disabled:opacity-30",a),e[0]=a,e[1]=l):l=e[1];let c;return e[2]!==i||e[3]!==s||e[4]!==t||e[5]!==o||e[6]!==l?(c=r.jsx(X,{type:"button",variant:"ghost",size:"icon-sm",onClick:o,disabled:s,"aria-label":t,title:t,className:l,children:i}),e[2]=i,e[3]=s,e[4]=t,e[5]=o,e[6]=l,e[7]=c):c=e[7],c}function Jc(n){const e=U.c(101),{open:t,images:s,initialIndex:o,onClose:i,onCloseComplete:a}=n,l=t===void 0?!0:t,c=Math.min(Math.max(o,0),Math.max(s.length-1,0)),[d,f]=b.useState(c),[u,m]=b.useState(100),p=b.useRef(null),h=b.useRef(null),g=s[d];let x;e[0]!==s.length?(x=de=>{f(Math.min(Math.max(de,0),s.length-1)),m(100)},e[0]=s.length,e[1]=x):x=e[1];const v=x;let w;e[2]!==v||e[3]!==d?(w=()=>v(d-1),e[2]=v,e[3]=d,e[4]=w):w=e[4];const y=w;let j;e[5]!==v||e[6]!==d?(j=()=>v(d+1),e[5]=v,e[6]=d,e[7]=j):j=e[7];const k=j;if(!g)return null;const N=s.length>1,C=d>0,S=d<s.length-1,_=u>100;let P;e[8]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{var de;return(de=p.current)==null?void 0:de.zoomIn()},e[8]=P):P=e[8];const A=P;let E;e[9]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{var de;return(de=p.current)==null?void 0:de.zoomOut()},e[9]=E):E=e[9];const T=E;let M;e[10]===Symbol.for("react.memo_cache_sentinel")?(M=()=>{var de;return(de=p.current)==null?void 0:de.resetTransform()},e[10]=M):M=e[10];const I=M;let R;e[11]!==S||e[12]!==C||e[13]!==k||e[14]!==y?(R=de=>{de.key==="ArrowLeft"&&C?(de.preventDefault(),y()):de.key==="ArrowRight"&&S?(de.preventDefault(),k()):de.key==="+"||de.key==="="?(de.preventDefault(),A()):de.key==="-"?(de.preventDefault(),T()):de.key==="0"&&(de.preventDefault(),I())},e[11]=S,e[12]=C,e[13]=k,e[14]=y,e[15]=R):R=e[15];const $=R;let D;e[16]===Symbol.for("react.memo_cache_sentinel")?(D=de=>{if(de.pointerType==="mouse"||de.isPrimary===!1){h.current=null;return}h.current={x:de.clientX,y:de.clientY}},e[16]=D):D=e[16];const O=D;let L;e[17]!==S||e[18]!==C||e[19]!==k||e[20]!==y?(L=de=>{var fe;const Ee=h.current;h.current=null;const Ae=((fe=p.current)==null?void 0:fe.instance.state.scale)??1;if(!Ee||Ae>1.01)return;const Le=de.clientX-Ee.x,ne=de.clientY-Ee.y;Math.abs(Le)<b4||Math.abs(Le)<Math.abs(ne)||(Le>0&&C&&y(),Le<0&&S&&k())},e[17]=S,e[18]=C,e[19]=k,e[20]=y,e[21]=L):L=e[21];const z=L;let F;e[22]!==i?(F=de=>{de||i()},e[22]=i,e[23]=F):F=e[23];let H;e[24]!==a?(H=de=>{de||a==null||a()},e[24]=a,e[25]=H):H=e[25];let B,W,K;e[26]===Symbol.for("react.memo_cache_sentinel")?(B=G("flex h-[calc(100dvh-1rem)] w-[calc(100vw-1rem)] max-w-none flex-col gap-0 overflow-hidden rounded-xl border-white/10 bg-black p-0 text-white","sm:h-[min(820px,calc(100dvh-2rem))] sm:w-[min(1120px,calc(100vw-2rem))] sm:max-w-none"),W=r.jsx(Xn,{className:"sr-only",children:"Image viewer"}),K=r.jsx(Jn,{className:"sr-only",children:"View and navigate images from this session."}),e[26]=B,e[27]=W,e[28]=K):(B=e[26],W=e[27],K=e[28]);let V;e[29]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-md bg-white/[0.06]",children:r.jsx(cv,{className:"size-3.5 text-white/65","data-icon":"icon"})}),e[29]=V):V=e[29];const Y=g.label||g.alt||"Session image";let q;e[30]!==Y?(q=r.jsx("div",{className:"truncate text-xs font-medium text-white/90",children:Y}),e[30]=Y,e[31]=q):q=e[31];let J;e[32]!==N||e[33]!==s.length||e[34]!==d?(J=N&&r.jsxs("div",{className:"text-xs tabular-nums text-white/50",children:[d+1," of ",s.length]}),e[32]=N,e[33]=s.length,e[34]=d,e[35]=J):J=e[35];let Z;e[36]!==q||e[37]!==J?(Z=r.jsxs("div",{className:"min-w-0 flex-1",children:[q,J]}),e[36]=q,e[37]=J,e[38]=Z):Z=e[38];const Q=u<=100;let ee;e[39]===Symbol.for("react.memo_cache_sentinel")?(ee=r.jsx(Gp,{className:"size-3.5","data-icon":"icon"}),e[39]=ee):ee=e[39];let oe;e[40]!==Q?(oe=r.jsx(_o,{label:"Zoom out",disabled:Q,onClick:T,children:ee}),e[40]=Q,e[41]=oe):oe=e[41];let se;e[42]!==u?(se=r.jsxs(X,{type:"button",variant:"ghost",size:"sm",onClick:I,className:"min-w-12 px-1.5 font-mono text-xs tabular-nums text-white/60 hover:bg-white/[0.06] hover:text-white","aria-label":"Reset zoom",title:"Reset zoom",children:[u,"%"]}),e[42]=u,e[43]=se):se=e[43];const re=u>=wf*100;let ie;e[44]===Symbol.for("react.memo_cache_sentinel")?(ie=r.jsx(_n,{className:"size-3.5","data-icon":"icon"}),e[44]=ie):ie=e[44];let ae;e[45]!==re?(ae=r.jsx(_o,{label:"Zoom in",disabled:re,onClick:A,children:ie}),e[45]=re,e[46]=ae):ae=e[46];let te;e[47]===Symbol.for("react.memo_cache_sentinel")?(te=r.jsx("div",{className:"mx-1 h-5 w-px bg-white/10"}),e[47]=te):te=e[47];let he;e[48]===Symbol.for("react.memo_cache_sentinel")?(he=r.jsx(jt,{className:"size-4","data-icon":"icon"}),e[48]=he):he=e[48];let me;e[49]!==i?(me=r.jsx(_o,{label:"Close image viewer",onClick:i,children:he}),e[49]=i,e[50]=me):me=e[50];let le;e[51]!==oe||e[52]!==se||e[53]!==ae||e[54]!==me?(le=r.jsxs("div",{className:"flex items-center gap-1",children:[oe,se,ae,te,me]}),e[51]=oe,e[52]=se,e[53]=ae,e[54]=me,e[55]=le):le=e[55];let xe;e[56]!==Z||e[57]!==le?(xe=r.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b border-white/10 bg-black/20 px-2.5 sm:px-3",children:[V,Z,le]}),e[56]=Z,e[57]=le,e[58]=xe):xe=e[58];const ge=g.id;let ce,we,pe;e[59]===Symbol.for("react.memo_cache_sentinel")?(ce={mode:"toggle"},we={step:.005},pe=(de,Ee)=>m(Math.round(Ee.scale*100)),e[59]=ce,e[60]=we,e[61]=pe):(ce=e[59],we=e[60],pe=e[61]);let ue,je;e[62]===Symbol.for("react.memo_cache_sentinel")?(ue={width:"100%",height:"100%"},je={width:"100%",height:"100%"},e[62]=ue,e[63]=je):(ue=e[62],je=e[63]);const Ne=g.src,Re=g.alt,Te=_?"cursor-grab active:cursor-grabbing":"cursor-zoom-in";let Pe;e[64]!==Te?(Pe=G("max-h-full max-w-full select-none object-contain",Te),e[64]=Te,e[65]=Pe):Pe=e[65];let Oe;e[66]!==g.alt||e[67]!==g.src||e[68]!==Pe?(Oe=r.jsx(h4,{wrapperStyle:ue,contentStyle:je,contentClass:"flex items-center justify-center p-3 sm:p-6",children:r.jsx("img",{src:Ne,alt:Re,draggable:!1,className:Pe})}),e[66]=g.alt,e[67]=g.src,e[68]=Pe,e[69]=Oe):Oe=e[69];let Fe;e[70]!==g.id||e[71]!==Oe?(Fe=r.jsx(f4,{ref:p,minScale:1,maxScale:wf,centerOnInit:!0,centerZoomedOut:!0,doubleClick:ce,wheel:we,onTransform:pe,children:Oe},ge),e[70]=g.id,e[71]=Oe,e[72]=Fe):Fe=e[72];let ze;e[73]!==S||e[74]!==C||e[75]!==k||e[76]!==y||e[77]!==N?(ze=N&&r.jsxs(r.Fragment,{children:[r.jsx(_o,{label:"Previous image",disabled:!C,onClick:y,className:"absolute left-2 top-1/2 size-10 -translate-y-1/2 rounded-full bg-black/45 backdrop-blur sm:left-3",children:r.jsx(wc,{className:"size-5","data-icon":"icon"})}),r.jsx(_o,{label:"Next image",disabled:!S,onClick:k,className:"absolute right-2 top-1/2 size-10 -translate-y-1/2 rounded-full bg-black/45 backdrop-blur sm:right-3",children:r.jsx(Ze,{className:"size-5","data-icon":"icon"})})]}),e[73]=S,e[74]=C,e[75]=k,e[76]=y,e[77]=N,e[78]=ze):ze=e[78];let Be;e[79]!==u?(Be=u===100&&r.jsxs("div",{className:"pointer-events-none absolute bottom-2 left-1/2 hidden -translate-x-1/2 items-center gap-1.5 rounded-full bg-black/60 px-2.5 py-1 text-xs text-white/60 sm:flex",children:[r.jsx(Ui,{className:"size-3","data-icon":"inline-start"}),"Scroll or double-click to zoom · drag to pan"]}),e[79]=u,e[80]=Be):Be=e[80];let _e;e[81]!==z||e[82]!==Fe||e[83]!==ze||e[84]!==Be?(_e=r.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden bg-black",onPointerDown:O,onPointerUp:z,children:[Fe,ze,Be]}),e[81]=z,e[82]=Fe,e[83]=ze,e[84]=Be,e[85]=_e):_e=e[85];let He;e[86]!==v||e[87]!==N||e[88]!==s||e[89]!==d?(He=N&&r.jsx("footer",{className:"shrink-0 border-t border-white/10 bg-black/25 px-2 py-2",children:r.jsx("div",{className:"flex gap-1.5 overflow-x-auto overscroll-x-contain pb-0.5",children:s.map((de,Ee)=>r.jsxs(X,{type:"button",variant:"ghost",onClick:()=>v(Ee),"aria-label":`View image ${Ee+1}`,"aria-current":Ee===d?"true":void 0,className:G("relative size-12 shrink-0 overflow-hidden rounded-md border bg-white/[0.04] p-0.5 sm:h-14 sm:w-[4.5rem]",Ee===d?"border-white ring-1 ring-white/40":"border-white/10 opacity-55 hover:border-white/25 hover:opacity-90"),children:[r.jsx("img",{src:de.src,alt:"",draggable:!1,className:"size-full rounded-[3px] object-cover"}),r.jsx("span",{className:"absolute bottom-0.5 right-0.5 rounded bg-black/70 px-1 font-mono text-xs text-white/80",children:Ee+1})]},`${de.id}-${Ee}`))})}),e[86]=v,e[87]=N,e[88]=s,e[89]=d,e[90]=He):He=e[90];let Ie;e[91]!==$||e[92]!==xe||e[93]!==_e||e[94]!==He?(Ie=r.jsxs(Yn,{showCloseButton:!1,onKeyDown:$,className:B,children:[W,K,xe,_e,He]}),e[91]=$,e[92]=xe,e[93]=_e,e[94]=He,e[95]=Ie):Ie=e[95];let Ce;return e[96]!==l||e[97]!==F||e[98]!==H||e[99]!==Ie?(Ce=r.jsx(Gn,{open:l,onOpenChange:F,onOpenChangeComplete:H,children:Ie}),e[96]=l,e[97]=F,e[98]=H,e[99]=Ie,e[100]=Ce):Ce=e[100],Ce}function Hl(n){return n.type==="user"}function Qc(n){return n.type==="assistant"}function jf(n){return n.type==="progress"}function Sf(n){return n.type==="system"}function Gg(n){return n.type==="summary"}function v4(n){return n.type==="queue-operation"}function Yg(n){return n.type==="attachment"}function y4(n){return n.type==="user"&&n.isCompactSummary===!0}function Xg(n){return n.type==="system"&&n.subtype==="compact_boundary"}function kf(n,e){let t=0;for(const s of n)e[s.name]=(e[s.name]??0)+1,s.isError&&t++;return t}function Nf(n,e){n.totalInputTokens+=e.input_tokens,n.totalOutputTokens+=e.output_tokens,n.totalCacheCreationTokens+=e.cache_creation_input_tokens??0,n.totalCacheReadTokens+=e.cache_read_input_tokens??0}function la(n){return{totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:n}}function ca(n){const e=la(n.length);for(const t of n){t.tokenUsage&&Nf(e,t.tokenUsage),t.durationMs&&(e.totalDurationMs+=t.durationMs),e.errorCount+=kf(t.toolCalls,e.toolCallCounts);for(const s of t.subAgentActivity)e.errorCount+=kf(s.toolCalls,e.toolCallCounts),s.tokenUsage&&Nf(e,s.tokenUsage)}return e}const w4=/<(agent-message|teammate-message)([^>]*)>([\s\S]*?)<\/\1>/g,j4=[/\bteammate_id=(?:"([^"]*)"|'([^']*)')/,/\bfrom=(?:"([^"]*)"|'([^']*)')/];function S4(n){for(const e of j4){const t=n.match(e),s=(t==null?void 0:t[1])??(t==null?void 0:t[2]);if(s)return s}return null}function k4(n){return n.replace(/^\s*<(?:agent-message|teammate-message)\b[^>]*>/,"").replace(/<\/(?:agent-message|teammate-message)>\s*$/,"").trim()}function or(n){let e=null,t=!1;const s=n.replace(w4,(o,i,a,l)=>(t=!0,e===null&&(e=S4(a)),l.trim()));return{sender:e,matched:t,body:t?s.trim():n}}const N4=[/\bblocking question\b/,/\bbefore i touch\b/,/\bshould i\b/,/\btell me one of\b/,/\byour call\b/,/\bwho owns\b/,/\bconfirm whether\b/],C4=[/(?:^|[,;:.!?—–-]\s*)tell me\b/,/(?:^|[,;:.!?—–-]\s*)say so\b/],_4=200,T4=/\bhttps?:\/\/\S+/g;function E4(n){const e=n.trim();if(!e)return!1;const t=e.slice(0,_4).toLowerCase();if(N4.some(i=>i.test(t)))return!0;const o=e.slice(e.lastIndexOf(`
|
|
52
|
+
`)+1).slice(-200).replace(T4,"").toLowerCase();return o.includes("?")||C4.some(i=>i.test(o))}function da(n){return typeof n=="string"?n:n.filter(e=>e.type==="text").map(e=>e.text).join(`
|
|
53
|
+
`)}function Cf(n){return n?typeof n=="string"?n:n.map(e=>e.type==="text"?e.text:"").filter(Boolean).join(`
|
|
54
|
+
`):""}function Jg(n){if(!(n!=null&&n.trim()))return!1;const e=n.trimStart();return e.startsWith("<")?!e.includes("<task-notification>")&&!e.startsWith("<system-reminder>")&&!e.startsWith("<local-command-"):!0}const P4=/<task-notification>[\s\S]*?<\/task-notification>/g,A4=/<[^>]*>/g;function R4(n){var t;if(((t=n.origin)==null?void 0:t.kind)==="task-notification")return!0;const e=da(n.message.content);return e.includes("<task-notification>")?e.replace(P4,"").replace(A4,"").trim()==="":!1}function M4(n){if(!Yg(n))return null;const e=n.attachment;if(!e||e.type!=="queued_command"||e.commandMode!=="prompt")return null;const t=e.prompt;if(t==null)return null;const s=typeof t=="string"?t:da(t);if(!Jg(s))return null;const o=e.origin;if((o==null?void 0:o.kind)==="peer"){const a=o.name??o.from??null;if(a)return{raw:s,sender:a,body:o.body??or(s).body}}if((o==null?void 0:o.kind)==="human")return{raw:s,sender:null,body:s};const i=or(s);return{raw:s,sender:i.sender,body:i.body}}const I4=[["attributionAgent","agent"],["attributionSkill","skill"],["attributionPlugin","plugin"],["attributionMcpServer","mcpServer"],["attributionMcpTool","mcpTool"]];function $4(n,e){let t=n;for(const[s,o]of I4){const i=e[s];typeof i!="string"||!i||(t={...t,[o]:i})}return t}function O4(n,e){var s,o;if(!n)return{...e};const t=(((s=n.output_tokens_details)==null?void 0:s.thinking_tokens)??0)+(((o=e.output_tokens_details)==null?void 0:o.thinking_tokens)??0);return{input_tokens:n.input_tokens+e.input_tokens,output_tokens:n.output_tokens+e.output_tokens,cache_creation_input_tokens:(n.cache_creation_input_tokens??0)+(e.cache_creation_input_tokens??0),cache_read_input_tokens:(n.cache_read_input_tokens??0)+(e.cache_read_input_tokens??0),speed:e.speed??n.speed,...n.output_tokens_details||e.output_tokens_details?{output_tokens_details:{thinking_tokens:t}}:{}}}const D4=/^This session is being continued from a previous conversation[\s\S]*?\n\nSummary:\s*\n/,L4=/\n+(?:If you need specific details from before compaction|(?:Please c|C)ontinue the conversation from where it left off)[\s\S]*$/;function z4(n){return da(n).trim().replace(D4,"").replace(L4,"").trim()}function F4(n){if(n)return{trigger:n.trigger,preTokens:n.preTokens,postTokens:n.postTokens}}function Qr(n,e){return{id:n.uuid??crypto.randomUUID(),userMessage:e,contentBlocks:[],thinking:[],assistantText:[],toolCalls:[],subAgentActivity:[],timestamp:n.timestamp??"",durationMs:null,tokenUsage:null,model:null}}function B4(n){const e=[];let t=0;for(;t<n.length;){const s=n[t];if(s.kind==="tool_calls"){const o=s.toolCalls.findIndex(i=>i.name==="EnterPlanMode");if(o!==-1){const i=s.toolCalls[o],a=String(i.input.plan??""),l=s.timestamp,c=s.toolCalls.slice(0,o);c.length>0&&e.push({kind:"tool_calls",toolCalls:c,timestamp:s.timestamp});const d=[],f=s.toolCalls.slice(o+1),u=f.findIndex(m=>m.name==="ExitPlanMode");if(u!==-1){d.push(...f.slice(0,u));const m=f[u],p=m.input.path?String(m.input.path):void 0;let h="pending";m.result!==null&&(h=m.isError?"rejected":"approved"),e.push({kind:"plan_mode",plan:a,planFilePath:p,status:h,toolCalls:d,timestamp:l});const g=f.slice(u+1);g.length>0&&e.push({kind:"tool_calls",toolCalls:g,timestamp:s.timestamp}),t++;continue}else{d.push(...f);let m,p,h="pending",g=t+1;const x=[];for(;g<n.length;){const v=n[g];if(v.kind==="tool_calls"){const w=v.toolCalls.findIndex(y=>y.name==="ExitPlanMode");if(w!==-1){d.push(...v.toolCalls.slice(0,w)),m=v.toolCalls[w],p=m.input.path?String(m.input.path):void 0,m.result!==null&&(h=m.isError?"rejected":"approved");const y=v.toolCalls.slice(w+1);e.push({kind:"plan_mode",plan:a,planFilePath:p,status:h,toolCalls:d,timestamp:l}),e.push(...x),y.length>0&&e.push({kind:"tool_calls",toolCalls:y,timestamp:v.timestamp}),t=g+1;break}else d.push(...v.toolCalls),g++}else if(v.kind==="hook_event"||v.kind==="text"||v.kind==="queued_prompt"||v.kind==="agent_message")x.push(v),g++;else break}m||(e.push({kind:"plan_mode",plan:a,planFilePath:void 0,status:"pending",toolCalls:d,timestamp:l}),e.push(...x),t=g);continue}}}e.push(s),t++}return e}function U4(n){return n.contentBlocks.some(e=>e.kind==="agent_message")?{...n,contentBlocks:n.contentBlocks.map(e=>{if(e.kind!=="agent_message")return e;const{reply:t,...s}=e;return s})}:n}function Zc(n){var s;const e=n.map(U4),t=new Map;for(const o of e)for(const i of o.contentBlocks){if(i.kind==="agent_message"){const a=t.get(i.sender);a?a.push(i):t.set(i.sender,[i]);continue}if(i.kind==="tool_calls")for(const a of i.toolCalls){if(a.name!=="SendMessage")continue;const l=a.input.to;if(typeof l!="string"||!l)continue;const c=(s=t.get(l))==null?void 0:s.shift();if(!c)continue;const d=a.input.summary;c.reply={summary:typeof d=="string"?d:"",timestamp:a.timestamp||i.timestamp||""}}}return e}function W4(n){const e=[];let t=!1;for(let s=0;s<n.length;s++){const o=n[s];if(Gg(o)||Xg(o)){t=!1;continue}if(Hl(o)&&!o.isMeta){const i=o.message.content;if(t&&Array.isArray(i)&&i.some(l=>l.type==="tool_result"))continue;e.push(s),t=!0;continue}Qc(o)&&!t&&(e.push(s),t=!0)}return e}function Qg(n){var N,C;const e=[],t=[];let s=null,o=0,i=null,a=null;function l(S){a&&(S.compactionSummary=a.summary,S.compactionMeta=a.meta,a=null)}let c=null;const d=new Map,f=new Set,u=new Map,m=new Map,p=new Set,h=new Map,g=[],x=new Map;function v(S,_){let P=x.get(S);P||(P=new Map,x.set(S,P)),P.set(_,(P.get(_)??0)+1)}function w(S,_){const P=x.get(S),A=P==null?void 0:P.get(_);return!P||!A?!1:(A===1?P.delete(_):P.set(_,A-1),!0)}function y(){for(const S of g)S.turn.contentBlocks.push(S.sender?{kind:"agent_message",sender:S.sender,body:S.body,timestamp:S.timestamp}:{kind:"queued_prompt",content:S.content,timestamp:S.timestamp});g.length=0}function j(S){if(!i)return;const _=u.get(S);if(!_||_.length===0)return;i.subAgentActivity.push(..._),u.delete(S);const P=p.has(S)?"background_agent":"sub_agent",A=m.get(S);if(A)A.messages.push(..._);else{const E={kind:P,messages:[..._]};i.contentBlocks.push(E),m.set(S,E)}}function k(){if(i){for(const S of i.toolCalls)j(S.id);for(const[S]of u)j(S);for(const S of i.contentBlocks)if(S.kind==="hook_event")for(const _ of S.events){if(!(_.eventName==="PostToolUse"||_.eventName.startsWith("PostToolUse:"))||!_.toolUseId)continue;const A=i.toolCalls.find(E=>E.id===_.toolUseId);A&&(_.updatedToolOutput&&(A.outputReplacedByHook=!0),_.durationMs!==void 0&&(A.hookDurationMs=(A.hookDurationMs??0)+_.durationMs))}i.contentBlocks=B4(i.contentBlocks),e.push(i),s!==null&&t.push(s),s=null,i=null,m.clear()}}for(o=0;o<n.length;o++){const S=n[o];if(Gg(S)){k(),a={summary:S.summary};continue}if(Xg(S)){k(),a={meta:F4(S.compactMetadata)};continue}if(y4(S)){k(),s=o,i=Qr(S,null),i.compactionSummary=z4(S.message.content),i.compactionMeta=a==null?void 0:a.meta,a=null;continue}if(Sf(S)&&S.subtype==="away_summary"&&S.content){c={content:S.content,timestamp:S.timestamp};continue}if(v4(S)){if(i&&S.operation==="enqueue"&&Jg(S.content)){const _=or(S.content);g.push({turn:i,content:S.content,timestamp:S.timestamp,sender:_.sender,body:_.body}),v(i,S.content)}continue}if(Yg(S)){const _=M4(S);i&&_!==null&&!w(i,_.raw)&&g.push({turn:i,content:_.raw,timestamp:((N=S.attachment)==null?void 0:N.timestamp)??S.timestamp,sender:_.sender,body:_.body});continue}if(g.length>0){const _=Hl(S)&&!S.isMeta?S.message.content:null;if(typeof _=="string"){const P=g.findIndex(A=>A.content===_);if(P>=0){const[A]=g.splice(P,1);w(A.turn,A.content)}}y()}if(Hl(S)&&!S.isMeta){const _=S.message.content;if(typeof _!="string"&&Array.isArray(_)&&_.some(A=>A.type==="tool_result")&&i){for(const E of _)if(E.type==="tool_result"){const T=d.get(E.tool_use_id);T&&(T.turn.toolCalls[T.index].result=Cf(E.content),T.turn.toolCalls[T.index].isError=E.is_error===!0,d.delete(E.tool_use_id))}const A=S.toolUseResult;if(A!=null&&A.agentId){const E=((C=_.find(D=>D.type==="tool_result"))==null?void 0:C.tool_use_id)??"",T=h.get(E),M=p.has(E),I=[];if(Array.isArray(A.content))for(const D of A.content)D.type==="text"&&I.push(D.text);const R={agentId:A.agentId,parentToolUseId:E||void 0,agentName:(T==null?void 0:T.name)??null,subagentType:(T==null?void 0:T.subagentType)??null,type:"assistant",content:A.content,toolCalls:[],thinking:[],text:I,timestamp:S.timestamp??"",tokenUsage:A.usage?{input_tokens:A.usage.input_tokens??0,output_tokens:A.usage.output_tokens??0,cache_creation_input_tokens:A.usage.cache_creation_input_tokens??0,cache_read_input_tokens:A.usage.cache_read_input_tokens??0}:null,model:null,isBackground:M,prompt:A.prompt,status:A.status,durationMs:A.totalDurationMs,toolUseCount:A.totalToolUseCount};if(!m.get(E)){i.subAgentActivity.push(R);const O={kind:M?"background_agent":"sub_agent",messages:[R]};i.contentBlocks.push(O),m.set(E,O)}}continue}if(R4(S)){const P={kind:"task_notification",content:da(_),timestamp:S.timestamp};if(i){i.contentBlocks.push(P);continue}s=o,i=Qr(S,null),i.contentBlocks.push(P),l(i);continue}k(),s=o,i=Qr(S,S.message.content),l(i),c&&(i.contentBlocks.push({kind:"recap",content:c.content,timestamp:c.timestamp}),c=null);continue}if(Qc(S)){let _=function(){M.length>0&&(I.contentBlocks.push({kind:"tool_calls",toolCalls:[...M],timestamp:E}),M.length=0)},P=function(){if(T.length>0){const R=I.contentBlocks[I.contentBlocks.length-1];R&&R.kind==="thinking"?R.blocks.push(...T):I.contentBlocks.push({kind:"thinking",blocks:[...T],timestamp:E}),T.length=0}};i||(s=o,i=Qr(S,null),l(i)),i.model=S.message.model,S.effort&&(i.effort=S.effort),i.attribution=$4(i.attribution,S);const A=S.message.id;f.has(A)||(f.add(A),i.tokenUsage=O4(i.tokenUsage,S.message.usage));const E=S.timestamp??"",T=[],M=[],I=i;for(const R of S.message.content)if(R.type==="thinking"){_();const $=R;if(!$.thinking)continue;i.thinking.push($),T.push($)}else if(R.type==="text"){_(),P();const $=/<thinking>([\s\S]*?)<\/thinking>/g;let D=R.text,O;for(;(O=$.exec(R.text))!==null;){const L=O[1].trim();if(L){const z={type:"thinking",thinking:L,signature:""};i.thinking.push(z),i.contentBlocks.push({kind:"thinking",blocks:[z],timestamp:E})}D=D.replace(O[0],"")}if(D=D.trim(),D){i.assistantText.push(D);const L=i.contentBlocks[i.contentBlocks.length-1];L&&L.kind==="text"?L.text.push(D):i.contentBlocks.push({kind:"text",text:[D],timestamp:E})}}else if(R.type==="tool_use"){P();const $={id:R.id,name:R.name,input:R.input,result:null,isError:!1,timestamp:S.timestamp??""},D=i.toolCalls.length;if(i.toolCalls.push($),M.push($),d.set(R.id,{turn:i,index:D}),R.name==="Task"||R.name==="Agent"){const O=R.input;O.run_in_background===!0&&p.add(R.id),h.set(R.id,{name:O.name??null,subagentType:O.subagent_type??null})}}P(),_();continue}if(jf(S)&&S.data.type==="agent_progress"){const _=S.data,P=S.parentToolUseID??"";let A=null;if(_.message.type==="assistant"){const R=_.message.message,$=R.id,D=R.usage;D&&$&&!f.has($)&&(f.add($),A={input_tokens:D.input_tokens??0,output_tokens:D.output_tokens??0,cache_creation_input_tokens:D.cache_creation_input_tokens??0,cache_read_input_tokens:D.cache_read_input_tokens??0})}const E=_.message.type==="assistant"?_.message.message.model??null:null,T=h.get(P),M={agentId:_.agentId,parentToolUseId:P||void 0,agentName:(T==null?void 0:T.name)??null,subagentType:(T==null?void 0:T.subagentType)??null,type:_.message.type,content:_.message.message.content,toolCalls:[],thinking:[],text:[],timestamp:_.message.timestamp??S.timestamp??"",tokenUsage:A,model:E,isBackground:p.has(P)};if(_.message.type==="assistant"){const R=_.message.message.content;if(Array.isArray(R))for(const $ of R)$.type==="thinking"?M.thinking.push($.thinking):$.type==="text"?M.text.push($.text):$.type==="tool_use"&&M.toolCalls.push({id:$.id,name:$.name,input:$.input,result:null,isError:!1,timestamp:_.message.timestamp??S.timestamp??""})}else if(_.message.type==="user"){const R=_.message.message.content;if(Array.isArray(R)){for(const $ of R)if($.type==="tool_result"){const D=u.get(P);if(D)for(const O of D){const L=O.toolCalls.find(z=>z.id===$.tool_use_id);L&&(L.result=Cf($.content),L.isError=$.is_error===!0)}}}}let I=u.get(P);I||(I=[],u.set(P,I)),I.push(M),i&&j(P);continue}if(jf(S)&&S.data.type==="hook_progress"){const _=S.data,P=String(_.hook_event_name??_.hookEvent??"unknown"),A=_.hookSpecificOutput,E={eventName:P,source:_.source!==void 0?String(_.source):void 0,toolName:_.tool_name!==void 0?String(_.tool_name):void 0,toolUseId:_.tool_use_id!==void 0?String(_.tool_use_id):void 0,command:_.command!==void 0?String(_.command):void 0,output:_.output!==void 0?String(_.output):void 0,stderr:_.stderr!==void 0?String(_.stderr):void 0,exitCode:_.exit_code!==void 0?Number(_.exit_code):void 0,decision:_.decision!==void 0?String(_.decision):void 0,durationMs:_.duration_ms!==void 0?Number(_.duration_ms):void 0,updatedToolOutput:(A==null?void 0:A.updatedToolOutput)!==void 0?String(A.updatedToolOutput):void 0,sessionTitle:(A==null?void 0:A.sessionTitle)!==void 0?String(A.sessionTitle):void 0,worktreePath:(A==null?void 0:A.worktreePath)!==void 0?String(A.worktreePath):void 0,timestamp:S.timestamp??""};if(i){const T=i.contentBlocks[i.contentBlocks.length-1];T&&T.kind==="hook_event"?T.events.push(E):i.contentBlocks.push({kind:"hook_event",events:[E],timestamp:S.timestamp})}continue}if(Sf(S)&&S.subtype==="turn_duration"&&i){S.durationMs!==void 0&&S.durationMs!==null&&(i.durationMs=(i.durationMs??0)+S.durationMs);continue}}return y(),k(),{turns:Zc(e),turnStartIndices:t}}function Zg(n){return Qg(n).turns}function _f(){return!0}function e1(n){const e=[];for(const t of n){const s=t.trim();if(s)try{e.push(JSON.parse(s))}catch{}}return e}function t1(n){return e1(n.split(`
|
|
55
|
+
`))}function n1(n){const e={sessionId:"",version:"",gitBranch:"",cwd:"",slug:"",name:"",model:"",branchedFrom:void 0};for(const t of n)if(t.sessionId&&!e.sessionId&&(e.sessionId=t.sessionId),t.version&&!e.version&&(e.version=t.version),t.gitBranch&&!e.gitBranch&&(e.gitBranch=t.gitBranch),t.cwd&&!e.cwd&&(e.cwd=t.cwd),t.slug&&!e.slug&&(e.slug=t.slug),t.name&&!e.name&&(e.name=t.name),t.branchedFrom&&!e.branchedFrom&&(e.branchedFrom=t.branchedFrom),Qc(t)&&t.message.model&&!e.model&&(e.model=t.message.model),e.sessionId&&e.version&&e.gitBranch&&e.cwd&&e.model)break;return e}function H4(n){return n1(e1(n))}function K4(n,e){const t=t1(n),s=n1(t),o=Zg(t),i=e!=null&&e.skipStats?la(o.length):ca(o);return{...s,turns:o,stats:i,rawMessages:e!=null&&e.skipStats?[]:t,agentKind:"claude"}}function q4(n,e){const t=t1(e);if(t.length===0)return n;const s=n.rawMessages,o=[...s,...t],i=W4(s),a=Math.max(0,n.turns.length-i.length);let l=Math.max(0,i.length-1);const c=new Set;for(const h of t)if(h.type==="progress"){const g=h.parentToolUseID;g&&c.add(g)}if(c.size>0)for(let h=l-1;h>=0;h--){const g=n.turns[a+h];if(g!=null&&g.toolCalls.some(x=>c.has(x.id))){l=h;break}}const d=i[l]??s.length,f=n.turns.slice(0,a+l),u=Zg(o.slice(d)),m=Zc([...f,...u]),p=ca(m);return{sessionId:n.sessionId,version:n.version,gitBranch:n.gitBranch,cwd:n.cwd,slug:n.slug,name:n.name,model:n.model||m.length>0&&m[m.length-1].model||"",turns:m,stats:p,rawMessages:o,branchedFrom:n.branchedFrom,agentKind:n.agentKind}}const s1="<task-notification>",V4=/<task-id>([^<]+)<\/task-id>/g,G4=/<tool-use-id>([^<]+)<\/tool-use-id>/g;function Cn(n){return typeof n=="object"&&n!==null}function Y4(n){const e=Cn(n.message)?n.message:null,t=e==null?void 0:e.content;return typeof t=="string"?[t]:Array.isArray(t)?t.filter(s=>Cn(s)&&typeof s.text=="string").map(s=>s.text):[]}function X4(n){const e=[],t=new Set,s=new Set,o=new Set;function i(a,l){if(a.includes(s1)){for(const c of a.matchAll(V4))t.add(c[1]),l==null||l.add(c[1]);for(const c of a.matchAll(G4))t.add(c[1]),l==null||l.add(c[1])}}for(const a of n){if(a.type==="user"){const l=Cn(a.toolUseResult)?a.toolUseResult:null;if((l==null?void 0:l.status)==="async_launched"){const c=Cn(a.message)?a.message:null,f=(Array.isArray(c==null?void 0:c.content)?c.content:[]).filter(p=>Cn(p)&&p.type==="tool_result").map(p=>p.tool_use_id),u=[l.agentId,l.taskId,...f].filter(p=>typeof p=="string"&&p.length>0),m=[l.description,l.workflowName,l.summary].find(p=>typeof p=="string"&&p.length>0)??"";u.length>0&&e.push({ids:u,description:m})}for(const c of Y4(a))i(c,o);continue}if(a.type==="assistant"){const l=Cn(a.message)?a.message:null,c=Array.isArray(l==null?void 0:l.content)?l.content:[];for(const d of c){if(!Cn(d)||d.type!=="tool_use"||d.name!=="TaskStop")continue;const f=Cn(d.input)?d.input:null,u=(f==null?void 0:f.task_id)??(f==null?void 0:f.shell_id);typeof u=="string"&&t.add(u)}continue}if(a.type==="attachment"){const l=Cn(a.attachment)?a.attachment:null;typeof(l==null?void 0:l.prompt)=="string"&&i(l.prompt,o);continue}if(a.type==="queue-operation"&&typeof a.content=="string"){const l=a.operation;i(a.content,l==="enqueue"?s:o)}}return{pendingDescriptions:e.filter(a=>!a.ids.some(l=>t.has(l))).map(a=>a.description),undeliveredNotifications:[...s].filter(a=>!o.has(a)).length}}function J4(n,e){return{status:"awaiting_agents",pendingQueue:e,pendingAgents:n.length,pendingAgentDescriptions:n.filter(t=>t.length>0)}}function Q4(n){var a,l;let e=0,t=null,s=!1;function o(c,d){const f={status:c,pendingQueue:Math.max(0,e)};return d&&(f.toolName=d),f}function i(){return t??(t=X4(n))}for(let c=n.length-1;c>=0;c--){const d=n[c];if(d.type!=="queue-operation"){if(d.type==="progress"){const f=d.data;if((f==null?void 0:f.type)==="hook_progress"&&(f.decision??((a=f.hookSpecificOutput)==null?void 0:a.permissionDecision))==="defer")return o("deferred");break}break}}for(let c=n.length-1;c>=0;c--){const d=n[c];if(d.type==="queue-operation"){if(typeof d.content=="string"&&d.content.includes(s1))continue;const f=d.operation;f==="enqueue"?e++:(f==="dequeue"||f==="remove")&&e--;continue}if(d.type==="attachment"){const f=Cn(d.attachment)?d.attachment:null;(f==null?void 0:f.commandMode)==="task-notification"&&(s=!0);continue}if(d.type==="assistant"){const f=d.message,u=f==null?void 0:f.stop_reason;if(u==="end_turn"){const m=i();if(s||m.undeliveredNotifications>0)return o("processing");if(m.pendingDescriptions.length>0)return J4(m.pendingDescriptions,Math.max(0,e));let p=!1;for(let h=c-1;h>=0;h--){const g=n[h];if(g.type==="user"&&!g.isMeta){p=!0;break}}return o(p?"completed":"idle")}if(u==="tool_use"){const m=f==null?void 0:f.content,p=(l=m==null?void 0:m.findLast)==null?void 0:l.call(m,h=>h.type==="tool_use");return o("tool_use",p==null?void 0:p.name)}return o("thinking")}if(d.type==="user"){if(d.isMeta)continue;return o("processing")}if(d.type==="system"&&d.subtype==="terminal_reason"){const f=d.reason;if(f)return{status:"completed",terminalReason:f,pendingQueue:Math.max(0,e)};continue}d.type!=="summary"&&d.type==="system"&&d.subtype}return{status:"idle"}}function Z4(n){return Qg(n).turnStartIndices}function o1(n,e,t){if(!e)return;n.assistantText.push(e);const s=n.contentBlocks[n.contentBlocks.length-1];if((s==null?void 0:s.kind)==="text"){s.text.push(e);return}n.contentBlocks.push({kind:"text",text:[e],timestamp:t})}const Tf={0:"\0",b:"\b",f:"\f",n:`
|
|
56
|
+
`,r:"\r",t:" ",v:"\v"};function ek(n){return!!(n&&/[A-Za-z_$]/.test(n))}function vi(n){return!!(n&&/[\w$]/.test(n))}function Fn(n,e){const t=n[e];if(t!=='"'&&t!=="'"&&t!=="`")return null;let s="",o=e+1;for(;o<n.length;){const i=n[o];if(i===t)return{endIndex:o+1,value:s};if(i!=="\\"){s+=i,o++;continue}if(o++,o>=n.length)return null;const a=n[o];if(a in Tf){s+=Tf[a],o++;continue}if(a===`
|
|
57
|
+
`){o++;continue}if(a==="\r"){o+=n[o+1]===`
|
|
58
|
+
`?2:1;continue}if(a==="x"&&/^[0-9a-fA-F]{2}$/.test(n.slice(o+1,o+3))){s+=String.fromCharCode(Number.parseInt(n.slice(o+1,o+3),16)),o+=3;continue}if(a==="u"){const l=n.slice(o+1).match(/^\{([0-9a-fA-F]+)\}/);if(l){const d=Number.parseInt(l[1],16);if(Number.isFinite(d)&&d<=1114111){s+=String.fromCodePoint(d),o+=l[0].length+1;continue}}const c=n.slice(o+1,o+5);if(/^[0-9a-fA-F]{4}$/.test(c)){s+=String.fromCharCode(Number.parseInt(c,16)),o+=5;continue}}s+=a,o++}return null}const cs={"(":")","[":"]","{":"}"};function ed(n,e){if(n[e]!=="/")return null;if(n[e+1]==="/"){const t=n.indexOf(`
|
|
59
|
+
`,e+2);return t===-1?n.length:t+1}if(n[e+1]==="*"){const t=n.indexOf("*/",e+2);return t===-1?n.length:t+2}return null}function ua(n,e){const t=Fn(n,e);if(t)return{endIndex:t.endIndex,isString:!0};const s=ed(n,e);return s===null?null:{endIndex:s,isString:!1}}function qt(n,e){let t=e;for(;t<n.length;){if(/\s/.test(n[t])){t++;continue}const s=ed(n,t);if(s===null)break;t=s}return t}function fa(n,e){const t=n[e];if(!cs[t])return null;const s=[cs[t]];for(let o=e+1;o<n.length;o++){const i=ua(n,o);if(i){o=i.endIndex-1;continue}const a=n[o];if(cs[a]){s.push(cs[a]);continue}if(a===s.at(-1)&&(s.pop(),s.length===0))return o}return null}function r1(n,e){if(!ek(n[e]))return null;let t=e+1;for(;vi(n[t]);)t++;return{value:n.slice(e,t),endIndex:t}}function tk(n,e,t){var f;const s=(f=t.trim().match(/^([A-Za-z_$][\w$]*)$/))==null?void 0:f[1];if(!s)return t;const o=n.slice(0,e),i=new RegExp(`\\b(?:const|let|var)\\s+${s.replace(/[$]/g,"\\$")}\\s*=`,"g"),a=[...o.matchAll(i)].at(-1);if(!a||a.index===void 0)return t;const l=qt(o,a.index+a[0].length),c=o[l];if(c==="{"||c==="["||c==="("){const u=fa(o,l);if(u!==null)return o.slice(l,u+1).trim()}const d=Fn(o,l);return d?o.slice(l,d.endIndex).trim():t}function nk(n){const e=[];for(let t=0;t<n.length;t++){const s=ua(n,t);if(s){t=s.endIndex-1;continue}if(!n.startsWith("tools",t)||vi(n[t-1])||vi(n[t+5]))continue;let o=qt(n,t+5),i="";if(n[o]==="."){o=qt(n,o+1);const c=r1(n,o);if(!c)continue;i=c.value,o=c.endIndex}else if(n[o]==="["){o=qt(n,o+1);const c=Fn(n,o);if(!c||(o=qt(n,c.endIndex),n[o]!=="]"))continue;i=c.value,o++}else continue;if(o=qt(n,o),n[o]!=="(")continue;const a=fa(n,o);if(a===null){e.push({name:i,argumentSource:n.slice(o+1).trim(),startIndex:t});break}const l=n.slice(o+1,a).trim();e.push({name:i,argumentSource:tk(n,t,l),startIndex:t})}return e}function i1(n,e){return Fn(n,e)??r1(n,e)}function sk(n,e,t){const s=[];for(let o=e;o<t;o++){const i=ua(n,o);if(i){o=i.endIndex-1;continue}const a=n[o];if(cs[a]){s.push(cs[a]);continue}if(s.length>0&&a===s.at(-1)){s.pop();continue}if(s.length===0&&a===",")return o}return t}function td(n,e){let t=qt(n,0);for(;n[t]==="(";)t=qt(n,t+1);if(n[t]!=="{")return null;const s=fa(n,t);if(s===null)return null;let o=t+1;for(;o<s;){if(o=qt(n,o),n[o]===","){o++;continue}const i=i1(n,o);if(!i){o++;continue}if(o=qt(n,i.endIndex),n[o]!==":"){o++;continue}const a=qt(n,o+1),l=sk(n,a,s);if(i.value===e)return n.slice(a,l).trim();o=l+1}return null}function a1(n,e,t){const s=[];for(let o=0;o<n.length;o++){const i=ed(n,o);if(i!==null){o=i-1;continue}const a=i1(n,o);if(a){if(a.value===e&&!vi(n[o-1])){const l=qt(n,a.endIndex);if(n[l]===":"){const c=t(qt(n,l+1));c!==null&&s.push(c)}}o=a.endIndex-1}}return s}function nd(n,e){return a1(n,e,t=>{var s;return((s=Fn(n,t))==null?void 0:s.value)??null})}function l1(n,e){return a1(n,e,t=>{const s=n.slice(t).match(/^-?[\d_]+(?:\.\d+)?/);if(!s)return null;const o=Number(s[0].replaceAll("_",""));return Number.isFinite(o)?o:null})}function c1(n){const e=qt(n,0);if(!n.slice(e).trim())return 0;if(n[e]!=="[")return 1;const t=fa(n,e);if(t===null)return 1;let s=0,o=!1;const i=[];for(let a=e+1;a<t;a++){const l=ua(n,a);if(l){o||(o=l.isString),a=l.endIndex-1;continue}const c=n[a];cs[c]?(o=!0,i.push(cs[c])):i.length>0&&c===i.at(-1)?i.pop():i.length===0&&c===","?(o&&s++,o=!1):/\s/.test(c)||(o=!0)}return s+(o?1:0)}function Ef(n){return n.includes("*** Begin Patch")&&n.includes("*** End Patch")}function ok(n){if(!n.includes("apply_patch")||!n.includes("*** Begin Patch"))return[];const e=new Map;for(let a=0;a<n.length;a++){const l=Fn(n,a);if(l){if(Ef(l.value)){const c=n.slice(0,a).match(/(?:^|[;\n])\s*(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*$/);c&&e.set(c[1],l.value)}a=l.endIndex-1}}const t=[],s=new Set,o=/\btools\s*\.\s*apply_patch\s*\(/g;let i;for(;(i=o.exec(n))!==null;){let a=i.index+i[0].length;for(;/\s/.test(n[a]??"");)a++;const l=Fn(n,a),c=l?null:n.slice(a).match(/^([A-Za-z_$][\w$]*)/),d=(l==null?void 0:l.value)??(c?e.get(c[1]):void 0);!d||!Ef(d)||s.has(d)||(s.add(d),t.push(d))}return t}function Pf(n,e){if(!e||n.startsWith("/")||/^[A-Za-z]:[\\/]/.test(n))return n;const t=e.replace(/[\\/]+$/,""),s=n.replace(/^\.[\\/]/,"");return/^[A-Za-z]:[\\/]/.test(e)?`${t}\\${s.replace(/\//g,"\\")}`:`${t}/${s}`}function Af(n,e,t,s=""){var c,d;const o=[],i=/^\*\*\*\s+(Update File|Add File|Delete File):\s*(.+)$/gm,a=[];let l;for(;(l=i.exec(n))!==null;)a.push({action:l[1],filePath:l[2].trim(),headerIdx:l.index,startIdx:l.index+l[0].length});for(let f=0;f<a.length;f++){const u=a[f],m=f+1<a.length?a[f+1].headerIdx:n.length,p=n.slice(u.startIdx,m),h=(d=(c=p.match(/^\*\*\*\s+Move to:\s*(.+)$/m))==null?void 0:c[1])==null?void 0:d.trim(),g=Pf(u.filePath,s),x=Pf(h||u.filePath,s),v=p.split(/^@@.*$/m).filter(k=>k.trim()),w=[],y=[];for(const k of v)for(const N of k.split(`
|
|
60
|
+
`))N.startsWith("-")?w.push(N.slice(1)):N.startsWith("+")?y.push(N.slice(1)):N.startsWith(" ")&&(w.push(N.slice(1)),y.push(N.slice(1)));const j=a.length>1?`${e}:file-${f}`:e;u.action==="Add File"?o.push({id:j,name:"Write",input:{file_path:x,content:y.join(`
|
|
61
|
+
`)},result:null,isError:!1,timestamp:t}):u.action==="Delete File"?o.push({id:j,name:"Edit",input:{file_path:x,old_string:w.join(`
|
|
62
|
+
`),new_string:""},result:null,isError:!1,timestamp:t}):o.push({id:j,name:"Edit",input:{file_path:x,...h?{old_path:g}:{},old_string:w.join(`
|
|
63
|
+
`),new_string:y.join(`
|
|
64
|
+
`)},result:null,isError:!1,timestamp:t})}return o}function d1(n,e,t,s,o=""){return n==="apply_patch"?Af(e,t,s,o):ok(e).flatMap((i,a)=>Af(i,`${t}:patch-${a}`,s,o))}function rk(n,e,t){var l;if(!e||!/(?:apply[_ ]patch|invalid patch|invalid context|failed to (?:apply|find)|could not apply)/i.test(n))return new Set;const s=new Map;for(const c of t){const d=(l=c.id.match(/:patch-(\d+)(?::file-\d+)?$/))==null?void 0:l[1];if(d===void 0)continue;const f=Number(d),u=s.get(f)??[];u.push(c),s.set(f,u)}if(s.size===0)return new Set(t.map(c=>c.id));const o=n.toLowerCase().replaceAll("\\","/"),i=new Set;for(const[c,d]of s)d.some(f=>{const u=String(f.input.file_path??"").toLowerCase().replaceAll("\\","/");if(!u)return!1;const p=u.split("/").filter(Boolean).slice(-2).join("/");return o.includes(u)||p.includes("/")&&o.includes(p)})&&i.add(c);for(const c of o.matchAll(/\bpatch\s*(?:#|-)?\s*(\d+)\b/g)){const d=Number(c[1]);s.has(d)&&i.add(d)}i.size===0&&i.add(Math.max(...s.keys()));const a=Math.min(...i);for(const c of s.keys())c>=a&&i.add(c);return new Set([...i].flatMap(c=>{var d;return((d=s.get(c))==null?void 0:d.map(f=>f.id))??[]}))}function sd(n){return typeof n=="object"&&n!==null}const ik=new Map([["spawn_agent","spawn_agent"],["spawnAgent","spawn_agent"],["wait_agent","wait_agent"],["waitAgent","wait_agent"],["send_message","send_message"],["sendMessage","send_message"],["followup_task","followup_task"],["followupTask","followup_task"],["list_agents","list_agents"],["listAgents","list_agents"],["interrupt_agent","interrupt_agent"],["interruptAgent","interrupt_agent"]]);function rr(n){const e=n.split(/(?:__|[.:/])+/).filter(Boolean).at(-1)??n;return ik.get(e)??n}function Kl(n){if(!n)return!1;const e=n.match(/Process exited with code (\d+)/);if(e)return e[1]!=="0";const t=n.replace(/\b0\s+(?:fail(?:ed|ures?)?|errors?)\b/gi,"").replace(/\bno\s+(?:failures?|errors?)\b/gi,"");return/\b(error|failed|exception)\b/i.test(t)}function ak(n){return{todos:(Array.isArray(n.plan)?n.plan:[]).filter(s=>sd(s)).map(s=>({content:typeof s.step=="string"?s.step:"",status:typeof s.status=="string"?s.status:"pending",activeForm:typeof s.step=="string"?s.step:""}))}}function lk(n){return typeof n=="string"?n:Array.isArray(n)?n.filter(e=>sd(e)&&typeof e.text=="string").map(e=>e.text).join(""):""}function u1(n){const e=lk(n);if(!e)return{text:"",isError:!1};try{const t=JSON.parse(e),s=typeof t.output=="string"?t.output:e,o=sd(t.metadata)?t.metadata:null,i=o?o.exit_code!==0&&o.exit_code!==void 0:Kl(s);return{text:s,isError:i}}catch{return{text:e,isError:Kl(e)}}}const ck=["# AGENTS.md instructions for ","<recommended_plugins>","<environment_context>","<permissions instructions>","<collaboration_mode>","<skills_instructions>"];function dk(n){var e,t;return((t=(e=globalThis.crypto)==null?void 0:e.randomUUID)==null?void 0:t.call(e))??`${n}-${Math.random().toString(36).slice(2,10)}`}function od(n){try{return JSON.parse(n)}catch{return null}}function st(n){return typeof n=="object"&&n!==null}function po(n){return!n||typeof n.type!="string"?!1:n.type==="session_meta"||n.type==="turn_context"||n.type==="event_msg"||n.type==="response_item"||n.type==="inter_agent_communication_metadata"||n.type==="compacted"||n.type==="world_state"}function yi(n,e){const t=n==null?void 0:n.content;return Array.isArray(t)?t.filter(s=>st(s)&&s.type===e&&typeof s.text=="string").map(s=>s.text).join(`
|
|
65
|
+
`).trim():""}const uk=/^data:(image\/(?:png|jpeg|gif|webp));base64,(.+)$/is,fk=/^data:(audio\/(?:wav|x-wav|mpeg|mp4|webm|ogg));base64,(.+)$/is;function f1(n){if(typeof n!="string")return null;const e=uk.exec(n);return!(e!=null&&e[1])||!e[2]?null:{type:"image",source:{type:"base64",media_type:e[1].toLowerCase(),data:e[2]}}}function m1(n){if(typeof n!="string")return null;const e=fk.exec(n);return!(e!=null&&e[1])||!e[2]?null:{type:"audio",source:{type:"base64",media_type:e[1].toLowerCase(),data:e[2]}}}function mk(n){return Array.isArray(n.images)?n.images.map(f1).filter(e=>e!==null):[]}function pk(n){return Array.isArray(n.audio)?n.audio.map(m1).filter(e=>e!==null):[]}function p1(n){return Array.isArray(n.content)?n.content.filter(e=>st(e)&&e.type==="input_image").map(e=>f1(e.image_url)).filter(e=>e!==null):[]}function h1(n){return Array.isArray(n.content)?n.content.filter(e=>st(e)&&e.type==="input_audio").map(e=>m1(e.audio_url)).filter(e=>e!==null):[]}function Rf(n,e,t=[],s=[],o=[]){const i=[...s.map(l=>`
|
|
66
|
+
`),...o.map(l=>`
|
|
67
|
+
[audio attachment](<${l}>)`)].join(""),a=n+i;return e.length===0&&t.length===0?a:[...e,...t,...a?[{type:"text",text:a}]:[]]}function hk(n){var a,l;const e=yi(n,"input_text");if(!e)return{messageType:null,text:""};const t=e.match(/\r?\nPayload:\s*(?:\r?\n|$)/);if(!e.startsWith("Message Type:")||!t||t.index===void 0)return{messageType:null,text:e.trim()};const o=((l=(a=e.slice(0,t.index).match(/^Message Type:\s*([^\r\n]+)/))==null?void 0:a[1])==null?void 0:l.trim().toUpperCase())??null,i=e.slice(t.index+t[0].length).trim();return{messageType:o,text:i}}function To(n){return n.split(/[\\/]/).filter(Boolean).at(-1)??null}function gk(n){if(typeof n!="string")return"";const e=n.trim();return/^gAAAAA[A-Za-z0-9_-]+$/.test(e)?"":e}function ql(n){const e=n.trim();return!e||ck.some(t=>e.startsWith(t))?"":e}function xk(n,e){return n?{input_tokens:n.input_tokens+e.input_tokens,output_tokens:n.output_tokens+e.output_tokens,cache_creation_input_tokens:(n.cache_creation_input_tokens??0)+(e.cache_creation_input_tokens??0),cache_read_input_tokens:(n.cache_read_input_tokens??0)+(e.cache_read_input_tokens??0)}:{...e}}function bk(n){if(!st(n))return null;const e=typeof n.input_tokens=="number"?n.input_tokens:0,t=typeof n.output_tokens=="number"?n.output_tokens:0,s=typeof n.cache_write_input_tokens=="number"?n.cache_write_input_tokens:typeof n.cache_creation_input_tokens=="number"?n.cache_creation_input_tokens:0,o=typeof n.cached_input_tokens=="number"?Math.max(0,n.cached_input_tokens):null,i=o??(typeof n.cache_read_input_tokens=="number"?n.cache_read_input_tokens:0),a=o===null?e:Math.max(0,e-o);return a===0&&t===0&&s===0&&i===0?null:{input_tokens:a,output_tokens:t,cache_creation_input_tokens:s,cache_read_input_tokens:i}}function vk(n,e,t){if(!e)return;const s={type:"thinking",thinking:e,signature:""};n.thinking.push(s);const o=n.contentBlocks[n.contentBlocks.length-1];if(o&&o.kind==="thinking"){o.blocks.push(s);return}n.contentBlocks.push({kind:"thinking",blocks:[s],timestamp:t})}function Hs(n,e,t){n.toolCalls.push(e);const s=n.contentBlocks[n.contentBlocks.length-1];if(s&&s.kind==="tool_calls"&&s.timestamp===t){s.toolCalls.push(e);return}n.contentBlocks.push({kind:"tool_calls",toolCalls:[e],timestamp:t})}function yk(n,e,t){if(!e||!(e.userMessage!==null||e.assistantText.length>0||e.toolCalls.length>0||e.thinking.length>0||e.subAgentActivity.length>0))return null;if(e.timestamp&&t){const o=new Date(e.timestamp).getTime(),i=new Date(t).getTime();Number.isFinite(o)&&Number.isFinite(i)&&i>=o&&(e.durationMs=i-o)}return n.push(e),null}function Mf(n){if(typeof n!="string"||!n.trim())return{};try{const e=JSON.parse(n);return st(e)?e:{value:e}}catch{return{raw:n}}}function Eo(n){if(typeof n=="string")return n;try{return JSON.stringify(n)}catch{return String(n??"")}}function If(...n){return n.find(e=>typeof e=="string")}function wk(n){return n.startsWith("exec-")}function jk(n){if(!st(n))return{text:Eo(n),isError:!1};if("Err"in n)return{text:Eo(n.Err),isError:!0};const e=st(n.Ok)?n.Ok:null;if(!e)return{text:Eo(n),isError:!1};const t=u1(e.content);return{text:t.text||(e.structuredContent!==void 0?Eo(e.structuredContent):Eo(e)),isError:e.isError===!0||t.isError}}function Sk(n,e,t){return{id:n?`${n}@${e}`:dk("codex-turn"),userMessage:null,contentBlocks:[],thinking:[],assistantText:[],toolCalls:[],subAgentActivity:[],timestamp:e,durationMs:null,tokenUsage:null,model:t}}function g1(n){return n.type==="event_msg"&&st(n.payload)&&n.payload.type==="user_message"&&typeof n.payload.message=="string"?ql(n.payload.message):n.type==="response_item"&&st(n.payload)&&n.payload.type==="message"&&n.payload.role==="user"?ql(yi(n.payload,"input_text")):""}function kk(n,e){if(n.type==="session_meta"||n.type==="event_msg"&&(e==null?void 0:e.type)==="task_started")return!1;if(n.type==="response_item"&&(e==null?void 0:e.type)==="message"){if(e.role==="developer"||e.role==="system")return!1;if(e.role==="user")return g1(n)!==""||p1(e).length>0||h1(e).length>0}return!0}function x1(n){let e="",t="",s="",o="",i="",a,l="",c="",d="",f="",u=0,m=!1,p=null,h="/root",g="";for(const x of n){if(!st(x.payload))continue;if(x.type==="session_meta"){if(e||(e=typeof x.payload.id=="string"?x.payload.id:""),t||(t=typeof x.payload.cli_version=="string"?x.payload.cli_version:""),o||(o=typeof x.payload.cwd=="string"?x.payload.cwd:""),!a&&st(x.payload.branchedFrom)){const j=typeof x.payload.branchedFrom.sessionId=="string"?x.payload.branchedFrom.sessionId:"";j&&(a={sessionId:j,turnIndex:typeof x.payload.branchedFrom.turnIndex=="number"?x.payload.branchedFrom.turnIndex:null})}const w=st(x.payload.source)?x.payload.source:null;if(w&&st(w.subagent)){m=!0;const j=st(w.subagent.thread_spawn)?w.subagent.thread_spawn:null;j&&typeof j.agent_path=="string"&&(h=j.agent_path)}typeof x.payload.forked_from_id=="string"&&x.payload.forked_from_id&&(p=x.payload.forked_from_id);const y=st(x.payload.git)?x.payload.git:null;s||(s=y&&typeof y.branch=="string"?y.branch:"")}x.type==="turn_context"&&(i||(i=typeof x.payload.model=="string"?x.payload.model:""),o||(o=typeof x.payload.cwd=="string"?x.payload.cwd:""));const v=g1(x);v&&v!==g&&(l||(l=v),c=v,g=v,u++,d||(d=x.timestamp??""),f=x.timestamp??f)}return f===""&&(f=d),{sessionId:e,version:t,gitBranch:s,cwd:o,model:i,slug:"",name:"",branchedFrom:a,firstUserMessage:l,lastUserMessage:c,timestamp:d,lastTimestamp:f,turnCount:u,isSubagent:m,parentSessionId:p,agentPath:h}}function b1(n){for(const e of n.split(`
|
|
68
|
+
`)){const t=e.trim();if(t)return po(od(t))}return!1}function Nk(n){return po(n[0]??null)}function Ck(n){const e=n.map(od).filter(po);return x1(e)}function v1(n,e){const t=x1(n.filter(po)),s=[],o=new Map,i=new Map,a=new Map,l=new Map,c=new Map,d=new Map,f=new Map,u=new Map;function m(P,A,E,T={}){const M=c.get(P);let I=u.get(P);if(!I){const $={agentId:P,parentToolUseId:(M==null?void 0:M.parentToolCallId)||void 0,agentName:(M==null?void 0:M.nickname)??(M!=null&&M.agentPath?To(M.agentPath):null),subagentType:(M==null?void 0:M.agentType)??null,type:"assistant",content:null,toolCalls:[],thinking:[],text:[],timestamp:(M==null?void 0:M.timestamp)??E,tokenUsage:null,model:(M==null?void 0:M.model)??null,isBackground:!1,prompt:(M==null?void 0:M.message)||void 0,status:T.status??"running"};A.subAgentActivity.push($);const D=A.contentBlocks[A.contentBlocks.length-1];(D==null?void 0:D.kind)==="sub_agent"?D.messages.push($):A.contentBlocks.push({kind:"sub_agent",messages:[$],timestamp:E}),I={message:$,turn:A},u.set(P,I)}const R=I.message;if(M&&(R.parentToolUseId=M.parentToolCallId||R.parentToolUseId,R.agentName=M.nickname??(M.agentPath?To(M.agentPath):R.agentName),R.subagentType=M.agentType,R.model=M.model,R.prompt=M.message||R.prompt),T.text&&!R.text.includes(T.text)&&(R.text.push(T.text),R.content=R.text.join(`
|
|
69
|
+
|
|
70
|
+
`)),T.status){const $=new Set(["completed","failed","interrupted"]);if(T.status==="running"&&R.status&&$.has(R.status)||(R.status=T.status),$.has(T.status)&&R.timestamp&&E){const D=new Date(R.timestamp).getTime(),O=new Date(E).getTime();Number.isFinite(D)&&Number.isFinite(O)&&O>=D&&(R.durationMs=O-D)}}return R}let p=null,h=null,g=t.model||null,x="",v=null,w=!1;const y=[];let j=0,k=null,N=null;function C(P){const A=s.length,E=yk(s,P,x);return s.length>A&&N!==null&&y.push(N),N=null,E}function S(P,A,E){const T=Sk(P,A,E);return N=k??j,k=null,w||(T.isFragment=!0),v&&(T.compactionSummary=v,v=null),T}function _(P,A,E,T,M){const I=i.get(A);if(I){I.input={...I.input,...E},I.result=T,I.isError=T==="failed";return}const R={id:A,name:"WebSearch",input:E,result:T,isError:T==="failed",timestamp:M};i.set(A,R),Hs(P,R,M)}for(let P=0;P<n.length;P++){const A=n[P];if(!po(A))continue;j=P;const E=st(A.payload)?A.payload:void 0,T=A.timestamp??"";if(A.type==="compacted"){p=C(p),v="Conversation compacted",x=T;continue}if(A.type!=="world_state"){if(A.type==="turn_context"){p=C(p),k=P,h=typeof(E==null?void 0:E.turn_id)=="string"?E.turn_id:null,g=typeof(E==null?void 0:E.model)=="string"?E.model:g,x=T,w=!0;continue}if(A.type==="event_msg"&&(E==null?void 0:E.type)==="user_message"&&typeof E.message=="string"){p&&(p.assistantText.length>0||p.toolCalls.length>0||p.thinking.length>0)&&(p=C(p)),w=!0,p??(p=S(h,T,g));const M=(Array.isArray(E.local_images)?E.local_images:[]).filter(R=>typeof R=="string"&&R.length>0),I=(Array.isArray(E.local_audio)?E.local_audio:[]).filter(R=>typeof R=="string"&&R.length>0);p.userMessage=Rf(E.message,mk(E),pk(E),M,I),p.isFragment=!1,p.timestamp=p.timestamp||T,x=T;continue}if(!(!p&&!kk(A,E))){if(p??(p=S(h,T,g)),!p.model&&g&&(p.model=g),p.timestamp||(p.timestamp=T),T&&(x=T),A.type==="event_msg"&&(E==null?void 0:E.type)==="token_count"){const M=st(E.info)?E.info:null,I=M?bk(M.last_token_usage):null;I&&(p.tokenUsage=xk(p.tokenUsage,I));continue}if(A.type==="event_msg"&&(E==null?void 0:E.type)==="web_search_end"&&typeof E.call_id=="string"){const M={};typeof E.query=="string"&&E.query&&(M.query=E.query),st(E.action)&&(M.action=E.action),_(p,E.call_id,M,"completed",T);continue}if(A.type==="event_msg"&&(E==null?void 0:E.type)==="mcp_tool_call_end"&&typeof E.call_id=="string"&&st(E.invocation)){const M=E.invocation,I=typeof M.server=="string"?M.server:"mcp",R=typeof M.tool=="string"?M.tool:"tool",$=st(M.arguments)?M.arguments:{},D=jk(E.result),O=o.get(E.call_id);O?(O.result=D.text,O.isError=D.isError,o.delete(E.call_id)):wk(E.call_id)||Hs(p,{id:E.call_id,name:`mcp__${I}__${R}`,input:$,result:D.text,isError:D.isError,timestamp:T},T);continue}if(A.type==="event_msg"&&(E==null?void 0:E.type)==="sub_agent_activity"&&typeof E.agent_thread_id=="string"&&typeof E.agent_path=="string"){const M=E.agent_thread_id,I=typeof E.event_id=="string"?E.event_id:"",R=typeof E.kind=="string"?E.kind:"started",$=I?l.get(I):void 0,D=d.get(E.agent_path),O=c.get(M)??(D?c.get(D):void 0);if(R!=="started"&&!O&&!$)continue;if(D&&D!==M&&!u.has(M)){const F=u.get(D);F&&(F.message.agentId=M,u.delete(D),u.set(M,F)),c.delete(D)}const L={agentId:M,nickname:(O==null?void 0:O.nickname)??To(E.agent_path)??($==null?void 0:$.taskName)??null,agentPath:E.agent_path,message:(O==null?void 0:O.message)??($==null?void 0:$.message)??"",model:(O==null?void 0:O.model)??($==null?void 0:$.model)??null,agentType:(O==null?void 0:O.agentType)??($==null?void 0:$.agentType)??null,timestamp:(O==null?void 0:O.timestamp)??(T||($==null?void 0:$.timestamp)||""),parentToolCallId:(O==null?void 0:O.parentToolCallId)??I};c.set(M,L),d.set(E.agent_path,M),I&&(R==="started"||$)&&f.set(I,M),m(M,p,T,{status:R==="interrupted"?"interrupted":"running"});continue}if(!(A.type!=="response_item"||!E)){if(E.type==="reasoning"){const M=Array.isArray(E.summary)?E.summary.filter(I=>typeof I=="string").join(`
|
|
71
|
+
`):"";vk(p,M.trim(),T);continue}if(E.type==="message"&&E.role==="assistant"){o1(p,yi(E,"output_text"),T);continue}if(E.type==="message"&&E.role==="user"&&p.userMessage===null){const M=ql(yi(E,"input_text")),I=p1(E),R=h1(E);(M||I.length>0||R.length>0)&&(p.userMessage=Rf(M,I,R),p.isFragment=!1,w=!0);continue}if(E.type==="web_search_call"&&typeof E.id=="string"){const M={};st(E.action)&&(M.action=E.action);const I=typeof E.status=="string"?E.status:"completed";_(p,E.id,M,I,T);continue}if(E.type==="tool_search_call"){const M=If(E.call_id,E.id)??"";if(M){const I={id:M,name:"ToolSearch",input:st(E.arguments)?E.arguments:{},result:null,isError:!1,timestamp:T};o.set(M,I),Hs(p,I,T)}continue}if(E.type==="tool_search_output"&&typeof E.call_id=="string"){const M=o.get(E.call_id);if(M){const I=Array.isArray(E.tools)?E.tools:[],R=I.filter(st).map(O=>If(O.name)??"").filter(Boolean),$=R.length>0?R.length:I.length,D=`Found ${$} tool${$===1?"":"s"}`;M.result=R.length>0?`${D}: ${R.join(", ")}`:D,M.isError=E.status==="failed",o.delete(E.call_id)}continue}if(E.type==="agent_message"&&typeof E.author=="string"){const M=E.author,I=typeof E.recipient=="string"?E.recipient:null,R=hk(E);if(R.messageType==="NEW_TASK")continue;const $=d.get(M),D=M.startsWith(`${t.agentPath}/`)&&(I===null||I===t.agentPath);if(!$&&!D)continue;const O=$??M;$||(c.set(O,{agentId:O,nickname:To(M),agentPath:M,message:"",model:null,agentType:null,timestamp:T,parentToolCallId:""}),d.set(M,O));let L;R.messageType==="FINAL_ANSWER"?L="completed":R.messageType==="ERROR"||R.messageType==="FAILED"?L="failed":R.messageType==="INTERRUPTED"?L="interrupted":R.messageType==="MESSAGE"&&(L="running"),m(O,p,T,{status:L,text:R.text||void 0});continue}if(E.type==="function_call"&&typeof E.call_id=="string"){const M=typeof E.name=="string"?E.name:"tool",I=rr(M),R=Mf(E.arguments);let $=I,D=R;I==="exec_command"?$="Bash":I==="update_plan"&&($="TodoWrite",D=ak(R)),I==="spawn_agent"&&l.set(E.call_id,{callId:E.call_id,message:gk(R.message),taskName:typeof R.task_name=="string"?R.task_name:null,model:typeof R.model=="string"?R.model:null,agentType:typeof R.agent_type=="string"?R.agent_type:null,timestamp:T});const O={id:E.call_id,name:$,input:D,result:null,isError:!1,timestamp:T};o.set(O.id,O),Hs(p,O,T);continue}if(E.type==="function_call_output"&&typeof E.call_id=="string"){const M=o.get(E.call_id);if(!M)continue;const I=typeof E.output=="string"?E.output:null;if(M.result=I,M.isError=Kl(I),o.delete(E.call_id),M.name==="spawn_agent"&&I)try{const R=JSON.parse(I),$=typeof R.agent_id=="string"?R.agent_id:f.get(M.id)??"",D=typeof R.task_name=="string"?R.task_name:null,O=typeof R.nickname=="string"?R.nickname:D?To(D):null;if($){const L=l.get(M.id),z=c.get($),F={agentId:$,nickname:O??(z==null?void 0:z.nickname)??(L==null?void 0:L.taskName)??null,agentPath:D??(z==null?void 0:z.agentPath)??null,message:(z==null?void 0:z.message)??(L==null?void 0:L.message)??"",model:(z==null?void 0:z.model)??(L==null?void 0:L.model)??null,agentType:(z==null?void 0:z.agentType)??(L==null?void 0:L.agentType)??null,timestamp:(z==null?void 0:z.timestamp)??(L==null?void 0:L.timestamp)??T,parentToolCallId:(z==null?void 0:z.parentToolCallId)??M.id};c.set($,F),f.set(M.id,$),F.agentPath&&d.set(F.agentPath,$),m($,p,T,{status:"running"})}}catch{}if(M.name==="wait_agent"&&I&&p)try{const R=JSON.parse(I),$=st(R.status)?R.status:{};for(const[D,O]of Object.entries($)){const L=st(O)?O:{},z=typeof L.completed=="string"?L.completed:"",F=typeof L.failed=="string"?L.failed:typeof L.error=="string"?L.error:"",H=typeof L.interrupted=="string"?L.interrupted:"",B=z?"completed":F?"failed":H?"interrupted":typeof L.status=="string"?L.status:"running";c.has(D)||c.set(D,{agentId:D,nickname:null,agentPath:null,message:"",model:null,agentType:null,timestamp:T,parentToolCallId:""}),m(D,p,T,{status:B,text:z||F||H||void 0})}}catch{}continue}if(E.type==="custom_tool_call"&&typeof E.call_id=="string"){const M=typeof E.name=="string"?E.name:"tool",I=typeof E.input=="string"?E.input:"",R=E.call_id,$=I?d1(M,I,R,T,t.cwd):[];if(M!=="apply_patch"){const D={id:R,name:M==="exec_command"?"Bash":M,input:Mf(I),result:null,isError:!1,timestamp:T};o.set(D.id,D),Hs(p,D,T)}for(const D of $)o.set(D.id,D),Hs(p,D,T);$.length>0&&a.set(R,{calls:$,direct:M==="apply_patch"});continue}if(E.type==="custom_tool_call_output"&&typeof E.call_id=="string"){const M=E.call_id,{text:I,isError:R}=u1(E.output),$=a.get(M);if($){const O=$.direct&&R?new Set($.calls.map(L=>L.id)):rk(I,R,$.calls);for(const L of $.calls){const z=o.get(L.id);z&&(z.result=I,z.isError=O.has(z.id),o.delete(z.id))}a.delete(M)}const D=o.get(M);D&&(D.result=I,D.isError=R,o.delete(M));continue}}}}}return C(p),{turnStartIndices:y,sessionId:t.sessionId,version:t.version,gitBranch:t.gitBranch,cwd:t.cwd,slug:t.slug,name:"",model:t.model,turns:s,stats:e!=null&&e.skipStats?la(s.length):ca(s),rawMessages:e!=null&&e.skipStats?[]:n,branchedFrom:t.branchedFrom,agentKind:"codex"}}function rd(n,e){const t=n.split(`
|
|
72
|
+
`).map(i=>i.trim()).filter(Boolean).map(od).filter(po),{turnStartIndices:s,...o}=v1(t,e);return o}function _k(n,e){const t=n.rawMessages.map(s=>JSON.stringify(s)).join(`
|
|
73
|
+
`);return rd(t?`${t}
|
|
74
|
+
${e}`:e)}const Tk=new Set(["FINAL_ANSWER","ERROR","FAILED","INTERRUPTED"]);function Ek(n){const e=n.content;return Array.isArray(e)?e.filter(t=>st(t)&&t.type==="input_text"&&typeof t.text=="string").map(t=>t.text).join(`
|
|
75
|
+
`):""}function Zr(n){if(typeof n!="string")return null;try{const e=JSON.parse(n);return st(e)?e:null}catch{return null}}function Pk(n){var c,d;const e=new Map,t=new Set,s=new Map,o=new Map,i=new Set,a=new Map;function l(f,u){t.has(f)||e.set(f,e.get(f)||u)}for(const f of n){const u=st(f.payload)?f.payload:null;if(u){if(f.type==="event_msg"&&u.type==="sub_agent_activity"&&typeof u.agent_thread_id=="string"&&typeof u.agent_path=="string"){const m=u.agent_thread_id,p=typeof u.kind=="string"?u.kind:"started",h=typeof u.event_id=="string"?u.event_id:"",g=s.get(u.agent_path),x=e.has(m)||t.has(m)||g!==void 0||o.has(h);if(p!=="started"&&!x)continue;g&&g!==m&&(e.has(g)&&(l(m,e.get(g)??""),e.delete(g)),t.has(g)&&t.add(m)),s.set(u.agent_path,m),p==="interrupted"?(t.add(m),e.delete(m)):l(m,o.get(h)??"");continue}if(f.type==="response_item"){if(u.type==="function_call"&&typeof u.call_id=="string"){const m=rr(typeof u.name=="string"?u.name:"");if(m==="spawn_agent"){const p=Zr(u.arguments);o.set(u.call_id,typeof(p==null?void 0:p.task_name)=="string"?p.task_name:"")}else if(m==="wait_agent")i.add(u.call_id);else if(m==="interrupt_agent"){const p=Zr(u.arguments),h=[p==null?void 0:p.agent_id,...Array.isArray(p==null?void 0:p.agent_ids)?p.agent_ids:[]].filter(g=>typeof g=="string");a.set(u.call_id,h)}continue}if(u.type==="function_call_output"&&typeof u.call_id=="string"){const m=u.call_id;if(o.has(m)){const p=Zr(u.output),h=typeof(p==null?void 0:p.agent_id)=="string"?p.agent_id:"";if(h){l(h,o.get(m)??"");const g=typeof(p==null?void 0:p.task_name)=="string"?p.task_name:"";g&&!s.has(g)&&s.set(g,h)}}else if(i.has(m)){const p=Zr(u.output),h=st(p==null?void 0:p.status)?p.status:{};for(const[g,x]of Object.entries(h)){const v=st(x)?x:{},w=typeof v.status=="string"?v.status:"";(typeof v.completed=="string"||typeof v.failed=="string"||typeof v.error=="string"||typeof v.interrupted=="string"||w==="completed"||w==="failed"||w==="interrupted")&&(t.add(g),e.delete(g))}}else if(a.has(m))for(const p of a.get(m)??[])t.add(p),e.delete(p);continue}if(u.type==="agent_message"&&typeof u.author=="string"){const p=((d=(c=Ek(u).match(/^Message Type:\s*([^\r\n]+)/))==null?void 0:c[1])==null?void 0:d.trim().toUpperCase())??"";if(!Tk.has(p))continue;const h=s.get(u.author)??u.author;t.add(h),e.delete(h)}}}}return[...e.entries()].filter(([f])=>!t.has(f)).map(([,f])=>f)}function Ak(n){for(let e=n.length-1;e>=0;e--){const t=n[e];if(t.type==="event_msg"){const s=t.payload;switch(s==null?void 0:s.type){case"task_complete":{const o=Pk(n);return o.length>0?{status:"awaiting_agents",pendingQueue:0,pendingAgents:o.length,pendingAgentDescriptions:o.filter(i=>i.length>0)}:{status:"completed"}}case"task_started":return{status:"processing"};case"agent_message":return{status:"thinking"};case"token_count":continue}}if(t.type==="response_item"){const s=t.payload;if(!s)continue;if(s.type==="function_call")return{status:"tool_use",toolName:s.name?rr(s.name):s.name};if(s.type==="message"){if(s.role==="assistant")return{status:"thinking"};if(s.role==="user")return{status:"processing"}}}}return{status:"idle"}}function Rk(n){return v1(n,{skipStats:!0}).turnStartIndices}const Mk=/^(?:assistant|auto_mode|auto_mode_switch|background_tasks|canvas|command|custom|elicitation|exit_plan_mode|extensions|external_tool|factory|hook|managed_settings|mcp|model|pending_messages|permission|sampling|session|skill|subagent|system|tool|ui|user_input)\./;function Tt(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function y1(n){return typeof n.agentId!="string"||n.agentId.length===0}function w1(n){return!Tt(n)||typeof n.type!="string"||!Tt(n.data)?!1:n.type==="abort"||n.type==="binary_asset"||n.type==="user.message"||Mk.test(n.type)}function j1(n){try{const e=JSON.parse(n);return w1(e)?e:null}catch{return null}}function Ik(n){return n.split(`
|
|
76
|
+
`).map(e=>e.trim()).filter(Boolean).map(j1).filter(e=>e!==null)}function ve(...n){return n.find(e=>typeof e=="string")??""}function Dn(n){return typeof n=="number"&&Number.isFinite(n)?n:0}function Do(n){return typeof n.timestamp=="string"?n.timestamp:""}function ss(n,e){var t,s;return typeof n.id=="string"&&n.id?n.id:((s=(t=globalThis.crypto)==null?void 0:t.randomUUID)==null?void 0:s.call(t))??`${e}-${Math.random().toString(36).slice(2,10)}`}function $f(n){const e=ss(n,"copilot-turn"),t=ve(n.data.turnId);return t?`${t}@${e}`:e}function el(n,e){if(!Tt(n))return;const t=ve(n.cwd),s=ve(n.branch);t&&(e.cwd=t),s&&(e.gitBranch=s)}function S1(n){const e={sessionId:"",version:"",gitBranch:"",cwd:"",model:"",slug:"",name:"",firstUserMessage:"",lastUserMessage:"",timestamp:"",lastTimestamp:"",turnCount:0,isSubagent:!1,parentSessionId:null};for(const t of n){if(!y1(t))continue;const{data:s}=t,o=Do(t);if(o&&(e.lastTimestamp=o),t.type==="session.start"){e.sessionId||(e.sessionId=ve(s.sessionId)),e.version||(e.version=ve(s.copilotVersion)||(typeof s.version=="number"?String(s.version):ve(s.version))),el(s.context,e),e.model=ve(s.selectedModel)||e.model;continue}if(t.type==="session.resume"){el(s.context,e),e.model=ve(s.selectedModel)||e.model;continue}if(t.type==="session.context_changed"){el(s,e);continue}if(t.type==="session.auto_mode_resolved"){e.model=ve(s.chosenModel)||e.model;continue}if(t.type==="session.model_change"){e.model=ve(s.newModel)||e.model;continue}if(t.type==="session.title_changed"){e.name=ve(s.title)||e.name;continue}if(t.type==="session.shutdown"){e.model=ve(s.currentModel)||e.model;continue}if((t.type==="assistant.turn_start"||t.type==="assistant.turn_end"||t.type==="assistant.message"||t.type==="assistant.usage"||t.type==="tool.execution_start"||t.type==="tool.execution_complete")&&(e.model=ve(s.model)||e.model),t.type!=="user.message")continue;e.turnCount++,e.timestamp||(e.timestamp=o);const i=ve(s.content).trim();i&&(e.firstUserMessage||(e.firstUserMessage=i),e.lastUserMessage=i)}return e.lastTimestamp||(e.lastTimestamp=e.timestamp),e}function $k(n){for(const e of n.split(`
|
|
77
|
+
`)){const t=e.trim();if(t)try{const s=JSON.parse(t);if(w1(s))return!0}catch{}}return!1}function Ok(n){var e;return Xk((e=n[0])==null?void 0:e.type)}function Dk(n){const e=n.map(t=>j1(t.trim())).filter(t=>t!==null);return S1(e)}function tl(n){if(typeof n=="string")return n;if(n===void 0)return"";try{return JSON.stringify(n)}catch{return String(n)}}function Of(n){return typeof n=="string"?n:Array.isArray(n)?n.flatMap(e=>{const t=typeof e=="string"?e:Tt(e)?ve(e.text,e.content):"";return t?[t]:[]}).join(`
|
|
78
|
+
`):""}function Lk(n){const e=new Map;for(const t of n){if(t.type!=="session.binary_asset"&&t.type!=="binary_asset")continue;const s=ve(t.data.assetId),o=ve(t.data.data),i=ve(t.data.mimeType);s&&o&&i&&e.set(s,{data:o,mimeType:i})}return e}function zk(n,e){if(!Tt(n))return null;const t=e.get(ve(n.assetId)),s=ve(n.mimeType,t==null?void 0:t.mimeType).toLowerCase(),o=ve(n.data,t==null?void 0:t.data);return!s.startsWith("image/")||!o?null:{type:"image",source:{type:"base64",media_type:s,data:o}}}function k1(n,e){if(!Array.isArray(n))return[];const t=[],s=new Set;for(const o of n){const i=zk(o,e);if(!i)continue;const a=`${i.source.media_type}:${i.source.data}`;s.has(a)||(s.add(a),t.push(i))}return t}function Fk(n,e){const t=ve(n.content),s=k1(n.attachments,e);return s.length===0?t:[...s,...t?[{type:"text",text:t}]:[]]}function Bk(n,e){return Tt(n.result)?k1([...Array.isArray(n.result.contents)?n.result.contents:[],...Array.isArray(n.result.binaryResultsForLlm)?n.result.binaryResultsForLlm:[]],e):[]}function ui(n,e){var o,i;if(!n)return{...e};const t=((o=n.output_tokens_details)==null?void 0:o.thinking_tokens)??0,s=((i=e.output_tokens_details)==null?void 0:i.thinking_tokens)??0;return{input_tokens:n.input_tokens+e.input_tokens,output_tokens:n.output_tokens+e.output_tokens,cache_creation_input_tokens:(n.cache_creation_input_tokens??0)+(e.cache_creation_input_tokens??0),cache_read_input_tokens:(n.cache_read_input_tokens??0)+(e.cache_read_input_tokens??0),...t||s?{output_tokens_details:{thinking_tokens:t+s}}:{}}}function Vl(n,e=!1){const t=Dn(n.cacheWriteTokens),s=Dn(n.cacheReadTokens),o=Dn(n.inputTokens),i={input_tokens:e?Math.max(0,o-t-s):o,output_tokens:Dn(n.outputTokens),cache_creation_input_tokens:t,cache_read_input_tokens:s},a=Dn(n.reasoningTokens);return a&&(i.output_tokens_details={thinking_tokens:a}),i.input_tokens===0&&i.output_tokens===0&&i.cache_creation_input_tokens===0&&i.cache_read_input_tokens===0&&a===0?null:i}function Uk(n){if(!Tt(n.modelMetrics))return null;let e=null;for(const t of Object.values(n.modelMetrics)){if(!Tt(t)||!Tt(t.usage))continue;const s=Vl(t.usage,!0);s&&(e=ui(e,s))}return e}function Wk(n){if(typeof n=="string")return{label:n};if(!Tt(n))return null;const e=ve(n.label,n.title,n.value,n.name);if(!e)return null;const t=ve(n.description);return t?{label:e,description:t}:{label:e}}function Hk(n){return Array.isArray(n)?n.map(Wk).filter(e=>e!==null):[]}function Kk(n){if(!Tt(n))return null;const e=ve(n.question,n.prompt,n.text,n.message);if(!e)return null;const t=ve(n.header,n.title),s=typeof n.multiSelect=="boolean"?n.multiSelect:typeof n.multi_select=="boolean"?n.multi_select:void 0;return{question:e,...t?{header:t}:{},options:Hk(n.options??n.choices),...s===void 0?{}:{multiSelect:s}}}function qk(n){const t=(Array.isArray(n.questions)?n.questions:[n]).map(Kk).filter(s=>s!==null);return t.length>0?{...n,questions:t}:n}function Lo(n){switch(n.toLowerCase().replace(/-/g,"_")){case"ask_user":return"AskUserQuestion";case"bash":case"powershell":case"shell":return"Bash";case"create":return"Write";case"edit":return"Edit";default:return n}}function wi(n,e){const t=Tt(e)?e:e===void 0?{}:{value:e};return n==="AskUserQuestion"?qk(t):n==="Edit"?{...t,file_path:ve(t.file_path,t.path),old_string:ve(t.old_string,t.old_str),new_string:ve(t.new_string,t.new_str)}:n==="Write"?{...t,file_path:ve(t.file_path,t.path),content:ve(t.content,t.file_text)}:n==="Bash"&&typeof t.command!="string"&&typeof t.cmd=="string"?{...t,command:t.cmd}:t}function Vk(n){const e=n.error;if(typeof e=="string")return e;if(Tt(e)){const s=ve(e.message,e.code);if(s)return s}const t=n.result;if(typeof t=="string")return t;if(!Tt(t))return t===void 0?"":tl(t);if(typeof t.detailedContent=="string")return t.detailedContent;if(typeof t.content=="string")return t.content;if(Array.isArray(t.contents)){const s=t.contents.flatMap(o=>{const i=typeof o=="string"?o:Tt(o)?ve(o.text,o.content,o.output):"";return i?[i]:[]}).join(`
|
|
79
|
+
`);if(s)return s}return t.structuredContent!==void 0?tl(t.structuredContent):tl(t)}function Df(n,e,t,s){if(!e||n.thinking.some(a=>a.thinking===e))return;const o={type:"thinking",thinking:e,signature:s};n.thinking.push(o);const i=n.contentBlocks[n.contentBlocks.length-1];if((i==null?void 0:i.kind)==="thinking"){i.blocks.push(o);return}n.contentBlocks.push({kind:"thinking",blocks:[o],timestamp:t})}function ei(n,e,t){n.toolCalls.push(e);const s=n.contentBlocks[n.contentBlocks.length-1];if((s==null?void 0:s.kind)==="tool_calls"){s.toolCalls.push(e);return}n.contentBlocks.push({kind:"tool_calls",toolCalls:[e],timestamp:t})}function zo(n,e,t,s){return{id:n,name:e,input:t,result:null,isError:!1,timestamp:s}}function Lf(n,e,t){if(!Array.isArray(n))return[];const s=[];for(const o of n){if(!Tt(o))continue;const i=ve(o.toolCallId),a=ve(o.name);if(!i||!a||t(i))continue;const l=Lo(a);s.push(zo(i,l,wi(l,o.arguments),e))}return s}function zf(n,e,t,s){n.name=e,n.input=wi(e,t),n.timestamp=s||n.timestamp}function Ff(n,e,t){n.result=Vk(e);const s=Bk(e,t);s.length>0&&(n.resultImages=s),n.isError=e.success===!1||e.error!==void 0&&e.error!==null}function Bf(n,e,t,s,o,i){return{id:n,userMessage:t,contentBlocks:[],thinking:[],assistantText:[],toolCalls:[],subAgentActivity:[],timestamp:e,durationMs:null,tokenUsage:null,model:s,...o?{effort:o}:{},...i?{isFragment:!0}:{}}}function Gk(n){return n.userMessage!==null||n.assistantText.length>0||n.thinking.length>0||n.toolCalls.length>0||n.subAgentActivity.length>0}function N1(n,e){const t=Ik(n),s=S1(t),o=Lk(t),i=[],a=new Map,l=new Map,c=new Map,d=new WeakMap,f=new WeakMap;let u=null,m=null,p,h=!1,g=!1,x=null;function v(C,S){S&&d.set(C,S)}function w(C){return u||(u=Bf($f(C),Do(C),null,m,p,!0)),u}function y(){u&&(Gk(u)&&i.push(u),u=null)}function j(C){var I;const S=typeof C.agentId=="string"?C.agentId:"";if(!S)return null;const _=l.get(S);if(_)return _.message;const P=C.data,A=ve(P.toolCallId),E=A?((I=a.get(A))==null?void 0:I.turn)??u:u;if(!E)return null;const T=ve(P.executionMode),M={agentId:S,...A?{parentToolUseId:A}:{},agentName:ve(P.agentDisplayName,P.agentName)||null,subagentType:ve(P.agentType,P.agentName)||null,type:"assistant",content:null,toolCalls:[],thinking:[],text:[],timestamp:Do(C),tokenUsage:null,model:ve(P.model)||null,isBackground:T==="background",...ve(P.description)?{prompt:ve(P.description)}:{},status:"running"};return E.subAgentActivity.push(M),E.contentBlocks.push({kind:M.isBackground?"background_agent":"sub_agent",messages:[M],timestamp:M.timestamp}),l.set(S,{message:M,turn:E}),M}function k(C){if(y1(C))return!1;const S=j(C);if(!S)return!0;const{data:_}=C,P=Do(C);if(C.type==="subagent.started"||C.type==="subagent.configured")return S.parentToolUseId||(S.parentToolUseId=ve(_.toolCallId)||void 0),S.agentName=ve(_.agentDisplayName,_.agentName)||S.agentName,S.subagentType=ve(_.agentType,_.agentName)||S.subagentType,S.model=ve(_.model)||S.model,S.prompt||(S.prompt=ve(_.description)||void 0),S.isBackground||(S.isBackground=ve(_.executionMode)==="background"),S.status="running",!0;if(C.type==="subagent.completed"||C.type==="subagent.failed"){S.agentName=ve(_.agentDisplayName,_.agentName)||S.agentName,S.subagentType=ve(_.agentType,_.agentName)||S.subagentType,S.model=ve(_.model)||S.model,S.durationMs=Dn(_.durationMs)||S.durationMs,S.toolUseCount=Dn(_.totalToolCalls)||S.toolUseCount,S.status=C.type==="subagent.completed"?"completed":"failed";const A=ve(_.error,_.message);return A&&!S.text.includes(A)&&S.text.push(A),!0}if(C.type==="user.message")return S.prompt||(S.prompt=ve(_.content)||void 0),!0;if(C.type==="assistant.reasoning"){const A=ve(_.content);return A&&!S.thinking.includes(A)&&S.thinking.push(A),!0}if(C.type==="assistant.message"){S.model=ve(_.model)||S.model;const A=ve(_.reasoningText);A&&!S.thinking.includes(A)&&S.thinking.push(A);const E=Of(_.content);E&&!S.text.includes(E)&&S.text.push(E);for(const T of Lf(_.toolRequests,P,M=>c.has(M)))S.toolCalls.push(T),c.set(T.id,{call:T,message:S});return!0}if(C.type==="assistant.usage"){S.model=ve(_.model)||S.model;const A=Vl(_);return A&&(S.tokenUsage=ui(S.tokenUsage,A)),!0}if(C.type==="tool.execution_start"){const A=ve(_.toolCallId)||ss(C,"copilot-agent-tool"),E=ve(_.toolName)||"Tool",T=Lo(E),M=c.get(A);if(M)zf(M.call,T,_.arguments,P);else{const I=zo(A,T,wi(T,_.arguments),P);S.toolCalls.push(I),c.set(A,{call:I,message:S})}return!0}if(C.type==="tool.execution_complete"){const A=ve(_.toolCallId)||ss(C,"copilot-agent-tool");let E=c.get(A);if(!E){const T=ve(_.toolName)||"Tool",M=Lo(T),I=zo(A,M,{},P);S.toolCalls.push(I),E={call:I,message:S}}return Ff(E.call,_,o),c.delete(A),!0}return!0}for(const C of t){if(k(C))continue;const{data:S}=C,_=Do(C);if(C.type==="session.start"||C.type==="session.resume"){m=ve(S.selectedModel)||m,p=ve(S.reasoningEffort)||p;continue}if(C.type==="session.auto_mode_resolved"){m=ve(S.chosenModel)||m,u&&(u.model=m);continue}if(C.type==="session.model_change"){m=ve(S.newModel)||m;const P=S.reasoningEffort;typeof P=="string"&&(p=P),u&&(u.model=m,p&&(u.effort=p));continue}if(C.type==="session.shutdown"){m=ve(S.currentModel)||m,u&&!u.model&&(u.model=m),x=Uk(S)??x;const P=Dn(S.totalApiDurationMs);u&&!g&&P&&f.set(u,P);continue}if(C.type==="user.message"){y(),u=Bf($f(C),_,Fk(S,o),m,p,!1),v(u,_);continue}if(C.type==="assistant.turn_start"){m=ve(S.model)||m;const P=w(C);P.model=m,p&&(P.effort=p),v(P,_);continue}if(C.type==="assistant.reasoning"){const P=w(C);Df(P,ve(S.content),_,ve(S.reasoningId)||ss(C,"copilot-thinking")),v(P,_);continue}if(C.type==="assistant.message"){m=ve(S.model)||m;const P=w(C);P.model=m,p&&(P.effort=p),Df(P,ve(S.reasoningText),_,ss(C,"copilot-thinking")),o1(P,Of(S.content),_);for(const A of Lf(S.toolRequests,_,E=>a.has(E)))ei(P,A,_),a.set(A.id,{call:A,turn:P});v(P,_);continue}if(C.type==="assistant.usage"){m=ve(S.model)||m,p=ve(S.reasoningEffort)||p;const P=Vl(S),A=Dn(S.duration);P&&(h=!0),A&&(g=!0);const E=w(C);E.model=m,p&&(E.effort=p),P&&(E.tokenUsage=ui(E.tokenUsage,P)),A&&f.set(E,(f.get(E)??0)+A),v(E,_);continue}if(C.type==="tool.execution_start"){m=ve(S.model)||m;const P=w(C);P.model=m;const A=ve(S.toolCallId)||ss(C,"copilot-tool"),E=ve(S.toolName)||"Tool",T=Lo(E),M=a.get(A);if(M)zf(M.call,T,S.arguments,_);else{const I=zo(A,T,wi(T,S.arguments),_);ei(P,I,_),a.set(A,{call:I,turn:P})}v(P,_);continue}if(C.type==="tool.execution_complete"){m=ve(S.model)||m;const P=ve(S.toolCallId)||ss(C,"copilot-tool");let A=a.get(P);if(!A){const E=w(C),T=ve(S.toolName)||"Tool",M=Lo(T),I=zo(P,M,{},_);ei(E,I,_),A={call:I,turn:E}}Ff(A.call,S,o),a.delete(P),v(A.turn,_);continue}if(C.type==="session.error"){const P=w(C),E={errorType:ve(S.errorType)||"unknown"};typeof S.statusCode=="number"&&(E.statusCode=S.statusCode),typeof S.errorCode=="string"&&(E.errorCode=S.errorCode),ei(P,{id:ss(C,"copilot-error"),name:"Error",input:E,result:ve(S.message)||"Copilot session error",isError:!0,timestamp:_},_),v(P,_);continue}(C.type==="assistant.turn_end"||C.type==="assistant.idle"||C.type==="session.idle")&&u&&v(u,_)}if(y(),!h&&x&&i.length===1&&(i[0].tokenUsage=ui(i[0].tokenUsage,x)),s.model)for(const C of i)C.model||(C.model=s.model);for(const C of i){const S=d.get(C),_=Date.parse(C.timestamp),P=S?Date.parse(S):Number.NaN;if(Number.isFinite(_)&&Number.isFinite(P)&&P>=_)C.durationMs=P-_;else{const A=f.get(C)??0;A&&(C.durationMs=A)}}const N=e!=null&&e.skipStats?la(i.length):ca(i);return!(e!=null&&e.skipStats)&&!h&&x&&i.length>1&&(N.totalInputTokens=x.input_tokens,N.totalOutputTokens=x.output_tokens,N.totalCacheCreationTokens=x.cache_creation_input_tokens??0,N.totalCacheReadTokens=x.cache_read_input_tokens??0),{sessionId:s.sessionId,version:s.version,gitBranch:s.gitBranch,cwd:s.cwd,slug:s.slug,name:s.name,model:s.model,turns:i,stats:N,rawMessages:e!=null&&e.skipStats?[]:t,agentKind:"copilot"}}function Yk(n,e){const t=n.rawMessages.map(s=>JSON.stringify(s)).join(`
|
|
80
|
+
`);return N1(t?`${t}
|
|
81
|
+
${e}`:e)}function Xk(n){return typeof n=="string"&&(n==="abort"||n==="binary_asset"||n==="user.message"||n.startsWith("assistant.")||n.startsWith("permission.")||n.startsWith("session.")||n.startsWith("subagent.")||n.startsWith("tool.")||n.startsWith("user_input."))}function Jk(n){const e=new Map;for(const o of n){const i=typeof o.agentId=="string"?o.agentId:"";if(!i&&(o.type==="abort"||o.type==="session.shutdown"||o.type==="session.error")){e.clear();continue}if(!i||!o.type.startsWith("subagent."))continue;const a=Tt(o.data)?o.data:{};if(o.type==="subagent.completed"||o.type==="subagent.failed"){e.delete(i);continue}if(o.type==="subagent.started"||o.type==="subagent.configured"){const l=[a.agentDisplayName,a.description,a.agentName].find(c=>typeof c=="string")??"";e.set(i,l||e.get(i)||"")}}if(e.size>0){const o=[...e.values()];return{status:"awaiting_agents",pendingQueue:0,pendingAgents:o.length,pendingAgentDescriptions:o.filter(i=>i.length>0)}}let t=!1;const s=new Set;for(let o=n.length-1;o>=0;o--){const i=n[o];if(typeof i.agentId=="string"&&i.agentId)continue;const a=Tt(i.data)?i.data:{};switch(i.type){case"abort":case"session.shutdown":return{status:"completed"};case"assistant.turn_end":{for(let l=o-1;l>=0;l--){const c=n[l];if(typeof c.agentId=="string"&&c.agentId)continue;if(c.type==="user.message")break;if(c.type==="abort")return{status:"completed"};if(c.type!=="assistant.message")continue;const d=Tt(c.data)?c.data:{};return Array.isArray(d.toolRequests)&&d.toolRequests.length>0?{status:"processing"}:{status:"completed"}}return{status:"processing"}}case"session.error":return{status:"completed",terminalReason:typeof a.message=="string"?a.message:"Copilot session error"};case"assistant.idle":case"session.idle":return{status:t?"completed":"idle"};case"permission.completed":{const l=typeof a.requestId=="string"?a.requestId:"";l&&s.add(l);continue}case"permission.requested":{const l=typeof a.requestId=="string"?a.requestId:"";if(l&&s.has(l))continue;return{status:"deferred"}}case"user_input.requested":return{status:"tool_use",toolName:"AskUserQuestion"};case"tool.execution_start":return s.size>0?{status:"thinking"}:{status:"tool_use",toolName:typeof a.toolName=="string"?rr(a.toolName):typeof a.name=="string"?rr(a.name):void 0};case"tool.execution_complete":return{status:"thinking"};case"assistant.turn_start":return{status:"processing"};case"assistant.message":case"assistant.message_delta":case"assistant.reasoning":case"assistant.reasoning_delta":return{status:"thinking"};case"user.message":return t=!0,{status:"processing"};case"session.start":case"session.resume":return{status:t?"processing":"idle"}}}return{status:"idle"}}function Qk(n){const e=[];for(let t=0;t<n.length;t++){const s=n[t];if(s.type!=="user.message"||typeof s.agentId=="string")continue;const o=s.data;!o||typeof o!="object"||Array.isArray(o)||typeof s.id!="string"||!s.id||e.push(t)}return e}const C1=Is[Is.length-1],Zk={kind:"codex",descriptor:An("codex"),detectsText:b1,detectsRecords:Nk,parse:rd,append:_k,metadataFromLines:Ck,status:Ak,turnBoundaries:Rk},eN={kind:"copilot",descriptor:An("copilot"),detectsText:$k,detectsRecords:Ok,parse:N1,append:Yk,metadataFromLines:Dk,status:Jk,turnBoundaries:Qk},tN={kind:"claude",descriptor:An("claude"),detectsText:_f,detectsRecords:_f,parse:K4,append:q4,metadataFromLines:H4,status:Q4,turnBoundaries:Z4},nN=Object.freeze({claude:tN,codex:Zk,copilot:eN});function sN(n){function e(t){for(const s of Is){const o=n[s];if(t(o))return o}return n[C1]}return{formatFor:t=>n[t],formatForText:t=>e(s=>s.detectsText(t)),formatForRecords:t=>e(s=>s.detectsRecords(t))}}const id=sN(nN);function _1(n){return id.formatFor(n)}function T1(n){return id.formatForText(n)}function E1(n){return id.formatForRecords(n)}function P1(n,e){const t=e.map(s=>{try{const o=JSON.parse(s);return o&&typeof o=="object"&&!Array.isArray(o)?o:{}}catch{return{}}});return n.turnBoundaries(t)}function A1(n,e,t){return P1(n,e)[t]??e.length}function oN(n,e,t){let s=-1;for(let o=0;o<e.length;o++)if(e[o].includes(t))try{const i=JSON.parse(e[o]);if((i==null?void 0:i.uuid)===t){s=o;break}}catch{}return s<0?null:P1(n,e).find(o=>o>s)??"keep-all"}function rN(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 iN(n,e){const t=n.contentBlocks,s=t.findIndex(o=>o.kind==="tool_calls"&&o.toolCalls.some(i=>i.id===e));return s===-1?!1:t.slice(s+1).some(o=>o.kind==="text"||o.kind==="thinking"||o.kind==="tool_calls")}function R1(n){const{turns:e}=n;if(e.length===0)return null;const t=e[e.length-1];if(!t||t.toolCalls.length===0)return null;const s=t.toolCalls[t.toolCalls.length-1];if(!s)return null;const{name:o}=s;if(o!=="ExitPlanMode"&&o!=="AskUserQuestion"||s.result!==null&&!s.isError||rN(e,o)||s.isError&&iN(t,s.id))return null;const i=s.input;if(o==="ExitPlanMode")return{type:"plan",allowedPrompts:i.allowedPrompts};const a=i.questions;return a&&a.length>0?{type:"question",toolUseId:s.id,questions:a}:null}function aN(n){return typeof n=="string"?n:n.filter(e=>e.type==="text").map(e=>e.text).join(`
|
|
82
|
+
`)}function ma(n,e){return T1(n).parse(n,e)}function lN(n,e){const t=E1(n.rawMessages);return(t.kind===C1?T1(e):t).append(n,e)}function pa(n){return n===null?"":typeof n=="string"?n:aN(n)}function M1(n){return n===null||typeof n=="string"?[]:n.filter(e=>e.type==="image")}const I1=b.createContext(null);function cN(n){const e=[];for(let t=0;t<n.length;t+=1){const s=n[t],o=M1(s.userMessage);for(let i=0;i<o.length;i+=1){const a=o[i];e.push({id:`${s.id}:attachment:${i}`,src:`data:${a.source.media_type};base64,${a.source.data}`,alt:`Attachment ${i+1} from turn ${t+1}`,label:`Turn ${t+1} · Image ${i+1}`})}}return e}function dN(n){const e=U.c(10),{images:t,children:s}=n,[o,i]=b.useState(null);let a;e[0]!==t?(a=m=>{const p=t.findIndex(g=>g.src===m.src),h=p>=0?t:[...t,{...m,id:m.id??`supplemental-image-${t.length}`}];i(g=>({key:((g==null?void 0:g.key)??0)+1,open:!0,images:h,index:p>=0?p:h.length-1}))},e[0]=t,e[1]=a):a=e[1];const l=a;let c;e[2]!==l?(c={openImage:l},e[2]=l,e[3]=c):c=e[3];const d=c;let f;e[4]!==o?(f=o&&r.jsx(Jc,{open:o.open,images:o.images,initialIndex:o.index,onClose:()=>i(uN),onCloseComplete:()=>i(null)},o.key),e[4]=o,e[5]=f):f=e[5];let u;return e[6]!==s||e[7]!==f||e[8]!==d?(u=r.jsxs(I1.Provider,{value:d,children:[s,f]}),e[6]=s,e[7]=f,e[8]=d,e[9]=u):u=e[9],u}function uN(n){return n?{...n,open:!1}:null}function fN(n){const e=U.c(7),{children:t}=n,{session:s}=it();s==null||s.turns;let o;e[0]!==(s==null?void 0:s.turns)?(o=(s==null?void 0:s.turns)??[],e[0]=s==null?void 0:s.turns,e[1]=o):o=e[1];let i;e[2]!==o?(i=cN(o),e[2]=o,e[3]=i):i=e[3];const a=i;let l;return e[4]!==t||e[5]!==a?(l=r.jsx(dN,{images:a,children:t}),e[4]=t,e[5]=a,e[6]=l):l=e[6],l}function $1(){return b.useContext(I1)}const O1=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp",".ico",".avif"]);function mN(n){if(!n)return!1;const e=n.lastIndexOf(".");return e===-1?!1:O1.has(n.slice(e).toLowerCase())}function ad(n){return!n||n.startsWith("http://")||n.startsWith("https://")||n.startsWith("data:")||!n.startsWith("/")?!1:mN(n)}function pN(n){return n&&(ad(n)?vr(`/api/local-file?path=${encodeURIComponent(n)}`):n)}function Gl(n){const e=U.c(41),{src:t,alt:s,id:o,className:i,thumbnailClassName:a}=n,l=o===void 0?"markdown-image":o,c=vn("hostFiles"),[d,f]=b.useState(!1),[u,m]=b.useState(!1),[p,h]=b.useState(),g=$1();let x;e[0]!==c||e[1]!==t?(x=ad(t)&&!c,e[0]=c,e[1]=t,e[2]=x):x=e[2];const v=x;let w;e[3]!==v||e[4]!==t?(w=v?void 0:pN(t),e[3]=v,e[4]=t,e[5]=w):w=e[5];const y=w;let j;e[6]!==s||e[7]!==l||e[8]!==y?(j=y?{id:l,src:y,alt:s??"Rendered image",label:s||"Rendered image"}:null,e[6]=s,e[7]=l,e[8]=y,e[9]=j):j=e[9];const k=j;let N;e[10]!==g||e[11]!==k?(N=()=>{k&&(g?g.openImage(k):(m(!0),f(!0)))},e[10]=g,e[11]=k,e[12]=N):N=e[12];const C=N;if(v){let D;return e[13]!==s?(D=s?r.jsx("span",{className:"text-muted-foreground",children:s}):null,e[13]=s,e[14]=D):D=e[14],D}if(y&&p===y){const D=s?`: ${s}`:"";let O;return e[15]!==D?(O=r.jsxs("span",{role:"status",className:"my-3 block text-xs text-muted-foreground",children:["Image unavailable",D]}),e[15]=D,e[16]=O):O=e[16],O}const S=`Open ${s||"rendered image"}`;let _;e[17]!==i?(_=G("group/image relative my-3 block h-auto max-w-full overflow-hidden rounded-lg border border-border bg-background p-1 transition-colors hover:bg-muted focus-visible:ring-ring/40",i),e[17]=i,e[18]=_):_=e[18];const P=s??"";let A;e[19]!==y?(A=()=>h(y),e[19]=y,e[20]=A):A=e[20];let E;e[21]!==a?(E=G("max-h-96 max-w-full rounded-lg object-contain",a),e[21]=a,e[22]=E):E=e[22];let T;e[23]!==y||e[24]!==E||e[25]!==P||e[26]!==A?(T=r.jsx("img",{src:y,alt:P,loading:"lazy",decoding:"async",onError:A,className:E}),e[23]=y,e[24]=E,e[25]=P,e[26]=A,e[27]=T):T=e[27];let M;e[28]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx("span",{className:"absolute right-2 top-2 flex size-7 items-center justify-center rounded-md border border-white/10 bg-black/45 text-white/70 opacity-80 backdrop-blur transition-[color,background-color,opacity] group-hover/image:bg-black/65 group-hover/image:text-white sm:opacity-0 sm:group-hover/image:opacity-100 sm:group-focus-visible/image:opacity-100",children:r.jsx(Ui,{className:"size-3.5","data-icon":"icon"})}),e[28]=M):M=e[28];let I;e[29]!==C||e[30]!==T||e[31]!==S||e[32]!==_?(I=r.jsxs(X,{type:"button",variant:"ghost",onClick:C,"aria-label":S,className:_,children:[T,M]}),e[29]=C,e[30]=T,e[31]=S,e[32]=_,e[33]=I):I=e[33];let R;e[34]!==d||e[35]!==u||e[36]!==k?(R=u&&k&&r.jsx(Jc,{open:d,images:[k],initialIndex:0,onClose:()=>f(!1),onCloseComplete:()=>m(!1)}),e[34]=d,e[35]=u,e[36]=k,e[37]=R):R=e[37];let $;return e[38]!==I||e[39]!==R?($=r.jsxs(r.Fragment,{children:[I,R]}),e[38]=I,e[39]=R,e[40]=$):$=e[40],$}function hN(n){const e=U.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 o;e[3]!==t?(o=G("w-full caption-bottom text-sm",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:r.jsx("table",{"data-slot":"table",className:o,...s})}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function gN(n){const e=U.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 o;e[3]!==t?(o=G("[&_tr]:border-b",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("thead",{"data-slot":"table-header",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function xN(n){const e=U.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 o;e[3]!==t?(o=G("[&_tr:last-child]:border-0",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("tbody",{"data-slot":"table-body",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function bN(n){const e=U.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 o;e[3]!==t?(o=G("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("tr",{"data-slot":"table-row",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function vN(n){const e=U.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 o;e[3]!==t?(o=G("h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("th",{"data-slot":"table-head",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function yN(n){const e=U.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 o;e[3]!==t?(o=G("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("td",{"data-slot":"table-cell",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function wN(n){if(!n)return null;let e=n;if(e.toLowerCase().startsWith("file://"))try{const l=new URL(e);e=`${l.pathname}${l.hash}`}catch{return null}const t=e.startsWith("/")&&!e.startsWith("//"),s=/^\/?[a-z]:[\\/]/i.test(e);if(!t&&!s)return null;let o,i;const a=e.match(/#L(\d+)(?:C(\d+))?$/i);if(a)o=Number(a[1]),i=a[2]?Number(a[2]):void 0,e=e.slice(0,-a[0].length);else{const l=e.match(/:(\d+)(?::(\d+))?$/);l&&(o=Number(l[1]),i=l[2]?Number(l[2]):void 0,e=e.slice(0,-l[0].length))}try{e=decodeURIComponent(e)}catch{return null}return/^\/[a-z]:[\\/]/i.test(e)&&(e=e.slice(1)),{path:e,line:o,column:i}}function jN(n){const e=U.c(17);let t,s,o;e[0]!==n?({href:s,children:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=vn("hostFiles");let a;e[4]!==s?(a=wN(s),e[4]=s,e[5]=a):a=e[5];const l=a;if(l&&!i){let u;return e[6]!==t||e[7]!==s?(u=r.jsx("span",{className:"text-muted-foreground",title:s,children:t}),e[6]=t,e[7]=s,e[8]=u):u=e[8],u}let c;e[9]!==l||e[10]!==s?(c=u=>{s&&(u.preventDefault(),l?bi(l.path,{line:l.line,column:l.column}):window.open(s,"_blank","noopener,noreferrer"))},e[9]=l,e[10]=s,e[11]=c):c=e[11];const d=c;let f;return e[12]!==t||e[13]!==d||e[14]!==s||e[15]!==o?(f=r.jsx("a",{href:s,onClick:d,className:"text-primary underline decoration-primary/30 hover:decoration-primary/60 cursor-pointer transition-colors",title:s,...o,children:t}),e[12]=t,e[13]=d,e[14]=s,e[15]=o,e[16]=f):f=e[16],f}const SN=[...O1].map(n=>n.slice(1)).join("|"),kN=new RegExp(`^([ \\t]*)(\\/[^\\s]+\\.(?:${SN}))[ \\t]*$`,"gim");function D1(n){return n.replace(kN,(e,t,s)=>`${t}`)}const $n={code:ZS,pre({children:n}){return r.jsx(r.Fragment,{children:n})},a:jN,h1({children:n}){return r.jsx("h1",{className:"text-xl font-semibold mt-6 mb-3 pb-2 border-b border-border/40 text-foreground first:mt-0",children:n})},h2({children:n}){return r.jsx("h2",{className:"text-lg font-semibold mt-5 mb-2 pb-1.5 border-b border-border/30 text-foreground first:mt-0",children:n})},h3({children:n}){return r.jsx("h3",{className:"text-base font-semibold mt-4 mb-2 text-foreground first:mt-0",children:n})},h4({children:n}){return r.jsx("h4",{className:"text-sm font-semibold mt-3 mb-1.5 text-foreground first:mt-0",children:n})},h5({children:n}){return r.jsx("h5",{className:"text-sm font-medium mt-3 mb-1 text-foreground first:mt-0",children:n})},h6({children:n}){return r.jsx("h6",{className:"text-xs font-medium mt-3 mb-1 text-muted-foreground first:mt-0",children:n})},p({children:n}){return r.jsx("p",{className:"my-1.5 leading-[1.55] text-foreground/90 first:mt-0 last:mb-0 md:my-2 md:leading-relaxed",children:n})},blockquote({children:n}){return r.jsx("blockquote",{className:"my-2 rounded-r-md border-l-2 border-border bg-muted/30 py-1.5 pl-3 pr-2.5 text-foreground/80 [&>p]:my-1 md:my-3 md:py-2 md:pl-4 md:pr-3",children:n})},ul({children:n}){return r.jsx("ul",{className:"my-1.5 flex list-disc flex-col gap-0.5 pl-5 marker:text-muted-foreground/50 [&_ol]:my-1 [&_ul]:my-1 md:my-2 md:gap-1 md:pl-6",children:n})},ol({children:n}){return r.jsx("ol",{className:"my-1.5 flex list-decimal flex-col gap-0.5 pl-5 marker:text-muted-foreground/50 [&_ol]:my-1 [&_ul]:my-1 md:my-2 md:gap-1 md:pl-6",children:n})},li({children:n}){return r.jsx("li",{className:"pl-1 leading-[1.55] text-foreground/90 md:leading-relaxed",children:n})},hr(){return r.jsx(It,{className:"my-4"})},table({children:n}){return r.jsx("div",{className:"my-3 overflow-x-auto rounded-lg border border-border/40",children:r.jsx(hN,{className:"border-collapse text-sm",children:n})})},thead({children:n}){return r.jsx(gN,{className:"bg-muted/50",children:n})},tbody({children:n}){return r.jsx(xN,{children:n})},tr({children:n}){return r.jsx(bN,{className:"even:bg-muted/20",children:n})},th({children:n}){return r.jsx(vN,{className:"h-9 px-3 py-2 text-xs font-medium text-muted-foreground",children:n})},td({children:n}){return r.jsx(yN,{className:"px-3 py-2 text-foreground/90",children:n})},strong({children:n}){return r.jsx("strong",{className:"font-semibold text-foreground",children:n})},em({children:n}){return r.jsx("em",{className:"italic text-foreground/90",children:n})},del({children:n}){return r.jsx("del",{className:"line-through text-muted-foreground",children:n})},img:Gl,input({checked:n,...e}){return r.jsx("input",{type:"checkbox",checked:n,readOnly:!0,className:"mr-2 rounded border-border accent-primary",...e})}},Bs=[Gi],NN=["system-reminder","local-command-caveat","command-name","command-message","command-args","env","claude_background_info","fast_mode_info","gitStatus","user-prompt-submit-hook"],CN=NN.join("|");function L1(){return new RegExp(`<(${CN})[^>]*>[\\s\\S]*?<\\/\\1>`,"g")}function ld(n){return n.replace(L1(),"").trim()}function _N(n){return L1().test(n)}const TN=/<command-message>([^<]+)<\/command-message>/,EN=/<command-name>([\s\S]*?)<\/command-name>/,PN=/<command-args>([\s\S]*?)<\/command-args>/;function z1(n){const e=n.match(TN);if(e)return e[1];const t=n.match(EN);return t?t[1].trim().replace(/^\//,""):null}function F1(n){const e=n.match(PN);if(!e)return null;const t=e[1].trim();return t.length>0?t:null}const B1={"local-command-stdout":"stdout","local-command-stderr":"stderr","bash-input":"input","bash-stdout":"stdout","bash-stderr":"stderr"},AN=new RegExp(`<(${Object.keys(B1).join("|")})>([\\s\\S]*?)<\\/\\1>`,"g");function RN(n){const e=[],t=n.replace(AN,(s,o,i)=>(e.push({text:cg(i).trim(),stream:B1[o]}),"")).trim();return{outputs:e,remainingText:t}}const MN=/<task-notification>([\s\S]*?)<\/task-notification>/g;function Ks(n,e){const t=n.match(new RegExp(`<${e}>([\\s\\S]*?)<\\/${e}>`));return t?t[1].trim():""}function ir(n){const e=[],t=n.replace(MN,(s,o)=>(e.push({taskId:Ks(o,"task-id"),toolUseId:Ks(o,"tool-use-id"),outputFile:Ks(o,"output-file"),status:Ks(o,"status"),summary:Ks(o,"summary"),result:Ks(o,"result")}),"")).trim();return{notifications:e,remainingText:t}}const IN=/\[Request interrupted by user[^\]]*\]/g;function U1(n){const e=[],t=n.replace(IN,s=>(e.push(s),"")).trim();return{interrupts:e,remainingText:t}}const Uf="[SYSTEM NOTIFICATION - NOT USER INPUT]";function W1(n){const e=n.indexOf(Uf);if(e===-1)return{text:n,isSystemNotification:!1};const t=e+Uf.length,s=n.indexOf(`
|
|
83
|
+
|
|
84
|
+
`,t),o=s===-1?t:s+2;return{text:(n.slice(0,e)+n.slice(o)).trim(),isSystemNotification:!0}}const Wf={Icon:aS,color:"text-destructive",bg:"border-destructive/20 bg-destructive/5",badgeVariant:"destructive"},Hf={completed:{Icon:iS,color:"text-success",bg:"border-success/20 bg-success/5",badgeVariant:"secondary",label:"Completed"},failed:{...Wf,label:"Failed"},error:{...Wf,label:"Error"},running:{Icon:lS,color:"text-warning",bg:"border-warning/20 bg-warning/5",badgeVariant:"outline",label:"Running"}};function H1(n){const e=U.c(32),{notification:t}=n,[s,o]=b.useState(!1),i=Hf[t.status]??Hf.running,{Icon:a}=i,l=t.result.length>0||t.outputFile.length>0,c=s?nt:Ze;let d;e[0]!==i.bg?(d=G("my-1 rounded-lg border p-3",i.bg),e[0]=i.bg,e[1]=d):d=e[1];let f;e[2]!==i.color?(f=G("mt-0.5 size-4 shrink-0",i.color),e[2]=i.color,e[3]=f):f=e[3];let u;e[4]!==a||e[5]!==f?(u=r.jsx(a,{className:f}),e[4]=a,e[5]=f,e[6]=u):u=e[6];let m;e[7]!==t.summary?(m=r.jsx("span",{className:"text-sm font-medium text-foreground",children:t.summary}),e[7]=t.summary,e[8]=m):m=e[8];let p;e[9]!==i.badgeVariant||e[10]!==i.color||e[11]!==i.label?(p=r.jsx(Me,{variant:i.badgeVariant,className:i.color,children:i.label}),e[9]=i.badgeVariant,e[10]=i.color,e[11]=i.label,e[12]=p):p=e[12];let h;e[13]!==m||e[14]!==p?(h=r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[m,p]}),e[13]=m,e[14]=p,e[15]=h):h=e[15];let g;e[16]!==c||e[17]!==s||e[18]!==l||e[19]!==t.outputFile||e[20]!==t.result?(g=l&&r.jsxs(r.Fragment,{children:[r.jsxs(an,{render:r.jsx(X,{type:"button",variant:"ghost",size:"xs",className:"mt-1.5 -ml-2 text-muted-foreground"}),children:[r.jsx(c,{"data-icon":"inline-start"}),s?"Hide detail":"Show detail"]}),r.jsx(Nt,{children:r.jsxs("div",{className:"mt-2 border-t border-border/30 pt-2 text-sm text-foreground/90",children:[t.result&&r.jsx(Pn,{components:$n,remarkPlugins:Bs,children:t.result}),t.outputFile&&r.jsxs("div",{className:"mt-2",children:[r.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Output file"}),r.jsx("div",{className:"mt-1 select-all break-all rounded bg-muted px-2 py-1 font-mono text-xs text-muted-foreground",children:t.outputFile})]})]})})]}),e[16]=c,e[17]=s,e[18]=l,e[19]=t.outputFile,e[20]=t.result,e[21]=g):g=e[21];let x;e[22]!==h||e[23]!==g?(x=r.jsxs("div",{className:"min-w-0 flex-1",children:[h,g]}),e[22]=h,e[23]=g,e[24]=x):x=e[24];let v;e[25]!==u||e[26]!==x?(v=r.jsxs("div",{className:"flex items-start gap-2",children:[u,x]}),e[25]=u,e[26]=x,e[27]=v):v=e[27];let w;return e[28]!==s||e[29]!==d||e[30]!==v?(w=r.jsx(kt,{open:s,onOpenChange:o,className:d,children:v}),e[28]=s,e[29]=d,e[30]=v,e[31]=w):w=e[31],w}function $N(n){const e=U.c(7),{content:t}=n;let s,o,i;if(e[0]!==t){i=Symbol.for("react.early_return_sentinel");e:{const{notifications:l}=ir(t);if(l.length===0){i=null;break e}s="flex flex-col",o=l.map(ON)}e[0]=t,e[1]=s,e[2]=o,e[3]=i}else s=e[1],o=e[2],i=e[3];if(i!==Symbol.for("react.early_return_sentinel"))return i;let a;return e[4]!==s||e[5]!==o?(a=r.jsx("div",{className:s,children:o}),e[4]=s,e[5]=o,e[6]=a):a=e[6],a}function ON(n,e){return r.jsx(H1,{notification:n},n.taskId||`notification-${e}`)}function DN(n){const e=U.c(15),{output:t}=n,s=t.stream==="stderr",o=t.stream==="input",i=s&&"border-destructive/20 bg-destructive/5 text-destructive",a=o&&"border-border bg-muted/50 text-foreground",l=!s&&!o&&"border-border bg-muted/40 text-muted-foreground";let c;e[0]!==i||e[1]!==a||e[2]!==l?(c=G("rounded-md border px-3 py-2 my-1 font-mono text-xs",i,a,l),e[0]=i,e[1]=a,e[2]=l,e[3]=c):c=e[3];let d;e[4]!==s||e[5]!==o?(d=o?r.jsx(Ze,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}):r.jsx(co,{className:G("size-3 shrink-0",s?"text-destructive":"text-muted-foreground"),"data-icon":"inline-start"}),e[4]=s,e[5]=o,e[6]=d):d=e[6];let f;e[7]!==t.text?(f=r.jsx("span",{className:"whitespace-pre-wrap break-words",children:t.text}),e[7]=t.text,e[8]=f):f=e[8];let u;e[9]!==d||e[10]!==f?(u=r.jsxs("div",{className:"flex items-center gap-1.5",children:[d,f]}),e[9]=d,e[10]=f,e[11]=u):u=e[11];let m;return e[12]!==c||e[13]!==u?(m=r.jsx("div",{className:c,children:u}),e[12]=c,e[13]=u,e[14]=m):m=e[14],m}function LN(n){const e=U.c(6),{loading:t,content:s}=n;let o;if(t){let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground/60 font-mono",children:[r.jsx(dg,{className:"w-3 h-3 text-muted-foreground/60"})," Loading..."]}),e[0]=a):a=e[0],o=a}else if(s){let a;e[1]!==s?(a=r.jsx(Pn,{components:$n,remarkPlugins:Bs,children:s}),e[1]=s,e[2]=a):a=e[2],o=a}else{let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("span",{className:"text-muted-foreground/60 font-mono",children:"Could not load command content"}),e[3]=a):a=e[3],o=a}let i;return e[4]!==o?(i=r.jsx("div",{className:"mt-2 max-h-80 overflow-auto rounded-md border border-border bg-muted/40 p-3 text-xs text-muted-foreground",children:o}),e[4]=o,e[5]=i):i=e[5],i}const cd=b.memo(function({content:e,timestamp:t,onEditCommand:s,onExpandCommand:o,compact:i=!1}){const a=$1(),[l,c]=b.useState(!1),[d,f]=b.useState(!1),[u,m]=b.useState(!1),[p,h]=b.useState(null),[g,x]=b.useState(!1),[v,w]=b.useState(null),y=b.useMemo(()=>pa(e),[e]),j=b.useMemo(()=>z1(y),[y]),k=b.useMemo(()=>F1(y),[y]),{sender:N,body:C,matched:S}=b.useMemo(()=>or(y),[y]),_=b.useMemo(()=>ld(C),[C]),{text:P,isSystemNotification:A}=b.useMemo(()=>W1(_),[_]),{notifications:E,remainingText:T}=b.useMemo(()=>ir(P),[P]),{outputs:M,remainingText:I}=b.useMemo(()=>RN(T),[T]),{interrupts:R,remainingText:$}=b.useMemo(()=>U1(I),[I]),D=b.useCallback(async V=>{if(!V){m(!1);return}if(p!==null){m(!0);return}if(!(!o||!j)){x(!0),m(!0);try{const Y=await o(j,k??void 0);h(Y)}finally{x(!1)}}},[p,o,j,k]),O=b.useMemo(()=>M1(e),[e]),L=b.useMemo(()=>O.map(V=>`data:${V.source.media_type};base64,${V.source.data}`),[O]),z=b.useMemo(()=>L.map((V,Y)=>({id:`message-attachment-${Y}`,src:V,alt:`Attachment ${Y+1}`,label:L.length>1?`Attachment ${Y+1}`:"Attached image"})),[L]),F=b.useMemo(()=>_N(y)||A||S,[y,A,S]),H=d?y:$,W=H.length>500&&!l?H.slice(0,500)+"...":H,K=V=>{const Y=z[V];Y&&(a?a.openImage(Y):w({index:V,open:!0}))};return r.jsxs("div",{className:"group",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"flex items-center gap-2 mb-1",children:F&&r.jsx(X,{type:"button",variant:"ghost",size:"xs",onClick:()=>f(!d),className:"-ml-2 text-muted-foreground",children:d?r.jsxs(r.Fragment,{children:[r.jsx(Wi,{"data-icon":"inline-start"})," Hide raw"]}):r.jsxs(r.Fragment,{children:[r.jsx(vo,{"data-icon":"inline-start"})," Show raw"]})})}),!d&&A&&r.jsx("div",{className:"mb-2",children:r.jsxs(Me,{variant:"outline",className:"text-muted-foreground",children:[r.jsx(co,{"data-icon":"inline-start"}),"System event"]})}),!d&&S&&r.jsx("div",{className:"mb-2",children:r.jsxs(Me,{variant:"outline",className:"text-muted-foreground",children:[r.jsx(Wn,{"data-icon":"inline-start"}),N?`From ${N}`:"Teammate message"]})}),j&&r.jsxs(kt,{open:u,onOpenChange:V=>void D(V),className:"mb-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(Me,{variant:"outline",className:"font-mono text-foreground",children:[r.jsx(co,{"data-icon":"inline-start"}),"/",j,k&&r.jsx("span",{className:"text-muted-foreground",children:k})]}),o&&r.jsxs(an,{render:r.jsx(X,{type:"button",variant:"ghost",size:"xs",className:"text-muted-foreground"}),children:[u?r.jsx(nt,{"data-icon":"inline-start"}):r.jsx(Ze,{"data-icon":"inline-start"}),u?"Collapse":"Expand"]}),u&&s&&r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:()=>s(j),className:"text-muted-foreground",children:[r.jsx(Ls,{"data-icon":"inline-start"}),"Edit"]})]}),r.jsx(Nt,{children:r.jsx(LN,{loading:g,content:p})})]}),L.length>0&&r.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:L.map((V,Y)=>r.jsxs(X,{type:"button",variant:"ghost",onClick:()=>K(Y),"aria-label":`Open attached image ${Y+1}`,className:G("group/image relative h-auto max-w-full overflow-hidden rounded-lg border border-border bg-background p-1 text-left","transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40"),children:[r.jsx("img",{src:V,alt:`Attachment ${Y+1}`,loading:"lazy",decoding:"async",className:"max-h-64 max-w-full rounded-lg object-contain sm:max-w-md"}),r.jsx("span",{className:"absolute right-2 top-2 flex size-7 items-center justify-center rounded-md border border-white/10 bg-black/45 text-white/70 opacity-80 backdrop-blur transition-[color,background-color,opacity] group-hover/image:bg-black/65 group-hover/image:text-white sm:opacity-0 sm:group-hover/image:opacity-100 sm:group-focus-visible/image:opacity-100",children:r.jsx(Ui,{className:"size-3.5","data-icon":"icon"})}),L.length>1&&r.jsxs("span",{className:"absolute bottom-2 right-2 rounded-md bg-black/55 px-1.5 py-0.5 font-mono text-xs text-white/80",children:[Y+1," / ",L.length]})]},`${O[Y].source.media_type}-${O[Y].source.data.slice(0,24)}-${Y}`))}),!d&&E.length>0&&r.jsx("div",{className:"mb-2 flex flex-col gap-2",children:E.map(V=>r.jsx(H1,{notification:V},V.taskId))}),!d&&M.length>0&&r.jsx("div",{className:"mb-2 flex flex-col gap-1",children:M.map((V,Y)=>r.jsx(DN,{output:V},Y))}),!d&&R.length>0&&r.jsx("div",{className:"mb-2 flex flex-col gap-1",children:R.map((V,Y)=>r.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-destructive",children:[r.jsx(dv,{className:"size-3 shrink-0","data-icon":"inline-start"}),r.jsx("span",{children:V})]},Y))}),W&&r.jsx("div",{className:"max-w-none overflow-hidden break-words text-sm leading-relaxed",children:r.jsx(Pn,{components:$n,remarkPlugins:Bs,children:W})}),H.length>500&&r.jsx(X,{type:"button",variant:"ghost",size:"xs",onClick:()=>c(!l),className:"mt-1 -ml-2 text-muted-foreground",children:l?r.jsxs(r.Fragment,{children:[r.jsx(nt,{"data-icon":"inline-start"})," Show less"]}):r.jsxs(r.Fragment,{children:[r.jsx(Ze,{"data-icon":"inline-start"})," Show more"]})}),!i&&t&&r.jsx("div",{className:"flex items-center mt-1.5 ml-auto",children:r.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(t).toLocaleTimeString()})})]}),v!==null&&r.jsx(Jc,{open:v.open,images:z,initialIndex:v.index,onClose:()=>w(V=>V?{...V,open:!1}:null),onCloseComplete:()=>w(null)},v.index)]})}),K1=b.memo(function(e){const t=U.c(10),{message:s,turnNumber:o}=e;let i;t[0]!==o?(i=r.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:["Turn ",o]}),t[0]=o,t[1]=i):i=t[1];let a;t[2]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(Me,{variant:"outline",children:"Queued"}),t[2]=a):a=t[2];let l;t[3]!==i?(l=r.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[i,a]}),t[3]=i,t[4]=l):l=t[4];let c;t[5]!==s?(c=r.jsx("div",{className:"rounded-lg border border-dashed bg-prompt-surface p-3",children:r.jsx(cd,{content:s,timestamp:""})}),t[5]=s,t[6]=c):c=t[6];let d;return t[7]!==l||t[8]!==c?(d=r.jsxs("div",{className:"motion-enter group relative px-4 py-5",children:[l,c]}),t[7]=l,t[8]=c,t[9]=d):d=t[9],d}),q1=b.memo(function(e){const t=U.c(30),{progress:s,expanded:o,onExpandedChange:i}=e,[a,l]=b.useState(!1),c=o??a,{todos:d,completed:f,total:u}=s,m=u>0?f/u*100:0;let p;t[0]!==i?(p=P=>{i==null||i(P),l(P)},t[0]=i,t[1]=p):p=t[1];let h;t[2]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(X,{type:"button",variant:"ghost",className:"h-auto w-full justify-start rounded-none px-3 py-2"}),t[2]=h):h=t[2];let g;t[3]!==c?(g=c?r.jsx(nt,{"data-icon":"inline-start"}):r.jsx(pr,{"data-icon":"inline-start"}),t[3]=c,t[4]=g):g=t[4];let x;t[5]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx("span",{className:"text-sm font-medium",children:"Tasks"}),t[5]=x):x=t[5];let v;t[6]!==f||t[7]!==u?(v=r.jsxs("span",{className:"font-mono text-xs tabular-nums text-muted-foreground",children:[f,"/",u]}),t[6]=f,t[7]=u,t[8]=v):v=t[8];let w;t[9]!==m?(w=m.toFixed(0),t[9]=m,t[10]=w):w=t[10];const y=`${w}% of tasks complete`;let j;t[11]!==m||t[12]!==y?(j=r.jsx(Mc,{value:m,className:"max-w-[200px] flex-1","aria-label":y}),t[11]=m,t[12]=y,t[13]=j):j=t[13];let k;t[14]!==s.inProgress?(k=s.inProgress&&r.jsxs("span",{className:"flex min-w-0 items-center gap-1 truncate text-xs text-info",children:[r.jsx(rt,{className:"size-3 shrink-0 animate-spin"}),r.jsx("span",{className:"truncate",children:s.inProgress.activeForm})]}),t[14]=s.inProgress,t[15]=k):k=t[15];let N;t[16]!==g||t[17]!==v||t[18]!==j||t[19]!==k?(N=r.jsxs(an,{render:h,children:[g,x,v,j,k]}),t[16]=g,t[17]=v,t[18]=j,t[19]=k,t[20]=N):N=t[20];let C;t[21]!==d?(C=d.map(zN),t[21]=d,t[22]=C):C=t[22];let S;t[23]!==C?(S=r.jsx(Nt,{children:r.jsx("div",{className:"px-3 pb-3 pt-1",children:r.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:C})})}),t[23]=C,t[24]=S):S=t[24];let _;return t[25]!==c||t[26]!==p||t[27]!==N||t[28]!==S?(_=r.jsxs(kt,{open:c,onOpenChange:p,className:"shrink-0 border-t bg-background",children:[N,S]}),t[25]=c,t[26]=p,t[27]=N,t[28]=S,t[29]=_):_=t[29],_});function zN(n,e){return r.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[n.status==="completed"?r.jsx(Un,{className:"size-3 shrink-0 text-success"}):n.status==="in_progress"?r.jsx(rt,{className:"size-3 shrink-0 animate-spin text-info"}):r.jsx(Yp,{className:"size-3 shrink-0 text-muted-foreground"}),r.jsx("span",{className:G("truncate text-xs",n.status==="in_progress"?"text-foreground":"text-muted-foreground",n.status==="completed"&&"line-through"),children:n.content}),n.owner&&r.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:n.owner})]},n.id??e)}function ha(n,e){const t=U.c(8);let s;t[0]!==e||t[1]!==n?(s=()=>{if(typeof window>"u")return e;try{const d=localStorage.getItem(n);return d===null?e:JSON.parse(d)}catch{return e}},t[0]=e,t[1]=n,t[2]=s):s=t[2];const[o,i]=b.useState(s);let a;t[3]!==n?(a=d=>{i(f=>{const u=typeof d=="function"?d(f):d;try{localStorage.setItem(n,JSON.stringify(u))}catch(m){const p=m;console.warn(`useLocalStorage: failed to serialize value for key "${n}"`,p)}return u})},t[3]=n,t[4]=a):a=t[4];const l=a;let c;return t[5]!==l||t[6]!==o?(c=[o,l],t[5]=l,t[6]=o,t[7]=c):c=t[7],c}function V1(n){return`${n.provider}:${n.latestVersion??"unknown"}`}function FN(n,e){const t=e.split(":")[0];return[...n.filter(s=>s.split(":")[0]!==t),e]}const BN="cogpit:provider-update-dismissals:v1";function UN(n,e){return n.filter(t=>t.status==="behind"&&!e.includes(V1(t)))}async function WN(n){const e=await ye("/api/provider-updates",{signal:n});if(!e.ok)throw new Error(`Provider update check failed (${e.status})`);return(await e.json()).providers??[]}async function HN(n){const e=await ye("/api/provider-updates/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:n})}),t=await e.json();if(!t.status)throw new Error(t.error??`Update failed (${e.status})`);return t}const KN=360*60*1e3;function qN(){const[n,e]=b.useState([]),[t,s]=ha(BN,[]),[o,i]=b.useState(null),[a,l]=b.useState(null);b.useEffect(()=>{const f=new AbortController,u=()=>{WN(f.signal).then(e).catch(()=>{})};u();const m=setInterval(u,KN);return()=>{f.abort(),clearInterval(m)}},[]);const c=b.useCallback(async f=>{i(f),l(null);try{const u=await HN(f);l(u),e(m=>m.map(p=>p.provider===f?u.info:p))}catch(u){l({provider:f,status:"failed",message:u instanceof Error?u.message:"Update failed.",output:null})}finally{i(null)}},[]),d=b.useCallback(f=>{s(u=>FN(u,V1(f)))},[s]);return{pending:UN(n,t),updating:o,outcome:a,update:c,dismiss:d,clearOutcome:b.useCallback(()=>l(null),[])}}const VN=5e3,GN={warning:"border-warning/30 bg-warning/10 text-warning",destructive:"border-destructive/30 bg-destructive/10 text-destructive",success:"border-success/30 bg-success/10 text-success"};function nl(n){return`grid-cols-[auto_minmax(0,1fr)_auto] rounded-none border-x-0 border-t-0 px-4 py-2 ${GN[n]}`}function Kf(n){const e=n.currentVersion?`v${n.currentVersion}`:"an older build";return`${n.displayName} ${e} → v${n.latestVersion}`}function G1(){const n=U.c(39),{pending:e,updating:t,outcome:s,update:o,dismiss:i,clearOutcome:a}=qN(),l=ut("configWrite"),c=(s==null?void 0:s.status)==="succeeded";let d,f;if(n[0]!==a||n[1]!==c?(d=()=>{if(!c)return;const T=setTimeout(a,VN);return()=>clearTimeout(T)},f=[c,a],n[0]=a,n[1]=c,n[2]=d,n[3]=f):(d=n[2],f=n[3]),b.useEffect(d,f),s){let T;return n[4]!==a||n[5]!==s.message||n[6]!==c?(T=c?r.jsxs(Ct,{className:nl("success"),children:[r.jsx(zi,{}),r.jsx(Dt,{children:s.message}),r.jsx(_t,{className:"text-success/80",children:"New sessions will use the updated CLI."})]}):r.jsxs(Ct,{className:nl("destructive"),children:[r.jsx(zs,{}),r.jsx(Dt,{children:"Update did not complete"}),r.jsx(_t,{className:"text-destructive/80",children:s.message}),r.jsx(xs,{className:"static col-start-3 row-span-2 row-start-1 self-center",children:r.jsx(X,{variant:"ghost",size:"xs",onClick:a,children:"Dismiss"})})]}),n[4]=a,n[5]=s.message,n[6]=c,n[7]=T):T=n[7],T}if(e.length===0)return null;const u=e[0],m=e.filter(T=>T.updateCommand!==null&&l),p=Ct;let h;n[8]===Symbol.for("react.memo_cache_sentinel")?(h=nl("warning"),n[8]=h):h=n[8];let g;n[9]!==t?(g=t?r.jsx(rt,{className:"animate-spin"}):r.jsx(wn,{}),n[9]=t,n[10]=g):g=n[10];let x;n[11]!==u||n[12]!==e?(x=e.length===1?Kf(u):`${e.map(YN).join(" and ")} are out of date`,n[11]=u,n[12]=e,n[13]=x):x=n[13];let v;n[14]!==x?(v=r.jsx(Dt,{children:x}),n[14]=x,n[15]=v):v=n[15];const w=e.length>1?e.map(Kf).join(" · "):m.length===1?`Cogpit can run \`${u.updateCommand}\` for you.`:u.updateCommand?`Run \`${u.updateCommand}\` to upgrade.`:"Update it with whatever installed it — Cogpit could not tell.";let y;n[16]!==w?(y=r.jsx(_t,{className:"text-warning/80",children:w}),n[16]=w,n[17]=y):y=n[17];const j=xs,k="static col-start-3 row-span-2 row-start-1 flex items-center gap-2 self-center";let N;n[18]!==e.length||n[19]!==o||n[20]!==t?(N=T=>r.jsxs(X,{variant:"outline",size:"xs",disabled:t!==null,onClick:()=>void o(T.provider),children:[r.jsx(Pl,{"data-icon":"inline-start"}),t===T.provider?"Updating…":e.length===1?"Update":`Update ${T.displayName}`]},T.provider),n[18]=e.length,n[19]=o,n[20]=t,n[21]=N):N=n[21];const C=m.map(N),S=t!==null;let _;n[22]!==i||n[23]!==e?(_=()=>e.forEach(i),n[22]=i,n[23]=e,n[24]=_):_=n[24];let P;n[25]!==S||n[26]!==_?(P=r.jsx(X,{variant:"ghost",size:"xs",disabled:S,onClick:_,className:"whitespace-nowrap text-muted-foreground",children:"Don't show again"}),n[25]=S,n[26]=_,n[27]=P):P=n[27];let A;n[28]!==j||n[29]!==C||n[30]!==P?(A=r.jsxs(j,{className:k,children:[C,P]}),n[28]=j,n[29]=C,n[30]=P,n[31]=A):A=n[31];let E;return n[32]!==p||n[33]!==A||n[34]!==h||n[35]!==g||n[36]!==v||n[37]!==y?(E=r.jsxs(p,{className:h,children:[g,v,y,A]}),n[32]=p,n[33]=A,n[34]=h,n[35]=g,n[36]=v,n[37]=y,n[38]=E):E=n[38],E}function YN(n){return n.displayName}function Y1(){const n=U.c(27),[e,t]=b.useState(null),[s,o]=b.useState(null),[i,a]=b.useState(!1);let l,c;if(n[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{const d=window.electronUpdater;d&&(d.onUpdateAvailable(f=>{t(f)}),d.onUpdateDownloaded(f=>{o(f)}))},c=[],n[0]=l,n[1]=c):(l=n[0],c=n[1]),b.useEffect(l,c),s&&!i){let d;n[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Pl,{}),n[2]=d):d=n[2];let f;n[3]!==s.version?(f=r.jsxs(Dt,{children:["Cogpit v",s.version," is ready"]}),n[3]=s.version,n[4]=f):f=n[4];let u;n[5]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(_t,{className:"text-success/80",children:"Restart to apply the update."}),n[5]=u):u=n[5];let m;n[6]===Symbol.for("react.memo_cache_sentinel")?(m=()=>a(!0),n[6]=m):m=n[6];let p;n[7]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(xs,{className:"static col-start-3 row-span-2 row-start-1 self-center",children:r.jsx(X,{variant:"ghost",size:"icon-xs",onClick:m,"aria-label":"Dismiss update",children:r.jsx(jt,{"data-icon":"inline-start"})})}),n[7]=p):p=n[7];let h;return n[8]!==f?(h=r.jsxs(Ct,{className:"grid-cols-[auto_minmax(0,1fr)_auto] rounded-none border-x-0 border-t-0 border-success/30 bg-success/10 px-4 py-2 pr-4 text-success has-data-[slot=alert-action]:pr-4",children:[d,f,u,p]}),n[8]=f,n[9]=h):h=n[9],h}if(e&&!i){let d;n[10]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Pl,{}),n[10]=d):d=n[10];let f;n[11]!==e.version?(f=r.jsxs(Dt,{children:["Cogpit v",e.version," is available"]}),n[11]=e.version,n[12]=f):f=n[12];let u;n[13]!==e.platform?(u=e.platform!=="mac"&&r.jsx(_t,{children:"Update through your package manager."}),n[13]=e.platform,n[14]=u):u=n[14];let m;n[15]!==e.platform||n[16]!==e.url?(m=e.platform==="mac"&&r.jsxs(X,{variant:"outline",size:"xs",render:r.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer"}),nativeButton:!1,children:[r.jsx(uv,{"data-icon":"inline-start"}),"Download"]}),n[15]=e.platform,n[16]=e.url,n[17]=m):m=n[17];let p;n[18]!==e.version?(p=r.jsx(X,{variant:"ghost",size:"xs",onClick:()=>{var x;a(!0),(x=window.electronUpdater)==null||x.dismissVersion(e.version)},className:"whitespace-nowrap text-muted-foreground",children:"Don't show again"}),n[18]=e.version,n[19]=p):p=n[19];let h;n[20]!==m||n[21]!==p?(h=r.jsxs(xs,{className:"static col-start-3 row-span-2 row-start-1 flex items-center gap-2 self-center",children:[m,p]}),n[20]=m,n[21]=p,n[22]=h):h=n[22];let g;return n[23]!==f||n[24]!==u||n[25]!==h?(g=r.jsxs(Ct,{className:"grid-cols-[auto_minmax(0,1fr)_auto] rounded-none border-x-0 border-t-0 border-info/30 bg-info/10 px-4 py-2 pr-4 text-info has-data-[slot=alert-action]:pr-4",children:[d,f,u,h]}),n[23]=f,n[24]=u,n[25]=h,n[26]=g):g=n[26],g}return null}const X1=b.createContext(null);function fi(n){const e=U.c(3),{value:t,children:s}=n;let o;return e[0]!==s||e[1]!==t?(o=r.jsx(X1.Provider,{value:t,children:s}),e[0]=s,e[1]=t,e[2]=o):o=e[2],o}function Rt(){const n=b.useContext(X1);if(!n)throw new Error("useAppContext must be used within an AppProvider");return n}const ar=null,{min:As,max:dn,abs:qf,floor:XN}=Math,J1=(n,e,t)=>As(t,dn(e,n)),Q1=n=>[...n].sort((e,t)=>e-t),Z1=typeof queueMicrotask=="function"?queueMicrotask:n=>{Promise.resolve().then(n)},Yl=()=>{let n;return[new Promise(e=>{n=e}),n]},ex=n=>{let e;return()=>(n&&(e=n(),n=void 0),e)},Ho=(n,e,t)=>{const s=t?"unshift":"push";for(let o=0;o<e;o++)n[s](-1);return n},tx=(n,e)=>{const t=n.t[e];return t===-1?n.o:t},JN=(n,e,t)=>{const s=n.t[e]===-1;return n.t[e]=t,n.i=As(e,n.i),s},mi=(n,e)=>{if(!n.l)return 0;if(n.i>=e)return n.u[e];n.i<0&&(n.u[0]=0,n.i=0);let t=n.i,s=n.u[t];for(;t<e;)s+=tx(n,t),n.u[++t]=s;return n.i=e,s},qs=(n,e,t=0,s=n.l-1)=>{let o=t;for(;t<=s;){const i=XN((t+s)/2);mi(n,i)<=e?(o=i,t=i+1):s=i-1}return J1(o,0,n.l-1)},Vf=(n,e,t)=>{const s=e-n.l;return n.i=t?-1:As(e-1,n.i),n.l=e,s>0?(Ho(n.u,s),Ho(n.t,s,t),n.o*s):(n.u.splice(s),(t?n.t.splice(0,-s):n.t.splice(s)).reduce((o,i)=>o-(i===-1?n.o:i),0))},QN=typeof window<"u",ZN=n=>n.documentElement,eC=n=>n.ownerDocument,tC=n=>n.defaultView,nx=ex(()=>!!/iP(hone|od|ad)/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>0),nC=ex(()=>"scrollBehavior"in ZN(document).style),sC=n=>dn(n.h(),n.p()),oC=(n,e=40,t=0,s,o=!1)=>{let i=!!t,a=1,l=0,c=0,d=0,f=0,u=0,m=0,p=0,h=0,g=ar,x=[0,i?dn(t-1,0):-1],v=0,w=!1;const y=((T,M,I)=>({o:M,t:I?Ho(I.slice(0,As(T,I.length)),dn(0,T-I.length)):Ho([],T),l:T,i:-1,u:Ho([],T+1)}))(n,s?s[1]:e,s&&s[0]),j=new Set,k=()=>d-c,N=()=>k()+u+f,C=(T,M)=>((I,R,$,D)=>{if(D=As(D,I.l-1),mi(I,D)<=R){const O=qs(I,$,D);return[qs(I,R,D,O),O]}{const O=qs(I,R,void 0,D);return[O,qs(I,$,O)]}})(y,T,M,x[0]),S=()=>mi(y,y.l),_=(T,M)=>{const I=mi(y,T)-u;return M?S()-I-P(T):I},P=T=>tx(y,T),A=(T,M=-1)=>y.t[T]===M,E=T=>{T&&(nx()&&p!==0||g&&h===1?u+=T:f+=T)};return{v:()=>{j.clear()},m:()=>a,_:()=>(T=>[T.t.slice(),T.o])(y),S:(T=200)=>{if(!w||i)return x;let M,I;if(m)[M,I]=x;else{let R=dn(0,N()),$=R+l;o||(T=dn(0,T),p!==1&&(R-=T),p!==2&&($+=T)),[M,I]=x=C(dn(0,R),dn(0,$)),g&&(M=As(M,g[0]),I=dn(I,g[1]))}return[dn(M,0),As(I,y.l-1)]},$:T=>qs(y,T-c),I:A,k:_,R:P,T:()=>y.l,C:()=>d,M:()=>p!==0,p:()=>l,O:()=>c,h:S,H:()=>(m=f,f=0,[m,h===2]),W:(T,M)=>{const I=[T,M];return j.add(I),()=>{j.delete(I)}},B:(T,M)=>{let I,R,$=0;switch(T){case 1:{if(M===d&&h===0)break;const D=m;m=0;const O=M-d,L=qf(O);D&&L<qf(D)+1||h!==0||(p=O<0?2:1),i&&(i=!1),d=M,$=4;const z=k();z>=-l&&z<=S()&&($+=1,R=L>l);break}case 2:$=8,p!==0&&(I=!0,$+=1),p=0,h=0,g=ar;break;case 3:{const D=M.filter(([O,L])=>!A(O,L));if(!D.length)break;E(D.reduce((O,[L,z])=>{let F;if(h===2)F=!0;else if(g&&h===1)F=L<g[0];else{const H=k(),B=_(L),W=P(L);F=p!==1&&h===0?B+W<=H:B<H&&B+W<H+l}return F&&(O+=z-P(L)),O},0));for(const[O,L]of D){const z=P(O),F=JN(y,O,L);o&&(v+=F?L:L-z)}o&&l&&v>l&&(E(((O,L)=>{let z=0;const F=[];O.t.forEach((Y,q)=>{Y!==-1&&(F.push(Y),q<L&&z++)}),O.i=-1;const H=Q1(F),B=H.length,W=B/2|0,K=B%2==0?(H[W-1]+H[W])/2:H[W],V=O.o;return((O.o=K)-V)*dn(L-z,0)})(y,qs(y,N()))),o=!1),$=3,R=!0;break}case 4:l!==M&&(l||(w=R=!0),l=M,$=3);break;case 5:M[1]?(E(Vf(y,M[0],!0)),h=2,$=1):(Vf(y,M[0]),$=1);break;case 6:c=M;break;case 7:h=1;break;case 8:g=C(M,M+l),$=1}$&&(a=1+(2147483647&a),I&&u&&(f+=u,u=0),j.forEach(([D,O])=>{$&D&&O(R)}))}}},dd=setTimeout,sl=(n,e)=>e?-n:n,rC=(n,e,t,s,o,i)=>{const a=Date.now;let l=0,c=!1,d=!1,f=!1,u=!1;const m=(()=>{let v;const w=()=>{v!=ar&&clearTimeout(v)},y=()=>{w(),v=dd(()=>{v=ar,(()=>{if(c||d)return c=!1,void m();f=!1,n.B(2)})()},150)};return y.J=w,y})(),p=()=>{l=a(),f&&(u=!0),n.B(1,s()),m()},h=v=>{if(c||!n.M()||v.ctrlKey)return;const w=a()-l;150>w&&50<w&&(t?v.deltaX:v.deltaY)&&(c=!0)},g=()=>{d=!0,f=u=!1},x=()=>{d=!1,nx()&&(f=!0)};return e.addEventListener("scroll",p),e.addEventListener("wheel",h,{passive:!0}),e.addEventListener("touchstart",g,{passive:!0}),e.addEventListener("touchend",x,{passive:!0}),{A:()=>{e.removeEventListener("scroll",p),e.removeEventListener("wheel",h),e.removeEventListener("touchstart",g),e.removeEventListener("touchend",x),m.J()},L:()=>{const[v,w]=n.H();v&&(o(v,w,u),u=!1,w&&n.p()>n.h()&&n.B(1,s()))}}},iC=(n,e,t)=>{let s;return[async(o,i)=>{if(!await e())return;s&&s();const a=()=>{const[l,c]=Yl();return s=()=>{c(!1)},n.p()&&dd(s,150),[l,n.W(2,()=>{c(!0)})]};if(i&&nC())n.B(8,o()),Z1(async()=>{for(;;){let l=!0;for(let[f,u]=n.S();f<=u;f++)if(n.I(f)){l=!1;break}if(l)break;const[c,d]=a();try{if(!await c)return}finally{d()}}n.B(7),t(o(),i)});else for(;;){const[l,c]=a();try{if(n.B(7),t(o()),!await l)return}finally{c()}}},()=>{s&&s()}]},aC=(n,e)=>{let t,s,o=Yl(),i=!1;const a=e?"scrollLeft":"scrollTop",l=e?"overflowX":"overflowY",[c,d]=iC(n,()=>o[0],(f,u)=>{f=sl(f,i),u?t.scrollTo({[e?"left":"top"]:f,behavior:"smooth"}):t[a]=f});return{N(f,u){t=u,e&&(i=getComputedStyle(u).direction==="rtl"),s=rC(n,u,e,()=>sl(u[a],i),(m,p,h)=>{if(h){const g=u.style,x=g[l];g[l]="hidden",dd(()=>{g[l]=x})}u[a]=sl(n.C()+m,i),p&&d()}),o[1](!0)},v(){s&&s.A(),o[1](!1),o=Yl()},P:()=>i,V(f){c(()=>f)},X(f){f+=n.C(),c(()=>f)},Y(f,{align:u,smooth:m,offset:p=0}={}){if(f=J1(f,0,n.T()-1),u==="nearest"){const h=n.k(f),g=n.C();if(h<g)u="start";else{if(!(h+n.R(f)>g+n.p()))return;u="end"}}c(()=>p+n.O()+n.k(f)+(u==="end"?n.R(f)-n.p():u==="center"?(n.R(f)-n.p())/2:0),m)},q:()=>{s&&s.L()}}},lC=n=>{let e;return{j(t){(e||(e=new(tC(eC(t))).ResizeObserver(n))).observe(t)},D(t){e.unobserve(t)},A(){e&&e.disconnect()}}},cC=(n,e)=>{let t;const s=e?"width":"height",o=new WeakMap,i=lC(a=>{const l=[];for(const{target:c,contentRect:d}of a)if(c.offsetParent)if(c===t)n.B(4,d[s]);else{const f=o.get(c);f!=ar&&l.push([f,d[s]])}l.length&&n.B(3,l)});return{G(a){i.j(t=a)},U:(a,l)=>(o.set(a,l),i.j(a),()=>{o.delete(a),i.D(a)}),v:i.A}},ji=QN?b.useLayoutEffect:b.useEffect,Gt="current",sx=(n,e)=>{if(Array.isArray(n))for(const t of n)sx(t,e);else n==null||typeof n=="boolean"||e.push(n)},dC=(n,e)=>{const t=n.key;return t??"_"+e},uC=n=>{const e=b.useRef(null);return e[Gt]||(e[Gt]=n())},Gf=n=>{const e=b.useRef(n);return ji(()=>{e[Gt]=n},[n]),e},fC=b.memo(({Z:n,ee:e,te:t,oe:s,ne:o,re:i,se:a,ie:l})=>{const c=b.useRef(null);ji(()=>e(c[Gt],t),[t]);const d=b.useMemo(()=>{const f={contain:"layout style",position:o&&l?void 0:"absolute",[a?"height":"width"]:"100%",[a?"top":"left"]:0,[a?"left":"top"]:s,visibility:!o||l?void 0:"hidden"};return a&&(f.display="inline-flex"),f},[s,o,l,a]);return r.jsx(i,typeof i=="string"?{ref:c,style:d,children:n}:{ref:c,style:d,index:t,children:n})}),mC=(n,e)=>b.useMemo(()=>{if(typeof n=="function")return[s=>n(e[s],s),e.length];const t=(s=>{const o=[];return sx(s,o),o})(n);return[s=>t[s],t.length]},[n,e]),pC=b.forwardRef(({children:n,data:e,bufferSize:t,itemSize:s,shift:o,horizontal:i,keepMounted:a,cache:l,startMargin:c=0,ssrCount:d,as:f="div",item:u="div",scrollRef:m,onScroll:p,onScrollEnd:h},g)=>{const[x,v]=mC(n,e),w=b.useRef(null),y=b.useRef(!!d),j=Gf(p),k=Gf(h),[N,C,S,_]=uC(()=>{const $=!!i,D=oC(v,s,d,l,!s);return[D,cC(D,$),aC(D,$),$]});v!==N.T()&&N.B(5,[v,o]),c!==N.O()&&N.B(6,c);const[P,A]=b.useReducer(N.m,void 0,N.m),E=N.M(),T=N.h(),M=S.P(),I=[],R=$=>{const D=x($);return r.jsx(fC,{ee:C.U,te:$,oe:N.k($,M),ne:N.I($),re:u,Z:D,se:_,ie:y[Gt]},dC(D,$))};if(ji(()=>{y[Gt]=!1,N.W(1,O=>{O?X2.flushSync(A):A()}),N.W(4,()=>{j[Gt]&&j[Gt](N.C())}),N.W(8,()=>{k[Gt]&&k[Gt]()});const $=w[Gt],D=O=>{C.G(O),S.N($,O)};return m?Z1(()=>{m[Gt]&&D(m[Gt])}):D($.parentElement),()=>{N.v(),C.v(),S.v()}},[]),ji(()=>{S.q()},[P]),b.useImperativeHandle(g,()=>({get cache(){return N._()},get scrollOffset(){return N.C()},get scrollSize(){return sC(N)},get viewportSize(){return N.p()},findItemIndex:N.$,getItemOffset:N.k,getItemSize:N.R,scrollToIndex:S.Y,scrollTo:S.V,scrollBy:S.X}),[]),a){const $=new Set(a);for(let[D,O]=N.S(t);D<=O;D++)$.add(D);Q1([...$]).forEach(D=>{I.push(R(D))})}else for(let[$,D]=N.S(t);$<=D;$++)I.push(R($));return r.jsx(f,{ref:w,style:{contain:"size style",overflowAnchor:"none",flex:"none",position:"relative",width:_?T:"100%",height:_?"100%":T,pointerEvents:E?"none":void 0},children:I})});function ga(n){const e=U.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=r.jsx(mv,{"data-slot":"context-menu",...t}),e[2]=t,e[3]=s):s=e[3],s}function xa(n){const e=U.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 o;e[3]!==t?(o=G("select-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(fv,{"data-slot":"context-menu-trigger",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function ba(n){const e=U.c(18);let t,s,o,i,a,l;e[0]!==n?({className:t,align:o,alignOffset:i,side:a,sideOffset:l,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a,e[6]=l):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5],l=e[6]);const c=o===void 0?"start":o,d=i===void 0?4:i,f=a===void 0?"right":a,u=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=r.jsx(Op,{"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]!==d||e[14]!==f||e[15]!==u||e[16]!==p?(h=r.jsx(zp,{children:r.jsx(Fp,{className:"isolate z-50 outline-none",align:c,alignOffset:d,side:f,sideOffset:u,children:p})}),e[12]=c,e[13]=d,e[14]=f,e[15]=u,e[16]=p,e[17]=h):h=e[17],h}function ao(n){const e=U.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=r.jsx(Dp,{"data-slot":"context-menu-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function ZM(n){const e=U.c(10);let t,s,o;e[0]!==n?({className:t,inset:s,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==t?(i=G("px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",t),e[4]=t,e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o||e[8]!==i?(a=r.jsx(Lp,{"data-slot":"context-menu-label","data-inset":s,className:i,...o}),e[6]=s,e[7]=o,e[8]=i,e[9]=a):a=e[9],a}function Yt(n){const e=U.c(12);let t,s,o,i;e[0]!==n?({className:t,inset:s,variant:i,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);const a=i===void 0?"default":i;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]!==o||e[9]!==l||e[10]!==a?(c=r.jsx($p,{"data-slot":"context-menu-item","data-inset":s,"data-variant":a,className:l,...o}),e[7]=s,e[8]=o,e[9]=l,e[10]=a,e[11]=c):c=e[11],c}function lr(n){const e=U.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 o;e[3]!==t?(o=G("-mx-1 my-1 h-px bg-border",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(mc,{"data-slot":"context-menu-separator",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function hC(n){const e=U.c(22),{children:t,turnIndex:s,branches:o,onRestoreToHere:i,onOpenBranches:a,onBranchFromHere:l}=n;let c;e[0]!==t?(c=r.jsx(xa,{className:"select-text",children:t}),e[0]=t,e[1]=c):c=e[1];let d;e[2]!==i||e[3]!==s?(d=()=>i(s),e[2]=i,e[3]=s,e[4]=d):d=e[4];let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(Sc,{"data-icon":"inline-start"}),e[5]=f):f=e[5];let u;e[6]!==d?(u=r.jsx(ao,{children:r.jsxs(Yt,{onClick:d,children:[f,"Restore to this point"]})}),e[6]=d,e[7]=u):u=e[7];let m;e[8]!==o.length||e[9]!==a||e[10]!==s?(m=o.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(lr,{}),r.jsx(ao,{children:r.jsxs(Yt,{onClick:()=>a(s),children:[r.jsx(jc,{"data-icon":"inline-start"}),"View branches (",o.length,")"]})})]}),e[8]=o.length,e[9]=a,e[10]=s,e[11]=m):m=e[11];let p;e[12]!==l||e[13]!==s?(p=l&&r.jsxs(r.Fragment,{children:[r.jsx(lr,{}),r.jsx(ao,{children:r.jsxs(Yt,{onClick:()=>l(s),children:[r.jsx(En,{"data-icon":"inline-start"}),"Duplicate from here"]})})]}),e[12]=l,e[13]=s,e[14]=p):p=e[14];let h;e[15]!==u||e[16]!==m||e[17]!==p?(h=r.jsxs(ba,{className:"min-w-44",children:[u,m,p]}),e[15]=u,e[16]=m,e[17]=p,e[18]=h):h=e[18];let g;return e[19]!==c||e[20]!==h?(g=r.jsxs(ga,{children:[c,h]}),e[19]=c,e[20]=h,e[21]=g):g=e[21],g}function gC(n){const e=U.c(15),{redoTurnCount:t,onRedoAll:s}=n;if(t<=0)return null;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(Sc,{className:"size-4","data-icon":"inline-start"}),e[0]=o):o=e[0];let i;e[1]!==t?(i=r.jsx("span",{className:"font-mono",children:t}),e[1]=t,e[2]=i):i=e[2];const a=t!==1?"s":"";let l;e[3]!==a?(l=r.jsxs("span",{children:["turn",a," archived"]}),e[3]=a,e[4]=l):l=e[4];let c;e[5]!==i||e[6]!==l?(c=r.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-muted-foreground",children:[o,i,l]}),e[5]=i,e[6]=l,e[7]=c):c=e[7];let d;e[8]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(It,{orientation:"vertical",className:"h-4"}),e[8]=d):d=e[8];let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(pv,{"data-icon":"inline-start"}),e[9]=f):f=e[9];let u;e[10]!==s?(u=r.jsxs(X,{variant:"default",size:"sm",onClick:s,children:[f,"Redo all"]}),e[10]=s,e[11]=u):u=e[11];let m;return e[12]!==c||e[13]!==u?(m=r.jsxs("div",{className:"sticky bottom-0 flex items-center justify-center gap-3 border-t border-border bg-background/95 px-4 py-2",role:"status",children:[c,d,u]}),e[12]=c,e[13]=u,e[14]=m):m=e[14],m}const Yf=new Map;function xC(n){let e=Yf.get(n);if(!e){const t=new Map;e={observer:new IntersectionObserver(o=>{var i;for(const a of o)(i=t.get(a.target))==null||i(a.isIntersecting)},{rootMargin:n}),callbacks:t},Yf.set(n,e)}return e}function ox(n){const e=U.c(5),t="100%",s=b.useRef(null),[o,i]=b.useState(!0);let a,l;e[0]!==t?(a=()=>{const d=s.current;if(!d)return;const{observer:f,callbacks:u}=xC(t);return u.set(d,i),f.observe(d),()=>{f.unobserve(d),u.delete(d)}},l=[t],e[0]=t,e[1]=a,e[2]=l):(a=e[1],l=e[2]),b.useEffect(a,l);let c;return e[3]!==o?(c={ref:s,isNear:o},e[3]=o,e[4]=c):c=e[4],c}function Si(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 Xf(n){const e=Si(n.lastActivityAt);return e!==Number.NEGATIVE_INFINITY?e:Si(n.lastModified)}function Jf(n,e){return n===e?0:e-n}function Qf(n){return[n.dirName??"",n.fileName??"",n.sessionId??""].join("/")}function bC(n,e){const t=Jf(Xf(n),Xf(e));if(t!==0)return t;const s=Jf(Si(n.lastModified),Si(e.lastModified));return s!==0?s:Qf(n).localeCompare(Qf(e))}function ud(n){return[...n].sort(bC)}function rx(n,e){const t=!!(n.teamName&&n.agentName);return e||mn(n.aiTitle||(t?n.agentName:"")||n.lastUserMessage||n.firstUserMessage||n.slug||n.sessionId,50)}const vC="Unknown project";function fd(n){const e=ta(n);return ea(e?e.parentPath:n,2)||vC}function yC(n){return fd(n.cwd||hn(n.dirName))}function wC(n){const e=ud(n),t=new Map;for(const s of e){const o=yC(s),i=t.get(o);i?i.push(s):t.set(o,[s])}return t}function ix(n,e){return n.isActive?!0:e.has(n.sessionId)?n.agentStatus!=="completed":!1}function jC(n,e,t){let s=-1;return n.forEach((o,i)=>{ix(o,e)&&(s=i)}),Math.max(t,s+1)}const md=new Set(["thinking","tool_use","processing","compacting","awaiting_agents"]),SC=12e4;function kC(n,e=Date.now()){const t=Date.parse(n.lastActivityAt||n.lastModified);return Number.isFinite(t)&&e-t<SC}function ax(n,e,t=Date.now()){return ix(n,e)?!0:n.agentStatus==="completed"||!n.agentStatus?!1:kC(n,t)}function NC(n,e,t=Date.now()){return n.some(s=>ax(s,e,t))}const CC="cogpit:session-list-cache",_C=10080*60*1e3,TC=24,Ln={projects:"projects",activeSessions:"active-sessions",runningProcesses:"running-processes"},Xl=new Map;function EC(){return{version:1,entries:{}}}function lx(){return Lt(CC)}function cx(){const n=lx(),e=Xl.get(n);if(e)return e;let t=EC();try{const s=localStorage.getItem(n);if(s){const o=JSON.parse(s);o.version===1&&o.entries&&typeof o.entries=="object"&&(t=o)}}catch{}return Xl.set(n,t),t}function dx(n){const e=cx().entries[n];if(!(!e||Date.now()-e.savedAt>_C))return e.value}function ux(n,e){const t=lx(),o={...cx().entries,[n]:{savedAt:Date.now(),value:e}},i=Object.entries(o).sort(([,l],[,c])=>c.savedAt-l.savedAt),a={version:1,entries:Object.fromEntries(i.slice(0,TC))};Xl.set(t,a);try{localStorage.setItem(t,JSON.stringify(a))}catch{}}function ki(n){const e=dx(n);return Array.isArray(e)?e:void 0}function Ko(n,e){ux(n,e)}function fx(n){return`sessions:${n}`}function PC(n){const e=dx(fx(n));if(!e||typeof e!="object")return;const t=e;if(!(!Array.isArray(t.sessions)||typeof t.total!="number"))return t}function AC(n,e){ux(fx(n),e)}const RC=2e4;function MC(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}const mx=b.createContext(null);function IC({children:n}){const[e]=b.useState(fn),[t,s]=b.useState(()=>ki(Ln.activeSessions)??[]),[o,i]=b.useState(()=>ki(Ln.runningProcesses)??[]),[a,l]=b.useState(!1),[c,d]=b.useState(null),[f,u]=b.useState(new Set),m=b.useRef(null),p=b.useRef(null),h=b.useRef(!1);b.useEffect(()=>(h.current=!0,()=>{var N;h.current=!1,(N=p.current)==null||N.abort(),p.current=null}),[]);const g=b.useCallback(async()=>{var S;if(!h.current||fn()!==e)return;(S=p.current)==null||S.abort();const N=new AbortController;p.current=N;const C=()=>h.current&&!N.signal.aborted&&p.current===N&&fn()===e;l(!0);try{const[_,P]=await Promise.all([ye("/api/active-sessions",{signal:N.signal}),ye("/api/running-processes",{signal:N.signal})]);if(!C())return;if(!_.ok||!P.ok)throw new Error("Failed to fetch live data");const[A,E]=await Promise.all([_.json(),P.json()]);if(!C())return;const T=Array.isArray(A)?A:[],M=Array.isArray(E)?E:[];s(T),i(M),Ko(Ln.activeSessions,T),Ko(Ln.runningProcesses,M),d(null)}catch(_){if(!C())return;d(_ instanceof Error?_.message:"Failed to load data")}finally{C()&&l(!1),p.current===N&&(p.current=null)}},[e]),x=b.useCallback(()=>{g()},[g]);b.useEffect(()=>{x()},[x]);const v=b.useMemo(()=>MC(o),[o]),w=b.useMemo(()=>NC(t,v),[t,v]);b.useEffect(()=>(window.addEventListener("focus",x),()=>window.removeEventListener("focus",x)),[x]),b.useEffect(()=>{if(!w)return;const N=setInterval(()=>{document.visibilityState==="visible"&&x()},RC);return()=>clearInterval(N)},[w,x]),b.useEffect(()=>{if(t.length===0)return;const N=m.current,C=new Map;for(const S of t)S.agentStatus&&v.has(S.sessionId)&&C.set(S.sessionId,S.agentStatus);N!==null&&u(S=>{let _=null;for(const[P,A]of C)A==="completed"&&N.get(P)!=="completed"&&(_??(_=new Set(S)),_.add(P));for(const P of S)C.get(P)!=="completed"&&(_??(_=new Set(S)),_.delete(P));return _??S}),m.current=C},[t,v]);const y=b.useCallback(N=>{u(C=>{if(!C.has(N))return C;const S=new Set(C);return S.delete(N),S})},[]),j=b.useCallback(N=>{s(C=>{const S=C.filter(_=>_.sessionId!==N);return fn()===e&&Ko(Ln.activeSessions,S),S})},[e]),k=b.useMemo(()=>({sessions:t,processes:o,procBySession:v,newlyCompleted:f,loading:a,error:c,refresh:x,removeSession:j,acknowledgeCompleted:y}),[t,o,v,f,a,c,x,j,y]);return r.jsx(mx.Provider,{value:k,children:n})}function px(){const n=pd();if(!n)throw new Error("useSessionInventory must be used within a SessionInventoryProvider");return n}function pd(){return b.useContext(mx)}const Zf=[20,50,80,110,140,170,200,230,260,290,320,350];function $C(n){let e=2166136261;for(let t=0;t<n.length;t++)e^=n.charCodeAt(t),e=Math.imul(e,16777619);return Zf[(e>>>0)%Zf.length]}function ol(n){const e=[];let t=!1;for(const s of n.split(`
|
|
85
|
+
`)){if(/^\s*(```|~~~)/.test(s)){t=!t;continue}let o=s;if(!t){if(o=o.replace(/^\s{0,3}#{1,6}\s+/,"").replace(/^\s*>\s?/,"").replace(/^\s*(?:[-*+]|\d+[.)])\s+/,""),/^\s*(?:[-*_]\s*){3,}$/.test(o))continue;o=o.replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]*)\]\[[^\]]*\]/g,"$1").replace(/(\*\*|__|~~)(.*?)\1/g,"$2").replace(new RegExp("(?<![\\w*])[*_](?=\\S)([^*_]+?)(?<=\\S)[*_](?![\\w*])","g"),"$1").replace(/`+/g,"")}const i=o.trim();i&&e.push(i)}return e.join(" ")}function OC(n){const e=n.split(`
|
|
86
|
+
`);let t=0;for(;t<e.length&&e[t].trim()==="";)t++;const s=ol(e[t]??"");return s?{subject:s,preview:ol(e.slice(t+1).join(`
|
|
87
|
+
`))}:{subject:ol(n),preview:""}}function Jl(n){if(!n)return null;const e=new Date(n).getTime();return Number.isNaN(e)?null:e}function DC(n,e){return n===null||e===null||e<n?null:e-n}function LC(n){const e=Jl(n);return e===null?null:new Date(e).toLocaleTimeString()}function zC(n){var s;const e=(s=pd())==null?void 0:s.sessions;let t;e:{if(!n||!e){t=null;break e}const o=e.filter(a=>a.agentName===n);if(o.length!==1){t=null;break e}const i=o[0].agentStatus;if(!i){t=null;break e}t=md.has(i)?"working":"idle"}return t}const FC=b.memo(function(e){const t=U.c(48),{sender:s,body:o,timestamp:i,reply:a,isLive:l}=e,[c,d]=b.useState(!1);let f;t[0]!==o?(f=k4(o),t[0]=o,t[1]=f):f=t[1];const u=f;let m;t[2]!==u?(m=OC(u),t[2]=u,t[3]=m):m=t[3];const{subject:p,preview:h}=m;let g;t[4]!==i?(g=LC(i),t[4]=i,t[5]=g):g=t[5];const x=g,v=zC(s);let w;t[6]!==u?(w=E4(u),t[6]=u,t[7]=w):w=t[7];const y=w,j=y&&!a,k=Jl(i),N=a?DC(k,Jl(a.timestamp)):null,C=!a&&l===!0,S=!!a||y;Ih(C&&S);const _=!0;let P;t[8]!==s?(P=$C(s),t[8]=s,t[9]=P):P=t[9];const A=String(P);let E;t[10]!==A?(E={"--agent-hue":A},t[10]=A,t[11]=E):E=t[11];const T=E,M="my-2 rounded-lg border border-l-[3px] border-border bg-card px-3 py-2 [border-left-color:oklch(0.52_0.16_var(--agent-hue))] dark:[border-left-color:oklch(0.74_0.14_var(--agent-hue))]";let I;t[12]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(hv,{className:"size-3.5 shrink-0 text-[oklch(0.52_0.16_var(--agent-hue))] dark:text-[oklch(0.74_0.14_var(--agent-hue))]","data-icon":"inline-start"}),t[12]=I):I=t[12];let R;t[13]!==s?(R=r.jsx("span",{className:"truncate font-mono text-xs font-medium text-[oklch(0.52_0.16_var(--agent-hue))] dark:text-[oklch(0.74_0.14_var(--agent-hue))]",children:s}),t[13]=s,t[14]=R):R=t[14];let $;t[15]!==v||t[16]!==s?($=v&&r.jsx("span",{"data-testid":"agent-liveness","data-live":v,title:v==="working"?`${s} is working now`:`${s} is idle`,className:`inline-flex size-1.5 shrink-0 rounded-full ${v==="working"?"animate-pulse bg-warning":"bg-success"}`}),t[15]=v,t[16]=s,t[17]=$):$=t[17];let D;t[18]!==R||t[19]!==$?(D=r.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[I,R,$]}),t[18]=R,t[19]=$,t[20]=D):D=t[20];let O;t[21]!==j?(O=j&&r.jsx(Me,{variant:"outline",className:"h-4 border-warning/30 bg-warning/10 px-1.5 text-[10px] tracking-wide text-warning uppercase",children:"Needs you"}),t[21]=j,t[22]=O):O=t[22];let L;t[23]!==x?(L=x&&r.jsx("span",{className:"text-xs text-muted-foreground",children:x}),t[23]=x,t[24]=L):L=t[24];let z;t[25]!==O||t[26]!==L?(z=r.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[O,L]}),t[25]=O,t[26]=L,t[27]=z):z=t[27];let F;t[28]!==D||t[29]!==z?(F=r.jsxs("div",{className:"flex items-center gap-2",children:[D,z]}),t[28]=D,t[29]=z,t[30]=F):F=t[30];let H;t[31]!==u||t[32]!==c||t[33]!==h||t[34]!==p?(H=c?r.jsx("div",{"data-testid":"agent-message-body",className:"mt-1.5 max-w-none overflow-hidden break-words text-sm leading-relaxed",children:r.jsx(Pn,{components:$n,remarkPlugins:Bs,children:u})}):r.jsxs(r.Fragment,{children:[r.jsx("p",{"data-testid":"agent-message-subject",className:"mt-1 line-clamp-2 break-words text-sm font-medium text-foreground",children:p}),h&&r.jsx("p",{"data-testid":"agent-message-preview",className:"mt-0.5 line-clamp-2 break-words text-xs leading-relaxed text-muted-foreground",children:h})]}),t[31]=u,t[32]=c,t[33]=h,t[34]=p,t[35]=H):H=t[35];const B="mt-1.5 flex items-center justify-end gap-2",W=S&&r.jsx("p",{"data-testid":"agent-message-state",className:`min-w-0 flex-1 truncate text-xs ${C?"text-warning":"text-muted-foreground"}`,children:a?r.jsxs(r.Fragment,{children:[N===null?"You replied":`You replied ${Tn(N)} later`,a.summary&&` · "${a.summary}"`]}):C?k===null?"Awaiting your reply":`Awaiting your reply · ${Tn(Math.max(0,Date.now()-k))}`:"Never answered"});let K;t[36]===Symbol.for("react.memo_cache_sentinel")?(K=()=>d(BC),t[36]=K):K=t[36];let V;t[37]!==u||t[38]!==c?(V=r.jsx(X,{type:"button",variant:"ghost",size:"xs",onClick:K,className:"-mr-2 text-muted-foreground",children:c?r.jsxs(r.Fragment,{children:[r.jsx(nt,{"data-icon":"inline-start"})," Collapse"]}):r.jsxs(r.Fragment,{children:[r.jsx(Ze,{"data-icon":"inline-start"})," Expand ·"," ",u.length.toLocaleString("en-US")," ",u.length===1?"char":"chars"]})}),t[37]=u,t[38]=c,t[39]=V):V=t[39];let Y;t[40]!==W||t[41]!==V?(Y=r.jsxs("div",{className:B,children:[W,V]}),t[40]=W,t[41]=V,t[42]=Y):Y=t[42];let q;return t[43]!==F||t[44]!==H||t[45]!==Y||t[46]!==T?(q=r.jsxs("div",{"data-agent-rail":_,style:T,className:M,children:[F,H,Y]}),t[43]=F,t[44]=H,t[45]=Y,t[46]=T,t[47]=q):q=t[47],q});function BC(n){return!n}const UC=1500;function ho(){const n=U.c(5),[e,t]=b.useState(!1),s=b.useRef(null);let o,i;n[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>()=>{s.current&&clearTimeout(s.current)},i=[],n[0]=o,n[1]=i):(o=n[0],i=n[1]),b.useEffect(o,i);let a;n[2]===Symbol.for("react.memo_cache_sentinel")?(a=async d=>{await br(d)&&(t(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>t(!1),UC))},n[2]=a):a=n[2];const l=a;let c;return n[3]!==e?(c=[e,l],n[3]=e,n[4]=c):c=n[4],c}const WC=b.memo(function(e){const t=U.c(20),{text:s,model:o,effort:i,timestamp:a,compact:l}=e,c=l===void 0?!1:l;let d;t[0]!==s?(d=D1(s),t[0]=s,t[1]=d):d=t[1];const f=d,[u,m]=ho();if(!s)return null;let p;t[2]!==c||t[3]!==u||t[4]!==m||t[5]!==i||t[6]!==o||t[7]!==s||t[8]!==a?(p=!c&&r.jsxs("div",{className:"mb-1 flex min-h-6 items-center justify-end gap-1.5",children:[o&&r.jsx("span",{className:"text-xs text-muted-foreground",children:Zi(o)}),i&&r.jsx("span",{className:"text-xs text-muted-foreground",title:`Reasoning effort: ${i}`,children:i}),(o||i)&&a&&r.jsx("span",{className:"text-xs text-muted-foreground",children:"·"}),a&&r.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(a).toLocaleTimeString()}),r.jsx(X,{variant:"ghost",size:"icon-sm",className:"opacity-60 transition-opacity hover:opacity-100 focus-visible:opacity-100 sm:opacity-0 sm:group-hover:opacity-100",onClick:()=>m(s),"aria-label":u?"Response copied":"Copy response",title:u?"Copied":"Copy response",children:u?r.jsx(dt,{"data-icon":"inline-start"}):r.jsx(En,{"data-icon":"inline-start"})})]}),t[2]=c,t[3]=u,t[4]=m,t[5]=i,t[6]=o,t[7]=s,t[8]=a,t[9]=p):p=t[9];const h=c&&"leading-relaxed";let g;t[10]!==h?(g=G("overflow-hidden break-words text-sm",h),t[10]=h,t[11]=g):g=t[11];let x;t[12]!==f?(x=r.jsx(Pn,{components:$n,remarkPlugins:Bs,children:f}),t[12]=f,t[13]=x):x=t[13];let v;t[14]!==g||t[15]!==x?(v=r.jsx("div",{className:g,children:x}),t[14]=g,t[15]=x,t[16]=v):v=t[16];let w;return t[17]!==p||t[18]!==v?(w=r.jsxs("div",{className:"group",children:[p,v]}),t[17]=p,t[18]=v,t[19]=w):w=t[19],w}),no=[];function HC(n){return n.map(e=>({messageId:e.messageId,parentToolUseId:e.parentToolUseId,stopped:e.stopped,...e.stopped?{stoppedAt:Date.now()}:{},blocks:e.blocks.map(t=>({...t}))}))}function KC(n,e){if(e.length===0)return n;const t=n.slice(),s=new Map,o=i=>{let a=s.get(i.messageId);if(a)return a;const l=t.findIndex(c=>c.messageId===i.messageId);return l>=0?(a={...t[l],blocks:t[l].blocks.map(c=>({...c}))},t[l]=a):(a={messageId:i.messageId,parentToolUseId:i.parentToolUseId,stopped:!1,blocks:[]},t.push(a)),s.set(i.messageId,a),a};for(const i of e){const a=o(i);if(i.event==="message_stop"){a.stopped=!0,a.stoppedAt=Date.now();continue}let l=a.blocks.find(c=>c.index===i.blockIndex);l||(l={index:i.blockIndex,blockType:i.blockType,...i.toolName?{toolName:i.toolName}:{},text:""},a.blocks.push(l)),i.delta&&(l.text+=i.delta)}return t}const em=/"id"\s*:\s*"(msg_[A-Za-z0-9]+)"/g;function qC(n,e){if(n.length===0||e.length===0)return n;const t=new Set;for(const o of e){em.lastIndex=0;let i;for(;(i=em.exec(o))!==null;)t.add(i[1])}if(t.size===0)return n;const s=n.filter(o=>o.parentToolUseId!==null||!t.has(o.messageId));return s.length===n.length?n:s}function VC(n,e=1e4,t=Date.now()){if(n.length===0)return n;const s=n.filter(o=>o.parentToolUseId!==null||!(o.stopped&&o.stoppedAt!==void 0&&t-o.stoppedAt>e));return s.length===n.length?n:s}function GC(n){return n.filter(e=>e.parentToolUseId===null)}function YC(n,e){return n.filter(t=>t.parentToolUseId===e)}const hx={},gx=b.createContext(no),xx=b.createContext(hx);function rl(n){const e=U.c(6),{value:t,agentProgress:s,children:o}=n,i=s===void 0?hx:s;let a;e[0]!==i||e[1]!==o?(a=r.jsx(xx.Provider,{value:i,children:o}),e[0]=i,e[1]=o,e[2]=a):a=e[2];let l;return e[3]!==a||e[4]!==t?(l=r.jsx(gx.Provider,{value:t,children:a}),e[3]=a,e[4]=t,e[5]=l):l=e[5],l}function hd(){return b.useContext(gx)}function XC(n){return b.useContext(xx)[n]??null}function Vs(n){return function({children:t}){return r.jsx(n,{className:"mt-2 mb-1 text-xs font-semibold text-foreground first:mt-0",children:t})}}const bx={...$n,code({className:n,children:e}){return!n&&typeof e=="string"&&!e.includes(`
|
|
88
|
+
`)?r.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[0.9em] text-foreground",children:e}):r.jsx("pre",{className:"my-1.5 overflow-x-auto rounded-md border bg-muted/30 p-2 font-mono text-xs leading-relaxed",children:r.jsx("code",{children:String(e).replace(/\n$/,"")})})},img:()=>null},JC={...bx,h1:Vs("h1"),h2:Vs("h2"),h3:Vs("h3"),h4:Vs("h4"),h5:Vs("h5"),h6:Vs("h6")},vx=b.memo(function(e){const t=U.c(3),{text:s,compactHeadings:o}=e,a=(o===void 0?!1:o)?JC:bx;let l;return t[0]!==a||t[1]!==s?(l=r.jsx(Pn,{components:a,remarkPlugins:Bs,children:s}),t[0]=a,t[1]=s,t[2]=l):l=t[2],l}),tm=400,QC=24,gd=b.memo(function(e){const t=U.c(24),{toolUseId:s}=e,o=hd(),i=XC(s),a=b.useRef(null),[l,c]=b.useState(!0);let d,f,u;if(t[0]!==l||t[1]!==o||t[2]!==s){u=YC(o,s).flatMap(ZC).filter(e_).map(t_).join(`
|
|
89
|
+
`);const N=u.split(`
|
|
90
|
+
`);d=l&&N.length>tm,f=d?N.slice(-tm).join(`
|
|
91
|
+
`):u,t[0]=l,t[1]=o,t[2]=s,t[3]=d,t[4]=f,t[5]=u}else d=t[3],f=t[4],u=t[5];const m=f;let p;t[6]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{const N=a.current;if(!N)return;const C=N.scrollHeight-N.scrollTop-N.clientHeight<QC;c(S=>S===C?S:C)},t[6]=p):p=t[6];const h=p;let g;t[7]!==l?(g=()=>{const N=a.current;if(!N||!l)return;const C=N.scrollHeight-N.clientHeight;N.scrollTop!==C&&(N.scrollTop=C)},t[7]=l,t[8]=g):g=t[8];let x;if(t[9]!==l||t[10]!==m?(x=[m,l],t[9]=l,t[10]=m,t[11]=x):x=t[11],b.useLayoutEffect(g,x),!u&&!i)return null;const v=i?"live-subagent-summary":void 0;let w;t[12]!==i?(w=i??r.jsx("span",{className:"uppercase tracking-wide",children:"Live"}),t[12]=i,t[13]=w):w=t[13];let y;t[14]!==v||t[15]!==w?(y=r.jsx("div",{"data-testid":v,className:"mb-1 text-xs font-medium text-muted-foreground",children:w}),t[14]=v,t[15]=w,t[16]=y):y=t[16];let j;t[17]!==d||t[18]!==m||t[19]!==u?(j=u&&r.jsxs("div",{ref:a,onScroll:h,"data-testid":"live-subagent-scroll",role:"region","aria-label":"Live sub-agent output",tabIndex:0,className:"text-xs break-words max-h-64 overflow-y-auto overscroll-contain pr-1",children:[d&&r.jsx("div",{className:"text-muted-foreground/50",children:"…"}),r.jsx(vx,{text:m,compactHeadings:!0})]}),t[17]=d,t[18]=m,t[19]=u,t[20]=j):j=t[20];let k;return t[21]!==y||t[22]!==j?(k=r.jsxs("div",{className:"mt-2 rounded-md border bg-muted/30 px-3 py-2","data-testid":"live-subagent-transcript",children:[y,j]}),t[21]=y,t[22]=j,t[23]=k):k=t[23],k});function ZC(n){return n.blocks}function e_(n){return n.blockType!=="tool_use"&&n.text}function t_(n){return n.text}function nm(n){return n.length>8?n.slice(0,8):n}function xd(n,e,t){const s=e??t;return s?`${s} - ${nm(n)}`:nm(n)}function n_(n){const e=new Map;for(const t of n)e.has(t.agentId)||e.set(t.agentId,xd(t.agentId,t.subagentType,t.agentName));return e}function s_(n){const e=new Map;for(const s of n)s.parentToolUseId&&!e.has(s.agentId)&&e.set(s.agentId,s.parentToolUseId);const t=new Map;for(const s of e.values())t.set(s,(t.get(s)??0)+1);for(const[s,o]of e)(t.get(o)??0)>1&&e.delete(s);return e}function o_(n){return n?typeof n=="string"?n:n.map(e=>e.type==="text"?e.text:"").filter(Boolean).join(`
|
|
92
|
+
`):""}function yx(n,e){if(b1(n))return rd(n).turns.filter(i=>i.assistantText.length>0||i.thinking.length>0||i.toolCalls.length>0).map(i=>({agentId:e,agentName:null,subagentType:null,type:"assistant",content:i.assistantText.join(`
|
|
93
|
+
|
|
94
|
+
`),toolCalls:i.toolCalls,thinking:i.thinking.map(a=>a.thinking),text:[...i.assistantText],timestamp:i.timestamp,tokenUsage:i.tokenUsage,model:i.model,isBackground:!0}));const t=[],s=new Map;for(const o of n.split(`
|
|
95
|
+
`)){const i=o.trim();if(!i)continue;let a;try{a=JSON.parse(i)}catch{continue}const l=a.type;if(l!=="user"&&l!=="assistant")continue;const c=a.message;if(!c)continue;const d=c.content,f=a.timestamp??"";if(l==="assistant"){const u={agentId:e,agentName:null,subagentType:null,type:"assistant",content:d,toolCalls:[],thinking:[],text:[],timestamp:f,tokenUsage:c.usage?{input_tokens:c.usage.input_tokens??0,output_tokens:c.usage.output_tokens??0,cache_creation_input_tokens:c.usage.cache_creation_input_tokens??0,cache_read_input_tokens:c.usage.cache_read_input_tokens??0}:null,model:c.model??null,isBackground:!0};if(Array.isArray(d)){for(const m of d)if(m.type==="thinking")u.thinking.push(m.thinking);else if(m.type==="text")u.text.push(m.text);else if(m.type==="tool_use"){const p={id:m.id,name:m.name,input:m.input,result:null,isError:!1,timestamp:f};u.toolCalls.push(p),s.set(m.id,p)}}t.push(u)}else if(l==="user"&&Array.isArray(d)){for(const u of d)if(u.type==="tool_result"){const m=s.get(u.tool_use_id);m&&(m.result=o_(u.content),m.isError=u.is_error??!1)}}}return t}const il=new Map;function r_(n,e){const t=U.c(21),{session:s,sessionSource:o,isLive:i}=it();let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=new Map,t[0]=a):a=t[0];const[l,c]=b.useState(a),[d,f]=b.useState(!1);let u;t[1]===Symbol.for("react.memo_cache_sentinel")?(u=new Set,t[1]=u):u=t[1];const m=b.useRef(u);let p;if(t[2]!==i||t[3]!==n){let _;t[5]!==i?(_=P=>P.text.length>0||P.thinking.length>0||P.toolCalls.length>0?!1:i?P.durationMs!=null:P.status==="async_launched",t[5]=i,t[6]=_):_=t[6],p=n.filter(_),t[2]=i,t[3]=n,t[4]=p}else p=t[4];const h=p,g=o==null?void 0:o.dirName,x=s==null?void 0:s.sessionId;let v;t[7]===Symbol.for("react.memo_cache_sentinel")?(v=oa(window.location.pathname),t[7]=v):v=t[7];const w=v;let y,j;t[8]!==h||t[9]!==g||t[10]!==e||t[11]!==x?(y=()=>{if(w||!e||!g||!x||h.length===0)return;const _=[];for(const E of h){const T=Lt(`${g}/${x}/${E.agentId}`);if(!m.current.has(T)){if(il.has(T)){c(M=>{const I=new Map(M);return I.set(E.agentId,il.get(T)),I}),m.current.add(T);continue}_.push({agentId:E.agentId,cacheKey:T})}}if(_.length===0)return;let P=!1;return f(!0),async function(){const T=new Map;await Promise.all(_.map(async M=>{const{agentId:I,cacheKey:R}=M;try{const $=`/api/sessions/${encodeURIComponent(g)}/${encodeURIComponent(x)}/subagents/agent-${encodeURIComponent(I)}.jsonl`,D=await ye($);if(!D.ok)return;const O=await D.text(),L=yx(O,I);il.set(R,L),m.current.add(R),T.set(I,L)}catch{}})),!P&&T.size>0&&c(M=>{const I=new Map(M);for(const[R,$]of T)I.set(R,$);return I}),P||f(!1)}(),()=>{P=!0}},j=[w,e,g,x,h],t[8]=h,t[9]=g,t[10]=e,t[11]=x,t[12]=y,t[13]=j):(y=t[12],j=t[13]),b.useEffect(y,j);let k;e:{if(l.size===0&&h.length===0){k=n;break e}let _;if(t[14]!==l||t[15]!==n){_=[];for(const P of n){const A=l.get(P.agentId);if(A&&A.length>0&&(P.status==="async_launched"||P.durationMs!=null)){const E={...A[0],durationMs:P.durationMs,toolUseCount:P.toolUseCount,status:P.status,prompt:P.prompt,agentName:P.agentName,subagentType:P.subagentType};_.push(E,...A.slice(1))}else _.push(P)}t[14]=l,t[15]=n,t[16]=_}else _=t[16];k=_}const N=k,C=w&&e&&h.length>0;let S;return t[17]!==N||t[18]!==d||t[19]!==C?(S={enrichedMessages:N,isLoading:d,unavailable:C},t[17]=N,t[18]=d,t[19]=C,t[20]=S):S=t[20],S}const wx=b.memo(function(e){const t=U.c(74),{messages:s,expandAll:o,label:i,countLabel:a,lazyLoad:l}=e,c=l===void 0?!1:l,[d,f]=b.useState(!1),u=o||d,{sessionSource:m,actions:p}=it(),h=m==null?void 0:m.dirName;let g;t[0]!==h?(g=uo(h),t[0]=h,t[1]=g):g=t[1];const x=g.subagentTranscripts,{enrichedMessages:v,isLoading:w,unavailable:y}=r_(s,c&&u&&x);let j;e:{if(!(m!=null&&m.fileName)){j=null;break e}let Q;t[2]!==m.fileName?(Q=bs(m.fileName),t[2]=m.fileName,t[3]=Q):Q=t[3];const ee=Q;if(ee){j=ee.parentSessionId;break e}let oe;if(t[4]!==m.fileName){let re;t[6]===Symbol.for("react.memo_cache_sentinel")?(re=/^([^/]+)\.jsonl$/,t[6]=re):re=t[6],oe=m.fileName.match(re),t[4]=m.fileName,t[5]=oe}else oe=t[5];const se=oe;j=(se==null?void 0:se[1])??null}const k=j;let N;t[7]!==v?(N=new Set(v.map(a_)),t[7]=v,t[8]=N):N=t[8];let C;t[9]!==N?(C=[...N],t[9]=N,t[10]=C):C=t[10];const S=C;let _;t[11]!==v?(_=n_(v),t[11]=v,t[12]=_):_=t[12];const P=_;let A;if(t[13]!==v||t[14]!==s){A=new Map;for(const Q of[...s,...v]){const ee=A.get(Q.agentId)??{};Q.durationMs!=null&&(ee.durationMs=Q.durationMs),Q.toolUseCount!=null&&(ee.toolUseCount=Q.toolUseCount),Q.status&&(ee.status=Q.status),A.set(Q.agentId,ee)}t[13]=v,t[14]=s,t[15]=A}else A=t[15];const E=A;let T;t[16]!==v||t[17]!==s?(T=s_([...s,...v]),t[16]=v,t[17]=s,t[18]=T):T=t[18];const M=T;let I,R;if(t[19]!==v){R=new Map,I=new Map;for(const Q of v)I.set(Q.agentId,Q),Q.text.length>0&&R.set(Q.agentId,Q);t[19]=v,t[20]=I,t[21]=R}else I=t[20],R=t[21];let $;if(t[22]!==S||t[23]!==I||t[24]!==R){$=new Map;for(const Q of S){const ee=R.get(Q)??I.get(Q);ee&&$.set(Q,ee)}t[22]=S,t[23]=I,t[24]=R,t[25]=$}else $=t[25];const D=$;let O;e:{let Q=0,ee=0,oe=!1,se=!0;for(const ie of s)ie.durationMs!=null&&(Q=Q+ie.durationMs,oe=!0),ie.toolUseCount!=null&&(ee=ee+ie.toolUseCount),ie.status&&ie.status!=="completed"&&(se=!1);if(!oe){O=null;break e}let re;t[26]!==se||t[27]!==Q||t[28]!==ee?(re={totalDuration:Q,totalToolUses:ee,allCompleted:se},t[26]=se,t[27]=Q,t[28]=ee,t[29]=re):re=t[29],O=re}const L=O;if(s.length===0)return null;let z;t[30]!==d?(z=()=>f(!d),t[30]=d,t[31]=z):z=t[31];let F;t[32]!==u?(F=u?r.jsx(nt,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}):r.jsx(Ze,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),t[32]=u,t[33]=F):F=t[33];let H;t[34]===Symbol.for("react.memo_cache_sentinel")?(H=r.jsx(Wn,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),t[34]=H):H=t[34];let B;t[35]!==i?(B=r.jsx("span",{className:"text-xs font-medium text-foreground",children:i}),t[35]=i,t[36]=B):B=t[36];let W;t[37]!==S.length||t[38]!==a?(W=S.length>1&&r.jsxs(Me,{variant:"secondary",children:[S.length," ",a]}),t[37]=S.length,t[38]=a,t[39]=W):W=t[39];let K;t[40]!==S||t[41]!==P?(K=S.map(Q=>r.jsx(Me,{variant:"outline",children:P.get(Q)},Q)),t[40]=S,t[41]=P,t[42]=K):K=t[42];let V;t[43]!==S.length||t[44]!==L?(V=L?r.jsxs("span",{className:"inline-flex items-center gap-2 text-xs text-muted-foreground",children:[L.allCompleted?r.jsx(Un,{className:"size-3 text-success","data-icon":"inline-start"}):r.jsx(zs,{className:"size-3 text-destructive","data-icon":"inline-start"}),r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(Ms,{className:"size-3","data-icon":"inline-start"}),Tn(L.totalDuration)]}),L.totalToolUses>0&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(Fi,{className:"size-3","data-icon":"inline-start"}),L.totalToolUses]})]}):r.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",S.length," agent",S.length!==1?"s":"",")"]}),t[43]=S.length,t[44]=L,t[45]=V):V=t[45];let Y;t[46]!==z||t[47]!==F||t[48]!==B||t[49]!==W||t[50]!==K||t[51]!==V?(Y=r.jsxs(X,{type:"button",variant:"ghost",onClick:z,className:"h-auto w-full min-w-0 flex-wrap justify-start gap-2 px-0 py-1 text-left whitespace-normal",children:[F,H,B,W,K,V]}),t[46]=z,t[47]=F,t[48]=B,t[49]=W,t[50]=K,t[51]=V,t[52]=Y):Y=t[52];let q;t[53]!==S||t[54]!==u||t[55]!==M?(q=!u&&S.map(Q=>{const ee=M.get(Q);return ee?r.jsx(gd,{toolUseId:ee},Q):null}),t[53]=S,t[54]=u,t[55]=M,t[56]=q):q=t[56];let J;t[57]!==p||t[58]!==S||t[59]!==P||t[60]!==D||t[61]!==x||t[62]!==w||t[63]!==u||t[64]!==k||t[65]!==M||t[66]!==m||t[67]!==E||t[68]!==y?(J=u&&r.jsxs("div",{className:"motion-enter mt-2 flex flex-col gap-2",children:[y?r.jsx("div",{className:"py-1 text-xs italic text-muted-foreground",children:"Sub-agent transcripts aren't available in a shared session."}):w&&r.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground py-1",children:[r.jsx(rt,{className:"size-3 animate-spin"}),"Loading agent output..."]}),S.map(Q=>{const ee=D.get(Q),oe=E.get(Q),se=x&&!!m&&!!k&&!y;return r.jsx(i_,{agentLabel:P.get(Q)??Q,message:ee,stats:oe,parentToolUseId:M.get(Q),canNavigate:se,onOpen:()=>{se&&p.handleLoadSession(m.dirName,`${k}/subagents/agent-${Q}.jsonl`)}},Q)})]}),t[57]=p,t[58]=S,t[59]=P,t[60]=D,t[61]=x,t[62]=w,t[63]=u,t[64]=k,t[65]=M,t[66]=m,t[67]=E,t[68]=y,t[69]=J):J=t[69];let Z;return t[70]!==Y||t[71]!==q||t[72]!==J?(Z=r.jsxs("div",{children:[Y,q,J]}),t[70]=Y,t[71]=q,t[72]=J,t[73]=Z):Z=t[73],Z});function i_(n){const e=U.c(22),{agentLabel:t,message:s,stats:o,parentToolUseId:i,canNavigate:a,onOpen:l}=n,c=s==null?void 0:s.text;let d;e[0]!==c?(d=D1((c??[]).join(`
|
|
96
|
+
|
|
97
|
+
`)),e[0]=c,e[1]=d):d=e[1];const f=d,u=((c==null?void 0:c.length)??0)>0,m=(o==null?void 0:o.status)!=null&&o.status!=="completed"&&o.status!=="async_launched",p=(o==null?void 0:o.status)==="completed";let h;e[2]!==t?(h=r.jsx(Me,{variant:"outline",children:t}),e[2]=t,e[3]=h):h=e[3];let g;e[4]!==p||e[5]!==o?(g=o&&r.jsxs("span",{className:"inline-flex items-center gap-2 text-xs text-muted-foreground",children:[p&&r.jsx(Un,{className:"size-3 text-success"}),o.durationMs!=null&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(Ms,{className:"size-3"}),Tn(o.durationMs)]}),o.toolUseCount!=null&&o.toolUseCount>0&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(Fi,{className:"size-3"}),o.toolUseCount]})]}),e[4]=p,e[5]=o,e[6]=g):g=e[6];let x;e[7]!==a||e[8]!==l?(x=a&&r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:l,className:"ml-auto",title:"Open this sub-agent's full chat session",children:[r.jsx(Xp,{"data-icon":"inline-start"}),"Open chat"]}),e[7]=a,e[8]=l,e[9]=x):x=e[9];let v;e[10]!==h||e[11]!==g||e[12]!==x?(v=r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[h,g,x]}),e[10]=h,e[11]=g,e[12]=x,e[13]=v):v=e[13];let w;e[14]!==u||e[15]!==m||e[16]!==f||e[17]!==i?(w=u?r.jsx("div",{className:"text-xs break-words overflow-hidden",children:r.jsx(Pn,{components:$n,remarkPlugins:Bs,children:f})}):r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("div",{className:"inline-flex items-center gap-1.5 text-xs italic text-muted-foreground",children:m?r.jsxs(r.Fragment,{children:[r.jsx(rt,{className:"size-3 animate-spin"}),"Working — no return yet"]}):r.jsx(r.Fragment,{children:"No return message from this agent"})}),i&&r.jsx(gd,{toolUseId:i})]}),e[14]=u,e[15]=m,e[16]=f,e[17]=i,e[18]=w):w=e[18];let y;return e[19]!==v||e[20]!==w?(y=r.jsx("div",{className:"border-l pl-3",children:r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[v,w]})}),e[19]=v,e[20]=w,e[21]=y):y=e[21],y}function a_(n){return n.agentId}const l_=b.memo(function(e){const t=U.c(3),{messages:s,expandAll:o}=e;let i;return t[0]!==o||t[1]!==s?(i=r.jsx(wx,{messages:s,expandAll:o,label:"Sub-agent activity",countLabel:"subagents active",lazyLoad:!0}),t[0]=o,t[1]=s,t[2]=i):i=t[2],i}),c_=b.memo(function(e){const t=U.c(3),{messages:s,expandAll:o}=e;let i;return t[0]!==o||t[1]!==s?(i=r.jsx(wx,{messages:s,expandAll:o,label:"Background agent activity",countLabel:"agents active",lazyLoad:!0}),t[0]=o,t[1]=s,t[2]=i):i=t[2],i}),d_=new Set(["StopFailure","PermissionDenied","PostToolUseFailure"]),u_=b.memo(function(e){const t=U.c(30),{events:s}=e,[o,i]=b.useState(!1);if(s.length===0)return null;let a;t[0]!==s?(a=s.some(f_),t[0]=s,t[1]=a):a=t[1];const l=a,c=o?nt:Ze,d=l?"border-destructive/20 bg-destructive/5":"bg-muted/30";let f;t[2]!==d?(f=G("my-1 rounded-md border px-2 py-1 text-xs",d),t[2]=d,t[3]=f):f=t[3];let u;t[4]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(X,{type:"button",variant:"ghost",size:"sm",className:"h-auto w-full justify-start px-0 py-0 text-left font-normal text-muted-foreground"}),t[4]=u):u=t[4];let m;t[5]!==c?(m=r.jsx(c,{className:"size-3 shrink-0","data-icon":"inline-start"}),t[5]=c,t[6]=m):m=t[6];let p;t[7]!==l?(p=l?r.jsx(bn,{className:"size-3 text-destructive","data-icon":"inline-start"}):r.jsx(gv,{className:"size-3","data-icon":"inline-start"}),t[7]=l,t[8]=p):p=t[8];const h=s.length===1?"":"s";let g;t[9]!==s.length||t[10]!==h?(g=r.jsxs("span",{className:"font-mono",children:[s.length," hook event",h]}),t[9]=s.length,t[10]=h,t[11]=g):g=t[11];let x;t[12]!==s?(x=s.map(m_).join(", "),t[12]=s,t[13]=x):x=t[13];let v;t[14]!==x?(v=r.jsx("span",{className:"truncate text-muted-foreground/60",children:x}),t[14]=x,t[15]=v):v=t[15];let w;t[16]!==v||t[17]!==m||t[18]!==p||t[19]!==g?(w=r.jsxs(an,{render:u,children:[m,p,g,v]}),t[16]=v,t[17]=m,t[18]=p,t[19]=g,t[20]=w):w=t[20];let y;t[21]!==s?(y=s.map(p_),t[21]=s,t[22]=y):y=t[22];let j;t[23]!==y?(j=r.jsx(Nt,{children:r.jsx("ul",{className:"ml-5 mt-1 flex flex-col gap-0.5 font-mono",children:y})}),t[23]=y,t[24]=j):j=t[24];let k;return t[25]!==o||t[26]!==w||t[27]!==j||t[28]!==f?(k=r.jsxs(kt,{open:o,onOpenChange:i,className:f,children:[w,j]}),t[25]=o,t[26]=w,t[27]=j,t[28]=f,t[29]=k):k=t[29],k});function f_(n){return d_.has(n.eventName)||n.exitCode!==void 0&&n.exitCode!==0}function m_(n){return n.eventName}function p_(n,e){return r.jsxs("li",{className:"text-muted-foreground/80",children:[r.jsx("span",{className:"text-foreground",children:n.eventName}),n.toolName&&r.jsxs("span",{children:[" · ",n.toolName]}),n.source&&r.jsxs("span",{className:"text-muted-foreground/50",children:[" (",n.source,")"]}),n.decision&&r.jsxs("span",{className:"text-warning",children:[" → ",n.decision]}),n.durationMs!==void 0&&r.jsxs("span",{className:"text-muted-foreground/50",children:[" ",n.durationMs,"ms"]}),n.exitCode!==void 0&&n.exitCode!==0&&r.jsxs("span",{className:"text-destructive",children:[" exit ",n.exitCode]}),n.stderr&&r.jsx("pre",{className:"ml-2 mt-0.5 whitespace-pre-wrap text-destructive",children:n.stderr.slice(0,500)}),n.updatedToolOutput&&r.jsx("span",{className:"text-info",children:" · output replaced by hook"}),n.sessionTitle&&r.jsxs("span",{className:"text-foreground",children:[" · title: ",n.sessionTitle]}),n.worktreePath&&r.jsxs("span",{className:"text-success",children:[" · path: ",n.worktreePath]})]},e)}const sm=768;function va(){const n=U.c(2),[e,t]=b.useState(typeof window<"u"?window.innerWidth<sm:!1);let s,o;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{const i=window.matchMedia(`(max-width: ${sm-1}px)`),a=l=>t(l.matches);return i.addEventListener("change",a),t(i.matches),()=>i.removeEventListener("change",a)},o=[],n[0]=s,n[1]=o):(s=n[0],o=n[1]),b.useEffect(s,o),e}const h_=24,Po=[];function g_(n,e){for(let s=0;s<Po.length;s++){const o=Po[s];if(o.oldStr===n&&o.newStr===e)return o.result}const t=b_(n,e);return Po.length>=h_&&Po.shift(),Po.push({oldStr:n,newStr:e,result:t}),t}const x_=25e4;function b_(n,e){const t=n.split(`
|
|
98
|
+
`),s=e.split(`
|
|
99
|
+
`),o=t.length,i=s.length;let a=0;for(;a<o&&a<i&&t[a]===s[a];)a++;let l=0;for(;l<o-a&&l<i-a&&t[o-1-l]===s[i-1-l];)l++;const c=o-a-l,d=i-a-l,f=[];for(let u=0;u<a;u++)f.push({type:"unchanged",text:t[u],oldIdx:u,newIdx:u});if(!(c===0&&d===0))if(c===0)for(let u=0;u<d;u++)f.push({type:"added",text:s[a+u],newIdx:a+u});else if(d===0)for(let u=0;u<c;u++)f.push({type:"removed",text:t[a+u],oldIdx:a+u});else if(c*d>x_){for(let u=0;u<c;u++)f.push({type:"removed",text:t[a+u],oldIdx:a+u});for(let u=0;u<d;u++)f.push({type:"added",text:s[a+u],newIdx:a+u})}else{const u=d+1,m=new Int32Array((c+1)*u);for(let x=1;x<=c;x++){const v=t[a+x-1],w=x*u,y=w-u;for(let j=1;j<=d;j++)if(v===s[a+j-1])m[w+j]=m[y+j-1]+1;else{const k=m[y+j],N=m[w+j-1];m[w+j]=k>N?k:N}}const p=[];let h=c,g=d;for(;h>0||g>0;)h>0&&g>0&&t[a+h-1]===s[a+g-1]?(p.push({type:"unchanged",text:t[a+h-1],oldIdx:a+h-1,newIdx:a+g-1}),h--,g--):g>0&&(h===0||m[h*u+g-1]>=m[(h-1)*u+g])?(p.push({type:"added",text:s[a+g-1],newIdx:a+g-1}),g--):(p.push({type:"removed",text:t[a+h-1],oldIdx:a+h-1}),h--);p.reverse(),f.push(...p)}for(let u=0;u<l;u++){const m=o-l+u,p=i-l+u;f.push({type:"unchanged",text:t[m],oldIdx:m,newIdx:p})}return f}function v_(n,e,t,s){const o=U.c(9),[i,a]=b.useState(null),[l,c]=b.useState(null);let d,f;o[0]!==t||o[1]!==s||o[2]!==e||o[3]!==n?(d=()=>{const m=Eg(t);if(!m){a(null),c(null);return}const p=s?"github-dark":"github-light";let h=!1;const g=requestAnimationFrame(()=>{h||_g().then(async x=>{if(h||(await Tg(x,m),h))return;const v=x.codeToTokens(n,{lang:m,theme:p});if(h)return;a(v.tokens);const w=x.codeToTokens(e,{lang:m,theme:p});h||c(w.tokens)}).catch(x=>{console.warn("[EditDiffView] highlight failed:",x),h||(a(null),c(null))})});return()=>{h=!0,cancelAnimationFrame(g)}},f=[n,e,t,s],o[0]=t,o[1]=s,o[2]=e,o[3]=n,o[4]=d,o[5]=f):(d=o[4],f=o[5]),b.useEffect(d,f);let u;return o[6]!==l||o[7]!==i?(u={oldTokens:i,newTokens:l},o[6]=l,o[7]=i,o[8]=u):u=o[8],u}const y_={removed:"bg-destructive/10",added:"bg-success/10",unchanged:""},om={removed:"border-destructive/20 text-destructive/70",added:"border-success/20 text-success/70",unchanged:"border-border text-muted-foreground"},w_={removed:"text-destructive",added:"text-success",unchanged:"text-muted-foreground"};function j_(n,e){return n.map((t,s)=>r.jsx("span",{style:{color:t.color},className:G(e&&"opacity-50"),children:t.content},s))}function S_(n,e,t){switch(n.type){case"removed":return e==null?void 0:e[n.oldIdx??-1];case"added":return t==null?void 0:t[n.newIdx??-1];case"unchanged":return(t==null?void 0:t[n.newIdx??-1])??(e==null?void 0:e[n.oldIdx??-1])}}function k_(n){const e=U.c(3),{type:t}=n;switch(t){case"removed":{let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Gp,{className:"inline size-3","data-icon":"icon"}),e[0]=s):s=e[0],s}case"added":{let s;return e[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(_n,{className:"inline size-3","data-icon":"icon"}),e[1]=s):s=e[1],s}default:{let s;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx("span",{className:"inline-block size-3","aria-hidden":"true"}),e[2]=s):s=e[2],s}}}const al=3;function N_(n){if(n.length===0)return[];const e=new Set;for(let i=0;i<n.length;i++)n[i].type!=="unchanged"&&e.add(i);if(e.size===0||n.length<=al*2+3)return n.map((i,a)=>({kind:"line",line:i,originalIdx:a}));const t=new Set;for(const i of e)for(let a=Math.max(0,i-al);a<=Math.min(n.length-1,i+al);a++)t.add(a);const s=[];let o=0;for(;o<n.length;)if(t.has(o))s.push({kind:"line",line:n[o],originalIdx:o}),o++;else{const i=o;let a=0;for(;o<n.length&&!t.has(o);)a++,o++;s.push({kind:"separator",count:a,fromIdx:i,toIdx:o-1})}return s}function C_(n){const e=U.c(7),{count:t,onExpand:s}=n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(Hi,{className:"shrink-0","data-icon":"inline-start"}),e[0]=o):o=e[0];let i;e[1]!==t?(i=r.jsxs("span",{className:"font-mono",children:[t," unchanged lines"]}),e[1]=t,e[2]=i):i=e[2];let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("span",{className:"flex-1 border-b border-border"}),e[3]=a):a=e[3];let l;return e[4]!==s||e[5]!==i?(l=r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:s,className:"h-auto w-full justify-start rounded-none px-2 py-1 text-xs text-muted-foreground",children:[o,i,a]}),e[4]=s,e[5]=i,e[6]=l):l=e[6],l}const rm=b.memo(function(e){const t=U.c(33),{line:s,lineNum:o,oldTokens:i,newTokens:a}=e;let l,c,d,f,u,m;if(t[0]!==s||t[1]!==o||t[2]!==a||t[3]!==i){m=S_(s,i,a);const x=y_[s.type];t[10]!==x?(d=G("flex",x),t[10]=x,t[11]=d):d=t[11];const v=om[s.type];let w;t[12]!==v?(w=G("w-8 shrink-0 select-none border-r pr-1 text-right text-xs leading-relaxed tabular-nums",v),t[12]=v,t[13]=w):w=t[13],t[14]!==o||t[15]!==w?(f=r.jsx("span",{className:w,children:o}),t[14]=o,t[15]=w,t[16]=f):f=t[16];const y=om[s.type];let j;t[17]!==y?(j=G("select-none shrink-0 w-5 text-right pr-1 border-r",y),t[17]=y,t[18]=j):j=t[18];let k;t[19]!==s.type?(k=r.jsx(k_,{type:s.type}),t[19]=s.type,t[20]=k):k=t[20],t[21]!==j||t[22]!==k?(u=r.jsx("span",{className:j,children:k}),t[21]=j,t[22]=k,t[23]=u):u=t[23],l="pl-2 whitespace-pre",c=m?j_(m,s.type==="unchanged"):r.jsx("span",{className:w_[s.type],children:s.text||" "}),t[0]=s,t[1]=o,t[2]=a,t[3]=i,t[4]=l,t[5]=c,t[6]=d,t[7]=f,t[8]=u,t[9]=m}else l=t[4],c=t[5],d=t[6],f=t[7],u=t[8],m=t[9];const p=m&&m.length===0&&" ";let h;t[24]!==l||t[25]!==c||t[26]!==p?(h=r.jsxs("span",{className:l,children:[c,p]}),t[24]=l,t[25]=c,t[26]=p,t[27]=h):h=t[27];let g;return t[28]!==d||t[29]!==f||t[30]!==u||t[31]!==h?(g=r.jsxs("div",{className:d,children:[f,u,h]}),t[28]=d,t[29]=f,t[30]=u,t[31]=h,t[32]=g):g=t[32],g}),im=120,am=60,__=120;function lm(n){const e=U.c(34),{lines:t,oldTokens:s,newTokens:o,compact:i,startLine:a}=n,l=a===void 0?1:a;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=new Set,e[0]=c):c=e[0];const[d,f]=b.useState(c);let u;e[1]!==t?(u=N_(t),e[1]=t,e[2]=u):u=e[2];const m=u,p=m.length>im,[h,g]=b.useState(p?am:m.length);let x;e[3]!==m.length?(x=()=>{g(m.length>im?am:m.length)},e[3]=m.length,e[4]=x):x=e[4];let v;e[5]!==m?(v=[m],e[5]=m,e[6]=v):v=e[6],b.useEffect(x,v);let w,y;e[7]!==m.length||e[8]!==h?(w=()=>{if(h>=m.length)return;const E=requestAnimationFrame(()=>{g(T=>Math.min(T+__,m.length))});return()=>cancelAnimationFrame(E)},y=[h,m.length],e[7]=m.length,e[8]=h,e[9]=w,e[10]=y):(w=e[9],y=e[10]),b.useEffect(w,y);let j;e[11]===Symbol.for("react.memo_cache_sentinel")?(j=E=>{f(T=>new Set(T).add(E))},e[11]=j):j=e[11];const k=j;let N;e[12]!==m||e[13]!==p||e[14]!==h?(N=p?m.slice(0,h):m,e[12]=m,e[13]=p,e[14]=h,e[15]=N):N=e[15];const C=N,S=i&&"max-h-64 overflow-y-auto";let _;e[16]!==S?(_=G("overflow-x-auto font-mono text-xs leading-relaxed",S),e[16]=S,e[17]=_):_=e[17];let P;if(e[18]!==d||e[19]!==C||e[20]!==t||e[21]!==o||e[22]!==s||e[23]!==l){let E;e[25]!==d||e[26]!==t||e[27]!==o||e[28]!==s||e[29]!==l?(E=(T,M)=>{if(T.kind==="separator")return d.has(T.fromIdx)?t.slice(T.fromIdx,T.toIdx+1).map(($,D)=>{const O=T.fromIdx+D;return r.jsx(rm,{line:$,lineNum:$.type==="removed"?($.oldIdx??0)+l:($.newIdx??0)+l,oldTokens:s,newTokens:o},`exp-${O}`)}):r.jsx(C_,{count:T.count,onExpand:()=>k(T.fromIdx)},`sep-${M}`);const{line:I}=T,R=I.type==="removed"?(I.oldIdx??0)+l:(I.newIdx??0)+l;return r.jsx(rm,{line:I,lineNum:R,oldTokens:s,newTokens:o},M)},e[25]=d,e[26]=t,e[27]=o,e[28]=s,e[29]=l,e[30]=E):E=e[30],P=C.map(E),e[18]=d,e[19]=C,e[20]=t,e[21]=o,e[22]=s,e[23]=l,e[24]=P}else P=e[24];let A;return e[31]!==_||e[32]!==P?(A=r.jsx("div",{className:_,children:P}),e[31]=_,e[32]=P,e[33]=A):A=e[33],A}function cm(n){const e=U.c(11),{lines:t}=n;let s=0,o=0;for(const m of t)m.type==="added"?s++:m.type==="removed"&&o++;let i;e[0]!==s||e[1]!==o?(i={added:s,removed:o},e[0]=s,e[1]=o,e[2]=i):i=e[2];const{added:a,removed:l}=i;let c;e[3]!==l?(c=l>0&&r.jsxs("span",{className:"text-destructive",children:["-",l]}),e[3]=l,e[4]=c):c=e[4];const d=l>0&&a>0&&" ";let f;e[5]!==a?(f=a>0&&r.jsxs("span",{className:"text-success",children:["+",a]}),e[5]=a,e[6]=f):f=e[6];let u;return e[7]!==c||e[8]!==d||e[9]!==f?(u=r.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:[c,d,f]}),e[7]=c,e[8]=d,e[9]=f,e[10]=u):u=e[10],u}function bd(n){const e=U.c(34),{oldString:t,newString:s,filePath:o,compact:i,startLine:a,hideHeader:l}=n,c=i===void 0?!0:i,d=a===void 0?1:a,f=l===void 0?!1:l,[u,m]=b.useState(!1),p=_r();let h;e[0]!==s||e[1]!==t?(h=g_(t,s),e[0]=s,e[1]=t,e[2]=h):h=e[2];const g=h,{oldTokens:x,newTokens:v}=v_(t,s,o,p);let w;e[3]!==o?(w=o.split("/").slice(-3).join("/"),e[3]=o,e[4]=w):w=e[4];const y=w,j=c&&"mt-1.5",k=f&&"border-0 rounded-none";let N;e[5]!==j||e[6]!==k?(N=G("overflow-hidden rounded border border-border bg-muted/20",j,k),e[5]=j,e[6]=k,e[7]=N):N=e[7];let C;e[8]!==f||e[9]!==c||e[10]!==g||e[11]!==y?(C=!f&&r.jsxs("div",{className:"flex items-center justify-between border-b border-border bg-muted/40 px-2 py-1",children:[r.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",children:y}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(cm,{lines:g}),c&&r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>m(!0),className:"text-muted-foreground",title:"Expand diff","aria-label":"Expand diff",children:r.jsx(Ui,{"data-icon":"icon"})})]})]}),e[8]=f,e[9]=c,e[10]=g,e[11]=y,e[12]=C):C=e[12];let S;e[13]!==c||e[14]!==g||e[15]!==v||e[16]!==x||e[17]!==d?(S=r.jsx(lm,{lines:g,oldTokens:x,newTokens:v,compact:c,startLine:d}),e[13]=c,e[14]=g,e[15]=v,e[16]=x,e[17]=d,e[18]=S):S=e[18];let _;e[19]!==S||e[20]!==N||e[21]!==C?(_=r.jsxs("div",{className:N,children:[C,S]}),e[19]=S,e[20]=N,e[21]=C,e[22]=_):_=e[22];let P;e[23]!==o||e[24]!==c||e[25]!==g||e[26]!==u||e[27]!==v||e[28]!==x||e[29]!==d?(P=c&&r.jsx(Gn,{open:u,onOpenChange:m,children:r.jsxs(Yn,{className:"flex max-h-[85vh] flex-col border-border bg-background sm:max-w-4xl",children:[r.jsxs(Ss,{children:[r.jsxs(Xn,{className:"font-mono text-sm text-foreground flex items-center gap-3",children:[o,r.jsx(cm,{lines:g})]}),r.jsx(Jn,{className:"sr-only",children:"Diff view for edit operation"})]}),r.jsx("div",{className:"flex-1 overflow-auto rounded border border-border bg-background",children:r.jsx(lm,{lines:g,oldTokens:x,newTokens:v,startLine:d})})]})}),e[23]=o,e[24]=c,e[25]=g,e[26]=u,e[27]=v,e[28]=x,e[29]=d,e[30]=P):P=e[30];let A;return e[31]!==_||e[32]!==P?(A=r.jsxs(r.Fragment,{children:[_,P]}),e[31]=_,e[32]=P,e[33]=A):A=e[33],A}const T_=new Set(["command","cmd","description","timeout","run_in_background"]);function jx(n){return typeof n!="number"||!Number.isFinite(n)?String(n):n<1e3?`${n} ms`:n%6e4===0?`${n/6e4} min`:n%1e3===0?`${n/1e3} sec`:`${(n/1e3).toFixed(1)} sec`}function Sx(n){return n.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase())}function E_(n){if(typeof n=="string")return n;if(n===null)return"null";if(n===void 0)return"undefined";try{return JSON.stringify(n)}catch{return String(n)}}function P_(n,e){const t=U.c(5),s=_r(),[o,i]=b.useState(null);let a,l;return t[0]!==n||t[1]!==s||t[2]!==e?(a=()=>{let c=!1;return qc(n,e,s).then(d=>{!c&&d&&d.length>0&&i(d)}),()=>{c=!0}},l=[n,s,e],t[0]=n,t[1]=s,t[2]=e,t[3]=a,t[4]=l):(a=t[3],l=t[4]),b.useEffect(a,l),o}function kx(n){const e=U.c(74),{title:t,code:s,language:o,codeLabel:i,copyLabel:a,icon:l,prompt:c,description:d,metadata:f}=n;let u;e[0]!==f?(u=f===void 0?[]:f,e[0]=f,e[1]=u):u=e[1];const m=u,[p,h]=ho(),g=P_(s,o);let x,v,w,y,j,k,N,C,S,_,P;if(e[2]!==l||e[3]!==s||e[4]!==i||e[5]!==p||e[6]!==h||e[7]!==a||e[8]!==d||e[9]!==c||e[10]!==t||e[11]!==g){const $=s.split(`
|
|
100
|
+
`);v=Xt,P="sm",w="mt-1.5";let D;e[23]!==l?(D=r.jsx(l,{className:"size-4","aria-hidden":"true"}),e[23]=l,e[24]=D):D=e[24];let O;e[25]!==D||e[26]!==t?(O=r.jsxs(nn,{className:"flex items-center gap-2",children:[D,t]}),e[25]=D,e[26]=t,e[27]=O):O=e[27];let L;e[28]!==d?(L=d&&r.jsx(sn,{children:d}),e[28]=d,e[29]=L):L=e[29];let z;e[30]!==s||e[31]!==h?(z=()=>h(s),e[30]=s,e[31]=h,e[32]=z):z=e[32];const F=p?`${t} copied`:a,H=p?"Copied":a;let B;e[33]!==p?(B=p?r.jsx(dt,{"data-icon":"inline-start","aria-hidden":"true"}):r.jsx(En,{"data-icon":"inline-start","aria-hidden":"true"}),e[33]=p,e[34]=B):B=e[34];let W;e[35]!==z||e[36]!==F||e[37]!==H||e[38]!==B?(W=r.jsx(vg,{children:r.jsx(X,{type:"button",variant:"ghost",size:"icon-sm",onClick:z,"aria-label":F,title:H,children:B})}),e[35]=z,e[36]=F,e[37]=H,e[38]=B,e[39]=W):W=e[39],e[40]!==O||e[41]!==L||e[42]!==W?(y=r.jsxs(tn,{children:[O,L,W]}),e[40]=O,e[41]=L,e[42]=W,e[43]=y):y=e[43],x=Jt,S="flex items-start gap-2 overflow-x-auto rounded-md bg-muted/50 p-3",e[44]!==c?(_=c&&r.jsx("span",{className:"select-none font-mono text-xs text-muted-foreground","aria-hidden":"true",children:c}),e[44]=c,e[45]=_):_=e[45],C="m-0 min-w-0 flex-1 whitespace-pre-wrap break-words font-mono text-xs leading-relaxed [overflow-wrap:anywhere]",j=i;const K=!g&&"text-foreground";e[46]!==K?(k=G("block",K),e[46]=K,e[47]=k):k=e[47];let V;e[48]!==g?(V=(Y,q)=>{const J=g==null?void 0:g[q];return r.jsx("span",{className:"block min-h-lh",children:J?J.map(R_):Y||" "},q)},e[48]=g,e[49]=V):V=e[49],N=$.map(V),e[2]=l,e[3]=s,e[4]=i,e[5]=p,e[6]=h,e[7]=a,e[8]=d,e[9]=c,e[10]=t,e[11]=g,e[12]=x,e[13]=v,e[14]=w,e[15]=y,e[16]=j,e[17]=k,e[18]=N,e[19]=C,e[20]=S,e[21]=_,e[22]=P}else x=e[12],v=e[13],w=e[14],y=e[15],j=e[16],k=e[17],N=e[18],C=e[19],S=e[20],_=e[21],P=e[22];let A;e[50]!==j||e[51]!==k||e[52]!==N?(A=r.jsx("code",{"aria-label":j,className:k,children:N}),e[50]=j,e[51]=k,e[52]=N,e[53]=A):A=e[53];let E;e[54]!==A||e[55]!==C?(E=r.jsx("pre",{className:C,children:A}),e[54]=A,e[55]=C,e[56]=E):E=e[56];let T;e[57]!==E||e[58]!==S||e[59]!==_?(T=r.jsxs("div",{className:S,children:[_,E]}),e[57]=E,e[58]=S,e[59]=_,e[60]=T):T=e[60];let M;e[61]!==x||e[62]!==T?(M=r.jsx(x,{children:T}),e[61]=x,e[62]=T,e[63]=M):M=e[63];let I;e[64]!==m||e[65]!==t?(I=m.length>0&&r.jsx(So,{className:"items-stretch",children:r.jsx("dl",{className:"grid w-full gap-1.5","aria-label":`${t} options`,children:m.map(A_)})}),e[64]=m,e[65]=t,e[66]=I):I=e[66];let R;return e[67]!==v||e[68]!==w||e[69]!==y||e[70]!==M||e[71]!==I||e[72]!==P?(R=r.jsxs(v,{size:P,className:w,children:[y,M,I]}),e[67]=v,e[68]=w,e[69]=y,e[70]=M,e[71]=I,e[72]=P,e[73]=R):R=e[73],R}function A_(n){const e=n.icon;return r.jsxs("div",{className:"grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-start gap-2 text-xs",children:[r.jsxs("dt",{className:"flex items-center gap-1 text-muted-foreground",children:[e&&r.jsx(e,{className:"size-3","aria-hidden":"true"}),n.label]}),r.jsx("dd",{className:"min-w-0 break-all font-mono text-card-foreground",children:n.value})]},n.key)}function R_(n,e){return r.jsx("span",{style:{color:n.color},children:n.content},e)}function M_(n){const e=[];n.timeout!==void 0&&e.push({key:"timeout",label:"Timeout",value:jx(n.timeout),icon:Ki}),typeof n.run_in_background=="boolean"&&e.push({key:"run_in_background",label:"Execution",value:n.run_in_background?"Background":"Foreground",icon:hr});for(const[t,s]of Object.entries(n))T_.has(t)||s===void 0||e.push({key:t,label:Sx(t),value:E_(s)});return e}function dm(n){const e=U.c(6),{input:t}=n,s=String(t.command??t.cmd??""),o=typeof t.description=="string"?t.description:"";let i;e[0]!==t?(i=M_(t),e[0]=t,e[1]=i):i=e[1];const a=i;let l;return e[2]!==s||e[3]!==o||e[4]!==a?(l=r.jsx(kx,{title:"Command",code:s,language:"bash",codeLabel:"Bash command",copyLabel:"Copy command",icon:co,prompt:"$",description:o,metadata:a}),e[2]=s,e[3]=o,e[4]=a,e[5]=l):l=e[5],l}function um(n,e){const t=n.match(new RegExp(`\\b${e}\\s*:\\s*([\\d_]+)`));if(!t)return null;const s=Number(t[1].replace(/_/g,""));return Number.isFinite(s)?s:null}function I_(n,e){const t=n.match(new RegExp(`\\b${e}\\s*:\\s*["']([^"']+)["']`));return(t==null?void 0:t[1])??null}function fm(n){const e=U.c(5),{input:t}=n,s=String(t.raw??"");let o;e[0]!==s?(o=$_(s),e[0]=s,e[1]=o):o=e[1];const i=o;let a;return e[2]!==i||e[3]!==s?(a=r.jsx(kx,{title:"Tool script",code:s,language:"typescript",codeLabel:"Codex exec script",copyLabel:"Copy script",icon:mr,metadata:i}),e[2]=i,e[3]=s,e[4]=a):a=e[4],a}function $_(n){const e=[],t=new Set(Array.from(n.matchAll(/\btools\.([A-Za-z_$][\w$]*)\s*\(/g),a=>a[1]));for(const a of t)e.push({key:`tool-${a}`,label:"Tool",value:Sx(a)});const s=I_(n,"workdir");s&&e.push({key:"workdir",label:"Working directory",value:s});const o=um(n,"yield_time_ms");o!==null&&e.push({key:"yield-time",label:"Yield",value:jx(o),icon:Ki});const i=um(n,"max_output_tokens");return i!==null&&e.push({key:"output-limit",label:"Output limit",value:`${i.toLocaleString()} tokens`}),e}const O_=Bn("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"}}),Nx=b.createContext({size:"default",variant:"default",spacing:2,orientation:"horizontal"});function Cx(n){const e=U.c(29);let t,s,o,i,a,l,c;e[0]!==n?({className:s,variant:c,size:i,spacing:a,orientation:l,children:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a,e[6]=l,e[7]=c):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5],l=e[6],c=e[7]);const d=a===void 0?2:a,f=l===void 0?"horizontal":l;let u;e[8]!==d?(u={"--gap":d},e[8]=d,e[9]=u):u=e[9];const m=u;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]!==f||e[13]!==i||e[14]!==d||e[15]!==c?(h={variant:c,size:i,spacing:d,orientation:f},e[12]=f,e[13]=i,e[14]=d,e[15]=c,e[16]=h):h=e[16];let g;e[17]!==t||e[18]!==h?(g=r.jsx(Nx.Provider,{value:h,children:t}),e[17]=t,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==f||e[21]!==o||e[22]!==i||e[23]!==d||e[24]!==m||e[25]!==p||e[26]!==g||e[27]!==c?(x=r.jsx(bv,{"data-slot":"toggle-group","data-variant":c,"data-size":i,"data-spacing":d,"data-orientation":f,orientation:f,style:m,className:p,...o,children:g}),e[20]=f,e[21]=o,e[22]=i,e[23]=d,e[24]=m,e[25]=p,e[26]=g,e[27]=c,e[28]=x):x=e[28],x}function _x(n){const e=U.c(19);let t,s,o,i,a;e[0]!==n?({className:s,children:t,variant:i,size:a,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5]);const l=i===void 0?"default":i,c=a===void 0?"default":a,d=b.useContext(Nx),f=d.variant||l,u=d.size||c,m=d.spacing;let p;e[6]!==s||e[7]!==d.size||e[8]!==d.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",O_({variant:d.variant||l,size:d.size||c}),s),e[6]=s,e[7]=d.size,e[8]=d.variant,e[9]=c,e[10]=l,e[11]=p):p=e[11];let h;return e[12]!==t||e[13]!==d.spacing||e[14]!==o||e[15]!==f||e[16]!==u||e[17]!==p?(h=r.jsx(xv,{"data-slot":"toggle-group-item","data-variant":f,"data-size":u,"data-spacing":m,className:p,...o,children:t}),e[12]=t,e[13]=d.spacing,e[14]=o,e[15]=f,e[16]=u,e[17]=p,e[18]=h):h=e[18],h}function D_(n){const e=U.c(31),{toolCall:t,sessionId:s,embedded:o}=n,i=o===void 0?!1:o;let a;e[0]!==t.input.questions?(a=t.input.questions??[],e[0]=t.input.questions,e[1]=a):a=e[1];const l=a;let c;e[2]!==l?(c=()=>Object.fromEntries(l.map(L_)),e[2]=l,e[3]=c):c=e[3];const[d,f]=b.useState(c),[u,m]=b.useState(!1),[p,h]=b.useState(!1),{chat:g}=yr(),{sendMessage:x}=g;if(l.length===0)return null;let v;e[4]!==d||e[5]!==l||e[6]!==x?(v=()=>{const E=l.map(T=>{var I;const M=(I=d[T.question])==null?void 0:I.trim();return M?l.length>1?`${T.question}
|
|
101
|
+
${M}`:M:null}).filter(Boolean).join(`
|
|
102
|
+
|
|
103
|
+
`);E&&x(E),h(!0)},e[4]=d,e[5]=l,e[6]=x,e[7]=v):v=e[7];const w=v;let y;if(e[8]!==d||e[9]!==w||e[10]!==s||e[11]!==t.id){const E=async T=>{T.preventDefault(),m(!0);try{(await Ac(s,t.id,d)).ok?h(!0):w()}catch{w()}m(!1)};y=T=>{E(T)},e[8]=d,e[9]=w,e[10]=s,e[11]=t.id,e[12]=y}else y=e[12];const j=!i&&"mt-2 rounded-md border bg-card p-3",k=p&&"pointer-events-none opacity-50";let N;e[13]!==j||e[14]!==k?(N=G("flex flex-col gap-3",j,k),e[13]=j,e[14]=k,e[15]=N):N=e[15];let C;if(e[16]!==d||e[17]!==l||e[18]!==t.id){let E;e[20]!==d||e[21]!==t.id?(E=(T,M)=>{const I=T.options&&T.options.length>0,R=new Set(T.multiSelect?(d[T.question]??"").split(", ").filter(Boolean):[]),$=`ask-user-answer-${t.id}-${M}`;return r.jsxs(Lw,{className:"gap-2 border-b border-border pb-3 last:border-b-0 last:pb-0",children:[(T.header||T.question)&&r.jsxs(zw,{variant:"label",className:"flex flex-col items-start gap-1",children:[T.header&&r.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:T.header}),r.jsx("span",{className:"text-sm leading-relaxed text-foreground",children:T.question})]}),I?r.jsx(Cx,{multiple:T.multiSelect,orientation:"vertical",variant:"outline",value:T.multiSelect?Array.from(R):d[T.question]?[d[T.question]]:[],onValueChange:D=>{if(!T.multiSelect&&D.length===0)return;const O=T.multiSelect?D.join(", "):D[0];f({...d,[T.question]:O})},className:"grid w-full gap-1.5",children:T.options.map((D,O)=>{const L=T.multiSelect?R.has(D.label):d[T.question]===D.label;return r.jsxs(_x,{value:D.label,"aria-label":D.label,className:"h-auto w-full justify-start whitespace-normal px-3 py-2.5 text-left",children:[r.jsx("span",{className:G("mt-0.5 flex size-4 shrink-0 items-center justify-center border",T.multiSelect?"rounded":"rounded-full",L?"border-primary bg-primary text-primary-foreground":"border-muted-foreground/30"),"aria-hidden":"true",children:L&&r.jsx(dt,{className:"size-3",strokeWidth:3,"data-icon":"icon"})}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block text-xs font-medium",children:D.label}),D.description&&r.jsx("span",{className:"mt-0.5 block text-xs leading-relaxed text-muted-foreground",children:D.description})]})]},O)})}):r.jsxs(gt,{children:[r.jsx(xt,{htmlFor:$,children:"Answer"}),r.jsx(ra,{id:$,value:d[T.question]??"",onChange:D=>{f({...d,[T.question]:D.target.value})},rows:2,placeholder:"Type your answer..."})]})]},M)},e[20]=d,e[21]=t.id,e[22]=E):E=e[22],C=l.map(E),e[16]=d,e[17]=l,e[18]=t.id,e[19]=C}else C=e[19];const S=u||p,_=p?"Sent":u?"Sending...":"Send answer";let P;e[23]!==S||e[24]!==_?(P=r.jsx(X,{type:"submit",size:"sm",disabled:S,children:_}),e[23]=S,e[24]=_,e[25]=P):P=e[25];let A;return e[26]!==C||e[27]!==P||e[28]!==y||e[29]!==N?(A=r.jsxs("form",{onSubmit:y,className:N,children:[C,P]}),e[26]=C,e[27]=P,e[28]=y,e[29]=N,e[30]=A):A=e[30],A}function L_(n){return[n.question,""]}function z_(n){return Array.isArray(n.input.questions)?n.input.questions.filter(e=>typeof e=="object"&&e!==null&&typeof e.question=="string"):[]}function mm(n){try{return JSON.parse(`"${n}"`)}catch{return n.replace(/\\"/g,'"').replace(/\\\\/g,"\\")}}function F_(n){const e={},t=/"((?:\\.|[^"\\])*)"\s*=\s*"((?:\\.|[^"\\])*)"/g;let s;for(;(s=t.exec(n))!==null;)e[mm(s[1])]=mm(s[2]);return e}function B_(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function U_(n,e){const t=(n.options??[]).filter(s=>{const o=s.label.trim();return o?new RegExp(`(^|[^\\p{L}\\p{N}])${B_(o)}(?=$|[^\\p{L}\\p{N}])`,"iu").test(e):!1});return t.length===1?t[0].label:void 0}function W_(n,e){const t=n.input.answers;if(typeof t=="object"&&t!==null&&!Array.isArray(t)){const o=Object.entries(t).filter(i=>typeof i[1]=="string");if(o.length>0)return Object.fromEntries(o)}if(!n.result)return{};const s=F_(n.result);for(const o of e)if(s[o.question]===void 0){const i=U_(o,n.result);i!==void 0&&(s[o.question]=i)}return s}function pm(n,e,t){return e===void 0?!1:n.multiSelect?e.split(/,\s*/).includes(t):e===t}function H_(n){const e=U.c(30),{question:t,answer:s,index:o,completed:i}=n;let a;e[0]!==t.options?(a=t.options??[],e[0]=t.options,e[1]=a):a=e[1];const l=a;let c;if(e[2]!==s||e[3]!==l||e[4]!==t){let y;e[6]!==s||e[7]!==t?(y=j=>pm(t,s,j.label),e[6]=s,e[7]=t,e[8]=y):y=e[8],c=l.filter(y),e[2]=s,e[3]=l,e[4]=t,e[5]=c}else c=e[5];const d=c.length,f=i&&s!==void 0&&d===0,u=o+1;let m;e[9]!==u?(m=r.jsx(Me,{variant:"outline",className:"size-5 rounded-full p-0 font-mono text-muted-foreground",children:u}),e[9]=u,e[10]=m):m=e[10];let p;e[11]!==t.header?(p=t.header&&r.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:t.header}),e[11]=t.header,e[12]=p):p=e[12];let h;e[13]!==m||e[14]!==p?(h=r.jsxs("div",{className:"mb-1.5 flex items-center gap-2",children:[m,p]}),e[13]=m,e[14]=p,e[15]=h):h=e[15];let g;e[16]!==t.question?(g=r.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:t.question}),e[16]=t.question,e[17]=g):g=e[17];let x;e[18]!==s||e[19]!==l||e[20]!==t?(x=l.length>0&&r.jsx("div",{className:"mt-2 flex flex-col divide-y divide-border",children:l.map((y,j)=>{const k=pm(t,s,y.label);return r.jsxs("div",{className:G("flex items-start gap-2.5 py-2",k?"text-foreground":"text-muted-foreground"),children:[r.jsx("span",{className:G("mt-0.5 flex size-4 shrink-0 items-center justify-center border",t.multiSelect?"rounded":"rounded-full",k?"border-primary bg-primary text-primary-foreground":"border-muted-foreground/30"),"aria-hidden":"true",children:k&&r.jsx(dt,{className:"size-3",strokeWidth:3,"data-icon":"icon"})}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsxs("span",{className:"block text-xs font-medium",children:[y.label,k&&r.jsx(Me,{variant:"secondary",className:"ml-2",children:"Selected"})]}),y.description&&r.jsx("span",{className:"mt-0.5 block text-xs leading-relaxed text-muted-foreground",children:y.description})]})]},`${y.label}-${j}`)})}),e[18]=s,e[19]=l,e[20]=t,e[21]=x):x=e[21];let v;e[22]!==s||e[23]!==f?(v=f&&r.jsxs("div",{className:"mt-2 border-l-2 border-border pl-3",children:[r.jsx("div",{className:"mb-0.5 text-xs font-medium text-muted-foreground",children:"Answer"}),r.jsx("p",{className:"whitespace-pre-wrap break-words text-sm leading-relaxed text-foreground/90",children:s.trim()||"No answer provided"})]}),e[22]=s,e[23]=f,e[24]=v):v=e[24];let w;return e[25]!==h||e[26]!==g||e[27]!==x||e[28]!==v?(w=r.jsxs("div",{className:"border-b border-border py-3 last:border-b-0",children:[h,g,x,v]}),e[25]=h,e[26]=g,e[27]=x,e[28]=v,e[29]=w):w=e[29],w}function K_(n){const e=U.c(61),{toolCall:t,expandToolPayloads:s,isAwaitingAnswer:o,sessionId:i}=n,[a,l]=b.useState(!1);let c;e[0]!==t?(c=z_(t),e[0]=t,e[1]=c):c=e[1];const d=c;let f;e[2]!==d||e[3]!==t?(f=W_(t,d),e[2]=d,e[3]=t,e[4]=f):f=e[4];const u=f,m=s||a,p=t.result!==null&&!t.isError,h=t.result===null&&o&&!!i&&d.length>0;let g;e[5]!==u?(g=Object.keys(u),e[5]=u,e[6]=g):g=e[6];const x=g.length>0,v=t.isError?bn:p?Un:Ki,w=t.isError?"Not answered":p?"Answered":h?"Waiting for answer":"No answer recorded",y=t.isError&&"border-destructive/30";let j;e[7]!==y?(j=G("my-1 overflow-hidden rounded-lg border bg-card",y),e[7]=y,e[8]=j):j=e[8];let k;e[9]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(Jp,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground","data-icon":"inline-start"}),e[9]=k):k=e[9];let N;e[10]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx("h3",{className:"text-sm font-medium text-foreground",children:"Decision requested"}),e[10]=N):N=e[10];const C=d.length===1?"question":"questions";let S;e[11]!==d.length||e[12]!==C?(S=r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[N,r.jsxs("span",{className:"text-xs text-muted-foreground",children:[d.length," ",C]})]}),e[11]=d.length,e[12]=C,e[13]=S):S=e[13];const _=t.isError?"destructive":p?"secondary":"outline";let P;e[14]!==v?(P=r.jsx(v,{"data-icon":"inline-start"}),e[14]=v,e[15]=P):P=e[15];let A;e[16]!==w||e[17]!==_||e[18]!==P?(A=r.jsxs(Me,{variant:_,children:[P,w]}),e[16]=w,e[17]=_,e[18]=P,e[19]=A):A=e[19];let E;e[20]!==A||e[21]!==S?(E=r.jsxs("div",{className:"min-w-0 flex-1",children:[S,A]}),e[20]=A,e[21]=S,e[22]=E):E=e[22];let T;e[23]!==t.timestamp?(T=t.timestamp&&r.jsx("time",{className:"hidden shrink-0 pt-0.5 font-mono text-xs tabular-nums text-muted-foreground sm:block",children:new Date(t.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),e[23]=t.timestamp,e[24]=T):T=e[24];let M;e[25]!==E||e[26]!==T?(M=r.jsxs("header",{className:"flex items-start gap-2.5 border-b px-3 py-2.5",children:[k,E,T]}),e[25]=E,e[26]=T,e[27]=M):M=e[27];let I;e[28]!==u||e[29]!==h||e[30]!==d||e[31]!==i||e[32]!==t?(I=h&&i?r.jsx(D_,{toolCall:t,sessionId:i,embedded:!0}):d.length>0?d.map((B,W)=>r.jsx(H_,{question:B,answer:u[B.question],index:W,completed:t.result!==null},`${B.question}-${W}`)):r.jsx("p",{className:"py-3 text-sm text-muted-foreground",children:"Question details are unavailable."}),e[28]=u,e[29]=h,e[30]=d,e[31]=i,e[32]=t,e[33]=I):I=e[33];let R;e[34]!==x||e[35]!==t.isError||e[36]!==t.result?(R=t.result!==null&&!x&&r.jsxs("div",{className:G("border-t border-border py-3",t.isError?"text-destructive":"text-muted-foreground"),children:[r.jsx("div",{className:"mb-0.5 text-xs font-semibold uppercase tracking-wide opacity-70",children:"Recorded response"}),r.jsx("p",{className:"whitespace-pre-wrap break-words text-sm leading-relaxed",children:t.result})]}),e[34]=x,e[35]=t.isError,e[36]=t.result,e[37]=R):R=e[37];let $;e[38]!==I||e[39]!==R?($=r.jsxs("div",{className:"px-3",children:[I,R]}),e[38]=I,e[39]=R,e[40]=$):$=e[40];let D;e[41]!==s?(D=()=>{s||l(q_)},e[41]=s,e[42]=D):D=e[42];let O;e[43]!==m?(O=m?r.jsx(nt,{"data-icon":"inline-start"}):r.jsx(Ze,{"data-icon":"inline-start"}),e[43]=m,e[44]=O):O=e[44];let L;e[45]!==m||e[46]!==D||e[47]!==O?(L=r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:D,className:"-ml-2 text-muted-foreground","aria-expanded":m,children:[O,"Raw details"]}),e[45]=m,e[46]=D,e[47]=O,e[48]=L):L=e[48];let z;e[49]!==m||e[50]!==t.input||e[51]!==t.result?(z=m&&r.jsxs("div",{className:"mt-1.5 grid gap-2 pb-1.5 lg:grid-cols-2",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Input"}),r.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap break-words rounded-md border bg-muted/30 p-2 font-mono text-xs leading-relaxed text-muted-foreground",children:JSON.stringify(t.input,null,2)})]}),t.result!==null&&r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Result"}),r.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap break-words rounded-md border bg-muted/30 p-2 font-mono text-xs leading-relaxed text-muted-foreground",children:t.result})]})]}),e[49]=m,e[50]=t.input,e[51]=t.result,e[52]=z):z=e[52];let F;e[53]!==L||e[54]!==z?(F=r.jsxs("div",{className:"border-t px-3 py-1.5",children:[L,z]}),e[53]=L,e[54]=z,e[55]=F):F=e[55];let H;return e[56]!==M||e[57]!==$||e[58]!==F||e[59]!==j?(H=r.jsxs("section",{className:j,"aria-label":"Question history",children:[M,$,F]}),e[56]=M,e[57]=$,e[58]=F,e[59]=j,e[60]=H):H=e[60],H}function q_(n){return!n}const V_="max-h-96 overflow-y-auto whitespace-pre-wrap break-all rounded-md border bg-muted/30 p-2 font-mono text-xs leading-relaxed text-muted-foreground",G_="whitespace-pre-wrap break-all border-l border-border pl-3 font-mono text-[11px] leading-relaxed text-muted-foreground";function Tx(n,e,t){const s=U.c(5),[o,i]=b.useState(null);let a,l;return s[0]!==n||s[1]!==t||s[2]!==e?(a=()=>{if(!e){i(null);return}let c=!1;return qc(n,e,t).then(d=>{c||i(d)}),()=>{c=!0}},l=[n,e,t],s[0]=n,s[1]=t,s[2]=e,s[3]=a,s[4]=l):(a=s[3],l=s[4]),b.useEffect(a,l),o}function Ex(n){const e=U.c(12),{lines:t,tokens:s,lineNums:o,variant:i}=n,a=i==="boxed"?V_:G_;let l;if(e[0]!==o||e[1]!==t||e[2]!==s){let f;e[4]!==o||e[5]!==s?(f=(u,m)=>{const p=s==null?void 0:s[m];return r.jsxs("span",{className:"block",children:[(o==null?void 0:o[m])&&r.jsx("span",{className:"inline-block w-10 text-right mr-2 text-muted-foreground/30 select-none",children:o[m]}),p?p.map(Y_):u||" "]},m)},e[4]=o,e[5]=s,e[6]=f):f=e[6],l=t.map(f),e[0]=o,e[1]=t,e[2]=s,e[3]=l}else l=e[3];let c;e[7]!==l?(c=r.jsx("code",{className:"block",children:l}),e[7]=l,e[8]=c):c=e[8];let d;return e[9]!==a||e[10]!==c?(d=r.jsx("pre",{className:a,children:c}),e[9]=a,e[10]=c,e[11]=d):d=e[11],d}function Y_(n,e){return r.jsx("span",{style:{color:n.color},children:n.content},e)}const X_=/^(\s*\d+)→(.*)$/;function Px(n){return n.split(/\r\n|\r|\n/)}function J_(n){const e=[],t=[];for(const s of Px(n)){const o=s.match(X_);o?(e.push(o[1]),t.push(o[2])):(e.push(""),t.push(s))}return{lineNums:e,codeLines:t}}function Q_(n){const e=U.c(14),{result:t,filePath:s,expanded:o,variant:i}=n,a=i===void 0?"boxed":i,l=_r();let c;e[0]!==s?(c=Eg(s),e[0]=s,e[1]=c):c=e[1];const d=c;let f;e[2]!==o||e[3]!==t?(f=o?t:t.slice(0,500),e[2]=o,e[3]=t,e[4]=f):f=e[4];const u=f;let m;e[5]!==u?(m=J_(u),e[5]=u,e[6]=m):m=e[6];const{lineNums:p,codeLines:h}=m;let g;e[7]!==h?(g=h.join(`
|
|
104
|
+
`),e[7]=h,e[8]=g):g=e[8];const v=Tx(g,d,l);let w;return e[9]!==h||e[10]!==p||e[11]!==v||e[12]!==a?(w=r.jsx(Ex,{lines:h,tokens:v,lineNums:p,variant:a}),e[9]=h,e[10]=p,e[11]=v,e[12]=a,e[13]=w):w=e[13],w}function Ax(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 Ql(n){const e=U.c(12),{result:t,expanded:s,alreadyPretty:o,variant:i}=n,a=i===void 0?"boxed":i,l=_r();let c;e[0]!==o||e[1]!==t?(c=o?t:Ax(t)??t,e[0]=o,e[1]=t,e[2]=c):c=e[2];const d=c;let f;e[3]!==s||e[4]!==d?(f=s?d:d.slice(0,2e3),e[3]=s,e[4]=d,e[5]=f):f=e[5];const u=f;let m;e[6]!==u?(m=Px(u),e[6]=u,e[7]=m):m=e[7];const p=m,h=Tx(u,"json",l);let g;return e[8]!==p||e[9]!==h||e[10]!==a?(g=r.jsx(Ex,{lines:p,tokens:h,variant:a}),e[8]=p,e[9]=h,e[10]=a,e[11]=g):g=e[11],g}const Z_={spawn_agent:{label:"Spawn agent",styleName:"Task"},wait_agent:{label:"Wait for agents",styleName:"Task"},send_message:{label:"Message agent",styleName:"Task"},followup_task:{label:"Follow up",styleName:"Task"},list_agents:{label:"List agents",styleName:"Task"},interrupt_agent:{label:"Interrupt agent",styleName:"Task"},tool_search:{label:"Find tools",styleName:"ToolSearch"},list_mcp_resources:{label:"List MCP resources",styleName:"Mcp"},list_mcp_resource_templates:{label:"List MCP templates",styleName:"Mcp"},read_mcp_resource:{label:"Read MCP resource",styleName:"Mcp"},request_plugin_install:{label:"Install plugin",styleName:"Mcp"},create_goal:{label:"Create goal",styleName:"TodoWrite"},get_goal:{label:"Check goal",styleName:"TodoWrite"},update_goal:{label:"Update goal",styleName:"TodoWrite"},view_image:{label:"View image",styleName:"Read"}};function eT(n){return typeof n=="object"&&n!==null}function rn(...n){return n.find(e=>typeof e=="string")??""}function go(n,e=140){const t=n.replace(/\s+/g," ").trim();return t.length>e?`${t.slice(0,e-1)}…`:t}function vd(n){const e=[],t=new Set;for(const s of n){const o=s.trim();!o||t.has(o)||(t.add(o),e.push(o))}return e}function Ar(n,e=""){const t=vd(n);if(t.length===0)return e;const s=go(t[0]);return t.length===1?s:`${s} · +${t.length-1} more`}function yd(n,e){return n===1?`1 ${e}`:`${n} ${e}${/(?:ch|sh|s|x|z)$/.test(e)?"es":"s"}`}const hm={mcp:"MCP",api:"API",url:"URL",openai:"OpenAI",figma:"Figma",clickup:"ClickUp"};function Ni(n,e=!1){const t=n.replace(/^mcp__/,"").replace(/__/g," ").replace(/[_./:-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim().split(/\s+/).filter(Boolean).map(o=>{const i=o.toLowerCase();return hm[i]?hm[i]:e?i[0].toUpperCase()+i.slice(1):i});if(t.length===0)return"Tool";const s=t.join(" ");return s[0].toUpperCase()+s.slice(1)}function tT(n){if(!n)return null;const e=n.trim(),t=Fn(e,0);return(t==null?void 0:t.endIndex)===e.length?t.value:null}function Ht(n,...e){for(const t of e){const s=tT(td(n,t));if(s)return s;const o=nd(n,t)[0];if(o)return o}return""}function nT(n,...e){for(const t of e){const s=l1(n,t)[0];if(s!==void 0)return s}return null}function Ci(n){return Ht(n,"description","query","q","cmd","command","file_path","path","uri","url","pattern","prompt","objective","message","location","ticker","target","task_name","plugin_id","server","status","id")}const sT=[{key:"search_query",label:"Search web",noun:"search",summaryGroups:[["q","query"]]},{key:"image_query",label:"Search images",noun:"image search",summaryGroups:[["q","query"]]},{key:"open",label:"Open page",noun:"page",summaryGroups:[["ref_id","url"]],detail:{property:"lineno",format:n=>`line ${n}`}},{key:"click",label:"Open link",noun:"link",summaryGroups:[["ref_id"]],detail:{property:"id",format:n=>`link ${n}`}},{key:"find",label:"Find on page",noun:"find",summaryGroups:[["pattern"],["ref_id","url"]]},{key:"screenshot",label:"Capture page",noun:"capture",summaryGroups:[["ref_id"]],detail:{property:"pageno",format:n=>`page ${n+1}`}},{key:"finance",label:"Check markets",noun:"quote",summaryGroups:[["ticker"]]},{key:"weather",label:"Check weather",noun:"forecast",summaryGroups:[["location"]]},{key:"sports",label:"Check sports",noun:"sports lookup",summaryGroups:[["league","team"]],countProperties:["league"]},{key:"time",label:"Check time",noun:"time lookup",summaryGroups:[["utc_offset"]]}];function gm(n,e){return e.flatMap(t=>nd(n,t))}function oT(n,e){const t=e.summaryGroups.map(i=>gm(n,i)),s=e.detail?l1(n,e.detail.property):[],o=e.countProperties?gm(n,e.countProperties):t[0];return{label:e.label,noun:e.noun,summary:[...t.map(i=>Ar(i)),e.detail&&s.length>0?e.detail.format(s[0]):""].filter(Boolean).join(" · "),count:Math.max(c1(n),vd(o).length,s.length,1)}}function rT(n){const e=[];for(const t of sT){const s=td(n,t.key);s&&e.push(oT(s,t))}return e}function iT(n){const e=rT(n);return e.length===0?{label:"Browse web",summary:Ci(n),styleName:"WebSearch"}:e.length===1?{label:e[0].label,summary:e[0].summary,styleName:"WebSearch"}:{label:"Browse web",summary:e.map(t=>yd(t.count,t.noun)).join(" · "),styleName:"WebSearch"}}function Rx(n){if(!n.startsWith("mcp__"))return null;const[,e,...t]=n.split("__");return!e||t.length===0?null:{server:Ni(e,!0),action:Ni(t.join(" "))}}function aT(n,e){const t=Rx(n);if(!t)return{label:Ni(n),summary:Ci(e),styleName:"Mcp"};const s=Ci(e);return{label:t.server,summary:[t.action,s].filter(Boolean).join(" · "),styleName:"Mcp"}}function lT(n){const e=Fn(n.trim(),0),t=(e==null?void 0:e.value)??n,s=vd(Array.from(t.matchAll(/^\*\*\*\s+(?:Update|Add|Delete) File:\s*(.+)$/gm),o=>o[1]));return Ar(s,s.length>0?yd(s.length,"file"):"")}function cT(n){const e=n.argumentSource;switch(n.name){case"exec_command":return{label:"Run command",summary:Ht(e,"cmd","command"),styleName:"Bash"};case"write_stdin":{const t=nT(e,"session_id"),s=Ht(e,"chars");return{label:"Continue command",summary:[t!==null?`session ${t}`:"",s?go(s,60):""].filter(Boolean).join(" · "),styleName:"Bash"}}case"apply_patch":return{label:"Apply patch",summary:lT(e),styleName:"Edit"};case"web__run":case"web_search":return iT(e);case"view_image":return{label:"View image",summary:Ht(e,"path"),styleName:"Read"};case"update_plan":{const t=td(e,"plan"),s=t?c1(t):0;return{label:"Update plan",summary:s>0?yd(s,"step"):Ht(e,"explanation"),styleName:"TodoWrite"}}case"create_goal":return{label:"Create goal",summary:Ht(e,"objective"),styleName:"TodoWrite"};case"get_goal":return{label:"Check goal",summary:"",styleName:"TodoWrite"};case"update_goal":return{label:"Update goal",summary:Ht(e,"status"),styleName:"TodoWrite"};case"list_mcp_resources":return{label:"List MCP resources",summary:Ht(e,"server"),styleName:"Mcp"};case"list_mcp_resource_templates":return{label:"List MCP templates",summary:Ht(e,"server"),styleName:"Mcp"};case"read_mcp_resource":return{label:"Read MCP resource",summary:[Ht(e,"server"),Ht(e,"uri")].filter(Boolean).join(" · "),styleName:"Mcp"};case"request_plugin_install":return{label:"Install plugin",summary:Ht(e,"plugin_id"),styleName:"Mcp"};case"tool_search":return{label:"Find tools",summary:Ht(e,"query"),styleName:"ToolSearch"};case"image_gen__imagegen":return{label:"Generate image",summary:Ht(e,"prompt"),styleName:"Image"};default:return n.name.startsWith("mcp__")?aT(n.name,e):{label:Ni(n.name),summary:Ci(e),styleName:n.name}}}function Mx(n){return typeof n.input.raw=="string"&&/(?:^|__|[.:/])exec$/.test(n.name)}function dT(n){const e=nk(n);if(e.length===0)return{label:"Run tool script",summary:"",styleName:"exec"};const t=e.map(cT),s=t[0];if(t.every(i=>i.label===s.label)){const i=Ar(t.map(a=>a.summary));return{label:s.label,summary:e.length===1?i:[`×${e.length}`,i].filter(Boolean).join(" · "),styleName:s.styleName}}const o=new Map;for(const i of t)o.set(i.label,(o.get(i.label)??0)+1);return{label:"Run tools",summary:[...o].map(([i,a])=>a>1?`${i} ×${a}`:i).join(" · "),styleName:"exec"}}function uT(n){const e=eT(n.action)?n.action:null,t=typeof(e==null?void 0:e.type)=="string"?e.type:"search";if(t==="open_page"||t==="openPage")return{label:"Open page",summary:rn(e==null?void 0:e.url,n.query),styleName:"WebSearch"};if(t==="find_in_page"||t==="findInPage")return{label:"Find on page",summary:[rn(e==null?void 0:e.pattern),rn(e==null?void 0:e.url)].filter(Boolean).join(" · "),styleName:"WebSearch"};const s=Array.isArray(e==null?void 0:e.queries)?e.queries.filter(i=>typeof i=="string"):[],o=rn(e==null?void 0:e.query,n.query);return{label:"Search web",summary:Ar([o,...s]),styleName:"WebSearch"}}const fT=["summary","headline","verdict","title"];function mT(n){const e=rn(...fT.map(t=>n[t]));if(e)return go(e);for(const[t,s]of Object.entries(n)){if(!Array.isArray(s))continue;const o=s.length===1&&t.endsWith("s")?t.slice(0,-1):t;return`${s.length} ${o}`}return""}function pT(n){const e=rn(n.description);if(e)return go(e);const t=rn(n.script);return(t?nd(t,"name")[0]??"":"")||rn(n.scriptPath)}function xm(n){const e=Object.keys(n);if(e.length===0)return"";const t=n[e[0]];return typeof t!="string"?"":t.length>80?t.slice(0,80)+"...":t}function bm(n){var t;const e=n.input;switch(n.name){case"Read":case"Write":case"Edit":return String(e.file_path??e.path??"");case"Bash":return String(e.command??e.cmd??"");case"Grep":case"Glob":return String(e.pattern??"");case"Task":case"Agent":return String(e.description??e.prompt??"");case"WebFetch":return String(e.url??"");case"NotebookEdit":return String(e.notebook_path??"");case"EnterPlanMode":return"Entered plan mode";case"ExitPlanMode":return"Waiting for plan approval";case"AskUserQuestion":{const s=e.questions;return((t=s==null?void 0:s[0])==null?void 0:t.question)??""}case"Monitor":{const s=String(e.bash_id??""),o=e.filter?` · filter=${e.filter}`:"";return`${s}${o}`}case"CronCreate":{const s=String(e.schedule??e.cron??""),o=String(e.prompt??""),i=o.length>60?o.slice(0,60)+"...":o;return s&&i?`${s} → ${i}`:s||i}case"CronList":return"";case"CronDelete":return String(e.id??e.cron_id??"");case"ScheduleWakeup":{const s=Number(e.delaySeconds??0),o=Math.round(s/60),i=s>=3600?`${Math.round(s/3600)}h`:s>=60?`${o}m`:`${s}s`,a=e.reason?` · ${e.reason}`:"";return`in ${i}${a}`}case"RemoteTrigger":{const s=String(e.action??""),o=String(e.id??e.trigger_id??"");return[s,o].filter(Boolean).join(" ")}case"PushNotification":return String(e.title??e.body??"");case"EnterWorktree":{const s=String(e.name??e.branch??""),o=e.path?` (${e.path})`:"";return`${s}${o}`}case"ExitWorktree":return String(e.name??e.branch??"");case"Skill":return String(e.skill??e.name??"");case"ToolSearch":return String(e.query??"");case"SendMessage":{const s=rn(e.to,e.recipient),o=go(rn(e.summary,e.message,e.content));return[s,o].filter(Boolean).join(" · ")}case"ListAgents":case"TaskList":return"";case"TaskCreate":return go(rn(e.subject,e.description));case"TaskUpdate":{const s=String(e.taskId??""),o=Array.isArray(e.addBlockedBy)?e.addBlockedBy.filter(a=>typeof a=="string"):[],i=rn(e.status)||(o.length>0?`blocked by ${o.join(", ")}`:"");return i?`${s} → ${i}`:s}case"TaskOutput":case"TaskStop":return String(e.task_id??"");case"Workflow":return pT(e);case"StructuredOutput":case"ReportFindings":case"DesignSync":case"Artifact":case"LSP":return mT(e)||xm(e);case"spawn_agent":return String(e.task_name??e.message??"");case"wait_agent":{const s=Array.isArray(e.ids)?e.ids.filter(o=>typeof o=="string"):[];return Ar(s)}case"send_message":case"followup_task":return[e.target,e.message].filter(s=>typeof s=="string").join(" · ");case"list_agents":return String(e.path_prefix??"");case"interrupt_agent":return String(e.target??"");case"list_mcp_resources":case"list_mcp_resource_templates":return String(e.server??"");case"read_mcp_resource":return[e.server,e.uri].filter(s=>typeof s=="string").join(" · ");case"request_plugin_install":return String(e.plugin_id??"");case"create_goal":return String(e.objective??"");case"update_goal":return String(e.status??"");case"view_image":return String(e.path??"");default:return xm(e)}}function ya(n){if(Mx(n))return dT(n.input.raw);if(n.name==="WebSearch")return uT(n.input);const e=Rx(n.name);if(e)return{label:e.server,summary:[e.action,bm(n)].filter(Boolean).join(" · "),styleName:"Mcp"};const t=Z_[n.name];return{label:(t==null?void 0:t.label)??n.name,summary:bm(n),styleName:(t==null?void 0:t.styleName)??n.name}}function hT(n){return ya(n).summary}const gT={mutating:"text-foreground",readOnly:"text-muted-foreground"},xT="text-destructive",vm=8,bT="whitespace-pre-wrap break-all border-l border-border pl-3 font-mono text-[11px] leading-relaxed text-muted-foreground",vT="max-h-96 overflow-y-auto whitespace-pre-wrap break-all rounded-md border p-2 font-mono text-xs leading-relaxed";function yT(n){return n.split(/\r\n|\r|\n/)}const wT={Write:"mutating",Edit:"mutating",Bash:"mutating",exec:"mutating",Task:"mutating",Skill:"mutating",TodoWrite:"mutating",Image:"mutating",AskUserQuestion:"mutating",CronCreate:"mutating",CronDelete:"mutating",ScheduleWakeup:"mutating",RemoteTrigger:"mutating",PushNotification:"mutating",EnterWorktree:"mutating",ExitWorktree:"mutating",Agent:"mutating",SendMessage:"mutating",EndConversation:"mutating",TaskCreate:"mutating",TaskUpdate:"mutating",TaskStop:"mutating",Workflow:"mutating",Read:"readOnly",Grep:"readOnly",Glob:"readOnly",WebFetch:"readOnly",WebSearch:"readOnly",ToolSearch:"readOnly",Monitor:"readOnly",CronList:"readOnly",Mcp:"readOnly",EnterPlanMode:"readOnly",ExitPlanMode:"readOnly",ListAgents:"readOnly",TaskList:"readOnly",TaskOutput:"readOnly",LSP:"readOnly",StructuredOutput:"readOnly",ReportFindings:"readOnly"},jT="readOnly";function ST(n){return wT[n]??jT}function Ix(n,e=!1){return e?xT:gT[ST(n)]}function ll(n){const e=U.c(8),{isOpen:t,onClick:s,label:o,controlsId:i}=n,a=t?nt:Ze;let l;e[0]!==a?(l=r.jsx(a,{"data-icon":"inline-start"}),e[0]=a,e[1]=l):l=e[1];let c;return e[2]!==i||e[3]!==t||e[4]!==o||e[5]!==s||e[6]!==l?(c=r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:s,className:"-ml-2 text-muted-foreground","aria-expanded":t,"aria-controls":i,children:[l,o]}),e[2]=i,e[3]=t,e[4]=o,e[5]=s,e[6]=l,e[7]=c):c=e[7],c}function $x(n){const e=U.c(2),{toolCall:t,isAgentActive:s}=n;if(t.isError){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(zs,{role:"img","aria-label":"Tool call failed",className:"size-4 text-destructive","data-icon":"icon"}),e[0]=o):o=e[0],o}if(t.result===null&&s){let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(rt,{role:"img","aria-label":"Tool call running",className:"size-4 animate-spin text-info","data-icon":"icon"}),e[1]=o):o=e[1],o}return null}function kT(n){const e=U.c(30),{toolCall:t,resultExpanded:s,onToggleExpanded:o,isMobile:i}=n,a=t.result??"",l=a.length>1e3,c=l&&!s?a.slice(0,500)+"...":a;let d;e[0]!==a||e[1]!==t.isError||e[2]!==t.name?(d=!t.isError&&t.name!=="Read"?Ax(a):null,e[0]=a,e[1]=t.isError,e[2]=t.name,e[3]=d):d=e[3];const f=d,u=f??a;let m;e[4]!==u?(m=yT(u),e[4]=u,e[5]=m):m=e[5];const p=m,h=Math.max(0,p.length-vm);let g;e[6]!==p||e[7]!==u||e[8]!==s?(g=s?u:p.slice(0,vm).join(`
|
|
105
|
+
`),e[6]=p,e[7]=u,e[8]=s,e[9]=g):g=e[9];const x=g,v=i?l:h>0,w=!i||!l||s,y=i?"boxed":"unboxed";let j;e[10]!==x||e[11]!==w||e[12]!==y||e[13]!==i||e[14]!==c||e[15]!==f||e[16]!==a||e[17]!==t.input||e[18]!==t.isError||e[19]!==t.name?(j=t.name==="Read"&&!t.isError&&typeof t.input.file_path=="string"?r.jsx(Q_,{result:i?a:x,filePath:t.input.file_path,expanded:w,variant:y}):f!==null?r.jsx(Ql,{result:i?f:x,expanded:w,alreadyPretty:!0,variant:y}):r.jsx("pre",{className:G(i?vT:bT,t.isError?G("border-destructive/20 text-destructive",i&&"bg-destructive/5"):i&&"border-border bg-muted/30 text-muted-foreground"),children:i?c:x}),e[10]=x,e[11]=w,e[12]=y,e[13]=i,e[14]=c,e[15]=f,e[16]=a,e[17]=t.input,e[18]=t.isError,e[19]=t.name,e[20]=j):j=e[20];let k;e[21]!==h||e[22]!==i||e[23]!==o||e[24]!==s||e[25]!==v?(k=v&&r.jsx("button",{type:"button",onClick:o,className:"mt-1 text-[10px] text-muted-foreground hover:text-foreground transition-colors",children:s?"Show less":i?"Show more":`+${h} lines`}),e[21]=h,e[22]=i,e[23]=o,e[24]=s,e[25]=v,e[26]=k):k=e[26];let N;return e[27]!==j||e[28]!==k?(N=r.jsxs("div",{className:"mt-1.5",children:[j,k]}),e[27]=j,e[28]=k,e[29]=N):N=e[29],N}function ym(n){const e=U.c(35),{toolCall:t,isMobile:s,isAgentActive:o,displayName:i,summary:a,nameTitle:l,nameClass:c,timeLabel:d,timeIso:f}=n;let u;e[0]!==f||e[1]!==d?(u=d&&r.jsx("time",{className:"sr-only",dateTime:f,children:d}),e[0]=f,e[1]=d,e[2]=u):u=e[2];const m=s?"gap-1.5":"gap-2";let p;e[3]!==m?(p=G("flex min-w-0 flex-1 items-center",m),e[3]=m,e[4]=p):p=e[4];const h=s?"text-[10px]":"text-[11px]";let g;e[5]!==c||e[6]!==h?(g=G("shrink-0 font-mono",h,c),e[5]=c,e[6]=h,e[7]=g):g=e[7];let x;e[8]!==i||e[9]!==l||e[10]!==g?(x=r.jsx("span",{className:g,title:l,children:i}),e[8]=i,e[9]=l,e[10]=g,e[11]=x):x=e[11];let v;e[12]!==s||e[13]!==a?(v=a&&r.jsx("span",{className:G("truncate font-mono text-muted-foreground",s?"text-[11px]":"text-xs"),children:a}),e[12]=s,e[13]=a,e[14]=v):v=e[14];let w;e[15]!==p||e[16]!==x||e[17]!==v?(w=r.jsxs("div",{className:p,children:[x,v]}),e[15]=p,e[16]=x,e[17]=v,e[18]=w):w=e[18];let y;e[19]!==s||e[20]!==t.hookDurationMs?(y=t.hookDurationMs!==void 0&&t.hookDurationMs>0&&!s&&r.jsxs("span",{className:"text-[10px] text-muted-foreground/50 tabular-nums",title:"PostToolUse hook duration",children:[t.hookDurationMs,"ms"]}),e[19]=s,e[20]=t.hookDurationMs,e[21]=y):y=e[21];let j;e[22]!==t.outputReplacedByHook?(j=t.outputReplacedByHook&&r.jsx("span",{className:"text-[10px] text-blue-400",title:"Output replaced by hook",children:"hook"}),e[22]=t.outputReplacedByHook,e[23]=j):j=e[23];let k;e[24]!==o||e[25]!==t?(k=r.jsx($x,{toolCall:t,isAgentActive:o}),e[24]=o,e[25]=t,e[26]=k):k=e[26];let N;e[27]!==j||e[28]!==k||e[29]!==y?(N=r.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[y,j,k]}),e[27]=j,e[28]=k,e[29]=y,e[30]=N):N=e[30];let C;return e[31]!==u||e[32]!==N||e[33]!==w?(C=r.jsxs(r.Fragment,{children:[u,w,N]}),e[31]=u,e[32]=N,e[33]=w,e[34]=C):C=e[34],C}function NT(n){if(n.isError)return null;const e=n.name==="Read"?n.input.file_path:n.name==="view_image"?n.input.path:null;return typeof e=="string"&&ad(e)?e:null}function wm(n){const e=U.c(4),{toolCall:t}=n,s=t.input.old_string,o=t.input.new_string,i=t.input.file_path;let a;return e[0]!==s||e[1]!==o||e[2]!==i?(a=r.jsx(bd,{oldString:s,newString:o,filePath:i}),e[0]=s,e[1]=o,e[2]=i,e[3]=a):a=e[3],a}const CT={AskUserQuestion:"Question",Bash:"Command",exec:"Command",Task:"Agent",WebFetch:"Fetch",WebSearch:"Search",EnterPlanMode:"Plan mode",ExitPlanMode:"Plan review",ToolSearch:"Tool search"},Ox=b.memo(function(e){var ce,we;const t=U.c(129),{toolCall:s,expandAll:o,expandToolPayloads:i,isAgentActive:a,skillMetadata:l}=e,c=i===void 0?!1:i,{session:d,pendingInteraction:f}=it(),u=va(),[m,p]=b.useState(!1),[h,g]=b.useState(!1),[x,v]=b.useState(!1),[w,y]=b.useState(!1),[j,k]=b.useState(!1),[N,C]=b.useState(!1),S=b.useId(),_=b.useId(),P=b.useId(),A=b.useId(),E=b.useId(),[T,M]=b.useState(!1),I=s.result!==null||!a,R=u&&I&&!o&&!T;let $;t[0]!==s?($=ya(s),t[0]=s,t[1]=$):$=t[1];const D=$;let O;t[2]!==s?(O=Mx(s),t[2]=s,t[3]=O):O=t[3];const L=O,z=u&&D.label===s.name?CT[s.name]??s.name:D.label,F=D.label===s.name?s.name:`${D.label} (${s.name})`;let H,B,W,K,V,Y,q,J,Z,Q,ee,oe,se;if(t[4]!==A||t[5]!==j||t[6]!==w||t[7]!==z||t[8]!==o||t[9]!==c||t[10]!==m||t[11]!==a||t[12]!==L||t[13]!==R||t[14]!==u||t[15]!==F||t[16]!==f||t[17]!==D.styleName||t[18]!==D.summary||t[19]!==x||t[20]!==h||t[21]!==(d==null?void 0:d.sessionId)||t[22]!==l||t[23]!==s){se=Symbol.for("react.early_return_sentinel");e:{const pe=Ix(D.styleName,s.isError);let ue;t[37]!==s.timestamp?(ue=s.timestamp?new Date(s.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}):void 0,t[37]=s.timestamp,t[38]=ue):ue=t[38];const je=ue;let Ne;t[39]!==s.timestamp?(Ne=s.timestamp?new Date(s.timestamp).toISOString():void 0,t[39]=s.timestamp,t[40]=Ne):Ne=t[40];const Re=Ne,Te=c||u&&o;Y=Te||m,q=Te||h,V=Te||w;const Pe=D.summary;let Oe;t[41]!==l||t[42]!==Pe||t[43]!==s.name?(Oe=s.name==="Skill"&&l?l.get(Pe)??null:null,t[41]=l,t[42]=Pe,t[43]=s.name,t[44]=Oe):Oe=t[44],Z=Oe,J=Z==null?void 0:Z.filePath,B=s.name==="Edit"&&typeof s.input.old_string=="string"&&typeof s.input.new_string=="string"&&typeof s.input.file_path=="string",H=B?"diff":s.name==="Bash"||L?"command":"result",K=c||j;const Fe=NT(s),ze=Fe!==null&&((ce=s.result)==null?void 0:ce.trim())==="";let Be;t[45]!==ze||t[46]!==u||t[47]!==x||t[48]!==s?(Be=s.result!==null&&!ze?r.jsx(kT,{toolCall:s,resultExpanded:x,onToggleExpanded:()=>v(!x),isMobile:u}):null,t[45]=ze,t[46]=u,t[47]=x,t[48]=s,t[49]=Be):Be=t[49],W=Be;let _e;t[50]!==R?(_e=()=>{R&&M(!0)},t[50]=R,t[51]=_e):_e=t[51];const He=_e;if(s.name==="AskUserQuestion"){const de=(f==null?void 0:f.type)==="question"&&f.toolUseId===s.id,Ee=d==null?void 0:d.sessionId;let Ae;t[52]!==Te||t[53]!==de||t[54]!==Ee||t[55]!==s?(Ae=r.jsx(K_,{toolCall:s,expandToolPayloads:Te,isAwaitingAnswer:de,sessionId:Ee}),t[52]=Te,t[53]=de,t[54]=Ee,t[55]=s,t[56]=Ae):Ae=t[56],se=Ae;break e}const Ie=R?"py-1":"py-1.5",Ce=s.isError&&!R&&"rounded-md bg-destructive/5 px-2";t[57]!==Ie||t[58]!==Ce?(Q=G(Ie,Ce),t[57]=Ie,t[58]=Ce,t[59]=Q):Q=t[59],ee=R?r.jsxs(X,{type:"button",variant:"ghost",size:"xs",className:"h-auto w-full justify-start px-1 py-1 text-left",onClick:He,"aria-label":`Expand ${z} tool call`,title:je,children:[r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[r.jsx("span",{className:G("shrink-0 font-mono text-xs",pe),title:F,children:z}),Pe&&r.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",children:Pe})]}),r.jsx(Ze,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-end"}),r.jsx($x,{toolCall:s,isAgentActive:a})]}):u?r.jsx("div",{className:"flex items-center gap-1.5",title:je,children:r.jsx(ym,{toolCall:s,isMobile:!0,isAgentActive:a,displayName:z,summary:Pe,nameTitle:F,nameClass:pe,timeLabel:je,timeIso:Re})}):r.jsx("button",{type:"button",className:"flex w-full items-center gap-2 rounded-sm text-left hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",title:je,"aria-label":`Toggle ${z} details${Pe?`: ${Pe}`:""}`,"aria-expanded":K,"aria-controls":A,onClick:()=>{c||k(_T)},children:r.jsx(ym,{toolCall:s,isMobile:!1,isAgentActive:a,displayName:z,summary:Pe,nameTitle:F,nameClass:pe,timeLabel:je,timeIso:Re})}),oe=ze&&!R&&r.jsx(Gl,{src:Fe,alt:Fe.slice(Fe.lastIndexOf("/")+1),id:`tool-image:${s.id}`,className:"my-1.5",thumbnailClassName:"max-h-40"})}t[4]=A,t[5]=j,t[6]=w,t[7]=z,t[8]=o,t[9]=c,t[10]=m,t[11]=a,t[12]=L,t[13]=R,t[14]=u,t[15]=F,t[16]=f,t[17]=D.styleName,t[18]=D.summary,t[19]=x,t[20]=h,t[21]=d==null?void 0:d.sessionId,t[22]=l,t[23]=s,t[24]=H,t[25]=B,t[26]=W,t[27]=K,t[28]=V,t[29]=Y,t[30]=q,t[31]=J,t[32]=Z,t[33]=Q,t[34]=ee,t[35]=oe,t[36]=se}else H=t[24],B=t[25],W=t[26],K=t[27],V=t[28],Y=t[29],q=t[30],J=t[31],Z=t[32],Q=t[33],ee=t[34],oe=t[35],se=t[36];if(se!==Symbol.for("react.early_return_sentinel"))return se;let re;t[60]!==R||t[61]!==s.id||t[62]!==s.resultImages?(re=!R&&((we=s.resultImages)==null?void 0:we.map((pe,ue)=>r.jsx(Gl,{src:`data:${pe.source.media_type};base64,${pe.source.data}`,alt:`Tool result image ${ue+1}`,id:`tool-result-image:${s.id}:${ue}`,className:"my-1.5",thumbnailClassName:"max-h-40"},`${pe.source.media_type}-${pe.source.data.length}-${pe.source.data.slice(0,32)}-${pe.source.data.slice(-32)}`))),t[60]=R,t[61]=s.id,t[62]=s.resultImages,t[63]=re):re=t[63];let ie;t[64]!==R||t[65]!==J||t[66]!==Z?(ie=Z&&!R&&r.jsxs("div",{className:"mt-1 flex items-center gap-2 font-mono text-xs text-muted-foreground",children:[r.jsxs("span",{children:["source: ",Z.source]}),J&&(!$s()||Kc())&&r.jsxs(X,{type:"button",variant:"link",size:"xs",onClick:pe=>{pe.stopPropagation(),bi(J)},className:"h-auto px-0 text-muted-foreground",title:J,children:[r.jsx(Xp,{"data-icon":"inline-start"}),"Open SKILL.md"]})]}),t[64]=R,t[65]=J,t[66]=Z,t[67]=ie):ie=t[67];let ae;t[68]!==w||t[69]!==B||t[70]!==m||t[71]!==R||t[72]!==u||t[73]!==S||t[74]!==_||t[75]!==P||t[76]!==W||t[77]!==h||t[78]!==V||t[79]!==Y||t[80]!==q?(ae=u&&!R&&r.jsxs("div",{className:"flex gap-3 mt-1",children:[B&&r.jsx(ll,{isOpen:V,onClick:()=>y(!w),label:"Diff",controlsId:S}),r.jsx(ll,{isOpen:Y,onClick:()=>p(!m),label:"Input",controlsId:_}),W&&r.jsx(ll,{isOpen:q,onClick:()=>g(!h),label:"Result",controlsId:P})]}),t[68]=w,t[69]=B,t[70]=m,t[71]=R,t[72]=u,t[73]=S,t[74]=_,t[75]=P,t[76]=W,t[77]=h,t[78]=V,t[79]=Y,t[80]=q,t[81]=ae):ae=t[81];let te;t[82]!==B||t[83]!==R||t[84]!==u||t[85]!==S||t[86]!==V||t[87]!==s?(te=u&&!R&&B&&r.jsx(kt,{open:V,children:r.jsx(Nt,{id:S,children:r.jsx(wm,{toolCall:s})})}),t[82]=B,t[83]=R,t[84]=u,t[85]=S,t[86]=V,t[87]=s,t[88]=te):te=t[88];let he;t[89]!==L||t[90]!==R||t[91]!==u||t[92]!==_||t[93]!==Y||t[94]!==s.input||t[95]!==s.name?(he=u&&!R&&r.jsx(kt,{open:Y,children:r.jsx(Nt,{id:_,children:s.name==="Bash"&&(typeof s.input.command=="string"||typeof s.input.cmd=="string")?r.jsx(dm,{input:s.input}):L?r.jsx(fm,{input:s.input}):r.jsx(Ql,{result:JSON.stringify(s.input),expanded:!0})})}),t[89]=L,t[90]=R,t[91]=u,t[92]=_,t[93]=Y,t[94]=s.input,t[95]=s.name,t[96]=he):he=t[96];let me;t[97]!==s.id||t[98]!==s.name||t[99]!==s.result?(me=(s.name==="Task"||s.name==="Agent")&&s.result===null&&r.jsx(gd,{toolUseId:s.id}),t[97]=s.id,t[98]=s.name,t[99]=s.result,t[100]=me):me=t[100];let le;t[101]!==R||t[102]!==u||t[103]!==P||t[104]!==W||t[105]!==q?(le=u&&!R&&W&&r.jsx(kt,{open:q,children:r.jsx(Nt,{id:P,children:W})}),t[101]=R,t[102]=u,t[103]=P,t[104]=W,t[105]=q,t[106]=le):le=t[106];let xe;t[107]!==E||t[108]!==N||t[109]!==A||t[110]!==H||t[111]!==B||t[112]!==u||t[113]!==W||t[114]!==K||t[115]!==s?(xe=!u&&r.jsx(kt,{open:K,children:r.jsxs(Nt,{id:A,onClick:TT,children:[H==="diff"&&B&&r.jsx(wm,{toolCall:s}),H==="command"&&(s.name==="Bash"?r.jsx(dm,{input:s.input}):r.jsx(fm,{input:s.input})),(H==="result"||H==="command")&&W,r.jsx("button",{type:"button",className:"mt-1 text-[10px] text-muted-foreground/50 transition-colors hover:text-muted-foreground","aria-expanded":N,"aria-controls":E,onClick:pe=>{pe.stopPropagation(),C(ET)},children:"input"}),r.jsx(kt,{open:N,children:r.jsx(Nt,{id:E,children:r.jsx(Ql,{result:JSON.stringify(s.input),expanded:!0})})})]})}),t[107]=E,t[108]=N,t[109]=A,t[110]=H,t[111]=B,t[112]=u,t[113]=W,t[114]=K,t[115]=s,t[116]=xe):xe=t[116];let ge;return t[117]!==ae||t[118]!==te||t[119]!==he||t[120]!==me||t[121]!==le||t[122]!==xe||t[123]!==Q||t[124]!==ee||t[125]!==oe||t[126]!==re||t[127]!==ie?(ge=r.jsxs("div",{className:Q,children:[ee,oe,re,ie,ae,te,he,me,le,xe]}),t[117]=ae,t[118]=te,t[119]=he,t[120]=me,t[121]=le,t[122]=xe,t[123]=Q,t[124]=ee,t[125]=oe,t[126]=re,t[127]=ie,t[128]=ge):ge=t[128],ge});function _T(n){return!n}function TT(n){return n.stopPropagation()}function ET(n){return!n}const PT=b.memo(function({plan:e,planFilePath:t,status:s,toolCalls:o,expandAll:i=!1,expandToolPayloads:a=!1,isAgentActive:l,skillMetadata:c}){const[d,f]=b.useState(!0),u=o.some(j=>j.name==="AskUserQuestion"&&j.result===null),[m,p]=b.useState(null),h=b.useRef(u);b.useEffect(()=>{u&&(h.current=!0)},[u]);const g=i||d,x=i||(m??(u||h.current)),v=s==="approved"?zi:s==="rejected"?zs:Ms,w=g?nt:Ze,y=x?nt:Ze;return r.jsxs(kt,{open:g,onOpenChange:f,className:G("my-2 rounded-lg border",s==="approved"?"border-success/20 bg-success/5":s==="rejected"?"border-destructive/20 bg-destructive/5":"border-warning/20 bg-warning/5"),children:[r.jsxs(an,{render:r.jsx(X,{type:"button",variant:"ghost",className:"h-auto w-full justify-start rounded-b-none p-2 text-left"}),children:[r.jsx(w,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),r.jsx(vv,{className:"size-4 text-muted-foreground","data-icon":"inline-start"}),r.jsx("span",{className:"text-sm font-medium",children:"Plan Mode"}),r.jsx(v,{className:G("size-4",s==="approved"?"text-success":s==="rejected"?"text-destructive":"text-warning")}),r.jsx("span",{className:"text-xs text-muted-foreground capitalize",children:s}),t&&r.jsx("span",{className:"ml-auto truncate font-mono text-xs text-muted-foreground",children:t})]}),r.jsx(Nt,{children:r.jsxs("div",{className:"px-3 pb-2",children:[r.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none border-t pt-2",children:r.jsx(Pn,{remarkPlugins:[Gi],components:$n,children:e})}),o.length>0&&r.jsxs(kt,{open:x,onOpenChange:p,className:"mt-2",children:[r.jsxs(an,{render:r.jsx(X,{type:"button",variant:"ghost",size:"xs",className:"-ml-2 text-muted-foreground"}),children:[r.jsx(y,{"data-icon":"inline-start"}),o.length," call",o.length===1?"":"s"," during planning"]}),r.jsx(Nt,{children:r.jsx("div",{className:"ml-4 mt-1 flex flex-col gap-1",children:o.map(j=>r.jsx(Ox,{toolCall:j,expandAll:i,expandToolPayloads:a,isAgentActive:l,skillMetadata:c},j.id))})})]})]})})]})}),AT=b.memo(function(e){const t=U.c(14),{content:s}=e,[o,i]=b.useState(!0),a=o?nt:Ze;let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(X,{type:"button",variant:"ghost",className:"h-auto w-full justify-start rounded-b-none p-2 text-left"}),t[0]=l):l=t[0];let c;t[1]!==a?(c=r.jsx(a,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),t[1]=a,t[2]=c):c=t[2];let d,f;t[3]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(yv,{className:"size-4 text-muted-foreground","data-icon":"inline-start"}),f=r.jsx("span",{className:"text-sm font-medium",children:"Session recap"}),t[3]=d,t[4]=f):(d=t[3],f=t[4]);let u;t[5]!==c?(u=r.jsxs(an,{render:l,children:[c,d,f]}),t[5]=c,t[6]=u):u=t[6];let m;t[7]===Symbol.for("react.memo_cache_sentinel")?(m=[Gi],t[7]=m):m=t[7];let p;t[8]!==s?(p=r.jsx(Nt,{children:r.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none border-t px-3 pb-2 pt-2",children:r.jsx(Pn,{remarkPlugins:m,components:$n,children:s})})}),t[8]=s,t[9]=p):p=t[9];let h;return t[10]!==o||t[11]!==u||t[12]!==p?(h=r.jsxs(kt,{open:o,onOpenChange:i,className:"my-2 rounded-lg border bg-card",children:[u,p]}),t[10]=o,t[11]=u,t[12]=p,t[13]=h):h=t[13],h}),cl=1;function jm(n,e){return!e||n.length<=cl?{visible:[...n],hidden:0}:{visible:n.slice(-cl),hidden:n.length-cl}}function RT(n){return`${n} earlier step${n===1?"":"s"}`}const MT=b.memo(function(e){const t=U.c(15),{blocks:s,expandAll:o}=e,[i,a]=b.useState(!1),l=o||i;if(s.length===0)return null;let c;t[0]!==o?(c=p=>{o||a(p)},t[0]=o,t[1]=c):c=t[1];let d;t[2]!==s.length||t[3]!==o||t[4]!==l?(d=!o&&r.jsxs(an,{render:r.jsx(X,{type:"button",variant:"ghost",size:"xs",className:"-ml-2 text-muted-foreground"}),children:[l?r.jsx(nt,{"data-icon":"inline-start"}):r.jsx(Ze,{"data-icon":"inline-start"}),r.jsxs("span",{children:["Thinking... (",s.length," block",s.length>1?"s":"",")"]})]}),t[2]=s.length,t[3]=o,t[4]=l,t[5]=d):d=t[5];let f;t[6]!==s?(f=s.map(IT),t[6]=s,t[7]=f):f=t[7];let u;t[8]!==f?(u=r.jsx(Nt,{className:"mt-1 flex flex-col gap-2",children:f}),t[8]=f,t[9]=u):u=t[9];let m;return t[10]!==l||t[11]!==c||t[12]!==d||t[13]!==u?(m=r.jsxs(kt,{open:l,onOpenChange:c,children:[d,u]}),t[10]=l,t[11]=c,t[12]=d,t[13]=u,t[14]=m):m=t[14],m});function IT(n,e){return r.jsx("pre",{className:"text-xs text-muted-foreground/70 font-mono whitespace-pre-wrap break-words max-h-96 overflow-y-auto",children:n.thinking},e)}function cr(n,e){if(!n&&!e)return{add:0,del:0};const t=n?n.split(`
|
|
106
|
+
`):[],s=e?e.split(`
|
|
107
|
+
`):[];if(t.length===0)return{add:s.length,del:0};if(s.length===0)return{add:0,del:t.length};const o=t.length,i=s.length;let a=0;for(;a<o&&a<i&&t[a]===s[a];)a++;let l=0;for(;l<o-a&&l<i-a&&t[o-1-l]===s[i-1-l];)l++;const c=o-a-l,d=i-a-l;if(c===0)return{add:d,del:0};if(d===0)return{add:0,del:c};let f=new Array(d+1).fill(0),u=new Array(d+1).fill(0);for(let p=1;p<=c;p++){u[0]=0;const h=t[a+p-1];for(let g=1;g<=d;g++)h===s[a+g-1]?u[g]=f[g-1]+1:u[g]=f[g]>u[g-1]?f[g]:u[g-1];[f,u]=[u,f]}const m=f[d];return{add:d-m,del:c-m}}function $T(n){let e=[];for(const a of n){if(a.isWrite){e=[{original:a.newString,current:a.newString}];continue}if(!a.oldString){e.push({original:a.oldString,current:a.newString});continue}let l=!1;for(const c of e){const d=c.current.indexOf(a.oldString);if(d!==-1){c.current=c.current.slice(0,d)+a.newString+c.current.slice(d+a.oldString.length),l=!0;break}}l||e.some(d=>d.original.includes(a.oldString)&&!d.current.includes(a.oldString))||e.push({original:a.oldString,current:a.newString})}const t=e.filter(a=>a.original!==a.current);if(t.length===0){if(n.some(l=>l.isWrite)&&e.length>0){const l=e.map(c=>c.current).join(`
|
|
108
|
+
`);if(l){const c=cr("",l);return{originalStr:"",currentStr:l,addCount:c.add,delCount:c.del}}}return{originalStr:"",currentStr:"",addCount:0,delCount:0}}const s=t.map(a=>a.original).join(`
|
|
109
|
+
`),o=t.map(a=>a.current).join(`
|
|
110
|
+
`),i=cr(s,o);return{originalStr:s,currentStr:o,addCount:i.add,delCount:i.del}}const OT=new Set(["echo","printf","true","false",":"]),DT=new Set(["find","grep","rg","ag","ack","locate","which","whereis"]),LT=new Set(["cat","head","tail","less","more","wc","stat","file","strings","jq","awk","cut","sort","uniq","tr"]),zT=new Set(["ls","tree","du"]);function FT(n){return n.split(/\|\||&&|[|;\n]/).map(e=>e.trim()).filter(Boolean)}function BT(n){const e=FT(n);let t=!1,s=!1,o=!1,i=!1;for(const a of e){const l=a.split(/\s+/)[0];if(!(!l||OT.has(l)))if(i=!0,DT.has(l))t=!0;else if(LT.has(l))s=!0;else if(zT.has(l))o=!0;else return"shell"}return i?o?"list":t?"search":s?"read":"shell":"shell"}const UT=/[\\/]claude(?:-\d+)?[\\/](?:[^\\/]+[\\/])+scratchpad[\\/]/i;function WT(n){return UT.test(n)}const HT=new Set(["Grep","Glob"]),KT=new Set(["Bash","PowerShell"]),qT=new Set(["Edit","Write","NotebookEdit","MultiEdit"]),VT=new Set(["Task","Agent"]);function Sm(n){const e=n.file_path??n.path;return typeof e=="string"?e:null}function GT(n){return typeof n.command=="string"?n.command:null}function YT(n){if(!n.startsWith("mcp__"))return null;const e=n.split("__")[1];return e?e.replace(/^claude[._]ai[._]/i,"").replace(/_/g," "):null}function XT(n,e){if(Array.isArray(e.edits)){let i=0,a=0;for(const l of e.edits){if(!l||typeof l!="object")continue;const{old_string:c,new_string:d}=l,f=cr(typeof c=="string"?c:"",typeof d=="string"?d:"");i+=f.add,a+=f.del}return{added:i,removed:a}}const t=n==="Edit"&&typeof e.old_string=="string"?e.old_string:"",s=typeof e.new_string=="string"?e.new_string:typeof e.content=="string"?e.content:typeof e.new_source=="string"?e.new_source:"",o=cr(t,s);return{added:o.add,removed:o.del}}function Gs(n,e,t=`${e}s`){return`${n} ${n===1?e:t}`}function JT(n){const e=Math.max(1,Math.floor(n/1e3));if(e<60)return`${e}s`;const t=Math.floor(e/60),s=e%60;if(t<60)return s>0?`${t}m ${s}s`:`${t}m`;const o=Math.floor(t/60),i=t%60;return i>0?`${o}h ${i}m`:`${o}h`}function QT(n,e={}){const t=new Set,s=new Set,o=new Set;let i=0,a=0,l=0,c=0,d=0,f=0,u=0,m=0,p=0,h=0,g=0,x=0;for(const k of n){const N=YT(k.name);if(N){p+=1,o.add(N);continue}if(qT.has(k.name)){const C=Sm(k.input),S=XT(k.name,k.input);C&&WT(C)?(l+=1,c+=S.added,d+=S.removed):(t.add(C??k.id),i+=S.added,a+=S.removed);continue}if(k.name==="Read"){const C=Sm(k.input);C?s.add(C):u+=1;continue}if(HT.has(k.name)){f+=1;continue}if(KT.has(k.name)){const C=GT(k.input);switch(C===null?"shell":BT(C)){case"search":f+=1;break;case"list":m+=1;break;case"read":u+=1;break;default:x+=1}continue}if(VT.has(k.name)){h+=1;continue}g+=1}const v=s.size>0?s.size:u,w=[],y=(k,N,C=0,S=0)=>{w.push(C>0||S>0?{key:k,text:N,added:C,removed:S}:{key:k,text:N})},j=e.thoughtForMs??0;if(j>0&&y("thought",`thought for ${JT(j)}`),t.size>0&&y("edit",`edited ${Gs(t.size,"file")}`,i,a),l>0&&y("scratchpad",`made ${l} scratchpad ${l===1?"edit":"edits"}`,c,d),f>0&&y("search",`searched for ${Gs(f,"pattern")}`),v>0&&y("read",`read ${Gs(v,"file")}`),m>0&&y("list",`listed ${Gs(m,"directory","directories")}`),p>0){const k=[...o].join(", ")||"MCP";y("mcp",p>1?`called ${k} ${p} times`:`called ${k}`)}return h>0&&y("agent",`ran ${Gs(h,"agent")}`),g>0&&y("other",`called ${Gs(g,"tool")}`),x>0&&y("bash",`ran ${x} shell ${x===1?"command":"commands"}`),{clauses:w}}const km="text-muted-foreground";function Nm(n){const e=U.c(4),{summary:t}=n;let s;e[0]!==t.clauses?(s=t.clauses.map(ZT),e[0]=t.clauses,e[1]=s):s=e[1];let o;return e[2]!==s?(o=r.jsx("span",{className:"text-xs text-muted-foreground",children:s}),e[2]=s,e[3]=o):o=e[3],o}function ZT(n,e){return r.jsxs("span",{children:[e>0&&", ",e===0?n.text[0].toUpperCase()+n.text.slice(1):n.text,n.added?r.jsxs("span",{className:"text-success",children:[" +",n.added]}):null,n.removed?r.jsxs("span",{className:"text-destructive",children:[" -",n.removed]}):null]},n.key)}const Cm=b.memo(function(e){const t=U.c(35),{toolCalls:s,expandAll:o,expandToolPayloads:i,activeToolCallId:a,isAgentActive:l,activityItems:c,thinkingCount:d,thoughtForMs:f,skillMetadata:u}=e,m=l===void 0?!1:l,p=d===void 0?0:d,h=f===void 0?0:f,[g,x]=b.useState(null),v=b.useRef(null),w=m&&s.some(e6);let y;t[0]!==s?(y=s.some(t6),t[0]=s,t[1]=y):y=t[1];const j=y,k=o||j||(g??w),N=g===null&&w&&!o&&!j,C=b.useRef(null),S=b.useRef(null);let _,P;t[2]!==a||t[3]!==s?(_=()=>{if(!a){C.current=null;return}a!==C.current&&s.some(W=>W.id===a)&&(C.current=a,x(!0),S.current=requestAnimationFrame(()=>{S.current=requestAnimationFrame(()=>{var W;S.current=null,(W=v.current)==null||W.scrollIntoView({behavior:"smooth",block:"nearest"})})}))},P=[a,s],t[2]=a,t[3]=s,t[4]=_,t[5]=P):(_=t[4],P=t[5]),b.useEffect(_,P);let A,E;t[6]===Symbol.for("react.memo_cache_sentinel")?(A=()=>()=>{S.current!==null&&cancelAnimationFrame(S.current)},E=[],t[6]=A,t[7]=E):(A=t[6],E=t[7]),b.useEffect(A,E);let T;if(t[8]!==s){const W=new Map;for(const K of s){const{label:V,styleName:Y}=ya(K),q=W.get(V);q?(q.count=q.count+1,q.hasError=q.hasError||!!K.isError):W.set(V,{count:1,styleName:Y,hasError:!!K.isError})}T=[...W].sort(n6),t[8]=s,t[9]=T}else T=t[9];const M=T;let I;t[10]!==h||t[11]!==s?(I=QT(s,{thoughtForMs:h}),t[10]=h,t[11]=s,t[12]=I):I=t[12];const R=I,$=function(K,V){const Y=m&&V&&K.result===null;return r.jsx("div",{ref:K.id===a?v:void 0,className:G(K.id===a&&"rounded-md ring-1 ring-ring"),children:r.jsx(Ox,{toolCall:K,expandAll:o,expandToolPayloads:i,isAgentActive:Y,skillMetadata:u})},K.id)};if(s.length===1&&p===0&&!c)return r.jsx("div",{className:"flex flex-col gap-2",children:$(s[0],!0)});if(k){let W;t[13]!==o||t[14]!==j||t[15]!==R||t[16]!==p?(W=!o&&!j&&r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:()=>x(!1),className:"-ml-2 text-muted-foreground",children:[r.jsx(nt,{"data-icon":"inline-start"}),R.clauses.length>0?r.jsx(Nm,{summary:R}):r.jsxs("span",{className:G("font-mono text-xs",km),children:["Thinking",p>1?` ×${p}`:""]})]}),t[13]=o,t[14]=j,t[15]=R,t[16]=p,t[17]=W):W=t[17];const K=c?(()=>{const Y=jm(c,N);return r.jsxs(r.Fragment,{children:[Y.hidden>0&&r.jsx(_m,{count:Y.hidden,onReveal:()=>x(!0)}),Y.visible.map((q,J)=>{if(q.kind==="thinking")return r.jsx(MT,{blocks:q.blocks,expandAll:!1},`thinking-${J}`);const Z=J===Y.visible.length-1;return q.toolCalls.map((Q,ee)=>$(Q,Z&&ee===q.toolCalls.length-1))})]})})():(()=>{const Y=jm(s,N);return r.jsxs(r.Fragment,{children:[Y.hidden>0&&r.jsx(_m,{count:Y.hidden,onReveal:()=>x(!0)}),Y.visible.map((q,J)=>$(q,J===Y.visible.length-1))]})})();let V;return t[18]!==W||t[19]!==K?(V=r.jsxs("div",{className:"motion-enter flex flex-col gap-2",children:[W,K]}),t[18]=W,t[19]=K,t[20]=V):V=t[20],V}let D;t[21]===Symbol.for("react.memo_cache_sentinel")?(D=()=>x(!0),t[21]=D):D=t[21];let O;t[22]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsx(Ze,{className:"mt-0.5 size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),t[22]=O):O=t[22];let L;t[23]!==R?(L=R.clauses.length>0&&r.jsx(Nm,{summary:R}),t[23]=R,t[24]=L):L=t[24];let z;t[25]!==p?(z=p>0&&r.jsxs("span",{className:G("font-mono text-xs",km),children:["Thinking",p>1?` ×${p}`:""]}),t[25]=p,t[26]=z):z=t[26];let F;t[27]!==M?(F=M.map(s6),t[27]=M,t[28]=F):F=t[28];let H;t[29]!==z||t[30]!==F?(H=r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[z,F]}),t[29]=z,t[30]=F,t[31]=H):H=t[31];let B;return t[32]!==L||t[33]!==H?(B=r.jsxs(X,{type:"button",variant:"ghost",onClick:D,className:"motion-enter h-auto w-full items-start justify-start gap-2 px-0 py-1 text-left whitespace-normal",children:[O,r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[L,H]})]}),t[32]=L,t[33]=H,t[34]=B):B=t[34],B});function _m(n){const e=U.c(6),{count:t,onReveal:s}=n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(nt,{"data-icon":"inline-start"}),e[0]=o):o=e[0];let i;e[1]!==t?(i=RT(t),e[1]=t,e[2]=i):i=e[2];let a;return e[3]!==s||e[4]!==i?(a=r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:s,className:"-ml-2 text-muted-foreground",children:[o,i]}),e[3]=s,e[4]=i,e[5]=a):a=e[5],a}function e6(n){return n.result===null}function t6(n){return n.name==="AskUserQuestion"}function n6(n,e){return e[1].count-n[1].count}function s6(n){const[e,t]=n,{count:s,styleName:o,hasError:i}=t;return r.jsxs("span",{className:G("font-mono text-xs",Ix(o,i)),children:[e,s>1?` ×${s}`:""]},e)}function o6(n){const e=U.c(15),{label:t,expanded:s,onToggle:o,compact:i}=n,l=(i===void 0?!1:i)&&"min-h-9";let c;e[0]!==l?(c=G("group/fold h-auto min-h-8 w-full cursor-pointer justify-start gap-1.5 px-1 text-left text-xs font-normal text-muted-foreground",l),e[0]=l,e[1]=c):c=e[1];const d=s&&"rotate-90";let f;e[2]!==d?(f=G("size-3 shrink-0 transition-transform duration-150 motion-reduce:transition-none",d),e[2]=d,e[3]=f):f=e[3];let u;e[4]!==f?(u=r.jsx(Ze,{"data-icon":"inline-start",className:f}),e[4]=f,e[5]=u):u=e[5];let m;e[6]!==t?(m=r.jsx("span",{className:"tabular-nums",children:t}),e[6]=t,e[7]=m):m=e[7];let p;e[8]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx("span",{"aria-hidden":!0,className:"pointer-events-none ml-1 h-px flex-1 bg-border/40 transition-colors group-hover/fold:bg-border/70"}),e[8]=p):p=e[8];let h;return e[9]!==s||e[10]!==o||e[11]!==c||e[12]!==u||e[13]!==m?(h=r.jsxs(X,{type:"button",variant:"ghost",onClick:o,"aria-expanded":s,className:c,children:[u,m,p]}),e[9]=s,e[10]=o,e[11]=c,e[12]=u,e[13]=m,e[14]=h):h=e[14],h}const Dx="synthesizedFrom",Tm=/[.*+?[\]{}()^$|]/,r6=/[$*?`~]|\\\s/,Lx=/<<(-?)\s*(?:'([^']+)'|"([^"]+)")/,i6=new RegExp(Lx,"g");function wd(n,e,t,s){return{id:e,name:t,input:{...s,[Dx]:n.name},result:null,isError:!1,timestamp:n.timestamp}}function a6(n){return typeof n.input[Dx]=="string"}function l6(n){const e=n[0];return(e==='"'||e==="'")&&n.at(-1)===e?n.slice(1,-1):n}function Em(n){const e=[];for(const t of n.split("/"))!t||t==="."||(t===".."?e.pop():e.push(t));return`/${e.join("/")}`}function wa(n,e){const t=l6(n.trim());return!t||r6.test(t)?null:t.startsWith("/")?Em(t):e?Em(`${e}/${t}`):null}function c6(n){const e=[];let t="",s=null;function o(i){t.trim()&&e.push({text:t.trim(),piped:i}),t=""}for(let i=0;i<n.length;i++){const a=n[i];if(s){t+=a,a===s&&(s=null);continue}if(a==='"'||a==="'"){s=a,t+=a;continue}if(a==="|"){o(!0),n[i+1]==="|"&&i++;continue}if(a===";"||a==="&"&&n[i+1]==="&"){o(!1),a==="&"&&i++;continue}t+=a}return o(!1),e}function d6(n){const e=n.split(`
|
|
111
|
+
`),t=[];let s=0;for(;s<e.length;){const o=e[s];s++;const i=new Map;for(const a of o.matchAll(i6)){const[,l,c,d]=a,f=c??d,u=[];for(;s<e.length&&e[s].trim()!==f;)u.push(l?e[s].replace(/^\t+/,""):e[s]),s++;s>=e.length||(s++,i.set(f,u.join(`
|
|
112
|
+
`)))}for(const a of c6(o))t.push({text:a.text,bodies:i,piped:a.piped})}return t}function u6(n,e){const t=n.match(/^cd\s+(?:"([^"]*)"|'([^']*)'|([^\s;&|]+))\s*$/);return t?wa(t[1]??t[2]??t[3]??"",e):null}function f6(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 m6(n,e){if(n.piped||n.bodies.size===0)return null;const t=n.text.match(Lx);if(!t)return null;const s=n.bodies.get(t[2]??t[3]??"");if(s===void 0)return null;const o=f6(n.text);if(!o)return null;const i=wa(o,e);return i?{name:"Write",input:{file_path:i,content:s}}:null}function Pm(n,e){const t=e==="replacement";let s="";for(let o=0;o<n.length;o++){const i=n[o];if(i==="\\"){const a=n[o+1];if(a===void 0||a==="|"||!Tm.test(a)&&!"\\/&#".includes(a))return null;s+=a,o++;continue}if(i==="&"&&t||!t&&Tm.test(i))return null;s+=i}return s}const p6=/^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 h6(n,e){var m;const t=(m=n.text.match(p6))==null?void 0:m.groups;if(!t)return null;const{pattern:s,replacement:o,flags:i,dquoted:a,squoted:l,bare:c}=t;if(/[^g]/.test(i))return null;const d=Pm(s,"pattern"),f=Pm(o,"replacement");if(!d||f===null)return null;const u=wa(a??l??c??"",e);return u?{name:"Edit",input:{file_path:u,old_string:d,new_string:f,replace_all:i.includes("g")}}:null}function zx(n,e=null){const t=n.input.command;if(typeof t!="string"||!t)return[];const s=[];let o=e;for(const i of d6(t)){const a=u6(i.text,o);if(a){o=a;continue}const l=m6(i,o)??h6(i,o);l&&s.push(wd(n,`${n.id}:bash-${s.length}`,l.name,l.input))}return s}function Fx(n,e){const t=n.input.edits,s=n.input.file_path??n.input.path;if(!Array.isArray(t)||typeof s!="string")return[];const o=wa(s,e)??s,i=[];for(const[a,l]of t.entries()){if(typeof l!="object"||l===null)continue;const{old_string:c,new_string:d,replace_all:f}=l;typeof c!="string"||typeof d!="string"||i.push(wd(n,`${n.id}:edit-${a}`,"Edit",{file_path:o,old_string:c,new_string:d,replace_all:f===!0}))}return i}function Bx(n,e){const t=[n.input.patch,n.input.value,n.input.input].find(s=>typeof s=="string");return t?d1("apply_patch",t,n.id,n.timestamp,e??"").map(s=>wd(n,s.id,s.name,s.input)):[]}function qo(n,e=null){const t=[];for(const s of n)s.isError||(s.name==="Edit"||s.name==="Write"?t.push(s):s.name==="MultiEdit"?t.push(...Fx(s,e)):s.name==="Bash"?t.push(...zx(s,e)):s.name==="apply_patch"&&t.push(...Bx(s,e)));return t}function _i(n,e=null){for(const t of n)if(!t.isError&&(t.name==="Edit"||t.name==="Write"||t.name==="MultiEdit"&&Fx(t,e).length>0||t.name==="Bash"&&zx(t,e).length>0||t.name==="apply_patch"&&Bx(t,e).length>0))return!0;return!1}const g6=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"]),x6={json:Du,jsonc:Du,md:La,mdx:La,txt:La,png:Ns,jpg:Ns,jpeg:Ns,gif:Ns,webp:Ns,svg:Ns,ico:Ns,sh:Hr,bash:Hr,zsh:Hr,fish:Hr};function Ux(n){const e=n.split("/").at(-1)??n,t=e.lastIndexOf(".");return t===-1?"":e.slice(t+1).toLowerCase()}function b6(n){const e=Ux(n);return x6[e]??(g6.has(e)?gr:qp)}function Zl(n){const e=U.c(11),{add:t,del:s,dimmed:o,className:i}=n,a=o&&"opacity-40";let l;e[0]!==i||e[1]!==a?(l=G("flex shrink-0 items-center gap-1 font-mono text-xs tabular-nums",a,i),e[0]=i,e[1]=a,e[2]=l):l=e[2];let c;e[3]!==t?(c=t>0&&r.jsxs("span",{className:"text-success",children:["+",t]}),e[3]=t,e[4]=c):c=e[4];let d;e[5]!==s?(d=s>0&&r.jsxs("span",{className:"text-destructive",children:["-",s]}),e[5]=s,e[6]=d):d=e[6];let f;return e[7]!==l||e[8]!==c||e[9]!==d?(f=r.jsxs("span",{className:l,children:[c,d]}),e[7]=l,e[8]=c,e[9]=d,e[10]=f):f=e[10],f}const Am=5;function jd(n){const e=U.c(11),{add:t,del:s}=n,o=t+s;if(o===0)return null;let i,a,l;if(e[0]!==t||e[1]!==o){const f=Math.round(t/o*Am);i=Am-f,a="flex items-center gap-[1px] shrink-0 ml-1",l=Array.from({length:f},y6),e[0]=t,e[1]=o,e[2]=i,e[3]=a,e[4]=l}else i=e[2],a=e[3],l=e[4];let c;e[5]!==i?(c=Array.from({length:i},v6),e[5]=i,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==l||e[9]!==c?(d=r.jsxs("span",{className:a,children:[l,c]}),e[7]=a,e[8]=l,e[9]=c,e[10]=d):d=e[10],d}function v6(n,e){return r.jsx("span",{className:"inline-block size-1.5 rounded-xs bg-destructive/70"},`d${e}`)}function y6(n,e){return r.jsx("span",{className:"inline-block size-1.5 rounded-xs bg-success/70"},`a${e}`)}const Ti="cogpit:open-subagent";function Wx(n){const e=U.c(3),{hasEdit:t,hasWrite:s}=n;if(t&&s){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("span",{className:"shrink-0 text-xs font-bold text-warning",children:"E+W"}),e[0]=i):i=e[0],i}if(s){let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("span",{className:"shrink-0 text-xs font-bold text-success",children:"W"}),e[1]=i):i=e[1],i}let o;return e[2]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx("span",{className:"shrink-0 text-xs font-bold text-warning",children:"E"}),e[2]=o):o=e[2],o}function Sd(n){const e=U.c(2),{agentId:t}=n;let s;return e[0]!==t?(s=r.jsx(X,{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:o=>{o.stopPropagation(),window.dispatchEvent(new CustomEvent(Ti,{detail:{agentId:t}}))},children:"S"}),e[0]=t,e[1]=s):s=e[1],s}const Hx=b.memo(function(e){const t=U.c(96),{file:s,defaultOpen:o,isHighlighted:i,diffMode:a}=e,{ref:l,isNear:c}=ox(),[d,f]=b.useState(o),[u,m]=b.useState(o),p=b.useRef(o);let h;t[0]===Symbol.for("react.memo_cache_sentinel")?(h=Ne=>{f(Ne),Ne?b.startTransition(()=>m(!0)):m(!1)},t[0]=h):h=t[0];const g=h;let x,v;t[1]!==o?(x=()=>{p.current!==o&&(p.current=o,g(o))},v=[o,g],t[1]=o,t[2]=x,t[3]=v):(x=t[2],v=t[3]),b.useEffect(x,v);let w,y;t[4]!==i?(w=()=>{i&&g(!0)},y=[i,g],t[4]=i,t[5]=w,t[6]=y):(w=t[5],y=t[6]),b.useEffect(w,y);let j;t[7]!==s.filePath?(j=Ux(s.filePath),t[7]=s.filePath,t[8]=j):j=t[8];const k=j,N=s.netOriginal,C=s.netCurrent,S=!!(N||C);let _;t[9]!==s.edits?(_=s.edits.some(k6),t[9]=s.edits,t[10]=_):_=t[10];const A=a==="per-edit"?_:S,E=u&&c&&A,[T,M]=b.useState(0);let I;t[11]===Symbol.for("react.memo_cache_sentinel")?(I=Ne=>{if(!Ne)return;const Re=Ne.offsetHeight;M(Te=>Te===Re?Te:Re)},t[11]=I):I=t[11];const R=I,$=s.turnRange[0]===s.turnRange[1]?`T${s.turnRange[0]+1}`:`T${s.turnRange[0]+1}–T${s.turnRange[1]+1}`,D=s.filePath,O=i?"border-ring ring-2 ring-ring/20":"border-border";let L;t[12]!==O?(L=G("rounded-lg border bg-card transition-colors",O),t[12]=O,t[13]=L):L=t[13];let z;t[14]!==d?(z=()=>g(!d),t[14]=d,t[15]=z):z=t[15];let F;t[16]!==d?(F=d?r.jsx(nt,{"data-icon":"inline-start",className:"size-3 shrink-0 text-muted-foreground"}):r.jsx(Ze,{"data-icon":"inline-start",className:"size-3 shrink-0 text-muted-foreground"}),t[16]=d,t[17]=F):F=t[17];let H;t[18]!==k?(H=r.jsx("span",{className:"shrink-0 font-mono text-xs font-bold text-muted-foreground",children:k}),t[18]=k,t[19]=H):H=t[19];let B;t[20]!==s.opTypes?(B=s.opTypes.includes("Edit"),t[20]=s.opTypes,t[21]=B):B=t[21];let W;t[22]!==s.opTypes?(W=s.opTypes.includes("Write"),t[22]=s.opTypes,t[23]=W):W=t[23];let K;t[24]!==B||t[25]!==W?(K=r.jsx(Wx,{hasEdit:B,hasWrite:W}),t[24]=B,t[25]=W,t[26]=K):K=t[26];let V;t[27]!==s.shortPath?(V=r.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",children:s.shortPath}),t[27]=s.shortPath,t[28]=V):V=t[28];let Y;t[29]!==$?(Y=r.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:$}),t[29]=$,t[30]=Y):Y=t[30];let q;t[31]!==s.editCount?(q=s.editCount>1&&r.jsxs(Me,{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]=q):q=t[32];let J;t[33]!==d||t[34]!==z||t[35]!==F||t[36]!==H||t[37]!==K||t[38]!==V||t[39]!==Y||t[40]!==q?(J=r.jsxs(X,{type:"button",variant:"ghost",onClick:z,className:"h-auto min-w-0 flex-1 justify-start gap-1.5 rounded-r-none px-2 py-1 font-normal","aria-expanded":d,children:[F,H,K,V,Y,q]}),t[33]=d,t[34]=z,t[35]=F,t[36]=H,t[37]=K,t[38]=V,t[39]=Y,t[40]=q,t[41]=J):J=t[41];let Z;t[42]!==s.subAgentId?(Z=s.subAgentId&&r.jsx(Sd,{agentId:s.subAgentId}),t[42]=s.subAgentId,t[43]=Z):Z=t[43];let Q;t[44]!==s.filePath?(Q=r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>bi(s.filePath),"aria-label":"Open file in editor"}),t[44]=s.filePath,t[45]=Q):Q=t[45];let ee;t[46]===Symbol.for("react.memo_cache_sentinel")?(ee=r.jsx(mr,{"data-icon":"inline-start"}),t[46]=ee):ee=t[46];let oe;t[47]!==Q?(oe=r.jsx(Pt,{render:Q,children:ee}),t[47]=Q,t[48]=oe):oe=t[48];let se;t[49]===Symbol.for("react.memo_cache_sentinel")?(se=r.jsx(At,{children:"Open in editor"}),t[49]=se):se=t[49];let re;t[50]!==oe?(re=r.jsxs(Et,{children:[oe,se]}),t[50]=oe,t[51]=re):re=t[51];let ie;t[52]!==s.filePath?(ie=r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>bi(s.filePath,{mode:"diff"}),"aria-label":"View git diff"}),t[52]=s.filePath,t[53]=ie):ie=t[53];let ae;t[54]===Symbol.for("react.memo_cache_sentinel")?(ae=r.jsx(wv,{"data-icon":"inline-start"}),t[54]=ae):ae=t[54];let te;t[55]!==ie?(te=r.jsx(Pt,{render:ie,children:ae}),t[55]=ie,t[56]=te):te=t[56];let he;t[57]===Symbol.for("react.memo_cache_sentinel")?(he=r.jsx(At,{children:"View git diff"}),t[57]=he):he=t[57];let me;t[58]!==te?(me=r.jsxs(Et,{children:[te,he]}),t[58]=te,t[59]=me):me=t[59];let le;t[60]!==re||t[61]!==me?(le=r.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[re,me]}),t[60]=re,t[61]=me,t[62]=le):le=t[62];let xe;t[63]!==s.addCount?(xe=s.addCount>0&&r.jsxs("span",{className:"font-mono text-xs tabular-nums text-success",children:["+",s.addCount]}),t[63]=s.addCount,t[64]=xe):xe=t[64];let ge;t[65]!==s.delCount?(ge=s.delCount>0&&r.jsxs("span",{className:"font-mono text-xs tabular-nums text-destructive",children:["-",s.delCount]}),t[65]=s.delCount,t[66]=ge):ge=t[66];let ce;t[67]!==s.addCount||t[68]!==s.delCount?(ce=r.jsx(jd,{add:s.addCount,del:s.delCount}),t[67]=s.addCount,t[68]=s.delCount,t[69]=ce):ce=t[69];let we;t[70]!==Z||t[71]!==le||t[72]!==xe||t[73]!==ge||t[74]!==ce?(we=r.jsxs("div",{className:"flex items-center gap-1.5 pr-2 shrink-0",children:[Z,le,xe,ge,ce]}),t[70]=Z,t[71]=le,t[72]=xe,t[73]=ge,t[74]=ce,t[75]=we):we=t[75];let pe;t[76]!==J||t[77]!==we?(pe=r.jsxs("div",{className:"group sticky top-0 z-10 flex w-full items-center rounded-t-lg bg-card transition-colors hover:bg-accent",children:[J,we]}),t[76]=J,t[77]=we,t[78]=pe):pe=t[78];let ue;t[79]!==a||t[80]!==s.edits||t[81]!==s.filePath||t[82]!==s.netStartLine||t[83]!==A||t[84]!==T||t[85]!==C||t[86]!==N||t[87]!==d||t[88]!==E?(ue=r.jsx(w6,{showDiff:E,open:d,hasDiff:A,diffRef:R,lastDiffHeight:T,oldString:N,newString:C,filePath:s.filePath,diffMode:a,edits:s.edits,netStartLine:s.netStartLine}),t[79]=a,t[80]=s.edits,t[81]=s.filePath,t[82]=s.netStartLine,t[83]=A,t[84]=T,t[85]=C,t[86]=N,t[87]=d,t[88]=E,t[89]=ue):ue=t[89];let je;return t[90]!==s.filePath||t[91]!==l||t[92]!==L||t[93]!==pe||t[94]!==ue?(je=r.jsxs("div",{ref:l,"data-file-path":D,className:L,children:[pe,ue]}),t[90]=s.filePath,t[91]=l,t[92]=L,t[93]=pe,t[94]=ue,t[95]=je):je=t[95],je}),w6=b.memo(function(e){const t=U.c(15),{showDiff:s,open:o,hasDiff:i,diffRef:a,lastDiffHeight:l,oldString:c,newString:d,filePath:f,diffMode:u,edits:m,netStartLine:p}=e;if(s){let h;t[0]!==u||t[1]!==m||t[2]!==f||t[3]!==p||t[4]!==d||t[5]!==c?(h=u==="per-edit"?r.jsx(S6,{edits:m,filePath:f}):r.jsx(bd,{oldString:c,newString:d,filePath:f,compact:!1,startLine:p,hideHeader:!0}),t[0]=u,t[1]=m,t[2]=f,t[3]=p,t[4]=d,t[5]=c,t[6]=h):h=t[6];let g;return t[7]!==u||t[8]!==a||t[9]!==h?(g=r.jsx("div",{ref:a,className:"motion-enter overflow-hidden rounded-b",children:h},u),t[7]=u,t[8]=a,t[9]=h,t[10]=g):g=t[10],g}if(o&&l>0){let h;return t[11]!==l?(h=r.jsx("div",{style:{height:l}}),t[11]=l,t[12]=h):h=t[12],h}if(o&&!i){const h=u==="per-edit"?"No edits":"No net changes (all edits cancelled out)";let g;return t[13]!==h?(g=r.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}),Rm=3,j6=5,S6=b.memo(function(e){const t=U.c(9),{edits:s,filePath:o}=e,i=s.length,a=s.filter(N6),l=a.length>Rm,[c,d]=b.useState(l?Rm:a.length);b.useEffect(()=>{if(c>=a.length)return;const x=requestAnimationFrame(()=>{d(v=>Math.min(v+j6,a.length))});return()=>cancelAnimationFrame(x)},[c,a.length]);const f=l?a.slice(0,c):a,u="divide-y divide-border/30";let m;t[0]!==o||t[1]!==i?(m=(x,v)=>r.jsxs("div",{children:[i>1&&r.jsxs("div",{className:"flex items-center gap-2 bg-muted/30 px-2.5 py-1",children:[r.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:[x.toolName," ",v+1,"/",i]}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["T",x.turnIndex+1]}),x.agentId&&r.jsx(Sd,{agentId:x.agentId})]}),r.jsx(bd,{oldString:x.oldString,newString:x.newString,filePath:o,compact:!1,startLine:x.startLine,hideHeader:!0})]},x.id),t[0]=o,t[1]=i,t[2]=m):m=t[2];const p=f.map(m);let h;t[3]!==a.length||t[4]!==c?(h=c<a.length&&r.jsxs("div",{className:"py-1.5 text-center text-xs text-muted-foreground",children:["Loading ",a.length-c," more edits…"]}),t[3]=a.length,t[4]=c,t[5]=h):h=t[5];let g;return t[6]!==p||t[7]!==h?(g=r.jsxs("div",{className:u,children:[p,h]}),t[6]=p,t[7]=h,t[8]=g):g=t[8],g});function k6(n){return!!(n.oldString||n.newString)}function N6(n){return!!(n.oldString||n.newString)}const dl=new Map;function C6(n){var j;const e=vn("hostFiles"),{sessionSource:t}=it(),s=t==null?void 0:t.dirName,o=St(s)==="codex",i=n.turns.length,a=((j=n.turns.at(-1))==null?void 0:j.toolCalls.length)??0,l=b.useMemo(()=>{let k=0;for(const N of n.turns){k+=N.toolCalls.length;for(const C of N.subAgentActivity)k+=C.toolCalls.length}return k},[i,a]),c=b.useMemo(()=>{const k=[];for(let N=0;N<n.turns.length;N++)for(const C of n.turns[N].subAgentActivity){const S=o&&(C.status==="completed"||C.status==="failed"||C.status==="interrupted");(C.isBackground||S)&&C.toolCalls.length===0&&k.push({agentId:C.agentId,turnIndex:N})}return k},[n.turns,l,o]),[d,f]=b.useState(new Map),u=b.useRef(new Set);b.useEffect(()=>{if(!s||!n.sessionId||c.length===0)return;const k=[];for(const{agentId:S}of c){const _=Lt(`${s}/${n.sessionId}/${S}`);if(!u.current.has(_)){if(dl.has(_)){f(P=>{const A=new Map(P);return A.set(S,dl.get(_)),A}),u.current.add(_);continue}k.push({agentId:S,cacheKey:_})}}if(k.length===0)return;let N=!1;async function C(){const S=new Map;await Promise.all(k.map(async({agentId:_,cacheKey:P})=>{try{const A=`/api/sessions/${encodeURIComponent(s)}/${encodeURIComponent(n.sessionId)}/subagents/agent-${encodeURIComponent(_)}.jsonl`,E=await ye(A);if(!E.ok)return;const T=await E.text(),I=yx(T,_).flatMap(R=>qo(R.toolCalls,n.cwd));dl.set(P,I),u.current.add(P),S.set(_,I)}catch{}})),!N&&S.size>0&&f(_=>{const P=new Map(_);for(const[A,E]of S)P.set(A,E);return P})}return C(),()=>{N=!0}},[s,n.sessionId,n.cwd,c]);const m=b.useMemo(()=>{const k=[],N=new Set;for(let C=0;C<n.turns.length;C++){const S=n.turns[C];for(const _ of qo(S.toolCalls,n.cwd))k.push({turnIndex:C,toolCall:_});for(const _ of S.subAgentActivity){for(const P of qo(_.toolCalls,n.cwd))k.push({turnIndex:C,toolCall:P,agentId:_.agentId});if((_.isBackground||o)&&_.toolCalls.length===0&&!N.has(_.agentId)){N.add(_.agentId);const P=d.get(_.agentId);if(P)for(const A of P)k.push({turnIndex:C,toolCall:A,agentId:_.agentId})}}}return k},[l,n.turns,d,o]),p=b.useMemo(()=>{const k=new Set;for(const N of m){const C=Kx(N.toolCall);C&&k.add(C)}return[...k]},[m]),[h,g]=b.useState(new Map);b.useEffect(()=>{if(!e||p.length===0){g(new Map);return}let k=!1;return Promise.all(p.map(N=>ye(`/api/file-content?path=${encodeURIComponent(N)}`).then(C=>C.ok?C.text():null).then(C=>C?[N,C]:null).catch(()=>null))).then(N=>{if(k)return;const C=new Map;for(const S of N)S&&C.set(S[0],S[1]);g(C)}),()=>{k=!0}},[e,p]);const x=n.turns.length-1,v=b.useMemo(()=>Ei(m,"all",h),[m,h]),w=b.useMemo(()=>Ei(m,x,h),[m,x,h]),y=b.useMemo(()=>{const k=new Map;for(const N of n.turns)for(const C of N.subAgentActivity)k.has(C.agentId)||k.set(C.agentId,{name:C.agentName,type:C.subagentType});return k},[n.turns]);return{fileChanges:m,fileContents:h,groupedByFile:v,groupedLastTurn:w,lastTurnIndex:x,agentMap:y}}function Mm(n,e){if(!n||!e)return 1;const t=n.indexOf(e);if(t===-1)return 1;let s=1;for(let o=0;o<t;o++)n[o]===`
|
|
113
|
+
`&&s++;return s}function Kx(n){return String(n.input.file_path??n.input.path??"")}function _6(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}}function Ei(n,e,t){const s=new Map;for(const i of n){if(e!=="all"&&i.turnIndex!==e)continue;const a=Kx(i.toolCall);if(!a)continue;let l=s.get(a);l||(l=[],s.set(a,l)),l.push(i)}const o=[];for(const[i,a]of s){const l=[],c=[];let d=1/0,f=-1/0,u=!1,m=!1,p;const h=t==null?void 0:t.get(i);for(let v=0;v<a.length;v++){const w=a[v],y=_6(w.toolCall);l.push(y),w.turnIndex<d&&(d=w.turnIndex),w.turnIndex>f&&(f=w.turnIndex),w.toolCall.name==="Edit"?u=!0:m=!0,w.agentId&&(p=w.agentId),c.push({id:w.toolCall.id,oldString:y.oldString,newString:y.newString,toolName:w.toolCall.name,turnIndex:w.turnIndex,agentId:w.agentId,startLine:w.toolCall.name==="Write"?1:Mm(h,y.newString||y.oldString)})}const g=$T(l),x=[];u&&x.push("Edit"),m&&x.push("Write"),o.push({filePath:i,shortPath:i.split("/").slice(-3).join("/"),editCount:a.length,turnRange:[d,f],opTypes:x,netOriginal:g.originalStr,netCurrent:g.currentStr,addCount:g.addCount,delCount:g.delCount,subAgentId:p??null,edits:c,netStartLine:g.currentStr?Mm(h,g.currentStr):c.length>0?c[0].startLine:1})}return o.sort((i,a)=>i.turnRange[1]-a.turnRange[1]||i.turnRange[0]-a.turnRange[0]||i.filePath.localeCompare(a.filePath)),o}function T6(n,e,t,s){const o=new Map;for(const a of n){if(!a.agentId||e!=="all"&&a.turnIndex!==e)continue;let l=o.get(a.agentId);l||(l=[],o.set(a.agentId,l)),l.push(a)}const i=[];for(const[a,l]of o){const c=Ei(l,"all",s);if(c.length===0)continue;let d=0,f=0;for(const m of c)d+=m.addCount,f+=m.delCount;const u=t.get(a);i.push({agentId:a,agentName:(u==null?void 0:u.name)??null,subagentType:(u==null?void 0:u.type)??null,files:c,totalAdd:d,totalDel:f})}return i.sort((a,l)=>{var f,u;const c=((f=a.files[0])==null?void 0:f.turnRange[0])??0,d=((u=l.files[0])==null?void 0:u.turnRange[0])??0;return c-d}),i}const dr="cogpit:focus-file",E6="cogpit:file-changes-prefs",P6={expanded:!0,diffMode:"net",scope:"last",groupByAgent:!1};function A6(n){const e=U.c(36),{group:t,allExpanded:s,highlightPath:o,diffMode:i}=n;let a;e[0]!==t.agentId||e[1]!==t.agentName?(a=t.agentName||t.agentId.slice(0,8),e[0]=t.agentId,e[1]=t.agentName,e[2]=a):a=e[2];const l=a,c=t.subagentType,d=`Open subagent ${t.agentId}`;let f;e[3]!==t.agentId?(f=()=>{window.dispatchEvent(new CustomEvent(Ti,{detail:{agentId:t.agentId}}))},e[3]=t.agentId,e[4]=f):f=e[4];let u;e[5]!==l||e[6]!==d||e[7]!==f?(u=r.jsx(X,{type:"button",variant:"ghost",size:"xs",className:"h-auto min-w-0 truncate px-1 text-xs font-semibold",title:d,onClick:f,children:l}),e[5]=l,e[6]=d,e[7]=f,e[8]=u):u=e[8];let m;e[9]!==c?(m=c&&r.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=r.jsx(Me,{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=r.jsx("div",{className:"flex-1"}),e[13]=h):h=e[13];let g;e[14]!==t.totalAdd?(g=r.jsxs("span",{className:"font-mono text-xs tabular-nums text-success",children:["+",t.totalAdd]}),e[14]=t.totalAdd,e[15]=g):g=e[15];let x;e[16]!==t.totalDel?(x=r.jsxs("span",{className:"font-mono text-xs tabular-nums text-destructive",children:["-",t.totalDel]}),e[16]=t.totalDel,e[17]=x):x=e[17];let v;e[18]!==u||e[19]!==m||e[20]!==p||e[21]!==g||e[22]!==x?(v=r.jsxs("div",{className:"flex items-center gap-2 px-1.5 pt-1.5 pb-0.5",children:[u,m,p,h,g,x]}),e[18]=u,e[19]=m,e[20]=p,e[21]=g,e[22]=x,e[23]=v):v=e[23];let w;if(e[24]!==s||e[25]!==i||e[26]!==t.files||e[27]!==o){let j;e[29]!==s||e[30]!==i||e[31]!==o?(j=k=>r.jsx(Hx,{file:k,defaultOpen:s,isHighlighted:o===k.filePath,diffMode:i},k.filePath),e[29]=s,e[30]=i,e[31]=o,e[32]=j):j=e[32],w=t.files.map(j),e[24]=s,e[25]=i,e[26]=t.files,e[27]=o,e[28]=w}else w=e[28];let y;return e[33]!==v||e[34]!==w?(y=r.jsxs("div",{className:"flex flex-col gap-1",children:[v,w]}),e[33]=v,e[34]=w,e[35]=y):y=e[35],y}const R6=b.memo(function({session:e,sessionChangeKey:t}){const s=b.useRef(null),o=b.useRef(null),i=b.useRef(!0),a=b.useRef(!1),l=b.useRef(0),c=b.useRef(e.turns.length),[d,f]=b.useState(!1),[u,m]=b.useState(!1),[p,h]=ha(E6,{}),g={...P6,...p},x=g.expanded,v=g.diffMode,w=g.groupByAgent,[y,j]=b.useState(g.scope),k=b.useCallback(q=>{h(J=>({...J,expanded:q}))},[h]),N=b.useCallback(q=>{h(J=>({...J,diffMode:q}))},[h]),C=b.useCallback(q=>{h(J=>({...J,groupByAgent:q}))},[h]);b.useEffect(()=>{typeof y!="number"&&h(q=>({...q,scope:y}))},[y,h]);const[S,_]=b.useState(null),P=b.useRef(null),{fileChanges:A,fileContents:E,groupedByFile:T,groupedLastTurn:M,lastTurnIndex:I,agentMap:R}=C6(e),$=b.useMemo(()=>typeof y!="number"?null:Ei(A,y,E),[A,y,E]);function D(){return typeof y=="number"?$??[]:y==="all"?T:M}const O=D(),L=b.useMemo(()=>w?T6(A,typeof y=="number"?y:y==="all"?"all":I,R,E):[],[w,A,y,I,R,E]);b.useEffect(()=>{const q=J=>{const Z=J.detail;Z!=null&&Z.filePath&&(j(Z.turnIndex),_(Z.filePath),P.current&&clearTimeout(P.current),P.current=setTimeout(()=>_(null),3e3),requestAnimationFrame(()=>{var ee;const Q=(ee=s.current)==null?void 0:ee.querySelector(`[data-file-path="${CSS.escape(Z.filePath)}"]`);Q==null||Q.scrollIntoView({behavior:"smooth",block:"nearest"})}))};return window.addEventListener(dr,q),()=>{window.removeEventListener(dr,q),P.current&&clearTimeout(P.current)}},[]);const z=b.useCallback(()=>{const q=s.current;q&&(f(q.scrollTop>10),m(q.scrollHeight-q.scrollTop-q.clientHeight>10))},[]),F=b.useCallback(()=>{const q=s.current;q&&(i.current=q.scrollHeight-q.scrollTop-q.clientHeight<50,z())},[z]);if(b.useEffect(()=>{z()},[A.length,O.length,z]),b.useEffect(()=>{const q=s.current;q&&(q.scrollTop=q.scrollHeight),i.current=!0,a.current=!1,l.current=A.length,c.current=e.turns.length,j(g.scope),_(null),z()},[t]),b.useEffect(()=>{const q=e.turns.length;q>c.current&&(a.current=!0),c.current=q},[e.turns.length]),b.useEffect(()=>{if(A.length<=l.current){l.current=A.length;return}l.current=A.length,(a.current||i.current)&&(requestAnimationFrame(()=>{var q;(q=o.current)==null||q.scrollIntoView({behavior:"smooth"})}),a.current=!1)},[A.length]),A.length===0)return null;let H=0,B=0,W=0;if(w)for(const q of L)H+=q.totalAdd,B+=q.totalDel,W+=q.files.length;else{for(const q of O)H+=q.addCount,B+=q.delCount;W=O.length}function K(){j(y==="last"?"all":"last")}function V(){return typeof y=="number"?`Turn ${y+1}`:y==="all"?"All turns":`Last turn (T${I+1})`}const Y=V();return r.jsxs("div",{className:"view-transition-file-panel panel-enter-bottom flex h-full min-w-0 flex-col overflow-hidden bg-card",children:[r.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 border-b px-3",children:[r.jsx(gr,{"data-icon":"inline-start",className:"size-3.5 text-muted-foreground"}),r.jsx("span",{className:"text-xs font-medium text-foreground",children:"File Changes"}),r.jsxs(Me,{variant:"outline",className:"h-5 px-1.5 text-xs text-muted-foreground",children:[W," file",W!==1?"s":""]}),r.jsx("div",{className:"flex-1"}),r.jsxs("span",{className:"font-mono text-xs tabular-nums text-success",children:["+",H]}),r.jsxs("span",{className:"font-mono text-xs tabular-nums text-destructive",children:["-",B]}),r.jsxs(Et,{children:[r.jsx(Pt,{render:r.jsx(X,{variant:w?"secondary":"ghost",size:"icon-xs",onClick:()=>C(!w),"aria-label":w?"Show all changes":"Group by subagent"}),children:r.jsx(Wn,{"data-icon":"inline-start"})}),r.jsx(At,{children:w?"Show all changes":"Group by subagent"})]}),r.jsxs(Et,{children:[r.jsx(Pt,{render:r.jsx(X,{variant:y==="all"?"secondary":"ghost",size:"icon-xs",onClick:K,"aria-label":y==="last"?"Show all turns":"Show last turn only"}),children:y==="all"?r.jsx(jv,{"data-icon":"inline-start"}):r.jsx(Ms,{"data-icon":"inline-start"})}),r.jsx(At,{children:y==="last"?"Click for all turns":"Click for last turn only"})]}),r.jsxs(Et,{children:[r.jsx(Pt,{render:r.jsx(X,{variant:v==="per-edit"?"secondary":"ghost",size:"icon-xs",onClick:()=>N(v==="net"?"per-edit":"net"),"aria-label":v==="net"?"Show per-edit diffs":"Show net diff"}),children:v==="net"?r.jsx(Sv,{"data-icon":"inline-start"}):r.jsx(kv,{"data-icon":"inline-start"})}),r.jsx(At,{children:v==="net"?"Switch to per-edit diffs":"Switch to net diff"})]}),r.jsxs(Et,{children:[r.jsx(Pt,{render:r.jsx(X,{variant:"ghost",size:"icon-xs",onClick:()=>k(!x),"aria-label":x?"Collapse all":"Expand all"}),children:x?r.jsx(qi,{"data-icon":"inline-start"}):r.jsx(Hi,{"data-icon":"inline-start"})}),r.jsx(At,{children:x?"Collapse all":"Expand all"})]})]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b bg-muted/30 px-3 py-1",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:"Showing:"}),y!=="all"&&I>0&&r.jsx(X,{variant:"ghost",size:"icon-xs",onClick:()=>{const q=typeof y=="number"?y:I;q>0&&j(q-1)},disabled:(typeof y=="number"?y:I)<=0,"aria-label":"Previous turn",children:r.jsx(wc,{"data-icon":"inline-start"})}),r.jsx("span",{className:G("text-xs font-medium",typeof y=="number"?"text-foreground":"text-muted-foreground"),children:Y}),y!=="all"&&I>0&&r.jsx(X,{variant:"ghost",size:"icon-xs",onClick:()=>{j(q=>typeof q!="number"?q:q+1>=I?"last":q+1)},disabled:y==="last","aria-label":"Next turn",children:r.jsx(Ze,{"data-icon":"inline-start"})}),typeof y=="number"&&r.jsx(X,{variant:"ghost",size:"icon-xs",onClick:()=>j("last"),"aria-label":"Back to last turn",children:r.jsx(jt,{"data-icon":"inline-start"})})]}),r.jsxs("div",{className:"relative flex-1 min-h-0",children:[r.jsx("div",{className:G("pointer-events-none absolute inset-x-0 top-0 z-10 h-6 bg-gradient-to-b from-background to-transparent transition-opacity duration-200",d?"opacity-100":"opacity-0")}),r.jsxs("div",{ref:s,onScroll:F,className:"h-full overflow-y-auto",children:[r.jsx("div",{className:"flex flex-col gap-1 p-1.5",children:w?L.length>0?L.map(q=>r.jsx(A6,{group:q,allExpanded:x,highlightPath:S,diffMode:v},q.agentId)):r.jsxs("div",{className:"py-4 text-center text-xs text-muted-foreground",children:["No subagent changes in ",Y.toLowerCase()]}):O.length>0?O.map(q=>r.jsx(Hx,{file:q,defaultOpen:x,isHighlighted:S===q.filePath,diffMode:v},q.filePath)):r.jsxs("div",{className:"py-4 text-center text-xs text-muted-foreground",children:["No file changes in ",Y.toLowerCase()]})}),r.jsx("div",{ref:o})]}),r.jsx("div",{className:G("pointer-events-none absolute inset-x-0 bottom-0 z-10 h-6 bg-gradient-to-t from-background to-transparent transition-opacity duration-200",u?"opacity-100":"opacity-0")})]})]})});function M6(n,e){const t=new Map;function s(o,i){const a=String(o.input.file_path??o.input.path??"");if(!a)return;const l=o.name==="Edit",c=l?String(o.input.old_string??""):"",d=String(l?o.input.new_string??"":o.input.content??""),f=cr(c,d),u=t.get(a)??{add:0,del:0,hasEdit:!1,hasWrite:!1,subAgentId:null};u.add+=f.add,u.del+=f.del,l?u.hasEdit=!0:u.hasWrite=!0,i&&(u.subAgentId=i),t.set(a,u)}return qo(n.toolCalls,e).forEach(o=>s(o)),n.subAgentActivity.forEach(o=>qo(o.toolCalls,e).forEach(i=>s(i,o.agentId))),[...t.entries()].map(([o,{add:i,del:a,hasEdit:l,hasWrite:c,subAgentId:d}])=>({filePath:o,additions:i,deletions:a,hasEdit:l,hasWrite:c,subAgentId:d}))}function Im(){return{children:new Map,isFile:!1,absPath:"",additions:0,deletions:0,hasEdit:!1,hasWrite:!1,subAgentId:null}}function I6(n,e){if(n.length===0)return[];const t=e.endsWith("/")?e.slice(0,-1):e,s=Im();for(const i of n){let a=i.filePath;t&&a.startsWith(t+"/")?a=a.slice(t.length+1):a.startsWith("/")&&(a=a.slice(1));const l=a.split("/");let c=s;for(let d=0;d<l.length;d++){let f=c.children.get(l[d]);f||(f=Im(),c.children.set(l[d],f)),d===l.length-1&&(f.isFile=!0,f.absPath=i.filePath,f.additions+=i.additions,f.deletions+=i.deletions,i.hasEdit&&(f.hasEdit=!0),i.hasWrite&&(f.hasWrite=!0),i.subAgentId&&(f.subAgentId=i.subAgentId)),c=f}}function o(i,a){return[...i.children.entries()].sort(([c,d],[f,u])=>{const m=d.isFile&&d.children.size===0,p=u.isFile&&u.children.size===0;return m!==p?m?1:-1:c.localeCompare(f)}).map(([c,d])=>{const f=a?`${a}/${c}`:c;if(d.isFile&&d.children.size===0)return{name:c,fullPath:f,absPath:d.absPath,isFile:!0,additions:d.additions,deletions:d.deletions,hasEdit:d.hasEdit,hasWrite:d.hasWrite,subAgentId:d.subAgentId,children:[]};let u=d,m=c,p=f;for(;!u.isFile&&u.children.size===1;){const[j,k]=[...u.children.entries()][0];if(k.isFile&&k.children.size===0)break;m+="/"+j,p+="/"+j,u=k}const h=o(u,p);let g=0,x=0,v=u.isFile?u.hasEdit:!1,w=u.isFile?u.hasWrite:!1,y=u.isFile?u.subAgentId:null;for(const j of h)g+=j.additions,x+=j.deletions,j.hasEdit&&(v=!0),j.hasWrite&&(w=!0),j.subAgentId&&(y=j.subAgentId);return u.isFile&&(g+=u.additions,x+=u.deletions),{name:m,fullPath:p,absPath:u.absPath,isFile:!1,additions:g,deletions:x,hasEdit:v,hasWrite:w,subAgentId:y,children:h}})}return o(s,"")}const $6=b.memo(function(e){const t=U.c(45),{turn:s,turnIndex:o,cwd:i}=e,a=vn("hostFiles");let l;t[0]!==i||t[1]!==s?(l=M6(s,i),t[0]=i,t[1]=s,t[2]=l):l=t[2];const c=l;let d;t[3]!==i||t[4]!==c?(d=I6(c,i),t[3]=i,t[4]=c,t[5]=d):d=t[5];const f=d,[u,m]=b.useState(!1);let p=0,h=0;if(t[6]!==p||t[7]!==h||t[8]!==c){for(const M of c)p=p+M.additions,h=h+M.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 v=u&&"rotate-90";let w;t[14]!==v?(w=G("size-3 shrink-0 transition-transform duration-150 motion-reduce:transition-none",v),t[14]=v,t[15]=w):w=t[15];let y;t[16]!==w?(y=r.jsx(Ze,{"data-icon":"inline-start",className:w}),t[16]=w,t[17]=y):y=t[17];let j;t[18]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(gr,{className:"size-3.5 shrink-0","data-icon":"inline-start"}),t[18]=j):j=t[18];const k=c.length!==1?"s":"";let N;t[19]!==c.length||t[20]!==k?(N=r.jsxs("span",{className:"font-medium tabular-nums",children:[c.length," file",k]}),t[19]=c.length,t[20]=k,t[21]=N):N=t[21];let C,S;t[22]!==x.add||t[23]!==x.del?(C=r.jsx(Zl,{add:x.add,del:x.del,className:"opacity-80"}),S=r.jsx(jd,{add:x.add,del:x.del}),t[22]=x.add,t[23]=x.del,t[24]=C,t[25]=S):(C=t[24],S=t[25]);let _;t[26]===Symbol.for("react.memo_cache_sentinel")?(_=r.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]=_):_=t[26];let P;t[27]!==C||t[28]!==S||t[29]!==y||t[30]!==N?(P=r.jsxs(an,{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:[y,j,N,C,S,_]}),t[27]=C,t[28]=S,t[29]=y,t[30]=N,t[31]=P):P=t[31];let A;if(t[32]!==a||t[33]!==f||t[34]!==o){let M;t[36]!==a||t[37]!==o?(M=I=>r.jsx(O6,{node:I,depth:0,turnIndex:o,canFocusFiles:a},I.fullPath),t[36]=a,t[37]=o,t[38]=M):M=t[38],A=f.map(M),t[32]=a,t[33]=f,t[34]=o,t[35]=A}else A=t[35];let E;t[39]!==A?(E=r.jsx(Nt,{className:"ml-1 border-l border-border/40 pl-3",children:r.jsx("div",{className:"py-0.5",children:A})}),t[39]=A,t[40]=E):E=t[40];let T;return t[41]!==u||t[42]!==P||t[43]!==E?(T=r.jsxs(kt,{open:u,onOpenChange:m,children:[P,E]}),t[41]=u,t[42]=P,t[43]=E,t[44]=T):T=t[44],T}),O6=b.memo(function n({node:e,depth:t,turnIndex:s,canFocusFiles:o}){const[i,a]=b.useState(!0),l=t*16+8;if(e.isFile){const c=b6(e.name),d=()=>{o&&e.absPath&&window.dispatchEvent(new CustomEvent(dr,{detail:{filePath:e.absPath,turnIndex:s}}))};return r.jsxs("div",{className:"flex h-7 w-full items-center gap-1.5 font-mono text-xs",style:{paddingLeft:l},children:[r.jsxs(X,{type:"button",variant:"ghost",size:"xs",disabled:!o,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",o&&"cursor-pointer"),onClick:d,title:o?"Click to focus in sidebar":void 0,children:[r.jsx(c,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}),r.jsx(Wx,{hasEdit:e.hasEdit,hasWrite:e.hasWrite}),r.jsx("span",{className:"truncate text-foreground/75",children:e.name})]}),e.subAgentId&&r.jsx(Sd,{agentId:e.subAgentId}),r.jsx(Zl,{add:e.additions,del:e.deletions}),r.jsx(jd,{add:e.additions,del:e.deletions})]})}return r.jsxs(r.Fragment,{children:[r.jsxs(X,{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:()=>a(!i),"aria-expanded":i,children:[i?r.jsx(nt,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}):r.jsx(Ze,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}),r.jsx(Nv,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}),r.jsx("span",{className:"truncate text-foreground/70",children:e.name}),r.jsx("div",{className:"flex-1 min-w-2"}),!i&&r.jsx(Zl,{add:e.additions,del:e.deletions,dimmed:!0})]}),i&&e.children.map(c=>r.jsx(n,{node:c,depth:t+1,turnIndex:s,canFocusFiles:o},c.fullPath))]})});function D6(n){const e=U.c(14),{branchCount:t,onClick:s}=n;if(t===0)return null;let o;e[0]!==s?(o=r.jsx(X,{variant:"ghost",size:"xs",onClick:u=>{u.stopPropagation(),s()},className:"h-6 text-muted-foreground"}),e[0]=s,e[1]=o):o=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(jc,{"data-icon":"inline-start"}),e[2]=i):i=e[2];let a;e[3]!==t?(a=r.jsx("span",{className:"font-mono text-xs",children:t}),e[3]=t,e[4]=a):a=e[4];let l;e[5]!==o||e[6]!==a?(l=r.jsxs(Pt,{render:o,children:[i,a]}),e[5]=o,e[6]=a,e[7]=l):l=e[7];const c=t!==1?"es":"";let d;e[8]!==t||e[9]!==c?(d=r.jsxs(At,{children:[t," branch",c," from this turn"]}),e[8]=t,e[9]=c,e[10]=d):d=e[10];let f;return e[11]!==l||e[12]!==d?(f=r.jsxs(Et,{children:[l,d]}),e[11]=l,e[12]=d,e[13]=f):f=e[13],f}function qx(n){return E1(n).status(n)}const L6=new Set(["Agent","TaskOutput","spawn_agent","wait_agent"]);function kd(n){switch(n){case"max_turns":return"Stopped — turn limit reached";case"aborted_tools":return"Stopped — tools aborted";case"blocking_limit":return"Stopped — blocked";default:return`Stopped — ${n.replace(/_/g," ")}`}}function Rr(n,e,t,s){switch(n){case"thinking":return"Thinking...";case"tool_use":return e&&L6.has(e)?"Running agents...":e?`Using ${e}`:"Using tool...";case"processing":return"Processing...";case"compacting":return"Compressing context...";case"deferred":return"Awaiting permission review";case"awaiting_agents":return s&&s>0?`Waiting on ${s} agent${s===1?"":"s"}...`:"Waiting on agents...";case"completed":return t?kd(t):"Done";default:return null}}function z6(n){const e=U.c(6),{status:t}=n;switch(t){case"thinking":{let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(_v,{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=r.jsx(yo,{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=r.jsx(Cv,{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=r.jsx(qi,{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=r.jsx(lo,{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=r.jsx(Un,{className:"size-5 text-success"}),e[5]=s):s=e[5],s}default:return null}}const $m=2e3,Vx=600;function Gx(n){const e=U.c(28),{status:t,label:s,fading:o,startTimestamp:i}=n,a=o===void 0?!1:o,l=t.status==="completed";let c;e[0]!==t.pendingAgentDescriptions?(c=t.pendingAgentDescriptions??[],e[0]=t.pendingAgentDescriptions,e[1]=c):c=e[1];const d=c,f=a?"opacity-0":"opacity-100";let u;e[2]!==f?(u=G("flex items-center gap-2.5 min-w-0 transition-opacity",f),e[2]=f,e[3]=u):u=e[3];let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m={transitionDuration:`${Vx}ms`},e[4]=m):m=e[4];let p;e[5]!==t.status?(p=r.jsx(z6,{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 v;e[7]!==h||e[8]!==g||e[9]!==x?(v=G("text-xs font-medium shrink-0",h,g,x),e[7]=h,e[8]=g,e[9]=x,e[10]=v):v=e[10];let w;e[11]!==s||e[12]!==v?(w=r.jsx("span",{className:v,children:s}),e[11]=s,e[12]=v,e[13]=w):w=e[13];let y;e[14]!==l||e[15]!==i?(y=!l&&i&&r.jsx(Nd,{startTimestamp:i}),e[14]=l,e[15]=i,e[16]=y):y=e[16];let j;e[17]!==d?(j=d.length>0&&r.jsx("span",{className:"truncate text-xs text-muted-foreground",title:d.join(`
|
|
114
|
+
`),children:d.join(" · ")}),e[17]=d,e[18]=j):j=e[18];let k;e[19]!==t.pendingQueue?(k=(t.pendingQueue??0)>0&&r.jsxs("span",{className:"ml-1 shrink-0 text-xs text-muted-foreground",children:["+",t.pendingQueue," queued"]}),e[19]=t.pendingQueue,e[20]=k):k=e[20];let N;return e[21]!==w||e[22]!==y||e[23]!==j||e[24]!==k||e[25]!==u||e[26]!==p?(N=r.jsxs("div",{className:u,style:m,children:[p,w,y,j,k]}),e[21]=w,e[22]=y,e[23]=j,e[24]=k,e[25]=u,e[26]=p,e[27]=N):N=e[27],N}function F6(n){const e=U.c(28),{status:t,durationLabel:s}=n,[o,i]=b.useState("visible");let a,l;if(e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const h=setTimeout(()=>i("fading"),$m),g=setTimeout(()=>i("ready"),$m+Vx);return()=>{clearTimeout(h),clearTimeout(g)}},l=[],e[0]=a,e[1]=l):(a=e[0],l=e[1]),b.useEffect(a,l),o==="ready"){let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(Un,{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 v;e[5]!==t.terminalReason?(v=t.terminalReason?kd(t.terminalReason):"Waiting for your input",e[5]=t.terminalReason,e[6]=v):v=e[6];let w;e[7]!==x||e[8]!==v?(w=r.jsx("span",{className:x,children:v}),e[7]=x,e[8]=v,e[9]=w):w=e[9];let y;e[10]!==s?(y=s&&r.jsx("span",{className:"font-mono text-xs tabular-nums text-muted-foreground",children:s}),e[10]=s,e[11]=y):y=e[11];let j;return e[12]!==w||e[13]!==y?(j=r.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4","data-agent-ready":!0,children:[h,w,y]}),e[12]=w,e[13]=y,e[14]=j):j=e[14],j}let c;e[15]!==t.status||e[16]!==t.terminalReason||e[17]!==t.toolName?(c=Rr(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 d=c,f=o==="fading";let u;e[19]!==d||e[20]!==t||e[21]!==f?(u=r.jsx(Gx,{status:t,label:d,fading:f}),e[19]=d,e[20]=t,e[21]=f,e[22]=u):u=e[22];let m;e[23]!==s?(m=s&&r.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]!==u||e[26]!==m?(p=r.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4",children:[u,m]}),e[25]=u,e[26]=m,e[27]=p):p=e[27],p}const B6=b.memo(function(){const e=U.c(25),{session:t,isLive:s,sseState:o,isCompacting:i,pendingInteraction:a}=it(),[l,c]=b.useState(!1),[d,f]=b.useState(!1),u=t==null?void 0:t.sessionId,[m,p]=b.useState(u);u!==m&&(p(u),c(!1),f(!1));let h;e:{if(!t||o!=="connected"){h=null;break e}if(i){let M;e[0]===Symbol.for("react.memo_cache_sentinel")?(M={status:"compacting"},e[0]=M):M=e[0],h=M;break e}const E=t.rawMessages;let T;e[1]!==E?(T=qx(E),e[1]=E,e[2]=T):T=e[2],h=T}const g=h;let x,v;e[3]!==g||e[4]!==s||e[5]!==d?(x=()=>{if(!(!g||g.status==="compacting"||g.status==="idle")){if(!s){g.status==="completed"&&!d&&c(!0);return}if(g.status==="completed"){f(!0);return}c(!1),f(!1)}},v=[g,s,d],e[3]=g,e[4]=s,e[5]=d,e[6]=x,e[7]=v):(x=e[6],v=e[7]),b.useEffect(x,v);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&&!d){w=null;break e}w=g;break e}if(!s||g.status==="idle"){w=null;break e}w=g}const y=w,j=(y==null?void 0:y.status)==="completed",k=(t==null?void 0:t.turns[t.turns.length-1])??null;let N;e:{if(!j||!k){N=null;break e}let E;if(e[8]!==k){const T=Pc(k);E=T!==null?Tn(T):null,e[8]=k,e[9]=E}else E=e[9];N=E}const C=N;if(a&&o==="connected"){let E;e[10]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsx(Jp,{className:"size-5 shrink-0 text-info"}),e[10]=E):E=e[10];const T=a.type==="plan"?"Waiting for plan approval":"Waiting for your answer";let M;return e[11]!==T?(M=r.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4",children:[E,r.jsx("span",{className:"text-xs font-medium text-info",children:T})]}),e[11]=T,e[12]=M):M=e[12],M}if(!y)return null;if(j){let E;return e[13]!==y||e[14]!==C?(E=r.jsx(F6,{status:y,durationLabel:C}),e[13]=y,e[14]=C,e[15]=E):E=e[15],E}let S;e[16]!==y.pendingAgents||e[17]!==y.status||e[18]!==y.terminalReason||e[19]!==y.toolName?(S=Rr(y.status,y.toolName,y.terminalReason,y.pendingAgents),e[16]=y.pendingAgents,e[17]=y.status,e[18]=y.terminalReason,e[19]=y.toolName,e[20]=S):S=e[20];const _=S;if(!_)return null;const P=k==null?void 0:k.timestamp;let A;return e[21]!==y||e[22]!==_||e[23]!==P?(A=r.jsx("div",{className:"flex items-center gap-2.5 py-3 px-4",children:r.jsx(Gx,{status:y,label:_,startTimestamp:P})}),e[21]=y,e[22]=_,e[23]=P,e[24]=A):A=e[24],A});function Nd(n){const e=U.c(3),{startTimestamp:t,className:s}=n;let o;return e[0]!==s||e[1]!==t?(o=r.jsx(U6,{startTimestamp:t,className:s},t),e[0]=s,e[1]=t,e[2]=o):o=e[2],o}function U6(n){const e=U.c(12),{startTimestamp:t,className:s}=n;let o;e[0]!==t?(o=new Date(t).getTime(),e[0]=t,e[1]=o):o=e[1];const i=o,a=b.useRef(null);let l,c;e[2]!==i?(l=()=>{const h=setInterval(()=>{const g=a.current;g&&(g.textContent=Tn(Math.max(0,Date.now()-i)))},1e3);return()=>clearInterval(h)},c=[i],e[2]=i,e[3]=l,e[4]=c):(l=e[3],c=e[4]),b.useEffect(l,c);let d;e[5]!==s?(d=G("font-mono text-xs tabular-nums text-muted-foreground",s),e[5]=s,e[6]=d):d=e[6];const f=Math.max(0,Date.now()-i);let u;e[7]!==f?(u=Tn(f),e[7]=f,e[8]=u):u=e[8];let m;return e[9]!==d||e[10]!==u?(m=r.jsx("span",{ref:a,className:d,children:u}),e[9]=d,e[10]=u,e[11]=m):m=e[11],m}function W6(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 o of n.assistantText)if(o.toLowerCase().includes(t))return!0;for(const o of n.contentBlocks)if(o.kind==="queued_prompt"&&o.content.toLowerCase().includes(t)||o.kind==="agent_message"&&(o.sender.toLowerCase().includes(t)||o.body.toLowerCase().includes(t)))return!0;for(const o of n.thinking)if(o.thinking.toLowerCase().includes(t))return!0;for(const o of n.toolCalls)if(o.name.toLowerCase().includes(t)||JSON.stringify(o.input).toLowerCase().includes(t)||(s=o.result)!=null&&s.toLowerCase().includes(t))return!0;return!1}const H6=6e5;function K6(n,e){const t=n[e].timestamp,s=e>0?n[e-1].timestamp:void 0;if(!t||!s)return 0;const o=Date.parse(t)-Date.parse(s);return!Number.isFinite(o)||o<=0?0:Math.min(o,H6)}function Om(n,e){const t=[],s=[];let o=0,i=0,a=e;for(;a<n.length;){const l=n[a];if(l.kind==="thinking")t.push({kind:"thinking",blocks:l.blocks}),o+=l.blocks.length,i+=K6(n,a),a++;else if(l.kind==="tool_calls")t.push({kind:"tool_calls",toolCalls:l.toolCalls}),s.push(...l.toolCalls),a++;else break}return{items:t,toolCalls:s,thinkingCount:o,thoughtForMs:i,nextIndex:a}}const ec=new Map,q6=300*1e3;function Dm(n){const e=ec.get(n);return e?Date.now()>e.expiresAt?(ec.delete(n),null):e.data:null}function V6(n,e){ec.set(n,{data:e,expiresAt:Date.now()+q6})}function G6(n){const e=U.c(5);let t;e[0]!==n?(t=()=>n?Dm(Lt(n))??new Map:new Map,e[0]=n,e[1]=t):t=e[1];const[s,o]=b.useState(t),i=b.useRef("");let a,l;return e[2]!==n?(a=()=>{if(!n||oa(window.location.pathname))return;const c=Lt(n),d=Dm(c);if(d){o(d);return}i.current=n;const f=new AbortController;return ye(`/api/slash-suggestions?cwd=${encodeURIComponent(n)}`,{signal:f.signal}).then(async u=>{if(f.signal.aborted||i.current!==n||!u.ok)return;const m=await u.json();if(f.signal.aborted||i.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});V6(c,p),o(p)}).catch(Y6),()=>f.abort()},l=[n],e[2]=n,e[3]=a,e[4]=l):(a=e[3],l=e[4]),b.useEffect(a,l),s}function Y6(){}const X6=new Set(["queued_prompt","agent_message","plan_mode","recap","task_notification"]),J6=new Set(["thinking","tool_calls","sub_agent","background_agent","hook_event"]),Q6=new Set(["AskUserQuestion","ExitPlanMode"]),Z6=new Set(["text","thinking","tool_calls"]);function e7(n){return n.kind==="tool_calls"&&n.toolCalls.some(e=>Q6.has(e.name)&&e.result==null)}function t7(n){for(let e=n.length-1;e>=0;e--){if(e7(n[e]))return e;if(Z6.has(n[e].kind))return-1}return-1}const ti={foldedIndices:[],foldAnchorIndex:-1,foldable:!1,hiddenToolCalls:0};function n7(n,e="settled"){if(n.length===0||!n.some(a=>J6.has(a.kind)))return ti;let t=-1;if(e==="settled"){for(let a=n.length-1;a>=0;a--)if(n[a].kind==="text"){t=a;break}if(t===-1)return ti}const s=t7(n),o=[];let i=0;for(let a=0;a<n.length;a++){if(a===t||a===s)continue;const l=n[a];X6.has(l.kind)||(o.push(a),l.kind==="tool_calls"&&(i+=l.toolCalls.length))}return o.length===0?ti:{foldedIndices:o,foldAnchorIndex:o[0],foldable:!0,hiddenToolCalls:i}}function s7(n,e){return n!==null&&n>0?`Worked for ${Tn(n)}`:e>0?`Worked through ${e} step${e===1?"":"s"}`:"Show work"}const Yx="border border-border bg-prompt-surface",Lm="border-l border-border/40",zm="border-l border-border";function Xx(n){const e=U.c(20),{turn:t,index:s,branchCount:o}=n,i=o===void 0?0:o,{state:a,isMobile:l}=Rt(),{activeTurnIndex:c,activeToolCallId:d,expandAll:f,expandToolPayloads:u}=a,{session:m,isLive:p,isSubAgentView:h,undoRedo:g,actions:x}=it(),v=p&&m!==null,w=v&&s===((m==null?void 0:m.turns.length)??0)-1;let y=!w;if(w&&m){let _;if(e[0]!==m.rawMessages){const{status:P}=qx(m.rawMessages);_=md.has(P),e[0]=m.rawMessages,e[1]=_}else _=e[1];y=!_}const j=(m==null?void 0:m.cwd)??"",k=G6(j),N=c===s,C=!g.enabled||h?void 0:g.requestUndo;let S;return e[2]!==x.handleEditCommand||e[3]!==x.handleExpandCommand||e[4]!==x.handleOpenBranches||e[5]!==d||e[6]!==i||e[7]!==j||e[8]!==f||e[9]!==u||e[10]!==s||e[11]!==w||e[12]!==l||e[13]!==v||e[14]!==y||e[15]!==k||e[16]!==N||e[17]!==C||e[18]!==t?(S=r.jsx(r7,{turn:t,index:s,branchCount:i,isActive:N,activeToolCallId:d,expandAll:f,expandToolPayloads:u,isAgentActive:w,isSessionLive:v,isTurnDone:y,isMobile:l,cwd:j,skillMetadata:k,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]=d,e[6]=i,e[7]=j,e[8]=f,e[9]=u,e[10]=s,e[11]=w,e[12]=l,e[13]=v,e[14]=y,e[15]=k,e[16]=N,e[17]=C,e[18]=t,e[19]=S):S=e[19],S}function o7(n){const e=U.c(5),{turn:t,isTurnDone:s,hiddenToolCalls:o}=n;if(s){let a;return e[0]!==o||e[1]!==t?(a=s7(Pc(t),o),e[0]=o,e[1]=t,e[2]=a):a=e[2],a}if(!t.timestamp)return"Working";let i;return e[3]!==t.timestamp?(i=r.jsxs("span",{className:"inline-flex items-baseline gap-1",children:["Working for",r.jsx(Nd,{startTimestamp:t.timestamp,className:"text-xs text-inherit"})]}),e[3]=t.timestamp,e[4]=i):i=e[4],i}const r7=b.memo(function({turn:e,index:t,branchCount:s,isActive:o,activeToolCallId:i,expandAll:a,expandToolPayloads:l,isAgentActive:c,isSessionLive:d,isTurnDone:f,isMobile:u,cwd:m,skillMetadata:p,onRestoreToHere:h,onOpenBranches:g,onEditCommand:x,onExpandCommand:v}){const{ref:w,isNear:y}=ox(),j=b.useRef(null),k=b.useRef(0);b.useLayoutEffect(()=>{y&&j.current&&(k.current=j.current.offsetHeight)},[y]);const N=_i(e.toolCalls,m)||e.subAgentActivity.some(M=>_i(M.toolCalls,m)),C=f?"settled":"working",S=b.useMemo(()=>n7(e.contentBlocks,C),[C,e.contentBlocks]),[_,P]=b.useState(void 0),A=_??(a||!f),{leadingBlocks:E,trailingBlocks:T}=b.useMemo(()=>{if(!S.foldable)return{leadingBlocks:[],trailingBlocks:[]};const M=S.foldAnchorIndex,I=new Set(S.foldedIndices);return{leadingBlocks:e.contentBlocks.slice(0,M),trailingBlocks:e.contentBlocks.slice(M).filter((R,$)=>A||!I.has(M+$))}},[S,e.contentBlocks,A]);return r.jsxs("div",{ref:w,"data-turn-index":t,className:G("group relative",u?"px-1 py-3":"px-4 py-5",o&&"rounded-lg ring-1 ring-ring/40"),children:[r.jsx(a7,{index:t,turn:e,branchCount:s,isTurnDone:f,isMobile:u,onRestoreToHere:h,onOpenBranches:g}),y?r.jsxs("div",{ref:j,className:G("flex flex-col",u?"gap-2":"gap-3"),children:[e.userMessage&&r.jsx("div",{"data-turn-prompt":!0,className:G(u?"rounded-lg p-2.5":"rounded-lg p-3",Yx),children:r.jsx(cd,{content:e.userMessage,timestamp:e.timestamp,onEditCommand:x,onExpandCommand:v,compact:u})}),S.foldable?r.jsxs(r.Fragment,{children:[E.length>0&&r.jsx(ul,{blocks:E,model:e.model,effort:e.effort,expandAll:a,expandToolPayloads:l,activeToolCallId:i,isAgentActive:c,isSessionLive:d,isMobile:u,skillMetadata:p}),r.jsx(o6,{label:r.jsx(o7,{turn:e,isTurnDone:f,hiddenToolCalls:S.hiddenToolCalls}),expanded:A,onToggle:()=>P(!A),compact:u}),T.length>0&&r.jsx(ul,{blocks:T,model:e.model,effort:e.effort,expandAll:a,expandToolPayloads:l,activeToolCallId:i,isAgentActive:c,isSessionLive:d,isMobile:u,skillMetadata:p})]}):r.jsx(ul,{blocks:e.contentBlocks,model:e.model,effort:e.effort,expandAll:a,expandToolPayloads:l,activeToolCallId:i,isAgentActive:c,isSessionLive:d,isMobile:u,skillMetadata:p}),f&&N&&r.jsx($6,{turn:e,turnIndex:t,cwd:m})]}):r.jsx("div",{style:{minHeight:k.current||i7(e)}})]})});function i7(n){return Math.max(60,(n.userMessage?40:0)+n.contentBlocks.length*60)}function a7(n){const e=U.c(26),{index:t,turn:s,branchCount:o,isTurnDone:i,isMobile:a,onRestoreToHere:l,onOpenBranches:c}=n,d=!i&&!!s.timestamp;let f;e[0]!==i||e[1]!==s?(f=i?Pc(s):null,e[0]=i,e[1]=s,e[2]=f):f=e[2];const u=f,m=a?"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=a?`Turn ${t+1}`:t+1;let g;e[5]!==h?(g=r.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]!==u||e[8]!==d||e[9]!==s.timestamp?(x=r.jsx(l7,{durationMs:u,showLiveTimer:d,timestamp:s.timestamp}),e[7]=u,e[8]=d,e[9]=s.timestamp,e[10]=x):x=e[10];let v;e[11]!==t||e[12]!==a||e[13]!==l?(v=l&&r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:()=>l(t),className:G("ml-auto text-muted-foreground transition-opacity hover:text-foreground",a?"opacity-70":"opacity-0 group-hover:opacity-100"),title:"Undo this turn and all after it",children:[r.jsx(Sc,{"data-icon":"inline-start"}),r.jsx("span",{className:"hidden sm:inline",children:"Restore"})]}),e[11]=t,e[12]=a,e[13]=l,e[14]=v):v=e[14];let w;e[15]!==o||e[16]!==t||e[17]!==c||e[18]!==l?(w=o>0&&c&&r.jsx("div",{className:G(!l&&"ml-auto"),children:r.jsx(D6,{branchCount:o,onClick:()=>c(t)})}),e[15]=o,e[16]=t,e[17]=c,e[18]=l,e[19]=w):w=e[19];let y;return e[20]!==p||e[21]!==g||e[22]!==x||e[23]!==v||e[24]!==w?(y=r.jsxs("div",{className:p,children:[g,x,v,w]}),e[20]=p,e[21]=g,e[22]=x,e[23]=v,e[24]=w,e[25]=y):y=e[25],y}function l7(n){const e=U.c(8),{durationMs:t,showLiveTimer:s,timestamp:o}=n;if(t!==null){let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Ms,{className:"size-3","data-icon":"inline-start"}),e[0]=i):i=e[0];let a;e[1]!==t?(a=Tn(t),e[1]=t,e[2]=a):a=e[2];let l;return e[3]!==a?(l=r.jsxs("span",{className:"flex items-center gap-1 font-mono text-xs tabular-nums text-muted-foreground",children:[i,a]}),e[3]=a,e[4]=l):l=e[4],l}if(s){let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Ms,{className:"size-3","data-icon":"inline-start"}),e[5]=i):i=e[5];let a;return e[6]!==o?(a=r.jsxs("span",{className:"flex items-center gap-1 font-mono text-xs tabular-nums text-info",children:[i,r.jsx(Nd,{startTimestamp:o,className:"tabular-nums"})]}),e[6]=o,e[7]=a):a=e[7],a}return null}function c7(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 ul(n){const e=U.c(11),{blocks:t,model:s,effort:o,expandAll:i,expandToolPayloads:a,activeToolCallId:l,isAgentActive:c,isSessionLive:d,isMobile:f,skillMetadata:u}=n;let m;if(e[0]!==l||e[1]!==t||e[2]!==o||e[3]!==i||e[4]!==a||e[5]!==c||e[6]!==f||e[7]!==d||e[8]!==s||e[9]!==u){const p=[],h=f?"ml-0 pl-2":"ml-1 pl-3",g=f?"gap-2":"gap-3",x=new Map,v=(y,j)=>{const k=c7(y)??`at-${j}`,N=x.get(k)??0;return x.set(k,N+1),N===0?k:`${k}#${N}`};let w=0;for(;w<t.length;){const y=t[w];if(y.kind==="thinking"||y.kind==="tool_calls"){const{items:j,toolCalls:k,thinkingCount:N,thoughtForMs:C,nextIndex:S}=Om(t,w),_=j.length===1&&j[0].kind==="tool_calls";p.push(r.jsx("div",{className:G(Lm,h),children:r.jsx(Cm,{toolCalls:k,expandAll:i,expandToolPayloads:a,activeToolCallId:l,isAgentActive:c,activityItems:_?void 0:j,thinkingCount:N,thoughtForMs:C,skillMetadata:u})},v(y,w))),w=S;continue}if(y.kind==="text"){const{items:j,toolCalls:k,thinkingCount:N,thoughtForMs:C,nextIndex:S}=Om(t,w+1);p.push(r.jsxs("div",{children:[r.jsx("div",{className:G("flex flex-col",g),children:y.text.map((_,P)=>r.jsx(WC,{text:_,model:s,effort:o,timestamp:y.timestamp,compact:f},P))}),(k.length>0||N>0)&&r.jsx("div",{className:G("mt-1.5",Lm,h),children:r.jsx(Cm,{toolCalls:k,expandAll:i,expandToolPayloads:a,activeToolCallId:l,isAgentActive:c,activityItems:N>0?j:void 0,thinkingCount:N,thoughtForMs:C,skillMetadata:u})})]},v(y,w))),w=S;continue}if(y.kind==="queued_prompt"){p.push(r.jsxs("div",{className:G(f?"rounded-lg p-2.5":"rounded-lg p-3",Yx),children:[r.jsx(Me,{variant:"outline",className:"mb-2",children:"Queued while working"}),r.jsx(cd,{content:y.content,timestamp:y.timestamp??"",compact:f})]},v(y,w))),w++;continue}if(y.kind==="agent_message"){p.push(r.jsx(FC,{sender:y.sender,body:y.body,reply:y.reply,timestamp:y.timestamp,isLive:d},v(y,w))),w++;continue}if(y.kind==="sub_agent"){p.push(r.jsx("div",{className:G(zm,h),children:r.jsx(l_,{messages:y.messages,expandAll:i})},v(y,w))),w++;continue}if(y.kind==="background_agent"){p.push(r.jsx("div",{className:G(zm,h),children:r.jsx(c_,{messages:y.messages,expandAll:i})},v(y,w))),w++;continue}if(y.kind==="hook_event"){p.push(r.jsx(u_,{events:y.events},v(y,w))),w++;continue}if(y.kind==="plan_mode"){p.push(r.jsx(PT,{plan:y.plan,planFilePath:y.planFilePath,status:y.status,toolCalls:y.toolCalls,expandAll:i,expandToolPayloads:a,isAgentActive:c,skillMetadata:u},v(y,w))),w++;continue}if(y.kind==="recap"){p.push(r.jsx(AT,{content:y.content,timestamp:y.timestamp},v(y,w))),w++;continue}if(y.kind==="task_notification"){p.push(r.jsx($N,{content:y.content},v(y,w))),w++;continue}w++}m=r.jsx(r.Fragment,{children:p}),e[0]=l,e[1]=t,e[2]=o,e[3]=i,e[4]=a,e[5]=c,e[6]=f,e[7]=d,e[8]=s,e[9]=u,e[10]=m}else m=e[10];return m}function d7(n){if(!n)return null;const e=n.trigger==="manual"?"manual":"auto";return n.postTokens!=null?`${e} · ${tt(n.preTokens)} → ${tt(n.postTokens)}`:`${e} · ${tt(n.preTokens)}`}const u7=b.memo(function(e){const t=U.c(30),{summary:s,meta:o}=e,[i,a]=b.useState(!1);let l;t[0]!==o?(l=d7(o),t[0]=o,t[1]=l):l=t[1];const c=l;let d;t[2]!==s?(d=s==null?void 0:s.trim(),t[2]=s,t[3]=d):d=t[3];const f=d;let u;t[4]!==f||t[5]!==i?(u=f&&(i?r.jsx(nt,{className:"size-3","data-icon":"inline-start"}):r.jsx(Ze,{className:"size-3","data-icon":"inline-start"})),t[4]=f,t[5]=i,t[6]=u):u=t[6];let m,p;t[7]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(Tv,{className:"size-3","data-icon":"inline-start"}),p=r.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&&r.jsxs(r.Fragment,{children:[r.jsx("span",{children:"·"}),r.jsx("span",{children:c})]}),t[9]=c,t[10]=h):h=t[10];let g;t[11]!==u||t[12]!==h?(g=r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground transition-colors group-hover:text-foreground",children:[u,m,p,h]}),t[11]=u,t[12]=h,t[13]=g):g=t[13];const x=g;if(!f){let S;t[14]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx("div",{className:"h-px flex-1 bg-border"}),t[14]=S):S=t[14];let _;t[15]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx("div",{className:"h-px flex-1 bg-border"}),t[15]=_):_=t[15];let P;return t[16]!==x?(P=r.jsxs("div",{className:"flex items-center gap-3 px-4 py-2",children:[S,x,_]}),t[16]=x,t[17]=P):P=t[17],P}let v,w;t[18]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(X,{type:"button",variant:"ghost",className:"group h-auto w-full gap-3 px-0"}),w=r.jsx("div",{className:"h-px flex-1 bg-border"}),t[18]=v,t[19]=w):(v=t[18],w=t[19]);let y;t[20]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx("div",{className:"h-px flex-1 bg-border"}),t[20]=y):y=t[20];let j;t[21]!==x?(j=r.jsxs(an,{render:v,children:[w,x,y]}),t[21]=x,t[22]=j):j=t[22];let k;t[23]===Symbol.for("react.memo_cache_sentinel")?(k=[Gi],t[23]=k):k=t[23];let N;t[24]!==f?(N=r.jsx(Nt,{children:r.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:r.jsx(Pn,{remarkPlugins:k,components:$n,children:f})})}),t[24]=f,t[25]=N):N=t[25];let C;return t[26]!==i||t[27]!==j||t[28]!==N?(C=r.jsxs(kt,{open:i,onOpenChange:a,className:"px-4 py-2",children:[j,N]}),t[26]=i,t[27]=j,t[28]=N,t[29]=C):C=t[29],C}),f7=1.5;function m7(n,e){return e<=0?!1:n<e*f7}function p7(n,e){return n===0&&!e}function h7(n,e){return!n||!n.firstKey||e.length<=n.length||e[0]===n.firstKey?!1:e.includes(n.firstKey)}function g7(n,e){return e&&e!=="claude"?n.isFragment===!0:n.userMessage===null}const x7=1e3;function b7(n){const e=new Map;return n.map(t=>{if(!t.contentBlocks.some(o=>o.kind==="agent_message"))return t;const s=t.contentBlocks.filter(o=>{if(o.kind!=="agent_message")return!0;const i=Date.parse(o.timestamp??"");if(Number.isNaN(i))return!0;const a=`${o.sender}\0${o.body}`,l=e.get(a);return l!==void 0&&Math.abs(i-l)<=x7?!1:(e.set(a,i),!0)});return s.length===t.contentBlocks.length?t:{...t,contentBlocks:s}})}function Jx(n,e,t){const s=new Set(n.map(c=>c.id)),o=e.filter(c=>!s.has(c.id));if(o.length===0)return n;const i=n[0],a=o[o.length-1],l=i&&a&&g7(i,t)?[...o.slice(0,-1),y7(a,i),...n.slice(1)]:[...o,...n];return Zc(b7(l))}function v7(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 y7(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:v7(n,e),tokenUsage:e.tokenUsage??n.tokenUsage,model:e.model??n.model,compactionSummary:n.compactionSummary??e.compactionSummary,compactionMeta:n.compactionMeta??e.compactionMeta}}function w7(n){const e=U.c(12),{index:t,children:s}=n,{isSubAgentView:o,undoRedo:i,actions:a}=it(),{requestUndo:l,branchesAtTurn:c}=i,{handleOpenBranches:d,handleBranchFromHere:f}=a;if(!i.enabled||o||!l||!d){let p;return e[0]!==s?(p=r.jsx(r.Fragment,{children:s}),e[0]=s,e[1]=p):p=e[1],p}let u;e[2]!==c||e[3]!==t?(u=c(t),e[2]=c,e[3]=t,e[4]=u):u=e[4];let m;return e[5]!==s||e[6]!==f||e[7]!==d||e[8]!==t||e[9]!==l||e[10]!==u?(m=r.jsx(hC,{turnIndex:t,branches:u,onRestoreToHere:l,onOpenBranches:d,onBranchFromHere:f,children:s}),e[5]=s,e[6]=f,e[7]=d,e[8]=t,e[9]=l,e[10]=u,e[11]=m):m=e[11],m}function j7(){const n=U.c(10),{session:e,isSubAgentView:t,undoRedo:s}=it(),{canRedo:o,redoTurnCount:i,redoGhostTurns:a,requestRedoAll:l,requestRedoUpTo:c}=s,d=(e==null?void 0:e.turns.length)??0;if(!s.enabled||t||!o||!l)return null;let f;n[0]!==i||n[1]!==l?(f=r.jsx(gC,{redoTurnCount:i,onRedoAll:l}),n[0]=i,n[1]=l,n[2]=f):f=n[2];let u;n[3]!==a||n[4]!==c||n[5]!==d?(u=a.length>0&&r.jsx("div",{className:"select-none",children:a.map((p,h)=>r.jsxs("div",{className:"group/ghost relative opacity-25 hover:opacity-40 transition-opacity",children:[r.jsx(Xx,{turn:p,index:d+h}),c&&r.jsxs(X,{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:[r.jsx(Ev,{"data-icon":"inline-start"}),"Redo to here"]})]},`ghost-${p.id}`))}),n[3]=a,n[4]=c,n[5]=d,n[6]=u):u=n[6];let m;return n[7]!==f||n[8]!==u?(m=r.jsxs(r.Fragment,{children:[f,u]}),n[7]=f,n[8]=u,n[9]=m):m=n[9],m}function S7(n){const e=U.c(5),{hasMore:t,isLoadingOlder:s}=n;let o;e[0]!==t||e[1]!==s?(o=s?r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx(rt,{className:"size-3 animate-spin","data-icon":"inline-start"}),"Loading older turns…"]}):t?null:r.jsx("span",{children:"Beginning of session"}),e[0]=t,e[1]=s,e[2]=o):o=e[2];let i;return e[3]!==o?(i=r.jsx("div",{className:"flex h-8 select-none items-center justify-center text-xs text-muted-foreground","data-testid":"history-status",children:o}),e[3]=o,e[4]=i):i=e[4],i}function k7(n){return(n.compactionSummary!=null||n.compactionMeta!=null)&&n.userMessage==null&&n.contentBlocks.length===0}function N7({filteredTurns:n,scrollContainerRef:e,hasMore:t=!1,isLoadingOlder:s=!1,pagingEnabled:o=!1,onLoadMore:i}){const{state:{activeTurnIndex:a}}=Rt(),{undoRedo:l}=it(),c=b.useRef(null),d=b.useRef(null),[f,u]=b.useState(0),m=b.useMemo(()=>{const y=new Map;return n.map(j=>{const k=y.get(j.turn.id)??0;return y.set(j.turn.id,k+1),{...j,key:k===0?j.turn.id:`${j.turn.id}#${k}`}})},[n]),p=b.useRef(null),h=b.useMemo(()=>h7(p.current,m.map(y=>y.key)),[m]);b.useLayoutEffect(()=>{var y;p.current={firstKey:(y=m[0])==null?void 0:y.key,length:m.length}},[m]);const g=b.useRef(t);b.useEffect(()=>{t&&(g.current=!0)},[t]);const x=t||g.current;b.useLayoutEffect(()=>{const y=e.current,j=d.current;if(!y||!j)return;const k=j.getBoundingClientRect().top-y.getBoundingClientRect().top+y.scrollTop;u(N=>Math.abs(N-k)<1?N:k)},[e,x]),b.useEffect(()=>{if(!t||!i||!o||s)return;const y=e.current;if(!y)return;const j=()=>{m7(y.scrollTop,y.clientHeight)&&i()};return j(),y.addEventListener("scroll",j,{passive:!0}),()=>y.removeEventListener("scroll",j)},[t,s,o,i,m.length,e]);const v=b.useMemo(()=>{const y=new Map;for(let j=0;j<m.length;j++)y.set(m[j].index,j);return y},[m]),w=b.useRef(null);return b.useEffect(()=>{var j;if(a===null){w.current=null;return}if(a===w.current)return;w.current=a;const y=v.get(a);y!==void 0&&((j=c.current)==null||j.scrollToIndex(y,{align:"start",smooth:!0}))},[a,v]),r.jsxs(r.Fragment,{children:[x&&r.jsx(S7,{hasMore:t,isLoadingOlder:s}),r.jsx("div",{ref:d,className:"motion-session-enter",children:r.jsx(pC,{ref:c,scrollRef:e,startMargin:f,shift:h,children:m.map(({turn:y,index:j,key:k})=>r.jsx("div",{"data-turn-index":j,children:r.jsx(w7,{index:j,children:r.jsxs("div",{children:[(y.compactionSummary||y.compactionMeta)&&r.jsx(u7,{summary:y.compactionSummary,meta:y.compactionMeta}),!k7(y)&&r.jsx(Xx,{turn:y,index:j,branchCount:l.branchesAtTurn?l.branchesAtTurn(j).length:0})]})})},k))})}),r.jsx(j7,{})]})}const C7=b.memo(function(e){const t=U.c(19),{chatScrollRef:s,hasMore:o,isLoadingOlder:i,pagingEnabled:a,onLoadMore:l}=e,{state:c}=Rt(),{searchQuery:d,sessionChangeKey:f}=c,{session:u}=it(),m=u==null?void 0:u.turns;let p;t[0]!==m?(p=m?m.map(_7):[],t[0]=m,t[1]=p):p=t[1];const h=p;let g;t[2]!==h||t[3]!==d?(g=d?h.filter(j=>{const{turn:k}=j;return W6(k,d)}):h,t[2]=h,t[3]=d,t[4]=g):g=t[4];const x=g;let v;t[5]!==x.length||t[6]!==o||t[7]!==d?(v=d?x.length===0:p7(x.length,o??!1),t[5]=x.length,t[6]=o,t[7]=d,t[8]=v):v=t[8];const w=v;let y;return t[9]!==s||t[10]!==x||t[11]!==o||t[12]!==i||t[13]!==l||t[14]!==a||t[15]!==d||t[16]!==f||t[17]!==w?(y=r.jsx(fN,{children:w?r.jsx(Hn,{className:"min-h-64 border-0",children:r.jsxs(Kn,{children:[r.jsx(js,{variant:"icon",children:d?r.jsx(Pv,{}):r.jsx(Qp,{})}),r.jsx(qn,{children:d?"No matching turns":"No conversation yet"}),r.jsx(Vn,{children:d?"Try a different search term.":"Messages and tool activity will appear here."})]})}):r.jsx(N7,{filteredTurns:x,scrollContainerRef:s,hasMore:o,isLoadingOlder:i,pagingEnabled:a,onLoadMore:l},f)}),t[9]=s,t[10]=x,t[11]=o,t[12]=i,t[13]=l,t[14]=a,t[15]=d,t[16]=f,t[17]=w,t[18]=y):y=t[18],y});function _7(n,e){return{turn:n,index:e}}const T7="[data-turn-index]",Qx="[data-turn-prompt]",Fm=1,E7=120,Bm=180;function P7(n){if(!n.userMessage)return null;const e=pa(n.userMessage),{body:t}=or(e),{remainingText:s}=ir(t),o=ld(s);if(!o){const a=z1(e);if(!a)return null;const l=F1(e);return l?`/${a} ${l}`:`/${a}`}const i=o.split(`
|
|
115
|
+
`)[0];return i.length>Bm?`${i.slice(0,Bm)}...`:i}function A7(n,e){for(let t=e;t>=0;t--){const s=n[t];if(!s)continue;const o=P7(s);if(o)return{index:t,text:o}}return null}function R7(n){const e=n.getBoundingClientRect().top;let t=null,s=0;for(const l of n.querySelectorAll(T7)){const c=l.getBoundingClientRect().top;if(c>e+Fm)break;t=l,s=c}if(!t)return null;const o=Number(t.dataset.turnIndex);if(!Number.isInteger(o))return null;const i=t.querySelector(Qx);return(i?i.getBoundingClientRect().bottom>e+Fm:s+E7>e)?null:o}const M7=b.memo(function(e){const t=U.c(22),{session:s,scrollContainerRef:o}=e,[i,a]=b.useState(null);let l,c;t[0]!==o||t[1]!==s.sessionId?(l=()=>{const j=o.current;if(!j)return;let k=null;const N=()=>{k=null;const P=R7(j);a(A=>P===null?null:(A==null?void 0:A.sessionId)===s.sessionId&&A.index===P?A:{sessionId:s.sessionId,index:P})},C=()=>{k===null&&(k=requestAnimationFrame(N))};a(null),j.addEventListener("scroll",C,{passive:!0});const S=new MutationObserver(C);S.observe(j,{childList:!0,subtree:!0});const _=new ResizeObserver(C);return _.observe(j),j.firstElementChild&&_.observe(j.firstElementChild),C(),()=>{j.removeEventListener("scroll",C),S.disconnect(),_.disconnect(),k!==null&&cancelAnimationFrame(k)}},c=[o,s.sessionId],t[0]=o,t[1]=s.sessionId,t[2]=l,t[3]=c):(l=t[2],c=t[3]),b.useEffect(l,c);let d;e:{if(!i||i.sessionId!==s.sessionId){d=null;break e}let j;t[4]!==s.turns||t[5]!==i.index?(j=A7(s.turns,i.index),t[4]=s.turns,t[5]=i.index,t[6]=j):j=t[6],d=j}const f=d;if(!f)return null;let u;t[7]!==f.index||t[8]!==o?(u=()=>{const j=o.current;if(!j)return;const k=j.querySelector(`[data-turn-index="${f.index}"]`),N=(k==null?void 0:k.querySelector(Qx))??k;if(!N)return;const C=j.scrollTop+N.getBoundingClientRect().top-j.getBoundingClientRect().top;j.scrollTo({top:Math.max(0,C),behavior:"smooth"})},t[7]=f.index,t[8]=o,t[9]=u):u=t[9];const m=u,p=`Scroll to turn ${f.index+1} prompt`;let h;t[10]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(Qp,{"data-icon":"inline-start"}),t[10]=h):h=t[10];const g=f.index+1;let x;t[11]!==g?(x=r.jsxs("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:["Turn ",g]}),t[11]=g,t[12]=x):x=t[12];let v;t[13]!==f.text?(v=r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-normal text-foreground/80",children:f.text}),t[13]=f.text,t[14]=v):v=t[14];let w;t[15]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(pr,{"data-icon":"inline-end",className:"ml-auto"}),t[15]=w):w=t[15];let y;return t[16]!==f.text||t[17]!==m||t[18]!==p||t[19]!==x||t[20]!==v?(y=r.jsxs(X,{type:"button",variant:"outline",size:"sm","aria-label":p,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-background px-3 text-left shadow-sm",onClick:m,children:[h,x,v,w]}),t[16]=f.text,t[17]=m,t[18]=p,t[19]=x,t[20]=v,t[21]=y):y=t[21],y});function I7(n){const e=U.c(14),{block:t,showCursor:s}=n;if(t.blockType==="tool_use"){const l=t.toolName??"tool";let c;return e[0]!==l?(c=r.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&&r.jsx(Um,{}),e[2]=s,e[3]=l):l=e[3];let c;return e[4]!==t.text||e[5]!==l?(c=r.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 o;e[7]!==t.text?(o=r.jsx(vx,{text:t.text}),e[7]=t.text,e[8]=o):o=e[8];let i;e[9]!==s?(i=s&&r.jsx(Um,{}),e[9]=s,e[10]=i):i=e[10];let a;return e[11]!==o||e[12]!==i?(a=r.jsxs("div",{className:"text-sm leading-relaxed break-words my-2",children:[o,i]}),e[11]=o,e[12]=i,e[13]=a):a=e[13],a}function Um(){const n=U.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.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 $7=b.memo(function(){const e=U.c(9),t=hd();let s,o,i,a;if(e[0]!==t){a=Symbol.for("react.early_return_sentinel");e:{const c=GC(t);if(c.length===0){a=null;break e}const d=new Map;s="px-4",o="streaming-turn-overlay",i=c.map(f=>{const u=d.get(f.messageId)??0;d.set(f.messageId,u+1);const m=f.blocks.reduce(O7,-1);return r.jsx("div",{children:f.blocks.map((p,h)=>r.jsx(I7,{block:p,showCursor:!f.stopped&&h===m},p.index))},`${f.messageId}:${u}`)})}e[0]=t,e[1]=s,e[2]=o,e[3]=i,e[4]=a}else s=e[1],o=e[2],i=e[3],a=e[4];if(a!==Symbol.for("react.early_return_sentinel"))return a;let l;return e[5]!==s||e[6]!==o||e[7]!==i?(l=r.jsx("div",{className:s,"data-testid":o,children:i}),e[5]=s,e[6]=o,e[7]=i,e[8]=l):l=e[8],l});function O7(n,e,t){return e.blockType!=="tool_use"&&e.text?t:n}const D7=3,Pi=["w-6","w-4","w-2.5","w-2"],L7=Pi[Pi.length-1];function z7(n){return n===null||n<0?L7:Pi[Math.min(n,Pi.length-1)]}function F7(n){return n.type==="text"}function fl(n){return n.replace(/\s+/g," ").trim()}function B7(n){const e=typeof n.userMessage=="string"?n.userMessage:Array.isArray(n.userMessage)?n.userMessage.filter(F7).map(l=>l.text).join(" "):"",{text:t}=W1(e),{remainingText:s}=ir(t),{remainingText:o}=U1(s),i=fl(ld(o));if(i)return i;for(const l of n.contentBlocks){if(l.kind!=="task_notification")continue;const c=ir(l.content).notifications.map(d=>d.summary).find(Boolean);if(c)return fl(c)}return n.assistantText.map(fl).find(Boolean)||"Untitled turn"}const U7=b.memo(function(e){const t=U.c(21),{turns:s,scrollContainerRef:o,onJumpToTurn:i}=e,[a,l]=b.useState(null),c=b.useRef(null),d=s.length;let f;if(t[0]!==s){const j=new Map;f=s.map(k=>{const N=j.get(k.id)??0;return j.set(k.id,N+1),N===0?k.id:`${k.id}#${N}`}),t[0]=s,t[1]=f}else f=t[1];const u=f;let m;t[2]!==o?(m=()=>{const j=o.current,k=c.current;if(!j||!k)return;let N=null;const C=()=>{N=null;const _=j.getBoundingClientRect().top+j.clientHeight/2;let P=null;for(const A of j.querySelectorAll("[data-turn-index]")){const E=A.getBoundingClientRect();if(E.top<=_&&E.bottom>=_){P=Number(A.dataset.turnIndex);break}}for(const A of k.querySelectorAll("[data-tick-index]"))A.dataset.current=String(Number(A.dataset.tickIndex)===P)},S=()=>{N===null&&(N=requestAnimationFrame(C))};return C(),j.addEventListener("scroll",S,{passive:!0}),()=>{j.removeEventListener("scroll",S),N!==null&&cancelAnimationFrame(N)}},t[2]=o,t[3]=m):m=t[3];let p;t[4]!==o||t[5]!==d?(p=[o,d],t[4]=o,t[5]=d,t[6]=p):p=t[6],b.useEffect(m,p);let h;t[7]===Symbol.for("react.memo_cache_sentinel")?(h=j=>{const k=j.key==="ArrowDown"?1:j.key==="ArrowUp"?-1:0,N=c.current;if(!N)return;const C=[...N.querySelectorAll("[data-tick-index]")];if(C.length===0)return;let S;if(k!==0){const _=C.indexOf(document.activeElement);S=C[Math.min(Math.max(_+k,0),C.length-1)]}else j.key==="Home"?S=C[0]:j.key==="End"&&(S=C[C.length-1]);S&&(j.preventDefault(),S.focus())},t[7]=h):h=t[7];const g=h;if(d<D7)return null;let x;t[8]===Symbol.for("react.memo_cache_sentinel")?(x=()=>l(null),t[8]=x):x=t[8];let v;t[9]===Symbol.for("react.memo_cache_sentinel")?(v=G("absolute left-0 top-0 hidden h-full max-h-full flex-col items-start gap-1","justify-evenly overflow-y-auto pb-6 pl-2 pt-14","opacity-60 transition-opacity hover:opacity-100 focus-within:opacity-100","[@media(pointer:fine)]:flex"),t[9]=v):v=t[9];let w;if(t[10]!==a||t[11]!==i||t[12]!==u||t[13]!==s){let j;t[15]!==a||t[16]!==i||t[17]!==u?(j=(k,N)=>{const C=B7(k);return r.jsx(X,{type:"button",variant:"ghost","data-tick-index":N,onMouseEnter:()=>l(N),onFocus:()=>l(N),onClick:()=>i(N),"aria-label":`Turn ${N+1}: ${C}`,className:G("group/tick relative h-1 shrink-0 rounded-full bg-muted-foreground/30 p-0","transition-[width,background-color] duration-150 motion-reduce:transition-none","hover:bg-muted-foreground/80 focus-visible:outline-none focus-visible:bg-muted-foreground/80","data-[current=true]:bg-primary/70",z7(a===null?null:Math.abs(N-a))),children:r.jsxs("span",{className:G("pointer-events-none absolute left-full top-1/2 ml-2 hidden w-64 -translate-y-1/2","rounded-md border bg-popover px-2 py-1.5 text-left","text-xs leading-relaxed text-popover-foreground shadow-sm","group-hover/tick:block group-focus-visible/tick:block"),children:[r.jsx("span",{className:"mr-1 font-mono text-muted-foreground/60",children:N+1}),r.jsx("span",{className:"line-clamp-2 align-middle",children:C})]})},u[N])},t[15]=a,t[16]=i,t[17]=u,t[18]=j):j=t[18],w=s.map(j),t[10]=a,t[11]=i,t[12]=u,t[13]=s,t[14]=w}else w=t[14];let y;return t[19]!==w?(y=r.jsx("nav",{ref:c,"aria-label":"Conversation timeline",onMouseLeave:x,onKeyDown:g,className:v,children:w}),t[19]=w,t[20]=y):y=t[20],y});class W7 extends b.Component{constructor(t){super(t);Wr(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?r.jsx("div",{className:"flex justify-center p-8",children:r.jsxs(Ct,{variant:"destructive",className:"max-w-md has-data-[slot=alert-action]:pr-2.5",children:[r.jsx(wn,{}),r.jsx(Dt,{children:r.jsx("h3",{children:this.props.fallbackMessage||"Something went wrong"})}),this.state.error&&r.jsx(_t,{className:"font-mono text-xs",children:this.state.error.message}),r.jsx(xs,{className:"static col-start-2 mt-2",children:r.jsxs(X,{variant:"outline",size:"sm",onClick:this.handleRetry,children:[r.jsx(Qt,{"data-icon":"inline-start"}),"Try again"]})})]})}):this.props.children}}const Wm="find-in-session-highlight",ml="find-in-session-active";function H7(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 K7=b.forwardRef(function(e,t){const s=U.c(63),{scrollContainerRef:o}=e,[i,a]=b.useState(!1),[l,c]=b.useState("");let d;s[0]===Symbol.for("react.memo_cache_sentinel")?(d=[],s[0]=d):d=s[0];const[f,u]=b.useState(d),[m,p]=b.useState(-1),h=b.useRef(null);let g;s[1]!==o?(g=()=>{const se=o.current;if(!se)return;se.querySelectorAll(`mark.${Wm}`).forEach(q7)},s[1]=o,s[2]=g):g=s[2];const x=g;let v;s[3]!==x||s[4]!==o?(v=se=>{if(x(),!se||!o.current){u([]),p(-1);return}const re=o.current,ie=H7(re),ae=se.toLowerCase(),te=[];for(const he of ie){const me=he.nodeValue||"",le=me.toLowerCase();let xe=0;const ge=[];for(;;){const ue=le.indexOf(ae,xe);if(ue===-1)break;ge.push(ue),xe=ue+1}if(ge.length===0)continue;const ce=he.parentNode;if(!ce)continue;const we=document.createDocumentFragment();let pe=0;for(const ue of ge){ue>pe&&we.appendChild(document.createTextNode(me.slice(pe,ue)));const je=document.createElement("mark");je.className=Wm,je.textContent=me.slice(ue,ue+se.length),we.appendChild(je),te.push(je),pe=ue+se.length}pe<me.length&&we.appendChild(document.createTextNode(me.slice(pe))),ce.replaceChild(we,he)}u(te),te.length>0?(p(0),te[0].classList.add(ml),te[0].scrollIntoView({block:"center",behavior:"smooth"})):p(-1)},s[3]=x,s[4]=o,s[5]=v):v=s[5];const w=v;let y;s[6]!==m||s[7]!==f?(y=se=>{if(f.length===0)return;m>=0&&m<f.length&&f[m].classList.remove(ml);const re=(se%f.length+f.length)%f.length;f[re].classList.add(ml),f[re].scrollIntoView({block:"center",behavior:"smooth"}),p(re)},s[6]=m,s[7]=f,s[8]=y):y=s[8];const j=y;let k;s[9]!==x?(k=()=>{a(!1),c(""),x(),u([]),p(-1)},s[9]=x,s[10]=k):k=s[10];const N=k;let C,S;s[11]!==N||s[12]!==i?(C=()=>({open:()=>{a(!0),requestAnimationFrame(()=>{var se;return(se=h.current)==null?void 0:se.focus()})},close:N,isOpen:i}),S=[N,i],s[11]=N,s[12]=i,s[13]=C,s[14]=S):(C=s[13],S=s[14]),b.useImperativeHandle(t,C,S);let _,P;s[15]!==w||s[16]!==l?(_=()=>{const se=setTimeout(()=>w(l),150);return()=>clearTimeout(se)},P=[l,w],s[15]=w,s[16]=l,s[17]=_,s[18]=P):(_=s[17],P=s[18]),b.useEffect(_,P);let A,E;s[19]!==x?(A=()=>()=>x(),E=[x],s[19]=x,s[20]=A,s[21]=E):(A=s[20],E=s[21]),b.useEffect(A,E);let T;s[22]!==m||s[23]!==j||s[24]!==N?(T=se=>{se.key==="Escape"?(se.preventDefault(),se.stopPropagation(),N()):se.key==="Enter"&&(se.preventDefault(),se.shiftKey?j(m-1):j(m+1))},s[22]=m,s[23]=j,s[24]=N,s[25]=T):T=s[25];const M=T;if(!i)return null;let I;s[26]===Symbol.for("react.memo_cache_sentinel")?(I=se=>c(se.target.value),s[26]=I):I=s[26];let R;s[27]!==M||s[28]!==l?(R=r.jsx(es,{ref:h,value:l,onChange:I,onKeyDown:M,placeholder:"Find in conversation","aria-label":"Find in conversation",autoFocus:!0}),s[27]=M,s[28]=l,s[29]=R):R=s[29];const $=l?f.length>0?`${m+1}/${f.length}`:"0/0":"";let D;s[30]!==$?(D=r.jsx(yn,{align:"inline-end",children:r.jsx("span",{className:"min-w-12 text-center text-xs tabular-nums",children:$})}),s[30]=$,s[31]=D):D=s[31];let O;s[32]!==R||s[33]!==D?(O=r.jsxs(Zn,{className:"w-64",children:[R,D]}),s[32]=R,s[33]=D,s[34]=O):O=s[34];let L;s[35]!==m||s[36]!==j?(L=()=>j(m-1),s[35]=m,s[36]=j,s[37]=L):L=s[37];const z=f.length===0,F=f.length>0?"hover:text-foreground":"cursor-default opacity-40";let H;s[38]!==F?(H=G("text-muted-foreground",F),s[38]=F,s[39]=H):H=s[39];let B;s[40]===Symbol.for("react.memo_cache_sentinel")?(B=r.jsx(pr,{"data-icon":"inline-start"}),s[40]=B):B=s[40];let W;s[41]!==L||s[42]!==z||s[43]!==H?(W=r.jsx(X,{type:"button",variant:"ghost",size:"icon-sm",onClick:L,disabled:z,className:H,"aria-label":"Previous match",children:B}),s[41]=L,s[42]=z,s[43]=H,s[44]=W):W=s[44];let K;s[45]!==m||s[46]!==j?(K=()=>j(m+1),s[45]=m,s[46]=j,s[47]=K):K=s[47];const V=f.length===0,Y=f.length>0?"hover:text-foreground":"cursor-default opacity-40";let q;s[48]!==Y?(q=G("text-muted-foreground",Y),s[48]=Y,s[49]=q):q=s[49];let J;s[50]===Symbol.for("react.memo_cache_sentinel")?(J=r.jsx(nt,{"data-icon":"inline-start"}),s[50]=J):J=s[50];let Z;s[51]!==K||s[52]!==V||s[53]!==q?(Z=r.jsx(X,{type:"button",variant:"ghost",size:"icon-sm",onClick:K,disabled:V,className:q,"aria-label":"Next match",children:J}),s[51]=K,s[52]=V,s[53]=q,s[54]=Z):Z=s[54];let Q;s[55]===Symbol.for("react.memo_cache_sentinel")?(Q=r.jsx(jt,{"data-icon":"inline-start"}),s[55]=Q):Q=s[55];let ee;s[56]!==N?(ee=r.jsx(X,{type:"button",variant:"ghost",size:"icon-sm",onClick:N,className:"text-muted-foreground hover:text-foreground","aria-label":"Close search",children:Q}),s[56]=N,s[57]=ee):ee=s[57];let oe;return s[58]!==O||s[59]!==W||s[60]!==Z||s[61]!==ee?(oe=r.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:[O,W,Z,ee]}),s[58]=O,s[59]=W,s[60]=Z,s[61]=ee,s[62]=oe):oe=s[62],oe});function q7(n){const e=n.parentNode;e&&(e.replaceChild(document.createTextNode(n.textContent||""),n),e.normalize())}const eI=["General","View","Tools"],ja=[{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}},{command:"device.switch.1",label:"Switch to device 1",description:"Jump to this machine (the local device)",group:"General",defaultShortcut:{key:"1",platformChord:!0}},{command:"device.switch.2",label:"Switch to device 2",description:"Jump to the 2nd device in the switcher",group:"General",defaultShortcut:{key:"2",platformChord:!0}},{command:"device.switch.3",label:"Switch to device 3",description:"Jump to the 3rd device in the switcher",group:"General",defaultShortcut:{key:"3",platformChord:!0}},{command:"device.switch.4",label:"Switch to device 4",description:"Jump to the 4th device in the switcher",group:"General",defaultShortcut:{key:"4",platformChord:!0}},{command:"device.switch.5",label:"Switch to device 5",description:"Jump to the 5th device in the switcher",group:"General",defaultShortcut:{key:"5",platformChord:!0}},{command:"device.switch.6",label:"Switch to device 6",description:"Jump to the 6th device in the switcher",group:"General",defaultShortcut:{key:"6",platformChord:!0}},{command:"device.switch.7",label:"Switch to device 7",description:"Jump to the 7th device in the switcher",group:"General",defaultShortcut:{key:"7",platformChord:!0}},{command:"device.switch.8",label:"Switch to device 8",description:"Jump to the 8th device in the switcher",group:"General",defaultShortcut:{key:"8",platformChord:!0}},{command:"device.switch.9",label:"Switch to device 9",description:"Jump to the 9th device in the switcher",group:"General",defaultShortcut:{key:"9",platformChord:!0}},{command:"device.cycle",label:"Cycle devices",description:"Switch to the next device in the switcher",group:"General",defaultShortcut:{key:"0",platformChord:!0}}],Zx="cogpit-keybindings";let _s=null;function e0(n=typeof navigator>"u"?"":navigator.platform){return/Mac|iPhone|iPad/i.test(n)}function ur(n){const e=n.toLowerCase();return e==="esc"?"escape":e}function V7(n){if(!n||typeof n!="object")return!1;const e=n;return e.doubleTapModifier==="mod"||typeof e.key=="string"&&e.key.length>0}function Cd(){if(_s)return _s;try{const n=localStorage.getItem(Zx);if(!n)return _s={};const e=JSON.parse(n);if(!e||typeof e!="object")return _s={};const t={};for(const s of ja){const o=e[s.command];V7(o)&&(t[s.command]=o)}return _s=t}catch{return _s={}}}function _d(n){_s=n;try{localStorage.setItem(Zx,JSON.stringify(n))}catch{}typeof window<"u"&&window.dispatchEvent(new Event("cogpit-keybindings-changed"))}function Mr(n){const e=ja.find(t=>t.command===n);if(!e)throw new Error(`Unknown keybinding command: ${n}`);return Cd()[n]??e.defaultShortcut}function tI(){return Object.fromEntries(ja.map(n=>[n.command,Mr(n.command)]))}function nI(n,e){const t="doubleTapModifier"in e?{...e}:{...e,key:ur(e.key)};_d({...Cd(),[n]:t})}function sI(n){const e={...Cd()};delete e[n],_d(e)}function oI(){_d({})}function rI(n){return{key:ur(n.key),metaKey:n.metaKey||void 0,ctrlKey:n.ctrlKey||void 0,shiftKey:n.shiftKey||void 0,altKey:n.altKey||void 0}}function t0(n){const e=n;if(!e)return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||e.isContentEditable===!0}function yt(n,e){const t=Mr(n);return"doubleTapModifier"in t||ur(e.key)!==ur(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 Ys(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 G7(n){const e=e0();return"doubleTapModifier"in n?e?"Double ⌘":"Double Ctrl":n.modKey?e?`${n.shiftKey?"⇧":""}⌘${Ys(n.key)}`:`Ctrl+${n.shiftKey?"Shift+":""}${Ys(n.key)}`:n.platformChord?e?`⌃⌘${n.shiftKey?"⇧":""}${Ys(n.key)}`:`Ctrl+Alt+${n.shiftKey?"Shift+":""}${Ys(n.key)}`:e?`${n.ctrlKey?"⌃":""}${n.altKey?"⌥":""}${n.shiftKey?"⇧":""}${n.metaKey?"⌘":""}${Ys(n.key)}`:[n.ctrlKey?"Ctrl":null,n.altKey?"Alt":null,n.shiftKey?"Shift":null,n.metaKey?"Meta":null,Ys(n.key)].filter(Boolean).join("+")}function pl(n){return G7(Mr(n))}function Hm(n){if("doubleTapModifier"in n)return[`double-tap:${n.doubleTapModifier}`];const e=(t,s,o,i)=>`${ur(n.key)}|${t}|${s}|${o}|${i}`;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 iI(n,e){const t=new Set(Hm(n));return ja.find(s=>s.command!==e&&Hm(Mr(s.command)).some(o=>t.has(o)))??null}function Km(n){return"doubleTapModifier"in Mr(n)?e0()?"Meta":"Control":null}const Y7=["device.switch.1","device.switch.2","device.switch.3","device.switch.4","device.switch.5","device.switch.6","device.switch.7","device.switch.8","device.switch.9"],X7="device.cycle";function J7(n){const e=Y7.findIndex(t=>yt(t,n));return e===-1?null:e+1}function Q7(n){return yt(X7,n)}const tc="cogpit:find-in-conversation",Sa=b.memo(function(e){const t=U.c(85),{searchInputRef:s,hasTodos:o,hasMore:i,isLoadingOlder:a,onLoadMore:l,mobileSearchOpen:c,onMobileSearchClose:d}=e,f=c===void 0?!1:c,{state:u,dispatch:m,isMobile:p}=Rt(),{session:h}=it(),{chat:g,scroll:x}=yr(),{searchQuery:v}=u,{pendingMessages:w}=g,{chatScrollRef:y,scrollEndRef:j,handleScroll:k,canScrollDown:N,scrollToBottomInstant:C,initialScrollDone:S}=x,_=b.useRef(null);let P;t[0]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{var ue;return(ue=_.current)==null?void 0:ue.open()},t[0]=P):P=t[0];const A=P;let E,T;t[1]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{const ue=function(Ne){yt("findInConversation",Ne)&&(Ne.preventDefault(),A())};return window.addEventListener("keydown",ue),window.addEventListener(tc,A),()=>{window.removeEventListener("keydown",ue),window.removeEventListener(tc,A)}},T=[A],t[1]=E,t[2]=T):(E=t[1],T=t[2]),b.useEffect(E,T);let M,I;t[3]!==p||t[4]!==f||t[5]!==s?(M=()=>{!p||!f||requestAnimationFrame(()=>{var ue;return(ue=s.current)==null?void 0:ue.focus()})},I=[p,f,s],t[3]=p,t[4]=f,t[5]=s,t[6]=M,t[7]=I):(M=t[6],I=t[7]),b.useEffect(M,I);let R;t[8]!==m?(R=ue=>m({type:"JUMP_TO_TURN",index:ue}),t[8]=m,t[9]=R):R=t[9];const $=R;let D;t[10]!==m||t[11]!==d?(D=()=>{m({type:"SET_SEARCH_QUERY",value:""}),d==null||d()},t[10]=m,t[11]=d,t[12]=D):D=t[12];const O=D,L=h,z=L.turns.length>0||w.length===0,F=p?"flex min-h-0 flex-1 flex-col":"min-h-0 flex-1";let H;t[13]!==F?(H=G("relative bg-background",F),t[13]=F,t[14]=H):H=t[14];let B;t[15]!==O||t[16]!==m||t[17]!==p||t[18]!==f||t[19]!==s||t[20]!==v?(B=p&&f&&r.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b bg-background px-3 py-2",children:[r.jsxs(Zn,{className:"h-9 flex-1",children:[r.jsx(es,{ref:s,value:v,onChange:ue=>m({type:"SET_SEARCH_QUERY",value:ue.target.value}),placeholder:"Search conversation...","aria-label":"Search conversation"}),r.jsx(yn,{align:"inline-start",children:r.jsx(xn,{})})]}),r.jsx(X,{variant:"ghost",size:"icon-sm",onClick:O,"aria-label":"Close conversation search",children:r.jsx(jt,{"data-icon":"inline-start"})})]}),t[15]=O,t[16]=m,t[17]=p,t[18]=f,t[19]=s,t[20]=v,t[21]=B):B=t[21];const W=p?"flex-1 min-h-0":"h-full";let K;t[22]!==W?(K=G("relative",W),t[22]=W,t[23]=K):K=t[23];let V;t[24]!==y?(V=r.jsx(K7,{ref:_,scrollContainerRef:y}),t[24]=y,t[25]=V):V=t[25];let Y;t[26]!==y||t[27]!==L.turns||t[28]!==$||t[29]!==p?(Y=!p&&r.jsx(U7,{turns:L.turns,scrollContainerRef:y,onJumpToTurn:$}),t[26]=y,t[27]=L.turns,t[28]=$,t[29]=p,t[30]=Y):Y=t[30];let q;t[31]!==y||t[32]!==L?(q=r.jsx(M7,{session:L,scrollContainerRef:y}),t[31]=y,t[32]=L,t[33]=q):q=t[33];const J=p&&"mobile-scroll";let Z;t[34]!==J?(Z=G("h-full overflow-x-hidden overflow-y-auto bg-background",J),t[34]=J,t[35]=Z):Z=t[35];let Q;t[36]!==o||t[37]!==p?(Q=p?"px-3 py-3 pb-5":G("mx-auto w-full max-w-[var(--chat-width)] px-6 pt-14",o?"pb-48":"pb-32"),t[36]=o,t[37]=p,t[38]=Q):Q=t[38];let ee;t[39]!==y||t[40]!==i||t[41]!==S||t[42]!==a||t[43]!==l||t[44]!==z?(ee=z&&r.jsx(C7,{chatScrollRef:y,hasMore:i,isLoadingOlder:a,pagingEnabled:S,onLoadMore:l}),t[39]=y,t[40]=i,t[41]=S,t[42]=a,t[43]=l,t[44]=z,t[45]=ee):ee=t[45];let oe;t[46]===Symbol.for("react.memo_cache_sentinel")?(oe=r.jsx($7,{}),t[46]=oe):oe=t[46];let se;if(t[47]!==L.turns.length||t[48]!==w){let ue;t[50]!==L.turns.length?(ue=(je,Ne)=>r.jsx(K1,{message:je,turnNumber:L.turns.length+1+Ne},Ne),t[50]=L.turns.length,t[51]=ue):ue=t[51],se=w.map(ue),t[47]=L.turns.length,t[48]=w,t[49]=se}else se=t[49];let re;t[52]===Symbol.for("react.memo_cache_sentinel")?(re=r.jsx(B6,{}),t[52]=re):re=t[52];let ie;t[53]!==j?(ie=r.jsx("div",{ref:j}),t[53]=j,t[54]=ie):ie=t[54];let ae;t[55]!==ee||t[56]!==se||t[57]!==ie?(ae=r.jsxs(W7,{fallbackMessage:"Failed to render conversation timeline",children:[ee,oe,se,re,ie]}),t[55]=ee,t[56]=se,t[57]=ie,t[58]=ae):ae=t[58];let te;t[59]!==Q||t[60]!==ae?(te=r.jsx("div",{className:Q,children:ae}),t[59]=Q,t[60]=ae,t[61]=te):te=t[61];let he;t[62]!==y||t[63]!==k||t[64]!==Z||t[65]!==te?(he=r.jsx("div",{ref:y,onScroll:k,className:Z,children:te}),t[62]=y,t[63]=k,t[64]=Z,t[65]=te,t[66]=he):he=t[66];const me=N?"opacity-100 scale-100":"opacity-0 scale-75 pointer-events-none",le=p?"right-3 bottom-3":"right-5 bottom-5";let xe;t[67]!==me||t[68]!==le?(xe=G("absolute rounded-full shadow-sm transition-[opacity,transform] duration-200 ease-out active:scale-95",me,le),t[67]=me,t[68]=le,t[69]=xe):xe=t[69];let ge;t[70]===Symbol.for("react.memo_cache_sentinel")?(ge=r.jsx(Av,{"data-icon":"inline-start"}),t[70]=ge):ge=t[70];let ce;t[71]!==C||t[72]!==xe?(ce=r.jsx(X,{size:"icon",className:xe,onClick:C,"aria-label":"Scroll to bottom",children:ge}),t[71]=C,t[72]=xe,t[73]=ce):ce=t[73];let we;t[74]!==K||t[75]!==V||t[76]!==Y||t[77]!==q||t[78]!==he||t[79]!==ce?(we=r.jsxs("div",{className:K,children:[V,Y,q,he,ce]}),t[74]=K,t[75]=V,t[76]=Y,t[77]=q,t[78]=he,t[79]=ce,t[80]=we):we=t[80];let pe;return t[81]!==H||t[82]!==B||t[83]!==we?(pe=r.jsxs("div",{className:H,children:[B,we]}),t[81]=H,t[82]=B,t[83]=we,t[84]=pe):pe=t[84],pe}),nc="cogpit-devices-changed",n0="cogpit:devices-changed";function s0(n){typeof n.connectionRevision=="number"&&rw(n.id,n.connectionRevision)}function o0(n,e,t=!1){window.dispatchEvent(new CustomEvent(nc,{detail:{deviceId:n,connectionRevision:e,removed:t}}));try{localStorage.setItem(n0,JSON.stringify({deviceId:n,connectionRevision:e,removed:t,nonce:`${Date.now()}:${Math.random()}`}))}catch{}}function qm(n){s0(n),o0(n.id,n.connectionRevision)}function hl(n,e=""){return`/api/hub/devices/${encodeURIComponent(n)}${e}`}async function Xs(n){try{const e=await n.json();return e&&typeof e=="object"?e:null}catch{return null}}function r0(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.version;if(typeof t=="string")return t}}function Z7(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.edition;if(t==="team"||t==="personal")return t}}function ka(){const[n,e]=b.useState([]),[t,s]=b.useState(!0),[o,i]=b.useState(()=>ht()),a=b.useRef(0),l=b.useCallback(async()=>{const h=++a.current;try{const g=await rs("/api/hub/devices");if(!g.ok)return;const x=await Xs(g);if(h!==a.current)return;const v=Array.isArray(x==null?void 0:x.devices)?x.devices:[];for(const w of v)s0(w);e(v)}catch{}finally{h===a.current&&s(!1)}},[]);b.useEffect(()=>{l()},[l]),b.useEffect(()=>{const h=()=>i(ht()),g=()=>void l(),x=y=>{if(y.key===n0){try{const j=JSON.parse(y.newValue??"null");(j==null?void 0:j.removed)===!0&&typeof j.deviceId=="string"&&ht()===j.deviceId&&ps(wt)}catch{}l()}},v=()=>{a.current+=1,e([]),s(!0),l()},w=()=>{a.current+=1,e([]),s(!1)};return window.addEventListener("cogpit-device-changed",h),window.addEventListener("popstate",h),window.addEventListener(nc,g),window.addEventListener("storage",x),window.addEventListener("cogpit-auth-changed",v),window.addEventListener("cogpit-identity-changed",v),window.addEventListener("cogpit-auth-required",w),()=>{window.removeEventListener("cogpit-device-changed",h),window.removeEventListener("popstate",h),window.removeEventListener(nc,g),window.removeEventListener("storage",x),window.removeEventListener("cogpit-auth-changed",v),window.removeEventListener("cogpit-identity-changed",v),window.removeEventListener("cogpit-auth-required",w)}},[l]);const c=b.useMemo(()=>o===wt?void 0:n.find(h=>h.id===o),[n,o]),d=b.useCallback(async(h,g,x,v)=>{try{const w=await rs("/api/hub/devices/probe",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:h,port:g,allowLocalTunnel:x,tls:v})}),y=await Xs(w);return(y==null?void 0:y.ok)===!0&&y.hello?{ok:!0,hello:y.hello}:{ok:!1,code:(y==null?void 0:y.code)??"UNREACHABLE",error:typeof(y==null?void 0:y.error)=="string"?y.error:void 0}}catch{return{ok:!1,code:"UNREACHABLE",error:"Could not reach the device."}}},[]),f=b.useCallback(async h=>{try{const g=await rs("/api/hub/devices",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(h)}),x=await Xs(g);if(g.ok&&(x!=null&&x.device)){const v=x.device;return qm(v),{ok:!0,device:v}}return{ok:!1,code:(x==null?void 0:x.code)??"ERROR",error:typeof(x==null?void 0:x.error)=="string"?x.error:"Could not add the device."}}catch{return{ok:!1,code:"ERROR",error:"Could not add the device."}}},[]),u=b.useCallback(async(h,g)=>{try{const x=await rs(hl(h),{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(g)}),v=await Xs(x);if(x.ok&&(v!=null&&v.device)){const w=v.device;return qm(w),{ok:!0,device:w}}return{ok:!1,code:(v==null?void 0:v.code)??"ERROR",error:typeof(v==null?void 0:v.error)=="string"?v.error:"Could not update the device."}}catch{return{ok:!1,code:"ERROR",error:"Could not update the device."}}},[]),m=b.useCallback(async h=>{try{const g=await rs(hl(h),{method:"DELETE"});if(g.ok)return ht()===h&&ps(wt),o0(h,void 0,!0),{ok:!0};const x=await Xs(g);return{ok:!1,error:typeof(x==null?void 0:x.error)=="string"?x.error:"Could not remove the device."}}catch{return{ok:!1,error:"Could not remove the device."}}},[]),p=b.useCallback(async h=>{try{const g=await rs(hl(h,"/test"),{method:"POST"});return await Xs(g)??{ok:!1,reachable:!1,code:"UNREACHABLE"}}catch{return{ok:!1,reachable:!1,code:"UNREACHABLE"}}},[]);return{devices:n,activeDeviceId:o,activeDevice:c,loading:t,refresh:l,probe:d,addDevice:f,updateDevice:u,removeDevice:m,testDevice:p}}const eE=b.lazy(()=>Ke(()=>import("./CommandPaletteHost-C-ParO8t.js"),__vite__mapDeps([25,1,2,3,4])).then(n=>({default:n.CommandPaletteHost}))),tE=b.lazy(()=>Ke(()=>import("./index-Cgnw8FK8.js"),__vite__mapDeps([26,1,2,3,4])).then(n=>({default:n.ConfigDialog}))),nE=b.lazy(()=>Ke(()=>Promise.resolve().then(()=>wE),void 0).then(n=>({default:n.DevicesDialog}))),sE=b.lazy(()=>Ke(()=>import("./KeyboardShortcutsDialog-CluzMowK.js"),__vite__mapDeps([27,1,2,3,4])).then(n=>({default:n.KeyboardShortcutsDialog}))),oE=b.lazy(()=>Ke(()=>import("./ProjectSwitcherModal-BUXfKNzX.js"),__vite__mapDeps([28,1,2,3,4])).then(n=>({default:n.ProjectSwitcherModal}))),rE=b.lazy(()=>Ke(()=>import("./ThemeSelectorModal-Cmx9maEq.js"),__vite__mapDeps([29,1,2,3,4])).then(n=>({default:n.ThemeSelectorModal}))),iE=b.lazy(()=>Ke(()=>import("./WorktreePanel-h3DRRXek.js"),__vite__mapDeps([30,1,2,3,4])).then(n=>({default:n.WorktreePanel})));function aE(n){const e=U.c(125),{navigation:t,project:s,chrome:o}=n,{state:i,config:a,theme:l}=Rt(),{session:c,sessionSource:d}=it(),{devices:f,activeDeviceId:u}=ka(),[m,p]=b.useState(null),[h,g]=b.useState(null);let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=ut("manageDevices"),e[0]=x):x=e[0];const v=x;let w;e[1]!==i.pendingCwd||e[2]!==i.pendingDirName?(w=i.pendingCwd??(i.pendingDirName?hn(i.pendingDirName):null),e[1]=i.pendingCwd,e[2]=i.pendingDirName,e[3]=w):w=e[3];const y=w,j=(d==null?void 0:d.dirName)??i.pendingDirName??i.dashboardProject??null,k=m??h;let N,C;e[4]!==m?(N=()=>{m&&g(m)},C=[m],e[4]=m,e[5]=N,e[6]=C):(N=e[5],C=e[6]),b.useEffect(N,C);const S=o.onKeyboardShortcutsOpenChange;let _,P;e[7]!==S?(_=()=>{const Se=function(Ue){yt("keyboardShortcuts",Ue)&&(t0(document.activeElement)||(Ue.preventDefault(),S(!0)))};return window.addEventListener("keydown",Se),()=>window.removeEventListener("keydown",Se)},P=[S],e[7]=S,e[8]=_,e[9]=P):(_=e[8],P=e[9]),b.useEffect(_,P);const A=u===wt;let E;e[10]!==A?(E={id:wt,name:"This machine",isLocal:!0,isActive:A},e[10]=A,e[11]=E):E=e[11];let T;if(e[12]!==u||e[13]!==f||e[14]!==E){let Se;e[16]!==u?(Se=$e=>({id:$e.id,name:$e.name,isLocal:!1,isActive:$e.id===u}),e[16]=u,e[17]=Se):Se=e[17],T=[E,...f.map(Se)],e[12]=u,e[13]=f,e[14]=E,e[15]=T}else T=e[15];const M=T;let I;e[18]!==c||e[19]!==(d==null?void 0:d.agentKind)||e[20]!==(d==null?void 0:d.dirName)?(I=()=>{if(!c)return;const Se=(d==null?void 0:d.agentKind)??St((d==null?void 0:d.dirName)??null);br(mh(Se,c.sessionId,c.cwd))},e[18]=c,e[19]=d==null?void 0:d.agentKind,e[20]=d==null?void 0:d.dirName,e[21]=I):I=e[21];const R=I,$=lE,D=s.supportsWorktrees&&t.panels.showWorktrees;let O;e[22]!==j||e[23]!==t.actions||e[24]!==t.panels?(O=Se=>{j&&t.actions.handleDashboardSelect(j,`${Se}.jsonl`),t.panels.setShowWorktrees(!1)},e[22]=j,e[23]=t.actions,e[24]=t.panels,e[25]=O):O=e[25];let L;e[26]!==j||e[27]!==t.panels.setShowWorktrees||e[28]!==s.worktrees.loading||e[29]!==s.worktrees.refetch||e[30]!==s.worktrees.worktrees||e[31]!==D||e[32]!==O?(L=r.jsx(b.Suspense,{fallback:null,children:r.jsx(iE,{open:D,onOpenChange:t.panels.setShowWorktrees,worktrees:s.worktrees.worktrees,loading:s.worktrees.loading,dirName:j,onRefetch:s.worktrees.refetch,onOpenSession:O})}),e[26]=j,e[27]=t.panels.setShowWorktrees,e[28]=s.worktrees.loading,e[29]=s.worktrees.refetch,e[30]=s.worktrees.worktrees,e[31]=D,e[32]=O,e[33]=L):L=e[33];const z=o.processPanel,F=o.workflowsPanel,H=o.undoDialog,B=o.branchModal,W=a.claudeDir??"";let K;e[34]!==a.handleCloseConfigDialog||e[35]!==a.handleConfigSaved||e[36]!==a.showConfigDialog||e[37]!==W?(K=r.jsx(b.Suspense,{fallback:null,children:r.jsx(tE,{open:a.showConfigDialog,currentPath:W,onClose:a.handleCloseConfigDialog,onSaved:a.handleConfigSaved})}),e[34]=a.handleCloseConfigDialog,e[35]=a.handleConfigSaved,e[36]=a.showConfigDialog,e[37]=W,e[38]=K):K=e[38];const V=(d==null?void 0:d.dirName)??i.pendingDirName??null,Y=(c==null?void 0:c.cwd)??i.pendingCwd??null;let q;e[39]!==a.defaultAgentKind||e[40]!==t.onStartNewFolder||e[41]!==t.onStartNewSession||e[42]!==t.panels.handleCloseProjectSwitcher||e[43]!==t.panels.showProjectSwitcher||e[44]!==V||e[45]!==Y?(q=r.jsx(b.Suspense,{fallback:null,children:r.jsx(oE,{open:t.panels.showProjectSwitcher,onClose:t.panels.handleCloseProjectSwitcher,onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:a.defaultAgentKind,currentProjectDirName:V,currentProjectCwd:Y})}),e[39]=a.defaultAgentKind,e[40]=t.onStartNewFolder,e[41]=t.onStartNewSession,e[42]=t.panels.handleCloseProjectSwitcher,e[43]=t.panels.showProjectSwitcher,e[44]=V,e[45]=Y,e[46]=q):q=e[46];let J;e[47]!==t.panels.handleCloseThemeSelector||e[48]!==t.panels.showThemeSelector||e[49]!==l.setPreview||e[50]!==l.setTheme||e[51]!==l.theme?(J=r.jsx(b.Suspense,{fallback:null,children:r.jsx(rE,{open:t.panels.showThemeSelector,onClose:t.panels.handleCloseThemeSelector,currentTheme:l.theme,onSelectTheme:l.setTheme,onPreviewTheme:l.setPreview})}),e[47]=t.panels.handleCloseThemeSelector,e[48]=t.panels.showThemeSelector,e[49]=l.setPreview,e[50]=l.setTheme,e[51]=l.theme,e[52]=J):J=e[52];const Z=o.commandPaletteOpen,Q=o.onCommandPaletteOpenChange,ee=t.actions.handleGoHome,oe=t.panels.handleOpenProjectSwitcher,se=t.onOpenPaletteProject,re=t.actions.handleDashboardSelect,ie=t.panels.handleToggleSidebar,ae=t.panels.handleToggleStats,te=t.panels.handleToggleFileChanges,he=t.panels.handleToggleWorktrees,me=t.panels.handleToggleMission,le=c?t.handlers.handleDuplicateSession:void 0,xe=c?R:void 0,ge=c?$:void 0,ce=ut("killAny")?o.onKillAll:void 0,we=ut("configWrite")?t.panels.handleToggleConfig:void 0,pe=a.openConfigDialog;let ue;e[53]!==S?(ue=()=>S(!0),e[53]=S,e[54]=ue):ue=e[54];const je=s.currentCwd?s.onTogglePreview:void 0,Ne=ut("hostFiles")&&s.currentCwd?s.onToggleProjectFiles:void 0,Re=t.panels.handleToggleThemeSelector,Te=s.onOpenTerminal,Pe=o.onFocusComposer,Oe=o.onExpandAll,Fe=o.onExpandToolPayloads,ze=o.onCollapseAll,Be=!!(c||i.pendingDirName);let _e;e[55]!==y||e[56]!==(c==null?void 0:c.cwd)||e[57]!==(d==null?void 0:d.dirName)||e[58]!==i.dashboardProject||e[59]!==i.pendingDirName?(_e=ut("terminal")&&!!((c==null?void 0:c.cwd)??y??(d==null?void 0:d.dirName)??i.pendingDirName??i.dashboardProject),e[55]=y,e[56]=c==null?void 0:c.cwd,e[57]=d==null?void 0:d.dirName,e[58]=i.dashboardProject,e[59]=i.pendingDirName,e[60]=_e):_e=e[60];const He=!!c;let Ie;e[61]!==s.hasFileChanges?(Ie=ut("hostFiles")&&s.hasFileChanges,e[61]=s.hasFileChanges,e[62]=Ie):Ie=e[62];const Ce=i.mainView==="config",de=i.mainView==="mission",Ee=(c==null?void 0:c.cwd)??y??null;let Ae;e[63]!==o.commandPaletteOpen||e[64]!==o.onCollapseAll||e[65]!==o.onCommandPaletteOpenChange||e[66]!==o.onExpandAll||e[67]!==o.onExpandToolPayloads||e[68]!==o.onFocusComposer||e[69]!==a.openConfigDialog||e[70]!==j||e[71]!==t.actions.handleDashboardSelect||e[72]!==t.actions.handleGoHome||e[73]!==t.onOpenPaletteProject||e[74]!==t.panels.handleOpenProjectSwitcher||e[75]!==t.panels.handleToggleFileChanges||e[76]!==t.panels.handleToggleMission||e[77]!==t.panels.handleToggleSidebar||e[78]!==t.panels.handleToggleStats||e[79]!==t.panels.handleToggleThemeSelector||e[80]!==t.panels.handleToggleWorktrees||e[81]!==t.panels.showFileChanges||e[82]!==t.panels.showSidebar||e[83]!==t.panels.showStats||e[84]!==t.panels.showWorktrees||e[85]!==M||e[86]!==s.launchTerminalRequest||e[87]!==s.onOpenTerminal||e[88]!==s.processPanel.addProcess||e[89]!==s.showProjectFiles||e[90]!==s.supportsWorktrees||e[91]!==le||e[92]!==xe||e[93]!==ge||e[94]!==ce||e[95]!==we||e[96]!==ue||e[97]!==je||e[98]!==Ne||e[99]!==Be||e[100]!==_e||e[101]!==He||e[102]!==Ie||e[103]!==Ce||e[104]!==de||e[105]!==Ee?(Ae=r.jsx(b.Suspense,{fallback:null,children:r.jsx(eE,{open:Z,onOpenChange:Q,onGoHome:ee,onNewSession:oe,onOpenProject:se,onOpenSession:re,onToggleSidebar:ie,onToggleStats:ae,onToggleFileChanges:te,onToggleWorktrees:he,onToggleMissionControl:me,onDuplicateSession:le,onCopyResumeCommand:xe,onFindInConversation:ge,onKillAll:ce,onOpenConfig:we,onOpenSettings:pe,onOpenKeyboardShortcuts:ue,onTogglePreview:je,onToggleProjectFiles:Ne,onOpenTheme:Re,onOpenTerminal:Te,onOpenDevices:v?p:void 0,onSwitchDevice:ps,devices:M,onFocusComposer:Pe,onExpandAll:Oe,onExpandToolPayloads:Fe,onCollapseAll:ze,canFocusComposer:Be,canOpenTerminal:_e,hasSession:He,hasFileChanges:Ie,supportsWorktrees:s.supportsWorktrees,showSidebar:t.panels.showSidebar,showStats:t.panels.showStats,showProjectFiles:s.showProjectFiles,showFileChanges:t.panels.showFileChanges,showWorktrees:t.panels.showWorktrees,showConfig:Ce,showMission:de,currentProjectDirName:j,projectCwd:Ee,onProcessStarted:s.processPanel.addProcess,launchTerminalRequest:s.launchTerminalRequest})}),e[63]=o.commandPaletteOpen,e[64]=o.onCollapseAll,e[65]=o.onCommandPaletteOpenChange,e[66]=o.onExpandAll,e[67]=o.onExpandToolPayloads,e[68]=o.onFocusComposer,e[69]=a.openConfigDialog,e[70]=j,e[71]=t.actions.handleDashboardSelect,e[72]=t.actions.handleGoHome,e[73]=t.onOpenPaletteProject,e[74]=t.panels.handleOpenProjectSwitcher,e[75]=t.panels.handleToggleFileChanges,e[76]=t.panels.handleToggleMission,e[77]=t.panels.handleToggleSidebar,e[78]=t.panels.handleToggleStats,e[79]=t.panels.handleToggleThemeSelector,e[80]=t.panels.handleToggleWorktrees,e[81]=t.panels.showFileChanges,e[82]=t.panels.showSidebar,e[83]=t.panels.showStats,e[84]=t.panels.showWorktrees,e[85]=M,e[86]=s.launchTerminalRequest,e[87]=s.onOpenTerminal,e[88]=s.processPanel.addProcess,e[89]=s.showProjectFiles,e[90]=s.supportsWorktrees,e[91]=le,e[92]=xe,e[93]=ge,e[94]=ce,e[95]=we,e[96]=ue,e[97]=je,e[98]=Ne,e[99]=Be,e[100]=_e,e[101]=He,e[102]=Ie,e[103]=Ce,e[104]=de,e[105]=Ee,e[106]=Ae):Ae=e[106];let Le;e[107]!==o.keyboardShortcutsOpen||e[108]!==S?(Le=r.jsx(b.Suspense,{fallback:null,children:r.jsx(sE,{open:o.keyboardShortcutsOpen,onOpenChange:S})}),e[107]=o.keyboardShortcutsOpen,e[108]=S,e[109]=Le):Le=e[109];let ne;e[110]!==m||e[111]!==k?(ne=v&&k!==null&&r.jsx(b.Suspense,{fallback:null,children:r.jsx(nE,{open:m!==null,initialMode:k,onClose:()=>p(null),onCloseComplete:()=>g(null)})}),e[110]=m,e[111]=k,e[112]=ne):ne=e[112];let fe;return e[113]!==o.branchModal||e[114]!==o.processPanel||e[115]!==o.undoDialog||e[116]!==o.workflowsPanel||e[117]!==L||e[118]!==K||e[119]!==q||e[120]!==J||e[121]!==Ae||e[122]!==Le||e[123]!==ne?(fe=r.jsxs(r.Fragment,{children:[L,z,F,H,B,K,q,J,Ae,Le,ne]}),e[113]=o.branchModal,e[114]=o.processPanel,e[115]=o.undoDialog,e[116]=o.workflowsPanel,e[117]=L,e[118]=K,e[119]=q,e[120]=J,e[121]=Ae,e[122]=Le,e[123]=ne,e[124]=fe):fe=e[124],fe}function lE(){window.dispatchEvent(new Event(tc))}function gl(n){const e=U.c(10),{reason:t,children:s}=n;if(!t)return s;let o;e[0]!==t?(o=r.jsx("span",{className:"inline-flex",tabIndex:0,"aria-label":t}),e[0]=t,e[1]=o):o=e[1];let i;e[2]!==s||e[3]!==o?(i=r.jsx(Pt,{render:o,children:s}),e[2]=s,e[3]=o,e[4]=i):i=e[4];let a;e[5]!==t?(a=r.jsx(At,{children:t}),e[5]=t,e[6]=a):a=e[6];let l;return e[7]!==i||e[8]!==a?(l=r.jsxs(Et,{children:[i,a]}),e[7]=i,e[8]=a,e[9]=l):l=e[9],l}const cE="2.1.0",i0={version:cE},dE=i0.version,uE=19384,fE=443,mE=450,pE=typeof navigator<"u"&&/Mac|iPhone|iPad/i.test(navigator.platform||""),hE=`${pE?"⌘⇧":"Ctrl+Shift+"}1–9`,gE=new Set(["BAD_PASSWORD","PASSWORD_REQUIRED","USERNAME_REQUIRES_PASSWORD"]),xE=new Set(["ACCOUNT_DISABLED"]);function Fo(n){const e=n.trim(),t=/^https:\/\//i.test(e),s=e.replace(/^https?:\/\//i,"").replace(/\/.*$/,""),o=/^(.+):(\d+)$/.exec(s),i=o?o[1]:s,a=o?Number(o[2]):void 0;return t?{host:i,port:a,tls:!0}:{host:i,port:a}}function a0(n,e,t){if(n.ok){if(n.hello.edition==="team"&&n.hello.needsBootstrap===!0)return{tone:"info",text:"Reachable team server — create its first admin account before adding it here."};if(n.hello.edition!=="team"&&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}"`:"",o=n.hello.version?` (v${n.hello.version})`:"";return{tone:"ok",text:`Found Cogpit${s}${o}.`}}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 l0={ok:"text-success",warn:"text-warning",info:"text-info",error:"text-destructive"};function bE(n){const e=U.c(10),{tone:t}=n,s=l0[t];let o;e[0]!==s?(o=G("size-3.5 shrink-0",s),e[0]=s,e[1]=o):o=e[1];const i=o;if(t==="ok"){let l;return e[2]!==i?(l=r.jsx(Un,{"data-icon":"inline-start",className:i}),e[2]=i,e[3]=l):l=e[3],l}if(t==="warn"){let l;return e[4]!==i?(l=r.jsx(wn,{"data-icon":"inline-start",className:i}),e[4]=i,e[5]=l):l=e[5],l}if(t==="info"){let l;return e[6]!==i?(l=r.jsx(Qt,{"data-icon":"inline-start",className:i}),e[6]=i,e[7]=l):l=e[7],l}let a;return e[8]!==i?(a=r.jsx(zs,{"data-icon":"inline-start",className:i}),e[8]=i,e[9]=a):a=e[9],a}const vE={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"};function yE({device:n,hubVersion:e,onRename:t,onCredentials:s,onRemove:o,onTest:i}){const[a,l]=b.useState(!1),[c,d]=b.useState(n.name),[f,u]=b.useState(!1),[m,p]=b.useState(n.username??""),[h,g]=b.useState(""),[x,v]=b.useState(null),[w,y]=b.useState(!1),[j,k]=b.useState(null);b.useEffect(()=>{d(n.name)},[n.name]),b.useEffect(()=>{p(n.username??"")},[n.username]);const N=r0(n),C=N!==void 0&&N!==e,S=Z7(n)==="team";async function _(){const A=c.trim();if(!A||A===n.name){l(!1),d(n.name);return}k("rename"),await t(n.id,A),k(null),l(!1)}async function P(){const A=m.trim(),E=n.username??"",T=A!==E,M=h.length>0;if(!T&&!M){u(!1),g(""),v(null);return}if(n.auth==="none"&&!M){v("Enter a password when adding an account to an unauthenticated device.");return}const I={};T&&(I.username=A||null),M&&(I.password=h),k("credentials"),v(null);const R=await s(n.id,I);if(k(null),!R.ok){v(R.error);return}u(!1),g("")}return r.jsxs("div",{className:"rounded-lg border bg-card",children:[r.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2",children:[r.jsx("span",{"aria-label":`Status: ${n.runtime.authState}`,className:G("size-2 shrink-0 rounded-full",vE[n.runtime.authState])}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[a?r.jsx(Ot,{value:c,autoFocus:!0,"aria-label":`Rename ${n.name}`,onChange:A=>d(A.target.value),onKeyDown:A=>{A.key==="Enter"&&_(),A.key==="Escape"&&(l(!1),d(n.name))},onBlur:()=>void _(),className:"h-6 text-sm"}):r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"truncate text-sm text-foreground",children:n.name}),N&&r.jsxs("span",{className:G("shrink-0 font-mono text-xs",C?"text-warning":"text-muted-foreground"),title:C?`Device runs v${N}; hub runs v${e}`:void 0,children:["v",N,C&&" ≠ hub"]}),n.auth==="none"&&r.jsx(Me,{variant:"secondary",children:"Unauthenticated"})]}),r.jsxs("span",{className:"truncate font-mono text-xs text-muted-foreground",children:[n.tls?"https://":"",n.host,":",n.port]}),n.username?r.jsxs("span",{className:"truncate text-xs text-muted-foreground",title:n.username,children:["Team account: ",n.username]}):S?r.jsx("span",{className:"text-xs text-warning",children:"Team account not configured"}):null]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[r.jsx(X,{variant:"ghost",size:"icon-sm","aria-label":`Re-test ${n.name}`,disabled:j==="test",onClick:async()=>{k("test"),await i(n.id),k(null)},children:r.jsx(Qt,{"data-icon":"inline-start",className:G(j==="test"&&"animate-spin")})}),r.jsx(X,{variant:"ghost",size:"icon-sm","aria-label":`Edit account for ${n.name}`,onClick:()=>{u(A=>!A),p(n.username??""),g(""),v(null)},children:r.jsx(Rv,{"data-icon":"inline-start"})}),r.jsx(X,{variant:"ghost",size:"icon-sm","aria-label":`Rename ${n.name}`,onClick:()=>l(!0),children:r.jsx(Ls,{"data-icon":"inline-start"})}),r.jsxs($c,{open:w,onOpenChange:A=>{j!=="remove"&&y(A)},children:[r.jsx(PS,{render:r.jsx(X,{variant:"ghost",size:"icon-sm","aria-label":`Remove ${n.name}`,className:"text-destructive hover:bg-destructive/10 hover:text-destructive"}),children:r.jsx(Bi,{"data-icon":"inline-start"})}),r.jsxs(Oc,{size:"sm",children:[r.jsxs(Dc,{children:[r.jsxs(zc,{children:["Remove ",n.name,"?"]}),r.jsx(Fc,{children:"This device will disappear from Cogpit. You can add it again later."})]}),r.jsxs(Lc,{children:[r.jsx(Uc,{disabled:j==="remove",children:"Cancel"}),r.jsxs(Bc,{variant:"destructive",disabled:j==="remove",onClick:async()=>{k("remove");try{await o(n.id)}finally{k(null)}},children:[j==="remove"&&r.jsx(rt,{"data-icon":"inline-start",className:"animate-spin"}),"Remove device"]})]})]})]})]})]}),f&&r.jsxs("div",{className:"flex flex-col gap-3 border-t px-3 py-3",children:[r.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[r.jsxs(gt,{children:[r.jsxs(xt,{htmlFor:`device-username-${n.id}`,children:["Username ",r.jsx("span",{className:"text-muted-foreground/60",children:"(team devices)"})]}),r.jsx(Ot,{id:`device-username-${n.id}`,"aria-label":`Username for ${n.name}`,value:m,onChange:A=>p(A.target.value),placeholder:"Leave empty for password-only auth",autoComplete:"off",spellCheck:!1})]}),r.jsxs(gt,{children:[r.jsxs(xt,{htmlFor:`device-password-${n.id}`,children:["New password ",r.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),r.jsx(Ot,{id:`device-password-${n.id}`,"aria-label":`New password for ${n.name}`,type:"password",value:h,onChange:A=>g(A.target.value),placeholder:"Leave blank to keep the stored password",autoComplete:"new-password"})]})]}),n.username&&m.trim()===""&&r.jsx("p",{className:"text-xs text-warning",children:"Clearing the username switches this device back to password-only authentication."}),x&&r.jsx(us,{children:x}),r.jsxs("div",{className:"flex justify-end gap-1.5",children:[r.jsx(X,{variant:"outline",size:"sm",onClick:()=>{u(!1),p(n.username??""),g(""),v(null)},children:"Cancel"}),r.jsx(X,{size:"sm",disabled:j==="credentials",onClick:()=>void P(),children:j==="credentials"?r.jsx(rt,{"data-icon":"inline-start",className:"animate-spin"}):"Save account"})]})]})]})}function c0(n){var Xe,Je;const e=U.c(118),{open:t,initialMode:s,onClose:o,onCloseComplete:i}=n,{devices:a,refresh:l,probe:c,addDevice:d,updateDevice:f,removeDevice:u,testDevice:m}=ka(),[p,h]=b.useState(""),[g,x]=b.useState(""),[v,w]=b.useState(""),[y,j]=b.useState(""),[k,N]=b.useState(!1),[C,S]=b.useState(!1),[_,P]=b.useState(null),[A,E]=b.useState(!1),[T,M]=b.useState(null),I=b.useRef(null),R=b.useRef(0);let $,D;e[0]!==s||e[1]!==t?($=()=>{t&&(h(""),x(""),w(""),j(""),N(!1),S(!1),P(null),M(null),s==="add"&&requestAnimationFrame(()=>{var De;return(De=I.current)==null?void 0:De.focus()}))},D=[t,s],e[0]=s,e[1]=t,e[2]=$,e[3]=D):($=e[2],D=e[3]),b.useEffect($,D);let O;e[4]!==k||e[5]!==g||e[6]!==c?(O=async()=>{const{host:De,port:qe,tls:ot}=Fo(g);if(!De){P(null),S(!1);return}const lt=R.current=R.current+1;S(!0);const bt=await c(De,qe,k,ot);lt===R.current&&(P({...a0(bt,De,qe??(ot?fE:uE)),hello:bt.ok?bt.hello:void 0}),S(!1))},e[4]=k,e[5]=g,e[6]=c,e[7]=O):O=e[7];const L=O;let z,F;e[8]!==g||e[9]!==t||e[10]!==L?(z=()=>{if(!t)return;if(!Fo(g).host){P(null),S(!1);return}const De=window.setTimeout(()=>void L(),mE);return()=>window.clearTimeout(De)},F=[t,g,L],e[8]=g,e[9]=t,e[10]=L,e[11]=z,e[12]=F):(z=e[11],F=e[12]),b.useEffect(z,F);const H=((Xe=_==null?void 0:_.hello)==null?void 0:Xe.edition)==="team",B=H&&((Je=_==null?void 0:_.hello)==null?void 0:Je.needsBootstrap)===!0,W=H||!k;let K;e:{if(A){K=!1;break e}if(!Fo(g).host){K=!1;break e}if(C||!_){K=!1;break e}if(B){K=!1;break e}if(W&&!y){K=!1;break e}if(H&&!v.trim()){K=!1;break e}if((_==null?void 0:_.tone)==="error"){K=!1;break e}K=!0}const V=K;let Y;e[13]!==d||e[14]!==k||e[15]!==W||e[16]!==g||e[17]!==p||e[18]!==o||e[19]!==y||e[20]!==H||e[21]!==v?(Y=async function(){const{host:qe,port:ot,tls:lt}=Fo(g);if(!qe)return;E(!0),M(null);const bt=await d({name:p.trim()||void 0,host:qe,port:ot,tls:lt,username:H?v.trim():void 0,password:W&&y||void 0,allowLocalTunnel:k});if(E(!1),bt.ok){o(),ps(bt.device.id);return}M({field:xE.has(bt.code)?"username":gE.has(bt.code)?"password":"host",message:bt.error})},e[13]=d,e[14]=k,e[15]=W,e[16]=g,e[17]=p,e[18]=o,e[19]=y,e[20]=H,e[21]=v,e[22]=Y):Y=e[22];const q=Y;let J;e[23]!==f?(J=async(De,qe)=>{await f(De,{name:qe})},e[23]=f,e[24]=J):J=e[24];const Z=J;let Q;e[25]!==u?(Q=async De=>{await u(De)},e[25]=u,e[26]=Q):Q=e[26];const ee=Q;let oe;e[27]!==l||e[28]!==m?(oe=async De=>{await m(De),await l()},e[27]=l,e[28]=m,e[29]=oe):oe=e[29];const se=oe;let re;e[30]!==o?(re=De=>{De||o()},e[30]=o,e[31]=re):re=e[31];let ie;e[32]!==i?(ie=De=>{De||i==null||i()},e[32]=i,e[33]=ie):ie=e[33];let ae;e[34]===Symbol.for("react.memo_cache_sentinel")?(ae=r.jsxs(Ss,{children:[r.jsx(Xn,{children:"Devices"}),r.jsxs(Jn,{children:["Control another Cogpit device from here. The active device is chosen from the header switcher — ",hE," jumps between devices."]})]}),e[34]=ae):ae=e[34];let te;e[35]!==a||e[36]!==ee||e[37]!==Z||e[38]!==se||e[39]!==f?(te=a.length>0&&r.jsx("div",{className:"flex flex-col gap-2",children:a.map(De=>r.jsx(yE,{device:De,hubVersion:dE,onRename:Z,onCredentials:f,onRemove:ee,onTest:se},De.id))}),e[35]=a,e[36]=ee,e[37]=Z,e[38]=se,e[39]=f,e[40]=te):te=e[40];let he;e[41]===Symbol.for("react.memo_cache_sentinel")?(he=r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(_n,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),r.jsx("p",{className:"text-sm font-medium text-foreground",children:"Add a device"})]}),e[41]=he):he=e[41];const me=(T==null?void 0:T.field)==="host";let le,xe;e[42]===Symbol.for("react.memo_cache_sentinel")?(le=r.jsx(xt,{htmlFor:"device-host",children:"Host"}),xe=r.jsx(fo,{children:"Enter a local address or an HTTPS URL."}),e[42]=le,e[43]=xe):(le=e[42],xe=e[43]);let ge;e[44]===Symbol.for("react.memo_cache_sentinel")?(ge=De=>{R.current=R.current+1,x(De.target.value),w(""),P(null),M(null)},e[44]=ge):ge=e[44];let ce;e[45]!==L?(ce=()=>void L(),e[45]=L,e[46]=ce):ce=e[46];let we;e[47]!==g||e[48]!==ce?(we=r.jsx(Ot,{id:"device-host",ref:I,value:g,onChange:ge,onBlur:ce,placeholder:"192.168.1.42, my-mac.local:19384 or https://cogpit.example.com",spellCheck:!1,autoComplete:"off"}),e[47]=g,e[48]=ce,e[49]=we):we=e[49];let pe;e[50]!==C?(pe=C&&r.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[r.jsx(rt,{"data-icon":"inline-start",className:"size-3.5 animate-spin"})," Checking device…"]}),e[50]=C,e[51]=pe):pe=e[51];let ue;e[52]!==_||e[53]!==C?(ue=!C&&_&&r.jsxs("p",{role:"status",className:G("flex items-center gap-1.5 text-xs",l0[_.tone]),children:[r.jsx(bE,{tone:_.tone}),_.text]}),e[52]=_,e[53]=C,e[54]=ue):ue=e[54];let je;e[55]!==T?(je=(T==null?void 0:T.field)==="host"&&r.jsx(us,{children:T.message}),e[55]=T,e[56]=je):je=e[56];let Ne;e[57]!==me||e[58]!==we||e[59]!==pe||e[60]!==ue||e[61]!==je?(Ne=r.jsxs(gt,{"data-invalid":me,children:[le,xe,we,pe,ue,je]}),e[57]=me,e[58]=we,e[59]=pe,e[60]=ue,e[61]=je,e[62]=Ne):Ne=e[62];let Re;e[63]===Symbol.for("react.memo_cache_sentinel")?(Re=r.jsxs(xt,{htmlFor:"device-name",children:["Name ",r.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),e[63]=Re):Re=e[63];let Te;e[64]===Symbol.for("react.memo_cache_sentinel")?(Te=De=>h(De.target.value),e[64]=Te):Te=e[64];let Pe;e[65]!==p?(Pe=r.jsxs(gt,{children:[Re,r.jsx(Ot,{id:"device-name",value:p,onChange:Te,placeholder:"Defaults to the device's own name"})]}),e[65]=p,e[66]=Pe):Pe=e[66];let Oe;e[67]!==T||e[68]!==H||e[69]!==v?(Oe=H&&r.jsxs(gt,{"data-invalid":(T==null?void 0:T.field)==="username",children:[r.jsx(xt,{htmlFor:"device-username",children:"Username"}),r.jsx(Ot,{id:"device-username",value:v,onChange:De=>w(De.target.value),placeholder:"Team account username",autoComplete:"username",spellCheck:!1}),r.jsx(fo,{children:"Requests through this hub will act as this account on the team server."}),(T==null?void 0:T.field)==="username"&&r.jsx(us,{children:T.message})]}),e[67]=T,e[68]=H,e[69]=v,e[70]=Oe):Oe=e[70];let Fe;e[71]!==W||e[72]!==y||e[73]!==T||e[74]!==H?(Fe=W&&r.jsxs(gt,{"data-invalid":(T==null?void 0:T.field)==="password",children:[r.jsx(xt,{htmlFor:"device-password",children:"Password"}),r.jsx(Ot,{id:"device-password",type:"password",value:y,onChange:De=>j(De.target.value),placeholder:H?"Password for that team account":"Network access password for that device",autoComplete:H?"current-password":"off"}),(T==null?void 0:T.field)==="password"&&r.jsx(us,{children:T.message})]}),e[71]=W,e[72]=y,e[73]=T,e[74]=H,e[75]=Fe):Fe=e[75];let ze;e[76]!==Ne||e[77]!==Pe||e[78]!==Oe||e[79]!==Fe?(ze=r.jsxs(wo,{children:[Ne,Pe,Oe,Fe]}),e[76]=Ne,e[77]=Pe,e[78]=Oe,e[79]=Fe,e[80]=ze):ze=e[80];let Be;e[81]===Symbol.for("react.memo_cache_sentinel")?(Be=De=>{R.current=R.current+1,N(De===!0),P(null),M(null)},e[81]=Be):Be=e[81];let _e;e[82]!==k?(_e=r.jsx(bg,{id:"device-local-tunnel",name:"device-local-tunnel",checked:k,onCheckedChange:Be}),e[82]=k,e[83]=_e):_e=e[83];const He=H?"":" — no password";let Ie;e[84]!==He?(Ie=r.jsxs(xt,{htmlFor:"device-local-tunnel",children:["This is a local tunnel",He]}),e[84]=He,e[85]=Ie):Ie=e[85];let Ce;e[86]!==_e||e[87]!==Ie?(Ce=r.jsxs(gt,{orientation:"horizontal",children:[_e,Ie]}),e[86]=_e,e[87]=Ie,e[88]=Ce):Ce=e[88];let de;e[89]!==k||e[90]!==H?(de=k&&r.jsxs(Ct,{className:"border-warning/40 bg-warning/10 text-warning",children:[r.jsx(Mv,{}),r.jsx(_t,{className:"text-warning",children:H?r.jsx(r.Fragment,{children:"The loopback address is allowed because the tunnel is local; team account authentication still applies."}):r.jsxs(r.Fragment,{children:["Traffic to this device is forwarded ",r.jsx("strong",{children:"unauthenticated"}),". Only use this for an SSH tunnel or another already-secured local channel."]})})]}),e[89]=k,e[90]=H,e[91]=de):de=e[91];let Ee;e[92]!==o?(Ee=r.jsx(X,{variant:"outline",onClick:o,children:"Close"}),e[92]=o,e[93]=Ee):Ee=e[93];const Ae=!V;let Le;e[94]!==q?(Le=()=>void q(),e[94]=q,e[95]=Le):Le=e[95];let ne;e[96]!==A?(ne=A?r.jsxs(r.Fragment,{children:[r.jsx(rt,{"data-icon":"inline-start",className:"size-4 animate-spin"})," Adding…"]}):"Add device",e[96]=A,e[97]=ne):ne=e[97];let fe;e[98]!==Ae||e[99]!==Le||e[100]!==ne?(fe=r.jsx(X,{disabled:Ae,onClick:Le,children:ne}),e[98]=Ae,e[99]=Le,e[100]=ne,e[101]=fe):fe=e[101];let Se;e[102]!==Ee||e[103]!==fe?(Se=r.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[Ee,fe]}),e[102]=Ee,e[103]=fe,e[104]=Se):Se=e[104];let $e;e[105]!==ze||e[106]!==Ce||e[107]!==de||e[108]!==Se?($e=r.jsxs("div",{className:"flex flex-col gap-4 border-t pt-4",children:[he,ze,Ce,de,Se]}),e[105]=ze,e[106]=Ce,e[107]=de,e[108]=Se,e[109]=$e):$e=e[109];let Ue;e[110]!==te||e[111]!==$e?(Ue=r.jsxs(Yn,{className:"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-xl",children:[ae,te,$e]}),e[110]=te,e[111]=$e,e[112]=Ue):Ue=e[112];let We;return e[113]!==t||e[114]!==re||e[115]!==ie||e[116]!==Ue?(We=r.jsx(Gn,{open:t,onOpenChange:re,onOpenChangeComplete:ie,children:Ue}),e[113]=t,e[114]=re,e[115]=ie,e[116]=Ue,e[117]=We):We=e[117],We}const wE=Object.freeze(Object.defineProperty({__proto__:null,DevicesDialog:c0,parseHostPort:Fo,probeMessage:a0},Symbol.toStringTag,{value:"Module"})),Vm=i0.version,jE={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"},Gm={ok:"Reachable",unknown:"Not reachable","bad-password":"Password rejected"};function SE(n){const e=U.c(6),{state:t}=n,s=Gm[t],o=Gm[t],i=jE[t];let a;e[0]!==i?(a=G("size-2 shrink-0 rounded-full",i),e[0]=i,e[1]=a):a=e[1];let l;return e[2]!==s||e[3]!==o||e[4]!==a?(l=r.jsx("span",{"aria-label":s,title:o,className:a}),e[2]=s,e[3]=o,e[4]=a,e[5]=l):l=e[5],l}function Td(n){const e=U.c(50),{compact:t}=n,s=t===void 0?!1:t,{devices:o,activeDeviceId:i,activeDevice:a,refresh:l,testDevice:c}=ka(),[d,f]=b.useState(null),u=(a==null?void 0:a.name)??"This machine",m=i!==wt;let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=ut("manageDevices"),e[0]=p):p=e[0];const h=p;let g;e[1]!==o||e[2]!==l||e[3]!==c?(g=z=>{!z||o.length===0||Promise.all(o.map(F=>c(F.id).catch(NE))).then(()=>l())},e[1]=o,e[2]=l,e[3]=c,e[4]=g):g=e[4];const x=g;if(!s&&o.length===0&&!m)return null;const v=s?"sm":"xs",w=s&&"h-10";let y;e[5]!==w?(y=G("max-w-40 justify-start",w),e[5]=w,e[6]=y):y=e[6];let j;e[7]!==v||e[8]!==y?(j=r.jsx(X,{variant:"ghost",size:v,"aria-label":"Switch device",className:y}),e[7]=v,e[8]=y,e[9]=j):j=e[9];let k;e[10]!==m?(k=m?r.jsx(Vp,{"data-icon":"inline-start"}):r.jsx(Lu,{"data-icon":"inline-start"}),e[10]=m,e[11]=k):k=e[11];let N;e[12]!==u?(N=r.jsx("span",{className:"truncate",children:u}),e[12]=u,e[13]=N):N=e[13];let C;e[14]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(nt,{"data-icon":"inline-end",className:"opacity-60"}),e[14]=C):C=e[14];let S;e[15]!==j||e[16]!==k||e[17]!==N?(S=r.jsxs(Mn,{render:j,children:[k,N,C]}),e[15]=j,e[16]=k,e[17]=N,e[18]=S):S=e[18];let _;e[19]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(hs,{children:"Devices"}),e[19]=_):_=e[19];let P,A;e[20]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(Lu,{}),A=r.jsx("span",{className:"flex-1 truncate",children:"This machine"}),e[20]=P,e[21]=A):(P=e[20],A=e[21]);let E;e[22]!==m?(E=!m&&r.jsx(dt,{className:"ml-auto text-success"}),e[22]=m,e[23]=E):E=e[23];let T;e[24]!==E?(T=r.jsxs(ct,{onClick:kE,children:[P,A,E]}),e[24]=E,e[25]=T):T=e[25];let M;if(e[26]!==i||e[27]!==s||e[28]!==o){let z;e[30]!==i||e[31]!==s?(z=F=>{const H=r0(F),B=H!==void 0&&H!==Vm,W=F.id===i;return r.jsxs(ct,{onClick:()=>ps(F.id),className:G(s&&"min-h-10"),children:[r.jsx(SE,{state:F.runtime.authState}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[r.jsx("span",{className:"truncate",children:F.name}),B&&r.jsxs("span",{className:"shrink-0 font-mono text-xs text-warning",title:`Device runs v${H}; hub runs v${Vm}`,children:["v",H]})]}),r.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:[F.host,":",F.port,F.auth==="none"&&" · unauthenticated"]})]}),W&&r.jsx(dt,{className:"ml-auto text-success"})]},F.id)},e[30]=i,e[31]=s,e[32]=z):z=e[32],M=o.map(z),e[26]=i,e[27]=s,e[28]=o,e[29]=M}else M=e[29];let I;e[33]!==T||e[34]!==M?(I=r.jsxs(Bt,{children:[_,T,M]}),e[33]=T,e[34]=M,e[35]=I):I=e[35];let R;e[36]!==o.length?(R=h&&r.jsxs(r.Fragment,{children:[r.jsx(io,{}),r.jsxs(Bt,{children:[r.jsxs(ct,{onClick:()=>f("add"),children:[r.jsx(_n,{}),r.jsx("span",{children:"Add device…"})]}),o.length>0&&r.jsxs(ct,{onClick:()=>f("manage"),children:[r.jsx(vc,{}),r.jsx("span",{children:"Manage devices…"})]})]})]}),e[36]=o.length,e[37]=R):R=e[37];let $;e[38]!==I||e[39]!==R?($=r.jsxs(In,{align:"end",sideOffset:6,className:"w-64",children:[I,R]}),e[38]=I,e[39]=R,e[40]=$):$=e[40];let D;e[41]!==x||e[42]!==S||e[43]!==$?(D=r.jsxs(Rn,{onOpenChange:x,children:[S,$]}),e[41]=x,e[42]=S,e[43]=$,e[44]=D):D=e[44];let O;e[45]!==d?(O=h&&r.jsx(c0,{open:d!==null,initialMode:d??"manage",onClose:()=>f(null)}),e[45]=d,e[46]=O):O=e[46];let L;return e[47]!==D||e[48]!==O?(L=r.jsxs(r.Fragment,{children:[D,O]}),e[47]=D,e[48]=O,e[49]=L):L=e[49],L}function kE(){return ps(wt)}function NE(){return null}const CE=6e4;function _E(){const[n,e]=b.useState([]),[t,s]=b.useState(!1),o=b.useRef(!1),i=b.useCallback(async()=>{if(!o.current){o.current=!0;try{const l=await ye("/api/system-processes");if(l.ok){const c=await l.json();e((c.processes??[]).filter(d=>d.suspectedLeak))}}catch{}finally{o.current=!1}}},[]),a=b.useCallback(async l=>{if(l.length!==0){s(!0);try{await ye("/api/system-processes/kill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pids:l})}),await new Promise(c=>setTimeout(c,1e3)),await i()}catch{}finally{s(!1)}}},[i]);return b.useEffect(()=>{i();const l=window.setInterval(()=>{document.visibilityState==="visible"&&i()},CE);return()=>window.clearInterval(l)},[i]),{leaks:n,killing:t,killLeaks:a,refresh:i}}const TE=6e4;function EE(){const n=U.c(29),{leaks:e,killing:t,killLeaks:s,refresh:o}=_E(),[i,a]=b.useState(!1),l=e.length>0,c=e.reduce(RE,0);let d,f;if(n[0]!==l?(d=()=>{if(l){a(!0);return}const E=window.setTimeout(()=>a(!1),TE);return()=>window.clearTimeout(E)},f=[l],n[0]=l,n[1]=d,n[2]=f):(d=n[1],f=n[2]),b.useEffect(d,f),!l&&!i)return null;const u=Et,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]!==o?(h=()=>void(l?s(e.map(AE)):o()),n[3]=l,n[4]=s,n[5]=e,n[6]=o,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 v;n[10]!==t||n[11]!==m||n[12]!==p||n[13]!==h||n[14]!==x?(v=r.jsx(X,{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]=v):v=n[15];let w;n[16]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(Iv,{"data-icon":"inline-start"}),n[16]=w):w=n[16];const y=t?"…":e.length;let j;n[17]!==y?(j=r.jsx("span",{className:"tabular-nums",children:y}),n[17]=y,n[18]=j):j=n[18];let k;n[19]!==j||n[20]!==v?(k=r.jsxs(Pt,{render:v,children:[w,j]}),n[19]=j,n[20]=v,n[21]=k):k=n[21];const N=At,C="bottom",S="p-3",_=l?r.jsxs("div",{className:"flex min-w-56 flex-col gap-2",children:[r.jsxs("div",{className:"text-xs font-medium",children:["Leaked agent processes · ",c.toFixed(0),"% CPU"]}),e.slice(0,6).map(PE),e.length>6&&r.jsxs("div",{className:"text-xs text-muted-foreground",children:["+",e.length-6," more"]}),r.jsx(It,{}),r.jsxs("div",{className:"text-xs text-muted-foreground",children:["Click to kill ",e.length===1?"it":"all of them"]})]}):r.jsxs("div",{className:"flex min-w-48 flex-col gap-1",children:[r.jsx("div",{className:"text-xs font-medium",children:"Leak monitor"}),r.jsx("div",{className:"text-xs text-muted-foreground",children:"No leaked agent processes. Click to scan again."})]});let P;n[22]!==N||n[23]!==_?(P=r.jsx(N,{side:C,className:S,children:_}),n[22]=N,n[23]=_,n[24]=P):P=n[24];let A;return n[25]!==u||n[26]!==k||n[27]!==P?(A=r.jsxs(u,{children:[k,P]}),n[25]=u,n[26]=k,n[27]=P,n[28]=A):A=n[28],A}function PE(n){return r.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[r.jsxs("span",{className:"truncate text-muted-foreground",children:[n.label," · ",Ec(n.ageSeconds)]}),r.jsxs("span",{className:"shrink-0 font-semibold text-destructive",children:[n.cpuPercent.toFixed(0),"%"]})]},n.pid)}function AE(n){return n.pid}function RE(n,e){return n+e.cpuPercent}const ME=15e3;function IE(){const n=U.c(12);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],n[0]=e):e=n[0];const[t,s]=b.useState(e);let o;n[1]===Symbol.for("react.memo_cache_sentinel")?(o=async()=>{try{const v=await ye("/api/notifications?limit=100");if(!v.ok)return;const w=await v.json();Array.isArray(w.notifications)&&s(w.notifications)}catch{}},n[1]=o):o=n[1];const i=o;let a,l;n[2]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{i();const v=window.setInterval(()=>void i(),ME);return()=>window.clearInterval(v)},l=[i],n[2]=a,n[3]=l):(a=n[2],l=n[3]),b.useEffect(a,l);let c;n[4]===Symbol.for("react.memo_cache_sentinel")?(c=async(v,w)=>{const y=new Date().toISOString();s(j=>j.map(k=>k.readAt===null&&w(k)?{...k,readAt:y}:k));try{await ye("/api/notifications/read",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(v)})}catch{}},n[4]=c):c=n[4];const d=c;let f;n[5]===Symbol.for("react.memo_cache_sentinel")?(f=async v=>d({ids:v},w=>v.includes(w.id)),n[5]=f):f=n[5];const u=f;let m;n[6]===Symbol.for("react.memo_cache_sentinel")?(m=async()=>d({all:!0},OE),n[6]=m):m=n[6];const p=m;let h;n[7]!==t?(h=t.filter($E),n[7]=t,n[8]=h):h=n[8];const g=h.length;let x;return n[9]!==t||n[10]!==g?(x={notifications:t,unreadCount:g,refresh:i,markRead:u,markAllRead:p},n[9]=t,n[10]=g,n[11]=x):x=n[11],x}function $E(n){return n.readAt===null}function OE(){return!0}function d0(n){window.history.pushState({},"",n),window.dispatchEvent(new PopStateEvent("popstate"))}function DE(){const n=U.c(30),{notifications:e,unreadCount:t,refresh:s,markRead:o,markAllRead:i}=IE(),[a,l]=b.useState(!1);let c;n[0]!==o?(c=function(S){if(o([S.id]),!S.dirName||!S.sessionId)return;const _=ht(),P=_===wt?"":`/d/${_}`;d0(`${P}/${encodeURIComponent(S.dirName)}/${encodeURIComponent(S.sessionId)}`),l(!1)},n[0]=o,n[1]=c):c=n[1];const d=c;let f;n[2]!==s?(f=C=>{l(C),C&&s()},n[2]=s,n[3]=f):f=n[3];const u=a?"secondary":"ghost",m=t>0?`Notifications, ${t} unread`:"Notifications";let p;n[4]!==u||n[5]!==m?(p=r.jsx(X,{type:"button",variant:u,size:"icon-sm",className:"relative","aria-label":m}),n[4]=u,n[5]=m,n[6]=p):p=n[6];let h;n[7]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(zu,{"data-icon":"inline-start"}),n[7]=h):h=n[7];let g;n[8]!==t?(g=t>0&&r.jsx(Me,{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=r.jsxs(Mn,{render:p,children:[h,g]}),n[10]=p,n[11]=g,n[12]=x):x=n[12];let v;n[13]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx("span",{className:"text-sm font-medium",children:"Notifications"}),n[13]=v):v=n[13];let w;n[14]!==i||n[15]!==t?(w=t>0&&r.jsxs(X,{variant:"ghost",size:"xs",onClick:()=>void i(),children:[r.jsx($v,{"data-icon":"inline-start"}),"Mark all read"]}),n[14]=i,n[15]=t,n[16]=w):w=n[16];let y;n[17]!==w?(y=r.jsxs("div",{className:"flex h-11 items-center justify-between border-b px-3",children:[v,w]}),n[17]=w,n[18]=y):y=n[18];let j;n[19]!==e||n[20]!==d?(j=r.jsx("div",{className:"max-h-96 overflow-y-auto",children:e.length===0?r.jsx(Hn,{className:"min-h-40 p-6",children:r.jsxs(Kn,{children:[r.jsx(js,{variant:"icon",children:r.jsx(zu,{})}),r.jsx(qn,{children:"No notifications"}),r.jsx(Vn,{children:"Session updates will appear here."})]})}):r.jsx(Bt,{children:e.map(C=>r.jsx(LE,{notification:C,onOpen:d},C.id))})}),n[19]=e,n[20]=d,n[21]=j):j=n[21];let k;n[22]!==y||n[23]!==j?(k=r.jsxs(In,{align:"end",sideOffset:6,className:"w-80 overflow-hidden p-0",children:[y,j]}),n[22]=y,n[23]=j,n[24]=k):k=n[24];let N;return n[25]!==a||n[26]!==f||n[27]!==k||n[28]!==x?(N=r.jsxs(Rn,{open:a,onOpenChange:f,children:[x,k]}),n[25]=a,n[26]=f,n[27]=k,n[28]=x,n[29]=N):N=n[29],N}function LE(n){const e=U.c(38),{notification:t,onOpen:s}=n,o=t.readAt===null,i=!!(t.dirName&&t.sessionId),a=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,(a-l)/1e3),d=t.kind==="permission"?bn:Vi;let f;e[2]!==t||e[3]!==s?(f=()=>s(t),e[2]=t,e[3]=s,e[4]=f):f=e[4];const u=!i&&"cursor-default",m=o&&"bg-accent/50";let p;e[5]!==u||e[6]!==m?(p=G("rounded-none border-b px-3 py-2.5 last:border-b-0",u,m),e[5]=u,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]!==d||e[11]!==g?(x=r.jsx(d,{className:g}),e[10]=d,e[11]=g,e[12]=x):x=e[12];const v=o?"font-medium text-foreground":"text-muted-foreground";let w;e[13]!==v?(w=G("truncate text-xs",v),e[13]=v,e[14]=w):w=e[14];let y;e[15]!==t.title||e[16]!==w?(y=r.jsx("span",{className:w,children:t.title}),e[15]=t.title,e[16]=w,e[17]=y):y=e[17];let j;e[18]!==c?(j=Ec(c),e[18]=c,e[19]=j):j=e[19];let k;e[20]!==j?(k=r.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:j}),e[20]=j,e[21]=k):k=e[21];let N;e[22]!==y||e[23]!==k?(N=r.jsxs("span",{className:"flex items-baseline justify-between gap-2",children:[y,k]}),e[22]=y,e[23]=k,e[24]=N):N=e[24];let C;e[25]!==t.body?(C=r.jsx("span",{className:"mt-0.5 block truncate text-xs text-muted-foreground",children:t.body}),e[25]=t.body,e[26]=C):C=e[26];let S;e[27]!==N||e[28]!==C?(S=r.jsxs("span",{className:"min-w-0 flex-1",children:[N,C]}),e[27]=N,e[28]=C,e[29]=S):S=e[29];let _;e[30]!==o?(_=o&&r.jsx("span",{className:"mt-1.5 size-1.5 shrink-0 rounded-full bg-primary"}),e[30]=o,e[31]=_):_=e[31];let P;return e[32]!==S||e[33]!==_||e[34]!==f||e[35]!==p||e[36]!==x?(P=r.jsxs(ct,{onClick:f,className:p,children:[x,S,_]}),e[32]=S,e[33]=_,e[34]=f,e[35]=p,e[36]=x,e[37]=P):P=e[37],P}const zE=2e3;function xo(n){return`${n.toFixed(n<10?1:0)}%`}function Ai(n){return`${n.toFixed(0)} MB`}function FE(n){return n>=10?`${n.toFixed(0)}/s`:n>=1?`${n.toFixed(1)}/s`:`${n.toFixed(2)}/s`}function BE(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 UE(n){const e=U.c(44),{metric:t,onKill:s}=n;let o;e[0]!==t.label?(o=r.jsx("span",{className:"truncate text-sm font-medium",children:t.label}),e[0]=t.label,e[1]=o):o=e[1];let i;e[2]!==t.pid?(i=r.jsxs(Me,{variant:"outline",children:["PID ",t.pid]}),e[2]=t.pid,e[3]=i):i=e[3];let a;e[4]!==t.suspectedLeak?(a=t.suspectedLeak&&r.jsx(Me,{variant:"destructive",children:"possible leak"}),e[4]=t.suspectedLeak,e[5]=a):a=e[5];let l;e[6]!==t.orphaned||e[7]!==t.suspectedLeak?(l=t.orphaned&&!t.suspectedLeak&&r.jsx(Me,{variant:"secondary",children:"orphaned"}),e[6]=t.orphaned,e[7]=t.suspectedLeak,e[8]=l):l=e[8];let c;e[9]!==o||e[10]!==i||e[11]!==a||e[12]!==l?(c=r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o,i,a,l]}),e[9]=o,e[10]=i,e[11]=a,e[12]=l,e[13]=c):c=e[13];let d;e[14]!==t.command?(d=r.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]=d):d=e[15];let f;e[16]!==c||e[17]!==d?(f=r.jsxs("div",{className:"min-w-0 flex-1",children:[c,d]}),e[16]=c,e[17]=d,e[18]=f):f=e[18];let u;e[19]!==t.pid||e[20]!==t.suspectedLeak||e[21]!==s?(u=t.suspectedLeak&&s&&r.jsx(X,{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]=u):u=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=xo(t.cpuPercent),e[25]=t.cpuPercent,e[26]=h):h=e[26];let g;e[27]!==p||e[28]!==h?(g=r.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=Ai(t.memoryMb),e[30]=t.memoryMb,e[31]=x):x=e[31];let v;e[32]!==t.ageSeconds?(v=Ec(t.ageSeconds),e[32]=t.ageSeconds,e[33]=v):v=e[33];let w;e[34]!==x||e[35]!==v?(w=r.jsxs("div",{className:"text-xs text-muted-foreground",children:[x," · ",v]}),e[34]=x,e[35]=v,e[36]=w):w=e[36];let y;e[37]!==g||e[38]!==w?(y=r.jsxs("div",{className:"shrink-0 text-right",children:[g,w]}),e[37]=g,e[38]=w,e[39]=y):y=e[39];let j;return e[40]!==y||e[41]!==f||e[42]!==u?(j=r.jsxs("div",{className:"flex items-start gap-3 py-2.5",children:[f,u,y]}),e[40]=y,e[41]=f,e[42]=u,e[43]=j):j=e[43],j}function WE(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 HE(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 u0(n){const e=U.c(34),{metric:t}=n;let s;e[0]!==t.name?(s=r.jsx("span",{className:"truncate text-sm font-medium",children:t.name}),e[0]=t.name,e[1]=s):s=e[1];let o;e[2]!==t.pid?(o=t.pid>0&&r.jsxs(Me,{variant:"outline",children:["PID ",t.pid]}),e[2]=t.pid,e[3]=o):o=e[3];let i;e[4]!==s||e[5]!==o?(i=r.jsxs("div",{className:"flex items-center gap-2",children:[s,o]}),e[4]=s,e[5]=o,e[6]=i):i=e[6];let a;e[7]!==t?(a=WE(t),e[7]=t,e[8]=a):a=e[8];let l;e[9]!==a?(l=r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:a}),e[9]=a,e[10]=l):l=e[10];let c;e[11]!==i||e[12]!==l?(c=r.jsxs("div",{className:"min-w-0 flex-1",children:[i,l]}),e[11]=i,e[12]=l,e[13]=c):c=e[13];const d=t.cpuPercent>=50&&"text-destructive";let f;e[14]!==d?(f=G("font-mono text-sm font-semibold tabular-nums",d),e[14]=d,e[15]=f):f=e[15];let u;e[16]!==t.cpuPercent?(u=xo(t.cpuPercent),e[16]=t.cpuPercent,e[17]=u):u=e[17];let m;e[18]!==f||e[19]!==u?(m=r.jsx("div",{className:f,children:u}),e[18]=f,e[19]=u,e[20]=m):m=e[20];let p;e[21]!==t.memoryMb?(p=Ai(t.memoryMb),e[21]=t.memoryMb,e[22]=p):p=e[22];let h;e[23]!==p?(h=r.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&&r.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=r.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 v;return e[31]!==x||e[32]!==c?(v=r.jsxs("div",{className:"flex items-start gap-3 py-2.5",children:[c,x]}),e[31]=x,e[32]=c,e[33]=v):v=e[33],v}function Ym(n){const e=U.c(6),{metrics:t,emptyLabel:s}=n;let o,i;if(e[0]!==s||e[1]!==t){i=Symbol.for("react.early_return_sentinel");e:{const a=t.slice(0,8);if(a.length===0){let l;e[4]!==s?(l=r.jsx("p",{className:"py-3 text-sm text-muted-foreground",children:s}),e[4]=s,e[5]=l):l=e[5],i=l;break e}o=a.map(KE)}e[0]=s,e[1]=t,e[2]=o,e[3]=i}else o=e[2],i=e[3];return i!==Symbol.for("react.early_return_sentinel")?i:o}function KE(n,e){const t=BE(n.bytesPerSecond);return r.jsxs("div",{children:[e>0&&r.jsx(It,{}),r.jsxs("div",{className:"flex items-center gap-3 py-2.5",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"truncate text-sm",children:n.name}),r.jsxs("div",{className:"mt-0.5 flex flex-wrap gap-x-2 text-xs text-muted-foreground",children:[r.jsx("span",{children:FE(n.ratePerSecond)}),t&&r.jsx("span",{children:t}),n.averageDurationMs!==void 0&&r.jsxs("span",{children:[n.averageDurationMs.toFixed(0)," ms avg"]})]})]}),n.active!==void 0&&n.active>0&&r.jsxs(Me,{variant:"secondary",children:[n.active," open"]})]})]},n.name)}function qE(n){const e=U.c(8),{values:t}=n,s=Math.max(100,...t);let o;e[0]!==t?(o=t.map(VE).join(", "),e[0]=t,e[1]=o):o=e[1];const i=`Recent Cogpit CPU: ${o}`;let a;e[2]!==s||e[3]!==t?(a=t.length===0?r.jsx("span",{className:"self-center text-xs text-muted-foreground",children:"Collecting samples…"}):t.map((c,d)=>r.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:xo(c)},d)),e[2]=s,e[3]=t,e[4]=a):a=e[4];let l;return e[5]!==i||e[6]!==a?(l=r.jsx("div",{className:"flex h-14 items-end gap-1 rounded-md bg-muted/50 p-2",role:"img","aria-label":i,children:a}),e[5]=i,e[6]=a,e[7]=l):l=e[7],l}function VE(n){return xo(n)}function GE(n){var xe,ge,ce,we;const e=U.c(135),{open:t,onOpenChange:s}=n,[o,i]=b.useState(null),[a,l]=b.useState(null);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[0]=c):c=e[0];const[d,f]=b.useState(c),[u,m]=b.useState(null),[p,h]=b.useState(!1),g=b.useRef(!1),[x,v]=ho();let w;e[1]===Symbol.for("react.memo_cache_sentinel")?(w=async()=>{var Pe;if(g.current)return;g.current=!0,h(!0);const pe=ye("/api/performance").then(e8),ue=((Pe=window.electronPerformance)==null?void 0:Pe.getSnapshot())??Promise.resolve(null),[je,Ne]=await Promise.allSettled([pe,ue]),Re=je.status==="fulfilled"?je.value:null,Te=Ne.status==="fulfilled"?Ne.value:null;if(Re&&l(Re),Te&&i(Te),!Re&&!Te)m("Performance data is unavailable.");else{m(null);const Oe=Te&&Te.processes.length>0?Te.processes.reduce(ZE,0):(Re==null?void 0:Re.cpuPercent)??0;f(Fe=>[...Fe.slice(-29),Oe])}g.current=!1,h(!1)},e[1]=w):w=e[1];const y=w;let j,k;e[2]!==t?(j=()=>{if(!t)return;y();const pe=window.setInterval(()=>void y(),zE);return()=>window.clearInterval(pe)},k=[t,y],e[2]=t,e[3]=j,e[4]=k):(j=e[3],k=e[4]),b.useEffect(j,k);let N,C,S,_,P,A,E,T,M,I,R,$,D,O,L,z,F,H,B;if(e[5]!==x||e[6]!==v||e[7]!==o||e[8]!==u||e[9]!==d||e[10]!==s||e[11]!==t||e[12]!==p||e[13]!==a){const pe=[...(o==null?void 0:o.processes)??[]].sort(QE),ue=pe.length>0?pe.reduce(JE,0):(a==null?void 0:a.cpuPercent)??0,je=pe[0];let Ne;e[33]!==((xe=a==null?void 0:a.system)==null?void 0:xe.processes)?(Ne=((ge=a==null?void 0:a.system)==null?void 0:ge.processes)??[],e[33]=(ce=a==null?void 0:a.system)==null?void 0:ce.processes,e[34]=Ne):Ne=e[34],E=Ne;const Re=((we=a==null?void 0:a.system)==null?void 0:we.suspectedLeakCount)??0,Te=Re>0||ue>=80?"High":ue>=15?"Active":"Idle";let Pe;e[35]===Symbol.for("react.memo_cache_sentinel")?(Pe=async ot=>{try{await ye("/api/system-processes/kill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pids:[ot]})}),await new Promise(XE)}catch{}y()},e[35]=Pe):Pe=e[35],A=Pe;let Oe;e[36]!==v||e[37]!==o||e[38]!==d||e[39]!==a?(Oe=()=>{v(JSON.stringify({capturedAt:new Date().toISOString(),electron:o,server:a,cpuHistory:d},null,2))},e[36]=v,e[37]=o,e[38]=d,e[39]=a,e[40]=Oe):Oe=e[40];const Fe=Oe;P=Gn,D=t,O=s,_=Yn,I="h-[min(780px,calc(100vh-2rem))] gap-0 p-0 sm:max-w-3xl";let ze;e[41]===Symbol.for("react.memo_cache_sentinel")?(ze=r.jsx(Xn,{children:"Power & activity monitor"}),e[41]=ze):ze=e[41];const Be=Te==="High"?"destructive":"secondary";let _e;e[42]!==Te||e[43]!==Be?(_e=r.jsxs("div",{className:"flex items-center gap-2",children:[ze,r.jsx(Me,{variant:Be,children:Te})]}),e[42]=Te,e[43]=Be,e[44]=_e):_e=e[44];let He;e[45]===Symbol.for("react.memo_cache_sentinel")?(He=r.jsx(Jn,{className:"mt-1",children:"Live CPU, memory, and wakeups. Sampling runs only while this window is open."}),e[45]=He):He=e[45];let Ie;e[46]!==_e?(Ie=r.jsxs("div",{className:"min-w-0 flex-1",children:[_e,He]}),e[46]=_e,e[47]=Ie):Ie=e[47];let Ce;e[48]===Symbol.for("react.memo_cache_sentinel")?(Ce=()=>void y(),e[48]=Ce):Ce=e[48];const de=p&&"animate-spin";let Ee;e[49]!==de?(Ee=G(de),e[49]=de,e[50]=Ee):Ee=e[50];let Ae;e[51]!==Ee?(Ae=r.jsx(Qt,{"data-icon":"inline-start",className:Ee}),e[51]=Ee,e[52]=Ae):Ae=e[52];let Le;e[53]!==p||e[54]!==Ae?(Le=r.jsxs(X,{variant:"outline",size:"sm",onClick:Ce,disabled:p,children:[Ae,"Refresh"]}),e[53]=p,e[54]=Ae,e[55]=Le):Le=e[55];const ne=!a&&!o;let fe;e[56]!==x?(fe=x?r.jsx(dt,{"data-icon":"inline-start"}):r.jsx(En,{"data-icon":"inline-start"}),e[56]=x,e[57]=fe):fe=e[57];const Se=x?"Copied":"Copy data";let $e;e[58]!==Fe||e[59]!==ne||e[60]!==fe||e[61]!==Se?($e=r.jsxs(X,{variant:"outline",size:"sm",onClick:Fe,disabled:ne,children:[fe,Se]}),e[58]=Fe,e[59]=ne,e[60]=fe,e[61]=Se,e[62]=$e):$e=e[62];let Ue;e[63]!==Le||e[64]!==$e?(Ue=r.jsxs("div",{className:"flex shrink-0 gap-1",children:[Le,$e]}),e[63]=Le,e[64]=$e,e[65]=Ue):Ue=e[65],e[66]!==Ie||e[67]!==Ue?(R=r.jsx(Ss,{className:"p-5 pb-4",children:r.jsxs("div",{className:"flex items-start gap-3 pr-8",children:[Ie,Ue]})}),e[66]=Ie,e[67]=Ue,e[68]=R):R=e[68],e[69]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx(It,{}),e[69]=$):$=e[69],S=Nr,M="min-h-0 min-w-0 flex-1",H="flex flex-col gap-4 p-5",e[70]!==u?(B=u&&r.jsx(Ct,{variant:"destructive",children:r.jsx(_t,{children:u})}),e[70]=u,e[71]=B):B=e[71];let We;e[72]===Symbol.for("react.memo_cache_sentinel")?(We=r.jsx(nn,{children:"Current load"}),e[72]=We):We=e[72];const Xe=ue>=80&&"text-destructive";let Je;e[73]!==Xe?(Je=G("font-mono text-lg font-semibold tabular-nums",Xe),e[73]=Xe,e[74]=Je):Je=e[74];const De=r.jsxs(tn,{children:[We,r.jsx(sn,{children:HE(ue,je,Re)}),r.jsx(vg,{children:r.jsxs("span",{className:Je,children:[xo(ue)," CPU"]})})]});let qe;e[75]!==d?(qe=r.jsx(Jt,{children:r.jsx(qE,{values:d})}),e[75]=d,e[76]=qe):qe=e[76],e[77]!==De||e[78]!==qe?(T=r.jsxs(Xt,{size:"sm",children:[De,qe]}),e[77]=De,e[78]=qe,e[79]=T):T=e[79],C=Xt,z="sm",e[80]===Symbol.for("react.memo_cache_sentinel")?(F=r.jsxs(tn,{children:[r.jsx(nn,{children:"Processes"}),r.jsx(sn,{children:"Which part of Cogpit is consuming CPU and memory."})]}),e[80]=F):F=e[80],N=Jt,L=pe.length>0?pe.map(YE):a?r.jsx(u0,{metric:{pid:0,name:"Server",type:"Node",cpuPercent:a.cpuPercent,memoryMb:a.memory.rssMb}}):r.jsx("p",{className:"py-3 text-sm text-muted-foreground",children:"Collecting process data…"}),e[5]=x,e[6]=v,e[7]=o,e[8]=u,e[9]=d,e[10]=s,e[11]=t,e[12]=p,e[13]=a,e[14]=N,e[15]=C,e[16]=S,e[17]=_,e[18]=P,e[19]=A,e[20]=E,e[21]=T,e[22]=M,e[23]=I,e[24]=R,e[25]=$,e[26]=D,e[27]=O,e[28]=L,e[29]=z,e[30]=F,e[31]=H,e[32]=B}else N=e[14],C=e[15],S=e[16],_=e[17],P=e[18],A=e[19],E=e[20],T=e[21],M=e[22],I=e[23],R=e[24],$=e[25],D=e[26],O=e[27],L=e[28],z=e[29],F=e[30],H=e[31],B=e[32];let W;e[81]!==N||e[82]!==L?(W=r.jsx(N,{children:L}),e[81]=N,e[82]=L,e[83]=W):W=e[83];let K;e[84]!==C||e[85]!==W||e[86]!==z||e[87]!==F?(K=r.jsxs(C,{size:z,children:[F,W]}),e[84]=C,e[85]=W,e[86]=z,e[87]=F,e[88]=K):K=e[88];let V;e[89]!==A||e[90]!==E?(V=E.length>0&&r.jsxs(Xt,{size:"sm",children:[r.jsxs(tn,{children:[r.jsx(nn,{children:"Agent processes"}),r.jsx(sn,{children:"Claude sessions, browsers, and scripts running outside Cogpit."})]}),r.jsx(Jt,{children:E.map((pe,ue)=>r.jsxs("div",{children:[ue>0&&r.jsx(It,{}),r.jsx(UE,{metric:pe,onKill:je=>void A(je)})]},pe.pid))})]}),e[89]=A,e[90]=E,e[91]=V):V=e[91];let Y;e[92]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx(nn,{children:"Server activity"}),e[92]=Y):Y=e[92];const q=(a==null?void 0:a.sampleWindowSeconds)??10;let J;e[93]!==q?(J=r.jsxs(tn,{children:[Y,r.jsxs(sn,{children:["File checks, streams, and agent work over the last ",q," seconds."]})]}),e[93]=q,e[94]=J):J=e[94];let Z;e[95]!==(a==null?void 0:a.activities)?(Z=(a==null?void 0:a.activities)??[],e[95]=a==null?void 0:a.activities,e[96]=Z):Z=e[96];let Q;e[97]!==Z?(Q=r.jsx(Jt,{children:r.jsx(Ym,{metrics:Z,emptyLabel:"No watched-file or stream activity in this sample."})}),e[97]=Z,e[98]=Q):Q=e[98];let ee;e[99]!==J||e[100]!==Q?(ee=r.jsxs(Xt,{size:"sm",children:[J,Q]}),e[99]=J,e[100]=Q,e[101]=ee):ee=e[101];let oe;e[102]===Symbol.for("react.memo_cache_sentinel")?(oe=r.jsxs(tn,{children:[r.jsx(nn,{children:"API activity"}),r.jsx(sn,{children:"Requests ranked by recent frequency and time."})]}),e[102]=oe):oe=e[102];let se;e[103]!==(a==null?void 0:a.requests)?(se=(a==null?void 0:a.requests)??[],e[103]=a==null?void 0:a.requests,e[104]=se):se=e[104];let re;e[105]!==se?(re=r.jsxs(Xt,{size:"sm",children:[oe,r.jsx(Jt,{children:r.jsx(Ym,{metrics:se,emptyLabel:"No API requests in this sample."})})]}),e[105]=se,e[106]=re):re=e[106];let ie;e[107]!==ee||e[108]!==re?(ie=r.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[ee,re]}),e[107]=ee,e[108]=re,e[109]=ie):ie=e[109];let ae;e[110]!==a?(ae=a&&r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Server event loop ",xo(a.eventLoopPercent)," · heap ",Ai(a.memory.heapUsedMb)," · RSS ",Ai(a.memory.rssMb)]}),e[110]=a,e[111]=ae):ae=e[111];let te;e[112]!==T||e[113]!==K||e[114]!==V||e[115]!==ie||e[116]!==ae||e[117]!==H||e[118]!==B?(te=r.jsxs("div",{className:H,children:[B,T,K,V,ie,ae]}),e[112]=T,e[113]=K,e[114]=V,e[115]=ie,e[116]=ae,e[117]=H,e[118]=B,e[119]=te):te=e[119];let he;e[120]!==S||e[121]!==M||e[122]!==te?(he=r.jsx(S,{className:M,children:te}),e[120]=S,e[121]=M,e[122]=te,e[123]=he):he=e[123];let me;e[124]!==_||e[125]!==I||e[126]!==R||e[127]!==$||e[128]!==he?(me=r.jsxs(_,{className:I,children:[R,$,he]}),e[124]=_,e[125]=I,e[126]=R,e[127]=$,e[128]=he,e[129]=me):me=e[129];let le;return e[130]!==P||e[131]!==D||e[132]!==O||e[133]!==me?(le=r.jsx(P,{open:D,onOpenChange:O,children:me}),e[130]=P,e[131]=D,e[132]=O,e[133]=me,e[134]=le):le=e[134],le}function YE(n,e){return r.jsxs("div",{children:[e>0&&r.jsx(It,{}),r.jsx(u0,{metric:n})]},n.pid)}function XE(n){return setTimeout(n,1e3)}function JE(n,e){return n+e.cpuPercent}function QE(n,e){return e.cpuPercent-n.cpuPercent}function ZE(n,e){return n+e.cpuPercent}async function e8(n){if(!n.ok)throw new Error(`Server monitor returned ${n.status}`);return n.json()}function t8(n){return`${n.title??`Pull request #${n.number}`}
|
|
116
|
+
${n.repo}${n.isDraft?" · draft":""}`}function f0(n){return{href:n.url,target:"_blank",rel:"noreferrer",onClick:e=>e.stopPropagation(),"aria-label":`Pull request #${n.number}`,title:t8(n)}}function Na(n){const e=U.c(17),{pullRequests:t,max:s,compact:o,layout:i}=n,a=s===void 0?3:s,l=i===void 0?"chips":i;if(!(t!=null&&t.length))return null;if(l==="list"){let u;e[0]!==t?(u=t.map(s8),e[0]=t,e[1]=u):u=e[1];let m;return e[2]!==u?(m=r.jsx("div",{className:"flex flex-col gap-0.5",children:u}),e[2]=u,e[3]=m):m=e[3],m}let c,d;if(e[4]!==o||e[5]!==a||e[6]!==t){const u=t.slice(-a);if(e[9]!==a||e[10]!==t){const p=t.slice(0,-a);c=p.length>0&&r.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",title:p.map(n8).join(`
|
|
117
|
+
`),children:["+",p.length]}),e[9]=a,e[10]=t,e[11]=c}else c=e[11];let m;e[12]!==o?(m=p=>{const h=p.isDraft?Zp:eh;return r.jsxs(Me,{variant:p.isDraft?"outline":"secondary",render:r.jsx("a",{...f0(p)}),className:G("shrink-0",o&&"px-1"),children:[r.jsx(h,{"data-icon":"inline-start"}),"#",p.number]},p.url)},e[12]=o,e[13]=m):m=e[13],d=u.map(m),e[4]=o,e[5]=a,e[6]=t,e[7]=c,e[8]=d}else c=e[7],d=e[8];let f;return e[14]!==c||e[15]!==d?(f=r.jsxs(r.Fragment,{children:[c,d]}),e[14]=c,e[15]=d,e[16]=f):f=e[16],f}function n8(n){return`#${n.number} ${n.title??n.repo}`}function s8(n){const e=n.isDraft?Zp:eh;return r.jsxs("a",{...f0(n),className:"flex items-center gap-1 text-foreground hover:underline",children:[r.jsx(e,{className:"size-2.5 shrink-0"}),r.jsxs("span",{className:"shrink-0",children:["#",n.number]}),n.title&&r.jsx("span",{className:"truncate text-muted-foreground",children:n.title})]},n.url)}const o8=b.memo(function(e){const t=U.c(37),{session:s,sessionSource:o,isLive:i,pullRequests:a,copied:l,creatingSession:c,onCopyResume:d,onNewSession:f,onDuplicateSession:u,onOpenTerminal:m}=e;let p;if(t[0]!==o){const A=o?bs(o.fileName):null;p=A?xd(A.agentId):null,t[0]=o,t[1]=p}else p=t[1];const h=p;let g;t[2]!==s.turns?(g=s.turns.some(a8),t[2]=s.turns,t[3]=g):g=t[3];const x=g;let v;t[4]!==s.rawMessages||t[5]!==(o==null?void 0:o.dirName)?(v=uo(o==null?void 0:o.dirName).contextWindow?s.rawMessages:[],t[4]=s.rawMessages,t[5]=o==null?void 0:o.dirName,t[6]=v):v=t[6];const w=v;let y;t[7]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx("div",{className:G(Nn,"flex h-8 min-w-0 items-center gap-2 pl-1 pr-3")}),t[7]=y):y=t[7];let j;t[8]!==l||t[9]!==c||t[10]!==d||t[11]!==u||t[12]!==f||t[13]!==m||t[14]!==s||t[15]!==o?(j=o?r.jsx(i8,{session:s,sessionSource:o,copied:l,creatingSession:c,onCopyResume:d,onNewSession:f,onDuplicateSession:u,onOpenTerminal:m}):r.jsx("button",{type:"button",onClick:d,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]=d,t[11]=u,t[12]=f,t[13]=m,t[14]=s,t[15]=o,t[16]=j):j=t[16];let k;t[17]!==i?(k=i&&r.jsx(na,{"aria-label":"Session is live"}),t[17]=i,t[18]=k):k=t[18];let N;t[19]!==s.model?(N=s.model&&r.jsx("span",{className:"shrink-0 font-mono text-[11px] text-foreground/80",children:Zi(s.model)}),t[19]=s.model,t[20]=N):N=t[20];let C;t[21]!==w?(C=r.jsx(eg,{rawMessages:w}),t[21]=w,t[22]=C):C=t[22];let S;t[23]!==j||t[24]!==k||t[25]!==N||t[26]!==C?(S=r.jsxs(Pt,{delay:200,render:y,children:[j,k,N,C]}),t[23]=j,t[24]=k,t[25]=N,t[26]=C,t[27]=S):S=t[27];let _;t[28]!==a||t[29]!==w||t[30]!==s||t[31]!==h||t[32]!==x?(_=r.jsx(At,{role:"tooltip",side:"bottom",align:"start",sideOffset:6,className:"p-3",children:r.jsx(r8,{session:s,thinkingEnabled:x,subAgentLabel:h,pullRequests:a,rawMessages:w})}),t[28]=a,t[29]=w,t[30]=s,t[31]=h,t[32]=x,t[33]=_):_=t[33];let P;return t[34]!==_||t[35]!==S?(P=r.jsxs(Et,{children:[S,_]}),t[34]=_,t[35]=S,t[36]=P):P=t[36],P});function Js(n){const e=U.c(7),{label:t,children:s}=n;let o;e[0]!==t?(o=r.jsx("span",{className:"w-24 shrink-0 text-muted-foreground",children:t}),e[0]=t,e[1]=o):o=e[1];let i;e[2]!==s?(i=r.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:s}),e[2]=s,e[3]=i):i=e[3];let a;return e[4]!==o||e[5]!==i?(a=r.jsxs("div",{className:"flex gap-3",children:[o,i]}),e[4]=o,e[5]=i,e[6]=a):a=e[6],a}function r8(n){const e=U.c(33),{session:t,thinkingEnabled:s,subAgentLabel:o,pullRequests:i,rawMessages:a}=n;let l,c,d,f,u,m,p;if(e[0]!==i||e[1]!==a||e[2]!==t.branchedFrom||e[3]!==t.gitBranch||e[4]!==t.model||e[5]!==o||e[6]!==s){const g=Zh(a),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&&r.jsxs(Js,{label:"Model",children:[r.jsx("span",{children:Zi(t.model)}),s&&r.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?(d=t.gitBranch&&r.jsx(Js,{label:"Branch",children:r.jsx("span",{className:"truncate font-mono",children:t.gitBranch})}),e[17]=t.gitBranch,e[18]=d):d=e[18],e[19]!==i?(f=i.length>0&&r.jsx(Js,{label:"Pull requests",children:r.jsx(Na,{pullRequests:i})}),e[19]=i,e[20]=f):f=e[20],e[21]!==o?(u=o&&r.jsx(Js,{label:"Agent",children:o}),e[21]=o,e[22]=u):u=e[22],e[23]!==x?(m=x&&r.jsxs(Js,{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&&r.jsxs(Js,{label:"Context",children:[tt(Math.max(0,g.compactAt-g.used))," left before compact ·"," ",tt(g.used)," / ",tt(g.limit)]}),e[0]=i,e[1]=a,e[2]=t.branchedFrom,e[3]=t.gitBranch,e[4]=t.model,e[5]=o,e[6]=s,e[7]=l,e[8]=c,e[9]=d,e[10]=f,e[11]=u,e[12]=m,e[13]=p}else l=e[7],c=e[8],d=e[9],f=e[10],u=e[11],m=e[12],p=e[13];let h;return e[25]!==l||e[26]!==c||e[27]!==d||e[28]!==f||e[29]!==u||e[30]!==m||e[31]!==p?(h=r.jsxs("div",{className:l,children:[c,d,f,u,m,p]}),e[25]=l,e[26]=c,e[27]=d,e[28]=f,e[29]=u,e[30]=m,e[31]=p,e[32]=h):h=e[32],h}function i8(n){const e=U.c(54),{session:t,sessionSource:s,copied:o,creatingSession:i,onCopyResume:a,onNewSession:l,onDuplicateSession:c,onOpenTerminal:d}=n,{dispatch:f}=Rt(),u=!!(t.cwd||s.dirName);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=$s(),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?`${zn(t.cwd)} / ${g}`:g,e[4]=t.cwd,e[5]=g,e[6]=x):x=e[6];const v=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 y=w;let j;e[10]===Symbol.for("react.memo_cache_sentinel")?(j=!p||Kc(),e[10]=j):j=e[10];const k=j;let N;e[11]!==f||e[12]!==s.dirName?(N=function(){b.startTransition(()=>{f({type:"GO_HOME",isMobile:!1}),f({type:"SET_DASHBOARD_PROJECT",dirName:s.dirName})})},e[11]=f,e[12]=s.dirName,e[13]=N):N=e[13];const C=N,S=`Copy resume command for ${v}; open session actions with the context menu`;let _;e[14]!==a||e[15]!==S?(_=r.jsx("button",{type:"button",onClick:a,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":S,"aria-haspopup":"menu",title:"Click to copy resume command. Right-click for session actions."}),e[14]=a,e[15]=S,e[16]=_):_=e[16];let P;e[17]!==o||e[18]!==t.cwd||e[19]!==g?(P=o?r.jsxs("span",{className:"flex items-center gap-1.5 text-success",children:[r.jsx(dt,{className:"size-3"})," Copied"]}):r.jsxs(r.Fragment,{children:[t.cwd&&r.jsx("span",{className:"truncate text-muted-foreground",children:zn(t.cwd)}),t.cwd&&r.jsx("span",{className:"text-muted-foreground/50",children:"/"}),r.jsx("span",{className:"truncate",children:g})]}),e[17]=o,e[18]=t.cwd,e[19]=g,e[20]=P):P=e[20];let A;e[21]!==_||e[22]!==P?(A=r.jsx(xa,{render:_,children:P}),e[21]=_,e[22]=P,e[23]=A):A=e[23];let E;e[24]!==l||e[25]!==t.cwd||e[26]!==s.dirName?(E=()=>l(s.dirName,t.cwd),e[24]=l,e[25]=t.cwd,e[26]=s.dirName,e[27]=E):E=e[27];let T;e[28]!==i?(T=i?r.jsx(Ut,{className:"size-3.5"}):r.jsx(_n,{className:"size-3.5"}),e[28]=i,e[29]=T):T=e[29];let M;e[30]!==i||e[31]!==E||e[32]!==T?(M=r.jsxs(Yt,{disabled:i,onClick:E,children:[T,"New session in this project"]}),e[30]=i,e[31]=E,e[32]=T,e[33]=M):M=e[33];let I;e[34]!==c?(I=c&&r.jsxs(Yt,{onClick:c,children:[r.jsx(En,{className:"size-3.5"}),"Duplicate this session"]}),e[34]=c,e[35]=I):I=e[35];let R;e[36]!==u||e[37]!==y?(R=u&&(k||!p)&&r.jsxs(r.Fragment,{children:[r.jsx(lr,{}),k&&r.jsxs(Yt,{onClick:()=>Sg(y),children:[r.jsx(mr,{className:"size-3.5"}),"Open project in editor"]}),!p&&r.jsxs(Yt,{onClick:()=>kg(y),children:[r.jsx(th,{className:"size-3.5"}),"Reveal in file manager"]})]}),e[36]=u,e[37]=y,e[38]=R):R=e[38];let $;e[39]!==d?($=d&&!p&&ut("terminal")&&r.jsxs(Yt,{onClick:d,children:[r.jsx(yo,{className:"size-3.5"}),"Open terminal in project"]}),e[39]=d,e[40]=$):$=e[40];let D;e[41]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(lr,{}),e[41]=D):D=e[41];let O;e[42]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsx(Jo,{className:"size-3.5"}),e[42]=O):O=e[42];let L;e[43]!==C?(L=r.jsxs(Yt,{onClick:C,children:[O,"View all sessions in this project"]}),e[43]=C,e[44]=L):L=e[44];let z;e[45]!==M||e[46]!==I||e[47]!==R||e[48]!==$||e[49]!==L?(z=r.jsxs(ba,{className:"min-w-56",children:[M,I,R,$,D,L]}),e[45]=M,e[46]=I,e[47]=R,e[48]=$,e[49]=L,e[50]=z):z=e[50];let F;return e[51]!==A||e[52]!==z?(F=r.jsxs(ga,{children:[A,z]}),e[51]=A,e[52]=z,e[53]=F):F=e[53],F}function a8(n){return n.thinking.length>0}const sc="Could not reach the server";async function ni(n,e){try{return await ye(n,e)}catch{return null}}async function xl(n){const e=await(n==null?void 0:n.json().catch(()=>null)),t=e==null?void 0:e.error;return typeof t=="string"&&t.length>0?t:sc}function l8(){const n=U.c(15);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],n[0]=e):e=n[0];const[t,s]=b.useState(e),[o,i]=b.useState(null),a=b.useRef(!0);let l,c;n[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>(a.current=!0,()=>{a.current=!1}),c=[],n[1]=l,n[2]=c):(l=n[1],c=n[2]),b.useEffect(l,c);let d;n[3]===Symbol.for("react.memo_cache_sentinel")?(d=async()=>{const N=await ni("/api/shares");if(!(N!=null&&N.ok))return;const C=await N.json().catch(f8);a.current&&Array.isArray(C)&&s(C)},n[3]=d):d=n[3];const f=d;let u,m;n[4]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{f()},m=[f],n[4]=u,n[5]=m):(u=n[4],m=n[5]),b.useEffect(u,m);let p;n[6]===Symbol.for("react.memo_cache_sentinel")?(p=async N=>{i(null);const C=await ni("/api/shares",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:N})});if(!(C!=null&&C.ok))return a.current&&i(await xl(C)),null;const S=await C.json().catch(u8);if(!(S!=null&&S.passphrase)||!S.share)return a.current&&i(sc),null;const _=S.share;return a.current&&s(P=>[...P.filter(A=>A.sessionId!==_.sessionId),_]),S.passphrase},n[6]=p):p=n[6];const h=p;let g;n[7]===Symbol.for("react.memo_cache_sentinel")?(g=async N=>{i(null);const C=await ni(`/api/shares/${encodeURIComponent(N)}/regenerate`,{method:"POST"});if(!(C!=null&&C.ok))return a.current&&i(await xl(C)),null;const S=await C.json().catch(d8);return S!=null&&S.passphrase?(f(),S.passphrase):(a.current&&i(sc),null)},n[7]=g):g=n[7];const x=g;let v;n[8]===Symbol.for("react.memo_cache_sentinel")?(v=async N=>{i(null);const C=await ni(`/api/shares/${encodeURIComponent(N)}`,{method:"DELETE"});if(!(C!=null&&C.ok)){a.current&&i(await xl(C));return}a.current&&s(S=>S.filter(_=>_.sessionId!==N))},n[8]=v):v=n[8];const w=v;let y;n[9]!==t?(y=async()=>{const N=t.map(c8);for(const C of N)await w(C)},n[9]=t,n[10]=y):y=n[10];const j=y;let k;return n[11]!==o||n[12]!==j||n[13]!==t?(k={shares:t,error:o,refresh:f,create:h,regenerate:x,revoke:w,revokeAll:j},n[11]=o,n[12]=j,n[13]=t,n[14]=k):k=n[14],k}function c8(n){return n.sessionId}function d8(){return null}function u8(){return null}function f8(){return null}const m8=5e3,p8="••••";function h8(n){return n===0?"No guests connected":n===1?"1 guest connected":`${n} guests connected`}function g8({sessionId:n}){const{config:{networkAccessDisabled:e}}=Rt(),{shares:t,error:s,refresh:o,create:i,regenerate:a,revoke:l}=l8(),[c,d]=b.useState(!1),[f,u]=b.useState(null),[m,p]=b.useState(!1),[h,g]=ho(),[x,v]=ho(),w=t.find(N=>N.sessionId===n)??null,y=`${window.location.origin}${Lj(n)}`;b.useEffect(()=>u(null),[n]),b.useEffect(()=>{if(!c)return;o();const N=setInterval(()=>void o(),m8);return()=>clearInterval(N)},[c,o]);async function j(N){p(!0);try{await N()}finally{p(!1)}}const k=e&&r.jsx("p",{className:"text-xs text-muted-foreground",children:"Network access is off, so this link only works on this machine."});return r.jsxs(Rn,{open:c,onOpenChange:N=>{d(N),N||u(null)},children:[r.jsx(Mn,{render:r.jsx(X,{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:r.jsx(Ov,{"data-icon":"inline-start"})}),r.jsx(In,{align:"end",sideOffset:6,className:"w-80 p-3",children:w?r.jsxs("div",{className:"flex flex-col gap-2.5",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("code",{className:"min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 font-mono text-[11px]",children:y}),r.jsx(X,{variant:"ghost",size:"icon-xs","aria-label":"Copy link",onClick:()=>g(y),children:h?r.jsx(dt,{"data-icon":"inline-start"}):r.jsx(En,{"data-icon":"inline-start"})})]}),r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("code",{className:"min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 font-mono text-[11px]",children:f??p8}),r.jsx(X,{variant:"ghost",size:"icon-xs","aria-label":"Regenerate passphrase",disabled:m,onClick:()=>j(async()=>{u(await a(n))}),children:r.jsx(Qt,{"data-icon":"inline-start"})})]}),f?r.jsx(X,{variant:"secondary",size:"xs",onClick:()=>v(`${y}
|
|
118
|
+
Passphrase: ${f}`),children:x?"Copied":"Copy link & passphrase"}):r.jsx("p",{className:"text-xs text-muted-foreground",children:"The passphrase is only shown once. Regenerate to get a new one."}),k,s&&r.jsx("p",{className:"text-xs text-destructive",children:s}),r.jsxs("div",{className:"flex items-center justify-between gap-2 border-t pt-2",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:h8(w.guests)}),r.jsx(X,{variant:"ghost",size:"xs",className:"text-destructive hover:text-destructive",disabled:m,onClick:()=>j(async()=>{await l(n),u(null)}),children:"Stop sharing"})]})]}):r.jsxs("div",{className:"flex flex-col gap-2.5",children:[r.jsx("p",{className:"text-xs text-muted-foreground",children:"Anyone with the link and passphrase can read and join this session."}),k,s&&r.jsx("p",{className:"text-xs text-destructive",children:s}),r.jsx(X,{size:"xs",disabled:m,onClick:()=>j(async()=>{u(await i(n))}),children:"Enable sharing"})]})})]})}function Ed(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 at(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)?n:void 0}function gn(n){return typeof n=="number"&&Number.isFinite(n)?n:void 0}function fs(n){return typeof n=="string"?n:void 0}function ds(n){return n?Ed(gn(n.utilization),fs(n.resets_at)):void 0}function m0(n){if(n)return{isEnabled:!!n.is_enabled,monthlyLimit:gn(n.monthly_limit),usedCredits:gn(n.used_credits),utilization:gn(n.utilization)}}function x8(n){return{fiveHour:ds(at(n.five_hour)),sevenDay:ds(at(n.seven_day)),sevenDayOpus:ds(at(n.seven_day_opus)),sevenDaySonnet:ds(at(n.seven_day_sonnet)),extraUsage:m0(at(n.extra_usage)),subscriptionType:fs(n.subscriptionType)}}function b8(n){if(n.available!==!0)return null;const e=at(n.usage),t=at(e==null?void 0:e.rate_limits),s=at(n.account),o={fiveHour:ds(at(t==null?void 0:t.five_hour)),sevenDay:ds(at(t==null?void 0:t.seven_day)),sevenDayOpus:ds(at(t==null?void 0:t.seven_day_opus)),sevenDaySonnet:ds(at(t==null?void 0:t.seven_day_sonnet)),extraUsage:m0(at(t==null?void 0:t.extra_usage)),subscriptionType:fs(e==null?void 0:e.subscription_type)??fs(s==null?void 0:s.subscriptionType)};return o.fiveHour||o.sevenDay||o.extraUsage||o.subscriptionType?o:null}function v8(n){const e=gn(n);if(e!==void 0)return new Date(e<1e10?e*1e3:e).toISOString()}function y8(n,e){const t=gn(n);return t===void 0||t<=0?e:t%1440===0?`${t/1440}-day`:t%60===0?`${t/60}-hour`:`${t}-minute`}function Xm(n,e){if(n)return Ed(gn(n.usedPercent),v8(n.resetsAt),y8(n.windowDurationMins,e))}function w8(n){var d,f,u;if(n.available!==!0)return null;const e=at((d=at(n.rateLimits))==null?void 0:d.rateLimits),t=at((f=at(n.account))==null?void 0:f.account),s=at((u=at(n.usage))==null?void 0:u.summary),o=at(e==null?void 0:e.credits),i=Xm(at(e==null?void 0:e.primary),"Primary"),a=Xm(at(e==null?void 0:e.secondary),"Secondary"),l=s==null?void 0:s.lifetimeTokens,c=gn(l)??(typeof l=="string"&&Number.isSafeInteger(Number(l))?Number(l):void 0);return!i&&!a&&c===void 0?null:{fiveHour:i,sevenDay:a,subscriptionType:fs(e==null?void 0:e.planType)??fs(t==null?void 0:t.planType),lifetimeTokens:c,creditBalance:fs(o==null?void 0:o.balance),creditsUnlimited:(o==null?void 0:o.unlimited)===!0}}function Jm(n,e){if(!n)return;const t=gn(n.remainingPercentage),s=gn(n.usedRequests),o=gn(n.entitlementRequests);let i;return t!==void 0?i=100-t:n.isUnlimitedEntitlement===!0||o===-1?i=0:s!==void 0&&o!==void 0&&o>0&&(i=s/o*100),Ed(i,fs(n.resetDate),e)}function j8(n){var s;if(n.available!==!0)return null;const e=at((s=at(n.quota))==null?void 0:s.quotaSnapshots),t=Jm(at(e==null?void 0:e.chat),"Chat")??Jm(at(e==null?void 0:e.premium_interactions),"Premium interactions");return t?{fiveHour:t}:null}const S8={claude:{endpoint:"/api/claude/runtime",read:b8,legacy:{endpoint:"/api/usage",read:x8}},codex:{endpoint:"/api/codex/runtime",read:w8},copilot:{endpoint:"/api/copilot/runtime",read:j8}},k8=300*1e3;function N8(n=Fs){const e=vn("viewUsage"),[t,s]=b.useState(null),[o,i]=b.useState(!1),[a,l]=b.useState(!1),c=b.useRef(0),d=b.useRef(null),f=b.useCallback(async()=>{var h;if(!e)return;const u=++c.current;(h=d.current)==null||h.abort();const m=new AbortController;d.current=m;const p=()=>c.current===u&&!m.signal.aborted;i(!0);try{const g=S8[n];let x=await ye(g.endpoint,{signal:m.signal}),v=g.read;if(g.legacy&&!x.ok&&!m.signal.aborted&&(x=await ye(g.legacy.endpoint,{signal:m.signal}),v=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 y=v(w);l(y!==null),s(y?{...y,agentKind:n,fetchedAt:Date.now()}:null)}catch{}finally{p()&&(d.current=null,i(!1))}},[n,e]);return b.useEffect(()=>{var m;if(s(null),l(!1),!e){i(!1),c.current+=1,(m=d.current)==null||m.abort(),d.current=null;return}f();const u=setInterval(f,k8);return()=>{var p;clearInterval(u),c.current+=1,(p=d.current)==null||p.abort(),d.current=null}},[n,e,f]),{usage:e?t:null,loading:e&&o,available:e&&a,refresh:f}}function p0(n){return n>=90?"danger":n>=80?"warning":n>=60?"caution":"nominal"}const h0={nominal:"text-muted-foreground",caution:"text-warning",warning:"text-warning",danger:"text-destructive"};function C8(n){var d;const e=U.c(31),{usage:t}=n;let s,o,i;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 f=[];t.fiveHour&&f.push({label:t.fiveHour.label??"5-hour",pct:t.fiveHour.utilization,resetsAt:t.fiveHour.resetsAt}),t.sevenDay&&f.push({label:t.sevenDay.label??"7-day",pct:t.sevenDay.utilization,resetsAt:t.sevenDay.resetsAt}),t.sevenDayOpus&&f.push({label:"Opus",pct:t.sevenDayOpus.utilization,resetsAt:t.sevenDayOpus.resetsAt}),t.sevenDaySonnet&&f.push({label:"Sonnet",pct:t.sevenDaySonnet.utilization,resetsAt:t.sevenDaySonnet.resetsAt}),s="flex min-w-[200px] flex-col gap-2";let u;e[10]!==t.agentKind?(u=t.agentKind?Eh(t.agentKind):"Agent",e[10]=t.agentKind,e[11]=u):u=e[11];let m;e[12]!==u?(m=r.jsxs("span",{className:"text-xs font-medium uppercase tracking-wide",children:[u," usage"]}),e[12]=u,e[13]=m):m=e[13];let p;e[14]!==t.subscriptionType?(p=t.subscriptionType&&r.jsx(Me,{variant:"secondary",children:t.subscriptionType}),e[14]=t.subscriptionType,e[15]=p):p=e[15],e[16]!==m||e[17]!==p?(o=r.jsxs("div",{className:"flex items-center justify-between",children:[m,p]}),e[16]=m,e[17]=p,e[18]=o):o=e[18],i=f.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,v=p0(h.pct);return r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs",children:[r.jsx("span",{className:"text-muted-foreground",children:h.label}),r.jsxs("span",{className:G("font-semibold",h0[v]),children:[h.pct.toFixed(1),"%"]})]}),r.jsx(Mc,{value:Math.min(h.pct,100)}),x!=null&&r.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]=o,e[9]=i}else s=e[7],o=e[8],i=e[9];let a;e[19]!==t.extraUsage?(a=((d=t.extraUsage)==null?void 0:d.isEnabled)&&t.extraUsage.usedCredits!=null&&t.extraUsage.monthlyLimit!=null&&r.jsxs("div",{className:"flex flex-col gap-1 pt-1 text-xs text-muted-foreground",children:[r.jsx(It,{}),"Extra: $",t.extraUsage.usedCredits.toFixed(2)," / $",t.extraUsage.monthlyLimit.toFixed(2)]}),e[19]=t.extraUsage,e[20]=a):a=e[20];let l;e[21]!==t.creditBalance||e[22]!==t.creditsUnlimited||e[23]!==t.lifetimeTokens?(l=(t.lifetimeTokens!=null||t.creditBalance||t.creditsUnlimited)&&r.jsxs("div",{className:"flex flex-col gap-1 pt-1 text-xs text-muted-foreground",children:[r.jsx(It,{}),t.lifetimeTokens!=null&&r.jsxs("div",{children:["Lifetime: ",tt(t.lifetimeTokens)," tokens"]}),t.creditsUnlimited?r.jsx("div",{children:"Credits: Unlimited"}):t.creditBalance?r.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]!==o||e[27]!==i||e[28]!==a||e[29]!==l?(c=r.jsxs("div",{className:s,children:[o,i,a,l]}),e[25]=s,e[26]=o,e[27]=i,e[28]=a,e[29]=l,e[30]=c):c=e[30],c}function _8(n){var j,k;const e=U.c(22),{agentKind:t}=n,s=t===void 0?Fs:t,{usage:o,loading:i,available:a,refresh:l}=N8(s);if(!a||!o)return null;const c=((j=o.fiveHour)==null?void 0:j.utilization)??((k=o.sevenDay)==null?void 0:k.utilization);if(c==null)return null;let d;e[0]!==o.agentKind?(d=o.agentKind?Eh(o.agentKind):"agent",e[0]=o.agentKind,e[1]=d):d=e[1];const f=`Refresh ${d} usage`;let u;e[2]!==i||e[3]!==l||e[4]!==f?(u=r.jsx(X,{type:"button",variant:"ghost",size:"xs","aria-label":f,onClick:l,disabled:i,className:"mr-1 font-mono"}),e[2]=i,e[3]=l,e[4]=f,e[5]=u):u=e[5];const m=h0[p0(c)],p=i&&"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=r.jsxs("span",{className:h,children:[g,"%"]}),e[11]=h,e[12]=g,e[13]=x):x=e[13];let v;e[14]!==u||e[15]!==x?(v=r.jsx(Pt,{render:u,children:x}),e[14]=u,e[15]=x,e[16]=v):v=e[16];let w;e[17]!==o?(w=r.jsx(At,{side:"bottom",className:"p-3",children:r.jsx(C8,{usage:o})}),e[17]=o,e[18]=w):w=e[18];let y;return e[19]!==v||e[20]!==w?(y=r.jsxs(Et,{children:[v,w]}),e[19]=v,e[20]=w,e[21]=y):y=e[21],y}function T8(n,e){const t=U.c(11);let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s={summary:null,loading:!1,error:null},t[0]=s):s=t[0];const[o,i]=b.useState(s),[a,l]=b.useState(0);let c;t[1]!==n||t[2]!==e?(c=()=>{const p=new AbortController;i(P8);const h=Intl.DateTimeFormat().resolvedOptions().timeZone;return ye(`/api/usage-cost?days=${n}&tz=${encodeURIComponent(h)}`,{signal:p.signal}).then(async g=>{if(!g.ok)throw new Error(`Usage scan failed (${g.status})`);const x=await g.json();i({summary:x,loading:!1,error:null})}).catch(g=>{p.signal.aborted||i(x=>({...x,loading:!1,error:g instanceof Error?g.message:"Usage scan failed"}))}),()=>p.abort()},t[1]=n,t[2]=e,t[3]=c):c=t[3];let d;t[4]!==n||t[5]!==e||t[6]!==a?(d=[n,e,a],t[4]=n,t[5]=e,t[6]=a,t[7]=d):d=t[7],b.useEffect(c,d);let f;t[8]===Symbol.for("react.memo_cache_sentinel")?(f=()=>l(E8),t[8]=f):f=t[8];const u=f;let m;return t[9]!==o?(m={...o,refresh:u},t[9]=o,t[10]=m):m=t[10],m}function E8(n){return n+1}function P8(n){return{...n,loading:!0,error:null}}function A8(n){const e=n.trim().toLowerCase().replace(/\[[^\]]*\]$/,""),t=e.lastIndexOf("/");return t===-1?e:e.slice(t+1)}const R8=new Set(["<synthetic>","synthetic","opus","sonnet","haiku","fable"]);function M8(n,e){const t=A8(e);return t.length===0||R8.has(t)?null:n.get(t)??null}function I8(n,e,t,s){const o=M8(n,e);if(o===null)return{costUsd:0,costSource:"unpriced"};const i=Math.min(t.cacheCreation1hTokens,t.cacheCreationTokens);return{costUsd:t.uncachedInputTokens*o.inputCostPerToken+t.cachedInputTokens*o.cacheReadCostPerToken+(t.cacheCreationTokens-i)*o.cacheCreationCostPerToken+i*o.cacheCreation1hCostPerToken+t.outputTokens*o.outputCostPerToken,costSource:"modelPriced"}}function $8(n){return n.uncachedInputTokens+n.cachedInputTokens+n.cacheCreationTokens+n.outputTokens}function g0(n,e,t){if(!e)return 0;const{costUsd:s,costSource:o}=I8(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 o==="unpriced"?0:s}const O8=[{days:7,label:"7 days"},{days:30,label:"30 days"},{days:90,label:"90 days"}],Vo=Ph.map(n=>({key:n,label:An(n).displayName,color:ww(n)}));function D8(n,e){const t=[],o=Date.parse(`${e}T00:00:00Z`);for(let i=Date.parse(`${n}T00:00:00Z`);i<=o;i+=864e5)t.push(new Date(i).toISOString().slice(0,10));return t}function Qm(){return{claude:{costUsd:0,tokens:0},codex:{costUsd:0,tokens:0},copilot:{costUsd:0,tokens:0}}}function L8(n){const e=new Map;for(const o of D8(n.sinceDay,n.untilDay))e.set(o,{day:o,byProvider:Qm(),costUsd:0,tokens:0});const t=new Map,s={costUsd:0,tokens:0,cacheSavingsUsd:0,byProvider:Qm(),days:[],models:[]};for(const o of n.buckets){const i=$8(o.totals);s.costUsd+=o.costUsd,s.tokens+=i,s.cacheSavingsUsd+=o.cacheSavingsUsd,s.byProvider[o.provider].costUsd+=o.costUsd,s.byProvider[o.provider].tokens+=i;const a=e.get(o.day);a&&(a.byProvider[o.provider].costUsd+=o.costUsd,a.byProvider[o.provider].tokens+=i,a.costUsd+=o.costUsd,a.tokens+=i);const l=`${o.provider}:${o.model}`;let c=t.get(l);c||(c={provider:o.provider,model:o.model,costUsd:0,tokens:0,unpriced:!0},t.set(l,c)),c.costUsd+=o.costUsd,c.tokens+=i,o.costSource!=="unpriced"&&(c.unpriced=!1)}return s.days=[...e.values()],s.models=[...t.values()].sort((o,i)=>i.costUsd-o.costUsd||i.tokens-o.tokens),s}function Zm(n){const e=Date.parse(`${n}T00:00:00Z`);return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",timeZone:"UTC"}).format(e)}const bl=720,vl=180,z8=18;function F8(n){const e=U.c(41),{days:t,metric:s}=n,[o,i]=b.useState(null);let a;e[0]!==s?(a=C=>s==="cost"?C.costUsd:C.tokens,e[0]=s,e[1]=a):a=e[1];const l=a;let c;if(e[2]!==t||e[3]!==l){let C;e[5]!==l?(C=S=>l(S),e[5]=l,e[6]=C):C=e[6],c=Math.max(...t.map(C)),e[2]=t,e[3]=l,e[4]=c}else c=e[4];const d=c;if(d<=0){let C;return e[7]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx("div",{className:"flex h-32 items-center justify-center text-xs text-muted-foreground",children:"No activity in this window."}),e[7]=C):C=e[7],C}const f=vl-z8,u=bl/t.length,m=Math.max(2,Math.min(28,u-2)),p=o!==null?t[o]:null;let h;e[8]!==p||e[9]!==s||e[10]!==l?(h=p&&r.jsx("div",{className:"pointer-events-none absolute left-0 right-0 top-0 z-10 flex justify-center",children:r.jsxs("div",{className:"rounded-md border bg-popover px-2.5 py-1.5 text-xs text-popover-foreground shadow-xs",children:[r.jsx("span",{className:"font-medium",children:Zm(p.day)}),Vo.map(C=>{const{key:S,label:_,color:P}=C,A=p.byProvider[S];return l(A)<=0?null:r.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-muted-foreground",children:[r.jsx("span",{"aria-hidden":!0,className:"size-1.5 rounded-full",style:{backgroundColor:P}}),_,": ",s==="cost"?as(A.costUsd):tt(A.tokens)]},S)}),r.jsx("span",{className:"ml-2 font-medium",children:s==="cost"?as(p.costUsd):tt(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,v;e[12]===Symbol.for("react.memo_cache_sentinel")?(x=()=>i(null),v=r.jsx("line",{x1:0,y1:f,x2:bl,y2:f,stroke:"var(--border)",strokeWidth:1}),e[12]=x,e[13]=v):(x=e[12],v=e[13]);let w;if(e[14]!==m||e[15]!==t||e[16]!==o||e[17]!==d||e[18]!==u||e[19]!==l){let C;e[21]!==m||e[22]!==o||e[23]!==d||e[24]!==u||e[25]!==l?(C=(S,_)=>{const P=_*u+(u-m)/2;let A=f;const E=o===_;return r.jsxs("g",{onMouseEnter:()=>i(_),children:[r.jsx("rect",{x:_*u,y:0,width:u,height:f,fill:"transparent"}),E&&r.jsx("rect",{x:_*u,y:0,width:u,height:f,fill:"var(--foreground)",opacity:.05,rx:2}),Vo.map(T=>{const{key:M,color:I}=T,R=l(S.byProvider[M]);if(R<=0)return null;const $=R/d*(f-6);return A=A-$,r.jsx("rect",{x:P,y:A,width:m,height:Math.max(1,$-1.5),rx:1.5,fill:I,opacity:E?1:.85},M)})]},S.day)},e[21]=m,e[22]=o,e[23]=d,e[24]=u,e[25]=l,e[26]=C):C=e[26],w=t.map(C),e[14]=m,e[15]=t,e[16]=o,e[17]=d,e[18]=u,e[19]=l,e[20]=w}else w=e[20];let y;if(e[27]!==t||e[28]!==u){let C;e[30]!==t.length||e[31]!==u?(C=(S,_)=>_===0||_===t.length-1||t.length>10&&_%7===0&&_<t.length-3?r.jsx("text",{x:_*u+u/2,y:vl-4,textAnchor:"middle",className:"fill-muted-foreground text-[10px]",children:Zm(S.day)},S.day):null,e[30]=t.length,e[31]=u,e[32]=C):C=e[32],y=t.map(C),e[27]=t,e[28]=u,e[29]=y}else y=e[29];let j;e[33]!==g||e[34]!==w||e[35]!==y?(j=r.jsxs("svg",{viewBox:`0 0 ${bl} ${vl}`,className:"w-full",role:"img","aria-label":g,onMouseLeave:x,children:[v,w,y]}),e[33]=g,e[34]=w,e[35]=y,e[36]=j):j=e[36];let k;e[37]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx("div",{className:"mt-1 flex items-center gap-4",children:Vo.map(B8)}),e[37]=k):k=e[37];let N;return e[38]!==h||e[39]!==j?(N=r.jsxs("div",{className:"relative",children:[h,j,k]}),e[38]=h,e[39]=j,e[40]=N):N=e[40],N}function B8(n){const{key:e,label:t,color:s}=n;return r.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[r.jsx("span",{"aria-hidden":!0,className:"size-2 rounded-full",style:{backgroundColor:s}}),t]},e)}function yl(n){const e=U.c(7),{label:t,value:s}=n;let o;e[0]!==t?(o=r.jsx("span",{className:"text-xs text-muted-foreground",children:t}),e[0]=t,e[1]=o):o=e[1];let i;e[2]!==s?(i=r.jsx("span",{className:"text-sm font-medium text-foreground tabular-nums",children:s}),e[2]=s,e[3]=i):i=e[3];let a;return e[4]!==o||e[5]!==i?(a=r.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[o,i]}),e[4]=o,e[5]=i,e[6]=a):a=e[6],a}function U8(n){const e=U.c(68),{days:t}=n,{summary:s,loading:o,error:i,refresh:a}=T8(t,!0),[l,c]=b.useState("cost");let d;e[0]!==s?(d=s?L8(s):null,e[0]=s,e[1]=d):d=e[1];const f=d;if(i){let z;e[2]!==a?(z=r.jsx(X,{variant:"outline",size:"sm",onClick:a,children:"Retry"}),e[2]=a,e[3]=z):z=e[3];let F;return e[4]!==i||e[5]!==z?(F=r.jsxs("div",{className:"flex flex-col items-center gap-2 py-10 text-sm text-muted-foreground",children:[i,z]}),e[4]=i,e[5]=z,e[6]=F):F=e[6],F}if(!f||!s){let z;return e[7]===Symbol.for("react.memo_cache_sentinel")?(z=r.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-sm text-muted-foreground",children:[r.jsx(Ut,{className:"size-4"})," Scanning transcripts…"]}),e[7]=z):z=e[7],z}const u=o&&"opacity-60";let m;e[8]!==u?(m=G("flex flex-col gap-5",u),e[8]=u,e[9]=m):m=e[9];let p;e[10]!==f.costUsd||e[11]!==f.tokens||e[12]!==l?(p=l==="cost"?as(f.costUsd):tt(f.tokens),e[10]=f.costUsd,e[11]=f.tokens,e[12]=l,e[13]=p):p=e[13];let h;e[14]!==p?(h=r.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=r.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 v;e[19]!==h||e[20]!==x?(v=r.jsxs("div",{className:"flex flex-col gap-0.5",children:[h,x]}),e[19]=h,e[20]=x,e[21]=v):v=e[21];let w;e[22]===Symbol.for("react.memo_cache_sentinel")?(w=["cost","tokens"],e[22]=w):w=e[22];let y;e[23]!==l?(y=r.jsx("div",{className:"flex rounded-md border p-0.5",children:w.map(z=>r.jsx(X,{variant:l===z?"secondary":"ghost",size:"xs",onClick:()=>c(z),children:z==="cost"?"Cost":"Tokens"},z))}),e[23]=l,e[24]=y):y=e[24];let j;e[25]!==f.byProvider||e[26]!==l?(j=Vo.map(z=>{const{key:F,label:H}=z,B=f.byProvider[F];return B.costUsd===0&&B.tokens===0?null:r.jsxs("span",{className:"text-xs text-muted-foreground tabular-nums",children:[H,": ",l==="cost"?as(B.costUsd):tt(B.tokens)]},F)}),e[25]=f.byProvider,e[26]=l,e[27]=j):j=e[27];let k;e[28]!==y||e[29]!==j?(k=r.jsxs("div",{className:"flex flex-col items-end gap-1.5",children:[y,j]}),e[28]=y,e[29]=j,e[30]=k):k=e[30];let N;e[31]!==k||e[32]!==v?(N=r.jsxs("div",{className:"flex items-end justify-between gap-4",children:[v,k]}),e[31]=k,e[32]=v,e[33]=N):N=e[33];let C;e[34]!==f.days||e[35]!==l?(C=r.jsx(F8,{days:f.days,metric:l}),e[34]=f.days,e[35]=l,e[36]=C):C=e[36];let S;e[37]!==f.tokens?(S=tt(f.tokens),e[37]=f.tokens,e[38]=S):S=e[38];let _;e[39]!==S?(_=r.jsx(yl,{label:"Processed tokens",value:S}),e[39]=S,e[40]=_):_=e[40];let P;e[41]!==f.cacheSavingsUsd?(P=as(f.cacheSavingsUsd),e[41]=f.cacheSavingsUsd,e[42]=P):P=e[42];let A;e[43]!==P?(A=r.jsx(yl,{label:"Cache savings",value:P}),e[43]=P,e[44]=A):A=e[44];const E=String(s.scannedFiles);let T;e[45]!==E?(T=r.jsx(yl,{label:"Files scanned",value:E}),e[45]=E,e[46]=T):T=e[46];let M;e[47]!==_||e[48]!==A||e[49]!==T?(M=r.jsxs("div",{className:"grid grid-cols-3 gap-x-6 gap-y-3 border-t pt-3",children:[_,A,T]}),e[47]=_,e[48]=A,e[49]=T,e[50]=M):M=e[50];let I;e[51]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx("thead",{children:r.jsxs("tr",{className:"border-b text-left text-xs text-muted-foreground",children:[r.jsx("th",{className:"py-1.5 font-normal",children:"Model"}),r.jsx("th",{className:"py-1.5 text-right font-normal",children:"Cost"}),r.jsx("th",{className:"py-1.5 text-right font-normal",children:"Share"}),r.jsx("th",{className:"py-1.5 text-right font-normal",children:"Tokens"})]})}),e[51]=I):I=e[51];let R;if(e[52]!==f.costUsd||e[53]!==f.models){let z;e[55]!==f.costUsd?(z=F=>{var H;return r.jsxs("tr",{className:"border-b border-border/50",children:[r.jsx("td",{className:"max-w-56 truncate py-1.5 text-foreground",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx("span",{"aria-hidden":!0,className:"size-2 shrink-0 rounded-full",style:{backgroundColor:(H=Vo.find(B=>B.key===F.provider))==null?void 0:H.color}}),F.model]})}),r.jsx("td",{className:"py-1.5 text-right text-foreground tabular-nums",children:F.unpriced?"—":as(F.costUsd)}),r.jsx("td",{className:"py-1.5 text-right text-muted-foreground tabular-nums",children:f.costUsd>0&&!F.unpriced?`${(F.costUsd/f.costUsd*100).toFixed(1)}%`:"—"}),r.jsx("td",{className:"py-1.5 text-right text-muted-foreground tabular-nums",children:tt(F.tokens)})]},`${F.provider}:${F.model}`)},e[55]=f.costUsd,e[56]=z):z=e[56],R=f.models.map(z),e[52]=f.costUsd,e[53]=f.models,e[54]=R}else R=e[54];let $;e[57]!==R?($=r.jsxs("table",{className:"w-full text-sm",children:[I,r.jsx("tbody",{children:R})]}),e[57]=R,e[58]=$):$=e[58];const D=s.pricing.status==="unavailable"?" (rate table unavailable — costs incomplete)":"";let O;e[59]!==D?(O=r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Raw API-equivalent prices from LiteLLM rates",D," ","— not what a subscription bills."]}),e[59]=D,e[60]=O):O=e[60];let L;return e[61]!==N||e[62]!==C||e[63]!==M||e[64]!==$||e[65]!==O||e[66]!==m?(L=r.jsxs("div",{className:m,children:[N,C,M,$,O]}),e[61]=N,e[62]=C,e[63]=M,e[64]=$,e[65]=O,e[66]=m,e[67]=L):L=e[67],L}function W8(n){const e=U.c(15),{open:t,onOpenChange:s}=n,[o,i]=b.useState(30);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsxs("div",{children:[r.jsx(Xn,{children:"API usage"}),r.jsx(Jn,{children:"What this machine's agent usage would cost at raw API prices."})]}),e[0]=a):a=e[0];let l;e[1]!==o?(l=O8.map(m=>r.jsx(X,{variant:o===m.days?"secondary":"ghost",size:"xs",onClick:()=>i(m.days),children:m.label},m.days)),e[1]=o,e[2]=l):l=e[2];let c;e[3]!==l?(c=r.jsx(Ss,{children:r.jsxs("div",{className:"flex items-center justify-between gap-4 pr-6",children:[a,r.jsx("div",{className:"flex rounded-md border p-0.5",children:l})]})}),e[3]=l,e[4]=c):c=e[4];let d;e[5]!==o||e[6]!==t?(d=t&&r.jsx(U8,{days:o}),e[5]=o,e[6]=t,e[7]=d):d=e[7];let f;e[8]!==c||e[9]!==d?(f=r.jsxs(Yn,{className:"max-h-[85vh] overflow-y-auto sm:max-w-3xl",children:[c,d]}),e[8]=c,e[9]=d,e[10]=f):f=e[10];let u;return e[11]!==s||e[12]!==t||e[13]!==f?(u=r.jsx(Gn,{open:t,onOpenChange:s,children:f}),e[11]=s,e[12]=t,e[13]=f,e[14]=u):u=e[14],u}const H8=/https:\/\/github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/,K8=/(?:^|[\n;&|(`])[ \t]*(?:[A-Za-z_]\w*=\S*[ \t]+)*gh[ \t]+pr[ \t]+create\b/,wl=String.raw`(?:--title|(?:^|\s)-t)(?:=|\s+)`,q8=[new RegExp(`${wl}"((?:[^"\\\\]|\\\\.)*)"`),new RegExp(`${wl}'([^']*)'`),new RegExp(`${wl}(\\S+)`)];function V8(n){const e=n.command??n.cmd;if(typeof e=="string")return[e];if(Array.isArray(e)){const a=e.filter(l=>typeof l=="string");return[a.join(" "),...a]}const t=n.source;if(typeof t!="string")return[];const s=[],o=/(?:["'](?:cmd|command)["']|\b(?:cmd|command))\s*:\s*"((?:\\.|[^"\\])*)"/g;for(const a of t.matchAll(o))try{s.push(JSON.parse(`"${a[1]}"`))}catch{}const i=/(?:["'](?:cmd|command)["']|\b(?:cmd|command))\s*:\s*`([^`]*)`/g;for(const a of t.matchAll(i))s.push(a[1]);return s}function G8(n){return V8(n).find(e=>K8.test(e))??null}function Y8(n){for(const e of q8){const t=e.exec(n);if(t)return t[1].replace(/\\(.)/g,"$1")}return null}function X8(){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,o,i,a){const l=H8.exec(s);l&&t({url:l[0],number:Number(l[3]),repo:`${l[1]}/${l[2]}`,title:Y8(o),isDraft:/(?:^|\s)--draft(?:\s|$)/.test(o),toolCallId:i,timestamp:a})}}}function J8(n){const e=X8();for(const t of n)for(const s of t.toolCalls){if(s.isError||!s.result)continue;const o=G8(s.input);o&&e.record(s.result,o,s.id,s.timestamp)}return e.pullRequests}function Q8(...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 Qs="flex h-8 items-center px-0.5",Z8=b.memo(function(e){var $t;const t=U.c(124),{showSidebar:s,sidebarRendered:o,sidebarShortcut:i,showStats:a,showWorktrees:l,showFileChanges:c,hasFileChanges:d,killing:f,creatingSession:u,onNewSession:m,onDuplicateSession:p,onOpenTerminal:h,onBackToMain:g,onShowWorkflows:x,workflowCount:v,onToggleSidebar:w,onToggleStats:y,onToggleWorktrees:j,onToggleFileChanges:k,onKillAll:N,onOpenSettings:C,showConfig:S,onToggleConfig:_,showMission:P,onToggleMission:A}=e,E=o===void 0?s:o,{config:T}=Rt(),{networkUrl:M,defaultAgentKind:I}=T,{session:R,sessionSource:$,isLive:D}=it(),O=pd(),L=vn("viewUsage"),[z,F]=b.useState(!1),[H,B]=b.useState(!1),[W,K]=ho(),V=R==null?void 0:R.turns;let Y;t[0]!==(O==null?void 0:O.sessions)||t[1]!==(R==null?void 0:R.sessionId)?(Y=($t=O==null?void 0:O.sessions.find(Vt=>Vt.sessionId===(R==null?void 0:R.sessionId)))==null?void 0:$t.pullRequests,t[0]=O==null?void 0:O.sessions,t[1]=R==null?void 0:R.sessionId,t[2]=Y):Y=t[2];const q=Y;let J;t[3]!==q||t[4]!==V?(J=Q8(J8(V??[]),q),t[3]=q,t[4]=V,t[5]=J):J=t[5];const Z=J;let Q;t[6]!==I||t[7]!==$?(Q=$?$.agentKind??St($.dirName):I,t[6]=I,t[7]=$,t[8]=Q):Q=t[8];const ee=Q;let oe;t[9]!==$?(oe=$?bs($.fileName)!==null:!1,t[9]=$,t[10]=oe):oe=t[10];const se=oe;let re;t[11]!==K||t[12]!==R||t[13]!==($==null?void 0:$.agentKind)||t[14]!==($==null?void 0:$.dirName)?(re=function(){if(!R)return;const Wt=($==null?void 0:$.agentKind)??St(($==null?void 0:$.dirName)??null);K(mh(Wt,R.sessionId,R.cwd))},t[11]=K,t[12]=R,t[13]=$==null?void 0:$.agentKind,t[14]=$==null?void 0:$.dirName,t[15]=re):re=t[15];const ie=re;let ae;t[16]!==M?(ae=function(){M&&br(M).then(t9)},t[16]=M,t[17]=ae):ae=t[17];const te=ae;let he,me;t[18]===Symbol.for("react.memo_cache_sentinel")?(me=r.jsx("div",{"aria-hidden":!0,className:"drag-strip absolute inset-x-0 top-0 z-10 h-10"}),he=r.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]=he,t[19]=me):(he=t[18],me=t[19]);const le=!E&&"window-inset-start";let xe;t[20]!==le?(xe=G("electron-no-drag pointer-events-auto flex min-w-0 items-center gap-1.5",le),t[20]=le,t[21]=xe):xe=t[21];let ge;t[22]!==w||t[23]!==s||t[24]!==i?(ge=!s&&r.jsx(e9,{icon:Lv,label:`Show sidebar (${i})`,onClick:w}),t[22]=w,t[23]=s,t[24]=i,t[25]=ge):ge=t[25];let ce;t[26]!==se||t[27]!==g||t[28]!==R?(ce=R&&se&&g&&r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:g,className:G(Nn,"h-8 shrink-0 px-2.5 text-xs text-muted-foreground"),children:[r.jsx(Ze,{className:"size-3 rotate-180"}),"Main"]}),t[26]=se,t[27]=g,t[28]=R,t[29]=ce):ce=t[29];let we;t[30]!==W||t[31]!==u||t[32]!==ie||t[33]!==D||t[34]!==p||t[35]!==m||t[36]!==h||t[37]!==Z||t[38]!==R||t[39]!==$?(we=R&&r.jsx(o8,{session:R,sessionSource:$,isLive:D,pullRequests:Z,copied:W,creatingSession:u,onCopyResume:ie,onNewSession:m,onDuplicateSession:p,onOpenTerminal:h}),t[30]=W,t[31]=u,t[32]=ie,t[33]=D,t[34]=p,t[35]=m,t[36]=h,t[37]=Z,t[38]=R,t[39]=$,t[40]=we):we=t[40];let pe;t[41]!==x||t[42]!==R||t[43]!==v?(pe=R&&x&&(v??0)>0&&r.jsxs(X,{variant:"ghost",size:"xs",className:G(Nn,"h-8 shrink-0 gap-1 px-2.5 text-[11px] text-muted-foreground hover:text-foreground"),onClick:x,children:[r.jsx(nh,{className:"size-3"}),"Workflows",r.jsx(Me,{variant:"outline",className:"h-4 min-w-4 justify-center px-1 text-[9px] font-semibold",children:v})]}),t[41]=x,t[42]=R,t[43]=v,t[44]=pe):pe=t[44];let ue;t[45]!==xe||t[46]!==ge||t[47]!==ce||t[48]!==we||t[49]!==pe?(ue=r.jsxs("div",{className:xe,children:[ge,ce,we,pe]}),t[45]=xe,t[46]=ge,t[47]=ce,t[48]=we,t[49]=pe,t[50]=ue):ue=t[50];let je,Ne,Re;t[51]===Symbol.for("react.memo_cache_sentinel")?(je=r.jsx("div",{className:G(Nn,Qs,"empty:hidden"),children:r.jsx(EE,{})}),Ne=r.jsx("div",{className:G(Nn,Qs,"empty:hidden"),children:r.jsx(DE,{})}),Re=G(Nn,Qs,"empty:hidden"),t[51]=je,t[52]=Ne,t[53]=Re):(je=t[51],Ne=t[52],Re=t[53]);let Te;t[54]!==ee?(Te=r.jsx("div",{className:Re,children:r.jsx(_8,{agentKind:ee})}),t[54]=ee,t[55]=Te):Te=t[55];let Pe;t[56]===Symbol.for("react.memo_cache_sentinel")?(Pe=r.jsx("div",{className:G(Nn,Qs,"empty:hidden"),children:r.jsx(Td,{})}),t[56]=Pe):Pe=t[56];let Oe;t[57]!==ee||t[58]!==R?(Oe=R&&zt(ee).sharing&&ut("share")&&r.jsx("div",{className:G(Nn,Qs),children:r.jsx(g8,{sessionId:R.sessionId})}),t[57]=ee,t[58]=R,t[59]=Oe):Oe=t[59];let Fe;t[60]===Symbol.for("react.memo_cache_sentinel")?(Fe=G(Nn,Qs),t[60]=Fe):Fe=t[60];let ze;t[61]===Symbol.for("react.memo_cache_sentinel")?(ze=r.jsx(Mn,{render:r.jsx(X,{variant:"ghost",size:"icon-sm","aria-label":"More actions"}),children:r.jsx(sh,{"data-icon":"inline-start"})}),t[61]=ze):ze=t[61];let Be;t[62]===Symbol.for("react.memo_cache_sentinel")?(Be=r.jsx(hs,{children:"Workspace"}),t[62]=Be):Be=t[62];let _e;t[63]!==A||t[64]!==P?(_e=A&&r.jsxs(ct,{onClick:A,children:[r.jsx(zv,{}),"Mission Control",P&&r.jsx(dt,{className:"ml-auto"})]}),t[63]=A,t[64]=P,t[65]=_e):_e=t[65];let He;t[66]!==_||t[67]!==S?(He=_&&r.jsxs(ct,{onClick:_,children:[r.jsx(Fv,{}),"Config",S&&r.jsx(dt,{className:"ml-auto"})]}),t[66]=_,t[67]=S,t[68]=He):He=t[68];let Ie;t[69]!==j||t[70]!==l?(Ie=j&&r.jsxs(ct,{onClick:j,children:[r.jsx(bo,{}),"Worktrees",l&&r.jsx(dt,{className:"ml-auto"})]}),t[69]=j,t[70]=l,t[71]=Ie):Ie=t[71];let Ce;t[72]!==d||t[73]!==k||t[74]!==c?(Ce=d&&k&&r.jsxs(ct,{onClick:k,children:[r.jsx(gr,{}),"File changes",c&&r.jsx(dt,{className:"ml-auto"})]}),t[72]=d,t[73]=k,t[74]=c,t[75]=Ce):Ce=t[75];let de;t[76]!==y||t[77]!==R||t[78]!==a?(de=R&&r.jsxs(ct,{onClick:y,children:[a?r.jsx(Bv,{}):r.jsx(Uv,{}),"Session details",a&&r.jsx(dt,{className:"ml-auto"})]}),t[76]=y,t[77]=R,t[78]=a,t[79]=de):de=t[79];let Ee;t[80]!==_e||t[81]!==He||t[82]!==Ie||t[83]!==Ce||t[84]!==de?(Ee=r.jsxs(Bt,{children:[Be,_e,He,Ie,Ce,de]}),t[80]=_e,t[81]=He,t[82]=Ie,t[83]=Ce,t[84]=de,t[85]=Ee):Ee=t[85];let Ae;t[86]===Symbol.for("react.memo_cache_sentinel")?(Ae=r.jsx(io,{}),t[86]=Ae):Ae=t[86];let Le;t[87]!==L?(Le=L&&r.jsxs(ct,{onClick:()=>F(!0),children:[r.jsx(oh,{}),"Usage & cost…"]}),t[87]=L,t[88]=Le):Le=t[88];let ne;t[89]===Symbol.for("react.memo_cache_sentinel")?(ne=r.jsxs(ct,{onClick:()=>B(!0),children:[r.jsx(rh,{}),"Server monitor…"]}),t[89]=ne):ne=t[89];let fe;t[90]!==te||t[91]!==M?(fe=M&&r.jsxs(ct,{onClick:te,children:[r.jsx(El,{className:"text-success"}),"Copy network URL",r.jsx("span",{className:"ml-auto truncate pl-2 font-mono text-[11px] text-muted-foreground",children:M})]}),t[90]=te,t[91]=M,t[92]=fe):fe=t[92];let Se;t[93]!==Le||t[94]!==fe?(Se=r.jsxs(Bt,{children:[Le,ne,fe]}),t[93]=Le,t[94]=fe,t[95]=Se):Se=t[95];let $e;t[96]===Symbol.for("react.memo_cache_sentinel")?($e=r.jsx(io,{}),t[96]=$e):$e=t[96];let Ue;t[97]===Symbol.for("react.memo_cache_sentinel")?(Ue=r.jsx(Wv,{}),t[97]=Ue):Ue=t[97];let We;t[98]!==C?(We=r.jsx(Bt,{children:r.jsxs(ct,{onClick:C,children:[Ue,"Settings"]})}),t[98]=C,t[99]=We):We=t[99];let Xe;t[100]!==f||t[101]!==N?(Xe=ut("killAny")&&r.jsxs(r.Fragment,{children:[r.jsx(io,{}),r.jsx(Bt,{children:r.jsxs(ct,{variant:"destructive",onClick:N,disabled:f,children:[r.jsx(Dv,{}),f?"Stopping processes…":"Stop all agent processes"]})})]}),t[100]=f,t[101]=N,t[102]=Xe):Xe=t[102];let Je;t[103]!==Ee||t[104]!==Se||t[105]!==We||t[106]!==Xe?(Je=r.jsx("div",{className:Fe,children:r.jsxs(Rn,{children:[ze,r.jsxs(In,{align:"end",sideOffset:6,className:"w-64",children:[Ee,Ae,Se,$e,We,Xe]})]})}),t[103]=Ee,t[104]=Se,t[105]=We,t[106]=Xe,t[107]=Je):Je=t[107];let De;t[108]!==Te||t[109]!==Oe||t[110]!==Je?(De=r.jsxs("div",{className:"electron-no-drag window-inset-end pointer-events-auto flex shrink-0 items-center gap-1.5",children:[je,Ne,Te,Pe,Oe,Je]}),t[108]=Te,t[109]=Oe,t[110]=Je,t[111]=De):De=t[111];let qe;t[112]!==ue||t[113]!==De?(qe=r.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:[ue,De]}),t[112]=ue,t[113]=De,t[114]=qe):qe=t[114];let ot;t[115]!==L||t[116]!==z?(ot=L&&r.jsx(W8,{open:z,onOpenChange:F}),t[115]=L,t[116]=z,t[117]=ot):ot=t[117];let lt;t[118]!==H?(lt=r.jsx(GE,{open:H,onOpenChange:B}),t[118]=H,t[119]=lt):lt=t[119];let bt;return t[120]!==qe||t[121]!==ot||t[122]!==lt?(bt=r.jsxs(r.Fragment,{children:[me,he,qe,ot,lt]}),t[120]=qe,t[121]=ot,t[122]=lt,t[123]=bt):bt=t[123],bt});function e9(n){const e=U.c(14),{icon:t,label:s,onClick:o}=n;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=G(Nn,"size-8 shrink-0"),e[0]=i):i=e[0];let a;e[1]!==s||e[2]!==o?(a=r.jsx(X,{variant:"ghost",size:"icon-sm",onClick:o,"aria-label":s,className:i}),e[1]=s,e[2]=o,e[3]=a):a=e[3];let l;e[4]!==t?(l=r.jsx(t,{"data-icon":"inline-start"}),e[4]=t,e[5]=l):l=e[5];let c;e[6]!==a||e[7]!==l?(c=r.jsx(Pt,{render:a,children:l}),e[6]=a,e[7]=l,e[8]=c):c=e[8];let d;e[9]!==s?(d=r.jsx(At,{side:"bottom",children:s}),e[9]=s,e[10]=d):d=e[10];let f;return e[11]!==c||e[12]!==d?(f=r.jsxs(Et,{children:[c,d]}),e[11]=c,e[12]=d,e[13]=f):f=e[13],f}function t9(n){n&&Cs.success("Copied network URL")}const n9=150,s9="(prefers-reduced-motion: reduce)";function o9(){if(typeof window.matchMedia!="function")return!1;try{return window.matchMedia(s9).matches}catch{return!1}}function r9(n){const e=U.c(5),{side:t,children:s,visible:o,enabled:i}=n,a=i===void 0?!0:i;if(o){let c;return e[0]!==s?(c=r.jsx(r.Fragment,{children:s}),e[0]=s,e[1]=c):c=e[1],c}if(!a)return null;let l;return e[2]!==s||e[3]!==t?(l=r.jsx(i9,{side:t,children:s}),e[2]=s,e[3]=t,e[4]=l):l=e[4],l}function i9(n){const e=U.c(26),{side:t,children:s}=n,[o,i]=b.useState(!1),[a,l]=b.useState(!1),c=b.useRef(0),d=b.useRef(0),f=b.useRef(0),u=b.useRef(null),m=b.useRef(null),p=b.useRef(!1),h=b.useId();let g,x;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=()=>()=>{clearTimeout(c.current),clearTimeout(d.current),clearTimeout(f.current)},x=[],e[0]=g,e[1]=x):(g=e[0],x=e[1]),b.useEffect(g,x);let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{clearTimeout(f.current),l(!0),i(!0)},e[2]=v):v=e[2];const w=v;let y;e[3]===Symbol.for("react.memo_cache_sentinel")?(y=()=>{if(clearTimeout(f.current),i(!1),o9()){l(!1);return}f.current=window.setTimeout(()=>{f.current=0,l(!1)},n9)},e[3]=y):y=e[3];const j=y;let k;e[4]===Symbol.for("react.memo_cache_sentinel")?(k=()=>{clearTimeout(d.current),clearTimeout(c.current),c.current=window.setTimeout(w,200)},e[4]=k):k=e[4];const N=k;let C;e[5]===Symbol.for("react.memo_cache_sentinel")?(C=()=>{clearTimeout(d.current),clearTimeout(c.current),w()},e[5]=C):C=e[5];const S=C;let _;e[6]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{if(p.current){p.current=!1;return}S()},e[6]=_):_=e[6];const P=_;let A;e[7]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{clearTimeout(c.current),d.current=window.setTimeout(j,300)},e[7]=A):A=e[7];const E=A;let T;e[8]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{var K,V;const W=document.activeElement;(K=u.current)!=null&&K.contains(W)||(V=m.current)!=null&&V.contains(W)||E()},e[8]=T):T=e[8];const M=T;let I;e[9]===Symbol.for("react.memo_cache_sentinel")?(I=W=>{var V,Y;const K=W.relatedTarget;(V=u.current)!=null&&V.contains(K)||(Y=m.current)!=null&&Y.contains(K)||E()},e[9]=I):I=e[9];const R=I;let $;e[10]===Symbol.for("react.memo_cache_sentinel")?($=W=>{W.key==="Escape"&&(W.preventDefault(),clearTimeout(c.current),clearTimeout(d.current),j(),p.current=!0,requestAnimationFrame(()=>{var K;return(K=u.current)==null?void 0:K.focus()}))},e[10]=$):$=e[10];const D=$,O=`Reveal ${t} sidebar`,L=`Reveal ${t} sidebar`;let z;e[11]===Symbol.for("react.memo_cache_sentinel")?(z=r.jsx("span",{"aria-hidden":"true",className:"mx-auto h-full w-px bg-border opacity-0 transition-opacity duration-150 group-hover:opacity-100"}),e[11]=z):z=e[11];let F;e[12]!==o||e[13]!==h||e[14]!==O||e[15]!==L?(F=r.jsx(X,{ref:u,type:"button",variant:"ghost","aria-label":O,"aria-controls":h,"aria-expanded":o,title:L,className:"group relative z-10 h-auto w-1.5 shrink-0 rounded-none p-0 focus-visible:ring-inset",onMouseEnter:N,onMouseLeave:M,onFocus:P,onBlur:R,onClick:S,children:z}),e[12]=o,e[13]=h,e[14]=O,e[15]=L,e[16]=F):F=e[16];let H;e[17]!==s||e[18]!==a||e[19]!==o||e[20]!==h||e[21]!==t?(H=a&&r.jsx("div",{ref:m,id:h,"aria-hidden":!o,inert:!o,className:G("electron-no-drag absolute inset-y-0 z-40 bg-background shadow-sm",!o&&"pointer-events-none animate-out fade-out-0 fill-mode-forwards duration-150 ease-in",t==="left"?o?"left-0 border-r panel-enter":"left-0 border-r slide-out-to-left-3":o?"right-0 border-l panel-enter-right":"right-0 border-l slide-out-to-right-3"),onMouseEnter:N,onMouseLeave:M,onFocusCapture:S,onBlurCapture:R,onKeyDown:D,children:s}),e[17]=s,e[18]=a,e[19]=o,e[20]=h,e[21]=t,e[22]=H):H=e[22];let B;return e[23]!==F||e[24]!==H?(B=r.jsxs(r.Fragment,{children:[F,H]}),e[23]=F,e[24]=H,e[25]=B):B=e[25],B}const a9=b.memo(function(e){const t=U.c(13),{onToggleSidebar:s,onGoHome:o,onOpenCommandPalette:i,sidebarShortcut:a,commandPaletteShortcut:l}=e;let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx("div",{className:"flex-1"}),t[0]=c):c=t[0];let d;t[1]!==o?(d=r.jsx(qa,{icon:vo,label:"Home",onClick:o,size:"default"}),t[1]=o,t[2]=d):d=t[2];const f=`Search (${l})`;let u;t[3]!==i||t[4]!==f?(u=r.jsx(qa,{icon:xn,label:f,onClick:i,size:"default"}),t[3]=i,t[4]=f,t[5]=u):u=t[5];const m=`Hide sidebar (${a})`;let p;t[6]!==s||t[7]!==m?(p=r.jsx(qa,{icon:Hv,label:m,onClick:s,size:"default"}),t[6]=s,t[7]=m,t[8]=p):p=t[8];let h;return t[9]!==d||t[10]!==u||t[11]!==p?(h=r.jsxs("div",{className:"electron-drag window-inset-start flex h-12 shrink-0 items-center gap-1 px-2",children:[c,d,u,p]}),t[9]=d,t[10]=u,t[11]=p,t[12]=h):h=t[12],h}),oc=new Map;let jl=null,Sl=null;async function l9(){try{const n=await ye("/api/usage-cost/rates");if(!n.ok)return oc;const e=await n.json();return new Map(Object.entries(e.rates??{}))}catch{return oc}}function x0(){const[n,e]=b.useState(jl??oc);return b.useEffect(()=>{if(jl!==null)return;let t=!0;return Sl??(Sl=l9().then(s=>(s.size>0&&(jl=s),Sl=null,s))),Sl.then(s=>{t&&e(s)}),()=>{t=!1}},[]),n}function c9(n,e){return n.map((t,s)=>{var p,h,g,x;const o=((p=t.tokenUsage)==null?void 0:p.input_tokens)??0,i=((h=t.tokenUsage)==null?void 0:h.cache_read_input_tokens)??0,a=((g=t.tokenUsage)==null?void 0:g.cache_creation_input_tokens)??0,l=o+i+a,c=t.subAgentActivity.length>0,d=gj(t),f=xj(t),u=Math.max(d+f,((x=t.tokenUsage)==null?void 0:x.output_tokens)??0),m=t.tokenUsage?g0(e,t.model,t.tokenUsage):0;return{turn:s+1,totalInput:l,totalOutput:u,thinkingTokens:d,visibleTokens:f,newInput:o,cacheRead:i,cacheWrite:a,hasSubAgents:c,cost:m}})}function d9(n){const e=U.c(41),{data:t}=n;let s;e[0]!==t.turn?(s=r.jsxs("div",{className:"mb-1 font-medium text-foreground",children:["Turn ",t.turn]}),e[0]=t.turn,e[1]=s):s=e[1];let o;e[2]!==t.totalInput?(o=tt(t.totalInput),e[2]=t.totalInput,e[3]=o):o=e[3];let i;e[4]!==o?(i=r.jsx("span",{className:"text-info",children:o}),e[4]=o,e[5]=i):i=e[5];let a;e[6]!==t.cacheRead?(a=tt(t.cacheRead),e[6]=t.cacheRead,e[7]=a):a=e[7];let l;e[8]!==t.cacheWrite?(l=tt(t.cacheWrite),e[8]=t.cacheWrite,e[9]=l):l=e[9];let c;e[10]!==t.newInput?(c=tt(t.newInput),e[10]=t.newInput,e[11]=c):c=e[11];let d;e[12]!==a||e[13]!==l||e[14]!==c?(d=r.jsxs("span",{className:"ml-1 opacity-60",children:["(",a," cached, ",l," written, ",c," new)"]}),e[12]=a,e[13]=l,e[14]=c,e[15]=d):d=e[15];let f;e[16]!==i||e[17]!==d?(f=r.jsxs("span",{children:["Input: ",i,d]}),e[16]=i,e[17]=d,e[18]=f):f=e[18];let u;e[19]!==t.totalOutput?(u=tt(t.totalOutput),e[19]=t.totalOutput,e[20]=u):u=e[20];let m;e[21]!==u?(m=r.jsx("span",{className:"text-success",children:u}),e[21]=u,e[22]=m):m=e[22];let p;e[23]!==t.thinkingTokens||e[24]!==t.visibleTokens?(p=t.thinkingTokens>0&&r.jsxs("span",{className:"ml-1 opacity-60",children:["(",tt(t.thinkingTokens)," thinking, ",tt(t.visibleTokens)," text)"]}),e[23]=t.thinkingTokens,e[24]=t.visibleTokens,e[25]=p):p=e[25];let h;e[26]!==m||e[27]!==p?(h=r.jsxs("span",{children:["Output: ",m,p]}),e[26]=m,e[27]=p,e[28]=h):h=e[28];let g;e[29]!==t.cost?(g=t.cost>0&&r.jsxs("span",{children:["API cost: ",r.jsx("span",{className:"text-warning",children:as(t.cost)})]}),e[29]=t.cost,e[30]=g):g=e[30];let x;e[31]!==t.hasSubAgents?(x=t.hasSubAgents&&r.jsx("span",{className:"text-warning",children:"Has sub-agent activity"}),e[31]=t.hasSubAgents,e[32]=x):x=e[32];let v;e[33]!==h||e[34]!==g||e[35]!==x||e[36]!==f?(v=r.jsxs("div",{className:"flex flex-col gap-0.5 text-muted-foreground",children:[f,h,g,x]}),e[33]=h,e[34]=g,e[35]=x,e[36]=f,e[37]=v):v=e[37];let w;return e[38]!==s||e[39]!==v?(w=r.jsx("div",{className:"pointer-events-none absolute left-0 right-0 top-[28px] z-10 px-1",children:r.jsxs("div",{className:"w-fit rounded-md border bg-popover px-2.5 py-2 text-xs text-popover-foreground shadow-xs",children:[s,v]})}),e[38]=s,e[39]=v,e[40]=w):w=e[40],w}function u9(n){const e=U.c(33),{padLeft:t,svgHeight:s}=n,o=s-10;let i;e[0]!==t||e[1]!==o?(i=r.jsx("rect",{x:t,y:o,width:6,height:6,rx:1.5,fill:"var(--info)",opacity:.85}),e[0]=t,e[1]=o,e[2]=i):i=e[2];const a=t+9,l=s-4;let c;e[3]!==a||e[4]!==l?(c=r.jsx("text",{x:a,y:l,className:"fill-muted-foreground text-xs",children:"Input"}),e[3]=a,e[4]=l,e[5]=c):c=e[5];const d=t+48,f=s-10;let u;e[6]!==d||e[7]!==f?(u=r.jsx("rect",{x:d,y:f,width:6,height:6,rx:1.5,fill:"var(--success)",opacity:.7}),e[6]=d,e[7]=f,e[8]=u):u=e[8];const m=t+57,p=s-4;let h;e[9]!==p||e[10]!==m?(h=r.jsx("text",{x:m,y:p,className:"fill-muted-foreground text-xs",children:"Output"}),e[9]=p,e[10]=m,e[11]=h):h=e[11];const g=t+104,x=s-10;let v;e[12]!==g||e[13]!==x?(v=r.jsx("rect",{x:g,y:x,width:6,height:6,rx:1.5,fill:"var(--muted-foreground)",opacity:.45}),e[12]=g,e[13]=x,e[14]=v):v=e[14];const w=t+113,y=s-4;let j;e[15]!==w||e[16]!==y?(j=r.jsx("text",{x:w,y,className:"fill-muted-foreground text-xs",children:"Think"}),e[15]=w,e[16]=y,e[17]=j):j=e[17];const k=t+155,N=s-7;let C;e[18]!==k||e[19]!==N?(C=r.jsx("circle",{cx:k,cy:N,r:2,fill:"var(--warning)",opacity:.8}),e[18]=k,e[19]=N,e[20]=C):C=e[20];const S=t+162,_=s-4;let P;e[21]!==S||e[22]!==_?(P=r.jsx("text",{x:S,y:_,className:"fill-muted-foreground text-xs",children:"Agent"}),e[21]=S,e[22]=_,e[23]=P):P=e[23];let A;return e[24]!==h||e[25]!==v||e[26]!==j||e[27]!==i||e[28]!==C||e[29]!==P||e[30]!==c||e[31]!==u?(A=r.jsxs(r.Fragment,{children:[i,c,u,h,v,j,C,P]}),e[24]=h,e[25]=v,e[26]=j,e[27]=i,e[28]=C,e[29]=P,e[30]=c,e[31]=u,e[32]=A):A=e[32],A}function f9(n){const e=U.c(61),{data:t,groupX:s,barW:o,groupW:i,baseY:a,chartH:l,maxVal:c,isHovered:d,onHover:f,padTop:u}=n,m=t.cacheRead/c*l,p=t.cacheWrite/c*l,h=t.newInput/c*l,g=t.thinkingTokens/c*l,x=t.visibleTokens/c*l;let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={cursor:"crosshair"},e[0]=v):v=e[0];let w;e[1]!==l||e[2]!==i||e[3]!==s||e[4]!==u?(w=r.jsx("rect",{x:s,y:u,width:i,height:l,fill:"transparent"}),e[1]=l,e[2]=i,e[3]=s,e[4]=u,e[5]=w):w=e[5];let y;e[6]!==l||e[7]!==i||e[8]!==s||e[9]!==d||e[10]!==u?(y=d&&r.jsx("rect",{x:s-1,y:u,width:i+2,height:l,fill:"var(--foreground)",opacity:.04,rx:2}),e[6]=l,e[7]=i,e[8]=s,e[9]=d,e[10]=u,e[11]=y):y=e[11];let j;e[12]!==o||e[13]!==a||e[14]!==m||e[15]!==s||e[16]!==d?(j=m>0&&r.jsx("rect",{x:s,y:a-m,width:o,height:m,rx:1,fill:"var(--info)",opacity:d?.45:.25}),e[12]=o,e[13]=a,e[14]=m,e[15]=s,e[16]=d,e[17]=j):j=e[17];let k;e[18]!==o||e[19]!==a||e[20]!==m||e[21]!==p||e[22]!==s||e[23]!==d?(k=p>0&&r.jsx("rect",{x:s,y:a-m-p,width:o,height:p,rx:1,fill:"var(--info)",opacity:d?.7:.5}),e[18]=o,e[19]=a,e[20]=m,e[21]=p,e[22]=s,e[23]=d,e[24]=k):k=e[24];let N;e[25]!==o||e[26]!==a||e[27]!==m||e[28]!==p||e[29]!==s||e[30]!==d||e[31]!==h?(N=h>0&&r.jsx("rect",{x:s,y:a-m-p-h,width:o,height:h,rx:1,fill:"var(--info)",opacity:d?1:.85}),e[25]=o,e[26]=a,e[27]=m,e[28]=p,e[29]=s,e[30]=d,e[31]=h,e[32]=N):N=e[32];let C;e[33]!==o||e[34]!==a||e[35]!==s||e[36]!==d||e[37]!==g?(C=g>0&&r.jsx("rect",{x:s+o+1,y:a-g,width:o,height:g,rx:1,fill:"var(--muted-foreground)",opacity:d?.7:.45}),e[33]=o,e[34]=a,e[35]=s,e[36]=d,e[37]=g,e[38]=C):C=e[38];let S;e[39]!==o||e[40]!==a||e[41]!==s||e[42]!==d||e[43]!==g||e[44]!==x?(S=x>0&&r.jsx("rect",{x:s+o+1,y:a-g-x,width:o,height:x,rx:1,fill:"var(--success)",opacity:d?.95:.7}),e[39]=o,e[40]=a,e[41]=s,e[42]=d,e[43]=g,e[44]=x,e[45]=S):S=e[45];let _;e[46]!==a||e[47]!==t.hasSubAgents||e[48]!==i||e[49]!==s?(_=t.hasSubAgents&&r.jsx("circle",{cx:s+i/2,cy:a+5,r:1.5,fill:"var(--warning)",opacity:.8}),e[46]=a,e[47]=t.hasSubAgents,e[48]=i,e[49]=s,e[50]=_):_=e[50];let P;return e[51]!==f||e[52]!==w||e[53]!==y||e[54]!==j||e[55]!==k||e[56]!==N||e[57]!==C||e[58]!==S||e[59]!==_?(P=r.jsxs("g",{onMouseEnter:f,style:v,children:[w,y,j,k,N,C,S,_]}),e[51]=f,e[52]=w,e[53]=y,e[54]=j,e[55]=k,e[56]=N,e[57]=C,e[58]=S,e[59]=_,e[60]=P):P=e[60],P}const b0=280,rc=130,pi=16,m9=22,Ts=36,p9=8,si=b0-Ts-p9,ep=rc-pi-m9;function h9(n){const e=U.c(34),{turns:t}=n,[s,o]=b.useState(null),i=x0();let a;e[0]!==i||e[1]!==t?(a=c9(t,i),e[0]=i,e[1]=t,e[2]=a):a=e[2];const l=a;if(l.length===0)return null;let c;e[3]!==l?(c=Math.max(...l.map(x9),...l.map(g9)),e[3]=l,e[4]=c):c=e[4];const d=c;if(d===0)return null;const f=Math.max(5,Math.min(20,si/l.length)),u=Math.max(2,(f-1)/2),m=pi+ep,p=s!==null?l[s]:null;let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(Qn,{children:"Input / Output Per Turn"}),e[5]=h):h=e[5];let g;e[6]!==p?(g=p&&r.jsx(d9,{data:p}),e[6]=p,e[7]=g):g=e[7];let x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x=()=>o(null),e[8]=x):x=e[8];let v;e[9]!==d?(v=tt(d),e[9]=d,e[10]=v):v=e[10];let w;e[11]!==v?(w=r.jsx("text",{x:Ts-4,y:pi,textAnchor:"end",dominantBaseline:"central",className:"fill-muted-foreground text-xs",children:v}),e[11]=v,e[12]=w):w=e[12];let y,j;e[13]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx("text",{x:Ts-4,y:m,textAnchor:"end",dominantBaseline:"central",className:"fill-muted-foreground text-xs",children:"0"}),j=r.jsx("line",{x1:Ts,y1:m,x2:Ts+si,y2:m,stroke:"var(--border)",strokeWidth:.5}),e[13]=y,e[14]=j):(y=e[13],j=e[14]);let k;if(e[15]!==u||e[16]!==l||e[17]!==f||e[18]!==s||e[19]!==d){let _;e[21]!==u||e[22]!==l.length||e[23]!==f||e[24]!==s||e[25]!==d?(_=(P,A)=>{const E=Ts+(l.length===1?(si-f)/2:A/(l.length-1)*(si-f));return r.jsx(f9,{data:P,groupX:E,barW:u,groupW:f,baseY:m,chartH:ep,maxVal:d,isHovered:s===A,onHover:()=>o(A),padTop:pi},A)},e[21]=u,e[22]=l.length,e[23]=f,e[24]=s,e[25]=d,e[26]=_):_=e[26],k=l.map(_),e[15]=u,e[16]=l,e[17]=f,e[18]=s,e[19]=d,e[20]=k}else k=e[20];let N;e[27]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(u9,{padLeft:Ts,svgHeight:rc}),e[27]=N):N=e[27];let C;e[28]!==k||e[29]!==w?(C=r.jsxs("svg",{width:"100%",viewBox:`0 0 ${b0} ${rc}`,onMouseLeave:x,children:[w,y,j,k,N]}),e[28]=k,e[29]=w,e[30]=C):C=e[30];let S;return e[31]!==C||e[32]!==g?(S=r.jsxs("section",{className:"relative",children:[h,g,C]}),e[31]=C,e[32]=g,e[33]=S):S=e[33],S}function g9(n){return n.totalOutput}function x9(n){return n.totalInput}const tp=280,np=32;function b9(n){const e=U.c(19),{turns:t}=n,[s,o]=b.useState(null);let i;e[0]!==t?(i=Math.max(1,...t.map(v9)),e[0]=t,e[1]=i):i=e[1];const a=i;if(t.length===0)return null;const l=Math.max(2,Math.min(20,tp/t.length)),c=l*t.length;let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Qn,{children:"Activity Heatmap"}),e[2]=d):d=e[2];const f=`0 0 ${Math.max(tp,c)} ${np}`;let u;if(e[3]!==a||e[4]!==l||e[5]!==t){let g;e[7]!==a||e[8]!==l?(g=(x,v)=>{const y=.1+x.toolCalls.length/a*.9;return r.jsx("rect",{x:v*l,y:0,width:l-1,height:np,rx:2,fill:"var(--foreground)",opacity:y,onMouseEnter:()=>o(v),onMouseLeave:()=>o(null),className:"cursor-pointer"},v)},e[7]=a,e[8]=l,e[9]=g):g=e[9],u=t.map(g),e[3]=a,e[4]=l,e[5]=t,e[6]=u}else u=e[6];let m;e[10]!==f||e[11]!==u?(m=r.jsx("svg",{width:"100%",viewBox:f,children:u}),e[10]=f,e[11]=u,e[12]=m):m=e[12];let p;e[13]!==s||e[14]!==t?(p=s!==null&&r.jsxs("div",{className:"pointer-events-none absolute -top-9 left-1/2 -translate-x-1/2 whitespace-nowrap rounded-md border bg-popover px-2 py-1 text-xs text-popover-foreground shadow-xs",children:["Turn ",s+1,": ",t[s].toolCalls.length," tool calls"]}),e[13]=s,e[14]=t,e[15]=p):p=e[15];let h;return e[16]!==m||e[17]!==p?(h=r.jsxs("section",{children:[d,r.jsxs("div",{className:"relative",children:[m,p]})]}),e[16]=m,e[17]=p,e[18]=h):h=e[18],h}function v9(n){return n.toolCalls.length}function y9(n){const e=U.c(7),{turns:t}=n;let s;if(e[0]!==t){const c={};for(const d of t)d.model&&(c[d.model]=(c[d.model]??0)+1);s=Object.entries(c).sort(j9),e[0]=t,e[1]=s}else s=e[1];const o=s;if(o.length<=1)return null;let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Qn,{children:"Models"}),e[2]=i):i=e[2];let a;e[3]!==o?(a=o.map(w9),e[3]=o,e[4]=a):a=e[4];let l;return e[5]!==a?(l=r.jsxs("section",{children:[i,r.jsx("div",{className:"flex flex-col gap-1",children:a})]}),e[5]=a,e[6]=l):l=e[6],l}function w9(n){const[e,t]=n;return r.jsxs("div",{className:"flex items-center justify-between rounded-md border bg-card px-2.5 py-1.5 text-xs",children:[r.jsx("span",{className:"truncate text-foreground",children:e}),r.jsx("span",{className:"ml-2 shrink-0 text-muted-foreground",children:t})]},e)}function j9(n,e){const[,t]=n,[,s]=e;return s-t}const S9=["agent","skill","plugin","mcpServer","mcpTool"],k9={agent:"Agents",skill:"Skills",plugin:"Plugins",mcpServer:"MCP servers",mcpTool:"MCP tools"},oi="Unattributed";function sp(n){return n.inputTokens+n.outputTokens}function N9(n,e){var i;const t=new Map;for(const a of n){const l=((i=a.attribution)==null?void 0:i[e])??oi;let c=t.get(l);c||(c={name:l,turns:0,inputTokens:0,outputTokens:0,isUnattributed:l===oi},t.set(l,c)),c.turns+=1;const d=a.tokenUsage;d&&(c.inputTokens+=d.input_tokens+(d.cache_read_input_tokens??0)+(d.cache_creation_input_tokens??0),c.outputTokens+=d.output_tokens)}const s=t.get(oi);s&&t.delete(oi);const o=[...t.values()].sort((a,l)=>sp(l)-sp(a));return s&&o.push(s),o}function C9(n){return S9.filter(e=>n.some(t=>{var s;return(s=t.attribution)==null?void 0:s[e]}))}function _9(n){const e=U.c(38),{bucket:t,maxTotal:s}=n,o=t.inputTokens+t.outputTokens,i=s>0?o/s:0,a=o>0?t.inputTokens/o*i:0,l=o>0?t.outputTokens/o*i:0,c=t.name,d=t.turns;let f;e[0]!==t.inputTokens?(f=tt(t.inputTokens),e[0]=t.inputTokens,e[1]=f):f=e[1];let u;e[2]!==t.outputTokens?(u=tt(t.outputTokens),e[2]=t.outputTokens,e[3]=u):u=e[3];const m=`${c} — ${d} ${t.turns===1?"turn":"turns"}, ${f} input, ${u} output`,p=t.isUnattributed?"truncate text-muted-foreground":"truncate text-foreground";let h;e[4]!==t.name||e[5]!==p?(h=r.jsx("span",{className:p,children:t.name}),e[4]=t.name,e[5]=p,e[6]=h):h=e[6];const g=t.turns===1?"turn":"turns";let x;e[7]!==t.turns||e[8]!==g?(x=r.jsxs("span",{children:[t.turns," ",g]}),e[7]=t.turns,e[8]=g,e[9]=x):x=e[9];let v;e[10]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx("span",{className:"opacity-40",children:"·"}),e[10]=v):v=e[10];let w;e[11]!==o?(w=tt(o),e[11]=o,e[12]=w):w=e[12];let y;e[13]!==w?(y=r.jsx("span",{children:w}),e[13]=w,e[14]=y):y=e[14];let j;e[15]!==y||e[16]!==x?(j=r.jsxs("span",{className:"ml-2 flex shrink-0 items-center gap-1.5 tabular-nums text-muted-foreground",children:[x,v,y]}),e[15]=y,e[16]=x,e[17]=j):j=e[17];let k;e[18]!==j||e[19]!==h?(k=r.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs",children:[h,j]}),e[18]=j,e[19]=h,e[20]=k):k=e[20];const N=t.isUnattributed?"rounded-xs bg-info/35":"rounded-xs bg-info/85",C=`${a*100}%`;let S;e[21]!==C?(S={width:C},e[21]=C,e[22]=S):S=e[22];let _;e[23]!==N||e[24]!==S?(_=r.jsx("div",{className:N,style:S}),e[23]=N,e[24]=S,e[25]=_):_=e[25];const P=t.isUnattributed?"rounded-xs bg-success/35":"rounded-xs bg-success/70",A=`${l*100}%`;let E;e[26]!==A?(E={width:A},e[26]=A,e[27]=E):E=e[27];let T;e[28]!==P||e[29]!==E?(T=r.jsx("div",{className:P,style:E}),e[28]=P,e[29]=E,e[30]=T):T=e[30];let M;e[31]!==_||e[32]!==T?(M=r.jsxs("div",{className:"mt-1.5 flex h-1 gap-[2px]","aria-hidden":"true",children:[_,T]}),e[31]=_,e[32]=T,e[33]=M):M=e[33];let I;return e[34]!==k||e[35]!==M||e[36]!==m?(I=r.jsxs("li",{className:"rounded-md border bg-card px-2.5 py-1.5",title:m,children:[k,M]}),e[34]=k,e[35]=M,e[36]=m,e[37]=I):I=e[37],I}function T9(){const n=U.c(2);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"size-1.5 rounded-xs bg-info/85"}),"Input"]}),n[0]=e):e=n[0];let t;return n[1]===Symbol.for("react.memo_cache_sentinel")?(t=r.jsxs("div",{className:"mt-2 flex items-center gap-3 text-xs text-muted-foreground",children:[e,r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"size-1.5 rounded-xs bg-success/70"}),"Output"]})]}),n[1]=t):t=n[1],t}function E9(n){const e=U.c(25),{turns:t}=n;let s;e[0]!==t?(s=C9(t),e[0]=t,e[1]=s):s=e[1];const o=s,[i,a]=b.useState(null);let l;e[2]!==o||e[3]!==i?(l=i&&o.includes(i)?i:o[0],e[2]=o,e[3]=i,e[4]=l):l=e[4];const c=l;let d;e[5]!==c||e[6]!==t?(d=c?N9(t,c):[],e[5]=c,e[6]=t,e[7]=d):d=e[7];const f=d;if(!c)return null;let u;e[8]!==f?(u=Math.max(...f.map(A9)),e[8]=f,e[9]=u):u=e[9];const m=u;let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(Qn,{children:"Attribution"}),e[10]=p):p=e[10];let h;e[11]!==c||e[12]!==o?(h=o.length>1&&r.jsx(Cx,{"aria-label":"Attribution dimension",value:[c],onValueChange:y=>{const j=y[0];typeof j=="string"&&a(j)},variant:"outline",size:"sm",className:"mb-2 flex-wrap",children:o.map(P9)}),e[11]=c,e[12]=o,e[13]=h):h=e[13];let g;if(e[14]!==f||e[15]!==m){let y;e[17]!==m?(y=j=>r.jsx(_9,{bucket:j,maxTotal:m},j.name),e[17]=m,e[18]=y):y=e[18],g=f.map(y),e[14]=f,e[15]=m,e[16]=g}else g=e[16];let x;e[19]!==g?(x=r.jsx("ul",{className:"flex max-h-[280px] flex-col gap-1 overflow-y-auto pr-0.5",children:g}),e[19]=g,e[20]=x):x=e[20];let v;e[21]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(T9,{}),e[21]=v):v=e[21];let w;return e[22]!==h||e[23]!==x?(w=r.jsxs("section",{children:[p,h,x,v]}),e[22]=h,e[23]=x,e[24]=w):w=e[24],w}function P9(n){return r.jsx(_x,{value:n,children:k9[n]},n)}function A9(n){return n.inputTokens+n.outputTokens}function R9(n){const e=[];for(let t=0;t<n.length;t++)for(const s of n[t].toolCalls)s.isError&&s.result&&e.push({turnIndex:t,toolName:s.name,message:s.result.slice(0,200)});return e}function M9(n){const e=U.c(14),{turns:t,onJumpToTurn:s}=n;let o;e[0]!==t?(o=R9(t),e[0]=t,e[1]=o):o=e[1];const i=o;if(i.length===0)return null;let a;e[2]!==i.length?(a=r.jsxs(Qn,{children:["Errors (",i.length,")"]}),e[2]=i.length,e[3]=a):a=e[3];let l;if(e[4]!==i||e[5]!==s){let f;e[7]!==s?(f=(u,m)=>r.jsxs(X,{type:"button",variant:"ghost",onClick:()=>s==null?void 0:s(u.turnIndex),className:"h-auto w-full flex-col items-stretch rounded-none border-b border-border px-2 py-2.5 text-left whitespace-normal last:border-b-0 hover:bg-destructive/5",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[r.jsx("span",{className:"font-medium text-destructive",children:u.toolName}),r.jsxs("span",{className:"text-muted-foreground",children:["Turn ",u.turnIndex+1]})]}),r.jsx("div",{className:"mt-0.5 line-clamp-2 text-xs leading-relaxed text-muted-foreground",children:u.message})]},m),e[7]=s,e[8]=f):f=e[8],l=i.map(f),e[4]=i,e[5]=s,e[6]=l}else l=e[6];let c;e[9]!==l?(c=r.jsx("div",{className:"flex max-h-[300px] flex-col overflow-y-auto pr-1",children:l}),e[9]=l,e[10]=c):c=e[10];let d;return e[11]!==a||e[12]!==c?(d=r.jsxs("section",{children:[a,c]}),e[11]=a,e[12]=c,e[13]=d):d=e[13],d}function op(n){const e=U.c(42),{agentId:t,subagentType:s,agentName:o,preview:i,isViewing:a,isBackground:l,status:c,durationMs:d,toolUseCount:f,disabled:u,onClick:m,onStop:p}=n;let h;e[0]!==t||e[1]!==o||e[2]!==s?(h=o||xd(t,s),e[0]=t,e[1]=o,e[2]=s,e[3]=h):h=e[3];const g=h;let x;e[4]!==d?(x=d==null?null:d<1e3?`${d}ms`:`${(d/1e3).toFixed(d>=1e4?0:1)}s`,e[4]=d,e[5]=x):x=e[5];const v=x;let w;e[6]!==c?(w=c==="running"?r.jsx(rt,{className:"size-3 shrink-0 animate-spin text-success","data-icon":"inline-start"}):c==="done"?r.jsx(Un,{className:"size-3 shrink-0 text-success","data-icon":"inline-start"}):c==="failed"?r.jsx(zs,{className:"size-3 shrink-0 text-destructive","data-icon":"inline-start"}):r.jsx(Yp,{className:"size-2.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),e[6]=c,e[7]=w):w=e[7];const y=w,j=a?"bg-accent":"hover:bg-muted/40";let k;e[8]!==j?(k=G("motion-list-item flex w-full items-start border-b border-border text-left transition-colors last:border-b-0",j),e[8]=j,e[9]=k):k=e[9];let N;e[10]!==g?(N=r.jsx(Me,{variant:"outline",children:g}),e[10]=g,e[11]=N):N=e[11];let C;e[12]!==l?(C=l&&r.jsx(Me,{variant:"outline",children:"Background"}),e[12]=l,e[13]=C):C=e[13];let S;e[14]!==a?(S=a&&r.jsx(Me,{children:"Viewing"}),e[14]=a,e[15]=S):S=e[15];const _=c==="running"?"active":c;let P;e[16]!==_?(P=r.jsx("span",{className:"ml-auto text-xs uppercase tracking-wide text-muted-foreground",children:_}),e[16]=_,e[17]=P):P=e[17];let A;e[18]!==y||e[19]!==P||e[20]!==N||e[21]!==C||e[22]!==S?(A=r.jsxs("div",{className:"flex items-center gap-1.5",children:[y,N,C,S,P]}),e[18]=y,e[19]=P,e[20]=N,e[21]=C,e[22]=S,e[23]=A):A=e[23];let E;e[24]!==i?(E=i&&r.jsx("p",{className:"mt-1 line-clamp-2 text-xs leading-relaxed text-muted-foreground",children:i}),e[24]=i,e[25]=E):E=e[25];let T;e[26]!==v||e[27]!==f?(T=(v||f!=null)&&r.jsxs("div",{className:"mt-1.5 flex items-center gap-2 text-xs text-muted-foreground",children:[v&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(Ki,{className:"size-2.5","data-icon":"inline-start"}),v]}),f!=null&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(Fi,{className:"size-2.5","data-icon":"inline-start"}),f," tools"]})]}),e[26]=v,e[27]=f,e[28]=T):T=e[28];let M;e[29]!==u||e[30]!==m||e[31]!==A||e[32]!==E||e[33]!==T?(M=r.jsxs(X,{type:"button",variant:"ghost",onClick:m,disabled:u,className:"h-auto min-w-0 flex-1 flex-col items-stretch rounded-none px-2.5 py-2 text-left whitespace-normal",children:[A,E,T]}),e[29]=u,e[30]=m,e[31]=A,e[32]=E,e[33]=T,e[34]=M):M=e[34];let I;e[35]!==g||e[36]!==p?(I=p&&r.jsx(X,{type:"button",variant:"ghost",size:"icon-sm",className:"m-1",onClick:p,"aria-label":`Stop ${g}`,children:r.jsx(jt,{"data-icon":"inline-start"})}),e[35]=g,e[36]=p,e[37]=I):I=e[37];let R;return e[38]!==M||e[39]!==I||e[40]!==k?(R=r.jsxs("div",{className:k,children:[M,I]}),e[38]=M,e[39]=I,e[40]=k,e[41]=R):R=e[41],R}function I9(n,e=!1){const t=n==null?void 0:n.toLowerCase();return t==="completed"||t==="success"||t==="done"?"done":t==="failed"||t==="error"||t==="cancelled"?"failed":e||t==="running"||t==="async_launched"?"running":"seen"}function ic(n){return n.split(`
|
|
119
|
+
`).map(e=>e.trim()).find(Boolean)??""}function $9(n){return n.name==="Task"||n.name==="Agent"}function O9(n,e){var i;const t=new Map;for(const a of n.turns)for(const l of a.contentBlocks)if(!(l.kind!=="sub_agent"&&l.kind!=="background_agent"))for(const c of l.messages){const d=t.get(c.agentId),f=I9(c.status);t.set(c.agentId,{agentId:c.agentId,agentName:c.agentName??(d==null?void 0:d.agentName)??null,subagentType:c.subagentType??(d==null?void 0:d.subagentType)??null,preview:ic(((i=c.prompt)==null?void 0:i.trim())||c.text.find(u=>u.trim())||"")||(d==null?void 0:d.preview)||"No task summary recorded",isBackground:c.isBackground||(d==null?void 0:d.isBackground)||!1,status:f==="seen"&&(d!=null&&d.status)?d.status:f,durationMs:c.durationMs??(d==null?void 0:d.durationMs),toolUseCount:c.toolUseCount??(d==null?void 0:d.toolUseCount),parentToolUseId:c.parentToolUseId??(d==null?void 0:d.parentToolUseId)})}const s=new Set;for(const a of t.values())a.parentToolUseId&&s.add(a.parentToolUseId);const o=new Set;for(const a of e)a.parentToolUseId&&o.add(a.parentToolUseId);for(const a of n.turns)for(const l of a.toolCalls){if(!$9(l)||!o.has(l.id)||s.has(l.id))continue;const c=l.input;t.set(`tool:${l.id}`,{agentId:`tool:${l.id}`,agentName:typeof c.name=="string"?c.name:null,subagentType:typeof c.subagent_type=="string"?c.subagent_type:null,preview:ic(typeof c.prompt=="string"?c.prompt:typeof c.description=="string"?c.description:"Agent task in progress"),isBackground:!1,status:"running",parentToolUseId:l.id})}return[...t.values()]}function D9({session:n,sessionSource:e,bgAgents:t,onLoadSession:s}){const o=hd(),i=b.useMemo(()=>{if(!e)return null;const w=bs(e.fileName);return w?{...w,dirName:e.dirName}:null},[e]),a=b.useMemo(()=>O9(n,o),[n,o]),l=b.useRef(a);b.useEffect(()=>{!i&&a.length>0&&(l.current=a)},[i,a]);const c=i&&a.length===0?l.current:a,d=b.useMemo(()=>{if(i)return i.parentSessionId;if(e!=null&&e.fileName){const w=e.fileName.match(/^([^/]+)\.jsonl$/);if(w)return w[1]}return null},[i,e]),f=b.useMemo(()=>d?t.filter(w=>w.parentSessionId===d):t,[t,d]),u=b.useMemo(()=>new Map(c.map(w=>[w.agentId,w])),[c]),m=b.useMemo(()=>{const w=new Set(f.map(y=>y.agentId));return c.filter(y=>!w.has(y.agentId))},[f,c]),p=b.useMemo(()=>[...f].sort((w,y)=>y.modifiedAt-w.modifiedAt),[f]),h=b.useMemo(()=>[...m].reverse(),[m]),g=f.length+m.length;if(g===0)return null;const x=w=>{ye(`/api/claude/tasks/${encodeURIComponent(n.sessionId)}/${encodeURIComponent(w)}`,{method:"DELETE"})},v=(i==null?void 0:i.agentId)??null;return r.jsxs("section",{children:[r.jsxs(Qn,{children:["Agents (",g,")"]}),i&&s&&r.jsxs(X,{type:"button",variant:"outline",size:"sm",onClick:()=>s(i.dirName,i.parentFileName),className:"mb-2 w-full justify-start",children:[r.jsx(Ze,{"data-icon":"inline-start",className:"rotate-180"}),"Back to Main Agent"]}),r.jsxs("div",{className:"flex max-h-[280px] flex-col gap-1.5 overflow-y-auto pr-0.5",children:[p.map((w,y)=>{const j=ic(w.preview??""),k=u.get(w.agentId);return r.jsx(op,{agentId:w.agentId,subagentType:(k==null?void 0:k.subagentType)??null,agentName:(k==null?void 0:k.agentName)??null,preview:(k==null?void 0:k.preview)||(j!==w.agentId?j:""),colorIndex:y,isViewing:v===w.agentId,isBackground:!0,status:w.isActive?"running":(k==null?void 0:k.status)==="failed"?"failed":"done",durationMs:k==null?void 0:k.durationMs,toolUseCount:k==null?void 0:k.toolUseCount,disabled:!s,onStop:w.isActive?()=>x(w.agentId):void 0,onClick:()=>s==null?void 0:s(w.dirName,w.fileName)},w.agentId)}),h.map((w,y)=>{const j=!!s&&!!d&&!!e&&!w.agentId.startsWith("tool:");return r.jsx(op,{agentId:w.agentId,subagentType:w.subagentType,agentName:w.agentName,preview:w.preview,colorIndex:p.length+y,isViewing:v===w.agentId,isBackground:w.isBackground,status:w.status,durationMs:w.durationMs,toolUseCount:w.toolUseCount,disabled:!j,onClick:()=>{j&&s(e.dirName,`${d}/subagents/agent-${w.agentId}.jsonl`)}},w.agentId)})]})]})}function L9(n,e){return`${n.id}-${e}`}function z9(n){const e=U.c(14),{turns:t,onJumpToTurn:s}=n,[o,i]=b.useState(null);if(t.length===0)return null;let a;e[0]!==t.length?(a=r.jsxs(Qn,{children:["Turns (",t.length,")"]}),e[0]=t.length,e[1]=a):a=e[1];let l;if(e[2]!==o||e[3]!==s||e[4]!==t){let f;e[6]!==o||e[7]!==s?(f=(u,m)=>{const p=pa(u.userMessage),h=o===m;return r.jsxs(X,{type:"button",variant:"ghost",onClick:()=>{i(m),s==null||s(m)},className:G("group h-auto w-full justify-start gap-2 px-2 py-1.5 text-left font-normal",h?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:[r.jsx("span",{className:"mt-0.5 shrink-0 font-mono text-xs text-muted-foreground",children:String(m+1).padStart(2,"0")}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs",children:p?mn(p,50):"(no message)"}),r.jsx("span",{className:"flex shrink-0 items-center gap-1",children:u.toolCalls.length>0&&r.jsx(Me,{variant:"secondary",className:"font-normal",children:u.toolCalls.length})})]},L9(u,m))},e[6]=o,e[7]=s,e[8]=f):f=e[8],l=t.map(f),e[2]=o,e[3]=s,e[4]=t,e[5]=l}else l=e[5];let c;e[9]!==l?(c=r.jsx("div",{className:"max-h-[400px] overflow-y-auto",children:r.jsx("div",{className:"flex flex-col gap-0.5 pr-2",children:l})}),e[9]=l,e[10]=c):c=e[10];let d;return e[11]!==a||e[12]!==c?(d=r.jsxs("section",{children:[a,c]}),e[11]=a,e[12]=c,e[13]=d):d=e[13],d}function F9(n){const e=n.input;return e.file_path&&typeof e.file_path=="string"?e.file_path.split("/").slice(-2).join("/"):e.command&&typeof e.command=="string"?mn(e.command,40):e.pattern&&typeof e.pattern=="string"?e.pattern:e.query&&typeof e.query=="string"?mn(e.query,40):e.url&&typeof e.url=="string"?mn(e.url,40):mn(hT(n),40)}function B9(n,e){return n.map(t=>{const s=t.tokenUsage;return!s||t.toolCalls.length===0?0:g0(e,t.model,s)/t.toolCalls.length})}function U9(n,e){const t=new Map;for(let s=0;s<n.length;s++)for(const o of n[s].toolCalls){const i=ya(o);t.has(i.label)||t.set(i.label,{calls:[],count:0,estimatedCost:0,styleName:i.styleName});const a=t.get(i.label);a.calls.push({tc:o,turnIndex:s}),a.count++,a.estimatedCost+=e[s]}return Array.from(t.entries()).sort((s,o)=>o[1].count-s[1].count)}function W9(n){const e=U.c(14),{turns:t,onJumpToTurn:s}=n,o=x0();let i;e[0]!==o||e[1]!==t?(i=B9(t,o),e[0]=o,e[1]=t,e[2]=i):i=e[2];const a=i;let l;e[3]!==a||e[4]!==t?(l=U9(t,a),e[3]=a,e[4]=t,e[5]=l):l=e[5];const c=l;if(c.length===0)return null;let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Qn,{children:"Tool Calls"}),e[6]=d):d=e[6];let f;if(e[7]!==s||e[8]!==c){let m;e[10]!==s?(m=p=>{const[h,g]=p;return r.jsxs(kt,{children:[r.jsxs(an,{className:"group flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-xs transition-colors hover:bg-muted",children:[r.jsx(Ze,{className:"size-3 shrink-0 text-muted-foreground transition-transform group-data-panel-open:rotate-90 motion-reduce:transition-none"}),r.jsx("span",{className:"font-medium text-foreground",children:h}),r.jsxs("span",{className:"ml-auto flex items-center gap-1.5",children:[g.estimatedCost>0&&r.jsx("span",{className:"font-mono text-xs text-warning",children:as(g.estimatedCost)}),r.jsx(Me,{variant:"secondary",className:"font-normal",children:g.count})]})]}),r.jsx(Nt,{children:r.jsxs("div",{className:"ml-4 flex flex-col gap-0.5 border-l border-border pl-2 pt-0.5",children:[g.calls.slice(0,50).map((x,v)=>{const{tc:w,turnIndex:y}=x,j=F9(w);return r.jsx("div",{children:r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:()=>s==null?void 0:s(y,w.id),className:G("h-auto w-full justify-start gap-1 px-1.5 py-0.5 text-left font-mono text-xs font-normal",w.isError?"text-destructive hover:bg-destructive/10":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:[w.isError&&r.jsx(wn,{className:"size-2.5 shrink-0 text-destructive","data-icon":"inline-start"}),r.jsx("span",{className:"truncate",children:j||w.id.slice(0,8)})]})},`${w.id}-${v}`)}),g.calls.length>50&&r.jsxs("div",{className:"px-1.5 py-0.5 text-xs text-muted-foreground",children:["+",g.calls.length-50," more"]})]})})]},h)},e[10]=s,e[11]=m):m=e[11],f=c.map(m),e[7]=s,e[8]=c,e[9]=f}else f=e[9];let u;return e[12]!==f?(u=r.jsxs("section",{children:[d,r.jsx("div",{className:"max-h-[320px] overflow-y-auto",children:r.jsx("div",{className:"flex flex-col gap-0.5 pr-2",children:f})})]}),e[12]=f,e[13]=u):u=e[13],u}function H9(n){const e=U.c(19),{searchInputRef:t}=n,{state:s,dispatch:o}=Rt(),{searchQuery:i,expandAll:a}=s,{actions:l}=it(),{handleToggleExpandAll:c}=l;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Session details"}),e[0]=d):d=e[0];const f=a?"Collapse all":"Expand all";let u;e[1]!==a?(u=a?r.jsx(qi,{"data-icon":"inline-start"}):r.jsx(Hi,{"data-icon":"inline-start"}),e[1]=a,e[2]=u):u=e[2];let m;e[3]!==c||e[4]!==f||e[5]!==u?(m=r.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[d,r.jsx(X,{variant:"ghost",size:"icon-sm",className:"shrink-0",onClick:c,"aria-label":f,children:u})]}),e[3]=c,e[4]=f,e[5]=u,e[6]=m):m=e[6];const p=i??"";let h;e[7]!==o?(h=y=>o({type:"SET_SEARCH_QUERY",value:y.target.value}),e[7]=o,e[8]=h):h=e[8];let g;e[9]!==t||e[10]!==p||e[11]!==h?(g=r.jsx(es,{ref:t,type:"text",value:p,onChange:h,placeholder:"Search conversation","aria-label":"Search conversation"}),e[9]=t,e[10]=p,e[11]=h,e[12]=g):g=e[12];let x;e[13]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(yn,{align:"inline-start",children:r.jsx(xn,{})}),e[13]=x):x=e[13];let v;e[14]!==g?(v=r.jsxs(Zn,{children:[g,x]}),e[14]=g,e[15]=v):v=e[15];let w;return e[16]!==v||e[17]!==m?(w=r.jsxs("div",{className:"sticky top-0 border-b bg-background px-3 py-3",children:[m,v]}),e[16]=v,e[17]=m,e[18]=w):w=e[18],w}const v0=b.memo(function(e){const t=U.c(40),{onJumpToTurn:s,onToggleServer:o,onServersChanged:i,searchInputRef:a,onLoadSession:l,backgroundAgents:c}=e,{isMobile:d}=Rt(),{session:f,sessionSource:u}=it(),m=f,{turns:p}=m,h=d?"mobile-scroll w-full flex-1":"view-transition-right-panel panel-enter-right w-[320px] border-l";let g;t[0]!==h?(g=G("h-full min-h-0 shrink-0 overflow-y-auto bg-background",h),t[0]=h,t[1]=g):g=t[1];let x;t[2]!==a?(x=a&&r.jsx(H9,{searchInputRef:a}),t[2]=a,t[3]=x):x=t[3];const v=d?"p-4":"p-3";let w;t[4]!==v?(w=G(v),t[4]=v,t[5]=w):w=t[5];let y;t[6]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsxs(mg,{variant:"line",className:"grid w-full grid-cols-4",children:[r.jsx($o,{value:"activity",children:"Activity"}),r.jsx($o,{value:"agents",children:"Agents"}),r.jsx($o,{value:"metrics",children:"Metrics"}),r.jsx($o,{value:"issues",children:"Issues"})]}),t[6]=y):y=t[6];let j;t[7]!==s||t[8]!==p?(j=r.jsxs(Oo,{value:"activity",className:"flex flex-col gap-6 pt-3",children:[r.jsx(z9,{turns:p,onJumpToTurn:s}),r.jsx(W9,{turns:p,onJumpToTurn:s})]}),t[7]=s,t[8]=p,t[9]=j):j=t[9];let k;t[10]!==i||t[11]!==o||t[12]!==m.cwd||t[13]!==p?(k=r.jsx(xg,{cwd:m.cwd,turns:p,onToggleServer:o,onServersChanged:i}),t[10]=i,t[11]=o,t[12]=m.cwd,t[13]=p,t[14]=k):k=t[14];let N;t[15]!==c?(N=c??[],t[15]=c,t[16]=N):N=t[16];let C;t[17]!==l||t[18]!==m||t[19]!==u||t[20]!==N?(C=r.jsx(D9,{session:m,sessionSource:u,bgAgents:N,onLoadSession:l}),t[17]=l,t[18]=m,t[19]=u,t[20]=N,t[21]=C):C=t[21];let S;t[22]!==C||t[23]!==k?(S=r.jsxs(Oo,{value:"agents",className:"flex flex-col gap-6 pt-3",children:[k,C]}),t[22]=C,t[23]=k,t[24]=S):S=t[24];let _;t[25]!==p?(_=r.jsxs(Oo,{value:"metrics",className:"flex flex-col gap-6 pt-3",children:[r.jsx(h9,{turns:p}),r.jsx(b9,{turns:p}),r.jsx(y9,{turns:p}),r.jsx(E9,{turns:p})]}),t[25]=p,t[26]=_):_=t[26];let P;t[27]!==s||t[28]!==p?(P=r.jsx(Oo,{value:"issues",className:"flex flex-col gap-6 pt-3",children:r.jsx(M9,{turns:p,onJumpToTurn:s})}),t[27]=s,t[28]=p,t[29]=P):P=t[29];let A;t[30]!==S||t[31]!==_||t[32]!==P||t[33]!==w||t[34]!==j?(A=r.jsxs(fg,{defaultValue:"activity",className:w,children:[y,j,S,_,P]}),t[30]=S,t[31]=_,t[32]=P,t[33]=w,t[34]=j,t[35]=A):A=t[35];let E;return t[36]!==A||t[37]!==g||t[38]!==x?(E=r.jsxs("aside",{className:g,children:[x,A]}),t[36]=A,t[37]=g,t[38]=x,t[39]=E):E=t[39],E});function K9(n){const e=U.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 o;e[3]!==t?(o=G("flex h-full w-full aria-[orientation=vertical]:flex-col",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Vv,{"data-slot":"resizable-panel-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function rp(n){const e=U.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=r.jsx(qv,{"data-slot":"resizable-panel",...t}),e[2]=t,e[3]=s):s=e[3],s}function q9(n){const e=U.c(12);let t,s,o;e[0]!==n?({withHandle:o,className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==t?(i=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]=i):i=e[5];let a;e[6]!==o?(a=o&&r.jsx("div",{className:"z-10 flex h-6 w-1 shrink-0 rounded-lg bg-border"}),e[6]=o,e[7]=a):a=e[7];let l;return e[8]!==s||e[9]!==i||e[10]!==a?(l=r.jsx(Kv,{"data-slot":"resizable-handle",className:i,...s,children:a}),e[8]=s,e[9]=i,e[10]=a,e[11]=l):l=e[11],l}function Ca(n){const e=U.c(4),{floating:t,children:s}=n;if(t){let i;return e[0]!==s?(i=r.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 z-20 flex justify-center",children:r.jsx("div",{className:"pointer-events-auto w-full max-w-[var(--chat-width)] border-t bg-background px-3 pt-3",children:s})}),e[0]=s,e[1]=i):i=e[1],i}let o;return e[2]!==s?(o=r.jsx("div",{className:"flex w-full shrink-0 justify-center",children:r.jsx("div",{className:"w-full max-w-[var(--chat-width)] px-3",children:s})}),e[2]=s,e[3]=o):o=e[3],o}function y0(n){const e=U.c(11),{projectPath:t}=n;let s;e[0]!==t?(s=t?zn(t):null,e[0]=t,e[1]=s):s=e[1];const o=s;let i;e[2]!==o?(i=o?r.jsxs(r.Fragment,{children:["What should we build in"," ",r.jsx("span",{children:o}),"?"]}):"What should we build?",e[2]=o,e[3]=i):i=e[3];let a;e[4]!==i?(a=r.jsx("h1",{className:"text-balance text-2xl font-semibold tracking-tight text-foreground",children:i}),e[4]=i,e[5]=a):a=e[5];let l;e[6]!==t?(l=t&&r.jsx("p",{className:"font-mono text-xs text-muted-foreground",children:ea(t)}),e[6]=t,e[7]=l):l=e[7];let c;return e[8]!==a||e[9]!==l?(c=r.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 text-center",children:[a,l]}),e[8]=a,e[9]=l,e[10]=c):c=e[10],c}function V9(n){const e=U.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 o;e[3]!==t?(o=G(t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function G9(n){const e=U.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 o;e[3]!==t?(o=G("flex flex-wrap items-center gap-1.5 text-sm wrap-break-word text-muted-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("ol",{"data-slot":"breadcrumb-list",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function ip(n){const e=U.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 o;e[3]!==t?(o=G("inline-flex items-center gap-1",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("li",{"data-slot":"breadcrumb-item",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Y9(n){const e=U.c(10);let t,s,o,i;if(e[0]!==n){const{className:c,render:d,...f}=n;t=d,i=Hp,s="a",o=Wp({className:G("transition-colors hover:text-foreground",c)},f),e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i}else t=e[1],s=e[2],o=e[3],i=e[4];let a;e[5]===Symbol.for("react.memo_cache_sentinel")?(a={slot:"breadcrumb-link"},e[5]=a):a=e[5];let l;return e[6]!==t||e[7]!==s||e[8]!==o?(l={defaultTagName:s,props:o,render:t,state:a},e[6]=t,e[7]=s,e[8]=o,e[9]=l):l=e[9],i(l)}function X9(n){const e=U.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 o;e[3]!==t?(o=G("font-normal text-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("span",{"data-slot":"breadcrumb-page",role:"link","aria-disabled":"true","aria-current":"page",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function J9(n){const e=U.c(12);let t,s,o;e[0]!==n?({children:t,className:s,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==s?(i=G("[&>svg]:size-3.5",s),e[4]=s,e[5]=i):i=e[5];let a;e[6]!==t?(a=t??r.jsx(Ze,{}),e[6]=t,e[7]=a):a=e[7];let l;return e[8]!==o||e[9]!==i||e[10]!==a?(l=r.jsx("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:i,...o,children:a}),e[8]=o,e[9]=i,e[10]=a,e[11]=l):l=e[11],l}function w0(n){const e=U.c(51),{children:t,sessionLabel:s,customName:o,onDuplicate:i,onDelete:a,onRename:l}=n,[c,d]=b.useState(!1),[f,u]=b.useState(!1),[m,p]=b.useState(""),h=b.useRef(null);let g;e[0]!==o?(g=function(){p(o||""),u(!0),requestAnimationFrame(()=>{var H;return(H=h.current)==null?void 0:H.select()})},e[0]=o,e[1]=g):g=e[1];const x=g;let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx("div",{className:"w-full"}),e[2]=v):v=e[2];let w;e[3]!==t?(w=r.jsx(xa,{render:v,children:t}),e[3]=t,e[4]=w):w=e[4];let y;e[5]!==i||e[6]!==l||e[7]!==x?(y=(l||i)&&r.jsxs(ao,{children:[l&&r.jsxs(Yt,{onClick:x,children:[r.jsx(Ls,{"data-icon":"inline-start"}),"Rename session"]}),i&&r.jsxs(Yt,{onClick:i,children:[r.jsx(En,{"data-icon":"inline-start"}),"Duplicate session"]})]}),e[5]=i,e[6]=l,e[7]=x,e[8]=y):y=e[8];let j;e[9]!==a||e[10]!==i||e[11]!==l?(j=a&&r.jsxs(r.Fragment,{children:[(i||l)&&r.jsx(lr,{}),r.jsx(ao,{children:r.jsxs(Yt,{variant:"destructive",onClick:()=>d(!0),children:[r.jsx(Bi,{"data-icon":"inline-start"}),"Delete session"]})})]}),e[9]=a,e[10]=i,e[11]=l,e[12]=j):j=e[12];let k;e[13]!==y||e[14]!==j?(k=r.jsxs(ba,{className:"min-w-44",children:[y,j]}),e[13]=y,e[14]=j,e[15]=k):k=e[15];let N;e[16]!==w||e[17]!==k?(N=r.jsxs(ga,{children:[w,k]}),e[16]=w,e[17]=k,e[18]=N):N=e[18];let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(zc,{children:"Delete session?"}),e[19]=C):C=e[19];let S;e[20]!==s?(S=r.jsxs(Dc,{children:[C,r.jsxs(Fc,{children:["This will permanently delete"," ",r.jsx("span",{className:"font-medium text-foreground",children:s}),". This action cannot be undone."]})]}),e[20]=s,e[21]=S):S=e[21];let _;e[22]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(Uc,{size:"sm",children:"Cancel"}),e[22]=_):_=e[22];let P;e[23]!==a?(P=r.jsxs(Lc,{children:[_,r.jsx(Bc,{variant:"destructive",size:"sm",onClick:()=>{a==null||a(),d(!1)},children:"Delete"})]}),e[23]=a,e[24]=P):P=e[24];let A;e[25]!==P||e[26]!==S?(A=r.jsxs(Oc,{children:[S,P]}),e[25]=P,e[26]=S,e[27]=A):A=e[27];let E;e[28]!==c||e[29]!==A?(E=r.jsx($c,{open:c,onOpenChange:d,children:A}),e[28]=c,e[29]=A,e[30]=E):E=e[30];let T;e[31]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsxs(Ss,{children:[r.jsx(Xn,{className:"text-foreground",children:"Rename session"}),r.jsx(Jn,{className:"text-muted-foreground",children:"Give this session a custom name. Clear to reset to default."})]}),e[31]=T):T=e[31];let M;e[32]!==l||e[33]!==m?(M=F=>{F.preventDefault(),l==null||l(m),u(!1)},e[32]=l,e[33]=m,e[34]=M):M=e[34];let I;e[35]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(xt,{htmlFor:"session-rename",children:"Session name"}),e[35]=I):I=e[35];let R;e[36]===Symbol.for("react.memo_cache_sentinel")?(R=F=>p(F.target.value),e[36]=R):R=e[36];let $;e[37]!==m||e[38]!==s?($=r.jsxs(gt,{children:[I,r.jsx(Ot,{id:"session-rename",ref:h,value:m,onChange:R,placeholder:s})]}),e[37]=m,e[38]=s,e[39]=$):$=e[39];let D;e[40]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsxs(Kh,{children:[r.jsx(X,{type:"button",variant:"ghost",size:"sm",onClick:()=>u(!1),children:"Cancel"}),r.jsx(X,{type:"submit",size:"sm",children:"Save"})]}),e[40]=D):D=e[40];let O;e[41]!==M||e[42]!==$?(O=r.jsxs(Yn,{className:"sm:max-w-md",children:[T,r.jsxs("form",{className:"flex flex-col gap-4",onSubmit:M,children:[$,D]})]}),e[41]=M,e[42]=$,e[43]=O):O=e[43];let L;e[44]!==f||e[45]!==O?(L=r.jsx(Gn,{open:f,onOpenChange:u,children:O}),e[44]=f,e[45]=O,e[46]=L):L=e[46];let z;return e[47]!==E||e[48]!==L||e[49]!==N?(z=r.jsxs(r.Fragment,{children:[N,E,L]}),e[47]=E,e[48]=L,e[49]=N,e[50]=z):z=e[50],z}const j0="session-custom-names";function S0(){try{const n=localStorage.getItem(Lt(j0));return n?JSON.parse(n):{}}catch{return{}}}function Q9(n){localStorage.setItem(Lt(j0),JSON.stringify(n))}let Ri=S0();const Mi=new Set;if(typeof window<"u"){const n=()=>{Ri=S0();for(const e of Mi)e()};window.addEventListener("cogpit-device-changed",n),window.addEventListener("cogpit-identity-changed",n)}function Z9(n){return Mi.add(n),()=>{Mi.delete(n)}}function eP(){return Ri}function ac(n,e){const t={...Ri},s=e.trim();s?t[n]=s:delete t[n],Q9(t),Ri=t;for(const o of Mi)o()}function k0(){const n=U.c(2),e=b.useSyncExternalStore(Z9,eP);let t;return n[0]!==e?(t={names:e,rename:ac},n[0]=e,n[1]=t):t=n[1],t}function is(n){const e=U.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 o;e[3]!==t?(o=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",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"skeleton",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function N0(n){const e=U.c(16),{value:t,onChange:s,placeholder:o,loading:i}=n,a=i===void 0?!1:i;let l;e[0]!==a?(l=r.jsx(yn,{children:a?r.jsx(rt,{className:"animate-spin","aria-label":"Searching session history"}):r.jsx(xn,{"aria-hidden":"true"})}),e[0]=a,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 d;e[4]!==a||e[5]!==o||e[6]!==c||e[7]!==t?(d=r.jsx(es,{type:"search","aria-busy":a,"aria-label":o,value:t,onChange:c,placeholder:o}),e[4]=a,e[5]=o,e[6]=c,e[7]=t,e[8]=d):d=e[8];let f;e[9]!==s||e[10]!==t?(f=t&&r.jsx(yn,{align:"inline-end",children:r.jsx(Cr,{"aria-label":"Clear search",onClick:()=>s(""),size:"icon-xs",children:r.jsx(jt,{})})}),e[9]=s,e[10]=t,e[11]=f):f=e[11];let u;return e[12]!==l||e[13]!==d||e[14]!==f?(u=r.jsxs(Zn,{className:"w-full sm:max-w-sm",children:[l,d,f]}),e[12]=l,e[13]=d,e[14]=f,e[15]=u):u=e[15],u}function C0(n){const e=U.c(10),{message:t,onRetry:s}=n;let o,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(wn,{"aria-hidden":"true"}),i=r.jsx(Dt,{children:"Could not load this data"}),e[0]=o,e[1]=i):(o=e[0],i=e[1]);let a;e[2]!==t?(a=r.jsx(_t,{children:t}),e[2]=t,e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Qt,{"data-icon":"inline-start"}),e[4]=l):l=e[4];let c;e[5]!==s?(c=r.jsx(xs,{children:r.jsxs(X,{variant:"ghost",size:"xs",onClick:s,children:[l,"Retry"]})}),e[5]=s,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=r.jsxs(Ct,{variant:"destructive",children:[o,i,a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d}function _0(n){const e=U.c(5),{count:t,includeMessagePlaceholder:s}=n,o=t===void 0?4:t,i=s===void 0?!1:s;let a;if(e[0]!==o||e[1]!==i){let l;e[3]!==i?(l=(c,d)=>r.jsxs("div",{children:[d>0&&r.jsx(It,{}),r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3.5",children:[r.jsx(is,{className:"size-8 shrink-0 rounded-md"}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[r.jsx(is,{className:"h-4 w-40 max-w-full"}),i&&r.jsx(is,{className:"h-3 w-72 max-w-full"}),r.jsx(is,{className:"h-3 w-52 max-w-full"})]}),r.jsx(is,{className:"hidden h-5 w-20 sm:block"})]})]},d),e[3]=i,e[4]=l):l=e[4],a=r.jsx("div",{className:"overflow-hidden rounded-lg border","aria-hidden":"true",children:Array.from({length:o},l)}),e[0]=o,e[1]=i,e[2]=a}else a=e[2];return a}function fr(n){return n==="idle"||n==="completed"}function Pd(n){return fr(n)?"text-success":n==="thinking"||n==="deferred"?"text-warning":"text-info"}const Rs={attention:"bg-warning",working:"bg-success ring-2 ring-success/30",idle:"bg-success/40"},tP=/(?:https?:\/\/)?github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/i,nP=/^([\w.-]+(?:\/[\w.-]+)?)#(\d+)$/,sP=/(?:^|\s)#(\d+)(?=\s|$)/,oP=/^(?:pr|pull\s+request)\s*#?(\d+)$/i;function ri(n){const e=Number(n);return Number.isSafeInteger(e)&&e>0?e:null}function rP(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 T0(n){const e=n.trim();if(!e)return null;const t=tP.exec(e);if(t){const l=ri(t[3]);return l===null?null:{number:l,repoHint:`${t[1]}/${t[2]}`.toLowerCase()}}const s=nP.exec(e);if(s){const l=ri(s[2]);return l===null?null:{number:l,repoHint:s[1].toLowerCase()}}const o=sP.exec(e);if(o){const l=ri(o[1]);if(l===null)return null;const c=`${e.slice(0,o.index)} ${e.slice(o.index+o[0].length)}`;return{number:l,repoHint:rP(c)}}const i=oP.exec(e);if(!i)return null;const a=ri(i[1]);return a===null?null:{number:a,repoHint:null}}function ap(n,e){if(!n)return!1;const t=n.toLowerCase().replace(/\.git$/,"");return t===e||t.endsWith(`/${e}`)||e.endsWith(`/${t}`)}function iP(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(o=>o.replace(/[^a-z0-9]/g,"")===s)}function aP(n,e,t=[]){if(n.number!==e.number)return!1;const s=e.repoHint;return s?n.repo&&s.includes("/")?ap(n.repo,s):ap(n.repo,s)?!0:t.some(o=>iP(o,s)):!0}function E0(n,e,t=[]){var i;const s=T0(e);if(s){const a=[n.cwd,n.projectShortName,...t];return((i=n.pullRequests)==null?void 0:i.some(l=>aP(l,s,a)))??!1}const o=e.trim().toLowerCase();return o?[...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(a=>a==null?void 0:a.toLowerCase().includes(o)):!0}const lP=120*1e3;function P0(n){return n?Date.now()-new Date(n).getTime()<lP:!1}function A0(n,e){const t=n.teamName?n.agentName:"",s=e||n.aiTitle||n.name||t||n.slug||n.firstUserMessage||n.customTitle;return s?mn(s,70):mn(n.sessionId,16)}function lp(n){return n.trim().replace(/\s+/g," ").slice(0,40).toLowerCase()}function cP(n,e){const t=(n.lastUserMessage||n.firstUserMessage||"").trim();return!t||lp(t)===lp(e)?null:mn(t,220)}function dP(n,e){return E0(n,e)}function uP(n,e){if(!n||!e)return null;const t=new Date(e).getTime()-new Date(n).getTime();return t>=6e4?Tn(t):null}function fP(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(`
|
|
120
|
+
`)}function mP(n){var t;const e=n.cwd?(t=ta(n.cwd))==null?void 0:t.worktreeName:void 0;return e?{icon:Gv,label:e,title:n.cwd}:n.gitBranch?{icon:bo,label:n.gitBranch}:null}function pP(n,e){return n.agentStatus==="deferred"?"attention":e?fr(n.agentStatus)?"idle":"working":null}function hP(n){const e=U.c(20),{session:t,live:s}=n;if(t.agentStatus==="deferred"){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(Me,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"Needs review"}),e[0]=o):o=e[0],o}if(s){const o=fr(t.agentStatus);let i;e[1]!==t.agentPendingAgents||e[2]!==t.agentStatus||e[3]!==t.agentTerminalReason||e[4]!==t.agentToolName?(i=Rr(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]=i):i=e[5];const a=i;let l;e[6]!==t.agentStatus?(l=Pd(t.agentStatus),e[6]=t.agentStatus,e[7]=l):l=e[7];const c=o?"bg-success/60":"bg-current";let d;e[8]!==c?(d=G("size-1.5 rounded-full",c),e[8]=c,e[9]=d):d=e[9];let f;e[10]!==d?(f=r.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:d}),e[10]=d,e[11]=f):f=e[11];let u;return e[12]!==a||e[13]!==l||e[14]!==f?(u=r.jsxs(Me,{variant:"secondary",className:l,children:[f,a]}),e[12]=a,e[13]=l,e[14]=f,e[15]=u):u=e[15],u}if(t.agentTerminalReason){let o;e[16]!==t.agentTerminalReason?(o=kd(t.agentTerminalReason),e[16]=t.agentTerminalReason,e[17]=o):o=e[17];let i;return e[18]!==o?(i=r.jsx(Me,{variant:"outline",className:"max-w-44 truncate text-warning",children:o}),e[18]=o,e[19]=i):i=e[19],i}return null}function kl(n){const e=U.c(9),{icon:t,title:s,className:o,children:i}=n;let a;e[0]!==o?(a=G("flex items-center gap-1",o),e[0]=o,e[1]=a):a=e[1];let l;e[2]!==t?(l=r.jsx(t,{className:"size-3 shrink-0"}),e[2]=t,e[3]=l):l=e[3];let c;return e[4]!==i||e[5]!==a||e[6]!==l||e[7]!==s?(c=r.jsxs("span",{className:a,title:s,children:[l,i]}),e[4]=i,e[5]=a,e[6]=l,e[7]=s,e[8]=c):c=e[8],c}function gP(n){const e=U.c(99),{session:t,customName:s,onSelect:o}=n,i=t.lastActivityAt||t.lastModified;let a,l;e[0]!==i||e[1]!==t?(a=P0(i),l=pP(t,a),e[0]=i,e[1]=t,e[2]=a,e[3]=l):(a=e[2],l=e[3]);const c=l,d=t.teamName?t.agentName:void 0;let f,u,m,p,h,g,x,v,w,y,j,k,N,C;if(e[4]!==s||e[5]!==c||e[6]!==i||e[7]!==a||e[8]!==o||e[9]!==t||e[10]!==d){const $=mP(t);let D;e[25]!==i||e[26]!==t.timestamp?(D=uP(t.timestamp,i),e[25]=i,e[26]=t.timestamp,e[27]=D):D=e[27];const O=D,L=t.turnCount??0;let z,F;e[28]!==s||e[29]!==t?(F=A0(t,s),z=cP(t,F),e[28]=s,e[29]=t,e[30]=z,e[31]=F):(z=e[30],F=e[31]);const H=z;g="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",u=o,e[32]!==t?(m=fP(t),e[32]=t,e[33]=m):m=e[33],p="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 B;e[34]===Symbol.for("react.memo_cache_sentinel")?(B=r.jsx(Fu,{className:"size-4"}),e[34]=B):B=e[34];let W;e[35]!==c?(W=c&&r.jsx("span",{"aria-hidden":"true","data-status-dot":c,className:G("absolute -top-1 -right-1 size-2 rounded-full ring-2 ring-card",Rs[c])}),e[35]=c,e[36]=W):W=e[36],e[37]!==W?(h=r.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:[B,W]}),e[37]=W,e[38]=h):h=e[38],k="flex min-w-0 flex-1 flex-col gap-1";let K;e[39]!==F?(K=r.jsx("span",{className:"truncate text-sm font-medium",children:F}),e[39]=F,e[40]=K):K=e[40];let V;e[41]!==d?(V=d&&r.jsxs(Me,{variant:"outline",className:"shrink-0",children:[r.jsx(lo,{"data-icon":"inline-start"}),mn(d,18)]}),e[41]=d,e[42]=V):V=e[42];let Y;e[43]!==t.branchedFrom?(Y=t.branchedFrom&&r.jsxs(Me,{variant:"outline",className:"shrink-0",title:"Branched from another session",children:[r.jsx(jc,{"data-icon":"inline-start"}),"branch"]}),e[43]=t.branchedFrom,e[44]=Y):Y=e[44];let q;e[45]!==a||e[46]!==t?(q=r.jsx(hP,{session:t,live:a}),e[45]=a,e[46]=t,e[47]=q):q=e[47];let J;e[48]!==i?(J=i&&r.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:jr(i)}),e[48]=i,e[49]=J):J=e[49];let Z;e[50]!==q||e[51]!==J?(Z=r.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2",children:[q,J]}),e[50]=q,e[51]=J,e[52]=Z):Z=e[52],e[53]!==K||e[54]!==V||e[55]!==Y||e[56]!==Z?(N=r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[K,V,Y,Z]}),e[53]=K,e[54]=V,e[55]=Y,e[56]=Z,e[57]=N):N=e[57],e[58]!==H?(C=H&&r.jsx("span",{className:"line-clamp-1 text-sm text-muted-foreground",children:H}),e[58]=H,e[59]=C):C=e[59],x="flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",e[60]!==t.model?(v=t.model&&r.jsx(Me,{variant:"outline",children:Zi(t.model)}),e[60]=t.model,e[61]=v):v=e[61],e[62]!==L?(w=L>0&&r.jsxs(kl,{icon:Fu,children:[L," ",L===1?"turn":"turns"]}),e[62]=L,e[63]=w):w=e[63],e[64]!==O?(y=O&&r.jsx(kl,{icon:Ms,title:"First prompt to last activity",children:O}),e[64]=O,e[65]=y):y=e[65],j=$&&r.jsx(kl,{icon:$.icon,className:"max-w-40 truncate",title:$.title,children:mn($.label,22)}),e[4]=s,e[5]=c,e[6]=i,e[7]=a,e[8]=o,e[9]=t,e[10]=d,e[11]=f,e[12]=u,e[13]=m,e[14]=p,e[15]=h,e[16]=g,e[17]=x,e[18]=v,e[19]=w,e[20]=y,e[21]=j,e[22]=k,e[23]=N,e[24]=C}else f=e[11],u=e[12],m=e[13],p=e[14],h=e[15],g=e[16],x=e[17],v=e[18],w=e[19],y=e[20],j=e[21],k=e[22],N=e[23],C=e[24];let S;e[66]!==t.size?(S=Qh(t.size),e[66]=t.size,e[67]=S):S=e[67];let _;e[68]!==S?(_=r.jsx("span",{children:S}),e[68]=S,e[69]=_):_=e[69];let P;e[70]!==_||e[71]!==x||e[72]!==v||e[73]!==w||e[74]!==y||e[75]!==j?(P=r.jsxs("span",{className:x,children:[v,w,y,j,_]}),e[70]=_,e[71]=x,e[72]=v,e[73]=w,e[74]=y,e[75]=j,e[76]=P):P=e[76];let A;e[77]!==P||e[78]!==k||e[79]!==N||e[80]!==C?(A=r.jsxs("span",{className:k,children:[N,C,P]}),e[77]=P,e[78]=k,e[79]=N,e[80]=C,e[81]=A):A=e[81];let E;e[82]!==f||e[83]!==u||e[84]!==m||e[85]!==p||e[86]!==h||e[87]!==A?(E=r.jsxs("button",{type:f,onClick:u,title:m,className:p,children:[h,A]}),e[82]=f,e[83]=u,e[84]=m,e[85]=p,e[86]=h,e[87]=A,e[88]=E):E=e[88];let T;e[89]!==t.matchedPullRequestNumber||e[90]!==t.pullRequests?(T=t.matchedPullRequestNumber?r.jsxs(Me,{variant:"outline",children:["Matched #",t.matchedPullRequestNumber]}):r.jsx(Na,{pullRequests:t.pullRequests,max:2,compact:!0}),e[89]=t.matchedPullRequestNumber,e[90]=t.pullRequests,e[91]=T):T=e[91];let M;e[92]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(Ze,{className:"size-4 text-muted-foreground transition-transform group-hover:translate-x-0.5"}),e[92]=M):M=e[92];let I;e[93]!==T?(I=r.jsxs("span",{className:"flex shrink-0 items-center gap-2 pt-1.5",children:[T,M]}),e[93]=T,e[94]=I):I=e[94];let R;return e[95]!==g||e[96]!==E||e[97]!==I?(R=r.jsxs("div",{className:g,children:[E,I]}),e[95]=g,e[96]=E,e[97]=I,e[98]=R):R=e[98],R}function xP(n){const e=U.c(61),{selectedProject:t,sessions:s,sessionsTotal:o,sessionsLoading:i,searchLoading:a,searchFilter:l,setSearchFilter:c,filteredSessions:d,fetchError:f,onSelectSession:u,onNewSession:m,creatingSession:p,onDuplicateSession:h,onDeleteSession:g,onBack:x,onRetryFetch:v,loadMoreSessions:w}=n,{names:y,rename:j}=k0();let k;e[0]!==t.path?(k=zn(t.path),e[0]=t.path,e[1]=k):k=e[1];const N=k;let C;e[2]!==x?(C=r.jsx(ip,{children:r.jsx(Y9,{render:r.jsx("button",{type:"button",onClick:x}),children:"Projects"})}),e[2]=x,e[3]=C):C=e[3];let S;e[4]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx(J9,{}),e[4]=S):S=e[4];let _;e[5]!==N?(_=r.jsx(ip,{className:"min-w-0",children:r.jsx(X9,{className:"truncate",children:N})}),e[5]=N,e[6]=_):_=e[6];let P;e[7]!==C||e[8]!==_?(P=r.jsx(V9,{children:r.jsxs(G9,{children:[C,S,_]})}),e[7]=C,e[8]=_,e[9]=P):P=e[9];let A;e[10]!==N?(A=r.jsx("h1",{className:"truncate text-2xl font-semibold tracking-tight",children:N}),e[10]=N,e[11]=A):A=e[11];let E;e[12]!==o?(E=r.jsx(Me,{variant:"secondary",children:o}),e[12]=o,e[13]=E):E=e[13];let T;e[14]!==A||e[15]!==E?(T=r.jsxs("div",{className:"flex items-center gap-2",children:[A,E]}),e[14]=A,e[15]=E,e[16]=T):T=e[16];let M;e[17]!==t.path?(M=ea(t.path),e[17]=t.path,e[18]=M):M=e[18];let I;e[19]!==M?(I=r.jsx("p",{className:"truncate text-sm text-muted-foreground",children:M}),e[19]=M,e[20]=I):I=e[20];let R;e[21]!==I||e[22]!==T?(R=r.jsxs("header",{className:"flex min-w-0 flex-col gap-1",children:[T,I]}),e[21]=I,e[22]=T,e[23]=R):R=e[23];let $;e[24]!==l||e[25]!==a||e[26]!==c?($=r.jsx(N0,{value:l,onChange:c,placeholder:"Search sessions or PRs...",loading:a}),e[24]=l,e[25]=a,e[26]=c,e[27]=$):$=e[27];let D;e[28]!==p||e[29]!==m||e[30]!==t.dirName||e[31]!==t.path?(D=m&&r.jsxs(X,{size:"sm",disabled:p,onClick:()=>m(t.dirName,t.path),children:[p?r.jsx(Ut,{"data-icon":"inline-start"}):r.jsx(_n,{"data-icon":"inline-start"}),"New Session"]}),e[28]=p,e[29]=m,e[30]=t.dirName,e[31]=t.path,e[32]=D):D=e[32];let O;e[33]!==$||e[34]!==D?(O=r.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[$,D]}),e[33]=$,e[34]=D,e[35]=O):O=e[35];let L;e[36]!==f||e[37]!==v?(L=f&&r.jsx(C0,{message:f,onRetry:v}),e[36]=f,e[37]=v,e[38]=L):L=e[38];let z;e[39]!==d||e[40]!==w||e[41]!==g||e[42]!==h||e[43]!==u||e[44]!==j||e[45]!==l||e[46]!==a||e[47]!==t.dirName||e[48]!==y||e[49]!==s||e[50]!==i||e[51]!==o?(z=(i||a)&&d.length===0?r.jsx(_0,{includeMessagePlaceholder:!0}):d.length===0?r.jsx(Hn,{className:"min-h-72 border",children:r.jsxs(Kn,{children:[r.jsx(js,{variant:"icon",children:r.jsx(Vi,{})}),r.jsx(qn,{children:l?"No sessions match your search":"No sessions yet"}),r.jsx(Vn,{children:l?"Try #157, honest-cms #157, or paste a PR URL.":"Start a session in this project and it will appear here."})]})}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"overflow-hidden rounded-lg border bg-card",children:d.map((B,W)=>r.jsxs(b.Fragment,{children:[W>0&&r.jsx(It,{}),r.jsx(w0,{sessionLabel:A0(B),customName:y[B.sessionId],onRename:K=>j(B.sessionId,K),onDuplicate:h?()=>h(t.dirName,B.fileName):void 0,onDelete:g?()=>g(t.dirName,B.fileName):void 0,children:r.jsx(gP,{session:B,customName:y[B.sessionId],onSelect:()=>u(t.dirName,B.fileName)})})]},B.fileName))}),s.length<o&&!l&&r.jsx("div",{className:"flex justify-center",children:r.jsxs(X,{variant:"outline",size:"sm",disabled:i,onClick:w,children:[i&&r.jsx(Ut,{"data-icon":"inline-start"}),i?"Loading...":"Load more sessions"]})})]}),e[39]=d,e[40]=w,e[41]=g,e[42]=h,e[43]=u,e[44]=j,e[45]=l,e[46]=a,e[47]=t.dirName,e[48]=y,e[49]=s,e[50]=i,e[51]=o,e[52]=z):z=e[52];let F;e[53]!==O||e[54]!==L||e[55]!==z?(F=r.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Sessions",children:[O,L,z]}),e[53]=O,e[54]=L,e[55]=z,e[56]=F):F=e[56];let H;return e[57]!==R||e[58]!==F||e[59]!==P?(H=r.jsx(Nr,{className:"h-full",children:r.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:[P,R,F]})}),e[57]=R,e[58]=F,e[59]=P,e[60]=H):H=e[60],H}function bP(n){const e=U.c(13),{projectPath:t,fallback:s,className:o}=n,[i,a]=b.useState(null);if(!t||i===t){let m;return e[0]!==s?(m=r.jsx(r.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=vr(l),e[2]=l,e[3]=c):c=e[3];let d;e[4]!==t?(d=()=>a(t),e[4]=t,e[5]=d):d=e[5];let f;e[6]!==o?(f=G("size-3.5 shrink-0 rounded-[3px] object-contain",o),e[6]=o,e[7]=f):f=e[7];let u;return e[8]!==t||e[9]!==c||e[10]!==d||e[11]!==f?(u=r.jsx("img",{src:c,alt:"","aria-hidden":!0,loading:"lazy",decoding:"async",onError:d,className:f},t),e[8]=t,e[9]=c,e[10]=d,e[11]=f,e[12]=u):u=e[12],u}function R0(n){const e=U.c(34),{children:t,projectLabel:s,customName:o,className:i,onRename:a}=n,[l,c]=b.useState(!1),[d,f]=b.useState(""),u=b.useRef(null);let m;e[0]!==o?(m=function(){f(o||""),c(!0),requestAnimationFrame(()=>{var M;return(M=u.current)==null?void 0:M.select()})},e[0]=o,e[1]=m):m=e[1];const p=m;let h;e[2]!==i?(h=G("w-full",i),e[2]=i,e[3]=h):h=e[3];let g;e[4]!==h?(g=r.jsx("div",{className:h}),e[4]=h,e[5]=g):g=e[5];let x;e[6]!==t||e[7]!==g?(x=r.jsx(xa,{render:g,children:t}),e[6]=t,e[7]=g,e[8]=x):x=e[8];let v;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(Ls,{"data-icon":"inline-start"}),e[9]=v):v=e[9];let w;e[10]!==p?(w=r.jsx(ba,{className:"min-w-44",children:r.jsx(ao,{children:r.jsxs(Yt,{onClick:p,children:[v,"Rename project"]})})}),e[10]=p,e[11]=w):w=e[11];let y;e[12]!==x||e[13]!==w?(y=r.jsxs(ga,{children:[x,w]}),e[12]=x,e[13]=w,e[14]=y):y=e[14];let j;e[15]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsxs(Ss,{children:[r.jsx(Xn,{className:"text-foreground",children:"Rename project"}),r.jsx(Jn,{className:"text-muted-foreground",children:"Give this project a custom name. Clear to reset to default."})]}),e[15]=j):j=e[15];let k;e[16]!==a||e[17]!==d?(k=T=>{T.preventDefault(),a(d),c(!1)},e[16]=a,e[17]=d,e[18]=k):k=e[18];let N;e[19]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(xt,{htmlFor:"project-rename",children:"Project name"}),e[19]=N):N=e[19];let C;e[20]===Symbol.for("react.memo_cache_sentinel")?(C=T=>f(T.target.value),e[20]=C):C=e[20];let S;e[21]!==s||e[22]!==d?(S=r.jsxs(gt,{children:[N,r.jsx(Ot,{id:"project-rename",ref:u,value:d,onChange:C,placeholder:s})]}),e[21]=s,e[22]=d,e[23]=S):S=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsxs(Kh,{children:[r.jsx(X,{type:"button",variant:"ghost",size:"sm",onClick:()=>c(!1),children:"Cancel"}),r.jsx(X,{type:"submit",size:"sm",children:"Save"})]}),e[24]=_):_=e[24];let P;e[25]!==S||e[26]!==k?(P=r.jsxs(Yn,{className:"sm:max-w-md",children:[j,r.jsxs("form",{className:"flex flex-col gap-4",onSubmit:k,children:[S,_]})]}),e[25]=S,e[26]=k,e[27]=P):P=e[27];let A;e[28]!==l||e[29]!==P?(A=r.jsx(Gn,{open:l,onOpenChange:c,children:P}),e[28]=l,e[29]=P,e[30]=A):A=e[30];let E;return e[31]!==A||e[32]!==y?(E=r.jsxs(r.Fragment,{children:[y,A]}),e[31]=A,e[32]=y,e[33]=E):E=e[33],E}const M0="project-custom-names";function I0(){try{const n=localStorage.getItem(Lt(M0));return n?JSON.parse(n):{}}catch{return{}}}function vP(n){localStorage.setItem(Lt(M0),JSON.stringify(n))}let Ii=I0();const $i=new Set;if(typeof window<"u"){const n=()=>{Ii=I0();for(const e of $i)e()};window.addEventListener("cogpit-device-changed",n),window.addEventListener("cogpit-identity-changed",n)}function yP(n){return $i.add(n),()=>{$i.delete(n)}}function wP(){return Ii}function jP(n,e){const t={...Ii},s=e.trim();s?t[n]=s:delete t[n],vP(t),Ii=t;for(const o of $i)o()}function $0(){const n=U.c(2),e=b.useSyncExternalStore(yP,wP);let t;return n[0]!==e?(t={names:e,rename:jP},n[0]=e,n[1]=t):t=n[1],t}function SP(n){const e=U.c(45),{projects:t,activeSessions:s,loading:o,refreshing:i,searchFilter:a,setSearchFilter:l,fetchError:c,selectedProjectDirName:d,onSelectProject:f,onRefresh:u}=n;let m;if(e[0]!==s){m={};for(const R of s)P0(R.lastModified)&&(m[R.dirName]=(m[R.dirName]||0)+1);e[0]=s,e[1]=m}else m=e[1];const p=m,{names:h,rename:g}=$0();let x;e:{if(!a){x=t;break e}let R;if(e[2]!==h||e[3]!==t||e[4]!==a){const $=a.toLowerCase();R=t.filter(D=>{var O;return D.path.toLowerCase().includes($)||D.shortName.toLowerCase().includes($)||((O=h[D.dirName])==null?void 0:O.toLowerCase().includes($))}),e[2]=h,e[3]=t,e[4]=a,e[5]=R}else R=e[5];x=R}const v=x;let w;e[6]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Projects"}),e[6]=w):w=e[6];let y;e[7]!==t.length?(y=r.jsxs("div",{className:"flex items-center gap-2",children:[w,r.jsx(Me,{variant:"secondary",children:t.length})]}),e[7]=t.length,e[8]=y):y=e[8];let j;e[9]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx("p",{className:"text-sm text-muted-foreground",children:"Open a project to browse and resume its sessions."}),e[9]=j):j=e[9];let k;e[10]!==y?(k=r.jsxs("header",{className:"flex flex-col gap-1",children:[y,j]}),e[10]=y,e[11]=k):k=e[11];let N;e[12]!==a||e[13]!==l?(N=r.jsx(N0,{value:a,onChange:l,placeholder:"Filter projects..."}),e[12]=a,e[13]=l,e[14]=N):N=e[14];const C=i&&"animate-spin";let S;e[15]!==C?(S=G(C),e[15]=C,e[16]=S):S=e[16];let _;e[17]!==S?(_=r.jsx(Qt,{"data-icon":"inline-start",className:S}),e[17]=S,e[18]=_):_=e[18];let P;e[19]!==u||e[20]!==i||e[21]!==_?(P=r.jsxs(X,{variant:"outline",size:"sm",onClick:u,disabled:i,"aria-label":"Refresh projects",children:[_,"Refresh"]}),e[19]=u,e[20]=i,e[21]=_,e[22]=P):P=e[22];let A;e[23]!==P||e[24]!==N?(A=r.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[N,P]}),e[23]=P,e[24]=N,e[25]=A):A=e[25];let E;e[26]!==c||e[27]!==u||e[28]!==d?(E=c&&!d&&r.jsx(C0,{message:c,onRetry:u}),e[26]=c,e[27]=u,e[28]=d,e[29]=E):E=e[29];let T;e[30]!==p||e[31]!==v||e[32]!==o||e[33]!==f||e[34]!==h||e[35]!==g||e[36]!==a?(T=o?r.jsx(_0,{}):v.length===0?r.jsx(Hn,{className:"min-h-72 border",children:r.jsxs(Kn,{children:[r.jsx(js,{variant:"icon",children:r.jsx(Jo,{})}),r.jsx(qn,{children:a?"No projects match your search":"No projects yet"}),r.jsx(Vn,{children:a?"Try a project name or path.":"Start Claude Code, Codex, or Copilot and its project will appear here."})]})}):r.jsx("div",{className:"overflow-hidden rounded-lg border bg-card",children:v.map((R,$)=>{const D=p[R.dirName]||0,O=h[R.dirName],L=vw(St(R.dirName));return r.jsxs(b.Fragment,{children:[$>0&&r.jsx(It,{}),r.jsx(R0,{projectLabel:zn(R.path),customName:O,onRename:z=>g(R.dirName,z),children:r.jsxs("button",{type:"button",onClick:()=>f==null?void 0:f(R.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:[r.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-3",children:[r.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-md border bg-muted/40",children:r.jsx(bP,{projectPath:R.path,className:"size-4",fallback:r.jsx(Jo,{className:"size-4 text-muted-foreground"})})}),r.jsxs("span",{className:"min-w-0",children:[r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"truncate text-sm font-medium",children:O||zn(R.path)}),L&&r.jsx(Me,{variant:"outline",className:"h-5 shrink-0 px-1.5 text-[10px]",children:L})]}),r.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:ea(R.path)})]})]}),r.jsxs("span",{className:"flex items-center gap-4 pl-11 text-sm text-muted-foreground sm:pl-0",children:[D>0&&r.jsxs(Me,{variant:"secondary",children:[r.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:"size-1.5 rounded-full bg-success"}),D," active"]}),r.jsxs("span",{className:"whitespace-nowrap",children:[R.sessionCount," ",R.sessionCount===1?"session":"sessions"]}),R.lastModified&&r.jsx("span",{className:"hidden w-24 whitespace-nowrap text-right md:inline",children:jr(R.lastModified)}),r.jsx(Ze,{className:"size-4 shrink-0 transition-transform group-hover:translate-x-0.5"})]})]})})]},R.dirName)})}),e[30]=p,e[31]=v,e[32]=o,e[33]=f,e[34]=h,e[35]=g,e[36]=a,e[37]=T):T=e[37];let M;e[38]!==A||e[39]!==E||e[40]!==T?(M=r.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Projects",children:[A,E,T]}),e[38]=A,e[39]=E,e[40]=T,e[41]=M):M=e[41];let I;return e[42]!==M||e[43]!==k?(I=r.jsx(Nr,{className:"h-full",children:r.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:[k,M]})}),e[42]=M,e[43]=k,e[44]=I):I=e[44],I}const kP=250,NP=400,cp={results:null,loading:!1,error:null};function O0(n,e){const t=b.useMemo(()=>T0(n),[n]),[s,o]=b.useState(0),[i,a]=b.useState(cp);b.useEffect(()=>{if(!t){a(cp);return}const c=new AbortController;a({results:null,loading:!0,error:null});let d=null;const f=async()=>{const m=new URLSearchParams({search:n.trim(),limit:"200"});e&&m.set("project",e);try{const p=await ye(`/api/active-sessions?${m}`,{signal:c.signal});if(!p.ok)throw new Error(`Search failed (${p.status})`);const h=await p.json();if(c.signal.aborted)return;const g=Number(p.headers.get("X-Cogpit-PR-Index-Pending")??"0");if(Number.isFinite(g)&&g>0){d=setTimeout(()=>{f()},NP);return}a({results:Array.isArray(h)?h:[],loading:!1,error:null})}catch(p){if(c.signal.aborted)return;a({results:[],loading:!1,error:p instanceof Error?p.message:"Search failed"})}},u=setTimeout(()=>{f()},kP);return()=>{clearTimeout(u),d&&clearTimeout(d),c.abort()}},[e,t,n,s]);const l=b.useCallback(()=>o(c=>c+1),[]);return{...i,active:t!==null,refresh:l}}const CP=b.memo(function({onSelectSession:e,onNewSession:t,creatingSession:s,selectedProjectDirName:o,onSelectProject:i,onDuplicateSession:a,onDeleteSession:l}){const[c]=b.useState(()=>({projects:ki(Ln.projects),activeSessions:ki(Ln.activeSessions)})),[d,f]=b.useState(c.projects??[]),[u,m]=b.useState(c.activeSessions??[]),[p,h]=b.useState(c.projects===void 0),[g,x]=b.useState(!1),[v,w]=b.useState([]),[y,j]=b.useState(0),[k,N]=b.useState(1),[C,S]=b.useState(!1),[_,P]=b.useState(""),[A,E]=b.useState(null),T=b.useRef(0),M=b.useRef(null),I=b.useCallback(async(B=!1)=>{B&&x(!0);try{const[W,K]=await Promise.all([ye("/api/projects"),ye("/api/active-sessions")]);if(!W.ok||!K.ok)throw new Error("Failed to fetch dashboard data");const V=await W.json(),Y=await K.json(),q=Array.isArray(V)?V:[],J=Array.isArray(Y)?Y:[];f(q),m(J),Ko(Ln.projects,q),Ko(Ln.activeSessions,J),E(null)}catch(W){E(W instanceof Error?W.message:"Failed to load data")}finally{h(!1),x(!1)}},[]);b.useEffect(()=>{I()},[I]);const R=b.useCallback(async(B,W=1,K=!1)=>{var J;const V=++T.current;(J=M.current)==null||J.abort();const Y=new AbortController;M.current=Y;const q=()=>V===T.current;if(S(!0),E(null),!K){const Z=PC(B);Z?(w(Z.sessions),j(Z.total),N(1)):w([])}try{const Z=await ye(`/api/sessions/${encodeURIComponent(B)}?page=${W}&limit=20`,{signal:Y.signal});if(!Z.ok)throw new Error(`Failed to load sessions (${Z.status})`);const Q=await Z.json();if(!q())return;const ee=Array.isArray(Q.sessions)?Q.sessions:[],oe=typeof Q.total=="number"?Q.total:ee.length;w(se=>K?[...se,...ee]:ee),j(oe),N(W),K||AC(B,{sessions:ee,total:oe})}catch(Z){if(!q()||Y.signal.aborted)return;E(Z instanceof Error?Z.message:"Failed to load sessions")}finally{q()&&(M.current=null,S(!1))}},[]);b.useEffect(()=>{var B;if(!o){T.current+=1,(B=M.current)==null||B.abort(),M.current=null,w([]),j(0),N(1),P(""),S(!1);return}P(""),R(o)},[o,R]),b.useEffect(()=>()=>{var B;T.current+=1,(B=M.current)==null||B.abort()},[]);const $=b.useMemo(()=>{if(!o)return null;const B=d.find(K=>K.dirName===o);if(B)return B;const W=hn(o);return{dirName:o,path:W,shortName:zn(W),sessionCount:y,lastModified:null}},[o,d,y]),D=b.useCallback(()=>{i==null||i(null)},[i]),O=b.useCallback(()=>{o&&R(o,k+1,!0)},[o,k,R]),L=O0(o?_:"",o??void 0),z=b.useMemo(()=>_?v.filter(B=>dP(B,_)):v,[v,_]),F=L.results??z;function H(B,W){l==null||l(B,W),w(K=>K.filter(V=>V.fileName!==W)),j(K=>K-1)}return $?r.jsx(xP,{selectedProject:$,sessions:v,sessionsTotal:y,sessionsLoading:C,searchLoading:L.loading,searchFilter:_,setSearchFilter:P,filteredSessions:F,fetchError:L.error??A,onSelectSession:e,onNewSession:t,creatingSession:s,onDuplicateSession:a,onDeleteSession:H,onBack:D,onRetryFetch:()=>{if(L.error){L.refresh();return}E(null),o&&R(o)},loadMoreSessions:O}):r.jsx(SP,{projects:d,activeSessions:u,loading:p,refreshing:g,searchFilter:_,setSearchFilter:P,fetchError:A,selectedProjectDirName:o??null,onSelectProject:i,onRefresh:()=>I(!0)})});async function D0(n,e,t){return(await ye(`/api/permissions/${encodeURIComponent(n)}/respond`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:e,behavior:t})})).ok}async function _P(n,e){return(await ye(`/api/permissions/${encodeURIComponent(n)}/respond-all`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({behavior:e})})).ok}async function L0(n,e){try{const t=await ye(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return{ok:t.ok,gone:t.status===404}}catch{return{ok:!1,gone:!1}}}function TP(n,e,t){return L0("/api/elicitation-answer",{sessionId:n,requestId:e,...t})}function EP(n,e,t){return L0("/api/user-dialog-answer",{sessionId:n,requestId:e,choice:t})}const PP=3e3,z0=b.createContext(null);async function Nl(n,e){try{const t=await ye(n);if(!t.ok)return;const s=await t.text();return s===e.current?void 0:(e.current=s,JSON.parse(s))}catch{return}}function Ao(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 ii(n,e,t){const s=new Map(n),o=(s.get(e)??[]).filter(i=>!t(i));return o.length>0?s.set(e,o):s.delete(e),s}function AP({children:n}){const[e,t]=b.useState(new Map),[s,o]=b.useState(new Map),[i,a]=b.useState(new Map),[l,c]=b.useState(new Map),[d,f]=b.useState(new Set),[u,m]=b.useState(new Set),p=b.useRef(""),h=b.useRef(""),g=b.useRef(""),x=b.useCallback(async()=>{const[E,T,M]=await Promise.all([Nl("/api/permissions",p),Nl("/api/user-questions",h),Nl("/api/agent-prompts",g)]);E&&(t(Ao(E.bySession)),f(new Set(Ao(E.plansBySession).keys()))),T&&o(Ao(T.bySession)),M&&(a(Ao(M.elicitationsBySession)),c(Ao(M.dialogsBySession)))},[]);b.useEffect(()=>{const E=()=>{document.visibilityState==="visible"&&x()};E();const T=setInterval(E,PP);return document.addEventListener("visibilitychange",E),()=>{clearInterval(T),document.removeEventListener("visibilitychange",E)}},[x]);const v=b.useCallback(async(E,T)=>{m(M=>new Set(M).add(E));try{return await T()}finally{m(M=>{const I=new Set(M);return I.delete(E),I}),x()}},[x]),w=b.useCallback((E,T,M)=>v(T,async()=>{await D0(E,T,M).catch(()=>!1)&&(t(R=>ii(R,E,$=>$.requestId===T)),p.current="")}),[v]),y=b.useCallback((E,T,M)=>v(T,async()=>{const I=await Ac(E,T,M);return I.ok&&(o(R=>ii(R,E,$=>$.toolUseId===T)),h.current=""),I}),[v]),j=b.useCallback((E,T,M)=>v(T,async()=>{const I=await TP(E,T,M);return I.ok&&(a(R=>ii(R,E,$=>$.requestId===T)),g.current=""),I}),[v]),k=b.useCallback((E,T,M)=>v(T,async()=>{const I=await EP(E,T,M);return I.ok&&(c(R=>ii(R,E,$=>$.requestId===T)),g.current=""),I}),[v]),N=b.useMemo(()=>new Set(e.keys()),[e]),C=b.useMemo(()=>new Set(s.keys()),[s]),S=b.useMemo(()=>new Set(i.keys()),[i]),_=b.useMemo(()=>new Set(l.keys()),[l]),P=b.useCallback(()=>{x()},[x]),A=b.useMemo(()=>({permissionsBySession:e,questionsBySession:s,elicitationsBySession:i,dialogsBySession:l,awaitingPermission:N,awaitingQuestion:C,awaitingElicitation:S,awaitingDialog:_,awaitingPlan:d,responding:u,respond:w,answerQuestion:y,answerElicitation:j,answerDialog:k,refresh:P}),[e,s,i,l,N,C,S,_,d,u,w,y,j,k,P]);return r.jsx(z0.Provider,{value:A,children:n})}function RP(){const n=b.useContext(z0);if(!n)throw new Error("usePendingHumanInput must be used within a PendingHumanInputProvider");return n}const F0=typeof navigator<"u"&&"vibrate"in navigator;function lc(){F0&&navigator.vibrate(10)}function MP(){F0&&navigator.vibrate(20)}function IP(n){return!!(n.teamName&&n.agentName)}function $P(n,e,t,s,o,i,a){const l=[],c=[];for(const d of ud(n)){if(s!=null&&s.has(d.sessionId)){l.push({session:d,reason:"permission"});continue}if(o!=null&&o.has(d.sessionId)){l.push({session:d,reason:"question"});continue}if(i!=null&&i.has(d.sessionId)){l.push({session:d,reason:"prompt"});continue}if(a!=null&&a.has(d.sessionId)){l.push({session:d,reason:"plan"});continue}if(d.agentStatus==="deferred"){l.push({session:d,reason:"deferred"});continue}if(IP(d))continue;const f=ax(d,e);if(d.agentStatus==="completed"||!f){t.has(d.sessionId)&&l.push({session:d,reason:"done"});continue}if(d.agentStatus==="idle"){l.push({session:d,reason:"waiting"});continue}(!d.agentStatus||md.has(d.agentStatus))&&c.push(d)}return{needsYou:l,working:c}}function OP(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"}}function Ad(n,e){return n?zt(n).externalProcesses&&(e==null?void 0:e.managed)===!1:!1}const B0="aw:turnCounts",DP=200,_a=new Map;try{const n=localStorage.getItem(B0);if(n){const e=JSON.parse(n);for(const[t,s]of e)_a.set(t,s)}}catch{}function LP(){try{const n=[..._a.entries()].slice(-DP);localStorage.setItem(B0,JSON.stringify(n))}catch{}}function zP(n,e){_a.set(Lt(n),e),LP()}function FP(n,e){const t=_a.get(Lt(n));return Math.max(t??0,e??0)}function U0(n){const e=U.c(40),{session:t,proc:s,statusLabel:o,customName:i,worktreeName:a}=n,l=i||t.aiTitle,c=t.lastUserMessage||t.firstUserMessage,d=FP(t.sessionId,t.turnCount);let f;e[0]!==l?(f=l&&r.jsx("span",{className:"font-medium leading-snug text-foreground",children:l}),e[0]=l,e[1]=f):f=e[1];let u;e[2]!==t.agentStatus||e[3]!==o?(u=o&&r.jsx("span",{className:G("font-medium",Pd(t.agentStatus)),children:o}),e[2]=t.agentStatus,e[3]=o,e[4]=u):u=e[4];let m;e[5]!==t.agentName||e[6]!==t.teamName?(m=t.teamName&&t.agentName&&r.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[r.jsx(Wn,{className:"size-3"}),t.agentName," · ",t.teamName]}),e[5]=t.agentName,e[6]=t.teamName,e[7]=m):m=e[7];let p;e[8]!==c?(p=c&&r.jsx("div",{className:"border-l-2 pl-2 text-muted-foreground",children:r.jsx("span",{className:"line-clamp-3 leading-relaxed",children:c})}),e[8]=c,e[9]=p):p=e[9];let h;e[10]!==t.pullRequests?(h=r.jsx(Na,{pullRequests:t.pullRequests,layout:"list"}),e[10]=t.pullRequests,e[11]=h):h=e[11];let g;e[12]!==t.gitBranch||e[13]!==a?(g=t.gitBranch&&r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx(bo,{className:"size-2.5"}),a?`${t.gitBranch} · ${a}`:t.gitBranch]}),e[12]=t.gitBranch,e[13]=a,e[14]=g):g=e[14];let x;e[15]!==d?(x=d>0&&r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx(Vi,{className:"size-2.5"}),d," ",d===1?"turn":"turns"]}),e[15]=d,e[16]=x):x=e[16];let v;e[17]!==t.size?(v=Qh(t.size),e[17]=t.size,e[18]=v):v=e[18];let w;e[19]!==v?(w=r.jsx("span",{children:v}),e[19]=v,e[20]=w):w=e[20];let y;e[21]!==s?(y=s&&r.jsxs("span",{className:"flex items-center gap-0.5 text-success",children:[r.jsx(Yv,{className:"size-2.5"}),s.memMB," MB"]}),e[21]=s,e[22]=y):y=e[22];const j=t.lastActivityAt||t.lastModified;let k;e[23]!==j?(k=jr(j),e[23]=j,e[24]=k):k=e[24];let N;e[25]!==k?(N=r.jsx("span",{children:k}),e[25]=k,e[26]=N):N=e[26];let C;e[27]!==y||e[28]!==N||e[29]!==g||e[30]!==x||e[31]!==w?(C=r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-muted-foreground",children:[g,x,w,y,N]}),e[27]=y,e[28]=N,e[29]=g,e[30]=x,e[31]=w,e[32]=C):C=e[32];let S;return e[33]!==f||e[34]!==C||e[35]!==u||e[36]!==m||e[37]!==p||e[38]!==h?(S=r.jsxs("div",{className:"flex w-64 flex-col gap-2 text-xs",children:[f,u,m,p,h,C]}),e[33]=f,e[34]=C,e[35]=u,e[36]=m,e[37]=p,e[38]=h,e[39]=S):S=e[39],S}const BP=120;function W0(n){const e=U.c(7),t=b.useRef(null);let s,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>()=>{t.current&&clearTimeout(t.current)},o=[],e[0]=s,e[1]=o):(s=e[0],o=e[1]),b.useEffect(s,o);let i;e[2]!==n?(i=()=>{n&&(t.current&&clearTimeout(t.current),t.current=setTimeout(n,BP))},e[2]=n,e[3]=i):i=e[3];const a=i;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 d;return e[5]!==a?(d={onHoverStart:a,onHoverEnd:c},e[5]=a,e[6]=d):d=e[6],d}const UP=6;function WP(n){const e=U.c(7),{iso:t}=n,[,s]=b.useState(0);let o;e[0]!==s?(o=()=>{const c=setInterval(()=>s(HP),15e3);return()=>clearInterval(c)},e[0]=s,e[1]=o):o=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=[],e[2]=i):i=e[2],b.useEffect(o,i);let a;e[3]!==t?(a=jr(t),e[3]=t,e[4]=a):a=e[4];let l;return e[5]!==a?(l=r.jsx("span",{"data-relative-time":!0,className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:a}),e[5]=a,e[6]=l):l=e[6],l}function HP(n){return n+1}const KP={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"}},qP={permission:Rs.attention,deferred:Rs.attention,waiting:Rs.attention,question:"bg-warning",prompt:"bg-warning",plan:"bg-warning",done:"bg-success"};function dp(n){const e=U.c(76),{session:t,chip:s,dotClassName:o,cardClassName:i,isActiveSession:a,proc:l,killingPids:c,customName:d,projectLabel:f,compact:u,onSelect:m,onKill:p,onResume:h,onPrefetch:g}=n,x=u===void 0?!1:u;let v;e[0]!==l||e[1]!==t.dirName?(v=Ad(St(t.dirName),l),e[0]=l,e[1]=t.dirName,e[2]=v):v=e[2];const w=v;let y;e[3]!==s||e[4]!==w||e[5]!==t.agentPendingAgents||e[6]!==t.agentStatus||e[7]!==t.agentTerminalReason||e[8]!==t.agentToolName?(y=w?"Read-only":Rr(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??s.label,e[3]=s,e[4]=w,e[5]=t.agentPendingAgents,e[6]=t.agentStatus,e[7]=t.agentTerminalReason,e[8]=t.agentToolName,e[9]=y):y=e[9];const j=y,k=!!h&&!w,{onHoverStart:N,onHoverEnd:C}=W0(g),S=x?"px-2.5 py-2":"border px-2 py-2",_=a&&!x&&"ring-1 ring-ring";let P;e[10]!==i||e[11]!==S||e[12]!==_?(P=G("group relative w-full rounded-md text-left transition-colors",S,i,_),e[10]=i,e[11]=S,e[12]=_,e[13]=P):P=e[13];let A;e[14]!==x||e[15]!==a?(A=x&&a&&r.jsx("span",{className:"absolute inset-y-2 left-0 w-0.5 rounded-full bg-primary","aria-hidden":"true"}),e[14]=x,e[15]=a,e[16]=A):A=e[16];const E=k&&"pr-20";let T;e[17]!==E?(T=G("w-full rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",E),e[17]=E,e[18]=T):T=e[18];let M;e[19]!==C||e[20]!==N||e[21]!==m||e[22]!==T?(M=r.jsx("button",{type:"button","data-attention-session":!0,onClick:m,onMouseEnter:N,onMouseLeave:C,onFocus:N,onBlur:C,className:T}),e[19]=C,e[20]=N,e[21]=m,e[22]=T,e[23]=M):M=e[23];const I=x&&"ring-0";let R;e[24]!==o||e[25]!==I?(R=G("size-1.5 shrink-0 rounded-full",o,I),e[24]=o,e[25]=I,e[26]=R):R=e[26];let $;e[27]!==R?($=r.jsx("span",{className:R,"aria-hidden":"true"}),e[27]=R,e[28]=$):$=e[28];let D;e[29]!==d||e[30]!==t?(D=rx(t,d),e[29]=d,e[30]=t,e[31]=D):D=e[31];let O;e[32]!==D?(O=r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs leading-tight text-foreground",children:D}),e[32]=D,e[33]=O):O=e[33];const L=x?"text-muted-foreground":s.className;let z;e[34]!==L?(z=G("shrink-0",L),e[34]=L,e[35]=z):z=e[35];const F=w?"Read-only":s.label;let H;e[36]!==z||e[37]!==F?(H=r.jsx(Me,{variant:"outline",className:z,children:F}),e[36]=z,e[37]=F,e[38]=H):H=e[38];let B;e[39]!==x||e[40]!==t.lastActivityAt||e[41]!==t.lastModified?(B=!x&&r.jsx(WP,{iso:t.lastActivityAt||t.lastModified}),e[39]=x,e[40]=t.lastActivityAt,e[41]=t.lastModified,e[42]=B):B=e[42];let W;e[43]!==$||e[44]!==O||e[45]!==H||e[46]!==B?(W=r.jsxs("span",{className:"flex items-center gap-1.5",children:[$,O,H,B]}),e[43]=$,e[44]=O,e[45]=H,e[46]=B,e[47]=W):W=e[47];let K;e[48]!==f?(K=r.jsx("span",{className:"mt-1 block truncate pl-3 text-xs text-muted-foreground",children:f}),e[48]=f,e[49]=K):K=e[49];let V;e[50]!==M||e[51]!==W||e[52]!==K?(V=r.jsxs(Pt,{render:M,children:[W,K]}),e[50]=M,e[51]=W,e[52]=K,e[53]=V):V=e[53];let Y;e[54]!==d||e[55]!==l||e[56]!==t||e[57]!==j?(Y=r.jsx(At,{side:"right",className:"max-w-[280px]",children:r.jsx(U0,{session:t,proc:l,statusLabel:j,customName:d})}),e[54]=d,e[55]=l,e[56]=t,e[57]=j,e[58]=Y):Y=e[58];let q;e[59]!==V||e[60]!==Y?(q=r.jsxs(Et,{children:[V,Y]}),e[59]=V,e[60]=Y,e[61]=q):q=e[61];let J;e[62]!==k||e[63]!==h?(J=k&&r.jsxs(X,{type:"button",variant:"outline",size:"xs",onClick:h,className:"absolute bottom-1 right-1 text-warning","aria-label":"Resume to evaluate",children:[r.jsx(hr,{"data-icon":"inline-start"}),"Resume"]}),e[62]=k,e[63]=h,e[64]=J):J=e[64];let Z;e[65]!==w||e[66]!==c||e[67]!==p||e[68]!==l?(Z=l&&p&&!w&&r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",onClick:ee=>p(l.pid,ee),disabled:c.has(l.pid),className:"absolute right-0 top-0 text-destructive opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",title:`Kill PID ${l.pid}`,"aria-label":`Kill process ${l.pid}`,children:r.jsx(jt,{"data-icon":"inline-start"})}),e[65]=w,e[66]=c,e[67]=p,e[68]=l,e[69]=Z):Z=e[69];let Q;return e[70]!==q||e[71]!==J||e[72]!==Z||e[73]!==P||e[74]!==A?(Q=r.jsxs("div",{className:P,children:[A,q,J,Z]}),e[70]=q,e[71]=J,e[72]=Z,e[73]=P,e[74]=A,e[75]=Q):Q=e[75],Q}function VP(n){const e=U.c(15),{dotClassName:t,labelClassName:s,label:o,count:i}=n;let a;e[0]!==t?(a=G("size-1.5 rounded-full",t),e[0]=t,e[1]=a):a=e[1];let l;e[2]!==a?(l=r.jsx("span",{className:a,"aria-hidden":"true"}),e[2]=a,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 d;e[6]!==o||e[7]!==c?(d=r.jsx("span",{className:c,children:o}),e[6]=o,e[7]=c,e[8]=d):d=e[8];let f;e[9]!==i?(f=r.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:i}),e[9]=i,e[10]=f):f=e[10];let u;return e[11]!==l||e[12]!==d||e[13]!==f?(u=r.jsxs("div",{className:"flex items-center gap-1.5 px-0.5",children:[l,d,f]}),e[11]=l,e[12]=d,e[13]=f,e[14]=u):u=e[14],u}function GP(n){const e=U.c(27),{groups:t,activeSessionKey:s,procBySession:o,killingPids:i,sessionNames:a,projectNames:l,onSelectSession:c,onKill:d,onResumeSession:f,onPrefetchSession:u}=n,[m,p]=b.useState(!1);let h;e[0]!==t.working||e[1]!==m?(h=m?t.working:t.working.slice(0,UP),e[0]=t.working,e[1]=m,e[2]=h):h=e[2];const g=h,x=t.working.length-g.length;let v;e[3]!==l?(v=S=>l[S.dirName]||fd(S.cwd||hn(S.dirName)),e[3]=l,e[4]=v):v=e[4];const w=v;let y;e[5]!==s||e[6]!==i||e[7]!==u||e[8]!==c||e[9]!==o||e[10]!==w||e[11]!==a?(y=S=>{const _=s===`${S.dirName}/${S.fileName}`;return{session:S,isActiveSession:_,proc:o.get(S.sessionId),killingPids:i,customName:a[S.sessionId],projectLabel:w(S),onSelect:()=>c(S.dirName,S.fileName),onPrefetch:u&&!_?()=>u(S.dirName,S.fileName):void 0}},e[5]=s,e[6]=i,e[7]=u,e[8]=c,e[9]=o,e[10]=w,e[11]=a,e[12]=y):y=e[12];const j=y;let k;e[13]!==t.needsYou||e[14]!==d||e[15]!==f||e[16]!==j?(k=t.needsYou.length>0&&r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx(VP,{dotClassName:Rs.attention,labelClassName:"text-warning",label:"Needs you",count:t.needsYou.length}),t.needsYou.map(S=>{const{session:_,reason:P}=S;return r.jsx(dp,{...j(_),chip:KP[P],dotClassName:qP[P],cardClassName:"border-warning/20 bg-warning/5 hover:bg-warning/10",onKill:d,onResume:P==="deferred"&&f?()=>f(_.sessionId,_.cwd,_.dirName):void 0},`${_.dirName}/${_.fileName}`)})]}),e[13]=t.needsYou,e[14]=d,e[15]=f,e[16]=j,e[17]=k):k=e[17];let N;e[18]!==t.working.length||e[19]!==x||e[20]!==d||e[21]!==j||e[22]!==g?(N=t.working.length>0&&r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsxs("div",{className:"flex items-center justify-between px-1",children:[r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Working"}),r.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:t.working.length})]}),r.jsx("div",{"data-working-list":!0,className:"flex flex-col gap-0.5 overflow-hidden rounded-lg border bg-background p-0.5",children:g.map(S=>r.jsx(dp,{...j(S),chip:{label:OP(S),className:""},dotClassName:Rs.working,cardClassName:"hover:bg-accent/50",compact:!0,onKill:d},`${S.dirName}/${S.fileName}`))}),x>0&&r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:()=>p(!0),className:"justify-start",children:[r.jsx(nt,{"data-icon":"inline-start"}),"Show ",x," more"]})]}),e[18]=t.working.length,e[19]=x,e[20]=d,e[21]=j,e[22]=g,e[23]=N):N=e[23];let C;return e[24]!==k||e[25]!==N?(C=r.jsxs("div",{className:"flex flex-col gap-2","data-attention-strip":!0,children:[k,N]}),e[24]=k,e[25]=N,e[26]=C):C=e[26],C}function YP(n){const e=U.c(26),{loading:t,isMobile:s,searchQuery:o,searchLoading:i,onSearchQueryChange:a,onRefresh:l}=n;let c;e[0]!==a?(c=y=>a(y.target.value),e[0]=a,e[1]=c):c=e[1];let d;e[2]!==i||e[3]!==o||e[4]!==c?(d=r.jsx(es,{type:"search",value:o,onChange:c,placeholder:"Search sessions or PRs","aria-label":"Search sessions by project, branch, title, prompt, PR number, or PR URL","aria-busy":i}),e[2]=i,e[3]=o,e[4]=c,e[5]=d):d=e[5];let f;e[6]!==i?(f=r.jsx(yn,{align:"inline-start",children:i?r.jsx(rt,{className:"animate-spin"}):r.jsx(xn,{})}),e[6]=i,e[7]=f):f=e[7];let u;e[8]!==a||e[9]!==o?(u=o&&r.jsx(yn,{align:"inline-end",children:r.jsx(Cr,{size:"icon-xs",onClick:()=>a(""),"aria-label":"Clear session search",children:r.jsx(jt,{"data-icon":"inline-start"})})}),e[8]=a,e[9]=o,e[10]=u):u=e[10];let m;e[11]!==d||e[12]!==f||e[13]!==u?(m=r.jsxs(Zn,{children:[d,f,u]}),e[11]=d,e[12]=f,e[13]=u,e[14]=m):m=e[14];const p=s?"icon-sm":"icon-xs",h=t&&"animate-spin";let g;e[15]!==h?(g=G(h),e[15]=h,e[16]=g):g=e[16];let x;e[17]!==g?(x=r.jsx(Qt,{"data-icon":"inline-start",className:g}),e[17]=g,e[18]=x):x=e[18];let v;e[19]!==l||e[20]!==p||e[21]!==x?(v=r.jsx(X,{variant:"ghost",size:p,onClick:l,"aria-label":"Refresh sessions",children:x}),e[19]=l,e[20]=p,e[21]=x,e[22]=v):v=e[22];let w;return e[23]!==v||e[24]!==m?(w=r.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b px-2.5 py-2",children:[m,v]}),e[23]=v,e[24]=m,e[25]=w):w=e[25],w}const XP=["first","second","third","fourth","fifth"];function JP(n){const e=U.c(13),{fetchError:t,showEmpty:s,searching:o,loading:i,sessionCount:a,onRetry:l}=n;let c;e[0]!==t||e[1]!==l?(c=t&&r.jsxs(Ct,{variant:"destructive",children:[r.jsx(wn,{}),r.jsx(Dt,{children:"Could not load sessions"}),r.jsx(_t,{className:"truncate",children:t}),r.jsx(xs,{children:r.jsx(X,{variant:"outline",size:"xs",onClick:l,children:"Retry"})})]}),e[0]=t,e[1]=l,e[2]=c):c=e[2];let d;e[3]!==o||e[4]!==s?(d=s&&r.jsx(Hn,{className:"min-h-56 px-4 py-8",children:r.jsxs(Kn,{children:[r.jsx(js,{variant:"icon",children:o?r.jsx(xn,{}):r.jsx(rh,{})}),r.jsx(qn,{children:o?"No matching sessions":"No sessions yet"}),r.jsx(Vn,{children:o?"Try #157, honest-cms #157, or paste a PR URL.":"Start Claude Code, Codex, or Copilot to see recent work here."})]})}),e[3]=o,e[4]=s,e[5]=d):d=e[5];let f;e[6]!==i||e[7]!==a?(f=i&&a===0&&r.jsx("div",{className:"flex flex-col gap-2 px-2 py-4","aria-label":"Loading sessions",children:XP.map(QP)}),e[6]=i,e[7]=a,e[8]=f):f=e[8];let u;return e[9]!==c||e[10]!==d||e[11]!==f?(u=r.jsxs(r.Fragment,{children:[c,d,f]}),e[9]=c,e[10]=d,e[11]=f,e[12]=u):u=e[12],u}function QP(n){return r.jsxs("div",{className:"flex items-center gap-2 py-1",children:[r.jsx(is,{className:"size-2 shrink-0 rounded-full"}),r.jsx(is,{className:"h-4 flex-1"}),r.jsx(is,{className:"h-4 w-10"})]},n)}function ZP(n){var we;const e=U.c(116),{session:t,isActiveSession:s,proc:o,killingPids:i,isNewlyCompleted:a,customName:l,worktreeName:c,teammateCount:d,teammatesCollapsed:f,onToggleTeammates:u,onSelectSession:m,onKill:p,onDuplicateSession:h,onDeleteSession:g,onRenameSession:x,onPrefetchSession:v,onResumeSession:w}=n,y=o!==void 0,j=t.isActive===!0,k=y||j,N=j&&fr(t.agentStatus),C=t.agentStatus==="deferred";let S;e[0]!==o||e[1]!==t.dirName?(S=Ad(St(t.dirName),o),e[0]=o,e[1]=t.dirName,e[2]=S):S=e[2];const _=S,[P,A]=b.useState(!1),E=_?"Read-only":k?N?"Running":Rr(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??"Running":null,T=C?"attention":k?fr(t.agentStatus)?"idle":"working":null,M=!!(t.teamName&&t.agentName);let I;e[3]!==l||e[4]!==t?(I=rx(t,l),e[3]=l,e[4]=t,e[5]=I):I=e[5];const R=I;let $;e[6]!==s||e[7]!==v||e[8]!==t.dirName||e[9]!==t.fileName?($=v&&!s?()=>v(t.dirName,t.fileName):void 0,e[6]=s,e[7]=v,e[8]=t.dirName,e[9]=t.fileName,e[10]=$):$=e[10];const{onHoverStart:D,onHoverEnd:O}=W0($);let L;e[11]!==w||e[12]!==P||e[13]!==t.cwd||e[14]!==t.dirName||e[15]!==t.sessionId?(L=pe=>{pe.stopPropagation(),!(!w||P)&&(A(!0),w(t.sessionId,t.cwd,t.dirName),setTimeout(()=>A(!1),3e3))},e[11]=w,e[12]=P,e[13]=t.cwd,e[14]=t.dirName,e[15]=t.sessionId,e[16]=L):L=e[16];const z=L;let F;e[17]!==y||e[18]!==s||e[19]!==j||e[20]!==a||e[21]!==t.agentStatus?(F=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",eA(s,!j&&y&&t.agentStatus==="completed"&&!!a)),e[17]=y,e[18]=s,e[19]=j,e[20]=a,e[21]=t.agentStatus,e[22]=F):F=e[22];const H=Et,B=Pt;let W;e[23]!==m||e[24]!==t.dirName||e[25]!==t.fileName?(W=()=>m(t.dirName,t.fileName),e[23]=m,e[24]=t.dirName,e[25]=t.fileName,e[26]=W):W=e[26];let K;e[27]!==O||e[28]!==D||e[29]!==W?(K=r.jsx("button",{type:"button","data-live-session":!0,onClick:W,onMouseEnter:D,onMouseLeave:O,onFocus:D,onBlur:O,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[27]=O,e[28]=D,e[29]=W,e[30]=K):K=e[30];let V;e[31]!==T?(V=T&&r.jsx("span",{"data-status-dot":T,className:G("size-1.5 rounded-full",Rs[T])}),e[31]=T,e[32]=V):V=e[32];let Y;e[33]!==V?(Y=r.jsx("span",{className:"flex w-1.5 shrink-0 items-center justify-center","aria-hidden":"true",children:V}),e[33]=V,e[34]=Y):Y=e[34];let q;e[35]!==R?(q=r.jsx("span",{className:"flex-1 truncate text-sm leading-tight text-foreground",children:R}),e[35]=R,e[36]=q):q=e[36];let J;e[37]!==M||e[38]!==t.agentName||e[39]!==R?(J=M&&r.jsxs(Me,{variant:"outline",children:[r.jsx(lo,{"data-icon":"inline-start"}),R!==t.agentName?t.agentName:"Agent"]}),e[37]=M,e[38]=t.agentName,e[39]=R,e[40]=J):J=e[40];const Z=k&&!C&&E&&r.jsx(Me,{variant:"secondary","data-session-live-state":!0,className:G("shrink-0",N&&"text-success",!N&&Pd(t.agentStatus)),children:E});let Q;e[41]!==C?(Q=C&&r.jsx(Me,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"deferred"}),e[41]=C,e[42]=Q):Q=e[42];let ee;e[43]!==c?(ee=c&&r.jsxs(Me,{variant:"outline",children:[r.jsx(bo,{"data-icon":"inline-start"}),c]}),e[43]=c,e[44]=ee):ee=e[44];let oe;e[45]!==B||e[46]!==q||e[47]!==J||e[48]!==Z||e[49]!==Q||e[50]!==ee||e[51]!==K||e[52]!==Y?(oe=r.jsxs(B,{render:K,children:[Y,q,J,Z,Q,ee]}),e[45]=B,e[46]=q,e[47]=J,e[48]=Z,e[49]=Q,e[50]=ee,e[51]=K,e[52]=Y,e[53]=oe):oe=e[53];let se;e[54]!==l||e[55]!==o||e[56]!==t||e[57]!==E||e[58]!==c?(se=r.jsx(At,{side:"right",className:"max-w-[280px]",children:r.jsx(U0,{session:t,proc:o,statusLabel:E,customName:l,worktreeName:c})}),e[54]=l,e[55]=o,e[56]=t,e[57]=E,e[58]=c,e[59]=se):se=e[59];let re;e[60]!==H||e[61]!==oe||e[62]!==se?(re=r.jsxs(H,{children:[oe,se]}),e[60]=H,e[61]=oe,e[62]=se,e[63]=re):re=e[63];let ie;e[64]!==u||e[65]!==d||e[66]!==f?(ie=!!d&&u&&r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:u,className:"shrink-0",title:f?"Show team agents":"Hide team agents","aria-label":f?`Show ${d} team agents`:`Hide ${d} team agents`,"aria-expanded":!f,children:[r.jsx(Wn,{"data-icon":"inline-start"}),d,r.jsx(Ze,{"data-icon":"inline-end",className:G("transition-transform duration-150",!f&&"rotate-90")})]}),e[64]=u,e[65]=d,e[66]=f,e[67]=ie):ie=e[67];let ae;e[68]!==z||e[69]!==C||e[70]!==_||e[71]!==w||e[72]!==P?(ae=C&&w&&!_&&r.jsxs(X,{type:"button",variant:"outline",size:"xs",onClick:z,disabled:P,className:"shrink-0 text-warning",title:"Resume to evaluate deferred permission","aria-label":"Resume to evaluate",children:[r.jsx(hr,{"data-icon":"inline-start"}),"Resume"]}),e[68]=z,e[69]=C,e[70]=_,e[71]=w,e[72]=P,e[73]=ae):ae=e[73];let te;e[74]!==t.matchedPullRequestNumber||e[75]!==t.pullRequests?(te=t.matchedPullRequestNumber?r.jsxs(Me,{variant:"outline",className:"shrink-0 px-1",children:["Matched #",t.matchedPullRequestNumber]}):r.jsx(Na,{pullRequests:t.pullRequests,max:1,compact:!0}),e[74]=t.matchedPullRequestNumber,e[75]=t.pullRequests,e[76]=te):te=e[76];const he=t.lastActivityAt||t.lastModified;let me;e[77]!==he?(me=jr(he),e[77]=he,e[78]=me):me=e[78];let le;e[79]!==me?(le=r.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:me}),e[79]=me,e[80]=le):le=e[80];let xe;e[81]!==y||e[82]!==_||e[83]!==i||e[84]!==p||e[85]!==o?(xe=y&&p&&!_&&r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",onClick:pe=>p(o.pid,pe),disabled:i.has(o.pid),className:"absolute right-0 top-0 text-destructive opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",title:`Kill PID ${o.pid}`,"aria-label":`Kill process ${o.pid}`,children:r.jsx(jt,{"data-icon":"inline-start"})}),e[81]=y,e[82]=_,e[83]=i,e[84]=p,e[85]=o,e[86]=xe):xe=e[86];let ge;e[87]!==re||e[88]!==ie||e[89]!==ae||e[90]!==te||e[91]!==le||e[92]!==xe||e[93]!==F?(ge=r.jsxs("div",{className:F,children:[re,ie,ae,te,le,xe]}),e[87]=re,e[88]=ie,e[89]=ae,e[90]=te,e[91]=le,e[92]=xe,e[93]=F,e[94]=ge):ge=e[94];const ce=ge;if(h||g||x){let pe;e[95]!==t.firstUserMessage||e[96]!==t.sessionId||e[97]!==t.slug?(pe=t.slug||((we=t.firstUserMessage)==null?void 0:we.slice(0,30))||t.sessionId.slice(0,12),e[95]=t.firstUserMessage,e[96]=t.sessionId,e[97]=t.slug,e[98]=pe):pe=e[98];let ue;e[99]!==h||e[100]!==t.dirName||e[101]!==t.fileName?(ue=h?()=>h(t.dirName,t.fileName):void 0,e[99]=h,e[100]=t.dirName,e[101]=t.fileName,e[102]=ue):ue=e[102];let je;e[103]!==g||e[104]!==t?(je=g?()=>g(t):void 0,e[103]=g,e[104]=t,e[105]=je):je=e[105];let Ne;e[106]!==x||e[107]!==t.sessionId?(Ne=x?Te=>x(t.sessionId,Te):void 0,e[106]=x,e[107]=t.sessionId,e[108]=Ne):Ne=e[108];let Re;return e[109]!==l||e[110]!==ce||e[111]!==pe||e[112]!==ue||e[113]!==je||e[114]!==Ne?(Re=r.jsx(w0,{sessionLabel:pe,customName:l,onDuplicate:ue,onDelete:je,onRename:Ne,children:ce}),e[109]=l,e[110]=ce,e[111]=pe,e[112]=ue,e[113]=je,e[114]=Ne,e[115]=Re):Re=e[115],Re}return ce}function eA(n,e){return n?"bg-accent":e?"bg-success/10":"hover:bg-accent/60"}function tA(n,e){return n.reduce((t,s)=>s.isActive?t+1:e.has(s.sessionId)?s.agentStatus==="completed"?t:t+1:t,0)}function nA(n){const e=U.c(36),{grouped:t,pendingProjectPath:s,pendingSession:o,collapsedGroups:i,searchQuery:a,activeSessionKey:l,procBySession:c,killingPids:d,newlyCompleted:f,sessionNames:u,projectNames:m,onToggleCollapsed:p,onSelectSession:h,onKill:g,onDuplicateSession:x,onDeleteSession:v,onRenameSession:w,onRenameProject:y,onNewSession:j,creatingSession:k,onPrefetchSession:N,onResumeSession:C}=n;let S;e[0]!==l||e[1]!==k||e[2]!==d||e[3]!==f||e[4]!==v||e[5]!==x||e[6]!==g||e[7]!==j||e[8]!==N||e[9]!==y||e[10]!==w||e[11]!==C||e[12]!==h||e[13]!==p||e[14]!==c||e[15]!==m||e[16]!==u?(S={activeSessionKey:l,procBySession:c,killingPids:d,newlyCompleted:f,sessionNames:u,projectNames:m,onToggleCollapsed:p,onSelectSession:h,onKill:g,onDuplicateSession:x,onDeleteSession:v,onRenameSession:w,onRenameProject:y,onNewSession:j,creatingSession:k,onPrefetchSession:N,onResumeSession:C},e[0]=l,e[1]=k,e[2]=d,e[3]=f,e[4]=v,e[5]=x,e[6]=g,e[7]=j,e[8]=N,e[9]=y,e[10]=w,e[11]=C,e[12]=h,e[13]=p,e[14]=c,e[15]=m,e[16]=u,e[17]=S):S=e[17];const _=S;let P;e[18]!==a?(P=a.trim(),e[18]=a,e[19]=P):P=e[19];const A=!!P;let E;e[20]!==i||e[21]!==A||e[22]!==t||e[23]!==s||e[24]!==o||e[25]!==c||e[26]!==_?(E=[...t.entries()].map((I,R)=>{const[$,D]=I,O=tA(D,c);return b.createElement(up,{..._,key:$,projectPath:$,sessions:D,liveCount:O,collapsed:i[$]??(R>=3&&O===0),forceExpand:A,pendingSession:s===$?o:void 0})}),e[20]=i,e[21]=A,e[22]=t,e[23]=s,e[24]=o,e[25]=c,e[26]=_,e[27]=E):E=e[27];let T;e[28]!==t||e[29]!==s||e[30]!==o||e[31]!==_?(T=s&&!t.has(s)&&o&&b.createElement(up,{..._,key:`pending-${s}`,projectPath:s,sessions:[],liveCount:0,collapsed:!1,pendingSession:o}),e[28]=t,e[29]=s,e[30]=o,e[31]=_,e[32]=T):T=e[32];let M;return e[33]!==E||e[34]!==T?(M=r.jsxs(r.Fragment,{children:[E,T]}),e[33]=E,e[34]=T,e[35]=M):M=e[35],M}function up(n){var He,Ie;const e=U.c(99),{projectPath:t,sessions:s,activeSessionKey:o,procBySession:i,killingPids:a,newlyCompleted:l,sessionNames:c,projectNames:d,liveCount:f,collapsed:u,onToggleCollapsed:m,forceExpand:p,onSelectSession:h,onKill:g,onDuplicateSession:x,onDeleteSession:v,onRenameSession:w,onRenameProject:y,onNewSession:j,creatingSession:k,pendingSession:N,onPrefetchSession:C,onResumeSession:S}=n,_=p===void 0?!1:p,P=b.useId(),A=!!N,E=_||A?!1:u;let T;e[0]!==s?(T=new Set(s.map(oA)),e[0]=s,e[1]=T):T=e[1];const M=T;let I;if(e[2]!==M||e[3]!==s){const Ce=new Map,de=[];for(const Ee of s){const Ae=Ee.teamLeadSessionId;if(Ae&&Ae!==Ee.sessionId&&M.has(Ae)){const Le=Ce.get(Ae);Le?Le.push(Ee):Ce.set(Ae,[Ee])}else de.push(Ee)}I={topLevelSessions:de,teammatesByLead:Ce},e[2]=M,e[3]=s,e[4]=I}else I=e[4];const{topLevelSessions:R,teammatesByLead:$}=I;let D;e[5]===Symbol.for("react.memo_cache_sentinel")?(D=new Set,e[5]=D):D=e[5];const[O,L]=b.useState(D);let z;e[6]===Symbol.for("react.memo_cache_sentinel")?(z=Ce=>{L(de=>{const Ee=new Set(de);return Ee.has(Ce)?Ee.delete(Ce):Ee.add(Ce),Ee})},e[6]=z):z=e[6];const F=z,[H,B]=b.useState(!1),W=s.length+(A?1:0);let K,V;e[7]!==_||e[8]!==A||e[9]!==i||e[10]!==H||e[11]!==R?(K=jC(R,i,Math.max(1,5-(A?1:0))),V=_||H?R:R.slice(0,K),e[7]=_,e[8]=A,e[9]=i,e[10]=H,e[11]=R,e[12]=K,e[13]=V):(K=e[12],V=e[13]);const Y=V,q=R.length-Y.length,J=H&&!_&&R.length>K,Z=((He=s.find(sA))==null?void 0:He.dirName)??((Ie=s[0])==null?void 0:Ie.dirName)??(N==null?void 0:N.dirName),Q=Z?d[Z]:void 0;let ee;e[14]!==o||e[15]!==a||e[16]!==l||e[17]!==v||e[18]!==x||e[19]!==g||e[20]!==C||e[21]!==w||e[22]!==S||e[23]!==h||e[24]!==i||e[25]!==c?(ee=function(de,Ee,Ae){return r.jsx(ZP,{session:de,isActiveSession:o===`${de.dirName}/${de.fileName}`,proc:i.get(de.sessionId),killingPids:a,isNewlyCompleted:l.has(de.sessionId),customName:c[de.sessionId],worktreeName:Ee,teammateCount:Ae==null?void 0:Ae.count,teammatesCollapsed:Ae==null?void 0:Ae.collapsed,onToggleTeammates:Ae==null?void 0:Ae.onToggle,onSelectSession:h,onKill:g,onDuplicateSession:x,onDeleteSession:v,onRenameSession:w,onPrefetchSession:C,onResumeSession:S},`${de.dirName}/${de.fileName}`)},e[14]=o,e[15]=a,e[16]=l,e[17]=v,e[18]=x,e[19]=g,e[20]=C,e[21]=w,e[22]=S,e[23]=h,e[24]=i,e[25]=c,e[26]=ee):ee=e[26];const oe=ee,se=!E;let re;e[27]!==Z||e[28]!==y?(re=Ce=>{Z&&y&&y(Z,Ce)},e[27]=Z,e[28]=y,e[29]=re):re=e[29];let ie;e[30]!==u||e[31]!==m||e[32]!==t?(ie=()=>m(t,!u),e[30]=u,e[31]=m,e[32]=t,e[33]=ie):ie=e[33];const ae=!E,te=_?"Groups stay expanded while searching":void 0,he=!E&&"rotate-90";let me;e[34]!==he?(me=G("size-3 shrink-0 text-muted-foreground transition-transform duration-150",he),e[34]=he,e[35]=me):me=e[35];let le;e[36]!==me?(le=r.jsx(Ze,{className:me}),e[36]=me,e[37]=le):le=e[37];const xe=Q||t;let ge;e[38]!==xe?(ge=r.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:xe}),e[38]=xe,e[39]=ge):ge=e[39];let ce;e[40]!==Q||e[41]!==t?(ce=Q&&r.jsx("span",{className:"truncate text-xs text-muted-foreground",children:t}),e[40]=Q,e[41]=t,e[42]=ce):ce=e[42];let we;e[43]!==f?(we=f>0&&r.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs font-medium text-success","aria-label":`${f} live sessions`,children:[r.jsx(na,{className:"size-1.5","aria-hidden":"true"}),f]}),e[43]=f,e[44]=we):we=e[44];let pe;e[45]!==W?(pe=r.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:W}),e[45]=W,e[46]=pe):pe=e[46];let ue;e[47]!==_||e[48]!==P||e[49]!==ie||e[50]!==ae||e[51]!==te||e[52]!==le||e[53]!==ge||e[54]!==ce||e[55]!==we||e[56]!==pe?(ue=r.jsxs("button",{type:"button",onClick:ie,disabled:_,"aria-expanded":ae,"aria-controls":P,title:te,className:"flex min-w-0 flex-1 items-center gap-1 rounded-md px-1 py-1 text-left transition-colors hover:bg-accent",children:[le,ge,ce,we,pe]}),e[47]=_,e[48]=P,e[49]=ie,e[50]=ae,e[51]=te,e[52]=le,e[53]=ge,e[54]=ce,e[55]=we,e[56]=pe,e[57]=ue):ue=e[57];let je;e[58]!==k||e[59]!==j||e[60]!==t||e[61]!==s[0]||e[62]!==s.length?(je=j&&s.length>0&&r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",className:"shrink-0",disabled:k,onClick:Ce=>{Ce.stopPropagation();const de=s[0];j(de.dirName,de.cwd??void 0)},"aria-label":`New session in ${t}`,children:k?r.jsx(rt,{"data-icon":"inline-start",className:"animate-spin"}):r.jsx(_n,{"data-icon":"inline-start"})}),e[58]=k,e[59]=j,e[60]=t,e[61]=s[0],e[62]=s.length,e[63]=je):je=e[63];let Ne;e[64]!==ue||e[65]!==je?(Ne=r.jsxs("div",{className:"flex w-full items-center gap-1 px-2 pb-1 pt-3",children:[ue,je]}),e[64]=ue,e[65]=je,e[66]=Ne):Ne=e[66];let Re;e[67]!==Q||e[68]!==t||e[69]!==Ne||e[70]!==re?(Re=r.jsx(R0,{projectLabel:t,customName:Q,className:"sticky top-0 z-20 bg-background",onRename:re,children:Ne}),e[67]=Q,e[68]=t,e[69]=Ne,e[70]=re,e[71]=Re):Re=e[71];let Te;e[72]!==N?(Te=N&&r.jsx(rA,{firstMessage:N.firstMessage}),e[72]=N,e[73]=Te):Te=e[73];let Pe;if(e[74]!==O||e[75]!==oe||e[76]!==$||e[77]!==Y){let Ce;e[79]!==O||e[80]!==oe||e[81]!==$?(Ce=de=>{const Ee=de.cwd??hn(de.dirName),Ae=ta(Ee),Le=$.get(de.sessionId);if(!Le)return oe(de,Ae==null?void 0:Ae.worktreeName);const ne=O.has(de.sessionId);return r.jsxs("div",{className:"flex flex-col gap-px",children:[oe(de,Ae==null?void 0:Ae.worktreeName,{count:Le.length,collapsed:ne,onToggle:()=>F(de.sessionId)}),!ne&&r.jsx("div",{className:"ml-3 flex flex-col gap-px border-l pl-1",children:Le.map(fe=>oe(fe))})]},`${de.dirName}/${de.fileName}`)},e[79]=O,e[80]=oe,e[81]=$,e[82]=Ce):Ce=e[82],Pe=Y.map(Ce),e[74]=O,e[75]=oe,e[76]=$,e[77]=Y,e[78]=Pe}else Pe=e[78];let Oe;e[83]!==q?(Oe=q>0&&r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:()=>B(!0),className:"justify-start",children:[r.jsx(nt,{"data-icon":"inline-start"}),"Show ",q," more"]}),e[83]=q,e[84]=Oe):Oe=e[84];let Fe;e[85]!==J?(Fe=J&&r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:()=>B(!1),className:"justify-start",children:[r.jsx(pr,{"data-icon":"inline-start"}),"Show less"]}),e[85]=J,e[86]=Fe):Fe=e[86];let ze;e[87]!==Te||e[88]!==Pe||e[89]!==Oe||e[90]!==Fe?(ze=r.jsxs("div",{className:"flex flex-col gap-px",children:[Te,Pe,Oe,Fe]}),e[87]=Te,e[88]=Pe,e[89]=Oe,e[90]=Fe,e[91]=ze):ze=e[91];let Be;e[92]!==P||e[93]!==ze?(Be=r.jsx(Nt,{id:P,className:"ml-3 border-l pl-1",children:ze}),e[92]=P,e[93]=ze,e[94]=Be):Be=e[94];let _e;return e[95]!==Re||e[96]!==Be||e[97]!==se?(_e=r.jsxs(kt,{open:se,className:"flex flex-col",children:[Re,Be]}),e[95]=Re,e[96]=Be,e[97]=se,e[98]=_e):_e=e[98],_e}function sA(n){return!ta(n.cwd??hn(n.dirName))}function oA(n){return n.sessionId}function rA(n){const e=U.c(3),{firstMessage:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(rt,{className:"size-3 shrink-0 animate-spin text-info"}),e[0]=s):s=e[0];const o=t||"New session";let i;return e[1]!==o?(i=r.jsxs("div",{className:"motion-enter relative flex w-full items-center gap-1.5 rounded-md bg-accent px-2 py-2 text-left",children:[s,r.jsx("span",{className:"flex-1 truncate text-xs leading-tight text-foreground",children:o})]}),e[1]=o,e[2]=i):i=e[2],i}const iA=b.memo(function(e){const t=U.c(122),{activeSessionKey:s,onSelectSession:o,onDuplicateSession:i,onDeleteSession:a,onNewSession:l,creatingSession:c,pendingSession:d,refreshRef:f,onPrefetchSession:u}=e,{names:m,rename:p}=k0(),{names:h,rename:g}=$0(),x=Ic(),v=vn("terminal"),w=vn("killAny"),{sessions:y,procBySession:j,newlyCompleted:k,loading:N,error:C,refresh:S,removeSession:_,acknowledgeCompleted:P}=px(),{awaitingPermission:A,awaitingQuestion:E,awaitingElicitation:T,awaitingDialog:M,awaitingPlan:I}=RP();let R;t[0]!==M||t[1]!==T?(R=new Set([...T,...M]),t[0]=M,t[1]=T,t[2]=R):R=t[2];const $=R;let D;t[3]===Symbol.for("react.memo_cache_sentinel")?(D=new Set,t[3]=D):D=t[3];const[O,L]=b.useState(D),[z,F]=b.useState("");let H,B;t[4]===Symbol.for("react.memo_cache_sentinel")?(H=Lt("live-sessions-collapsed-projects"),B={},t[4]=H,t[5]=B):(H=t[4],B=t[5]);const[W,K]=ha(H,B);let V;t[6]!==K?(V=(Ge,et)=>{K(mt=>({...mt,[Ge]:et}))},t[6]=K,t[7]=V):V=t[7];const Y=V,q=b.useRef(y);let J;t[8]===Symbol.for("react.memo_cache_sentinel")?(J=new Set,t[8]=J):J=t[8];const Z=b.useRef(J),Q=b.useRef(!1);let ee;t[9]===Symbol.for("react.memo_cache_sentinel")?(ee=(Ge,et)=>{if(!Q.current)return;const mt=setTimeout(()=>{Z.current.delete(mt),Q.current&&Ge()},et);Z.current.add(mt)},t[9]=ee):ee=t[9];const oe=ee;let se,re;t[10]===Symbol.for("react.memo_cache_sentinel")?(se=()=>{const Ge=Z.current;return Q.current=!0,()=>{Q.current=!1;for(const et of Ge)clearTimeout(et);Ge.clear()}},re=[],t[10]=se,t[11]=re):(se=t[10],re=t[11]),b.useEffect(se,re);let ie,ae;t[12]!==y?(ie=()=>{q.current=y},ae=[y],t[12]=y,t[13]=ie,t[14]=ae):(ie=t[13],ae=t[14]),b.useEffect(ie,ae);let te,he;t[15]!==S||t[16]!==f?(te=()=>{if(f)return f.current=S,()=>{f.current===S&&(f.current=null)}},he=[S,f],t[15]=S,t[16]=f,t[17]=te,t[18]=he):(te=t[17],he=t[18]),b.useEffect(te,he);const me=va(),le=O0(z);let xe;e:{if(!z.trim()){xe=y;break e}let Ge;if(t[19]!==h||t[20]!==z||t[21]!==m||t[22]!==y){let et;t[24]!==h||t[25]!==z||t[26]!==m?(et=mt=>{const Ft=m[mt.sessionId],Zt=h[mt.dirName];return E0(mt,z,[Ft,Zt])},t[24]=h,t[25]=z,t[26]=m,t[27]=et):et=t[27],Ge=y.filter(et),t[19]=h,t[20]=z,t[21]=m,t[22]=y,t[23]=Ge}else Ge=t[23];xe=Ge}const ge=xe,ce=le.results??ge;let we;t[28]!==ce?(we=wC(ce),t[28]=ce,t[29]=we):we=t[29];const pe=we;let ue;t[30]!==A||t[31]!==I||t[32]!==$||t[33]!==E||t[34]!==k||t[35]!==j||t[36]!==y?(ue=$P(y,j,k,A,E,$,I),t[30]=A,t[31]=I,t[32]=$,t[33]=E,t[34]=k,t[35]=j,t[36]=y,t[37]=ue):ue=t[37];const je=ue,Ne=je.needsYou.length>0||je.working.length>0;let Re;t[38]!==Ne||t[39]!==z?(Re=!z.trim()&&Ne,t[38]=Ne,t[39]=z,t[40]=Re):Re=t[40];const Te=Re;let Pe;e:{if(!d){Pe=null;break e}let Ge;t[41]!==d.cwd||t[42]!==d.dirName?(Ge=d.cwd||hn(d.dirName),t[41]=d.cwd,t[42]=d.dirName,t[43]=Ge):Ge=t[43];let et;t[44]!==Ge?(et=fd(Ge),t[44]=Ge,t[45]=et):et=t[45],Pe=et}const Oe=Pe,Fe=b.useRef(!1);let ze,Be;t[46]!==u||t[47]!==y?(ze=()=>{if(Fe.current||!u||y.length===0)return;Fe.current=!0;const Ge=ud(y).slice(0,3),et=globalThis,mt=()=>{for(const Us of Ge)u(Us.dirName,Us.fileName)};let Ft=null,Zt=null;return typeof et.requestIdleCallback=="function"?Ft=et.requestIdleCallback(mt,{timeout:1500}):Zt=setTimeout(mt,300),()=>{Ft!=null&&typeof et.cancelIdleCallback=="function"&&et.cancelIdleCallback(Ft),Zt!=null&&clearTimeout(Zt)}},Be=[y,u],t[46]=u,t[47]=y,t[48]=ze,t[49]=Be):(ze=t[48],Be=t[49]),b.useEffect(ze,Be);let _e;t[50]!==S?(_e=async(Ge,et)=>{et.stopPropagation(),L(mt=>new Set(mt).add(Ge));try{await ye("/api/kill-process",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pid:Ge})}),oe(S,1500)}catch{}oe(()=>{L(mt=>{const Ft=new Set(mt);return Ft.delete(Ge),Ft})},2e3)},t[50]=S,t[51]=_e):_e=t[51];const He=_e;let Ie;t[52]!==P||t[53]!==o?(Ie=(Ge,et)=>{const mt=q.current.find(Ft=>Ft.dirName===Ge&&Ft.fileName===et);mt&&P(mt.sessionId),o(Ge,et)},t[52]=P,t[53]=o,t[54]=Ie):Ie=t[54];const Ce=Ie;let de;t[55]!==a||t[56]!==_?(de=Ge=>{a==null||a(Ge.dirName,Ge.fileName),_(Ge.sessionId)},t[55]=a,t[56]=_,t[57]=de):de=t[57];const Ee=de;let Ae;t[58]!==S||t[59]!==x?(Ae=(Ge,et,mt)=>{const{command:Ft,args:Zt}=my(St(mt),Ge),Us=`resume_${crypto.randomUUID().slice(0,8)}`;x.send({type:"spawn",id:Us,name:`Resume ${Ge.slice(0,8)}`,command:Ft,args:Zt,cwd:et??void 0,metadata:{type:"terminal"}}),oe(S,3e3)},t[58]=S,t[59]=x,t[60]=Ae):Ae=t[60];const Le=Ae;let ne;t[61]!==S?(ne=()=>{MP(),S()},t[61]=S,t[62]=ne):ne=t[62];let fe;t[63]!==me||t[64]!==N||t[65]!==le.loading||t[66]!==z||t[67]!==ne?(fe=r.jsx(YP,{loading:N,isMobile:me,searchQuery:z,searchLoading:le.loading,onSearchQueryChange:F,onRefresh:ne}),t[63]=me,t[64]=N,t[65]=le.loading,t[66]=z,t[67]=ne,t[68]=fe):fe=t[68];const Se=le.error??C,$e=ce.length===0&&!d&&!N&&!le.loading&&!C&&!le.error;let Ue;t[69]!==z?(Ue=z.trim(),t[69]=z,t[70]=Ue):Ue=t[70];const We=!!Ue,Xe=N||le.loading,Je=le.active?ce.length:y.length,De=le.error?le.refresh:S;let qe;t[71]!==Se||t[72]!==$e||t[73]!==We||t[74]!==Xe||t[75]!==Je||t[76]!==De?(qe=r.jsx(JP,{fetchError:Se,showEmpty:$e,searching:We,loading:Xe,sessionCount:Je,onRetry:De}),t[71]=Se,t[72]=$e,t[73]=We,t[74]=Xe,t[75]=Je,t[76]=De,t[77]=qe):qe=t[77];let ot;t[78]!==s||t[79]!==je||t[80]!==w||t[81]!==v||t[82]!==He||t[83]!==Le||t[84]!==Ce||t[85]!==O||t[86]!==u||t[87]!==j||t[88]!==h||t[89]!==m||t[90]!==Te?(ot=Te&&r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx(GP,{groups:je,activeSessionKey:s,procBySession:j,killingPids:O,sessionNames:m,projectNames:h,onSelectSession:Ce,onKill:w?He:void 0,onResumeSession:v?Le:void 0,onPrefetchSession:u}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Projects"}),r.jsx(It,{className:"flex-1"})]})]}),t[78]=s,t[79]=je,t[80]=w,t[81]=v,t[82]=He,t[83]=Le,t[84]=Ce,t[85]=O,t[86]=u,t[87]=j,t[88]=h,t[89]=m,t[90]=Te,t[91]=ot):ot=t[91];const lt=w?He:void 0,bt=a?Ee:void 0,$t=v?Le:void 0;let Vt;t[92]!==s||t[93]!==W||t[94]!==c||t[95]!==pe||t[96]!==Ce||t[97]!==O||t[98]!==k||t[99]!==i||t[100]!==l||t[101]!==u||t[102]!==Oe||t[103]!==d||t[104]!==j||t[105]!==h||t[106]!==g||t[107]!==p||t[108]!==z||t[109]!==m||t[110]!==lt||t[111]!==bt||t[112]!==$t||t[113]!==Y?(Vt=r.jsx(nA,{grouped:pe,pendingProjectPath:Oe,pendingSession:d,collapsedGroups:W,searchQuery:z,activeSessionKey:s,procBySession:j,killingPids:O,newlyCompleted:k,sessionNames:m,projectNames:h,onToggleCollapsed:Y,onSelectSession:Ce,onKill:lt,onDuplicateSession:i,onDeleteSession:bt,onRenameSession:p,onRenameProject:g,onNewSession:l,creatingSession:c,onPrefetchSession:u,onResumeSession:$t}),t[92]=s,t[93]=W,t[94]=c,t[95]=pe,t[96]=Ce,t[97]=O,t[98]=k,t[99]=i,t[100]=l,t[101]=u,t[102]=Oe,t[103]=d,t[104]=j,t[105]=h,t[106]=g,t[107]=p,t[108]=z,t[109]=m,t[110]=lt,t[111]=bt,t[112]=$t,t[113]=Y,t[114]=Vt):Vt=t[114];let Wt;t[115]!==qe||t[116]!==ot||t[117]!==Vt?(Wt=r.jsx(Nr,{className:"flex-1",children:r.jsxs("div",{className:"flex flex-col gap-4 p-2",children:[qe,ot,Vt]})}),t[115]=qe,t[116]=ot,t[117]=Vt,t[118]=Wt):Wt=t[118];let ts;return t[119]!==fe||t[120]!==Wt?(ts=r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[fe,Wt]}),t[119]=fe,t[120]=Wt,t[121]=ts):ts=t[121],ts}),aA=b.memo(function(e){const t=U.c(16),{activeSessionKey:s,onSelectSession:o,onNewSession:i,creatingSession:a,isMobile:l,onDuplicateSession:c,onDeleteSession:d,pendingSession:f,liveSessionsRefreshRef:u,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]!==a||t[4]!==u||t[5]!==d||t[6]!==c||t[7]!==i||t[8]!==m||t[9]!==o||t[10]!==f?(x=r.jsx(iA,{activeSessionKey:s,onSelectSession:o,onDuplicateSession:c,onDeleteSession:d,onNewSession:i,creatingSession:a,pendingSession:f,refreshRef:u,onPrefetchSession:m}),t[2]=s,t[3]=a,t[4]=u,t[5]=d,t[6]=c,t[7]=i,t[8]=m,t[9]=o,t[10]=f,t[11]=x):x=t[11];let v;return t[12]!==p||t[13]!==g||t[14]!==x?(v=r.jsxs("aside",{className:g,"aria-label":"Session browser",children:[p,x]}),t[12]=p,t[13]=g,t[14]=x,t[15]=v):v=t[15],v}),lA=b.lazy(()=>Ke(()=>import("./index-cjmnKg1q.js"),__vite__mapDeps([31,1,2,3,4])).then(n=>({default:n.MissionControl})));function H0(n){const e=U.c(3),{label:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Ut,{className:"size-4"}),e[0]=s):s=e[0];let o;return e[1]!==t?(o=r.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]=o):o=e[2],o}function K0(n){const e=U.c(12),{navigation:t,mobile:s,header:o}=n,i=s===void 0?!1:s,{sessionSource:a}=it(),l=a?`${a.dirName}/${a.fileName}`:null;let c;return e[0]!==l||e[1]!==o||e[2]!==i||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=r.jsx(aA,{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:i,header:o}),e[0]=l,e[1]=o,e[2]=i,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 q0(n){const e=U.c(8),{navigation:t}=n,{state:s}=Rt();let o;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?(o=r.jsx(CP,{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]=o):o=e[7],o}function cA(n){const e=U.c(3),{navigation:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(H0,{label:"Loading Mission Control…"}),e[0]=s):s=e[0];let o;return e[1]!==t.actions.handleDashboardSelect?(o=r.jsx(b.Suspense,{fallback:s,children:r.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 flex-col",children:r.jsx(lA,{onSelectSession:t.actions.handleDashboardSelect})})}),e[1]=t.actions.handleDashboardSelect,e[2]=o):o=e[2],o}function dA({mainView:n,hasSession:e,pendingDirName:t}){return n==="config"?"config":n==="mission"?"mission":e?"session":t?"pending":"dashboard"}function uA({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:o}){if(!e)return`@${n}`;const i=e.includes("```")?"````":"```",a=t===s?`line ${t}`:`lines ${t}-${s}`;return`${o?`Review request: ${o}
|
|
121
|
+
`:""}${n} (${a})
|
|
122
|
+
${i}
|
|
123
|
+
${e}
|
|
124
|
+
${i}`}const mA=b.lazy(()=>Ke(()=>import("./ConfigBrowser-Co4eu81Z.js"),__vite__mapDeps([32,1,2,33,3,4])).then(n=>({default:n.ConfigBrowser}))),pA=b.lazy(()=>Ke(()=>import("./PreviewPanel-i4Yn68yV.js"),__vite__mapDeps([34,1,2,3,4])).then(n=>({default:n.PreviewPanel}))),hA=b.lazy(()=>Ke(()=>import("./ProjectFilesPanel-DPLFARWn.js"),__vite__mapDeps([35,1,33,2,3,4])).then(n=>({default:n.ProjectFilesPanel})));function gA(n){const e=U.c(33),{navigation:t,sessionView:s,project:o,floatingChrome:i}=n,{state:a}=Rt(),{session:l}=it();if(!l)return null;const c=o.hasFileChanges&&t.panels.showFileChanges?70:100;let d;e[0]!==s.teamMembersBar?(d=s.teamMembersBar&&r.jsx("div",{className:"pt-10",children:s.teamMembersBar}),e[0]=s.teamMembersBar,e[1]=d):d=e[1];const f=!!s.todoProgress&&s.todosExpanded;let u;e[2]!==s.hasMoreTurns||e[3]!==s.isLoadingOlderTurns||e[4]!==s.onLoadMoreTurns||e[5]!==s.searchInputRef||e[6]!==f?(u=r.jsx(Sa,{searchInputRef:s.searchInputRef,hasTodos:f,hasMore:s.hasMoreTurns,isLoadingOlder:s.isLoadingOlderTurns,onLoadMore:s.onLoadMoreTurns}),e[2]=s.hasMoreTurns,e[3]=s.isLoadingOlderTurns,e[4]=s.onLoadMoreTurns,e[5]=s.searchInputRef,e[6]=f,e[7]=u):u=e[7];let m;e[8]!==s.onTodosExpandedChange||e[9]!==s.todoProgress||e[10]!==s.todosExpanded?(m=s.todoProgress&&r.jsx(q1,{progress:s.todoProgress,expanded:s.todosExpanded,onExpandedChange:s.onTodosExpandedChange}),e[8]=s.onTodosExpandedChange,e[9]=s.todoProgress,e[10]=s.todosExpanded,e[11]=m):m=e[11];let p;e[12]!==s.activeComposer||e[13]!==m?(p=r.jsxs(Ca,{floating:!0,children:[m,s.activeComposer]}),e[12]=s.activeComposer,e[13]=m,e[14]=p):p=e[14];let h;e[15]!==i||e[16]!==d||e[17]!==u||e[18]!==p?(h=r.jsxs("div",{className:"relative flex h-full min-h-0 flex-col",children:[i,d,u,p]}),e[15]=i,e[16]=d,e[17]=u,e[18]=p,e[19]=h):h=e[19];let g;e[20]!==c||e[21]!==h?(g=r.jsx(rp,{defaultSize:c,minSize:"500px",children:h}),e[20]=c,e[21]=h,e[22]=g):g=e[22];let x;e[23]!==t||e[24]!==o.hasFileChanges||e[25]!==l||e[26]!==s.fileChangesCollapsed||e[27]!==s.onFileChangesPanelResize||e[28]!==a?(x=o.hasFileChanges&&t.panels.showFileChanges&&r.jsxs(r.Fragment,{children:[r.jsx(q9,{withHandle:!0}),r.jsx(rp,{defaultSize:30,minSize:0,collapsible:!0,onResize:s.onFileChangesPanelResize,children:!s.fileChangesCollapsed&&r.jsx(R6,{session:l,sessionChangeKey:a.sessionChangeKey})})]}),e[23]=t,e[24]=o.hasFileChanges,e[25]=l,e[26]=s.fileChangesCollapsed,e[27]=s.onFileChangesPanelResize,e[28]=a,e[29]=x):x=e[29];let v;return e[30]!==g||e[31]!==x?(v=r.jsx("div",{className:"flex min-h-0 flex-1 bg-background",children:r.jsxs(K9,{orientation:"horizontal",className:"min-h-0 flex-1",children:[g,x]})}),e[30]=g,e[31]=x,e[32]=v):v=e[32],v}function xA(n){const e=U.c(38),{navigation:t,sessionView:s,project:o,view:i,floatingChrome:a}=n,{state:l}=Rt(),{session:c,sessionSource:d}=it();let f,u;if(e[0]!==(c==null?void 0:c.cwd)||e[1]!==d||e[2]!==l.configFilePath||e[3]!==l.dashboardProject||e[4]!==l.pendingCwd||e[5]!==l.pendingDirName||e[6]!==i){u=Symbol.for("react.early_return_sentinel");e:if(f=l.pendingCwd??(l.pendingDirName?hn(l.pendingDirName):null),i==="config"){let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(H0,{label:"Loading configuration…"}),e[9]=p):p=e[9];const h=r.jsx(mA,{projectPath:uA({sessionCwd:c==null?void 0:c.cwd,pendingPath:f,sessionDirPath:d!=null&&d.dirName?hn(d.dirName):null,dashboardProjectPath:l.dashboardProject?hn(l.dashboardProject):null}),initialFilePath:l.configFilePath});let g;e[10]!==h?(g=r.jsx(b.Suspense,{fallback:p,children:r.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 pt-10",children:h})}),e[10]=h,e[11]=g):g=e[11],u=g;break e}e[0]=c==null?void 0:c.cwd,e[1]=d,e[2]=l.configFilePath,e[3]=l.dashboardProject,e[4]=l.pendingCwd,e[5]=l.pendingDirName,e[6]=i,e[7]=f,e[8]=u}else f=e[7],u=e[8];if(u!==Symbol.for("react.early_return_sentinel"))return u;if(i==="mission"){let p;return e[12]!==t?(p=r.jsx("div",{className:"flex min-h-0 flex-1 flex-col pt-10",children:r.jsx(cA,{navigation:t})}),e[12]=t,e[13]=p):p=e[13],p}if(i==="session"){let p;return e[14]!==a||e[15]!==t||e[16]!==o||e[17]!==s?(p=r.jsx(gA,{navigation:t,sessionView:s,project:o,floatingChrome:a}),e[14]=a,e[15]=t,e[16]=o,e[17]=s,e[18]=p):p=e[18],p}if(i==="pending"){const p=s.pendingTurns.length>0,h=$s()?"Only on the machine running this session":void 0;let g;e[19]===Symbol.for("react.memo_cache_sentinel")?(g=Kc()?void 0:h,e[19]=g):g=e[19];const x=g,v=!p&&"justify-center gap-4";let w;e[20]!==v?(w=G("flex min-h-0 min-w-0 flex-1 flex-col bg-background",v),e[20]=v,e[21]=w):w=e[21];let y;e[22]!==p||e[23]!==f||e[24]!==s.pendingTurns?(y=p?r.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-14",children:r.jsx("div",{className:"mx-auto w-full max-w-[var(--chat-width)]",children:s.pendingTurns})}):r.jsx(y0,{projectPath:f}),e[22]=p,e[23]=f,e[24]=s.pendingTurns,e[25]=y):y=e[25];let j;e[26]!==s.pendingComposer?(j=r.jsx(Ca,{children:s.pendingComposer}),e[26]=s.pendingComposer,e[27]=j):j=e[27];let k;e[28]!==p||e[29]!==o?(k=!p&&r.jsxs("div",{className:"flex items-center justify-center gap-2",children:[ut("terminal")&&r.jsx(gl,{reason:h,children:r.jsxs(X,{variant:"outline",size:"xs",disabled:!!h,onClick:o.onOpenTerminal,children:[r.jsx(yo,{"data-icon":"inline-start"}),"Terminal"]})}),ut("hostFiles")&&r.jsxs(r.Fragment,{children:[r.jsx(gl,{reason:x,children:r.jsxs(X,{variant:"outline",size:"xs",disabled:!!x,onClick:()=>Sg(o.pendingProject),children:[r.jsx(mr,{"data-icon":"inline-start"}),"Open in editor"]})}),r.jsx(gl,{reason:h,children:r.jsxs(X,{variant:"outline",size:"xs",disabled:!!h,onClick:()=>kg(o.pendingProject),children:[r.jsx(th,{"data-icon":"inline-start"}),"Reveal in files"]})})]})]}),e[28]=p,e[29]=o,e[30]=k):k=e[30];let N;return e[31]!==w||e[32]!==y||e[33]!==j||e[34]!==k?(N=r.jsxs("div",{className:w,children:[y,j,k]}),e[31]=w,e[32]=y,e[33]=j,e[34]=k,e[35]=N):N=e[35],N}let m;return e[36]!==t?(m=r.jsx(q0,{navigation:t}),e[36]=t,e[37]=m):m=e[37],m}function bA(n){const e=U.c(78),{navigation:t,sessionView:s,project:o,chrome:i}=n,{state:a,config:l}=Rt(),{session:c}=it();let d;e[0]!==s.chatInputRef.current?(d=function(Y){var re,ie,ae;const{path:q,text:J,startLine:Z,endLine:Q,comment:ee}=Y,oe=fA({path:q,text:J,startLine:Z,endLine:Q,comment:ee}),se=((re=s.chatInputRef.current)==null?void 0:re.getText().trimEnd())??"";(ie=s.chatInputRef.current)==null||ie.setText(se?`${se}
|
|
125
|
+
|
|
126
|
+
${oe}
|
|
127
|
+
`:`${oe}
|
|
128
|
+
`),(ae=s.chatInputRef.current)==null||ae.focus()},e[0]=s.chatInputRef.current,e[1]=d):d=e[1];const f=d,u=a.mainView,m=!!c;let p;e[2]!==a.mainView||e[3]!==a.pendingDirName||e[4]!==m?(p=dA({mainView:u,hasSession:m,pendingDirName:a.pendingDirName}),e[2]=a.mainView,e[3]=a.pendingDirName,e[4]=m,e[5]=p):p=e[5];const h=p,g=t.panels.handleToggleSidebar,x=t.actions.handleGoHome,v=i.onOpenCommandPalette;let w,y;e[6]===Symbol.for("react.memo_cache_sentinel")?(w=pl("toggleSidebar"),y=pl("commandPalette"),e[6]=w,e[7]=y):(w=e[6],y=e[7]);let j;e[8]!==i.onOpenCommandPalette||e[9]!==t.actions.handleGoHome||e[10]!==t.panels.handleToggleSidebar?(j=r.jsx(a9,{onToggleSidebar:g,onGoHome:x,onOpenCommandPalette:v,sidebarShortcut:w,commandPaletteShortcut:y}),e[8]=i.onOpenCommandPalette,e[9]=t.actions.handleGoHome,e[10]=t.panels.handleToggleSidebar,e[11]=j):j=e[11];const k=j,N=t.panels.showSidebar&&a.mainView!=="config",C=t.panels.showSidebar;let S;e[12]===Symbol.for("react.memo_cache_sentinel")?(S=pl("toggleSidebar"),e[12]=S):S=e[12];const _=o.supportsWorktrees&&t.panels.showWorktrees,P=o.supportsWorktrees?t.panels.handleToggleWorktrees:void 0,A=a.mainView==="config",E=ut("configWrite")?t.panels.handleToggleConfig:void 0,T=a.mainView==="mission";let M;e[13]!==i.killing||e[14]!==i.onKillAll||e[15]!==l.openConfigDialog||e[16]!==t.creatingSession||e[17]!==t.handlers.handleDuplicateSession||e[18]!==t.onStartNewSession||e[19]!==t.panels.handleToggleFileChanges||e[20]!==t.panels.handleToggleMission||e[21]!==t.panels.handleToggleSidebar||e[22]!==t.panels.handleToggleStats||e[23]!==t.panels.showFileChanges||e[24]!==t.panels.showSidebar||e[25]!==t.panels.showStats||e[26]!==o.hasFileChanges||e[27]!==o.onOpenTerminal||e[28]!==s.onBackToMain||e[29]!==s.onShowWorkflows||e[30]!==s.workflowCount||e[31]!==N||e[32]!==_||e[33]!==P||e[34]!==A||e[35]!==E||e[36]!==T?(M=r.jsx(Z8,{showSidebar:C,sidebarRendered:N,sidebarShortcut:S,showStats:t.panels.showStats,showWorktrees:_,showFileChanges:t.panels.showFileChanges,hasFileChanges:o.hasFileChanges,killing:i.killing,creatingSession:t.creatingSession,onNewSession:t.onStartNewSession,onDuplicateSession:t.handlers.handleDuplicateSession,onOpenTerminal:o.onOpenTerminal,onBackToMain:s.onBackToMain,onShowWorkflows:s.onShowWorkflows,workflowCount:s.workflowCount,onToggleSidebar:t.panels.handleToggleSidebar,onToggleStats:t.panels.handleToggleStats,onToggleWorktrees:P,onToggleFileChanges:t.panels.handleToggleFileChanges,showConfig:A,onToggleConfig:E,showMission:T,onToggleMission:t.panels.handleToggleMission,onKillAll:i.onKillAll,onOpenSettings:l.openConfigDialog}),e[13]=i.killing,e[14]=i.onKillAll,e[15]=l.openConfigDialog,e[16]=t.creatingSession,e[17]=t.handlers.handleDuplicateSession,e[18]=t.onStartNewSession,e[19]=t.panels.handleToggleFileChanges,e[20]=t.panels.handleToggleMission,e[21]=t.panels.handleToggleSidebar,e[22]=t.panels.handleToggleStats,e[23]=t.panels.showFileChanges,e[24]=t.panels.showSidebar,e[25]=t.panels.showStats,e[26]=o.hasFileChanges,e[27]=o.onOpenTerminal,e[28]=s.onBackToMain,e[29]=s.onShowWorkflows,e[30]=s.workflowCount,e[31]=N,e[32]=_,e[33]=P,e[34]=A,e[35]=E,e[36]=T,e[37]=M):M=e[37];const I=M;let R;e[38]!==t||e[39]!==k||e[40]!==N?(R=N&&r.jsx("div",{className:"view-transition-sidebar panel-enter w-80 shrink-0 border-r bg-sidebar text-sidebar-foreground",children:r.jsx(K0,{navigation:t,header:k})}),e[38]=t,e[39]=k,e[40]=N,e[41]=R):R=e[41];const $=h!=="session"&&I;let D;e[42]!==I||e[43]!==t||e[44]!==o||e[45]!==s||e[46]!==h?(D=r.jsx(xA,{navigation:t,sessionView:s,project:o,view:h,floatingChrome:I}),e[42]=I,e[43]=t,e[44]=o,e[45]=s,e[46]=h,e[47]=D):D=e[47];let O;e[48]!==$||e[49]!==D?(O=r.jsxs("main",{className:"app-view-transition relative flex min-w-0 flex-1 flex-col overflow-hidden",children:[$,D]}),e[48]=$,e[49]=D,e[50]=O):O=e[50];const L=!o.showPreview&&!o.showProjectFiles&&t.panels.showStats&&!!c&&a.mainView!=="config",z=!o.showPreview&&!o.showProjectFiles&&!!c&&a.mainView!=="config";let F;e[51]!==t.actions.handleJumpToTurn||e[52]!==t.handlers.handleLoadSessionScrollAware||e[53]!==o.backgroundAgents||e[54]!==o.processPanel.handleServersChanged||e[55]!==o.processPanel.handleToggleServer||e[56]!==s.searchInputRef?(F=r.jsx(v0,{onJumpToTurn:t.actions.handleJumpToTurn,onToggleServer:o.processPanel.handleToggleServer,onServersChanged:o.processPanel.handleServersChanged,searchInputRef:s.searchInputRef,onLoadSession:t.handlers.handleLoadSessionScrollAware,backgroundAgents:o.backgroundAgents}),e[51]=t.actions.handleJumpToTurn,e[52]=t.handlers.handleLoadSessionScrollAware,e[53]=o.backgroundAgents,e[54]=o.processPanel.handleServersChanged,e[55]=o.processPanel.handleToggleServer,e[56]=s.searchInputRef,e[57]=F):F=e[57];let H;e[58]!==L||e[59]!==z||e[60]!==F?(H=r.jsx(r9,{side:"right",visible:L,enabled:z,children:F}),e[58]=L,e[59]=z,e[60]=F,e[61]=H):H=e[61];let B;e[62]!==o.currentCwd||e[63]!==o.onCloseRightWorkspace||e[64]!==o.showPreview?(B=o.showPreview&&o.currentCwd&&r.jsx(b.Suspense,{fallback:null,children:r.jsx(pA,{cwd:o.currentCwd,onClose:o.onCloseRightWorkspace})}),e[62]=o.currentCwd,e[63]=o.onCloseRightWorkspace,e[64]=o.showPreview,e[65]=B):B=e[65];let W;e[66]!==f||e[67]!==o.onCloseRightWorkspace||e[68]!==o.projectFilesRequest||e[69]!==o.projectFilesRoot||e[70]!==o.showProjectFiles?(W=o.showProjectFiles&&o.projectFilesRoot&&r.jsx(b.Suspense,{fallback:null,children:r.jsx(hA,{cwd:o.projectFilesRoot,onClose:o.onCloseRightWorkspace,onAddToPrompt:f,openRequest:o.projectFilesRequest})}),e[66]=f,e[67]=o.onCloseRightWorkspace,e[68]=o.projectFilesRequest,e[69]=o.projectFilesRoot,e[70]=o.showProjectFiles,e[71]=W):W=e[71];let K;return e[72]!==R||e[73]!==O||e[74]!==H||e[75]!==B||e[76]!==W?(K=r.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden bg-background",children:[R,O,H,B,W]}),e[72]=R,e[73]=O,e[74]=H,e[75]=B,e[76]=W,e[77]=K):K=e[77],K}function vA(n){const e=U.c(16),{navigation:t,sessionView:s,project:o,chrome:i}=n,{theme:a}=Rt(),l=`${a.themeClasses} flex h-dvh flex-col bg-background text-foreground`;let c,d;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(Y1,{}),d=r.jsx(G1,{}),e[0]=c,e[1]=d):(c=e[0],d=e[1]);let f;e[2]!==i||e[3]!==t||e[4]!==o||e[5]!==s?(f=r.jsx(bA,{navigation:t,sessionView:s,project:o,chrome:i}),e[2]=i,e[3]=t,e[4]=o,e[5]=s,e[6]=f):f=e[6];let u;e[7]!==i||e[8]!==t||e[9]!==o?(u=r.jsx(aE,{navigation:t,project:o,chrome:i}),e[7]=i,e[8]=t,e[9]=o,e[10]=u):u=e[10];let m;return e[11]!==i.backgroundServers||e[12]!==l||e[13]!==f||e[14]!==u?(m=r.jsxs("div",{className:l,children:[i.backgroundServers,c,d,f,u]}),e[11]=i.backgroundServers,e[12]=l,e[13]=f,e[14]=u,e[15]=m):m=e[15],m}const yA=[{id:"sessions",label:"Sessions",icon:Jo},{id:"chat",label:"Chat",icon:Vi},{id:"stats",label:"Stats",icon:oh,requiresSession:!0}],wA=b.memo(function(e){const t=U.c(17),{activeTab:s,onTabChange:o}=e,{session:i,isLive:a}=it(),l=i!==null;let c,d,f;if(t[0]!==s||t[1]!==l||t[2]!==a||t[3]!==o){let m;t[7]!==l?(m=g=>!(g.requiresSession&&!l),t[7]=l,t[8]=m):m=t[8];const p=yA.filter(m);c="flex shrink-0 items-stretch border-t bg-background pb-[env(safe-area-inset-bottom)]",d="Navigation";let h;t[9]!==s||t[10]!==a||t[11]!==o?(h=g=>{const x=g.icon,v=s===g.id;return r.jsx("button",{type:"button","aria-current":v?"page":void 0,"aria-label":g.label,title:g.label,onClick:()=>{lc(),o(g.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",v?"text-foreground":"text-muted-foreground hover:text-foreground"),children:r.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",v?"scale-100 bg-accent":"scale-95"),children:[r.jsx(x,{className:G("size-[18px] transition-transform duration-150 ease-out motion-reduce:transition-none",v&&"scale-110"),"aria-hidden":"true"}),g.id==="chat"&&a&&r.jsx(na,{className:"absolute right-0.5 top-0.5 size-1.5 ring-2 ring-background"})]})},g.id)},t[9]=s,t[10]=a,t[11]=o,t[12]=h):h=t[12],f=p.map(h),t[0]=s,t[1]=l,t[2]=a,t[3]=o,t[4]=c,t[5]=d,t[6]=f}else c=t[4],d=t[5],f=t[6];let u;return t[13]!==c||t[14]!==d||t[15]!==f?(u=r.jsx("nav",{className:c,"aria-label":d,children:f}),t[13]=c,t[14]=d,t[15]=f,t[16]=u):u=t[16],u});function jA(n){const e=U.c(63),{session:t,sessionSource:s,isSubAgentView:o,claudeRawMessages:i,creatingSession:a,onNewSession:l,onDuplicateSession:c,onBackToMain:d,onShowFileChanges:f,hasFileChanges:u,onShowWorkflows:m,workflowCount:p,onSearch:h,expandAll:g,onToggleExpandAll:x}=n;let v;e[0]!==l||e[1]!==t.cwd||e[2]!==s?(v=()=>{s&&l(s.dirName,t.cwd)},e[0]=l,e[1]=t.cwd,e[2]=s,e[3]=v):v=e[3];const w=v;let y;e[4]!==o||e[5]!==d?(y=o&&d&&r.jsx(X,{type:"button",variant:"ghost",size:"icon-sm",onClick:d,"aria-label":"Back to main agent",children:r.jsx(wc,{"data-icon":"inline-start"})}),e[4]=o,e[5]=d,e[6]=y):y=e[6];let j,k;e[7]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(Td,{compact:!0}),k=r.jsx(It,{orientation:"vertical",className:"h-4"}),e[7]=j,e[8]=k):(j=e[7],k=e[8]);let N;e[9]!==i?(N=r.jsx(eg,{rawMessages:i,warnOnly:!0}),e[9]=i,e[10]=N):N=e[10];let C;e[11]!==t.cwd?(C=t.cwd?zn(t.cwd):"Session",e[11]=t.cwd,e[12]=C):C=e[12];let S;e[13]!==C?(S=r.jsx("span",{className:"min-w-0 flex-1 truncate text-center text-xs font-medium text-muted-foreground",children:C}),e[13]=C,e[14]=S):S=e[14];let _;e[15]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(Mn,{render:r.jsx(X,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Session actions"}),children:r.jsx(sh,{"data-icon":"inline-start"})}),e[15]=_):_=e[15];let P;e[16]!==t.cwd?(P=t.cwd?zn(t.cwd):"Current session",e[16]=t.cwd,e[17]=P):P=e[17];let A;e[18]!==P?(A=r.jsx("span",{className:"truncate text-foreground",children:P}),e[18]=P,e[19]=A):A=e[19];let E;e[20]!==t.gitBranch||e[21]!==t.model?(E=[t.model,t.gitBranch].filter(Boolean).join(" · ")||"Session actions",e[20]=t.gitBranch,e[21]=t.model,e[22]=E):E=e[22];let T;e[23]!==E?(T=r.jsx("span",{className:"truncate font-normal",children:E}),e[23]=E,e[24]=T):T=e[24];let M;e[25]!==A||e[26]!==T?(M=r.jsxs(hs,{className:"flex flex-col gap-0.5",children:[A,T]}),e[25]=A,e[26]=T,e[27]=M):M=e[27];let I;e[28]!==a||e[29]!==w||e[30]!==s?(I=s&&r.jsxs(ct,{onClick:w,disabled:a,children:[a?r.jsx(Ut,{}):r.jsx(_n,{}),r.jsx("span",{children:"New session"})]}),e[28]=a,e[29]=w,e[30]=s,e[31]=I):I=e[31];let R;e[32]!==c?(R=c&&r.jsxs(ct,{onClick:c,children:[r.jsx(En,{}),r.jsx("span",{children:"Duplicate session"})]}),e[32]=c,e[33]=R):R=e[33];let $;e[34]!==M||e[35]!==I||e[36]!==R?($=r.jsxs(Bt,{children:[M,I,R]}),e[34]=M,e[35]=I,e[36]=R,e[37]=$):$=e[37];let D;e[38]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(io,{}),e[38]=D):D=e[38];let O;e[39]!==h?(O=h&&r.jsxs(ct,{onClick:h,children:[r.jsx(xn,{}),r.jsx("span",{children:"Search conversation"})]}),e[39]=h,e[40]=O):O=e[40];let L;e[41]!==g||e[42]!==x?(L=x&&r.jsxs(ct,{onClick:x,children:[g?r.jsx(qi,{}):r.jsx(Hi,{}),r.jsx("span",{children:g?"Collapse tool calls":"Expand tool calls"})]}),e[41]=g,e[42]=x,e[43]=L):L=e[43];let z;e[44]!==u||e[45]!==f?(z=u&&f&&r.jsxs(ct,{onClick:f,children:[r.jsx(gr,{}),r.jsx("span",{children:"File changes"})]}),e[44]=u,e[45]=f,e[46]=z):z=e[46];let F;e[47]!==m||e[48]!==p?(F=m&&(p??0)>0&&r.jsxs(ct,{onClick:m,children:[r.jsx(nh,{}),r.jsx("span",{className:"flex-1",children:"Workflows"}),r.jsx(Me,{variant:"secondary",children:p})]}),e[47]=m,e[48]=p,e[49]=F):F=e[49];let H;e[50]!==O||e[51]!==L||e[52]!==z||e[53]!==F?(H=r.jsxs(Bt,{children:[O,L,z,F]}),e[50]=O,e[51]=L,e[52]=z,e[53]=F,e[54]=H):H=e[54];let B;e[55]!==$||e[56]!==H?(B=r.jsxs(Rn,{children:[_,r.jsxs(In,{align:"end",sideOffset:6,className:"w-72",children:[$,D,H]})]}),e[55]=$,e[56]=H,e[57]=B):B=e[57];let W;return e[58]!==y||e[59]!==B||e[60]!==N||e[61]!==S?(W=r.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-1.5 border-b bg-background px-2",children:[y,j,k,N,S,B]}),e[58]=y,e[59]=B,e[60]=N,e[61]=S,e[62]=W):W=e[62],W}const SA=b.memo(function(e){const t=U.c(11),{isMobile:s}=Rt(),{session:o,sessionSource:i}=it();if(!s||!o)return null;let a;t[0]!==i?(a=i?bs(i.fileName):null,t[0]=i,t[1]=a):a=t[1];const l=a;let c;t[2]!==o||t[3]!==(i==null?void 0:i.dirName)?(c=uo(i==null?void 0:i.dirName).contextWindow?o.rawMessages:[],t[2]=o,t[3]=i==null?void 0:i.dirName,t[4]=c):c=t[4];const d=c,f=l!==null;let u;return t[5]!==d||t[6]!==e||t[7]!==o||t[8]!==i||t[9]!==f?(u=r.jsx(jA,{...e,onDuplicateSession:e.onDuplicateSession,session:o,sessionSource:i,isSubAgentView:f,claudeRawMessages:d}),t[5]=d,t[6]=e,t[7]=o,t[8]=i,t[9]=f,t[10]=u):u=t[10],u});function kA({onSwipeLeft:n,onSwipeRight:e,threshold:t=50,enabled:s=!0}){const o=b.useRef(null),i=b.useRef(null),a=b.useRef(n),l=b.useRef(e);return a.current=n,l.current=e,b.useEffect(()=>{const c=o.current;if(!c||!s)return;function d(u){const m=u.touches[0];i.current={x:m.clientX,y:m.clientY}}function f(u){var g,x;if(!i.current)return;const m=u.changedTouches[0],p=m.clientX-i.current.x,h=m.clientY-i.current.y;i.current=null,!(Math.abs(p)<t||Math.abs(p)<Math.abs(h))&&(p>0?(g=l.current)==null||g.call(l):(x=a.current)==null||x.call(a))}return c.addEventListener("touchstart",d,{passive:!0}),c.addEventListener("touchend",f,{passive:!0}),()=>{c.removeEventListener("touchstart",d),c.removeEventListener("touchend",f)}},[s,t]),o}const NA=["sessions","chat","stats"];function CA({hasSession:n,hasPendingSession:e}){return NA.filter(t=>!(t==="stats"&&!n&&!e))}function fp(n,e,t){const s=n.indexOf(e);return s===-1?null:n[s+t]??null}const _A=b.lazy(()=>Ke(()=>import("./MobileFileChanges-DiOncgtO.js"),__vite__mapDeps([36,1,2,3,4])).then(n=>({default:n.MobileFileChanges})));function TA(n){const e=U.c(71),{navigation:t,sessionView:s,project:o,chrome:i}=n,{state:a,theme:l}=Rt(),{session:c,isSubAgentView:d}=it(),f=!!c,u=!!a.pendingDirName;let m;e[0]!==f||e[1]!==u?(m=CA({hasSession:f,hasPendingSession:u}),e[0]=f,e[1]=u,e[2]=m):m=e[2];const p=m;let h;e[3]!==t.actions||e[4]!==a.mobileTab||e[5]!==p?(h={enabled:!0,onSwipeLeft:()=>{const z=fp(p,a.mobileTab,1);z&&(lc(),t.actions.handleMobileTabChange(z))},onSwipeRight:()=>{const z=fp(p,a.mobileTab,-1);z&&(lc(),t.actions.handleMobileTabChange(z))}},e[3]=t.actions,e[4]=a.mobileTab,e[5]=p,e[6]=h):h=e[6];const g=kA(h);let x;e[7]!==i||e[8]!==t.actions?(x=z=>{i.onSearchOpenChange(!1),t.actions.handleMobileTabChange(z)},e[7]=i,e[8]=t.actions,e[9]=x):x=e[9];const v=x,w=`${l.themeClasses} flex h-dvh flex-col bg-background text-foreground`,y=i.backgroundServers;let j,k;e[10]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(Y1,{}),k=r.jsx(G1,{}),e[10]=j,e[11]=k):(j=e[10],k=e[11]);let N;e[12]!==c||e[13]!==a.mobileTab?(N=!(a.mobileTab==="chat"&&c)&&r.jsx("div",{className:"motion-slide-down-in flex h-12 shrink-0 items-center border-b bg-background px-2",children:r.jsx(Td,{compact:!0})}),e[12]=c,e[13]=a.mobileTab,e[14]=N):N=e[14];const C=a.mobileTab,S=!(a.mobileTab==="chat"&&c)&&"motion-session-enter";let _;e[15]!==S?(_=G("flex min-h-0 min-w-0 flex-1",S),e[15]=S,e[16]=_):_=e[16];let P;e[17]!==t||e[18]!==a.mobileTab?(P=a.mobileTab==="sessions"&&r.jsx(K0,{navigation:t,mobile:!0}),e[17]=t,e[18]=a.mobileTab,e[19]=P):P=e[19];let A;e[20]!==i||e[21]!==d||e[22]!==t||e[23]!==o||e[24]!==c||e[25]!==s||e[26]!==a.expandAll||e[27]!==a.mobileTab||e[28]!==a.pendingDirName?(A=a.mobileTab==="chat"&&r.jsx("div",{className:"flex flex-1 min-h-0 flex-col min-w-0",children:c?r.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[s.teamMembersBar,r.jsx(SA,{creatingSession:t.creatingSession,onNewSession:t.onStartNewSession,onDuplicateSession:t.handlers.handleDuplicateSession,onOpenTerminal:o.onOpenTerminal,onBackToMain:d?s.onBackToMain:void 0,onShowFileChanges:()=>i.onFileChangesOpenChange(!0),hasFileChanges:o.hasFileChanges,onShowWorkflows:s.onShowWorkflows,workflowCount:s.workflowCount,onSearch:()=>i.onSearchOpenChange(!0),expandAll:a.expandAll,onToggleExpandAll:s.onToggleExpandAll}),r.jsx(Sa,{searchInputRef:s.searchInputRef,hasMore:s.hasMoreTurns,isLoadingOlder:s.isLoadingOlderTurns,onLoadMore:s.onLoadMoreTurns,mobileSearchOpen:i.searchOpen,onMobileSearchClose:()=>i.onSearchOpenChange(!1)})]}):a.pendingDirName?r.jsx("div",{className:"flex flex-1 min-h-0 flex-col",children:s.pendingTurns.length>0?r.jsx("div",{className:"flex-1 overflow-y-auto px-1 py-3",children:s.pendingTurns}):r.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-4 px-4",children:[r.jsx(y0,{projectPath:s.pendingPath??null}),ut("terminal")&&r.jsxs(X,{variant:"outline",size:"xs",onClick:o.onOpenTerminal,children:[r.jsx(yo,{"data-icon":"inline-start"}),"Terminal"]})]})}):r.jsx(q0,{navigation:t})}),e[20]=i,e[21]=d,e[22]=t,e[23]=o,e[24]=c,e[25]=s,e[26]=a.expandAll,e[27]=a.mobileTab,e[28]=a.pendingDirName,e[29]=A):A=e[29];let E;e[30]!==t.handlers||e[31]!==o||e[32]!==c||e[33]!==a.mobileTab?(E=a.mobileTab==="stats"&&c&&r.jsx(v0,{onJumpToTurn:t.handlers.handleMobileJumpToTurn,onToggleServer:o.processPanel.handleToggleServer,onServersChanged:o.processPanel.handleServersChanged,onLoadSession:t.handlers.handleLoadSessionScrollAware,backgroundAgents:o.backgroundAgents}),e[30]=t.handlers,e[31]=o,e[32]=c,e[33]=a.mobileTab,e[34]=E):E=e[34];let T;e[35]!==a.mobileTab||e[36]!==_||e[37]!==P||e[38]!==A||e[39]!==E?(T=r.jsxs("div",{className:_,children:[P,A,E]},C),e[35]=a.mobileTab,e[36]=_,e[37]=P,e[38]=A,e[39]=E,e[40]=T):T=e[40];let M;e[41]!==g||e[42]!==T?(M=r.jsx("main",{ref:g,className:"app-view-transition flex flex-1 min-h-0 overflow-hidden",children:T}),e[41]=g,e[42]=T,e[43]=M):M=e[43];const I=a.mobileTab==="chat"&&i.processPanel;let R;e[44]!==c||e[45]!==s||e[46]!==a.mobileTab||e[47]!==a.pendingDirName?(R=a.mobileTab==="chat"&&(c||a.pendingDirName)&&r.jsxs(r.Fragment,{children:[s.todoProgress,c?s.activeComposer:s.pendingComposer]}),e[44]=c,e[45]=s,e[46]=a.mobileTab,e[47]=a.pendingDirName,e[48]=R):R=e[48];let $;e[49]!==I||e[50]!==R?($=r.jsxs("div",{className:"shrink-0",children:[I,R]}),e[49]=I,e[50]=R,e[51]=$):$=e[51];let D;e[52]!==v||e[53]!==a.mobileTab?(D=r.jsx(wA,{activeTab:a.mobileTab,onTabChange:v}),e[52]=v,e[53]=a.mobileTab,e[54]=D):D=e[54];let O;e[55]!==i||e[56]!==o||e[57]!==c||e[58]!==a.sessionChangeKey?(O=c&&o.hasFileChanges&&r.jsx(b.Suspense,{fallback:null,children:r.jsx(_A,{open:i.fileChangesOpen,onClose:()=>i.onFileChangesOpenChange(!1),session:c,sessionChangeKey:a.sessionChangeKey})}),e[55]=i,e[56]=o,e[57]=c,e[58]=a.sessionChangeKey,e[59]=O):O=e[59];let L;return e[60]!==i.backgroundServers||e[61]!==i.branchModal||e[62]!==i.undoDialog||e[63]!==i.workflowsPanel||e[64]!==N||e[65]!==M||e[66]!==$||e[67]!==D||e[68]!==O||e[69]!==w?(L=r.jsxs("div",{className:w,children:[y,j,k,N,M,$,i.workflowsPanel,D,i.undoDialog,i.branchModal,O]}),e[60]=i.backgroundServers,e[61]=i.branchModal,e[62]=i.undoDialog,e[63]=i.workflowsPanel,e[64]=N,e[65]=M,e[66]=$,e[67]=D,e[68]=O,e[69]=w,e[70]=L):L=e[70],L}function EA(n){const e=U.c(13),{sessionId:t,loadError:s,searchInputRef:o,activeComposer:i,hasMoreTurns:a,isLoadingOlderTurns:l,onLoadMoreTurns:c}=n,{theme:d,isMobile:f}=Rt(),{session:u}=it(),m=`${d.themeClasses} flex h-dvh flex-col overflow-hidden bg-background text-foreground`;let p;e[0]!==i||e[1]!==a||e[2]!==l||e[3]!==f||e[4]!==s||e[5]!==c||e[6]!==o||e[7]!==u||e[8]!==t?(p=u?r.jsxs("main",{className:"relative flex min-h-0 flex-1 flex-col",children:[r.jsx(Sa,{searchInputRef:o,hasMore:a,isLoadingOlder:l,onLoadMore:c}),f?i:r.jsx(Ca,{floating:!0,children:i})]}):r.jsx("main",{className:"flex min-h-0 flex-1 items-center justify-center p-6",children:r.jsx(Hn,{className:"max-w-md",children:r.jsxs(Kn,{children:[r.jsx(js,{variant:"icon",children:s?r.jsx(bn,{}):r.jsx(rt,{className:"animate-spin"})}),r.jsx(qn,{children:s?"Unable to open session":"Opening session"}),r.jsx(Vn,{children:s??`Looking for ${t} in your local Claude, Codex, and Copilot history.`})]})})}),e[0]=i,e[1]=a,e[2]=l,e[3]=f,e[4]=s,e[5]=c,e[6]=o,e[7]=u,e[8]=t,e[9]=p):p=e[9];let h;return e[10]!==m||e[11]!==p?(h=r.jsx("div",{className:m,children:p}),e[10]=m,e[11]=p,e[12]=h):h=e[12],h}const PA=5;function ai(n,e){const t=fn(),s=ms();return`${s===null?t:`${t}:${s}`}:${n}/${e}`}class AA{constructor(){Wr(this,"cache",new Map)}get(e,t){const s=ai(e,t),o=this.cache.get(s);return o&&(o.lastAccessed=Date.now()),o}set(e,t,s,o,i,a,l,c){const d=ai(e,t);!this.cache.has(d)&&this.cache.size>=PA&&this.evictLRU(),this.cache.set(d,{parsed:s,olderTurns:[],source:{dirName:e,fileName:t,rawText:o,agentKind:l,...c!==void 0?{watchOffset:c}:{}},nextByteOffset:i,hasMore:a,lastAccessed:Date.now()})}update(e,t,s){const o=ai(e,t),i=this.cache.get(o);i&&(s.parsed!==void 0&&(i.parsed=s.parsed),s.olderTurns!==void 0&&(i.olderTurns=s.olderTurns),s.nextByteOffset!==void 0&&(i.nextByteOffset=s.nextByteOffset),s.hasMore!==void 0&&(i.hasMore=s.hasMore),s.lastAccessed!==void 0&&(i.lastAccessed=s.lastAccessed),s.source&&(i.source={...i.source,...s.source}))}evict(e,t){e!==void 0&&t!==void 0?this.cache.delete(ai(e,t)):this.evictLRU()}clear(){this.cache.clear()}evictLRU(){let e,t=1/0;for(const[s,o]of this.cache)o.lastAccessed<t&&(t=o.lastAccessed,e=s);e!==void 0&&this.cache.delete(e)}}const pn=new AA,mp={};function V0(n,e,t,s,o,i){const[a,l]=b.useState(!1),[c,d]=b.useState("disconnected"),[f,u]=b.useState(!1),[m,p]=b.useState(null),[h,g]=b.useState(mp),[x,v]=b.useState(null),[w,y]=b.useState(no),j=b.useRef(""),k=b.useRef(null),N=b.useRef(no),C=b.useRef("disconnected"),S=b.useRef(e);S.current=e;const _=b.useRef(o);_.current=o;const P=b.useRef(t);P.current=t;const A=b.useRef(s);A.current=s;const E=b.useRef(i??null);E.current=i??null;const T=b.useRef(!1),M=(n==null?void 0:n.dirName)??null,I=(n==null?void 0:n.fileName)??null,R=(n==null?void 0:n.rawText)??"",$=(n==null?void 0:n.watchOffset)??new TextEncoder().encode(R).byteLength;return b.useEffect(()=>{if(j.current=R,!R){k.current=null,l(!1);return}const D=E.current;if(D){k.current=D;return}P.current(R).then(O=>{k.current=O})},[R]),b.useEffect(()=>{if(v(null),!M||!I){l(!1),d("disconnected");return}d("connecting");const D=`/api/watch/${encodeURIComponent(M)}/${encodeURIComponent(I)}?offset=${$}`,O=new EventSource(vr(D));let L=null;const z=(ae=3e4)=>{L&&clearTimeout(L),L=setTimeout(()=>{l(!1),u(!1)},ae)};let F="",H=$,B=!1,W=!1,K=!1,V=null;const Y=()=>{K=!1,V=null,k.current&&S.current(k.current)},q=()=>{K||(K=!0,V=requestAnimationFrame(Y))};let J=!1,Z=null,Q=null;const ee=()=>{J=!1,Z=null,y(N.current)},oe=()=>{J||(J=!0,Z=requestAnimationFrame(ee))},se=ae=>{ae!==N.current&&(N.current=ae,oe(),ae.length>0&&!Q&&(Q=setInterval(()=>{const te=VC(N.current);te!==N.current&&(N.current=te,oe()),N.current.length===0&&Q&&(clearInterval(Q),Q=null)},5e3)))},re=()=>{se(no),g(mp)},ie=()=>{if(W||B||!F)return;const ae=F;F="",B=!0;const te=k.current;(te?A.current(te,ae):P.current(j.current)).then(me=>{W||(k.current=me,M&&I&&pn.update(M,I,{parsed:me,source:{rawText:j.current,watchOffset:H}}),q())}).catch(me=>{console.error("[useLiveSession] worker parse failed:",me)}).finally(()=>{B=!1,!W&&F&&ie()})};return O.onopen=()=>{var ae;if(C.current!=="connected"){const te=T.current;T.current=!1,C.current="connected",d("connected"),te&&((ae=_.current)==null||ae.call(_))}},O.onmessage=ae=>{try{C.current!=="connected"&&(C.current="connected",d("connected"));const te=JSON.parse(ae.data);if(te.type==="init")te.recentlyActive?(l(!0),z(5e3)):z();else if(te.type==="compacting_in_progress")l(!0),u(!0),re(),z();else if(te.type==="subagent_activity")l(!0),z();else if(te.type==="copilot_activity")l(!0),z();else if(te.type==="stream_snapshot")l(!0),z(),se(HC(te.messages??[]));else if(te.type==="stream_delta")l(!0),z(),p(null),v(null),se(KC(N.current,te.events??[]));else if(te.type==="agent_progress")l(!0),z(),g(he=>({...he,[te.toolUseId]:te.summary}));else if(te.type==="prompt_suggestion")v(typeof te.suggestion=="string"?te.suggestion:null);else if(te.type==="turn_error")p(typeof te.message=="string"?te.message:"The turn failed");else if(te.type==="stream_clear")re();else if(te.type==="lines"&&te.lines.length>0){l(!0),u(!1),z(),se(qC(N.current,te.lines));const he=te.lines.join(`
|
|
129
|
+
`)+`
|
|
130
|
+
`;H+=new TextEncoder().encode(he).byteLength,j.current+=he,F+=he,ie()}}catch(te){console.error("[useLiveSession] Error processing SSE message:",te)}},O.onerror=()=>{l(!1),u(!1),T.current=C.current==="connected",C.current="disconnected",d("disconnected"),re()},()=>{W=!0,O.close(),l(!1),C.current="disconnected",d("disconnected"),L&&clearTimeout(L),V!==null&&cancelAnimationFrame(V),Z!==null&&cancelAnimationFrame(Z),Q&&clearInterval(Q),N.current=no,y(no)}},[M,I,R,$]),{isLive:a,sseState:c,isCompacting:f,streamingOverlay:w,turnError:m,agentProgress:h,promptSuggestion:x}}const RA=3e4;function G0(n,e,t){const s=U.c(9),o=RA,[i,a]=b.useState(!1),l=b.useRef(e);let c,d;s[0]!==e?(c=()=>{l.current=e},d=[e],s[0]=e,s[1]=c,s[2]=d):(c=s[1],d=s[2]),b.useEffect(c,d);let f,u;s[3]!==o||s[4]!==n?(f=()=>{if(!n){a(!1);return}let p=!0,h=null;const g=new EventSource(vr(n));a(!1);const x=()=>{h&&clearTimeout(h),h=setTimeout(()=>{p&&a(!1)},o)};return g.onmessage=v=>{if(p)try{const w=JSON.parse(v.data);w.type==="init"?x():w.type==="update"&&(a(!0),x(),l.current())}catch{}},g.onerror=()=>{p&&a(!1)},()=>{p=!1,g.close(),h&&clearTimeout(h)}},u=[n,o],s[3]=o,s[4]=n,s[5]=f,s[6]=u):(f=s[5],u=s[6]),b.useEffect(f,u);let m;return s[7]!==i?(m={isLive:i},s[7]=i,s[8]=m):m=s[8],m}function MA(n,e){const t=n?`/api/team-watch/${encodeURIComponent(n)}`:null;return G0(t,e)}function IA(n,e){const[t,s]=b.useState(null),o=b.useRef(null),i=(()=>{if(!n)return null;let l,c=null;const d=n.match(/^([^/]+)\/subagents\/(.+)$/);d?(l=d[1],c=d[2]):l=n.replace(".jsonl","");const f=new URLSearchParams({leadSessionId:l});return c&&f.set("subagentFile",c),e&&f.set("dirName",e),f.toString()})();o.current=i;const a=b.useCallback(async()=>{const l=o.current;if(l)try{const c=await ye(`/api/session-team?${l}`);if(!c.ok){s(null);return}const d=await c.json();s(d?{teamName:d.teamName,config:d.config,currentMemberName:d.currentMemberName||null}:null)}catch{s(null)}},[]);return b.useEffect(()=>{if(!n){s(null);return}a()},[n,a]),MA((t==null?void 0:t.teamName)??null,a),t}function $A(n,e,t,s){let o=null;return n&&e&&(o=`/api/workflow-watch/${encodeURIComponent(n)}/${encodeURIComponent(e)}`,t&&(o=o+`/${encodeURIComponent(t)}`)),G0(o,s)}function OA(n,e,t=!0){const[s,o]=b.useState([]),[i,a]=b.useState(!1),l=b.useRef(0),c=!!n&&!!e,d=b.useCallback(async()=>{const m=++l.current;if(!c){o([]);return}try{const p=await ye(`/api/workflows/${encodeURIComponent(n)}/${encodeURIComponent(e)}`);if(!p.ok){m===l.current&&o([]);return}const h=await p.json();m===l.current&&o(Array.isArray(h)?h:[])}catch{m===l.current&&o([])}finally{m===l.current&&a(!1)}},[c,n,e]);b.useEffect(()=>{if(!c){o([]),a(!1);return}a(!0),d()},[c,d]);const f=c&&(t||s.length>0),{isLive:u}=$A(f?n:null,f?e:null,null,d);return{workflows:s,loading:i,isLive:u,refetch:d}}const Oi={mode:"bypassPermissions",allowedTools:[],disallowedTools:[]},DA="cogpit:permissions";function LA(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 pp(n,e){const t=await n.json().catch(()=>({error:e}));return typeof t.error=="string"&&t.error?t.error:e}async function Y0(n,{model:e,agentKind:t,errorFallback:s,onModelRejected:o}){const i=d=>typeof s=="function"?s(d):s;let l=await n(t==="copilot"?e||"auto":e||void 0),c=l.ok?null:await pp(l,i(l));return!l.ok&&t==="codex"&&e&&LA(c)&&(o==null||o(e),l=await n(void 0),c=l.ok?null:await pp(l,i(l))),{res:l,errorMessage:c}}function zA({sessionSource:n,parsedSessionId:e,cwd:t,permissions:s,onPermissionsApplied:o,model:i,effort:a,fastMode:l,ultracode:c,mcpConfig:d,onCodexModelRejected:f,readOnly:u=!1,onCreateSession:m}){const[p,h]=b.useState("idle"),[g,x]=b.useState(),[v,w]=b.useState([]),y=b.useRef(null),j=b.useRef(null),k=b.useRef(!1),N=n!=null&&n.fileName?Rl(n.fileName):null,C=e||N,S=n?St(n.dirName):null,_=b.useCallback(()=>{var R;(R=y.current)==null||R.abort(),y.current=null,k.current=!1,h("idle"),x(void 0),w([])},[]);b.useEffect(()=>{var R;j.current!==C&&(k.current?(k.current=!1,(R=y.current)==null||R.abort(),y.current=null,h("idle"),x(void 0)):_(),j.current=C)},[C,_]),b.useEffect(()=>()=>{var R;(R=y.current)==null||R.abort()},[]),b.useEffect(()=>{u&&_()},[u,_]);const P=b.useCallback(async(R,$)=>{if(u)return;if(!C&&m){w(L=>[...L,R]),h("connected"),x(void 0),k.current=!0,o==null||o();try{if(!await m(R,$)){k.current=!1,h("idle"),w([]);return}h("idle")}catch(L){k.current=!1,x(L instanceof Error?L.message:"Failed to create session"),h("error"),w([])}return}if(!C)return;w(L=>[...L,R]),h("connected"),x(void 0);const D=s??Oi;o==null||o();const O=new AbortController;y.current=O;try{const L={sessionId:C,message:R,images:$||void 0,cwd:t||void 0,permissions:D,effort:a||void 0,fastMode:l?!0:void 0,ultracode:c?!0:void 0,mcpConfig:d||void 0},{res:z,errorMessage:F}=await Y0(H=>ye("/api/send-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...L,model:H}),signal:O.signal}),{model:i,agentKind:S,errorFallback:H=>`Request failed (${H.status})`,onModelRejected:f});y.current===O&&(z.ok?h("idle"):(x(F||`Request failed (${z.status})`),h("error"),w(H=>H.slice(0,-1))))}catch(L){if(L instanceof Error&&L.name==="AbortError")return;y.current===O&&(x(L instanceof Error?L.message:"Unknown error"),h("error"),w(z=>z.slice(0,-1)))}},[C,S,t,s,o,i,a,l,c,d,f,u,m]),A=b.useCallback(()=>{_()},[_]),E=b.useCallback(()=>{!C||u||ye("/api/interrupt-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:C})}).catch(()=>{})},[C,u]),T=b.useCallback(()=>{var R;(R=y.current)==null||R.abort(),y.current=null,E(),h("idle"),w([])},[E]),M=T,I=b.useCallback((R=1)=>{w($=>$.slice(R))},[]);return{status:p,error:g,pendingMessages:v,sendMessage:P,disconnect:A,interrupt:T,stopAgent:M,consumePending:I,isConnected:p==="connected"}}const os={expandAll:!1,expandToolPayloads:!1},FA={session:null,windowTurns:[],olderTurns:[],sessionSource:null,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...os,sessionChangeKey:0,currentMemberName:null,loadingMember:null,mainView:"sessions",configFilePath:null,mobileTab:"sessions",dashboardProject:null};function hp(n,e,t,s){const o=Jx(e,t,s);return o===n.turns?n:{...n,turns:o}}function Zs(n){return{session:n,windowTurns:(n==null?void 0:n.turns)??[],olderTurns:[]}}function BA(n,e){var t,s;switch(e.type){case"LOAD_SESSION":return{...n,...Zs(e.session),sessionSource:e.source,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...os,mainView:"sessions",currentMemberName:null,dashboardProject:null,sessionChangeKey:n.sessionChangeKey+1,mobileTab:e.isMobile?"chat":n.mobileTab};case"GO_HOME":return{...n,...Zs(null),sessionSource:null,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...os,mainView:"sessions",currentMemberName:null,dashboardProject:null,mobileTab:e.isMobile?"sessions":n.mobileTab};case"SWITCH_TEAM_MEMBER":return{...n,...Zs(e.session),sessionSource:e.source,activeTurnIndex:null,searchQuery:"",...os,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,...os};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,...os}:{...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:hp(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:hp(n.session,n.windowTurns,e.turns,(s=n.sessionSource)==null?void 0:s.agentKind)};case"RELOAD_SESSION_CONTENT":return{...n,...Zs(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 o=n.mobileTab;return!e.hasSession&&(o==="stats"||o==="chat")&&(o="sessions"),o!==n.mobileTab?{...n,mobileTab:o}: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"INIT_PENDING_SESSION":return{...n,...Zs(null),sessionSource:null,pendingDirName:e.dirName,pendingCwd:e.cwd??null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...os,mainView:"sessions",currentMemberName:null,dashboardProject:null,sessionChangeKey:n.sessionChangeKey+1,mobileTab:e.isMobile?"chat":n.mobileTab};case"FINALIZE_SESSION":return{...n,...Zs(e.session),sessionSource:e.source,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...os,mainView:"sessions",currentMemberName:null,dashboardProject:null,sessionChangeKey:n.sessionChangeKey+1,mobileTab:e.isMobile?"chat":n.mobileTab};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"};default:return n}}function X0(){return b.useReducer(BA,FA)}function gp(n){n(),requestAnimationFrame(()=>{n(),requestAnimationFrame(n)})}function J0({session:n,isLive:e,pendingMessages:t,consumePending:s,sessionChangeKey:o,partialContentLen:i=0}){const a=b.useRef(null),l=b.useRef(null),c=b.useRef(!0),d=b.useRef(!1),f=b.useRef(0),u=b.useMemo(()=>(n==null?void 0:n.turns.flatMap(O=>O.contentBlocks.flatMap(L=>L.kind==="queued_prompt"?[{id:JSON.stringify([L.timestamp??"",L.content]),content:L.content}]:[])))??[],[n==null?void 0:n.turns]),m=b.useRef(null),p=b.useRef(!1),[h,g]=b.useState(!1),[x,v]=b.useState(!1),[w,y]=b.useState(null),j=b.useCallback(()=>{requestAnimationFrame(()=>{var O;(O=l.current)==null||O.scrollIntoView({behavior:"smooth"})})},[]),k=b.useCallback(()=>{gp(()=>{const O=a.current;O&&(O.scrollTop=O.scrollHeight),c.current=!0,d.current=!1})},[]),N=b.useCallback(()=>{p.current=!0},[]),C=b.useRef(!1),S=b.useRef(!1),_=b.useCallback(()=>{const O=a.current;if(!O)return;const L=O.scrollTop>10,z=O.scrollHeight-O.scrollTop-O.clientHeight>10;L!==C.current&&(C.current=L,g(L)),z!==S.current&&(S.current=z,v(z))},[]),P=b.useCallback(()=>{const O=a.current;O&&(c.current=O.scrollHeight-O.scrollTop-O.clientHeight<150,_())},[_]),A=b.useCallback(O=>{f.current=O},[]),E=b.useRef(o);b.useEffect(()=>{if(o===E.current)return;E.current=o;const O=p.current;p.current=!1;const L=()=>{const F=a.current;F&&(O?(F.scrollTop=0,c.current=!1):(F.scrollTop=F.scrollHeight,c.current=!0),d.current=!1)};gp(L);const z=setTimeout(()=>{L(),y(o)},150);return()=>clearTimeout(z)},[o]);const T=t.length;b.useEffect(()=>{T>0&&(d.current=!0,j())},[T,j]),b.useEffect(()=>{const O=(n==null?void 0:n.sessionId)??null,L=m.current,z=new Set(u.map(B=>B.id));if(!L||L.sessionId!==O){m.current={sessionId:O,ids:z};return}const F=u.filter(B=>!L.ids.has(B.id));if(m.current={sessionId:O,ids:z},F.length===0||T===0)return;let H=0;for(const B of F){const W=t[H];(W===B.content||(W==null?void 0:W.trim())===""&&B.content.length>0)&&H++}H>0&&s(H)},[n==null?void 0:n.sessionId,u,t,T,s]);const M=(n==null?void 0:n.turns.length)??0;b.useEffect(()=>{if(M===0)return;const O=M-f.current;O>0&&(T>0&&s(Math.min(O,T)),(d.current||c.current)&&(j(),d.current=!1)),f.current=M},[M,T,s,j]);const I=n==null?void 0:n.turns.at(-1),R=(I==null?void 0:I.toolCalls.length)??0,$=(I==null?void 0:I.assistantText.length)??0;b.useEffect(()=>{if(!(!n||!e)){if(c.current){const O=a.current;O&&(O.scrollTop=O.scrollHeight)}requestAnimationFrame(_)}},[M,R,$,i,e,_]);const D=w===o;return b.useMemo(()=>({chatScrollRef:a,scrollEndRef:l,canScrollUp:h,canScrollDown:x,initialScrollDone:D,handleScroll:P,scrollToBottomInstant:k,requestScrollToTop:N,resetTurnCount:A}),[h,x,D,P,k,N,A])}async function Q0(n,e,t,s){const o=await ye(`/api/sessions/${encodeURIComponent(n)}/${encodeURIComponent(e)}?tail=30`);if(!o.ok)throw new Error(`Failed to load ${s} (${o.status})`);const i=await o.json(),a=new Set(i.headerLines),l=i.tailLines.filter(f=>!a.has(f)),c=[...i.headerLines,...l].join(`
|
|
131
|
+
`);return{parsed:await t(c),source:{dirName:n,fileName:e,rawText:c,agentKind:St(n),watchOffset:i.totalSize},byteOffset:i.byteOffset,hasMore:i.hasMore}}async function Ds(n,e,t,s){const o=pn.get(n,e);if(o)return{parsed:o.parsed,source:o.source};const i=fn(),a=ms(),{parsed:l,source:c,byteOffset:d,hasMore:f}=await Q0(n,e,t,s);if(fn()!==i||ms()!==a)return{parsed:l,source:c};const u=pn.get(n,e);return u?{parsed:u.parsed,source:u.source}:(pn.set(n,e,l,c.rawText,d,f,c.agentKind,c.watchOffset),{parsed:l,source:c})}async function Z0(n,e,t,s){pn.evict(n,e);const o=fn(),i=ms(),{parsed:a,source:l,byteOffset:c,hasMore:d}=await Q0(n,e,t,s);return fn()===o&&ms()===i&&pn.set(n,e,a,l.rawText,c,d,l.agentKind,l.watchOffset),{parsed:a,source:l}}function UA({dispatch:n,isMobile:e,mobileTab:t="sessions",teamContext:s,scrollToBottomInstant:o,resetTurnCount:i,workerParse:a,onBeforeSwitch:l}){const[c,d]=b.useState(null),f=b.useCallback((v,w)=>{d(null),b.startTransition(()=>{n({type:"LOAD_SESSION",session:v,source:w,isMobile:e})}),i(v.turns.length),zP(v.sessionId,v.turns.length),o()},[n,e,i,o]),u=b.useCallback(async(v,w)=>{l==null||l(),d(null);try{const{parsed:y,source:j}=await Ds(v,w,a,"session");f(y,j)}catch(y){d(y instanceof Error?y.message:"Failed to load session")}},[f,a,l]),m=b.useCallback(async v=>{if(s){l==null||l(),d(null),n({type:"SET_LOADING_MEMBER",name:v.name});try{const w=await ye(`/api/team-member-session/${encodeURIComponent(s.teamName)}/${encodeURIComponent(v.name)}`);if(!w.ok)throw new Error(`Failed to find session for ${v.name}`);const{dirName:y,fileName:j}=await w.json(),{parsed:k,source:N}=await Ds(y,j,a,`session for ${v.name}`);b.startTransition(()=>{n({type:"SWITCH_TEAM_MEMBER",session:k,source:N,memberName:v.name})}),i(k.turns.length),o()}catch(w){d(w instanceof Error?w.message:"Failed to switch team member")}finally{n({type:"SET_LOADING_MEMBER",name:null})}}},[n,s,i,o,a,l]),p=b.useCallback(()=>d(null),[]),h=b.useCallback(()=>{b.startTransition(()=>{n({type:"GO_HOME",isMobile:e})})},[n,e]),g=b.useCallback((v,w)=>{n({type:"JUMP_TO_TURN",index:v,toolCallId:w})},[n]),x=b.useCallback(v=>{v!==t&&b.startTransition(()=>{n({type:"SET_MOBILE_TAB",tab:v})})},[n,t]);return{loadError:c,clearLoadError:p,handleLoadSession:f,handleDashboardSelect:u,handleTeamMemberSwitch:m,handleGoHome:h,handleJumpToTurn:g,handleMobileTabChange:x}}const WA=/^\/preview\/([^/]+)\/?$/;function Rd(n){const e=WA.exec(n);if(!e)return null;try{const t=decodeURIComponent(e[1]);return t.length>0?t:null}catch{return null}}function e2(){const n=ht();return n===wt?"":`/d/${n}`}function cc(){const n=e2();return n?`${n}/`:"/"}function t2(n){const e=/^\/d\/[^/]+(\/.*)?$/.exec(n);return e?e[1]||"/":n}function HA(n,e){return fy(n,e)}function KA(n){const e=e2();if(n.sessionSource){const{dirName:t,fileName:s}=n.sessionSource,o=uy(t,s);return`${e}/${encodeURIComponent(t)}/${encodeURIComponent(o)}`}return n.pendingDirName?`${e}/${encodeURIComponent(n.pendingDirName)}`:n.dashboardProject?`${e}/${encodeURIComponent(n.dashboardProject)}`:cc()}function xp(n){const e=t2(n),t=Rd(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 qA({state:n,dispatch:e,isMobile:t,resetTurnCount:s,scrollToBottomInstant:o,workerParse:i}){const[a,l]=b.useState(null),c=b.useRef(0),d=b.useRef(window.location.pathname),f=b.useRef(!1),u=b.useCallback(async m=>{c.current++;try{if(m.type==="preview"&&m.sessionId){l(null);try{const p=await ye(`/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 Ds(h.dirName,h.fileName,i,"session preview");e({type:"LOAD_SESSION",session:g.parsed,source:g.source,isMobile:t}),s(g.parsed.turns.length),o()}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=HA(m.dirName,m.sessionId);let h;try{h=await Ds(m.dirName,p,i,"session")}catch{e({type:"GO_HOME",isMobile:t});const g=cc();window.history.replaceState(null,"",g),d.current=g,No(ht(),g);return}e({type:"LOAD_SESSION",session:h.parsed,source:h.source,isMobile:t}),s(h.parsed.turns.length),o()}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=cc();window.history.replaceState(null,"",p),d.current=p,No(ht(),p)}}finally{c.current--}},[e,t,s,o,i]);return b.useEffect(()=>{if(f.current)return;f.current=!0,No(ht(),window.location.pathname);const m=xp(window.location.pathname);(m.type!=="home"||m.normalizeHome)&&u(m)},[u]),b.useEffect(()=>{if(c.current>0||Rd(t2(window.location.pathname)))return;const m=KA(n);m!==d.current&&(window.history.pushState(null,"",m),d.current=m,No(ht(),m))},[n.sessionSource,n.pendingDirName,n.mainView,n.dashboardProject]),b.useEffect(()=>{const m=()=>{const p=xp(window.location.pathname);d.current=window.location.pathname,No(ht(),window.location.pathname),u(p)};return window.addEventListener("popstate",m),()=>window.removeEventListener("popstate",m)},[u]),{previewLoadError:a}}const VA=400;function bp(){return Array.from(document.querySelectorAll("[data-live-session]"))}function GA(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 vp(n){n.focus({preventScroll:!0});const e=GA(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 YA(n){const e=U.c(20),{isMobile:t,searchInputRef:s,chatInputRef:o,dispatch:i,onToggleSidebar:a,onToggleRightSidebar:l,onToggleMissionControl:c,onOpenCommandPalette:d,onOpenProjectSwitcher:f,onOpenThemeSelector:u,onOpenTerminal:m,onToggleIntegratedTerminal:p,onTogglePreview:h,onToggleProjectFiles:g,onHistoryBack:x,onHistoryForward:v,onNavigateToSession:w,onCommitNavigation:y}=n;let j,k;e[0]!==o||e[1]!==i||e[2]!==t||e[3]!==y||e[4]!==x||e[5]!==v||e[6]!==w||e[7]!==d||e[8]!==f||e[9]!==m||e[10]!==u||e[11]!==p||e[12]!==c||e[13]!==h||e[14]!==g||e[15]!==l||e[16]!==a||e[17]!==s?(j=()=>{if(t)return;let N=!1,C=!1,S=null;const _=function(T){var $,D;const M=Km("missionControl");if(M){if(T.key===M){T.repeat||(N=!0,C=T.shiftKey||T.altKey||(M==="Meta"?T.ctrlKey:T.metaKey));return}N&&(C=!0),S=null}if(yt("commandPalette",T)){T.preventDefault(),d==null||d();return}if(yt("integratedTerminal",T)){if(!ut("terminal"))return;T.preventDefault(),p();return}if(yt("preview",T)){T.preventDefault(),h();return}if(yt("projectFiles",T)){if(!ut("hostFiles"))return;T.preventDefault(),g();return}if(yt("expandAll",T)){T.preventDefault(),i({type:"SET_EXPAND_ALL",value:!0});return}if(yt("expandToolPayloads",T)){T.preventDefault(),i({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0});return}if(yt("toggleSidebar",T)){T.preventDefault(),a();return}if(yt("toggleStats",T)){T.preventDefault(),l();return}if(yt("missionControl",T)){T.preventDefault(),c();return}if(yt("newSession",T)&&(T.preventDefault(),f()),yt("themeSelector",T)&&(T.preventDefault(),u()),yt("systemTerminal",T)){if(!ut("terminal"))return;T.preventDefault(),m()}if(T.key==="Escape"&&(i({type:"SET_SEARCH_QUERY",value:""}),($=s.current)==null||$.blur()),(T.metaKey||T.ctrlKey)&&T.shiftKey&&T.code.startsWith("Digit")){const O=parseInt(T.code.charAt(5),10);if(O>=1&&O<=9){T.preventDefault();const z=bp()[O-1];z&&(vp(z),z.click())}}const I=yt("recentSessionForward",T);if(I||yt("recentSessionBack",T)){T.preventDefault();const O=I?v():x();O&&w(O.dirName,O.fileName)}yt("focusComposer",T)&&!t0(document.activeElement)&&(T.preventDefault(),(D=o.current)==null||D.focus());const R=yt("nextLiveSession",T);if(R||yt("prevLiveSession",T)){T.preventDefault();const O=bp();if(O.length===0)return;const L=O.findIndex(XA);let z;L===-1?z=R?0:O.length-1:z=Math.max(0,Math.min(O.length-1,L+(R?1:-1))),vp(O[z])}},P=function(T){const M=Km("missionControl");if(M&&T.key===M&&N){const I=!C;if(N=!1,C=!1,I){const R=Date.now();S!==null&&R-S<=VA?(S=null,T.preventDefault(),c()):S=R}else S=null}T.key==="Control"&&(y==null||y())},A=function(){N=!1,C=!1,S=null};return window.addEventListener("keydown",_),window.addEventListener("keyup",P),window.addEventListener("blur",A),()=>{window.removeEventListener("keydown",_),window.removeEventListener("keyup",P),window.removeEventListener("blur",A)}},k=[t,s,o,i,a,l,c,d,f,u,m,p,h,g,x,v,w,y],e[0]=o,e[1]=i,e[2]=t,e[3]=y,e[4]=x,e[5]=v,e[6]=w,e[7]=d,e[8]=f,e[9]=m,e[10]=u,e[11]=p,e[12]=c,e[13]=h,e[14]=g,e[15]=l,e[16]=a,e[17]=s,e[18]=j,e[19]=k):(j=e[18],k=e[19]),b.useEffect(j,k)}function XA(n){return n===document.activeElement}const yp="cogpit-theme",aI=[{id:"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",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",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)"]}];function JA(n){switch(n){case"dark":return"dark";case"oled":return"dark theme-oled";case"light":return""}}function n2(){const[n,e]=b.useState(()=>{try{const l=localStorage.getItem(yp);if(l==="dark"||l==="oled"||l==="light")return l}catch{}return"dark"}),[t,s]=b.useState(null),o=b.useCallback(l=>{localStorage.setItem(yp,l),e(l),s(null)},[]),i=t??n,a=JA(i);return b.useEffect(()=>{const l=document.documentElement.classList;l.remove("dark","theme-oled"),i==="dark"?l.add("dark"):i==="oled"&&l.add("dark","theme-oled")},[i]),{theme:n,activeTheme:i,themeClasses:a,setTheme:o,setPreview:s}}const QA="cogpit-session-history",dc=50;function s2(){return Lt(QA)}function ZA(){try{const n=localStorage.getItem(s2());if(!n)return[];const e=JSON.parse(n);if(Array.isArray(e))return e.slice(0,dc)}catch{}return[]}function wp(n){try{localStorage.setItem(s2(),JSON.stringify(n))}catch{}}function eR(){const n=U.c(6);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=ZA(),n[0]=e):e=n[0];const t=b.useRef(e),s=b.useRef(0),o=b.useRef(!1);let i;n[1]===Symbol.for("react.memo_cache_sentinel")?(i=(h,g)=>{if(o.current){o.current=!1;return}const x=`${h}/${g}`;t.current=t.current.filter(v=>`${v.dirName}/${v.fileName}`!==x),t.current.unshift({dirName:h,fileName:g}),t.current.length>dc&&(t.current.length=dc),s.current=0,wp(t.current)},n[1]=i):i=n[1];const a=i;let l;n[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{if(t.current.length<=1)return null;const h=(s.current+1)%t.current.length;return s.current=h,o.current=!0,t.current[h]},n[2]=l):l=n[2];const c=l;let d;n[3]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{if(t.current.length<=1)return null;const h=(s.current-1+t.current.length)%t.current.length;return s.current=h,o.current=!0,t.current[h]},n[3]=d):d=n[3];const f=d;let u;n[4]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{if(s.current===0){o.current=!1;return}const h=t.current[s.current];h&&(t.current.splice(s.current,1),t.current.unshift(h),wp(t.current)),s.current=0,o.current=!1},n[4]=u):u=n[4];const m=u;let p;return n[5]===Symbol.for("react.memo_cache_sentinel")?(p={push:a,goBack:c,goForward:f,commitNavigation:m},n[5]=p):p=n[5],p}function o2(){return Lt(DA)}function jp(){try{const n=localStorage.getItem(o2());if(n){const e=JSON.parse(n);return{mode:e.mode||Oi.mode,allowedTools:Array.isArray(e.allowedTools)?e.allowedTools:[],disallowedTools:Array.isArray(e.disallowedTools)?e.disallowedTools:[]}}}catch{}return Oi}function tR(n){localStorage.setItem(o2(),JSON.stringify(n))}function nR(){const n=U.c(21),[e,t]=b.useState(jp),[s,o]=b.useState(jp),i=b.useRef(!0);let a,l;n[0]!==e?(a=()=>{if(i.current){i.current=!1;return}tR(e)},l=[e],n[0]=e,n[1]=a,n[2]=l):(a=n[1],l=n[2]),b.useEffect(a,l);let c;n[3]!==s.allowedTools||n[4]!==s.disallowedTools||n[5]!==s.mode||n[6]!==e.allowedTools||n[7]!==e.disallowedTools||n[8]!==e.mode?(c=e.mode!==s.mode||JSON.stringify(e.allowedTools)!==JSON.stringify(s.allowedTools)||JSON.stringify(e.disallowedTools)!==JSON.stringify(s.disallowedTools),n[3]=s.allowedTools,n[4]=s.disallowedTools,n[5]=s.mode,n[6]=e.allowedTools,n[7]=e.disallowedTools,n[8]=e.mode,n[9]=c):c=n[9];const d=c;let f;n[10]===Symbol.for("react.memo_cache_sentinel")?(f=k=>{t(N=>({...N,mode:k}))},n[10]=f):f=n[10];const u=f;let m;n[11]===Symbol.for("react.memo_cache_sentinel")?(m=k=>{t(N=>{const C=N.allowedTools.includes(k);return{...N,allowedTools:C?N.allowedTools.filter(S=>S!==k):[...N.allowedTools,k]}})},n[11]=m):m=n[11];const p=m;let h;n[12]===Symbol.for("react.memo_cache_sentinel")?(h=k=>{t(N=>{const C=N.disallowedTools.includes(k);return{...N,disallowedTools:C?N.disallowedTools.filter(S=>S!==k):[...N.disallowedTools,k]}})},n[12]=h):h=n[12];const g=h;let x;n[13]!==e?(x=()=>{o(e)},n[13]=e,n[14]=x):x=n[14];const v=x;let w;n[15]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{t(Oi)},n[15]=w):w=n[15];const y=w;let j;return n[16]!==s||n[17]!==e||n[18]!==d||n[19]!==v?(j={config:e,appliedConfig:s,hasPendingChanges:d,setMode:u,toggleAllowedTool:p,toggleDisallowedTool:g,markApplied:v,resetToDefault:y},n[16]=s,n[17]=e,n[18]=d,n[19]=v,n[20]=j):j=n[20],j}const sR=2e3;function oR(n,e){return n.length!==e.length?!1:JSON.stringify(n)===JSON.stringify(e)}function rR(n){const[e,t]=b.useState([]),[s,o]=b.useState(null),[i,a]=b.useState(new Set);b.useEffect(()=>{if(!n){t([]),o(null);return}let d=!1;const f=async()=>{if(!d)try{const h=await ye(`/api/permissions/${encodeURIComponent(n)}`);if(d)return;if(h.ok){const g=await h.json();if(d)return;t(v=>oR(v,g.permissions)?v:g.permissions);const x=g.plan?{type:"plan",provider:"copilot",...g.plan}:null;o(v=>JSON.stringify(v)===JSON.stringify(x)?v:x)}}catch{}},u=()=>{(typeof document>"u"||document.visibilityState==="visible")&&f()},m=()=>{document.visibilityState==="visible"&&f()};u();const p=setInterval(u,sR);return document.addEventListener("visibilitychange",m),()=>{d=!0,clearInterval(p),document.removeEventListener("visibilitychange",m)}},[n]);const l=b.useCallback(async(d,f)=>{if(n){a(u=>new Set(u).add(d));try{await D0(n,d,f)&&t(u=>u.filter(m=>m.requestId!==d))}finally{a(u=>{const m=new Set(u);return m.delete(d),m})}}},[n]),c=b.useCallback(async d=>{if(n)try{await _P(n,d)&&t([])}catch{}},[n]);return{requests:e,plan:s,responding:i,respond:l,respondAll:c}}function iR(n){return n.file_path??n.path??""}function r2(n){const e=[];for(const t of n.toolCalls){if(t.isError||a6(t))continue;const s=iR(t.input);if(s){if(t.name==="Edit"){const o=t.input.old_string,i=t.input.new_string;o!==void 0&&i!==void 0&&e.push({type:"Edit",filePath:s,oldString:o,newString:i,replaceAll:t.input.replace_all??!1})}else if(t.name==="Write"){const o=t.input.content;o!==void 0&&e.push({type:"Write",filePath:s,content:o})}}}return e}function aR(n,e){return{index:e,userMessage:pa(n.userMessage),toolCalls:r2(n),thinkingBlocks:n.thinking.map(t=>t.thinking),assistantText:[...n.assistantText],timestamp:n.timestamp,model:n.model}}function Di(n,e,t){const s=[];for(let o=e;o>t;o--){const i=n[o];if(!i)continue;const a=r2(i);for(let l=a.length-1;l>=0;l--){const c=a[l];c&&(c.type==="Edit"?s.push({type:"reverse-edit",filePath:c.filePath,oldString:c.newString,newString:c.oldString,replaceAll:c.replaceAll,turnIndex:o}):c.type==="Write"&&s.push({type:"delete-write",filePath:c.filePath,content:c.content,turnIndex:o}))}}return s}function lR(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 Go(n,e){const t=[],s=e!==void 0?e+1:n.length;for(let o=0;o<s;o++){const i=n[o];i&&t.push(...lR(i.toolCalls,i.index))}return t}function i2(n,e,t,s){var l;const o=[];for(let c=e+1;c<n.length;c++){const d=n[c];d&&o.push(aR(d,c))}const i=((l=o[0])==null?void 0:l.userMessage)||"Untitled branch",a=i.length>60?i.slice(0,57)+"...":i;return{id:crypto.randomUUID(),createdAt:new Date().toISOString(),branchPointTurnIndex:e,label:a,turns:o,jsonlLines:t,...s&&s.length>0?{childBranches:s}:{}}}function a2(n,e){const t=[],s=[];for(const o of n)o.branchPointTurnIndex>e?s.push(o):t.push(o);return{retained:t,scooped:s}}function l2(n,e,t){const s=e+t,o=[],i=[];for(const a of n)a.branchPointTurnIndex<=s?o.push(a):i.push(a);return{restored:o,remaining:i}}function cR(n){const e=new Set,t=new Set;for(const s of n)e.add(s.filePath),t.add(s.turnIndex);return{turnCount:t.size,fileCount:e.size,filePaths:[...e],operationCount:n.length}}function dR(n,e){return{sessionId:n,currentTurnIndex:e-1,totalTurns:e,branches:[],activeBranchId:null}}function li(n,e){return n.length>0?cR(n):{turnCount:e,fileCount:0,filePaths:[],operationCount:0}}function c2(n,e,t){return A1(_1(St(t)),n,e)}function d2(n,e,t,s){const o=_1(St(s)),i=e==null?void 0:e.id;if(i){const a=oN(o,n,i);if(a==="keep-all")return n.length;if(a!==null)return a}return A1(o,n,t)}class Bo extends Error{constructor(){super("abort")}}async function uR(n,e,t,s,o,i,a){var w;const l=n.targetTurnIndex,c=Di(e.turns,e.turns.length-1,l),d=l+1,f=o.split(`
|
|
132
|
+
`).filter(Boolean),u=d2(f,e.turns[l],d,t.dirName),m=f.slice(u);if(m.length===0)throw a("Unable to locate the selected turn in the current session file"),new Bo;const{retained:p,scooped:h}=a2(s.branches,l),g=i2(e.turns,l,m,h),x={...s,currentTurnIndex:l,totalTurns:d,branches:[...p,g],activeBranchId:null},v=uo(t.dirName).fileCheckpoints?(w=e.turns[l+1])==null?void 0:w.id:void 0;await i({operations:c,sessionSource:t,sessionMutation:{type:"truncate",keepLines:u,expectedLineCount:f.length},state:x,...v?{checkpoint:{sessionId:e.sessionId,userMessageId:v,cwd:e.cwd}}:{}})}async function fR(n,e,t,s,o,i){var v;const a=n.redoUpToArchiveIndex!==void 0&&n.redoUpToArchiveIndex<s.turns.length-1,l=n.redoUpToArchiveIndex??s.turns.length-1,c=l+1,d=Go(s.turns,l),f=a?c2(s.jsonlLines,c,e.dirName):s.jsonlLines.length,u=s.jsonlLines.slice(0,f),m=s.jsonlLines.slice(f),p=s.childBranches??[];let h;if(a&&m.length>0){const{restored:w,remaining:y}=l2(p,s.branchPointTurnIndex,c),j={...s,branchPointTurnIndex:s.branchPointTurnIndex+c,turns:s.turns.slice(c),jsonlLines:m,label:((v=s.turns[c])==null?void 0:v.userMessage)||s.label,childBranches:y.length>0?y:void 0};h=[...t.branches.map(k=>k.id===s.id?j:k),...w]}else h=[...t.branches.filter(w=>w.id!==s.id),...p];const g={...t,currentTurnIndex:t.currentTurnIndex+c,totalTurns:t.totalTurns+c,branches:h,activeBranchId:null},x=o.split(`
|
|
133
|
+
`).filter(Boolean);await i({operations:d,sessionSource:e,sessionMutation:{type:"append",lines:u,expectedLineCount:x.length},state:g})}async function mR(n,e,t,s,o,i,a){var j;let l=[...t.branches],c=o.split(`
|
|
134
|
+
`).filter(Boolean);const d=[];if(n.turns.length>s.branchPointTurnIndex+1){const k=Di(n.turns,n.turns.length-1,s.branchPointTurnIndex);d.push(...k);const{retained:N,scooped:C}=a2(l,s.branchPointTurnIndex);l=N;const S=s.branchPointTurnIndex+1,_=d2(c,n.turns[s.branchPointTurnIndex],S,e.dirName),P=c.slice(_);if(P.length>0){const A=i2(n.turns,s.branchPointTurnIndex,P,C);l=[...l,A],c=c.slice(0,_)}}const f=i.branchTurnIndex??s.turns.length-1,u=f+1,m=f<s.turns.length-1,p=Go(s.turns,f);d.push(...p);const h=m?c2(s.jsonlLines,u,e.dirName):s.jsonlLines.length,g=s.jsonlLines.slice(0,h),x=s.jsonlLines.slice(h),v=s.childBranches??[];let w;if(m&&x.length>0){const{restored:k,remaining:N}=l2(v,s.branchPointTurnIndex,u);w=[{...s,branchPointTurnIndex:s.branchPointTurnIndex+u,turns:s.turns.slice(u),jsonlLines:x,label:((j=s.turns[u])==null?void 0:j.userMessage)||s.label,childBranches:N.length>0?N:void 0},...k]}else w=v;const y={...t,currentTurnIndex:s.branchPointTurnIndex+u,totalTurns:s.branchPointTurnIndex+1+u,branches:[...l.filter(k=>k.id!==s.id),...w],activeBranchId:null};await a({operations:d,sessionSource:e,sessionMutation:{type:"splice",keepLines:c.length,lines:g,expectedLineCount:o.split(`
|
|
135
|
+
`).filter(Boolean).length},state:y})}const pR=[];function u2(n,e,t,s=!0){const[o,i]=b.useState(null),[a,l]=b.useState(null),[c,d]=b.useState(!1),[f,u]=b.useState(null),m=b.useRef(null),p=b.useRef(0);b.useEffect(()=>{if(p.current+=1,!s||!n){i(null),l(null),u(null),m.current=null;return}if(n.sessionId===m.current)return;if(m.current=n.sessionId,!uo(e==null?void 0:e.dirName).redo){i(null);return}const A=n.sessionId,E=new AbortController;return ye(`/api/undo-state/${encodeURIComponent(A)}`,{signal:E.signal}).then(T=>T.ok?T.json():null).then(T=>{m.current===A&&i(T??null)}).catch(T=>{T instanceof Error&&T.name==="AbortError"||m.current===A&&i(null)}),()=>E.abort()},[s,n==null?void 0:n.sessionId]);const h=b.useCallback(async A=>{try{const E=await ye("/api/undo/transaction",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({operations:A.operations,session:{dirName:A.sessionSource.dirName,fileName:A.sessionSource.fileName,mutation:A.sessionMutation},state:A.state,checkpoint:A.checkpoint})}),T=await E.json().catch(()=>null);if(!E.ok)throw u((T==null?void 0:T.error)||"Undo transaction failed"),new Bo;i(A.state)}catch(E){throw E instanceof Bo?E:(u(String(E)),new Bo)}},[]),g=(o==null?void 0:o.branches)??pR,{canRedo:x,redoTurnCount:v,redoBranch:w}=b.useMemo(()=>{if(!n||g.length===0)return{canRedo:!1,redoTurnCount:0,redoBranch:null};for(let A=g.length-1;A>=0;A--){const E=g[A];if(E.branchPointTurnIndex+1===n.turns.length)return{canRedo:!0,redoTurnCount:E.turns.length,redoBranch:E}}return{canRedo:!1,redoTurnCount:0,redoBranch:null}},[n,g]),y=b.useMemo(()=>{if(!w||w.jsonlLines.length===0)return[];try{return ma(w.jsonlLines.join(`
|
|
136
|
+
`)).turns}catch{return[]}},[w]),j=b.useCallback(A=>g.filter(E=>E.branchPointTurnIndex===A),[g]),k=b.useCallback(A=>{if(!s||!n)return;const E=A-1;if(E>=n.turns.length-1||E<-1)return;if(uo(e==null?void 0:e.dirName).nativeRewind){const M=n.turns[A];if(!M)return;const I=n.sessionId,R=++p.current,$=()=>p.current===R&&m.current===I,D=M.id.includes("@")?M.id.slice(M.id.lastIndexOf("@")+1):M.id,O=n.turns.length-A;ye(`/api/copilot-history/${encodeURIComponent(n.sessionId)}/preview`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({eventId:D})}).then(async L=>{var B;if(!$())return;const z=L.ok?await L.json():null;if(!$())return;const F=((B=z==null?void 0:z.files)==null?void 0:B.map(({path:W})=>W).filter(W=>typeof W=="string"))??[],H=z!=null&&z.available?z.fileCount??F.length:0;l({type:"undo",summary:{turnCount:O,fileCount:H,filePaths:F,operationCount:H},targetTurnIndex:E,copilot:{eventId:D,mode:"conversation",filesAvailable:!!(z!=null&&z.available&&H>0)}})}).catch(()=>{$()&&l({type:"undo",summary:{turnCount:O,fileCount:0,filePaths:[],operationCount:0},targetTurnIndex:E,copilot:{eventId:D,mode:"conversation"}})});return}const T=Di(n.turns,n.turns.length-1,E);l({type:"undo",summary:li(T,n.turns.length-1-E),targetTurnIndex:E})},[s,n,e==null?void 0:e.dirName]),N=b.useCallback(()=>{if(!s||!x||!w||!n)return;const A=Go(w.turns);l({type:"redo",summary:li(A,w.turns.length),targetTurnIndex:w.branchPointTurnIndex+w.turns.length,branchId:w.id})},[s,x,w,n]),C=b.useCallback(A=>{if(!s||!x||!w||!n)return;const E=A+1,T=Go(w.turns,A);l({type:"redo",summary:li(T,E),targetTurnIndex:w.branchPointTurnIndex+E,branchId:w.id,redoUpToArchiveIndex:A})},[s,x,w,n]),S=b.useCallback((A,E)=>{if(!s||!n)return;const T=g.find($=>$.id===A);if(!T)return;const M=E??T.turns.length-1,I=n.turns.length>T.branchPointTurnIndex+1?Di(n.turns,n.turns.length-1,T.branchPointTurnIndex):[],R=Go(T.turns,M);l({type:"branch-switch",summary:li([...I,...R],M+1),targetTurnIndex:T.branchPointTurnIndex,branchId:A,branchTurnIndex:M})},[s,n,g]),_=b.useCallback(async(A=!1)=>{if(!s||!a||!n||!e){l(null);return}d(!0),u(null);try{if(a.copilot){const I=A&&a.copilot.filesAvailable?"conversation-and-files":"conversation",R=await ye(`/api/copilot-history/${encodeURIComponent(n.sessionId)}/rewind`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({eventId:a.copilot.eventId,mode:I})}),$=await R.json().catch(()=>null);if(!R.ok||($==null?void 0:$.outcome)!=="success"){u(($==null?void 0:$.error)||`Copilot rewind failed${$!=null&&$.outcome?`: ${$.outcome}`:""}`);return}await t(),l(null);return}const E=o??dR(n.sessionId,n.turns.length),T=await ye(`/api/sessions/${encodeURIComponent(e.dirName)}/${encodeURIComponent(e.fileName)}`);if(!T.ok){u("Failed to read session file");return}const M=await T.text();if(a.type==="undo")await uR(a,n,e,E,M,h,u);else if(a.type==="redo"){const I=g.find(R=>R.id===a.branchId);if(!I){l(null);return}await fR(a,e,E,I,M,h)}else if(a.type==="branch-switch"){const I=g.find(R=>R.id===a.branchId);if(!I){l(null);return}await mR(n,e,E,I,M,a,h)}try{await ye("/api/stop-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:n.sessionId})})}catch{}await t(),l(null)}catch(E){if(!(E instanceof Bo))throw E}finally{d(!1)}},[s,a,n,e,o,g,h,t]),P=b.useCallback(()=>{p.current+=1,l(null),u(null)},[]);return{enabled:s,undoState:o,canRedo:x,redoTurnCount:v,redoGhostTurns:y,branches:g,branchesAtTurn:j,requestUndo:k,requestRedoAll:N,requestRedoUpTo:C,requestBranchSwitch:S,confirmState:a,confirmApply:_,confirmCancel:P,isApplying:c,applyError:f}}async function hR(n){try{const t=await(await rs("/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 Sp(n){const e=await ye("/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:dy(t==null?void 0:t.mode,Fs),useBuiltInEditor:(t==null?void 0:t.useBuiltInEditor)===!0}}function gR(){const n=U.c(26),[e,t]=b.useState(!0),[s,o]=b.useState(null),[i,a]=b.useState(null),[l,c]=b.useState(Fs),[d,f]=b.useState(!1),[u,m]=b.useState(null),[p,h]=b.useState(!1),[g,x]=b.useState(0),v=b.useRef(null),w=b.useRef(null);let y;n[0]===Symbol.for("react.memo_cache_sentinel")?(y=B=>{a(B.claudeDir),c(B.defaultAgentKind),WS(B.useBuiltInEditor)},n[0]=y):y=n[0];const j=y;let k;n[1]===Symbol.for("react.memo_cache_sentinel")?(k=async()=>{var K;(K=v.current)==null||K.abort();const B=new AbortController;v.current=B;const W=await hR(B.signal);B.signal.aborted||v.current!==B||(m(W.url),h(W.disabled))},n[1]=k):k=n[1];const N=k;let C,S;n[2]===Symbol.for("react.memo_cache_sentinel")?(C=()=>()=>{var B,W;(B=v.current)==null||B.abort(),(W=w.current)==null||W.abort()},S=[],n[2]=C,n[3]=S):(C=n[2],S=n[3]),b.useEffect(C,S);let _;n[4]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{const B=new AbortController;return t(!0),o(null),Sp(B.signal).then(j).catch(W=>{W instanceof Error&&W.name==="AbortError"||(a(null),o(W instanceof Error?W.message:"Failed to load configuration"))}).finally(()=>{B.signal.aborted||t(!1)}),()=>B.abort()},n[4]=_):_=n[4];let P;n[5]!==g?(P=[j,g],n[5]=g,n[6]=P):P=n[6],b.useEffect(_,P);let A,E;n[7]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{const B=()=>x(bR);return window.addEventListener("cogpit-auth-changed",B),()=>window.removeEventListener("cogpit-auth-changed",B)},E=[],n[7]=A,n[8]=E):(A=n[7],E=n[8]),b.useEffect(A,E);let T;n[9]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{N()},n[9]=T):T=n[9];let M;n[10]!==i?(M=[i,N],n[10]=i,n[11]=M):M=n[11],b.useEffect(T,M);let I;n[12]===Symbol.for("react.memo_cache_sentinel")?(I=()=>f(!1),n[12]=I):I=n[12];const R=I;let $;n[13]!==i?($=B=>{if(f(!1),B!==i){a(B),window.location.reload();return}x(xR),N()},n[13]=i,n[14]=$):$=n[14];const D=$;let O;n[15]===Symbol.for("react.memo_cache_sentinel")?(O=()=>f(!0),n[15]=O):O=n[15];const L=O;let z;n[16]===Symbol.for("react.memo_cache_sentinel")?(z=()=>{var W;(W=w.current)==null||W.abort();const B=new AbortController;w.current=B,t(!0),o(null),Sp(B.signal).then(K=>{B.signal.aborted||w.current!==B||j(K)}).catch(K=>{B.signal.aborted||w.current!==B||(a(null),o(K instanceof Error?K.message:"Failed to load configuration"))}).finally(()=>{B.signal.aborted||w.current!==B||t(!1)})},n[16]=z):z=n[16];const F=z;let H;return n[17]!==i||n[18]!==s||n[19]!==e||n[20]!==l||n[21]!==D||n[22]!==p||n[23]!==u||n[24]!==d?(H={configLoading:e,configError:s,claudeDir:i,defaultAgentKind:l,setClaudeDir:a,showConfigDialog:d,openConfigDialog:L,handleCloseConfigDialog:R,handleConfigSaved:D,retryConfig:F,networkUrl:u,networkAccessDisabled:p},n[17]=i,n[18]=s,n[19]=e,n[20]=l,n[21]=D,n[22]=p,n[23]=u,n[24]=d,n[25]=H):H=n[25],H}function xR(n){return n+1}function bR(n){return n+1}const kp={authenticated:!0,edition:"personal",user:null,capabilities:sa},cn={authenticated:!1,edition:"personal",user:null,capabilities:Sr},f2=Object.keys(sa);function Np(n,e){return n!==null&&n.edition===e&&n.authenticated&&(e==="personal"?n.user===null:n.user!==null)&&f2.every(t=>{var s;return typeof((s=n.capabilities)==null?void 0:s[t])=="boolean"})}function vR(n,e){const t={...Sr};for(const s of f2)t[s]=n[s]&&e[s];return t}async function Cp(n,e){try{const t=await n("/api/me",{signal:e});return t.ok?await t.json():null}catch{return null}}async function yR(n){try{const e=await ye("/api/hello",{signal:n});return e.ok?(await e.json()).edition==="team"?"team":"personal":null}catch{return null}}function Ro(n){var e;return so(n),Sh(((e=n.user)==null?void 0:e.id)??null),n}function wR(n){const e=U.c(8);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={...cn,checked:!1},e[0]=t):t=e[0];const[s,o]=b.useState(t),[i,a]=b.useState(0),l=b.useRef(null),c=b.useRef(!1);let d;e[1]!==n?(d=()=>{var y;if((y=l.current)==null||y.abort(),n===null){c.current=!1,so(cn),o({...cn,checked:!1});return}const p=c.current;c.current=!1,so(cn),o(j=>p?{...j,capabilities:Sr,checked:!1}:{...cn,checked:!1});const h=new AbortController;l.current=h;const g=$s(),x=Cp(rs,h.signal),v=g?yR(h.signal):Promise.resolve(n),w=g?Cp(ye,h.signal):Promise.resolve(null);return Promise.all([x,v,w]).then(j=>{const[k,N,C]=j;if(h.signal.aborted)return;const S=Np(k,n)?k:n==="personal"?kp:null;if(!S||N===null){o({...Ro(cn),checked:!1});return}if(!g){o({...Ro(S),checked:!0});return}const _=Np(C,N)?C:N==="personal"?kp:null;if(!_){o({...Ro(cn),checked:!1});return}o({...Ro({authenticated:S.authenticated,edition:S.edition,user:S.user,capabilities:vR(S.capabilities,_.capabilities)}),checked:!0})}).catch(()=>{h.signal.aborted||o({...Ro(cn),checked:!1})}),()=>{h.abort(),l.current===h&&(l.current=null)}},e[1]=n,e[2]=d):d=e[2];let f;e[3]!==n||e[4]!==i?(f=[n,i],e[3]=n,e[4]=i,e[5]=f):f=e[5],b.useEffect(d,f);let u,m;return e[6]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{const p=()=>{var g;(g=l.current)==null||g.abort(),c.current=!1,so(cn),Sh(null),o({...cn,checked:!1}),a(kR)},h=g=>{var w,y;const x=ht();if(x===wt)return;const v=(w=g.detail)==null?void 0:w.deviceId;v&&v!==x||((y=l.current)==null||y.abort(),c.current=!0,so(cn),o(SR),a(jR))};return window.addEventListener("cogpit-auth-changed",p),window.addEventListener("cogpit-devices-changed",h),()=>{window.removeEventListener("cogpit-auth-changed",p),window.removeEventListener("cogpit-devices-changed",h)}},m=[],e[6]=u,e[7]=m):(u=e[6],m=e[7]),b.useEffect(u,m),s}function jR(n){return n+1}function SR(n){return{...n,capabilities:Sr,checked:!1}}function kR(n){return n+1}const NR=3e4;function CR(n){const[e,t]=b.useState(()=>({dirName:n,worktrees:[],loading:n!==null,error:null})),s=b.useRef(0),o=b.useCallback(async()=>{if(!n)return;const a=++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 ye(`/api/worktrees/${encodeURIComponent(n)}`);if(a!==s.current)return;if(l.ok){const c=await l.json();if(a!==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(a!==s.current)return;t(c=>c.dirName===n?{...c,loading:!1,error:l instanceof Error?l.message:"Unknown error"}:c)}},[n]);b.useEffect(()=>{if(!n){s.current+=1;return}o();const a=setInterval(()=>void o(),NR);return()=>{clearInterval(a),s.current+=1}},[n,o]);const i=e.dirName===n?e:{worktrees:[],loading:n!==null,error:null};return{worktrees:i.worktrees,loading:i.loading,error:i.error,refetch:o}}function _R(){const n=U.c(3),[e,t]=b.useState(!1);let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=async()=>{t(!0);try{await ye("/api/kill-all",{method:"POST"})}catch{}setTimeout(()=>t(!1),1500)},n[0]=s):s=n[0];const o=s;let i;return n[1]!==e?(i={killing:e,handleKillAll:o},n[1]=e,n[2]=i):i=n[2],i}function TR(n,e){return n?`${n}.jsonl`:e??null}async function m2(n){try{const e=await ye(`/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 ER=300,Cl=new Map;function uc(n,e){const t=Lt(n),s=Cl.get(t),o=s?{...s.patch,...e}:e;s&&clearTimeout(s.timer);const i=setTimeout(()=>{Cl.delete(t),Lt(n)===t&&(async()=>{try{await ye(`/api/session-config/${encodeURIComponent(n)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)})}catch{}})()},ER);Cl.set(t,{patch:o,timer:i})}function fc(n){return new Set(n.filter(e=>e.status==="connected").map(e=>e.name))}async function _p(n){const e=await m2(n);return Array.isArray(e==null?void 0:e.mcpServers)?e.mcpServers:null}function Tp(n,e){uc(n,{mcpServers:e})}async function PR(n){if(!n.ok)return null;const e=await n.json();return{servers:e.servers??[],configs:e.configs??{}}}async function Ep(n,e){try{const t=await ye(n,{signal:e});if(e.aborted)return null;const s=await PR(t);return e.aborted?null:s}catch{return null}}async function Pp(n,e,t){const s=fc(t);if(s.size===0)return[];if(n){const o=await _p(n);if(o)return o.filter(i=>s.has(i))}if(e&&n!==e){const o=await _p(e);if(o)return o.filter(i=>s.has(i))}return[...s]}function AR(n,e,t,s=!0){const[o,i]=b.useState([]),[a,l]=b.useState({}),[c,d]=b.useState([]),[f,u]=b.useState(!1),[m,p]=b.useState(!1),h=b.useRef(null),g=b.useRef(e);g.current=e;const x=t??e??null,v=b.useRef(x);v.current=x;const w=b.useRef(void 0);b.useEffect(()=>{var C,S;if(!s||!n){(C=h.current)==null||C.abort(),w.current=void 0,i([]),l({}),d([]),u(!1),p(!1);return}const N=new AbortController;return(S=h.current)==null||S.abort(),i([]),l({}),d([]),u(!0),p(!1),w.current=n,Ep(`/api/mcp-servers?cwd=${encodeURIComponent(n)}`,N.signal).then(async _=>{if(N.signal.aborted||w.current!==n||!_)return;i(_.servers),l(_.configs);const P=await Pp(v.current,g.current,_.servers);N.signal.aborted||w.current!==n||d(P)}).finally(()=>{N.signal.aborted||w.current!==n||(u(!1),p(!0))}),()=>N.abort()},[n,s]),b.useEffect(()=>()=>{var N;return(N=h.current)==null?void 0:N.abort()},[]),b.useEffect(()=>{if(o.length===0||!x)return;let N=!1;return Pp(x,e,o).then(C=>{N||v.current!==x||d(C)}),()=>{N=!0}},[x]);const y=b.useCallback(N=>{d(C=>{const S=C.includes(N)?C.filter(_=>_!==N):[...C,N];return v.current&&Tp(v.current,S),S})},[]),j=b.useCallback(()=>{var C;if(!s||!n)return;(C=h.current)==null||C.abort();const N=new AbortController;h.current=N,u(!0),Ep(`/api/mcp-servers?cwd=${encodeURIComponent(n)}&refresh=1`,N.signal).then(S=>{if(N.signal.aborted||w.current!==n||!S)return;i(S.servers),l(S.configs);const _=fc(S.servers);d(P=>{const A=P.filter(E=>_.has(E));return v.current&&Tp(v.current,A),A})}).finally(()=>{N.signal.aborted||h.current!==N||u(!1)})},[n,s]),k=b.useMemo(()=>{if(o.length===0)return null;const N=fc(o);if(c.length===N.size&&N.size>0&&c.every(_=>N.has(_))||!c.every(_=>a[_]))return null;const S=Object.fromEntries(c.map(_=>[_,a[_]]));return JSON.stringify({mcpServers:S})},[c,a,o]);return{servers:o,selectedServers:c,mcpConfigJson:k,loading:f,loaded:m,toggleServer:y,refresh:j}}function RR(n){var s,o;const e=U.c(12);let t;e:{if(!n){t=null;break e}let i=null,a;if(e[0]!==i||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 v=x.input;Array.isArray(v.todos)&&(i=v.todos);continue}if(x.name==="TaskCreate"){const v=x.input;h=h+1;const y=((o=(s=x.result)==null?void 0:s.match(/(?:Task\s*#?|task[_ ]?id["': ]+)(\d+)/i))==null?void 0:o[1])??String(h);p.set(y,{id:y,content:v.subject||v.description||`Task ${y}`,activeForm:v.activeForm||v.subject||`Working on task ${y}`,status:"pending",owner:v.owner});continue}if(x.name==="TaskUpdate"){const v=x.input,w=String(v.taskId??"");if(!w)continue;if(v.status==="deleted"){p.delete(w);continue}const y=p.get(w)??{id:w,content:v.subject||v.description||`Task ${w}`,activeForm:v.activeForm||v.subject||`Working on task ${w}`,status:"pending"};p.set(w,{...y,content:v.subject||v.description||y.content,activeForm:v.activeForm||y.activeForm,status:v.status||y.status,owner:v.owner??y.owner,blockedBy:v.addBlockedBy?[...new Set([...y.blockedBy??[],...v.addBlockedBy])]:y.blockedBy})}}a=p.size>0?[...p.values()]:i,e[0]=i,e[1]=n.turns,e[2]=a,e[3]=i}else a=e[2],i=e[3];const l=a;if(!l||l.length===0){t=null;break e}let c;e[4]!==l?(c=l.filter(IR),e[4]=l,e[5]=c):c=e[5];const d=c.length;let f;e[6]!==l?(f=l.find(MR)??null,e[6]=l,e[7]=f):f=e[7];const u=f;let m;e[8]!==d||e[9]!==u||e[10]!==l?(m={todos:l,completed:d,total:l.length,inProgress:u},e[8]=d,e[9]=u,e[10]=l,e[11]=m):m=e[11],t=m}return t}function MR(n){return n.status==="in_progress"}function IR(n){return n.status==="completed"}function $R(n){const e=U.c(4);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];const[s,o]=b.useState(t);let i,a;return e[1]!==n?(i=()=>{if(!n){o([]);return}let l=!1;const c=async function(){try{const u=await ye(`/api/background-agents?cwd=${encodeURIComponent(n)}`);if(l)return;if(u.ok){const m=await u.json();o(m)}}catch{}};c();const d=setInterval(c,5e3);return()=>{l=!0,clearInterval(d)}},a=[n],e[1]=n,e[2]=i,e[3]=a):(i=e[2],a=e[3]),b.useEffect(i,a),s}function OR(n,e){const t=U.c(8),s=e===void 0?!0:e;let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],t[0]=o):o=t[0];const[i,a]=b.useState(o),[l,c]=b.useState(!1),d=b.useRef(void 0);let f,u;t[1]!==n||t[2]!==s?(f=()=>{if(!s){d.current=void 0,a([]),c(!1);return}if(d.current===n)return;d.current=n,c(!0);const p=n?`?cwd=${encodeURIComponent(n)}`:"";ye(`/api/slash-suggestions${p}`).then(DR).then(h=>a(h.suggestions||[])).catch(()=>a([])).finally(()=>c(!1))},u=[n,s],t[1]=n,t[2]=s,t[3]=f,t[4]=u):(f=t[3],u=t[4]),b.useEffect(f,u);let m;return t[5]!==l||t[6]!==i?(m={suggestions:i,loading:l},t[5]=l,t[6]=i,t[7]=m):m=t[7],m}function DR(n){return n.json()}function Mo(n,e){const t=U.c(6),[s,o]=ha(n,e),i=typeof s=="boolean"?s:e;let a;t[0]!==e||t[1]!==o?(a=d=>{o(f=>typeof d=="function"?d(typeof f=="boolean"?f:e):d)},t[0]=e,t[1]=o,t[2]=a):a=t[2];const l=a;let c;return t[3]!==l||t[4]!==i?(c=[i,l],t[3]=l,t[4]=i,t[5]=c):c=t[5],c}function LR(n,e){const t=U.c(45),[s,o]=Mo("panel-sidebar-visible",!0),[i,a]=Mo("panel-stats-visible",!1),[l,c]=Mo("panel-worktrees-visible",!1),[d,f]=Mo("panel-workflows-visible",!1),[u,m]=Mo("panel-file-changes-visible",!0),[p,h]=b.useState(!1),[g,x]=b.useState(!1);let v;t[0]!==o||t[1]!==s?(v=()=>{b.startTransition(()=>o(!s))},t[0]=o,t[1]=s,t[2]=v):v=t[2];const w=v;let y;t[3]!==a||t[4]!==i?(y=()=>{b.startTransition(()=>a(!i))},t[3]=a,t[4]=i,t[5]=y):y=t[5];const j=y;let k;t[6]!==c?(k=()=>c(BR),t[6]=c,t[7]=k):k=t[7];const N=k;let C;t[8]!==f?(C=()=>f(FR),t[8]=f,t[9]=C):C=t[9];const S=C;let _;t[10]!==m||t[11]!==u?(_=()=>{b.startTransition(()=>m(!u))},t[10]=m,t[11]=u,t[12]=_):_=t[12];const P=_;let A;t[13]!==e||t[14]!==n.mainView?(A=()=>{const K=n.mainView==="config";b.startTransition(()=>{e({type:K?"CLOSE_CONFIG":"OPEN_CONFIG"})})},t[13]=e,t[14]=n.mainView,t[15]=A):A=t[15];const E=A;let T;t[16]!==e||t[17]!==n.mainView?(T=()=>{const K=n.mainView==="mission";b.startTransition(()=>{e({type:K?"CLOSE_MISSION":"OPEN_MISSION"})})},t[16]=e,t[17]=n.mainView,t[18]=T):T=t[18];const M=T;let I;t[19]!==e?(I=K=>{b.startTransition(()=>{e({type:"OPEN_CONFIG",filePath:K})})},t[19]=e,t[20]=I):I=t[20];const R=I;let $;t[21]===Symbol.for("react.memo_cache_sentinel")?($=()=>h(!0),t[21]=$):$=t[21];const D=$;let O;t[22]===Symbol.for("react.memo_cache_sentinel")?(O=()=>h(!1),t[22]=O):O=t[22];const L=O;let z;t[23]===Symbol.for("react.memo_cache_sentinel")?(z=()=>x(zR),t[23]=z):z=t[23];const F=z;let H;t[24]===Symbol.for("react.memo_cache_sentinel")?(H=()=>x(!1),t[24]=H):H=t[24];const B=H;let W;return t[25]!==R||t[26]!==E||t[27]!==P||t[28]!==M||t[29]!==w||t[30]!==j||t[31]!==S||t[32]!==N||t[33]!==m||t[34]!==o||t[35]!==f||t[36]!==c||t[37]!==u||t[38]!==p||t[39]!==s||t[40]!==i||t[41]!==g||t[42]!==d||t[43]!==l?(W={showSidebar:s,showStats:i,showWorktrees:l,showWorkflows:d,showFileChanges:u,showProjectSwitcher:p,showThemeSelector:g,handleToggleSidebar:w,handleToggleStats:j,handleToggleWorktrees:N,handleToggleWorkflows:S,handleToggleFileChanges:P,handleToggleConfig:E,handleToggleMission:M,handleEditConfig:R,handleOpenProjectSwitcher:D,handleCloseProjectSwitcher:L,handleToggleThemeSelector:F,handleCloseThemeSelector:B,setShowSidebar:o,setShowWorktrees:c,setShowWorkflows:f,setShowFileChanges:m},t[25]=R,t[26]=E,t[27]=P,t[28]=M,t[29]=w,t[30]=j,t[31]=S,t[32]=N,t[33]=m,t[34]=o,t[35]=f,t[36]=c,t[37]=u,t[38]=p,t[39]=s,t[40]=i,t[41]=g,t[42]=d,t[43]=l,t[44]=W):W=t[44],W}function zR(n){return!n}function FR(n){return!n}function BR(n){return!n}function UR(n){var K;const{state:e,dispatch:t,isMobile:s,handleJumpToTurn:o,markPermissionsApplied:i,hasPermsPendingChanges:a,permissionsConfig:l,selectedModel:c,selectedEffort:d,fastMode:f,ultracode:u,mcpConfig:m,scrollRequestScrollToTop:p,handleDashboardSelect:h,workerParse:g}=n,x=b.useCallback(async()=>{if(!e.sessionSource)return;const{dirName:V,fileName:Y}=e.sessionSource;try{const{parsed:q,source:J}=await Z0(V,Y,g,"session");t({type:"RELOAD_SESSION_CONTENT",session:q,source:J})}catch{}},[e.sessionSource,t,g]),[v,w]=b.useState(null),y=b.useCallback(V=>w(V),[]),j=b.useCallback(()=>w(null),[]),k=b.useCallback(async(V,Y)=>{try{const q=await ye("/api/branch-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dirName:V,fileName:Y})});if(!q.ok)return;const J=await q.json(),{parsed:Z,source:Q}=await Ds(J.dirName,J.fileName,g,"session");t({type:"LOAD_SESSION",session:Z,source:Q,isMobile:s})}catch{}},[t,s,g]),N=b.useCallback(()=>{e.sessionSource&&k(e.sessionSource.dirName,e.sessionSource.fileName)},[e.sessionSource,k]),C=b.useCallback(async(V,Y)=>{try{await ye("/api/delete-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dirName:V,fileName:Y})})}catch{}},[]),S=b.useCallback(async V=>{var Z,Q;if(!e.sessionSource)return;const{dirName:Y,fileName:q}=e.sessionSource,J=(Q=(Z=e.session)==null?void 0:Z.turns[V])==null?void 0:Q.id;try{const ee=await ye("/api/branch-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dirName:Y,fileName:q,turnIndex:V,turnUuid:J})});if(!ee.ok)return;const oe=await ee.json(),{parsed:se,source:re}=await Ds(oe.dirName,oe.fileName,g,"session");t({type:"LOAD_SESSION",session:se,source:re,isMobile:s})}catch{}},[e.sessionSource,e.session,t,s,g]),_=b.useCallback((V,Y)=>{o(V,Y),t({type:"SET_MOBILE_TAB",tab:"chat"})},[o,t]),[P,A]=b.useState({}),E=b.useRef(c);E.current=c;const T=b.useRef(d);T.current=d;const M=b.useRef(m);M.current=m;const I=b.useRef(f);I.current=f;const R=b.useRef(u);R.current=u;const $=b.useRef(l);$.current=l;const D=((K=e.session)==null?void 0:K.sessionId)??null,O=b.useRef(null);b.useEffect(()=>{D!==O.current&&(O.current=D,D&&A(V=>D in V?V:{...V,[D]:{model:E.current,effort:T.current,fastMode:I.current,ultracode:R.current,mcpConfig:M.current}}))},[D]);const L=D?P[D]:void 0,z=m!==((L==null?void 0:L.mcpConfig)??null),F=L!=null&&(c!==L.model||d!==L.effort||f!==L.fastMode||u!==L.ultracode||a||z),H=b.useCallback(async()=>{var oe,se;if(!D)return;const V=E.current,Y=T.current,q=I.current,J=R.current,Z=M.current,Q=$.current,ee=((oe=e.sessionSource)==null?void 0:oe.agentKind)??St(((se=e.sessionSource)==null?void 0:se.dirName)??null);zt(ee).settingsApply==="live"&&await ye(`/api/claude/settings/${encodeURIComponent(D)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:V,effort:Y,fastMode:q,ultracode:J,mcpConfig:Z,permissionMode:Q.mode,allowedTools:Q.allowedTools,disallowedTools:Q.disallowedTools})}),A(re=>({...re,[D]:{model:V,effort:Y,fastMode:q,ultracode:J,mcpConfig:Z}})),i()},[D,e.sessionSource,i]),B=b.useCallback(async()=>{if(D)try{await ye("/api/stop-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:D})})}catch{}},[D]),W=b.useCallback((V,Y)=>{bs(Y)&&p(),h(V,Y)},[p,h]);return{reloadSession:x,branchModalTurn:v,setBranchModalTurn:w,handleOpenBranches:y,handleCloseBranchModal:j,handleDuplicateSessionByPath:k,handleDuplicateSession:N,handleDeleteSession:C,handleBranchFromHere:S,handleMobileJumpToTurn:_,hasSettingsChanges:F,handleApplySettings:H,handleStopSession:B,handleLoadSessionScrollAware:W}}function p2(){const n=U.c(6),e=b.useRef(null);let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t=new Map,n[0]=t):t=n[0];const s=b.useRef(t),o=b.useRef(0);let i,a;n[1]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{const m=s.current,p=new Worker(new URL("/assets/session-parser.worker-DTq2tkdd.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()}},a=[],n[1]=i,n[2]=a):(i=n[1],a=n[2]),b.useEffect(i,a);let l;n[3]===Symbol.for("react.memo_cache_sentinel")?(l=m=>{const p=e.current;return p?new Promise((h,g)=>{o.current=o.current+1;const x=o.current;s.current.set(x,{resolve:h,reject:g}),p.postMessage({type:"parse",id:x,text:m})}):Promise.resolve().then(()=>ma(m))},n[3]=l):l=n[3];const c=l;let d;n[4]===Symbol.for("react.memo_cache_sentinel")?(d=(m,p)=>{const h=e.current;return h?new Promise((g,x)=>{o.current=o.current+1;const v=o.current;s.current.set(v,{resolve:g,reject:x}),h.postMessage({type:"append",id:v,existing:m,newText:p})}):Promise.resolve().then(()=>lN(m,p))},n[4]=d):d=n[4];const f=d;let u;return n[5]===Symbol.for("react.memo_cache_sentinel")?(u={parse:c,append:f},n[5]=u):u=n[5],u}const WR=30;function h2({dirName:n,fileName:e,sessionChangeKey:t,workerParse:s,onOlderTurns:o}){const[i,a]=b.useState(!1),[l,c]=b.useState(!1),d=b.useRef(""),f=b.useRef(null),u=`${n??""}::${e??""}::${t}`;return b.useEffect(()=>{d.current=u,f.current=null,c(!1);const p=n&&e?pn.get(n,e):void 0;a((p==null?void 0:p.hasMore)??!1),p&&p.olderTurns.length>0&&o(p.olderTurns)},[u,n,e,t,o]),{loadMore:b.useCallback(async()=>{if(!n||!e||f.current)return 0;const p=`${n}::${e}::${t}`,h=pn.get(n,e);if(!(h!=null&&h.hasMore))return d.current===p&&a(!1),0;const g=Symbol("paging-flight");f.current=g,c(!0);try{const x=await ye(`/api/sessions/${encodeURIComponent(n)}/${encodeURIComponent(e)}?before=${h.nextByteOffset}&count=${WR}`);if(!x.ok)return 0;const v=await x.json(),w=v.lines.length>0&&v.hasMore;if(d.current===p&&a(w),v.lines.length===0)return pn.update(n,e,{hasMore:w,nextByteOffset:v.byteOffset}),0;const y=new Set(v.headerLines),j=v.lines.filter(C=>!y.has(C)),k=await s([...v.headerLines,...j].join(`
|
|
137
|
+
`)),N=Jx(h.olderTurns,k.turns,h.source.agentKind);return pn.update(n,e,{hasMore:w,nextByteOffset:v.byteOffset,olderTurns:N}),d.current!==p?0:(o(N),k.turns.length)}finally{f.current===g&&(f.current=null,d.current===p&&c(!1))}},[n,e,t,s,o]),hasMore:i,isLoadingOlder:l}}function HR(n){const e=U.c(48),{agentKind:t,session:s,sessionSource:o,pendingDirName:i,isLive:a}=n,l=t??Fs,c=Th(l),[d,f]=b.useState(""),[u,m]=b.useState(""),[p,h]=b.useState(!1),[g,x]=b.useState(!1),v=d||(s==null?void 0:s.model);let w;e[0]!==l||e[1]!==v?(w=ky(l,v),e[0]=l,e[1]=v,e[2]=w):w=e[2];const y=w,j=g&&y;let k;e[3]!==l||e[4]!==u||e[5]!==d||e[6]!==j?(k=j?"xhigh":Yi(l,u,d),e[3]=l,e[4]=u,e[5]=d,e[6]=j,e[7]=k):k=e[7];const N=k;let C;e[8]!==l||e[9]!==d?(C=bh(l,d),e[8]=l,e[9]=d,e[10]=C):C=e[10];const S=!!C,_=S&&p;let P;e[11]!==l||e[12]!==d?(P=jy(l,d),e[11]=l,e[12]=d,e[13]=P):P=e[13];const A=P,[E,T]=b.useState(null),M=b.useRef(null),I=(o==null?void 0:o.fileName)??null,R=b.useRef(I);let $,D;e[14]!==I?($=()=>{const ee=R.current;R.current=I,!(ee===null||ee===I)&&x(!1)},D=[I],e[14]=I,e[15]=$,e[16]=D):($=e[15],D=e[16]),b.useEffect($,D);let O,L;e[17]!==i?(O=()=>{i&&x(!1)},L=[i],e[17]=i,e[18]=O,e[19]=L):(O=e[18],L=e[19]),b.useEffect(O,L);let z;e[20]===Symbol.for("react.memo_cache_sentinel")?(z=ee=>{f(oe=>oe===ee?"":oe),T(`${ee} is unavailable for this account. Cogpit retried the turn with Codex's default model.`)},e[20]=z):z=e[20];const F=z;let H;e[21]===Symbol.for("react.memo_cache_sentinel")?(H=()=>{T(null)},e[21]=H):H=e[21];const B=H;let W,K;e[22]!==c||e[23]!==i||e[24]!==d||e[25]!==o?(W=()=>{d&&(!o&&!i||c.some(ee=>ee.value===d)||f(""))},K=[c,d,o,i],e[22]=c,e[23]=i,e[24]=d,e[25]=o,e[26]=W,e[27]=K):(W=e[26],K=e[27]),b.useEffect(W,K);let V,Y;e[28]!==E?(V=()=>{if(!E)return;const ee=setTimeout(()=>T(null),12e3);return()=>clearTimeout(ee)},Y=[E],e[28]=E,e[29]=V,e[30]=Y):(V=e[29],Y=e[30]),b.useEffect(V,Y);const q=s==null?void 0:s.rawMessages;let J,Z;e[31]!==l||e[32]!==a||e[33]!==q?(J=()=>{if(!a||!q||!zt(l).modelFallbackNotices)return;let ee;for(let ae=q.length-1;ae>=0;ae=ae-1,ae){const te=q[ae];if(te.type==="system"&&te.subtype==="model_refusal_fallback"){ee=te;break}}if(!ee)return;const oe=typeof ee.uuid=="string"?ee.uuid:`${String(ee.original_model)}:${String(ee.fallback_model)}:${String(ee.request_id)}`;if(M.current===oe)return;M.current=oe;const se=typeof ee.original_model=="string"?ee.original_model:"Fable",re=typeof ee.fallback_model=="string"?ee.fallback_model:"Opus",ie=typeof ee.api_refusal_explanation=="string"?` ${ee.api_refusal_explanation}`:"";T(`${se} could not handle this request, so Claude continued with ${re}.${ie}`)},Z=[a,q,l],e[31]=l,e[32]=a,e[33]=q,e[34]=J,e[35]=Z):(J=e[34],Z=e[35]),b.useEffect(J,Z);let Q;return e[36]!==N||e[37]!==_||e[38]!==S||e[39]!==p||e[40]!==A||e[41]!==E||e[42]!==u||e[43]!==d||e[44]!==j||e[45]!==y||e[46]!==g?(Q={selectedModel:d,setSelectedModel:f,selectedEffort:u,setSelectedEffort:m,fastModeEnabled:p,ultracodeEnabled:g,effectiveEffort:N,fastModeAvailable:S,fastModeActive:_,setFastModeEnabled:h,ultracodeAvailable:y,ultracodeActive:j,setUltracodeEnabled:x,imageInputAvailable:A,modelFallbackNotice:E,dismissModelFallbackNotice:B,handleCodexModelRejected:F},e[36]=N,e[37]=_,e[38]=S,e[39]=p,e[40]=A,e[41]=E,e[42]=u,e[43]=d,e[44]=j,e[45]=y,e[46]=g,e[47]=Q):Q=e[47],Q}const KR=["model","effort","fastMode","ultracode","permissionMode"];function qR({sessionKey:n,values:e,onHydrate:t}){const s=b.useRef(null),o=b.useRef(null),i=b.useRef(t);i.current=t;const a=b.useRef(e);a.current=e,b.useEffect(()=>{if(s.current=null,o.current=null,!n)return;let c=!1;return m2(n).then(d=>{if(c||d===null)return;if(KR.some(u=>d[u]!==void 0)){i.current(d);const u=a.current,m={model:d.model??u.model,effort:d.effort??u.effort,fastMode:d.fastMode??u.fastMode,ultracode:d.ultracode??u.ultracode,permissionMode:d.permissionMode??u.permissionMode};o.current=JSON.stringify(m)}else uc(n,a.current),o.current=JSON.stringify(a.current);s.current=n}),()=>{c=!0}},[n]);const l=JSON.stringify(e);b.useEffect(()=>{!n||s.current!==n||l!==o.current&&(o.current=l,uc(n,a.current))},[l,n])}function VR(n){const[e,t]=b.useState(new Map),[s,o]=b.useState(null),[i,a]=b.useState(!0),l=b.useRef(new Map),c=b.useRef(null);b.useEffect(()=>{const x=n??null,v=c.current;if(v&&v!==x&&l.current.set(v,{activeId:s,collapsed:i}),x!==v){const w=x?l.current.get(x):null;w?(o(w.activeId),a(w.collapsed)):(o(null),a(!0))}c.current=x},[n]);const d=b.useCallback(()=>a(x=>!x),[]),f=b.useCallback(x=>{t(v=>{const w=new Map(v);return w.set(x.id,x),w}),o(x.id),a(!1)},[]),u=b.useCallback(x=>{t(v=>{const w=new Map(v);return w.delete(x),o(y=>{if(y!==x)return y;const j=[...w.keys()];return j.length>0?j[j.length-1]:null}),w})},[]),m=b.useCallback(x=>{o(x),a(!1)},[]),p=b.useCallback((x,v)=>{t(w=>{const y=w.get(x);if(!y||y.status===v)return w;const j=new Map(w);return j.set(x,{...y,status:v}),j})},[]),h=b.useCallback(x=>{t(v=>{let w=!1;const y=new Map(v),j=new Set(x.map(k=>k.id));for(const[k,N]of y)N.type==="task"&&!j.has(k)&&(y.delete(k),w=!0);for(const k of x){const N=y.get(k.id);N?(N.name!==k.title||N.outputPath!==k.outputPath)&&(y.set(k.id,{...N,name:k.title,outputPath:k.outputPath}),w=!0):(y.set(k.id,{id:k.id,name:k.title,type:"task",status:"running",outputPath:k.outputPath}),w=!0)}return w?y:v})},[]),g=b.useCallback((x,v,w)=>{v&&w&&t(y=>{if(y.has(x))return y;const j=new Map(y);return j.set(x,{id:x,name:w,type:"task",status:"running",outputPath:v}),j}),o(y=>y===x?(a(!0),y):(a(!1),x))},[]);return{processes:e,activeProcessId:s,collapsed:i,toggleCollapse:d,addProcess:f,removeProcess:u,setActive:m,updateProcessStatus:p,handleServersChanged:h,handleToggleServer:g}}function GR(n){const e=U.c(50),{sessionId:t,sessionCwd:s,pendingPath:o,sessionDirName:i,pendingDirName:a,dashboardProject:l,supportsFileWorkspace:c}=n,d=VR(t),[f,u]=b.useState(null),[m,p]=b.useState(0),h=b.useRef(0),g=s??o??void 0,x=!!(g&&(f==null?void 0:f.kind)==="preview"&&f.cwd===g),v=(f==null?void 0:f.kind)==="project-files"&&f.anchorCwd===(g??null)?f:null;let w;e[0]!==a||e[1]!==o?(w={path:o,dirName:a},e[0]=a,e[1]=o,e[2]=w):w=e[2];const y=w;let j;e[3]!==l||e[4]!==a||e[5]!==o||e[6]!==s||e[7]!==i?(j=()=>{if($s()){console.warn("[open-terminal] unavailable for remote devices");return}const K=s??o??void 0,V=i??a??l??void 0;if(!K&&!V){console.warn("[open-terminal] no project path available");return}ye("/api/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:K,dirName:V})}).then(eM).catch(ZR)},e[3]=l,e[4]=a,e[5]=o,e[6]=s,e[7]=i,e[8]=j):j=e[8];const k=j;let N;e[9]!==l||e[10]!==a||e[11]!==o||e[12]!==s||e[13]!==i?(N=K=>{if($s()){console.warn("[mcp-auth] unavailable for remote devices");return}const V=s??o??void 0,Y=i??a??l??void 0;!V&&!Y||ye("/api/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:V,dirName:Y,command:"claude /mcp"})}).catch(QR)},e[9]=l,e[10]=a,e[11]=o,e[12]=s,e[13]=i,e[14]=N):N=e[14];const C=N;let S;e[15]!==o||e[16]!==d||e[17]!==s?(S=()=>{const V=[...d.processes.values()].filter(JR).at(-1);if(!V){(s??o)&&p(XR);return}d.activeProcessId===V.id&&!d.collapsed?d.toggleCollapse():d.setActive(V.id)},e[15]=o,e[16]=d,e[17]=s,e[18]=S):S=e[18];const _=S;let P;e[19]!==o||e[20]!==s?(P=()=>{(s??o)&&p(YR)},e[19]=o,e[20]=s,e[21]=P):P=e[21];const A=P;let E;e[22]!==g||e[23]!==x?(E=()=>{g&&b.startTransition(()=>{u(x?null:{kind:"preview",cwd:g})})},e[22]=g,e[23]=x,e[24]=E):E=e[24];const T=E;let M;e[25]!==g||e[26]!==v?(M=()=>{g&&b.startTransition(()=>{u(v?null:{kind:"project-files",root:g,anchorCwd:g,request:null})})},e[25]=g,e[26]=v,e[27]=M):M=e[27];const I=M;let R;e[28]!==g||e[29]!==c?(R=K=>{if(!c)return!1;const V=KS(K,g);if(!V)return!1;h.current=h.current+1;const Y=h.current;return b.startTransition(()=>u({kind:"project-files",root:V.root,anchorCwd:g??null,request:V.file?{file:V.file,mode:V.mode,line:V.line,token:Y}:null})),!0},e[28]=g,e[29]=c,e[30]=R):R=e[30];const $=R;let D,O;e[31]!==$?(O=()=>HS($),D=[$],e[31]=$,e[32]=D,e[33]=O):(D=e[32],O=e[33]),b.useEffect(O,D);let L;e[34]===Symbol.for("react.memo_cache_sentinel")?(L=()=>{b.startTransition(()=>u(null))},e[34]=L):L=e[34];const z=L,F=v!==null,H=v==null?void 0:v.root,B=(v==null?void 0:v.request)??null;let W;return e[35]!==g||e[36]!==C||e[37]!==A||e[38]!==k||e[39]!==_||e[40]!==T||e[41]!==I||e[42]!==m||e[43]!==y||e[44]!==d||e[45]!==x||e[46]!==F||e[47]!==H||e[48]!==B?(W={processPanel:d,currentCwd:g,showPreview:x,showProjectFiles:F,projectFilesRoot:H,projectFilesRequest:B,launchTerminalRequest:m,pendingProject:y,handleOpenTerminal:k,handleMcpAuth:C,handleToggleIntegratedTerminal:_,handleNewIntegratedTerminal:A,handleTogglePreview:T,handleToggleProjectFiles:I,closeRightWorkspace:z},e[35]=g,e[36]=C,e[37]=A,e[38]=k,e[39]=_,e[40]=T,e[41]=I,e[42]=m,e[43]=y,e[44]=d,e[45]=x,e[46]=F,e[47]=H,e[48]=B,e[49]=W):W=e[49],W}function YR(n){return n+1}function XR(n){return n+1}function JR(n){return n.type==="terminal"}function QR(n){return console.error("[mcp-auth] open-terminal failed:",n)}function ZR(n){return console.error("[open-terminal] fetch failed:",n)}function eM(n){n.ok||n.json().then(nM).catch(tM)}function tM(){}function nM(n){return console.error("[open-terminal]",n.error)}function sM(n){const e=n.replace(/<[^>]+>[\s\S]*?<\/[^>]+>/g,"").trim();if(!e)return"";const t=e.split(`
|
|
138
|
+
`)[0].trim();return t.length<=60?t:t.slice(0,57)+"..."}const oM={totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:0};function g2(n,e){return{dirName:n.dirName,fileName:n.fileName,rawText:e,agentKind:St(n.dirName)}}function rM(n){return{sessionId:n.sessionId,version:"",gitBranch:"",cwd:"",slug:"",name:"",model:"",turns:[],stats:{...oM},rawMessages:[],agentKind:St(n.dirName)}}function x2(n){if(!(n!=null&&n.trim()))return null;try{return{rawText:n,parsed:ma(n)}}catch{return null}}async function iM(n,e,t=3,s=100,o=!0){if(o){const i=x2(n.initialContent);if(i)return i}for(let i=0;i<t;i++){if(e.signal.aborted)throw new DOMException("Aborted","AbortError");const a=await ye(`/api/sessions/${encodeURIComponent(n.dirName)}/${encodeURIComponent(n.fileName)}`,{signal:e.signal});if(a.ok){const l=await a.text();if(l.trim())try{return{rawText:l,parsed:ma(l)}}catch{}}i<t-1&&await new Promise(l=>setTimeout(l,s))}return null}async function aM(n,e,t,s){let o=s;for(let i=0;i<30;i++){if(e.signal.aborted)return;const a=await iM(n,e,1,0,!1);if(a&&a.rawText!==o){t({type:"RELOAD_SESSION_CONTENT",session:a.parsed,source:g2(n,a.rawText)});return}o=(a==null?void 0:a.rawText)??o,await new Promise(l=>setTimeout(l,200))}}async function Ap(n,e,t,s,o){const i=x2(n.initialContent),a=(i==null?void 0:i.rawText)??"",l=(i==null?void 0:i.parsed)??rM(n),c=g2(n,a);return t({type:"FINALIZE_SESSION",session:l,source:c,isMobile:s}),o(l,c),aM(n,e,t,a),n.sessionId}async function lM(n,e,t,s){const o=await ye(`/api/sessions/${encodeURIComponent(n)}?page=1&limit=10`,{signal:s.signal});if(!o.ok)return null;const i=await o.json(),a=t-3e4,l=e.trim(),c=(i.sessions??[]).filter(f=>{const u=f.lastModified?new Date(f.lastModified).getTime():0;return Number.isFinite(u)&&u>=a}),d=c.find(f=>{var u,m;return((u=f.firstUserMessage)==null?void 0:u.trim())===l||((m=f.lastUserMessage)==null?void 0:m.trim())===l})??c[0];return d?{dirName:n,fileName:d.fileName,sessionId:d.sessionId}:null}function cM({permissionsConfig:n,dispatch:e,isMobile:t,onSessionFinalized:s,onCreateStarted:o,onCodexModelRejected:i,model:a,effort:l,fastMode:c,ultracode:d,mcpConfig:f}){const[u,m]=b.useState(!1),[p,h]=b.useState(null),[g,x]=b.useState(!1),[v,w]=b.useState(""),y=b.useRef(null),j=b.useRef(null),k=b.useRef(null),N=b.useCallback((P,A)=>{j.current=P,k.current=A??null,h(null),m(!1),e({type:"INIT_PENDING_SESSION",dirName:P,cwd:A,isMobile:t})},[e,t]),C=b.useCallback(async(P,A)=>{var $;const E=j.current;if(!E)return null;const T=St(E),M=k.current;($=y.current)==null||$.abort();const I=new AbortController;y.current=I,m(!0),h(null),o==null||o(P);const R=Date.now();try{const D=sM(P),O=zt(T),L={dirName:E,cwd:T==="claude"?M??void 0:void 0,message:P,images:A,permissions:n,effort:l||void 0,fastMode:c?!0:void 0,ultracode:O.ultracode&&d?!0:void 0,name:(T==="claude"||T==="copilot")&&D||void 0,worktreeName:O.worktrees&&g?v||Ny(P):void 0,mcpConfig:O.mcp&&f||void 0},{res:z,errorMessage:F}=await Y0(W=>ye("/api/create-and-send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...L,model:W}),signal:I.signal}),{model:a,agentKind:T,errorFallback:"Unknown error",onModelRejected:i});if(!z.ok){if(T==="codex"){const W=await lM(E,P,R,I);if(W){j.current=null,k.current=null;const K=await Ap(W,I,e,t,s);return D&&K&&ac(K,D),K}}return h(F||`Failed to create session (${z.status})`),null}const H=await z.json();j.current=null,k.current=null;const B=await Ap(H,I,e,t,s);return D&&B&&ac(B,D),B}catch(D){return I.signal.aborted||h(D instanceof Error?D.message:"Failed to create session"),null}finally{I.signal.aborted||m(!1)}},[n,a,l,c,d,f,g,v,e,t,s,o,i]),S=b.useCallback(()=>h(null),[]),_=b.useCallback(()=>{var P;(P=y.current)==null||P.abort(),y.current=null,j.current=null,k.current=null,m(!1),h(null)},[]);return{creatingSession:u,createError:p,clearCreateError:S,handleNewSession:N,createAndSend:C,cancelCreation:_,pendingDirNameRef:j,worktreeEnabled:g,setWorktreeEnabled:x,worktreeName:v,setWorktreeName:w}}function dM(n){const e=U.c(40),{permissionsConfig:t,dispatch:s,isMobile:o,defaultAgentKind:i,pendingDirName:a,pendingCwd:l,model:c,effort:d,fastMode:f,ultracode:u,mcpConfig:m,onCodexModelRejected:p}=n,h=b.useRef(null),g=b.useRef(null),[x,v]=b.useState(null);let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w=B=>{var W;(W=h.current)==null||W.call(h,B),setTimeout(()=>{var K;return(K=g.current)==null?void 0:K.call(g)},300),setTimeout(()=>{var K;return(K=g.current)==null?void 0:K.call(g)},2e3)},e[0]=w):w=e[0];let y;e[1]!==s||e[2]!==d||e[3]!==f||e[4]!==o||e[5]!==m||e[6]!==c||e[7]!==p||e[8]!==t||e[9]!==u?(y={permissionsConfig:t,dispatch:s,isMobile:o,onSessionFinalized:w,onCreateStarted:v,onCodexModelRejected:p,model:c,effort:d,fastMode:f,ultracode:u,mcpConfig:m},e[1]=s,e[2]=d,e[3]=f,e[4]=o,e[5]=m,e[6]=c,e[7]=p,e[8]=t,e[9]=u,e[10]=y):y=e[10];const j=cM(y),k=j.handleNewSession,[N,C]=b.useState(null);let S;e[11]===Symbol.for("react.memo_cache_sentinel")?(S=new Map,e[11]=S):S=e[11];const _=b.useRef(S);let P;e[12]===Symbol.for("react.memo_cache_sentinel")?(P=async B=>{const W=_.current;if(W.has(B))return W.get(B)??null;try{const K=await ye("/api/projects");if(!K.ok)return W.set(B,null),null;const V=await K.json(),Y=py(V,B,"claude");return W.set(B,Y),Y}catch{return W.set(B,null),null}},e[12]=P):P=e[12];const A=P;let E;e[13]!==k?(E=async(B,W)=>{const K=W??null;if(!K){C(null),k(B);return}const V=St(B)!=="claude",Y=V?await A(K):za("claude",K);C(Y?{claudeDirName:Y,cwd:K}:null),k(V||!Y?B:Y,K)},e[13]=k,e[14]=E):E=e[14];const T=E;let M;e[15]!==i||e[16]!==T?(M=B=>{const W=za(i,B);T(W,B)},e[15]=i,e[16]=T,e[17]=M):M=e[17];const I=M;let R;e[18]!==k||e[19]!==N?(R=B=>{if(!N)return;const W=za(B,N.cwd,N.claudeDirName);k(W,N.cwd)},e[18]=k,e[19]=N,e[20]=R):R=e[20];const $=R;let D;e:{if(!j.creatingSession||!a){D=null;break e}const B=x??void 0;let W;e[21]!==l||e[22]!==a||e[23]!==B?(W={dirName:a,cwd:l,firstMessage:B},e[21]=l,e[22]=a,e[23]=B,e[24]=W):W=e[24],D=W}const O=D;let L,z;e[25]!==a?(z=()=>{a||(v(null),C(null))},L=[a],e[25]=a,e[26]=L,e[27]=z):(L=e[26],z=e[27]),b.useEffect(z,L);const F=N?$:void 0;let H;return e[28]!==I||e[29]!==T||e[30]!==j.cancelCreation||e[31]!==j.clearCreateError||e[32]!==j.createAndSend||e[33]!==j.createError||e[34]!==j.creatingSession||e[35]!==j.setWorktreeEnabled||e[36]!==j.worktreeEnabled||e[37]!==O||e[38]!==F?(H={creatingSession:j.creatingSession,createError:j.createError,clearCreateError:j.clearCreateError,createAndSend:j.createAndSend,cancelCreation:j.cancelCreation,worktreeEnabled:j.worktreeEnabled,setWorktreeEnabled:j.setWorktreeEnabled,sessionFinalizedRef:h,liveSessionsRefreshRef:g,pendingSessionInfo:O,pendingAgentKindChange:F,handleStartNewSession:T,handleStartNewFolder:I},e[28]=I,e[29]=T,e[30]=j.cancelCreation,e[31]=j.clearCreateError,e[32]=j.createAndSend,e[33]=j.createError,e[34]=j.creatingSession,e[35]=j.setWorktreeEnabled,e[36]=j.worktreeEnabled,e[37]=O,e[38]=F,e[39]=H):H=e[39],H}const _l=new Set;function uM(n,e){const t=fn(),s=ms();return`${s===null?t:`${t}:${s}`}:${n}/${e}`}async function fM(n,e,t){const s=uM(n,e);if(!_l.has(s)&&!pn.get(n,e)){_l.add(s);try{await Ds(n,e,t,"session prefetch")}catch{}finally{_l.delete(s)}}}function mM({onAuthenticated:n}){const[e,t]=b.useState(null),[s,o]=b.useState(""),[i,a]=b.useState(""),[l,c]=b.useState(!1),[d,f]=b.useState(null),[u,m]=b.useState(!1),p=e==="team";b.useEffect(()=>{let x=!1;return Ch().then(v=>{x||t(v)}),()=>{x=!0}},[]);const h=b.useCallback(async x=>{if(x.preventDefault(),!(!i.trim()||p&&!s.trim())){m(!0),f(null);try{const v=await fetch("/api/auth/verify",p?{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json","X-Cogpit-Client":"1"},body:JSON.stringify({username:s.trim(),password:i})}:{method:"POST",credentials:"same-origin",cache:"no-store",headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json","X-Cogpit-Client":"1"}}),w=await v.json();v.ok&&w.valid?(Ji(),a(""),o(""),n()):f(w.error||(p?"Invalid credentials":"Invalid password"))}catch{f("Failed to connect to server")}finally{m(!1)}}},[p,n,i,s]),g=u||!i.trim()||p&&!s.trim();return r.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-4 py-8",children:r.jsx("form",{onSubmit:h,className:"w-full max-w-sm",children:r.jsxs(Xt,{children:[r.jsxs(tn,{children:[r.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:r.jsx(Xv,{className:"size-4"})}),r.jsx(nn,{children:"Sign in to Cogpit"}),r.jsx(sn,{children:p?"Use your team account to continue.":"Enter the server password to continue."})]}),e===null?r.jsx(Jt,{children:r.jsx("div",{className:"flex min-h-24 items-center justify-center",role:"status","aria-label":"Checking server",children:r.jsx(Ut,{className:"size-5 text-muted-foreground"})})}):r.jsxs(r.Fragment,{children:[r.jsxs(Jt,{className:"flex flex-col gap-4",children:[r.jsxs(wo,{children:[p&&r.jsxs(gt,{children:[r.jsx(xt,{htmlFor:"login-username",children:"Username"}),r.jsx(Ot,{id:"login-username",type:"text",value:s,onChange:x=>o(x.target.value),placeholder:"Username",autoComplete:"username",autoFocus:!0})]}),r.jsxs(gt,{children:[r.jsx(xt,{htmlFor:"login-password",children:"Password"}),r.jsxs(Zn,{children:[r.jsx(es,{id:"login-password",type:l?"text":"password",value:i,onChange:x=>a(x.target.value),placeholder:"Password",autoComplete:"current-password",autoFocus:!p}),r.jsx(yn,{align:"inline-end",children:r.jsx(Cr,{size:"icon-xs",onClick:()=>c(x=>!x),"aria-label":l?"Hide password":"Show password",children:l?r.jsx(Wi,{}):r.jsx(vo,{})})})]})]})]}),d&&r.jsxs(Ct,{variant:"destructive",children:[r.jsx(bn,{"aria-hidden":"true"}),r.jsx(Dt,{children:"Sign in failed"}),r.jsx(_t,{children:d})]})]}),r.jsx(So,{children:r.jsxs(X,{type:"submit",className:"w-full",disabled:g,children:[u&&r.jsx(Ut,{"data-icon":"inline-start"}),"Connect"]})})]})]})})})}const Rp=16,hi="__cogpitBootstrapToken";function pM(){const e=new URLSearchParams(window.location.hash.replace(/^#/,"")).get("bootstrap")||"",t=window.history.state||{},s=e||(typeof t[hi]=="string"?t[hi]:"");return e&&window.history.replaceState({...t,[hi]:e},"",`${window.location.pathname}${window.location.search}`),s}function Mp(){const n={...window.history.state||{}};delete n[hi],window.history.replaceState(n,"",`${window.location.pathname}${window.location.search}`)}function hM({onAuthenticated:n,onBootstrapClosed:e}){const[t]=b.useState(pM),[s,o]=b.useState(""),[i,a]=b.useState(""),[l,c]=b.useState(""),[d,f]=b.useState(""),[u,m]=b.useState(!1),[p,h]=b.useState(null),[g,x]=b.useState(!1),v=d.length>0&&d!==l,w=!t||!s.trim()||l.length<Rp||d!==l,y=b.useCallback(async j=>{if(j.preventDefault(),!w){x(!0),h(null);try{const k=await fetch("/api/team/bootstrap",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json","X-Cogpit-Client":"1","X-Cogpit-Bootstrap-Token":t},body:JSON.stringify({username:s.trim(),password:l,...i.trim()?{displayName:i.trim()}:{}})}),N=await k.json();if(k.ok){Mp(),c(""),f(""),o(""),a(""),await e(),n();return}if(k.status===410){Mp(),await e();return}h(N.error||"Could not create the admin account")}catch{h("Failed to connect to server")}finally{x(!1)}}},[t,i,w,n,e,l,s]);return r.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-4 py-8",children:r.jsx("form",{onSubmit:y,className:"w-full max-w-md",children:r.jsxs(Xt,{children:[r.jsxs(tn,{children:[r.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:r.jsx(Jv,{className:"size-4"})}),r.jsx(nn,{children:"Create the first admin"}),r.jsx(sn,{children:"Set up the account that will manage this Cogpit team server."})]}),r.jsxs(Jt,{className:"flex flex-col gap-4",children:[!t&&r.jsxs(Ct,{children:[r.jsx(wn,{"aria-hidden":"true"}),r.jsx(Dt,{children:"Setup link required"}),r.jsx(_t,{children:"Open the one-time setup URL shown in the Cogpit server log."})]}),r.jsxs(wo,{children:[r.jsxs(gt,{children:[r.jsx(xt,{htmlFor:"bootstrap-username",children:"Username"}),r.jsx(Ot,{id:"bootstrap-username",type:"text",value:s,onChange:j=>o(j.target.value),placeholder:"Username",autoComplete:"username",autoFocus:!0}),r.jsx(fo,{children:"Use 2 to 32 lowercase letters, numbers, dots, underscores, or hyphens."})]}),r.jsxs(gt,{children:[r.jsxs(xt,{htmlFor:"bootstrap-display-name",children:["Display name ",r.jsx("span",{className:"font-normal text-muted-foreground",children:"Optional"})]}),r.jsx(Ot,{id:"bootstrap-display-name",type:"text",value:i,onChange:j=>a(j.target.value),placeholder:"Display name (optional)",autoComplete:"name"})]}),r.jsxs(gt,{children:[r.jsx(xt,{htmlFor:"bootstrap-password",children:"Password"}),r.jsxs(Zn,{children:[r.jsx(es,{id:"bootstrap-password",type:u?"text":"password",value:l,onChange:j=>c(j.target.value),placeholder:"Password",autoComplete:"new-password"}),r.jsx(yn,{align:"inline-end",children:r.jsx(Cr,{size:"icon-xs",onClick:()=>m(j=>!j),"aria-label":u?"Hide password":"Show password",children:u?r.jsx(Wi,{}):r.jsx(vo,{})})})]}),r.jsxs(fo,{children:["Use at least ",Rp," characters."]})]}),r.jsxs(gt,{"data-invalid":v,children:[r.jsx(xt,{htmlFor:"bootstrap-confirm-password",children:"Confirm password"}),r.jsx(Ot,{id:"bootstrap-confirm-password",type:u?"text":"password",value:d,onChange:j=>f(j.target.value),placeholder:"Confirm password",autoComplete:"new-password","aria-invalid":v}),v&&r.jsx(us,{children:"Passwords do not match"})]})]}),p&&r.jsxs(Ct,{variant:"destructive",children:[r.jsx(bn,{"aria-hidden":"true"}),r.jsx(Dt,{children:"Could not create the account"}),r.jsx(_t,{children:p})]})]}),r.jsx(So,{children:r.jsxs(X,{type:"submit",className:"w-full",disabled:g||w,children:[g&&r.jsx(Ut,{"data-icon":"inline-start"}),"Create admin account"]})})]})})})}function gM(){const n=U.c(18);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=Xi(),n[0]=e):e=n[0];const t=e,[s,o]=b.useState(null),[i,a]=b.useState(!1),[l,c]=b.useState(!1),d=b.useRef(0);let f,u;n[1]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{let E=!1;return Nh().then(T=>{E||o(T)}),()=>{E=!0}},u=[],n[1]=f,n[2]=u):(f=n[1],u=n[2]),b.useEffect(f,u);const m=t?!0:s===null?null:s.edition==="team";let p,h;n[3]!==m?(p=()=>{if(m===null)return;if(!m){a(!0),c(!0);return}let E=!1;const T=d.current;return lw().then(M=>{!E&&d.current===T&&(a(M),c(!0))}),()=>{E=!0}},h=[m],n[3]=m,n[4]=p,n[5]=h):(p=n[4],h=n[5]),b.useEffect(p,h);let g;n[6]!==(s==null?void 0:s.edition)?(g=()=>{let E=!1;const T=()=>{const M=d.current=d.current+1,I=()=>{E||d.current!==M||(a(!1),c(!0))};if(t||(s==null?void 0:s.edition)==="team"){I();return}Yu().then(R=>{E||d.current!==M||(o(R),R.edition==="team"&&I())})};return window.addEventListener("cogpit-auth-required",T),()=>{E=!0,window.removeEventListener("cogpit-auth-required",T)}},n[6]=s==null?void 0:s.edition,n[7]=g):g=n[7];const x=s==null?void 0:s.edition;let v;n[8]!==x?(v=[x,t],n[8]=x,n[9]=v):v=n[9],b.useEffect(g,v);let w;n[10]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{d.current=d.current+1,a(!0),c(!0),window.dispatchEvent(new Event("cogpit-auth-changed"))},n[10]=w):w=n[10];const y=w;let j;n[11]===Symbol.for("react.memo_cache_sentinel")?(j=async()=>{o(await Yu())},n[11]=j):j=n[11];const k=j;let N;n[12]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{d.current=d.current+1,a(!1),c(!0),cw().finally(xM)},n[12]=N):N=n[12];const C=N,S=(s==null?void 0:s.edition)??null,_=l&&s!==null,P=(s==null?void 0:s.needsBootstrap)===!0;let A;return n[13]!==i||n[14]!==S||n[15]!==_||n[16]!==P?(A={isRemote:t,edition:S,authChecked:_,authenticated:i,needsBootstrap:P,handleAuthenticated:y,refreshServerState:k,logout:C},n[13]=i,n[14]=S,n[15]=_,n[16]=P,n[17]=A):A=n[17],A}function xM(){window.dispatchEvent(new Event("cogpit-auth-changed"))}const bM=b.lazy(()=>Ke(()=>import("./index-DUI5EaV5.js"),__vite__mapDeps([37,1,2,3,4])).then(n=>({default:n.BranchModal}))),vM=b.lazy(()=>Ke(()=>import("./WorkflowsPanel-Cgm_kbHR.js"),__vite__mapDeps([38,1,4,2,3])).then(n=>({default:n.WorkflowsPanel})));function yM(){var mu,pu,hu,gu,xu,bu,vu,yu,wu,ju,Su,ku,Nu,Cu,_u,Tu,Eu,Pu,Au,Ru;const n=Rd(window.location.pathname),e=gR(),t=gM(),s=wR(t.edition),o=s.checked&&(t.edition!=="team"||s.authenticated&&s.edition==="team"&&s.user!==null),i=o&&s.capabilities.configWrite,a=o&&s.capabilities.hostFiles,l=o&&s.capabilities.terminal,c=va(),d=n2(),[f,u]=X0(),{procBySession:m}=px(),{parse:p,append:h}=p2(),g=b.useCallback(ke=>{u({type:"SET_OLDER_TURNS",turns:ke})},[u]),x=b.useCallback((ke,Ve)=>{fM(ke,Ve,p)},[p]),v=h2({dirName:((mu=f.sessionSource)==null?void 0:mu.dirName)??null,fileName:((pu=f.sessionSource)==null?void 0:pu.fileName)??null,sessionChangeKey:f.sessionChangeKey,workerParse:p,onOlderTurns:g}),{loadMore:w}=v,y=!!f.searchQuery&&v.hasMore,j=((hu=f.session)==null?void 0:hu.turns.length)??0;b.useEffect(()=>{y&&w()},[y,w,j]);const k=LR(f,u),N=b.useRef(null),C=b.useRef(null),[S,_]=b.useState(!1),[P,A]=b.useState(!1),E=b.useCallback(()=>u({type:"TOGGLE_EXPAND_ALL"}),[u]),T=b.useCallback(()=>_(!0),[]),M=b.useCallback(()=>{var ke;return(ke=C.current)==null?void 0:ke.focus()},[]),I=b.useCallback(()=>u({type:"SET_EXPAND_ALL",value:!0}),[u]),R=b.useCallback(()=>u({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0}),[u]),$=b.useCallback(()=>u({type:"SET_EXPAND_ALL",value:!1}),[u]),D=b.useCallback(ke=>{b.startTransition(()=>{u({type:"SET_DASHBOARD_PROJECT",dirName:ke})})},[u]),O=f.pendingCwd??(f.pendingDirName?hn(f.pendingDirName):null),L=((gu=f.sessionSource)==null?void 0:gu.agentKind)??St(((xu=f.sessionSource)==null?void 0:xu.dirName)??f.pendingDirName??null),z=(bu=f.session)!=null&&bu.sessionId?m.get(f.session.sessionId):void 0,F=zt(L),H=Ad(L,z),B=F.worktrees,W=F.mcp,K=OR(i?((vu=f.session)==null?void 0:vu.cwd)??O??void 0:void 0,i&&F.slashCommands),V=b.useCallback(ke=>{if(!i)return;const Ve=K.suggestions.find(vt=>vt.name===ke);b.startTransition(()=>{u({type:"OPEN_CONFIG",filePath:Ve==null?void 0:Ve.filePath})})},[i,u,K.suggestions]),Y=b.useCallback(async(ke,Ve)=>{if(!i)return null;const vt=K.suggestions.find(ln=>ln.name===ke);if(!(vt!=null&&vt.filePath))return null;try{const ln=await ye("/api/expand-command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:vt.filePath,args:Ve||""})});return ln.ok?(await ln.json()).content??null:null}catch{return null}},[i,K.suggestions]),{processPanel:q,currentCwd:J,showPreview:Z,showProjectFiles:Q,projectFilesRoot:ee,projectFilesRequest:oe,launchTerminalRequest:se,pendingProject:re,handleOpenTerminal:ie,handleMcpAuth:ae,handleToggleIntegratedTerminal:te,handleNewIntegratedTerminal:he,handleTogglePreview:me,handleToggleProjectFiles:le,closeRightWorkspace:xe}=GR({sessionId:(yu=f.session)==null?void 0:yu.sessionId,sessionCwd:(wu=f.session)==null?void 0:wu.cwd,pendingPath:O,sessionDirName:(ju=f.sessionSource)==null?void 0:ju.dirName,pendingDirName:f.pendingDirName,dashboardProject:f.dashboardProject,supportsFileWorkspace:!c&&a}),ge=RR(f.session??null),[ce,we]=b.useState(!1),pe=((Su=f.sessionSource)==null?void 0:Su.dirName)??f.pendingDirName??f.dashboardProject??null,ue=CR(o&&B&&k.showWorktrees?pe:null),je=b.useMemo(()=>{const ke=f.session;return ke?ke.turns.some(Ve=>_i(Ve.toolCalls,ke.cwd)||Ve.subAgentActivity.some(vt=>_i(vt.toolCalls,ke.cwd))):!1},[f.session]),Ne=b.useMemo(()=>{if(!f.session||!F.workflows)return 0;let ke=0;for(const Ve of f.session.turns)for(const vt of Ve.toolCalls)vt.name==="Workflow"&&ke++;return ke},[f.session,F.workflows]),Re=Ne>0,Te=b.useMemo(()=>{const ke=f.sessionSource;return!ke||!F.workflows||bs(ke.fileName)?{dirName:null,sessionId:null}:{dirName:ke.dirName,sessionId:Rl(ke.fileName)}},[f.sessionSource,F.workflows]),Pe=OA(Te.dirName,Te.sessionId,Re),Oe=Re||Pe.workflows.length>0,Fe=Pe.workflows.length||Ne,ze=k.setShowWorkflows,Be=b.useCallback(()=>ze(!0),[ze]),[_e,He]=b.useState(!1),Ie=b.useCallback(ke=>{He(ke.asPercentage===0)},[]),[Ce,de]=b.useState(!1),[Ee,Ae]=b.useState(!1),Le=k.setShowFileChanges;b.useEffect(()=>{if(!a)return;const ke=()=>{c?de(!0):b.startTransition(()=>{Le(!0),He(!1)})};return window.addEventListener(dr,ke),()=>window.removeEventListener(dr,ke)},[a,Le,c]);const ne=b.useMemo(()=>f.session?R1(f.session):null,[f.session]),fe=b.useRef(null),{isLive:Se,sseState:$e,isCompacting:Ue,streamingOverlay:We,turnError:Xe,agentProgress:Je,promptSuggestion:De}=V0(f.sessionSource,ke=>{b.startTransition(()=>{u({type:"UPDATE_SESSION",session:ke})})},p,h,()=>{var ke;return(ke=fe.current)==null?void 0:ke.call(fe)},f.session),qe=b.useMemo(()=>We.reduce((ke,Ve)=>ke+Ve.blocks.reduce((vt,ln)=>vt+ln.text.length,0),0),[We]),ot=$R(((ku=f.session)==null?void 0:ku.cwd)??null),lt=nR(),bt=lt.setMode,$t=rR(H?null:((Nu=f.session)==null?void 0:Nu.sessionId)??null),Vt=H?null:$t.plan??ne,{selectedModel:Wt,setSelectedModel:ts,selectedEffort:Ge,setSelectedEffort:et,fastModeEnabled:mt,ultracodeEnabled:Ft,effectiveEffort:Zt,fastModeAvailable:Us,fastModeActive:Ir,setFastModeEnabled:Ta,ultracodeAvailable:y2,ultracodeActive:$r,setUltracodeEnabled:Ea,imageInputAvailable:Md,modelFallbackNotice:w2,dismissModelFallbackNotice:j2,handleCodexModelRejected:Id}=HR({agentKind:L,session:f.session,sessionSource:f.sessionSource,pendingDirName:f.pendingDirName,isLive:Se}),$d=TR((Cu=f.session)==null?void 0:Cu.sessionId,(_u=f.sessionSource)==null?void 0:_u.fileName);qR({sessionKey:$d,values:{model:Wt,effort:Ge,fastMode:mt,ultracode:Ft,permissionMode:lt.config.mode},onHydrate:b.useCallback(ke=>{ke.model!==void 0&&ts(ke.model),ke.effort!==void 0&&et(ke.effort),ke.fastMode!==void 0&&Ta(ke.fastMode),ke.ultracode!==void 0&&Ea(ke.ultracode),ke.permissionMode&&bt(ke.permissionMode)},[ts,et,Ta,Ea,bt])});const en=AR(W&&i?J:void 0,W&&i?pe??void 0:void 0,W&&i?$d??void 0:void 0,i),{showWorktrees:Od,setShowWorktrees:Dd,showWorkflows:Ld}=k;b.useEffect(()=>{!B&&Od&&Dd(!1)},[B,Od,Dd]),b.useEffect(()=>{Ld&&!Oe&&ze(!1)},[Ld,Oe,ze]);const{creatingSession:zd,createError:Fd,clearCreateError:S2,createAndSend:k2,cancelCreation:Bd,worktreeEnabled:N2,setWorktreeEnabled:C2,sessionFinalizedRef:Or,liveSessionsRefreshRef:Ud,pendingSessionInfo:Wd,pendingAgentKindChange:_2,handleStartNewSession:Hd,handleStartNewFolder:T2}=dM({permissionsConfig:lt.config,dispatch:u,isMobile:c,defaultAgentKind:e.defaultAgentKind,pendingDirName:f.pendingDirName,pendingCwd:f.pendingCwd,onCodexModelRejected:Id,model:Wt,effort:Zt,fastMode:Ir,ultracode:$r,mcpConfig:W&&i?en.mcpConfigJson:null}),pt=zA({sessionSource:f.sessionSource,parsedSessionId:((Tu=f.session)==null?void 0:Tu.sessionId)??null,cwd:(Eu=f.session)==null?void 0:Eu.cwd,permissions:lt.config,onPermissionsApplied:lt.markApplied,model:Wt,effort:Zt,fastMode:Ir,ultracode:$r,mcpConfig:W&&i?en.mcpConfigJson:null,onCodexModelRejected:Id,readOnly:H,onCreateSession:f.pendingDirName?k2:void 0}),Mt=IA(F.agentTeams?((Pu=f.sessionSource)==null?void 0:Pu.fileName)??null:null,((Au=f.sessionSource)==null?void 0:Au.dirName)??null);b.useEffect(()=>{Mt!=null&&Mt.currentMemberName?u({type:"SET_CURRENT_MEMBER_NAME",name:Mt.currentMemberName}):Mt||u({type:"SET_CURRENT_MEMBER_NAME",name:null})},[Mt==null?void 0:Mt.currentMemberName,Mt,u]),b.useEffect(()=>{c&&u({type:"GUARD_MOBILE_TAB",hasSession:!!f.session||!!f.pendingDirName})},[f.session,f.pendingDirName,f.mobileTab,c,u]);const jn=J0({session:f.session,isLive:Se,pendingMessages:pt.pendingMessages,consumePending:pt.consumePending,sessionChangeKey:f.sessionChangeKey,partialContentLen:qe}),Kd=jn.chatScrollRef,qd=jn.resetTurnCount,Vd=jn.scrollToBottomInstant,E2=b.useCallback(ke=>{we(ke),requestAnimationFrame(()=>{const Ve=Kd.current;Ve&&Ve.scrollTo({top:Ve.scrollTop+(ke?64:-64),behavior:"smooth"})})},[Kd]);b.useLayoutEffect(()=>{const ke=Ve=>{qd(0),Vd()};return Or.current=ke,()=>{Or.current===ke&&(Or.current=null)}},[qd,Vd,Or]);const P2=b.useCallback(()=>{pt.disconnect(),Bd()},[pt.disconnect,Bd]),Sn=UA({dispatch:u,isMobile:c,mobileTab:f.mobileTab,teamContext:Mt,scrollToBottomInstant:jn.scrollToBottomInstant,resetTurnCount:jn.resetTurnCount,workerParse:p,onBeforeSwitch:P2}),A2=b.useCallback(ke=>{b.startTransition(()=>{u({type:"GO_HOME",isMobile:c}),u({type:"SET_DASHBOARD_PROJECT",dirName:ke})})},[u,c]),{previewLoadError:R2}=qA({state:f,dispatch:u,isMobile:c,resetTurnCount:jn.resetTurnCount,scrollToBottomInstant:jn.scrollToBottomInstant,workerParse:p}),Dr=eR(),Gd=Dr.push;b.useEffect(()=>{f.sessionSource&&Gd(f.sessionSource.dirName,f.sessionSource.fileName)},[f.sessionSource,Gd]);const ft=UR({state:{session:f.session,sessionSource:f.sessionSource},dispatch:u,isMobile:c,handleJumpToTurn:Sn.handleJumpToTurn,markPermissionsApplied:lt.markApplied,hasPermsPendingChanges:lt.hasPendingChanges,permissionsConfig:lt.config,selectedModel:Wt,selectedEffort:Zt,fastMode:Ir,ultracode:$r,mcpConfig:W&&i?en.mcpConfigJson:null,scrollRequestScrollToTop:jn.requestScrollToTop,handleDashboardSelect:Sn.handleDashboardSelect,workerParse:p}),{hasSettingsChanges:Yd,handleApplySettings:Xd}=ft,Jd=W&&i&&en.mcpConfigJson!==null,Qd=b.useRef(!1);b.useEffect(()=>{var vt;const ke=en.loaded&&!Qd.current;Qd.current=en.loaded;const Ve=(vt=f.session)==null?void 0:vt.sessionId;ke&&Ve&&Jd&&Yd&&Xd()},[en.loaded,Jd,Yd,Xd,(Ru=f.session)==null?void 0:Ru.sessionId]),b.useLayoutEffect(()=>(fe.current=ft.reloadSession,()=>{fe.current===ft.reloadSession&&(fe.current=null)}),[ft.reloadSession]);const On=u2(f.session,f.sessionSource,ft.reloadSession,a),Lr=On.requestBranchSwitch,zr=ft.setBranchModalTurn,M2=b.useCallback((ke,Ve)=>{Lr(ke,Ve),zr(null)},[Lr,zr]),I2=b.useCallback(ke=>{Lr(ke),zr(null)},[Lr,zr]);YA({isMobile:c,searchInputRef:N,chatInputRef:C,dispatch:u,onToggleSidebar:k.handleToggleSidebar,onToggleRightSidebar:k.handleToggleStats,onToggleMissionControl:k.handleToggleMission,onOpenCommandPalette:T,onOpenProjectSwitcher:k.handleOpenProjectSwitcher,onOpenThemeSelector:k.handleToggleThemeSelector,onOpenTerminal:ie,onToggleIntegratedTerminal:te,onTogglePreview:me,onToggleProjectFiles:le,onHistoryBack:Dr.goBack,onHistoryForward:Dr.goForward,onNavigateToSession:Sn.handleDashboardSelect,onCommitNavigation:Dr.commitNavigation});const{killing:$2,handleKillAll:O2}=_R(),ns=f.sessionSource?bs(f.sessionSource.fileName):null,D2=ns!==null&&!!(Mt!=null&&Mt.currentMemberName),Pa=ns!==null&&!D2,Fr=Sn.handleDashboardSelect,Zd=b.useCallback(()=>{!f.sessionSource||!ns||Fr(f.sessionSource.dirName,ns.parentFileName)},[f.sessionSource,ns,Fr]);b.useEffect(()=>{const ke=Ve=>{const{agentId:vt}=Ve.detail??{};if(!vt||!f.sessionSource||!F.subagentTranscripts)return;const ln=ns?ns.parentSessionId:Rl(f.sessionSource.fileName);Fr(f.sessionSource.dirName,`${ln}/subagents/agent-${vt}.jsonl`)};return window.addEventListener(Ti,ke),()=>window.removeEventListener(Ti,ke)},[f.sessionSource,ns,Fr,F.subagentTranscripts]);const[L2,eu]=b.useState(null),z2=ft.branchModalTurn!==null,Ws=ft.branchModalTurn??L2;b.useEffect(()=>{ft.branchModalTurn!==null&&eu(ft.branchModalTurn)},[ft.branchModalTurn]);const tu=Ws!==null?On.branchesAtTurn(Ws):[],F2=Pa?r.jsxs("div",{className:"flex shrink-0 items-center justify-center gap-2 border-t bg-card px-4 py-2.5",children:[r.jsx(lo,{"data-icon":"inline-start",className:"size-3.5 text-muted-foreground"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:"Viewing sub-agent session (read-only)"})]}):null,B2=H?r.jsxs("div",{role:"status",className:"flex shrink-0 items-center justify-center gap-2 border-t bg-card px-4 py-2.5",children:[r.jsx(lo,{"data-icon":"inline-start",className:"size-3.5 text-muted-foreground"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:jw(L)})]}):null,Aa=F2||B2,U2=Sn.loadError||Fd||null;let Ra;Sn.loadError?Ra=Sn.clearLoadError:Fd&&(Ra=S2);const W2=!!(f.session&&f.sessionSource&&$e==="disconnected"),Ma=b.useMemo(()=>({state:f,dispatch:u,config:e,theme:d,networkAuth:t,me:s,isMobile:c}),[f.activeTurnIndex,f.activeToolCallId,f.searchQuery,f.expandAll,f.expandToolPayloads,f.mainView,f.mobileTab,f.dashboardProject,f.pendingDirName,f.pendingCwd,f.currentMemberName,f.loadingMember,f.configFilePath,f.sessionChangeKey,u,e,d,t,s,c]),Ia=b.useMemo(()=>({session:f.session,sessionSource:f.sessionSource,isLive:Se,sseState:$e,isCompacting:Ue,turnError:Xe,promptSuggestion:De,undoRedo:On,pendingInteraction:Vt,permissionRequests:$t.requests,permissionResponding:$t.responding,respondPermission:$t.respond,respondAllPermissions:$t.respondAll,isSubAgentView:Pa,slashSuggestions:K.suggestions,slashSuggestionsLoading:K.loading,actions:{handleStopSession:ft.handleStopSession,handleEditConfig:i?k.handleEditConfig:void 0,handleEditCommand:i?V:void 0,handleExpandCommand:i?Y:void 0,handleOpenBranches:ft.handleOpenBranches,handleBranchFromHere:ft.handleBranchFromHere,handleToggleExpandAll:E,handleLoadSession:ft.handleLoadSessionScrollAware}}),[f.session,f.sessionSource,Se,$e,Ue,Xe,De,On,Vt,Pa,$t.requests,$t.responding,$t.respond,$t.respondAll,K.suggestions,K.loading,ft.handleStopSession,i,k.handleEditConfig,V,Y,ft.handleOpenBranches,ft.handleBranchFromHere,E,ft.handleLoadSessionScrollAware]),$a=b.useMemo(()=>({chat:{status:pt.status,error:pt.error,pendingMessages:pt.pendingMessages,isConnected:pt.isConnected,sendMessage:pt.sendMessage,interrupt:pt.interrupt,stopAgent:pt.stopAgent,consumePending:pt.consumePending},scroll:jn}),[pt.status,pt.error,pt.pendingMessages,pt.isConnected,pt.sendMessage,pt.interrupt,pt.stopAgent,pt.consumePending,jn]),ko=!!f.pendingDirName&&!f.session;if(b.useEffect(()=>{if(!ko||c)return;const ke=requestAnimationFrame(()=>{var Ve;return(Ve=C.current)==null?void 0:Ve.focus()});return()=>cancelAnimationFrame(ke)},[ko,c,f.pendingDirName]),!t.authChecked)return r.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-background",role:"status","aria-label":"Checking authentication",children:r.jsx(rt,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(!t.authenticated)return t.needsBootstrap?r.jsx(hM,{onAuthenticated:t.handleAuthenticated,onBootstrapClosed:t.refreshServerState}):r.jsx(mM,{onAuthenticated:t.handleAuthenticated});if(!o)return r.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-background",role:"status","aria-label":"Loading identity",children:r.jsx(rt,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(e.configLoading)return r.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-background",role:"status","aria-label":"Loading",children:r.jsx(rt,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(e.configError)return r.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-background text-foreground",children:r.jsxs(Hn,{children:[r.jsxs(Kn,{children:[r.jsx(js,{variant:"icon",children:r.jsx(wn,{className:"text-destructive"})}),r.jsx(qn,{children:"Failed to connect"}),r.jsx(Vn,{children:e.configError})]}),r.jsx(vh,{children:r.jsxs(X,{variant:"outline",size:"sm",onClick:e.retryConfig,children:[r.jsx(Qt,{"data-icon":"inline-start"}),"Retry"]})})]})});if(!e.claudeDir)return i?r.jsx(BS,{onConfigured:e.setClaudeDir}):r.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-background text-sm text-muted-foreground",children:"Cogpit is waiting for an administrator to finish server setup."});const Oa=r.jsx(ow,{activeError:U2,clearActiveError:Ra,modelFallbackNotice:w2,dismissModelFallbackNotice:j2,connectionLost:W2,theme:d.activeTheme}),nu=a?r.jsx(OS,{state:On.confirmState,isApplying:On.isApplying,applyError:On.applyError,onConfirm:On.confirmApply,onCancel:On.confirmCancel}):null,H2=Ws!==null&&f.session?f.session.turns.slice(Ws):[],su=a&&Ws!==null&&tu.length>0&&r.jsx(b.Suspense,{fallback:null,children:r.jsx(bM,{open:z2,branches:tu,branchPointTurnIndex:Ws,currentTurns:H2,onClose:ft.handleCloseBranchModal,onCloseComplete:()=>eu(null),onRedoToTurn:M2,onRedoEntireBranch:I2})}),ou=l&&r.jsx(NS,{processes:q.processes,activeProcessId:q.activeProcessId,collapsed:q.collapsed,onSetActive:q.setActive,onRemove:q.removeProcess,onToggleCollapse:q.toggleCollapse,onRequestTerminal:ut("terminal")?he:void 0,onAddTerminalContext:ke=>{var Mu,Iu,$u;const Ve=ke.trim();if(!Ve)return;const vt=Ve.includes("```")?"````":"```",ln=`${vt}terminal
|
|
139
|
+
${Ve}
|
|
140
|
+
${vt}`,Da=((Mu=C.current)==null?void 0:Mu.getText().trimEnd())??"";(Iu=C.current)==null||Iu.setText(Da?`${Da}
|
|
141
|
+
|
|
142
|
+
${ln}
|
|
143
|
+
`:`${ln}
|
|
144
|
+
`),($u=C.current)==null||$u.focus()},onUpdateStatus:q.updateProcessStatus,projectDir:J,onProcessStarted:q.addProcess,mobile:c}),ru=Mt&&r.jsx(p3,{teamName:Mt.config.name||Mt.teamName,members:Mt.config.members,currentMemberName:f.currentMemberName,loadingMember:f.loadingMember,onMemberClick:Sn.handleTeamMemberSwitch}),iu=Oe&&r.jsx(b.Suspense,{fallback:null,children:r.jsx(vM,{open:k.showWorkflows,onOpenChange:k.setShowWorkflows,dirName:Te.dirName,sessionId:Te.sessionId,workflows:Pe.workflows,isLive:Pe.isLive,onRefetchList:Pe.refetch},`${Te.dirName??""}:${Te.sessionId??""}`)}),Br=F.goals?f.session:null,au=ke=>{var Ve;return r.jsx(d3,{agentKind:L,onAgentKindChange:ko?_2:void 0,selectedModel:Wt,onModelChange:ts,selectedEffort:Zt,onEffortChange:et,fastModeEnabled:Ir,onFastModeEnabledChange:Us?Ta:void 0,isNewSession:ko,worktreeEnabled:N2,onWorktreeEnabledChange:ko&&B?C2:void 0,ultracodeEnabled:$r,onUltracodeEnabledChange:y2?Ea:void 0,onApplySettings:ft.handleApplySettings,activeModelId:(Ve=f.session)==null?void 0:Ve.model,mcpServers:W&&i?en.servers:void 0,selectedMcpServers:W&&i?en.selectedServers:void 0,onToggleMcpServer:W&&i?en.toggleServer:void 0,onRefreshMcpServers:W&&i?en.refresh:void 0,mcpLoading:W&&i?en.loading:void 0,onMcpAuth:W&&i?ae:void 0,permissionMode:lt.config.mode,onPermissionModeChange:lt.setMode,mobileExtra:c&&ke&&Br?r.jsx(eS,{}):void 0,trailingExtra:!c&&ke&&Br?r.jsx(lg,{}):void 0,mobile:c})},lu=au(!0),cu=au(!1),du=r.jsxs("div",{className:"shrink-0 bg-background",children:[!c&&r.jsx(ag,{}),r.jsx(Fl,{ref:C,allowImages:Md,agentKind:L,projectCwd:J,compact:c,leadingAccessory:c?lu:void 0}),!c&&lu]}),Ur=Br?r.jsx(Zj,{agentKind:L,session:Br,onSendCommand:pt.sendMessage,children:du}):du,K2=r.jsxs("div",{className:"shrink-0 bg-background",children:[r.jsx(Fl,{ref:C,allowImages:Md,agentKind:L,projectCwd:J,compact:c,leadingAccessory:c?cu:void 0}),!c&&cu]}),uu=pt.pendingMessages.map((ke,Ve)=>r.jsx(K1,{message:ke,turnNumber:Ve+1},Ve)),q2=c?f.mobileTab==="stats":k.showStats,fu=f.session&&!q2&&r.jsx("div",{className:"hidden",children:r.jsx(xg,{cwd:f.session.cwd,turns:f.session.turns,onServersChanged:q.handleServersChanged})});return n?r.jsxs(fi,{value:Ma,children:[r.jsx(Va,{children:r.jsx(di,{value:Ia,chatValue:$a,children:r.jsx(rl,{value:We,agentProgress:Je,children:r.jsx(EA,{sessionId:n,loadError:R2,searchInputRef:N,activeComposer:Aa||K2,hasMoreTurns:v.hasMore,isLoadingOlderTurns:v.isLoadingOlder,onLoadMoreTurns:v.loadMore})})})}),Oa]}):c?r.jsxs(fi,{value:Ma,children:[r.jsx(Va,{enabled:l,children:r.jsx(di,{value:Ia,chatValue:$a,children:r.jsx(rl,{value:We,agentProgress:Je,children:r.jsx(TA,{navigation:{actions:Sn,handlers:ft,creatingSession:zd,pendingSession:Wd,onStartNewSession:Hd,onSelectProject:D,liveSessionsRefreshRef:Ud,onPrefetchSession:x},sessionView:{searchInputRef:N,teamMembersBar:ru,activeComposer:Aa||Ur,pendingComposer:Ur,pendingTurns:uu,todoProgress:ge&&r.jsx(q1,{progress:ge}),hasMoreTurns:v.hasMore,isLoadingOlderTurns:v.isLoadingOlder,onLoadMoreTurns:v.loadMore,onBackToMain:Zd,onShowWorkflows:Be,onToggleExpandAll:E,workflowCount:Fe,pendingPath:O},project:{processPanel:q,backgroundAgents:ot,hasFileChanges:a&&je,onOpenTerminal:ie},chrome:{backgroundServers:fu,processPanel:ou,workflowsPanel:iu,undoDialog:nu,branchModal:su,fileChangesOpen:Ce,onFileChangesOpenChange:de,searchOpen:Ee,onSearchOpenChange:Ae}})})})}),Oa]}):r.jsxs(fi,{value:Ma,children:[r.jsx(Va,{enabled:l,children:r.jsx(di,{value:Ia,chatValue:$a,children:r.jsx(rl,{value:We,agentProgress:Je,children:r.jsx(vA,{navigation:{panels:k,actions:Sn,handlers:ft,creatingSession:zd,pendingSession:Wd,onStartNewSession:Hd,onStartNewFolder:T2,onSelectProject:D,onOpenPaletteProject:A2,liveSessionsRefreshRef:Ud,onPrefetchSession:x},sessionView:{searchInputRef:N,chatInputRef:C,teamMembersBar:ru,activeComposer:Aa||Ur,pendingComposer:Ur,pendingTurns:uu,todoProgress:ge,todosExpanded:ce,onTodosExpandedChange:E2,hasMoreTurns:v.hasMore,isLoadingOlderTurns:v.isLoadingOlder,onLoadMoreTurns:v.loadMore,onBackToMain:Zd,onShowWorkflows:Be,workflowCount:Fe,fileChangesCollapsed:_e,onFileChangesPanelResize:Ie},project:{processPanel:q,worktrees:ue,backgroundAgents:ot,supportsWorktrees:B,hasFileChanges:a&&je,currentCwd:J,showPreview:Z,showProjectFiles:a&&Q,projectFilesRoot:ee,projectFilesRequest:oe,launchTerminalRequest:se,pendingProject:re,onOpenTerminal:ie,onTogglePreview:me,onToggleProjectFiles:le,onCloseRightWorkspace:xe},chrome:{backgroundServers:fu,processPanel:ou,workflowsPanel:iu,undoDialog:nu,branchModal:su,killing:$2,onKillAll:O2,commandPaletteOpen:S,onCommandPaletteOpenChange:_,onOpenCommandPalette:T,onFocusComposer:M,onExpandAll:I,onExpandToolPayloads:R,onCollapseAll:$,keyboardShortcutsOpen:P,onKeyboardShortcutsOpenChange:A}})})})}),Oa]})}function wM(){var w;const[n,e]=b.useState(ht),[t,s]=b.useState(()=>ci(ht())),[o,i]=b.useState(ms),[a,l]=b.useState(0),[c,d]=b.useState(!1),[f,u]=b.useState(!1),[m,p]=b.useState(!1),{devices:h,testDevice:g}=ka();b.useEffect(()=>{const y=()=>{const j=ht();e(k=>k===j?k:j),s(ci(j))};return window.addEventListener("cogpit-device-changed",y),window.addEventListener("popstate",y),()=>{window.removeEventListener("cogpit-device-changed",y),window.removeEventListener("popstate",y)}},[]),b.useEffect(()=>{const y=j=>{const k=j.detail;(k==null?void 0:k.deviceId)===ht()&&s(ci(k.deviceId))};return window.addEventListener("cogpit-device-scope-changed",y),()=>window.removeEventListener("cogpit-device-scope-changed",y)},[]),b.useEffect(()=>{const y=()=>i(ms());return window.addEventListener("cogpit-identity-changed",y),()=>window.removeEventListener("cogpit-identity-changed",y)},[]),b.useEffect(()=>(window.__cogpitRevealSession=d0,()=>{delete window.__cogpitRevealSession}),[]),b.useEffect(()=>{const y=j=>{const k=[wt,...h.map(_=>_.id)],N=ht();let C;const S=J7(j);if(S!==null)C=k[S-1];else if(Q7(j)){const _=k.indexOf(N);C=k[(_+1)%k.length]}!C||C===N||(j.preventDefault(),ps(C))};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[h]),b.useEffect(()=>{const y=j=>{const k=j.detail;!(k!=null&&k.deviceId)||k.deviceId!==ht()||(d(!0),k.reason==="DEVICE_AUTH_FAILED"&&u(!0))};return window.addEventListener("cogpit-device-unreachable",y),()=>window.removeEventListener("cogpit-device-unreachable",y)},[]),b.useEffect(()=>{d(!1),u(!1),p(!1)},[n,t]);const x=b.useCallback(async()=>{p(!0);try{const y=await g(n);y.reachable&&y.authState==="bad-password"?u(!0):y.ok&&(d(!1),u(!1),l(j=>j+1))}finally{p(!1)}},[n,g]);b.useEffect(()=>{if(!c||f)return;const y=setInterval(()=>void x(),1e4);return()=>clearInterval(y)},[c,f,x]);const v=((w=h.find(y=>y.id===n))==null?void 0:w.name)??n;return r.jsxs(r.Fragment,{children:[c&&n!==wt&&r.jsxs(Ct,{role:"status",className:"fixed inset-x-3 top-3 z-40 mx-auto max-w-2xl border-warning/40 bg-popover shadow-md",children:[r.jsx(Qv,{"data-icon":"inline-start",className:"text-warning"}),r.jsx(Dt,{children:f?"Device credentials need attention":"Remote device unavailable"}),r.jsx(_t,{children:f?`${v} rejected the stored password. Update it in Devices.`:`Can’t reach ${v}. Cogpit will keep retrying.`}),r.jsxs("div",{className:"col-start-2 mt-2 flex flex-wrap gap-2",children:[!f&&r.jsxs(X,{variant:"outline",size:"xs",onClick:()=>void x(),disabled:m,children:[m&&r.jsx(rt,{"data-icon":"inline-start",className:"animate-spin"}),m?"Retrying":"Retry now"]}),r.jsx(X,{variant:"outline",size:"xs",onClick:()=>ps(wt),children:"Switch to this machine"})]})]}),r.jsx(IC,{children:r.jsx(AP,{children:r.jsx(yM,{})})},`${n}:${t}:${a}:${o??""}`)]})}const Ip="Invalid link or passphrase.";function jM(n,e){return n===401?Ip:n===429?e||"Too many attempts. Try again in a minute.":n===426?"This link needs a secure HTTPS connection. Open the tunnel URL instead of the plain http address.":n===403?"Network access is off on the host, so this session cannot be joined right now.":e||Ip}function SM({sessionId:n,onAuthenticated:e}){const[t,s]=b.useState(""),[o,i]=b.useState(!1),[a,l]=b.useState(null),[c,d]=b.useState(!1),f=b.useCallback(async u=>{if(u.preventDefault(),!!t.trim()){d(!0),l(null);try{const m=await fetch("/api/share/verify",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json","X-Cogpit-Client":"1"},body:JSON.stringify({sessionId:n,passphrase:t})}),p=await m.json();m.ok&&p.valid?(s(""),e()):l(jM(m.status,p.error))}catch{l("Failed to connect to server")}finally{d(!1)}}},[e,t,n]);return r.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-4 py-8",children:r.jsx("form",{onSubmit:f,className:"w-full max-w-sm",children:r.jsxs(Xt,{children:[r.jsxs(tn,{children:[r.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:r.jsx(Wn,{className:"size-4"})}),r.jsx(nn,{children:"Join this session"}),r.jsx(sn,{children:"Enter the passphrase you were given to join the shared session."})]}),r.jsxs(Jt,{className:"flex flex-col gap-4",children:[r.jsx(wo,{children:r.jsxs(gt,{children:[r.jsx(xt,{htmlFor:"share-passphrase",children:"Passphrase"}),r.jsxs(Zn,{children:[r.jsx(es,{id:"share-passphrase",type:o?"text":"password",value:t,onChange:u=>s(u.target.value),placeholder:"copper-lantern-drift-92",autoComplete:"current-password",autoFocus:!0}),r.jsx(yn,{align:"inline-end",children:r.jsx(Cr,{size:"icon-xs",onClick:()=>i(u=>!u),"aria-label":o?"Hide passphrase":"Show passphrase",children:o?r.jsx(Wi,{}):r.jsx(vo,{})})})]})]})}),a&&r.jsxs(Ct,{variant:"destructive",children:[r.jsx(bn,{"aria-hidden":"true"}),r.jsx(Dt,{children:"Could not join"}),r.jsx(_t,{children:a})]})]}),r.jsx(So,{children:r.jsxs(X,{type:"submit",className:"w-full",disabled:c||!t.trim(),children:[c&&r.jsx(Ut,{"data-icon":"inline-start"}),"Connect"]})})]})})})}function kM(){const n=U.c(9),[e,t]=b.useState("idle"),[s,o]=b.useState();let i;n[0]===Symbol.for("react.memo_cache_sentinel")?(i=[],n[0]=i):i=n[0];const[a,l]=b.useState(i);let c;n[1]===Symbol.for("react.memo_cache_sentinel")?(c=(x,v)=>{l(w=>[...w,x]),t("connected"),o(void 0),Aj(x,v).then(w=>{if(w.ok){t("idle");return}o(`Request failed (${w.status})`),t("error"),l(_M)}).catch(w=>{o(w instanceof Error?w.message:"Unknown error"),t("error"),l(CM)})},n[1]=c):c=n[1];const d=c;let f;n[2]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{Rj().catch(NM),t("idle"),l([])},n[2]=f):f=n[2];const u=f;let m;n[3]===Symbol.for("react.memo_cache_sentinel")?(m=x=>{const v=x===void 0?1:x;l(w=>w.slice(v))},n[3]=m):m=n[3];const p=m,h=e==="connected";let g;return n[4]!==s||n[5]!==a||n[6]!==e||n[7]!==h?(g={status:e,error:s,pendingMessages:a,isConnected:h,sendMessage:d,interrupt:u,stopAgent:u,consumePending:p},n[4]=s,n[5]=a,n[6]=e,n[7]=h,n[8]=g):g=n[8],g}function NM(){}function CM(n){return n.slice(0,-1)}function _M(n){return n.slice(0,-1)}const TM=2e3;function EM(n,e){return n.length!==e.length?!1:JSON.stringify(n)===JSON.stringify(e)}function PM(){const n=U.c(11);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],n[0]=e):e=n[0];const[t,s]=b.useState(e);let o;n[1]===Symbol.for("react.memo_cache_sentinel")?(o=new Set,n[1]=o):o=n[1];const[i,a]=b.useState(o);let l,c;n[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{let h=!1;const g=async()=>{const w=await Oj();h||w===null||s(y=>EM(y,w)?y:w)},x=()=>{document.visibilityState==="visible"&&g()};x();const v=setInterval(x,TM);return document.addEventListener("visibilitychange",x),()=>{h=!0,clearInterval(v),document.removeEventListener("visibilitychange",x)}},c=[],n[2]=l,n[3]=c):(l=n[2],c=n[3]),b.useEffect(l,c);let d;n[4]===Symbol.for("react.memo_cache_sentinel")?(d=(h,g)=>{a(x=>new Set(x).add(h)),Ij(h,g).then(x=>{x&&s(v=>v.filter(w=>w.requestId!==h))}).finally(()=>{a(x=>{const v=new Set(x);return v.delete(h),v})})},n[4]=d):d=n[4];const f=d;let u;n[5]!==t?(u=h=>{for(const g of t)f(g.requestId,h)},n[5]=t,n[6]=u):u=n[6];const m=u;let p;return n[7]!==t||n[8]!==m||n[9]!==i?(p={requests:t,responding:i,respond:f,respondAll:m},n[7]=t,n[8]=m,n[9]=i,n[10]=p):p=n[10],p}const b2={authenticated:!0,edition:"personal",user:null,capabilities:Sr};function AM(n){var le,xe;const e=U.c(78),{info:t,children:s}=n,o=va(),i=n2(),[a,l]=X0(),{parse:c,append:d}=p2(),[f,u]=b.useState("loading");let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=[],e[0]=m):m=e[0],b.useEffect(OM,m);const p=kM(),h=PM();let g;e[1]!==l||e[2]!==t.dirName||e[3]!==t.fileName||e[4]!==o||e[5]!==c?(g=async()=>{try{const{parsed:ge,source:ce}=await Z0(t.dirName,t.fileName,c,"shared session");l({type:"LOAD_SESSION",session:ge,source:ce,isMobile:o}),u("ready")}catch{u("failed")}},e[1]=l,e[2]=t.dirName,e[3]=t.fileName,e[4]=o,e[5]=c,e[6]=g):g=e[6];const x=g,v=b.useRef(!1);let w,y;e[7]!==x?(w=()=>{v.current||(v.current=!0,x())},y=[x],e[7]=x,e[8]=w,e[9]=y):(w=e[8],y=e[9]),b.useEffect(w,y);let j;e[10]!==l?(j=ge=>{l({type:"UPDATE_SESSION",session:ge})},e[10]=l,e[11]=j):j=e[11];const k=j,{isLive:N,sseState:C,isCompacting:S,turnError:_}=V0(a.sessionSource,k,c,d,void 0,a.session);let P;e[12]!==l?(P=ge=>{l({type:"SET_OLDER_TURNS",turns:ge})},e[12]=l,e[13]=P):P=e[13];const A=P,E=((le=a.sessionSource)==null?void 0:le.dirName)??null,T=((xe=a.sessionSource)==null?void 0:xe.fileName)??null;let M;e[14]!==A||e[15]!==a.sessionChangeKey||e[16]!==E||e[17]!==T||e[18]!==c?(M={dirName:E,fileName:T,sessionChangeKey:a.sessionChangeKey,workerParse:c,onOlderTurns:A},e[14]=A,e[15]=a.sessionChangeKey,e[16]=E,e[17]=T,e[18]=c,e[19]=M):M=e[19];const I=h2(M);let R;e[20]!==p.consumePending||e[21]!==p.pendingMessages||e[22]!==N||e[23]!==a.session||e[24]!==a.sessionChangeKey?(R={session:a.session,isLive:N,pendingMessages:p.pendingMessages,consumePending:p.consumePending,sessionChangeKey:a.sessionChangeKey},e[20]=p.consumePending,e[21]=p.pendingMessages,e[22]=N,e[23]=a.session,e[24]=a.sessionChangeKey,e[25]=R):R=e[25];const $=J0(R),D=u2(a.session,a.sessionSource,x,!1);let O;e[26]!==a.session?(O=a.session?R1(a.session):null,e[26]=a.session,e[27]=O):O=e[27];const L=O;let z;e[28]!==l?(z=()=>{l({type:"TOGGLE_EXPAND_ALL"})},e[28]=l,e[29]=z):z=e[29];const F=z,H=IM,B=MM;let W;e[30]!==t.dirName?(W=St(t.dirName),e[30]=t.dirName,e[31]=W):W=e[31];let K;e[32]!==W?(K={configLoading:!1,configError:null,claudeDir:null,defaultAgentKind:W,setClaudeDir:B,showConfigDialog:!1,openConfigDialog:B,handleCloseConfigDialog:B,handleConfigSaved:B,retryConfig:B,networkUrl:null,networkAccessDisabled:!1},e[32]=W,e[33]=K):K=e[33];let V;e[34]===Symbol.for("react.memo_cache_sentinel")?(V={isRemote:Xi(),edition:"personal",authChecked:!0,authenticated:!0,needsBootstrap:!1,handleAuthenticated:B,refreshServerState:RM,logout:B},e[34]=V):V=e[34];let Y;e[35]!==l||e[36]!==o||e[37]!==a||e[38]!==K||e[39]!==i?(Y={state:a,dispatch:l,config:K,theme:i,networkAuth:V,me:b2,isMobile:o},e[35]=l,e[36]=o,e[37]=a,e[38]=K,e[39]=i,e[40]=Y):Y=e[40];const q=Y;let J;e[41]===Symbol.for("react.memo_cache_sentinel")?(J=[],e[41]=J):J=e[41];let Z;e[42]!==F?(Z={handleStopSession:H,handleOpenBranches:B,handleBranchFromHere:B,handleToggleExpandAll:F,handleLoadSession:B},e[42]=F,e[43]=Z):Z=e[43];let Q;e[44]!==S||e[45]!==N||e[46]!==L||e[47]!==h.requests||e[48]!==h.respond||e[49]!==h.respondAll||e[50]!==h.responding||e[51]!==C||e[52]!==a.session||e[53]!==a.sessionSource||e[54]!==Z||e[55]!==_||e[56]!==D?(Q={session:a.session,sessionSource:a.sessionSource,isLive:N,sseState:C,isCompacting:S,turnError:_,undoRedo:D,pendingInteraction:L,permissionRequests:h.requests,permissionResponding:h.responding,respondPermission:h.respond,respondAllPermissions:h.respondAll,isSubAgentView:!1,slashSuggestions:J,slashSuggestionsLoading:!1,promptSuggestion:null,actions:Z},e[44]=S,e[45]=N,e[46]=L,e[47]=h.requests,e[48]=h.respond,e[49]=h.respondAll,e[50]=h.responding,e[51]=C,e[52]=a.session,e[53]=a.sessionSource,e[54]=Z,e[55]=_,e[56]=D,e[57]=Q):Q=e[57];const ee=Q;let oe;e[58]!==p||e[59]!==$?(oe={chat:p,scroll:$},e[58]=p,e[59]=$,e[60]=oe):oe=e[60];const se=oe;let re;e[61]!==I?(re=()=>{I.loadMore()},e[61]=I,e[62]=re):re=e[62];let ie;e[63]!==f||e[64]!==I.hasMore||e[65]!==I.isLoadingOlder||e[66]!==re?(ie={loadState:f,hasMore:I.hasMore,isLoadingOlder:I.isLoadingOlder,loadMore:re},e[63]=f,e[64]=I.hasMore,e[65]=I.isLoadingOlder,e[66]=re,e[67]=ie):ie=e[67];const ae=ie;let te;e[68]!==s||e[69]!==ae?(te=s(ae),e[68]=s,e[69]=ae,e[70]=te):te=e[70];let he;e[71]!==se||e[72]!==ee||e[73]!==te?(he=r.jsx(di,{value:ee,chatValue:se,children:te}),e[71]=se,e[72]=ee,e[73]=te,e[74]=he):he=e[74];let me;return e[75]!==q||e[76]!==he?(me=r.jsx(fi,{value:q,children:he}),e[75]=q,e[76]=he,e[77]=me):me=e[77],me}function RM(){return Promise.resolve()}function MM(){}async function IM(){await Mj().catch($M)}function $M(){}function OM(){so(b2)}function DM(n){const e=U.c(6),{info:t}=n,s=b.useRef(null);let o;e[0]!==t.provider||e[1]!==t.title?(o=a=>r.jsxs("div",{className:"flex h-dvh min-h-0 flex-col bg-background",children:[r.jsxs("header",{className:"flex shrink-0 items-center gap-2 border-b px-4 py-2",children:[r.jsx(Wn,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),r.jsx("h1",{className:"truncate text-sm font-medium text-foreground",children:t.title}),r.jsx("span",{className:"ml-auto shrink-0 text-xs text-muted-foreground",children:"Guest view"})]}),a.loadState==="failed"?r.jsx("div",{className:"flex flex-1 items-center justify-center p-6",children:r.jsxs(Ct,{variant:"destructive",className:"max-w-sm",children:[r.jsx(bn,{"aria-hidden":"true"}),r.jsx(Dt,{children:"Session unavailable"}),r.jsx(_t,{children:"This conversation could not be loaded. It may have been deleted on the host."})]})}):a.loadState==="loading"?r.jsx("div",{className:"flex flex-1 items-center justify-center",role:"status","aria-label":"Loading shared session",children:r.jsx(Ut,{className:"size-5 text-muted-foreground"})}):r.jsxs(r.Fragment,{children:[r.jsx(Sa,{searchInputRef:s,hasMore:a.hasMore,isLoadingOlder:a.isLoadingOlder,onLoadMore:a.loadMore}),r.jsx(Ca,{children:r.jsx(Fl,{agentKind:t.provider,projectCwd:null})})]})]}),e[0]=t.provider,e[1]=t.title,e[2]=o):o=e[2];let i;return e[3]!==t||e[4]!==o?(i=r.jsx(AM,{info:t,children:o}),e[3]=t,e[4]=o,e[5]=i):i=e[5],i}function Tl(n){const e=U.c(2),{children:t}=n;let s;return e[0]!==t?(s=r.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-4 py-8",children:r.jsx("div",{className:"w-full max-w-sm",children:t})}),e[0]=t,e[1]=s):s=e[1],s}function LM(){const n=U.c(19);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=sg(window.location.pathname),n[0]=e):e=n[0];const t=e;let s;n[1]===Symbol.for("react.memo_cache_sentinel")?(s=t?{kind:"probing"}:{kind:"error",message:"This share link is not valid."},n[1]=s):s=n[1];const[o,i]=b.useState(s);let a;n[2]===Symbol.for("react.memo_cache_sentinel")?(a=async()=>{i({kind:"probing"});const p=await Pj();i(p.status==="ok"?{kind:"ready",info:p.info}:p.status==="unauthenticated"?{kind:"login"}:{kind:"error",message:p.message})},n[2]=a):a=n[2];const l=a;let c,d;n[3]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{t&&l()},d=[l,t],n[3]=c,n[4]=d):(c=n[3],d=n[4]),b.useEffect(c,d);let f,u;if(n[5]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{const p=()=>{i(zM)};return window.addEventListener(zl,p),window.addEventListener("cogpit-auth-required",p),()=>{window.removeEventListener(zl,p),window.removeEventListener("cogpit-auth-required",p)}},u=[],n[5]=f,n[6]=u):(f=n[5],u=n[6]),b.useEffect(f,u),o.kind==="ready"){let p;return n[7]!==o.info?(p=r.jsx(DM,{info:o.info}),n[7]=o.info,n[8]=p):p=n[8],p}if(o.kind==="login"&&t){let p;return n[9]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(SM,{sessionId:t,onAuthenticated:()=>void l()}),n[9]=p):p=n[9],p}if(o.kind==="ended"){let p;return n[10]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(Tl,{children:r.jsx(Xt,{children:r.jsxs(tn,{children:[r.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:r.jsx(Zv,{className:"size-4"})}),r.jsx(nn,{children:"Sharing has ended"}),r.jsx(sn,{children:"The host stopped sharing this session or changed its passphrase. Ask for a new link to rejoin."})]})})}),n[10]=p):p=n[10],p}if(o.kind==="error"){let p,h;n[11]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(bn,{"aria-hidden":"true"}),h=r.jsx(Dt,{children:"Could not open this session"}),n[11]=p,n[12]=h):(p=n[11],h=n[12]);let g;n[13]!==o.message?(g=r.jsxs(Ct,{variant:"destructive",children:[p,h,r.jsx(_t,{children:o.message})]}),n[13]=o.message,n[14]=g):g=n[14];let x;n[15]===Symbol.for("react.memo_cache_sentinel")?(x=t&&r.jsx(X,{className:"mt-3 w-full",onClick:()=>void l(),children:"Try again"}),n[15]=x):x=n[15];let v;return n[16]!==g?(v=r.jsxs(Tl,{children:[g,x]}),n[16]=g,n[17]=v):v=n[17],v}let m;return n[18]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(Tl,{children:r.jsx(Xt,{children:r.jsxs(Jt,{className:"flex min-h-24 items-center justify-center gap-2",role:"status","aria-label":"Opening shared session",children:[r.jsx(Wn,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),r.jsx(Ut,{className:"size-5 text-muted-foreground"})]})})}),n[18]=m):m=n[18],m}function zM(n){return n.kind==="ready"?{kind:"ended"}:n}class FM extends b.Component{constructor(){super(...arguments);Wr(this,"state",{error:null})}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,s){console.error("[Cogpit] Unhandled render error",t,s.componentStack)}render(){if(!this.state.error)return this.props.children;const t=this.state.error.message||"An unexpected render error occurred.";return r.jsx("main",{className:"flex h-dvh items-center justify-center bg-background p-6 text-foreground",children:r.jsxs(Xt,{className:"w-full max-w-lg text-center",children:[r.jsxs(tn,{className:"justify-items-center",children:[r.jsx(wn,{"aria-hidden":"true",className:"mb-2 size-8 text-destructive"}),r.jsx(nn,{children:r.jsx("h1",{children:"Cogpit hit a render error"})}),r.jsx(sn,{children:"Reload the app to recover. Your sessions and project files are unchanged."})]}),r.jsx(Jt,{children:r.jsx("pre",{className:"max-h-40 w-full overflow-auto rounded-md bg-muted p-3 text-left font-mono text-xs whitespace-pre-wrap",children:t})}),r.jsx(So,{className:"justify-center",children:r.jsxs(X,{onClick:()=>window.location.reload(),children:[r.jsx(Qt,{"data-icon":"inline-start"}),"Reload Cogpit"]})})]})})}}const v2=document.getElementById("root");if(!v2)throw new Error("Root element not found");J2.createRoot(v2).render(r.jsx(b.StrictMode,{children:r.jsx(FM,{children:oa(window.location.pathname)?r.jsx(LM,{}):r.jsx(wM,{})})}));export{Oc as $,Ct as A,X as B,XM as C,Gn as D,Hn as E,R6 as F,qn as G,Vn as H,yn as I,Yh as J,ja as K,qM as L,ea as M,Vh as N,Gh as O,qh as P,yt as Q,py as R,s3 as S,vn as T,G as U,Me as V,jr as W,kt as X,an as Y,Nt as Z,$c as _,o3 as a,na as a$,Dc as a0,MS as a1,zc as a2,Fc as a3,Lc as a4,Uc as a5,Bc as a6,Cs as a7,ka as a8,wo as a9,kg as aA,br as aB,aI as aC,xt as aD,fo as aE,l8 as aF,FS as aG,Ot as aH,bg as aI,GM as aJ,ya as aK,tn as aL,nn as aM,Jt as aN,So as aO,Xt as aP,ma as aQ,D1 as aR,Bs as aS,$n as aT,ho as aU,Tn as aV,Dt as aW,sn as aX,vg as aY,Mc as aZ,$A as a_,gt as aa,Cr as ab,us as ac,Cx as ad,_x as ae,Lt as af,_j as ag,cr as ah,Ut as ai,b6 as aj,Zl as ak,bd as al,ra as am,Kh as an,_r as ao,Eg as ap,qc as aq,pl as ar,Y7 as as,U3 as at,YM as au,Ic as av,$s as aw,ut as ax,Kc as ay,Sg as az,r3 as b,cy as b0,VM as b1,Et as b2,Pt as b3,At as b4,ga as b5,xa as b6,ba as b7,ao as b8,ZM as b9,Yt as ba,lr as bb,PS as bc,is as bd,Dw as be,QM as bf,ud as bg,ax as bh,md as bi,rx as bj,Zi as bk,px as bl,RP as bm,k0 as bn,ha as bo,xs as bp,yC as bq,n3 as c,Jw as d,eI as e,G7 as f,tI as g,Yn as h,Ss as i,Xn as j,Jn as k,It as l,Zn as m,es as n,oI as o,_t as p,Nr as q,sI as r,rI as s,iI as t,nI as u,$0 as v,ye as w,JM as x,Kn as y,js as z};
|