cogpit 2.6.0 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1 -1
- package/dist/web/assets/{CommandPaletteHost-DfaMCzBW.js → CommandPaletteHost-DLho8Ydr.js} +1 -1
- package/dist/web/assets/{ConfigBrowser-CYyPu1XZ.js → ConfigBrowser-DcRITnFh.js} +1 -1
- package/dist/web/assets/{HighlightedEditor-D0E4fNIR.js → HighlightedEditor-DIp1oA0P.js} +1 -1
- package/dist/web/assets/{KeyboardShortcutsDialog-Cmk72Wcu.js → KeyboardShortcutsDialog-BbU77pdm.js} +1 -1
- package/dist/web/assets/{MobileFileChanges-B5e6WRrN.js → MobileFileChanges-GkG76Ztq.js} +1 -1
- package/dist/web/assets/{PreviewPanel-L5TxNJuc.js → PreviewPanel-B8DbD395.js} +1 -1
- package/dist/web/assets/{ProjectFilesPanel-9mVexNJQ.js → ProjectFilesPanel-nG1bZOL7.js} +1 -1
- package/dist/web/assets/{ProjectSwitcherModal-D37bS3Y8.js → ProjectSwitcherModal-HW-WAt1o.js} +1 -1
- package/dist/web/assets/{TerminalOutput-qo7CUaKh.js → TerminalOutput-Cpqldw8o.js} +1 -1
- package/dist/web/assets/{ThemeSelectorModal-DeKpqiLO.js → ThemeSelectorModal-BZ9ceBWr.js} +1 -1
- package/dist/web/assets/{WorkflowsPanel-Dvy1NPzW.js → WorkflowsPanel-DOOg6Hqp.js} +1 -1
- package/dist/web/assets/{WorktreePanel-DJdlsguj.js → WorktreePanel-JHMvhzQu.js} +1 -1
- package/dist/web/assets/index-9nniVy_T.js +157 -0
- package/dist/web/assets/index-BDtY-qce.css +1 -0
- package/dist/web/assets/{index-vzYZixNy.js → index-BhAAK3QZ.js} +1 -1
- package/dist/web/assets/{index-CyRmDc3P.js → index-D2-ty4Xm.js} +1 -1
- package/dist/web/assets/{index-aYw7Kb2u.js → index-De7cnbso.js} +1 -1
- package/dist/web/assets/{index-C1O8__7w.js → index-L4keTj_3.js} +1 -1
- package/dist/web/assets/vendor-ui-CKSkT7i9.js +912 -0
- package/dist/web/index.html +3 -3
- package/package.json +1 -1
- package/dist/web/assets/index-BnTYSkBh.css +0 -1
- package/dist/web/assets/index-CdXCbj1g.js +0 -157
- package/dist/web/assets/vendor-ui-CevbH8m5.js +0 -907
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalOutput-Cpqldw8o.js","assets/vendor-react-gGw_S5I_.js","assets/vendor-ui-CKSkT7i9.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-DLho8Ydr.js","assets/index-D2-ty4Xm.js","assets/KeyboardShortcutsDialog-BbU77pdm.js","assets/ProjectSwitcherModal-HW-WAt1o.js","assets/ThemeSelectorModal-BZ9ceBWr.js","assets/ProjectFilesPanel-nG1bZOL7.js","assets/HighlightedEditor-DIp1oA0P.js","assets/WorktreePanel-JHMvhzQu.js","assets/index-BhAAK3QZ.js","assets/index-De7cnbso.js","assets/ConfigBrowser-DcRITnFh.js","assets/PreviewPanel-B8DbD395.js","assets/MobileFileChanges-GkG76Ztq.js","assets/index-L4keTj_3.js","assets/WorkflowsPanel-DOOg6Hqp.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var by=Object.defineProperty;var vy=(n,e,t)=>e in n?by(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Si=(n,e,t)=>vy(n,typeof e!="symbol"?e+"":e,t);import{c as B,j as r,d as ye,e as yy,r as y,a as wy,f as jy}from"./vendor-react-gGw_S5I_.js";import{aC as Sy,aD as Ny,aE as ky,aF as ns,ae as rt,aG as Cy,N as gn,aH as hd,at as Wn,aI as _y,aJ as Ty,aK as Ey,aL as Ay,aM as Py,aN as $y,a1 as it,aO as Ry,J as dt,aP as Iy,al as My,b as Pt,aQ as Oy,aR as w1,aS as Dy,aT as j1,D as Ca,a3 as No,aU as Zi,h as ea,aV as S1,G as zn,aW as gd,aX as Ly,aY as zy,aZ as Fy,a_ as By,a$ as Uy,b0 as Wy,b1 as Hy,b2 as qy,b3 as Ky,b4 as Vy,b5 as Gy,b6 as Yy,b7 as Xy,b8 as Ir,b9 as Jy,ba as xd,bb as bd,bc as vd,bd as N1,be as yd,bf as Mr,X as nt,bg as wd,bh as Qy,I as jd,af as ss,bi as Zy,bj as k1,bk as C1,bl as vo,bm as Es,bn as e3,bo as t3,bp as n3,bq as s3,br as hr,S as an,z as ko,bs as Vs,bt as _1,bu as o3,bv as r3,bw as T1,bx as E1,by as A1,bz as i3,bA as a3,bB as P1,bC as $1,bD as l3,bE as R1,bF as c3,bG as d3,bH as u3,ah as Or,bI as f3,_ as _a,o as ta,aa as ys,bJ as Sc,bK as m3,bL as p3,bM as h3,bN as g3,bO as x3,bP as b3,bQ as v3,bR as Sd,bS as y3,bT as Yt,A as xn,bU as w3,bV as j3,bW as S3,bX as N3,bY as k3,bZ as C3,b_ as Co,b$ as Dr,c0 as _3,j as Ta,c1 as T3,c2 as E3,c3 as A3,c4 as P3,c5 as $3,c6 as R3,c7 as I3,c8 as M3,c9 as O3,ca as D3,C as Xe,P as Fn,y as Gs,d as I1,cb as L3,cc as z3,cd as F3,ce as B3,F as _o,ai as Ys,cf as U3,cg as M1,W as Nd,f as Ea,a9 as Aa,ch as W3,ci as Pa,cj as Nc,ck as H3,R as kd,cl as q3,cm as K3,$ as Us,c as O1,cn as V3,t as $a,co as Cd,a0 as qi,cp as Lr,cq as D1,cr as G3,cs as Y3,ct as Ni,cu as Is,aj as um,k as zr,cv as X3,a4 as J3,cw as Q3,au as Z3,u as Ra,O as ew,V as _d,cx as tw,cy as nw,cz as sw,cA as ow,cB as rw,cC as iw,cD as aw,cE as L1,cF as lw,cG as cw,cH as Td,ar as dw,n as fm,cI as uw,cJ as mm,l as Ia,cK as fw,cL as Ed,i as Fr,B as z1,cM as mw,a5 as Ad,s as pw,cN as hw,cO as F1,q as B1,av as U1,w as gw,cP as xw,cQ as bw,cR as vw,cS as yw,cT as ww,cU as Zt,Q as W1,cV as jw,ao as pm,an as Sw,cW as Nw,cX as kw,cY as H1,cZ as Pd,c_ as Cw,c$ as _w,d0 as q1,d1 as Tw,d2 as kc,ay as Ew,d3 as Aw,d4 as K1,d5 as Pw,p as $w,d6 as Rw,d7 as Iw,ad as Mw,L as Ow,x as Dw,ap as Lw,d8 as zw,ac as Fw,d9 as Bw}from"./vendor-ui-CKSkT7i9.js";import{c as Uw,a as Ww}from"./vendor-shiki-DOn6sF-i.js";import{r as Ma,M as Hn}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 Hw="modulepreload",qw=function(n){return"/"+n},hm={},qe=function(e,t,s){let o=Promise.resolve();if(t&&t.length>0){let a=function(d){return Promise.all(d.map(u=>Promise.resolve(u).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),c=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));o=a(t.map(d=>{if(d=qw(d),d in hm)return;hm[d]=!0;const u=d.endsWith(".css"),f=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${f}`))return;const m=document.createElement("link");if(m.rel=u?"stylesheet":Hw,u||(m.as="script"),m.crossOrigin="",m.href=d,c&&m.setAttribute("nonce",c),document.head.appendChild(m),u)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)})},ws=["codex","copilot","claude"],Cc="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";function Kw(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 Vw(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 V1(n){return{lossy:!1,owns:e=>typeof e=="string"&&e.startsWith(n),encode:e=>Kw(n,e),decode:e=>Vw(n,e)}}function G1(n){const e=new RegExp(`(${Cc})\\.jsonl$`,"i").exec(n);return e?e[1]:null}const Y1={urlId:n=>n.replace(/\.jsonl$/,""),fileNameFromUrlId:n=>n.endsWith(".jsonl")?n:`${n}.jsonl`};function X1(n){return`'${n.replace(/'/g,"'\\''")}'`}function gr(n,e){return e?[n,e]:[]}function na(n,e){var t;return((t=e.exec(n))==null?void 0:t[1])??null}const sa="[0-9a-f-]{36}",J1="codex__",Q1="copilot__",Gw=new Set(["default","plan","acceptEdits","dontAsk","auto"]),Z1={kind:"claude",displayName:"Claude Code",binName:"claude",dirName:{lossy:!0,owns:n=>typeof n=="string"&&!n.startsWith(J1)&&!n.startsWith(Q1),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:G1,...Y1},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"]:[...Gw.has(n.mode)?["--permission-mode",n.mode]:[],...(n.allowedTools??[]).flatMap(e=>["--allowedTools",e]),...(n.disallowedTools??[]).flatMap(e=>["--disallowedTools",e])]:["--permission-mode","default"],model:n=>gr("--model",n),effort:n=>gr("--effort",n),fastTier:()=>[]},serviceTier:null,cli:{packageName:"@anthropic-ai/claude-code",homebrew:{name:"claude-code",cask:!1},wingetId:null,versionArgs:["--version"],selfUpdate:{args:["update"],matches:n=>n.endsWith("/.local/bin/claude")||n.endsWith("/.local/bin/claude.exe")||n.includes("/.local/share/claude/")},bundledBySdk:!0,homeDirName:".claude",homeEnvVar:null,installMarker:"projects",homeIsDiscoverable:!1,process:{by:"command",sessionIdFromCommand:n=>na(n,new RegExp(`--resume(?:=|\\s+)(${sa})`))??na(n,new RegExp(`--session-id(?:=|\\s+)(${sa})`))}},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",pluginManifestDir:".claude-plugin"},contextWindow:{defaultLimit:1e6,limits:[{match:"claude-haiku-4-5",limit:2e5},{match:"claude-haiku-4-1",limit:2e5},{match:"claude-sonnet-4-5",limit:2e5},{match:"claude-opus-4-5",limit:2e5},{match:"claude-opus-4-1",limit:2e5}],compactBuffer:33e3,extendedContext:{marker:"[1m]",limit:1e6}},capabilities:{worktrees:!0,mcp:!0,slashCommands:!0,workflows:!0,agentTeams:!0,subagentTranscripts:!0,nestedSubagents:!1,sharing:!0,goals:"transcript",undo:!0,redo:!0,nativeRewind:!1,fileCheckpoints:!0,reasoningEffort:!0,fastTier:!0,imageInput:!0,planMode:!0,midTurnSteering:!1,stopSession:!0,ultracode:!0,contextWindow:!0,externalProcesses:!1,accountSwitching:!0,modelFallbackNotices:!0,autoPermissionMode:"per-model",settingsApply:"live",turnLiveness:"transcript",tokenStreaming:!0,nativeFork:!1,namedSessions:!0}},gm={appServerValue:"priority",cliConfigValue:"fast"},Yw={kind:"codex",displayName:"Codex",binName:"codex",dirName:V1(J1),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:G1,...Y1},metadataFromHead:!1,resume:{command:(n,e)=>e?`codex -C ${X1(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=>gr("-m",n),effort:n=>n?["-c",`model_reasoning_effort=${JSON.stringify(n)}`]:[],fastTier:n=>n?["-c",`service_tier=${JSON.stringify(gm.cliConfigValue)}`,"--enable","fast_mode"]:[]},serviceTier:gm,cli:{packageName:"@openai/codex",homebrew:{name:"codex",cask:!1},wingetId:null,versionArgs:["--version"],selfUpdate:null,bundledBySdk:!1,homeDirName:".codex",homeEnvVar:"CODEX_HOME",installMarker:"",homeIsDiscoverable:!0,process:{by:"command",sessionIdFromCommand:n=>na(n,new RegExp(`codex(?:\\s+\\S+)*\\s+exec\\s+resume\\s+(${sa})`))}},config:{rootDirName:".codex",instructions:[{in:"scope",path:"AGENTS.md",scopes:["global","project"]}],settings:[{in:"root",path:"config.toml",scopes:["global","project"]}],skillsDir:"skills",agentsDir:"agents",commandsDir:"prompts",themesDir:null,pluginsDir:null,pluginManifestDir:null},contextWindow:{defaultLimit:272e3,limits:[],compactBuffer:0,extendedContext:null},capabilities:{worktrees:!1,mcp:!1,slashCommands:!1,workflows:!1,agentTeams:!1,subagentTranscripts:!0,nestedSubagents:!0,sharing:!1,goals:"thread-api",undo:!0,redo:!0,nativeRewind:!1,fileCheckpoints:!1,reasoningEffort:!0,fastTier:!0,imageInput:!0,planMode:!0,midTurnSteering:!0,stopSession:!1,ultracode:!1,contextWindow:!1,externalProcesses:!1,accountSwitching:!1,modelFallbackNotices:!1,autoPermissionMode:"never",settingsApply:"next-turn",turnLiveness:"runtime",tokenStreaming:!0,nativeFork:!1,namedSessions:!1}},Xw={kind:"copilot",displayName:"GitHub Copilot CLI",binName:"copilot",dirName:V1(Q1),sessionFile:{name:n=>`${n}/events.jsonl`,sessionId:n=>{const e=new RegExp(`^(${Cc})/events\\.jsonl$`,"i").exec(n);return e?e[1]:null},urlId:n=>{const e=new RegExp(`^(${Cc})/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 ${X1(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=>gr("--model",n),effort:n=>gr("--reasoning-effort",n),fastTier:()=>[]},serviceTier:null,cli:{packageName:"@github/copilot",homebrew:{name:"copilot-cli",cask:!0},wingetId:"GitHub.Copilot",versionArgs:["--version"],selfUpdate:{args:["update"],matches:n=>n.endsWith("/.local/bin/copilot")||n==="/usr/local/bin/copilot"},bundledBySdk:!1,homeDirName:".copilot",homeEnvVar:"COPILOT_HOME",installMarker:"session-state",homeIsDiscoverable:!0,process:{by:"executable",sessionIdFromCommand:n=>na(n,new RegExp(`--resume(?:=|\\s+)(${sa})`))}},config:{rootDirName:".copilot",instructions:[{in:"scope",path:"AGENTS.md",scopes:["global","project"]}],settings:[{in:"root",path:"config.json",scopes:["global"]}],skillsDir:"skills",agentsDir:null,commandsDir:null,themesDir:null,pluginsDir:null,pluginManifestDir:null},contextWindow:{defaultLimit:2e5,limits:[],compactBuffer:0,extendedContext:null},capabilities:{worktrees:!1,mcp:!1,slashCommands:!1,workflows:!1,agentTeams:!1,subagentTranscripts:!1,nestedSubagents:!1,sharing:!1,goals:!1,undo:!0,redo:!1,nativeRewind:!0,fileCheckpoints:!1,reasoningEffort:!1,fastTier:!1,imageInput:!1,planMode:!0,midTurnSteering:!0,stopSession:!0,ultracode:!1,contextWindow:!1,externalProcesses:!0,accountSwitching:!1,modelFallbackNotices:!1,autoPermissionMode:"always",settingsApply:"next-turn",turnLiveness:"runtime",tokenStreaming:!1,nativeFork:!0,namedSessions:!0}},xr=Object.freeze({claude:Z1,codex:Yw,copilot:Xw});function en(n){return xr[n]}function Oa(){return ws.map(n=>xr[n])}function Jw(n,e){const t=Oa().filter(n);if(t.length!==1)throw new Error(`Expected exactly one agent with ${e}, found ${t.length}`);return t[0]}function As(n){for(const e of ws)if(e!=="claude"&&xr[e].dirName.owns(n))return xr[e];return Z1}function $t(n){return As(n).kind}function Pl(n,e,t){const s=xr[n].dirName;return t&&s.lossy?t:s.encode(e)}const Xs=As(null).kind;var v1;const ki=((v1=Oa().find(n=>n.dirName.lossy))==null?void 0:v1.kind)??null;function To(n){return As(n).capabilities}function Gt(n){return en(n).capabilities}function Qw(n,e){return ws.find(t=>t===n)??e}function _c(n){for(const e of Oa()){const t=e.sessionFile.sessionId(n);if(t)return t}return n.replace(/\.jsonl$/,"")}function Zw(n,e){return As(n).sessionFile.urlId(e)}function ej(n,e){return As(n).sessionFile.fileNameFromUrlId(e)}function eg(n,e,t){return en(n).resume.command(e,t)}function tj(n,e){const t=en(n);return{command:t.binName,args:[...t.resume.args(e)]}}function xm(n){return n.replace(/\/+$/,"")||"/"}function nj(n,e,t){var o;const s=xm(e);return((o=n.find(i=>As(i.dirName).kind===t&&xm(i.path)===s))==null?void 0:o.dirName)??null}const sj=[{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"}],$d=[{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"}],tg=[...$d,{value:"ultra",label:"Ultra",description:"Maximum reasoning with automatic task delegation"}],Ci=$d.slice(0,4);var y1;const Zo=[{value:((y1=en("codex").serviceTier)==null?void 0:y1.appServerValue)??"priority",label:"Fast",description:"1.5× speed with increased usage"}],bm={isDefault:!0,defaultReasoningEffort:"medium",supportedReasoningEfforts:tg,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:Zo},oj=[{value:"",label:"Default",description:"Use Codex's recommended model (GPT-5.6 Sol)",resolvedModel:"gpt-5.6-sol",...bm},{value:"gpt-5.6-sol",label:"GPT-5.6 Sol",description:"Flagship model for the most ambitious work",...bm},{value:"gpt-5.6-terra",label:"GPT-5.6 Terra",description:"Balanced model for everyday work",defaultReasoningEffort:"medium",supportedReasoningEfforts:tg,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:Zo},{value:"gpt-5.6-luna",label:"GPT-5.6 Luna",description:"Fastest, most cost-efficient model",defaultReasoningEffort:"medium",supportedReasoningEfforts:$d,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:Zo},{value:"gpt-5.5",label:"GPT-5.5",description:"Frontier model for complex real-world work",defaultReasoningEffort:"medium",supportedReasoningEfforts:Ci,inputModalities:["text","image"],supportsPersonality:!0,serviceTiers:Zo},{value:"gpt-5.4",label:"GPT-5.4",description:"Strong model for everyday coding",defaultReasoningEffort:"medium",supportedReasoningEfforts:Ci,inputModalities:["text","image"],supportsPersonality:!0,serviceTiers:Zo},{value:"gpt-5.4-mini",label:"GPT-5.4 Mini",description:"Small, fast model for simpler tasks",defaultReasoningEffort:"medium",supportedReasoningEfforts:Ci,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:Ci,inputModalities:["text"],supportsPersonality:!0}],rj=[{value:"",label:"Default",supportsEffort:!1,inputModalities:["text"]},{value:"auto",label:"Auto",description:"Let Copilot choose the best available model",supportsEffort:!1,inputModalities:["text"]}],ij={claude:sj,codex:oj,copilot:rj};function aj(n){return ij[n]}function G(...n){return Sy(Ny(n))}const ng=new Map,Tc=new Set;function lj(n,e){!Array.isArray(e)||e.length===0||(ng.set(n,e),Tc.forEach(t=>t()))}function cj(n){return Tc.add(n),()=>Tc.delete(n)}const vm="high",dj=[{value:"low",label:"Light"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"xhigh",label:"Extra High"},{value:"max",label:"Max"}];function uj(n){return ng.get(n)??aj(n)}function Br(n,e){return e?n.find(t=>t.value===e):n.find(t=>t.value!==""&&t.isDefault)??n.find(t=>t.value==="")??n.find(t=>t.value!=="")}function sg(n,e,t){const s=Br(e,t),o=s==null?void 0:s.supportedReasoningEfforts;return o&&o.length>0?o:(s==null?void 0:s.supportsEffort)===!1||!Gt(n).reasoningEffort?[]:dj}function fj(n,e){var t,s;return(s=(t=Br(n,e))==null?void 0:t.serviceTiers)==null?void 0:s.find(o=>o.value==="fast"||o.value==="priority"||o.label.toLowerCase()==="fast")}function mj(n,e,t){var o;const s=(o=Br(e,t))==null?void 0:o.inputModalities;return s?s.includes("image"):Gt(n).imageInput}function pj(n,e,t){var o;const s=Gt(n).autoPermissionMode;return s==="always"?!0:s==="never"?!1:((o=Br(e,t))==null?void 0:o.supportsAutoMode)===!0}function hj(n,e){return Gt(n).ultracode?!(e??"").toLowerCase().startsWith("haiku"):!1}function gj(n,e,t,s){var l;const o=sg(n,e,s);if(o.length===0)return"";const i=c=>!!c&&o.some(d=>d.value===c);if(i(t))return t;const a=(l=Br(e,s))==null?void 0:l.defaultReasoningEffort;return i(a)?a:i(vm)?vm:o[0].value}function xj(n){return n.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").slice(0,40).replace(/-$/,"")}async function Ur(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 bj=ns("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 ee(n){const e=B.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(bj({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(ky,{"data-slot":"button",className:a,...s}),e[9]=s,e[10]=a,e[11]=l):l=e[11],l}function ln(n){const e=B.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 cn(n){const e=B.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 vj=ns("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 bn(n){const e=B.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(vj({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 dn(n){const e=B.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=B.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 og(n){const e=B.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 yj(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 wj=n=>{switch(n){case"success":return Nj;case"info":return Cj;case"warning":return kj;case"error":return _j;default:return null}},jj=Array(12).fill(0),Sj=({visible:n,className:e})=>ye.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":n},ye.createElement("div",{className:"sonner-spinner"},jj.map((t,s)=>ye.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${s}`})))),Nj=ye.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},ye.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"})),kj=ye.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},ye.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"})),Cj=ye.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},ye.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"})),_j=ye.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},ye.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"})),Tj=ye.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"},ye.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ye.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),Ej=()=>{const[n,e]=ye.useState(document.hidden);return ye.useEffect(()=>{const t=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[]),n};let Aj=1;const Pj=100,ym=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:Aj++};class $j{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-Pj;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=ym(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],ye.isValidElement(d))i=!1,this.create({id:s,type:"default",message:d});else if(Ij(d)&&!d.ok){i=!1;const f=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 f=="object"&&!ye.isValidElement(f)?f:{message:f};this.create({id:s,type:"error",description:m,...h})}else if(d instanceof Error){i=!1;const f=typeof t.error=="function"?await t.error(d):t.error,m=typeof t.description=="function"?await t.description(d):t.description,h=typeof f=="object"&&!ye.isValidElement(f)?f:{message:f};this.create({id:s,type:"error",description:m,...h})}else if(t.success!==void 0){i=!1;const f=typeof t.success=="function"?await t.success(d):t.success,m=typeof t.description=="function"?await t.description(d):t.description,h=typeof f=="object"&&!ye.isValidElement(f)?f:{message:f};this.create({id:s,type:"success",description:m,...h})}}).catch(async d=>{if(a=["reject",d],t.error!==void 0){i=!1;const u=typeof t.error=="function"?await t.error(d):t.error,f=typeof t.description=="function"?await t.description(d):t.description,p=typeof u=="object"&&!ye.isValidElement(u)?u:{message:u};this.create({id:s,type:"error",description:f,...p})}}).finally(()=>{i&&(this.dismiss(s),s=void 0),t.finally==null||t.finally.call(t)}),c=()=>new Promise((d,u)=>l.then(()=>a[0]==="reject"?u(a[1]):d(a[1])).catch(u));return typeof s!="string"&&typeof s!="number"?{unwrap:c}:Object.assign(s,{unwrap:c})},this.custom=(e,t)=>{const s=ym(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 Jt=new $j,Rj=(n,e)=>Jt.message(n,e),Ij=n=>n&&typeof n=="object"&&"ok"in n&&typeof n.ok=="boolean"&&"status"in n&&typeof n.status=="number",Mj=Rj,Oj=()=>Jt.toasts,Dj=()=>Jt.getActiveToasts(),Ms=Object.assign(Mj,{success:Jt.success,info:Jt.info,warning:Jt.warning,error:Jt.error,custom:Jt.custom,message:Jt.message,promise:Jt.promise,dismiss:Jt.dismiss,loading:Jt.loading},{getHistory:Oj,getToasts:Dj});yj("[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 _i(n){return n.label!==void 0}const Lj=3,zj="24px",Fj="16px",wm=4e3,Bj=356,Uj=14,Wj=45,Hj=200;function In(...n){return n.filter(Boolean).join(" ")}function qj(n){const[e,t]=n.split("-"),s=[];return e&&s.push(e),t&&s.push(t),s}const Kj=n=>{var e,t,s,o,i,a,l,c,d;const{invert:u,toast:f,unstyled:m,interacting:p,setHeights:h,visibleToasts:g,heights:x,index:b,toasts:w,expanded:v,removeToast:S,defaultRichColors:j,closeButton:k,style:C,cancelButtonStyle:N,actionButtonStyle:_,className:A="",descriptionClassName:P="",duration:T,position:E,gap:$,expandByDefault:I,classNames:R,icons:D,closeButtonAriaLabel:O="Close toast"}=n,[M,F]=ye.useState(null),[z,L]=ye.useState(null),[W,U]=ye.useState(!1),[H,K]=ye.useState(!1),[V,Y]=ye.useState(!1),[q,J]=ye.useState(!1),[Q,X]=ye.useState(!1),[Z,te]=ye.useState(0),[ne,oe]=ye.useState(0),re=ye.useRef(f.duration||T||wm),ae=ye.useRef(null),se=ye.useRef(null),de=b===0,le=b+1<=g,ce=f.type,me=ce??"default",ue=f.dismissible!==!1,ie=f.className||"",ge=f.descriptionClassName||"",pe=ye.useMemo(()=>x.findIndex(we=>we.toastId===f.id)||0,[x,f.id]),xe=ye.useMemo(()=>{var we;return(we=f.closeButton)!=null?we:k},[f.closeButton,k]),Ce=ye.useMemo(()=>f.duration||T||wm,[f.duration,T]),Te=ye.useRef(0),Ee=ye.useRef(0),$e=ye.useRef(0),Re=ye.useRef(null),[Fe,Le]=E.split("-"),Ie=ye.useMemo(()=>x.reduce((we,Me,fe)=>fe>=pe?we:we+Me.height,0),[x,pe]),_e=Ej(),je=ye.useMemo(()=>{var we;return(we=n.swipeDirections)!=null?we:qj(E)},[n.swipeDirections,E]),ze=f.invert||u,Ne=ce==="loading";Ee.current=ye.useMemo(()=>pe*$+Ie,[pe,Ie]),ye.useEffect(()=>{re.current=Ce},[Ce]),ye.useEffect(()=>{U(!0)},[]),ye.useEffect(()=>{const we=se.current;if(we){const Me=we.getBoundingClientRect().height;return oe(Me),h(fe=>[{toastId:f.id,height:Me,position:f.position},...fe]),()=>h(fe=>fe.filter(ve=>ve.toastId!==f.id))}},[h,f.id]),ye.useLayoutEffect(()=>{if(!W)return;const we=se.current,Me=we.style.height;we.style.height="auto";const fe=we.getBoundingClientRect().height;we.style.height=Me,oe(fe),h(ve=>ve.find(Ue=>Ue.toastId===f.id)?ve.map(Ue=>Ue.toastId===f.id?{...Ue,height:fe}:Ue):[{toastId:f.id,height:fe,position:f.position},...ve])},[W,f.title,f.description,h,f.id,f.jsx,f.action,f.cancel]);const Se=ye.useCallback(()=>{K(!0),te(Ee.current),h(we=>we.filter(Me=>Me.toastId!==f.id)),setTimeout(()=>{S(f)},Hj)},[f,S,h,Ee]);ye.useEffect(()=>{if(f.promise&&ce==="loading"||f.duration===1/0||f.type==="loading")return;let we;return v||p||_e?(()=>{if($e.current<Te.current){const ve=new Date().getTime()-Te.current;re.current=re.current-ve}$e.current=new Date().getTime()})():(()=>{re.current!==1/0&&(Te.current=new Date().getTime(),we=setTimeout(()=>{f.onAutoClose==null||f.onAutoClose.call(f,f),Se()},re.current))})(),()=>clearTimeout(we)},[v,p,f,ce,_e,Se]),ye.useEffect(()=>{f.delete&&(Se(),f.onDismiss==null||f.onDismiss.call(f,f))},[Se,f.delete]);function he(){var we;if(D!=null&&D.loading){var Me;return ye.createElement("div",{className:In(R==null?void 0:R.loader,f==null||(Me=f.classNames)==null?void 0:Me.loader,"sonner-loader"),"data-visible":ce==="loading"},D.loading)}return ye.createElement(Sj,{className:In(R==null?void 0:R.loader,f==null||(we=f.classNames)==null?void 0:we.loader),visible:ce==="loading"})}const De=f.icon||(D==null?void 0:D[ce])||wj(ce);var Be,We;return ye.createElement("li",{tabIndex:0,ref:se,className:In(A,ie,R==null?void 0:R.toast,f==null||(e=f.classNames)==null?void 0:e.toast,R==null?void 0:R[me],f==null||(t=f.classNames)==null?void 0:t[me]),"data-sonner-toast":"","data-rich-colors":(Be=f.richColors)!=null?Be:j,"data-styled":!(f.jsx||f.unstyled||m),"data-mounted":W,"data-promise":!!f.promise,"data-swiped":Q,"data-removed":H,"data-visible":le,"data-y-position":Fe,"data-x-position":Le,"data-index":b,"data-front":de,"data-swiping":V,"data-dismissible":ue,"data-type":ce,"data-invert":ze,"data-swipe-out":q,"data-swipe-direction":z,"data-expanded":!!(v||I&&W),"data-testid":f.testId,style:{"--index":b,"--toasts-before":b,"--z-index":w.length-b,"--offset":`${H?Z:Ee.current}px`,"--initial-height":I?"auto":`${ne}px`,...C,...f.style},onDragEnd:()=>{Y(!1),F(null),Re.current=null},onPointerDown:we=>{we.button!==2&&(Ne||!ue||(ae.current=new Date,te(Ee.current),we.target.setPointerCapture(we.pointerId),we.target.tagName!=="BUTTON"&&(Y(!0),Re.current={x:we.clientX,y:we.clientY})))},onPointerUp:()=>{var we,Me,fe;if(q||!ue)return;Re.current=null;const ve=Number(((we=se.current)==null?void 0:we.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Oe=Number(((Me=se.current)==null?void 0:Me.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Ue=new Date().getTime()-((fe=ae.current)==null?void 0:fe.getTime()),Ke=M==="x"?ve:Oe,Ze=Math.abs(Ke)/Ue;if((M==="x"?je.includes(ve>0?"right":"left"):je.includes(Oe>0?"bottom":"top"))&&(Math.abs(Ke)>=Wj||Ze>.11)){te(Ee.current),f.onDismiss==null||f.onDismiss.call(f,f),L(M==="x"?ve>0?"right":"left":Oe>0?"down":"up"),Se(),J(!0);return}else{var Ye,At;(Ye=se.current)==null||Ye.style.setProperty("--swipe-amount-x","0px"),(At=se.current)==null||At.style.setProperty("--swipe-amount-y","0px")}X(!1),Y(!1),F(null)},onPointerMove:we=>{var Me,fe,ve;if(!Re.current||!ue||((Me=window.getSelection())==null?void 0:Me.toString().length)>0)return;const Ue=we.clientY-Re.current.y,Ke=we.clientX-Re.current.x;!M&&(Math.abs(Ke)>1||Math.abs(Ue)>1)&&F(Math.abs(Ke)>Math.abs(Ue)?"x":"y");let Ze={x:0,y:0};const He=Ye=>1/(1.5+Math.abs(Ye)/20);if(M==="y"){if(je.includes("top")||je.includes("bottom"))if(je.includes("top")&&Ue<0||je.includes("bottom")&&Ue>0)Ze.y=Ue;else{const Ye=Ue*He(Ue);Ze.y=Math.abs(Ye)<Math.abs(Ue)?Ye:Ue}}else if(M==="x"&&(je.includes("left")||je.includes("right")))if(je.includes("left")&&Ke<0||je.includes("right")&&Ke>0)Ze.x=Ke;else{const Ye=Ke*He(Ke);Ze.x=Math.abs(Ye)<Math.abs(Ke)?Ye:Ke}(Math.abs(Ze.x)>0||Math.abs(Ze.y)>0)&&X(!0),(fe=se.current)==null||fe.style.setProperty("--swipe-amount-x",`${Ze.x}px`),(ve=se.current)==null||ve.style.setProperty("--swipe-amount-y",`${Ze.y}px`)}},xe&&!f.jsx&&ce!=="loading"?ye.createElement("button",{"aria-label":O,"data-disabled":Ne,"data-close-button":!0,onClick:Ne||!ue?()=>{}:()=>{Se(),f.onDismiss==null||f.onDismiss.call(f,f)},className:In(R==null?void 0:R.closeButton,f==null||(s=f.classNames)==null?void 0:s.closeButton)},(We=D==null?void 0:D.close)!=null?We:Tj):null,(ce||f.icon||f.promise)&&f.icon!==null&&((D==null?void 0:D[ce])!==null||f.icon)?ye.createElement("div",{"data-icon":"",className:In(R==null?void 0:R.icon,f==null||(o=f.classNames)==null?void 0:o.icon)},ce==="loading"?f.icon||he():f.promise?he():null,ce!=="loading"?De:null):null,ye.createElement("div",{"data-content":"",className:In(R==null?void 0:R.content,f==null||(i=f.classNames)==null?void 0:i.content)},ye.createElement("div",{"data-title":"",className:In(R==null?void 0:R.title,f==null||(a=f.classNames)==null?void 0:a.title)},f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title),f.description?ye.createElement("div",{"data-description":"",className:In(P,ge,R==null?void 0:R.description,f==null||(l=f.classNames)==null?void 0:l.description)},typeof f.description=="function"?f.description():f.description):null),ye.isValidElement(f.cancel)?f.cancel:f.cancel&&_i(f.cancel)?ye.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||N,onClick:we=>{_i(f.cancel)&&ue&&(f.cancel.onClick==null||f.cancel.onClick.call(f.cancel,we),Se())},className:In(R==null?void 0:R.cancelButton,f==null||(c=f.classNames)==null?void 0:c.cancelButton)},f.cancel.label):null,ye.isValidElement(f.action)?f.action:f.action&&_i(f.action)?ye.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||_,onClick:we=>{_i(f.action)&&(f.action.onClick==null||f.action.onClick.call(f.action,we),!we.defaultPrevented&&Se())},className:In(R==null?void 0:R.actionButton,f==null||(d=f.classNames)==null?void 0:d.actionButton)},f.action.label):null)};function jm(){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 Vj(n,e){const t={};return[n,e].forEach((s,o)=>{const i=o===1,a=i?"--mobile-offset":"--offset",l=i?Fj:zj;function c(d){["top","right","bottom","left"].forEach(u=>{t[`${a}-${u}`]=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 Gj=ye.forwardRef(function(e,t){const{id:s,invert:o,position:i="bottom-right",hotkey:a=["altKey","KeyT"],expand:l,closeButton:c,className:d,offset:u,mobileOffset:f,theme:m="light",richColors:p,duration:h,style:g,visibleToasts:x=Lj,toastOptions:b,dir:w=jm(),gap:v=Uj,icons:S,customAriaLabel:j,containerAriaLabel:k="Notifications"}=e,[C,N]=ye.useState([]),_=ye.useMemo(()=>s?C.filter(U=>U.toasterId===s):C.filter(U=>!U.toasterId),[C,s]),A=ye.useMemo(()=>Array.from(new Set([i].concat(_.filter(U=>U.position).map(U=>U.position)))),[_,i]),[P,T]=ye.useState([]),[E,$]=ye.useState(!1),[I,R]=ye.useState(!1),[D,O]=ye.useState(m!=="system"?m:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),M=ye.useRef(null),F=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),z=ye.useRef(null),L=ye.useRef(!1),W=ye.useCallback(U=>{N(H=>{var K;return(K=H.find(V=>V.id===U.id))!=null&&K.delete||Jt.dismiss(U.id),H.filter(({id:V})=>V!==U.id)})},[]);return ye.useEffect(()=>Jt.subscribe(U=>{if(U.dismiss){requestAnimationFrame(()=>{N(H=>H.map(K=>K.id===U.id?{...K,delete:!0}:K))});return}setTimeout(()=>{yy.flushSync(()=>{N(H=>{const K=H.findIndex(V=>V.id===U.id);return K!==-1?[...H.slice(0,K),{...H[K],...U},...H.slice(K+1)]:[U,...H]})})})}),[]),ye.useEffect(()=>{if(m!=="system"){O(m);return}if(m==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?O("dark"):O("light")),typeof window>"u")return;const U=window.matchMedia("(prefers-color-scheme: dark)");try{U.addEventListener("change",({matches:H})=>{O(H?"dark":"light")})}catch{U.addListener(({matches:K})=>{try{O(K?"dark":"light")}catch(V){console.error(V)}})}},[m]),ye.useEffect(()=>{C.length<=1&&$(!1)},[C]),ye.useEffect(()=>{const U=H=>{var K;if(a.length>0&&a.every(q=>H[q]||H.code===q)){var Y;$(!0),(Y=M.current)==null||Y.focus()}H.code==="Escape"&&(document.activeElement===M.current||(K=M.current)!=null&&K.contains(document.activeElement))&&$(!1)};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[a]),ye.useEffect(()=>{if(M.current)return()=>{z.current&&(z.current.focus({preventScroll:!0}),z.current=null,L.current=!1)}},[M.current]),ye.createElement("section",{ref:t,"aria-label":j??`${k} ${F}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0,"data-react-aria-top-layer":!0},A.map((U,H)=>{var K;const[V,Y]=U.split("-");return _.length?ye.createElement("ol",{key:U,dir:w==="auto"?jm():w,tabIndex:-1,ref:M,className:d,"data-sonner-toaster":!0,"data-sonner-theme":D,"data-y-position":V,"data-x-position":Y,style:{"--front-toast-height":`${((K=P[0])==null?void 0:K.height)||0}px`,"--width":`${Bj}px`,"--gap":`${v}px`,...g,...Vj(u,f)},onBlur:q=>{L.current&&!q.currentTarget.contains(q.relatedTarget)&&(L.current=!1,z.current&&(z.current.focus({preventScroll:!0}),z.current=null))},onFocus:q=>{q.target instanceof HTMLElement&&q.target.dataset.dismissible==="false"||L.current||(L.current=!0,z.current=q.relatedTarget)},onMouseEnter:()=>$(!0),onMouseMove:()=>$(!0),onMouseLeave:()=>{I||$(!1)},onDragEnd:()=>$(!1),onPointerDown:q=>{q.target instanceof HTMLElement&&q.target.dataset.dismissible==="false"||R(!0)},onPointerUp:()=>R(!1)},_.filter(q=>!q.position&&H===0||q.position===U).map((q,J)=>{var Q,X;return ye.createElement(Kj,{key:q.id,icons:S,index:J,toast:q,defaultRichColors:p,duration:(Q=b==null?void 0:b.duration)!=null?Q:h,className:b==null?void 0:b.className,descriptionClassName:b==null?void 0:b.descriptionClassName,invert:o,visibleToasts:x,closeButton:(X=b==null?void 0:b.closeButton)!=null?X:c,interacting:I,position:U,style:b==null?void 0:b.style,unstyled:b==null?void 0:b.unstyled,classNames:b==null?void 0:b.classNames,cancelButtonStyle:b==null?void 0:b.cancelButtonStyle,actionButtonStyle:b==null?void 0:b.actionButtonStyle,closeButtonAriaLabel:b==null?void 0:b.closeButtonAriaLabel,removeToast:W,toasts:_.filter(Z=>Z.position==q.position),heights:P.filter(Z=>Z.position==q.position),setHeights:T,expandByDefault:l,gap:v,expanded:E,swipeDirections:e.swipeDirections})})):null}))}),Yj=n=>{const e=B.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(Wn,{className:"size-4"}),info:r.jsx(hd,{className:"size-4"}),warning:r.jsx(gn,{className:"size-4"}),error:r.jsx(Cy,{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(Gj,{className:"toaster group",icons:s,style:o,...t}),e[4]=t,e[5]=i):i=e[5],i};function Xj(n){const e=B.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){Ms.dismiss("app-error");return}Ms.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]),y.useEffect(c,d);let u,f;e[4]!==i||e[5]!==o?(u=()=>{if(!o){Ms.dismiss("model-fallback");return}Ms.warning(o,{id:"model-fallback",duration:1/0,onDismiss:i})},f=[i,o],e[4]=i,e[5]=o,e[6]=u,e[7]=f):(u=e[6],f=e[7]),y.useEffect(u,f);let m,p;e[8]!==a?(m=()=>{if(!a){Ms.dismiss("session-connection");return}Ms.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]),y.useEffect(m,p);const h=l==="light"?"light":"dark";let g;return e[11]!==h?(g=r.jsx(Yj,{theme:h,position:"bottom-center",closeButton:!0,visibleToasts:3}),e[11]=h,e[12]=g):g=e[12],g}const Tt="local",rg="cogpit-last-path::",Ec=new Map;function vt(){var t;const n=typeof window<"u"?(t=window.location)==null?void 0:t.pathname:void 0;if(!n)return Tt;const e=/^\/d\/([^/]+)/.exec(n);return e?e[1]:Tt}function Ws(){return vt()!==Tt}function ig(){const n=vt();return n===Tt?"":`/hub/${n}`}function ag(n){const e=ig();return!e||n.startsWith("/api/hub/")||n.startsWith("/api/auth/")?n:n.startsWith("/api")||n.startsWith("/__pty")||n.startsWith("/__browser")?`${e}${n}`:n}let br=null;function lg(n){n!==br&&(br=n,window.dispatchEvent(new Event("cogpit-identity-changed")))}function js(){return br}function Ki(n){return n===Tt?0:Ec.get(n)??0}function Jj(n,e){if(n===Tt||!Number.isSafeInteger(e)||e<0)return!1;const t=Ec.get(n);return t!==void 0&&e<=t?!1:(Ec.set(n,e),window.dispatchEvent(new CustomEvent("cogpit-device-scope-changed",{detail:{deviceId:n,connectionRevision:e}})),!0)}function Nn(){const n=vt(),e=Ki(n);return e===0?n:`${n}@${e}`}function Vt(n){const e=vt(),t=Nn();return br!==null?`${n}::${t}::${br}`:e===Tt?n:`${n}::${t}`}function Ho(n,e){sessionStorage.setItem(`${rg}${n}`,e)}function Ss(n){const t=sessionStorage.getItem(`${rg}${n}`)??(n===Tt?"/":`/d/${n}/`);window.history.pushState(null,"",t),window.dispatchEvent(new Event("cogpit-device-changed"))}const Sm="cogpit-network-token",Qj=new Set(["localhost","127.0.0.1","::1","0:0:0:0:0:0:0:1"]);function Da(){const n=window.location.hostname.toLowerCase(),e=n.startsWith("[")&&n.endsWith("]")?n.slice(1,-1):n;return!Qj.has(e)}function La(){try{localStorage.removeItem(Sm),sessionStorage.removeItem(Sm)}catch{}}typeof window<"u"&&La();const Zj={edition:"personal",needsBootstrap:!1};let vr=null,yo=null;function cg(){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 yo=e.edition==="team"?"team":"personal",{edition:yo,needsBootstrap:yo==="team"&&e.needsBootstrap===!0}}).catch(()=>(vr=null,Zj))}function dg(){return vr??(vr=cg()),vr}function Nm(){return vr=cg(),vr}function ug(){return dg().then(n=>n.edition)}async function e4(){if(!Da()&&yo!=="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 t4(){try{await fetch("/api/auth/logout",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"X-Cogpit-Client":"1"}})}finally{La()}}function km(){return La(),window.dispatchEvent(new Event("cogpit-auth-required")),Promise.reject(new Error("Authentication required"))}function fg(n,e,t){t&&typeof n=="string"&&n.startsWith("/api")&&(n=ag(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(Da()||yo==="team")return km();if(yo===null)return ug().then(i=>i==="team"?km():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 be(n,e){return fg(n,e,!0)}function ms(n,e){return fg(n,e,!1)}function Wr(n){return ag(n)}const n4=300*1e3,s4=30*1e3;let Ac=0,qo=null;function o4(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 r4(){try{const n=await be("/api/models");if(!n.ok)throw new Error(`GET /api/models → ${n.status}`);const e=await n.json();for(const t of ws){const s=e==null?void 0:e[t];o4(s)&&lj(t,s)}Ac=Date.now()+n4}catch{Ac=Date.now()+s4}}function Rd(){return qo||(Date.now()<Ac?Promise.resolve():(qo=r4().finally(()=>{qo=null}),qo))}function i4(){const n=()=>{document.visibilityState==="visible"&&Rd()};return window.addEventListener("focus",n),document.addEventListener("visibilitychange",n),()=>{window.removeEventListener("focus",n),document.removeEventListener("visibilitychange",n)}}function a4(n){const e=B.c(3);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0],y.useEffect(l4,t);let s;return e[1]!==n?(s=()=>uj(n),e[1]=n,e[2]=s):s=e[2],y.useSyncExternalStore(cj,s)}function l4(){return Rd(),i4()}function mg(n,e){const t=B.c(26),s=a4(n);let o;t[0]!==n||t[1]!==e||t[2]!==s?(o=sg(n,s,e),t[0]=n,t[1]=e,t[2]=s,t[3]=o):o=t[3];let i;t[4]!==e||t[5]!==s?(i=fj(s,e),t[4]=e,t[5]=s,t[6]=i):i=t[6];let a;t[7]!==n||t[8]!==e||t[9]!==s?(a=mj(n,s,e),t[7]=n,t[8]=e,t[9]=s,t[10]=a):a=t[10];let l;t[11]!==n||t[12]!==e||t[13]!==s?(l=pj(n,s,e),t[11]=n,t[12]=e,t[13]=s,t[14]=l):l=t[14];let c;t[15]!==n||t[16]!==e||t[17]!==s?(c=u=>gj(n,s,u,e),t[15]=n,t[16]=e,t[17]=s,t[18]=c):c=t[18];let d;return t[19]!==s||t[20]!==o||t[21]!==i||t[22]!==a||t[23]!==l||t[24]!==c?(d={options:s,effortOptions:o,fastTier:i,imageInput:a,autoPermissionMode:l,normalizeEffort:c},t[19]=s,t[20]=o,t[21]=i,t[22]=a,t[23]=l,t[24]=c,t[25]=d):d=t[25],d}function Id(n){const e=B.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(_y,{"data-slot":"popover",...t}),e[2]=t,e[3]=s):s=e[3],s}function Md(n){const e=B.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(Ty,{"data-slot":"popover-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function c4(n){const e=B.c(22);let t,s,o,i,a,l,c,d;e[0]!==n?({align:i,alignOffset:a,side:l,sideOffset:c,collisionPadding:d,collisionAvoidance:s,className: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,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 u=i===void 0?"start":i,f=a===void 0?0:a,m=l===void 0?"bottom":l,p=c===void 0?6:c,h=d===void 0?8:d;let g;e[9]!==t?(g=G("z-50 max-h-(--available-height) origin-(--transform-origin) rounded-xl bg-popover text-popover-foreground shadow-lg ring-1 ring-foreground/10 outline-none duration-100 ease-out data-[side=bottom]:slide-in-from-top-1 data-[side=top]:slide-in-from-bottom-1 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",t),e[9]=t,e[10]=g):g=e[10];let x;e[11]!==o||e[12]!==g?(x=r.jsx(Ey,{"data-slot":"popover-content",className:g,...o}),e[11]=o,e[12]=g,e[13]=x):x=e[13];let b;return e[14]!==u||e[15]!==f||e[16]!==s||e[17]!==h||e[18]!==m||e[19]!==p||e[20]!==x?(b=r.jsx(Ay,{children:r.jsx(Py,{className:"isolate z-50 outline-none",align:u,alignOffset:f,side:m,sideOffset:p,collisionPadding:h,collisionAvoidance:s,children:x})}),e[14]=u,e[15]=f,e[16]=s,e[17]=h,e[18]=m,e[19]=p,e[20]=x,e[21]=b):b=e[21],b}const d4=new Set(["mcp","server","servers","api","app","the","and"]),u4=/^([\w-]+\.[a-z]{2,})\s+(.+)$/i;function pg(n){const e=u4.exec(n.trim());return e?{short:e[2],namespace:e[1]}:{short:n.trim()}}function f4(n){const{short:e}=pg(n),t=e.split(/[^a-z0-9]+/i).filter(i=>i&&!d4.has(i.toLowerCase())),s=t.length>0?t:[e];return(s.length>=2?s[0][0]+s[1][0]:s[0].slice(0,2)).toUpperCase()}function Od(n){return n?"bottom":"top"}function Dd(n){const e=B.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("max-w-72 data-popup-open:bg-accent data-popup-open:text-accent-foreground",s),e[4]=s,e[5]=i):i=e[5];let a;e[6]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(it,{"data-icon":"inline-end",className:"opacity-60"}),e[6]=a):a=e[6];let l;return e[7]!==t||e[8]!==o||e[9]!==i?(l=r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",className:i,...o,children:[t,a]}),e[7]=t,e[8]=o,e[9]=i,e[10]=l):l=e[10],l}function Ld(n){const e=B.c(13);let t,s,o,i;e[0]!==n?({side:o,align:i,className:t,...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=i===void 0?"start":i;let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l={side:"none",align:"shift",fallbackAxisSide:"none"},e[5]=l):l=e[5];let c;e[6]!==t?(c=G("flex flex-col overflow-hidden p-0",t),e[6]=t,e[7]=c):c=e[7];let d;return e[8]!==a||e[9]!==s||e[10]!==o||e[11]!==c?(d=r.jsx(c4,{side:o,align:a,collisionAvoidance:l,className:c,...s}),e[8]=a,e[9]=s,e[10]=o,e[11]=c,e[12]=d):d=e[12],d}function wo(n){const e=B.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-2 pb-1 pt-1.5 text-[11px] font-medium uppercase tracking-wide 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",{className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Pc(n){const e=B.c(16);let t,s,o,i,a;e[0]!==n?({value:a,onValueChange:i,className:o,children:s,...t}=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]!==i?(l=u=>i(u),e[6]=i,e[7]=l):l=e[7];let c;e[8]!==o?(c=G("flex flex-col gap-px",o),e[8]=o,e[9]=c):c=e[9];let d;return e[10]!==t||e[11]!==s||e[12]!==l||e[13]!==c||e[14]!==a?(d=r.jsx($y,{value:a,onValueChange:l,className:c,...t,children:s}),e[10]=t,e[11]=s,e[12]=l,e[13]=c,e[14]=a,e[15]=d):d=e[15],d}const m4="flex w-full cursor-pointer select-none items-center gap-2.5 rounded-lg px-2 py-1.5 text-left text-sm outline-none transition-colors duration-100 hover:bg-accent/70 focus-visible:ring-2 focus-visible:ring-ring/40";function zd(n){const e=B.c(16),{value:t,title:s,description:o,icon:i,disabled:a}=n;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=G(m4,"group/option data-checked:bg-accent data-checked:text-accent-foreground data-disabled:cursor-not-allowed data-disabled:opacity-40 data-disabled:hover:bg-transparent"),e[0]=l):l=e[0];let c;e[1]!==i?(c=i&&r.jsx(i,{className:"size-4 shrink-0 text-muted-foreground group-data-checked/option:text-foreground"}),e[1]=i,e[2]=c):c=e[2];let d;e[3]!==s?(d=r.jsx("span",{className:"truncate leading-5 group-data-checked/option:font-medium",children:s}),e[3]=s,e[4]=d):d=e[4];let u;e[5]!==o?(u=o&&r.jsx("span",{className:"truncate text-xs leading-4 text-muted-foreground",title:o,children:o}),e[5]=o,e[6]=u):u=e[6];let f;e[7]!==d||e[8]!==u?(f=r.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[d,u]}),e[7]=d,e[8]=u,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(Ry,{keepMounted:!0,className:"shrink-0 text-foreground opacity-0 transition-opacity duration-100 data-checked:opacity-100",children:r.jsx(dt,{className:"size-4"})}),e[10]=m):m=e[10];let p;return e[11]!==a||e[12]!==c||e[13]!==f||e[14]!==t?(p=r.jsxs(Iy,{value:t,disabled:a,className:l,children:[c,f,m]}),e[11]=a,e[12]=c,e[13]=f,e[14]=t,e[15]=p):p=e[15],p}const p4=8;function h4(n){const e=B.c(89),{servers:t,selected:s,onToggle:o,onSetSelection:i,onRefresh:a,loading:l,onAuth:c,isNewSession:d}=n,[u,f]=y.useState(""),m=y.useId();let p,h,g,x,b,w,v,S,j,k,C,N,_,A,P,T,E;if(e[0]!==u||e[1]!==d||e[2]!==m||e[3]!==l||e[4]!==c||e[5]!==a||e[6]!==i||e[7]!==o||e[8]!==s||e[9]!==t){const D=t.filter(b4),O=t.filter(x4);let M;e[27]!==s?(M=new Set(s),e[27]=s,e[28]=M):M=e[28];const F=M;let z;e[29]!==F?(z=le=>F.has(le.name),e[29]=F,e[30]=z):z=e[30];const L=D.filter(z).length,W=l&&t.length===0,U=W?"MCPs":`MCPs ${L}/${D.length}`,H=u.trim().toLowerCase(),K=le=>!H||le.name.toLowerCase().includes(H),V=D.filter(K),Y=O.filter(K);h=Id,v=!1,e[31]===Symbol.for("react.memo_cache_sentinel")?(S=le=>{le||f("")},e[31]=S):S=e[31];let q;e[32]!==U?(q=r.jsx(Dd,{"aria-label":U}),e[32]=U,e[33]=q):q=e[33];let J;e[34]===Symbol.for("react.memo_cache_sentinel")?(J=r.jsx(My,{"data-icon":"inline-start"}),e[34]=J):J=e[34];let Q;e[35]!==U?(Q=r.jsx("span",{className:"truncate",children:U}),e[35]=U,e[36]=Q):Q=e[36];let X;e[37]!==W?(X=W&&r.jsx(Pt,{className:"size-3 animate-spin","aria-hidden":!0}),e[37]=W,e[38]=X):X=e[38],e[39]!==q||e[40]!==Q||e[41]!==X?(j=r.jsxs(Md,{render:q,children:[J,Q,X]}),e[39]=q,e[40]=Q,e[41]=X,e[42]=j):j=e[42],p=Ld,e[43]!==d?(T=Od(d),e[43]=d,e[44]=T):T=e[44],E="MCP servers",x="w-[23rem]";const Z=D.length>0&&r.jsxs("span",{"aria-hidden":!0,className:"ml-1.5 font-normal normal-case tracking-normal",children:[L," on"]});let te;e[45]!==m||e[46]!==Z?(te=r.jsxs(wo,{id:m,className:"pt-1",children:["MCP servers",Z]}),e[45]=m,e[46]=Z,e[47]=te):te=e[47];const ne=i&&D.length>1&&r.jsxs(r.Fragment,{children:[r.jsx(Cm,{label:"Turn every server on",disabled:L===D.length,onClick:()=>i(D.map(g4)),children:"All"}),r.jsx(Cm,{label:"Turn every server off",disabled:L===0,onClick:()=>i([]),children:"None"})]}),oe=l&&"animate-spin";let re;e[48]!==oe?(re=G(oe),e[48]=oe,e[49]=re):re=e[49];let ae;e[50]!==re?(ae=r.jsx(Pt,{className:re}),e[50]=re,e[51]=ae):ae=e[51];let se;e[52]!==a||e[53]!==ae?(se=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:a,"aria-label":"Refresh status",title:"Refresh status",className:"text-muted-foreground",children:ae}),e[52]=a,e[53]=ae,e[54]=se):se=e[54];let de;e[55]!==ne||e[56]!==se?(de=r.jsxs("div",{className:"flex items-center gap-0.5",children:[ne,se]}),e[55]=ne,e[56]=se,e[57]=de):de=e[57],e[58]!==te||e[59]!==de?(b=r.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 px-1.5 pt-1.5",children:[te,de]}),e[58]=te,e[59]=de,e[60]=b):b=e[60],e[61]!==u||e[62]!==t.length?(w=t.length>p4&&r.jsx("div",{className:"shrink-0 px-1.5 pt-1",children:r.jsx("input",{type:"search",value:u,onChange:le=>f(le.target.value),placeholder:"Filter servers…","aria-label":"Filter servers",className:"h-7 w-full rounded-md bg-muted/60 px-2 text-xs text-foreground outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring/40 [&::-webkit-search-cancel-button]:hidden"})}),e[61]=u,e[62]=t.length,e[63]=w):w=e[63],g="group",k=m,C="flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto p-1.5",e[64]!==l||e[65]!==t.length?(N=t.length===0&&r.jsx("p",{className:"px-0.5 py-1 text-xs text-muted-foreground",children:l?"Loading…":"No MCP servers configured"}),e[64]=l,e[65]=t.length,e[66]=N):N=e[66],_=t.length>0&&V.length===0&&Y.length===0&&r.jsx("p",{className:"px-0.5 py-1 text-xs text-muted-foreground",children:"No servers match."}),A=V.length>0&&r.jsx("div",{className:"grid grid-cols-2 gap-1",children:V.map(le=>r.jsx(_m,{server:le,on:F.has(le.name),onClick:()=>o(le.name)},le.name))}),P=Y.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(wo,{className:"px-0.5 pt-2 text-warning/80",children:"Needs sign-in"}),r.jsx("div",{className:"grid grid-cols-2 gap-1",children:Y.map(le=>r.jsx(_m,{server:le,onClick:()=>c(le.name)},le.name))})]}),e[0]=u,e[1]=d,e[2]=m,e[3]=l,e[4]=c,e[5]=a,e[6]=i,e[7]=o,e[8]=s,e[9]=t,e[10]=p,e[11]=h,e[12]=g,e[13]=x,e[14]=b,e[15]=w,e[16]=v,e[17]=S,e[18]=j,e[19]=k,e[20]=C,e[21]=N,e[22]=_,e[23]=A,e[24]=P,e[25]=T,e[26]=E}else p=e[10],h=e[11],g=e[12],x=e[13],b=e[14],w=e[15],v=e[16],S=e[17],j=e[18],k=e[19],C=e[20],N=e[21],_=e[22],A=e[23],P=e[24],T=e[25],E=e[26];let $;e[67]!==g||e[68]!==k||e[69]!==C||e[70]!==N||e[71]!==_||e[72]!==A||e[73]!==P?($=r.jsxs("div",{role:g,"aria-labelledby":k,className:C,children:[N,_,A,P]}),e[67]=g,e[68]=k,e[69]=C,e[70]=N,e[71]=_,e[72]=A,e[73]=P,e[74]=$):$=e[74];let I;e[75]!==p||e[76]!==x||e[77]!==b||e[78]!==w||e[79]!==$||e[80]!==T||e[81]!==E?(I=r.jsxs(p,{side:T,"aria-label":E,className:x,children:[b,w,$]}),e[75]=p,e[76]=x,e[77]=b,e[78]=w,e[79]=$,e[80]=T,e[81]=E,e[82]=I):I=e[82];let R;return e[83]!==h||e[84]!==v||e[85]!==S||e[86]!==j||e[87]!==I?(R=r.jsxs(h,{modal:v,onOpenChange:S,children:[j,I]}),e[83]=h,e[84]=v,e[85]=S,e[86]=j,e[87]=I,e[88]=R):R=e[88],R}function g4(n){return n.name}function x4(n){return n.status!=="connected"}function b4(n){return n.status==="connected"}function Cm(n){const e=B.c(5),{label:t,disabled:s,onClick:o,children:i}=n;let a;return e[0]!==i||e[1]!==s||e[2]!==t||e[3]!==o?(a=r.jsx(ee,{type:"button",variant:"ghost",size:"xs","aria-label":t,title:t,disabled:s,onClick:o,className:"h-6 px-1.5 text-[11px] text-muted-foreground",children:i}),e[0]=i,e[1]=s,e[2]=t,e[3]=o,e[4]=a):a=e[4],a}function _m(n){const e=B.c(34),{server:t,on:s,onClick:o}=n;let i;e[0]!==t.name?(i=pg(t.name),e[0]=t.name,e[1]=i):i=e[1];const{short:a,namespace:l}=i,c=s===void 0,d=c?void 0:"checkbox",u=c?void 0:s,f=c?`${t.name}, needs sign-in`:t.name,m=c?`${t.name} · Sign in to connect`:t.name,p=c&&"bg-warning/5 ring-warning/25 hover:bg-warning/10",h=s===!0&&"bg-accent text-accent-foreground ring-foreground/10",g=s===!1&&"text-muted-foreground ring-transparent hover:bg-accent/60 hover:text-foreground";let x;e[2]!==p||e[3]!==h||e[4]!==g?(x=G("flex min-w-0 items-center gap-2 rounded-lg px-2 py-1.5 text-left text-sm outline-none ring-1 ring-inset transition-[background-color,box-shadow,color] duration-100 focus-visible:ring-2 focus-visible:ring-ring/40",p,h,g),e[2]=p,e[3]=h,e[4]=g,e[5]=x):x=e[5];const b=c&&"bg-warning/15 text-warning",w=s===!0&&"bg-primary text-primary-foreground",v=s===!1&&"bg-muted text-muted-foreground";let S;e[6]!==b||e[7]!==w||e[8]!==v?(S=G("flex size-6 shrink-0 items-center justify-center rounded-md text-[10px] font-semibold tracking-wide transition-colors duration-100",b,w,v),e[6]=b,e[7]=w,e[8]=v,e[9]=S):S=e[9];let j;e[10]!==t.name?(j=f4(t.name),e[10]=t.name,e[11]=j):j=e[11];let k;e[12]!==S||e[13]!==j?(k=r.jsx("span",{"aria-hidden":!0,className:S,children:j}),e[12]=S,e[13]=j,e[14]=k):k=e[14];let C;e[15]!==a?(C=r.jsx("span",{className:"truncate leading-4",children:a}),e[15]=a,e[16]=C):C=e[16];let N;e[17]!==l?(N=l&&r.jsx("span",{className:"truncate text-[10px] leading-3 text-muted-foreground",children:l}),e[17]=l,e[18]=N):N=e[18];let _;e[19]!==C||e[20]!==N?(_=r.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[C,N]}),e[19]=C,e[20]=N,e[21]=_):_=e[21];let A;e[22]!==c?(A=c&&r.jsx(Oy,{className:"size-3.5 shrink-0 text-warning","aria-hidden":!0}),e[22]=c,e[23]=A):A=e[23];let P;return e[24]!==o||e[25]!==k||e[26]!==_||e[27]!==A||e[28]!==d||e[29]!==u||e[30]!==f||e[31]!==m||e[32]!==x?(P=r.jsxs("button",{type:"button",role:d,"aria-checked":u,"aria-label":f,title:m,onClick:o,className:x,children:[k,_,A]}),e[24]=o,e[25]=k,e[26]=_,e[27]=A,e[28]=d,e[29]=u,e[30]=f,e[31]=m,e[32]=x,e[33]=P):P=e[33],P}const hg=ns("group/toggle inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap outline-none transition-[color,background-color,border-color,box-shadow,transform,scale] duration-100 ease-out hover:bg-muted hover:text-foreground active:scale-[0.96] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-pressed:bg-muted motion-reduce:transition-none motion-reduce:active:scale-100 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-muted"},size:{default:"h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",sm:"h-7 min-w-7 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2"}},defaultVariants:{variant:"default",size:"default"}});function v4(n){const e=B.c(12);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?"default":o,l=i===void 0?"default":i;let c;e[5]!==t||e[6]!==l||e[7]!==a?(c=G(hg({variant:a,size:l,className:t})),e[5]=t,e[6]=l,e[7]=a,e[8]=c):c=e[8];let d;return e[9]!==s||e[10]!==c?(d=r.jsx(w1,{"data-slot":"toggle",className:c,...s}),e[9]=s,e[10]=c,e[11]=d):d=e[11],d}const gg=y.createContext({size:"default",variant:"default",spacing:2,orientation:"horizontal"});function xg(n){const e=B.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,u=l===void 0?"horizontal":l;let f;e[8]!==d?(f={"--gap":d},e[8]=d,e[9]=f):f=e[9];const m=f;let p;e[10]!==s?(p=G("group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-[orientation=vertical]:flex-col data-[orientation=vertical]:items-stretch",s),e[10]=s,e[11]=p):p=e[11];let h;e[12]!==u||e[13]!==i||e[14]!==d||e[15]!==c?(h={variant:c,size:i,spacing:d,orientation:u},e[12]=u,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(gg.Provider,{value:h,children:t}),e[17]=t,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==u||e[21]!==o||e[22]!==i||e[23]!==d||e[24]!==m||e[25]!==p||e[26]!==g||e[27]!==c?(x=r.jsx(Dy,{"data-slot":"toggle-group","data-variant":c,"data-size":i,"data-spacing":d,"data-orientation":u,orientation:u,style:m,className:p,...o,children:g}),e[20]=u,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 bg(n){const e=B.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=y.useContext(gg),u=d.variant||l,f=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",hg({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]!==u||e[16]!==f||e[17]!==p?(h=r.jsx(w1,{"data-slot":"toggle-group-item","data-variant":u,"data-size":f,"data-spacing":m,className:p,...o,children:t}),e[12]=t,e[13]=d.spacing,e[14]=o,e[15]=u,e[16]=f,e[17]=p,e[18]=h):h=e[18],h}en("claude").contextWindow.compactBuffer;function y4(n,e){var a;const{defaultLimit:t,limits:s,extendedContext:o}=en(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 w4(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=y4(e,t),c=l-en(t).contextWindow.compactBuffer;return{used:a,limit:l,compactAt:c,percent:Math.min(100,a/c*100),percentAbsolute:Math.min(100,a/l*100)}}function pn(n){return Number.isFinite(n)?n<.01?`$${n.toFixed(4)}`:n<1?`$${n.toFixed(3)}`:`$${n.toFixed(2)}`:"—"}const j4=["fable","mythos","opus","sonnet","haiku"];function Tm(n){return n.charAt(0).toUpperCase()+n.slice(1)}function Js(n){if(!n)return"unknown";const e=n.toLowerCase(),t=/\[1m\]$/.test(e)?" 1M":"",s=e.replace(/\[[^\]]*\]$/,"");for(const o of j4){const i=s.match(new RegExp(`${o}(?:-(\\d+)(?:-(\\d{1,2}))?(?!\\d))?`));if(!i)continue;const a=i[1]?` ${i[1]}${i[2]?`.${i[2]}`:""}`:"";return`${Tm(o)}${a}${t}`}if(s.startsWith("gpt-")){const[o,...i]=s.slice(4).split("-"),a=i.map(Tm).join(" ");return`GPT-${o}${a?` ${a}`:""}${t}`}return n.length>20?n.slice(0,20)+"...":n}function ut(n){return n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}k`:String(n)}function Bn(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 S4(n){if(n<60)return`${n}s`;const e=Math.floor(n/60),t=n%60;return`${e}m ${t}s`}function vg(n){return n>=1e6?`${(n/1e6).toFixed(1)}MB`:n>=1e3?`${(n/1e3).toFixed(0)}KB`:`${n}B`}function Hr(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 Fd(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 Bd(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 kn(n,e){return n.length<=e?n:n.slice(0,e)+"..."}function _n(n){return As(n).dirName.decode(n)??n}function za(n,e=2){const t=n.replace(/\/+$/,"").split("/").filter(Boolean);return t.length<=e?n:t.slice(-e).join("/")}function Fa(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 es(n){return n.replace(/\/+$/,"").split("/").at(-1)??n}function Ns(n){const e=n.match(/^([^/]+)\/subagents\/agent-([^.]+)\.jsonl$/);return e?{parentSessionId:e[1],agentId:e[2],parentFileName:`${e[1]}.jsonl`}:null}function yg(n){for(let e=n.length-1;e>=0;e--){const t=n[e];if(t.type==="assistant")return w4(t.message.usage,t.message.model??"","claude")}return null}const wg={claude:No,codex:Ca,copilot:j1},Ud={claude:"Claude",codex:"Codex",copilot:"Copilot"},N4={claude:"Claude",codex:"Codex",copilot:"GitHub Copilot"},k4={claude:null,codex:"Codex",copilot:"Copilot"},C4={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"}},_4={claude:"var(--chart-1)",codex:"var(--chart-2)",copilot:"var(--chart-3)"},T4={claude:"Interrupt agent",codex:"Stop active turn",copilot:"Stop Copilot turn"},E4={claude:[{value:"default",label:"Ask",description:"Ask before sensitive actions"},{value:"plan",label:"Plan",description:"Read and plan without changing files"},{value:"acceptEdits",label:"Accept Edits",description:"Allow file edits; ask for other actions"},{value:"auto",label:"Auto",description:"Run autonomously with classifier safeguards"},{value:"dontAsk",label:"Don't Ask",description:"Deny actions that need approval"},{value:"bypassPermissions",label:"Full access",description:"Skip permission checks"}],codex:[{value:"default",label:"Workspace",description:"Write inside the project sandbox"},{value:"plan",label:"Read only",description:"Inspect and plan without writing"},{value:"bypassPermissions",label:"Full access",description:"No sandbox or approval checks"}],copilot:[{value:"default",label:"Ask",description:"Ask before running tools or changing files"},{value:"plan",label:"Plan",description:"Explore and plan without changing project files"},{value:"auto",label:"Autopilot",description:"Implement autonomously until the task is complete"},{value:"bypassPermissions",label:"Full access",description:"Allow tools, paths, and URLs without asking"}]};function A4(n){return E4[n]}function P4(n){return wg[n]}function Ba(n){return Ud[n]}function fB(n){return N4[n]}function $4(n){return k4[n]}function mB(n){return C4[n]}function R4(n){return T4[n]}function I4(n){return _4[n]}const Em=As(null).kind,jg=[Em,...ws.filter(n=>n!==Em)];function M4(n){return`This ${Ud[n]} session is controlled by another process. Cogpit can only view it.`}const $c=jg.map(n=>({value:n,label:Ud[n],Icon:wg[n]}));function O4(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 D4(n){var t;const e=(t=n.find(s=>s.value===""))==null?void 0:t.resolvedModel;return e?Wd(e,n):"Default"}function Wd(n,e){var t;return((t=O4(n,e))==null?void 0:t.label)??Js(n)}function L4(n){var ze;const e=B.c(107),{agentKind:t,onAgentKindChange:s,selectedModel:o,resolvedDefaultName:i,modelOptions:a,onModelChange:l,selectedEffort:c,effortOptions:d,onEffortChange:u,fastTier:f,fastModeEnabled:m,onFastModeEnabledChange:p,ultracodeEnabled:h,onUltracodeEnabledChange:g,isNewSession:x}=n,b=m===void 0?!1:m,w=h===void 0?!1:h;let v;e[0]!==t?(v=Gt(t),e[0]=t,e[1]=v):v=e[1];const S=v;let j;e[2]!==t?(j=$c.find(Ne=>Ne.value===t),e[2]=t,e[3]=j):j=e[3];const k=j,C=k==null?void 0:k.Icon,N=(k==null?void 0:k.label)??t;let _;e[4]!==a||e[5]!==i||e[6]!==o?(_=((ze=a.find(Ne=>Ne.value===o))==null?void 0:ze.label)??i,e[4]=a,e[5]=i,e[6]=o,e[7]=_):_=e[7];const A=_;let P;if(e[8]!==d||e[9]!==c){let Ne;e[11]!==c?(Ne=Se=>Se.value===c,e[11]=c,e[12]=Ne):Ne=e[12],P=d.find(Ne),e[8]=d,e[9]=c,e[10]=P}else P=e[10];const T=P,E=!s,$=S.reasoningEffort,I=S.fastTier,R=S.ultracode,D=!!f&&!!p,O=!!g,M=b&&D,F=w&&O,z=F?"Pinned by Ultracode":T==null?void 0:T.description,L=T==null?void 0:T.label;let W;e[13]!==A||e[14]!==N||e[15]!==L?(W=[N,A,L].filter(Boolean),e[13]=A,e[14]=N,e[15]=L,e[16]=W):W=e[16];const U=W.join(" · "),H=M?"Fast mode on":null,K=F?"Ultracode on":null;let V;e[17]!==K||e[18]!==H?(V=[H,K].filter(Boolean),e[17]=K,e[18]=H,e[19]=V):V=e[19];const Y=V.join(", "),q=y.useId(),J=y.useId(),Q=y.useId(),X=Y?`${U} (${Y})`:U,Z=Y?`${U} · ${Y}`:void 0;let te;e[20]!==X||e[21]!==Z?(te=r.jsx(Dd,{"aria-label":X,title:Z}),e[20]=X,e[21]=Z,e[22]=te):te=e[22];let ne;e[23]!==C?(ne=C&&r.jsx(C,{"data-icon":"inline-start"}),e[23]=C,e[24]=ne):ne=e[24];let oe;e[25]!==A?(oe=r.jsx("span",{className:"truncate",children:A}),e[25]=A,e[26]=oe):oe=e[26];let re;e[27]!==T?(re=T&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-muted-foreground/60","aria-hidden":!0,children:"·"}),r.jsx("span",{className:"shrink-0 text-muted-foreground",children:T.label})]}),e[27]=T,e[28]=re):re=e[28];let ae;e[29]!==oe||e[30]!==re?(ae=r.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[oe,re]}),e[29]=oe,e[30]=re,e[31]=ae):ae=e[31];let se;e[32]!==M?(se=M&&r.jsx(Zi,{className:"size-3 shrink-0 fill-current","aria-hidden":!0}),e[32]=M,e[33]=se):se=e[33];let de;e[34]!==F?(de=F&&r.jsx(ea,{className:"size-3 shrink-0 fill-current","aria-hidden":!0}),e[34]=F,e[35]=de):de=e[35];let le;e[36]!==te||e[37]!==ne||e[38]!==ae||e[39]!==se||e[40]!==de?(le=r.jsxs(Md,{render:te,children:[ne,ae,se,de]}),e[36]=te,e[37]=ne,e[38]=ae,e[39]=se,e[40]=de,e[41]=le):le=e[41];let ce;e[42]!==x?(ce=Od(x),e[42]=x,e[43]=ce):ce=e[43];let me;e[44]!==q?(me=r.jsx(wo,{id:q,children:"Provider"}),e[44]=q,e[45]=me):me=e[45];let ue;e[46]!==s?(ue=Ne=>s==null?void 0:s(Ne),e[46]=s,e[47]=ue):ue=e[47];let ie;e[48]!==t||e[49]!==E?(ie=$c.map(Ne=>r.jsx(zd,{value:Ne.value,title:Ne.label,icon:Ne.Icon,disabled:E&&Ne.value!==t},Ne.value)),e[48]=t,e[49]=E,e[50]=ie):ie=e[50];let ge;e[51]!==t||e[52]!==q||e[53]!==ue||e[54]!==ie?(ge=r.jsx(Pc,{value:t,onValueChange:ue,"aria-labelledby":q,children:ie}),e[51]=t,e[52]=q,e[53]=ue,e[54]=ie,e[55]=ge):ge=e[55];let pe;e[56]!==E?(pe=E&&r.jsx("p",{className:"mt-auto px-2 pb-1 pt-3 text-[11px] leading-4 text-muted-foreground",children:"Fixed for this session. Start a new one to switch."}),e[56]=E,e[57]=pe):pe=e[57];let xe;e[58]!==me||e[59]!==ge||e[60]!==pe?(xe=r.jsxs("div",{className:"flex flex-col border-r bg-muted/30 p-1.5",children:[me,ge,pe]}),e[58]=me,e[59]=ge,e[60]=pe,e[61]=xe):xe=e[61];let Ce;e[62]!==J?(Ce=r.jsx(wo,{id:J,children:"Model"}),e[62]=J,e[63]=Ce):Ce=e[63];let Te;e[64]!==D||e[65]!==M||e[66]!==(f==null?void 0:f.description)||e[67]!==A||e[68]!==p||e[69]!==g||e[70]!==I||e[71]!==R||e[72]!==O||e[73]!==F?(Te=(I||R)&&r.jsxs("div",{className:"flex items-center gap-1",children:[I&&r.jsx(Am,{label:"Fast mode",pressed:M,onPressedChange:Ne=>p==null?void 0:p(Ne),disabled:!D,title:D?`Fast mode · ${(f==null?void 0:f.description)??"Lower latency with increased usage"}`:`Fast mode isn't offered for ${A}`,children:r.jsx(Zi,{className:G(M&&"fill-current")})}),R&&r.jsxs(Am,{label:"Ultracode",pressed:F,onPressedChange:Ne=>g==null?void 0:g(Ne),disabled:!O,title:O?"Ultracode · Extra High effort with standing multi-agent orchestration":`Ultracode isn't available for ${A}`,children:[r.jsx(ea,{className:G(F&&"fill-current")}),"Ultracode"]})]}),e[64]=D,e[65]=M,e[66]=f==null?void 0:f.description,e[67]=A,e[68]=p,e[69]=g,e[70]=I,e[71]=R,e[72]=O,e[73]=F,e[74]=Te):Te=e[74];let Ee;e[75]!==Ce||e[76]!==Te?(Ee=r.jsxs("div",{className:"flex items-center justify-between gap-2 pr-0.5",children:[Ce,Te]}),e[75]=Ce,e[76]=Te,e[77]=Ee):Ee=e[77];let $e;e[78]!==a?($e=a.map(F4),e[78]=a,e[79]=$e):$e=e[79];let Re;e[80]!==J||e[81]!==l||e[82]!==o||e[83]!==$e?(Re=r.jsx(Pc,{value:o,onValueChange:l,"aria-labelledby":J,className:"max-h-56 min-h-0 flex-1 overflow-y-auto",children:$e}),e[80]=J,e[81]=l,e[82]=o,e[83]=$e,e[84]=Re):Re=e[84];let Fe;e[85]!==Ee||e[86]!==Re?(Fe=r.jsxs("div",{className:"flex min-h-0 flex-col p-1.5",children:[Ee,Re]}),e[85]=Ee,e[86]=Re,e[87]=Fe):Fe=e[87];let Le;e[88]!==xe||e[89]!==Fe?(Le=r.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-[10.5rem_minmax(0,1fr)] overflow-hidden",children:[xe,Fe]}),e[88]=xe,e[89]=Fe,e[90]=Le):Le=e[90];let Ie;e[91]!==z||e[92]!==Q||e[93]!==d||e[94]!==A||e[95]!==u||e[96]!==c||e[97]!==$||e[98]!==F?(Ie=$&&r.jsxs("div",{className:"shrink-0 border-t p-3 pt-2",children:[r.jsxs("div",{className:"mb-1.5 flex items-baseline justify-between gap-3",children:[r.jsx(wo,{id:Q,className:"p-0",children:"Reasoning effort"}),z&&r.jsx("span",{className:"truncate text-[11px] leading-4 text-muted-foreground",children:z})]}),d.length>0?r.jsx(xg,{value:[c],onValueChange:Ne=>{const[Se]=Ne;Se&&u(Se)},disabled:F,variant:"outline",size:"sm",spacing:0,"aria-labelledby":Q,className:"w-full",children:d.map(z4)}):r.jsxs("p",{className:"text-xs leading-5 text-muted-foreground",children:["Not adjustable for ",A,"."]})]}),e[91]=z,e[92]=Q,e[93]=d,e[94]=A,e[95]=u,e[96]=c,e[97]=$,e[98]=F,e[99]=Ie):Ie=e[99];let _e;e[100]!==ce||e[101]!==Le||e[102]!==Ie?(_e=r.jsxs(Ld,{side:ce,align:"end","aria-label":"Model settings",className:"w-[34rem] max-w-[calc(100vw-1.5rem)]",children:[Le,Ie]}),e[100]=ce,e[101]=Le,e[102]=Ie,e[103]=_e):_e=e[103];let je;return e[104]!==le||e[105]!==_e?(je=r.jsxs(Id,{modal:!1,onOpenChange:B4,children:[le,_e]}),e[104]=le,e[105]=_e,e[106]=je):je=e[106],je}function z4(n){return r.jsx(bg,{value:n.value,title:n.description,className:G("min-w-0 flex-1 px-1 text-xs","data-pressed:bg-primary data-pressed:text-primary-foreground data-pressed:hover:bg-primary/90"),children:r.jsx("span",{className:"truncate",children:n.label})},n.value)}function F4(n){return r.jsx(zd,{value:n.value,title:n.menuLabel??n.label,description:n.description},n.value)}function B4(n){n&&Rd()}function Am(n){const e=B.c(7),{label:t,pressed:s,onPressedChange:o,disabled:i,title:a,children:l}=n;let c;return e[0]!==l||e[1]!==i||e[2]!==t||e[3]!==o||e[4]!==s||e[5]!==a?(c=r.jsx(v4,{variant:"outline",size:"sm",pressed:s,onPressedChange:o,disabled:i,"aria-label":t,title:a,className:"h-6 gap-1 px-1.5 text-xs text-muted-foreground data-pressed:bg-primary data-pressed:text-primary-foreground data-pressed:hover:bg-primary/90 [&_svg:not([class*='size-'])]:size-3.5",children:l}),e[0]=l,e[1]=i,e[2]=t,e[3]=o,e[4]=s,e[5]=a,e[6]=c):c=e[6],c}function Sg(n,e){return A4(n).filter(t=>t.value!=="auto"||e)}function U4(n){const e=B.c(22),{agentKind:t,mode:s,onChange:o,autoAvailable:i,isNewSession:a}=n,l=i===void 0?!1:i,[c,d]=y.useState(!1),u=Sg(t,l),f=u.find(T=>T.value===s)??u[0],m=y.useId(),p=`Permissions: ${f.label}`;let h;e[0]!==p?(h=r.jsx(Dd,{"aria-label":p}),e[0]=p,e[1]=h):h=e[1];let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx(S1,{"data-icon":"inline-start"}),e[2]=g):g=e[2];const x=Ld;let b;e[3]!==a?(b=Od(a),e[3]=a,e[4]=b):b=e[4];const w="Permissions",v="w-80",S="p-1.5";let j;e[5]!==m?(j=r.jsx(wo,{id:m,children:"Permissions"}),e[5]=m,e[6]=j):j=e[6];const k=Pc;let C;e[7]!==o?(C=T=>{o(T),d(!1)},e[7]=o,e[8]=C):C=e[8];const N=u.map(W4);let _;e[9]!==k||e[10]!==m||e[11]!==s||e[12]!==C||e[13]!==N?(_=r.jsx(k,{value:s,onValueChange:C,"aria-labelledby":m,children:N}),e[9]=k,e[10]=m,e[11]=s,e[12]=C,e[13]=N,e[14]=_):_=e[14];let A;e[15]!==_||e[16]!==j?(A=r.jsxs("div",{className:S,children:[j,_]}),e[15]=_,e[16]=j,e[17]=A):A=e[17];let P;return e[18]!==x||e[19]!==A||e[20]!==b?(P=r.jsx(x,{side:b,"aria-label":w,className:v,children:A}),e[18]=x,e[19]=A,e[20]=b,e[21]=P):P=e[21],r.jsxs(Id,{modal:!1,open:c,onOpenChange:d,children:[r.jsxs(Md,{render:h,children:[g,r.jsx("span",{className:"truncate",children:f.label})]}),P]})}function W4(n){return r.jsx(zd,{value:n.value,title:n.label,description:n.description},n.value)}function H4(n){const e=B.c(54),{agentKind:t,onAgentKindChange:s,selectedModel:o,resolvedDefaultName:i,modelOptions:a,onModelChange:l,selectedEffort:c,effortOptions:d,onEffortChange:u,fastTier:f,fastModeEnabled:m,onFastModeEnabledChange:p,isNewSession:h,worktreeEnabled:g,onWorktreeEnabledChange:x,ultracodeEnabled:b,onUltracodeEnabledChange:w,autoModeAvailable:v,permissionMode:S,onPermissionModeChange:j,mcpServers:k,selectedMcpServers:C,onToggleMcpServer:N,onSetMcpServers:_,onRefreshMcpServers:A,mcpLoading:P,onMcpAuth:T,changeAndApply:E,trailingExtra:$}=n;let I;e[0]!==t?(I=Gt(t),e[0]=t,e[1]=I):I=e[1];const{worktrees:R}=I;let D;e[2]!==t||e[3]!==v||e[4]!==E||e[5]!==h||e[6]!==j||e[7]!==S?(D=j&&S&&r.jsx(U4,{agentKind:t,mode:S,onChange:H=>E(()=>j(H)),autoAvailable:v,isNewSession:h}),e[2]=t,e[3]=v,e[4]=E,e[5]=h,e[6]=j,e[7]=S,e[8]=D):D=e[8];let O;e[9]!==h||e[10]!==x||e[11]!==R||e[12]!==g?(O=R&&h&&x&&r.jsxs(ee,{type:"button",variant:g?"secondary":"ghost",size:"xs","aria-pressed":!!g,onClick:()=>x(!g),children:[r.jsx(zn,{"data-icon":"inline-start"}),"Worktree"]}),e[9]=h,e[10]=x,e[11]=R,e[12]=g,e[13]=O):O=e[13];let M;e[14]!==E||e[15]!==h||e[16]!==P||e[17]!==k||e[18]!==T||e[19]!==A||e[20]!==_||e[21]!==N||e[22]!==C?(M=N&&A&&T&&(P||k&&k.length>0)&&r.jsx(h4,{servers:k??[],selected:C??[],onToggle:H=>E(()=>N(H)),onSetSelection:_?H=>E(()=>_(H)):void 0,onRefresh:A,loading:P??!1,onAuth:T,isNewSession:h}),e[14]=E,e[15]=h,e[16]=P,e[17]=k,e[18]=T,e[19]=A,e[20]=_,e[21]=N,e[22]=C,e[23]=M):M=e[23];let F;e[24]!==D||e[25]!==O||e[26]!==M||e[27]!==$?(F=r.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:[D,O,M,$]}),e[24]=D,e[25]=O,e[26]=M,e[27]=$,e[28]=F):F=e[28];let z;e[29]!==E||e[30]!==p?(z=p?H=>E(()=>p(H)):void 0,e[29]=E,e[30]=p,e[31]=z):z=e[31];let L;e[32]!==E||e[33]!==w?(L=w?H=>E(()=>w(H)):void 0,e[32]=E,e[33]=w,e[34]=L):L=e[34];let W;e[35]!==t||e[36]!==d||e[37]!==m||e[38]!==f||e[39]!==h||e[40]!==a||e[41]!==s||e[42]!==u||e[43]!==l||e[44]!==i||e[45]!==c||e[46]!==o||e[47]!==z||e[48]!==L||e[49]!==b?(W=r.jsx(L4,{agentKind:t,onAgentKindChange:s,selectedModel:o,resolvedDefaultName:i,modelOptions:a,onModelChange:l,selectedEffort:c,effortOptions:d,onEffortChange:u,fastTier:f,fastModeEnabled:m,onFastModeEnabledChange:z,ultracodeEnabled:b,onUltracodeEnabledChange:L,isNewSession:h}),e[35]=t,e[36]=d,e[37]=m,e[38]=f,e[39]=h,e[40]=a,e[41]=s,e[42]=u,e[43]=l,e[44]=i,e[45]=c,e[46]=o,e[47]=z,e[48]=L,e[49]=b,e[50]=W):W=e[50];let U;return e[51]!==F||e[52]!==W?(U=r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1",role:"group","aria-label":"Session settings",children:[F,W]}),e[51]=F,e[52]=W,e[53]=U):U=e[53],U}function Nt(n){const e=B.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(gd,{"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 q4(n){const e=B.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 K4(n){const e=B.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 V4(n){const e=B.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 Mo(n){const e=B.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 G4=ns("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 jt(n){const e=B.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(G4({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 pB(n){const e=B.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 St(n){const e=B.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(q4,{"data-slot":"field-label",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Eo(n){const e=B.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 bs(n){var u;const e=B.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 f;e[5]!==o?(f=[...new Map(o.map(X4)).values()],e[5]=o,e[6]=f):f=e[6];const m=f;if((m==null?void 0:m.length)==1){a=(u=m[0])==null?void 0:u.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(Y4)}),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 Y4(n,e){return(n==null?void 0:n.message)&&r.jsx("li",{children:n.message},e)}function X4(n){return[n==null?void 0:n.message,n]}const Rc=zy;function J4(n){const e=B.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(Jy,{"data-slot":"select-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Ic(n){const e=B.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(By,{"data-slot":"select-value",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Mc(n){const e=B.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(Wy,{render:r.jsx(it,{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(Fy,{"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 Oc(n){const e=B.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 u=i===void 0?"bottom":i,f=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(Q4,{}),e[11]=x):x=e[11];let b;e[12]!==t?(b=r.jsx(Hy,{children:t}),e[12]=t,e[13]=b):b=e[13];let w;e[14]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(Z4,{}),e[14]=w):w=e[14];let v;e[15]!==o||e[16]!==g||e[17]!==b?(v=r.jsxs(Uy,{"data-slot":"select-content",className:g,...o,children:[x,b,w]}),e[15]=o,e[16]=g,e[17]=b,e[18]=v):v=e[18];let S;return e[19]!==m||e[20]!==h||e[21]!==p||e[22]!==u||e[23]!==f||e[24]!==v?(S=r.jsx(qy,{children:r.jsx(Ky,{side:u,sideOffset:f,align:m,alignOffset:p,alignItemWithTrigger:h,className:"isolate z-50",children:v})}),e[19]=m,e[20]=h,e[21]=p,e[22]=u,e[23]=f,e[24]=v,e[25]=S):S=e[25],S}function Dc(n){const e=B.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(Vy,{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(Gy,{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(Ly,{"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 Q4(n){const e=B.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(Ir,{}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.jsx(Yy,{"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 Z4(n){const e=B.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(it,{}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.jsx(Xy,{"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 e5(n){const e=B.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(N1,{"data-slot":"sheet",...t}),e[2]=t,e[3]=s):s=e[3],s}function t5(n){const e=B.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(Qy,{"data-slot":"sheet-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function n5(n){const e=B.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(Mr,{"data-slot":"sheet-close",...t}),e[2]=t,e[3]=s):s=e[3],s}function s5(n){const e=B.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(yd,{"data-slot":"sheet-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function o5(n){const e=B.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(wd,{"data-slot":"sheet-overlay",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function r5(n){const e=B.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(o5,{}),e[6]=d):d=e[6];let u;e[7]!==s?(u=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]=u):u=e[8];let f;e[9]!==c?(f=c&&r.jsxs(Mr,{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(nt,{"data-icon":"inline-start",className:"size-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]}),e[9]=c,e[10]=f):f=e[10];let m;return e[11]!==t||e[12]!==o||e[13]!==l||e[14]!==u||e[15]!==f?(m=r.jsxs(s5,{children:[d,r.jsxs(vd,{"data-slot":"sheet-content","data-side":l,className:u,...o,children:[t,f]})]}),e[11]=t,e[12]=o,e[13]=l,e[14]=u,e[15]=f,e[16]=m):m=e[16],m}function i5(n){const e=B.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 a5(n){const e=B.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(xd,{"data-slot":"sheet-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function l5(n){const e=B.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(bd,{"data-slot":"sheet-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function ir(n){const e=B.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(St,{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 u;return e[6]!==l||e[7]!==c||e[8]!==d?(u=r.jsxs(jt,{className:l,children:[c,d]}),e[6]=l,e[7]=c,e[8]=d,e[9]=u):u=e[9],u}function Ti(n){const e=B.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 u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Ic,{}),e[2]=u):u=e[2];let f;e[3]!==s||e[4]!==c?(f=r.jsx(Mc,{"aria-label":s,title:c,className:"h-10 w-full",children:u}),e[3]=s,e[4]=c,e[5]=f):f=e[5];let m;e[6]!==i?(m=i.map(c5),e[6]=i,e[7]=m):m=e[7];let p;e[8]!==m?(p=r.jsx(Oc,{children:r.jsx(J4,{children:m})}),e[8]=m,e[9]=p):p=e[9];let h;e[10]!==l||e[11]!==d||e[12]!==f||e[13]!==p||e[14]!==o?(h=r.jsxs(Rc,{value:o,onValueChange:d,disabled:l,children:[f,p]}),e[10]=l,e[11]=d,e[12]=f,e[13]=p,e[14]=o,e[15]=h):h=e[15];let g;return e[16]!==t||e[17]!==h?(g=r.jsx(ir,{label:t,children:h}),e[16]=t,e[17]=h,e[18]=g):g=e[18],g}function c5(n){return r.jsx(Dc,{value:n.value,children:n.menuLabel??n.label},n.value||"default")}function d5(n){const e=B.c(28),{agentKind:t,onAgentKindChange:s,selectedModel:o,onModelChange:i,modelOptions:a,selectedEffort:l,onEffortChange:c,effortOptions:d,ultracodeEnabled:u,fastTier:f,fastModeEnabled:m,onFastModeEnabledChange:p,permissionMode:h,permissionOptions:g,onPermissionModeChange:x,changeAndApply:b}=n;let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx("h3",{id:"mobile-model-controls",className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Model and behavior"}),e[0]=w):w=e[0];let v;e[1]!==t||e[2]!==s?(v=s&&r.jsx(Ti,{label:"Agent",ariaLabel:"Agent",value:t,options:$c,onChange:_=>s(_)}),e[1]=t,e[2]=s,e[3]=v):v=e[3];let S;e[4]!==a||e[5]!==i||e[6]!==o?(S=r.jsx(Ti,{label:"Model",ariaLabel:"Model",value:o,options:a,onChange:i}),e[4]=a,e[5]=i,e[6]=o,e[7]=S):S=e[7];let j;e[8]!==d||e[9]!==c||e[10]!==l||e[11]!==u?(j=d.length>0&&r.jsx(Ti,{label:"Reasoning",ariaLabel:"Reasoning effort",value:l,options:d,onChange:c,disabled:u,title:u?"Effort is pinned to XHigh while Ultracode is on":void 0}),e[8]=d,e[9]=c,e[10]=l,e[11]=u,e[12]=j):j=e[12];let k;e[13]!==b||e[14]!==m||e[15]!==f||e[16]!==p?(k=f&&p&&r.jsx(ir,{label:"Speed",children:r.jsxs(ee,{type:"button",variant:m?"secondary":"ghost","aria-pressed":!!m,onClick:()=>b(()=>p(!m)),title:f.description,className:"h-10 justify-start",children:[r.jsx(Zi,{"data-icon":"inline-start",className:G(m&&"fill-current")}),m?"Fast":"Standard"]})}),e[13]=b,e[14]=m,e[15]=f,e[16]=p,e[17]=k):k=e[17];let C;e[18]!==x||e[19]!==h||e[20]!==g?(C=x&&h&&r.jsx(Ti,{label:"Access",ariaLabel:"Access policy",value:h,options:g,onChange:_=>x(_)}),e[18]=x,e[19]=h,e[20]=g,e[21]=C):C=e[21];let N;return e[22]!==v||e[23]!==S||e[24]!==j||e[25]!==k||e[26]!==C?(N=r.jsxs("section",{"aria-labelledby":"mobile-model-controls",className:"flex flex-col gap-2",children:[w,r.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[v,S,j,k,C]})]}),e[22]=v,e[23]=S,e[24]=j,e[25]=k,e[26]=C,e[27]=N):N=e[27],N}function u5(n){const e=B.c(30),{agentKind:t,isNewSession:s,worktreeEnabled:o,onWorktreeEnabledChange:i,ultracodeEnabled:a,onUltracodeEnabledChange:l,mcpServers:c,selectedMcpServers:d,onToggleMcpServer:u,onRefreshMcpServers:f,mcpLoading:m,onMcpAuth:p,changeAndApply:h}=n;let g;e[0]!==t?(g=Gt(t),e[0]=t,e[1]=g):g=e[1];const{worktrees:x,ultracode:b}=g,w=!!(u&&f&&p&&(m||c&&c.length>0)),v=!!(x&&s&&i||b&&l||w);let S;e[2]!==d?(S=d??[],e[2]=d,e[3]=S):S=e[3];let j;e[4]!==S?(j=new Set(S),e[4]=S,e[5]=j):j=e[5];const k=j;if(!v)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 N;e[7]!==s||e[8]!==i||e[9]!==x||e[10]!==o?(N=x&&s&&i&&r.jsx(ir,{label:"Isolation",children:r.jsxs(ee,{type:"button",variant:o?"secondary":"ghost","aria-pressed":!!o,onClick:()=>i(!o),className:"h-10 justify-start",children:[r.jsx(zn,{"data-icon":"inline-start"}),"Worktree"]})}),e[7]=s,e[8]=i,e[9]=x,e[10]=o,e[11]=N):N=e[11];let _;e[12]!==h||e[13]!==l||e[14]!==b||e[15]!==a?(_=b&&l&&r.jsx(ir,{label:"Workflow",children:r.jsxs(ee,{type:"button",variant:a?"secondary":"ghost","aria-pressed":!!a,onClick:()=>h(()=>l(!a)),className:"h-10 justify-start",children:[r.jsx(Zi,{"data-icon":"inline-start",className:G(a&&"fill-current")}),"Ultracode"]})}),e[12]=h,e[13]=l,e[14]=b,e[15]=a,e[16]=_):_=e[16];let A;e[17]!==h||e[18]!==m||e[19]!==c||e[20]!==p||e[21]!==f||e[22]!==u||e[23]!==k||e[24]!==w?(A=w&&u&&f&&p&&r.jsx(ir,{label:"Connections",wide:!0,children:r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsxs(ee,{type:"button",variant:"ghost",onClick:f,className:"min-h-10 justify-start",children:[r.jsx(Pt,{"data-icon":"inline-start",className:G(m&&"animate-spin")}),"Refresh MCP status"]}),(c??[]).map(T=>{const E=k.has(T.name),$=T.status==="connected";return r.jsxs(ee,{type:"button",variant:"ghost","aria-pressed":$?E:void 0,onClick:()=>$?h(()=>u(T.name)):p(T.name),className:"min-h-10 justify-start text-left",children:[r.jsx("span",{className:G("size-2 shrink-0 rounded-full",$&&E?"bg-success":$?"bg-muted-foreground":"bg-warning")}),r.jsx("span",{className:"min-w-0 flex-1 truncate",children:T.name}),r.jsx("span",{className:"text-xs text-muted-foreground",children:$?E?"On":"Off":"Connect"})]},T.name)})]})}),e[17]=h,e[18]=m,e[19]=c,e[20]=p,e[21]=f,e[22]=u,e[23]=k,e[24]=w,e[25]=A):A=e[25];let P;return e[26]!==N||e[27]!==_||e[28]!==A?(P=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:[N,_,A]})]}),e[26]=N,e[27]=_,e[28]=A,e[29]=P):P=e[29],P}function f5(n){var ae,se;const e=B.c(74),{open:t,onOpenChange:s,agentKind:o,onAgentKindChange:i,selectedModel:a,resolvedDefaultName:l,catalogOptions:c,modelOptions:d,onModelChange:u,selectedEffort:f,effortOptions:m,onEffortChange:p,fastTier:h,fastModeEnabled:g,onFastModeEnabledChange:x,isNewSession:b,worktreeEnabled:w,onWorktreeEnabledChange:v,ultracodeEnabled:S,onUltracodeEnabledChange:j,autoModeAvailable:k,permissionMode:C,onPermissionModeChange:N,mcpServers:_,selectedMcpServers:A,onToggleMcpServer:P,onRefreshMcpServers:T,mcpLoading:E,onMcpAuth:$,mobileExtra:I,changeAndApply:R}=n;let D,O;e[0]!==o||e[1]!==k||e[2]!==C?(D=Sg(o,k),O=(ae=D.find(de=>de.value===C))==null?void 0:ae.label,e[0]=o,e[1]=k,e[2]=C,e[3]=D,e[4]=O):(D=e[3],O=e[4]);const M=O;let F;e[5]!==c||e[6]!==l||e[7]!==a?(F=a?Wd(a,c):l,e[5]=c,e[6]=l,e[7]=a,e[8]=F):F=e[8];let z;e[9]!==m||e[10]!==f?(z=(se=m.find(de=>de.value===f))==null?void 0:se.label,e[9]=m,e[10]=f,e[11]=z):z=e[11];let L;e[12]!==M||e[13]!==F||e[14]!==z?(L=[F,z,M].filter(Boolean),e[12]=M,e[13]=F,e[14]=z,e[15]=L):L=e[15];const W=L.join(" · ");let U;e[16]!==R||e[17]!==N?(U=de=>{N&&R(()=>N(de))},e[16]=R,e[17]=N,e[18]=U):U=e[18];const H=U;let K;e[19]===Symbol.for("react.memo_cache_sentinel")?(K=r.jsx(t5,{render:r.jsx(ee,{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(jd,{})}),e[19]=K):K=e[19];let V;e[20]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx(a5,{children:"Session controls"}),e[20]=V):V=e[20];let Y;e[21]!==W?(Y=r.jsx(l5,{className:"truncate text-xs",children:W}),e[21]=W,e[22]=Y):Y=e[22];let q;e[23]===Symbol.for("react.memo_cache_sentinel")?(q=r.jsx(n5,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"icon-lg",className:"absolute right-2 top-2","aria-label":"Close session controls"}),children:r.jsx(nt,{})}),e[23]=q):q=e[23];let J;e[24]!==Y?(J=r.jsxs(i5,{className:"gap-1 px-4 pb-3 pt-4",children:[V,Y,q]}),e[24]=Y,e[25]=J):J=e[25];let Q;e[26]!==o||e[27]!==R||e[28]!==H||e[29]!==m||e[30]!==g||e[31]!==h||e[32]!==d||e[33]!==i||e[34]!==p||e[35]!==x||e[36]!==u||e[37]!==C||e[38]!==D||e[39]!==f||e[40]!==a||e[41]!==S?(Q=r.jsx(d5,{agentKind:o,onAgentKindChange:i,selectedModel:a,onModelChange:u,modelOptions:d,selectedEffort:f,onEffortChange:p,effortOptions:m,ultracodeEnabled:S,fastTier:h,fastModeEnabled:g,onFastModeEnabledChange:x,permissionMode:C,permissionOptions:D,onPermissionModeChange:H,changeAndApply:R}),e[26]=o,e[27]=R,e[28]=H,e[29]=m,e[30]=g,e[31]=h,e[32]=d,e[33]=i,e[34]=p,e[35]=x,e[36]=u,e[37]=C,e[38]=D,e[39]=f,e[40]=a,e[41]=S,e[42]=Q):Q=e[42];let X;e[43]!==o||e[44]!==R||e[45]!==b||e[46]!==E||e[47]!==_||e[48]!==$||e[49]!==T||e[50]!==P||e[51]!==j||e[52]!==v||e[53]!==A||e[54]!==S||e[55]!==w?(X=r.jsx(u5,{agentKind:o,isNewSession:b,worktreeEnabled:w,onWorktreeEnabledChange:v,ultracodeEnabled:S,onUltracodeEnabledChange:j,mcpServers:_,selectedMcpServers:A,onToggleMcpServer:P,onRefreshMcpServers:T,mcpLoading:E,onMcpAuth:$,changeAndApply:R}),e[43]=o,e[44]=R,e[45]=b,e[46]=E,e[47]=_,e[48]=$,e[49]=T,e[50]=P,e[51]=j,e[52]=v,e[53]=A,e[54]=S,e[55]=w,e[56]=X):X=e[56];let Z;e[57]!==I?(Z=I&&r.jsxs("section",{"aria-labelledby":"mobile-goal-controls",className:"flex flex-col gap-2 pt-1",children:[r.jsx(Nt,{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[57]=I,e[58]=Z):Z=e[58];let te;e[59]!==o||e[60]!==b?(te=!b&&r.jsx("p",{className:"text-xs text-muted-foreground",children:Gt(o).settingsApply==="live"?"Changes apply live.":"Changes apply on the next turn."}),e[59]=o,e[60]=b,e[61]=te):te=e[61];let ne;e[62]!==Q||e[63]!==X||e[64]!==Z||e[65]!==te?(ne=r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-4 py-4",children:[Q,X,Z,te]}),e[62]=Q,e[63]=X,e[64]=Z,e[65]=te,e[66]=ne):ne=e[66];let oe;e[67]!==J||e[68]!==ne?(oe=r.jsxs(r5,{side:"bottom",className:"max-h-[82dvh] overflow-hidden rounded-t-2xl pb-[env(safe-area-inset-bottom)]",showCloseButton:!1,children:[J,ne]}),e[67]=J,e[68]=ne,e[69]=oe):oe=e[69];let re;return e[70]!==s||e[71]!==t||e[72]!==oe?(re=r.jsx(r.Fragment,{children:r.jsxs(e5,{open:t,onOpenChange:s,children:[K,oe]})}),e[70]=s,e[71]=t,e[72]=oe,e[73]=re):re=e[73],re}const m5=y.memo(function(e){const t=B.c(53),{agentKind:s,onAgentKindChange:o,selectedModel:i,onModelChange:a,selectedEffort:l,onEffortChange:c,fastModeEnabled:d,onFastModeEnabledChange:u,isNewSession:f,worktreeEnabled:m,onWorktreeEnabledChange:p,ultracodeEnabled:h,onUltracodeEnabledChange:g,onApplySettings:x,activeModelId:b,mcpServers:w,selectedMcpServers:v,onToggleMcpServer:S,onSetMcpServers:j,onRefreshMcpServers:k,mcpLoading:C,onMcpAuth:N,permissionMode:_,onPermissionModeChange:A,mobileExtra:P,trailingExtra:T,mobile:E}=e,$=s===void 0?Xs:s,I=E===void 0?!1:E,[R,D]=y.useState(!1);let O;t[0]!==f||t[1]!==x?(O=se=>{se(),!f&&x&&setTimeout(()=>x(),0)},t[0]=f,t[1]=x,t[2]=O):O=t[2];const M=O;let F;t[3]!==M||t[4]!==a?(F=se=>M(()=>a(se)),t[3]=M,t[4]=a,t[5]=F):F=t[5];const z=F;let L;t[6]!==M||t[7]!==c?(L=se=>M(()=>c(se)),t[6]=M,t[7]=c,t[8]=L):L=t[8];const W=L,{options:U,effortOptions:H,fastTier:K,autoPermissionMode:V,normalizeEffort:Y}=mg($,i),q=(b==null?void 0:b.toLowerCase().startsWith("gpt-"))??!1,Q=b&&($==="copilot"||q===($==="codex"))?b:void 0;let X,Z;t[9]!==U||t[10]!==Q?(X=Q?Wd(Q,U):D4(U),Z=U.map(se=>{const de=[se.description,se.availabilityMessage].filter(Boolean).join(" · ")||void 0;return se.value===""?{...se,description:de,label:X,menuLabel:se.label}:{...se,description:de}}),t[9]=U,t[10]=Q,t[11]=X,t[12]=Z):(X=t[11],Z=t[12]);const te=Z;let ne;t[13]!==Y||t[14]!==l?(ne=Y(l),t[13]=Y,t[14]=l,t[15]=ne):ne=t[15];let oe;t[16]!==$||t[17]!==V||t[18]!==M||t[19]!==H||t[20]!==d||t[21]!==K||t[22]!==W||t[23]!==z||t[24]!==f||t[25]!==C||t[26]!==w||t[27]!==te||t[28]!==o||t[29]!==u||t[30]!==N||t[31]!==A||t[32]!==k||t[33]!==j||t[34]!==S||t[35]!==g||t[36]!==p||t[37]!==_||t[38]!==X||t[39]!==v||t[40]!==i||t[41]!==ne||t[42]!==h||t[43]!==m?(oe={agentKind:$,onAgentKindChange:o,selectedModel:i,resolvedDefaultName:X,modelOptions:te,onModelChange:z,selectedEffort:ne,effortOptions:H,onEffortChange:W,fastTier:K,fastModeEnabled:d,onFastModeEnabledChange:u,isNewSession:f,worktreeEnabled:m,onWorktreeEnabledChange:p,ultracodeEnabled:h,onUltracodeEnabledChange:g,autoModeAvailable:V,permissionMode:_,onPermissionModeChange:A,mcpServers:w,selectedMcpServers:v,onToggleMcpServer:S,onSetMcpServers:j,onRefreshMcpServers:k,mcpLoading:C,onMcpAuth:N,changeAndApply:M},t[16]=$,t[17]=V,t[18]=M,t[19]=H,t[20]=d,t[21]=K,t[22]=W,t[23]=z,t[24]=f,t[25]=C,t[26]=w,t[27]=te,t[28]=o,t[29]=u,t[30]=N,t[31]=A,t[32]=k,t[33]=j,t[34]=S,t[35]=g,t[36]=p,t[37]=_,t[38]=X,t[39]=v,t[40]=i,t[41]=ne,t[42]=h,t[43]=m,t[44]=oe):oe=t[44];const re=oe;if(I){let se;return t[45]!==U||t[46]!==re||t[47]!==P||t[48]!==R?(se=r.jsx(f5,{...re,open:R,onOpenChange:D,catalogOptions:U,mobileExtra:P}),t[45]=U,t[46]=re,t[47]=P,t[48]=R,t[49]=se):se=t[49],se}let ae;return t[50]!==re||t[51]!==T?(ae=r.jsx(H4,{...re,trailingExtra:T}),t[50]=re,t[51]=T,t[52]=ae):ae=t[52],ae});function Ng(n){return n.agentType==="team-lead"}function p5(n){return Ng(n)?void 0:n.color}const h5={blue:"bg-blue-500",green:"bg-green-500",yellow:"bg-yellow-500",purple:"bg-purple-500",orange:"bg-orange-500"};function g5(n){return n?h5[n]??"bg-zinc-400":"bg-zinc-400"}const x5=y.memo(function(e){const t=B.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(ss,{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 u;t[3]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Nt,{orientation:"vertical",className:"h-3.5"}),t[3]=u):u=t[3];let f;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,b=g.name===a,w=g5(p5(g));return r.jsxs(ee,{variant:"ghost",size:"xs",onClick:()=>l(g),disabled:b,className:G("whitespace-nowrap",x?"bg-accent text-accent-foreground":"text-muted-foreground"),children:[b?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}),Ng(g)&&r.jsx(Zy,{"data-icon":"inline-end",className:"text-warning"})]},g.agentId)},t[9]=i,t[10]=a,t[11]=l,t[12]=h):h=t[12],f=o.map(h),t[4]=i,t[5]=a,t[6]=o,t[7]=l,t[8]=f}else f=t[8];let m;t[13]!==f?(m=r.jsx("div",{className:"flex items-center gap-1",children:f}),t[13]=f,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,u,m]}),t[15]=d,t[16]=m,t[17]=p):p=t[17],p});function kg(n){const e=B.c(3),t=y.useRef(null),[s,o]=y.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]),y.useEffect(i,a),s}const Cg=y.createContext(null),_g=y.createContext(null);function Vi(n){const e=B.c(6),{value:t,chatValue:s,children:o}=n;let i;e[0]!==s||e[1]!==o?(i=r.jsx(_g.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(Cg.Provider,{value:t,children:i}),e[3]=i,e[4]=t,e[5]=a):a=e[5],a}function at(){const n=y.useContext(Cg);if(!n)throw new Error("useSessionContext must be used within a SessionProvider");return n}function qr(){const n=y.useContext(_g);if(!n)throw new Error("useSessionChatContext must be used within a SessionProvider");return n}const b5=ns("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 Pe(n){const e=B.c(13);let t,s,o,i,a;if(e[0]!==n){const{className:d,variant:u,render:f,...m}=n;t=f,a=u===void 0?"default":u,i=C1,s="span",o=k1({className:G(b5({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 Pm=1,v5=.9,y5=.8,w5=.17,$l=.1,Rl=.999,j5=.9999,S5=.99,N5=/[\\\/_+.#"@\[\(\{&]/,k5=/[\\\/_+.#"@\[\(\{&]/g,C5=/[\s-]/,Tg=/[\s-]/g;function Lc(n,e,t,s,o,i,a){if(i===e.length)return o===n.length?Pm:S5;var l=`${o},${i}`;if(a[l]!==void 0)return a[l];for(var c=s.charAt(i),d=t.indexOf(c,o),u=0,f,m,p,h;d>=0;)f=Lc(n,e,t,s,d+1,i+1,a),f>u&&(d===o?f*=Pm:N5.test(n.charAt(d-1))?(f*=y5,p=n.slice(o,d-1).match(k5),p&&o>0&&(f*=Math.pow(Rl,p.length))):C5.test(n.charAt(d-1))?(f*=v5,h=n.slice(o,d-1).match(Tg),h&&o>0&&(f*=Math.pow(Rl,h.length))):(f*=w5,o>0&&(f*=Math.pow(Rl,d-o))),n.charAt(d)!==e.charAt(i)&&(f*=j5)),(f<$l&&t.charAt(d-1)===s.charAt(i+1)||s.charAt(i+1)===s.charAt(i)&&t.charAt(d-1)!==s.charAt(i))&&(m=Lc(n,e,t,s,d+1,i+2,a),m*$l>f&&(f=m*$l)),f>u&&(u=f),d=t.indexOf(c,d+1);return a[l]=u,u}function $m(n){return n.toLowerCase().replace(Tg," ")}function _5(n,e,t){return n=t&&t.length>0?`${n+" "+t.join(" ")}`:n,Lc(n,e,$m(n),$m(e),0,0,{})}var Ko='[cmdk-group=""]',Il='[cmdk-group-items=""]',T5='[cmdk-group-heading=""]',Eg='[cmdk-item=""]',Rm=`${Eg}:not([aria-disabled="true"])`,zc="cmdk-item-select",fo="data-value",E5=(n,e,t)=>_5(n,e,t),Ag=y.createContext(void 0),Kr=()=>y.useContext(Ag),Pg=y.createContext(void 0),Hd=()=>y.useContext(Pg),$g=y.createContext(void 0),Rg=y.forwardRef((n,e)=>{let t=mo(()=>{var L,W;return{search:"",value:(W=(L=n.value)!=null?L:n.defaultValue)!=null?W:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),s=mo(()=>new Set),o=mo(()=>new Map),i=mo(()=>new Map),a=mo(()=>new Set),l=Ig(n),{label:c,children:d,value:u,onValueChange:f,filter:m,shouldFilter:p,loop:h,disablePointerSelection:g=!1,vimBindings:x=!0,...b}=n,w=vo(),v=vo(),S=vo(),j=y.useRef(null),k=F5();Hs(()=>{if(u!==void 0){let L=u.trim();t.current.value=L,C.emit()}},[u]),Hs(()=>{k(6,E)},[]);let C=y.useMemo(()=>({subscribe:L=>(a.current.add(L),()=>a.current.delete(L)),snapshot:()=>t.current,setState:(L,W,U)=>{var H,K,V,Y;if(!Object.is(t.current[L],W)){if(t.current[L]=W,L==="search")T(),A(),k(1,P);else if(L==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let q=document.getElementById(S);q?q.focus():(H=document.getElementById(w))==null||H.focus()}if(k(7,()=>{var q;t.current.selectedItemId=(q=$())==null?void 0:q.id,C.emit()}),U||k(5,E),((K=l.current)==null?void 0:K.value)!==void 0){let q=W??"";(Y=(V=l.current).onValueChange)==null||Y.call(V,q);return}}C.emit()}},emit:()=>{a.current.forEach(L=>L())}}),[]),N=y.useMemo(()=>({value:(L,W,U)=>{var H;W!==((H=i.current.get(L))==null?void 0:H.value)&&(i.current.set(L,{value:W,keywords:U}),t.current.filtered.items.set(L,_(W,U)),k(2,()=>{A(),C.emit()}))},item:(L,W)=>(s.current.add(L),W&&(o.current.has(W)?o.current.get(W).add(L):o.current.set(W,new Set([L]))),k(3,()=>{T(),A(),t.current.value||P(),C.emit()}),()=>{i.current.delete(L),s.current.delete(L),t.current.filtered.items.delete(L);let U=$();k(4,()=>{T(),(U==null?void 0:U.getAttribute("id"))===L&&P(),C.emit()})}),group:L=>(o.current.has(L)||o.current.set(L,new Set),()=>{i.current.delete(L),o.current.delete(L)}),filter:()=>l.current.shouldFilter,label:c||n["aria-label"],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:w,inputId:S,labelId:v,listInnerRef:j}),[]);function _(L,W){var U,H;let K=(H=(U=l.current)==null?void 0:U.filter)!=null?H:E5;return L?K(L,t.current.search,W):0}function A(){if(!t.current.search||l.current.shouldFilter===!1)return;let L=t.current.filtered.items,W=[];t.current.filtered.groups.forEach(H=>{let K=o.current.get(H),V=0;K.forEach(Y=>{let q=L.get(Y);V=Math.max(q,V)}),W.push([H,V])});let U=j.current;I().sort((H,K)=>{var V,Y;let q=H.getAttribute("id"),J=K.getAttribute("id");return((V=L.get(J))!=null?V:0)-((Y=L.get(q))!=null?Y:0)}).forEach(H=>{let K=H.closest(Il);K?K.appendChild(H.parentElement===K?H:H.closest(`${Il} > *`)):U.appendChild(H.parentElement===U?H:H.closest(`${Il} > *`))}),W.sort((H,K)=>K[1]-H[1]).forEach(H=>{var K;let V=(K=j.current)==null?void 0:K.querySelector(`${Ko}[${fo}="${encodeURIComponent(H[0])}"]`);V==null||V.parentElement.appendChild(V)})}function P(){let L=I().find(U=>U.getAttribute("aria-disabled")!=="true"),W=L==null?void 0:L.getAttribute(fo);C.setState("value",W||void 0)}function T(){var L,W,U,H;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=(W=(L=i.current.get(V))==null?void 0:L.value)!=null?W:"",q=(H=(U=i.current.get(V))==null?void 0:U.keywords)!=null?H:[],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 E(){var L,W,U;let H=$();H&&(((L=H.parentElement)==null?void 0:L.firstChild)===H&&((U=(W=H.closest(Ko))==null?void 0:W.querySelector(T5))==null||U.scrollIntoView({block:"nearest"})),H.scrollIntoView({block:"nearest"}))}function $(){var L;return(L=j.current)==null?void 0:L.querySelector(`${Eg}[aria-selected="true"]`)}function I(){var L;return Array.from(((L=j.current)==null?void 0:L.querySelectorAll(Rm))||[])}function R(L){let W=I()[L];W&&C.setState("value",W.getAttribute(fo))}function D(L){var W;let U=$(),H=I(),K=H.findIndex(Y=>Y===U),V=H[K+L];(W=l.current)!=null&&W.loop&&(V=K+L<0?H[H.length-1]:K+L===H.length?H[0]:H[K+L]),V&&C.setState("value",V.getAttribute(fo))}function O(L){let W=$(),U=W==null?void 0:W.closest(Ko),H;for(;U&&!H;)U=L>0?L5(U,Ko):z5(U,Ko),H=U==null?void 0:U.querySelector(Rm);H?C.setState("value",H.getAttribute(fo)):D(L)}let M=()=>R(I().length-1),F=L=>{L.preventDefault(),L.metaKey?M():L.altKey?O(1):D(1)},z=L=>{L.preventDefault(),L.metaKey?R(0):L.altKey?O(-1):D(-1)};return y.createElement(Es.div,{ref:e,tabIndex:-1,...b,"cmdk-root":"",onKeyDown:L=>{var W;(W=b.onKeyDown)==null||W.call(b,L);let U=L.nativeEvent.isComposing||L.keyCode===229;if(!(L.defaultPrevented||U))switch(L.key){case"n":case"j":{x&&L.ctrlKey&&F(L);break}case"ArrowDown":{F(L);break}case"p":case"k":{x&&L.ctrlKey&&z(L);break}case"ArrowUp":{z(L);break}case"Home":{L.preventDefault(),R(0);break}case"End":{L.preventDefault(),M();break}case"Enter":{L.preventDefault();let H=$();if(H){let K=new Event(zc);H.dispatchEvent(K)}}}}},y.createElement("label",{"cmdk-label":"",htmlFor:N.inputId,id:N.labelId,style:U5},c),Ua(n,L=>y.createElement(Pg.Provider,{value:C},y.createElement(Ag.Provider,{value:N},L))))}),A5=y.forwardRef((n,e)=>{var t,s;let o=vo(),i=y.useRef(null),a=y.useContext($g),l=Kr(),c=Ig(n),d=(s=(t=c.current)==null?void 0:t.forceMount)!=null?s:a==null?void 0:a.forceMount;Hs(()=>{if(!d)return l.item(o,a==null?void 0:a.id)},[d]);let u=Mg(o,i,[n.value,n.children,i],n.keywords),f=Hd(),m=ks(k=>k.value&&k.value===u.current),p=ks(k=>d||l.filter()===!1?!0:k.search?k.filtered.items.get(o)>0:!0);y.useEffect(()=>{let k=i.current;if(!(!k||n.disabled))return k.addEventListener(zc,h),()=>k.removeEventListener(zc,h)},[p,n.onSelect,n.disabled]);function h(){var k,C;g(),(C=(k=c.current).onSelect)==null||C.call(k,u.current)}function g(){f.setState("value",u.current,!0)}if(!p)return null;let{disabled:x,value:b,onSelect:w,forceMount:v,keywords:S,...j}=n;return y.createElement(Es.div,{ref:hr(i,e),...j,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)}),P5=y.forwardRef((n,e)=>{let{heading:t,children:s,forceMount:o,...i}=n,a=vo(),l=y.useRef(null),c=y.useRef(null),d=vo(),u=Kr(),f=ks(p=>o||u.filter()===!1?!0:p.search?p.filtered.groups.has(a):!0);Hs(()=>u.group(a),[]),Mg(a,l,[n.value,n.heading,c]);let m=y.useMemo(()=>({id:a,forceMount:o}),[o]);return y.createElement(Es.div,{ref:hr(l,e),...i,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},t&&y.createElement("div",{ref:c,"cmdk-group-heading":"","aria-hidden":!0,id:d},t),Ua(n,p=>y.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":t?d:void 0},y.createElement($g.Provider,{value:m},p))))}),$5=y.forwardRef((n,e)=>{let{alwaysRender:t,...s}=n,o=y.useRef(null),i=ks(a=>!a.search);return!t&&!i?null:y.createElement(Es.div,{ref:hr(o,e),...s,"cmdk-separator":"",role:"separator"})}),R5=y.forwardRef((n,e)=>{let{onValueChange:t,...s}=n,o=n.value!=null,i=Hd(),a=ks(d=>d.search),l=ks(d=>d.selectedItemId),c=Kr();return y.useEffect(()=>{n.value!=null&&i.setState("search",n.value)},[n.value]),y.createElement(Es.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)}})}),I5=y.forwardRef((n,e)=>{let{children:t,label:s="Suggestions",...o}=n,i=y.useRef(null),a=y.useRef(null),l=ks(d=>d.selectedItemId),c=Kr();return y.useEffect(()=>{if(a.current&&i.current){let d=a.current,u=i.current,f,m=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let p=d.offsetHeight;u.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return m.observe(d),()=>{cancelAnimationFrame(f),m.unobserve(d)}}},[]),y.createElement(Es.div,{ref:hr(i,e),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":s,id:c.listId},Ua(n,d=>y.createElement("div",{ref:hr(a,c.listInnerRef),"cmdk-list-sizer":""},d)))}),M5=y.forwardRef((n,e)=>{let{open:t,onOpenChange:s,overlayClassName:o,contentClassName:i,container:a,...l}=n;return y.createElement(e3,{open:t,onOpenChange:s},y.createElement(t3,{container:a},y.createElement(n3,{"cmdk-overlay":"",className:o}),y.createElement(s3,{"aria-label":n.label,"cmdk-dialog":"",className:i},y.createElement(Rg,{ref:e,...l}))))}),O5=y.forwardRef((n,e)=>ks(t=>t.filtered.count===0)?y.createElement(Es.div,{ref:e,...n,"cmdk-empty":"",role:"presentation"}):null),D5=y.forwardRef((n,e)=>{let{progress:t,children:s,label:o="Loading...",...i}=n;return y.createElement(Es.div,{ref:e,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Ua(n,a=>y.createElement("div",{"aria-hidden":!0},a)))}),Oo=Object.assign(Rg,{List:I5,Item:A5,Input:R5,Group:P5,Separator:$5,Dialog:M5,Empty:O5,Loading:D5});function L5(n,e){let t=n.nextElementSibling;for(;t;){if(t.matches(e))return t;t=t.nextElementSibling}}function z5(n,e){let t=n.previousElementSibling;for(;t;){if(t.matches(e))return t;t=t.previousElementSibling}}function Ig(n){let e=y.useRef(n);return Hs(()=>{e.current=n}),e}var Hs=typeof window>"u"?y.useEffect:y.useLayoutEffect;function mo(n){let e=y.useRef();return e.current===void 0&&(e.current=n()),e}function ks(n){let e=Hd(),t=()=>n(e.snapshot());return y.useSyncExternalStore(e.subscribe,t,t)}function Mg(n,e,t,s=[]){let o=y.useRef(),i=Kr();return Hs(()=>{var a;let l=(()=>{var d;for(let u of t){if(typeof u=="string")return u.trim();if(typeof u=="object"&&"current"in u)return u.current?(d=u.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(fo,l),o.current=l}),o}var F5=()=>{let[n,e]=y.useState(),t=mo(()=>new Map);return Hs(()=>{t.current.forEach(s=>s()),t.current=new Map},[n]),(s,o)=>{t.current.set(s,o),e({})}};function B5(n){let e=n.type;return typeof e=="function"?e(n.props):"render"in e?e.render(n.props):n}function Ua({asChild:n,children:e},t){return n&&y.isValidElement(e)?y.cloneElement(B5(e),{ref:e.ref},t(e.props.children)):t(e)}var U5={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function os(n){const e=B.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(N1,{"data-slot":"dialog",...t}),e[2]=t,e[3]=s):s=e[3],s}function W5(n){const e=B.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(yd,{"data-slot":"dialog-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function hB(n){const e=B.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(Mr,{"data-slot":"dialog-close",...t}),e[2]=t,e[3]=s):s=e[3],s}function H5(n){const e=B.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(wd,{"data-slot":"dialog-overlay",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function rs(n){const e=B.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(H5,{}),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(Mr,{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(nt,{"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 u;return e[10]!==t||e[11]!==o||e[12]!==c||e[13]!==d?(u=r.jsxs(W5,{children:[l,r.jsxs(vd,{"data-slot":"dialog-content",className:c,...o,children:[t,d]})]}),e[10]=t,e[11]=o,e[12]=c,e[13]=d,e[14]=u):u=e[14],u}function Ps(n){const e=B.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 Og(n){const e=B.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 is(n){const e=B.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(xd,{"data-slot":"dialog-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function as(n){const e=B.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(bd,{"data-slot":"dialog-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Dg(n){const e=B.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(Oo,{"data-slot":"command",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function gB(n){const e=B.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,u=l===void 0?!1:l;let f;e[7]!==s?(f=G("top-1/3 translate-y-0 overflow-hidden rounded-xl! p-0",s),e[7]=s,e[8]=f):f=e[8];let m;e[9]!==c?(m=r.jsx(is,{children:c}),e[9]=c,e[10]=m):m=e[10];let p;e[11]!==d?(p=r.jsx(as,{children:d}),e[11]=d,e[12]=p):p=e[12];let h;e[13]!==m||e[14]!==p?(h=r.jsxs(Ps,{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]!==u||e[18]!==f||e[19]!==h?(g=r.jsxs(rs,{className:f,showCloseButton:u,children:[h,t]}),e[16]=t,e[17]=u,e[18]=f,e[19]=h,e[20]=g):g=e[20];let x;return e[21]!==o||e[22]!==g?(x=r.jsx(os,{...o,children:g}),e[21]=o,e[22]=g,e[23]=x):x=e[23],x}function xB(n){const e=B.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(an,{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(Oo.Input,{"data-slot":"command-input",className:i,...s})]}),e[6]=s,e[7]=i,e[8]=a):a=e[8],a}function Lg(n){const e=B.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(Oo.List,{"data-slot":"command-list",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function bB(n){const e=B.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(Oo.Empty,{"data-slot":"command-empty",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function zg(n){const e=B.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(Oo.Group,{"data-slot":"command-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Fg(n){const e=B.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(Oo.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 q5(n){const e=B.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 K5(n){return r.jsx(Pe,{variant:n.source==="built-in"?"secondary":"outline",children:n.source})}const V5=y.memo(function(e){const t=B.c(38),{suggestions:s,filter:o,loading:i,selectedIndex:a,onSelect:l,onHover:c,onEdit:d}=e;let u;t[0]===Symbol.for("react.memo_cache_sentinel")?(u=new Map,t[0]=u):u=t[0];const f=y.useRef(u);let m,p;if(t[1]!==a?(m=()=>{var P;const A=f.current.get(a);A&&((P=A.scrollIntoView)==null||P.call(A,{block:"nearest"}))},p=[a],t[1]=a,t[2]=m,t[3]=p):(m=t[2],p=t[3]),y.useEffect(m,p),i){let A;return t[4]===Symbol.for("react.memo_cache_sentinel")?(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.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]=A):A=t[4],A}if(s.length===0){const A=o?`No commands or skills matching "${o}"`:"No commands or skills found";let P;return t[5]!==A?(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.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:A})})}),t[5]=A,t[6]=P):P=t[6],P}let h,g,x,b,w,v,S,j,k;if(t[7]!==d||t[8]!==c||t[9]!==l||t[10]!==a||t[11]!==s){const A=s.filter(Y5),P=[{heading:"Commands",suggestions:A,offset:0},{heading:"Skills",suggestions:s.filter(X5),offset:A.length}];x="motion-popover-in absolute bottom-full left-0 right-0 z-50 mx-auto mb-2 max-w-[var(--chat-width)]",g=Dg,w="slash-suggestions",v=s[a]?`${s[a].type}-${s[a].name}`:void 0,t[21]!==c||t[22]!==s?(S=T=>{const E=s.findIndex($=>`${$.type}-${$.name}`===T);E>=0&&c(E)},t[21]=c,t[22]=s,t[23]=S):S=t[23],j=!1,k="border shadow-sm",h=Lg,b=P.map(T=>T.suggestions.length>0&&r.jsx(zg,{heading:T.heading,children:T.suggestions.map((E,$)=>{const I=T.offset+$;return r.jsx(G5,{suggestion:E,index:I,isSelected:I===a,onSelect:l,onHover:c,onEdit:d,itemRefs:f},`${E.type}-${E.name}`)})},T.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]=b,t[16]=w,t[17]=v,t[18]=S,t[19]=j,t[20]=k}else h=t[12],g=t[13],x=t[14],b=t[15],w=t[16],v=t[17],S=t[18],j=t[19],k=t[20];let C;t[24]!==h||t[25]!==b?(C=r.jsx(h,{children:b}),t[24]=h,t[25]=b,t[26]=C):C=t[26];let N;t[27]!==g||t[28]!==C||t[29]!==w||t[30]!==v||t[31]!==S||t[32]!==j||t[33]!==k?(N=r.jsx(g,{id:w,value:v,onValueChange:S,shouldFilter:j,className:k,children:C}),t[27]=g,t[28]=C,t[29]=w,t[30]=v,t[31]=S,t[32]=j,t[33]=k,t[34]=N):N=t[34];let _;return t[35]!==x||t[36]!==N?(_=r.jsx("div",{className:x,children:N}),t[35]=x,t[36]=N,t[37]=_):_=t[37],_});function G5({suggestion:n,index:e,isSelected:t,onSelect:s,onHover:o,onEdit:i,itemRefs:a}){const l=y.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(Fg,{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(ko,{className:"size-4 text-muted-foreground"}):r.jsx(ea,{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]}),K5(n)]}),n.description&&r.jsx("p",{className:"mt-0.5 line-clamp-1 text-xs text-muted-foreground",children:n.description})]}),t&&r.jsx(q5,{className:i&&n.filePath?"mr-6":void 0,children:"Enter"})]}),i&&n.filePath&&r.jsx(ee,{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(Vs,{"data-icon":"inline-start"})})]})}function Y5(n){return n.type==="command"}function X5(n){return n.type==="skill"}function J5(n){const e=B.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=y.useRef(c);let u,f;e[1]!==i?(u=()=>{var v,S;(S=(v=d.current.get(i))==null?void 0:v.scrollIntoView)==null||S.call(v,{block:"nearest"})},f=[i],e[1]=i,e[2]=u,e[3]=f):(u=e[2],f=e[3]),y.useEffect(u,f);const m=t[i];let p;e[4]!==t||e[5]!==l?(p=v=>{const S=t.indexOf(v);S>=0&&l(S)},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((v,S)=>r.jsxs(Fg,{ref:j=>{j?(j.id=`file-suggestion-${S}`,d.current.set(S,j)):d.current.delete(S)},value:v,onMouseEnter:()=>l(S),onSelect:()=>a(v),onMouseDown:Q5,children:[r.jsx(_1,{"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:v}),S===i&&r.jsx("span",{className:"text-xs text-muted-foreground",children:"↵"})]},v)),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 b;e[18]!==g||e[19]!==x?(b=r.jsx(Lg,{className:"max-h-70",children:r.jsx(zg,{heading:g,children:x})}),e[18]=g,e[19]=x,e[20]=b):b=e[20];let w;return e[21]!==m||e[22]!==p||e[23]!==b?(w=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(Dg,{id:"file-suggestions",value:m,onValueChange:p,shouldFilter:!1,className:"border shadow-sm",children:b})}),e[21]=m,e[22]=p,e[23]=b,e[24]=w):w=e[24],w}function Q5(n){return n.preventDefault()}const Z5=ns("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 pt(n){const e=B.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(Z5({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 Et(n){const e=B.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 ht(n){const e=B.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 Cs(n){const e=B.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 Do(n){const e=B.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(o3,{"data-slot":"dropdown-menu",...t}),e[2]=t,e[3]=s):s=e[3],s}function Lo(n){const e=B.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(r3,{"data-slot":"dropdown-menu-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function zo(n){const e=B.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,u=a===void 0?"bottom":a,f=l===void 0?4:l;let m;e[7]!==t?(m=G("z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 ease-out outline-none data-[side=bottom]:slide-in-from-top-1 data-[side=inline-end]:slide-in-from-left-1 data-[side=inline-start]:slide-in-from-right-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",t),e[7]=t,e[8]=m):m=e[8];let p;e[9]!==s||e[10]!==m?(p=r.jsx(T1,{"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]!==u||e[15]!==f||e[16]!==p?(h=r.jsx(P1,{children:r.jsx($1,{className:"isolate z-50 outline-none",align:c,alignOffset:d,side:u,sideOffset:f,children:p})}),e[12]=c,e[13]=d,e[14]=u,e[15]=f,e[16]=p,e[17]=h):h=e[17],h}function Zn(n){const e=B.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(E1,{"data-slot":"dropdown-menu-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function Bg(n){const e=B.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(R1,{"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 Wt(n){const e=B.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(A1,{"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 vB(n){const e=B.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(a3,{"data-slot":"dropdown-menu-radio-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function yB(n){const e=B.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(l3,{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 u;return e[9]!==t||e[10]!==l||e[11]!==o||e[12]!==i||e[13]!==c?(u=r.jsxs(i3,{"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]=u):u=e[14],u}function oa(n){const e=B.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(gd,{"data-slot":"dropdown-menu-separator",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function ft(n){const e=B.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(d3,{"data-slot":"collapsible",...t}),e[2]=t,e[3]=s):s=e[3],s}function Rt(n){const e=B.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(u3,{"data-slot":"collapsible-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function mt(n){const e=B.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(c3,{"data-slot":"collapsible-content",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const eS={exit_only:"Exit plan mode",interactive:"Implement interactively",autopilot:"Implement with Autopilot",autopilot_fleet:"Implement with Fleet"};function Im(n){return eS[n]??n.replaceAll("_"," ")}function tS(n){const e=B.c(46),{allowedPrompts:t,summary:s,planContent:o,actions:i,recommendedAction:a,responding:l,responseError:c,onApprove:d,onReject:u}=n;let f,m,p,h,g,x,b,w,v,S;if(e[0]!==d||e[1]!==a||e[2]!==s||e[3]!==i||e[4]!==l){const P=i===void 0?[]:i;p=l===void 0?!1:l;const T=a??P[0],E=P.filter(R=>R!==T);m=pt,b="mb-3 pr-44",e[15]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(Or,{}),v=r.jsx(Et,{children:"Plan ready for review"}),e[15]=w,e[16]=v):(w=e[15],v=e[16]);const $=s||"Approve the plan or ask the agent to revise it.";e[17]!==$?(S=r.jsx(ht,{children:$}),e[17]=$,e[18]=S):S=e[18],f=Cs,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(ee,{size:"sm",disabled:p,onClick:()=>d(T),children:[I,p?"Sending...":T?Im(T):"Approve"]}),x=E.length>0&&r.jsxs(Do,{children:[r.jsx(Lo,{render:r.jsx(ee,{type:"button",variant:"outline",size:"icon-sm","aria-label":"Other plan actions",disabled:p}),children:r.jsx(it,{"data-icon":"icon"})}),r.jsx(zo,{align:"end",children:r.jsx(Zn,{children:E.map(R=>r.jsx(Wt,{onClick:()=>d(R),children:Im(R)},R))})})]}),e[0]=d,e[1]=a,e[2]=s,e[3]=i,e[4]=l,e[5]=f,e[6]=m,e[7]=p,e[8]=h,e[9]=g,e[10]=x,e[11]=b,e[12]=w,e[13]=v,e[14]=S}else f=e[5],m=e[6],p=e[7],h=e[8],g=e[9],x=e[10],b=e[11],w=e[12],v=e[13],S=e[14];let j;e[21]!==u||e[22]!==p?(j=r.jsx(ee,{variant:"ghost",size:"sm",disabled:p,onClick:u,children:"Reject"}),e[21]=u,e[22]=p,e[23]=j):j=e[23];let k;e[24]!==f||e[25]!==j||e[26]!==h||e[27]!==g||e[28]!==x?(k=r.jsxs(f,{className:h,children:[g,x,j]}),e[24]=f,e[25]=j,e[26]=h,e[27]=g,e[28]=x,e[29]=k):k=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 N;e[32]!==o?(N=o&&r.jsxs(ft,{className:"col-span-full mt-2",children:[r.jsx(Rt,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"xs"}),children:"Review full plan"}),r.jsx(mt,{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]=N):N=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(nS)]}),e[34]=t,e[35]=_):_=e[35];let A;return e[36]!==m||e[37]!==k||e[38]!==C||e[39]!==N||e[40]!==_||e[41]!==b||e[42]!==w||e[43]!==v||e[44]!==S?(A=r.jsxs(m,{className:b,children:[w,v,S,k,C,N,_]}),e[36]=m,e[37]=k,e[38]=C,e[39]=N,e[40]=_,e[41]=b,e[42]=w,e[43]=v,e[44]=S,e[45]=A):A=e[45],A}function nS(n,e){return r.jsx(Pe,{variant:"outline",children:n.prompt},e)}const sS=["allow","allow_always","deny"];function Ei(n,e){return(n.availableDecisions??sS).includes(e)}function oS(n){switch(n){case"Bash":return{label:"Run command",icon:ko,tone:"cmd"};case"Edit":return{label:"Edit file",icon:Sc,tone:"write"};case"Write":return{label:"Write file",icon:Sc,tone:"write"};case"Read":return{label:"Read file",icon:ys,tone:"read"};case"Glob":return{label:"File search",icon:an,tone:"search"};case"Grep":return{label:"Content search",icon:an,tone:"search"};case"WebFetch":return{label:"Fetch URL",icon:ta,tone:"net"};case"WebSearch":return{label:"Web search",icon:ta,tone:"net"};default:return{label:n,icon:_a,tone:"other"}}}function rS(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 iS({requests:n,responding:e,onRespond:t,onRespondAll:s}){var w;const o=n[0],i=n.length,a=o?Ei(o,"allow"):!1,l=o?Ei(o,"allow_always"):!1,c=o?Ei(o,"deny"):!1,d=i>1&&n.every(v=>Ei(v,"allow")),u=y.useEffectEvent(v=>{if(!o)return;const S=v.target;if(S&&(S.tagName==="INPUT"||S.tagName==="TEXTAREA"||S.isContentEditable)||v.metaKey||v.ctrlKey||v.altKey)return;const j=v.key.toLowerCase();j==="a"&&v.shiftKey&&d?(v.preventDefault(),s("allow")):j==="a"&&a?(v.preventDefault(),t(o.requestId,"allow")):j==="s"&&l?(v.preventDefault(),t(o.requestId,"allow_always")):j==="d"&&c&&(v.preventDefault(),t(o.requestId,"deny"))});y.useEffect(()=>{const v=S=>u(S);return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[]);const f=o?oS(o.toolName):null,m=o?rS(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||!f)return null;const g=f.icon,x=e.has(o.requestId),b=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(S1,{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:f.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}),b&&r.jsxs(Pe,{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(ee,{variant:"ghost",size:"sm",className:"text-destructive",disabled:x,onClick:()=>t(o.requestId,"deny"),title:"Deny (D)",children:[r.jsx(nt,{"data-icon":"inline-start"}),"Deny",r.jsx("kbd",{className:"ml-0.5 font-mono text-xs text-muted-foreground",children:"D"})]}),l&&r.jsxs(ee,{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(f3,{"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(ee,{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(ee,{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 aS=1568,lS=.85,Mm=35e5;function cS(n,e){let{width:t,height:s}=n;const o=Math.min(1,aS/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?lS:void 0),u=d.split(",")[1];if(u.length>Mm){let f=l?.7:.8;for(;u.length>Mm&&f>.3;)d=i.toDataURL("image/jpeg",f),u=d.split(",")[1],f-=.1;return{dataUrl:d,base64:u,mediaType:"image/jpeg"}}return{dataUrl:d,base64:u,mediaType:c}}function dS(n){const e=B.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]=y.useState(s),[a,l]=y.useState(!1),[c,d]=y.useState(!1),u=y.useRef(t);let f,m;e[1]!==t?(f=()=>{u.current=t},m=[t],e[1]=t,e[2]=f,e[3]=m):(f=e[2],m=e[3]),y.useEffect(f,m);let p;e[4]!==t?(p=R=>{const D=Array.from(R).filter(mS);if(!t){D.length>0&&d(!0);return}d(!1);for(const O of D){const M=new FileReader;M.onload=()=>{if(!u.current){d(!0);return}const F=M.result,z=new Image;z.onload=()=>{if(!u.current){d(!0);return}const L=cS(z,O.type);i(W=>[...W,{id:crypto.randomUUID(),file:O,preview:L.dataUrl,data:L.base64,mediaType:L.mediaType}])},z.src=F},M.onerror=()=>{console.warn(`Failed to read image file: ${O.name}`)},M.readAsDataURL(O)}},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(D=>D.filter((O,M)=>M!==R)),d(!1)},e[6]=g):g=e[6];const x=g;let b;e[7]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{i([]),d(!1)},e[7]=b):b=e[7];const w=b;let v;e[8]===Symbol.for("react.memo_cache_sentinel")?(v=()=>d(!1),e[8]=v):v=e[8];const S=v;let j;e[9]!==t?(j=R=>{R.preventDefault(),t&&l(!0)},e[9]=t,e[10]=j):j=e[10];const k=j;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 N=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 A=_;let P;e[14]!==h?(P=R=>{var F;const D=(F=R.clipboardData)==null?void 0:F.items;if(!D)return;const O=Array.from(D).filter(fS);if(O.length===0)return;R.preventDefault();const M=O.map(uS).filter(Boolean);h(M)},e[14]=h,e[15]=P):P=e[15];const T=P,E=!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,$=!t&&o.length>0;let I;return e[16]!==k||e[17]!==A||e[18]!==T||e[19]!==o||e[20]!==a||e[21]!==E||e[22]!==$?(I={images:o,isDragOver:a,imageError:E,hasUnsupportedAttachments:$,dismissImageError:S,removeImage:x,clearImages:w,handleDragOver:k,handleDragLeave:N,handleDrop:A,handlePaste:T},e[16]=k,e[17]=A,e[18]=T,e[19]=o,e[20]=a,e[21]=E,e[22]=$,e[23]=I):I=e[23],I}function uS(n){return n.getAsFile()}function fS(n){return n.type.startsWith("image/")}function mS(n){return n.type.startsWith("image/")}function pS(n){const e=B.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(g3,{"data-slot":"tooltip-provider",delay:o,...t}),e[3]=o,e[4]=t,e[5]=i):i=e[5],i}function It(n){const e=B.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(pS,{children:r.jsx(h3,{"data-slot":"tooltip",...t})}),e[2]=t,e[3]=s):s=e[3],s}function Mt(n){const e=B.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(m3,{"data-slot":"tooltip-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function Ot(n){const e=B.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,u=a===void 0?4:a,f=l===void 0?"center":l,m=c===void 0?0:c;let p;e[8]!==s?(p=G("z-50 w-fit origin-(--transform-origin) overflow-hidden rounded-md bg-popover px-2.5 py-1.5 text-xs text-popover-foreground shadow-md ring-1 ring-foreground/10 text-balance duration-100 ease-out data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",s),e[8]=s,e[9]=p):p=e[9];let h;e[10]!==t||e[11]!==o||e[12]!==p?(h=r.jsx(p3,{"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]!==f||e[15]!==m||e[16]!==d||e[17]!==u||e[18]!==h?(g=r.jsx(x3,{children:r.jsx(b3,{align:f,alignOffset:m,side:d,sideOffset:u,className:"isolate z-50",children:h})}),e[14]=f,e[15]=m,e[16]=d,e[17]=u,e[18]=h,e[19]=g):g=e[19],g}const Mn="rounded-full border bg-background/80 shadow-sm backdrop-blur",Wa=y.memo(function(e){const t=B.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}),Ml=y.memo(function(e){const t=B.c(17),{icon:s,label:o,onClick:i,disabled:a,className:l,iconClassName:c,size:d}=e,f=(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]!==f?(m=r.jsx(ee,{variant:"ghost",size:f,className:l,onClick:i,disabled:a,"aria-label":o}),t[0]=l,t[1]=a,t[2]=o,t[3]=i,t[4]=f,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(Mt,{render:m,children:p}),t[9]=m,t[10]=p,t[11]=h):h=t[11];let g;t[12]!==o?(g=r.jsx(Ot,{children:o}),t[12]=o,t[13]=g):g=t[13];let x;return t[14]!==h||t[15]!==g?(x=r.jsxs(It,{children:[h,g]}),t[14]=h,t[15]=g,t[16]=x):x=t[16],x});function hS(n){return n<10?"critical":n<30?"warning":"healthy"}const gS={critical:"border-destructive/30 bg-destructive/10 text-destructive",warning:"border-warning/30 bg-warning/10 text-warning",healthy:"text-muted-foreground"},Ug=y.memo(function(e){const t=B.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 u,f,m,p,h,g,x,b,w,v,S,j,k;if(t[0]!==s||t[1]!==l||t[2]!==c||t[3]!==d){x=Symbol.for("react.early_return_sentinel");e:{const A=yg(s);if(!A){x=null;break e}const P=Math.max(0,100-A.percent),T=hS(P);if(d&&T==="healthy"){x=null;break e}const E=Math.max(0,A.compactAt-A.used);let $;t[17]!==P||t[18]!==E||t[19]!==l?($=l?`${P.toFixed(0)}% · ${ut(E)}`:`${P.toFixed(0)}%`,t[17]=P,t[18]=E,t[19]=l,t[20]=$):$=t[20];const I=$,R=gS[T],D=l&&"gap-1";let O;t[21]!==R||t[22]!==D?(O=G("shrink-0 tabular-nums",R,D),t[21]=R,t[22]=D,t[23]=O):O=t[23];let M;t[24]!==I||t[25]!==O?(M=r.jsx(Pe,{variant:"outline",className:O,children:I}),t[24]=I,t[25]=O,t[26]=M):M=t[26];const F=M;if(!c){x=F;break e}f=It,t[27]!==F?(g=r.jsx(Mt,{render:F}),t[27]=F,t[28]=g):g=t[28],u=Ot,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]!==E?(z=ut(E),t[30]=E,t[31]=z):z=t[31];let L;t[32]!==P?(L=P.toFixed(1),t[32]=P,t[33]=L):L=t[33],t[34]!==z||t[35]!==L?(h=r.jsxs("div",{children:[z," remaining (",L,"%)"]}),t[34]=z,t[35]=L,t[36]=h):h=t[36],b="text-muted-foreground",w=ut(A.used),v=" / ",S=ut(A.limit),j=" tokens used (",k=A.percentAbsolute.toFixed(1)}t[0]=s,t[1]=l,t[2]=c,t[3]=d,t[4]=u,t[5]=f,t[6]=m,t[7]=p,t[8]=h,t[9]=g,t[10]=x,t[11]=b,t[12]=w,t[13]=v,t[14]=S,t[15]=j,t[16]=k}else u=t[4],f=t[5],m=t[6],p=t[7],h=t[8],g=t[9],x=t[10],b=t[11],w=t[12],v=t[13],S=t[14],j=t[15],k=t[16];if(x!==Symbol.for("react.early_return_sentinel"))return x;let C;t[37]!==b||t[38]!==w||t[39]!==v||t[40]!==S||t[41]!==j||t[42]!==k?(C=r.jsxs("div",{className:b,children:[w,v,S,j,k,"%)"]}),t[37]=b,t[38]=w,t[39]=v,t[40]=S,t[41]=j,t[42]=k,t[43]=C):C=t[43];let N;t[44]!==u||t[45]!==m||t[46]!==p||t[47]!==h||t[48]!==C?(N=r.jsxs(u,{className:m,children:[p,h,C]}),t[44]=u,t[45]=m,t[46]=p,t[47]=h,t[48]=C,t[49]=N):N=t[49];let _;return t[50]!==f||t[51]!==g||t[52]!==N?(_=r.jsxs(f,{children:[g,N]}),t[50]=f,t[51]=g,t[52]=N,t[53]=_):_=t[53],_});function xS(n){const e=B.c(7),{isPlanApproval:t,isUserQuestion:s,elapsedSec:o}=n,{isLive:i}=at(),{chat:a}=qr(),{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:S4(o)}),r.jsx(Wa,{})]}),e[0]=o,e[1]=t,e[2]=s,e[3]=c,e[4]=d):d=e[4];let u;return e[5]!==d?(u=r.jsx(r.Fragment,{children:d}),e[5]=d,e[6]=u):u=e[6],u}function bS(n){const e=B.c(26),{hasContent:t,onSubmit:s,submitLabel:o}=n,i=o===void 0?"Send message":o,{isLive:a,sessionSource:l,actions:c}=at(),{handleStopSession:d}=c,{chat:u}=qr(),{isConnected:f,interrupt:m}=u,p=f||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)??$t((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=R4(g),e[3]=g,e[4]=x):x=e[4];const b=x;let w;e[5]!==b||e[6]!==m||e[7]!==p?(w=p&&r.jsxs(It,{children:[r.jsx(Mt,{render:r.jsx(ee,{variant:"outline",size:"icon-sm",className:"motion-enter shrink-0 rounded-full text-warning",onClick:m,"aria-label":b,title:b}),children:r.jsx(Sd,{"data-icon":"inline-start",className:"fill-current"})}),r.jsxs(Ot,{children:[b," (Esc)"]})]}),e[5]=b,e[6]=m,e[7]=p,e[8]=w):w=e[8];let v;e[9]!==g||e[10]!==d||e[11]!==p?(v=p&&Gt(g).stopSession&&r.jsxs(It,{children:[r.jsx(Mt,{render:r.jsx(ee,{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(v3,{"data-icon":"inline-start"})}),r.jsx(Ot,{children:"Stop session"})]}),e[9]=g,e[10]=d,e[11]=p,e[12]=v):v=e[12];const S=t?"default":"secondary",j=!t&&"text-muted-foreground";let k;e[13]!==j?(k=G("shrink-0 rounded-full",j),e[13]=j,e[14]=k):k=e[14];const C=!t;let N;e[15]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(y3,{"data-icon":"inline-start"}),e[15]=N):N=e[15];let _;e[16]!==s||e[17]!==i||e[18]!==k||e[19]!==C||e[20]!==S?(_=r.jsx(ee,{variant:S,size:"icon-sm",className:k,disabled:C,onClick:s,"aria-label":i,title:i,children:N}),e[16]=s,e[17]=i,e[18]=k,e[19]=C,e[20]=S,e[21]=_):_=e[21];let A;return e[22]!==_||e[23]!==w||e[24]!==v?(A=r.jsxs("div",{className:"flex items-center gap-1",children:[w,v,_]}),e[22]=_,e[23]=w,e[24]=v,e[25]=A):A=e[25],A}function Om(n){const e=B.c(34),{error:t}=n,[s,o]=y.useState(!1),[i,a]=y.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 u=d;let f;e[5]!==t?(f=async()=>{try{await navigator.clipboard.writeText(t),a(!0),setTimeout(()=>a(!1),1500)}catch{}},e[5]=t,e[6]=f):f=e[6];const m=f;let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=()=>o(!0),e[7]=p):p=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(Yt,{"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]!==u?(x=u&&r.jsx("span",{className:"shrink-0 opacity-60",children:"(details)"}),e[11]=u,e[12]=x):x=e[12];let b;e[13]!==g||e[14]!==x?(b=r.jsxs(ee,{type:"button",variant:"ghost",size:"sm",onClick:p,title:"Click to view the full error",className:"motion-enter mt-1 w-full justify-start text-destructive",children:[h,g,x]}),e[13]=g,e[14]=x,e[15]=b):b=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsxs(Ps,{children:[r.jsxs(is,{className:"flex items-center gap-2 text-destructive",children:[r.jsx(Yt,{className:"size-4"}),"Error details"]}),r.jsx(as,{children:"The full output from the failed request, including the underlying process stderr."})]}),e[16]=w):w=e[16];let v;e[17]!==t?(v=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]=v):v=e[18];let S;e[19]!==i?(S=i?r.jsx(dt,{"data-icon":"inline-start"}):r.jsx(xn,{"data-icon":"inline-start"}),e[19]=i,e[20]=S):S=e[20];const j=i?"Copied":"Copy";let k;e[21]!==m||e[22]!==S||e[23]!==j?(k=r.jsx("div",{className:"flex justify-end",children:r.jsxs(ee,{type:"button",variant:"outline",size:"sm",onClick:m,children:[S,j]})}),e[21]=m,e[22]=S,e[23]=j,e[24]=k):k=e[24];let C;e[25]!==v||e[26]!==k?(C=r.jsxs(rs,{className:"max-w-2xl",children:[w,v,k]}),e[25]=v,e[26]=k,e[27]=C):C=e[27];let N;e[28]!==s||e[29]!==C?(N=r.jsx(os,{open:s,onOpenChange:o,children:C}),e[28]=s,e[29]=C,e[30]=N):N=e[30];let _;return e[31]!==N||e[32]!==b?(_=r.jsxs(r.Fragment,{children:[b,N]}),e[31]=N,e[32]=b,e[33]=_):_=e[33],_}function vS(n){const e=B.c(17),{suggestion:t,onAccept:s}=n,[o,i]=y.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(ea,{"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(ee,{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 u;e[9]!==t?(u=()=>i(t),e[9]=t,e[10]=u):u=e[10];let f;e[11]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(nt,{}),e[11]=f):f=e[11];let m;e[12]!==u?(m=r.jsx(ee,{type:"button",variant:"ghost",size:"icon","aria-label":"Dismiss suggestion",onClick:u,className:"shrink-0 text-muted-foreground",children:f}),e[12]=u,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 yS(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 wS(n,e,t){return`${n.slice(0,e.start)}@${t} `}const Ha={terminal:!0,configWrite:!0,hostFiles:!0,manageUsers:!0,manageWorkspaces:!0,manageDevices:!0,killAny:!0,viewAllSessions:!0,viewUsage:!0,share:!0,runFlows:!0},Vr={terminal:!1,configWrite:!1,hostFiles:!1,manageUsers:!1,manageWorkspaces:!1,manageDevices:!1,killAny:!1,viewAllSessions:!1,viewUsage:!1,share:!1,runFlows:!1};let Wg=Ha;const Fc=new Set;function bo(n){Wg=(n==null?void 0:n.capabilities)??Ha;for(const e of Fc)e()}function ot(n){return Wg[n]}function jS(n){return Fc.add(n),()=>Fc.delete(n)}function An(n){const e=B.c(3);let t,s;return e[0]!==n?(t=()=>ot(n),s=()=>ot(n),e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]),y.useSyncExternalStore(jS,t,s)}function SS(n){const e=n.files;return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function NS(n,e,t){const s=An("hostFiles"),[o,i]=y.useState([]),[a,l]=y.useState(!1);return y.useEffect(()=>{if(!s||!t||!n){i([]),l(!1);return}const c=new AbortController,d=window.setTimeout(async()=>{l(!0);try{const u=await be(`/api/project-files?cwd=${encodeURIComponent(n)}&q=${encodeURIComponent(e)}&limit=30`,{signal:c.signal});if(!u.ok)throw new Error(`Request failed (${u.status})`);const f=await u.json();c.signal.aborted||i(SS(f))}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 Bc="cogpit-share-revoked";function kS(){window.dispatchEvent(new Event(Bc))}async function Hg(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&&kS(),s}function Gr(n,e){return Hg(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e??{})})}async function CS(){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 _S(n,e){return Gr("/api/share/send-message",e!=null&&e.length?{message:n,images:e}:{message:n})}function TS(){return Gr("/api/share/interrupt")}function ES(){return Gr("/api/share/stop")}async function AS(n,e){return(await Gr("/api/share/permission",{requestId:n,behavior:e})).ok}async function PS(n,e){try{const t=await Gr("/api/share/answer",{toolUseId:n,answers:e});return{ok:t.ok,gone:t.status===404}}catch{return{ok:!1,gone:!1}}}async function $S(){try{const n=await Hg("/api/share/pending");if(!n.ok)return null;const e=await n.json();return Array.isArray(e.permissions)?e.permissions:[]}catch{return null}}const RS=/^\/shared\/([^/]+)\/?$/;function qg(n){const e=RS.exec(n);if(!e)return null;try{return decodeURIComponent(e[1])||null}catch{return null}}function qa(n){return qg(n)!==null}function IS(n){return`/shared/${encodeURIComponent(n)}`}function wB(n){return[...n].join(", ")}async function qd(n,e,t){if(qa(window.location.pathname))return PS(e,t);try{const s=await be("/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 MS(n,e,t){try{return(await be(`/api/permissions/${encodeURIComponent(n)}/plan`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:e,...t})})).ok}catch{return!1}}function Ka(n){const e=B.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 Ai(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 OS(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 DS(n,e,t){return t?"border-warning/40 focus-within:border-warning/60 focus-within:ring-warning/15":n||e?"border-info/40 focus-within:border-info/60 focus-within:ring-info/15":"border-input focus-within:border-ring focus-within:ring-ring/20"}function LS(n,e,t){return n?"px-4 pb-1.5 pt-3.5":e?G("col-span-2 row-start-1",t?"py-2.5 pr-3 pl-2":"py-3 pr-4 pl-4"):G("col-start-2 row-start-1",t?"py-2 pr-1 pl-2":"py-2.5 pr-2 pl-4")}function zS(n,e){return n?"gap-1 px-2 pb-2 pt-0.5":e?"col-start-2 row-start-2 px-1.5 pb-1.5":"col-start-3 row-start-1 pr-1.5 pb-1.5"}const Uc=y.memo(y.forwardRef(function({allowImages:e=!0,agentKind:t,projectCwd:s,leadingAccessory:o,footer:i,compact:a=!1},l){var Me;const c=An("hostFiles"),{session:d,isLive:u,actions:{handleEditConfig:f},pendingInteraction:m,permissionRequests:p,permissionResponding:h,respondPermission:g,respondAllPermissions:x,slashSuggestions:b,slashSuggestionsLoading:w,turnError:v,promptSuggestion:S}=at(),{chat:{status:j,error:k,isConnected:C,sendMessage:N,interrupt:_}}=qr(),A=C||u,[P,T]=y.useState(""),[E,$]=y.useState(!1),[I,R]=y.useState(!1),[D,O]=y.useState(null),M=y.useRef(null),F=y.useRef(null),z=y.useRef(!1),L=y.useRef(""),W=y.useRef(null);y.useEffect(()=>{L.current=P},[P]);const U=y.useCallback(fe=>{z.current=fe,$(fe)},[]),{images:H,isDragOver:K,imageError:V,hasUnsupportedAttachments:Y,dismissImageError:q,removeImage:J,clearImages:Q,handleDragOver:X,handleDragLeave:Z,handleDrop:te,handlePaste:ne}=dS(e),[oe,re]=y.useState(0),[ae,se]=y.useState(0),[de,le]=y.useState(!1),ce=P.startsWith("/")&&!P.includes(" "),me=ce?P.slice(1):"",ue=y.useMemo(()=>{if(!ce)return[];const fe=me.toLowerCase(),ve=b.filter(Ke=>fe?Ke.name.toLowerCase().includes(fe)||Ke.description.toLowerCase().includes(fe):!0),Oe=ve.filter(Ke=>Ke.type==="command"),Ue=ve.filter(Ke=>Ke.type==="skill");return[...Oe,...Ue]},[ce,me,b]),ie=y.useMemo(()=>yS(P),[P]),ge=!!(c&&ie&&s&&!de),pe=NS(s,(ie==null?void 0:ie.query)??"",ge);y.useEffect(()=>{re(0)},[me]),y.useEffect(()=>{se(0)},[ie==null?void 0:ie.query]);const xe=kg(C),Ce=(m==null?void 0:m.type)==="plan"?m.requestId??null:null;y.useEffect(()=>{F.current=Ce,M.current=null,R(!1),O(null)},[Ce]);const Te=y.useCallback(async fe=>{const ve=m;if(!(d!=null&&d.sessionId)||(ve==null?void 0:ve.type)!=="question")return;const Oe=ve.questions[0];if(!Oe||!fe.trim())return;(await qd(d.sessionId,ve.toolUseId,{[Oe.question]:fe})).ok||N(fe)},[m,d==null?void 0:d.sessionId,N]),Ee=y.useCallback(async(fe,ve,Oe)=>{const Ue=m;if((Ue==null?void 0:Ue.type)==="plan"&&Ue.provider==="copilot"&&Ue.requestId&&(d!=null&&d.sessionId)){const Ke=Ue.requestId;if(M.current)return!1;M.current=Ke,R(!0),O(null);try{const Ze=await MS(d.sessionId,Ke,{approved:fe,...ve?{selectedAction:ve}:{},...Oe?{feedback:Oe}:{}});return!Ze&&F.current===Ke&&O("Couldn't send the plan response. Try again."),Ze}finally{M.current===Ke&&(M.current=null,R(!1))}}return N(fe?"yes":Oe||"no"),!0},[m,d==null?void 0:d.sessionId,N]),$e=y.useCallback(()=>{requestAnimationFrame(()=>{const fe=W.current;fe&&(fe.focus(),fe.selectionStart=fe.selectionEnd=fe.value.length,U(Ai(fe,z.current)))})},[U]),Re=y.useCallback(fe=>{T(`/${fe.name} `),re(0),$e()},[$e]),Fe=y.useCallback(fe=>{T(fe),$e()},[$e]),Le=y.useCallback(fe=>{if(!ie)return;const ve=wS(P,ie,fe);T(ve),le(!0),se(0),requestAnimationFrame(()=>{const Oe=W.current;Oe&&(Oe.focus(),Oe.selectionStart=Oe.selectionEnd=Oe.value.length,U(Ai(Oe,z.current)))})},[ie,P,U]),Ie=y.useCallback(async()=>{const fe=P.trim();if(!fe&&H.length===0||!e&&H.length>0)return;if((m==null?void 0:m.type)==="question"){Te(fe),T(""),U(!1),W.current&&(W.current.style.height="auto");return}if((m==null?void 0:m.type)==="plan"&&m.provider==="copilot"){if(!fe||!await Ee(!1,void 0,fe))return;T(""),U(!1),W.current&&(W.current.style.height="auto");return}const ve=e&&H.length>0?H.map(Oe=>({data:Oe.data,mediaType:Oe.mediaType})):void 0;N(fe,ve),T(""),Q(),U(!1),W.current&&(W.current.style.height="auto")},[P,H,e,N,Q,U,m,Te,Ee]),_e=y.useCallback(fe=>{if(ge&&fe.key==="Escape"){fe.preventDefault(),le(!0);return}if(ge&&pe.files.length>0){if(fe.key==="ArrowDown"){fe.preventDefault(),se(ve=>ve<pe.files.length-1?ve+1:0);return}if(fe.key==="ArrowUp"){fe.preventDefault(),se(ve=>ve>0?ve-1:pe.files.length-1);return}if(fe.key==="Tab"||fe.key==="Enter"&&!fe.shiftKey){fe.preventDefault();const ve=pe.files[ae];ve&&Le(ve);return}}if(ce&&ue.length>0){if(fe.key==="ArrowDown"){fe.preventDefault(),re(ve=>ve<ue.length-1?ve+1:0);return}if(fe.key==="ArrowUp"){fe.preventDefault(),re(ve=>ve>0?ve-1:ue.length-1);return}if(fe.key==="Tab"||fe.key==="Enter"&&!fe.shiftKey){fe.preventDefault();const ve=ue[oe];ve&&Re(ve);return}if(fe.key==="Escape"){fe.preventDefault(),T("");return}}if(fe.key==="Escape"&&A&&_){fe.preventDefault(),_();return}fe.key==="Enter"&&!fe.shiftKey&&(fe.preventDefault(),Ie())},[Ie,A,_,ge,pe.files,ae,Le,ce,ue,oe,Re]),je=y.useCallback(fe=>{T(fe.target.value),le(!1),U(Ai(fe.target,z.current))},[U]);y.useImperativeHandle(l,()=>({focus:()=>{var fe;return(fe=W.current)==null?void 0:fe.focus()},getText:()=>L.current,setText:fe=>{T(fe),le(!1),requestAnimationFrame(()=>U(Ai(W.current,z.current)))}}),[U]);const ze=(m==null?void 0:m.type)==="plan",Ne=(m==null?void 0:m.type)==="question",Se=p.length>0,he=!!i,De=(P.trim().length>0||H.length>0)&&!Y,Be=Gt(t??Xs).midTurnSteering&&A,We=ge?"file-suggestions":ce?"slash-suggestions":void 0,we=ge&&pe.files[ae]?`file-suggestion-${ae}`:ce&&ue[oe]?`slash-suggestion-${oe}`:void 0;return r.jsxs("div",{className:G("relative pb-0",a?"px-2 pt-2":"px-3 pt-2",K&&"ring-2 ring-info/40 ring-inset"),onDragOver:X,onDragLeave:Z,onDrop:te,children:[K&&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"})}),ce&&r.jsx(V5,{suggestions:ue,filter:me,loading:w,selectedIndex:oe,onSelect:Re,onHover:re,onEdit:f}),ge&&r.jsx(J5,{files:pe.files,query:(ie==null?void 0:ie.query)??"",loading:pe.loading,selectedIndex:ae,onSelect:Le,onHover:se}),r.jsxs("div",{children:[ze&&r.jsx(tS,{allowedPrompts:m.allowedPrompts,summary:m.summary,planContent:m.planContent,actions:m.actions,recommendedAction:m.recommendedAction,responding:I,responseError:D,onApprove:fe=>{Ee(!0,fe)},onReject:()=>{Ee(!1)}}),r.jsx(vS,{suggestion:S,onAccept:Fe}),H.length>0&&r.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:H.map((fe,ve)=>r.jsxs("div",{className:"motion-list-item relative group/thumb",children:[r.jsx("img",{src:fe.preview,alt:`Upload ${ve+1}`,className:"h-16 w-auto rounded-md border bg-muted object-contain"}),r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>J(ve),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 ${ve+1}`,children:r.jsx(nt,{className:"size-3","data-icon":"icon"})})]},fe.id))}),V&&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:V}),!Y&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:q,className:"text-muted-foreground","aria-label":"Dismiss image notice",children:r.jsx(nt,{"data-icon":"icon"})})]}),r.jsxs("div",{className:G("relative overflow-hidden border bg-composer-surface/85 shadow-lg shadow-black/5 backdrop-blur-xl transition-[border-color,box-shadow] duration-150",he?"rounded-3xl":"rounded-xl",DS(ze,Ne,Se),"focus-within:ring-3"),children:[Se&&r.jsx(iS,{requests:p,responding:h,onRespond:g,onRespondAll:x},(Me=p[0])==null?void 0:Me.requestId),r.jsxs("div",{className:G("min-w-0",he?"flex flex-col":"grid items-end",!he&&(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(Ka,{ref:W,value:P,onChange:je,onKeyDown:_e,onPaste:ne,onFocus:()=>{setTimeout(()=>{var fe;return(fe=W.current)==null?void 0:fe.scrollIntoView({behavior:"smooth",block:"center"})},300)},placeholder:OS(ze,Ne,C,Se,Be,a),"aria-label":"Message",role:"combobox","aria-autocomplete":"list","aria-expanded":!!We,"aria-controls":We,"aria-activedescendant":we,rows:1,className:G("min-h-0 w-full resize-none rounded-none border-0 bg-transparent text-sm text-foreground shadow-none placeholder:text-muted-foreground focus-visible:border-transparent focus-visible:ring-0 dark:bg-transparent",LS(he,E,a))}),r.jsxs("div",{className:G("flex shrink-0 items-center justify-end",zS(he,E)),children:[i,r.jsx(xS,{isPlanApproval:ze,isUserQuestion:Ne,elapsedSec:xe}),r.jsx(bS,{hasContent:De,onSubmit:Ie,submitLabel:Be?"Steer active turn":"Send message"})]})]})]}),j==="error"&&k&&r.jsx(Om,{error:k},k),v&&r.jsx(Om,{error:v},v)]})]})}));function FS(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)?n:null}function BS(n){for(let e=n.length-1;e>=0;e-=1){const t=n[e];if(t.type!=="attachment")continue;const s=FS(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}function Pi(n){return`/api/codex/goals/${encodeURIComponent(n)}`}function Dt(n){const e=B.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(w3,{"data-slot":"input",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Yr(n){const e=B.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(US,{children:r.jsx(WS,{})}),e[7]=l):l=e[7];let c;return e[8]!==t||e[9]!==o||e[10]!==a||e[11]!==i?(c=r.jsxs(j3,{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 US(n){const e=B.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(S3,{className:o,"data-slot":"progress-track",...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function WS(n){const e=B.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(N3,{"data-slot":"progress-indicator",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Kg(n){const e=B.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(k3,{className:o,"data-slot":"progress-label",...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Vg(n){const e=B.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-sm text-muted-foreground tabular-nums",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(C3,{className:o,"data-slot":"progress-value",...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const HS={section:null,canCreate:!1,beginEditing:()=>{}},Kd=y.createContext(HS);function Gg(){return y.useContext(Kd)}const Yg="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-1",Xg="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-2";function qS(n){return n==="usageLimited"?"Usage limited":n==="budgetLimited"?"Budget limited":n.charAt(0).toUpperCase()+n.slice(1)}function KS(n){return n==="complete"?"secondary":n==="blocked"||n.endsWith("Limited")?"destructive":n==="paused"?"outline":"default"}function VS({agentKind:n,threadId:e,children:t}){const s=Ba(n),[o,i]=y.useState(null),[a,l]=y.useState(!0),[c,d]=y.useState(!1),[u,f]=y.useState(""),[m,p]=y.useState(""),[h,g]=y.useState(!1),[x,b]=y.useState(null),w=y.useCallback(async A=>{try{const P=await be(Pi(e),{signal:A});if(P.status===404||P.status===501){l(!1);return}if(!P.ok)return;const T=await P.json();i(T.goal),l(!0)}catch{}},[e]);y.useEffect(()=>{const A=new AbortController;w(A.signal);const P=a?setInterval(()=>void w(),1e4):void 0;return()=>{A.abort(),P!==void 0&&clearInterval(P)}},[w,a]);const v=y.useCallback(()=>{var A;f((o==null?void 0:o.objective)??""),p(((A=o==null?void 0:o.tokenBudget)==null?void 0:A.toString())??""),b(null),d(!0)},[o]),S=async()=>{const A=u.trim();if(!A)return;const P=m.trim()?Number(m):null;if(P!==null&&(!Number.isSafeInteger(P)||P<=0)){b("Token budget must be a positive whole number");return}g(!0),b(null);try{const T=await be(Pi(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({objective:A,status:(o==null?void 0:o.status)==="complete"?"active":(o==null?void 0:o.status)??"active",tokenBudget:P})}),E=await T.json();if(!T.ok)throw new Error(E.error||"Could not save goal");i(E.goal),d(!1)}catch(T){b(T instanceof Error?T.message:"Could not save goal")}finally{g(!1)}},j=async A=>{if(o){g(!0);try{const P=await be(Pi(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:A})});P.ok&&i((await P.json()).goal)}finally{g(!1)}}},k=async()=>{g(!0);try{(await be(Pi(e),{method:"DELETE"})).ok&&(i(null),d(!1))}finally{g(!1)}},C=o!=null&&o.tokenBudget?Math.min(100,o.tokensUsed/o.tokenBudget*100):null;let N=null;if(a&&c)N=r.jsxs("form",{className:Xg,onSubmit:A=>{A.preventDefault(),S()},children:[r.jsxs("div",{className:"mb-2 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[r.jsx(Co,{className:"size-3.5","data-icon":"inline-start"}),o?"Edit long-running goal":"Set a long-running goal"]}),r.jsxs(Mo,{className:"gap-2",children:[r.jsxs(jt,{children:[r.jsx(St,{className:"sr-only",htmlFor:"goal-objective",children:"Goal objective"}),r.jsx(Ka,{id:"goal-objective",value:u,onChange:A=>f(A.target.value),placeholder:`What should ${s} keep working toward?`,rows:2,autoFocus:!0})]}),r.jsxs(jt,{orientation:"horizontal","data-invalid":!!x,children:[r.jsx(St,{className:"text-xs text-muted-foreground",htmlFor:"goal-budget",children:"Token budget"}),r.jsx(Dt,{id:"goal-budget",type:"number",min:1,step:1,value:m,onChange:A=>p(A.target.value),placeholder:"Optional",className:"ml-auto h-8 w-28","aria-invalid":!!x})]})]}),r.jsx(bs,{className:"mt-1.5",children:x}),r.jsxs("div",{className:"mt-2 flex items-center justify-end gap-1",children:[r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>d(!1),children:[r.jsx(nt,{"data-icon":"inline-start"}),"Cancel"]}),r.jsxs(ee,{type:"submit",size:"xs",disabled:h||!u.trim(),children:[r.jsx(dt,{"data-icon":"inline-start"}),"Save goal"]})]})]});else if(a&&o){const A=o.status==="paused",P=o.status==="complete";N=r.jsxs("section",{className:Yg,"aria-label":`${s} goal`,children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Co,{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:o.objective,children:o.objective}),r.jsx(Pe,{variant:KS(o.status),children:qS(o.status)}),r.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[ut(o.tokensUsed),o.tokenBudget?` / ${ut(o.tokenBudget)}`:""," · ",Math.max(0,Math.round(o.timeUsedSeconds/60)),"m"]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[A&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void j("active"),disabled:h,"aria-label":"Resume goal",children:r.jsx(Dr,{"data-icon":"icon"})}),!A&&!P&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void j("paused"),disabled:h,"aria-label":"Pause goal",children:r.jsx(_3,{"data-icon":"icon"})}),!P&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void j("complete"),disabled:h,"aria-label":"Mark goal complete",children:r.jsx(dt,{"data-icon":"icon"})}),r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:v,"aria-label":"Edit goal",children:r.jsx(Vs,{"data-icon":"icon"})}),r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void k(),disabled:h,className:"text-destructive","aria-label":"Clear goal",children:r.jsx(Ta,{"data-icon":"icon"})})]})]}),C!==null&&r.jsx(Yr,{className:"mt-1 mb-0.5",value:C,"aria-label":`${C.toFixed(0)}% of goal token budget used`})]})}const _=y.useMemo(()=>({section:N,canCreate:a&&!o&&!c,beginEditing:v}),[N,a,o,c,v]);return r.jsx(Kd.Provider,{value:_,children:t})}function GS(n){switch(n){case"active":return"Goal active";case"achieved":return"Achieved";default:return"Needs attention"}}function YS(n){switch(n){case"failed":return"destructive";case"achieved":return"secondary";default:return"outline"}}function XS(n){const e=B.c(84),{agentKind:t,session:s,onSendCommand:o,children:i}=n;let a;e[0]!==t?(a=Ba(t),e[0]=t,e[1]=a):a=e[1];const l=a;let c;e[2]!==s.rawMessages?(c=BS(s.rawMessages),e[2]=s.rawMessages,e[3]=c):c=e[3];const d=c,[u,f]=y.useState(),[m,p]=y.useState(!1),[h,g]=y.useState(""),[x,b]=y.useState(null),w=d?`${d.status}\0${d.condition}`:"",[v,S]=y.useState(w);v!==w&&(S(w),f(void 0));const j=u!==void 0?u:d;let k;e[4]!==(j==null?void 0:j.condition)?(k=()=>{g((j==null?void 0:j.condition)??""),b(null),p(!0)},e[4]=j==null?void 0:j.condition,e[5]=k):k=e[5];const C=k;let N;e[6]!==h||e[7]!==o?(N=()=>{const D=h.trim();if(D){if(D.length>4e3){b("Goal conditions can be at most 4,000 characters");return}f({condition:D,status:"active",iterations:0,durationMs:0,tokens:0}),p(!1),o(`/goal ${D}`)}},e[6]=h,e[7]=o,e[8]=N):N=e[8];const _=N;let A;e[9]!==o?(A=()=>{f(null),p(!1),o("/goal clear")},e[9]=o,e[10]=A):A=e[10];const P=A;let T;if(e[11]!==l||e[12]!==C||e[13]!==P||e[14]!==h||e[15]!==m||e[16]!==x||e[17]!==j||e[18]!==_){if(T=null,m){let D;e[20]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(Co,{className:"size-3.5","data-icon":"inline-start"}),e[20]=D):D=e[20];const O=j?"Replace goal":"Set a long-running goal";let M;e[21]!==O?(M=r.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[D,O]}),e[21]=O,e[22]=M):M=e[22];const F=!!x;let z;e[23]===Symbol.for("react.memo_cache_sentinel")?(z=r.jsx(St,{className:"sr-only",htmlFor:"goal-condition",children:"Goal condition"}),e[23]=z):z=e[23];let L;e[24]===Symbol.for("react.memo_cache_sentinel")?(L=Z=>g(Z.target.value),e[24]=L):L=e[24];const W=`A measurable condition ${l} should keep working toward…`,U=!!x;let H;e[25]!==h||e[26]!==W||e[27]!==U?(H=r.jsx(Ka,{id:"goal-condition",value:h,onChange:L,placeholder:W,rows:2,maxLength:4e3,"aria-invalid":U,autoFocus:!0}),e[25]=h,e[26]=W,e[27]=U,e[28]=H):H=e[28];let K;e[29]!==x?(K=r.jsx(bs,{children:x}),e[29]=x,e[30]=K):K=e[30];let V;e[31]!==H||e[32]!==K||e[33]!==F?(V=r.jsxs(jt,{"data-invalid":F,children:[z,H,K]}),e[31]=H,e[32]=K,e[33]=F,e[34]=V):V=e[34];let Y;e[35]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>p(!1),children:[r.jsx(nt,{"data-icon":"inline-start"}),"Cancel"]}),e[35]=Y):Y=e[35];let q;e[36]!==h?(q=h.trim(),e[36]=h,e[37]=q):q=e[37];const J=!q;let Q;e[38]===Symbol.for("react.memo_cache_sentinel")?(Q=r.jsx(dt,{"data-icon":"inline-start"}),e[38]=Q):Q=e[38];let X;e[39]!==_||e[40]!==J?(X=r.jsxs("div",{className:"mt-2 flex items-center justify-end gap-1",children:[Y,r.jsxs(ee,{type:"button",size:"xs",onClick:_,disabled:J,children:[Q,"Start goal"]})]}),e[39]=_,e[40]=J,e[41]=X):X=e[41],T=r.jsxs("section",{className:Xg,"aria-label":`${l} goal editor`,children:[M,V,X]})}else if(j){let D;e[42]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(Co,{className:"size-3.5 shrink-0 text-primary","data-icon":"inline-start"}),e[42]=D):D=e[42];let O;e[43]!==j.condition?(O=r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",title:j.condition,children:j.condition}),e[43]=j.condition,e[44]=O):O=e[44];let M;e[45]!==j.status?(M=YS(j.status),e[45]=j.status,e[46]=M):M=e[46];let F;e[47]!==j.status?(F=GS(j.status),e[47]=j.status,e[48]=F):F=e[48];let z;e[49]!==M||e[50]!==F?(z=r.jsx(Pe,{variant:M,children:F}),e[49]=M,e[50]=F,e[51]=z):z=e[51];const L=j.iterations,W=j.iterations===1?"":"s";let U;e[52]!==j.tokens?(U=ut(j.tokens),e[52]=j.tokens,e[53]=U):U=e[53];let H;e[54]!==j.durationMs?(H=Math.round(j.durationMs/6e4),e[54]=j.durationMs,e[55]=H):H=e[55];const K=Math.max(0,H);let V;e[56]!==j.iterations||e[57]!==W||e[58]!==U||e[59]!==K?(V=r.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[L," turn",W," · ",U," · ",K,"m"]}),e[56]=j.iterations,e[57]=W,e[58]=U,e[59]=K,e[60]=V):V=e[60];let Y;e[61]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx(Vs,{"data-icon":"icon"}),e[61]=Y):Y=e[61];let q;e[62]!==C?(q=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:C,"aria-label":"Replace goal",children:Y}),e[62]=C,e[63]=q):q=e[63];let J;e[64]===Symbol.for("react.memo_cache_sentinel")?(J=r.jsx(Ta,{"data-icon":"icon"}),e[64]=J):J=e[64];let Q;e[65]!==P?(Q=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:P,"aria-label":"Clear goal",children:J}),e[65]=P,e[66]=Q):Q=e[66];let X;e[67]!==q||e[68]!==Q?(X=r.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[q,Q]}),e[67]=q,e[68]=Q,e[69]=X):X=e[69];let Z;e[70]!==z||e[71]!==V||e[72]!==X||e[73]!==O?(Z=r.jsxs("div",{className:"flex items-center gap-2",children:[D,O,z,V,X]}),e[70]=z,e[71]=V,e[72]=X,e[73]=O,e[74]=Z):Z=e[74];let te;e[75]!==j.reason?(te=j.reason&&r.jsx("p",{className:"line-clamp-2 pb-0.5 pl-5 text-xs text-muted-foreground",children:j.reason}),e[75]=j.reason,e[76]=te):te=e[76],T=r.jsxs("section",{className:Yg,"aria-label":`${l} goal`,children:[Z,te]})}e[11]=l,e[12]=C,e[13]=P,e[14]=h,e[15]=m,e[16]=x,e[17]=j,e[18]=_,e[19]=T}else T=e[19];const E=!j&&!m;let $;e[77]!==C||e[78]!==T||e[79]!==E?($={section:T,canCreate:E,beginEditing:C},e[77]=C,e[78]=T,e[79]=E,e[80]=$):$=e[80];const I=$;let R;return e[81]!==i||e[82]!==I?(R=r.jsx(Kd.Provider,{value:I,children:i}),e[81]=i,e[82]=I,e[83]=R):R=e[83],R}function JS(n){const e=B.c(9),{agentKind:t,session:s,onSendCommand:o,children:i}=n,a=Gt(t).goals;if(a==="thread-api"){let l;return e[0]!==t||e[1]!==i||e[2]!==s.sessionId?(l=r.jsx(VS,{agentKind:t,threadId:s.sessionId,children:i}),e[0]=t,e[1]=i,e[2]=s.sessionId,e[3]=l):l=e[3],l}if(a==="transcript"){let l;return e[4]!==t||e[5]!==i||e[6]!==o||e[7]!==s?(l=r.jsx(XS,{agentKind:t,session:s,onSendCommand:o,children:i}),e[4]=t,e[5]=i,e[6]=o,e[7]=s,e[8]=l):l=e[8],l}return i}function Jg(){return Gg().section}function Qg(){const n=B.c(3),{canCreate:e,beginEditing:t}=Gg();if(!e)return null;let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Co,{"data-icon":"inline-start"}),n[0]=s):s=n[0];let o;return n[1]!==t?(o=r.jsxs(ee,{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 QS(){const n=B.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs(r.Fragment,{children:[r.jsx(Jg,{}),r.jsx(Qg,{})]}),n[0]=e):e=n[0],e}const ZS=/\x1b\].*?(?:\x07|\x1b\\)/g,eN=/\x1b\[[0-9;]*[A-Za-z]/g,tN=/\x1b[()][AB012]/g,nN=/\[2K\[1G/g;function Zg(n){return n.replace(ZS,"").replace(eN,"").replace(tN,"").replace(nN,`
|
|
5
|
+
`).replace(/\r/g,"")}function qn(n){const e=B.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(E3,{"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(sN,{}),c=r.jsx(A3,{}),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(T3,{"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 sN(n){const e=B.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($3,{"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(P3,{"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 ex(n){const e=B.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 oN(n){const e=B.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 rN(n){const e=B.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 iN(n){const e=B.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 st(n){const e=B.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=ex,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 aN(n){const e=An("hostFiles"),[t,s]=y.useState([]),[o,i]=y.useState(!1),a=y.useCallback(async()=>{if(!e||!n){s([]);return}i(!0);try{const l=await be(`/api/scripts?dir=${encodeURIComponent(n)}`);if(l.ok){const c=await l.json();s(c)}}catch{}finally{i(!1)}},[e,n]);return y.useEffect(()=>{a()},[a]),{scripts:t,loading:o,refresh:a}}const Dm=500,lN=5e3;function cN(n){const e=B.c(29),t=n===void 0?!0:n,[s,o]=y.useState("disconnected");let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=[],e[0]=i):i=e[0];const[a,l]=y.useState(i),c=y.useRef(null);let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=new Map,e[1]=d):d=e[1];const u=y.useRef(d),f=y.useRef(Dm),m=y.useRef(null),p=y.useRef(!1),h=y.useRef(dN);let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=F=>{var W;const z=F.type,L=F.id;if(z==="sessions"){l(F.sessions??[]);return}L&&((W=u.current.get(L))==null||W(z,F))},e[2]=g):g=e[2];const x=g;let b,w;e[3]!==t?(b=()=>{if(p.current=!1,!t)return()=>{p.current=!0};const F=function(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}${ig()}/__pty`},z=function(){if(p.current||c.current&&c.current.readyState!==WebSocket.CLOSED)return;o("connecting");const W=new WebSocket(F());c.current=W,W.onopen=()=>{if(p.current){W.close();return}f.current=Dm,o("connected"),W.send(JSON.stringify({type:"list"}))},W.onmessage=U=>{try{const H=JSON.parse(U.data);x(H)}catch{}},W.onclose=()=>{if(p.current)return;o("disconnected"),c.current=null;const U=f.current;f.current=Math.min(U*2,lN),m.current=setTimeout(()=>h.current(),U)}};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]=b,e[5]=w):(b=e[4],w=e[5]),y.useEffect(b,w);let v;e[6]!==t?(v=F=>{if(!t)return;const z=c.current;z&&z.readyState===WebSocket.OPEN&&z.send(JSON.stringify(F))},e[6]=t,e[7]=v):v=e[7];const S=v;let j;e[8]===Symbol.for("react.memo_cache_sentinel")?(j=(F,z)=>{u.current.set(F,z)},e[8]=j):j=e[8];const k=j;let C;e[9]===Symbol.for("react.memo_cache_sentinel")?(C=F=>{u.current.delete(F)},e[9]=C):C=e[9];const N=C;let _;e[10]!==S?(_=F=>{const z=F===void 0?{}:F,L=`pty_${crypto.randomUUID().slice(0,8)}`;return S({type:"spawn",id:L,name:z.name??"Terminal",cwd:z.cwd,metadata:{type:"terminal"}}),L},e[10]=S,e[11]=_):_=e[11];const A=_;let P;e[12]!==S?(P=F=>{const z=`script_${crypto.randomUUID().slice(0,8)}`;return S({type:"spawn",id:z,name:F.name,cwd:F.cwd,args:["run",F.scriptName],command:"bun",metadata:{type:"script",source:F.source,scriptName:F.scriptName}}),z},e[12]=S,e[13]=P):P=e[13];const T=P;let E;e[14]!==S?(E=F=>{S({type:"kill",id:F})},e[14]=S,e[15]=E):E=e[15];const $=E;let I;e[16]!==S?(I=(F,z)=>{S({type:"input",id:F,data:z})},e[16]=S,e[17]=I):I=e[17];const R=I;let D;e[18]!==S?(D=(F,z,L)=>{S({type:"resize",id:F,cols:z,rows:L})},e[18]=S,e[19]=D):D=e[19];const O=D;let M;return e[20]!==$||e[21]!==O||e[22]!==S||e[23]!==a||e[24]!==T||e[25]!==A||e[26]!==s||e[27]!==R?(M={status:s,send:S,subscribe:k,unsubscribe:N,sessions:a,spawnTerminal:A,spawnScript:T,killSession:$,writeInput:R,resize:O},e[20]=$,e[21]=O,e[22]=S,e[23]=a,e[24]=T,e[25]=A,e[26]=s,e[27]=R,e[28]=M):M=e[28],M}function dN(){}const tx=y.createContext(null);function Ol(n){const e=B.c(3),{children:t,enabled:s}=n,i=cN(s===void 0?!0:s);let a;return e[0]!==t||e[1]!==i?(a=r.jsx(tx.Provider,{value:i,children:t}),e[0]=t,e[1]=i,e[2]=a):a=e[2],a}function Vd(){const n=y.useContext(tx);if(!n)throw new Error("usePty must be used within a PtyProvider");return n}function uN(n){var u;const e=B.c(11),t=Vd();let s;if(e[0]!==t.sessions){s=new Map;for(const f of t.sessions)((u=f.metadata)==null?void 0:u.type)==="script"&&s.set(f.id,{id:f.id,name:f.name,cwd:f.cwd,status:f.status==="running"?"running":"stopped",source:f.metadata.source??"root/"});e[0]=t.sessions,e[1]=s}else s=e[1];const o=s;let i;e[2]!==n||e[3]!==t?(i=(f,m,p)=>{const h=t.spawnScript({name:f,cwd:m,source:p,scriptName:f}),g=p==="root/"?f:`${p.replace(/\/$/,"")}:${f}`;n==null||n({id:h,name:g,type:"script",status:"running",source:p})},e[2]=n,e[3]=t,e[4]=i):i=e[4];const a=i;let l;e[5]!==t?(l=f=>{t.killSession(f)},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 fN(n){const e=B.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 u;e[0]!==l?(u=G("size-1.5 shrink-0 rounded-full",l),e[0]=l,e[1]=u):u=e[1];let f;e[2]!==u?(f=r.jsx("span",{className:u}),e[2]=u,e[3]=f):f=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(Sd,{"data-icon":"inline-end",className:"fill-current text-destructive"}):r.jsx(Dr,{"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]!==f||e[11]!==m||e[12]!==p?(h=r.jsxs(ee,{type:"button",variant:"ghost",size:"sm",className:"motion-list-item group w-full justify-start px-2",onClick:c,title:d,children:[f,m,p]}),e[8]=c,e[9]=d,e[10]=f,e[11]=m,e[12]=p,e[13]=h):h=e[13],h}const mN=y.memo(function(e){const t=B.c(42),{projectDir:s,onProcessStarted:o}=e,[i,a]=y.useState(!1),[l,c]=y.useState("");let d;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=new Set,t[0]=d):d=t[0];const[u,f]=y.useState(d),{scripts:m,loading:p}=aN(s),{runningProcesses:h,runScript:g,stopScript:x}=uN(o);let b;if(t[1]!==m||t[2]!==l){const z=l.trim().toLowerCase(),L=z?m.filter(W=>W.name.toLowerCase().includes(z)||W.dirLabel.toLowerCase().includes(z)):m;b=new Map;for(const W of L){const U=b.get(W.dirLabel)??[];U.push(W),b.set(W.dirLabel,U)}t[1]=m,t[2]=l,t[3]=b}else b=t[3];const w=b;let v;if(t[4]!==h){v=new Map;for(const[z,L]of h)v.set(`${L.name}:${L.cwd}`,{id:z,status:L.status});t[4]=h,t[5]=v}else v=t[5];const S=v;if(!s||!p&&m.length===0)return null;let j;t[6]===Symbol.for("react.memo_cache_sentinel")?(j=function(L){f(W=>{const U=new Set(W);return U.has(L)?U.delete(L):U.add(L),U})},t[6]=j):j=t[6];const k=j;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 N;t[8]!==p?(N=p&&r.jsx(st,{className:"size-3 text-muted-foreground","aria-label":"Loading scripts"}),t[8]=p,t[9]=N):N=t[9];const _=i?"Close script search":"Search scripts";let A,P;t[10]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{a(pN),c("")},P=r.jsx(an,{}),t[10]=A,t[11]=P):(A=t[10],P=t[11]);let T;t[12]!==i||t[13]!==_?(T=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm","aria-label":_,"aria-expanded":i,onClick:A,children:P}),t[12]=i,t[13]=_,t[14]=T):T=t[14];let E;t[15]!==N||t[16]!==T?(E=r.jsxs("div",{className:"flex h-8 shrink-0 items-center gap-2 px-2",children:[C,N,T]}),t[15]=N,t[16]=T,t[17]=E):E=t[17];let $;t[18]!==i||t[19]!==l?($=i&&r.jsx("div",{className:"motion-slide-down-in px-2 pb-2",children:r.jsx(Dt,{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]=$):$=t[20];let I;t[21]!==u||t[22]!==w||t[23]!==g||t[24]!==S||t[25]!==l||t[26]!==x?(I=[...w.entries()].map(z=>{const[L,W]=z,U=u.has(L)||!!l,H=W.filter(hN),K=W.filter(gN),V=U?W:H.length>0?H:W.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:L}),V.map(Y=>{const q=S.get(`${Y.name}:${Y.dir}`);return r.jsx(fN,{script:Y,status:(q==null?void 0:q.status)??null,onRun:()=>g(Y.name,Y.dir,Y.dirLabel),onStop:()=>{q&&x(q.id)}},`${L}:${Y.name}`)}),!l&&K.length>0&&r.jsx(ee,{type:"button",variant:"link",size:"sm",className:"h-auto justify-start px-2 py-1",onClick:()=>k(L),children:U?"Show less":`Show ${K.length} more`})]},L)}),t[21]=u,t[22]=w,t[23]=g,t[24]=S,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(ln,{className:"gap-1 p-3",children:r.jsxs(cn,{className:"gap-1",children:[r.jsx(dn,{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 D;t[32]!==I||t[33]!==R?(D=r.jsxs(qn,{className:"min-h-0 flex-1 px-1 pb-1",children:[I,R]}),t[32]=I,t[33]=R,t[34]=D):D=t[34];let O;t[35]!==$||t[36]!==D||t[37]!==E?(O=r.jsxs("section",{className:"flex w-56 shrink-0 flex-col","aria-label":"Scripts",children:[E,$,D]}),t[35]=$,t[36]=D,t[37]=E,t[38]=O):O=t[38];let M;t[39]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(Nt,{orientation:"vertical"}),t[39]=M):M=t[39];let F;return t[40]!==O?(F=r.jsxs(r.Fragment,{children:[O,M]}),t[40]=O,t[41]=F):F=t[41],F});function pN(n){return!n}function hN(n){return n.isCommon}function gN(n){return!n.isCommon}function Va(n){const e=B.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(M3,{"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 xN=ns("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 Ga(n){const e=B.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(xN({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(D3,{"data-slot":"tabs-indicator","data-variant":a,className:c}),e[9]=a,e[10]=d):d=e[10];let u;return e[11]!==t||e[12]!==o||e[13]!==l||e[14]!==d||e[15]!==a?(u=r.jsxs(I3,{"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]=u):u=e[16],u}function Dn(n){const e=B.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(O3,{"data-slot":"tabs-trigger",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Ln(n){const e=B.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(R3,{"data-slot":"tabs-content",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const bN=y.lazy(()=>qe(()=>import("./TerminalOutput-Cpqldw8o.js"),__vite__mapDeps([0,1,2,3,4,5])).then(n=>({default:n.TerminalOutput})));function vN({process:n}){const[e,t]=y.useState(""),[s,o]=y.useState(!1),i=y.useRef(null);return y.useEffect(()=>{let a;if(n.type==="task"&&n.outputPath)a=Wr(`/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 u=Zg(d.text);u&&t(f=>{const m=f+u;return m.length>1e5?m.slice(-1e5):m})}}catch{}},l.onerror=()=>{},()=>l.close()},[n.id,n.type,n.outputPath]),y.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 yN(n){const e=B.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 u;e[0]!==s||e[1]!==o?(u=()=>{s&&o()},e[0]=s,e[1]=o,e[2]=u):u=e[2];const f=a?"gap-1 px-1.5":"gap-1.5 px-2";let m;e[3]!==f?(m=G("h-6 min-w-0 justify-start py-0 text-xs",f),e[3]=f,e[4]=m):m=e[4];let p;e[5]!==t.status?(p=t.status==="running"&&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 b;e[11]!==x?(b=G("px-1 py-0 font-normal",x),e[11]=x,e[12]=b):b=e[12];let w;e[13]!==t.type||e[14]!==b?(w=r.jsx(Pe,{variant:"secondary",className:b,children:t.type}),e[13]=t.type,e[14]=b,e[15]=w):w=e[15];let v;e[16]!==t.id||e[17]!==t.name||e[18]!==w||e[19]!==u||e[20]!==m||e[21]!==p||e[22]!==h||e[23]!==g?(v=r.jsxs(Dn,{value:c,"aria-label":d,onClick:u,className:m,children:[p,h,g,w]}),e[16]=t.id,e[17]=t.name,e[18]=w,e[19]=u,e[20]=m,e[21]=p,e[22]=h,e[23]=g,e[24]=v):v=e[24];const S=`Close ${t.name}`,j=`Close ${t.name}`;let k;e[25]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(nt,{"data-icon":"inline-start"}),e[25]=k):k=e[25];let C;e[26]!==i||e[27]!==S||e[28]!==j?(C=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs","aria-label":S,title:j,onClick:i,className:"mr-0.5 text-muted-foreground",children:k}),e[26]=i,e[27]=S,e[28]=j,e[29]=C):C=e[29];let N;return e[30]!==l||e[31]!==v||e[32]!==C?(N=r.jsxs("div",{title:l,className:"inline-flex h-6 shrink-0 items-center",children:[v,C]}),e[30]=l,e[31]=v,e[32]=C,e[33]=N):N=e[33],N}const nx=100,sx=600,wN=200,ox="process-panel-height";function jN(){try{const n=localStorage.getItem(ox);if(n)return Math.min(sx,Math.max(nx,Number(n)))}catch{}return wN}const SN=y.memo(function(e){const t=B.c(89),{processes:s,activeProcessId:o,collapsed:i,onSetActive:a,onRemove:l,onToggleCollapse:c,onRequestTerminal:d,onAddTerminalContext:u,onUpdateStatus:f,projectDir:m,onProcessStarted:p,mobile:h}=e,g=h===void 0?!1:h,x=Vd(),[b,w]=y.useState(jN),v=y.useRef(null);let S,j;t[0]!==f||t[1]!==x.sessions?(S=()=>{for(const ie of x.sessions)ie.status==="exited"&&(f==null||f(ie.id,"stopped"))},j=[x.sessions,f],t[0]=f,t[1]=x.sessions,t[2]=S,t[3]=j):(S=t[2],j=t[3]),y.useEffect(S,j);let k;t[4]!==l||t[5]!==x?(k=ie=>{ie.type!=="task"&&x.killSession(ie.id),l(ie.id)},t[4]=l,t[5]=x,t[6]=k):k=t[6];const C=k;let N;t[7]!==b?(N=ie=>{ie.preventDefault(),v.current={startY:ie.clientY,startH:b},ie.target.setPointerCapture(ie.pointerId)},t[7]=b,t[8]=N):N=t[8];const _=N;let A;t[9]===Symbol.for("react.memo_cache_sentinel")?(A=ie=>{if(!v.current)return;const ge=v.current.startY-ie.clientY,pe=Math.min(sx,Math.max(nx,v.current.startH+ge));w(pe)},t[9]=A):A=t[9];const P=A;let T;t[10]!==b?(T=()=>{if(v.current){v.current=null;try{localStorage.setItem(ox,String(b))}catch{}}},t[10]=b,t[11]=T):T=t[11];const E=T;let $;t[12]!==o||t[13]!==s?($=o?s.get(o):null,t[12]=o,t[13]=s,t[14]=$):$=t[14];const I=$;let R;t[15]!==s?(R=[...s.values()],t[15]=s,t[16]=R):R=t[16];const D=R;let O;t[17]!==a?(O=ie=>{typeof ie=="string"&&a(ie)},t[17]=a,t[18]=O):O=t[18];let M;t[19]!==I||t[20]!==i||t[21]!==g||t[22]!==_||t[23]!==E?(M=!g&&!i&&I&&r.jsx("div",{className:"h-1 cursor-row-resize transition-colors hover:bg-accent active:bg-muted-foreground/30",onPointerDown:_,onPointerMove:P,onPointerUp:E,onPointerCancel:E}),t[19]=I,t[20]=i,t[21]=g,t[22]=_,t[23]=E,t[24]=M):M=t[24];const F=g?"h-7 gap-1 px-2":"h-8 gap-2 px-3";let z;t[25]!==F?(z=G("flex shrink-0 items-center border-b bg-card",F),t[25]=F,t[26]=z):z=t[26];const L=i?"Expand terminal panel":"Collapse terminal panel",W=!i;let U;t[27]!==i?(U=i?r.jsx(Xe,{"data-icon":"inline-start"}):r.jsx(it,{"data-icon":"inline-start"}),t[27]=i,t[28]=U):U=t[28];const H=g&&"sr-only";let K;t[29]!==H?(K=G(H),t[29]=H,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]!==L||t[35]!==W||t[36]!==U||t[37]!==V?(Y=r.jsxs(ee,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2",onClick:c,"aria-label":L,"aria-expanded":W,children:[U,V]}),t[33]=c,t[34]=L,t[35]=W,t[36]=U,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 Q;t[41]!==o||t[42]!==C||t[43]!==g||t[44]!==a||t[45]!==D?(Q=D.map(ie=>r.jsx(yN,{process:ie,isActive:ie.id===o,onSelectActive:()=>a(ie.id),onClose:()=>C(ie),mobile:g},ie.id)),t[41]=o,t[42]=C,t[43]=g,t[44]=a,t[45]=D,t[46]=Q):Q=t[46];let X;t[47]!==J||t[48]!==Q?(X=r.jsx(Ga,{variant:"default","aria-label":"Open processes",className:J,children:Q}),t[47]=J,t[48]=Q,t[49]=X):X=t[49];let Z;t[50]!==d||t[51]!==m?(Z=d&&r.jsx(ee,{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(Fn,{})}),t[50]=d,t[51]=m,t[52]=Z):Z=t[52];let te;t[53]!==z||t[54]!==Y||t[55]!==X||t[56]!==Z?(te=r.jsxs("div",{className:z,children:[Y,X,Z]}),t[53]=z,t[54]=Y,t[55]=X,t[56]=Z,t[57]=te):te=t[57];const ne=!i,oe=g?"min(36dvh, 260px)":b;let re;t[58]!==oe?(re={height:oe},t[58]=oe,t[59]=re):re=t[59];let ae;t[60]!==g||t[61]!==p||t[62]!==m?(ae=!g&&r.jsx(mN,{projectDir:m,onProcessStarted:p}),t[60]=g,t[61]=p,t[62]=m,t[63]=ae):ae=t[63];let se;t[64]!==C||t[65]!==u||t[66]!==d||t[67]!==D?(se=D.map(ie=>r.jsx(Ln,{value:ie.id,className:"col-start-1 row-start-1 flex min-h-0 flex-col",children:ie.type==="task"?r.jsx(vN,{process:ie}):r.jsx(y.Suspense,{fallback:r.jsx("div",{className:"flex size-full items-center justify-center text-xs text-muted-foreground",children:"Loading terminal…"}),children:r.jsx(bN,{processId:ie.id,autoFocus:!0,onRequestNew:d,onRequestClose:()=>C(ie),onAddContext:u})})},ie.id)),t[64]=C,t[65]=u,t[66]=d,t[67]=D,t[68]=se):se=t[68];let de;t[69]!==I||t[70]!==d||t[71]!==m?(de=!I&&r.jsxs(ln,{className:"col-start-1 row-start-1 rounded-none",children:[r.jsxs(cn,{children:[r.jsx(bn,{variant:"icon",children:r.jsx(Gs,{})}),r.jsx(dn,{children:"No terminal open"}),r.jsx(vn,{children:"Start a terminal here or run a project script from the left."})]}),d&&m&&r.jsx(og,{children:r.jsxs(ee,{type:"button",size:"sm",onClick:d,children:[r.jsx(Fn,{"data-icon":"inline-start"}),"New terminal"]})})]}),t[69]=I,t[70]=d,t[71]=m,t[72]=de):de=t[72];let le;t[73]!==se||t[74]!==de?(le=r.jsxs("div",{className:"grid min-h-0 min-w-0 flex-1 grid-cols-1",children:[se,de]}),t[73]=se,t[74]=de,t[75]=le):le=t[75];let ce;t[76]!==re||t[77]!==ae||t[78]!==le?(ce=r.jsx(mt,{children:r.jsxs("div",{className:"flex min-h-0",style:re,children:[ae,le]})}),t[76]=re,t[77]=ae,t[78]=le,t[79]=ce):ce=t[79];let me;t[80]!==ne||t[81]!==ce?(me=r.jsx(ft,{open:ne,className:"min-h-0",children:ce}),t[80]=ne,t[81]=ce,t[82]=me):me=t[82];let ue;return t[83]!==o||t[84]!==O||t[85]!==M||t[86]!==te||t[87]!==me?(ue=r.jsxs(Va,{value:o,onValueChange:O,className:"shrink-0 gap-0 border-t bg-background",children:[M,te,me]}),t[83]=o,t[84]=O,t[85]=M,t[86]=te,t[87]=me,t[88]=ue):ue=t[88],ue});function Xr(n){const e=B.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 NN=/(?::(\d{4,5}))|(?:port\s+(\d{4,5}))|(?:localhost:(\d{4,5}))/gi;function kN(n){const e=new Set;for(const t of n.matchAll(NN)){const s=parseInt(t[1]||t[2]||t[3],10);s>0&&s<65536&&e.add(s)}return[...e]}function CN(n){var s;const e=B.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(" "),u=kN(d);if(u.length===0){const p=a.toLowerCase();(p.includes("run dev")||p.includes("next dev")||p.includes("vite"))&&u.push(3e3)}const f=(i.result||"").match(/Output is being written to:\s*(\S+)/),m=f?f[1]:null;for(const p of u)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 Lm(n){var e;return((e=n.preview.split(`
|
|
6
|
+
`).find(t=>t.trim()))==null?void 0:e.trim())||`Task ${n.id}`}function _N(n){const e=B.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(Pe,{variant:"secondary",className:"font-mono",children:[a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d}function rx({cwd:n,turns:e,onToggleServer:t,onServersChanged:s}){const[o,i]=y.useState([]),a=CN(e);y.useEffect(()=>{if(!n)return;let c=!1;async function d(){try{const f=await be(`/api/background-tasks?cwd=${encodeURIComponent(n)}`);if(c)return;if(f.ok){const h=await f.json();if(c)return;if(h.length>0){i(h);return}}if(a.size===0){i([]);return}const m=[...a.keys()],p=await be(`/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[b,w]of a)!h[b]||x.has(b)||(x.add(b),g.push({id:`port-${b}`,outputPath:w.outputPath,ports:[b],portStatus:{[b]:!0},preview:w.description}));i(g)}}catch{}}d();const u=setInterval(d,1e4);return()=>{c=!0,clearInterval(u)}},[n,a]);const l=y.useCallback(async c=>{try{await be("/api/kill-port",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({port:c})}),setTimeout(()=>{i(d=>d.filter(u=>!u.ports.includes(c)))},1500)}catch{}},[]);return y.useEffect(()=>{if(!s)return;const c=o.filter(d=>d.outputPath).map(d=>({id:d.id,outputPath:d.outputPath,title:Lm(d)}));s(c)},[o,s]),o.length===0?null:r.jsxs("section",{children:[r.jsxs(Xr,{children:["Active Servers (",o.length,")"]}),r.jsx("div",{className:"flex flex-col gap-1.5",children:o.map(c=>{const d=c.ports.filter(f=>c.portStatus[f]),u=Lm(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(I1,{className:"size-3 shrink-0 text-success","data-icon":"inline-start"}),r.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:u})]}),r.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[c.ports.map(f=>r.jsx(_N,{port:f,isActive:c.portStatus[f]},f)),r.jsx("div",{className:"flex-1"}),c.outputPath&&r.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:()=>t==null?void 0:t(c.id,c.outputPath,u),title:"View server output","aria-label":"View server output",children:r.jsx(Gs,{"data-icon":"inline-start"})}),d.length>0&&r.jsxs(ee,{variant:"ghost",size:"xs",className:"text-destructive",onClick:()=>d.forEach(f=>l(f)),title:"Stop server","aria-label":"Stop server",children:[r.jsx(Sd,{"data-icon":"inline-start",className:"fill-current"}),r.jsx("span",{children:"Stop"})]})]})]},c.id)})})]})}function Gd(n){const e=B.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(L3,{"data-slot":"alert-dialog",...t}),e[2]=t,e[3]=s):s=e[3],s}function TN(n){const e=B.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(z3,{"data-slot":"alert-dialog-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function EN(n){const e=B.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(yd,{"data-slot":"alert-dialog-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function AN(n){const e=B.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(wd,{"data-slot":"alert-dialog-overlay",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Yd(n){const e=B.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(AN,{}),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(EN,{children:[a,r.jsx(vd,{"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 Xd(n){const e=B.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 Jd(n){const e=B.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 PN(n){const e=B.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 Qd(n){const e=B.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(xd,{"data-slot":"alert-dialog-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Zd(n){const e=B.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(bd,{"data-slot":"alert-dialog-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function eu(n){const e=B.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(ee,{"data-slot":"alert-dialog-action",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function tu(n){const e=B.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(ee,{variant:a,size:l}),e[7]=l,e[8]=a,e[9]=d):d=e[9];let u;return e[10]!==s||e[11]!==c||e[12]!==d?(u=r.jsx(Mr,{"data-slot":"alert-dialog-cancel",className:c,render:d,...s}),e[10]=s,e[11]=c,e[12]=d,e[13]=u):u=e[13],u}function ix(n){const e=B.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(B3,{"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(F3,{"data-slot":"checkbox",className:o,...s,children:i}),e[6]=s,e[7]=o,e[8]=a):a=e[8],a}const $N={undo:"Undo turns?",redo:"Redo turns?","branch-switch":"Switch branch?"},RN={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 IN({state:n,isApplying:e,applyError:t,onConfirm:s,onCancel:o}){var f,m;const i=y.useRef(n),[a,l]=y.useState({key:"",selected:!1});y.useEffect(()=>{n&&(i.current=n)},[n]);const c=n??i.current;if(!c)return null;const d=((f=c.nativeRewind)==null?void 0:f.eventId)??`${c.type}:${c.targetTurnIndex}:${c.branchId??""}`,u=a.key===d&&a.selected;return r.jsx(Gd,{open:n!==null,onOpenChange:p=>{p||o()},onOpenChangeComplete:p=>{p||(i.current=null,l({key:"",selected:!1}))},children:r.jsxs(Yd,{children:[r.jsxs(Xd,{children:[r.jsx(PN,{children:r.jsx(gn,{className:"text-warning"})}),r.jsx(Qd,{children:$N[c.type]}),r.jsx(Zd,{children:c.nativeRewind?u?"This removes the selected turn and everything after it, restoring captured files.":"This removes the selected turn and everything after it. Files stay unchanged.":RN[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.nativeRewind)==null?void 0:m.filesAvailable)&&r.jsxs("label",{className:"mt-2 flex items-center gap-2 text-sm text-foreground",children:[r.jsx(ix,{checked:u,disabled:e,onCheckedChange:p=>l({key:d,selected:p===!0})}),"Restore captured file changes"]})]}),t&&r.jsx(pt,{variant:"destructive",children:r.jsx(ht,{children:t})}),r.jsxs(Jd,{children:[r.jsx(tu,{onClick:o,disabled:e,children:"Cancel"}),r.jsx(eu,{onClick:()=>s(u),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 on(n){const e=B.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 un(n){const e=B.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 fn(n){const e=B.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 mn(n){const e=B.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 ax(n){const e=B.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 rn(n){const e=B.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 Jr(n){const e=B.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 ls(n){const e=B.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 MN=ns("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 Pn(n){const e=B.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(MN({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:ON,...s}),e[7]=i,e[8]=s,e[9]=a,e[10]=l):l=e[10],l}function ON(n){var e,t;n.target.closest("button")||(t=(e=n.currentTarget.parentElement)==null?void 0:e.querySelector("input"))==null||t.focus()}const DN=ns("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 Qr(n){const e=B.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 u;e[6]!==t||e[7]!==d?(u=G(DN({size:d}),t),e[6]=t,e[7]=d,e[8]=u):u=e[8];let f;return e[9]!==s||e[10]!==d||e[11]!==u||e[12]!==l||e[13]!==c?(f=r.jsx(ee,{type:l,"data-size":d,variant:c,className:u,...s}),e[9]=s,e[10]=d,e[11]=u,e[12]=l,e[13]=c,e[14]=f):f=e[14],f}function cs(n){const e=B.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(Dt,{"data-slot":"input-group-control",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function LN(){const[n,e]=y.useState("idle"),[t,s]=y.useState(null),o=y.useRef(void 0),i=y.useCallback(async d=>{if(!d.trim()){e("idle"),s(null);return}e("validating"),s(null);try{const f=await(await be(`/api/config/validate?path=${encodeURIComponent(d)}`)).json();f.valid?(e("valid"),s(null)):(e("invalid"),s(f.error||"Invalid path"))}catch{e("invalid"),s("Failed to validate path")}},[]),a=y.useCallback(d=>{clearTimeout(o.current),o.current=setTimeout(()=>i(d),400)},[i]),l=y.useCallback(()=>{e("idle"),s(null),clearTimeout(o.current)},[]),c=y.useCallback(async(d,u)=>{try{const f=await be("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({claudeDir:d,...u})}),m=await f.json();return f.ok&&m.success?{success:!0,claudeDir:m.claudeDir}:(s(m.error||"Failed to save"),e("invalid"),{success:!1,error:m.error})}catch{return s("Failed to save configuration"),{success:!1,error:"Network error"}}},[]);return y.useEffect(()=>()=>clearTimeout(o.current),[]),{status:n,error:t,debouncedValidate:a,validate:i,reset:l,save:c}}const po=Jw(n=>!n.cli.homeIsDiscoverable,"a home Cogpit has to be told about"),lx=Oa().filter(n=>n.cli.homeIsDiscoverable);function cx(n){return n.flatMap((e,t)=>t===0?[e]:[t===n.length-1?" and ":", ",e])}function dx(n){const e=B.c(2),{children:t}=n;let s;return e[0]!==t?(s=r.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-xs text-foreground",children:t}),e[0]=t,e[1]=s):s=e[1],s}const zN=cx(lx.map(n=>n.displayName)),FN=cx(lx.map(n=>r.jsx(dx,{children:["~",n.cli.homeDirName,n.cli.installMarker].filter(Boolean).join("/")},n.kind))),BN=`~/${po.cli.homeDirName}`;function UN(n){const e=B.c(46),{onConfigured:t}=n,[s,o]=y.useState(""),[i,a]=y.useState(!1),{status:l,error:c,debouncedValidate:d,save:u}=LN();let f;e[0]!==d?(f=M=>{const F=M.target.value;o(F),d(F)},e[0]=d,e[1]=f):f=e[1];const m=f;let p;e[2]!==t||e[3]!==s||e[4]!==u?(p=async()=>{a(!0);const M=await u(s);M.success&&M.claudeDir&&t(M.claudeDir),a(!1)},e[2]=t,e[3]=s,e[4]=u,e[5]=p):p=e[5];const h=p;let g;e[6]!==h||e[7]!==i||e[8]!==l?(g=M=>{M.preventDefault(),l==="valid"&&!i&&h()},e[6]=h,e[7]=i,e[8]=l,e[9]=g):g=e[9];let x,b;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(jd,{className:"size-4"})}),b=r.jsx(fn,{children:"Connect your coding agent"}),e[10]=x,e[11]=b):(x=e[10],b=e[11]);let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsxs(un,{children:[x,b,r.jsxs(mn,{children:["Cogpit detects ",zN," automatically. Existing histories live in"," ",FN,"."," ","For ",po.displayName,", enter its data directory, usually"," ",r.jsx(dx,{children:BN}),"."]})]}),e[12]=w):w=e[12];const v=l==="invalid";let S;e[13]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsxs(St,{htmlFor:"agent-data-directory",children:[po.displayName," data directory"]}),e[13]=S):S=e[13];let j;e[14]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(Pn,{children:r.jsx(_o,{"aria-hidden":"true"})}),e[14]=j):j=e[14];const k=l==="invalid";let C;e[15]!==m||e[16]!==s||e[17]!==k?(C=r.jsxs(ls,{children:[j,r.jsx(cs,{id:"agent-data-directory",value:s,onChange:m,placeholder:`/Users/you/${po.cli.homeDirName}`,autoFocus:!0,"aria-invalid":k,"aria-describedby":"agent-directory-status"})]}),e[15]=m,e[16]=s,e[17]=k,e[18]=C):C=e[18];let N;e[19]!==l?(N=l==="validating"&&r.jsxs(Eo,{className:"flex items-center gap-2",children:[r.jsx(st,{className:"size-4"}),"Checking path..."]}),e[19]=l,e[20]=N):N=e[20];let _;e[21]!==l?(_=l==="valid"&&r.jsxs(Eo,{className:"flex items-center gap-2 text-success",children:[r.jsx(Or,{className:"size-4"}),po.displayName," history found"]}),e[21]=l,e[22]=_):_=e[22];let A;e[23]!==c||e[24]!==l?(A=l==="invalid"&&c&&r.jsxs(bs,{className:"flex items-center gap-2",children:[r.jsx(Ys,{className:"size-4"}),c]}),e[23]=c,e[24]=l,e[25]=A):A=e[25];let P;e[26]!==N||e[27]!==_||e[28]!==A?(P=r.jsxs("div",{id:"agent-directory-status",className:"min-h-5",role:"status","aria-live":"polite",children:[N,_,A]}),e[26]=N,e[27]=_,e[28]=A,e[29]=P):P=e[29];let T;e[30]!==C||e[31]!==P||e[32]!==v?(T=r.jsx(rn,{children:r.jsx(Mo,{children:r.jsxs(jt,{"data-invalid":v,children:[S,C,P]})})}),e[30]=C,e[31]=P,e[32]=v,e[33]=T):T=e[33];const E=l!=="valid"||i;let $;e[34]!==i?($=i&&r.jsx(st,{"data-icon":"inline-start"}),e[34]=i,e[35]=$):$=e[35];const I=i?"Saving...":`Connect ${po.displayName}`;let R;e[36]!==E||e[37]!==$||e[38]!==I?(R=r.jsx(Jr,{children:r.jsxs(ee,{type:"submit",className:"w-full",disabled:E,children:[$,I]})}),e[36]=E,e[37]=$,e[38]=I,e[39]=R):R=e[39];let D;e[40]!==T||e[41]!==R?(D=r.jsxs(on,{children:[w,T,R]}),e[40]=T,e[41]=R,e[42]=D):D=e[42];let O;return e[43]!==D||e[44]!==g?(O=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:D})}),e[43]=D,e[44]=g,e[45]=O):O=e[45],O}const ux=/^[a-z]:[\\/]/i;function nu(n){return(ux.test(n)?n.replace(/\\/g,"/"):n).replace(/\/+$/,"")||"/"}function zm(n){const e=nu(n);return ux.test(n)?e.toLowerCase():e}function WN(n){const e=nu(n),t=e.lastIndexOf("/");return t<0?e:t===0?"/":e.slice(0,t)}function Fm(n,e){const t=zm(n),s=zm(e);if(t===s)return"";const o=t==="/"?"/":`${t}/`;return s.startsWith(o)?nu(e).slice(o.length):null}let su=!1;function HN(n){su=n}function ou(){return su}let ar=null;function qN(n){return ar=n,()=>{ar===n&&(ar=null)}}function KN(n,e){if(!n.path)return null;if(n.kind==="project")return{root:n.path,file:null,mode:"edit"};if(e){const o=Fm(e,n.path);if(o)return{root:e,file:o,mode:Bm(n),line:n.line}}const t=WN(n.path),s=Fm(t,n.path);return s?{root:t,file:s,mode:Bm(n),line:n.line}:null}function Bm(n){return n.mode==="diff"?"diff":"edit"}function fx(n){return su&&ar!==null&&ar(n)}function mx(n,e){be(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).catch(()=>{})}function yr(n,e={}){if(ot("hostFiles")&&!fx({kind:"file",path:n,...e})){if(Ws()){Ur(n);return}mx("/api/open-in-editor",{path:n,mode:e.mode??"file",line:e.line,column:e.column})}}function px(n){ot("hostFiles")&&(n.path&&fx({kind:"project",path:n.path})||gx("/api/open-in-editor",n))}function hx(n){ot("hostFiles")&&gx("/api/reveal-in-folder",n)}function gx(n,e){!e.path&&!e.dirName||mx(n,{path:e.path||void 0,dirName:e.dirName||void 0})}let Dl=null;const Wc=new Set,$i=new Map,Um=["typescript","tsx","javascript","jsx","json","css","html","python","bash","yaml","markdown"],xx={typescript:()=>qe(()=>import("./typescript-BPQ3VLAy.js"),[]),tsx:()=>qe(()=>import("./tsx-COt5Ahok.js"),[]),javascript:()=>qe(()=>import("./javascript-wDzz0qaB.js"),[]),jsx:()=>qe(()=>import("./jsx-g9-lgVsj.js"),[]),json:()=>qe(()=>import("./json-Cp-IABpG.js"),[]),css:()=>qe(()=>import("./css-DPfMkruS.js"),[]),html:()=>qe(()=>import("./html-GMplVEZG.js"),__vite__mapDeps([6,7,8])),python:()=>qe(()=>import("./python-B6aJPvgy.js"),[]),bash:()=>qe(()=>import("./bash-Yzrsuije.js"),[]),yaml:()=>qe(()=>import("./yaml-Buea-lGh.js"),[]),markdown:()=>qe(()=>import("./markdown-Cvjx9yec.js"),[]),rust:()=>qe(()=>import("./rust-B1yitclQ.js"),[]),go:()=>qe(()=>import("./go-CxLEBnE3.js"),[]),toml:()=>qe(()=>import("./toml-vGWfd6FD.js"),[]),sql:()=>qe(()=>import("./sql-BLtJtn59.js"),[]),c:()=>qe(()=>import("./c-BIGW1oBm.js"),[]),cpp:()=>qe(()=>import("./cpp-BRuaLJcg.js"),__vite__mapDeps([9,10,11])),java:()=>qe(()=>import("./java-CylS5w8V.js"),[]),ruby:()=>qe(()=>import("./ruby-B0Tyh1qT.js"),__vite__mapDeps([12,6,7,8,13,14,11,15,16,17,9,10,18,19])),swift:()=>qe(()=>import("./swift-D82vCrfD.js"),[]),kotlin:()=>qe(()=>import("./kotlin-BdnUsdx6.js"),[]),php:()=>qe(()=>import("./php-aq0itWAE.js"),__vite__mapDeps([20,6,7,8,13,14,11,21])),vue:()=>qe(()=>import("./vue-DVfSmUF7.js"),__vite__mapDeps([22,8,7,15,21,6])),svelte:()=>qe(()=>import("./svelte-DZMnMd3x.js"),__vite__mapDeps([23,7,15,8])),scss:()=>qe(()=>import("./scss-OYdSNvt2.js"),__vite__mapDeps([24,8]))};function bx(){return Dl||(Dl=(async()=>{const[n,e,...t]=await Promise.all([qe(()=>import("./github-dark-DHJKELXO.js"),[]).then(o=>o.default),qe(()=>import("./github-light-DAi9KRSo.js"),[]).then(o=>o.default),...Um.map(o=>xx[o]().then(i=>i.default))]),s=await Uw({themes:[n,e],langs:t,engine:Ww()});for(const o of Um)Wc.add(o);return s})()),Dl}async function vx(n,e){if(Wc.has(e))return;if($i.has(e))return $i.get(e);const t=xx[e];if(!t)return;const s=t().then(async o=>{await n.loadLanguage(o.default),Wc.add(e)}).finally(()=>$i.delete(e));$i.set(e,s),await s}const VN={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 yx(n){var t;const e=((t=n.split(".").pop())==null?void 0:t.toLowerCase())??"";return VN[e]??null}async function wx(n,e,t){try{const s=await bx();await vx(s,e);const o=t?"github-dark":"github-light";return s.codeToTokens(n,{lang:e,theme:o}).tokens}catch{return null}}function Zr(){const n=B.c(2),[e,t]=y.useState(GN);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]),y.useEffect(s,o),e}function GN(){return typeof document<"u"&&document.documentElement.classList.contains("dark")}const YN={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 XN(n){return YN[n.toLowerCase()]??n}function JN(n){if(!n)return null;const e=n.match(/language-(\S+)/);return(e==null?void 0:e[1])??null}function QN(n){const e=B.c(10),{text:t}=n,[s,o]=y.useState(!1),i=y.useRef(null),a=y.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]),y.useEffect(l,c);let d;e[2]!==t?(d=function(){const g=a.current=a.current+1;Ur(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 u=d,f=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(xn,{"data-icon":"icon"}),e[4]=s,e[5]=m):m=e[5];let p;return e[6]!==u||e[7]!==f||e[8]!==m?(p=r.jsx(ee,{type:"button",variant:"ghost",size:"xs",onClick:u,className:"text-muted-foreground",title:"Copy code","aria-label":f,children:m}),e[6]=u,e[7]=f,e[8]=m,e[9]=p):p=e[9],p}function ZN(n){const e=B.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 ek(n){const e=B.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=JN(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 u=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 f;return e[12]!==u||e[13]!==l||e[14]!==o?(f=r.jsx(tk,{code:u,lang:l,...o}),e[12]=u,e[13]=l,e[14]=o,e[15]=f):f=e[15],f}function tk(n){const e=B.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=Zr(),[a,l]=y.useState(null),[c,d]=y.useState(!1),u=t.split(`
|
|
8
|
+
`),f=u.length,m=f>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 T=!1;return wx(t,s,i).then(E=>{T||l({key:p,lines:E})}),()=>{T=!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]),y.useEffect(g,x);const b=c?Xe:it,w="my-3 overflow-hidden rounded-lg border border-border bg-muted/20";let v;e[10]!==b||e[11]!==c||e[12]!==m?(v=m&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>d(!c),className:"text-muted-foreground","aria-label":c?"Expand code":"Collapse code",children:r.jsx(b,{"data-icon":"icon"})}),e[10]=b,e[11]=c,e[12]=m,e[13]=v):v=e[13];let S;e[14]!==s?(S=s&&r.jsx(Pe,{variant:"ghost",className:"px-0 uppercase tracking-wide text-muted-foreground",children:XN(s)}),e[14]=s,e[15]=S):S=e[15];let j;e[16]!==m||e[17]!==f?(j=m&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:[f," lines"]}),e[16]=m,e[17]=f,e[18]=j):j=e[18];let k;e[19]!==v||e[20]!==S||e[21]!==j?(k=r.jsxs("div",{className:"flex items-center gap-2",children:[v,S,j]}),e[19]=v,e[20]=S,e[21]=j,e[22]=k):k=e[22];let C;e[23]!==t?(C=r.jsx(QN,{text:t}),e[23]=t,e[24]=C):C=e[24];let N;e[25]!==k||e[26]!==C?(N=r.jsxs("div",{className:"flex items-center justify-between border-b border-border bg-muted/40 px-3 py-1.5",children:[k,C]}),e[25]=k,e[26]=C,e[27]=N):N=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:u.map((T,E)=>{const $=h==null?void 0:h[E];return r.jsxs("span",{className:"block",children:[r.jsx(ZN,{num:E+1}),$?$.map(nk):T||" "]},E)})})})});let A;e[28]!==c||e[29]!==f?(A=c&&r.jsxs(ee,{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 ${f} lines of code`,children:["Show ",f," lines..."]}),e[28]=c,e[29]=f,e[30]=A):A=e[30];let P;return e[31]!==_||e[32]!==A||e[33]!==N?(P=r.jsxs("div",{className:w,children:[N,_,A]}),e[31]=_,e[32]=A,e[33]=N,e[34]=P):P=e[34],P}function nk(n,e){return r.jsx("span",{style:{color:n.color},children:n.content},e)}var Ls=function(n,e){return Number(n.toFixed(e))},sk=function(n,e){return e},Qe=function(n,e,t){t&&typeof t=="function"&&t(n,e)},ok=function(n){return-Math.cos(n*Math.PI)/2+.5},rk=function(n){return n},ik=function(n){return n*n},ak=function(n){return n*(2-n)},lk=function(n){return n<.5?2*n*n:-1+(4-2*n)*n},ck=function(n){return n*n*n},dk=function(n){return--n*n*n+1},uk=function(n){return n<.5?4*n*n*n:(n-1)*(2*n-2)*(2*n-2)+1},fk=function(n){return n*n*n*n},mk=function(n){return 1- --n*n*n*n},pk=function(n){return n<.5?8*n*n*n*n:1-8*--n*n*n*n},hk=function(n){return n*n*n*n*n},gk=function(n){return 1+--n*n*n*n*n},xk=function(n){return n<.5?16*n*n*n*n*n:1+16*--n*n*n*n*n},jx={easeOut:ok,linear:rk,easeInQuad:ik,easeOutQuad:ak,easeInOutQuad:lk,easeInCubic:ck,easeOutCubic:dk,easeInOutCubic:uk,easeInQuart:fk,easeOutQuart:mk,easeInOutQuart:pk,easeInQuint:hk,easeOutQuint:gk,easeInOutQuint:xk},Sx=function(n){typeof n=="number"&&cancelAnimationFrame(n)},Sn=function(n){n.mounted&&(Sx(n.animation),n.isAnimating=!1,n.animation=null,n.velocity=null)};function Nx(n,e,t,s){if(n.mounted){var o=new Date().getTime(),i=1;Sn(n),n.animation=function(){if(!n.mounted)return Sx(n.animation);var a=new Date().getTime()-o,l=a/t,c=jx[e],d=c(l);a>=t?(s(i),n.animation=null):n.animation&&(s(d),requestAnimationFrame(n.animation))},requestAnimationFrame(n.animation)}}function bk(n){var e=n.scale,t=n.positionX,s=n.positionY;return!(Number.isNaN(e)||Number.isNaN(t)||Number.isNaN(s))}function $s(n,e,t,s){var o=bk(e);if(!(!n.mounted||!o)){var i=n.setState,a=n.state,l=a.scale,c=a.positionX,d=a.positionY,u=e.scale-l,f=e.positionX-c,m=e.positionY-d;t===0?i(e.scale,e.positionX,e.positionY):Nx(n,s,t,function(p){p!==1?n.isAnimating=!0:n.isAnimating=!1;var h=l+u*p,g=c+f*p,x=d+m*p;i(h,g,x)})}}function vk(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,u=o-c;return{wrapperWidth:s,wrapperHeight:o,newContentWidth:l,newDiffWidth:d,newContentHeight:c,newDiffHeight:u}}var yk=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,u=l,f=s-o-c,m=c;return{minPositionX:d,maxPositionX:u,minPositionY:f,maxPositionY:m,scaleWidthFactor:l,scaleHeightFactor:c}},ru=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=vk(t,s,e),c=l.wrapperWidth,d=l.wrapperHeight,u=l.newContentWidth,f=l.newContentHeight,m=l.newDiffWidth,p=l.newDiffHeight,h=yk(c,u,m,d,f,p,!!i),g=c>=u&&d>=f;a&&g&&!i&&(h.minPositionX=0,h.maxPositionX=0,h.minPositionY=0,h.maxPositionY=0);var x=n.setup,b=x.minPositionX,w=x.maxPositionX,v=x.minPositionY,S=x.maxPositionY;return b!=null&&(h.minPositionX=c*(1-e)+b*e),w!=null&&(h.maxPositionX=w*e),v!=null&&(h.minPositionY=d*(1-e)+v*e),S!=null&&(h.maxPositionY=S*e),h},wr=function(n,e,t,s){return s?n<e?Ls(e,2):n>t?Ls(t,2):Ls(n,2):Ls(n,2)},Ao=function(n,e){var t=ru(n,e);return n.bounds=t,t};function ei(n,e,t,s,o,i,a){var l=t.minPositionX,c=t.minPositionY,d=t.maxPositionX,u=t.maxPositionY,f=0,m=0;a&&(f=o,m=i);var p=wr(n,l-f,d+f,s),h=wr(e,c-m,u+m,s);return{x:p,y:h}}function Ya(n,e,t,s,o,i){var a=n.state,l=a.scale,c=a.positionX,d=a.positionY,u=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 f=c-e*u,m=d-t*u,p=ei(f,m,o,i,0,0,null);return p}var Wm=1e-7;function ti(n,e,t,s,o){var i=o?s:0,a=Math.max(e-i,Wm),l=t+i;return!Number.isNaN(t)&&n>=l?l:!Number.isNaN(e)&&n<=a?a:Math.max(n,Wm)}var Hm=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(u){return u instanceof Element?o==null?void 0:o.contains(u):!1}):o==null?void 0:o.contains(i),c=s&&i&&l;if(!c)return!1;var d=ni(i,t);return!(d||i.getAttribute("draggable")==="true"||i.getAttribute("contenteditable")==="true"||i.isContentEditable)},qm=function(n){var e=n.isInitialized,t=n.isPanning,s=n.setup,o=s.panning.disabled,i=e&&t&&!o;return!!i},wk=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}},jk=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 Sk(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 u=n.bounds,f=u.maxPositionX,m=u.minPositionX,p=u.maxPositionY,h=u.minPositionY,g=t>f||t<m,x=s>p||s<h,b=t>f?d.offsetWidth:n.setup.minPositionX||0,w=s>p?d.offsetHeight:n.setup.minPositionY||0,v=Ya(n,b,w,o,n.bounds,l||c),S=v.x,j=v.y;return{scale:o,positionX:g?S:t,positionY:x?j:s}}}function kx(n,e,t,s,o){var i=n.setup.limitToBounds,a=n.wrapperComponent,l=n.bounds,c=n.state,d=c.scale,u=c.positionX,f=c.positionY;if(!(a===null||l===null||e===u&&t===f)){var m=ei(e,t,l,i,s,o,a),p=m.x,h=m.y;n.setState(d,p,h)}}var Nk=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 u=e-s.x,f=t-s.y,m=a?c:u,p=l?d:f;return{x:m,y:p}},_s=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},ps;(function(n){n.TRACK_PAD="track_pad",n.MOUSE="mouse",n.TOUCH="touch"})(ps||(ps={}));var kk=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 u=t.offsetWidth<s.offsetWidth*c||t.offsetHeight<s.offsetHeight*c;return u},Ck=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 _k(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 Km(n,e,t,s,o,i,a,l,c,d){if(o){if(e>a&&t>a){var u=a+(n-a)*d;return u>c?c:u<a?a:u}if(e<i&&t<i){var u=i+(n-i)*d;return u<l?l:u>i?i:u}}return s?e:wr(n,i,a,o)}function Tk(n){var e=1,t=n.offsetWidth/window.innerWidth;return Number.isNaN(t)?e:Math.min(e,t)}var Ll=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 Ek(n,e,t){var s,o,i=kk(n);if(i){var a=n.lastMousePosition,l=n.velocityTime,c=n.setup,d=n.wrapperComponent,u=c.velocityAnimation,f=u.maxStrengthMouse,m=u.maxStrengthTouch,p=u.sensitivityTouch,h=u.sensitivityMouse,g=Date.now();if(a&&l&&d){var x=Tk(d),b=(s={},s[ps.TOUCH]=p,s[ps.MOUSE]=h,s)[t],w=(o={},o[ps.TOUCH]=m,o[ps.MOUSE]=f,o)[t],v=e.x-a.x,S=e.y-a.y,j=Ll(v/x,w,b),k=Ll(S/x,w,b),C=g-l,N=v*v+S*S,_=Ll(Math.sqrt(N)/C,w,b);n.velocity={velocityX:j,velocityY:k,total:_}}n.lastMousePosition=e,n.velocityTime=g}}function Ak(n){var e=n.velocity,t=n.bounds,s=n.setup,o=n.wrapperComponent,i=Ck(n);if(!(!i||!e||!t||!o)){var a=e.velocityX,l=e.velocityY,c=e.total,d=t.maxPositionX,u=t.minPositionX,f=t.maxPositionY,m=t.minPositionY,p=s.limitToBounds,h=s.autoAlignment,g=s.zoomAnimation,x=s.panning,b=x.lockAxisY,w=x.lockAxisX,v=g.animationType,S=h.sizeX,j=h.sizeY,k=h.velocityAlignmentTime,C=k,N=_k(n,c),_=Math.max(N,C),A=_s(n,S),P=_s(n,j),T=A*o.offsetWidth/100,E=P*o.offsetHeight/100,$=d+T,I=u-T,R=f+E,D=m-E,O=n.state,M=new Date().getTime();Nx(n,v,_,function(F){var z=n.state,L=z.scale,W=z.positionX,U=z.positionY,H=new Date().getTime()-M,K=H/C,V=jx[h.animationType],Y=1-V(Math.min(1,K)),q=1-F,J=W+a*q,Q=U+l*q,X=Km(J,O.positionX,W,w,p,u,d,I,$,Y),Z=Km(Q,O.positionY,U,b,p,m,f,D,R,Y);if(W!==J||U!==Q){n.setState(L,X,Z);var te=n.props.onPanning;te&&te(Je(n),{})}})}}function Vm(n,e){var t=n.state,s=t.scale,o=t.positionX,i=t.positionY;n.panStartPosition={x:o,y:i},Sn(n),Ao(n,s),window.TouchEvent!==void 0&&e instanceof TouchEvent?jk(n,e):wk(n,e)}function Cx(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,u=i.animationType,f=a||t<o||!l&&!c;if(!f){var m=Sk(n);m&&$s(n,m,d,u)}}function Gm(n,e,t,s){var o=n.startCoords,i=n.setup,a=i.autoAlignment,l=a.sizeX,c=a.sizeY;if(o){var d=Nk(n,e,t),u=d.x,f=d.y,m=_s(n,l),p=_s(n,c);Ek(n,{x:u,y:f},s),kx(n,u,f,m,p)}}function Pk(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 u=a-d.x,f=l-d.y;if(u*u+f*f<=25)return}n.isAnimating=!1,n.animation=null;var m=(s==null?void 0:s.offsetWidth)||0,p=(s==null?void 0:s.offsetHeight)||0,h=((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,b=!e&&t&&t.total>.1&&x;b?Ak(n):Cx(n)}}function iu(n,e,t,s){var o=n.setup,i=o.minScale,a=o.maxScale,l=o.limitToBounds,c=ti(Ls(e,2),i,a,0,!1),d=Ao(n,c),u=Ya(n,t,s,c,d,l),f=u.x,m=u.y;return{scale:c,positionX:f,positionY:m}}function au(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,u=d.disabled,f=d.animationTime,m=d.animationType,p=s>=a&&s<=l,h=u||p;if((s>=1||c)&&Cx(n),!(h||!o||!n.mounted)){var g=e||o.offsetWidth/2,x=t||o.offsetHeight/2,b=s<a?a:l,w=iu(n,b,g,x);w&&$s(n,w,f,m)}}var hn=function(){return hn=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},hn.apply(this,arguments)};function Ym(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 zl={scale:1,positionX:0,positionY:0},Ds={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"}},Hc={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},_x=function(n){var e,t,s,o,i,a,l,c,d,u=Math.max((e=n.minScale)!==null&&e!==void 0?e:Ds.minScale,1e-7),f=(t=n.maxScale)!==null&&t!==void 0?t:Ds.maxScale,m=(s=n.initialScale)!==null&&s!==void 0?s:zl.scale,p=Math.min(Math.max(m,u),f),h=wr((o=n.initialPositionX)!==null&&o!==void 0?o:zl.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=wr((l=n.initialPositionY)!==null&&l!==void 0?l:zl.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}},Xm=function(n){var e=hn({},Ds);return Object.keys(n).forEach(function(t){var s=t,o=typeof n[s]<"u",i=typeof Ds[s]<"u";if(i&&o){var a=Object.prototype.toString.call(Ds[s]),l=a==="[object Object]",c=a==="[object Array]";l?e[s]=hn(hn({},Ds[s]),n[s]):c?e[s]=Ym(Ym([],Ds[s],!0),n[s]):e[s]=n[s]}}),e.minScale<=0&&(e.minScale=1e-7),e},Tx=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,u=c.size;if(!o)throw new Error("Wrapper is not mounted");var f=d?s*Math.exp(e*t):s+e*t,m=ti(Ls(f,3),l,a,u,!1);return m};function Ex(n,e,t,s,o){var i,a,l=n.wrapperComponent,c=n.state,d=c.scale,u=c.positionX,f=c.positionY,m=n.setup.zoomAnimation;if(!l)return console.error("No WrapperComponent found");var p=m.disabled?0:s,h=l.offsetWidth,g=l.offsetHeight,x=(h/2-u)/d,b=(g/2-f)/d,w=Tx(n,e,t),v=iu(n,w,x,b);if(!v)return console.error("Error during zoom event. New transformation state was not calculated.");var S=n.props,j=S.onZoomStart,k=S.onZoom,C=S.onZoomStop,N=new MouseEvent("mousemove",{bubbles:!0}),_=Je(n);Qe(_,N,j),Qe(_,N,k),$s(n,v,p,o);var A=(a=(i=l.ownerDocument)===null||i===void 0?void 0:i.defaultView)!==null&&a!==void 0?a:typeof window<"u"?window:null;A&&A.setTimeout(function(){n.mounted&&Qe(Je(n),N,C)},p)}function Ax(n,e,t,s){var o,i,a=n.setup,l=n.wrapperComponent,c=n.contentComponent,d=a.limitToBounds,u=a.centerOnInit,f=_x(n.props),m=n.state,p=m.scale,h=m.positionX,g=m.positionY;if(l){var x=f.positionX,b=f.positionY;if(u&&c){var w=lu(f.scale,l,c);x=w.positionX,b=w.positionY}var v=ru(n,f.scale),S=ei(x,b,v,d,0,0,l),j={scale:f.scale,positionX:S.x,positionY:S.y};if(!(p===f.scale&&h===f.positionX&&g===f.positionY)){s==null||s();var k=n.props,C=k.onZoomStart,N=k.onZoom,_=k.onZoomStop,A=new MouseEvent("mousemove",{bubbles:!0}),P=Je(n);Qe(P,A,C),Qe(P,A,N),$s(n,j,e,t);var T=(i=(o=l.ownerDocument)===null||o===void 0?void 0:o.defaultView)!==null&&i!==void 0?i:typeof window<"u"?window:null;T&&T.setTimeout(function(){n.mounted&&Qe(Je(n),A,_)},e)}}}function $k(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 Rk(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,u=c.minScale,f=c.maxScale;if(!i||!a)return l;var m=i.getBoundingClientRect(),p=e.getBoundingClientRect(),h=$k(e,i,a,l),g=h.x,x=h.y,b=p.width/l.scale,w=p.height/l.scale,v=i.offsetWidth/b,S=i.offsetHeight/w,j=ti(t||Math.min(v,S),u,f,0,!1),k=(m.width-b*j)/2,C=(m.height-w*j)/2,N=(m.left-g)*j+k+s,_=(m.top-x)*j+C+o,A=ru(n,j),P=ei(N,_,A,d,0,0,i),T=P.x,E=P.y;return{positionX:T,positionY:E,scale:j}}var Ik=function(n){return function(e,t,s){e===void 0&&(e=.5),t===void 0&&(t=300),s===void 0&&(s="easeOut"),Ex(n,1,e,t,s)}},Mk=function(n){return function(e,t,s){e===void 0&&(e=.5),t===void 0&&(t=300),s===void 0&&(s="easeOut"),Ex(n,-1,e,t,s)}},Ok=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,u=n.wrapperComponent,f=n.contentComponent,m=n.setup.disabled;if(!(m||!u||!f)){var p={positionX:Number.isNaN(e)?l:e,positionY:Number.isNaN(t)?c:t,scale:Number.isNaN(s)?d:s};$s(n,p,o,i)}}},Dk=function(n){return function(e,t){e===void 0&&(e=200),t===void 0&&(t="easeOut"),Ax(n,e,t)}},Lk=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=lu(e||o.scale,i,a);$s(n,l,t,s)}}},zk=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),Sn(n);var l=n.wrapperComponent,c=typeof e=="string"?document.getElementById(e):e;if(l&&c&&l.contains(c)){var d=Rk(n,c,t,i,a);$s(n,d,s,o)}}},qc=function(n){return{instance:n,state:n.state,zoomIn:Ik(n),zoomOut:Mk(n),setTransform:Ok(n),resetTransform:Dk(n),centerView:Lk(n),zoomToElement:zk(n)}},Fk=function(n){return{instance:n,state:n.state}},Je=function(n){var e={};return Object.assign(e,Fk(n)),Object.assign(e,qc(n)),e},Fl=!1;function Bl(){try{var n={get passive(){return Fl=!0,!1}};return n}catch{return Fl=!1,Fl}}var Ri=".".concat(Hc.wrapperClass),ni=function(n,e){return e.some(function(t){return n.matches("".concat(Ri," ").concat(t,", ").concat(Ri," .").concat(t,", ").concat(Ri," ").concat(t," *, ").concat(Ri," .").concat(t," *"))})},jr=function(n){n&&clearTimeout(n)},Bk=function(n){return Number.parseFloat(n.toFixed(8))},Px=function(n,e,t){var s=Bk(t);return"translate(".concat(n,"px, ").concat(e,"px) scale(").concat(s,")")},lu=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 Uk(n,e){n!=null&&(typeof n=="function"?n(e):n.current=e)}function Wk(n){return function(e){n.forEach(function(t){typeof t=="function"?t(e):t!=null&&(t.current=e)})}}var $x=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,u=l&&!c&&!s&&d;if(!u||o&&!e.ctrlKey||i&&e.ctrlKey)return!1;var f=ni(d,a);if(f)return!1;var m=n.isPressingKeys(n.setup.wheel.activationKeys);return!!m},Hk=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=$x(n,e);if(l)return!1;var c=e.target,d=ni(c,a);if(d)return!1;var u=n.isPressingKeys(i);return!!u},qk=function(n){return n?n.deltaY<0?1:-1:0};function Kk(n,e){var t=qk(n),s=sk(e,t);return s}function Rx(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 Vk=function(n,e,t,s,o){var i=n.state.scale,a=n.wrapperComponent,l=n.setup,c=l.maxScale,d=l.minScale,u=l.zoomAnimation,f=l.disablePadding,m=u.size,p=u.disabled;if(!a)throw new Error("Wrapper is not mounted");var h=i+e*t,g=s?!1:!p,x=ti(h,d,c,m,g&&!f);return x},Ix=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},Gk=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=ni(a,o);return!c},Yk=function(n){var e=n.setup.pinch.disabled,t=n.isInitialized,s=n.pinchStartDistance,o=t&&!e&&s!==null;return!!o},Xk=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}},Mx=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))},Jk=5,Qk=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,u=l.size,f=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/Jk),x=t+g,b=x===1/0?0:Ls(x,10);return ti(b,a,i,u,!f&&!c)},Ox=160,Dx=100,Zk=function(n,e){var t=n.props,s=t.onWheelStart,o=t.onZoomStart;n.wheelStopEventTimer||(Sn(n),Qe(Je(n),e,s),Qe(Je(n),e,o))},eC=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,u=a.centerZoomedOut,f=a.zoomAnimation,m=a.wheel,p=a.disablePadding,h=a.smooth,g=f.size,x=f.disabled,b=m.step;if(!i)throw new Error("Component not mounted");e.cancelable&&e.preventDefault(),e.stopPropagation();var w=Kk(e,null),v=h?b*Math.abs(e.deltaY):b,S=Vk(n,w,v,!e.ctrlKey);if(c!==S){var j=Ao(n,S),k=Rx(e,i,c),C=x||g===0||u||p,N=d&&C,_=Ya(n,k.x,k.y,S,j,N),A=_.x,P=_.y;n.previousWheelEvent=e,n.setState(S,A,P),Qe(Je(n),e,s),Qe(Je(n),e,o)}},tC=function(n,e){var t=n.props,s=t.onWheelStop,o=t.onZoomStop;jr(n.wheelAnimationTimer),n.wheelAnimationTimer=setTimeout(function(){n.mounted&&(au(n,e.x,e.y),n.wheelAnimationTimer=null)},Dx);var i=Ix(n,e);i&&(jr(n.wheelStopEventTimer),n.wheelStopEventTimer=setTimeout(function(){n.mounted&&(n.wheelStopEventTimer=null,Qe(Je(n),e,s),Qe(Je(n),e,o))},Ox))},nC=function(n,e){var t=n.props,s=t.onWheelStart,o=t.onPanningStart;n.wheelStopEventTimer||(Sn(n),Qe(Je(n),e,s),Qe(Je(n),e,o))},sC=function(n,e){var t=n.props,s=t.onWheelStop,o=t.onPanningStop;jr(n.wheelAnimationTimer),n.wheelAnimationTimer=setTimeout(function(){n.mounted&&(au(n,e.x,e.y),n.wheelAnimationTimer=null)},Dx);var i=Ix(n,e);i&&(jr(n.wheelStopEventTimer),n.wheelStopEventTimer=setTimeout(function(){n.mounted&&(n.wheelStopEventTimer=null,Qe(Je(n),e,s),Qe(Je(n),e,o))},Ox))},Lx=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}},oC=function(n,e){var t=Mx(e);n.pinchStartDistance=t,n.lastDistance=t,n.pinchStartScale=n.state.scale,n.isPanning=!1,n.isPinching=!0,n.pinchPreviousCenter=Lx(e),Sn(n)},rC=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,u=l.zoomAnimation,f=l.autoAlignment,m=l.pinch,p=l.panning,h=u.disabled,g=u.size,x=m.allowPanning;if(!(s===null||!t)){var b=Xk(e,a,t);if(!(!Number.isFinite(b.x)||!Number.isFinite(b.y))){var w=Mx(e),v=Qk(n,w),S=Lx(e),j=a/v,k=(S.x-((i==null?void 0:i.x)||0))*j,C=(S.y-((i==null?void 0:i.y)||0))*j;if(!(v===a&&k===0&&C===0)){n.pinchPreviousCenter=S;var N=Ao(n,v),_=h||g===0||d,A=c&&_,P=Ya(n,b.x,b.y,v,N,A),T=P.x,E=P.y;if(n.pinchMidpoint=b,n.lastDistance=w,p.disabled||!x)n.setState(v,T,E);else{var $=f.sizeX,I=f.sizeY,R=_s(n,$,v),D=_s(n,I,v),O=T+k,M=E+C,F=ei(O,M,N,c,R,D,o),z=F.x,L=F.y;n.setState(v,z,L)}}}}},iC=function(n){var e=n.pinchMidpoint;n.velocity=null,n.lastDistance=null,n.pinchMidpoint=null,n.pinchStartScale=null,n.pinchStartDistance=null,n.isPinching=!1,au(n,e==null?void 0:e.x,e==null?void 0:e.y)},zx=function(n,e){var t=n.props.onZoomStop,s=n.setup.doubleClick.animationTime;jr(n.doubleClickStopEventTimer),n.doubleClickStopEventTimer=setTimeout(function(){n.doubleClickStopEventTimer=null,Qe(Je(n),e,t)},s)},aC=function(n,e){var t=n.props,s=t.onZoomStart,o=t.onZoom,i=n.setup.doubleClick,a=i.animationTime,l=i.animationType;Qe(Je(n),e,s),Ax(n,a,l,function(){return Qe(Je(n),e,o)}),zx(n,e)};function lC(n,e){return n==="toggle"?e===1?1:-1:n==="zoomOut"?-1:1}function cC(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,u=t.doubleClick,f=u.disabled,m=u.mode,p=u.step,h=u.animationTime,g=u.animationType;if(!f&&!s){if(m==="reset")return aC(n,e);if(!i)return console.error("No ContentComponent found");var x=lC(m,n.state.scale),b=Tx(n,x,p);if(a!==b){Qe(Je(n),e,c);var w=Rx(e,i,a),v=iu(n,b,w.x,w.y);if(!v)return console.error("Error during zoom event. New transformation state was not calculated.");Qe(Je(n),e,d),$s(n,v,h,g),zx(n,e)}}}var dC=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),u=t&&c&&d&&!a;if(!u)return!1;var f=ni(c,l);return!f},uC=(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&&Ao(t,t.state.scale),t.setup=Xm(s)},this.initializeWindowEvents=function(){var s,o,i,a,l=Bl(),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=Bl(),d=(s=t.wrapperComponent)===null||s===void 0?void 0:s.ownerDocument,u=d==null?void 0:d.defaultView;u==null||u.removeEventListener("mousedown",t.onPanningStart,c),u==null||u.removeEventListener("mousemove",t.onPanning,c),u==null||u.removeEventListener("mouseup",t.onPanningStop,c),d==null||d.removeEventListener("mouseleave",t.clearPanning,c),u==null||u.removeEventListener("keyup",t.setKeyUnPressed,c),u==null||u.removeEventListener("keydown",t.setKeyPressed,c),u==null||u.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),Sn(t),(l=t.observer)===null||l===void 0||l.disconnect()},this.handleInitializeWrapperEvents=function(s){var o=Bl();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(Je(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(Je(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=$x(t,s);i&&(Zk(t,s),eC(t,s),tC(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=Hk(t,s);if(c){s.cancelable&&s.preventDefault(),s.stopPropagation();var d=t.state,u=d.positionX,f=d.positionY,m=u-s.deltaX,p=f-s.deltaY,h=a?u:m,g=l?f:p,x=t.setup.autoAlignment,b=x.sizeX,w=x.sizeY,v=_s(t,b),S=_s(t,w);h===u&&g===f||(nC(t,s),kx(t,h,g,v,S),Qe(Je(t),s,o),sC(t,s))}},this.onPanningStart=function(s){var o=t.setup.disabled,i=t.props.onPanningStart;if(!o){t.syncModifierKeys(s);var a=Hm(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(),Sn(t),Vm(t,s),Qe(Je(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=qm(t);if(a){var l=t.isPressingKeys(t.setup.panning.activationKeys);l&&(s.cancelable&&s.preventDefault(),s.stopPropagation(),Gm(t,s.clientX,s.clientY,ps.MOUSE),Qe(Je(t),s,i))}}},this.onPanningStop=function(s){var o=t.setup.panning.velocityDisabled,i=t.props.onPanningStop;t.isPanning&&(Pk(t,o),Qe(Je(t),s,i))},this.onPinchStart=function(s){var o=t.setup.disabled,i=t.props.onPinchStart;if(!o){var a=Gk(t,s);a&&(oC(t,s),Sn(t),Qe(Je(t),s,i))}},this.onPinch=function(s){var o=t.setup.disabled,i=t.props.onPinch;if(!o){var a=Yk(t);a&&(s.cancelable&&s.preventDefault(),s.stopPropagation(),rC(t,s),Qe(Je(t),s,i))}},this.onPinchStop=function(s){var o=t.props.onPinchStop;t.pinchStartScale&&(iC(t),Qe(Je(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,Sn(t);var u=s.touches,f=u.length===1,m=u.length===2,p=Hm(t,s);if(f){if(!p)return;Sn(t),Vm(t,s),Qe(Je(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=qm(t);if(!a)return;s.cancelable&&s.preventDefault(),s.stopPropagation();var l=s.touches[0];Gm(t,l.clientX,l.clientY,ps.TOUCH),Qe(Je(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=dC(t,s);i&&cC(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=lu(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):Px(s,o,i)},this.getContext=function(){return Je(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:Je(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=Je(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,Ao(t,t.state.scale),t.handleInitializeWrapperEvents(s),t.handleInitialize(o),t.initializeWindowEvents(),t.isInitialized=!0;var i=Je(t);Qe(i,void 0,t.props.onInit),Uk(t.props.ref,i)},this.props=e,this.setup=Xm(this.props),this.state=_x(this.props)}return n})(),Xa=ye.createContext(null),fC=function(n,e){return typeof n=="function"?n(e):n},mC=ye.forwardRef(function(n,e){var t=y.useRef(new uC(n)).current,s=fC(n.children,qc(t));return y.useImperativeHandle(e,function(){return qc(t)},[t]),y.useEffect(function(){t.update(n)},[t,n]),r.jsx(Xa.Provider,hn({value:t},{children:s}))});ye.forwardRef(function(n,e){var t=y.useRef(null),s=y.useContext(Xa);return y.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",hn({},n,{ref:Wk([t,e])}))});function pC(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 hC=`.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
|
+
`,Ul={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo",infiniteGrid:"transform-component-module_infiniteGrid__Z-aP3"};pC(hC);var gC=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,u=n.contentProps,f=u===void 0?{}:u,m=n.infinite,p=m===void 0?!1:m,h=y.useContext(Xa),g=h.init,x=h.cleanupWindowEvents,b=y.useRef(null),w=y.useRef(null),v=y.useRef(null);return y.useEffect(function(){var S=b.current,j=w.current;return S!==null&&j!==null&&g&&(g==null||g(S,j)),function(){x==null||x()}},[]),y.useEffect(function(){if(p){var S=v.current;if(S){var j=function(){var k=h.state,C=k.positionX,N=k.positionY;S.style.backgroundPosition="".concat(C,"px ").concat(N,"px")};return j(),h.onChange(j)}}},[p,h]),r.jsxs("div",hn({},d,{ref:b,className:"".concat(Hc.wrapperClass," ").concat(Ul.wrapper," ").concat(s),style:a},{children:[p&&r.jsx("div",{ref:v,className:Ul.infiniteGrid,"aria-hidden":!0}),r.jsx("div",hn({},f,{ref:w,className:"".concat(Hc.contentClass," ").concat(Ul.content," ").concat(i),style:hn(hn({},l),{transform:Px(h.state.positionX,h.state.positionY,h.state.scale)})},{children:e}))]}))};function xC(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 bC(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,u=n.margin,f=u===void 0?0:u,m=n.threshold,p=m===void 0?0:m,h={x:-f,y:-f,width:c+2*f,height:d+2*f},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,b=g.y<h.y+h.height&&g.y+g.height>h.y;return x&&b}var w=g.width*g.height;if(w<=0)return!1;var v=xC(h,g);return v/w>=p}ye.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,u=n.placeholder,f=u===void 0?null:u,m=n.onShow,p=n.onHide,h=n.children,g=n.className,x=n.style,b=y.useContext(Xa),w=y.useState(!1),v=w[0],S=w[1],j=y.useRef(!1),k=y.useRef(m),C=y.useRef(p);return k.current=m,C.current=p,y.useEffect(function(){var N=function(){var P,T,E=b.wrapperComponent;if(E){var $=bC({elementX:t,elementY:s,elementWidth:o,elementHeight:i,scale:b.state.scale,positionX:b.state.positionX,positionY:b.state.positionY,viewportWidth:E.offsetWidth,viewportHeight:E.offsetHeight,margin:l,threshold:d});$!==j.current&&(j.current=$,S($),$?(P=k.current)===null||P===void 0||P.call(k):(T=C.current)===null||T===void 0||T.call(C))}};N();var _=b.onChange(N),A;return b.wrapperComponent||(A=b.onInit(function(){return N()})),function(){_(),A==null||A()}},[b,t,s,o,i,l,d]),v?r.jsx("div",hn({ref:e,className:g,style:x},{children:h})):f?r.jsx(r.Fragment,{children:f}):null});const Jm=8,vC=56;function Vo(n){const e=B.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(ee,{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 cu(n){const e=B.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,u]=y.useState(c),[f,m]=y.useState(100),p=y.useRef(null),h=y.useRef(null),g=s[d];let x;e[0]!==s.length?(x=he=>{u(Math.min(Math.max(he,0),s.length-1)),m(100)},e[0]=s.length,e[1]=x):x=e[1];const b=x;let w;e[2]!==b||e[3]!==d?(w=()=>b(d-1),e[2]=b,e[3]=d,e[4]=w):w=e[4];const v=w;let S;e[5]!==b||e[6]!==d?(S=()=>b(d+1),e[5]=b,e[6]=d,e[7]=S):S=e[7];const j=S;if(!g)return null;const k=s.length>1,C=d>0,N=d<s.length-1,_=f>100;let A;e[8]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{var he;return(he=p.current)==null?void 0:he.zoomIn()},e[8]=A):A=e[8];const P=A;let T;e[9]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{var he;return(he=p.current)==null?void 0:he.zoomOut()},e[9]=T):T=e[9];const E=T;let $;e[10]===Symbol.for("react.memo_cache_sentinel")?($=()=>{var he;return(he=p.current)==null?void 0:he.resetTransform()},e[10]=$):$=e[10];const I=$;let R;e[11]!==N||e[12]!==C||e[13]!==j||e[14]!==v?(R=he=>{he.key==="ArrowLeft"&&C?(he.preventDefault(),v()):he.key==="ArrowRight"&&N?(he.preventDefault(),j()):he.key==="+"||he.key==="="?(he.preventDefault(),P()):he.key==="-"?(he.preventDefault(),E()):he.key==="0"&&(he.preventDefault(),I())},e[11]=N,e[12]=C,e[13]=j,e[14]=v,e[15]=R):R=e[15];const D=R;let O;e[16]===Symbol.for("react.memo_cache_sentinel")?(O=he=>{if(he.pointerType==="mouse"||he.isPrimary===!1){h.current=null;return}h.current={x:he.clientX,y:he.clientY}},e[16]=O):O=e[16];const M=O;let F;e[17]!==N||e[18]!==C||e[19]!==j||e[20]!==v?(F=he=>{var Me;const De=h.current;h.current=null;const Be=((Me=p.current)==null?void 0:Me.instance.state.scale)??1;if(!De||Be>1.01)return;const We=he.clientX-De.x,we=he.clientY-De.y;Math.abs(We)<vC||Math.abs(We)<Math.abs(we)||(We>0&&C&&v(),We<0&&N&&j())},e[17]=N,e[18]=C,e[19]=j,e[20]=v,e[21]=F):F=e[21];const z=F;let L;e[22]!==i?(L=he=>{he||i()},e[22]=i,e[23]=L):L=e[23];let W;e[24]!==a?(W=he=>{he||a==null||a()},e[24]=a,e[25]=W):W=e[25];let U,H,K;e[26]===Symbol.for("react.memo_cache_sentinel")?(U=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"),H=r.jsx(is,{className:"sr-only",children:"Image viewer"}),K=r.jsx(as,{className:"sr-only",children:"View and navigate images from this session."}),e[26]=U,e[27]=H,e[28]=K):(U=e[26],H=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(U3,{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]!==k||e[33]!==s.length||e[34]!==d?(J=k&&r.jsxs("div",{className:"text-xs tabular-nums text-white/50",children:[d+1," of ",s.length]}),e[32]=k,e[33]=s.length,e[34]=d,e[35]=J):J=e[35];let Q;e[36]!==q||e[37]!==J?(Q=r.jsxs("div",{className:"min-w-0 flex-1",children:[q,J]}),e[36]=q,e[37]=J,e[38]=Q):Q=e[38];const X=f<=100;let Z;e[39]===Symbol.for("react.memo_cache_sentinel")?(Z=r.jsx(M1,{className:"size-3.5","data-icon":"icon"}),e[39]=Z):Z=e[39];let te;e[40]!==X?(te=r.jsx(Vo,{label:"Zoom out",disabled:X,onClick:E,children:Z}),e[40]=X,e[41]=te):te=e[41];let ne;e[42]!==f?(ne=r.jsxs(ee,{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:[f,"%"]}),e[42]=f,e[43]=ne):ne=e[43];const oe=f>=Jm*100;let re;e[44]===Symbol.for("react.memo_cache_sentinel")?(re=r.jsx(Fn,{className:"size-3.5","data-icon":"icon"}),e[44]=re):re=e[44];let ae;e[45]!==oe?(ae=r.jsx(Vo,{label:"Zoom in",disabled:oe,onClick:P,children:re}),e[45]=oe,e[46]=ae):ae=e[46];let se;e[47]===Symbol.for("react.memo_cache_sentinel")?(se=r.jsx("div",{className:"mx-1 h-5 w-px bg-white/10"}),e[47]=se):se=e[47];let de;e[48]===Symbol.for("react.memo_cache_sentinel")?(de=r.jsx(nt,{className:"size-4","data-icon":"icon"}),e[48]=de):de=e[48];let le;e[49]!==i?(le=r.jsx(Vo,{label:"Close image viewer",onClick:i,children:de}),e[49]=i,e[50]=le):le=e[50];let ce;e[51]!==te||e[52]!==ne||e[53]!==ae||e[54]!==le?(ce=r.jsxs("div",{className:"flex items-center gap-1",children:[te,ne,ae,se,le]}),e[51]=te,e[52]=ne,e[53]=ae,e[54]=le,e[55]=ce):ce=e[55];let me;e[56]!==Q||e[57]!==ce?(me=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,Q,ce]}),e[56]=Q,e[57]=ce,e[58]=me):me=e[58];const ue=g.id;let ie,ge,pe;e[59]===Symbol.for("react.memo_cache_sentinel")?(ie={mode:"toggle"},ge={step:.005},pe=(he,De)=>m(Math.round(De.scale*100)),e[59]=ie,e[60]=ge,e[61]=pe):(ie=e[59],ge=e[60],pe=e[61]);let xe,Ce;e[62]===Symbol.for("react.memo_cache_sentinel")?(xe={width:"100%",height:"100%"},Ce={width:"100%",height:"100%"},e[62]=xe,e[63]=Ce):(xe=e[62],Ce=e[63]);const Te=g.src,Ee=g.alt,$e=_?"cursor-grab active:cursor-grabbing":"cursor-zoom-in";let Re;e[64]!==$e?(Re=G("max-h-full max-w-full select-none object-contain",$e),e[64]=$e,e[65]=Re):Re=e[65];let Fe;e[66]!==g.alt||e[67]!==g.src||e[68]!==Re?(Fe=r.jsx(gC,{wrapperStyle:xe,contentStyle:Ce,contentClass:"flex items-center justify-center p-3 sm:p-6",children:r.jsx("img",{src:Te,alt:Ee,draggable:!1,className:Re})}),e[66]=g.alt,e[67]=g.src,e[68]=Re,e[69]=Fe):Fe=e[69];let Le;e[70]!==g.id||e[71]!==Fe?(Le=r.jsx(mC,{ref:p,minScale:1,maxScale:Jm,centerOnInit:!0,centerZoomedOut:!0,doubleClick:ie,wheel:ge,onTransform:pe,children:Fe},ue),e[70]=g.id,e[71]=Fe,e[72]=Le):Le=e[72];let Ie;e[73]!==N||e[74]!==C||e[75]!==j||e[76]!==v||e[77]!==k?(Ie=k&&r.jsxs(r.Fragment,{children:[r.jsx(Vo,{label:"Previous image",disabled:!C,onClick:v,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(Nd,{className:"size-5","data-icon":"icon"})}),r.jsx(Vo,{label:"Next image",disabled:!N,onClick:j,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(Xe,{className:"size-5","data-icon":"icon"})})]}),e[73]=N,e[74]=C,e[75]=j,e[76]=v,e[77]=k,e[78]=Ie):Ie=e[78];let _e;e[79]!==f?(_e=f===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(Ea,{className:"size-3","data-icon":"inline-start"}),"Scroll or double-click to zoom · drag to pan"]}),e[79]=f,e[80]=_e):_e=e[80];let je;e[81]!==z||e[82]!==Le||e[83]!==Ie||e[84]!==_e?(je=r.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden bg-black",onPointerDown:M,onPointerUp:z,children:[Le,Ie,_e]}),e[81]=z,e[82]=Le,e[83]=Ie,e[84]=_e,e[85]=je):je=e[85];let ze;e[86]!==b||e[87]!==k||e[88]!==s||e[89]!==d?(ze=k&&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((he,De)=>r.jsxs(ee,{type:"button",variant:"ghost",onClick:()=>b(De),"aria-label":`View image ${De+1}`,"aria-current":De===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]",De===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:he.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:De+1})]},`${he.id}-${De}`))})}),e[86]=b,e[87]=k,e[88]=s,e[89]=d,e[90]=ze):ze=e[90];let Ne;e[91]!==D||e[92]!==me||e[93]!==je||e[94]!==ze?(Ne=r.jsxs(rs,{showCloseButton:!1,onKeyDown:D,className:U,children:[H,K,me,je,ze]}),e[91]=D,e[92]=me,e[93]=je,e[94]=ze,e[95]=Ne):Ne=e[95];let Se;return e[96]!==l||e[97]!==L||e[98]!==W||e[99]!==Ne?(Se=r.jsx(os,{open:l,onOpenChange:L,onOpenChangeComplete:W,children:Ne}),e[96]=l,e[97]=L,e[98]=W,e[99]=Ne,e[100]=Se):Se=e[100],Se}function Kc(n){return n.type==="user"}function du(n){return n.type==="assistant"}function Qm(n){return n.type==="progress"}function Zm(n){return n.type==="system"}function Fx(n){return n.type==="summary"}function yC(n){return n.type==="queue-operation"}function Bx(n){return n.type==="attachment"}function wC(n){return n.type==="user"&&n.isCompactSummary===!0}function Ux(n){return n.type==="system"&&n.subtype==="compact_boundary"}function ep(n,e){let t=0;for(const s of n)e[s.name]=(e[s.name]??0)+1,s.isError&&t++;return t}function tp(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 Ja(n){return{totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:n}}function Qa(n){const e=Ja(n.length);for(const t of n){t.tokenUsage&&tp(e,t.tokenUsage),t.durationMs&&(e.totalDurationMs+=t.durationMs),e.errorCount+=ep(t.toolCalls,e.toolCallCounts);for(const s of t.subAgentActivity)e.errorCount+=ep(s.toolCalls,e.toolCallCounts),s.tokenUsage&&tp(e,s.tokenUsage)}return e}const jC=/<(agent-message|teammate-message)([^>]*)>([\s\S]*?)<\/\1>/g,SC=[/\bteammate_id=(?:"([^"]*)"|'([^']*)')/,/\bfrom=(?:"([^"]*)"|'([^']*)')/];function NC(n){for(const e of SC){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 kC(n){return n.replace(/^\s*<(?:agent-message|teammate-message)\b[^>]*>/,"").replace(/<\/(?:agent-message|teammate-message)>\s*$/,"").trim()}function Sr(n){let e=null,t=!1;const s=n.replace(jC,(o,i,a,l)=>(t=!0,e===null&&(e=NC(a)),l.trim()));return{sender:e,matched:t,body:t?s.trim():n}}const CC=[/\bblocking question\b/,/\bbefore i touch\b/,/\bshould i\b/,/\btell me one of\b/,/\byour call\b/,/\bwho owns\b/,/\bconfirm whether\b/],_C=[/(?:^|[,;:.!?—–-]\s*)tell me\b/,/(?:^|[,;:.!?—–-]\s*)say so\b/],TC=200,EC=/\bhttps?:\/\/\S+/g;function AC(n){const e=n.trim();if(!e)return!1;const t=e.slice(0,TC).toLowerCase();if(CC.some(i=>i.test(t)))return!0;const o=e.slice(e.lastIndexOf(`
|
|
52
|
+
`)+1).slice(-200).replace(EC,"").toLowerCase();return o.includes("?")||_C.some(i=>i.test(o))}function Za(n){return typeof n=="string"?n:n.filter(e=>e.type==="text").map(e=>e.text).join(`
|
|
53
|
+
`)}function np(n){return n?typeof n=="string"?n:n.map(e=>e.type==="text"?e.text:"").filter(Boolean).join(`
|
|
54
|
+
`):""}function Wx(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 PC=/<task-notification>[\s\S]*?<\/task-notification>/g,$C=/<[^>]*>/g;function RC(n){var t;if(((t=n.origin)==null?void 0:t.kind)==="task-notification")return!0;const e=Za(n.message.content);return e.includes("<task-notification>")?e.replace(PC,"").replace($C,"").trim()==="":!1}function IC(n){if(!Bx(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:Za(t);if(!Wx(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??Sr(s).body}}if((o==null?void 0:o.kind)==="human")return{raw:s,sender:null,body:s};const i=Sr(s);return{raw:s,sender:i.sender,body:i.body}}const MC=[["attributionAgent","agent"],["attributionSkill","skill"],["attributionPlugin","plugin"],["attributionMcpServer","mcpServer"],["attributionMcpTool","mcpTool"]];function OC(n,e){let t=n;for(const[s,o]of MC){const i=e[s];typeof i!="string"||!i||(t={...t,[o]:i})}return t}function DC(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 LC=/^This session is being continued from a previous conversation[\s\S]*?\n\nSummary:\s*\n/,zC=/\n+(?:If you need specific details from before compaction|(?:Please c|C)ontinue the conversation from where it left off)[\s\S]*$/;function FC(n){return Za(n).trim().replace(LC,"").replace(zC,"").trim()}function BC(n){if(n)return{trigger:n.trigger,preTokens:n.preTokens,postTokens:n.postTokens}}function Ii(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 UC(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=[],u=s.toolCalls.slice(o+1),f=u.findIndex(m=>m.name==="ExitPlanMode");if(f!==-1){d.push(...u.slice(0,f));const m=u[f],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=u.slice(f+1);g.length>0&&e.push({kind:"tool_calls",toolCalls:g,timestamp:s.timestamp}),t++;continue}else{d.push(...u);let m,p,h="pending",g=t+1;const x=[];for(;g<n.length;){const b=n[g];if(b.kind==="tool_calls"){const w=b.toolCalls.findIndex(v=>v.name==="ExitPlanMode");if(w!==-1){d.push(...b.toolCalls.slice(0,w)),m=b.toolCalls[w],p=m.input.path?String(m.input.path):void 0,m.result!==null&&(h=m.isError?"rejected":"approved");const v=b.toolCalls.slice(w+1);e.push({kind:"plan_mode",plan:a,planFilePath:p,status:h,toolCalls:d,timestamp:l}),e.push(...x),v.length>0&&e.push({kind:"tool_calls",toolCalls:v,timestamp:b.timestamp}),t=g+1;break}else d.push(...b.toolCalls),g++}else if(b.kind==="hook_event"||b.kind==="text"||b.kind==="queued_prompt"||b.kind==="agent_message")x.push(b),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 WC(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 uu(n){var s;const e=n.map(WC),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 HC(n){const e=[];let t=!1;for(let s=0;s<n.length;s++){const o=n[s];if(Fx(o)||Ux(o)){t=!1;continue}if(Kc(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}du(o)&&!t&&(e.push(s),t=!0)}return e}function Hx(n){var k,C;const e=[],t=[];let s=null,o=0,i=null,a=null;function l(N){a&&(N.compactionSummary=a.summary,N.compactionMeta=a.meta,a=null)}let c=null;const d=new Map,u=new Set,f=new Map,m=new Map,p=new Set,h=new Map,g=[],x=new Map;function b(N,_){let A=x.get(N);A||(A=new Map,x.set(N,A)),A.set(_,(A.get(_)??0)+1)}function w(N,_){const A=x.get(N),P=A==null?void 0:A.get(_);return!A||!P?!1:(P===1?A.delete(_):A.set(_,P-1),!0)}function v(){for(const N of g)N.turn.contentBlocks.push(N.sender?{kind:"agent_message",sender:N.sender,body:N.body,timestamp:N.timestamp}:{kind:"queued_prompt",content:N.content,timestamp:N.timestamp});g.length=0}function S(N){if(!i)return;const _=f.get(N);if(!_||_.length===0)return;i.subAgentActivity.push(..._),f.delete(N);const A=p.has(N)?"background_agent":"sub_agent",P=m.get(N);if(P)P.messages.push(..._);else{const T={kind:A,messages:[..._]};i.contentBlocks.push(T),m.set(N,T)}}function j(){if(i){for(const N of i.toolCalls)S(N.id);for(const[N]of f)S(N);for(const N of i.contentBlocks)if(N.kind==="hook_event")for(const _ of N.events){if(!(_.eventName==="PostToolUse"||_.eventName.startsWith("PostToolUse:"))||!_.toolUseId)continue;const P=i.toolCalls.find(T=>T.id===_.toolUseId);P&&(_.updatedToolOutput&&(P.outputReplacedByHook=!0),_.durationMs!==void 0&&(P.hookDurationMs=(P.hookDurationMs??0)+_.durationMs))}i.contentBlocks=UC(i.contentBlocks),e.push(i),s!==null&&t.push(s),s=null,i=null,m.clear()}}for(o=0;o<n.length;o++){const N=n[o];if(Fx(N)){j(),a={summary:N.summary};continue}if(Ux(N)){j(),a={meta:BC(N.compactMetadata)};continue}if(wC(N)){j(),s=o,i=Ii(N,null),i.compactionSummary=FC(N.message.content),i.compactionMeta=a==null?void 0:a.meta,a=null;continue}if(Zm(N)&&N.subtype==="away_summary"&&N.content){c={content:N.content,timestamp:N.timestamp};continue}if(yC(N)){if(i&&N.operation==="enqueue"&&Wx(N.content)){const _=Sr(N.content);g.push({turn:i,content:N.content,timestamp:N.timestamp,sender:_.sender,body:_.body}),b(i,N.content)}continue}if(Bx(N)){const _=IC(N);i&&_!==null&&!w(i,_.raw)&&g.push({turn:i,content:_.raw,timestamp:((k=N.attachment)==null?void 0:k.timestamp)??N.timestamp,sender:_.sender,body:_.body});continue}if(g.length>0){const _=Kc(N)&&!N.isMeta?N.message.content:null;if(typeof _=="string"){const A=g.findIndex(P=>P.content===_);if(A>=0){const[P]=g.splice(A,1);w(P.turn,P.content)}}v()}if(Kc(N)&&!N.isMeta){const _=N.message.content;if(typeof _!="string"&&Array.isArray(_)&&_.some(P=>P.type==="tool_result")&&i){for(const T of _)if(T.type==="tool_result"){const E=d.get(T.tool_use_id);E&&(E.turn.toolCalls[E.index].result=np(T.content),E.turn.toolCalls[E.index].isError=T.is_error===!0,d.delete(T.tool_use_id))}const P=N.toolUseResult;if(P!=null&&P.agentId){const T=((C=_.find(O=>O.type==="tool_result"))==null?void 0:C.tool_use_id)??"",E=h.get(T),$=p.has(T),I=[];if(Array.isArray(P.content))for(const O of P.content)O.type==="text"&&I.push(O.text);const R={agentId:P.agentId,parentToolUseId:T||void 0,agentName:(E==null?void 0:E.name)??null,subagentType:(E==null?void 0:E.subagentType)??null,type:"assistant",content:P.content,toolCalls:[],thinking:[],text:I,timestamp:N.timestamp??"",tokenUsage:P.usage?{input_tokens:P.usage.input_tokens??0,output_tokens:P.usage.output_tokens??0,cache_creation_input_tokens:P.usage.cache_creation_input_tokens??0,cache_read_input_tokens:P.usage.cache_read_input_tokens??0}:null,model:null,isBackground:$,prompt:P.prompt,status:P.status,durationMs:P.totalDurationMs,toolUseCount:P.totalToolUseCount};if(!m.get(T)){i.subAgentActivity.push(R);const M={kind:$?"background_agent":"sub_agent",messages:[R]};i.contentBlocks.push(M),m.set(T,M)}}continue}if(RC(N)){const A={kind:"task_notification",content:Za(_),timestamp:N.timestamp};if(i){i.contentBlocks.push(A);continue}s=o,i=Ii(N,null),i.contentBlocks.push(A),l(i);continue}j(),s=o,i=Ii(N,N.message.content),l(i),c&&(i.contentBlocks.push({kind:"recap",content:c.content,timestamp:c.timestamp}),c=null);continue}if(du(N)){let _=function(){$.length>0&&(I.contentBlocks.push({kind:"tool_calls",toolCalls:[...$],timestamp:T}),$.length=0)},A=function(){if(E.length>0){const R=I.contentBlocks[I.contentBlocks.length-1];R&&R.kind==="thinking"?R.blocks.push(...E):I.contentBlocks.push({kind:"thinking",blocks:[...E],timestamp:T}),E.length=0}};i||(s=o,i=Ii(N,null),l(i)),i.model=N.message.model,N.effort&&(i.effort=N.effort),i.attribution=OC(i.attribution,N);const P=N.message.id;u.has(P)||(u.add(P),i.tokenUsage=DC(i.tokenUsage,N.message.usage));const T=N.timestamp??"",E=[],$=[],I=i;for(const R of N.message.content)if(R.type==="thinking"){_();const D=R;if(!D.thinking)continue;i.thinking.push(D),E.push(D)}else if(R.type==="text"){_(),A();const D=/<thinking>([\s\S]*?)<\/thinking>/g;let O=R.text,M;for(;(M=D.exec(R.text))!==null;){const F=M[1].trim();if(F){const z={type:"thinking",thinking:F,signature:""};i.thinking.push(z),i.contentBlocks.push({kind:"thinking",blocks:[z],timestamp:T})}O=O.replace(M[0],"")}if(O=O.trim(),O){i.assistantText.push(O);const F=i.contentBlocks[i.contentBlocks.length-1];F&&F.kind==="text"?F.text.push(O):i.contentBlocks.push({kind:"text",text:[O],timestamp:T})}}else if(R.type==="tool_use"){A();const D={id:R.id,name:R.name,input:R.input,result:null,isError:!1,timestamp:N.timestamp??""},O=i.toolCalls.length;if(i.toolCalls.push(D),$.push(D),d.set(R.id,{turn:i,index:O}),R.name==="Task"||R.name==="Agent"){const M=R.input;M.run_in_background===!0&&p.add(R.id),h.set(R.id,{name:M.name??null,subagentType:M.subagent_type??null})}}A(),_();continue}if(Qm(N)&&N.data.type==="agent_progress"){const _=N.data,A=N.parentToolUseID??"";let P=null;if(_.message.type==="assistant"){const R=_.message.message,D=R.id,O=R.usage;O&&D&&!u.has(D)&&(u.add(D),P={input_tokens:O.input_tokens??0,output_tokens:O.output_tokens??0,cache_creation_input_tokens:O.cache_creation_input_tokens??0,cache_read_input_tokens:O.cache_read_input_tokens??0})}const T=_.message.type==="assistant"?_.message.message.model??null:null,E=h.get(A),$={agentId:_.agentId,parentToolUseId:A||void 0,agentName:(E==null?void 0:E.name)??null,subagentType:(E==null?void 0:E.subagentType)??null,type:_.message.type,content:_.message.message.content,toolCalls:[],thinking:[],text:[],timestamp:_.message.timestamp??N.timestamp??"",tokenUsage:P,model:T,isBackground:p.has(A)};if(_.message.type==="assistant"){const R=_.message.message.content;if(Array.isArray(R))for(const D of R)D.type==="thinking"?$.thinking.push(D.thinking):D.type==="text"?$.text.push(D.text):D.type==="tool_use"&&$.toolCalls.push({id:D.id,name:D.name,input:D.input,result:null,isError:!1,timestamp:_.message.timestamp??N.timestamp??""})}else if(_.message.type==="user"){const R=_.message.message.content;if(Array.isArray(R)){for(const D of R)if(D.type==="tool_result"){const O=f.get(A);if(O)for(const M of O){const F=M.toolCalls.find(z=>z.id===D.tool_use_id);F&&(F.result=np(D.content),F.isError=D.is_error===!0)}}}}let I=f.get(A);I||(I=[],f.set(A,I)),I.push($),i&&S(A);continue}if(Qm(N)&&N.data.type==="hook_progress"){const _=N.data,A=String(_.hook_event_name??_.hookEvent??"unknown"),P=_.hookSpecificOutput,T={eventName:A,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:(P==null?void 0:P.updatedToolOutput)!==void 0?String(P.updatedToolOutput):void 0,sessionTitle:(P==null?void 0:P.sessionTitle)!==void 0?String(P.sessionTitle):void 0,worktreePath:(P==null?void 0:P.worktreePath)!==void 0?String(P.worktreePath):void 0,timestamp:N.timestamp??""};if(i){const E=i.contentBlocks[i.contentBlocks.length-1];E&&E.kind==="hook_event"?E.events.push(T):i.contentBlocks.push({kind:"hook_event",events:[T],timestamp:N.timestamp})}continue}if(Zm(N)&&N.subtype==="turn_duration"&&i){N.durationMs!==void 0&&N.durationMs!==null&&(i.durationMs=(i.durationMs??0)+N.durationMs);continue}}return v(),j(),{turns:uu(e),turnStartIndices:t}}function qx(n){return Hx(n).turns}function sp(){return!0}function Kx(n){const e=[];for(const t of n){const s=t.trim();if(s)try{e.push(JSON.parse(s))}catch{}}return e}function Vx(n){return Kx(n.split(`
|
|
55
|
+
`))}function Gx(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),du(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 qC(n){return Gx(Kx(n))}function KC(n,e){const t=Vx(n),s=Gx(t),o=qx(t),i=e!=null&&e.skipStats?Ja(o.length):Qa(o);return{...s,turns:o,stats:i,rawMessages:e!=null&&e.skipStats?[]:t,agentKind:"claude"}}function VC(n,e){const t=Vx(e);if(t.length===0)return n;const s=n.rawMessages,o=[...s,...t],i=HC(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,u=n.turns.slice(0,a+l),f=qx(o.slice(d)),m=uu([...u,...f]),p=Qa(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 Yx="<task-notification>",GC=/<task-id>([^<]+)<\/task-id>/g,YC=/<tool-use-id>([^<]+)<\/tool-use-id>/g;function On(n){return typeof n=="object"&&n!==null}function XC(n){const e=On(n.message)?n.message:null,t=e==null?void 0:e.content;return typeof t=="string"?[t]:Array.isArray(t)?t.filter(s=>On(s)&&typeof s.text=="string").map(s=>s.text):[]}function JC(n){const e=[],t=new Set,s=new Set,o=new Set;function i(a,l){if(a.includes(Yx)){for(const c of a.matchAll(GC))t.add(c[1]),l==null||l.add(c[1]);for(const c of a.matchAll(YC))t.add(c[1]),l==null||l.add(c[1])}}for(const a of n){if(a.type==="user"){const l=On(a.toolUseResult)?a.toolUseResult:null;if((l==null?void 0:l.status)==="async_launched"){const c=On(a.message)?a.message:null,u=(Array.isArray(c==null?void 0:c.content)?c.content:[]).filter(p=>On(p)&&p.type==="tool_result").map(p=>p.tool_use_id),f=[l.agentId,l.taskId,...u].filter(p=>typeof p=="string"&&p.length>0),m=[l.description,l.workflowName,l.summary].find(p=>typeof p=="string"&&p.length>0)??"";f.length>0&&e.push({ids:f,description:m})}for(const c of XC(a))i(c,o);continue}if(a.type==="assistant"){const l=On(a.message)?a.message:null,c=Array.isArray(l==null?void 0:l.content)?l.content:[];for(const d of c){if(!On(d)||d.type!=="tool_use"||d.name!=="TaskStop")continue;const u=On(d.input)?d.input:null,f=(u==null?void 0:u.task_id)??(u==null?void 0:u.shell_id);typeof f=="string"&&t.add(f)}continue}if(a.type==="attachment"){const l=On(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 QC(n,e){return{status:"awaiting_agents",pendingQueue:e,pendingAgents:n.length,pendingAgentDescriptions:n.filter(t=>t.length>0)}}function ZC(n){var a,l;let e=0,t=null,s=!1;function o(c,d){const u={status:c,pendingQueue:Math.max(0,e)};return d&&(u.toolName=d),u}function i(){return t??(t=JC(n))}for(let c=n.length-1;c>=0;c--){const d=n[c];if(d.type!=="queue-operation"){if(d.type==="progress"){const u=d.data;if((u==null?void 0:u.type)==="hook_progress"&&(u.decision??((a=u.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(Yx))continue;const u=d.operation;u==="enqueue"?e++:(u==="dequeue"||u==="remove")&&e--;continue}if(d.type==="attachment"){const u=On(d.attachment)?d.attachment:null;(u==null?void 0:u.commandMode)==="task-notification"&&(s=!0);continue}if(d.type==="assistant"){const u=d.message,f=u==null?void 0:u.stop_reason;if(f==="end_turn"){const m=i();if(s||m.undeliveredNotifications>0)return o("processing");if(m.pendingDescriptions.length>0)return QC(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(f==="tool_use"){const m=u==null?void 0:u.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 u=d.reason;if(u)return{status:"completed",terminalReason:u,pendingQueue:Math.max(0,e)};continue}d.type!=="summary"&&d.type==="system"&&d.subtype}return{status:"idle"}}function e6(n,e,t){const s=typeof n.sessionId=="string"?n.sessionId:"";return{record:{...n,sessionId:e,branchedFrom:{sessionId:s,turnIndex:t}},originalId:s}}function t6(n){return Hx(n).turnStartIndices}function Xx(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 op={0:"\0",b:"\b",f:"\f",n:`
|
|
56
|
+
`,r:"\r",t:" ",v:"\v"};function n6(n){return!!(n&&/[A-Za-z_$]/.test(n))}function ra(n){return!!(n&&/[\w$]/.test(n))}function Un(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 op){s+=op[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 hs={"(":")","[":"]","{":"}"};function fu(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 si(n,e){const t=Un(n,e);if(t)return{endIndex:t.endIndex,isString:!0};const s=fu(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=fu(n,t);if(s===null)break;t=s}return t}function el(n,e){const t=n[e];if(!hs[t])return null;const s=[hs[t]];for(let o=e+1;o<n.length;o++){const i=si(n,o);if(i){o=i.endIndex-1;continue}const a=n[o];if(hs[a]){s.push(hs[a]);continue}if(a===s.at(-1)&&(s.pop(),s.length===0))return o}return null}function Jx(n,e){if(!n6(n[e]))return null;let t=e+1;for(;ra(n[t]);)t++;return{value:n.slice(e,t),endIndex:t}}function s6(n,e,t){var u;const s=(u=t.trim().match(/^([A-Za-z_$][\w$]*)$/))==null?void 0:u[1];if(!s)return t;const o=n.slice(0,e),i=new RegExp(`\\b(?:const|let|var)\\s+${s.replace(/[$]/g,"\\$")}\\s*=`,"y");let a=null;for(let f=0;f<o.length;f++){const m=si(o,f);if(m){f=m.endIndex-1;continue}i.lastIndex=f;const p=i.exec(o);p&&(a=p,f+=p[0].length-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 f=el(o,l);if(f!==null)return o.slice(l,f+1).trim()}const d=Un(o,l);return d?o.slice(l,d.endIndex).trim():t}function Qx(n){const e=[];let t="";for(let s=0;s<n.length;s++){const o=si(n,s);if(o){o.isString&&(t="literal"),s=o.endIndex-1;continue}const i=t===".";if(/\s/.test(n[s])||(t=n[s]),i||!n.startsWith("tools",s)||ra(n[s-1])||ra(n[s+5]))continue;let a=Qt(n,s+5),l="";if(n[a]==="."){a=Qt(n,a+1);const u=Jx(n,a);if(!u)continue;l=u.value,a=u.endIndex}else if(n[a]==="["){a=Qt(n,a+1);const u=Un(n,a);if(!u||(a=Qt(n,u.endIndex),n[a]!=="]"))continue;l=u.value,a++}else continue;if(a=Qt(n,a),n[a]!=="(")continue;const c=el(n,a);if(c===null){e.push({name:l,argumentSource:n.slice(a+1).trim(),startIndex:s});break}const d=n.slice(a+1,c).trim();e.push({name:l,argumentSource:s6(n,s,d),startIndex:s})}return e}function Zx(n,e){return Un(n,e)??Jx(n,e)}function o6(n,e,t){const s=[];for(let o=e;o<t;o++){const i=si(n,o);if(i){o=i.endIndex-1;continue}const a=n[o];if(hs[a]){s.push(hs[a]);continue}if(s.length>0&&a===s.at(-1)){s.pop();continue}if(s.length===0&&a===",")return o}return t}function tl(n,e){let t=Qt(n,0);for(;n[t]==="(";)t=Qt(n,t+1);if(n[t]!=="{")return null;const s=el(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=Zx(n,o);if(!i){o++;continue}if(o=Qt(n,i.endIndex),n[o]!==":"){o++;continue}const a=Qt(n,o+1),l=o6(n,a,s);if(i.value===e)return n.slice(a,l).trim();o=l+1}return null}function e0(n,e,t){const s=[];for(let o=0;o<n.length;o++){const i=fu(n,o);if(i!==null){o=i-1;continue}const a=Zx(n,o);if(a){if(a.value===e&&!ra(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 mu(n,e){return e0(n,e,t=>{var s;return((s=Un(n,t))==null?void 0:s.value)??null})}function t0(n,e){return e0(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 n0(n){const e=Qt(n,0);if(!n.slice(e).trim())return 0;if(n[e]!=="[")return 1;const t=el(n,e);if(t===null)return 1;let s=0,o=!1;const i=[];for(let a=e+1;a<t;a++){const l=si(n,a);if(l){o||(o=l.isString),a=l.endIndex-1;continue}const c=n[a];hs[c]?(o=!0,i.push(hs[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)}const r6=["cmd","command","workdir","description","timeout","yield_time_ms","max_output_tokens","session_id","chars","tty","login","shell","path","file_path","pattern","query","url","prompt","message","target","task_name","agent_id","agent_ids","model","agent_type","fork_turns","reasoning_effort","questions","plan","explanation","search_query","image_query","open","click","find","screenshot","finance","weather","sports","time","response_length","server","uri","cursor","name","code","old_string","new_string","content","replace_all","patch","input"];function rp(n){try{return{value:JSON.parse(n)}}catch{}if(n.startsWith("`")&&n.includes("${"))return null;const e=Un(n,0);return e&&e.endIndex===n.length?{value:e.value}:null}function i6(n){return typeof n.raw!="string"?[]:Qx(n.raw).map(({name:e,argumentSource:t})=>{const s=t.trim(),o=rp(s);if(o){const a=o.value;return a&&typeof a=="object"&&!Array.isArray(a)?{name:e,input:a}:{name:e,input:typeof a=="string"?{raw:a}:{value:a}}}const i={raw:t};for(const a of r6){const l=tl(s,a);if(l===null)continue;const c=rp(l);c&&(i[a]=c.value)}return{name:e,input:i}})}function ip(n){return n.includes("*** Begin Patch")&&n.includes("*** End Patch")}function a6(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=Un(n,a);if(l){if(ip(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=Un(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||!ip(d)||s.has(d)||(s.add(d),t.push(d))}return t}function ap(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 lp(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 u=0;u<a.length;u++){const f=a[u],m=u+1<a.length?a[u+1].headerIdx:n.length,p=n.slice(f.startIdx,m),h=(d=(c=p.match(/^\*\*\*\s+Move to:\s*(.+)$/m))==null?void 0:c[1])==null?void 0:d.trim(),g=ap(f.filePath,s),x=ap(h||f.filePath,s),b=p.split(/^@@.*$/m).filter(j=>j.trim()),w=[],v=[];for(const j of b)for(const k of j.split(`
|
|
60
|
+
`))k.startsWith("-")?w.push(k.slice(1)):k.startsWith("+")?v.push(k.slice(1)):k.startsWith(" ")&&(w.push(k.slice(1)),v.push(k.slice(1)));const S=a.length>1?`${e}:file-${u}`:e;f.action==="Add File"?o.push({id:S,name:"Write",input:{file_path:x,content:v.join(`
|
|
61
|
+
`)},result:null,isError:!1,timestamp:t}):f.action==="Delete File"?o.push({id:S,name:"Edit",input:{file_path:x,old_string:w.join(`
|
|
62
|
+
`),new_string:""},result:null,isError:!1,timestamp:t}):o.push({id:S,name:"Edit",input:{file_path:x,...h?{old_path:g}:{},old_string:w.join(`
|
|
63
|
+
`),new_string:v.join(`
|
|
64
|
+
`)},result:null,isError:!1,timestamp:t})}return o}function s0(n,e,t,s,o=""){return n==="apply_patch"?lp(e,t,s,o):a6(e).flatMap((i,a)=>lp(i,`${t}:patch-${a}`,s,o))}function l6(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 u=Number(d),f=s.get(u)??[];f.push(c),s.set(u,f)}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(u=>{const f=String(u.input.file_path??"").toLowerCase().replaceAll("\\","/");if(!f)return!1;const p=f.split("/").filter(Boolean).slice(-2).join("/");return o.includes(f)||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(u=>u.id))??[]}))}function Fs(n){return typeof n=="object"&&n!==null}const c6=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"]]),d6=new Set(["exec","exec_command","write_stdin","apply_patch","update_plan","view_image","request_user_input","request_user_input_async","tool_search","list_mcp_resources","list_mcp_resource_templates","read_mcp_resource","request_plugin_install","create_goal","get_goal","update_goal","wait"]);function Tn(n){if(n.startsWith("mcp__"))return n;const e=n.split(/(?:__|[.:/])+/).filter(Boolean).at(-1)??n;return c6.get(e)??(d6.has(e)?e:n)}function u6(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 f6(n){return{todos:(Array.isArray(n.plan)?n.plan:[]).filter(s=>Fs(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 m6(n){if(n.type!=="image"&&n.type!=="input_image"&&n.type!=="image_url")return null;const e=Fs(n.source)?n.source:n,t=e.media_type??e.mimeType;if(typeof t=="string"&&t.startsWith("image/")&&typeof e.data=="string"&&e.data)return{type:"image",source:{type:"base64",media_type:t,data:e.data}};const s=Fs(n.image_url)?n.image_url.url:n.image_url,o=typeof s=="string"?/^data:(image\/[^;,]+);base64,(.+)$/is.exec(s):null;return o?{type:"image",source:{type:"base64",media_type:o[1].toLowerCase(),data:o[2]}}:null}function cp(n){if(typeof n=="string")return{text:n,images:[]};if(!Array.isArray(n))return{text:n==null?"":JSON.stringify(n),images:[]};const e=[],t=[];for(const s of n){if(!Fs(s))continue;typeof s.text=="string"&&e.push(s.text);const o=m6(s);o&&t.push(o)}return{text:e.join(""),images:t}}function Vc(n){const e=cp(n);let t=Fs(n)&&!Array.isArray(n)?n:null;try{const d=t??JSON.parse(e.text);Fs(d)&&!Array.isArray(d)&&(t=d)}catch{}const s=t&&("output"in t||"content"in t)?cp(t.output??t.content):e,o=s===e?e.images:[...e.images,...s.images],i=Fs(t==null?void 0:t.metadata)?t.metadata:null,a=(i==null?void 0:i.exit_code)??(t==null?void 0:t.exit_code),l=typeof(t==null?void 0:t.isError)=="boolean"?t.isError:typeof(t==null?void 0:t.is_error)=="boolean"?t.is_error:void 0,c=l===!0||(typeof a=="number"?a!==0:l??u6(s.text));return{text:s.text,isError:c,...o.length>0?{images:o}:{}}}const p6=["# AGENTS.md instructions for ","<recommended_plugins>","<environment_context>","<permissions instructions>","<collaboration_mode>","<skills_instructions>"];function h6(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 pu(n){try{return JSON.parse(n)}catch{return null}}function tt(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 ia(n,e){const t=n==null?void 0:n.content;return Array.isArray(t)?t.filter(s=>tt(s)&&s.type===e&&typeof s.text=="string").map(s=>s.text).join(`
|
|
65
|
+
`).trim():""}const g6=/^data:(image\/(?:png|jpeg|gif|webp));base64,(.+)$/is,x6=/^data:(audio\/(?:wav|x-wav|mpeg|mp4|webm|ogg));base64,(.+)$/is;function o0(n){if(typeof n!="string")return null;const e=g6.exec(n);return!(e!=null&&e[1])||!e[2]?null:{type:"image",source:{type:"base64",media_type:e[1].toLowerCase(),data:e[2]}}}function r0(n){if(typeof n!="string")return null;const e=x6.exec(n);return!(e!=null&&e[1])||!e[2]?null:{type:"audio",source:{type:"base64",media_type:e[1].toLowerCase(),data:e[2]}}}function b6(n){return Array.isArray(n.images)?n.images.map(o0).filter(e=>e!==null):[]}function v6(n){return Array.isArray(n.audio)?n.audio.map(r0).filter(e=>e!==null):[]}function i0(n){return Array.isArray(n.content)?n.content.filter(e=>tt(e)&&e.type==="input_image").map(e=>o0(e.image_url)).filter(e=>e!==null):[]}function a0(n){return Array.isArray(n.content)?n.content.filter(e=>tt(e)&&e.type==="input_audio").map(e=>r0(e.audio_url)).filter(e=>e!==null):[]}function dp(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 y6(n){var a,l;const e=ia(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 Go(n){return n.split(/[\\/]/).filter(Boolean).at(-1)??null}function w6(n){if(typeof n!="string")return"";const e=n.trim();return/^gAAAAA[A-Za-z0-9_-]+$/.test(e)?"":e}function Gc(n){const e=n.trim();return!e||p6.some(t=>e.startsWith(t))?"":e}function j6(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 S6(n){if(!tt(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 N6(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 to(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 k6(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 up(n){if(typeof n!="string"||!n.trim())return{};try{const e=JSON.parse(n);return tt(e)?e:{value:e}}catch{return{raw:n}}}function Yo(n){if(typeof n=="string")return n;try{return JSON.stringify(n)}catch{return String(n??"")}}function fp(...n){return n.find(e=>typeof e=="string")}function C6(n){return n.startsWith("exec-")}function _6(n){var o;if(!tt(n))return{text:Yo(n),isError:!1};if("Err"in n)return{text:Yo(n.Err),isError:!0};const e=tt(n.Ok)?n.Ok:null;if(!e)return{text:Yo(n),isError:!1};const t=Vc({...e,content:e.content}),s=t.text||((o=t.images)!=null&&o.length?"":e.structuredContent!==void 0?Yo(e.structuredContent):Yo(e));return{...t,text:s,isError:t.isError}}function T6(n,e,t){return{id:n?`${n}@${e}`:h6("codex-turn"),userMessage:null,contentBlocks:[],thinking:[],assistantText:[],toolCalls:[],subAgentActivity:[],timestamp:e,durationMs:null,tokenUsage:null,model:t}}function l0(n){return n.type==="event_msg"&&tt(n.payload)&&n.payload.type==="user_message"&&typeof n.payload.message=="string"?Gc(n.payload.message):n.type==="response_item"&&tt(n.payload)&&n.payload.type==="message"&&n.payload.role==="user"?Gc(ia(n.payload,"input_text")):""}function E6(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 l0(n)!==""||i0(e).length>0||a0(e).length>0}return!0}function c0(n){let e="",t="",s="",o="",i="",a,l="",c="",d="",u="",f=0,m=!1,p=null,h="/root",g="";for(const x of n){if(!tt(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&&tt(x.payload.branchedFrom)){const S=typeof x.payload.branchedFrom.sessionId=="string"?x.payload.branchedFrom.sessionId:"";S&&(a={sessionId:S,turnIndex:typeof x.payload.branchedFrom.turnIndex=="number"?x.payload.branchedFrom.turnIndex:null})}const w=tt(x.payload.source)?x.payload.source:null;if(w&&tt(w.subagent)){m=!0;const S=tt(w.subagent.thread_spawn)?w.subagent.thread_spawn:null;S&&typeof S.agent_path=="string"&&(h=S.agent_path)}typeof x.payload.forked_from_id=="string"&&x.payload.forked_from_id&&(p=x.payload.forked_from_id);const v=tt(x.payload.git)?x.payload.git:null;s||(s=v&&typeof v.branch=="string"?v.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 b=l0(x);b&&b!==g&&(l||(l=b),c=b,g=b,f++,d||(d=x.timestamp??""),u=x.timestamp??u)}return u===""&&(u=d),{sessionId:e,version:t,gitBranch:s,cwd:o,model:i,slug:"",name:"",branchedFrom:a,firstUserMessage:l,lastUserMessage:c,timestamp:d,lastTimestamp:u,turnCount:f,isSubagent:m,parentSessionId:p,agentPath:h}}function d0(n){for(const e of n.split(`
|
|
68
|
+
`)){const t=e.trim();if(t)return Po(pu(t))}return!1}function A6(n){return Po(n[0]??null)}function P6(n){const e=n.map(pu).filter(Po);return c0(e)}function u0(n,e){const t=c0(n.filter(Po)),s=[],o=new Map,i=new Map,a=new Map,l=new Map,c=new Map,d=new Map,u=new Map,f=new Map;function m(A,P,T,E={}){const $=c.get(A);let I=f.get(A);if(!I){const D={agentId:A,parentToolUseId:($==null?void 0:$.parentToolCallId)||void 0,agentName:($==null?void 0:$.nickname)??($!=null&&$.agentPath?Go($.agentPath):null),subagentType:($==null?void 0:$.agentType)??null,type:"assistant",content:null,toolCalls:[],thinking:[],text:[],timestamp:($==null?void 0:$.timestamp)??T,tokenUsage:null,model:($==null?void 0:$.model)??null,isBackground:!1,prompt:($==null?void 0:$.message)||void 0,status:E.status??"running"};P.subAgentActivity.push(D);const O=P.contentBlocks[P.contentBlocks.length-1];(O==null?void 0:O.kind)==="sub_agent"?O.messages.push(D):P.contentBlocks.push({kind:"sub_agent",messages:[D],timestamp:T}),I={message:D,turn:P},f.set(A,I)}const R=I.message;if($&&(R.parentToolUseId=$.parentToolCallId||R.parentToolUseId,R.agentName=$.nickname??($.agentPath?Go($.agentPath):R.agentName),R.subagentType=$.agentType,R.model=$.model,R.prompt=$.message||R.prompt),E.text&&!R.text.includes(E.text)&&(R.text.push(E.text),R.content=R.text.join(`
|
|
69
|
+
|
|
70
|
+
`)),E.status){const D=new Set(["completed","failed","interrupted"]);if(E.status==="running"&&R.status&&D.has(R.status)||(R.status=E.status),D.has(E.status)&&R.timestamp&&T){const O=new Date(R.timestamp).getTime(),M=new Date(T).getTime();Number.isFinite(O)&&Number.isFinite(M)&&M>=O&&(R.durationMs=M-O)}}return R}let p=null,h=null,g=t.model||null,x="",b=null,w=!1;const v=[];let S=0,j=null,k=null;function C(A){const P=s.length,T=k6(s,A,x);return s.length>P&&k!==null&&v.push(k),k=null,T}function N(A,P,T){const E=T6(A,P,T);return k=j??S,j=null,w||(E.isFragment=!0),b&&(E.compactionSummary=b,b=null),E}function _(A,P,T,E,$){const I=i.get(P);if(I){I.input={...I.input,...T},I.result=E,I.isError=E==="failed";return}const R={id:P,name:"WebSearch",input:T,result:E,isError:E==="failed",timestamp:$};i.set(P,R),to(A,R,$)}for(let A=0;A<n.length;A++){const P=n[A];if(!Po(P))continue;S=A;const T=tt(P.payload)?P.payload:void 0,E=P.timestamp??"";if(P.type==="compacted"){p=C(p),b="Conversation compacted",x=E;continue}if(P.type!=="world_state"){if(P.type==="turn_context"){p=C(p),j=A,h=typeof(T==null?void 0:T.turn_id)=="string"?T.turn_id:null,g=typeof(T==null?void 0:T.model)=="string"?T.model:g,x=E,w=!0;continue}if(P.type==="event_msg"&&(T==null?void 0:T.type)==="user_message"&&typeof T.message=="string"){p&&(p.assistantText.length>0||p.toolCalls.length>0||p.thinking.length>0)&&(p=C(p)),w=!0,p??(p=N(h,E,g));const $=(Array.isArray(T.local_images)?T.local_images:[]).filter(R=>typeof R=="string"&&R.length>0),I=(Array.isArray(T.local_audio)?T.local_audio:[]).filter(R=>typeof R=="string"&&R.length>0);p.userMessage=dp(T.message,b6(T),v6(T),$,I),p.isFragment=!1,p.timestamp=p.timestamp||E,x=E;continue}if(!(!p&&!E6(P,T))){if(p??(p=N(h,E,g)),!p.model&&g&&(p.model=g),p.timestamp||(p.timestamp=E),E&&(x=E),P.type==="event_msg"&&(T==null?void 0:T.type)==="token_count"){const $=tt(T.info)?T.info:null,I=$?S6($.last_token_usage):null;I&&(p.tokenUsage=j6(p.tokenUsage,I));continue}if(P.type==="event_msg"&&(T==null?void 0:T.type)==="web_search_end"&&typeof T.call_id=="string"){const $={};typeof T.query=="string"&&T.query&&($.query=T.query),tt(T.action)&&($.action=T.action),_(p,T.call_id,$,"completed",E);continue}if(P.type==="event_msg"&&(T==null?void 0:T.type)==="mcp_tool_call_end"&&typeof T.call_id=="string"&&tt(T.invocation)){const $=T.invocation,I=typeof $.server=="string"?$.server:"mcp",R=typeof $.tool=="string"?$.tool:"tool",D=tt($.arguments)?$.arguments:{},O=_6(T.result),M=o.get(T.call_id);M?(M.result=O.text,M.isError=O.isError,O.images&&(M.resultImages=O.images),o.delete(T.call_id)):C6(T.call_id)||to(p,{id:T.call_id,name:`mcp__${I}__${R}`,input:D,result:O.text,isError:O.isError,...O.images?{resultImages:O.images}:{},timestamp:E},E);continue}if(P.type==="event_msg"&&(T==null?void 0:T.type)==="sub_agent_activity"&&typeof T.agent_thread_id=="string"&&typeof T.agent_path=="string"){const $=T.agent_thread_id,I=typeof T.event_id=="string"?T.event_id:"",R=typeof T.kind=="string"?T.kind:"started",D=I?l.get(I):void 0,O=d.get(T.agent_path),M=c.get($)??(O?c.get(O):void 0);if(R!=="started"&&!M&&!D)continue;if(O&&O!==$&&!f.has($)){const L=f.get(O);L&&(L.message.agentId=$,f.delete(O),f.set($,L)),c.delete(O)}const F={agentId:$,nickname:(M==null?void 0:M.nickname)??Go(T.agent_path)??(D==null?void 0:D.taskName)??null,agentPath:T.agent_path,message:(M==null?void 0:M.message)??(D==null?void 0:D.message)??"",model:(M==null?void 0:M.model)??(D==null?void 0:D.model)??null,agentType:(M==null?void 0:M.agentType)??(D==null?void 0:D.agentType)??null,timestamp:(M==null?void 0:M.timestamp)??(E||(D==null?void 0:D.timestamp)||""),parentToolCallId:(M==null?void 0:M.parentToolCallId)??I};c.set($,F),d.set(T.agent_path,$),I&&(R==="started"||D)&&u.set(I,$),m($,p,E,{status:R==="interrupted"?"interrupted":"running"});continue}if(!(P.type!=="response_item"||!T)){if(T.type==="reasoning"){const $=Array.isArray(T.summary)?T.summary.filter(I=>typeof I=="string").join(`
|
|
71
|
+
`):"";N6(p,$.trim(),E);continue}if(T.type==="message"&&T.role==="assistant"){Xx(p,ia(T,"output_text"),E);continue}if(T.type==="message"&&T.role==="user"&&p.userMessage===null){const $=Gc(ia(T,"input_text")),I=i0(T),R=a0(T);($||I.length>0||R.length>0)&&(p.userMessage=dp($,I,R),p.isFragment=!1,w=!0);continue}if(T.type==="web_search_call"&&typeof T.id=="string"){const $={};tt(T.action)&&($.action=T.action);const I=typeof T.status=="string"?T.status:"completed";_(p,T.id,$,I,E);continue}if(T.type==="tool_search_call"){const $=fp(T.call_id,T.id)??"";if($){const I={id:$,name:"ToolSearch",input:tt(T.arguments)?T.arguments:{},result:null,isError:!1,timestamp:E};o.set($,I),to(p,I,E)}continue}if(T.type==="tool_search_output"&&typeof T.call_id=="string"){const $=o.get(T.call_id);if($){const I=Array.isArray(T.tools)?T.tools:[],R=I.filter(tt).map(M=>fp(M.name)??"").filter(Boolean),D=R.length>0?R.length:I.length,O=`Found ${D} tool${D===1?"":"s"}`;$.result=R.length>0?`${O}: ${R.join(", ")}`:O,$.isError=T.status==="failed",o.delete(T.call_id)}continue}if(T.type==="agent_message"&&typeof T.author=="string"){const $=T.author,I=typeof T.recipient=="string"?T.recipient:null,R=y6(T);if(R.messageType==="NEW_TASK")continue;const D=d.get($),O=$.startsWith(`${t.agentPath}/`)&&(I===null||I===t.agentPath);if(!D&&!O)continue;const M=D??$;D||(c.set(M,{agentId:M,nickname:Go($),agentPath:$,message:"",model:null,agentType:null,timestamp:E,parentToolCallId:""}),d.set($,M));let F;R.messageType==="FINAL_ANSWER"?F="completed":R.messageType==="ERROR"||R.messageType==="FAILED"?F="failed":R.messageType==="INTERRUPTED"?F="interrupted":R.messageType==="MESSAGE"&&(F="running"),m(M,p,E,{status:F,text:R.text||void 0});continue}if(T.type==="function_call"&&typeof T.call_id=="string"){const $=typeof T.name=="string"?T.name:"tool",I=Tn($),R=up(T.arguments);let D=I,O=R;I==="exec_command"?D="Bash":I==="update_plan"&&(D="TodoWrite",O=f6(R)),I==="spawn_agent"&&l.set(T.call_id,{callId:T.call_id,message:w6(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:E});const M={id:T.call_id,name:D,input:O,result:null,isError:!1,timestamp:E};o.set(M.id,M),to(p,M,E);continue}if(T.type==="function_call_output"&&typeof T.call_id=="string"){const $=o.get(T.call_id);if(!$)continue;const I=Vc(T.output),R=I.text;if($.result=R,$.isError=I.isError,I.images&&($.resultImages=I.images),o.delete(T.call_id),$.name==="spawn_agent"&&R)try{const D=JSON.parse(R),O=typeof D.agent_id=="string"?D.agent_id:u.get($.id)??"",M=typeof D.task_name=="string"?D.task_name:null,F=typeof D.nickname=="string"?D.nickname:M?Go(M):null;if(O){const z=l.get($.id),L=c.get(O),W={agentId:O,nickname:F??(L==null?void 0:L.nickname)??(z==null?void 0:z.taskName)??null,agentPath:M??(L==null?void 0:L.agentPath)??null,message:(L==null?void 0:L.message)??(z==null?void 0:z.message)??"",model:(L==null?void 0:L.model)??(z==null?void 0:z.model)??null,agentType:(L==null?void 0:L.agentType)??(z==null?void 0:z.agentType)??null,timestamp:(L==null?void 0:L.timestamp)??(z==null?void 0:z.timestamp)??E,parentToolCallId:(L==null?void 0:L.parentToolCallId)??$.id};c.set(O,W),u.set($.id,O),W.agentPath&&d.set(W.agentPath,O),m(O,p,E,{status:"running"})}}catch{}if($.name==="wait_agent"&&R&&p)try{const D=JSON.parse(R),O=tt(D.status)?D.status:{};for(const[M,F]of Object.entries(O)){const z=tt(F)?F:{},L=typeof z.completed=="string"?z.completed:"",W=typeof z.failed=="string"?z.failed:typeof z.error=="string"?z.error:"",U=typeof z.interrupted=="string"?z.interrupted:"",H=L?"completed":W?"failed":U?"interrupted":typeof z.status=="string"?z.status:"running";c.has(M)||c.set(M,{agentId:M,nickname:null,agentPath:null,message:"",model:null,agentType:null,timestamp:E,parentToolCallId:""}),m(M,p,E,{status:H,text:L||W||U||void 0})}}catch{}continue}if(T.type==="custom_tool_call"&&typeof T.call_id=="string"){const $=Tn(typeof T.name=="string"?T.name:"tool"),I=typeof T.input=="string"?T.input:"",R=T.call_id,D=I?s0($,I,R,E,t.cwd):[];if($!=="apply_patch"){const O={id:R,name:$==="exec_command"?"Bash":$,input:up(I),result:null,isError:!1,timestamp:E};o.set(O.id,O),to(p,O,E)}for(const O of D)o.set(O.id,O),to(p,O,E);D.length>0&&a.set(R,{calls:D,direct:$==="apply_patch"});continue}if(T.type==="custom_tool_call_output"&&typeof T.call_id=="string"){const $=T.call_id,{text:I,isError:R,images:D}=Vc(T.output),O=a.get($);if(O){const F=O.direct&&R?new Set(O.calls.map(z=>z.id)):l6(I,R,O.calls);for(const z of O.calls){const L=o.get(z.id);L&&(L.result=I,L.isError=F.has(L.id),o.delete(L.id))}a.delete($)}const M=o.get($);M&&(M.result=I,M.isError=R,D&&(M.resultImages=D),o.delete($));continue}}}}}return C(p),{turnStartIndices:v,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?Ja(s.length):Qa(s),rawMessages:e!=null&&e.skipStats?[]:n,branchedFrom:t.branchedFrom,agentKind:"codex"}}function hu(n,e){const t=n.split(`
|
|
72
|
+
`).map(i=>i.trim()).filter(Boolean).map(pu).filter(Po),{turnStartIndices:s,...o}=u0(t,e);return o}function $6(n,e){const t=n.rawMessages.map(s=>JSON.stringify(s)).join(`
|
|
73
|
+
`);return hu(t?`${t}
|
|
74
|
+
${e}`:e)}const R6=new Set(["FINAL_ANSWER","ERROR","FAILED","INTERRUPTED"]);function I6(n){const e=n.content;return Array.isArray(e)?e.filter(t=>tt(t)&&t.type==="input_text"&&typeof t.text=="string").map(t=>t.text).join(`
|
|
75
|
+
`):""}function Mi(n){if(typeof n!="string")return null;try{const e=JSON.parse(n);return tt(e)?e:null}catch{return null}}function M6(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(u,f){t.has(u)||e.set(u,e.get(u)||f)}for(const u of n){const f=tt(u.payload)?u.payload:null;if(f){if(u.type==="event_msg"&&f.type==="sub_agent_activity"&&typeof f.agent_thread_id=="string"&&typeof f.agent_path=="string"){const m=f.agent_thread_id,p=typeof f.kind=="string"?f.kind:"started",h=typeof f.event_id=="string"?f.event_id:"",g=s.get(f.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(f.agent_path,m),p==="interrupted"?(t.add(m),e.delete(m)):l(m,o.get(h)??"");continue}if(u.type==="response_item"){if(f.type==="function_call"&&typeof f.call_id=="string"){const m=Tn(typeof f.name=="string"?f.name:"");if(m==="spawn_agent"){const p=Mi(f.arguments);o.set(f.call_id,typeof(p==null?void 0:p.task_name)=="string"?p.task_name:"")}else if(m==="wait_agent")i.add(f.call_id);else if(m==="interrupt_agent"){const p=Mi(f.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(f.call_id,h)}continue}if(f.type==="function_call_output"&&typeof f.call_id=="string"){const m=f.call_id;if(o.has(m)){const p=Mi(f.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=Mi(f.output),h=tt(p==null?void 0:p.status)?p.status:{};for(const[g,x]of Object.entries(h)){const b=tt(x)?x:{},w=typeof b.status=="string"?b.status:"";(typeof b.completed=="string"||typeof b.failed=="string"||typeof b.error=="string"||typeof b.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(f.type==="agent_message"&&typeof f.author=="string"){const p=((d=(c=I6(f).match(/^Message Type:\s*([^\r\n]+)/))==null?void 0:c[1])==null?void 0:d.trim().toUpperCase())??"";if(!R6.has(p))continue;const h=s.get(f.author)??f.author;t.add(h),e.delete(h)}}}}return[...e.entries()].filter(([u])=>!t.has(u)).map(([,u])=>u)}function O6(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=M6(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?Tn(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 D6(n,e,t){const s=tt(n.payload)?{...n.payload}:{},o=typeof s.id=="string"?s.id:"";return s.id=e,s.branchedFrom={sessionId:o,turnIndex:t},{record:{...n,payload:s},originalId:o}}function L6(n){return u0(n,{skipStats:!0}).turnStartIndices}const z6=/^(?: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 Lt(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function f0(n){return typeof n.agentId!="string"||n.agentId.length===0}function m0(n){return!Lt(n)||typeof n.type!="string"||!Lt(n.data)?!1:n.type==="abort"||n.type==="binary_asset"||n.type==="user.message"||z6.test(n.type)}function p0(n){try{const e=JSON.parse(n);return m0(e)?e:null}catch{return null}}function F6(n){return n.split(`
|
|
76
|
+
`).map(e=>e.trim()).filter(Boolean).map(p0).filter(e=>e!==null)}function ke(...n){return n.find(e=>typeof e=="string")??""}function Jn(n){return typeof n=="number"&&Number.isFinite(n)?n:0}function er(n){return typeof n.timestamp=="string"?n.timestamp:""}function us(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 mp(n){const e=us(n,"copilot-turn"),t=ke(n.data.turnId);return t?`${t}@${e}`:e}function Wl(n,e){if(!Lt(n))return;const t=ke(n.cwd),s=ke(n.branch);t&&(e.cwd=t),s&&(e.gitBranch=s)}function h0(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(!f0(t))continue;const{data:s}=t,o=er(t);if(o&&(e.lastTimestamp=o),t.type==="session.start"){e.sessionId||(e.sessionId=ke(s.sessionId)),e.version||(e.version=ke(s.copilotVersion)||(typeof s.version=="number"?String(s.version):ke(s.version))),Wl(s.context,e),e.model=ke(s.selectedModel)||e.model;continue}if(t.type==="session.resume"){Wl(s.context,e),e.model=ke(s.selectedModel)||e.model;continue}if(t.type==="session.context_changed"){Wl(s,e);continue}if(t.type==="session.auto_mode_resolved"){e.model=ke(s.chosenModel)||e.model;continue}if(t.type==="session.model_change"){e.model=ke(s.newModel)||e.model;continue}if(t.type==="session.title_changed"){e.name=ke(s.title)||e.name;continue}if(t.type==="session.shutdown"){e.model=ke(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=ke(s.model)||e.model),t.type!=="user.message")continue;e.turnCount++,e.timestamp||(e.timestamp=o);const i=ke(s.content).trim();i&&(e.firstUserMessage||(e.firstUserMessage=i),e.lastUserMessage=i)}return e.lastTimestamp||(e.lastTimestamp=e.timestamp),e}function B6(n){for(const e of n.split(`
|
|
77
|
+
`)){const t=e.trim();if(t)try{const s=JSON.parse(t);if(m0(s))return!0}catch{}}return!1}function U6(n){var e;return n_((e=n[0])==null?void 0:e.type)}function W6(n){const e=n.map(t=>p0(t.trim())).filter(t=>t!==null);return h0(e)}function Hl(n){if(typeof n=="string")return n;if(n===void 0)return"";try{return JSON.stringify(n)}catch{return String(n)}}function pp(n){return typeof n=="string"?n:Array.isArray(n)?n.flatMap(e=>{const t=typeof e=="string"?e:Lt(e)?ke(e.text,e.content):"";return t?[t]:[]}).join(`
|
|
78
|
+
`):""}function H6(n){const e=new Map;for(const t of n){if(t.type!=="session.binary_asset"&&t.type!=="binary_asset")continue;const s=ke(t.data.assetId),o=ke(t.data.data),i=ke(t.data.mimeType);s&&o&&i&&e.set(s,{data:o,mimeType:i})}return e}function q6(n,e){if(!Lt(n))return null;const t=e.get(ke(n.assetId)),s=ke(n.mimeType,t==null?void 0:t.mimeType).toLowerCase(),o=ke(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 g0(n,e){if(!Array.isArray(n))return[];const t=[],s=new Set;for(const o of n){const i=q6(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 K6(n,e){const t=ke(n.content),s=g0(n.attachments,e);return s.length===0?t:[...s,...t?[{type:"text",text:t}]:[]]}function V6(n,e){return Lt(n.result)?g0([...Array.isArray(n.result.contents)?n.result.contents:[],...Array.isArray(n.result.binaryResultsForLlm)?n.result.binaryResultsForLlm:[]],e):[]}function Gi(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 Yc(n,e=!1){const t=Jn(n.cacheWriteTokens),s=Jn(n.cacheReadTokens),o=Jn(n.inputTokens),i={input_tokens:e?Math.max(0,o-t-s):o,output_tokens:Jn(n.outputTokens),cache_creation_input_tokens:t,cache_read_input_tokens:s},a=Jn(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 G6(n){if(!Lt(n.modelMetrics))return null;let e=null;for(const t of Object.values(n.modelMetrics)){if(!Lt(t)||!Lt(t.usage))continue;const s=Yc(t.usage,!0);s&&(e=Gi(e,s))}return e}function Y6(n){if(typeof n=="string")return{label:n};if(!Lt(n))return null;const e=ke(n.label,n.title,n.value,n.name);if(!e)return null;const t=ke(n.description);return t?{label:e,description:t}:{label:e}}function X6(n){return Array.isArray(n)?n.map(Y6).filter(e=>e!==null):[]}function J6(n){if(!Lt(n))return null;const e=ke(n.question,n.prompt,n.text,n.message);if(!e)return null;const t=ke(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:X6(n.options??n.choices),...s===void 0?{}:{multiSelect:s}}}function Q6(n){const t=(Array.isArray(n.questions)?n.questions:[n]).map(J6).filter(s=>s!==null);return t.length>0?{...n,questions:t}:n}function tr(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 aa(n,e){const t=Lt(e)?e:e===void 0?{}:{value:e};return n==="AskUserQuestion"?Q6(t):n==="Edit"?{...t,file_path:ke(t.file_path,t.path),old_string:ke(t.old_string,t.old_str),new_string:ke(t.new_string,t.new_str)}:n==="Write"?{...t,file_path:ke(t.file_path,t.path),content:ke(t.content,t.file_text)}:n==="Bash"&&typeof t.command!="string"&&typeof t.cmd=="string"?{...t,command:t.cmd}:t}function Z6(n){const e=n.error;if(typeof e=="string")return e;if(Lt(e)){const s=ke(e.message,e.code);if(s)return s}const t=n.result;if(typeof t=="string")return t;if(!Lt(t))return t===void 0?"":Hl(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:Lt(o)?ke(o.text,o.content,o.output):"";return i?[i]:[]}).join(`
|
|
79
|
+
`);if(s)return s}return t.structuredContent!==void 0?Hl(t.structuredContent):Hl(t)}function hp(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 Oi(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 nr(n,e,t,s){return{id:n,name:e,input:t,result:null,isError:!1,timestamp:s}}function gp(n,e,t){if(!Array.isArray(n))return[];const s=[];for(const o of n){if(!Lt(o))continue;const i=ke(o.toolCallId),a=ke(o.name);if(!i||!a||t(i))continue;const l=tr(a);s.push(nr(i,l,aa(l,o.arguments),e))}return s}function xp(n,e,t,s){n.name=e,n.input=aa(e,t),n.timestamp=s||n.timestamp}function bp(n,e,t){n.result=Z6(e);const s=V6(e,t);s.length>0&&(n.resultImages=s),n.isError=e.success===!1||e.error!==void 0&&e.error!==null}function vp(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 e_(n){return n.userMessage!==null||n.assistantText.length>0||n.thinking.length>0||n.toolCalls.length>0||n.subAgentActivity.length>0}function x0(n,e){const t=F6(n),s=h0(t),o=H6(t),i=[],a=new Map,l=new Map,c=new Map,d=new WeakMap,u=new WeakMap;let f=null,m=null,p,h=!1,g=!1,x=null;function b(C,N){N&&d.set(C,N)}function w(C){return f||(f=vp(mp(C),er(C),null,m,p,!0)),f}function v(){f&&(e_(f)&&i.push(f),f=null)}function S(C){var I;const N=typeof C.agentId=="string"?C.agentId:"";if(!N)return null;const _=l.get(N);if(_)return _.message;const A=C.data,P=ke(A.toolCallId),T=P?((I=a.get(P))==null?void 0:I.turn)??f:f;if(!T)return null;const E=ke(A.executionMode),$={agentId:N,...P?{parentToolUseId:P}:{},agentName:ke(A.agentDisplayName,A.agentName)||null,subagentType:ke(A.agentType,A.agentName)||null,type:"assistant",content:null,toolCalls:[],thinking:[],text:[],timestamp:er(C),tokenUsage:null,model:ke(A.model)||null,isBackground:E==="background",...ke(A.description)?{prompt:ke(A.description)}:{},status:"running"};return T.subAgentActivity.push($),T.contentBlocks.push({kind:$.isBackground?"background_agent":"sub_agent",messages:[$],timestamp:$.timestamp}),l.set(N,{message:$,turn:T}),$}function j(C){if(f0(C))return!1;const N=S(C);if(!N)return!0;const{data:_}=C,A=er(C);if(C.type==="subagent.started"||C.type==="subagent.configured")return N.parentToolUseId||(N.parentToolUseId=ke(_.toolCallId)||void 0),N.agentName=ke(_.agentDisplayName,_.agentName)||N.agentName,N.subagentType=ke(_.agentType,_.agentName)||N.subagentType,N.model=ke(_.model)||N.model,N.prompt||(N.prompt=ke(_.description)||void 0),N.isBackground||(N.isBackground=ke(_.executionMode)==="background"),N.status="running",!0;if(C.type==="subagent.completed"||C.type==="subagent.failed"){N.agentName=ke(_.agentDisplayName,_.agentName)||N.agentName,N.subagentType=ke(_.agentType,_.agentName)||N.subagentType,N.model=ke(_.model)||N.model,N.durationMs=Jn(_.durationMs)||N.durationMs,N.toolUseCount=Jn(_.totalToolCalls)||N.toolUseCount,N.status=C.type==="subagent.completed"?"completed":"failed";const P=ke(_.error,_.message);return P&&!N.text.includes(P)&&N.text.push(P),!0}if(C.type==="user.message")return N.prompt||(N.prompt=ke(_.content)||void 0),!0;if(C.type==="assistant.reasoning"){const P=ke(_.content);return P&&!N.thinking.includes(P)&&N.thinking.push(P),!0}if(C.type==="assistant.message"){N.model=ke(_.model)||N.model;const P=ke(_.reasoningText);P&&!N.thinking.includes(P)&&N.thinking.push(P);const T=pp(_.content);T&&!N.text.includes(T)&&N.text.push(T);for(const E of gp(_.toolRequests,A,$=>c.has($)))N.toolCalls.push(E),c.set(E.id,{call:E,message:N});return!0}if(C.type==="assistant.usage"){N.model=ke(_.model)||N.model;const P=Yc(_);return P&&(N.tokenUsage=Gi(N.tokenUsage,P)),!0}if(C.type==="tool.execution_start"){const P=ke(_.toolCallId)||us(C,"copilot-agent-tool"),T=ke(_.toolName)||"Tool",E=tr(T),$=c.get(P);if($)xp($.call,E,_.arguments,A);else{const I=nr(P,E,aa(E,_.arguments),A);N.toolCalls.push(I),c.set(P,{call:I,message:N})}return!0}if(C.type==="tool.execution_complete"){const P=ke(_.toolCallId)||us(C,"copilot-agent-tool");let T=c.get(P);if(!T){const E=ke(_.toolName)||"Tool",$=tr(E),I=nr(P,$,{},A);N.toolCalls.push(I),T={call:I,message:N}}return bp(T.call,_,o),c.delete(P),!0}return!0}for(const C of t){if(j(C))continue;const{data:N}=C,_=er(C);if(C.type==="session.start"||C.type==="session.resume"){m=ke(N.selectedModel)||m,p=ke(N.reasoningEffort)||p;continue}if(C.type==="session.auto_mode_resolved"){m=ke(N.chosenModel)||m,f&&(f.model=m);continue}if(C.type==="session.model_change"){m=ke(N.newModel)||m;const A=N.reasoningEffort;typeof A=="string"&&(p=A),f&&(f.model=m,p&&(f.effort=p));continue}if(C.type==="session.shutdown"){m=ke(N.currentModel)||m,f&&!f.model&&(f.model=m),x=G6(N)??x;const A=Jn(N.totalApiDurationMs);f&&!g&&A&&u.set(f,A);continue}if(C.type==="user.message"){v(),f=vp(mp(C),_,K6(N,o),m,p,!1),b(f,_);continue}if(C.type==="assistant.turn_start"){m=ke(N.model)||m;const A=w(C);A.model=m,p&&(A.effort=p),b(A,_);continue}if(C.type==="assistant.reasoning"){const A=w(C);hp(A,ke(N.content),_,ke(N.reasoningId)||us(C,"copilot-thinking")),b(A,_);continue}if(C.type==="assistant.message"){m=ke(N.model)||m;const A=w(C);A.model=m,p&&(A.effort=p),hp(A,ke(N.reasoningText),_,us(C,"copilot-thinking")),Xx(A,pp(N.content),_);for(const P of gp(N.toolRequests,_,T=>a.has(T)))Oi(A,P,_),a.set(P.id,{call:P,turn:A});b(A,_);continue}if(C.type==="assistant.usage"){m=ke(N.model)||m,p=ke(N.reasoningEffort)||p;const A=Yc(N),P=Jn(N.duration);A&&(h=!0),P&&(g=!0);const T=w(C);T.model=m,p&&(T.effort=p),A&&(T.tokenUsage=Gi(T.tokenUsage,A)),P&&u.set(T,(u.get(T)??0)+P),b(T,_);continue}if(C.type==="tool.execution_start"){m=ke(N.model)||m;const A=w(C);A.model=m;const P=ke(N.toolCallId)||us(C,"copilot-tool"),T=ke(N.toolName)||"Tool",E=tr(T),$=a.get(P);if($)xp($.call,E,N.arguments,_);else{const I=nr(P,E,aa(E,N.arguments),_);Oi(A,I,_),a.set(P,{call:I,turn:A})}b(A,_);continue}if(C.type==="tool.execution_complete"){m=ke(N.model)||m;const A=ke(N.toolCallId)||us(C,"copilot-tool");let P=a.get(A);if(!P){const T=w(C),E=ke(N.toolName)||"Tool",$=tr(E),I=nr(A,$,{},_);Oi(T,I,_),P={call:I,turn:T}}bp(P.call,N,o),a.delete(A),b(P.turn,_);continue}if(C.type==="session.error"){const A=w(C),T={errorType:ke(N.errorType)||"unknown"};typeof N.statusCode=="number"&&(T.statusCode=N.statusCode),typeof N.errorCode=="string"&&(T.errorCode=N.errorCode),Oi(A,{id:us(C,"copilot-error"),name:"Error",input:T,result:ke(N.message)||"Copilot session error",isError:!0,timestamp:_},_),b(A,_);continue}(C.type==="assistant.turn_end"||C.type==="assistant.idle"||C.type==="session.idle")&&f&&b(f,_)}if(v(),!h&&x&&i.length===1&&(i[0].tokenUsage=Gi(i[0].tokenUsage,x)),s.model)for(const C of i)C.model||(C.model=s.model);for(const C of i){const N=d.get(C),_=Date.parse(C.timestamp),A=N?Date.parse(N):Number.NaN;if(Number.isFinite(_)&&Number.isFinite(A)&&A>=_)C.durationMs=A-_;else{const P=u.get(C)??0;P&&(C.durationMs=P)}}const k=e!=null&&e.skipStats?Ja(i.length):Qa(i);return!(e!=null&&e.skipStats)&&!h&&x&&i.length>1&&(k.totalInputTokens=x.input_tokens,k.totalOutputTokens=x.output_tokens,k.totalCacheCreationTokens=x.cache_creation_input_tokens??0,k.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:k,rawMessages:e!=null&&e.skipStats?[]:t,agentKind:"copilot"}}function t_(n,e){const t=n.rawMessages.map(s=>JSON.stringify(s)).join(`
|
|
80
|
+
`);return x0(t?`${t}
|
|
81
|
+
${e}`:e)}function n_(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 s_(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=Lt(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=Lt(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=Lt(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"?Tn(a.toolName):typeof a.name=="string"?Tn(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 o_(){throw new Error("Copilot sessions branch through the CLI's fork API, not by copying the transcript")}function r_(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 b0=ws[ws.length-1],i_={kind:"codex",descriptor:en("codex"),detectsText:d0,detectsRecords:A6,parse:hu,append:$6,metadataFromLines:P6,status:O6,brandBranch:D6,turnBoundaries:L6},a_={kind:"copilot",descriptor:en("copilot"),detectsText:B6,detectsRecords:U6,parse:x0,append:t_,metadataFromLines:W6,status:s_,brandBranch:o_,turnBoundaries:r_},l_={kind:"claude",descriptor:en("claude"),detectsText:sp,detectsRecords:sp,parse:KC,append:VC,metadataFromLines:qC,status:ZC,brandBranch:e6,turnBoundaries:t6},c_=Object.freeze({claude:l_,codex:i_,copilot:a_});function d_(n){function e(t){for(const s of ws){const o=n[s];if(t(o))return o}return n[b0]}return{formatFor:t=>n[t],formatForText:t=>e(s=>s.detectsText(t)),formatForRecords:t=>e(s=>s.detectsRecords(t))}}const gu=d_(c_);function v0(n){return gu.formatFor(n)}function y0(n){return gu.formatForText(n)}function w0(n){return gu.formatForRecords(n)}function j0(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 S0(n,e,t){return j0(n,e)[t]??e.length}function u_(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:j0(n,e).find(o=>o>s)??"keep-all"}function f_(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 m_(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 N0(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||f_(e,o)||s.isError&&m_(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 p_(n){return typeof n=="string"?n:n.filter(e=>e.type==="text").map(e=>e.text).join(`
|
|
82
|
+
`)}function nl(n,e){return y0(n).parse(n,e)}function h_(n,e){const t=w0(n.rawMessages);return(t.kind===b0?y0(e):t).append(n,e)}function sl(n){return n===null?"":typeof n=="string"?n:p_(n)}function k0(n){return n===null||typeof n=="string"?[]:n.filter(e=>e.type==="image")}const C0=y.createContext(null);function g_(n){const e=[];for(let t=0;t<n.length;t+=1){const s=n[t],o=k0(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 x_(n){const e=B.c(10),{images:t,children:s}=n,[o,i]=y.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 u;e[4]!==o?(u=o&&r.jsx(cu,{open:o.open,images:o.images,initialIndex:o.index,onClose:()=>i(b_),onCloseComplete:()=>i(null)},o.key),e[4]=o,e[5]=u):u=e[5];let f;return e[6]!==s||e[7]!==u||e[8]!==d?(f=r.jsxs(C0.Provider,{value:d,children:[s,u]}),e[6]=s,e[7]=u,e[8]=d,e[9]=f):f=e[9],f}function b_(n){return n?{...n,open:!1}:null}function v_(n){const e=B.c(7),{children:t}=n,{session:s}=at();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=g_(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(x_,{images:a,children:t}),e[4]=t,e[5]=a,e[6]=l):l=e[6],l}function _0(){return y.useContext(C0)}const T0=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp",".ico",".avif"]);function y_(n){if(!n)return!1;const e=n.lastIndexOf(".");return e===-1?!1:T0.has(n.slice(e).toLowerCase())}function xu(n){return!n||n.startsWith("http://")||n.startsWith("https://")||n.startsWith("data:")||!n.startsWith("/")?!1:y_(n)}function w_(n){return n&&(xu(n)?Wr(`/api/local-file?path=${encodeURIComponent(n)}`):n)}function Xc(n){const e=B.c(41),{src:t,alt:s,id:o,className:i,thumbnailClassName:a}=n,l=o===void 0?"markdown-image":o,c=An("hostFiles"),[d,u]=y.useState(!1),[f,m]=y.useState(!1),[p,h]=y.useState(),g=_0();let x;e[0]!==c||e[1]!==t?(x=xu(t)&&!c,e[0]=c,e[1]=t,e[2]=x):x=e[2];const b=x;let w;e[3]!==b||e[4]!==t?(w=b?void 0:w_(t),e[3]=b,e[4]=t,e[5]=w):w=e[5];const v=w;let S;e[6]!==s||e[7]!==l||e[8]!==v?(S=v?{id:l,src:v,alt:s??"Rendered image",label:s||"Rendered image"}:null,e[6]=s,e[7]=l,e[8]=v,e[9]=S):S=e[9];const j=S;let k;e[10]!==g||e[11]!==j?(k=()=>{j&&(g?g.openImage(j):(m(!0),u(!0)))},e[10]=g,e[11]=j,e[12]=k):k=e[12];const C=k;if(b){let O;return e[13]!==s?(O=s?r.jsx("span",{className:"text-muted-foreground",children:s}):null,e[13]=s,e[14]=O):O=e[14],O}if(v&&p===v){const O=s?`: ${s}`:"";let M;return e[15]!==O?(M=r.jsxs("span",{role:"status",className:"my-3 block text-xs text-muted-foreground",children:["Image unavailable",O]}),e[15]=O,e[16]=M):M=e[16],M}const N=`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 A=s??"";let P;e[19]!==v?(P=()=>h(v),e[19]=v,e[20]=P):P=e[20];let T;e[21]!==a?(T=G("max-h-96 max-w-full rounded-lg object-contain",a),e[21]=a,e[22]=T):T=e[22];let E;e[23]!==v||e[24]!==T||e[25]!==A||e[26]!==P?(E=r.jsx("img",{src:v,alt:A,loading:"lazy",decoding:"async",onError:P,className:T}),e[23]=v,e[24]=T,e[25]=A,e[26]=P,e[27]=E):E=e[27];let $;e[28]===Symbol.for("react.memo_cache_sentinel")?($=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(Ea,{className:"size-3.5","data-icon":"icon"})}),e[28]=$):$=e[28];let I;e[29]!==C||e[30]!==E||e[31]!==N||e[32]!==_?(I=r.jsxs(ee,{type:"button",variant:"ghost",onClick:C,"aria-label":N,className:_,children:[E,$]}),e[29]=C,e[30]=E,e[31]=N,e[32]=_,e[33]=I):I=e[33];let R;e[34]!==d||e[35]!==f||e[36]!==j?(R=f&&j&&r.jsx(cu,{open:d,images:[j],initialIndex:0,onClose:()=>u(!1),onCloseComplete:()=>m(!1)}),e[34]=d,e[35]=f,e[36]=j,e[37]=R):R=e[37];let D;return e[38]!==I||e[39]!==R?(D=r.jsxs(r.Fragment,{children:[I,R]}),e[38]=I,e[39]=R,e[40]=D):D=e[40],D}function j_(n){const e=B.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 S_(n){const e=B.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 N_(n){const e=B.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 k_(n){const e=B.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 C_(n){const e=B.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 __(n){const e=B.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 T_(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 E_(n){const e=B.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=An("hostFiles");let a;e[4]!==s?(a=T_(s),e[4]=s,e[5]=a):a=e[5];const l=a;if(l&&!i){let f;return e[6]!==t||e[7]!==s?(f=r.jsx("span",{className:"text-muted-foreground",title:s,children:t}),e[6]=t,e[7]=s,e[8]=f):f=e[8],f}let c;e[9]!==l||e[10]!==s?(c=f=>{s&&(f.preventDefault(),l?yr(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 u;return e[12]!==t||e[13]!==d||e[14]!==s||e[15]!==o?(u=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]=u):u=e[16],u}const A_=[...T0].map(n=>n.slice(1)).join("|"),P_=new RegExp(`^([ \\t]*)(\\/[^\\s]+\\.(?:${A_}))[ \\t]*$`,"gim");function E0(n){return n.replace(P_,(e,t,s)=>`${t}`)}const Kn={code:ek,pre({children:n}){return r.jsx(r.Fragment,{children:n})},a:E_,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(Nt,{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(j_,{className:"border-collapse text-sm",children:n})})},thead({children:n}){return r.jsx(S_,{className:"bg-muted/50",children:n})},tbody({children:n}){return r.jsx(N_,{children:n})},tr({children:n}){return r.jsx(k_,{className:"even:bg-muted/20",children:n})},th({children:n}){return r.jsx(C_,{className:"h-9 px-3 py-2 text-xs font-medium text-muted-foreground",children:n})},td({children:n}){return r.jsx(__,{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:Xc,input({checked:n,...e}){return r.jsx("input",{type:"checkbox",checked:n,readOnly:!0,className:"mr-2 rounded border-border accent-primary",...e})}},Qs=[Ma],$_=["system-reminder","local-command-caveat","command-name","command-message","command-args","env","claude_background_info","fast_mode_info","gitStatus","user-prompt-submit-hook"],R_=$_.join("|");function A0(){return new RegExp(`<(${R_})[^>]*>[\\s\\S]*?<\\/\\1>`,"g")}function P0(n){return n.replace(A0(),"").trim()}function I_(n){return A0().test(n)}const M_=/<command-message>([^<]+)<\/command-message>/,O_=/<command-name>([\s\S]*?)<\/command-name>/,D_=/<command-args>([\s\S]*?)<\/command-args>/;function $0(n){const e=n.match(M_);if(e)return e[1];const t=n.match(O_);return t?t[1].trim().replace(/^\//,""):null}function R0(n){const e=n.match(D_);if(!e)return null;const t=e[1].trim();return t.length>0?t:null}const I0={"local-command-stdout":"stdout","local-command-stderr":"stderr","bash-input":"input","bash-stdout":"stdout","bash-stderr":"stderr"},L_=new RegExp(`<(${Object.keys(I0).join("|")})>([\\s\\S]*?)<\\/\\1>`,"g");function z_(n){const e=[],t=n.replace(L_,(s,o,i)=>(e.push({text:Zg(i).trim(),stream:I0[o]}),"")).trim();return{outputs:e,remainingText:t}}const F_=/<task-notification>([\s\S]*?)<\/task-notification>/g;function no(n,e){const t=n.match(new RegExp(`<${e}>([\\s\\S]*?)<\\/${e}>`));return t?t[1].trim():""}function bu(n){const e=[],t=n.replace(F_,(s,o)=>(e.push({taskId:no(o,"task-id"),toolUseId:no(o,"tool-use-id"),outputFile:no(o,"output-file"),status:no(o,"status"),summary:no(o,"summary"),result:no(o,"result")}),"")).trim();return{notifications:e,remainingText:t}}const B_=/\[Request interrupted by user[^\]]*\]/g;function U_(n){const e=[],t=n.replace(B_,s=>(e.push(s),"")).trim();return{interrupts:e,remainingText:t}}const yp="[SYSTEM NOTIFICATION - NOT USER INPUT]";function W_(n){const e=n.indexOf(yp);if(e===-1)return{text:n,isSystemNotification:!1};const t=e+yp.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 wp={Icon:rN,color:"text-destructive",bg:"border-destructive/20 bg-destructive/5",badgeVariant:"destructive"},jp={completed:{Icon:oN,color:"text-success",bg:"border-success/20 bg-success/5",badgeVariant:"secondary",label:"Completed"},failed:{...wp,label:"Failed"},error:{...wp,label:"Error"},running:{Icon:iN,color:"text-warning",bg:"border-warning/20 bg-warning/5",badgeVariant:"outline",label:"Running"}};function M0(n){const e=B.c(32),{notification:t}=n,[s,o]=y.useState(!1),i=jp[t.status]??jp.running,{Icon:a}=i,l=t.result.length>0||t.outputFile.length>0,c=s?it:Xe;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 u;e[2]!==i.color?(u=G("mt-0.5 size-4 shrink-0",i.color),e[2]=i.color,e[3]=u):u=e[3];let f;e[4]!==a||e[5]!==u?(f=r.jsx(a,{className:u}),e[4]=a,e[5]=u,e[6]=f):f=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(Pe,{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(Rt,{render:r.jsx(ee,{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(mt,{children:r.jsxs("div",{className:"mt-2 border-t border-border/30 pt-2 text-sm text-foreground/90",children:[t.result&&r.jsx(Hn,{components:Kn,remarkPlugins:Qs,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 b;e[25]!==f||e[26]!==x?(b=r.jsxs("div",{className:"flex items-start gap-2",children:[f,x]}),e[25]=f,e[26]=x,e[27]=b):b=e[27];let w;return e[28]!==s||e[29]!==d||e[30]!==b?(w=r.jsx(ft,{open:s,onOpenChange:o,className:d,children:b}),e[28]=s,e[29]=d,e[30]=b,e[31]=w):w=e[31],w}function H_(n){const e=B.c(7),{content:t}=n;let s,o,i;if(e[0]!==t){i=Symbol.for("react.early_return_sentinel");e:{const{notifications:l}=bu(t);if(l.length===0){i=null;break e}s="flex flex-col",o=l.map(q_)}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 q_(n,e){return r.jsx(M0,{notification:n},n.taskId||`notification-${e}`)}function K_(n){const e=B.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(Xe,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}):r.jsx(ko,{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 u;e[7]!==t.text?(u=r.jsx("span",{className:"whitespace-pre-wrap break-words",children:t.text}),e[7]=t.text,e[8]=u):u=e[8];let f;e[9]!==d||e[10]!==u?(f=r.jsxs("div",{className:"flex items-center gap-1.5",children:[d,u]}),e[9]=d,e[10]=u,e[11]=f):f=e[11];let m;return e[12]!==c||e[13]!==f?(m=r.jsx("div",{className:c,children:f}),e[12]=c,e[13]=f,e[14]=m):m=e[14],m}function V_(n){const e=B.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(ex,{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(Hn,{components:Kn,remarkPlugins:Qs,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 vu=y.memo(function({content:e,timestamp:t,onEditCommand:s,onExpandCommand:o,compact:i=!1}){const a=_0(),[l,c]=y.useState(!1),[d,u]=y.useState(!1),[f,m]=y.useState(!1),[p,h]=y.useState(null),[g,x]=y.useState(!1),[b,w]=y.useState(null),v=y.useMemo(()=>sl(e),[e]),S=y.useMemo(()=>$0(v),[v]),j=y.useMemo(()=>R0(v),[v]),{sender:k,body:C,matched:N}=y.useMemo(()=>Sr(v),[v]),_=y.useMemo(()=>P0(C),[C]),{text:A,isSystemNotification:P}=y.useMemo(()=>W_(_),[_]),{notifications:T,remainingText:E}=y.useMemo(()=>bu(A),[A]),{outputs:$,remainingText:I}=y.useMemo(()=>z_(E),[E]),{interrupts:R,remainingText:D}=y.useMemo(()=>U_(I),[I]),O=y.useCallback(async V=>{if(!V){m(!1);return}if(p!==null){m(!0);return}if(!(!o||!S)){x(!0),m(!0);try{const Y=await o(S,j??void 0);h(Y)}finally{x(!1)}}},[p,o,S,j]),M=y.useMemo(()=>k0(e),[e]),F=y.useMemo(()=>M.map(V=>`data:${V.source.media_type};base64,${V.source.data}`),[M]),z=y.useMemo(()=>F.map((V,Y)=>({id:`message-attachment-${Y}`,src:V,alt:`Attachment ${Y+1}`,label:F.length>1?`Attachment ${Y+1}`:"Attached image"})),[F]),L=y.useMemo(()=>I_(v)||P||N,[v,P,N]),W=d?v:D,H=W.length>500&&!l?W.slice(0,500)+"...":W,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:L&&r.jsx(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>u(!d),className:"-ml-2 text-muted-foreground",children:d?r.jsxs(r.Fragment,{children:[r.jsx(Aa,{"data-icon":"inline-start"})," Hide raw"]}):r.jsxs(r.Fragment,{children:[r.jsx(ys,{"data-icon":"inline-start"})," Show raw"]})})}),!d&&P&&r.jsx("div",{className:"mb-2",children:r.jsxs(Pe,{variant:"outline",className:"text-muted-foreground",children:[r.jsx(ko,{"data-icon":"inline-start"}),"System event"]})}),!d&&N&&r.jsx("div",{className:"mb-2",children:r.jsxs(Pe,{variant:"outline",className:"text-muted-foreground",children:[r.jsx(ss,{"data-icon":"inline-start"}),k?`From ${k}`:"Teammate message"]})}),S&&r.jsxs(ft,{open:f,onOpenChange:V=>void O(V),className:"mb-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(Pe,{variant:"outline",className:"font-mono text-foreground",children:[r.jsx(ko,{"data-icon":"inline-start"}),"/",S,j&&r.jsx("span",{className:"text-muted-foreground",children:j})]}),o&&r.jsxs(Rt,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"text-muted-foreground"}),children:[f?r.jsx(it,{"data-icon":"inline-start"}):r.jsx(Xe,{"data-icon":"inline-start"}),f?"Collapse":"Expand"]}),f&&s&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>s(S),className:"text-muted-foreground",children:[r.jsx(Vs,{"data-icon":"inline-start"}),"Edit"]})]}),r.jsx(mt,{children:r.jsx(V_,{loading:g,content:p})})]}),F.length>0&&r.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:F.map((V,Y)=>r.jsxs(ee,{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(Ea,{className:"size-3.5","data-icon":"icon"})}),F.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," / ",F.length]})]},`${M[Y].source.media_type}-${M[Y].source.data.slice(0,24)}-${Y}`))}),!d&&T.length>0&&r.jsx("div",{className:"mb-2 flex flex-col gap-2",children:T.map(V=>r.jsx(M0,{notification:V},V.taskId))}),!d&&$.length>0&&r.jsx("div",{className:"mb-2 flex flex-col gap-1",children:$.map((V,Y)=>r.jsx(K_,{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(W3,{className:"size-3 shrink-0","data-icon":"inline-start"}),r.jsx("span",{children:V})]},Y))}),H&&r.jsx("div",{className:"max-w-none overflow-hidden break-words text-sm leading-relaxed",children:r.jsx(Hn,{components:Kn,remarkPlugins:Qs,children:H})}),W.length>500&&r.jsx(ee,{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(it,{"data-icon":"inline-start"})," Show less"]}):r.jsxs(r.Fragment,{children:[r.jsx(Xe,{"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()})})]}),b!==null&&r.jsx(cu,{open:b.open,images:z,initialIndex:b.index,onClose:()=>w(V=>V?{...V,open:!1}:null),onCloseComplete:()=>w(null)},b.index)]})}),O0=y.memo(function(e){const t=B.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(Pe,{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(vu,{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}),D0=y.memo(function(e){const t=B.c(30),{progress:s,expanded:o,onExpandedChange:i}=e,[a,l]=y.useState(!1),c=o??a,{todos:d,completed:u,total:f}=s,m=f>0?u/f*100:0;let p;t[0]!==i?(p=A=>{i==null||i(A),l(A)},t[0]=i,t[1]=p):p=t[1];let h;t[2]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(ee,{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(it,{"data-icon":"inline-start"}):r.jsx(Ir,{"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 b;t[6]!==u||t[7]!==f?(b=r.jsxs("span",{className:"font-mono text-xs tabular-nums text-muted-foreground",children:[u,"/",f]}),t[6]=u,t[7]=f,t[8]=b):b=t[8];let w;t[9]!==m?(w=m.toFixed(0),t[9]=m,t[10]=w):w=t[10];const v=`${w}% of tasks complete`;let S;t[11]!==m||t[12]!==v?(S=r.jsx(Yr,{value:m,className:"max-w-[200px] flex-1","aria-label":v}),t[11]=m,t[12]=v,t[13]=S):S=t[13];let j;t[14]!==s.inProgress?(j=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]=j):j=t[15];let k;t[16]!==g||t[17]!==b||t[18]!==S||t[19]!==j?(k=r.jsxs(Rt,{render:h,children:[g,x,b,S,j]}),t[16]=g,t[17]=b,t[18]=S,t[19]=j,t[20]=k):k=t[20];let C;t[21]!==d?(C=d.map(G_),t[21]=d,t[22]=C):C=t[22];let N;t[23]!==C?(N=r.jsx(mt,{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]=N):N=t[24];let _;return t[25]!==c||t[26]!==p||t[27]!==k||t[28]!==N?(_=r.jsxs(ft,{open:c,onOpenChange:p,className:"shrink-0 border-t bg-background",children:[k,N]}),t[25]=c,t[26]=p,t[27]=k,t[28]=N,t[29]=_):_=t[29],_});function G_(n,e){return r.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[n.status==="completed"?r.jsx(Wn,{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(Pa,{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 oi(n,e){const t=B.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]=y.useState(s);let a;t[3]!==n?(a=d=>{i(u=>{const f=typeof d=="function"?d(u):d;try{localStorage.setItem(n,JSON.stringify(f))}catch(m){const p=m;console.warn(`useLocalStorage: failed to serialize value for key "${n}"`,p)}return f})},t[3]=n,t[4]=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 L0(n){return`${n.provider}:${n.latestVersion??"unknown"}`}function Y_(n,e){const t=e.split(":")[0];return[...n.filter(s=>s.split(":")[0]!==t),e]}const X_="cogpit:provider-update-dismissals:v1";function J_(n,e){return n.filter(t=>t.status==="behind"&&!e.includes(L0(t)))}async function Q_(n){const e=await be("/api/provider-updates",{signal:n});if(!e.ok)throw new Error(`Provider update check failed (${e.status})`);return(await e.json()).providers??[]}async function Z_(n){const e=await be("/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 e7=360*60*1e3;function t7(){const[n,e]=y.useState([]),[t,s]=oi(X_,[]),[o,i]=y.useState(null),[a,l]=y.useState(null);y.useEffect(()=>{const u=new AbortController,f=()=>{Q_(u.signal).then(e).catch(()=>{})};f();const m=setInterval(f,e7);return()=>{u.abort(),clearInterval(m)}},[]);const c=y.useCallback(async u=>{i(u),l(null);try{const f=await Z_(u);l(f),e(m=>m.map(p=>p.provider===u?f.info:p))}catch(f){l({provider:u,status:"failed",message:f instanceof Error?f.message:"Update failed.",output:null})}finally{i(null)}},[]),d=y.useCallback(u=>{s(f=>Y_(f,L0(u)))},[s]);return{pending:J_(n,t),updating:o,outcome:a,update:c,dismiss:d,clearOutcome:y.useCallback(()=>l(null),[])}}const n7=5e3,s7={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 ql(n){return`grid-cols-[auto_minmax(0,1fr)_auto] rounded-none border-x-0 border-t-0 px-4 py-2 ${s7[n]}`}function Sp(n){const e=n.currentVersion?`v${n.currentVersion}`:"an older build";return`${n.displayName} ${e} → v${n.latestVersion}`}function z0(){const n=B.c(39),{pending:e,updating:t,outcome:s,update:o,dismiss:i,clearOutcome:a}=t7(),l=ot("configWrite"),c=(s==null?void 0:s.status)==="succeeded";let d,u;if(n[0]!==a||n[1]!==c?(d=()=>{if(!c)return;const E=setTimeout(a,n7);return()=>clearTimeout(E)},u=[c,a],n[0]=a,n[1]=c,n[2]=d,n[3]=u):(d=n[2],u=n[3]),y.useEffect(d,u),s){let E;return n[4]!==a||n[5]!==s.message||n[6]!==c?(E=c?r.jsxs(pt,{className:ql("success"),children:[r.jsx(Or,{}),r.jsx(Et,{children:s.message}),r.jsx(ht,{className:"text-success/80",children:"New sessions will use the updated CLI."})]}):r.jsxs(pt,{className:ql("destructive"),children:[r.jsx(Ys,{}),r.jsx(Et,{children:"Update did not complete"}),r.jsx(ht,{className:"text-destructive/80",children:s.message}),r.jsx(Cs,{className:"static col-start-3 row-span-2 row-start-1 self-center",children:r.jsx(ee,{variant:"ghost",size:"xs",onClick:a,children:"Dismiss"})})]}),n[4]=a,n[5]=s.message,n[6]=c,n[7]=E):E=n[7],E}if(e.length===0)return null;const f=e[0],m=e.filter(E=>E.updateCommand!==null&&l),p=pt;let h;n[8]===Symbol.for("react.memo_cache_sentinel")?(h=ql("warning"),n[8]=h):h=n[8];let g;n[9]!==t?(g=t?r.jsx(rt,{className:"animate-spin"}):r.jsx(gn,{}),n[9]=t,n[10]=g):g=n[10];let x;n[11]!==f||n[12]!==e?(x=e.length===1?Sp(f):`${e.map(o7).join(" and ")} are out of date`,n[11]=f,n[12]=e,n[13]=x):x=n[13];let b;n[14]!==x?(b=r.jsx(Et,{children:x}),n[14]=x,n[15]=b):b=n[15];const w=e.length>1?e.map(Sp).join(" · "):m.length===1?`Cogpit can run \`${f.updateCommand}\` for you.`:f.updateCommand?`Run \`${f.updateCommand}\` to upgrade.`:"Update it with whatever installed it — Cogpit could not tell.";let v;n[16]!==w?(v=r.jsx(ht,{className:"text-warning/80",children:w}),n[16]=w,n[17]=v):v=n[17];const S=Cs,j="static col-start-3 row-span-2 row-start-1 flex items-center gap-2 self-center";let k;n[18]!==e.length||n[19]!==o||n[20]!==t?(k=E=>r.jsxs(ee,{variant:"outline",size:"xs",disabled:t!==null,onClick:()=>void o(E.provider),children:[r.jsx(Nc,{"data-icon":"inline-start"}),t===E.provider?"Updating…":e.length===1?"Update":`Update ${E.displayName}`]},E.provider),n[18]=e.length,n[19]=o,n[20]=t,n[21]=k):k=n[21];const C=m.map(k),N=t!==null;let _;n[22]!==i||n[23]!==e?(_=()=>e.forEach(i),n[22]=i,n[23]=e,n[24]=_):_=n[24];let A;n[25]!==N||n[26]!==_?(A=r.jsx(ee,{variant:"ghost",size:"xs",disabled:N,onClick:_,className:"whitespace-nowrap text-muted-foreground",children:"Don't show again"}),n[25]=N,n[26]=_,n[27]=A):A=n[27];let P;n[28]!==S||n[29]!==C||n[30]!==A?(P=r.jsxs(S,{className:j,children:[C,A]}),n[28]=S,n[29]=C,n[30]=A,n[31]=P):P=n[31];let T;return n[32]!==p||n[33]!==P||n[34]!==h||n[35]!==g||n[36]!==b||n[37]!==v?(T=r.jsxs(p,{className:h,children:[g,b,v,P]}),n[32]=p,n[33]=P,n[34]=h,n[35]=g,n[36]=b,n[37]=v,n[38]=T):T=n[38],T}function o7(n){return n.displayName}function F0(){const n=B.c(27),[e,t]=y.useState(null),[s,o]=y.useState(null),[i,a]=y.useState(!1);let l,c;if(n[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{const d=window.electronUpdater;d&&(d.onUpdateAvailable(u=>{t(u)}),d.onUpdateDownloaded(u=>{o(u)}))},c=[],n[0]=l,n[1]=c):(l=n[0],c=n[1]),y.useEffect(l,c),s&&!i){let d;n[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Nc,{}),n[2]=d):d=n[2];let u;n[3]!==s.version?(u=r.jsxs(Et,{children:["Cogpit v",s.version," is ready"]}),n[3]=s.version,n[4]=u):u=n[4];let f;n[5]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(ht,{className:"text-success/80",children:"Restart to apply the update."}),n[5]=f):f=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(Cs,{className:"static col-start-3 row-span-2 row-start-1 self-center",children:r.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:m,"aria-label":"Dismiss update",children:r.jsx(nt,{"data-icon":"inline-start"})})}),n[7]=p):p=n[7];let h;return n[8]!==u?(h=r.jsxs(pt,{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,u,f,p]}),n[8]=u,n[9]=h):h=n[9],h}if(e&&!i){let d;n[10]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Nc,{}),n[10]=d):d=n[10];let u;n[11]!==e.version?(u=r.jsxs(Et,{children:["Cogpit v",e.version," is available"]}),n[11]=e.version,n[12]=u):u=n[12];let f;n[13]!==e.platform?(f=e.platform!=="mac"&&r.jsx(ht,{children:"Update through your package manager."}),n[13]=e.platform,n[14]=f):f=n[14];let m;n[15]!==e.platform||n[16]!==e.url?(m=e.platform==="mac"&&r.jsxs(ee,{variant:"outline",size:"xs",render:r.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer"}),nativeButton:!1,children:[r.jsx(H3,{"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(ee,{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(Cs,{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]!==u||n[24]!==f||n[25]!==h?(g=r.jsxs(pt,{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,u,f,h]}),n[23]=u,n[24]=f,n[25]=h,n[26]=g):g=n[26],g}return null}const B0=y.createContext(null);function Yi(n){const e=B.c(3),{value:t,children:s}=n;let o;return e[0]!==s||e[1]!==t?(o=r.jsx(B0.Provider,{value:t,children:s}),e[0]=s,e[1]=t,e[2]=o):o=e[2],o}function Ht(){const n=y.useContext(B0);if(!n)throw new Error("useAppContext must be used within an AppProvider");return n}const Nr=null,{min:zs,max:jn,abs:Np,floor:r7}=Math,U0=(n,e,t)=>zs(t,jn(e,n)),W0=n=>[...n].sort((e,t)=>e-t),H0=typeof queueMicrotask=="function"?queueMicrotask:n=>{Promise.resolve().then(n)},Jc=()=>{let n;return[new Promise(e=>{n=e}),n]},q0=n=>{let e;return()=>(n&&(e=n(),n=void 0),e)},lr=(n,e,t)=>{const s=t?"unshift":"push";for(let o=0;o<e;o++)n[s](-1);return n},K0=(n,e)=>{const t=n.t[e];return t===-1?n.o:t},i7=(n,e,t)=>{const s=n.t[e]===-1;return n.t[e]=t,n.i=zs(e,n.i),s},Xi=(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+=K0(n,t),n.u[++t]=s;return n.i=e,s},so=(n,e,t=0,s=n.l-1)=>{let o=t;for(;t<=s;){const i=r7((t+s)/2);Xi(n,i)<=e?(o=i,t=i+1):s=i-1}return U0(o,0,n.l-1)},kp=(n,e,t)=>{const s=e-n.l;return n.i=t?-1:zs(e-1,n.i),n.l=e,s>0?(lr(n.u,s),lr(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))},a7=typeof window<"u",l7=n=>n.documentElement,c7=n=>n.ownerDocument,d7=n=>n.defaultView,V0=q0(()=>!!/iP(hone|od|ad)/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>0),u7=q0(()=>"scrollBehavior"in l7(document).style),f7=n=>jn(n.h(),n.p()),m7=(n,e=40,t=0,s,o=!1)=>{let i=!!t,a=1,l=0,c=0,d=0,u=0,f=0,m=0,p=0,h=0,g=Nr,x=[0,i?jn(t-1,0):-1],b=0,w=!1;const v=((E,$,I)=>({o:$,t:I?lr(I.slice(0,zs(E,I.length)),jn(0,E-I.length)):lr([],E),l:E,i:-1,u:lr([],E+1)}))(n,s?s[1]:e,s&&s[0]),S=new Set,j=()=>d-c,k=()=>j()+f+u,C=(E,$)=>((I,R,D,O)=>{if(O=zs(O,I.l-1),Xi(I,O)<=R){const M=so(I,D,O);return[so(I,R,O,M),M]}{const M=so(I,R,void 0,O);return[M,so(I,D,M)]}})(v,E,$,x[0]),N=()=>Xi(v,v.l),_=(E,$)=>{const I=Xi(v,E)-f;return $?N()-I-A(E):I},A=E=>K0(v,E),P=(E,$=-1)=>v.t[E]===$,T=E=>{E&&(V0()&&p!==0||g&&h===1?f+=E:u+=E)};return{v:()=>{S.clear()},m:()=>a,_:()=>(E=>[E.t.slice(),E.o])(v),S:(E=200)=>{if(!w||i)return x;let $,I;if(m)[$,I]=x;else{let R=jn(0,k()),D=R+l;o||(E=jn(0,E),p!==1&&(R-=E),p!==2&&(D+=E)),[$,I]=x=C(jn(0,R),jn(0,D)),g&&($=zs($,g[0]),I=jn(I,g[1]))}return[jn($,0),zs(I,v.l-1)]},$:E=>so(v,E-c),I:P,k:_,R:A,T:()=>v.l,C:()=>d,M:()=>p!==0,p:()=>l,O:()=>c,h:N,H:()=>(m=u,u=0,[m,h===2]),W:(E,$)=>{const I=[E,$];return S.add(I),()=>{S.delete(I)}},B:(E,$)=>{let I,R,D=0;switch(E){case 1:{if($===d&&h===0)break;const O=m;m=0;const M=$-d,F=Np(M);O&&F<Np(O)+1||h!==0||(p=M<0?2:1),i&&(i=!1),d=$,D=4;const z=j();z>=-l&&z<=N()&&(D+=1,R=F>l);break}case 2:D=8,p!==0&&(I=!0,D+=1),p=0,h=0,g=Nr;break;case 3:{const O=$.filter(([M,F])=>!P(M,F));if(!O.length)break;T(O.reduce((M,[F,z])=>{let L;if(h===2)L=!0;else if(g&&h===1)L=F<g[0];else{const W=j(),U=_(F),H=A(F);L=p!==1&&h===0?U+H<=W:U<W&&U+H<W+l}return L&&(M+=z-A(F)),M},0));for(const[M,F]of O){const z=A(M),L=i7(v,M,F);o&&(b+=L?F:F-z)}o&&l&&b>l&&(T(((M,F)=>{let z=0;const L=[];M.t.forEach((Y,q)=>{Y!==-1&&(L.push(Y),q<F&&z++)}),M.i=-1;const W=W0(L),U=W.length,H=U/2|0,K=U%2==0?(W[H-1]+W[H])/2:W[H],V=M.o;return((M.o=K)-V)*jn(F-z,0)})(v,so(v,k()))),o=!1),D=3,R=!0;break}case 4:l!==$&&(l||(w=R=!0),l=$,D=3);break;case 5:$[1]?(T(kp(v,$[0],!0)),h=2,D=1):(kp(v,$[0]),D=1);break;case 6:c=$;break;case 7:h=1;break;case 8:g=C($,$+l),D=1}D&&(a=1+(2147483647&a),I&&f&&(u+=f,f=0),S.forEach(([O,M])=>{D&O&&M(R)}))}}},yu=setTimeout,Kl=(n,e)=>e?-n:n,p7=(n,e,t,s,o,i)=>{const a=Date.now;let l=0,c=!1,d=!1,u=!1,f=!1;const m=(()=>{let b;const w=()=>{b!=Nr&&clearTimeout(b)},v=()=>{w(),b=yu(()=>{b=Nr,(()=>{if(c||d)return c=!1,void m();u=!1,n.B(2)})()},150)};return v.J=w,v})(),p=()=>{l=a(),u&&(f=!0),n.B(1,s()),m()},h=b=>{if(c||!n.M()||b.ctrlKey)return;const w=a()-l;150>w&&50<w&&(t?b.deltaX:b.deltaY)&&(c=!0)},g=()=>{d=!0,u=f=!1},x=()=>{d=!1,V0()&&(u=!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[b,w]=n.H();b&&(o(b,w,f),f=!1,w&&n.p()>n.h()&&n.B(1,s()))}}},h7=(n,e,t)=>{let s;return[async(o,i)=>{if(!await e())return;s&&s();const a=()=>{const[l,c]=Jc();return s=()=>{c(!1)},n.p()&&yu(s,150),[l,n.W(2,()=>{c(!0)})]};if(i&&u7())n.B(8,o()),H0(async()=>{for(;;){let l=!0;for(let[u,f]=n.S();u<=f;u++)if(n.I(u)){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()}]},g7=(n,e)=>{let t,s,o=Jc(),i=!1;const a=e?"scrollLeft":"scrollTop",l=e?"overflowX":"overflowY",[c,d]=h7(n,()=>o[0],(u,f)=>{u=Kl(u,i),f?t.scrollTo({[e?"left":"top"]:u,behavior:"smooth"}):t[a]=u});return{N(u,f){t=f,e&&(i=getComputedStyle(f).direction==="rtl"),s=p7(n,f,e,()=>Kl(f[a],i),(m,p,h)=>{if(h){const g=f.style,x=g[l];g[l]="hidden",yu(()=>{g[l]=x})}f[a]=Kl(n.C()+m,i),p&&d()}),o[1](!0)},v(){s&&s.A(),o[1](!1),o=Jc()},P:()=>i,V(u){c(()=>u)},X(u){u+=n.C(),c(()=>u)},Y(u,{align:f,smooth:m,offset:p=0}={}){if(u=U0(u,0,n.T()-1),f==="nearest"){const h=n.k(u),g=n.C();if(h<g)f="start";else{if(!(h+n.R(u)>g+n.p()))return;f="end"}}c(()=>p+n.O()+n.k(u)+(f==="end"?n.R(u)-n.p():f==="center"?(n.R(u)-n.p())/2:0),m)},q:()=>{s&&s.L()}}},x7=n=>{let e;return{j(t){(e||(e=new(d7(c7(t))).ResizeObserver(n))).observe(t)},D(t){e.unobserve(t)},A(){e&&e.disconnect()}}},b7=(n,e)=>{let t;const s=e?"width":"height",o=new WeakMap,i=x7(a=>{const l=[];for(const{target:c,contentRect:d}of a)if(c.offsetParent)if(c===t)n.B(4,d[s]);else{const u=o.get(c);u!=Nr&&l.push([u,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}},la=a7?y.useLayoutEffect:y.useEffect,nn="current",G0=(n,e)=>{if(Array.isArray(n))for(const t of n)G0(t,e);else n==null||typeof n=="boolean"||e.push(n)},v7=(n,e)=>{const t=n.key;return t??"_"+e},y7=n=>{const e=y.useRef(null);return e[nn]||(e[nn]=n())},Cp=n=>{const e=y.useRef(n);return la(()=>{e[nn]=n},[n]),e},w7=y.memo(({Z:n,ee:e,te:t,oe:s,ne:o,re:i,se:a,ie:l})=>{const c=y.useRef(null);la(()=>e(c[nn],t),[t]);const d=y.useMemo(()=>{const u={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&&(u.display="inline-flex"),u},[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})}),j7=(n,e)=>y.useMemo(()=>{if(typeof n=="function")return[s=>n(e[s],s),e.length];const t=(s=>{const o=[];return G0(s,o),o})(n);return[s=>t[s],t.length]},[n,e]),S7=y.forwardRef(({children:n,data:e,bufferSize:t,itemSize:s,shift:o,horizontal:i,keepMounted:a,cache:l,startMargin:c=0,ssrCount:d,as:u="div",item:f="div",scrollRef:m,onScroll:p,onScrollEnd:h},g)=>{const[x,b]=j7(n,e),w=y.useRef(null),v=y.useRef(!!d),S=Cp(p),j=Cp(h),[k,C,N,_]=y7(()=>{const D=!!i,O=m7(b,s,d,l,!s);return[O,b7(O,D),g7(O,D),D]});b!==k.T()&&k.B(5,[b,o]),c!==k.O()&&k.B(6,c);const[A,P]=y.useReducer(k.m,void 0,k.m),T=k.M(),E=k.h(),$=N.P(),I=[],R=D=>{const O=x(D);return r.jsx(w7,{ee:C.U,te:D,oe:k.k(D,$),ne:k.I(D),re:f,Z:O,se:_,ie:v[nn]},v7(O,D))};if(la(()=>{v[nn]=!1,k.W(1,M=>{M?wy.flushSync(P):P()}),k.W(4,()=>{S[nn]&&S[nn](k.C())}),k.W(8,()=>{j[nn]&&j[nn]()});const D=w[nn],O=M=>{C.G(M),N.N(D,M)};return m?H0(()=>{m[nn]&&O(m[nn])}):O(D.parentElement),()=>{k.v(),C.v(),N.v()}},[]),la(()=>{N.q()},[A]),y.useImperativeHandle(g,()=>({get cache(){return k._()},get scrollOffset(){return k.C()},get scrollSize(){return f7(k)},get viewportSize(){return k.p()},findItemIndex:k.$,getItemOffset:k.k,getItemSize:k.R,scrollToIndex:N.Y,scrollTo:N.V,scrollBy:N.X}),[]),a){const D=new Set(a);for(let[O,M]=k.S(t);O<=M;O++)D.add(O);W0([...D]).forEach(O=>{I.push(R(O))})}else for(let[D,O]=k.S(t);D<=O;D++)I.push(R(D));return r.jsx(u,{ref:w,style:{contain:"size style",overflowAnchor:"none",flex:"none",position:"relative",width:_?E:"100%",height:_?"100%":E,pointerEvents:T?"none":void 0},children:I})});function N7(n){const e=B.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(kd,{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(Nt,{orientation:"vertical",className:"h-4"}),e[8]=d):d=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(q3,{"data-icon":"inline-start"}),e[9]=u):u=e[9];let f;e[10]!==s?(f=r.jsxs(ee,{variant:"default",size:"sm",onClick:s,children:[u,"Redo all"]}),e[10]=s,e[11]=f):f=e[11];let m;return e[12]!==c||e[13]!==f?(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,f]}),e[12]=c,e[13]=f,e[14]=m):m=e[14],m}const _p=new Map;function k7(n){let e=_p.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},_p.set(n,e)}return e}function Y0(n){const e=B.c(5),t="100%",s=y.useRef(null),[o,i]=y.useState(!0);let a,l;e[0]!==t?(a=()=>{const d=s.current;if(!d)return;const{observer:u,callbacks:f}=k7(t);return f.set(d,i),u.observe(d),()=>{u.unobserve(d),f.delete(d)}},l=[t],e[0]=t,e[1]=a,e[2]=l):(a=e[1],l=e[2]),y.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 ca(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 Tp(n){const e=ca(n.lastActivityAt);return e!==Number.NEGATIVE_INFINITY?e:ca(n.lastModified)}function Ep(n,e){return n===e?0:e-n}function Ap(n){return[n.dirName??"",n.fileName??"",n.sessionId??""].join("/")}function C7(n,e){const t=Ep(Tp(n),Tp(e));if(t!==0)return t;const s=Ep(ca(n.lastModified),ca(e.lastModified));return s!==0?s:Ap(n).localeCompare(Ap(e))}function wu(n){return[...n].sort(C7)}function X0(n,e){const t=!!(n.teamName&&n.agentName);return e||kn(n.aiTitle||(t?n.agentName:"")||n.lastUserMessage||n.firstUserMessage||n.slug||n.sessionId,50)}const _7="Unknown project";function ju(n){const e=Fa(n);return za(e?e.parentPath:n,2)||_7}function T7(n){return ju(n.cwd||_n(n.dirName))}function E7(n){const e=wu(n),t=new Map;for(const s of e){const o=T7(s),i=t.get(o);i?i.push(s):t.set(o,[s])}return t}function J0(n,e){return n.isActive?!0:e.has(n.sessionId)?n.agentStatus!=="completed":!1}function A7(n,e,t){let s=-1;return n.forEach((o,i)=>{J0(o,e)&&(s=i)}),Math.max(t,s+1)}const Su=new Set(["thinking","tool_use","processing","compacting","awaiting_agents"]),P7=12e4;function $7(n,e=Date.now()){const t=Date.parse(n.lastActivityAt||n.lastModified);return Number.isFinite(t)&&e-t<P7}function Q0(n,e,t=Date.now()){return J0(n,e)?!0:n.agentStatus==="completed"||!n.agentStatus?!1:$7(n,t)}function R7(n,e,t=Date.now()){return n.some(s=>Q0(s,e,t))}const I7="cogpit:session-list-cache",M7=10080*60*1e3,O7=24,Qn={projects:"projects",activeSessions:"active-sessions",runningProcesses:"running-processes"},Qc=new Map;function D7(){return{version:1,entries:{}}}function Z0(){return Vt(I7)}function e2(){const n=Z0(),e=Qc.get(n);if(e)return e;let t=D7();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 Qc.set(n,t),t}function t2(n){const e=e2().entries[n];if(!(!e||Date.now()-e.savedAt>M7))return e.value}function n2(n,e){const t=Z0(),o={...e2().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,O7))};Qc.set(t,a);try{localStorage.setItem(t,JSON.stringify(a))}catch{}}function da(n){const e=t2(n);return Array.isArray(e)?e:void 0}function cr(n,e){n2(n,e)}function s2(n){return`sessions:${n}`}function L7(n){const e=t2(s2(n));if(!e||typeof e!="object")return;const t=e;if(!(!Array.isArray(t.sessions)||typeof t.total!="number"))return t}function z7(n,e){n2(s2(n),e)}const F7=2e4;function B7(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 o2=y.createContext(null);function U7({children:n}){const[e]=y.useState(Nn),[t,s]=y.useState(()=>da(Qn.activeSessions)??[]),[o,i]=y.useState(()=>da(Qn.runningProcesses)??[]),[a,l]=y.useState(!1),[c,d]=y.useState(null),[u,f]=y.useState(new Set),m=y.useRef(null),p=y.useRef(null),h=y.useRef(!1);y.useEffect(()=>(h.current=!0,()=>{var k;h.current=!1,(k=p.current)==null||k.abort(),p.current=null}),[]);const g=y.useCallback(async()=>{var N;if(!h.current||Nn()!==e)return;(N=p.current)==null||N.abort();const k=new AbortController;p.current=k;const C=()=>h.current&&!k.signal.aborted&&p.current===k&&Nn()===e;l(!0);try{const[_,A]=await Promise.all([be("/api/active-sessions",{signal:k.signal}),be("/api/running-processes",{signal:k.signal})]);if(!C())return;if(!_.ok||!A.ok)throw new Error("Failed to fetch live data");const[P,T]=await Promise.all([_.json(),A.json()]);if(!C())return;const E=Array.isArray(P)?P:[],$=Array.isArray(T)?T:[];s(E),i($),cr(Qn.activeSessions,E),cr(Qn.runningProcesses,$),d(null)}catch(_){if(!C())return;d(_ instanceof Error?_.message:"Failed to load data")}finally{C()&&l(!1),p.current===k&&(p.current=null)}},[e]),x=y.useCallback(()=>{g()},[g]);y.useEffect(()=>{x()},[x]);const b=y.useMemo(()=>B7(o),[o]),w=y.useMemo(()=>R7(t,b),[t,b]);y.useEffect(()=>(window.addEventListener("focus",x),()=>window.removeEventListener("focus",x)),[x]),y.useEffect(()=>{if(!w)return;const k=setInterval(()=>{document.visibilityState==="visible"&&x()},F7);return()=>clearInterval(k)},[w,x]),y.useEffect(()=>{if(t.length===0)return;const k=m.current,C=new Map;for(const N of t)N.agentStatus&&b.has(N.sessionId)&&C.set(N.sessionId,N.agentStatus);k!==null&&f(N=>{let _=null;for(const[A,P]of C)P==="completed"&&k.get(A)!=="completed"&&(_??(_=new Set(N)),_.add(A));for(const A of N)C.get(A)!=="completed"&&(_??(_=new Set(N)),_.delete(A));return _??N}),m.current=C},[t,b]);const v=y.useCallback(k=>{f(C=>{if(!C.has(k))return C;const N=new Set(C);return N.delete(k),N})},[]),S=y.useCallback(k=>{s(C=>{const N=C.filter(_=>_.sessionId!==k);return Nn()===e&&cr(Qn.activeSessions,N),N})},[e]),j=y.useMemo(()=>({sessions:t,processes:o,procBySession:b,newlyCompleted:u,loading:a,error:c,refresh:x,removeSession:S,acknowledgeCompleted:v}),[t,o,b,u,a,c,x,S,v]);return r.jsx(o2.Provider,{value:j,children:n})}function r2(){const n=Nu();if(!n)throw new Error("useSessionInventory must be used within a SessionInventoryProvider");return n}function Nu(){return y.useContext(o2)}const Pp=[20,50,80,110,140,170,200,230,260,290,320,350];function W7(n){let e=2166136261;for(let t=0;t<n.length;t++)e^=n.charCodeAt(t),e=Math.imul(e,16777619);return Pp[(e>>>0)%Pp.length]}function Vl(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 H7(n){const e=n.split(`
|
|
86
|
+
`);let t=0;for(;t<e.length&&e[t].trim()==="";)t++;const s=Vl(e[t]??"");return s?{subject:s,preview:Vl(e.slice(t+1).join(`
|
|
87
|
+
`))}:{subject:Vl(n),preview:""}}function Zc(n){if(!n)return null;const e=new Date(n).getTime();return Number.isNaN(e)?null:e}function q7(n,e){return n===null||e===null||e<n?null:e-n}function K7(n){const e=Zc(n);return e===null?null:new Date(e).toLocaleTimeString()}function V7(n){var s;const e=(s=Nu())==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=Su.has(i)?"working":"idle"}return t}const G7=y.memo(function(e){const t=B.c(48),{sender:s,body:o,timestamp:i,reply:a,isLive:l}=e,[c,d]=y.useState(!1);let u;t[0]!==o?(u=kC(o),t[0]=o,t[1]=u):u=t[1];const f=u;let m;t[2]!==f?(m=H7(f),t[2]=f,t[3]=m):m=t[3];const{subject:p,preview:h}=m;let g;t[4]!==i?(g=K7(i),t[4]=i,t[5]=g):g=t[5];const x=g,b=V7(s);let w;t[6]!==f?(w=AC(f),t[6]=f,t[7]=w):w=t[7];const v=w,S=v&&!a,j=Zc(i),k=a?q7(j,Zc(a.timestamp)):null,C=!a&&l===!0,N=!!a||v;kg(C&&N);const _=!0;let A;t[8]!==s?(A=W7(s),t[8]=s,t[9]=A):A=t[9];const P=String(A);let T;t[10]!==P?(T={"--agent-hue":P},t[10]=P,t[11]=T):T=t[11];const E=T,$="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(K3,{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 D;t[15]!==b||t[16]!==s?(D=b&&r.jsx("span",{"data-testid":"agent-liveness","data-live":b,title:b==="working"?`${s} is working now`:`${s} is idle`,className:`inline-flex size-1.5 shrink-0 rounded-full ${b==="working"?"animate-pulse bg-warning":"bg-success"}`}),t[15]=b,t[16]=s,t[17]=D):D=t[17];let O;t[18]!==R||t[19]!==D?(O=r.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[I,R,D]}),t[18]=R,t[19]=D,t[20]=O):O=t[20];let M;t[21]!==S?(M=S&&r.jsx(Pe,{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]=S,t[22]=M):M=t[22];let F;t[23]!==x?(F=x&&r.jsx("span",{className:"text-xs text-muted-foreground",children:x}),t[23]=x,t[24]=F):F=t[24];let z;t[25]!==M||t[26]!==F?(z=r.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[M,F]}),t[25]=M,t[26]=F,t[27]=z):z=t[27];let L;t[28]!==O||t[29]!==z?(L=r.jsxs("div",{className:"flex items-center gap-2",children:[O,z]}),t[28]=O,t[29]=z,t[30]=L):L=t[30];let W;t[31]!==f||t[32]!==c||t[33]!==h||t[34]!==p?(W=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(Hn,{components:Kn,remarkPlugins:Qs,children:f})}):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]=f,t[32]=c,t[33]=h,t[34]=p,t[35]=W):W=t[35];const U="mt-1.5 flex items-center justify-end gap-2",H=N&&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:[k===null?"You replied":`You replied ${Bn(k)} later`,a.summary&&` · "${a.summary}"`]}):C?j===null?"Awaiting your reply":`Awaiting your reply · ${Bn(Math.max(0,Date.now()-j))}`:"Never answered"});let K;t[36]===Symbol.for("react.memo_cache_sentinel")?(K=()=>d(Y7),t[36]=K):K=t[36];let V;t[37]!==f||t[38]!==c?(V=r.jsx(ee,{type:"button",variant:"ghost",size:"xs",onClick:K,className:"-mr-2 text-muted-foreground",children:c?r.jsxs(r.Fragment,{children:[r.jsx(it,{"data-icon":"inline-start"})," Collapse"]}):r.jsxs(r.Fragment,{children:[r.jsx(Xe,{"data-icon":"inline-start"})," Expand ·"," ",f.length.toLocaleString("en-US")," ",f.length===1?"char":"chars"]})}),t[37]=f,t[38]=c,t[39]=V):V=t[39];let Y;t[40]!==H||t[41]!==V?(Y=r.jsxs("div",{className:U,children:[H,V]}),t[40]=H,t[41]=V,t[42]=Y):Y=t[42];let q;return t[43]!==L||t[44]!==W||t[45]!==Y||t[46]!==E?(q=r.jsxs("div",{"data-agent-rail":_,style:E,className:$,children:[L,W,Y]}),t[43]=L,t[44]=W,t[45]=Y,t[46]=E,t[47]=q):q=t[47],q});function Y7(n){return!n}const X7=1500;function Ts(){const n=B.c(5),[e,t]=y.useState(!1),s=y.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]),y.useEffect(o,i);let a;n[2]===Symbol.for("react.memo_cache_sentinel")?(a=async d=>{await Ur(d)&&(t(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>t(!1),X7))},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 J7=y.memo(function(e){const t=B.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=E0(s),t[0]=s,t[1]=d):d=t[1];const u=d,[f,m]=Ts();if(!s)return null;let p;t[2]!==c||t[3]!==f||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:Js(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(ee,{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":f?"Response copied":"Copy response",title:f?"Copied":"Copy response",children:f?r.jsx(dt,{"data-icon":"inline-start"}):r.jsx(xn,{"data-icon":"inline-start"})})]}),t[2]=c,t[3]=f,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]!==u?(x=r.jsx(Hn,{components:Kn,remarkPlugins:Qs,children:u}),t[12]=u,t[13]=x):x=t[13];let b;t[14]!==g||t[15]!==x?(b=r.jsx("div",{className:g,children:x}),t[14]=g,t[15]=x,t[16]=b):b=t[16];let w;return t[17]!==p||t[18]!==b?(w=r.jsxs("div",{className:"group",children:[p,b]}),t[17]=p,t[18]=b,t[19]=w):w=t[19],w}),ho=[];function Q7(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 Z7(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 $p=/"id"\s*:\s*"(msg_[A-Za-z0-9]+)"/g;function eT(n,e){if(n.length===0||e.length===0)return n;const t=new Set;for(const o of e){$p.lastIndex=0;let i;for(;(i=$p.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 tT(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 nT(n){return n.filter(e=>e.parentToolUseId===null)}function sT(n,e){return n.filter(t=>t.parentToolUseId===e)}const i2={},a2=y.createContext(ho),l2=y.createContext(i2);function Gl(n){const e=B.c(6),{value:t,agentProgress:s,children:o}=n,i=s===void 0?i2:s;let a;e[0]!==i||e[1]!==o?(a=r.jsx(l2.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(a2.Provider,{value:t,children:a}),e[3]=a,e[4]=t,e[5]=l):l=e[5],l}function ku(){return y.useContext(a2)}function oT(n){return y.useContext(l2)[n]??null}function oo(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 c2={...Kn,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},rT={...c2,h1:oo("h1"),h2:oo("h2"),h3:oo("h3"),h4:oo("h4"),h5:oo("h5"),h6:oo("h6")},Cu=y.memo(function(e){const t=B.c(3),{text:s,compactHeadings:o}=e,a=(o===void 0?!1:o)?rT:c2;let l;return t[0]!==a||t[1]!==s?(l=r.jsx(Hn,{components:a,remarkPlugins:Qs,children:s}),t[0]=a,t[1]=s,t[2]=l):l=t[2],l}),Rp=400,iT=24,_u=y.memo(function(e){const t=B.c(24),{toolUseId:s}=e,o=ku(),i=oT(s),a=y.useRef(null),[l,c]=y.useState(!0);let d,u,f;if(t[0]!==l||t[1]!==o||t[2]!==s){f=sT(o,s).flatMap(aT).filter(lT).map(cT).join(`
|
|
89
|
+
`);const k=f.split(`
|
|
90
|
+
`);d=l&&k.length>Rp,u=d?k.slice(-Rp).join(`
|
|
91
|
+
`):f,t[0]=l,t[1]=o,t[2]=s,t[3]=d,t[4]=u,t[5]=f}else d=t[3],u=t[4],f=t[5];const m=u;let p;t[6]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{const k=a.current;if(!k)return;const C=k.scrollHeight-k.scrollTop-k.clientHeight<iT;c(N=>N===C?N:C)},t[6]=p):p=t[6];const h=p;let g;t[7]!==l?(g=()=>{const k=a.current;if(!k||!l)return;const C=k.scrollHeight-k.clientHeight;k.scrollTop!==C&&(k.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],y.useLayoutEffect(g,x),!f&&!i)return null;const b=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 v;t[14]!==b||t[15]!==w?(v=r.jsx("div",{"data-testid":b,className:"mb-1 text-xs font-medium text-muted-foreground",children:w}),t[14]=b,t[15]=w,t[16]=v):v=t[16];let S;t[17]!==d||t[18]!==m||t[19]!==f?(S=f&&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(Cu,{text:m,compactHeadings:!0})]}),t[17]=d,t[18]=m,t[19]=f,t[20]=S):S=t[20];let j;return t[21]!==v||t[22]!==S?(j=r.jsxs("div",{className:"mt-2 rounded-md border bg-muted/30 px-3 py-2","data-testid":"live-subagent-transcript",children:[v,S]}),t[21]=v,t[22]=S,t[23]=j):j=t[23],j});function aT(n){return n.blocks}function lT(n){return n.blockType!=="tool_use"&&n.text}function cT(n){return n.text}function Ip(n){return n.length>8?n.slice(0,8):n}function Tu(n,e,t){const s=e??t;return s?`${s} - ${Ip(n)}`:Ip(n)}function dT(n){const e=new Map;for(const t of n)e.has(t.agentId)||e.set(t.agentId,Tu(t.agentId,t.subagentType,t.agentName));return e}function uT(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 fT(n){return n?typeof n=="string"?n:n.map(e=>e.type==="text"?e.text:"").filter(Boolean).join(`
|
|
92
|
+
`):""}function d2(n,e){if(d0(n))return hu(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,u=a.timestamp??"";if(l==="assistant"){const f={agentId:e,agentName:null,subagentType:null,type:"assistant",content:d,toolCalls:[],thinking:[],text:[],timestamp:u,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")f.thinking.push(m.thinking);else if(m.type==="text")f.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:u};f.toolCalls.push(p),s.set(m.id,p)}}t.push(f)}else if(l==="user"&&Array.isArray(d)){for(const f of d)if(f.type==="tool_result"){const m=s.get(f.tool_use_id);m&&(m.result=fT(f.content),m.isError=f.is_error??!1)}}}return t}const Yl=new Map;function mT(n,e){const t=B.c(21),{session:s,sessionSource:o,isLive:i}=at();let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=new Map,t[0]=a):a=t[0];const[l,c]=y.useState(a),[d,u]=y.useState(!1);let f;t[1]===Symbol.for("react.memo_cache_sentinel")?(f=new Set,t[1]=f):f=t[1];const m=y.useRef(f);let p;if(t[2]!==i||t[3]!==n){let _;t[5]!==i?(_=A=>A.text.length>0||A.thinking.length>0||A.toolCalls.length>0?!1:i?A.durationMs!=null:A.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 b;t[7]===Symbol.for("react.memo_cache_sentinel")?(b=qa(window.location.pathname),t[7]=b):b=t[7];const w=b;let v,S;t[8]!==h||t[9]!==g||t[10]!==e||t[11]!==x?(v=()=>{if(w||!e||!g||!x||h.length===0)return;const _=[];for(const T of h){const E=Vt(`${g}/${x}/${T.agentId}`);if(!m.current.has(E)){if(Yl.has(E)){c($=>{const I=new Map($);return I.set(T.agentId,Yl.get(E)),I}),m.current.add(E);continue}_.push({agentId:T.agentId,cacheKey:E})}}if(_.length===0)return;let A=!1;return u(!0),async function(){const E=new Map;await Promise.all(_.map(async $=>{const{agentId:I,cacheKey:R}=$;try{const D=`/api/sessions/${encodeURIComponent(g)}/${encodeURIComponent(x)}/subagents/agent-${encodeURIComponent(I)}.jsonl`,O=await be(D);if(!O.ok)return;const M=await O.text(),F=d2(M,I);Yl.set(R,F),m.current.add(R),E.set(I,F)}catch{}})),!A&&E.size>0&&c($=>{const I=new Map($);for(const[R,D]of E)I.set(R,D);return I}),A||u(!1)}(),()=>{A=!0}},S=[w,e,g,x,h],t[8]=h,t[9]=g,t[10]=e,t[11]=x,t[12]=v,t[13]=S):(v=t[12],S=t[13]),y.useEffect(v,S);let j;e:{if(l.size===0&&h.length===0){j=n;break e}let _;if(t[14]!==l||t[15]!==n){_=[];for(const A of n){const P=l.get(A.agentId);if(P&&P.length>0&&(A.status==="async_launched"||A.durationMs!=null)){const T={...P[0],durationMs:A.durationMs,toolUseCount:A.toolUseCount,status:A.status,prompt:A.prompt,agentName:A.agentName,subagentType:A.subagentType};_.push(T,...P.slice(1))}else _.push(A)}t[14]=l,t[15]=n,t[16]=_}else _=t[16];j=_}const k=j,C=w&&e&&h.length>0;let N;return t[17]!==k||t[18]!==d||t[19]!==C?(N={enrichedMessages:k,isLoading:d,unavailable:C},t[17]=k,t[18]=d,t[19]=C,t[20]=N):N=t[20],N}const u2=y.memo(function(e){const t=B.c(74),{messages:s,expandAll:o,label:i,countLabel:a,lazyLoad:l}=e,c=l===void 0?!1:l,[d,u]=y.useState(!1),f=o||d,{sessionSource:m,actions:p}=at(),h=m==null?void 0:m.dirName;let g;t[0]!==h?(g=To(h),t[0]=h,t[1]=g):g=t[1];const x=g.subagentTranscripts,{enrichedMessages:b,isLoading:w,unavailable:v}=mT(s,c&&f&&x);let S;e:{if(!(m!=null&&m.fileName)){S=null;break e}let X;t[2]!==m.fileName?(X=Ns(m.fileName),t[2]=m.fileName,t[3]=X):X=t[3];const Z=X;if(Z){S=Z.parentSessionId;break e}let te;if(t[4]!==m.fileName){let oe;t[6]===Symbol.for("react.memo_cache_sentinel")?(oe=/^([^/]+)\.jsonl$/,t[6]=oe):oe=t[6],te=m.fileName.match(oe),t[4]=m.fileName,t[5]=te}else te=t[5];const ne=te;S=(ne==null?void 0:ne[1])??null}const j=S;let k;t[7]!==b?(k=new Set(b.map(hT)),t[7]=b,t[8]=k):k=t[8];let C;t[9]!==k?(C=[...k],t[9]=k,t[10]=C):C=t[10];const N=C;let _;t[11]!==b?(_=dT(b),t[11]=b,t[12]=_):_=t[12];const A=_;let P;if(t[13]!==b||t[14]!==s){P=new Map;for(const X of[...s,...b]){const Z=P.get(X.agentId)??{};X.durationMs!=null&&(Z.durationMs=X.durationMs),X.toolUseCount!=null&&(Z.toolUseCount=X.toolUseCount),X.status&&(Z.status=X.status),P.set(X.agentId,Z)}t[13]=b,t[14]=s,t[15]=P}else P=t[15];const T=P;let E;t[16]!==b||t[17]!==s?(E=uT([...s,...b]),t[16]=b,t[17]=s,t[18]=E):E=t[18];const $=E;let I,R;if(t[19]!==b){R=new Map,I=new Map;for(const X of b)I.set(X.agentId,X),X.text.length>0&&R.set(X.agentId,X);t[19]=b,t[20]=I,t[21]=R}else I=t[20],R=t[21];let D;if(t[22]!==N||t[23]!==I||t[24]!==R){D=new Map;for(const X of N){const Z=R.get(X)??I.get(X);Z&&D.set(X,Z)}t[22]=N,t[23]=I,t[24]=R,t[25]=D}else D=t[25];const O=D;let M;e:{let X=0,Z=0,te=!1,ne=!0;for(const re of s)re.durationMs!=null&&(X=X+re.durationMs,te=!0),re.toolUseCount!=null&&(Z=Z+re.toolUseCount),re.status&&re.status!=="completed"&&(ne=!1);if(!te){M=null;break e}let oe;t[26]!==ne||t[27]!==X||t[28]!==Z?(oe={totalDuration:X,totalToolUses:Z,allCompleted:ne},t[26]=ne,t[27]=X,t[28]=Z,t[29]=oe):oe=t[29],M=oe}const F=M;if(s.length===0)return null;let z;t[30]!==d?(z=()=>u(!d),t[30]=d,t[31]=z):z=t[31];let L;t[32]!==f?(L=f?r.jsx(it,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}):r.jsx(Xe,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),t[32]=f,t[33]=L):L=t[33];let W;t[34]===Symbol.for("react.memo_cache_sentinel")?(W=r.jsx(ss,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),t[34]=W):W=t[34];let U;t[35]!==i?(U=r.jsx("span",{className:"text-xs font-medium text-foreground",children:i}),t[35]=i,t[36]=U):U=t[36];let H;t[37]!==N.length||t[38]!==a?(H=N.length>1&&r.jsxs(Pe,{variant:"secondary",children:[N.length," ",a]}),t[37]=N.length,t[38]=a,t[39]=H):H=t[39];let K;t[40]!==N||t[41]!==A?(K=N.map(X=>r.jsx(Pe,{variant:"outline",children:A.get(X)},X)),t[40]=N,t[41]=A,t[42]=K):K=t[42];let V;t[43]!==N.length||t[44]!==F?(V=F?r.jsxs("span",{className:"inline-flex items-center gap-2 text-xs text-muted-foreground",children:[F.allCompleted?r.jsx(Wn,{className:"size-3 text-success","data-icon":"inline-start"}):r.jsx(Ys,{className:"size-3 text-destructive","data-icon":"inline-start"}),r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(Us,{className:"size-3","data-icon":"inline-start"}),Bn(F.totalDuration)]}),F.totalToolUses>0&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(_a,{className:"size-3","data-icon":"inline-start"}),F.totalToolUses]})]}):r.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",N.length," agent",N.length!==1?"s":"",")"]}),t[43]=N.length,t[44]=F,t[45]=V):V=t[45];let Y;t[46]!==z||t[47]!==L||t[48]!==U||t[49]!==H||t[50]!==K||t[51]!==V?(Y=r.jsxs(ee,{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:[L,W,U,H,K,V]}),t[46]=z,t[47]=L,t[48]=U,t[49]=H,t[50]=K,t[51]=V,t[52]=Y):Y=t[52];let q;t[53]!==N||t[54]!==f||t[55]!==$?(q=!f&&N.map(X=>{const Z=$.get(X);return Z?r.jsx(_u,{toolUseId:Z},X):null}),t[53]=N,t[54]=f,t[55]=$,t[56]=q):q=t[56];let J;t[57]!==p||t[58]!==N||t[59]!==A||t[60]!==O||t[61]!==x||t[62]!==w||t[63]!==f||t[64]!==j||t[65]!==$||t[66]!==m||t[67]!==T||t[68]!==v?(J=f&&r.jsxs("div",{className:"motion-enter mt-2 flex flex-col gap-2",children:[v?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..."]}),N.map(X=>{const Z=O.get(X),te=T.get(X),ne=x&&!!m&&!!j&&!v;return r.jsx(pT,{agentLabel:A.get(X)??X,message:Z,stats:te,parentToolUseId:$.get(X),canNavigate:ne,onOpen:()=>{ne&&p.handleLoadSession(m.dirName,`${j}/subagents/agent-${X}.jsonl`)}},X)})]}),t[57]=p,t[58]=N,t[59]=A,t[60]=O,t[61]=x,t[62]=w,t[63]=f,t[64]=j,t[65]=$,t[66]=m,t[67]=T,t[68]=v,t[69]=J):J=t[69];let Q;return t[70]!==Y||t[71]!==q||t[72]!==J?(Q=r.jsxs("div",{children:[Y,q,J]}),t[70]=Y,t[71]=q,t[72]=J,t[73]=Q):Q=t[73],Q});function pT(n){const e=B.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=E0((c??[]).join(`
|
|
96
|
+
|
|
97
|
+
`)),e[0]=c,e[1]=d):d=e[1];const u=d,f=((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(Pe,{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(Wn,{className:"size-3 text-success"}),o.durationMs!=null&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(Us,{className:"size-3"}),Bn(o.durationMs)]}),o.toolUseCount!=null&&o.toolUseCount>0&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(_a,{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(ee,{type:"button",variant:"ghost",size:"xs",onClick:l,className:"ml-auto",title:"Open this sub-agent's full chat session",children:[r.jsx(O1,{"data-icon":"inline-start"}),"Open chat"]}),e[7]=a,e[8]=l,e[9]=x):x=e[9];let b;e[10]!==h||e[11]!==g||e[12]!==x?(b=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]=b):b=e[13];let w;e[14]!==f||e[15]!==m||e[16]!==u||e[17]!==i?(w=f?r.jsx("div",{className:"text-xs break-words overflow-hidden",children:r.jsx(Hn,{components:Kn,remarkPlugins:Qs,children:u})}):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(_u,{toolUseId:i})]}),e[14]=f,e[15]=m,e[16]=u,e[17]=i,e[18]=w):w=e[18];let v;return e[19]!==b||e[20]!==w?(v=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:[b,w]})}),e[19]=b,e[20]=w,e[21]=v):v=e[21],v}function hT(n){return n.agentId}const gT=y.memo(function(e){const t=B.c(3),{messages:s,expandAll:o}=e;let i;return t[0]!==o||t[1]!==s?(i=r.jsx(u2,{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}),xT=y.memo(function(e){const t=B.c(3),{messages:s,expandAll:o}=e;let i;return t[0]!==o||t[1]!==s?(i=r.jsx(u2,{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}),bT=new Set(["StopFailure","PermissionDenied","PostToolUseFailure"]),vT=y.memo(function(e){const t=B.c(30),{events:s}=e,[o,i]=y.useState(!1);if(s.length===0)return null;let a;t[0]!==s?(a=s.some(yT),t[0]=s,t[1]=a):a=t[1];const l=a,c=o?it:Xe,d=l?"border-destructive/20 bg-destructive/5":"bg-muted/30";let u;t[2]!==d?(u=G("my-1 rounded-md border px-2 py-1 text-xs",d),t[2]=d,t[3]=u):u=t[3];let f;t[4]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(ee,{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]=f):f=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(Yt,{className:"size-3 text-destructive","data-icon":"inline-start"}):r.jsx(V3,{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(wT).join(", "),t[12]=s,t[13]=x):x=t[13];let b;t[14]!==x?(b=r.jsx("span",{className:"truncate text-muted-foreground/60",children:x}),t[14]=x,t[15]=b):b=t[15];let w;t[16]!==b||t[17]!==m||t[18]!==p||t[19]!==g?(w=r.jsxs(Rt,{render:f,children:[m,p,g,b]}),t[16]=b,t[17]=m,t[18]=p,t[19]=g,t[20]=w):w=t[20];let v;t[21]!==s?(v=s.map(jT),t[21]=s,t[22]=v):v=t[22];let S;t[23]!==v?(S=r.jsx(mt,{children:r.jsx("ul",{className:"ml-5 mt-1 flex flex-col gap-0.5 font-mono",children:v})}),t[23]=v,t[24]=S):S=t[24];let j;return t[25]!==o||t[26]!==w||t[27]!==S||t[28]!==u?(j=r.jsxs(ft,{open:o,onOpenChange:i,className:u,children:[w,S]}),t[25]=o,t[26]=w,t[27]=S,t[28]=u,t[29]=j):j=t[29],j});function yT(n){return bT.has(n.eventName)||n.exitCode!==void 0&&n.exitCode!==0}function wT(n){return n.eventName}function jT(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 ST=24,Xo=[];function NT(n,e){for(let s=0;s<Xo.length;s++){const o=Xo[s];if(o.oldStr===n&&o.newStr===e)return o.result}const t=CT(n,e);return Xo.length>=ST&&Xo.shift(),Xo.push({oldStr:n,newStr:e,result:t}),t}const kT=25e4;function CT(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,u=[];for(let f=0;f<a;f++)u.push({type:"unchanged",text:t[f],oldIdx:f,newIdx:f});if(!(c===0&&d===0))if(c===0)for(let f=0;f<d;f++)u.push({type:"added",text:s[a+f],newIdx:a+f});else if(d===0)for(let f=0;f<c;f++)u.push({type:"removed",text:t[a+f],oldIdx:a+f});else if(c*d>kT){for(let f=0;f<c;f++)u.push({type:"removed",text:t[a+f],oldIdx:a+f});for(let f=0;f<d;f++)u.push({type:"added",text:s[a+f],newIdx:a+f})}else{const f=d+1,m=new Int32Array((c+1)*f);for(let x=1;x<=c;x++){const b=t[a+x-1],w=x*f,v=w-f;for(let S=1;S<=d;S++)if(b===s[a+S-1])m[w+S]=m[v+S-1]+1;else{const j=m[v+S],k=m[w+S-1];m[w+S]=j>k?j:k}}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*f+g-1]>=m[(h-1)*f+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(),u.push(...p)}for(let f=0;f<l;f++){const m=o-l+f,p=i-l+f;u.push({type:"unchanged",text:t[m],oldIdx:m,newIdx:p})}return u}function _T(n,e,t,s){const o=B.c(9),[i,a]=y.useState(null),[l,c]=y.useState(null);let d,u;o[0]!==t||o[1]!==s||o[2]!==e||o[3]!==n?(d=()=>{const m=yx(t);if(!m){a(null),c(null);return}const p=s?"github-dark":"github-light";let h=!1;const g=requestAnimationFrame(()=>{h||bx().then(async x=>{if(h||(await vx(x,m),h))return;const b=x.codeToTokens(n,{lang:m,theme:p});if(h)return;a(b.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)}},u=[n,e,t,s],o[0]=t,o[1]=s,o[2]=e,o[3]=n,o[4]=d,o[5]=u):(d=o[4],u=o[5]),y.useEffect(d,u);let f;return o[6]!==l||o[7]!==i?(f={oldTokens:i,newTokens:l},o[6]=l,o[7]=i,o[8]=f):f=o[8],f}const TT={removed:"bg-destructive/10",added:"bg-success/10",unchanged:""},Mp={removed:"border-destructive/20 text-destructive/70",added:"border-success/20 text-success/70",unchanged:"border-border text-muted-foreground"},ET={removed:"text-destructive",added:"text-success",unchanged:"text-muted-foreground"};function AT(n,e){return n.map((t,s)=>r.jsx("span",{style:{color:t.color},className:G(e&&"opacity-50"),children:t.content},s))}function PT(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 $T(n){const e=B.c(3),{type:t}=n;switch(t){case"removed":{let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(M1,{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(Fn,{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 Xl=3;function RT(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<=Xl*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-Xl);a<=Math.min(n.length-1,i+Xl);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 IT(n){const e=B.c(7),{count:t,onExpand:s}=n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx($a,{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(ee,{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 Op=y.memo(function(e){const t=B.c(33),{line:s,lineNum:o,oldTokens:i,newTokens:a}=e;let l,c,d,u,f,m;if(t[0]!==s||t[1]!==o||t[2]!==a||t[3]!==i){m=PT(s,i,a);const x=TT[s.type];t[10]!==x?(d=G("flex",x),t[10]=x,t[11]=d):d=t[11];const b=Mp[s.type];let w;t[12]!==b?(w=G("w-8 shrink-0 select-none border-r pr-1 text-right text-xs leading-relaxed tabular-nums",b),t[12]=b,t[13]=w):w=t[13],t[14]!==o||t[15]!==w?(u=r.jsx("span",{className:w,children:o}),t[14]=o,t[15]=w,t[16]=u):u=t[16];const v=Mp[s.type];let S;t[17]!==v?(S=G("select-none shrink-0 w-5 text-right pr-1 border-r",v),t[17]=v,t[18]=S):S=t[18];let j;t[19]!==s.type?(j=r.jsx($T,{type:s.type}),t[19]=s.type,t[20]=j):j=t[20],t[21]!==S||t[22]!==j?(f=r.jsx("span",{className:S,children:j}),t[21]=S,t[22]=j,t[23]=f):f=t[23],l="pl-2 whitespace-pre",c=m?AT(m,s.type==="unchanged"):r.jsx("span",{className:ET[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]=u,t[8]=f,t[9]=m}else l=t[4],c=t[5],d=t[6],u=t[7],f=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]!==u||t[30]!==f||t[31]!==h?(g=r.jsxs("div",{className:d,children:[u,f,h]}),t[28]=d,t[29]=u,t[30]=f,t[31]=h,t[32]=g):g=t[32],g}),Dp=120,Lp=60,MT=120;function zp(n){const e=B.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,u]=y.useState(c);let f;e[1]!==t?(f=RT(t),e[1]=t,e[2]=f):f=e[2];const m=f,p=m.length>Dp,[h,g]=y.useState(p?Lp:m.length);let x;e[3]!==m.length?(x=()=>{g(m.length>Dp?Lp:m.length)},e[3]=m.length,e[4]=x):x=e[4];let b;e[5]!==m?(b=[m],e[5]=m,e[6]=b):b=e[6],y.useEffect(x,b);let w,v;e[7]!==m.length||e[8]!==h?(w=()=>{if(h>=m.length)return;const T=requestAnimationFrame(()=>{g(E=>Math.min(E+MT,m.length))});return()=>cancelAnimationFrame(T)},v=[h,m.length],e[7]=m.length,e[8]=h,e[9]=w,e[10]=v):(w=e[9],v=e[10]),y.useEffect(w,v);let S;e[11]===Symbol.for("react.memo_cache_sentinel")?(S=T=>{u(E=>new Set(E).add(T))},e[11]=S):S=e[11];const j=S;let k;e[12]!==m||e[13]!==p||e[14]!==h?(k=p?m.slice(0,h):m,e[12]=m,e[13]=p,e[14]=h,e[15]=k):k=e[15];const C=k,N=i&&"max-h-64 overflow-y-auto";let _;e[16]!==N?(_=G("overflow-x-auto font-mono text-xs leading-relaxed",N),e[16]=N,e[17]=_):_=e[17];let A;if(e[18]!==d||e[19]!==C||e[20]!==t||e[21]!==o||e[22]!==s||e[23]!==l){let T;e[25]!==d||e[26]!==t||e[27]!==o||e[28]!==s||e[29]!==l?(T=(E,$)=>{if(E.kind==="separator")return d.has(E.fromIdx)?t.slice(E.fromIdx,E.toIdx+1).map((D,O)=>{const M=E.fromIdx+O;return r.jsx(Op,{line:D,lineNum:D.type==="removed"?(D.oldIdx??0)+l:(D.newIdx??0)+l,oldTokens:s,newTokens:o},`exp-${M}`)}):r.jsx(IT,{count:E.count,onExpand:()=>j(E.fromIdx)},`sep-${$}`);const{line:I}=E,R=I.type==="removed"?(I.oldIdx??0)+l:(I.newIdx??0)+l;return r.jsx(Op,{line:I,lineNum:R,oldTokens:s,newTokens:o},$)},e[25]=d,e[26]=t,e[27]=o,e[28]=s,e[29]=l,e[30]=T):T=e[30],A=C.map(T),e[18]=d,e[19]=C,e[20]=t,e[21]=o,e[22]=s,e[23]=l,e[24]=A}else A=e[24];let P;return e[31]!==_||e[32]!==A?(P=r.jsx("div",{className:_,children:A}),e[31]=_,e[32]=A,e[33]=P):P=e[33],P}function Fp(n){const e=B.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 u;e[5]!==a?(u=a>0&&r.jsxs("span",{className:"text-success",children:["+",a]}),e[5]=a,e[6]=u):u=e[6];let f;return e[7]!==c||e[8]!==d||e[9]!==u?(f=r.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:[c,d,u]}),e[7]=c,e[8]=d,e[9]=u,e[10]=f):f=e[10],f}function Eu(n){const e=B.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,u=l===void 0?!1:l,[f,m]=y.useState(!1),p=Zr();let h;e[0]!==s||e[1]!==t?(h=NT(t,s),e[0]=s,e[1]=t,e[2]=h):h=e[2];const g=h,{oldTokens:x,newTokens:b}=_T(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 v=w,S=c&&"mt-1.5",j=u&&"border-0 rounded-none";let k;e[5]!==S||e[6]!==j?(k=G("overflow-hidden rounded border border-border bg-muted/20",S,j),e[5]=S,e[6]=j,e[7]=k):k=e[7];let C;e[8]!==u||e[9]!==c||e[10]!==g||e[11]!==v?(C=!u&&r.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2 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:v}),r.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r.jsx(Fp,{lines:g}),c&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>m(!0),className:"text-muted-foreground",title:"Expand diff","aria-label":"Expand diff",children:r.jsx(Ea,{"data-icon":"icon"})})]})]}),e[8]=u,e[9]=c,e[10]=g,e[11]=v,e[12]=C):C=e[12];let N;e[13]!==c||e[14]!==g||e[15]!==b||e[16]!==x||e[17]!==d?(N=r.jsx(zp,{lines:g,oldTokens:x,newTokens:b,compact:c,startLine:d}),e[13]=c,e[14]=g,e[15]=b,e[16]=x,e[17]=d,e[18]=N):N=e[18];let _;e[19]!==N||e[20]!==k||e[21]!==C?(_=r.jsxs("div",{className:k,children:[C,N]}),e[19]=N,e[20]=k,e[21]=C,e[22]=_):_=e[22];let A;e[23]!==o||e[24]!==c||e[25]!==g||e[26]!==f||e[27]!==b||e[28]!==x||e[29]!==d?(A=c&&r.jsx(os,{open:f,onOpenChange:m,children:r.jsxs(rs,{className:"flex max-h-[85vh] flex-col border-border bg-background sm:max-w-4xl",children:[r.jsxs(Ps,{children:[r.jsxs(is,{className:"font-mono text-sm text-foreground flex min-w-0 flex-wrap items-center gap-3 [overflow-wrap:anywhere]",children:[o,r.jsx(Fp,{lines:g})]}),r.jsx(as,{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(zp,{lines:g,oldTokens:x,newTokens:b,startLine:d})})]})}),e[23]=o,e[24]=c,e[25]=g,e[26]=f,e[27]=b,e[28]=x,e[29]=d,e[30]=A):A=e[30];let P;return e[31]!==_||e[32]!==A?(P=r.jsxs(r.Fragment,{children:[_,A]}),e[31]=_,e[32]=A,e[33]=P):P=e[33],P}const ua={Read:{label:"Read file",styleName:"Read"},Write:{label:"Write file",styleName:"Write"},Edit:{label:"Edit file",styleName:"Edit"},Bash:{label:"Run command",styleName:"Bash"},Grep:{label:"Search files",styleName:"Grep"},Glob:{label:"Find files",styleName:"Glob"},Task:{label:"Spawn agent",styleName:"Task"},Agent:{label:"Spawn agent",styleName:"Task"},WebFetch:{label:"Open page",styleName:"WebFetch"},TodoWrite:{label:"Update plan",styleName:"TodoWrite"},AskUserQuestion:{label:"Ask question",styleName:"AskUserQuestion"},Skill:{label:"Use skill",styleName:"Skill"},ToolSearch:{label:"Find tools",styleName:"ToolSearch"},SendMessage:{label:"Message agent",styleName:"SendMessage"},ListAgents:{label:"List agents",styleName:"ListAgents"},TaskCreate:{label:"Create task",styleName:"TaskCreate"},TaskUpdate:{label:"Update task",styleName:"TaskUpdate"},TaskList:{label:"List tasks",styleName:"TaskList"},TaskOutput:{label:"Read task output",styleName:"TaskOutput"},TaskStop:{label:"Stop task",styleName:"TaskStop"},NotebookEdit:{label:"Edit notebook",styleName:"Edit"},EnterPlanMode:{label:"Enter plan mode",styleName:"EnterPlanMode"},ExitPlanMode:{label:"Exit plan mode",styleName:"ExitPlanMode"},EnterWorktree:{label:"Enter worktree",styleName:"EnterWorktree"},ExitWorktree:{label:"Exit worktree",styleName:"ExitWorktree"},Workflow:{label:"Run workflow",styleName:"Workflow"},exec_command:{label:"Run command",styleName:"Bash"},write_stdin:{label:"Continue command",styleName:"Bash"},apply_patch:{label:"Apply patch",styleName:"Edit"},update_plan:{label:"Update plan",styleName:"TodoWrite"},request_user_input:{label:"Ask question",styleName:"AskUserQuestion"},request_user_input_async:{label:"Ask question",styleName:"AskUserQuestion"},wait:{label:"Wait for tools",styleName:"Mcp"},spawn_agent:{label:"Spawn agent",styleName:"Task"},wait_agent:{label:"Wait for agents",styleName:"TaskOutput"},send_message:{label:"Message agent",styleName:"SendMessage"},followup_task:{label:"Follow up",styleName:"Task"},list_agents:{label:"List agents",styleName:"ListAgents"},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:"TaskList"},update_goal:{label:"Update goal",styleName:"TodoWrite"},view_image:{label:"View image",styleName:"Read"}},OT=new Set(["Write","Edit","Bash","exec","Task","Agent","Skill","TodoWrite","Image","AskUserQuestion","CronCreate","CronDelete","ScheduleWakeup","RemoteTrigger","PushNotification","EnterWorktree","ExitWorktree","SendMessage","EndConversation","TaskCreate","TaskUpdate","TaskStop","Workflow"]);function DT(n){var t;const e=Tn(n);return OT.has(((t=ua[e])==null?void 0:t.styleName)??e)?"mutating":"readOnly"}function f2(n){return typeof n=="object"&&n!==null}function Ut(...n){return n.find(e=>typeof e=="string")??""}function gs(n){return typeof n!="string"?"":/^gAAAAA[A-Za-z0-9_-]+={0,2}$/.test(n.trim())?"Encrypted message":n}function Fo(n){const e=n.command??n.cmd;return typeof e=="string"?e:!Array.isArray(e)||!e.every(t=>typeof t=="string")?"":e.map(t=>/^[A-Za-z0-9_./:@%+=,-]+$/.test(t)?t:`'${t.replace(/'/g,`'"'"'`)}'`).join(" ")}function ts(n,e=140){const t=n.replace(/\s+/g," ").trim();return t.length>e?`${t.slice(0,e-1)}…`:t}function Au(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 ri(n,e=""){const t=Au(n);if(t.length===0)return e;const s=ts(t[0]);return t.length===1?s:`${s} · +${t.length-1} more`}function ol(n,e){return n===1?`1 ${e}`:`${n} ${e}${/(?:ch|sh|s|x|z)$/.test(e)?"es":"s"}`}const Bp={mcp:"MCP",api:"API",url:"URL",openai:"OpenAI",figma:"Figma",clickup:"ClickUp"};function kr(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 Bp[i]?Bp[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 LT(n){if(!n)return null;const e=n.trim(),t=Un(e,0);return(t==null?void 0:t.endIndex)===e.length?t.value:null}function Bt(n,...e){for(const t of e){const s=LT(tl(n,t));if(s)return s;const o=mu(n,t)[0];if(o)return o}return""}function zT(n,...e){for(const t of e){const s=t0(n,t)[0];if(s!==void 0)return s}return null}function fa(n){return Bt(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 FT=[{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 Up(n,e){return e.flatMap(t=>mu(n,t))}function BT(n,e){const t=e.summaryGroups.map(i=>Up(n,i)),s=e.detail?t0(n,e.detail.property):[],o=e.countProperties?Up(n,e.countProperties):t[0];return{label:e.label,noun:e.noun,summary:[...t.map(i=>ri(i)),e.detail&&s.length>0?e.detail.format(s[0]):""].filter(Boolean).join(" · "),count:Math.max(n0(n),Au(o).length,s.length,1)}}function UT(n){const e=[];for(const t of FT){const s=tl(n,t.key);s&&e.push(BT(s,t))}return e}function m2(n){const e=UT(n);return e.length===0?{label:"Browse web",summary:fa(n),styleName:"WebSearch"}:e.length===1?{label:e[0].label,summary:e[0].summary,styleName:"WebSearch"}:{label:"Browse web",summary:e.map(t=>ol(t.count,t.noun)).join(" · "),styleName:"WebSearch"}}function p2(n){if(!n.startsWith("mcp__"))return null;const[,e,...t]=n.split("__");return!e||t.length===0?null:{server:kr(e,!0),action:kr(t.join(" "))}}function WT(n,e){const t=p2(n);if(!t)return{label:kr(n),summary:fa(e),styleName:"Mcp"};const s=fa(e);return{label:t.server,summary:[t.action,s].filter(Boolean).join(" · "),styleName:"Mcp"}}function h2(n){const e=Un(n.trim(),0),t=(e==null?void 0:e.value)??n,s=Au(Array.from(t.matchAll(/^\*\*\*\s+(?:Update|Add|Delete) File:\s*(.+)$/gm),o=>o[1]));return ri(s,s.length>0?ol(s.length,"file"):"")}function HT(n){const e=n.argumentSource;switch(Tn(n.name)){case"exec_command":return{label:"Run command",summary:Bt(e,"cmd","command"),styleName:"Bash"};case"write_stdin":{const t=zT(e,"session_id"),s=Bt(e,"chars");return{label:"Continue command",summary:[t!==null?`session ${t}`:"",s?ts(s,60):""].filter(Boolean).join(" · "),styleName:"Bash"}}case"apply_patch":return{label:"Apply patch",summary:h2(e),styleName:"Edit"};case"web__run":case"web_search":return m2(e);case"view_image":return{label:"View image",summary:Bt(e,"path"),styleName:"Read"};case"update_plan":{const t=tl(e,"plan"),s=t?n0(t):0;return{label:"Update plan",summary:s>0?ol(s,"step"):Bt(e,"explanation"),styleName:"TodoWrite"}}case"create_goal":return{label:"Create goal",summary:Bt(e,"objective"),styleName:"TodoWrite"};case"get_goal":return{label:"Check goal",summary:"",styleName:"TaskList"};case"update_goal":return{label:"Update goal",summary:Bt(e,"status"),styleName:"TodoWrite"};case"list_mcp_resources":return{label:"List MCP resources",summary:Bt(e,"server"),styleName:"Mcp"};case"list_mcp_resource_templates":return{label:"List MCP templates",summary:Bt(e,"server"),styleName:"Mcp"};case"read_mcp_resource":return{label:"Read MCP resource",summary:[Bt(e,"server"),Bt(e,"uri")].filter(Boolean).join(" · "),styleName:"Mcp"};case"request_plugin_install":return{label:"Install plugin",summary:Bt(e,"plugin_id"),styleName:"Mcp"};case"tool_search":return{label:"Find tools",summary:Bt(e,"query"),styleName:"ToolSearch"};case"image_gen__imagegen":return{label:"Generate image",summary:Bt(e,"prompt"),styleName:"Image"};case"spawn_agent":return{label:"Spawn agent",summary:gs(Bt(e,"task_name","message")),styleName:"Task"};case"send_message":case"followup_task":return{...ua[Tn(n.name)],summary:[Bt(e,"target"),gs(Bt(e,"message"))].filter(Boolean).join(" · ")};default:{const t=Tn(n.name),s=ua[t];return t.startsWith("mcp__")?WT(t,e):{label:(s==null?void 0:s.label)??kr(t),summary:gs(fa(e)),styleName:(s==null?void 0:s.styleName)??t}}}}function g2(n){return typeof n.input.raw=="string"&&/(?:^|__|[.:/])exec$/.test(n.name)}function qT(n){const e=Qx(n);if(e.length===0)return{label:"Run tool script",summary:"",styleName:"exec"};const t=e.map(HT),s=t[0];if(t.every(i=>i.label===s.label)){const i=ri(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 KT(n){const e=f2(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:Ut(e==null?void 0:e.url,n.query),styleName:"WebSearch"};if(t==="find_in_page"||t==="findInPage")return{label:"Find on page",summary:[Ut(e==null?void 0:e.pattern),Ut(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=Ut(e==null?void 0:e.query,n.query);return{label:"Search web",summary:ri([o,...s]),styleName:"WebSearch"}}const VT=["summary","headline","verdict","title"];function GT(n){const e=Ut(...VT.map(t=>n[t]));if(e)return ts(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 YT(n){const e=Ut(n.description);if(e)return ts(e);const t=Ut(n.script);return(t?mu(t,"name")[0]??"":"")||Ut(n.scriptPath)}function Wp(n){const e=Ut(...["description","summary","query","q","command","cmd","file_path","path","url","uri","pattern","prompt","objective","message","title","name"].map(s=>n[s]));if(e)return ts(e);const t=Object.entries(n).find(([s,o])=>s!=="raw"&&s!=="script"&&typeof o=="string");return t?ts(t[1]):""}function Hp(n){const e=n.input;switch(n.name){case"Read":case"Write":case"Edit":return String(e.file_path??e.path??"");case"Bash":case"exec_command":return Fo(e);case"write_stdin":return[e.session_id!==void 0?`session ${e.session_id}`:"",Ut(e.chars)].filter(Boolean).join(" · ");case"apply_patch":return h2(Ut(e.patch,e.raw,e.input));case"TodoWrite":case"update_plan":{const t=Array.isArray(e.todos)?e.todos:Array.isArray(e.plan)?e.plan:[];return t.length>0?ol(t.length,"step"):Ut(e.explanation)}case"Grep":case"Glob":return String(e.pattern??"");case"Task":case"Agent":return gs(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":case"request_user_input":case"request_user_input_async":{const t=Array.isArray(e.questions)?e.questions.find(f2):null;return Ut(t==null?void 0:t.question,t==null?void 0:t.title)}case"Monitor":{const t=String(e.bash_id??""),s=e.filter?` · filter=${e.filter}`:"";return`${t}${s}`}case"CronCreate":{const t=String(e.schedule??e.cron??""),s=String(e.prompt??""),o=s.length>60?s.slice(0,60)+"...":s;return t&&o?`${t} → ${o}`:t||o}case"CronList":return"";case"CronDelete":return String(e.id??e.cron_id??"");case"ScheduleWakeup":{const t=Number(e.delaySeconds??0),s=Math.round(t/60),o=t>=3600?`${Math.round(t/3600)}h`:t>=60?`${s}m`:`${t}s`,i=e.reason?` · ${e.reason}`:"";return`in ${o}${i}`}case"RemoteTrigger":{const t=String(e.action??""),s=String(e.id??e.trigger_id??"");return[t,s].filter(Boolean).join(" ")}case"PushNotification":return String(e.title??e.body??"");case"EnterWorktree":{const t=String(e.name??e.branch??""),s=e.path?` (${e.path})`:"";return`${t}${s}`}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 t=Ut(e.to,e.recipient),s=ts(gs(Ut(e.summary,e.message,e.content)));return[t,s].filter(Boolean).join(" · ")}case"ListAgents":case"TaskList":return"";case"TaskCreate":return ts(Ut(e.subject,e.description));case"TaskUpdate":{const t=String(e.taskId??""),s=Array.isArray(e.addBlockedBy)?e.addBlockedBy.filter(i=>typeof i=="string"):[],o=Ut(e.status)||(s.length>0?`blocked by ${s.join(", ")}`:"");return o?`${t} → ${o}`:t}case"TaskOutput":case"TaskStop":return String(e.task_id??"");case"Workflow":return YT(e);case"StructuredOutput":case"ReportFindings":case"DesignSync":case"Artifact":case"LSP":return GT(e)||Wp(e);case"spawn_agent":return gs(e.task_name??e.message);case"wait_agent":{const t=Array.isArray(e.ids)?e.ids.filter(s=>typeof s=="string"):[];return ri(t)}case"send_message":case"followup_task":return[e.target,gs(e.message)].filter(t=>typeof t=="string"&&t.length>0).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(t=>typeof t=="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 Wp(e)}}function ii(n){if(g2(n))return qT(n.input.raw);const e=Tn(n.name);if(e==="WebSearch"||e==="web_search")return KT(n.input);if(e==="web__run"||e==="web.run")return m2(JSON.stringify(n.input));const t=p2(n.name);if(t)return{label:t.server,summary:[t.action,Hp(n)].filter(Boolean).join(" · "),styleName:"Mcp"};const s=ua[e];return{label:(s==null?void 0:s.label)??kr(e),summary:ts(Hp({name:e,input:n.input})),styleName:(s==null?void 0:s.styleName)??e}}function XT(n){return ii(n).summary}const JT={file_path:"File",path:"Path",target:"Recipient",recipient:"Recipient",recipient_agent_id:"Recipient",agent_id:"Agent",agent_type:"Agent type",subagent_type:"Agent type",task_name:"Task",description:"Description",message:"Message",prompt:"Task",content:"Content",query:"Query",pattern:"Pattern",url:"URL",workdir:"Working directory",cwd:"Working directory",max_output_tokens:"Output limit",yield_time_ms:"Yield",timeout_ms:"Timeout"};function QT(n){return JT[n]??n.replace(/_/g," ").replace(/^./,e=>e.toUpperCase())}function ZT(n,e){if(typeof e=="number"){if(n==="max_output_tokens")return`${e.toLocaleString()} tokens`;if(n.endsWith("_ms"))return e<1e3?`${e} ms`:`${e/1e3} sec`}return String(e)}function Cr(n){const e=B.c(20),{value:t}=n,[s,o]=y.useState(!1),i=y.useId();let a,l,c,d;if(e[0]!==s||e[1]!==i||e[2]!==t){const p=gs(t);a=p.length>800,l=i;const h=s&&"max-h-96 overflow-auto";e[7]!==h?(c=G("whitespace-pre-wrap break-words [overflow-wrap:anywhere]",h),e[7]=h,e[8]=c):c=e[8],d=a&&!s?`${p.slice(0,800)}…`:p,e[0]=s,e[1]=i,e[2]=t,e[3]=a,e[4]=l,e[5]=c,e[6]=d}else a=e[3],l=e[4],c=e[5],d=e[6];let u;e[9]!==l||e[10]!==c||e[11]!==d?(u=r.jsx("div",{id:l,className:c,children:d}),e[9]=l,e[10]=c,e[11]=d,e[12]=u):u=e[12];let f;e[13]!==s||e[14]!==i||e[15]!==a?(f=a&&r.jsx(ee,{type:"button",variant:"ghost",size:"xs","aria-expanded":s,"aria-controls":i,onClick:()=>o(e8),children:s?"Show less":"Show more"}),e[13]=s,e[14]=i,e[15]=a,e[16]=f):f=e[16];let m;return e[17]!==u||e[18]!==f?(m=r.jsxs(r.Fragment,{children:[u,f]}),e[17]=u,e[18]=f,e[19]=m):m=e[19],m}function e8(n){return!n}function t8(n){const e=n.todos??n.plan;return Array.isArray(e)?e.flatMap(t=>{if(!t||typeof t!="object")return[];const s=t,o=s.content??s.step??s.description;return typeof o=="string"?[{text:o,status:typeof s.status=="string"?s.status:"pending"}]:[]}):[]}function n8(n){const e=B.c(4),{steps:t}=n;let s;e[0]!==t?(s=t.map(s8),e[0]=t,e[1]=s):s=e[1];let o;return e[2]!==s?(o=r.jsx("section",{className:"mt-2 min-w-0","aria-label":"Plan",children:r.jsx("ol",{className:"flex flex-col gap-2",children:s})}),e[2]=s,e[3]=o):o=e[3],o}function s8(n,e){const t=n.status==="completed",s=n.status==="in_progress",o=t?dt:s?Cd:Pa,i=t?"Completed":s?"In progress":"Pending";return r.jsxs("li",{className:"flex min-w-0 items-start gap-2 text-xs",children:[r.jsx(o,{role:"img","aria-label":i,className:G("mt-0.5 size-3 shrink-0 text-muted-foreground",s&&"text-info")}),r.jsx("div",{className:"min-w-0 flex-1",children:r.jsx(Cr,{value:n.text})}),r.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:i})]},e)}function o8(n){const e=B.c(4),{questions:t}=n;let s;e[0]!==t?(s=t.map(r8),e[0]=t,e[1]=s):s=e[1];let o;return e[2]!==s?(o=r.jsx("section",{className:"mt-2 flex min-w-0 flex-col gap-3","aria-label":"Questions",children:s}),e[2]=s,e[3]=o):o=e[3],o}function r8(n,e){return r.jsxs("div",{className:"min-w-0 text-xs",children:[r.jsx(Cr,{value:String(n.question??n.title)}),Array.isArray(n.options)&&r.jsx("ul",{className:"mt-2 flex min-w-0 flex-col gap-1.5 border-l border-border pl-3",children:n.options.map(i8)})]},e)}function i8(n,e){const t=typeof n=="string"?{label:n}:n;return!t||typeof t.label!="string"?null:r.jsxs("li",{className:"min-w-0",children:[r.jsx(Cr,{value:t.label}),typeof t.description=="string"&&r.jsx("div",{className:"mt-0.5 text-muted-foreground",children:r.jsx(Cr,{value:t.description})})]},e)}function x2(n){const e=B.c(21),{input:t}=n;let s;e[0]!==t?(s=t8(t),e[0]=t,e[1]=s):s=e[1];const o=s;let i;e[2]!==t.questions?(i=Array.isArray(t.questions)?t.questions.filter(c8):[],e[2]=t.questions,e[3]=i):i=e[3];const a=i;let l,c,d,u,f;if(e[4]!==t||e[5]!==a||e[6]!==o){f=Symbol.for("react.early_return_sentinel");e:{const p=Object.entries(t).filter(l8);if(o.length===0&&p.length===0&&a.length===0){f=null;break e}l="min-w-0",e[12]!==o?(c=o.length>0&&r.jsx(n8,{steps:o}),e[12]=o,e[13]=c):c=e[13],e[14]!==a?(d=a.length>0&&r.jsx(o8,{questions:a}),e[14]=a,e[15]=d):d=e[15],u=p.length>0&&r.jsx("dl",{className:"mt-2 flex min-w-0 flex-col gap-2","aria-label":"Call details",children:p.map(a8)})}e[4]=t,e[5]=a,e[6]=o,e[7]=l,e[8]=c,e[9]=d,e[10]=u,e[11]=f}else l=e[7],c=e[8],d=e[9],u=e[10],f=e[11];if(f!==Symbol.for("react.early_return_sentinel"))return f;let m;return e[16]!==l||e[17]!==c||e[18]!==d||e[19]!==u?(m=r.jsxs("div",{className:l,children:[c,d,u]}),e[16]=l,e[17]=c,e[18]=d,e[19]=u,e[20]=m):m=e[20],m}function a8(n){const[e,t]=n;return r.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(4rem,auto)_minmax(0,1fr)] items-start gap-x-3 text-xs",children:[r.jsx("dt",{className:"max-w-32 break-words text-muted-foreground",children:QT(e)}),r.jsx("dd",{className:"min-w-0",children:r.jsx(Cr,{value:ZT(e,t)})})]},e)}function l8(n){const[e,t]=n;return e!=="raw"&&e!=="type"&&(typeof t=="string"?t.length>0:typeof t=="number"||typeof t=="boolean")}function c8(n){return n!==null&&typeof n=="object"&&typeof(n.question??n.title)=="string"}const d8="min-w-0 max-h-96 overflow-y-auto whitespace-pre-wrap break-words [overflow-wrap:anywhere] rounded-md border bg-muted/30 p-2 font-mono text-xs leading-relaxed text-muted-foreground",b2="min-w-0 max-h-96 overflow-auto whitespace-pre-wrap break-words [overflow-wrap:anywhere] border-l border-border pl-3 font-mono text-xs leading-relaxed text-muted-foreground";function Pu(n,e,t){const s=B.c(5),[o,i]=y.useState(null);let a,l;return s[0]!==n||s[1]!==t||s[2]!==e?(a=()=>{if(!e)return;let c=!1;return wx(n,e,t).then(d=>{c||i({code:n,lang:e,isDark:t,tokens:d})}).catch(u8),()=>{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]),y.useEffect(a,l),(o==null?void 0:o.code)===n&&o.lang===e&&o.isDark===t?o.tokens:null}function u8(){}function $u(n){const e=B.c(13),{lines:t,tokens:s,lineNums:o,variant:i,label:a}=n,l=i==="boxed"?d8:b2;let c;if(e[0]!==o||e[1]!==t||e[2]!==s){let f;e[4]!==o||e[5]!==s?(f=(m,p)=>{const h=s==null?void 0:s[p];return r.jsxs("span",{className:"block",children:[(o==null?void 0:o[p])&&r.jsx("span",{className:"inline-block w-10 text-right mr-2 text-muted-foreground/30 select-none",children:o[p]}),h?h.map(f8):m||" "]},p)},e[4]=o,e[5]=s,e[6]=f):f=e[6],c=t.map(f),e[0]=o,e[1]=t,e[2]=s,e[3]=c}else c=e[3];let d;e[7]!==a||e[8]!==c?(d=r.jsx("code",{className:"block","aria-label":a,children:c}),e[7]=a,e[8]=c,e[9]=d):d=e[9];let u;return e[10]!==l||e[11]!==d?(u=r.jsx("pre",{tabIndex:0,className:l,children:d}),e[10]=l,e[11]=d,e[12]=u):u=e[12],u}function f8(n,e){return r.jsx("span",{style:{color:n.color},children:n.content},e)}function v2(n){const e=B.c(6),{code:t,language:s,label:o}=n,i=Zr(),a=Pu(t,s,i);let l;e[0]!==t?(l=_r(t),e[0]=t,e[1]=l):l=e[1];const c=l;let d;return e[2]!==o||e[3]!==c||e[4]!==a?(d=r.jsx($u,{lines:c,tokens:a,variant:"unboxed",label:o}),e[2]=o,e[3]=c,e[4]=a,e[5]=d):d=e[5],d}const m8=/^(\s*\d+)→(.*)$/;function _r(n){return n.split(/\r\n|\r|\n/)}function p8(n){const e=[],t=[];for(const s of _r(n)){const o=s.match(m8);o?(e.push(o[1]),t.push(o[2])):(e.push(""),t.push(s))}return{lineNums:e,codeLines:t}}function y2(n){const e=B.c(14),{result:t,filePath:s,expanded:o,variant:i}=n,a=i===void 0?"boxed":i,l=Zr();let c;e[0]!==s?(c=yx(s),e[0]=s,e[1]=c):c=e[1];const d=c;let u;e[2]!==o||e[3]!==t?(u=o?t:Ru(t).text,e[2]=o,e[3]=t,e[4]=u):u=e[4];const f=u;let m;e[5]!==f?(m=p8(f),e[5]=f,e[6]=m):m=e[6];const{lineNums:p,codeLines:h}=m;let g;e[7]!==h?(g=h.join(`
|
|
100
|
+
`),e[7]=h,e[8]=g):g=e[8];const b=Pu(g,d,l);let w;return e[9]!==h||e[10]!==p||e[11]!==b||e[12]!==a?(w=r.jsx($u,{lines:h,tokens:b,lineNums:p,variant:a}),e[9]=h,e[10]=p,e[11]=b,e[12]=a,e[13]=w):w=e[13],w}function w2(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 j2(n){const e=B.c(12),{result:t,expanded:s,alreadyPretty:o,variant:i}=n,a=i===void 0?"boxed":i,l=Zr();let c;e[0]!==o||e[1]!==t?(c=o?t:w2(t)??t,e[0]=o,e[1]=t,e[2]=c):c=e[2];const d=c;let u;e[3]!==s||e[4]!==d?(u=s?d:Ru(d).text,e[3]=s,e[4]=d,e[5]=u):u=e[5];const f=u;let m;e[6]!==f?(m=_r(f),e[6]=f,e[7]=m):m=e[7];const p=m,h=Pu(f,"json",l);let g;return e[8]!==p||e[9]!==h||e[10]!==a?(g=r.jsx($u,{lines:p,tokens:h,variant:a}),e[8]=p,e[9]=h,e[10]=a,e[11]=g):g=e[11],g}function Ru(n){const e=_r(n),t=e.slice(0,8).join(`
|
|
101
|
+
`),s=t.slice(0,1e3);return{text:s,hiddenLines:Math.max(0,e.length-_r(s).length),truncated:e.length>8||t.length>1e3}}function h8(n){const e=B.c(36),{result:t,isError:s,filePath:o}=n,i=s===void 0?!1:s,[a,l]=y.useState(!1),[c,d]=Ts(),u=y.useId();let f;e[0]!==o||e[1]!==i||e[2]!==t?(f=!i&&!o?w2(t):null,e[0]=o,e[1]=i,e[2]=t,e[3]=f):f=e[3];const m=f,p=m??t;let h;e[4]!==p?(h=Ru(p),e[4]=p,e[5]=h):h=e[5];const g=h,x=a?p:g.text,b=i&&"text-destructive";let w;e[6]!==b?(w=G("text-xs text-muted-foreground",b),e[6]=b,e[7]=w):w=e[7];const v=i?"Error":"Result";let S;e[8]!==w||e[9]!==v?(S=r.jsx("span",{className:w,children:v}),e[8]=w,e[9]=v,e[10]=S):S=e[10];let j;e[11]!==c||e[12]!==d||e[13]!==t?(j=t.trim()&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>d(t),"aria-label":c?"Result copied":"Copy result",children:c?r.jsx(dt,{"data-icon":"icon"}):r.jsx(xn,{"data-icon":"icon"})}),e[11]=c,e[12]=d,e[13]=t,e[14]=j):j=e[14];let k;e[15]!==S||e[16]!==j?(k=r.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2",children:[S,j]}),e[15]=S,e[16]=j,e[17]=k):k=e[17];let C;e[18]!==o||e[19]!==i||e[20]!==m||e[21]!==t||e[22]!==x?(C=t.trim()?o&&!i?r.jsx(y2,{result:x,filePath:o,expanded:!0,variant:"unboxed"}):m!==null?r.jsx(j2,{result:x,expanded:!0,alreadyPretty:!0,variant:"unboxed"}):r.jsx("pre",{tabIndex:0,className:G(b2,i&&"border-destructive/30 text-destructive"),children:x}):r.jsx("p",{className:"text-xs text-muted-foreground",children:"No output"}),e[18]=o,e[19]=i,e[20]=m,e[21]=t,e[22]=x,e[23]=C):C=e[23];let N;e[24]!==u||e[25]!==C?(N=r.jsx("div",{id:u,children:C}),e[24]=u,e[25]=C,e[26]=N):N=e[26];let _;e[27]!==a||e[28]!==g.hiddenLines||e[29]!==g.truncated||e[30]!==u?(_=g.truncated&&r.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"mt-1",onClick:()=>l(g8),"aria-expanded":a,"aria-controls":u,children:a?"Show less":g.hiddenLines>0?`+${g.hiddenLines} ${g.hiddenLines===1?"line":"lines"}`:"Show more"}),e[27]=a,e[28]=g.hiddenLines,e[29]=g.truncated,e[30]=u,e[31]=_):_=e[31];let A;return e[32]!==N||e[33]!==_||e[34]!==k?(A=r.jsxs("section",{className:"mt-1.5 min-w-0","aria-label":"Result",children:[k,N,_]}),e[32]=N,e[33]=_,e[34]=k,e[35]=A):A=e[35],A}function g8(n){return!n}function x8(n){const e=B.c(25),{name:t,input:s}=n;let o;e[0]!==s||e[1]!==t?(o=ii(typeof s.raw=="string"&&s.raw.startsWith("{")?{name:"exec",input:{raw:`tools.${t}(${s.raw})`}}:{name:t,input:s}),e[0]=s,e[1]=t,e[2]=o):o=e[2];const i=o;let a;e[3]!==s?(a=Fo(s),e[3]=s,e[4]=a):a=e[4];const l=a;let c;e[5]!==l||e[6]!==s?(c=l?Object.fromEntries(Object.entries(s).filter(b8)):s,e[5]=l,e[6]=s,e[7]=c):c=e[7];const d=c;let u;e[8]!==i.label?(u=r.jsx("span",{className:"font-medium",children:i.label}),e[8]=i.label,e[9]=u):u=e[9];let f;e[10]!==l||e[11]!==i.summary?(f=i.summary&&!l&&r.jsx("span",{className:"truncate text-muted-foreground",children:i.summary}),e[10]=l,e[11]=i.summary,e[12]=f):f=e[12];let m;e[13]!==u||e[14]!==f?(m=r.jsxs("div",{className:"mb-1 flex min-w-0 flex-wrap items-center gap-x-2 text-xs",children:[u,f]}),e[13]=u,e[14]=f,e[15]=m):m=e[15];let p;e[16]!==l?(p=l&&r.jsx(v2,{code:l,language:"bash",label:"Command"}),e[16]=l,e[17]=p):p=e[17];let h;e[18]!==d?(h=r.jsx(x2,{input:d}),e[18]=d,e[19]=h):h=e[19];let g;return e[20]!==i.label||e[21]!==m||e[22]!==p||e[23]!==h?(g=r.jsxs("section",{className:"min-w-0","aria-label":i.label,children:[m,p,h]}),e[20]=i.label,e[21]=m,e[22]=p,e[23]=h,e[24]=g):g=e[24],g}function b8(n){const[e]=n;return e!=="command"&&e!=="cmd"}function v8(n){const e=B.c(32),{input:t}=n,s=String(t.raw??"");let o;e[0]!==t?(o=i6(t),e[0]=t,e[1]=o):o=e[1];const i=o,[a,l]=y.useState(!1),[c,d]=Ts(),u=y.useId(),f=i.length===0||a;let m;e[2]!==i?(m=i.length>0&&r.jsx("div",{className:"flex min-w-0 flex-col gap-3",children:i.map(w8)}),e[2]=i,e[3]=m):m=e[3];let p;e[4]!==i.length||e[5]!==f||e[6]!==u?(p=i.length>0?r.jsxs(ee,{type:"button",variant:"ghost",size:"xs","aria-expanded":f,"aria-controls":u,onClick:()=>l(y8),children:[r.jsx(Xe,{"data-icon":"inline-start",className:G(f&&"rotate-90")}),"Source"]}):r.jsx("span",{className:"text-xs text-muted-foreground",children:"Script"}),e[4]=i.length,e[5]=f,e[6]=u,e[7]=p):p=e[7];let h;e[8]!==d||e[9]!==s?(h=()=>d(s),e[8]=d,e[9]=s,e[10]=h):h=e[10];const g=c?"Tool script copied":"Copy script";let x;e[11]!==c?(x=c?r.jsx(dt,{"data-icon":"icon"}):r.jsx(xn,{"data-icon":"icon"}),e[11]=c,e[12]=x):x=e[12];let b;e[13]!==h||e[14]!==g||e[15]!==x?(b=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:h,"aria-label":g,children:x}),e[13]=h,e[14]=g,e[15]=x,e[16]=b):b=e[16];let w;e[17]!==p||e[18]!==b?(w=r.jsxs("div",{className:"mb-1 mt-1 flex items-center justify-between gap-2",children:[p,b]}),e[17]=p,e[18]=b,e[19]=w):w=e[19];let v;e[20]!==s?(v=r.jsx(v2,{code:s,language:"typescript",label:"Codex exec script"}),e[20]=s,e[21]=v):v=e[21];let S;e[22]!==u||e[23]!==v?(S=r.jsx(mt,{id:u,children:v}),e[22]=u,e[23]=v,e[24]=S):S=e[24];let j;e[25]!==f||e[26]!==S?(j=r.jsx(ft,{open:f,children:S}),e[25]=f,e[26]=S,e[27]=j):j=e[27];let k;return e[28]!==j||e[29]!==m||e[30]!==w?(k=r.jsxs("section",{className:"mt-2 min-w-0","aria-label":"Tool script",children:[m,w,j]}),e[28]=j,e[29]=m,e[30]=w,e[31]=k):k=e[31],k}function y8(n){return!n}function w8(n,e){return r.jsx(x8,{...n},e)}const j8=/(?:^|;|&&)\s*echo\s+(["']?)---([\w.-]*)\1\s*(?=;|&&|$)/g;function qp(n){return n.replace(/^\s*(?:;|&&)/,"").trim()}function S8(n,e){const t=[],s=[];let o=0;for(const l of n.matchAll(j8)){const c=qp(n.slice(o,l.index));c&&t.push({label:s.at(-1)??"",command:c,chunk:s.length}),s.push(l[2]),o=l.index+l[0].length}if(s.length===0)return null;const i=qp(n.slice(o));if(i&&t.push({label:s.at(-1)??"",command:i,chunk:s.length}),t.length<2)return null;const a=e===null?null:N8(e,s);return a!==null&&a.length<2?null:t.map(({chunk:l,...c})=>({...c,output:a!==null&&l<a.length?a[l]:null}))}function N8(n,e){const t=[[]];let s=0;for(const o of n.split(/\r\n|\r|\n/))s<e.length&&o===`---${e[s]}`?(t.push([]),s++):t[t.length-1].push(o);return t.map(o=>o.join(`
|
|
102
|
+
`).trim())}const k8=new Set(["mv","cp","rm","mkdir","touch","tee","ln","chmod","chown","install","rsync"]),C8=/(?:^|[^\d&])>{1,2}(?!\s*&|\s*\/dev\/null)/,_8=/\|\||&&|[|;\n]/,T8=new Set(["echo","printf","true","false",":"]),E8=new Set(["find","grep","rg","ag","ack","locate","which","whereis"]),A8=new Set(["cat","head","tail","less","more","wc","stat","file","strings","jq","awk","cut","sort","uniq","tr","sed","diff","xxd","od"]),P8=new Set(["ls","tree","du"]),$8=new Set(["xargs","sudo","env","time","nohup","command"]);function R8(n){const e=n.split(/\s+/);for(;e.length>1&&($8.has(e[0])||/^-/.test(e[0]));)e.shift();const[t,...s]=e;return k8.has(t)||t==="sed"&&s.some(o=>/^-[a-zA-Z]*i/.test(o))||/^python3?$/.test(t)&&s[0]==="-"||t==="git"&&/^(add|commit|checkout|reset|push|stash|rebase|merge|rm|mv)$/.test(s[0]??"")?!0:C8.test(n)}const S2=/<<-?\s*['"]?\w+['"]?/,I8=/'[^']*'|"(?:[^"\\]|\\.)*"/g;function M8(n){return n.split(S2)[0].replace(I8,'""').split(_8).map(e=>e.trim()).filter(Boolean)}function O8(n){const e=M8(n);if(e.some(R8))return"write";let t=!1,s=!1,o=!1;for(const i of e){const a=i.split(/\s+/)[0];if(!(!a||T8.has(a)))if(E8.has(a))t=!0;else if(A8.has(a))s=!0;else if(P8.has(a))o=!0;else return"run"}return o?"list":t?"search":s?"read":"run"}const D8=/^["']?((?:~|\.{1,2})?\/?[\w.@+-]+(?:\/[\w.@+*{}-]+)+\/?|[\w@+-]+\.(?:[cm]?[jt]sx?|json|md|mdx|py|rb|go|rs|sh|zsh|ya?ml|toml|css|scss|html|txt|sql|swift|kt|java|plist|lock))["']?[,:;]?$/;function N2(n){const e=new Set;for(const t of n.split(S2)[0].split(/\s+/)){const s=t.match(D8);if(!s)continue;const o=s[1];o.includes("*")||o.includes("{")||o.startsWith("-")||e.add(o)}return[...e]}const L8=/^(?:cat|head(?:\s+-n?\s*\d+)?|tail(?:\s+-n?\s*\d+)?|sed\s+-n\s+(\d+),(\d+)p)\s+(["']?)(\S+)\3(?:\s*\|\s*(?:head|tail)(?:\s+-n?\s*\d+)?)?$/;function z8(n){const e=n.trim().match(L8);if(!e)return null;const[,t,s,,o]=e;return N2(o).length?t?{path:o,from:Number(t),to:Number(s)}:{path:o}:null}const F8=/(?:No such file or directory|command not found|no matches found|Permission denied|is not recognized as an internal|Traceback \(most recent call last\)|^fatal: |^npm ERR!|^error: |^ERROR: |exited with code [1-9]\d*|^FAIL\b)/m;function B8(n,e){return!e||n==="read"&&e.split(`
|
|
103
|
+
`).length>3?!1:F8.test(e)}function k2(n){const e=O8(n.command);return{kind:e,paths:N2(n.command),readFile:e==="read"?z8(n.command):null,failed:B8(e,n.output)}}function C2(n){var e;return n.label||((e=n.command.match(/^[\w.-]+/))==null?void 0:e[0])||"…"}function U8(n){const e=[],t=new Map;for(const s of n){const o=C2(s),i=k2(s).failed?"failed":"muted",a=t.get(o);if(a){a.count++,i==="failed"&&(a.tone="failed");continue}const l={name:o,tone:i,count:1};e.push(l),t.set(o,l)}return e}const _2={muted:"text-muted-foreground",failed:"border-destructive/30 text-destructive"},ma={read:{icon:qi,label:"read",plural:"reads"},search:{icon:an,label:"search",plural:"searches"},list:{icon:_o,label:"list",plural:"lists"},run:{icon:Dr,label:"run",plural:"runs"},write:{icon:Sc,label:"write",plural:"writes"}},W8=["read","search","list","run","write"],H8=new Set(["command","cmd","description","timeout","run_in_background"]);function T2(n){const e=Fo(n.input);return S8(e,n.result)??[{label:"",command:e,output:n.result}]}function q8(n,e,t){if(!n.isError||t.some(o=>o.failed))return-1;const s=e.findLastIndex(o=>o.output!==null);return s>=0?s:e.length-1}function K8(n){return typeof n!="number"||!Number.isFinite(n)?String(n):n<1e3?`${n} ms timeout`:n%6e4===0?`${n/6e4} min timeout`:n%1e3===0?`${n/1e3} sec timeout`:`${(n/1e3).toFixed(1)} sec timeout`}function V8(n){return n.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase())}function G8(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 Y8(n){const e=[];n.timeout!==void 0&&e.push(K8(n.timeout)),typeof n.run_in_background=="boolean"&&e.push(n.run_in_background?"Background":"Foreground");for(const[t,s]of Object.entries(n))H8.has(t)||s===void 0||e.push(`${V8(t)} ${G8(s)}`);return e}function X8(n,e){const t=T2(n),s=t.map(k2),o=q8(n,t,s);return{toolCall:n,command:Fo(n.input),description:typeof n.input.description=="string"?n.input.description:void 0,rows:t.map((i,a)=>({section:i,analysis:s[a],failed:s[a].failed||a===o,pending:e&&n.result===null&&a===t.length-1})),options:Y8(n.input)}}function E2(n){return n?n.split(`
|
|
104
|
+
`).length:0}function J8(n){if(n.pending)return"running";if(n.section.output===null)return"not run";if(n.section.output==="")return"no output";const e=E2(n.section.output);return e===1?"1 line":`${e} lines`}function Q8(n,e){return n.startsWith("/")?n:n.startsWith("~")||!e?null:`${e.replace(/\/$/,"")}/${n.replace(/^\.\//,"")}`}function A2(n){const e=B.c(12),{path:t,line:s,cwd:o,children:i}=n;let a;e[0]!==o||e[1]!==t?(a=Q8(t,o),e[0]=o,e[1]=t,e[2]=a):a=e[2];const l=a;if(!l||!ot("hostFiles")){let f;return e[3]!==i?(f=r.jsx(r.Fragment,{children:i}),e[3]=i,e[4]=f):f=e[4],f}const c=`Open ${l}${s?`:${s}`:""}`;let d;e[5]!==s||e[6]!==l?(d=f=>{f.stopPropagation(),yr(l,s?{line:s}:{})},e[5]=s,e[6]=l,e[7]=d):d=e[7];let u;return e[8]!==i||e[9]!==c||e[10]!==d?(u=r.jsx("button",{type:"button",className:"rounded-sm underline decoration-dotted decoration-muted-foreground/60 underline-offset-2 hover:bg-muted hover:text-foreground hover:decoration-solid",title:c,onClick:d,children:i}),e[8]=i,e[9]=c,e[10]=d,e[11]=u):u=e[11],u}function Z8(n){const e=B.c(13),{command:t,paths:s,cwd:o}=n;if(s.length===0){let d;return e[0]!==t?(d=r.jsx(r.Fragment,{children:t}),e[0]=t,e[1]=d):d=e[1],d}let i;e[2]!==s?(i=new Set(s),e[2]=s,e[3]=i):i=e[3];const a=i;let l;if(e[4]!==t||e[5]!==o||e[6]!==a){let d;e[8]!==o||e[9]!==a?(d=(u,f)=>{const m=u.replace(/^["']|["']?[,:;]?$/g,"");return a.has(m)?r.jsx(A2,{path:m,cwd:o,children:u},f):u},e[8]=o,e[9]=a,e[10]=d):d=e[10],l=t.split(/(\s+)/).map(d),e[4]=t,e[5]=o,e[6]=a,e[7]=l}else l=e[7];let c;return e[11]!==l?(c=r.jsx(r.Fragment,{children:l}),e[11]=l,e[12]=c):c=e[12],c}const eE=/^([^\s:]+):(\d+)([:-])/,Jl="mb-1.5 ml-6 min-w-0 max-h-96 overflow-y-auto whitespace-pre-wrap break-words [overflow-wrap:anywhere] border-l pl-3 font-mono text-[11px] leading-relaxed text-muted-foreground";function tE(n){const e=B.c(16),{row:t,cwd:s}=n,o=t.section.output??"";if(t.analysis.readFile&&!t.failed){let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=G(Jl,"pl-0 [&_pre]:border-0 [&_pre]:pl-3"),e[0]=c):c=e[0];let d;return e[1]!==o||e[2]!==t.analysis.readFile.path?(d=r.jsx("div",{className:c,children:r.jsx(y2,{result:o,filePath:t.analysis.readFile.path,expanded:!0,variant:"unboxed"})}),e[1]=o,e[2]=t.analysis.readFile.path,e[3]=d):d=e[3],d}if(t.analysis.kind==="search"&&!t.failed){let c;if(e[4]!==s||e[5]!==o){let u;e[7]!==s?(u=(f,m)=>{const p=f.match(eE);return r.jsx("span",{className:"block",children:p?r.jsxs(r.Fragment,{children:[r.jsxs(A2,{path:p[1],line:Number(p[2]),cwd:s,children:[p[1],":",p[2]]}),f.slice(p[1].length+p[2].length+1)]}):f||" "},m)},e[7]=s,e[8]=u):u=e[8],c=o.split(`
|
|
105
|
+
`).map(u),e[4]=s,e[5]=o,e[6]=c}else c=e[6];let d;return e[9]!==c?(d=r.jsx("pre",{className:Jl,children:c}),e[9]=c,e[10]=d):d=e[10],d}const i=t.failed&&"border-destructive/30 text-destructive";let a;e[11]!==i?(a=G(Jl,i),e[11]=i,e[12]=a):a=e[12];let l;return e[13]!==o||e[14]!==a?(l=r.jsx("pre",{className:a,children:o}),e[13]=o,e[14]=a,e[15]=l):l=e[15],l}function nE(n){var W;const e=B.c(56),{row:t,index:s,defaultOpen:o,cwd:i}=n,[a,l]=y.useState(o);let c;e[0]!==t.section?(c=C2(t.section),e[0]=t.section,e[1]=c):c=e[1];const d=c,u=t.section.output!==null&&t.section.output!=="",f=`${d} section: ${t.section.command}`,m=ma[t.analysis.kind].icon,p=t.failed&&"text-destructive";let h;e[2]!==p?(h=G("w-4 shrink-0 text-right font-mono text-[10px] tabular-nums text-muted-foreground/60",p),e[2]=p,e[3]=h):h=e[3];const g=s+1;let x;e[4]!==h||e[5]!==g?(x=r.jsx("span",{className:h,"aria-hidden":"true",children:g}),e[4]=h,e[5]=g,e[6]=x):x=e[6];const b=ma[t.analysis.kind];let w;e[7]!==m||e[8]!==b.label?(w=r.jsx(m,{className:"size-3 shrink-0 text-muted-foreground","aria-label":b.label}),e[7]=m,e[8]=b.label,e[9]=w):w=e[9];const v=t.failed&&_2.failed;let S;e[10]!==v?(S=G("h-5 shrink-0 px-1.5 font-mono text-[10px] text-muted-foreground",v),e[10]=v,e[11]=S):S=e[11];let j;e[12]!==d||e[13]!==S?(j=r.jsx(Pe,{variant:"outline",className:S,children:d}),e[12]=d,e[13]=S,e[14]=j):j=e[14];let k;e[15]!==i||e[16]!==t.analysis.paths||e[17]!==t.section.command?(k=r.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground/85",children:r.jsx(Z8,{command:t.section.command,paths:t.analysis.paths,cwd:i})}),e[15]=i,e[16]=t.analysis.paths,e[17]=t.section.command,e[18]=k):k=e[18];let C;e[19]!==t.analysis.readFile?(C=((W=t.analysis.readFile)==null?void 0:W.from)&&r.jsxs("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground/60",children:["L",t.analysis.readFile.from,"–",t.analysis.readFile.to]}),e[19]=t.analysis.readFile,e[20]=C):C=e[20];const N=t.failed&&"font-medium text-destructive";let _;e[21]!==N?(_=G("shrink-0 text-[10px] tabular-nums text-muted-foreground",N),e[21]=N,e[22]=_):_=e[22];let A;e[23]!==t?(A=t.failed?"failed":J8(t),e[23]=t,e[24]=A):A=e[24];let P;e[25]!==_||e[26]!==A?(P=r.jsx("span",{className:_,children:A}),e[25]=_,e[26]=A,e[27]=P):P=e[27];const T=a&&"rotate-90",E=!u&&"invisible";let $;e[28]!==T||e[29]!==E?($=G("size-3 shrink-0 text-muted-foreground/60 transition-transform",T,E),e[28]=T,e[29]=E,e[30]=$):$=e[30];let I;e[31]!==$?(I=r.jsx(Xe,{className:$,"aria-hidden":"true"}),e[31]=$,e[32]=I):I=e[32];let R;e[33]!==j||e[34]!==k||e[35]!==C||e[36]!==P||e[37]!==I||e[38]!==x||e[39]!==w?(R=r.jsxs(r.Fragment,{children:[x,w,j,k,C,P,I]}),e[33]=j,e[34]=k,e[35]=C,e[36]=P,e[37]=I,e[38]=x,e[39]=w,e[40]=R):R=e[40];const D=R;if(!u){let U;return e[41]!==D||e[42]!==f?(U=r.jsx("div",{className:"group/row flex min-w-0 w-full items-center gap-2 py-2 text-left","aria-label":f,children:D}),e[41]=D,e[42]=f,e[43]=U):U=e[43],U}let O,M;e[44]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsx("div",{role:"button",tabIndex:0}),M=G("group/row flex min-w-0 w-full items-center gap-2 py-2 text-left","cursor-pointer rounded-sm hover:bg-muted/40"),e[44]=O,e[45]=M):(O=e[44],M=e[45]);let F;e[46]!==D||e[47]!==f?(F=r.jsx(Rt,{nativeButton:!1,render:O,className:M,"aria-label":f,children:D}),e[46]=D,e[47]=f,e[48]=F):F=e[48];let z;e[49]!==i||e[50]!==t?(z=r.jsx(mt,{children:r.jsx(tE,{row:t,cwd:i})}),e[49]=i,e[50]=t,e[51]=z):z=e[51];let L;return e[52]!==a||e[53]!==F||e[54]!==z?(L=r.jsxs(ft,{open:a,onOpenChange:l,children:[F,z]}),e[52]=a,e[53]=F,e[54]=z,e[55]=L):L=e[55],L}function sE(n){const e=new Map;for(const{analysis:t}of n)e.set(t.kind,(e.get(t.kind)??0)+1);return W8.filter(t=>e.has(t)).map(t=>{const s=e.get(t)??0;return`${s} ${s===1?ma[t].label:ma[t].plural}`}).join(" · ")}function oE(n){const e=B.c(10),{call:t,index:s}=n,o=s+1;let i;e[0]!==o?(i=r.jsxs("span",{className:"font-medium text-foreground/70",children:["Call ",o]}),e[0]=o,e[1]=i):i=e[1];let a;e[2]!==t.description?(a=t.description&&r.jsx("span",{children:t.description}),e[2]=t.description,e[3]=a):a=e[3];let l;e[4]!==t.options?(l=t.options.map(rE),e[4]=t.options,e[5]=l):l=e[5];let c;return e[6]!==i||e[7]!==a||e[8]!==l?(c=r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 pb-1 pt-2 text-[11px] text-muted-foreground",children:[i,a,l]}),e[6]=i,e[7]=a,e[8]=l,e[9]=c):c=e[9],c}function rE(n){return r.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/70",children:n},n)}function iE(n){const e=B.c(51),{toolCalls:t,cwd:s,expandAll:o,isAgentActive:i}=n,a=o===void 0?!1:o,l=i===void 0?!1:i;let c;if(e[0]!==l||e[1]!==t){let K;e[3]!==l?(K=V=>X8(V,l),e[3]=l,e[4]=K):K=e[4],c=t.map(K),e[0]=l,e[1]=t,e[2]=c}else c=e[2];const d=c,u=d.flatMap(mE),f=u.length,m=u.reduce(fE,0),p=u.filter(uE).length,h=u.filter(dE).length,[g,x]=Ts();let b;e[5]!==d?(b=d.map(cE).join(`
|
|
106
|
+
|
|
107
|
+
`),e[5]=d,e[6]=b):b=e[6];const w=b,v=d.length===1?d[0].description:void 0;let S;e[7]!==d[0]||e[8]!==d.length?(S=d.length===1?d[0].options:[],e[7]=d[0],e[8]=d.length,e[9]=S):S=e[9];const j=S;let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(ko,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),e[10]=k):k=e[10];const C=mn,N="flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 [overflow-wrap:anywhere]";let _;e[11]!==d.length?(_=d.length>1&&r.jsxs("span",{children:[d.length," calls"]}),e[11]=d.length,e[12]=_):_=e[12];const A=sE(u);let P;e[13]!==A?(P=r.jsx("span",{children:A}),e[13]=A,e[14]=P):P=e[14];let T;e[15]!==v?(T=v&&r.jsx("span",{className:"text-foreground/70",children:v}),e[15]=v,e[16]=T):T=e[16];let E;e[17]!==j?(E=j.map(lE),e[17]=j,e[18]=E):E=e[18];const $=m===1?"line":"lines";let I;e[19]!==p?(I=p>0&&r.jsxs("span",{className:"font-medium text-destructive",children:[" · ",p," failed"]}),e[19]=p,e[20]=I):I=e[20];let R;e[21]!==h?(R=h>0&&r.jsxs("span",{children:[" · ",h," not run"]}),e[21]=h,e[22]=R):R=e[22];let D;e[23]!==$||e[24]!==I||e[25]!==R||e[26]!==m?(D=r.jsxs("span",{className:"ml-auto tabular-nums",children:[m," ",$,I,R]}),e[23]=$,e[24]=I,e[25]=R,e[26]=m,e[27]=D):D=e[27];let O;e[28]!==C||e[29]!==P||e[30]!==T||e[31]!==E||e[32]!==D||e[33]!==_?(O=r.jsxs(C,{className:N,children:[_,P,T,E,D]}),e[28]=C,e[29]=P,e[30]=T,e[31]=E,e[32]=D,e[33]=_,e[34]=O):O=e[34];let M;e[35]!==w||e[36]!==x?(M=()=>x(w),e[35]=w,e[36]=x,e[37]=M):M=e[37];const F=g?"Commands copied":f===1?"Copy command":"Copy commands",z=g?"Copied":f===1?"Copy command":"Copy commands";let L;e[38]!==g?(L=g?r.jsx(dt,{"data-icon":"inline-start","aria-hidden":"true"}):r.jsx(xn,{"data-icon":"inline-start","aria-hidden":"true"}),e[38]=g,e[39]=L):L=e[39];let W;e[40]!==M||e[41]!==F||e[42]!==z||e[43]!==L?(W=r.jsx(ax,{children:r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:M,"aria-label":F,title:z,children:L})}),e[40]=M,e[41]=F,e[42]=z,e[43]=L,e[44]=W):W=e[44];let U;e[45]!==d||e[46]!==s||e[47]!==a?(U=d.map((K,V)=>{const Y=d.slice(0,V).reduce(aE,0);return r.jsxs("div",{children:[V>0&&r.jsx(Nt,{}),d.length>1&&r.jsx(oE,{call:K,index:V}),K.rows.map((q,J)=>r.jsx(nE,{row:q,index:Y+J,defaultOpen:a,cwd:s},J))]},K.toolCall.id)}),e[45]=d,e[46]=s,e[47]=a,e[48]=U):U=e[48];let H;return e[49]!==U?(H=r.jsx(rn,{children:r.jsx("div",{"aria-label":"Command sections",children:U})}),e[49]=U,e[50]=H):H=e[50],r.jsxs(on,{size:"sm",className:"mt-1.5 min-w-0",role:"region","aria-label":f===1?"Bash command":"Bash commands",children:[r.jsxs(un,{children:[r.jsxs(fn,{className:"flex min-w-0 items-center gap-2",children:[k,f," ",f===1?"command":"commands"]}),O,W]}),H]})}function aE(n,e){return n+e.rows.length}function lE(n){return r.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/70",children:n},n)}function cE(n){return n.command}function dE(n){return n.section.output===null&&!n.pending}function uE(n){return n.failed}function fE(n,e){return n+E2(e.section.output)}function mE(n){return n.rows}function pE(n){const e=B.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(hE)),e[2]=l,e[3]=c):c=e[3];const[d,u]=y.useState(c),[f,m]=y.useState(!1),[p,h]=y.useState(!1),{chat:g}=qr(),{sendMessage:x}=g;if(l.length===0)return null;let b;e[4]!==d||e[5]!==l||e[6]!==x?(b=()=>{const T=l.map(E=>{var I;const $=(I=d[E.question])==null?void 0:I.trim();return $?l.length>1?`${E.question}
|
|
108
|
+
${$}`:$:null}).filter(Boolean).join(`
|
|
109
|
+
|
|
110
|
+
`);T&&x(T),h(!0)},e[4]=d,e[5]=l,e[6]=x,e[7]=b):b=e[7];const w=b;let v;if(e[8]!==d||e[9]!==w||e[10]!==s||e[11]!==t.id){const T=async E=>{E.preventDefault(),m(!0);try{(await qd(s,t.id,d)).ok?h(!0):w()}catch{w()}m(!1)};v=E=>{T(E)},e[8]=d,e[9]=w,e[10]=s,e[11]=t.id,e[12]=v}else v=e[12];const S=!i&&"mt-2 rounded-md border bg-card p-3",j=p&&"pointer-events-none opacity-50";let k;e[13]!==S||e[14]!==j?(k=G("flex flex-col gap-3",S,j),e[13]=S,e[14]=j,e[15]=k):k=e[15];let C;if(e[16]!==d||e[17]!==l||e[18]!==t.id){let T;e[20]!==d||e[21]!==t.id?(T=(E,$)=>{const I=E.options&&E.options.length>0,R=new Set(E.multiSelect?(d[E.question]??"").split(", ").filter(Boolean):[]),D=`ask-user-answer-${t.id}-${$}`;return r.jsxs(K4,{className:"gap-2 border-b border-border pb-3 last:border-b-0 last:pb-0",children:[(E.header||E.question)&&r.jsxs(V4,{variant:"label",className:"flex flex-col items-start gap-1",children:[E.header&&r.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:E.header}),r.jsx("span",{className:"text-sm leading-relaxed text-foreground",children:E.question})]}),I?r.jsx(xg,{multiple:E.multiSelect,orientation:"vertical",variant:"outline",value:E.multiSelect?Array.from(R):d[E.question]?[d[E.question]]:[],onValueChange:O=>{if(!E.multiSelect&&O.length===0)return;const M=E.multiSelect?O.join(", "):O[0];u({...d,[E.question]:M})},className:"grid w-full gap-1.5",children:E.options.map((O,M)=>{const F=E.multiSelect?R.has(O.label):d[E.question]===O.label;return r.jsxs(bg,{value:O.label,"aria-label":O.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",E.multiSelect?"rounded":"rounded-full",F?"border-primary bg-primary text-primary-foreground":"border-muted-foreground/30"),"aria-hidden":"true",children:F&&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:O.label}),O.description&&r.jsx("span",{className:"mt-0.5 block text-xs leading-relaxed text-muted-foreground",children:O.description})]})]},M)})}):r.jsxs(jt,{children:[r.jsx(St,{htmlFor:D,children:"Answer"}),r.jsx(Ka,{id:D,value:d[E.question]??"",onChange:O=>{u({...d,[E.question]:O.target.value})},rows:2,placeholder:"Type your answer..."})]})]},$)},e[20]=d,e[21]=t.id,e[22]=T):T=e[22],C=l.map(T),e[16]=d,e[17]=l,e[18]=t.id,e[19]=C}else C=e[19];const N=f||p,_=p?"Sent":f?"Sending...":"Send answer";let A;e[23]!==N||e[24]!==_?(A=r.jsx(ee,{type:"submit",size:"sm",disabled:N,children:_}),e[23]=N,e[24]=_,e[25]=A):A=e[25];let P;return e[26]!==C||e[27]!==A||e[28]!==v||e[29]!==k?(P=r.jsxs("form",{onSubmit:v,className:k,children:[C,A]}),e[26]=C,e[27]=A,e[28]=v,e[29]=k,e[30]=P):P=e[30],P}function hE(n){return[n.question,""]}function gE(n){return Array.isArray(n.input.questions)?n.input.questions.filter(e=>typeof e=="object"&&e!==null&&typeof e.question=="string"):[]}function Kp(n){try{return JSON.parse(`"${n}"`)}catch{return n.replace(/\\"/g,'"').replace(/\\\\/g,"\\")}}function xE(n){const e={},t=/"((?:\\.|[^"\\])*)"\s*=\s*"((?:\\.|[^"\\])*)"/g;let s;for(;(s=t.exec(n))!==null;)e[Kp(s[1])]=Kp(s[2]);return e}function bE(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function vE(n,e){const t=(n.options??[]).filter(s=>{const o=s.label.trim();return o?new RegExp(`(^|[^\\p{L}\\p{N}])${bE(o)}(?=$|[^\\p{L}\\p{N}])`,"iu").test(e):!1});return t.length===1?t[0].label:void 0}function yE(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=xE(n.result);for(const o of e)if(s[o.question]===void 0){const i=vE(o,n.result);i!==void 0&&(s[o.question]=i)}return s}function Vp(n,e,t){return e===void 0?!1:n.multiSelect?e.split(/,\s*/).includes(t):e===t}function wE(n){const e=B.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 v;e[6]!==s||e[7]!==t?(v=S=>Vp(t,s,S.label),e[6]=s,e[7]=t,e[8]=v):v=e[8],c=l.filter(v),e[2]=s,e[3]=l,e[4]=t,e[5]=c}else c=e[5];const d=c.length,u=i&&s!==void 0&&d===0,f=o+1;let m;e[9]!==f?(m=r.jsx(Pe,{variant:"outline",className:"size-5 rounded-full p-0 font-mono text-muted-foreground",children:f}),e[9]=f,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((v,S)=>{const j=Vp(t,s,v.label);return r.jsxs("div",{className:G("flex items-start gap-2.5 py-2",j?"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",j?"border-primary bg-primary text-primary-foreground":"border-muted-foreground/30"),"aria-hidden":"true",children:j&&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:[v.label,j&&r.jsx(Pe,{variant:"secondary",className:"ml-2",children:"Selected"})]}),v.description&&r.jsx("span",{className:"mt-0.5 block text-xs leading-relaxed text-muted-foreground",children:v.description})]})]},`${v.label}-${S}`)})}),e[18]=s,e[19]=l,e[20]=t,e[21]=x):x=e[21];let b;e[22]!==s||e[23]!==u?(b=u&&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]=u,e[24]=b):b=e[24];let w;return e[25]!==h||e[26]!==g||e[27]!==x||e[28]!==b?(w=r.jsxs("div",{className:"border-b border-border py-3 last:border-b-0",children:[h,g,x,b]}),e[25]=h,e[26]=g,e[27]=x,e[28]=b,e[29]=w):w=e[29],w}function jE(n){const e=B.c(61),{toolCall:t,expandToolPayloads:s,isAwaitingAnswer:o,sessionId:i}=n,[a,l]=y.useState(!1);let c;e[0]!==t?(c=gE(t),e[0]=t,e[1]=c):c=e[1];const d=c;let u;e[2]!==d||e[3]!==t?(u=yE(t,d),e[2]=d,e[3]=t,e[4]=u):u=e[4];const f=u,m=s||a,p=t.result!==null&&!t.isError,h=t.result===null&&o&&!!i&&d.length>0;let g;e[5]!==f?(g=Object.keys(f),e[5]=f,e[6]=g):g=e[6];const x=g.length>0,b=t.isError?Yt:p?Wn:Lr,w=t.isError?"Not answered":p?"Answered":h?"Waiting for answer":"No answer recorded",v=t.isError&&"border-destructive/30";let S;e[7]!==v?(S=G("my-1 overflow-hidden rounded-lg border bg-card",v),e[7]=v,e[8]=S):S=e[8];let j;e[9]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(D1,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground","data-icon":"inline-start"}),e[9]=j):j=e[9];let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx("h3",{className:"text-sm font-medium text-foreground",children:"Decision requested"}),e[10]=k):k=e[10];const C=d.length===1?"question":"questions";let N;e[11]!==d.length||e[12]!==C?(N=r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[k,r.jsxs("span",{className:"text-xs text-muted-foreground",children:[d.length," ",C]})]}),e[11]=d.length,e[12]=C,e[13]=N):N=e[13];const _=t.isError?"destructive":p?"secondary":"outline";let A;e[14]!==b?(A=r.jsx(b,{"data-icon":"inline-start"}),e[14]=b,e[15]=A):A=e[15];let P;e[16]!==w||e[17]!==_||e[18]!==A?(P=r.jsxs(Pe,{variant:_,children:[A,w]}),e[16]=w,e[17]=_,e[18]=A,e[19]=P):P=e[19];let T;e[20]!==P||e[21]!==N?(T=r.jsxs("div",{className:"min-w-0 flex-1",children:[N,P]}),e[20]=P,e[21]=N,e[22]=T):T=e[22];let E;e[23]!==t.timestamp?(E=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]=E):E=e[24];let $;e[25]!==T||e[26]!==E?($=r.jsxs("header",{className:"flex items-start gap-2.5 border-b px-3 py-2.5",children:[j,T,E]}),e[25]=T,e[26]=E,e[27]=$):$=e[27];let I;e[28]!==f||e[29]!==h||e[30]!==d||e[31]!==i||e[32]!==t?(I=h&&i?r.jsx(pE,{toolCall:t,sessionId:i,embedded:!0}):d.length>0?d.map((U,H)=>r.jsx(wE,{question:U,answer:f[U.question],index:H,completed:t.result!==null},`${U.question}-${H}`)):r.jsx("p",{className:"py-3 text-sm text-muted-foreground",children:"Question details are unavailable."}),e[28]=f,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 D;e[38]!==I||e[39]!==R?(D=r.jsxs("div",{className:"px-3",children:[I,R]}),e[38]=I,e[39]=R,e[40]=D):D=e[40];let O;e[41]!==s?(O=()=>{s||l(SE)},e[41]=s,e[42]=O):O=e[42];let M;e[43]!==m?(M=m?r.jsx(it,{"data-icon":"inline-start"}):r.jsx(Xe,{"data-icon":"inline-start"}),e[43]=m,e[44]=M):M=e[44];let F;e[45]!==m||e[46]!==O||e[47]!==M?(F=r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:O,className:"-ml-2 text-muted-foreground","aria-expanded":m,children:[M,"Raw details"]}),e[45]=m,e[46]=O,e[47]=M,e[48]=F):F=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 L;e[53]!==F||e[54]!==z?(L=r.jsxs("div",{className:"border-t px-3 py-1.5",children:[F,z]}),e[53]=F,e[54]=z,e[55]=L):L=e[55];let W;return e[56]!==$||e[57]!==D||e[58]!==L||e[59]!==S?(W=r.jsxs("section",{className:S,"aria-label":"Question history",children:[$,D,L]}),e[56]=$,e[57]=D,e[58]=L,e[59]=S,e[60]=W):W=e[60],W}function SE(n){return!n}const NE=4;function P2(n,e=!1){return e?"text-destructive":DT(n)==="mutating"?"text-foreground":"text-muted-foreground"}function kE(n){const e=B.c(2),{toolCall:t,isAgentActive:s}=n;if(t.isError){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(Ys,{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 CE(n){const e=B.c(12),{chips:t}=n;let s,o,i,a;if(e[0]!==t){const d=t.slice(0,NE);s=t.length-d.length,o="flex min-w-0 items-center gap-1 overflow-hidden",i=`Sections: ${t.map(TE).join(", ")}`,a=d.map(_E),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];let l;e[5]!==s?(l=s>0&&r.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:["+",s]}),e[5]=s,e[6]=l):l=e[6];let c;return e[7]!==o||e[8]!==i||e[9]!==a||e[10]!==l?(c=r.jsxs("span",{className:o,"aria-label":i,children:[a,l]}),e[7]=o,e[8]=i,e[9]=a,e[10]=l,e[11]=c):c=e[11],c}function _E(n,e){return r.jsxs(Pe,{variant:"outline",className:G("h-4 shrink-0 px-1.5 font-mono text-[10px]",_2[n.tone]),children:[n.name,n.count>1?` ×${n.count}`:""]},e)}function TE(n){return`${n.name}${n.count>1?` ×${n.count}`:""}`}function EE(n){const e=B.c(4),{chips:t,summary:s}=n;if(t){let i;return e[0]!==t?(i=r.jsx(CE,{chips:t}),e[0]=t,e[1]=i):i=e[1],i}if(!s)return null;let o;return e[2]!==s?(o=r.jsx("span",{className:"min-w-0 truncate font-mono text-xs text-muted-foreground",children:s}),e[2]=s,e[3]=o):o=e[3],o}function AE(n){const e=B.c(30),{toolCall:t,isAgentActive:s,displayName:o,summary:i,sectionChips:a,nameTitle:l,nameClass:c,timeLabel:d,timeIso:u}=n;let f;e[0]!==u||e[1]!==d?(f=d&&r.jsx("time",{className:"sr-only",dateTime:u,children:d}),e[0]=u,e[1]=d,e[2]=f):f=e[2];let m;e[3]!==c?(m=G("max-w-[50%] shrink-0 truncate font-mono text-xs",c),e[3]=c,e[4]=m):m=e[4];let p;e[5]!==o||e[6]!==l||e[7]!==m?(p=r.jsx("span",{className:m,title:l,children:o}),e[5]=o,e[6]=l,e[7]=m,e[8]=p):p=e[8];let h;e[9]!==a||e[10]!==i?(h=r.jsx(EE,{chips:a,summary:i}),e[9]=a,e[10]=i,e[11]=h):h=e[11];let g;e[12]!==p||e[13]!==h?(g=r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[p,h]}),e[12]=p,e[13]=h,e[14]=g):g=e[14];let x;e[15]!==t.hookDurationMs?(x=t.hookDurationMs!==void 0&&t.hookDurationMs>0&&r.jsxs("span",{className:"text-[10px] text-muted-foreground/50 tabular-nums",title:"PostToolUse hook duration",children:[t.hookDurationMs,"ms"]}),e[15]=t.hookDurationMs,e[16]=x):x=e[16];let b;e[17]!==t.outputReplacedByHook?(b=t.outputReplacedByHook&&r.jsx("span",{className:"text-[10px] text-info",title:"Output replaced by hook",children:"hook"}),e[17]=t.outputReplacedByHook,e[18]=b):b=e[18];let w;e[19]!==s||e[20]!==t?(w=r.jsx(kE,{toolCall:t,isAgentActive:s}),e[19]=s,e[20]=t,e[21]=w):w=e[21];let v;e[22]!==x||e[23]!==b||e[24]!==w?(v=r.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[x,b,w]}),e[22]=x,e[23]=b,e[24]=w,e[25]=v):v=e[25];let S;return e[26]!==f||e[27]!==g||e[28]!==v?(S=r.jsxs(r.Fragment,{children:[f,g,v]}),e[26]=f,e[27]=g,e[28]=v,e[29]=S):S=e[29],S}function PE(n){if(n.isError)return null;const e=n.name==="Read"?n.input.file_path:/(?:^|[._])view_image$/.test(n.name)?n.input.path:null;return typeof e=="string"&&xu(e)?e:null}function $E(n){const e=B.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(Eu,{oldString:s,newString:o,filePath:i}),e[0]=s,e[1]=o,e[2]=i,e[3]=a):a=e[3],a}const $2=y.memo(function(e){var Re,Fe,Le,Ie;const t=B.c(167),{toolCall:s,groupedBashCalls:o,expandToolPayloads:i,isAgentActive:a,skillMetadata:l}=e,c=i===void 0?!1:i,{session:d,pendingInteraction:u}=at(),[f,m]=y.useState(!1),[p,h]=y.useState(!1),g=y.useId(),x=y.useId();let b;t[0]!==s?(b=g2(s),t[0]=s,t[1]=b):b=t[1];const w=b;let v;t[2]!==w||t[3]!==s.input||t[4]!==s.name?(v=!w&&(s.name==="Bash"||/(?:^|[._])exec_command$/.test(s.name))&&!!Fo(s.input),t[2]=w,t[3]=s.input,t[4]=s.name,t[5]=v):v=t[5];const S=v;let j;t[6]!==o||t[7]!==S||t[8]!==s?(j=o??(S?[s]:[]),t[6]=o,t[7]=S,t[8]=s,t[9]=j):j=t[9];const k=j;let C;t[10]!==s?(C=ii(s),t[10]=s,t[11]=C):C=t[11];const N=C;let _;t[12]!==k?(_=k.length>0?k.flatMap(T2):null,t[12]=k,t[13]=_):_=t[13];const A=_;let P;t[14]!==A?(P=A&&(A.length>1||A.some(RE))?U8(A):void 0,t[14]=A,t[15]=P):P=t[15];const T=P,E=k.length>1?`${N.label} ×${k.length}`:N.label,$=N.label===s.name?s.name:`${N.label} (${s.name})`;let I;t[16]!==k||t[17]!==s.isError?(I=s.isError||k.some(IE),t[16]=k,t[17]=s.isError,t[18]=I):I=t[18];let R;t[19]!==N.styleName||t[20]!==I?(R=P2(N.styleName,I),t[19]=N.styleName,t[20]=I,t[21]=R):R=t[21];const D=R;let O;e:{if(k.length<=1){O=s;break e}const _e=k.some(ME)?null:s.result;let je;t[22]!==k?(je=k.some(OE),t[22]=k,t[23]=je):je=t[23];let ze;t[24]!==k?(ze=k.some(DE),t[24]=k,t[25]=ze):ze=t[25];let Ne;t[26]!==k?(Ne=k.reduce(LE,0),t[26]=k,t[27]=Ne):Ne=t[27];let Se;t[28]!==_e||t[29]!==je||t[30]!==ze||t[31]!==Ne||t[32]!==s?(Se={...s,result:_e,isError:je,outputReplacedByHook:ze,hookDurationMs:Ne},t[28]=_e,t[29]=je,t[30]=ze,t[31]=Ne,t[32]=s,t[33]=Se):Se=t[33],O=Se}const M=O;let F;t[34]!==s.timestamp?(F=s.timestamp?new Date(s.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}):void 0,t[34]=s.timestamp,t[35]=F):F=t[35];const z=F;let L;t[36]!==s.timestamp?(L=s.timestamp?new Date(s.timestamp).toISOString():void 0,t[36]=s.timestamp,t[37]=L):L=t[37];const W=L,U=c||f,H=k.length>1?`${(A==null?void 0:A.length)??k.length} commands`:N.summary;let K;t[38]!==l||t[39]!==H||t[40]!==s.name?(K=s.name==="Skill"&&l?l.get(H)??null:null,t[38]=l,t[39]=H,t[40]=s.name,t[41]=K):K=t[41];const V=K,Y=V==null?void 0:V.filePath,q=s.name==="Edit"&&typeof s.input.old_string=="string"&&typeof s.input.new_string=="string"&&typeof s.input.file_path=="string";let J,Q,X,Z,te;if(t[42]!==k.length||t[43]!==T||t[44]!==E||t[45]!==c||t[46]!==q||t[47]!==a||t[48]!==D||t[49]!==$||t[50]!==g||t[51]!==u||t[52]!==(d==null?void 0:d.sessionId)||t[53]!==U||t[54]!==M||t[55]!==H||t[56]!==W||t[57]!==z||t[58]!==s){te=Symbol.for("react.early_return_sentinel");e:{const _e=PE(s),je=!!((Re=s.resultImages)!=null&&Re.length),ze=_e!==null&&((Fe=s.result)==null?void 0:Fe.trim())===""&&!je;let Ne;if(t[64]!==k.length||t[65]!==q||t[66]!==ze||t[67]!==je||t[68]!==s.isError||t[69]!==s.result?(Ne=s.result!==null&&!ze&&k.length===0&&(!je||!!((Le=s.result)!=null&&Le.trim()))&&(!q||s.isError),t[64]=k.length,t[65]=q,t[66]=ze,t[67]=je,t[68]=s.isError,t[69]=s.result,t[70]=Ne):Ne=t[70],J=Ne,s.name==="AskUserQuestion"){const fe=(u==null?void 0:u.type)==="question"&&u.toolUseId===s.id,ve=d==null?void 0:d.sessionId;let Oe;t[71]!==c||t[72]!==fe||t[73]!==ve||t[74]!==s?(Oe=r.jsx(jE,{toolCall:s,expandToolPayloads:c,isAwaitingAnswer:fe,sessionId:ve}),t[71]=c,t[72]=fe,t[73]=ve,t[74]=s,t[75]=Oe):Oe=t[75],te=Oe;break e}const Se=M.isError&&"rounded-md bg-destructive/5 px-2";t[76]!==Se?(Q=G("min-w-0 py-1",Se),t[76]=Se,t[77]=Q):Q=t[77];const he=`Toggle ${E} details${H?`: ${H}`:""}`;let De;t[78]!==c?(De=()=>{c||m(zE)},t[78]=c,t[79]=De):De=t[79];const Be=U&&"rotate-90";let We;t[80]!==Be?(We=G("size-3 shrink-0 text-muted-foreground transition-transform",Be),t[80]=Be,t[81]=We):We=t[81];let we;t[82]!==We?(we=r.jsx(Xe,{className:We,"aria-hidden":"true"}),t[82]=We,t[83]=we):we=t[83];let Me;t[84]!==T||t[85]!==E||t[86]!==a||t[87]!==D||t[88]!==$||t[89]!==M||t[90]!==H||t[91]!==W||t[92]!==z?(Me=r.jsx(AE,{toolCall:M,isAgentActive:a,displayName:E,summary:H,sectionChips:T,nameTitle:$,nameClass:D,timeLabel:z,timeIso:W}),t[84]=T,t[85]=E,t[86]=a,t[87]=D,t[88]=$,t[89]=M,t[90]=H,t[91]=W,t[92]=z,t[93]=Me):Me=t[93],t[94]!==g||t[95]!==U||t[96]!==he||t[97]!==De||t[98]!==we||t[99]!==Me||t[100]!==z?(X=r.jsxs("button",{type:"button",className:"flex min-h-11 w-full min-w-0 items-center gap-2 rounded-sm text-left hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring sm:min-h-7",title:z,"aria-label":he,"aria-expanded":U,"aria-controls":g,onClick:De,children:[we,Me]}),t[94]=g,t[95]=U,t[96]=he,t[97]=De,t[98]=we,t[99]=Me,t[100]=z,t[101]=X):X=t[101],Z=ze&&r.jsx(Xc,{src:_e,alt:_e.slice(_e.lastIndexOf("/")+1),id:`tool-image:${s.id}`,className:"my-1.5",thumbnailClassName:"max-h-40"})}t[42]=k.length,t[43]=T,t[44]=E,t[45]=c,t[46]=q,t[47]=a,t[48]=D,t[49]=$,t[50]=g,t[51]=u,t[52]=d==null?void 0:d.sessionId,t[53]=U,t[54]=M,t[55]=H,t[56]=W,t[57]=z,t[58]=s,t[59]=J,t[60]=Q,t[61]=X,t[62]=Z,t[63]=te}else J=t[59],Q=t[60],X=t[61],Z=t[62],te=t[63];if(te!==Symbol.for("react.early_return_sentinel"))return te;let ne;t[102]!==s.id||t[103]!==s.resultImages?(ne=(Ie=s.resultImages)==null?void 0:Ie.map((_e,je)=>r.jsx(Xc,{src:`data:${_e.source.media_type};base64,${_e.source.data}`,alt:`Tool result image ${je+1}`,id:`tool-result-image:${s.id}:${je}`,className:"my-1.5",thumbnailClassName:"max-h-40"},`${_e.source.media_type}-${_e.source.data.length}-${_e.source.data.slice(0,32)}-${_e.source.data.slice(-32)}`)),t[102]=s.id,t[103]=s.resultImages,t[104]=ne):ne=t[104];let oe;t[105]!==Y||t[106]!==V?(oe=V&&r.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-2 font-mono text-xs text-muted-foreground",children:[r.jsxs("span",{children:["source: ",V.source]}),Y&&(!Ws()||ou())&&r.jsxs(ee,{type:"button",variant:"link",size:"xs",onClick:()=>yr(Y),title:Y,children:[r.jsx(O1,{"data-icon":"inline-start"}),"Open SKILL.md"]})]}),t[105]=Y,t[106]=V,t[107]=oe):oe=t[107];let re;t[108]!==q||t[109]!==s?(re=q&&r.jsx($E,{toolCall:s}),t[108]=q,t[109]=s,t[110]=re):re=t[110];let ae;t[111]!==k||t[112]!==c||t[113]!==q||t[114]!==a||t[115]!==w||t[116]!==(d==null?void 0:d.cwd)||t[117]!==s.input?(ae=k.length>0?r.jsx(iE,{toolCalls:k,cwd:d==null?void 0:d.cwd,expandAll:c,isAgentActive:!!a}):w?r.jsx(v8,{input:s.input}):q?null:r.jsx(x2,{input:s.input}),t[111]=k,t[112]=c,t[113]=q,t[114]=a,t[115]=w,t[116]=d==null?void 0:d.cwd,t[117]=s.input,t[118]=ae):ae=t[118];let se;t[119]!==J||t[120]!==s.input||t[121]!==s.isError||t[122]!==s.name||t[123]!==s.result?(se=J&&r.jsx(h8,{result:s.result??"",isError:s.isError,filePath:s.name==="Read"&&typeof s.input.file_path=="string"?s.input.file_path:void 0}),t[119]=J,t[120]=s.input,t[121]=s.isError,t[122]=s.name,t[123]=s.result,t[124]=se):se=t[124];let de;t[125]===Symbol.for("react.memo_cache_sentinel")?(de=()=>h(FE),t[125]=de):de=t[125];const le=p&&"rotate-90";let ce;t[126]!==le?(ce=G(le),t[126]=le,t[127]=ce):ce=t[127];let me;t[128]!==ce?(me=r.jsx(Xe,{"data-icon":"inline-start",className:ce}),t[128]=ce,t[129]=me):me=t[129];let ue;t[130]!==x||t[131]!==p||t[132]!==me?(ue=r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",className:"mt-1","aria-expanded":p,"aria-controls":x,onClick:de,children:[me,"Input"]}),t[130]=x,t[131]=p,t[132]=me,t[133]=ue):ue=t[133];let ie;t[134]!==k||t[135]!==s.input?(ie=JSON.stringify(k.length>1?k.map(BE):s.input),t[134]=k,t[135]=s.input,t[136]=ie):ie=t[136];let ge;t[137]!==ie?(ge=r.jsx(j2,{result:ie,expanded:!0}),t[137]=ie,t[138]=ge):ge=t[138];let pe;t[139]!==x||t[140]!==ge?(pe=r.jsx(mt,{id:x,children:ge}),t[139]=x,t[140]=ge,t[141]=pe):pe=t[141];let xe;t[142]!==p||t[143]!==ue||t[144]!==pe?(xe=r.jsxs(ft,{open:p,children:[ue,pe]}),t[142]=p,t[143]=ue,t[144]=pe,t[145]=xe):xe=t[145];let Ce;t[146]!==g||t[147]!==re||t[148]!==ae||t[149]!==se||t[150]!==xe?(Ce=r.jsxs(mt,{id:g,children:[re,ae,se,xe]}),t[146]=g,t[147]=re,t[148]=ae,t[149]=se,t[150]=xe,t[151]=Ce):Ce=t[151];let Te;t[152]!==U||t[153]!==Ce?(Te=r.jsx(ft,{open:U,children:Ce}),t[152]=U,t[153]=Ce,t[154]=Te):Te=t[154];let Ee;t[155]!==s.id||t[156]!==s.name||t[157]!==s.result?(Ee=(s.name==="Task"||s.name==="Agent")&&s.result===null&&r.jsx(_u,{toolUseId:s.id}),t[155]=s.id,t[156]=s.name,t[157]=s.result,t[158]=Ee):Ee=t[158];let $e;return t[159]!==Q||t[160]!==X||t[161]!==Z||t[162]!==ne||t[163]!==oe||t[164]!==Te||t[165]!==Ee?($e=r.jsxs("div",{className:Q,children:[X,Z,ne,oe,Te,Ee]}),t[159]=Q,t[160]=X,t[161]=Z,t[162]=ne,t[163]=oe,t[164]=Te,t[165]=Ee,t[166]=$e):$e=t[166],$e});function RE(n){return n.label}function IE(n){return n.isError}function ME(n){return n.result===null}function OE(n){return n.isError}function DE(n){return n.outputReplacedByHook}function LE(n,e){return n+(e.hookDurationMs??0)}function zE(n){return!n}function FE(n){return!n}function BE(n){return n.input}const UE=y.memo(function({plan:e,planFilePath:t,status:s,toolCalls:o,expandAll:i=!1,expandToolPayloads:a=!1,isAgentActive:l,skillMetadata:c}){const[d,u]=y.useState(!0),f=o.some(S=>S.name==="AskUserQuestion"&&S.result===null),[m,p]=y.useState(null),h=y.useRef(f);y.useEffect(()=>{f&&(h.current=!0)},[f]);const g=i||d,x=i||(m??(f||h.current)),b=s==="approved"?Or:s==="rejected"?Ys:Us,w=g?it:Xe,v=x?it:Xe;return r.jsxs(ft,{open:g,onOpenChange:u,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(Rt,{render:r.jsx(ee,{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(G3,{className:"size-4 text-muted-foreground","data-icon":"inline-start"}),r.jsx("span",{className:"text-sm font-medium",children:"Plan Mode"}),r.jsx(b,{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(mt,{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(Hn,{remarkPlugins:[Ma],components:Kn,children:e})}),o.length>0&&r.jsxs(ft,{open:x,onOpenChange:p,className:"mt-2",children:[r.jsxs(Rt,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"-ml-2 text-muted-foreground"}),children:[r.jsx(v,{"data-icon":"inline-start"}),o.length," call",o.length===1?"":"s"," during planning"]}),r.jsx(mt,{children:r.jsx("div",{className:"ml-4 mt-1 flex flex-col gap-1",children:o.map(S=>r.jsx($2,{toolCall:S,expandToolPayloads:a,isAgentActive:l,skillMetadata:c},S.id))})})]})]})})]})}),WE=y.memo(function(e){const t=B.c(14),{content:s}=e,[o,i]=y.useState(!0),a=o?it:Xe;let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(ee,{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,u;t[3]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Y3,{className:"size-4 text-muted-foreground","data-icon":"inline-start"}),u=r.jsx("span",{className:"text-sm font-medium",children:"Session recap"}),t[3]=d,t[4]=u):(d=t[3],u=t[4]);let f;t[5]!==c?(f=r.jsxs(Rt,{render:l,children:[c,d,u]}),t[5]=c,t[6]=f):f=t[6];let m;t[7]===Symbol.for("react.memo_cache_sentinel")?(m=[Ma],t[7]=m):m=t[7];let p;t[8]!==s?(p=r.jsx(mt,{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(Hn,{remarkPlugins:m,components:Kn,children:s})})}),t[8]=s,t[9]=p):p=t[9];let h;return t[10]!==o||t[11]!==f||t[12]!==p?(h=r.jsxs(ft,{open:o,onOpenChange:i,className:"my-2 rounded-lg border bg-card",children:[f,p]}),t[10]=o,t[11]=f,t[12]=p,t[13]=h):h=t[13],h}),Ql=1;function Gp(n,e){return!e||n.length<=Ql?{visible:[...n],hidden:0}:{visible:n.slice(-Ql),hidden:n.length-Ql}}function HE(n){return`${n} earlier step${n===1?"":"s"}`}const qE=y.memo(function(e){const t=B.c(15),{blocks:s,expandAll:o}=e,[i,a]=y.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(Rt,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"-ml-2 text-muted-foreground"}),children:[l?r.jsx(it,{"data-icon":"inline-start"}):r.jsx(Xe,{"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 u;t[6]!==s?(u=s.map(KE),t[6]=s,t[7]=u):u=t[7];let f;t[8]!==u?(f=r.jsx(mt,{className:"mt-1 flex flex-col gap-2",children:u}),t[8]=u,t[9]=f):f=t[9];let m;return t[10]!==l||t[11]!==c||t[12]!==d||t[13]!==f?(m=r.jsxs(ft,{open:l,onOpenChange:c,children:[d,f]}),t[10]=l,t[11]=c,t[12]=d,t[13]=f,t[14]=m):m=t[14],m});function KE(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 Tr(n,e){if(!n&&!e)return{add:0,del:0};const t=n?n.split(`
|
|
111
|
+
`):[],s=e?e.split(`
|
|
112
|
+
`):[];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 u=new Array(d+1).fill(0),f=new Array(d+1).fill(0);for(let p=1;p<=c;p++){f[0]=0;const h=t[a+p-1];for(let g=1;g<=d;g++)h===s[a+g-1]?f[g]=u[g-1]+1:f[g]=u[g]>f[g-1]?u[g]:f[g-1];[u,f]=[f,u]}const m=u[d];return{add:d-m,del:c-m}}function VE(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(`
|
|
113
|
+
`);if(l){const c=Tr("",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(`
|
|
114
|
+
`),o=t.map(a=>a.current).join(`
|
|
115
|
+
`),i=Tr(s,o);return{originalStr:s,currentStr:o,addCount:i.add,delCount:i.del}}const GE=new Set(["echo","printf","true","false",":"]),YE=new Set(["find","grep","rg","ag","ack","locate","which","whereis"]),XE=new Set(["cat","head","tail","less","more","wc","stat","file","strings","jq","awk","cut","sort","uniq","tr"]),JE=new Set(["ls","tree","du"]);function QE(n){return n.split(/\|\||&&|[|;\n]/).map(e=>e.trim()).filter(Boolean)}function ZE(n){const e=QE(n);let t=!1,s=!1,o=!1,i=!1;for(const a of e){const l=a.split(/\s+/)[0];if(!(!l||GE.has(l)))if(i=!0,YE.has(l))t=!0;else if(XE.has(l))s=!0;else if(JE.has(l))o=!0;else return"shell"}return i?o?"list":t?"search":s?"read":"shell":"shell"}const e9=/[\\/]claude(?:-\d+)?[\\/](?:[^\\/]+[\\/])+scratchpad[\\/]/i;function t9(n){return e9.test(n)}const n9=new Set(["Grep","Glob"]),s9=new Set(["Bash","PowerShell"]),o9=new Set(["Edit","Write","NotebookEdit","MultiEdit"]),r9=new Set(["Task","Agent"]);function Yp(n){const e=n.file_path??n.path;return typeof e=="string"?e:null}function i9(n){return typeof n.command=="string"?n.command:null}function a9(n){if(!n.startsWith("mcp__"))return null;const e=n.split("__")[1];return e?e.replace(/^claude[._]ai[._]/i,"").replace(/_/g," "):null}function l9(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,u=Tr(typeof c=="string"?c:"",typeof d=="string"?d:"");i+=u.add,a+=u.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=Tr(t,s);return{added:o.add,removed:o.del}}function ro(n,e,t=`${e}s`){return`${n} ${n===1?e:t}`}function c9(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 d9(n,e={}){const t=new Set,s=new Set,o=new Set;let i=0,a=0,l=0,c=0,d=0,u=0,f=0,m=0,p=0,h=0,g=0,x=0;for(const j of n){const k=a9(j.name);if(k){p+=1,o.add(k);continue}if(o9.has(j.name)){const C=Yp(j.input),N=l9(j.name,j.input);C&&t9(C)?(l+=1,c+=N.added,d+=N.removed):(t.add(C??j.id),i+=N.added,a+=N.removed);continue}if(j.name==="Read"){const C=Yp(j.input);C?s.add(C):f+=1;continue}if(n9.has(j.name)){u+=1;continue}if(s9.has(j.name)){const C=i9(j.input);switch(C===null?"shell":ZE(C)){case"search":u+=1;break;case"list":m+=1;break;case"read":f+=1;break;default:x+=1}continue}if(r9.has(j.name)){h+=1;continue}g+=1}const b=s.size>0?s.size:f,w=[],v=(j,k,C=0,N=0)=>{w.push(C>0||N>0?{key:j,text:k,added:C,removed:N}:{key:j,text:k})},S=e.thoughtForMs??0;if(S>0&&v("thought",`thought for ${c9(S)}`),t.size>0&&v("edit",`edited ${ro(t.size,"file")}`,i,a),l>0&&v("scratchpad",`made ${l} scratchpad ${l===1?"edit":"edits"}`,c,d),u>0&&v("search",`searched for ${ro(u,"pattern")}`),b>0&&v("read",`read ${ro(b,"file")}`),m>0&&v("list",`listed ${ro(m,"directory","directories")}`),p>0){const j=[...o].join(", ")||"MCP";v("mcp",p>1?`called ${j} ${p} times`:`called ${j}`)}return h>0&&v("agent",`ran ${ro(h,"agent")}`),g>0&&v("other",`called ${ro(g,"tool")}`),x>0&&v("bash",`ran ${x} shell ${x===1?"command":"commands"}`),{clauses:w}}const Xp="text-muted-foreground";function Jp(n){const e=B.c(4),{summary:t}=n;let s;e[0]!==t.clauses?(s=t.clauses.map(u9),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 u9(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 Qp=y.memo(function(e){const t=B.c(35),{toolCalls:s,expandAll:o,expandToolPayloads:i,activeToolCallId:a,isAgentActive:l,activityItems:c,thinkingCount:d,thoughtForMs:u,skillMetadata:f}=e,m=l===void 0?!1:l,p=d===void 0?0:d,h=u===void 0?0:u,[g,x]=y.useState(null),b=y.useRef(null),w=m&&s.some(f9);let v;t[0]!==s?(v=s.some(m9),t[0]=s,t[1]=v):v=t[1];const S=v,j=o||S||(g??w),k=g===null&&w&&!o&&!S,C=y.useRef(null),N=y.useRef(null);let _,A;t[2]!==a||t[3]!==s?(_=()=>{if(!a){C.current=null;return}a!==C.current&&s.some(K=>K.id===a)&&(C.current=a,x(!0),N.current=requestAnimationFrame(()=>{N.current=requestAnimationFrame(()=>{var K;N.current=null,(K=b.current)==null||K.scrollIntoView({behavior:"smooth",block:"nearest"})})}))},A=[a,s],t[2]=a,t[3]=s,t[4]=_,t[5]=A):(_=t[4],A=t[5]),y.useEffect(_,A);let P,T;t[6]===Symbol.for("react.memo_cache_sentinel")?(P=()=>()=>{N.current!==null&&cancelAnimationFrame(N.current)},T=[],t[6]=P,t[7]=T):(P=t[6],T=t[7]),y.useEffect(P,T);let E;if(t[8]!==s){const K=new Map;for(const V of s){const{label:Y,styleName:q}=ii(V),J=K.get(Y);J?(J.count=J.count+1,J.hasError=J.hasError||!!V.isError):K.set(Y,{count:1,styleName:q,hasError:!!V.isError})}E=[...K].sort(p9),t[8]=s,t[9]=E}else E=t[9];const $=E;let I;t[10]!==h||t[11]!==s?(I=d9(s,{thoughtForMs:h}),t[10]=h,t[11]=s,t[12]=I):I=t[12];const R=I,D=function(V,Y,q){const J=q??[V],Q=m&&Y&&J.some(h9),X=a!==null&&J.some(Z=>Z.id===a);return r.jsx("div",{ref:X?b:void 0,className:G(X&&"rounded-md ring-1 ring-ring"),children:r.jsx($2,{toolCall:V,groupedBashCalls:q,expandToolPayloads:i,isAgentActive:Q,skillMetadata:f})},V.id)},O=function(V,Y){const q=[];let J=0;for(;J<V.length;){const Q=V[J];if(Q.name!=="Bash"){q.push(D(Q,Y&&J===V.length-1)),J++;continue}let X=J+1;for(;X<V.length&&V[X].name==="Bash";)X++;const Z=V.slice(J,X);q.push(D(Q,Y&&X===V.length,Z.length>1?Z:void 0)),J=X}return q};if(s.length===1&&p===0&&!c)return r.jsx("div",{className:"flex flex-col gap-2",children:O(s,!0)});if(j){let K;t[13]!==o||t[14]!==S||t[15]!==R||t[16]!==p?(K=!o&&!S&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>x(!1),className:"-ml-2 text-muted-foreground",children:[r.jsx(it,{"data-icon":"inline-start"}),R.clauses.length>0?r.jsx(Jp,{summary:R}):r.jsxs("span",{className:G("font-mono text-xs",Xp),children:["Thinking",p>1?` ×${p}`:""]})]}),t[13]=o,t[14]=S,t[15]=R,t[16]=p,t[17]=K):K=t[17];const V=c?(()=>{const q=Gp(c,k);return r.jsxs(r.Fragment,{children:[q.hidden>0&&r.jsx(Zp,{count:q.hidden,onReveal:()=>x(!0)}),(()=>{const J=[];let Q=0;for(;Q<q.visible.length;){const X=q.visible[Q];if(X.kind==="thinking"){J.push(r.jsx(qE,{blocks:X.blocks,expandAll:!1},`thinking-${Q}`)),Q++;continue}const Z=[...X.toolCalls];let te=Q+1;for(;te<q.visible.length&&q.visible[te].kind==="tool_calls";){const ne=q.visible[te];ne.kind==="tool_calls"&&Z.push(...ne.toolCalls),te++}J.push(...O(Z,te===q.visible.length)),Q=te}return J})()]})})():(()=>{const q=Gp(s,k);return r.jsxs(r.Fragment,{children:[q.hidden>0&&r.jsx(Zp,{count:q.hidden,onReveal:()=>x(!0)}),O(q.visible,!0)]})})();let Y;return t[18]!==K||t[19]!==V?(Y=r.jsxs("div",{className:"motion-enter flex flex-col gap-2",children:[K,V]}),t[18]=K,t[19]=V,t[20]=Y):Y=t[20],Y}let M;t[21]===Symbol.for("react.memo_cache_sentinel")?(M=()=>x(!0),t[21]=M):M=t[21];let F;t[22]===Symbol.for("react.memo_cache_sentinel")?(F=r.jsx(Xe,{className:"mt-0.5 size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),t[22]=F):F=t[22];let z;t[23]!==R?(z=R.clauses.length>0&&r.jsx(Jp,{summary:R}),t[23]=R,t[24]=z):z=t[24];let L;t[25]!==p?(L=p>0&&r.jsxs("span",{className:G("font-mono text-xs",Xp),children:["Thinking",p>1?` ×${p}`:""]}),t[25]=p,t[26]=L):L=t[26];let W;t[27]!==$?(W=$.map(g9),t[27]=$,t[28]=W):W=t[28];let U;t[29]!==L||t[30]!==W?(U=r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[L,W]}),t[29]=L,t[30]=W,t[31]=U):U=t[31];let H;return t[32]!==z||t[33]!==U?(H=r.jsxs(ee,{type:"button",variant:"ghost",onClick:M,className:"motion-enter h-auto w-full items-start justify-start gap-2 px-0 py-1 text-left whitespace-normal",children:[F,r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[z,U]})]}),t[32]=z,t[33]=U,t[34]=H):H=t[34],H});function Zp(n){const e=B.c(6),{count:t,onReveal:s}=n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(it,{"data-icon":"inline-start"}),e[0]=o):o=e[0];let i;e[1]!==t?(i=HE(t),e[1]=t,e[2]=i):i=e[2];let a;return e[3]!==s||e[4]!==i?(a=r.jsxs(ee,{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 f9(n){return n.result===null}function m9(n){return n.name==="AskUserQuestion"}function p9(n,e){return e[1].count-n[1].count}function h9(n){return n.result===null}function g9(n){const[e,t]=n,{count:s,styleName:o,hasError:i}=t;return r.jsxs("span",{className:G("font-mono text-xs",P2(o,i)),children:[e,s>1?` ×${s}`:""]},e)}function x9(n){const e=B.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 u;e[2]!==d?(u=G("size-3 shrink-0 transition-transform duration-150 motion-reduce:transition-none",d),e[2]=d,e[3]=u):u=e[3];let f;e[4]!==u?(f=r.jsx(Xe,{"data-icon":"inline-start",className:u}),e[4]=u,e[5]=f):f=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]!==f||e[13]!==m?(h=r.jsxs(ee,{type:"button",variant:"ghost",onClick:o,"aria-expanded":s,className:c,children:[f,m,p]}),e[9]=s,e[10]=o,e[11]=c,e[12]=f,e[13]=m,e[14]=h):h=e[14],h}const R2="synthesizedFrom",eh=/[.*+?[\]{}()^$|]/,b9=/[$*?`~]|\\\s/,I2=/<<(-?)\s*(?:'([^']+)'|"([^"]+)")/,v9=new RegExp(I2,"g");function Iu(n,e,t,s){return{id:e,name:t,input:{...s,[R2]:n.name},result:null,isError:!1,timestamp:n.timestamp}}function y9(n){return typeof n.input[R2]=="string"}function w9(n){const e=n[0];return(e==='"'||e==="'")&&n.at(-1)===e?n.slice(1,-1):n}function th(n){const e=[];for(const t of n.split("/"))!t||t==="."||(t===".."?e.pop():e.push(t));return`/${e.join("/")}`}function rl(n,e){const t=w9(n.trim());return!t||b9.test(t)?null:t.startsWith("/")?th(t):e?th(`${e}/${t}`):null}function j9(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 S9(n){const e=n.split(`
|
|
116
|
+
`),t=[];let s=0;for(;s<e.length;){const o=e[s];s++;const i=new Map;for(const a of o.matchAll(v9)){const[,l,c,d]=a,u=c??d,f=[];for(;s<e.length&&e[s].trim()!==u;)f.push(l?e[s].replace(/^\t+/,""):e[s]),s++;s>=e.length||(s++,i.set(u,f.join(`
|
|
117
|
+
`)))}for(const a of j9(o))t.push({text:a.text,bodies:i,piped:a.piped})}return t}function N9(n,e){const t=n.match(/^cd\s+(?:"([^"]*)"|'([^']*)'|([^\s;&|]+))\s*$/);return t?rl(t[1]??t[2]??t[3]??"",e):null}function k9(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 C9(n,e){if(n.piped||n.bodies.size===0)return null;const t=n.text.match(I2);if(!t)return null;const s=n.bodies.get(t[2]??t[3]??"");if(s===void 0)return null;const o=k9(n.text);if(!o)return null;const i=rl(o,e);return i?{name:"Write",input:{file_path:i,content:s}}:null}function nh(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==="|"||!eh.test(a)&&!"\\/&#".includes(a))return null;s+=a,o++;continue}if(i==="&"&&t||!t&&eh.test(i))return null;s+=i}return s}const _9=/^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 T9(n,e){var m;const t=(m=n.text.match(_9))==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=nh(s,"pattern"),u=nh(o,"replacement");if(!d||u===null)return null;const f=rl(a??l??c??"",e);return f?{name:"Edit",input:{file_path:f,old_string:d,new_string:u,replace_all:i.includes("g")}}:null}function M2(n,e=null){const t=n.input.command;if(typeof t!="string"||!t)return[];const s=[];let o=e;for(const i of S9(t)){const a=N9(i.text,o);if(a){o=a;continue}const l=C9(i,o)??T9(i,o);l&&s.push(Iu(n,`${n.id}:bash-${s.length}`,l.name,l.input))}return s}function O2(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=rl(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:u}=l;typeof c!="string"||typeof d!="string"||i.push(Iu(n,`${n.id}:edit-${a}`,"Edit",{file_path:o,old_string:c,new_string:d,replace_all:u===!0}))}return i}function D2(n,e){const t=[n.input.patch,n.input.value,n.input.input].find(s=>typeof s=="string");return t?s0("apply_patch",t,n.id,n.timestamp,e??"").map(s=>Iu(n,s.id,s.name,s.input)):[]}function dr(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(...O2(s,e)):s.name==="Bash"?t.push(...M2(s,e)):s.name==="apply_patch"&&t.push(...D2(s,e)));return t}function pa(n,e=null){for(const t of n)if(!t.isError&&(t.name==="Edit"||t.name==="Write"||t.name==="MultiEdit"&&O2(t,e).length>0||t.name==="Bash"&&M2(t,e).length>0||t.name==="apply_patch"&&D2(t,e).length>0))return!0;return!1}const E9=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"]),A9={json:um,jsonc:um,md:qi,mdx:qi,txt:qi,png:Is,jpg:Is,jpeg:Is,gif:Is,webp:Is,svg:Is,ico:Is,sh:Ni,bash:Ni,zsh:Ni,fish:Ni};function L2(n){const e=n.split("/").at(-1)??n,t=e.lastIndexOf(".");return t===-1?"":e.slice(t+1).toLowerCase()}function P9(n){const e=L2(n);return A9[e]??(E9.has(e)?zr:_1)}function ed(n){const e=B.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 u;return e[7]!==l||e[8]!==c||e[9]!==d?(u=r.jsxs("span",{className:l,children:[c,d]}),e[7]=l,e[8]=c,e[9]=d,e[10]=u):u=e[10],u}const sh=5;function Mu(n){const e=B.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 u=Math.round(t/o*sh);i=sh-u,a="flex items-center gap-[1px] shrink-0 ml-1",l=Array.from({length:u},R9),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},$9),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 $9(n,e){return r.jsx("span",{className:"inline-block size-1.5 rounded-xs bg-destructive/70"},`d${e}`)}function R9(n,e){return r.jsx("span",{className:"inline-block size-1.5 rounded-xs bg-success/70"},`a${e}`)}const ha="cogpit:open-subagent";function z2(n){const e=B.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 Ou(n){const e=B.c(2),{agentId:t}=n;let s;return e[0]!==t?(s=r.jsx(ee,{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(ha,{detail:{agentId:t}}))},children:"S"}),e[0]=t,e[1]=s):s=e[1],s}const F2=y.memo(function(e){const t=B.c(96),{file:s,defaultOpen:o,isHighlighted:i,diffMode:a}=e,{ref:l,isNear:c}=Y0(),[d,u]=y.useState(o),[f,m]=y.useState(o),p=y.useRef(o);let h;t[0]===Symbol.for("react.memo_cache_sentinel")?(h=Te=>{u(Te),Te?y.startTransition(()=>m(!0)):m(!1)},t[0]=h):h=t[0];const g=h;let x,b;t[1]!==o?(x=()=>{p.current!==o&&(p.current=o,g(o))},b=[o,g],t[1]=o,t[2]=x,t[3]=b):(x=t[2],b=t[3]),y.useEffect(x,b);let w,v;t[4]!==i?(w=()=>{i&&g(!0)},v=[i,g],t[4]=i,t[5]=w,t[6]=v):(w=t[5],v=t[6]),y.useEffect(w,v);let S;t[7]!==s.filePath?(S=L2(s.filePath),t[7]=s.filePath,t[8]=S):S=t[8];const j=S,k=s.netOriginal,C=s.netCurrent,N=!!(k||C);let _;t[9]!==s.edits?(_=s.edits.some(D9),t[9]=s.edits,t[10]=_):_=t[10];const P=a==="per-edit"?_:N,T=f&&c&&P,[E,$]=y.useState(0);let I;t[11]===Symbol.for("react.memo_cache_sentinel")?(I=Te=>{if(!Te)return;const Ee=Te.offsetHeight;$($e=>$e===Ee?$e:Ee)},t[11]=I):I=t[11];const R=I,D=s.turnRange[0]===s.turnRange[1]?`T${s.turnRange[0]+1}`:`T${s.turnRange[0]+1}–T${s.turnRange[1]+1}`,O=s.filePath,M=i?"border-ring ring-2 ring-ring/20":"border-border";let F;t[12]!==M?(F=G("rounded-lg border bg-card transition-colors",M),t[12]=M,t[13]=F):F=t[13];let z;t[14]!==d?(z=()=>g(!d),t[14]=d,t[15]=z):z=t[15];let L;t[16]!==d?(L=d?r.jsx(it,{"data-icon":"inline-start",className:"size-3 shrink-0 text-muted-foreground"}):r.jsx(Xe,{"data-icon":"inline-start",className:"size-3 shrink-0 text-muted-foreground"}),t[16]=d,t[17]=L):L=t[17];let W;t[18]!==j?(W=r.jsx("span",{className:"shrink-0 font-mono text-xs font-bold text-muted-foreground",children:j}),t[18]=j,t[19]=W):W=t[19];let U;t[20]!==s.opTypes?(U=s.opTypes.includes("Edit"),t[20]=s.opTypes,t[21]=U):U=t[21];let H;t[22]!==s.opTypes?(H=s.opTypes.includes("Write"),t[22]=s.opTypes,t[23]=H):H=t[23];let K;t[24]!==U||t[25]!==H?(K=r.jsx(z2,{hasEdit:U,hasWrite:H}),t[24]=U,t[25]=H,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]!==D?(Y=r.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:D}),t[29]=D,t[30]=Y):Y=t[30];let q;t[31]!==s.editCount?(q=s.editCount>1&&r.jsxs(Pe,{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]!==L||t[36]!==W||t[37]!==K||t[38]!==V||t[39]!==Y||t[40]!==q?(J=r.jsxs(ee,{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:[L,W,K,V,Y,q]}),t[33]=d,t[34]=z,t[35]=L,t[36]=W,t[37]=K,t[38]=V,t[39]=Y,t[40]=q,t[41]=J):J=t[41];let Q;t[42]!==s.subAgentId?(Q=s.subAgentId&&r.jsx(Ou,{agentId:s.subAgentId}),t[42]=s.subAgentId,t[43]=Q):Q=t[43];let X;t[44]!==s.filePath?(X=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>yr(s.filePath),"aria-label":"Open file in editor"}),t[44]=s.filePath,t[45]=X):X=t[45];let Z;t[46]===Symbol.for("react.memo_cache_sentinel")?(Z=r.jsx(Ca,{"data-icon":"inline-start"}),t[46]=Z):Z=t[46];let te;t[47]!==X?(te=r.jsx(Mt,{render:X,children:Z}),t[47]=X,t[48]=te):te=t[48];let ne;t[49]===Symbol.for("react.memo_cache_sentinel")?(ne=r.jsx(Ot,{children:"Open in editor"}),t[49]=ne):ne=t[49];let oe;t[50]!==te?(oe=r.jsxs(It,{children:[te,ne]}),t[50]=te,t[51]=oe):oe=t[51];let re;t[52]!==s.filePath?(re=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>yr(s.filePath,{mode:"diff"}),"aria-label":"View git diff"}),t[52]=s.filePath,t[53]=re):re=t[53];let ae;t[54]===Symbol.for("react.memo_cache_sentinel")?(ae=r.jsx(X3,{"data-icon":"inline-start"}),t[54]=ae):ae=t[54];let se;t[55]!==re?(se=r.jsx(Mt,{render:re,children:ae}),t[55]=re,t[56]=se):se=t[56];let de;t[57]===Symbol.for("react.memo_cache_sentinel")?(de=r.jsx(Ot,{children:"View git diff"}),t[57]=de):de=t[57];let le;t[58]!==se?(le=r.jsxs(It,{children:[se,de]}),t[58]=se,t[59]=le):le=t[59];let ce;t[60]!==oe||t[61]!==le?(ce=r.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[oe,le]}),t[60]=oe,t[61]=le,t[62]=ce):ce=t[62];let me;t[63]!==s.addCount?(me=s.addCount>0&&r.jsxs("span",{className:"font-mono text-xs tabular-nums text-success",children:["+",s.addCount]}),t[63]=s.addCount,t[64]=me):me=t[64];let ue;t[65]!==s.delCount?(ue=s.delCount>0&&r.jsxs("span",{className:"font-mono text-xs tabular-nums text-destructive",children:["-",s.delCount]}),t[65]=s.delCount,t[66]=ue):ue=t[66];let ie;t[67]!==s.addCount||t[68]!==s.delCount?(ie=r.jsx(Mu,{add:s.addCount,del:s.delCount}),t[67]=s.addCount,t[68]=s.delCount,t[69]=ie):ie=t[69];let ge;t[70]!==Q||t[71]!==ce||t[72]!==me||t[73]!==ue||t[74]!==ie?(ge=r.jsxs("div",{className:"flex items-center gap-1.5 pr-2 shrink-0",children:[Q,ce,me,ue,ie]}),t[70]=Q,t[71]=ce,t[72]=me,t[73]=ue,t[74]=ie,t[75]=ge):ge=t[75];let pe;t[76]!==J||t[77]!==ge?(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,ge]}),t[76]=J,t[77]=ge,t[78]=pe):pe=t[78];let xe;t[79]!==a||t[80]!==s.edits||t[81]!==s.filePath||t[82]!==s.netStartLine||t[83]!==P||t[84]!==E||t[85]!==C||t[86]!==k||t[87]!==d||t[88]!==T?(xe=r.jsx(I9,{showDiff:T,open:d,hasDiff:P,diffRef:R,lastDiffHeight:E,oldString:k,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]=P,t[84]=E,t[85]=C,t[86]=k,t[87]=d,t[88]=T,t[89]=xe):xe=t[89];let Ce;return t[90]!==s.filePath||t[91]!==l||t[92]!==F||t[93]!==pe||t[94]!==xe?(Ce=r.jsxs("div",{ref:l,"data-file-path":O,className:F,children:[pe,xe]}),t[90]=s.filePath,t[91]=l,t[92]=F,t[93]=pe,t[94]=xe,t[95]=Ce):Ce=t[95],Ce}),I9=y.memo(function(e){const t=B.c(15),{showDiff:s,open:o,hasDiff:i,diffRef:a,lastDiffHeight:l,oldString:c,newString:d,filePath:u,diffMode:f,edits:m,netStartLine:p}=e;if(s){let h;t[0]!==f||t[1]!==m||t[2]!==u||t[3]!==p||t[4]!==d||t[5]!==c?(h=f==="per-edit"?r.jsx(O9,{edits:m,filePath:u}):r.jsx(Eu,{oldString:c,newString:d,filePath:u,compact:!1,startLine:p,hideHeader:!0}),t[0]=f,t[1]=m,t[2]=u,t[3]=p,t[4]=d,t[5]=c,t[6]=h):h=t[6];let g;return t[7]!==f||t[8]!==a||t[9]!==h?(g=r.jsx("div",{ref:a,className:"motion-enter overflow-hidden rounded-b",children:h},f),t[7]=f,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=f==="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}),oh=3,M9=5,O9=y.memo(function(e){const t=B.c(9),{edits:s,filePath:o}=e,i=s.length,a=s.filter(L9),l=a.length>oh,[c,d]=y.useState(l?oh:a.length);y.useEffect(()=>{if(c>=a.length)return;const x=requestAnimationFrame(()=>{d(b=>Math.min(b+M9,a.length))});return()=>cancelAnimationFrame(x)},[c,a.length]);const u=l?a.slice(0,c):a,f="divide-y divide-border/30";let m;t[0]!==o||t[1]!==i?(m=(x,b)=>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," ",b+1,"/",i]}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["T",x.turnIndex+1]}),x.agentId&&r.jsx(Ou,{agentId:x.agentId})]}),r.jsx(Eu,{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=u.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:f,children:[p,h]}),t[6]=p,t[7]=h,t[8]=g):g=t[8],g});function D9(n){return!!(n.oldString||n.newString)}function L9(n){return!!(n.oldString||n.newString)}const Zl=new Map;function z9(n){var S;const e=An("hostFiles"),{sessionSource:t}=at(),s=t==null?void 0:t.dirName,o=$t(s)==="codex",i=n.turns.length,a=((S=n.turns.at(-1))==null?void 0:S.toolCalls.length)??0,l=y.useMemo(()=>{let j=0;for(const k of n.turns){j+=k.toolCalls.length;for(const C of k.subAgentActivity)j+=C.toolCalls.length}return j},[i,a]),c=y.useMemo(()=>{const j=[];for(let k=0;k<n.turns.length;k++)for(const C of n.turns[k].subAgentActivity){const N=o&&(C.status==="completed"||C.status==="failed"||C.status==="interrupted");(C.isBackground||N)&&C.toolCalls.length===0&&j.push({agentId:C.agentId,turnIndex:k})}return j},[n.turns,l,o]),[d,u]=y.useState(new Map),f=y.useRef(new Set);y.useEffect(()=>{if(!s||!n.sessionId||c.length===0)return;const j=[];for(const{agentId:N}of c){const _=Vt(`${s}/${n.sessionId}/${N}`);if(!f.current.has(_)){if(Zl.has(_)){u(A=>{const P=new Map(A);return P.set(N,Zl.get(_)),P}),f.current.add(_);continue}j.push({agentId:N,cacheKey:_})}}if(j.length===0)return;let k=!1;async function C(){const N=new Map;await Promise.all(j.map(async({agentId:_,cacheKey:A})=>{try{const P=`/api/sessions/${encodeURIComponent(s)}/${encodeURIComponent(n.sessionId)}/subagents/agent-${encodeURIComponent(_)}.jsonl`,T=await be(P);if(!T.ok)return;const E=await T.text(),I=d2(E,_).flatMap(R=>dr(R.toolCalls,n.cwd));Zl.set(A,I),f.current.add(A),N.set(_,I)}catch{}})),!k&&N.size>0&&u(_=>{const A=new Map(_);for(const[P,T]of N)A.set(P,T);return A})}return C(),()=>{k=!0}},[s,n.sessionId,n.cwd,c]);const m=y.useMemo(()=>{const j=[],k=new Set;for(let C=0;C<n.turns.length;C++){const N=n.turns[C];for(const _ of dr(N.toolCalls,n.cwd))j.push({turnIndex:C,toolCall:_});for(const _ of N.subAgentActivity){for(const A of dr(_.toolCalls,n.cwd))j.push({turnIndex:C,toolCall:A,agentId:_.agentId});if((_.isBackground||o)&&_.toolCalls.length===0&&!k.has(_.agentId)){k.add(_.agentId);const A=d.get(_.agentId);if(A)for(const P of A)j.push({turnIndex:C,toolCall:P,agentId:_.agentId})}}}return j},[l,n.turns,d,o]),p=y.useMemo(()=>{const j=new Set;for(const k of m){const C=B2(k.toolCall);C&&j.add(C)}return[...j]},[m]),[h,g]=y.useState(new Map);y.useEffect(()=>{if(!e||p.length===0){g(new Map);return}let j=!1;return Promise.all(p.map(k=>be(`/api/file-content?path=${encodeURIComponent(k)}`).then(C=>C.ok?C.text():null).then(C=>C?[k,C]:null).catch(()=>null))).then(k=>{if(j)return;const C=new Map;for(const N of k)N&&C.set(N[0],N[1]);g(C)}),()=>{j=!0}},[e,p]);const x=n.turns.length-1,b=y.useMemo(()=>ga(m,"all",h),[m,h]),w=y.useMemo(()=>ga(m,x,h),[m,x,h]),v=y.useMemo(()=>{const j=new Map;for(const k of n.turns)for(const C of k.subAgentActivity)j.has(C.agentId)||j.set(C.agentId,{name:C.agentName,type:C.subagentType});return j},[n.turns]);return{fileChanges:m,fileContents:h,groupedByFile:b,groupedLastTurn:w,lastTurnIndex:x,agentMap:v}}function rh(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]===`
|
|
118
|
+
`&&s++;return s}function B2(n){return String(n.input.file_path??n.input.path??"")}function F9(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 ga(n,e,t){const s=new Map;for(const i of n){if(e!=="all"&&i.turnIndex!==e)continue;const a=B2(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,u=-1/0,f=!1,m=!1,p;const h=t==null?void 0:t.get(i);for(let b=0;b<a.length;b++){const w=a[b],v=F9(w.toolCall);l.push(v),w.turnIndex<d&&(d=w.turnIndex),w.turnIndex>u&&(u=w.turnIndex),w.toolCall.name==="Edit"?f=!0:m=!0,w.agentId&&(p=w.agentId),c.push({id:w.toolCall.id,oldString:v.oldString,newString:v.newString,toolName:w.toolCall.name,turnIndex:w.turnIndex,agentId:w.agentId,startLine:w.toolCall.name==="Write"?1:rh(h,v.newString||v.oldString)})}const g=VE(l),x=[];f&&x.push("Edit"),m&&x.push("Write"),o.push({filePath:i,shortPath:i.split("/").slice(-3).join("/"),editCount:a.length,turnRange:[d,u],opTypes:x,netOriginal:g.originalStr,netCurrent:g.currentStr,addCount:g.addCount,delCount:g.delCount,subAgentId:p??null,edits:c,netStartLine:g.currentStr?rh(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 B9(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=ga(l,"all",s);if(c.length===0)continue;let d=0,u=0;for(const m of c)d+=m.addCount,u+=m.delCount;const f=t.get(a);i.push({agentId:a,agentName:(f==null?void 0:f.name)??null,subagentType:(f==null?void 0:f.type)??null,files:c,totalAdd:d,totalDel:u})}return i.sort((a,l)=>{var u,f;const c=((u=a.files[0])==null?void 0:u.turnRange[0])??0,d=((f=l.files[0])==null?void 0:f.turnRange[0])??0;return c-d}),i}const Er="cogpit:focus-file",U9="cogpit:file-changes-prefs",W9={expanded:!0,diffMode:"net",scope:"last",groupByAgent:!1};function H9(n){const e=B.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 u;e[3]!==t.agentId?(u=()=>{window.dispatchEvent(new CustomEvent(ha,{detail:{agentId:t.agentId}}))},e[3]=t.agentId,e[4]=u):u=e[4];let f;e[5]!==l||e[6]!==d||e[7]!==u?(f=r.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"h-auto min-w-0 truncate px-1 text-xs font-semibold",title:d,onClick:u,children:l}),e[5]=l,e[6]=d,e[7]=u,e[8]=f):f=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(Pe,{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 b;e[18]!==f||e[19]!==m||e[20]!==p||e[21]!==g||e[22]!==x?(b=r.jsxs("div",{className:"flex items-center gap-2 px-1.5 pt-1.5 pb-0.5",children:[f,m,p,h,g,x]}),e[18]=f,e[19]=m,e[20]=p,e[21]=g,e[22]=x,e[23]=b):b=e[23];let w;if(e[24]!==s||e[25]!==i||e[26]!==t.files||e[27]!==o){let S;e[29]!==s||e[30]!==i||e[31]!==o?(S=j=>r.jsx(F2,{file:j,defaultOpen:s,isHighlighted:o===j.filePath,diffMode:i},j.filePath),e[29]=s,e[30]=i,e[31]=o,e[32]=S):S=e[32],w=t.files.map(S),e[24]=s,e[25]=i,e[26]=t.files,e[27]=o,e[28]=w}else w=e[28];let v;return e[33]!==b||e[34]!==w?(v=r.jsxs("div",{className:"flex flex-col gap-1",children:[b,w]}),e[33]=b,e[34]=w,e[35]=v):v=e[35],v}const q9=y.memo(function({session:e,sessionChangeKey:t}){const s=y.useRef(null),o=y.useRef(null),i=y.useRef(!0),a=y.useRef(!1),l=y.useRef(0),c=y.useRef(e.turns.length),[d,u]=y.useState(!1),[f,m]=y.useState(!1),[p,h]=oi(U9,{}),g={...W9,...p},x=g.expanded,b=g.diffMode,w=g.groupByAgent,[v,S]=y.useState(g.scope),j=y.useCallback(q=>{h(J=>({...J,expanded:q}))},[h]),k=y.useCallback(q=>{h(J=>({...J,diffMode:q}))},[h]),C=y.useCallback(q=>{h(J=>({...J,groupByAgent:q}))},[h]);y.useEffect(()=>{typeof v!="number"&&h(q=>({...q,scope:v}))},[v,h]);const[N,_]=y.useState(null),A=y.useRef(null),{fileChanges:P,fileContents:T,groupedByFile:E,groupedLastTurn:$,lastTurnIndex:I,agentMap:R}=z9(e),D=y.useMemo(()=>typeof v!="number"?null:ga(P,v,T),[P,v,T]);function O(){return typeof v=="number"?D??[]:v==="all"?E:$}const M=O(),F=y.useMemo(()=>w?B9(P,typeof v=="number"?v:v==="all"?"all":I,R,T):[],[w,P,v,I,R,T]);y.useEffect(()=>{const q=J=>{const Q=J.detail;Q!=null&&Q.filePath&&(S(Q.turnIndex),_(Q.filePath),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>_(null),3e3),requestAnimationFrame(()=>{var Z;const X=(Z=s.current)==null?void 0:Z.querySelector(`[data-file-path="${CSS.escape(Q.filePath)}"]`);X==null||X.scrollIntoView({behavior:"smooth",block:"nearest"})}))};return window.addEventListener(Er,q),()=>{window.removeEventListener(Er,q),A.current&&clearTimeout(A.current)}},[]);const z=y.useCallback(()=>{const q=s.current;q&&(u(q.scrollTop>10),m(q.scrollHeight-q.scrollTop-q.clientHeight>10))},[]),L=y.useCallback(()=>{const q=s.current;q&&(i.current=q.scrollHeight-q.scrollTop-q.clientHeight<50,z())},[z]);if(y.useEffect(()=>{z()},[P.length,M.length,z]),y.useEffect(()=>{const q=s.current;q&&(q.scrollTop=q.scrollHeight),i.current=!0,a.current=!1,l.current=P.length,c.current=e.turns.length,S(g.scope),_(null),z()},[t]),y.useEffect(()=>{const q=e.turns.length;q>c.current&&(a.current=!0),c.current=q},[e.turns.length]),y.useEffect(()=>{if(P.length<=l.current){l.current=P.length;return}l.current=P.length,(a.current||i.current)&&(requestAnimationFrame(()=>{var q;(q=o.current)==null||q.scrollIntoView({behavior:"smooth"})}),a.current=!1)},[P.length]),P.length===0)return null;let W=0,U=0,H=0;if(w)for(const q of F)W+=q.totalAdd,U+=q.totalDel,H+=q.files.length;else{for(const q of M)W+=q.addCount,U+=q.delCount;H=M.length}function K(){S(v==="last"?"all":"last")}function V(){return typeof v=="number"?`Turn ${v+1}`:v==="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(zr,{"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(Pe,{variant:"outline",className:"h-5 px-1.5 text-xs text-muted-foreground",children:[H," file",H!==1?"s":""]}),r.jsx("div",{className:"flex-1"}),r.jsxs("span",{className:"font-mono text-xs tabular-nums text-success",children:["+",W]}),r.jsxs("span",{className:"font-mono text-xs tabular-nums text-destructive",children:["-",U]}),r.jsxs(It,{children:[r.jsx(Mt,{render:r.jsx(ee,{variant:w?"secondary":"ghost",size:"icon-xs",onClick:()=>C(!w),"aria-label":w?"Show all changes":"Group by subagent"}),children:r.jsx(ss,{"data-icon":"inline-start"})}),r.jsx(Ot,{children:w?"Show all changes":"Group by subagent"})]}),r.jsxs(It,{children:[r.jsx(Mt,{render:r.jsx(ee,{variant:v==="all"?"secondary":"ghost",size:"icon-xs",onClick:K,"aria-label":v==="last"?"Show all turns":"Show last turn only"}),children:v==="all"?r.jsx(J3,{"data-icon":"inline-start"}):r.jsx(Us,{"data-icon":"inline-start"})}),r.jsx(Ot,{children:v==="last"?"Click for all turns":"Click for last turn only"})]}),r.jsxs(It,{children:[r.jsx(Mt,{render:r.jsx(ee,{variant:b==="per-edit"?"secondary":"ghost",size:"icon-xs",onClick:()=>k(b==="net"?"per-edit":"net"),"aria-label":b==="net"?"Show per-edit diffs":"Show net diff"}),children:b==="net"?r.jsx(Q3,{"data-icon":"inline-start"}):r.jsx(Z3,{"data-icon":"inline-start"})}),r.jsx(Ot,{children:b==="net"?"Switch to per-edit diffs":"Switch to net diff"})]}),r.jsxs(It,{children:[r.jsx(Mt,{render:r.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:()=>j(!x),"aria-label":x?"Collapse all":"Expand all"}),children:x?r.jsx(Ra,{"data-icon":"inline-start"}):r.jsx($a,{"data-icon":"inline-start"})}),r.jsx(Ot,{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:"}),v!=="all"&&I>0&&r.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:()=>{const q=typeof v=="number"?v:I;q>0&&S(q-1)},disabled:(typeof v=="number"?v:I)<=0,"aria-label":"Previous turn",children:r.jsx(Nd,{"data-icon":"inline-start"})}),r.jsx("span",{className:G("text-xs font-medium",typeof v=="number"?"text-foreground":"text-muted-foreground"),children:Y}),v!=="all"&&I>0&&r.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:()=>{S(q=>typeof q!="number"?q:q+1>=I?"last":q+1)},disabled:v==="last","aria-label":"Next turn",children:r.jsx(Xe,{"data-icon":"inline-start"})}),typeof v=="number"&&r.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:()=>S("last"),"aria-label":"Back to last turn",children:r.jsx(nt,{"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:L,className:"h-full overflow-y-auto",children:[r.jsx("div",{className:"flex flex-col gap-1 p-1.5",children:w?F.length>0?F.map(q=>r.jsx(H9,{group:q,allExpanded:x,highlightPath:N,diffMode:b},q.agentId)):r.jsxs("div",{className:"py-4 text-center text-xs text-muted-foreground",children:["No subagent changes in ",Y.toLowerCase()]}):M.length>0?M.map(q=>r.jsx(F2,{file:q,defaultOpen:x,isHighlighted:N===q.filePath,diffMode:b},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",f?"opacity-100":"opacity-0")})]})]})});function K9(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??""),u=Tr(c,d),f=t.get(a)??{add:0,del:0,hasEdit:!1,hasWrite:!1,subAgentId:null};f.add+=u.add,f.del+=u.del,l?f.hasEdit=!0:f.hasWrite=!0,i&&(f.subAgentId=i),t.set(a,f)}return dr(n.toolCalls,e).forEach(o=>s(o)),n.subAgentActivity.forEach(o=>dr(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 ih(){return{children:new Map,isFile:!1,absPath:"",additions:0,deletions:0,hasEdit:!1,hasWrite:!1,subAgentId:null}}function V9(n,e){if(n.length===0)return[];const t=e.endsWith("/")?e.slice(0,-1):e,s=ih();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 u=c.children.get(l[d]);u||(u=ih(),c.children.set(l[d],u)),d===l.length-1&&(u.isFile=!0,u.absPath=i.filePath,u.additions+=i.additions,u.deletions+=i.deletions,i.hasEdit&&(u.hasEdit=!0),i.hasWrite&&(u.hasWrite=!0),i.subAgentId&&(u.subAgentId=i.subAgentId)),c=u}}function o(i,a){return[...i.children.entries()].sort(([c,d],[u,f])=>{const m=d.isFile&&d.children.size===0,p=f.isFile&&f.children.size===0;return m!==p?m?1:-1:c.localeCompare(u)}).map(([c,d])=>{const u=a?`${a}/${c}`:c;if(d.isFile&&d.children.size===0)return{name:c,fullPath:u,absPath:d.absPath,isFile:!0,additions:d.additions,deletions:d.deletions,hasEdit:d.hasEdit,hasWrite:d.hasWrite,subAgentId:d.subAgentId,children:[]};let f=d,m=c,p=u;for(;!f.isFile&&f.children.size===1;){const[S,j]=[...f.children.entries()][0];if(j.isFile&&j.children.size===0)break;m+="/"+S,p+="/"+S,f=j}const h=o(f,p);let g=0,x=0,b=f.isFile?f.hasEdit:!1,w=f.isFile?f.hasWrite:!1,v=f.isFile?f.subAgentId:null;for(const S of h)g+=S.additions,x+=S.deletions,S.hasEdit&&(b=!0),S.hasWrite&&(w=!0),S.subAgentId&&(v=S.subAgentId);return f.isFile&&(g+=f.additions,x+=f.deletions),{name:m,fullPath:p,absPath:f.absPath,isFile:!1,additions:g,deletions:x,hasEdit:b,hasWrite:w,subAgentId:v,children:h}})}return o(s,"")}const G9=y.memo(function(e){const t=B.c(45),{turn:s,turnIndex:o,cwd:i}=e,a=An("hostFiles");let l;t[0]!==i||t[1]!==s?(l=K9(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=V9(c,i),t[3]=i,t[4]=c,t[5]=d):d=t[5];const u=d,[f,m]=y.useState(!1);let p=0,h=0;if(t[6]!==p||t[7]!==h||t[8]!==c){for(const $ of c)p=p+$.additions,h=h+$.deletions;t[6]=p,t[7]=h,t[8]=c,t[9]=p,t[10]=h}else p=t[9],h=t[10];let g;t[11]!==p||t[12]!==h?(g={add:p,del:h},t[11]=p,t[12]=h,t[13]=g):g=t[13];const x=g;if(c.length===0)return null;const b=f&&"rotate-90";let w;t[14]!==b?(w=G("size-3 shrink-0 transition-transform duration-150 motion-reduce:transition-none",b),t[14]=b,t[15]=w):w=t[15];let v;t[16]!==w?(v=r.jsx(Xe,{"data-icon":"inline-start",className:w}),t[16]=w,t[17]=v):v=t[17];let S;t[18]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx(zr,{className:"size-3.5 shrink-0","data-icon":"inline-start"}),t[18]=S):S=t[18];const j=c.length!==1?"s":"";let k;t[19]!==c.length||t[20]!==j?(k=r.jsxs("span",{className:"font-medium tabular-nums",children:[c.length," file",j]}),t[19]=c.length,t[20]=j,t[21]=k):k=t[21];let C,N;t[22]!==x.add||t[23]!==x.del?(C=r.jsx(ed,{add:x.add,del:x.del,className:"opacity-80"}),N=r.jsx(Mu,{add:x.add,del:x.del}),t[22]=x.add,t[23]=x.del,t[24]=C,t[25]=N):(C=t[24],N=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 A;t[27]!==C||t[28]!==N||t[29]!==v||t[30]!==k?(A=r.jsxs(Rt,{className:"group/files flex min-h-7 w-full cursor-pointer items-center gap-1.5 rounded-md px-1 text-left text-xs text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[v,S,k,C,N,_]}),t[27]=C,t[28]=N,t[29]=v,t[30]=k,t[31]=A):A=t[31];let P;if(t[32]!==a||t[33]!==u||t[34]!==o){let $;t[36]!==a||t[37]!==o?($=I=>r.jsx(Y9,{node:I,depth:0,turnIndex:o,canFocusFiles:a},I.fullPath),t[36]=a,t[37]=o,t[38]=$):$=t[38],P=u.map($),t[32]=a,t[33]=u,t[34]=o,t[35]=P}else P=t[35];let T;t[39]!==P?(T=r.jsx(mt,{className:"ml-1 border-l border-border/40 pl-3",children:r.jsx("div",{className:"py-0.5",children:P})}),t[39]=P,t[40]=T):T=t[40];let E;return t[41]!==f||t[42]!==A||t[43]!==T?(E=r.jsxs(ft,{open:f,onOpenChange:m,children:[A,T]}),t[41]=f,t[42]=A,t[43]=T,t[44]=E):E=t[44],E}),Y9=y.memo(function n({node:e,depth:t,turnIndex:s,canFocusFiles:o}){const[i,a]=y.useState(!0),l=t*16+8;if(e.isFile){const c=P9(e.name),d=()=>{o&&e.absPath&&window.dispatchEvent(new CustomEvent(Er,{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(ee,{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(z2,{hasEdit:e.hasEdit,hasWrite:e.hasWrite}),r.jsx("span",{className:"truncate text-foreground/75",children:e.name})]}),e.subAgentId&&r.jsx(Ou,{agentId:e.subAgentId}),r.jsx(ed,{add:e.additions,del:e.deletions}),r.jsx(Mu,{add:e.additions,del:e.deletions})]})}return r.jsxs(r.Fragment,{children:[r.jsxs(ee,{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(it,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}):r.jsx(Xe,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}),r.jsx(ew,{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(ed,{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 X9(n){const e=B.c(14),{branchCount:t,onClick:s}=n;if(t===0)return null;let o;e[0]!==s?(o=r.jsx(ee,{variant:"ghost",size:"xs",onClick:f=>{f.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(_d,{"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(Mt,{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(Ot,{children:[t," branch",c," from this turn"]}),e[8]=t,e[9]=c,e[10]=d):d=e[10];let u;return e[11]!==l||e[12]!==d?(u=r.jsxs(It,{children:[l,d]}),e[11]=l,e[12]=d,e[13]=u):u=e[13],u}function il(n){const e=B.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(nw,{"data-slot":"context-menu",...t}),e[2]=t,e[3]=s):s=e[3],s}function al(n){const e=B.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(tw,{"data-slot":"context-menu-trigger",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function ll(n){const e=B.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,u=a===void 0?"right":a,f=l===void 0?0:l;let m;e[7]!==t?(m=G("z-50 max-h-(--available-height) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 ease-out outline-none data-[side=bottom]:slide-in-from-top-1 data-[side=inline-end]:slide-in-from-left-1 data-[side=inline-start]:slide-in-from-right-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",t),e[7]=t,e[8]=m):m=e[8];let p;e[9]!==s||e[10]!==m?(p=r.jsx(T1,{"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]!==u||e[15]!==f||e[16]!==p?(h=r.jsx(P1,{children:r.jsx($1,{className:"isolate z-50 outline-none",align:c,alignOffset:d,side:u,sideOffset:f,children:p})}),e[12]=c,e[13]=d,e[14]=u,e[15]=f,e[16]=p,e[17]=h):h=e[17],h}function jo(n){const e=B.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(E1,{"data-slot":"context-menu-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function jB(n){const e=B.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(R1,{"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 sn(n){const e=B.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(A1,{"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 Ar(n){const e=B.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(gd,{"data-slot":"context-menu-separator",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function J9(n){const e=B.c(22),{children:t,turnIndex:s,branches:o,onRestoreToHere:i,onOpenBranches:a,onBranchFromHere:l}=n;let c;e[0]!==t?(c=r.jsx(al,{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 u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(kd,{"data-icon":"inline-start"}),e[5]=u):u=e[5];let f;e[6]!==d?(f=r.jsx(jo,{children:r.jsxs(sn,{onClick:d,children:[u,"Restore to this point"]})}),e[6]=d,e[7]=f):f=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(Ar,{}),r.jsx(jo,{children:r.jsxs(sn,{onClick:()=>a(s),children:[r.jsx(_d,{"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(Ar,{}),r.jsx(jo,{children:r.jsxs(sn,{onClick:()=>l(s),children:[r.jsx(xn,{"data-icon":"inline-start"}),"Duplicate from here"]})})]}),e[12]=l,e[13]=s,e[14]=p):p=e[14];let h;e[15]!==f||e[16]!==m||e[17]!==p?(h=r.jsxs(ll,{className:"min-w-44",children:[f,m,p]}),e[15]=f,e[16]=m,e[17]=p,e[18]=h):h=e[18];let g;return e[19]!==c||e[20]!==h?(g=r.jsxs(il,{children:[c,h]}),e[19]=c,e[20]=h,e[21]=g):g=e[21],g}function U2(n){return w0(n).status(n)}const Q9=new Set(["Agent","TaskOutput","spawn_agent","wait_agent"]);function Du(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 ai(n,e,t,s){switch(n){case"thinking":return"Thinking...";case"tool_use":return e&&Q9.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?Du(t):"Done";default:return null}}function Z9(n){const e=B.c(6),{status:t}=n;switch(t){case"thinking":{let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(ow,{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(Gs,{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(sw,{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(Ra,{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(No,{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(Wn,{className:"size-5 text-success"}),e[5]=s):s=e[5],s}default:return null}}const ah=2e3,W2=600;function H2(n){const e=B.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,u=a?"opacity-0":"opacity-100";let f;e[2]!==u?(f=G("flex items-center gap-2.5 min-w-0 transition-opacity",u),e[2]=u,e[3]=f):f=e[3];let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m={transitionDuration:`${W2}ms`},e[4]=m):m=e[4];let p;e[5]!==t.status?(p=r.jsx(Z9,{status:t.status}),e[5]=t.status,e[6]=p):p=e[6];const h=!l&&"text-muted-foreground",g=l&&t.terminalReason&&"text-warning",x=l&&!t.terminalReason&&"text-success";let b;e[7]!==h||e[8]!==g||e[9]!==x?(b=G("text-xs font-medium shrink-0",h,g,x),e[7]=h,e[8]=g,e[9]=x,e[10]=b):b=e[10];let w;e[11]!==s||e[12]!==b?(w=r.jsx("span",{className:b,children:s}),e[11]=s,e[12]=b,e[13]=w):w=e[13];let v;e[14]!==l||e[15]!==i?(v=!l&&i&&r.jsx(Lu,{startTimestamp:i}),e[14]=l,e[15]=i,e[16]=v):v=e[16];let S;e[17]!==d?(S=d.length>0&&r.jsx("span",{className:"truncate text-xs text-muted-foreground",title:d.join(`
|
|
119
|
+
`),children:d.join(" · ")}),e[17]=d,e[18]=S):S=e[18];let j;e[19]!==t.pendingQueue?(j=(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]=j):j=e[20];let k;return e[21]!==w||e[22]!==v||e[23]!==S||e[24]!==j||e[25]!==f||e[26]!==p?(k=r.jsxs("div",{className:f,style:m,children:[p,w,v,S,j]}),e[21]=w,e[22]=v,e[23]=S,e[24]=j,e[25]=f,e[26]=p,e[27]=k):k=e[27],k}function eA(n){const e=B.c(28),{status:t,durationLabel:s}=n,[o,i]=y.useState("visible");let a,l;if(e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const h=setTimeout(()=>i("fading"),ah),g=setTimeout(()=>i("ready"),ah+W2);return()=>{clearTimeout(h),clearTimeout(g)}},l=[],e[0]=a,e[1]=l):(a=e[0],l=e[1]),y.useEffect(a,l),o==="ready"){let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(Wn,{className:"size-4 shrink-0 text-success"}),e[2]=h):h=e[2];const g=t.terminalReason?"text-warning":"text-muted-foreground";let x;e[3]!==g?(x=G("text-xs font-medium",g),e[3]=g,e[4]=x):x=e[4];let b;e[5]!==t.terminalReason?(b=t.terminalReason?Du(t.terminalReason):"Waiting for your input",e[5]=t.terminalReason,e[6]=b):b=e[6];let w;e[7]!==x||e[8]!==b?(w=r.jsx("span",{className:x,children:b}),e[7]=x,e[8]=b,e[9]=w):w=e[9];let v;e[10]!==s?(v=s&&r.jsx("span",{className:"font-mono text-xs tabular-nums text-muted-foreground",children:s}),e[10]=s,e[11]=v):v=e[11];let S;return e[12]!==w||e[13]!==v?(S=r.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4","data-agent-ready":!0,children:[h,w,v]}),e[12]=w,e[13]=v,e[14]=S):S=e[14],S}let c;e[15]!==t.status||e[16]!==t.terminalReason||e[17]!==t.toolName?(c=ai(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,u=o==="fading";let f;e[19]!==d||e[20]!==t||e[21]!==u?(f=r.jsx(H2,{status:t,label:d,fading:u}),e[19]=d,e[20]=t,e[21]=u,e[22]=f):f=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]!==f||e[26]!==m?(p=r.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4",children:[f,m]}),e[25]=f,e[26]=m,e[27]=p):p=e[27],p}const tA=y.memo(function(){const e=B.c(25),{session:t,isLive:s,sseState:o,isCompacting:i,pendingInteraction:a}=at(),[l,c]=y.useState(!1),[d,u]=y.useState(!1),f=t==null?void 0:t.sessionId,[m,p]=y.useState(f);f!==m&&(p(f),c(!1),u(!1));let h;e:{if(!t||o!=="connected"){h=null;break e}if(i){let $;e[0]===Symbol.for("react.memo_cache_sentinel")?($={status:"compacting"},e[0]=$):$=e[0],h=$;break e}const T=t.rawMessages;let E;e[1]!==T?(E=U2(T),e[1]=T,e[2]=E):E=e[2],h=E}const g=h;let x,b;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"){u(!0);return}c(!1),u(!1)}},b=[g,s,d],e[3]=g,e[4]=s,e[5]=d,e[6]=x,e[7]=b):(x=e[6],b=e[7]),y.useEffect(x,b);let w;e:{if(!g){w=null;break e}if(g.status==="compacting"){w=g;break e}if(g.status==="completed"){if(l){w=null;break e}if(!s&&!d){w=null;break e}w=g;break e}if(!s||g.status==="idle"){w=null;break e}w=g}const v=w,S=(v==null?void 0:v.status)==="completed",j=(t==null?void 0:t.turns[t.turns.length-1])??null;let k;e:{if(!S||!j){k=null;break e}let T;if(e[8]!==j){const E=Bd(j);T=E!==null?Bn(E):null,e[8]=j,e[9]=T}else T=e[9];k=T}const C=k;if(a&&o==="connected"){let T;e[10]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx(D1,{className:"size-5 shrink-0 text-info"}),e[10]=T):T=e[10];const E=a.type==="plan"?"Waiting for plan approval":"Waiting for your answer";let $;return e[11]!==E?($=r.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4",children:[T,r.jsx("span",{className:"text-xs font-medium text-info",children:E})]}),e[11]=E,e[12]=$):$=e[12],$}if(!v)return null;if(S){let T;return e[13]!==v||e[14]!==C?(T=r.jsx(eA,{status:v,durationLabel:C}),e[13]=v,e[14]=C,e[15]=T):T=e[15],T}let N;e[16]!==v.pendingAgents||e[17]!==v.status||e[18]!==v.terminalReason||e[19]!==v.toolName?(N=ai(v.status,v.toolName,v.terminalReason,v.pendingAgents),e[16]=v.pendingAgents,e[17]=v.status,e[18]=v.terminalReason,e[19]=v.toolName,e[20]=N):N=e[20];const _=N;if(!_)return null;const A=j==null?void 0:j.timestamp;let P;return e[21]!==v||e[22]!==_||e[23]!==A?(P=r.jsx("div",{className:"flex items-center gap-2.5 py-3 px-4",children:r.jsx(H2,{status:v,label:_,startTimestamp:A})}),e[21]=v,e[22]=_,e[23]=A,e[24]=P):P=e[24],P});function Lu(n){const e=B.c(3),{startTimestamp:t,className:s}=n;let o;return e[0]!==s||e[1]!==t?(o=r.jsx(nA,{startTimestamp:t,className:s},t),e[0]=s,e[1]=t,e[2]=o):o=e[2],o}function nA(n){const e=B.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=y.useRef(null);let l,c;e[2]!==i?(l=()=>{const h=setInterval(()=>{const g=a.current;g&&(g.textContent=Bn(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]),y.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 u=Math.max(0,Date.now()-i);let f;e[7]!==u?(f=Bn(u),e[7]=u,e[8]=f):f=e[8];let m;return e[9]!==d||e[10]!==f?(m=r.jsx("span",{ref:a,className:d,children:f}),e[9]=d,e[10]=f,e[11]=m):m=e[11],m}function sA(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 oA=6e5;function rA(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,oA)}function lh(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+=rA(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 td=new Map,iA=300*1e3;function ch(n){const e=td.get(n);return e?Date.now()>e.expiresAt?(td.delete(n),null):e.data:null}function aA(n,e){td.set(n,{data:e,expiresAt:Date.now()+iA})}function lA(n){const e=B.c(5);let t;e[0]!==n?(t=()=>n?ch(Vt(n))??new Map:new Map,e[0]=n,e[1]=t):t=e[1];const[s,o]=y.useState(t),i=y.useRef("");let a,l;return e[2]!==n?(a=()=>{if(!n||qa(window.location.pathname))return;const c=Vt(n),d=ch(c);if(d){o(d);return}i.current=n;const u=new AbortController;return be(`/api/slash-suggestions?cwd=${encodeURIComponent(n)}`,{signal:u.signal}).then(async f=>{if(u.signal.aborted||i.current!==n||!f.ok)return;const m=await f.json();if(u.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});aA(c,p),o(p)}).catch(cA),()=>u.abort()},l=[n],e[2]=n,e[3]=a,e[4]=l):(a=e[3],l=e[4]),y.useEffect(a,l),s}function cA(){}const dA=new Set(["queued_prompt","agent_message","plan_mode","recap","task_notification"]),uA=new Set(["thinking","tool_calls","sub_agent","background_agent","hook_event"]),fA=new Set(["AskUserQuestion","ExitPlanMode"]),mA=new Set(["text","thinking","tool_calls"]);function pA(n){return n.kind==="tool_calls"&&n.toolCalls.some(e=>fA.has(e.name)&&e.result==null)}function hA(n){for(let e=n.length-1;e>=0;e--){if(pA(n[e]))return e;if(mA.has(n[e].kind))return-1}return-1}const Di={foldedIndices:[],foldAnchorIndex:-1,foldable:!1,hiddenToolCalls:0};function gA(n,e="settled"){if(n.length===0||!n.some(a=>uA.has(a.kind)))return Di;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 Di}const s=hA(n),o=[];let i=0;for(let a=0;a<n.length;a++){if(a===t||a===s)continue;const l=n[a];dA.has(l.kind)||(o.push(a),l.kind==="tool_calls"&&(i+=l.toolCalls.length))}return o.length===0?Di:{foldedIndices:o,foldAnchorIndex:o[0],foldable:!0,hiddenToolCalls:i}}function xA(n,e){return n!==null&&n>0?`Worked for ${Bn(n)}`:e>0?`Worked through ${e} step${e===1?"":"s"}`:"Show work"}const q2="border border-border bg-prompt-surface",dh="border-l border-border/40",uh="border-l border-border";function K2(n){const e=B.c(20),{turn:t,index:s,branchCount:o}=n,i=o===void 0?0:o,{state:a,isMobile:l}=Ht(),{activeTurnIndex:c,activeToolCallId:d,expandAll:u,expandToolPayloads:f}=a,{session:m,isLive:p,isSubAgentView:h,undoRedo:g,actions:x}=at(),b=p&&m!==null,w=b&&s===((m==null?void 0:m.turns.length)??0)-1;let v=!w;if(w&&m){let _;if(e[0]!==m.rawMessages){const{status:A}=U2(m.rawMessages);_=Su.has(A),e[0]=m.rawMessages,e[1]=_}else _=e[1];v=!_}const S=(m==null?void 0:m.cwd)??"",j=lA(S),k=c===s,C=!g.enabled||h?void 0:g.requestUndo;let N;return e[2]!==x.handleEditCommand||e[3]!==x.handleExpandCommand||e[4]!==x.handleOpenBranches||e[5]!==d||e[6]!==i||e[7]!==S||e[8]!==u||e[9]!==f||e[10]!==s||e[11]!==w||e[12]!==l||e[13]!==b||e[14]!==v||e[15]!==j||e[16]!==k||e[17]!==C||e[18]!==t?(N=r.jsx(yA,{turn:t,index:s,branchCount:i,isActive:k,activeToolCallId:d,expandAll:u,expandToolPayloads:f,isAgentActive:w,isSessionLive:b,isTurnDone:v,isMobile:l,cwd:S,skillMetadata:j,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]=S,e[8]=u,e[9]=f,e[10]=s,e[11]=w,e[12]=l,e[13]=b,e[14]=v,e[15]=j,e[16]=k,e[17]=C,e[18]=t,e[19]=N):N=e[19],N}function bA(n){const e=B.c(12),{index:t,children:s}=n,{session:o,isSubAgentView:i,undoRedo:a,actions:l}=at(),{requestUndo:c,branchesAtTurn:d}=a,{handleOpenBranches:u,handleBranchFromHere:f}=l,m=t>=((o==null?void 0:o.turns.length)??0);if(!a.enabled||i||m||!c||!u){let g;return e[0]!==s?(g=r.jsx(r.Fragment,{children:s}),e[0]=s,e[1]=g):g=e[1],g}let p;e[2]!==d||e[3]!==t?(p=d(t),e[2]=d,e[3]=t,e[4]=p):p=e[4];let h;return e[5]!==s||e[6]!==f||e[7]!==u||e[8]!==t||e[9]!==c||e[10]!==p?(h=r.jsx(J9,{turnIndex:t,branches:p,onRestoreToHere:c,onOpenBranches:u,onBranchFromHere:f,children:s}),e[5]=s,e[6]=f,e[7]=u,e[8]=t,e[9]=c,e[10]=p,e[11]=h):h=e[11],h}function vA(n){const e=B.c(5),{turn:t,isTurnDone:s,hiddenToolCalls:o}=n;if(s){let a;return e[0]!==o||e[1]!==t?(a=xA(Bd(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(Lu,{startTimestamp:t.timestamp,className:"text-xs text-inherit"})]}),e[3]=t.timestamp,e[4]=i):i=e[4],i}const yA=y.memo(function({turn:e,index:t,branchCount:s,isActive:o,activeToolCallId:i,expandAll:a,expandToolPayloads:l,isAgentActive:c,isSessionLive:d,isTurnDone:u,isMobile:f,cwd:m,skillMetadata:p,onRestoreToHere:h,onOpenBranches:g,onEditCommand:x,onExpandCommand:b}){const{ref:w,isNear:v}=Y0(),S=y.useRef(null),j=y.useRef(0);y.useLayoutEffect(()=>{v&&S.current&&(j.current=S.current.offsetHeight)},[v]);const k=pa(e.toolCalls,m)||e.subAgentActivity.some($=>pa($.toolCalls,m)),C=u?"settled":"working",N=y.useMemo(()=>gA(e.contentBlocks,C),[C,e.contentBlocks]),[_,A]=y.useState(void 0),P=_??(a||!u),{leadingBlocks:T,trailingBlocks:E}=y.useMemo(()=>{if(!N.foldable)return{leadingBlocks:[],trailingBlocks:[]};const $=N.foldAnchorIndex,I=new Set(N.foldedIndices);return{leadingBlocks:e.contentBlocks.slice(0,$),trailingBlocks:e.contentBlocks.slice($).filter((R,D)=>P||!I.has($+D))}},[N,e.contentBlocks,P]);return r.jsxs("div",{ref:w,"data-turn-index":t,className:G("group relative",f?"px-1 py-3":"px-4 py-5",o&&"rounded-lg ring-1 ring-ring/40"),children:[r.jsx(jA,{index:t,turn:e,branchCount:s,isTurnDone:u,isMobile:f,onRestoreToHere:h,onOpenBranches:g}),v?r.jsxs("div",{ref:S,className:G("flex flex-col",f?"gap-2":"gap-3"),children:[e.userMessage&&r.jsx(bA,{index:t,children:r.jsx("div",{"data-turn-prompt":!0,className:G(f?"rounded-lg p-2.5":"rounded-lg p-3",q2),children:r.jsx(vu,{content:e.userMessage,timestamp:e.timestamp,onEditCommand:x,onExpandCommand:b,compact:f})})}),N.foldable?r.jsxs(r.Fragment,{children:[T.length>0&&r.jsx(ec,{blocks:T,model:e.model,effort:e.effort,expandAll:a,expandToolPayloads:l,activeToolCallId:i,isAgentActive:c,isSessionLive:d,isMobile:f,skillMetadata:p}),r.jsx(x9,{label:r.jsx(vA,{turn:e,isTurnDone:u,hiddenToolCalls:N.hiddenToolCalls}),expanded:P,onToggle:()=>A(!P),compact:f}),E.length>0&&r.jsx(ec,{blocks:E,model:e.model,effort:e.effort,expandAll:a,expandToolPayloads:l,activeToolCallId:i,isAgentActive:c,isSessionLive:d,isMobile:f,skillMetadata:p})]}):r.jsx(ec,{blocks:e.contentBlocks,model:e.model,effort:e.effort,expandAll:a,expandToolPayloads:l,activeToolCallId:i,isAgentActive:c,isSessionLive:d,isMobile:f,skillMetadata:p}),u&&k&&r.jsx(G9,{turn:e,turnIndex:t,cwd:m})]}):r.jsx("div",{style:{minHeight:j.current||wA(e)}})]})});function wA(n){return Math.max(60,(n.userMessage?40:0)+n.contentBlocks.length*60)}function jA(n){const e=B.c(26),{index:t,turn:s,branchCount:o,isTurnDone:i,isMobile:a,onRestoreToHere:l,onOpenBranches:c}=n,d=!i&&!!s.timestamp;let u;e[0]!==i||e[1]!==s?(u=i?Bd(s):null,e[0]=i,e[1]=s,e[2]=u):u=e[2];const f=u,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]!==f||e[8]!==d||e[9]!==s.timestamp?(x=r.jsx(SA,{durationMs:f,showLiveTimer:d,timestamp:s.timestamp}),e[7]=f,e[8]=d,e[9]=s.timestamp,e[10]=x):x=e[10];let b;e[11]!==t||e[12]!==a||e[13]!==l?(b=l&&r.jsxs(ee,{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(kd,{"data-icon":"inline-start"}),r.jsx("span",{className:"hidden sm:inline",children:"Restore"})]}),e[11]=t,e[12]=a,e[13]=l,e[14]=b):b=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(X9,{branchCount:o,onClick:()=>c(t)})}),e[15]=o,e[16]=t,e[17]=c,e[18]=l,e[19]=w):w=e[19];let v;return e[20]!==p||e[21]!==g||e[22]!==x||e[23]!==b||e[24]!==w?(v=r.jsxs("div",{className:p,children:[g,x,b,w]}),e[20]=p,e[21]=g,e[22]=x,e[23]=b,e[24]=w,e[25]=v):v=e[25],v}function SA(n){const e=B.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(Us,{className:"size-3","data-icon":"inline-start"}),e[0]=i):i=e[0];let a;e[1]!==t?(a=Bn(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(Us,{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(Lu,{startTimestamp:o,className:"tabular-nums"})]}),e[6]=o,e[7]=a):a=e[7],a}return null}function NA(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 ec(n){const e=B.c(11),{blocks:t,model:s,effort:o,expandAll:i,expandToolPayloads:a,activeToolCallId:l,isAgentActive:c,isSessionLive:d,isMobile:u,skillMetadata:f}=n;let m;if(e[0]!==l||e[1]!==t||e[2]!==o||e[3]!==i||e[4]!==a||e[5]!==c||e[6]!==u||e[7]!==d||e[8]!==s||e[9]!==f){const p=[],h=u?"ml-0 pl-2":"ml-1 pl-3",g=u?"gap-2":"gap-3",x=new Map,b=(v,S)=>{const j=NA(v)??`at-${S}`,k=x.get(j)??0;return x.set(j,k+1),k===0?j:`${j}#${k}`};let w=0;for(;w<t.length;){const v=t[w];if(v.kind==="thinking"||v.kind==="tool_calls"){const{items:S,toolCalls:j,thinkingCount:k,thoughtForMs:C,nextIndex:N}=lh(t,w),_=S.length===1&&S[0].kind==="tool_calls";p.push(r.jsx("div",{className:G(dh,h),children:r.jsx(Qp,{toolCalls:j,expandAll:i,expandToolPayloads:a,activeToolCallId:l,isAgentActive:c,activityItems:_?void 0:S,thinkingCount:k,thoughtForMs:C,skillMetadata:f})},b(v,w))),w=N;continue}if(v.kind==="text"){const{items:S,toolCalls:j,thinkingCount:k,thoughtForMs:C,nextIndex:N}=lh(t,w+1);p.push(r.jsxs("div",{children:[r.jsx("div",{className:G("flex flex-col",g),children:v.text.map((_,A)=>r.jsx(J7,{text:_,model:s,effort:o,timestamp:v.timestamp,compact:u},A))}),(j.length>0||k>0)&&r.jsx("div",{className:G("mt-1.5",dh,h),children:r.jsx(Qp,{toolCalls:j,expandAll:i,expandToolPayloads:a,activeToolCallId:l,isAgentActive:c,activityItems:k>0?S:void 0,thinkingCount:k,thoughtForMs:C,skillMetadata:f})})]},b(v,w))),w=N;continue}if(v.kind==="queued_prompt"){p.push(r.jsxs("div",{className:G(u?"rounded-lg p-2.5":"rounded-lg p-3",q2),children:[r.jsx(Pe,{variant:"outline",className:"mb-2",children:"Queued while working"}),r.jsx(vu,{content:v.content,timestamp:v.timestamp??"",compact:u})]},b(v,w))),w++;continue}if(v.kind==="agent_message"){p.push(r.jsx(G7,{sender:v.sender,body:v.body,reply:v.reply,timestamp:v.timestamp,isLive:d},b(v,w))),w++;continue}if(v.kind==="sub_agent"){p.push(r.jsx("div",{className:G(uh,h),children:r.jsx(gT,{messages:v.messages,expandAll:i})},b(v,w))),w++;continue}if(v.kind==="background_agent"){p.push(r.jsx("div",{className:G(uh,h),children:r.jsx(xT,{messages:v.messages,expandAll:i})},b(v,w))),w++;continue}if(v.kind==="hook_event"){p.push(r.jsx(vT,{events:v.events},b(v,w))),w++;continue}if(v.kind==="plan_mode"){p.push(r.jsx(UE,{plan:v.plan,planFilePath:v.planFilePath,status:v.status,toolCalls:v.toolCalls,expandAll:i,expandToolPayloads:a,isAgentActive:c,skillMetadata:f},b(v,w))),w++;continue}if(v.kind==="recap"){p.push(r.jsx(WE,{content:v.content,timestamp:v.timestamp},b(v,w))),w++;continue}if(v.kind==="task_notification"){p.push(r.jsx(H_,{content:v.content},b(v,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]=u,e[7]=d,e[8]=s,e[9]=f,e[10]=m}else m=e[10];return m}function kA(n){if(!n)return null;const e=n.trigger==="manual"?"manual":"auto";return n.postTokens!=null?`${e} · ${ut(n.preTokens)} → ${ut(n.postTokens)}`:`${e} · ${ut(n.preTokens)}`}const CA=y.memo(function(e){const t=B.c(30),{summary:s,meta:o}=e,[i,a]=y.useState(!1);let l;t[0]!==o?(l=kA(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 u=d;let f;t[4]!==u||t[5]!==i?(f=u&&(i?r.jsx(it,{className:"size-3","data-icon":"inline-start"}):r.jsx(Xe,{className:"size-3","data-icon":"inline-start"})),t[4]=u,t[5]=i,t[6]=f):f=t[6];let m,p;t[7]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(rw,{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]!==f||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:[f,m,p,h]}),t[11]=f,t[12]=h,t[13]=g):g=t[13];const x=g;if(!u){let N;t[14]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx("div",{className:"h-px flex-1 bg-border"}),t[14]=N):N=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 A;return t[16]!==x?(A=r.jsxs("div",{className:"flex items-center gap-3 px-4 py-2",children:[N,x,_]}),t[16]=x,t[17]=A):A=t[17],A}let b,w;t[18]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx(ee,{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]=b,t[19]=w):(b=t[18],w=t[19]);let v;t[20]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx("div",{className:"h-px flex-1 bg-border"}),t[20]=v):v=t[20];let S;t[21]!==x?(S=r.jsxs(Rt,{render:b,children:[w,x,v]}),t[21]=x,t[22]=S):S=t[22];let j;t[23]===Symbol.for("react.memo_cache_sentinel")?(j=[Ma],t[23]=j):j=t[23];let k;t[24]!==u?(k=r.jsx(mt,{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(Hn,{remarkPlugins:j,components:Kn,children:u})})}),t[24]=u,t[25]=k):k=t[25];let C;return t[26]!==i||t[27]!==S||t[28]!==k?(C=r.jsxs(ft,{open:i,onOpenChange:a,className:"px-4 py-2",children:[S,k]}),t[26]=i,t[27]=S,t[28]=k,t[29]=C):C=t[29],C}),_A=1.5;function TA(n,e){return e<=0?!1:n<e*_A}function EA(n,e){return n===0&&!e}function AA(n,e){return!n||!n.firstKey||e.length<=n.length||e[0]===n.firstKey?!1:e.includes(n.firstKey)}function PA(n,e){return e&&e!=="claude"?n.isFragment===!0:n.userMessage===null}const $A=1e3;function RA(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)<=$A?!1:(e.set(a,i),!0)});return s.length===t.contentBlocks.length?t:{...t,contentBlocks:s}})}function V2(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&&PA(i,t)?[...o.slice(0,-1),MA(a,i),...n.slice(1)]:[...o,...n];return uu(RA(l))}function IA(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 MA(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:IA(n,e),tokenUsage:e.tokenUsage??n.tokenUsage,model:e.model??n.model,compactionSummary:n.compactionSummary??e.compactionSummary,compactionMeta:n.compactionMeta??e.compactionMeta}}function OA(){const n=B.c(10),{session:e,isSubAgentView:t,undoRedo:s}=at(),{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 u;n[0]!==i||n[1]!==l?(u=r.jsx(N7,{redoTurnCount:i,onRedoAll:l}),n[0]=i,n[1]=l,n[2]=u):u=n[2];let f;n[3]!==a||n[4]!==c||n[5]!==d?(f=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(K2,{turn:p,index:d+h}),c&&r.jsxs(ee,{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(iw,{"data-icon":"inline-start"}),"Redo to here"]})]},`ghost-${p.id}`))}),n[3]=a,n[4]=c,n[5]=d,n[6]=f):f=n[6];let m;return n[7]!==u||n[8]!==f?(m=r.jsxs(r.Fragment,{children:[u,f]}),n[7]=u,n[8]=f,n[9]=m):m=n[9],m}function DA(n){const e=B.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 LA(n){return(n.compactionSummary!=null||n.compactionMeta!=null)&&n.userMessage==null&&n.contentBlocks.length===0}function zA({filteredTurns:n,scrollContainerRef:e,hasMore:t=!1,isLoadingOlder:s=!1,pagingEnabled:o=!1,onLoadMore:i}){const{state:{activeTurnIndex:a}}=Ht(),{undoRedo:l}=at(),c=y.useRef(null),d=y.useRef(null),[u,f]=y.useState(0),m=y.useMemo(()=>{const v=new Map;return n.map(S=>{const j=v.get(S.turn.id)??0;return v.set(S.turn.id,j+1),{...S,key:j===0?S.turn.id:`${S.turn.id}#${j}`}})},[n]),p=y.useRef(null),h=y.useMemo(()=>AA(p.current,m.map(v=>v.key)),[m]);y.useLayoutEffect(()=>{var v;p.current={firstKey:(v=m[0])==null?void 0:v.key,length:m.length}},[m]);const g=y.useRef(t);y.useEffect(()=>{t&&(g.current=!0)},[t]);const x=t||g.current;y.useLayoutEffect(()=>{const v=e.current,S=d.current;if(!v||!S)return;const j=S.getBoundingClientRect().top-v.getBoundingClientRect().top+v.scrollTop;f(k=>Math.abs(k-j)<1?k:j)},[e,x]),y.useEffect(()=>{if(!t||!i||!o||s)return;const v=e.current;if(!v)return;const S=()=>{TA(v.scrollTop,v.clientHeight)&&i()};return S(),v.addEventListener("scroll",S,{passive:!0}),()=>v.removeEventListener("scroll",S)},[t,s,o,i,m.length,e]);const b=y.useMemo(()=>{const v=new Map;for(let S=0;S<m.length;S++)v.set(m[S].index,S);return v},[m]),w=y.useRef(null);return y.useEffect(()=>{var S;if(a===null){w.current=null;return}if(a===w.current)return;w.current=a;const v=b.get(a);v!==void 0&&((S=c.current)==null||S.scrollToIndex(v,{align:"start",smooth:!0}))},[a,b]),r.jsxs(r.Fragment,{children:[x&&r.jsx(DA,{hasMore:t,isLoadingOlder:s}),r.jsx("div",{ref:d,className:"motion-session-enter",children:r.jsx(S7,{ref:c,scrollRef:e,startMargin:u,shift:h,children:m.map(({turn:v,index:S,key:j})=>r.jsxs("div",{"data-turn-index":S,children:[(v.compactionSummary||v.compactionMeta)&&r.jsx(CA,{summary:v.compactionSummary,meta:v.compactionMeta}),!LA(v)&&r.jsx(K2,{turn:v,index:S,branchCount:l.branchesAtTurn?l.branchesAtTurn(S).length:0})]},j))})}),r.jsx(OA,{})]})}const FA=y.memo(function(e){const t=B.c(19),{chatScrollRef:s,hasMore:o,isLoadingOlder:i,pagingEnabled:a,onLoadMore:l}=e,{state:c}=Ht(),{searchQuery:d,sessionChangeKey:u}=c,{session:f}=at(),m=f==null?void 0:f.turns;let p;t[0]!==m?(p=m?m.map(BA):[],t[0]=m,t[1]=p):p=t[1];const h=p;let g;t[2]!==h||t[3]!==d?(g=d?h.filter(S=>{const{turn:j}=S;return sA(j,d)}):h,t[2]=h,t[3]=d,t[4]=g):g=t[4];const x=g;let b;t[5]!==x.length||t[6]!==o||t[7]!==d?(b=d?x.length===0:EA(x.length,o??!1),t[5]=x.length,t[6]=o,t[7]=d,t[8]=b):b=t[8];const w=b;let v;return t[9]!==s||t[10]!==x||t[11]!==o||t[12]!==i||t[13]!==l||t[14]!==a||t[15]!==d||t[16]!==u||t[17]!==w?(v=r.jsx(v_,{children:w?r.jsx(ln,{className:"min-h-64 border-0",children:r.jsxs(cn,{children:[r.jsx(bn,{variant:"icon",children:d?r.jsx(aw,{}):r.jsx(L1,{})}),r.jsx(dn,{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(zA,{filteredTurns:x,scrollContainerRef:s,hasMore:o,isLoadingOlder:i,pagingEnabled:a,onLoadMore:l},u)}),t[9]=s,t[10]=x,t[11]=o,t[12]=i,t[13]=l,t[14]=a,t[15]=d,t[16]=u,t[17]=w,t[18]=v):v=t[18],v});function BA(n,e){return{turn:n,index:e}}const UA="[data-turn-index]",G2="[data-turn-prompt]",fh=1,WA=120,mh=180;function HA(n){if(!n.userMessage)return null;const e=sl(n.userMessage),{body:t}=Sr(e),{remainingText:s}=bu(t),o=P0(s);if(!o){const a=$0(e);if(!a)return null;const l=R0(e);return l?`/${a} ${l}`:`/${a}`}const i=o.split(`
|
|
120
|
+
`)[0];return i.length>mh?`${i.slice(0,mh)}...`:i}function qA(n,e){for(let t=e;t>=0;t--){const s=n[t];if(!s)continue;const o=HA(s);if(o)return{index:t,text:o}}return null}function KA(n){const e=n.getBoundingClientRect().top;let t=null,s=0;for(const l of n.querySelectorAll(UA)){const c=l.getBoundingClientRect().top;if(c>e+fh)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(G2);return(i?i.getBoundingClientRect().bottom>e+fh:s+WA>e)?null:o}const VA=y.memo(function(e){const t=B.c(22),{session:s,scrollContainerRef:o}=e,[i,a]=y.useState(null);let l,c;t[0]!==o||t[1]!==s.sessionId?(l=()=>{const S=o.current;if(!S)return;let j=null;const k=()=>{j=null;const A=KA(S);a(P=>A===null?null:(P==null?void 0:P.sessionId)===s.sessionId&&P.index===A?P:{sessionId:s.sessionId,index:A})},C=()=>{j===null&&(j=requestAnimationFrame(k))};a(null),S.addEventListener("scroll",C,{passive:!0});const N=new MutationObserver(C);N.observe(S,{childList:!0,subtree:!0});const _=new ResizeObserver(C);return _.observe(S),S.firstElementChild&&_.observe(S.firstElementChild),C(),()=>{S.removeEventListener("scroll",C),N.disconnect(),_.disconnect(),j!==null&&cancelAnimationFrame(j)}},c=[o,s.sessionId],t[0]=o,t[1]=s.sessionId,t[2]=l,t[3]=c):(l=t[2],c=t[3]),y.useEffect(l,c);let d;e:{if(!i||i.sessionId!==s.sessionId){d=null;break e}let S;t[4]!==s.turns||t[5]!==i.index?(S=qA(s.turns,i.index),t[4]=s.turns,t[5]=i.index,t[6]=S):S=t[6],d=S}const u=d;if(!u)return null;let f;t[7]!==u.index||t[8]!==o?(f=()=>{const S=o.current;if(!S)return;const j=S.querySelector(`[data-turn-index="${u.index}"]`),k=(j==null?void 0:j.querySelector(G2))??j;if(!k)return;const C=S.scrollTop+k.getBoundingClientRect().top-S.getBoundingClientRect().top;S.scrollTo({top:Math.max(0,C),behavior:"smooth"})},t[7]=u.index,t[8]=o,t[9]=f):f=t[9];const m=f,p=`Scroll to turn ${u.index+1} prompt`;let h;t[10]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(L1,{"data-icon":"inline-start"}),t[10]=h):h=t[10];const g=u.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 b;t[13]!==u.text?(b=r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-normal text-foreground/80",children:u.text}),t[13]=u.text,t[14]=b):b=t[14];let w;t[15]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(Ir,{"data-icon":"inline-end",className:"ml-auto"}),t[15]=w):w=t[15];let v;return t[16]!==u.text||t[17]!==m||t[18]!==p||t[19]!==x||t[20]!==b?(v=r.jsxs(ee,{type:"button",variant:"outline",size:"sm","aria-label":p,title:u.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,b,w]}),t[16]=u.text,t[17]=m,t[18]=p,t[19]=x,t[20]=b,t[21]=v):v=t[21],v});function GA(n){const e=B.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(ph,{}),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(Cu,{text:t.text}),e[7]=t.text,e[8]=o):o=e[8];let i;e[9]!==s?(i=s&&r.jsx(ph,{}),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 ph(){const n=B.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 YA=y.memo(function(){const e=B.c(9),t=ku();let s,o,i,a;if(e[0]!==t){a=Symbol.for("react.early_return_sentinel");e:{const c=nT(t);if(c.length===0){a=null;break e}const d=new Map;s="px-4",o="streaming-turn-overlay",i=c.map(u=>{const f=d.get(u.messageId)??0;d.set(u.messageId,f+1);const m=u.blocks.reduce(XA,-1);return r.jsx("div",{children:u.blocks.map((p,h)=>r.jsx(GA,{block:p,showCursor:!u.stopped&&h===m},p.index))},`${u.messageId}:${f}`)})}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 XA(n,e,t){return e.blockType!=="tool_use"&&e.text?t:n}class JA extends y.Component{constructor(t){super(t);Si(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(pt,{variant:"destructive",className:"max-w-md has-data-[slot=alert-action]:pr-2.5",children:[r.jsx(gn,{}),r.jsx(Et,{children:r.jsx("h3",{children:this.props.fallbackMessage||"Something went wrong"})}),this.state.error&&r.jsx(ht,{className:"font-mono text-xs",children:this.state.error.message}),r.jsx(Cs,{className:"static col-start-2 mt-2",children:r.jsxs(ee,{variant:"outline",size:"sm",onClick:this.handleRetry,children:[r.jsx(Pt,{"data-icon":"inline-start"}),"Try again"]})})]})}):this.props.children}}const hh="find-in-session-highlight",tc="find-in-session-active";function QA(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 ZA=y.forwardRef(function(e,t){const s=B.c(63),{scrollContainerRef:o}=e,[i,a]=y.useState(!1),[l,c]=y.useState("");let d;s[0]===Symbol.for("react.memo_cache_sentinel")?(d=[],s[0]=d):d=s[0];const[u,f]=y.useState(d),[m,p]=y.useState(-1),h=y.useRef(null);let g;s[1]!==o?(g=()=>{const ne=o.current;if(!ne)return;ne.querySelectorAll(`mark.${hh}`).forEach(eP)},s[1]=o,s[2]=g):g=s[2];const x=g;let b;s[3]!==x||s[4]!==o?(b=ne=>{if(x(),!ne||!o.current){f([]),p(-1);return}const oe=o.current,re=QA(oe),ae=ne.toLowerCase(),se=[];for(const de of re){const le=de.nodeValue||"",ce=le.toLowerCase();let me=0;const ue=[];for(;;){const xe=ce.indexOf(ae,me);if(xe===-1)break;ue.push(xe),me=xe+1}if(ue.length===0)continue;const ie=de.parentNode;if(!ie)continue;const ge=document.createDocumentFragment();let pe=0;for(const xe of ue){xe>pe&&ge.appendChild(document.createTextNode(le.slice(pe,xe)));const Ce=document.createElement("mark");Ce.className=hh,Ce.textContent=le.slice(xe,xe+ne.length),ge.appendChild(Ce),se.push(Ce),pe=xe+ne.length}pe<le.length&&ge.appendChild(document.createTextNode(le.slice(pe))),ie.replaceChild(ge,de)}f(se),se.length>0?(p(0),se[0].classList.add(tc),se[0].scrollIntoView({block:"center",behavior:"smooth"})):p(-1)},s[3]=x,s[4]=o,s[5]=b):b=s[5];const w=b;let v;s[6]!==m||s[7]!==u?(v=ne=>{if(u.length===0)return;m>=0&&m<u.length&&u[m].classList.remove(tc);const oe=(ne%u.length+u.length)%u.length;u[oe].classList.add(tc),u[oe].scrollIntoView({block:"center",behavior:"smooth"}),p(oe)},s[6]=m,s[7]=u,s[8]=v):v=s[8];const S=v;let j;s[9]!==x?(j=()=>{a(!1),c(""),x(),f([]),p(-1)},s[9]=x,s[10]=j):j=s[10];const k=j;let C,N;s[11]!==k||s[12]!==i?(C=()=>({open:()=>{a(!0),requestAnimationFrame(()=>{var ne;return(ne=h.current)==null?void 0:ne.focus()})},close:k,isOpen:i}),N=[k,i],s[11]=k,s[12]=i,s[13]=C,s[14]=N):(C=s[13],N=s[14]),y.useImperativeHandle(t,C,N);let _,A;s[15]!==w||s[16]!==l?(_=()=>{const ne=setTimeout(()=>w(l),150);return()=>clearTimeout(ne)},A=[l,w],s[15]=w,s[16]=l,s[17]=_,s[18]=A):(_=s[17],A=s[18]),y.useEffect(_,A);let P,T;s[19]!==x?(P=()=>()=>x(),T=[x],s[19]=x,s[20]=P,s[21]=T):(P=s[20],T=s[21]),y.useEffect(P,T);let E;s[22]!==m||s[23]!==S||s[24]!==k?(E=ne=>{ne.key==="Escape"?(ne.preventDefault(),ne.stopPropagation(),k()):ne.key==="Enter"&&(ne.preventDefault(),ne.shiftKey?S(m-1):S(m+1))},s[22]=m,s[23]=S,s[24]=k,s[25]=E):E=s[25];const $=E;if(!i)return null;let I;s[26]===Symbol.for("react.memo_cache_sentinel")?(I=ne=>c(ne.target.value),s[26]=I):I=s[26];let R;s[27]!==$||s[28]!==l?(R=r.jsx(cs,{ref:h,value:l,onChange:I,onKeyDown:$,placeholder:"Find in conversation","aria-label":"Find in conversation",autoFocus:!0}),s[27]=$,s[28]=l,s[29]=R):R=s[29];const D=l?u.length>0?`${m+1}/${u.length}`:"0/0":"";let O;s[30]!==D?(O=r.jsx(Pn,{align:"inline-end",children:r.jsx("span",{className:"min-w-12 text-center text-xs tabular-nums",children:D})}),s[30]=D,s[31]=O):O=s[31];let M;s[32]!==R||s[33]!==O?(M=r.jsxs(ls,{className:"w-64",children:[R,O]}),s[32]=R,s[33]=O,s[34]=M):M=s[34];let F;s[35]!==m||s[36]!==S?(F=()=>S(m-1),s[35]=m,s[36]=S,s[37]=F):F=s[37];const z=u.length===0,L=u.length>0?"hover:text-foreground":"cursor-default opacity-40";let W;s[38]!==L?(W=G("text-muted-foreground",L),s[38]=L,s[39]=W):W=s[39];let U;s[40]===Symbol.for("react.memo_cache_sentinel")?(U=r.jsx(Ir,{"data-icon":"inline-start"}),s[40]=U):U=s[40];let H;s[41]!==F||s[42]!==z||s[43]!==W?(H=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:F,disabled:z,className:W,"aria-label":"Previous match",children:U}),s[41]=F,s[42]=z,s[43]=W,s[44]=H):H=s[44];let K;s[45]!==m||s[46]!==S?(K=()=>S(m+1),s[45]=m,s[46]=S,s[47]=K):K=s[47];const V=u.length===0,Y=u.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(it,{"data-icon":"inline-start"}),s[50]=J):J=s[50];let Q;s[51]!==K||s[52]!==V||s[53]!==q?(Q=r.jsx(ee,{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]=Q):Q=s[54];let X;s[55]===Symbol.for("react.memo_cache_sentinel")?(X=r.jsx(nt,{"data-icon":"inline-start"}),s[55]=X):X=s[55];let Z;s[56]!==k?(Z=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:k,className:"text-muted-foreground hover:text-foreground","aria-label":"Close search",children:X}),s[56]=k,s[57]=Z):Z=s[57];let te;return s[58]!==M||s[59]!==H||s[60]!==Q||s[61]!==Z?(te=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:[M,H,Q,Z]}),s[58]=M,s[59]=H,s[60]=Q,s[61]=Z,s[62]=te):te=s[62],te});function eP(n){const e=n.parentNode;e&&(e.replaceChild(document.createTextNode(n.textContent||""),n),e.normalize())}const SB=["General","View","Tools"],cl=[{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}}],Y2="cogpit-keybindings";let Os=null;function X2(n=typeof navigator>"u"?"":navigator.platform){return/Mac|iPhone|iPad/i.test(n)}function Pr(n){const e=n.toLowerCase();return e==="esc"?"escape":e}function tP(n){if(!n||typeof n!="object")return!1;const e=n;return e.doubleTapModifier==="mod"||typeof e.key=="string"&&e.key.length>0}function zu(){if(Os)return Os;try{const n=localStorage.getItem(Y2);if(!n)return Os={};const e=JSON.parse(n);if(!e||typeof e!="object")return Os={};const t={};for(const s of cl){const o=e[s.command];tP(o)&&(t[s.command]=o)}return Os=t}catch{return Os={}}}function Fu(n){Os=n;try{localStorage.setItem(Y2,JSON.stringify(n))}catch{}typeof window<"u"&&window.dispatchEvent(new Event("cogpit-keybindings-changed"))}function li(n){const e=cl.find(t=>t.command===n);if(!e)throw new Error(`Unknown keybinding command: ${n}`);return zu()[n]??e.defaultShortcut}function NB(){return Object.fromEntries(cl.map(n=>[n.command,li(n.command)]))}function kB(n,e){const t="doubleTapModifier"in e?{...e}:{...e,key:Pr(e.key)};Fu({...zu(),[n]:t})}function CB(n){const e={...zu()};delete e[n],Fu(e)}function _B(){Fu({})}function TB(n){return{key:Pr(n.key),metaKey:n.metaKey||void 0,ctrlKey:n.ctrlKey||void 0,shiftKey:n.shiftKey||void 0,altKey:n.altKey||void 0}}function J2(n){const e=n;if(!e)return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||e.isContentEditable===!0}function Ct(n,e){const t=li(n);return"doubleTapModifier"in t||Pr(e.key)!==Pr(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 io(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 nP(n){const e=X2();return"doubleTapModifier"in n?e?"Double ⌘":"Double Ctrl":n.modKey?e?`${n.shiftKey?"⇧":""}⌘${io(n.key)}`:`Ctrl+${n.shiftKey?"Shift+":""}${io(n.key)}`:n.platformChord?e?`⌃⌘${n.shiftKey?"⇧":""}${io(n.key)}`:`Ctrl+Alt+${n.shiftKey?"Shift+":""}${io(n.key)}`:e?`${n.ctrlKey?"⌃":""}${n.altKey?"⌥":""}${n.shiftKey?"⇧":""}${n.metaKey?"⌘":""}${io(n.key)}`:[n.ctrlKey?"Ctrl":null,n.altKey?"Alt":null,n.shiftKey?"Shift":null,n.metaKey?"Meta":null,io(n.key)].filter(Boolean).join("+")}function nc(n){return nP(li(n))}function gh(n){if("doubleTapModifier"in n)return[`double-tap:${n.doubleTapModifier}`];const e=(t,s,o,i)=>`${Pr(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 EB(n,e){const t=new Set(gh(n));return cl.find(s=>s.command!==e&&gh(li(s.command)).some(o=>t.has(o)))??null}function xh(n){return"doubleTapModifier"in li(n)?X2()?"Meta":"Control":null}const sP=["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"],oP="device.cycle";function rP(n){const e=sP.findIndex(t=>Ct(t,n));return e===-1?null:e+1}function iP(n){return Ct(oP,n)}const nd="cogpit:find-in-conversation",dl=y.memo(function(e){const t=B.c(77),{searchInputRef:s,hasTodos:o,hasMore:i,isLoadingOlder:a,onLoadMore:l,mobileSearchOpen:c,onMobileSearchClose:d}=e,u=c===void 0?!1:c,{state:f,dispatch:m,isMobile:p}=Ht(),{session:h}=at(),{chat:g,scroll:x}=qr(),{searchQuery:b}=f,{pendingMessages:w}=g,{chatScrollRef:v,scrollEndRef:S,handleScroll:j,canScrollDown:k,scrollToBottomInstant:C,initialScrollDone:N}=x,_=y.useRef(null);let A;t[0]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{var ie;return(ie=_.current)==null?void 0:ie.open()},t[0]=A):A=t[0];const P=A;let T,E;t[1]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{const ie=function(pe){Ct("findInConversation",pe)&&(pe.preventDefault(),P())};return window.addEventListener("keydown",ie),window.addEventListener(nd,P),()=>{window.removeEventListener("keydown",ie),window.removeEventListener(nd,P)}},E=[P],t[1]=T,t[2]=E):(T=t[1],E=t[2]),y.useEffect(T,E);let $,I;t[3]!==p||t[4]!==u||t[5]!==s?($=()=>{!p||!u||requestAnimationFrame(()=>{var ie;return(ie=s.current)==null?void 0:ie.focus()})},I=[p,u,s],t[3]=p,t[4]=u,t[5]=s,t[6]=$,t[7]=I):($=t[6],I=t[7]),y.useEffect($,I);let R;t[8]!==m||t[9]!==d?(R=()=>{m({type:"SET_SEARCH_QUERY",value:""}),d==null||d()},t[8]=m,t[9]=d,t[10]=R):R=t[10];const D=R,O=h,M=O.turns.length>0||w.length===0,F=p?"flex min-h-0 flex-1 flex-col":"min-h-0 flex-1";let z;t[11]!==F?(z=G("relative bg-background",F),t[11]=F,t[12]=z):z=t[12];let L;t[13]!==D||t[14]!==m||t[15]!==p||t[16]!==u||t[17]!==s||t[18]!==b?(L=p&&u&&r.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b bg-background px-3 py-2",children:[r.jsxs(ls,{className:"h-9 flex-1",children:[r.jsx(cs,{ref:s,value:b,onChange:ie=>m({type:"SET_SEARCH_QUERY",value:ie.target.value}),placeholder:"Search conversation...","aria-label":"Search conversation"}),r.jsx(Pn,{align:"inline-start",children:r.jsx(an,{})})]}),r.jsx(ee,{variant:"ghost",size:"icon-sm",onClick:D,"aria-label":"Close conversation search",children:r.jsx(nt,{"data-icon":"inline-start"})})]}),t[13]=D,t[14]=m,t[15]=p,t[16]=u,t[17]=s,t[18]=b,t[19]=L):L=t[19];const W=p?"flex-1 min-h-0":"h-full";let U;t[20]!==W?(U=G("relative",W),t[20]=W,t[21]=U):U=t[21];let H;t[22]!==v?(H=r.jsx(ZA,{ref:_,scrollContainerRef:v}),t[22]=v,t[23]=H):H=t[23];let K;t[24]!==v||t[25]!==O?(K=r.jsx(VA,{session:O,scrollContainerRef:v}),t[24]=v,t[25]=O,t[26]=K):K=t[26];const V=p&&"mobile-scroll";let Y;t[27]!==V?(Y=G("h-full overflow-x-hidden overflow-y-auto bg-background",V),t[27]=V,t[28]=Y):Y=t[28];let q;t[29]!==o||t[30]!==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[29]=o,t[30]=p,t[31]=q):q=t[31];let J;t[32]!==v||t[33]!==i||t[34]!==N||t[35]!==a||t[36]!==l||t[37]!==M?(J=M&&r.jsx(FA,{chatScrollRef:v,hasMore:i,isLoadingOlder:a,pagingEnabled:N,onLoadMore:l}),t[32]=v,t[33]=i,t[34]=N,t[35]=a,t[36]=l,t[37]=M,t[38]=J):J=t[38];let Q;t[39]===Symbol.for("react.memo_cache_sentinel")?(Q=r.jsx(YA,{}),t[39]=Q):Q=t[39];let X;if(t[40]!==O.turns.length||t[41]!==w){let ie;t[43]!==O.turns.length?(ie=(ge,pe)=>r.jsx(O0,{message:ge,turnNumber:O.turns.length+1+pe},pe),t[43]=O.turns.length,t[44]=ie):ie=t[44],X=w.map(ie),t[40]=O.turns.length,t[41]=w,t[42]=X}else X=t[42];let Z;t[45]===Symbol.for("react.memo_cache_sentinel")?(Z=r.jsx(tA,{}),t[45]=Z):Z=t[45];let te;t[46]!==S?(te=r.jsx("div",{ref:S}),t[46]=S,t[47]=te):te=t[47];let ne;t[48]!==J||t[49]!==X||t[50]!==te?(ne=r.jsxs(JA,{fallbackMessage:"Failed to render conversation timeline",children:[J,Q,X,Z,te]}),t[48]=J,t[49]=X,t[50]=te,t[51]=ne):ne=t[51];let oe;t[52]!==q||t[53]!==ne?(oe=r.jsx("div",{className:q,children:ne}),t[52]=q,t[53]=ne,t[54]=oe):oe=t[54];let re;t[55]!==v||t[56]!==j||t[57]!==Y||t[58]!==oe?(re=r.jsx("div",{ref:v,onScroll:j,className:Y,children:oe}),t[55]=v,t[56]=j,t[57]=Y,t[58]=oe,t[59]=re):re=t[59];const ae=k?"opacity-100 scale-100":"opacity-0 scale-75 pointer-events-none",se=p?"right-3 bottom-3":"right-5 bottom-5";let de;t[60]!==ae||t[61]!==se?(de=G("absolute rounded-full shadow-sm transition-[opacity,transform] duration-200 ease-out active:scale-95",ae,se),t[60]=ae,t[61]=se,t[62]=de):de=t[62];let le;t[63]===Symbol.for("react.memo_cache_sentinel")?(le=r.jsx(lw,{"data-icon":"inline-start"}),t[63]=le):le=t[63];let ce;t[64]!==C||t[65]!==de?(ce=r.jsx(ee,{size:"icon",className:de,onClick:C,"aria-label":"Scroll to bottom",children:le}),t[64]=C,t[65]=de,t[66]=ce):ce=t[66];let me;t[67]!==U||t[68]!==H||t[69]!==K||t[70]!==re||t[71]!==ce?(me=r.jsxs("div",{className:U,children:[H,K,re,ce]}),t[67]=U,t[68]=H,t[69]=K,t[70]=re,t[71]=ce,t[72]=me):me=t[72];let ue;return t[73]!==L||t[74]!==me||t[75]!==z?(ue=r.jsxs("div",{className:z,children:[L,me]}),t[73]=L,t[74]=me,t[75]=z,t[76]=ue):ue=t[76],ue}),sd="cogpit-devices-changed",Q2="cogpit:devices-changed";function Z2(n){typeof n.connectionRevision=="number"&&Jj(n.id,n.connectionRevision)}function eb(n,e,t=!1){window.dispatchEvent(new CustomEvent(sd,{detail:{deviceId:n,connectionRevision:e,removed:t}}));try{localStorage.setItem(Q2,JSON.stringify({deviceId:n,connectionRevision:e,removed:t,nonce:`${Date.now()}:${Math.random()}`}))}catch{}}function bh(n){Z2(n),eb(n.id,n.connectionRevision)}function sc(n,e=""){return`/api/hub/devices/${encodeURIComponent(n)}${e}`}async function ao(n){try{const e=await n.json();return e&&typeof e=="object"?e:null}catch{return null}}function tb(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.version;if(typeof t=="string")return t}}function aP(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.edition;if(t==="team"||t==="personal")return t}}function ul(){const[n,e]=y.useState([]),[t,s]=y.useState(!0),[o,i]=y.useState(()=>vt()),a=y.useRef(0),l=y.useCallback(async()=>{const h=++a.current;try{const g=await ms("/api/hub/devices");if(!g.ok)return;const x=await ao(g);if(h!==a.current)return;const b=Array.isArray(x==null?void 0:x.devices)?x.devices:[];for(const w of b)Z2(w);e(b)}catch{}finally{h===a.current&&s(!1)}},[]);y.useEffect(()=>{l()},[l]),y.useEffect(()=>{const h=()=>i(vt()),g=()=>void l(),x=v=>{if(v.key===Q2){try{const S=JSON.parse(v.newValue??"null");(S==null?void 0:S.removed)===!0&&typeof S.deviceId=="string"&&vt()===S.deviceId&&Ss(Tt)}catch{}l()}},b=()=>{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(sd,g),window.addEventListener("storage",x),window.addEventListener("cogpit-auth-changed",b),window.addEventListener("cogpit-identity-changed",b),window.addEventListener("cogpit-auth-required",w),()=>{window.removeEventListener("cogpit-device-changed",h),window.removeEventListener("popstate",h),window.removeEventListener(sd,g),window.removeEventListener("storage",x),window.removeEventListener("cogpit-auth-changed",b),window.removeEventListener("cogpit-identity-changed",b),window.removeEventListener("cogpit-auth-required",w)}},[l]);const c=y.useMemo(()=>o===Tt?void 0:n.find(h=>h.id===o),[n,o]),d=y.useCallback(async(h,g,x,b)=>{try{const w=await ms("/api/hub/devices/probe",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:h,port:g,allowLocalTunnel:x,tls:b})}),v=await ao(w);return(v==null?void 0:v.ok)===!0&&v.hello?{ok:!0,hello:v.hello}:{ok:!1,code:(v==null?void 0:v.code)??"UNREACHABLE",error:typeof(v==null?void 0:v.error)=="string"?v.error:void 0}}catch{return{ok:!1,code:"UNREACHABLE",error:"Could not reach the device."}}},[]),u=y.useCallback(async h=>{try{const g=await ms("/api/hub/devices",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(h)}),x=await ao(g);if(g.ok&&(x!=null&&x.device)){const b=x.device;return bh(b),{ok:!0,device:b}}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."}}},[]),f=y.useCallback(async(h,g)=>{try{const x=await ms(sc(h),{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(g)}),b=await ao(x);if(x.ok&&(b!=null&&b.device)){const w=b.device;return bh(w),{ok:!0,device:w}}return{ok:!1,code:(b==null?void 0:b.code)??"ERROR",error:typeof(b==null?void 0:b.error)=="string"?b.error:"Could not update the device."}}catch{return{ok:!1,code:"ERROR",error:"Could not update the device."}}},[]),m=y.useCallback(async h=>{try{const g=await ms(sc(h),{method:"DELETE"});if(g.ok)return vt()===h&&Ss(Tt),eb(h,void 0,!0),{ok:!0};const x=await ao(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=y.useCallback(async h=>{try{const g=await ms(sc(h,"/test"),{method:"POST"});return await ao(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:u,updateDevice:f,removeDevice:m,testDevice:p}}const lP=/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/;function vh(n,e){if(!lP.test(e))throw new Error(`Invalid Cogpit ${n} id "${e}"`)}function go(n,e){return`${n}.${e}`}function cP(n){const e=new Set,t=new Set,s=[];for(const o of n){if(vh("plugin",o.id),e.has(o.id))throw new Error(`Duplicate Cogpit plugin id "${o.id}"`);e.add(o.id);for(const i of o.workspacePanels??[]){vh("panel",i.id);const a=go(o.id,i.id);if(t.has(a))throw new Error(`Duplicate Cogpit workspace panel id "${a}"`);t.add(a),s.push({...i,id:a,pluginId:o.id,localId:i.id})}}return s.sort((o,i)=>(o.order??100)-(i.order??100)||o.title.localeCompare(i.title))}const Li=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});function fl(n,e){const t=Date.parse(n);if(!Number.isFinite(t))return"Unknown time";const s=Math.round((t-e)/1e3);if(Math.abs(s)<60)return Li.format(s,"second");const o=Math.round(s/60);if(Math.abs(o)<60)return Li.format(o,"minute");const i=Math.round(o/60);return Math.abs(i)<24?Li.format(i,"hour"):Li.format(Math.round(i/24),"day")}function Bu(n,e,t){const s=n?Date.parse(n):Number.NaN;if(!Number.isFinite(s))return null;const o=e?Date.parse(e):t,i=Math.max(0,Math.round((o-s)/1e3));if(i<60)return`${i}s`;const a=Math.floor(i/60);return a<60?`${a}m ${i%60}s`:`${Math.floor(a/60)}h ${a%60}m`}function ml(n){const e=B.c(3),[t,s]=y.useState(dP);let o,i;return e[0]!==n?(o=()=>{if(s(Date.now()),!n)return;const a=window.setInterval(()=>s(Date.now()),1e3);return()=>window.clearInterval(a)},i=[n],e[0]=n,e[1]=o,e[2]=i):(o=e[1],i=e[2]),y.useEffect(o,i),t}function dP(){return Date.now()}function $r(n){const e=B.c(3),{label:t,children:s}=n;let o;return e[0]!==s||e[1]!==t?(o=r.jsx("div",{className:"no-scrollbar flex shrink-0 items-center gap-1 overflow-x-auto border-b px-3 py-1.5",role:"group","aria-label":t,children:s}),e[0]=s,e[1]=t,e[2]=o):o=e[2],o}function pl(n){const e=B.c(10),{icon:t,title:s,description:o}=n;let i;e[0]!==t?(i=r.jsx(bn,{variant:"icon",children:r.jsx(t,{})}),e[0]=t,e[1]=i):i=e[1];let a;e[2]!==s?(a=r.jsx(dn,{children:s}),e[2]=s,e[3]=a):a=e[3];let l;e[4]!==o?(l=r.jsx(vn,{children:o}),e[4]=o,e[5]=l):l=e[5];let c;return e[6]!==i||e[7]!==a||e[8]!==l?(c=r.jsx(ln,{className:"border-0",children:r.jsxs(cn,{children:[i,a,l]})}),e[6]=i,e[7]=a,e[8]=l,e[9]=c):c=e[9],c}function Uu(n){const e=B.c(16),{count:t,children:s}=n,[o,i]=y.useState(!1),a=o&&"rotate-90";let l;e[0]!==a?(l=G("size-3 shrink-0 transition-transform",a),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==l?(c=r.jsx(Xe,{className:l}),e[2]=l,e[3]=c):c=e[3];let d;e[4]!==t?(d=r.jsx("span",{className:"font-mono text-[10px] tabular-nums opacity-70",children:t}),e[4]=t,e[5]=d):d=e[5];let u;e[6]!==o||e[7]!==c||e[8]!==d?(u=r.jsxs(Rt,{className:"flex h-7 w-full items-center gap-1.5 rounded-sm px-1 text-left text-xs text-muted-foreground outline-none hover:bg-accent/60 hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/20","aria-expanded":o,children:[c,"Closed",d]}),e[6]=o,e[7]=c,e[8]=d,e[9]=u):u=e[9];let f;e[10]!==s?(f=r.jsx(mt,{children:r.jsx("div",{className:"flex flex-col gap-4 pt-2",children:s})}),e[10]=s,e[11]=f):f=e[11];let m;return e[12]!==o||e[13]!==u||e[14]!==f?(m=r.jsxs(ft,{open:o,onOpenChange:i,children:[u,f]}),e[12]=o,e[13]=u,e[14]=f,e[15]=m):m=e[15],m}function nb(n){const e=B.c(4),{count:t}=n;if(t===0)return null;const s=`${t} comment${t===1?"":"s"}`;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(cw,{className:"size-3","aria-hidden":!0}),e[0]=o):o=e[0];let i;return e[1]!==t||e[2]!==s?(i=r.jsxs("span",{className:"flex items-center gap-0.5 font-mono text-[10px] text-muted-foreground tabular-nums","aria-label":s,title:s,children:[o,t]}),e[1]=t,e[2]=s,e[3]=i):i=e[3],i}const uP=700,fP=12;function Wu(n){const e=B.c(15),{body:t}=n,[s,o]=y.useState(!1);let i;e[0]!==t?(i=t.length>uP||t.split(`
|
|
121
|
+
`).length>fP,e[0]=t,e[1]=i):i=e[1];const a=i,l=a&&!s&&"max-h-52 overflow-hidden [mask-image:linear-gradient(to_bottom,black_70%,transparent)]";let c;e[2]!==l?(c=G("break-words text-xs leading-5",l),e[2]=l,e[3]=c):c=e[3];let d;e[4]!==t?(d=r.jsx(Cu,{text:t,compactHeadings:!0}),e[4]=t,e[5]=d):d=e[5];let u;e[6]!==c||e[7]!==d?(u=r.jsx("div",{className:c,children:d}),e[6]=c,e[7]=d,e[8]=u):u=e[8];let f;e[9]!==s||e[10]!==a?(f=a&&r.jsx("button",{type:"button",className:"mt-1 text-[11px] text-muted-foreground underline-offset-2 outline-none hover:text-foreground hover:underline focus-visible:underline",onClick:()=>o(mP),"aria-expanded":s,children:s?"Show less":"Show full description"}),e[9]=s,e[10]=a,e[11]=f):f=e[11];let m;return e[12]!==u||e[13]!==f?(m=r.jsxs("div",{className:"max-w-[72ch]",children:[u,f]}),e[12]=u,e[13]=f,e[14]=m):m=e[14],m}function mP(n){return!n}function yt(n){const e=B.c(13);let t,s,o,i;e[0]!==n?({pressed:o,className:s,children:t,...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]);const a=o?"border-foreground/20 bg-foreground/[0.06] text-foreground":"border-transparent text-muted-foreground hover:bg-accent hover:text-foreground";let l;e[5]!==s||e[6]!==a?(l=G("inline-flex h-6 shrink-0 items-center gap-1 rounded-full border px-2 text-[11px] leading-none outline-none transition-colors","focus-visible:ring-[3px] focus-visible:ring-ring/20 disabled:opacity-40",a,s),e[5]=s,e[6]=a,e[7]=l):l=e[7];let c;return e[8]!==t||e[9]!==o||e[10]!==i||e[11]!==l?(c=r.jsx("button",{type:"button","aria-pressed":o,className:l,...i,children:t}),e[8]=t,e[9]=o,e[10]=i,e[11]=l,e[12]=c):c=e[12],c}function wt(n){const e=B.c(2),{children:t}=n;let s;return e[0]!==t?(s=r.jsx("span",{className:"font-mono text-[10px] tabular-nums opacity-70",children:t}),e[0]=t,e[1]=s):s=e[1],s}function ct(n){const e=B.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}const xo="cogpit",_t={worktrees:go(xo,"worktrees"),projectFiles:go(xo,"project-files"),browser:go(xo,"browser"),fileChanges:go(xo,"file-changes"),sessionInfo:go(xo,"session-info")},pP=y.lazy(()=>qe(()=>import("./CommandPaletteHost-DLho8Ydr.js"),__vite__mapDeps([25,1,2,3,4])).then(n=>({default:n.CommandPaletteHost}))),hP=y.lazy(()=>qe(()=>import("./index-D2-ty4Xm.js"),__vite__mapDeps([26,1,2,3,4])).then(n=>({default:n.ConfigDialog}))),gP=y.lazy(()=>qe(()=>Promise.resolve().then(()=>IP),void 0).then(n=>({default:n.DevicesDialog}))),xP=y.lazy(()=>qe(()=>import("./KeyboardShortcutsDialog-BbU77pdm.js"),__vite__mapDeps([27,1,2,3,4])).then(n=>({default:n.KeyboardShortcutsDialog}))),bP=y.lazy(()=>qe(()=>import("./ProjectSwitcherModal-HW-WAt1o.js"),__vite__mapDeps([28,1,2,3,4])).then(n=>({default:n.ProjectSwitcherModal}))),vP=y.lazy(()=>qe(()=>import("./ThemeSelectorModal-BZ9ceBWr.js"),__vite__mapDeps([29,1,2,3,4])).then(n=>({default:n.ThemeSelectorModal})));function yP(n){const e=B.c(120),{navigation:t,project:s,chrome:o}=n,{state:i,config:a,theme:l}=Ht(),{session:c,sessionSource:d}=at(),{devices:u,activeDeviceId:f}=ul(),[m,p]=y.useState(null),[h,g]=y.useState(null);let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=ot("manageDevices"),e[0]=x):x=e[0];const b=x;let w;e[1]!==i.pendingCwd||e[2]!==i.pendingDirName?(w=i.pendingCwd??(i.pendingDirName?_n(i.pendingDirName):null),e[1]=i.pendingCwd,e[2]=i.pendingDirName,e[3]=w):w=e[3];const v=w,S=(d==null?void 0:d.dirName)??i.pendingDirName??i.dashboardProject??null,j=m??h;let k,C;e[4]!==m?(k=()=>{m&&g(m)},C=[m],e[4]=m,e[5]=k,e[6]=C):(k=e[5],C=e[6]),y.useEffect(k,C);const N=o.onKeyboardShortcutsOpenChange;let _,A;e[7]!==N?(_=()=>{const Oe=function(Ke){Ct("keyboardShortcuts",Ke)&&(J2(document.activeElement)||(Ke.preventDefault(),N(!0)))};return window.addEventListener("keydown",Oe),()=>window.removeEventListener("keydown",Oe)},A=[N],e[7]=N,e[8]=_,e[9]=A):(_=e[8],A=e[9]),y.useEffect(_,A);const P=f===Tt;let T;e[10]!==P?(T={id:Tt,name:"This machine",isLocal:!0,isActive:P},e[10]=P,e[11]=T):T=e[11];let E;if(e[12]!==f||e[13]!==u||e[14]!==T){let Oe;e[16]!==f?(Oe=Ue=>({id:Ue.id,name:Ue.name,isLocal:!1,isActive:Ue.id===f}),e[16]=f,e[17]=Oe):Oe=e[17],E=[T,...u.map(Oe)],e[12]=f,e[13]=u,e[14]=T,e[15]=E}else E=e[15];const $=E;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 Oe=(d==null?void 0:d.agentKind)??$t((d==null?void 0:d.dirName)??null);Ur(eg(Oe,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,D=wP,O=o.processPanel,M=o.workflowsPanel,F=o.undoDialog,z=o.branchModal,L=a.claudeDir??"";let W;e[22]!==a.handleCloseConfigDialog||e[23]!==a.handleConfigSaved||e[24]!==a.showConfigDialog||e[25]!==L?(W=r.jsx(y.Suspense,{fallback:null,children:r.jsx(hP,{open:a.showConfigDialog,currentPath:L,onClose:a.handleCloseConfigDialog,onSaved:a.handleConfigSaved})}),e[22]=a.handleCloseConfigDialog,e[23]=a.handleConfigSaved,e[24]=a.showConfigDialog,e[25]=L,e[26]=W):W=e[26];const U=(d==null?void 0:d.dirName)??i.pendingDirName??null,H=(c==null?void 0:c.cwd)??i.pendingCwd??null;let K;e[27]!==a.defaultAgentKind||e[28]!==t.onStartNewFolder||e[29]!==t.onStartNewSession||e[30]!==t.panels.handleCloseProjectSwitcher||e[31]!==t.panels.showProjectSwitcher||e[32]!==U||e[33]!==H?(K=r.jsx(y.Suspense,{fallback:null,children:r.jsx(bP,{open:t.panels.showProjectSwitcher,onClose:t.panels.handleCloseProjectSwitcher,onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:a.defaultAgentKind,currentProjectDirName:U,currentProjectCwd:H})}),e[27]=a.defaultAgentKind,e[28]=t.onStartNewFolder,e[29]=t.onStartNewSession,e[30]=t.panels.handleCloseProjectSwitcher,e[31]=t.panels.showProjectSwitcher,e[32]=U,e[33]=H,e[34]=K):K=e[34];let V;e[35]!==t.panels.handleCloseThemeSelector||e[36]!==t.panels.showThemeSelector||e[37]!==l.setPreview||e[38]!==l.setTheme||e[39]!==l.theme?(V=r.jsx(y.Suspense,{fallback:null,children:r.jsx(vP,{open:t.panels.showThemeSelector,onClose:t.panels.handleCloseThemeSelector,currentTheme:l.theme,onSelectTheme:l.setTheme,onPreviewTheme:l.setPreview})}),e[35]=t.panels.handleCloseThemeSelector,e[36]=t.panels.showThemeSelector,e[37]=l.setPreview,e[38]=l.setTheme,e[39]=l.theme,e[40]=V):V=e[40];const Y=o.commandPaletteOpen,q=o.onCommandPaletteOpenChange,J=t.actions.handleGoHome,Q=t.panels.handleOpenProjectSwitcher,X=t.onOpenPaletteProject,Z=t.actions.handleDashboardSelect,te=t.panels.handleToggleSidebar;let ne,oe,re;e[41]!==t.panels?(ne=()=>t.panels.toggleWorkspacePanel(_t.sessionInfo),oe=()=>t.panels.toggleWorkspacePanel(_t.fileChanges),re=()=>t.panels.toggleWorkspacePanel(_t.worktrees),e[41]=t.panels,e[42]=ne,e[43]=oe,e[44]=re):(ne=e[42],oe=e[43],re=e[44]);const ae=t.panels.handleToggleMission,se=c?t.handlers.handleDuplicateSession:void 0,de=c?R:void 0,le=c?D:void 0,ce=ot("killAny")?o.onKillAll:void 0,me=ot("configWrite")?t.panels.handleToggleConfig:void 0,ue=a.openConfigDialog;let ie;e[45]!==N?(ie=()=>N(!0),e[45]=N,e[46]=ie):ie=e[46];const ge=s.currentCwd?s.onTogglePreview:void 0,pe=ot("hostFiles")&&s.currentCwd?s.onToggleProjectFiles:void 0;let xe;e[47]!==t.panels?(xe=ot("hostFiles")?()=>t.panels.toggleWorkspacePanel(_t.browser):void 0,e[47]=t.panels,e[48]=xe):xe=e[48];const Ce=t.panels.handleToggleThemeSelector,Te=s.onOpenTerminal,Ee=o.onFocusComposer,$e=o.onExpandAll,Re=o.onExpandToolPayloads,Fe=o.onCollapseAll,Le=!!(c||i.pendingDirName);let Ie;e[49]!==v||e[50]!==(c==null?void 0:c.cwd)||e[51]!==(d==null?void 0:d.dirName)||e[52]!==i.dashboardProject||e[53]!==i.pendingDirName?(Ie=ot("terminal")&&!!((c==null?void 0:c.cwd)??v??(d==null?void 0:d.dirName)??i.pendingDirName??i.dashboardProject),e[49]=v,e[50]=c==null?void 0:c.cwd,e[51]=d==null?void 0:d.dirName,e[52]=i.dashboardProject,e[53]=i.pendingDirName,e[54]=Ie):Ie=e[54];const _e=!!c;let je;e[55]!==s.hasFileChanges?(je=ot("hostFiles")&&s.hasFileChanges,e[55]=s.hasFileChanges,e[56]=je):je=e[56];const ze=t.panels.activeWorkspacePanel===_t.sessionInfo,Ne=t.panels.activeWorkspacePanel===_t.browser,Se=t.panels.activeWorkspacePanel===_t.fileChanges,he=t.panels.activeWorkspacePanel===_t.worktrees,De=i.mainView==="config",Be=i.mainView==="mission",We=(c==null?void 0:c.cwd)??v??null;let we;e[57]!==o.commandPaletteOpen||e[58]!==o.onCollapseAll||e[59]!==o.onCommandPaletteOpenChange||e[60]!==o.onExpandAll||e[61]!==o.onExpandToolPayloads||e[62]!==o.onFocusComposer||e[63]!==a.openConfigDialog||e[64]!==S||e[65]!==t.actions.handleDashboardSelect||e[66]!==t.actions.handleGoHome||e[67]!==t.onOpenPaletteProject||e[68]!==t.panels.handleOpenProjectSwitcher||e[69]!==t.panels.handleToggleMission||e[70]!==t.panels.handleToggleSidebar||e[71]!==t.panels.handleToggleThemeSelector||e[72]!==t.panels.showSidebar||e[73]!==$||e[74]!==s.launchTerminalRequest||e[75]!==s.onOpenTerminal||e[76]!==s.processPanel.addProcess||e[77]!==s.showProjectFiles||e[78]!==s.supportsWorktrees||e[79]!==ne||e[80]!==oe||e[81]!==re||e[82]!==se||e[83]!==de||e[84]!==le||e[85]!==ce||e[86]!==me||e[87]!==ie||e[88]!==ge||e[89]!==pe||e[90]!==xe||e[91]!==Le||e[92]!==Ie||e[93]!==_e||e[94]!==je||e[95]!==ze||e[96]!==Ne||e[97]!==Se||e[98]!==he||e[99]!==De||e[100]!==Be||e[101]!==We?(we=r.jsx(y.Suspense,{fallback:null,children:r.jsx(pP,{open:Y,onOpenChange:q,onGoHome:J,onNewSession:Q,onOpenProject:X,onOpenSession:Z,onToggleSidebar:te,onToggleStats:ne,onToggleFileChanges:oe,onToggleWorktrees:re,onToggleMissionControl:ae,onDuplicateSession:se,onCopyResumeCommand:de,onFindInConversation:le,onKillAll:ce,onOpenConfig:me,onOpenSettings:ue,onOpenKeyboardShortcuts:ie,onTogglePreview:ge,onToggleProjectFiles:pe,onToggleBrowser:xe,onOpenTheme:Ce,onOpenTerminal:Te,onOpenDevices:b?p:void 0,onSwitchDevice:Ss,devices:$,onFocusComposer:Ee,onExpandAll:$e,onExpandToolPayloads:Re,onCollapseAll:Fe,canFocusComposer:Le,canOpenTerminal:Ie,hasSession:_e,hasFileChanges:je,supportsWorktrees:s.supportsWorktrees,showSidebar:t.panels.showSidebar,showStats:ze,showProjectFiles:s.showProjectFiles,showBrowser:Ne,showFileChanges:Se,showWorktrees:he,showConfig:De,showMission:Be,currentProjectDirName:S,projectCwd:We,onProcessStarted:s.processPanel.addProcess,launchTerminalRequest:s.launchTerminalRequest})}),e[57]=o.commandPaletteOpen,e[58]=o.onCollapseAll,e[59]=o.onCommandPaletteOpenChange,e[60]=o.onExpandAll,e[61]=o.onExpandToolPayloads,e[62]=o.onFocusComposer,e[63]=a.openConfigDialog,e[64]=S,e[65]=t.actions.handleDashboardSelect,e[66]=t.actions.handleGoHome,e[67]=t.onOpenPaletteProject,e[68]=t.panels.handleOpenProjectSwitcher,e[69]=t.panels.handleToggleMission,e[70]=t.panels.handleToggleSidebar,e[71]=t.panels.handleToggleThemeSelector,e[72]=t.panels.showSidebar,e[73]=$,e[74]=s.launchTerminalRequest,e[75]=s.onOpenTerminal,e[76]=s.processPanel.addProcess,e[77]=s.showProjectFiles,e[78]=s.supportsWorktrees,e[79]=ne,e[80]=oe,e[81]=re,e[82]=se,e[83]=de,e[84]=le,e[85]=ce,e[86]=me,e[87]=ie,e[88]=ge,e[89]=pe,e[90]=xe,e[91]=Le,e[92]=Ie,e[93]=_e,e[94]=je,e[95]=ze,e[96]=Ne,e[97]=Se,e[98]=he,e[99]=De,e[100]=Be,e[101]=We,e[102]=we):we=e[102];let Me;e[103]!==o.keyboardShortcutsOpen||e[104]!==N?(Me=r.jsx(y.Suspense,{fallback:null,children:r.jsx(xP,{open:o.keyboardShortcutsOpen,onOpenChange:N})}),e[103]=o.keyboardShortcutsOpen,e[104]=N,e[105]=Me):Me=e[105];let fe;e[106]!==m||e[107]!==j?(fe=b&&j!==null&&r.jsx(y.Suspense,{fallback:null,children:r.jsx(gP,{open:m!==null,initialMode:j,onClose:()=>p(null),onCloseComplete:()=>g(null)})}),e[106]=m,e[107]=j,e[108]=fe):fe=e[108];let ve;return e[109]!==o.branchModal||e[110]!==o.processPanel||e[111]!==o.undoDialog||e[112]!==o.workflowsPanel||e[113]!==W||e[114]!==K||e[115]!==V||e[116]!==we||e[117]!==Me||e[118]!==fe?(ve=r.jsxs(r.Fragment,{children:[O,M,F,z,W,K,V,we,Me,fe]}),e[109]=o.branchModal,e[110]=o.processPanel,e[111]=o.undoDialog,e[112]=o.workflowsPanel,e[113]=W,e[114]=K,e[115]=V,e[116]=we,e[117]=Me,e[118]=fe,e[119]=ve):ve=e[119],ve}function wP(){window.dispatchEvent(new Event(nd))}function oc(n){const e=B.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(Mt,{render:o,children:s}),e[2]=s,e[3]=o,e[4]=i):i=e[4];let a;e[5]!==t?(a=r.jsx(Ot,{children:t}),e[5]=t,e[6]=a):a=e[6];let l;return e[7]!==i||e[8]!==a?(l=r.jsxs(It,{children:[i,a]}),e[7]=i,e[8]=a,e[9]=l):l=e[9],l}const jP="2.6.1",sb={version:jP},SP=sb.version,NP=19384,kP=443,CP=450,_P=typeof navigator<"u"&&/Mac|iPhone|iPad/i.test(navigator.platform||""),TP=`${_P?"⌘⇧":"Ctrl+Shift+"}1–9`,EP=new Set(["BAD_PASSWORD","PASSWORD_REQUIRED","USERNAME_REQUIRES_PASSWORD"]),AP=new Set(["ACCOUNT_DISABLED"]);function sr(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 ob(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 rb={ok:"text-success",warn:"text-warning",info:"text-info",error:"text-destructive"};function PP(n){const e=B.c(10),{tone:t}=n,s=rb[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(Wn,{"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(gn,{"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(Pt,{"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(Ys,{"data-icon":"inline-start",className:i}),e[8]=i,e[9]=a):a=e[9],a}const $P={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"};function RP({device:n,hubVersion:e,onRename:t,onCredentials:s,onRemove:o,onTest:i}){const[a,l]=y.useState(!1),[c,d]=y.useState(n.name),[u,f]=y.useState(!1),[m,p]=y.useState(n.username??""),[h,g]=y.useState(""),[x,b]=y.useState(null),[w,v]=y.useState(!1),[S,j]=y.useState(null);y.useEffect(()=>{d(n.name)},[n.name]),y.useEffect(()=>{p(n.username??"")},[n.username]);const k=tb(n),C=k!==void 0&&k!==e,N=aP(n)==="team";async function _(){const P=c.trim();if(!P||P===n.name){l(!1),d(n.name);return}j("rename"),await t(n.id,P),j(null),l(!1)}async function A(){const P=m.trim(),T=n.username??"",E=P!==T,$=h.length>0;if(!E&&!$){f(!1),g(""),b(null);return}if(n.auth==="none"&&!$){b("Enter a password when adding an account to an unauthenticated device.");return}const I={};E&&(I.username=P||null),$&&(I.password=h),j("credentials"),b(null);const R=await s(n.id,I);if(j(null),!R.ok){b(R.error);return}f(!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",$P[n.runtime.authState])}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[a?r.jsx(Dt,{value:c,autoFocus:!0,"aria-label":`Rename ${n.name}`,onChange:P=>d(P.target.value),onKeyDown:P=>{P.key==="Enter"&&_(),P.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}),k&&r.jsxs("span",{className:G("shrink-0 font-mono text-xs",C?"text-warning":"text-muted-foreground"),title:C?`Device runs v${k}; hub runs v${e}`:void 0,children:["v",k,C&&" ≠ hub"]}),n.auth==="none"&&r.jsx(Pe,{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]}):N?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(ee,{variant:"ghost",size:"icon-sm","aria-label":`Re-test ${n.name}`,disabled:S==="test",onClick:async()=>{j("test"),await i(n.id),j(null)},children:r.jsx(Pt,{"data-icon":"inline-start",className:G(S==="test"&&"animate-spin")})}),r.jsx(ee,{variant:"ghost",size:"icon-sm","aria-label":`Edit account for ${n.name}`,onClick:()=>{f(P=>!P),p(n.username??""),g(""),b(null)},children:r.jsx(Td,{"data-icon":"inline-start"})}),r.jsx(ee,{variant:"ghost",size:"icon-sm","aria-label":`Rename ${n.name}`,onClick:()=>l(!0),children:r.jsx(Vs,{"data-icon":"inline-start"})}),r.jsxs(Gd,{open:w,onOpenChange:P=>{S!=="remove"&&v(P)},children:[r.jsx(TN,{render:r.jsx(ee,{variant:"ghost",size:"icon-sm","aria-label":`Remove ${n.name}`,className:"text-destructive hover:bg-destructive/10 hover:text-destructive"}),children:r.jsx(Ta,{"data-icon":"inline-start"})}),r.jsxs(Yd,{size:"sm",children:[r.jsxs(Xd,{children:[r.jsxs(Qd,{children:["Remove ",n.name,"?"]}),r.jsx(Zd,{children:"This device will disappear from Cogpit. You can add it again later."})]}),r.jsxs(Jd,{children:[r.jsx(tu,{disabled:S==="remove",children:"Cancel"}),r.jsxs(eu,{variant:"destructive",disabled:S==="remove",onClick:async()=>{j("remove");try{await o(n.id)}finally{j(null)}},children:[S==="remove"&&r.jsx(rt,{"data-icon":"inline-start",className:"animate-spin"}),"Remove device"]})]})]})]})]})]}),u&&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(jt,{children:[r.jsxs(St,{htmlFor:`device-username-${n.id}`,children:["Username ",r.jsx("span",{className:"text-muted-foreground/60",children:"(team devices)"})]}),r.jsx(Dt,{id:`device-username-${n.id}`,"aria-label":`Username for ${n.name}`,value:m,onChange:P=>p(P.target.value),placeholder:"Leave empty for password-only auth",autoComplete:"off",spellCheck:!1})]}),r.jsxs(jt,{children:[r.jsxs(St,{htmlFor:`device-password-${n.id}`,children:["New password ",r.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),r.jsx(Dt,{id:`device-password-${n.id}`,"aria-label":`New password for ${n.name}`,type:"password",value:h,onChange:P=>g(P.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(bs,{children:x}),r.jsxs("div",{className:"flex justify-end gap-1.5",children:[r.jsx(ee,{variant:"outline",size:"sm",onClick:()=>{f(!1),p(n.username??""),g(""),b(null)},children:"Cancel"}),r.jsx(ee,{size:"sm",disabled:S==="credentials",onClick:()=>void A(),children:S==="credentials"?r.jsx(rt,{"data-icon":"inline-start",className:"animate-spin"}):"Save account"})]})]})]})}function ib(n){var Ke,Ze;const e=B.c(118),{open:t,initialMode:s,onClose:o,onCloseComplete:i}=n,{devices:a,refresh:l,probe:c,addDevice:d,updateDevice:u,removeDevice:f,testDevice:m}=ul(),[p,h]=y.useState(""),[g,x]=y.useState(""),[b,w]=y.useState(""),[v,S]=y.useState(""),[j,k]=y.useState(!1),[C,N]=y.useState(!1),[_,A]=y.useState(null),[P,T]=y.useState(!1),[E,$]=y.useState(null),I=y.useRef(null),R=y.useRef(0);let D,O;e[0]!==s||e[1]!==t?(D=()=>{t&&(h(""),x(""),w(""),S(""),k(!1),N(!1),A(null),$(null),s==="add"&&requestAnimationFrame(()=>{var He;return(He=I.current)==null?void 0:He.focus()}))},O=[t,s],e[0]=s,e[1]=t,e[2]=D,e[3]=O):(D=e[2],O=e[3]),y.useEffect(D,O);let M;e[4]!==j||e[5]!==g||e[6]!==c?(M=async()=>{const{host:He,port:Ye,tls:At}=sr(g);if(!He){A(null),N(!1);return}const Vn=R.current=R.current+1;N(!0);const qt=await c(He,Ye,j,At);Vn===R.current&&(A({...ob(qt,He,Ye??(At?kP:NP)),hello:qt.ok?qt.hello:void 0}),N(!1))},e[4]=j,e[5]=g,e[6]=c,e[7]=M):M=e[7];const F=M;let z,L;e[8]!==g||e[9]!==t||e[10]!==F?(z=()=>{if(!t)return;if(!sr(g).host){A(null),N(!1);return}const He=window.setTimeout(()=>void F(),CP);return()=>window.clearTimeout(He)},L=[t,g,F],e[8]=g,e[9]=t,e[10]=F,e[11]=z,e[12]=L):(z=e[11],L=e[12]),y.useEffect(z,L);const W=((Ke=_==null?void 0:_.hello)==null?void 0:Ke.edition)==="team",U=W&&((Ze=_==null?void 0:_.hello)==null?void 0:Ze.needsBootstrap)===!0,H=W||!j;let K;e:{if(P){K=!1;break e}if(!sr(g).host){K=!1;break e}if(C||!_){K=!1;break e}if(U){K=!1;break e}if(H&&!v){K=!1;break e}if(W&&!b.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]!==j||e[15]!==H||e[16]!==g||e[17]!==p||e[18]!==o||e[19]!==v||e[20]!==W||e[21]!==b?(Y=async function(){const{host:Ye,port:At,tls:Vn}=sr(g);if(!Ye)return;T(!0),$(null);const qt=await d({name:p.trim()||void 0,host:Ye,port:At,tls:Vn,username:W?b.trim():void 0,password:H&&v||void 0,allowLocalTunnel:j});if(T(!1),qt.ok){o(),Ss(qt.device.id);return}$({field:AP.has(qt.code)?"username":EP.has(qt.code)?"password":"host",message:qt.error})},e[13]=d,e[14]=j,e[15]=H,e[16]=g,e[17]=p,e[18]=o,e[19]=v,e[20]=W,e[21]=b,e[22]=Y):Y=e[22];const q=Y;let J;e[23]!==u?(J=async(He,Ye)=>{await u(He,{name:Ye})},e[23]=u,e[24]=J):J=e[24];const Q=J;let X;e[25]!==f?(X=async He=>{await f(He)},e[25]=f,e[26]=X):X=e[26];const Z=X;let te;e[27]!==l||e[28]!==m?(te=async He=>{await m(He),await l()},e[27]=l,e[28]=m,e[29]=te):te=e[29];const ne=te;let oe;e[30]!==o?(oe=He=>{He||o()},e[30]=o,e[31]=oe):oe=e[31];let re;e[32]!==i?(re=He=>{He||i==null||i()},e[32]=i,e[33]=re):re=e[33];let ae;e[34]===Symbol.for("react.memo_cache_sentinel")?(ae=r.jsxs(Ps,{children:[r.jsx(is,{children:"Devices"}),r.jsxs(as,{children:["Control another Cogpit device from here. The active device is chosen from the header switcher — ",TP," jumps between devices."]})]}),e[34]=ae):ae=e[34];let se;e[35]!==a||e[36]!==Z||e[37]!==Q||e[38]!==ne||e[39]!==u?(se=a.length>0&&r.jsx("div",{className:"flex flex-col gap-2",children:a.map(He=>r.jsx(RP,{device:He,hubVersion:SP,onRename:Q,onCredentials:u,onRemove:Z,onTest:ne},He.id))}),e[35]=a,e[36]=Z,e[37]=Q,e[38]=ne,e[39]=u,e[40]=se):se=e[40];let de;e[41]===Symbol.for("react.memo_cache_sentinel")?(de=r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Fn,{"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]=de):de=e[41];const le=(E==null?void 0:E.field)==="host";let ce,me;e[42]===Symbol.for("react.memo_cache_sentinel")?(ce=r.jsx(St,{htmlFor:"device-host",children:"Host"}),me=r.jsx(Eo,{children:"Enter a local address or an HTTPS URL."}),e[42]=ce,e[43]=me):(ce=e[42],me=e[43]);let ue;e[44]===Symbol.for("react.memo_cache_sentinel")?(ue=He=>{R.current=R.current+1,x(He.target.value),w(""),A(null),$(null)},e[44]=ue):ue=e[44];let ie;e[45]!==F?(ie=()=>void F(),e[45]=F,e[46]=ie):ie=e[46];let ge;e[47]!==g||e[48]!==ie?(ge=r.jsx(Dt,{id:"device-host",ref:I,value:g,onChange:ue,onBlur:ie,placeholder:"192.168.1.42, my-mac.local:19384 or https://cogpit.example.com",spellCheck:!1,autoComplete:"off"}),e[47]=g,e[48]=ie,e[49]=ge):ge=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 xe;e[52]!==_||e[53]!==C?(xe=!C&&_&&r.jsxs("p",{role:"status",className:G("flex items-center gap-1.5 text-xs",rb[_.tone]),children:[r.jsx(PP,{tone:_.tone}),_.text]}),e[52]=_,e[53]=C,e[54]=xe):xe=e[54];let Ce;e[55]!==E?(Ce=(E==null?void 0:E.field)==="host"&&r.jsx(bs,{children:E.message}),e[55]=E,e[56]=Ce):Ce=e[56];let Te;e[57]!==le||e[58]!==ge||e[59]!==pe||e[60]!==xe||e[61]!==Ce?(Te=r.jsxs(jt,{"data-invalid":le,children:[ce,me,ge,pe,xe,Ce]}),e[57]=le,e[58]=ge,e[59]=pe,e[60]=xe,e[61]=Ce,e[62]=Te):Te=e[62];let Ee;e[63]===Symbol.for("react.memo_cache_sentinel")?(Ee=r.jsxs(St,{htmlFor:"device-name",children:["Name ",r.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),e[63]=Ee):Ee=e[63];let $e;e[64]===Symbol.for("react.memo_cache_sentinel")?($e=He=>h(He.target.value),e[64]=$e):$e=e[64];let Re;e[65]!==p?(Re=r.jsxs(jt,{children:[Ee,r.jsx(Dt,{id:"device-name",value:p,onChange:$e,placeholder:"Defaults to the device's own name"})]}),e[65]=p,e[66]=Re):Re=e[66];let Fe;e[67]!==E||e[68]!==W||e[69]!==b?(Fe=W&&r.jsxs(jt,{"data-invalid":(E==null?void 0:E.field)==="username",children:[r.jsx(St,{htmlFor:"device-username",children:"Username"}),r.jsx(Dt,{id:"device-username",value:b,onChange:He=>w(He.target.value),placeholder:"Team account username",autoComplete:"username",spellCheck:!1}),r.jsx(Eo,{children:"Requests through this hub will act as this account on the team server."}),(E==null?void 0:E.field)==="username"&&r.jsx(bs,{children:E.message})]}),e[67]=E,e[68]=W,e[69]=b,e[70]=Fe):Fe=e[70];let Le;e[71]!==H||e[72]!==v||e[73]!==E||e[74]!==W?(Le=H&&r.jsxs(jt,{"data-invalid":(E==null?void 0:E.field)==="password",children:[r.jsx(St,{htmlFor:"device-password",children:"Password"}),r.jsx(Dt,{id:"device-password",type:"password",value:v,onChange:He=>S(He.target.value),placeholder:W?"Password for that team account":"Network access password for that device",autoComplete:W?"current-password":"off"}),(E==null?void 0:E.field)==="password"&&r.jsx(bs,{children:E.message})]}),e[71]=H,e[72]=v,e[73]=E,e[74]=W,e[75]=Le):Le=e[75];let Ie;e[76]!==Te||e[77]!==Re||e[78]!==Fe||e[79]!==Le?(Ie=r.jsxs(Mo,{children:[Te,Re,Fe,Le]}),e[76]=Te,e[77]=Re,e[78]=Fe,e[79]=Le,e[80]=Ie):Ie=e[80];let _e;e[81]===Symbol.for("react.memo_cache_sentinel")?(_e=He=>{R.current=R.current+1,k(He===!0),A(null),$(null)},e[81]=_e):_e=e[81];let je;e[82]!==j?(je=r.jsx(ix,{id:"device-local-tunnel",name:"device-local-tunnel",checked:j,onCheckedChange:_e}),e[82]=j,e[83]=je):je=e[83];const ze=W?"":" — no password";let Ne;e[84]!==ze?(Ne=r.jsxs(St,{htmlFor:"device-local-tunnel",children:["This is a local tunnel",ze]}),e[84]=ze,e[85]=Ne):Ne=e[85];let Se;e[86]!==je||e[87]!==Ne?(Se=r.jsxs(jt,{orientation:"horizontal",children:[je,Ne]}),e[86]=je,e[87]=Ne,e[88]=Se):Se=e[88];let he;e[89]!==j||e[90]!==W?(he=j&&r.jsxs(pt,{className:"border-warning/40 bg-warning/10 text-warning",children:[r.jsx(dw,{}),r.jsx(ht,{className:"text-warning",children:W?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]=j,e[90]=W,e[91]=he):he=e[91];let De;e[92]!==o?(De=r.jsx(ee,{variant:"outline",onClick:o,children:"Close"}),e[92]=o,e[93]=De):De=e[93];const Be=!V;let We;e[94]!==q?(We=()=>void q(),e[94]=q,e[95]=We):We=e[95];let we;e[96]!==P?(we=P?r.jsxs(r.Fragment,{children:[r.jsx(rt,{"data-icon":"inline-start",className:"size-4 animate-spin"})," Adding…"]}):"Add device",e[96]=P,e[97]=we):we=e[97];let Me;e[98]!==Be||e[99]!==We||e[100]!==we?(Me=r.jsx(ee,{disabled:Be,onClick:We,children:we}),e[98]=Be,e[99]=We,e[100]=we,e[101]=Me):Me=e[101];let fe;e[102]!==De||e[103]!==Me?(fe=r.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[De,Me]}),e[102]=De,e[103]=Me,e[104]=fe):fe=e[104];let ve;e[105]!==Ie||e[106]!==Se||e[107]!==he||e[108]!==fe?(ve=r.jsxs("div",{className:"flex flex-col gap-4 border-t pt-4",children:[de,Ie,Se,he,fe]}),e[105]=Ie,e[106]=Se,e[107]=he,e[108]=fe,e[109]=ve):ve=e[109];let Oe;e[110]!==se||e[111]!==ve?(Oe=r.jsxs(rs,{className:"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-xl",children:[ae,se,ve]}),e[110]=se,e[111]=ve,e[112]=Oe):Oe=e[112];let Ue;return e[113]!==t||e[114]!==oe||e[115]!==re||e[116]!==Oe?(Ue=r.jsx(os,{open:t,onOpenChange:oe,onOpenChangeComplete:re,children:Oe}),e[113]=t,e[114]=oe,e[115]=re,e[116]=Oe,e[117]=Ue):Ue=e[117],Ue}const IP=Object.freeze(Object.defineProperty({__proto__:null,DevicesDialog:ib,parseHostPort:sr,probeMessage:ob},Symbol.toStringTag,{value:"Module"})),yh=sb.version,MP={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"},wh={ok:"Reachable",unknown:"Not reachable","bad-password":"Password rejected"};function OP(n){const e=B.c(6),{state:t}=n,s=wh[t],o=wh[t],i=MP[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 Hu(n){const e=B.c(50),{compact:t}=n,s=t===void 0?!1:t,{devices:o,activeDeviceId:i,activeDevice:a,refresh:l,testDevice:c}=ul(),[d,u]=y.useState(null),f=(a==null?void 0:a.name)??"This machine",m=i!==Tt;let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=ot("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(L=>c(L.id).catch(LP))).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 b=s?"sm":"xs",w=s&&"h-10";let v;e[5]!==w?(v=G("max-w-40 justify-start",w),e[5]=w,e[6]=v):v=e[6];let S;e[7]!==b||e[8]!==v?(S=r.jsx(ee,{variant:"ghost",size:b,"aria-label":"Switch device",className:v}),e[7]=b,e[8]=v,e[9]=S):S=e[9];let j;e[10]!==m?(j=m?r.jsx(I1,{"data-icon":"inline-start"}):r.jsx(fm,{"data-icon":"inline-start"}),e[10]=m,e[11]=j):j=e[11];let k;e[12]!==f?(k=r.jsx("span",{className:"truncate",children:f}),e[12]=f,e[13]=k):k=e[13];let C;e[14]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(it,{"data-icon":"inline-end",className:"opacity-60"}),e[14]=C):C=e[14];let N;e[15]!==S||e[16]!==j||e[17]!==k?(N=r.jsxs(Lo,{render:S,children:[j,k,C]}),e[15]=S,e[16]=j,e[17]=k,e[18]=N):N=e[18];let _;e[19]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(Bg,{children:"Devices"}),e[19]=_):_=e[19];let A,P;e[20]===Symbol.for("react.memo_cache_sentinel")?(A=r.jsx(fm,{}),P=r.jsx("span",{className:"flex-1 truncate",children:"This machine"}),e[20]=A,e[21]=P):(A=e[20],P=e[21]);let T;e[22]!==m?(T=!m&&r.jsx(dt,{className:"ml-auto text-success"}),e[22]=m,e[23]=T):T=e[23];let E;e[24]!==T?(E=r.jsxs(Wt,{onClick:DP,children:[A,P,T]}),e[24]=T,e[25]=E):E=e[25];let $;if(e[26]!==i||e[27]!==s||e[28]!==o){let z;e[30]!==i||e[31]!==s?(z=L=>{const W=tb(L),U=W!==void 0&&W!==yh,H=L.id===i;return r.jsxs(Wt,{onClick:()=>Ss(L.id),className:G(s&&"min-h-10"),children:[r.jsx(OP,{state:L.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:L.name}),U&&r.jsxs("span",{className:"shrink-0 font-mono text-xs text-warning",title:`Device runs v${W}; hub runs v${yh}`,children:["v",W]})]}),r.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:[L.host,":",L.port,L.auth==="none"&&" · unauthenticated"]})]}),H&&r.jsx(dt,{className:"ml-auto text-success"})]},L.id)},e[30]=i,e[31]=s,e[32]=z):z=e[32],$=o.map(z),e[26]=i,e[27]=s,e[28]=o,e[29]=$}else $=e[29];let I;e[33]!==E||e[34]!==$?(I=r.jsxs(Zn,{children:[_,E,$]}),e[33]=E,e[34]=$,e[35]=I):I=e[35];let R;e[36]!==o.length?(R=h&&r.jsxs(r.Fragment,{children:[r.jsx(oa,{}),r.jsxs(Zn,{children:[r.jsxs(Wt,{onClick:()=>u("add"),children:[r.jsx(Fn,{}),r.jsx("span",{children:"Add device…"})]}),o.length>0&&r.jsxs(Wt,{onClick:()=>u("manage"),children:[r.jsx(jd,{}),r.jsx("span",{children:"Manage devices…"})]})]})]}),e[36]=o.length,e[37]=R):R=e[37];let D;e[38]!==I||e[39]!==R?(D=r.jsxs(zo,{align:"end",sideOffset:6,className:"w-64",children:[I,R]}),e[38]=I,e[39]=R,e[40]=D):D=e[40];let O;e[41]!==x||e[42]!==N||e[43]!==D?(O=r.jsxs(Do,{onOpenChange:x,children:[N,D]}),e[41]=x,e[42]=N,e[43]=D,e[44]=O):O=e[44];let M;e[45]!==d?(M=h&&r.jsx(ib,{open:d!==null,initialMode:d??"manage",onClose:()=>u(null)}),e[45]=d,e[46]=M):M=e[46];let F;return e[47]!==O||e[48]!==M?(F=r.jsxs(r.Fragment,{children:[O,M]}),e[47]=O,e[48]=M,e[49]=F):F=e[49],F}function DP(){return Ss(Tt)}function LP(){return null}const zP=6e4;function FP(){const[n,e]=y.useState([]),[t,s]=y.useState(!1),o=y.useRef(!1),i=y.useCallback(async()=>{if(!o.current){o.current=!0;try{const l=await be("/api/system-processes");if(l.ok){const c=await l.json();e((c.processes??[]).filter(d=>d.suspectedLeak))}}catch{}finally{o.current=!1}}},[]),a=y.useCallback(async l=>{if(l.length!==0){s(!0);try{await be("/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 y.useEffect(()=>{i();const l=window.setInterval(()=>{document.visibilityState==="visible"&&i()},zP);return()=>window.clearInterval(l)},[i]),{leaks:n,killing:t,killLeaks:a,refresh:i}}const BP=6e4;function UP(){const n=B.c(29),{leaks:e,killing:t,killLeaks:s,refresh:o}=FP(),[i,a]=y.useState(!1),l=e.length>0,c=e.reduce(qP,0);let d,u;if(n[0]!==l?(d=()=>{if(l){a(!0);return}const T=window.setTimeout(()=>a(!1),BP);return()=>window.clearTimeout(T)},u=[l],n[0]=l,n[1]=d,n[2]=u):(d=n[1],u=n[2]),y.useEffect(d,u),!l&&!i)return null;const f=It,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(HP)):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 b;n[10]!==t||n[11]!==m||n[12]!==p||n[13]!==h||n[14]!==x?(b=r.jsx(ee,{variant:m,size:"xs","aria-label":p,onClick:h,disabled:t,className:x}),n[10]=t,n[11]=m,n[12]=p,n[13]=h,n[14]=x,n[15]=b):b=n[15];let w;n[16]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(uw,{"data-icon":"inline-start"}),n[16]=w):w=n[16];const v=t?"…":e.length;let S;n[17]!==v?(S=r.jsx("span",{className:"tabular-nums",children:v}),n[17]=v,n[18]=S):S=n[18];let j;n[19]!==S||n[20]!==b?(j=r.jsxs(Mt,{render:b,children:[w,S]}),n[19]=S,n[20]=b,n[21]=j):j=n[21];const k=Ot,C="bottom",N="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(WP),e.length>6&&r.jsxs("div",{className:"text-xs text-muted-foreground",children:["+",e.length-6," more"]}),r.jsx(Nt,{}),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 A;n[22]!==k||n[23]!==_?(A=r.jsx(k,{side:C,className:N,children:_}),n[22]=k,n[23]=_,n[24]=A):A=n[24];let P;return n[25]!==f||n[26]!==j||n[27]!==A?(P=r.jsxs(f,{children:[j,A]}),n[25]=f,n[26]=j,n[27]=A,n[28]=P):P=n[28],P}function WP(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," · ",Fd(n.ageSeconds)]}),r.jsxs("span",{className:"shrink-0 font-semibold text-destructive",children:[n.cpuPercent.toFixed(0),"%"]})]},n.pid)}function HP(n){return n.pid}function qP(n,e){return n+e.cpuPercent}const KP=15e3;function VP(){const n=B.c(12);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],n[0]=e):e=n[0];const[t,s]=y.useState(e);let o;n[1]===Symbol.for("react.memo_cache_sentinel")?(o=async()=>{try{const b=await be("/api/notifications?limit=100");if(!b.ok)return;const w=await b.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 b=window.setInterval(()=>void i(),KP);return()=>window.clearInterval(b)},l=[i],n[2]=a,n[3]=l):(a=n[2],l=n[3]),y.useEffect(a,l);let c;n[4]===Symbol.for("react.memo_cache_sentinel")?(c=async(b,w)=>{const v=new Date().toISOString();s(S=>S.map(j=>j.readAt===null&&w(j)?{...j,readAt:v}:j));try{await be("/api/notifications/read",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)})}catch{}},n[4]=c):c=n[4];const d=c;let u;n[5]===Symbol.for("react.memo_cache_sentinel")?(u=async b=>d({ids:b},w=>b.includes(w.id)),n[5]=u):u=n[5];const f=u;let m;n[6]===Symbol.for("react.memo_cache_sentinel")?(m=async()=>d({all:!0},YP),n[6]=m):m=n[6];const p=m;let h;n[7]!==t?(h=t.filter(GP),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:f,markAllRead:p},n[9]=t,n[10]=g,n[11]=x):x=n[11],x}function GP(n){return n.readAt===null}function YP(){return!0}function ab(n){window.history.pushState({},"",n),window.dispatchEvent(new PopStateEvent("popstate"))}function XP(){const n=B.c(30),{notifications:e,unreadCount:t,refresh:s,markRead:o,markAllRead:i}=VP(),[a,l]=y.useState(!1);let c;n[0]!==o?(c=function(N){if(o([N.id]),!N.dirName||!N.sessionId)return;const _=vt(),A=_===Tt?"":`/d/${_}`;ab(`${A}/${encodeURIComponent(N.dirName)}/${encodeURIComponent(N.sessionId)}`),l(!1)},n[0]=o,n[1]=c):c=n[1];const d=c;let u;n[2]!==s?(u=C=>{l(C),C&&s()},n[2]=s,n[3]=u):u=n[3];const f=a?"secondary":"ghost",m=t>0?`Notifications, ${t} unread`:"Notifications";let p;n[4]!==f||n[5]!==m?(p=r.jsx(ee,{type:"button",variant:f,size:"icon-sm",className:"relative","aria-label":m}),n[4]=f,n[5]=m,n[6]=p):p=n[6];let h;n[7]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(mm,{"data-icon":"inline-start"}),n[7]=h):h=n[7];let g;n[8]!==t?(g=t>0&&r.jsx(Pe,{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(Lo,{render:p,children:[h,g]}),n[10]=p,n[11]=g,n[12]=x):x=n[12];let b;n[13]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx("span",{className:"text-sm font-medium",children:"Notifications"}),n[13]=b):b=n[13];let w;n[14]!==i||n[15]!==t?(w=t>0&&r.jsxs(ee,{variant:"ghost",size:"xs",onClick:()=>void i(),children:[r.jsx(fw,{"data-icon":"inline-start"}),"Mark all read"]}),n[14]=i,n[15]=t,n[16]=w):w=n[16];let v;n[17]!==w?(v=r.jsxs("div",{className:"flex h-11 items-center justify-between border-b px-3",children:[b,w]}),n[17]=w,n[18]=v):v=n[18];let S;n[19]!==e||n[20]!==d?(S=r.jsx("div",{className:"max-h-96 overflow-y-auto",children:e.length===0?r.jsx(ln,{className:"min-h-40 p-6",children:r.jsxs(cn,{children:[r.jsx(bn,{variant:"icon",children:r.jsx(mm,{})}),r.jsx(dn,{children:"No notifications"}),r.jsx(vn,{children:"Session updates will appear here."})]})}):r.jsx(Zn,{children:e.map(C=>r.jsx(JP,{notification:C,onOpen:d},C.id))})}),n[19]=e,n[20]=d,n[21]=S):S=n[21];let j;n[22]!==v||n[23]!==S?(j=r.jsxs(zo,{align:"end",sideOffset:6,className:"w-80 overflow-hidden p-0",children:[v,S]}),n[22]=v,n[23]=S,n[24]=j):j=n[24];let k;return n[25]!==a||n[26]!==u||n[27]!==j||n[28]!==x?(k=r.jsxs(Do,{open:a,onOpenChange:u,children:[x,j]}),n[25]=a,n[26]=u,n[27]=j,n[28]=x,n[29]=k):k=n[29],k}function JP(n){const e=B.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"?Yt:Ia;let u;e[2]!==t||e[3]!==s?(u=()=>s(t),e[2]=t,e[3]=s,e[4]=u):u=e[4];const f=!i&&"cursor-default",m=o&&"bg-accent/50";let p;e[5]!==f||e[6]!==m?(p=G("rounded-none border-b px-3 py-2.5 last:border-b-0",f,m),e[5]=f,e[6]=m,e[7]=p):p=e[7];const h=t.kind==="permission"?"text-warning":"text-info";let g;e[8]!==h?(g=G("mt-0.5",h),e[8]=h,e[9]=g):g=e[9];let x;e[10]!==d||e[11]!==g?(x=r.jsx(d,{className:g}),e[10]=d,e[11]=g,e[12]=x):x=e[12];const b=o?"font-medium text-foreground":"text-muted-foreground";let w;e[13]!==b?(w=G("truncate text-xs",b),e[13]=b,e[14]=w):w=e[14];let v;e[15]!==t.title||e[16]!==w?(v=r.jsx("span",{className:w,children:t.title}),e[15]=t.title,e[16]=w,e[17]=v):v=e[17];let S;e[18]!==c?(S=Fd(c),e[18]=c,e[19]=S):S=e[19];let j;e[20]!==S?(j=r.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:S}),e[20]=S,e[21]=j):j=e[21];let k;e[22]!==v||e[23]!==j?(k=r.jsxs("span",{className:"flex items-baseline justify-between gap-2",children:[v,j]}),e[22]=v,e[23]=j,e[24]=k):k=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 N;e[27]!==k||e[28]!==C?(N=r.jsxs("span",{className:"min-w-0 flex-1",children:[k,C]}),e[27]=k,e[28]=C,e[29]=N):N=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 A;return e[32]!==N||e[33]!==_||e[34]!==u||e[35]!==p||e[36]!==x?(A=r.jsxs(Wt,{onClick:u,className:p,children:[x,N,_]}),e[32]=N,e[33]=_,e[34]=u,e[35]=p,e[36]=x,e[37]=A):A=e[37],A}const QP=2e3;function $o(n){return`${n.toFixed(n<10?1:0)}%`}function xa(n){return`${n.toFixed(0)} MB`}function ZP(n){return n>=10?`${n.toFixed(0)}/s`:n>=1?`${n.toFixed(1)}/s`:`${n.toFixed(2)}/s`}function e$(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 t$(n){const e=B.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(Pe,{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(Pe,{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(Pe,{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 u;e[16]!==c||e[17]!==d?(u=r.jsxs("div",{className:"min-w-0 flex-1",children:[c,d]}),e[16]=c,e[17]=d,e[18]=u):u=e[18];let f;e[19]!==t.pid||e[20]!==t.suspectedLeak||e[21]!==s?(f=t.suspectedLeak&&s&&r.jsx(ee,{variant:"destructive",size:"xs",className:"shrink-0",onClick:()=>s(t.pid),children:"Kill"}),e[19]=t.pid,e[20]=t.suspectedLeak,e[21]=s,e[22]=f):f=e[22];const m=t.cpuPercent>=20&&"text-destructive";let p;e[23]!==m?(p=G("font-mono text-sm font-semibold tabular-nums",m),e[23]=m,e[24]=p):p=e[24];let h;e[25]!==t.cpuPercent?(h=$o(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=xa(t.memoryMb),e[30]=t.memoryMb,e[31]=x):x=e[31];let b;e[32]!==t.ageSeconds?(b=Fd(t.ageSeconds),e[32]=t.ageSeconds,e[33]=b):b=e[33];let w;e[34]!==x||e[35]!==b?(w=r.jsxs("div",{className:"text-xs text-muted-foreground",children:[x," · ",b]}),e[34]=x,e[35]=b,e[36]=w):w=e[36];let v;e[37]!==g||e[38]!==w?(v=r.jsxs("div",{className:"shrink-0 text-right",children:[g,w]}),e[37]=g,e[38]=w,e[39]=v):v=e[39];let S;return e[40]!==v||e[41]!==u||e[42]!==f?(S=r.jsxs("div",{className:"flex items-start gap-3 py-2.5",children:[u,f,v]}),e[40]=v,e[41]=u,e[42]=f,e[43]=S):S=e[43],S}function n$(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 s$(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 lb(n){const e=B.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(Pe,{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=n$(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 u;e[14]!==d?(u=G("font-mono text-sm font-semibold tabular-nums",d),e[14]=d,e[15]=u):u=e[15];let f;e[16]!==t.cpuPercent?(f=$o(t.cpuPercent),e[16]=t.cpuPercent,e[17]=f):f=e[17];let m;e[18]!==u||e[19]!==f?(m=r.jsx("div",{className:u,children:f}),e[18]=u,e[19]=f,e[20]=m):m=e[20];let p;e[21]!==t.memoryMb?(p=xa(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 b;return e[31]!==x||e[32]!==c?(b=r.jsxs("div",{className:"flex items-start gap-3 py-2.5",children:[c,x]}),e[31]=x,e[32]=c,e[33]=b):b=e[33],b}function jh(n){const e=B.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(o$)}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 o$(n,e){const t=e$(n.bytesPerSecond);return r.jsxs("div",{children:[e>0&&r.jsx(Nt,{}),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:ZP(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(Pe,{variant:"secondary",children:[n.active," open"]})]})]},n.name)}function r$(n){const e=B.c(8),{values:t}=n,s=Math.max(100,...t);let o;e[0]!==t?(o=t.map(i$).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:$o(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 i$(n){return $o(n)}function a$(n){var me,ue,ie,ge;const e=B.c(135),{open:t,onOpenChange:s}=n,[o,i]=y.useState(null),[a,l]=y.useState(null);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[0]=c):c=e[0];const[d,u]=y.useState(c),[f,m]=y.useState(null),[p,h]=y.useState(!1),g=y.useRef(!1),[x,b]=Ts();let w;e[1]===Symbol.for("react.memo_cache_sentinel")?(w=async()=>{var Re;if(g.current)return;g.current=!0,h(!0);const pe=be("/api/performance").then(m$),xe=((Re=window.electronPerformance)==null?void 0:Re.getSnapshot())??Promise.resolve(null),[Ce,Te]=await Promise.allSettled([pe,xe]),Ee=Ce.status==="fulfilled"?Ce.value:null,$e=Te.status==="fulfilled"?Te.value:null;if(Ee&&l(Ee),$e&&i($e),!Ee&&!$e)m("Performance data is unavailable.");else{m(null);const Fe=$e&&$e.processes.length>0?$e.processes.reduce(f$,0):(Ee==null?void 0:Ee.cpuPercent)??0;u(Le=>[...Le.slice(-29),Fe])}g.current=!1,h(!1)},e[1]=w):w=e[1];const v=w;let S,j;e[2]!==t?(S=()=>{if(!t)return;v();const pe=window.setInterval(()=>void v(),QP);return()=>window.clearInterval(pe)},j=[t,v],e[2]=t,e[3]=S,e[4]=j):(S=e[3],j=e[4]),y.useEffect(S,j);let k,C,N,_,A,P,T,E,$,I,R,D,O,M,F,z,L,W,U;if(e[5]!==x||e[6]!==b||e[7]!==o||e[8]!==f||e[9]!==d||e[10]!==s||e[11]!==t||e[12]!==p||e[13]!==a){const pe=[...(o==null?void 0:o.processes)??[]].sort(u$),xe=pe.length>0?pe.reduce(d$,0):(a==null?void 0:a.cpuPercent)??0,Ce=pe[0];let Te;e[33]!==((me=a==null?void 0:a.system)==null?void 0:me.processes)?(Te=((ue=a==null?void 0:a.system)==null?void 0:ue.processes)??[],e[33]=(ie=a==null?void 0:a.system)==null?void 0:ie.processes,e[34]=Te):Te=e[34],T=Te;const Ee=((ge=a==null?void 0:a.system)==null?void 0:ge.suspectedLeakCount)??0,$e=Ee>0||xe>=80?"High":xe>=15?"Active":"Idle";let Re;e[35]===Symbol.for("react.memo_cache_sentinel")?(Re=async At=>{try{await be("/api/system-processes/kill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pids:[At]})}),await new Promise(c$)}catch{}v()},e[35]=Re):Re=e[35],P=Re;let Fe;e[36]!==b||e[37]!==o||e[38]!==d||e[39]!==a?(Fe=()=>{b(JSON.stringify({capturedAt:new Date().toISOString(),electron:o,server:a,cpuHistory:d},null,2))},e[36]=b,e[37]=o,e[38]=d,e[39]=a,e[40]=Fe):Fe=e[40];const Le=Fe;A=os,O=t,M=s,_=rs,I="h-[min(780px,calc(100vh-2rem))] gap-0 p-0 sm:max-w-3xl";let Ie;e[41]===Symbol.for("react.memo_cache_sentinel")?(Ie=r.jsx(is,{children:"Power & activity monitor"}),e[41]=Ie):Ie=e[41];const _e=$e==="High"?"destructive":"secondary";let je;e[42]!==$e||e[43]!==_e?(je=r.jsxs("div",{className:"flex items-center gap-2",children:[Ie,r.jsx(Pe,{variant:_e,children:$e})]}),e[42]=$e,e[43]=_e,e[44]=je):je=e[44];let ze;e[45]===Symbol.for("react.memo_cache_sentinel")?(ze=r.jsx(as,{className:"mt-1",children:"Live CPU, memory, and wakeups. Sampling runs only while this window is open."}),e[45]=ze):ze=e[45];let Ne;e[46]!==je?(Ne=r.jsxs("div",{className:"min-w-0 flex-1",children:[je,ze]}),e[46]=je,e[47]=Ne):Ne=e[47];let Se;e[48]===Symbol.for("react.memo_cache_sentinel")?(Se=()=>void v(),e[48]=Se):Se=e[48];const he=p&&"animate-spin";let De;e[49]!==he?(De=G(he),e[49]=he,e[50]=De):De=e[50];let Be;e[51]!==De?(Be=r.jsx(Pt,{"data-icon":"inline-start",className:De}),e[51]=De,e[52]=Be):Be=e[52];let We;e[53]!==p||e[54]!==Be?(We=r.jsxs(ee,{variant:"outline",size:"sm",onClick:Se,disabled:p,children:[Be,"Refresh"]}),e[53]=p,e[54]=Be,e[55]=We):We=e[55];const we=!a&&!o;let Me;e[56]!==x?(Me=x?r.jsx(dt,{"data-icon":"inline-start"}):r.jsx(xn,{"data-icon":"inline-start"}),e[56]=x,e[57]=Me):Me=e[57];const fe=x?"Copied":"Copy data";let ve;e[58]!==Le||e[59]!==we||e[60]!==Me||e[61]!==fe?(ve=r.jsxs(ee,{variant:"outline",size:"sm",onClick:Le,disabled:we,children:[Me,fe]}),e[58]=Le,e[59]=we,e[60]=Me,e[61]=fe,e[62]=ve):ve=e[62];let Oe;e[63]!==We||e[64]!==ve?(Oe=r.jsxs("div",{className:"flex shrink-0 gap-1",children:[We,ve]}),e[63]=We,e[64]=ve,e[65]=Oe):Oe=e[65],e[66]!==Ne||e[67]!==Oe?(R=r.jsx(Ps,{className:"p-5 pb-4",children:r.jsxs("div",{className:"flex items-start gap-3 pr-8",children:[Ne,Oe]})}),e[66]=Ne,e[67]=Oe,e[68]=R):R=e[68],e[69]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(Nt,{}),e[69]=D):D=e[69],N=qn,$="min-h-0 min-w-0 flex-1",W="flex flex-col gap-4 p-5",e[70]!==f?(U=f&&r.jsx(pt,{variant:"destructive",children:r.jsx(ht,{children:f})}),e[70]=f,e[71]=U):U=e[71];let Ue;e[72]===Symbol.for("react.memo_cache_sentinel")?(Ue=r.jsx(fn,{children:"Current load"}),e[72]=Ue):Ue=e[72];const Ke=xe>=80&&"text-destructive";let Ze;e[73]!==Ke?(Ze=G("font-mono text-lg font-semibold tabular-nums",Ke),e[73]=Ke,e[74]=Ze):Ze=e[74];const He=r.jsxs(un,{children:[Ue,r.jsx(mn,{children:s$(xe,Ce,Ee)}),r.jsx(ax,{children:r.jsxs("span",{className:Ze,children:[$o(xe)," CPU"]})})]});let Ye;e[75]!==d?(Ye=r.jsx(rn,{children:r.jsx(r$,{values:d})}),e[75]=d,e[76]=Ye):Ye=e[76],e[77]!==He||e[78]!==Ye?(E=r.jsxs(on,{size:"sm",children:[He,Ye]}),e[77]=He,e[78]=Ye,e[79]=E):E=e[79],C=on,z="sm",e[80]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsxs(un,{children:[r.jsx(fn,{children:"Processes"}),r.jsx(mn,{children:"Which part of Cogpit is consuming CPU and memory."})]}),e[80]=L):L=e[80],k=rn,F=pe.length>0?pe.map(l$):a?r.jsx(lb,{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]=b,e[7]=o,e[8]=f,e[9]=d,e[10]=s,e[11]=t,e[12]=p,e[13]=a,e[14]=k,e[15]=C,e[16]=N,e[17]=_,e[18]=A,e[19]=P,e[20]=T,e[21]=E,e[22]=$,e[23]=I,e[24]=R,e[25]=D,e[26]=O,e[27]=M,e[28]=F,e[29]=z,e[30]=L,e[31]=W,e[32]=U}else k=e[14],C=e[15],N=e[16],_=e[17],A=e[18],P=e[19],T=e[20],E=e[21],$=e[22],I=e[23],R=e[24],D=e[25],O=e[26],M=e[27],F=e[28],z=e[29],L=e[30],W=e[31],U=e[32];let H;e[81]!==k||e[82]!==F?(H=r.jsx(k,{children:F}),e[81]=k,e[82]=F,e[83]=H):H=e[83];let K;e[84]!==C||e[85]!==H||e[86]!==z||e[87]!==L?(K=r.jsxs(C,{size:z,children:[L,H]}),e[84]=C,e[85]=H,e[86]=z,e[87]=L,e[88]=K):K=e[88];let V;e[89]!==P||e[90]!==T?(V=T.length>0&&r.jsxs(on,{size:"sm",children:[r.jsxs(un,{children:[r.jsx(fn,{children:"Agent processes"}),r.jsx(mn,{children:"Claude sessions, browsers, and scripts running outside Cogpit."})]}),r.jsx(rn,{children:T.map((pe,xe)=>r.jsxs("div",{children:[xe>0&&r.jsx(Nt,{}),r.jsx(t$,{metric:pe,onKill:Ce=>void P(Ce)})]},pe.pid))})]}),e[89]=P,e[90]=T,e[91]=V):V=e[91];let Y;e[92]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx(fn,{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(un,{children:[Y,r.jsxs(mn,{children:["File checks, streams, and agent work over the last ",q," seconds."]})]}),e[93]=q,e[94]=J):J=e[94];let Q;e[95]!==(a==null?void 0:a.activities)?(Q=(a==null?void 0:a.activities)??[],e[95]=a==null?void 0:a.activities,e[96]=Q):Q=e[96];let X;e[97]!==Q?(X=r.jsx(rn,{children:r.jsx(jh,{metrics:Q,emptyLabel:"No watched-file or stream activity in this sample."})}),e[97]=Q,e[98]=X):X=e[98];let Z;e[99]!==J||e[100]!==X?(Z=r.jsxs(on,{size:"sm",children:[J,X]}),e[99]=J,e[100]=X,e[101]=Z):Z=e[101];let te;e[102]===Symbol.for("react.memo_cache_sentinel")?(te=r.jsxs(un,{children:[r.jsx(fn,{children:"API activity"}),r.jsx(mn,{children:"Requests ranked by recent frequency and time."})]}),e[102]=te):te=e[102];let ne;e[103]!==(a==null?void 0:a.requests)?(ne=(a==null?void 0:a.requests)??[],e[103]=a==null?void 0:a.requests,e[104]=ne):ne=e[104];let oe;e[105]!==ne?(oe=r.jsxs(on,{size:"sm",children:[te,r.jsx(rn,{children:r.jsx(jh,{metrics:ne,emptyLabel:"No API requests in this sample."})})]}),e[105]=ne,e[106]=oe):oe=e[106];let re;e[107]!==Z||e[108]!==oe?(re=r.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[Z,oe]}),e[107]=Z,e[108]=oe,e[109]=re):re=e[109];let ae;e[110]!==a?(ae=a&&r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Server event loop ",$o(a.eventLoopPercent)," · heap ",xa(a.memory.heapUsedMb)," · RSS ",xa(a.memory.rssMb)]}),e[110]=a,e[111]=ae):ae=e[111];let se;e[112]!==E||e[113]!==K||e[114]!==V||e[115]!==re||e[116]!==ae||e[117]!==W||e[118]!==U?(se=r.jsxs("div",{className:W,children:[U,E,K,V,re,ae]}),e[112]=E,e[113]=K,e[114]=V,e[115]=re,e[116]=ae,e[117]=W,e[118]=U,e[119]=se):se=e[119];let de;e[120]!==N||e[121]!==$||e[122]!==se?(de=r.jsx(N,{className:$,children:se}),e[120]=N,e[121]=$,e[122]=se,e[123]=de):de=e[123];let le;e[124]!==_||e[125]!==I||e[126]!==R||e[127]!==D||e[128]!==de?(le=r.jsxs(_,{className:I,children:[R,D,de]}),e[124]=_,e[125]=I,e[126]=R,e[127]=D,e[128]=de,e[129]=le):le=e[129];let ce;return e[130]!==A||e[131]!==O||e[132]!==M||e[133]!==le?(ce=r.jsx(A,{open:O,onOpenChange:M,children:le}),e[130]=A,e[131]=O,e[132]=M,e[133]=le,e[134]=ce):ce=e[134],ce}function l$(n,e){return r.jsxs("div",{children:[e>0&&r.jsx(Nt,{}),r.jsx(lb,{metric:n})]},n.pid)}function c$(n){return setTimeout(n,1e3)}function d$(n,e){return n+e.cpuPercent}function u$(n,e){return e.cpuPercent-n.cpuPercent}function f$(n,e){return n+e.cpuPercent}async function m$(n){if(!n.ok)throw new Error(`Server monitor returned ${n.status}`);return n.json()}function p$(n){return`${n.title??`Pull request #${n.number}`}
|
|
122
|
+
${n.repo}${n.isDraft?" · draft":""}`}function cb(n){return{href:n.url,target:"_blank",rel:"noreferrer",onClick:e=>e.stopPropagation(),"aria-label":`Pull request #${n.number}`,title:p$(n)}}function hl(n){const e=B.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 f;e[0]!==t?(f=t.map(g$),e[0]=t,e[1]=f):f=e[1];let m;return e[2]!==f?(m=r.jsx("div",{className:"flex flex-col gap-0.5",children:f}),e[2]=f,e[3]=m):m=e[3],m}let c,d;if(e[4]!==o||e[5]!==a||e[6]!==t){const f=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(h$).join(`
|
|
123
|
+
`),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?Ed:Fr;return r.jsxs(Pe,{variant:p.isDraft?"outline":"secondary",render:r.jsx("a",{...cb(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=f.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 u;return e[14]!==c||e[15]!==d?(u=r.jsxs(r.Fragment,{children:[c,d]}),e[14]=c,e[15]=d,e[16]=u):u=e[16],u}function h$(n){return`#${n.number} ${n.title??n.repo}`}function g$(n){const e=n.isDraft?Ed:Fr;return r.jsxs("a",{...cb(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 x$=y.memo(function(e){const t=B.c(37),{session:s,sessionSource:o,isLive:i,pullRequests:a,copied:l,creatingSession:c,onCopyResume:d,onNewSession:u,onDuplicateSession:f,onOpenTerminal:m}=e;let p;if(t[0]!==o){const P=o?Ns(o.fileName):null;p=P?Tu(P.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(y$),t[2]=s.turns,t[3]=g):g=t[3];const x=g;let b;t[4]!==s.rawMessages||t[5]!==(o==null?void 0:o.dirName)?(b=To(o==null?void 0:o.dirName).contextWindow?s.rawMessages:[],t[4]=s.rawMessages,t[5]=o==null?void 0:o.dirName,t[6]=b):b=t[6];const w=b;let v;t[7]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx("div",{className:G(Mn,"flex h-8 min-w-0 items-center gap-2 pl-1 pr-3")}),t[7]=v):v=t[7];let S;t[8]!==l||t[9]!==c||t[10]!==d||t[11]!==f||t[12]!==u||t[13]!==m||t[14]!==s||t[15]!==o?(S=o?r.jsx(v$,{session:s,sessionSource:o,copied:l,creatingSession:c,onCopyResume:d,onNewSession:u,onDuplicateSession:f,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]=f,t[12]=u,t[13]=m,t[14]=s,t[15]=o,t[16]=S):S=t[16];let j;t[17]!==i?(j=i&&r.jsx(Wa,{"aria-label":"Session is live"}),t[17]=i,t[18]=j):j=t[18];let k;t[19]!==s.model?(k=s.model&&r.jsx("span",{className:"shrink-0 font-mono text-[11px] text-foreground/80",children:Js(s.model)}),t[19]=s.model,t[20]=k):k=t[20];let C;t[21]!==w?(C=r.jsx(Ug,{rawMessages:w}),t[21]=w,t[22]=C):C=t[22];let N;t[23]!==S||t[24]!==j||t[25]!==k||t[26]!==C?(N=r.jsxs(Mt,{delay:200,render:v,children:[S,j,k,C]}),t[23]=S,t[24]=j,t[25]=k,t[26]=C,t[27]=N):N=t[27];let _;t[28]!==a||t[29]!==w||t[30]!==s||t[31]!==h||t[32]!==x?(_=r.jsx(Ot,{role:"tooltip",side:"bottom",align:"start",sideOffset:6,className:"p-3",children:r.jsx(b$,{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 A;return t[34]!==_||t[35]!==N?(A=r.jsxs(It,{children:[N,_]}),t[34]=_,t[35]=N,t[36]=A):A=t[36],A});function lo(n){const e=B.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 b$(n){const e=B.c(33),{session:t,thinkingEnabled:s,subAgentLabel:o,pullRequests:i,rawMessages:a}=n;let l,c,d,u,f,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=yg(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(lo,{label:"Model",children:[r.jsx("span",{children:Js(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(lo,{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?(u=i.length>0&&r.jsx(lo,{label:"Pull requests",children:r.jsx(hl,{pullRequests:i})}),e[19]=i,e[20]=u):u=e[20],e[21]!==o?(f=o&&r.jsx(lo,{label:"Agent",children:o}),e[21]=o,e[22]=f):f=e[22],e[23]!==x?(m=x&&r.jsxs(lo,{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(lo,{label:"Context",children:[ut(Math.max(0,g.compactAt-g.used))," left before compact ·"," ",ut(g.used)," / ",ut(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]=u,e[11]=f,e[12]=m,e[13]=p}else l=e[7],c=e[8],d=e[9],u=e[10],f=e[11],m=e[12],p=e[13];let h;return e[25]!==l||e[26]!==c||e[27]!==d||e[28]!==u||e[29]!==f||e[30]!==m||e[31]!==p?(h=r.jsxs("div",{className:l,children:[c,d,u,f,m,p]}),e[25]=l,e[26]=c,e[27]=d,e[28]=u,e[29]=f,e[30]=m,e[31]=p,e[32]=h):h=e[32],h}function v$(n){const e=B.c(54),{session:t,sessionSource:s,copied:o,creatingSession:i,onCopyResume:a,onNewSession:l,onDuplicateSession:c,onOpenTerminal:d}=n,{dispatch:u}=Ht(),f=!!(t.cwd||s.dirName);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=Ws(),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?`${es(t.cwd)} / ${g}`:g,e[4]=t.cwd,e[5]=g,e[6]=x):x=e[6];const b=x;let w;e[7]!==t.cwd||e[8]!==s.dirName?(w={path:t.cwd,dirName:s.dirName},e[7]=t.cwd,e[8]=s.dirName,e[9]=w):w=e[9];const v=w;let S;e[10]===Symbol.for("react.memo_cache_sentinel")?(S=!p||ou(),e[10]=S):S=e[10];const j=S;let k;e[11]!==u||e[12]!==s.dirName?(k=function(){y.startTransition(()=>{u({type:"GO_HOME",isMobile:!1}),u({type:"SET_DASHBOARD_PROJECT",dirName:s.dirName})})},e[11]=u,e[12]=s.dirName,e[13]=k):k=e[13];const C=k,N=`Copy resume command for ${b}; open session actions with the context menu`;let _;e[14]!==a||e[15]!==N?(_=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":N,"aria-haspopup":"menu",title:"Click to copy resume command. Right-click for session actions."}),e[14]=a,e[15]=N,e[16]=_):_=e[16];let A;e[17]!==o||e[18]!==t.cwd||e[19]!==g?(A=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:es(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]=A):A=e[20];let P;e[21]!==_||e[22]!==A?(P=r.jsx(al,{render:_,children:A}),e[21]=_,e[22]=A,e[23]=P):P=e[23];let T;e[24]!==l||e[25]!==t.cwd||e[26]!==s.dirName?(T=()=>l(s.dirName,t.cwd),e[24]=l,e[25]=t.cwd,e[26]=s.dirName,e[27]=T):T=e[27];let E;e[28]!==i?(E=i?r.jsx(st,{className:"size-3.5"}):r.jsx(Fn,{className:"size-3.5"}),e[28]=i,e[29]=E):E=e[29];let $;e[30]!==i||e[31]!==T||e[32]!==E?($=r.jsxs(sn,{disabled:i,onClick:T,children:[E,"New session in this project"]}),e[30]=i,e[31]=T,e[32]=E,e[33]=$):$=e[33];let I;e[34]!==c?(I=c&&r.jsxs(sn,{onClick:c,children:[r.jsx(xn,{className:"size-3.5"}),"Duplicate this session"]}),e[34]=c,e[35]=I):I=e[35];let R;e[36]!==f||e[37]!==v?(R=f&&(j||!p)&&r.jsxs(r.Fragment,{children:[r.jsx(Ar,{}),j&&r.jsxs(sn,{onClick:()=>px(v),children:[r.jsx(Ca,{className:"size-3.5"}),"Open project in editor"]}),!p&&r.jsxs(sn,{onClick:()=>hx(v),children:[r.jsx(z1,{className:"size-3.5"}),"Reveal in file manager"]})]}),e[36]=f,e[37]=v,e[38]=R):R=e[38];let D;e[39]!==d?(D=d&&!p&&ot("terminal")&&r.jsxs(sn,{onClick:d,children:[r.jsx(Gs,{className:"size-3.5"}),"Open terminal in project"]}),e[39]=d,e[40]=D):D=e[40];let O;e[41]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsx(Ar,{}),e[41]=O):O=e[41];let M;e[42]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(_o,{className:"size-3.5"}),e[42]=M):M=e[42];let F;e[43]!==C?(F=r.jsxs(sn,{onClick:C,children:[M,"View all sessions in this project"]}),e[43]=C,e[44]=F):F=e[44];let z;e[45]!==$||e[46]!==I||e[47]!==R||e[48]!==D||e[49]!==F?(z=r.jsxs(ll,{className:"min-w-56",children:[$,I,R,D,O,F]}),e[45]=$,e[46]=I,e[47]=R,e[48]=D,e[49]=F,e[50]=z):z=e[50];let L;return e[51]!==P||e[52]!==z?(L=r.jsxs(il,{children:[P,z]}),e[51]=P,e[52]=z,e[53]=L):L=e[53],L}function y$(n){return n.thinking.length>0}const od="Could not reach the server";async function zi(n,e){try{return await be(n,e)}catch{return null}}async function rc(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:od}function w$(){const n=B.c(15);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],n[0]=e):e=n[0];const[t,s]=y.useState(e),[o,i]=y.useState(null),a=y.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]),y.useEffect(l,c);let d;n[3]===Symbol.for("react.memo_cache_sentinel")?(d=async()=>{const k=await zi("/api/shares");if(!(k!=null&&k.ok))return;const C=await k.json().catch(k$);a.current&&Array.isArray(C)&&s(C)},n[3]=d):d=n[3];const u=d;let f,m;n[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{u()},m=[u],n[4]=f,n[5]=m):(f=n[4],m=n[5]),y.useEffect(f,m);let p;n[6]===Symbol.for("react.memo_cache_sentinel")?(p=async k=>{i(null);const C=await zi("/api/shares",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:k})});if(!(C!=null&&C.ok))return a.current&&i(await rc(C)),null;const N=await C.json().catch(N$);if(!(N!=null&&N.passphrase)||!N.share)return a.current&&i(od),null;const _=N.share;return a.current&&s(A=>[...A.filter(P=>P.sessionId!==_.sessionId),_]),N.passphrase},n[6]=p):p=n[6];const h=p;let g;n[7]===Symbol.for("react.memo_cache_sentinel")?(g=async k=>{i(null);const C=await zi(`/api/shares/${encodeURIComponent(k)}/regenerate`,{method:"POST"});if(!(C!=null&&C.ok))return a.current&&i(await rc(C)),null;const N=await C.json().catch(S$);return N!=null&&N.passphrase?(u(),N.passphrase):(a.current&&i(od),null)},n[7]=g):g=n[7];const x=g;let b;n[8]===Symbol.for("react.memo_cache_sentinel")?(b=async k=>{i(null);const C=await zi(`/api/shares/${encodeURIComponent(k)}`,{method:"DELETE"});if(!(C!=null&&C.ok)){a.current&&i(await rc(C));return}a.current&&s(N=>N.filter(_=>_.sessionId!==k))},n[8]=b):b=n[8];const w=b;let v;n[9]!==t?(v=async()=>{const k=t.map(j$);for(const C of k)await w(C)},n[9]=t,n[10]=v):v=n[10];const S=v;let j;return n[11]!==o||n[12]!==S||n[13]!==t?(j={shares:t,error:o,refresh:u,create:h,regenerate:x,revoke:w,revokeAll:S},n[11]=o,n[12]=S,n[13]=t,n[14]=j):j=n[14],j}function j$(n){return n.sessionId}function S$(){return null}function N$(){return null}function k$(){return null}const C$=5e3,_$="••••";function T$(n){return n===0?"No guests connected":n===1?"1 guest connected":`${n} guests connected`}function E$({sessionId:n}){const{config:{networkAccessDisabled:e}}=Ht(),{shares:t,error:s,refresh:o,create:i,regenerate:a,revoke:l}=w$(),[c,d]=y.useState(!1),[u,f]=y.useState(null),[m,p]=y.useState(!1),[h,g]=Ts(),[x,b]=Ts(),w=t.find(k=>k.sessionId===n)??null,v=`${window.location.origin}${IS(n)}`;y.useEffect(()=>f(null),[n]),y.useEffect(()=>{if(!c)return;o();const k=setInterval(()=>void o(),C$);return()=>clearInterval(k)},[c,o]);async function S(k){p(!0);try{await k()}finally{p(!1)}}const j=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(Do,{open:c,onOpenChange:k=>{d(k),k||f(null)},children:[r.jsx(Lo,{render:r.jsx(ee,{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(mw,{"data-icon":"inline-start"})}),r.jsx(zo,{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:v}),r.jsx(ee,{variant:"ghost",size:"icon-xs","aria-label":"Copy link",onClick:()=>g(v),children:h?r.jsx(dt,{"data-icon":"inline-start"}):r.jsx(xn,{"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:u??_$}),r.jsx(ee,{variant:"ghost",size:"icon-xs","aria-label":"Regenerate passphrase",disabled:m,onClick:()=>S(async()=>{f(await a(n))}),children:r.jsx(Pt,{"data-icon":"inline-start"})})]}),u?r.jsx(ee,{variant:"secondary",size:"xs",onClick:()=>b(`${v}
|
|
124
|
+
Passphrase: ${u}`),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."}),j,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:T$(w.guests)}),r.jsx(ee,{variant:"ghost",size:"xs",className:"text-destructive hover:text-destructive",disabled:m,onClick:()=>S(async()=>{await l(n),f(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."}),j,s&&r.jsx("p",{className:"text-xs text-destructive",children:s}),r.jsx(ee,{size:"xs",disabled:m,onClick:()=>S(async()=>{f(await i(n))}),children:"Enable sharing"})]})})]})}function qu(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 lt(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)?n:void 0}function En(n){return typeof n=="number"&&Number.isFinite(n)?n:void 0}function vs(n){return typeof n=="string"?n:void 0}function xs(n){return n?qu(En(n.utilization),vs(n.resets_at)):void 0}function db(n){if(n)return{isEnabled:!!n.is_enabled,monthlyLimit:En(n.monthly_limit),usedCredits:En(n.used_credits),utilization:En(n.utilization)}}function A$(n){return{fiveHour:xs(lt(n.five_hour)),sevenDay:xs(lt(n.seven_day)),sevenDayOpus:xs(lt(n.seven_day_opus)),sevenDaySonnet:xs(lt(n.seven_day_sonnet)),extraUsage:db(lt(n.extra_usage)),subscriptionType:vs(n.subscriptionType)}}function P$(n){if(n.available!==!0)return null;const e=lt(n.usage),t=lt(e==null?void 0:e.rate_limits),s=lt(n.account),o={fiveHour:xs(lt(t==null?void 0:t.five_hour)),sevenDay:xs(lt(t==null?void 0:t.seven_day)),sevenDayOpus:xs(lt(t==null?void 0:t.seven_day_opus)),sevenDaySonnet:xs(lt(t==null?void 0:t.seven_day_sonnet)),extraUsage:db(lt(t==null?void 0:t.extra_usage)),subscriptionType:vs(e==null?void 0:e.subscription_type)??vs(s==null?void 0:s.subscriptionType)};return o.fiveHour||o.sevenDay||o.extraUsage||o.subscriptionType?o:null}function $$(n){const e=En(n);if(e!==void 0)return new Date(e<1e10?e*1e3:e).toISOString()}function R$(n,e){const t=En(n);return t===void 0||t<=0?e:t%1440===0?`${t/1440}-day`:t%60===0?`${t/60}-hour`:`${t}-minute`}function Sh(n,e){if(n)return qu(En(n.usedPercent),$$(n.resetsAt),R$(n.windowDurationMins,e))}function I$(n){var d,u,f;if(n.available!==!0)return null;const e=lt((d=lt(n.rateLimits))==null?void 0:d.rateLimits),t=lt((u=lt(n.account))==null?void 0:u.account),s=lt((f=lt(n.usage))==null?void 0:f.summary),o=lt(e==null?void 0:e.credits),i=Sh(lt(e==null?void 0:e.primary),"Primary"),a=Sh(lt(e==null?void 0:e.secondary),"Secondary"),l=s==null?void 0:s.lifetimeTokens,c=En(l)??(typeof l=="string"&&Number.isSafeInteger(Number(l))?Number(l):void 0);return!i&&!a&&c===void 0?null:{fiveHour:i,sevenDay:a,subscriptionType:vs(e==null?void 0:e.planType)??vs(t==null?void 0:t.planType),lifetimeTokens:c,creditBalance:vs(o==null?void 0:o.balance),creditsUnlimited:(o==null?void 0:o.unlimited)===!0}}function Nh(n,e){if(!n)return;const t=En(n.remainingPercentage),s=En(n.usedRequests),o=En(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),qu(i,vs(n.resetDate),e)}function M$(n){var s;if(n.available!==!0)return null;const e=lt((s=lt(n.quota))==null?void 0:s.quotaSnapshots),t=Nh(lt(e==null?void 0:e.chat),"Chat")??Nh(lt(e==null?void 0:e.premium_interactions),"Premium interactions");return t?{fiveHour:t}:null}const O$={claude:{endpoint:"/api/claude/runtime",read:P$,legacy:{endpoint:"/api/usage",read:A$}},codex:{endpoint:"/api/codex/runtime",read:I$},copilot:{endpoint:"/api/copilot/runtime",read:M$}};function D$(n){return O$[n]}const L$=300*1e3;function z$(n=Xs){const e=An("viewUsage"),[t,s]=y.useState(null),[o,i]=y.useState(!1),[a,l]=y.useState(!1),c=y.useRef(0),d=y.useRef(null),u=y.useCallback(async()=>{var h;if(!e)return;const f=++c.current;(h=d.current)==null||h.abort();const m=new AbortController;d.current=m;const p=()=>c.current===f&&!m.signal.aborted;i(!0);try{const g=D$(n);let x=await be(g.endpoint,{signal:m.signal}),b=g.read;if(g.legacy&&!x.ok&&!m.signal.aborted&&(x=await be(g.legacy.endpoint,{signal:m.signal}),b=g.legacy.read),!p())return;if(x.status===501||x.status===404){l(!1);return}if(!x.ok){l(!0);return}const w=await x.json();if(!p())return;const v=b(w);l(v!==null),s(v?{...v,agentKind:n,fetchedAt:Date.now()}:null)}catch{}finally{p()&&(d.current=null,i(!1))}},[n,e]);return y.useEffect(()=>{var m;if(s(null),l(!1),!e){i(!1),c.current+=1,(m=d.current)==null||m.abort(),d.current=null;return}u();const f=setInterval(u,L$);return()=>{var p;clearInterval(f),c.current+=1,(p=d.current)==null||p.abort(),d.current=null}},[n,e,u]),{usage:e?t:null,loading:e&&o,available:e&&a,refresh:u}}function ub(n){return n>=90?"danger":n>=80?"warning":n>=60?"caution":"nominal"}const fb={nominal:"text-muted-foreground",caution:"text-warning",warning:"text-warning",danger:"text-destructive"};function F$(n){var d;const e=B.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 u=[];t.fiveHour&&u.push({label:t.fiveHour.label??"5-hour",pct:t.fiveHour.utilization,resetsAt:t.fiveHour.resetsAt}),t.sevenDay&&u.push({label:t.sevenDay.label??"7-day",pct:t.sevenDay.utilization,resetsAt:t.sevenDay.resetsAt}),t.sevenDayOpus&&u.push({label:"Opus",pct:t.sevenDayOpus.utilization,resetsAt:t.sevenDayOpus.resetsAt}),t.sevenDaySonnet&&u.push({label:"Sonnet",pct:t.sevenDaySonnet.utilization,resetsAt:t.sevenDaySonnet.resetsAt}),s="flex min-w-[200px] flex-col gap-2";let f;e[10]!==t.agentKind?(f=t.agentKind?Ba(t.agentKind):"Agent",e[10]=t.agentKind,e[11]=f):f=e[11];let m;e[12]!==f?(m=r.jsxs("span",{className:"text-xs font-medium uppercase tracking-wide",children:[f," usage"]}),e[12]=f,e[13]=m):m=e[13];let p;e[14]!==t.subscriptionType?(p=t.subscriptionType&&r.jsx(Pe,{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=u.map(h=>{const g=h.resetsAt&&t.fetchedAt!=null?new Date(h.resetsAt).getTime()-t.fetchedAt:null,x=g!=null?Math.max(0,Math.round(g/36e5)):null,b=ub(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",fb[b]),children:[h.pct.toFixed(1),"%"]})]}),r.jsx(Yr,{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(Nt,{}),"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(Nt,{}),t.lifetimeTokens!=null&&r.jsxs("div",{children:["Lifetime: ",ut(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 B$(n){var S,j;const e=B.c(22),{agentKind:t}=n,s=t===void 0?Xs:t,{usage:o,loading:i,available:a,refresh:l}=z$(s);if(!a||!o)return null;const c=((S=o.fiveHour)==null?void 0:S.utilization)??((j=o.sevenDay)==null?void 0:j.utilization);if(c==null)return null;let d;e[0]!==o.agentKind?(d=o.agentKind?Ba(o.agentKind):"agent",e[0]=o.agentKind,e[1]=d):d=e[1];const u=`Refresh ${d} usage`;let f;e[2]!==i||e[3]!==l||e[4]!==u?(f=r.jsx(ee,{type:"button",variant:"ghost",size:"xs","aria-label":u,onClick:l,disabled:i,className:"mr-1 font-mono"}),e[2]=i,e[3]=l,e[4]=u,e[5]=f):f=e[5];const m=fb[ub(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 b;e[14]!==f||e[15]!==x?(b=r.jsx(Mt,{render:f,children:x}),e[14]=f,e[15]=x,e[16]=b):b=e[16];let w;e[17]!==o?(w=r.jsx(Ot,{side:"bottom",className:"p-3",children:r.jsx(F$,{usage:o})}),e[17]=o,e[18]=w):w=e[18];let v;return e[19]!==b||e[20]!==w?(v=r.jsxs(It,{children:[b,w]}),e[19]=b,e[20]=w,e[21]=v):v=e[21],v}function U$(n,e){const t=B.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]=y.useState(s),[a,l]=y.useState(0);let c;t[1]!==n||t[2]!==e?(c=()=>{const p=new AbortController;i(H$);const h=Intl.DateTimeFormat().resolvedOptions().timeZone;return be(`/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],y.useEffect(c,d);let u;t[8]===Symbol.for("react.memo_cache_sentinel")?(u=()=>l(W$),t[8]=u):u=t[8];const f=u;let m;return t[9]!==o?(m={...o,refresh:f},t[9]=o,t[10]=m):m=t[10],m}function W$(n){return n+1}function H$(n){return{...n,loading:!0,error:null}}function q$(n){const e=n.trim().toLowerCase().replace(/\[[^\]]*\]$/,""),t=e.lastIndexOf("/");return t===-1?e:e.slice(t+1)}const K$=new Set(["<synthetic>","synthetic","opus","sonnet","haiku","fable"]);function V$(n,e){const t=q$(e);return t.length===0||K$.has(t)?null:n.get(t)??null}function G$(n,e){const t=n.longContextThresholdTokens,s=e.uncachedInputTokens+e.cachedInputTokens+e.cacheCreationTokens,o=t!==null&&s>t;return function(a,l,c){return a<=0?0:c===null||t===null?a*l:n.longContextPricing==="wholeRequest"?a*(o?c:l):a<=t?a*l:t*l+(a-t)*c}}function Y$(n){return n.uncachedInputUsd+n.cachedInputUsd+n.cacheCreationUsd+n.outputUsd}function X$(n,e,t,s=null){const o=V$(n,e);if(o===null)return null;const i=Math.min(t.cacheCreation1hTokens,t.cacheCreationTokens),a=t.cacheCreationTokens-i,l=G$(o,t),c=s==="fast"?o.fastCostMultiplier:1;return{uncachedInputUsd:c*l(t.uncachedInputTokens,o.inputCostPerToken,o.inputCostPerTokenAboveThreshold),cachedInputUsd:c*l(t.cachedInputTokens,o.cacheReadCostPerToken,o.cacheReadCostPerTokenAboveThreshold),cacheCreationUsd:c*(l(a,o.cacheCreationCostPerToken,o.cacheCreationCostPerTokenAboveThreshold)+i*o.cacheCreation1hCostPerToken),outputUsd:c*l(t.outputTokens,o.outputCostPerToken,o.outputCostPerTokenAboveThreshold)}}function J$(n,e,t,s,o=null){const i=X$(n,e,t,o);return i===null?{costUsd:0,costSource:"unpriced"}:{costUsd:Y$(i),costSource:"modelPriced"}}function Ku(n){return n.uncachedInputTokens+n.cachedInputTokens+n.cacheCreationTokens+n.outputTokens}function Q$(n,e,t){if(!e)return 0;const{costUsd:s,costSource:o}=J$(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 Z$=[{days:7,label:"7 days"},{days:30,label:"30 days"},{days:90,label:"90 days"}],ur=jg.map(n=>({key:n,label:en(n).displayName,color:I4(n)}));function eR(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 kh(){return{claude:{costUsd:0,tokens:0},codex:{costUsd:0,tokens:0},copilot:{costUsd:0,tokens:0}}}function tR(n){const e=new Map;for(const o of eR(n.sinceDay,n.untilDay))e.set(o,{day:o,byProvider:kh(),costUsd:0,tokens:0});const t=new Map,s={costUsd:0,tokens:0,cacheSavingsUsd:0,byProvider:kh(),days:[],models:[]};for(const o of n.buckets){const i=Ku(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 Ch(n){const e=Date.parse(`${n}T00:00:00Z`);return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",timeZone:"UTC"}).format(e)}const ic=720,ac=180,nR=18;function sR(n){const e=B.c(41),{days:t,metric:s}=n,[o,i]=y.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=N=>l(N),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 u=ac-nR,f=ic/t.length,m=Math.max(2,Math.min(28,f-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:Ch(p.day)}),ur.map(C=>{const{key:N,label:_,color:A}=C,P=p.byProvider[N];return l(P)<=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:A}}),_,": ",s==="cost"?pn(P.costUsd):ut(P.tokens)]},N)}),r.jsx("span",{className:"ml-2 font-medium",children:s==="cost"?pn(p.costUsd):ut(p.tokens)})]})}),e[8]=p,e[9]=s,e[10]=l,e[11]=h):h=e[11];const g=`Daily ${s==="cost"?"raw API cost":"processed tokens"} by provider`;let x,b;e[12]===Symbol.for("react.memo_cache_sentinel")?(x=()=>i(null),b=r.jsx("line",{x1:0,y1:u,x2:ic,y2:u,stroke:"var(--border)",strokeWidth:1}),e[12]=x,e[13]=b):(x=e[12],b=e[13]);let w;if(e[14]!==m||e[15]!==t||e[16]!==o||e[17]!==d||e[18]!==f||e[19]!==l){let C;e[21]!==m||e[22]!==o||e[23]!==d||e[24]!==f||e[25]!==l?(C=(N,_)=>{const A=_*f+(f-m)/2;let P=u;const T=o===_;return r.jsxs("g",{onMouseEnter:()=>i(_),children:[r.jsx("rect",{x:_*f,y:0,width:f,height:u,fill:"transparent"}),T&&r.jsx("rect",{x:_*f,y:0,width:f,height:u,fill:"var(--foreground)",opacity:.05,rx:2}),ur.map(E=>{const{key:$,color:I}=E,R=l(N.byProvider[$]);if(R<=0)return null;const D=R/d*(u-6);return P=P-D,r.jsx("rect",{x:A,y:P,width:m,height:Math.max(1,D-1.5),rx:1.5,fill:I,opacity:T?1:.85},$)})]},N.day)},e[21]=m,e[22]=o,e[23]=d,e[24]=f,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]=f,e[19]=l,e[20]=w}else w=e[20];let v;if(e[27]!==t||e[28]!==f){let C;e[30]!==t.length||e[31]!==f?(C=(N,_)=>_===0||_===t.length-1||t.length>10&&_%7===0&&_<t.length-3?r.jsx("text",{x:_*f+f/2,y:ac-4,textAnchor:"middle",className:"fill-muted-foreground text-[10px]",children:Ch(N.day)},N.day):null,e[30]=t.length,e[31]=f,e[32]=C):C=e[32],v=t.map(C),e[27]=t,e[28]=f,e[29]=v}else v=e[29];let S;e[33]!==g||e[34]!==w||e[35]!==v?(S=r.jsxs("svg",{viewBox:`0 0 ${ic} ${ac}`,className:"w-full",role:"img","aria-label":g,onMouseLeave:x,children:[b,w,v]}),e[33]=g,e[34]=w,e[35]=v,e[36]=S):S=e[36];let j;e[37]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx("div",{className:"mt-1 flex items-center gap-4",children:ur.map(oR)}),e[37]=j):j=e[37];let k;return e[38]!==h||e[39]!==S?(k=r.jsxs("div",{className:"relative",children:[h,S,j]}),e[38]=h,e[39]=S,e[40]=k):k=e[40],k}function oR(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 lc(n){const e=B.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 rR(n){const e=B.c(68),{days:t}=n,{summary:s,loading:o,error:i,refresh:a}=U$(t,!0),[l,c]=y.useState("cost");let d;e[0]!==s?(d=s?tR(s):null,e[0]=s,e[1]=d):d=e[1];const u=d;if(i){let z;e[2]!==a?(z=r.jsx(ee,{variant:"outline",size:"sm",onClick:a,children:"Retry"}),e[2]=a,e[3]=z):z=e[3];let L;return e[4]!==i||e[5]!==z?(L=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]=L):L=e[6],L}if(!u||!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(st,{className:"size-4"})," Scanning transcripts…"]}),e[7]=z):z=e[7],z}const f=o&&"opacity-60";let m;e[8]!==f?(m=G("flex flex-col gap-5",f),e[8]=f,e[9]=m):m=e[9];let p;e[10]!==u.costUsd||e[11]!==u.tokens||e[12]!==l?(p=l==="cost"?pn(u.costUsd):ut(u.tokens),e[10]=u.costUsd,e[11]=u.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 b;e[19]!==h||e[20]!==x?(b=r.jsxs("div",{className:"flex flex-col gap-0.5",children:[h,x]}),e[19]=h,e[20]=x,e[21]=b):b=e[21];let w;e[22]===Symbol.for("react.memo_cache_sentinel")?(w=["cost","tokens"],e[22]=w):w=e[22];let v;e[23]!==l?(v=r.jsx("div",{className:"flex rounded-md border p-0.5",children:w.map(z=>r.jsx(ee,{variant:l===z?"secondary":"ghost",size:"xs",onClick:()=>c(z),children:z==="cost"?"Cost":"Tokens"},z))}),e[23]=l,e[24]=v):v=e[24];let S;e[25]!==u.byProvider||e[26]!==l?(S=ur.map(z=>{const{key:L,label:W}=z,U=u.byProvider[L];return U.costUsd===0&&U.tokens===0?null:r.jsxs("span",{className:"text-xs text-muted-foreground tabular-nums",children:[W,": ",l==="cost"?pn(U.costUsd):ut(U.tokens)]},L)}),e[25]=u.byProvider,e[26]=l,e[27]=S):S=e[27];let j;e[28]!==v||e[29]!==S?(j=r.jsxs("div",{className:"flex flex-col items-end gap-1.5",children:[v,S]}),e[28]=v,e[29]=S,e[30]=j):j=e[30];let k;e[31]!==j||e[32]!==b?(k=r.jsxs("div",{className:"flex items-end justify-between gap-4",children:[b,j]}),e[31]=j,e[32]=b,e[33]=k):k=e[33];let C;e[34]!==u.days||e[35]!==l?(C=r.jsx(sR,{days:u.days,metric:l}),e[34]=u.days,e[35]=l,e[36]=C):C=e[36];let N;e[37]!==u.tokens?(N=ut(u.tokens),e[37]=u.tokens,e[38]=N):N=e[38];let _;e[39]!==N?(_=r.jsx(lc,{label:"Processed tokens",value:N}),e[39]=N,e[40]=_):_=e[40];let A;e[41]!==u.cacheSavingsUsd?(A=pn(u.cacheSavingsUsd),e[41]=u.cacheSavingsUsd,e[42]=A):A=e[42];let P;e[43]!==A?(P=r.jsx(lc,{label:"Cache savings",value:A}),e[43]=A,e[44]=P):P=e[44];const T=String(s.scannedFiles);let E;e[45]!==T?(E=r.jsx(lc,{label:"Files scanned",value:T}),e[45]=T,e[46]=E):E=e[46];let $;e[47]!==_||e[48]!==P||e[49]!==E?($=r.jsxs("div",{className:"grid grid-cols-3 gap-x-6 gap-y-3 border-t pt-3",children:[_,P,E]}),e[47]=_,e[48]=P,e[49]=E,e[50]=$):$=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]!==u.costUsd||e[53]!==u.models){let z;e[55]!==u.costUsd?(z=L=>{var W;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:(W=ur.find(U=>U.key===L.provider))==null?void 0:W.color}}),L.model]})}),r.jsx("td",{className:"py-1.5 text-right text-foreground tabular-nums",children:L.unpriced?"—":pn(L.costUsd)}),r.jsx("td",{className:"py-1.5 text-right text-muted-foreground tabular-nums",children:u.costUsd>0&&!L.unpriced?`${(L.costUsd/u.costUsd*100).toFixed(1)}%`:"—"}),r.jsx("td",{className:"py-1.5 text-right text-muted-foreground tabular-nums",children:ut(L.tokens)})]},`${L.provider}:${L.model}`)},e[55]=u.costUsd,e[56]=z):z=e[56],R=u.models.map(z),e[52]=u.costUsd,e[53]=u.models,e[54]=R}else R=e[54];let D;e[57]!==R?(D=r.jsxs("table",{className:"w-full text-sm",children:[I,r.jsx("tbody",{children:R})]}),e[57]=R,e[58]=D):D=e[58];const O=s.pricing.status==="unavailable"?" (rate table unavailable — costs incomplete)":"";let M;e[59]!==O?(M=r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Raw API-equivalent prices from LiteLLM rates",O," ","— not what a subscription bills."]}),e[59]=O,e[60]=M):M=e[60];let F;return e[61]!==k||e[62]!==C||e[63]!==$||e[64]!==D||e[65]!==M||e[66]!==m?(F=r.jsxs("div",{className:m,children:[k,C,$,D,M]}),e[61]=k,e[62]=C,e[63]=$,e[64]=D,e[65]=M,e[66]=m,e[67]=F):F=e[67],F}function iR(n){const e=B.c(15),{open:t,onOpenChange:s}=n,[o,i]=y.useState(30);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsxs("div",{children:[r.jsx(is,{children:"API usage"}),r.jsx(as,{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=Z$.map(m=>r.jsx(ee,{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(Ps,{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(rR,{days:o}),e[5]=o,e[6]=t,e[7]=d):d=e[7];let u;e[8]!==c||e[9]!==d?(u=r.jsxs(rs,{className:"max-h-[85vh] overflow-y-auto sm:max-w-3xl",children:[c,d]}),e[8]=c,e[9]=d,e[10]=u):u=e[10];let f;return e[11]!==s||e[12]!==t||e[13]!==u?(f=r.jsx(os,{open:t,onOpenChange:s,children:u}),e[11]=s,e[12]=t,e[13]=u,e[14]=f):f=e[14],f}const aR=/https:\/\/github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/,lR=/(?:^|[\n;&|(`])[ \t]*(?:[A-Za-z_]\w*=\S*[ \t]+)*gh[ \t]+pr[ \t]+create\b/,cc=String.raw`(?:--title|(?:^|\s)-t)(?:=|\s+)`,cR=[new RegExp(`${cc}"((?:[^"\\\\]|\\\\.)*)"`),new RegExp(`${cc}'([^']*)'`),new RegExp(`${cc}(\\S+)`)];function dR(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 uR(n){return dR(n).find(e=>lR.test(e))??null}function fR(n){for(const e of cR){const t=e.exec(n);if(t)return t[1].replace(/\\(.)/g,"$1")}return null}function mR(){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=aR.exec(s);l&&t({url:l[0],number:Number(l[3]),repo:`${l[1]}/${l[2]}`,title:fR(o),isDraft:/(?:^|\s)--draft(?:\s|$)/.test(o),toolCallId:i,timestamp:a})}}}function pR(n){const e=mR();for(const t of n)for(const s of t.toolCalls){if(s.isError||!s.result)continue;const o=uR(s.input);o&&e.record(s.result,o,s.id,s.timestamp)}return e.pullRequests}function hR(...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 co="flex h-8 items-center px-0.5",gR=y.memo(function(e){var Ne;const t=B.c(98),{showSidebar:s,sidebarRendered:o,sidebarShortcut:i,killing:a,creatingSession:l,onNewSession:c,onDuplicateSession:d,onOpenTerminal:u,onBackToMain:f,onShowWorkflows:m,workflowCount:p,onToggleSidebar:h,onKillAll:g,onOpenSettings:x}=e,b=o===void 0?s:o,{config:w}=Ht(),{networkUrl:v,defaultAgentKind:S}=w,{session:j,sessionSource:k,isLive:C}=at(),N=Nu(),_=An("viewUsage"),[A,P]=y.useState(!1),[T,E]=y.useState(!1),[$,I]=Ts(),R=j==null?void 0:j.turns;let D;t[0]!==(N==null?void 0:N.sessions)||t[1]!==(j==null?void 0:j.sessionId)?(D=(Ne=N==null?void 0:N.sessions.find(Se=>Se.sessionId===(j==null?void 0:j.sessionId)))==null?void 0:Ne.pullRequests,t[0]=N==null?void 0:N.sessions,t[1]=j==null?void 0:j.sessionId,t[2]=D):D=t[2];const O=D;let M;t[3]!==O||t[4]!==R?(M=hR(pR(R??[]),O),t[3]=O,t[4]=R,t[5]=M):M=t[5];const F=M;let z;t[6]!==S||t[7]!==k?(z=k?k.agentKind??$t(k.dirName):S,t[6]=S,t[7]=k,t[8]=z):z=t[8];const L=z;let W;t[9]!==k?(W=k?Ns(k.fileName)!==null:!1,t[9]=k,t[10]=W):W=t[10];const U=W;let H;t[11]!==I||t[12]!==j||t[13]!==(k==null?void 0:k.agentKind)||t[14]!==(k==null?void 0:k.dirName)?(H=function(){if(!j)return;const he=(k==null?void 0:k.agentKind)??$t((k==null?void 0:k.dirName)??null);I(eg(he,j.sessionId,j.cwd))},t[11]=I,t[12]=j,t[13]=k==null?void 0:k.agentKind,t[14]=k==null?void 0:k.dirName,t[15]=H):H=t[15];const K=H;let V;t[16]!==v?(V=function(){v&&Ur(v).then(bR)},t[16]=v,t[17]=V):V=t[17];const Y=V;let q,J;t[18]===Symbol.for("react.memo_cache_sentinel")?(J=r.jsx("div",{"aria-hidden":!0,className:"drag-strip absolute inset-x-0 top-0 z-10 h-10"}),q=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]=q,t[19]=J):(q=t[18],J=t[19]);const Q=!b&&"window-inset-start";let X;t[20]!==Q?(X=G("electron-no-drag pointer-events-auto flex min-w-0 items-center gap-1.5",Q),t[20]=Q,t[21]=X):X=t[21];let Z;t[22]!==h||t[23]!==s||t[24]!==i?(Z=!s&&r.jsx(xR,{icon:hw,label:`Show sidebar (${i})`,onClick:h}),t[22]=h,t[23]=s,t[24]=i,t[25]=Z):Z=t[25];let te;t[26]!==U||t[27]!==f||t[28]!==j?(te=j&&U&&f&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:f,className:G(Mn,"h-8 shrink-0 px-2.5 text-xs text-muted-foreground"),children:[r.jsx(Xe,{className:"size-3 rotate-180"}),"Main"]}),t[26]=U,t[27]=f,t[28]=j,t[29]=te):te=t[29];let ne;t[30]!==$||t[31]!==l||t[32]!==K||t[33]!==C||t[34]!==d||t[35]!==c||t[36]!==u||t[37]!==F||t[38]!==j||t[39]!==k?(ne=j&&r.jsx(x$,{session:j,sessionSource:k,isLive:C,pullRequests:F,copied:$,creatingSession:l,onCopyResume:K,onNewSession:c,onDuplicateSession:d,onOpenTerminal:u}),t[30]=$,t[31]=l,t[32]=K,t[33]=C,t[34]=d,t[35]=c,t[36]=u,t[37]=F,t[38]=j,t[39]=k,t[40]=ne):ne=t[40];let oe;t[41]!==m||t[42]!==j||t[43]!==p?(oe=j&&m&&(p??0)>0&&r.jsxs(ee,{variant:"ghost",size:"xs",className:G(Mn,"h-8 shrink-0 gap-1 px-2.5 text-[11px] text-muted-foreground hover:text-foreground"),onClick:m,children:[r.jsx(Ad,{className:"size-3"}),"Workflows",r.jsx(Pe,{variant:"outline",className:"h-4 min-w-4 justify-center px-1 text-[9px] font-semibold",children:p})]}),t[41]=m,t[42]=j,t[43]=p,t[44]=oe):oe=t[44];let re;t[45]!==X||t[46]!==Z||t[47]!==te||t[48]!==ne||t[49]!==oe?(re=r.jsxs("div",{className:X,children:[Z,te,ne,oe]}),t[45]=X,t[46]=Z,t[47]=te,t[48]=ne,t[49]=oe,t[50]=re):re=t[50];let ae,se,de;t[51]===Symbol.for("react.memo_cache_sentinel")?(ae=r.jsx("div",{className:G(Mn,co,"empty:hidden"),children:r.jsx(UP,{})}),se=r.jsx("div",{className:G(Mn,co,"empty:hidden"),children:r.jsx(XP,{})}),de=G(Mn,co,"empty:hidden"),t[51]=ae,t[52]=se,t[53]=de):(ae=t[51],se=t[52],de=t[53]);let le;t[54]!==L?(le=r.jsx("div",{className:de,children:r.jsx(B$,{agentKind:L})}),t[54]=L,t[55]=le):le=t[55];let ce;t[56]===Symbol.for("react.memo_cache_sentinel")?(ce=r.jsx("div",{className:G(Mn,co,"empty:hidden"),children:r.jsx(Hu,{})}),t[56]=ce):ce=t[56];let me;t[57]!==L||t[58]!==j?(me=j&&Gt(L).sharing&&ot("share")&&r.jsx("div",{className:G(Mn,co),children:r.jsx(E$,{sessionId:j.sessionId})}),t[57]=L,t[58]=j,t[59]=me):me=t[59];let ue;t[60]===Symbol.for("react.memo_cache_sentinel")?(ue=G(Mn,co),t[60]=ue):ue=t[60];let ie;t[61]===Symbol.for("react.memo_cache_sentinel")?(ie=r.jsx(Lo,{render:r.jsx(ee,{variant:"ghost",size:"icon-sm","aria-label":"More actions"}),children:r.jsx(F1,{"data-icon":"inline-start"})}),t[61]=ie):ie=t[61];let ge;t[62]!==_?(ge=_&&r.jsxs(Wt,{onClick:()=>P(!0),children:[r.jsx(B1,{}),"Usage & cost…"]}),t[62]=_,t[63]=ge):ge=t[63];let pe;t[64]===Symbol.for("react.memo_cache_sentinel")?(pe=r.jsxs(Wt,{onClick:()=>E(!0),children:[r.jsx(U1,{}),"Server monitor…"]}),t[64]=pe):pe=t[64];let xe;t[65]!==Y||t[66]!==v?(xe=v&&r.jsxs(Wt,{onClick:Y,children:[r.jsx(ta,{className:"text-success"}),"Copy network URL",r.jsx("span",{className:"ml-auto truncate pl-2 font-mono text-[11px] text-muted-foreground",children:v})]}),t[65]=Y,t[66]=v,t[67]=xe):xe=t[67];let Ce;t[68]!==ge||t[69]!==xe?(Ce=r.jsxs(Zn,{children:[ge,pe,xe]}),t[68]=ge,t[69]=xe,t[70]=Ce):Ce=t[70];let Te;t[71]===Symbol.for("react.memo_cache_sentinel")?(Te=r.jsx(oa,{}),t[71]=Te):Te=t[71];let Ee;t[72]===Symbol.for("react.memo_cache_sentinel")?(Ee=r.jsx(gw,{}),t[72]=Ee):Ee=t[72];let $e;t[73]!==x?($e=r.jsx(Zn,{children:r.jsxs(Wt,{onClick:x,children:[Ee,"Settings"]})}),t[73]=x,t[74]=$e):$e=t[74];let Re;t[75]!==a||t[76]!==g?(Re=ot("killAny")&&r.jsxs(r.Fragment,{children:[r.jsx(oa,{}),r.jsx(Zn,{children:r.jsxs(Wt,{variant:"destructive",onClick:g,disabled:a,children:[r.jsx(pw,{}),a?"Stopping processes…":"Stop all agent processes"]})})]}),t[75]=a,t[76]=g,t[77]=Re):Re=t[77];let Fe;t[78]!==Ce||t[79]!==$e||t[80]!==Re?(Fe=r.jsx("div",{className:ue,children:r.jsxs(Do,{children:[ie,r.jsxs(zo,{align:"end",sideOffset:6,className:"w-64",children:[Ce,Te,$e,Re]})]})}),t[78]=Ce,t[79]=$e,t[80]=Re,t[81]=Fe):Fe=t[81];let Le;t[82]!==le||t[83]!==me||t[84]!==Fe?(Le=r.jsxs("div",{className:"electron-no-drag window-inset-end pointer-events-auto flex shrink-0 items-center gap-1.5",children:[ae,se,le,ce,me,Fe]}),t[82]=le,t[83]=me,t[84]=Fe,t[85]=Le):Le=t[85];let Ie;t[86]!==re||t[87]!==Le?(Ie=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:[re,Le]}),t[86]=re,t[87]=Le,t[88]=Ie):Ie=t[88];let _e;t[89]!==_||t[90]!==A?(_e=_&&r.jsx(iR,{open:A,onOpenChange:P}),t[89]=_,t[90]=A,t[91]=_e):_e=t[91];let je;t[92]!==T?(je=r.jsx(a$,{open:T,onOpenChange:E}),t[92]=T,t[93]=je):je=t[93];let ze;return t[94]!==Ie||t[95]!==_e||t[96]!==je?(ze=r.jsxs(r.Fragment,{children:[J,q,Ie,_e,je]}),t[94]=Ie,t[95]=_e,t[96]=je,t[97]=ze):ze=t[97],ze});function xR(n){const e=B.c(14),{icon:t,label:s,onClick:o}=n;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=G(Mn,"size-8 shrink-0"),e[0]=i):i=e[0];let a;e[1]!==s||e[2]!==o?(a=r.jsx(ee,{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(Mt,{render:a,children:l}),e[6]=a,e[7]=l,e[8]=c):c=e[8];let d;e[9]!==s?(d=r.jsx(Ot,{side:"bottom",children:s}),e[9]=s,e[10]=d):d=e[10];let u;return e[11]!==c||e[12]!==d?(u=r.jsxs(It,{children:[c,d]}),e[11]=c,e[12]=d,e[13]=u):u=e[13],u}function bR(n){n&&Ms.success("Copied network URL")}const vR=y.memo(function(e){const t=B.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(Ml,{icon:ys,label:"Home",onClick:o,size:"default"}),t[1]=o,t[2]=d):d=t[2];const u=`Search (${l})`;let f;t[3]!==i||t[4]!==u?(f=r.jsx(Ml,{icon:an,label:u,onClick:i,size:"default"}),t[3]=i,t[4]=u,t[5]=f):f=t[5];const m=`Hide sidebar (${a})`;let p;t[6]!==s||t[7]!==m?(p=r.jsx(Ml,{icon:xw,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]!==f||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,f,p]}),t[9]=d,t[10]=f,t[11]=p,t[12]=h):h=t[12],h});function yR(n){const e=B.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(yw,{"data-slot":"resizable-panel-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function _h(n){const e=B.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(vw,{"data-slot":"resizable-panel",...t}),e[2]=t,e[3]=s):s=e[3],s}function wR(n){const e=B.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(bw,{"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}const mb=y.createContext(null);function jR(n){const e=B.c(3),{value:t,children:s}=n;let o;return e[0]!==s||e[1]!==t?(o=r.jsx(mb.Provider,{value:t,children:s}),e[0]=s,e[1]=t,e[2]=o):o=e[2],o}function Vu(){const n=y.useContext(mb);if(!n)throw new Error("Built-in workspace panel services are unavailable");return n}function pb(n){const e=B.c(18),{title:t,icon:s,active:o,onClick:i,children:a}=n,l=o&&"bg-sidebar-primary text-sidebar-primary-foreground hover:bg-sidebar-primary/90 hover:text-sidebar-primary-foreground";let c;e[0]!==l?(c=G("relative rounded-md",l),e[0]=l,e[1]=c):c=e[1];let d;e[2]!==o||e[3]!==i||e[4]!==c||e[5]!==t?(d=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm","aria-label":t,"aria-pressed":o,onClick:i,className:c}),e[2]=o,e[3]=i,e[4]=c,e[5]=t,e[6]=d):d=e[6];let u;e[7]!==s?(u=r.jsx(s,{"data-icon":"inline-start"}),e[7]=s,e[8]=u):u=e[8];let f;e[9]!==a||e[10]!==d||e[11]!==u?(f=r.jsxs(Mt,{render:d,children:[u,a]}),e[9]=a,e[10]=d,e[11]=u,e[12]=f):f=e[12];let m;e[13]!==t?(m=r.jsx(Ot,{side:"left",children:t}),e[13]=t,e[14]=m):m=e[14];let p;return e[15]!==f||e[16]!==m?(p=r.jsxs(It,{children:[f,m]}),e[15]=f,e[16]=m,e[17]=p):p=e[17],p}function hb(n,e){return n.filter(t=>{var s;return((s=t.when)==null?void 0:s.call(t,e))??!0})}function SR(n){const e=B.c(25),{panels:t,context:s,activePanelId:o,onTogglePanel:i,actions:a}=n;let l;e[0]!==a?(l=a===void 0?[]:a,e[0]=a,e[1]=l):l=e[1];const c=l;let d,u,f,m,p,h;if(e[2]!==c||e[3]!==o||e[4]!==s||e[5]!==i||e[6]!==t){h=Symbol.for("react.early_return_sentinel");e:{const x=hb(t,s);if(x.length===0&&c.length===0){h=null;break e}d="Workspace panels",u="electron-no-drag flex w-11 shrink-0 flex-col items-center gap-1 border-l bg-sidebar py-2 text-sidebar-foreground",e[13]!==c?(f=c.map(NR),e[13]=c,e[14]=f):f=e[14],m=c.length>0&&x.length>0&&r.jsx("div",{"aria-hidden":!0,className:"my-1 h-px w-6 bg-sidebar-border"});let b;e[15]!==o||e[16]!==s||e[17]!==i?(b=w=>{var k;const v=w.id===o,S=(k=w.badge)==null?void 0:k.call(w,s),j=w.indicator;return r.jsx(pb,{title:w.title,icon:w.icon,active:v,onClick:()=>i(w.id),children:j?r.jsx(j,{context:s,active:v}):S!=null&&r.jsx(Pe,{className:"absolute -right-1 -top-1 min-w-4 px-1 text-[9px]",variant:"secondary",children:S})},w.id)},e[15]=o,e[16]=s,e[17]=i,e[18]=b):b=e[18],p=x.map(b)}e[2]=c,e[3]=o,e[4]=s,e[5]=i,e[6]=t,e[7]=d,e[8]=u,e[9]=f,e[10]=m,e[11]=p,e[12]=h}else d=e[7],u=e[8],f=e[9],m=e[10],p=e[11],h=e[12];if(h!==Symbol.for("react.early_return_sentinel"))return h;let g;return e[19]!==d||e[20]!==u||e[21]!==f||e[22]!==m||e[23]!==p?(g=r.jsxs("aside",{"aria-label":d,className:u,children:[f,m,p]}),e[19]=d,e[20]=u,e[21]=f,e[22]=m,e[23]=p,e[24]=g):g=e[24],g}function NR(n){return r.jsx(pb,{title:n.title,icon:n.icon,active:n.active,onClick:n.onSelect},n.id)}function kR(n){const e=B.c(20),{panels:t,context:s,activePanelId:o,onClosePanel:i,onOpenPanel:a}=n;let l;e[0]!==o?(l=()=>new Set([o]),e[0]=o,e[1]=l):l=e[1];const[c,d]=y.useState(l);let u,f;e[2]!==o?(u=()=>{d(h=>{if(h.has(o))return h;const g=new Set(h);return g.add(o),g})},f=[o],e[2]=o,e[3]=u,e[4]=f):(u=e[3],f=e[4]),y.useEffect(u,f);let m;if(e[5]!==o||e[6]!==s||e[7]!==i||e[8]!==a||e[9]!==t||e[10]!==c){let h;e[12]!==o||e[13]!==s||e[14]!==i||e[15]!==a||e[16]!==c?(h=g=>{const x=g.id===o;if(!x&&(!g.keepAlive||!c.has(g.id)))return null;const b=g.component;return r.jsx("div",{className:G("absolute inset-0 min-h-0",!x&&"hidden"),"aria-hidden":!x,children:r.jsx(b,{context:s,active:x,closePanel:i,openPanel:a})},g.id)},e[12]=o,e[13]=s,e[14]=i,e[15]=a,e[16]=c,e[17]=h):h=e[17],m=t.map(h),e[5]=o,e[6]=s,e[7]=i,e[8]=a,e[9]=t,e[10]=c,e[11]=m}else m=e[11];let p;return e[18]!==m?(p=r.jsx("div",{className:"relative h-full min-h-0 overflow-hidden bg-background",children:m}),e[18]=m,e[19]=p):p=e[19],p}function CR(n){const e=n==null?void 0:n.match(/^(\d+(?:\.\d+)?)%$/);if(!e)return"64%";const t=Number(e[1]);return t>0&&t<100?`${100-t}%`:"64%"}function _R(n){const e=B.c(24),{children:t,panels:s,context:o,activePanel:i,services:a,onClosePanel:l,onOpenPanel:c,onTogglePanel:d,actions:u}=n;let f;e[0]!==i?(f=i?CR(i.defaultSize):"100%",e[0]=i,e[1]=f):f=e[1];let m;e[2]!==t||e[3]!==f?(m=r.jsx(_h,{defaultSize:f,minSize:"320px",children:t}),e[2]=t,e[3]=f,e[4]=m):m=e[4];let p;e[5]!==i||e[6]!==o||e[7]!==l||e[8]!==c||e[9]!==s||e[10]!==a?(p=i&&r.jsxs(r.Fragment,{children:[r.jsx(wR,{withHandle:!0}),r.jsx(_h,{defaultSize:i.defaultSize??"36%",minSize:i.minSize??"300px",maxSize:i.maxSize??"70%",children:r.jsx(jR,{value:a,children:r.jsx(kR,{panels:s,context:o,activePanelId:i.id,onClosePanel:l,onOpenPanel:c})})})]}),e[5]=i,e[6]=o,e[7]=l,e[8]=c,e[9]=s,e[10]=a,e[11]=p):p=e[11];let h;e[12]!==m||e[13]!==p?(h=r.jsxs(yR,{orientation:"horizontal",className:"min-h-0 min-w-0 w-auto flex-1",children:[m,p]}),e[12]=m,e[13]=p,e[14]=h):h=e[14];const g=(i==null?void 0:i.id)??null;let x;e[15]!==u||e[16]!==o||e[17]!==d||e[18]!==s||e[19]!==g?(x=r.jsx(SR,{panels:s,context:o,activePanelId:g,onTogglePanel:d,actions:u}),e[15]=u,e[16]=o,e[17]=d,e[18]=s,e[19]=g,e[20]=x):x=e[20];let b;return e[21]!==h||e[22]!==x?(b=r.jsxs(r.Fragment,{children:[h,x]}),e[21]=h,e[22]=x,e[23]=b):b=e[23],b}const ci={data:null,error:null,loading:!1,refreshing:!1},TR=8e3,ER=new Set(["clickup_not_configured","clickup_auth_failed","project_unlinked"]),gl="*",Gu={endpoint:()=>"/api/clickup/status",pollIntervalMs:5*6e4,fallbackError:"Unable to reach ClickUp",stores:new Map},gb={endpoint:()=>"/api/clickup/tasks/mine",pollIntervalMs:6e4,fallbackError:"Unable to load your ClickUp tasks",stores:new Map},ba={endpoint:n=>`/api/clickup/tasks/list?cwd=${encodeURIComponent(n)}`,pollIntervalMs:6e4,fallbackError:"Unable to load the linked ClickUp list",stores:new Map};function va(n,e){let t=n.stores.get(e);return t||(t={snapshot:ci,listeners:new Set,request:null,fetchedAt:0},n.stores.set(e,t)),t}function fr(n,e){n.snapshot=e;for(const t of n.listeners)t()}async function xb(n){try{const e=await n.json();if(typeof e.error=="string"&&typeof e.code=="string")return e}catch{}return{error:`ClickUp request failed (${n.status})`,code:"clickup_api_failed"}}function mr(n,e){const t=n;return{error:typeof t.error=="string"?t.error:e,code:typeof t.code=="string"?t.code:"clickup_api_failed"}}async function So(n,e,t=!1){const s=va(n,e);if(s.request)return s.request;if(!(!t&&s.snapshot.error&&ER.has(s.snapshot.error.code))&&!(!t&&s.fetchedAt>0&&Date.now()-s.fetchedAt<TR))return(t||s.snapshot.data===null)&&fr(s,{...s.snapshot,error:t?null:s.snapshot.error,loading:s.snapshot.data===null,refreshing:s.snapshot.data!==null}),s.request=be(n.endpoint(e)).then(async o=>{if(!o.ok)throw await xb(o);const i=await o.json();s.fetchedAt=Date.now(),fr(s,{data:i,error:null,loading:!1,refreshing:!1})}).catch(o=>{fr(s,{...s.snapshot,error:mr(o,n.fallbackError),loading:!1,refreshing:!1})}).finally(()=>{s.request=null}),s.request}function Yu(n,e,t){const s=B.c(17),o=e??"";let i;s[0]!==n||s[1]!==o?(i=p=>{if(!o)return PR;const h=va(n,o);return h.listeners.add(p),()=>h.listeners.delete(p)},s[0]=n,s[1]=o,s[2]=i):i=s[2];let a;s[3]!==n||s[4]!==o?(a=()=>o?va(n,o).snapshot:ci,s[3]=n,s[4]=o,s[5]=a):a=s[5];const l=y.useSyncExternalStore(i,a,AR);let c,d;s[6]!==t||s[7]!==n||s[8]!==o?(c=()=>{if(!t||!o)return;So(n,o);const p=window.setInterval(()=>{So(n,o)},n.pollIntervalMs);return()=>window.clearInterval(p)},d=[n,t,o],s[6]=t,s[7]=n,s[8]=o,s[9]=c,s[10]=d):(c=s[9],d=s[10]),y.useEffect(c,d);let u;s[11]!==n||s[12]!==o?(u=()=>o?So(n,o,!0):Promise.resolve(),s[11]=n,s[12]=o,s[13]=u):u=s[13];const f=u;let m;return s[14]!==f||s[15]!==l?(m={...l,refresh:f},s[14]=f,s[15]=l,s[16]=m):m=s[16],m}function AR(){return ci}function PR(){}function bb(n){return Yu(Gu,gl,n)}function vb(n){return Yu(gb,gl,n)}function $R(n,e){return Yu(ba,n,e)}async function di(n,e){const t=await be(n,e);if(!t.ok)throw await xb(t);return t.json()}function yb(n,e){return{method:n,headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}}function wb(){for(const n of[gb,ba])for(const e of n.stores.values())e.fetchedAt=0,fr(e,ci)}async function RR(n){await di("/api/clickup/token",yb("POST",{token:n})),wb(),await So(Gu,gl,!0)}async function IR(){await di("/api/clickup/token",{method:"DELETE"}),wb(),await So(Gu,gl,!0)}async function jb(n,e){await di("/api/clickup/project-list",yb("PUT",{cwd:n,listId:e}));const t=va(ba,n);t.fetchedAt=0,fr(t,ci),e!==null&&await So(ba,n,!0)}function MR(){return di("/api/clickup/spaces")}function OR(n){return di(`/api/clickup/lists?spaceId=${encodeURIComponent(n)}`)}const Th={status:null,due:"all",priority:null,query:""},Eh={urgent:0,high:1,normal:2,low:3},Ah=1440*60*1e3;function Bo(n){return n.status.type==="closed"}function Sb(n){const e=new Date(n);return e.setHours(0,0,0,0),e.getTime()}function Ro(n,e){return n.dueAt!==null&&!Bo(n)&&n.dueAt<Sb(e)}function Nb(n,e,t){if(e==="all")return!0;if(e==="none")return n.dueAt===null;if(n.dueAt===null)return!1;const s=Sb(t);switch(e){case"overdue":return Ro(n,t);case"today":return n.dueAt>=s&&n.dueAt<s+Ah;case"week":return n.dueAt>=s&&n.dueAt<s+7*Ah}}function DR(n,e){const t=e.trim().toLowerCase();return t?[n.name,n.customId??"",n.listName,n.folderName??"",...n.tags.map(s=>s.name)].some(s=>s.toLowerCase().includes(t)):!0}function LR(n,e,t){return n.filter(s=>(e.status===null||s.status.name===e.status)&&(e.priority===null||s.priority===e.priority)&&Nb(s,e.due,t)&&DR(s,e.query))}function zR(n){const e=new Map;for(const t of n)e.has(t.status.name)||e.set(t.status.name,t.status);return[...e.values()].sort((t,s)=>t.order-s.order||t.name.localeCompare(s.name))}function FR(n,e){return[...n].sort((t,s)=>{const o=Number(Ro(s,e))-Number(Ro(t,e));if(o!==0)return o;if(t.dueAt!==s.dueAt)return t.dueAt===null?1:s.dueAt===null?-1:t.dueAt-s.dueAt;const i=(t.priority?Eh[t.priority]:4)-(s.priority?Eh[s.priority]:4);return i!==0?i:s.updatedAt-t.updatedAt})}function Xu(n,e){return n?`${n} › ${e}`:e}function BR(n){const e=n.customId??n.id,t=n.description.trim();return[`Work on ClickUp task ${e}: ${n.name}`,n.url,...t?["",t]:[]].join(`
|
|
125
|
+
`)}function UR(n){const e=n.trim();if(/^\d+$/.test(e))return e;const t=e.match(/\/li\/(\d+)/)??e.match(/\/list\/(\d+)/);return t?t[1]:null}const WR={urgent:"text-destructive",high:"text-warning",normal:"text-info",low:"text-muted-foreground"},HR=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"});function kb(n){const e=B.c(5),{priority:t}=n;if(!t)return null;const s=WR[t];let o;e[0]!==s?(o=G("size-3 shrink-0",s),e[0]=s,e[1]=o):o=e[1];const i=`${t} priority`;let a;return e[2]!==o||e[3]!==i?(a=r.jsx(Co,{className:o,"aria-label":i,role:"img",fill:"currentColor"}),e[2]=o,e[3]=i,e[4]=a):a=e[4],a}function qR(n){const e=B.c(14),{task:t,now:s}=n;if(t.dueAt===null)return null;const o=Ro(t,s);let i;e[0]!==t.dueAt?(i=new Date(t.dueAt).toLocaleDateString(),e[0]=t.dueAt,e[1]=i):i=e[1];const a=`Due ${i}`,l=o?"text-destructive":"text-muted-foreground";let c;e[2]!==l?(c=G("flex shrink-0 items-center gap-0.5 text-[10px] tabular-nums",l),e[2]=l,e[3]=c):c=e[3];let d;e[4]!==t.dueAt?(d=new Date(t.dueAt).toISOString(),e[4]=t.dueAt,e[5]=d):d=e[5];const u=o?`${a} (overdue)`:a;let f;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(jw,{className:"size-3","aria-hidden":!0}),e[6]=f):f=e[6];let m;e[7]!==t.dueAt?(m=HR.format(t.dueAt),e[7]=t.dueAt,e[8]=m):m=e[8];let p;return e[9]!==c||e[10]!==d||e[11]!==u||e[12]!==m?(p=r.jsxs("time",{className:c,dateTime:d,title:u,children:[f,m]}),e[9]=c,e[10]=d,e[11]=u,e[12]=m,e[13]=p):p=e[13],p}function KR(n){const e=B.c(14),{assignees:t,viewer:s}=n;let o,i,a,l,c;if(e[0]!==t||e[1]!==s){c=Symbol.for("react.early_return_sentinel");e:{let u;e[7]!==s?(u=p=>p.id!==s.id,e[7]=s,e[8]=u):u=e[8];const f=t.filter(u);if(f.length===0){c=null;break e}const m=`Also assigned to ${f.map(GR).join(", ")}`;o="flex shrink-0 -space-x-1",i=m,a=m,l=f.slice(0,3).map(VR)}e[0]=t,e[1]=s,e[2]=o,e[3]=i,e[4]=a,e[5]=l,e[6]=c}else o=e[2],i=e[3],a=e[4],l=e[5],c=e[6];if(c!==Symbol.for("react.early_return_sentinel"))return c;let d;return e[9]!==o||e[10]!==i||e[11]!==a||e[12]!==l?(d=r.jsx("span",{className:o,"aria-label":i,title:a,children:l}),e[9]=o,e[10]=i,e[11]=a,e[12]=l,e[13]=d):d=e[13],d}function VR(n){return r.jsx("span",{className:"flex size-4 items-center justify-center rounded-full border border-background text-[8px] font-medium text-white",style:{backgroundColor:n.color??"#6b7280"},"aria-hidden":!0,children:n.initials.slice(0,2)},n.id)}function GR(n){return n.username}function YR(n){const e=B.c(130),{task:t,viewer:s,now:o,onPickStatus:i,composePrompt:a}=n,[l,c]=y.useState(!1);let d,u,f,m,p,h,g,x,b,w,v,S,j,k,C,N;if(e[0]!==l||e[1]!==t){const ie=Bo(t);let ge;e[18]!==t.description?(ge=t.description.trim(),e[18]=t.description,e[19]=ge):ge=e[19],f=ge;let pe;e[20]!==t.folderName||e[21]!==t.listName?(pe=Xu(t.folderName,t.listName),e[20]=t.folderName,e[21]=t.listName,e[22]=pe):pe=e[22],m=pe,h="relative pl-3",g=t.name,e[23]!==t.status.color?(x=r.jsx("span",{"aria-hidden":!0,className:"absolute inset-y-1 left-0 w-0.5 rounded-full",style:{backgroundColor:t.status.color}}),e[23]=t.status.color,e[24]=x):x=e[24],u=ft,C=l,N=c,k="group/task flex items-start gap-1 pr-1",d=Rt,v="flex min-w-0 flex-1 flex-col rounded-sm px-1 py-1 text-left outline-none hover:bg-accent/60 focus-visible:ring-[3px] focus-visible:ring-ring/20",S=`${t.name}: ${t.status.name}`,j=l,b="flex min-w-0 items-center gap-2",e[25]!==t.priority?(w=r.jsx(kb,{priority:t.priority}),e[25]=t.priority,e[26]=w):w=e[26],p=G("min-w-0 flex-1 truncate text-[13px] font-medium leading-5",ie&&"text-muted-foreground line-through decoration-border"),e[0]=l,e[1]=t,e[2]=d,e[3]=u,e[4]=f,e[5]=m,e[6]=p,e[7]=h,e[8]=g,e[9]=x,e[10]=b,e[11]=w,e[12]=v,e[13]=S,e[14]=j,e[15]=k,e[16]=C,e[17]=N}else d=e[2],u=e[3],f=e[4],m=e[5],p=e[6],h=e[7],g=e[8],x=e[9],b=e[10],w=e[11],v=e[12],S=e[13],j=e[14],k=e[15],C=e[16],N=e[17];let _;e[27]!==p||e[28]!==t.name?(_=r.jsx("span",{className:p,children:t.name}),e[27]=p,e[28]=t.name,e[29]=_):_=e[29];let A;e[30]!==t.customId?(A=t.customId&&r.jsx("span",{className:"shrink-0 font-mono text-[10px] text-muted-foreground",children:t.customId}),e[30]=t.customId,e[31]=A):A=e[31];let P;e[32]!==_||e[33]!==A||e[34]!==b||e[35]!==w?(P=r.jsxs("span",{className:b,children:[w,_,A]}),e[32]=_,e[33]=A,e[34]=b,e[35]=w,e[36]=P):P=e[36];let T;e[37]!==t.status.color?(T={color:t.status.color},e[37]=t.status.color,e[38]=T):T=e[38];let E;e[39]!==T||e[40]!==t.status.name?(E=r.jsx("span",{className:"shrink-0 rounded-sm px-1 text-[10px] uppercase tracking-wide",style:T,children:t.status.name}),e[39]=T,e[40]=t.status.name,e[41]=E):E=e[41];let $;e[42]!==m?($=r.jsx("span",{className:"truncate",children:m}),e[42]=m,e[43]=$):$=e[43];let I;e[44]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx("span",{className:"shrink-0",children:"·"}),e[44]=I):I=e[44];let R;e[45]!==t.updatedAt?(R=new Date(t.updatedAt).toISOString(),e[45]=t.updatedAt,e[46]=R):R=e[46];let D;e[47]!==t.updatedAt?(D=new Date(t.updatedAt).toLocaleString(),e[47]=t.updatedAt,e[48]=D):D=e[48];let O;e[49]!==o||e[50]!==t.updatedAt?(O=fl(new Date(t.updatedAt).toISOString(),o),e[49]=o,e[50]=t.updatedAt,e[51]=O):O=e[51];let M;e[52]!==R||e[53]!==D||e[54]!==O?(M=r.jsx("time",{className:"shrink-0",dateTime:R,title:D,children:O}),e[52]=R,e[53]=D,e[54]=O,e[55]=M):M=e[55];let F;e[56]!==E||e[57]!==$||e[58]!==M?(F=r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-[11px] leading-4 text-muted-foreground",children:[E,$,I,M]}),e[56]=E,e[57]=$,e[58]=M,e[59]=F):F=e[59];let z;e[60]!==d||e[61]!==P||e[62]!==F||e[63]!==v||e[64]!==S||e[65]!==j?(z=r.jsxs(d,{className:v,"aria-label":S,"aria-expanded":j,children:[P,F]}),e[60]=d,e[61]=P,e[62]=F,e[63]=v,e[64]=S,e[65]=j,e[66]=z):z=e[66];let L;e[67]!==o||e[68]!==t?(L=r.jsx(qR,{task:t,now:o}),e[67]=o,e[68]=t,e[69]=L):L=e[69];let W;e[70]!==t.assignees||e[71]!==s?(W=r.jsx(KR,{assignees:t.assignees,viewer:s}),e[70]=t.assignees,e[71]=s,e[72]=W):W=e[72];const U=`Open ${t.customId??t.name} in ClickUp`;let H;e[73]!==t.url?(H=()=>window.open(t.url,"_blank","noopener,noreferrer"),e[73]=t.url,e[74]=H):H=e[74];let K;e[75]===Symbol.for("react.memo_cache_sentinel")?(K=r.jsx(Zt,{}),e[75]=K):K=e[75];let V;e[76]!==U||e[77]!==H?(V=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",className:"size-6 text-muted-foreground opacity-0 transition-opacity group-hover/task:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100","aria-label":U,onClick:H,children:K}),e[76]=U,e[77]=H,e[78]=V):V=e[78];let Y;e[79]!==L||e[80]!==W||e[81]!==V?(Y=r.jsxs("div",{className:"mt-1 flex shrink-0 items-center gap-1.5",children:[L,W,V]}),e[79]=L,e[80]=W,e[81]=V,e[82]=Y):Y=e[82];let q;e[83]!==z||e[84]!==Y||e[85]!==k?(q=r.jsxs("div",{className:k,children:[z,Y]}),e[83]=z,e[84]=Y,e[85]=k,e[86]=q):q=e[86];let J;e[87]!==f?(J=f?r.jsx(Wu,{body:f}):r.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"No description."}),e[87]=f,e[88]=J):J=e[88];let Q;e[89]!==i||e[90]!==t.status.name?(Q=()=>i(t.status.name),e[89]=i,e[90]=t.status.name,e[91]=Q):Q=e[91];const X=`Only tasks in ${t.status.name}`;let Z;e[92]!==t.status.color?(Z=r.jsx("span",{"aria-hidden":!0,className:"size-2 rounded-full",style:{backgroundColor:t.status.color}}),e[92]=t.status.color,e[93]=Z):Z=e[93];let te;e[94]!==Q||e[95]!==X||e[96]!==Z||e[97]!==t.status.name?(te=r.jsx("li",{children:r.jsxs("button",{type:"button",className:"inline-flex h-5 items-center gap-1 rounded-full border px-1.5 text-[10px] leading-none text-muted-foreground outline-none hover:border-foreground/30 hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/20",onClick:Q,"aria-label":X,children:[Z,t.status.name]})}),e[94]=Q,e[95]=X,e[96]=Z,e[97]=t.status.name,e[98]=te):te=e[98];let ne;e[99]!==t.tags?(ne=t.tags.map(XR),e[99]=t.tags,e[100]=ne):ne=e[100];let oe;e[101]!==te||e[102]!==ne?(oe=r.jsxs("ul",{className:"flex flex-wrap gap-1","aria-label":"Task details",children:[te,ne]}),e[101]=te,e[102]=ne,e[103]=oe):oe=e[103];let re;e[104]!==a||e[105]!==t?(re=a&&r.jsxs(ee,{type:"button",size:"xs",onClick:()=>a(BR(t)),children:[r.jsx(W1,{"data-icon":"inline-start"}),"Add to prompt"]}),e[104]=a,e[105]=t,e[106]=re):re=e[106];let ae;e[107]!==t.url?(ae=r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer"}),e[107]=t.url,e[108]=ae):ae=e[108];let se;e[109]===Symbol.for("react.memo_cache_sentinel")?(se=r.jsx(Zt,{"data-icon":"inline-end"}),e[109]=se):se=e[109];let de;e[110]!==ae?(de=r.jsxs(ee,{variant:"outline",size:"xs",render:ae,children:["Open in ClickUp",se]}),e[110]=ae,e[111]=de):de=e[111];let le;e[112]!==re||e[113]!==de?(le=r.jsxs("div",{className:"flex flex-wrap gap-2",children:[re,de]}),e[112]=re,e[113]=de,e[114]=le):le=e[114];let ce;e[115]!==J||e[116]!==oe||e[117]!==le?(ce=r.jsx(mt,{children:r.jsxs("div",{className:"flex flex-col gap-3 py-2 pl-1 pr-1",children:[J,oe,le]})}),e[115]=J,e[116]=oe,e[117]=le,e[118]=ce):ce=e[118];let me;e[119]!==u||e[120]!==q||e[121]!==ce||e[122]!==C||e[123]!==N?(me=r.jsxs(u,{open:C,onOpenChange:N,children:[q,ce]}),e[119]=u,e[120]=q,e[121]=ce,e[122]=C,e[123]=N,e[124]=me):me=e[124];let ue;return e[125]!==h||e[126]!==g||e[127]!==x||e[128]!==me?(ue=r.jsxs("article",{className:h,"aria-label":g,children:[x,me]}),e[125]=h,e[126]=g,e[127]=x,e[128]=me,e[129]=ue):ue=e[129],ue}function XR(n){return r.jsx("li",{className:"inline-flex h-5 items-center rounded-full border px-1.5 text-[10px] leading-none text-muted-foreground",children:n.name},n.name)}function Cb(n){const e=B.c(75),{tasks:t,viewer:s,composePrompt:o,emptyTitle:i,emptyDescription:a,truncated:l}=n,[c,d]=y.useState(Th),u=ml(!1);if(t.length===0){let C;return e[0]!==a||e[1]!==i?(C=r.jsx(pl,{icon:ww,title:i,description:a}),e[0]=a,e[1]=i,e[2]=C):C=e[2],C}let f,m,p,h,g,x,b,w;if(e[3]!==o||e[4]!==c||e[5]!==u||e[6]!==t||e[7]!==s){const C=t.filter(eI),N=zR(C),_=[...new Set(C.flatMap(ZR))],A=ue=>C.filter(ie=>Nb(ie,ue,u)).length,P=A("overdue"),T=A("today"),E=A("week"),$=LR(t,c,u),I=FR($.filter(QR),u),R=$.filter(Bo).sort(JR);let D;e[16]===Symbol.for("react.memo_cache_sentinel")?(D=ue=>d(ie=>({...ie,...ue})),e[16]=D):D=e[16];const O=D;let M;e[17]!==c.due||e[18]!==c.priority||e[19]!==c.query||e[20]!==c.status?(M=c.status!==null||c.due!=="all"||c.priority!==null||c.query.trim()!=="",e[17]=c.due,e[18]=c.priority,e[19]=c.query,e[20]=c.status,e[21]=M):M=e[21];const F=M;let z;e[22]!==o||e[23]!==u||e[24]!==s?(z=ue=>r.jsx(YR,{task:ue,viewer:s,now:u,onPickStatus:ie=>O({status:ie}),composePrompt:o},ue.id),e[22]=o,e[23]=u,e[24]=s,e[25]=z):z=e[25];const L=z;let W;e[26]===Symbol.for("react.memo_cache_sentinel")?(W=r.jsx(an,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}),e[26]=W):W=e[26];let U;e[27]===Symbol.for("react.memo_cache_sentinel")?(U=ue=>O({query:ue.target.value}),e[27]=U):U=e[27];let H;e[28]!==c.query?(H=r.jsx(Dt,{type:"search",value:c.query,onChange:U,placeholder:"Search tasks","aria-label":"Search tasks",className:"h-7 border-0 bg-transparent px-0 text-xs shadow-none focus-visible:ring-0"}),e[28]=c.query,e[29]=H):H=e[29];let K;e[30]!==F?(K=F&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>d(Th),"aria-label":"Clear filters",children:[r.jsx(nt,{"data-icon":"inline-start"}),"Clear"]}),e[30]=F,e[31]=K):K=e[31],e[32]!==H||e[33]!==K?(x=r.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b px-3 py-1.5",children:[W,H,K]}),e[32]=H,e[33]=K,e[34]=x):x=e[34];let V;e[35]===Symbol.for("react.memo_cache_sentinel")?(V=()=>O({due:"all"}),e[35]=V):V=e[35];const Y=c.due==="overdue",q=P===0;let J;e[36]===Symbol.for("react.memo_cache_sentinel")?(J=()=>O({due:"overdue"}),e[36]=J):J=e[36];const Q=P>0&&c.due!=="overdue"?"text-destructive":void 0;let X;e[37]!==P?(X=r.jsx(wt,{children:P}),e[37]=P,e[38]=X):X=e[38];let Z;e[39]!==Y||e[40]!==q||e[41]!==Q||e[42]!==X?(Z=r.jsxs(yt,{pressed:Y,disabled:q,onClick:J,className:Q,children:["Overdue",X]}),e[39]=Y,e[40]=q,e[41]=Q,e[42]=X,e[43]=Z):Z=e[43];const te=c.due==="today",ne=T===0;let oe;e[44]===Symbol.for("react.memo_cache_sentinel")?(oe=()=>O({due:"today"}),e[44]=oe):oe=e[44];let re;e[45]!==T?(re=r.jsx(wt,{children:T}),e[45]=T,e[46]=re):re=e[46];let ae;e[47]!==te||e[48]!==ne||e[49]!==re?(ae=r.jsxs(yt,{pressed:te,disabled:ne,onClick:oe,children:["Today",re]}),e[47]=te,e[48]=ne,e[49]=re,e[50]=ae):ae=e[50];const se=c.due==="week",de=E===0;let le;e[51]===Symbol.for("react.memo_cache_sentinel")?(le=()=>O({due:"week"}),e[51]=le):le=e[51];let ce;e[52]!==E?(ce=r.jsx(wt,{children:E}),e[52]=E,e[53]=ce):ce=e[53];let me;e[54]!==se||e[55]!==de||e[56]!==ce?(me=r.jsxs(yt,{pressed:se,disabled:de,onClick:le,children:["This week",ce]}),e[54]=se,e[55]=de,e[56]=ce,e[57]=me):me=e[57],b=r.jsxs($r,{label:"Filter by due date and priority",children:[r.jsxs(yt,{pressed:c.due==="all",onClick:V,children:["All",r.jsx(wt,{children:C.length})]}),Z,ae,me,_.length>0&&r.jsx("span",{className:"mx-1 h-4 w-px shrink-0 bg-border","aria-hidden":!0}),_.map(ue=>r.jsxs(yt,{pressed:c.priority===ue,onClick:()=>O({priority:c.priority===ue?null:ue}),"aria-label":`Only ${ue} priority tasks`,children:[r.jsx(kb,{priority:ue}),ue,r.jsx(wt,{children:C.filter(ie=>ie.priority===ue).length})]},ue))]}),w=N.length>1&&r.jsx($r,{label:"Filter by status",children:N.map(ue=>r.jsxs(yt,{pressed:c.status===ue.name,onClick:()=>O({status:c.status===ue.name?null:ue.name}),"aria-label":`Only tasks in ${ue.name}`,children:[r.jsx("span",{"aria-hidden":!0,className:"size-2 rounded-full",style:{backgroundColor:ue.color}}),ue.name,r.jsx(wt,{children:C.filter(ie=>ie.status.name===ue.name).length})]},ue.name))}),f=qn,g="min-h-0 flex-1",m="flex flex-col gap-4 px-3 py-3",p=I.length===0?r.jsx("p",{className:"px-1 py-3 text-center text-xs text-muted-foreground",children:F?"No tasks match these filters.":"Nothing open here."}):I.map(L),h=R.length>0&&r.jsx(Uu,{count:R.length,children:R.map(L)}),e[3]=o,e[4]=c,e[5]=u,e[6]=t,e[7]=s,e[8]=f,e[9]=m,e[10]=p,e[11]=h,e[12]=g,e[13]=x,e[14]=b,e[15]=w}else f=e[8],m=e[9],p=e[10],h=e[11],g=e[12],x=e[13],b=e[14],w=e[15];let v;e[58]!==t.length||e[59]!==l?(v=l&&r.jsxs("p",{className:"px-1 text-center text-[11px] text-muted-foreground",children:["Showing the first ",t.length," tasks; narrow it down in ClickUp to see the rest."]}),e[58]=t.length,e[59]=l,e[60]=v):v=e[60];let S;e[61]!==m||e[62]!==p||e[63]!==h||e[64]!==v?(S=r.jsxs("div",{className:m,children:[p,h,v]}),e[61]=m,e[62]=p,e[63]=h,e[64]=v,e[65]=S):S=e[65];let j;e[66]!==f||e[67]!==g||e[68]!==S?(j=r.jsx(f,{className:g,children:S}),e[66]=f,e[67]=g,e[68]=S,e[69]=j):j=e[69];let k;return e[70]!==j||e[71]!==x||e[72]!==b||e[73]!==w?(k=r.jsxs(r.Fragment,{children:[x,b,w,j]}),e[70]=j,e[71]=x,e[72]=b,e[73]=w,e[74]=k):k=e[74],k}function JR(n,e){return(e.closedAt??e.updatedAt)-(n.closedAt??n.updatedAt)}function QR(n){return!Bo(n)}function ZR(n){return n.priority?[n.priority]:[]}function eI(n){return!Bo(n)}function tI(n,e){return n?e===null?"Loading lists…":"Choose a list":"Choose a space first"}function nI({projectPath:n,onLinked:e}){const[t,s]=y.useState(""),[o,i]=y.useState(null),[a,l]=y.useState(""),[c,d]=y.useState(null),[u,f]=y.useState(""),[m,p]=y.useState(!1),[h,g]=y.useState(null);y.useEffect(()=>{let w=!1;return MR().then(v=>{w||i(v.spaces)}).catch(v=>{w||g(mr(v,"Unable to load spaces").error)}),()=>{w=!0}},[]),y.useEffect(()=>{if(!a)return;let w=!1;return d(null),f(""),OR(a).then(v=>{w||d(v.lists)}).catch(v=>{w||g(mr(v,"Unable to load lists").error)}),()=>{w=!0}},[a]);async function x(w){if(!w){g("Paste a ClickUp list URL such as https://app.clickup.com/…/v/li/901700000000");return}p(!0),g(null);try{await jb(n,w),e()}catch(v){g(mr(v,"Unable to link that list").error)}finally{p(!1)}}function b(w){w.preventDefault(),x(UR(t))}return r.jsxs("div",{className:"flex flex-col gap-4 p-4","aria-label":"Link a ClickUp list",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm font-medium",children:"Link this project to a ClickUp list"}),r.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:"Tasks from the linked list show up here, next to the code they belong to."})]}),r.jsxs("form",{className:"flex flex-col gap-2",onSubmit:b,children:[r.jsx("label",{className:"text-[11px] font-medium text-muted-foreground",htmlFor:"clickup-list-url",children:"List URL or id"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Dt,{id:"clickup-list-url",value:t,onChange:w=>s(w.target.value),placeholder:"https://app.clickup.com/…/v/li/901700000000",className:"h-8 text-xs",autoComplete:"off",spellCheck:!1}),r.jsxs(ee,{type:"submit",size:"sm",disabled:m||!t.trim(),children:[m?r.jsx(st,{}):r.jsx(pm,{"data-icon":"inline-start"}),"Link"]})]})]}),r.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:[r.jsx("span",{className:"h-px flex-1 bg-border","aria-hidden":!0}),"or browse",r.jsx("span",{className:"h-px flex-1 bg-border","aria-hidden":!0})]}),r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsxs(Rc,{value:a,onValueChange:w=>l(w??""),children:[r.jsx(Mc,{className:"h-8 text-xs","aria-label":"Space",disabled:o===null,children:r.jsx(Ic,{placeholder:o===null?"Loading spaces…":"Choose a space"})}),r.jsx(Oc,{children:o==null?void 0:o.map(w=>r.jsx(Dc,{value:w.id,children:w.name},w.id))})]}),r.jsxs(Rc,{value:u,onValueChange:w=>f(w??""),children:[r.jsx(Mc,{className:"h-8 text-xs","aria-label":"List",disabled:!a||c===null,children:r.jsx(Ic,{placeholder:tI(a,c)})}),r.jsxs(Oc,{children:[c==null?void 0:c.map(w=>r.jsx(Dc,{value:w.id,children:Xu(w.folderName,w.name)},w.id)),(c==null?void 0:c.length)===0&&r.jsx("p",{className:"px-2 py-1 text-xs text-muted-foreground",children:"This space has no lists."})]})]}),r.jsxs(ee,{type:"button",size:"sm",variant:"outline",disabled:m||!u,onClick:()=>{x(u)},children:[m?r.jsx(st,{}):r.jsx(pm,{"data-icon":"inline-start"}),"Link selected list"]})]}),h&&r.jsx("p",{role:"alert",className:"text-xs text-destructive",children:h})]})}function sI({data:n,projectPath:e,composePrompt:t,onUnlinked:s}){const[o,i]=y.useState(!1),a=Xu(n.list.folderName,n.list.name);async function l(){i(!0);try{await jb(e,null),s()}finally{i(!1)}}return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex h-8 shrink-0 items-center gap-2 border-b px-3 text-[11px] text-muted-foreground",children:[r.jsx("a",{href:n.list.url,target:"_blank",rel:"noopener noreferrer",className:"min-w-0 flex-1 truncate outline-none hover:text-foreground focus-visible:underline",title:a,children:a}),r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>{l()},disabled:o,"aria-label":"Unlink this project from ClickUp",children:[o?r.jsx(st,{}):r.jsx(Sw,{"data-icon":"inline-start"}),"Unlink"]})]}),r.jsx(Cb,{tasks:n.tasks,viewer:n.viewer,composePrompt:t,emptyTitle:"No tasks in this list",emptyDescription:"Tasks added to the linked list will show up here.",truncated:n.truncated})]})}const oI="https://app.clickup.com/settings/apps";function rI(n){return n==="mine"||n==="project"}function iI(n){return n.code==="clickup_auth_failed"?"Generate a new personal token in ClickUp and add it again.":n.code==="clickup_rate_limited"?"ClickUp allows 100 requests a minute per token; the panel retries on its own.":"Check your ClickUp access, then try again."}function _b(n){const e=B.c(3),{label:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=[0,1,2].map(aI),e[0]=s):s=e[0];let o;return e[1]!==t?(o=r.jsx("div",{className:"flex flex-col gap-5 px-3 py-4","aria-label":t,children:s}),e[1]=t,e[2]=o):o=e[2],o}function aI(n){return r.jsxs("div",{className:"flex flex-col gap-2 border-l-2 border-border pl-3",children:[r.jsx(ct,{className:"h-3.5 w-3/4"}),r.jsx(ct,{className:"h-2.5 w-1/2"})]},n)}function Ph(n){const e=B.c(23),{state:t,loadingLabel:s,onRetry:o,children:i}=n;if(t.data){let l;e[0]!==i||e[1]!==t.data?(l=i(t.data),e[0]=i,e[1]=t.data,e[2]=l):l=e[2];let c;return e[3]!==l?(c=r.jsx(r.Fragment,{children:l}),e[3]=l,e[4]=c):c=e[4],c}if(t.error){let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Yt,{}),e[5]=l):l=e[5];let c;e[6]!==t.error.error?(c=r.jsx(Et,{children:t.error.error}),e[6]=t.error.error,e[7]=c):c=e[7];let d;e[8]!==t.error?(d=iI(t.error),e[8]=t.error,e[9]=d):d=e[9];let u;e[10]!==d?(u=r.jsx("span",{children:d}),e[10]=d,e[11]=u):u=e[11];let f;e[12]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(Pt,{"data-icon":"inline-start"}),e[12]=f):f=e[12];let m;e[13]!==o?(m=r.jsxs(ee,{type:"button",variant:"outline",size:"xs",onClick:o,children:[f,"Try again"]}),e[13]=o,e[14]=m):m=e[14];let p;e[15]!==u||e[16]!==m?(p=r.jsxs(ht,{className:"flex flex-col items-start gap-2",children:[u,m]}),e[15]=u,e[16]=m,e[17]=p):p=e[17];let h;return e[18]!==c||e[19]!==p?(h=r.jsx("div",{className:"p-3",children:r.jsxs(pt,{variant:"destructive",children:[l,c,p]})}),e[18]=c,e[19]=p,e[20]=h):h=e[20],h}let a;return e[21]!==s?(a=r.jsx(_b,{label:s}),e[21]=s,e[22]=a):a=e[22],a}function lI({error:n}){const[e,t]=y.useState(""),[s,o]=y.useState(!1),[i,a]=y.useState(null);async function l(c){c.preventDefault(),o(!0),a(null);try{await RR(e.trim()),t("")}catch(d){a(mr(d,"Unable to save the token").error)}finally{o(!1)}}return r.jsxs("form",{className:"flex flex-col gap-4 p-4",onSubmit:c=>{l(c)},"aria-label":"Connect ClickUp",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm font-medium",children:"Connect ClickUp"}),r.jsxs("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:["Paste a personal API token. Cogpit keeps it on this machine, in ",r.jsx("code",{className:"font-mono",children:"~/.cogpit/clickup.json"}),", and never shows it again. A ",r.jsx("code",{className:"font-mono",children:"CLICKUP_API_TOKEN"})," in the server environment works too."]})]}),n&&n.code!=="clickup_not_configured"&&r.jsx("p",{role:"alert",className:"text-xs text-destructive",children:n.error}),r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx("label",{className:"text-[11px] font-medium text-muted-foreground",htmlFor:"clickup-token",children:"Personal API token"}),r.jsx(Dt,{id:"clickup-token",type:"password",value:e,onChange:c=>t(c.target.value),placeholder:"pk_…",className:"h-8 font-mono text-xs",autoComplete:"off",spellCheck:!1})]}),i&&r.jsx("p",{role:"alert",className:"text-xs text-destructive",children:i}),r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsxs(ee,{type:"submit",size:"sm",disabled:s||!e.trim(),children:[s?r.jsx(st,{}):r.jsx(Td,{"data-icon":"inline-start"}),"Connect"]}),r.jsxs(ee,{variant:"outline",size:"sm",render:r.jsx("a",{href:oI,target:"_blank",rel:"noopener noreferrer"}),children:["Get a token",r.jsx(Zt,{"data-icon":"inline-end"})]})]})]})}function $h(n){const e=B.c(5),{value:t,attention:s}=n;if(t===null||t===0)return null;const o=s?"text-destructive":"text-muted-foreground";let i;e[0]!==o?(i=G("font-mono text-[10px] tabular-nums",o),e[0]=o,e[1]=i):i=e[1];let a;return e[2]!==i||e[3]!==t?(a=r.jsx("span",{className:i,children:t}),e[2]=i,e[3]=t,e[4]=a):a=e[4],a}function cI(){var l;const n=B.c(5),e=bb(!0),{data:t}=vb(((l=e.data)==null?void 0:l.configured)===!0);let s;if(n[0]!==(t==null?void 0:t.tasks)){const c=Date.now();s=(t==null?void 0:t.tasks.filter(d=>Ro(d,c)).length)??0,n[0]=t==null?void 0:t.tasks,n[1]=s}else s=n[1];const o=s;if(o===0)return null;const i=`${o} overdue ClickUp task${o===1?"":"s"}`;let a;return n[2]!==o||n[3]!==i?(a=r.jsx(Pe,{variant:"destructive",className:"absolute -right-1 -top-1 min-w-4 px-1 text-[9px]","aria-label":i,children:o}),n[2]=o,n[3]=i,n[4]=a):a=n[4],a}function dI(n){var I,R,D,O,M,F,z;const e=B.c(69),{context:t,active:s,closePanel:o}=n,[i,a]=y.useState("mine"),l=t.projectPath,c=bb(s),d=((I=c.data)==null?void 0:I.configured)===!0,u=vb(s&&d),f=$R(l,s&&d&&i==="project"),m=i==="mine"?u:f;let p;if(e[0]!==u.data){const L=Date.now();p=u.data?u.data.tasks.filter(W=>Ro(W,L)).length:null,e[0]=u.data,e[1]=p}else p=e[1];const h=p,g=u.data?u.data.tasks.length:null,x=((R=c.data)==null?void 0:R.workspace)??null;let b;if(c.data===null&&c.error===null){let L;e[2]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(_b,{label:"Checking ClickUp connection"}),e[2]=L):L=e[2],b=L}else if(d){const L=h||g,W=!!h;let U;e[5]!==L||e[6]!==W?(U=r.jsxs(Dn,{value:"mine",className:"h-full flex-none rounded-none px-0 text-xs",children:["My tasks",r.jsx($h,{value:L,attention:W})]}),e[5]=L,e[6]=W,e[7]=U):U=e[7];const H=!l;let K;e[8]!==f.data?(K=f.data?f.data.tasks.filter(fI).length:null,e[8]=f.data,e[9]=K):K=e[9];let V;e[10]!==K?(V=r.jsx($h,{value:K}),e[10]=K,e[11]=V):V=e[11];let Y;e[12]!==H||e[13]!==V?(Y=r.jsxs(Dn,{value:"project",className:"h-full flex-none rounded-none px-0 text-xs",disabled:H,children:["This project",V]}),e[12]=H,e[13]=V,e[14]=Y):Y=e[14];let q;e[15]!==U||e[16]!==Y?(q=r.jsx("div",{className:"flex h-9 shrink-0 items-end border-b px-3",children:r.jsxs(Ga,{variant:"line",className:"h-full gap-3 p-0","aria-label":"ClickUp views",children:[U,Y]})}),e[15]=U,e[16]=Y,e[17]=q):q=e[17];let J;e[18]!==u?(J=()=>{u.refresh()},e[18]=u,e[19]=J):J=e[19];let Q;e[20]!==t.composePrompt?(Q=re=>r.jsx(Cb,{tasks:re.tasks,viewer:re.viewer,composePrompt:t.composePrompt,emptyTitle:"Nothing assigned to you",emptyDescription:"Open tasks assigned to you anywhere in the workspace will show up here.",truncated:re.truncated}),e[20]=t.composePrompt,e[21]=Q):Q=e[21];let X;e[22]!==u||e[23]!==J||e[24]!==Q?(X=r.jsx(Ln,{value:"mine",className:"flex min-h-0 flex-col",children:r.jsx(Ph,{state:u,loadingLabel:"Loading your tasks",onRetry:J,children:Q})}),e[22]=u,e[23]=J,e[24]=Q,e[25]=X):X=e[25];let Z;e[26]!==t.composePrompt||e[27]!==f||e[28]!==l?(Z=l&&(((D=f.error)==null?void 0:D.code)==="project_unlinked"?r.jsx(nI,{projectPath:l,onLinked:()=>{f.refresh()}}):r.jsx(Ph,{state:f,loadingLabel:"Loading the linked list",onRetry:()=>{f.refresh()},children:re=>r.jsx(sI,{data:re,projectPath:l,composePrompt:t.composePrompt,onUnlinked:()=>{f.refresh()}})})),e[26]=t.composePrompt,e[27]=f,e[28]=l,e[29]=Z):Z=e[29];let te;e[30]!==Z?(te=r.jsx(Ln,{value:"project",className:"flex min-h-0 flex-col",children:Z}),e[30]=Z,e[31]=te):te=e[31];let ne;e[32]!==X||e[33]!==te?(ne=r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[X,te]}),e[32]=X,e[33]=te,e[34]=ne):ne=e[34];let oe;e[35]!==ne||e[36]!==q?(oe=r.jsxs(r.Fragment,{children:[q,ne]}),e[35]=ne,e[36]=q,e[37]=oe):oe=e[37],b=oe}else{let L;e[3]!==c.error?(L=r.jsx(lI,{error:c.error}),e[3]=c.error,e[4]=L):L=e[4],b=L}let w;e[38]===Symbol.for("react.memo_cache_sentinel")?(w=L=>{rI(L)&&a(L)},e[38]=w):w=e[38];let v;e[39]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx("h2",{className:"text-sm font-medium leading-tight",children:"ClickUp"}),e[39]=v):v=e[39];let S;e[40]!==c.data||e[41]!==x?(S=r.jsxs("div",{className:"min-w-0 flex-1",children:[v,x?r.jsxs("a",{href:`https://app.clickup.com/${x.id}/home`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex max-w-full items-center gap-0.5 truncate text-[11px] text-muted-foreground outline-none hover:text-foreground focus-visible:underline",children:[r.jsxs("span",{className:"truncate",children:[x.name,(O=c.data)!=null&&O.viewer?` · ${c.data.viewer.username}`:""]}),r.jsx(Zt,{className:"size-3 shrink-0"})]}):r.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:"Not connected"})]}),e[40]=c.data,e[41]=x,e[42]=S):S=e[42];let j;e[43]!==d||e[44]!==((M=c.data)==null?void 0:M.tokenFromEnv)?(j=d&&!((F=c.data)!=null&&F.tokenFromEnv)&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:uI,"aria-label":"Disconnect ClickUp",title:"Disconnect ClickUp",children:r.jsx(Td,{})}),e[43]=d,e[44]=(z=c.data)==null?void 0:z.tokenFromEnv,e[45]=j):j=e[45];let k;e[46]!==d||e[47]!==m||e[48]!==c?(k=()=>{d?m.refresh():c.refresh()},e[46]=d,e[47]=m,e[48]=c,e[49]=k):k=e[49];const C=m.loading||m.refreshing||c.loading,N=i==="mine"?"Refresh my tasks":"Refresh project tasks";let _;e[50]!==m.refreshing?(_=m.refreshing?r.jsx(st,{}):r.jsx(Pt,{}),e[50]=m.refreshing,e[51]=_):_=e[51];let A;e[52]!==k||e[53]!==C||e[54]!==N||e[55]!==_?(A=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:k,disabled:C,"aria-label":N,children:_}),e[52]=k,e[53]=C,e[54]=N,e[55]=_,e[56]=A):A=e[56];let P;e[57]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(nt,{}),e[57]=P):P=e[57];let T;e[58]!==o?(T=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:o,"aria-label":"Close ClickUp",children:P}),e[58]=o,e[59]=T):T=e[59];let E;e[60]!==A||e[61]!==T||e[62]!==S||e[63]!==j?(E=r.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b pl-4 pr-2",children:[S,j,A,T]}),e[60]=A,e[61]=T,e[62]=S,e[63]=j,e[64]=E):E=e[64];let $;return e[65]!==b||e[66]!==E||e[67]!==i?($=r.jsxs(Va,{value:i,onValueChange:w,className:"size-full min-h-0 gap-0","aria-label":"ClickUp panel",children:[E,b]}),e[65]=b,e[66]=E,e[67]=i,e[68]=$):$=e[68],$}function uI(){IR()}function fI(n){return!Bo(n)}const mI={id:"clickup",workspacePanels:[{id:"tasks",title:"ClickUp",icon:Nw,component:dI,indicator:cI,order:42,defaultSize:"38%",minSize:"360px",maxSize:"62%",when:n=>n.canAccessHostFiles}]},Ju={data:null,error:null,loading:!1,refreshing:!1},pI=8e3,hI=1500,gI=10,xI=new Set(["gh_missing","gh_auth_required","no_git_repository","no_github_remote"]),bI={endpoint:n=>`/api/github/actions?cwd=${encodeURIComponent(n)}&limit=20`,pollIntervalMs:1e4,fallbackError:"Unable to load GitHub Actions",stores:new Map},vI={endpoint:n=>`/api/github/pulls?cwd=${encodeURIComponent(n)}&limit=30`,pollIntervalMs:3e4,fallbackError:"Unable to load pull requests",stores:new Map},yI={endpoint:n=>`/api/github/issues?cwd=${encodeURIComponent(n)}&limit=30`,pollIntervalMs:6e4,fallbackError:"Unable to load issues",stores:new Map},wI={endpoint:n=>`/api/github/pulls/sessions?cwd=${encodeURIComponent(n)}`,pollIntervalMs:3e4,fallbackError:"Unable to match sessions to pull requests",stores:new Map,settling:n=>n.pending>0};function rd(n,e){let t=n.stores.get(e);return t||(t={snapshot:Ju,listeners:new Set,request:null,fetchedAt:0,settleTimer:null,settleAttempts:0},n.stores.set(e,t)),t}function dc(n,e){n.snapshot=e;for(const t of n.listeners)t()}async function Tb(n){try{const e=await n.json();if(typeof e.error=="string"&&typeof e.code=="string")return e}catch{}return{error:`GitHub request failed (${n.status})`,code:"github_api_failed"}}function Eb(n,e){const t=n;return{error:typeof t.error=="string"?t.error:e,code:typeof t.code=="string"?t.code:"github_api_failed"}}async function Ji(n,e,t=!1){const s=rd(n,e);if(s.request)return s.request;if(!(!t&&s.snapshot.error&&xI.has(s.snapshot.error.code))&&!(!t&&s.fetchedAt>0&&Date.now()-s.fetchedAt<pI))return(t||s.snapshot.data===null)&&dc(s,{...s.snapshot,error:t?null:s.snapshot.error,loading:s.snapshot.data===null,refreshing:s.snapshot.data!==null}),s.request=be(n.endpoint(e)).then(async o=>{var a;if(!o.ok)throw await Tb(o);const i=await o.json();s.fetchedAt=Date.now(),dc(s,{data:i,error:null,loading:!1,refreshing:!1}),(a=n.settling)!=null&&a.call(n,i)&&s.settleAttempts<gI?(s.settleAttempts+=1,s.settleTimer=window.setTimeout(()=>{s.settleTimer=null,Ji(n,e,!0)},hI)):s.settleAttempts=0}).catch(o=>{dc(s,{...s.snapshot,error:Eb(o,n.fallbackError),loading:!1,refreshing:!1})}).finally(()=>{s.request=null}),s.request}function xl(n,e,t){const s=B.c(17),o=e??"";let i;s[0]!==o||s[1]!==n?(i=p=>{if(!o)return SI;const h=rd(n,o);return h.listeners.add(p),()=>h.listeners.delete(p)},s[0]=o,s[1]=n,s[2]=i):i=s[2];let a;s[3]!==o||s[4]!==n?(a=()=>o?rd(n,o).snapshot:Ju,s[3]=o,s[4]=n,s[5]=a):a=s[5];const l=y.useSyncExternalStore(i,a,jI);let c,d;s[6]!==t||s[7]!==o||s[8]!==n?(c=()=>{if(!t||!o)return;Ji(n,o);const p=window.setInterval(()=>{Ji(n,o)},n.pollIntervalMs);return()=>window.clearInterval(p)},d=[n,t,o],s[6]=t,s[7]=o,s[8]=n,s[9]=c,s[10]=d):(c=s[9],d=s[10]),y.useEffect(c,d);let u;s[11]!==o||s[12]!==n?(u=()=>o?Ji(n,o,!0):Promise.resolve(),s[11]=o,s[12]=n,s[13]=u):u=s[13];const f=u;let m;return s[14]!==f||s[15]!==l?(m={...l,refresh:f},s[14]=f,s[15]=l,s[16]=m):m=s[16],m}function jI(){return Ju}function SI(){}function Ab(n,e){return xl(bI,n,e)}function Pb(n,e){return xl(vI,n,e)}function NI(n,e){return xl(yI,n,e)}function kI(n,e){return xl(wI,n,e)}async function $b(n){const e=await be(n);if(!e.ok)throw await Tb(e);return e.json()}function CI(n,e){return $b(`/api/github/actions/jobs?cwd=${encodeURIComponent(n)}&runId=${e}`)}function _I(n,e){return $b(`/api/github/pulls/files?cwd=${encodeURIComponent(n)}&number=${e}`)}const TI={data:null,error:null,loading:!1};function Rb(n,e,t){const s=B.c(12),o=t===void 0?!1:t,[i,a]=y.useState(!1),[l,c]=y.useState(TI);let d;s[0]!==e||s[1]!==n||s[2]!==l?(d=async function(){if(!l.loading){c(EI);try{c({data:await n(),error:null,loading:!1})}catch(g){c({data:null,error:Eb(g,e),loading:!1})}}},s[0]=e,s[1]=n,s[2]=l,s[3]=d):d=s[3];const u=d;let f;s[4]!==u||s[5]!==o||s[6]!==l?(f=function(g){a(g),g&&(!l.data||o)&&u()},s[4]=u,s[5]=o,s[6]=l,s[7]=f):f=s[7];const m=f;let p;return s[8]!==m||s[9]!==i||s[10]!==l?(p={open:i,state:l,onOpenChange:m},s[8]=m,s[9]=i,s[10]=l,s[11]=p):p=s[11],p}function EI(n){return{...n,error:null,loading:!0}}function ui(n){return n!=="completed"}function Uo(n){return n==="action_required"||n==="failure"||n==="startup_failure"||n==="timed_out"}function Qu(n,e){return ui(n)?"live":Uo(e)?"fail":e==="success"?"pass":"quiet"}const Rh={live:0,fail:1,quiet:2,pass:3};function AI(n){return n.reduce((e,t)=>Rh[t]<Rh[e]?t:e,"pass")}const PI={live:"bg-info motion-safe:animate-pulse",fail:"bg-destructive",pass:"bg-success",quiet:"bg-border"};function Zu(n,e){return n==="in_progress"?"Running":ui(n)?"Queued":e==="success"?"Passed":e==="cancelled"?"Cancelled":e==="skipped"?"Skipped":e==="timed_out"?"Timed out":e==="action_required"?"Needs action":e==="neutral"||e==="stale"?"Neutral":"Failed"}function ef(n){const e=B.c(14),{status:t,conclusion:s,className:o}=n;let i;e[0]!==s||e[1]!==t?(i=Zu(t,s),e[0]=s,e[1]=t,e[2]=i):i=e[2];const a=i;let l,c,d;if(e[3]!==o||e[4]!==s||e[5]!==a||e[6]!==t){d=Symbol.for("react.early_return_sentinel");e:{const f=G("size-3.5 shrink-0",o);if(t==="in_progress"){d=r.jsx(st,{className:G(f,"text-info"),"aria-label":a});break e}if(ui(t)){d=r.jsx(Lr,{className:G(f,"text-info"),"aria-label":a});break e}if(s==="success"){d=r.jsx(dt,{className:G(f,"text-success"),"aria-label":a});break e}if(Uo(s)){d=r.jsx(nt,{className:G(f,"text-destructive"),"aria-label":a});break e}if(s==="skipped"||s==="cancelled"){d=r.jsx(kw,{className:G(f,"text-muted-foreground"),"aria-label":a});break e}l=Pa,c=G(f,"text-muted-foreground")}e[3]=o,e[4]=s,e[5]=a,e[6]=t,e[7]=l,e[8]=c,e[9]=d}else l=e[7],c=e[8],d=e[9];if(d!==Symbol.for("react.early_return_sentinel"))return d;let u;return e[10]!==l||e[11]!==a||e[12]!==c?(u=r.jsx(l,{className:c,"aria-label":a}),e[10]=l,e[11]=a,e[12]=c,e[13]=u):u=e[13],u}function $I(n){const e=B.c(19),{step:t,now:s}=n;let o,i,a,l;if(e[0]!==t.conclusion||e[1]!==t.status){const f=Uo(t.conclusion);o=t.conclusion==="skipped",a="flex min-w-0 items-center gap-2 py-0.5 text-[11px] leading-5",l=r.jsx(ef,{status:t.status,conclusion:t.conclusion,className:"size-3"}),i=G("min-w-0 flex-1 truncate",f&&"font-medium text-destructive",o&&"text-muted-foreground"),e[0]=t.conclusion,e[1]=t.status,e[2]=o,e[3]=i,e[4]=a,e[5]=l}else o=e[2],i=e[3],a=e[4],l=e[5];let c;e[6]!==t.name||e[7]!==i?(c=r.jsx("span",{className:i,children:t.name}),e[6]=t.name,e[7]=i,e[8]=c):c=e[8];let d;e[9]!==s||e[10]!==o||e[11]!==t.completedAt||e[12]!==t.startedAt?(d=!o&&r.jsx("span",{className:"shrink-0 font-mono text-[10px] text-muted-foreground tabular-nums",children:Bu(t.startedAt,t.completedAt,s)}),e[9]=s,e[10]=o,e[11]=t.completedAt,e[12]=t.startedAt,e[13]=d):d=e[13];let u;return e[14]!==a||e[15]!==l||e[16]!==c||e[17]!==d?(u=r.jsxs("li",{className:a,children:[l,c,d]}),e[14]=a,e[15]=l,e[16]=c,e[17]=d,e[18]=u):u=e[18],u}function RI(n){const e=B.c(39),{job:t,now:s}=n;let o;e[0]!==t.conclusion||e[1]!==t.status?(o=Qu(t.status,t.conclusion),e[0]=t.conclusion,e[1]=t.status,e[2]=o):o=e[2];const i=o,[a,l]=y.useState(i==="fail"||i==="live");let c;e[3]!==t.completedAt||e[4]!==t.startedAt||e[5]!==s?(c=Bu(t.startedAt,t.completedAt,s),e[3]=t.completedAt,e[4]=t.startedAt,e[5]=s,e[6]=c):c=e[6];const d=c,u=t.name;let f;e[7]!==t.conclusion||e[8]!==t.status?(f=Zu(t.status,t.conclusion),e[7]=t.conclusion,e[8]=t.status,e[9]=f):f=e[9];const m=`${u}: ${f}`,p=a&&"rotate-90";let h;e[10]!==p?(h=G("size-3 shrink-0 text-muted-foreground transition-transform",p),e[10]=p,e[11]=h):h=e[11];let g;e[12]!==h?(g=r.jsx(Xe,{className:h}),e[12]=h,e[13]=g):g=e[13];let x;e[14]!==t.conclusion||e[15]!==t.status?(x=r.jsx(ef,{status:t.status,conclusion:t.conclusion}),e[14]=t.conclusion,e[15]=t.status,e[16]=x):x=e[16];const b=i==="fail"&&"text-destructive";let w;e[17]!==b?(w=G("min-w-0 flex-1 truncate",b),e[17]=b,e[18]=w):w=e[18];let v;e[19]!==t.name||e[20]!==w?(v=r.jsx("span",{className:w,children:t.name}),e[19]=t.name,e[20]=w,e[21]=v):v=e[21];let S;e[22]!==d?(S=d&&r.jsx("span",{className:"shrink-0 font-mono text-[10px] text-muted-foreground tabular-nums",children:d}),e[22]=d,e[23]=S):S=e[23];let j;e[24]!==v||e[25]!==S||e[26]!==m||e[27]!==g||e[28]!==x?(j=r.jsxs(Rt,{className:"flex w-full min-w-0 items-center gap-2 rounded-sm py-1 text-left text-xs outline-none hover:bg-accent/60 focus-visible:ring-[3px] focus-visible:ring-ring/20","aria-label":m,children:[g,x,v,S]}),e[24]=v,e[25]=S,e[26]=m,e[27]=g,e[28]=x,e[29]=j):j=e[29];let k;e[30]!==t.steps||e[31]!==s?(k=t.steps.length>0&&r.jsx("ul",{className:"ml-[5px] border-l border-border pl-4",children:t.steps.map(_=>r.jsx($I,{step:_,now:s},_.number))}),e[30]=t.steps,e[31]=s,e[32]=k):k=e[32];let C;e[33]!==k?(C=r.jsx(mt,{children:k}),e[33]=k,e[34]=C):C=e[34];let N;return e[35]!==a||e[36]!==j||e[37]!==C?(N=r.jsxs(ft,{open:a,onOpenChange:l,children:[j,C]}),e[35]=a,e[36]=j,e[37]=C,e[38]=N):N=e[38],N}function II(n){var H,K,V;const e=B.c(73),{run:t,projectPath:s,now:o}=n;let i;e[0]!==t.conclusion||e[1]!==t.status?(i=Qu(t.status,t.conclusion),e[0]=t.conclusion,e[1]=t.status,e[2]=i):i=e[2];const a=i,l=a==="live";let c;e[3]!==s||e[4]!==t.id?(c=()=>CI(s,t.id),e[3]=s,e[4]=t.id,e[5]=c):c=e[5];const{open:d,state:u,onOpenChange:f}=Rb(c,"Unable to load workflow jobs",l);let m;e[6]!==((H=u.data)==null?void 0:H.jobs)?(m=((K=u.data)==null?void 0:K.jobs)??[],e[6]=(V=u.data)==null?void 0:V.jobs,e[7]=m):m=e[7];const p=m,h=l?null:t.updatedAt;let g;e[8]!==o||e[9]!==t.createdAt||e[10]!==h?(g=Bu(t.createdAt,h,o),e[8]=o,e[9]=t.createdAt,e[10]=h,e[11]=g):g=e[11];const x=g,b=t.name,w=t.runNumber;let v;e[12]!==t.conclusion||e[13]!==t.status?(v=Zu(t.status,t.conclusion),e[12]=t.conclusion,e[13]=t.status,e[14]=v):v=e[14];const S=`${b} #${w}: ${v}`;let j;e[15]!==t.conclusion||e[16]!==t.status?(j=r.jsx(ef,{status:t.status,conclusion:t.conclusion}),e[15]=t.conclusion,e[16]=t.status,e[17]=j):j=e[17];const k=a==="quiet"&&"text-muted-foreground";let C;e[18]!==k?(C=G("min-w-0 truncate",k),e[18]=k,e[19]=C):C=e[19];let N;e[20]!==t.name||e[21]!==C?(N=r.jsx("span",{className:C,children:t.name}),e[20]=t.name,e[21]=C,e[22]=N):N=e[22];let _;e[23]!==t.runNumber?(_=r.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["#",t.runNumber]}),e[23]=t.runNumber,e[24]=_):_=e[24];let A;e[25]===Symbol.for("react.memo_cache_sentinel")?(A=r.jsx("span",{className:"min-w-0 flex-1"}),e[25]=A):A=e[25];let P;e[26]!==t.branch?(P=r.jsx("span",{className:"max-w-24 truncate font-mono text-[10px] text-muted-foreground",children:t.branch}),e[26]=t.branch,e[27]=P):P=e[27];let T;e[28]!==l||e[29]!==x?(T=x&&r.jsx("span",{className:G("w-14 shrink-0 text-right font-mono text-[10px] tabular-nums",l?"text-info":"text-muted-foreground"),children:x}),e[28]=l,e[29]=x,e[30]=T):T=e[30];let E;e[31]!==d||e[32]!==j||e[33]!==N||e[34]!==_||e[35]!==P||e[36]!==T||e[37]!==S?(E=r.jsxs(Rt,{className:"flex h-7 min-w-0 flex-1 items-center gap-2 rounded-sm px-1 text-left text-xs outline-none hover:bg-accent/60 focus-visible:ring-[3px] focus-visible:ring-ring/20","aria-label":S,"aria-expanded":d,children:[j,N,_,A,P,T]}),e[31]=d,e[32]=j,e[33]=N,e[34]=_,e[35]=P,e[36]=T,e[37]=S,e[38]=E):E=e[38];const $=`Open ${t.name} #${t.runNumber} on GitHub`;let I;e[39]!==t.url?(I=()=>window.open(t.url,"_blank","noopener,noreferrer"),e[39]=t.url,e[40]=I):I=e[40];let R;e[41]===Symbol.for("react.memo_cache_sentinel")?(R=r.jsx(Zt,{}),e[41]=R):R=e[41];let D;e[42]!==$||e[43]!==I?(D=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",className:"size-6 text-muted-foreground opacity-0 transition-opacity group-hover/run:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100","aria-label":$,onClick:I,children:R}),e[42]=$,e[43]=I,e[44]=D):D=e[44];let O;e[45]!==E||e[46]!==D?(O=r.jsxs("div",{className:"group/run flex items-center gap-1 pr-1",children:[E,D]}),e[45]=E,e[46]=D,e[47]=O):O=e[47];let M;e[48]!==u.data||e[49]!==u.loading?(M=u.loading&&!u.data&&r.jsxs("div",{className:"flex items-center gap-2 py-1 text-[11px] text-muted-foreground",role:"status",children:[r.jsx(st,{className:"size-3"}),"Loading jobs"]}),e[48]=u.data,e[49]=u.loading,e[50]=M):M=e[50];let F;e[51]!==u.error?(F=u.error&&r.jsx("p",{className:"py-1 text-[11px] text-destructive",children:u.error.error}),e[51]=u.error,e[52]=F):F=e[52];let z;e[53]!==p.length||e[54]!==u.data||e[55]!==u.error||e[56]!==u.loading?(z=!u.loading&&!u.error&&u.data&&p.length===0&&r.jsx("p",{className:"py-1 text-[11px] text-muted-foreground",children:"GitHub reported no jobs for this run."}),e[53]=p.length,e[54]=u.data,e[55]=u.error,e[56]=u.loading,e[57]=z):z=e[57];let L;if(e[58]!==p||e[59]!==o){let Y;e[61]!==o?(Y=q=>r.jsx(RI,{job:q,now:o},q.id),e[61]=o,e[62]=Y):Y=e[62],L=p.map(Y),e[58]=p,e[59]=o,e[60]=L}else L=e[60];let W;e[63]!==M||e[64]!==F||e[65]!==z||e[66]!==L?(W=r.jsx(mt,{children:r.jsxs("div",{className:"ml-[7px] border-l border-border py-1 pl-3 pr-1",children:[M,F,z,L]})}),e[63]=M,e[64]=F,e[65]=z,e[66]=L,e[67]=W):W=e[67];let U;return e[68]!==f||e[69]!==d||e[70]!==O||e[71]!==W?(U=r.jsxs(ft,{open:d,onOpenChange:f,children:[O,W]}),e[68]=f,e[69]=d,e[70]=O,e[71]=W,e[72]=U):U=e[72],U}function MI(n){const e=new Map;for(const s of n){const o=s.commitSha||`run-${s.id}`,i=e.get(o);if(i){i.runs.push(s),s.createdAt>i.createdAt&&(i.createdAt=s.createdAt);continue}e.set(o,{sha:s.commitSha,title:s.displayTitle,actor:s.actor,createdAt:s.createdAt,runs:[s],tone:"pass"})}const t=[...e.values()];for(const s of t)s.tone=AI(s.runs.map(o=>Qu(o.status,o.conclusion)));return t.sort((s,o)=>{const i=s.tone==="live"?0:1,a=o.tone==="live"?0:1;return i-a||o.createdAt.localeCompare(s.createdAt)})}function OI(n){const e=B.c(41),{group:t,projectPath:s,now:o}=n,i=t.title,a=PI[t.tone];let l;e[0]!==a?(l=G("absolute inset-y-1 left-0 w-0.5 rounded-full",a),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==l?(c=r.jsx("span",{"aria-hidden":!0,className:l}),e[2]=l,e[3]=c):c=e[3];let d;e[4]!==t.title?(d=r.jsx("h3",{className:"truncate text-[13px] font-medium leading-5",title:t.title,children:t.title}),e[4]=t.title,e[5]=d):d=e[5];let u;e[6]!==t.sha?(u=t.sha&&r.jsx("span",{className:"font-mono",children:t.sha.slice(0,7)}),e[6]=t.sha,e[7]=u):u=e[7];let f;e[8]!==t.actor?(f=t.actor&&r.jsx("span",{className:"truncate",children:t.actor}),e[8]=t.actor,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx("span",{className:"shrink-0",children:"·"}),e[10]=m):m=e[10];const p=t.createdAt;let h;e[11]!==t.createdAt?(h=new Date(t.createdAt).toLocaleString(),e[11]=t.createdAt,e[12]=h):h=e[12];let g;e[13]!==t.createdAt||e[14]!==o?(g=fl(t.createdAt,o),e[13]=t.createdAt,e[14]=o,e[15]=g):g=e[15];let x;e[16]!==t.createdAt||e[17]!==h||e[18]!==g?(x=r.jsx("time",{className:"shrink-0",dateTime:p,title:h,children:g}),e[16]=t.createdAt,e[17]=h,e[18]=g,e[19]=x):x=e[19];let b;e[20]!==x||e[21]!==u||e[22]!==f?(b=r.jsxs("p",{className:"flex min-w-0 items-center gap-1.5 text-[11px] leading-4 text-muted-foreground",children:[u,f,m,x]}),e[20]=x,e[21]=u,e[22]=f,e[23]=b):b=e[23];let w;e[24]!==b||e[25]!==d?(w=r.jsxs("header",{className:"mb-1 min-w-0",children:[d,b]}),e[24]=b,e[25]=d,e[26]=w):w=e[26];let v;if(e[27]!==t.runs||e[28]!==o||e[29]!==s){let k;e[31]!==o||e[32]!==s?(k=C=>r.jsx(II,{run:C,projectPath:s,now:o},C.id),e[31]=o,e[32]=s,e[33]=k):k=e[33],v=t.runs.map(k),e[27]=t.runs,e[28]=o,e[29]=s,e[30]=v}else v=e[30];let S;e[34]!==v?(S=r.jsx("div",{className:"-ml-1 flex flex-col",children:v}),e[34]=v,e[35]=S):S=e[35];let j;return e[36]!==t.title||e[37]!==w||e[38]!==S||e[39]!==c?(j=r.jsxs("article",{className:"relative pl-3","aria-label":i,children:[c,w,S]}),e[36]=t.title,e[37]=w,e[38]=S,e[39]=c,e[40]=j):j=e[40],j}function DI(n,e){return e==="failed"?n.filter(t=>Uo(t.conclusion)):e==="all"?[...n]:n.filter(t=>t.branch===e.branch)}function LI(n,e){return n==="failed"?"Nothing failed in the latest runs.":n==="all"?`No recent runs on ${e}.`:`No recent runs on ${n.branch}.`}function zI(n){const e=B.c(22),{data:t,filter:s,projectPath:o}=n;let i;e[0]!==t.runs||e[1]!==s?(i=DI(t.runs,s),e[0]=t.runs,e[1]=s,e[2]=i):i=e[2];const a=i;let l;e[3]!==a?(l=MI(a),e[3]=a,e[4]=l):l=e[4];const c=l;let d;e[5]!==c?(d=c.some(FI),e[5]=c,e[6]=d):d=e[6];const u=ml(d);if(t.runs.length===0){let p;return e[7]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(pl,{icon:Ad,title:"No workflow runs yet",description:"Push a commit that triggers a workflow and it will show up here."}),e[7]=p):p=e[7],p}if(c.length===0){let p;e[8]!==t.branch||e[9]!==s?(p=LI(s,t.branch),e[8]=t.branch,e[9]=s,e[10]=p):p=e[10];let h;return e[11]!==p?(h=r.jsx("p",{className:"px-4 py-6 text-center text-xs text-muted-foreground",children:p}),e[11]=p,e[12]=h):h=e[12],h}let f;if(e[13]!==c||e[14]!==u||e[15]!==o){let p;e[17]!==u||e[18]!==o?(p=h=>r.jsx(OI,{group:h,projectPath:o,now:u},h.sha||h.runs[0].id),e[17]=u,e[18]=o,e[19]=p):p=e[19],f=c.map(p),e[13]=c,e[14]=u,e[15]=o,e[16]=f}else f=e[16];let m;return e[20]!==f?(m=r.jsx(qn,{className:"min-h-0 flex-1",children:r.jsx("div",{className:"flex flex-col gap-5 px-3 py-3",children:f})}),e[20]=f,e[21]=m):m=e[21],m}function FI(n){return n.tone==="live"}function BI(n){const e=B.c(23),{data:t,projectPath:s,focus:o}=n,[i,a]=y.useState("all");let l,c;e[0]!==o?(l=()=>{o&&a({branch:o.branch})},c=[o],e[0]=o,e[1]=l,e[2]=c):(l=e[1],c=e[2]),y.useEffect(l,c);const d=t.runs;let u;e[3]!==d?(u=d.filter(UI),e[3]=d,e[4]=u):u=e[4];const f=u.length,m=t.branch;let p;e[5]!==m||e[6]!==d?(p=m?d.filter(j=>j.branch===m).length:0,e[5]=m,e[6]=d,e[7]=p):p=e[7];const h=p,g=typeof i=="object"&&i.branch!==m?i.branch:null,x=typeof i=="object"&&!g,b=x&&!m||i==="failed"&&f===0?"all":i;let w;e[8]!==m||e[9]!==h||e[10]!==x||e[11]!==b||e[12]!==f||e[13]!==g||e[14]!==d?(w=d.length>0&&r.jsxs($r,{label:"Filter runs",children:[r.jsxs(yt,{pressed:b==="all",onClick:()=>a("all"),children:["All",r.jsx(wt,{children:d.length})]}),m&&r.jsxs(yt,{pressed:x&&b!=="all",disabled:h===0,onClick:()=>a({branch:m}),"aria-label":`Only runs on ${m}`,children:[r.jsx(zn,{className:"size-3"}),r.jsx("span",{className:"max-w-28 truncate",children:m}),r.jsx(wt,{children:h})]}),g&&r.jsxs(yt,{pressed:!0,onClick:()=>a("all"),"aria-label":`Only runs on ${g}`,children:[r.jsx(zn,{className:"size-3"}),r.jsx("span",{className:"max-w-28 truncate",children:g}),r.jsx(wt,{children:d.filter(j=>j.branch===g).length}),r.jsx(nt,{className:"size-3","aria-hidden":!0})]}),r.jsxs(yt,{pressed:b==="failed",disabled:f===0,onClick:()=>a("failed"),children:[r.jsx("span",{className:G(f>0&&"text-destructive"),children:"Failed"})," ",r.jsx(wt,{children:f})]})]}),e[8]=m,e[9]=h,e[10]=x,e[11]=b,e[12]=f,e[13]=g,e[14]=d,e[15]=w):w=e[15];let v;e[16]!==t||e[17]!==b||e[18]!==s?(v=r.jsx(zI,{data:t,filter:b,projectPath:s}),e[16]=t,e[17]=b,e[18]=s,e[19]=v):v=e[19];let S;return e[20]!==w||e[21]!==v?(S=r.jsxs(r.Fragment,{children:[w,v]}),e[20]=w,e[21]=v,e[22]=S):S=e[22],S}function UI(n){return Uo(n.conclusion)}const Ib={open:"Open",completed:"Completed",not_planned:"Not planned"},WI={open:"bg-success",completed:"bg-info",not_planned:"bg-border"};function HI(n){const e=B.c(9),{state:t}=n,s=Ib[t];if(t==="open"){let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=G("size-3.5 shrink-0","text-success"),e[0]=a):a=e[0];let l;return e[1]!==s?(l=r.jsx(Cd,{className:a,"aria-label":s}),e[1]=s,e[2]=l):l=e[2],l}if(t==="completed"){let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=G("size-3.5 shrink-0","text-info"),e[3]=a):a=e[3];let l;return e[4]!==s?(l=r.jsx(Wn,{className:a,"aria-label":s}),e[4]=s,e[5]=l):l=e[5],l}let o;e[6]===Symbol.for("react.memo_cache_sentinel")?(o=G("size-3.5 shrink-0","text-muted-foreground"),e[6]=o):o=e[6];let i;return e[7]!==s?(i=r.jsx(_w,{className:o,"aria-label":s}),e[7]=s,e[8]=i):i=e[8],i}function Mb(n){const e=B.c(2),{label:t}=n,s=`#${t.color}`;let o;return e[0]!==s?(o=r.jsx("span",{"aria-hidden":!0,className:"inline-block size-2 shrink-0 rounded-full",style:{backgroundColor:s}}),e[0]=s,e[1]=o):o=e[1],o}function qI(n){const e=n.body.trim();return[`Work on GitHub issue #${n.number}: ${n.title}`,n.url,...e?["",e]:[]].join(`
|
|
126
|
+
`)}function KI(n){const e=B.c(7),{issue:t,viewer:s}=n;if(s!==null&&t.assignees.includes(s)){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(H1,{className:"size-3 text-info","aria-label":"Assigned to you",role:"img"}),e[0]=d):d=e[0],d}if(t.assignees.length===0)return null;let o;e[1]!==t.assignees?(o=t.assignees.join(", "),e[1]=t.assignees,e[2]=o):o=e[2];const i=`Assigned to ${o}`;let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(Pd,{className:"size-3","aria-hidden":!0}),e[3]=a):a=e[3];const l=t.assignees.length>1&&t.assignees.length;let c;return e[4]!==i||e[5]!==l?(c=r.jsxs("span",{className:"flex items-center gap-0.5 text-[10px] text-muted-foreground","aria-label":i,title:i,children:[a,l]}),e[4]=i,e[5]=l,e[6]=c):c=e[6],c}function VI(n){const e=B.c(5),{state:t}=n;if(t==="merged"){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(q1,{className:"size-3 text-info","aria-hidden":!0}),e[0]=a):a=e[0],a}const s=t==="closed"?"text-destructive":"text-success";let o;e[1]!==s?(o=G("size-3",s),e[1]=s,e[2]=o):o=e[2];let i;return e[3]!==o?(i=r.jsx(Fr,{className:o,"aria-hidden":!0}),e[3]=o,e[4]=i):i=e[4],i}function GI(n){const e=B.c(12),{issue:t,viewer:s,onShowPull:o}=n,i=t.linkedPulls[0];let a;e[0]!==t||e[1]!==s?(a=r.jsx(KI,{issue:t,viewer:s}),e[0]=t,e[1]=s,e[2]=a):a=e[2];let l;e[3]!==o||e[4]!==i?(l=i&&r.jsxs("button",{type:"button",className:"flex items-center gap-0.5 rounded-sm font-mono text-[10px] text-muted-foreground outline-none hover:bg-accent hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/20","aria-label":`Pull request #${i.number} (${i.state}), show pull requests`,title:`Pull request #${i.number} · ${i.state}`,onClick:o,children:[r.jsx(VI,{state:i.state}),"#",i.number]}),e[3]=o,e[4]=i,e[5]=l):l=e[5];let c;e[6]!==t.comments?(c=r.jsx(nb,{count:t.comments}),e[6]=t.comments,e[7]=c):c=e[7];let d;return e[8]!==a||e[9]!==l||e[10]!==c?(d=r.jsxs("span",{className:"flex h-5 shrink-0 items-center gap-1.5",children:[a,l,c]}),e[8]=a,e[9]=l,e[10]=c,e[11]=d):d=e[11],d}function YI(n){const e=B.c(86),{issue:t,viewer:s,now:o,onPickLabel:i,onShowPull:a,composePrompt:l}=n,[c,d]=y.useState(!1),u=t.state==="open"?t.updatedAt:t.closedAt??t.updatedAt;let f;e[0]!==t.body?(f=t.body.trim(),e[0]=t.body,e[1]=f):f=e[1];const m=f,p=t.title,h=WI[t.state];let g;e[2]!==h?(g=G("absolute inset-y-1 left-0 w-0.5 rounded-full",h),e[2]=h,e[3]=g):g=e[3];let x;e[4]!==g?(x=r.jsx("span",{"aria-hidden":!0,className:g}),e[4]=g,e[5]=x):x=e[5];const b=`${t.title} #${t.number}: ${Ib[t.state]}`;let w;e[6]!==t.state?(w=r.jsx(HI,{state:t.state}),e[6]=t.state,e[7]=w):w=e[7];const v=t.state!=="open"&&"text-muted-foreground";let S;e[8]!==v?(S=G("min-w-0 flex-1 truncate text-[13px] font-medium leading-5",v),e[8]=v,e[9]=S):S=e[9];let j;e[10]!==t.title||e[11]!==S?(j=r.jsx("span",{className:S,children:t.title}),e[10]=t.title,e[11]=S,e[12]=j):j=e[12];let k;e[13]!==t.number?(k=r.jsxs("span",{className:"shrink-0 font-mono text-[10px] text-muted-foreground",children:["#",t.number]}),e[13]=t.number,e[14]=k):k=e[14];let C;e[15]!==j||e[16]!==k||e[17]!==w?(C=r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[w,j,k]}),e[15]=j,e[16]=k,e[17]=w,e[18]=C):C=e[18];let N;e[19]!==t.author?(N=t.author&&r.jsx("span",{className:"shrink-0",children:t.author}),e[19]=t.author,e[20]=N):N=e[20];let _;e[21]!==t.labels?(_=t.labels.length>0&&r.jsxs("span",{className:"flex min-w-0 items-center gap-1 truncate",children:[t.labels.slice(0,3).map(XI),t.labels.length>3&&r.jsxs("span",{children:["+",t.labels.length-3]})]}),e[21]=t.labels,e[22]=_):_=e[22];let A;e[23]===Symbol.for("react.memo_cache_sentinel")?(A=r.jsx("span",{className:"shrink-0",children:"·"}),e[23]=A):A=e[23];let P;e[24]!==u?(P=new Date(u).toLocaleString(),e[24]=u,e[25]=P):P=e[25];let T;e[26]!==u||e[27]!==o?(T=fl(u,o),e[26]=u,e[27]=o,e[28]=T):T=e[28];let E;e[29]!==u||e[30]!==P||e[31]!==T?(E=r.jsx("time",{className:"shrink-0",dateTime:u,title:P,children:T}),e[29]=u,e[30]=P,e[31]=T,e[32]=E):E=e[32];let $;e[33]!==N||e[34]!==_||e[35]!==E?($=r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 pl-[22px] text-[11px] leading-4 text-muted-foreground",children:[N,_,A,E]}),e[33]=N,e[34]=_,e[35]=E,e[36]=$):$=e[36];let I;e[37]!==c||e[38]!==C||e[39]!==$||e[40]!==b?(I=r.jsxs(Rt,{className:"flex min-w-0 flex-1 flex-col rounded-sm px-1 py-1 text-left outline-none hover:bg-accent/60 focus-visible:ring-[3px] focus-visible:ring-ring/20","aria-label":b,"aria-expanded":c,children:[C,$]}),e[37]=c,e[38]=C,e[39]=$,e[40]=b,e[41]=I):I=e[41];let R;e[42]!==t||e[43]!==a||e[44]!==s?(R=r.jsx(GI,{issue:t,viewer:s,onShowPull:a}),e[42]=t,e[43]=a,e[44]=s,e[45]=R):R=e[45];const D=`Open #${t.number} on GitHub`;let O;e[46]!==t.url?(O=()=>window.open(t.url,"_blank","noopener,noreferrer"),e[46]=t.url,e[47]=O):O=e[47];let M;e[48]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(Zt,{}),e[48]=M):M=e[48];let F;e[49]!==D||e[50]!==O?(F=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",className:"size-6 text-muted-foreground opacity-0 transition-opacity group-hover/issue:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100","aria-label":D,onClick:O,children:M}),e[49]=D,e[50]=O,e[51]=F):F=e[51];let z;e[52]!==R||e[53]!==F?(z=r.jsxs("div",{className:"mt-1 flex shrink-0 items-center gap-1",children:[R,F]}),e[52]=R,e[53]=F,e[54]=z):z=e[54];let L;e[55]!==I||e[56]!==z?(L=r.jsxs("div",{className:"group/issue flex items-start gap-1 pr-1",children:[I,z]}),e[55]=I,e[56]=z,e[57]=L):L=e[57];let W;e[58]!==m?(W=m?r.jsx(Wu,{body:m}):r.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"No description."}),e[58]=m,e[59]=W):W=e[59];let U;e[60]!==t.labels||e[61]!==i?(U=t.labels.length>0&&r.jsx("ul",{className:"flex flex-wrap gap-1","aria-label":"Labels",children:t.labels.map(Z=>r.jsx("li",{children:r.jsxs("button",{type:"button",className:"inline-flex h-5 items-center gap-1 rounded-full border px-1.5 text-[10px] leading-none text-muted-foreground outline-none hover:border-foreground/30 hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/20",onClick:()=>i(Z.name),"aria-label":`Only issues labeled ${Z.name}`,children:[r.jsx(Mb,{label:Z}),Z.name]})},Z.name))}),e[60]=t.labels,e[61]=i,e[62]=U):U=e[62];let H;e[63]!==l||e[64]!==t?(H=l&&r.jsxs(ee,{type:"button",size:"xs",onClick:()=>l(qI(t)),children:[r.jsx(W1,{"data-icon":"inline-start"}),"Add to prompt"]}),e[63]=l,e[64]=t,e[65]=H):H=e[65];let K;e[66]!==t.url?(K=r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer"}),e[66]=t.url,e[67]=K):K=e[67];let V;e[68]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx(Zt,{"data-icon":"inline-end"}),e[68]=V):V=e[68];let Y;e[69]!==K?(Y=r.jsxs(ee,{variant:"outline",size:"xs",render:K,children:["Open issue on GitHub",V]}),e[69]=K,e[70]=Y):Y=e[70];let q;e[71]!==H||e[72]!==Y?(q=r.jsxs("div",{className:"flex flex-wrap gap-2",children:[H,Y]}),e[71]=H,e[72]=Y,e[73]=q):q=e[73];let J;e[74]!==W||e[75]!==U||e[76]!==q?(J=r.jsx(mt,{children:r.jsxs("div",{className:"flex flex-col gap-3 py-2 pl-[22px] pr-1",children:[W,U,q]})}),e[74]=W,e[75]=U,e[76]=q,e[77]=J):J=e[77];let Q;e[78]!==c||e[79]!==L||e[80]!==J?(Q=r.jsxs(ft,{open:c,onOpenChange:d,children:[L,J]}),e[78]=c,e[79]=L,e[80]=J,e[81]=Q):Q=e[81];let X;return e[82]!==t.title||e[83]!==Q||e[84]!==x?(X=r.jsxs("article",{className:"relative pl-3","aria-label":p,children:[x,Q]}),e[82]=t.title,e[83]=Q,e[84]=x,e[85]=X):X=e[85],X}function XI(n){return r.jsxs("span",{className:"flex items-center gap-1 truncate",children:[r.jsx(Mb,{label:n}),r.jsx("span",{className:"truncate",children:n.name})]},n.name)}function Ih(n,e,t){return e==="assigned"?t!==null&&n.assignees.includes(t):e==="opened"?t!==null&&n.author===t:e==="unassigned"?n.assignees.length===0:!0}function JI(n){const e=B.c(75),{data:t,composePrompt:s,onShowPulls:o}=n,[i,a]=y.useState("all"),[l,c]=y.useState(null),d=ml(!1),u=t.viewer;let f;e[0]!==t.issues||e[1]!==u?(f=I=>t.issues.filter(R=>Ih(R,I,u)).length,e[0]=t.issues,e[1]=u,e[2]=f):f=e[2];const m=f;let p;e[3]!==m?(p=m("assigned"),e[3]=m,e[4]=p):p=e[4];const h=p;let g;e[5]!==m?(g=m("opened"),e[5]=m,e[6]=g):g=e[6];const x=g;let b;e[7]!==m?(b=m("unassigned"),e[7]=m,e[8]=b):b=e[8];const w=b,v=i==="assigned"&&h===0||i==="opened"&&x===0||i==="unassigned"&&w===0?"all":i,S=t.issues;let j,k,C,N,_,A,P;if(e[9]!==h||e[10]!==s||e[11]!==t.issues||e[12]!==v||e[13]!==l||e[14]!==d||e[15]!==o||e[16]!==x||e[17]!==w||e[18]!==u){C=Symbol.for("react.early_return_sentinel");e:{let I;e[26]!==v||e[27]!==l||e[28]!==u?(I=te=>Ih(te,v,u)&&(l===null||te.labels.some(ne=>ne.name===l)),e[26]=v,e[27]=l,e[28]=u,e[29]=I):I=e[29];const R=S.filter(I),D=R.filter(ZI),O=R.filter(QI);if(t.issues.length===0){let te;e[30]===Symbol.for("react.memo_cache_sentinel")?(te=r.jsx(pl,{icon:Cd,title:"No issues yet",description:"Issues opened on this repository will show up here."}),e[30]=te):te=e[30],C=te;break e}let M;e[31]!==s||e[32]!==d||e[33]!==o||e[34]!==u?(M=te=>r.jsx(YI,{issue:te,viewer:u,now:d,onPickLabel:c,onShowPull:o,composePrompt:s},te.number),e[31]=s,e[32]=d,e[33]=o,e[34]=u,e[35]=M):M=e[35];const F=M,z=v==="all";let L;e[36]===Symbol.for("react.memo_cache_sentinel")?(L=()=>a("all"),e[36]=L):L=e[36];let W;e[37]!==t.issues.length?(W=r.jsx(wt,{children:t.issues.length}),e[37]=t.issues.length,e[38]=W):W=e[38];let U;e[39]!==z||e[40]!==W?(U=r.jsxs(yt,{pressed:z,onClick:L,children:["All",W]}),e[39]=z,e[40]=W,e[41]=U):U=e[41];let H;e[42]!==h||e[43]!==v||e[44]!==u?(H=u&&r.jsxs(yt,{pressed:v==="assigned",disabled:h===0,onClick:()=>a("assigned"),"aria-label":"Only issues assigned to you",children:[r.jsx(H1,{className:"size-3"}),"Mine",r.jsx(wt,{children:h})]}),e[42]=h,e[43]=v,e[44]=u,e[45]=H):H=e[45];let K;e[46]!==v||e[47]!==x||e[48]!==u?(K=u&&r.jsxs(yt,{pressed:v==="opened",disabled:x===0,onClick:()=>a("opened"),"aria-label":"Only issues you opened",children:[r.jsx(Pd,{className:"size-3"}),"Opened",r.jsx(wt,{children:x})]}),e[46]=v,e[47]=x,e[48]=u,e[49]=K):K=e[49];const V=v==="unassigned",Y=w===0;let q;e[50]===Symbol.for("react.memo_cache_sentinel")?(q=()=>a("unassigned"),e[50]=q):q=e[50];let J;e[51]===Symbol.for("react.memo_cache_sentinel")?(J=r.jsx(Cw,{className:"size-3"}),e[51]=J):J=e[51];let Q;e[52]!==w?(Q=r.jsx(wt,{children:w}),e[52]=w,e[53]=Q):Q=e[53];let X;e[54]!==V||e[55]!==Y||e[56]!==Q?(X=r.jsxs(yt,{pressed:V,disabled:Y,onClick:q,"aria-label":"Only unassigned issues",children:[J,"Unassigned",Q]}),e[54]=V,e[55]=Y,e[56]=Q,e[57]=X):X=e[57];const Z=l&&r.jsxs(yt,{pressed:!0,onClick:()=>c(null),"aria-label":`Clear label filter ${l}`,children:[r.jsx("span",{className:"max-w-28 truncate",children:l}),r.jsx(wt,{children:R.length}),r.jsx(nt,{className:"size-3","aria-hidden":!0})]});e[58]!==U||e[59]!==H||e[60]!==K||e[61]!==X||e[62]!==Z?(k=r.jsxs($r,{label:"Filter issues",children:[U,H,K,X,Z]}),e[58]=U,e[59]=H,e[60]=K,e[61]=X,e[62]=Z,e[63]=k):k=e[63],j=qn,P="min-h-0 flex-1",N="flex flex-col gap-4 px-3 py-3",_=D.length===0?r.jsx("p",{className:"px-1 py-3 text-center text-xs text-muted-foreground",children:"Nothing open here."}):D.map(F),A=O.length>0&&r.jsx(Uu,{count:O.length,children:O.map(F)})}e[9]=h,e[10]=s,e[11]=t.issues,e[12]=v,e[13]=l,e[14]=d,e[15]=o,e[16]=x,e[17]=w,e[18]=u,e[19]=j,e[20]=k,e[21]=C,e[22]=N,e[23]=_,e[24]=A,e[25]=P}else j=e[19],k=e[20],C=e[21],N=e[22],_=e[23],A=e[24],P=e[25];if(C!==Symbol.for("react.early_return_sentinel"))return C;let T;e[64]!==N||e[65]!==_||e[66]!==A?(T=r.jsxs("div",{className:N,children:[_,A]}),e[64]=N,e[65]=_,e[66]=A,e[67]=T):T=e[67];let E;e[68]!==j||e[69]!==T||e[70]!==P?(E=r.jsx(j,{className:P,children:T}),e[68]=j,e[69]=T,e[70]=P,e[71]=E):E=e[71];let $;return e[72]!==k||e[73]!==E?($=r.jsxs(r.Fragment,{children:[k,E]}),e[72]=k,e[73]=E,e[74]=$):$=e[74],$}function QI(n){return n.state!=="open"}function ZI(n){return n.state==="open"}const Ob={open:"Open",draft:"Draft",merged:"Merged",closed:"Closed"},eM={open:"bg-success",draft:"bg-border",merged:"bg-info",closed:"bg-destructive"};function qs(n){return n.state==="open"||n.state==="draft"}function tM(n){const e=B.c(12),{state:t}=n,s=Ob[t];if(t==="open"){let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=G("size-3.5 shrink-0","text-success"),e[0]=a):a=e[0];let l;return e[1]!==s?(l=r.jsx(Fr,{className:a,"aria-label":s}),e[1]=s,e[2]=l):l=e[2],l}if(t==="draft"){let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=G("size-3.5 shrink-0","text-muted-foreground"),e[3]=a):a=e[3];let l;return e[4]!==s?(l=r.jsx(Ed,{className:a,"aria-label":s}),e[4]=s,e[5]=l):l=e[5],l}if(t==="merged"){let a;e[6]===Symbol.for("react.memo_cache_sentinel")?(a=G("size-3.5 shrink-0","text-info"),e[6]=a):a=e[6];let l;return e[7]!==s?(l=r.jsx(q1,{className:a,"aria-label":s}),e[7]=s,e[8]=l):l=e[8],l}let o;e[9]===Symbol.for("react.memo_cache_sentinel")?(o=G("size-3.5 shrink-0","text-destructive"),e[9]=o):o=e[9];let i;return e[10]!==s?(i=r.jsx(Tw,{className:o,"aria-label":s}),e[10]=s,e[11]=i):i=e[11],i}function Mh(n){return n==="success"?"Checks passed":n==="failure"?"Checks failed":"Checks running"}function nM(n){const e=B.c(3),{checks:t}=n;if(t==="success"){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(dt,{className:"size-3 text-success"}),e[0]=o):o=e[0],o}if(t==="failure"){let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(nt,{className:"size-3 text-destructive"}),e[1]=o):o=e[1],o}let s;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Lr,{className:"size-3 text-info"}),e[2]=s):s=e[2],s}function sM(n){return n.reviewRequested?{icon:r.jsx(ys,{className:"size-3 text-info"}),label:"Your review is requested"}:n.review==="approved"?{icon:r.jsx(Or,{className:"size-3 text-success"}),label:"Approved"}:n.review==="changes_requested"?{icon:r.jsx(Yt,{className:"size-3 text-warning"}),label:"Changes requested"}:n.review==="review_required"&&qs(n)?{icon:r.jsx(ys,{className:"size-3 text-muted-foreground"}),label:"Review required"}:null}function oM(n){const e=B.c(17),{pull:t,onShowChecks:s}=n;let o;e[0]!==t?(o=sM(t),e[0]=t,e[1]=o):o=e[1];const i=o;let a;e[2]!==s||e[3]!==t.checks||e[4]!==t.headBranch?(a=t.checks&&r.jsx("button",{type:"button",className:"rounded-sm outline-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/20","aria-label":`${Mh(t.checks)}, show runs`,title:Mh(t.checks),onClick:()=>s(t.headBranch),children:r.jsx(nM,{checks:t.checks})}),e[2]=s,e[3]=t.checks,e[4]=t.headBranch,e[5]=a):a=e[5];let l;e[6]!==i?(l=i&&r.jsx("span",{"aria-label":i.label,title:i.label,role:"img",children:i.icon}),e[6]=i,e[7]=l):l=e[7];let c;e[8]!==t.conflicts?(c=t.conflicts&&r.jsx(gn,{className:"size-3 text-warning","aria-label":"Has merge conflicts",role:"img"}),e[8]=t.conflicts,e[9]=c):c=e[9];let d;e[10]!==t.comments?(d=r.jsx(nb,{count:t.comments}),e[10]=t.comments,e[11]=d):d=e[11];let u;return e[12]!==a||e[13]!==l||e[14]!==c||e[15]!==d?(u=r.jsxs("span",{className:"flex h-5 shrink-0 items-center gap-1.5",children:[a,l,c,d]}),e[12]=a,e[13]=l,e[14]=c,e[15]=d,e[16]=u):u=e[16],u}function rM(n){return n==="added"||n==="copied"?{mark:"A",className:"text-success"}:n==="removed"?{mark:"D",className:"text-destructive"}:n==="renamed"?{mark:"R",className:"text-info"}:{mark:"M",className:"text-warning"}}function iM(n){const e=n.lastIndexOf("/");return e===-1?{directory:"",name:n}:{directory:n.slice(0,e+1),name:n.slice(e+1)}}function aM(n){const e=B.c(38),{file:t}=n;let s,o,i,a,l,c;if(e[0]!==t.path||e[1]!==t.status){const{mark:S,className:j}=rM(t.status);o=S;let k;e[8]!==t.path?(k=iM(t.path),e[8]=t.path,e[9]=k):k=e[9],{directory:s,name:i}=k,l="flex min-w-0 items-center gap-2 py-0.5 font-mono text-[11px] leading-5",c=t.path,a=G("w-3 shrink-0 text-center font-medium",j),e[0]=t.path,e[1]=t.status,e[2]=s,e[3]=o,e[4]=i,e[5]=a,e[6]=l,e[7]=c}else s=e[2],o=e[3],i=e[4],a=e[5],l=e[6],c=e[7];let d;e[10]!==t.status||e[11]!==o||e[12]!==a?(d=r.jsx("span",{className:a,"aria-label":t.status,children:o}),e[10]=t.status,e[11]=o,e[12]=a,e[13]=d):d=e[13];let u;e[14]!==s?(u=r.jsx("span",{className:"text-muted-foreground",children:s}),e[14]=s,e[15]=u):u=e[15];const f=t.status==="removed"&&"line-through text-muted-foreground";let m;e[16]!==f?(m=G(f),e[16]=f,e[17]=m):m=e[17];let p;e[18]!==i||e[19]!==m?(p=r.jsx("span",{className:m,children:i}),e[18]=i,e[19]=m,e[20]=p):p=e[20];let h;e[21]!==u||e[22]!==p?(h=r.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[u,p]}),e[21]=u,e[22]=p,e[23]=h):h=e[23];let g;e[24]!==t.additions?(g=t.additions>0&&r.jsxs("span",{className:"text-success",children:["+",t.additions]}),e[24]=t.additions,e[25]=g):g=e[25];const x=t.additions>0&&t.deletions>0&&" ";let b;e[26]!==t.deletions?(b=t.deletions>0&&r.jsxs("span",{className:"text-destructive",children:["−",t.deletions]}),e[26]=t.deletions,e[27]=b):b=e[27];let w;e[28]!==g||e[29]!==x||e[30]!==b?(w=r.jsxs("span",{className:"shrink-0 text-[10px] tabular-nums",children:[g,x,b]}),e[28]=g,e[29]=x,e[30]=b,e[31]=w):w=e[31];let v;return e[32]!==w||e[33]!==l||e[34]!==c||e[35]!==d||e[36]!==h?(v=r.jsxs("li",{className:l,title:c,children:[d,h,w]}),e[32]=w,e[33]=l,e[34]=c,e[35]=d,e[36]=h,e[37]=v):v=e[37],v}function lM(n){var j,k,C,N,_,A;const e=B.c(40),{pull:t,files:s}=n;let o;e[0]!==t.body?(o=t.body.trim(),e[0]=t.body,e[1]=o):o=e[1];const i=o;let a;e[2]!==((j=s.data)==null?void 0:j.files)?(a=((k=s.data)==null?void 0:k.files)??[],e[2]=(C=s.data)==null?void 0:C.files,e[3]=a):a=e[3];const l=a;let c;e[4]!==i?(c=i?r.jsx(Wu,{body:i}):r.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"No description."}),e[4]=i,e[5]=c):c=e[5];let d;e[6]!==s.data||e[7]!==l.length?(d=s.data&&r.jsx("span",{className:"font-mono text-[10px] font-normal text-muted-foreground tabular-nums",children:s.data.truncated?`${l.length}+`:l.length}),e[6]=s.data,e[7]=l.length,e[8]=d):d=e[8];let u;e[9]!==d?(u=r.jsxs("h4",{className:"flex items-center gap-1.5 text-[11px] font-medium leading-5",children:["Files changed",d]}),e[9]=d,e[10]=u):u=e[10];let f;e[11]!==s.data||e[12]!==s.loading?(f=s.loading&&!s.data&&r.jsxs("div",{className:"flex items-center gap-2 py-1 text-[11px] text-muted-foreground",role:"status",children:[r.jsx(st,{className:"size-3"}),"Loading files"]}),e[11]=s.data,e[12]=s.loading,e[13]=f):f=e[13];let m;e[14]!==s.error?(m=s.error&&r.jsx("p",{className:"py-1 text-[11px] text-destructive",children:s.error.error}),e[14]=s.error,e[15]=m):m=e[15];let p;e[16]!==s.data||e[17]!==l.length?(p=s.data&&l.length===0&&r.jsx("p",{className:"py-1 text-[11px] text-muted-foreground",children:"No file changes on this pull request."}),e[16]=s.data,e[17]=l.length,e[18]=p):p=e[18];let h;e[19]!==l?(h=l.length>0&&r.jsx("ul",{className:"border-l border-border pl-2",children:l.map(cM)}),e[19]=l,e[20]=h):h=e[20];let g;e[21]!==((N=s.data)==null?void 0:N.truncated)||e[22]!==l.length?(g=((_=s.data)==null?void 0:_.truncated)&&r.jsxs("p",{className:"py-1 text-[11px] text-muted-foreground",children:["GitHub lists the first ",l.length," files here. The full set is on the pull request."]}),e[21]=(A=s.data)==null?void 0:A.truncated,e[22]=l.length,e[23]=g):g=e[23];let x;e[24]!==g||e[25]!==u||e[26]!==f||e[27]!==m||e[28]!==p||e[29]!==h?(x=r.jsxs("section",{"aria-label":"Files changed",className:"min-w-0",children:[u,f,m,p,h,g]}),e[24]=g,e[25]=u,e[26]=f,e[27]=m,e[28]=p,e[29]=h,e[30]=x):x=e[30];let b;e[31]!==t.url?(b=r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer"}),e[31]=t.url,e[32]=b):b=e[32];let w;e[33]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(Zt,{"data-icon":"inline-end"}),e[33]=w):w=e[33];let v;e[34]!==b?(v=r.jsxs(ee,{variant:"outline",size:"xs",className:"self-start",render:b,children:["Open pull request on GitHub",w]}),e[34]=b,e[35]=v):v=e[35];let S;return e[36]!==x||e[37]!==v||e[38]!==c?(S=r.jsxs("div",{className:"flex flex-col gap-3 py-2 pl-[22px] pr-1",children:[c,x,v]}),e[36]=x,e[37]=v,e[38]=c,e[39]=S):S=e[39],S}function cM(n){return r.jsx(aM,{file:n},n.path)}function dM(n){const e=B.c(7),{sessions:t,openSession:s}=n;let o;if(e[0]!==s||e[1]!==t){let a;e[3]!==s?(a=l=>r.jsxs("button",{type:"button",className:"inline-flex h-5 max-w-full items-center gap-1 rounded-full border px-1.5 text-[10px] leading-none text-muted-foreground outline-none hover:border-foreground/30 hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/20 disabled:cursor-default disabled:hover:border-border disabled:hover:text-muted-foreground",onClick:()=>s==null?void 0:s(l.dirName,l.fileName),disabled:!s,"aria-label":`Open session: ${l.title||l.sessionId}`,title:l.title||l.sessionId,children:[r.jsx(kc,{className:"size-3 shrink-0","aria-hidden":!0}),r.jsx("span",{className:"truncate",children:l.title||l.sessionId.slice(0,8)})]},l.sessionId),e[3]=s,e[4]=a):a=e[4],o=t.map(a),e[0]=s,e[1]=t,e[2]=o}else o=e[2];let i;return e[5]!==o?(i=r.jsx("div",{className:"flex flex-wrap gap-1 pl-[26px] pr-1 pb-1","aria-label":"Sessions on this pull request",children:o}),e[5]=o,e[6]=i):i=e[6],i}function uM(n){const e=B.c(88),{pull:t,projectPath:s,currentBranch:o,sessions:i,openSession:a,onShowChecks:l,now:c}=n;let d;e[0]!==s||e[1]!==t.number?(d=()=>_I(s,t.number),e[0]=s,e[1]=t.number,e[2]=d):d=e[2];const{open:u,state:f,onOpenChange:m}=Rb(d,"Unable to load changed files"),p=o!==null&&t.headBranch===o,h=qs(t)?t.updatedAt:t.closedAt??t.updatedAt,g=t.title,x=eM[t.state];let b;e[3]!==x?(b=G("absolute inset-y-1 left-0 w-0.5 rounded-full",x),e[3]=x,e[4]=b):b=e[4];let w;e[5]!==b?(w=r.jsx("span",{"aria-hidden":!0,className:b}),e[5]=b,e[6]=w):w=e[6];const v=`${t.title} #${t.number}: ${Ob[t.state]}`;let S;e[7]!==t.state?(S=r.jsx(tM,{state:t.state}),e[7]=t.state,e[8]=S):S=e[8];let j;e[9]!==t?(j=!qs(t)&&"text-muted-foreground",e[9]=t,e[10]=j):j=e[10];let k;e[11]!==j?(k=G("min-w-0 flex-1 truncate text-[13px] font-medium leading-5",j),e[11]=j,e[12]=k):k=e[12];let C;e[13]!==t.title||e[14]!==k?(C=r.jsx("span",{className:k,children:t.title}),e[13]=t.title,e[14]=k,e[15]=C):C=e[15];let N;e[16]!==t.number?(N=r.jsxs("span",{className:"shrink-0 font-mono text-[10px] text-muted-foreground",children:["#",t.number]}),e[16]=t.number,e[17]=N):N=e[17];let _;e[18]!==C||e[19]!==N||e[20]!==S?(_=r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[S,C,N]}),e[18]=C,e[19]=N,e[20]=S,e[21]=_):_=e[21];let A;e[22]!==t.author?(A=t.author&&r.jsx("span",{className:"shrink-0",children:t.author}),e[22]=t.author,e[23]=A):A=e[23];let P;e[24]!==p?(P=p&&r.jsx(zn,{className:"size-3 shrink-0 text-foreground","aria-label":"Current branch"}),e[24]=p,e[25]=P):P=e[25];const T=p&&"text-foreground";let E;e[26]!==T?(E=G("truncate",T),e[26]=T,e[27]=E):E=e[27];let $;e[28]!==t.headBranch||e[29]!==E?($=r.jsx("span",{className:E,children:t.headBranch}),e[28]=t.headBranch,e[29]=E,e[30]=$):$=e[30];let I;e[31]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(Ew,{className:"size-3 shrink-0","aria-hidden":!0}),e[31]=I):I=e[31];let R;e[32]!==t.baseBranch?(R=r.jsx("span",{className:"max-w-24 shrink-0 truncate",children:t.baseBranch}),e[32]=t.baseBranch,e[33]=R):R=e[33];let D;e[34]!==P||e[35]!==$||e[36]!==R?(D=r.jsxs("span",{className:"flex min-w-0 items-center gap-1 font-mono",children:[P,$,I,R]}),e[34]=P,e[35]=$,e[36]=R,e[37]=D):D=e[37];let O;e[38]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsx("span",{className:"shrink-0",children:"·"}),e[38]=O):O=e[38];let M;e[39]!==h?(M=new Date(h).toLocaleString(),e[39]=h,e[40]=M):M=e[40];let F;e[41]!==h||e[42]!==c?(F=fl(h,c),e[41]=h,e[42]=c,e[43]=F):F=e[43];let z;e[44]!==h||e[45]!==M||e[46]!==F?(z=r.jsx("time",{className:"shrink-0",dateTime:h,title:M,children:F}),e[44]=h,e[45]=M,e[46]=F,e[47]=z):z=e[47];let L;e[48]!==A||e[49]!==D||e[50]!==z?(L=r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 pl-[22px] text-[11px] leading-4 text-muted-foreground",children:[A,D,O,z]}),e[48]=A,e[49]=D,e[50]=z,e[51]=L):L=e[51];let W;e[52]!==u||e[53]!==_||e[54]!==L||e[55]!==v?(W=r.jsxs(Rt,{className:"flex min-w-0 flex-1 flex-col rounded-sm px-1 py-1 text-left outline-none hover:bg-accent/60 focus-visible:ring-[3px] focus-visible:ring-ring/20","aria-label":v,"aria-expanded":u,children:[_,L]}),e[52]=u,e[53]=_,e[54]=L,e[55]=v,e[56]=W):W=e[56];let U;e[57]!==l||e[58]!==t?(U=r.jsx(oM,{pull:t,onShowChecks:l}),e[57]=l,e[58]=t,e[59]=U):U=e[59];const H=`Open #${t.number} on GitHub`;let K;e[60]!==t.url?(K=()=>window.open(t.url,"_blank","noopener,noreferrer"),e[60]=t.url,e[61]=K):K=e[61];let V;e[62]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx(Zt,{}),e[62]=V):V=e[62];let Y;e[63]!==H||e[64]!==K?(Y=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",className:"size-6 text-muted-foreground opacity-0 transition-opacity group-hover/pull:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100","aria-label":H,onClick:K,children:V}),e[63]=H,e[64]=K,e[65]=Y):Y=e[65];let q;e[66]!==U||e[67]!==Y?(q=r.jsxs("div",{className:"mt-1 flex shrink-0 items-center gap-1",children:[U,Y]}),e[66]=U,e[67]=Y,e[68]=q):q=e[68];let J;e[69]!==W||e[70]!==q?(J=r.jsxs("div",{className:"group/pull flex items-start gap-1 pr-1",children:[W,q]}),e[69]=W,e[70]=q,e[71]=J):J=e[71];let Q;e[72]!==a||e[73]!==i?(Q=i.length>0&&r.jsx(dM,{sessions:i,openSession:a}),e[72]=a,e[73]=i,e[74]=Q):Q=e[74];let X;e[75]!==f||e[76]!==t?(X=r.jsx(mt,{children:r.jsx(lM,{pull:t,files:f})}),e[75]=f,e[76]=t,e[77]=X):X=e[77];let Z;e[78]!==m||e[79]!==u||e[80]!==J||e[81]!==Q||e[82]!==X?(Z=r.jsxs(ft,{open:u,onOpenChange:m,children:[J,Q,X]}),e[78]=m,e[79]=u,e[80]=J,e[81]=Q,e[82]=X,e[83]=Z):Z=e[83];let te;return e[84]!==t.title||e[85]!==Z||e[86]!==w?(te=r.jsxs("article",{className:"relative pl-3","aria-label":g,children:[w,Z]}),e[84]=t.title,e[85]=Z,e[86]=w,e[87]=te):te=e[87],te}function fM(n,e,t){return e==="mine"?n.filter(s=>s.author===t.viewer):e==="branch"?n.filter(s=>s.headBranch===t.branch):[...n]}function mM(n){const e=new Map;for(const t of n)for(const s of t.numbers){const o=e.get(s);o?o.push(t):e.set(s,[t])}return e}function pM(n){const e=B.c(61),{data:t,sessions:s,projectPath:o,openSession:i,onShowChecks:a}=n,[l,c]=y.useState("all"),d=ml(!1);let u;e[0]!==s?(u=mM(s),e[0]=s,e[1]=u):u=e[1];const f=u;let m;e[2]!==t.pulls||e[3]!==t.viewer?(m=t.viewer?t.pulls.filter(P=>P.author===t.viewer).length:0,e[2]=t.pulls,e[3]=t.viewer,e[4]=m):m=e[4];const p=m;let h;e[5]!==t.branch||e[6]!==t.pulls?(h=t.branch?t.pulls.filter(P=>P.headBranch===t.branch).length:0,e[5]=t.branch,e[6]=t.pulls,e[7]=h):h=e[7];const g=h,x=l==="mine"&&p===0||l==="branch"&&g===0?"all":l;let b,w,v,S,j,k,C;if(e[8]!==g||e[9]!==t||e[10]!==x||e[11]!==f||e[12]!==p||e[13]!==d||e[14]!==a||e[15]!==i||e[16]!==o){C=Symbol.for("react.early_return_sentinel");e:{const P=fM(t.pulls,x,t),T=P.filter(qs),E=P.filter(hM);if(t.pulls.length===0){let L;e[24]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(pl,{icon:Fr,title:"No pull requests yet",description:"Open one from a branch and it will show up here."}),e[24]=L):L=e[24],C=L;break e}let $;e[25]!==t.branch||e[26]!==f||e[27]!==d||e[28]!==a||e[29]!==i||e[30]!==o?($=L=>r.jsx(uM,{pull:L,projectPath:o,currentBranch:t.branch,sessions:f.get(L.number)??[],openSession:i,onShowChecks:a,now:d},L.number),e[25]=t.branch,e[26]=f,e[27]=d,e[28]=a,e[29]=i,e[30]=o,e[31]=$):$=e[31];const I=$,R=x==="all";let D;e[32]===Symbol.for("react.memo_cache_sentinel")?(D=()=>c("all"),e[32]=D):D=e[32];let O;e[33]!==t.pulls.length?(O=r.jsx(wt,{children:t.pulls.length}),e[33]=t.pulls.length,e[34]=O):O=e[34];let M;e[35]!==R||e[36]!==O?(M=r.jsxs(yt,{pressed:R,onClick:D,children:["All",O]}),e[35]=R,e[36]=O,e[37]=M):M=e[37];let F;e[38]!==t.viewer||e[39]!==x||e[40]!==p?(F=t.viewer&&r.jsxs(yt,{pressed:x==="mine",disabled:p===0,onClick:()=>c("mine"),"aria-label":`Only pull requests by ${t.viewer}`,children:[r.jsx(Pd,{className:"size-3"}),"Mine",r.jsx(wt,{children:p})]}),e[38]=t.viewer,e[39]=x,e[40]=p,e[41]=F):F=e[41];let z;e[42]!==g||e[43]!==t.branch||e[44]!==x?(z=t.branch&&r.jsxs(yt,{pressed:x==="branch",disabled:g===0,onClick:()=>c("branch"),"aria-label":`Only pull requests from ${t.branch}`,children:[r.jsx(zn,{className:"size-3"}),r.jsx("span",{className:"max-w-28 truncate",children:t.branch}),r.jsx(wt,{children:g})]}),e[42]=g,e[43]=t.branch,e[44]=x,e[45]=z):z=e[45],e[46]!==M||e[47]!==F||e[48]!==z?(k=r.jsxs($r,{label:"Filter pull requests",children:[M,F,z]}),e[46]=M,e[47]=F,e[48]=z,e[49]=k):k=e[49],b=qn,j="min-h-0 flex-1",w="flex flex-col gap-4 px-3 py-3",v=T.length===0?r.jsx("p",{className:"px-1 py-3 text-center text-xs text-muted-foreground",children:"Nothing open right now."}):T.map(I),S=E.length>0&&r.jsx(Uu,{count:E.length,children:E.map(I)})}e[8]=g,e[9]=t,e[10]=x,e[11]=f,e[12]=p,e[13]=d,e[14]=a,e[15]=i,e[16]=o,e[17]=b,e[18]=w,e[19]=v,e[20]=S,e[21]=j,e[22]=k,e[23]=C}else b=e[17],w=e[18],v=e[19],S=e[20],j=e[21],k=e[22],C=e[23];if(C!==Symbol.for("react.early_return_sentinel"))return C;let N;e[50]!==w||e[51]!==v||e[52]!==S?(N=r.jsxs("div",{className:w,children:[v,S]}),e[50]=w,e[51]=v,e[52]=S,e[53]=N):N=e[53];let _;e[54]!==b||e[55]!==N||e[56]!==j?(_=r.jsx(b,{className:j,children:N}),e[54]=b,e[55]=N,e[56]=j,e[57]=_):_=e[57];let A;return e[58]!==_||e[59]!==k?(A=r.jsxs(r.Fragment,{children:[k,_]}),e[58]=_,e[59]=k,e[60]=A):A=e[60],A}function hM(n){return!qs(n)}const gM={actions:"Refresh GitHub Actions",pulls:"Refresh pull requests",issues:"Refresh issues"};function xM(n){return n==="actions"||n==="pulls"||n==="issues"}function bM(n){return n.code==="gh_missing"?"Install GitHub CLI, then refresh this panel.":n.code==="gh_auth_required"?"Run `gh auth login` on the Cogpit host, then refresh.":n.code==="no_github_remote"?"Add a GitHub origin remote to this repository.":"Check the repository and your GitHub access, then try again."}function vM(n){const e=B.c(3),{label:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=[0,1,2].map(yM),e[0]=s):s=e[0];let o;return e[1]!==t?(o=r.jsx("div",{className:"flex flex-col gap-5 px-3 py-4","aria-label":t,children:s}),e[1]=t,e[2]=o):o=e[2],o}function yM(n){return r.jsxs("div",{className:"flex flex-col gap-2 border-l-2 border-border pl-3",children:[r.jsx(ct,{className:"h-3.5 w-3/4"}),r.jsx(ct,{className:"h-2.5 w-1/2"}),r.jsx(ct,{className:"h-3 w-full"}),r.jsx(ct,{className:"h-3 w-full"})]},n)}function uc(n){const e=B.c(23),{state:t,loadingLabel:s,onRetry:o,children:i}=n;if(t.data){let l;e[0]!==i||e[1]!==t.data?(l=i(t.data),e[0]=i,e[1]=t.data,e[2]=l):l=e[2];let c;return e[3]!==l?(c=r.jsx(r.Fragment,{children:l}),e[3]=l,e[4]=c):c=e[4],c}if(t.error){let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Yt,{}),e[5]=l):l=e[5];let c;e[6]!==t.error.error?(c=r.jsx(Et,{children:t.error.error}),e[6]=t.error.error,e[7]=c):c=e[7];let d;e[8]!==t.error?(d=bM(t.error),e[8]=t.error,e[9]=d):d=e[9];let u;e[10]!==d?(u=r.jsx("span",{children:d}),e[10]=d,e[11]=u):u=e[11];let f;e[12]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(Pt,{"data-icon":"inline-start"}),e[12]=f):f=e[12];let m;e[13]!==o?(m=r.jsxs(ee,{type:"button",variant:"outline",size:"xs",onClick:o,children:[f,"Try again"]}),e[13]=o,e[14]=m):m=e[14];let p;e[15]!==u||e[16]!==m?(p=r.jsxs(ht,{className:"flex flex-col items-start gap-2",children:[u,m]}),e[15]=u,e[16]=m,e[17]=p):p=e[17];let h;return e[18]!==c||e[19]!==p?(h=r.jsx("div",{className:"p-3",children:r.jsxs(pt,{variant:"destructive",children:[l,c,p]})}),e[18]=c,e[19]=p,e[20]=h):h=e[20],h}let a;return e[21]!==s?(a=r.jsx(vM,{label:s}),e[21]=s,e[22]=a):a=e[22],a}function fc(n){const e=B.c(5),{value:t,attention:s}=n;if(t===null||t===0)return null;const o=s?"text-info":"text-muted-foreground";let i;e[0]!==o?(i=G("font-mono text-[10px] tabular-nums",o),e[0]=o,e[1]=i):i=e[1];let a;return e[2]!==i||e[3]!==t?(a=r.jsx("span",{className:i,children:t}),e[2]=i,e[3]=t,e[4]=a):a=e[4],a}function wM(n){var f,m,p,h;const e=B.c(11),{context:t}=n,s=t.projectPath!==null,{data:o}=Ab(t.projectPath,s),i=Pb(t.projectPath,s);let a;e[0]!==(o==null?void 0:o.runs)?(a=(o==null?void 0:o.runs.filter(SM).length)??0,e[0]=o==null?void 0:o.runs,e[1]=a):a=e[1];const l=a,c=(f=o==null?void 0:o.runs[0])!=null&&f.conclusion?Uo(o.runs[0].conclusion):!1;let d;e[2]!==((m=i.data)==null?void 0:m.pulls)?(d=((p=i.data)==null?void 0:p.pulls.filter(jM).length)??0,e[2]=(h=i.data)==null?void 0:h.pulls,e[3]=d):d=e[3];const u=d;if(l>0){const g=`${l} active GitHub Actions run${l===1?"":"s"}`;let x;return e[4]!==l||e[5]!==g?(x=r.jsx(Pe,{className:"absolute -right-1 -top-1 min-w-4 px-1 text-[9px]","aria-label":g,children:l}),e[4]=l,e[5]=g,e[6]=x):x=e[6],x}if(c){let g;return e[7]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx(Pe,{variant:"destructive",className:"absolute -right-0.5 -top-0.5 size-3 p-0 text-[8px]","aria-label":"Latest GitHub Actions run failed",children:"!"}),e[7]=g):g=e[7],g}if(u>0){const g=`${u} pull request${u===1?"":"s"} waiting for your review`;let x;return e[8]!==u||e[9]!==g?(x=r.jsx(Pe,{variant:"secondary",className:"absolute -right-1 -top-1 min-w-4 px-1 text-[9px]","aria-label":g,children:u}),e[8]=u,e[9]=g,e[10]=x):x=e[10],x}return null}function jM(n){return qs(n)&&n.reviewRequested}function SM(n){return ui(n.status)}function NM(n){const e=B.c(78),{context:t,active:s,closePanel:o}=n,[i,a]=y.useState("actions"),[l,c]=y.useState(null),d=t.projectPath,u=Ab(d,s),f=Pb(d,s),m=kI(d,s&&i==="pulls"),p=NI(d,s&&i==="issues");let h;e[0]!==p||e[1]!==f||e[2]!==u?(h={actions:u,pulls:f,issues:p},e[0]=p,e[1]=f,e[2]=u,e[3]=h):h=e[3];const g=h[i];let x;e[4]===Symbol.for("react.memo_cache_sentinel")?(x=function(oe){c({branch:oe}),a("actions")},e[4]=x):x=e[4];const b=x,w=u.data??f.data??p.data;let v;e[5]!==u.data?(v=u.data?u.data.runs.filter(CM).length:null,e[5]=u.data,e[6]=v):v=e[6];const S=v;let j;e[7]!==f.data?(j=f.data?f.data.pulls.filter(qs).length:null,e[7]=f.data,e[8]=j):j=e[8];const k=j;let C;e[9]!==p.data?(C=p.data?p.data.issues.filter(kM).length:null,e[9]=p.data,e[10]=C):C=e[10];const N=C;let _;e[11]===Symbol.for("react.memo_cache_sentinel")?(_=ne=>{xM(ne)&&a(ne)},e[11]=_):_=e[11];let A;e[12]===Symbol.for("react.memo_cache_sentinel")?(A=r.jsx("h2",{className:"text-sm font-medium leading-tight",children:"GitHub"}),e[12]=A):A=e[12];let P;e[13]!==w||e[14]!==i?(P=r.jsxs("div",{className:"min-w-0 flex-1",children:[A,w?r.jsxs("a",{href:`${w.repositoryUrl}/${i}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex max-w-full items-center gap-0.5 truncate text-[11px] text-muted-foreground outline-none hover:text-foreground focus-visible:underline",children:[r.jsx("span",{className:"truncate",children:w.repository}),r.jsx(Zt,{className:"size-3 shrink-0"})]}):r.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:"Current repository"})]}),e[13]=w,e[14]=i,e[15]=P):P=e[15];let T;e[16]!==g?(T=()=>{g.refresh()},e[16]=g,e[17]=T):T=e[17];const E=g.loading||g.refreshing||!d,$=gM[i];let I;e[18]!==g.refreshing?(I=g.refreshing?r.jsx(st,{}):r.jsx(Pt,{}),e[18]=g.refreshing,e[19]=I):I=e[19];let R;e[20]!==E||e[21]!==$||e[22]!==I||e[23]!==T?(R=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:T,disabled:E,"aria-label":$,children:I}),e[20]=E,e[21]=$,e[22]=I,e[23]=T,e[24]=R):R=e[24];let D;e[25]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(nt,{}),e[25]=D):D=e[25];let O;e[26]!==o?(O=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:o,"aria-label":"Close GitHub",children:D}),e[26]=o,e[27]=O):O=e[27];let M;e[28]!==R||e[29]!==O||e[30]!==P?(M=r.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b pl-4 pr-2",children:[P,R,O]}),e[28]=R,e[29]=O,e[30]=P,e[31]=M):M=e[31];let F;e[32]!==S?(F=r.jsxs(Dn,{value:"actions",className:"h-full flex-none rounded-none px-0 text-xs",children:["Actions",r.jsx(fc,{value:S,attention:!0})]}),e[32]=S,e[33]=F):F=e[33];let z;e[34]!==k?(z=r.jsxs(Dn,{value:"pulls",className:"h-full flex-none rounded-none px-0 text-xs",children:["Pull requests",r.jsx(fc,{value:k})]}),e[34]=k,e[35]=z):z=e[35];let L;e[36]!==N?(L=r.jsxs(Dn,{value:"issues",className:"h-full flex-none rounded-none px-0 text-xs",children:["Issues",r.jsx(fc,{value:N})]}),e[36]=N,e[37]=L):L=e[37];let W;e[38]!==F||e[39]!==z||e[40]!==L?(W=r.jsx("div",{className:"flex h-9 shrink-0 items-end border-b px-3",children:r.jsxs(Ga,{variant:"line",className:"h-full gap-3 p-0","aria-label":"GitHub views",children:[F,z,L]})}),e[38]=F,e[39]=z,e[40]=L,e[41]=W):W=e[41];let U;e[42]!==u?(U=()=>{u.refresh()},e[42]=u,e[43]=U):U=e[43];let H;e[44]!==l||e[45]!==d?(H=ne=>d&&r.jsx(BI,{data:ne,projectPath:d,focus:l}),e[44]=l,e[45]=d,e[46]=H):H=e[46];let K;e[47]!==u||e[48]!==U||e[49]!==H?(K=r.jsx(Ln,{value:"actions",className:"flex min-h-0 flex-col",children:r.jsx(uc,{state:u,loadingLabel:"Loading workflow runs",onRetry:U,children:H})}),e[47]=u,e[48]=U,e[49]=H,e[50]=K):K=e[50];let V;e[51]!==f?(V=()=>{f.refresh()},e[51]=f,e[52]=V):V=e[52];let Y;e[53]!==t.openSession||e[54]!==d||e[55]!==m?(Y=ne=>{var oe;return d&&r.jsx(pM,{data:ne,sessions:((oe=m.data)==null?void 0:oe.sessions)??[],projectPath:d,openSession:t.openSession,onShowChecks:b})},e[53]=t.openSession,e[54]=d,e[55]=m,e[56]=Y):Y=e[56];let q;e[57]!==f||e[58]!==V||e[59]!==Y?(q=r.jsx(Ln,{value:"pulls",className:"flex min-h-0 flex-col",children:r.jsx(uc,{state:f,loadingLabel:"Loading pull requests",onRetry:V,children:Y})}),e[57]=f,e[58]=V,e[59]=Y,e[60]=q):q=e[60];let J;e[61]!==p?(J=()=>{p.refresh()},e[61]=p,e[62]=J):J=e[62];let Q;e[63]!==t.composePrompt?(Q=ne=>r.jsx(JI,{data:ne,composePrompt:t.composePrompt,onShowPulls:()=>a("pulls")}),e[63]=t.composePrompt,e[64]=Q):Q=e[64];let X;e[65]!==p||e[66]!==J||e[67]!==Q?(X=r.jsx(Ln,{value:"issues",className:"flex min-h-0 flex-col",children:r.jsx(uc,{state:p,loadingLabel:"Loading issues",onRetry:J,children:Q})}),e[65]=p,e[66]=J,e[67]=Q,e[68]=X):X=e[68];let Z;e[69]!==K||e[70]!==q||e[71]!==X?(Z=r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[K,q,X]}),e[69]=K,e[70]=q,e[71]=X,e[72]=Z):Z=e[72];let te;return e[73]!==M||e[74]!==W||e[75]!==Z||e[76]!==i?(te=r.jsxs(Va,{value:i,onValueChange:_,className:"size-full min-h-0 gap-0","aria-label":"GitHub panel",children:[M,W,Z]}),e[73]=M,e[74]=W,e[75]=Z,e[76]=i,e[77]=te):te=e[77],te}function kM(n){return n.state==="open"}function CM(n){return ui(n.status)}const _M={id:"github",workspacePanels:[{id:"repository",title:"GitHub",icon:j1,component:NM,indicator:wM,order:40,defaultSize:"38%",minSize:"360px",maxSize:"62%",when:n=>n.canAccessHostFiles&&n.projectPath!==null}]},tf={data:null,error:null,loading:!1,refreshing:!1},Oh=new Map,TM=8e3,EM=1e4,AM=new Set(["vercel_access_denied","vercel_auth_required","vercel_cli_too_old","vercel_missing","vercel_project_unlinked"]);function nf(n){let e=Oh.get(n);return e||(e={snapshot:tf,listeners:new Set,request:null,fetchedAt:0},Oh.set(n,e)),e}function mc(n,e){n.snapshot=e;for(const t of n.listeners)t()}async function Db(n){try{const e=await n.json();if(typeof e.error=="string"&&typeof e.code=="string")return e}catch{}return{error:`Vercel request failed (${n.status})`,code:"vercel_api_failed"}}async function pc(n,e=!1){const t=nf(n);if(t.request)return t.request;if(!(!e&&t.snapshot.error&&AM.has(t.snapshot.error.code))&&!(!e&&t.fetchedAt>0&&Date.now()-t.fetchedAt<TM))return mc(t,{...t.snapshot,error:null,loading:t.snapshot.data===null,refreshing:t.snapshot.data!==null}),t.request=be(`/api/vercel-deployments?cwd=${encodeURIComponent(n)}&limit=20`).then(async s=>{if(!s.ok)throw await Db(s);const o=await s.json();t.fetchedAt=Date.now(),mc(t,{data:o,error:null,loading:!1,refreshing:!1})}).catch(s=>{const o=s;mc(t,{...t.snapshot,error:{error:typeof o.error=="string"?o.error:"Unable to load Vercel deployments",code:typeof o.code=="string"?o.code:"vercel_api_failed"},loading:!1,refreshing:!1})}).finally(()=>{t.request=null}),t.request}function PM(n,e){if(!n)return()=>{};const t=nf(n);return t.listeners.add(e),()=>t.listeners.delete(e)}function $M(n){return n?nf(n).snapshot:tf}function Lb(n,e){const t=B.c(13),s=n??"";let o;t[0]!==s?(o=m=>PM(s,m),t[0]=s,t[1]=o):o=t[1];let i;t[2]!==s?(i=()=>$M(s),t[2]=s,t[3]=i):i=t[3];const a=y.useSyncExternalStore(o,i,RM);let l,c;t[4]!==e||t[5]!==s?(l=()=>{if(!e||!s)return;pc(s);const m=window.setInterval(()=>{pc(s)},EM);return()=>window.clearInterval(m)},c=[e,s],t[4]=e,t[5]=s,t[6]=l,t[7]=c):(l=t[6],c=t[7]),y.useEffect(l,c);let d;t[8]!==s?(d=()=>s?pc(s,!0):Promise.resolve(),t[8]=s,t[9]=d):d=t[9];const u=d;let f;return t[10]!==u||t[11]!==a?(f={...a,refresh:u},t[10]=u,t[11]=a,t[12]=f):f=t[12],f}function RM(){return tf}async function IM(n,e){const t=await be(`/api/vercel-deployments/build-logs?cwd=${encodeURIComponent(n)}&deploymentId=${encodeURIComponent(e)}&limit=200`);if(!t.ok)throw await Db(t);return t.json()}const MM={live:"bg-info motion-safe:animate-pulse",fail:"bg-destructive",pass:"bg-success"};function fi(n){return n==="BUILDING"||n==="INITIALIZING"||n==="QUEUED"}function bl(n){return n==="BLOCKED"||n==="CANCELED"||n==="ERROR"}function Io(n){return n.target==="production"}function zb(n){return fi(n)?"live":bl(n)?"fail":"pass"}function sf(n){return n==="READY"?"Ready":n==="BUILDING"?"Building":n==="INITIALIZING"?"Initializing":n==="QUEUED"?"Queued":n==="CANCELED"?"Canceled":n==="BLOCKED"?"Blocked":"Failed"}function Fb(n,e){const t=Math.floor((e-n)/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 OM(n,e){const t=n.buildingAt??n.createdAt,s=n.readyAt??(fi(n.state)?e:null);if(s===null)return null;const o=Math.max(0,Math.round((s-t)/1e3));if(o<60)return`${o}s`;const i=Math.floor(o/60);return i<60?`${i}m ${o%60}s`:`${Math.floor(i/60)}h ${i%60}m`}function DM(n){const e=B.c(3),[t,s]=y.useState(LM);let o,i;return e[0]!==n?(o=()=>{if(s(Date.now()),!n)return;const a=window.setInterval(()=>s(Date.now()),1e3);return()=>window.clearInterval(a)},i=[n],e[0]=n,e[1]=o,e[2]=i):(o=e[1],i=e[2]),y.useEffect(o,i),t}function LM(){return Date.now()}function of(n){if(!n)return null;try{return new URL(n).host}catch{return null}}function id(n){return n.commitMessage.split(`
|
|
127
|
+
`)[0]||of(n.url)||`${sf(n.state)} deployment`}function zM(n){return[n.errorCode,n.errorMessage].filter(Boolean).join(": ")||null}function Bb(n){const e=B.c(12),{state:t,className:s}=n;let o;e[0]!==t?(o=sf(t),e[0]=t,e[1]=o):o=e[1];const i=o;let a,l,c;if(e[2]!==s||e[3]!==i||e[4]!==t){c=Symbol.for("react.early_return_sentinel");e:{const u=G("size-3.5 shrink-0",s);if(t==="BUILDING"){c=r.jsx(st,{className:G(u,"text-info"),"aria-label":i});break e}if(t==="INITIALIZING"||t==="QUEUED"){c=r.jsx(Lr,{className:G(u,"text-info"),"aria-label":i});break e}if(t==="READY"){c=r.jsx(dt,{className:G(u,"text-success"),"aria-label":i});break e}if(t==="BLOCKED"){c=r.jsx(Aw,{className:G(u,"text-destructive"),"aria-label":i});break e}a=nt,l=G(u,"text-destructive")}e[2]=s,e[3]=i,e[4]=t,e[5]=a,e[6]=l,e[7]=c}else a=e[5],l=e[6],c=e[7];if(c!==Symbol.for("react.early_return_sentinel"))return c;let d;return e[8]!==a||e[9]!==i||e[10]!==l?(d=r.jsx(a,{className:l,"aria-label":i}),e[8]=a,e[9]=i,e[10]=l,e[11]=d):d=e[11],d}function FM(){const n=B.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("span",{className:"shrink-0 rounded-sm border border-foreground/25 px-1 font-mono text-[9px] uppercase leading-[14px] tracking-wide text-foreground/80",children:"prod"}),n[0]=e):e=n[0],e}function BM(n){return n.code==="vercel_missing"?"Install Vercel CLI on the Cogpit host, then refresh.":n.code==="vercel_cli_too_old"?"Update Vercel CLI to 50.5.1 or newer, then refresh.":n.code==="vercel_auth_required"?"Run `vercel login` on the Cogpit host, then refresh.":n.code==="vercel_project_unlinked"?"Run `vercel link` from this exact project root.":n.code==="vercel_access_denied"?"Sign in to an account with access to the linked Vercel project.":"Check the linked project and your Vercel access, then try again."}function UM(){const n=B.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs("div",{className:"flex flex-col gap-4 px-3 py-4","aria-label":"Loading Vercel deployments",children:[r.jsxs("div",{className:"flex flex-col gap-2 rounded-md border px-3 py-2.5",children:[r.jsx(ct,{className:"h-2.5 w-16"}),r.jsx(ct,{className:"h-3.5 w-3/4"}),r.jsx(ct,{className:"h-2.5 w-1/2"})]}),[0,1,2,3].map(WM)]}),n[0]=e):e=n[0],e}function WM(n){return r.jsxs("div",{className:"flex flex-col gap-2 border-l-2 border-border pl-3",children:[r.jsx(ct,{className:"h-3.5 w-4/5"}),r.jsx(ct,{className:"h-2.5 w-1/2"})]},n)}const HM={data:null,error:null,loading:!1};function qM(n){const e=B.c(5),{logs:t}=n;if(t.events.length===0){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("p",{className:"py-1 text-[11px] text-muted-foreground",children:"Vercel reported no build output."}),e[0]=i):i=e[0],i}let s;e[1]!==t.events?(s=t.events.map(KM),e[1]=t.events,e[2]=s):s=e[2];let o;return e[3]!==s?(o=r.jsx("div",{className:"max-h-64 overflow-auto rounded-md bg-muted/50 px-2 py-1.5 font-mono text-[10px] leading-4",children:s}),e[3]=s,e[4]=o):o=e[4],o}function KM(n){return r.jsxs("div",{className:G("flex gap-2",n.type==="stderr"&&"text-destructive"),children:[r.jsx("time",{className:"shrink-0 text-muted-foreground tabular-nums",dateTime:new Date(n.createdAt).toISOString(),children:new Date(n.createdAt).toLocaleTimeString([],{hour12:!1})}),r.jsx("span",{className:"min-w-0 whitespace-pre-wrap break-words",children:n.text})]},n.id)}function Dh(n){const e=B.c(6),{href:t,children:s}=n;let o;e[0]!==s?(o=r.jsx("span",{className:"truncate",children:s}),e[0]=s,e[1]=o):o=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Zt,{className:"size-3 shrink-0"}),e[2]=i):i=e[2];let a;return e[3]!==t||e[4]!==o?(a=r.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"inline-flex min-w-0 items-center gap-0.5 text-[11px] text-muted-foreground outline-none hover:text-foreground focus-visible:underline",children:[o,i]}),e[3]=t,e[4]=o,e[5]=a):a=e[5],a}function VM(n){const e=B.c(106),{deployment:t,projectPath:s,now:o}=n,[i,a]=y.useState(!1),[l,c]=y.useState(HM);let d;e[0]!==t.state?(d=zb(t.state),e[0]=t.state,e[1]=d):d=e[1];const u=d;let f;e[2]!==t||e[3]!==o?(f=OM(t,o),e[2]=t,e[3]=o,e[4]=f):f=e[4];const m=f;let p;e[5]!==t?(p=id(t),e[5]=t,e[6]=p):p=e[6];const h=p;let g;e[7]!==t?(g=zM(t),e[7]=t,e[8]=g):g=e[8];const x=g;let b;e[9]!==t.url?(b=of(t.url),e[9]=t.url,e[10]=b):b=e[10];const w=b;let v;e[11]!==t.id||e[12]!==l.loading||e[13]!==s?(v=async function(){if(!l.loading){c(GM);try{const le=await IM(s,t.id);c({data:le,error:null,loading:!1})}catch(le){const me=le;c({data:null,error:{error:typeof me.error=="string"?me.error:"Unable to load build output",code:me.code??"vercel_api_failed"},loading:!1})}}},e[11]=t.id,e[12]=l.loading,e[13]=s,e[14]=v):v=e[14];const S=v;let j;e[15]!==t.state||e[16]!==S||e[17]!==l.data?(j=function(le){a(le),le&&(!l.data||fi(t.state))&&S()},e[15]=t.state,e[16]=S,e[17]=l.data,e[18]=j):j=e[18];const k=j,C=MM[u];let N;e[19]!==C?(N=G("absolute inset-y-1 left-0 w-0.5 rounded-full",C),e[19]=C,e[20]=N):N=e[20];let _;e[21]!==N?(_=r.jsx("span",{"aria-hidden":!0,className:N}),e[21]=N,e[22]=_):_=e[22];let A;e[23]!==t.state?(A=sf(t.state),e[23]=t.state,e[24]=A):A=e[24];const P=`${h}: ${A}`;let T;e[25]!==t.state?(T=r.jsx(Bb,{state:t.state}),e[25]=t.state,e[26]=T):T=e[26];const E=u==="fail"&&"text-destructive";let $;e[27]!==E?($=G("min-w-0 flex-1 truncate text-xs font-medium",E),e[27]=E,e[28]=$):$=e[28];let I;e[29]!==$||e[30]!==h?(I=r.jsx("span",{className:$,children:h}),e[29]=$,e[30]=h,e[31]=I):I=e[31];let R;e[32]!==t?(R=Io(t)&&r.jsx(FM,{}),e[32]=t,e[33]=R):R=e[33];let D;e[34]!==t.createdAt||e[35]!==o?(D=Fb(t.createdAt,o),e[34]=t.createdAt,e[35]=o,e[36]=D):D=e[36];let O;e[37]!==D?(O=r.jsx("span",{className:"w-7 shrink-0 text-right font-mono text-[10px] text-muted-foreground tabular-nums",children:D}),e[37]=D,e[38]=O):O=e[38];let M;e[39]!==T||e[40]!==I||e[41]!==R||e[42]!==O?(M=r.jsxs("span",{className:"flex w-full min-w-0 items-center gap-2",children:[T,I,R,O]}),e[39]=T,e[40]=I,e[41]=R,e[42]=O,e[43]=M):M=e[43];let F;e[44]!==t.branch?(F=t.branch&&r.jsx("span",{className:"min-w-0 truncate",children:t.branch}),e[44]=t.branch,e[45]=F):F=e[45];let z;e[46]!==t.commitSha?(z=t.commitSha&&r.jsx("span",{className:"shrink-0",children:t.commitSha.slice(0,7)}),e[46]=t.commitSha,e[47]=z):z=e[47];let L;e[48]!==t.branch||e[49]!==t.commitSha?(L=!t.branch&&!t.commitSha&&r.jsx("span",{className:"min-w-0 truncate",children:"deployed from CLI"}),e[48]=t.branch,e[49]=t.commitSha,e[50]=L):L=e[50];let W;e[51]===Symbol.for("react.memo_cache_sentinel")?(W=r.jsx("span",{className:"min-w-0 flex-1"}),e[51]=W):W=e[51];let U;e[52]!==m||e[53]!==u?(U=m&&r.jsx("span",{className:G("shrink-0 tabular-nums",u==="live"&&"text-info"),children:m}),e[52]=m,e[53]=u,e[54]=U):U=e[54];let H;e[55]!==F||e[56]!==z||e[57]!==L||e[58]!==U?(H=r.jsxs("span",{className:"flex w-full min-w-0 items-center gap-2 pl-[22px] font-mono text-[10px] leading-4 text-muted-foreground",children:[F,z,L,W,U]}),e[55]=F,e[56]=z,e[57]=L,e[58]=U,e[59]=H):H=e[59];let K;e[60]!==x?(K=x&&r.jsx("span",{className:"w-full min-w-0 truncate pl-[22px] text-[11px] leading-4 text-destructive",title:x,children:x}),e[60]=x,e[61]=K):K=e[61];let V;e[62]!==i||e[63]!==P||e[64]!==M||e[65]!==H||e[66]!==K?(V=r.jsxs(Rt,{className:"flex min-w-0 flex-1 flex-col gap-0.5 rounded-sm px-1 py-1 text-left outline-none hover:bg-accent/60 focus-visible:ring-[3px] focus-visible:ring-ring/20","aria-label":P,"aria-expanded":i,children:[M,H,K]}),e[62]=i,e[63]=P,e[64]=M,e[65]=H,e[66]=K,e[67]=V):V=e[67];let Y;e[68]!==t.url||e[69]!==h?(Y=t.url&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",className:"mt-0.5 size-6 text-muted-foreground opacity-0 transition-opacity group-hover/deployment:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100","aria-label":`Open ${h}`,onClick:()=>window.open(t.url??"","_blank","noopener,noreferrer"),children:r.jsx(Zt,{})}),e[68]=t.url,e[69]=h,e[70]=Y):Y=e[70];let q;e[71]!==V||e[72]!==Y?(q=r.jsxs("div",{className:"flex items-start gap-1",children:[V,Y]}),e[71]=V,e[72]=Y,e[73]=q):q=e[73];let J;e[74]!==t.url||e[75]!==w?(J=t.url&&w&&r.jsx(Dh,{href:t.url,children:w}),e[74]=t.url,e[75]=w,e[76]=J):J=e[76];let Q;e[77]!==t.inspectorUrl?(Q=t.inspectorUrl&&r.jsx(Dh,{href:t.inspectorUrl,children:"Inspect on Vercel"}),e[77]=t.inspectorUrl,e[78]=Q):Q=e[78];let X;e[79]!==t.creator?(X=t.creator&&r.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["by ",t.creator]}),e[79]=t.creator,e[80]=X):X=e[80];let Z;e[81]!==J||e[82]!==Q||e[83]!==X?(Z=r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1",children:[J,Q,X]}),e[81]=J,e[82]=Q,e[83]=X,e[84]=Z):Z=e[84];let te;e[85]!==l.data||e[86]!==l.loading?(te=l.loading&&!l.data&&r.jsxs("div",{className:"flex items-center gap-2 py-1 text-[11px] text-muted-foreground",role:"status",children:[r.jsx(st,{className:"size-3"}),"Loading build output"]}),e[85]=l.data,e[86]=l.loading,e[87]=te):te=e[87];let ne;e[88]!==l.error?(ne=l.error&&r.jsx("p",{className:"text-[11px] text-destructive",children:l.error.error}),e[88]=l.error,e[89]=ne):ne=e[89];let oe;e[90]!==l.data?(oe=l.data&&r.jsx(qM,{logs:l.data}),e[90]=l.data,e[91]=oe):oe=e[91];let re;e[92]!==Z||e[93]!==te||e[94]!==ne||e[95]!==oe?(re=r.jsx(mt,{children:r.jsxs("div",{className:"ml-[7px] flex flex-col gap-2 border-l border-border py-2 pl-4 pr-1",children:[Z,te,ne,oe]})}),e[92]=Z,e[93]=te,e[94]=ne,e[95]=oe,e[96]=re):re=e[96];let ae;e[97]!==_||e[98]!==q||e[99]!==re||e[100]!==h?(ae=r.jsxs("article",{className:"group/deployment relative pl-3","aria-label":h,children:[_,q,re]}),e[97]=_,e[98]=q,e[99]=re,e[100]=h,e[101]=ae):ae=e[101];let se;return e[102]!==k||e[103]!==i||e[104]!==ae?(se=r.jsx(ft,{open:i,onOpenChange:k,children:ae}),e[102]=k,e[103]=i,e[104]=ae,e[105]=se):se=e[105],se}function GM(n){return{...n,error:null,loading:!0}}function YM(n){const e=n.filter(Io),t=e.find(i=>i.state==="READY")??null,s=e[0]??null,o=s&&s!==t&&s.state!=="READY"?s:null;return{live:t,pending:o}}function XM(n){const e=B.c(11),{deployments:t,now:s}=n;let o,i;if(e[0]!==t||e[1]!==s){i=Symbol.for("react.early_return_sentinel");e:{const{live:a,pending:l}=YM(t),c=a??l;if(!c){i=null;break e}const d=id(c),u=of(c.url),f=l?zb(l.state):null,m=a?"border-success/30 bg-success/[0.05]":"border-destructive/30 bg-destructive/[0.05]";let p;e[4]!==m?(p=G("mx-3 mt-3 rounded-md border px-3 py-2.5",m),e[4]=m,e[5]=p):p=e[5];const h=a?"bg-success":"bg-destructive";let g;e[6]!==h?(g=G("size-1.5 rounded-full",h),e[6]=h,e[7]=g):g=e[7];let x;e[8]!==g?(x=r.jsx("span",{"aria-hidden":!0,className:g}),e[8]=g,e[9]=x):x=e[9];let b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx("span",{className:"min-w-0 flex-1"}),e[10]=b):b=e[10],o=r.jsxs("section",{"aria-label":"Production",className:p,children:[r.jsxs("p",{className:"mb-1 flex items-center gap-1.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:[x,a?"Live on production":"Production is down",r.jsx("span",{className:"ml-auto font-mono normal-case tracking-normal tabular-nums",children:Fb(c.readyAt??c.createdAt,s)})]}),r.jsx("h3",{className:"truncate text-[13px] font-medium leading-5",title:d,children:d}),r.jsxs("p",{className:"mt-0.5 flex min-w-0 items-center gap-2 font-mono text-[10px] text-muted-foreground",children:[c.branch&&r.jsx("span",{className:"truncate",children:c.branch}),c.commitSha&&r.jsx("span",{className:"shrink-0",children:c.commitSha.slice(0,7)}),b,c.url&&u&&r.jsxs("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex min-w-0 max-w-[60%] items-center gap-0.5 font-sans text-[11px] text-foreground/80 outline-none hover:text-foreground focus-visible:underline",children:[r.jsx("span",{className:"truncate",children:u}),r.jsx(Zt,{className:"size-3 shrink-0"})]})]}),a&&l&&f&&r.jsxs("p",{className:G("mt-1.5 flex items-center gap-1.5 border-t border-border/60 pt-1.5 text-[11px]",f==="fail"?"text-destructive":"text-info"),children:[r.jsx(Bb,{state:l.state,className:"size-3"}),r.jsxs("span",{className:"min-w-0 truncate",children:[f==="fail"?"Newer production deploy failed":"Newer production deploy in progress"," · ",id(l)]})]})]})}e[0]=t,e[1]=s,e[2]=o,e[3]=i}else o=e[2],i=e[3];return i!==Symbol.for("react.early_return_sentinel")?i:o}function JM(n,e){return e==="failed"?n.filter(t=>bl(t.state)):e==="production"?n.filter(Io):e==="preview"?n.filter(t=>!Io(t)):[...n]}function QM(n){const e=B.c(17),{data:t,filter:s,projectPath:o}=n;let i;e[0]!==t.deployments||e[1]!==s?(i=JM(t.deployments,s),e[0]=t.deployments,e[1]=s,e[2]=i):i=e[2];const a=i;let l;e[3]!==t.deployments?(l=t.deployments.some(ZM),e[3]=t.deployments,e[4]=l):l=e[4];const c=DM(l);if(t.deployments.length===0){let m;return e[5]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(ln,{className:"border-0",children:r.jsxs(cn,{children:[r.jsx(bn,{variant:"icon",children:r.jsx(K1,{})}),r.jsx(dn,{children:"No deployments yet"}),r.jsx(vn,{children:"New Vercel deployments for this linked project will show up here."})]})}),e[5]=m):m=e[5],m}let d;e[6]!==t.deployments||e[7]!==c?(d=r.jsx(XM,{deployments:t.deployments,now:c}),e[6]=t.deployments,e[7]=c,e[8]=d):d=e[8];let u;e[9]!==a||e[10]!==s||e[11]!==c||e[12]!==o?(u=a.length===0?r.jsxs("p",{className:"px-4 py-6 text-center text-xs text-muted-foreground",children:["No recent ",s," deployments."]}):r.jsx("div",{className:"flex flex-col gap-3 px-3 py-3",children:a.map(m=>r.jsx(VM,{deployment:m,projectPath:o,now:c},m.id))}),e[9]=a,e[10]=s,e[11]=c,e[12]=o,e[13]=u):u=e[13];let f;return e[14]!==d||e[15]!==u?(f=r.jsxs(qn,{className:"min-h-0 flex-1",children:[d,u]}),e[14]=d,e[15]=u,e[16]=f):f=e[16],f}function ZM(n){return fi(n.state)}function eO(n){const e=B.c(6),{context:t}=n,{data:s}=Lb(t.projectPath,t.projectPath!==null);let o;e[0]!==(s==null?void 0:s.deployments)?(o=(s==null?void 0:s.deployments.filter(tO).length)??0,e[0]=s==null?void 0:s.deployments,e[1]=o):o=e[1];const i=o,a=s!=null&&s.deployments[0]?bl(s.deployments[0].state):!1;if(i>0){const l=`${i} active Vercel deployment${i===1?"":"s"}`;let c;return e[2]!==i||e[3]!==l?(c=r.jsx(Pe,{className:"absolute -right-1 -top-1 min-w-4 px-1 text-[9px]","aria-label":l,children:i}),e[2]=i,e[3]=l,e[4]=c):c=e[4],c}if(a){let l;return e[5]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Pe,{variant:"destructive",className:"absolute -right-0.5 -top-0.5 size-3 p-0 text-[8px]","aria-label":"Latest Vercel deployment failed",children:"!"}),e[5]=l):l=e[5],l}return null}function tO(n){return fi(n.state)}function nO(n){const e=B.c(57),{context:t,active:s,closePanel:o}=n,{data:i,error:a,loading:l,refreshing:c,refresh:d}=Lb(t.projectPath,s),[u,f]=y.useState("all"),m=t.projectPath;let p;e[0]!==(i==null?void 0:i.deployments)?(p=(i==null?void 0:i.deployments)??[],e[0]=i==null?void 0:i.deployments,e[1]=p):p=e[1];const h=p,g=h.length;let x;e[2]!==h?(x=h.filter(Io),e[2]=h,e[3]=x):x=e[3];const b=x.length;let w;e[4]!==h?(w=h.filter(oO),e[4]=h,e[5]=w):w=e[5];const v=w.length;let S;e[6]!==h?(S=h.filter(sO),e[6]=h,e[7]=S):S=e[7];let j;e[8]!==h.length||e[9]!==x.length||e[10]!==w.length||e[11]!==S.length?(j={all:g,production:b,preview:v,failed:S.length},e[8]=h.length,e[9]=x.length,e[10]=w.length,e[11]=S.length,e[12]=j):j=e[12];const k=j,C=u!=="all"&&k[u]===0?"all":u;let N;e[13]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx("h2",{className:"text-sm font-medium leading-tight",children:"Vercel Deployments"}),e[13]=N):N=e[13];let _;e[14]!==i?(_=r.jsxs("div",{className:"min-w-0 flex-1",children:[N,i!=null&&i.projectUrl?r.jsxs("a",{href:i.projectUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex max-w-full items-center gap-0.5 truncate text-[11px] text-muted-foreground outline-none hover:text-foreground focus-visible:underline",children:[r.jsx("span",{className:"truncate",children:i.projectName}),r.jsx(Zt,{className:"size-3 shrink-0"})]}):r.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:"Project linked at the session root"})]}),e[14]=i,e[15]=_):_=e[15];let A;e[16]!==d?(A=()=>{d()},e[16]=d,e[17]=A):A=e[17];const P=l||c||!m;let T;e[18]!==c?(T=c?r.jsx(st,{}):r.jsx(Pt,{}),e[18]=c,e[19]=T):T=e[19];let E;e[20]!==A||e[21]!==P||e[22]!==T?(E=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:A,disabled:P,"aria-label":"Refresh Vercel deployments",children:T}),e[20]=A,e[21]=P,e[22]=T,e[23]=E):E=e[23];let $;e[24]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx(nt,{}),e[24]=$):$=e[24];let I;e[25]!==o?(I=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:o,"aria-label":"Close Vercel deployments",children:$}),e[25]=o,e[26]=I):I=e[26];let R;e[27]!==_||e[28]!==E||e[29]!==I?(R=r.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b pl-4 pr-2",children:[_,E,I]}),e[27]=_,e[28]=E,e[29]=I,e[30]=R):R=e[30];let D;e[31]!==k||e[32]!==i||e[33]!==C?(D=i&&i.deployments.length>0&&r.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b px-3 py-1.5",role:"group","aria-label":"Filter deployments",children:[r.jsxs(yt,{pressed:C==="all",onClick:()=>f("all"),children:["All ",r.jsx(wt,{children:k.all})]}),r.jsxs(yt,{pressed:C==="production",disabled:k.production===0,onClick:()=>f("production"),children:["Production ",r.jsx(wt,{children:k.production})]}),r.jsxs(yt,{pressed:C==="preview",disabled:k.preview===0,onClick:()=>f("preview"),children:["Preview ",r.jsx(wt,{children:k.preview})]}),r.jsxs(yt,{pressed:C==="failed",disabled:k.failed===0,onClick:()=>f("failed"),children:[r.jsx("span",{className:G(k.failed>0&&"text-destructive"),children:"Failed"})," ",r.jsx(wt,{children:k.failed})]})]}),e[31]=k,e[32]=i,e[33]=C,e[34]=D):D=e[34];let O;e[35]!==i||e[36]!==l?(O=l&&!i&&r.jsx(UM,{}),e[35]=i,e[36]=l,e[37]=O):O=e[37];let M;e[38]!==i||e[39]!==a||e[40]!==d?(M=a&&!i&&r.jsx("div",{className:"p-3",children:r.jsxs(pt,{variant:"destructive",children:[r.jsx(Yt,{}),r.jsx(Et,{children:a.error}),r.jsxs(ht,{className:"flex flex-col items-start gap-2",children:[r.jsx("span",{children:BM(a)}),r.jsxs(ee,{type:"button",variant:"outline",size:"xs",onClick:()=>{d()},children:[r.jsx(Pt,{"data-icon":"inline-start"}),"Try again"]})]})]})}),e[38]=i,e[39]=a,e[40]=d,e[41]=M):M=e[41];let F;e[42]!==i||e[43]!==C||e[44]!==m?(F=i&&m&&r.jsx(QM,{data:i,filter:C,projectPath:m}),e[42]=i,e[43]=C,e[44]=m,e[45]=F):F=e[45];let z;e[46]!==i||e[47]!==a||e[48]!==l?(z=!l&&!i&&!a&&r.jsx(ln,{className:"border-0",children:r.jsxs(cn,{children:[r.jsx(bn,{variant:"icon",children:r.jsx(Gs,{})}),r.jsx(dn,{children:"Select a project session"})]})}),e[46]=i,e[47]=a,e[48]=l,e[49]=z):z=e[49];let L;return e[50]!==R||e[51]!==D||e[52]!==O||e[53]!==M||e[54]!==F||e[55]!==z?(L=r.jsxs("section",{className:"flex size-full min-h-0 flex-col","aria-label":"Vercel deployments panel",children:[R,D,O,M,F,z]}),e[50]=R,e[51]=D,e[52]=O,e[53]=M,e[54]=F,e[55]=z,e[56]=L):L=e[56],L}function sO(n){return bl(n.state)}function oO(n){return!Io(n)}const rO={id:"vercel-deployments",workspacePanels:[{id:"deployments",title:"Vercel Deployments",icon:K1,component:nO,indicator:eO,order:45,defaultSize:"42%",minSize:"380px",maxSize:"68%",when:n=>n.canAccessHostFiles&&n.projectPath!==null}]},iO=[_M,mI,rO];function aO(n,e,t){const s=B.c(16);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o={summary:null,loading:!1,error:null},s[0]=o):o=s[0];const[i,a]=y.useState(o),[l,c]=y.useState(0);let d,u;s[1]!==n||s[2]!==e?(d=()=>{a({summary:null,loading:!!(n&&e),error:null})},u=[n,e],s[1]=n,s[2]=e,s[3]=d,s[4]=u):(d=s[3],u=s[4]),y.useEffect(d,u);let f;s[5]!==n||s[6]!==e?(f=()=>{if(!n||!e)return;const x=new AbortController;a(cO);const b=new URLSearchParams({dirName:n,fileName:e});return be(`/api/usage-cost/session?${b}`,{signal:x.signal}).then(async w=>{if(!w.ok)throw new Error(`Cost scan failed (${w.status})`);const v=await w.json();a({summary:v,loading:!1,error:null})}).catch(w=>{x.signal.aborted||a(v=>({...v,loading:!1,error:w instanceof Error?w.message:"Cost scan failed"}))}),()=>x.abort()},s[5]=n,s[6]=e,s[7]=f):f=s[7];let m;s[8]!==n||s[9]!==e||s[10]!==l||s[11]!==t?(m=[n,e,l,t],s[8]=n,s[9]=e,s[10]=l,s[11]=t,s[12]=m):m=s[12],y.useEffect(f,m);let p;s[13]===Symbol.for("react.memo_cache_sentinel")?(p=()=>c(lO),s[13]=p):p=s[13];const h=p;let g;return s[14]!==i?(g={...i,refresh:h},s[14]=i,s[15]=g):g=s[15],g}function lO(n){return n+1}function cO(n){return{...n,loading:!0,error:null}}function dO(n){return n.records===0?"No usage":n.unpricedRecords===n.records?"Rates unavailable":n.unpricedRecords>0?"Partial estimate":n.providerReportedRecords===n.records?"Provider reported":n.providerReportedRecords>0?"Transcript + API rates":"Current API rates"}function uO(n){return[{label:"New input",tokens:n.totals.uncachedInputTokens,costUsd:n.breakdown.uncachedInputUsd},{label:"Cache reads",tokens:n.totals.cachedInputTokens,costUsd:n.breakdown.cachedInputUsd},{label:"Cache writes",tokens:n.totals.cacheCreationTokens,costUsd:n.breakdown.cacheCreationUsd},{label:"Output",tokens:n.totals.outputTokens,costUsd:n.breakdown.outputUsd},{label:"Provider total",tokens:0,costUsd:n.breakdown.unallocatedUsd}].filter(e=>e.tokens>0||e.costUsd>0)}function fO(){const n=B.c(3);let e,t;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx(ct,{className:"h-4 w-24"}),r.jsx(ct,{className:"h-10 w-32"}),r.jsx(ct,{className:"h-3 w-44"})]}),t=r.jsx(ct,{className:"h-20 w-full"}),n[0]=e,n[1]=t):(e=n[0],t=n[1]);let s;return n[2]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsxs("div",{className:"flex flex-col gap-5 pt-2",role:"status","aria-label":"Reading session cost",children:[e,t,r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx(ct,{className:"h-8 w-full"}),r.jsx(ct,{className:"h-8 w-full"}),r.jsx(ct,{className:"h-8 w-full"})]})]}),n[2]=s):s=n[2],s}function mO(n){const e=B.c(10),{message:t,retry:s}=n;let o,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(hd,{}),i=r.jsx(Et,{children:"Cost unavailable"}),e[0]=o,e[1]=i):(o=e[0],i=e[1]);let a;e[2]!==t?(a=r.jsx(ht,{children:t}),e[2]=t,e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Pt,{"data-icon":"inline-start"}),e[4]=l):l=e[4];let c;e[5]!==s?(c=r.jsxs(ee,{variant:"outline",size:"xs",onClick:s,className:"mt-2",children:[l,"Retry"]}),e[5]=s,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=r.jsxs(pt,{variant:"destructive",className:"mt-2",children:[o,i,a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d}function Fi(n){const e=B.c(7),{label:t,value:s}=n;let o;e[0]!==t?(o=r.jsx("dt",{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("dd",{className:"truncate 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 pO(n){const e=B.c(22),{row:t,totalCost:s}=n,o=s>0?t.costUsd/s*100:0;let i;e[0]!==t.label?(i=r.jsx(Kg,{children:t.label}),e[0]=t.label,e[1]=i):i=e[1];let a;e[2]!==t.costUsd?(a=r.jsx(Vg,{children:()=>pn(t.costUsd)}),e[2]=t.costUsd,e[3]=a):a=e[3];let l;e[4]!==o||e[5]!==i||e[6]!==a?(l=r.jsxs(Yr,{value:o,children:[i,a]}),e[4]=o,e[5]=i,e[6]=a,e[7]=l):l=e[7];let c;e[8]!==t.tokens?(c=t.tokens>0?ut(t.tokens):"Reported by provider",e[8]=t.tokens,e[9]=c):c=e[9];let d;e[10]!==c?(d=r.jsx("span",{children:c}),e[10]=c,e[11]=d):d=e[11];let u;e[12]!==o?(u=o>0?`${o.toFixed(1)}%`:"—",e[12]=o,e[13]=u):u=e[13];let f;e[14]!==u?(f=r.jsx("span",{children:u}),e[14]=u,e[15]=f):f=e[15];let m;e[16]!==d||e[17]!==f?(m=r.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs text-muted-foreground tabular-nums",children:[d,f]}),e[16]=d,e[17]=f,e[18]=m):m=e[18];let p;return e[19]!==l||e[20]!==m?(p=r.jsxs("div",{className:"flex flex-col gap-1.5",children:[l,m]}),e[19]=l,e[20]=m,e[21]=p):p=e[21],p}function hO(n){const e=B.c(8),{summary:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx("h3",{id:"cost-models-heading",className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"By model"}),e[0]=s):s=e[0];let o;if(e[1]!==t.costUsd||e[2]!==t.models){let a;e[4]!==t.costUsd?(a=l=>{const c=t.costUsd>0?l.costUsd/t.costUsd*100:0;return r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsxs(Yr,{value:c,children:[r.jsx(Kg,{title:l.model,children:Js(l.model)}),r.jsx(Vg,{children:()=>l.costSource==="unpriced"?"Unpriced":pn(l.costUsd)})]}),r.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs text-muted-foreground tabular-nums",children:[r.jsxs("span",{children:[l.records," ",l.records===1?"call":"calls"]}),r.jsxs("span",{children:[ut(Ku(l.totals))," tokens"]})]})]},l.model)},e[4]=t.costUsd,e[5]=a):a=e[5],o=t.models.map(a),e[1]=t.costUsd,e[2]=t.models,e[3]=o}else o=e[3];let i;return e[6]!==o?(i=r.jsxs("section",{"aria-labelledby":"cost-models-heading",className:"flex flex-col gap-3",children:[s,r.jsx("div",{className:"flex flex-col gap-3",children:o})]}),e[6]=o,e[7]=i):i=e[7],i}function gO(n){return n.map((e,t)=>({...e,call:t+1})).filter(e=>e.costSource!=="unpriced").sort((e,t)=>t.costUsd-e.costUsd).slice(0,5)}function xO(n){const e=B.c(5),{rows:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx("h3",{id:"cost-calls-heading",className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Most expensive calls"}),e[0]=s):s=e[0];let o;e[1]!==t?(o=t.map(bO),e[1]=t,e[2]=o):o=e[2];let i;return e[3]!==o?(i=r.jsxs("section",{"aria-labelledby":"cost-calls-heading",className:"flex flex-col gap-2",children:[s,r.jsx("ol",{className:"flex flex-col gap-0.5",children:o})]}),e[3]=o,e[4]=i):i=e[4],i}function bO(n){return r.jsxs("li",{className:"flex items-center gap-2 rounded-md px-2 py-1.5 hover:bg-muted/50",children:[r.jsxs("span",{className:"min-w-0 flex-1 truncate text-xs text-foreground",children:["Call ",n.call," · ",Js(n.model)]}),n.isSubagent&&r.jsx(Pe,{variant:"outline",children:"Agent"}),r.jsx("span",{className:"shrink-0 font-mono text-xs text-foreground tabular-nums",children:pn(n.costUsd)})]},`${n.timestamp}:${n.call}`)}function vO(n){const e=B.c(74),{summary:t}=n;let s;e[0]!==t.provider?(s=P4(t.provider),e[0]=t.provider,e[1]=s):s=e[1];const o=s;let i,a,l,c,d,u;if(e[2]!==o||e[3]!==t){const g=Ku(t.totals),x=uO(t);let b;e[10]!==t.calls?(b=gO(t.calls),e[10]=t.calls,e[11]=b):b=e[11],u=b;const w=t.providerReportedRecords+t.modelPricedRecords>0;i="flex flex-col gap-5 pt-2";let v;e[12]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx("p",{id:"session-cost-heading",className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"API equivalent"}),e[12]=v):v=e[12];let S;e[13]!==o?(S=r.jsx(o,{"aria-hidden":"true"}),e[13]=o,e[14]=S):S=e[14];let j;e[15]!==t.provider?(j=en(t.provider),e[15]=t.provider,e[16]=j):j=e[16];let k;e[17]!==j.displayName||e[18]!==S?(k=r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[v,r.jsxs(Pe,{variant:"outline",children:[S,j.displayName]})]}),e[17]=j.displayName,e[18]=S,e[19]=k):k=e[19];let C;e[20]!==w||e[21]!==t.costUsd?(C=w?pn(t.costUsd):"—",e[20]=w,e[21]=t.costUsd,e[22]=C):C=e[22];let N;e[23]!==C?(N=r.jsx("span",{className:"text-4xl font-semibold tracking-tight text-foreground tabular-nums",children:C}),e[23]=C,e[24]=N):N=e[24];const _=t.unpricedRecords>0?"secondary":"outline";let A;e[25]!==t?(A=dO(t),e[25]=t,e[26]=A):A=e[26];let P;e[27]!==_||e[28]!==A?(P=r.jsx(Pe,{variant:_,children:A}),e[27]=_,e[28]=A,e[29]=P):P=e[29];let T;e[30]!==N||e[31]!==P?(T=r.jsxs("div",{className:"flex items-end justify-between gap-3",children:[N,P]}),e[30]=N,e[31]=P,e[32]=T):T=e[32];const E=t.records===1?"model call":"model calls",$=t.includedSubagents>0?` · ${t.includedSubagents} agent ${t.includedSubagents===1?"transcript":"transcripts"}`:"";let I;e[33]!==t.records||e[34]!==E||e[35]!==$?(I=r.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.records," ",E,$]}),e[33]=t.records,e[34]=E,e[35]=$,e[36]=I):I=e[36],e[37]!==k||e[38]!==T||e[39]!==I?(a=r.jsxs("section",{"aria-labelledby":"session-cost-heading",className:"flex flex-col gap-2",children:[k,T,I]}),e[37]=k,e[38]=T,e[39]=I,e[40]=a):a=e[40],e[41]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Nt,{}),e[41]=l):l=e[41];const R=ut(g);let D;e[42]!==R?(D=r.jsx(Fi,{label:"Processed tokens",value:R}),e[42]=R,e[43]=D):D=e[43];let O;e[44]!==t.cacheSavingsUsd?(O=pn(t.cacheSavingsUsd),e[44]=t.cacheSavingsUsd,e[45]=O):O=e[45];let M;e[46]!==O?(M=r.jsx(Fi,{label:"Cache savings",value:O}),e[46]=O,e[47]=M):M=e[47];let F;e[48]!==t.totals.cachedInputTokens?(F=ut(t.totals.cachedInputTokens),e[48]=t.totals.cachedInputTokens,e[49]=F):F=e[49];let z;e[50]!==F?(z=r.jsx(Fi,{label:"Cached input",value:F}),e[50]=F,e[51]=z):z=e[51];let L;e[52]!==t.totals.reasoningTokens?(L=ut(t.totals.reasoningTokens),e[52]=t.totals.reasoningTokens,e[53]=L):L=e[53];let W;e[54]!==L?(W=r.jsx(Fi,{label:"Reasoning",value:L}),e[54]=L,e[55]=W):W=e[55],e[56]!==D||e[57]!==M||e[58]!==z||e[59]!==W?(c=r.jsxs("dl",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:[D,M,z,W]}),e[56]=D,e[57]=M,e[58]=z,e[59]=W,e[60]=c):c=e[60],d=x.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(Nt,{}),r.jsxs("section",{"aria-labelledby":"cost-breakdown-heading",className:"flex flex-col gap-3",children:[r.jsx("h3",{id:"cost-breakdown-heading",className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Cost by token type"}),r.jsx("div",{className:"flex flex-col gap-4",children:x.map(U=>r.jsx(pO,{row:U,totalCost:t.costUsd},U.label))})]})]}),e[2]=o,e[3]=t,e[4]=i,e[5]=a,e[6]=l,e[7]=c,e[8]=d,e[9]=u}else i=e[4],a=e[5],l=e[6],c=e[7],d=e[8],u=e[9];let f;e[61]!==t?(f=t.models.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(Nt,{}),r.jsx(hO,{summary:t})]}),e[61]=t,e[62]=f):f=e[62];let m;e[63]!==u?(m=u.length>=2&&r.jsxs(r.Fragment,{children:[r.jsx(Nt,{}),r.jsx(xO,{rows:u})]}),e[63]=u,e[64]=m):m=e[64];let p;e[65]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsxs(pt,{children:[r.jsx(hd,{}),r.jsx(Et,{children:"How this is calculated"}),r.jsx(ht,{children:"Token counts come from the provider transcript. Costs use provider totals when present, then current LiteLLM API rates, the same pricing source as ccusage. This is not a subscription bill."})]}),e[65]=p):p=e[65];let h;return e[66]!==i||e[67]!==a||e[68]!==l||e[69]!==c||e[70]!==d||e[71]!==f||e[72]!==m?(h=r.jsxs("div",{className:i,children:[a,l,c,d,f,m,p]}),e[66]=i,e[67]=a,e[68]=l,e[69]=c,e[70]=d,e[71]=f,e[72]=m,e[73]=h):h=e[73],h}function yO(n){const e=B.c(7),{dirName:t,fileName:s,revision:o}=n,{summary:i,loading:a,error:l,refresh:c}=aO(t,s,o);if(l){let u;return e[0]!==l||e[1]!==c?(u=r.jsx(mO,{message:l,retry:c}),e[0]=l,e[1]=c,e[2]=u):u=e[2],u}if(!i){if(a){let f;return e[3]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(fO,{}),e[3]=f):f=e[3],f}let u;return e[4]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(ln,{className:"mt-2 min-h-52",children:r.jsxs(cn,{children:[r.jsx(bn,{variant:"icon",children:r.jsx(Pw,{})}),r.jsx(dn,{children:"No transcript cost yet"}),r.jsx(vn,{children:"Cost appears after the first model response is written."})]})}),e[4]=u):u=e[4],u}let d;return e[5]!==i?(d=r.jsx(vO,{summary:i}),e[5]=i,e[6]=d):d=e[6],d}function wO(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 jO(n){const e=B.c(14),{turns:t,onJumpToTurn:s}=n;let o;e[0]!==t?(o=wO(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(Xr,{children:["Errors (",i.length,")"]}),e[2]=i.length,e[3]=a):a=e[3];let l;if(e[4]!==i||e[5]!==s){let u;e[7]!==s?(u=(f,m)=>r.jsxs(ee,{type:"button",variant:"ghost",onClick:()=>s==null?void 0:s(f.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:f.toolName}),r.jsxs("span",{className:"text-muted-foreground",children:["Turn ",f.turnIndex+1]})]}),r.jsx("div",{className:"mt-0.5 line-clamp-2 text-xs leading-relaxed text-muted-foreground",children:f.message})]},m),e[7]=s,e[8]=u):u=e[8],l=i.map(u),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 Lh(n){const e=B.c(42),{agentId:t,subagentType:s,agentName:o,preview:i,isViewing:a,isBackground:l,status:c,durationMs:d,toolUseCount:u,disabled:f,onClick:m,onStop:p}=n;let h;e[0]!==t||e[1]!==o||e[2]!==s?(h=o||Tu(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 b=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(Wn,{className:"size-3 shrink-0 text-success","data-icon":"inline-start"}):c==="failed"?r.jsx(Ys,{className:"size-3 shrink-0 text-destructive","data-icon":"inline-start"}):r.jsx(Pa,{className:"size-2.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),e[6]=c,e[7]=w):w=e[7];const v=w,S=a?"bg-accent":"hover:bg-muted/40";let j;e[8]!==S?(j=G("motion-list-item flex w-full items-start border-b border-border text-left transition-colors last:border-b-0",S),e[8]=S,e[9]=j):j=e[9];let k;e[10]!==g?(k=r.jsx(Pe,{variant:"outline",children:g}),e[10]=g,e[11]=k):k=e[11];let C;e[12]!==l?(C=l&&r.jsx(Pe,{variant:"outline",children:"Background"}),e[12]=l,e[13]=C):C=e[13];let N;e[14]!==a?(N=a&&r.jsx(Pe,{children:"Viewing"}),e[14]=a,e[15]=N):N=e[15];const _=c==="running"?"active":c;let A;e[16]!==_?(A=r.jsx("span",{className:"ml-auto text-xs uppercase tracking-wide text-muted-foreground",children:_}),e[16]=_,e[17]=A):A=e[17];let P;e[18]!==v||e[19]!==A||e[20]!==k||e[21]!==C||e[22]!==N?(P=r.jsxs("div",{className:"flex items-center gap-1.5",children:[v,k,C,N,A]}),e[18]=v,e[19]=A,e[20]=k,e[21]=C,e[22]=N,e[23]=P):P=e[23];let T;e[24]!==i?(T=i&&r.jsx("p",{className:"mt-1 line-clamp-2 text-xs leading-relaxed text-muted-foreground",children:i}),e[24]=i,e[25]=T):T=e[25];let E;e[26]!==b||e[27]!==u?(E=(b||u!=null)&&r.jsxs("div",{className:"mt-1.5 flex items-center gap-2 text-xs text-muted-foreground",children:[b&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(Lr,{className:"size-2.5","data-icon":"inline-start"}),b]}),u!=null&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(_a,{className:"size-2.5","data-icon":"inline-start"}),u," tools"]})]}),e[26]=b,e[27]=u,e[28]=E):E=e[28];let $;e[29]!==f||e[30]!==m||e[31]!==P||e[32]!==T||e[33]!==E?($=r.jsxs(ee,{type:"button",variant:"ghost",onClick:m,disabled:f,className:"h-auto min-w-0 flex-1 flex-col items-stretch rounded-none px-2.5 py-2 text-left whitespace-normal",children:[P,T,E]}),e[29]=f,e[30]=m,e[31]=P,e[32]=T,e[33]=E,e[34]=$):$=e[34];let I;e[35]!==g||e[36]!==p?(I=p&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",className:"m-1",onClick:p,"aria-label":`Stop ${g}`,children:r.jsx(nt,{"data-icon":"inline-start"})}),e[35]=g,e[36]=p,e[37]=I):I=e[37];let R;return e[38]!==$||e[39]!==I||e[40]!==j?(R=r.jsxs("div",{className:j,children:[$,I]}),e[38]=$,e[39]=I,e[40]=j,e[41]=R):R=e[41],R}function SO(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 ad(n){return n.split(`
|
|
128
|
+
`).map(e=>e.trim()).find(Boolean)??""}function NO(n){return n.name==="Task"||n.name==="Agent"}function kO(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),u=SO(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:ad(((i=c.prompt)==null?void 0:i.trim())||c.text.find(f=>f.trim())||"")||(d==null?void 0:d.preview)||"No task summary recorded",isBackground:c.isBackground||(d==null?void 0:d.isBackground)||!1,status:u==="seen"&&(d!=null&&d.status)?d.status:u,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(!NO(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:ad(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 CO({session:n,sessionSource:e,bgAgents:t,onLoadSession:s}){const o=ku(),i=y.useMemo(()=>{if(!e)return null;const w=Ns(e.fileName);return w?{...w,dirName:e.dirName}:null},[e]),a=y.useMemo(()=>kO(n,o),[n,o]),l=y.useRef(a);y.useEffect(()=>{!i&&a.length>0&&(l.current=a)},[i,a]);const c=i&&a.length===0?l.current:a,d=y.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]),u=y.useMemo(()=>d?t.filter(w=>w.parentSessionId===d):t,[t,d]),f=y.useMemo(()=>new Map(c.map(w=>[w.agentId,w])),[c]),m=y.useMemo(()=>{const w=new Set(u.map(v=>v.agentId));return c.filter(v=>!w.has(v.agentId))},[u,c]),p=y.useMemo(()=>[...u].sort((w,v)=>v.modifiedAt-w.modifiedAt),[u]),h=y.useMemo(()=>[...m].reverse(),[m]),g=u.length+m.length;if(g===0)return null;const x=w=>{be(`/api/claude/tasks/${encodeURIComponent(n.sessionId)}/${encodeURIComponent(w)}`,{method:"DELETE"})},b=(i==null?void 0:i.agentId)??null;return r.jsxs("section",{children:[r.jsxs(Xr,{children:["Agents (",g,")"]}),i&&s&&r.jsxs(ee,{type:"button",variant:"outline",size:"sm",onClick:()=>s(i.dirName,i.parentFileName),className:"mb-2 w-full justify-start",children:[r.jsx(Xe,{"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,v)=>{const S=ad(w.preview??""),j=f.get(w.agentId);return r.jsx(Lh,{agentId:w.agentId,subagentType:(j==null?void 0:j.subagentType)??null,agentName:(j==null?void 0:j.agentName)??null,preview:(j==null?void 0:j.preview)||(S!==w.agentId?S:""),colorIndex:v,isViewing:b===w.agentId,isBackground:!0,status:w.isActive?"running":(j==null?void 0:j.status)==="failed"?"failed":"done",durationMs:j==null?void 0:j.durationMs,toolUseCount:j==null?void 0:j.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,v)=>{const S=!!s&&!!d&&!!e&&!w.agentId.startsWith("tool:");return r.jsx(Lh,{agentId:w.agentId,subagentType:w.subagentType,agentName:w.agentName,preview:w.preview,colorIndex:p.length+v,isViewing:b===w.agentId,isBackground:w.isBackground,status:w.status,durationMs:w.durationMs,toolUseCount:w.toolUseCount,disabled:!S,onClick:()=>{S&&s(e.dirName,`${d}/subagents/agent-${w.agentId}.jsonl`)}},w.agentId)})]})]})}function _O(n,e){return`${n.id}-${e}`}function TO(n){const e=B.c(14),{turns:t,onJumpToTurn:s}=n,[o,i]=y.useState(null);if(t.length===0)return null;let a;e[0]!==t.length?(a=r.jsxs(Xr,{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 u;e[6]!==o||e[7]!==s?(u=(f,m)=>{const p=sl(f.userMessage),h=o===m;return r.jsxs(ee,{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?kn(p,50):"(no message)"}),r.jsx("span",{className:"flex shrink-0 items-center gap-1",children:f.toolCalls.length>0&&r.jsx(Pe,{variant:"secondary",className:"font-normal",children:f.toolCalls.length})})]},_O(f,m))},e[6]=o,e[7]=s,e[8]=u):u=e[8],l=t.map(u),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}const ld=new Map;let hc=null,gc=null;async function EO(){try{const n=await be("/api/usage-cost/rates");if(!n.ok)return ld;const e=await n.json();return new Map(Object.entries(e.rates??{}))}catch{return ld}}function AO(){const[n,e]=y.useState(hc??ld);return y.useEffect(()=>{if(hc!==null)return;let t=!0;return gc??(gc=EO().then(s=>(s.size>0&&(hc=s),gc=null,s))),gc.then(s=>{t&&e(s)}),()=>{t=!1}},[]),n}function PO(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"?kn(e.command,40):e.pattern&&typeof e.pattern=="string"?e.pattern:e.query&&typeof e.query=="string"?kn(e.query,40):e.url&&typeof e.url=="string"?kn(e.url,40):kn(XT(n),40)}function $O(n,e){return n.map(t=>{const s=t.tokenUsage;return!s||t.toolCalls.length===0?0:Q$(e,t.model,s)/t.toolCalls.length})}function RO(n,e){const t=new Map;for(let s=0;s<n.length;s++)for(const o of n[s].toolCalls){const i=ii(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 IO(n){const e=B.c(14),{turns:t,onJumpToTurn:s}=n,o=AO();let i;e[0]!==o||e[1]!==t?(i=$O(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=RO(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(Xr,{children:"Tool Calls"}),e[6]=d):d=e[6];let u;if(e[7]!==s||e[8]!==c){let m;e[10]!==s?(m=p=>{const[h,g]=p;return r.jsxs(ft,{children:[r.jsxs(Rt,{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(Xe,{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:pn(g.estimatedCost)}),r.jsx(Pe,{variant:"secondary",className:"font-normal",children:g.count})]})]}),r.jsx(mt,{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,b)=>{const{tc:w,turnIndex:v}=x,S=PO(w);return r.jsx("div",{children:r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>s==null?void 0:s(v,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(gn,{className:"size-2.5 shrink-0 text-destructive","data-icon":"inline-start"}),r.jsx("span",{className:"truncate",children:S||w.id.slice(0,8)})]})},`${w.id}-${b}`)}),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],u=c.map(m),e[7]=s,e[8]=c,e[9]=u}else u=e[9];let f;return e[12]!==u?(f=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:u})})]}),e[12]=u,e[13]=f):f=e[13],f}function MO(n){const e=B.c(19),{searchInputRef:t}=n,{state:s,dispatch:o}=Ht(),{searchQuery:i,expandAll:a}=s,{actions:l}=at(),{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 u=a?"Collapse all":"Expand all";let f;e[1]!==a?(f=a?r.jsx(Ra,{"data-icon":"inline-start"}):r.jsx($a,{"data-icon":"inline-start"}),e[1]=a,e[2]=f):f=e[2];let m;e[3]!==c||e[4]!==u||e[5]!==f?(m=r.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[d,r.jsx(ee,{variant:"ghost",size:"icon-sm",className:"shrink-0",onClick:c,"aria-label":u,children:f})]}),e[3]=c,e[4]=u,e[5]=f,e[6]=m):m=e[6];const p=i??"";let h;e[7]!==o?(h=v=>o({type:"SET_SEARCH_QUERY",value:v.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(cs,{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(Pn,{align:"inline-start",children:r.jsx(an,{})}),e[13]=x):x=e[13];let b;e[14]!==g?(b=r.jsxs(ls,{children:[g,x]}),e[14]=g,e[15]=b):b=e[15];let w;return e[16]!==b||e[17]!==m?(w=r.jsxs("div",{className:"sticky top-0 border-b bg-background px-3 py-3",children:[m,b]}),e[16]=b,e[17]=m,e[18]=w):w=e[18],w}const Ub=y.memo(function(e){const t=B.c(48),{embedded:s,onJumpToTurn:o,onToggleServer:i,onServersChanged:a,searchInputRef:l,onLoadSession:c,backgroundAgents:d}=e,u=s===void 0?!1:s,{isMobile:f}=Ht(),{session:m,sessionSource:p}=at(),h=m,{turns:g}=h;let x;t[0]!==h.stats.totalCacheCreationTokens||t[1]!==h.stats.totalCacheReadTokens||t[2]!==h.stats.totalInputTokens||t[3]!==h.stats.totalOutputTokens||t[4]!==g.length?(x=[h.stats.totalInputTokens,h.stats.totalOutputTokens,h.stats.totalCacheCreationTokens,h.stats.totalCacheReadTokens,g.length],t[0]=h.stats.totalCacheCreationTokens,t[1]=h.stats.totalCacheReadTokens,t[2]=h.stats.totalInputTokens,t[3]=h.stats.totalOutputTokens,t[4]=g.length,t[5]=x):x=t[5];const b=x.join(":"),w=f?"mobile-scroll w-full flex-1":u?"w-full":"view-transition-right-panel panel-enter-right w-[320px] border-l";let v;t[6]!==w?(v=G("h-full min-h-0 shrink-0 overflow-y-auto bg-background",w),t[6]=w,t[7]=v):v=t[7];let S;t[8]!==l?(S=l&&r.jsx(MO,{searchInputRef:l}),t[8]=l,t[9]=S):S=t[9];const j=f?"p-4":"p-3";let k;t[10]!==j?(k=G(j),t[10]=j,t[11]=k):k=t[11];let C;t[12]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsxs(Ga,{variant:"line",className:"grid w-full grid-cols-4",children:[r.jsx(Dn,{value:"activity",children:"Activity"}),r.jsx(Dn,{value:"agents",children:"Agents"}),r.jsx(Dn,{value:"cost",children:"Cost"}),r.jsx(Dn,{value:"issues",children:"Issues"})]}),t[12]=C):C=t[12];let N;t[13]!==o||t[14]!==g?(N=r.jsxs(Ln,{value:"activity",className:"flex flex-col gap-6 pt-3",children:[r.jsx(TO,{turns:g,onJumpToTurn:o}),r.jsx(IO,{turns:g,onJumpToTurn:o})]}),t[13]=o,t[14]=g,t[15]=N):N=t[15];let _;t[16]!==a||t[17]!==i||t[18]!==h.cwd||t[19]!==g?(_=r.jsx(rx,{cwd:h.cwd,turns:g,onToggleServer:i,onServersChanged:a}),t[16]=a,t[17]=i,t[18]=h.cwd,t[19]=g,t[20]=_):_=t[20];let A;t[21]!==d?(A=d??[],t[21]=d,t[22]=A):A=t[22];let P;t[23]!==c||t[24]!==h||t[25]!==p||t[26]!==A?(P=r.jsx(CO,{session:h,sessionSource:p,bgAgents:A,onLoadSession:c}),t[23]=c,t[24]=h,t[25]=p,t[26]=A,t[27]=P):P=t[27];let T;t[28]!==_||t[29]!==P?(T=r.jsxs(Ln,{value:"agents",className:"flex flex-col gap-6 pt-3",children:[_,P]}),t[28]=_,t[29]=P,t[30]=T):T=t[30];const E=(p==null?void 0:p.dirName)??null,$=(p==null?void 0:p.fileName)??null;let I;t[31]!==b||t[32]!==E||t[33]!==$?(I=r.jsx(Ln,{value:"cost",className:"pt-3",children:r.jsx(yO,{dirName:E,fileName:$,revision:b})}),t[31]=b,t[32]=E,t[33]=$,t[34]=I):I=t[34];let R;t[35]!==o||t[36]!==g?(R=r.jsx(Ln,{value:"issues",className:"flex flex-col gap-6 pt-3",children:r.jsx(jO,{turns:g,onJumpToTurn:o})}),t[35]=o,t[36]=g,t[37]=R):R=t[37];let D;t[38]!==T||t[39]!==I||t[40]!==R||t[41]!==k||t[42]!==N?(D=r.jsxs(Va,{defaultValue:"activity",className:k,children:[C,N,T,I,R]}),t[38]=T,t[39]=I,t[40]=R,t[41]=k,t[42]=N,t[43]=D):D=t[43];let O;return t[44]!==D||t[45]!==v||t[46]!==S?(O=r.jsxs("aside",{className:v,children:[S,D]}),t[44]=D,t[45]=v,t[46]=S,t[47]=O):O=t[47],O}),OO="default",DO="tmp-",LO=/^[a-z0-9][a-z0-9_-]{0,39}$/;function zO(n){return LO.test(n)}function FO(n){return n.startsWith(DO)}function zh(n,e){let t="",s="",o=!0,i=e;for(;i<n.length;i++){const a=n[i],l=n[i+1];if(!s&&/[\s;&|()<>]/.test(a))break;if(a==="\\"&&s!=="'"){if(l===void 0)return null;if(!s||/[$`"\\\n]/.test(l)){l!==`
|
|
129
|
+
`&&(t+=l),i++;continue}}if(a===s){s="";continue}if(!s&&(a==="'"||a==='"')){s=a;continue}if(s!=="'"){if(a==="`"||a==="$"&&/[('"{]/.test(l??""))return null;(a==="$"||!s&&/[*?[{}~]/.test(a))&&(o=!1)}t+=a}return s?null:{value:t,start:e,end:i,literal:o}}function BO(n){const e=[];let t=[],s=0,o=0;const i=()=>({commands:[...e,{words:t,end:n.length,pipeline:s}],complete:!1});for(let a=0;a<n.length;){const l=n[a];if(l==="\\"&&n[a+1]===`
|
|
130
|
+
`){a+=2;continue}if(l==="#"){const u=n.indexOf(`
|
|
131
|
+
`,a);e.push({words:t,end:a,pipeline:s}),t.length>0&&o===0&&s++,t=[],a=u<0?n.length:u;continue}if(/[^\S\n]/.test(l)){a++;continue}if(/[;&|()\n]/.test(l)){const u=n[a+1],f=l==="|"&&u!=="|";if(l==="("&&o++,l===")"&&o--,o<0)return i();e.push({words:t,end:a,pipeline:s}),o===0&&!f&&l!=="("&&l!==")"&&(l!==`
|
|
132
|
+
`||t.length>0)&&s++,t=[],a+=(l==="&"||l==="|")&&(u===l||f&&u==="&")?2:1;continue}if(/^(?:\d+)?<</.test(n.slice(a)))return i();const c=/^(?:\d+)?(?:>>|>\||>&|<&|<>|[<>])/.exec(n.slice(a));if(c){for(a+=c[0].length;/[^\S\n]/.test(n[a]??"");)a++;const u=zh(n,a);if(!u||u.end===a)return i();a=u.end;continue}const d=zh(n,a);if(!d||d.end===a)return i();t.push(d),a=d.end}return e.push({words:t,end:n.length,pipeline:s}),{commands:e,complete:o===0}}const or="agent-browser",UO=new Map([["env",new Set(["-i","--ignore-environment","--"])],["command",new Set(["--"])],["exec",new Set(["--"])],["npx",new Set(["-y","--yes","--"])],["bunx",new Set(["--bun","--"])]]),WO=new Set(["echo","printf","rg","grep","cat","head","tail","wc","ls","stat","file","basename","dirname","cp","mv","rm","mkdir","rmdir","touch"]),HO=new Set(["commit","log","show","diff","status","add","grep","ls-files","rev-parse"]),qO=/^(?:if|then|else|elif|fi|while|until|for|select|case|esac|do|done|function|\{|\}|!)$/,KO=/^[A-Za-z_][A-Za-z_\d]*=/;function Wb(n){return n.slice(n.lastIndexOf("/")+1)}function VO(n,e){var s,o;let t=0;for(;t<n.length;){const i=n[t];if(KO.test(e.slice(i.start,i.end))){t++;continue}if(!i.literal||qO.test(i.value))return null;const a=Wb(i.value);if(a==="command"&&["-v","-V"].includes((s=n[t+1])==null?void 0:s.value))return-1;const l=UO.get(a);if(!l)return t;for(t++;(o=n[t])!=null&&o.value.startsWith("-");){if(!n[t].literal||!l.has(n[t].value))return null;if(n[t++].value==="--")break}}return-1}function GO(n,e,t){const[s,...o]=n;if(o.some(l=>!l.literal))return null;let i=OO,a=null;for(let l=0;l<o.length;l++){const c=o[l];if(c.value!=="--session"&&!c.value.startsWith("--session="))continue;if(a!==null)return null;const d=c.value==="--session"?o[++l]:c;if(i=c.value==="--session"?d==null?void 0:d.value:c.value.slice(10),!i||!zO(i)||d!==c&&!/^(?:\s|\\\n)*$/.test(t.slice(c.end,d.start)))return null;a={start:c.start,end:d.end}}return{text:or+t.slice(s.end,e).trimEnd(),binaryEnd:s.end,end:e,browser:i,sessionFlag:a}}function YO(n){var l;const{commands:e,complete:t}=BO(n),s=[],o=e.some(({words:c})=>c.some(({value:d})=>d.includes(or)));if(!t)return{invocations:s,ambiguous:o||n.includes(or)};const i=new Set(e.filter(({words:c})=>c.some(({value:d})=>d.includes(or))).map(({pipeline:c})=>c));let a=!1;for(const{words:c,end:d,pipeline:u}of e){const f=VO(c,n);if(f===null){a||(a=o);continue}if(f<0)continue;const m=Wb(c[f].value);if(m!==or){!(WO.has(m)||m==="git"&&HO.has((l=c[f+1])==null?void 0:l.value))&&i.has(u)&&(a=!0);continue}const p=GO(c.slice(f),d,n);p===null?a=!0:s.push(p)}return{invocations:s,ambiguous:a}}function XO(n){return YO(n).invocations}const Fh=120,JO=/(?:^|[._])exec_command$/;function QO(n){return n.name==="Bash"||JO.test(n.name)}function ZO(n){if(!QO(n))return null;const[e]=XO(Fo(n.input));if(e===void 0||FO(e.browser))return null;const{text:t}=e;return{session:e.browser,command:t.length>Fh?`${t.slice(0,Fh-1)}…`:t,timestamp:n.timestamp,toolCallId:n.id,done:n.result!==null}}function eD(n){const e=(n==null?void 0:n.turns)??[];for(let t=e.length-1;t>=0;t--){const s=e[t].toolCalls;for(let o=s.length-1;o>=0;o--){const i=ZO(s[o]);if(i)return i}}return null}const Bh=1e4,tD=y.lazy(()=>qe(()=>import("./ProjectFilesPanel-nG1bZOL7.js"),__vite__mapDeps([30,1,31,2,4,3])).then(n=>({default:n.ProjectFilesPanel}))),nD=y.lazy(()=>qe(()=>import("./WorktreePanel-JHMvhzQu.js"),__vite__mapDeps([32,1,2,3,4])).then(n=>({default:n.WorktreePanel}))),sD=y.lazy(()=>qe(()=>import("./index-BhAAK3QZ.js"),__vite__mapDeps([33,1,2,3,4])).then(n=>({default:n.BrowserPanel})));function rf(){const n=B.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-sm text-muted-foreground",role:"status",children:[r.jsx(st,{}),"Loading panel…"]}),n[0]=e):e=n[0],e}function oD(n){const e=B.c(6),{context:t,closePanel:s}=n,o=Vu(),i=o.projectFilesRoot??t.projectPath;if(!i)return null;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(rf,{}),e[0]=a):a=e[0];let l;return e[1]!==s||e[2]!==i||e[3]!==o.addProjectContext||e[4]!==o.projectFilesRequest?(l=r.jsx(y.Suspense,{fallback:a,children:r.jsx(tD,{cwd:i,onClose:s,onAddToPrompt:o.addProjectContext,openRequest:o.projectFilesRequest,embedded:!0},i)}),e[1]=s,e[2]=i,e[3]=o.addProjectContext,e[4]=o.projectFilesRequest,e[5]=l):l=e[5],l}function rD(n){const e=B.c(3),{context:t}=n;if(!t.session)return null;let s;return e[0]!==t.session||e[1]!==t.sessionChangeKey?(s=r.jsx(q9,{session:t.session,sessionChangeKey:t.sessionChangeKey}),e[0]=t.session,e[1]=t.sessionChangeKey,e[2]=s):s=e[2],s}function iD(){const n=B.c(7),e=Vu();let t;return n[0]!==e.backgroundAgents||n[1]!==e.jumpToTurn||n[2]!==e.loadSession||n[3]!==e.searchInputRef||n[4]!==e.serversChanged||n[5]!==e.toggleServer?(t=r.jsx(Ub,{embedded:!0,onJumpToTurn:e.jumpToTurn,onToggleServer:e.toggleServer,onServersChanged:e.serversChanged,searchInputRef:e.searchInputRef,onLoadSession:e.loadSession,backgroundAgents:e.backgroundAgents}),n[0]=e.backgroundAgents,n[1]=e.jumpToTurn,n[2]=e.loadSession,n[3]=e.searchInputRef,n[4]=e.serversChanged,n[5]=e.toggleServer,n[6]=t):t=n[6],t}function aD(n){const e=B.c(3);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=r.jsx(rf,{}),e[0]=t):t=e[0];let s;return e[1]!==n?(s=r.jsx(y.Suspense,{fallback:t,children:r.jsx(sD,{...n})}),e[1]=n,e[2]=s):s=e[2],s}function lD(n){var d;const e=B.c(8),{context:t}=n,[,s]=y.useState(0);let o;e[0]!==t.session?(o=Date.parse(((d=eD(t.session))==null?void 0:d.timestamp)??""),e[0]=t.session,e[1]=o):o=e[1];const i=o;let a;e[2]!==i||e[3]!==s?(a=()=>{const u=i+Bh-Date.now();if(Number.isNaN(u)||u<=0)return;const f=setTimeout(()=>s(cD),u);return()=>clearTimeout(f)},e[2]=i,e[3]=s,e[4]=a):a=e[4];let l;if(e[5]!==i?(l=[i],e[5]=i,e[6]=l):l=e[6],y.useEffect(a,l),Number.isNaN(i)||Date.now()-i>=Bh)return null;let c;return e[7]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx("span",{role:"status","aria-label":"The agent is using the browser",className:"absolute -right-0.5 -top-0.5 size-2 rounded-full bg-emerald-500 motion-safe:animate-pulse"}),e[7]=c):c=e[7],c}function cD(n){return n+1}function dD(n){const e=B.c(8),{closePanel:t}=n,s=Vu();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(rf,{}),e[0]=o):o=e[0];let i;return e[1]!==t||e[2]!==s.openWorktreeSession||e[3]!==s.worktreeDirName||e[4]!==s.worktrees.loading||e[5]!==s.worktrees.refetch||e[6]!==s.worktrees.worktrees?(i=r.jsx(y.Suspense,{fallback:o,children:r.jsx(nD,{worktrees:s.worktrees.worktrees,loading:s.worktrees.loading,dirName:s.worktreeDirName,onRefetch:s.worktrees.refetch,onOpenSession:s.openWorktreeSession,onClose:t})}),e[1]=t,e[2]=s.openWorktreeSession,e[3]=s.worktreeDirName,e[4]=s.worktrees.loading,e[5]=s.worktrees.refetch,e[6]=s.worktrees.worktrees,e[7]=i):i=e[7],i}const uD={id:xo,workspacePanels:[{id:"worktrees",title:"Worktrees",icon:zn,component:dD,order:5,defaultSize:"36%",minSize:"320px",when:n=>n.supportsWorktrees===!0},{id:"project-files",title:"Project files",icon:$w,component:oD,order:10,defaultSize:"55%",minSize:"340px",maxSize:"75%",keepAlive:!0,when:n=>n.canAccessHostFiles&&n.projectPath!==null},{id:"browser",title:"Browser",icon:ta,component:aD,indicator:lD,order:15,defaultSize:"46%",minSize:"360px",maxSize:"75%",keepAlive:!0,when:n=>n.canAccessHostFiles},{id:"file-changes",title:"File changes",icon:zr,component:rD,order:20,defaultSize:"36%",minSize:"320px",when:n=>n.canAccessHostFiles&&n.hasFileChanges&&n.session!==null},{id:"session-info",title:"Session details",icon:Rw,component:iD,order:30,defaultSize:"36%",minSize:"320px",when:n=>n.session!==null}]},fD=cP([uD,...iO]);function vl(n){const e=B.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 bg-gradient-to-t from-background via-background/70 to-transparent pt-4",children:r.jsx("div",{className:"pointer-events-auto w-full max-w-[var(--chat-width)] px-3 pb-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 pb-3",children:s})}),e[2]=s,e[3]=o):o=e[3],o}function Hb(n){const e=B.c(11),{projectPath:t}=n;let s;e[0]!==t?(s=t?es(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:za(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 mD(n){const e=B.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 pD(n){const e=B.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 Uh(n){const e=B.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 hD(n){const e=B.c(10);let t,s,o,i;if(e[0]!==n){const{className:c,render:d,...u}=n;t=d,i=C1,s="a",o=k1({className:G("transition-colors hover:text-foreground",c)},u),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 gD(n){const e=B.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 xD(n){const e=B.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(Xe,{}),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 qb(n){const e=B.c(51),{children:t,sessionLabel:s,customName:o,onDuplicate:i,onDelete:a,onRename:l}=n,[c,d]=y.useState(!1),[u,f]=y.useState(!1),[m,p]=y.useState(""),h=y.useRef(null);let g;e[0]!==o?(g=function(){p(o||""),f(!0),requestAnimationFrame(()=>{var W;return(W=h.current)==null?void 0:W.select()})},e[0]=o,e[1]=g):g=e[1];const x=g;let b;e[2]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx("div",{className:"w-full"}),e[2]=b):b=e[2];let w;e[3]!==t?(w=r.jsx(al,{render:b,children:t}),e[3]=t,e[4]=w):w=e[4];let v;e[5]!==i||e[6]!==l||e[7]!==x?(v=(l||i)&&r.jsxs(jo,{children:[l&&r.jsxs(sn,{onClick:x,children:[r.jsx(Vs,{"data-icon":"inline-start"}),"Rename session"]}),i&&r.jsxs(sn,{onClick:i,children:[r.jsx(xn,{"data-icon":"inline-start"}),"Duplicate session"]})]}),e[5]=i,e[6]=l,e[7]=x,e[8]=v):v=e[8];let S;e[9]!==a||e[10]!==i||e[11]!==l?(S=a&&r.jsxs(r.Fragment,{children:[(i||l)&&r.jsx(Ar,{}),r.jsx(jo,{children:r.jsxs(sn,{variant:"destructive",onClick:()=>d(!0),children:[r.jsx(Ta,{"data-icon":"inline-start"}),"Delete session"]})})]}),e[9]=a,e[10]=i,e[11]=l,e[12]=S):S=e[12];let j;e[13]!==v||e[14]!==S?(j=r.jsxs(ll,{className:"min-w-44",children:[v,S]}),e[13]=v,e[14]=S,e[15]=j):j=e[15];let k;e[16]!==w||e[17]!==j?(k=r.jsxs(il,{children:[w,j]}),e[16]=w,e[17]=j,e[18]=k):k=e[18];let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(Qd,{children:"Delete session?"}),e[19]=C):C=e[19];let N;e[20]!==s?(N=r.jsxs(Xd,{children:[C,r.jsxs(Zd,{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]=N):N=e[21];let _;e[22]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(tu,{size:"sm",children:"Cancel"}),e[22]=_):_=e[22];let A;e[23]!==a?(A=r.jsxs(Jd,{children:[_,r.jsx(eu,{variant:"destructive",size:"sm",onClick:()=>{a==null||a(),d(!1)},children:"Delete"})]}),e[23]=a,e[24]=A):A=e[24];let P;e[25]!==A||e[26]!==N?(P=r.jsxs(Yd,{children:[N,A]}),e[25]=A,e[26]=N,e[27]=P):P=e[27];let T;e[28]!==c||e[29]!==P?(T=r.jsx(Gd,{open:c,onOpenChange:d,children:P}),e[28]=c,e[29]=P,e[30]=T):T=e[30];let E;e[31]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsxs(Ps,{children:[r.jsx(is,{className:"text-foreground",children:"Rename session"}),r.jsx(as,{className:"text-muted-foreground",children:"Give this session a custom name. Clear to reset to default."})]}),e[31]=E):E=e[31];let $;e[32]!==l||e[33]!==m?($=L=>{L.preventDefault(),l==null||l(m),f(!1)},e[32]=l,e[33]=m,e[34]=$):$=e[34];let I;e[35]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(St,{htmlFor:"session-rename",children:"Session name"}),e[35]=I):I=e[35];let R;e[36]===Symbol.for("react.memo_cache_sentinel")?(R=L=>p(L.target.value),e[36]=R):R=e[36];let D;e[37]!==m||e[38]!==s?(D=r.jsxs(jt,{children:[I,r.jsx(Dt,{id:"session-rename",ref:h,value:m,onChange:R,placeholder:s})]}),e[37]=m,e[38]=s,e[39]=D):D=e[39];let O;e[40]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsxs(Og,{children:[r.jsx(ee,{type:"button",variant:"ghost",size:"sm",onClick:()=>f(!1),children:"Cancel"}),r.jsx(ee,{type:"submit",size:"sm",children:"Save"})]}),e[40]=O):O=e[40];let M;e[41]!==$||e[42]!==D?(M=r.jsxs(rs,{className:"sm:max-w-md",children:[E,r.jsxs("form",{className:"flex flex-col gap-4",onSubmit:$,children:[D,O]})]}),e[41]=$,e[42]=D,e[43]=M):M=e[43];let F;e[44]!==u||e[45]!==M?(F=r.jsx(os,{open:u,onOpenChange:f,children:M}),e[44]=u,e[45]=M,e[46]=F):F=e[46];let z;return e[47]!==T||e[48]!==F||e[49]!==k?(z=r.jsxs(r.Fragment,{children:[k,T,F]}),e[47]=T,e[48]=F,e[49]=k,e[50]=z):z=e[50],z}const Kb="session-custom-names";function Vb(){try{const n=localStorage.getItem(Vt(Kb));return n?JSON.parse(n):{}}catch{return{}}}function bD(n){localStorage.setItem(Vt(Kb),JSON.stringify(n))}let ya=Vb();const wa=new Set;if(typeof window<"u"){const n=()=>{ya=Vb();for(const e of wa)e()};window.addEventListener("cogpit-device-changed",n),window.addEventListener("cogpit-identity-changed",n)}function vD(n){return wa.add(n),()=>{wa.delete(n)}}function yD(){return ya}function cd(n,e){const t={...ya},s=e.trim();s?t[n]=s:delete t[n],bD(t),ya=t;for(const o of wa)o()}function Gb(){const n=B.c(2),e=y.useSyncExternalStore(vD,yD);let t;return n[0]!==e?(t={names:e,rename:cd},n[0]=e,n[1]=t):t=n[1],t}function Yb(n){const e=B.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(Pn,{children:a?r.jsx(rt,{className:"animate-spin","aria-label":"Searching session history"}):r.jsx(an,{"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(cs,{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 u;e[9]!==s||e[10]!==t?(u=t&&r.jsx(Pn,{align:"inline-end",children:r.jsx(Qr,{"aria-label":"Clear search",onClick:()=>s(""),size:"icon-xs",children:r.jsx(nt,{})})}),e[9]=s,e[10]=t,e[11]=u):u=e[11];let f;return e[12]!==l||e[13]!==d||e[14]!==u?(f=r.jsxs(ls,{className:"w-full sm:max-w-sm",children:[l,d,u]}),e[12]=l,e[13]=d,e[14]=u,e[15]=f):f=e[15],f}function Xb(n){const e=B.c(10),{message:t,onRetry:s}=n;let o,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(gn,{"aria-hidden":"true"}),i=r.jsx(Et,{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(ht,{children:t}),e[2]=t,e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Pt,{"data-icon":"inline-start"}),e[4]=l):l=e[4];let c;e[5]!==s?(c=r.jsx(Cs,{children:r.jsxs(ee,{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(pt,{variant:"destructive",children:[o,i,a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d}function Jb(n){const e=B.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(Nt,{}),r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3.5",children:[r.jsx(ct,{className:"size-8 shrink-0 rounded-md"}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[r.jsx(ct,{className:"h-4 w-40 max-w-full"}),i&&r.jsx(ct,{className:"h-3 w-72 max-w-full"}),r.jsx(ct,{className:"h-3 w-52 max-w-full"})]}),r.jsx(ct,{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 Rr(n){return n==="idle"||n==="completed"}function af(n){return Rr(n)?"text-success":n==="thinking"||n==="deferred"?"text-warning":"text-info"}const Bs={attention:"bg-warning",working:"bg-success ring-2 ring-success/30",idle:"bg-success/40"},wD=/(?:https?:\/\/)?github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/i,jD=/^([\w.-]+(?:\/[\w.-]+)?)#(\d+)$/,SD=/(?:^|\s)#(\d+)(?=\s|$)/,ND=/^(?:pr|pull\s+request)\s*#?(\d+)$/i;function Bi(n){const e=Number(n);return Number.isSafeInteger(e)&&e>0?e:null}function kD(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 Qb(n){const e=n.trim();if(!e)return null;const t=wD.exec(e);if(t){const l=Bi(t[3]);return l===null?null:{number:l,repoHint:`${t[1]}/${t[2]}`.toLowerCase()}}const s=jD.exec(e);if(s){const l=Bi(s[2]);return l===null?null:{number:l,repoHint:s[1].toLowerCase()}}const o=SD.exec(e);if(o){const l=Bi(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:kD(c)}}const i=ND.exec(e);if(!i)return null;const a=Bi(i[1]);return a===null?null:{number:a,repoHint:null}}function Wh(n,e){if(!n)return!1;const t=n.toLowerCase().replace(/\.git$/,"");return t===e||t.endsWith(`/${e}`)||e.endsWith(`/${t}`)}function CD(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 _D(n,e,t=[]){if(n.number!==e.number)return!1;const s=e.repoHint;return s?n.repo&&s.includes("/")?Wh(n.repo,s):Wh(n.repo,s)?!0:t.some(o=>CD(o,s)):!0}function Zb(n,e,t=[]){var i;const s=Qb(e);if(s){const a=[n.cwd,n.projectShortName,...t];return((i=n.pullRequests)==null?void 0:i.some(l=>_D(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 TD=120*1e3;function ev(n){return n?Date.now()-new Date(n).getTime()<TD:!1}function tv(n,e){const t=n.teamName?n.agentName:"",s=e||n.aiTitle||n.name||t||n.slug||n.firstUserMessage||n.customTitle;return s?kn(s,70):kn(n.sessionId,16)}function Hh(n){return n.trim().replace(/\s+/g," ").slice(0,40).toLowerCase()}function ED(n,e){const t=(n.lastUserMessage||n.firstUserMessage||"").trim();return!t||Hh(t)===Hh(e)?null:kn(t,220)}function AD(n,e){return Zb(n,e)}function PD(n,e){if(!n||!e)return null;const t=new Date(e).getTime()-new Date(n).getTime();return t>=6e4?Bn(t):null}function $D(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(`
|
|
133
|
+
`)}function RD(n){var t;const e=n.cwd?(t=Fa(n.cwd))==null?void 0:t.worktreeName:void 0;return e?{icon:Iw,label:e,title:n.cwd}:n.gitBranch?{icon:zn,label:n.gitBranch}:null}function ID(n,e){return n.agentStatus==="deferred"?"attention":e?Rr(n.agentStatus)?"idle":"working":null}function MD(n){const e=B.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(Pe,{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=Rr(t.agentStatus);let i;e[1]!==t.agentPendingAgents||e[2]!==t.agentStatus||e[3]!==t.agentTerminalReason||e[4]!==t.agentToolName?(i=ai(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=af(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 u;e[10]!==d?(u=r.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:d}),e[10]=d,e[11]=u):u=e[11];let f;return e[12]!==a||e[13]!==l||e[14]!==u?(f=r.jsxs(Pe,{variant:"secondary",className:l,children:[u,a]}),e[12]=a,e[13]=l,e[14]=u,e[15]=f):f=e[15],f}if(t.agentTerminalReason){let o;e[16]!==t.agentTerminalReason?(o=Du(t.agentTerminalReason),e[16]=t.agentTerminalReason,e[17]=o):o=e[17];let i;return e[18]!==o?(i=r.jsx(Pe,{variant:"outline",className:"max-w-44 truncate text-warning",children:o}),e[18]=o,e[19]=i):i=e[19],i}return null}function xc(n){const e=B.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 OD(n){const e=B.c(99),{session:t,customName:s,onSelect:o}=n,i=t.lastActivityAt||t.lastModified;let a,l;e[0]!==i||e[1]!==t?(a=ev(i),l=ID(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 u,f,m,p,h,g,x,b,w,v,S,j,k,C;if(e[4]!==s||e[5]!==c||e[6]!==i||e[7]!==a||e[8]!==o||e[9]!==t||e[10]!==d){const D=RD(t);let O;e[25]!==i||e[26]!==t.timestamp?(O=PD(t.timestamp,i),e[25]=i,e[26]=t.timestamp,e[27]=O):O=e[27];const M=O,F=t.turnCount??0;let z,L;e[28]!==s||e[29]!==t?(L=tv(t,s),z=ED(t,L),e[28]=s,e[29]=t,e[30]=z,e[31]=L):(z=e[30],L=e[31]);const W=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",u="button",f=o,e[32]!==t?(m=$D(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 U;e[34]===Symbol.for("react.memo_cache_sentinel")?(U=r.jsx(kc,{className:"size-4"}),e[34]=U):U=e[34];let H;e[35]!==c?(H=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",Bs[c])}),e[35]=c,e[36]=H):H=e[36],e[37]!==H?(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:[U,H]}),e[37]=H,e[38]=h):h=e[38],j="flex min-w-0 flex-1 flex-col gap-1";let K;e[39]!==L?(K=r.jsx("span",{className:"truncate text-sm font-medium",children:L}),e[39]=L,e[40]=K):K=e[40];let V;e[41]!==d?(V=d&&r.jsxs(Pe,{variant:"outline",className:"shrink-0",children:[r.jsx(No,{"data-icon":"inline-start"}),kn(d,18)]}),e[41]=d,e[42]=V):V=e[42];let Y;e[43]!==t.branchedFrom?(Y=t.branchedFrom&&r.jsxs(Pe,{variant:"outline",className:"shrink-0",title:"Branched from another session",children:[r.jsx(_d,{"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(MD,{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:Hr(i)}),e[48]=i,e[49]=J):J=e[49];let Q;e[50]!==q||e[51]!==J?(Q=r.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2",children:[q,J]}),e[50]=q,e[51]=J,e[52]=Q):Q=e[52],e[53]!==K||e[54]!==V||e[55]!==Y||e[56]!==Q?(k=r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[K,V,Y,Q]}),e[53]=K,e[54]=V,e[55]=Y,e[56]=Q,e[57]=k):k=e[57],e[58]!==W?(C=W&&r.jsx("span",{className:"line-clamp-1 text-sm text-muted-foreground",children:W}),e[58]=W,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?(b=t.model&&r.jsx(Pe,{variant:"outline",children:Js(t.model)}),e[60]=t.model,e[61]=b):b=e[61],e[62]!==F?(w=F>0&&r.jsxs(xc,{icon:kc,children:[F," ",F===1?"turn":"turns"]}),e[62]=F,e[63]=w):w=e[63],e[64]!==M?(v=M&&r.jsx(xc,{icon:Us,title:"First prompt to last activity",children:M}),e[64]=M,e[65]=v):v=e[65],S=D&&r.jsx(xc,{icon:D.icon,className:"max-w-40 truncate",title:D.title,children:kn(D.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]=u,e[12]=f,e[13]=m,e[14]=p,e[15]=h,e[16]=g,e[17]=x,e[18]=b,e[19]=w,e[20]=v,e[21]=S,e[22]=j,e[23]=k,e[24]=C}else u=e[11],f=e[12],m=e[13],p=e[14],h=e[15],g=e[16],x=e[17],b=e[18],w=e[19],v=e[20],S=e[21],j=e[22],k=e[23],C=e[24];let N;e[66]!==t.size?(N=vg(t.size),e[66]=t.size,e[67]=N):N=e[67];let _;e[68]!==N?(_=r.jsx("span",{children:N}),e[68]=N,e[69]=_):_=e[69];let A;e[70]!==_||e[71]!==x||e[72]!==b||e[73]!==w||e[74]!==v||e[75]!==S?(A=r.jsxs("span",{className:x,children:[b,w,v,S,_]}),e[70]=_,e[71]=x,e[72]=b,e[73]=w,e[74]=v,e[75]=S,e[76]=A):A=e[76];let P;e[77]!==A||e[78]!==j||e[79]!==k||e[80]!==C?(P=r.jsxs("span",{className:j,children:[k,C,A]}),e[77]=A,e[78]=j,e[79]=k,e[80]=C,e[81]=P):P=e[81];let T;e[82]!==u||e[83]!==f||e[84]!==m||e[85]!==p||e[86]!==h||e[87]!==P?(T=r.jsxs("button",{type:u,onClick:f,title:m,className:p,children:[h,P]}),e[82]=u,e[83]=f,e[84]=m,e[85]=p,e[86]=h,e[87]=P,e[88]=T):T=e[88];let E;e[89]!==t.matchedPullRequestNumber||e[90]!==t.pullRequests?(E=t.matchedPullRequestNumber?r.jsxs(Pe,{variant:"outline",children:["Matched #",t.matchedPullRequestNumber]}):r.jsx(hl,{pullRequests:t.pullRequests,max:2,compact:!0}),e[89]=t.matchedPullRequestNumber,e[90]=t.pullRequests,e[91]=E):E=e[91];let $;e[92]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx(Xe,{className:"size-4 text-muted-foreground transition-transform group-hover:translate-x-0.5"}),e[92]=$):$=e[92];let I;e[93]!==E?(I=r.jsxs("span",{className:"flex shrink-0 items-center gap-2 pt-1.5",children:[E,$]}),e[93]=E,e[94]=I):I=e[94];let R;return e[95]!==g||e[96]!==T||e[97]!==I?(R=r.jsxs("div",{className:g,children:[T,I]}),e[95]=g,e[96]=T,e[97]=I,e[98]=R):R=e[98],R}function DD(n){const e=B.c(61),{selectedProject:t,sessions:s,sessionsTotal:o,sessionsLoading:i,searchLoading:a,searchFilter:l,setSearchFilter:c,filteredSessions:d,fetchError:u,onSelectSession:f,onNewSession:m,creatingSession:p,onDuplicateSession:h,onDeleteSession:g,onBack:x,onRetryFetch:b,loadMoreSessions:w}=n,{names:v,rename:S}=Gb();let j;e[0]!==t.path?(j=es(t.path),e[0]=t.path,e[1]=j):j=e[1];const k=j;let C;e[2]!==x?(C=r.jsx(Uh,{children:r.jsx(hD,{render:r.jsx("button",{type:"button",onClick:x}),children:"Projects"})}),e[2]=x,e[3]=C):C=e[3];let N;e[4]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(xD,{}),e[4]=N):N=e[4];let _;e[5]!==k?(_=r.jsx(Uh,{className:"min-w-0",children:r.jsx(gD,{className:"truncate",children:k})}),e[5]=k,e[6]=_):_=e[6];let A;e[7]!==C||e[8]!==_?(A=r.jsx(mD,{children:r.jsxs(pD,{children:[C,N,_]})}),e[7]=C,e[8]=_,e[9]=A):A=e[9];let P;e[10]!==k?(P=r.jsx("h1",{className:"truncate text-2xl font-semibold tracking-tight",children:k}),e[10]=k,e[11]=P):P=e[11];let T;e[12]!==o?(T=r.jsx(Pe,{variant:"secondary",children:o}),e[12]=o,e[13]=T):T=e[13];let E;e[14]!==P||e[15]!==T?(E=r.jsxs("div",{className:"flex items-center gap-2",children:[P,T]}),e[14]=P,e[15]=T,e[16]=E):E=e[16];let $;e[17]!==t.path?($=za(t.path),e[17]=t.path,e[18]=$):$=e[18];let I;e[19]!==$?(I=r.jsx("p",{className:"truncate text-sm text-muted-foreground",children:$}),e[19]=$,e[20]=I):I=e[20];let R;e[21]!==I||e[22]!==E?(R=r.jsxs("header",{className:"flex min-w-0 flex-col gap-1",children:[E,I]}),e[21]=I,e[22]=E,e[23]=R):R=e[23];let D;e[24]!==l||e[25]!==a||e[26]!==c?(D=r.jsx(Yb,{value:l,onChange:c,placeholder:"Search sessions or PRs...",loading:a}),e[24]=l,e[25]=a,e[26]=c,e[27]=D):D=e[27];let O;e[28]!==p||e[29]!==m||e[30]!==t.dirName||e[31]!==t.path?(O=m&&r.jsxs(ee,{size:"sm",disabled:p,onClick:()=>m(t.dirName,t.path),children:[p?r.jsx(st,{"data-icon":"inline-start"}):r.jsx(Fn,{"data-icon":"inline-start"}),"New Session"]}),e[28]=p,e[29]=m,e[30]=t.dirName,e[31]=t.path,e[32]=O):O=e[32];let M;e[33]!==D||e[34]!==O?(M=r.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[D,O]}),e[33]=D,e[34]=O,e[35]=M):M=e[35];let F;e[36]!==u||e[37]!==b?(F=u&&r.jsx(Xb,{message:u,onRetry:b}),e[36]=u,e[37]=b,e[38]=F):F=e[38];let z;e[39]!==d||e[40]!==w||e[41]!==g||e[42]!==h||e[43]!==f||e[44]!==S||e[45]!==l||e[46]!==a||e[47]!==t.dirName||e[48]!==v||e[49]!==s||e[50]!==i||e[51]!==o?(z=(i||a)&&d.length===0?r.jsx(Jb,{includeMessagePlaceholder:!0}):d.length===0?r.jsx(ln,{className:"min-h-72 border",children:r.jsxs(cn,{children:[r.jsx(bn,{variant:"icon",children:r.jsx(Ia,{})}),r.jsx(dn,{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((U,H)=>r.jsxs(y.Fragment,{children:[H>0&&r.jsx(Nt,{}),r.jsx(qb,{sessionLabel:tv(U),customName:v[U.sessionId],onRename:K=>S(U.sessionId,K),onDuplicate:h?()=>h(t.dirName,U.fileName):void 0,onDelete:g?()=>g(t.dirName,U.fileName):void 0,children:r.jsx(OD,{session:U,customName:v[U.sessionId],onSelect:()=>f(t.dirName,U.fileName)})})]},U.fileName))}),s.length<o&&!l&&r.jsx("div",{className:"flex justify-center",children:r.jsxs(ee,{variant:"outline",size:"sm",disabled:i,onClick:w,children:[i&&r.jsx(st,{"data-icon":"inline-start"}),i?"Loading...":"Load more sessions"]})})]}),e[39]=d,e[40]=w,e[41]=g,e[42]=h,e[43]=f,e[44]=S,e[45]=l,e[46]=a,e[47]=t.dirName,e[48]=v,e[49]=s,e[50]=i,e[51]=o,e[52]=z):z=e[52];let L;e[53]!==M||e[54]!==F||e[55]!==z?(L=r.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Sessions",children:[M,F,z]}),e[53]=M,e[54]=F,e[55]=z,e[56]=L):L=e[56];let W;return e[57]!==R||e[58]!==L||e[59]!==A?(W=r.jsx(qn,{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:[A,R,L]})}),e[57]=R,e[58]=L,e[59]=A,e[60]=W):W=e[60],W}function LD(n){const e=B.c(13),{projectPath:t,fallback:s,className:o}=n,[i,a]=y.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=Wr(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 u;e[6]!==o?(u=G("size-3.5 shrink-0 rounded-[3px] object-contain",o),e[6]=o,e[7]=u):u=e[7];let f;return e[8]!==t||e[9]!==c||e[10]!==d||e[11]!==u?(f=r.jsx("img",{src:c,alt:"","aria-hidden":!0,loading:"lazy",decoding:"async",onError:d,className:u},t),e[8]=t,e[9]=c,e[10]=d,e[11]=u,e[12]=f):f=e[12],f}function nv(n){const e=B.c(34),{children:t,projectLabel:s,customName:o,className:i,onRename:a}=n,[l,c]=y.useState(!1),[d,u]=y.useState(""),f=y.useRef(null);let m;e[0]!==o?(m=function(){u(o||""),c(!0),requestAnimationFrame(()=>{var $;return($=f.current)==null?void 0:$.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(al,{render:g,children:t}),e[6]=t,e[7]=g,e[8]=x):x=e[8];let b;e[9]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx(Vs,{"data-icon":"inline-start"}),e[9]=b):b=e[9];let w;e[10]!==p?(w=r.jsx(ll,{className:"min-w-44",children:r.jsx(jo,{children:r.jsxs(sn,{onClick:p,children:[b,"Rename project"]})})}),e[10]=p,e[11]=w):w=e[11];let v;e[12]!==x||e[13]!==w?(v=r.jsxs(il,{children:[x,w]}),e[12]=x,e[13]=w,e[14]=v):v=e[14];let S;e[15]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsxs(Ps,{children:[r.jsx(is,{className:"text-foreground",children:"Rename project"}),r.jsx(as,{className:"text-muted-foreground",children:"Give this project a custom name. Clear to reset to default."})]}),e[15]=S):S=e[15];let j;e[16]!==a||e[17]!==d?(j=E=>{E.preventDefault(),a(d),c(!1)},e[16]=a,e[17]=d,e[18]=j):j=e[18];let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(St,{htmlFor:"project-rename",children:"Project name"}),e[19]=k):k=e[19];let C;e[20]===Symbol.for("react.memo_cache_sentinel")?(C=E=>u(E.target.value),e[20]=C):C=e[20];let N;e[21]!==s||e[22]!==d?(N=r.jsxs(jt,{children:[k,r.jsx(Dt,{id:"project-rename",ref:f,value:d,onChange:C,placeholder:s})]}),e[21]=s,e[22]=d,e[23]=N):N=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsxs(Og,{children:[r.jsx(ee,{type:"button",variant:"ghost",size:"sm",onClick:()=>c(!1),children:"Cancel"}),r.jsx(ee,{type:"submit",size:"sm",children:"Save"})]}),e[24]=_):_=e[24];let A;e[25]!==N||e[26]!==j?(A=r.jsxs(rs,{className:"sm:max-w-md",children:[S,r.jsxs("form",{className:"flex flex-col gap-4",onSubmit:j,children:[N,_]})]}),e[25]=N,e[26]=j,e[27]=A):A=e[27];let P;e[28]!==l||e[29]!==A?(P=r.jsx(os,{open:l,onOpenChange:c,children:A}),e[28]=l,e[29]=A,e[30]=P):P=e[30];let T;return e[31]!==P||e[32]!==v?(T=r.jsxs(r.Fragment,{children:[v,P]}),e[31]=P,e[32]=v,e[33]=T):T=e[33],T}const sv="project-custom-names";function ov(){try{const n=localStorage.getItem(Vt(sv));return n?JSON.parse(n):{}}catch{return{}}}function zD(n){localStorage.setItem(Vt(sv),JSON.stringify(n))}let ja=ov();const Sa=new Set;if(typeof window<"u"){const n=()=>{ja=ov();for(const e of Sa)e()};window.addEventListener("cogpit-device-changed",n),window.addEventListener("cogpit-identity-changed",n)}function FD(n){return Sa.add(n),()=>{Sa.delete(n)}}function BD(){return ja}function UD(n,e){const t={...ja},s=e.trim();s?t[n]=s:delete t[n],zD(t),ja=t;for(const o of Sa)o()}function rv(){const n=B.c(2),e=y.useSyncExternalStore(FD,BD);let t;return n[0]!==e?(t={names:e,rename:UD},n[0]=e,n[1]=t):t=n[1],t}function WD(n){const e=B.c(45),{projects:t,activeSessions:s,loading:o,refreshing:i,searchFilter:a,setSearchFilter:l,fetchError:c,selectedProjectDirName:d,onSelectProject:u,onRefresh:f}=n;let m;if(e[0]!==s){m={};for(const R of s)ev(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}=rv();let x;e:{if(!a){x=t;break e}let R;if(e[2]!==h||e[3]!==t||e[4]!==a){const D=a.toLowerCase();R=t.filter(O=>{var M;return O.path.toLowerCase().includes(D)||O.shortName.toLowerCase().includes(D)||((M=h[O.dirName])==null?void 0:M.toLowerCase().includes(D))}),e[2]=h,e[3]=t,e[4]=a,e[5]=R}else R=e[5];x=R}const b=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 v;e[7]!==t.length?(v=r.jsxs("div",{className:"flex items-center gap-2",children:[w,r.jsx(Pe,{variant:"secondary",children:t.length})]}),e[7]=t.length,e[8]=v):v=e[8];let S;e[9]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx("p",{className:"text-sm text-muted-foreground",children:"Open a project to browse and resume its sessions."}),e[9]=S):S=e[9];let j;e[10]!==v?(j=r.jsxs("header",{className:"flex flex-col gap-1",children:[v,S]}),e[10]=v,e[11]=j):j=e[11];let k;e[12]!==a||e[13]!==l?(k=r.jsx(Yb,{value:a,onChange:l,placeholder:"Filter projects..."}),e[12]=a,e[13]=l,e[14]=k):k=e[14];const C=i&&"animate-spin";let N;e[15]!==C?(N=G(C),e[15]=C,e[16]=N):N=e[16];let _;e[17]!==N?(_=r.jsx(Pt,{"data-icon":"inline-start",className:N}),e[17]=N,e[18]=_):_=e[18];let A;e[19]!==f||e[20]!==i||e[21]!==_?(A=r.jsxs(ee,{variant:"outline",size:"sm",onClick:f,disabled:i,"aria-label":"Refresh projects",children:[_,"Refresh"]}),e[19]=f,e[20]=i,e[21]=_,e[22]=A):A=e[22];let P;e[23]!==A||e[24]!==k?(P=r.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[k,A]}),e[23]=A,e[24]=k,e[25]=P):P=e[25];let T;e[26]!==c||e[27]!==f||e[28]!==d?(T=c&&!d&&r.jsx(Xb,{message:c,onRetry:f}),e[26]=c,e[27]=f,e[28]=d,e[29]=T):T=e[29];let E;e[30]!==p||e[31]!==b||e[32]!==o||e[33]!==u||e[34]!==h||e[35]!==g||e[36]!==a?(E=o?r.jsx(Jb,{}):b.length===0?r.jsx(ln,{className:"min-h-72 border",children:r.jsxs(cn,{children:[r.jsx(bn,{variant:"icon",children:r.jsx(_o,{})}),r.jsx(dn,{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:b.map((R,D)=>{const O=p[R.dirName]||0,M=h[R.dirName],F=$4($t(R.dirName));return r.jsxs(y.Fragment,{children:[D>0&&r.jsx(Nt,{}),r.jsx(nv,{projectLabel:es(R.path),customName:M,onRename:z=>g(R.dirName,z),children:r.jsxs("button",{type:"button",onClick:()=>u==null?void 0:u(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(LD,{projectPath:R.path,className:"size-4",fallback:r.jsx(_o,{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:M||es(R.path)}),F&&r.jsx(Pe,{variant:"outline",className:"h-5 shrink-0 px-1.5 text-[10px]",children:F})]}),r.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:za(R.path)})]})]}),r.jsxs("span",{className:"flex items-center gap-4 pl-11 text-sm text-muted-foreground sm:pl-0",children:[O>0&&r.jsxs(Pe,{variant:"secondary",children:[r.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:"size-1.5 rounded-full bg-success"}),O," 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:Hr(R.lastModified)}),r.jsx(Xe,{className:"size-4 shrink-0 transition-transform group-hover:translate-x-0.5"})]})]})})]},R.dirName)})}),e[30]=p,e[31]=b,e[32]=o,e[33]=u,e[34]=h,e[35]=g,e[36]=a,e[37]=E):E=e[37];let $;e[38]!==P||e[39]!==T||e[40]!==E?($=r.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Projects",children:[P,T,E]}),e[38]=P,e[39]=T,e[40]=E,e[41]=$):$=e[41];let I;return e[42]!==$||e[43]!==j?(I=r.jsx(qn,{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:[j,$]})}),e[42]=$,e[43]=j,e[44]=I):I=e[44],I}const HD=250,qD=400,qh={results:null,loading:!1,error:null};function iv(n,e){const t=y.useMemo(()=>Qb(n),[n]),[s,o]=y.useState(0),[i,a]=y.useState(qh);y.useEffect(()=>{if(!t){a(qh);return}const c=new AbortController;a({results:null,loading:!0,error:null});let d=null;const u=async()=>{const m=new URLSearchParams({search:n.trim(),limit:"200"});e&&m.set("project",e);try{const p=await be(`/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(()=>{u()},qD);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"})}},f=setTimeout(()=>{u()},HD);return()=>{clearTimeout(f),d&&clearTimeout(d),c.abort()}},[e,t,n,s]);const l=y.useCallback(()=>o(c=>c+1),[]);return{...i,active:t!==null,refresh:l}}const KD=y.memo(function({onSelectSession:e,onNewSession:t,creatingSession:s,selectedProjectDirName:o,onSelectProject:i,onDuplicateSession:a,onDeleteSession:l}){const[c]=y.useState(()=>({projects:da(Qn.projects),activeSessions:da(Qn.activeSessions)})),[d,u]=y.useState(c.projects??[]),[f,m]=y.useState(c.activeSessions??[]),[p,h]=y.useState(c.projects===void 0),[g,x]=y.useState(!1),[b,w]=y.useState([]),[v,S]=y.useState(0),[j,k]=y.useState(1),[C,N]=y.useState(!1),[_,A]=y.useState(""),[P,T]=y.useState(null),E=y.useRef(0),$=y.useRef(null),I=y.useCallback(async(U=!1)=>{U&&x(!0);try{const[H,K]=await Promise.all([be("/api/projects"),be("/api/active-sessions")]);if(!H.ok||!K.ok)throw new Error("Failed to fetch dashboard data");const V=await H.json(),Y=await K.json(),q=Array.isArray(V)?V:[],J=Array.isArray(Y)?Y:[];u(q),m(J),cr(Qn.projects,q),cr(Qn.activeSessions,J),T(null)}catch(H){T(H instanceof Error?H.message:"Failed to load data")}finally{h(!1),x(!1)}},[]);y.useEffect(()=>{I()},[I]);const R=y.useCallback(async(U,H=1,K=!1)=>{var J;const V=++E.current;(J=$.current)==null||J.abort();const Y=new AbortController;$.current=Y;const q=()=>V===E.current;if(N(!0),T(null),!K){const Q=L7(U);Q?(w(Q.sessions),S(Q.total),k(1)):w([])}try{const Q=await be(`/api/sessions/${encodeURIComponent(U)}?page=${H}&limit=20`,{signal:Y.signal});if(!Q.ok)throw new Error(`Failed to load sessions (${Q.status})`);const X=await Q.json();if(!q())return;const Z=Array.isArray(X.sessions)?X.sessions:[],te=typeof X.total=="number"?X.total:Z.length;w(ne=>K?[...ne,...Z]:Z),S(te),k(H),K||z7(U,{sessions:Z,total:te})}catch(Q){if(!q()||Y.signal.aborted)return;T(Q instanceof Error?Q.message:"Failed to load sessions")}finally{q()&&($.current=null,N(!1))}},[]);y.useEffect(()=>{var U;if(!o){E.current+=1,(U=$.current)==null||U.abort(),$.current=null,w([]),S(0),k(1),A(""),N(!1);return}A(""),R(o)},[o,R]),y.useEffect(()=>()=>{var U;E.current+=1,(U=$.current)==null||U.abort()},[]);const D=y.useMemo(()=>{if(!o)return null;const U=d.find(K=>K.dirName===o);if(U)return U;const H=_n(o);return{dirName:o,path:H,shortName:es(H),sessionCount:v,lastModified:null}},[o,d,v]),O=y.useCallback(()=>{i==null||i(null)},[i]),M=y.useCallback(()=>{o&&R(o,j+1,!0)},[o,j,R]),F=iv(o?_:"",o??void 0),z=y.useMemo(()=>_?b.filter(U=>AD(U,_)):b,[b,_]),L=F.results??z;function W(U,H){l==null||l(U,H),w(K=>K.filter(V=>V.fileName!==H)),S(K=>K-1)}return D?r.jsx(DD,{selectedProject:D,sessions:b,sessionsTotal:v,sessionsLoading:C,searchLoading:F.loading,searchFilter:_,setSearchFilter:A,filteredSessions:L,fetchError:F.error??P,onSelectSession:e,onNewSession:t,creatingSession:s,onDuplicateSession:a,onDeleteSession:W,onBack:O,onRetryFetch:()=>{if(F.error){F.refresh();return}T(null),o&&R(o)},loadMoreSessions:M}):r.jsx(WD,{projects:d,activeSessions:f,loading:p,refreshing:g,searchFilter:_,setSearchFilter:A,fetchError:P,selectedProjectDirName:o??null,onSelectProject:i,onRefresh:()=>I(!0)})});async function av(n,e,t){return(await be(`/api/permissions/${encodeURIComponent(n)}/respond`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:e,behavior:t})})).ok}async function VD(n,e){return(await be(`/api/permissions/${encodeURIComponent(n)}/respond-all`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({behavior:e})})).ok}async function lv(n,e){try{const t=await be(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 GD(n,e,t){return lv("/api/elicitation-answer",{sessionId:n,requestId:e,...t})}function YD(n,e,t){return lv("/api/user-dialog-answer",{sessionId:n,requestId:e,choice:t})}const XD=3e3,cv=y.createContext(null);async function bc(n,e){try{const t=await be(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 Jo(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 Ui(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 JD({children:n}){const[e,t]=y.useState(new Map),[s,o]=y.useState(new Map),[i,a]=y.useState(new Map),[l,c]=y.useState(new Map),[d,u]=y.useState(new Set),[f,m]=y.useState(new Set),p=y.useRef(""),h=y.useRef(""),g=y.useRef(""),x=y.useCallback(async()=>{const[T,E,$]=await Promise.all([bc("/api/permissions",p),bc("/api/user-questions",h),bc("/api/agent-prompts",g)]);T&&(t(Jo(T.bySession)),u(new Set(Jo(T.plansBySession).keys()))),E&&o(Jo(E.bySession)),$&&(a(Jo($.elicitationsBySession)),c(Jo($.dialogsBySession)))},[]);y.useEffect(()=>{const T=()=>{document.visibilityState==="visible"&&x()};T();const E=setInterval(T,XD);return document.addEventListener("visibilitychange",T),()=>{clearInterval(E),document.removeEventListener("visibilitychange",T)}},[x]);const b=y.useCallback(async(T,E)=>{m($=>new Set($).add(T));try{return await E()}finally{m($=>{const I=new Set($);return I.delete(T),I}),x()}},[x]),w=y.useCallback((T,E,$)=>b(E,async()=>{await av(T,E,$).catch(()=>!1)&&(t(R=>Ui(R,T,D=>D.requestId===E)),p.current="")}),[b]),v=y.useCallback((T,E,$)=>b(E,async()=>{const I=await qd(T,E,$);return I.ok&&(o(R=>Ui(R,T,D=>D.toolUseId===E)),h.current=""),I}),[b]),S=y.useCallback((T,E,$)=>b(E,async()=>{const I=await GD(T,E,$);return I.ok&&(a(R=>Ui(R,T,D=>D.requestId===E)),g.current=""),I}),[b]),j=y.useCallback((T,E,$)=>b(E,async()=>{const I=await YD(T,E,$);return I.ok&&(c(R=>Ui(R,T,D=>D.requestId===E)),g.current=""),I}),[b]),k=y.useMemo(()=>new Set(e.keys()),[e]),C=y.useMemo(()=>new Set(s.keys()),[s]),N=y.useMemo(()=>new Set(i.keys()),[i]),_=y.useMemo(()=>new Set(l.keys()),[l]),A=y.useCallback(()=>{x()},[x]),P=y.useMemo(()=>({permissionsBySession:e,questionsBySession:s,elicitationsBySession:i,dialogsBySession:l,awaitingPermission:k,awaitingQuestion:C,awaitingElicitation:N,awaitingDialog:_,awaitingPlan:d,responding:f,respond:w,answerQuestion:v,answerElicitation:S,answerDialog:j,refresh:A}),[e,s,i,l,k,C,N,_,d,f,w,v,S,j,A]);return r.jsx(cv.Provider,{value:P,children:n})}function QD(){const n=y.useContext(cv);if(!n)throw new Error("usePendingHumanInput must be used within a PendingHumanInputProvider");return n}const Kh=768;function lf(){const n=B.c(2),[e,t]=y.useState(typeof window<"u"?window.innerWidth<Kh:!1);let s,o;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{const i=window.matchMedia(`(max-width: ${Kh-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]),y.useEffect(s,o),e}const dv=typeof navigator<"u"&&"vibrate"in navigator;function dd(){dv&&navigator.vibrate(10)}function ZD(){dv&&navigator.vibrate(20)}function eL(n){return!!(n.teamName&&n.agentName)}function tL(n,e,t,s,o,i,a){const l=[],c=[];for(const d of wu(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(eL(d))continue;const u=Q0(d,e);if(d.agentStatus==="completed"||!u){t.has(d.sessionId)&&l.push({session:d,reason:"done"});continue}if(d.agentStatus==="idle"){l.push({session:d,reason:"waiting"});continue}(!d.agentStatus||Su.has(d.agentStatus))&&c.push(d)}return{needsYou:l,working:c}}function nL(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 cf(n,e){return n?Gt(n).externalProcesses&&(e==null?void 0:e.managed)===!1:!1}const uv="aw:turnCounts",sL=200,yl=new Map;try{const n=localStorage.getItem(uv);if(n){const e=JSON.parse(n);for(const[t,s]of e)yl.set(t,s)}}catch{}function oL(){try{const n=[...yl.entries()].slice(-sL);localStorage.setItem(uv,JSON.stringify(n))}catch{}}function rL(n,e){yl.set(Vt(n),e),oL()}function iL(n,e){const t=yl.get(Vt(n));return Math.max(t??0,e??0)}function fv(n){const e=B.c(40),{session:t,proc:s,statusLabel:o,customName:i,worktreeName:a}=n,l=i||t.aiTitle,c=t.lastUserMessage||t.firstUserMessage,d=iL(t.sessionId,t.turnCount);let u;e[0]!==l?(u=l&&r.jsx("span",{className:"font-medium leading-snug text-foreground",children:l}),e[0]=l,e[1]=u):u=e[1];let f;e[2]!==t.agentStatus||e[3]!==o?(f=o&&r.jsx("span",{className:G("font-medium",af(t.agentStatus)),children:o}),e[2]=t.agentStatus,e[3]=o,e[4]=f):f=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(ss,{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(hl,{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(zn,{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(Ia,{className:"size-2.5"}),d," ",d===1?"turn":"turns"]}),e[15]=d,e[16]=x):x=e[16];let b;e[17]!==t.size?(b=vg(t.size),e[17]=t.size,e[18]=b):b=e[18];let w;e[19]!==b?(w=r.jsx("span",{children:b}),e[19]=b,e[20]=w):w=e[20];let v;e[21]!==s?(v=s&&r.jsxs("span",{className:"flex items-center gap-0.5 text-success",children:[r.jsx(Mw,{className:"size-2.5"}),s.memMB," MB"]}),e[21]=s,e[22]=v):v=e[22];const S=t.lastActivityAt||t.lastModified;let j;e[23]!==S?(j=Hr(S),e[23]=S,e[24]=j):j=e[24];let k;e[25]!==j?(k=r.jsx("span",{children:j}),e[25]=j,e[26]=k):k=e[26];let C;e[27]!==v||e[28]!==k||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,v,k]}),e[27]=v,e[28]=k,e[29]=g,e[30]=x,e[31]=w,e[32]=C):C=e[32];let N;return e[33]!==u||e[34]!==C||e[35]!==f||e[36]!==m||e[37]!==p||e[38]!==h?(N=r.jsxs("div",{className:"flex w-64 flex-col gap-2 text-xs",children:[u,f,m,p,h,C]}),e[33]=u,e[34]=C,e[35]=f,e[36]=m,e[37]=p,e[38]=h,e[39]=N):N=e[39],N}const aL=120;function mv(n){const e=B.c(7),t=y.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]),y.useEffect(s,o);let i;e[2]!==n?(i=()=>{n&&(t.current&&clearTimeout(t.current),t.current=setTimeout(n,aL))},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 lL=6;function cL(n){const e=B.c(7),{iso:t}=n,[,s]=y.useState(0);let o;e[0]!==s?(o=()=>{const c=setInterval(()=>s(dL),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],y.useEffect(o,i);let a;e[3]!==t?(a=Hr(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 dL(n){return n+1}const uL={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"}},fL={permission:Bs.attention,deferred:Bs.attention,waiting:Bs.attention,question:"bg-warning",prompt:"bg-warning",plan:"bg-warning",done:"bg-success"};function Vh(n){const e=B.c(76),{session:t,chip:s,dotClassName:o,cardClassName:i,isActiveSession:a,proc:l,killingPids:c,customName:d,projectLabel:u,compact:f,onSelect:m,onKill:p,onResume:h,onPrefetch:g}=n,x=f===void 0?!1:f;let b;e[0]!==l||e[1]!==t.dirName?(b=cf($t(t.dirName),l),e[0]=l,e[1]=t.dirName,e[2]=b):b=e[2];const w=b;let v;e[3]!==s||e[4]!==w||e[5]!==t.agentPendingAgents||e[6]!==t.agentStatus||e[7]!==t.agentTerminalReason||e[8]!==t.agentToolName?(v=w?"Read-only":ai(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]=v):v=e[9];const S=v,j=!!h&&!w,{onHoverStart:k,onHoverEnd:C}=mv(g),N=x?"px-2.5 py-2":"border px-2 py-2",_=a&&!x&&"ring-1 ring-ring";let A;e[10]!==i||e[11]!==N||e[12]!==_?(A=G("group relative w-full rounded-md text-left transition-colors",N,i,_),e[10]=i,e[11]=N,e[12]=_,e[13]=A):A=e[13];let P;e[14]!==x||e[15]!==a?(P=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]=P):P=e[16];const T=j&&"pr-20";let E;e[17]!==T?(E=G("w-full rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",T),e[17]=T,e[18]=E):E=e[18];let $;e[19]!==C||e[20]!==k||e[21]!==m||e[22]!==E?($=r.jsx("button",{type:"button","data-attention-session":!0,onClick:m,onMouseEnter:k,onMouseLeave:C,onFocus:k,onBlur:C,className:E}),e[19]=C,e[20]=k,e[21]=m,e[22]=E,e[23]=$):$=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 D;e[27]!==R?(D=r.jsx("span",{className:R,"aria-hidden":"true"}),e[27]=R,e[28]=D):D=e[28];let O;e[29]!==d||e[30]!==t?(O=X0(t,d),e[29]=d,e[30]=t,e[31]=O):O=e[31];let M;e[32]!==O?(M=r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs leading-tight text-foreground",children:O}),e[32]=O,e[33]=M):M=e[33];const F=x?"text-muted-foreground":s.className;let z;e[34]!==F?(z=G("shrink-0",F),e[34]=F,e[35]=z):z=e[35];const L=w?"Read-only":s.label;let W;e[36]!==z||e[37]!==L?(W=r.jsx(Pe,{variant:"outline",className:z,children:L}),e[36]=z,e[37]=L,e[38]=W):W=e[38];let U;e[39]!==x||e[40]!==t.lastActivityAt||e[41]!==t.lastModified?(U=!x&&r.jsx(cL,{iso:t.lastActivityAt||t.lastModified}),e[39]=x,e[40]=t.lastActivityAt,e[41]=t.lastModified,e[42]=U):U=e[42];let H;e[43]!==D||e[44]!==M||e[45]!==W||e[46]!==U?(H=r.jsxs("span",{className:"flex items-center gap-1.5",children:[D,M,W,U]}),e[43]=D,e[44]=M,e[45]=W,e[46]=U,e[47]=H):H=e[47];let K;e[48]!==u?(K=r.jsx("span",{className:"mt-1 block truncate pl-3 text-xs text-muted-foreground",children:u}),e[48]=u,e[49]=K):K=e[49];let V;e[50]!==$||e[51]!==H||e[52]!==K?(V=r.jsxs(Mt,{render:$,children:[H,K]}),e[50]=$,e[51]=H,e[52]=K,e[53]=V):V=e[53];let Y;e[54]!==d||e[55]!==l||e[56]!==t||e[57]!==S?(Y=r.jsx(Ot,{side:"right",className:"max-w-[280px]",children:r.jsx(fv,{session:t,proc:l,statusLabel:S,customName:d})}),e[54]=d,e[55]=l,e[56]=t,e[57]=S,e[58]=Y):Y=e[58];let q;e[59]!==V||e[60]!==Y?(q=r.jsxs(It,{children:[V,Y]}),e[59]=V,e[60]=Y,e[61]=q):q=e[61];let J;e[62]!==j||e[63]!==h?(J=j&&r.jsxs(ee,{type:"button",variant:"outline",size:"xs",onClick:h,className:"absolute bottom-1 right-1 text-warning","aria-label":"Resume to evaluate",children:[r.jsx(Dr,{"data-icon":"inline-start"}),"Resume"]}),e[62]=j,e[63]=h,e[64]=J):J=e[64];let Q;e[65]!==w||e[66]!==c||e[67]!==p||e[68]!==l?(Q=l&&p&&!w&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:Z=>p(l.pid,Z),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(nt,{"data-icon":"inline-start"})}),e[65]=w,e[66]=c,e[67]=p,e[68]=l,e[69]=Q):Q=e[69];let X;return e[70]!==q||e[71]!==J||e[72]!==Q||e[73]!==A||e[74]!==P?(X=r.jsxs("div",{className:A,children:[P,q,J,Q]}),e[70]=q,e[71]=J,e[72]=Q,e[73]=A,e[74]=P,e[75]=X):X=e[75],X}function mL(n){const e=B.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 u;e[9]!==i?(u=r.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:i}),e[9]=i,e[10]=u):u=e[10];let f;return e[11]!==l||e[12]!==d||e[13]!==u?(f=r.jsxs("div",{className:"flex items-center gap-1.5 px-0.5",children:[l,d,u]}),e[11]=l,e[12]=d,e[13]=u,e[14]=f):f=e[14],f}function pL(n){const e=B.c(27),{groups:t,activeSessionKey:s,procBySession:o,killingPids:i,sessionNames:a,projectNames:l,onSelectSession:c,onKill:d,onResumeSession:u,onPrefetchSession:f}=n,[m,p]=y.useState(!1);let h;e[0]!==t.working||e[1]!==m?(h=m?t.working:t.working.slice(0,lL),e[0]=t.working,e[1]=m,e[2]=h):h=e[2];const g=h,x=t.working.length-g.length;let b;e[3]!==l?(b=N=>l[N.dirName]||ju(N.cwd||_n(N.dirName)),e[3]=l,e[4]=b):b=e[4];const w=b;let v;e[5]!==s||e[6]!==i||e[7]!==f||e[8]!==c||e[9]!==o||e[10]!==w||e[11]!==a?(v=N=>{const _=s===`${N.dirName}/${N.fileName}`;return{session:N,isActiveSession:_,proc:o.get(N.sessionId),killingPids:i,customName:a[N.sessionId],projectLabel:w(N),onSelect:()=>c(N.dirName,N.fileName),onPrefetch:f&&!_?()=>f(N.dirName,N.fileName):void 0}},e[5]=s,e[6]=i,e[7]=f,e[8]=c,e[9]=o,e[10]=w,e[11]=a,e[12]=v):v=e[12];const S=v;let j;e[13]!==t.needsYou||e[14]!==d||e[15]!==u||e[16]!==S?(j=t.needsYou.length>0&&r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx(mL,{dotClassName:Bs.attention,labelClassName:"text-warning",label:"Needs you",count:t.needsYou.length}),t.needsYou.map(N=>{const{session:_,reason:A}=N;return r.jsx(Vh,{...S(_),chip:uL[A],dotClassName:fL[A],cardClassName:"border-warning/20 bg-warning/5 hover:bg-warning/10",onKill:d,onResume:A==="deferred"&&u?()=>u(_.sessionId,_.cwd,_.dirName):void 0},`${_.dirName}/${_.fileName}`)})]}),e[13]=t.needsYou,e[14]=d,e[15]=u,e[16]=S,e[17]=j):j=e[17];let k;e[18]!==t.working.length||e[19]!==x||e[20]!==d||e[21]!==S||e[22]!==g?(k=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(N=>r.jsx(Vh,{...S(N),chip:{label:nL(N),className:""},dotClassName:Bs.working,cardClassName:"hover:bg-accent/50",compact:!0,onKill:d},`${N.dirName}/${N.fileName}`))}),x>0&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>p(!0),className:"justify-start",children:[r.jsx(it,{"data-icon":"inline-start"}),"Show ",x," more"]})]}),e[18]=t.working.length,e[19]=x,e[20]=d,e[21]=S,e[22]=g,e[23]=k):k=e[23];let C;return e[24]!==j||e[25]!==k?(C=r.jsxs("div",{className:"flex flex-col gap-2","data-attention-strip":!0,children:[j,k]}),e[24]=j,e[25]=k,e[26]=C):C=e[26],C}function hL(n){const e=B.c(26),{loading:t,isMobile:s,searchQuery:o,searchLoading:i,onSearchQueryChange:a,onRefresh:l}=n;let c;e[0]!==a?(c=v=>a(v.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(cs,{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 u;e[6]!==i?(u=r.jsx(Pn,{align:"inline-start",children:i?r.jsx(rt,{className:"animate-spin"}):r.jsx(an,{})}),e[6]=i,e[7]=u):u=e[7];let f;e[8]!==a||e[9]!==o?(f=o&&r.jsx(Pn,{align:"inline-end",children:r.jsx(Qr,{size:"icon-xs",onClick:()=>a(""),"aria-label":"Clear session search",children:r.jsx(nt,{"data-icon":"inline-start"})})}),e[8]=a,e[9]=o,e[10]=f):f=e[10];let m;e[11]!==d||e[12]!==u||e[13]!==f?(m=r.jsxs(ls,{children:[d,u,f]}),e[11]=d,e[12]=u,e[13]=f,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(Pt,{"data-icon":"inline-start",className:g}),e[17]=g,e[18]=x):x=e[18];let b;e[19]!==l||e[20]!==p||e[21]!==x?(b=r.jsx(ee,{variant:"ghost",size:p,onClick:l,"aria-label":"Refresh sessions",children:x}),e[19]=l,e[20]=p,e[21]=x,e[22]=b):b=e[22];let w;return e[23]!==b||e[24]!==m?(w=r.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b px-2.5 py-2",children:[m,b]}),e[23]=b,e[24]=m,e[25]=w):w=e[25],w}const gL=["first","second","third","fourth","fifth"];function xL(n){const e=B.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(pt,{variant:"destructive",children:[r.jsx(gn,{}),r.jsx(Et,{children:"Could not load sessions"}),r.jsx(ht,{className:"truncate",children:t}),r.jsx(Cs,{children:r.jsx(ee,{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(ln,{className:"min-h-56 px-4 py-8",children:r.jsxs(cn,{children:[r.jsx(bn,{variant:"icon",children:o?r.jsx(an,{}):r.jsx(U1,{})}),r.jsx(dn,{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 u;e[6]!==i||e[7]!==a?(u=i&&a===0&&r.jsx("div",{className:"flex flex-col gap-2 px-2 py-4","aria-label":"Loading sessions",children:gL.map(bL)}),e[6]=i,e[7]=a,e[8]=u):u=e[8];let f;return e[9]!==c||e[10]!==d||e[11]!==u?(f=r.jsxs(r.Fragment,{children:[c,d,u]}),e[9]=c,e[10]=d,e[11]=u,e[12]=f):f=e[12],f}function bL(n){return r.jsxs("div",{className:"flex items-center gap-2 py-1",children:[r.jsx(ct,{className:"size-2 shrink-0 rounded-full"}),r.jsx(ct,{className:"h-4 flex-1"}),r.jsx(ct,{className:"h-4 w-10"})]},n)}function vL(n){var ge;const e=B.c(116),{session:t,isActiveSession:s,proc:o,killingPids:i,isNewlyCompleted:a,customName:l,worktreeName:c,teammateCount:d,teammatesCollapsed:u,onToggleTeammates:f,onSelectSession:m,onKill:p,onDuplicateSession:h,onDeleteSession:g,onRenameSession:x,onPrefetchSession:b,onResumeSession:w}=n,v=o!==void 0,S=t.isActive===!0,j=v||S,k=S&&Rr(t.agentStatus),C=t.agentStatus==="deferred";let N;e[0]!==o||e[1]!==t.dirName?(N=cf($t(t.dirName),o),e[0]=o,e[1]=t.dirName,e[2]=N):N=e[2];const _=N,[A,P]=y.useState(!1),T=_?"Read-only":j?k?"Running":ai(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??"Running":null,E=C?"attention":j?Rr(t.agentStatus)?"idle":"working":null,$=!!(t.teamName&&t.agentName);let I;e[3]!==l||e[4]!==t?(I=X0(t,l),e[3]=l,e[4]=t,e[5]=I):I=e[5];const R=I;let D;e[6]!==s||e[7]!==b||e[8]!==t.dirName||e[9]!==t.fileName?(D=b&&!s?()=>b(t.dirName,t.fileName):void 0,e[6]=s,e[7]=b,e[8]=t.dirName,e[9]=t.fileName,e[10]=D):D=e[10];const{onHoverStart:O,onHoverEnd:M}=mv(D);let F;e[11]!==w||e[12]!==A||e[13]!==t.cwd||e[14]!==t.dirName||e[15]!==t.sessionId?(F=pe=>{pe.stopPropagation(),!(!w||A)&&(P(!0),w(t.sessionId,t.cwd,t.dirName),setTimeout(()=>P(!1),3e3))},e[11]=w,e[12]=A,e[13]=t.cwd,e[14]=t.dirName,e[15]=t.sessionId,e[16]=F):F=e[16];const z=F;let L;e[17]!==v||e[18]!==s||e[19]!==S||e[20]!==a||e[21]!==t.agentStatus?(L=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",yL(s,!S&&v&&t.agentStatus==="completed"&&!!a)),e[17]=v,e[18]=s,e[19]=S,e[20]=a,e[21]=t.agentStatus,e[22]=L):L=e[22];const W=It,U=Mt;let H;e[23]!==m||e[24]!==t.dirName||e[25]!==t.fileName?(H=()=>m(t.dirName,t.fileName),e[23]=m,e[24]=t.dirName,e[25]=t.fileName,e[26]=H):H=e[26];let K;e[27]!==M||e[28]!==O||e[29]!==H?(K=r.jsx("button",{type:"button","data-live-session":!0,onClick:H,onMouseEnter:O,onMouseLeave:M,onFocus:O,onBlur:M,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]=M,e[28]=O,e[29]=H,e[30]=K):K=e[30];let V;e[31]!==E?(V=E&&r.jsx("span",{"data-status-dot":E,className:G("size-1.5 rounded-full",Bs[E])}),e[31]=E,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]!==$||e[38]!==t.agentName||e[39]!==R?(J=$&&r.jsxs(Pe,{variant:"outline",children:[r.jsx(No,{"data-icon":"inline-start"}),R!==t.agentName?t.agentName:"Agent"]}),e[37]=$,e[38]=t.agentName,e[39]=R,e[40]=J):J=e[40];const Q=j&&!C&&T&&r.jsx(Pe,{variant:"secondary","data-session-live-state":!0,className:G("shrink-0",k&&"text-success",!k&&af(t.agentStatus)),children:T});let X;e[41]!==C?(X=C&&r.jsx(Pe,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"deferred"}),e[41]=C,e[42]=X):X=e[42];let Z;e[43]!==c?(Z=c&&r.jsxs(Pe,{variant:"outline",children:[r.jsx(zn,{"data-icon":"inline-start"}),c]}),e[43]=c,e[44]=Z):Z=e[44];let te;e[45]!==U||e[46]!==q||e[47]!==J||e[48]!==Q||e[49]!==X||e[50]!==Z||e[51]!==K||e[52]!==Y?(te=r.jsxs(U,{render:K,children:[Y,q,J,Q,X,Z]}),e[45]=U,e[46]=q,e[47]=J,e[48]=Q,e[49]=X,e[50]=Z,e[51]=K,e[52]=Y,e[53]=te):te=e[53];let ne;e[54]!==l||e[55]!==o||e[56]!==t||e[57]!==T||e[58]!==c?(ne=r.jsx(Ot,{side:"right",className:"max-w-[280px]",children:r.jsx(fv,{session:t,proc:o,statusLabel:T,customName:l,worktreeName:c})}),e[54]=l,e[55]=o,e[56]=t,e[57]=T,e[58]=c,e[59]=ne):ne=e[59];let oe;e[60]!==W||e[61]!==te||e[62]!==ne?(oe=r.jsxs(W,{children:[te,ne]}),e[60]=W,e[61]=te,e[62]=ne,e[63]=oe):oe=e[63];let re;e[64]!==f||e[65]!==d||e[66]!==u?(re=!!d&&f&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:f,className:"shrink-0",title:u?"Show team agents":"Hide team agents","aria-label":u?`Show ${d} team agents`:`Hide ${d} team agents`,"aria-expanded":!u,children:[r.jsx(ss,{"data-icon":"inline-start"}),d,r.jsx(Xe,{"data-icon":"inline-end",className:G("transition-transform duration-150",!u&&"rotate-90")})]}),e[64]=f,e[65]=d,e[66]=u,e[67]=re):re=e[67];let ae;e[68]!==z||e[69]!==C||e[70]!==_||e[71]!==w||e[72]!==A?(ae=C&&w&&!_&&r.jsxs(ee,{type:"button",variant:"outline",size:"xs",onClick:z,disabled:A,className:"shrink-0 text-warning",title:"Resume to evaluate deferred permission","aria-label":"Resume to evaluate",children:[r.jsx(Dr,{"data-icon":"inline-start"}),"Resume"]}),e[68]=z,e[69]=C,e[70]=_,e[71]=w,e[72]=A,e[73]=ae):ae=e[73];let se;e[74]!==t.matchedPullRequestNumber||e[75]!==t.pullRequests?(se=t.matchedPullRequestNumber?r.jsxs(Pe,{variant:"outline",className:"shrink-0 px-1",children:["Matched #",t.matchedPullRequestNumber]}):r.jsx(hl,{pullRequests:t.pullRequests,max:1,compact:!0}),e[74]=t.matchedPullRequestNumber,e[75]=t.pullRequests,e[76]=se):se=e[76];const de=t.lastActivityAt||t.lastModified;let le;e[77]!==de?(le=Hr(de),e[77]=de,e[78]=le):le=e[78];let ce;e[79]!==le?(ce=r.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:le}),e[79]=le,e[80]=ce):ce=e[80];let me;e[81]!==v||e[82]!==_||e[83]!==i||e[84]!==p||e[85]!==o?(me=v&&p&&!_&&r.jsx(ee,{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(nt,{"data-icon":"inline-start"})}),e[81]=v,e[82]=_,e[83]=i,e[84]=p,e[85]=o,e[86]=me):me=e[86];let ue;e[87]!==oe||e[88]!==re||e[89]!==ae||e[90]!==se||e[91]!==ce||e[92]!==me||e[93]!==L?(ue=r.jsxs("div",{className:L,children:[oe,re,ae,se,ce,me]}),e[87]=oe,e[88]=re,e[89]=ae,e[90]=se,e[91]=ce,e[92]=me,e[93]=L,e[94]=ue):ue=e[94];const ie=ue;if(h||g||x){let pe;e[95]!==t.firstUserMessage||e[96]!==t.sessionId||e[97]!==t.slug?(pe=t.slug||((ge=t.firstUserMessage)==null?void 0:ge.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 xe;e[99]!==h||e[100]!==t.dirName||e[101]!==t.fileName?(xe=h?()=>h(t.dirName,t.fileName):void 0,e[99]=h,e[100]=t.dirName,e[101]=t.fileName,e[102]=xe):xe=e[102];let Ce;e[103]!==g||e[104]!==t?(Ce=g?()=>g(t):void 0,e[103]=g,e[104]=t,e[105]=Ce):Ce=e[105];let Te;e[106]!==x||e[107]!==t.sessionId?(Te=x?$e=>x(t.sessionId,$e):void 0,e[106]=x,e[107]=t.sessionId,e[108]=Te):Te=e[108];let Ee;return e[109]!==l||e[110]!==ie||e[111]!==pe||e[112]!==xe||e[113]!==Ce||e[114]!==Te?(Ee=r.jsx(qb,{sessionLabel:pe,customName:l,onDuplicate:xe,onDelete:Ce,onRename:Te,children:ie}),e[109]=l,e[110]=ie,e[111]=pe,e[112]=xe,e[113]=Ce,e[114]=Te,e[115]=Ee):Ee=e[115],Ee}return ie}function yL(n,e){return n?"bg-accent":e?"bg-success/10":"hover:bg-accent/60"}function wL(n,e){return n.reduce((t,s)=>s.isActive?t+1:e.has(s.sessionId)?s.agentStatus==="completed"?t:t+1:t,0)}function jL(n){const e=B.c(36),{grouped:t,pendingProjectPath:s,pendingSession:o,collapsedGroups:i,searchQuery:a,activeSessionKey:l,procBySession:c,killingPids:d,newlyCompleted:u,sessionNames:f,projectNames:m,onToggleCollapsed:p,onSelectSession:h,onKill:g,onDuplicateSession:x,onDeleteSession:b,onRenameSession:w,onRenameProject:v,onNewSession:S,creatingSession:j,onPrefetchSession:k,onResumeSession:C}=n;let N;e[0]!==l||e[1]!==j||e[2]!==d||e[3]!==u||e[4]!==b||e[5]!==x||e[6]!==g||e[7]!==S||e[8]!==k||e[9]!==v||e[10]!==w||e[11]!==C||e[12]!==h||e[13]!==p||e[14]!==c||e[15]!==m||e[16]!==f?(N={activeSessionKey:l,procBySession:c,killingPids:d,newlyCompleted:u,sessionNames:f,projectNames:m,onToggleCollapsed:p,onSelectSession:h,onKill:g,onDuplicateSession:x,onDeleteSession:b,onRenameSession:w,onRenameProject:v,onNewSession:S,creatingSession:j,onPrefetchSession:k,onResumeSession:C},e[0]=l,e[1]=j,e[2]=d,e[3]=u,e[4]=b,e[5]=x,e[6]=g,e[7]=S,e[8]=k,e[9]=v,e[10]=w,e[11]=C,e[12]=h,e[13]=p,e[14]=c,e[15]=m,e[16]=f,e[17]=N):N=e[17];const _=N;let A;e[18]!==a?(A=a.trim(),e[18]=a,e[19]=A):A=e[19];const P=!!A;let T;e[20]!==i||e[21]!==P||e[22]!==t||e[23]!==s||e[24]!==o||e[25]!==c||e[26]!==_?(T=[...t.entries()].map((I,R)=>{const[D,O]=I,M=wL(O,c);return y.createElement(Gh,{..._,key:D,projectPath:D,sessions:O,liveCount:M,collapsed:i[D]??(R>=3&&M===0),forceExpand:P,pendingSession:s===D?o:void 0})}),e[20]=i,e[21]=P,e[22]=t,e[23]=s,e[24]=o,e[25]=c,e[26]=_,e[27]=T):T=e[27];let E;e[28]!==t||e[29]!==s||e[30]!==o||e[31]!==_?(E=s&&!t.has(s)&&o&&y.createElement(Gh,{..._,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]=E):E=e[32];let $;return e[33]!==T||e[34]!==E?($=r.jsxs(r.Fragment,{children:[T,E]}),e[33]=T,e[34]=E,e[35]=$):$=e[35],$}function Gh(n){var ze,Ne;const e=B.c(99),{projectPath:t,sessions:s,activeSessionKey:o,procBySession:i,killingPids:a,newlyCompleted:l,sessionNames:c,projectNames:d,liveCount:u,collapsed:f,onToggleCollapsed:m,forceExpand:p,onSelectSession:h,onKill:g,onDuplicateSession:x,onDeleteSession:b,onRenameSession:w,onRenameProject:v,onNewSession:S,creatingSession:j,pendingSession:k,onPrefetchSession:C,onResumeSession:N}=n,_=p===void 0?!1:p,A=y.useId(),P=!!k,T=_||P?!1:f;let E;e[0]!==s?(E=new Set(s.map(NL)),e[0]=s,e[1]=E):E=e[1];const $=E;let I;if(e[2]!==$||e[3]!==s){const Se=new Map,he=[];for(const De of s){const Be=De.teamLeadSessionId;if(Be&&Be!==De.sessionId&&$.has(Be)){const We=Se.get(Be);We?We.push(De):Se.set(Be,[De])}else he.push(De)}I={topLevelSessions:he,teammatesByLead:Se},e[2]=$,e[3]=s,e[4]=I}else I=e[4];const{topLevelSessions:R,teammatesByLead:D}=I;let O;e[5]===Symbol.for("react.memo_cache_sentinel")?(O=new Set,e[5]=O):O=e[5];const[M,F]=y.useState(O);let z;e[6]===Symbol.for("react.memo_cache_sentinel")?(z=Se=>{F(he=>{const De=new Set(he);return De.has(Se)?De.delete(Se):De.add(Se),De})},e[6]=z):z=e[6];const L=z,[W,U]=y.useState(!1),H=s.length+(P?1:0);let K,V;e[7]!==_||e[8]!==P||e[9]!==i||e[10]!==W||e[11]!==R?(K=A7(R,i,Math.max(1,5-(P?1:0))),V=_||W?R:R.slice(0,K),e[7]=_,e[8]=P,e[9]=i,e[10]=W,e[11]=R,e[12]=K,e[13]=V):(K=e[12],V=e[13]);const Y=V,q=R.length-Y.length,J=W&&!_&&R.length>K,Q=((ze=s.find(SL))==null?void 0:ze.dirName)??((Ne=s[0])==null?void 0:Ne.dirName)??(k==null?void 0:k.dirName),X=Q?d[Q]:void 0;let Z;e[14]!==o||e[15]!==a||e[16]!==l||e[17]!==b||e[18]!==x||e[19]!==g||e[20]!==C||e[21]!==w||e[22]!==N||e[23]!==h||e[24]!==i||e[25]!==c?(Z=function(he,De,Be){return r.jsx(vL,{session:he,isActiveSession:o===`${he.dirName}/${he.fileName}`,proc:i.get(he.sessionId),killingPids:a,isNewlyCompleted:l.has(he.sessionId),customName:c[he.sessionId],worktreeName:De,teammateCount:Be==null?void 0:Be.count,teammatesCollapsed:Be==null?void 0:Be.collapsed,onToggleTeammates:Be==null?void 0:Be.onToggle,onSelectSession:h,onKill:g,onDuplicateSession:x,onDeleteSession:b,onRenameSession:w,onPrefetchSession:C,onResumeSession:N},`${he.dirName}/${he.fileName}`)},e[14]=o,e[15]=a,e[16]=l,e[17]=b,e[18]=x,e[19]=g,e[20]=C,e[21]=w,e[22]=N,e[23]=h,e[24]=i,e[25]=c,e[26]=Z):Z=e[26];const te=Z,ne=!T;let oe;e[27]!==Q||e[28]!==v?(oe=Se=>{Q&&v&&v(Q,Se)},e[27]=Q,e[28]=v,e[29]=oe):oe=e[29];let re;e[30]!==f||e[31]!==m||e[32]!==t?(re=()=>m(t,!f),e[30]=f,e[31]=m,e[32]=t,e[33]=re):re=e[33];const ae=!T,se=_?"Groups stay expanded while searching":void 0,de=!T&&"rotate-90";let le;e[34]!==de?(le=G("size-3 shrink-0 text-muted-foreground transition-transform duration-150",de),e[34]=de,e[35]=le):le=e[35];let ce;e[36]!==le?(ce=r.jsx(Xe,{className:le}),e[36]=le,e[37]=ce):ce=e[37];const me=X||t;let ue;e[38]!==me?(ue=r.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:me}),e[38]=me,e[39]=ue):ue=e[39];let ie;e[40]!==X||e[41]!==t?(ie=X&&r.jsx("span",{className:"truncate text-xs text-muted-foreground",children:t}),e[40]=X,e[41]=t,e[42]=ie):ie=e[42];let ge;e[43]!==u?(ge=u>0&&r.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs font-medium text-success","aria-label":`${u} live sessions`,children:[r.jsx(Wa,{className:"size-1.5","aria-hidden":"true"}),u]}),e[43]=u,e[44]=ge):ge=e[44];let pe;e[45]!==H?(pe=r.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:H}),e[45]=H,e[46]=pe):pe=e[46];let xe;e[47]!==_||e[48]!==A||e[49]!==re||e[50]!==ae||e[51]!==se||e[52]!==ce||e[53]!==ue||e[54]!==ie||e[55]!==ge||e[56]!==pe?(xe=r.jsxs("button",{type:"button",onClick:re,disabled:_,"aria-expanded":ae,"aria-controls":A,title:se,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:[ce,ue,ie,ge,pe]}),e[47]=_,e[48]=A,e[49]=re,e[50]=ae,e[51]=se,e[52]=ce,e[53]=ue,e[54]=ie,e[55]=ge,e[56]=pe,e[57]=xe):xe=e[57];let Ce;e[58]!==j||e[59]!==S||e[60]!==t||e[61]!==s[0]||e[62]!==s.length?(Ce=S&&s.length>0&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",className:"shrink-0",disabled:j,onClick:Se=>{Se.stopPropagation();const he=s[0];S(he.dirName,he.cwd??void 0)},"aria-label":`New session in ${t}`,children:j?r.jsx(rt,{"data-icon":"inline-start",className:"animate-spin"}):r.jsx(Fn,{"data-icon":"inline-start"})}),e[58]=j,e[59]=S,e[60]=t,e[61]=s[0],e[62]=s.length,e[63]=Ce):Ce=e[63];let Te;e[64]!==xe||e[65]!==Ce?(Te=r.jsxs("div",{className:"flex w-full items-center gap-1 px-2 pb-1 pt-3",children:[xe,Ce]}),e[64]=xe,e[65]=Ce,e[66]=Te):Te=e[66];let Ee;e[67]!==X||e[68]!==t||e[69]!==Te||e[70]!==oe?(Ee=r.jsx(nv,{projectLabel:t,customName:X,className:"sticky top-0 z-20 bg-background",onRename:oe,children:Te}),e[67]=X,e[68]=t,e[69]=Te,e[70]=oe,e[71]=Ee):Ee=e[71];let $e;e[72]!==k?($e=k&&r.jsx(kL,{firstMessage:k.firstMessage}),e[72]=k,e[73]=$e):$e=e[73];let Re;if(e[74]!==M||e[75]!==te||e[76]!==D||e[77]!==Y){let Se;e[79]!==M||e[80]!==te||e[81]!==D?(Se=he=>{const De=he.cwd??_n(he.dirName),Be=Fa(De),We=D.get(he.sessionId);if(!We)return te(he,Be==null?void 0:Be.worktreeName);const we=M.has(he.sessionId);return r.jsxs("div",{className:"flex flex-col gap-px",children:[te(he,Be==null?void 0:Be.worktreeName,{count:We.length,collapsed:we,onToggle:()=>L(he.sessionId)}),!we&&r.jsx("div",{className:"ml-3 flex flex-col gap-px border-l pl-1",children:We.map(Me=>te(Me))})]},`${he.dirName}/${he.fileName}`)},e[79]=M,e[80]=te,e[81]=D,e[82]=Se):Se=e[82],Re=Y.map(Se),e[74]=M,e[75]=te,e[76]=D,e[77]=Y,e[78]=Re}else Re=e[78];let Fe;e[83]!==q?(Fe=q>0&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>U(!0),className:"justify-start",children:[r.jsx(it,{"data-icon":"inline-start"}),"Show ",q," more"]}),e[83]=q,e[84]=Fe):Fe=e[84];let Le;e[85]!==J?(Le=J&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>U(!1),className:"justify-start",children:[r.jsx(Ir,{"data-icon":"inline-start"}),"Show less"]}),e[85]=J,e[86]=Le):Le=e[86];let Ie;e[87]!==$e||e[88]!==Re||e[89]!==Fe||e[90]!==Le?(Ie=r.jsxs("div",{className:"flex flex-col gap-px",children:[$e,Re,Fe,Le]}),e[87]=$e,e[88]=Re,e[89]=Fe,e[90]=Le,e[91]=Ie):Ie=e[91];let _e;e[92]!==A||e[93]!==Ie?(_e=r.jsx(mt,{id:A,className:"ml-3 border-l pl-1",children:Ie}),e[92]=A,e[93]=Ie,e[94]=_e):_e=e[94];let je;return e[95]!==Ee||e[96]!==_e||e[97]!==ne?(je=r.jsxs(ft,{open:ne,className:"flex flex-col",children:[Ee,_e]}),e[95]=Ee,e[96]=_e,e[97]=ne,e[98]=je):je=e[98],je}function SL(n){return!Fa(n.cwd??_n(n.dirName))}function NL(n){return n.sessionId}function kL(n){const e=B.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 CL=y.memo(function(e){const t=B.c(122),{activeSessionKey:s,onSelectSession:o,onDuplicateSession:i,onDeleteSession:a,onNewSession:l,creatingSession:c,pendingSession:d,refreshRef:u,onPrefetchSession:f}=e,{names:m,rename:p}=Gb(),{names:h,rename:g}=rv(),x=Vd(),b=An("terminal"),w=An("killAny"),{sessions:v,procBySession:S,newlyCompleted:j,loading:k,error:C,refresh:N,removeSession:_,acknowledgeCompleted:A}=r2(),{awaitingPermission:P,awaitingQuestion:T,awaitingElicitation:E,awaitingDialog:$,awaitingPlan:I}=QD();let R;t[0]!==$||t[1]!==E?(R=new Set([...E,...$]),t[0]=$,t[1]=E,t[2]=R):R=t[2];const D=R;let O;t[3]===Symbol.for("react.memo_cache_sentinel")?(O=new Set,t[3]=O):O=t[3];const[M,F]=y.useState(O),[z,L]=y.useState("");let W,U;t[4]===Symbol.for("react.memo_cache_sentinel")?(W=Vt("live-sessions-collapsed-projects"),U={},t[4]=W,t[5]=U):(W=t[4],U=t[5]);const[H,K]=oi(W,U);let V;t[6]!==K?(V=(Ve,et)=>{K(xt=>({...xt,[Ve]:et}))},t[6]=K,t[7]=V):V=t[7];const Y=V,q=y.useRef(v);let J;t[8]===Symbol.for("react.memo_cache_sentinel")?(J=new Set,t[8]=J):J=t[8];const Q=y.useRef(J),X=y.useRef(!1);let Z;t[9]===Symbol.for("react.memo_cache_sentinel")?(Z=(Ve,et)=>{if(!X.current)return;const xt=setTimeout(()=>{Q.current.delete(xt),X.current&&Ve()},et);Q.current.add(xt)},t[9]=Z):Z=t[9];const te=Z;let ne,oe;t[10]===Symbol.for("react.memo_cache_sentinel")?(ne=()=>{const Ve=Q.current;return X.current=!0,()=>{X.current=!1;for(const et of Ve)clearTimeout(et);Ve.clear()}},oe=[],t[10]=ne,t[11]=oe):(ne=t[10],oe=t[11]),y.useEffect(ne,oe);let re,ae;t[12]!==v?(re=()=>{q.current=v},ae=[v],t[12]=v,t[13]=re,t[14]=ae):(re=t[13],ae=t[14]),y.useEffect(re,ae);let se,de;t[15]!==N||t[16]!==u?(se=()=>{if(u)return u.current=N,()=>{u.current===N&&(u.current=null)}},de=[N,u],t[15]=N,t[16]=u,t[17]=se,t[18]=de):(se=t[17],de=t[18]),y.useEffect(se,de);const le=lf(),ce=iv(z);let me;e:{if(!z.trim()){me=v;break e}let Ve;if(t[19]!==h||t[20]!==z||t[21]!==m||t[22]!==v){let et;t[24]!==h||t[25]!==z||t[26]!==m?(et=xt=>{const zt=m[xt.sessionId],Yn=h[xt.dirName];return Zb(xt,z,[zt,Yn])},t[24]=h,t[25]=z,t[26]=m,t[27]=et):et=t[27],Ve=v.filter(et),t[19]=h,t[20]=z,t[21]=m,t[22]=v,t[23]=Ve}else Ve=t[23];me=Ve}const ue=me,ie=ce.results??ue;let ge;t[28]!==ie?(ge=E7(ie),t[28]=ie,t[29]=ge):ge=t[29];const pe=ge;let xe;t[30]!==P||t[31]!==I||t[32]!==D||t[33]!==T||t[34]!==j||t[35]!==S||t[36]!==v?(xe=tL(v,S,j,P,T,D,I),t[30]=P,t[31]=I,t[32]=D,t[33]=T,t[34]=j,t[35]=S,t[36]=v,t[37]=xe):xe=t[37];const Ce=xe,Te=Ce.needsYou.length>0||Ce.working.length>0;let Ee;t[38]!==Te||t[39]!==z?(Ee=!z.trim()&&Te,t[38]=Te,t[39]=z,t[40]=Ee):Ee=t[40];const $e=Ee;let Re;e:{if(!d){Re=null;break e}let Ve;t[41]!==d.cwd||t[42]!==d.dirName?(Ve=d.cwd||_n(d.dirName),t[41]=d.cwd,t[42]=d.dirName,t[43]=Ve):Ve=t[43];let et;t[44]!==Ve?(et=ju(Ve),t[44]=Ve,t[45]=et):et=t[45],Re=et}const Fe=Re,Le=y.useRef(!1);let Ie,_e;t[46]!==f||t[47]!==v?(Ie=()=>{if(Le.current||!f||v.length===0)return;Le.current=!0;const Ve=wu(v).slice(0,3),et=globalThis,xt=()=>{for(const Zs of Ve)f(Zs.dirName,Zs.fileName)};let zt=null,Yn=null;return typeof et.requestIdleCallback=="function"?zt=et.requestIdleCallback(xt,{timeout:1500}):Yn=setTimeout(xt,300),()=>{zt!=null&&typeof et.cancelIdleCallback=="function"&&et.cancelIdleCallback(zt),Yn!=null&&clearTimeout(Yn)}},_e=[v,f],t[46]=f,t[47]=v,t[48]=Ie,t[49]=_e):(Ie=t[48],_e=t[49]),y.useEffect(Ie,_e);let je;t[50]!==N?(je=async(Ve,et)=>{et.stopPropagation(),F(xt=>new Set(xt).add(Ve));try{await be("/api/kill-process",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pid:Ve})}),te(N,1500)}catch{}te(()=>{F(xt=>{const zt=new Set(xt);return zt.delete(Ve),zt})},2e3)},t[50]=N,t[51]=je):je=t[51];const ze=je;let Ne;t[52]!==A||t[53]!==o?(Ne=(Ve,et)=>{const xt=q.current.find(zt=>zt.dirName===Ve&&zt.fileName===et);xt&&A(xt.sessionId),o(Ve,et)},t[52]=A,t[53]=o,t[54]=Ne):Ne=t[54];const Se=Ne;let he;t[55]!==a||t[56]!==_?(he=Ve=>{a==null||a(Ve.dirName,Ve.fileName),_(Ve.sessionId)},t[55]=a,t[56]=_,t[57]=he):he=t[57];const De=he;let Be;t[58]!==N||t[59]!==x?(Be=(Ve,et,xt)=>{const{command:zt,args:Yn}=tj($t(xt),Ve),Zs=`resume_${crypto.randomUUID().slice(0,8)}`;x.send({type:"spawn",id:Zs,name:`Resume ${Ve.slice(0,8)}`,command:zt,args:Yn,cwd:et??void 0,metadata:{type:"terminal"}}),te(N,3e3)},t[58]=N,t[59]=x,t[60]=Be):Be=t[60];const We=Be;let we;t[61]!==N?(we=()=>{ZD(),N()},t[61]=N,t[62]=we):we=t[62];let Me;t[63]!==le||t[64]!==k||t[65]!==ce.loading||t[66]!==z||t[67]!==we?(Me=r.jsx(hL,{loading:k,isMobile:le,searchQuery:z,searchLoading:ce.loading,onSearchQueryChange:L,onRefresh:we}),t[63]=le,t[64]=k,t[65]=ce.loading,t[66]=z,t[67]=we,t[68]=Me):Me=t[68];const fe=ce.error??C,ve=ie.length===0&&!d&&!k&&!ce.loading&&!C&&!ce.error;let Oe;t[69]!==z?(Oe=z.trim(),t[69]=z,t[70]=Oe):Oe=t[70];const Ue=!!Oe,Ke=k||ce.loading,Ze=ce.active?ie.length:v.length,He=ce.error?ce.refresh:N;let Ye;t[71]!==fe||t[72]!==ve||t[73]!==Ue||t[74]!==Ke||t[75]!==Ze||t[76]!==He?(Ye=r.jsx(xL,{fetchError:fe,showEmpty:ve,searching:Ue,loading:Ke,sessionCount:Ze,onRetry:He}),t[71]=fe,t[72]=ve,t[73]=Ue,t[74]=Ke,t[75]=Ze,t[76]=He,t[77]=Ye):Ye=t[77];let At;t[78]!==s||t[79]!==Ce||t[80]!==w||t[81]!==b||t[82]!==ze||t[83]!==We||t[84]!==Se||t[85]!==M||t[86]!==f||t[87]!==S||t[88]!==h||t[89]!==m||t[90]!==$e?(At=$e&&r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx(pL,{groups:Ce,activeSessionKey:s,procBySession:S,killingPids:M,sessionNames:m,projectNames:h,onSelectSession:Se,onKill:w?ze:void 0,onResumeSession:b?We:void 0,onPrefetchSession:f}),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(Nt,{className:"flex-1"})]})]}),t[78]=s,t[79]=Ce,t[80]=w,t[81]=b,t[82]=ze,t[83]=We,t[84]=Se,t[85]=M,t[86]=f,t[87]=S,t[88]=h,t[89]=m,t[90]=$e,t[91]=At):At=t[91];const Vn=w?ze:void 0,qt=a?De:void 0,Xt=b?We:void 0;let Gn;t[92]!==s||t[93]!==H||t[94]!==c||t[95]!==pe||t[96]!==Se||t[97]!==M||t[98]!==j||t[99]!==i||t[100]!==l||t[101]!==f||t[102]!==Fe||t[103]!==d||t[104]!==S||t[105]!==h||t[106]!==g||t[107]!==p||t[108]!==z||t[109]!==m||t[110]!==Vn||t[111]!==qt||t[112]!==Xt||t[113]!==Y?(Gn=r.jsx(jL,{grouped:pe,pendingProjectPath:Fe,pendingSession:d,collapsedGroups:H,searchQuery:z,activeSessionKey:s,procBySession:S,killingPids:M,newlyCompleted:j,sessionNames:m,projectNames:h,onToggleCollapsed:Y,onSelectSession:Se,onKill:Vn,onDuplicateSession:i,onDeleteSession:qt,onRenameSession:p,onRenameProject:g,onNewSession:l,creatingSession:c,onPrefetchSession:f,onResumeSession:Xt}),t[92]=s,t[93]=H,t[94]=c,t[95]=pe,t[96]=Se,t[97]=M,t[98]=j,t[99]=i,t[100]=l,t[101]=f,t[102]=Fe,t[103]=d,t[104]=S,t[105]=h,t[106]=g,t[107]=p,t[108]=z,t[109]=m,t[110]=Vn,t[111]=qt,t[112]=Xt,t[113]=Y,t[114]=Gn):Gn=t[114];let Kt;t[115]!==Ye||t[116]!==At||t[117]!==Gn?(Kt=r.jsx(qn,{className:"flex-1",children:r.jsxs("div",{className:"flex flex-col gap-4 p-2",children:[Ye,At,Gn]})}),t[115]=Ye,t[116]=At,t[117]=Gn,t[118]=Kt):Kt=t[118];let Rs;return t[119]!==Me||t[120]!==Kt?(Rs=r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[Me,Kt]}),t[119]=Me,t[120]=Kt,t[121]=Rs):Rs=t[121],Rs}),_L=y.memo(function(e){const t=B.c(16),{activeSessionKey:s,onSelectSession:o,onNewSession:i,creatingSession:a,isMobile:l,onDuplicateSession:c,onDeleteSession:d,pendingSession:u,liveSessionsRefreshRef:f,onPrefetchSession:m,header:p}=e,h=l?"w-full":"w-80";let g;t[0]!==h?(g=G("flex h-full shrink-0 flex-col bg-sidebar",h),t[0]=h,t[1]=g):g=t[1];let x;t[2]!==s||t[3]!==a||t[4]!==f||t[5]!==d||t[6]!==c||t[7]!==i||t[8]!==m||t[9]!==o||t[10]!==u?(x=r.jsx(CL,{activeSessionKey:s,onSelectSession:o,onDuplicateSession:c,onDeleteSession:d,onNewSession:i,creatingSession:a,pendingSession:u,refreshRef:f,onPrefetchSession:m}),t[2]=s,t[3]=a,t[4]=f,t[5]=d,t[6]=c,t[7]=i,t[8]=m,t[9]=o,t[10]=u,t[11]=x):x=t[11];let b;return t[12]!==p||t[13]!==g||t[14]!==x?(b=r.jsxs("aside",{className:g,"aria-label":"Session browser",children:[p,x]}),t[12]=p,t[13]=g,t[14]=x,t[15]=b):b=t[15],b}),TL=y.lazy(()=>qe(()=>import("./index-De7cnbso.js"),__vite__mapDeps([34,1,2,3,4])).then(n=>({default:n.MissionControl})));function pv(n){const e=B.c(3),{label:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(st,{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 hv(n){const e=B.c(12),{navigation:t,mobile:s,header:o}=n,i=s===void 0?!1:s,{sessionSource:a}=at(),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(_L,{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 gv(n){const e=B.c(8),{navigation:t}=n,{state:s}=Ht();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(KD,{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 EL(n){const e=B.c(3),{navigation:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(pv,{label:"Loading Mission Control…"}),e[0]=s):s=e[0];let o;return e[1]!==t.actions.handleDashboardSelect?(o=r.jsx(y.Suspense,{fallback:s,children:r.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 flex-col",children:r.jsx(TL,{onSelectSession:t.actions.handleDashboardSelect})})}),e[1]=t.actions.handleDashboardSelect,e[2]=o):o=e[2],o}function AL({mainView:n,hasSession:e,pendingDirName:t}){return n==="config"?"config":n==="mission"?"mission":e?"session":t?"pending":"dashboard"}function PL({sessionCwd:n,pendingPath:e,sessionDirPath:t,dashboardProjectPath:s}){return n??e??t??s??null}function $L({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}
|
|
134
|
+
`:""}${n} (${a})
|
|
135
|
+
${i}
|
|
136
|
+
${e}
|
|
137
|
+
${i}`}const RL=y.lazy(()=>qe(()=>import("./ConfigBrowser-DcRITnFh.js"),__vite__mapDeps([35,1,2,31,3,4])).then(n=>({default:n.ConfigBrowser}))),IL=y.lazy(()=>qe(()=>import("./PreviewPanel-B8DbD395.js"),__vite__mapDeps([36,1,2,3,4])).then(n=>({default:n.PreviewPanel})));function ML(n){const e=B.c(20),{sessionView:t,floatingChrome:s}=n,{session:o}=at();if(!o)return null;let i;e[0]!==t.teamMembersBar?(i=t.teamMembersBar&&r.jsx("div",{className:"pt-10",children:t.teamMembersBar}),e[0]=t.teamMembersBar,e[1]=i):i=e[1];const a=!!t.todoProgress&&t.todosExpanded;let l;e[2]!==t.hasMoreTurns||e[3]!==t.isLoadingOlderTurns||e[4]!==t.onLoadMoreTurns||e[5]!==t.searchInputRef||e[6]!==a?(l=r.jsx(dl,{searchInputRef:t.searchInputRef,hasTodos:a,hasMore:t.hasMoreTurns,isLoadingOlder:t.isLoadingOlderTurns,onLoadMore:t.onLoadMoreTurns}),e[2]=t.hasMoreTurns,e[3]=t.isLoadingOlderTurns,e[4]=t.onLoadMoreTurns,e[5]=t.searchInputRef,e[6]=a,e[7]=l):l=e[7];let c;e[8]!==t.onTodosExpandedChange||e[9]!==t.todoProgress||e[10]!==t.todosExpanded?(c=t.todoProgress&&r.jsx(D0,{progress:t.todoProgress,expanded:t.todosExpanded,onExpandedChange:t.onTodosExpandedChange}),e[8]=t.onTodosExpandedChange,e[9]=t.todoProgress,e[10]=t.todosExpanded,e[11]=c):c=e[11];let d;e[12]!==t.activeComposer||e[13]!==c?(d=r.jsxs(vl,{floating:!0,children:[c,t.activeComposer]}),e[12]=t.activeComposer,e[13]=c,e[14]=d):d=e[14];let u;return e[15]!==s||e[16]!==i||e[17]!==l||e[18]!==d?(u=r.jsx("div",{className:"flex min-h-0 flex-1 bg-background",children:r.jsxs("div",{className:"relative flex h-full min-h-0 flex-1 flex-col",children:[s,i,l,d]})}),e[15]=s,e[16]=i,e[17]=l,e[18]=d,e[19]=u):u=e[19],u}function OL(n){const e=B.c(36),{navigation:t,sessionView:s,project:o,view:i,floatingChrome:a}=n,{state:l}=Ht(),{session:c,sessionSource:d}=at();let u,f;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){f=Symbol.for("react.early_return_sentinel");e:if(u=l.pendingCwd??(l.pendingDirName?_n(l.pendingDirName):null),i==="config"){let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(pv,{label:"Loading configuration…"}),e[9]=p):p=e[9];const h=r.jsx(RL,{projectPath:PL({sessionCwd:c==null?void 0:c.cwd,pendingPath:u,sessionDirPath:d!=null&&d.dirName?_n(d.dirName):null,dashboardProjectPath:l.dashboardProject?_n(l.dashboardProject):null}),initialFilePath:l.configFilePath});let g;e[10]!==h?(g=r.jsx(y.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],f=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]=u,e[8]=f}else u=e[7],f=e[8];if(f!==Symbol.for("react.early_return_sentinel"))return f;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(EL,{navigation:t})}),e[12]=t,e[13]=p):p=e[13],p}if(i==="session"){let p;return e[14]!==a||e[15]!==s?(p=r.jsx(ML,{sessionView:s,floatingChrome:a}),e[14]=a,e[15]=s,e[16]=p):p=e[16],p}if(i==="pending"){const p=s.pendingTurns.length>0,h=Ws()?"Only on the machine running this session":void 0;let g;e[17]===Symbol.for("react.memo_cache_sentinel")?(g=ou()?void 0:h,e[17]=g):g=e[17];const x=g,b=!p&&"justify-center gap-4";let w;e[18]!==b?(w=G("flex min-h-0 min-w-0 flex-1 flex-col bg-background",b),e[18]=b,e[19]=w):w=e[19];let v;e[20]!==p||e[21]!==u||e[22]!==s.pendingTurns?(v=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(Hb,{projectPath:u}),e[20]=p,e[21]=u,e[22]=s.pendingTurns,e[23]=v):v=e[23];let S;e[24]!==s.pendingComposer?(S=r.jsx(vl,{children:s.pendingComposer}),e[24]=s.pendingComposer,e[25]=S):S=e[25];let j;e[26]!==p||e[27]!==o?(j=!p&&r.jsxs("div",{className:"flex items-center justify-center gap-2",children:[ot("terminal")&&r.jsx(oc,{reason:h,children:r.jsxs(ee,{variant:"outline",size:"xs",disabled:!!h,onClick:o.onOpenTerminal,children:[r.jsx(Gs,{"data-icon":"inline-start"}),"Terminal"]})}),ot("hostFiles")&&r.jsxs(r.Fragment,{children:[r.jsx(oc,{reason:x,children:r.jsxs(ee,{variant:"outline",size:"xs",disabled:!!x,onClick:()=>px(o.pendingProject),children:[r.jsx(Ca,{"data-icon":"inline-start"}),"Open in editor"]})}),r.jsx(oc,{reason:h,children:r.jsxs(ee,{variant:"outline",size:"xs",disabled:!!h,onClick:()=>hx(o.pendingProject),children:[r.jsx(z1,{"data-icon":"inline-start"}),"Reveal in files"]})})]})]}),e[26]=p,e[27]=o,e[28]=j):j=e[28];let k;return e[29]!==w||e[30]!==v||e[31]!==S||e[32]!==j?(k=r.jsxs("div",{className:w,children:[v,S,j]}),e[29]=w,e[30]=v,e[31]=S,e[32]=j,e[33]=k):k=e[33],k}let m;return e[34]!==t?(m=r.jsx(gv,{navigation:t}),e[34]=t,e[35]=m):m=e[35],m}function DL(n){const e=B.c(104),{navigation:t,sessionView:s,project:o,chrome:i}=n,{state:a,config:l}=Ht(),{session:c,sessionSource:d}=at();let u;e[0]!==s.chatInputRef?(u=function(le){var me,ue,ie;const ce=((me=s.chatInputRef.current)==null?void 0:me.getText().trimEnd())??"";(ue=s.chatInputRef.current)==null||ue.setText(ce?`${ce}
|
|
138
|
+
|
|
139
|
+
${le}
|
|
140
|
+
`:`${le}
|
|
141
|
+
`),(ie=s.chatInputRef.current)==null||ie.focus()},e[0]=s.chatInputRef,e[1]=u):u=e[1];const f=u;let m;e[2]!==f?(m=function(le){const{path:ce,text:me,startLine:ue,endLine:ie,comment:ge}=le;f($L({path:ce,text:me,startLine:ue,endLine:ie,comment:ge}))},e[2]=f,e[3]=m):m=e[3];const p=m,h=a.mainView,g=!!c;let x;e[4]!==a.mainView||e[5]!==a.pendingDirName||e[6]!==g?(x=AL({mainView:h,hasSession:g,pendingDirName:a.pendingDirName}),e[4]=a.mainView,e[5]=a.pendingDirName,e[6]=g,e[7]=x):x=e[7];const b=x,w=t.panels.handleToggleSidebar,v=t.actions.handleGoHome,S=i.onOpenCommandPalette;let j,k;e[8]===Symbol.for("react.memo_cache_sentinel")?(k=nc("toggleSidebar"),j=nc("commandPalette"),e[8]=j,e[9]=k):(j=e[8],k=e[9]);let C;e[10]!==i.onOpenCommandPalette||e[11]!==t.actions.handleGoHome||e[12]!==t.panels.handleToggleSidebar?(C=r.jsx(vR,{onToggleSidebar:w,onGoHome:v,onOpenCommandPalette:S,sidebarShortcut:k,commandPaletteShortcut:j}),e[10]=i.onOpenCommandPalette,e[11]=t.actions.handleGoHome,e[12]=t.panels.handleToggleSidebar,e[13]=C):C=e[13];const N=C,_=t.panels.showSidebar&&a.mainView!=="config",A=o.currentCwd??null;let P,T,E;e[14]!==f||e[15]!==t.handlers.handleLoadSessionScrollAware||e[16]!==t.panels.activeWorkspacePanel||e[17]!==o.hasFileChanges||e[18]!==o.supportsWorktrees||e[19]!==c||e[20]!==a.mainView||e[21]!==a.sessionChangeKey||e[22]!==A?(P={session:c,sessionChangeKey:a.sessionChangeKey,projectPath:A,hasFileChanges:o.hasFileChanges,canAccessHostFiles:ot("hostFiles"),supportsWorktrees:o.supportsWorktrees,openSession:t.handlers.handleLoadSessionScrollAware,composePrompt:f},E=hb(fD,P),T=a.mainView==="sessions"?E.find(de=>de.id===t.panels.activeWorkspacePanel):null,e[14]=f,e[15]=t.handlers.handleLoadSessionScrollAware,e[16]=t.panels.activeWorkspacePanel,e[17]=o.hasFileChanges,e[18]=o.supportsWorktrees,e[19]=c,e[20]=a.mainView,e[21]=a.sessionChangeKey,e[22]=A,e[23]=P,e[24]=T,e[25]=E):(P=e[23],T=e[24],E=e[25]);const $=T,I=(d==null?void 0:d.dirName)??a.pendingDirName??a.dashboardProject??null;let R;e[26]!==t.panels||e[27]!==o?(R=function(le){o.showPreview&&o.onCloseRightWorkspace(),t.panels.toggleWorkspacePanel(le)},e[26]=t.panels,e[27]=o,e[28]=R):R=e[28];const D=R;let O;e[29]!==t.panels||e[30]!==o?(O=function(le){o.showPreview&&o.onCloseRightWorkspace(),t.panels.openWorkspacePanel(le)},e[29]=t.panels,e[30]=o,e[31]=O):O=e[31];const M=O;let F;e[32]!==t.actions||e[33]!==t.panels||e[34]!==I?(F=function(le){I&&(t.actions.handleDashboardSelect(I,`${le}.jsonl`),t.panels.closeWorkspacePanel())},e[32]=t.actions,e[33]=t.panels,e[34]=I,e[35]=F):F=e[35];const z=F,L=t.panels.showSidebar;let W;e[36]===Symbol.for("react.memo_cache_sentinel")?(W=nc("toggleSidebar"),e[36]=W):W=e[36];let U;e[37]!==i.killing||e[38]!==i.onKillAll||e[39]!==l.openConfigDialog||e[40]!==t.creatingSession||e[41]!==t.handlers.handleDuplicateSession||e[42]!==t.onStartNewSession||e[43]!==t.panels.handleToggleSidebar||e[44]!==t.panels.showSidebar||e[45]!==o.onOpenTerminal||e[46]!==s.onBackToMain||e[47]!==s.onShowWorkflows||e[48]!==s.workflowCount||e[49]!==_?(U=r.jsx(gR,{showSidebar:L,sidebarRendered:_,sidebarShortcut:W,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,onKillAll:i.onKillAll,onOpenSettings:l.openConfigDialog}),e[37]=i.killing,e[38]=i.onKillAll,e[39]=l.openConfigDialog,e[40]=t.creatingSession,e[41]=t.handlers.handleDuplicateSession,e[42]=t.onStartNewSession,e[43]=t.panels.handleToggleSidebar,e[44]=t.panels.showSidebar,e[45]=o.onOpenTerminal,e[46]=s.onBackToMain,e[47]=s.onShowWorkflows,e[48]=s.workflowCount,e[49]=_,e[50]=U):U=e[50];const H=U;let K;e[51]!==t||e[52]!==N||e[53]!==_?(K=_&&r.jsx("div",{className:"view-transition-sidebar panel-enter w-80 shrink-0 border-r bg-sidebar text-sidebar-foreground",children:r.jsx(hv,{navigation:t,header:N})}),e[51]=t,e[52]=N,e[53]=_,e[54]=K):K=e[54];const V=$??null,Y=o.projectFilesRoot??o.currentCwd??null;let q;e[55]!==p||e[56]!==t.actions.handleJumpToTurn||e[57]!==t.handlers.handleLoadSessionScrollAware||e[58]!==z||e[59]!==o.backgroundAgents||e[60]!==o.processPanel.handleServersChanged||e[61]!==o.processPanel.handleToggleServer||e[62]!==o.projectFilesRequest||e[63]!==o.worktrees||e[64]!==s.searchInputRef||e[65]!==Y||e[66]!==I?(q={projectFilesRoot:Y,projectFilesRequest:o.projectFilesRequest,backgroundAgents:o.backgroundAgents,searchInputRef:s.searchInputRef,addProjectContext:p,jumpToTurn:t.actions.handleJumpToTurn,toggleServer:o.processPanel.handleToggleServer,serversChanged:o.processPanel.handleServersChanged,loadSession:t.handlers.handleLoadSessionScrollAware,worktrees:o.worktrees,worktreeDirName:I,openWorktreeSession:z},e[55]=p,e[56]=t.actions.handleJumpToTurn,e[57]=t.handlers.handleLoadSessionScrollAware,e[58]=z,e[59]=o.backgroundAgents,e[60]=o.processPanel.handleServersChanged,e[61]=o.processPanel.handleToggleServer,e[62]=o.projectFilesRequest,e[63]=o.worktrees,e[64]=s.searchInputRef,e[65]=Y,e[66]=I,e[67]=q):q=e[67];const J=a.mainView==="mission";let Q;e[68]!==t.panels.handleToggleMission||e[69]!==J?(Q={id:"mission-control",title:"Mission Control",icon:Ow,active:J,onSelect:t.panels.handleToggleMission},e[68]=t.panels.handleToggleMission,e[69]=J,e[70]=Q):Q=e[70];let X;e[71]!==t.panels.handleToggleConfig||e[72]!==a.mainView?(X=ot("configWrite")?[{id:"config",title:"Config",icon:Dw,active:a.mainView==="config",onSelect:t.panels.handleToggleConfig}]:[],e[71]=t.panels.handleToggleConfig,e[72]=a.mainView,e[73]=X):X=e[73];let Z;e[74]!==Q||e[75]!==X?(Z=[Q,...X],e[74]=Q,e[75]=X,e[76]=Z):Z=e[76];const te=b!=="session"&&H;let ne;e[77]!==H||e[78]!==t||e[79]!==o||e[80]!==s||e[81]!==b?(ne=r.jsx(OL,{navigation:t,sessionView:s,project:o,view:b,floatingChrome:H}),e[77]=H,e[78]=t,e[79]=o,e[80]=s,e[81]=b,e[82]=ne):ne=e[82];let oe;e[83]!==te||e[84]!==ne?(oe=r.jsxs("main",{className:"app-view-transition relative flex size-full min-w-0 flex-col overflow-hidden",children:[te,ne]}),e[83]=te,e[84]=ne,e[85]=oe):oe=e[85];let re;e[86]!==t.panels.closeWorkspacePanel||e[87]!==M||e[88]!==P||e[89]!==V||e[90]!==q||e[91]!==Z||e[92]!==oe||e[93]!==D||e[94]!==E?(re=r.jsx(_R,{panels:E,context:P,activePanel:V,services:q,onClosePanel:t.panels.closeWorkspacePanel,onOpenPanel:M,onTogglePanel:D,actions:Z,children:oe}),e[86]=t.panels.closeWorkspacePanel,e[87]=M,e[88]=P,e[89]=V,e[90]=q,e[91]=Z,e[92]=oe,e[93]=D,e[94]=E,e[95]=re):re=e[95];let ae;e[96]!==o.currentCwd||e[97]!==o.onCloseRightWorkspace||e[98]!==o.showPreview?(ae=o.showPreview&&o.currentCwd&&r.jsx(y.Suspense,{fallback:null,children:r.jsx(IL,{cwd:o.currentCwd,onClose:o.onCloseRightWorkspace})}),e[96]=o.currentCwd,e[97]=o.onCloseRightWorkspace,e[98]=o.showPreview,e[99]=ae):ae=e[99];let se;return e[100]!==K||e[101]!==re||e[102]!==ae?(se=r.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden bg-background",children:[K,re,ae]}),e[100]=K,e[101]=re,e[102]=ae,e[103]=se):se=e[103],se}function LL(n){const e=B.c(16),{navigation:t,sessionView:s,project:o,chrome:i}=n,{theme:a}=Ht(),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(F0,{}),d=r.jsx(z0,{}),e[0]=c,e[1]=d):(c=e[0],d=e[1]);let u;e[2]!==i||e[3]!==t||e[4]!==o||e[5]!==s?(u=r.jsx(DL,{navigation:t,sessionView:s,project:o,chrome:i}),e[2]=i,e[3]=t,e[4]=o,e[5]=s,e[6]=u):u=e[6];let f;e[7]!==i||e[8]!==t||e[9]!==o?(f=r.jsx(yP,{navigation:t,project:o,chrome:i}),e[7]=i,e[8]=t,e[9]=o,e[10]=f):f=e[10];let m;return e[11]!==i.backgroundServers||e[12]!==l||e[13]!==u||e[14]!==f?(m=r.jsxs("div",{className:l,children:[i.backgroundServers,c,d,u,f]}),e[11]=i.backgroundServers,e[12]=l,e[13]=u,e[14]=f,e[15]=m):m=e[15],m}const zL=[{id:"sessions",label:"Sessions",icon:_o},{id:"chat",label:"Chat",icon:Ia},{id:"stats",label:"Stats",icon:B1,requiresSession:!0}],FL=y.memo(function(e){const t=B.c(17),{activeTab:s,onTabChange:o}=e,{session:i,isLive:a}=at(),l=i!==null;let c,d,u;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=zL.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,b=s===g.id;return r.jsx("button",{type:"button","aria-current":b?"page":void 0,"aria-label":g.label,title:g.label,onClick:()=>{dd(),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",b?"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",b?"scale-100 bg-accent":"scale-95"),children:[r.jsx(x,{className:G("size-[18px] transition-transform duration-150 ease-out motion-reduce:transition-none",b&&"scale-110"),"aria-hidden":"true"}),g.id==="chat"&&a&&r.jsx(Wa,{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],u=p.map(h),t[0]=s,t[1]=l,t[2]=a,t[3]=o,t[4]=c,t[5]=d,t[6]=u}else c=t[4],d=t[5],u=t[6];let f;return t[13]!==c||t[14]!==d||t[15]!==u?(f=r.jsx("nav",{className:c,"aria-label":d,children:u}),t[13]=c,t[14]=d,t[15]=u,t[16]=f):f=t[16],f});function BL(n){const e=B.c(63),{session:t,sessionSource:s,isSubAgentView:o,claudeRawMessages:i,creatingSession:a,onNewSession:l,onDuplicateSession:c,onBackToMain:d,onShowFileChanges:u,hasFileChanges:f,onShowWorkflows:m,workflowCount:p,onSearch:h,expandAll:g,onToggleExpandAll:x}=n;let b;e[0]!==l||e[1]!==t.cwd||e[2]!==s?(b=()=>{s&&l(s.dirName,t.cwd)},e[0]=l,e[1]=t.cwd,e[2]=s,e[3]=b):b=e[3];const w=b;let v;e[4]!==o||e[5]!==d?(v=o&&d&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:d,"aria-label":"Back to main agent",children:r.jsx(Nd,{"data-icon":"inline-start"})}),e[4]=o,e[5]=d,e[6]=v):v=e[6];let S,j;e[7]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx(Hu,{compact:!0}),j=r.jsx(Nt,{orientation:"vertical",className:"h-4"}),e[7]=S,e[8]=j):(S=e[7],j=e[8]);let k;e[9]!==i?(k=r.jsx(Ug,{rawMessages:i,warnOnly:!0}),e[9]=i,e[10]=k):k=e[10];let C;e[11]!==t.cwd?(C=t.cwd?es(t.cwd):"Session",e[11]=t.cwd,e[12]=C):C=e[12];let N;e[13]!==C?(N=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]=N):N=e[14];let _;e[15]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(Lo,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Session actions"}),children:r.jsx(F1,{"data-icon":"inline-start"})}),e[15]=_):_=e[15];let A;e[16]!==t.cwd?(A=t.cwd?es(t.cwd):"Current session",e[16]=t.cwd,e[17]=A):A=e[17];let P;e[18]!==A?(P=r.jsx("span",{className:"truncate text-foreground",children:A}),e[18]=A,e[19]=P):P=e[19];let T;e[20]!==t.gitBranch||e[21]!==t.model?(T=[t.model,t.gitBranch].filter(Boolean).join(" · ")||"Session actions",e[20]=t.gitBranch,e[21]=t.model,e[22]=T):T=e[22];let E;e[23]!==T?(E=r.jsx("span",{className:"truncate font-normal",children:T}),e[23]=T,e[24]=E):E=e[24];let $;e[25]!==P||e[26]!==E?($=r.jsxs(Bg,{className:"flex flex-col gap-0.5",children:[P,E]}),e[25]=P,e[26]=E,e[27]=$):$=e[27];let I;e[28]!==a||e[29]!==w||e[30]!==s?(I=s&&r.jsxs(Wt,{onClick:w,disabled:a,children:[a?r.jsx(st,{}):r.jsx(Fn,{}),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(Wt,{onClick:c,children:[r.jsx(xn,{}),r.jsx("span",{children:"Duplicate session"})]}),e[32]=c,e[33]=R):R=e[33];let D;e[34]!==$||e[35]!==I||e[36]!==R?(D=r.jsxs(Zn,{children:[$,I,R]}),e[34]=$,e[35]=I,e[36]=R,e[37]=D):D=e[37];let O;e[38]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsx(oa,{}),e[38]=O):O=e[38];let M;e[39]!==h?(M=h&&r.jsxs(Wt,{onClick:h,children:[r.jsx(an,{}),r.jsx("span",{children:"Search conversation"})]}),e[39]=h,e[40]=M):M=e[40];let F;e[41]!==g||e[42]!==x?(F=x&&r.jsxs(Wt,{onClick:x,children:[g?r.jsx(Ra,{}):r.jsx($a,{}),r.jsx("span",{children:g?"Collapse tool calls":"Expand tool calls"})]}),e[41]=g,e[42]=x,e[43]=F):F=e[43];let z;e[44]!==f||e[45]!==u?(z=f&&u&&r.jsxs(Wt,{onClick:u,children:[r.jsx(zr,{}),r.jsx("span",{children:"File changes"})]}),e[44]=f,e[45]=u,e[46]=z):z=e[46];let L;e[47]!==m||e[48]!==p?(L=m&&(p??0)>0&&r.jsxs(Wt,{onClick:m,children:[r.jsx(Ad,{}),r.jsx("span",{className:"flex-1",children:"Workflows"}),r.jsx(Pe,{variant:"secondary",children:p})]}),e[47]=m,e[48]=p,e[49]=L):L=e[49];let W;e[50]!==M||e[51]!==F||e[52]!==z||e[53]!==L?(W=r.jsxs(Zn,{children:[M,F,z,L]}),e[50]=M,e[51]=F,e[52]=z,e[53]=L,e[54]=W):W=e[54];let U;e[55]!==D||e[56]!==W?(U=r.jsxs(Do,{children:[_,r.jsxs(zo,{align:"end",sideOffset:6,className:"w-72",children:[D,O,W]})]}),e[55]=D,e[56]=W,e[57]=U):U=e[57];let H;return e[58]!==v||e[59]!==U||e[60]!==k||e[61]!==N?(H=r.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-1.5 border-b bg-background px-2",children:[v,S,j,k,N,U]}),e[58]=v,e[59]=U,e[60]=k,e[61]=N,e[62]=H):H=e[62],H}const UL=y.memo(function(e){const t=B.c(11),{isMobile:s}=Ht(),{session:o,sessionSource:i}=at();if(!s||!o)return null;let a;t[0]!==i?(a=i?Ns(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=To(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,u=l!==null;let f;return t[5]!==d||t[6]!==e||t[7]!==o||t[8]!==i||t[9]!==u?(f=r.jsx(BL,{...e,onDuplicateSession:e.onDuplicateSession,session:o,sessionSource:i,isSubAgentView:u,claudeRawMessages:d}),t[5]=d,t[6]=e,t[7]=o,t[8]=i,t[9]=u,t[10]=f):f=t[10],f});function WL({onSwipeLeft:n,onSwipeRight:e,threshold:t=50,enabled:s=!0}){const o=y.useRef(null),i=y.useRef(null),a=y.useRef(n),l=y.useRef(e);return a.current=n,l.current=e,y.useEffect(()=>{const c=o.current;if(!c||!s)return;function d(f){const m=f.touches[0];i.current={x:m.clientX,y:m.clientY}}function u(f){var g,x;if(!i.current)return;const m=f.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",u,{passive:!0}),()=>{c.removeEventListener("touchstart",d),c.removeEventListener("touchend",u)}},[s,t]),o}const HL=["sessions","chat","stats"];function qL({hasSession:n,hasPendingSession:e}){return HL.filter(t=>!(t==="stats"&&!n&&!e))}function Yh(n,e,t){const s=n.indexOf(e);return s===-1?null:n[s+t]??null}const KL=y.lazy(()=>qe(()=>import("./MobileFileChanges-GkG76Ztq.js"),__vite__mapDeps([37,1,2,3,4])).then(n=>({default:n.MobileFileChanges})));function VL(n){const e=B.c(71),{navigation:t,sessionView:s,project:o,chrome:i}=n,{state:a,theme:l}=Ht(),{session:c,isSubAgentView:d}=at(),u=!!c,f=!!a.pendingDirName;let m;e[0]!==u||e[1]!==f?(m=qL({hasSession:u,hasPendingSession:f}),e[0]=u,e[1]=f,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=Yh(p,a.mobileTab,1);z&&(dd(),t.actions.handleMobileTabChange(z))},onSwipeRight:()=>{const z=Yh(p,a.mobileTab,-1);z&&(dd(),t.actions.handleMobileTabChange(z))}},e[3]=t.actions,e[4]=a.mobileTab,e[5]=p,e[6]=h):h=e[6];const g=WL(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 b=x,w=`${l.themeClasses} flex h-dvh flex-col bg-background text-foreground`,v=i.backgroundServers;let S,j;e[10]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx(F0,{}),j=r.jsx(z0,{}),e[10]=S,e[11]=j):(S=e[10],j=e[11]);let k;e[12]!==c||e[13]!==a.mobileTab?(k=!(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(Hu,{compact:!0})}),e[12]=c,e[13]=a.mobileTab,e[14]=k):k=e[14];const C=a.mobileTab,N=!(a.mobileTab==="chat"&&c)&&"motion-session-enter";let _;e[15]!==N?(_=G("flex min-h-0 min-w-0 flex-1",N),e[15]=N,e[16]=_):_=e[16];let A;e[17]!==t||e[18]!==a.mobileTab?(A=a.mobileTab==="sessions"&&r.jsx(hv,{navigation:t,mobile:!0}),e[17]=t,e[18]=a.mobileTab,e[19]=A):A=e[19];let P;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?(P=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(UL,{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(dl,{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(Hb,{projectPath:s.pendingPath??null}),ot("terminal")&&r.jsxs(ee,{variant:"outline",size:"xs",onClick:o.onOpenTerminal,children:[r.jsx(Gs,{"data-icon":"inline-start"}),"Terminal"]})]})}):r.jsx(gv,{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]=P):P=e[29];let T;e[30]!==t.handlers||e[31]!==o||e[32]!==c||e[33]!==a.mobileTab?(T=a.mobileTab==="stats"&&c&&r.jsx(Ub,{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]=T):T=e[34];let E;e[35]!==a.mobileTab||e[36]!==_||e[37]!==A||e[38]!==P||e[39]!==T?(E=r.jsxs("div",{className:_,children:[A,P,T]},C),e[35]=a.mobileTab,e[36]=_,e[37]=A,e[38]=P,e[39]=T,e[40]=E):E=e[40];let $;e[41]!==g||e[42]!==E?($=r.jsx("main",{ref:g,className:"app-view-transition flex flex-1 min-h-0 overflow-hidden",children:E}),e[41]=g,e[42]=E,e[43]=$):$=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 D;e[49]!==I||e[50]!==R?(D=r.jsxs("div",{className:"shrink-0",children:[I,R]}),e[49]=I,e[50]=R,e[51]=D):D=e[51];let O;e[52]!==b||e[53]!==a.mobileTab?(O=r.jsx(FL,{activeTab:a.mobileTab,onTabChange:b}),e[52]=b,e[53]=a.mobileTab,e[54]=O):O=e[54];let M;e[55]!==i||e[56]!==o||e[57]!==c||e[58]!==a.sessionChangeKey?(M=c&&o.hasFileChanges&&r.jsx(y.Suspense,{fallback:null,children:r.jsx(KL,{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]=M):M=e[59];let F;return e[60]!==i.backgroundServers||e[61]!==i.branchModal||e[62]!==i.undoDialog||e[63]!==i.workflowsPanel||e[64]!==k||e[65]!==$||e[66]!==D||e[67]!==O||e[68]!==M||e[69]!==w?(F=r.jsxs("div",{className:w,children:[v,S,j,k,$,D,i.workflowsPanel,O,i.undoDialog,i.branchModal,M]}),e[60]=i.backgroundServers,e[61]=i.branchModal,e[62]=i.undoDialog,e[63]=i.workflowsPanel,e[64]=k,e[65]=$,e[66]=D,e[67]=O,e[68]=M,e[69]=w,e[70]=F):F=e[70],F}function GL(n){const e=B.c(13),{sessionId:t,loadError:s,searchInputRef:o,activeComposer:i,hasMoreTurns:a,isLoadingOlderTurns:l,onLoadMoreTurns:c}=n,{theme:d,isMobile:u}=Ht(),{session:f}=at(),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]!==u||e[4]!==s||e[5]!==c||e[6]!==o||e[7]!==f||e[8]!==t?(p=f?r.jsxs("main",{className:"relative flex min-h-0 flex-1 flex-col",children:[r.jsx(dl,{searchInputRef:o,hasMore:a,isLoadingOlder:l,onLoadMore:c}),u?i:r.jsx(vl,{floating:!0,children:i})]}):r.jsx("main",{className:"flex min-h-0 flex-1 items-center justify-center p-6",children:r.jsx(ln,{className:"max-w-md",children:r.jsxs(cn,{children:[r.jsx(bn,{variant:"icon",children:s?r.jsx(Yt,{}):r.jsx(rt,{className:"animate-spin"})}),r.jsx(dn,{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]=u,e[4]=s,e[5]=c,e[6]=o,e[7]=f,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 YL=5;function Wi(n,e){const t=Nn(),s=js();return`${s===null?t:`${t}:${s}`}:${n}/${e}`}class XL{constructor(){Si(this,"cache",new Map)}get(e,t){const s=Wi(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=Wi(e,t);!this.cache.has(d)&&this.cache.size>=YL&&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=Wi(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(Wi(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 Cn=new XL,Xh={};function xv(n,e,t,s,o,i){const[a,l]=y.useState(!1),[c,d]=y.useState("disconnected"),[u,f]=y.useState(!1),[m,p]=y.useState(null),[h,g]=y.useState(Xh),[x,b]=y.useState(null),[w,v]=y.useState(ho),S=y.useRef(""),j=y.useRef(null),k=y.useRef(ho),C=y.useRef("disconnected"),N=y.useRef(e);N.current=e;const _=y.useRef(o);_.current=o;const A=y.useRef(t);A.current=t;const P=y.useRef(s);P.current=s;const T=y.useRef(i??null);T.current=i??null;const E=y.useRef(!1),$=(n==null?void 0:n.dirName)??null,I=(n==null?void 0:n.fileName)??null,R=(n==null?void 0:n.rawText)??"",D=(n==null?void 0:n.watchOffset)??new TextEncoder().encode(R).byteLength;return y.useEffect(()=>{if(S.current=R,!R){j.current=null,l(!1);return}const O=T.current;if(O){j.current=O;return}A.current(R).then(M=>{j.current=M})},[R]),y.useEffect(()=>{if(b(null),!$||!I){l(!1),d("disconnected");return}d("connecting");const O=`/api/watch/${encodeURIComponent($)}/${encodeURIComponent(I)}?offset=${D}`,M=new EventSource(Wr(O));let F=null;const z=(ae=3e4)=>{F&&clearTimeout(F),F=setTimeout(()=>{l(!1),f(!1)},ae)};let L="",W=D,U=!1,H=!1,K=!1,V=null;const Y=()=>{K=!1,V=null,j.current&&N.current(j.current)},q=()=>{K||(K=!0,V=requestAnimationFrame(Y))};let J=!1,Q=null,X=null;const Z=()=>{J=!1,Q=null,v(k.current)},te=()=>{J||(J=!0,Q=requestAnimationFrame(Z))},ne=ae=>{ae!==k.current&&(k.current=ae,te(),ae.length>0&&!X&&(X=setInterval(()=>{const se=tT(k.current);se!==k.current&&(k.current=se,te()),k.current.length===0&&X&&(clearInterval(X),X=null)},5e3)))},oe=()=>{ne(ho),g(Xh)},re=()=>{if(H||U||!L)return;const ae=L;L="",U=!0;const se=j.current;(se?P.current(se,ae):A.current(S.current)).then(le=>{H||(j.current=le,$&&I&&Cn.update($,I,{parsed:le,source:{rawText:S.current,watchOffset:W}}),q())}).catch(le=>{console.error("[useLiveSession] worker parse failed:",le)}).finally(()=>{U=!1,!H&&L&&re()})};return M.onopen=()=>{var ae;if(C.current!=="connected"){const se=E.current;E.current=!1,C.current="connected",d("connected"),se&&((ae=_.current)==null||ae.call(_))}},M.onmessage=ae=>{try{C.current!=="connected"&&(C.current="connected",d("connected"));const se=JSON.parse(ae.data);if(se.type==="init")se.recentlyActive?(l(!0),z(5e3)):z();else if(se.type==="compacting_in_progress")l(!0),f(!0),oe(),z();else if(se.type==="subagent_activity")l(!0),z();else if(se.type==="runtime_activity")l(!0),z();else if(se.type==="stream_snapshot")l(!0),z(),ne(Q7(se.messages??[]));else if(se.type==="stream_delta")l(!0),z(),p(null),b(null),ne(Z7(k.current,se.events??[]));else if(se.type==="agent_progress")l(!0),z(),g(de=>({...de,[se.toolUseId]:se.summary}));else if(se.type==="prompt_suggestion")b(typeof se.suggestion=="string"?se.suggestion:null);else if(se.type==="turn_error")p(typeof se.message=="string"?se.message:"The turn failed");else if(se.type==="stream_clear")oe();else if(se.type==="lines"&&se.lines.length>0){l(!0),f(!1),z(),ne(eT(k.current,se.lines));const de=se.lines.join(`
|
|
142
|
+
`)+`
|
|
143
|
+
`;W+=new TextEncoder().encode(de).byteLength,S.current+=de,L+=de,re()}}catch(se){console.error("[useLiveSession] Error processing SSE message:",se)}},M.onerror=()=>{l(!1),f(!1),E.current=C.current==="connected",C.current="disconnected",d("disconnected"),oe()},()=>{H=!0,M.close(),l(!1),C.current="disconnected",d("disconnected"),F&&clearTimeout(F),V!==null&&cancelAnimationFrame(V),Q!==null&&cancelAnimationFrame(Q),X&&clearInterval(X),k.current=ho,v(ho)}},[$,I,R,D]),{isLive:a,sseState:c,isCompacting:u,streamingOverlay:w,turnError:m,agentProgress:h,promptSuggestion:x}}const JL=3e4;function bv(n,e,t){const s=B.c(9),o=JL,[i,a]=y.useState(!1),l=y.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]),y.useEffect(c,d);let u,f;s[3]!==o||s[4]!==n?(u=()=>{if(!n){a(!1);return}let p=!0,h=null;const g=new EventSource(Wr(n));a(!1);const x=()=>{h&&clearTimeout(h),h=setTimeout(()=>{p&&a(!1)},o)};return g.onmessage=b=>{if(p)try{const w=JSON.parse(b.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)}},f=[n,o],s[3]=o,s[4]=n,s[5]=u,s[6]=f):(u=s[5],f=s[6]),y.useEffect(u,f);let m;return s[7]!==i?(m={isLive:i},s[7]=i,s[8]=m):m=s[8],m}function QL(n,e){const t=n?`/api/team-watch/${encodeURIComponent(n)}`:null;return bv(t,e)}function ZL(n,e){const[t,s]=y.useState(null),o=y.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 u=new URLSearchParams({leadSessionId:l});return c&&u.set("subagentFile",c),e&&u.set("dirName",e),u.toString()})();o.current=i;const a=y.useCallback(async()=>{const l=o.current;if(l)try{const c=await be(`/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 y.useEffect(()=>{if(!n){s(null);return}a()},[n,a]),QL((t==null?void 0:t.teamName)??null,a),t}function ez(n,e,t,s){let o=null;return n&&e&&(o=`/api/workflow-watch/${encodeURIComponent(n)}/${encodeURIComponent(e)}`,t&&(o=o+`/${encodeURIComponent(t)}`)),bv(o,s)}function tz(n,e,t=!0){const[s,o]=y.useState([]),[i,a]=y.useState(!1),l=y.useRef(0),c=!!n&&!!e,d=y.useCallback(async()=>{const m=++l.current;if(!c){o([]);return}try{const p=await be(`/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]);y.useEffect(()=>{if(!c){o([]),a(!1);return}a(!0),d()},[c,d]);const u=c&&(t||s.length>0),{isLive:f}=ez(u?n:null,u?e:null,null,d);return{workflows:s,loading:i,isLive:f,refetch:d}}const Na={mode:"bypassPermissions",allowedTools:[],disallowedTools:[]},nz="cogpit:permissions";function sz(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 Jh(n,e){const t=await n.json().catch(()=>({error:e}));return typeof t.error=="string"&&t.error?t.error:e}async function vv(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 Jh(l,i(l));return!l.ok&&t==="codex"&&e&&sz(c)&&(o==null||o(e),l=await n(void 0),c=l.ok?null:await Jh(l,i(l))),{res:l,errorMessage:c}}function oz({sessionSource:n,parsedSessionId:e,cwd:t,permissions:s,onPermissionsApplied:o,model:i,effort:a,fastMode:l,ultracode:c,mcpConfig:d,onModelRejected:u,readOnly:f=!1,onCreateSession:m}){const[p,h]=y.useState("idle"),[g,x]=y.useState(),[b,w]=y.useState([]),v=y.useRef(null),S=y.useRef(null),j=y.useRef(!1),k=n!=null&&n.fileName?_c(n.fileName):null,C=e||k,N=n?$t(n.dirName):null,_=y.useCallback(()=>{var R;(R=v.current)==null||R.abort(),v.current=null,j.current=!1,h("idle"),x(void 0),w([])},[]);y.useEffect(()=>{var R;S.current!==C&&(j.current?(j.current=!1,(R=v.current)==null||R.abort(),v.current=null,h("idle"),x(void 0)):_(),S.current=C)},[C,_]),y.useEffect(()=>()=>{var R;(R=v.current)==null||R.abort()},[]),y.useEffect(()=>{f&&_()},[f,_]);const A=y.useCallback(async(R,D)=>{if(f)return;if(!C&&m){w(F=>[...F,R]),h("connected"),x(void 0),j.current=!0,o==null||o();try{if(!await m(R,D)){j.current=!1,h("idle"),w([]);return}h("idle")}catch(F){j.current=!1,x(F instanceof Error?F.message:"Failed to create session"),h("error"),w([])}return}if(!C)return;w(F=>[...F,R]),h("connected"),x(void 0);const O=s??Na;o==null||o();const M=new AbortController;v.current=M;try{const F={sessionId:C,message:R,images:D||void 0,cwd:t||void 0,permissions:O,effort:a||void 0,fastMode:l?!0:void 0,ultracode:c?!0:void 0,mcpConfig:d||void 0},{res:z,errorMessage:L}=await vv(W=>be("/api/send-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...F,model:W}),signal:M.signal}),{model:i,agentKind:N,errorFallback:W=>`Request failed (${W.status})`,onModelRejected:u});v.current===M&&(z.ok?h("idle"):(x(L||`Request failed (${z.status})`),h("error"),w(W=>W.slice(0,-1))))}catch(F){if(F instanceof Error&&F.name==="AbortError")return;v.current===M&&(x(F instanceof Error?F.message:"Unknown error"),h("error"),w(z=>z.slice(0,-1)))}},[C,N,t,s,o,i,a,l,c,d,u,f,m]),P=y.useCallback(()=>{_()},[_]),T=y.useCallback(()=>{!C||f||be("/api/interrupt-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:C})}).catch(()=>{})},[C,f]),E=y.useCallback(()=>{var R;(R=v.current)==null||R.abort(),v.current=null,T(),h("idle"),w([])},[T]),$=E,I=y.useCallback((R=1)=>{w(D=>D.slice(R))},[]);return{status:p,error:g,pendingMessages:b,sendMessage:A,disconnect:P,interrupt:E,stopAgent:$,consumePending:I,isConnected:p==="connected"}}const fs={expandAll:!1,expandToolPayloads:!1},rz={session:null,windowTurns:[],olderTurns:[],sessionSource:null,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...fs,sessionChangeKey:0,currentMemberName:null,loadingMember:null,mainView:"sessions",configFilePath:null,mobileTab:"sessions",dashboardProject:null};function Qh(n,e,t,s){const o=V2(e,t,s);return o===n.turns?n:{...n,turns:o}}function uo(n){return{session:n,windowTurns:(n==null?void 0:n.turns)??[],olderTurns:[]}}function iz(n,e){var t,s;switch(e.type){case"LOAD_SESSION":return{...n,...uo(e.session),sessionSource:e.source,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...fs,mainView:"sessions",currentMemberName:null,dashboardProject:null,sessionChangeKey:n.sessionChangeKey+1,mobileTab:e.isMobile?"chat":n.mobileTab};case"GO_HOME":return{...n,...uo(null),sessionSource:null,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...fs,mainView:"sessions",currentMemberName:null,dashboardProject:null,mobileTab:e.isMobile?"sessions":n.mobileTab};case"SWITCH_TEAM_MEMBER":return{...n,...uo(e.session),sessionSource:e.source,activeTurnIndex:null,searchQuery:"",...fs,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,...fs};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,...fs}:{...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:Qh(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:Qh(n.session,n.windowTurns,e.turns,(s=n.sessionSource)==null?void 0:s.agentKind)};case"RELOAD_SESSION_CONTENT":return{...n,...uo(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,...uo(null),sessionSource:null,pendingDirName:e.dirName,pendingCwd:e.cwd??null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...fs,mainView:"sessions",currentMemberName:null,dashboardProject:null,sessionChangeKey:n.sessionChangeKey+1,mobileTab:e.isMobile?"chat":n.mobileTab};case"FINALIZE_SESSION":return{...n,...uo(e.session),sessionSource:e.source,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...fs,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 yv(){return y.useReducer(iz,rz)}function Zh(n){n(),requestAnimationFrame(()=>{n(),requestAnimationFrame(n)})}function wv({session:n,isLive:e,pendingMessages:t,consumePending:s,sessionChangeKey:o,partialContentLen:i=0}){const a=y.useRef(null),l=y.useRef(null),c=y.useRef(!0),d=y.useRef(!1),u=y.useRef(0),f=y.useMemo(()=>(n==null?void 0:n.turns.flatMap(M=>M.contentBlocks.flatMap(F=>F.kind==="queued_prompt"?[{id:JSON.stringify([F.timestamp??"",F.content]),content:F.content}]:[])))??[],[n==null?void 0:n.turns]),m=y.useRef(null),p=y.useRef(!1),[h,g]=y.useState(!1),[x,b]=y.useState(!1),[w,v]=y.useState(null),S=y.useCallback(()=>{requestAnimationFrame(()=>{var M;(M=l.current)==null||M.scrollIntoView({behavior:"smooth"})})},[]),j=y.useCallback(()=>{Zh(()=>{const M=a.current;M&&(M.scrollTop=M.scrollHeight),c.current=!0,d.current=!1})},[]),k=y.useCallback(()=>{p.current=!0},[]),C=y.useRef(!1),N=y.useRef(!1),_=y.useCallback(()=>{const M=a.current;if(!M)return;const F=M.scrollTop>10,z=M.scrollHeight-M.scrollTop-M.clientHeight>10;F!==C.current&&(C.current=F,g(F)),z!==N.current&&(N.current=z,b(z))},[]),A=y.useCallback(()=>{const M=a.current;M&&(c.current=M.scrollHeight-M.scrollTop-M.clientHeight<150,_())},[_]),P=y.useCallback(M=>{u.current=M},[]),T=y.useRef(o);y.useEffect(()=>{if(o===T.current)return;T.current=o;const M=p.current;p.current=!1;const F=()=>{const L=a.current;L&&(M?(L.scrollTop=0,c.current=!1):(L.scrollTop=L.scrollHeight,c.current=!0),d.current=!1)};Zh(F);const z=setTimeout(()=>{F(),v(o)},150);return()=>clearTimeout(z)},[o]);const E=t.length;y.useEffect(()=>{E>0&&(d.current=!0,S())},[E,S]),y.useEffect(()=>{const M=(n==null?void 0:n.sessionId)??null,F=m.current,z=new Set(f.map(U=>U.id));if(!F||F.sessionId!==M){m.current={sessionId:M,ids:z};return}const L=f.filter(U=>!F.ids.has(U.id));if(m.current={sessionId:M,ids:z},L.length===0||E===0)return;let W=0;for(const U of L){const H=t[W];(H===U.content||(H==null?void 0:H.trim())===""&&U.content.length>0)&&W++}W>0&&s(W)},[n==null?void 0:n.sessionId,f,t,E,s]);const $=(n==null?void 0:n.turns.length)??0;y.useEffect(()=>{if($===0)return;const M=$-u.current;M>0&&(E>0&&s(Math.min(M,E)),(d.current||c.current)&&(S(),d.current=!1)),u.current=$},[$,E,s,S]);const I=n==null?void 0:n.turns.at(-1),R=(I==null?void 0:I.toolCalls.length)??0,D=(I==null?void 0:I.assistantText.length)??0;y.useEffect(()=>{if(!(!n||!e)){if(c.current){const M=a.current;M&&(M.scrollTop=M.scrollHeight)}requestAnimationFrame(_)}},[$,R,D,i,e,_]);const O=w===o;return y.useMemo(()=>({chatScrollRef:a,scrollEndRef:l,canScrollUp:h,canScrollDown:x,initialScrollDone:O,handleScroll:A,scrollToBottomInstant:j,requestScrollToTop:k,resetTurnCount:P}),[h,x,O,A,j,k,P])}async function jv(n,e,t,s){const o=await be(`/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(u=>!a.has(u)),c=[...i.headerLines,...l].join(`
|
|
144
|
+
`);return{parsed:await t(c),source:{dirName:n,fileName:e,rawText:c,agentKind:$t(n),watchOffset:i.totalSize},byteOffset:i.byteOffset,hasMore:i.hasMore}}async function Ks(n,e,t,s){const o=Cn.get(n,e);if(o)return{parsed:o.parsed,source:o.source};const i=Nn(),a=js(),{parsed:l,source:c,byteOffset:d,hasMore:u}=await jv(n,e,t,s);if(Nn()!==i||js()!==a)return{parsed:l,source:c};const f=Cn.get(n,e);return f?{parsed:f.parsed,source:f.source}:(Cn.set(n,e,l,c.rawText,d,u,c.agentKind,c.watchOffset),{parsed:l,source:c})}async function Sv(n,e,t,s){Cn.evict(n,e);const o=Nn(),i=js(),{parsed:a,source:l,byteOffset:c,hasMore:d}=await jv(n,e,t,s);return Nn()===o&&js()===i&&Cn.set(n,e,a,l.rawText,c,d,l.agentKind,l.watchOffset),{parsed:a,source:l}}function az({dispatch:n,isMobile:e,mobileTab:t="sessions",teamContext:s,scrollToBottomInstant:o,resetTurnCount:i,workerParse:a,onBeforeSwitch:l}){const[c,d]=y.useState(null),u=y.useCallback((b,w)=>{d(null),y.startTransition(()=>{n({type:"LOAD_SESSION",session:b,source:w,isMobile:e})}),i(b.turns.length),rL(b.sessionId,b.turns.length),o()},[n,e,i,o]),f=y.useCallback(async(b,w)=>{l==null||l(),d(null);try{const{parsed:v,source:S}=await Ks(b,w,a,"session");u(v,S)}catch(v){d(v instanceof Error?v.message:"Failed to load session")}},[u,a,l]),m=y.useCallback(async b=>{if(s){l==null||l(),d(null),n({type:"SET_LOADING_MEMBER",name:b.name});try{const w=await be(`/api/team-member-session/${encodeURIComponent(s.teamName)}/${encodeURIComponent(b.name)}`);if(!w.ok)throw new Error(`Failed to find session for ${b.name}`);const{dirName:v,fileName:S}=await w.json(),{parsed:j,source:k}=await Ks(v,S,a,`session for ${b.name}`);y.startTransition(()=>{n({type:"SWITCH_TEAM_MEMBER",session:j,source:k,memberName:b.name})}),i(j.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=y.useCallback(()=>d(null),[]),h=y.useCallback(()=>{y.startTransition(()=>{n({type:"GO_HOME",isMobile:e})})},[n,e]),g=y.useCallback((b,w)=>{n({type:"JUMP_TO_TURN",index:b,toolCallId:w})},[n]),x=y.useCallback(b=>{b!==t&&y.startTransition(()=>{n({type:"SET_MOBILE_TAB",tab:b})})},[n,t]);return{loadError:c,clearLoadError:p,handleLoadSession:u,handleDashboardSelect:f,handleTeamMemberSwitch:m,handleGoHome:h,handleJumpToTurn:g,handleMobileTabChange:x}}const lz=/^\/preview\/([^/]+)\/?$/;function df(n){const e=lz.exec(n);if(!e)return null;try{const t=decodeURIComponent(e[1]);return t.length>0?t:null}catch{return null}}function Nv(){const n=vt();return n===Tt?"":`/d/${n}`}function ud(){const n=Nv();return n?`${n}/`:"/"}function kv(n){const e=/^\/d\/[^/]+(\/.*)?$/.exec(n);return e?e[1]||"/":n}function cz(n,e){return ej(n,e)}function dz(n){const e=Nv();if(n.sessionSource){const{dirName:t,fileName:s}=n.sessionSource,o=Zw(t,s);return`${e}/${encodeURIComponent(t)}/${encodeURIComponent(o)}`}return n.pendingDirName?`${e}/${encodeURIComponent(n.pendingDirName)}`:n.dashboardProject?`${e}/${encodeURIComponent(n.dashboardProject)}`:ud()}function e1(n){const e=kv(n),t=df(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 uz({state:n,dispatch:e,isMobile:t,resetTurnCount:s,scrollToBottomInstant:o,workerParse:i}){const[a,l]=y.useState(null),c=y.useRef(0),d=y.useRef(window.location.pathname),u=y.useRef(!1),f=y.useCallback(async m=>{c.current++;try{if(m.type==="preview"&&m.sessionId){l(null);try{const p=await be(`/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 Ks(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=cz(m.dirName,m.sessionId);let h;try{h=await Ks(m.dirName,p,i,"session")}catch{e({type:"GO_HOME",isMobile:t});const g=ud();window.history.replaceState(null,"",g),d.current=g,Ho(vt(),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=ud();window.history.replaceState(null,"",p),d.current=p,Ho(vt(),p)}}finally{c.current--}},[e,t,s,o,i]);return y.useEffect(()=>{if(u.current)return;u.current=!0,Ho(vt(),window.location.pathname);const m=e1(window.location.pathname);(m.type!=="home"||m.normalizeHome)&&f(m)},[f]),y.useEffect(()=>{if(c.current>0||df(kv(window.location.pathname)))return;const m=dz(n);m!==d.current&&(window.history.pushState(null,"",m),d.current=m,Ho(vt(),m))},[n.sessionSource,n.pendingDirName,n.mainView,n.dashboardProject]),y.useEffect(()=>{const m=()=>{const p=e1(window.location.pathname);d.current=window.location.pathname,Ho(vt(),window.location.pathname),f(p)};return window.addEventListener("popstate",m),()=>window.removeEventListener("popstate",m)},[f]),{previewLoadError:a}}const fz=400;function t1(){return Array.from(document.querySelectorAll("[data-live-session]"))}function mz(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 n1(n){n.focus({preventScroll:!0});const e=mz(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 pz(n){const e=B.c(20),{isMobile:t,searchInputRef:s,chatInputRef:o,dispatch:i,onToggleSidebar:a,onToggleRightSidebar:l,onToggleMissionControl:c,onOpenCommandPalette:d,onOpenProjectSwitcher:u,onOpenThemeSelector:f,onOpenTerminal:m,onToggleIntegratedTerminal:p,onTogglePreview:h,onToggleProjectFiles:g,onHistoryBack:x,onHistoryForward:b,onNavigateToSession:w,onCommitNavigation:v}=n;let S,j;e[0]!==o||e[1]!==i||e[2]!==t||e[3]!==v||e[4]!==x||e[5]!==b||e[6]!==w||e[7]!==d||e[8]!==u||e[9]!==m||e[10]!==f||e[11]!==p||e[12]!==c||e[13]!==h||e[14]!==g||e[15]!==l||e[16]!==a||e[17]!==s?(S=()=>{if(t)return;let k=!1,C=!1,N=null;const _=function(E){var D,O;const $=xh("missionControl");if($){if(E.key===$){E.repeat||(k=!0,C=E.shiftKey||E.altKey||($==="Meta"?E.ctrlKey:E.metaKey));return}k&&(C=!0),N=null}if(Ct("commandPalette",E)){E.preventDefault(),d==null||d();return}if(Ct("integratedTerminal",E)){if(!ot("terminal"))return;E.preventDefault(),p();return}if(Ct("preview",E)){E.preventDefault(),h();return}if(Ct("projectFiles",E)){if(!ot("hostFiles"))return;E.preventDefault(),g();return}if(Ct("expandAll",E)){E.preventDefault(),i({type:"SET_EXPAND_ALL",value:!0});return}if(Ct("expandToolPayloads",E)){E.preventDefault(),i({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0});return}if(Ct("toggleSidebar",E)){E.preventDefault(),a();return}if(Ct("toggleStats",E)){E.preventDefault(),l();return}if(Ct("missionControl",E)){E.preventDefault(),c();return}if(Ct("newSession",E)&&(E.preventDefault(),u()),Ct("themeSelector",E)&&(E.preventDefault(),f()),Ct("systemTerminal",E)){if(!ot("terminal"))return;E.preventDefault(),m()}if(E.key==="Escape"&&(i({type:"SET_SEARCH_QUERY",value:""}),(D=s.current)==null||D.blur()),(E.metaKey||E.ctrlKey)&&E.shiftKey&&E.code.startsWith("Digit")){const M=parseInt(E.code.charAt(5),10);if(M>=1&&M<=9){E.preventDefault();const z=t1()[M-1];z&&(n1(z),z.click())}}const I=Ct("recentSessionForward",E);if(I||Ct("recentSessionBack",E)){E.preventDefault();const M=I?b():x();M&&w(M.dirName,M.fileName)}Ct("focusComposer",E)&&!J2(document.activeElement)&&(E.preventDefault(),(O=o.current)==null||O.focus());const R=Ct("nextLiveSession",E);if(R||Ct("prevLiveSession",E)){E.preventDefault();const M=t1();if(M.length===0)return;const F=M.findIndex(hz);let z;F===-1?z=R?0:M.length-1:z=Math.max(0,Math.min(M.length-1,F+(R?1:-1))),n1(M[z])}},A=function(E){const $=xh("missionControl");if($&&E.key===$&&k){const I=!C;if(k=!1,C=!1,I){const R=Date.now();N!==null&&R-N<=fz?(N=null,E.preventDefault(),c()):N=R}else N=null}E.key==="Control"&&(v==null||v())},P=function(){k=!1,C=!1,N=null};return window.addEventListener("keydown",_),window.addEventListener("keyup",A),window.addEventListener("blur",P),()=>{window.removeEventListener("keydown",_),window.removeEventListener("keyup",A),window.removeEventListener("blur",P)}},j=[t,s,o,i,a,l,c,d,u,f,m,p,h,g,x,b,w,v],e[0]=o,e[1]=i,e[2]=t,e[3]=v,e[4]=x,e[5]=b,e[6]=w,e[7]=d,e[8]=u,e[9]=m,e[10]=f,e[11]=p,e[12]=c,e[13]=h,e[14]=g,e[15]=l,e[16]=a,e[17]=s,e[18]=S,e[19]=j):(S=e[18],j=e[19]),y.useEffect(S,j)}function hz(n){return n===document.activeElement}const s1="cogpit-theme",AB=[{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 gz(n){switch(n){case"dark":return"dark";case"oled":return"dark theme-oled";case"light":return""}}function Cv(){const[n,e]=y.useState(()=>{try{const l=localStorage.getItem(s1);if(l==="dark"||l==="oled"||l==="light")return l}catch{}return"dark"}),[t,s]=y.useState(null),o=y.useCallback(l=>{localStorage.setItem(s1,l),e(l),s(null)},[]),i=t??n,a=gz(i);return y.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 xz="cogpit-session-history",fd=50;function _v(){return Vt(xz)}function bz(){try{const n=localStorage.getItem(_v());if(!n)return[];const e=JSON.parse(n);if(Array.isArray(e))return e.slice(0,fd)}catch{}return[]}function o1(n){try{localStorage.setItem(_v(),JSON.stringify(n))}catch{}}function vz(){const n=B.c(6);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=bz(),n[0]=e):e=n[0];const t=y.useRef(e),s=y.useRef(0),o=y.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(b=>`${b.dirName}/${b.fileName}`!==x),t.current.unshift({dirName:h,fileName:g}),t.current.length>fd&&(t.current.length=fd),s.current=0,o1(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 u=d;let f;n[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{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),o1(t.current)),s.current=0,o.current=!1},n[4]=f):f=n[4];const m=f;let p;return n[5]===Symbol.for("react.memo_cache_sentinel")?(p={push:a,goBack:c,goForward:u,commitNavigation:m},n[5]=p):p=n[5],p}function Tv(){return Vt(nz)}function r1(){try{const n=localStorage.getItem(Tv());if(n){const e=JSON.parse(n);return{mode:e.mode||Na.mode,allowedTools:Array.isArray(e.allowedTools)?e.allowedTools:[],disallowedTools:Array.isArray(e.disallowedTools)?e.disallowedTools:[]}}}catch{}return Na}function yz(n){localStorage.setItem(Tv(),JSON.stringify(n))}function wz(){const n=B.c(21),[e,t]=y.useState(r1),[s,o]=y.useState(r1),i=y.useRef(!0);let a,l;n[0]!==e?(a=()=>{if(i.current){i.current=!1;return}yz(e)},l=[e],n[0]=e,n[1]=a,n[2]=l):(a=n[1],l=n[2]),y.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 u;n[10]===Symbol.for("react.memo_cache_sentinel")?(u=j=>{t(k=>({...k,mode:j}))},n[10]=u):u=n[10];const f=u;let m;n[11]===Symbol.for("react.memo_cache_sentinel")?(m=j=>{t(k=>{const C=k.allowedTools.includes(j);return{...k,allowedTools:C?k.allowedTools.filter(N=>N!==j):[...k.allowedTools,j]}})},n[11]=m):m=n[11];const p=m;let h;n[12]===Symbol.for("react.memo_cache_sentinel")?(h=j=>{t(k=>{const C=k.disallowedTools.includes(j);return{...k,disallowedTools:C?k.disallowedTools.filter(N=>N!==j):[...k.disallowedTools,j]}})},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 b=x;let w;n[15]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{t(Na)},n[15]=w):w=n[15];const v=w;let S;return n[16]!==s||n[17]!==e||n[18]!==d||n[19]!==b?(S={config:e,appliedConfig:s,hasPendingChanges:d,setMode:f,toggleAllowedTool:p,toggleDisallowedTool:g,markApplied:b,resetToDefault:v},n[16]=s,n[17]=e,n[18]=d,n[19]=b,n[20]=S):S=n[20],S}const jz=2e3;function Sz(n,e){return n.length!==e.length?!1:JSON.stringify(n)===JSON.stringify(e)}function Nz(n){const[e,t]=y.useState([]),[s,o]=y.useState(null),[i,a]=y.useState(new Set);y.useEffect(()=>{if(!n){t([]),o(null);return}let d=!1;const u=async()=>{if(!d)try{const h=await be(`/api/permissions/${encodeURIComponent(n)}`);if(d)return;if(h.ok){const g=await h.json();if(d)return;t(b=>Sz(b,g.permissions)?b:g.permissions);const x=g.plan?{type:"plan",provider:"copilot",...g.plan}:null;o(b=>JSON.stringify(b)===JSON.stringify(x)?b:x)}}catch{}},f=()=>{(typeof document>"u"||document.visibilityState==="visible")&&u()},m=()=>{document.visibilityState==="visible"&&u()};f();const p=setInterval(f,jz);return document.addEventListener("visibilitychange",m),()=>{d=!0,clearInterval(p),document.removeEventListener("visibilitychange",m)}},[n]);const l=y.useCallback(async(d,u)=>{if(n){a(f=>new Set(f).add(d));try{await av(n,d,u)&&t(f=>f.filter(m=>m.requestId!==d))}finally{a(f=>{const m=new Set(f);return m.delete(d),m})}}},[n]),c=y.useCallback(async d=>{if(n)try{await VD(n,d)&&t([])}catch{}},[n]);return{requests:e,plan:s,responding:i,respond:l,respondAll:c}}async function kz(n,e){const t=await be(`/api/copilot-history/${encodeURIComponent(n)}/preview`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({eventId:e})});return t.ok?await t.json():null}async function Cz(n,e,t){const s=await be(`/api/copilot-history/${encodeURIComponent(n)}/rewind`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({eventId:e,mode:t})}),o=await s.json().catch(()=>null);return!s.ok||(o==null?void 0:o.outcome)!=="success"?{ok:!1,error:(o==null?void 0:o.error)||`Copilot rewind failed${o!=null&&o.outcome?`: ${o.outcome}`:""}`}:{ok:!0}}function _z(n){return n.file_path??n.path??""}function Ev(n){const e=[];for(const t of n.toolCalls){if(t.isError||y9(t))continue;const s=_z(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 Tz(n,e){return{index:e,userMessage:sl(n.userMessage),toolCalls:Ev(n),thinkingBlocks:n.thinking.map(t=>t.thinking),assistantText:[...n.assistantText],timestamp:n.timestamp,model:n.model}}function ka(n,e,t){const s=[];for(let o=e;o>t;o--){const i=n[o];if(!i)continue;const a=Ev(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 Ez(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 pr(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(...Ez(i.toolCalls,i.index))}return t}function Av(n,e,t,s){var l;const o=[];for(let c=e+1;c<n.length;c++){const d=n[c];d&&o.push(Tz(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 Pv(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 $v(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 Az(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 Pz(n,e){return{sessionId:n,currentTurnIndex:e-1,totalTurns:e,branches:[],activeBranchId:null}}function Hi(n,e){return n.length>0?Az(n):{turnCount:e,fileCount:0,filePaths:[],operationCount:0}}function Rv(n,e,t){return S0(v0($t(t)),n,e)}function Iv(n,e,t,s){const o=v0($t(s)),i=e==null?void 0:e.id;if(i){const a=u_(o,n,i);if(a==="keep-all")return n.length;if(a!==null)return a}return S0(o,n,t)}class rr extends Error{constructor(){super("abort")}}async function $z(n,e,t,s,o,i,a){var w;const l=n.targetTurnIndex,c=ka(e.turns,e.turns.length-1,l),d=l+1,u=o.split(`
|
|
145
|
+
`).filter(Boolean),f=Iv(u,e.turns[l],d,t.dirName),m=u.slice(f);if(m.length===0)throw a("Unable to locate the selected turn in the current session file"),new rr;const{retained:p,scooped:h}=Pv(s.branches,l),g=Av(e.turns,l,m,h),x={...s,currentTurnIndex:l,totalTurns:d,branches:[...p,g],activeBranchId:null},b=To(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:f,expectedLineCount:u.length},state:x,...b?{checkpoint:{sessionId:e.sessionId,userMessageId:b,cwd:e.cwd}}:{}})}async function Rz(n,e,t,s,o,i){var b;const a=n.redoUpToArchiveIndex!==void 0&&n.redoUpToArchiveIndex<s.turns.length-1,l=n.redoUpToArchiveIndex??s.turns.length-1,c=l+1,d=pr(s.turns,l),u=a?Rv(s.jsonlLines,c,e.dirName):s.jsonlLines.length,f=s.jsonlLines.slice(0,u),m=s.jsonlLines.slice(u),p=s.childBranches??[];let h;if(a&&m.length>0){const{restored:w,remaining:v}=$v(p,s.branchPointTurnIndex,c),S={...s,branchPointTurnIndex:s.branchPointTurnIndex+c,turns:s.turns.slice(c),jsonlLines:m,label:((b=s.turns[c])==null?void 0:b.userMessage)||s.label,childBranches:v.length>0?v:void 0};h=[...t.branches.map(j=>j.id===s.id?S:j),...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(`
|
|
146
|
+
`).filter(Boolean);await i({operations:d,sessionSource:e,sessionMutation:{type:"append",lines:f,expectedLineCount:x.length},state:g})}async function Iz(n,e,t,s,o,i,a){var S;let l=[...t.branches],c=o.split(`
|
|
147
|
+
`).filter(Boolean);const d=[];if(n.turns.length>s.branchPointTurnIndex+1){const j=ka(n.turns,n.turns.length-1,s.branchPointTurnIndex);d.push(...j);const{retained:k,scooped:C}=Pv(l,s.branchPointTurnIndex);l=k;const N=s.branchPointTurnIndex+1,_=Iv(c,n.turns[s.branchPointTurnIndex],N,e.dirName),A=c.slice(_);if(A.length>0){const P=Av(n.turns,s.branchPointTurnIndex,A,C);l=[...l,P],c=c.slice(0,_)}}const u=i.branchTurnIndex??s.turns.length-1,f=u+1,m=u<s.turns.length-1,p=pr(s.turns,u);d.push(...p);const h=m?Rv(s.jsonlLines,f,e.dirName):s.jsonlLines.length,g=s.jsonlLines.slice(0,h),x=s.jsonlLines.slice(h),b=s.childBranches??[];let w;if(m&&x.length>0){const{restored:j,remaining:k}=$v(b,s.branchPointTurnIndex,f);w=[{...s,branchPointTurnIndex:s.branchPointTurnIndex+f,turns:s.turns.slice(f),jsonlLines:x,label:((S=s.turns[f])==null?void 0:S.userMessage)||s.label,childBranches:k.length>0?k:void 0},...j]}else w=b;const v={...t,currentTurnIndex:s.branchPointTurnIndex+f,totalTurns:s.branchPointTurnIndex+1+f,branches:[...l.filter(j=>j.id!==s.id),...w],activeBranchId:null};await a({operations:d,sessionSource:e,sessionMutation:{type:"splice",keepLines:c.length,lines:g,expectedLineCount:o.split(`
|
|
148
|
+
`).filter(Boolean).length},state:v})}const Mz=[];function Mv(n,e,t,s=!0){const[o,i]=y.useState(null),[a,l]=y.useState(null),[c,d]=y.useState(!1),[u,f]=y.useState(null),m=y.useRef(null),p=y.useRef(0);y.useEffect(()=>{if(p.current+=1,!s||!n){i(null),l(null),f(null),m.current=null;return}if(n.sessionId===m.current)return;if(m.current=n.sessionId,!To(e==null?void 0:e.dirName).redo){i(null);return}const P=n.sessionId,T=new AbortController;return be(`/api/undo-state/${encodeURIComponent(P)}`,{signal:T.signal}).then(E=>E.ok?E.json():null).then(E=>{m.current===P&&i(E??null)}).catch(E=>{E instanceof Error&&E.name==="AbortError"||m.current===P&&i(null)}),()=>T.abort()},[s,n==null?void 0:n.sessionId]);const h=y.useCallback(async P=>{try{const T=await be("/api/undo/transaction",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({operations:P.operations,session:{dirName:P.sessionSource.dirName,fileName:P.sessionSource.fileName,mutation:P.sessionMutation},state:P.state,checkpoint:P.checkpoint})}),E=await T.json().catch(()=>null);if(!T.ok)throw f((E==null?void 0:E.error)||"Undo transaction failed"),new rr;i(P.state)}catch(T){throw T instanceof rr?T:(f(String(T)),new rr)}},[]),g=(o==null?void 0:o.branches)??Mz,{canRedo:x,redoTurnCount:b,redoBranch:w}=y.useMemo(()=>{if(!n||g.length===0)return{canRedo:!1,redoTurnCount:0,redoBranch:null};for(let P=g.length-1;P>=0;P--){const T=g[P];if(T.branchPointTurnIndex+1===n.turns.length)return{canRedo:!0,redoTurnCount:T.turns.length,redoBranch:T}}return{canRedo:!1,redoTurnCount:0,redoBranch:null}},[n,g]),v=y.useMemo(()=>{if(!w||w.jsonlLines.length===0)return[];try{return nl(w.jsonlLines.join(`
|
|
149
|
+
`)).turns}catch{return[]}},[w]),S=y.useCallback(P=>g.filter(T=>T.branchPointTurnIndex===P),[g]),j=y.useCallback(P=>{if(!s||!n)return;const T=P-1;if(T>=n.turns.length-1||T<-1)return;if(To(e==null?void 0:e.dirName).nativeRewind){const $=n.turns[P];if(!$)return;const I=n.sessionId,R=++p.current,D=()=>p.current===R&&m.current===I,O=$.id.includes("@")?$.id.slice($.id.lastIndexOf("@")+1):$.id,M=n.turns.length-P;kz(n.sessionId,O).then(F=>{var W;if(!D())return;const z=((W=F==null?void 0:F.files)==null?void 0:W.map(({path:U})=>U).filter(U=>typeof U=="string"))??[],L=F!=null&&F.available?F.fileCount??z.length:0;l({type:"undo",summary:{turnCount:M,fileCount:L,filePaths:z,operationCount:L},targetTurnIndex:T,nativeRewind:{eventId:O,mode:"conversation",filesAvailable:!!(F!=null&&F.available&&L>0)}})}).catch(()=>{D()&&l({type:"undo",summary:{turnCount:M,fileCount:0,filePaths:[],operationCount:0},targetTurnIndex:T,nativeRewind:{eventId:O,mode:"conversation"}})});return}const E=ka(n.turns,n.turns.length-1,T);l({type:"undo",summary:Hi(E,n.turns.length-1-T),targetTurnIndex:T})},[s,n,e==null?void 0:e.dirName]),k=y.useCallback(()=>{if(!s||!x||!w||!n)return;const P=pr(w.turns);l({type:"redo",summary:Hi(P,w.turns.length),targetTurnIndex:w.branchPointTurnIndex+w.turns.length,branchId:w.id})},[s,x,w,n]),C=y.useCallback(P=>{if(!s||!x||!w||!n)return;const T=P+1,E=pr(w.turns,P);l({type:"redo",summary:Hi(E,T),targetTurnIndex:w.branchPointTurnIndex+T,branchId:w.id,redoUpToArchiveIndex:P})},[s,x,w,n]),N=y.useCallback((P,T)=>{if(!s||!n)return;const E=g.find(D=>D.id===P);if(!E)return;const $=T??E.turns.length-1,I=n.turns.length>E.branchPointTurnIndex+1?ka(n.turns,n.turns.length-1,E.branchPointTurnIndex):[],R=pr(E.turns,$);l({type:"branch-switch",summary:Hi([...I,...R],$+1),targetTurnIndex:E.branchPointTurnIndex,branchId:P,branchTurnIndex:$})},[s,n,g]),_=y.useCallback(async(P=!1)=>{if(!s||!a||!n||!e){l(null);return}d(!0),f(null);try{if(a.nativeRewind){const I=P&&a.nativeRewind.filesAvailable?"conversation-and-files":"conversation",R=await Cz(n.sessionId,a.nativeRewind.eventId,I);if(!R.ok){f(R.error);return}await t(),l(null);return}const T=o??Pz(n.sessionId,n.turns.length),E=await be(`/api/sessions/${encodeURIComponent(e.dirName)}/${encodeURIComponent(e.fileName)}`);if(!E.ok){f("Failed to read session file");return}const $=await E.text();if(a.type==="undo")await $z(a,n,e,T,$,h,f);else if(a.type==="redo"){const I=g.find(R=>R.id===a.branchId);if(!I){l(null);return}await Rz(a,e,T,I,$,h)}else if(a.type==="branch-switch"){const I=g.find(R=>R.id===a.branchId);if(!I){l(null);return}await Iz(n,e,T,I,$,a,h)}try{await be("/api/stop-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:n.sessionId})})}catch{}await t(),l(null)}catch(T){if(!(T instanceof rr))throw T}finally{d(!1)}},[s,a,n,e,o,g,h,t]),A=y.useCallback(()=>{p.current+=1,l(null),f(null)},[]);return{enabled:s,undoState:o,canRedo:x,redoTurnCount:b,redoGhostTurns:v,branches:g,branchesAtTurn:S,requestUndo:j,requestRedoAll:k,requestRedoUpTo:C,requestBranchSwitch:N,confirmState:a,confirmApply:_,confirmCancel:A,isApplying:c,applyError:u}}async function Oz(n){try{const t=await(await ms("/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 i1(n){const e=await be("/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:Qw(t==null?void 0:t.mode,Xs),useBuiltInEditor:(t==null?void 0:t.useBuiltInEditor)===!0}}function Dz(){const n=B.c(26),[e,t]=y.useState(!0),[s,o]=y.useState(null),[i,a]=y.useState(null),[l,c]=y.useState(Xs),[d,u]=y.useState(!1),[f,m]=y.useState(null),[p,h]=y.useState(!1),[g,x]=y.useState(0),b=y.useRef(null),w=y.useRef(null);let v;n[0]===Symbol.for("react.memo_cache_sentinel")?(v=U=>{a(U.claudeDir),c(U.defaultAgentKind),HN(U.useBuiltInEditor)},n[0]=v):v=n[0];const S=v;let j;n[1]===Symbol.for("react.memo_cache_sentinel")?(j=async()=>{var K;(K=b.current)==null||K.abort();const U=new AbortController;b.current=U;const H=await Oz(U.signal);U.signal.aborted||b.current!==U||(m(H.url),h(H.disabled))},n[1]=j):j=n[1];const k=j;let C,N;n[2]===Symbol.for("react.memo_cache_sentinel")?(C=()=>()=>{var U,H;(U=b.current)==null||U.abort(),(H=w.current)==null||H.abort()},N=[],n[2]=C,n[3]=N):(C=n[2],N=n[3]),y.useEffect(C,N);let _;n[4]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{const U=new AbortController;return t(!0),o(null),i1(U.signal).then(S).catch(H=>{H instanceof Error&&H.name==="AbortError"||(a(null),o(H instanceof Error?H.message:"Failed to load configuration"))}).finally(()=>{U.signal.aborted||t(!1)}),()=>U.abort()},n[4]=_):_=n[4];let A;n[5]!==g?(A=[S,g],n[5]=g,n[6]=A):A=n[6],y.useEffect(_,A);let P,T;n[7]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{const U=()=>x(zz);return window.addEventListener("cogpit-auth-changed",U),()=>window.removeEventListener("cogpit-auth-changed",U)},T=[],n[7]=P,n[8]=T):(P=n[7],T=n[8]),y.useEffect(P,T);let E;n[9]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{k()},n[9]=E):E=n[9];let $;n[10]!==i?($=[i,k],n[10]=i,n[11]=$):$=n[11],y.useEffect(E,$);let I;n[12]===Symbol.for("react.memo_cache_sentinel")?(I=()=>u(!1),n[12]=I):I=n[12];const R=I;let D;n[13]!==i?(D=U=>{if(u(!1),U!==i){a(U),window.location.reload();return}x(Lz),k()},n[13]=i,n[14]=D):D=n[14];const O=D;let M;n[15]===Symbol.for("react.memo_cache_sentinel")?(M=()=>u(!0),n[15]=M):M=n[15];const F=M;let z;n[16]===Symbol.for("react.memo_cache_sentinel")?(z=()=>{var H;(H=w.current)==null||H.abort();const U=new AbortController;w.current=U,t(!0),o(null),i1(U.signal).then(K=>{U.signal.aborted||w.current!==U||S(K)}).catch(K=>{U.signal.aborted||w.current!==U||(a(null),o(K instanceof Error?K.message:"Failed to load configuration"))}).finally(()=>{U.signal.aborted||w.current!==U||t(!1)})},n[16]=z):z=n[16];const L=z;let W;return n[17]!==i||n[18]!==s||n[19]!==e||n[20]!==l||n[21]!==O||n[22]!==p||n[23]!==f||n[24]!==d?(W={configLoading:e,configError:s,claudeDir:i,defaultAgentKind:l,setClaudeDir:a,showConfigDialog:d,openConfigDialog:F,handleCloseConfigDialog:R,handleConfigSaved:O,retryConfig:L,networkUrl:f,networkAccessDisabled:p},n[17]=i,n[18]=s,n[19]=e,n[20]=l,n[21]=O,n[22]=p,n[23]=f,n[24]=d,n[25]=W):W=n[25],W}function Lz(n){return n+1}function zz(n){return n+1}const a1={authenticated:!0,edition:"personal",user:null,capabilities:Ha},wn={authenticated:!1,edition:"personal",user:null,capabilities:Vr},Ov=Object.keys(Ha);function l1(n,e){return n!==null&&n.edition===e&&n.authenticated&&(e==="personal"?n.user===null:n.user!==null)&&Ov.every(t=>{var s;return typeof((s=n.capabilities)==null?void 0:s[t])=="boolean"})}function Fz(n,e){const t={...Vr};for(const s of Ov)t[s]=n[s]&&e[s];return t}async function c1(n,e){try{const t=await n("/api/me",{signal:e});return t.ok?await t.json():null}catch{return null}}async function Bz(n){try{const e=await be("/api/hello",{signal:n});return e.ok?(await e.json()).edition==="team"?"team":"personal":null}catch{return null}}function Qo(n){var e;return bo(n),lg(((e=n.user)==null?void 0:e.id)??null),n}function Uz(n){const e=B.c(8);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={...wn,checked:!1},e[0]=t):t=e[0];const[s,o]=y.useState(t),[i,a]=y.useState(0),l=y.useRef(null),c=y.useRef(!1);let d;e[1]!==n?(d=()=>{var v;if((v=l.current)==null||v.abort(),n===null){c.current=!1,bo(wn),o({...wn,checked:!1});return}const p=c.current;c.current=!1,bo(wn),o(S=>p?{...S,capabilities:Vr,checked:!1}:{...wn,checked:!1});const h=new AbortController;l.current=h;const g=Ws(),x=c1(ms,h.signal),b=g?Bz(h.signal):Promise.resolve(n),w=g?c1(be,h.signal):Promise.resolve(null);return Promise.all([x,b,w]).then(S=>{const[j,k,C]=S;if(h.signal.aborted)return;const N=l1(j,n)?j:n==="personal"?a1:null;if(!N||k===null){o({...Qo(wn),checked:!1});return}if(!g){o({...Qo(N),checked:!0});return}const _=l1(C,k)?C:k==="personal"?a1:null;if(!_){o({...Qo(wn),checked:!1});return}o({...Qo({authenticated:N.authenticated,edition:N.edition,user:N.user,capabilities:Fz(N.capabilities,_.capabilities)}),checked:!0})}).catch(()=>{h.signal.aborted||o({...Qo(wn),checked:!1})}),()=>{h.abort(),l.current===h&&(l.current=null)}},e[1]=n,e[2]=d):d=e[2];let u;e[3]!==n||e[4]!==i?(u=[n,i],e[3]=n,e[4]=i,e[5]=u):u=e[5],y.useEffect(d,u);let f,m;return e[6]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{const p=()=>{var g;(g=l.current)==null||g.abort(),c.current=!1,bo(wn),lg(null),o({...wn,checked:!1}),a(qz)},h=g=>{var w,v;const x=vt();if(x===Tt)return;const b=(w=g.detail)==null?void 0:w.deviceId;b&&b!==x||((v=l.current)==null||v.abort(),c.current=!0,bo(wn),o(Hz),a(Wz))};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]=f,e[7]=m):(f=e[6],m=e[7]),y.useEffect(f,m),s}function Wz(n){return n+1}function Hz(n){return{...n,capabilities:Vr,checked:!1}}function qz(n){return n+1}const Kz=3e4;function Vz(n){const[e,t]=y.useState(()=>({dirName:n,worktrees:[],loading:n!==null,error:null})),s=y.useRef(0),o=y.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 be(`/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]);y.useEffect(()=>{if(!n){s.current+=1;return}o();const a=setInterval(()=>void o(),Kz);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 Gz(){const n=B.c(3),[e,t]=y.useState(!1);let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=async()=>{t(!0);try{await be("/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 Yz(n,e){return n?`${n}.jsonl`:e??null}async function Dv(n){try{const e=await be(`/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 Xz=300,vc=new Map;function md(n,e){const t=Vt(n),s=vc.get(t),o=s?{...s.patch,...e}:e;s&&clearTimeout(s.timer);const i=setTimeout(()=>{vc.delete(t),Vt(n)===t&&(async()=>{try{await be(`/api/session-config/${encodeURIComponent(n)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)})}catch{}})()},Xz);vc.set(t,{patch:o,timer:i})}function pd(n){return new Set(n.filter(e=>e.status==="connected").map(e=>e.name))}async function d1(n){const e=await Dv(n);return Array.isArray(e==null?void 0:e.mcpServers)?e.mcpServers:null}function yc(n,e){md(n,{mcpServers:e})}async function Jz(n){if(!n.ok)return null;const e=await n.json();return{servers:e.servers??[],configs:e.configs??{}}}async function u1(n,e){try{const t=await be(n,{signal:e});if(e.aborted)return null;const s=await Jz(t);return e.aborted?null:s}catch{return null}}async function f1(n,e,t){const s=pd(t);if(s.size===0)return[];if(n){const o=await d1(n);if(o)return o.filter(i=>s.has(i))}if(e&&n!==e){const o=await d1(e);if(o)return o.filter(i=>s.has(i))}return[...s]}function Qz(n,e,t,s=!0){const[o,i]=y.useState([]),[a,l]=y.useState({}),[c,d]=y.useState([]),[u,f]=y.useState(!1),[m,p]=y.useState(!1),h=y.useRef(null),g=y.useRef(e);g.current=e;const x=t??e??null,b=y.useRef(x);b.current=x;const w=y.useRef(void 0);y.useEffect(()=>{var N,_;if(!s||!n){(N=h.current)==null||N.abort(),w.current=void 0,i([]),l({}),d([]),f(!1),p(!1);return}const C=new AbortController;return(_=h.current)==null||_.abort(),i([]),l({}),d([]),f(!0),p(!1),w.current=n,u1(`/api/mcp-servers?cwd=${encodeURIComponent(n)}`,C.signal).then(async A=>{if(C.signal.aborted||w.current!==n||!A)return;i(A.servers),l(A.configs);const P=await f1(b.current,g.current,A.servers);C.signal.aborted||w.current!==n||d(P)}).finally(()=>{C.signal.aborted||w.current!==n||(f(!1),p(!0))}),()=>C.abort()},[n,s]),y.useEffect(()=>()=>{var C;return(C=h.current)==null?void 0:C.abort()},[]),y.useEffect(()=>{if(o.length===0||!x)return;let C=!1;return f1(x,e,o).then(N=>{C||b.current!==x||d(N)}),()=>{C=!0}},[x]);const v=y.useCallback(C=>{d(N=>{const _=N.includes(C)?N.filter(A=>A!==C):[...N,C];return b.current&&yc(b.current,_),_})},[]),S=y.useCallback(C=>{d(()=>(b.current&&yc(b.current,C),C))},[]),j=y.useCallback(()=>{var N;if(!s||!n)return;(N=h.current)==null||N.abort();const C=new AbortController;h.current=C,f(!0),u1(`/api/mcp-servers?cwd=${encodeURIComponent(n)}&refresh=1`,C.signal).then(_=>{if(C.signal.aborted||w.current!==n||!_)return;i(_.servers),l(_.configs);const A=pd(_.servers);d(P=>{const T=P.filter(E=>A.has(E));return b.current&&yc(b.current,T),T})}).finally(()=>{C.signal.aborted||h.current!==C||f(!1)})},[n,s]),k=y.useMemo(()=>{if(o.length===0)return null;const C=pd(o);if(c.length===C.size&&C.size>0&&c.every(A=>C.has(A))||!c.every(A=>a[A]))return null;const _=Object.fromEntries(c.map(A=>[A,a[A]]));return JSON.stringify({mcpServers:_})},[c,a,o]);return{servers:o,selectedServers:c,mcpConfigJson:k,loading:u,loaded:m,toggleServer:v,setSelection:S,refresh:j}}function Zz(n){var s,o;const e=B.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 b=x.input;Array.isArray(b.todos)&&(i=b.todos);continue}if(x.name==="TaskCreate"){const b=x.input;h=h+1;const v=((o=(s=x.result)==null?void 0:s.match(/(?:Task\s*#?|task[_ ]?id["': ]+)(\d+)/i))==null?void 0:o[1])??String(h);p.set(v,{id:v,content:b.subject||b.description||`Task ${v}`,activeForm:b.activeForm||b.subject||`Working on task ${v}`,status:"pending",owner:b.owner});continue}if(x.name==="TaskUpdate"){const b=x.input,w=String(b.taskId??"");if(!w)continue;if(b.status==="deleted"){p.delete(w);continue}const v=p.get(w)??{id:w,content:b.subject||b.description||`Task ${w}`,activeForm:b.activeForm||b.subject||`Working on task ${w}`,status:"pending"};p.set(w,{...v,content:b.subject||b.description||v.content,activeForm:b.activeForm||v.activeForm,status:b.status||v.status,owner:b.owner??v.owner,blockedBy:b.addBlockedBy?[...new Set([...v.blockedBy??[],...b.addBlockedBy])]:v.blockedBy})}}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(tF),e[4]=l,e[5]=c):c=e[5];const d=c.length;let u;e[6]!==l?(u=l.find(eF)??null,e[6]=l,e[7]=u):u=e[7];const f=u;let m;e[8]!==d||e[9]!==f||e[10]!==l?(m={todos:l,completed:d,total:l.length,inProgress:f},e[8]=d,e[9]=f,e[10]=l,e[11]=m):m=e[11],t=m}return t}function eF(n){return n.status==="in_progress"}function tF(n){return n.status==="completed"}function nF(n){const e=B.c(4);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];const[s,o]=y.useState(t);let i,a;return e[1]!==n?(i=()=>{if(!n){o([]);return}let l=!1;const c=async function(){try{const f=await be(`/api/background-agents?cwd=${encodeURIComponent(n)}`);if(l)return;if(f.ok){const m=await f.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]),y.useEffect(i,a),s}function sF(n,e){const t=B.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]=y.useState(o),[l,c]=y.useState(!1),d=y.useRef(void 0);let u,f;t[1]!==n||t[2]!==s?(u=()=>{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)}`:"";be(`/api/slash-suggestions${p}`).then(oF).then(h=>a(h.suggestions||[])).catch(()=>a([])).finally(()=>c(!1))},f=[n,s],t[1]=n,t[2]=s,t[3]=u,t[4]=f):(u=t[3],f=t[4]),y.useEffect(u,f);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 oF(n){return n.json()}function m1(n,e){const t=B.c(6),[s,o]=oi(n,e),i=typeof s=="boolean"?s:e;let a;t[0]!==e||t[1]!==o?(a=d=>{o(u=>typeof d=="function"?d(typeof u=="boolean"?u: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 p1(){if(typeof window>"u")return _t.fileChanges;try{if(JSON.parse(localStorage.getItem("panel-worktrees-visible")??"false")===!0)return _t.worktrees;if(JSON.parse(localStorage.getItem("panel-stats-visible")??"false")===!0)return _t.sessionInfo;if(JSON.parse(localStorage.getItem("panel-file-changes-visible")??"true")===!1)return null}catch{}return _t.fileChanges}function rF(n,e){const t=B.c(46),[s,o]=m1("panel-sidebar-visible",!0),[i,a]=m1("panel-workflows-visible",!1);let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=p1(),t[0]=l):l=t[0];const[c,d]=oi("workspace-panel-active",l);let u;t[1]!==c?(u=typeof c=="string"||c===null?c:p1(),t[1]=c,t[2]=u):u=t[2];const f=u,[m,p]=y.useState(!1),[h,g]=y.useState(!1);let x;t[3]!==o||t[4]!==s?(x=()=>{y.startTransition(()=>o(!s))},t[3]=o,t[4]=s,t[5]=x):x=t[5];const b=x;let w;t[6]!==a?(w=()=>a(aF),t[6]=a,t[7]=w):w=t[7];const v=w;let S;t[8]!==e||t[9]!==d||t[10]!==n.mainView?(S=H=>{y.startTransition(()=>{const K=n.mainView==="config"||n.mainView==="mission";n.mainView==="config"&&e({type:"CLOSE_CONFIG"}),n.mainView==="mission"&&e({type:"CLOSE_MISSION"}),d(V=>K||V!==H?H:null)})},t[8]=e,t[9]=d,t[10]=n.mainView,t[11]=S):S=t[11];const j=S;let k;t[12]!==e||t[13]!==d||t[14]!==n.mainView?(k=H=>{y.startTransition(()=>{n.mainView==="config"&&e({type:"CLOSE_CONFIG"}),n.mainView==="mission"&&e({type:"CLOSE_MISSION"}),d(H)})},t[12]=e,t[13]=d,t[14]=n.mainView,t[15]=k):k=t[15];const C=k;let N;t[16]!==d?(N=()=>{y.startTransition(()=>d(null))},t[16]=d,t[17]=N):N=t[17];const _=N;let A;t[18]!==e||t[19]!==n.mainView?(A=()=>{const H=n.mainView==="config";y.startTransition(()=>{e({type:H?"CLOSE_CONFIG":"OPEN_CONFIG"})})},t[18]=e,t[19]=n.mainView,t[20]=A):A=t[20];const P=A;let T;t[21]!==e||t[22]!==n.mainView?(T=()=>{const H=n.mainView==="mission";y.startTransition(()=>{e({type:H?"CLOSE_MISSION":"OPEN_MISSION"})})},t[21]=e,t[22]=n.mainView,t[23]=T):T=t[23];const E=T;let $;t[24]!==e?($=H=>{y.startTransition(()=>{e({type:"OPEN_CONFIG",filePath:H})})},t[24]=e,t[25]=$):$=t[25];const I=$;let R;t[26]===Symbol.for("react.memo_cache_sentinel")?(R=()=>p(!0),t[26]=R):R=t[26];const D=R;let O;t[27]===Symbol.for("react.memo_cache_sentinel")?(O=()=>p(!1),t[27]=O):O=t[27];const M=O;let F;t[28]===Symbol.for("react.memo_cache_sentinel")?(F=()=>g(iF),t[28]=F):F=t[28];const z=F;let L;t[29]===Symbol.for("react.memo_cache_sentinel")?(L=()=>g(!1),t[29]=L):L=t[29];const W=L;let U;return t[30]!==f||t[31]!==_||t[32]!==I||t[33]!==P||t[34]!==E||t[35]!==b||t[36]!==v||t[37]!==C||t[38]!==o||t[39]!==a||t[40]!==m||t[41]!==s||t[42]!==h||t[43]!==i||t[44]!==j?(U={showSidebar:s,showWorkflows:i,activeWorkspacePanel:f,showProjectSwitcher:m,showThemeSelector:h,handleToggleSidebar:b,handleToggleWorkflows:v,toggleWorkspacePanel:j,openWorkspacePanel:C,closeWorkspacePanel:_,handleToggleConfig:P,handleToggleMission:E,handleEditConfig:I,handleOpenProjectSwitcher:D,handleCloseProjectSwitcher:M,handleToggleThemeSelector:z,handleCloseThemeSelector:W,setShowSidebar:o,setShowWorkflows:a},t[30]=f,t[31]=_,t[32]=I,t[33]=P,t[34]=E,t[35]=b,t[36]=v,t[37]=C,t[38]=o,t[39]=a,t[40]=m,t[41]=s,t[42]=h,t[43]=i,t[44]=j,t[45]=U):U=t[45],U}function iF(n){return!n}function aF(n){return!n}function lF(n){var K;const{state:e,dispatch:t,isMobile:s,handleJumpToTurn:o,markPermissionsApplied:i,hasPermsPendingChanges:a,permissionsConfig:l,selectedModel:c,selectedEffort:d,fastMode:u,ultracode:f,mcpConfig:m,scrollRequestScrollToTop:p,handleDashboardSelect:h,workerParse:g}=n,x=y.useCallback(async()=>{if(!e.sessionSource)return;const{dirName:V,fileName:Y}=e.sessionSource;try{const{parsed:q,source:J}=await Sv(V,Y,g,"session");t({type:"RELOAD_SESSION_CONTENT",session:q,source:J})}catch{}},[e.sessionSource,t,g]),[b,w]=y.useState(null),v=y.useCallback(V=>w(V),[]),S=y.useCallback(()=>w(null),[]),j=y.useCallback(async(V,Y)=>{try{const q=await be("/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:Q,source:X}=await Ks(J.dirName,J.fileName,g,"session");t({type:"LOAD_SESSION",session:Q,source:X,isMobile:s})}catch{}},[t,s,g]),k=y.useCallback(()=>{e.sessionSource&&j(e.sessionSource.dirName,e.sessionSource.fileName)},[e.sessionSource,j]),C=y.useCallback(async(V,Y)=>{try{await be("/api/delete-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dirName:V,fileName:Y})})}catch{}},[]),N=y.useCallback(async V=>{var Q,X;if(!e.sessionSource)return;const{dirName:Y,fileName:q}=e.sessionSource,J=(X=(Q=e.session)==null?void 0:Q.turns[V])==null?void 0:X.id;try{const Z=await be("/api/branch-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dirName:Y,fileName:q,turnIndex:V,turnUuid:J})});if(!Z.ok)return;const te=await Z.json(),{parsed:ne,source:oe}=await Ks(te.dirName,te.fileName,g,"session");t({type:"LOAD_SESSION",session:ne,source:oe,isMobile:s})}catch{}},[e.sessionSource,e.session,t,s,g]),_=y.useCallback((V,Y)=>{o(V,Y),t({type:"SET_MOBILE_TAB",tab:"chat"})},[o,t]),[A,P]=y.useState({}),T=y.useRef(c);T.current=c;const E=y.useRef(d);E.current=d;const $=y.useRef(m);$.current=m;const I=y.useRef(u);I.current=u;const R=y.useRef(f);R.current=f;const D=y.useRef(l);D.current=l;const O=((K=e.session)==null?void 0:K.sessionId)??null,M=y.useRef(null);y.useEffect(()=>{O!==M.current&&(M.current=O,O&&P(V=>O in V?V:{...V,[O]:{model:T.current,effort:E.current,fastMode:I.current,ultracode:R.current,mcpConfig:$.current}}))},[O]);const F=O?A[O]:void 0,z=m!==((F==null?void 0:F.mcpConfig)??null),L=F!=null&&(c!==F.model||d!==F.effort||u!==F.fastMode||f!==F.ultracode||a||z),W=y.useCallback(async()=>{var te,ne;if(!O)return;const V=T.current,Y=E.current,q=I.current,J=R.current,Q=$.current,X=D.current,Z=((te=e.sessionSource)==null?void 0:te.agentKind)??$t(((ne=e.sessionSource)==null?void 0:ne.dirName)??null);Gt(Z).settingsApply==="live"&&await be(`/api/claude/settings/${encodeURIComponent(O)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:V,effort:Y,fastMode:q,ultracode:J,mcpConfig:Q,permissionMode:X.mode,allowedTools:X.allowedTools,disallowedTools:X.disallowedTools})}),P(oe=>({...oe,[O]:{model:V,effort:Y,fastMode:q,ultracode:J,mcpConfig:Q}})),i()},[O,e.sessionSource,i]),U=y.useCallback(async()=>{if(O)try{await be("/api/stop-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:O})})}catch{}},[O]),H=y.useCallback((V,Y)=>{Ns(Y)&&p(),h(V,Y)},[p,h]);return{reloadSession:x,branchModalTurn:b,setBranchModalTurn:w,handleOpenBranches:v,handleCloseBranchModal:S,handleDuplicateSessionByPath:j,handleDuplicateSession:k,handleDeleteSession:C,handleBranchFromHere:N,handleMobileJumpToTurn:_,hasSettingsChanges:L,handleApplySettings:W,handleStopSession:U,handleLoadSessionScrollAware:H}}function Lv(){const n=B.c(6),e=y.useRef(null);let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t=new Map,n[0]=t):t=n[0];const s=y.useRef(t),o=y.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-CnmfpqaO.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]),y.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(()=>nl(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 b=o.current;s.current.set(b,{resolve:g,reject:x}),h.postMessage({type:"append",id:b,existing:m,newText:p})}):Promise.resolve().then(()=>h_(m,p))},n[4]=d):d=n[4];const u=d;let f;return n[5]===Symbol.for("react.memo_cache_sentinel")?(f={parse:c,append:u},n[5]=f):f=n[5],f}const cF=30;function zv({dirName:n,fileName:e,sessionChangeKey:t,workerParse:s,onOlderTurns:o}){const[i,a]=y.useState(!1),[l,c]=y.useState(!1),d=y.useRef(""),u=y.useRef(null),f=`${n??""}::${e??""}::${t}`;return y.useEffect(()=>{d.current=f,u.current=null,c(!1);const p=n&&e?Cn.get(n,e):void 0;a((p==null?void 0:p.hasMore)??!1),p&&p.olderTurns.length>0&&o(p.olderTurns)},[f,n,e,t,o]),{loadMore:y.useCallback(async()=>{if(!n||!e||u.current)return 0;const p=`${n}::${e}::${t}`,h=Cn.get(n,e);if(!(h!=null&&h.hasMore))return d.current===p&&a(!1),0;const g=Symbol("paging-flight");u.current=g,c(!0);try{const x=await be(`/api/sessions/${encodeURIComponent(n)}/${encodeURIComponent(e)}?before=${h.nextByteOffset}&count=${cF}`);if(!x.ok)return 0;const b=await x.json(),w=b.lines.length>0&&b.hasMore;if(d.current===p&&a(w),b.lines.length===0)return Cn.update(n,e,{hasMore:w,nextByteOffset:b.byteOffset}),0;const v=new Set(b.headerLines),S=b.lines.filter(C=>!v.has(C)),j=await s([...b.headerLines,...S].join(`
|
|
150
|
+
`)),k=V2(h.olderTurns,j.turns,h.source.agentKind);return Cn.update(n,e,{hasMore:w,nextByteOffset:b.byteOffset,olderTurns:k}),d.current!==p?0:(o(k),j.turns.length)}finally{u.current===g&&(u.current=null,d.current===p&&c(!1))}},[n,e,t,s,o]),hasMore:i,isLoadingOlder:l}}function dF(n){const e=B.c(43),{agentKind:t,session:s,sessionSource:o,pendingDirName:i,isLive:a}=n,l=t??Xs,[c,d]=y.useState(""),[u,f]=y.useState(""),[m,p]=y.useState(!1),[h,g]=y.useState(!1),{options:x,fastTier:b,imageInput:w,normalizeEffort:v}=mg(l,c),S=c||(s==null?void 0:s.model);let j;e[0]!==l||e[1]!==S?(j=hj(l,S),e[0]=l,e[1]=S,e[2]=j):j=e[2];const k=j,C=h&&k;let N;e[3]!==v||e[4]!==u||e[5]!==C?(N=C?"xhigh":v(u),e[3]=v,e[4]=u,e[5]=C,e[6]=N):N=e[6];const _=N,A=!!b,P=A&&m,[T,E]=y.useState(null),$=y.useRef(null),I=(o==null?void 0:o.fileName)??null,R=y.useRef(I);let D,O;e[7]!==I?(D=()=>{const Z=R.current;R.current=I,!(Z===null||Z===I)&&g(!1)},O=[I],e[7]=I,e[8]=D,e[9]=O):(D=e[8],O=e[9]),y.useEffect(D,O);let M,F;e[10]!==i?(M=()=>{i&&g(!1)},F=[i],e[10]=i,e[11]=M,e[12]=F):(M=e[11],F=e[12]),y.useEffect(M,F);let z;e[13]!==l?(z=Z=>{d(te=>te===Z?"":te),E(`${Z} is unavailable for this account. Cogpit retried the turn with ${en(l).displayName}'s default model.`)},e[13]=l,e[14]=z):z=e[14];const L=z;let W;e[15]===Symbol.for("react.memo_cache_sentinel")?(W=()=>{E(null)},e[15]=W):W=e[15];const U=W;let H,K;e[16]!==x||e[17]!==i||e[18]!==c||e[19]!==o?(H=()=>{c&&(!o&&!i||x.some(Z=>Z.value===c)||d(""))},K=[x,c,o,i],e[16]=x,e[17]=i,e[18]=c,e[19]=o,e[20]=H,e[21]=K):(H=e[20],K=e[21]),y.useEffect(H,K);let V,Y;e[22]!==T?(V=()=>{if(!T)return;const Z=setTimeout(()=>E(null),12e3);return()=>clearTimeout(Z)},Y=[T],e[22]=T,e[23]=V,e[24]=Y):(V=e[23],Y=e[24]),y.useEffect(V,Y);const q=s==null?void 0:s.rawMessages;let J,Q;e[25]!==l||e[26]!==a||e[27]!==q?(J=()=>{if(!a||!q||!Gt(l).modelFallbackNotices)return;let Z;for(let ae=q.length-1;ae>=0;ae=ae-1,ae){const se=q[ae];if(se.type==="system"&&se.subtype==="model_refusal_fallback"){Z=se;break}}if(!Z)return;const te=typeof Z.uuid=="string"?Z.uuid:`${String(Z.original_model)}:${String(Z.fallback_model)}:${String(Z.request_id)}`;if($.current===te)return;$.current=te;const ne=typeof Z.original_model=="string"?Z.original_model:"Fable",oe=typeof Z.fallback_model=="string"?Z.fallback_model:"Opus",re=typeof Z.api_refusal_explanation=="string"?` ${Z.api_refusal_explanation}`:"";E(`${ne} could not handle this request, so Claude continued with ${oe}.${re}`)},Q=[a,q,l],e[25]=l,e[26]=a,e[27]=q,e[28]=J,e[29]=Q):(J=e[28],Q=e[29]),y.useEffect(J,Q);let X;return e[30]!==_||e[31]!==P||e[32]!==A||e[33]!==m||e[34]!==L||e[35]!==w||e[36]!==T||e[37]!==u||e[38]!==c||e[39]!==C||e[40]!==k||e[41]!==h?(X={selectedModel:c,setSelectedModel:d,selectedEffort:u,setSelectedEffort:f,fastModeEnabled:m,ultracodeEnabled:h,effectiveEffort:_,fastModeAvailable:A,fastModeActive:P,setFastModeEnabled:p,ultracodeAvailable:k,ultracodeActive:C,setUltracodeEnabled:g,imageInputAvailable:w,modelFallbackNotice:T,dismissModelFallbackNotice:U,handleModelRejected:L},e[30]=_,e[31]=P,e[32]=A,e[33]=m,e[34]=L,e[35]=w,e[36]=T,e[37]=u,e[38]=c,e[39]=C,e[40]=k,e[41]=h,e[42]=X):X=e[42],X}const uF=["model","effort","fastMode","ultracode","permissionMode"];function fF({sessionKey:n,values:e,onHydrate:t}){const s=y.useRef(null),o=y.useRef(null),i=y.useRef(t);i.current=t;const a=y.useRef(e);a.current=e,y.useEffect(()=>{if(s.current=null,o.current=null,!n)return;let c=!1;return Dv(n).then(d=>{if(c||d===null)return;if(uF.some(f=>d[f]!==void 0)){i.current(d);const f=a.current,m={model:d.model??f.model,effort:d.effort??f.effort,fastMode:d.fastMode??f.fastMode,ultracode:d.ultracode??f.ultracode,permissionMode:d.permissionMode??f.permissionMode};o.current=JSON.stringify(m)}else md(n,a.current),o.current=JSON.stringify(a.current);s.current=n}),()=>{c=!0}},[n]);const l=JSON.stringify(e);y.useEffect(()=>{!n||s.current!==n||l!==o.current&&(o.current=l,md(n,a.current))},[l,n])}function mF(n){const[e,t]=y.useState(new Map),[s,o]=y.useState(null),[i,a]=y.useState(!0),l=y.useRef(new Map),c=y.useRef(null);y.useEffect(()=>{const x=n??null,b=c.current;if(b&&b!==x&&l.current.set(b,{activeId:s,collapsed:i}),x!==b){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=y.useCallback(()=>a(x=>!x),[]),u=y.useCallback(x=>{t(b=>{const w=new Map(b);return w.set(x.id,x),w}),o(x.id),a(!1)},[]),f=y.useCallback(x=>{t(b=>{const w=new Map(b);return w.delete(x),o(v=>{if(v!==x)return v;const S=[...w.keys()];return S.length>0?S[S.length-1]:null}),w})},[]),m=y.useCallback(x=>{o(x),a(!1)},[]),p=y.useCallback((x,b)=>{t(w=>{const v=w.get(x);if(!v||v.status===b)return w;const S=new Map(w);return S.set(x,{...v,status:b}),S})},[]),h=y.useCallback(x=>{t(b=>{let w=!1;const v=new Map(b),S=new Set(x.map(j=>j.id));for(const[j,k]of v)k.type==="task"&&!S.has(j)&&(v.delete(j),w=!0);for(const j of x){const k=v.get(j.id);k?(k.name!==j.title||k.outputPath!==j.outputPath)&&(v.set(j.id,{...k,name:j.title,outputPath:j.outputPath}),w=!0):(v.set(j.id,{id:j.id,name:j.title,type:"task",status:"running",outputPath:j.outputPath}),w=!0)}return w?v:b})},[]),g=y.useCallback((x,b,w)=>{b&&w&&t(v=>{if(v.has(x))return v;const S=new Map(v);return S.set(x,{id:x,name:w,type:"task",status:"running",outputPath:b}),S}),o(v=>v===x?(a(!0),v):(a(!1),x))},[]);return{processes:e,activeProcessId:s,collapsed:i,toggleCollapse:d,addProcess:u,removeProcess:f,setActive:m,updateProcessStatus:p,handleServersChanged:h,handleToggleServer:g}}function pF(n){const e=B.c(54),{sessionId:t,sessionCwd:s,pendingPath:o,sessionDirName:i,pendingDirName:a,dashboardProject:l,supportsFileWorkspace:c,activeWorkspacePanel:d,openWorkspacePanel:u,closeWorkspacePanel:f}=n,m=mF(t),[p,h]=y.useState(null),[g,x]=y.useState(0),b=y.useRef(0),w=s??o??void 0,v=!!(w&&(p==null?void 0:p.kind)==="preview"&&p.cwd===w),S=(p==null?void 0:p.kind)==="project-files"&&p.anchorCwd===(w??null)?p:null;let j;e[0]!==a||e[1]!==o?(j={path:o,dirName:a},e[0]=a,e[1]=o,e[2]=j):j=e[2];const k=j;let C;e[3]!==l||e[4]!==a||e[5]!==o||e[6]!==s||e[7]!==i?(C=()=>{if(Ws()){console.warn("[open-terminal] unavailable for remote devices");return}const q=s??o??void 0,J=i??a??l??void 0;if(!q&&!J){console.warn("[open-terminal] no project path available");return}be("/api/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:q,dirName:J})}).then(yF).catch(vF)},e[3]=l,e[4]=a,e[5]=o,e[6]=s,e[7]=i,e[8]=C):C=e[8];const N=C;let _;e[9]!==l||e[10]!==a||e[11]!==o||e[12]!==s||e[13]!==i?(_=q=>{if(Ws()){console.warn("[mcp-auth] unavailable for remote devices");return}const J=s??o??void 0,Q=i??a??l??void 0;!J&&!Q||be("/api/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:J,dirName:Q,command:"claude /mcp"})}).catch(bF)},e[9]=l,e[10]=a,e[11]=o,e[12]=s,e[13]=i,e[14]=_):_=e[14];const A=_;let P;e[15]!==o||e[16]!==m||e[17]!==s?(P=()=>{const J=[...m.processes.values()].filter(xF).at(-1);if(!J){(s??o)&&x(gF);return}m.activeProcessId===J.id&&!m.collapsed?m.toggleCollapse():m.setActive(J.id)},e[15]=o,e[16]=m,e[17]=s,e[18]=P):P=e[18];const T=P;let E;e[19]!==o||e[20]!==s?(E=()=>{(s??o)&&x(hF)},e[19]=o,e[20]=s,e[21]=E):E=e[21];const $=E;let I;e[22]!==f||e[23]!==w||e[24]!==v?(I=()=>{w&&y.startTransition(()=>{f(),h(v?null:{kind:"preview",cwd:w})})},e[22]=f,e[23]=w,e[24]=v,e[25]=I):I=e[25];const R=I;let D;e[26]!==d||e[27]!==f||e[28]!==w||e[29]!==u?(D=()=>{if(w){if(d===_t.projectFiles){f();return}y.startTransition(()=>{h({kind:"project-files",root:w,anchorCwd:w,request:null}),u(_t.projectFiles)})}},e[26]=d,e[27]=f,e[28]=w,e[29]=u,e[30]=D):D=e[30];const O=D;let M;e[31]!==w||e[32]!==u||e[33]!==c?(M=q=>{if(!c)return!1;const J=KN(q,w);if(!J)return!1;b.current=b.current+1;const Q=b.current;return y.startTransition(()=>h({kind:"project-files",root:J.root,anchorCwd:w??null,request:J.file?{file:J.file,mode:J.mode,line:J.line,token:Q}:null})),u(_t.projectFiles),!0},e[31]=w,e[32]=u,e[33]=c,e[34]=M):M=e[34];const F=M;let z,L;e[35]!==F?(L=()=>qN(F),z=[F],e[35]=F,e[36]=z,e[37]=L):(z=e[36],L=e[37]),y.useEffect(L,z);let W;e[38]===Symbol.for("react.memo_cache_sentinel")?(W=()=>{y.startTransition(()=>h(null))},e[38]=W):W=e[38];const U=W,H=!!(w&&d===_t.projectFiles),K=S==null?void 0:S.root,V=(S==null?void 0:S.request)??null;let Y;return e[39]!==w||e[40]!==A||e[41]!==$||e[42]!==N||e[43]!==T||e[44]!==R||e[45]!==O||e[46]!==g||e[47]!==k||e[48]!==m||e[49]!==v||e[50]!==H||e[51]!==K||e[52]!==V?(Y={processPanel:m,currentCwd:w,showPreview:v,showProjectFiles:H,projectFilesRoot:K,projectFilesRequest:V,launchTerminalRequest:g,pendingProject:k,handleOpenTerminal:N,handleMcpAuth:A,handleToggleIntegratedTerminal:T,handleNewIntegratedTerminal:$,handleTogglePreview:R,handleToggleProjectFiles:O,closeRightWorkspace:U},e[39]=w,e[40]=A,e[41]=$,e[42]=N,e[43]=T,e[44]=R,e[45]=O,e[46]=g,e[47]=k,e[48]=m,e[49]=v,e[50]=H,e[51]=K,e[52]=V,e[53]=Y):Y=e[53],Y}function hF(n){return n+1}function gF(n){return n+1}function xF(n){return n.type==="terminal"}function bF(n){return console.error("[mcp-auth] open-terminal failed:",n)}function vF(n){return console.error("[open-terminal] fetch failed:",n)}function yF(n){n.ok||n.json().then(jF).catch(wF)}function wF(){}function jF(n){return console.error("[open-terminal]",n.error)}function SF(n){const e=n.replace(/<[^>]+>[\s\S]*?<\/[^>]+>/g,"").trim();if(!e)return"";const t=e.split(`
|
|
151
|
+
`)[0].trim();return t.length<=60?t:t.slice(0,57)+"..."}const NF={totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:0};function Fv(n,e){return{dirName:n.dirName,fileName:n.fileName,rawText:e,agentKind:$t(n.dirName)}}function kF(n){return{sessionId:n.sessionId,version:"",gitBranch:"",cwd:"",slug:"",name:"",model:"",turns:[],stats:{...NF},rawMessages:[],agentKind:$t(n.dirName)}}function Bv(n){if(!(n!=null&&n.trim()))return null;try{return{rawText:n,parsed:nl(n)}}catch{return null}}async function CF(n,e,t=3,s=100,o=!0){if(o){const i=Bv(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 be(`/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:nl(l)}}catch{}}i<t-1&&await new Promise(l=>setTimeout(l,s))}return null}async function _F(n,e,t,s){let o=s;for(let i=0;i<30;i++){if(e.signal.aborted)return;const a=await CF(n,e,1,0,!1);if(a&&a.rawText!==o){t({type:"RELOAD_SESSION_CONTENT",session:a.parsed,source:Fv(n,a.rawText)});return}o=(a==null?void 0:a.rawText)??o,await new Promise(l=>setTimeout(l,200))}}async function h1(n,e,t,s,o){const i=Bv(n.initialContent),a=(i==null?void 0:i.rawText)??"",l=(i==null?void 0:i.parsed)??kF(n),c=Fv(n,a);return t({type:"FINALIZE_SESSION",session:l,source:c,isMobile:s}),o(l,c),_F(n,e,t,a),n.sessionId}async function TF(n,e,t,s){const o=await be(`/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(u=>{const f=u.lastModified?new Date(u.lastModified).getTime():0;return Number.isFinite(f)&&f>=a}),d=c.find(u=>{var f,m;return((f=u.firstUserMessage)==null?void 0:f.trim())===l||((m=u.lastUserMessage)==null?void 0:m.trim())===l})??c[0];return d?{dirName:n,fileName:d.fileName,sessionId:d.sessionId}:null}function EF({permissionsConfig:n,dispatch:e,isMobile:t,onSessionFinalized:s,onCreateStarted:o,onModelRejected:i,model:a,effort:l,fastMode:c,ultracode:d,mcpConfig:u}){const[f,m]=y.useState(!1),[p,h]=y.useState(null),[g,x]=y.useState(!1),[b,w]=y.useState(""),v=y.useRef(null),S=y.useRef(null),j=y.useRef(null),k=y.useCallback((A,P)=>{S.current=A,j.current=P??null,h(null),m(!1),e({type:"INIT_PENDING_SESSION",dirName:A,cwd:P,isMobile:t})},[e,t]),C=y.useCallback(async(A,P)=>{var D;const T=S.current;if(!T)return null;const E=$t(T),$=j.current;(D=v.current)==null||D.abort();const I=new AbortController;v.current=I,m(!0),h(null),o==null||o(A);const R=Date.now();try{const O=SF(A),M=en(E),{capabilities:F}=M,z={dirName:T,cwd:M.dirName.lossy?$??void 0:void 0,message:A,images:P,permissions:n,effort:l||void 0,fastMode:c?!0:void 0,ultracode:F.ultracode&&d?!0:void 0,name:F.namedSessions&&O||void 0,worktreeName:F.worktrees&&g?b||xj(A):void 0,mcpConfig:F.mcp&&u||void 0},{res:L,errorMessage:W}=await vv(K=>be("/api/create-and-send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...z,model:K}),signal:I.signal}),{model:a,agentKind:E,errorFallback:"Unknown error",onModelRejected:i});if(!L.ok){if(E==="codex"){const K=await TF(T,A,R,I);if(K){S.current=null,j.current=null;const V=await h1(K,I,e,t,s);return O&&V&&cd(V,O),V}}return h(W||`Failed to create session (${L.status})`),null}const U=await L.json();S.current=null,j.current=null;const H=await h1(U,I,e,t,s);return O&&H&&cd(H,O),H}catch(O){return I.signal.aborted||h(O instanceof Error?O.message:"Failed to create session"),null}finally{I.signal.aborted||m(!1)}},[n,a,l,c,d,u,g,b,e,t,s,o,i]),N=y.useCallback(()=>h(null),[]),_=y.useCallback(()=>{var A;(A=v.current)==null||A.abort(),v.current=null,S.current=null,j.current=null,m(!1),h(null)},[]);return{creatingSession:f,createError:p,clearCreateError:N,handleNewSession:k,createAndSend:C,cancelCreation:_,pendingDirNameRef:S,worktreeEnabled:g,setWorktreeEnabled:x,worktreeName:b,setWorktreeName:w}}function AF(n){const e=B.c(40),{permissionsConfig:t,dispatch:s,isMobile:o,defaultAgentKind:i,pendingDirName:a,pendingCwd:l,model:c,effort:d,fastMode:u,ultracode:f,mcpConfig:m,onModelRejected:p}=n,h=y.useRef(null),g=y.useRef(null),[x,b]=y.useState(null);let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w=U=>{var H;(H=h.current)==null||H.call(h,U),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 v;e[1]!==s||e[2]!==d||e[3]!==u||e[4]!==o||e[5]!==m||e[6]!==c||e[7]!==p||e[8]!==t||e[9]!==f?(v={permissionsConfig:t,dispatch:s,isMobile:o,onSessionFinalized:w,onCreateStarted:b,onModelRejected:p,model:c,effort:d,fastMode:u,ultracode:f,mcpConfig:m},e[1]=s,e[2]=d,e[3]=u,e[4]=o,e[5]=m,e[6]=c,e[7]=p,e[8]=t,e[9]=f,e[10]=v):v=e[10];const S=EF(v),j=S.handleNewSession,[k,C]=y.useState(null);let N;e[11]===Symbol.for("react.memo_cache_sentinel")?(N=new Map,e[11]=N):N=e[11];const _=y.useRef(N);let A;e[12]===Symbol.for("react.memo_cache_sentinel")?(A=async U=>{if(ki===null)return null;const H=_.current;if(H.has(U))return H.get(U)??null;try{const K=await be("/api/projects");if(!K.ok)return H.set(U,null),null;const V=await K.json(),Y=nj(V,U,ki);return H.set(U,Y),Y}catch{return H.set(U,null),null}},e[12]=A):A=e[12];const P=A;let T;e[13]!==j?(T=async(U,H)=>{const K=H??null;if(!K){C(null),j(U);return}const V=$t(U)===ki?ki:null,Y=V?Pl(V,K):await P(K);C(Y?{discoveredDirName:Y,cwd:K}:null),j(V&&Y?Y:U,K)},e[13]=j,e[14]=T):T=e[14];const E=T;let $;e[15]!==i||e[16]!==E?($=U=>{const H=Pl(i,U);E(H,U)},e[15]=i,e[16]=E,e[17]=$):$=e[17];const I=$;let R;e[18]!==j||e[19]!==k?(R=U=>{if(!k)return;const H=Pl(U,k.cwd,k.discoveredDirName);j(H,k.cwd)},e[18]=j,e[19]=k,e[20]=R):R=e[20];const D=R;let O;e:{if(!S.creatingSession||!a){O=null;break e}const U=x??void 0;let H;e[21]!==l||e[22]!==a||e[23]!==U?(H={dirName:a,cwd:l,firstMessage:U},e[21]=l,e[22]=a,e[23]=U,e[24]=H):H=e[24],O=H}const M=O;let F,z;e[25]!==a?(z=()=>{a||(b(null),C(null))},F=[a],e[25]=a,e[26]=F,e[27]=z):(F=e[26],z=e[27]),y.useEffect(z,F);const L=k?D:void 0;let W;return e[28]!==I||e[29]!==E||e[30]!==S.cancelCreation||e[31]!==S.clearCreateError||e[32]!==S.createAndSend||e[33]!==S.createError||e[34]!==S.creatingSession||e[35]!==S.setWorktreeEnabled||e[36]!==S.worktreeEnabled||e[37]!==M||e[38]!==L?(W={creatingSession:S.creatingSession,createError:S.createError,clearCreateError:S.clearCreateError,createAndSend:S.createAndSend,cancelCreation:S.cancelCreation,worktreeEnabled:S.worktreeEnabled,setWorktreeEnabled:S.setWorktreeEnabled,sessionFinalizedRef:h,liveSessionsRefreshRef:g,pendingSessionInfo:M,pendingAgentKindChange:L,handleStartNewSession:E,handleStartNewFolder:I},e[28]=I,e[29]=E,e[30]=S.cancelCreation,e[31]=S.clearCreateError,e[32]=S.createAndSend,e[33]=S.createError,e[34]=S.creatingSession,e[35]=S.setWorktreeEnabled,e[36]=S.worktreeEnabled,e[37]=M,e[38]=L,e[39]=W):W=e[39],W}const wc=new Set;function PF(n,e){const t=Nn(),s=js();return`${s===null?t:`${t}:${s}`}:${n}/${e}`}async function $F(n,e,t){const s=PF(n,e);if(!wc.has(s)&&!Cn.get(n,e)){wc.add(s);try{await Ks(n,e,t,"session prefetch")}catch{}finally{wc.delete(s)}}}function RF({onAuthenticated:n}){const[e,t]=y.useState(null),[s,o]=y.useState(""),[i,a]=y.useState(""),[l,c]=y.useState(!1),[d,u]=y.useState(null),[f,m]=y.useState(!1),p=e==="team";y.useEffect(()=>{let x=!1;return ug().then(b=>{x||t(b)}),()=>{x=!0}},[]);const h=y.useCallback(async x=>{if(x.preventDefault(),!(!i.trim()||p&&!s.trim())){m(!0),u(null);try{const b=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 b.json();b.ok&&w.valid?(La(),a(""),o(""),n()):u(w.error||(p?"Invalid credentials":"Invalid password"))}catch{u("Failed to connect to server")}finally{m(!1)}}},[p,n,i,s]),g=f||!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(on,{children:[r.jsxs(un,{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(Lw,{className:"size-4"})}),r.jsx(fn,{children:"Sign in to Cogpit"}),r.jsx(mn,{children:p?"Use your team account to continue.":"Enter the server password to continue."})]}),e===null?r.jsx(rn,{children:r.jsx("div",{className:"flex min-h-24 items-center justify-center",role:"status","aria-label":"Checking server",children:r.jsx(st,{className:"size-5 text-muted-foreground"})})}):r.jsxs(r.Fragment,{children:[r.jsxs(rn,{className:"flex flex-col gap-4",children:[r.jsxs(Mo,{children:[p&&r.jsxs(jt,{children:[r.jsx(St,{htmlFor:"login-username",children:"Username"}),r.jsx(Dt,{id:"login-username",type:"text",value:s,onChange:x=>o(x.target.value),placeholder:"Username",autoComplete:"username",autoFocus:!0})]}),r.jsxs(jt,{children:[r.jsx(St,{htmlFor:"login-password",children:"Password"}),r.jsxs(ls,{children:[r.jsx(cs,{id:"login-password",type:l?"text":"password",value:i,onChange:x=>a(x.target.value),placeholder:"Password",autoComplete:"current-password",autoFocus:!p}),r.jsx(Pn,{align:"inline-end",children:r.jsx(Qr,{size:"icon-xs",onClick:()=>c(x=>!x),"aria-label":l?"Hide password":"Show password",children:l?r.jsx(Aa,{}):r.jsx(ys,{})})})]})]})]}),d&&r.jsxs(pt,{variant:"destructive",children:[r.jsx(Yt,{"aria-hidden":"true"}),r.jsx(Et,{children:"Sign in failed"}),r.jsx(ht,{children:d})]})]}),r.jsx(Jr,{children:r.jsxs(ee,{type:"submit",className:"w-full",disabled:g,children:[f&&r.jsx(st,{"data-icon":"inline-start"}),"Connect"]})})]})]})})})}const g1=16,Qi="__cogpitBootstrapToken";function IF(){const e=new URLSearchParams(window.location.hash.replace(/^#/,"")).get("bootstrap")||"",t=window.history.state||{},s=e||(typeof t[Qi]=="string"?t[Qi]:"");return e&&window.history.replaceState({...t,[Qi]:e},"",`${window.location.pathname}${window.location.search}`),s}function x1(){const n={...window.history.state||{}};delete n[Qi],window.history.replaceState(n,"",`${window.location.pathname}${window.location.search}`)}function MF({onAuthenticated:n,onBootstrapClosed:e}){const[t]=y.useState(IF),[s,o]=y.useState(""),[i,a]=y.useState(""),[l,c]=y.useState(""),[d,u]=y.useState(""),[f,m]=y.useState(!1),[p,h]=y.useState(null),[g,x]=y.useState(!1),b=d.length>0&&d!==l,w=!t||!s.trim()||l.length<g1||d!==l,v=y.useCallback(async S=>{if(S.preventDefault(),!w){x(!0),h(null);try{const j=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()}:{}})}),k=await j.json();if(j.ok){x1(),c(""),u(""),o(""),a(""),await e(),n();return}if(j.status===410){x1(),await e();return}h(k.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:v,className:"w-full max-w-md",children:r.jsxs(on,{children:[r.jsxs(un,{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(zw,{className:"size-4"})}),r.jsx(fn,{children:"Create the first admin"}),r.jsx(mn,{children:"Set up the account that will manage this Cogpit team server."})]}),r.jsxs(rn,{className:"flex flex-col gap-4",children:[!t&&r.jsxs(pt,{children:[r.jsx(gn,{"aria-hidden":"true"}),r.jsx(Et,{children:"Setup link required"}),r.jsx(ht,{children:"Open the one-time setup URL shown in the Cogpit server log."})]}),r.jsxs(Mo,{children:[r.jsxs(jt,{children:[r.jsx(St,{htmlFor:"bootstrap-username",children:"Username"}),r.jsx(Dt,{id:"bootstrap-username",type:"text",value:s,onChange:S=>o(S.target.value),placeholder:"Username",autoComplete:"username",autoFocus:!0}),r.jsx(Eo,{children:"Use 2 to 32 lowercase letters, numbers, dots, underscores, or hyphens."})]}),r.jsxs(jt,{children:[r.jsxs(St,{htmlFor:"bootstrap-display-name",children:["Display name ",r.jsx("span",{className:"font-normal text-muted-foreground",children:"Optional"})]}),r.jsx(Dt,{id:"bootstrap-display-name",type:"text",value:i,onChange:S=>a(S.target.value),placeholder:"Display name (optional)",autoComplete:"name"})]}),r.jsxs(jt,{children:[r.jsx(St,{htmlFor:"bootstrap-password",children:"Password"}),r.jsxs(ls,{children:[r.jsx(cs,{id:"bootstrap-password",type:f?"text":"password",value:l,onChange:S=>c(S.target.value),placeholder:"Password",autoComplete:"new-password"}),r.jsx(Pn,{align:"inline-end",children:r.jsx(Qr,{size:"icon-xs",onClick:()=>m(S=>!S),"aria-label":f?"Hide password":"Show password",children:f?r.jsx(Aa,{}):r.jsx(ys,{})})})]}),r.jsxs(Eo,{children:["Use at least ",g1," characters."]})]}),r.jsxs(jt,{"data-invalid":b,children:[r.jsx(St,{htmlFor:"bootstrap-confirm-password",children:"Confirm password"}),r.jsx(Dt,{id:"bootstrap-confirm-password",type:f?"text":"password",value:d,onChange:S=>u(S.target.value),placeholder:"Confirm password",autoComplete:"new-password","aria-invalid":b}),b&&r.jsx(bs,{children:"Passwords do not match"})]})]}),p&&r.jsxs(pt,{variant:"destructive",children:[r.jsx(Yt,{"aria-hidden":"true"}),r.jsx(Et,{children:"Could not create the account"}),r.jsx(ht,{children:p})]})]}),r.jsx(Jr,{children:r.jsxs(ee,{type:"submit",className:"w-full",disabled:g||w,children:[g&&r.jsx(st,{"data-icon":"inline-start"}),"Create admin account"]})})]})})})}function OF(){const n=B.c(18);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=Da(),n[0]=e):e=n[0];const t=e,[s,o]=y.useState(null),[i,a]=y.useState(!1),[l,c]=y.useState(!1),d=y.useRef(0);let u,f;n[1]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{let T=!1;return dg().then(E=>{T||o(E)}),()=>{T=!0}},f=[],n[1]=u,n[2]=f):(u=n[1],f=n[2]),y.useEffect(u,f);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 T=!1;const E=d.current;return e4().then($=>{!T&&d.current===E&&(a($),c(!0))}),()=>{T=!0}},h=[m],n[3]=m,n[4]=p,n[5]=h):(p=n[4],h=n[5]),y.useEffect(p,h);let g;n[6]!==(s==null?void 0:s.edition)?(g=()=>{let T=!1;const E=()=>{const $=d.current=d.current+1,I=()=>{T||d.current!==$||(a(!1),c(!0))};if(t||(s==null?void 0:s.edition)==="team"){I();return}Nm().then(R=>{T||d.current!==$||(o(R),R.edition==="team"&&I())})};return window.addEventListener("cogpit-auth-required",E),()=>{T=!0,window.removeEventListener("cogpit-auth-required",E)}},n[6]=s==null?void 0:s.edition,n[7]=g):g=n[7];const x=s==null?void 0:s.edition;let b;n[8]!==x?(b=[x,t],n[8]=x,n[9]=b):b=n[9],y.useEffect(g,b);let w;n[10]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{d.current=d.current+1,a(!0),c(!0),window.dispatchEvent(new Event("cogpit-auth-changed"))},n[10]=w):w=n[10];const v=w;let S;n[11]===Symbol.for("react.memo_cache_sentinel")?(S=async()=>{o(await Nm())},n[11]=S):S=n[11];const j=S;let k;n[12]===Symbol.for("react.memo_cache_sentinel")?(k=()=>{d.current=d.current+1,a(!1),c(!0),t4().finally(DF)},n[12]=k):k=n[12];const C=k,N=(s==null?void 0:s.edition)??null,_=l&&s!==null,A=(s==null?void 0:s.needsBootstrap)===!0;let P;return n[13]!==i||n[14]!==N||n[15]!==_||n[16]!==A?(P={isRemote:t,edition:N,authChecked:_,authenticated:i,needsBootstrap:A,handleAuthenticated:v,refreshServerState:j,logout:C},n[13]=i,n[14]=N,n[15]=_,n[16]=A,n[17]=P):P=n[17],P}function DF(){window.dispatchEvent(new Event("cogpit-auth-changed"))}const LF=y.lazy(()=>qe(()=>import("./index-L4keTj_3.js"),__vite__mapDeps([38,1,2,3,4])).then(n=>({default:n.BranchModal}))),zF=y.lazy(()=>qe(()=>import("./WorkflowsPanel-DOOg6Hqp.js"),__vite__mapDeps([39,1,4,2,3])).then(n=>({default:n.WorkflowsPanel})));function FF(){var Uf,Wf,Hf,qf,Kf,Vf,Gf,Yf,Xf,Jf,Qf,Zf,em,tm,nm,sm,om,rm,im,am;const n=df(window.location.pathname),e=Dz(),t=OF(),s=Uz(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=lf(),d=Cv(),[u,f]=yv(),{procBySession:m}=r2(),{parse:p,append:h}=Lv(),g=y.useCallback(Ae=>{f({type:"SET_OLDER_TURNS",turns:Ae})},[f]),x=y.useCallback((Ae,Ge)=>{$F(Ae,Ge,p)},[p]),b=zv({dirName:((Uf=u.sessionSource)==null?void 0:Uf.dirName)??null,fileName:((Wf=u.sessionSource)==null?void 0:Wf.fileName)??null,sessionChangeKey:u.sessionChangeKey,workerParse:p,onOlderTurns:g}),{loadMore:w}=b,v=!!u.searchQuery&&b.hasMore,S=((Hf=u.session)==null?void 0:Hf.turns.length)??0;y.useEffect(()=>{v&&w()},[v,w,S]);const j=rF(u,f),k=y.useRef(null),C=y.useRef(null),[N,_]=y.useState(!1),[A,P]=y.useState(!1),T=y.useCallback(()=>f({type:"TOGGLE_EXPAND_ALL"}),[f]),E=y.useCallback(()=>_(!0),[]),$=y.useCallback(()=>{var Ae;return(Ae=C.current)==null?void 0:Ae.focus()},[]),I=y.useCallback(()=>f({type:"SET_EXPAND_ALL",value:!0}),[f]),R=y.useCallback(()=>f({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0}),[f]),D=y.useCallback(()=>f({type:"SET_EXPAND_ALL",value:!1}),[f]),O=j.toggleWorkspacePanel,M=y.useCallback(()=>O(_t.sessionInfo),[O]),F=y.useCallback(Ae=>{y.startTransition(()=>{f({type:"SET_DASHBOARD_PROJECT",dirName:Ae})})},[f]),z=u.pendingCwd??(u.pendingDirName?_n(u.pendingDirName):null),L=((qf=u.sessionSource)==null?void 0:qf.agentKind)??$t(((Kf=u.sessionSource)==null?void 0:Kf.dirName)??u.pendingDirName??null),W=(Vf=u.session)!=null&&Vf.sessionId?m.get(u.session.sessionId):void 0,U=Gt(L),H=cf(L,W),K=U.worktrees,V=U.mcp,Y=sF(i?((Gf=u.session)==null?void 0:Gf.cwd)??z??void 0:void 0,i&&U.slashCommands),q=y.useCallback(Ae=>{if(!i)return;const Ge=Y.suggestions.find(kt=>kt.name===Ae);y.startTransition(()=>{f({type:"OPEN_CONFIG",filePath:Ge==null?void 0:Ge.filePath})})},[i,f,Y.suggestions]),J=y.useCallback(async(Ae,Ge)=>{if(!i)return null;const kt=Y.suggestions.find(yn=>yn.name===Ae);if(!(kt!=null&&kt.filePath))return null;try{const yn=await be("/api/expand-command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:kt.filePath,args:Ge||""})});return yn.ok?(await yn.json()).content??null:null}catch{return null}},[i,Y.suggestions]),{processPanel:Q,currentCwd:X,showPreview:Z,showProjectFiles:te,projectFilesRoot:ne,projectFilesRequest:oe,launchTerminalRequest:re,pendingProject:ae,handleOpenTerminal:se,handleMcpAuth:de,handleToggleIntegratedTerminal:le,handleNewIntegratedTerminal:ce,handleTogglePreview:me,handleToggleProjectFiles:ue,closeRightWorkspace:ie}=pF({sessionId:(Yf=u.session)==null?void 0:Yf.sessionId,sessionCwd:(Xf=u.session)==null?void 0:Xf.cwd,pendingPath:z,sessionDirName:(Jf=u.sessionSource)==null?void 0:Jf.dirName,pendingDirName:u.pendingDirName,dashboardProject:u.dashboardProject,supportsFileWorkspace:!c&&a,activeWorkspacePanel:j.activeWorkspacePanel,openWorkspacePanel:j.openWorkspacePanel,closeWorkspacePanel:j.closeWorkspacePanel}),ge=Zz(u.session??null),[pe,xe]=y.useState(!1),Ce=((Qf=u.sessionSource)==null?void 0:Qf.dirName)??u.pendingDirName??u.dashboardProject??null,{activeWorkspacePanel:Te,closeWorkspacePanel:Ee,showWorkflows:$e}=j,Re=Vz(o&&K&&u.mainView==="sessions"&&Te===_t.worktrees?Ce:null),Fe=y.useMemo(()=>{const Ae=u.session;return Ae?Ae.turns.some(Ge=>pa(Ge.toolCalls,Ae.cwd)||Ge.subAgentActivity.some(kt=>pa(kt.toolCalls,Ae.cwd))):!1},[u.session]),Le=y.useMemo(()=>{if(!u.session||!U.workflows)return 0;let Ae=0;for(const Ge of u.session.turns)for(const kt of Ge.toolCalls)kt.name==="Workflow"&&Ae++;return Ae},[u.session,U.workflows]),Ie=Le>0,_e=y.useMemo(()=>{const Ae=u.sessionSource;return!Ae||!U.workflows||Ns(Ae.fileName)?{dirName:null,sessionId:null}:{dirName:Ae.dirName,sessionId:_c(Ae.fileName)}},[u.sessionSource,U.workflows]),je=tz(_e.dirName,_e.sessionId,Ie),ze=Ie||je.workflows.length>0,Ne=je.workflows.length||Le,Se=j.setShowWorkflows,he=y.useCallback(()=>Se(!0),[Se]),[De,Be]=y.useState(!1),[We,we]=y.useState(!1),Me=j.openWorkspacePanel;y.useEffect(()=>{if(!a)return;const Ae=()=>{c?Be(!0):Me(_t.fileChanges)};return window.addEventListener(Er,Ae),()=>window.removeEventListener(Er,Ae)},[a,Me,c]);const fe=y.useMemo(()=>u.session?N0(u.session):null,[u.session]),ve=y.useRef(null),{isLive:Oe,sseState:Ue,isCompacting:Ke,streamingOverlay:Ze,turnError:He,agentProgress:Ye,promptSuggestion:At}=xv(u.sessionSource,Ae=>{y.startTransition(()=>{f({type:"UPDATE_SESSION",session:Ae})})},p,h,()=>{var Ae;return(Ae=ve.current)==null?void 0:Ae.call(ve)},u.session),Vn=y.useMemo(()=>Ze.reduce((Ae,Ge)=>Ae+Ge.blocks.reduce((kt,yn)=>kt+yn.text.length,0),0),[Ze]),qt=nF(((Zf=u.session)==null?void 0:Zf.cwd)??null),Xt=wz(),Gn=Xt.setMode,Kt=Nz(H?null:((em=u.session)==null?void 0:em.sessionId)??null),Rs=H?null:Kt.plan??fe,{selectedModel:Ve,setSelectedModel:et,selectedEffort:xt,setSelectedEffort:zt,fastModeEnabled:Yn,ultracodeEnabled:Zs,effectiveEffort:mi,fastModeAvailable:Hv,fastModeActive:pi,setFastModeEnabled:wl,ultracodeAvailable:qv,ultracodeActive:hi,setUltracodeEnabled:jl,imageInputAvailable:uf,modelFallbackNotice:Kv,dismissModelFallbackNotice:Vv,handleModelRejected:ff}=dF({agentKind:L,session:u.session,sessionSource:u.sessionSource,pendingDirName:u.pendingDirName,isLive:Oe}),mf=Yz((tm=u.session)==null?void 0:tm.sessionId,(nm=u.sessionSource)==null?void 0:nm.fileName);fF({sessionKey:mf,values:{model:Ve,effort:xt,fastMode:Yn,ultracode:Zs,permissionMode:Xt.config.mode},onHydrate:y.useCallback(Ae=>{Ae.model!==void 0&&et(Ae.model),Ae.effort!==void 0&&zt(Ae.effort),Ae.fastMode!==void 0&&wl(Ae.fastMode),Ae.ultracode!==void 0&&jl(Ae.ultracode),Ae.permissionMode&&Gn(Ae.permissionMode)},[et,zt,wl,jl,Gn])});const tn=Qz(V&&i?X:void 0,V&&i?Ce??void 0:void 0,V&&i?mf??void 0:void 0,i);y.useEffect(()=>{!K&&Te===_t.worktrees&&Ee()},[K,Te,Ee]),y.useEffect(()=>{$e&&!ze&&Se(!1)},[$e,ze,Se]);const{creatingSession:pf,createError:hf,clearCreateError:Gv,createAndSend:Yv,cancelCreation:gf,worktreeEnabled:Xv,setWorktreeEnabled:Jv,sessionFinalizedRef:gi,liveSessionsRefreshRef:xf,pendingSessionInfo:bf,pendingAgentKindChange:Qv,handleStartNewSession:vf,handleStartNewFolder:Zv}=AF({permissionsConfig:Xt.config,dispatch:f,isMobile:c,defaultAgentKind:e.defaultAgentKind,pendingDirName:u.pendingDirName,pendingCwd:u.pendingCwd,onModelRejected:ff,model:Ve,effort:mi,fastMode:pi,ultracode:hi,mcpConfig:V&&i?tn.mcpConfigJson:null}),bt=oz({sessionSource:u.sessionSource,parsedSessionId:((sm=u.session)==null?void 0:sm.sessionId)??null,cwd:(om=u.session)==null?void 0:om.cwd,permissions:Xt.config,onPermissionsApplied:Xt.markApplied,model:Ve,effort:mi,fastMode:pi,ultracode:hi,mcpConfig:V&&i?tn.mcpConfigJson:null,onModelRejected:ff,readOnly:H,onCreateSession:u.pendingDirName?Yv:void 0}),Ft=ZL(U.agentTeams?((rm=u.sessionSource)==null?void 0:rm.fileName)??null:null,((im=u.sessionSource)==null?void 0:im.dirName)??null);y.useEffect(()=>{Ft!=null&&Ft.currentMemberName?f({type:"SET_CURRENT_MEMBER_NAME",name:Ft.currentMemberName}):Ft||f({type:"SET_CURRENT_MEMBER_NAME",name:null})},[Ft==null?void 0:Ft.currentMemberName,Ft,f]),y.useEffect(()=>{c&&f({type:"GUARD_MOBILE_TAB",hasSession:!!u.session||!!u.pendingDirName})},[u.session,u.pendingDirName,u.mobileTab,c,f]);const $n=wv({session:u.session,isLive:Oe,pendingMessages:bt.pendingMessages,consumePending:bt.consumePending,sessionChangeKey:u.sessionChangeKey,partialContentLen:Vn}),yf=$n.chatScrollRef,wf=$n.resetTurnCount,jf=$n.scrollToBottomInstant,ey=y.useCallback(Ae=>{xe(Ae),requestAnimationFrame(()=>{const Ge=yf.current;Ge&&Ge.scrollTo({top:Ge.scrollTop+(Ae?64:-64),behavior:"smooth"})})},[yf]);y.useLayoutEffect(()=>{const Ae=Ge=>{wf(0),jf()};return gi.current=Ae,()=>{gi.current===Ae&&(gi.current=null)}},[wf,jf,gi]);const ty=y.useCallback(()=>{bt.disconnect(),gf()},[bt.disconnect,gf]),Rn=az({dispatch:f,isMobile:c,mobileTab:u.mobileTab,teamContext:Ft,scrollToBottomInstant:$n.scrollToBottomInstant,resetTurnCount:$n.resetTurnCount,workerParse:p,onBeforeSwitch:ty}),ny=y.useCallback(Ae=>{y.startTransition(()=>{f({type:"GO_HOME",isMobile:c}),f({type:"SET_DASHBOARD_PROJECT",dirName:Ae})})},[f,c]),{previewLoadError:sy}=uz({state:u,dispatch:f,isMobile:c,resetTurnCount:$n.resetTurnCount,scrollToBottomInstant:$n.scrollToBottomInstant,workerParse:p}),xi=vz(),Sf=xi.push;y.useEffect(()=>{u.sessionSource&&Sf(u.sessionSource.dirName,u.sessionSource.fileName)},[u.sessionSource,Sf]);const gt=lF({state:{session:u.session,sessionSource:u.sessionSource},dispatch:f,isMobile:c,handleJumpToTurn:Rn.handleJumpToTurn,markPermissionsApplied:Xt.markApplied,hasPermsPendingChanges:Xt.hasPendingChanges,permissionsConfig:Xt.config,selectedModel:Ve,selectedEffort:mi,fastMode:pi,ultracode:hi,mcpConfig:V&&i?tn.mcpConfigJson:null,scrollRequestScrollToTop:$n.requestScrollToTop,handleDashboardSelect:Rn.handleDashboardSelect,workerParse:p}),{hasSettingsChanges:Nf,handleApplySettings:kf}=gt,Cf=V&&i&&tn.mcpConfigJson!==null,_f=y.useRef(!1);y.useEffect(()=>{var kt;const Ae=tn.loaded&&!_f.current;_f.current=tn.loaded;const Ge=(kt=u.session)==null?void 0:kt.sessionId;Ae&&Ge&&Cf&&Nf&&kf()},[tn.loaded,Cf,Nf,kf,(am=u.session)==null?void 0:am.sessionId]),y.useLayoutEffect(()=>(ve.current=gt.reloadSession,()=>{ve.current===gt.reloadSession&&(ve.current=null)}),[gt.reloadSession]);const Xn=Mv(u.session,u.sessionSource,gt.reloadSession,a),bi=Xn.requestBranchSwitch,vi=gt.setBranchModalTurn,oy=y.useCallback((Ae,Ge)=>{bi(Ae,Ge),vi(null)},[bi,vi]),ry=y.useCallback(Ae=>{bi(Ae),vi(null)},[bi,vi]);pz({isMobile:c,searchInputRef:k,chatInputRef:C,dispatch:f,onToggleSidebar:j.handleToggleSidebar,onToggleRightSidebar:M,onToggleMissionControl:j.handleToggleMission,onOpenCommandPalette:E,onOpenProjectSwitcher:j.handleOpenProjectSwitcher,onOpenThemeSelector:j.handleToggleThemeSelector,onOpenTerminal:se,onToggleIntegratedTerminal:le,onTogglePreview:me,onToggleProjectFiles:ue,onHistoryBack:xi.goBack,onHistoryForward:xi.goForward,onNavigateToSession:Rn.handleDashboardSelect,onCommitNavigation:xi.commitNavigation});const{killing:iy,handleKillAll:ay}=Gz(),ds=u.sessionSource?Ns(u.sessionSource.fileName):null,ly=ds!==null&&!!(Ft!=null&&Ft.currentMemberName),Sl=ds!==null&&!ly,yi=Rn.handleDashboardSelect,Tf=y.useCallback(()=>{!u.sessionSource||!ds||yi(u.sessionSource.dirName,ds.parentFileName)},[u.sessionSource,ds,yi]);y.useEffect(()=>{const Ae=Ge=>{const{agentId:kt}=Ge.detail??{};if(!kt||!u.sessionSource||!U.subagentTranscripts)return;const yn=ds?ds.parentSessionId:_c(u.sessionSource.fileName);yi(u.sessionSource.dirName,`${yn}/subagents/agent-${kt}.jsonl`)};return window.addEventListener(ha,Ae),()=>window.removeEventListener(ha,Ae)},[u.sessionSource,ds,yi,U.subagentTranscripts]);const[cy,Ef]=y.useState(null),dy=gt.branchModalTurn!==null,eo=gt.branchModalTurn??cy;y.useEffect(()=>{gt.branchModalTurn!==null&&Ef(gt.branchModalTurn)},[gt.branchModalTurn]);const Af=eo!==null?Xn.branchesAtTurn(eo):[],uy=Sl?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(No,{"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,fy=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(No,{"data-icon":"inline-start",className:"size-3.5 text-muted-foreground"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:M4(L)})]}):null,Nl=uy||fy,my=Rn.loadError||hf||null;let kl;Rn.loadError?kl=Rn.clearLoadError:hf&&(kl=Gv);const py=!!(u.session&&u.sessionSource&&Ue==="disconnected"),Cl=y.useMemo(()=>({state:u,dispatch:f,config:e,theme:d,networkAuth:t,me:s,isMobile:c}),[u.activeTurnIndex,u.activeToolCallId,u.searchQuery,u.expandAll,u.expandToolPayloads,u.mainView,u.mobileTab,u.dashboardProject,u.pendingDirName,u.pendingCwd,u.currentMemberName,u.loadingMember,u.configFilePath,u.sessionChangeKey,f,e,d,t,s,c]),_l=y.useMemo(()=>({session:u.session,sessionSource:u.sessionSource,isLive:Oe,sseState:Ue,isCompacting:Ke,turnError:He,promptSuggestion:At,undoRedo:Xn,pendingInteraction:Rs,permissionRequests:Kt.requests,permissionResponding:Kt.responding,respondPermission:Kt.respond,respondAllPermissions:Kt.respondAll,isSubAgentView:Sl,slashSuggestions:Y.suggestions,slashSuggestionsLoading:Y.loading,actions:{handleStopSession:gt.handleStopSession,handleEditConfig:i?j.handleEditConfig:void 0,handleEditCommand:i?q:void 0,handleExpandCommand:i?J:void 0,handleOpenBranches:gt.handleOpenBranches,handleBranchFromHere:gt.handleBranchFromHere,handleToggleExpandAll:T,handleLoadSession:gt.handleLoadSessionScrollAware}}),[u.session,u.sessionSource,Oe,Ue,Ke,He,At,Xn,Rs,Sl,Kt.requests,Kt.responding,Kt.respond,Kt.respondAll,Y.suggestions,Y.loading,gt.handleStopSession,i,j.handleEditConfig,q,J,gt.handleOpenBranches,gt.handleBranchFromHere,T,gt.handleLoadSessionScrollAware]),Tl=y.useMemo(()=>({chat:{status:bt.status,error:bt.error,pendingMessages:bt.pendingMessages,isConnected:bt.isConnected,sendMessage:bt.sendMessage,interrupt:bt.interrupt,stopAgent:bt.stopAgent,consumePending:bt.consumePending},scroll:$n}),[bt.status,bt.error,bt.pendingMessages,bt.isConnected,bt.sendMessage,bt.interrupt,bt.stopAgent,bt.consumePending,$n]),Wo=!!u.pendingDirName&&!u.session;if(y.useEffect(()=>{if(!Wo||c)return;const Ae=requestAnimationFrame(()=>{var Ge;return(Ge=C.current)==null?void 0:Ge.focus()});return()=>cancelAnimationFrame(Ae)},[Wo,c,u.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(MF,{onAuthenticated:t.handleAuthenticated,onBootstrapClosed:t.refreshServerState}):r.jsx(RF,{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(ln,{children:[r.jsxs(cn,{children:[r.jsx(bn,{variant:"icon",children:r.jsx(gn,{className:"text-destructive"})}),r.jsx(dn,{children:"Failed to connect"}),r.jsx(vn,{children:e.configError})]}),r.jsx(og,{children:r.jsxs(ee,{variant:"outline",size:"sm",onClick:e.retryConfig,children:[r.jsx(Pt,{"data-icon":"inline-start"}),"Retry"]})})]})});if(!e.claudeDir)return i?r.jsx(UN,{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 El=r.jsx(Xj,{activeError:my,clearActiveError:kl,modelFallbackNotice:Kv,dismissModelFallbackNotice:Vv,connectionLost:py,theme:d.activeTheme}),Pf=a?r.jsx(IN,{state:Xn.confirmState,isApplying:Xn.isApplying,applyError:Xn.applyError,onConfirm:Xn.confirmApply,onCancel:Xn.confirmCancel}):null,hy=eo!==null&&u.session?u.session.turns.slice(eo):[],$f=a&&eo!==null&&Af.length>0&&r.jsx(y.Suspense,{fallback:null,children:r.jsx(LF,{open:dy,branches:Af,branchPointTurnIndex:eo,currentTurns:hy,onClose:gt.handleCloseBranchModal,onCloseComplete:()=>Ef(null),onRedoToTurn:oy,onRedoEntireBranch:ry})}),Rf=l&&r.jsx(SN,{processes:Q.processes,activeProcessId:Q.activeProcessId,collapsed:Q.collapsed,onSetActive:Q.setActive,onRemove:Q.removeProcess,onToggleCollapse:Q.toggleCollapse,onRequestTerminal:ot("terminal")?ce:void 0,onAddTerminalContext:Ae=>{var lm,cm,dm;const Ge=Ae.trim();if(!Ge)return;const kt=Ge.includes("```")?"````":"```",yn=`${kt}terminal
|
|
152
|
+
${Ge}
|
|
153
|
+
${kt}`,Al=((lm=C.current)==null?void 0:lm.getText().trimEnd())??"";(cm=C.current)==null||cm.setText(Al?`${Al}
|
|
154
|
+
|
|
155
|
+
${yn}
|
|
156
|
+
`:`${yn}
|
|
157
|
+
`),(dm=C.current)==null||dm.focus()},onUpdateStatus:Q.updateProcessStatus,projectDir:X,onProcessStarted:Q.addProcess,mobile:c}),If=Ft&&r.jsx(x5,{teamName:Ft.config.name||Ft.teamName,members:Ft.config.members,currentMemberName:u.currentMemberName,loadingMember:u.loadingMember,onMemberClick:Rn.handleTeamMemberSwitch}),Mf=ze&&r.jsx(y.Suspense,{fallback:null,children:r.jsx(zF,{open:j.showWorkflows,onOpenChange:j.setShowWorkflows,dirName:_e.dirName,sessionId:_e.sessionId,workflows:je.workflows,isLive:je.isLive,onRefetchList:je.refetch},`${_e.dirName??""}:${_e.sessionId??""}`)}),wi=U.goals?u.session:null,Of=Ae=>{var Ge;return r.jsx(m5,{agentKind:L,onAgentKindChange:Wo?Qv:void 0,selectedModel:Ve,onModelChange:et,selectedEffort:mi,onEffortChange:zt,fastModeEnabled:pi,onFastModeEnabledChange:Hv?wl:void 0,isNewSession:Wo,worktreeEnabled:Xv,onWorktreeEnabledChange:Wo&&K?Jv:void 0,ultracodeEnabled:hi,onUltracodeEnabledChange:qv?jl:void 0,onApplySettings:gt.handleApplySettings,activeModelId:(Ge=u.session)==null?void 0:Ge.model,mcpServers:V&&i?tn.servers:void 0,selectedMcpServers:V&&i?tn.selectedServers:void 0,onToggleMcpServer:V&&i?tn.toggleServer:void 0,onSetMcpServers:V&&i?tn.setSelection:void 0,onRefreshMcpServers:V&&i?tn.refresh:void 0,mcpLoading:V&&i?tn.loading:void 0,onMcpAuth:V&&i?de:void 0,permissionMode:Xt.config.mode,onPermissionModeChange:Xt.setMode,mobileExtra:c&&Ae&&wi?r.jsx(QS,{}):void 0,trailingExtra:!c&&Ae&&wi?r.jsx(Qg,{}):void 0,mobile:c})},Df=Of(!0),Lf=Of(!1),zf=r.jsxs("div",{className:G("shrink-0",c&&"bg-background"),children:[!c&&r.jsx(Jg,{}),r.jsx(Uc,{ref:C,allowImages:uf,agentKind:L,projectCwd:X,compact:c,leadingAccessory:c?Df:void 0,footer:c?void 0:Df})]}),ji=wi?r.jsx(JS,{agentKind:L,session:wi,onSendCommand:bt.sendMessage,children:zf}):zf,gy=r.jsx("div",{className:G("shrink-0",c&&"bg-background"),children:r.jsx(Uc,{ref:C,allowImages:uf,agentKind:L,projectCwd:X,compact:c,leadingAccessory:c?Lf:void 0,footer:c?void 0:Lf})}),Ff=bt.pendingMessages.map((Ae,Ge)=>r.jsx(O0,{message:Ae,turnNumber:Ge+1},Ge)),xy=c?u.mobileTab==="stats":j.activeWorkspacePanel===_t.sessionInfo,Bf=u.session&&!xy&&r.jsx("div",{className:"hidden",children:r.jsx(rx,{cwd:u.session.cwd,turns:u.session.turns,onServersChanged:Q.handleServersChanged})});return n?r.jsxs(Yi,{value:Cl,children:[r.jsx(Ol,{children:r.jsx(Vi,{value:_l,chatValue:Tl,children:r.jsx(Gl,{value:Ze,agentProgress:Ye,children:r.jsx(GL,{sessionId:n,loadError:sy,searchInputRef:k,activeComposer:Nl||gy,hasMoreTurns:b.hasMore,isLoadingOlderTurns:b.isLoadingOlder,onLoadMoreTurns:b.loadMore})})})}),El]}):c?r.jsxs(Yi,{value:Cl,children:[r.jsx(Ol,{enabled:l,children:r.jsx(Vi,{value:_l,chatValue:Tl,children:r.jsx(Gl,{value:Ze,agentProgress:Ye,children:r.jsx(VL,{navigation:{actions:Rn,handlers:gt,creatingSession:pf,pendingSession:bf,onStartNewSession:vf,onSelectProject:F,liveSessionsRefreshRef:xf,onPrefetchSession:x},sessionView:{searchInputRef:k,teamMembersBar:If,activeComposer:Nl||ji,pendingComposer:ji,pendingTurns:Ff,todoProgress:ge&&r.jsx(D0,{progress:ge}),hasMoreTurns:b.hasMore,isLoadingOlderTurns:b.isLoadingOlder,onLoadMoreTurns:b.loadMore,onBackToMain:Tf,onShowWorkflows:he,onToggleExpandAll:T,workflowCount:Ne,pendingPath:z},project:{processPanel:Q,backgroundAgents:qt,hasFileChanges:a&&Fe,onOpenTerminal:se},chrome:{backgroundServers:Bf,processPanel:Rf,workflowsPanel:Mf,undoDialog:Pf,branchModal:$f,fileChangesOpen:De,onFileChangesOpenChange:Be,searchOpen:We,onSearchOpenChange:we}})})})}),El]}):r.jsxs(Yi,{value:Cl,children:[r.jsx(Ol,{enabled:l,children:r.jsx(Vi,{value:_l,chatValue:Tl,children:r.jsx(Gl,{value:Ze,agentProgress:Ye,children:r.jsx(LL,{navigation:{panels:j,actions:Rn,handlers:gt,creatingSession:pf,pendingSession:bf,onStartNewSession:vf,onStartNewFolder:Zv,onSelectProject:F,onOpenPaletteProject:ny,liveSessionsRefreshRef:xf,onPrefetchSession:x},sessionView:{searchInputRef:k,chatInputRef:C,teamMembersBar:If,activeComposer:Nl||ji,pendingComposer:ji,pendingTurns:Ff,todoProgress:ge,todosExpanded:pe,onTodosExpandedChange:ey,hasMoreTurns:b.hasMore,isLoadingOlderTurns:b.isLoadingOlder,onLoadMoreTurns:b.loadMore,onBackToMain:Tf,onShowWorkflows:he,workflowCount:Ne},project:{processPanel:Q,worktrees:Re,backgroundAgents:qt,supportsWorktrees:K,hasFileChanges:a&&Fe,currentCwd:X,showPreview:Z,showProjectFiles:a&&te,projectFilesRoot:ne,projectFilesRequest:oe,launchTerminalRequest:re,pendingProject:ae,onOpenTerminal:se,onTogglePreview:me,onToggleProjectFiles:ue,onCloseRightWorkspace:ie},chrome:{backgroundServers:Bf,processPanel:Rf,workflowsPanel:Mf,undoDialog:Pf,branchModal:$f,killing:iy,onKillAll:ay,commandPaletteOpen:N,onCommandPaletteOpenChange:_,onOpenCommandPalette:E,onFocusComposer:$,onExpandAll:I,onExpandToolPayloads:R,onCollapseAll:D,keyboardShortcutsOpen:A,onKeyboardShortcutsOpenChange:P}})})})}),El]})}function BF(){var w;const[n,e]=y.useState(vt),[t,s]=y.useState(()=>Ki(vt())),[o,i]=y.useState(js),[a,l]=y.useState(0),[c,d]=y.useState(!1),[u,f]=y.useState(!1),[m,p]=y.useState(!1),{devices:h,testDevice:g}=ul();y.useEffect(()=>{const v=()=>{const S=vt();e(j=>j===S?j:S),s(Ki(S))};return window.addEventListener("cogpit-device-changed",v),window.addEventListener("popstate",v),()=>{window.removeEventListener("cogpit-device-changed",v),window.removeEventListener("popstate",v)}},[]),y.useEffect(()=>{const v=S=>{const j=S.detail;(j==null?void 0:j.deviceId)===vt()&&s(Ki(j.deviceId))};return window.addEventListener("cogpit-device-scope-changed",v),()=>window.removeEventListener("cogpit-device-scope-changed",v)},[]),y.useEffect(()=>{const v=()=>i(js());return window.addEventListener("cogpit-identity-changed",v),()=>window.removeEventListener("cogpit-identity-changed",v)},[]),y.useEffect(()=>(window.__cogpitRevealSession=ab,()=>{delete window.__cogpitRevealSession}),[]),y.useEffect(()=>{const v=S=>{const j=[Tt,...h.map(_=>_.id)],k=vt();let C;const N=rP(S);if(N!==null)C=j[N-1];else if(iP(S)){const _=j.indexOf(k);C=j[(_+1)%j.length]}!C||C===k||(S.preventDefault(),Ss(C))};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[h]),y.useEffect(()=>{const v=S=>{const j=S.detail;!(j!=null&&j.deviceId)||j.deviceId!==vt()||(d(!0),j.reason==="DEVICE_AUTH_FAILED"&&f(!0))};return window.addEventListener("cogpit-device-unreachable",v),()=>window.removeEventListener("cogpit-device-unreachable",v)},[]),y.useEffect(()=>{d(!1),f(!1),p(!1)},[n,t]);const x=y.useCallback(async()=>{p(!0);try{const v=await g(n);v.reachable&&v.authState==="bad-password"?f(!0):v.ok&&(d(!1),f(!1),l(S=>S+1))}finally{p(!1)}},[n,g]);y.useEffect(()=>{if(!c||u)return;const v=setInterval(()=>void x(),1e4);return()=>clearInterval(v)},[c,u,x]);const b=((w=h.find(v=>v.id===n))==null?void 0:w.name)??n;return r.jsxs(r.Fragment,{children:[c&&n!==Tt&&r.jsxs(pt,{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(Fw,{"data-icon":"inline-start",className:"text-warning"}),r.jsx(Et,{children:u?"Device credentials need attention":"Remote device unavailable"}),r.jsx(ht,{children:u?`${b} rejected the stored password. Update it in Devices.`:`Can’t reach ${b}. Cogpit will keep retrying.`}),r.jsxs("div",{className:"col-start-2 mt-2 flex flex-wrap gap-2",children:[!u&&r.jsxs(ee,{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(ee,{variant:"outline",size:"xs",onClick:()=>Ss(Tt),children:"Switch to this machine"})]})]}),r.jsx(U7,{children:r.jsx(JD,{children:r.jsx(FF,{})})},`${n}:${t}:${a}:${o??""}`)]})}const b1="Invalid link or passphrase.";function UF(n,e){return n===401?b1: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||b1}function WF({sessionId:n,onAuthenticated:e}){const[t,s]=y.useState(""),[o,i]=y.useState(!1),[a,l]=y.useState(null),[c,d]=y.useState(!1),u=y.useCallback(async f=>{if(f.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(UF(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:u,className:"w-full max-w-sm",children:r.jsxs(on,{children:[r.jsxs(un,{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(ss,{className:"size-4"})}),r.jsx(fn,{children:"Join this session"}),r.jsx(mn,{children:"Enter the passphrase you were given to join the shared session."})]}),r.jsxs(rn,{className:"flex flex-col gap-4",children:[r.jsx(Mo,{children:r.jsxs(jt,{children:[r.jsx(St,{htmlFor:"share-passphrase",children:"Passphrase"}),r.jsxs(ls,{children:[r.jsx(cs,{id:"share-passphrase",type:o?"text":"password",value:t,onChange:f=>s(f.target.value),placeholder:"copper-lantern-drift-92",autoComplete:"current-password",autoFocus:!0}),r.jsx(Pn,{align:"inline-end",children:r.jsx(Qr,{size:"icon-xs",onClick:()=>i(f=>!f),"aria-label":o?"Hide passphrase":"Show passphrase",children:o?r.jsx(Aa,{}):r.jsx(ys,{})})})]})]})}),a&&r.jsxs(pt,{variant:"destructive",children:[r.jsx(Yt,{"aria-hidden":"true"}),r.jsx(Et,{children:"Could not join"}),r.jsx(ht,{children:a})]})]}),r.jsx(Jr,{children:r.jsxs(ee,{type:"submit",className:"w-full",disabled:c||!t.trim(),children:[c&&r.jsx(st,{"data-icon":"inline-start"}),"Connect"]})})]})})})}function HF(){const n=B.c(9),[e,t]=y.useState("idle"),[s,o]=y.useState();let i;n[0]===Symbol.for("react.memo_cache_sentinel")?(i=[],n[0]=i):i=n[0];const[a,l]=y.useState(i);let c;n[1]===Symbol.for("react.memo_cache_sentinel")?(c=(x,b)=>{l(w=>[...w,x]),t("connected"),o(void 0),_S(x,b).then(w=>{if(w.ok){t("idle");return}o(`Request failed (${w.status})`),t("error"),l(VF)}).catch(w=>{o(w instanceof Error?w.message:"Unknown error"),t("error"),l(KF)})},n[1]=c):c=n[1];const d=c;let u;n[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{TS().catch(qF),t("idle"),l([])},n[2]=u):u=n[2];const f=u;let m;n[3]===Symbol.for("react.memo_cache_sentinel")?(m=x=>{const b=x===void 0?1:x;l(w=>w.slice(b))},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:f,stopAgent:f,consumePending:p},n[4]=s,n[5]=a,n[6]=e,n[7]=h,n[8]=g):g=n[8],g}function qF(){}function KF(n){return n.slice(0,-1)}function VF(n){return n.slice(0,-1)}const GF=2e3;function YF(n,e){return n.length!==e.length?!1:JSON.stringify(n)===JSON.stringify(e)}function XF(){const n=B.c(11);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],n[0]=e):e=n[0];const[t,s]=y.useState(e);let o;n[1]===Symbol.for("react.memo_cache_sentinel")?(o=new Set,n[1]=o):o=n[1];const[i,a]=y.useState(o);let l,c;n[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{let h=!1;const g=async()=>{const w=await $S();h||w===null||s(v=>YF(v,w)?v:w)},x=()=>{document.visibilityState==="visible"&&g()};x();const b=setInterval(x,GF);return document.addEventListener("visibilitychange",x),()=>{h=!0,clearInterval(b),document.removeEventListener("visibilitychange",x)}},c=[],n[2]=l,n[3]=c):(l=n[2],c=n[3]),y.useEffect(l,c);let d;n[4]===Symbol.for("react.memo_cache_sentinel")?(d=(h,g)=>{a(x=>new Set(x).add(h)),AS(h,g).then(x=>{x&&s(b=>b.filter(w=>w.requestId!==h))}).finally(()=>{a(x=>{const b=new Set(x);return b.delete(h),b})})},n[4]=d):d=n[4];const u=d;let f;n[5]!==t?(f=h=>{for(const g of t)u(g.requestId,h)},n[5]=t,n[6]=f):f=n[6];const m=f;let p;return n[7]!==t||n[8]!==m||n[9]!==i?(p={requests:t,responding:i,respond:u,respondAll:m},n[7]=t,n[8]=m,n[9]=i,n[10]=p):p=n[10],p}const Uv={authenticated:!0,edition:"personal",user:null,capabilities:Vr};function JF(n){var ce,me;const e=B.c(78),{info:t,children:s}=n,o=lf(),i=Cv(),[a,l]=yv(),{parse:c,append:d}=Lv(),[u,f]=y.useState("loading");let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=[],e[0]=m):m=e[0],y.useEffect(nB,m);const p=HF(),h=XF();let g;e[1]!==l||e[2]!==t.dirName||e[3]!==t.fileName||e[4]!==o||e[5]!==c?(g=async()=>{try{const{parsed:ue,source:ie}=await Sv(t.dirName,t.fileName,c,"shared session");l({type:"LOAD_SESSION",session:ue,source:ie,isMobile:o}),f("ready")}catch{f("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,b=y.useRef(!1);let w,v;e[7]!==x?(w=()=>{b.current||(b.current=!0,x())},v=[x],e[7]=x,e[8]=w,e[9]=v):(w=e[8],v=e[9]),y.useEffect(w,v);let S;e[10]!==l?(S=ue=>{l({type:"UPDATE_SESSION",session:ue})},e[10]=l,e[11]=S):S=e[11];const j=S,{isLive:k,sseState:C,isCompacting:N,turnError:_}=xv(a.sessionSource,j,c,d,void 0,a.session);let A;e[12]!==l?(A=ue=>{l({type:"SET_OLDER_TURNS",turns:ue})},e[12]=l,e[13]=A):A=e[13];const P=A,T=((ce=a.sessionSource)==null?void 0:ce.dirName)??null,E=((me=a.sessionSource)==null?void 0:me.fileName)??null;let $;e[14]!==P||e[15]!==a.sessionChangeKey||e[16]!==T||e[17]!==E||e[18]!==c?($={dirName:T,fileName:E,sessionChangeKey:a.sessionChangeKey,workerParse:c,onOlderTurns:P},e[14]=P,e[15]=a.sessionChangeKey,e[16]=T,e[17]=E,e[18]=c,e[19]=$):$=e[19];const I=zv($);let R;e[20]!==p.consumePending||e[21]!==p.pendingMessages||e[22]!==k||e[23]!==a.session||e[24]!==a.sessionChangeKey?(R={session:a.session,isLive:k,pendingMessages:p.pendingMessages,consumePending:p.consumePending,sessionChangeKey:a.sessionChangeKey},e[20]=p.consumePending,e[21]=p.pendingMessages,e[22]=k,e[23]=a.session,e[24]=a.sessionChangeKey,e[25]=R):R=e[25];const D=wv(R),O=Mv(a.session,a.sessionSource,x,!1);let M;e[26]!==a.session?(M=a.session?N0(a.session):null,e[26]=a.session,e[27]=M):M=e[27];const F=M;let z;e[28]!==l?(z=()=>{l({type:"TOGGLE_EXPAND_ALL"})},e[28]=l,e[29]=z):z=e[29];const L=z,W=eB,U=ZF;let H;e[30]!==t.dirName?(H=$t(t.dirName),e[30]=t.dirName,e[31]=H):H=e[31];let K;e[32]!==H?(K={configLoading:!1,configError:null,claudeDir:null,defaultAgentKind:H,setClaudeDir:U,showConfigDialog:!1,openConfigDialog:U,handleCloseConfigDialog:U,handleConfigSaved:U,retryConfig:U,networkUrl:null,networkAccessDisabled:!1},e[32]=H,e[33]=K):K=e[33];let V;e[34]===Symbol.for("react.memo_cache_sentinel")?(V={isRemote:Da(),edition:"personal",authChecked:!0,authenticated:!0,needsBootstrap:!1,handleAuthenticated:U,refreshServerState:QF,logout:U},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:Uv,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 Q;e[42]!==L?(Q={handleStopSession:W,handleOpenBranches:U,handleBranchFromHere:U,handleToggleExpandAll:L,handleLoadSession:U},e[42]=L,e[43]=Q):Q=e[43];let X;e[44]!==N||e[45]!==k||e[46]!==F||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]!==Q||e[55]!==_||e[56]!==O?(X={session:a.session,sessionSource:a.sessionSource,isLive:k,sseState:C,isCompacting:N,turnError:_,undoRedo:O,pendingInteraction:F,permissionRequests:h.requests,permissionResponding:h.responding,respondPermission:h.respond,respondAllPermissions:h.respondAll,isSubAgentView:!1,slashSuggestions:J,slashSuggestionsLoading:!1,promptSuggestion:null,actions:Q},e[44]=N,e[45]=k,e[46]=F,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]=Q,e[55]=_,e[56]=O,e[57]=X):X=e[57];const Z=X;let te;e[58]!==p||e[59]!==D?(te={chat:p,scroll:D},e[58]=p,e[59]=D,e[60]=te):te=e[60];const ne=te;let oe;e[61]!==I?(oe=()=>{I.loadMore()},e[61]=I,e[62]=oe):oe=e[62];let re;e[63]!==u||e[64]!==I.hasMore||e[65]!==I.isLoadingOlder||e[66]!==oe?(re={loadState:u,hasMore:I.hasMore,isLoadingOlder:I.isLoadingOlder,loadMore:oe},e[63]=u,e[64]=I.hasMore,e[65]=I.isLoadingOlder,e[66]=oe,e[67]=re):re=e[67];const ae=re;let se;e[68]!==s||e[69]!==ae?(se=s(ae),e[68]=s,e[69]=ae,e[70]=se):se=e[70];let de;e[71]!==ne||e[72]!==Z||e[73]!==se?(de=r.jsx(Vi,{value:Z,chatValue:ne,children:se}),e[71]=ne,e[72]=Z,e[73]=se,e[74]=de):de=e[74];let le;return e[75]!==q||e[76]!==de?(le=r.jsx(Yi,{value:q,children:de}),e[75]=q,e[76]=de,e[77]=le):le=e[77],le}function QF(){return Promise.resolve()}function ZF(){}async function eB(){await ES().catch(tB)}function tB(){}function nB(){bo(Uv)}function sB(n){const e=B.c(6),{info:t}=n,s=y.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(ss,{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(pt,{variant:"destructive",className:"max-w-sm",children:[r.jsx(Yt,{"aria-hidden":"true"}),r.jsx(Et,{children:"Session unavailable"}),r.jsx(ht,{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(st,{className:"size-5 text-muted-foreground"})}):r.jsxs(r.Fragment,{children:[r.jsx(dl,{searchInputRef:s,hasMore:a.hasMore,isLoadingOlder:a.isLoadingOlder,onLoadMore:a.loadMore}),r.jsx(vl,{children:r.jsx(Uc,{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(JF,{info:t,children:o}),e[3]=t,e[4]=o,e[5]=i):i=e[5],i}function jc(n){const e=B.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 oB(){const n=B.c(19);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=qg(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]=y.useState(s);let a;n[2]===Symbol.for("react.memo_cache_sentinel")?(a=async()=>{i({kind:"probing"});const p=await CS();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]),y.useEffect(c,d);let u,f;if(n[5]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{const p=()=>{i(rB)};return window.addEventListener(Bc,p),window.addEventListener("cogpit-auth-required",p),()=>{window.removeEventListener(Bc,p),window.removeEventListener("cogpit-auth-required",p)}},f=[],n[5]=u,n[6]=f):(u=n[5],f=n[6]),y.useEffect(u,f),o.kind==="ready"){let p;return n[7]!==o.info?(p=r.jsx(sB,{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(WF,{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(jc,{children:r.jsx(on,{children:r.jsxs(un,{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(Bw,{className:"size-4"})}),r.jsx(fn,{children:"Sharing has ended"}),r.jsx(mn,{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(Yt,{"aria-hidden":"true"}),h=r.jsx(Et,{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(pt,{variant:"destructive",children:[p,h,r.jsx(ht,{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(ee,{className:"mt-3 w-full",onClick:()=>void l(),children:"Try again"}),n[15]=x):x=n[15];let b;return n[16]!==g?(b=r.jsxs(jc,{children:[g,x]}),n[16]=g,n[17]=b):b=n[17],b}let m;return n[18]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(jc,{children:r.jsx(on,{children:r.jsxs(rn,{className:"flex min-h-24 items-center justify-center gap-2",role:"status","aria-label":"Opening shared session",children:[r.jsx(ss,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),r.jsx(st,{className:"size-5 text-muted-foreground"})]})})}),n[18]=m):m=n[18],m}function rB(n){return n.kind==="ready"?{kind:"ended"}:n}class iB extends y.Component{constructor(){super(...arguments);Si(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(on,{className:"w-full max-w-lg text-center",children:[r.jsxs(un,{className:"justify-items-center",children:[r.jsx(gn,{"aria-hidden":"true",className:"mb-2 size-8 text-destructive"}),r.jsx(fn,{children:r.jsx("h1",{children:"Cogpit hit a render error"})}),r.jsx(mn,{children:"Reload the app to recover. Your sessions and project files are unchanged."})]}),r.jsx(rn,{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(Jr,{className:"justify-center",children:r.jsxs(ee,{onClick:()=>window.location.reload(),children:[r.jsx(Pt,{"data-icon":"inline-start"}),"Reload Cogpit"]})})]})})}}const Wv=document.getElementById("root");if(!Wv)throw new Error("Root element not found");jy.createRoot(Wv).render(r.jsx(y.StrictMode,{children:r.jsx(iB,{children:qa(window.location.pathname)?r.jsx(oB,{}):r.jsx(BF,{})})}));export{Vt as $,pt as A,ee as B,xB as C,os as D,ln as E,q9 as F,dn as G,vn as H,Pn as I,Fg as J,cl as K,fB as L,za as M,Lg as N,zg as O,Dg as P,Ct as Q,nj as R,i5 as S,ul as T,Mo as U,jt as V,Qr as W,bs as X,xg as Y,bg as Z,G as _,a5 as a,Dt as a$,Zr as a0,yx as a1,wx as a2,An as a3,Pe as a4,Hr as a5,ft as a6,Rt as a7,mt as a8,Gd as a9,Tr as aA,ed as aB,Eu as aC,Qs as aD,Ka as aE,Og as aF,ii as aG,un as aH,fn as aI,rn as aJ,Jr as aK,on as aL,nl as aM,E0 as aN,Ts as aO,Bn as aP,Et as aQ,mn as aR,ax as aS,Yr as aT,ez as aU,Wa as aV,St as aW,Eo as aX,w$ as aY,en as aZ,pB as a_,Yd as aa,Xd as ab,PN as ac,Qd as ad,Zd as ae,Jd as af,tu as ag,eu as ah,Ms as ai,nc as aj,sP as ak,st as al,q5 as am,gB as an,Vd as ao,Ws as ap,ot as aq,ou as ar,px as as,hx as at,Ur as au,AB as av,P9 as aw,SS as ax,Kn as ay,Xc as az,l5 as b,LN as b0,Oa as b1,ix as b2,mB as b3,It as b4,Mt as b5,Ot as b6,il as b7,al as b8,ll as b9,oa as bA,zo as bB,Do as bC,v4 as bD,hB as bE,eD as bF,jo as ba,jB as bb,sn as bc,Ar as bd,TN as be,ct as bf,q4 as bg,wB as bh,wu as bi,Q0 as bj,Su as bk,X0 as bl,Js as bm,r2 as bn,QD as bo,Gb as bp,oi as bq,Cs as br,T7 as bs,ag as bt,ig as bu,og as bv,Wt as bw,Lo as bx,yB as by,vB as bz,r5 as c,e5 as d,SB as e,nP as f,NB as g,rs as h,Ps as i,is as j,as as k,Nt as l,ls as m,cs as n,_B as o,ht as p,qn as q,CB as r,TB as s,EB as t,kB as u,rv as v,be as w,bB as x,cn as y,bn as z};
|