cogpit 3.4.0 → 3.4.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.
Files changed (26) hide show
  1. package/dist/cli-runtime.js +329 -265
  2. package/dist/instance-worker.js +3 -1
  3. package/dist/web/assets/{CogpitBlock-BycygJkN.js → CogpitBlock-B7SKhn5k.js} +1 -1
  4. package/dist/web/assets/{CommandPaletteHost-BgKoDHcE.js → CommandPaletteHost-Dig9sRnN.js} +1 -1
  5. package/dist/web/assets/{ConfigBrowser-Bg_4DTXP.js → ConfigBrowser-C_4UyHta.js} +1 -1
  6. package/dist/web/assets/{CrewPanel-zGPJa0nm.js → CrewPanel-CyCZndfq.js} +1 -1
  7. package/dist/web/assets/{HighlightedEditor-C2wqN7Xw.js → HighlightedEditor-YAPOkcjz.js} +1 -1
  8. package/dist/web/assets/{KeyboardShortcutsDialog-CUUxScBc.js → KeyboardShortcutsDialog-CjA8MBfY.js} +1 -1
  9. package/dist/web/assets/{MissionHome-BTxUBbuU.js → MissionHome-CK5zZCld.js} +1 -1
  10. package/dist/web/assets/{MobileFileChanges-BN7bdxse.js → MobileFileChanges-DyjwWXMW.js} +1 -1
  11. package/dist/web/assets/{PluginsDialog-XdukDCaQ.js → PluginsDialog-BHKZ3Esx.js} +1 -1
  12. package/dist/web/assets/{PreviewPanel-u6bXlEMm.js → PreviewPanel-CXOXFWWK.js} +1 -1
  13. package/dist/web/assets/{ProjectFilesPanel-BMSrF4EP.js → ProjectFilesPanel-CwBgFc0T.js} +1 -1
  14. package/dist/web/assets/{ProjectSwitcherModal-Ph5R0C2t.js → ProjectSwitcherModal-DB-xcVjM.js} +1 -1
  15. package/dist/web/assets/{TerminalOutput-w6mgZ5a7.js → TerminalOutput-BA4pFb8E.js} +1 -1
  16. package/dist/web/assets/{ThemeSelectorModal-DB69FVzW.js → ThemeSelectorModal-B8nIlHO2.js} +1 -1
  17. package/dist/web/assets/{WorkflowsPanel-DFIpG32k.js → WorkflowsPanel-BZhR5Ld-.js} +1 -1
  18. package/dist/web/assets/{WorktreePanel-B_9oCuoW.js → WorktreePanel-DYxBPlno.js} +1 -1
  19. package/dist/web/assets/{edition-ui-ZYzlZ7yi.js → edition-ui-CXQDiuhB.js} +1 -1
  20. package/dist/web/assets/{index-CKeIY-uM.js → index-B1Aq64LJ.js} +1 -1
  21. package/dist/web/assets/{index-C1aZnlGg.js → index-C0oae6L9.js} +1 -1
  22. package/dist/web/assets/{index-BYjv05SI.js → index-D3WV64DU.js} +11 -11
  23. package/dist/web/assets/{index-vyOkk7K_.js → index-utwOdTFc.js} +2 -2
  24. package/dist/web/assets/{switch-DkwGVNAF.js → switch-B1AuQGfo.js} +1 -1
  25. package/dist/web/index.html +1 -1
  26. package/package.json +2 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalOutput-w6mgZ5a7.js","assets/vendor-react-gGw_S5I_.js","assets/vendor-ui-DkzcTXCS.js","assets/vendor-shiki-DOn6sF-i.js","assets/vendor-markdown-BE1gYnO9.js","assets/html-GMplVEZG.js","assets/javascript-wDzz0qaB.js","assets/css-DPfMkruS.js","assets/cpp-BRuaLJcg.js","assets/c-BIGW1oBm.js","assets/sql-BLtJtn59.js","assets/ruby-B0Tyh1qT.js","assets/xml-D2mA2LmW.js","assets/java-CylS5w8V.js","assets/typescript-BPQ3VLAy.js","assets/jsx-g9-lgVsj.js","assets/tsx-COt5Ahok.js","assets/bash-Yzrsuije.js","assets/yaml-Buea-lGh.js","assets/php-aq0itWAE.js","assets/json-Cp-IABpG.js","assets/vue-DVfSmUF7.js","assets/svelte-DZMnMd3x.js","assets/scss-OYdSNvt2.js","assets/CogpitBlock-BycygJkN.js","assets/ProjectSwitcherModal-Ph5R0C2t.js","assets/CommandPaletteHost-BgKoDHcE.js","assets/index-vyOkk7K_.js","assets/switch-DkwGVNAF.js","assets/password-BV9mqUzz.js","assets/KeyboardShortcutsDialog-CUUxScBc.js","assets/ThemeSelectorModal-DB69FVzW.js","assets/ProjectFilesPanel-BMSrF4EP.js","assets/HighlightedEditor-C2wqN7Xw.js","assets/WorktreePanel-B_9oCuoW.js","assets/CrewPanel-zGPJa0nm.js","assets/index-CKeIY-uM.js","assets/MissionHome-BTxUBbuU.js","assets/ConfigBrowser-Bg_4DTXP.js","assets/PreviewPanel-u6bXlEMm.js","assets/PluginsDialog-XdukDCaQ.js","assets/MobileFileChanges-BN7bdxse.js","assets/edition-ui-ZYzlZ7yi.js","assets/index-C1aZnlGg.js","assets/WorkflowsPanel-DFIpG32k.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalOutput-BA4pFb8E.js","assets/vendor-react-gGw_S5I_.js","assets/vendor-ui-DkzcTXCS.js","assets/vendor-shiki-DOn6sF-i.js","assets/vendor-markdown-BE1gYnO9.js","assets/html-GMplVEZG.js","assets/javascript-wDzz0qaB.js","assets/css-DPfMkruS.js","assets/cpp-BRuaLJcg.js","assets/c-BIGW1oBm.js","assets/sql-BLtJtn59.js","assets/ruby-B0Tyh1qT.js","assets/xml-D2mA2LmW.js","assets/java-CylS5w8V.js","assets/typescript-BPQ3VLAy.js","assets/jsx-g9-lgVsj.js","assets/tsx-COt5Ahok.js","assets/bash-Yzrsuije.js","assets/yaml-Buea-lGh.js","assets/php-aq0itWAE.js","assets/json-Cp-IABpG.js","assets/vue-DVfSmUF7.js","assets/svelte-DZMnMd3x.js","assets/scss-OYdSNvt2.js","assets/CogpitBlock-B7SKhn5k.js","assets/ProjectSwitcherModal-DB-xcVjM.js","assets/CommandPaletteHost-Dig9sRnN.js","assets/index-utwOdTFc.js","assets/switch-B1AuQGfo.js","assets/password-BV9mqUzz.js","assets/KeyboardShortcutsDialog-CjA8MBfY.js","assets/ThemeSelectorModal-B8nIlHO2.js","assets/ProjectFilesPanel-CwBgFc0T.js","assets/HighlightedEditor-YAPOkcjz.js","assets/WorktreePanel-DYxBPlno.js","assets/CrewPanel-CyCZndfq.js","assets/index-B1Aq64LJ.js","assets/MissionHome-CK5zZCld.js","assets/ConfigBrowser-C_4UyHta.js","assets/PreviewPanel-CXOXFWWK.js","assets/PluginsDialog-BHKZ3Esx.js","assets/MobileFileChanges-DyjwWXMW.js","assets/edition-ui-CXQDiuhB.js","assets/index-C0oae6L9.js","assets/WorkflowsPanel-BZhR5Ld-.js"])))=>i.map(i=>d[i]);
2
2
  var CP=Object.defineProperty;var _P=(n,e,t)=>e in n?CP(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Ge=(n,e,t)=>_P(n,typeof e!="symbol"?e+"":e,t);import{j as a,c as V,r as y,d as _e,e as EP,a as TP,f as AP}from"./vendor-react-gGw_S5I_.js";import{aY as IP,aZ as PP,a_ as $P,a$ as oo,b0 as d4,b1 as X1,b2 as J1,b3 as Q1,b4 as ex,b5 as bc,X as Mt,b6 as tx,b7 as RP,b8 as OP,b9 as LP,ba as MP,bb as zP,bc as DP,bd as FP,be as UP,a5 as _t,bf as BP,bg as WP,bh as qP,bi as VP,bj as HP,N as nn,bk as KP,bl as GP,bm as ka,bn as f4,bo as m4,ar as nx,C as it,af as St,bp as ZP,O as Ir,bq as yf,br as Pr,bs as YP,bt as XP,bu as JP,bv as QP,bw as e$,bx as t$,by as n$,bz as s$,al as p4,a as Fn,bA as r$,bB as h4,bC as o$,bD as i$,bE as a$,bF as l$,bG as c$,bH as g4,A as Ao,bI as Sd,i as ql,bJ as x4,G as Gr,bK as sx,bL as u$,J as rx,ag as er,bM as d$,bN as Ki,bO as Uo,bP as f$,bQ as m$,bR as p$,bS as h$,bT as Vl,S as ss,ap as yr,bU as b4,bV as g$,bW as x$,bX as v4,bY as y4,bZ as w4,b_ as S4,b$ as k4,c0 as j4,c1 as b$,c2 as v$,c3 as y$,ai as wf,c4 as w$,a2 as Sf,p as na,ab as ja,c5 as hg,c6 as N4,c7 as C4,c8 as _4,c9 as E4,ca as T4,cb as A4,cc as S$,au as ox,ak as k$,Y as wr,B as Es,cd as j$,ce as N$,cf as C$,cg as _$,ch as E$,ci as Hl,cj as Na,ck as T$,k as kf,am as ix,cl as A$,cm as I$,an as P$,c as ax,cn as $$,co as R$,cp as O$,cq as L$,cr as M$,cs as z$,ct as D$,cu as F$,cv as U$,cw as B$,P as Sr,z as Ca,cx as W$,cy as q$,cz as V$,cA as H$,n as Zr,aj as Bo,cB as K$,as as I4,$ as lx,e as jf,cC as G$,cD as Z$,cE as P4,j as cx,aE as $4,aU as Y$,a7 as mi,cF as gg,cG as R4,cH as X$,aa as ux,cI as J$,cJ as dx,cK as fx,cL as xg,cM as Q$,R as mx,cN as e8,cO as t8,a3 as Io,b as O4,cP as n8,u as _a,a4 as kl,cQ as kd,cR as px,m as vc,cS as s8,cT as r8,cU as o8,cV as L4,cW as M4,cX as mu,cY as Yo,av as xy,F as yc,I as hx,cZ as i8,a8 as jd,c_ as a8,c$ as l8,v as Nf,Q as sa,_ as gx,d0 as c8,d1 as u8,d2 as d8,d3 as f8,d4 as m8,d5 as p8,d6 as h8,d7 as g8,d8 as z4,d9 as x8,da as b8,aL as v8,o as bg,db as y8,dc as D4,D as wc,dd as w8,aH as Cf,aG as Ns,a9 as F4,de as U4,t as S8,df as k8,aP as B4,r as j8,dg as vg,x as N8,dh as C8,di as _8,dj as E8,dk as T8,dl as A8,q as I8,dm as P8,dn as $8,dp as R8,dq as O8,aC as xx,U as bx,H as L8,dr as W4,ds as M8,ae as z8,L as q4,y as V4,ah as D8,aA as F8,aS as U8,dt as B8,du as W8,dv as q8,ad as V8,dw as H8}from"./vendor-ui-DkzcTXCS.js";import{c as K8,a as G8}from"./vendor-shiki-DOn6sF-i.js";import{r as H4,M as tr}from"./vendor-markdown-BE1gYnO9.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const o of r)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&s(i)}).observe(document,{childList:!0,subtree:!0});function t(r){const o={};return r.integrity&&(o.integrity=r.integrity),r.referrerPolicy&&(o.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?o.credentials="include":r.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function s(r){if(r.ep)return;r.ep=!0;const o=t(r);fetch(r.href,o)}})();const Z8="modulepreload",Y8=function(n){return"/"+n},by={},nt=function(e,t,s){let r=Promise.resolve();if(t&&t.length>0){let i=function(u){return Promise.all(u.map(d=>Promise.resolve(d).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),c=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));r=i(t.map(u=>{if(u=Y8(u),u in by)return;by[u]=!0;const d=u.endsWith(".css"),f=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${f}`))return;const m=document.createElement("link");if(m.rel=d?"stylesheet":Z8,d||(m.as="script"),m.crossOrigin="",m.href=u,c&&m.setAttribute("nonce",c),document.head.appendChild(m),d)return new Promise((p,h)=>{m.addEventListener("load",p),m.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${u}`)))})}))}function o(i){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=i,window.dispatchEvent(l),!l.defaultPrevented)throw i}return r.then(i=>{for(const l of i||[])l.status==="rejected"&&o(l.reason);return e().catch(o)})},Ys=["acp","codex","copilot","claude"];function Nd(n,e){if(n==="default")return e;const t=new TextEncoder().encode(e),s=btoa(Array.from(t,r=>String.fromCharCode(r)).join("")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return`i-${n}__${s}`}function yg(n){const e=/^i-([A-Za-z0-9-]+)__([A-Za-z0-9_-]+)$/.exec(n);if(!e)return{instanceId:"default",nativeId:n};try{const t=Uint8Array.from(atob(e[2].replace(/-/g,"+").replace(/_/g,"/")),s=>s.charCodeAt(0));return{instanceId:e[1],nativeId:new TextDecoder("utf-8",{fatal:!0}).decode(t)}}catch{throw new Error("Invalid instance session ID")}}function X8(n,e){return n==="default"?e:`instance__${n}__${e}`}function Yr(n){const e=/^instance__([A-Za-z0-9-]+)__(.+)$/.exec(n??"");return e?{instanceId:e[1],nativeDirName:e[2]}:{instanceId:"default",nativeDirName:n??""}}function ra(n,e){return e==="default"?n:{...n,instanceId:e,sessionId:Nd(e,yg(n.sessionId).nativeId),...n.branchedFrom?{branchedFrom:{...n.branchedFrom,sessionId:Nd(e,yg(n.branchedFrom.sessionId).nativeId)}}:{}}}const vx="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}",J8=new RegExp(`^${vx}$`,"i");function vy(n,e){const t=new TextEncoder().encode(e);let s="";for(const o of t)s+=String.fromCharCode(o);const r=btoa(s).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return`${n}${r}`}function yy(n,e){if(!e.startsWith(n))return null;try{const t=e.slice(n.length).replace(/-/g,"+").replace(/_/g,"/"),s=atob(t),r=Uint8Array.from(s,o=>o.charCodeAt(0));return new TextDecoder().decode(r)}catch{return null}}function yx(n){return{lossy:!1,owns:e=>typeof e=="string"&&e.startsWith(n),recognizes:e=>{const t=yy(n,e);return t!==null&&t!==""&&vy(n,t)===e},encode:e=>vy(n,e),decode:e=>yy(n,e)}}function Kl(n){const e=new RegExp(`(${vx})\\.jsonl(?:\\.zst)?$`,"i").exec(n);return e?e[1]:null}function _f(n){return n?{rootSessionId:n.toLowerCase(),isRootTranscript:!0}:null}function wx(n){const e=n.split("/");return e.every(s=>s!==""&&s!=="."&&s!==".."&&!s.includes("\\"))?e:null}const Sx={urlId:n=>n.replace(/\.jsonl$/,""),fileNameFromUrlId:n=>n.endsWith(".jsonl")?n:`${n}.jsonl`};function K4(n){return`'${n.replace(/'/g,"'\\''")}'`}function Gl(n,e){return e?[n,e]:[]}function Cd(n,e){var t;return((t=e.exec(n))==null?void 0:t[1])??null}const _d="[0-9a-f-]{36}",G4="codex__",Z4="copilot__",Q8=new Set(["default","plan","acceptEdits","dontAsk","auto"]),eR=new Set(["subagents","workflows"]);function tR(n){const e=wx(n);if(!e)return null;const[t,s]=e;if(e.length===1){const r=t.replace(/\.jsonl$/,"");return r!==t&&Sy(r)?_f(r):null}return e.length>2&&eR.has(s)&&Sy(t)?{rootSessionId:t.toLowerCase(),isRootTranscript:!1}:null}const Y4={kind:"claude",displayName:"Claude Code",binName:"claude",dirName:{lossy:!0,owns:n=>typeof n=="string"&&!n.startsWith(G4)&&!n.startsWith(Z4),recognizes:n=>/^(?:(?:-|[A-Za-z]--)[A-Za-z0-9-]*|[A-Za-z]-)$/.test(n),encode:n=>(n.replace(/[\\/]+$/,"")||n).replace(/[^a-zA-Z0-9]/g,"-"),decode:n=>{const e=/^([A-Za-z])--(.*)$/.exec(n);return e?`${e[1]}:\\${e[2].replace(/-/g,"\\")}`:"/"+n.replace(/^-/,"").replace(/-/g,"/")}},projectWorktreeDir:".claude/worktrees",sessionFile:{name:n=>`${n}.jsonl`,sessionId:Kl,...Sx,transcriptRoot:tR},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"]:[...Q8.has(n.mode)?["--permission-mode",n.mode]:[],...(n.allowedTools??[]).flatMap(e=>["--allowedTools",e]),...(n.disallowedTools??[]).flatMap(e=>["--disallowedTools",e])]:["--permission-mode","default"],model:n=>Gl("--model",n),effort:n=>Gl("--effort",n),fastTier:()=>[]},serviceTier:null,cli:{packageName:"@anthropic-ai/claude-code",homebrew:{name:"claude-code",cask:!1},wingetId:null,versionArgs:["--version"],selfUpdate:{args:["update"],matches:n=>n.endsWith("/.local/bin/claude")||n.endsWith("/.local/bin/claude.exe")||n.includes("/.local/share/claude/")},bundledBySdk:!0,homeDirName:".claude",homeEnvVar:null,sdkHomeEnvVar:"CLAUDE_CONFIG_DIR",installMarker:"projects",homeIsDiscoverable:!1,process:{by:"command",sessionIdFromCommand:n=>Cd(n,new RegExp(`--resume(?:=|\\s+)(${_d})`))??Cd(n,new RegExp(`--session-id(?:=|\\s+)(${_d})`))}},config:{rootDirName:".claude",instructions:[{in:"scope",path:"CLAUDE.md",scopes:["global","project"]},{in:"root",path:"CLAUDE.md",label:".claude/CLAUDE.md",scopes:["project"]},{in:"scope",path:"AGENTS.md",scopes:["project"],fallback:!0}],settings:[{in:"root",path:"settings.json",scopes:["global"]},{in:"root",path:"settings.local.json",scopes:["project"]}],skillsDir:"skills",agentsDir:"agents",commandsDir:"commands",themesDir:"themes",pluginsDir:"plugins",pluginManifestDir:".claude-plugin"},contextWindow:{defaultLimit:1e6,limits:[{match:"claude-haiku-4-5",limit:2e5},{match:"claude-haiku-4-1",limit:2e5},{match:"claude-sonnet-4-5",limit:2e5},{match:"claude-opus-4-5",limit:2e5},{match:"claude-opus-4-1",limit:2e5}],compactBuffer:33e3,extendedContext:{marker:"[1m]",limit:1e6}},capabilities:{worktrees:!0,mcp:!0,slashCommands:!0,workflows:!0,agentTeams:!0,subagentTranscripts:!0,nestedSubagents:!1,sharing:!0,goals:"transcript",undo:!0,redo:!0,nativeRewind:!1,fileCheckpoints:!0,reasoningEffort:!0,configurableContextWindow:!1,fastTier:!0,lowPriorityInTerminal:!0,imageInput:!0,midTurnSteering:!0,activeNotifications:!0,stopSession:!0,ultracode:!0,contextWindow:!0,externalProcesses:!1,accountSwitching:!0,modelFallbackNotices:!0,autoPermissionMode:"per-model",toolPermissionRules:!0,settingsApply:"live",turnLiveness:"transcript",tokenStreaming:!0,nativeFork:!1,namedSessions:!0}},wy={appServerValue:"priority",cliConfigValue:"fast"},nR={kind:"codex",displayName:"Codex",binName:"codex",dirName:yx(G4),projectWorktreeDir:null,sessionFile:{name:(n,e=new Date)=>{const t=String(e.getFullYear()),s=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0"),o=String(e.getHours()).padStart(2,"0"),i=String(e.getMinutes()).padStart(2,"0"),l=String(e.getSeconds()).padStart(2,"0");return`${t}/${s}/${r}/rollout-${t}-${s}-${r}T${o}-${i}-${l}-${n}.jsonl`},sessionId:Kl,...Sx,transcriptRoot:n=>wx(n)?_f(Kl(n)):null},metadataFromHead:!1,resume:{command:(n,e)=>e?`codex -C ${K4(e)} resume ${n}`:`codex resume ${n}`,args:n=>["resume",n]},launchArgs:{permissions:n=>{const e=(n==null?void 0:n.mode)||"default";return e==="bypassPermissions"?["--dangerously-bypass-approvals-and-sandbox"]:e==="auto"?["--approve-for-me"]:["--sandbox",e==="plan"?"read-only":"workspace-write","-c",'approval_policy="never"']},model:n=>Gl("-m",n),effort:n=>n?["-c",`model_reasoning_effort=${JSON.stringify(n)}`]:[],fastTier:n=>n?["-c",`service_tier=${JSON.stringify(wy.cliConfigValue)}`,"--enable","fast_mode"]:[]},serviceTier:wy,cli:{packageName:"@openai/codex",homebrew:{name:"codex",cask:!1},wingetId:null,versionArgs:["--version"],selfUpdate:null,bundledBySdk:!1,homeDirName:".codex",homeEnvVar:"CODEX_HOME",sessionIdEnvVar:"CODEX_THREAD_ID",installMarker:"",homeIsDiscoverable:!0,process:{by:"command",sessionIdFromCommand:n=>Cd(n,new RegExp(`codex(?:\\s+\\S+)*\\s+exec\\s+resume\\s+(${_d})`))}},config:{rootDirName:".codex",instructions:[{in:"scope",path:"AGENTS.md",scopes:["global","project"]}],settings:[{in:"root",path:"config.toml",scopes:["global","project"]}],skillsDir:"skills",agentsDir:"agents",commandsDir:"prompts",themesDir:null,pluginsDir:null,pluginManifestDir:null},contextWindow:{defaultLimit:272e3,limits:[],compactBuffer:0,extendedContext:null},capabilities:{worktrees:!0,mcp:!1,slashCommands:!1,workflows:!1,agentTeams:!1,subagentTranscripts:!0,nestedSubagents:!0,sharing:!1,goals:"thread-api",undo:!0,redo:!0,nativeRewind:!1,fileCheckpoints:!1,reasoningEffort:!0,configurableContextWindow:!0,fastTier:!0,lowPriorityInTerminal:!1,imageInput:!0,midTurnSteering:!0,activeNotifications:!0,stopSession:!1,ultracode:!1,contextWindow:!1,externalProcesses:!1,accountSwitching:!1,modelFallbackNotices:!1,autoPermissionMode:"always",toolPermissionRules:!0,settingsApply:"next-turn",turnLiveness:"runtime",tokenStreaming:!0,nativeFork:!1,namedSessions:!1}};function Km(n){const e=new RegExp(`^(${vx})/events\\.jsonl$`,"i").exec(n);return e?e[1]:null}const sl={kind:"copilot",displayName:"GitHub Copilot CLI",binName:"copilot",dirName:yx(Z4),projectWorktreeDir:null,sessionFile:{name:n=>`${n}/events.jsonl`,sessionId:Km,urlId:n=>Km(n)??n.replace(/\.jsonl$/,""),fileNameFromUrlId:n=>n.endsWith(".jsonl")?n:`${n}/events.jsonl`,transcriptRoot:n=>_f(Km(n))},metadataFromHead:!0,resume:{command:(n,e)=>e?`copilot -C ${K4(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=>Gl("--model",n),effort:n=>Gl("--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=>Cd(n,new RegExp(`--resume(?:=|\\s+)(${_d})`))}},config:{rootDirName:".copilot",instructions:[{in:"scope",path:"AGENTS.md",scopes:["global","project"]}],settings:[{in:"root",path:"config.json",scopes:["global"]}],skillsDir:"skills",agentsDir:null,commandsDir:null,themesDir:null,pluginsDir:null,pluginManifestDir:null},contextWindow:{defaultLimit:2e5,limits:[],compactBuffer:0,extendedContext:null},capabilities:{worktrees:!1,mcp:!1,slashCommands:!1,workflows:!1,agentTeams:!1,subagentTranscripts:!1,nestedSubagents:!1,sharing:!1,goals:!1,undo:!0,redo:!1,nativeRewind:!0,fileCheckpoints:!1,reasoningEffort:!1,configurableContextWindow:!1,fastTier:!1,lowPriorityInTerminal:!1,imageInput:!1,midTurnSteering:!0,activeNotifications:!0,stopSession:!0,ultracode:!1,contextWindow:!1,externalProcesses:!0,accountSwitching:!1,modelFallbackNotices:!1,autoPermissionMode:"always",toolPermissionRules:!0,settingsApply:"next-turn",turnLiveness:"runtime",tokenStreaming:!1,nativeFork:!0,namedSessions:!0}},sR={...sl,kind:"acp",displayName:"ACP agent",binName:"acp",dirName:yx("acp__"),sessionFile:{name:n=>`${n}.jsonl`,sessionId:Kl,...Sx,transcriptRoot:n=>{const e=wx(n);return(e==null?void 0:e.length)===1?_f(Kl(n)):null}},resume:{command:()=>"Resume this session in Cogpit",args:()=>[]},launchArgs:{permissions:()=>[],model:()=>[],effort:()=>[],fastTier:()=>[]},cli:{...sl.cli,packageName:"",homebrew:null,wingetId:null,selfUpdate:null,requiresConfiguration:!0,homeDirName:".cogpit-acp",homeEnvVar:"COGPIT_ACP_HOME",homeIsDiscoverable:!0,installMarker:"projects"},config:{...sl.config,rootDirName:".cogpit-acp",instructions:[],settings:[],skillsDir:null},capabilities:{...sl.capabilities,undo:!1,redo:!1,nativeRewind:!1,nativeFork:!1,midTurnSteering:!1,activeNotifications:!1,externalProcesses:!1,autoPermissionMode:"never",toolPermissionRules:!1,namedSessions:!1}},Zl=Object.freeze({claude:Y4,codex:nR,copilot:sl,acp:sR});function Cn(n){return Zl[n]}function Sc(){return Ys.map(n=>Zl[n])}function rR(n,e){const t=Sc().filter(n);if(t.length!==1)throw new Error(`Expected exactly one agent with ${e}, found ${t.length}`);return t[0]}function vs(n){const e=Yr(n);if(e.instanceId!=="default"){const t=vs(e.nativeDirName);return{...t,dirName:{...t.dirName,encode:s=>X8(e.instanceId,t.dirName.encode(s)),decode:s=>t.dirName.decode(Yr(s).nativeDirName)},sessionFile:{...t.sessionFile,name:s=>t.sessionFile.name(yg(s).nativeId),sessionId:s=>{const r=t.sessionFile.sessionId(s);return r?Nd(e.instanceId,r):null},transcriptRoot:s=>{const r=t.sessionFile.transcriptRoot(s);return r?{...r,rootSessionId:Nd(e.instanceId,r.rootSessionId)}:null}}}}for(const t of Ys)if(t!=="claude"&&Zl[t].dirName.owns(n))return Zl[t];return Y4}function un(n){return vs(n).kind}function Gm(n,e,t){const s=Zl[n].dirName;return t&&s.lossy?t:s.encode(e)}function Sy(n){return J8.test(n)}const Wo=vs(null).kind;var c4;const pu=((c4=Sc().find(n=>n.dirName.lossy))==null?void 0:c4.kind)??null;function oa(n){return vs(n).capabilities}function bn(n){return Cn(n).capabilities}function oR(n,e){return Ys.find(t=>t===n)??e}function Ed(n){for(const e of Sc()){const t=e.sessionFile.sessionId(n);if(t)return t}return n.replace(/\.jsonl$/,"")}function kx(n,e){var t;return((t=vs(n).sessionFile.transcriptRoot(e))==null?void 0:t.rootSessionId)??null}function iR(n,e){const t=vs(n).sessionFile.transcriptRoot(e);return t!=null&&t.isRootTranscript?t.rootSessionId:null}function X4(n,e){return vs(n).sessionFile.urlId(e)}function aR(n,e){return vs(n).sessionFile.fileNameFromUrlId(e)}function jx(n,e,t){return Cn(n).resume.command(e,t)}function lR(n,e){const t=Cn(n);return{command:t.binName,args:[...t.resume.args(e)]}}function ky(n){return n.replace(/\/+$/,"")||"/"}function cR(n,e,t){var r;const s=ky(e);return((r=n.find(o=>vs(o.dirName).kind===t&&ky(o.path)===s))==null?void 0:r.dirName)??null}const Lt="local",J4="cogpit-last-path::",wg=new Map;function Kt(){var t;const n=typeof window<"u"?(t=window.location)==null?void 0:t.pathname:void 0;if(!n)return Lt;const e=/^\/d\/([^/]+)/.exec(n);return e?e[1]:Lt}function qo(){return Kt()!==Lt}function Nx(){const n=Kt();return n===Lt?"":`/d/${n}`}function Q4(){const n=Kt();return n===Lt?"":`/hub/${n}`}function Cx(n){const e=Q4();return!e||n.startsWith("/api/hub/")||n.startsWith("/api/auth/")?n:n.startsWith("/api")||n.startsWith("/__pty")||n.startsWith("/__browser")?`${e}${n}`:n}let Yl=null;function uR(n){n!==Yl&&(Yl=n,window.dispatchEvent(new Event("cogpit-identity-changed")))}function Zn(){return Yl}function Qu(n){return n===Lt?0:wg.get(n)??0}function dR(n,e){if(n===Lt||!Number.isSafeInteger(e)||e<0)return!1;const t=wg.get(n);return t!==void 0&&e<=t?!1:(wg.set(n,e),window.dispatchEvent(new CustomEvent("cogpit-device-scope-changed",{detail:{deviceId:n,connectionRevision:e}})),!0)}function cn(){const n=Kt(),e=Qu(n);return e===0?n:`${n}@${e}`}function sn(n){const e=Kt(),t=cn();return Yl!==null?`${n}::${t}::${Yl}`:e===Lt?n:`${n}::${t}`}function Va(n,e){sessionStorage.setItem(`${J4}${n}`,e)}function Xs(n){const t=sessionStorage.getItem(`${J4}${n}`)??(n===Lt?"/":`/d/${n}/`);window.history.pushState(null,"",t),window.dispatchEvent(new Event("cogpit-device-changed"))}const fR=["personal","team"];function eN(n){return fR.includes(n)}const mR="X-Cogpit-Gate",_x={terminal:!0,configWrite:!0,hostFiles:!0,manageDevices:!0,killAny:!0,viewUsage:!0,share:!0,browser:!0},Ea={terminal:!1,configWrite:!1,hostFiles:!1,manageDevices:!1,killAny:!1,viewUsage:!1,share:!1,browser:!1},Sg="cogpit-gate";function pR(n){n.status===403&&n.headers.has(mR)&&window.dispatchEvent(new Event(Sg))}function hR(n){return window.addEventListener(Sg,n),()=>window.removeEventListener(Sg,n)}const gR="/api/session-access/",Ex="X-Cogpit-Session-Access",xR="X-Cogpit-Session-Id",jy="access",Ny="session-config",tN="cogpit-session-access-lost",nN="cogpit-session-access-changed",sN="cogpit-session-deleted",bR=6e4,ed=new Map,vR=["none","view","interact","own"];function rN(n){return typeof n=="string"&&vR.includes(n)}function oN(n,e,t=!1){window.dispatchEvent(new CustomEvent(n,{detail:{sessionId:e,background:t}}))}function iN(n,e,t=!1){oN(e==="none"?tN:nN,n,t)}function yR(n){return n.headers.has(Ex)}function aN(n){return n.headers.get(Ex)==="none"}function wR(n,e=!1){const t=n.headers.get(Ex),s=n.headers.get(xR);rN(t)&&s&&iN(s,t,e)}function SR(n){function e(t){let s;try{s=JSON.parse(t.data)}catch{return}rN(s.level)&&typeof s.sessionId=="string"&&iN(s.sessionId,s.level)}return n.addEventListener(jy,e),()=>n.removeEventListener(jy,e)}function Tx(n,e,t){function s(r){const o=r.detail,i=o==null?void 0:o.sessionId;typeof i!="string"||t!==void 0&&i!==t||e(i,(o==null?void 0:o.background)===!0)}return window.addEventListener(n,s),()=>window.removeEventListener(n,s)}function kR(n){return Tx(tN,n)}function jR(n,e){const t=e.catch(()=>!1);ed.set(n,t);const s=()=>{ed.get(n)===t&&ed.delete(n)};return t.then(r=>(r?(oN(sN,n),setTimeout(s,bR)):s(),r))}function NR(n){return ed.get(n)??Promise.resolve(!1)}function CR(n){return Tx(sN,n)}function lN(n,e){return Tx(nN,n,e)}let cN=null;function Td(){return cN}function _R(n){cN=n}const ER=["DEVICE_AUTH_FAILED","DEVICE_UNREACHABLE","DEVICE_REFUSED"],Cy="cogpit-network-token",TR=new Set(["localhost","127.0.0.1","::1","0:0:0:0:0:0:0:1"]);function Ef(){const n=window.location.hostname.toLowerCase(),e=n.startsWith("[")&&n.endsWith("]")?n.slice(1,-1):n;return!TR.has(e)}function Tf(){try{localStorage.removeItem(Cy),sessionStorage.removeItem(Cy)}catch{}}typeof window<"u"&&Tf();const AR={edition:"personal",signIn:"password",setupRequired:!1};let Xl=null;function uN(){return fetch("/api/hello",{method:"GET",credentials:"same-origin",cache:"no-store",headers:{"X-Cogpit-Client":"1"}}).then(async n=>{if(!n.ok)throw new Error(`Hello handshake failed (${n.status})`);const e=await n.json(),t=e.signIn==="account"?"account":"password";return _R(t),{edition:eN(e.edition)?e.edition:"personal",signIn:t,setupRequired:t==="account"&&e.setupRequired===!0}}).catch(()=>(Xl=null,AR))}function dN(){return Xl??(Xl=uN()),Xl}function _y(){return Xl=uN(),Xl}function fN(){return dN().then(n=>n.signIn)}async function IR(){if(!Ef()&&Td()!=="account")return!0;try{return(await fetch("/api/auth/session",{method:"GET",credentials:"same-origin",cache:"no-store",headers:{"X-Cogpit-Client":"1"}})).ok}catch{return!1}}async function PR(){try{await fetch("/api/auth/logout",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"X-Cogpit-Client":"1"}})}finally{Tf()}}const $R=new Set(ER);function Ey(){return Tf(),window.dispatchEvent(new Event("cogpit-auth-required")),Promise.reject(new Error("Authentication required"))}function mN(n,e,t){t&&typeof n=="string"&&n.startsWith("/api")&&(n=Cx(n));const{background:s=!1,...r}=e??{},o=new Headers(r.headers);return o.delete("Authorization"),o.set("X-Cogpit-Client","1"),fetch(n,{...r,headers:o,credentials:"same-origin"}).then(i=>{if(wR(i,s),pR(i),i.status===401){if(Ef()||Td()==="account")return Ey();if(Td()===null)return fN().then(l=>l==="account"?Ey():i)}if(i.status===502){const l=i.headers.get("X-Cogpit-Hub-Error"),c=i.headers.get("X-Cogpit-Device");c&&l&&$R.has(l)&&window.dispatchEvent(new CustomEvent("cogpit-device-unreachable",{detail:{deviceId:c,reason:l}}))}return i})}function Ce(n,e){return mN(n,e,!0)}function is(n,e,t={}){return Ce(n,{method:"POST",...t,headers:{"Content-Type":"application/json",...t.headers},body:JSON.stringify(e)})}function Ur(n,e){return mN(n,e,!1)}function Af(n){return Cx(n)}const jl={conversation:null,commands:[],cursor:0,freshness:"waiting"},Jl=new Map;class RR{constructor(e,t){Ge(this,"state",jl);Ge(this,"listeners",new Set);Ge(this,"timer");Ge(this,"pending");Ge(this,"attempts",0);Ge(this,"stopped",!1);Ge(this,"identityChanged",()=>{var e;this.stopped=!0,clearTimeout(this.timer),(e=this.pending)==null||e.abort(),this.apply({...jl,freshness:"stale",error:"Account or device changed"}),Jl.delete(this.key)});Ge(this,"refresh",()=>{document.visibilityState!=="hidden"&&this.fetch()});Ge(this,"subscribe",e=>(this.listeners.add(e),this.listeners.size===1&&(window.addEventListener("cogpit-command-accepted",this.refresh),window.addEventListener("online",this.refresh),window.addEventListener("cogpit-identity-changed",this.identityChanged),window.addEventListener("cogpit-device-scope-changed",this.identityChanged),document.addEventListener("visibilitychange",this.refresh),this.fetch()),()=>{var t;this.listeners.delete(e),this.listeners.size||(clearTimeout(this.timer),(t=this.pending)==null||t.abort(),window.removeEventListener("cogpit-command-accepted",this.refresh),window.removeEventListener("online",this.refresh),window.removeEventListener("cogpit-identity-changed",this.identityChanged),window.removeEventListener("cogpit-device-scope-changed",this.identityChanged),document.removeEventListener("visibilitychange",this.refresh),Jl.delete(this.key))}));Ge(this,"snapshot",()=>this.state);this.key=e,this.url=t}get watched(){return this.listeners.size>0}admit(e){this.state.commands.some(t=>t.id===e.id)||this.apply({...this.state,commands:[...this.state.commands,e]})}apply(e){if(JSON.stringify(this.state)!==JSON.stringify(e)){this.state=e;for(const t of this.listeners)t()}}async fetch(){if(this.stopped||this.pending||!this.listeners.size||document.visibilityState==="hidden")return;clearTimeout(this.timer);const e=new AbortController;this.pending=e;let t=!1;try{const s=await Ce(`${this.url}&after=${this.state.cursor}`,{signal:e.signal});if(!s.ok)throw t=[401,403,404].includes(s.status),new Error(`Queue unavailable (${s.status})`);const r=await s.json();if(e.signal.aborted)return;if(!r.conversation||!Array.isArray(r.commands)||!r.replay||!Number.isSafeInteger(r.replay.cursor))throw new Error("Invalid queue snapshot");this.apply({conversation:r.conversation,commands:r.commands,cursor:r.replay.cursor,freshness:"current",currentAddress:r.currentAddress,pendingTransition:r.pendingTransition}),this.attempts=0}catch(s){e.signal.aborted||this.apply({...t?jl:this.state,freshness:"stale",error:s instanceof Error?s.message:"Queue unavailable"}),this.attempts++}finally{this.pending=void 0,!this.stopped&&this.listeners.size&&!t&&(this.timer=setTimeout(()=>{this.fetch()},Math.min(3e4,2e3*2**Math.min(this.attempts,4))*(.8+Math.random()*.4)))}}async action(e){if(this.stopped)throw new Error("Account or device changed; reopen the conversation");const t=await Ce(this.url.split("?")[0],{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const s=await t.json();throw new Error(s.error??"Queue update failed")}await this.fetch()}}function pN(n){const e=Af(`/api/session-commands?sessionId=${encodeURIComponent(n)}`);return{key:JSON.stringify([cn(),Zn(),e]),url:e}}function If(n){const{key:e,url:t}=pN(n);let s=Jl.get(e);return s||(s=new RR(e,t),Jl.set(e,s)),s}function OR(n){const e=Jl.get(pN(n.sessionId).key);return e!=null&&e.watched?(e.admit(n),!0):!1}function G(...n){return IP(PP(n))}const LR=oo("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 Q({className:n,variant:e,size:t,...s}){return a.jsx($P,{"data-slot":"button",className:G(LR({variant:e,size:t,className:n})),...s})}const MR=[{value:"",label:"Default"},{value:"opus",label:"Opus"},{value:"fable",label:"Fable"},{value:"sonnet",label:"Sonnet"},{value:"haiku",label:"Haiku"}],kg=[{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"}],zR=[...kg,{value:"ultra",label:"Ultra",description:"Maximum reasoning with automatic task delegation"}];var u4;const Ax=((u4=Cn("codex").serviceTier)==null?void 0:u4.appServerValue)??"priority",DR=[{value:Ax,label:"Fast",description:"1.5× speed with increased usage"}],Ty=[{value:Ax,label:"Fast",description:"1.5× speed"}],Ay=[{value:Ax,label:"Fast",description:"2× speed with increased usage"}],Xo={defaultReasoningEffort:"medium",supportedReasoningEfforts:zR,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:DR},FR=[{value:"",label:"Default",description:"Use the model configured in Codex"},{value:"gpt-6.1-sol",label:"GPT-6.1 Sol",description:"Latest workhorse model for coding and everyday work",...Xo,defaultReasoningEffort:"low",serviceTiers:Ay},{value:"gpt-6-astra",label:"GPT-6 Astra",description:"Frontier intelligence for the most demanding work",...Xo,serviceTiers:Ay},{value:"gpt-6-sol",label:"GPT-6 Sol",description:"Previous generation workhorse model",...Xo,serviceTiers:Ty},{value:"gpt-6-luna",label:"GPT-6 Luna",description:"Fast and affordable model for easier tasks",...Xo,supportedReasoningEfforts:kg,serviceTiers:Ty},{value:"gpt-5.6-sol",label:"GPT-5.6 Sol",description:"Older generation workhorse model",...Xo,defaultReasoningEffort:"low"},{value:"gpt-5.6-terra",label:"GPT-5.6 Terra",description:"Older balanced model for straightforward work",...Xo},{value:"gpt-5.6-luna",label:"GPT-5.6 Luna",description:"Older fast and efficient model",...Xo,supportedReasoningEfforts:kg}],UR=[{value:"",label:"Default",supportsEffort:!1,inputModalities:["text"]},{value:"auto",label:"Auto",description:"Let Copilot choose the best available model",supportsEffort:!1,inputModalities:["text"]}],BR={acp:[{value:"",label:"Provider default"}],claude:MR,codex:FR,copilot:UR};function WR(n){return BR[n]}const Ix=new Map,Ad=new Set;function qR(n,e){!Array.isArray(e)||e.length===0||(Ix.set(n,e),Ad.forEach(t=>t()))}function VR(n){return Ad.add(n),()=>Ad.delete(n)}function HR(){Ix.clear(),Ad.forEach(n=>n())}const Iy="high",KR=[{value:"low",label:"Light"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"xhigh",label:"Extra High"},{value:"max",label:"Max"}];function GR(n){return Ix.get(n)??WR(n)}function kc(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 hN(n,e,t){const s=kc(e,t),r=s==null?void 0:s.supportedReasoningEfforts;return r&&r.length>0?r:(s==null?void 0:s.supportsEffort)===!1||!bn(n).reasoningEffort?[]:KR}function ZR(n,e){var t,s;return(s=(t=kc(n,e))==null?void 0:t.serviceTiers)==null?void 0:s.find(r=>r.value==="fast"||r.value==="priority"||r.label.toLowerCase()==="fast")}function YR(n,e,t){var r;const s=(r=kc(e,t))==null?void 0:r.inputModalities;return s?s.includes("image"):bn(n).imageInput}function XR(n,e,t){var r;const s=bn(n).autoPermissionMode;return s==="always"?!0:s==="never"?!1:((r=kc(e,t))==null?void 0:r.supportsAutoMode)===!0}function JR(n,e){return bn(n).ultracode?!(e??"").toLowerCase().startsWith("haiku"):!1}function QR(n,e,t,s){var l;const r=hN(n,e,s);if(r.length===0)return"";const o=c=>!!c&&r.some(u=>u.value===c);if(o(t))return t;const i=(l=kc(e,s))==null?void 0:l.defaultReasoningEffort;return o(i)?i:o(Iy)?Iy:r[0].value}function e9(n){return n.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").slice(0,40).replace(/-$/,"")}async function Pf(n){try{return await navigator.clipboard.writeText(n),!0}catch{const e=document.activeElement,t=document.createElement("textarea");t.value=n,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();const s=document.execCommand("copy");return document.body.removeChild(t),e instanceof HTMLElement&&e.focus(),s}}function nr(n){const e=V.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(d4,{"data-slot":"dialog",...t}),e[2]=t,e[3]=s):s=e[3],s}function t9(n){const e=V.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(ex,{"data-slot":"dialog-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function g2e(n){const e=V.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(bc,{"data-slot":"dialog-close",...t}),e[2]=t,e[3]=s):s=e[3],s}function n9(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("fixed inset-0 z-50 bg-black/55 duration-150 ease-out data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0 data-closed:duration-100 data-closed:ease-in motion-reduce:animate-none",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(tx,{"data-slot":"dialog-overlay",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function sr(n){const e=V.c(15);let t,s,r,o;e[0]!==n?({className:s,children:t,showCloseButton:o,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);const i=o===void 0?!0:o;let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(n9,{}),e[5]=l):l=e[5];let c;e[6]!==s?(c=G("fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl border bg-popover p-6 text-popover-foreground shadow-lg duration-150 ease-out sm:max-w-lg data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-100 data-closed:ease-in motion-reduce:animate-none",s),e[6]=s,e[7]=c):c=e[7];let u;e[8]!==i?(u=i&&a.jsxs(bc,{className:"absolute top-4 right-4 inline-flex size-7 items-center justify-center rounded-md text-muted-foreground outline-none transition-[color,background-color,transform,scale] duration-100 ease-out hover:bg-accent hover:text-foreground active:scale-90 focus-visible:ring-[3px] focus-visible:ring-ring/20 disabled:pointer-events-none motion-reduce:transition-none motion-reduce:active:scale-100",children:[a.jsx(Mt,{"data-icon":"inline-start",className:"size-4"}),a.jsx("span",{className:"sr-only",children:"Close"})]}),e[8]=i,e[9]=u):u=e[9];let d;return e[10]!==t||e[11]!==r||e[12]!==c||e[13]!==u?(d=a.jsxs(t9,{children:[l,a.jsxs(X1,{"data-slot":"dialog-content",className:c,...r,children:[t,u]})]}),e[10]=t,e[11]=r,e[12]=c,e[13]=u,e[14]=d):d=e[14],d}function io(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex flex-col gap-2 text-center sm:text-left",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"dialog-header",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Px(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"dialog-footer",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function rr(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-lg leading-none font-semibold",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(J1,{"data-slot":"dialog-title",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function or(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-muted-foreground text-sm",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(Q1,{"data-slot":"dialog-description",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function s9(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("label",{"data-slot":"label",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function r9(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("fieldset",{"data-slot":"field-set",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function o9(n){const e=V.c(10);let t,s,r;e[0]!==n?({className:t,variant:r,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);const o=r===void 0?"legend":r;let i;e[4]!==t?(i=G("mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base",t),e[4]=t,e[5]=i):i=e[5];let l;return e[6]!==s||e[7]!==i||e[8]!==o?(l=a.jsx("legend",{"data-slot":"field-legend","data-variant":o,className:i,...s}),e[6]=s,e[7]=i,e[8]=o,e[9]=l):l=e[9],l}function Ta(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("group/field-group @container/field-group flex w-full flex-col gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"field-group",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}const i9=oo("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 fn(n){const e=V.c(11);let t,s,r;e[0]!==n?({className:t,orientation:r,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);const o=r===void 0?"vertical":r;let i;e[4]!==t||e[5]!==o?(i=G(i9({orientation:o}),t),e[4]=t,e[5]=o,e[6]=i):i=e[6];let l;return e[7]!==o||e[8]!==s||e[9]!==i?(l=a.jsx("div",{role:"group","data-slot":"field","data-orientation":o,className:i,...s}),e[7]=o,e[8]=s,e[9]=i,e[10]=l):l=e[10],l}function x2e(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("group/field-content flex flex-1 flex-col gap-0.5 leading-snug",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"field-content",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function mn(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border has-[>[data-slot=field]]:not-has-[:disabled,[data-disabled]]:hover:bg-muted/50 has-[>[data-slot=field]]:has-[:focus-visible]:border-ring has-[>[data-slot=field]]:has-[:focus-visible]:ring-3 has-[>[data-slot=field]]:has-[:focus-visible]:ring-ring/50 *:data-[slot=field]:p-2.5 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10","has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(s9,{"data-slot":"field-label",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function ia(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-left text-sm leading-normal font-normal text-muted-foreground group-data-[orientation=horizontal]/field:text-balance [[data-variant=legend]+&]:-mt-1.5","last:mt-0 nth-last-2:-mt-1","[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("p",{"data-slot":"field-description",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function _o(n){var d;const e=V.c(15);let t,s,r,o;e[0]!==n?({className:s,children:t,errors:r,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);let i;e:{if(t){i=t;break e}if(!(r!=null&&r.length)){i=null;break e}let f;e[5]!==r?(f=[...new Map(r.map(l9)).values()],e[5]=r,e[6]=f):f=e[6];const m=f;if((m==null?void 0:m.length)==1){i=(d=m[0])==null?void 0:d.message;break e}let p;e[7]!==m?(p=a.jsx("ul",{className:"ml-4 flex list-disc flex-col gap-1",children:m.map(a9)}),e[7]=m,e[8]=p):p=e[8],i=p}const l=i;if(!l)return null;let c;e[9]!==s?(c=G("text-sm font-normal text-destructive",s),e[9]=s,e[10]=c):c=e[10];let u;return e[11]!==l||e[12]!==o||e[13]!==c?(u=a.jsx("div",{role:"alert","data-slot":"field-error",className:c,...o,children:l}),e[11]=l,e[12]=o,e[13]=c,e[14]=u):u=e[14],u}function a9(n,e){return(n==null?void 0:n.message)&&a.jsx("li",{children:n.message},e)}function l9(n){return[n==null?void 0:n.message,n]}function On({className:n,...e}){return a.jsx(RP,{"data-slot":"input",className:G("h-8 w-full min-w-0 rounded-lg border border-input bg-background px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",n),...e})}const c9=oo("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 jt({className:n,variant:e,...t}){return a.jsx("div",{"data-slot":"alert",role:"alert",className:G(c9({variant:e}),n),...t})}function tn({className:n,...e}){return a.jsx("div",{"data-slot":"alert-title",className:G("font-medium group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground",n),...e})}function Rt({className:n,...e}){return a.jsx("div",{"data-slot":"alert-description",className:G("text-sm text-balance text-muted-foreground md:text-pretty [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4",n),...e})}function Po({className:n,...e}){return a.jsx("div",{"data-slot":"alert-action",className:G("absolute top-2 right-2",n),...e})}const gN=OP;function xN(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("scroll-my-1 p-1",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(MP,{"data-slot":"select-group",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function bN(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex flex-1 text-left",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(DP,{"data-slot":"select-value",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function vN(n){const e=V.c(13);let t,s,r,o;e[0]!==n?({className:s,size:o,children:t,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);const i=o===void 0?"default":o;let l;e[5]!==s?(l=G("group/select-trigger flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input py-2 pr-2 pl-2.5 text-sm whitespace-nowrap outline-none transition-[color,background-color,border-color,box-shadow,transform,scale] duration-100 ease-out select-none data-pressed:scale-[0.98] focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 motion-reduce:transition-none motion-reduce:data-pressed:scale-100 bg-background hover:bg-accent dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",s),e[5]=s,e[6]=l):l=e[6];let c;e[7]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx(UP,{render:a.jsx(_t,{className:"pointer-events-none size-4 text-muted-foreground transition-transform duration-150 ease-out group-data-popup-open/select-trigger:rotate-180 motion-reduce:transition-none"})}),e[7]=c):c=e[7];let u;return e[8]!==t||e[9]!==r||e[10]!==i||e[11]!==l?(u=a.jsxs(zP,{"data-slot":"select-trigger","data-size":i,className:l,...r,children:[t,c]}),e[8]=t,e[9]=r,e[10]=i,e[11]=l,e[12]=u):u=e[12],u}function yN(n){const e=V.c(26);let t,s,r,o,i,l,c,u;e[0]!==n?({className:s,children:t,side:o,sideOffset:i,align:l,alignOffset:c,alignItemWithTrigger:u,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i,e[6]=l,e[7]=c,e[8]=u):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5],l=e[6],c=e[7],u=e[8]);const d=o===void 0?"bottom":o,f=i===void 0?4:i,m=l===void 0?"center":l,p=c===void 0?0:c,h=u===void 0?!0:u;let g;e[9]!==s?(g=G("relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 ease-out data-[side=none]:animate-none data-[side=bottom]:slide-in-from-top-1 data-[side=inline-end]:slide-in-from-left-1 data-[side=inline-start]:slide-in-from-right-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",s),e[9]=s,e[10]=g):g=e[10];let x;e[11]===Symbol.for("react.memo_cache_sentinel")?(x=a.jsx(u9,{}),e[11]=x):x=e[11];let b;e[12]!==t?(b=a.jsx(BP,{children:t}),e[12]=t,e[13]=b):b=e[13];let w;e[14]===Symbol.for("react.memo_cache_sentinel")?(w=a.jsx(d9,{}),e[14]=w):w=e[14];let v;e[15]!==r||e[16]!==g||e[17]!==b?(v=a.jsxs(LP,{"data-slot":"select-content",className:g,...r,children:[x,b,w]}),e[15]=r,e[16]=g,e[17]=b,e[18]=v):v=e[18];let j;return e[19]!==m||e[20]!==h||e[21]!==p||e[22]!==d||e[23]!==f||e[24]!==v?(j=a.jsx(WP,{children:a.jsx(qP,{side:d,sideOffset:f,align:m,alignOffset:p,alignItemWithTrigger:h,className:"isolate z-50",children:v})}),e[19]=m,e[20]=h,e[21]=p,e[22]=d,e[23]=f,e[24]=v,e[25]=j):j=e[25],j}function jg(n){const e=V.c(13);let t,s,r;e[0]!==n?({className:s,children:t,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);let o;e[4]!==s?(o=G("relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none transition-colors duration-75 focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",s),e[4]=s,e[5]=o):o=e[5];let i;e[6]!==t?(i=a.jsx(VP,{className:"flex flex-1 shrink-0 gap-2 whitespace-nowrap",children:t}),e[6]=t,e[7]=i):i=e[7];let l;e[8]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(HP,{className:"transition-[opacity,transform,scale] duration-100 ease-out motion-safe:data-starting-style:scale-75 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:scale-75 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none",render:a.jsx("span",{className:"pointer-events-none absolute right-2 flex size-4 items-center justify-center"}),children:a.jsx(nn,{className:"pointer-events-none"})}),e[8]=l):l=e[8];let c;return e[9]!==r||e[10]!==o||e[11]!==i?(c=a.jsxs(FP,{"data-slot":"select-item",className:o,...r,children:[i,l]}),e[9]=r,e[10]=o,e[11]=i,e[12]=c):c=e[12],c}function u9(n){const e=V.c(9);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 transition-opacity duration-100 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none [&_svg:not([class*='size-'])]:size-4",t),e[3]=t,e[4]=r):r=e[4];let o;e[5]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(ka,{}),e[5]=o):o=e[5];let i;return e[6]!==s||e[7]!==r?(i=a.jsx(KP,{"data-slot":"select-scroll-up-button",className:r,...s,children:o}),e[6]=s,e[7]=r,e[8]=i):i=e[8],i}function d9(n){const e=V.c(9);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 transition-opacity duration-100 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none [&_svg:not([class*='size-'])]:size-4",t),e[3]=t,e[4]=r):r=e[4];let o;e[5]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(_t,{}),e[5]=o):o=e[5];let i;return e[6]!==s||e[7]!==r?(i=a.jsx(GP,{"data-slot":"select-scroll-down-button",className:r,...s,children:o}),e[6]=s,e[7]=r,e[8]=i):i=e[8],i}function f9({sessionId:n,onOpen:e,open:t,onOpenChange:s}){var E,T,$;const r=y.useMemo(()=>If(n),[n]),o=y.useSyncExternalStore(r.subscribe,r.snapshot),[i,l]=y.useState([]),[c,u]=y.useState(Ys.at(-1)),[d,f]=y.useState(""),[m,p]=y.useState(!1),[h,g]=y.useState(""),[x,b]=y.useState(null),w=y.useRef(null),[v,j]=y.useState(null),[k,_]=y.useState(!t),N=y.useRef(0);y.useEffect(()=>{t&&_(!1)},[t]),y.useEffect(()=>{const A=++N.current,R=new AbortController;return Ce("/api/provider-instances",{signal:R.signal}).then(async P=>{if(P.ok){const z=await P.json();A===N.current&&l(z.instances.filter(L=>!L.retired))}}).catch(()=>{}),()=>{N.current=A+1,R.abort()}},[n]),y.useEffect(()=>{!k||!v||v.epoch!==N.current||(j(null),e(v.dirName,v.fileName))},[k,v,e]);async function S(A){if(!o.conversation)return;const R=N.current,P=i.find(M=>M.id===c),z=o.conversation.binding,L={sessionId:n,expectedRevision:o.conversation.revision,mode:A,agent:A==="resume"?z.agent:(P==null?void 0:P.agent)??c,instanceId:A==="resume"?z.instanceId:(P==null?void 0:P.id)??"default",message:d},I=JSON.stringify(L);(!w.current||w.current.payload!==I)&&(w.current={id:crypto.randomUUID(),payload:I}),p(!0),b(null);try{const M=await Ce("/api/conversation-transition",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...L,commandId:w.current.id})}),F=await M.json();if(R!==N.current)return;if(!M.ok)throw new Error(F.error||"Provider handoff failed");F.dirName&&F.fileName&&j({dirName:F.dirName,fileName:F.fileName,epoch:R}),s(!1),w.current=null}catch(M){R===N.current&&b(M instanceof Error?M.message:"Provider handoff failed")}finally{R===N.current&&p(!1)}}async function C(A=!1){if(!o.pendingTransition||A&&!window.confirm("Confirm you inspected the target provider’s history and no session was created for this handoff. This releases the conversation so you can start a new handoff."))return;const R=N.current;p(!0),b(null);try{const P=await Ce("/api/conversation-transition",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"resolve",sessionId:n,commandId:o.pendingTransition.id,confirmNotCreated:A,targetSessionId:A?void 0:h||o.pendingTransition.sessionId})}),z=await P.json();if(R!==N.current)return;if(!P.ok)throw new Error(z.error||"Handoff reconciliation failed");w.current=null,window.dispatchEvent(new Event("cogpit-command-accepted")),z.dirName&&z.fileName&&e(z.dirName,z.fileName)}catch(P){R===N.current&&b(P instanceof Error?P.message:"Handoff reconciliation failed")}finally{R===N.current&&p(!1)}}return a.jsxs("div",{className:"flex flex-col gap-2 px-3 empty:hidden",children:[o.conversation&&o.conversation.binding.sessionId!==n&&o.currentAddress&&a.jsx(Q,{size:"xs",variant:"outline",onClick:()=>e(o.currentAddress.dirName,o.currentAddress.fileName),children:"Open current conversation session"}),o.pendingTransition&&a.jsx(jt,{children:a.jsxs(Rt,{className:"flex flex-col gap-2",children:[a.jsx("p",{children:"A provider handoff needs reconciliation. Inspect the target provider’s history before choosing a recovery action."}),a.jsx(On,{"aria-label":"Recovered session ID",placeholder:o.pendingTransition.sessionId||"Native session ID found in history",value:h,onChange:A=>g(A.target.value)}),a.jsx(Q,{size:"xs",disabled:m||!(h||o.pendingTransition.sessionId),onClick:()=>void C(),children:"Attach recovered session"}),a.jsx(Q,{size:"xs",variant:"outline",disabled:m,onClick:()=>void C(!0),children:"Confirm no session was created"})]})}),a.jsx(nr,{open:t,onOpenChange:A=>{A&&_(!1),s(A)},onOpenChangeComplete:A=>{_(!A)},children:a.jsxs(sr,{children:[a.jsxs(io,{children:[a.jsx(rr,{children:"Continue this conversation"}),a.jsx(or,{children:"Native resume keeps the current provider and account. Context handoff starts a new native session with up to 12 recent turns and 24,000 characters of text context. Files remain in the same project."})]}),a.jsxs(ia,{children:["Conversation: ",((E=o.conversation)==null?void 0:E.id)||"Loading…"]}),x&&a.jsx(jt,{variant:"destructive",children:a.jsx(Rt,{children:x})}),a.jsxs(Ta,{children:[a.jsxs(fn,{children:[a.jsx(mn,{children:"Target provider or account"}),a.jsxs(gN,{value:c,onValueChange:A=>A&&u(A),children:[a.jsx(vN,{"aria-label":"Handoff provider",children:a.jsx(bN,{children:((T=i.find(A=>A.id===c))==null?void 0:T.label)||(($=Cn(c))==null?void 0:$.displayName)})}),a.jsx(yN,{children:a.jsxs(xN,{children:[Ys.map(A=>a.jsxs(jg,{value:A,children:[Cn(A).displayName," · Default profile"]},A)),i.map(A=>a.jsx(jg,{value:A.id,children:A.label},A.id))]})})]})]}),a.jsxs(fn,{children:[a.jsx(mn,{htmlFor:"handoff-message",children:"Next request"}),a.jsx(On,{id:"handoff-message",value:d,onChange:A=>f(A.target.value)}),a.jsx(ia,{children:"Tool state and permissions are established by the new provider."})]}),a.jsx(Q,{disabled:m||!o.conversation,onClick:()=>void S("handoff"),children:"Start context handoff"}),a.jsx(Q,{variant:"outline",disabled:m||!o.conversation,onClick:()=>void S("resume"),children:"Keep current native session"})]})]})}),!t&&x&&a.jsx(jt,{variant:"destructive",children:a.jsx(Rt,{children:x})})]})}function Py(n){return n.split(/\r?\n/).filter(t=>!t.trimStart().startsWith("[ede_diagnostic]")).join(`
3
3
  `).trim()||"The agent stopped before completing this turn. You can continue the conversation."}function kr(n,e){const t=V.c(8);let s;t[0]!==e||t[1]!==n?(s=()=>{if(typeof window>"u")return e;try{const u=localStorage.getItem(n);return u===null?e:JSON.parse(u)}catch{return e}},t[0]=e,t[1]=n,t[2]=s):s=t[2];const[r,o]=y.useState(s);let i;t[3]!==n?(i=u=>{o(d=>{const f=typeof u=="function"?u(d):u;try{localStorage.setItem(n,JSON.stringify(f))}catch(m){const p=m;console.warn(`useLocalStorage: failed to serialize value for key "${n}"`,p)}return f})},t[3]=n,t[4]=i):i=t[4];const l=i;let c;return t[5]!==l||t[6]!==r?(c=[r,l],t[5]=l,t[6]=r,t[7]=c):c=t[7],c}const m9=oo("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 Fe(n){const e=V.c(13);let t,s,r,o,i;if(e[0]!==n){const{className:u,variant:d,render:f,...m}=n;t=f,i=d===void 0?"default":d,o=m4,s="span",r=f4({className:G(m9({variant:i}),u)},m),e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i}else t=e[1],s=e[2],r=e[3],o=e[4],i=e[5];let l;e[6]!==i?(l={slot:"badge",variant:i},e[6]=i,e[7]=l):l=e[7];let c;return e[8]!==t||e[9]!==s||e[10]!==r||e[11]!==l?(c={defaultTagName:s,props:r,render:t,state:l},e[8]=t,e[9]=s,e[10]=r,e[11]=l,e[12]=c):c=e[12],o(c)}function Id(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 jr(n){const e=Id(n.lastActivityAt);return e!==Number.NEGATIVE_INFINITY?e:Id(n.lastModified)}function $y(n,e){return n===e?0:e-n}function Ry(n){return[n.dirName??"",n.fileName??"",n.sessionId??""].join("/")}function p9(n,e){const t=$y(jr(n),jr(e));if(t!==0)return t;const s=$y(Id(n.lastModified),Id(e.lastModified));return s!==0?s:Ry(n).localeCompare(Ry(e))}function Aa(n){return[...n].sort(p9)}function h9(n,e){var i;const{defaultLimit:t,limits:s,extendedContext:r}=Cn(e).contextWindow,o=n.trim().toLowerCase();return r&&o.includes(r.marker)?r.limit:((i=s.find(l=>o.includes(l.match)))==null?void 0:i.limit)??t}function g9(n,e,t){const s=typeof n.input_tokens=="number"?n.input_tokens:0,r=typeof n.cache_creation_input_tokens=="number"?n.cache_creation_input_tokens:0,o=typeof n.cache_read_input_tokens=="number"?n.cache_read_input_tokens:0,i=s+r+o,l=h9(e,t),c=l-Cn(t).contextWindow.compactBuffer;return{used:i,limit:l,compactAt:c,percent:Math.min(100,i/c*100),percentAbsolute:Math.min(100,i/l*100)}}const x9=["fable","mythos","opus","sonnet","haiku"];function Oy(n){return n.charAt(0).toUpperCase()+n.slice(1)}function ao(n){if(!n)return"unknown";const e=n.toLowerCase(),t=/\[1m\]$/.test(e)?" 1M":"",s=e.replace(/\[[^\]]*\]$/,"");for(const r of x9){const o=s.match(new RegExp(`${r}(?:-(\\d+)(?:-(\\d{1,2}))?(?!\\d))?`));if(!o)continue;const i=o[1]?` ${o[1]}${o[2]?`.${o[2]}`:""}`:"";return`${Oy(r)}${i}${t}`}if(s.startsWith("gpt-")){const[r,...o]=s.slice(4).split("-"),i=o.map(Oy).join(" ");return`GPT-${r}${i?` ${i}`:""}${t}`}return n.length>20?n.slice(0,20)+"...":n}function b9(n){return n.split("/").map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("[\\\\/]")}const v9=new RegExp(`[\\\\/](?:${[...Sc().map(n=>n.projectWorktreeDir),".worktrees"].filter(n=>n!==null).map(b9).join("|")})[\\\\/]([^\\\\/]+)`);function Nr(n){const e=v9.exec(n);return e?{parentPath:n.slice(0,e.index),worktreeName:e[1]}:null}function b2e(n,e){return e===`worktree-${n}`}function gs(n){return Number.isFinite(n)?n<.01?`$${n.toFixed(4)}`:n<1?`$${n.toFixed(3)}`:`$${n.toFixed(2)}`:"—"}function vt(n){return n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}k`:String(n)}function Js(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 wN(n){return n>=1e6?`${(n/1e6).toFixed(1)}MB`:n>=1e3?`${(n/1e3).toFixed(0)}KB`:`${n}B`}function Cr(n){const e=Date.now()-new Date(n).getTime(),t=Math.floor(e/6e4);if(t<1)return"now";if(t<60)return`${t}m`;const s=Math.floor(t/60);if(s<24)return`${s}h`;const r=Math.floor(s/24);return r<7?`${r}d`:new Date(n).toLocaleDateString()}function SN(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 $x(n){if(n.durationMs!==null)return n.durationMs;if(!n.timestamp)return null;let e=0,t=n.timestamp,s="";const r=i=>{i&&i>s&&(s=i)},o=()=>{if(!s)return;const i=new Date(s).getTime()-new Date(t).getTime();i>0&&(e+=i),s=""};for(const i of n.contentBlocks){if(i.kind==="task_notification"){o(),i.timestamp&&(t=i.timestamp);continue}if(r(i.timestamp),i.kind==="tool_calls"||i.kind==="plan_mode")for(const l of i.toolCalls)r(l.timestamp)}return o(),e>0?e:null}function Bs(n,e){return n.length<=e?n:n.slice(0,e)+"..."}function xs(n){return vs(n).dirName.decode(n)??n}function jc(n,e=2){const t=n.replace(/\/+$/,"").split("/").filter(Boolean);return t.length<=e?n:t.slice(-e).join("/")}function _r(n){return n.replace(/\/+$/,"").split("/").at(-1)??n}function $o(n){const e=n.match(/^([^/]+)\/subagents\/agent-([^.]+)\.jsonl$/);return e?{parentSessionId:e[1],agentId:e[2],parentFileName:`${e[1]}.jsonl`}:null}function kN(n){for(let e=n.length-1;e>=0;e--){const t=n[e];if(t.type==="assistant")return g9(t.message.usage,t.message.model??"","claude")}return null}function pi(n,e){return e||Bs(NN(n),50)}const y9="Untitled session";function jN(n,e){const t=n.teamName&&n.agentName?n.agentName:"";return e||n.customTitle||n.aiTitle||t||n.lastUserMessage||n.firstUserMessage||n.slug||void 0}function NN(n,e){return jN(n,e)??y9}function w9(n,e){return jN(n,e)===void 0}function S9(n){const e=new Set(n.map(r=>r.sessionId)),t=new Map,s=[];for(const r of n){const o=r.teamLeadSessionId;if(o&&o!==r.sessionId&&e.has(o)){const i=t.get(o);i?i.push(r):t.set(o,[r])}else s.push(r)}return{topLevelSessions:s,teammatesByLead:t}}function k9(n){return n.find(e=>!Nr(e.cwd??xs(e.dirName)))??n[0]}const j9="Unknown project";function Rx(n){const e=Nr(n);return jc(e?e.parentPath:n,2)||j9}function Nl(n){return Rx(n.cwd||xs(n.dirName))}function Ox(n){return n==="inactive"?"Archived after two weeks without activity":"Archived"}function N9(n,e){return e?n:n.filter(t=>!t.archived)}function C9(n){const e=Aa(n),t=new Map;for(const s of e){const r=Nl(s),o=t.get(r);o?o.push(s):t.set(r,[s])}return t}function Lx(n,e){return n.isActive?!0:e?n.agentStatus!=="completed":!1}const $f=new Set(["thinking","tool_use","processing","compacting","awaiting_agents"]),_9=12e4;function CN(n,e=Date.now()){const t=Date.parse(n.lastActivityAt||n.lastModified);return Number.isFinite(t)&&e-t<_9}function Mx(n,e,t=Date.now()){return Lx(n,e.get(n.sessionId))?!0:n.agentStatus==="completed"||!n.agentStatus?!1:CN(n,t)}function E9(n,e,t=Date.now()){return n.some(s=>Mx(s,e,t))}const T9={awaitingPermission:new Set,awaitingQuestion:new Set,awaitingPrompt:new Set,awaitingPlan:new Set};function zx(n){var o,i;const e=new Map(n.map(l=>[l.sessionId,l])),t=l=>{const c=e.get(l);return c!==void 0&&!c.archived},s=[],r=new Map;for(const l of n){const c=l.crew;if(!c){s.push(l);continue}const u=[];let d=c.parentId;for(;d&&d!==l.sessionId&&e.has(d)&&!u.includes(d);)u.push(d),d=(i=(o=e.get(d))==null?void 0:o.crew)==null?void 0:i.parentId;c.hostId&&c.hostId!==l.sessionId&&!u.includes(c.hostId)&&u.push(c.hostId),c.rootId!==l.sessionId&&!u.includes(c.rootId)&&u.push(c.rootId);const f=[...u].reverse().find(t);if(!f){s.push(l);continue}const m=r.get(f);m?m.push(l):r.set(f,[l])}for(const l of r.values())l.sort((c,u)=>{var d,f;return(((d=c.crew)==null?void 0:d.startedAt)??0)-(((f=u.crew)==null?void 0:f.startedAt)??0)});return{topLevel:s,crewOf:r}}function _N(n,e,t){const s=n.sessionId;return t.awaitingPermission.has(s)?{state:"needs-you",need:"permission"}:t.awaitingQuestion.has(s)?{state:"needs-you",need:"question"}:t.awaitingPrompt.has(s)?{state:"needs-you",need:"input"}:t.awaitingPlan.has(s)?{state:"needs-you",need:"plan"}:n.agentStatus==="deferred"?{state:"needs-you",need:"deferred"}:{state:Mx(n,e)&&(!n.agentStatus||$f.has(n.agentStatus))?"working":"done"}}function Dx(n,e){const t={size:n.length,needsYou:0,working:0,done:0};let s;for(const r of n){const{state:o}=e(r);o==="needs-you"?(t.needsYou++,(!s||jr(r)<jr(s))&&(s=r)):o==="working"?t.working++:t.done++}return s&&(t.longestWaitSince=s.lastActivityAt||s.lastModified),t}function Ly(n,e){const t=e.reduce((s,r)=>jr(r)>jr(s)?r:s,n);return t.lastActivityAt||t.lastModified}function My(n){var e;return((e=n==null?void 0:n.cwd)==null?void 0:e.replace(/\/+$/,"").split("/").at(-1))||void 0}function Pd(n,{customName:e,parent:t}){var r;if(e)return e;if((r=n.crew)!=null&&r.name)return n.crew.name;if(n.customTitle)return n.customTitle;const s=My(n);return s&&s!==My(t)?s:A9(n.firstUserMessage)??pi(n)}const zy=60;function A9(n){const e=n==null?void 0:n.split(`
4
4
  `).map(t=>t.replace(/^#+\s*/,"").trim()).find(Boolean);if(e)return e.length>zy?`${e.slice(0,zy-1)}…`:e}function I9(n,e){return e.filter(t=>{var s;return((s=t.crew)==null?void 0:s.parentId)===n}).length}function $d(n,e,t){const s=e.get(n);if(!s)return;const r=t[n];return s.crew?Pd(s,{customName:r,parent:e.get(s.crew.parentId)}):pi(s,r)}const P9={capabilities:_x,user:{edition:"personal",user:null,hubUser:null,enforcesSessionAccess:!1},gate:null},EN={capabilities:Ea,user:{edition:null,user:null,hubUser:null,enforcesSessionAccess:null},gate:null};let TN=P9,Ng=null;const Cg=new Set;function Cl(n,e=(n==null?void 0:n.user)??null){TN=n?{capabilities:n.capabilities,user:{edition:n.edition,user:n.user,hubUser:e,enforcesSessionAccess:n.enforcesSessionAccess===!0},gate:n.gate??null}:EN,Ng=cn();for(const t of Cg)t()}function Fx(){return Ng===null||Ng===cn()?TN:EN}function xt(n){const{capabilities:e}=Fx();return Object.hasOwn(e,n)&&e[n]===!0}function Rd(){return Fx().user}function Dy(){return Fx().gate}function Rf(n){return Cg.add(n),()=>Cg.delete(n)}function AN(){return y.useSyncExternalStore(Rf,Rd,Rd)}function IN(){return y.useSyncExternalStore(Rf,Dy,Dy)}function Ux(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function $9(n){return Ux(n)?n:null}const R9="cogpit:session-list-cache",O9=10080*60*1e3,L9=24,Ql={projects:"projects",activeSessions:"active-sessions",runningProcesses:"running-processes"};function PN(n,e){return e===null?n:`${n}:${e}`}function td(n){return PN(Ql.activeSessions,n)}const Od=new Map;function M9(){return{version:1,entries:{}}}function Of(){return Td()==="account"&&Zn()===null?null:sn(R9)}function Bx(n){const e=Od.get(n);if(e)return e;let t=M9();try{const s=localStorage.getItem(n);if(s){const r=JSON.parse(s);r.version===1&&r.entries&&typeof r.entries=="object"&&(t=r)}}catch{}return Od.set(n,t),t}function $N(n,e){Od.set(n,e);try{localStorage.setItem(n,JSON.stringify(e))}catch{}}function RN(n){const e=Of(),t=e===null?void 0:Bx(e).entries[n];if(!(!t||Date.now()-t.savedAt>O9))return t.value}function ON(n,e){const t=Of();if(t===null)return;const s={...Bx(t).entries,[n]:{savedAt:Date.now(),value:e}},r=Object.entries(s).sort(([,o],[,i])=>i.savedAt-o.savedAt);$N(t,{version:1,entries:Object.fromEntries(r.slice(0,L9))})}function LN(n){return Ux(n)&&Array.isArray(n.sessions)&&typeof n.total=="number"}function Fy(n,e){return n.filter(t=>!(Ux(t)&&t.sessionId===e))}function z9(n,e){if(Array.isArray(n)){const r=Fy(n,e);return r.length===n.length?n:r}if(!LN(n))return n;const t=Fy(n.sessions,e),s=n.sessions.length-t.length;return s===0?n:{sessions:t,total:n.total-s}}function Gi(n){const e=RN(n);return Array.isArray(e)?e:void 0}function _l(n,e){ON(n,e)}function MN(n,e){return PN(`sessions:${n}`,e)}function D9(n,e){const t=RN(MN(n,e));return LN(t)?t:void 0}function F9(n,e,t){ON(MN(n,e),t)}function U9(n){const e=Of();if(e===null)return;const t=Bx(e);let s=!1;const r={};for(const[o,i]of Object.entries(t.entries)){const l=z9(i.value,n);s||(s=l!==i.value),r[o]=l===i.value?i:{...i,value:l}}s&&$N(e,{version:1,entries:r})}function B9(){const n=Of();if(n!==null){Od.delete(n);try{localStorage.removeItem(n)}catch{}}}const W9=Object.freeze({});let Nc=W9,Ia="idle";const _g=new Set;function Lf(n,e){Nc=n,Ia=e;for(const t of _g)t()}function Eg(){return Nc}function ec(){return Ia}function Wx(n){return _g.add(n),()=>_g.delete(n)}function q9(n){if(Ia==="installed")throw new Error(`An edition UI is already installed; ${n.edition} cannot replace it`);Lf(n.ui,"installed")}function V9(){Ia!=="installed"&&Lf(Nc,"loading")}function H9(){Ia!=="installed"&&Lf(Nc,"unavailable")}function K9(){Ia!=="installed"&&Lf(Nc,"failed")}const G9=[],Uy=new WeakMap;function By(){const n=Rd();let e=Uy.get(n);return e||(e={...n,can:xt},Uy.set(n,e)),e}function $r(){return y.useSyncExternalStore(Wx,Eg,Eg)}function Wy(){return ec()==="unavailable"}function Z9(){return y.useSyncExternalStore(Wx,Wy,Wy)}function Y9(){return y.useSyncExternalStore(Rf,By,By)}function qx(){const n=V.c(5),{mainViews:e}=$r(),t=e===void 0?G9:e,s=Y9();let r;if(n[0]!==s||n[1]!==t){let o;n[3]!==s?(o=i=>i.isAvailable(s),n[3]=s,n[4]=o):o=n[4],r=t.filter(o),n[0]=s,n[1]=t,n[2]=r}else r=n[2];return r}function zN(n){const e=V.c(3),t=qx();let s;return e[0]!==n||e[1]!==t?(s=n===null?null:t.find(r=>r.id===n)??null,e[0]=n,e[1]=t,e[2]=s):s=e[2],s}const X9=Object.freeze({key:null,query:Object.freeze({})});function J9(){return()=>{}}function Q9(){return null}function Mf(){const n=V.c(7),{sessionListFilter:e}=$r();let t;n[0]!==e?(t=c=>(e==null?void 0:e.subscribe(c))??J9(),n[0]=e,n[1]=t):t=n[1];const s=t;let r;n[2]!==e?(r=e?()=>e.getKey():Q9,n[2]=e,n[3]=r):r=n[3];const o=r,i=y.useSyncExternalStore(s,o,o);let l;return n[4]!==i||n[5]!==e?(l=e&&i!==null?{key:i,query:e.getQuery()}:X9,n[4]=i,n[5]=e,n[6]=l):l=n[6],l}function El(n,e,t={}){const s=new URLSearchParams(t);for(const[o,i]of Object.entries(e.query))s.set(o,i);const r=s.toString();return r?`${n}?${r}`:n}function zf(n,e){return El("/api/active-sessions",e,n)}async function zs(n){try{const e=await(n==null?void 0:n.json());return e&&typeof e=="object"?e:null}catch{return null}}async function Tl(n,e){const t=await zs(n);return typeof(t==null?void 0:t.error)=="string"&&t.error?t.error:e}const eO=["view","interact","own"],tO=1e3,nO=3e4,Ld=new Map,DN=new Set,nd=new Map,hi=new Set,Tg=new Set;let qy=0;function Vo(n){return`${sn("session-access")}::${n}`}function Pa(n){for(const e of n)e()}function Cc(n,e,t){e!=="none"&&DN.add(n);const s=Ld.get(n);return s&&s.ticket>t?!1:(Ld.set(n,{level:e,ticket:t}),(s==null?void 0:s.level)!==e)}function sO(n){return eO.includes(n==null?void 0:n.level)}function rO(n){var e;return(e=Ld.get(Vo(n)))==null?void 0:e.level}function oO(n){return DN.has(Vo(n))}function iO(n){return hi.add(n),()=>hi.delete(n)}function Xr(){return qy+=1,qy}function aa(n,e){let t=!1;for(const{sessionId:s,access:r}of n)r&&(t=Cc(Vo(s),r.level,e)||t);t&&Pa(hi)}async function aO(n){let e;try{e=await Ce(`${gR}${encodeURIComponent(n)}`)}catch{return null}if(e.status===404&&aN(e))return"none";if(!e.ok)return null;const t=await zs(e);return sO(t)?t.level:null}async function lO(n,e){var r;const t=Xr(),s=await aO(n);return s===null?null:(Cc(e,s,t)&&Pa(hi),((r=Ld.get(e))==null?void 0:r.level)??null)}function FN(n){const e=Vo(n),t=lO(n,e).finally(()=>{nd.get(e)===t&&nd.delete(e)});return nd.set(e,t),t}function Vy(n){return nd.get(Vo(n))??FN(n)}function v2e(n,e,t){Cc(Vo(n),e,t)&&Pa(hi)}function cO(n){Cc(Vo(n),"none",Xr())&&Pa(hi)}function UN(n){const{enforcesSessionAccess:e,user:t}=Rd();!e||!t||Cc(Vo(n),"own",Xr())&&Pa(hi)}function BN(){Pa(Tg)}function Df(n){return Tg.add(n),()=>Tg.delete(n)}function uO(n){let e=!1,t=0,s=0,r;async function o(l){const c=++s;clearTimeout(r);const u=await l();if(e||c!==s)return;if(u){t=0;return}const d=Math.min(tO*2**t,nO);t+=1,r=setTimeout(()=>void o(()=>Vy(n)),d)}o(()=>Vy(n));const i=lN(()=>{t=0,o(()=>FN(n))},n);return()=>{e=!0,clearTimeout(r),i()}}const dO=2e4;function fO(n){const e=new Map;for(const t of n){if(!t.sessionId)continue;const s=e.get(t.sessionId);(!s||t.memMB>s.memMB)&&e.set(t.sessionId,t)}return e}function Hy(n,e){let t=null;for(const s of e){const r=!!s.archived;n.has(s.sessionId)!==r&&(t??(t=new Set(n)),r?t.add(s.sessionId):t.delete(s.sessionId))}return t??n}const WN=y.createContext(null);function mO({children:n}){const[e]=y.useState(cn),t=Mf(),s=IN()!==null,r=td(t.key),[o,i]=y.useState(()=>Gi(r)??[]),[l,c]=y.useState(()=>Gi(Ql.runningProcesses)??[]),[u,d]=y.useState(!1),[f,m]=y.useState(null),[p,h]=y.useState(new Set),[g,x]=kr(sn("live-sessions-show-archived"),!1),b=g===!0,[w,v]=y.useState(!1),j=b||w,[k,_]=y.useState(0),N=y.useRef(Hy(new Set,o)),[S,C]=y.useState(N.current),E=y.useCallback(H=>{N.current=H,C(H)},[]),T=y.useRef(null),$=y.useRef(!1),A=y.useRef(o),R=y.useRef(r),P=y.useRef(null),z=y.useRef(!1);y.useEffect(()=>(z.current=!0,()=>{var H;z.current=!1,(H=P.current)==null||H.abort(),P.current=null}),[]);const L=y.useCallback(async()=>{var Y;if(s||!z.current||cn()!==e)return;(Y=P.current)==null||Y.abort();const H=new AbortController;P.current=H;const K=()=>z.current&&!H.signal.aborted&&P.current===H&&cn()===e;d(!0);const Z=Xr();try{const[X,ee]=await Promise.all([Ce(zf(j?{archived:"include"}:{},t),{signal:H.signal}),Ce("/api/running-processes",{signal:H.signal})]);if(!K())return;if(!X.ok||!ee.ok)throw new Error("Failed to fetch live data");const[te,se]=await Promise.all([X.json(),ee.json()]);if(!K())return;const J=Array.isArray(te)?te:[],ne=Array.isArray(se)?se:[];aa(J,Z),$.current&&($.current=!1,T.current=null),A.current=J,i(J),c(ne),E(Hy(N.current,J)),_(Number(X.headers.get("X-Cogpit-Archived-Count"))||0),_l(r,J),_l(Ql.runningProcesses,ne),m(null)}catch(X){if(!K())return;m(X instanceof Error?X.message:"Failed to load data")}finally{K()&&d(!1),P.current===H&&(P.current=null)}},[s,e,j,t,r,E]),I=y.useCallback(()=>{L()},[L]);y.useEffect(()=>{if(R.current===r)return;R.current=r,$.current=!0;const H=Gi(r)??[];A.current=H,i(H)},[r]),y.useEffect(()=>{I()},[I]),y.useEffect(()=>Df(()=>{$.current=!0,I()}),[I]);const M=y.useMemo(()=>fO(l),[l]),F=y.useMemo(()=>E9(o,M),[o,M]);y.useEffect(()=>(window.addEventListener("focus",I),()=>window.removeEventListener("focus",I)),[I]),y.useEffect(()=>{if(!F)return;const H=setInterval(()=>{document.visibilityState==="visible"&&I()},dO);return()=>clearInterval(H)},[F,I]),y.useEffect(()=>{if(o.length===0||$.current)return;const H=T.current,K=new Map;for(const Z of o)Z.agentStatus&&M.has(Z.sessionId)&&K.set(Z.sessionId,Z.agentStatus);H!==null&&h(Z=>{let Y=null;for(const[X,ee]of K)ee==="completed"&&H.has(X)&&H.get(X)!=="completed"&&(Y??(Y=new Set(Z)),Y.add(X));for(const X of Z)K.get(X)!=="completed"&&(Y??(Y=new Set(Z)),Y.delete(X));return Y??Z}),T.current=K},[o,M]);const U=y.useCallback(H=>{h(K=>{if(!K.has(H))return K;const Z=new Set(K);return Z.delete(H),Z})},[]),O=y.useCallback(H=>{A.current=H,i(H),cn()===e&&_l(r,H)},[e,r]),D=y.useCallback(H=>{O(A.current.filter(K=>K.sessionId!==H))},[O]),B=y.useCallback((H,K)=>{const Z=N.current,Y=new Set(H.filter(te=>Z.has(te)!==K));if(Y.size===0)return;const X=new Set(Z);for(const te of Y)K?X.add(te):X.delete(te);E(X),O(A.current.map(te=>{if(!Y.has(te.sessionId))return te;if(K)return{...te,archived:!0,archivedReason:"manual"};const{archived:se,archivedReason:J,...ne}=te;return ne}));const ee=K?Y.size:-Y.size;_(te=>Math.max(0,te+ee))},[E,O]),q=y.useCallback(H=>S.has(H),[S]),W=y.useMemo(()=>({sessions:o,processes:l,procBySession:M,newlyCompleted:p,loading:u,error:f,refresh:I,removeSession:D,acknowledgeCompleted:U,showArchived:b,setShowArchived:x,setSearchActive:v,archivedCount:k,isArchived:q,setArchived:B}),[o,l,M,p,u,f,I,D,U,b,x,k,q,B]);return a.jsx(WN.Provider,{value:W,children:n})}function Vx(){const n=ir();if(!n)throw new Error("useSessionInventory must be used within a SessionInventoryProvider");return n}function ir(){return y.useContext(WN)}function qN(n){function e(){try{const i=localStorage.getItem(sn(n));return i?JSON.parse(i):{}}catch{return{}}}let t=e();const s=new Set;function r(){for(const i of s)i()}function o(){t=e(),r()}return typeof window<"u"&&(window.addEventListener("cogpit-device-changed",o),window.addEventListener("cogpit-identity-changed",o)),{subscribe:i=>(s.add(i),()=>{s.delete(i)}),getSnapshot:()=>t,rename:(i,l)=>{const c={...t},u=l.trim();u?c[i]=u:delete c[i],localStorage.setItem(sn(n),JSON.stringify(c)),t=c,r()}}}const Ag=qN("session-custom-names"),VN=Ag.rename;function Ff(){const n=V.c(2),e=y.useSyncExternalStore(Ag.subscribe,Ag.getSnapshot);let t;return n[0]!==e?(t={names:e,rename:VN},n[0]=e,n[1]=t):t=n[1],t}function $a(){const n=V.c(5),e=ir(),{names:t}=Ff();e==null||e.sessions;let s;n[0]!==(e==null?void 0:e.sessions)?(s=new Map(((e==null?void 0:e.sessions)??[]).map(pO)),n[0]=e==null?void 0:e.sessions,n[1]=s):s=n[1];const r=s;let o;return n[2]!==r||n[3]!==t?(o=i=>$d(i,r,t),n[2]=r,n[3]=t,n[4]=o):o=n[4],o}function pO(n){return[n.sessionId,n]}const hO=/\x1b\].*?(?:\x07|\x1b\\)/g,gO=/\x1b\[[0-9;]*[A-Za-z]/g,xO=/\x1b[()][AB012]/g,bO=/\[2K\[1G/g;function HN(n){return n.replace(hO,"").replace(gO,"").replace(xO,"").replace(bO,`
@@ -67,7 +67,7 @@ ${t.join(`
67
67
 
68
68
  `)}return x.write("payload.value = newResult;"),x.write("return payload;"),x.compile()};let i;const l=nc,c=!Qs.jitless,d=c&&tD.value,f=e.catchall;let m;n._zod.parse=(p,h)=>{m??(m=s.value);const g=p.value;return l(g)?c&&d&&(h==null?void 0:h.async)===!1&&h.jitless!==!0?(i||(i=o(e.shape)),p=i(p,h),f?sC([],g,p,h,m,n,(h==null?void 0:h.abortEarly)===!0):p):t(p,h):(p.issues.push({expected:"object",code:"invalid_type",input:g,inst:n}),p)}});function S2(n,e,t,s){for(const o of n)if(o.issues.length===0)return e.value=o.value,e;const r=n.filter(o=>!Vr(o));return r.length===1?(e.value=r[0].value,r[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:t,errors:n.map(o=>o.issues.map(i=>Oo(i,s,Er())))}),e)}const rC=pe("$ZodUnion",(n,e)=>{Bt.init(n,e),wt(n,"optin",s=>s.def.options.some(r=>r._zod.optin==="defaulted")?"defaulted":s.def.options.some(r=>r._zod.optin!==void 0)?"optional":void 0),wt(n,"optout",s=>s.def.options.some(r=>r._zod.optout==="optional")?"optional":void 0),wt(n,"values",s=>{if(s.def.options.every(r=>r._zod.values))return new Set(s.def.options.flatMap(r=>Array.from(r._zod.values)))}),wt(n,"pattern",s=>{if(s.def.options.every(r=>r._zod.pattern)){const r=s.def.options.map(o=>o._zod.pattern);return new RegExp(`^(${r.map(o=>a0(o.source)).join("|")})$`)}});const t=e.options.length===1?e.options[0]._zod.run:null;n._zod.parse=(s,r)=>{if(t)return t(s,r);let o=!1;const i=[];for(const l of e.options){const c=l._zod.run({value:s.value,issues:[]},r);if(c instanceof Promise)i.push(c),o=!0;else{if(c.issues.length===0)return c;i.push(c)}}return o?Promise.all(i).then(l=>S2(l,s,n,r)):S2(i,s,n,r)}});function kU(n){var t;const e=new Map;for(const s of n.options){const r=(t=s._zod.propValues)==null?void 0:t[n.discriminator];if(!r||r.size===0)throw new Error(`Invalid discriminated union option at index "${n.options.indexOf(s)}"`);for(const o of r)if(e.has(o)){if(o!==void 0)throw new Error(`Duplicate discriminator value "${String(o)}"`);e.set(o,null)}else e.set(o,s)}return e}const jU=pe("$ZodDiscriminatedUnion",(n,e)=>{e.inclusive=!1,rC.init(n,e);const t=n._zod.parse;wt(n,"propValues",r=>{var l,c;const o={};let i=0;for(const u of r.def.options){const d=u._zod.propValues;if(!d||Object.keys(d).length===0)throw new Error(`Invalid discriminated union option at index "${r.def.options.indexOf(u)}"`);(l=d[r.def.discriminator])!=null&&l.has(void 0)&&i++;for(const[f,m]of Object.entries(d)){Object.prototype.hasOwnProperty.call(o,f)||lo(o,f,new Set);for(const p of m)o[f].add(p)}}return!r.def.unionFallback&&i>1&&((c=o[r.def.discriminator])==null||c.delete(void 0)),o}),e.options.forEach((r,o)=>{const i=l0(r._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,e.discriminator))throw new Error(`Invalid discriminated union option at index "${o}"`)});const s=Vf(()=>kU(e));n._zod.parse=(r,o)=>{const i=r.value;if(!nc(i))return r.issues.push({code:"invalid_type",expected:"object",input:i,inst:n}),r;const l=i==null?void 0:i[e.discriminator],c=s.value.get(l);return c&&(l!==void 0||o.direction!=="backward")?c._zod.run(r,o):e.unionFallback||o.direction==="backward"?t(r,o):(r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:e.discriminator,options:Array.from(s.value.keys()).filter(u=>s.value.get(u)!==null),input:i,path:[e.discriminator],inst:n}),r)}}),NU=pe("$ZodIntersection",(n,e)=>{Bt.init(n,e),n._zod.parse=(t,s)=>{const r=t.value,o=e.left._zod.run({value:r,issues:[]},s),i=e.right._zod.run({value:r,issues:[]},s);return o instanceof Promise||i instanceof Promise?Promise.all([o,i]).then(([c,u])=>k2(t,c,u)):k2(t,o,i)}});function Ug(n,e){if(n===e)return{valid:!0,data:n};if(n instanceof Date&&e instanceof Date&&+n==+e)return{valid:!0,data:n};if(ca(n)&&ca(e)){const t=Object.keys(e),s=Object.keys(n).filter(o=>t.indexOf(o)!==-1),r={...n,...e};Object.prototype.hasOwnProperty.call(r,"__proto__")&&delete r.__proto__;for(const o of s){if(o==="__proto__")continue;const i=Ug(n[o],e[o]);if(!i.valid)return{valid:!1,mergeErrorPath:[o,...i.mergeErrorPath]};r[o]=i.data}return{valid:!0,data:r}}if(Array.isArray(n)&&Array.isArray(e)){if(n.length!==e.length)return{valid:!1,mergeErrorPath:[]};const t=[];for(let s=0;s<n.length;s++){const r=n[s],o=e[s],i=Ug(r,o);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};t.push(i.data)}return{valid:!0,data:t}}return{valid:!1,mergeErrorPath:[]}}function k2(n,e,t){const s=new Map;let r;const o=new Map,i=(u,d)=>{var m,p;let f;if(u.code==="unrecognized_keys"&&!((m=u.path)!=null&&m.length))r??(r=u),f=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&((p=u.path)==null?void 0:p.length)===1){const h=String(u.path[0]);o.has(h)||o.set(h,u),f=[h]}else return!1;for(const h of f)s.has(h)||s.set(h,{}),s.get(h)[d]=!0;return!0};for(const u of e.issues)i(u,"l")||n.issues.push(u);for(const u of t.issues)i(u,"r")||n.issues.push(u);const l=[...s].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(l.length){const u=r?l.filter(d=>r.keys.includes(d)):[];u.length&&n.issues.push({...r,keys:u});for(const d of l)!u.includes(d)&&o.has(d)&&n.issues.push(o.get(d))}const c=Ug(e.value,t.value);if(!c.valid){if(Vr(n))return n;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return n.value=c.data,n}const CU=pe("$ZodRecord",(n,e)=>{Bt.init(n,e);const t=Qs.memoizer;t==null||t.attach(n),n._zod.parse=(s,r)=>{const o=s.value;if(!ca(o))return s.issues.push({expected:"record",code:"invalid_type",input:o,inst:n}),s;const i=[],l=e.keyType._zod.values;if(l&&!e.partial){s.value=t?t.alloc(n,s,{},r):{};const c=new Set;for(const d of l)if(typeof d=="string"||typeof d=="number"||typeof d=="symbol"){if(c.add(typeof d=="number"?d.toString():d),d==="__proto__")continue;const f=e.keyType._zod.run({value:d,issues:[]},r);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(f.issues.length){s.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map(h=>Oo(h,r,Er())),input:d,path:[d],inst:n});continue}const m=f.value;if(m==="__proto__")continue;const p=e.valueType._zod.run({value:o[d],issues:[]},r);p instanceof Promise?i.push(p.then(h=>{h.issues.length&&s.issues.push(...Wi(d,h.issues)),s.value[m]=h.value})):(p.issues.length&&s.issues.push(...Wi(d,p.issues)),s.value[m]=p.value)}let u;for(const d in o)if(!c.has(d))if(e.mode==="loose"){if(d==="__proto__")continue;s.value[d]=o[d]}else u=u??[],u.push(d);u&&u.length>0&&s.issues.push({code:"unrecognized_keys",input:o,inst:n,keys:u,continue:!0})}else{s.value=t?t.alloc(n,s,{},r):{};let c;for(const u of Reflect.ownKeys(o)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(o,u))continue;let d=e.keyType._zod.run({value:u,issues:[]},r);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&h0.test(u)&&d.issues.length){const h=e.keyType._zod.run({value:Number(u),issues:[]},r);if(h instanceof Promise)throw new Error("Async schemas not supported in object keys currently");h.issues.length===0&&(d=h)}if(d.issues.length){e.mode==="loose"?s.value[u]=o[u]:l?(c=c??[],c.push(u)):s.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(h=>Oo(h,r,Er())),input:u,path:[u],inst:n});continue}const m=d.value;if(m==="__proto__")continue;const p=e.valueType._zod.run({value:o[u],issues:[]},r);p instanceof Promise?i.push(p.then(h=>{h.issues.length&&s.issues.push(...Wi(u,h.issues)),s.value[m]=h.value})):(p.issues.length&&s.issues.push(...Wi(u,p.issues)),s.value[m]=p.value)}c&&c.length>0&&s.issues.push({code:"unrecognized_keys",input:o,inst:n,keys:c,continue:!0})}return i.length?Promise.all(i).then(()=>s):s}}),_U=pe("$ZodEnum",(n,e)=>{Bt.init(n,e);const t=Mg(e.entries),s=new Set(t);n._zod.values=s,wt(n,"pattern",r=>{const o=Mg(r.def.entries).filter(i=>nD.has(typeof i));return new RegExp(o.length?`^(${o.map(i=>ua(i.toString())).join("|")})$`:"^[^\\s\\S]$")}),n._zod.parse=(r,o)=>{const i=r.value;return s.has(i)||r.issues.push({code:"invalid_value",values:t,input:i,inst:n}),r}}),EU=pe("$ZodLiteral",(n,e)=>{Bt.init(n,e);const t=new Set(e.values);n._zod.values=t,wt(n,"pattern",s=>{const r=s.def.values;return new RegExp(r.length?`^(${r.map(o=>typeof o=="string"?ua(o):o?ua(o.toString()):String(o)).join("|")})$`:"^[^\\s\\S]$")}),n._zod.parse=(s,r)=>{const o=s.value;return t.has(o)||s.issues.push({code:"invalid_value",values:e.values,input:o,inst:n}),s}}),TU=pe("$ZodTransform",(n,e)=>{var t;Bt.init(n,e),n._zod.optin="optional",(t=Qs.memoizer)==null||t.guard(n),n._zod.parse=(s,r)=>{if(r.direction==="backward")throw new W5(n.constructor.name);const o=e.transform(s.value,s);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(l=>(s.value=l,s));if(o instanceof Promise)throw new di;return s.value=o,s}});function j2(n,e){return n.value=e.issues.length?void 0:e.value,n}const oC=pe("$ZodOptional",(n,e)=>{Bt.init(n,e),wt(n,"optin",t=>t.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),n._zod.optout="optional",wt(n,"values",t=>{const s=t.def.innerType._zod.values;return s?new Set([...s,void 0]):void 0}),wt(n,"pattern",t=>{const s=t.def.innerType._zod.pattern;return s?new RegExp(`^(${a0(s.source)})?$`):void 0}),n._zod.parse=(t,s)=>{if(t.value===void 0){if(e.innerType._zod.optin!=="defaulted")return t;const r=e.innerType._zod.run({value:t.value,issues:[]},s);return r instanceof Promise?r.then(o=>j2(t,o)):j2(t,r)}return e.innerType._zod.run(t,s)}}),AU=pe("$ZodExactOptional",(n,e)=>{oC.init(n,e),wt(n,"values",t=>t.def.innerType._zod.values),wt(n,"pattern",t=>t.def.innerType._zod.pattern),n._zod.parse=(t,s)=>e.innerType._zod.run(t,s)}),IU=pe("$ZodNullable",(n,e)=>{Bt.init(n,e),wt(n,"optin",t=>t.def.innerType._zod.optin),wt(n,"optout",t=>t.def.innerType._zod.optout),wt(n,"pattern",t=>{const s=t.def.innerType._zod.pattern;return s?new RegExp(`^(${a0(s.source)}|null)$`):void 0}),wt(n,"values",t=>t.def.innerType._zod.values?new Set([...t.def.innerType._zod.values,null]):void 0),n._zod.parse=(t,s)=>t.value===null?t:e.innerType._zod.run(t,s)}),PU=pe("$ZodDefault",(n,e)=>{Bt.init(n,e),n._zod.optin="defaulted",wt(n,"values",t=>t.def.innerType._zod.values),n._zod.parse=(t,s)=>{if(s.direction==="backward")return e.innerType._zod.run(t,s);if(t.value===void 0)return t.value=e.defaultValue,t;const r=e.innerType._zod.run(t,s);return r instanceof Promise?r.then(o=>N2(o,e)):N2(r,e)}});function N2(n,e){return n.value===void 0&&(n.value=e.defaultValue),n}const $U=pe("$ZodPrefault",(n,e)=>{Bt.init(n,e),n._zod.optin="defaulted",wt(n,"values",t=>t.def.innerType._zod.values),n._zod.parse=(t,s)=>(s.direction==="backward"||t.value===void 0&&(t.value=e.defaultValue),e.innerType._zod.run(t,s))}),RU=pe("$ZodNonOptional",(n,e)=>{Bt.init(n,e),wt(n,"values",t=>{const s=t.def.innerType._zod.values;return s?new Set([...s].filter(r=>r!==void 0)):void 0}),n._zod.parse=(t,s)=>{const r=e.innerType._zod.run(t,s);return r instanceof Promise?r.then(o=>C2(o,n)):C2(r,n)}});function C2(n,e){return!n.issues.length&&n.value===void 0&&n.issues.push({code:"invalid_type",expected:"nonoptional",input:n.value,inst:e}),n}function _2(n,e,t,s){return e.issues.length?(n.value=t.catchValue({...e,value:n.value,error:{issues:e.issues.map(r=>Oo(r,s,Er()))},input:n.value}),n):(n.value=e.value,e.memo&&(n.memo=!0),n)}const OU=pe("$ZodCatch",(n,e)=>{Bt.init(n,e),wt(n,"optin",t=>t.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),wt(n,"optout",t=>t.def.innerType._zod.optout),wt(n,"values",t=>t.def.innerType._zod.values),n._zod.parse=(t,s)=>{if(s.direction==="backward")return e.innerType._zod.run(t,s);const r=e.innerType._zod.run({value:t.value,issues:[]},s);return r instanceof Promise?r.then(o=>_2(t,o,e,s)):_2(t,r,e,s)}}),LU=pe("$ZodPipe",(n,e)=>{Bt.init(n,e),wt(n,"values",t=>t.def.in._zod.values),wt(n,"optin",t=>t.def.in._zod.optin),wt(n,"optout",t=>t.def.out._zod.optout),wt(n,"propValues",t=>t.def.in._zod.propValues),n._zod.parse=(t,s)=>{if(s.direction==="backward"){const o=e.out._zod.run(t,s);return o instanceof Promise?o.then(i=>bu(i,e.in,s)):bu(o,e.in,s)}const r=e.in._zod.run(t,s);return r instanceof Promise?r.then(o=>bu(o,e.out,s)):bu(r,e.out,s)}});function bu(n,e,t){return n.issues.some(s=>s.code!=="unrecognized_keys")?(n.aborted=!0,n):e._zod.run({value:n.value,issues:n.issues},t)}const MU=pe("$ZodReadonly",(n,e)=>{Bt.init(n,e),wt(n,"propValues",t=>t.def.innerType._zod.propValues),wt(n,"values",t=>t.def.innerType._zod.values),wt(n,"optin",t=>{var s,r;return(r=(s=t.def.innerType)==null?void 0:s._zod)==null?void 0:r.optin}),wt(n,"optout",t=>{var s,r;return(r=(s=t.def.innerType)==null?void 0:s._zod)==null?void 0:r.optout}),n._zod.parse=(t,s)=>{if(s.direction==="backward")return e.innerType._zod.run(t,s);const r=e.innerType._zod.run(t,s);return r instanceof Promise?r.then(E2):E2(r)}});function E2(n){return n.memo||(n.value=Object.freeze(n.value)),n}const zU=pe("$ZodCustom",(n,e)=>{as.init(n,e),Bt.init(n,e),n._zod.parse=(t,s)=>t,n._zod.check=t=>{const s=t.value,r=e.fn(s);if(r instanceof Promise)return r.then(o=>T2(o,t,s,n));T2(r,t,s,n)}});function T2(n,e,t,s){if(!n){const r={code:"custom",input:t,inst:s,path:[...s._zod.def.path??[]],continue:!s._zod.def.abort};s._zod.def.params&&(r.params=s._zod.def.params),e.issues.push(sc(r))}}class DU extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const Bg="~memo",A2=[];function iC(n){return n!==null&&typeof n=="object"}function tp(n){return n.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}const aC=new WeakMap,rl=0,ad=1,$l=2;function ld(n,e,t){const s=aC.get(n);if(s!==void 0)return s?$l:rl;if(e.has(n))return $l;e.add(n);let r=rl;const o=d=>{if(r!==$l&&(d!=null&&d._zod)){const f=ld(d,e);f>r&&(r=f)}},i=(d,f)=>{var p;let m=rl;for(const h of Reflect.ownKeys(d)){const g=Object.getOwnPropertyDescriptor(d,h);if(!g.enumerable)continue;const x=g.get?ad:(p=g.value)!=null&&p._zod?ld(g.value,e):rl;x>m&&(m=x)}return m},l=d=>{d>r&&(r=d)},c=n._zod.def;switch(c.type){case"object":{const d=l0(c);l(d?i(d):ad),o(c.catchall);break}case"array":o(c.element);break;case"tuple":for(const d of c.items)o(d);o(c.rest);break;case"record":case"map":o(c.keyType),o(c.valueType);break;case"set":o(c.valueType);break;case"union":for(const d of c.options)o(d);break;case"intersection":o(c.left),o(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":o(c.innerType);break;case"pipe":o(c.in),o(c.out);break;case"function":o(c.input),o(c.output);break;case"lazy":{const d=c._cachedInner??void 0;l(d?ld(d,e):ad);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(const d in c){const f=Object.getOwnPropertyDescriptor(c,d);if(!f||f.get)continue;const m=f.value;if(!(!m||typeof m!="object")){if(m._zod)o(m);else if(Array.isArray(m))for(const p of m)o(p)}}}return e.delete(n),FU(n,r)}function FU(n,e){return e!==ad&&aC.set(n,e===$l),e}function UU(n,e){let t=n.buckets.get(e);return t||(t=new WeakMap,n.buckets.set(e,t)),t}let vu;const yu=[],BU={alloc(n,e,t){const s=vu;if(!s)return t;vu=void 0;const r={value:t,issues:null};return s.set(e.value,r),yu.push(r),t},guard(n){var e;(e=n._zod).deferred??(e.deferred=[]),n._zod.deferred.push(()=>{const t=n._zod.parse,s=(r,o)=>{if(o.direction!=="backward"&&qU(o,r.value))throw new DU;return t(r,o)};n._zod.parse=s,n._zod.run===t&&(n._zod.run=s)})},attach(n){var e;let t,s=!1,r,o;(e=n._zod).deferred??(e.deferred=[]),n._zod.deferred.push(()=>{const i=n._zod.parse,l=(c,u)=>{if(t===void 0){const b=ld(n,new Set);if(b===rl)return n._zod.parse=i,n._zod.run===l&&(n._zod.run=i),i(c,u);b===$l||s?t=!0:s=!0}const d=c.value;if(!iC(d))return i(c,u);let f=u[Bg];f||(f={buckets:new WeakMap,backEdges:void 0},u[Bg]=f);let m;r===u?m=o:(m=UU(f,n),r=u,o=m);const p=m.get(d);if(p)return c.value=p.value,p.issues?p.issues.length&&c.issues.push(...tp(p.issues)):(c.memo=!0,f.backEdges??(f.backEdges=new WeakSet),f.backEdges.add(p.value)),c;vu=m;const h=yu.length,g=i(c,u);vu=void 0;const x=yu.length>h?yu.pop():void 0;return g instanceof Promise?g.then(b=>(x&&(x.issues=b.issues.length?tp(b.issues):A2),b)):(x&&(x.issues=g.issues.length?tp(g.issues):A2),g)};n._zod.parse=l,n._zod.run===i&&(n._zod.run=l)})}};function WU(){return BU}function qU(n,e){var s;const t=(s=n[Bg])==null?void 0:s.backEdges;return t!==void 0&&iC(e)&&t.has(e)}const VU=()=>{const n={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function e(o){return n[o]??null}const t={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},s={nan:"NaN"};function r(o,i){return o==="number"&&typeof i=="number"&&!Number.isFinite(i)?String(i):s[o]??o}return o=>{switch(o.code){case"invalid_type":{const i=r(o.expected),l=mD(o.input),c=r(l,o.input);return`Invalid input: expected ${i}, received ${c}`}case"invalid_value":return o.values.length===1?`Invalid input: expected ${z5(o.values[0])}`:`Invalid option: expected one of ${m2(o.values,"|")}`;case"too_big":{const i=o.exact?"exactly ":o.inclusive?"<=":"<",l=e(o.origin);return l?`Too big: expected ${o.origin??"value"} to have ${i}${o.maximum.toString()} ${l.unit??"elements"}`:`Too big: expected ${o.origin??"value"} to be ${i}${o.maximum.toString()}`}case"too_small":{const i=o.exact?"exactly ":o.inclusive?">=":">",l=e(o.origin);return l?`Too small: expected ${o.origin} to have ${i}${o.minimum.toString()} ${l.unit}`:`Too small: expected ${o.origin} to be ${i}${o.minimum.toString()}`}case"invalid_format":{const i=o;return i.format==="starts_with"?`Invalid string: must start with "${i.prefix}"`:i.format==="ends_with"?`Invalid string: must end with "${i.suffix}"`:i.format==="includes"?`Invalid string: must include "${i.includes}"`:i.format==="regex"?`Invalid string: must match pattern ${i.pattern}`:`Invalid ${t[i.format]??o.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${o.divisor}`;case"unrecognized_keys":return`Unrecognized key${o.keys.length>1?"s":""}: ${m2(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":return o.options&&Array.isArray(o.options)&&o.options.length>0?`Invalid discriminator value. Expected ${o.options.map(l=>`'${l}'`).join(" | ")}`:o.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}};function HU(){return{localeError:VU()}}var I2;class KU{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const s=t[0];return this._map.set(e,s),s&&typeof s=="object"&&"id"in s&&this._idmap.set(s.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const s={...this.get(t)??{}};delete s.id;const r={...s,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function GU(){return new KU}(I2=globalThis).__zod_globalRegistry??(I2.__zod_globalRegistry=GU());const ol=globalThis.__zod_globalRegistry;function lC(n){return n.checks&&(n.checks=[...n.checks]),n}function ZU(n,e){return new n(lC({type:"string",...Ye(e)}))}function YU(n,e){return new n({type:"string",format:"email",check:"string_format",abort:!1,...Ye(e)})}function XU(n,e){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...Ye(e)})}function JU(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...Ye(e)})}function QU(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Ye(e)})}function eB(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Ye(e)})}function tB(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Ye(e)})}function nB(n,e){return new n({type:"string",format:"url",check:"string_format",abort:!1,...Ye(e)})}function sB(n,e){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...Ye(e)})}function rB(n,e){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...Ye(e)})}function oB(n,e){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...Ye(e)})}function iB(n,e){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...Ye(e)})}function aB(n,e){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...Ye(e)})}function lB(n,e){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...Ye(e)})}function cB(n,e){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...Ye(e)})}function uB(n,e){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...Ye(e)})}function dB(n,e){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...Ye(e)})}function fB(n,e){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Ye(e)})}function mB(n,e){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Ye(e)})}function pB(n,e){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...Ye(e)})}function hB(n,e){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...Ye(e)})}function gB(n,e){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...Ye(e)})}function xB(n,e){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...Ye(e)})}function bB(n,e){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Ye(e)})}function vB(n,e){return new n({type:"string",format:"date",check:"string_format",...Ye(e)})}function yB(n,e){return new n({type:"string",format:"time",check:"string_format",precision:null,...Ye(e)})}function wB(n,e){return new n({type:"string",format:"duration",check:"string_format",...Ye(e)})}function SB(n,e){return new n(lC({type:"number",checks:[],...Ye(e)}))}function kB(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...Ye(e)})}function jB(n,e){return new n({type:"boolean",...Ye(e)})}function NB(n,e){return new n({type:"null",...Ye(e)})}function CB(n){return new n({type:"unknown"})}function _B(n,e){return new n({type:"never",...Ye(e)})}function P2(n,e){return new H5({check:"less_than",...Ye(e),value:n,inclusive:!1})}function np(n,e){return new H5({check:"less_than",...Ye(e),value:n,inclusive:!0})}function $2(n,e){return new K5({check:"greater_than",...Ye(e),value:n,inclusive:!1})}function sp(n,e){return new K5({check:"greater_than",...Ye(e),value:n,inclusive:!0})}function R2(n,e){return new vF({check:"multiple_of",...Ye(e),value:n})}function cC(n,e){return new wF({check:"max_length",...Ye(e),maximum:n})}function Bd(n,e){return new SF({check:"min_length",...Ye(e),minimum:n})}function uC(n,e){return new kF({check:"length_equals",...Ye(e),length:n})}function EB(n,e){return new jF({check:"string_format",format:"regex",...Ye(e),pattern:n})}function TB(n){return new NF({check:"string_format",format:"lowercase",...Ye(n)})}function AB(n){return new CF({check:"string_format",format:"uppercase",...Ye(n)})}function IB(n,e){return new _F({check:"string_format",format:"includes",...Ye(e),includes:n})}function PB(n,e){return new EF({check:"string_format",format:"starts_with",...Ye(e),prefix:n})}function $B(n,e){return new TF({check:"string_format",format:"ends_with",...Ye(e),suffix:n})}function La(n){return new AF({check:"overwrite",tx:n})}function RB(n){return La(e=>e.normalize(n))}function OB(){return La(n=>n.trim())}function LB(){return La(n=>n.toLowerCase())}function MB(){return La(n=>n.toUpperCase())}function zB(){return La(n=>eD(n))}function DB(n,e,t){return new n({type:"array",element:e,...Ye(t)})}function FB(n,e,t){const s=Ye(t);return s.abort??(s.abort=!0),new n({type:"custom",check:"custom",fn:e,...s})}function UB(n,e,t){return new n({type:"custom",check:"custom",fn:e,...Ye(t)})}function BB(n,e){const t=WB(s=>(s.addIssue=r=>{if(typeof r=="string")s.issues.push(sc(r,s.value,t._zod.def));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),"input"in o||(o.input=s.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),s.issues.push(sc(o))}},n(s.value,s)),e);return t}function WB(n,e){const t=new as({check:"custom",...Ye(e)});return t._zod.check=n,t}function Rl(n,...e){for(const t of e)for(const s of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,s)&&lo(n,s,t[s]);return n}function dC(n){let e=(n==null?void 0:n.target)??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:n.processors??{},metadataRegistry:(n==null?void 0:n.metadata)??ol,target:e,unrepresentable:(n==null?void 0:n.unrepresentable)??"throw",override:(n==null?void 0:n.override)??(()=>{}),io:(n==null?void 0:n.io)??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:(n==null?void 0:n.cycles)??"ref",reused:(n==null?void 0:n.reused)??"inline",intersections:[],deferred:[],external:(n==null?void 0:n.external)??void 0}}function Mo(n,e,t,s,r){const o=typeof e.unrepresentable=="function"?e.unrepresentable({zodSchema:n,path:s.path,message:r}):e.unrepresentable;if(o==="any")return!1;if(o===void 0||o==="throw")throw new Error(r);return Object.assign(t,o),!0}function pn(n,e,t={path:[],schemaPath:[]}){var d,f;var s;const r=n._zod.def,o=e.seen.get(n);if(o)return o.count++,t.schemaPath.includes(n)&&(o.cycle=t.path),o.schema;const i={schema:{},count:1,cycle:void 0,path:t.path};e.seen.set(n,i),e.sharedDefsExtractedFor=void 0,e.sharedEmitDoneFor=void 0;const l=(f=(d=n._zod).toJSONSchema)==null?void 0:f.call(d);if(l)i.schema=l;else{const m={...t,schemaPath:[...t.schemaPath,n],path:t.path};if(n._zod.processJSONSchema)n._zod.processJSONSchema(e,i.schema,m);else{const h=i.schema,g=e.processors[r.type];if(!g)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);g(n,e,h,m)}const p=n._zod.parent;p&&(i.ref||(i.ref=p),pn(p,e,m),e.seen.get(p).isParent=!0)}const c=e.metadataRegistry.get(n);return c&&Rl(i.schema,c),e.io==="input"&&qn(n)&&(delete i.schema.examples,delete i.schema.default),e.io==="input"&&"_prefault"in i.schema&&((s=i.schema).default??(s.default=i.schema._prefault)),delete i.schema._prefault,e.seen.get(n).schema}function O2(n){return n.replace(/~/g,"~0").replace(/\//g,"~1")}function fC(n,e){var i,l,c,u;const t=n.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");if(n.external&&n.sharedDefsExtractedFor===n.external)return;const s=new Map;for(const d of n.seen.entries()){const f=(i=n.metadataRegistry.get(d[0]))==null?void 0:i.id;if(f){const m=s.get(f);if(m&&m!==d[0])throw new Error(`Duplicate schema id "${f}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);s.set(f,d[0])}}const r=d=>{var g;const f=n.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const x=(g=n.external.registry.get(d[0]))==null?void 0:g.id,b=n.external.uri??(v=>v);if(x)return{ref:b(x)};const w=d[1].defId??d[1].schema.id??`schema${n.counter++}`;return d[1].defId=w,{defId:w,ref:`${b("__shared")}#/${f}/${O2(w)}`}}const m="#",p=`${m}/${f}/`;if(d[1]===t&&!d[1].schema.id)return{ref:m};const h=d[1].schema.id??`__schema${n.counter++}`;return{defId:h,ref:p+O2(h)}},o=d=>{if(d[1].schema.$ref)return;const f=d[1],{ref:m,defId:p}=r(d);f.def={...f.schema},p&&(f.defId=p);const h=f.schema;for(const g in h)delete h[g];h.$ref=m};if(n.cycles==="throw")for(const d of n.seen.entries()){const f=d[1];if(f.cycle)throw new Error(`Cycle detected: #/${(l=f.cycle)==null?void 0:l.join("/")}/<root>
69
69
 
70
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const d of n.seen.entries()){const f=d[1];if(e===d[0]){o(d);continue}if(n.external){const p=(c=n.external.registry.get(d[0]))==null?void 0:c.id;if(e!==d[0]&&p){o(d);continue}}if((u=n.metadataRegistry.get(d[0]))==null?void 0:u.id){o(d);continue}if(f.cycle){o(d);continue}f.count>1&&n.reused==="ref"&&o(d)}n.external&&(n.sharedDefsExtractedFor=n.external)}function mC(n){const e=n.anyOf;if(!Array.isArray(e)||e.length===0||n.type!==void 0)return;const t=[];for(const s of e){if(!s||typeof s!="object")return;mC(s);const r=Object.keys(s);if(r.length!==1||r[0]!=="type")return;const o=s.type;for(const i of Array.isArray(o)?o:[o]){if(typeof i!="string")return;t.includes(i)||t.push(i)}}delete n.anyOf,n.type=t.length===1?t[0]:t}const pC=new Set(["type","properties","required","additionalProperties"]),L2=["oneOf","anyOf"];function M2(n){const e=n.additionalProperties;return e===void 0||e===!1||typeof e!="object"||e===null?null:Object.keys(e).length?e:null}function Wg(n){var o;const e=[];for(const i of n){if(typeof i!="object"||i.type!=="object")return null;for(const l in i)if(!pC.has(l))return null;e.push(i)}const t={},s=new Set;for(const i of e){for(const l in i.properties){if(Object.prototype.hasOwnProperty.call(t,l))continue;const c=[];for(const d of e){const f=((o=d.properties)==null?void 0:o[l])??M2(d);f!=null&&(c.some(m=>JSON.stringify(m)===JSON.stringify(f))||c.push(f))}const u=c.length===1?c[0]:Wg(c)??{allOf:c};lo(t,l,u)}for(const l of i.required??[])s.add(l)}const r={type:"object",properties:t};if(s.size&&(r.required=[...s]),e.every(i=>i.additionalProperties===!1))r.additionalProperties=!1;else{const i=[];for(const l of e){const c=M2(l);c&&!i.some(u=>JSON.stringify(u)===JSON.stringify(c))&&i.push(c)}i.length===1?r.additionalProperties=i[0]:i.length>1&&(r.additionalProperties={allOf:i})}return r}function qB(n){const e=n.allOf;if(!Array.isArray(e)||e.length<2)return;for(const r of pC)if(r in n)return;const t=e.filter(r=>L2.some(o=>Array.isArray(r[o])));let s=null;if(!t.length)s=Wg(e);else{const r=t[0],o=L2.find(c=>Array.isArray(r[c]));if(Object.keys(r).length!==1)return;const i=e.filter(c=>c!==r),l=r[o].map(c=>Wg([...i,c]));if(l.some(c=>!c))return;s={[o]:l}}s&&(delete n.allOf,Rl(n,s))}function hC(n,e){var l,c,u,d;const t=n.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=f=>{const m=n.seen.get(f);if(m.ref===null)return;const p=m.def??m.schema,h={...p},g=m.ref;if(m.ref=null,g){s(g);const b=n.seen.get(g),w=b.schema;if(w.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(w)):Rl(p,w),Rl(p,h),f._zod.parent===g)for(const j in p)j==="$ref"||j==="allOf"||j in h||delete p[j];if(w.$ref&&b.def)for(const j in p)j==="$ref"||j==="allOf"||j in b.def&&JSON.stringify(p[j])===JSON.stringify(b.def[j])&&delete p[j]}const x=f._zod.parent;if(x&&x!==g){s(x);const b=n.seen.get(x);if(b!=null&&b.schema.$ref&&(p.$ref=b.schema.$ref,b.def))for(const w in p)w==="$ref"||w==="allOf"||w in b.def&&JSON.stringify(p[w])===JSON.stringify(b.def[w])&&delete p[w]}n.override({zodSchema:f,jsonSchema:p,path:m.path??[]})};if(!n.external||n.sharedEmitDoneFor!==n.external){for(const f of[...n.seen.entries()].reverse())s(f[0]);if(n.target!=="openapi-3.0")for(const f of n.seen.entries())mC(f[1].def??f[1].schema);for(const f of n.deferred)f();if(n.intersections.length){const f=new Map;for(const m of n.seen.values())for(const p of[m.schema,m.def]){const h=p==null?void 0:p.allOf;if(!Array.isArray(h))continue;const g=f.get(h);g?g.push(p):f.set(h,[p])}for(const m of n.intersections)for(const p of f.get(m)??[])qB(p)}}const r={};if(n.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":n.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":n.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":n.target,(l=n.external)!=null&&l.uri){const f=(c=n.external.registry.get(e))==null?void 0:c.id;if(!f)throw new Error("Schema is missing an `id` property");r.$id=n.external.uri(f)}Rl(r,t.defId?t.schema:t.def??t.schema);const o=(u=n.metadataRegistry.get(e))==null?void 0:u.id;o!==void 0&&r.id===o&&delete r.id;const i=((d=n.external)==null?void 0:d.defs)??{};if(!n.external||n.sharedEmitDoneFor!==n.external)for(const f of n.seen.entries()){const m=f[1];m.def&&m.defId&&(m.def.id===m.defId&&delete m.def.id,lo(i,m.defId,m.def))}n.external&&(n.sharedEmitDoneFor=n.external),n.external||Object.keys(i).length>0&&(n.target==="draft-2020-12"?r.$defs=i:r.definitions=i);try{const f=JSON.parse(JSON.stringify(r));return Object.defineProperty(f,"~standard",{value:{...e["~standard"],jsonSchema:{input:Wd(e,"input",n.processors),output:Wd(e,"output",n.processors)}},enumerable:!1,writable:!1}),f}catch{throw new Error("Error converting schema to JSON.")}}function qn(n,e){const t=e??{seen:new Set};if(t.seen.has(n))return!1;t.seen.add(n);const s=n._zod.def;if(s.type==="transform")return!0;if(s.type==="array")return qn(s.element,t);if(s.type==="set")return qn(s.valueType,t);if(s.type==="lazy")return qn(s.getter(),t);if(s.type==="promise"||s.type==="optional"||s.type==="nonoptional"||s.type==="nullable"||s.type==="readonly"||s.type==="default"||s.type==="prefault"||s.type==="catch")return qn(s.innerType,t);if(s.type==="intersection")return qn(s.left,t)||qn(s.right,t);if(s.type==="record"||s.type==="map")return qn(s.keyType,t)||qn(s.valueType,t);if(s.type==="pipe")return n._zod.traits.has("$ZodCodec")?!0:qn(s.in,t)||qn(s.out,t);if(s.type==="object"){for(const r in s.shape)if(qn(s.shape[r],t))return!0;return!1}if(s.type==="union"){for(const r of s.options)if(qn(r,t))return!0;return!1}if(s.type==="tuple"){for(const r of s.items)if(qn(r,t))return!0;return!!(s.rest&&qn(s.rest,t))}return!1}const VB=(n,e={})=>t=>{const s=dC({...t,processors:e});return pn(n,s),fC(s,n),hC(s,n)},Wd=(n,e,t={})=>s=>{const{libraryOptions:r,target:o}=s??{},i=dC({...r??{},target:o,io:e,processors:t});return pn(n,i),fC(i,n),hC(i,n)},da=(n,e,t)=>{(n[e]===void 0||t>n[e])&&(n[e]=t)},fa=(n,e,t)=>{(n[e]===void 0||t<n[e])&&(n[e]=t)},z2=(n,e)=>{da(n,"minimum",e),fa(n,"maximum",e)},gC=(n,e)=>{n.multipleOf??(n.multipleOf=[]),n.multipleOf.includes(e)||n.multipleOf.push(e)},xC=(n,e)=>{n.patterns??(n.patterns=new Set),n.patterns.add(e)},bC=(n,e)=>{n.mime=n.mime?n.mime.filter(t=>e.includes(t)):[...e]},vC=(n,e)=>{n.format=e,e.includes("int")&&(n.isInt=!0)},D2=(n,e)=>da(n,"minimum",e.minimum),F2=(n,e)=>fa(n,"maximum",e.maximum),U2=n=>(e,t)=>{vC(e,t.format);const[s,r]=n[t.format];da(e,"minimum",s),fa(e,"maximum",r)},rp={greater_than:(n,e)=>da(n,e.inclusive?"minimum":"exclusiveMinimum",e.value),less_than:(n,e)=>fa(n,e.inclusive?"maximum":"exclusiveMaximum",e.value),multiple_of:(n,e)=>gC(n,e.value),number_format:U2(D5),bigint_format:U2(rD),min_length:D2,max_length:F2,length_equals:(n,e)=>z2(n,e.length),min_size:D2,max_size:F2,size_equals:(n,e)=>z2(n,e.size),string_format:(n,e)=>{vC(n,e.format),e.pattern&&xC(n,e.pattern),(e.format==="base64"||e.format==="base64url")&&(n.contentEncoding=e.format),(e.local||e.precision===-1)&&(n.laxFormat=!0)},mime_type:(n,e)=>bC(n,e.mime)};function Ws(n){var o;const e={},t=n._zod.def,s=n._zod.traits.has("$ZodCheck")?[n,...t.checks??[]]:t.checks??[];for(const i of s)(o=rp[i._zod.def.check])==null||o.call(rp,e,i._zod.def);const r=n._zod.bag;r.minimum!==void 0&&da(e,"minimum",r.minimum),r.exclusiveMinimum!==void 0&&da(e,"exclusiveMinimum",r.exclusiveMinimum),r.maximum!==void 0&&fa(e,"maximum",r.maximum),r.exclusiveMaximum!==void 0&&fa(e,"exclusiveMaximum",r.exclusiveMaximum),r.multipleOf!==void 0&&gC(e,r.multipleOf),r.format!==void 0&&(e.format??(e.format=r.format),r.format.includes("int")&&(e.isInt=!0)),r.mime&&bC(e,r.mime);for(const i of r.patterns??[])xC(e,i);return e}const HB={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},KB=new Map([[eC,oF],[b0,iF]]),yC=n=>KB.get(n)??n,GB=(n,e,t,s)=>{const r=t;r.type="string";const{minimum:o,maximum:i,format:l,patterns:c,contentEncoding:u,laxFormat:d}=Ws(n);if(typeof o=="number"&&(r.minLength=o),typeof i=="number"&&(r.maxLength=i),l&&(r.format=HB[l]??l,r.format===""&&delete r.format,(l==="time"||d)&&delete r.format),u&&(r.contentEncoding=u),c&&c.size>0){const f=[...c].map(yC);f.length===1?r.pattern=f[0].source:f.length>1&&(r.allOf=[...f.map(m=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},ZB=(n,e,t,s)=>{const r=t,{minimum:o,maximum:i,multipleOf:l,exclusiveMaximum:c,exclusiveMinimum:u,isInt:d}=Ws(n);r.type=d?"integer":"number";const f=typeof u=="number"&&u>=(o??Number.NEGATIVE_INFINITY),m=typeof c=="number"&&c<=(i??Number.POSITIVE_INFINITY),p=e.target==="draft-04"||e.target==="openapi-3.0";if(f?p?(r.minimum=u,r.exclusiveMinimum=!0):r.exclusiveMinimum=u:typeof o=="number"&&(r.minimum=o),m?p?(r.maximum=c,r.exclusiveMaximum=!0):r.exclusiveMaximum=c:typeof i=="number"&&(r.maximum=i),l){const h=new Set;for(const b of l)Number.isFinite(b)&&b!==0?h.add(Math.abs(b)):Mo(n,e,r,s,`A multipleOf divisor of ${b} cannot be represented in JSON Schema`);const[g,...x]=h;g!==void 0&&(r.multipleOf=g),x.length&&(r.allOf=[...r.allOf??[],...x.map(b=>({multipleOf:b}))])}},YB=(n,e,t,s)=>{t.type="boolean"},XB=(n,e,t,s)=>{e.target==="openapi-3.0"?(t.type="string",t.nullable=!0,t.enum=[null]):t.type="null"},JB=(n,e,t,s)=>{t.not={}},QB=(n,e,t,s)=>{},eW=(n,e,t,s)=>{const r=n._zod.def,o=Mg(r.entries);if(o.length===0){t.not={};return}o.every(i=>typeof i=="number")&&(t.type="number"),o.every(i=>typeof i=="string")&&(t.type="string"),t.enum=o},tW=(n,e,t,s)=>{const r=n._zod.def;if(r.values.length===0){t.not={};return}const o=[];for(const i of r.values)if(i===void 0){if(Mo(n,e,t,s,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i=="bigint"){if(Mo(n,e,t,s,"BigInt literals cannot be represented in JSON Schema"))return;o.push(Number(i))}else o.push(i);if(o.length!==0)if(o.length===1){const i=o[0];t.type=i===null?"null":typeof i,e.target==="draft-04"||e.target==="openapi-3.0"?t.enum=[i]:t.const=i}else o.every(i=>typeof i=="number")&&(t.type="number"),o.every(i=>typeof i=="string")&&(t.type="string"),o.every(i=>typeof i=="boolean")&&(t.type="boolean"),o.every(i=>i===null)&&(t.type="null"),t.enum=o},nW=(n,e,t,s)=>{Mo(n,e,t,s,"Custom types cannot be represented in JSON Schema")},sW=(n,e,t,s)=>{Mo(n,e,t,s,"Transforms cannot be represented in JSON Schema")},rW=(n,e,t,s)=>{const r=t,o=n._zod.def,{minimum:i,maximum:l}=Ws(n);typeof i=="number"&&(r.minItems=i),typeof l=="number"&&(r.maxItems=l),r.type="array",r.items=pn(o.element,e,{...s,path:[...s.path,"items"]})};function qd(n){const e=n._zod.def;return e.type==="pipe"&&e.in._zod.traits.has("$ZodTransform")?qd(e.out):e.type==="catch"?qd(e.innerType):n._zod.optin}const oW=(n,e,t,s)=>{var u;const r=t,o=n._zod.def,i=o.shape;if(Object.getOwnPropertySymbols(i).length&&Mo(n,e,r,s,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(const d in i)lo(r.properties,d,pn(i[d],e,{...s,path:[...s.path,"properties",d]}));const c=[];for(const d of Object.keys(i)){const f=o.shape[d];(e.io==="input"?qd(f)===void 0:f._zod.optout===void 0)&&c.push(d)}c.length>0&&(r.required=c),((u=o.catchall)==null?void 0:u._zod.def.type)==="never"?r.additionalProperties=!1:o.catchall?o.catchall&&(r.additionalProperties=pn(o.catchall,e,{...s,path:[...s.path,"additionalProperties"]})):e.io==="output"&&(r.additionalProperties=!1)},iW=(n,e,t,s)=>{const r=n._zod.def,o=r.inclusive===!1,i=r.options.map((l,c)=>pn(l,e,{...s,path:[...s.path,o?"oneOf":"anyOf",c]}));o?t.oneOf=i:t.anyOf=i},aW=(n,e,t,s)=>{const r=n._zod.def,o=pn(r.left,e,{...s,path:[...s.path,"allOf",0]}),i=pn(r.right,e,{...s,path:[...s.path,"allOf",1]}),l=u=>"allOf"in u&&Object.keys(u).length===1,c=[...l(o)?o.allOf:[o],...l(i)?i.allOf:[i]];t.allOf=c,e.intersections.push(c)};function qg(n,e,t){var h;if(e.$ref){if(t.has(e))return e;t.add(e);const g=(h=n.get(e))==null?void 0:h.def;if(!g)return e;const x=qg(n,g,t);return x===g?e:x}for(const g of["anyOf","oneOf"]){const x=e[g];if(!Array.isArray(x))continue;const b=x.map(w=>qg(n,w,t));b.some((w,v)=>w!==x[v])&&(e={...e,[g]:b})}const s=Array.isArray(e.type)?e.type:[e.type],r=!s.includes("string")&&s.some(g=>g==="number"||g==="integer"),o=e.enum??(e.const!==void 0?[e.const]:void 0);if(!r&&!(o!=null&&o.some(g=>typeof g=="number")))return e;const{minimum:i,maximum:l,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:d,format:f,id:m,...p}=e;return p.enum?p.enum=p.enum.map(g=>typeof g=="number"?String(g):g):typeof p.const=="number"&&(p.const=String(p.const)),r&&(p.type="string",o||(p.pattern=(s.includes("number")?h0:pF).source)),p}const Vg=new WeakMap;function lW(n){var s;const e=new Map;for(const r of n.seen.values())r.def&&!e.has(r.schema)&&e.set(r.schema,r);const t=new Map;for(const r of Vg.get(n)??[]){const o=n.seen.get(r),i=(s=(o==null?void 0:o.def)??(o==null?void 0:o.schema))==null?void 0:s.propertyNames;if(!i||i===!0||t.has(i))continue;const l=qg(e,i,new Set);l!==i&&t.set(i,l)}if(t.size)for(const r of n.seen.values())for(const o of[r.schema,r.def]){const i=o&&t.get(o.propertyNames);i&&(o.propertyNames=i)}}const cW=(n,e,t,s)=>{const r=t,o=n._zod.def;r.type="object";const i=o.keyType,l=Ws(i).patterns;if(o.mode==="loose"&&l&&l.size>0){const d=pn(o.valueType,e,{...s,path:[...s.path,"patternProperties","*"]});r.patternProperties={};for(const f of l)lo(r.patternProperties,yC(f).source,d)}else{if(e.target==="draft-07"||e.target==="draft-2020-12"){r.propertyNames=pn(o.keyType,e,{...s,path:[...s.path,"propertyNames"]});let d=Vg.get(e);d||(d=[],Vg.set(e,d),e.deferred.push(()=>lW(e))),d.push(n)}r.additionalProperties=pn(o.valueType,e,{...s,path:[...s.path,"additionalProperties"]})}const c=i._zod.values,u=e.io==="input"&&qd(o.valueType)!==void 0;if(c&&!o.partial&&!u){const d=[...c].filter(f=>typeof f=="string"||typeof f=="number");d.length>0&&(r.required=d.map(String))}},uW=(n,e,t,s)=>{const r=n._zod.def,o=pn(r.innerType,e,s),i=e.seen.get(n);e.target==="openapi-3.0"?(i.ref=r.innerType,t.nullable=!0):t.anyOf=[o,{type:"null"}]},dW=(n,e,t,s)=>{const r=n._zod.def;pn(r.innerType,e,s);const o=e.seen.get(n);o.ref=r.innerType},v0=Symbol();function wC(n,e,t,s,r){let o=!1;const i=JSON.stringify(n,(l,c)=>typeof c!="bigint"?c:(o=!0,null));return o?(Mo(e,t,s,r,"BigInt defaults cannot be represented in JSON Schema"),v0):JSON.parse(i)}const fW=(n,e,t,s)=>{const r=n._zod.def;pn(r.innerType,e,s);const o=e.seen.get(n);o.ref=r.innerType;const i=wC(r.defaultValue,n,e,t,s);i!==v0&&(t.default=i)},mW=(n,e,t,s)=>{const r=n._zod.def;pn(r.innerType,e,s);const o=e.seen.get(n);if(o.ref=r.innerType,e.io!=="input")return;const i=wC(r.defaultValue,n,e,t,s);i!==v0&&(t._prefault=i)},pW=(n,e,t,s)=>{const r=n._zod.def;pn(r.innerType,e,s);const o=e.seen.get(n);o.ref=r.innerType;let i;try{i=r.catchValue(void 0)}catch{Mo(n,e,t,s,"Dynamic catch values are not supported in JSON Schema");return}t.default=i},hW=(n,e,t,s)=>{const r=n._zod.def,o=r.in._zod.traits.has("$ZodTransform"),i=e.io==="input"?o?r.out:r.in:r.out;pn(i,e,s);const l=e.seen.get(n);l.ref=i},gW=(n,e,t,s)=>{const r=n._zod.def;pn(r.innerType,e,s);const o=e.seen.get(n);o.ref=r.innerType,t.readOnly=!0},SC=(n,e,t,s)=>{const r=n._zod.def;pn(r.innerType,e,s);const o=e.seen.get(n);o.ref=r.innerType},B2=new WeakSet([Object.prototype,Error.prototype]);function wu(n,e,t){Object.defineProperty(n,e,{configurable:!0,enumerable:!1,get(){const s=t(this);return Object.defineProperty(this,e,{value:s,configurable:!0,writable:!0}),s},set(s){Object.defineProperty(this,e,{value:s,configurable:!0,writable:!0})}})}const xW=(n,e)=>{CD.init(n,e),n.name="ZodError";const t=Object.getPrototypeOf(n);B2.has(t)||(B2.add(t),wu(t,"format",s=>r=>TD(s,r)),wu(t,"flatten",s=>r=>ED(s,r)),wu(t,"addIssue",s=>r=>{s.issues.push(r),s.message=JSON.stringify(s.issues,zg,2)}),wu(t,"addIssues",s=>r=>{s.issues.push(...r),s.message=JSON.stringify(s.issues,zg,2)}),Object.defineProperty(t,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},Ts=pe("ZodError",xW,void 0,{Parent:Error}),bW=d0(Ts),vW=f0(Ts),yW=m0(Ts),wW=p0(Ts),SW=OD(Ts),kW=LD(Ts),jW=MD(Ts),NW=zD(Ts),CW=DD(Ts),_W=FD(Ts),EW=UD(Ts),TW=BD(Ts);function AW(){Qs.localeError||Er(HU())}function Zf(){Qs.memoizer||Er({memoizer:WU()})}const qt=pe("ZodType",(n,e)=>(AW(),Bt.init(n,e),n.def=e,n.type=e.type,n),{check(...n){const e=this.def;return this.clone(hs(e,{checks:[...e.checks??[],...n.map(t=>typeof t=="function"?{_zod:{check:t,def:{check:"custom"},onattach:[]}}:t)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,e){return Ho(this,n,e)},brand(){return this},register(n,e){return n.add(this,e),this},refine(n,e){return this.check(Nq(n,e))},superRefine(n,e){return this.check(Cq(n,e))},overwrite(n){return this.check(La(n))},optional(){return V2(this)},exactOptional(){return mq(this)},nullable(){return H2(this)},nullish(){return V2(H2(this))},nonoptional(n){return vq(this,n)},array(){return at(this)},or(n){return eo([this,n])},and(n){return cq(this,n)},transform(n){return K2(this,fq(n))},default(n){return gq(this,n)},prefault(n){return bq(this,n)},catch(n){return wq(this,n)},pipe(n){return K2(this,n)},readonly(){return jq(this)},describe(n){const e=this.clone();return ol.add(e,{description:n}),e},meta(...n){if(n.length===0)return ol.get(this);const e=this.clone();return ol.add(e,n[0]),e},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n,...e){return e.length===0?n(this):n(this,...e)},get"~standard"(){return U5(this,"~standard",{...Z5(this),jsonSchema:{input:Wd(this,"input"),output:Wd(this,"output")}})},set"~standard"(n){Lo(this,"~standard",n)},parse:function n(e,t){return bW(this,e,t,{callee:n})},parseAsync:async function n(e,t){return await vW(this,e,t,{callee:n})},safeParse(n,e){return yW(this,n,e)},async safeParseAsync(n,e){return wW(this,n,e)},get spa(){return this==null?void 0:this.safeParseAsync},set spa(n){Lo(this,"spa",n)},validate(n,e){return PD(this,n,e)},validateAsync(n,e){return RD(this,n,e)},encode:function n(e,t){return SW(this,e,t,{callee:n})},decode:function n(e,t){return kW(this,e,t,{callee:n})},encodeAsync:async function n(e,t){return await jW(this,e,t,{callee:n})},decodeAsync:async function n(e,t){return await NW(this,e,t,{callee:n})},safeEncode(n,e){return CW(this,n,e)},safeDecode(n,e){return _W(this,n,e)},async safeEncodeAsync(n,e){return EW(this,n,e)},async safeDecodeAsync(n,e){return TW(this,n,e)},toJSONSchema(n){return VB(this,{})(n)},get description(){var n;return(n=ol.get(this))==null?void 0:n.description},get _def(){return this._zod.def}}),kC=pe("_ZodString",(n,e)=>{x0.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>GB(n,t,s)},B5({format:n=>Ws(n).format??null,minLength:n=>Ws(n).minimum??null,maxLength:n=>Ws(n).maximum??null},{regex(...n){return this.check(EB(...n))},includes(...n){return this.check(IB(...n))},startsWith(...n){return this.check(PB(...n))},endsWith(...n){return this.check($B(...n))},min(...n){return this.check(Bd(...n))},max(...n){return this.check(cC(...n))},length(...n){return this.check(uC(...n))},nonempty(...n){return this.check(Bd(1,...n))},lowercase(n){return this.check(TB(n))},uppercase(n){return this.check(AB(n))},trim(){return this.check(OB())},normalize(...n){return this.check(RB(...n))},toLowerCase(){return this.check(LB())},toUpperCase(){return this.check(MB())},slugify(){return this.check(zB())}})),IW=pe("ZodString",(n,e)=>{x0.init(n,e),kC.init(n,e)},{email(n){return this.check(YU(LW,n))},url(n){return this.check(nB(zW,n))},jwt(n){return this.check(xB(QW,n))},emoji(n){return this.check(sB(DW,n))},guid(n){return this.check(XU(MW,n))},uuid(n){return this.check(JU(Su,n))},uuidv4(n){return this.check(QU(Su,n))},uuidv6(n){return this.check(eB(Su,n))},uuidv7(n){return this.check(tB(Su,n))},nanoid(n){return this.check(rB(FW,n))},cuid(n){return this.check(oB(UW,n))},cuid2(n){return this.check(iB(BW,n))},ulid(n){return this.check(aB(WW,n))},base64(n){return this.check(pB(YW,n))},base64url(n){return this.check(hB(XW,n))},xid(n){return this.check(lB(qW,n))},ksuid(n){return this.check(cB(VW,n))},ipv4(n){return this.check(uB(HW,n))},ipv6(n){return this.check(dB(KW,n))},cidrv4(n){return this.check(fB(GW,n))},cidrv6(n){return this.check(mB(ZW,n))},e164(n){return this.check(gB(JW,n))},datetime(n){return this.check(bB(PW,n))},date(n){return this.check(vB($W,n))},time(n){return this.check(yB(RW,n))},duration(n){return this.check(wB(OW,n))}});function Le(n){return ZU(IW,n)}const Xt=pe("ZodStringFormat",(n,e)=>{Wt.init(n,e),kC.init(n,e)}),PW=pe("ZodISODateTime",(n,e)=>{YF.init(n,e),Xt.init(n,e)}),$W=pe("ZodISODate",(n,e)=>{XF.init(n,e),Xt.init(n,e)}),RW=pe("ZodISOTime",(n,e)=>{JF.init(n,e),Xt.init(n,e)}),OW=pe("ZodISODuration",(n,e)=>{QF.init(n,e),Xt.init(n,e)}),LW=pe("ZodEmail",(n,e)=>{LF.init(n,e),Xt.init(n,e)}),MW=pe("ZodGUID",(n,e)=>{RF.init(n,e),Xt.init(n,e)}),Su=pe("ZodUUID",(n,e)=>{OF.init(n,e),Xt.init(n,e)}),zW=pe("ZodURL",(n,e)=>{BF.init(n,e),Xt.init(n,e)}),DW=pe("ZodEmoji",(n,e)=>{WF.init(n,e),Xt.init(n,e)}),FW=pe("ZodNanoID",(n,e)=>{qF.init(n,e),Xt.init(n,e)}),UW=pe("ZodCUID",(n,e)=>{VF.init(n,e),Xt.init(n,e)}),BW=pe("ZodCUID2",(n,e)=>{HF.init(n,e),Xt.init(n,e)}),WW=pe("ZodULID",(n,e)=>{KF.init(n,e),Xt.init(n,e)}),qW=pe("ZodXID",(n,e)=>{GF.init(n,e),Xt.init(n,e)}),VW=pe("ZodKSUID",(n,e)=>{ZF.init(n,e),Xt.init(n,e)}),HW=pe("ZodIPv4",(n,e)=>{eU.init(n,e),Xt.init(n,e)}),KW=pe("ZodIPv6",(n,e)=>{nU.init(n,e),Xt.init(n,e)}),GW=pe("ZodCIDRv4",(n,e)=>{sU.init(n,e),Xt.init(n,e)}),ZW=pe("ZodCIDRv6",(n,e)=>{oU.init(n,e),Xt.init(n,e)}),YW=pe("ZodBase64",(n,e)=>{iU.init(n,e),Xt.init(n,e)}),XW=pe("ZodBase64URL",(n,e)=>{lU.init(n,e),Xt.init(n,e)}),JW=pe("ZodE164",(n,e)=>{cU.init(n,e),Xt.init(n,e)}),QW=pe("ZodJWT",(n,e)=>{dU.init(n,e),Xt.init(n,e)}),jC=pe("ZodNumber",(n,e)=>{tC.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>ZB(n,t,s,r),n.isFinite=!0},B5({minValue:n=>{const{minimum:e,exclusiveMinimum:t}=Ws(n);return Math.max(e??Number.NEGATIVE_INFINITY,t??Number.NEGATIVE_INFINITY)},maxValue:n=>{const{maximum:e,exclusiveMaximum:t}=Ws(n);return Math.min(e??Number.POSITIVE_INFINITY,t??Number.POSITIVE_INFINITY)},isInt:n=>{const{isInt:e,multipleOf:t}=Ws(n);return!!e||!!(t!=null&&t.some(Number.isSafeInteger))},format:n=>Ws(n).format??null},{gt(n,e){return this.check($2(n,e))},gte(n,e){return this.check(sp(n,e))},min(n,e){return this.check(sp(n,e))},lt(n,e){return this.check(P2(n,e))},lte(n,e){return this.check(np(n,e))},max(n,e){return this.check(np(n,e))},int(n){return this.check(W2(n))},safe(n){return this.check(W2(n))},positive(n){return this.check($2(0,n))},nonnegative(n){return this.check(sp(0,n))},negative(n){return this.check(P2(0,n))},nonpositive(n){return this.check(np(0,n))},multipleOf(n,e){return this.check(R2(n,e))},step(n,e){return this.check(R2(n,e))},finite(){return this}}));function bt(n){return SB(jC,n)}const eq=pe("ZodNumberFormat",(n,e)=>{fU.init(n,e),jC.init(n,e)});function W2(n){return kB(eq,n)}const tq=pe("ZodBoolean",(n,e)=>{mU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>YB(n,t,s)});function Ft(n){return jB(tq,n)}const nq=pe("ZodNull",(n,e)=>{pU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>XB(n,t,s)});function NC(n){return NB(nq,n)}const sq=pe("ZodUnknown",(n,e)=>{hU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>QB()});function Qr(){return CB(sq)}const rq=pe("ZodNever",(n,e)=>{gU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>JB(n,t,s)});function CC(n){return _B(rq,n)}const oq=pe("ZodArray",(n,e)=>{Zf(),vU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>rW(n,t,s,r),n.element=e.element},{min(n,e){return this.check(Bd(n,e))},nonempty(n){return this.check(Bd(1,n))},max(n,e){return this.check(cC(n,e))},length(n,e){return this.check(uC(n,e))},unwrap(){return this.element}});function at(n,e){return DB(oq,n,e)}const _C=pe("ZodObject",(n,e)=>{Zf(),SU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>oW(n,t,s,r),bD(n,"shape",t=>t._zod.def.shape,!1)},{keyof(){return Ct(Object.keys(this._zod.def.shape))},catchall(n){return this.clone(hs(this._zod.def,{catchall:n}))},passthrough(){return this.clone(hs(this._zod.def,{catchall:Qr()}))},loose(){return this.clone(hs(this._zod.def,{catchall:Qr()}))},strict(){return this.clone(hs(this._zod.def,{catchall:CC()}))},strip(){return this.clone(hs(this._zod.def,{catchall:void 0}))},extend(n){return aD(this,n)},safeExtend(n){return lD(this,n)},merge(n){return cD(this,n)},pick(n){return oD(this,n)},omit(n){return iD(this,n)},partial(...n){return p2(TC,this,n[0])},exactPartial(...n){return p2(AC,this,n[0],"exactPartial")},required(...n){return uD(IC,this,n[0])}});function iq(n,e){const t={type:"object",shape:n??{},...Ye(e)};return new _C(t)}function xe(n,e){return new _C({type:"object",shape:n,catchall:CC(),...Ye(e)})}const EC=pe("ZodUnion",(n,e)=>{rC.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>iW(n,t,s,r),n.options=e.options});function eo(n,e){return new EC({type:"union",options:n,...Ye(e)})}const aq=pe("ZodDiscriminatedUnion",(n,e)=>{EC.init(n,e),jU.init(n,e)});function Rr(n,e,t){return new aq({type:"union",options:e,discriminator:n,...Ye(t)})}const lq=pe("ZodIntersection",(n,e)=>{NU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>aW(n,t,s,r)});function cq(n,e){return new lq({type:"intersection",left:n,right:e})}const q2=pe("ZodRecord",(n,e)=>{Zf(),CU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>cW(n,t,s,r),n.keyType=e.keyType,n.valueType=e.valueType});function Xn(n,e,t){return!e||!e._zod?new q2({type:"record",keyType:Le(),valueType:n,...Ye(e)}):new q2({type:"record",keyType:n,valueType:e,...Ye(t)})}const Hg=pe("ZodEnum",(n,e)=>{_U.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(s,r,o)=>eW(n,s,r),n.enum=e.entries,n.options=[...n._zod.values];const t=new Set(Object.keys(e.entries));n.extract=(s,r)=>{const o={};for(const i of s)if(t.has(i))o[i]=e.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Hg({...e,checks:[],...Ye(r),entries:o})},n.exclude=(s,r)=>{const o={...e.entries};for(const i of s)if(t.has(i))delete o[i];else throw new Error(`Key ${i} not found in enum`);return new Hg({...e,checks:[],...Ye(r),entries:o})}});function Ct(n,e){const t=Array.isArray(n)?Object.fromEntries(n.map(s=>[s,s])):n;return new Hg({type:"enum",entries:t,...Ye(e)})}const uq=pe("ZodLiteral",(n,e)=>{EU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>tW(n,t,s,r),n.values=new Set(e.values),Object.defineProperty(n,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function Ze(n,e){return new uq({type:"literal",values:Array.isArray(n)?n:[n],...Ye(e)})}const dq=pe("ZodTransform",(n,e)=>{Zf(),TU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>sW(n,t,s,r),n._zod.parse=(t,s)=>{if(s.direction==="backward")throw new W5(n.constructor.name);t.addIssue=o=>{if(typeof o=="string")t.issues.push(sc(o,t.value,e));else{const i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=t.value),i.inst??(i.inst=n),t.issues.push(sc(i))}};const r=e.transform(t.value,t);return r instanceof Promise?r.then(o=>(t.value=o,t)):(t.value=r,t)}});function fq(n){return new dq({type:"transform",transform:n})}const TC=pe("ZodOptional",(n,e)=>{oC.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>SC(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function V2(n){return new TC({type:"optional",innerType:n})}const AC=pe("ZodExactOptional",(n,e)=>{AU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>SC(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function mq(n){return new AC({type:"optional",innerType:n})}const pq=pe("ZodNullable",(n,e)=>{IU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>uW(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function H2(n){return new pq({type:"nullable",innerType:n})}const hq=pe("ZodDefault",(n,e)=>{PU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>fW(n,t,s,r),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function gq(n,e){return new hq({type:"default",innerType:n,get defaultValue(){return typeof e=="function"?e():M5(e)}})}const xq=pe("ZodPrefault",(n,e)=>{$U.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>mW(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function bq(n,e){return new xq({type:"prefault",innerType:n,get defaultValue(){return typeof e=="function"?e():M5(e)}})}const IC=pe("ZodNonOptional",(n,e)=>{RU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>dW(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function vq(n,e){return new IC({type:"nonoptional",innerType:n,...Ye(e)})}const yq=pe("ZodCatch",(n,e)=>{OU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>pW(n,t,s,r),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function wq(n,e){return new yq({type:"catch",innerType:n,catchValue:typeof e=="function"?e:yD(e)})}const Sq=pe("ZodPipe",(n,e)=>{LU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>hW(n,t,s,r),n.in=e.in,n.out=e.out});function K2(n,e){return new Sq({type:"pipe",in:n,out:e})}const kq=pe("ZodReadonly",(n,e)=>{MU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>gW(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function jq(n){return new kq({type:"readonly",innerType:n})}const PC=pe("ZodCustom",(n,e)=>{zU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>nW(n,t,s,r)});function $C(n,e){return FB(PC,n??(()=>!0),e)}function Nq(n,e={}){return UB(PC,n,e)}function Cq(n,e){return BB(n,e)}var ku={exports:{}},op,G2;function Lc(){if(G2)return op;G2=1;const n="2.0.0",e=256,t=Number.MAX_SAFE_INTEGER||9007199254740991,s=16,r=e-6;return op={MAX_LENGTH:e,MAX_SAFE_COMPONENT_LENGTH:s,MAX_SAFE_BUILD_LENGTH:r,MAX_SAFE_INTEGER:t,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:n,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2},op}var ip,Z2;function Yf(){if(Z2)return ip;Z2=1;var n={};return ip=typeof process=="object"&&n&&n.NODE_DEBUG&&/\bsemver\b/i.test(n.NODE_DEBUG)?(...t)=>console.error("SEMVER",...t):()=>{},ip}var Y2;function Mc(){return Y2||(Y2=1,(function(n,e){const{MAX_SAFE_COMPONENT_LENGTH:t,MAX_SAFE_BUILD_LENGTH:s,MAX_LENGTH:r}=Lc(),o=Yf();e=n.exports={};const i=e.re=[],l=e.safeRe=[],c=e.src=[],u=e.safeSrc=[],d=e.t={};let f=0;const m="[a-zA-Z0-9-]",p=[["\\s",1],["\\d",r],[m,s]],h=x=>{for(const[b,w]of p)x=x.split(`${b}*`).join(`${b}{0,${w}}`).split(`${b}+`).join(`${b}{1,${w}}`);return x},g=(x,b,w)=>{const v=h(b),j=f++;o(x,j,b),d[x]=j,c[j]=b,u[j]=v,i[j]=new RegExp(b,w?"g":void 0),l[j]=new RegExp(v,w?"g":void 0)};g("NUMERICIDENTIFIER","0|[1-9]\\d*"),g("NUMERICIDENTIFIERLOOSE","\\d+"),g("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${m}*`),g("MAINVERSION",`(${c[d.NUMERICIDENTIFIER]})\\.(${c[d.NUMERICIDENTIFIER]})\\.(${c[d.NUMERICIDENTIFIER]})`),g("MAINVERSIONLOOSE",`(${c[d.NUMERICIDENTIFIERLOOSE]})\\.(${c[d.NUMERICIDENTIFIERLOOSE]})\\.(${c[d.NUMERICIDENTIFIERLOOSE]})`),g("PRERELEASEIDENTIFIER",`(?:${c[d.NONNUMERICIDENTIFIER]}|${c[d.NUMERICIDENTIFIER]})`),g("PRERELEASEIDENTIFIERLOOSE",`(?:${c[d.NONNUMERICIDENTIFIER]}|${c[d.NUMERICIDENTIFIERLOOSE]})`),g("PRERELEASE",`(?:-(${c[d.PRERELEASEIDENTIFIER]}(?:\\.${c[d.PRERELEASEIDENTIFIER]})*))`),g("PRERELEASELOOSE",`(?:-?(${c[d.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[d.PRERELEASEIDENTIFIERLOOSE]})*))`),g("BUILDIDENTIFIER",`${m}+`),g("BUILD",`(?:\\+(${c[d.BUILDIDENTIFIER]}(?:\\.${c[d.BUILDIDENTIFIER]})*))`),g("FULLPLAIN",`v?${c[d.MAINVERSION]}${c[d.PRERELEASE]}?${c[d.BUILD]}?`),g("FULL",`^${c[d.FULLPLAIN]}$`),g("LOOSEPLAIN",`[v=\\s]*${c[d.MAINVERSIONLOOSE]}${c[d.PRERELEASELOOSE]}?${c[d.BUILD]}?`),g("LOOSE",`^${c[d.LOOSEPLAIN]}$`),g("GTLT","((?:<|>)?=?)"),g("XRANGEIDENTIFIERLOOSE",`${c[d.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),g("XRANGEIDENTIFIER",`${c[d.NUMERICIDENTIFIER]}|x|X|\\*`),g("XRANGEPLAIN",`[v=\\s]*(${c[d.XRANGEIDENTIFIER]})(?:\\.(${c[d.XRANGEIDENTIFIER]})(?:\\.(${c[d.XRANGEIDENTIFIER]})(?:${c[d.PRERELEASE]})?${c[d.BUILD]}?)?)?`),g("XRANGEPLAINLOOSE",`[v=\\s]*(${c[d.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[d.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[d.XRANGEIDENTIFIERLOOSE]})(?:${c[d.PRERELEASELOOSE]})?${c[d.BUILD]}?)?)?`),g("XRANGE",`^${c[d.GTLT]}\\s*${c[d.XRANGEPLAIN]}$`),g("XRANGELOOSE",`^${c[d.GTLT]}\\s*${c[d.XRANGEPLAINLOOSE]}$`),g("COERCEPLAIN",`(^|[^\\d])(\\d{1,${t}})(?:\\.(\\d{1,${t}}))?(?:\\.(\\d{1,${t}}))?`),g("COERCE",`${c[d.COERCEPLAIN]}(?:$|[^\\d])`),g("COERCEFULL",c[d.COERCEPLAIN]+`(?:${c[d.PRERELEASE]})?(?:${c[d.BUILD]})?(?:$|[^\\d])`),g("COERCERTL",c[d.COERCE],!0),g("COERCERTLFULL",c[d.COERCEFULL],!0),g("LONETILDE","(?:~>?)"),g("TILDETRIM",`(\\s*)${c[d.LONETILDE]}\\s+`,!0),e.tildeTrimReplace="$1~",g("TILDE",`^${c[d.LONETILDE]}${c[d.XRANGEPLAIN]}$`),g("TILDELOOSE",`^${c[d.LONETILDE]}${c[d.XRANGEPLAINLOOSE]}$`),g("LONECARET","(?:\\^)"),g("CARETTRIM",`(\\s*)${c[d.LONECARET]}\\s+`,!0),e.caretTrimReplace="$1^",g("CARET",`^${c[d.LONECARET]}${c[d.XRANGEPLAIN]}$`),g("CARETLOOSE",`^${c[d.LONECARET]}${c[d.XRANGEPLAINLOOSE]}$`),g("COMPARATORLOOSE",`^${c[d.GTLT]}\\s*(${c[d.LOOSEPLAIN]})$|^$`),g("COMPARATOR",`^${c[d.GTLT]}\\s*(${c[d.FULLPLAIN]})$|^$`),g("COMPARATORTRIM",`(\\s*)${c[d.GTLT]}\\s*(${c[d.LOOSEPLAIN]}|${c[d.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace="$1$2$3",g("HYPHENRANGE",`^\\s*(${c[d.XRANGEPLAIN]})\\s+-\\s+(${c[d.XRANGEPLAIN]})\\s*$`),g("HYPHENRANGELOOSE",`^\\s*(${c[d.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[d.XRANGEPLAINLOOSE]})\\s*$`),g("STAR","(<|>)?=?\\s*\\*"),g("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),g("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")})(ku,ku.exports)),ku.exports}var ap,X2;function y0(){if(X2)return ap;X2=1;const n=Object.freeze({loose:!0}),e=Object.freeze({});return ap=s=>s?typeof s!="object"?n:s:e,ap}var lp,J2;function RC(){if(J2)return lp;J2=1;const n=/^[0-9]+$/,e=(s,r)=>{if(typeof s=="number"&&typeof r=="number")return s===r?0:s<r?-1:1;const o=n.test(s),i=n.test(r);return o&&i&&(s=+s,r=+r),s===r?0:o&&!i?-1:i&&!o?1:s<r?-1:1};return lp={compareIdentifiers:e,rcompareIdentifiers:(s,r)=>e(r,s)},lp}var cp,Q2;function Wn(){if(Q2)return cp;Q2=1;const n=Yf(),{MAX_LENGTH:e,MAX_SAFE_INTEGER:t}=Lc(),{safeRe:s,t:r}=Mc(),o=y0(),{compareIdentifiers:i}=RC(),l=(u,d)=>{const f=d.split(".");if(f.length>u.length)return!1;for(let m=0;m<f.length;m++)if(i(u[m],f[m])!==0)return!1;return!0};class c{constructor(d,f){if(f=o(f),d instanceof c){if(d.loose===!!f.loose&&d.includePrerelease===!!f.includePrerelease)return d;d=d.version}else if(typeof d!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof d}".`);if(d.length>e)throw new TypeError(`version is longer than ${e} characters`);n("SemVer",d,f),this.options=f,this.loose=!!f.loose,this.includePrerelease=!!f.includePrerelease;const m=d.trim().match(f.loose?s[r.LOOSE]:s[r.FULL]);if(!m)throw new TypeError(`Invalid Version: ${d}`);if(this.raw=d,this.major=+m[1],this.minor=+m[2],this.patch=+m[3],this.major>t||this.major<0)throw new TypeError("Invalid major version");if(this.minor>t||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>t||this.patch<0)throw new TypeError("Invalid patch version");m[4]?this.prerelease=m[4].split(".").map(p=>{if(/^[0-9]+$/.test(p)){const h=+p;if(h>=0&&h<t)return h}return p}):this.prerelease=[],this.build=m[5]?m[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(d){if(n("SemVer.compare",this.version,this.options,d),!(d instanceof c)){if(typeof d=="string"&&d===this.version)return 0;d=new c(d,this.options)}return d.version===this.version?0:this.compareMain(d)||this.comparePre(d)}compareMain(d){return d instanceof c||(d=new c(d,this.options)),this.major<d.major?-1:this.major>d.major?1:this.minor<d.minor?-1:this.minor>d.minor?1:this.patch<d.patch?-1:this.patch>d.patch?1:0}comparePre(d){if(d instanceof c||(d=new c(d,this.options)),this.prerelease.length&&!d.prerelease.length)return-1;if(!this.prerelease.length&&d.prerelease.length)return 1;if(!this.prerelease.length&&!d.prerelease.length)return 0;let f=0;do{const m=this.prerelease[f],p=d.prerelease[f];if(n("prerelease compare",f,m,p),m===void 0&&p===void 0)return 0;if(p===void 0)return 1;if(m===void 0)return-1;if(m===p)continue;return i(m,p)}while(++f)}compareBuild(d){d instanceof c||(d=new c(d,this.options));let f=0;do{const m=this.build[f],p=d.build[f];if(n("build compare",f,m,p),m===void 0&&p===void 0)return 0;if(p===void 0)return 1;if(m===void 0)return-1;if(m===p)continue;return i(m,p)}while(++f)}inc(d,f,m){if(d.startsWith("pre")){if(!f&&m===!1)throw new Error("invalid increment argument: identifier is empty");if(f){const p=`-${f}`.match(this.options.loose?s[r.PRERELEASELOOSE]:s[r.PRERELEASE]);if(!p||p[1]!==f)throw new Error(`invalid identifier: ${f}`)}}switch(d){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",f,m);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",f,m);break;case"prepatch":this.prerelease.length=0,this.inc("patch",f,m),this.inc("pre",f,m);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",f,m),this.inc("pre",f,m);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{const p=Number(m)?1:0;if(this.prerelease.length===0)this.prerelease=[p];else{let h=this.prerelease.length;for(;--h>=0;)typeof this.prerelease[h]=="number"&&(this.prerelease[h]++,h=-2);if(h===-1){if(f===this.prerelease.join(".")&&m===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(p)}}if(f){let h=[f,p];if(m===!1&&(h=[f]),l(this.prerelease,f)){const g=this.prerelease[f.split(".").length];isNaN(g)&&(this.prerelease=h)}else this.prerelease=h}break}default:throw new Error(`invalid increment argument: ${d}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}return cp=c,cp}var up,ew;function wi(){if(ew)return up;ew=1;const n=Wn();return up=(t,s,r=!1)=>{if(t instanceof n)return t;try{return new n(t,s)}catch(o){if(!r)return null;throw o}},up}var dp,tw;function _q(){if(tw)return dp;tw=1;const n=wi();return dp=(t,s)=>{const r=n(t,s);return r?r.version:null},dp}var fp,nw;function Eq(){if(nw)return fp;nw=1;const n=wi();return fp=(t,s)=>{const r=n(t.trim().replace(/^[=v]+/,""),s);return r?r.version:null},fp}var mp,sw;function Tq(){if(sw)return mp;sw=1;const n=Wn();return mp=(t,s,r,o,i)=>{typeof r=="string"&&(i=o,o=r,r=void 0);try{return new n(t instanceof n?t.version:t,r).inc(s,o,i).version}catch{return null}},mp}var pp,rw;function Aq(){if(rw)return pp;rw=1;const n=wi();return pp=(t,s)=>{const r=n(t,null,!0),o=n(s,null,!0),i=r.compare(o);if(i===0)return null;const l=i>0,c=l?r:o,u=l?o:r,d=!!c.prerelease.length;if(!!u.prerelease.length&&!d){if(!u.patch&&!u.minor)return"major";if(u.compareMain(c)===0)return u.minor&&!u.patch?"minor":"patch"}const m=d?"pre":"";return r.major!==o.major?m+"major":r.minor!==o.minor?m+"minor":r.patch!==o.patch?m+"patch":"prerelease"},pp}var hp,ow;function Iq(){if(ow)return hp;ow=1;const n=Wn();return hp=(t,s)=>new n(t,s).major,hp}var gp,iw;function Pq(){if(iw)return gp;iw=1;const n=Wn();return gp=(t,s)=>new n(t,s).minor,gp}var xp,aw;function $q(){if(aw)return xp;aw=1;const n=Wn();return xp=(t,s)=>new n(t,s).patch,xp}var bp,lw;function Rq(){if(lw)return bp;lw=1;const n=wi();return bp=(t,s)=>{const r=n(t,s);return r&&r.prerelease.length?r.prerelease:null},bp}var vp,cw;function ar(){if(cw)return vp;cw=1;const n=Wn();return vp=(t,s,r)=>new n(t,r).compare(new n(s,r)),vp}var yp,uw;function Oq(){if(uw)return yp;uw=1;const n=ar();return yp=(t,s,r)=>n(s,t,r),yp}var wp,dw;function Lq(){if(dw)return wp;dw=1;const n=ar();return wp=(t,s)=>n(t,s,!0),wp}var Sp,fw;function w0(){if(fw)return Sp;fw=1;const n=Wn();return Sp=(t,s,r)=>{const o=new n(t,r),i=new n(s,r);return o.compare(i)||o.compareBuild(i)},Sp}var kp,mw;function Mq(){if(mw)return kp;mw=1;const n=w0();return kp=(t,s)=>t.sort((r,o)=>n(r,o,s)),kp}var jp,pw;function zq(){if(pw)return jp;pw=1;const n=w0();return jp=(t,s)=>t.sort((r,o)=>n(o,r,s)),jp}var Np,hw;function Xf(){if(hw)return Np;hw=1;const n=ar();return Np=(t,s,r)=>n(t,s,r)>0,Np}var Cp,gw;function S0(){if(gw)return Cp;gw=1;const n=ar();return Cp=(t,s,r)=>n(t,s,r)<0,Cp}var _p,xw;function OC(){if(xw)return _p;xw=1;const n=ar();return _p=(t,s,r)=>n(t,s,r)===0,_p}var Ep,bw;function LC(){if(bw)return Ep;bw=1;const n=ar();return Ep=(t,s,r)=>n(t,s,r)!==0,Ep}var Tp,vw;function k0(){if(vw)return Tp;vw=1;const n=ar();return Tp=(t,s,r)=>n(t,s,r)>=0,Tp}var Ap,yw;function j0(){if(yw)return Ap;yw=1;const n=ar();return Ap=(t,s,r)=>n(t,s,r)<=0,Ap}var Ip,ww;function MC(){if(ww)return Ip;ww=1;const n=OC(),e=LC(),t=Xf(),s=k0(),r=S0(),o=j0();return Ip=(l,c,u,d)=>{switch(c){case"===":return typeof l=="object"&&(l=l.version),typeof u=="object"&&(u=u.version),l===u;case"!==":return typeof l=="object"&&(l=l.version),typeof u=="object"&&(u=u.version),l!==u;case"":case"=":case"==":return n(l,u,d);case"!=":return e(l,u,d);case">":return t(l,u,d);case">=":return s(l,u,d);case"<":return r(l,u,d);case"<=":return o(l,u,d);default:throw new TypeError(`Invalid operator: ${c}`)}},Ip}var Pp,Sw;function Dq(){if(Sw)return Pp;Sw=1;const n=Wn(),e=wi(),{safeRe:t,t:s}=Mc();return Pp=(o,i)=>{if(o instanceof n)return o;if(typeof o=="number"&&(o=String(o)),typeof o!="string")return null;i=i||{};let l=null;if(!i.rtl)l=o.match(i.includePrerelease?t[s.COERCEFULL]:t[s.COERCE]);else{const p=i.includePrerelease?t[s.COERCERTLFULL]:t[s.COERCERTL];let h;for(;(h=p.exec(o))&&(!l||l.index+l[0].length!==o.length);)(!l||h.index+h[0].length!==l.index+l[0].length)&&(l=h),p.lastIndex=h.index+h[1].length+h[2].length;p.lastIndex=-1}if(l===null)return null;const c=l[2],u=l[3]||"0",d=l[4]||"0",f=i.includePrerelease&&l[5]?`-${l[5]}`:"",m=i.includePrerelease&&l[6]?`+${l[6]}`:"";return e(`${c}.${u}.${d}${f}${m}`,i)},Pp}var $p,kw;function Fq(){if(kw)return $p;kw=1;const n=wi(),e=Lc(),t=Wn(),s=(l,c,u)=>{if(!e.RELEASE_TYPES.includes(c))return null;const d=r(l,u);return d&&o(d,c)},r=(l,c)=>{const u=l instanceof t?l.version:l;return n(u,c)},o=(l,c)=>{if(i(c))return l.version;switch(l.prerelease=[],c){case"major":l.minor=0,l.patch=0;break;case"minor":l.patch=0;break}return l.format()},i=l=>l.startsWith("pre");return $p=s,$p}var Rp,jw;function Uq(){if(jw)return Rp;jw=1;class n{constructor(){this.max=1e3,this.map=new Map}get(t){const s=this.map.get(t);if(s!==void 0)return this.map.delete(t),this.map.set(t,s),s}delete(t){return this.map.delete(t)}set(t,s){if(!this.delete(t)&&s!==void 0){if(this.map.size>=this.max){const o=this.map.keys().next().value;this.delete(o)}this.map.set(t,s)}return this}}return Rp=n,Rp}var Op,Nw;function lr(){if(Nw)return Op;Nw=1;const n=/\s+/g;class e{constructor(I,M){if(M=r(M),I instanceof e)return I.loose===!!M.loose&&I.includePrerelease===!!M.includePrerelease?I:new e(I.raw,M);if(I instanceof o)return this.raw=I.value,this.set=[[I]],this.formatted=void 0,this;if(this.options=M,this.loose=!!M.loose,this.includePrerelease=!!M.includePrerelease,this.raw=I.trim().replace(n," "),this.set=this.raw.split("||").map(F=>this.parseRange(F.trim())).filter(F=>F.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const F=this.set[0];if(this.set=this.set.filter(U=>!b(U[0])),this.set.length===0)this.set=[F];else if(this.set.length>1){for(const U of this.set)if(U.length===1&&w(U[0])){this.set=[U];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let I=0;I<this.set.length;I++){I>0&&(this.formatted+="||");const M=this.set[I];for(let F=0;F<M.length;F++)F>0&&(this.formatted+=" "),this.formatted+=M[F].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(I){I=I.replace(x,"");const F=((this.options.includePrerelease&&h)|(this.options.loose&&g))+":"+I,U=s.get(F);if(U)return U;const O=this.options.loose,D=O?c[d.HYPHENRANGELOOSE]:c[d.HYPHENRANGE];I=I.replace(D,P(this.options.includePrerelease)),i("hyphen replace",I),I=I.replace(c[d.COMPARATORTRIM],f),i("comparator trim",I),I=I.replace(c[d.TILDETRIM],m),i("tilde trim",I),I=I.replace(c[d.CARETTRIM],p),i("caret trim",I);let B=I.split(" ").map(K=>j(K,this.options)).join(" ").split(/\s+/).map(K=>R(K,this.options));O&&(B=B.filter(K=>(i("loose invalid filter",K,this.options),!!K.match(c[d.COMPARATORLOOSE])))),i("range list",B);const q=new Map,W=B.map(K=>new o(K,this.options));for(const K of W){if(b(K))return[K];q.set(K.value,K)}q.size>1&&q.has("")&&q.delete("");const H=[...q.values()];return s.set(F,H),H}intersects(I,M){if(!(I instanceof e))throw new TypeError("a Range is required");return this.set.some(F=>v(F,M)&&I.set.some(U=>v(U,M)&&F.every(O=>U.every(D=>O.intersects(D,M)))))}test(I){if(!I)return!1;if(typeof I=="string")try{I=new l(I,this.options)}catch{return!1}for(let M=0;M<this.set.length;M++)if(z(this.set[M],I,this.options))return!0;return!1}}Op=e;const t=Uq(),s=new t,r=y0(),o=Jf(),i=Yf(),l=Wn(),{safeRe:c,src:u,t:d,comparatorTrimReplace:f,tildeTrimReplace:m,caretTrimReplace:p}=Mc(),{FLAG_INCLUDE_PRERELEASE:h,FLAG_LOOSE:g}=Lc(),x=new RegExp(u[d.BUILD],"g"),b=L=>L.value==="<0.0.0-0",w=L=>L.value==="",v=(L,I)=>{let M=!0;const F=L.slice();let U=F.pop();for(;M&&F.length;)M=F.every(O=>U.intersects(O,I)),U=F.pop();return M},j=(L,I)=>(L=L.replace(c[d.BUILD],""),i("comp",L,I),L=C(L,I),i("caret",L),L=N(L,I),i("tildes",L),L=T(L,I),i("xrange",L),L=A(L,I),i("stars",L),L),k=L=>!L||L.toLowerCase()==="x"||L==="*",_=(L,I,M)=>k(L)&&!k(I)||k(I)&&M&&!k(M),N=(L,I)=>L.trim().split(/\s+/).map(M=>S(M,I)).join(" "),S=(L,I)=>{const M=I.loose?c[d.TILDELOOSE]:c[d.TILDE],F=I.includePrerelease?"-0":"";return L.replace(M,(U,O,D,B,q)=>{i("tilde",L,U,O,D,B,q);let W;return k(O)?W="":k(D)?W=`>=${O}.0.0${F} <${+O+1}.0.0-0`:k(B)?W=`>=${O}.${D}.0${F} <${O}.${+D+1}.0-0`:q?(i("replaceTilde pr",q),W=`>=${O}.${D}.${B}-${q} <${O}.${+D+1}.0-0`):W=`>=${O}.${D}.${B} <${O}.${+D+1}.0-0`,i("tilde return",W),W})},C=(L,I)=>L.trim().split(/\s+/).map(M=>E(M,I)).join(" "),E=(L,I)=>{i("caret",L,I);const M=I.loose?c[d.CARETLOOSE]:c[d.CARET],F=I.includePrerelease?"-0":"";return L.replace(M,(U,O,D,B,q)=>{i("caret",L,U,O,D,B,q);let W;return k(O)?W="":k(D)?W=`>=${O}.0.0${F} <${+O+1}.0.0-0`:k(B)?O==="0"?W=`>=${O}.${D}.0${F} <${O}.${+D+1}.0-0`:W=`>=${O}.${D}.0${F} <${+O+1}.0.0-0`:q?(i("replaceCaret pr",q),O==="0"?D==="0"?W=`>=${O}.${D}.${B}-${q} <${O}.${D}.${+B+1}-0`:W=`>=${O}.${D}.${B}-${q} <${O}.${+D+1}.0-0`:W=`>=${O}.${D}.${B}-${q} <${+O+1}.0.0-0`):(i("no pr"),O==="0"?D==="0"?W=`>=${O}.${D}.${B} <${O}.${D}.${+B+1}-0`:W=`>=${O}.${D}.${B} <${O}.${+D+1}.0-0`:W=`>=${O}.${D}.${B} <${+O+1}.0.0-0`),i("caret return",W),W})},T=(L,I)=>(i("replaceXRanges",L,I),L.split(/\s+/).map(M=>$(M,I)).join(" ")),$=(L,I)=>{L=L.trim();const M=I.loose?c[d.XRANGELOOSE]:c[d.XRANGE];return L.replace(M,(F,U,O,D,B,q)=>{if(i("xRange",L,F,U,O,D,B,q),_(O,D,B))return L;const W=k(O),H=W||k(D),K=H||k(B),Z=K;return U==="="&&Z&&(U=""),q=I.includePrerelease?"-0":"",W?U===">"||U==="<"?F="<0.0.0-0":F="*":U&&Z?(H&&(D=0),B=0,U===">"?(U=">=",H?(O=+O+1,D=0,B=0):(D=+D+1,B=0)):U==="<="&&(U="<",H?O=+O+1:D=+D+1),U==="<"&&(q="-0"),F=`${U+O}.${D}.${B}${q}`):H?F=`>=${O}.0.0${q} <${+O+1}.0.0-0`:K&&(F=`>=${O}.${D}.0${q} <${O}.${+D+1}.0-0`),i("xRange return",F),F})},A=(L,I)=>(i("replaceStars",L,I),L.trim().replace(c[d.STAR],"")),R=(L,I)=>(i("replaceGTE0",L,I),L.trim().replace(c[I.includePrerelease?d.GTE0PRE:d.GTE0],"")),P=L=>(I,M,F,U,O,D,B,q,W,H,K,Z)=>(k(F)?M="":k(U)?M=`>=${F}.0.0${L?"-0":""}`:k(O)?M=`>=${F}.${U}.0${L?"-0":""}`:D?M=`>=${M}`:M=`>=${M}${L?"-0":""}`,k(W)?q="":k(H)?q=`<${+W+1}.0.0-0`:k(K)?q=`<${W}.${+H+1}.0-0`:Z?q=`<=${W}.${H}.${K}-${Z}`:L?q=`<${W}.${H}.${+K+1}-0`:q=`<=${q}`,`${M} ${q}`.trim()),z=(L,I,M)=>{for(let F=0;F<L.length;F++)if(!L[F].test(I))return!1;if(I.prerelease.length&&!M.includePrerelease){for(let F=0;F<L.length;F++)if(i(L[F].semver),L[F].semver!==o.ANY&&L[F].semver.prerelease.length>0){const U=L[F].semver;if(U.major===I.major&&U.minor===I.minor&&U.patch===I.patch)return!0}return!1}return!0};return Op}var Lp,Cw;function Jf(){if(Cw)return Lp;Cw=1;const n=Symbol("SemVer ANY");class e{static get ANY(){return n}constructor(d,f){if(f=t(f),d instanceof e){if(d.loose===!!f.loose)return d;d=d.value}d=d.trim().split(/\s+/).join(" "),i("comparator",d,f),this.options=f,this.loose=!!f.loose,this.parse(d),this.semver===n?this.value="":this.value=this.operator+this.semver.version,i("comp",this)}parse(d){const f=this.options.loose?s[r.COMPARATORLOOSE]:s[r.COMPARATOR],m=d.match(f);if(!m)throw new TypeError(`Invalid comparator: ${d}`);this.operator=m[1]!==void 0?m[1]:"",this.operator==="="&&(this.operator=""),m[2]?this.semver=new l(m[2],this.options.loose):this.semver=n}toString(){return this.value}test(d){if(i("Comparator.test",d,this.options.loose),this.semver===n||d===n)return!0;if(typeof d=="string")try{d=new l(d,this.options)}catch{return!1}return o(d,this.operator,this.semver,this.options)}intersects(d,f){if(!(d instanceof e))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new c(d.value,f).test(this.value):d.operator===""?d.value===""?!0:new c(this.value,f).test(d.semver):(f=t(f),f.includePrerelease&&(this.value==="<0.0.0-0"||d.value==="<0.0.0-0")||!f.includePrerelease&&(this.value.startsWith("<0.0.0")||d.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&d.operator.startsWith(">")||this.operator.startsWith("<")&&d.operator.startsWith("<")||this.semver.version===d.semver.version&&this.operator.includes("=")&&d.operator.includes("=")||o(this.semver,"<",d.semver,f)&&this.operator.startsWith(">")&&d.operator.startsWith("<")||o(this.semver,">",d.semver,f)&&this.operator.startsWith("<")&&d.operator.startsWith(">")))}}Lp=e;const t=y0(),{safeRe:s,t:r}=Mc(),o=MC(),i=Yf(),l=Wn(),c=lr();return Lp}var Mp,_w;function Qf(){if(_w)return Mp;_w=1;const n=lr();return Mp=(t,s,r)=>{try{s=new n(s,r)}catch{return!1}return s.test(t)},Mp}var zp,Ew;function Bq(){if(Ew)return zp;Ew=1;const n=lr();return zp=(t,s)=>new n(t,s).set.map(r=>r.map(o=>o.value).join(" ").trim().split(" ")),zp}var Dp,Tw;function Wq(){if(Tw)return Dp;Tw=1;const n=Wn(),e=lr();return Dp=(s,r,o)=>{let i=null,l=null,c=null;try{c=new e(r,o)}catch{return null}return s.forEach(u=>{c.test(u)&&(!i||l.compare(u)===-1)&&(i=u,l=new n(i,o))}),i},Dp}var Fp,Aw;function qq(){if(Aw)return Fp;Aw=1;const n=Wn(),e=lr();return Fp=(s,r,o)=>{let i=null,l=null,c=null;try{c=new e(r,o)}catch{return null}return s.forEach(u=>{c.test(u)&&(!i||l.compare(u)===1)&&(i=u,l=new n(i,o))}),i},Fp}var Up,Iw;function Vq(){if(Iw)return Up;Iw=1;const n=Wn(),e=lr(),t=Xf();return Up=(r,o)=>{r=new e(r,o);let i=new n("0.0.0");if(r.test(i)||(i=new n("0.0.0-0"),r.test(i)))return i;i=null;for(let l=0;l<r.set.length;++l){const c=r.set[l];let u=null;c.forEach(d=>{const f=new n(d.semver.version);switch(d.operator){case">":f.prerelease.length===0?f.patch++:f.prerelease.push(0),f.raw=f.format();case"":case">=":(!u||t(f,u))&&(u=f);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${d.operator}`)}}),u&&(!i||t(i,u))&&(i=u)}return i&&r.test(i)?i:null},Up}var Bp,Pw;function Hq(){if(Pw)return Bp;Pw=1;const n=lr();return Bp=(t,s)=>{try{return new n(t,s).range||"*"}catch{return null}},Bp}var Wp,$w;function N0(){if($w)return Wp;$w=1;const n=Wn(),e=Jf(),{ANY:t}=e,s=lr(),r=Qf(),o=Xf(),i=S0(),l=j0(),c=k0();return Wp=(d,f,m,p)=>{d=new n(d,p),f=new s(f,p);let h,g,x,b,w;switch(m){case">":h=o,g=l,x=i,b=">",w=">=";break;case"<":h=i,g=c,x=o,b="<",w="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(r(d,f,p))return!1;for(let v=0;v<f.set.length;++v){const j=f.set[v];let k=null,_=null;if(j.forEach(N=>{N.semver===t&&(N=new e(">=0.0.0")),k=k||N,_=_||N,h(N.semver,k.semver,p)?k=N:x(N.semver,_.semver,p)&&(_=N)}),k.operator===b||k.operator===w||(!_.operator||_.operator===b)&&g(d,_.semver))return!1;if(_.operator===w&&x(d,_.semver))return!1}return!0},Wp}var qp,Rw;function Kq(){if(Rw)return qp;Rw=1;const n=N0();return qp=(t,s,r)=>n(t,s,">",r),qp}var Vp,Ow;function Gq(){if(Ow)return Vp;Ow=1;const n=N0();return Vp=(t,s,r)=>n(t,s,"<",r),Vp}var Hp,Lw;function Zq(){if(Lw)return Hp;Lw=1;const n=lr();return Hp=(t,s,r)=>(t=new n(t,r),s=new n(s,r),t.intersects(s,r)),Hp}var Kp,Mw;function Yq(){if(Mw)return Kp;Mw=1;const n=Qf(),e=ar();return Kp=(t,s,r)=>{const o=[];let i=null,l=null;const c=t.sort((m,p)=>e(m,p,r));for(const m of c)n(m,s,r)?(l=m,i||(i=m)):(l&&o.push([i,l]),l=null,i=null);i&&o.push([i,null]);const u=[];for(const[m,p]of o)m===p?u.push(m):!p&&m===c[0]?u.push("*"):p?m===c[0]?u.push(`<=${p}`):u.push(`${m} - ${p}`):u.push(`>=${m}`);const d=u.join(" || "),f=typeof s.raw=="string"?s.raw:String(s);return d.length<f.length?d:s},Kp}var Gp,zw;function Xq(){if(zw)return Gp;zw=1;const n=lr(),e=Jf(),{ANY:t}=e,s=Qf(),r=ar(),o=(f,m,p={})=>{if(f===m)return!0;f=new n(f,p),m=new n(m,p);let h=!1;e:for(const g of f.set){for(const x of m.set){const b=c(g,x,p);if(h=h||b!==null,b)continue e}if(h)return!1}return!0},i=[new e(">=0.0.0-0")],l=[new e(">=0.0.0")],c=(f,m,p)=>{if(f===m)return!0;if(f.length===1&&f[0].semver===t){if(m.length===1&&m[0].semver===t)return!0;p.includePrerelease?f=i:f=l}if(m.length===1&&m[0].semver===t){if(p.includePrerelease)return!0;m=l}const h=new Set;let g,x;for(const S of f)S.operator===">"||S.operator===">="?g=u(g,S,p):S.operator==="<"||S.operator==="<="?x=d(x,S,p):h.add(S.semver);if(h.size>1)return null;let b;if(g&&x){if(b=r(g.semver,x.semver,p),b>0)return null;if(b===0&&(g.operator!==">="||x.operator!=="<="))return null}for(const S of h){if(g&&!s(S,String(g),p)||x&&!s(S,String(x),p))return null;for(const C of m)if(!s(S,String(C),p))return!1;return!0}let w,v,j,k,_=x&&!p.includePrerelease&&x.semver.prerelease.length?x.semver:!1,N=g&&!p.includePrerelease&&g.semver.prerelease.length?g.semver:!1;_&&_.prerelease.length===1&&x.operator==="<"&&_.prerelease[0]===0&&(_=!1);for(const S of m){if(k=k||S.operator===">"||S.operator===">=",j=j||S.operator==="<"||S.operator==="<=",g){if(N&&S.semver.prerelease&&S.semver.prerelease.length&&S.semver.major===N.major&&S.semver.minor===N.minor&&S.semver.patch===N.patch&&(N=!1),S.operator===">"||S.operator===">="){if(w=u(g,S,p),w===S&&w!==g)return!1}else if(g.operator===">="&&!S.test(g.semver))return!1}if(x){if(_&&S.semver.prerelease&&S.semver.prerelease.length&&S.semver.major===_.major&&S.semver.minor===_.minor&&S.semver.patch===_.patch&&(_=!1),S.operator==="<"||S.operator==="<="){if(v=d(x,S,p),v===S&&v!==x)return!1}else if(x.operator==="<="&&!S.test(x.semver))return!1}if(!S.operator&&(x||g)&&b!==0)return!1}return!(g&&j&&!x&&b!==0||x&&k&&!g&&b!==0||N||_)},u=(f,m,p)=>{if(!f)return m;const h=r(f.semver,m.semver,p);return h>0?f:h<0||m.operator===">"&&f.operator===">="?m:f},d=(f,m,p)=>{if(!f)return m;const h=r(f.semver,m.semver,p);return h<0?f:h>0||m.operator==="<"&&f.operator==="<="?m:f};return Gp=o,Gp}var Zp,Dw;function Jq(){if(Dw)return Zp;Dw=1;const n=Mc(),e=Lc(),t=Wn(),s=RC(),r=wi(),o=_q(),i=Eq(),l=Tq(),c=Aq(),u=Iq(),d=Pq(),f=$q(),m=Rq(),p=ar(),h=Oq(),g=Lq(),x=w0(),b=Mq(),w=zq(),v=Xf(),j=S0(),k=OC(),_=LC(),N=k0(),S=j0(),C=MC(),E=Dq(),T=Fq(),$=Jf(),A=lr(),R=Qf(),P=Bq(),z=Wq(),L=qq(),I=Vq(),M=Hq(),F=N0(),U=Kq(),O=Gq(),D=Zq(),B=Yq(),q=Xq();return Zp={parse:r,valid:o,clean:i,inc:l,diff:c,major:u,minor:d,patch:f,prerelease:m,compare:p,rcompare:h,compareLoose:g,compareBuild:x,sort:b,rsort:w,gt:v,lt:j,eq:k,neq:_,gte:N,lte:S,cmp:C,coerce:E,truncate:T,Comparator:$,Range:A,satisfies:R,toComparators:P,maxSatisfying:z,minSatisfying:L,minVersion:I,validRange:M,outside:F,gtr:U,ltr:O,intersects:D,simplifyRange:B,subset:q,SemVer:t,re:n.re,src:n.src,tokens:n.t,SEMVER_SPEC_VERSION:e.SEMVER_SPEC_VERSION,RELEASE_TYPES:e.RELEASE_TYPES,compareIdentifiers:s.compareIdentifiers,rcompareIdentifiers:s.rcompareIdentifiers},Zp}var Vn=Jq();const lt=Le().min(1).max(64).regex(/^[a-zA-Z][a-zA-Z0-9_.-]*$/u).refine(n=>!["constructor","prototype","__proto__"].includes(n),"Reserved identifier"),_s=Le().min(1).max(128).refine(n=>[...n].every(e=>e.charCodeAt(0)>=32&&e.charCodeAt(0)!==127),"Control characters are forbidden"),Cs=n=>Le().refine(e=>Pl(e)<=n,"Text exceeds byte limit"),il=Le().min(1).max(256).refine(n=>/^[A-Za-z0-9_./-]+$/u.test(n)?n.split("/").every(e=>e!==""&&e!=="."&&e!==".."&&!e.endsWith(".")&&!/^(?:con|prn|aux|nul|com[0-9]|lpt[0-9])(?:\.|$)/iu.test(e)):!1,"Expected a canonical portable package path");function zo(n,e,t,s){const r=n.safeParse(i0(e,{maxBytes:t,maxNodes:s}));if(!r.success)throw new tc(r.error.issues.map(o=>({path:o.path.length?`$.${o.path.map(String).join(".")}`:"$",message:o.message})));return r.data}const Qq=["actions","actionJobs","pulls","pullFiles","pullSessions","issues","mergePull"],eV=["deployments","buildLogs"],tV=["workspace","deployments","version"],Yp=n=>at(Ct(n)).min(1).max(n.length).refine(e=>new Set(e).size===e.length,"Duplicate operation"),nV=Rr("id",[xe({id:Ze("github"),operations:Yp(Qq)}),xe({id:Ze("vercel"),operations:Yp(eV)}),xe({id:Ze("cloudflare"),operations:Yp(tV)})]),Br=bt().int().positive().max(Number.MAX_SAFE_INTEGER),Qo={integration:Ze("github")},Fw={integration:Ze("vercel")},Xp={integration:Ze("cloudflare")},Uw=Le().regex(/^[A-Za-z0-9_-]+$/).max(64).optional(),Jp=Le().max(240).regex(/^(?:[^/\\]+\/)*wrangler\.(?:json|jsonc|toml)$/).refine(n=>n.split("/").every(e=>e!=="."&&e!==".."),"Invalid configuration path").optional(),sV=Rr("operation",[xe({...Qo,operation:Ze("actions"),limit:Br.max(30).optional()}),xe({...Qo,operation:Ze("actionJobs"),runId:Br}),xe({...Qo,operation:Ze("pulls"),limit:Br.max(50).optional()}),xe({...Qo,operation:Ze("pullFiles"),number:Br}),xe({...Qo,operation:Ze("pullSessions")}),xe({...Qo,operation:Ze("issues"),limit:Br.max(50).optional()}),xe({...Qo,operation:Ze("mergePull"),number:Br,method:Ct(["merge","squash","rebase"]),headSha:Le().regex(/^[0-9a-f]{40}$/)})]),rV=Rr("operation",[xe({...Fw,operation:Ze("deployments"),limit:Br.max(30).optional()}),xe({...Fw,operation:Ze("buildLogs"),deploymentId:Le().regex(/^dpl_[A-Za-z0-9]+$/).max(128),limit:Br.max(500).optional()})]),oV=Rr("operation",[xe({...Xp,operation:Ze("workspace"),config:Jp}),xe({...Xp,operation:Ze("deployments"),config:Jp,environment:Uw,limit:Br.max(30).optional()}),xe({...Xp,operation:Ze("version"),config:Jp,environment:Uw,versionId:Le().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/)})]),iV=Rr("integration",[sV,rV,oV]),aV=Rr("ok",[xe({ok:Ze(!0),data:$C(()=>!0)}),xe({ok:Ze(!1),error:xe({code:Le().min(1).max(64),message:Le().min(1).max(512)})})]),ju={id:lt,label:_s,description:Cs(512).optional()},lV=Rr("type",[xe({...ju,type:Ze("string"),default:Cs(4096).default(""),maxLength:bt().int().min(1).max(4096).default(256)}),xe({...ju,type:Ze("boolean"),default:Ft().default(!1)}),xe({...ju,type:Ze("number"),default:bt().finite(),min:bt().finite(),max:bt().finite(),step:bt().positive().optional()}),xe({...ju,type:Ze("select"),default:Cs(256),options:at(xe({value:Cs(256),label:_s})).min(1).max(64)})]).superRefine((n,e)=>{n.type==="number"&&(n.min>n.max||n.default<n.min||n.default>n.max)&&e.addIssue({code:"custom",message:"Invalid numeric setting bounds/default"}),n.type==="string"&&n.default.length>n.maxLength&&e.addIssue({code:"custom",message:"Default exceeds setting length"}),n.type==="select"&&(!n.options.some(t=>t.value===n.default)||new Set(n.options.map(t=>t.value)).size!==n.options.length)&&e.addIssue({code:"custom",message:"Invalid select options/default"})}),cV=xe({scope:Ct(["plugin","project"]),fields:at(lV).min(1).max(32).refine(n=>new Set(n.map(e=>e.id)).size===n.length,"Duplicate setting ID")}).refine(n=>new TextEncoder().encode(JSON.stringify(Object.fromEntries(n.fields.map(e=>[e.id,e.default])))).byteLength<=16384,"Default settings exceed 16 KiB"),uV=xe({id:lt,title:_s,description:Cs(512),source:il.refine(n=>n.endsWith(".md"),"Skill source must be Markdown")}),dV=xe({id:Le().regex(/^[a-z][a-z0-9-]{0,63}$/u),title:_s,height:bt().int().min(80).max(800).default(240)}),fV=xe({id:lt,title:_s,skill:lt,prompt:Cs(4096).refine(n=>n.trim().length>0,"Action prompt is required")});function k2e(n,e){const t={};for(const s of n.fields)t[s.id]=s.type==="string"?Le().max(s.maxLength).default(s.default):s.type==="boolean"?Ft().default(s.default):s.type==="number"?bt().finite().min(s.min).max(s.max).default(s.default):Ct(s.options.map(r=>r.value)).default(s.default);return xe(t).parse(e)}function zC(n){const e=n==null?void 0:n.match(/^cogpit:([a-z][a-z0-9-]*\.[a-z][a-z0-9-]*):([a-z][a-z0-9-]{0,63})$/u);return e?{pluginId:e[1],blockId:e[2]}:null}const Ss=1,mV="1.2.0",DC="browser-iife-v1",Kg=Le().max(128).refine(n=>Vn.valid(n)===n,"Expected strict SemVer"),cd=Le().min(1).max(256).refine(n=>Vn.validRange(n)!==null,"Expected a SemVer range"),Bw=Xn(lt,cd).refine(n=>Object.keys(n).length<=32,"Too many capabilities"),Ww=xe({client:Bw,host:Bw}),al=n=>new Set(n).size===n.length,pV=at(lt).max(32).refine(al,"Duplicate identifier"),qw=Le().min(1).max(64).regex(/^[a-z][a-z0-9-]*$/u),Qp=Le().regex(/^(?:[1-9][0-9]{0,3}px|(?:[1-9][0-9]?|100)%)$/u),hV=xe({manifestVersion:Ze(1),id:Le().max(128).regex(/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$/u),publisher:qw,name:_s,version:Kg,runtime:Ze(DC),entry:il.refine(n=>n.endsWith(".js"),"Entry must be JavaScript").optional(),style:il.refine(n=>n.endsWith(".css"),"Style must be CSS").optional(),engines:xe({pluginApi:cd,client:cd,host:cd}),protocol:Ze(Ss).default(Ss),requires:Ww,optional:Ww.default({client:{},host:{}}),browser:at(Ct(["message-channel","blob-script","web-crypto"])).max(3).refine(al).default([]),contributes:xe({panels:at(xe({id:qw,title:_s,icon:il.refine(n=>/\.(png|jpe?g|webp)$/u.test(n),"Expected a raster icon"),order:bt().int().min(0).max(1e3).optional(),defaultSize:Qp.optional(),minSize:Qp.optional(),maxSize:Qp.optional(),when:Ct(["always","project-selected"]).default("project-selected")})).max(8).default([]),settings:cV.optional(),skills:at(uV).max(16).optional(),chatBlocks:at(dV).max(8).optional(),sessionActions:at(fV).max(8).optional()}),permissions:xe({context:at(Ct(["project.identity","session.identity"])).max(2).refine(al).default([]),composer:at(Ze("append")).max(1).default([]),navigation:at(Ct(["external","session"])).max(2).refine(al).default([]),connections:at(xe({id:lt,definition:il,operations:pV.min(1)})).max(8).default([]),integrations:at(nV).max(2).default([]),storage:xe({scope:Ct(["project","plugin"]),quotaKiB:bt().int().min(1).max(1024)}).optional()}),stateVersion:bt().int().min(1).max(Number.MAX_SAFE_INTEGER)}).superRefine((n,e)=>{var t,s,r,o;!n.contributes.panels.length&&!((t=n.contributes.skills)!=null&&t.length)&&!((s=n.contributes.chatBlocks)!=null&&s.length)&&!n.contributes.settings&&e.addIssue({code:"custom",path:["contributes"],message:"At least one contribution is required"}),(n.contributes.panels.length||(r=n.contributes.chatBlocks)!=null&&r.length)&&!n.entry&&e.addIssue({code:"custom",path:["entry"],message:"Visual contributions require a JavaScript entry"}),n.style&&!n.entry&&e.addIssue({code:"custom",path:["style"],message:"Styles require a JavaScript entry"});for(const i of n.contributes.sessionActions??[])(o=n.contributes.skills)!=null&&o.some(l=>l.id===i.skill)||e.addIssue({code:"custom",path:["contributes","sessionActions"],message:"Session actions must reference a declared skill"});n.id.startsWith(`${n.publisher}.`)||e.addIssue({code:"custom",path:["id"],message:"Plugin ID must belong to its publisher"}),["cogpit.worktrees","cogpit.project-files","cogpit.browser","cogpit.file-changes","cogpit.session-info"].includes(n.id)&&e.addIssue({code:"custom",path:["id"],message:"Reserved built-in ID"});for(const[i,l]of[["panels",n.contributes.panels],["skills",n.contributes.skills??[]],["chatBlocks",n.contributes.chatBlocks??[]],["sessionActions",n.contributes.sessionActions??[]],["connections",n.permissions.connections],["integrations",n.permissions.integrations]])al(l.map(c=>c.id))||e.addIssue({code:"custom",path:[i],message:"Duplicate contribution ID"});for(const i of["client","host"])for(const l of Object.keys(n.optional[i]))Object.hasOwn(n.requires[i],l)&&e.addIssue({code:"custom",path:["optional",i,l],message:"Capability is already required"})});function FC(n){return zo(hV,n,Qt.manifestBytes)}const C0=8*1024*1024,UC=Ct(["audio/mpeg","audio/wav","audio/flac","audio/ogg","audio/opus","audio/aac"]);function em(n){var r,o;if(!n||typeof n!="object"||Object.keys(n).length!==2)throw new tc([{path:"$",message:"Invalid media response"}]);const e=Object.getOwnPropertyDescriptors(n),t=UC.safeParse((r=e.mimeType)==null?void 0:r.value),s=(o=e.bytes)==null?void 0:o.value;if(!t.success||!(s instanceof ArrayBuffer)||s.byteLength===0||s.byteLength>C0)throw new tc([{path:"$",message:"Invalid or oversized audio response"}]);return{mimeType:t.data,bytes:s}}const BC=Le().max(256).refine(n=>{try{const e=new URL(n);return e.protocol==="https:"&&e.origin===n&&!e.username&&!e.password&&!e.port&&/^(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z][a-z0-9-]*[a-z0-9]$/u.test(e.hostname)&&!/\.(?:localhost|local|internal)$/u.test(e.hostname)}catch{return!1}},"Expected an exact public HTTPS origin"),wo=Le().max(256).refine(n=>(!n||n.startsWith("/"))&&!/~(?![01])/u.test(n)&&n.split("/").length<=9&&!n.split("/").some(e=>["__proto__","prototype","constructor"].includes(e)),"Invalid bounded JSON pointer"),WC=Le().min(1).max(1024).regex(/^[a-zA-Z0-9._~-]+$/u).refine(n=>n!=="."&&n!==".."),gV=Rr("type",[xe({type:Ze("string"),required:Ft().optional(),maxLength:bt().int().min(1).max(16384),multiline:Ft().optional(),enum:at(_s).min(1).max(64).optional()}),xe({type:Ze("integer"),required:Ft().optional(),min:bt().int().min(Number.MIN_SAFE_INTEGER),max:bt().int().max(Number.MAX_SAFE_INTEGER)}),xe({type:Ze("number"),required:Ft().optional(),min:bt().finite(),max:bt().finite()}),xe({type:Ze("boolean"),required:Ft().optional()})]),xV=eo([xe({literal:WC}),xe({resource:lt}),xe({arg:lt})]),Vw=eo([lt,xe({literal:eo([Le().max(1024),bt().int().min(Number.MIN_SAFE_INTEGER).max(Number.MAX_SAFE_INTEGER),Ft()])}),xe({arg:lt}),xe({resource:lt}),xe({identity:lt})]),bV=xe({audience:Ct(["setup","panel"]),origin:BC,method:Ct(["GET","POST"]),path:at(xV).min(1).max(16),args:Xn(lt,gV).refine(n=>Object.keys(n).length<=16),query:Xn(Le().max(68).regex(/^[a-zA-Z][a-zA-Z0-9_.-]*(?:\[\])?$/u).refine(n=>!["constructor","prototype","__proto__"].includes(n.replace(/\[\]$/u,""))),Vw).refine(n=>Object.keys(n).length<=16),body:Xn(lt,Vw).refine(n=>Object.keys(n).length<=16).optional(),response:xe({type:Ze("audio"),mimeTypes:at(UC).min(1).max(6),maxBytes:bt().int().min(1).max(C0)}).optional()}),Hw=xe({operation:lt,items:wo,nested:wo.optional(),id:wo,label:wo}),vV=xe({label:_s,scope:Ct(["connection","project"]).optional(),dependsOn:at(lt).max(7).refine(n=>new Set(n).size===n.length).optional(),options:eo([Hw,at(Hw).min(1).max(4)]).optional(),input:xe({allowId:Ft(),urls:at(xe({origin:BC,pathMarker:WC})).min(1).max(8).optional(),validation:xe({operation:lt,argument:lt,id:wo.optional(),label:wo,parents:Xn(lt,wo).refine(n=>Object.keys(n).length<=7).optional()})}).optional()}).refine(n=>!!n.options||!!n.input,"Expected listed or validated entered resources"),yV=xe({version:Ze(1),id:lt,label:_s,secret:xe({id:lt,label:_s}),auth:xe({header:Le().max(64).regex(/^(?:Authorization|X-[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*)$/iu).refine(n=>!/^x-(?:forwarded|http-method|original|rewrite)(?:-|$)/iu.test(n),"Unsafe credential header"),scheme:Ct(["raw","bearer"])}),validationOperation:lt,identity:Xn(lt,wo).refine(n=>Object.keys(n).length<=8).optional(),resources:Xn(lt,vV).refine(n=>Object.keys(n).length<=8),operations:Xn(lt,bV).refine(n=>Object.keys(n).length>0&&Object.keys(n).length<=32)});function Vd(n){return n?[...n.path.flatMap(e=>"resource"in e?[e.resource]:[]),...Object.values(n.query).flatMap(e=>typeof e=="object"&&"resource"in e?[e.resource]:[])]:[]}function Kw(n,e){const t=n.resources[e];if(!t)return[];const s=t.options?Array.isArray(t.options)?t.options:[t.options]:[];return[...new Set([...t.dependsOn??[],...s.flatMap(r=>Vd(n.operations[r.operation])),...Vd(t.input?n.operations[t.input.validation.operation]:void 0)])]}const wV=yV.superRefine((n,e)=>{var u,d;const t=(f,m)=>e.addIssue({code:"custom",path:f,message:m}),s=f=>{var m;return((m=n.operations[f])==null?void 0:m.audience)==="setup"},r=(f,m)=>f&&Object.entries(f.args).every(([p,h])=>!h.required||p===m),o=n.operations[n.validationOperation];(!s(n.validationOperation)||!r(o)||Vd(o).length||Object.values((o==null?void 0:o.query)??{}).some(f=>typeof f=="object"&&"identity"in f))&&t(["validationOperation"],"Expected an independent setup operation without required arguments");for(const[f,m]of Object.entries(n.resources)){const p=Kw(n,f);for(const g of p)(g===f||!Object.hasOwn(n.resources,g))&&t(["resources",f,"dependsOn"],"Unknown or self-dependent resource"),(m.scope??"connection")==="connection"&&((u=n.resources[g])==null?void 0:u.scope)==="project"&&t(["resources",f,"scope"],"Connection resource cannot depend on a project resource");const h=m.options?Array.isArray(m.options)?m.options:[m.options]:[];for(const g of h){const x=n.operations[g.operation];(!s(g.operation)||!r(x))&&t(["resources",f,"options"],"Expected a setup operation without required arguments"),p.some(b=>!Vd(x).includes(b))&&t(["resources",f,"options"],"Every options source must bind all parent resources")}if(m.input){const g=m.input,x=g.validation,b=n.operations[x.operation],w=b==null?void 0:b.args[x.argument];!g.allowId&&!g.urls&&t(["resources",f,"input"],"Expected an accepted input format"),(!s(x.operation)||!r(b,x.argument)||(w==null?void 0:w.type)!=="string"||!w.required||b.path.filter(v=>"arg"in v&&v.arg===x.argument).length!==1)&&t(["resources",f,"input","validation"],"Validation must request the candidate as one required path argument"),(p.some(v=>!Object.hasOwn(x.parents??{},v))||Object.keys(x.parents??{}).some(v=>!p.includes(v)))&&t(["resources",f,"input","validation","parents"],"Validation must prove each selected parent")}}const i=new Set,l=new Set,c=f=>{if(i.has(f)){t(["resources",f,"dependsOn"],"Resource dependency cycle");return}if(!l.has(f)){i.add(f);for(const m of Kw(n,f))Object.hasOwn(n.resources,m)&&c(m);i.delete(f),l.add(f)}};for(const f of Object.keys(n.resources))c(f);for(const[f,m]of Object.entries(n.operations)){m.audience==="setup"&&(m.method!=="GET"||m.response)&&t(["operations",f],"Setup operations must return JSON from GET"),m.body&&m.method!=="POST"&&t(["operations",f,"body"],"Only POST operations have a body");const p=new Set;for(const[h,g]of Object.entries(m.args))(Object.hasOwn(n.resources,h)||Object.hasOwn(n.identity??{},h))&&t(["operations",f,"args",h],"Argument shadows a host-owned binding"),(g.type==="integer"||g.type==="number")&&g.min>g.max&&t(["operations",f,"args",h],"Inverted numeric bounds"),g.type==="string"&&((d=g.enum)!=null&&d.some(x=>new TextEncoder().encode(x).byteLength>g.maxLength))&&t(["operations",f,"args",h],"Enum exceeds string limit");for(const h of m.path)if("resource"in h&&!Object.hasOwn(n.resources,h.resource)&&t(["operations",f,"path"],"Unknown selected resource"),"arg"in h){const g=m.args[h.arg];((g==null?void 0:g.type)!=="string"||g.required!==!0)&&t(["operations",f,"path"],"Path argument must be a required string"),p.add(h.arg)}for(const h of[...Object.values(m.query),...Object.values(m.body??{})]){const g=typeof h=="string"?h:"arg"in h?h.arg:void 0;g!==void 0?(Object.hasOwn(m.args,g)||t(["operations",f,"query"],"Unknown query argument"),p.add(g)):typeof h=="object"&&"resource"in h&&!Object.hasOwn(n.resources,h.resource)?t(["operations",f,"query"],"Unknown selected resource"):typeof h=="object"&&"identity"in h&&!Object.hasOwn(n.identity??{},h.identity)&&t(["operations",f,"query"],"Unknown validated identity")}Object.keys(m.args).some(h=>!p.has(h))&&t(["operations",f,"args"],"Unused argument")}});function Gg(n){return zo(wV,n,Qt.definitionBytes)}const qC={appVersion:Le().min(1).max(128),apiVersions:at(Kg).max(16),manifestVersions:at(bt().int().min(1).max(1024)).max(16),protocolVersions:at(bt().int().min(1).max(1024)).max(16),runtimes:at(Le().min(1).max(64)).max(16),capabilities:Xn(lt,Kg).refine(n=>Object.keys(n).length<=64)},SV=xe({...qC,browser:at(Le().min(1).max(64)).max(16)}),kV=xe({...qC,platform:Le().min(1).max(32),registryRevision:bt().int().min(0).max(Number.MAX_SAFE_INTEGER)});function jV(n){return zo(SV,n,16*1024)}function NV(n){return zo(kV,n,16*1024)}function _0(n,e,t,s={}){var f;const r=[],o=[],i=(m,p)=>!!Vn.valid(m)&&!!Vn.validRange(p)&&Vn.satisfies(m,p,{includePrerelease:s.allowPrerelease===!0}),l=(m,p,h,g,x)=>r.push({side:m,code:p,name:h,required:g,actual:x});s.revoked&&l("package","REVOKED",n.id,"non-revoked package",n.version),Vn.prerelease(n.version)&&!s.allowPrerelease&&l("package","PRERELEASE",n.id,"stable release",n.version);for(const m of["client","host"]){const p=m==="client"?e:t;i(p.appVersion,n.engines[m])||l(m,"APP_VERSION","app",n.engines[m],p.appVersion),p.manifestVersions.includes(n.manifestVersion)||l(m,"MANIFEST_VERSION","manifest",String(n.manifestVersion),p.manifestVersions.join(",")),p.protocolVersions.includes(n.protocol)||l(m,"PROTOCOL_VERSION","protocol",String(n.protocol),p.protocolVersions.join(",")),p.runtimes.includes(n.runtime)||l(m,"RUNTIME","runtime",n.runtime,p.runtimes.join(","));for(const[h,g]of Object.entries(n.requires[m])){const x=p.capabilities[h]??null;(!x||!i(x,g))&&l(m,"CAPABILITY",h,g,x)}for(const[h,g]of Object.entries(n.optional[m])){const x=p.capabilities[h]??null;(!x||!i(x,g))&&o.push({side:m,name:h,required:g,actual:x})}}for(const m of n.browser)e.browser.includes(m)||l("client","BROWSER",m,"available",null);const c=[],u=new Vn.Range(n.engines.pluginApi,{includePrerelease:s.allowPrerelease===!0});for(const m of e.apiVersions.filter(p=>Vn.valid(p)))for(const p of t.apiVersions.filter(h=>Vn.valid(h))){if(Vn.major(m)!==Vn.major(p))continue;const h=Vn.compare(m,p)<=0?m:p;i(h,n.engines.pluginApi)&&c.push(h);for(const g of u.set){const x=`${g.map(w=>w.value).join(" ")} >=${Vn.major(h)}.0.0 <=${h}`,b=(f=Vn.minVersion(x))==null?void 0:f.version;b&&i(b,n.engines.pluginApi)&&c.push(b)}}const d=c.sort(Vn.rcompare)[0]??null;if(!d){for(const m of["client","host"]){const p=m==="client"?e.apiVersions:t.apiVersions;p.some(h=>i(h,n.engines.pluginApi))||l(m,"API_VERSION","pluginApi",n.engines.pluginApi,p.join(","))}r.some(m=>m.code==="API_VERSION")||l("host","API_VERSION","pluginApi","common API version",t.apiVersions.join(","))}return{compatible:r.length===0,apiVersion:d,issues:r,unavailableOptional:o}}const Hd=$C(()=>!0),Gw=xe({}),CV=xe({id:lt,name:_s}).nullable(),VC=xe({mode:Ct(["light","dark"]),tokens:Xn(Le().regex(/^--[a-z][a-z0-9-]{0,63}$/u),Cs(256)).refine(n=>Object.keys(n).length<=64)}),HC=Le().regex(/^s_[a-f0-9]{48}$/u),_V=xe({handle:HC}).nullable().optional(),EV=xe({type:Ze("chat-block"),id:lt,source:Cs(16384)}).optional(),KC=xe({project:CV,theme:VC,locale:Le().min(1).max(64),reducedMotion:Ft(),visible:Ft(),session:_V,surface:EV});function Zw(n){return zo(KC,n,Qt.responseBytes)}const GC=["INVALID_REQUEST","INVALID_RESPONSE","INCOMPATIBLE_HOST","INCOMPATIBLE_CLIENT","PERMISSION_REQUIRED","CONNECTION_REQUIRED","RESOURCE_REQUIRED","STALE_ACTIVATION","RATE_LIMITED","PLUGIN_DISABLED","CAPABILITY_UNAVAILABLE","UPSTREAM_FAILED","CANCELED","TIMEOUT","DISPOSED"],TV=xe({code:Ct(GC),message:Cs(512)}),ll=Le().min(1).max(64).regex(/^[a-zA-Z0-9_-]+$/u),AV=Le().min(1).max(2048).refine(n=>{try{const e=new URL(n);return e.protocol==="https:"&&!e.username&&!e.password}catch{return!1}},"Expected an HTTPS URL without credentials"),eh=lt,ZC={"lifecycle.ready":Gw,"connections.request":xe({handle:lt,operationId:lt,args:Xn(lt,eo([Le(),bt().finite(),Ft()]))}),"connections.media":xe({handle:lt,operationId:lt,args:Xn(lt,eo([Le(),bt().finite(),Ft()]))}),"connections.status":xe({handle:lt}),"integrations.request":iV,"storage.get":xe({key:eh}),"storage.set":xe({key:eh,value:Hd}),"storage.delete":xe({key:eh}),"composer.append":xe({text:Cs(Qt.composerBytes)}),"navigation.openExternal":xe({url:AV}),"navigation.openSession":xe({handle:lt}),"settings.get":Gw,"ui.resize":xe({height:bt().int().min(80).max(800)})},IV=xe({configured:Ft(),readOnly:Ft(),selected:Xn(lt,xe({id:Cs(1024),label:Cs(256)})).refine(n=>Object.keys(n).length<=8)}),PV=Rr("event",[xe({protocol:Ze(Ss),type:Ze("event"),event:Ze("context"),value:KC}),xe({protocol:Ze(Ss),type:Ze("event"),event:Ze("theme"),value:VC}),xe({protocol:Ze(Ss),type:Ze("event"),event:Ze("visibility"),value:Ft()}),xe({protocol:Ze(Ss),type:Ze("event"),event:Ze("session"),value:xe({handle:HC}).nullable()}),xe({protocol:Ze(Ss),type:Ze("event"),event:Ze("dispose"),value:NC()})]),$V=eo([xe({protocol:Ze(Ss),type:Ze("request"),id:ll,method:Ct(Object.keys(ZC)),params:Hd}),xe({protocol:Ze(Ss),type:Ze("result"),id:ll,value:Hd}),xe({protocol:Ze(Ss),type:Ze("error"),id:ll,error:TV}),xe({protocol:Ze(Ss),type:Ze("cancel"),id:ll}),PV]);function Yw(n){var s,r,o,i,l;if(n&&typeof n=="object"&&((s=Object.getOwnPropertyDescriptor(n,"type"))==null?void 0:s.value)==="media-result"){const c=Object.getOwnPropertyDescriptors(n);if(Object.keys(c).length!==4||((r=c.protocol)==null?void 0:r.value)!==1)throw new Error("Invalid media envelope");return{protocol:1,type:"media-result",id:ll.parse((o=c.id)==null?void 0:o.value),value:em((i=c.value)==null?void 0:i.value)}}const e=n!==null&&typeof n=="object"&&((l=Object.getOwnPropertyDescriptor(n,"type"))==null?void 0:l.value)==="result",t=zo($V,n,e?Qt.resultMessageBytes:Qt.messageBytes,e?Qt.responseNodes+16:Qt.nodes);if(t.type==="request"){const c=t.method==="connections.media"?Qt.messageBytes:t.method==="composer.append"?Qt.composerBytes+64:t.method==="storage.set"?Qt.storageValueBytes:Qt.argumentBytes,u=zo(ZC[t.method],t.params,c);return{...t,params:u}}return t.type==="result"?{...t,value:i0(t.value,{maxBytes:Qt.responseBytes,maxNodes:Qt.responseNodes})}:t}function YC(n,e){if(n==="connections.media")return em(e);const t=n==="integrations.request"?aV:n==="connections.status"?IV:n==="connections.request"||n==="storage.get"||n==="settings.get"?Hd:NC();return zo(t,e,Qt.responseBytes,Qt.responseNodes)}const Xw=xe({values:Xn(Le(),eo([Le().max(4096),bt().finite(),Ft()])),revision:bt().int().nonnegative().max(Number.MAX_SAFE_INTEGER),adjustedFields:at(Le().max(64)).max(32).optional()}),zc=bt().int().min(0).max(Number.MAX_SAFE_INTEGER),tm=Le().regex(/^[a-f0-9]{64}$/),rc=Qr().transform(FC),XC=Rr("type",[xe({type:Ze("all")}),xe({type:Ze("projects"),projectIds:at(Le().min(1).max(512)).max(128).refine(n=>new Set(n).size===n.length)})]),RV=xe({digest:tm,manifest:rc,targetPath:Le().min(1).max(512),installedAt:zc,unavailableReason:Le().max(1e3).optional()}),OV=xe({id:Le().regex(/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$/).max(128),selectedDigest:tm,manifest:rc,enabled:Ft(),scope:XC,pinned:Ft(),versions:at(RV).min(1).max(64),lastError:Le().max(1e3).optional()}),LV=xe({id:Le().max(128),label:Le().max(128),kind:Ct(["official","development"]),fingerprint:Le().max(128),verifiedAt:zc.optional()}),JC=xe({available:Ft(),error:Le().max(2e3).optional(),revision:zc,plugins:at(OV).max(256),publishers:at(LV).max(256),legacyPluginIds:at(Ct(["github","clickup","vercel-deployments"])).max(3).optional(),availableSeeds:at(xe({manifest:rc,digest:tm})).max(256).optional(),recoveryCode:Ct(["STORE_LOCKED","STORE_VERSION","STORE_CORRUPT","STORE_UNAVAILABLE"]).optional()}),MV=xe({side:Ct(["client","host"]),name:Le().max(128),required:Le().max(256),actual:Le().max(512).nullable()}),zV=xe({compatible:Ft(),apiVersion:Le().max(128).nullable(),issues:at(xe({side:Ct(["client","host","package"]),code:Ct(["APP_VERSION","API_VERSION","MANIFEST_VERSION","PROTOCOL_VERSION","RUNTIME","CAPABILITY","BROWSER","PRERELEASE","REVOKED"]),name:Le().max(128),required:Le().max(256),actual:Le().max(512).nullable()})).max(128),unavailableOptional:at(MV).max(128)});Qr().transform(jV);const ud=xe({transactionId:Le().uuid(),manifest:rc,digest:tm,compatibility:zV,connectionDefinitions:at(Qr().transform(Gg)).max(8),oldVersion:Le().max(128).nullable(),registryRevision:zc,publisherKind:Ct(["official","development"]),scope:XC,operation:Ct(["install","update","rollback"]).optional(),previousManifest:rc.optional(),previousConnectionDefinitions:at(Qr().transform(Gg)).max(8).optional(),incompatibleClients:at(Le().max(256)).max(256).optional()}),QC=xe({id:Le().regex(/^p_[a-f0-9]{40}$/),name:Le().max(512),paths:at(Le().max(8192)).max(256)}),DV=xe({runtime:Qr().transform(NV),host:xe({name:Le().max(256),instanceId:Le().max(128)}),store:JC,projects:at(QC).max(1024),safeMode:Ft(),connectionRevision:zc.optional()}),Zg=Le().regex(/^[a-zA-Z][a-zA-Z0-9_.-]*$/).max(64),E0=bt().int().nonnegative().max(Number.MAX_SAFE_INTEGER),e_=xe({pluginId:Le().regex(/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$/).max(128),projectId:Le().regex(/^p_[a-f0-9]{40}$/).nullable()});e_.extend({expectedRevision:E0});const FV=e_.extend({connectionId:Zg});FV.extend({expectedRevision:E0});const t_=xe({id:Le().min(1).max(1024),label:Le().min(1).max(256)}),UV=at(t_).max(1e3),Jw=xe({revision:E0,connections:at(xe({id:Zg,label:Le().min(1).max(128),status:Ct(["disconnected","connected","environment"]),readOnly:Ft(),legacyImportAvailable:Ft().optional(),selected:Xn(Zg,t_).refine(n=>Object.keys(n).length<=8),definition:Qr().transform(Gg)})).max(8)}),n_="3.4.0",s_={version:n_};function cl(n=globalThis){var u,d,f,m,p,h,g,x,b,w,v,j,k,_,N,S,C,E;const e=T=>typeof T=="function",t=e(n.MessageChannel)&&e((d=(u=n.MessagePort)==null?void 0:u.prototype)==null?void 0:d.postMessage)&&e((m=(f=n.MessagePort)==null?void 0:f.prototype)==null?void 0:m.start)&&e((h=(p=n.MessagePort)==null?void 0:p.prototype)==null?void 0:h.close),s=e(n.Blob)&&e((g=n.URL)==null?void 0:g.createObjectURL)&&e((x=n.URL)==null?void 0:x.revokeObjectURL),r=e((w=(b=n.crypto)==null?void 0:b.subtle)==null?void 0:w.digest)&&e((v=n.crypto)==null?void 0:v.getRandomValues),o=n.isSecureContext===!0,l=[["secure context (HTTPS or localhost)",o],["MessageChannel",t],["Blob URLs",s],["Web Crypto",r],["AbortController",e(n.AbortController)],["AbortSignal.any",e((j=n.AbortSignal)==null?void 0:j.any)],["AbortSignal.timeout",e((k=n.AbortSignal)==null?void 0:k.timeout)],["AbortSignal.throwIfAborted",e((N=(_=n.AbortSignal)==null?void 0:_.prototype)==null?void 0:N.throwIfAborted)],["structuredClone",e(n.structuredClone)],["Object.hasOwn",e((S=n.Object)==null?void 0:S.hasOwn)],["fetch",e(n.fetch)],["Headers",e(n.Headers)],["ReadableStream",e((E=(C=n.ReadableStream)==null?void 0:C.prototype)==null?void 0:E.getReader)],["TextEncoder",e(n.TextEncoder)],["TextDecoder",e(n.TextDecoder)]].filter(([,T])=>!T).map(([T])=>T),c=[];return t&&c.push("message-channel"),s&&c.push("blob-script"),r&&o&&c.push("web-crypto"),{supported:l.length===0,browser:c,missing:l,error:l.length?`Runtime plugins are unavailable in this browser. Missing: ${l.join(", ")}. Update your browser or use a secure connection.`:null}}const BV=xe({sessionId:Le().regex(/^[a-f0-9]{64}$/),expiresAt:bt().int().positive()}),Qw=xe({id:Le().min(1).max(128),expiresAt:bt().int().positive()}),WV=xe({deadline:bt().int().positive()}),qV=xe({status:Ct(["prepared","trial","committing","committed","cancelled","abandoned"]),preview:ud,deadline:bt().int().positive().optional()}),Yg={status:null,error:null,activation:""};function bo(){const n=cl();return{appVersion:n_,apiVersions:[mV],manifestVersions:[1],protocolVersions:[Ss],runtimes:n.supported?[DC]:[],capabilities:n.supported?{"workspace.panel":"1.0.0","composer.append":"1.0.0","navigation.external":"1.0.0","navigation.session":"1.0.0","chat.blocks":"1.0.0","session.actions":"1.0.0","media.audio":"1.0.0","settings.fields":"1.0.0"}:{},browser:n.browser}}class Xg extends Error{constructor(e,t,s){super(e),this.code=t,this.status=s}}async function Jg(n,e){var c;const t=n.headers.get("Content-Length");if(t&&Number(t)>e)throw await((c=n.body)==null?void 0:c.cancel()),new Error("Plugin response exceeds its size limit");if(!n.body)throw new Error("Plugin host returned an empty response");const s=n.body.getReader(),r=[];let o=0;try{for(;;){const{done:u,value:d}=await s.read();if(u)break;if(o+=d.byteLength,o>e)throw new Error("Plugin response exceeds its size limit");r.push(d)}}catch(u){throw await s.cancel().catch(()=>{}),u}finally{s.releaseLock()}const i=new Uint8Array(o);let l=0;for(const u of r)i.set(u,l),l+=u.byteLength;return i.buffer}async function Ga(n){const e=await Jg(n,4194304);let t;try{t=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(e))}catch{throw new Error("This host does not support runtime plugins, or returned an invalid response")}if(!n.ok){const s=iq({error:Le().max(2e3),code:Le().max(128).optional()}).safeParse(t);throw new Xg(s.success?s.data.error:"Plugin request failed",s.success?s.data.code??"HOST_ERROR":"HOST_ERROR",n.status)}return t}class VV{constructor(){Ge(this,"scope",cn());Ge(this,"identity",Zn());Ge(this,"base",new URL(Cx("/api/plugins/"),window.location.origin));Ge(this,"lifetimeController");Ge(this,"session",null);Ge(this,"renewal",null);Ge(this,"refreshPromise",null);Ge(this,"timer");Ge(this,"listeners",new Set);Ge(this,"state",Yg);Ge(this,"running",!1);Ge(this,"getSnapshot",()=>this.state);Ge(this,"subscribe",e=>(this.listeners.add(e),()=>this.listeners.delete(e)));Ge(this,"hostChanged",()=>{(this.scope!==cn()||this.identity!==Zn())&&this.stop()})}get controller(){const e=cl();if(!e.supported)throw new Xg(e.error,"UNSUPPORTED_BROWSER",0);if(!this.lifetimeController)throw new Error("The plugin client has not started");return this.lifetimeController}publish(e){if(JSON.stringify(this.state)!==JSON.stringify(e)){this.state=e;for(const t of this.listeners)t()}}assertCurrent(e){const t=this.controller.signal;if((e??t).throwIfAborted(),!this.running||this.scope!==cn()||this.identity!==Zn())throw new Error("The connected host or signed-in user changed")}start(){if(this.running)return;const e=cl();if(!e.supported){this.publish({status:null,error:e.error,activation:""});return}this.running=!0,this.lifetimeController=new AbortController;for(const t of["cogpit-device-changed","cogpit-device-scope-changed","cogpit-identity-changed","popstate"])window.addEventListener(t,this.hostChanged);this.refresh(),this.timer=setInterval(()=>{this.refresh()},5e3)}stop(){var t;this.running=!1,clearInterval(this.timer),(t=this.lifetimeController)==null||t.abort();const e=this.session;this.session=null,this.renewal=null,this.refreshPromise=null;for(const s of["cogpit-device-changed","cogpit-device-scope-changed","cogpit-identity-changed","popstate"])window.removeEventListener(s,this.hostChanged);this.publish(Yg),e&&this.releaseSession(e.sessionId)}releaseSession(e){cl().supported&&Ce(new URL("session",this.base),{method:"DELETE",headers:{"X-Cogpit-Plugin-Session":e},signal:AbortSignal.timeout(5e3),keepalive:!0}).catch(()=>{})}async ensureSession(){if(this.assertCurrent(),this.session&&this.session.expiresAt-Date.now()>25e3)return;if(this.renewal)return this.renewal;const e=this.controller.signal,t=new Headers;t.set("Content-Type","application/json"),this.session&&t.set("X-Cogpit-Plugin-Session",this.session.sessionId);const s=(async()=>{const r=await Ce(new URL("session",this.base),{method:"POST",headers:t,body:JSON.stringify({client:bo()}),signal:AbortSignal.any([e,AbortSignal.timeout(2e4)])}),o=BV.parse(await Ga(r));try{this.assertCurrent(e)}catch(i){throw this.releaseSession(o.sessionId),i}this.session=o})();this.renewal=s;try{await s}finally{this.renewal===s&&(this.renewal=null)}}async request(e,t={}){const s=this.controller.signal;await this.ensureSession(),this.assertCurrent(s);const r=new Headers(t.headers);r.set("X-Cogpit-Plugin-Session",this.session.sessionId);const o=await Ce(new URL(e,this.base),{...t,headers:r,signal:AbortSignal.any([s,...t.signal?[t.signal]:[],AbortSignal.timeout(3e4)])});return this.assertCurrent(s),o}async json(e,t,s="POST",r){const o=this.controller.signal,i=await this.request(e,{method:s,signal:r,...t===void 0?{}:{body:JSON.stringify(t),headers:{"Content-Type":"application/json"}}}),l=await Ga(i);return this.assertCurrent(o),l}refresh(){const e=cl();if(!e.supported)return this.stop(),this.publish({status:null,error:e.error,activation:""}),Promise.resolve();if(this.refreshPromise)return this.refreshPromise;const t=this.controller.signal,s=(async()=>{var r;try{const o=DV.parse(await this.json("status",void 0,"GET"));if(this.assertCurrent(t),((r=this.state.status)==null?void 0:r.host.instanceId)===o.host.instanceId&&this.state.status.store.revision>o.store.revision)return;this.publish({status:o,error:null,activation:`${this.scope}:${this.identity??"personal"}:${o.host.instanceId}:${this.session.sessionId}:${o.connectionRevision??0}`})}catch(o){if(t.aborted||!this.running)return;o instanceof Xg&&o.code==="STALE_ACTIVATION"&&(this.session=null),this.publish({status:null,error:o instanceof Error?o.message:"Plugin host is unavailable",activation:""})}})();return this.refreshPromise=s,s.finally(()=>{this.refreshPromise===s&&(this.refreshPromise=null)}),s}async stageSeed(e,t){return ud.parse(await this.json("stage-seed",{pluginId:e,scope:t,client:bo()}))}async stage(e,t){const s=this.controller.signal;if(e.size>4*1024*1024)throw new Error("Choose a plugin package smaller than 4 MiB");const r=ud.parse(await Ga(await this.request("stage",{method:"POST",body:e,headers:{"Content-Type":"application/octet-stream","X-Cogpit-Plugin-Client":JSON.stringify(bo()),"X-Cogpit-Plugin-Scope":JSON.stringify(t)}})));return this.assertCurrent(s),r}async payload(e,t){const s=this.controller.signal,r=await this.request(`payload/${encodeURIComponent(e)}`,{signal:t});r.ok||await Ga(r);const o=await Jg(r,4*1024*1024);return this.assertCurrent(s),t==null||t.throwIfAborted(),o}async settings(e,t){const s=new URLSearchParams({pluginId:e.pluginId,...e.projectId?{projectId:e.projectId}:{}});return Xw.parse(await this.json(`settings?${s}`,void 0,"GET",t))}async saveSettings(e,t,s,r){return Xw.parse(await this.json("settings",{...e,values:t,expectedRevision:s},"POST",r))}async media(e,t,s){var l;const r=this.controller.signal,o=await this.request(`leases/${encodeURIComponent(e)}/call`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"},signal:s});o.ok||await Ga(o);const i=await Jg(o,C0);return this.assertCurrent(r),s==null||s.throwIfAborted(),em({mimeType:(l=o.headers.get("Content-Type"))==null?void 0:l.split(";")[0],bytes:i})}acceptStore(e){const t=JC.parse(e),s=this.state.status;s&&t.revision>=s.store.revision&&this.publish({...this.state,status:{...s,store:t,runtime:{...s.runtime,registryRevision:t.revision}}})}async beginTrial(e,t){return WV.parse(await this.json(`transactions/${e.transactionId}/trial`,void 0,"POST",t)).deadline}async commit(e,t){this.acceptStore(await this.json(`transactions/${e.transactionId}/commit`,{expectedRevision:e.registryRevision},"POST",t)),await this.refresh()}async transactionOutcome(e){return qV.parse(await this.json(`transactions/${e.transactionId}`,void 0,"GET"))}async cancel(e){await this.json(`transactions/${e.transactionId}`,void 0,"DELETE")}async enrollDeveloper(e){this.acceptStore(await this.json("publishers",{...e,development:!0})),await this.refresh()}async changeInstalled(e,t,s,r){const o=`installed/${encodeURIComponent(e)}${t==="uninstall"?"":`/${t}`}`;this.acceptStore(await this.json(o,{...s,expectedRevision:r},t==="uninstall"?"DELETE":"POST")),await this.refresh()}async rollback(e,t,s){return ud.parse(await this.json(`installed/${encodeURIComponent(e)}/rollback`,{digest:t,scope:s,client:bo()}))}async lease(e,t,s,r,o){return Qw.parse(await this.json("leases",{pluginId:e,projectId:t,contextEpoch:s,...o?{workspacePath:o}:{},client:bo()},"POST",r))}async renewLease(e,t){return Qw.parse(await this.json(`leases/${encodeURIComponent(e)}/renew`,void 0,"POST",t))}async revokeLease(e){await this.json(`leases/${encodeURIComponent(e)}`,void 0,"DELETE")}async call(e,t,s){if(t.method==="connections.media")throw new Error("Use the binary media transport for audio");const r=xe({value:Qr()}).parse(await this.json(`leases/${encodeURIComponent(e)}/call`,t,"POST",s));return YC(t.method,r.value)}async resolveSession(e,t,s){return xe({dirName:Le().min(1).max(8192),fileName:Le().min(1).max(8192)}).parse(await this.json(`leases/${encodeURIComponent(e)}/session`,{handle:t},"POST",s))}async sessionHandle(e,t,s){return xe({handle:Le().regex(/^s_[a-f0-9]{48}$/)}).parse(await this.json(`leases/${encodeURIComponent(e)}/session-handle`,t,"POST",s)).handle}async resolveWorkspace(e,t){return QC.nullable().parse(await this.json("workspace/resolve",{workspacePath:e},"POST",t))}async connections(e,t){const s=new URLSearchParams({pluginId:e.pluginId,...e.projectId?{projectId:e.projectId}:{}});return Jw.parse(await this.json(`connections?${s}`,void 0,"GET",t))}async connectionOptions(e,t,s,r){return UV.parse(await this.json("connections/options",{...e,connectionId:t,resourceId:s},"POST",r))}async changeConnection(e,t,s,r,o,i){const l=Jw.parse(await this.json(`connections/${s}`,{...e,connectionId:t,...r,expectedRevision:o},"POST",i));return await this.refresh(),l}async clearPluginData(e,t,s){await this.json("connections/clear-data",{pluginId:e,expectedRevision:t},"POST",s),await this.refresh()}}const vo=0,Te=1,ot=2,ln=3,Pt=4,bs=5,Dc=6,An=7,Hn=8,mt=9,rt=10,Ht=11,ft=12,Ut=13,Fc=14,ts=15,Un=16,Bn=17,ls=18,cs=19,os=20,ht=21,et=22,wn=23,Jn=24,gn=25,HV=0;function In(n){return n>=48&&n<=57}function Do(n){return In(n)||n>=65&&n<=70||n>=97&&n<=102}function T0(n){return n>=65&&n<=90}function KV(n){return n>=97&&n<=122}function GV(n){return T0(n)||KV(n)}function ZV(n){return n>=128}function Kd(n){return GV(n)||ZV(n)||n===95}function r_(n){return Kd(n)||In(n)||n===45}function YV(n){return n>=0&&n<=8||n===11||n>=14&&n<=31||n===127}function Gd(n){return n===10||n===13||n===12}function vi(n){return Gd(n)||n===32||n===9}function qs(n,e){return!(n!==92||Gd(e)||e===HV)}function dd(n,e,t){return n===45?Kd(e)||e===45||qs(e,t):Kd(n)?!0:n===92?qs(n,e):!1}function th(n,e,t){return n===43||n===45?In(e)?2:e===46&&In(t)?3:0:n===46?In(e)?2:0:In(n)?1:0}function o_(n){return n===65279||n===65534?1:0}const Qg=new Array(128),XV=128,fd=130,i_=131,A0=132,a_=133;for(let n=0;n<Qg.length;n++)Qg[n]=vi(n)&&fd||In(n)&&i_||Kd(n)&&A0||YV(n)&&a_||n||XV;function nh(n){return n<128?Qg[n]:A0}function Yi(n,e){return e<n.length?n.charCodeAt(e):0}function e1(n,e,t){return t===13&&Yi(n,e+1)===10?2:1}function Xi(n,e,t){let s=n.charCodeAt(e);return T0(s)&&(s=s|32),s===t}function oc(n,e,t,s){if(t-e!==s.length||e<0||t>n.length)return!1;for(let r=e;r<t;r++){const o=s.charCodeAt(r-e);let i=n.charCodeAt(r);if(T0(i)&&(i=i|32),i!==o)return!1}return!0}function JV(n,e){for(;e>=0&&vi(n.charCodeAt(e));e--);return e+1}function Nu(n,e){for(;e<n.length&&vi(n.charCodeAt(e));e++);return e}function sh(n,e){for(;e<n.length&&In(n.charCodeAt(e));e++);return e}function yi(n,e){if(e+=2,Do(Yi(n,e-1))){for(const s=Math.min(n.length,e+5);e<s&&Do(Yi(n,e));e++);const t=Yi(n,e);vi(t)&&(e+=e1(n,e,t))}return e}function Cu(n,e){for(;e<n.length;e++){const t=n.charCodeAt(e);if(!r_(t)){if(qs(t,Yi(n,e+1))){e=yi(n,e)-1;continue}break}}return e}function nm(n,e){let t=n.charCodeAt(e);if((t===43||t===45)&&(t=n.charCodeAt(e+=1)),In(t)&&(e=sh(n,e+1),t=n.charCodeAt(e)),t===46&&In(n.charCodeAt(e+1))&&(e+=2,e=sh(n,e)),Xi(n,e,101)){let s=0;t=n.charCodeAt(e+1),(t===45||t===43)&&(s=1,t=n.charCodeAt(e+2)),In(t)&&(e=sh(n,e+1+s+1))}return e}function rh(n,e){for(;e<n.length;e++){const t=n.charCodeAt(e);if(t===41){e++;break}qs(t,Yi(n,e+1))&&(e=yi(n,e))}return e}function I0(n){if(n.length===1&&!Do(n.charCodeAt(0)))return n[0];let e=parseInt(n,16);return(e===0||e>=55296&&e<=57343||e>1114111)&&(e=65533),String.fromCodePoint(e)}const t1=["EOF-token","ident-token","function-token","at-keyword-token","hash-token","string-token","bad-string-token","url-token","bad-url-token","delim-token","number-token","percentage-token","dimension-token","whitespace-token","CDO-token","CDC-token","colon-token","semicolon-token","comma-token","[-token","]-token","(-token",")-token","{-token","}-token","comment-token"],QV=16*1024;function Zd(n=null,e){return n===null||n.length<e?new Uint32Array(Math.max(e+1024,QV)):n}const eS=10,eH=12,tS=13;function nS(n){const e=n.source,t=e.length,s=e.length>0?o_(e.charCodeAt(0)):0,r=Zd(n.lines,t),o=Zd(n.columns,t);let i=n.startLine,l=n.startColumn;for(let c=s;c<t;c++){const u=e.charCodeAt(c);r[c]=i,o[c]=l++,(u===eS||u===tS||u===eH)&&(u===tS&&c+1<t&&e.charCodeAt(c+1)===eS&&(c++,r[c]=i,o[c]=l),i++,l=1)}r[t]=i,o[t]=l,n.lines=r,n.columns=o,n.computed=!0}class tH{constructor(e,t,s,r){this.setSource(e,t,s,r),this.lines=null,this.columns=null}setSource(e="",t=0,s=1,r=1){this.source=e,this.startOffset=t,this.startLine=s,this.startColumn=r,this.computed=!1}getLocation(e,t){return this.computed||nS(this),{source:t,offset:this.startOffset+e,line:this.lines[e],column:this.columns[e]}}getLocationRange(e,t,s){return this.computed||nS(this),{source:s,start:{offset:this.startOffset+e,line:this.lines[e],column:this.columns[e]},end:{offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]}}}}const Rs=16777215,Os=24,Uc=1,sm=2,So=new Uint8Array(32);So[ot]=et;So[ht]=et;So[cs]=os;So[wn]=Jn;const Vs=new Uint8Array(32);Vs[ot]=Uc;Vs[ht]=Uc;Vs[cs]=Uc;Vs[wn]=Uc;Vs[et]=sm;Vs[os]=sm;Vs[Jn]=sm;function sS(n,e,t){return n<e?e:n>t?t:n}class nH{constructor(e,t){this.setSource(e,t)}reset(){this.eof=!1,this.tokenIndex=-1,this.tokenType=0,this.tokenStart=this.firstCharOffset,this.tokenEnd=this.firstCharOffset}setSource(e="",t=()=>{}){e=String(e||"");const s=e.length,r=Zd(this.offsetAndType,e.length+1),o=Zd(this.balance,e.length+1);let i=0,l=-1,c=0,u=e.length;this.offsetAndType=null,this.balance=null,o.fill(0),t(e,(d,f,m)=>{const p=i++;if(r[p]=d<<Os|m,l===-1&&(l=f),o[p]=u,d===c){const h=o[u];o[u]=p,u=h,c=So[r[h]>>Os]}else this.isBlockOpenerTokenType(d)&&(u=p,c=So[d])}),r[i]=vo<<Os|s,o[i]=i;for(let d=0;d<i;d++){const f=o[d];if(f<=d){const m=o[f];m!==d&&(o[d]=m)}else f>i&&(o[d]=i)}this.source=e,this.firstCharOffset=l===-1?0:l,this.tokenCount=i,this.offsetAndType=r,this.balance=o,this.reset(),this.next()}lookupType(e){return e+=this.tokenIndex,e<this.tokenCount?this.offsetAndType[e]>>Os:vo}lookupTypeNonSC(e){for(let t=this.tokenIndex;t<this.tokenCount;t++){const s=this.offsetAndType[t]>>Os;if(s!==Ut&&s!==gn&&e--===0)return s}return vo}lookupOffset(e){return e+=this.tokenIndex,e<this.tokenCount?this.offsetAndType[e-1]&Rs:this.source.length}lookupOffsetNonSC(e){for(let t=this.tokenIndex;t<this.tokenCount;t++){const s=this.offsetAndType[t]>>Os;if(s!==Ut&&s!==gn&&e--===0)return t-this.tokenIndex}return vo}lookupValue(e,t){return e+=this.tokenIndex,e<this.tokenCount?oc(this.source,this.offsetAndType[e-1]&Rs,this.offsetAndType[e]&Rs,t):!1}getTokenStart(e){return e===this.tokenIndex?this.tokenStart:e>0?e<this.tokenCount?this.offsetAndType[e-1]&Rs:this.offsetAndType[this.tokenCount]&Rs:this.firstCharOffset}getTokenEnd(e){return e===this.tokenIndex?this.tokenEnd:this.offsetAndType[sS(e,0,this.tokenCount)]&Rs}getTokenType(e){return e===this.tokenIndex?this.tokenType:this.offsetAndType[sS(e,0,this.tokenCount)]>>Os}substrToCursor(e){return this.source.substring(e,this.tokenStart)}isBlockOpenerTokenType(e){return Vs[e]===Uc}isBlockCloserTokenType(e){return Vs[e]===sm}getBlockTokenPairIndex(e){const t=this.getTokenType(e);if(Vs[t]===1){const s=this.balance[e],r=this.getTokenType(s);return So[t]===r?s:-1}else if(Vs[t]===2){const s=this.balance[e],r=this.getTokenType(s);return So[r]===t?s:-1}return-1}isBalanceEdge(e){return this.balance[this.tokenIndex]<e}isDelim(e,t){return t?this.lookupType(t)===mt&&this.source.charCodeAt(this.lookupOffset(t))===e:this.tokenType===mt&&this.source.charCodeAt(this.tokenStart)===e}skip(e){let t=this.tokenIndex+e;t<this.tokenCount?(this.tokenIndex=t,this.tokenStart=this.offsetAndType[t-1]&Rs,t=this.offsetAndType[t],this.tokenType=t>>Os,this.tokenEnd=t&Rs):(this.tokenIndex=this.tokenCount,this.next())}next(){let e=this.tokenIndex+1;e<this.tokenCount?(this.tokenIndex=e,this.tokenStart=this.tokenEnd,e=this.offsetAndType[e],this.tokenType=e>>Os,this.tokenEnd=e&Rs):(this.eof=!0,this.tokenIndex=this.tokenCount,this.tokenType=vo,this.tokenStart=this.tokenEnd=this.source.length)}skipSC(){for(;this.tokenType===Ut||this.tokenType===gn;)this.next()}skipUntilBalanced(e,t){let s=e,r=0,o=0;e:for(;s<this.tokenCount;s++){if(r=this.balance[s],r<e)break e;switch(o=s>0?this.offsetAndType[s-1]&Rs:this.firstCharOffset,t(this.source.charCodeAt(o))){case 1:break e;case 2:s++;break e;default:this.isBlockOpenerTokenType(this.offsetAndType[s]>>Os)&&(s=r)}}this.skip(s-this.tokenIndex)}forEachToken(e){for(let t=0,s=this.firstCharOffset;t<this.tokenCount;t++){const r=s,o=this.offsetAndType[t],i=o&Rs,l=o>>Os;s=i,e(l,r,i,t)}}dump(){const e=new Array(this.tokenCount);return this.forEachToken((t,s,r,o)=>{e[o]={idx:o,type:t1[t],chunk:this.source.substring(s,r),balance:this.balance[o]}}),e}}function rm(n,e){function t(f){return f<l?n.charCodeAt(f):0}function s(){if(u=nm(n,u),dd(t(u),t(u+1),t(u+2))){d=ft,u=Cu(n,u);return}if(t(u)===37){d=Ht,u++;return}d=rt}function r(){const f=u;if(u=Cu(n,u),oc(n,f,u,"url")&&t(u)===40){if(u=Nu(n,u+1),t(u)===34||t(u)===39){d=ot,u=f+4;return}i();return}if(t(u)===40){d=ot,u++;return}d=Te}function o(f){for(f||(f=t(u++)),d=bs;u<n.length;u++){const m=n.charCodeAt(u);switch(nh(m)){case f:u++;return;case fd:if(Gd(m)){u+=e1(n,u,m),d=Dc;return}break;case 92:if(u===n.length-1)break;const p=t(u+1);Gd(p)?u+=e1(n,u+1,p):qs(m,p)&&(u=yi(n,u)-1);break}}}function i(){for(d=An,u=Nu(n,u);u<n.length;u++){const f=n.charCodeAt(u);switch(nh(f)){case 41:u++;return;case fd:if(u=Nu(n,u),t(u)===41||u>=n.length){u<n.length&&u++;return}u=rh(n,u),d=Hn;return;case 34:case 39:case 40:case a_:u=rh(n,u),d=Hn;return;case 92:if(qs(f,t(u+1))){u=yi(n,u)-1;break}u=rh(n,u),d=Hn;return}}}n=String(n||"");const l=n.length;let c=o_(t(0)),u=c,d;for(;u<l;){const f=n.charCodeAt(u);switch(nh(f)){case fd:d=Ut,u=Nu(n,u+1);break;case 34:o();break;case 35:r_(t(u+1))||qs(t(u+1),t(u+2))?(d=Pt,u=Cu(n,u+1)):(d=mt,u++);break;case 39:o();break;case 40:d=ht,u++;break;case 41:d=et,u++;break;case 43:th(f,t(u+1),t(u+2))?s():(d=mt,u++);break;case 44:d=ls,u++;break;case 45:th(f,t(u+1),t(u+2))?s():t(u+1)===45&&t(u+2)===62?(d=ts,u=u+3):dd(f,t(u+1),t(u+2))?r():(d=mt,u++);break;case 46:th(f,t(u+1),t(u+2))?s():(d=mt,u++);break;case 47:t(u+1)===42?(d=gn,u=n.indexOf("*/",u+2),u=u===-1?n.length:u+2):(d=mt,u++);break;case 58:d=Un,u++;break;case 59:d=Bn,u++;break;case 60:t(u+1)===33&&t(u+2)===45&&t(u+3)===45?(d=Fc,u=u+4):(d=mt,u++);break;case 64:dd(t(u+1),t(u+2),t(u+3))?(d=ln,u=Cu(n,u+1)):(d=mt,u++);break;case 91:d=cs,u++;break;case 92:qs(f,t(u+1))?r():(d=mt,u++);break;case 93:d=os,u++;break;case 123:d=wn,u++;break;case 125:d=Jn,u++;break;case i_:s();break;case A0:r();break;default:d=mt,u++}e(d,c,c=u)}}let _i=null;class jn{static createItem(e){return{prev:null,next:null,data:e}}constructor(){this.head=null,this.tail=null,this.cursor=null}createItem(e){return jn.createItem(e)}allocateCursor(e,t){let s;return _i!==null?(s=_i,_i=_i.cursor,s.prev=e,s.next=t,s.cursor=this.cursor):s={prev:e,next:t,cursor:this.cursor},this.cursor=s,s}releaseCursor(){const{cursor:e}=this;this.cursor=e.cursor,e.prev=null,e.next=null,e.cursor=_i,_i=e}updateCursors(e,t,s,r){let{cursor:o}=this;for(;o!==null;)o.prev===e&&(o.prev=t),o.next===s&&(o.next=r),o=o.cursor}*[Symbol.iterator](){for(let e=this.head;e!==null;e=e.next)yield e.data}get size(){let e=0;for(let t=this.head;t!==null;t=t.next)e++;return e}get isEmpty(){return this.head===null}get first(){return this.head&&this.head.data}get last(){return this.tail&&this.tail.data}fromArray(e){let t=null;this.head=null;for(let s of e){const r=jn.createItem(s);t!==null?t.next=r:this.head=r,r.prev=t,t=r}return this.tail=t,this}toArray(){return[...this]}toJSON(){return[...this]}forEach(e,t=this){const s=this.allocateCursor(null,this.head);for(;s.next!==null;){const r=s.next;s.next=r.next,e.call(t,r.data,r,this)}this.releaseCursor()}forEachRight(e,t=this){const s=this.allocateCursor(this.tail,null);for(;s.prev!==null;){const r=s.prev;s.prev=r.prev,e.call(t,r.data,r,this)}this.releaseCursor()}reduce(e,t,s=this){let r=this.allocateCursor(null,this.head),o=t,i;for(;r.next!==null;)i=r.next,r.next=i.next,o=e.call(s,o,i.data,i,this);return this.releaseCursor(),o}reduceRight(e,t,s=this){let r=this.allocateCursor(this.tail,null),o=t,i;for(;r.prev!==null;)i=r.prev,r.prev=i.prev,o=e.call(s,o,i.data,i,this);return this.releaseCursor(),o}some(e,t=this){for(let s=this.head;s!==null;s=s.next)if(e.call(t,s.data,s,this))return!0;return!1}map(e,t=this){const s=new jn;for(let r=this.head;r!==null;r=r.next)s.appendData(e.call(t,r.data,r,this));return s}filter(e,t=this){const s=new jn;for(let r=this.head;r!==null;r=r.next)e.call(t,r.data,r,this)&&s.appendData(r.data);return s}nextUntil(e,t,s=this){if(e===null)return;const r=this.allocateCursor(null,e);for(;r.next!==null;){const o=r.next;if(r.next=o.next,t.call(s,o.data,o,this))break}this.releaseCursor()}prevUntil(e,t,s=this){if(e===null)return;const r=this.allocateCursor(e,null);for(;r.prev!==null;){const o=r.prev;if(r.prev=o.prev,t.call(s,o.data,o,this))break}this.releaseCursor()}clear(){this.head=null,this.tail=null}copy(){const e=new jn;for(let t of this)e.appendData(t);return e}prepend(e){return this.updateCursors(null,e,this.head,e),this.head!==null?(this.head.prev=e,e.next=this.head):this.tail=e,this.head=e,this}prependData(e){return this.prepend(jn.createItem(e))}append(e){return this.insert(e)}appendData(e){return this.insert(jn.createItem(e))}insert(e,t=null){if(t!==null)if(this.updateCursors(t.prev,e,t,e),t.prev===null){if(this.head!==t)throw new Error("before doesn't belong to list");this.head=e,t.prev=e,e.next=t,this.updateCursors(null,e)}else t.prev.next=e,e.prev=t.prev,t.prev=e,e.next=t;else this.updateCursors(this.tail,e,null,e),this.tail!==null?(this.tail.next=e,e.prev=this.tail):this.head=e,this.tail=e;return this}insertData(e,t){return this.insert(jn.createItem(e),t)}remove(e){if(this.updateCursors(e,e.prev,e,e.next),e.prev!==null)e.prev.next=e.next;else{if(this.head!==e)throw new Error("item doesn't belong to list");this.head=e.next}if(e.next!==null)e.next.prev=e.prev;else{if(this.tail!==e)throw new Error("item doesn't belong to list");this.tail=e.prev}return e.prev=null,e.next=null,e}push(e){this.insert(jn.createItem(e))}pop(){return this.tail!==null?this.remove(this.tail):null}unshift(e){this.prepend(jn.createItem(e))}shift(){return this.head!==null?this.remove(this.head):null}prependList(e){return this.insertList(e,this.head)}appendList(e){return this.insertList(e)}insertList(e,t){return e.head===null?this:(t!=null?(this.updateCursors(t.prev,e.tail,t,e.head),t.prev!==null?(t.prev.next=e.head,e.head.prev=t.prev):this.head=e.head,t.prev=e.tail,e.tail.next=t):(this.updateCursors(this.tail,e.tail,null,e.head),this.tail!==null?(this.tail.next=e.head,e.head.prev=this.tail):this.head=e.head,this.tail=e.tail),e.head=null,e.tail=null,this)}replace(e,t){"head"in t?this.insertList(t,e):this.insert(t,e),this.remove(e)}}function om(n,e){const t=Object.create(SyntaxError.prototype),s=new Error;return Object.assign(t,{name:n,message:e,get stack(){return(s.stack||"").replace(/^(.+\n){1,3}/,`${n}: ${e}
70
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const d of n.seen.entries()){const f=d[1];if(e===d[0]){o(d);continue}if(n.external){const p=(c=n.external.registry.get(d[0]))==null?void 0:c.id;if(e!==d[0]&&p){o(d);continue}}if((u=n.metadataRegistry.get(d[0]))==null?void 0:u.id){o(d);continue}if(f.cycle){o(d);continue}f.count>1&&n.reused==="ref"&&o(d)}n.external&&(n.sharedDefsExtractedFor=n.external)}function mC(n){const e=n.anyOf;if(!Array.isArray(e)||e.length===0||n.type!==void 0)return;const t=[];for(const s of e){if(!s||typeof s!="object")return;mC(s);const r=Object.keys(s);if(r.length!==1||r[0]!=="type")return;const o=s.type;for(const i of Array.isArray(o)?o:[o]){if(typeof i!="string")return;t.includes(i)||t.push(i)}}delete n.anyOf,n.type=t.length===1?t[0]:t}const pC=new Set(["type","properties","required","additionalProperties"]),L2=["oneOf","anyOf"];function M2(n){const e=n.additionalProperties;return e===void 0||e===!1||typeof e!="object"||e===null?null:Object.keys(e).length?e:null}function Wg(n){var o;const e=[];for(const i of n){if(typeof i!="object"||i.type!=="object")return null;for(const l in i)if(!pC.has(l))return null;e.push(i)}const t={},s=new Set;for(const i of e){for(const l in i.properties){if(Object.prototype.hasOwnProperty.call(t,l))continue;const c=[];for(const d of e){const f=((o=d.properties)==null?void 0:o[l])??M2(d);f!=null&&(c.some(m=>JSON.stringify(m)===JSON.stringify(f))||c.push(f))}const u=c.length===1?c[0]:Wg(c)??{allOf:c};lo(t,l,u)}for(const l of i.required??[])s.add(l)}const r={type:"object",properties:t};if(s.size&&(r.required=[...s]),e.every(i=>i.additionalProperties===!1))r.additionalProperties=!1;else{const i=[];for(const l of e){const c=M2(l);c&&!i.some(u=>JSON.stringify(u)===JSON.stringify(c))&&i.push(c)}i.length===1?r.additionalProperties=i[0]:i.length>1&&(r.additionalProperties={allOf:i})}return r}function qB(n){const e=n.allOf;if(!Array.isArray(e)||e.length<2)return;for(const r of pC)if(r in n)return;const t=e.filter(r=>L2.some(o=>Array.isArray(r[o])));let s=null;if(!t.length)s=Wg(e);else{const r=t[0],o=L2.find(c=>Array.isArray(r[c]));if(Object.keys(r).length!==1)return;const i=e.filter(c=>c!==r),l=r[o].map(c=>Wg([...i,c]));if(l.some(c=>!c))return;s={[o]:l}}s&&(delete n.allOf,Rl(n,s))}function hC(n,e){var l,c,u,d;const t=n.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=f=>{const m=n.seen.get(f);if(m.ref===null)return;const p=m.def??m.schema,h={...p},g=m.ref;if(m.ref=null,g){s(g);const b=n.seen.get(g),w=b.schema;if(w.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(w)):Rl(p,w),Rl(p,h),f._zod.parent===g)for(const j in p)j==="$ref"||j==="allOf"||j in h||delete p[j];if(w.$ref&&b.def)for(const j in p)j==="$ref"||j==="allOf"||j in b.def&&JSON.stringify(p[j])===JSON.stringify(b.def[j])&&delete p[j]}const x=f._zod.parent;if(x&&x!==g){s(x);const b=n.seen.get(x);if(b!=null&&b.schema.$ref&&(p.$ref=b.schema.$ref,b.def))for(const w in p)w==="$ref"||w==="allOf"||w in b.def&&JSON.stringify(p[w])===JSON.stringify(b.def[w])&&delete p[w]}n.override({zodSchema:f,jsonSchema:p,path:m.path??[]})};if(!n.external||n.sharedEmitDoneFor!==n.external){for(const f of[...n.seen.entries()].reverse())s(f[0]);if(n.target!=="openapi-3.0")for(const f of n.seen.entries())mC(f[1].def??f[1].schema);for(const f of n.deferred)f();if(n.intersections.length){const f=new Map;for(const m of n.seen.values())for(const p of[m.schema,m.def]){const h=p==null?void 0:p.allOf;if(!Array.isArray(h))continue;const g=f.get(h);g?g.push(p):f.set(h,[p])}for(const m of n.intersections)for(const p of f.get(m)??[])qB(p)}}const r={};if(n.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":n.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":n.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":n.target,(l=n.external)!=null&&l.uri){const f=(c=n.external.registry.get(e))==null?void 0:c.id;if(!f)throw new Error("Schema is missing an `id` property");r.$id=n.external.uri(f)}Rl(r,t.defId?t.schema:t.def??t.schema);const o=(u=n.metadataRegistry.get(e))==null?void 0:u.id;o!==void 0&&r.id===o&&delete r.id;const i=((d=n.external)==null?void 0:d.defs)??{};if(!n.external||n.sharedEmitDoneFor!==n.external)for(const f of n.seen.entries()){const m=f[1];m.def&&m.defId&&(m.def.id===m.defId&&delete m.def.id,lo(i,m.defId,m.def))}n.external&&(n.sharedEmitDoneFor=n.external),n.external||Object.keys(i).length>0&&(n.target==="draft-2020-12"?r.$defs=i:r.definitions=i);try{const f=JSON.parse(JSON.stringify(r));return Object.defineProperty(f,"~standard",{value:{...e["~standard"],jsonSchema:{input:Wd(e,"input",n.processors),output:Wd(e,"output",n.processors)}},enumerable:!1,writable:!1}),f}catch{throw new Error("Error converting schema to JSON.")}}function qn(n,e){const t=e??{seen:new Set};if(t.seen.has(n))return!1;t.seen.add(n);const s=n._zod.def;if(s.type==="transform")return!0;if(s.type==="array")return qn(s.element,t);if(s.type==="set")return qn(s.valueType,t);if(s.type==="lazy")return qn(s.getter(),t);if(s.type==="promise"||s.type==="optional"||s.type==="nonoptional"||s.type==="nullable"||s.type==="readonly"||s.type==="default"||s.type==="prefault"||s.type==="catch")return qn(s.innerType,t);if(s.type==="intersection")return qn(s.left,t)||qn(s.right,t);if(s.type==="record"||s.type==="map")return qn(s.keyType,t)||qn(s.valueType,t);if(s.type==="pipe")return n._zod.traits.has("$ZodCodec")?!0:qn(s.in,t)||qn(s.out,t);if(s.type==="object"){for(const r in s.shape)if(qn(s.shape[r],t))return!0;return!1}if(s.type==="union"){for(const r of s.options)if(qn(r,t))return!0;return!1}if(s.type==="tuple"){for(const r of s.items)if(qn(r,t))return!0;return!!(s.rest&&qn(s.rest,t))}return!1}const VB=(n,e={})=>t=>{const s=dC({...t,processors:e});return pn(n,s),fC(s,n),hC(s,n)},Wd=(n,e,t={})=>s=>{const{libraryOptions:r,target:o}=s??{},i=dC({...r??{},target:o,io:e,processors:t});return pn(n,i),fC(i,n),hC(i,n)},da=(n,e,t)=>{(n[e]===void 0||t>n[e])&&(n[e]=t)},fa=(n,e,t)=>{(n[e]===void 0||t<n[e])&&(n[e]=t)},z2=(n,e)=>{da(n,"minimum",e),fa(n,"maximum",e)},gC=(n,e)=>{n.multipleOf??(n.multipleOf=[]),n.multipleOf.includes(e)||n.multipleOf.push(e)},xC=(n,e)=>{n.patterns??(n.patterns=new Set),n.patterns.add(e)},bC=(n,e)=>{n.mime=n.mime?n.mime.filter(t=>e.includes(t)):[...e]},vC=(n,e)=>{n.format=e,e.includes("int")&&(n.isInt=!0)},D2=(n,e)=>da(n,"minimum",e.minimum),F2=(n,e)=>fa(n,"maximum",e.maximum),U2=n=>(e,t)=>{vC(e,t.format);const[s,r]=n[t.format];da(e,"minimum",s),fa(e,"maximum",r)},rp={greater_than:(n,e)=>da(n,e.inclusive?"minimum":"exclusiveMinimum",e.value),less_than:(n,e)=>fa(n,e.inclusive?"maximum":"exclusiveMaximum",e.value),multiple_of:(n,e)=>gC(n,e.value),number_format:U2(D5),bigint_format:U2(rD),min_length:D2,max_length:F2,length_equals:(n,e)=>z2(n,e.length),min_size:D2,max_size:F2,size_equals:(n,e)=>z2(n,e.size),string_format:(n,e)=>{vC(n,e.format),e.pattern&&xC(n,e.pattern),(e.format==="base64"||e.format==="base64url")&&(n.contentEncoding=e.format),(e.local||e.precision===-1)&&(n.laxFormat=!0)},mime_type:(n,e)=>bC(n,e.mime)};function Ws(n){var o;const e={},t=n._zod.def,s=n._zod.traits.has("$ZodCheck")?[n,...t.checks??[]]:t.checks??[];for(const i of s)(o=rp[i._zod.def.check])==null||o.call(rp,e,i._zod.def);const r=n._zod.bag;r.minimum!==void 0&&da(e,"minimum",r.minimum),r.exclusiveMinimum!==void 0&&da(e,"exclusiveMinimum",r.exclusiveMinimum),r.maximum!==void 0&&fa(e,"maximum",r.maximum),r.exclusiveMaximum!==void 0&&fa(e,"exclusiveMaximum",r.exclusiveMaximum),r.multipleOf!==void 0&&gC(e,r.multipleOf),r.format!==void 0&&(e.format??(e.format=r.format),r.format.includes("int")&&(e.isInt=!0)),r.mime&&bC(e,r.mime);for(const i of r.patterns??[])xC(e,i);return e}const HB={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},KB=new Map([[eC,oF],[b0,iF]]),yC=n=>KB.get(n)??n,GB=(n,e,t,s)=>{const r=t;r.type="string";const{minimum:o,maximum:i,format:l,patterns:c,contentEncoding:u,laxFormat:d}=Ws(n);if(typeof o=="number"&&(r.minLength=o),typeof i=="number"&&(r.maxLength=i),l&&(r.format=HB[l]??l,r.format===""&&delete r.format,(l==="time"||d)&&delete r.format),u&&(r.contentEncoding=u),c&&c.size>0){const f=[...c].map(yC);f.length===1?r.pattern=f[0].source:f.length>1&&(r.allOf=[...f.map(m=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},ZB=(n,e,t,s)=>{const r=t,{minimum:o,maximum:i,multipleOf:l,exclusiveMaximum:c,exclusiveMinimum:u,isInt:d}=Ws(n);r.type=d?"integer":"number";const f=typeof u=="number"&&u>=(o??Number.NEGATIVE_INFINITY),m=typeof c=="number"&&c<=(i??Number.POSITIVE_INFINITY),p=e.target==="draft-04"||e.target==="openapi-3.0";if(f?p?(r.minimum=u,r.exclusiveMinimum=!0):r.exclusiveMinimum=u:typeof o=="number"&&(r.minimum=o),m?p?(r.maximum=c,r.exclusiveMaximum=!0):r.exclusiveMaximum=c:typeof i=="number"&&(r.maximum=i),l){const h=new Set;for(const b of l)Number.isFinite(b)&&b!==0?h.add(Math.abs(b)):Mo(n,e,r,s,`A multipleOf divisor of ${b} cannot be represented in JSON Schema`);const[g,...x]=h;g!==void 0&&(r.multipleOf=g),x.length&&(r.allOf=[...r.allOf??[],...x.map(b=>({multipleOf:b}))])}},YB=(n,e,t,s)=>{t.type="boolean"},XB=(n,e,t,s)=>{e.target==="openapi-3.0"?(t.type="string",t.nullable=!0,t.enum=[null]):t.type="null"},JB=(n,e,t,s)=>{t.not={}},QB=(n,e,t,s)=>{},eW=(n,e,t,s)=>{const r=n._zod.def,o=Mg(r.entries);if(o.length===0){t.not={};return}o.every(i=>typeof i=="number")&&(t.type="number"),o.every(i=>typeof i=="string")&&(t.type="string"),t.enum=o},tW=(n,e,t,s)=>{const r=n._zod.def;if(r.values.length===0){t.not={};return}const o=[];for(const i of r.values)if(i===void 0){if(Mo(n,e,t,s,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i=="bigint"){if(Mo(n,e,t,s,"BigInt literals cannot be represented in JSON Schema"))return;o.push(Number(i))}else o.push(i);if(o.length!==0)if(o.length===1){const i=o[0];t.type=i===null?"null":typeof i,e.target==="draft-04"||e.target==="openapi-3.0"?t.enum=[i]:t.const=i}else o.every(i=>typeof i=="number")&&(t.type="number"),o.every(i=>typeof i=="string")&&(t.type="string"),o.every(i=>typeof i=="boolean")&&(t.type="boolean"),o.every(i=>i===null)&&(t.type="null"),t.enum=o},nW=(n,e,t,s)=>{Mo(n,e,t,s,"Custom types cannot be represented in JSON Schema")},sW=(n,e,t,s)=>{Mo(n,e,t,s,"Transforms cannot be represented in JSON Schema")},rW=(n,e,t,s)=>{const r=t,o=n._zod.def,{minimum:i,maximum:l}=Ws(n);typeof i=="number"&&(r.minItems=i),typeof l=="number"&&(r.maxItems=l),r.type="array",r.items=pn(o.element,e,{...s,path:[...s.path,"items"]})};function qd(n){const e=n._zod.def;return e.type==="pipe"&&e.in._zod.traits.has("$ZodTransform")?qd(e.out):e.type==="catch"?qd(e.innerType):n._zod.optin}const oW=(n,e,t,s)=>{var u;const r=t,o=n._zod.def,i=o.shape;if(Object.getOwnPropertySymbols(i).length&&Mo(n,e,r,s,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(const d in i)lo(r.properties,d,pn(i[d],e,{...s,path:[...s.path,"properties",d]}));const c=[];for(const d of Object.keys(i)){const f=o.shape[d];(e.io==="input"?qd(f)===void 0:f._zod.optout===void 0)&&c.push(d)}c.length>0&&(r.required=c),((u=o.catchall)==null?void 0:u._zod.def.type)==="never"?r.additionalProperties=!1:o.catchall?o.catchall&&(r.additionalProperties=pn(o.catchall,e,{...s,path:[...s.path,"additionalProperties"]})):e.io==="output"&&(r.additionalProperties=!1)},iW=(n,e,t,s)=>{const r=n._zod.def,o=r.inclusive===!1,i=r.options.map((l,c)=>pn(l,e,{...s,path:[...s.path,o?"oneOf":"anyOf",c]}));o?t.oneOf=i:t.anyOf=i},aW=(n,e,t,s)=>{const r=n._zod.def,o=pn(r.left,e,{...s,path:[...s.path,"allOf",0]}),i=pn(r.right,e,{...s,path:[...s.path,"allOf",1]}),l=u=>"allOf"in u&&Object.keys(u).length===1,c=[...l(o)?o.allOf:[o],...l(i)?i.allOf:[i]];t.allOf=c,e.intersections.push(c)};function qg(n,e,t){var h;if(e.$ref){if(t.has(e))return e;t.add(e);const g=(h=n.get(e))==null?void 0:h.def;if(!g)return e;const x=qg(n,g,t);return x===g?e:x}for(const g of["anyOf","oneOf"]){const x=e[g];if(!Array.isArray(x))continue;const b=x.map(w=>qg(n,w,t));b.some((w,v)=>w!==x[v])&&(e={...e,[g]:b})}const s=Array.isArray(e.type)?e.type:[e.type],r=!s.includes("string")&&s.some(g=>g==="number"||g==="integer"),o=e.enum??(e.const!==void 0?[e.const]:void 0);if(!r&&!(o!=null&&o.some(g=>typeof g=="number")))return e;const{minimum:i,maximum:l,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:d,format:f,id:m,...p}=e;return p.enum?p.enum=p.enum.map(g=>typeof g=="number"?String(g):g):typeof p.const=="number"&&(p.const=String(p.const)),r&&(p.type="string",o||(p.pattern=(s.includes("number")?h0:pF).source)),p}const Vg=new WeakMap;function lW(n){var s;const e=new Map;for(const r of n.seen.values())r.def&&!e.has(r.schema)&&e.set(r.schema,r);const t=new Map;for(const r of Vg.get(n)??[]){const o=n.seen.get(r),i=(s=(o==null?void 0:o.def)??(o==null?void 0:o.schema))==null?void 0:s.propertyNames;if(!i||i===!0||t.has(i))continue;const l=qg(e,i,new Set);l!==i&&t.set(i,l)}if(t.size)for(const r of n.seen.values())for(const o of[r.schema,r.def]){const i=o&&t.get(o.propertyNames);i&&(o.propertyNames=i)}}const cW=(n,e,t,s)=>{const r=t,o=n._zod.def;r.type="object";const i=o.keyType,l=Ws(i).patterns;if(o.mode==="loose"&&l&&l.size>0){const d=pn(o.valueType,e,{...s,path:[...s.path,"patternProperties","*"]});r.patternProperties={};for(const f of l)lo(r.patternProperties,yC(f).source,d)}else{if(e.target==="draft-07"||e.target==="draft-2020-12"){r.propertyNames=pn(o.keyType,e,{...s,path:[...s.path,"propertyNames"]});let d=Vg.get(e);d||(d=[],Vg.set(e,d),e.deferred.push(()=>lW(e))),d.push(n)}r.additionalProperties=pn(o.valueType,e,{...s,path:[...s.path,"additionalProperties"]})}const c=i._zod.values,u=e.io==="input"&&qd(o.valueType)!==void 0;if(c&&!o.partial&&!u){const d=[...c].filter(f=>typeof f=="string"||typeof f=="number");d.length>0&&(r.required=d.map(String))}},uW=(n,e,t,s)=>{const r=n._zod.def,o=pn(r.innerType,e,s),i=e.seen.get(n);e.target==="openapi-3.0"?(i.ref=r.innerType,t.nullable=!0):t.anyOf=[o,{type:"null"}]},dW=(n,e,t,s)=>{const r=n._zod.def;pn(r.innerType,e,s);const o=e.seen.get(n);o.ref=r.innerType},v0=Symbol();function wC(n,e,t,s,r){let o=!1;const i=JSON.stringify(n,(l,c)=>typeof c!="bigint"?c:(o=!0,null));return o?(Mo(e,t,s,r,"BigInt defaults cannot be represented in JSON Schema"),v0):JSON.parse(i)}const fW=(n,e,t,s)=>{const r=n._zod.def;pn(r.innerType,e,s);const o=e.seen.get(n);o.ref=r.innerType;const i=wC(r.defaultValue,n,e,t,s);i!==v0&&(t.default=i)},mW=(n,e,t,s)=>{const r=n._zod.def;pn(r.innerType,e,s);const o=e.seen.get(n);if(o.ref=r.innerType,e.io!=="input")return;const i=wC(r.defaultValue,n,e,t,s);i!==v0&&(t._prefault=i)},pW=(n,e,t,s)=>{const r=n._zod.def;pn(r.innerType,e,s);const o=e.seen.get(n);o.ref=r.innerType;let i;try{i=r.catchValue(void 0)}catch{Mo(n,e,t,s,"Dynamic catch values are not supported in JSON Schema");return}t.default=i},hW=(n,e,t,s)=>{const r=n._zod.def,o=r.in._zod.traits.has("$ZodTransform"),i=e.io==="input"?o?r.out:r.in:r.out;pn(i,e,s);const l=e.seen.get(n);l.ref=i},gW=(n,e,t,s)=>{const r=n._zod.def;pn(r.innerType,e,s);const o=e.seen.get(n);o.ref=r.innerType,t.readOnly=!0},SC=(n,e,t,s)=>{const r=n._zod.def;pn(r.innerType,e,s);const o=e.seen.get(n);o.ref=r.innerType},B2=new WeakSet([Object.prototype,Error.prototype]);function wu(n,e,t){Object.defineProperty(n,e,{configurable:!0,enumerable:!1,get(){const s=t(this);return Object.defineProperty(this,e,{value:s,configurable:!0,writable:!0}),s},set(s){Object.defineProperty(this,e,{value:s,configurable:!0,writable:!0})}})}const xW=(n,e)=>{CD.init(n,e),n.name="ZodError";const t=Object.getPrototypeOf(n);B2.has(t)||(B2.add(t),wu(t,"format",s=>r=>TD(s,r)),wu(t,"flatten",s=>r=>ED(s,r)),wu(t,"addIssue",s=>r=>{s.issues.push(r),s.message=JSON.stringify(s.issues,zg,2)}),wu(t,"addIssues",s=>r=>{s.issues.push(...r),s.message=JSON.stringify(s.issues,zg,2)}),Object.defineProperty(t,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},Ts=pe("ZodError",xW,void 0,{Parent:Error}),bW=d0(Ts),vW=f0(Ts),yW=m0(Ts),wW=p0(Ts),SW=OD(Ts),kW=LD(Ts),jW=MD(Ts),NW=zD(Ts),CW=DD(Ts),_W=FD(Ts),EW=UD(Ts),TW=BD(Ts);function AW(){Qs.localeError||Er(HU())}function Zf(){Qs.memoizer||Er({memoizer:WU()})}const qt=pe("ZodType",(n,e)=>(AW(),Bt.init(n,e),n.def=e,n.type=e.type,n),{check(...n){const e=this.def;return this.clone(hs(e,{checks:[...e.checks??[],...n.map(t=>typeof t=="function"?{_zod:{check:t,def:{check:"custom"},onattach:[]}}:t)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,e){return Ho(this,n,e)},brand(){return this},register(n,e){return n.add(this,e),this},refine(n,e){return this.check(Nq(n,e))},superRefine(n,e){return this.check(Cq(n,e))},overwrite(n){return this.check(La(n))},optional(){return V2(this)},exactOptional(){return mq(this)},nullable(){return H2(this)},nullish(){return V2(H2(this))},nonoptional(n){return vq(this,n)},array(){return at(this)},or(n){return eo([this,n])},and(n){return cq(this,n)},transform(n){return K2(this,fq(n))},default(n){return gq(this,n)},prefault(n){return bq(this,n)},catch(n){return wq(this,n)},pipe(n){return K2(this,n)},readonly(){return jq(this)},describe(n){const e=this.clone();return ol.add(e,{description:n}),e},meta(...n){if(n.length===0)return ol.get(this);const e=this.clone();return ol.add(e,n[0]),e},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n,...e){return e.length===0?n(this):n(this,...e)},get"~standard"(){return U5(this,"~standard",{...Z5(this),jsonSchema:{input:Wd(this,"input"),output:Wd(this,"output")}})},set"~standard"(n){Lo(this,"~standard",n)},parse:function n(e,t){return bW(this,e,t,{callee:n})},parseAsync:async function n(e,t){return await vW(this,e,t,{callee:n})},safeParse(n,e){return yW(this,n,e)},async safeParseAsync(n,e){return wW(this,n,e)},get spa(){return this==null?void 0:this.safeParseAsync},set spa(n){Lo(this,"spa",n)},validate(n,e){return PD(this,n,e)},validateAsync(n,e){return RD(this,n,e)},encode:function n(e,t){return SW(this,e,t,{callee:n})},decode:function n(e,t){return kW(this,e,t,{callee:n})},encodeAsync:async function n(e,t){return await jW(this,e,t,{callee:n})},decodeAsync:async function n(e,t){return await NW(this,e,t,{callee:n})},safeEncode(n,e){return CW(this,n,e)},safeDecode(n,e){return _W(this,n,e)},async safeEncodeAsync(n,e){return EW(this,n,e)},async safeDecodeAsync(n,e){return TW(this,n,e)},toJSONSchema(n){return VB(this,{})(n)},get description(){var n;return(n=ol.get(this))==null?void 0:n.description},get _def(){return this._zod.def}}),kC=pe("_ZodString",(n,e)=>{x0.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>GB(n,t,s)},B5({format:n=>Ws(n).format??null,minLength:n=>Ws(n).minimum??null,maxLength:n=>Ws(n).maximum??null},{regex(...n){return this.check(EB(...n))},includes(...n){return this.check(IB(...n))},startsWith(...n){return this.check(PB(...n))},endsWith(...n){return this.check($B(...n))},min(...n){return this.check(Bd(...n))},max(...n){return this.check(cC(...n))},length(...n){return this.check(uC(...n))},nonempty(...n){return this.check(Bd(1,...n))},lowercase(n){return this.check(TB(n))},uppercase(n){return this.check(AB(n))},trim(){return this.check(OB())},normalize(...n){return this.check(RB(...n))},toLowerCase(){return this.check(LB())},toUpperCase(){return this.check(MB())},slugify(){return this.check(zB())}})),IW=pe("ZodString",(n,e)=>{x0.init(n,e),kC.init(n,e)},{email(n){return this.check(YU(LW,n))},url(n){return this.check(nB(zW,n))},jwt(n){return this.check(xB(QW,n))},emoji(n){return this.check(sB(DW,n))},guid(n){return this.check(XU(MW,n))},uuid(n){return this.check(JU(Su,n))},uuidv4(n){return this.check(QU(Su,n))},uuidv6(n){return this.check(eB(Su,n))},uuidv7(n){return this.check(tB(Su,n))},nanoid(n){return this.check(rB(FW,n))},cuid(n){return this.check(oB(UW,n))},cuid2(n){return this.check(iB(BW,n))},ulid(n){return this.check(aB(WW,n))},base64(n){return this.check(pB(YW,n))},base64url(n){return this.check(hB(XW,n))},xid(n){return this.check(lB(qW,n))},ksuid(n){return this.check(cB(VW,n))},ipv4(n){return this.check(uB(HW,n))},ipv6(n){return this.check(dB(KW,n))},cidrv4(n){return this.check(fB(GW,n))},cidrv6(n){return this.check(mB(ZW,n))},e164(n){return this.check(gB(JW,n))},datetime(n){return this.check(bB(PW,n))},date(n){return this.check(vB($W,n))},time(n){return this.check(yB(RW,n))},duration(n){return this.check(wB(OW,n))}});function Le(n){return ZU(IW,n)}const Xt=pe("ZodStringFormat",(n,e)=>{Wt.init(n,e),kC.init(n,e)}),PW=pe("ZodISODateTime",(n,e)=>{YF.init(n,e),Xt.init(n,e)}),$W=pe("ZodISODate",(n,e)=>{XF.init(n,e),Xt.init(n,e)}),RW=pe("ZodISOTime",(n,e)=>{JF.init(n,e),Xt.init(n,e)}),OW=pe("ZodISODuration",(n,e)=>{QF.init(n,e),Xt.init(n,e)}),LW=pe("ZodEmail",(n,e)=>{LF.init(n,e),Xt.init(n,e)}),MW=pe("ZodGUID",(n,e)=>{RF.init(n,e),Xt.init(n,e)}),Su=pe("ZodUUID",(n,e)=>{OF.init(n,e),Xt.init(n,e)}),zW=pe("ZodURL",(n,e)=>{BF.init(n,e),Xt.init(n,e)}),DW=pe("ZodEmoji",(n,e)=>{WF.init(n,e),Xt.init(n,e)}),FW=pe("ZodNanoID",(n,e)=>{qF.init(n,e),Xt.init(n,e)}),UW=pe("ZodCUID",(n,e)=>{VF.init(n,e),Xt.init(n,e)}),BW=pe("ZodCUID2",(n,e)=>{HF.init(n,e),Xt.init(n,e)}),WW=pe("ZodULID",(n,e)=>{KF.init(n,e),Xt.init(n,e)}),qW=pe("ZodXID",(n,e)=>{GF.init(n,e),Xt.init(n,e)}),VW=pe("ZodKSUID",(n,e)=>{ZF.init(n,e),Xt.init(n,e)}),HW=pe("ZodIPv4",(n,e)=>{eU.init(n,e),Xt.init(n,e)}),KW=pe("ZodIPv6",(n,e)=>{nU.init(n,e),Xt.init(n,e)}),GW=pe("ZodCIDRv4",(n,e)=>{sU.init(n,e),Xt.init(n,e)}),ZW=pe("ZodCIDRv6",(n,e)=>{oU.init(n,e),Xt.init(n,e)}),YW=pe("ZodBase64",(n,e)=>{iU.init(n,e),Xt.init(n,e)}),XW=pe("ZodBase64URL",(n,e)=>{lU.init(n,e),Xt.init(n,e)}),JW=pe("ZodE164",(n,e)=>{cU.init(n,e),Xt.init(n,e)}),QW=pe("ZodJWT",(n,e)=>{dU.init(n,e),Xt.init(n,e)}),jC=pe("ZodNumber",(n,e)=>{tC.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>ZB(n,t,s,r),n.isFinite=!0},B5({minValue:n=>{const{minimum:e,exclusiveMinimum:t}=Ws(n);return Math.max(e??Number.NEGATIVE_INFINITY,t??Number.NEGATIVE_INFINITY)},maxValue:n=>{const{maximum:e,exclusiveMaximum:t}=Ws(n);return Math.min(e??Number.POSITIVE_INFINITY,t??Number.POSITIVE_INFINITY)},isInt:n=>{const{isInt:e,multipleOf:t}=Ws(n);return!!e||!!(t!=null&&t.some(Number.isSafeInteger))},format:n=>Ws(n).format??null},{gt(n,e){return this.check($2(n,e))},gte(n,e){return this.check(sp(n,e))},min(n,e){return this.check(sp(n,e))},lt(n,e){return this.check(P2(n,e))},lte(n,e){return this.check(np(n,e))},max(n,e){return this.check(np(n,e))},int(n){return this.check(W2(n))},safe(n){return this.check(W2(n))},positive(n){return this.check($2(0,n))},nonnegative(n){return this.check(sp(0,n))},negative(n){return this.check(P2(0,n))},nonpositive(n){return this.check(np(0,n))},multipleOf(n,e){return this.check(R2(n,e))},step(n,e){return this.check(R2(n,e))},finite(){return this}}));function bt(n){return SB(jC,n)}const eq=pe("ZodNumberFormat",(n,e)=>{fU.init(n,e),jC.init(n,e)});function W2(n){return kB(eq,n)}const tq=pe("ZodBoolean",(n,e)=>{mU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>YB(n,t,s)});function Ft(n){return jB(tq,n)}const nq=pe("ZodNull",(n,e)=>{pU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>XB(n,t,s)});function NC(n){return NB(nq,n)}const sq=pe("ZodUnknown",(n,e)=>{hU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>QB()});function Qr(){return CB(sq)}const rq=pe("ZodNever",(n,e)=>{gU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>JB(n,t,s)});function CC(n){return _B(rq,n)}const oq=pe("ZodArray",(n,e)=>{Zf(),vU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>rW(n,t,s,r),n.element=e.element},{min(n,e){return this.check(Bd(n,e))},nonempty(n){return this.check(Bd(1,n))},max(n,e){return this.check(cC(n,e))},length(n,e){return this.check(uC(n,e))},unwrap(){return this.element}});function at(n,e){return DB(oq,n,e)}const _C=pe("ZodObject",(n,e)=>{Zf(),SU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>oW(n,t,s,r),bD(n,"shape",t=>t._zod.def.shape,!1)},{keyof(){return Ct(Object.keys(this._zod.def.shape))},catchall(n){return this.clone(hs(this._zod.def,{catchall:n}))},passthrough(){return this.clone(hs(this._zod.def,{catchall:Qr()}))},loose(){return this.clone(hs(this._zod.def,{catchall:Qr()}))},strict(){return this.clone(hs(this._zod.def,{catchall:CC()}))},strip(){return this.clone(hs(this._zod.def,{catchall:void 0}))},extend(n){return aD(this,n)},safeExtend(n){return lD(this,n)},merge(n){return cD(this,n)},pick(n){return oD(this,n)},omit(n){return iD(this,n)},partial(...n){return p2(TC,this,n[0])},exactPartial(...n){return p2(AC,this,n[0],"exactPartial")},required(...n){return uD(IC,this,n[0])}});function iq(n,e){const t={type:"object",shape:n??{},...Ye(e)};return new _C(t)}function xe(n,e){return new _C({type:"object",shape:n,catchall:CC(),...Ye(e)})}const EC=pe("ZodUnion",(n,e)=>{rC.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>iW(n,t,s,r),n.options=e.options});function eo(n,e){return new EC({type:"union",options:n,...Ye(e)})}const aq=pe("ZodDiscriminatedUnion",(n,e)=>{EC.init(n,e),jU.init(n,e)});function Rr(n,e,t){return new aq({type:"union",options:e,discriminator:n,...Ye(t)})}const lq=pe("ZodIntersection",(n,e)=>{NU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>aW(n,t,s,r)});function cq(n,e){return new lq({type:"intersection",left:n,right:e})}const q2=pe("ZodRecord",(n,e)=>{Zf(),CU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>cW(n,t,s,r),n.keyType=e.keyType,n.valueType=e.valueType});function Xn(n,e,t){return!e||!e._zod?new q2({type:"record",keyType:Le(),valueType:n,...Ye(e)}):new q2({type:"record",keyType:n,valueType:e,...Ye(t)})}const Hg=pe("ZodEnum",(n,e)=>{_U.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(s,r,o)=>eW(n,s,r),n.enum=e.entries,n.options=[...n._zod.values];const t=new Set(Object.keys(e.entries));n.extract=(s,r)=>{const o={};for(const i of s)if(t.has(i))o[i]=e.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Hg({...e,checks:[],...Ye(r),entries:o})},n.exclude=(s,r)=>{const o={...e.entries};for(const i of s)if(t.has(i))delete o[i];else throw new Error(`Key ${i} not found in enum`);return new Hg({...e,checks:[],...Ye(r),entries:o})}});function Ct(n,e){const t=Array.isArray(n)?Object.fromEntries(n.map(s=>[s,s])):n;return new Hg({type:"enum",entries:t,...Ye(e)})}const uq=pe("ZodLiteral",(n,e)=>{EU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>tW(n,t,s,r),n.values=new Set(e.values),Object.defineProperty(n,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function Ze(n,e){return new uq({type:"literal",values:Array.isArray(n)?n:[n],...Ye(e)})}const dq=pe("ZodTransform",(n,e)=>{Zf(),TU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>sW(n,t,s,r),n._zod.parse=(t,s)=>{if(s.direction==="backward")throw new W5(n.constructor.name);t.addIssue=o=>{if(typeof o=="string")t.issues.push(sc(o,t.value,e));else{const i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=t.value),i.inst??(i.inst=n),t.issues.push(sc(i))}};const r=e.transform(t.value,t);return r instanceof Promise?r.then(o=>(t.value=o,t)):(t.value=r,t)}});function fq(n){return new dq({type:"transform",transform:n})}const TC=pe("ZodOptional",(n,e)=>{oC.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>SC(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function V2(n){return new TC({type:"optional",innerType:n})}const AC=pe("ZodExactOptional",(n,e)=>{AU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>SC(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function mq(n){return new AC({type:"optional",innerType:n})}const pq=pe("ZodNullable",(n,e)=>{IU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>uW(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function H2(n){return new pq({type:"nullable",innerType:n})}const hq=pe("ZodDefault",(n,e)=>{PU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>fW(n,t,s,r),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function gq(n,e){return new hq({type:"default",innerType:n,get defaultValue(){return typeof e=="function"?e():M5(e)}})}const xq=pe("ZodPrefault",(n,e)=>{$U.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>mW(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function bq(n,e){return new xq({type:"prefault",innerType:n,get defaultValue(){return typeof e=="function"?e():M5(e)}})}const IC=pe("ZodNonOptional",(n,e)=>{RU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>dW(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function vq(n,e){return new IC({type:"nonoptional",innerType:n,...Ye(e)})}const yq=pe("ZodCatch",(n,e)=>{OU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>pW(n,t,s,r),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function wq(n,e){return new yq({type:"catch",innerType:n,catchValue:typeof e=="function"?e:yD(e)})}const Sq=pe("ZodPipe",(n,e)=>{LU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>hW(n,t,s,r),n.in=e.in,n.out=e.out});function K2(n,e){return new Sq({type:"pipe",in:n,out:e})}const kq=pe("ZodReadonly",(n,e)=>{MU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>gW(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function jq(n){return new kq({type:"readonly",innerType:n})}const PC=pe("ZodCustom",(n,e)=>{zU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>nW(n,t,s,r)});function $C(n,e){return FB(PC,n??(()=>!0),e)}function Nq(n,e={}){return UB(PC,n,e)}function Cq(n,e){return BB(n,e)}var ku={exports:{}},op,G2;function Lc(){if(G2)return op;G2=1;const n="2.0.0",e=256,t=Number.MAX_SAFE_INTEGER||9007199254740991,s=16,r=e-6;return op={MAX_LENGTH:e,MAX_SAFE_COMPONENT_LENGTH:s,MAX_SAFE_BUILD_LENGTH:r,MAX_SAFE_INTEGER:t,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:n,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2},op}var ip,Z2;function Yf(){if(Z2)return ip;Z2=1;var n={};return ip=typeof process=="object"&&n&&n.NODE_DEBUG&&/\bsemver\b/i.test(n.NODE_DEBUG)?(...t)=>console.error("SEMVER",...t):()=>{},ip}var Y2;function Mc(){return Y2||(Y2=1,(function(n,e){const{MAX_SAFE_COMPONENT_LENGTH:t,MAX_SAFE_BUILD_LENGTH:s,MAX_LENGTH:r}=Lc(),o=Yf();e=n.exports={};const i=e.re=[],l=e.safeRe=[],c=e.src=[],u=e.safeSrc=[],d=e.t={};let f=0;const m="[a-zA-Z0-9-]",p=[["\\s",1],["\\d",r],[m,s]],h=x=>{for(const[b,w]of p)x=x.split(`${b}*`).join(`${b}{0,${w}}`).split(`${b}+`).join(`${b}{1,${w}}`);return x},g=(x,b,w)=>{const v=h(b),j=f++;o(x,j,b),d[x]=j,c[j]=b,u[j]=v,i[j]=new RegExp(b,w?"g":void 0),l[j]=new RegExp(v,w?"g":void 0)};g("NUMERICIDENTIFIER","0|[1-9]\\d*"),g("NUMERICIDENTIFIERLOOSE","\\d+"),g("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${m}*`),g("MAINVERSION",`(${c[d.NUMERICIDENTIFIER]})\\.(${c[d.NUMERICIDENTIFIER]})\\.(${c[d.NUMERICIDENTIFIER]})`),g("MAINVERSIONLOOSE",`(${c[d.NUMERICIDENTIFIERLOOSE]})\\.(${c[d.NUMERICIDENTIFIERLOOSE]})\\.(${c[d.NUMERICIDENTIFIERLOOSE]})`),g("PRERELEASEIDENTIFIER",`(?:${c[d.NONNUMERICIDENTIFIER]}|${c[d.NUMERICIDENTIFIER]})`),g("PRERELEASEIDENTIFIERLOOSE",`(?:${c[d.NONNUMERICIDENTIFIER]}|${c[d.NUMERICIDENTIFIERLOOSE]})`),g("PRERELEASE",`(?:-(${c[d.PRERELEASEIDENTIFIER]}(?:\\.${c[d.PRERELEASEIDENTIFIER]})*))`),g("PRERELEASELOOSE",`(?:-?(${c[d.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[d.PRERELEASEIDENTIFIERLOOSE]})*))`),g("BUILDIDENTIFIER",`${m}+`),g("BUILD",`(?:\\+(${c[d.BUILDIDENTIFIER]}(?:\\.${c[d.BUILDIDENTIFIER]})*))`),g("FULLPLAIN",`v?${c[d.MAINVERSION]}${c[d.PRERELEASE]}?${c[d.BUILD]}?`),g("FULL",`^${c[d.FULLPLAIN]}$`),g("LOOSEPLAIN",`[v=\\s]*${c[d.MAINVERSIONLOOSE]}${c[d.PRERELEASELOOSE]}?${c[d.BUILD]}?`),g("LOOSE",`^${c[d.LOOSEPLAIN]}$`),g("GTLT","((?:<|>)?=?)"),g("XRANGEIDENTIFIERLOOSE",`${c[d.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),g("XRANGEIDENTIFIER",`${c[d.NUMERICIDENTIFIER]}|x|X|\\*`),g("XRANGEPLAIN",`[v=\\s]*(${c[d.XRANGEIDENTIFIER]})(?:\\.(${c[d.XRANGEIDENTIFIER]})(?:\\.(${c[d.XRANGEIDENTIFIER]})(?:${c[d.PRERELEASE]})?${c[d.BUILD]}?)?)?`),g("XRANGEPLAINLOOSE",`[v=\\s]*(${c[d.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[d.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[d.XRANGEIDENTIFIERLOOSE]})(?:${c[d.PRERELEASELOOSE]})?${c[d.BUILD]}?)?)?`),g("XRANGE",`^${c[d.GTLT]}\\s*${c[d.XRANGEPLAIN]}$`),g("XRANGELOOSE",`^${c[d.GTLT]}\\s*${c[d.XRANGEPLAINLOOSE]}$`),g("COERCEPLAIN",`(^|[^\\d])(\\d{1,${t}})(?:\\.(\\d{1,${t}}))?(?:\\.(\\d{1,${t}}))?`),g("COERCE",`${c[d.COERCEPLAIN]}(?:$|[^\\d])`),g("COERCEFULL",c[d.COERCEPLAIN]+`(?:${c[d.PRERELEASE]})?(?:${c[d.BUILD]})?(?:$|[^\\d])`),g("COERCERTL",c[d.COERCE],!0),g("COERCERTLFULL",c[d.COERCEFULL],!0),g("LONETILDE","(?:~>?)"),g("TILDETRIM",`(\\s*)${c[d.LONETILDE]}\\s+`,!0),e.tildeTrimReplace="$1~",g("TILDE",`^${c[d.LONETILDE]}${c[d.XRANGEPLAIN]}$`),g("TILDELOOSE",`^${c[d.LONETILDE]}${c[d.XRANGEPLAINLOOSE]}$`),g("LONECARET","(?:\\^)"),g("CARETTRIM",`(\\s*)${c[d.LONECARET]}\\s+`,!0),e.caretTrimReplace="$1^",g("CARET",`^${c[d.LONECARET]}${c[d.XRANGEPLAIN]}$`),g("CARETLOOSE",`^${c[d.LONECARET]}${c[d.XRANGEPLAINLOOSE]}$`),g("COMPARATORLOOSE",`^${c[d.GTLT]}\\s*(${c[d.LOOSEPLAIN]})$|^$`),g("COMPARATOR",`^${c[d.GTLT]}\\s*(${c[d.FULLPLAIN]})$|^$`),g("COMPARATORTRIM",`(\\s*)${c[d.GTLT]}\\s*(${c[d.LOOSEPLAIN]}|${c[d.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace="$1$2$3",g("HYPHENRANGE",`^\\s*(${c[d.XRANGEPLAIN]})\\s+-\\s+(${c[d.XRANGEPLAIN]})\\s*$`),g("HYPHENRANGELOOSE",`^\\s*(${c[d.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[d.XRANGEPLAINLOOSE]})\\s*$`),g("STAR","(<|>)?=?\\s*\\*"),g("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),g("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")})(ku,ku.exports)),ku.exports}var ap,X2;function y0(){if(X2)return ap;X2=1;const n=Object.freeze({loose:!0}),e=Object.freeze({});return ap=s=>s?typeof s!="object"?n:s:e,ap}var lp,J2;function RC(){if(J2)return lp;J2=1;const n=/^[0-9]+$/,e=(s,r)=>{if(typeof s=="number"&&typeof r=="number")return s===r?0:s<r?-1:1;const o=n.test(s),i=n.test(r);return o&&i&&(s=+s,r=+r),s===r?0:o&&!i?-1:i&&!o?1:s<r?-1:1};return lp={compareIdentifiers:e,rcompareIdentifiers:(s,r)=>e(r,s)},lp}var cp,Q2;function Wn(){if(Q2)return cp;Q2=1;const n=Yf(),{MAX_LENGTH:e,MAX_SAFE_INTEGER:t}=Lc(),{safeRe:s,t:r}=Mc(),o=y0(),{compareIdentifiers:i}=RC(),l=(u,d)=>{const f=d.split(".");if(f.length>u.length)return!1;for(let m=0;m<f.length;m++)if(i(u[m],f[m])!==0)return!1;return!0};class c{constructor(d,f){if(f=o(f),d instanceof c){if(d.loose===!!f.loose&&d.includePrerelease===!!f.includePrerelease)return d;d=d.version}else if(typeof d!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof d}".`);if(d.length>e)throw new TypeError(`version is longer than ${e} characters`);n("SemVer",d,f),this.options=f,this.loose=!!f.loose,this.includePrerelease=!!f.includePrerelease;const m=d.trim().match(f.loose?s[r.LOOSE]:s[r.FULL]);if(!m)throw new TypeError(`Invalid Version: ${d}`);if(this.raw=d,this.major=+m[1],this.minor=+m[2],this.patch=+m[3],this.major>t||this.major<0)throw new TypeError("Invalid major version");if(this.minor>t||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>t||this.patch<0)throw new TypeError("Invalid patch version");m[4]?this.prerelease=m[4].split(".").map(p=>{if(/^[0-9]+$/.test(p)){const h=+p;if(h>=0&&h<t)return h}return p}):this.prerelease=[],this.build=m[5]?m[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(d){if(n("SemVer.compare",this.version,this.options,d),!(d instanceof c)){if(typeof d=="string"&&d===this.version)return 0;d=new c(d,this.options)}return d.version===this.version?0:this.compareMain(d)||this.comparePre(d)}compareMain(d){return d instanceof c||(d=new c(d,this.options)),this.major<d.major?-1:this.major>d.major?1:this.minor<d.minor?-1:this.minor>d.minor?1:this.patch<d.patch?-1:this.patch>d.patch?1:0}comparePre(d){if(d instanceof c||(d=new c(d,this.options)),this.prerelease.length&&!d.prerelease.length)return-1;if(!this.prerelease.length&&d.prerelease.length)return 1;if(!this.prerelease.length&&!d.prerelease.length)return 0;let f=0;do{const m=this.prerelease[f],p=d.prerelease[f];if(n("prerelease compare",f,m,p),m===void 0&&p===void 0)return 0;if(p===void 0)return 1;if(m===void 0)return-1;if(m===p)continue;return i(m,p)}while(++f)}compareBuild(d){d instanceof c||(d=new c(d,this.options));let f=0;do{const m=this.build[f],p=d.build[f];if(n("build compare",f,m,p),m===void 0&&p===void 0)return 0;if(p===void 0)return 1;if(m===void 0)return-1;if(m===p)continue;return i(m,p)}while(++f)}inc(d,f,m){if(d.startsWith("pre")){if(!f&&m===!1)throw new Error("invalid increment argument: identifier is empty");if(f){const p=`-${f}`.match(this.options.loose?s[r.PRERELEASELOOSE]:s[r.PRERELEASE]);if(!p||p[1]!==f)throw new Error(`invalid identifier: ${f}`)}}switch(d){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",f,m);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",f,m);break;case"prepatch":this.prerelease.length=0,this.inc("patch",f,m),this.inc("pre",f,m);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",f,m),this.inc("pre",f,m);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{const p=Number(m)?1:0;if(this.prerelease.length===0)this.prerelease=[p];else{let h=this.prerelease.length;for(;--h>=0;)typeof this.prerelease[h]=="number"&&(this.prerelease[h]++,h=-2);if(h===-1){if(f===this.prerelease.join(".")&&m===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(p)}}if(f){let h=[f,p];if(m===!1&&(h=[f]),l(this.prerelease,f)){const g=this.prerelease[f.split(".").length];isNaN(g)&&(this.prerelease=h)}else this.prerelease=h}break}default:throw new Error(`invalid increment argument: ${d}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}return cp=c,cp}var up,ew;function wi(){if(ew)return up;ew=1;const n=Wn();return up=(t,s,r=!1)=>{if(t instanceof n)return t;try{return new n(t,s)}catch(o){if(!r)return null;throw o}},up}var dp,tw;function _q(){if(tw)return dp;tw=1;const n=wi();return dp=(t,s)=>{const r=n(t,s);return r?r.version:null},dp}var fp,nw;function Eq(){if(nw)return fp;nw=1;const n=wi();return fp=(t,s)=>{const r=n(t.trim().replace(/^[=v]+/,""),s);return r?r.version:null},fp}var mp,sw;function Tq(){if(sw)return mp;sw=1;const n=Wn();return mp=(t,s,r,o,i)=>{typeof r=="string"&&(i=o,o=r,r=void 0);try{return new n(t instanceof n?t.version:t,r).inc(s,o,i).version}catch{return null}},mp}var pp,rw;function Aq(){if(rw)return pp;rw=1;const n=wi();return pp=(t,s)=>{const r=n(t,null,!0),o=n(s,null,!0),i=r.compare(o);if(i===0)return null;const l=i>0,c=l?r:o,u=l?o:r,d=!!c.prerelease.length;if(!!u.prerelease.length&&!d){if(!u.patch&&!u.minor)return"major";if(u.compareMain(c)===0)return u.minor&&!u.patch?"minor":"patch"}const m=d?"pre":"";return r.major!==o.major?m+"major":r.minor!==o.minor?m+"minor":r.patch!==o.patch?m+"patch":"prerelease"},pp}var hp,ow;function Iq(){if(ow)return hp;ow=1;const n=Wn();return hp=(t,s)=>new n(t,s).major,hp}var gp,iw;function Pq(){if(iw)return gp;iw=1;const n=Wn();return gp=(t,s)=>new n(t,s).minor,gp}var xp,aw;function $q(){if(aw)return xp;aw=1;const n=Wn();return xp=(t,s)=>new n(t,s).patch,xp}var bp,lw;function Rq(){if(lw)return bp;lw=1;const n=wi();return bp=(t,s)=>{const r=n(t,s);return r&&r.prerelease.length?r.prerelease:null},bp}var vp,cw;function ar(){if(cw)return vp;cw=1;const n=Wn();return vp=(t,s,r)=>new n(t,r).compare(new n(s,r)),vp}var yp,uw;function Oq(){if(uw)return yp;uw=1;const n=ar();return yp=(t,s,r)=>n(s,t,r),yp}var wp,dw;function Lq(){if(dw)return wp;dw=1;const n=ar();return wp=(t,s)=>n(t,s,!0),wp}var Sp,fw;function w0(){if(fw)return Sp;fw=1;const n=Wn();return Sp=(t,s,r)=>{const o=new n(t,r),i=new n(s,r);return o.compare(i)||o.compareBuild(i)},Sp}var kp,mw;function Mq(){if(mw)return kp;mw=1;const n=w0();return kp=(t,s)=>t.sort((r,o)=>n(r,o,s)),kp}var jp,pw;function zq(){if(pw)return jp;pw=1;const n=w0();return jp=(t,s)=>t.sort((r,o)=>n(o,r,s)),jp}var Np,hw;function Xf(){if(hw)return Np;hw=1;const n=ar();return Np=(t,s,r)=>n(t,s,r)>0,Np}var Cp,gw;function S0(){if(gw)return Cp;gw=1;const n=ar();return Cp=(t,s,r)=>n(t,s,r)<0,Cp}var _p,xw;function OC(){if(xw)return _p;xw=1;const n=ar();return _p=(t,s,r)=>n(t,s,r)===0,_p}var Ep,bw;function LC(){if(bw)return Ep;bw=1;const n=ar();return Ep=(t,s,r)=>n(t,s,r)!==0,Ep}var Tp,vw;function k0(){if(vw)return Tp;vw=1;const n=ar();return Tp=(t,s,r)=>n(t,s,r)>=0,Tp}var Ap,yw;function j0(){if(yw)return Ap;yw=1;const n=ar();return Ap=(t,s,r)=>n(t,s,r)<=0,Ap}var Ip,ww;function MC(){if(ww)return Ip;ww=1;const n=OC(),e=LC(),t=Xf(),s=k0(),r=S0(),o=j0();return Ip=(l,c,u,d)=>{switch(c){case"===":return typeof l=="object"&&(l=l.version),typeof u=="object"&&(u=u.version),l===u;case"!==":return typeof l=="object"&&(l=l.version),typeof u=="object"&&(u=u.version),l!==u;case"":case"=":case"==":return n(l,u,d);case"!=":return e(l,u,d);case">":return t(l,u,d);case">=":return s(l,u,d);case"<":return r(l,u,d);case"<=":return o(l,u,d);default:throw new TypeError(`Invalid operator: ${c}`)}},Ip}var Pp,Sw;function Dq(){if(Sw)return Pp;Sw=1;const n=Wn(),e=wi(),{safeRe:t,t:s}=Mc();return Pp=(o,i)=>{if(o instanceof n)return o;if(typeof o=="number"&&(o=String(o)),typeof o!="string")return null;i=i||{};let l=null;if(!i.rtl)l=o.match(i.includePrerelease?t[s.COERCEFULL]:t[s.COERCE]);else{const p=i.includePrerelease?t[s.COERCERTLFULL]:t[s.COERCERTL];let h;for(;(h=p.exec(o))&&(!l||l.index+l[0].length!==o.length);)(!l||h.index+h[0].length!==l.index+l[0].length)&&(l=h),p.lastIndex=h.index+h[1].length+h[2].length;p.lastIndex=-1}if(l===null)return null;const c=l[2],u=l[3]||"0",d=l[4]||"0",f=i.includePrerelease&&l[5]?`-${l[5]}`:"",m=i.includePrerelease&&l[6]?`+${l[6]}`:"";return e(`${c}.${u}.${d}${f}${m}`,i)},Pp}var $p,kw;function Fq(){if(kw)return $p;kw=1;const n=wi(),e=Lc(),t=Wn(),s=(l,c,u)=>{if(!e.RELEASE_TYPES.includes(c))return null;const d=r(l,u);return d&&o(d,c)},r=(l,c)=>{const u=l instanceof t?l.version:l;return n(u,c)},o=(l,c)=>{if(i(c))return l.version;switch(l.prerelease=[],c){case"major":l.minor=0,l.patch=0;break;case"minor":l.patch=0;break}return l.format()},i=l=>l.startsWith("pre");return $p=s,$p}var Rp,jw;function Uq(){if(jw)return Rp;jw=1;class n{constructor(){this.max=1e3,this.map=new Map}get(t){const s=this.map.get(t);if(s!==void 0)return this.map.delete(t),this.map.set(t,s),s}delete(t){return this.map.delete(t)}set(t,s){if(!this.delete(t)&&s!==void 0){if(this.map.size>=this.max){const o=this.map.keys().next().value;this.delete(o)}this.map.set(t,s)}return this}}return Rp=n,Rp}var Op,Nw;function lr(){if(Nw)return Op;Nw=1;const n=/\s+/g;class e{constructor(I,M){if(M=r(M),I instanceof e)return I.loose===!!M.loose&&I.includePrerelease===!!M.includePrerelease?I:new e(I.raw,M);if(I instanceof o)return this.raw=I.value,this.set=[[I]],this.formatted=void 0,this;if(this.options=M,this.loose=!!M.loose,this.includePrerelease=!!M.includePrerelease,this.raw=I.trim().replace(n," "),this.set=this.raw.split("||").map(F=>this.parseRange(F.trim())).filter(F=>F.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const F=this.set[0];if(this.set=this.set.filter(U=>!b(U[0])),this.set.length===0)this.set=[F];else if(this.set.length>1){for(const U of this.set)if(U.length===1&&w(U[0])){this.set=[U];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let I=0;I<this.set.length;I++){I>0&&(this.formatted+="||");const M=this.set[I];for(let F=0;F<M.length;F++)F>0&&(this.formatted+=" "),this.formatted+=M[F].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(I){I=I.replace(x,"");const F=((this.options.includePrerelease&&h)|(this.options.loose&&g))+":"+I,U=s.get(F);if(U)return U;const O=this.options.loose,D=O?c[d.HYPHENRANGELOOSE]:c[d.HYPHENRANGE];I=I.replace(D,P(this.options.includePrerelease)),i("hyphen replace",I),I=I.replace(c[d.COMPARATORTRIM],f),i("comparator trim",I),I=I.replace(c[d.TILDETRIM],m),i("tilde trim",I),I=I.replace(c[d.CARETTRIM],p),i("caret trim",I);let B=I.split(" ").map(K=>j(K,this.options)).join(" ").split(/\s+/).map(K=>R(K,this.options));O&&(B=B.filter(K=>(i("loose invalid filter",K,this.options),!!K.match(c[d.COMPARATORLOOSE])))),i("range list",B);const q=new Map,W=B.map(K=>new o(K,this.options));for(const K of W){if(b(K))return[K];q.set(K.value,K)}q.size>1&&q.has("")&&q.delete("");const H=[...q.values()];return s.set(F,H),H}intersects(I,M){if(!(I instanceof e))throw new TypeError("a Range is required");return this.set.some(F=>v(F,M)&&I.set.some(U=>v(U,M)&&F.every(O=>U.every(D=>O.intersects(D,M)))))}test(I){if(!I)return!1;if(typeof I=="string")try{I=new l(I,this.options)}catch{return!1}for(let M=0;M<this.set.length;M++)if(z(this.set[M],I,this.options))return!0;return!1}}Op=e;const t=Uq(),s=new t,r=y0(),o=Jf(),i=Yf(),l=Wn(),{safeRe:c,src:u,t:d,comparatorTrimReplace:f,tildeTrimReplace:m,caretTrimReplace:p}=Mc(),{FLAG_INCLUDE_PRERELEASE:h,FLAG_LOOSE:g}=Lc(),x=new RegExp(u[d.BUILD],"g"),b=L=>L.value==="<0.0.0-0",w=L=>L.value==="",v=(L,I)=>{let M=!0;const F=L.slice();let U=F.pop();for(;M&&F.length;)M=F.every(O=>U.intersects(O,I)),U=F.pop();return M},j=(L,I)=>(L=L.replace(c[d.BUILD],""),i("comp",L,I),L=C(L,I),i("caret",L),L=N(L,I),i("tildes",L),L=T(L,I),i("xrange",L),L=A(L,I),i("stars",L),L),k=L=>!L||L.toLowerCase()==="x"||L==="*",_=(L,I,M)=>k(L)&&!k(I)||k(I)&&M&&!k(M),N=(L,I)=>L.trim().split(/\s+/).map(M=>S(M,I)).join(" "),S=(L,I)=>{const M=I.loose?c[d.TILDELOOSE]:c[d.TILDE],F=I.includePrerelease?"-0":"";return L.replace(M,(U,O,D,B,q)=>{i("tilde",L,U,O,D,B,q);let W;return k(O)?W="":k(D)?W=`>=${O}.0.0${F} <${+O+1}.0.0-0`:k(B)?W=`>=${O}.${D}.0${F} <${O}.${+D+1}.0-0`:q?(i("replaceTilde pr",q),W=`>=${O}.${D}.${B}-${q} <${O}.${+D+1}.0-0`):W=`>=${O}.${D}.${B} <${O}.${+D+1}.0-0`,i("tilde return",W),W})},C=(L,I)=>L.trim().split(/\s+/).map(M=>E(M,I)).join(" "),E=(L,I)=>{i("caret",L,I);const M=I.loose?c[d.CARETLOOSE]:c[d.CARET],F=I.includePrerelease?"-0":"";return L.replace(M,(U,O,D,B,q)=>{i("caret",L,U,O,D,B,q);let W;return k(O)?W="":k(D)?W=`>=${O}.0.0${F} <${+O+1}.0.0-0`:k(B)?O==="0"?W=`>=${O}.${D}.0${F} <${O}.${+D+1}.0-0`:W=`>=${O}.${D}.0${F} <${+O+1}.0.0-0`:q?(i("replaceCaret pr",q),O==="0"?D==="0"?W=`>=${O}.${D}.${B}-${q} <${O}.${D}.${+B+1}-0`:W=`>=${O}.${D}.${B}-${q} <${O}.${+D+1}.0-0`:W=`>=${O}.${D}.${B}-${q} <${+O+1}.0.0-0`):(i("no pr"),O==="0"?D==="0"?W=`>=${O}.${D}.${B} <${O}.${D}.${+B+1}-0`:W=`>=${O}.${D}.${B} <${O}.${+D+1}.0-0`:W=`>=${O}.${D}.${B} <${+O+1}.0.0-0`),i("caret return",W),W})},T=(L,I)=>(i("replaceXRanges",L,I),L.split(/\s+/).map(M=>$(M,I)).join(" ")),$=(L,I)=>{L=L.trim();const M=I.loose?c[d.XRANGELOOSE]:c[d.XRANGE];return L.replace(M,(F,U,O,D,B,q)=>{if(i("xRange",L,F,U,O,D,B,q),_(O,D,B))return L;const W=k(O),H=W||k(D),K=H||k(B),Z=K;return U==="="&&Z&&(U=""),q=I.includePrerelease?"-0":"",W?U===">"||U==="<"?F="<0.0.0-0":F="*":U&&Z?(H&&(D=0),B=0,U===">"?(U=">=",H?(O=+O+1,D=0,B=0):(D=+D+1,B=0)):U==="<="&&(U="<",H?O=+O+1:D=+D+1),U==="<"&&(q="-0"),F=`${U+O}.${D}.${B}${q}`):H?F=`>=${O}.0.0${q} <${+O+1}.0.0-0`:K&&(F=`>=${O}.${D}.0${q} <${O}.${+D+1}.0-0`),i("xRange return",F),F})},A=(L,I)=>(i("replaceStars",L,I),L.trim().replace(c[d.STAR],"")),R=(L,I)=>(i("replaceGTE0",L,I),L.trim().replace(c[I.includePrerelease?d.GTE0PRE:d.GTE0],"")),P=L=>(I,M,F,U,O,D,B,q,W,H,K,Z)=>(k(F)?M="":k(U)?M=`>=${F}.0.0${L?"-0":""}`:k(O)?M=`>=${F}.${U}.0${L?"-0":""}`:D?M=`>=${M}`:M=`>=${M}${L?"-0":""}`,k(W)?q="":k(H)?q=`<${+W+1}.0.0-0`:k(K)?q=`<${W}.${+H+1}.0-0`:Z?q=`<=${W}.${H}.${K}-${Z}`:L?q=`<${W}.${H}.${+K+1}-0`:q=`<=${q}`,`${M} ${q}`.trim()),z=(L,I,M)=>{for(let F=0;F<L.length;F++)if(!L[F].test(I))return!1;if(I.prerelease.length&&!M.includePrerelease){for(let F=0;F<L.length;F++)if(i(L[F].semver),L[F].semver!==o.ANY&&L[F].semver.prerelease.length>0){const U=L[F].semver;if(U.major===I.major&&U.minor===I.minor&&U.patch===I.patch)return!0}return!1}return!0};return Op}var Lp,Cw;function Jf(){if(Cw)return Lp;Cw=1;const n=Symbol("SemVer ANY");class e{static get ANY(){return n}constructor(d,f){if(f=t(f),d instanceof e){if(d.loose===!!f.loose)return d;d=d.value}d=d.trim().split(/\s+/).join(" "),i("comparator",d,f),this.options=f,this.loose=!!f.loose,this.parse(d),this.semver===n?this.value="":this.value=this.operator+this.semver.version,i("comp",this)}parse(d){const f=this.options.loose?s[r.COMPARATORLOOSE]:s[r.COMPARATOR],m=d.match(f);if(!m)throw new TypeError(`Invalid comparator: ${d}`);this.operator=m[1]!==void 0?m[1]:"",this.operator==="="&&(this.operator=""),m[2]?this.semver=new l(m[2],this.options.loose):this.semver=n}toString(){return this.value}test(d){if(i("Comparator.test",d,this.options.loose),this.semver===n||d===n)return!0;if(typeof d=="string")try{d=new l(d,this.options)}catch{return!1}return o(d,this.operator,this.semver,this.options)}intersects(d,f){if(!(d instanceof e))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new c(d.value,f).test(this.value):d.operator===""?d.value===""?!0:new c(this.value,f).test(d.semver):(f=t(f),f.includePrerelease&&(this.value==="<0.0.0-0"||d.value==="<0.0.0-0")||!f.includePrerelease&&(this.value.startsWith("<0.0.0")||d.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&d.operator.startsWith(">")||this.operator.startsWith("<")&&d.operator.startsWith("<")||this.semver.version===d.semver.version&&this.operator.includes("=")&&d.operator.includes("=")||o(this.semver,"<",d.semver,f)&&this.operator.startsWith(">")&&d.operator.startsWith("<")||o(this.semver,">",d.semver,f)&&this.operator.startsWith("<")&&d.operator.startsWith(">")))}}Lp=e;const t=y0(),{safeRe:s,t:r}=Mc(),o=MC(),i=Yf(),l=Wn(),c=lr();return Lp}var Mp,_w;function Qf(){if(_w)return Mp;_w=1;const n=lr();return Mp=(t,s,r)=>{try{s=new n(s,r)}catch{return!1}return s.test(t)},Mp}var zp,Ew;function Bq(){if(Ew)return zp;Ew=1;const n=lr();return zp=(t,s)=>new n(t,s).set.map(r=>r.map(o=>o.value).join(" ").trim().split(" ")),zp}var Dp,Tw;function Wq(){if(Tw)return Dp;Tw=1;const n=Wn(),e=lr();return Dp=(s,r,o)=>{let i=null,l=null,c=null;try{c=new e(r,o)}catch{return null}return s.forEach(u=>{c.test(u)&&(!i||l.compare(u)===-1)&&(i=u,l=new n(i,o))}),i},Dp}var Fp,Aw;function qq(){if(Aw)return Fp;Aw=1;const n=Wn(),e=lr();return Fp=(s,r,o)=>{let i=null,l=null,c=null;try{c=new e(r,o)}catch{return null}return s.forEach(u=>{c.test(u)&&(!i||l.compare(u)===1)&&(i=u,l=new n(i,o))}),i},Fp}var Up,Iw;function Vq(){if(Iw)return Up;Iw=1;const n=Wn(),e=lr(),t=Xf();return Up=(r,o)=>{r=new e(r,o);let i=new n("0.0.0");if(r.test(i)||(i=new n("0.0.0-0"),r.test(i)))return i;i=null;for(let l=0;l<r.set.length;++l){const c=r.set[l];let u=null;c.forEach(d=>{const f=new n(d.semver.version);switch(d.operator){case">":f.prerelease.length===0?f.patch++:f.prerelease.push(0),f.raw=f.format();case"":case">=":(!u||t(f,u))&&(u=f);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${d.operator}`)}}),u&&(!i||t(i,u))&&(i=u)}return i&&r.test(i)?i:null},Up}var Bp,Pw;function Hq(){if(Pw)return Bp;Pw=1;const n=lr();return Bp=(t,s)=>{try{return new n(t,s).range||"*"}catch{return null}},Bp}var Wp,$w;function N0(){if($w)return Wp;$w=1;const n=Wn(),e=Jf(),{ANY:t}=e,s=lr(),r=Qf(),o=Xf(),i=S0(),l=j0(),c=k0();return Wp=(d,f,m,p)=>{d=new n(d,p),f=new s(f,p);let h,g,x,b,w;switch(m){case">":h=o,g=l,x=i,b=">",w=">=";break;case"<":h=i,g=c,x=o,b="<",w="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(r(d,f,p))return!1;for(let v=0;v<f.set.length;++v){const j=f.set[v];let k=null,_=null;if(j.forEach(N=>{N.semver===t&&(N=new e(">=0.0.0")),k=k||N,_=_||N,h(N.semver,k.semver,p)?k=N:x(N.semver,_.semver,p)&&(_=N)}),k.operator===b||k.operator===w||(!_.operator||_.operator===b)&&g(d,_.semver))return!1;if(_.operator===w&&x(d,_.semver))return!1}return!0},Wp}var qp,Rw;function Kq(){if(Rw)return qp;Rw=1;const n=N0();return qp=(t,s,r)=>n(t,s,">",r),qp}var Vp,Ow;function Gq(){if(Ow)return Vp;Ow=1;const n=N0();return Vp=(t,s,r)=>n(t,s,"<",r),Vp}var Hp,Lw;function Zq(){if(Lw)return Hp;Lw=1;const n=lr();return Hp=(t,s,r)=>(t=new n(t,r),s=new n(s,r),t.intersects(s,r)),Hp}var Kp,Mw;function Yq(){if(Mw)return Kp;Mw=1;const n=Qf(),e=ar();return Kp=(t,s,r)=>{const o=[];let i=null,l=null;const c=t.sort((m,p)=>e(m,p,r));for(const m of c)n(m,s,r)?(l=m,i||(i=m)):(l&&o.push([i,l]),l=null,i=null);i&&o.push([i,null]);const u=[];for(const[m,p]of o)m===p?u.push(m):!p&&m===c[0]?u.push("*"):p?m===c[0]?u.push(`<=${p}`):u.push(`${m} - ${p}`):u.push(`>=${m}`);const d=u.join(" || "),f=typeof s.raw=="string"?s.raw:String(s);return d.length<f.length?d:s},Kp}var Gp,zw;function Xq(){if(zw)return Gp;zw=1;const n=lr(),e=Jf(),{ANY:t}=e,s=Qf(),r=ar(),o=(f,m,p={})=>{if(f===m)return!0;f=new n(f,p),m=new n(m,p);let h=!1;e:for(const g of f.set){for(const x of m.set){const b=c(g,x,p);if(h=h||b!==null,b)continue e}if(h)return!1}return!0},i=[new e(">=0.0.0-0")],l=[new e(">=0.0.0")],c=(f,m,p)=>{if(f===m)return!0;if(f.length===1&&f[0].semver===t){if(m.length===1&&m[0].semver===t)return!0;p.includePrerelease?f=i:f=l}if(m.length===1&&m[0].semver===t){if(p.includePrerelease)return!0;m=l}const h=new Set;let g,x;for(const S of f)S.operator===">"||S.operator===">="?g=u(g,S,p):S.operator==="<"||S.operator==="<="?x=d(x,S,p):h.add(S.semver);if(h.size>1)return null;let b;if(g&&x){if(b=r(g.semver,x.semver,p),b>0)return null;if(b===0&&(g.operator!==">="||x.operator!=="<="))return null}for(const S of h){if(g&&!s(S,String(g),p)||x&&!s(S,String(x),p))return null;for(const C of m)if(!s(S,String(C),p))return!1;return!0}let w,v,j,k,_=x&&!p.includePrerelease&&x.semver.prerelease.length?x.semver:!1,N=g&&!p.includePrerelease&&g.semver.prerelease.length?g.semver:!1;_&&_.prerelease.length===1&&x.operator==="<"&&_.prerelease[0]===0&&(_=!1);for(const S of m){if(k=k||S.operator===">"||S.operator===">=",j=j||S.operator==="<"||S.operator==="<=",g){if(N&&S.semver.prerelease&&S.semver.prerelease.length&&S.semver.major===N.major&&S.semver.minor===N.minor&&S.semver.patch===N.patch&&(N=!1),S.operator===">"||S.operator===">="){if(w=u(g,S,p),w===S&&w!==g)return!1}else if(g.operator===">="&&!S.test(g.semver))return!1}if(x){if(_&&S.semver.prerelease&&S.semver.prerelease.length&&S.semver.major===_.major&&S.semver.minor===_.minor&&S.semver.patch===_.patch&&(_=!1),S.operator==="<"||S.operator==="<="){if(v=d(x,S,p),v===S&&v!==x)return!1}else if(x.operator==="<="&&!S.test(x.semver))return!1}if(!S.operator&&(x||g)&&b!==0)return!1}return!(g&&j&&!x&&b!==0||x&&k&&!g&&b!==0||N||_)},u=(f,m,p)=>{if(!f)return m;const h=r(f.semver,m.semver,p);return h>0?f:h<0||m.operator===">"&&f.operator===">="?m:f},d=(f,m,p)=>{if(!f)return m;const h=r(f.semver,m.semver,p);return h<0?f:h>0||m.operator==="<"&&f.operator==="<="?m:f};return Gp=o,Gp}var Zp,Dw;function Jq(){if(Dw)return Zp;Dw=1;const n=Mc(),e=Lc(),t=Wn(),s=RC(),r=wi(),o=_q(),i=Eq(),l=Tq(),c=Aq(),u=Iq(),d=Pq(),f=$q(),m=Rq(),p=ar(),h=Oq(),g=Lq(),x=w0(),b=Mq(),w=zq(),v=Xf(),j=S0(),k=OC(),_=LC(),N=k0(),S=j0(),C=MC(),E=Dq(),T=Fq(),$=Jf(),A=lr(),R=Qf(),P=Bq(),z=Wq(),L=qq(),I=Vq(),M=Hq(),F=N0(),U=Kq(),O=Gq(),D=Zq(),B=Yq(),q=Xq();return Zp={parse:r,valid:o,clean:i,inc:l,diff:c,major:u,minor:d,patch:f,prerelease:m,compare:p,rcompare:h,compareLoose:g,compareBuild:x,sort:b,rsort:w,gt:v,lt:j,eq:k,neq:_,gte:N,lte:S,cmp:C,coerce:E,truncate:T,Comparator:$,Range:A,satisfies:R,toComparators:P,maxSatisfying:z,minSatisfying:L,minVersion:I,validRange:M,outside:F,gtr:U,ltr:O,intersects:D,simplifyRange:B,subset:q,SemVer:t,re:n.re,src:n.src,tokens:n.t,SEMVER_SPEC_VERSION:e.SEMVER_SPEC_VERSION,RELEASE_TYPES:e.RELEASE_TYPES,compareIdentifiers:s.compareIdentifiers,rcompareIdentifiers:s.rcompareIdentifiers},Zp}var Vn=Jq();const lt=Le().min(1).max(64).regex(/^[a-zA-Z][a-zA-Z0-9_.-]*$/u).refine(n=>!["constructor","prototype","__proto__"].includes(n),"Reserved identifier"),_s=Le().min(1).max(128).refine(n=>[...n].every(e=>e.charCodeAt(0)>=32&&e.charCodeAt(0)!==127),"Control characters are forbidden"),Cs=n=>Le().refine(e=>Pl(e)<=n,"Text exceeds byte limit"),il=Le().min(1).max(256).refine(n=>/^[A-Za-z0-9_./-]+$/u.test(n)?n.split("/").every(e=>e!==""&&e!=="."&&e!==".."&&!e.endsWith(".")&&!/^(?:con|prn|aux|nul|com[0-9]|lpt[0-9])(?:\.|$)/iu.test(e)):!1,"Expected a canonical portable package path");function zo(n,e,t,s){const r=n.safeParse(i0(e,{maxBytes:t,maxNodes:s}));if(!r.success)throw new tc(r.error.issues.map(o=>({path:o.path.length?`$.${o.path.map(String).join(".")}`:"$",message:o.message})));return r.data}const Qq=["actions","actionJobs","pulls","pullFiles","pullSessions","issues","mergePull"],eV=["deployments","buildLogs"],tV=["workspace","deployments","version"],Yp=n=>at(Ct(n)).min(1).max(n.length).refine(e=>new Set(e).size===e.length,"Duplicate operation"),nV=Rr("id",[xe({id:Ze("github"),operations:Yp(Qq)}),xe({id:Ze("vercel"),operations:Yp(eV)}),xe({id:Ze("cloudflare"),operations:Yp(tV)})]),Br=bt().int().positive().max(Number.MAX_SAFE_INTEGER),Qo={integration:Ze("github")},Fw={integration:Ze("vercel")},Xp={integration:Ze("cloudflare")},Uw=Le().regex(/^[A-Za-z0-9_-]+$/).max(64).optional(),Jp=Le().max(240).regex(/^(?:[^/\\]+\/)*wrangler\.(?:json|jsonc|toml)$/).refine(n=>n.split("/").every(e=>e!=="."&&e!==".."),"Invalid configuration path").optional(),sV=Rr("operation",[xe({...Qo,operation:Ze("actions"),limit:Br.max(30).optional()}),xe({...Qo,operation:Ze("actionJobs"),runId:Br}),xe({...Qo,operation:Ze("pulls"),limit:Br.max(50).optional()}),xe({...Qo,operation:Ze("pullFiles"),number:Br}),xe({...Qo,operation:Ze("pullSessions")}),xe({...Qo,operation:Ze("issues"),limit:Br.max(50).optional()}),xe({...Qo,operation:Ze("mergePull"),number:Br,method:Ct(["merge","squash","rebase"]),headSha:Le().regex(/^[0-9a-f]{40}$/)})]),rV=Rr("operation",[xe({...Fw,operation:Ze("deployments"),limit:Br.max(30).optional()}),xe({...Fw,operation:Ze("buildLogs"),deploymentId:Le().regex(/^dpl_[A-Za-z0-9]+$/).max(128),limit:Br.max(500).optional()})]),oV=Rr("operation",[xe({...Xp,operation:Ze("workspace"),config:Jp}),xe({...Xp,operation:Ze("deployments"),config:Jp,environment:Uw,limit:Br.max(30).optional()}),xe({...Xp,operation:Ze("version"),config:Jp,environment:Uw,versionId:Le().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/)})]),iV=Rr("integration",[sV,rV,oV]),aV=Rr("ok",[xe({ok:Ze(!0),data:$C(()=>!0)}),xe({ok:Ze(!1),error:xe({code:Le().min(1).max(64),message:Le().min(1).max(512)})})]),ju={id:lt,label:_s,description:Cs(512).optional()},lV=Rr("type",[xe({...ju,type:Ze("string"),default:Cs(4096).default(""),maxLength:bt().int().min(1).max(4096).default(256)}),xe({...ju,type:Ze("boolean"),default:Ft().default(!1)}),xe({...ju,type:Ze("number"),default:bt().finite(),min:bt().finite(),max:bt().finite(),step:bt().positive().optional()}),xe({...ju,type:Ze("select"),default:Cs(256),options:at(xe({value:Cs(256),label:_s})).min(1).max(64)})]).superRefine((n,e)=>{n.type==="number"&&(n.min>n.max||n.default<n.min||n.default>n.max)&&e.addIssue({code:"custom",message:"Invalid numeric setting bounds/default"}),n.type==="string"&&n.default.length>n.maxLength&&e.addIssue({code:"custom",message:"Default exceeds setting length"}),n.type==="select"&&(!n.options.some(t=>t.value===n.default)||new Set(n.options.map(t=>t.value)).size!==n.options.length)&&e.addIssue({code:"custom",message:"Invalid select options/default"})}),cV=xe({scope:Ct(["plugin","project"]),fields:at(lV).min(1).max(32).refine(n=>new Set(n.map(e=>e.id)).size===n.length,"Duplicate setting ID")}).refine(n=>new TextEncoder().encode(JSON.stringify(Object.fromEntries(n.fields.map(e=>[e.id,e.default])))).byteLength<=16384,"Default settings exceed 16 KiB"),uV=xe({id:lt,title:_s,description:Cs(512),source:il.refine(n=>n.endsWith(".md"),"Skill source must be Markdown")}),dV=xe({id:Le().regex(/^[a-z][a-z0-9-]{0,63}$/u),title:_s,height:bt().int().min(80).max(800).default(240)}),fV=xe({id:lt,title:_s,skill:lt,prompt:Cs(4096).refine(n=>n.trim().length>0,"Action prompt is required")});function k2e(n,e){const t={};for(const s of n.fields)t[s.id]=s.type==="string"?Le().max(s.maxLength).default(s.default):s.type==="boolean"?Ft().default(s.default):s.type==="number"?bt().finite().min(s.min).max(s.max).default(s.default):Ct(s.options.map(r=>r.value)).default(s.default);return xe(t).parse(e)}function zC(n){const e=n==null?void 0:n.match(/^cogpit:([a-z][a-z0-9-]*\.[a-z][a-z0-9-]*):([a-z][a-z0-9-]{0,63})$/u);return e?{pluginId:e[1],blockId:e[2]}:null}const Ss=1,mV="1.2.0",DC="browser-iife-v1",Kg=Le().max(128).refine(n=>Vn.valid(n)===n,"Expected strict SemVer"),cd=Le().min(1).max(256).refine(n=>Vn.validRange(n)!==null,"Expected a SemVer range"),Bw=Xn(lt,cd).refine(n=>Object.keys(n).length<=32,"Too many capabilities"),Ww=xe({client:Bw,host:Bw}),al=n=>new Set(n).size===n.length,pV=at(lt).max(32).refine(al,"Duplicate identifier"),qw=Le().min(1).max(64).regex(/^[a-z][a-z0-9-]*$/u),Qp=Le().regex(/^(?:[1-9][0-9]{0,3}px|(?:[1-9][0-9]?|100)%)$/u),hV=xe({manifestVersion:Ze(1),id:Le().max(128).regex(/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$/u),publisher:qw,name:_s,version:Kg,runtime:Ze(DC),entry:il.refine(n=>n.endsWith(".js"),"Entry must be JavaScript").optional(),style:il.refine(n=>n.endsWith(".css"),"Style must be CSS").optional(),engines:xe({pluginApi:cd,client:cd,host:cd}),protocol:Ze(Ss).default(Ss),requires:Ww,optional:Ww.default({client:{},host:{}}),browser:at(Ct(["message-channel","blob-script","web-crypto"])).max(3).refine(al).default([]),contributes:xe({panels:at(xe({id:qw,title:_s,icon:il.refine(n=>/\.(png|jpe?g|webp)$/u.test(n),"Expected a raster icon"),order:bt().int().min(0).max(1e3).optional(),defaultSize:Qp.optional(),minSize:Qp.optional(),maxSize:Qp.optional(),when:Ct(["always","project-selected"]).default("project-selected")})).max(8).default([]),settings:cV.optional(),skills:at(uV).max(16).optional(),chatBlocks:at(dV).max(8).optional(),sessionActions:at(fV).max(8).optional()}),permissions:xe({context:at(Ct(["project.identity","session.identity"])).max(2).refine(al).default([]),composer:at(Ze("append")).max(1).default([]),navigation:at(Ct(["external","session"])).max(2).refine(al).default([]),connections:at(xe({id:lt,definition:il,operations:pV.min(1)})).max(8).default([]),integrations:at(nV).max(2).default([]),storage:xe({scope:Ct(["project","plugin"]),quotaKiB:bt().int().min(1).max(1024)}).optional()}),stateVersion:bt().int().min(1).max(Number.MAX_SAFE_INTEGER)}).superRefine((n,e)=>{var t,s,r,o;!n.contributes.panels.length&&!((t=n.contributes.skills)!=null&&t.length)&&!((s=n.contributes.chatBlocks)!=null&&s.length)&&!n.contributes.settings&&e.addIssue({code:"custom",path:["contributes"],message:"At least one contribution is required"}),(n.contributes.panels.length||(r=n.contributes.chatBlocks)!=null&&r.length)&&!n.entry&&e.addIssue({code:"custom",path:["entry"],message:"Visual contributions require a JavaScript entry"}),n.style&&!n.entry&&e.addIssue({code:"custom",path:["style"],message:"Styles require a JavaScript entry"});for(const i of n.contributes.sessionActions??[])(o=n.contributes.skills)!=null&&o.some(l=>l.id===i.skill)||e.addIssue({code:"custom",path:["contributes","sessionActions"],message:"Session actions must reference a declared skill"});n.id.startsWith(`${n.publisher}.`)||e.addIssue({code:"custom",path:["id"],message:"Plugin ID must belong to its publisher"}),["cogpit.worktrees","cogpit.project-files","cogpit.browser","cogpit.file-changes","cogpit.session-info"].includes(n.id)&&e.addIssue({code:"custom",path:["id"],message:"Reserved built-in ID"});for(const[i,l]of[["panels",n.contributes.panels],["skills",n.contributes.skills??[]],["chatBlocks",n.contributes.chatBlocks??[]],["sessionActions",n.contributes.sessionActions??[]],["connections",n.permissions.connections],["integrations",n.permissions.integrations]])al(l.map(c=>c.id))||e.addIssue({code:"custom",path:[i],message:"Duplicate contribution ID"});for(const i of["client","host"])for(const l of Object.keys(n.optional[i]))Object.hasOwn(n.requires[i],l)&&e.addIssue({code:"custom",path:["optional",i,l],message:"Capability is already required"})});function FC(n){return zo(hV,n,Qt.manifestBytes)}const C0=8*1024*1024,UC=Ct(["audio/mpeg","audio/wav","audio/flac","audio/ogg","audio/opus","audio/aac"]);function em(n){var r,o;if(!n||typeof n!="object"||Object.keys(n).length!==2)throw new tc([{path:"$",message:"Invalid media response"}]);const e=Object.getOwnPropertyDescriptors(n),t=UC.safeParse((r=e.mimeType)==null?void 0:r.value),s=(o=e.bytes)==null?void 0:o.value;if(!t.success||!(s instanceof ArrayBuffer)||s.byteLength===0||s.byteLength>C0)throw new tc([{path:"$",message:"Invalid or oversized audio response"}]);return{mimeType:t.data,bytes:s}}const BC=Le().max(256).refine(n=>{try{const e=new URL(n);return e.protocol==="https:"&&e.origin===n&&!e.username&&!e.password&&!e.port&&/^(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z][a-z0-9-]*[a-z0-9]$/u.test(e.hostname)&&!/\.(?:localhost|local|internal)$/u.test(e.hostname)}catch{return!1}},"Expected an exact public HTTPS origin"),wo=Le().max(256).refine(n=>(!n||n.startsWith("/"))&&!/~(?![01])/u.test(n)&&n.split("/").length<=9&&!n.split("/").some(e=>["__proto__","prototype","constructor"].includes(e)),"Invalid bounded JSON pointer"),WC=Le().min(1).max(1024).regex(/^[a-zA-Z0-9._~-]+$/u).refine(n=>n!=="."&&n!==".."),gV=Rr("type",[xe({type:Ze("string"),required:Ft().optional(),maxLength:bt().int().min(1).max(16384),multiline:Ft().optional(),enum:at(_s).min(1).max(64).optional()}),xe({type:Ze("integer"),required:Ft().optional(),min:bt().int().min(Number.MIN_SAFE_INTEGER),max:bt().int().max(Number.MAX_SAFE_INTEGER)}),xe({type:Ze("number"),required:Ft().optional(),min:bt().finite(),max:bt().finite()}),xe({type:Ze("boolean"),required:Ft().optional()})]),xV=eo([xe({literal:WC}),xe({resource:lt}),xe({arg:lt})]),Vw=eo([lt,xe({literal:eo([Le().max(1024),bt().int().min(Number.MIN_SAFE_INTEGER).max(Number.MAX_SAFE_INTEGER),Ft()])}),xe({arg:lt}),xe({resource:lt}),xe({identity:lt})]),bV=xe({audience:Ct(["setup","panel"]),origin:BC,method:Ct(["GET","POST"]),path:at(xV).min(1).max(16),args:Xn(lt,gV).refine(n=>Object.keys(n).length<=16),query:Xn(Le().max(68).regex(/^[a-zA-Z][a-zA-Z0-9_.-]*(?:\[\])?$/u).refine(n=>!["constructor","prototype","__proto__"].includes(n.replace(/\[\]$/u,""))),Vw).refine(n=>Object.keys(n).length<=16),body:Xn(lt,Vw).refine(n=>Object.keys(n).length<=16).optional(),response:xe({type:Ze("audio"),mimeTypes:at(UC).min(1).max(6),maxBytes:bt().int().min(1).max(C0)}).optional()}),Hw=xe({operation:lt,items:wo,nested:wo.optional(),id:wo,label:wo}),vV=xe({label:_s,scope:Ct(["connection","project"]).optional(),dependsOn:at(lt).max(7).refine(n=>new Set(n).size===n.length).optional(),options:eo([Hw,at(Hw).min(1).max(4)]).optional(),input:xe({allowId:Ft(),urls:at(xe({origin:BC,pathMarker:WC})).min(1).max(8).optional(),validation:xe({operation:lt,argument:lt,id:wo.optional(),label:wo,parents:Xn(lt,wo).refine(n=>Object.keys(n).length<=7).optional()})}).optional()}).refine(n=>!!n.options||!!n.input,"Expected listed or validated entered resources"),yV=xe({version:Ze(1),id:lt,label:_s,secret:xe({id:lt,label:_s}),auth:xe({header:Le().max(64).regex(/^(?:Authorization|X-[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*)$/iu).refine(n=>!/^x-(?:forwarded|http-method|original|rewrite)(?:-|$)/iu.test(n),"Unsafe credential header"),scheme:Ct(["raw","bearer"])}),validationOperation:lt,identity:Xn(lt,wo).refine(n=>Object.keys(n).length<=8).optional(),resources:Xn(lt,vV).refine(n=>Object.keys(n).length<=8),operations:Xn(lt,bV).refine(n=>Object.keys(n).length>0&&Object.keys(n).length<=32)});function Vd(n){return n?[...n.path.flatMap(e=>"resource"in e?[e.resource]:[]),...Object.values(n.query).flatMap(e=>typeof e=="object"&&"resource"in e?[e.resource]:[])]:[]}function Kw(n,e){const t=n.resources[e];if(!t)return[];const s=t.options?Array.isArray(t.options)?t.options:[t.options]:[];return[...new Set([...t.dependsOn??[],...s.flatMap(r=>Vd(n.operations[r.operation])),...Vd(t.input?n.operations[t.input.validation.operation]:void 0)])]}const wV=yV.superRefine((n,e)=>{var u,d;const t=(f,m)=>e.addIssue({code:"custom",path:f,message:m}),s=f=>{var m;return((m=n.operations[f])==null?void 0:m.audience)==="setup"},r=(f,m)=>f&&Object.entries(f.args).every(([p,h])=>!h.required||p===m),o=n.operations[n.validationOperation];(!s(n.validationOperation)||!r(o)||Vd(o).length||Object.values((o==null?void 0:o.query)??{}).some(f=>typeof f=="object"&&"identity"in f))&&t(["validationOperation"],"Expected an independent setup operation without required arguments");for(const[f,m]of Object.entries(n.resources)){const p=Kw(n,f);for(const g of p)(g===f||!Object.hasOwn(n.resources,g))&&t(["resources",f,"dependsOn"],"Unknown or self-dependent resource"),(m.scope??"connection")==="connection"&&((u=n.resources[g])==null?void 0:u.scope)==="project"&&t(["resources",f,"scope"],"Connection resource cannot depend on a project resource");const h=m.options?Array.isArray(m.options)?m.options:[m.options]:[];for(const g of h){const x=n.operations[g.operation];(!s(g.operation)||!r(x))&&t(["resources",f,"options"],"Expected a setup operation without required arguments"),p.some(b=>!Vd(x).includes(b))&&t(["resources",f,"options"],"Every options source must bind all parent resources")}if(m.input){const g=m.input,x=g.validation,b=n.operations[x.operation],w=b==null?void 0:b.args[x.argument];!g.allowId&&!g.urls&&t(["resources",f,"input"],"Expected an accepted input format"),(!s(x.operation)||!r(b,x.argument)||(w==null?void 0:w.type)!=="string"||!w.required||b.path.filter(v=>"arg"in v&&v.arg===x.argument).length!==1)&&t(["resources",f,"input","validation"],"Validation must request the candidate as one required path argument"),(p.some(v=>!Object.hasOwn(x.parents??{},v))||Object.keys(x.parents??{}).some(v=>!p.includes(v)))&&t(["resources",f,"input","validation","parents"],"Validation must prove each selected parent")}}const i=new Set,l=new Set,c=f=>{if(i.has(f)){t(["resources",f,"dependsOn"],"Resource dependency cycle");return}if(!l.has(f)){i.add(f);for(const m of Kw(n,f))Object.hasOwn(n.resources,m)&&c(m);i.delete(f),l.add(f)}};for(const f of Object.keys(n.resources))c(f);for(const[f,m]of Object.entries(n.operations)){m.audience==="setup"&&(m.method!=="GET"||m.response)&&t(["operations",f],"Setup operations must return JSON from GET"),m.body&&m.method!=="POST"&&t(["operations",f,"body"],"Only POST operations have a body");const p=new Set;for(const[h,g]of Object.entries(m.args))(Object.hasOwn(n.resources,h)||Object.hasOwn(n.identity??{},h))&&t(["operations",f,"args",h],"Argument shadows a host-owned binding"),(g.type==="integer"||g.type==="number")&&g.min>g.max&&t(["operations",f,"args",h],"Inverted numeric bounds"),g.type==="string"&&((d=g.enum)!=null&&d.some(x=>new TextEncoder().encode(x).byteLength>g.maxLength))&&t(["operations",f,"args",h],"Enum exceeds string limit");for(const h of m.path)if("resource"in h&&!Object.hasOwn(n.resources,h.resource)&&t(["operations",f,"path"],"Unknown selected resource"),"arg"in h){const g=m.args[h.arg];((g==null?void 0:g.type)!=="string"||g.required!==!0)&&t(["operations",f,"path"],"Path argument must be a required string"),p.add(h.arg)}for(const h of[...Object.values(m.query),...Object.values(m.body??{})]){const g=typeof h=="string"?h:"arg"in h?h.arg:void 0;g!==void 0?(Object.hasOwn(m.args,g)||t(["operations",f,"query"],"Unknown query argument"),p.add(g)):typeof h=="object"&&"resource"in h&&!Object.hasOwn(n.resources,h.resource)?t(["operations",f,"query"],"Unknown selected resource"):typeof h=="object"&&"identity"in h&&!Object.hasOwn(n.identity??{},h.identity)&&t(["operations",f,"query"],"Unknown validated identity")}Object.keys(m.args).some(h=>!p.has(h))&&t(["operations",f,"args"],"Unused argument")}});function Gg(n){return zo(wV,n,Qt.definitionBytes)}const qC={appVersion:Le().min(1).max(128),apiVersions:at(Kg).max(16),manifestVersions:at(bt().int().min(1).max(1024)).max(16),protocolVersions:at(bt().int().min(1).max(1024)).max(16),runtimes:at(Le().min(1).max(64)).max(16),capabilities:Xn(lt,Kg).refine(n=>Object.keys(n).length<=64)},SV=xe({...qC,browser:at(Le().min(1).max(64)).max(16)}),kV=xe({...qC,platform:Le().min(1).max(32),registryRevision:bt().int().min(0).max(Number.MAX_SAFE_INTEGER)});function jV(n){return zo(SV,n,16*1024)}function NV(n){return zo(kV,n,16*1024)}function _0(n,e,t,s={}){var f;const r=[],o=[],i=(m,p)=>!!Vn.valid(m)&&!!Vn.validRange(p)&&Vn.satisfies(m,p,{includePrerelease:s.allowPrerelease===!0}),l=(m,p,h,g,x)=>r.push({side:m,code:p,name:h,required:g,actual:x});s.revoked&&l("package","REVOKED",n.id,"non-revoked package",n.version),Vn.prerelease(n.version)&&!s.allowPrerelease&&l("package","PRERELEASE",n.id,"stable release",n.version);for(const m of["client","host"]){const p=m==="client"?e:t;i(p.appVersion,n.engines[m])||l(m,"APP_VERSION","app",n.engines[m],p.appVersion),p.manifestVersions.includes(n.manifestVersion)||l(m,"MANIFEST_VERSION","manifest",String(n.manifestVersion),p.manifestVersions.join(",")),p.protocolVersions.includes(n.protocol)||l(m,"PROTOCOL_VERSION","protocol",String(n.protocol),p.protocolVersions.join(",")),p.runtimes.includes(n.runtime)||l(m,"RUNTIME","runtime",n.runtime,p.runtimes.join(","));for(const[h,g]of Object.entries(n.requires[m])){const x=p.capabilities[h]??null;(!x||!i(x,g))&&l(m,"CAPABILITY",h,g,x)}for(const[h,g]of Object.entries(n.optional[m])){const x=p.capabilities[h]??null;(!x||!i(x,g))&&o.push({side:m,name:h,required:g,actual:x})}}for(const m of n.browser)e.browser.includes(m)||l("client","BROWSER",m,"available",null);const c=[],u=new Vn.Range(n.engines.pluginApi,{includePrerelease:s.allowPrerelease===!0});for(const m of e.apiVersions.filter(p=>Vn.valid(p)))for(const p of t.apiVersions.filter(h=>Vn.valid(h))){if(Vn.major(m)!==Vn.major(p))continue;const h=Vn.compare(m,p)<=0?m:p;i(h,n.engines.pluginApi)&&c.push(h);for(const g of u.set){const x=`${g.map(w=>w.value).join(" ")} >=${Vn.major(h)}.0.0 <=${h}`,b=(f=Vn.minVersion(x))==null?void 0:f.version;b&&i(b,n.engines.pluginApi)&&c.push(b)}}const d=c.sort(Vn.rcompare)[0]??null;if(!d){for(const m of["client","host"]){const p=m==="client"?e.apiVersions:t.apiVersions;p.some(h=>i(h,n.engines.pluginApi))||l(m,"API_VERSION","pluginApi",n.engines.pluginApi,p.join(","))}r.some(m=>m.code==="API_VERSION")||l("host","API_VERSION","pluginApi","common API version",t.apiVersions.join(","))}return{compatible:r.length===0,apiVersion:d,issues:r,unavailableOptional:o}}const Hd=$C(()=>!0),Gw=xe({}),CV=xe({id:lt,name:_s}).nullable(),VC=xe({mode:Ct(["light","dark"]),tokens:Xn(Le().regex(/^--[a-z][a-z0-9-]{0,63}$/u),Cs(256)).refine(n=>Object.keys(n).length<=64)}),HC=Le().regex(/^s_[a-f0-9]{48}$/u),_V=xe({handle:HC}).nullable().optional(),EV=xe({type:Ze("chat-block"),id:lt,source:Cs(16384)}).optional(),KC=xe({project:CV,theme:VC,locale:Le().min(1).max(64),reducedMotion:Ft(),visible:Ft(),session:_V,surface:EV});function Zw(n){return zo(KC,n,Qt.responseBytes)}const GC=["INVALID_REQUEST","INVALID_RESPONSE","INCOMPATIBLE_HOST","INCOMPATIBLE_CLIENT","PERMISSION_REQUIRED","CONNECTION_REQUIRED","RESOURCE_REQUIRED","STALE_ACTIVATION","RATE_LIMITED","PLUGIN_DISABLED","CAPABILITY_UNAVAILABLE","UPSTREAM_FAILED","CANCELED","TIMEOUT","DISPOSED"],TV=xe({code:Ct(GC),message:Cs(512)}),ll=Le().min(1).max(64).regex(/^[a-zA-Z0-9_-]+$/u),AV=Le().min(1).max(2048).refine(n=>{try{const e=new URL(n);return e.protocol==="https:"&&!e.username&&!e.password}catch{return!1}},"Expected an HTTPS URL without credentials"),eh=lt,ZC={"lifecycle.ready":Gw,"connections.request":xe({handle:lt,operationId:lt,args:Xn(lt,eo([Le(),bt().finite(),Ft()]))}),"connections.media":xe({handle:lt,operationId:lt,args:Xn(lt,eo([Le(),bt().finite(),Ft()]))}),"connections.status":xe({handle:lt}),"integrations.request":iV,"storage.get":xe({key:eh}),"storage.set":xe({key:eh,value:Hd}),"storage.delete":xe({key:eh}),"composer.append":xe({text:Cs(Qt.composerBytes)}),"navigation.openExternal":xe({url:AV}),"navigation.openSession":xe({handle:lt}),"settings.get":Gw,"ui.resize":xe({height:bt().int().min(80).max(800)})},IV=xe({configured:Ft(),readOnly:Ft(),selected:Xn(lt,xe({id:Cs(1024),label:Cs(256)})).refine(n=>Object.keys(n).length<=8)}),PV=Rr("event",[xe({protocol:Ze(Ss),type:Ze("event"),event:Ze("context"),value:KC}),xe({protocol:Ze(Ss),type:Ze("event"),event:Ze("theme"),value:VC}),xe({protocol:Ze(Ss),type:Ze("event"),event:Ze("visibility"),value:Ft()}),xe({protocol:Ze(Ss),type:Ze("event"),event:Ze("session"),value:xe({handle:HC}).nullable()}),xe({protocol:Ze(Ss),type:Ze("event"),event:Ze("dispose"),value:NC()})]),$V=eo([xe({protocol:Ze(Ss),type:Ze("request"),id:ll,method:Ct(Object.keys(ZC)),params:Hd}),xe({protocol:Ze(Ss),type:Ze("result"),id:ll,value:Hd}),xe({protocol:Ze(Ss),type:Ze("error"),id:ll,error:TV}),xe({protocol:Ze(Ss),type:Ze("cancel"),id:ll}),PV]);function Yw(n){var s,r,o,i,l;if(n&&typeof n=="object"&&((s=Object.getOwnPropertyDescriptor(n,"type"))==null?void 0:s.value)==="media-result"){const c=Object.getOwnPropertyDescriptors(n);if(Object.keys(c).length!==4||((r=c.protocol)==null?void 0:r.value)!==1)throw new Error("Invalid media envelope");return{protocol:1,type:"media-result",id:ll.parse((o=c.id)==null?void 0:o.value),value:em((i=c.value)==null?void 0:i.value)}}const e=n!==null&&typeof n=="object"&&((l=Object.getOwnPropertyDescriptor(n,"type"))==null?void 0:l.value)==="result",t=zo($V,n,e?Qt.resultMessageBytes:Qt.messageBytes,e?Qt.responseNodes+16:Qt.nodes);if(t.type==="request"){const c=t.method==="connections.media"?Qt.messageBytes:t.method==="composer.append"?Qt.composerBytes+64:t.method==="storage.set"?Qt.storageValueBytes:Qt.argumentBytes,u=zo(ZC[t.method],t.params,c);return{...t,params:u}}return t.type==="result"?{...t,value:i0(t.value,{maxBytes:Qt.responseBytes,maxNodes:Qt.responseNodes})}:t}function YC(n,e){if(n==="connections.media")return em(e);const t=n==="integrations.request"?aV:n==="connections.status"?IV:n==="connections.request"||n==="storage.get"||n==="settings.get"?Hd:NC();return zo(t,e,Qt.responseBytes,Qt.responseNodes)}const Xw=xe({values:Xn(Le(),eo([Le().max(4096),bt().finite(),Ft()])),revision:bt().int().nonnegative().max(Number.MAX_SAFE_INTEGER),adjustedFields:at(Le().max(64)).max(32).optional()}),zc=bt().int().min(0).max(Number.MAX_SAFE_INTEGER),tm=Le().regex(/^[a-f0-9]{64}$/),rc=Qr().transform(FC),XC=Rr("type",[xe({type:Ze("all")}),xe({type:Ze("projects"),projectIds:at(Le().min(1).max(512)).max(128).refine(n=>new Set(n).size===n.length)})]),RV=xe({digest:tm,manifest:rc,targetPath:Le().min(1).max(512),installedAt:zc,unavailableReason:Le().max(1e3).optional()}),OV=xe({id:Le().regex(/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$/).max(128),selectedDigest:tm,manifest:rc,enabled:Ft(),scope:XC,pinned:Ft(),versions:at(RV).min(1).max(64),lastError:Le().max(1e3).optional()}),LV=xe({id:Le().max(128),label:Le().max(128),kind:Ct(["official","development"]),fingerprint:Le().max(128),verifiedAt:zc.optional()}),JC=xe({available:Ft(),error:Le().max(2e3).optional(),revision:zc,plugins:at(OV).max(256),publishers:at(LV).max(256),legacyPluginIds:at(Ct(["github","clickup","vercel-deployments"])).max(3).optional(),availableSeeds:at(xe({manifest:rc,digest:tm})).max(256).optional(),recoveryCode:Ct(["STORE_LOCKED","STORE_VERSION","STORE_CORRUPT","STORE_UNAVAILABLE"]).optional()}),MV=xe({side:Ct(["client","host"]),name:Le().max(128),required:Le().max(256),actual:Le().max(512).nullable()}),zV=xe({compatible:Ft(),apiVersion:Le().max(128).nullable(),issues:at(xe({side:Ct(["client","host","package"]),code:Ct(["APP_VERSION","API_VERSION","MANIFEST_VERSION","PROTOCOL_VERSION","RUNTIME","CAPABILITY","BROWSER","PRERELEASE","REVOKED"]),name:Le().max(128),required:Le().max(256),actual:Le().max(512).nullable()})).max(128),unavailableOptional:at(MV).max(128)});Qr().transform(jV);const ud=xe({transactionId:Le().uuid(),manifest:rc,digest:tm,compatibility:zV,connectionDefinitions:at(Qr().transform(Gg)).max(8),oldVersion:Le().max(128).nullable(),registryRevision:zc,publisherKind:Ct(["official","development"]),scope:XC,operation:Ct(["install","update","rollback"]).optional(),previousManifest:rc.optional(),previousConnectionDefinitions:at(Qr().transform(Gg)).max(8).optional(),incompatibleClients:at(Le().max(256)).max(256).optional()}),QC=xe({id:Le().regex(/^p_[a-f0-9]{40}$/),name:Le().max(512),paths:at(Le().max(8192)).max(256)}),DV=xe({runtime:Qr().transform(NV),host:xe({name:Le().max(256),instanceId:Le().max(128)}),store:JC,projects:at(QC).max(1024),safeMode:Ft(),connectionRevision:zc.optional()}),Zg=Le().regex(/^[a-zA-Z][a-zA-Z0-9_.-]*$/).max(64),E0=bt().int().nonnegative().max(Number.MAX_SAFE_INTEGER),e_=xe({pluginId:Le().regex(/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$/).max(128),projectId:Le().regex(/^p_[a-f0-9]{40}$/).nullable()});e_.extend({expectedRevision:E0});const FV=e_.extend({connectionId:Zg});FV.extend({expectedRevision:E0});const t_=xe({id:Le().min(1).max(1024),label:Le().min(1).max(256)}),UV=at(t_).max(1e3),Jw=xe({revision:E0,connections:at(xe({id:Zg,label:Le().min(1).max(128),status:Ct(["disconnected","connected","environment"]),readOnly:Ft(),legacyImportAvailable:Ft().optional(),selected:Xn(Zg,t_).refine(n=>Object.keys(n).length<=8),definition:Qr().transform(Gg)})).max(8)}),n_="3.4.1",s_={version:n_};function cl(n=globalThis){var u,d,f,m,p,h,g,x,b,w,v,j,k,_,N,S,C,E;const e=T=>typeof T=="function",t=e(n.MessageChannel)&&e((d=(u=n.MessagePort)==null?void 0:u.prototype)==null?void 0:d.postMessage)&&e((m=(f=n.MessagePort)==null?void 0:f.prototype)==null?void 0:m.start)&&e((h=(p=n.MessagePort)==null?void 0:p.prototype)==null?void 0:h.close),s=e(n.Blob)&&e((g=n.URL)==null?void 0:g.createObjectURL)&&e((x=n.URL)==null?void 0:x.revokeObjectURL),r=e((w=(b=n.crypto)==null?void 0:b.subtle)==null?void 0:w.digest)&&e((v=n.crypto)==null?void 0:v.getRandomValues),o=n.isSecureContext===!0,l=[["secure context (HTTPS or localhost)",o],["MessageChannel",t],["Blob URLs",s],["Web Crypto",r],["AbortController",e(n.AbortController)],["AbortSignal.any",e((j=n.AbortSignal)==null?void 0:j.any)],["AbortSignal.timeout",e((k=n.AbortSignal)==null?void 0:k.timeout)],["AbortSignal.throwIfAborted",e((N=(_=n.AbortSignal)==null?void 0:_.prototype)==null?void 0:N.throwIfAborted)],["structuredClone",e(n.structuredClone)],["Object.hasOwn",e((S=n.Object)==null?void 0:S.hasOwn)],["fetch",e(n.fetch)],["Headers",e(n.Headers)],["ReadableStream",e((E=(C=n.ReadableStream)==null?void 0:C.prototype)==null?void 0:E.getReader)],["TextEncoder",e(n.TextEncoder)],["TextDecoder",e(n.TextDecoder)]].filter(([,T])=>!T).map(([T])=>T),c=[];return t&&c.push("message-channel"),s&&c.push("blob-script"),r&&o&&c.push("web-crypto"),{supported:l.length===0,browser:c,missing:l,error:l.length?`Runtime plugins are unavailable in this browser. Missing: ${l.join(", ")}. Update your browser or use a secure connection.`:null}}const BV=xe({sessionId:Le().regex(/^[a-f0-9]{64}$/),expiresAt:bt().int().positive()}),Qw=xe({id:Le().min(1).max(128),expiresAt:bt().int().positive()}),WV=xe({deadline:bt().int().positive()}),qV=xe({status:Ct(["prepared","trial","committing","committed","cancelled","abandoned"]),preview:ud,deadline:bt().int().positive().optional()}),Yg={status:null,error:null,activation:""};function bo(){const n=cl();return{appVersion:n_,apiVersions:[mV],manifestVersions:[1],protocolVersions:[Ss],runtimes:n.supported?[DC]:[],capabilities:n.supported?{"workspace.panel":"1.0.0","composer.append":"1.0.0","navigation.external":"1.0.0","navigation.session":"1.0.0","chat.blocks":"1.0.0","session.actions":"1.0.0","media.audio":"1.0.0","settings.fields":"1.0.0"}:{},browser:n.browser}}class Xg extends Error{constructor(e,t,s){super(e),this.code=t,this.status=s}}async function Jg(n,e){var c;const t=n.headers.get("Content-Length");if(t&&Number(t)>e)throw await((c=n.body)==null?void 0:c.cancel()),new Error("Plugin response exceeds its size limit");if(!n.body)throw new Error("Plugin host returned an empty response");const s=n.body.getReader(),r=[];let o=0;try{for(;;){const{done:u,value:d}=await s.read();if(u)break;if(o+=d.byteLength,o>e)throw new Error("Plugin response exceeds its size limit");r.push(d)}}catch(u){throw await s.cancel().catch(()=>{}),u}finally{s.releaseLock()}const i=new Uint8Array(o);let l=0;for(const u of r)i.set(u,l),l+=u.byteLength;return i.buffer}async function Ga(n){const e=await Jg(n,4194304);let t;try{t=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(e))}catch{throw new Error("This host does not support runtime plugins, or returned an invalid response")}if(!n.ok){const s=iq({error:Le().max(2e3),code:Le().max(128).optional()}).safeParse(t);throw new Xg(s.success?s.data.error:"Plugin request failed",s.success?s.data.code??"HOST_ERROR":"HOST_ERROR",n.status)}return t}class VV{constructor(){Ge(this,"scope",cn());Ge(this,"identity",Zn());Ge(this,"base",new URL(Cx("/api/plugins/"),window.location.origin));Ge(this,"lifetimeController");Ge(this,"session",null);Ge(this,"renewal",null);Ge(this,"refreshPromise",null);Ge(this,"timer");Ge(this,"listeners",new Set);Ge(this,"state",Yg);Ge(this,"running",!1);Ge(this,"getSnapshot",()=>this.state);Ge(this,"subscribe",e=>(this.listeners.add(e),()=>this.listeners.delete(e)));Ge(this,"hostChanged",()=>{(this.scope!==cn()||this.identity!==Zn())&&this.stop()})}get controller(){const e=cl();if(!e.supported)throw new Xg(e.error,"UNSUPPORTED_BROWSER",0);if(!this.lifetimeController)throw new Error("The plugin client has not started");return this.lifetimeController}publish(e){if(JSON.stringify(this.state)!==JSON.stringify(e)){this.state=e;for(const t of this.listeners)t()}}assertCurrent(e){const t=this.controller.signal;if((e??t).throwIfAborted(),!this.running||this.scope!==cn()||this.identity!==Zn())throw new Error("The connected host or signed-in user changed")}start(){if(this.running)return;const e=cl();if(!e.supported){this.publish({status:null,error:e.error,activation:""});return}this.running=!0,this.lifetimeController=new AbortController;for(const t of["cogpit-device-changed","cogpit-device-scope-changed","cogpit-identity-changed","popstate"])window.addEventListener(t,this.hostChanged);this.refresh(),this.timer=setInterval(()=>{this.refresh()},5e3)}stop(){var t;this.running=!1,clearInterval(this.timer),(t=this.lifetimeController)==null||t.abort();const e=this.session;this.session=null,this.renewal=null,this.refreshPromise=null;for(const s of["cogpit-device-changed","cogpit-device-scope-changed","cogpit-identity-changed","popstate"])window.removeEventListener(s,this.hostChanged);this.publish(Yg),e&&this.releaseSession(e.sessionId)}releaseSession(e){cl().supported&&Ce(new URL("session",this.base),{method:"DELETE",headers:{"X-Cogpit-Plugin-Session":e},signal:AbortSignal.timeout(5e3),keepalive:!0}).catch(()=>{})}async ensureSession(){if(this.assertCurrent(),this.session&&this.session.expiresAt-Date.now()>25e3)return;if(this.renewal)return this.renewal;const e=this.controller.signal,t=new Headers;t.set("Content-Type","application/json"),this.session&&t.set("X-Cogpit-Plugin-Session",this.session.sessionId);const s=(async()=>{const r=await Ce(new URL("session",this.base),{method:"POST",headers:t,body:JSON.stringify({client:bo()}),signal:AbortSignal.any([e,AbortSignal.timeout(2e4)])}),o=BV.parse(await Ga(r));try{this.assertCurrent(e)}catch(i){throw this.releaseSession(o.sessionId),i}this.session=o})();this.renewal=s;try{await s}finally{this.renewal===s&&(this.renewal=null)}}async request(e,t={}){const s=this.controller.signal;await this.ensureSession(),this.assertCurrent(s);const r=new Headers(t.headers);r.set("X-Cogpit-Plugin-Session",this.session.sessionId);const o=await Ce(new URL(e,this.base),{...t,headers:r,signal:AbortSignal.any([s,...t.signal?[t.signal]:[],AbortSignal.timeout(3e4)])});return this.assertCurrent(s),o}async json(e,t,s="POST",r){const o=this.controller.signal,i=await this.request(e,{method:s,signal:r,...t===void 0?{}:{body:JSON.stringify(t),headers:{"Content-Type":"application/json"}}}),l=await Ga(i);return this.assertCurrent(o),l}refresh(){const e=cl();if(!e.supported)return this.stop(),this.publish({status:null,error:e.error,activation:""}),Promise.resolve();if(this.refreshPromise)return this.refreshPromise;const t=this.controller.signal,s=(async()=>{var r;try{const o=DV.parse(await this.json("status",void 0,"GET"));if(this.assertCurrent(t),((r=this.state.status)==null?void 0:r.host.instanceId)===o.host.instanceId&&this.state.status.store.revision>o.store.revision)return;this.publish({status:o,error:null,activation:`${this.scope}:${this.identity??"personal"}:${o.host.instanceId}:${this.session.sessionId}:${o.connectionRevision??0}`})}catch(o){if(t.aborted||!this.running)return;o instanceof Xg&&o.code==="STALE_ACTIVATION"&&(this.session=null),this.publish({status:null,error:o instanceof Error?o.message:"Plugin host is unavailable",activation:""})}})();return this.refreshPromise=s,s.finally(()=>{this.refreshPromise===s&&(this.refreshPromise=null)}),s}async stageSeed(e,t){return ud.parse(await this.json("stage-seed",{pluginId:e,scope:t,client:bo()}))}async stage(e,t){const s=this.controller.signal;if(e.size>4*1024*1024)throw new Error("Choose a plugin package smaller than 4 MiB");const r=ud.parse(await Ga(await this.request("stage",{method:"POST",body:e,headers:{"Content-Type":"application/octet-stream","X-Cogpit-Plugin-Client":JSON.stringify(bo()),"X-Cogpit-Plugin-Scope":JSON.stringify(t)}})));return this.assertCurrent(s),r}async payload(e,t){const s=this.controller.signal,r=await this.request(`payload/${encodeURIComponent(e)}`,{signal:t});r.ok||await Ga(r);const o=await Jg(r,4*1024*1024);return this.assertCurrent(s),t==null||t.throwIfAborted(),o}async settings(e,t){const s=new URLSearchParams({pluginId:e.pluginId,...e.projectId?{projectId:e.projectId}:{}});return Xw.parse(await this.json(`settings?${s}`,void 0,"GET",t))}async saveSettings(e,t,s,r){return Xw.parse(await this.json("settings",{...e,values:t,expectedRevision:s},"POST",r))}async media(e,t,s){var l;const r=this.controller.signal,o=await this.request(`leases/${encodeURIComponent(e)}/call`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"},signal:s});o.ok||await Ga(o);const i=await Jg(o,C0);return this.assertCurrent(r),s==null||s.throwIfAborted(),em({mimeType:(l=o.headers.get("Content-Type"))==null?void 0:l.split(";")[0],bytes:i})}acceptStore(e){const t=JC.parse(e),s=this.state.status;s&&t.revision>=s.store.revision&&this.publish({...this.state,status:{...s,store:t,runtime:{...s.runtime,registryRevision:t.revision}}})}async beginTrial(e,t){return WV.parse(await this.json(`transactions/${e.transactionId}/trial`,void 0,"POST",t)).deadline}async commit(e,t){this.acceptStore(await this.json(`transactions/${e.transactionId}/commit`,{expectedRevision:e.registryRevision},"POST",t)),await this.refresh()}async transactionOutcome(e){return qV.parse(await this.json(`transactions/${e.transactionId}`,void 0,"GET"))}async cancel(e){await this.json(`transactions/${e.transactionId}`,void 0,"DELETE")}async enrollDeveloper(e){this.acceptStore(await this.json("publishers",{...e,development:!0})),await this.refresh()}async changeInstalled(e,t,s,r){const o=`installed/${encodeURIComponent(e)}${t==="uninstall"?"":`/${t}`}`;this.acceptStore(await this.json(o,{...s,expectedRevision:r},t==="uninstall"?"DELETE":"POST")),await this.refresh()}async rollback(e,t,s){return ud.parse(await this.json(`installed/${encodeURIComponent(e)}/rollback`,{digest:t,scope:s,client:bo()}))}async lease(e,t,s,r,o){return Qw.parse(await this.json("leases",{pluginId:e,projectId:t,contextEpoch:s,...o?{workspacePath:o}:{},client:bo()},"POST",r))}async renewLease(e,t){return Qw.parse(await this.json(`leases/${encodeURIComponent(e)}/renew`,void 0,"POST",t))}async revokeLease(e){await this.json(`leases/${encodeURIComponent(e)}`,void 0,"DELETE")}async call(e,t,s){if(t.method==="connections.media")throw new Error("Use the binary media transport for audio");const r=xe({value:Qr()}).parse(await this.json(`leases/${encodeURIComponent(e)}/call`,t,"POST",s));return YC(t.method,r.value)}async resolveSession(e,t,s){return xe({dirName:Le().min(1).max(8192),fileName:Le().min(1).max(8192)}).parse(await this.json(`leases/${encodeURIComponent(e)}/session`,{handle:t},"POST",s))}async sessionHandle(e,t,s){return xe({handle:Le().regex(/^s_[a-f0-9]{48}$/)}).parse(await this.json(`leases/${encodeURIComponent(e)}/session-handle`,t,"POST",s)).handle}async resolveWorkspace(e,t){return QC.nullable().parse(await this.json("workspace/resolve",{workspacePath:e},"POST",t))}async connections(e,t){const s=new URLSearchParams({pluginId:e.pluginId,...e.projectId?{projectId:e.projectId}:{}});return Jw.parse(await this.json(`connections?${s}`,void 0,"GET",t))}async connectionOptions(e,t,s,r){return UV.parse(await this.json("connections/options",{...e,connectionId:t,resourceId:s},"POST",r))}async changeConnection(e,t,s,r,o,i){const l=Jw.parse(await this.json(`connections/${s}`,{...e,connectionId:t,...r,expectedRevision:o},"POST",i));return await this.refresh(),l}async clearPluginData(e,t,s){await this.json("connections/clear-data",{pluginId:e,expectedRevision:t},"POST",s),await this.refresh()}}const vo=0,Te=1,ot=2,ln=3,Pt=4,bs=5,Dc=6,An=7,Hn=8,mt=9,rt=10,Ht=11,ft=12,Ut=13,Fc=14,ts=15,Un=16,Bn=17,ls=18,cs=19,os=20,ht=21,et=22,wn=23,Jn=24,gn=25,HV=0;function In(n){return n>=48&&n<=57}function Do(n){return In(n)||n>=65&&n<=70||n>=97&&n<=102}function T0(n){return n>=65&&n<=90}function KV(n){return n>=97&&n<=122}function GV(n){return T0(n)||KV(n)}function ZV(n){return n>=128}function Kd(n){return GV(n)||ZV(n)||n===95}function r_(n){return Kd(n)||In(n)||n===45}function YV(n){return n>=0&&n<=8||n===11||n>=14&&n<=31||n===127}function Gd(n){return n===10||n===13||n===12}function vi(n){return Gd(n)||n===32||n===9}function qs(n,e){return!(n!==92||Gd(e)||e===HV)}function dd(n,e,t){return n===45?Kd(e)||e===45||qs(e,t):Kd(n)?!0:n===92?qs(n,e):!1}function th(n,e,t){return n===43||n===45?In(e)?2:e===46&&In(t)?3:0:n===46?In(e)?2:0:In(n)?1:0}function o_(n){return n===65279||n===65534?1:0}const Qg=new Array(128),XV=128,fd=130,i_=131,A0=132,a_=133;for(let n=0;n<Qg.length;n++)Qg[n]=vi(n)&&fd||In(n)&&i_||Kd(n)&&A0||YV(n)&&a_||n||XV;function nh(n){return n<128?Qg[n]:A0}function Yi(n,e){return e<n.length?n.charCodeAt(e):0}function e1(n,e,t){return t===13&&Yi(n,e+1)===10?2:1}function Xi(n,e,t){let s=n.charCodeAt(e);return T0(s)&&(s=s|32),s===t}function oc(n,e,t,s){if(t-e!==s.length||e<0||t>n.length)return!1;for(let r=e;r<t;r++){const o=s.charCodeAt(r-e);let i=n.charCodeAt(r);if(T0(i)&&(i=i|32),i!==o)return!1}return!0}function JV(n,e){for(;e>=0&&vi(n.charCodeAt(e));e--);return e+1}function Nu(n,e){for(;e<n.length&&vi(n.charCodeAt(e));e++);return e}function sh(n,e){for(;e<n.length&&In(n.charCodeAt(e));e++);return e}function yi(n,e){if(e+=2,Do(Yi(n,e-1))){for(const s=Math.min(n.length,e+5);e<s&&Do(Yi(n,e));e++);const t=Yi(n,e);vi(t)&&(e+=e1(n,e,t))}return e}function Cu(n,e){for(;e<n.length;e++){const t=n.charCodeAt(e);if(!r_(t)){if(qs(t,Yi(n,e+1))){e=yi(n,e)-1;continue}break}}return e}function nm(n,e){let t=n.charCodeAt(e);if((t===43||t===45)&&(t=n.charCodeAt(e+=1)),In(t)&&(e=sh(n,e+1),t=n.charCodeAt(e)),t===46&&In(n.charCodeAt(e+1))&&(e+=2,e=sh(n,e)),Xi(n,e,101)){let s=0;t=n.charCodeAt(e+1),(t===45||t===43)&&(s=1,t=n.charCodeAt(e+2)),In(t)&&(e=sh(n,e+1+s+1))}return e}function rh(n,e){for(;e<n.length;e++){const t=n.charCodeAt(e);if(t===41){e++;break}qs(t,Yi(n,e+1))&&(e=yi(n,e))}return e}function I0(n){if(n.length===1&&!Do(n.charCodeAt(0)))return n[0];let e=parseInt(n,16);return(e===0||e>=55296&&e<=57343||e>1114111)&&(e=65533),String.fromCodePoint(e)}const t1=["EOF-token","ident-token","function-token","at-keyword-token","hash-token","string-token","bad-string-token","url-token","bad-url-token","delim-token","number-token","percentage-token","dimension-token","whitespace-token","CDO-token","CDC-token","colon-token","semicolon-token","comma-token","[-token","]-token","(-token",")-token","{-token","}-token","comment-token"],QV=16*1024;function Zd(n=null,e){return n===null||n.length<e?new Uint32Array(Math.max(e+1024,QV)):n}const eS=10,eH=12,tS=13;function nS(n){const e=n.source,t=e.length,s=e.length>0?o_(e.charCodeAt(0)):0,r=Zd(n.lines,t),o=Zd(n.columns,t);let i=n.startLine,l=n.startColumn;for(let c=s;c<t;c++){const u=e.charCodeAt(c);r[c]=i,o[c]=l++,(u===eS||u===tS||u===eH)&&(u===tS&&c+1<t&&e.charCodeAt(c+1)===eS&&(c++,r[c]=i,o[c]=l),i++,l=1)}r[t]=i,o[t]=l,n.lines=r,n.columns=o,n.computed=!0}class tH{constructor(e,t,s,r){this.setSource(e,t,s,r),this.lines=null,this.columns=null}setSource(e="",t=0,s=1,r=1){this.source=e,this.startOffset=t,this.startLine=s,this.startColumn=r,this.computed=!1}getLocation(e,t){return this.computed||nS(this),{source:t,offset:this.startOffset+e,line:this.lines[e],column:this.columns[e]}}getLocationRange(e,t,s){return this.computed||nS(this),{source:s,start:{offset:this.startOffset+e,line:this.lines[e],column:this.columns[e]},end:{offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]}}}}const Rs=16777215,Os=24,Uc=1,sm=2,So=new Uint8Array(32);So[ot]=et;So[ht]=et;So[cs]=os;So[wn]=Jn;const Vs=new Uint8Array(32);Vs[ot]=Uc;Vs[ht]=Uc;Vs[cs]=Uc;Vs[wn]=Uc;Vs[et]=sm;Vs[os]=sm;Vs[Jn]=sm;function sS(n,e,t){return n<e?e:n>t?t:n}class nH{constructor(e,t){this.setSource(e,t)}reset(){this.eof=!1,this.tokenIndex=-1,this.tokenType=0,this.tokenStart=this.firstCharOffset,this.tokenEnd=this.firstCharOffset}setSource(e="",t=()=>{}){e=String(e||"");const s=e.length,r=Zd(this.offsetAndType,e.length+1),o=Zd(this.balance,e.length+1);let i=0,l=-1,c=0,u=e.length;this.offsetAndType=null,this.balance=null,o.fill(0),t(e,(d,f,m)=>{const p=i++;if(r[p]=d<<Os|m,l===-1&&(l=f),o[p]=u,d===c){const h=o[u];o[u]=p,u=h,c=So[r[h]>>Os]}else this.isBlockOpenerTokenType(d)&&(u=p,c=So[d])}),r[i]=vo<<Os|s,o[i]=i;for(let d=0;d<i;d++){const f=o[d];if(f<=d){const m=o[f];m!==d&&(o[d]=m)}else f>i&&(o[d]=i)}this.source=e,this.firstCharOffset=l===-1?0:l,this.tokenCount=i,this.offsetAndType=r,this.balance=o,this.reset(),this.next()}lookupType(e){return e+=this.tokenIndex,e<this.tokenCount?this.offsetAndType[e]>>Os:vo}lookupTypeNonSC(e){for(let t=this.tokenIndex;t<this.tokenCount;t++){const s=this.offsetAndType[t]>>Os;if(s!==Ut&&s!==gn&&e--===0)return s}return vo}lookupOffset(e){return e+=this.tokenIndex,e<this.tokenCount?this.offsetAndType[e-1]&Rs:this.source.length}lookupOffsetNonSC(e){for(let t=this.tokenIndex;t<this.tokenCount;t++){const s=this.offsetAndType[t]>>Os;if(s!==Ut&&s!==gn&&e--===0)return t-this.tokenIndex}return vo}lookupValue(e,t){return e+=this.tokenIndex,e<this.tokenCount?oc(this.source,this.offsetAndType[e-1]&Rs,this.offsetAndType[e]&Rs,t):!1}getTokenStart(e){return e===this.tokenIndex?this.tokenStart:e>0?e<this.tokenCount?this.offsetAndType[e-1]&Rs:this.offsetAndType[this.tokenCount]&Rs:this.firstCharOffset}getTokenEnd(e){return e===this.tokenIndex?this.tokenEnd:this.offsetAndType[sS(e,0,this.tokenCount)]&Rs}getTokenType(e){return e===this.tokenIndex?this.tokenType:this.offsetAndType[sS(e,0,this.tokenCount)]>>Os}substrToCursor(e){return this.source.substring(e,this.tokenStart)}isBlockOpenerTokenType(e){return Vs[e]===Uc}isBlockCloserTokenType(e){return Vs[e]===sm}getBlockTokenPairIndex(e){const t=this.getTokenType(e);if(Vs[t]===1){const s=this.balance[e],r=this.getTokenType(s);return So[t]===r?s:-1}else if(Vs[t]===2){const s=this.balance[e],r=this.getTokenType(s);return So[r]===t?s:-1}return-1}isBalanceEdge(e){return this.balance[this.tokenIndex]<e}isDelim(e,t){return t?this.lookupType(t)===mt&&this.source.charCodeAt(this.lookupOffset(t))===e:this.tokenType===mt&&this.source.charCodeAt(this.tokenStart)===e}skip(e){let t=this.tokenIndex+e;t<this.tokenCount?(this.tokenIndex=t,this.tokenStart=this.offsetAndType[t-1]&Rs,t=this.offsetAndType[t],this.tokenType=t>>Os,this.tokenEnd=t&Rs):(this.tokenIndex=this.tokenCount,this.next())}next(){let e=this.tokenIndex+1;e<this.tokenCount?(this.tokenIndex=e,this.tokenStart=this.tokenEnd,e=this.offsetAndType[e],this.tokenType=e>>Os,this.tokenEnd=e&Rs):(this.eof=!0,this.tokenIndex=this.tokenCount,this.tokenType=vo,this.tokenStart=this.tokenEnd=this.source.length)}skipSC(){for(;this.tokenType===Ut||this.tokenType===gn;)this.next()}skipUntilBalanced(e,t){let s=e,r=0,o=0;e:for(;s<this.tokenCount;s++){if(r=this.balance[s],r<e)break e;switch(o=s>0?this.offsetAndType[s-1]&Rs:this.firstCharOffset,t(this.source.charCodeAt(o))){case 1:break e;case 2:s++;break e;default:this.isBlockOpenerTokenType(this.offsetAndType[s]>>Os)&&(s=r)}}this.skip(s-this.tokenIndex)}forEachToken(e){for(let t=0,s=this.firstCharOffset;t<this.tokenCount;t++){const r=s,o=this.offsetAndType[t],i=o&Rs,l=o>>Os;s=i,e(l,r,i,t)}}dump(){const e=new Array(this.tokenCount);return this.forEachToken((t,s,r,o)=>{e[o]={idx:o,type:t1[t],chunk:this.source.substring(s,r),balance:this.balance[o]}}),e}}function rm(n,e){function t(f){return f<l?n.charCodeAt(f):0}function s(){if(u=nm(n,u),dd(t(u),t(u+1),t(u+2))){d=ft,u=Cu(n,u);return}if(t(u)===37){d=Ht,u++;return}d=rt}function r(){const f=u;if(u=Cu(n,u),oc(n,f,u,"url")&&t(u)===40){if(u=Nu(n,u+1),t(u)===34||t(u)===39){d=ot,u=f+4;return}i();return}if(t(u)===40){d=ot,u++;return}d=Te}function o(f){for(f||(f=t(u++)),d=bs;u<n.length;u++){const m=n.charCodeAt(u);switch(nh(m)){case f:u++;return;case fd:if(Gd(m)){u+=e1(n,u,m),d=Dc;return}break;case 92:if(u===n.length-1)break;const p=t(u+1);Gd(p)?u+=e1(n,u+1,p):qs(m,p)&&(u=yi(n,u)-1);break}}}function i(){for(d=An,u=Nu(n,u);u<n.length;u++){const f=n.charCodeAt(u);switch(nh(f)){case 41:u++;return;case fd:if(u=Nu(n,u),t(u)===41||u>=n.length){u<n.length&&u++;return}u=rh(n,u),d=Hn;return;case 34:case 39:case 40:case a_:u=rh(n,u),d=Hn;return;case 92:if(qs(f,t(u+1))){u=yi(n,u)-1;break}u=rh(n,u),d=Hn;return}}}n=String(n||"");const l=n.length;let c=o_(t(0)),u=c,d;for(;u<l;){const f=n.charCodeAt(u);switch(nh(f)){case fd:d=Ut,u=Nu(n,u+1);break;case 34:o();break;case 35:r_(t(u+1))||qs(t(u+1),t(u+2))?(d=Pt,u=Cu(n,u+1)):(d=mt,u++);break;case 39:o();break;case 40:d=ht,u++;break;case 41:d=et,u++;break;case 43:th(f,t(u+1),t(u+2))?s():(d=mt,u++);break;case 44:d=ls,u++;break;case 45:th(f,t(u+1),t(u+2))?s():t(u+1)===45&&t(u+2)===62?(d=ts,u=u+3):dd(f,t(u+1),t(u+2))?r():(d=mt,u++);break;case 46:th(f,t(u+1),t(u+2))?s():(d=mt,u++);break;case 47:t(u+1)===42?(d=gn,u=n.indexOf("*/",u+2),u=u===-1?n.length:u+2):(d=mt,u++);break;case 58:d=Un,u++;break;case 59:d=Bn,u++;break;case 60:t(u+1)===33&&t(u+2)===45&&t(u+3)===45?(d=Fc,u=u+4):(d=mt,u++);break;case 64:dd(t(u+1),t(u+2),t(u+3))?(d=ln,u=Cu(n,u+1)):(d=mt,u++);break;case 91:d=cs,u++;break;case 92:qs(f,t(u+1))?r():(d=mt,u++);break;case 93:d=os,u++;break;case 123:d=wn,u++;break;case 125:d=Jn,u++;break;case i_:s();break;case A0:r();break;default:d=mt,u++}e(d,c,c=u)}}let _i=null;class jn{static createItem(e){return{prev:null,next:null,data:e}}constructor(){this.head=null,this.tail=null,this.cursor=null}createItem(e){return jn.createItem(e)}allocateCursor(e,t){let s;return _i!==null?(s=_i,_i=_i.cursor,s.prev=e,s.next=t,s.cursor=this.cursor):s={prev:e,next:t,cursor:this.cursor},this.cursor=s,s}releaseCursor(){const{cursor:e}=this;this.cursor=e.cursor,e.prev=null,e.next=null,e.cursor=_i,_i=e}updateCursors(e,t,s,r){let{cursor:o}=this;for(;o!==null;)o.prev===e&&(o.prev=t),o.next===s&&(o.next=r),o=o.cursor}*[Symbol.iterator](){for(let e=this.head;e!==null;e=e.next)yield e.data}get size(){let e=0;for(let t=this.head;t!==null;t=t.next)e++;return e}get isEmpty(){return this.head===null}get first(){return this.head&&this.head.data}get last(){return this.tail&&this.tail.data}fromArray(e){let t=null;this.head=null;for(let s of e){const r=jn.createItem(s);t!==null?t.next=r:this.head=r,r.prev=t,t=r}return this.tail=t,this}toArray(){return[...this]}toJSON(){return[...this]}forEach(e,t=this){const s=this.allocateCursor(null,this.head);for(;s.next!==null;){const r=s.next;s.next=r.next,e.call(t,r.data,r,this)}this.releaseCursor()}forEachRight(e,t=this){const s=this.allocateCursor(this.tail,null);for(;s.prev!==null;){const r=s.prev;s.prev=r.prev,e.call(t,r.data,r,this)}this.releaseCursor()}reduce(e,t,s=this){let r=this.allocateCursor(null,this.head),o=t,i;for(;r.next!==null;)i=r.next,r.next=i.next,o=e.call(s,o,i.data,i,this);return this.releaseCursor(),o}reduceRight(e,t,s=this){let r=this.allocateCursor(this.tail,null),o=t,i;for(;r.prev!==null;)i=r.prev,r.prev=i.prev,o=e.call(s,o,i.data,i,this);return this.releaseCursor(),o}some(e,t=this){for(let s=this.head;s!==null;s=s.next)if(e.call(t,s.data,s,this))return!0;return!1}map(e,t=this){const s=new jn;for(let r=this.head;r!==null;r=r.next)s.appendData(e.call(t,r.data,r,this));return s}filter(e,t=this){const s=new jn;for(let r=this.head;r!==null;r=r.next)e.call(t,r.data,r,this)&&s.appendData(r.data);return s}nextUntil(e,t,s=this){if(e===null)return;const r=this.allocateCursor(null,e);for(;r.next!==null;){const o=r.next;if(r.next=o.next,t.call(s,o.data,o,this))break}this.releaseCursor()}prevUntil(e,t,s=this){if(e===null)return;const r=this.allocateCursor(e,null);for(;r.prev!==null;){const o=r.prev;if(r.prev=o.prev,t.call(s,o.data,o,this))break}this.releaseCursor()}clear(){this.head=null,this.tail=null}copy(){const e=new jn;for(let t of this)e.appendData(t);return e}prepend(e){return this.updateCursors(null,e,this.head,e),this.head!==null?(this.head.prev=e,e.next=this.head):this.tail=e,this.head=e,this}prependData(e){return this.prepend(jn.createItem(e))}append(e){return this.insert(e)}appendData(e){return this.insert(jn.createItem(e))}insert(e,t=null){if(t!==null)if(this.updateCursors(t.prev,e,t,e),t.prev===null){if(this.head!==t)throw new Error("before doesn't belong to list");this.head=e,t.prev=e,e.next=t,this.updateCursors(null,e)}else t.prev.next=e,e.prev=t.prev,t.prev=e,e.next=t;else this.updateCursors(this.tail,e,null,e),this.tail!==null?(this.tail.next=e,e.prev=this.tail):this.head=e,this.tail=e;return this}insertData(e,t){return this.insert(jn.createItem(e),t)}remove(e){if(this.updateCursors(e,e.prev,e,e.next),e.prev!==null)e.prev.next=e.next;else{if(this.head!==e)throw new Error("item doesn't belong to list");this.head=e.next}if(e.next!==null)e.next.prev=e.prev;else{if(this.tail!==e)throw new Error("item doesn't belong to list");this.tail=e.prev}return e.prev=null,e.next=null,e}push(e){this.insert(jn.createItem(e))}pop(){return this.tail!==null?this.remove(this.tail):null}unshift(e){this.prepend(jn.createItem(e))}shift(){return this.head!==null?this.remove(this.head):null}prependList(e){return this.insertList(e,this.head)}appendList(e){return this.insertList(e)}insertList(e,t){return e.head===null?this:(t!=null?(this.updateCursors(t.prev,e.tail,t,e.head),t.prev!==null?(t.prev.next=e.head,e.head.prev=t.prev):this.head=e.head,t.prev=e.tail,e.tail.next=t):(this.updateCursors(this.tail,e.tail,null,e.head),this.tail!==null?(this.tail.next=e.head,e.head.prev=this.tail):this.head=e.head,this.tail=e.tail),e.head=null,e.tail=null,this)}replace(e,t){"head"in t?this.insertList(t,e):this.insert(t,e),this.remove(e)}}function om(n,e){const t=Object.create(SyntaxError.prototype),s=new Error;return Object.assign(t,{name:n,message:e,get stack(){return(s.stack||"").replace(/^(.+\n){1,3}/,`${n}: ${e}
71
71
  `)}})}const oh=100,rS=60,oS=" ";function iS({source:n,line:e,column:t,baseLine:s,baseColumn:r},o){function i(h,g){return u.slice(h,g).map((x,b)=>String(h+b+1).padStart(m)+" |"+x).join(`
72
72
  `)}const l=`
73
73
  `.repeat(Math.max(s-1,0)),c=" ".repeat(Math.max(r-1,0)),u=(l+c+n).split(/\r\n?|\n|\f/),d=Math.max(1,e-o)-1,f=Math.min(e+o,u.length+1),m=Math.max(4,String(f).length)+1;let p=0;t+=(oS.length-1)*(u[e-1].substr(0,t-1).match(/\t/g)||[]).length,t>oh&&(p=t-rS+3,t=rS-2);for(let h=d;h<=f;h++)h>=0&&h<u.length&&(u[h]=u[h].replace(/\t/g,oS),u[h]=(p>0&&u[h].length>p?"…":"")+u[h].substr(p,oh-2)+(u[h].length>p+oh-1?"…":""));return[i(d,e),new Array(t+m+2).join("-")+"^",i(e,f)].filter(Boolean).join(`
@@ -331,7 +331,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
331
331
  }
332
332
  `,GQ=[...Array.from(KQ.matchAll(/--color-[\w-]+:\s*var\((--[\w-]+)\)/g),n=>n[1]),"--surface-opacity","--surface-rgb","--surface","--surface-hover","--radius","--font-sans","--font-mono"];function fk(){const n=document.documentElement,e=getComputedStyle(n),t={};for(const s of GQ){const r=e.getPropertyValue(s).trim();r&&new TextEncoder().encode(r).byteLength<=256&&(t[s]=r)}return{theme:{mode:n.classList.contains("dark")?"dark":"light",tokens:t},locale:(n.lang||navigator.language||"en").slice(0,64),reducedMotion:window.matchMedia("(prefers-reduced-motion: reduce)").matches}}function FE(n,e,t,s,r=null){let o="";for(const l of(e==null?void 0:e.name.trim())??""){if(o.length+l.length>128)break;l.charCodeAt(0)>=32&&l.charCodeAt(0)!==127&&(o+=l)}const i=n.permissions.context.includes("session.identity")?{session:r?{handle:r}:null}:{};return{...s,project:e&&n.permissions.context.includes("project.identity")?{id:e.id,name:o.trim()||"Project"}:null,visible:t,...i}}function UE(){const n=V.c(2),[e,t]=y.useState(fk);let s,r;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{const o=()=>{const c=fk();t(u=>JSON.stringify(u)===JSON.stringify(c)?u:c)},i=new MutationObserver(o);i.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","lang"]});const l=window.matchMedia("(prefers-reduced-motion: reduce)");return l.addEventListener("change",o),window.addEventListener("languagechange",o),()=>{i.disconnect(),l.removeEventListener("change",o),window.removeEventListener("languagechange",o)}},r=[],n[0]=s,n[1]=r):(s=n[0],r=n[1]),y.useEffect(s,r),e}function ZQ(n,e,t){if(!e)return null;const s=l=>{const c=(t==="win32"?l.replaceAll("\\","/").toLowerCase():l).replace(/\/+$/,"")||"/";return c.split("/").some(u=>u==="."||u==="..")?null:c},r=s(e);if(!r)return null;let o=null,i=-1;for(const l of n)for(const c of l.paths){const u=s(c);u&&u.length>i&&(r===u||r.startsWith(u.endsWith("/")?u:`${u}/`))&&(o=l,i=u.length)}return o}function BE(n){const e=V.c(22),{client:t,status:s,activation:r,projectPath:o}=n,i=!!(s!=null&&s.store.available)&&!!r;let l;e[0]!==i||e[1]!==o||e[2]!==s?(l=i?ZQ(s.projects,o,s.runtime.platform):null,e[0]=i,e[1]=o,e[2]=s,e[3]=l):l=e[3];const c=l,u=i&&!c?o:null;let d;e[4]!==r||e[5]!==o||e[6]!==(s==null?void 0:s.connectionRevision)||e[7]!==(s==null?void 0:s.host.instanceId)||e[8]!==(s==null?void 0:s.projects)||e[9]!==(s==null?void 0:s.store)?(d=JSON.stringify([r,o,s==null?void 0:s.host.instanceId,s==null?void 0:s.store.revision,s==null?void 0:s.connectionRevision,s==null?void 0:s.projects]),e[4]=r,e[5]=o,e[6]=s==null?void 0:s.connectionRevision,e[7]=s==null?void 0:s.host.instanceId,e[8]=s==null?void 0:s.projects,e[9]=s==null?void 0:s.store,e[10]=d):d=e[10];const f=d,[m,p]=y.useState(null);let h,g;if(e[11]!==t||e[12]!==f||e[13]!==u?(h=()=>{if(!u)return;const b=new AbortController;return Promise.resolve().then(()=>(b.signal.throwIfAborted(),t.resolveWorkspace(u,b.signal))).then(w=>{b.signal.aborted||p({key:f,project:w})}).catch(()=>{b.signal.aborted||p({key:f,project:null})}),()=>b.abort()},g=[t,f,u],e[11]=t,e[12]=f,e[13]=u,e[14]=h,e[15]=g):(h=e[14],g=e[15]),y.useEffect(h,g),!i||!o){let b;return e[16]===Symbol.for("react.memo_cache_sentinel")?(b={project:null,resolving:!1},e[16]=b):b=e[16],b}if(c){let b;return e[17]!==c?(b={project:c,resolving:!1},e[17]=c,e[18]=b):b=e[18],b}let x;return e[19]!==f||e[20]!==m?(x=(m==null?void 0:m.key)===f?{project:m.project,resolving:!1}:{project:null,resolving:!0},e[19]=f,e[20]=m,e[21]=x):x=e[21],x}const WE=()=>new URLSearchParams(window.location.search).get("pluginSafeMode")==="1",YQ=n=>(window.addEventListener("popstate",n),()=>window.removeEventListener("popstate",n)),Y0=()=>y.useSyncExternalStore(YQ,WE,XQ);function O2e(n){const e=new URL(window.location.href);n?e.searchParams.set("pluginSafeMode","1"):e.searchParams.delete("pluginSafeMode"),window.history.replaceState(window.history.state,"",e),window.dispatchEvent(new PopStateEvent("popstate"))}function XQ(){return!0}const X0=y.createContext(null),JQ=()=>y.useContext(X0);function qE(n){const e=V.c(13),{runtime:t,workspacePath:s,children:r}=n,o=Y0();let i;e[0]!==t||e[1]!==s?(i={...t,projectPath:s},e[0]=t,e[1]=s,e[2]=i):i=e[2];const{project:l,resolving:c}=BE(i),{client:u,status:d,error:f,activation:m}=t,p=o||c?"":m;let h;e[3]!==u||e[4]!==f||e[5]!==l||e[6]!==d||e[7]!==p||e[8]!==s?(h={client:u,status:d,error:f,activation:p,project:l,workspacePath:s},e[3]=u,e[4]=f,e[5]=l,e[6]=d,e[7]=p,e[8]=s,e[9]=h):h=e[9];const g=h;let x;return e[10]!==r||e[11]!==g?(x=a.jsx(X0.Provider,{value:g,children:r}),e[10]=r,e[11]=g,e[12]=x):x=e[12],x}function QQ(n){var g,x,b,w;const e=V.c(21),{language:t,source:s,instanceKey:r,fallback:o}=n,i=y.useContext(X0);let l;e[0]!==t?(l=zC(t),e[0]=t,e[1]=l):l=e[1];const c=l;let u,d,f,m;if(e[2]!==o||e[3]!==r||e[4]!==i||e[5]!==s||e[6]!==(c==null?void 0:c.blockId)||e[7]!==(c==null?void 0:c.pluginId)){m=Symbol.for("react.early_return_sentinel");e:{if(d=(g=i==null?void 0:i.status)==null?void 0:g.store.plugins.find(v=>v.id===(c==null?void 0:c.pluginId)),u=(x=d==null?void 0:d.manifest.contributes.chatBlocks)==null?void 0:x.find(v=>v.id===(c==null?void 0:c.blockId)),!(i!=null&&i.activation)||!((b=i.status)!=null&&b.store.available)||i.status.safeMode||!(d!=null&&d.enabled)||!u||Pl(s)>16384||d.scope.type==="projects"&&(!i.project||!d.scope.projectIds.includes(i.project.id))||!_0(d.manifest,bo(),i.status.runtime,{allowPrerelease:d.manifest.publisher.startsWith("dev-")}).compatible){let v;e[12]!==o?(v=a.jsx(a.Fragment,{children:o}),e[12]=o,e[13]=v):v=e[13],m=v;break e}f=JSON.stringify([i.activation,i.status.store.revision,d.selectedDigest,(w=i.project)==null?void 0:w.id,i.workspacePath,u.id,r,s])}e[2]=o,e[3]=r,e[4]=i,e[5]=s,e[6]=c==null?void 0:c.blockId,e[7]=c==null?void 0:c.pluginId,e[8]=u,e[9]=d,e[10]=f,e[11]=m}else u=e[8],d=e[9],f=e[10],m=e[11];if(m!==Symbol.for("react.early_return_sentinel"))return m;const p=f;let h;return e[14]!==u||e[15]!==o||e[16]!==p||e[17]!==d||e[18]!==i||e[19]!==s?(h=a.jsx(eee,{runtime:i,plugin:d,block:u,source:s,fallback:o},p),e[14]=u,e[15]=o,e[16]=p,e[17]=d,e[18]=i,e[19]=s,e[20]=h):h=e[20],h}function eee(n){const e=V.c(16),{runtime:t,plugin:s,block:r,source:o,fallback:i}=n,l=y.useRef(null),[c,u]=y.useState(!1),[d,f]=y.useState(r.height);let m,p;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{if(!l.current)return;if(typeof IntersectionObserver>"u"){u(!0);return}const w=new IntersectionObserver(v=>u(v.some(tee)),{rootMargin:"200px"});return w.observe(l.current),()=>w.disconnect()},p=[],e[0]=m,e[1]=p):(m=e[0],p=e[1]),y.useEffect(m,p);let h;e[2]!==d?(h={minHeight:d},e[2]=d,e[3]=h):h=e[3];const g=`${s.id}:${r.id}`;let x;e[4]!==r||e[5]!==i||e[6]!==d||e[7]!==s||e[8]!==t||e[9]!==o||e[10]!==c?(x=c?a.jsx(nee,{runtime:t,plugin:s,block:r,source:o,height:d,resize:f,fallback:i}):a.jsxs("div",{className:"rounded-lg border bg-card p-3 text-sm",children:[a.jsx("p",{className:"mb-2 font-medium",children:r.title}),a.jsx("p",{className:"whitespace-pre-wrap",children:o})]}),e[4]=r,e[5]=i,e[6]=d,e[7]=s,e[8]=t,e[9]=o,e[10]=c,e[11]=x):x=e[11];let b;return e[12]!==h||e[13]!==g||e[14]!==x?(b=a.jsx("div",{ref:l,style:h,className:"my-3","data-plugin-block":g,children:x}),e[12]=h,e[13]=g,e[14]=x,e[15]=b):b=e[15],b}function tee(n){return n.isIntersecting}function nee(n){const e=V.c(40),{runtime:t,plugin:s,block:r,source:o,height:i,resize:l,fallback:c}=n,u=UE(),[d,f]=y.useState(null),[m,p]=y.useState(null),[h]=y.useState(see);let g,x;e[0]!==h||e[1]!==s.id||e[2]!==s.selectedDigest||e[3]!==l||e[4]!==t.client||e[5]!==t.project||e[6]!==t.workspacePath?(g=()=>{var E;const C=DE({client:t.client,pluginId:s.id,digest:s.selectedDigest,projectId:((E=t.project)==null?void 0:E.id)??null,workspacePath:t.project?t.workspacePath:null,contextEpoch:h,active:!0,resize:l,onLoaded:(T,$)=>f({payload:T,leaseId:$,activation:C}),onError:T=>p(T.message)});return()=>C.dispose()},x=[t.client,t.project,t.workspacePath,s.id,s.selectedDigest,h,l],e[0]=h,e[1]=s.id,e[2]=s.selectedDigest,e[3]=l,e[4]=t.client,e[5]=t.project,e[6]=t.workspacePath,e[7]=g,e[8]=x):(g=e[7],x=e[8]),y.useEffect(g,x);let b;e[9]!==s.manifest||e[10]!==u||e[11]!==t.project?(b=FE(s.manifest,t.project,!0,u),e[9]=s.manifest,e[10]=u,e[11]=t.project,e[12]=b):b=e[12];let w;e[13]!==r.id||e[14]!==o?(w={type:"chat-block",id:r.id,source:o},e[13]=r.id,e[14]=o,e[15]=w):w=e[15];let v;e[16]!==b||e[17]!==w?(v={...b,surface:w},e[16]=b,e[17]=w,e[18]=v):v=e[18];const j=v;if(m){let C;e[19]!==r.title||e[20]!==m?(C=a.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:[r.title," could not load. ",m]}),e[19]=r.title,e[20]=m,e[21]=C):C=e[21];let E;return e[22]!==c||e[23]!==C?(E=a.jsxs(a.Fragment,{children:[c,C]}),e[22]=c,e[23]=C,e[24]=E):E=e[24],E}if(!d){let C;return e[25]!==r.title?(C=a.jsxs("div",{role:"status",className:"rounded-lg border bg-card p-3 text-sm",children:["Loading ",r.title,"…"]}),e[25]=r.title,e[26]=C):C=e[26],C}let k;e[27]!==i?(k={height:i},e[27]=i,e[28]=k):k=e[28];const _=`${h}:${d.leaseId}`;let N;e[29]!==r.title||e[30]!==j||e[31]!==d.activation.execute||e[32]!==d.activation.fail||e[33]!==d.payload||e[34]!==s.selectedDigest||e[35]!==_?(N=a.jsx(zE,{payload:d.payload,digest:s.selectedDigest,activationKey:_,context:j,active:!0,title:r.title,execute:d.activation.execute,onError:d.activation.fail}),e[29]=r.title,e[30]=j,e[31]=d.activation.execute,e[32]=d.activation.fail,e[33]=d.payload,e[34]=s.selectedDigest,e[35]=_,e[36]=N):N=e[36];let S;return e[37]!==k||e[38]!==N?(S=a.jsx("div",{style:k,children:N}),e[37]=k,e[38]=N,e[39]=S):S=e[39],S}function see(){return crypto.randomUUID()}function ree(){const n=V.c(2),e=JQ();let t;return n[0]!==e?(t=e?a.jsx(oee,{runtime:e}):null,n[0]=e,n[1]=t):t=n[1],t}function oee({runtime:n}){var m,p;const e=QM(),t=ez(),[s,r]=y.useState(null),[o,i]=y.useState(null),l=y.useRef({epoch:0,locked:!1}),c=(m=e==null?void 0:e.session)==null?void 0:m.sessionId;if(y.useEffect(()=>{const h=l.current;return h.epoch++,h.locked=!1,r(null),i(null),()=>{h.epoch++,h.locked=!1}},[c,n.activation]),!(n!=null&&n.activation)||!((p=n.status)!=null&&p.store.available)||n.status.safeMode||!t||!c||(e==null?void 0:e.permissions.send)===!1)return null;const u=n.status.store.plugins.filter(h=>h.enabled&&(h.scope.type==="all"||!!n.project&&h.scope.projectIds.includes(n.project.id))&&_0(h.manifest,bo(),n.status.runtime,{allowPrerelease:h.manifest.publisher.startsWith("dev-")}).compatible).flatMap(h=>(h.manifest.contributes.sessionActions??[]).map(g=>({...g,key:`${h.id}:${g.id}`})));if(!u.length)return null;const d=!!s;async function f(h){const g=l.current;if(!t||d||g.locked)return;g.locked=!0;const x=++g.epoch;r(h.key),i(null);try{!await t.chat.sendMessage(h.prompt)&&g.epoch===x&&i("The request could not be sent. Try again when the session is ready.")}catch{g.epoch===x&&i("The request could not be sent.")}finally{g.epoch===x&&(g.locked=!1,r(null))}}return a.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[u.map(h=>a.jsx(Q,{type:"button",size:"xs",variant:"ghost",className:"text-muted-foreground hover:text-foreground",disabled:d,"aria-busy":s===h.key,onClick:()=>{f(h)},children:s===h.key?"Sending…":h.title},h.key)),o&&a.jsx("span",{role:"alert",className:"text-xs text-destructive",children:o})]})}function mk(n){const e=V.c(34),{error:t}=n,[s,r]=y.useState(!1),[o,i]=y.useState(!1);let l;e[0]!==t?(l=t.split(`
333
333
  `),e[0]=t,e[1]=l):l=e[1];const c=l[0];let u;e[2]!==t||e[3]!==c?(u=t.includes(`
334
- `)||t.length>c.length,e[2]=t,e[3]=c,e[4]=u):u=e[4];const d=u;let f;e[5]!==t?(f=async()=>{try{await navigator.clipboard.writeText(t),i(!0),setTimeout(()=>i(!1),1500)}catch{}},e[5]=t,e[6]=f):f=e[6];const m=f;let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=()=>r(!0),e[7]=p):p=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx(wr,{"data-icon":"inline-start"}),e[8]=h):h=e[8];let g;e[9]!==c?(g=a.jsx("span",{className:"truncate",children:c}),e[9]=c,e[10]=g):g=e[10];let x;e[11]!==d?(x=d&&a.jsx("span",{className:"shrink-0 opacity-60",children:"(details)"}),e[11]=d,e[12]=x):x=e[12];let b;e[13]!==g||e[14]!==x?(b=a.jsxs(Q,{type:"button",variant:"ghost",size:"sm",onClick:p,title:"Click to view the full error",className:"motion-enter mt-1 w-full justify-start text-destructive",children:[h,g,x]}),e[13]=g,e[14]=x,e[15]=b):b=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=a.jsxs(io,{children:[a.jsxs(rr,{className:"flex items-center gap-2 text-destructive",children:[a.jsx(wr,{className:"size-4"}),"Error details"]}),a.jsx(or,{children:"The full output from the failed request, including the underlying process stderr."})]}),e[16]=w):w=e[16];let v;e[17]!==t?(v=a.jsx("pre",{className:"max-h-[50vh] select-text overflow-auto whitespace-pre-wrap break-words rounded-md border bg-muted/30 p-3 font-mono text-xs text-destructive",children:t}),e[17]=t,e[18]=v):v=e[18];let j;e[19]!==o?(j=o?a.jsx(nn,{"data-icon":"inline-start"}):a.jsx(Es,{"data-icon":"inline-start"}),e[19]=o,e[20]=j):j=e[20];const k=o?"Copied":"Copy";let _;e[21]!==m||e[22]!==j||e[23]!==k?(_=a.jsx("div",{className:"flex justify-end",children:a.jsxs(Q,{type:"button",variant:"outline",size:"sm",onClick:m,children:[j,k]})}),e[21]=m,e[22]=j,e[23]=k,e[24]=_):_=e[24];let N;e[25]!==v||e[26]!==_?(N=a.jsxs(sr,{className:"max-w-2xl",children:[w,v,_]}),e[25]=v,e[26]=_,e[27]=N):N=e[27];let S;e[28]!==s||e[29]!==N?(S=a.jsx(nr,{open:s,onOpenChange:r,children:N}),e[28]=s,e[29]=N,e[30]=S):S=e[30];let C;return e[31]!==S||e[32]!==b?(C=a.jsxs(a.Fragment,{children:[b,S]}),e[31]=S,e[32]=b,e[33]=C):C=e[33],C}function iee(n){const e=V.c(17),{suggestion:t,onAccept:s}=n,[r,o]=y.useState(null);if(!t||t===r)return null;let i;e[0]!==s||e[1]!==t?(i=()=>{o(t),s(t)},e[0]=s,e[1]=t,e[2]=i):i=e[2];let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(ql,{"data-icon":"inline-start"}),e[3]=l):l=e[3];let c;e[4]!==t?(c=a.jsx("span",{className:"truncate",children:t}),e[4]=t,e[5]=c):c=e[5];let u;e[6]!==i||e[7]!==c?(u=a.jsxs(Q,{type:"button",variant:"ghost",size:"sm",title:"Put this in the composer",onClick:i,className:"min-w-0 flex-1 justify-start text-muted-foreground",children:[l,c]}),e[6]=i,e[7]=c,e[8]=u):u=e[8];let d;e[9]!==t?(d=()=>o(t),e[9]=t,e[10]=d):d=e[10];let f;e[11]===Symbol.for("react.memo_cache_sentinel")?(f=a.jsx(Mt,{}),e[11]=f):f=e[11];let m;e[12]!==d?(m=a.jsx(Q,{type:"button",variant:"ghost",size:"icon","aria-label":"Dismiss suggestion",onClick:d,className:"shrink-0 text-muted-foreground",children:f}),e[12]=d,e[13]=m):m=e[13];let p;return e[14]!==u||e[15]!==m?(p=a.jsxs("div",{className:"motion-enter mb-1 flex items-center gap-1",children:[u,m]}),e[14]=u,e[15]=m,e[16]=p):p=e[16],p}function aee(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 lee(n,e,t){return`${n.slice(0,e.start)}@${t} `}function Nn(n){const e=V.c(3);let t,s;return e[0]!==n?(t=()=>xt(n),s=()=>xt(n),e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]),y.useSyncExternalStore(Rf,t,s)}function cee(n){const e=n.files;return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function uee(n,e,t){const s=Nn("hostFiles"),[r,o]=y.useState([]),[i,l]=y.useState(!1);return y.useEffect(()=>{if(!s||!t||!n){o([]),l(!1);return}const c=new AbortController,u=window.setTimeout(async()=>{l(!0);try{const d=await Ce(`/api/project-files?cwd=${encodeURIComponent(n)}&q=${encodeURIComponent(e)}&limit=30`,{signal:c.signal});if(!d.ok)throw new Error(`Request failed (${d.status})`);const f=await d.json();c.signal.aborted||o(cee(f))}catch{c.signal.aborted||o([])}finally{c.signal.aborted||l(!1)}},120);return()=>{window.clearTimeout(u),c.abort()}},[s,n,t,e]),{files:r,loading:i}}const p1="cogpit-share-revoked";function dee(){window.dispatchEvent(new Event(p1))}async function VE(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&&dee(),s}function Bc(n,e){return VE(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e??{})})}async function fee(){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 mee(n,e){return Bc("/api/share/send-message",e!=null&&e.length?{message:n,images:e}:{message:n})}function pee(){return Bc("/api/share/interrupt")}function hee(){return Bc("/api/share/stop")}async function gee(n,e){return(await Bc("/api/share/permission",{requestId:n,behavior:e})).ok}async function xee(n,e){try{const t=await Bc("/api/share/answer",{toolUseId:n,answers:e});return{ok:t.ok,gone:t.status===404}}catch{return{ok:!1,gone:!1}}}async function bee(){try{const n=await VE("/api/share/pending");if(!n.ok)return null;const e=await n.json();return Array.isArray(e.permissions)?e.permissions:[]}catch{return null}}const vee=/^\/shared\/([^/]+)\/?$/;function HE(n){const e=vee.exec(n);if(!e)return null;try{return decodeURIComponent(e[1])||null}catch{return null}}function lm(n){return HE(n)!==null}function yee(n){return`/shared/${encodeURIComponent(n)}`}async function KE(n,e,t){const s=typeof e.commandId=="string"?e.commandId:crypto.randomUUID(),r={...e,commandId:s};for(let o=0;;o++)try{const i=await(t?Ce(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r),signal:t}):is(n,r));return i.ok&&window.dispatchEvent(new CustomEvent("cogpit-command-accepted",{detail:{commandId:s,sessionId:e.sessionId}})),i}catch(i){if(i instanceof Error&&i.name==="AbortError")throw i;if(t!=null&&t.aborted||o>=1)throw new Error(`Delivery could not be confirmed. Your draft is retained. Check receipt ${s} before sending again.`,{cause:i})}}function wee(n){return[...n].join(", ")}async function GE(n,e){try{const t=await is(n,e);return{ok:t.ok,gone:t.status===404}}catch{return{ok:!1,gone:!1}}}function J0(n,e,t){return lm(window.location.pathname)?xee(e,t):KE("/api/ask-user-answer",{sessionId:n,toolUseId:e,answers:t}).then(s=>({ok:s.ok,gone:s.status===404}),()=>({ok:!1,gone:!1}))}async function See(n,e,t){try{return(await is(`/api/permissions/${encodeURIComponent(n)}/plan`,{requestId:e,...t})).ok}catch{return!1}}function Wc(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-background px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("textarea",{"data-slot":"textarea",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Ou(n,e){if(!n)return!1;const t=n.offsetHeight;n.style.transition="none",n.style.height="auto";const s=Math.min(n.scrollHeight,200);let r;if(e){const i=n.style.width;n.style.width=`${Math.max(100,n.offsetWidth-140)}px`,r=n.scrollHeight>48,n.style.width=i}else r=s>44;return t!==s&&(n.style.height=t+"px",n.offsetHeight,n.style.transition="height 150ms ease"),n.style.height=s+"px",r}function kee(n,e,t,s,r,o){return s?"Resolve approval to continue...":n?"Provide feedback to request changes...":e?"Type a custom response...":o?r?"Steer…":"Message…":r?"Steer the active turn… (Enter to send)":t?"Message... (Enter to send)":"Send a message... (Enter to send)"}function jee(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 Nee(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 Cee(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 h1=y.memo(y.forwardRef(function({allowImages:e=!0,agentKind:t,projectCwd:s,leadingAccessory:r,footer:o,compact:i=!1},l){var He;const c=Nn("hostFiles"),{session:u,isLive:d,actions:{handleEditConfig:f},pendingInteraction:m,permissionRequests:p,permissionResponding:h,respondPermission:g,respondAllPermissions:x,slashSuggestions:b,slashSuggestionsLoading:w,turnError:v,promptSuggestion:j}=kt(),{chat:{status:k,error:_,isConnected:N,sendMessage:S,interrupt:C}}=Wf(),E=N||d,[T,$]=y.useState(""),[A,R]=y.useState(!1),[P,z]=y.useState(!1),[L,I]=y.useState(null),M=y.useRef(null),F=y.useRef(null),U=y.useRef(!1),O=y.useRef(""),D=y.useRef(null);y.useEffect(()=>{O.current=T},[T]);const B=y.useCallback(me=>{U.current=me,R(me)},[]),{images:q,isDragOver:W,imageError:H,hasUnsupportedAttachments:K,dismissImageError:Z,removeImage:Y,clearImages:X,restoreImages:ee,handleDragOver:te,handleDragLeave:se,handleDrop:J,handlePaste:ne}=Bz(e),ie=y.useRef(q);y.useEffect(()=>{ie.current=q},[q]);const ae=(u==null?void 0:u.sessionId)??null,oe=y.useRef(null),ue=y.useRef(null);y.useEffect(()=>{const me=()=>O.current.trim()!==""||ie.current.length>0;oe.current={sessionId:ae};const je=ae&&!me()?Hz(ae):void 0;return je&&(ue.current=ae,O.current=je.text,ie.current=je.images,$(je.text),ee(je.images)),()=>{oe.current=null,ae&&ue.current===ae&&me()&&(f2(ae,{text:O.current,images:ie.current}),O.current="",ie.current=[],$(""),X()),ue.current=null}},[ae,ee,X]);const[re,de]=y.useState(0),[fe,le]=y.useState(0),[ce,he]=y.useState(!1),ge=T.startsWith("/")&&!T.includes(" "),be=ge?T.slice(1):"",ve=y.useMemo(()=>{if(!ge)return[];const me=be.toLowerCase(),je=b.filter(dt=>me?dt.name.toLowerCase().includes(me)||dt.description.toLowerCase().includes(me):!0),Xe=je.filter(dt=>dt.type==="command"),tt=je.filter(dt=>dt.type==="skill");return[...Xe,...tt]},[ge,be,b]),Se=y.useMemo(()=>aee(T),[T]),we=!!(c&&Se&&s&&!ce),Ee=uee(s,(Se==null?void 0:Se.query)??"",we);y.useEffect(()=>{de(0)},[be]),y.useEffect(()=>{le(0)},[Se==null?void 0:Se.query]);const $e=(m==null?void 0:m.type)==="plan"?m.requestId??null:null;y.useEffect(()=>{F.current=$e,M.current=null,z(!1),I(null)},[$e]);const Be=y.useCallback(async me=>{const je=m;if(!(u!=null&&u.sessionId)||(je==null?void 0:je.type)!=="question")return;const Xe=je.questions[0];if(!Xe||!me.trim())return;(await J0(u.sessionId,je.toolUseId,{[Xe.question]:me})).ok||S(me)},[m,u==null?void 0:u.sessionId,S]),qe=y.useCallback(async(me,je,Xe)=>{const tt=m;if((tt==null?void 0:tt.type)==="plan"&&tt.provider==="copilot"&&tt.requestId&&(u!=null&&u.sessionId)){const dt=tt.requestId;if(M.current)return!1;M.current=dt,z(!0),I(null);try{const zt=await See(u.sessionId,dt,{approved:me,...je?{selectedAction:je}:{},...Xe?{feedback:Xe}:{}});return!zt&&F.current===dt&&I("Couldn't send the plan response. Try again."),zt}finally{M.current===dt&&(M.current=null,z(!1))}}return S(me?"yes":Xe||"no"),!0},[m,u==null?void 0:u.sessionId,S]),ze=y.useCallback(()=>{requestAnimationFrame(()=>{const me=D.current;me&&(me.focus(),me.selectionStart=me.selectionEnd=me.value.length,B(Ou(me,U.current)))})},[B]),Ie=y.useCallback(me=>{$(`/${me.name} `),de(0),ze()},[ze]),Me=y.useCallback(me=>{$(me),ze()},[ze]),Ue=y.useCallback(me=>{if(!Se)return;const je=lee(T,Se,me);$(je),he(!0),le(0),requestAnimationFrame(()=>{const Xe=D.current;Xe&&(Xe.focus(),Xe.selectionStart=Xe.selectionEnd=Xe.value.length,B(Ou(Xe,U.current)))})},[Se,T,B]),De=y.useCallback(async()=>{const me=T.trim();if(!me&&q.length===0||!e&&q.length>0)return;if((m==null?void 0:m.type)==="question"){Be(me),$(""),B(!1),D.current&&(D.current.style.height="auto");return}if((m==null?void 0:m.type)==="plan"&&m.provider==="copilot"){if(!me||!await qe(!1,void 0,me))return;$(""),B(!1),D.current&&(D.current.style.height="auto");return}const je=e&&q.length>0?q.map(tt=>({data:tt.data,mediaType:tt.mediaType})):void 0,Xe={text:T,images:q};ue.current=null,S(me,je).then(tt=>{var dt;if(!tt){if(((dt=oe.current)==null?void 0:dt.sessionId)!==ae){ae&&f2(ae,Xe);return}ue.current=ae,$(zt=>zt||Xe.text),ee(Xe.images)}}),$(""),X(),B(!1),D.current&&(D.current.style.height="auto")},[T,q,e,S,X,ee,B,m,Be,qe,ae]),Ke=y.useCallback(me=>{if(we&&me.key==="Escape"){me.preventDefault(),he(!0);return}if(we&&Ee.files.length>0){if(me.key==="ArrowDown"){me.preventDefault(),le(je=>je<Ee.files.length-1?je+1:0);return}if(me.key==="ArrowUp"){me.preventDefault(),le(je=>je>0?je-1:Ee.files.length-1);return}if(me.key==="Tab"||me.key==="Enter"&&!me.shiftKey){me.preventDefault();const je=Ee.files[fe];je&&Ue(je);return}}if(ge&&ve.length>0){if(me.key==="ArrowDown"){me.preventDefault(),de(je=>je<ve.length-1?je+1:0);return}if(me.key==="ArrowUp"){me.preventDefault(),de(je=>je>0?je-1:ve.length-1);return}if(me.key==="Tab"||me.key==="Enter"&&!me.shiftKey){me.preventDefault();const je=ve[re];je&&Ie(je);return}if(me.key==="Escape"){me.preventDefault(),$("");return}}if(me.key==="Escape"&&E&&C){me.preventDefault(),C();return}me.key==="Enter"&&!me.shiftKey&&(me.preventDefault(),De())},[De,E,C,we,Ee.files,fe,Ue,ge,ve,re,Ie]),Ne=y.useCallback(me=>{$(me.target.value),he(!1),B(Ou(me.target,U.current))},[B]);y.useImperativeHandle(l,()=>({focus:()=>{var me;return(me=D.current)==null?void 0:me.focus()},getText:()=>O.current,setText:me=>{$(me),he(!1),requestAnimationFrame(()=>B(Ou(D.current,U.current)))}}),[B]);const Ae=(m==null?void 0:m.type)==="plan",Qe=(m==null?void 0:m.type)==="question",Je=p.length>0,ke=!!o,We=(T.trim().length>0||q.length>0)&&!K,ye=bn(t??Wo).midTurnSteering&&E,Re=we?"file-suggestions":ge?"slash-suggestions":void 0,Ve=we&&Ee.files[fe]?`file-suggestion-${fe}`:ge&&ve[re]?`slash-suggestion-${re}`:void 0;return a.jsxs("div",{className:G("relative pb-0",i?"px-2 pt-2":"px-3 pt-2",W&&"ring-2 ring-info/40 ring-inset"),onDragOver:te,onDragLeave:se,onDrop:J,children:[W&&a.jsx("div",{className:"motion-enter pointer-events-none absolute inset-0 flex items-center justify-center rounded-lg border-2 border-dashed border-info/40 bg-info/10",children:a.jsx("span",{className:"text-sm font-medium text-info",children:"Drop images here"})}),ge&&a.jsx(Ez,{suggestions:ve,filter:be,loading:w,selectedIndex:re,onSelect:Ie,onHover:de,onEdit:f}),we&&a.jsx(Pz,{files:Ee.files,query:(Se==null?void 0:Se.query)??"",loading:Ee.loading,selectedIndex:fe,onSelect:Ue,onHover:le}),a.jsxs("div",{children:[Ae&&a.jsx(I5,{allowedPrompts:m.allowedPrompts,summary:m.summary,planContent:m.planContent,actions:m.actions,recommendedAction:m.recommendedAction,responding:P,responseError:L,onApprove:me=>{qe(!0,me)},onReject:()=>{qe(!1)}}),a.jsx(iee,{suggestion:j,onAccept:Me}),q.length>0&&a.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:q.map((me,je)=>a.jsxs("div",{className:"motion-list-item relative group/thumb",children:[a.jsx("img",{src:me.preview,alt:`Upload ${je+1}`,className:"h-16 w-auto rounded-md border bg-muted object-contain"}),a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>Y(je),className:"absolute -right-1.5 -top-1.5 size-5 rounded-full border bg-popover p-0 text-muted-foreground opacity-100 hover:bg-destructive hover:text-destructive-foreground sm:opacity-0 sm:group-hover/thumb:opacity-100 sm:focus-visible:opacity-100","aria-label":`Remove image ${je+1}`,children:a.jsx(Mt,{className:"size-3","data-icon":"icon"})})]},me.id))}),H&&a.jsxs("div",{role:"status","aria-live":"polite",className:"motion-enter mb-2 flex items-center gap-2 text-xs text-warning",children:[a.jsx("span",{className:"flex-1",children:H}),!K&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:Z,className:"text-muted-foreground","aria-label":"Dismiss image notice",children:a.jsx(Mt,{"data-icon":"icon"})})]}),a.jsxs("div",{className:G("relative overflow-hidden border bg-popover shadow-lg shadow-black/5 transition-[border-color,box-shadow] duration-150",ke?"rounded-3xl":"rounded-xl",jee(Ae,Qe,Je),"focus-within:ring-3"),children:[Je&&a.jsx(P5,{requests:p,responding:h,onRespond:g,onRespondAll:x},(He=p[0])==null?void 0:He.requestId),a.jsxs("div",{className:G("min-w-0",ke?"flex flex-col":"grid items-end",!ke&&(A?"grid-cols-[1fr_auto]":"grid-cols-[auto_minmax(0,1fr)_auto]")),children:[r&&a.jsx("div",{className:G("flex shrink-0 items-center",A?"col-start-1 row-start-2 pl-0.5 pb-0.5":"col-start-1 row-start-1"),children:r}),a.jsx(Wc,{ref:D,value:T,onChange:Ne,onKeyDown:Ke,onPaste:ne,onFocus:()=>{setTimeout(()=>{var me;return(me=D.current)==null?void 0:me.scrollIntoView({behavior:"smooth",block:"center"})},300)},placeholder:kee(Ae,Qe,N,Je,ye,i),"aria-label":"Message",role:"combobox","aria-autocomplete":"list","aria-expanded":!!Re,"aria-controls":Re,"aria-activedescendant":Ve,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",Nee(ke,A,i))}),a.jsxs("div",{className:G("flex shrink-0 items-center justify-end",Cee(ke,A)),children:[o,a.jsx(ree,{}),a.jsx(Gz,{hasContent:We,onSubmit:De,submitLabel:ye?"Steer active turn":"Send message"})]})]})]}),k==="error"&&_&&a.jsx(mk,{error:_},_),v&&a.jsx(mk,{error:v},v)]})]})}));function _ee(n){for(let e=n.length-1;e>=0;e-=1){const t=n[e];if(t.type!=="attachment")continue;const s=$9(t.attachment);if((s==null?void 0:s.type)!=="goal_status")continue;const r=typeof s.condition=="string"?s.condition:"",o=s.met===!0,i=s.failed===!0;return s.sentinel===!0&&o||!r?null:{condition:r,status:i?"failed":o?"achieved":"active",reason:typeof s.reason=="string"?s.reason:void 0,iterations:typeof s.iterations=="number"?s.iterations:0,durationMs:typeof s.durationMs=="number"?s.durationMs:0,tokens:typeof s.tokens=="number"?s.tokens:0}}return null}function Lu(n){return`/api/codex/goals/${encodeURIComponent(n)}`}function qc(n){const e=V.c(13);let t,s,r,o;e[0]!==n?({className:s,children:t,value:o,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);let i;e[5]!==s?(i=G("flex flex-wrap gap-3",s),e[5]=s,e[6]=i):i=e[6];let l;e[7]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(Eee,{children:a.jsx(Tee,{})}),e[7]=l):l=e[7];let c;return e[8]!==t||e[9]!==r||e[10]!==i||e[11]!==o?(c=a.jsxs(j$,{value:o,"data-slot":"progress",className:i,...r,children:[t,l]}),e[8]=t,e[9]=r,e[10]=i,e[11]=o,e[12]=c):c=e[12],c}function Eee(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("relative flex h-1 w-full items-center overflow-x-hidden rounded-full bg-muted",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(N$,{className:r,"data-slot":"progress-track",...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Tee(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("h-full bg-primary transition-[width] duration-150 ease-out motion-reduce:transition-none",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(C$,{"data-slot":"progress-indicator",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function ZE(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-sm font-medium",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(_$,{className:r,"data-slot":"progress-label",...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function YE(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("ml-auto text-sm text-muted-foreground tabular-nums",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(E$,{className:r,"data-slot":"progress-value",...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}const Aee={section:null,canCreate:!1,beginEditing:()=>{}},Q0=y.createContext(Aee);function XE(){return y.useContext(Q0)}const JE="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-1",QE="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-2";function Iee(n){return n==="usageLimited"?"Usage limited":n==="budgetLimited"?"Budget limited":n.charAt(0).toUpperCase()+n.slice(1)}function Pee(n){return n==="complete"?"secondary":n==="blocked"||n.endsWith("Limited")?"destructive":n==="paused"?"outline":"default"}function $ee({agentKind:n,threadId:e,children:t}){const s=Bf(n),[r,o]=y.useState(null),[i,l]=y.useState(!0),[c,u]=y.useState(!1),[d,f]=y.useState(""),[m,p]=y.useState(""),[h,g]=y.useState(!1),[x,b]=y.useState(null),w=y.useCallback(async E=>{try{const T=await Ce(Lu(e),{signal:E});if(T.status===404||T.status===501){l(!1);return}if(!T.ok)return;const $=await T.json();o($.goal),l(!0)}catch{}},[e]);y.useEffect(()=>{const E=new AbortController;w(E.signal);const T=i?setInterval(()=>void w(),1e4):void 0;return()=>{E.abort(),T!==void 0&&clearInterval(T)}},[w,i]);const v=y.useCallback(()=>{var E;f((r==null?void 0:r.objective)??""),p(((E=r==null?void 0:r.tokenBudget)==null?void 0:E.toString())??""),b(null),u(!0)},[r]),j=async()=>{const E=d.trim();if(!E)return;const T=m.trim()?Number(m):null;if(T!==null&&(!Number.isSafeInteger(T)||T<=0)){b("Token budget must be a positive whole number");return}g(!0),b(null);try{const $=await Ce(Lu(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({objective:E,status:(r==null?void 0:r.status)==="complete"?"active":(r==null?void 0:r.status)??"active",tokenBudget:T})}),A=await $.json();if(!$.ok)throw new Error(A.error||"Could not save goal");o(A.goal),u(!1)}catch($){b($ instanceof Error?$.message:"Could not save goal")}finally{g(!1)}},k=async E=>{if(r){g(!0);try{const T=await Ce(Lu(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:E})});T.ok&&o((await T.json()).goal)}finally{g(!1)}}},_=async()=>{g(!0);try{(await Ce(Lu(e),{method:"DELETE"})).ok&&(o(null),u(!1))}finally{g(!1)}},N=r!=null&&r.tokenBudget?Math.min(100,r.tokensUsed/r.tokenBudget*100):null;let S=null;if(i&&c)S=a.jsxs("form",{className:QE,onSubmit:E=>{E.preventDefault(),j()},children:[a.jsxs("div",{className:"mb-2 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[a.jsx(Hl,{className:"size-3.5","data-icon":"inline-start"}),r?"Edit long-running goal":"Set a long-running goal"]}),a.jsxs(Ta,{className:"gap-2",children:[a.jsxs(fn,{children:[a.jsx(mn,{className:"sr-only",htmlFor:"goal-objective",children:"Goal objective"}),a.jsx(Wc,{id:"goal-objective",value:d,onChange:E=>f(E.target.value),placeholder:`What should ${s} keep working toward?`,rows:2,autoFocus:!0})]}),a.jsxs(fn,{orientation:"horizontal","data-invalid":!!x,children:[a.jsx(mn,{className:"text-xs text-muted-foreground",htmlFor:"goal-budget",children:"Token budget"}),a.jsx(On,{id:"goal-budget",type:"number",min:1,step:1,value:m,onChange:E=>p(E.target.value),placeholder:"Optional",className:"ml-auto h-8 w-28","aria-invalid":!!x})]})]}),a.jsx(_o,{className:"mt-1.5",children:x}),a.jsxs("div",{className:"mt-2 flex items-center justify-end gap-1",children:[a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",onClick:()=>u(!1),children:[a.jsx(Mt,{"data-icon":"inline-start"}),"Cancel"]}),a.jsxs(Q,{type:"submit",size:"xs",disabled:h||!d.trim(),children:[a.jsx(nn,{"data-icon":"inline-start"}),"Save goal"]})]})]});else if(i&&r){const E=r.status==="paused",T=r.status==="complete";S=a.jsxs("section",{className:JE,"aria-label":`${s} goal`,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Hl,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",title:r.objective,children:r.objective}),a.jsx(Fe,{variant:Pee(r.status),children:Iee(r.status)}),a.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[vt(r.tokensUsed),r.tokenBudget?` / ${vt(r.tokenBudget)}`:""," · ",Math.max(0,Math.round(r.timeUsedSeconds/60)),"m"]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[E&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void k("active"),disabled:h,"aria-label":"Resume goal",children:a.jsx(Na,{"data-icon":"icon"})}),!E&&!T&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void k("paused"),disabled:h,"aria-label":"Pause goal",children:a.jsx(T$,{"data-icon":"icon"})}),!T&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void k("complete"),disabled:h,"aria-label":"Mark goal complete",children:a.jsx(nn,{"data-icon":"icon"})}),a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:v,"aria-label":"Edit goal",children:a.jsx(yr,{"data-icon":"icon"})}),a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void _(),disabled:h,className:"text-destructive","aria-label":"Clear goal",children:a.jsx(kf,{"data-icon":"icon"})})]})]}),N!==null&&a.jsx(qc,{className:"mt-1 mb-0.5",value:N,"aria-label":`${N.toFixed(0)}% of goal token budget used`})]})}const C=y.useMemo(()=>({section:S,canCreate:i&&!r&&!c,beginEditing:v}),[S,i,r,c,v]);return a.jsx(Q0.Provider,{value:C,children:t})}function Ree(n){switch(n){case"active":return"Goal active";case"achieved":return"Achieved";default:return"Needs attention"}}function Oee(n){switch(n){case"failed":return"destructive";case"achieved":return"secondary";default:return"outline"}}function Lee(n){const e=V.c(89),{agentKind:t,session:s,onSendCommand:r,children:o}=n;let i;e[0]!==t?(i=Bf(t),e[0]=t,e[1]=i):i=e[1];const l=i;let c;e[2]!==s.rawMessages?(c=_ee(s.rawMessages),e[2]=s.rawMessages,e[3]=c):c=e[3];const u=c,[d,f]=y.useState(),[m,p]=y.useState(!1),[h,g]=y.useState(""),[x,b]=y.useState(null),w=u?`${u.status}\0${u.condition}`:"",[v,j]=y.useState(w);v!==w&&(j(w),f(void 0));const k=d!==void 0?d:u;let _;e[4]!==(k==null?void 0:k.condition)?(_=()=>{g((k==null?void 0:k.condition)??""),b(null),p(!0)},e[4]=k==null?void 0:k.condition,e[5]=_):_=e[5];const N=_;let S;e[6]!==r||e[7]!==d?(S=async(M,F)=>{const U=d;f(F),p(!1);const O=await r(M);return O||f(U),O},e[6]=r,e[7]=d,e[8]=S):S=e[8];const C=S;let E;e[9]!==h||e[10]!==C?(E=async()=>{const M=h.trim();if(!M)return;if(M.length>4e3){b("Goal conditions can be at most 4,000 characters");return}await C(`/goal ${M}`,{condition:M,status:"active",iterations:0,durationMs:0,tokens:0})||(g(M),p(!0))},e[9]=h,e[10]=C,e[11]=E):E=e[11];const T=E;let $;e[12]!==C?($=()=>void C("/goal clear",null),e[12]=C,e[13]=$):$=e[13];const A=$;let R;if(e[14]!==l||e[15]!==N||e[16]!==A||e[17]!==h||e[18]!==m||e[19]!==x||e[20]!==k||e[21]!==T){if(R=null,m){let M;e[23]===Symbol.for("react.memo_cache_sentinel")?(M=a.jsx(Hl,{className:"size-3.5","data-icon":"inline-start"}),e[23]=M):M=e[23];const F=k?"Replace goal":"Set a long-running goal";let U;e[24]!==F?(U=a.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[M,F]}),e[24]=F,e[25]=U):U=e[25];const O=!!x;let D;e[26]===Symbol.for("react.memo_cache_sentinel")?(D=a.jsx(mn,{className:"sr-only",htmlFor:"goal-condition",children:"Goal condition"}),e[26]=D):D=e[26];let B;e[27]===Symbol.for("react.memo_cache_sentinel")?(B=ne=>g(ne.target.value),e[27]=B):B=e[27];const q=`A measurable condition ${l} should keep working toward…`,W=!!x;let H;e[28]!==h||e[29]!==q||e[30]!==W?(H=a.jsx(Wc,{id:"goal-condition",value:h,onChange:B,placeholder:q,rows:2,maxLength:4e3,"aria-invalid":W,autoFocus:!0}),e[28]=h,e[29]=q,e[30]=W,e[31]=H):H=e[31];let K;e[32]!==x?(K=a.jsx(_o,{children:x}),e[32]=x,e[33]=K):K=e[33];let Z;e[34]!==O||e[35]!==H||e[36]!==K?(Z=a.jsxs(fn,{"data-invalid":O,children:[D,H,K]}),e[34]=O,e[35]=H,e[36]=K,e[37]=Z):Z=e[37];let Y;e[38]===Symbol.for("react.memo_cache_sentinel")?(Y=a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",onClick:()=>p(!1),children:[a.jsx(Mt,{"data-icon":"inline-start"}),"Cancel"]}),e[38]=Y):Y=e[38];let X;e[39]!==T?(X=()=>void T(),e[39]=T,e[40]=X):X=e[40];let ee;e[41]!==h?(ee=h.trim(),e[41]=h,e[42]=ee):ee=e[42];const te=!ee;let se;e[43]===Symbol.for("react.memo_cache_sentinel")?(se=a.jsx(nn,{"data-icon":"inline-start"}),e[43]=se):se=e[43];let J;e[44]!==X||e[45]!==te?(J=a.jsxs("div",{className:"mt-2 flex items-center justify-end gap-1",children:[Y,a.jsxs(Q,{type:"button",size:"xs",onClick:X,disabled:te,children:[se,"Start goal"]})]}),e[44]=X,e[45]=te,e[46]=J):J=e[46],R=a.jsxs("section",{className:QE,"aria-label":`${l} goal editor`,children:[U,Z,J]})}else if(k){let M;e[47]===Symbol.for("react.memo_cache_sentinel")?(M=a.jsx(Hl,{className:"size-3.5 shrink-0 text-primary","data-icon":"inline-start"}),e[47]=M):M=e[47];let F;e[48]!==k.condition?(F=a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",title:k.condition,children:k.condition}),e[48]=k.condition,e[49]=F):F=e[49];let U;e[50]!==k.status?(U=Oee(k.status),e[50]=k.status,e[51]=U):U=e[51];let O;e[52]!==k.status?(O=Ree(k.status),e[52]=k.status,e[53]=O):O=e[53];let D;e[54]!==O||e[55]!==U?(D=a.jsx(Fe,{variant:U,children:O}),e[54]=O,e[55]=U,e[56]=D):D=e[56];const B=k.iterations,q=k.iterations===1?"":"s";let W;e[57]!==k.tokens?(W=vt(k.tokens),e[57]=k.tokens,e[58]=W):W=e[58];let H;e[59]!==k.durationMs?(H=Math.round(k.durationMs/6e4),e[59]=k.durationMs,e[60]=H):H=e[60];const K=Math.max(0,H);let Z;e[61]!==k.iterations||e[62]!==q||e[63]!==W||e[64]!==K?(Z=a.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[B," turn",q," · ",W," · ",K,"m"]}),e[61]=k.iterations,e[62]=q,e[63]=W,e[64]=K,e[65]=Z):Z=e[65];let Y;e[66]===Symbol.for("react.memo_cache_sentinel")?(Y=a.jsx(yr,{"data-icon":"icon"}),e[66]=Y):Y=e[66];let X;e[67]!==N?(X=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:N,"aria-label":"Replace goal",children:Y}),e[67]=N,e[68]=X):X=e[68];let ee;e[69]===Symbol.for("react.memo_cache_sentinel")?(ee=a.jsx(kf,{"data-icon":"icon"}),e[69]=ee):ee=e[69];let te;e[70]!==A?(te=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:A,"aria-label":"Clear goal",children:ee}),e[70]=A,e[71]=te):te=e[71];let se;e[72]!==X||e[73]!==te?(se=a.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[X,te]}),e[72]=X,e[73]=te,e[74]=se):se=e[74];let J;e[75]!==D||e[76]!==Z||e[77]!==se||e[78]!==F?(J=a.jsxs("div",{className:"flex items-center gap-2",children:[M,F,D,Z,se]}),e[75]=D,e[76]=Z,e[77]=se,e[78]=F,e[79]=J):J=e[79];let ne;e[80]!==k.reason?(ne=k.reason&&a.jsx("p",{className:"line-clamp-2 pb-0.5 pl-5 text-xs text-muted-foreground",children:k.reason}),e[80]=k.reason,e[81]=ne):ne=e[81],R=a.jsxs("section",{className:JE,"aria-label":`${l} goal`,children:[J,ne]})}e[14]=l,e[15]=N,e[16]=A,e[17]=h,e[18]=m,e[19]=x,e[20]=k,e[21]=T,e[22]=R}else R=e[22];const P=!k&&!m;let z;e[82]!==N||e[83]!==R||e[84]!==P?(z={section:R,canCreate:P,beginEditing:N},e[82]=N,e[83]=R,e[84]=P,e[85]=z):z=e[85];const L=z;let I;return e[86]!==o||e[87]!==L?(I=a.jsx(Q0.Provider,{value:L,children:o}),e[86]=o,e[87]=L,e[88]=I):I=e[88],I}function Mee(n){const e=V.c(9),{agentKind:t,session:s,onSendCommand:r,children:o}=n,i=bn(t).goals;if(i==="thread-api"){let l;return e[0]!==t||e[1]!==o||e[2]!==s.sessionId?(l=a.jsx($ee,{agentKind:t,threadId:s.sessionId,children:o}),e[0]=t,e[1]=o,e[2]=s.sessionId,e[3]=l):l=e[3],l}if(i==="transcript"){let l;return e[4]!==t||e[5]!==o||e[6]!==r||e[7]!==s?(l=a.jsx(Lee,{agentKind:t,session:s,onSendCommand:r,children:o}),e[4]=t,e[5]=o,e[6]=r,e[7]=s,e[8]=l):l=e[8],l}return o}function zee(){return XE().section}function pk(){const n=V.c(3),{canCreate:e,beginEditing:t}=XE();if(!e)return null;let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(Hl,{"data-icon":"inline-start"}),n[0]=s):s=n[0];let r;return n[1]!==t?(r=a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",onClick:t,title:"Set a long-running goal for this session",children:[s,"Set goal"]}),n[1]=t,n[2]=r):r=n[2],r}const Dee=["allow","allow_always","deny"],Fee=[{decision:"allow",label:"Allow",variant:"default"},{decision:"deny",label:"Deny",variant:"destructive"},{decision:"allow_always",label:"Always",variant:"outline"}];function Uee(n,e){return(n.availableDecisions??Dee).includes(e)}function Bee(n){const e=V.c(22),{request:t,queued:s,responding:r,onRespond:o}=n;let i;if(e[0]!==o||e[1]!==s||e[2]!==t||e[3]!==r){let l;e[5]!==t?(l=w=>Uee(t,w.decision),e[5]=t,e[6]=l):l=e[6];const c=Fee.filter(l);t.defaultToNo&&c.sort(qee);const u=c.some(Wee);let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx(ix,{className:"text-warning"}),e[7]=d):d=e[7];const f=t.title||`Allow ${t.toolName}?`;let m;e[8]!==f?(m=a.jsx("span",{className:"min-w-0 flex-1 truncate",children:f}),e[8]=f,e[9]=m):m=e[9];let p;e[10]!==s?(p=s>0&&a.jsxs("span",{className:"shrink-0 font-mono text-xs text-warning",children:["+",s]}),e[10]=s,e[11]=p):p=e[11];let h;e[12]!==m||e[13]!==p?(h=a.jsxs(tn,{className:"flex min-w-0 items-center gap-2",children:[m,p]}),e[12]=m,e[13]=p,e[14]=h):h=e[14];let g;e[15]!==t.toolName?(g=a.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:t.toolName}),e[15]=t.toolName,e[16]=g):g=e[16];let x;e[17]!==t.summary?(x=t.summary&&a.jsx("code",{className:"min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 font-mono text-xs text-foreground",children:t.summary}),e[17]=t.summary,e[18]=x):x=e[18];let b;e[19]!==g||e[20]!==x?(b=a.jsxs("div",{className:"col-start-2 mt-2 flex min-w-0 items-center gap-2",children:[g,x]}),e[19]=g,e[20]=x,e[21]=b):b=e[21],i=a.jsxs(jt,{className:"border-warning/40 bg-warning/5",children:[d,h,b,o&&(u?a.jsx("div",{className:"col-start-2 mt-3 flex items-center gap-2",children:c.map(w=>{const{decision:v,label:j,variant:k}=w;return a.jsx(Q,{autoFocus:t.defaultToNo&&v==="deny",size:"xs",variant:k,disabled:r,onClick:()=>o(t.requestId,v),children:j},`${t.requestId}:${v}`)})}):a.jsx("p",{className:"col-start-2 mt-2 text-xs text-warning",children:"Resolve this approval in its own provider"}))]}),e[0]=o,e[1]=s,e[2]=t,e[3]=r,e[4]=i}else i=e[4];return i}function Wee(n){return n.decision!=="allow_always"}function qee(n,e){return+(e.decision==="deny")-+(n.decision==="deny")}const eT=y.createContext({size:"default",variant:"default",spacing:2,orientation:"horizontal"});function tT(n){const e=V.c(29);let t,s,r,o,i,l,c;e[0]!==n?({className:s,variant:c,size:o,spacing:i,orientation:l,children:t,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i,e[6]=l,e[7]=c):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5],l=e[6],c=e[7]);const u=i===void 0?2:i,d=l===void 0?"horizontal":l;let f;e[8]!==u?(f={"--gap":u},e[8]=u,e[9]=f):f=e[9];const m=f;let p;e[10]!==s?(p=G("group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-[orientation=vertical]:flex-col data-[orientation=vertical]:items-stretch",s),e[10]=s,e[11]=p):p=e[11];let h;e[12]!==d||e[13]!==o||e[14]!==u||e[15]!==c?(h={variant:c,size:o,spacing:u,orientation:d},e[12]=d,e[13]=o,e[14]=u,e[15]=c,e[16]=h):h=e[16];let g;e[17]!==t||e[18]!==h?(g=a.jsx(eT.Provider,{value:h,children:t}),e[17]=t,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==d||e[21]!==r||e[22]!==o||e[23]!==u||e[24]!==m||e[25]!==p||e[26]!==g||e[27]!==c?(x=a.jsx(A$,{"data-slot":"toggle-group","data-variant":c,"data-size":o,"data-spacing":u,"data-orientation":d,orientation:d,style:m,className:p,...r,children:g}),e[20]=d,e[21]=r,e[22]=o,e[23]=u,e[24]=m,e[25]=p,e[26]=g,e[27]=c,e[28]=x):x=e[28],x}function g1(n){const e=V.c(19);let t,s,r,o,i;e[0]!==n?({className:s,children:t,variant:o,size:i,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5]);const l=o===void 0?"default":o,c=i===void 0?"default":i,u=y.useContext(eT),d=u.variant||l,f=u.size||c,m=u.spacing;let p;e[6]!==s||e[7]!==u.size||e[8]!==u.variant||e[9]!==c||e[10]!==l?(p=G("shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t",p5({variant:u.variant||l,size:u.size||c}),s),e[6]=s,e[7]=u.size,e[8]=u.variant,e[9]=c,e[10]=l,e[11]=p):p=e[11];let h;return e[12]!==t||e[13]!==u.spacing||e[14]!==r||e[15]!==d||e[16]!==f||e[17]!==p?(h=a.jsx(h4,{"data-slot":"toggle-group-item","data-variant":d,"data-size":f,"data-spacing":m,className:p,...r,children:t}),e[12]=t,e[13]=u.spacing,e[14]=r,e[15]=d,e[16]=f,e[17]=p,e[18]=h):h=e[18],h}function Vee(n){return n.some(e=>e.options.length===0||e.options.some(t=>t.hasPreview))}function Hee(n){const e=V.c(64),{request:t,responding:s,gone:r,onAnswer:o,onOpenSession:i}=n,l=t.questions,[c,u]=y.useState(0);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={},e[0]=d):d=e[0];const f=y.useRef(d);let m;e[1]===Symbol.for("react.memo_cache_sentinel")?(m=new Set,e[1]=m):m=e[1];const[p,h]=y.useState(m);if(l.length===0)return null;if(Vee(l)){let M;e[2]!==l[0].question?(M=a.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:l[0].question}),e[2]=l[0].question,e[3]=M):M=e[3];let F;e[4]===Symbol.for("react.memo_cache_sentinel")?(F=a.jsx(it,{"data-icon":"inline-end"}),e[4]=F):F=e[4];let U;e[5]!==i?(U=a.jsxs(Q,{variant:"outline",size:"sm",onClick:i,className:"mt-3",children:["Open full question",F]}),e[5]=i,e[6]=U):U=e[6];let O;return e[7]!==M||e[8]!==U?(O=a.jsxs(hk,{children:[M,U]}),e[7]=M,e[8]=U,e[9]=O):O=e[9],O}const g=l[c],x=s||!o;let b;e[10]!==g.question||e[11]!==c||e[12]!==o||e[13]!==l.length||e[14]!==t.toolUseId?(b=function(F){const U={...f.current,[g.question]:F};if(c+1<l.length){f.current=U,h(new Set),u(c+1);return}o==null||o(t.toolUseId,U)},e[10]=g.question,e[11]=c,e[12]=o,e[13]=l.length,e[14]=t.toolUseId,e[15]=b):b=e[15];const w=b;let v;e[16]!==g.header?(v=g.header&&a.jsx(Fe,{variant:"outline",className:"border-info/40 text-info",children:g.header}),e[16]=g.header,e[17]=v):v=e[17];let j;e[18]!==c||e[19]!==l.length?(j=l.length>1&&a.jsxs("span",{className:"ml-auto shrink-0 font-mono text-xs text-muted-foreground",children:[c+1," of ",l.length]}),e[18]=c,e[19]=l.length,e[20]=j):j=e[20];let k;e[21]!==v||e[22]!==j?(k=a.jsxs("div",{className:"flex items-baseline gap-1.5",children:[v,j]}),e[21]=v,e[22]=j,e[23]=k):k=e[23];let _;e[24]!==g.question?(_=a.jsx("p",{className:"mt-2 line-clamp-3 text-sm leading-relaxed text-foreground",title:g.question,children:g.question}),e[24]=g.question,e[25]=_):_=e[25];let N;e[26]!==p?(N=[...p],e[26]=p,e[27]=N):N=e[27];let S;e[28]!==w||e[29]!==g.multiSelect?(S=M=>{g.multiSelect?h(new Set(M)):M[0]&&w(M[0])},e[28]=w,e[29]=g.multiSelect,e[30]=S):S=e[30];const C=g.multiSelect,E=g.question;let T;if(e[31]!==g.options||e[32]!==x){let M;e[34]!==x?(M=F=>a.jsx(Kee,{option:F,disabled:x},F.label),e[34]=x,e[35]=M):M=e[35],T=g.options.map(M),e[31]=g.options,e[32]=x,e[33]=T}else T=e[33];let $;e[36]!==g.multiSelect||e[37]!==g.question||e[38]!==T||e[39]!==N||e[40]!==S?($=a.jsx(tT,{value:N,onValueChange:S,multiple:C,orientation:"vertical",variant:"outline",size:"sm",className:"mt-3 w-full items-stretch","aria-label":E,children:T}),e[36]=g.multiSelect,e[37]=g.question,e[38]=T,e[39]=N,e[40]=S,e[41]=$):$=e[41];let A;e[42]!==w||e[43]!==g.multiSelect||e[44]!==c||e[45]!==o||e[46]!==l.length||e[47]!==s||e[48]!==p?(A=g.multiSelect&&o&&a.jsx(Q,{size:"sm",disabled:s||p.size===0,onClick:()=>w(wee(p)),children:c+1<l.length?"Next":"Send"}),e[42]=w,e[43]=g.multiSelect,e[44]=c,e[45]=o,e[46]=l.length,e[47]=s,e[48]=p,e[49]=A):A=e[49];let R;e[50]===Symbol.for("react.memo_cache_sentinel")?(R=a.jsx(it,{"data-icon":"inline-end"}),e[50]=R):R=e[50];let P;e[51]!==i?(P=a.jsxs(Q,{variant:"ghost",size:"sm",onClick:i,className:"ml-auto text-muted-foreground",children:["Open session",R]}),e[51]=i,e[52]=P):P=e[52];let z;e[53]!==A||e[54]!==P?(z=a.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[A,P]}),e[53]=A,e[54]=P,e[55]=z):z=e[55];let L;e[56]!==r?(L=r&&a.jsx("p",{className:"mt-2 text-xs text-warning",children:"This question may already be answered. Open the session to check."}),e[56]=r,e[57]=L):L=e[57];let I;return e[58]!==$||e[59]!==z||e[60]!==L||e[61]!==k||e[62]!==_?(I=a.jsxs(hk,{children:[k,_,$,z,L]}),e[58]=$,e[59]=z,e[60]=L,e[61]=k,e[62]=_,e[63]=I):I=e[63],I}function Kee(n){const e=V.c(17),{option:t,disabled:s}=n;let r;e[0]!==t.label?(r=a.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:t.label}),e[0]=t.label,e[1]=r):r=e[1];const o=r;if(!t.description){let d;return e[2]!==s||e[3]!==o||e[4]!==t.label?(d=a.jsx(g1,{value:t.label,disabled:s,className:"w-full justify-start px-3",children:o}),e[2]=s,e[3]=o,e[4]=t.label,e[5]=d):d=e[5],d}let i;e[6]!==s||e[7]!==t.label?(i=a.jsx(g1,{value:t.label,disabled:s,className:"w-full justify-start px-3"}),e[6]=s,e[7]=t.label,e[8]=i):i=e[8];let l;e[9]!==o||e[10]!==i?(l=a.jsx(Zt,{render:i,children:o}),e[9]=o,e[10]=i,e[11]=l):l=e[11];let c;e[12]!==t.description?(c=a.jsx(Yt,{side:"right",className:"max-w-72 text-left",children:t.description}),e[12]=t.description,e[13]=c):c=e[13];let u;return e[14]!==l||e[15]!==c?(u=a.jsxs(Gt,{children:[l,c]}),e[14]=l,e[15]=c,e[16]=u):u=e[16],u}function hk(n){const e=V.c(4),{children:t}=n;let s,r;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(I$,{className:"text-info"}),r=a.jsx(tn,{children:"Answer to continue"}),e[0]=s,e[1]=r):(s=e[0],r=e[1]);let o;return e[2]!==t?(o=a.jsxs(jt,{className:"border-info/40 bg-info/5",children:[s,r,a.jsx("div",{className:"col-start-2 mt-1 min-w-0",children:t})]}),e[2]=t,e[3]=o):o=e[3],o}function Gee(n){const e=V.c(45),{sessionId:t,pending:s,queued:r,responding:o,onRespond:i,onOpen:l}=n;switch(s.kind){case"permission":{let c;e[0]!==s||e[1]!==t?(c={...s,sessionId:t,timestamp:0},e[0]=s,e[1]=t,e[2]=c):c=e[2];let u;e[3]!==i?(u=(f,m)=>i(f,{decision:m}),e[3]=i,e[4]=u):u=e[4];let d;return e[5]!==r||e[6]!==o||e[7]!==c||e[8]!==u?(d=a.jsx(Bee,{request:c,queued:r,responding:o,onRespond:u}),e[5]=r,e[6]=o,e[7]=c,e[8]=u,e[9]=d):d=e[9],d}case"question":{const c=s.requestId;let u;e[10]!==s.questions?(u=s.questions.map(Zee),e[10]=s.questions,e[11]=u):u=e[11];let d;e[12]!==s.requestId||e[13]!==t||e[14]!==u?(d={sessionId:t,toolUseId:c,askedAt:0,questions:u},e[12]=s.requestId,e[13]=t,e[14]=u,e[15]=d):d=e[15];let f;e[16]!==i?(f=(p,h)=>i(p,{answers:h}),e[16]=i,e[17]=f):f=e[17];let m;return e[18]!==l||e[19]!==o||e[20]!==d||e[21]!==f?(m=a.jsx(Hee,{request:d,responding:o,gone:!1,onAnswer:f,onOpenSession:l}),e[18]=l,e[19]=o,e[20]=d,e[21]=f,e[22]=m):m=e[22],m}case"plan":{let c,u;e[23]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx(P$,{className:"text-info"}),u=a.jsx(tn,{children:"Approve the plan?"}),e[23]=c,e[24]=u):(c=e[23],u=e[24]);let d;e[25]!==s.summary?(d=s.summary&&a.jsx("p",{className:"col-start-2 mt-1 line-clamp-3 text-sm text-foreground",children:s.summary}),e[25]=s.summary,e[26]=d):d=e[26];let f;e[27]!==i||e[28]!==s.requestId?(f=()=>i(s.requestId,{approved:!0}),e[27]=i,e[28]=s.requestId,e[29]=f):f=e[29];let m;e[30]!==o||e[31]!==f?(m=a.jsx(Q,{size:"xs",disabled:o,onClick:f,children:"Approve"}),e[30]=o,e[31]=f,e[32]=m):m=e[32];let p;e[33]!==i||e[34]!==s.requestId?(p=()=>i(s.requestId,{approved:!1}),e[33]=i,e[34]=s.requestId,e[35]=p):p=e[35];let h;e[36]!==o||e[37]!==p?(h=a.jsx(Q,{size:"xs",variant:"destructive",disabled:o,onClick:p,children:"Reject"}),e[36]=o,e[37]=p,e[38]=h):h=e[38];let g;e[39]!==m||e[40]!==h?(g=a.jsxs("div",{className:"col-start-2 mt-3 flex items-center gap-2",children:[m,h]}),e[39]=m,e[40]=h,e[41]=g):g=e[41];let x;return e[42]!==d||e[43]!==g?(x=a.jsxs(jt,{className:"border-info/40 bg-info/5",children:[c,u,d,g]}),e[42]=d,e[43]=g,e[44]=x):x=e[44],x}}}function Zee(n){return{question:n.question,multiSelect:n.multiSelect,options:n.options.map(Yee)}}function Yee(n){return{label:n,hasPreview:!1}}const Xee=3e3;function Jee(n){const[e,t]=y.useState([]),[s,r]=y.useState(new Set),o=y.useCallback(async l=>{if(n)try{const c=await Ce(`/api/session-requests?parent=${encodeURIComponent(n)}`);if(!l()||!c.ok)return;const u=await c.json();if(!l())return;t(d=>JSON.stringify(d)===JSON.stringify(u.requests)?d:u.requests)}catch{}},[n]);Ra(n?o:null,Xee),y.useEffect(()=>{t([])},[n]);const i=y.useCallback(async(l,c,u)=>{r(d=>new Set(d).add(c));try{const d=await is("/api/session-respond",{sessionId:l,requestId:c,...u});(d.ok||d.status===404)&&t(f=>f.map(m=>m.sessionId===l?{...m,waiting:m.waiting.filter(p=>p.requestId!==c)}:m).filter(m=>m.waiting.length>0))}finally{r(d=>{const f=new Set(d);return f.delete(c),f})}},[]);return{requests:e,responding:s,respond:i}}function Ma(n){window.history.pushState({},"",n),window.dispatchEvent(new PopStateEvent("popstate"))}function pa(n,e,t){return`${t===void 0?Nx():`/d/${encodeURIComponent(t)}`}/${encodeURIComponent(n)}/${encodeURIComponent(X4(n,e))}`}async function cm(n){let e;try{e=await Ce(`/api/find-session/${encodeURIComponent(n)}`)}catch{return!1}const t=e.ok?await zs(e):null;return typeof(t==null?void 0:t.dirName)!="string"||typeof t.fileName!="string"?!1:(Ma(pa(t.dirName,t.fileName)),!0)}function Qee(n){var o;if(!n.address)return null;const{dirName:e,fileName:t}=n.address,s=((o=n.device)==null?void 0:o.id)??Kt();return`${s===Lt?"":`/d/${encodeURIComponent(s)}`}/${encodeURIComponent(e)}/${encodeURIComponent(X4(e,t))}`}function ete(n){const e=V.c(9),{sessionId:t}=n,{requests:s,responding:r,respond:o}=Jee(t);if(s.length===0)return null;let i;if(e[0]!==s||e[1]!==o||e[2]!==r){let c;e[4]!==o||e[5]!==r?(c=u=>a.jsx(tte,{request:u,responding:r,onRespond:(d,f)=>void o(u.sessionId,d,f)},u.sessionId),e[4]=o,e[5]=r,e[6]=c):c=e[6],i=s.map(c),e[0]=s,e[1]=o,e[2]=r,e[3]=i}else i=e[3];let l;return e[7]!==i?(l=a.jsx("div",{className:"flex flex-col gap-2 px-3 pb-2",children:i}),e[7]=i,e[8]=l):l=e[8],l}function tte(n){const e=V.c(26),{request:t,responding:s,onRespond:r}=n;let o;e[0]!==t?(o=Qee(t),e[0]=t,e[1]=o):o=e[1];const i=o;let l;e[2]!==i?(l=()=>{i&&Ma(i)},e[2]=i,e[3]=l):l=e[3];const c=l,[u]=t.waiting;if(!u)return null;let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx(ax,{className:"size-3.5"}),e[4]=d):d=e[4];const f=t.device?`Delegated session on ${t.device.name}`:"Delegated session";let m;e[5]!==f?(m=a.jsx("span",{className:"truncate",children:f}),e[5]=f,e[6]=m):m=e[6];let p;e[7]!==c||e[8]!==i?(p=i&&a.jsxs(Q,{variant:"ghost",size:"xs",className:"ml-auto",onClick:c,children:["Open",a.jsx(it,{"data-icon":"inline-end"})]}),e[7]=c,e[8]=i,e[9]=p):p=e[9];let h;e[10]!==m||e[11]!==p?(h=a.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[d,m,p]}),e[10]=m,e[11]=p,e[12]=h):h=e[12];const g=u.requestId,x=t.sessionId,b=t.waiting.length-1;let w;e[13]!==u.requestId||e[14]!==s?(w=s.has(u.requestId),e[13]=u.requestId,e[14]=s,e[15]=w):w=e[15];let v;e[16]!==r||e[17]!==c||e[18]!==u||e[19]!==t.sessionId||e[20]!==b||e[21]!==w?(v=a.jsx(Gee,{sessionId:x,pending:u,queued:b,responding:w,onRespond:r,onOpen:c},g),e[16]=r,e[17]=c,e[18]=u,e[19]=t.sessionId,e[20]=b,e[21]=w,e[22]=v):v=e[22];let j;return e[23]!==v||e[24]!==h?(j=a.jsxs("div",{className:"flex flex-col gap-1",children:[h,v]}),e[23]=v,e[24]=h,e[25]=j):j=e[25],j}const x1="cogpit-session-config-changed";function nte(n){if(typeof n!="string")return null;let e;try{e=JSON.parse(n)}catch{e=n.trim()}if(typeof e=="string")return e||null;const t=e==null?void 0:e.sessionId;return typeof t=="string"?t:null}function ste(n){function e(t){const s=nte(t.data);s&&window.dispatchEvent(new CustomEvent(x1,{detail:{sessionId:s}}))}return n.addEventListener(Ny,e),()=>n.removeEventListener(Ny,e)}function rte(n,e){function t(s){var r;((r=s.detail)==null?void 0:r.sessionId)===n&&e()}return window.addEventListener(x1,t),()=>window.removeEventListener(x1,t)}const nf=new Map;class ote extends EventTarget{constructor(t,s){super();Ge(this,"CONNECTING",0);Ge(this,"OPEN",1);Ge(this,"CLOSED",2);Ge(this,"withCredentials",!1);Ge(this,"onopen",null);Ge(this,"onmessage",null);Ge(this,"onerror",null);this.owner=t,this.options=s;for(const r of["open","message","error"])super.addEventListener(r,o=>{const i=r==="open"?this.onopen:r==="message"?this.onmessage:this.onerror;i==null||i.call(this,o)})}get url(){return this.owner.url}get readyState(){var t;return((t=this.owner.source)==null?void 0:t.readyState)??(this.owner.health.transport==="denied"?2:0)}addEventListener(t,s,r){this.owner.listen(t),super.addEventListener(t,s,r)}close(){this.owner.remove(this)}emit(t){this.dispatchEvent(t instanceof MessageEvent?new MessageEvent(t.type,{data:t.data,origin:t.origin,lastEventId:t.lastEventId}):new Event(t.type))}}class ite{constructor(e,t){Ge(this,"source",null);Ge(this,"health",{transport:"connecting",freshness:"waiting",lastEventAt:null});Ge(this,"subscribers",new Set);Ge(this,"types",new Set(["open","error","message","access","session-config"]));Ge(this,"linked",new Set);Ge(this,"asking",null);Ge(this,"timer");Ge(this,"attempts",0);Ge(this,"generation",0);Ge(this,"retryingGeneration",null);Ge(this,"stopped",!1);Ge(this,"stopFrames",[]);Ge(this,"foreground",()=>{document.visibilityState==="hidden"||this.stopped||this.health.transport==="denied"||(!this.source||this.health.transport!=="open"||this.health.lastEventAt!==null&&Date.now()-this.health.lastEventAt>45e3)&&this.connect()});Ge(this,"identityChanged",()=>this.stop());this.key=e,this.url=t,window.addEventListener("online",this.foreground),document.addEventListener("visibilitychange",this.foreground),window.addEventListener("cogpit-identity-changed",this.identityChanged),window.addEventListener("cogpit-device-scope-changed",this.identityChanged),this.connect()}add(e){const t=new ote(this,e);return this.subscribers.add(t),queueMicrotask(()=>{var s,r;this.subscribers.has(t)&&((s=e.onState)==null||s.call(e,this.health),this.health.transport==="open"?t.emit(new Event("open")):this.health.transport==="denied"&&((r=e.onLost)==null||r.call(e)))}),t}remove(e){this.subscribers.delete(e),this.subscribers.size||this.stop()}listen(e){this.types.add(e),this.link(e)}link(e){const t=this.source,s=this.generation;!t||this.linked.has(e)||(this.linked.add(e),t.addEventListener(e,r=>{if(!(this.stopped||s!==this.generation)){if(e==="open")this.attempts=0,this.setHealth({...this.health,transport:"open"});else if(e==="error"){if(this.retryingGeneration===s)return;this.retryingGeneration=s,this.setHealth({...this.health,transport:"retrying",freshness:"stale"});const o=t.readyState===EventSource.CLOSED;t.close(),this.retry(s,o)}else this.setHealth({transport:"open",freshness:"current",lastEventAt:Date.now()});for(const o of this.subscribers)o.emit(r)}}))}setHealth(e){var t,s;this.health=e;for(const r of this.subscribers)(s=(t=r.options).onState)==null||s.call(t,e)}connect(){var e,t;if(!this.stopped){clearTimeout(this.timer),(e=this.asking)==null||e.abort();for(const s of this.stopFrames)s();(t=this.source)==null||t.close(),this.generation++,this.retryingGeneration=null,this.linked.clear(),this.setHealth({...this.health,transport:"connecting"}),this.source=new EventSource(this.url),this.stopFrames=[SR(this.source),ste(this.source)];for(const s of this.types)this.link(s)}}async retry(e,t){var o,i,l;const s=new AbortController;if(this.asking=s,t)try{const c=await Ce(this.url,{signal:s.signal});if((o=c.body)==null||o.cancel(),this.stopped||e!==this.generation||s.signal.aborted)return;if(c.status===401||c.status===403||aN(c)){this.setHealth({...this.health,transport:"denied",freshness:"stale"});for(const u of this.subscribers)(l=(i=u.options).onLost)==null||l.call(i);return}}catch{if(this.stopped||s.signal.aborted)return}if(this.stopped||e!==this.generation)return;const r=Math.min(3e4,500*2**Math.min(this.attempts++,6))*(.75+Math.random()*.5);this.timer=setTimeout(()=>this.connect(),r)}stop(){var e,t;this.stopped=!0,this.generation++,clearTimeout(this.timer),(e=this.asking)==null||e.abort(),(t=this.source)==null||t.close();for(const s of this.stopFrames)s();window.removeEventListener("online",this.foreground),document.removeEventListener("visibilitychange",this.foreground),window.removeEventListener("cogpit-identity-changed",this.identityChanged),window.removeEventListener("cogpit-device-scope-changed",this.identityChanged),this.setHealth({...this.health,transport:"closed",freshness:"stale"}),nf.get(this.key)===this&&nf.delete(this.key)}}function eb(n,e={}){const t=Af(n),s=JSON.stringify([cn(),Zn(),t]);let r=nf.get(s);r||(r=new ite(s,t),nf.set(s,r));const o=r.add(e);return{source:o,close:()=>o.close(),state:()=>r.health}}function Vc({className:n,children:e,...t}){return a.jsxs($$,{"data-slot":"scroll-area",className:G("relative overflow-hidden",n),...t,children:[a.jsx(R$,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:e}),a.jsx(ate,{}),a.jsx(O$,{})]})}function ate({className:n,orientation:e="vertical",...t}){return a.jsx(L$,{"data-slot":"scroll-area-scrollbar","data-orientation":e,orientation:e,className:G("flex touch-none p-px transition-colors select-none data-[orientation=horizontal]:h-2.5 data-[orientation=horizontal]:flex-col data-[orientation=horizontal]:border-t data-[orientation=horizontal]:border-t-transparent data-[orientation=vertical]:h-full data-[orientation=vertical]:w-2.5 data-[orientation=vertical]:border-l data-[orientation=vertical]:border-l-transparent",n),...t,children:a.jsx(M$,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}function nT({className:n,...e}){return a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",className:G("status-icon-spin size-5",n),...e,children:[a.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.2"}),a.jsx("path",{d:"M12 2A10 10 0 0 1 22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function lte({className:n,...e}){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:G("size-5",n),...e,children:a.jsx("path",{className:"status-icon-complete",d:"M20 6L9 17L4 12"})})}function cte({className:n,...e}){return a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:G("size-5",n),...e,children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function ute({className:n,...e}){return a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",className:G("status-icon-spin size-5",n),...e,children:[a.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.1"}),a.jsx("path",{d:"M12 2A10 10 0 0 1 22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),a.jsx("path",{d:"M12 22A10 10 0 0 1 2 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function Pn({className:n,...e}){const t=n==null?void 0:n.replace(/\banimate-spin\b/g,"").trim();return a.jsx(nT,{className:G(t),...e})}function dte(n){const e=Nn("hostFiles"),[t,s]=y.useState([]),[r,o]=y.useState(!1),i=y.useCallback(async()=>{if(!e||!n){s([]);return}o(!0);try{const l=await Ce(`/api/scripts?dir=${encodeURIComponent(n)}`);if(l.ok){const c=await l.json();s(c)}}catch{}finally{o(!1)}},[e,n]);return y.useEffect(()=>{i()},[i]),{scripts:t,loading:r,refresh:i}}const gk=500,fte=5e3;function mte(n){const e=V.c(29),t=n===void 0?!0:n,[s,r]=y.useState("disconnected");let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[0]=o):o=e[0];const[i,l]=y.useState(o),c=y.useRef(null);let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u=new Map,e[1]=u):u=e[1];const d=y.useRef(u),f=y.useRef(gk),m=y.useRef(null),p=y.useRef(!1),h=y.useRef(pte);let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=F=>{var D;const U=F.type,O=F.id;if(U==="sessions"){l(F.sessions??[]);return}O&&((D=d.current.get(O))==null||D(U,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}${Q4()}/__pty`},U=function(){if(p.current||c.current&&c.current.readyState!==WebSocket.CLOSED)return;r("connecting");const D=new WebSocket(F());c.current=D,D.onopen=()=>{if(p.current){D.close();return}f.current=gk,r("connected"),D.send(JSON.stringify({type:"list"}))},D.onmessage=B=>{try{const q=JSON.parse(B.data);x(q)}catch{}},D.onclose=()=>{if(p.current)return;r("disconnected"),c.current=null;const B=f.current;f.current=Math.min(B*2,fte),m.current=setTimeout(()=>h.current(),B)}};return h.current=U,U(),()=>{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 U=c.current;U&&U.readyState===WebSocket.OPEN&&U.send(JSON.stringify(F))},e[6]=t,e[7]=v):v=e[7];const j=v;let k;e[8]===Symbol.for("react.memo_cache_sentinel")?(k=(F,U)=>{d.current.set(F,U)},e[8]=k):k=e[8];const _=k;let N;e[9]===Symbol.for("react.memo_cache_sentinel")?(N=F=>{d.current.delete(F)},e[9]=N):N=e[9];const S=N;let C;e[10]!==j?(C=F=>{const U=F===void 0?{}:F,O=`pty_${crypto.randomUUID().slice(0,8)}`;return j({type:"spawn",id:O,name:U.name??"Terminal",cwd:U.cwd,metadata:{type:"terminal"}}),O},e[10]=j,e[11]=C):C=e[11];const E=C;let T;e[12]!==j?(T=F=>{const U=`script_${crypto.randomUUID().slice(0,8)}`;return j({type:"spawn",id:U,name:F.name,cwd:F.cwd,args:["run",F.scriptName],command:"bun",metadata:{type:"script",source:F.source,scriptName:F.scriptName}}),U},e[12]=j,e[13]=T):T=e[13];const $=T;let A;e[14]!==j?(A=F=>{j({type:"kill",id:F})},e[14]=j,e[15]=A):A=e[15];const R=A;let P;e[16]!==j?(P=(F,U)=>{j({type:"input",id:F,data:U})},e[16]=j,e[17]=P):P=e[17];const z=P;let L;e[18]!==j?(L=(F,U,O)=>{j({type:"resize",id:F,cols:U,rows:O})},e[18]=j,e[19]=L):L=e[19];const I=L;let M;return e[20]!==R||e[21]!==I||e[22]!==j||e[23]!==i||e[24]!==$||e[25]!==E||e[26]!==s||e[27]!==z?(M={status:s,send:j,subscribe:_,unsubscribe:S,sessions:i,spawnTerminal:E,spawnScript:$,killSession:R,writeInput:z,resize:I},e[20]=R,e[21]=I,e[22]=j,e[23]=i,e[24]=$,e[25]=E,e[26]=s,e[27]=z,e[28]=M):M=e[28],M}function pte(){}const sT=y.createContext(null);function _h(n){const e=V.c(3),{children:t,enabled:s}=n,o=mte(s===void 0?!0:s);let i;return e[0]!==t||e[1]!==o?(i=a.jsx(sT.Provider,{value:o,children:t}),e[0]=t,e[1]=o,e[2]=i):i=e[2],i}function tb(){const n=y.useContext(sT);if(!n)throw new Error("usePty must be used within a PtyProvider");return n}function hte(n){var d;const e=V.c(11),t=tb();let s;if(e[0]!==t.sessions){s=new Map;for(const f of t.sessions)((d=f.metadata)==null?void 0:d.type)==="script"&&s.set(f.id,{id:f.id,name:f.name,cwd:f.cwd,status:f.status==="running"?"running":"stopped",source:f.metadata.source??"root/"});e[0]=t.sessions,e[1]=s}else s=e[1];const r=s;let o;e[2]!==n||e[3]!==t?(o=(f,m,p)=>{const h=t.spawnScript({name:f,cwd:m,source:p,scriptName:f}),g=p==="root/"?f:`${p.replace(/\/$/,"")}:${f}`;n==null||n({id:h,name:g,type:"script",status:"running",source:p})},e[2]=n,e[3]=t,e[4]=o):o=e[4];const i=o;let l;e[5]!==t?(l=f=>{t.killSession(f)},e[5]=t,e[6]=l):l=e[6];const c=l;let u;return e[7]!==i||e[8]!==r||e[9]!==c?(u={runningProcesses:r,runScript:i,stopScript:c},e[7]=i,e[8]=r,e[9]=c,e[10]=u):u=e[10],u}function gte(n){const e=V.c(14),{script:t,status:s,onRun:r,onStop:o}=n,i=s==="running";let l="bg-transparent";i?l="bg-primary":s==="errored"&&(l="bg-destructive");const c=i?o:r,u=i?`Stop ${t.name}`:`Run: ${t.command}`;let d;e[0]!==l?(d=G("size-1.5 shrink-0 rounded-full",l),e[0]=l,e[1]=d):d=e[1];let f;e[2]!==d?(f=a.jsx("span",{className:d}),e[2]=d,e[3]=f):f=e[3];let m;e[4]!==t.name?(m=a.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:t.name}),e[4]=t.name,e[5]=m):m=e[5];let p;e[6]!==i?(p=i?a.jsx(ox,{"data-icon":"inline-end",className:"fill-current text-destructive"}):a.jsx(Na,{"data-icon":"inline-end",className:"opacity-0 text-muted-foreground transition-opacity group-hover:opacity-100"}),e[6]=i,e[7]=p):p=e[7];let h;return e[8]!==c||e[9]!==u||e[10]!==f||e[11]!==m||e[12]!==p?(h=a.jsxs(Q,{type:"button",variant:"ghost",size:"sm",className:"motion-list-item group w-full justify-start px-2",onClick:c,title:u,children:[f,m,p]}),e[8]=c,e[9]=u,e[10]=f,e[11]=m,e[12]=p,e[13]=h):h=e[13],h}const xte=y.memo(function(e){const t=V.c(42),{projectDir:s,onProcessStarted:r}=e,[o,i]=y.useState(!1),[l,c]=y.useState("");let u;t[0]===Symbol.for("react.memo_cache_sentinel")?(u=new Set,t[0]=u):u=t[0];const[d,f]=y.useState(u),{scripts:m,loading:p}=dte(s),{runningProcesses:h,runScript:g,stopScript:x}=hte(r);let b;if(t[1]!==m||t[2]!==l){const U=l.trim().toLowerCase(),O=U?m.filter(D=>D.name.toLowerCase().includes(U)||D.dirLabel.toLowerCase().includes(U)):m;b=new Map;for(const D of O){const B=b.get(D.dirLabel)??[];B.push(D),b.set(D.dirLabel,B)}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[U,O]of h)v.set(`${O.name}:${O.cwd}`,{id:U,status:O.status});t[4]=h,t[5]=v}else v=t[5];const j=v;if(!s||!p&&m.length===0)return null;let k;t[6]===Symbol.for("react.memo_cache_sentinel")?(k=function(O){f(D=>{const B=new Set(D);return B.has(O)?B.delete(O):B.add(O),B})},t[6]=k):k=t[6];const _=k;let N;t[7]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx("span",{className:"flex-1 text-xs font-medium text-muted-foreground",children:"Scripts"}),t[7]=N):N=t[7];let S;t[8]!==p?(S=p&&a.jsx(Pn,{className:"size-3 text-muted-foreground","aria-label":"Loading scripts"}),t[8]=p,t[9]=S):S=t[9];const C=o?"Close script search":"Search scripts";let E,T;t[10]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{i(bte),c("")},T=a.jsx(ss,{}),t[10]=E,t[11]=T):(E=t[10],T=t[11]);let $;t[12]!==o||t[13]!==C?($=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm","aria-label":C,"aria-expanded":o,onClick:E,children:T}),t[12]=o,t[13]=C,t[14]=$):$=t[14];let A;t[15]!==S||t[16]!==$?(A=a.jsxs("div",{className:"flex h-8 shrink-0 items-center gap-2 px-2",children:[N,S,$]}),t[15]=S,t[16]=$,t[17]=A):A=t[17];let R;t[18]!==o||t[19]!==l?(R=o&&a.jsx("div",{className:"motion-slide-down-in px-2 pb-2",children:a.jsx(On,{type:"search",value:l,onChange:U=>c(U.target.value),placeholder:"Filter scripts...","aria-label":"Filter scripts",className:"h-7",autoFocus:!0})}),t[18]=o,t[19]=l,t[20]=R):R=t[20];let P;t[21]!==d||t[22]!==w||t[23]!==g||t[24]!==j||t[25]!==l||t[26]!==x?(P=[...w.entries()].map(U=>{const[O,D]=U,B=d.has(O)||!!l,q=D.filter(vte),W=D.filter(yte),H=B?D:q.length>0?q:D.slice(0,1);return a.jsxs("div",{className:"flex flex-col gap-0.5 pb-1",children:[w.size>1&&a.jsx("div",{className:"truncate px-2 pt-1 text-xs text-muted-foreground",children:O}),H.map(K=>{const Z=j.get(`${K.name}:${K.dir}`);return a.jsx(gte,{script:K,status:(Z==null?void 0:Z.status)??null,onRun:()=>g(K.name,K.dir,K.dirLabel),onStop:()=>{Z&&x(Z.id)}},`${O}:${K.name}`)}),!l&&W.length>0&&a.jsx(Q,{type:"button",variant:"link",size:"sm",className:"h-auto justify-start px-2 py-1",onClick:()=>_(O),children:B?"Show less":`Show ${W.length} more`})]},O)}),t[21]=d,t[22]=w,t[23]=g,t[24]=j,t[25]=l,t[26]=x,t[27]=P):P=t[27];let z;t[28]!==w.size||t[29]!==p||t[30]!==l?(z=!p&&w.size===0&&l&&a.jsx(Ln,{className:"gap-1 p-3",children:a.jsxs(Mn,{className:"gap-1",children:[a.jsx(zn,{children:"No matching scripts"}),a.jsx(Dn,{children:"Try another name."})]})}),t[28]=w.size,t[29]=p,t[30]=l,t[31]=z):z=t[31];let L;t[32]!==P||t[33]!==z?(L=a.jsxs(Vc,{className:"min-h-0 flex-1 px-1 pb-1",children:[P,z]}),t[32]=P,t[33]=z,t[34]=L):L=t[34];let I;t[35]!==R||t[36]!==L||t[37]!==A?(I=a.jsxs("section",{className:"flex w-56 shrink-0 flex-col","aria-label":"Scripts",children:[A,R,L]}),t[35]=R,t[36]=L,t[37]=A,t[38]=I):I=t[38];let M;t[39]===Symbol.for("react.memo_cache_sentinel")?(M=a.jsx(en,{orientation:"vertical"}),t[39]=M):M=t[39];let F;return t[40]!==I?(F=a.jsxs(a.Fragment,{children:[I,M]}),t[40]=I,t[41]=F):F=t[41],F});function bte(n){return!n}function vte(n){return n.isCommon}function yte(n){return!n.isCommon}function rT({className:n,orientation:e="horizontal",...t}){return a.jsx(U$,{"data-slot":"tabs","data-orientation":e,className:G("group/tabs relative flex gap-2 data-[orientation=horizontal]:flex-col","has-[>[data-slot=tabs-content]]:grid has-[>[data-slot=tabs-content]]:grid-cols-1 [&>[data-slot=tabs-list]]:col-start-1 [&>[data-slot=tabs-list]]:row-start-1 [&>[data-slot=tabs-content]]:col-start-1 [&>[data-slot=tabs-content]]:row-start-2","data-[orientation=vertical]:has-[>[data-slot=tabs-content]]:grid-cols-[auto_minmax(0,1fr)] data-[orientation=vertical]:[&>[data-slot=tabs-content]]:col-start-2 data-[orientation=vertical]:[&>[data-slot=tabs-content]]:row-start-1",n),...t})}const wte=oo("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 oT({className:n,children:e,variant:t="default",...s}){return a.jsxs(D$,{"data-slot":"tabs-list","data-variant":t,className:G(wte({variant:t}),"relative isolate",n),...s,children:[e,a.jsx(F$,{"data-slot":"tabs-indicator","data-variant":t,className:G("pointer-events-none absolute top-0 left-0 z-0 h-(--active-tab-height) w-(--active-tab-width) translate-x-(--active-tab-left) translate-y-(--active-tab-top) transition-[translate,width,height] duration-150 ease-out motion-reduce:transition-none after:absolute after:content-['']","data-[variant=default]:after:inset-0 data-[variant=default]:after:rounded-md data-[variant=default]:after:bg-background data-[variant=default]:after:shadow-sm","data-[variant=line]:after:bg-foreground data-[variant=line]:data-[orientation=horizontal]:after:inset-x-0 data-[variant=line]:data-[orientation=horizontal]:after:-bottom-[5px] data-[variant=line]:data-[orientation=horizontal]:after:h-0.5 data-[variant=line]:data-[orientation=vertical]:after:inset-y-0 data-[variant=line]:data-[orientation=vertical]:after:-right-1 data-[variant=line]:data-[orientation=vertical]:after:w-0.5")})]})}function hl({className:n,...e}){return a.jsx(B$,{"data-slot":"tabs-trigger",className:G("relative z-10 inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 outline-none transition-[color,border-color,box-shadow,transform,scale] duration-100 ease-out group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground active:scale-[0.98] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-active:text-foreground dark:text-muted-foreground dark:hover:text-foreground dark:data-active:text-foreground motion-reduce:transition-none motion-reduce:active:scale-100 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",n),...e})}function gl({className:n,...e}){return a.jsx(z$,{"data-slot":"tabs-content",className:G("flex-1 text-sm outline-none transition-[opacity,translate] duration-150 ease-out motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none","motion-safe:data-starting-style:data-[activation-direction=left]:translate-x-[-0.25rem] motion-safe:data-starting-style:data-[activation-direction=right]:translate-x-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=left]:translate-x-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=right]:translate-x-[-0.25rem]","motion-safe:data-starting-style:data-[activation-direction=up]:translate-y-[-0.25rem] motion-safe:data-starting-style:data-[activation-direction=down]:translate-y-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=up]:translate-y-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=down]:translate-y-[-0.25rem]",n),...e})}const Ste=y.lazy(()=>nt(()=>import("./TerminalOutput-w6mgZ5a7.js"),__vite__mapDeps([0,1,2,3,4])).then(n=>({default:n.TerminalOutput})));function kte({process:n}){const[e,t]=y.useState(""),[s,r]=y.useState(!1),o=y.useRef(null);return y.useEffect(()=>{if(n.type!=="task"||!n.outputPath)return;t(""),r(!1);const i=eb(`/api/task-output?path=${encodeURIComponent(n.outputPath)}`),l=i.source;return l.onopen=()=>r(!0),l.onmessage=c=>{try{const u=JSON.parse(c.data);if(u.type==="output"&&u.text){const d=HN(u.text);d&&t(f=>{const m=f+d;return m.length>1e5?m.slice(-1e5):m})}}catch{}},i.close},[n.id,n.type,n.outputPath]),y.useEffect(()=>{o.current&&(o.current.scrollTop=o.current.scrollHeight)},[e]),a.jsx("pre",{ref:o,className:"flex-1 overflow-auto bg-background px-3 py-2 font-mono text-xs leading-relaxed text-foreground whitespace-pre-wrap break-words",children:e||a.jsx("span",{className:"text-muted-foreground",children:s?"Waiting for output...":"Connecting..."})})}function jte(n){const e=V.c(34),{process:t,isActive:s,onSelectActive:r,onClose:o,mobile:i}=n,l=t.source??t.name,c=t.id,u=t.name;let d;e[0]!==s||e[1]!==r?(d=()=>{s&&r()},e[0]=s,e[1]=r,e[2]=d):d=e[2];const f=i?"gap-1 px-1.5":"gap-1.5 px-2";let m;e[3]!==f?(m=G("h-6 min-w-0 justify-start py-0 text-xs",f),e[3]=f,e[4]=m):m=e[4];let p;e[5]!==t.status?(p=t.status==="running"&&a.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full bg-success"}),e[5]=t.status,e[6]=p):p=e[6];let h;e[7]!==t.status?(h=t.status==="errored"&&a.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full bg-destructive"}),e[7]=t.status,e[8]=h):h=e[8];let g;e[9]!==t.name?(g=a.jsx("span",{className:"truncate max-w-[100px]",children:t.name}),e[9]=t.name,e[10]=g):g=e[10];const x=i&&"hidden";let b;e[11]!==x?(b=G("px-1 py-0 font-normal",x),e[11]=x,e[12]=b):b=e[12];let w;e[13]!==t.type||e[14]!==b?(w=a.jsx(Fe,{variant:"secondary",className:b,children:t.type}),e[13]=t.type,e[14]=b,e[15]=w):w=e[15];let v;e[16]!==t.id||e[17]!==t.name||e[18]!==w||e[19]!==d||e[20]!==m||e[21]!==p||e[22]!==h||e[23]!==g?(v=a.jsxs(hl,{value:c,"aria-label":u,onClick:d,className:m,children:[p,h,g,w]}),e[16]=t.id,e[17]=t.name,e[18]=w,e[19]=d,e[20]=m,e[21]=p,e[22]=h,e[23]=g,e[24]=v):v=e[24];const j=`Close ${t.name}`,k=`Close ${t.name}`;let _;e[25]===Symbol.for("react.memo_cache_sentinel")?(_=a.jsx(Mt,{"data-icon":"inline-start"}),e[25]=_):_=e[25];let N;e[26]!==o||e[27]!==j||e[28]!==k?(N=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs","aria-label":j,title:k,onClick:o,className:"mr-0.5 text-muted-foreground",children:_}),e[26]=o,e[27]=j,e[28]=k,e[29]=N):N=e[29];let S;return e[30]!==l||e[31]!==v||e[32]!==N?(S=a.jsxs("div",{title:l,className:"inline-flex h-6 shrink-0 items-center",children:[v,N]}),e[30]=l,e[31]=v,e[32]=N,e[33]=S):S=e[33],S}const iT=100,aT=600,Nte=200,lT="process-panel-height";function Cte(){try{const n=localStorage.getItem(lT);if(n)return Math.min(aT,Math.max(iT,Number(n)))}catch{}return Nte}const _te=y.memo(function(e){const t=V.c(89),{processes:s,activeProcessId:r,collapsed:o,onSetActive:i,onRemove:l,onToggleCollapse:c,onRequestTerminal:u,onAddTerminalContext:d,onUpdateStatus:f,projectDir:m,onProcessStarted:p,mobile:h}=e,g=h===void 0?!1:h,x=tb(),[b,w]=y.useState(Cte),v=y.useRef(null);let j,k;t[0]!==f||t[1]!==x.sessions?(j=()=>{for(const ce of x.sessions)ce.status==="exited"&&(f==null||f(ce.id,"stopped"))},k=[x.sessions,f],t[0]=f,t[1]=x.sessions,t[2]=j,t[3]=k):(j=t[2],k=t[3]),y.useEffect(j,k);let _;t[4]!==l||t[5]!==x?(_=ce=>{ce.type!=="task"&&x.killSession(ce.id),l(ce.id)},t[4]=l,t[5]=x,t[6]=_):_=t[6];const N=_;let S;t[7]!==b?(S=ce=>{ce.preventDefault(),v.current={startY:ce.clientY,startH:b},ce.target.setPointerCapture(ce.pointerId)},t[7]=b,t[8]=S):S=t[8];const C=S;let E;t[9]===Symbol.for("react.memo_cache_sentinel")?(E=ce=>{if(!v.current)return;const he=v.current.startY-ce.clientY,ge=Math.min(aT,Math.max(iT,v.current.startH+he));w(ge)},t[9]=E):E=t[9];const T=E;let $;t[10]!==b?($=()=>{if(v.current){v.current=null;try{localStorage.setItem(lT,String(b))}catch{}}},t[10]=b,t[11]=$):$=t[11];const A=$;let R;t[12]!==r||t[13]!==s?(R=r?s.get(r):null,t[12]=r,t[13]=s,t[14]=R):R=t[14];const P=R;let z;t[15]!==s?(z=[...s.values()],t[15]=s,t[16]=z):z=t[16];const L=z;let I;t[17]!==i?(I=ce=>{typeof ce=="string"&&i(ce)},t[17]=i,t[18]=I):I=t[18];let M;t[19]!==P||t[20]!==o||t[21]!==g||t[22]!==C||t[23]!==A?(M=!g&&!o&&P&&a.jsx("div",{className:"h-1 cursor-row-resize transition-colors hover:bg-accent active:bg-muted-foreground/30",onPointerDown:C,onPointerMove:T,onPointerUp:A,onPointerCancel:A}),t[19]=P,t[20]=o,t[21]=g,t[22]=C,t[23]=A,t[24]=M):M=t[24];const F=g?"h-7 gap-1 px-2":"h-8 gap-2 px-3";let U;t[25]!==F?(U=G("flex shrink-0 items-center border-b bg-card",F),t[25]=F,t[26]=U):U=t[26];const O=o?"Expand terminal panel":"Collapse terminal panel",D=!o;let B;t[27]!==o?(B=o?a.jsx(it,{"data-icon":"inline-start"}):a.jsx(_t,{"data-icon":"inline-start"}),t[27]=o,t[28]=B):B=t[28];const q=g&&"sr-only";let W;t[29]!==q?(W=G(q),t[29]=q,t[30]=W):W=t[30];let H;t[31]!==W?(H=a.jsx("span",{className:W,children:"Terminal"}),t[31]=W,t[32]=H):H=t[32];let K;t[33]!==c||t[34]!==O||t[35]!==D||t[36]!==B||t[37]!==H?(K=a.jsxs(Q,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2",onClick:c,"aria-label":O,"aria-expanded":D,children:[B,H]}),t[33]=c,t[34]=O,t[35]=D,t[36]=B,t[37]=H,t[38]=K):K=t[38];const Z=!g&&"ml-2";let Y;t[39]!==Z?(Y=G("min-w-0 flex-1 justify-start overflow-x-auto no-scrollbar",Z),t[39]=Z,t[40]=Y):Y=t[40];let X;t[41]!==r||t[42]!==N||t[43]!==g||t[44]!==i||t[45]!==L?(X=L.map(ce=>a.jsx(jte,{process:ce,isActive:ce.id===r,onSelectActive:()=>i(ce.id),onClose:()=>N(ce),mobile:g},ce.id)),t[41]=r,t[42]=N,t[43]=g,t[44]=i,t[45]=L,t[46]=X):X=t[46];let ee;t[47]!==Y||t[48]!==X?(ee=a.jsx(oT,{variant:"default","aria-label":"Open processes",className:Y,children:X}),t[47]=Y,t[48]=X,t[49]=ee):ee=t[49];let te;t[50]!==u||t[51]!==m?(te=u&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",disabled:!m,onClick:u,"aria-label":"New terminal",title:m?"New terminal":"Open a project to start a terminal",children:a.jsx(Sr,{})}),t[50]=u,t[51]=m,t[52]=te):te=t[52];let se;t[53]!==U||t[54]!==K||t[55]!==ee||t[56]!==te?(se=a.jsxs("div",{className:U,children:[K,ee,te]}),t[53]=U,t[54]=K,t[55]=ee,t[56]=te,t[57]=se):se=t[57];const J=!o,ne=g?"min(36dvh, 260px)":b;let ie;t[58]!==ne?(ie={height:ne},t[58]=ne,t[59]=ie):ie=t[59];let ae;t[60]!==g||t[61]!==p||t[62]!==m?(ae=!g&&a.jsx(xte,{projectDir:m,onProcessStarted:p}),t[60]=g,t[61]=p,t[62]=m,t[63]=ae):ae=t[63];let oe;t[64]!==N||t[65]!==d||t[66]!==u||t[67]!==L?(oe=L.map(ce=>a.jsx(gl,{value:ce.id,className:"col-start-1 row-start-1 flex min-h-0 flex-col",children:ce.type==="task"?a.jsx(kte,{process:ce}):a.jsx(y.Suspense,{fallback:a.jsx("div",{className:"flex size-full items-center justify-center text-xs text-muted-foreground",children:"Loading terminal…"}),children:a.jsx(Ste,{processId:ce.id,autoFocus:!0,onRequestNew:u,onRequestClose:()=>N(ce),onAddContext:d})})},ce.id)),t[64]=N,t[65]=d,t[66]=u,t[67]=L,t[68]=oe):oe=t[68];let ue;t[69]!==P||t[70]!==u||t[71]!==m?(ue=!P&&a.jsxs(Ln,{className:"col-start-1 row-start-1 rounded-none",children:[a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:a.jsx(Ca,{})}),a.jsx(zn,{children:"No terminal open"}),a.jsx(Dn,{children:"Start a terminal here or run a project script from the left."})]}),u&&m&&a.jsx(_c,{children:a.jsxs(Q,{type:"button",size:"sm",onClick:u,children:[a.jsx(Sr,{"data-icon":"inline-start"}),"New terminal"]})})]}),t[69]=P,t[70]=u,t[71]=m,t[72]=ue):ue=t[72];let re;t[73]!==oe||t[74]!==ue?(re=a.jsxs("div",{className:"grid min-h-0 min-w-0 flex-1 grid-cols-1",children:[oe,ue]}),t[73]=oe,t[74]=ue,t[75]=re):re=t[75];let de;t[76]!==ie||t[77]!==ae||t[78]!==re?(de=a.jsx(yn,{children:a.jsxs("div",{className:"flex min-h-0",style:ie,children:[ae,re]})}),t[76]=ie,t[77]=ae,t[78]=re,t[79]=de):de=t[79];let fe;t[80]!==J||t[81]!==de?(fe=a.jsx(vn,{open:J,className:"min-h-0",children:de}),t[80]=J,t[81]=de,t[82]=fe):fe=t[82];let le;return t[83]!==r||t[84]!==I||t[85]!==M||t[86]!==se||t[87]!==fe?(le=a.jsxs(rT,{value:r,onValueChange:I,className:"shrink-0 gap-0 border-t bg-background",children:[M,se,fe]}),t[83]=r,t[84]=I,t[85]=M,t[86]=se,t[87]=fe,t[88]=le):le=t[88],le});function Hc(n){const e=V.c(2),{children:t}=n;let s;return e[0]!==t?(s=a.jsx("h3",{className:"mb-3 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:t}),e[0]=t,e[1]=s):s=e[1],s}const Ete=/(?::(\d{4,5}))|(?:port\s+(\d{4,5}))|(?:localhost:(\d{4,5}))/gi;function Tte(n){const e=new Set;for(const t of n.matchAll(Ete)){const s=parseInt(t[1]||t[2]||t[3],10);s>0&&s<65536&&e.add(s)}return[...e]}function Ate(n){var s;const e=V.c(2);let t;if(e[0]!==n){t=new Map;for(let r=0;r<n.length;r++)for(const o of n[r].toolCalls){if(o.name!=="Bash"||!o.input.run_in_background)continue;const i=o.input.command||"",l=o.input.description||"",c=((s=n[r].assistantText)==null?void 0:s.join(" "))||"",u=[i,l,o.result||"",c].join(" "),d=Tte(u);if(d.length===0){const p=i.toLowerCase();(p.includes("run dev")||p.includes("next dev")||p.includes("vite"))&&d.push(3e3)}const f=(o.result||"").match(/Output is being written to:\s*(\S+)/),m=f?f[1]:null;for(const p of d)t.set(p,{description:l||i.replace(/^cd\s+"[^"]*"\s*&&\s*/,"").slice(0,60),outputPath:m})}e[0]=n,e[1]=t}else t=e[1];return t}function xk(n){var e;return((e=n.preview.split(`
334
+ `)||t.length>c.length,e[2]=t,e[3]=c,e[4]=u):u=e[4];const d=u;let f;e[5]!==t?(f=async()=>{try{await navigator.clipboard.writeText(t),i(!0),setTimeout(()=>i(!1),1500)}catch{}},e[5]=t,e[6]=f):f=e[6];const m=f;let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=()=>r(!0),e[7]=p):p=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx(wr,{"data-icon":"inline-start"}),e[8]=h):h=e[8];let g;e[9]!==c?(g=a.jsx("span",{className:"truncate",children:c}),e[9]=c,e[10]=g):g=e[10];let x;e[11]!==d?(x=d&&a.jsx("span",{className:"shrink-0 opacity-60",children:"(details)"}),e[11]=d,e[12]=x):x=e[12];let b;e[13]!==g||e[14]!==x?(b=a.jsxs(Q,{type:"button",variant:"ghost",size:"sm",onClick:p,title:"Click to view the full error",className:"motion-enter mt-1 w-full justify-start text-destructive",children:[h,g,x]}),e[13]=g,e[14]=x,e[15]=b):b=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=a.jsxs(io,{children:[a.jsxs(rr,{className:"flex items-center gap-2 text-destructive",children:[a.jsx(wr,{className:"size-4"}),"Error details"]}),a.jsx(or,{children:"The full output from the failed request, including the underlying process stderr."})]}),e[16]=w):w=e[16];let v;e[17]!==t?(v=a.jsx("pre",{className:"max-h-[50vh] select-text overflow-auto whitespace-pre-wrap break-words rounded-md border bg-muted/30 p-3 font-mono text-xs text-destructive",children:t}),e[17]=t,e[18]=v):v=e[18];let j;e[19]!==o?(j=o?a.jsx(nn,{"data-icon":"inline-start"}):a.jsx(Es,{"data-icon":"inline-start"}),e[19]=o,e[20]=j):j=e[20];const k=o?"Copied":"Copy";let _;e[21]!==m||e[22]!==j||e[23]!==k?(_=a.jsx("div",{className:"flex justify-end",children:a.jsxs(Q,{type:"button",variant:"outline",size:"sm",onClick:m,children:[j,k]})}),e[21]=m,e[22]=j,e[23]=k,e[24]=_):_=e[24];let N;e[25]!==v||e[26]!==_?(N=a.jsxs(sr,{className:"max-w-2xl",children:[w,v,_]}),e[25]=v,e[26]=_,e[27]=N):N=e[27];let S;e[28]!==s||e[29]!==N?(S=a.jsx(nr,{open:s,onOpenChange:r,children:N}),e[28]=s,e[29]=N,e[30]=S):S=e[30];let C;return e[31]!==S||e[32]!==b?(C=a.jsxs(a.Fragment,{children:[b,S]}),e[31]=S,e[32]=b,e[33]=C):C=e[33],C}function iee(n){const e=V.c(17),{suggestion:t,onAccept:s}=n,[r,o]=y.useState(null);if(!t||t===r)return null;let i;e[0]!==s||e[1]!==t?(i=()=>{o(t),s(t)},e[0]=s,e[1]=t,e[2]=i):i=e[2];let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(ql,{"data-icon":"inline-start"}),e[3]=l):l=e[3];let c;e[4]!==t?(c=a.jsx("span",{className:"truncate",children:t}),e[4]=t,e[5]=c):c=e[5];let u;e[6]!==i||e[7]!==c?(u=a.jsxs(Q,{type:"button",variant:"ghost",size:"sm",title:"Put this in the composer",onClick:i,className:"min-w-0 flex-1 justify-start text-muted-foreground",children:[l,c]}),e[6]=i,e[7]=c,e[8]=u):u=e[8];let d;e[9]!==t?(d=()=>o(t),e[9]=t,e[10]=d):d=e[10];let f;e[11]===Symbol.for("react.memo_cache_sentinel")?(f=a.jsx(Mt,{}),e[11]=f):f=e[11];let m;e[12]!==d?(m=a.jsx(Q,{type:"button",variant:"ghost",size:"icon","aria-label":"Dismiss suggestion",onClick:d,className:"shrink-0 text-muted-foreground",children:f}),e[12]=d,e[13]=m):m=e[13];let p;return e[14]!==u||e[15]!==m?(p=a.jsxs("div",{className:"motion-enter mb-1 flex items-center gap-1",children:[u,m]}),e[14]=u,e[15]=m,e[16]=p):p=e[16],p}function aee(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 lee(n,e,t){return`${n.slice(0,e.start)}@${t} `}function Nn(n){const e=V.c(3);let t,s;return e[0]!==n?(t=()=>xt(n),s=()=>xt(n),e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]),y.useSyncExternalStore(Rf,t,s)}function cee(n){const e=n.files;return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function uee(n,e,t){const s=Nn("hostFiles"),[r,o]=y.useState([]),[i,l]=y.useState(!1);return y.useEffect(()=>{if(!s||!t||!n){o([]),l(!1);return}const c=new AbortController,u=window.setTimeout(async()=>{l(!0);try{const d=await Ce(`/api/project-files?cwd=${encodeURIComponent(n)}&q=${encodeURIComponent(e)}&limit=30`,{signal:c.signal});if(!d.ok)throw new Error(`Request failed (${d.status})`);const f=await d.json();c.signal.aborted||o(cee(f))}catch{c.signal.aborted||o([])}finally{c.signal.aborted||l(!1)}},120);return()=>{window.clearTimeout(u),c.abort()}},[s,n,t,e]),{files:r,loading:i}}const p1="cogpit-share-revoked";function dee(){window.dispatchEvent(new Event(p1))}async function VE(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&&dee(),s}function Bc(n,e){return VE(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e??{})})}async function fee(){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 mee(n,e){return Bc("/api/share/send-message",e!=null&&e.length?{message:n,images:e}:{message:n})}function pee(){return Bc("/api/share/interrupt")}function hee(){return Bc("/api/share/stop")}async function gee(n,e){return(await Bc("/api/share/permission",{requestId:n,behavior:e})).ok}async function xee(n,e){try{const t=await Bc("/api/share/answer",{toolUseId:n,answers:e});return{ok:t.ok,gone:t.status===404}}catch{return{ok:!1,gone:!1}}}async function bee(){try{const n=await VE("/api/share/pending");if(!n.ok)return null;const e=await n.json();return Array.isArray(e.permissions)?e.permissions:[]}catch{return null}}const vee=/^\/shared\/([^/]+)\/?$/;function HE(n){const e=vee.exec(n);if(!e)return null;try{return decodeURIComponent(e[1])||null}catch{return null}}function lm(n){return HE(n)!==null}function yee(n){return`/shared/${encodeURIComponent(n)}`}async function KE(n,e,t){const s=typeof e.commandId=="string"?e.commandId:crypto.randomUUID(),r={...e,commandId:s};for(let o=0;;o++)try{const i=await(t?Ce(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r),signal:t}):is(n,r));return i.ok&&window.dispatchEvent(new CustomEvent("cogpit-command-accepted",{detail:{commandId:s,sessionId:e.sessionId}})),i}catch(i){if(i instanceof Error&&i.name==="AbortError")throw i;if(t!=null&&t.aborted||o>=1)throw new Error(`Delivery could not be confirmed. Your draft is retained. Check receipt ${s} before sending again.`,{cause:i})}}function wee(n){return[...n].join(", ")}async function GE(n,e){try{const t=await is(n,e);return{ok:t.ok,gone:t.status===404}}catch{return{ok:!1,gone:!1}}}function J0(n,e,t){return lm(window.location.pathname)?xee(e,t):KE("/api/ask-user-answer",{sessionId:n,toolUseId:e,answers:t}).then(s=>({ok:s.ok,gone:s.status===404}),()=>({ok:!1,gone:!1}))}async function See(n,e,t){try{return(await is(`/api/permissions/${encodeURIComponent(n)}/plan`,{requestId:e,...t})).ok}catch{return!1}}function Wc(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-background px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("textarea",{"data-slot":"textarea",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Ou(n,e){if(!n)return!1;const t=n.offsetHeight;n.style.transition="none",n.style.height="auto";const s=Math.min(n.scrollHeight,200);let r;if(e){const i=n.style.width;n.style.width=`${Math.max(100,n.offsetWidth-140)}px`,r=n.scrollHeight>48,n.style.width=i}else r=s>44;return t!==s&&(n.style.height=t+"px",n.offsetHeight,n.style.transition="height 150ms ease"),n.style.height=s+"px",r}function kee(n,e,t,s,r,o){return s?"Resolve approval to continue...":n?"Provide feedback to request changes...":e?"Type a custom response...":o?r?"Steer…":"Message…":r?"Steer the active turn… (Enter to send)":t?"Message... (Enter to send)":"Send a message... (Enter to send)"}function jee(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 Nee(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 Cee(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 h1=y.memo(y.forwardRef(function({allowImages:e=!0,agentKind:t,projectCwd:s,leadingAccessory:r,footer:o,compact:i=!1},l){var He;const c=Nn("hostFiles"),{session:u,isLive:d,actions:{handleEditConfig:f},pendingInteraction:m,permissionRequests:p,permissionResponding:h,respondPermission:g,respondAllPermissions:x,slashSuggestions:b,slashSuggestionsLoading:w,turnError:v,promptSuggestion:j}=kt(),{chat:{status:k,error:_,isConnected:N,sendMessage:S,interrupt:C}}=Wf(),E=N||d,[T,$]=y.useState(""),[A,R]=y.useState(!1),[P,z]=y.useState(!1),[L,I]=y.useState(null),M=y.useRef(null),F=y.useRef(null),U=y.useRef(!1),O=y.useRef(""),D=y.useRef(null);y.useEffect(()=>{O.current=T},[T]);const B=y.useCallback(me=>{U.current=me,R(me)},[]),{images:q,isDragOver:W,imageError:H,hasUnsupportedAttachments:K,dismissImageError:Z,removeImage:Y,clearImages:X,restoreImages:ee,handleDragOver:te,handleDragLeave:se,handleDrop:J,handlePaste:ne}=Bz(e),ie=y.useRef(q);y.useEffect(()=>{ie.current=q},[q]);const ae=(u==null?void 0:u.sessionId)??null,oe=y.useRef(null),ue=y.useRef(null);y.useEffect(()=>{const me=()=>O.current.trim()!==""||ie.current.length>0;oe.current={sessionId:ae};const je=ae&&!me()?Hz(ae):void 0;return je&&(ue.current=ae,O.current=je.text,ie.current=je.images,$(je.text),ee(je.images)),()=>{oe.current=null,ae&&ue.current===ae&&me()&&(f2(ae,{text:O.current,images:ie.current}),O.current="",ie.current=[],$(""),X()),ue.current=null}},[ae,ee,X]);const[re,de]=y.useState(0),[fe,le]=y.useState(0),[ce,he]=y.useState(!1),ge=T.startsWith("/")&&!T.includes(" "),be=ge?T.slice(1):"",ve=y.useMemo(()=>{if(!ge)return[];const me=be.toLowerCase(),je=b.filter(dt=>me?dt.name.toLowerCase().includes(me)||dt.description.toLowerCase().includes(me):!0),Xe=je.filter(dt=>dt.type==="command"),tt=je.filter(dt=>dt.type==="skill");return[...Xe,...tt]},[ge,be,b]),Se=y.useMemo(()=>aee(T),[T]),we=!!(c&&Se&&s&&!ce),Ee=uee(s,(Se==null?void 0:Se.query)??"",we);y.useEffect(()=>{de(0)},[be]),y.useEffect(()=>{le(0)},[Se==null?void 0:Se.query]);const $e=(m==null?void 0:m.type)==="plan"?m.requestId??null:null;y.useEffect(()=>{F.current=$e,M.current=null,z(!1),I(null)},[$e]);const Be=y.useCallback(async me=>{const je=m;if(!(u!=null&&u.sessionId)||(je==null?void 0:je.type)!=="question")return;const Xe=je.questions[0];if(!Xe||!me.trim())return;(await J0(u.sessionId,je.toolUseId,{[Xe.question]:me})).ok||S(me)},[m,u==null?void 0:u.sessionId,S]),qe=y.useCallback(async(me,je,Xe)=>{const tt=m;if((tt==null?void 0:tt.type)==="plan"&&tt.provider==="copilot"&&tt.requestId&&(u!=null&&u.sessionId)){const dt=tt.requestId;if(M.current)return!1;M.current=dt,z(!0),I(null);try{const zt=await See(u.sessionId,dt,{approved:me,...je?{selectedAction:je}:{},...Xe?{feedback:Xe}:{}});return!zt&&F.current===dt&&I("Couldn't send the plan response. Try again."),zt}finally{M.current===dt&&(M.current=null,z(!1))}}return S(me?"yes":Xe||"no"),!0},[m,u==null?void 0:u.sessionId,S]),ze=y.useCallback(()=>{requestAnimationFrame(()=>{const me=D.current;me&&(me.focus(),me.selectionStart=me.selectionEnd=me.value.length,B(Ou(me,U.current)))})},[B]),Ie=y.useCallback(me=>{$(`/${me.name} `),de(0),ze()},[ze]),Me=y.useCallback(me=>{$(me),ze()},[ze]),Ue=y.useCallback(me=>{if(!Se)return;const je=lee(T,Se,me);$(je),he(!0),le(0),requestAnimationFrame(()=>{const Xe=D.current;Xe&&(Xe.focus(),Xe.selectionStart=Xe.selectionEnd=Xe.value.length,B(Ou(Xe,U.current)))})},[Se,T,B]),De=y.useCallback(async()=>{const me=T.trim();if(!me&&q.length===0||!e&&q.length>0)return;if((m==null?void 0:m.type)==="question"){Be(me),$(""),B(!1),D.current&&(D.current.style.height="auto");return}if((m==null?void 0:m.type)==="plan"&&m.provider==="copilot"){if(!me||!await qe(!1,void 0,me))return;$(""),B(!1),D.current&&(D.current.style.height="auto");return}const je=e&&q.length>0?q.map(tt=>({data:tt.data,mediaType:tt.mediaType})):void 0,Xe={text:T,images:q};ue.current=null,S(me,je).then(tt=>{var dt;if(!tt){if(((dt=oe.current)==null?void 0:dt.sessionId)!==ae){ae&&f2(ae,Xe);return}ue.current=ae,$(zt=>zt||Xe.text),ee(Xe.images)}}),$(""),X(),B(!1),D.current&&(D.current.style.height="auto")},[T,q,e,S,X,ee,B,m,Be,qe,ae]),Ke=y.useCallback(me=>{if(we&&me.key==="Escape"){me.preventDefault(),he(!0);return}if(we&&Ee.files.length>0){if(me.key==="ArrowDown"){me.preventDefault(),le(je=>je<Ee.files.length-1?je+1:0);return}if(me.key==="ArrowUp"){me.preventDefault(),le(je=>je>0?je-1:Ee.files.length-1);return}if(me.key==="Tab"||me.key==="Enter"&&!me.shiftKey){me.preventDefault();const je=Ee.files[fe];je&&Ue(je);return}}if(ge&&ve.length>0){if(me.key==="ArrowDown"){me.preventDefault(),de(je=>je<ve.length-1?je+1:0);return}if(me.key==="ArrowUp"){me.preventDefault(),de(je=>je>0?je-1:ve.length-1);return}if(me.key==="Tab"||me.key==="Enter"&&!me.shiftKey){me.preventDefault();const je=ve[re];je&&Ie(je);return}if(me.key==="Escape"){me.preventDefault(),$("");return}}if(me.key==="Escape"&&E&&C){me.preventDefault(),C();return}me.key==="Enter"&&!me.shiftKey&&(me.preventDefault(),De())},[De,E,C,we,Ee.files,fe,Ue,ge,ve,re,Ie]),Ne=y.useCallback(me=>{$(me.target.value),he(!1),B(Ou(me.target,U.current))},[B]);y.useImperativeHandle(l,()=>({focus:()=>{var me;return(me=D.current)==null?void 0:me.focus()},getText:()=>O.current,setText:me=>{$(me),he(!1),requestAnimationFrame(()=>B(Ou(D.current,U.current)))}}),[B]);const Ae=(m==null?void 0:m.type)==="plan",Qe=(m==null?void 0:m.type)==="question",Je=p.length>0,ke=!!o,We=(T.trim().length>0||q.length>0)&&!K,ye=bn(t??Wo).midTurnSteering&&E,Re=we?"file-suggestions":ge?"slash-suggestions":void 0,Ve=we&&Ee.files[fe]?`file-suggestion-${fe}`:ge&&ve[re]?`slash-suggestion-${re}`:void 0;return a.jsxs("div",{className:G("relative pb-0",i?"px-2 pt-2":"px-3 pt-2",W&&"ring-2 ring-info/40 ring-inset"),onDragOver:te,onDragLeave:se,onDrop:J,children:[W&&a.jsx("div",{className:"motion-enter pointer-events-none absolute inset-0 flex items-center justify-center rounded-lg border-2 border-dashed border-info/40 bg-info/10",children:a.jsx("span",{className:"text-sm font-medium text-info",children:"Drop images here"})}),ge&&a.jsx(Ez,{suggestions:ve,filter:be,loading:w,selectedIndex:re,onSelect:Ie,onHover:de,onEdit:f}),we&&a.jsx(Pz,{files:Ee.files,query:(Se==null?void 0:Se.query)??"",loading:Ee.loading,selectedIndex:fe,onSelect:Ue,onHover:le}),a.jsxs("div",{children:[Ae&&a.jsx(I5,{allowedPrompts:m.allowedPrompts,summary:m.summary,planContent:m.planContent,actions:m.actions,recommendedAction:m.recommendedAction,responding:P,responseError:L,onApprove:me=>{qe(!0,me)},onReject:()=>{qe(!1)}}),a.jsx(iee,{suggestion:j,onAccept:Me}),q.length>0&&a.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:q.map((me,je)=>a.jsxs("div",{className:"motion-list-item relative group/thumb",children:[a.jsx("img",{src:me.preview,alt:`Upload ${je+1}`,className:"h-16 w-auto rounded-md border bg-muted object-contain"}),a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>Y(je),className:"absolute -right-1.5 -top-1.5 size-5 rounded-full border bg-popover p-0 text-muted-foreground opacity-100 hover:bg-destructive hover:text-destructive-foreground sm:opacity-0 sm:group-hover/thumb:opacity-100 sm:focus-visible:opacity-100","aria-label":`Remove image ${je+1}`,children:a.jsx(Mt,{className:"size-3","data-icon":"icon"})})]},me.id))}),H&&a.jsxs("div",{role:"status","aria-live":"polite",className:"motion-enter mb-2 flex items-center gap-2 text-xs text-warning",children:[a.jsx("span",{className:"flex-1",children:H}),!K&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:Z,className:"text-muted-foreground","aria-label":"Dismiss image notice",children:a.jsx(Mt,{"data-icon":"icon"})})]}),a.jsxs("div",{className:G("relative overflow-hidden border bg-popover shadow-lg shadow-black/5 transition-[border-color,box-shadow] duration-150",ke?"rounded-3xl":"rounded-xl",jee(Ae,Qe,Je),"focus-within:ring-3"),children:[Je&&a.jsx(P5,{requests:p,responding:h,onRespond:g,onRespondAll:x},(He=p[0])==null?void 0:He.requestId),a.jsxs("div",{className:G("min-w-0",ke?"flex flex-col":"grid items-end",!ke&&(A?"grid-cols-[1fr_auto]":"grid-cols-[auto_minmax(0,1fr)_auto]")),children:[r&&a.jsx("div",{className:G("flex shrink-0 items-center",A?"col-start-1 row-start-2 pl-0.5 pb-0.5":"col-start-1 row-start-1"),children:r}),a.jsx(Wc,{ref:D,value:T,onChange:Ne,onKeyDown:Ke,onPaste:ne,onFocus:()=>{setTimeout(()=>{var me;return(me=D.current)==null?void 0:me.scrollIntoView({behavior:"smooth",block:"center"})},300)},placeholder:kee(Ae,Qe,N,Je,ye,i),"aria-label":"Message",role:"combobox","aria-autocomplete":"list","aria-expanded":!!Re,"aria-controls":Re,"aria-activedescendant":Ve,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",Nee(ke,A,i))}),a.jsxs("div",{className:G("flex shrink-0 items-center justify-end",Cee(ke,A)),children:[o,a.jsx(ree,{}),a.jsx(Gz,{hasContent:We,onSubmit:De,submitLabel:ye?"Steer active turn":"Send message"})]})]})]}),k==="error"&&_&&a.jsx(mk,{error:_},_),v&&a.jsx(mk,{error:v},v)]})]})}));function _ee(n){for(let e=n.length-1;e>=0;e-=1){const t=n[e];if(t.type!=="attachment")continue;const s=$9(t.attachment);if((s==null?void 0:s.type)!=="goal_status")continue;const r=typeof s.condition=="string"?s.condition:"",o=s.met===!0,i=s.failed===!0;return s.sentinel===!0&&o||!r?null:{condition:r,status:i?"failed":o?"achieved":"active",reason:typeof s.reason=="string"?s.reason:void 0,iterations:typeof s.iterations=="number"?s.iterations:0,durationMs:typeof s.durationMs=="number"?s.durationMs:0,tokens:typeof s.tokens=="number"?s.tokens:0}}return null}function Lu(n){return`/api/codex/goals/${encodeURIComponent(n)}`}function qc(n){const e=V.c(13);let t,s,r,o;e[0]!==n?({className:s,children:t,value:o,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);let i;e[5]!==s?(i=G("flex flex-wrap gap-3",s),e[5]=s,e[6]=i):i=e[6];let l;e[7]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(Eee,{children:a.jsx(Tee,{})}),e[7]=l):l=e[7];let c;return e[8]!==t||e[9]!==r||e[10]!==i||e[11]!==o?(c=a.jsxs(j$,{value:o,"data-slot":"progress",className:i,...r,children:[t,l]}),e[8]=t,e[9]=r,e[10]=i,e[11]=o,e[12]=c):c=e[12],c}function Eee(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("relative flex h-1 w-full items-center overflow-x-hidden rounded-full bg-muted",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(N$,{className:r,"data-slot":"progress-track",...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Tee(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("h-full bg-primary transition-[width] duration-150 ease-out motion-reduce:transition-none",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(C$,{"data-slot":"progress-indicator",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function ZE(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-sm font-medium",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(_$,{className:r,"data-slot":"progress-label",...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function YE(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("ml-auto text-sm text-muted-foreground tabular-nums",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(E$,{className:r,"data-slot":"progress-value",...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}const Aee={section:null,canCreate:!1,beginEditing:()=>{}},Q0=y.createContext(Aee);function XE(){return y.useContext(Q0)}const JE="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-1",QE="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-2";function Iee(n){return n==="usageLimited"?"Usage limited":n==="budgetLimited"?"Budget limited":n.charAt(0).toUpperCase()+n.slice(1)}function Pee(n){return n==="complete"?"secondary":n==="blocked"||n.endsWith("Limited")?"destructive":n==="paused"?"outline":"default"}function $ee({agentKind:n,threadId:e,children:t}){const s=Bf(n),[r,o]=y.useState(null),[i,l]=y.useState(!0),[c,u]=y.useState(!1),[d,f]=y.useState(""),[m,p]=y.useState(""),[h,g]=y.useState(!1),[x,b]=y.useState(null),w=y.useCallback(async E=>{try{const T=await Ce(Lu(e),{signal:E});if(T.status===404||T.status===501){l(!1);return}if(!T.ok)return;const $=await T.json();o($.goal),l(!0)}catch{}},[e]);y.useEffect(()=>{const E=new AbortController;w(E.signal);const T=i?setInterval(()=>void w(),1e4):void 0;return()=>{E.abort(),T!==void 0&&clearInterval(T)}},[w,i]);const v=y.useCallback(()=>{var E;f((r==null?void 0:r.objective)??""),p(((E=r==null?void 0:r.tokenBudget)==null?void 0:E.toString())??""),b(null),u(!0)},[r]),j=async()=>{const E=d.trim();if(!E)return;const T=m.trim()?Number(m):null;if(T!==null&&(!Number.isSafeInteger(T)||T<=0)){b("Token budget must be a positive whole number");return}g(!0),b(null);try{const $=await Ce(Lu(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({objective:E,status:(r==null?void 0:r.status)==="complete"?"active":(r==null?void 0:r.status)??"active",tokenBudget:T})}),A=await $.json();if(!$.ok)throw new Error(A.error||"Could not save goal");o(A.goal),u(!1)}catch($){b($ instanceof Error?$.message:"Could not save goal")}finally{g(!1)}},k=async E=>{if(r){g(!0);try{const T=await Ce(Lu(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:E})});T.ok&&o((await T.json()).goal)}finally{g(!1)}}},_=async()=>{g(!0);try{(await Ce(Lu(e),{method:"DELETE"})).ok&&(o(null),u(!1))}finally{g(!1)}},N=r!=null&&r.tokenBudget?Math.min(100,r.tokensUsed/r.tokenBudget*100):null;let S=null;if(i&&c)S=a.jsxs("form",{className:QE,onSubmit:E=>{E.preventDefault(),j()},children:[a.jsxs("div",{className:"mb-2 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[a.jsx(Hl,{className:"size-3.5","data-icon":"inline-start"}),r?"Edit long-running goal":"Set a long-running goal"]}),a.jsxs(Ta,{className:"gap-2",children:[a.jsxs(fn,{children:[a.jsx(mn,{className:"sr-only",htmlFor:"goal-objective",children:"Goal objective"}),a.jsx(Wc,{id:"goal-objective",value:d,onChange:E=>f(E.target.value),placeholder:`What should ${s} keep working toward?`,rows:2,autoFocus:!0})]}),a.jsxs(fn,{orientation:"horizontal","data-invalid":!!x,children:[a.jsx(mn,{className:"text-xs text-muted-foreground",htmlFor:"goal-budget",children:"Token budget"}),a.jsx(On,{id:"goal-budget",type:"number",min:1,step:1,value:m,onChange:E=>p(E.target.value),placeholder:"Optional",className:"ml-auto h-8 w-28","aria-invalid":!!x})]})]}),a.jsx(_o,{className:"mt-1.5",children:x}),a.jsxs("div",{className:"mt-2 flex items-center justify-end gap-1",children:[a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",onClick:()=>u(!1),children:[a.jsx(Mt,{"data-icon":"inline-start"}),"Cancel"]}),a.jsxs(Q,{type:"submit",size:"xs",disabled:h||!d.trim(),children:[a.jsx(nn,{"data-icon":"inline-start"}),"Save goal"]})]})]});else if(i&&r){const E=r.status==="paused",T=r.status==="complete";S=a.jsxs("section",{className:JE,"aria-label":`${s} goal`,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Hl,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",title:r.objective,children:r.objective}),a.jsx(Fe,{variant:Pee(r.status),children:Iee(r.status)}),a.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[vt(r.tokensUsed),r.tokenBudget?` / ${vt(r.tokenBudget)}`:""," · ",Math.max(0,Math.round(r.timeUsedSeconds/60)),"m"]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[E&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void k("active"),disabled:h,"aria-label":"Resume goal",children:a.jsx(Na,{"data-icon":"icon"})}),!E&&!T&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void k("paused"),disabled:h,"aria-label":"Pause goal",children:a.jsx(T$,{"data-icon":"icon"})}),!T&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void k("complete"),disabled:h,"aria-label":"Mark goal complete",children:a.jsx(nn,{"data-icon":"icon"})}),a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:v,"aria-label":"Edit goal",children:a.jsx(yr,{"data-icon":"icon"})}),a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void _(),disabled:h,className:"text-destructive","aria-label":"Clear goal",children:a.jsx(kf,{"data-icon":"icon"})})]})]}),N!==null&&a.jsx(qc,{className:"mt-1 mb-0.5",value:N,"aria-label":`${N.toFixed(0)}% of goal token budget used`})]})}const C=y.useMemo(()=>({section:S,canCreate:i&&!r&&!c,beginEditing:v}),[S,i,r,c,v]);return a.jsx(Q0.Provider,{value:C,children:t})}function Ree(n){switch(n){case"active":return"Goal active";case"achieved":return"Achieved";default:return"Needs attention"}}function Oee(n){switch(n){case"failed":return"destructive";case"achieved":return"secondary";default:return"outline"}}function Lee(n){const e=V.c(89),{agentKind:t,session:s,onSendCommand:r,children:o}=n;let i;e[0]!==t?(i=Bf(t),e[0]=t,e[1]=i):i=e[1];const l=i;let c;e[2]!==s.rawMessages?(c=_ee(s.rawMessages),e[2]=s.rawMessages,e[3]=c):c=e[3];const u=c,[d,f]=y.useState(),[m,p]=y.useState(!1),[h,g]=y.useState(""),[x,b]=y.useState(null),w=u?`${u.status}\0${u.condition}`:"",[v,j]=y.useState(w);v!==w&&(j(w),f(void 0));const k=d!==void 0?d:u;let _;e[4]!==(k==null?void 0:k.condition)?(_=()=>{g((k==null?void 0:k.condition)??""),b(null),p(!0)},e[4]=k==null?void 0:k.condition,e[5]=_):_=e[5];const N=_;let S;e[6]!==r||e[7]!==d?(S=async(M,F)=>{const U=d;f(F),p(!1);const O=await r(M);return O||f(U),O},e[6]=r,e[7]=d,e[8]=S):S=e[8];const C=S;let E;e[9]!==h||e[10]!==C?(E=async()=>{const M=h.trim();if(!M)return;if(M.length>4e3){b("Goal conditions can be at most 4,000 characters");return}await C(`/goal ${M}`,{condition:M,status:"active",iterations:0,durationMs:0,tokens:0})||(g(M),p(!0))},e[9]=h,e[10]=C,e[11]=E):E=e[11];const T=E;let $;e[12]!==C?($=()=>void C("/goal clear",null),e[12]=C,e[13]=$):$=e[13];const A=$;let R;if(e[14]!==l||e[15]!==N||e[16]!==A||e[17]!==h||e[18]!==m||e[19]!==x||e[20]!==k||e[21]!==T){if(R=null,m){let M;e[23]===Symbol.for("react.memo_cache_sentinel")?(M=a.jsx(Hl,{className:"size-3.5","data-icon":"inline-start"}),e[23]=M):M=e[23];const F=k?"Replace goal":"Set a long-running goal";let U;e[24]!==F?(U=a.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[M,F]}),e[24]=F,e[25]=U):U=e[25];const O=!!x;let D;e[26]===Symbol.for("react.memo_cache_sentinel")?(D=a.jsx(mn,{className:"sr-only",htmlFor:"goal-condition",children:"Goal condition"}),e[26]=D):D=e[26];let B;e[27]===Symbol.for("react.memo_cache_sentinel")?(B=ne=>g(ne.target.value),e[27]=B):B=e[27];const q=`A measurable condition ${l} should keep working toward…`,W=!!x;let H;e[28]!==h||e[29]!==q||e[30]!==W?(H=a.jsx(Wc,{id:"goal-condition",value:h,onChange:B,placeholder:q,rows:2,maxLength:4e3,"aria-invalid":W,autoFocus:!0}),e[28]=h,e[29]=q,e[30]=W,e[31]=H):H=e[31];let K;e[32]!==x?(K=a.jsx(_o,{children:x}),e[32]=x,e[33]=K):K=e[33];let Z;e[34]!==O||e[35]!==H||e[36]!==K?(Z=a.jsxs(fn,{"data-invalid":O,children:[D,H,K]}),e[34]=O,e[35]=H,e[36]=K,e[37]=Z):Z=e[37];let Y;e[38]===Symbol.for("react.memo_cache_sentinel")?(Y=a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",onClick:()=>p(!1),children:[a.jsx(Mt,{"data-icon":"inline-start"}),"Cancel"]}),e[38]=Y):Y=e[38];let X;e[39]!==T?(X=()=>void T(),e[39]=T,e[40]=X):X=e[40];let ee;e[41]!==h?(ee=h.trim(),e[41]=h,e[42]=ee):ee=e[42];const te=!ee;let se;e[43]===Symbol.for("react.memo_cache_sentinel")?(se=a.jsx(nn,{"data-icon":"inline-start"}),e[43]=se):se=e[43];let J;e[44]!==X||e[45]!==te?(J=a.jsxs("div",{className:"mt-2 flex items-center justify-end gap-1",children:[Y,a.jsxs(Q,{type:"button",size:"xs",onClick:X,disabled:te,children:[se,"Start goal"]})]}),e[44]=X,e[45]=te,e[46]=J):J=e[46],R=a.jsxs("section",{className:QE,"aria-label":`${l} goal editor`,children:[U,Z,J]})}else if(k){let M;e[47]===Symbol.for("react.memo_cache_sentinel")?(M=a.jsx(Hl,{className:"size-3.5 shrink-0 text-primary","data-icon":"inline-start"}),e[47]=M):M=e[47];let F;e[48]!==k.condition?(F=a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",title:k.condition,children:k.condition}),e[48]=k.condition,e[49]=F):F=e[49];let U;e[50]!==k.status?(U=Oee(k.status),e[50]=k.status,e[51]=U):U=e[51];let O;e[52]!==k.status?(O=Ree(k.status),e[52]=k.status,e[53]=O):O=e[53];let D;e[54]!==O||e[55]!==U?(D=a.jsx(Fe,{variant:U,children:O}),e[54]=O,e[55]=U,e[56]=D):D=e[56];const B=k.iterations,q=k.iterations===1?"":"s";let W;e[57]!==k.tokens?(W=vt(k.tokens),e[57]=k.tokens,e[58]=W):W=e[58];let H;e[59]!==k.durationMs?(H=Math.round(k.durationMs/6e4),e[59]=k.durationMs,e[60]=H):H=e[60];const K=Math.max(0,H);let Z;e[61]!==k.iterations||e[62]!==q||e[63]!==W||e[64]!==K?(Z=a.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[B," turn",q," · ",W," · ",K,"m"]}),e[61]=k.iterations,e[62]=q,e[63]=W,e[64]=K,e[65]=Z):Z=e[65];let Y;e[66]===Symbol.for("react.memo_cache_sentinel")?(Y=a.jsx(yr,{"data-icon":"icon"}),e[66]=Y):Y=e[66];let X;e[67]!==N?(X=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:N,"aria-label":"Replace goal",children:Y}),e[67]=N,e[68]=X):X=e[68];let ee;e[69]===Symbol.for("react.memo_cache_sentinel")?(ee=a.jsx(kf,{"data-icon":"icon"}),e[69]=ee):ee=e[69];let te;e[70]!==A?(te=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:A,"aria-label":"Clear goal",children:ee}),e[70]=A,e[71]=te):te=e[71];let se;e[72]!==X||e[73]!==te?(se=a.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[X,te]}),e[72]=X,e[73]=te,e[74]=se):se=e[74];let J;e[75]!==D||e[76]!==Z||e[77]!==se||e[78]!==F?(J=a.jsxs("div",{className:"flex items-center gap-2",children:[M,F,D,Z,se]}),e[75]=D,e[76]=Z,e[77]=se,e[78]=F,e[79]=J):J=e[79];let ne;e[80]!==k.reason?(ne=k.reason&&a.jsx("p",{className:"line-clamp-2 pb-0.5 pl-5 text-xs text-muted-foreground",children:k.reason}),e[80]=k.reason,e[81]=ne):ne=e[81],R=a.jsxs("section",{className:JE,"aria-label":`${l} goal`,children:[J,ne]})}e[14]=l,e[15]=N,e[16]=A,e[17]=h,e[18]=m,e[19]=x,e[20]=k,e[21]=T,e[22]=R}else R=e[22];const P=!k&&!m;let z;e[82]!==N||e[83]!==R||e[84]!==P?(z={section:R,canCreate:P,beginEditing:N},e[82]=N,e[83]=R,e[84]=P,e[85]=z):z=e[85];const L=z;let I;return e[86]!==o||e[87]!==L?(I=a.jsx(Q0.Provider,{value:L,children:o}),e[86]=o,e[87]=L,e[88]=I):I=e[88],I}function Mee(n){const e=V.c(9),{agentKind:t,session:s,onSendCommand:r,children:o}=n,i=bn(t).goals;if(i==="thread-api"){let l;return e[0]!==t||e[1]!==o||e[2]!==s.sessionId?(l=a.jsx($ee,{agentKind:t,threadId:s.sessionId,children:o}),e[0]=t,e[1]=o,e[2]=s.sessionId,e[3]=l):l=e[3],l}if(i==="transcript"){let l;return e[4]!==t||e[5]!==o||e[6]!==r||e[7]!==s?(l=a.jsx(Lee,{agentKind:t,session:s,onSendCommand:r,children:o}),e[4]=t,e[5]=o,e[6]=r,e[7]=s,e[8]=l):l=e[8],l}return o}function zee(){return XE().section}function pk(){const n=V.c(3),{canCreate:e,beginEditing:t}=XE();if(!e)return null;let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(Hl,{"data-icon":"inline-start"}),n[0]=s):s=n[0];let r;return n[1]!==t?(r=a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",onClick:t,title:"Set a long-running goal for this session",children:[s,"Set goal"]}),n[1]=t,n[2]=r):r=n[2],r}const Dee=["allow","allow_always","deny"],Fee=[{decision:"allow",label:"Allow",variant:"default"},{decision:"deny",label:"Deny",variant:"destructive"},{decision:"allow_always",label:"Always",variant:"outline"}];function Uee(n,e){return(n.availableDecisions??Dee).includes(e)}function Bee(n){const e=V.c(22),{request:t,queued:s,responding:r,onRespond:o}=n;let i;if(e[0]!==o||e[1]!==s||e[2]!==t||e[3]!==r){let l;e[5]!==t?(l=w=>Uee(t,w.decision),e[5]=t,e[6]=l):l=e[6];const c=Fee.filter(l);t.defaultToNo&&c.sort(qee);const u=c.some(Wee);let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx(ix,{className:"text-warning"}),e[7]=d):d=e[7];const f=t.title||`Allow ${t.toolName}?`;let m;e[8]!==f?(m=a.jsx("span",{className:"min-w-0 flex-1 truncate",children:f}),e[8]=f,e[9]=m):m=e[9];let p;e[10]!==s?(p=s>0&&a.jsxs("span",{className:"shrink-0 font-mono text-xs text-warning",children:["+",s]}),e[10]=s,e[11]=p):p=e[11];let h;e[12]!==m||e[13]!==p?(h=a.jsxs(tn,{className:"flex min-w-0 items-center gap-2",children:[m,p]}),e[12]=m,e[13]=p,e[14]=h):h=e[14];let g;e[15]!==t.toolName?(g=a.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:t.toolName}),e[15]=t.toolName,e[16]=g):g=e[16];let x;e[17]!==t.summary?(x=t.summary&&a.jsx("code",{className:"min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 font-mono text-xs text-foreground",children:t.summary}),e[17]=t.summary,e[18]=x):x=e[18];let b;e[19]!==g||e[20]!==x?(b=a.jsxs("div",{className:"col-start-2 mt-2 flex min-w-0 items-center gap-2",children:[g,x]}),e[19]=g,e[20]=x,e[21]=b):b=e[21],i=a.jsxs(jt,{className:"border-warning/40 bg-warning/5",children:[d,h,b,o&&(u?a.jsx("div",{className:"col-start-2 mt-3 flex items-center gap-2",children:c.map(w=>{const{decision:v,label:j,variant:k}=w;return a.jsx(Q,{autoFocus:t.defaultToNo&&v==="deny",size:"xs",variant:k,disabled:r,onClick:()=>o(t.requestId,v),children:j},`${t.requestId}:${v}`)})}):a.jsx("p",{className:"col-start-2 mt-2 text-xs text-warning",children:"Resolve this approval in its own provider"}))]}),e[0]=o,e[1]=s,e[2]=t,e[3]=r,e[4]=i}else i=e[4];return i}function Wee(n){return n.decision!=="allow_always"}function qee(n,e){return+(e.decision==="deny")-+(n.decision==="deny")}const eT=y.createContext({size:"default",variant:"default",spacing:2,orientation:"horizontal"});function tT(n){const e=V.c(29);let t,s,r,o,i,l,c;e[0]!==n?({className:s,variant:c,size:o,spacing:i,orientation:l,children:t,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i,e[6]=l,e[7]=c):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5],l=e[6],c=e[7]);const u=i===void 0?2:i,d=l===void 0?"horizontal":l;let f;e[8]!==u?(f={"--gap":u},e[8]=u,e[9]=f):f=e[9];const m=f;let p;e[10]!==s?(p=G("group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-[orientation=vertical]:flex-col data-[orientation=vertical]:items-stretch",s),e[10]=s,e[11]=p):p=e[11];let h;e[12]!==d||e[13]!==o||e[14]!==u||e[15]!==c?(h={variant:c,size:o,spacing:u,orientation:d},e[12]=d,e[13]=o,e[14]=u,e[15]=c,e[16]=h):h=e[16];let g;e[17]!==t||e[18]!==h?(g=a.jsx(eT.Provider,{value:h,children:t}),e[17]=t,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==d||e[21]!==r||e[22]!==o||e[23]!==u||e[24]!==m||e[25]!==p||e[26]!==g||e[27]!==c?(x=a.jsx(A$,{"data-slot":"toggle-group","data-variant":c,"data-size":o,"data-spacing":u,"data-orientation":d,orientation:d,style:m,className:p,...r,children:g}),e[20]=d,e[21]=r,e[22]=o,e[23]=u,e[24]=m,e[25]=p,e[26]=g,e[27]=c,e[28]=x):x=e[28],x}function g1(n){const e=V.c(19);let t,s,r,o,i;e[0]!==n?({className:s,children:t,variant:o,size:i,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5]);const l=o===void 0?"default":o,c=i===void 0?"default":i,u=y.useContext(eT),d=u.variant||l,f=u.size||c,m=u.spacing;let p;e[6]!==s||e[7]!==u.size||e[8]!==u.variant||e[9]!==c||e[10]!==l?(p=G("shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t",p5({variant:u.variant||l,size:u.size||c}),s),e[6]=s,e[7]=u.size,e[8]=u.variant,e[9]=c,e[10]=l,e[11]=p):p=e[11];let h;return e[12]!==t||e[13]!==u.spacing||e[14]!==r||e[15]!==d||e[16]!==f||e[17]!==p?(h=a.jsx(h4,{"data-slot":"toggle-group-item","data-variant":d,"data-size":f,"data-spacing":m,className:p,...r,children:t}),e[12]=t,e[13]=u.spacing,e[14]=r,e[15]=d,e[16]=f,e[17]=p,e[18]=h):h=e[18],h}function Vee(n){return n.some(e=>e.options.length===0||e.options.some(t=>t.hasPreview))}function Hee(n){const e=V.c(64),{request:t,responding:s,gone:r,onAnswer:o,onOpenSession:i}=n,l=t.questions,[c,u]=y.useState(0);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={},e[0]=d):d=e[0];const f=y.useRef(d);let m;e[1]===Symbol.for("react.memo_cache_sentinel")?(m=new Set,e[1]=m):m=e[1];const[p,h]=y.useState(m);if(l.length===0)return null;if(Vee(l)){let M;e[2]!==l[0].question?(M=a.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:l[0].question}),e[2]=l[0].question,e[3]=M):M=e[3];let F;e[4]===Symbol.for("react.memo_cache_sentinel")?(F=a.jsx(it,{"data-icon":"inline-end"}),e[4]=F):F=e[4];let U;e[5]!==i?(U=a.jsxs(Q,{variant:"outline",size:"sm",onClick:i,className:"mt-3",children:["Open full question",F]}),e[5]=i,e[6]=U):U=e[6];let O;return e[7]!==M||e[8]!==U?(O=a.jsxs(hk,{children:[M,U]}),e[7]=M,e[8]=U,e[9]=O):O=e[9],O}const g=l[c],x=s||!o;let b;e[10]!==g.question||e[11]!==c||e[12]!==o||e[13]!==l.length||e[14]!==t.toolUseId?(b=function(F){const U={...f.current,[g.question]:F};if(c+1<l.length){f.current=U,h(new Set),u(c+1);return}o==null||o(t.toolUseId,U)},e[10]=g.question,e[11]=c,e[12]=o,e[13]=l.length,e[14]=t.toolUseId,e[15]=b):b=e[15];const w=b;let v;e[16]!==g.header?(v=g.header&&a.jsx(Fe,{variant:"outline",className:"border-info/40 text-info",children:g.header}),e[16]=g.header,e[17]=v):v=e[17];let j;e[18]!==c||e[19]!==l.length?(j=l.length>1&&a.jsxs("span",{className:"ml-auto shrink-0 font-mono text-xs text-muted-foreground",children:[c+1," of ",l.length]}),e[18]=c,e[19]=l.length,e[20]=j):j=e[20];let k;e[21]!==v||e[22]!==j?(k=a.jsxs("div",{className:"flex items-baseline gap-1.5",children:[v,j]}),e[21]=v,e[22]=j,e[23]=k):k=e[23];let _;e[24]!==g.question?(_=a.jsx("p",{className:"mt-2 line-clamp-3 text-sm leading-relaxed text-foreground",title:g.question,children:g.question}),e[24]=g.question,e[25]=_):_=e[25];let N;e[26]!==p?(N=[...p],e[26]=p,e[27]=N):N=e[27];let S;e[28]!==w||e[29]!==g.multiSelect?(S=M=>{g.multiSelect?h(new Set(M)):M[0]&&w(M[0])},e[28]=w,e[29]=g.multiSelect,e[30]=S):S=e[30];const C=g.multiSelect,E=g.question;let T;if(e[31]!==g.options||e[32]!==x){let M;e[34]!==x?(M=F=>a.jsx(Kee,{option:F,disabled:x},F.label),e[34]=x,e[35]=M):M=e[35],T=g.options.map(M),e[31]=g.options,e[32]=x,e[33]=T}else T=e[33];let $;e[36]!==g.multiSelect||e[37]!==g.question||e[38]!==T||e[39]!==N||e[40]!==S?($=a.jsx(tT,{value:N,onValueChange:S,multiple:C,orientation:"vertical",variant:"outline",size:"sm",className:"mt-3 w-full items-stretch","aria-label":E,children:T}),e[36]=g.multiSelect,e[37]=g.question,e[38]=T,e[39]=N,e[40]=S,e[41]=$):$=e[41];let A;e[42]!==w||e[43]!==g.multiSelect||e[44]!==c||e[45]!==o||e[46]!==l.length||e[47]!==s||e[48]!==p?(A=g.multiSelect&&o&&a.jsx(Q,{size:"sm",disabled:s||p.size===0,onClick:()=>w(wee(p)),children:c+1<l.length?"Next":"Send"}),e[42]=w,e[43]=g.multiSelect,e[44]=c,e[45]=o,e[46]=l.length,e[47]=s,e[48]=p,e[49]=A):A=e[49];let R;e[50]===Symbol.for("react.memo_cache_sentinel")?(R=a.jsx(it,{"data-icon":"inline-end"}),e[50]=R):R=e[50];let P;e[51]!==i?(P=a.jsxs(Q,{variant:"ghost",size:"sm",onClick:i,className:"ml-auto text-muted-foreground",children:["Open session",R]}),e[51]=i,e[52]=P):P=e[52];let z;e[53]!==A||e[54]!==P?(z=a.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[A,P]}),e[53]=A,e[54]=P,e[55]=z):z=e[55];let L;e[56]!==r?(L=r&&a.jsx("p",{className:"mt-2 text-xs text-warning",children:"This question may already be answered. Open the session to check."}),e[56]=r,e[57]=L):L=e[57];let I;return e[58]!==$||e[59]!==z||e[60]!==L||e[61]!==k||e[62]!==_?(I=a.jsxs(hk,{children:[k,_,$,z,L]}),e[58]=$,e[59]=z,e[60]=L,e[61]=k,e[62]=_,e[63]=I):I=e[63],I}function Kee(n){const e=V.c(17),{option:t,disabled:s}=n;let r;e[0]!==t.label?(r=a.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:t.label}),e[0]=t.label,e[1]=r):r=e[1];const o=r;if(!t.description){let d;return e[2]!==s||e[3]!==o||e[4]!==t.label?(d=a.jsx(g1,{value:t.label,disabled:s,className:"w-full justify-start px-3",children:o}),e[2]=s,e[3]=o,e[4]=t.label,e[5]=d):d=e[5],d}let i;e[6]!==s||e[7]!==t.label?(i=a.jsx(g1,{value:t.label,disabled:s,className:"w-full justify-start px-3"}),e[6]=s,e[7]=t.label,e[8]=i):i=e[8];let l;e[9]!==o||e[10]!==i?(l=a.jsx(Zt,{render:i,children:o}),e[9]=o,e[10]=i,e[11]=l):l=e[11];let c;e[12]!==t.description?(c=a.jsx(Yt,{side:"right",className:"max-w-72 text-left",children:t.description}),e[12]=t.description,e[13]=c):c=e[13];let u;return e[14]!==l||e[15]!==c?(u=a.jsxs(Gt,{children:[l,c]}),e[14]=l,e[15]=c,e[16]=u):u=e[16],u}function hk(n){const e=V.c(4),{children:t}=n;let s,r;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(I$,{className:"text-info"}),r=a.jsx(tn,{children:"Answer to continue"}),e[0]=s,e[1]=r):(s=e[0],r=e[1]);let o;return e[2]!==t?(o=a.jsxs(jt,{className:"border-info/40 bg-info/5",children:[s,r,a.jsx("div",{className:"col-start-2 mt-1 min-w-0",children:t})]}),e[2]=t,e[3]=o):o=e[3],o}function Gee(n){const e=V.c(45),{sessionId:t,pending:s,queued:r,responding:o,onRespond:i,onOpen:l}=n;switch(s.kind){case"permission":{let c;e[0]!==s||e[1]!==t?(c={...s,sessionId:t,timestamp:0},e[0]=s,e[1]=t,e[2]=c):c=e[2];let u;e[3]!==i?(u=(f,m)=>i(f,{decision:m}),e[3]=i,e[4]=u):u=e[4];let d;return e[5]!==r||e[6]!==o||e[7]!==c||e[8]!==u?(d=a.jsx(Bee,{request:c,queued:r,responding:o,onRespond:u}),e[5]=r,e[6]=o,e[7]=c,e[8]=u,e[9]=d):d=e[9],d}case"question":{const c=s.requestId;let u;e[10]!==s.questions?(u=s.questions.map(Zee),e[10]=s.questions,e[11]=u):u=e[11];let d;e[12]!==s.requestId||e[13]!==t||e[14]!==u?(d={sessionId:t,toolUseId:c,askedAt:0,questions:u},e[12]=s.requestId,e[13]=t,e[14]=u,e[15]=d):d=e[15];let f;e[16]!==i?(f=(p,h)=>i(p,{answers:h}),e[16]=i,e[17]=f):f=e[17];let m;return e[18]!==l||e[19]!==o||e[20]!==d||e[21]!==f?(m=a.jsx(Hee,{request:d,responding:o,gone:!1,onAnswer:f,onOpenSession:l}),e[18]=l,e[19]=o,e[20]=d,e[21]=f,e[22]=m):m=e[22],m}case"plan":{let c,u;e[23]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx(P$,{className:"text-info"}),u=a.jsx(tn,{children:"Approve the plan?"}),e[23]=c,e[24]=u):(c=e[23],u=e[24]);let d;e[25]!==s.summary?(d=s.summary&&a.jsx("p",{className:"col-start-2 mt-1 line-clamp-3 text-sm text-foreground",children:s.summary}),e[25]=s.summary,e[26]=d):d=e[26];let f;e[27]!==i||e[28]!==s.requestId?(f=()=>i(s.requestId,{approved:!0}),e[27]=i,e[28]=s.requestId,e[29]=f):f=e[29];let m;e[30]!==o||e[31]!==f?(m=a.jsx(Q,{size:"xs",disabled:o,onClick:f,children:"Approve"}),e[30]=o,e[31]=f,e[32]=m):m=e[32];let p;e[33]!==i||e[34]!==s.requestId?(p=()=>i(s.requestId,{approved:!1}),e[33]=i,e[34]=s.requestId,e[35]=p):p=e[35];let h;e[36]!==o||e[37]!==p?(h=a.jsx(Q,{size:"xs",variant:"destructive",disabled:o,onClick:p,children:"Reject"}),e[36]=o,e[37]=p,e[38]=h):h=e[38];let g;e[39]!==m||e[40]!==h?(g=a.jsxs("div",{className:"col-start-2 mt-3 flex items-center gap-2",children:[m,h]}),e[39]=m,e[40]=h,e[41]=g):g=e[41];let x;return e[42]!==d||e[43]!==g?(x=a.jsxs(jt,{className:"border-info/40 bg-info/5",children:[c,u,d,g]}),e[42]=d,e[43]=g,e[44]=x):x=e[44],x}}}function Zee(n){return{question:n.question,multiSelect:n.multiSelect,options:n.options.map(Yee)}}function Yee(n){return{label:n,hasPreview:!1}}const Xee=3e3;function Jee(n){const[e,t]=y.useState([]),[s,r]=y.useState(new Set),o=y.useCallback(async l=>{if(n)try{const c=await Ce(`/api/session-requests?parent=${encodeURIComponent(n)}`);if(!l()||!c.ok)return;const u=await c.json();if(!l())return;t(d=>JSON.stringify(d)===JSON.stringify(u.requests)?d:u.requests)}catch{}},[n]);Ra(n?o:null,Xee),y.useEffect(()=>{t([])},[n]);const i=y.useCallback(async(l,c,u)=>{r(d=>new Set(d).add(c));try{const d=await is("/api/session-respond",{sessionId:l,requestId:c,...u});(d.ok||d.status===404)&&t(f=>f.map(m=>m.sessionId===l?{...m,waiting:m.waiting.filter(p=>p.requestId!==c)}:m).filter(m=>m.waiting.length>0))}finally{r(d=>{const f=new Set(d);return f.delete(c),f})}},[]);return{requests:e,responding:s,respond:i}}function Ma(n){window.history.pushState({},"",n),window.dispatchEvent(new PopStateEvent("popstate"))}function pa(n,e,t){return`${t===void 0?Nx():`/d/${encodeURIComponent(t)}`}/${encodeURIComponent(n)}/${encodeURIComponent(X4(n,e))}`}async function cm(n){let e;try{e=await Ce(`/api/find-session/${encodeURIComponent(n)}`)}catch{return!1}const t=e.ok?await zs(e):null;return typeof(t==null?void 0:t.dirName)!="string"||typeof t.fileName!="string"?!1:(Ma(pa(t.dirName,t.fileName)),!0)}function Qee(n){var o;if(!n.address)return null;const{dirName:e,fileName:t}=n.address,s=((o=n.device)==null?void 0:o.id)??Kt();return`${s===Lt?"":`/d/${encodeURIComponent(s)}`}/${encodeURIComponent(e)}/${encodeURIComponent(X4(e,t))}`}function ete(n){const e=V.c(9),{sessionId:t}=n,{requests:s,responding:r,respond:o}=Jee(t);if(s.length===0)return null;let i;if(e[0]!==s||e[1]!==o||e[2]!==r){let c;e[4]!==o||e[5]!==r?(c=u=>a.jsx(tte,{request:u,responding:r,onRespond:(d,f)=>void o(u.sessionId,d,f)},u.sessionId),e[4]=o,e[5]=r,e[6]=c):c=e[6],i=s.map(c),e[0]=s,e[1]=o,e[2]=r,e[3]=i}else i=e[3];let l;return e[7]!==i?(l=a.jsx("div",{className:"flex flex-col gap-2 px-3 pb-2",children:i}),e[7]=i,e[8]=l):l=e[8],l}function tte(n){const e=V.c(26),{request:t,responding:s,onRespond:r}=n;let o;e[0]!==t?(o=Qee(t),e[0]=t,e[1]=o):o=e[1];const i=o;let l;e[2]!==i?(l=()=>{i&&Ma(i)},e[2]=i,e[3]=l):l=e[3];const c=l,[u]=t.waiting;if(!u)return null;let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx(ax,{className:"size-3.5"}),e[4]=d):d=e[4];const f=t.device?`Delegated session on ${t.device.name}`:"Delegated session";let m;e[5]!==f?(m=a.jsx("span",{className:"truncate",children:f}),e[5]=f,e[6]=m):m=e[6];let p;e[7]!==c||e[8]!==i?(p=i&&a.jsxs(Q,{variant:"ghost",size:"xs",className:"ml-auto",onClick:c,children:["Open",a.jsx(it,{"data-icon":"inline-end"})]}),e[7]=c,e[8]=i,e[9]=p):p=e[9];let h;e[10]!==m||e[11]!==p?(h=a.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[d,m,p]}),e[10]=m,e[11]=p,e[12]=h):h=e[12];const g=u.requestId,x=t.sessionId,b=t.waiting.length-1;let w;e[13]!==u.requestId||e[14]!==s?(w=s.has(u.requestId),e[13]=u.requestId,e[14]=s,e[15]=w):w=e[15];let v;e[16]!==r||e[17]!==c||e[18]!==u||e[19]!==t.sessionId||e[20]!==b||e[21]!==w?(v=a.jsx(Gee,{sessionId:x,pending:u,queued:b,responding:w,onRespond:r,onOpen:c},g),e[16]=r,e[17]=c,e[18]=u,e[19]=t.sessionId,e[20]=b,e[21]=w,e[22]=v):v=e[22];let j;return e[23]!==v||e[24]!==h?(j=a.jsxs("div",{className:"flex flex-col gap-1",children:[h,v]}),e[23]=v,e[24]=h,e[25]=j):j=e[25],j}const x1="cogpit-session-config-changed";function nte(n){if(typeof n!="string")return null;let e;try{e=JSON.parse(n)}catch{e=n.trim()}if(typeof e=="string")return e||null;const t=e==null?void 0:e.sessionId;return typeof t=="string"?t:null}function ste(n){function e(t){const s=nte(t.data);s&&window.dispatchEvent(new CustomEvent(x1,{detail:{sessionId:s}}))}return n.addEventListener(Ny,e),()=>n.removeEventListener(Ny,e)}function rte(n,e){function t(s){var r;((r=s.detail)==null?void 0:r.sessionId)===n&&e()}return window.addEventListener(x1,t),()=>window.removeEventListener(x1,t)}const nf=new Map;class ote extends EventTarget{constructor(t,s){super();Ge(this,"CONNECTING",0);Ge(this,"OPEN",1);Ge(this,"CLOSED",2);Ge(this,"withCredentials",!1);Ge(this,"onopen",null);Ge(this,"onmessage",null);Ge(this,"onerror",null);this.owner=t,this.options=s;for(const r of["open","message","error"])super.addEventListener(r,o=>{const i=r==="open"?this.onopen:r==="message"?this.onmessage:this.onerror;i==null||i.call(this,o)})}get url(){return this.owner.url}get readyState(){var t;return((t=this.owner.source)==null?void 0:t.readyState)??(this.owner.health.transport==="denied"?2:0)}addEventListener(t,s,r){this.owner.listen(t),super.addEventListener(t,s,r)}close(){this.owner.remove(this)}emit(t){this.dispatchEvent(t instanceof MessageEvent?new MessageEvent(t.type,{data:t.data,origin:t.origin,lastEventId:t.lastEventId}):new Event(t.type))}}class ite{constructor(e,t){Ge(this,"source",null);Ge(this,"health",{transport:"connecting",freshness:"waiting",lastEventAt:null});Ge(this,"subscribers",new Set);Ge(this,"types",new Set(["open","error","message","access","session-config"]));Ge(this,"linked",new Set);Ge(this,"asking",null);Ge(this,"timer");Ge(this,"attempts",0);Ge(this,"generation",0);Ge(this,"retryingGeneration",null);Ge(this,"stopped",!1);Ge(this,"stopFrames",[]);Ge(this,"foreground",()=>{document.visibilityState==="hidden"||this.stopped||this.health.transport==="denied"||(!this.source||this.health.transport!=="open"||this.health.lastEventAt!==null&&Date.now()-this.health.lastEventAt>45e3)&&this.connect()});Ge(this,"identityChanged",()=>this.stop());this.key=e,this.url=t,window.addEventListener("online",this.foreground),document.addEventListener("visibilitychange",this.foreground),window.addEventListener("cogpit-identity-changed",this.identityChanged),window.addEventListener("cogpit-device-scope-changed",this.identityChanged),this.connect()}add(e){const t=new ote(this,e);return this.subscribers.add(t),queueMicrotask(()=>{var s,r;this.subscribers.has(t)&&((s=e.onState)==null||s.call(e,this.health),this.health.transport==="open"?t.emit(new Event("open")):this.health.transport==="denied"&&((r=e.onLost)==null||r.call(e)))}),t}remove(e){this.subscribers.delete(e),this.subscribers.size||this.stop()}listen(e){this.types.add(e),this.link(e)}link(e){const t=this.source,s=this.generation;!t||this.linked.has(e)||(this.linked.add(e),t.addEventListener(e,r=>{if(!(this.stopped||s!==this.generation)){if(e==="open")this.attempts=0,this.setHealth({...this.health,transport:"open"});else if(e==="error"){if(this.retryingGeneration===s)return;this.retryingGeneration=s,this.setHealth({...this.health,transport:"retrying",freshness:"stale"});const o=t.readyState===EventSource.CLOSED;t.close(),this.retry(s,o)}else this.setHealth({transport:"open",freshness:"current",lastEventAt:Date.now()});for(const o of this.subscribers)o.emit(r)}}))}setHealth(e){var t,s;this.health=e;for(const r of this.subscribers)(s=(t=r.options).onState)==null||s.call(t,e)}connect(){var e,t;if(!this.stopped){clearTimeout(this.timer),(e=this.asking)==null||e.abort();for(const s of this.stopFrames)s();(t=this.source)==null||t.close(),this.generation++,this.retryingGeneration=null,this.linked.clear(),this.setHealth({...this.health,transport:"connecting"}),this.source=new EventSource(this.url),this.stopFrames=[SR(this.source),ste(this.source)];for(const s of this.types)this.link(s)}}async retry(e,t){var o,i,l;const s=new AbortController;if(this.asking=s,t)try{const c=await Ce(this.url,{signal:s.signal});if((o=c.body)==null||o.cancel(),this.stopped||e!==this.generation||s.signal.aborted)return;if(c.status===401||c.status===403||aN(c)){this.setHealth({...this.health,transport:"denied",freshness:"stale"});for(const u of this.subscribers)(l=(i=u.options).onLost)==null||l.call(i);return}}catch{if(this.stopped||s.signal.aborted)return}if(this.stopped||e!==this.generation)return;const r=Math.min(3e4,500*2**Math.min(this.attempts++,6))*(.75+Math.random()*.5);this.timer=setTimeout(()=>this.connect(),r)}stop(){var e,t;this.stopped=!0,this.generation++,clearTimeout(this.timer),(e=this.asking)==null||e.abort(),(t=this.source)==null||t.close();for(const s of this.stopFrames)s();window.removeEventListener("online",this.foreground),document.removeEventListener("visibilitychange",this.foreground),window.removeEventListener("cogpit-identity-changed",this.identityChanged),window.removeEventListener("cogpit-device-scope-changed",this.identityChanged),this.setHealth({...this.health,transport:"closed",freshness:"stale"}),nf.get(this.key)===this&&nf.delete(this.key)}}function eb(n,e={}){const t=Af(n),s=JSON.stringify([cn(),Zn(),t]);let r=nf.get(s);r||(r=new ite(s,t),nf.set(s,r));const o=r.add(e);return{source:o,close:()=>o.close(),state:()=>r.health}}function Vc({className:n,children:e,...t}){return a.jsxs($$,{"data-slot":"scroll-area",className:G("relative overflow-hidden",n),...t,children:[a.jsx(R$,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:e}),a.jsx(ate,{}),a.jsx(O$,{})]})}function ate({className:n,orientation:e="vertical",...t}){return a.jsx(L$,{"data-slot":"scroll-area-scrollbar","data-orientation":e,orientation:e,className:G("flex touch-none p-px transition-colors select-none data-[orientation=horizontal]:h-2.5 data-[orientation=horizontal]:flex-col data-[orientation=horizontal]:border-t data-[orientation=horizontal]:border-t-transparent data-[orientation=vertical]:h-full data-[orientation=vertical]:w-2.5 data-[orientation=vertical]:border-l data-[orientation=vertical]:border-l-transparent",n),...t,children:a.jsx(M$,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}function nT({className:n,...e}){return a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",className:G("status-icon-spin size-5",n),...e,children:[a.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.2"}),a.jsx("path",{d:"M12 2A10 10 0 0 1 22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function lte({className:n,...e}){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:G("size-5",n),...e,children:a.jsx("path",{className:"status-icon-complete",d:"M20 6L9 17L4 12"})})}function cte({className:n,...e}){return a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:G("size-5",n),...e,children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function ute({className:n,...e}){return a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",className:G("status-icon-spin size-5",n),...e,children:[a.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.1"}),a.jsx("path",{d:"M12 2A10 10 0 0 1 22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),a.jsx("path",{d:"M12 22A10 10 0 0 1 2 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function Pn({className:n,...e}){const t=n==null?void 0:n.replace(/\banimate-spin\b/g,"").trim();return a.jsx(nT,{className:G(t),...e})}function dte(n){const e=Nn("hostFiles"),[t,s]=y.useState([]),[r,o]=y.useState(!1),i=y.useCallback(async()=>{if(!e||!n){s([]);return}o(!0);try{const l=await Ce(`/api/scripts?dir=${encodeURIComponent(n)}`);if(l.ok){const c=await l.json();s(c)}}catch{}finally{o(!1)}},[e,n]);return y.useEffect(()=>{i()},[i]),{scripts:t,loading:r,refresh:i}}const gk=500,fte=5e3;function mte(n){const e=V.c(29),t=n===void 0?!0:n,[s,r]=y.useState("disconnected");let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[0]=o):o=e[0];const[i,l]=y.useState(o),c=y.useRef(null);let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u=new Map,e[1]=u):u=e[1];const d=y.useRef(u),f=y.useRef(gk),m=y.useRef(null),p=y.useRef(!1),h=y.useRef(pte);let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=F=>{var D;const U=F.type,O=F.id;if(U==="sessions"){l(F.sessions??[]);return}O&&((D=d.current.get(O))==null||D(U,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}${Q4()}/__pty`},U=function(){if(p.current||c.current&&c.current.readyState!==WebSocket.CLOSED)return;r("connecting");const D=new WebSocket(F());c.current=D,D.onopen=()=>{if(p.current){D.close();return}f.current=gk,r("connected"),D.send(JSON.stringify({type:"list"}))},D.onmessage=B=>{try{const q=JSON.parse(B.data);x(q)}catch{}},D.onclose=()=>{if(p.current)return;r("disconnected"),c.current=null;const B=f.current;f.current=Math.min(B*2,fte),m.current=setTimeout(()=>h.current(),B)}};return h.current=U,U(),()=>{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 U=c.current;U&&U.readyState===WebSocket.OPEN&&U.send(JSON.stringify(F))},e[6]=t,e[7]=v):v=e[7];const j=v;let k;e[8]===Symbol.for("react.memo_cache_sentinel")?(k=(F,U)=>{d.current.set(F,U)},e[8]=k):k=e[8];const _=k;let N;e[9]===Symbol.for("react.memo_cache_sentinel")?(N=F=>{d.current.delete(F)},e[9]=N):N=e[9];const S=N;let C;e[10]!==j?(C=F=>{const U=F===void 0?{}:F,O=`pty_${crypto.randomUUID().slice(0,8)}`;return j({type:"spawn",id:O,name:U.name??"Terminal",cwd:U.cwd,metadata:{type:"terminal"}}),O},e[10]=j,e[11]=C):C=e[11];const E=C;let T;e[12]!==j?(T=F=>{const U=`script_${crypto.randomUUID().slice(0,8)}`;return j({type:"spawn",id:U,name:F.name,cwd:F.cwd,args:["run",F.scriptName],command:"bun",metadata:{type:"script",source:F.source,scriptName:F.scriptName}}),U},e[12]=j,e[13]=T):T=e[13];const $=T;let A;e[14]!==j?(A=F=>{j({type:"kill",id:F})},e[14]=j,e[15]=A):A=e[15];const R=A;let P;e[16]!==j?(P=(F,U)=>{j({type:"input",id:F,data:U})},e[16]=j,e[17]=P):P=e[17];const z=P;let L;e[18]!==j?(L=(F,U,O)=>{j({type:"resize",id:F,cols:U,rows:O})},e[18]=j,e[19]=L):L=e[19];const I=L;let M;return e[20]!==R||e[21]!==I||e[22]!==j||e[23]!==i||e[24]!==$||e[25]!==E||e[26]!==s||e[27]!==z?(M={status:s,send:j,subscribe:_,unsubscribe:S,sessions:i,spawnTerminal:E,spawnScript:$,killSession:R,writeInput:z,resize:I},e[20]=R,e[21]=I,e[22]=j,e[23]=i,e[24]=$,e[25]=E,e[26]=s,e[27]=z,e[28]=M):M=e[28],M}function pte(){}const sT=y.createContext(null);function _h(n){const e=V.c(3),{children:t,enabled:s}=n,o=mte(s===void 0?!0:s);let i;return e[0]!==t||e[1]!==o?(i=a.jsx(sT.Provider,{value:o,children:t}),e[0]=t,e[1]=o,e[2]=i):i=e[2],i}function tb(){const n=y.useContext(sT);if(!n)throw new Error("usePty must be used within a PtyProvider");return n}function hte(n){var d;const e=V.c(11),t=tb();let s;if(e[0]!==t.sessions){s=new Map;for(const f of t.sessions)((d=f.metadata)==null?void 0:d.type)==="script"&&s.set(f.id,{id:f.id,name:f.name,cwd:f.cwd,status:f.status==="running"?"running":"stopped",source:f.metadata.source??"root/"});e[0]=t.sessions,e[1]=s}else s=e[1];const r=s;let o;e[2]!==n||e[3]!==t?(o=(f,m,p)=>{const h=t.spawnScript({name:f,cwd:m,source:p,scriptName:f}),g=p==="root/"?f:`${p.replace(/\/$/,"")}:${f}`;n==null||n({id:h,name:g,type:"script",status:"running",source:p})},e[2]=n,e[3]=t,e[4]=o):o=e[4];const i=o;let l;e[5]!==t?(l=f=>{t.killSession(f)},e[5]=t,e[6]=l):l=e[6];const c=l;let u;return e[7]!==i||e[8]!==r||e[9]!==c?(u={runningProcesses:r,runScript:i,stopScript:c},e[7]=i,e[8]=r,e[9]=c,e[10]=u):u=e[10],u}function gte(n){const e=V.c(14),{script:t,status:s,onRun:r,onStop:o}=n,i=s==="running";let l="bg-transparent";i?l="bg-primary":s==="errored"&&(l="bg-destructive");const c=i?o:r,u=i?`Stop ${t.name}`:`Run: ${t.command}`;let d;e[0]!==l?(d=G("size-1.5 shrink-0 rounded-full",l),e[0]=l,e[1]=d):d=e[1];let f;e[2]!==d?(f=a.jsx("span",{className:d}),e[2]=d,e[3]=f):f=e[3];let m;e[4]!==t.name?(m=a.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:t.name}),e[4]=t.name,e[5]=m):m=e[5];let p;e[6]!==i?(p=i?a.jsx(ox,{"data-icon":"inline-end",className:"fill-current text-destructive"}):a.jsx(Na,{"data-icon":"inline-end",className:"opacity-0 text-muted-foreground transition-opacity group-hover:opacity-100"}),e[6]=i,e[7]=p):p=e[7];let h;return e[8]!==c||e[9]!==u||e[10]!==f||e[11]!==m||e[12]!==p?(h=a.jsxs(Q,{type:"button",variant:"ghost",size:"sm",className:"motion-list-item group w-full justify-start px-2",onClick:c,title:u,children:[f,m,p]}),e[8]=c,e[9]=u,e[10]=f,e[11]=m,e[12]=p,e[13]=h):h=e[13],h}const xte=y.memo(function(e){const t=V.c(42),{projectDir:s,onProcessStarted:r}=e,[o,i]=y.useState(!1),[l,c]=y.useState("");let u;t[0]===Symbol.for("react.memo_cache_sentinel")?(u=new Set,t[0]=u):u=t[0];const[d,f]=y.useState(u),{scripts:m,loading:p}=dte(s),{runningProcesses:h,runScript:g,stopScript:x}=hte(r);let b;if(t[1]!==m||t[2]!==l){const U=l.trim().toLowerCase(),O=U?m.filter(D=>D.name.toLowerCase().includes(U)||D.dirLabel.toLowerCase().includes(U)):m;b=new Map;for(const D of O){const B=b.get(D.dirLabel)??[];B.push(D),b.set(D.dirLabel,B)}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[U,O]of h)v.set(`${O.name}:${O.cwd}`,{id:U,status:O.status});t[4]=h,t[5]=v}else v=t[5];const j=v;if(!s||!p&&m.length===0)return null;let k;t[6]===Symbol.for("react.memo_cache_sentinel")?(k=function(O){f(D=>{const B=new Set(D);return B.has(O)?B.delete(O):B.add(O),B})},t[6]=k):k=t[6];const _=k;let N;t[7]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx("span",{className:"flex-1 text-xs font-medium text-muted-foreground",children:"Scripts"}),t[7]=N):N=t[7];let S;t[8]!==p?(S=p&&a.jsx(Pn,{className:"size-3 text-muted-foreground","aria-label":"Loading scripts"}),t[8]=p,t[9]=S):S=t[9];const C=o?"Close script search":"Search scripts";let E,T;t[10]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{i(bte),c("")},T=a.jsx(ss,{}),t[10]=E,t[11]=T):(E=t[10],T=t[11]);let $;t[12]!==o||t[13]!==C?($=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm","aria-label":C,"aria-expanded":o,onClick:E,children:T}),t[12]=o,t[13]=C,t[14]=$):$=t[14];let A;t[15]!==S||t[16]!==$?(A=a.jsxs("div",{className:"flex h-8 shrink-0 items-center gap-2 px-2",children:[N,S,$]}),t[15]=S,t[16]=$,t[17]=A):A=t[17];let R;t[18]!==o||t[19]!==l?(R=o&&a.jsx("div",{className:"motion-slide-down-in px-2 pb-2",children:a.jsx(On,{type:"search",value:l,onChange:U=>c(U.target.value),placeholder:"Filter scripts...","aria-label":"Filter scripts",className:"h-7",autoFocus:!0})}),t[18]=o,t[19]=l,t[20]=R):R=t[20];let P;t[21]!==d||t[22]!==w||t[23]!==g||t[24]!==j||t[25]!==l||t[26]!==x?(P=[...w.entries()].map(U=>{const[O,D]=U,B=d.has(O)||!!l,q=D.filter(vte),W=D.filter(yte),H=B?D:q.length>0?q:D.slice(0,1);return a.jsxs("div",{className:"flex flex-col gap-0.5 pb-1",children:[w.size>1&&a.jsx("div",{className:"truncate px-2 pt-1 text-xs text-muted-foreground",children:O}),H.map(K=>{const Z=j.get(`${K.name}:${K.dir}`);return a.jsx(gte,{script:K,status:(Z==null?void 0:Z.status)??null,onRun:()=>g(K.name,K.dir,K.dirLabel),onStop:()=>{Z&&x(Z.id)}},`${O}:${K.name}`)}),!l&&W.length>0&&a.jsx(Q,{type:"button",variant:"link",size:"sm",className:"h-auto justify-start px-2 py-1",onClick:()=>_(O),children:B?"Show less":`Show ${W.length} more`})]},O)}),t[21]=d,t[22]=w,t[23]=g,t[24]=j,t[25]=l,t[26]=x,t[27]=P):P=t[27];let z;t[28]!==w.size||t[29]!==p||t[30]!==l?(z=!p&&w.size===0&&l&&a.jsx(Ln,{className:"gap-1 p-3",children:a.jsxs(Mn,{className:"gap-1",children:[a.jsx(zn,{children:"No matching scripts"}),a.jsx(Dn,{children:"Try another name."})]})}),t[28]=w.size,t[29]=p,t[30]=l,t[31]=z):z=t[31];let L;t[32]!==P||t[33]!==z?(L=a.jsxs(Vc,{className:"min-h-0 flex-1 px-1 pb-1",children:[P,z]}),t[32]=P,t[33]=z,t[34]=L):L=t[34];let I;t[35]!==R||t[36]!==L||t[37]!==A?(I=a.jsxs("section",{className:"flex w-56 shrink-0 flex-col","aria-label":"Scripts",children:[A,R,L]}),t[35]=R,t[36]=L,t[37]=A,t[38]=I):I=t[38];let M;t[39]===Symbol.for("react.memo_cache_sentinel")?(M=a.jsx(en,{orientation:"vertical"}),t[39]=M):M=t[39];let F;return t[40]!==I?(F=a.jsxs(a.Fragment,{children:[I,M]}),t[40]=I,t[41]=F):F=t[41],F});function bte(n){return!n}function vte(n){return n.isCommon}function yte(n){return!n.isCommon}function rT({className:n,orientation:e="horizontal",...t}){return a.jsx(U$,{"data-slot":"tabs","data-orientation":e,className:G("group/tabs relative flex gap-2 data-[orientation=horizontal]:flex-col","has-[>[data-slot=tabs-content]]:grid has-[>[data-slot=tabs-content]]:grid-cols-1 [&>[data-slot=tabs-list]]:col-start-1 [&>[data-slot=tabs-list]]:row-start-1 [&>[data-slot=tabs-content]]:col-start-1 [&>[data-slot=tabs-content]]:row-start-2","data-[orientation=vertical]:has-[>[data-slot=tabs-content]]:grid-cols-[auto_minmax(0,1fr)] data-[orientation=vertical]:[&>[data-slot=tabs-content]]:col-start-2 data-[orientation=vertical]:[&>[data-slot=tabs-content]]:row-start-1",n),...t})}const wte=oo("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 oT({className:n,children:e,variant:t="default",...s}){return a.jsxs(D$,{"data-slot":"tabs-list","data-variant":t,className:G(wte({variant:t}),"relative isolate",n),...s,children:[e,a.jsx(F$,{"data-slot":"tabs-indicator","data-variant":t,className:G("pointer-events-none absolute top-0 left-0 z-0 h-(--active-tab-height) w-(--active-tab-width) translate-x-(--active-tab-left) translate-y-(--active-tab-top) transition-[translate,width,height] duration-150 ease-out motion-reduce:transition-none after:absolute after:content-['']","data-[variant=default]:after:inset-0 data-[variant=default]:after:rounded-md data-[variant=default]:after:bg-background data-[variant=default]:after:shadow-sm","data-[variant=line]:after:bg-foreground data-[variant=line]:data-[orientation=horizontal]:after:inset-x-0 data-[variant=line]:data-[orientation=horizontal]:after:-bottom-[5px] data-[variant=line]:data-[orientation=horizontal]:after:h-0.5 data-[variant=line]:data-[orientation=vertical]:after:inset-y-0 data-[variant=line]:data-[orientation=vertical]:after:-right-1 data-[variant=line]:data-[orientation=vertical]:after:w-0.5")})]})}function hl({className:n,...e}){return a.jsx(B$,{"data-slot":"tabs-trigger",className:G("relative z-10 inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 outline-none transition-[color,border-color,box-shadow,transform,scale] duration-100 ease-out group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground active:scale-[0.98] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-active:text-foreground dark:text-muted-foreground dark:hover:text-foreground dark:data-active:text-foreground motion-reduce:transition-none motion-reduce:active:scale-100 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",n),...e})}function gl({className:n,...e}){return a.jsx(z$,{"data-slot":"tabs-content",className:G("flex-1 text-sm outline-none transition-[opacity,translate] duration-150 ease-out motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none","motion-safe:data-starting-style:data-[activation-direction=left]:translate-x-[-0.25rem] motion-safe:data-starting-style:data-[activation-direction=right]:translate-x-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=left]:translate-x-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=right]:translate-x-[-0.25rem]","motion-safe:data-starting-style:data-[activation-direction=up]:translate-y-[-0.25rem] motion-safe:data-starting-style:data-[activation-direction=down]:translate-y-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=up]:translate-y-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=down]:translate-y-[-0.25rem]",n),...e})}const Ste=y.lazy(()=>nt(()=>import("./TerminalOutput-BA4pFb8E.js"),__vite__mapDeps([0,1,2,3,4])).then(n=>({default:n.TerminalOutput})));function kte({process:n}){const[e,t]=y.useState(""),[s,r]=y.useState(!1),o=y.useRef(null);return y.useEffect(()=>{if(n.type!=="task"||!n.outputPath)return;t(""),r(!1);const i=eb(`/api/task-output?path=${encodeURIComponent(n.outputPath)}`),l=i.source;return l.onopen=()=>r(!0),l.onmessage=c=>{try{const u=JSON.parse(c.data);if(u.type==="output"&&u.text){const d=HN(u.text);d&&t(f=>{const m=f+d;return m.length>1e5?m.slice(-1e5):m})}}catch{}},i.close},[n.id,n.type,n.outputPath]),y.useEffect(()=>{o.current&&(o.current.scrollTop=o.current.scrollHeight)},[e]),a.jsx("pre",{ref:o,className:"flex-1 overflow-auto bg-background px-3 py-2 font-mono text-xs leading-relaxed text-foreground whitespace-pre-wrap break-words",children:e||a.jsx("span",{className:"text-muted-foreground",children:s?"Waiting for output...":"Connecting..."})})}function jte(n){const e=V.c(34),{process:t,isActive:s,onSelectActive:r,onClose:o,mobile:i}=n,l=t.source??t.name,c=t.id,u=t.name;let d;e[0]!==s||e[1]!==r?(d=()=>{s&&r()},e[0]=s,e[1]=r,e[2]=d):d=e[2];const f=i?"gap-1 px-1.5":"gap-1.5 px-2";let m;e[3]!==f?(m=G("h-6 min-w-0 justify-start py-0 text-xs",f),e[3]=f,e[4]=m):m=e[4];let p;e[5]!==t.status?(p=t.status==="running"&&a.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full bg-success"}),e[5]=t.status,e[6]=p):p=e[6];let h;e[7]!==t.status?(h=t.status==="errored"&&a.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full bg-destructive"}),e[7]=t.status,e[8]=h):h=e[8];let g;e[9]!==t.name?(g=a.jsx("span",{className:"truncate max-w-[100px]",children:t.name}),e[9]=t.name,e[10]=g):g=e[10];const x=i&&"hidden";let b;e[11]!==x?(b=G("px-1 py-0 font-normal",x),e[11]=x,e[12]=b):b=e[12];let w;e[13]!==t.type||e[14]!==b?(w=a.jsx(Fe,{variant:"secondary",className:b,children:t.type}),e[13]=t.type,e[14]=b,e[15]=w):w=e[15];let v;e[16]!==t.id||e[17]!==t.name||e[18]!==w||e[19]!==d||e[20]!==m||e[21]!==p||e[22]!==h||e[23]!==g?(v=a.jsxs(hl,{value:c,"aria-label":u,onClick:d,className:m,children:[p,h,g,w]}),e[16]=t.id,e[17]=t.name,e[18]=w,e[19]=d,e[20]=m,e[21]=p,e[22]=h,e[23]=g,e[24]=v):v=e[24];const j=`Close ${t.name}`,k=`Close ${t.name}`;let _;e[25]===Symbol.for("react.memo_cache_sentinel")?(_=a.jsx(Mt,{"data-icon":"inline-start"}),e[25]=_):_=e[25];let N;e[26]!==o||e[27]!==j||e[28]!==k?(N=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs","aria-label":j,title:k,onClick:o,className:"mr-0.5 text-muted-foreground",children:_}),e[26]=o,e[27]=j,e[28]=k,e[29]=N):N=e[29];let S;return e[30]!==l||e[31]!==v||e[32]!==N?(S=a.jsxs("div",{title:l,className:"inline-flex h-6 shrink-0 items-center",children:[v,N]}),e[30]=l,e[31]=v,e[32]=N,e[33]=S):S=e[33],S}const iT=100,aT=600,Nte=200,lT="process-panel-height";function Cte(){try{const n=localStorage.getItem(lT);if(n)return Math.min(aT,Math.max(iT,Number(n)))}catch{}return Nte}const _te=y.memo(function(e){const t=V.c(89),{processes:s,activeProcessId:r,collapsed:o,onSetActive:i,onRemove:l,onToggleCollapse:c,onRequestTerminal:u,onAddTerminalContext:d,onUpdateStatus:f,projectDir:m,onProcessStarted:p,mobile:h}=e,g=h===void 0?!1:h,x=tb(),[b,w]=y.useState(Cte),v=y.useRef(null);let j,k;t[0]!==f||t[1]!==x.sessions?(j=()=>{for(const ce of x.sessions)ce.status==="exited"&&(f==null||f(ce.id,"stopped"))},k=[x.sessions,f],t[0]=f,t[1]=x.sessions,t[2]=j,t[3]=k):(j=t[2],k=t[3]),y.useEffect(j,k);let _;t[4]!==l||t[5]!==x?(_=ce=>{ce.type!=="task"&&x.killSession(ce.id),l(ce.id)},t[4]=l,t[5]=x,t[6]=_):_=t[6];const N=_;let S;t[7]!==b?(S=ce=>{ce.preventDefault(),v.current={startY:ce.clientY,startH:b},ce.target.setPointerCapture(ce.pointerId)},t[7]=b,t[8]=S):S=t[8];const C=S;let E;t[9]===Symbol.for("react.memo_cache_sentinel")?(E=ce=>{if(!v.current)return;const he=v.current.startY-ce.clientY,ge=Math.min(aT,Math.max(iT,v.current.startH+he));w(ge)},t[9]=E):E=t[9];const T=E;let $;t[10]!==b?($=()=>{if(v.current){v.current=null;try{localStorage.setItem(lT,String(b))}catch{}}},t[10]=b,t[11]=$):$=t[11];const A=$;let R;t[12]!==r||t[13]!==s?(R=r?s.get(r):null,t[12]=r,t[13]=s,t[14]=R):R=t[14];const P=R;let z;t[15]!==s?(z=[...s.values()],t[15]=s,t[16]=z):z=t[16];const L=z;let I;t[17]!==i?(I=ce=>{typeof ce=="string"&&i(ce)},t[17]=i,t[18]=I):I=t[18];let M;t[19]!==P||t[20]!==o||t[21]!==g||t[22]!==C||t[23]!==A?(M=!g&&!o&&P&&a.jsx("div",{className:"h-1 cursor-row-resize transition-colors hover:bg-accent active:bg-muted-foreground/30",onPointerDown:C,onPointerMove:T,onPointerUp:A,onPointerCancel:A}),t[19]=P,t[20]=o,t[21]=g,t[22]=C,t[23]=A,t[24]=M):M=t[24];const F=g?"h-7 gap-1 px-2":"h-8 gap-2 px-3";let U;t[25]!==F?(U=G("flex shrink-0 items-center border-b bg-card",F),t[25]=F,t[26]=U):U=t[26];const O=o?"Expand terminal panel":"Collapse terminal panel",D=!o;let B;t[27]!==o?(B=o?a.jsx(it,{"data-icon":"inline-start"}):a.jsx(_t,{"data-icon":"inline-start"}),t[27]=o,t[28]=B):B=t[28];const q=g&&"sr-only";let W;t[29]!==q?(W=G(q),t[29]=q,t[30]=W):W=t[30];let H;t[31]!==W?(H=a.jsx("span",{className:W,children:"Terminal"}),t[31]=W,t[32]=H):H=t[32];let K;t[33]!==c||t[34]!==O||t[35]!==D||t[36]!==B||t[37]!==H?(K=a.jsxs(Q,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2",onClick:c,"aria-label":O,"aria-expanded":D,children:[B,H]}),t[33]=c,t[34]=O,t[35]=D,t[36]=B,t[37]=H,t[38]=K):K=t[38];const Z=!g&&"ml-2";let Y;t[39]!==Z?(Y=G("min-w-0 flex-1 justify-start overflow-x-auto no-scrollbar",Z),t[39]=Z,t[40]=Y):Y=t[40];let X;t[41]!==r||t[42]!==N||t[43]!==g||t[44]!==i||t[45]!==L?(X=L.map(ce=>a.jsx(jte,{process:ce,isActive:ce.id===r,onSelectActive:()=>i(ce.id),onClose:()=>N(ce),mobile:g},ce.id)),t[41]=r,t[42]=N,t[43]=g,t[44]=i,t[45]=L,t[46]=X):X=t[46];let ee;t[47]!==Y||t[48]!==X?(ee=a.jsx(oT,{variant:"default","aria-label":"Open processes",className:Y,children:X}),t[47]=Y,t[48]=X,t[49]=ee):ee=t[49];let te;t[50]!==u||t[51]!==m?(te=u&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",disabled:!m,onClick:u,"aria-label":"New terminal",title:m?"New terminal":"Open a project to start a terminal",children:a.jsx(Sr,{})}),t[50]=u,t[51]=m,t[52]=te):te=t[52];let se;t[53]!==U||t[54]!==K||t[55]!==ee||t[56]!==te?(se=a.jsxs("div",{className:U,children:[K,ee,te]}),t[53]=U,t[54]=K,t[55]=ee,t[56]=te,t[57]=se):se=t[57];const J=!o,ne=g?"min(36dvh, 260px)":b;let ie;t[58]!==ne?(ie={height:ne},t[58]=ne,t[59]=ie):ie=t[59];let ae;t[60]!==g||t[61]!==p||t[62]!==m?(ae=!g&&a.jsx(xte,{projectDir:m,onProcessStarted:p}),t[60]=g,t[61]=p,t[62]=m,t[63]=ae):ae=t[63];let oe;t[64]!==N||t[65]!==d||t[66]!==u||t[67]!==L?(oe=L.map(ce=>a.jsx(gl,{value:ce.id,className:"col-start-1 row-start-1 flex min-h-0 flex-col",children:ce.type==="task"?a.jsx(kte,{process:ce}):a.jsx(y.Suspense,{fallback:a.jsx("div",{className:"flex size-full items-center justify-center text-xs text-muted-foreground",children:"Loading terminal…"}),children:a.jsx(Ste,{processId:ce.id,autoFocus:!0,onRequestNew:u,onRequestClose:()=>N(ce),onAddContext:d})})},ce.id)),t[64]=N,t[65]=d,t[66]=u,t[67]=L,t[68]=oe):oe=t[68];let ue;t[69]!==P||t[70]!==u||t[71]!==m?(ue=!P&&a.jsxs(Ln,{className:"col-start-1 row-start-1 rounded-none",children:[a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:a.jsx(Ca,{})}),a.jsx(zn,{children:"No terminal open"}),a.jsx(Dn,{children:"Start a terminal here or run a project script from the left."})]}),u&&m&&a.jsx(_c,{children:a.jsxs(Q,{type:"button",size:"sm",onClick:u,children:[a.jsx(Sr,{"data-icon":"inline-start"}),"New terminal"]})})]}),t[69]=P,t[70]=u,t[71]=m,t[72]=ue):ue=t[72];let re;t[73]!==oe||t[74]!==ue?(re=a.jsxs("div",{className:"grid min-h-0 min-w-0 flex-1 grid-cols-1",children:[oe,ue]}),t[73]=oe,t[74]=ue,t[75]=re):re=t[75];let de;t[76]!==ie||t[77]!==ae||t[78]!==re?(de=a.jsx(yn,{children:a.jsxs("div",{className:"flex min-h-0",style:ie,children:[ae,re]})}),t[76]=ie,t[77]=ae,t[78]=re,t[79]=de):de=t[79];let fe;t[80]!==J||t[81]!==de?(fe=a.jsx(vn,{open:J,className:"min-h-0",children:de}),t[80]=J,t[81]=de,t[82]=fe):fe=t[82];let le;return t[83]!==r||t[84]!==I||t[85]!==M||t[86]!==se||t[87]!==fe?(le=a.jsxs(rT,{value:r,onValueChange:I,className:"shrink-0 gap-0 border-t bg-background",children:[M,se,fe]}),t[83]=r,t[84]=I,t[85]=M,t[86]=se,t[87]=fe,t[88]=le):le=t[88],le});function Hc(n){const e=V.c(2),{children:t}=n;let s;return e[0]!==t?(s=a.jsx("h3",{className:"mb-3 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:t}),e[0]=t,e[1]=s):s=e[1],s}const Ete=/(?::(\d{4,5}))|(?:port\s+(\d{4,5}))|(?:localhost:(\d{4,5}))/gi;function Tte(n){const e=new Set;for(const t of n.matchAll(Ete)){const s=parseInt(t[1]||t[2]||t[3],10);s>0&&s<65536&&e.add(s)}return[...e]}function Ate(n){var s;const e=V.c(2);let t;if(e[0]!==n){t=new Map;for(let r=0;r<n.length;r++)for(const o of n[r].toolCalls){if(o.name!=="Bash"||!o.input.run_in_background)continue;const i=o.input.command||"",l=o.input.description||"",c=((s=n[r].assistantText)==null?void 0:s.join(" "))||"",u=[i,l,o.result||"",c].join(" "),d=Tte(u);if(d.length===0){const p=i.toLowerCase();(p.includes("run dev")||p.includes("next dev")||p.includes("vite"))&&d.push(3e3)}const f=(o.result||"").match(/Output is being written to:\s*(\S+)/),m=f?f[1]:null;for(const p of d)t.set(p,{description:l||i.replace(/^cd\s+"[^"]*"\s*&&\s*/,"").slice(0,60),outputPath:m})}e[0]=n,e[1]=t}else t=e[1];return t}function xk(n){var e;return((e=n.preview.split(`
335
335
  `).find(t=>t.trim()))==null?void 0:e.trim())||`Task ${n.id}`}function Ite(n){const e=V.c(10),{port:t,isActive:s}=n,r=s?"bg-success":"bg-muted-foreground/40";let o;e[0]!==r?(o=G("inline-block size-1.5 rounded-full",r),e[0]=r,e[1]=o):o=e[1];let i;e[2]!==o?(i=a.jsx("span",{className:o}),e[2]=o,e[3]=i):i=e[3];const l=s?"text-success":"text-muted-foreground";let c;e[4]!==t||e[5]!==l?(c=a.jsxs("span",{className:l,children:[":",t]}),e[4]=t,e[5]=l,e[6]=c):c=e[6];let u;return e[7]!==i||e[8]!==c?(u=a.jsxs(Fe,{variant:"secondary",className:"font-mono",children:[i,c]}),e[7]=i,e[8]=c,e[9]=u):u=e[9],u}function cT({cwd:n,turns:e,canStop:t=!1,onToggleServer:s,onServersChanged:r}){const[o,i]=y.useState([]),l=Ate(e),c=y.useRef(l);y.useLayoutEffect(()=>{c.current=l},[l]);const u=y.useCallback(async f=>{const m=p=>{f()&&i(h=>JSON.stringify(h)===JSON.stringify(p)?h:p)};try{const p=await Ce(`/api/background-tasks?cwd=${encodeURIComponent(n)}`);if(!f())return;if(p.ok){const w=await p.json();if(!f())return;if(w.length>0){m(w);return}}const h=c.current;if(h.size===0){m([]);return}const g=await Ce(`/api/check-ports?ports=${[...h.keys()].join(",")}`);if(!g.ok||!f())return;const x=await g.json(),b=[];for(const[w,v]of h)x[w]&&b.push({id:`port-${w}`,outputPath:v.outputPath,ports:[w],portStatus:{[w]:!0},preview:v.description});m(b)}catch{}},[n]);Ra(n?u:null,1e4);const d=y.useCallback(async f=>{try{await Ce("/api/kill-port",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({port:f})}),setTimeout(()=>{i(m=>m.filter(p=>!p.ports.includes(f)))},1500)}catch{}},[]);return y.useEffect(()=>{if(!r)return;const f=o.filter(m=>m.outputPath).map(m=>({id:m.id,outputPath:m.outputPath,title:xk(m)}));r(f)},[o,r]),o.length===0?null:a.jsxs("section",{children:[a.jsxs(Hc,{children:["Active Servers (",o.length,")"]}),a.jsx("div",{className:"flex flex-col gap-1.5",children:o.map(f=>{const m=f.ports.filter(h=>f.portStatus[h]),p=xk(f);return a.jsxs("div",{className:"border-b border-border px-2 py-2 last:border-b-0",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(ax,{className:"size-3 shrink-0 text-success","data-icon":"inline-start"}),a.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:p})]}),a.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[f.ports.map(h=>a.jsx(Ite,{port:h,isActive:f.portStatus[h]},h)),a.jsx("div",{className:"flex-1"}),f.outputPath&&a.jsx(Q,{variant:"ghost",size:"icon-xs",onClick:()=>s==null?void 0:s(f.id,f.outputPath,p),title:"View server output","aria-label":"View server output",children:a.jsx(Ca,{"data-icon":"inline-start"})}),t&&m.length>0&&a.jsxs(Q,{variant:"ghost",size:"xs",className:"text-destructive",onClick:()=>m.forEach(h=>d(h)),title:"Stop server","aria-label":"Stop server",children:[a.jsx(ox,{"data-icon":"inline-start",className:"fill-current"}),a.jsx("span",{children:"Stop"})]})]})]},f.id)})})]})}function nb(n){const e=V.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(W$,{"data-slot":"alert-dialog",...t}),e[2]=t,e[3]=s):s=e[3],s}function Pte(n){const e=V.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(q$,{"data-slot":"alert-dialog-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function $te(n){const e=V.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(ex,{"data-slot":"alert-dialog-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function Rte(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("fixed inset-0 isolate z-50 bg-black/55 duration-150 ease-out data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0 data-closed:duration-100 data-closed:ease-in motion-reduce:animate-none",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(tx,{"data-slot":"alert-dialog-overlay",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function sb(n){const e=V.c(11);let t,s,r;e[0]!==n?({className:t,size:r,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);const o=r===void 0?"default":r;let i;e[4]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx(Rte,{}),e[4]=i):i=e[4];let l;e[5]!==t?(l=G("group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl border bg-popover p-4 text-popover-foreground shadow-lg duration-150 ease-out outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-100 data-closed:ease-in motion-reduce:animate-none",t),e[5]=t,e[6]=l):l=e[6];let c;return e[7]!==s||e[8]!==o||e[9]!==l?(c=a.jsxs($te,{children:[i,a.jsx(X1,{"data-slot":"alert-dialog-content","data-size":o,className:l,...s})]}),e[7]=s,e[8]=o,e[9]=l,e[10]=c):c=e[10],c}function rb(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"alert-dialog-header",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function ob(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"alert-dialog-footer",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Ote(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("mb-2 inline-flex size-10 items-center justify-center rounded-md bg-muted sm:group-data-[size=default]/alert-dialog-content:row-span-2 *:[svg:not([class*='size-'])]:size-6",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"alert-dialog-media",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function ib(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(J1,{"data-slot":"alert-dialog-title",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function ab(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(Q1,{"data-slot":"alert-dialog-description",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function lb(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G(t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(Q,{"data-slot":"alert-dialog-action",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function cb(n){const e=V.c(14);let t,s,r,o;e[0]!==n?({className:t,variant:r,size:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);const i=r===void 0?"outline":r,l=o===void 0?"default":o;let c;e[5]!==t?(c=G(t),e[5]=t,e[6]=c):c=e[6];let u;e[7]!==l||e[8]!==i?(u=a.jsx(Q,{variant:i,size:l}),e[7]=l,e[8]=i,e[9]=u):u=e[9];let d;return e[10]!==s||e[11]!==c||e[12]!==u?(d=a.jsx(bc,{"data-slot":"alert-dialog-cancel",className:c,render:u,...s}),e[10]=s,e[11]=c,e[12]=u,e[13]=d):d=e[13],d}function uT(n){const e=V.c(9);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input outline-none transition-[color,background-color,border-color,box-shadow,transform,scale] duration-100 ease-out active:scale-90 group-has-disabled/field:opacity-50 group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary bg-background dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary motion-reduce:transition-none motion-reduce:active:scale-100",t),e[3]=t,e[4]=r):r=e[4];let o;e[5]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(H$,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-[opacity,transform,scale] duration-100 ease-out motion-safe:data-starting-style:scale-75 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:scale-75 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none [&>svg]:size-3.5",children:a.jsx(nn,{})}),e[5]=o):o=e[5];let i;return e[6]!==s||e[7]!==r?(i=a.jsx(V$,{"data-slot":"checkbox",className:r,...s,children:o}),e[6]=s,e[7]=r,e[8]=i):i=e[8],i}const Lte={undo:"Undo turns?",redo:"Redo turns?","branch-switch":"Switch branch?"},Mte={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 zte({state:n,isApplying:e,applyError:t,onConfirm:s,onCancel:r}){var f,m;const o=y.useRef(n),[i,l]=y.useState({key:"",selected:!1});y.useEffect(()=>{n&&(o.current=n)},[n]);const c=n??o.current;if(!c)return null;const u=((f=c.nativeRewind)==null?void 0:f.eventId)??`${c.type}:${c.targetTurnIndex}:${c.branchId??""}`,d=i.key===u&&i.selected;return a.jsx(nb,{open:n!==null,onOpenChange:p=>{p||r()},onOpenChangeComplete:p=>{p||(o.current=null,l({key:"",selected:!1}))},children:a.jsxs(sb,{children:[a.jsxs(rb,{children:[a.jsx(Ote,{children:a.jsx(Ir,{className:"text-warning"})}),a.jsx(ib,{children:Lte[c.type]}),a.jsx(ab,{children:c.nativeRewind?d?"This removes the selected turn and everything after it, restoring captured files.":"This removes the selected turn and everything after it. Files stay unchanged.":Mte[c.type]})]}),a.jsxs("div",{className:"flex flex-col gap-2 py-2",children:[a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("span",{className:"text-muted-foreground",children:"Turns affected"}),a.jsx("span",{className:"text-foreground font-mono",children:c.summary.turnCount})]}),a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("span",{className:"text-muted-foreground",children:"Files affected"}),a.jsx("span",{className:"text-foreground font-mono",children:c.summary.fileCount})]}),a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("span",{className:"text-muted-foreground",children:"Operations"}),a.jsx("span",{className:"text-foreground font-mono",children:c.summary.operationCount})]}),c.summary.filePaths.length>0&&a.jsx("div",{className:"mt-2 max-h-32 overflow-y-auto rounded-md border bg-muted/30 p-2",children:c.summary.filePaths.map(p=>a.jsx("div",{className:"truncate font-mono text-xs text-muted-foreground",children:p},p))}),((m=c.nativeRewind)==null?void 0:m.filesAvailable)&&a.jsxs("label",{className:"mt-2 flex items-center gap-2 text-sm text-foreground",children:[a.jsx(uT,{checked:d,disabled:e,onCheckedChange:p=>l({key:u,selected:p===!0})}),"Restore captured file changes"]})]}),t&&a.jsx(jt,{variant:"destructive",children:a.jsx(Rt,{children:t})}),a.jsxs(ob,{children:[a.jsx(cb,{onClick:r,disabled:e,children:"Cancel"}),a.jsx(lb,{onClick:()=>s(d),disabled:e,children:e?a.jsxs(a.Fragment,{children:[a.jsx(St,{"data-icon":"inline-start",className:"animate-spin"}),"Applying..."]}):c.type==="undo"?"Undo":c.type==="redo"?"Redo":"Switch"})]})]})})}function Ds(n){const e=V.c(10);let t,s,r;e[0]!==n?({className:t,size:r,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);const o=r===void 0?"default":r;let i;e[4]!==t?(i=G("group/card flex flex-col gap-4 overflow-hidden rounded-xl bg-card py-4 text-sm text-card-foreground ring-1 ring-foreground/10 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",t),e[4]=t,e[5]=i):i=e[5];let l;return e[6]!==s||e[7]!==o||e[8]!==i?(l=a.jsx("div",{"data-slot":"card","data-size":o,className:i,...s}),e[6]=s,e[7]=o,e[8]=i,e[9]=l):l=e[9],l}function gr(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"card-header",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function xr(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"card-title",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function br(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-sm text-muted-foreground",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"card-description",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Dte(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("col-start-2 row-span-2 row-start-1 self-start justify-self-end",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"card-action",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Fs(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("px-4 group-data-[size=sm]/card:px-3",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"card-content",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function um(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex items-center rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/card:p-3",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"card-footer",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Ko(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto bg-background dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"input-group",role:"group",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}const Fte=oo("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 Tr(n){const e=V.c(11);let t,s,r;e[0]!==n?({className:t,align:r,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);const o=r===void 0?"inline-start":r;let i;e[4]!==o||e[5]!==t?(i=G(Fte({align:o}),t),e[4]=o,e[5]=t,e[6]=i):i=e[6];let l;return e[7]!==o||e[8]!==s||e[9]!==i?(l=a.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":o,className:i,onClick:Ute,...s}),e[7]=o,e[8]=s,e[9]=i,e[10]=l):l=e[10],l}function Ute(n){var e,t;n.target.closest("button")||(t=(e=n.currentTarget.parentElement)==null?void 0:e.querySelector("input"))==null||t.focus()}const Bte=oo("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 dm(n){const e=V.c(15);let t,s,r,o,i;e[0]!==n?({className:t,type:r,variant:o,size:i,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5]);const l=r===void 0?"button":r,c=o===void 0?"ghost":o,u=i===void 0?"xs":i;let d;e[6]!==t||e[7]!==u?(d=G(Bte({size:u}),t),e[6]=t,e[7]=u,e[8]=d):d=e[8];let f;return e[9]!==s||e[10]!==u||e[11]!==d||e[12]!==l||e[13]!==c?(f=a.jsx(Q,{type:l,"data-size":u,variant:c,className:d,...s}),e[9]=s,e[10]=u,e[11]=d,e[12]=l,e[13]=c,e[14]=f):f=e[14],f}function Go(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(On,{"data-slot":"input-group-control",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Wte(){const[n,e]=y.useState("idle"),[t,s]=y.useState(null),r=y.useRef(void 0),o=y.useCallback(async u=>{if(!u.trim()){e("idle"),s(null);return}e("validating"),s(null);try{const f=await(await Ce(`/api/config/validate?path=${encodeURIComponent(u)}`)).json();f.valid?(e("valid"),s(null)):(e("invalid"),s(f.error||"Invalid path"))}catch{e("invalid"),s("Failed to validate path")}},[]),i=y.useCallback(u=>{clearTimeout(r.current),r.current=setTimeout(()=>o(u),400)},[o]),l=y.useCallback(()=>{e("idle"),s(null),clearTimeout(r.current)},[]),c=y.useCallback(async(u,d)=>{try{const f=await Ce("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({claudeDir:u,...d})}),m=await f.json();return f.ok&&m.success?{success:!0,claudeDir:m.claudeDir}:(s(m.error||"Failed to save"),e("invalid"),{success:!1,error:m.error})}catch{return s("Failed to save configuration"),{success:!1,error:"Network error"}}},[]);return y.useEffect(()=>()=>clearTimeout(r.current),[]),{status:n,error:t,debouncedValidate:i,validate:o,reset:l,save:c}}const Ui=rR(n=>!n.cli.homeIsDiscoverable,"a home Cogpit has to be told about"),dT=Sc().filter(n=>n.cli.homeIsDiscoverable&&!n.cli.requiresConfiguration);function fT(n){return n.flatMap((e,t)=>t===0?[e]:[t===n.length-1?" and ":", ",e])}function mT(n){const e=V.c(2),{children:t}=n;let s;return e[0]!==t?(s=a.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-xs text-foreground",children:t}),e[0]=t,e[1]=s):s=e[1],s}const qte=fT(dT.map(n=>n.displayName)),Vte=fT(dT.map(n=>a.jsx(mT,{children:["~",n.cli.homeDirName,n.cli.installMarker].filter(Boolean).join("/")},n.kind))),Hte=`~/${Ui.cli.homeDirName}`;function Kte(n){const e=V.c(46),{onConfigured:t}=n,[s,r]=y.useState(""),[o,i]=y.useState(!1),{status:l,error:c,debouncedValidate:u,save:d}=Wte();let f;e[0]!==u?(f=M=>{const F=M.target.value;r(F),u(F)},e[0]=u,e[1]=f):f=e[1];const m=f;let p;e[2]!==t||e[3]!==s||e[4]!==d?(p=async()=>{i(!0);const M=await d(s);M.success&&M.claudeDir&&t(M.claudeDir),i(!1)},e[2]=t,e[3]=s,e[4]=d,e[5]=p):p=e[5];const h=p;let g;e[6]!==h||e[7]!==o||e[8]!==l?(g=M=>{M.preventDefault(),l==="valid"&&!o&&h()},e[6]=h,e[7]=o,e[8]=l,e[9]=g):g=e[9];let x,b;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=a.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:a.jsx(rx,{className:"size-4"})}),b=a.jsx(xr,{children:"Connect your coding agent"}),e[10]=x,e[11]=b):(x=e[10],b=e[11]);let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=a.jsxs(gr,{children:[x,b,a.jsxs(br,{children:["Cogpit detects ",qte," automatically. Existing histories live in"," ",Vte,"."," ","For ",Ui.displayName,", enter its data directory, usually"," ",a.jsx(mT,{children:Hte}),"."]})]}),e[12]=w):w=e[12];const v=l==="invalid";let j;e[13]===Symbol.for("react.memo_cache_sentinel")?(j=a.jsxs(mn,{htmlFor:"agent-data-directory",children:[Ui.displayName," data directory"]}),e[13]=j):j=e[13];let k;e[14]===Symbol.for("react.memo_cache_sentinel")?(k=a.jsx(Tr,{children:a.jsx(Zr,{"aria-hidden":"true"})}),e[14]=k):k=e[14];const _=l==="invalid";let N;e[15]!==m||e[16]!==s||e[17]!==_?(N=a.jsxs(Ko,{children:[k,a.jsx(Go,{id:"agent-data-directory",value:s,onChange:m,placeholder:`/Users/you/${Ui.cli.homeDirName}`,autoFocus:!0,"aria-invalid":_,"aria-describedby":"agent-directory-status"})]}),e[15]=m,e[16]=s,e[17]=_,e[18]=N):N=e[18];let S;e[19]!==l?(S=l==="validating"&&a.jsxs(ia,{className:"flex items-center gap-2",children:[a.jsx(Pn,{className:"size-4"}),"Checking path..."]}),e[19]=l,e[20]=S):S=e[20];let C;e[21]!==l?(C=l==="valid"&&a.jsxs(ia,{className:"flex items-center gap-2 text-success",children:[a.jsx(wf,{className:"size-4"}),Ui.displayName," history found"]}),e[21]=l,e[22]=C):C=e[22];let E;e[23]!==c||e[24]!==l?(E=l==="invalid"&&c&&a.jsxs(_o,{className:"flex items-center gap-2",children:[a.jsx(Bo,{className:"size-4"}),c]}),e[23]=c,e[24]=l,e[25]=E):E=e[25];let T;e[26]!==S||e[27]!==C||e[28]!==E?(T=a.jsxs("div",{id:"agent-directory-status",className:"min-h-5",role:"status","aria-live":"polite",children:[S,C,E]}),e[26]=S,e[27]=C,e[28]=E,e[29]=T):T=e[29];let $;e[30]!==N||e[31]!==T||e[32]!==v?($=a.jsx(Fs,{children:a.jsx(Ta,{children:a.jsxs(fn,{"data-invalid":v,children:[j,N,T]})})}),e[30]=N,e[31]=T,e[32]=v,e[33]=$):$=e[33];const A=l!=="valid"||o;let R;e[34]!==o?(R=o&&a.jsx(Pn,{"data-icon":"inline-start"}),e[34]=o,e[35]=R):R=e[35];const P=o?"Saving...":`Connect ${Ui.displayName}`;let z;e[36]!==A||e[37]!==R||e[38]!==P?(z=a.jsx(um,{children:a.jsxs(Q,{type:"submit",className:"w-full",disabled:A,children:[R,P]})}),e[36]=A,e[37]=R,e[38]=P,e[39]=z):z=e[39];let L;e[40]!==$||e[41]!==z?(L=a.jsxs(Ds,{children:[w,$,z]}),e[40]=$,e[41]=z,e[42]=L):L=e[42];let I;return e[43]!==L||e[44]!==g?(I=a.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-canvas px-4 py-8 text-foreground",children:a.jsx("form",{className:"w-full max-w-lg",onSubmit:g,children:L})}),e[43]=L,e[44]=g,e[45]=I):I=e[45],I}const bk={0:"\0",b:"\b",f:"\f",n:`
336
336
  `,r:"\r",t:" ",v:"\v"};function Gte(n){return!!(n&&/[A-Za-z_$]/.test(n))}function sf(n){return!!(n&&/[\w$]/.test(n))}function Ar(n,e){const t=n[e];if(t!=='"'&&t!=="'"&&t!=="`")return null;let s="",r=e+1;for(;r<n.length;){const o=n[r];if(o===t)return{endIndex:r+1,value:s};if(o!=="\\"){s+=o,r++;continue}if(r++,r>=n.length)return null;const i=n[r];if(i in bk){s+=bk[i],r++;continue}if(i===`
337
337
  `){r++;continue}if(i==="\r"){r+=n[r+1]===`
@@ -370,7 +370,7 @@ ${e}`:e)}function Tse(n){return typeof n=="string"&&(n==="abort"||n==="binary_as
370
370
  `),{skipStats:!0}).turns;return s.length!==t.length?null:t.map((r,o)=>({line:r,id:s[o].id}))}function Mse(n){return fb(n)?yT(n.input):[n]}function zse(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 Dse(n,e){const t=n.contentBlocks,s=t.findIndex(r=>r.kind==="tool_calls"&&r.toolCalls.some(o=>o.id===e));return s===-1?!1:t.slice(s+1).some(r=>r.kind==="text"||r.kind==="thinking"||r.kind==="tool_calls")}function Fse(n){for(let e=n.toolCalls.length-1;e>=0;e--){const t=n.toolCalls[e];if(!t.asyncQuestion||t.isError)continue;if(t.asyncAnswer!==void 0)return null;const s=t.input.questions;if(s&&s.length>0)return{type:"question",toolUseId:t.id,questions:s}}return null}function Use(n,e){const t=e.toolCalls[e.toolCalls.length-1];if(!t||t.asyncQuestion)return null;const{name:s}=t;if(s!=="ExitPlanMode"&&s!=="AskUserQuestion"||t.result!==null&&!t.isError||zse(n,s)||t.isError&&Dse(e,t.id))return null;const r=t.input;if(s==="ExitPlanMode")return{type:"plan",allowedPrompts:r.allowedPrompts};const o=r.questions;return o&&o.length>0?{type:"question",toolUseId:t.id,questions:o}:null}function r6(n){const{turns:e}=n;if(e.length===0)return null;const t=e[e.length-1];return!t||t.toolCalls.length===0?null:Use(e,t)??Fse(t)}function Bse(n){return typeof n=="string"?n:n.filter(e=>e.type==="text").map(e=>e.text).join(`
371
371
  `)}function xm(n,e){return t6(n).parse(n,e)}function Wse(n,e){const t=n6(n.rawMessages),r=(t.kind===XT?t6(e):t).append(n,e);return n.instanceId?ra(r,n.instanceId):r}function za(n){return n===null?"":typeof n=="string"?n:Bse(n)}function o6(n){return n===null||typeof n=="string"?[]:n.filter(e=>e.type==="image")}const i6=/^[a-z]:[\\/]/i;function vb(n){return(i6.test(n)?n.replace(/\\/g,"/"):n).replace(/\/+$/,"")||"/"}function Bk(n){const e=vb(n);return i6.test(n)?e.toLowerCase():e}function qse(n){const e=vb(n),t=e.lastIndexOf("/");return t<0?e:t===0?"/":e.slice(0,t)}function j1(n,e){const t=Bk(n),s=Bk(e);if(t===s)return"";const r=t==="/"?"/":`${t}/`;return s.startsWith(r)?vb(e).slice(r.length):null}let yb=!1;function Vse(n){yb=n}function wb(){return yb}let Dl=null;function Hse(n){return Dl=n,()=>{Dl===n&&(Dl=null)}}function Kse(n,e){if(!n.path)return null;if(n.kind==="project")return{root:n.path,file:null,mode:"edit"};if(e){const r=j1(e,n.path);if(r)return{root:e,file:r,mode:Wk(n),line:n.line}}const t=qse(n.path),s=j1(t,n.path);return s?{root:t,file:s,mode:Wk(n),line:n.line}:null}function Wk(n){return n.mode==="diff"?"diff":"edit"}function a6(n){return yb&&Dl!==null&&Dl(n)}function l6(n,e){is(n,e).catch(()=>{})}function cc(n,e={}){if(xt("hostFiles")&&!a6({kind:"file",path:n,...e})){if(qo()){Pf(n);return}l6("/api/open-in-editor",{path:n,mode:e.mode??"file",line:e.line,column:e.column})}}function c6(n){xt("hostFiles")&&(n.path&&a6({kind:"project",path:n.path})||d6("/api/open-in-editor",n))}function u6(n){xt("hostFiles")&&d6("/api/reveal-in-folder",n)}function d6(n,e){!e.path&&!e.dirName||l6(n,{path:e.path||void 0,dirName:e.dirName||void 0})}const Gse=1500;function no(){const n=V.c(5),[e,t]=y.useState(!1),s=y.useRef(null),r=y.useRef(!0);let o,i;n[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>(r.current=!0,()=>{r.current=!1,s.current&&clearTimeout(s.current)}),i=[],n[0]=o,n[1]=i):(o=n[0],i=n[1]),y.useEffect(o,i);let l;n[2]===Symbol.for("react.memo_cache_sentinel")?(l=async d=>{!await Pf(d)||!r.current||(t(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>t(!1),Gse))},n[2]=l):l=n[2];const c=l;let u;return n[3]!==e?(u=[e,c],n[3]=e,n[4]=u):u=n[4],u}function Gc(){const n=V.c(2),[e,t]=y.useState(Zse);let s,r;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{const o=document.documentElement,i=()=>t(o.classList.contains("dark")),l=new MutationObserver(i);return l.observe(o,{attributes:!0,attributeFilter:["class"]}),()=>l.disconnect()},r=[],n[0]=s,n[1]=r):(s=n[0],r=n[1]),y.useEffect(s,r),e}function Zse(){return typeof document<"u"&&document.documentElement.classList.contains("dark")}let Ih=null;const N1=new Set,Uu=new Map,qk=["typescript","tsx","javascript","jsx","json","css","html","python","bash","yaml","markdown"],f6={typescript:()=>nt(()=>import("./typescript-BPQ3VLAy.js"),[]),tsx:()=>nt(()=>import("./tsx-COt5Ahok.js"),[]),javascript:()=>nt(()=>import("./javascript-wDzz0qaB.js"),[]),jsx:()=>nt(()=>import("./jsx-g9-lgVsj.js"),[]),json:()=>nt(()=>import("./json-Cp-IABpG.js"),[]),css:()=>nt(()=>import("./css-DPfMkruS.js"),[]),html:()=>nt(()=>import("./html-GMplVEZG.js"),__vite__mapDeps([5,6,7])),python:()=>nt(()=>import("./python-B6aJPvgy.js"),[]),bash:()=>nt(()=>import("./bash-Yzrsuije.js"),[]),yaml:()=>nt(()=>import("./yaml-Buea-lGh.js"),[]),markdown:()=>nt(()=>import("./markdown-Cvjx9yec.js"),[]),rust:()=>nt(()=>import("./rust-B1yitclQ.js"),[]),go:()=>nt(()=>import("./go-CxLEBnE3.js"),[]),toml:()=>nt(()=>import("./toml-vGWfd6FD.js"),[]),sql:()=>nt(()=>import("./sql-BLtJtn59.js"),[]),c:()=>nt(()=>import("./c-BIGW1oBm.js"),[]),cpp:()=>nt(()=>import("./cpp-BRuaLJcg.js"),__vite__mapDeps([8,9,10])),java:()=>nt(()=>import("./java-CylS5w8V.js"),[]),ruby:()=>nt(()=>import("./ruby-B0Tyh1qT.js"),__vite__mapDeps([11,5,6,7,12,13,10,14,15,16,8,9,17,18])),swift:()=>nt(()=>import("./swift-D82vCrfD.js"),[]),kotlin:()=>nt(()=>import("./kotlin-BdnUsdx6.js"),[]),php:()=>nt(()=>import("./php-aq0itWAE.js"),__vite__mapDeps([19,5,6,7,12,13,10,20])),vue:()=>nt(()=>import("./vue-DVfSmUF7.js"),__vite__mapDeps([21,7,6,14,20,5])),svelte:()=>nt(()=>import("./svelte-DZMnMd3x.js"),__vite__mapDeps([22,6,14,7])),scss:()=>nt(()=>import("./scss-OYdSNvt2.js"),__vite__mapDeps([23,7]))};function m6(){return Ih||(Ih=(async()=>{const[n,e,...t]=await Promise.all([nt(()=>import("./github-dark-DHJKELXO.js"),[]).then(r=>r.default),nt(()=>import("./github-light-DAi9KRSo.js"),[]).then(r=>r.default),...qk.map(r=>f6[r]().then(o=>o.default))]),s=await K8({themes:[n,e],langs:t,engine:G8()});for(const r of qk)N1.add(r);return s})()),Ih}async function p6(n,e){if(N1.has(e))return;if(Uu.has(e))return Uu.get(e);const t=f6[e];if(!t)return;const s=t().then(async r=>{await n.loadLanguage(r.default),N1.add(e)}).finally(()=>Uu.delete(e));Uu.set(e,s),await s}const Yse={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 h6(n){var t;const e=((t=n.split(".").pop())==null?void 0:t.toLowerCase())??"";return Yse[e]??null}async function Xse(n,e,t){try{const s=await m6();await p6(s,e);const r=t?"github-dark":"github-light";return s.codeToTokens(n,{lang:e,theme:r}).tokens}catch{return null}}const Jse="min-w-0 max-h-96 overflow-y-auto whitespace-pre-wrap break-words [overflow-wrap:anywhere] rounded-md border bg-muted p-3 font-mono text-xs leading-relaxed text-foreground/85",Sb="min-w-0 max-h-96 overflow-auto whitespace-pre-wrap break-words [overflow-wrap:anywhere] rounded-md bg-muted p-3 font-mono text-xs leading-relaxed text-foreground/85";function bm(n,e,t){const s=V.c(5),[r,o]=y.useState(null);let i,l;return s[0]!==n||s[1]!==t||s[2]!==e?(i=()=>{if(!e)return;let c=!1;return Xse(n,e,t).then(u=>{c||o({code:n,lang:e,isDark:t,tokens:u})}).catch(Qse),()=>{c=!0}},l=[n,e,t],s[0]=n,s[1]=t,s[2]=e,s[3]=i,s[4]=l):(i=s[3],l=s[4]),y.useEffect(i,l),(r==null?void 0:r.code)===n&&r.lang===e&&r.isDark===t?r.tokens:null}function Qse(){}function kb(n){const e=V.c(13),{lines:t,tokens:s,lineNums:r,variant:o,label:i}=n,l=o==="boxed"?Jse:Sb;let c;if(e[0]!==r||e[1]!==t||e[2]!==s){let f;e[4]!==r||e[5]!==s?(f=(m,p)=>{const h=s==null?void 0:s[p];return a.jsxs("span",{className:"block",children:[(r==null?void 0:r[p])&&a.jsx("span",{className:"inline-block w-10 text-right mr-2 text-muted-foreground select-none",children:r[p]}),h?h.map(ere):m||" "]},p)},e[4]=r,e[5]=s,e[6]=f):f=e[6],c=t.map(f),e[0]=r,e[1]=t,e[2]=s,e[3]=c}else c=e[3];let u;e[7]!==i||e[8]!==c?(u=a.jsx("code",{className:"block","aria-label":i,children:c}),e[7]=i,e[8]=c,e[9]=u):u=e[9];let d;return e[10]!==l||e[11]!==u?(d=a.jsx("pre",{tabIndex:0,className:l,children:u}),e[10]=l,e[11]=u,e[12]=d):d=e[12],d}function ere(n,e){return a.jsx("span",{style:{color:n.color},children:n.content},e)}function g6(n){const e=V.c(6),{code:t,language:s,label:r}=n,o=Gc(),i=bm(t,s,o);let l;e[0]!==t?(l=uc(t),e[0]=t,e[1]=l):l=e[1];const c=l;let u;return e[2]!==r||e[3]!==c||e[4]!==i?(u=a.jsx(kb,{lines:c,tokens:i,variant:"unboxed",label:r}),e[2]=r,e[3]=c,e[4]=i,e[5]=u):u=e[5],u}const tre=/^(\s*\d+)→(.*)$/;function uc(n){return n.split(/\r\n|\r|\n/)}function nre(n){const e=[],t=[];for(const s of uc(n)){const r=s.match(tre);r?(e.push(r[1]),t.push(r[2])):(e.push(""),t.push(s))}return{lineNums:e,codeLines:t}}function sre(n){const e=V.c(11),{result:t,filePath:s,variant:r}=n,o=r===void 0?"boxed":r,i=Gc();let l;e[0]!==s?(l=h6(s),e[0]=s,e[1]=l):l=e[1];const c=l;let u;e[2]!==t?(u=nre(t),e[2]=t,e[3]=u):u=e[3];const{lineNums:d,codeLines:f}=u;let m;e[4]!==f?(m=f.join(`
372
372
  `),e[4]=f,e[5]=m):m=e[5];const h=bm(m,c,i);let g;return e[6]!==f||e[7]!==d||e[8]!==h||e[9]!==o?(g=a.jsx(kb,{lines:f,tokens:h,lineNums:d,variant:o}),e[6]=f,e[7]=d,e[8]=h,e[9]=o,e[10]=g):g=e[10],g}function x6(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 b6(n){const e=V.c(9),{result:t,alreadyPretty:s,variant:r}=n,o=r===void 0?"boxed":r,i=Gc();let l;e[0]!==s||e[1]!==t?(l=s?t:x6(t)??t,e[0]=s,e[1]=t,e[2]=l):l=e[2];const c=l;let u;e[3]!==c?(u=uc(c),e[3]=c,e[4]=u):u=e[4];const d=u,f=bm(c,"json",i);let m;return e[5]!==d||e[6]!==f||e[7]!==o?(m=a.jsx(kb,{lines:d,tokens:f,variant:o}),e[5]=d,e[6]=f,e[7]=o,e[8]=m):m=e[8],m}function rre(n){const e=uc(n),t=e.slice(0,8).join(`
373
- `),s=t.slice(0,1e3);return{text:s,hiddenLines:Math.max(0,e.length-uc(s).length),truncated:e.length>8||t.length>1e3}}function v6(n){const e=V.c(37),{result:t,isError:s,filePath:r,renderResult:o}=n,i=s===void 0?!1:s,[l,c]=y.useState(!1),[u,d]=no(),f=y.useId();let m;e[0]!==r||e[1]!==i||e[2]!==t?(m=!i&&!r?x6(t):null,e[0]=r,e[1]=i,e[2]=t,e[3]=m):m=e[3];const p=m,h=p??t;let g;e[4]!==h?(g=rre(h),e[4]=h,e[5]=g):g=e[5];const x=g,b=l?h:x.text,w=i&&"text-destructive";let v;e[6]!==w?(v=G("text-xs text-muted-foreground",w),e[6]=w,e[7]=v):v=e[7];const j=i?"Error":"Result";let k;e[8]!==v||e[9]!==j?(k=a.jsx("span",{className:v,children:j}),e[8]=v,e[9]=j,e[10]=k):k=e[10];let _;e[11]!==u||e[12]!==d||e[13]!==t?(_=t.trim()&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>d(t),"aria-label":u?"Result copied":"Copy result",children:u?a.jsx(nn,{"data-icon":"icon"}):a.jsx(Es,{"data-icon":"icon"})}),e[11]=u,e[12]=d,e[13]=t,e[14]=_):_=e[14];let N;e[15]!==k||e[16]!==_?(N=a.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[k,_]}),e[15]=k,e[16]=_,e[17]=N):N=e[17];let S;e[18]!==r||e[19]!==i||e[20]!==p||e[21]!==o||e[22]!==t||e[23]!==b?(S=t.trim()?o?o(b):r&&!i?a.jsx(sre,{result:b,filePath:r,variant:"unboxed"}):p!==null?a.jsx(b6,{result:b,alreadyPretty:!0,variant:"unboxed"}):a.jsx("pre",{tabIndex:0,className:G(Sb,i&&"border-destructive/30 text-destructive"),children:b}):a.jsx("p",{className:"text-xs text-muted-foreground",children:"No output"}),e[18]=r,e[19]=i,e[20]=p,e[21]=o,e[22]=t,e[23]=b,e[24]=S):S=e[24];let C;e[25]!==f||e[26]!==S?(C=a.jsx("div",{id:f,children:S}),e[25]=f,e[26]=S,e[27]=C):C=e[27];let E;e[28]!==l||e[29]!==x.hiddenLines||e[30]!==x.truncated||e[31]!==f?(E=x.truncated&&a.jsx(Q,{type:"button",variant:"ghost",size:"xs",className:"mt-1",onClick:()=>c(ore),"aria-expanded":l,"aria-controls":f,children:l?"Show less":x.hiddenLines>0?`+${x.hiddenLines} ${x.hiddenLines===1?"line":"lines"}`:"Show more"}),e[28]=l,e[29]=x.hiddenLines,e[30]=x.truncated,e[31]=f,e[32]=E):E=e[32];let T;return e[33]!==C||e[34]!==E||e[35]!==N?(T=a.jsxs("section",{className:"mt-3 min-w-0","aria-label":"Result",children:[N,C,E]}),e[33]=C,e[34]=E,e[35]=N,e[36]=T):T=e[36],T}function ore(n){return!n}const ire={"cogpit-status":"status","cogpit-decisions":"decisions","cogpit-checklist":"checklist"};function are(n){return n&&ire[n.toLowerCase()]||null}const y6=y.createContext(null),lre=y.lazy(()=>nt(()=>import("./CogpitBlock-BycygJkN.js"),__vite__mapDeps([24,1,2,3,4]))),cre={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 ure(n){return cre[n.toLowerCase()]??n}function dre(n){if(!n)return null;const e=n.match(/language-(\S+)/);return(e==null?void 0:e[1])??null}function fre(n){const e=V.c(9),{text:t}=n,[s,r]=no();let o;e[0]!==r||e[1]!==t?(o=()=>r(t),e[0]=r,e[1]=t,e[2]=o):o=e[2];const i=s?"Copied":"Copy code";let l;e[3]!==s?(l=s?a.jsxs(a.Fragment,{children:[a.jsx(nn,{className:"text-success","data-icon":"inline-start"}),a.jsx("span",{className:"text-success",children:"Copied"})]}):a.jsx(Es,{"data-icon":"icon"}),e[3]=s,e[4]=l):l=e[4];let c;return e[5]!==o||e[6]!==i||e[7]!==l?(c=a.jsx(Q,{type:"button",variant:"ghost",size:"xs",onClick:o,className:"text-muted-foreground",title:"Copy code","aria-label":i,children:l}),e[5]=o,e[6]=i,e[7]=l,e[8]=c):c=e[8],c}function mre(n){const e=V.c(2),{num:t}=n;let s;return e[0]!==t?(s=a.jsx("span",{className:"mr-3 inline-block w-8 select-none text-right text-xs text-muted-foreground/60",children:t}),e[0]=t,e[1]=s):s=e[1],s}function jb(n){var b,w,v;const e=V.c(33);let t,s,r,o;e[0]!==n?({children:s,className:r,node:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);const i=y.useContext(y6),l=!r&&typeof s=="string"&&!s.includes(`
373
+ `),s=t.slice(0,1e3);return{text:s,hiddenLines:Math.max(0,e.length-uc(s).length),truncated:e.length>8||t.length>1e3}}function v6(n){const e=V.c(37),{result:t,isError:s,filePath:r,renderResult:o}=n,i=s===void 0?!1:s,[l,c]=y.useState(!1),[u,d]=no(),f=y.useId();let m;e[0]!==r||e[1]!==i||e[2]!==t?(m=!i&&!r?x6(t):null,e[0]=r,e[1]=i,e[2]=t,e[3]=m):m=e[3];const p=m,h=p??t;let g;e[4]!==h?(g=rre(h),e[4]=h,e[5]=g):g=e[5];const x=g,b=l?h:x.text,w=i&&"text-destructive";let v;e[6]!==w?(v=G("text-xs text-muted-foreground",w),e[6]=w,e[7]=v):v=e[7];const j=i?"Error":"Result";let k;e[8]!==v||e[9]!==j?(k=a.jsx("span",{className:v,children:j}),e[8]=v,e[9]=j,e[10]=k):k=e[10];let _;e[11]!==u||e[12]!==d||e[13]!==t?(_=t.trim()&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>d(t),"aria-label":u?"Result copied":"Copy result",children:u?a.jsx(nn,{"data-icon":"icon"}):a.jsx(Es,{"data-icon":"icon"})}),e[11]=u,e[12]=d,e[13]=t,e[14]=_):_=e[14];let N;e[15]!==k||e[16]!==_?(N=a.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[k,_]}),e[15]=k,e[16]=_,e[17]=N):N=e[17];let S;e[18]!==r||e[19]!==i||e[20]!==p||e[21]!==o||e[22]!==t||e[23]!==b?(S=t.trim()?o?o(b):r&&!i?a.jsx(sre,{result:b,filePath:r,variant:"unboxed"}):p!==null?a.jsx(b6,{result:b,alreadyPretty:!0,variant:"unboxed"}):a.jsx("pre",{tabIndex:0,className:G(Sb,i&&"border-destructive/30 text-destructive"),children:b}):a.jsx("p",{className:"text-xs text-muted-foreground",children:"No output"}),e[18]=r,e[19]=i,e[20]=p,e[21]=o,e[22]=t,e[23]=b,e[24]=S):S=e[24];let C;e[25]!==f||e[26]!==S?(C=a.jsx("div",{id:f,children:S}),e[25]=f,e[26]=S,e[27]=C):C=e[27];let E;e[28]!==l||e[29]!==x.hiddenLines||e[30]!==x.truncated||e[31]!==f?(E=x.truncated&&a.jsx(Q,{type:"button",variant:"ghost",size:"xs",className:"mt-1",onClick:()=>c(ore),"aria-expanded":l,"aria-controls":f,children:l?"Show less":x.hiddenLines>0?`+${x.hiddenLines} ${x.hiddenLines===1?"line":"lines"}`:"Show more"}),e[28]=l,e[29]=x.hiddenLines,e[30]=x.truncated,e[31]=f,e[32]=E):E=e[32];let T;return e[33]!==C||e[34]!==E||e[35]!==N?(T=a.jsxs("section",{className:"mt-3 min-w-0","aria-label":"Result",children:[N,C,E]}),e[33]=C,e[34]=E,e[35]=N,e[36]=T):T=e[36],T}function ore(n){return!n}const ire={"cogpit-status":"status","cogpit-decisions":"decisions","cogpit-checklist":"checklist"};function are(n){return n&&ire[n.toLowerCase()]||null}const y6=y.createContext(null),lre=y.lazy(()=>nt(()=>import("./CogpitBlock-B7SKhn5k.js"),__vite__mapDeps([24,1,2,3,4]))),cre={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 ure(n){return cre[n.toLowerCase()]??n}function dre(n){if(!n)return null;const e=n.match(/language-(\S+)/);return(e==null?void 0:e[1])??null}function fre(n){const e=V.c(9),{text:t}=n,[s,r]=no();let o;e[0]!==r||e[1]!==t?(o=()=>r(t),e[0]=r,e[1]=t,e[2]=o):o=e[2];const i=s?"Copied":"Copy code";let l;e[3]!==s?(l=s?a.jsxs(a.Fragment,{children:[a.jsx(nn,{className:"text-success","data-icon":"inline-start"}),a.jsx("span",{className:"text-success",children:"Copied"})]}):a.jsx(Es,{"data-icon":"icon"}),e[3]=s,e[4]=l):l=e[4];let c;return e[5]!==o||e[6]!==i||e[7]!==l?(c=a.jsx(Q,{type:"button",variant:"ghost",size:"xs",onClick:o,className:"text-muted-foreground",title:"Copy code","aria-label":i,children:l}),e[5]=o,e[6]=i,e[7]=l,e[8]=c):c=e[8],c}function mre(n){const e=V.c(2),{num:t}=n;let s;return e[0]!==t?(s=a.jsx("span",{className:"mr-3 inline-block w-8 select-none text-right text-xs text-muted-foreground/60",children:t}),e[0]=t,e[1]=s):s=e[1],s}function jb(n){var b,w,v;const e=V.c(33);let t,s,r,o;e[0]!==n?({children:s,className:r,node:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);const i=y.useContext(y6),l=!r&&typeof s=="string"&&!s.includes(`
374
374
  `);let c;e[5]!==r?(c=dre(r),e[5]=r,e[6]=c):c=e[6];const u=c,d=String(s);let f;if(e[7]!==d){let j;e[9]===Symbol.for("react.memo_cache_sentinel")?(j=/\n$/,e[9]=j):j=e[9],f=d.replace(j,""),e[7]=d,e[8]=f}else f=e[8];const m=f;if(l){let j;return e[10]!==s||e[11]!==o?(j=a.jsx("code",{className:"rounded-md border border-border bg-muted px-1.5 py-0.5 font-mono text-[0.9em] text-foreground",...o,children:s}),e[10]=s,e[11]=o,e[12]=j):j=e[12],j}let p;e[13]!==m||e[14]!==u||e[15]!==o?(p=a.jsx(pre,{code:m,lang:u,...o}),e[13]=m,e[14]=u,e[15]=o,e[16]=p):p=e[16];const h=p;if(i&&u&&zC(u)){const j=`${i.messageKey}:${((b=t==null?void 0:t.position)==null?void 0:b.start.offset)??0}`;let k;return e[17]!==m||e[18]!==u||e[19]!==h||e[20]!==j?(k=a.jsx(QQ,{language:u,source:m,instanceKey:j,fallback:h}),e[17]=m,e[18]=u,e[19]=h,e[20]=j,e[21]=k):k=e[21],k}let g;e[22]!==i||e[23]!==u?(g=i?are(u):null,e[22]=i,e[23]=u,e[24]=g):g=e[24];const x=g;if(x){const j=String(((w=t==null?void 0:t.position)==null?void 0:w.start.offset)??((v=t==null?void 0:t.position)==null?void 0:v.start.line)??0);let k;e[25]!==x||e[26]!==m||e[27]!==h||e[28]!==j?(k=a.jsx(lre,{kind:x,source:m,occurrence:j,fallback:h}),e[25]=x,e[26]=m,e[27]=h,e[28]=j,e[29]=k):k=e[29];let _;return e[30]!==h||e[31]!==k?(_=a.jsx(y.Suspense,{fallback:h,children:k}),e[30]=h,e[31]=k,e[32]=_):_=e[32],_}return h}function pre(n){const e=V.c(39);let t,s,r;e[0]!==n?({code:t,lang:s,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);const o=Gc(),i=bm(t,s,o),[l,c]=y.useState(!1);let u,d,f,m;if(e[4]!==t||e[5]!==l||e[6]!==s||e[7]!==r||e[8]!==i){const g=t.split(`
375
375
  `);u=g.length;const x=u>30,b=l?it:_t;d="my-3 overflow-hidden rounded-lg border border-border bg-muted";let w;e[13]!==b||e[14]!==l||e[15]!==x?(w=x&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>c(!l),className:"text-muted-foreground","aria-label":l?"Expand code":"Collapse code",children:a.jsx(b,{"data-icon":"icon"})}),e[13]=b,e[14]=l,e[15]=x,e[16]=w):w=e[16];let v;e[17]!==s?(v=s&&a.jsx(Fe,{variant:"ghost",className:"px-0 uppercase tracking-wide text-muted-foreground",children:ure(s)}),e[17]=s,e[18]=v):v=e[18];let j;e[19]!==x||e[20]!==u?(j=x&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:[u," lines"]}),e[19]=x,e[20]=u,e[21]=j):j=e[21];let k;e[22]!==w||e[23]!==v||e[24]!==j?(k=a.jsxs("div",{className:"flex items-center gap-2",children:[w,v,j]}),e[22]=w,e[23]=v,e[24]=j,e[25]=k):k=e[25];let _;e[26]!==t?(_=a.jsx(fre,{text:t}),e[26]=t,e[27]=_):_=e[27],e[28]!==k||e[29]!==_?(f=a.jsxs("div",{className:"flex items-center justify-between border-b border-border bg-muted px-3 py-1.5",children:[k,_]}),e[28]=k,e[29]=_,e[30]=f):f=e[30],m=!l&&a.jsx("div",{className:"overflow-x-auto",children:a.jsx("pre",{className:"m-0 p-3 font-mono text-xs leading-relaxed",children:a.jsx("code",{className:G("block",!i&&"text-foreground/90"),...r,children:g.map((N,S)=>{const C=i==null?void 0:i[S];return a.jsxs("span",{className:"block",children:[a.jsx(mre,{num:S+1}),C?C.map(hre):N||" "]},S)})})})}),e[4]=t,e[5]=l,e[6]=s,e[7]=r,e[8]=i,e[9]=u,e[10]=d,e[11]=f,e[12]=m}else u=e[9],d=e[10],f=e[11],m=e[12];let p;e[31]!==l||e[32]!==u?(p=l&&a.jsxs(Q,{type:"button",variant:"ghost",size:"sm",onClick:()=>c(!1),className:"h-auto w-full justify-start rounded-none px-3 py-2 text-xs text-muted-foreground","aria-label":`Expand ${u} lines of code`,children:["Show ",u," lines..."]}),e[31]=l,e[32]=u,e[33]=p):p=e[33];let h;return e[34]!==d||e[35]!==f||e[36]!==m||e[37]!==p?(h=a.jsxs("div",{className:d,children:[f,m,p]}),e[34]=d,e[35]=f,e[36]=m,e[37]=p,e[38]=h):h=e[38],h}function hre(n,e){return a.jsx("span",{style:{color:n.color},children:n.content},e)}var li=function(n,e){return Number(n.toFixed(e))},gre=function(n,e){return e},gt=function(n,e,t){t&&typeof t=="function"&&t(n,e)},xre=function(n){return-Math.cos(n*Math.PI)/2+.5},bre=function(n){return n},vre=function(n){return n*n},yre=function(n){return n*(2-n)},wre=function(n){return n<.5?2*n*n:-1+(4-2*n)*n},Sre=function(n){return n*n*n},kre=function(n){return--n*n*n+1},jre=function(n){return n<.5?4*n*n*n:(n-1)*(2*n-2)*(2*n-2)+1},Nre=function(n){return n*n*n*n},Cre=function(n){return 1- --n*n*n*n},_re=function(n){return n<.5?8*n*n*n*n:1-8*--n*n*n*n},Ere=function(n){return n*n*n*n*n},Tre=function(n){return 1+--n*n*n*n*n},Are=function(n){return n<.5?16*n*n*n*n*n:1+16*--n*n*n*n*n},w6={easeOut:xre,linear:bre,easeInQuad:vre,easeOutQuad:yre,easeInOutQuad:wre,easeInCubic:Sre,easeOutCubic:kre,easeInOutCubic:jre,easeInQuart:Nre,easeOutQuart:Cre,easeInOutQuart:_re,easeInQuint:Ere,easeOutQuint:Tre,easeInOutQuint:Are},S6=function(n){typeof n=="number"&&cancelAnimationFrame(n)},Us=function(n){n.mounted&&(S6(n.animation),n.isAnimating=!1,n.animation=null,n.velocity=null)};function k6(n,e,t,s){if(n.mounted){var r=new Date().getTime(),o=1;Us(n),n.animation=function(){if(!n.mounted)return S6(n.animation);var i=new Date().getTime()-r,l=i/t,c=w6[e],u=c(l);i>=t?(s(o),n.animation=null):n.animation&&(s(u),requestAnimationFrame(n.animation))},requestAnimationFrame(n.animation)}}function Ire(n){var e=n.scale,t=n.positionX,s=n.positionY;return!(Number.isNaN(e)||Number.isNaN(t)||Number.isNaN(s))}function Zo(n,e,t,s){var r=Ire(e);if(!(!n.mounted||!r)){var o=n.setState,i=n.state,l=i.scale,c=i.positionX,u=i.positionY,d=e.scale-l,f=e.positionX-c,m=e.positionY-u;t===0?o(e.scale,e.positionX,e.positionY):k6(n,s,t,function(p){p!==1?n.isAnimating=!0:n.isAnimating=!1;var h=l+d*p,g=c+f*p,x=u+m*p;o(h,g,x)})}}function Pre(n,e,t){var s=n.offsetWidth,r=n.offsetHeight,o=e.offsetWidth,i=e.offsetHeight,l=o*t,c=i*t,u=s-l,d=r-c;return{wrapperWidth:s,wrapperHeight:r,newContentWidth:l,newDiffWidth:u,newContentHeight:c,newDiffHeight:d}}var $re=function(n,e,t,s,r,o,i){var l=n>e?t*(i?.5:1):0,c=s>r?o*(i?.5:1):0,u=n-e-l,d=l,f=s-r-c,m=c;return{minPositionX:u,maxPositionX:d,minPositionY:f,maxPositionY:m,scaleWidthFactor:l,scaleHeightFactor:c}},Nb=function(n,e){var t=n.wrapperComponent,s=n.contentComponent,r=n.setup,o=r.centerZoomedOut,i=r.disablePadding;if(!t||!s)throw new Error("Components are not mounted");var l=Pre(t,s,e),c=l.wrapperWidth,u=l.wrapperHeight,d=l.newContentWidth,f=l.newContentHeight,m=l.newDiffWidth,p=l.newDiffHeight,h=$re(c,d,m,u,f,p,!!o),g=c>=d&&u>=f;i&&g&&!o&&(h.minPositionX=0,h.maxPositionX=0,h.minPositionY=0,h.maxPositionY=0);var x=n.setup,b=x.minPositionX,w=x.maxPositionX,v=x.minPositionY,j=x.maxPositionY;return b!=null&&(h.minPositionX=c*(1-e)+b*e),w!=null&&(h.maxPositionX=w*e),v!=null&&(h.minPositionY=u*(1-e)+v*e),j!=null&&(h.maxPositionY=j*e),h},dc=function(n,e,t,s){return s?n<e?li(e,2):n>t?li(t,2):li(n,2):li(n,2)},ga=function(n,e){var t=Nb(n,e);return n.bounds=t,t};function Zc(n,e,t,s,r,o,i){var l=t.minPositionX,c=t.minPositionY,u=t.maxPositionX,d=t.maxPositionY,f=0,m=0;i&&(f=r,m=o);var p=dc(n,l-f,u+f,s),h=dc(e,c-m,d+m,s);return{x:p,y:h}}function vm(n,e,t,s,r,o){var i=n.state,l=i.scale,c=i.positionX,u=i.positionY,d=s-l;if(!Number.isFinite(e)||!Number.isFinite(t))return console.error("Mouse X and Y position were not provided!"),{x:c,y:u};var f=c-e*d,m=u-t*d,p=Zc(f,m,r,o,0,0,null);return p}var Vk=1e-7;function Yc(n,e,t,s,r){var o=r?s:0,i=Math.max(e-o,Vk),l=t+o;return!Number.isNaN(t)&&n>=l?l:!Number.isNaN(e)&&n<=i?i:Math.max(n,Vk)}var Hk=function(n,e){var t=n.setup.panning.excluded,s=n.isInitialized,r=n.wrapperComponent,o=e.target,i="shadowRoot"in o&&"composedPath"in e,l=i?e.composedPath().some(function(d){return d instanceof Element?r==null?void 0:r.contains(d):!1}):r==null?void 0:r.contains(o),c=s&&o&&l;if(!c)return!1;var u=Xc(o,t);return!(u||o.getAttribute("draggable")==="true"||o.getAttribute("contenteditable")==="true"||o.isContentEditable)},Kk=function(n){var e=n.isInitialized,t=n.isPanning,s=n.setup,r=s.panning.disabled,o=e&&t&&!r;return!!o},Rre=function(n,e){var t=n.state,s=t.positionX,r=t.positionY;n.isPanning=!0;var o=e.clientX,i=e.clientY;n.startCoords={x:o-s,y:i-r}},Ore=function(n,e){var t=e.touches,s=n.state,r=s.positionX,o=s.positionY;n.isPanning=!0;var i=t.length===1;if(i){var l=t[0].clientX,c=t[0].clientY;n.startCoords={x:l-r,y:c-o}}};function Lre(n){var e=n.state,t=e.positionX,s=e.positionY,r=e.scale,o=n.setup,i=o.disabled,l=o.limitToBounds,c=o.centerZoomedOut,u=n.wrapperComponent;if(!(i||!u||!n.bounds)){var d=n.bounds,f=d.maxPositionX,m=d.minPositionX,p=d.maxPositionY,h=d.minPositionY,g=t>f||t<m,x=s>p||s<h,b=t>f?u.offsetWidth:n.setup.minPositionX||0,w=s>p?u.offsetHeight:n.setup.minPositionY||0,v=vm(n,b,w,r,n.bounds,l||c),j=v.x,k=v.y;return{scale:r,positionX:g?j:t,positionY:x?k:s}}}function j6(n,e,t,s,r){var o=n.setup.limitToBounds,i=n.wrapperComponent,l=n.bounds,c=n.state,u=c.scale,d=c.positionX,f=c.positionY;if(!(i===null||l===null||e===d&&t===f)){var m=Zc(e,t,l,o,s,r,i),p=m.x,h=m.y;n.setState(u,p,h)}}var Mre=function(n,e,t){var s=n.startCoords,r=n.state,o=n.setup.panning,i=o.lockAxisX,l=o.lockAxisY,c=r.positionX,u=r.positionY;if(!s)return{x:c,y:u};var d=e-s.x,f=t-s.y,m=i?c:d,p=l?u:f;return{x:m,y:p}},Fo=function(n,e,t){var s=n.setup,r=n.state,o=s.minScale,i=s.disablePadding,l=s.centerZoomedOut,c=t??r.scale;return e>0&&c>=o&&!i&&!l?e:0},jo;(function(n){n.TRACK_PAD="track_pad",n.MOUSE="mouse",n.TOUCH="touch"})(jo||(jo={}));var zre=function(n){var e=n.mounted,t=n.wrapperComponent,s=n.contentComponent,r=n.setup,o=r.disabled,i=r.velocityAnimation,l=r.limitToBounds,c=n.state.scale,u=i.disabled;if(u||o||!e||!t||!s)return!1;if(!l)return!0;var d=t.offsetWidth<s.offsetWidth*c||t.offsetHeight<s.offsetHeight*c;return d},Dre=function(n){var e=n.mounted,t=n.velocity,s=n.bounds,r=n.setup,o=r.disabled,i=r.velocityAnimation,l=i.disabled,c=!l&&!o&&e;return!(!c||!t||!s)};function Fre(n,e){var t=n.setup.velocityAnimation,s=t.animationTime,r=t.maxAnimationTime,o=t.inertia;return Math.min(s*Math.max(1,Math.abs(e/o)),r)}function Gk(n,e,t,s,r,o,i,l,c,u){if(r){if(e>i&&t>i){var d=i+(n-i)*u;return d>c?c:d<i?i:d}if(e<o&&t<o){var d=o+(n-o)*u;return d<l?l:d>o?o:d}}return s?e:dc(n,o,i,r)}function Ure(n){var e=1,t=n.offsetWidth/window.innerWidth;return Number.isNaN(t)?e:Math.min(e,t)}var Ph=function(n,e,t){var s=0,r=n*t;return Number.isNaN(r)?s:n<0?Math.max(r,-e):Math.min(r,e)};function Bre(n,e,t){var s,r,o=zre(n);if(o){var i=n.lastMousePosition,l=n.velocityTime,c=n.setup,u=n.wrapperComponent,d=c.velocityAnimation,f=d.maxStrengthMouse,m=d.maxStrengthTouch,p=d.sensitivityTouch,h=d.sensitivityMouse,g=Date.now();if(i&&l&&u){var x=Ure(u),b=(s={},s[jo.TOUCH]=p,s[jo.MOUSE]=h,s)[t],w=(r={},r[jo.TOUCH]=m,r[jo.MOUSE]=f,r)[t],v=e.x-i.x,j=e.y-i.y,k=Ph(v/x,w,b),_=Ph(j/x,w,b),N=g-l,S=v*v+j*j,C=Ph(Math.sqrt(S)/N,w,b);n.velocity={velocityX:k,velocityY:_,total:C}}n.lastMousePosition=e,n.velocityTime=g}}function Wre(n){var e=n.velocity,t=n.bounds,s=n.setup,r=n.wrapperComponent,o=Dre(n);if(!(!o||!e||!t||!r)){var i=e.velocityX,l=e.velocityY,c=e.total,u=t.maxPositionX,d=t.minPositionX,f=t.maxPositionY,m=t.minPositionY,p=s.limitToBounds,h=s.autoAlignment,g=s.zoomAnimation,x=s.panning,b=x.lockAxisY,w=x.lockAxisX,v=g.animationType,j=h.sizeX,k=h.sizeY,_=h.velocityAlignmentTime,N=_,S=Fre(n,c),C=Math.max(S,N),E=Fo(n,j),T=Fo(n,k),$=E*r.offsetWidth/100,A=T*r.offsetHeight/100,R=u+$,P=d-$,z=f+A,L=m-A,I=n.state,M=new Date().getTime();k6(n,v,C,function(F){var U=n.state,O=U.scale,D=U.positionX,B=U.positionY,q=new Date().getTime()-M,W=q/N,H=w6[h.animationType],K=1-H(Math.min(1,W)),Z=1-F,Y=D+i*Z,X=B+l*Z,ee=Gk(Y,I.positionX,D,w,p,d,u,P,R,K),te=Gk(X,I.positionY,B,b,p,m,f,L,z,K);if(D!==Y||B!==X){n.setState(O,ee,te);var se=n.props.onPanning;se&&se(pt(n),{})}})}}function Zk(n,e){var t=n.state,s=t.scale,r=t.positionX,o=t.positionY;n.panStartPosition={x:r,y:o},Us(n),ga(n,s),window.TouchEvent!==void 0&&e instanceof TouchEvent?Ore(n,e):Rre(n,e)}function N6(n,e){var t=n.state.scale,s=n.setup,r=s.minScale,o=s.autoAlignment,i=o.disabled,l=o.sizeX,c=o.sizeY,u=o.animationTime,d=o.animationType,f=i||t<r||!l&&!c;if(!f){var m=Lre(n);m&&Zo(n,m,u,d)}}function Yk(n,e,t,s){var r=n.startCoords,o=n.setup,i=o.autoAlignment,l=i.sizeX,c=i.sizeY;if(r){var u=Mre(n,e,t),d=u.x,f=u.y,m=Fo(n,l),p=Fo(n,c);Bre(n,{x:d,y:f},s),j6(n,d,f,m,p)}}function qre(n,e){if(n.isPanning){var t=n.velocity,s=n.wrapperComponent,r=n.contentComponent;n.isPanning=!1;var o=n.state,i=o.positionX,l=o.positionY,c=o.scale,u=n.panStartPosition;if(n.panStartPosition=null,u){var d=i-u.x,f=l-u.y;if(d*d+f*f<=25)return}n.isAnimating=!1,n.animation=null;var m=(s==null?void 0:s.offsetWidth)||0,p=(s==null?void 0:s.offsetHeight)||0,h=((r==null?void 0:r.offsetWidth)||0)*c,g=((r==null?void 0:r.offsetHeight)||0)*c,x=!n.setup.limitToBounds||m<h||p<g,b=!e&&t&&t.total>.1&&x;b?Wre(n):N6(n)}}function Cb(n,e,t,s){var r=n.setup,o=r.minScale,i=r.maxScale,l=r.limitToBounds,c=Yc(li(e,2),o,i,0,!1),u=ga(n,c),d=vm(n,t,s,c,u,l),f=d.x,m=d.y;return{scale:c,positionX:f,positionY:m}}function _b(n,e,t){var s=n.state.scale,r=n.wrapperComponent,o=n.setup,i=o.minScale,l=o.maxScale,c=o.limitToBounds,u=o.zoomAnimation,d=u.disabled,f=u.animationTime,m=u.animationType,p=s>=i&&s<=l,h=d||p;if((s>=1||c)&&N6(n),!(h||!r||!n.mounted)){var g=e||r.offsetWidth/2,x=t||r.offsetHeight/2,b=s<i?i:l,w=Cb(n,b,g,x);w&&Zo(n,w,f,m)}}var ks=function(){return ks=Object.assign||function(e){for(var t,s=1,r=arguments.length;s<r;s++){t=arguments[s];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},ks.apply(this,arguments)};function Xk(n,e,t){for(var s=0,r=e.length,o;s<r;s++)(o||!(s in e))&&(o||(o=Array.prototype.slice.call(e,0,s)),o[s]=e[s]);return n.concat(o||Array.prototype.slice.call(e))}var $h={scale:1,positionX:0,positionY:0},ai={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"}},C1={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},C6=function(n){var e,t,s,r,o,i,l,c,u,d=Math.max((e=n.minScale)!==null&&e!==void 0?e:ai.minScale,1e-7),f=(t=n.maxScale)!==null&&t!==void 0?t:ai.maxScale,m=(s=n.initialScale)!==null&&s!==void 0?s:$h.scale,p=Math.min(Math.max(m,d),f),h=dc((r=n.initialPositionX)!==null&&r!==void 0?r:$h.positionX,(o=n.minPositionX)!==null&&o!==void 0?o:-1/0,(i=n.maxPositionX)!==null&&i!==void 0?i:1/0,n.minPositionX!=null||n.maxPositionX!=null),g=dc((l=n.initialPositionY)!==null&&l!==void 0?l:$h.positionY,(c=n.minPositionY)!==null&&c!==void 0?c:-1/0,(u=n.maxPositionY)!==null&&u!==void 0?u:1/0,n.minPositionY!=null||n.maxPositionY!=null);return{previousScale:p,scale:p,positionX:h,positionY:g}},Jk=function(n){var e=ks({},ai);return Object.keys(n).forEach(function(t){var s=t,r=typeof n[s]<"u",o=typeof ai[s]<"u";if(o&&r){var i=Object.prototype.toString.call(ai[s]),l=i==="[object Object]",c=i==="[object Array]";l?e[s]=ks(ks({},ai[s]),n[s]):c?e[s]=Xk(Xk([],ai[s],!0),n[s]):e[s]=n[s]}}),e.minScale<=0&&(e.minScale=1e-7),e},_6=function(n,e,t){var s=n.state.scale,r=n.wrapperComponent,o=n.setup,i=o.maxScale,l=o.minScale,c=o.zoomAnimation,u=o.smooth,d=c.size;if(!r)throw new Error("Wrapper is not mounted");var f=u?s*Math.exp(e*t):s+e*t,m=Yc(li(f,3),l,i,d,!1);return m};function E6(n,e,t,s,r){var o,i,l=n.wrapperComponent,c=n.state,u=c.scale,d=c.positionX,f=c.positionY,m=n.setup.zoomAnimation;if(!l)return console.error("No WrapperComponent found");var p=m.disabled?0:s,h=l.offsetWidth,g=l.offsetHeight,x=(h/2-d)/u,b=(g/2-f)/u,w=_6(n,e,t),v=Cb(n,w,x,b);if(!v)return console.error("Error during zoom event. New transformation state was not calculated.");var j=n.props,k=j.onZoomStart,_=j.onZoom,N=j.onZoomStop,S=new MouseEvent("mousemove",{bubbles:!0}),C=pt(n);gt(C,S,k),gt(C,S,_),Zo(n,v,p,r);var E=(i=(o=l.ownerDocument)===null||o===void 0?void 0:o.defaultView)!==null&&i!==void 0?i:typeof window<"u"?window:null;E&&E.setTimeout(function(){n.mounted&&gt(pt(n),S,N)},p)}function T6(n,e,t,s){var r,o,i=n.setup,l=n.wrapperComponent,c=n.contentComponent,u=i.limitToBounds,d=i.centerOnInit,f=C6(n.props),m=n.state,p=m.scale,h=m.positionX,g=m.positionY;if(l){var x=f.positionX,b=f.positionY;if(d&&c){var w=Eb(f.scale,l,c);x=w.positionX,b=w.positionY}var v=Nb(n,f.scale),j=Zc(x,b,v,u,0,0,l),k={scale:f.scale,positionX:j.x,positionY:j.y};if(!(p===f.scale&&h===f.positionX&&g===f.positionY)){s==null||s();var _=n.props,N=_.onZoomStart,S=_.onZoom,C=_.onZoomStop,E=new MouseEvent("mousemove",{bubbles:!0}),T=pt(n);gt(T,E,N),gt(T,E,S),Zo(n,k,e,t);var $=(o=(r=l.ownerDocument)===null||r===void 0?void 0:r.defaultView)!==null&&o!==void 0?o:typeof window<"u"?window:null;$&&$.setTimeout(function(){n.mounted&&gt(pt(n),E,C)},e)}}}function Vre(n,e,t,s){var r=n.getBoundingClientRect(),o=e.getBoundingClientRect(),i=t.getBoundingClientRect(),l=o.x*s.scale,c=o.y*s.scale;return{x:(r.x-i.x+l)/s.scale,y:(r.y-i.y+c)/s.scale}}function Hre(n,e,t,s,r){s===void 0&&(s=0),r===void 0&&(r=0);var o=n.wrapperComponent,i=n.contentComponent,l=n.state,c=n.setup,u=c.limitToBounds,d=c.minScale,f=c.maxScale;if(!o||!i)return l;var m=o.getBoundingClientRect(),p=e.getBoundingClientRect(),h=Vre(e,o,i,l),g=h.x,x=h.y,b=p.width/l.scale,w=p.height/l.scale,v=o.offsetWidth/b,j=o.offsetHeight/w,k=Yc(t||Math.min(v,j),d,f,0,!1),_=(m.width-b*k)/2,N=(m.height-w*k)/2,S=(m.left-g)*k+_+s,C=(m.top-x)*k+N+r,E=Nb(n,k),T=Zc(S,C,E,u,0,0,o),$=T.x,A=T.y;return{positionX:$,positionY:A,scale:k}}var Kre=function(n){return function(e,t,s){e===void 0&&(e=.5),t===void 0&&(t=300),s===void 0&&(s="easeOut"),E6(n,1,e,t,s)}},Gre=function(n){return function(e,t,s){e===void 0&&(e=.5),t===void 0&&(t=300),s===void 0&&(s="easeOut"),E6(n,-1,e,t,s)}},Zre=function(n){return function(e,t,s,r,o){r===void 0&&(r=300),o===void 0&&(o="easeOut");var i=n.state,l=i.positionX,c=i.positionY,u=i.scale,d=n.wrapperComponent,f=n.contentComponent,m=n.setup.disabled;if(!(m||!d||!f)){var p={positionX:Number.isNaN(e)?l:e,positionY:Number.isNaN(t)?c:t,scale:Number.isNaN(s)?u:s};Zo(n,p,r,o)}}},Yre=function(n){return function(e,t){e===void 0&&(e=200),t===void 0&&(t="easeOut"),T6(n,e,t)}},Xre=function(n){return function(e,t,s){t===void 0&&(t=200),s===void 0&&(s="easeOut");var r=n.state,o=n.wrapperComponent,i=n.contentComponent;if(o&&i){var l=Eb(e||r.scale,o,i);Zo(n,l,t,s)}}},Jre=function(n){return function(e,t,s,r,o,i){s===void 0&&(s=600),r===void 0&&(r="easeOut"),o===void 0&&(o=0),i===void 0&&(i=0),Us(n);var l=n.wrapperComponent,c=typeof e=="string"?document.getElementById(e):e;if(l&&c&&l.contains(c)){var u=Hre(n,c,t,o,i);Zo(n,u,s,r)}}},_1=function(n){return{instance:n,state:n.state,zoomIn:Kre(n),zoomOut:Gre(n),setTransform:Zre(n),resetTransform:Yre(n),centerView:Xre(n),zoomToElement:Jre(n)}},Qre=function(n){return{instance:n,state:n.state}},pt=function(n){var e={};return Object.assign(e,Qre(n)),Object.assign(e,_1(n)),e},Rh=!1;function Oh(){try{var n={get passive(){return Rh=!0,!1}};return n}catch{return Rh=!1,Rh}}var Bu=".".concat(C1.wrapperClass),Xc=function(n,e){return e.some(function(t){return n.matches("".concat(Bu," ").concat(t,", ").concat(Bu," .").concat(t,", ").concat(Bu," ").concat(t," *, ").concat(Bu," .").concat(t," *"))})},fc=function(n){n&&clearTimeout(n)},eoe=function(n){return Number.parseFloat(n.toFixed(8))},A6=function(n,e,t){var s=eoe(t);return"translate(".concat(n,"px, ").concat(e,"px) scale(").concat(s,")")},Eb=function(n,e,t){var s=t.offsetWidth*n,r=t.offsetHeight*n,o=(e.offsetWidth-s)/2,i=(e.offsetHeight-r)/2;return{scale:n,positionX:o,positionY:i}};function toe(n,e){n!=null&&(typeof n=="function"?n(e):n.current=e)}function noe(n){return function(e){n.forEach(function(t){typeof t=="function"?t(e):t!=null&&(t.current=e)})}}var I6=function(n,e){var t=n.setup.wheel,s=t.disabled,r=t.wheelDisabled,o=t.touchPadDisabled,i=t.excluded,l=n.isInitialized,c=n.isPanning,u=e.target,d=l&&!c&&!s&&u;if(!d||r&&!e.ctrlKey||o&&e.ctrlKey)return!1;var f=Xc(u,i);if(f)return!1;var m=n.isPressingKeys(n.setup.wheel.activationKeys);return!!m},soe=function(n,e){var t=n.setup,s=t.disabled,r=t.trackPadPanning,o=r.activationKeys,i=r.excluded;if(!n.wrapperComponent||!n.contentComponent||s||r.disabled||e.ctrlKey)return!1;var l=I6(n,e);if(l)return!1;var c=e.target,u=Xc(c,i);if(u)return!1;var d=n.isPressingKeys(o);return!!d},roe=function(n){return n?n.deltaY<0?1:-1:0};function ooe(n,e){var t=roe(n),s=gre(e,t);return s}function P6(n,e,t){var s=e.getBoundingClientRect(),r=0,o=0;if("clientX"in n)r=(n.clientX-s.left)/t,o=(n.clientY-s.top)/t;else{var i=n.touches[0];r=(i.clientX-s.left)/t,o=(i.clientY-s.top)/t}return Number.isNaN(r)||Number.isNaN(o)?(console.error("No mouse or touch offset found"),{x:0,y:0}):{x:r,y:o}}var ioe=function(n,e,t,s,r){var o=n.state.scale,i=n.wrapperComponent,l=n.setup,c=l.maxScale,u=l.minScale,d=l.zoomAnimation,f=l.disablePadding,m=d.size,p=d.disabled;if(!i)throw new Error("Wrapper is not mounted");var h=o+e*t,g=s?!1:!p,x=Yc(h,u,c,m,g&&!f);return x},$6=function(n,e){var t=n.previousWheelEvent,s=n.state.scale,r=n.setup,o=r.maxScale,i=r.minScale;return t?s<o||s>i||Math.sign(t.deltaY)!==Math.sign(e.deltaY)||t.deltaY>0&&t.deltaY<e.deltaY||t.deltaY<0&&t.deltaY>e.deltaY||Math.sign(t.deltaY)!==Math.sign(e.deltaY):!1},aoe=function(n,e){var t=n.setup.pinch,s=t.disabled,r=t.excluded,o=n.isInitialized,i=e.target,l=o&&!s&&i;if(!l)return!1;var c=Xc(i,r);return!c},loe=function(n){var e=n.setup.pinch.disabled,t=n.isInitialized,s=n.pinchStartDistance,r=t&&!e&&s!==null;return!!r},coe=function(n,e,t){var s=t.getBoundingClientRect(),r=n.touches,o=r[0].clientX-s.left,i=r[0].clientY-s.top,l=r[1].clientX-s.left,c=r[1].clientY-s.top;return{x:(o+l)/2/e,y:(i+c)/2/e}},R6=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))},uoe=5,doe=function(n,e){var t=n.pinchStartScale,s=n.pinchStartDistance,r=n.setup,o=r.maxScale,i=r.minScale,l=r.zoomAnimation,c=r.disablePadding,u=r.pinch,d=l.size,f=l.disabled,m=u.step;if(!t||s===null)throw new Error("Pinch touches distance was not provided");if(e<0)return n.state.scale;var p=e/s,h=p*t,g=(h-t)*(m/uoe),x=t+g,b=x===1/0?0:li(x,10);return Yc(b,i,o,d,!f&&!c)},O6=160,L6=100,foe=function(n,e){var t=n.props,s=t.onWheelStart,r=t.onZoomStart;n.wheelStopEventTimer||(Us(n),gt(pt(n),e,s),gt(pt(n),e,r))},moe=function(n,e){var t=n.props,s=t.onWheel,r=t.onZoom,o=n.contentComponent,i=n.setup,l=n.state,c=l.scale,u=i.limitToBounds,d=i.centerZoomedOut,f=i.zoomAnimation,m=i.wheel,p=i.disablePadding,h=i.smooth,g=f.size,x=f.disabled,b=m.step;if(!o)throw new Error("Component not mounted");e.cancelable&&e.preventDefault(),e.stopPropagation();var w=ooe(e,null),v=h?b*Math.abs(e.deltaY):b,j=ioe(n,w,v,!e.ctrlKey);if(c!==j){var k=ga(n,j),_=P6(e,o,c),N=x||g===0||d||p,S=u&&N,C=vm(n,_.x,_.y,j,k,S),E=C.x,T=C.y;n.previousWheelEvent=e,n.setState(j,E,T),gt(pt(n),e,s),gt(pt(n),e,r)}},poe=function(n,e){var t=n.props,s=t.onWheelStop,r=t.onZoomStop;fc(n.wheelAnimationTimer),n.wheelAnimationTimer=setTimeout(function(){n.mounted&&(_b(n,e.x,e.y),n.wheelAnimationTimer=null)},L6);var o=$6(n,e);o&&(fc(n.wheelStopEventTimer),n.wheelStopEventTimer=setTimeout(function(){n.mounted&&(n.wheelStopEventTimer=null,gt(pt(n),e,s),gt(pt(n),e,r))},O6))},hoe=function(n,e){var t=n.props,s=t.onWheelStart,r=t.onPanningStart;n.wheelStopEventTimer||(Us(n),gt(pt(n),e,s),gt(pt(n),e,r))},goe=function(n,e){var t=n.props,s=t.onWheelStop,r=t.onPanningStop;fc(n.wheelAnimationTimer),n.wheelAnimationTimer=setTimeout(function(){n.mounted&&(_b(n,e.x,e.y),n.wheelAnimationTimer=null)},L6);var o=$6(n,e);o&&(fc(n.wheelStopEventTimer),n.wheelStopEventTimer=setTimeout(function(){n.mounted&&(n.wheelStopEventTimer=null,gt(pt(n),e,s),gt(pt(n),e,r))},O6))},M6=function(n){for(var e=0,t=0,s=0;s<2;s+=1)e+=n.touches[s].clientX,t+=n.touches[s].clientY;var r=e/2,o=t/2;return{x:r,y:o}},xoe=function(n,e){var t=R6(e);n.pinchStartDistance=t,n.lastDistance=t,n.pinchStartScale=n.state.scale,n.isPanning=!1,n.isPinching=!0,n.pinchPreviousCenter=M6(e),Us(n)},boe=function(n,e){var t=n.contentComponent,s=n.pinchStartDistance,r=n.wrapperComponent,o=n.pinchPreviousCenter,i=n.state.scale,l=n.setup,c=l.limitToBounds,u=l.centerZoomedOut,d=l.zoomAnimation,f=l.autoAlignment,m=l.pinch,p=l.panning,h=d.disabled,g=d.size,x=m.allowPanning;if(!(s===null||!t)){var b=coe(e,i,t);if(!(!Number.isFinite(b.x)||!Number.isFinite(b.y))){var w=R6(e),v=doe(n,w),j=M6(e),k=i/v,_=(j.x-((o==null?void 0:o.x)||0))*k,N=(j.y-((o==null?void 0:o.y)||0))*k;if(!(v===i&&_===0&&N===0)){n.pinchPreviousCenter=j;var S=ga(n,v),C=h||g===0||u,E=c&&C,T=vm(n,b.x,b.y,v,S,E),$=T.x,A=T.y;if(n.pinchMidpoint=b,n.lastDistance=w,p.disabled||!x)n.setState(v,$,A);else{var R=f.sizeX,P=f.sizeY,z=Fo(n,R,v),L=Fo(n,P,v),I=$+_,M=A+N,F=Zc(I,M,S,c,z,L,r),U=F.x,O=F.y;n.setState(v,U,O)}}}}},voe=function(n){var e=n.pinchMidpoint;n.velocity=null,n.lastDistance=null,n.pinchMidpoint=null,n.pinchStartScale=null,n.pinchStartDistance=null,n.isPinching=!1,_b(n,e==null?void 0:e.x,e==null?void 0:e.y)},z6=function(n,e){var t=n.props.onZoomStop,s=n.setup.doubleClick.animationTime;fc(n.doubleClickStopEventTimer),n.doubleClickStopEventTimer=setTimeout(function(){n.doubleClickStopEventTimer=null,gt(pt(n),e,t)},s)},yoe=function(n,e){var t=n.props,s=t.onZoomStart,r=t.onZoom,o=n.setup.doubleClick,i=o.animationTime,l=o.animationType;gt(pt(n),e,s),T6(n,i,l,function(){return gt(pt(n),e,r)}),z6(n,e)};function woe(n,e){return n==="toggle"?e===1?1:-1:n==="zoomOut"?-1:1}function Soe(n,e){var t=n.setup,s=n.doubleClickStopEventTimer,r=n.state,o=n.contentComponent,i=r.scale,l=n.props,c=l.onZoomStart,u=l.onZoom,d=t.doubleClick,f=d.disabled,m=d.mode,p=d.step,h=d.animationTime,g=d.animationType;if(!f&&!s){if(m==="reset")return yoe(n,e);if(!o)return console.error("No ContentComponent found");var x=woe(m,n.state.scale),b=_6(n,x,p);if(i!==b){gt(pt(n),e,c);var w=P6(e,o,i),v=Cb(n,b,w.x,w.y);if(!v)return console.error("Error during zoom event. New transformation state was not calculated.");gt(pt(n),e,u),Zo(n,v,h,g),z6(n,e)}}}var koe=function(n,e){var t=n.isInitialized,s=n.setup,r=n.wrapperComponent,o=s.doubleClick,i=o.disabled,l=o.excluded,c=e.target,u=r==null?void 0:r.contains(c),d=t&&c&&u&&!i;if(!d)return!1;var f=Xc(c,l);return!f},joe=(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&&ga(t,t.state.scale),t.setup=Jk(s)},this.initializeWindowEvents=function(){var s,r,o,i,l=Oh(),c=(s=t.wrapperComponent)===null||s===void 0?void 0:s.ownerDocument,u=c==null?void 0:c.defaultView;(r=t.wrapperComponent)===null||r===void 0||r.addEventListener("wheel",t.onWheelPanning,l),(o=t.wrapperComponent)===null||o===void 0||o.addEventListener("keyup",t.setKeyUnPressed,l),(i=t.wrapperComponent)===null||i===void 0||i.addEventListener("keydown",t.setKeyPressed,l),u==null||u.addEventListener("mousedown",t.onPanningStart,l),u==null||u.addEventListener("mousemove",t.onPanning,l),u==null||u.addEventListener("mouseup",t.onPanningStop,l),c==null||c.addEventListener("mouseleave",t.clearPanning,l),u==null||u.addEventListener("keyup",t.setKeyUnPressed,l),u==null||u.addEventListener("keydown",t.setKeyPressed,l),u==null||u.addEventListener("blur",t.handleWindowBlur)},this.cleanupWindowEvents=function(){var s,r,o,i,l,c=Oh(),u=(s=t.wrapperComponent)===null||s===void 0?void 0:s.ownerDocument,d=u==null?void 0:u.defaultView;d==null||d.removeEventListener("mousedown",t.onPanningStart,c),d==null||d.removeEventListener("mousemove",t.onPanning,c),d==null||d.removeEventListener("mouseup",t.onPanningStop,c),u==null||u.removeEventListener("mouseleave",t.clearPanning,c),d==null||d.removeEventListener("keyup",t.setKeyUnPressed,c),d==null||d.removeEventListener("keydown",t.setKeyPressed,c),d==null||d.removeEventListener("blur",t.handleWindowBlur),document.removeEventListener("mouseleave",t.clearPanning,c),(r=t.wrapperComponent)===null||r===void 0||r.removeEventListener("wheel",t.onWheelPanning,c),(o=t.wrapperComponent)===null||o===void 0||o.removeEventListener("keyup",t.setKeyUnPressed,c),(i=t.wrapperComponent)===null||i===void 0||i.removeEventListener("keydown",t.setKeyPressed,c),Us(t),(l=t.observer)===null||l===void 0||l.disconnect()},this.handleInitializeWrapperEvents=function(s){var r=Oh();s.addEventListener("wheel",t.onWheelZoom,r),s.addEventListener("dblclick",t.onDoubleClick,r),s.addEventListener("touchstart",t.onTouchPanningStart,r),s.addEventListener("touchmove",t.onTouchPanning,r),s.addEventListener("touchend",t.onTouchPanningStop,r)},this.handleInitialize=function(s){var r=t.setup.centerOnInit;t.applyTransformation(),t.onInitCallbacks.forEach(function(o){return o(pt(t))}),r&&(t.setCenter(),t.observer=new ResizeObserver(function(){var o,i=s.offsetWidth,l=s.offsetHeight;(i>0||l>0)&&(t.onInitCallbacks.forEach(function(c){return c(pt(t))}),t.setCenter(),(o=t.observer)===null||o===void 0||o.disconnect())}),setTimeout(function(){var o;(o=t.observer)===null||o===void 0||o.disconnect()},5e3),t.observer.observe(s))},this.onWheelZoom=function(s){var r=t.setup.disabled;if(!r){t.syncModifierKeys(s);var o=I6(t,s);o&&(foe(t,s),moe(t,s),poe(t,s))}},this.onWheelPanning=function(s){var r=t.props.onPanning,o=t.setup.trackPadPanning,i=o.lockAxisX,l=o.lockAxisY;t.syncModifierKeys(s);var c=soe(t,s);if(c){s.cancelable&&s.preventDefault(),s.stopPropagation();var u=t.state,d=u.positionX,f=u.positionY,m=d-s.deltaX,p=f-s.deltaY,h=i?d:m,g=l?f:p,x=t.setup.autoAlignment,b=x.sizeX,w=x.sizeY,v=Fo(t,b),j=Fo(t,w);h===d&&g===f||(hoe(t,s),j6(t,h,g,v,j),gt(pt(t),s,r),goe(t,s))}},this.onPanningStart=function(s){var r=t.setup.disabled,o=t.props.onPanningStart;if(!r){t.syncModifierKeys(s);var i=Hk(t,s);if(i){var l=t.isPressingKeys(t.setup.panning.activationKeys);l&&(s.button===0&&!t.setup.panning.allowLeftClickPan||s.button===1&&!t.setup.panning.allowMiddleClickPan||s.button===2&&!t.setup.panning.allowRightClickPan||(s.cancelable&&s.preventDefault(),s.stopPropagation(),Us(t),Zk(t,s),gt(pt(t),s,o)))}}},this.onPanning=function(s){var r=t.setup.disabled,o=t.props.onPanning;if(!r){if(t.syncModifierKeys(s),t.isPanning&&s.buttons===0){t.clearPanning(s);return}var i=Kk(t);if(i){var l=t.isPressingKeys(t.setup.panning.activationKeys);l&&(s.cancelable&&s.preventDefault(),s.stopPropagation(),Yk(t,s.clientX,s.clientY,jo.MOUSE),gt(pt(t),s,o))}}},this.onPanningStop=function(s){var r=t.setup.panning.velocityDisabled,o=t.props.onPanningStop;t.isPanning&&(qre(t,r),gt(pt(t),s,o))},this.onPinchStart=function(s){var r=t.setup.disabled,o=t.props.onPinchStart;if(!r){var i=aoe(t,s);i&&(xoe(t,s),Us(t),gt(pt(t),s,o))}},this.onPinch=function(s){var r=t.setup.disabled,o=t.props.onPinch;if(!r){var i=loe(t);i&&(s.cancelable&&s.preventDefault(),s.stopPropagation(),boe(t,s),gt(pt(t),s,o))}},this.onPinchStop=function(s){var r=t.props.onPinchStop;t.pinchStartScale&&(voe(t),gt(pt(t),s,r))},this.onTouchPanningStart=function(s){var r=t.setup,o=r.disabled,i=r.doubleClick,l=t.props.onPanningStart;if(!o){var c=!(i!=null&&i.disabled),u=t.lastTouch&&+new Date-t.lastTouch<200;if(c&&u&&s.touches.length===1)t.onDoubleClick(s);else{t.lastTouch=+new Date,Us(t);var d=s.touches,f=d.length===1,m=d.length===2,p=Hk(t,s);if(f){if(!p)return;Us(t),Zk(t,s),gt(pt(t),s,l)}m&&t.onPinchStart(s)}}},this.onTouchPanning=function(s){var r=t.setup.disabled,o=t.props.onPanning;if(t.isPanning&&s.touches.length===1){if(r)return;var i=Kk(t);if(!i)return;s.cancelable&&s.preventDefault(),s.stopPropagation();var l=s.touches[0];Yk(t,l.clientX,l.clientY,jo.TOUCH),gt(pt(t),s,o)}else s.touches.length>1&&t.onPinch(s)},this.onTouchPanningStop=function(s){t.onPanningStop(s),t.onPinchStop(s)},this.onDoubleClick=function(s){var r=t.setup.disabled;if(!r){var o=koe(t,s);o&&Soe(t,s)}},this.clearPanning=function(s){t.isPanning&&t.onPanningStop(s)},this.handleWindowBlur=function(){t.pressedKeys={},t.isPanning&&(t.isPanning=!1,t.startCoords=null)},this.syncModifierKeys=function(s){var r=s.ctrlKey,o=s.metaKey,i=s.shiftKey,l=s.altKey;typeof r=="boolean"&&(t.pressedKeys.Control=r),typeof o=="boolean"&&(t.pressedKeys.Meta=o),typeof i=="boolean"&&(t.pressedKeys.Shift=i),typeof l=="boolean"&&(t.pressedKeys.Alt=l)},this.setKeyPressed=function(s){t.pressedKeys[s.key]=!0},this.setKeyUnPressed=function(s){t.pressedKeys[s.key]=!1},this.isPressingKeys=function(s){return typeof s=="function"?s(Object.entries(t.pressedKeys).filter(function(r){var o=r[1];return o}).map(function(r){var o=r[0];return o})):s.length?!!s.every(function(r){return t.pressedKeys[r]}):!0},this.setCenter=function(){if(t.wrapperComponent&&t.contentComponent){var s=Eb(t.state.scale,t.wrapperComponent,t.contentComponent);t.setState(s.scale,s.positionX,s.positionY)}},this.handleTransformStyles=function(s,r,o){return t.props.customTransform?t.props.customTransform(s,r,o):A6(s,r,o)},this.getContext=function(){return pt(t)},this.applyTransformation=function(){if(!(!t.mounted||!t.contentComponent)){var s=t.state,r=s.scale,o=s.positionX,i=s.positionY,l=t.handleTransformStyles(o,i,r);t.props.detached||(t.contentComponent.style.transform=l),t.onTransformCallbacks.forEach(function(c){return c({scale:r,positionX:o,positionY:i,previousScale:t.state.previousScale,ref:pt(t)})})}},this.setState=function(s,r,o){var i=t.props.onTransform;if(!Number.isNaN(s)&&!Number.isNaN(r)&&!Number.isNaN(o)){var l=Math.max(s,1e-7);l!==t.state.scale&&(t.state.previousScale=t.state.scale,t.state.scale=l),t.state.positionX=r,t.state.positionY=o,t.applyTransformation();var c=pt(t);t.onChangeCallbacks.forEach(function(u){return u(c)}),gt(c,{scale:t.state.scale,positionX:r,positionY:o},i)}else console.error("Detected NaN set state values")},this.onTransform=function(s){return t.onTransformCallbacks.has(s)||t.onTransformCallbacks.add(s),function(){t.onTransformCallbacks.delete(s)}},this.onChange=function(s){return t.onChangeCallbacks.has(s)||t.onChangeCallbacks.add(s),function(){t.onChangeCallbacks.delete(s)}},this.onInit=function(s){return t.onInitCallbacks.has(s)||t.onInitCallbacks.add(s),function(){t.onInitCallbacks.delete(s)}},this.init=function(s,r){t.cleanupWindowEvents(),t.wrapperComponent=s,t.contentComponent=r,ga(t,t.state.scale),t.handleInitializeWrapperEvents(s),t.handleInitialize(r),t.initializeWindowEvents(),t.isInitialized=!0;var o=pt(t);gt(o,void 0,t.props.onInit),toe(t.props.ref,o)},this.props=e,this.setup=Jk(this.props),this.state=C6(this.props)}return n})(),ym=_e.createContext(null),Noe=function(n,e){return typeof n=="function"?n(e):n},Coe=_e.forwardRef(function(n,e){var t=y.useRef(new joe(n)).current,s=Noe(n.children,_1(t));return y.useImperativeHandle(e,function(){return _1(t)},[t]),y.useEffect(function(){t.update(n)},[t,n]),a.jsx(ym.Provider,ks({value:t},{children:s}))});_e.forwardRef(function(n,e){var t=y.useRef(null),s=y.useContext(ym);return y.useEffect(function(){return s.onChange(function(r){if(t.current){var o=0,i=0;t.current.style.transform=s.handleTransformStyles(o,i,1/r.instance.state.scale)}})},[s]),a.jsx("div",ks({},n,{ref:noe([t,e])}))});function _oe(n,e){e===void 0&&(e={});var t=e.insertAt;if(!(typeof document>"u")){var s=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&s.firstChild?s.insertBefore(r,s.firstChild):s.appendChild(r),r.styleSheet?r.styleSheet.cssText=n:r.appendChild(document.createTextNode(n))}}var Eoe=`.transform-component-module_wrapper__SPB86 {
376
376
  position: relative;
@@ -458,7 +458,7 @@ ${R}`:R:null}).filter(Boolean).join(`
458
458
  `),t=[];let s=0;for(;s<e.length;){const r=e[s];s++;const o=new Map;for(const i of r.matchAll(bde)){const[,l,c,u]=i,d=c??u,f=[];for(;s<e.length&&e[s].trim()!==d;)f.push(l?e[s].replace(/^\t+/,""):e[s]),s++;s>=e.length||(s++,o.set(d,f.join(`
459
459
  `)))}for(const i of wde(r))t.push({text:i.text,bodies:o,piped:i.piped})}return t}function kde(n,e){const t=n.match(/^cd\s+(?:"([^"]*)"|'([^']*)'|([^\s;&|]+))\s*$/);return t?jm(t[1]??t[2]??t[3]??"",e):null}function jde(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 Nde(n,e){if(n.piped||n.bodies.size===0)return null;const t=n.text.match(JA);if(!t)return null;const s=n.bodies.get(t[2]??t[3]??"");if(s===void 0)return null;const r=jde(n.text);if(!r)return null;const o=jm(r,e);return o?{name:"Write",input:{file_path:o,content:s}}:null}function O3(n,e){const t=e==="replacement";let s="";for(let r=0;r<n.length;r++){const o=n[r];if(o==="\\"){const i=n[r+1];if(i===void 0||i==="|"||!$3.test(i)&&!"\\/&#".includes(i))return null;s+=i,r++;continue}if(o==="&"&&t||!t&&$3.test(o))return null;s+=o}return s}const Cde=/^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 _de(n,e){var m;const t=(m=n.text.match(Cde))==null?void 0:m.groups;if(!t)return null;const{pattern:s,replacement:r,flags:o,dquoted:i,squoted:l,bare:c}=t;if(/[^g]/.test(o))return null;const u=O3(s,"pattern"),d=O3(r,"replacement");if(!u||d===null)return null;const f=jm(i??l??c??"",e);return f?{name:"Edit",input:{file_path:f,old_string:u,new_string:d,replace_all:o.includes("g")}}:null}function QA(n,e=null){if(n.fileDiffs)return nne(n.fileDiffs).map((o,i)=>({...ff(n,`${n.id}:bash-${i}`,"Edit",{file_path:o.filePath,old_string:o.oldString,new_string:o.newString}),diffLineCounts:o.diffLineCounts}));const t=n.input.command;if(typeof t!="string"||!t)return[];const s=[];let r=e;for(const o of Sde(t)){const i=kde(o.text,r);if(i){r=i;continue}const l=Nde(o,r)??_de(o,r);l&&s.push(ff(n,`${n.id}:bash-${s.length}`,l.name,l.input))}return s}function eI(n,e){const t=n.input.edits,s=n.input.file_path??n.input.path;if(!Array.isArray(t)||typeof s!="string")return[];const r=jm(s,e)??s,o=[];for(const[i,l]of t.entries()){if(typeof l!="object"||l===null)continue;const{old_string:c,new_string:u,replace_all:d}=l;typeof c!="string"||typeof u!="string"||o.push(ff(n,`${n.id}:edit-${i}`,"Edit",{file_path:r,old_string:c,new_string:u,replace_all:d===!0}))}return o}function tI(n,e){const t=[n.input.patch,n.input.value,n.input.input].find(s=>typeof s=="string");return t?OT("apply_patch",t,n.id,n.timestamp,e??"").map(s=>ff(n,s.id,s.name,s.input)):[]}function Ul(n,e=null){const t=[];for(const s of n)s.isError||s.awaitingReview||(s.name==="Edit"||s.name==="Write"?t.push(s):s.name==="MultiEdit"?t.push(...eI(s,e)):s.name==="Bash"?t.push(...QA(s,e)):s.name==="apply_patch"&&t.push(...tI(s,e)));return t}function mf(n,e=null){for(const t of n)if(!(t.isError||t.awaitingReview)&&(t.name==="Edit"||t.name==="Write"||t.name==="MultiEdit"&&eI(t,e).length>0||t.name==="Bash"&&QA(t,e).length>0||t.name==="apply_patch"&&tI(t,e).length>0))return!0;return!1}const pf=new Map;function Ede(n,e,t){let s=pf.get(e);if(!s){const r=new Map;s={observer:new IntersectionObserver(i=>{for(const l of i){if(!l.isIntersecting)continue;const c=r.get(l.target);L3(l.target,e),c==null||c()}},{rootMargin:e}),reveal:r},pf.set(e,s)}return s.reveal.set(n,t),s.observer.observe(n),()=>L3(n,e)}function L3(n,e){const t=pf.get(e);t!=null&&t.reveal.delete(n)&&(t.observer.unobserve(n),!(t.reveal.size>0)&&(t.observer.disconnect(),pf.delete(e)))}function Tde(n){const e=V.c(6),t="100%",s=y.useRef(null),[r,o]=y.useState(!1);let i,l;e[0]!==r||e[1]!==t?(i=()=>{const u=s.current;if(!(!u||r))return Ede(u,t,()=>o(!0))},l=[t,r],e[0]=r,e[1]=t,e[2]=i,e[3]=l):(i=e[2],l=e[3]),y.useEffect(i,l);let c;return e[4]!==r?(c={ref:s,revealed:r},e[4]=r,e[5]=c):c=e[5],c}const Ade=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"]),Ide={json:xy,jsonc:xy,md:kl,mdx:kl,txt:kl,png:Yo,jpg:Yo,jpeg:Yo,gif:Yo,webp:Yo,svg:Yo,ico:Yo,sh:mu,bash:mu,zsh:mu,fish:mu};function nI(n){const e=n.split("/").at(-1)??n,t=e.lastIndexOf(".");return t===-1?"":e.slice(t+1).toLowerCase()}function Pde(n){const e=nI(n);return Ide[e]??(Ade.has(e)?yc:b4)}function xa({add:n,del:e,dimmed:t,className:s,breakdown:r,onBreakdownRequest:o}){const i=G("flex shrink-0 items-center gap-1 font-mono text-xs tabular-nums",t&&"opacity-40",s),l=a.jsxs(a.Fragment,{children:[n>0&&a.jsxs("span",{className:"text-success",children:["+",n]}),e>0&&a.jsxs("span",{className:"text-destructive",children:["-",e]})]});return r===void 0||n+e===0?a.jsx("span",{className:i,children:l}):a.jsx(E4,{delay:0,children:a.jsxs(N4,{onOpenChange:c=>{c&&(o==null||o())},children:[a.jsx(C4,{render:a.jsx("span",{}),tabIndex:0,className:G(i,"cursor-default rounded-xs underline decoration-dotted underline-offset-4 outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50"),children:l}),a.jsx(T4,{children:a.jsx(A4,{side:"bottom",sideOffset:6,className:"isolate z-50",children:a.jsx(_4,{className:"z-50 w-fit origin-(--transform-origin) rounded-md bg-popover px-3 py-2 text-xs text-popover-foreground shadow-md ring-1 ring-foreground/10 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 motion-reduce:animate-none",children:r===null?a.jsx("span",{className:"text-muted-foreground",children:"Loading breakdown…"}):a.jsxs("div",{className:"grid grid-cols-[auto_auto_auto] items-baseline gap-x-4 gap-y-1 font-mono tabular-nums",children:[r.map(c=>a.jsx(M3,{...c},c.label)),a.jsx("div",{className:"col-span-3 my-0.5 border-t border-border"}),a.jsx(M3,{label:"Total",additions:n,deletions:e})]})})})})]})})}function M3({label:n,additions:e,deletions:t}){return a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"font-sans",children:n}),a.jsxs("span",{className:"text-right text-success",children:["+",e]}),a.jsxs("span",{className:"text-right text-destructive",children:["-",t]})]})}const z3=5;function qb(n){const e=V.c(11),{add:t,del:s}=n,r=t+s;if(r===0)return null;let o,i,l;if(e[0]!==t||e[1]!==r){const d=Math.round(t/r*z3);o=z3-d,i="flex items-center gap-[1px] shrink-0 ml-1",l=Array.from({length:d},Rde),e[0]=t,e[1]=r,e[2]=o,e[3]=i,e[4]=l}else o=e[2],i=e[3],l=e[4];let c;e[5]!==o?(c=Array.from({length:o},$de),e[5]=o,e[6]=c):c=e[6];let u;return e[7]!==i||e[8]!==l||e[9]!==c?(u=a.jsxs("span",{className:i,children:[l,c]}),e[7]=i,e[8]=l,e[9]=c,e[10]=u):u=e[10],u}function $de(n,e){return a.jsx("span",{className:"inline-block size-1.5 rounded-xs bg-destructive/70"},`d${e}`)}function Rde(n,e){return a.jsx("span",{className:"inline-block size-1.5 rounded-xs bg-success/70"},`a${e}`)}const hf="cogpit:open-subagent";function sI(n){const e=V.c(3),{hasEdit:t,hasWrite:s}=n;if(t&&s){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx("span",{className:"shrink-0 text-xs font-bold text-warning",children:"E+W"}),e[0]=o):o=e[0],o}if(s){let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx("span",{className:"shrink-0 text-xs font-bold text-success",children:"W"}),e[1]=o):o=e[1],o}let r;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx("span",{className:"shrink-0 text-xs font-bold text-warning",children:"E"}),e[2]=r):r=e[2],r}function Vb(n){const e=V.c(2),{agentId:t}=n;let s;return e[0]!==t?(s=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",className:"size-5 shrink-0 font-mono text-xs font-bold text-muted-foreground","aria-label":"Open sub-agent view",title:"Open sub-agent view",onClick:r=>{r.stopPropagation(),window.dispatchEvent(new CustomEvent(hf,{detail:{agentId:t}}))},children:"S"}),e[0]=t,e[1]=s):s=e[1],s}const rI=y.memo(function(e){const t=V.c(92),{file:s,defaultOpen:r,isHighlighted:o,diffMode:i}=e,{ref:l,revealed:c}=Tde(),[u,d]=y.useState(r),[f,m]=y.useState(r),p=y.useRef(r);let h;t[0]===Symbol.for("react.memo_cache_sentinel")?(h=ve=>{d(ve),ve?y.startTransition(()=>m(!0)):m(!1)},t[0]=h):h=t[0];const g=h;let x,b;t[1]!==r?(x=()=>{p.current!==r&&(p.current=r,g(r))},b=[r,g],t[1]=r,t[2]=x,t[3]=b):(x=t[2],b=t[3]),y.useEffect(x,b);let w,v;t[4]!==o?(w=()=>{o&&g(!0)},v=[o,g],t[4]=o,t[5]=w,t[6]=v):(w=t[5],v=t[6]),y.useEffect(w,v);let j;t[7]!==s.filePath?(j=nI(s.filePath),t[7]=s.filePath,t[8]=j):j=t[8];const k=j,_=s.netOriginal,N=s.netCurrent,S=!!(_||N);let C;t[9]!==s.edits?(C=s.edits.some(zde),t[9]=s.edits,t[10]=C):C=t[10];const T=i==="per-edit"?C:S,$=f&&c&&T,[A,R]=y.useState(0);let P;t[11]===Symbol.for("react.memo_cache_sentinel")?(P=ve=>{if(!ve)return;const Se=ve.offsetHeight;R(we=>we===Se?we:Se)},t[11]=P):P=t[11];const z=P,L=s.turnRange[0]===s.turnRange[1]?`T${s.turnRange[0]+1}`:`T${s.turnRange[0]+1}–T${s.turnRange[1]+1}`,I=s.filePath,M=o?"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 U;t[14]!==u?(U=()=>g(!u),t[14]=u,t[15]=U):U=t[15];let O;t[16]!==u?(O=u?a.jsx(_t,{"data-icon":"inline-start",className:"size-3 shrink-0 text-muted-foreground"}):a.jsx(it,{"data-icon":"inline-start",className:"size-3 shrink-0 text-muted-foreground"}),t[16]=u,t[17]=O):O=t[17];let D;t[18]!==k?(D=a.jsx("span",{className:"shrink-0 font-mono text-xs font-bold text-muted-foreground",children:k}),t[18]=k,t[19]=D):D=t[19];let B;t[20]!==s.opTypes?(B=s.opTypes.includes("Edit"),t[20]=s.opTypes,t[21]=B):B=t[21];let q;t[22]!==s.opTypes?(q=s.opTypes.includes("Write"),t[22]=s.opTypes,t[23]=q):q=t[23];let W;t[24]!==B||t[25]!==q?(W=a.jsx(sI,{hasEdit:B,hasWrite:q}),t[24]=B,t[25]=q,t[26]=W):W=t[26];let H;t[27]!==s.shortPath?(H=a.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",children:s.shortPath}),t[27]=s.shortPath,t[28]=H):H=t[28];let K;t[29]!==L?(K=a.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:L}),t[29]=L,t[30]=K):K=t[30];let Z;t[31]!==s.editCount?(Z=s.editCount>1&&a.jsxs(Fe,{variant:"outline",className:"h-5 shrink-0 px-1 font-mono text-xs text-muted-foreground",children:[s.editCount,"x"]}),t[31]=s.editCount,t[32]=Z):Z=t[32];let Y;t[33]!==u||t[34]!==U||t[35]!==O||t[36]!==D||t[37]!==W||t[38]!==H||t[39]!==K||t[40]!==Z?(Y=a.jsxs(Q,{type:"button",variant:"ghost",onClick:U,className:"h-auto min-w-0 flex-1 justify-start gap-1.5 rounded-r-none px-2 py-1 font-normal","aria-expanded":u,children:[O,D,W,H,K,Z]}),t[33]=u,t[34]=U,t[35]=O,t[36]=D,t[37]=W,t[38]=H,t[39]=K,t[40]=Z,t[41]=Y):Y=t[41];let X;t[42]!==s.subAgentId?(X=s.subAgentId&&a.jsx(Vb,{agentId:s.subAgentId}),t[42]=s.subAgentId,t[43]=X):X=t[43];let ee;t[44]!==s.filePath?(ee=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>cc(s.filePath),"aria-label":"Open file in editor"}),t[44]=s.filePath,t[45]=ee):ee=t[45];let te;t[46]===Symbol.for("react.memo_cache_sentinel")?(te=a.jsx(hx,{"data-icon":"inline-start"}),t[46]=te):te=t[46];let se;t[47]!==ee?(se=a.jsx(Zt,{render:ee,children:te}),t[47]=ee,t[48]=se):se=t[48];let J;t[49]===Symbol.for("react.memo_cache_sentinel")?(J=a.jsx(Yt,{children:"Open in editor"}),t[49]=J):J=t[49];let ne;t[50]!==se?(ne=a.jsxs(Gt,{children:[se,J]}),t[50]=se,t[51]=ne):ne=t[51];let ie;t[52]!==s.filePath?(ie=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>cc(s.filePath,{mode:"diff"}),"aria-label":"View git diff"}),t[52]=s.filePath,t[53]=ie):ie=t[53];let ae;t[54]===Symbol.for("react.memo_cache_sentinel")?(ae=a.jsx(i8,{"data-icon":"inline-start"}),t[54]=ae):ae=t[54];let oe;t[55]!==ie?(oe=a.jsx(Zt,{render:ie,children:ae}),t[55]=ie,t[56]=oe):oe=t[56];let ue;t[57]===Symbol.for("react.memo_cache_sentinel")?(ue=a.jsx(Yt,{children:"View git diff"}),t[57]=ue):ue=t[57];let re;t[58]!==oe?(re=a.jsxs(Gt,{children:[oe,ue]}),t[58]=oe,t[59]=re):re=t[59];let de;t[60]!==ne||t[61]!==re?(de=a.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[ne,re]}),t[60]=ne,t[61]=re,t[62]=de):de=t[62];let fe,le;t[63]!==s.addCount||t[64]!==s.delCount?(fe=a.jsx(xa,{add:s.addCount,del:s.delCount}),le=a.jsx(qb,{add:s.addCount,del:s.delCount}),t[63]=s.addCount,t[64]=s.delCount,t[65]=fe,t[66]=le):(fe=t[65],le=t[66]);let ce;t[67]!==X||t[68]!==de||t[69]!==fe||t[70]!==le?(ce=a.jsxs("div",{className:"flex items-center gap-1.5 pr-2 shrink-0",children:[X,de,fe,le]}),t[67]=X,t[68]=de,t[69]=fe,t[70]=le,t[71]=ce):ce=t[71];let he;t[72]!==Y||t[73]!==ce?(he=a.jsxs("div",{className:"group sticky top-0 z-10 flex w-full items-center rounded-t-lg bg-popover",children:[Y,ce]}),t[72]=Y,t[73]=ce,t[74]=he):he=t[74];let ge;t[75]!==i||t[76]!==s.edits||t[77]!==s.filePath||t[78]!==s.netStartLine||t[79]!==T||t[80]!==A||t[81]!==N||t[82]!==_||t[83]!==u||t[84]!==$?(ge=a.jsx(Ode,{showDiff:$,open:u,hasDiff:T,diffRef:z,lastDiffHeight:A,oldString:_,newString:N,filePath:s.filePath,diffMode:i,edits:s.edits,netStartLine:s.netStartLine}),t[75]=i,t[76]=s.edits,t[77]=s.filePath,t[78]=s.netStartLine,t[79]=T,t[80]=A,t[81]=N,t[82]=_,t[83]=u,t[84]=$,t[85]=ge):ge=t[85];let be;return t[86]!==s.filePath||t[87]!==l||t[88]!==F||t[89]!==he||t[90]!==ge?(be=a.jsxs("div",{ref:l,"data-file-path":I,className:F,children:[he,ge]}),t[86]=s.filePath,t[87]=l,t[88]=F,t[89]=he,t[90]=ge,t[91]=be):be=t[91],be}),Ode=y.memo(function(e){const t=V.c(15),{showDiff:s,open:r,hasDiff:o,diffRef:i,lastDiffHeight:l,oldString:c,newString:u,filePath:d,diffMode:f,edits:m,netStartLine:p}=e;if(s){let h;t[0]!==f||t[1]!==m||t[2]!==d||t[3]!==p||t[4]!==u||t[5]!==c?(h=f==="per-edit"?a.jsx(Mde,{edits:m,filePath:d}):a.jsx(Ub,{oldString:c,newString:u,filePath:d,compact:!1,startLine:p,hideHeader:!0}),t[0]=f,t[1]=m,t[2]=d,t[3]=p,t[4]=u,t[5]=c,t[6]=h):h=t[6];let g;return t[7]!==f||t[8]!==i||t[9]!==h?(g=a.jsx("div",{ref:i,className:"motion-enter overflow-hidden rounded-b",children:h},f),t[7]=f,t[8]=i,t[9]=h,t[10]=g):g=t[10],g}if(r&&l>0){let h;return t[11]!==l?(h=a.jsx("div",{style:{height:l}}),t[11]=l,t[12]=h):h=t[12],h}if(r&&!o){const h=f==="per-edit"?"No edits":"No net changes (all edits cancelled out)";let g;return t[13]!==h?(g=a.jsx("div",{className:"motion-enter px-3 py-2 text-xs italic text-muted-foreground",children:h}),t[13]=h,t[14]=g):g=t[14],g}return null}),D3=3,Lde=5,Mde=y.memo(function(e){const t=V.c(9),{edits:s,filePath:r}=e,o=s.length,i=s.filter(Dde),l=i.length>D3,[c,u]=y.useState(l?D3:i.length);y.useEffect(()=>{if(c>=i.length)return;const x=requestAnimationFrame(()=>{u(b=>Math.min(b+Lde,i.length))});return()=>cancelAnimationFrame(x)},[c,i.length]);const d=l?i.slice(0,c):i,f="divide-y divide-border/30";let m;t[0]!==r||t[1]!==o?(m=(x,b)=>a.jsxs("div",{children:[o>1&&a.jsxs("div",{className:"flex items-center gap-2 bg-muted/30 px-2.5 py-1",children:[a.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:[x.toolName," ",b+1,"/",o]}),a.jsxs("span",{className:"text-xs text-muted-foreground",children:["T",x.turnIndex+1]}),x.agentId&&a.jsx(Vb,{agentId:x.agentId})]}),a.jsx(Ub,{oldString:x.oldString,newString:x.newString,filePath:r,compact:!1,startLine:x.startLine,hideHeader:!0})]},x.id),t[0]=r,t[1]=o,t[2]=m):m=t[2];const p=d.map(m);let h;t[3]!==i.length||t[4]!==c?(h=c<i.length&&a.jsxs("div",{className:"py-1.5 text-center text-xs text-muted-foreground",children:["Loading ",i.length-c," more edits…"]}),t[3]=i.length,t[4]=c,t[5]=h):h=t[5];let g;return t[6]!==p||t[7]!==h?(g=a.jsxs("div",{className:f,children:[p,h]}),t[6]=p,t[7]=h,t[8]=g):g=t[8],g});function zde(n){return!!(n.oldString||n.newString)}function Dde(n){return!!(n.oldString||n.newString)}const Gh=new Map;function Fde(n){var _;const e=Nn("hostFiles"),{sessionSource:t}=kt(),s=t==null?void 0:t.dirName,r=un(s)==="codex",o=n.turns.length,i=((_=n.turns.at(-1))==null?void 0:_.toolCalls.length)??0,l=y.useMemo(()=>{let N=0;for(const S of n.turns){N+=S.toolCalls.length;for(const C of S.subAgentActivity)N+=C.toolCalls.length}return N},[o,i]),c=y.useMemo(()=>{const N=[];for(let S=0;S<n.turns.length;S++)for(const C of n.turns[S].subAgentActivity){const E=r&&(C.status==="completed"||C.status==="failed"||C.status==="interrupted");(C.isBackground||E)&&C.toolCalls.length===0&&N.push({agentId:C.agentId,turnIndex:S})}return N},[n.turns,l,r]),[u,d]=y.useState(new Map),f=y.useRef(new Set);y.useEffect(()=>{if(!s||!n.sessionId||c.length===0)return;const N=[];for(const{agentId:E}of c){const T=sn(`${s}/${n.sessionId}/${E}`);if(!f.current.has(T)){if(Gh.has(T)){d($=>{const A=new Map($);return A.set(E,Gh.get(T)),A}),f.current.add(T);continue}N.push({agentId:E,cacheKey:T})}}if(N.length===0)return;let S=!1;async function C(){const E=new Map;await Promise.all(N.map(async({agentId:T,cacheKey:$})=>{try{const A=`/api/sessions/${encodeURIComponent(s)}/${encodeURIComponent(n.sessionId)}/subagents/agent-${encodeURIComponent(T)}.jsonl`,R=await Ce(A);if(!R.ok)return;const P=await R.text(),L=PA(P,T).flatMap(I=>Ul(I.toolCalls,n.cwd));Gh.set($,L),f.current.add($),E.set(T,L)}catch{}})),!S&&E.size>0&&d(T=>{const $=new Map(T);for(const[A,R]of E)$.set(A,R);return $})}return C(),()=>{S=!0}},[s,n.sessionId,n.cwd,c]);const m=y.useMemo(()=>{const N=[],S=new Set;for(let C=0;C<n.turns.length;C++){const E=n.turns[C];for(const T of Ul(E.toolCalls,n.cwd))N.push({turnIndex:C,toolCall:T});for(const T of E.subAgentActivity){for(const $ of Ul(T.toolCalls,n.cwd))N.push({turnIndex:C,toolCall:$,agentId:T.agentId});if((T.isBackground||r)&&T.toolCalls.length===0&&!S.has(T.agentId)){S.add(T.agentId);const $=u.get(T.agentId);if($)for(const A of $)N.push({turnIndex:C,toolCall:A,agentId:T.agentId})}}}return N},[l,n.turns,u,r]),p=y.useMemo(()=>{const N=new Map;for(const{toolCall:S}of m){const C=oI(S);C&&N.set(C,JSON.stringify([S.id,S.input,S.result]))}return JSON.stringify([...N])},[m]),h=sn(JSON.stringify([s,n.sessionId,n.cwd])),[g,x]=y.useState(new Map),b=y.useRef(new Map),[w,v]=y.useState(0);y.useEffect(()=>{const N=()=>v(S=>S+1);return window.addEventListener("focus",N),()=>window.removeEventListener("focus",N)},[]),y.useEffect(()=>{b.current=new Map},[h,t==null?void 0:t.rawText,w]),y.useEffect(()=>{const N=JSON.parse(p);if(!e||N.length===0){x(E=>E.size?new Map:E);return}let S=!1;const C=b.current;return Promise.all(N.map(async([E,T])=>{const $=C.get(E);if(($==null?void 0:$.revision)===T)return[E,$.text];try{const A=await Ce(`/api/file-content?path=${encodeURIComponent(E)}`);if(!A.ok)return null;const R=await A.text();return S?null:(C.set(E,{revision:T,text:R}),[E,R])}catch{return null}})).then(E=>{if(S)return;const T=new Map;for(const $ of E)$&&T.set(...$);for(const $ of C.keys())T.has($)||C.delete($);x($=>$.size===T.size&&[...T].every(([A,R])=>$.get(A)===R)?$:T)}),()=>{S=!0}},[e,p,h,t==null?void 0:t.rawText,w]);const j=n.turns.length-1,k=y.useMemo(()=>{const N=new Map;for(const S of n.turns)for(const C of S.subAgentActivity)N.has(C.agentId)||N.set(C.agentId,{name:C.agentName,type:C.subagentType});return N},[n.turns]);return{fileChanges:m,fileContents:g,lastTurnIndex:j,agentMap:k}}function F3(n,e){if(!n||!e)return 1;const t=n.indexOf(e);if(t===-1)return 1;let s=1;for(let r=0;r<t;r++)n[r]===`
460
460
  `&&s++;return s}function oI(n){return String(n.input.file_path??n.input.path??"")}function Ude(n){const e=n.name==="Edit";return{oldString:e?String(n.input.old_string??""):"",newString:String(e?n.input.new_string??"":n.input.content??""),isWrite:!e,diffLineCounts:n.diffLineCounts}}function iI(n,e,t){const s=new Map;for(const o of n){if(e!=="all"&&o.turnIndex!==e)continue;const i=oI(o.toolCall);if(!i)continue;let l=s.get(i);l||(l=[],s.set(i,l)),l.push(o)}const r=[];for(const[o,i]of s){const l=[],c=[];let u=1/0,d=-1/0,f=!1,m=!1,p;const h=t==null?void 0:t.get(o);for(let b=0;b<i.length;b++){const w=i[b],v=Ude(w.toolCall);l.push(v),w.turnIndex<u&&(u=w.turnIndex),w.turnIndex>d&&(d=w.turnIndex),w.toolCall.name==="Edit"?f=!0:m=!0,w.agentId&&(p=w.agentId),c.push({id:w.toolCall.id,oldString:v.oldString,newString:v.newString,toolName:w.toolCall.name,turnIndex:w.turnIndex,agentId:w.agentId,startLine:w.toolCall.name==="Write"?1:F3(h,v.newString||v.oldString)})}const g=Wle(l),x=[];f&&x.push("Edit"),m&&x.push("Write"),r.push({filePath:o,shortPath:o.split("/").slice(-3).join("/"),editCount:i.length,turnRange:[u,d],opTypes:x,netOriginal:g.originalStr,netCurrent:g.currentStr,addCount:g.addCount,delCount:g.delCount,subAgentId:p??null,edits:c,netStartLine:g.currentStr?F3(h,g.currentStr):c.length>0?c[0].startLine:1})}return r.sort((o,i)=>o.turnRange[1]-i.turnRange[1]||o.turnRange[0]-i.turnRange[0]||o.filePath.localeCompare(i.filePath)),r}function Bde(n,e,t,s){const r=new Map;for(const i of n){if(!i.agentId||e!=="all"&&i.turnIndex!==e)continue;let l=r.get(i.agentId);l||(l=[],r.set(i.agentId,l)),l.push(i)}const o=[];for(const[i,l]of r){const c=iI(l,"all",s);if(c.length===0)continue;let u=0,d=0;for(const m of c)u+=m.addCount,d+=m.delCount;const f=t.get(i);o.push({agentId:i,agentName:(f==null?void 0:f.name)??null,subagentType:(f==null?void 0:f.type)??null,files:c,totalAdd:u,totalDel:d})}return o.sort((i,l)=>{var d,f;const c=((d=i.files[0])==null?void 0:d.turnRange[0])??0,u=((f=l.files[0])==null?void 0:f.turnRange[0])??0;return c-u}),o}const aI={code:"Code",tests:"Tests",mocks:"Mocks",generated:"Generated",docs:"Docs"},U3=Object.keys(aI),Wde=new Set(["bun.lock","bun.lockb","cargo.lock","composer.lock","deno.lock","flake.lock","gemfile.lock","go.sum","gradle.lockfile","mix.lock","npm-shrinkwrap.json","package-lock.json","packages.lock.json","pipfile.lock","pnpm-lock.yaml","podfile.lock","poetry.lock","pubspec.lock","uv.lock","yarn.lock"]),qde=/(\.generated\.|\.gen\.|\.g\.dart$|\.pb\.go$|_pb2(_grpc)?\.py$|\.pb\.(cc|h)$|\.min\.(js|css)$|\.(js|css)\.map$)/,Vde=new Set(["__generated__","generated"]),Hde=/(\.snap$|\.(mocks?|fixtures?|stubs?|fakes?)\.[^.]+$|^(mocks?|fixtures?|stubs?|fakes?)([-_.A-Z]|$))/,Kde=new Set(["__fixtures__","__mocks__","__snapshots__","fakes","fixture","fixtures","mock","mocks","stubs","testdata"]),Gde=/(\.(test|spec|e2e)\.[^.]+$|_(test|spec)\.[^.]+$|^test_.+\.py$|^conftest\.py$|^(vitest|jest)\.setup\.[^.]+$)/i,Zde=/(Tests?|Spec)\.(java|kt|kts|scala|groovy|cs|php|swift|m)$/,Yde=new Set(["__tests__","__test__","cypress","e2e","spec","specs","test","tests"]),Xde=/\.(md|mdx|markdown|rst|adoc|txt)$/i,Jde=/^(requirements.*|constraints.*|CMakeLists|robots|llms)\.txt$/i;function Qde(n){const e=n.replaceAll("\\","/").split("/"),t=e.pop()??"",s=e.map(o=>o.toLowerCase()),r=o=>s.some(i=>o.has(i));return Wde.has(t.toLowerCase())||qde.test(t)||r(Vde)?"generated":Hde.test(t)||r(Kde)?"mocks":Gde.test(t)||Zde.test(t)||r(Yde)?"tests":Xde.test(t)&&!Jde.test(t)?"docs":"code"}function efe(n){const e=U3.map(t=>({kind:t,label:aI[t],additions:0,deletions:0}));for(const t of n){const s=e[U3.indexOf(Qde(t.path))];s.additions+=t.additions,s.deletions+=t.deletions}return e.filter(t=>t.additions>0||t.deletions>0)}function lI(n,e){return efe(Array.from(e,t=>({path:j1(n,t.filePath)??t.filePath,additions:t.additions,deletions:t.deletions})))}const gc="cogpit:focus-file",tfe="cogpit:file-changes-prefs",nfe={expanded:!0,diffMode:"net",scope:"last",groupByAgent:!1};function cI(n,e){return lI(n,e.map(t=>({filePath:t.filePath,additions:t.addCount,deletions:t.delCount})))}function sfe(n){const e=V.c(38),{group:t,cwd:s,allExpanded:r,highlightPath:o,diffMode:i}=n;let l;e[0]!==t.agentId||e[1]!==t.agentName?(l=t.agentName||t.agentId.slice(0,8),e[0]=t.agentId,e[1]=t.agentName,e[2]=l):l=e[2];const c=l,u=t.subagentType,d=`Open subagent ${t.agentId}`;let f;e[3]!==t.agentId?(f=()=>{window.dispatchEvent(new CustomEvent(hf,{detail:{agentId:t.agentId}}))},e[3]=t.agentId,e[4]=f):f=e[4];let m;e[5]!==c||e[6]!==d||e[7]!==f?(m=a.jsx(Q,{type:"button",variant:"ghost",size:"xs",className:"h-auto min-w-0 truncate px-1 text-xs font-semibold",title:d,onClick:f,children:c}),e[5]=c,e[6]=d,e[7]=f,e[8]=m):m=e[8];let p;e[9]!==u?(p=u&&a.jsx("span",{className:"truncate text-xs text-muted-foreground",children:u}),e[9]=u,e[10]=p):p=e[10];let h;e[11]!==t.files.length?(h=a.jsx(Fe,{variant:"outline",className:"h-5 px-1.5 text-xs text-muted-foreground",children:t.files.length}),e[11]=t.files.length,e[12]=h):h=e[12];let g;e[13]===Symbol.for("react.memo_cache_sentinel")?(g=a.jsx("div",{className:"flex-1"}),e[13]=g):g=e[13];const x=t.totalAdd,b=t.totalDel;let w;e[14]!==s||e[15]!==t.files?(w=cI(s,t.files),e[14]=s,e[15]=t.files,e[16]=w):w=e[16];let v;e[17]!==t.totalAdd||e[18]!==t.totalDel||e[19]!==w?(v=a.jsx(xa,{add:x,del:b,breakdown:w}),e[17]=t.totalAdd,e[18]=t.totalDel,e[19]=w,e[20]=v):v=e[20];let j;e[21]!==v||e[22]!==m||e[23]!==p||e[24]!==h?(j=a.jsxs("div",{className:"flex items-center gap-2 px-1.5 pt-1.5 pb-0.5",children:[m,p,h,g,v]}),e[21]=v,e[22]=m,e[23]=p,e[24]=h,e[25]=j):j=e[25];let k;if(e[26]!==r||e[27]!==i||e[28]!==t.files||e[29]!==o){let N;e[31]!==r||e[32]!==i||e[33]!==o?(N=S=>a.jsx(rI,{file:S,defaultOpen:r,isHighlighted:o===S.filePath,diffMode:i},S.filePath),e[31]=r,e[32]=i,e[33]=o,e[34]=N):N=e[34],k=t.files.map(N),e[26]=r,e[27]=i,e[28]=t.files,e[29]=o,e[30]=k}else k=e[30];let _;return e[35]!==j||e[36]!==k?(_=a.jsxs("div",{className:"flex flex-col gap-1",children:[j,k]}),e[35]=j,e[36]=k,e[37]=_):_=e[37],_}const rfe=y.memo(function({session:e,sessionChangeKey:t}){const s=y.useRef(null),r=y.useRef(null),o=y.useRef(!0),i=y.useRef(!1),l=y.useRef(0),c=y.useRef(e.turns.length),[u,d]=y.useState(!1),[f,m]=y.useState(!1),[p,h]=kr(tfe,{}),g={...nfe,...p},x=g.expanded,b=g.diffMode,w=g.groupByAgent,[v,j]=y.useState(g.scope),k=y.useCallback(W=>{h(H=>({...H,expanded:W}))},[h]),_=y.useCallback(W=>{h(H=>({...H,diffMode:W}))},[h]),N=y.useCallback(W=>{h(H=>({...H,groupByAgent:W}))},[h]);y.useEffect(()=>{typeof v!="number"&&h(W=>({...W,scope:v}))},[v,h]);const[S,C]=y.useState(null),E=y.useRef(null),{fileChanges:T,fileContents:$,lastTurnIndex:A,agentMap:R}=Fde(e),P=y.useMemo(()=>iI(T,typeof v=="number"?v:v==="all"?"all":A,$),[T,v,A,$]),z=y.useMemo(()=>w?Bde(T,typeof v=="number"?v:v==="all"?"all":A,R,$):[],[w,T,v,A,R,$]);y.useEffect(()=>{const W=H=>{const K=H.detail;K!=null&&K.filePath&&(j(K.turnIndex),C(K.filePath),E.current&&clearTimeout(E.current),E.current=setTimeout(()=>C(null),3e3),requestAnimationFrame(()=>{var Y;const Z=(Y=s.current)==null?void 0:Y.querySelector(`[data-file-path="${CSS.escape(K.filePath)}"]`);Z==null||Z.scrollIntoView({behavior:"smooth",block:"nearest"})}))};return window.addEventListener(gc,W),()=>{window.removeEventListener(gc,W),E.current&&clearTimeout(E.current)}},[]);const L=y.useCallback(()=>{const W=s.current;W&&(d(W.scrollTop>10),m(W.scrollHeight-W.scrollTop-W.clientHeight>10))},[]),I=y.useCallback(()=>{const W=s.current;W&&(o.current=W.scrollHeight-W.scrollTop-W.clientHeight<50,L())},[L]);if(y.useEffect(()=>{L()},[T.length,P.length,L]),y.useEffect(()=>{const W=s.current;W&&(W.scrollTop=W.scrollHeight),o.current=!0,i.current=!1,l.current=T.length,c.current=e.turns.length,j(g.scope),C(null),L()},[t]),y.useEffect(()=>{const W=e.turns.length;W>c.current&&(i.current=!0),c.current=W},[e.turns.length]),y.useEffect(()=>{if(T.length<=l.current){l.current=T.length;return}l.current=T.length,(i.current||o.current)&&(requestAnimationFrame(()=>{var W;(W=r.current)==null||W.scrollIntoView({behavior:"smooth"})}),i.current=!1)},[T.length]),T.length===0)return null;const M=w?z.flatMap(W=>W.files):P;let F=0,U=0;for(const W of M)F+=W.addCount,U+=W.delCount;const O=M.length;function D(){j(v==="last"?"all":"last")}function B(){return typeof v=="number"?`Turn ${v+1}`:v==="all"?"All turns":`Last turn (T${A+1})`}const q=B();return a.jsxs("div",{className:"view-transition-file-panel panel-enter-bottom flex h-full min-w-0 flex-col overflow-hidden bg-canvas",children:[a.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 border-b px-3",children:[a.jsx(yc,{"data-icon":"inline-start",className:"size-3.5 text-muted-foreground"}),a.jsx("span",{className:"text-xs font-medium text-foreground",children:"File Changes"}),a.jsxs(Fe,{variant:"outline",className:"h-5 px-1.5 text-xs text-muted-foreground",children:[O," file",O!==1?"s":""]}),a.jsx("div",{className:"flex-1"}),a.jsx(xa,{add:F,del:U,breakdown:cI(e.cwd,M)}),a.jsxs(Gt,{children:[a.jsx(Zt,{render:a.jsx(Q,{variant:w?"secondary":"ghost",size:"icon-xs",onClick:()=>N(!w),"aria-label":w?"Show all changes":"Group by subagent"}),children:a.jsx(er,{"data-icon":"inline-start"})}),a.jsx(Yt,{children:w?"Show all changes":"Group by subagent"})]}),a.jsxs(Gt,{children:[a.jsx(Zt,{render:a.jsx(Q,{variant:v==="all"?"secondary":"ghost",size:"icon-xs",onClick:D,"aria-label":v==="last"?"Show all turns":"Show last turn only"}),children:v==="all"?a.jsx(jd,{"data-icon":"inline-start"}):a.jsx(Io,{"data-icon":"inline-start"})}),a.jsx(Yt,{children:v==="last"?"Click for all turns":"Click for last turn only"})]}),a.jsxs(Gt,{children:[a.jsx(Zt,{render:a.jsx(Q,{variant:b==="per-edit"?"secondary":"ghost",size:"icon-xs",onClick:()=>_(b==="net"?"per-edit":"net"),"aria-label":b==="net"?"Show per-edit diffs":"Show net diff"}),children:b==="net"?a.jsx(a8,{"data-icon":"inline-start"}):a.jsx(l8,{"data-icon":"inline-start"})}),a.jsx(Yt,{children:b==="net"?"Switch to per-edit diffs":"Switch to net diff"})]}),a.jsxs(Gt,{children:[a.jsx(Zt,{render:a.jsx(Q,{variant:"ghost",size:"icon-xs",onClick:()=>k(!x),"aria-label":x?"Collapse all":"Expand all"}),children:x?a.jsx(Nf,{"data-icon":"inline-start"}):a.jsx(_a,{"data-icon":"inline-start"})}),a.jsx(Yt,{children:x?"Collapse all":"Expand all"})]})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b bg-muted/30 px-3 py-1",children:[a.jsx("span",{className:"text-xs text-muted-foreground",children:"Showing:"}),v!=="all"&&A>0&&a.jsx(Q,{variant:"ghost",size:"icon-xs",onClick:()=>{const W=typeof v=="number"?v:A;W>0&&j(W-1)},disabled:(typeof v=="number"?v:A)<=0,"aria-label":"Previous turn",children:a.jsx(lx,{"data-icon":"inline-start"})}),a.jsx("span",{className:G("text-xs font-medium",typeof v=="number"?"text-foreground":"text-muted-foreground"),children:q}),v!=="all"&&A>0&&a.jsx(Q,{variant:"ghost",size:"icon-xs",onClick:()=>{j(W=>typeof W!="number"?W:W+1>=A?"last":W+1)},disabled:v==="last","aria-label":"Next turn",children:a.jsx(it,{"data-icon":"inline-start"})}),typeof v=="number"&&a.jsx(Q,{variant:"ghost",size:"icon-xs",onClick:()=>j("last"),"aria-label":"Back to last turn",children:a.jsx(Mt,{"data-icon":"inline-start"})})]}),a.jsxs("div",{className:"relative flex-1 min-h-0",children:[a.jsx("div",{className:G("pointer-events-none absolute inset-x-0 top-0 z-10 h-6 bg-gradient-to-b from-canvas to-transparent transition-opacity duration-200",u?"opacity-100":"opacity-0")}),a.jsxs("div",{ref:s,onScroll:I,className:"h-full overflow-y-auto",children:[a.jsx("div",{className:"flex flex-col gap-1 p-1.5",children:w?z.length>0?z.map(W=>a.jsx(sfe,{group:W,cwd:e.cwd,allExpanded:x,highlightPath:S,diffMode:b},W.agentId)):a.jsxs("div",{className:"py-4 text-center text-xs text-muted-foreground",children:["No subagent changes in ",q.toLowerCase()]}):P.length>0?P.map(W=>a.jsx(rI,{file:W,defaultOpen:x,isHighlighted:S===W.filePath,diffMode:b},W.filePath)):a.jsxs("div",{className:"py-4 text-center text-xs text-muted-foreground",children:["No file changes in ",q.toLowerCase()]})}),a.jsx("div",{ref:r})]}),a.jsx("div",{className:G("pointer-events-none absolute inset-x-0 bottom-0 z-10 h-6 bg-gradient-to-t from-canvas to-transparent transition-opacity duration-200",f?"opacity-100":"opacity-0")})]})]})});function ofe(n,e){const t=new Map;function s(r,o){const i=String(r.input.file_path??r.input.path??"");if(!i)return;const l=r.name==="Edit",c=l?String(r.input.old_string??""):"",u=String(l?r.input.new_string??"":r.input.content??""),d=r.diffLineCounts??I1(c,u),f=t.get(i)??{add:0,del:0,hasEdit:!1,hasWrite:!1,subAgentId:null};f.add+=d.add,f.del+=d.del,l?f.hasEdit=!0:f.hasWrite=!0,o&&(f.subAgentId=o),t.set(i,f)}return Ul(n.toolCalls,e).forEach(r=>s(r)),n.subAgentActivity.forEach(r=>Ul(r.toolCalls,e).forEach(o=>s(o,r.agentId))),[...t.entries()].map(([r,{add:o,del:i,hasEdit:l,hasWrite:c,subAgentId:u}])=>({filePath:r,additions:o,deletions:i,hasEdit:l,hasWrite:c,subAgentId:u}))}function B3(){return{children:new Map,isFile:!1,absPath:"",additions:0,deletions:0,hasEdit:!1,hasWrite:!1,subAgentId:null}}function ife(n,e){if(n.length===0)return[];const t=e.endsWith("/")?e.slice(0,-1):e,s=B3();for(const o of n){let i=o.filePath;t&&i.startsWith(t+"/")?i=i.slice(t.length+1):i.startsWith("/")&&(i=i.slice(1));const l=i.split("/");let c=s;for(let u=0;u<l.length;u++){let d=c.children.get(l[u]);d||(d=B3(),c.children.set(l[u],d)),u===l.length-1&&(d.isFile=!0,d.absPath=o.filePath,d.additions+=o.additions,d.deletions+=o.deletions,o.hasEdit&&(d.hasEdit=!0),o.hasWrite&&(d.hasWrite=!0),o.subAgentId&&(d.subAgentId=o.subAgentId)),c=d}}function r(o,i){return[...o.children.entries()].sort(([c,u],[d,f])=>{const m=u.isFile&&u.children.size===0,p=f.isFile&&f.children.size===0;return m!==p?m?1:-1:c.localeCompare(d)}).map(([c,u])=>{const d=i?`${i}/${c}`:c;if(u.isFile&&u.children.size===0)return{name:c,fullPath:d,absPath:u.absPath,isFile:!0,additions:u.additions,deletions:u.deletions,hasEdit:u.hasEdit,hasWrite:u.hasWrite,subAgentId:u.subAgentId,children:[]};let f=u,m=c,p=d;for(;!f.isFile&&f.children.size===1;){const[j,k]=[...f.children.entries()][0];if(k.isFile&&k.children.size===0)break;m+="/"+j,p+="/"+j,f=k}const h=r(f,p);let g=0,x=0,b=f.isFile?f.hasEdit:!1,w=f.isFile?f.hasWrite:!1,v=f.isFile?f.subAgentId:null;for(const j of h)g+=j.additions,x+=j.deletions,j.hasEdit&&(b=!0),j.hasWrite&&(w=!0),j.subAgentId&&(v=j.subAgentId);return f.isFile&&(g+=f.additions,x+=f.deletions),{name:m,fullPath:p,absPath:f.absPath,isFile:!1,additions:g,deletions:x,hasEdit:b,hasWrite:w,subAgentId:v,children:h}})}return r(s,"")}const afe=y.memo(function(e){const t=V.c(54),{turn:s,turnIndex:r,cwd:o}=e,i=Nn("hostFiles");let l;t[0]!==o||t[1]!==s?(l=ofe(s,o),t[0]=o,t[1]=s,t[2]=l):l=t[2];const c=l;let u;t[3]!==o||t[4]!==c?(u=ife(c,o),t[3]=o,t[4]=c,t[5]=u):u=t[5];const d=u,[f,m]=y.useState(!1);let p=0,h=0;if(t[6]!==p||t[7]!==h||t[8]!==c){for(const I of c)p=p+I.additions,h=h+I.deletions;t[6]=p,t[7]=h,t[8]=c,t[9]=p,t[10]=h}else p=t[9],h=t[10];const g=p,x=h;let b;t[11]!==o||t[12]!==c?(b=lI(o,c),t[11]=o,t[12]=c,t[13]=b):b=t[13];let w;t[14]!==p||t[15]!==h||t[16]!==b?(w={add:g,del:x,breakdown:b},t[14]=p,t[15]=h,t[16]=b,t[17]=w):w=t[17];const v=w;if(c.length===0)return null;const j=f&&"rotate-90";let k;t[18]!==j?(k=G("size-3 shrink-0 transition-transform duration-150 motion-reduce:transition-none",j),t[18]=j,t[19]=k):k=t[19];let _;t[20]!==k?(_=a.jsx(it,{"data-icon":"inline-start",className:k}),t[20]=k,t[21]=_):_=t[21];let N;t[22]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx(yc,{className:"size-3.5 shrink-0","data-icon":"inline-start"}),t[22]=N):N=t[22];const S=c.length!==1?"s":"";let C;t[23]!==c.length||t[24]!==S?(C=a.jsxs("span",{className:"font-medium tabular-nums",children:[c.length," file",S]}),t[23]=c.length,t[24]=S,t[25]=C):C=t[25];let E;t[26]!==C||t[27]!==_?(E=a.jsxs(rs,{className:"flex cursor-pointer items-center gap-1.5 text-left outline-none after:absolute after:inset-0 after:rounded-md focus-visible:after:ring-[3px] focus-visible:after:ring-ring/50",children:[_,N,C]}),t[26]=C,t[27]=_,t[28]=E):E=t[28];let T;t[29]!==v.add||t[30]!==v.breakdown||t[31]!==v.del?(T=a.jsx(xa,{add:v.add,del:v.del,breakdown:v.breakdown,className:"relative opacity-80"}),t[29]=v.add,t[30]=v.breakdown,t[31]=v.del,t[32]=T):T=t[32];let $;t[33]!==v.add||t[34]!==v.del?($=a.jsx(qb,{add:v.add,del:v.del}),t[33]=v.add,t[34]=v.del,t[35]=$):$=t[35];let A;t[36]===Symbol.for("react.memo_cache_sentinel")?(A=a.jsx("span",{"aria-hidden":!0,className:"pointer-events-none ml-1 h-px flex-1 bg-border/40 transition-colors group-hover/files:bg-border/70"}),t[36]=A):A=t[36];let R;t[37]!==E||t[38]!==T||t[39]!==$?(R=a.jsxs("div",{className:"group/files relative flex min-h-7 w-full items-center gap-1.5 px-1 text-xs text-muted-foreground transition-colors hover:text-foreground",children:[E,T,$,A]}),t[37]=E,t[38]=T,t[39]=$,t[40]=R):R=t[40];let P;if(t[41]!==i||t[42]!==d||t[43]!==r){let I;t[45]!==i||t[46]!==r?(I=M=>a.jsx(lfe,{node:M,depth:0,turnIndex:r,canFocusFiles:i},M.fullPath),t[45]=i,t[46]=r,t[47]=I):I=t[47],P=d.map(I),t[41]=i,t[42]=d,t[43]=r,t[44]=P}else P=t[44];let z;t[48]!==P?(z=a.jsx(yn,{className:"ml-1 border-l border-border/40 pl-3",children:a.jsx("div",{className:"py-0.5",children:P})}),t[48]=P,t[49]=z):z=t[49];let L;return t[50]!==f||t[51]!==R||t[52]!==z?(L=a.jsxs(vn,{open:f,onOpenChange:m,children:[R,z]}),t[50]=f,t[51]=R,t[52]=z,t[53]=L):L=t[53],L}),lfe=y.memo(function n({node:e,depth:t,turnIndex:s,canFocusFiles:r}){const[o,i]=y.useState(!0),l=t*16+8;if(e.isFile){const c=Pde(e.name),u=()=>{r&&e.absPath&&window.dispatchEvent(new CustomEvent(gc,{detail:{filePath:e.absPath,turnIndex:s}}))};return a.jsxs("div",{className:"flex h-7 w-full items-center gap-1.5 font-mono text-xs",style:{paddingLeft:l},children:[a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",disabled:!r,className:G("h-7 min-w-0 flex-1 justify-start gap-1.5 rounded-sm px-0 font-mono text-xs font-normal disabled:opacity-100",r&&"cursor-pointer"),onClick:u,title:r?"Click to focus in sidebar":void 0,children:[a.jsx(c,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}),a.jsx(sI,{hasEdit:e.hasEdit,hasWrite:e.hasWrite}),a.jsx("span",{className:"truncate text-foreground/75",children:e.name})]}),e.subAgentId&&a.jsx(Vb,{agentId:e.subAgentId}),a.jsx(xa,{add:e.additions,del:e.deletions}),a.jsx(qb,{add:e.additions,del:e.deletions})]})}return a.jsxs(a.Fragment,{children:[a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",className:"h-7 w-full justify-start gap-1 rounded-sm font-mono text-xs font-normal",style:{paddingLeft:l},onClick:()=>i(!o),"aria-expanded":o,children:[o?a.jsx(_t,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}):a.jsx(it,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}),a.jsx(sa,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}),a.jsx("span",{className:"truncate text-foreground/70",children:e.name}),a.jsx("div",{className:"flex-1 min-w-2"}),!o&&a.jsx(xa,{add:e.additions,del:e.deletions,dimmed:!0})]}),o&&e.children.map(c=>a.jsx(n,{node:c,depth:t+1,turnIndex:s,canFocusFiles:r},c.fullPath))]})});function cfe(n){const e=V.c(14),{branchCount:t,onClick:s}=n;if(t===0)return null;let r;e[0]!==s?(r=a.jsx(Q,{variant:"ghost",size:"xs",onClick:f=>{f.stopPropagation(),s()},className:"h-6 text-muted-foreground"}),e[0]=s,e[1]=r):r=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(gx,{"data-icon":"inline-start"}),e[2]=o):o=e[2];let i;e[3]!==t?(i=a.jsx("span",{className:"font-mono text-xs",children:t}),e[3]=t,e[4]=i):i=e[4];let l;e[5]!==r||e[6]!==i?(l=a.jsxs(Zt,{render:r,children:[o,i]}),e[5]=r,e[6]=i,e[7]=l):l=e[7];const c=t!==1?"es":"";let u;e[8]!==t||e[9]!==c?(u=a.jsxs(Yt,{children:[t," branch",c," from this turn"]}),e[8]=t,e[9]=c,e[10]=u):u=e[10];let d;return e[11]!==l||e[12]!==u?(d=a.jsxs(Gt,{children:[l,u]}),e[11]=l,e[12]=u,e[13]=d):d=e[13],d}function Nm(n){const e=V.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(u8,{"data-slot":"context-menu",...t}),e[2]=t,e[3]=s):s=e[3],s}function Cm(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("select-none",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(c8,{"data-slot":"context-menu-trigger",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function _m(n){const e=V.c(18);let t,s,r,o,i,l;e[0]!==n?({className:t,align:r,alignOffset:o,side:i,sideOffset:l,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i,e[6]=l):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5],l=e[6]);const c=r===void 0?"start":r,u=o===void 0?4:o,d=i===void 0?"right":i,f=l===void 0?0:l;let m;e[7]!==t?(m=G("z-50 max-h-(--available-height) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 ease-out outline-none data-[side=bottom]:slide-in-from-top-1 data-[side=inline-end]:slide-in-from-left-1 data-[side=inline-start]:slide-in-from-right-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",t),e[7]=t,e[8]=m):m=e[8];let p;e[9]!==s||e[10]!==m?(p=a.jsx(v4,{"data-slot":"context-menu-content",className:m,...s}),e[9]=s,e[10]=m,e[11]=p):p=e[11];let h;return e[12]!==c||e[13]!==u||e[14]!==d||e[15]!==f||e[16]!==p?(h=a.jsx(S4,{children:a.jsx(k4,{className:"isolate z-50 outline-none",align:c,alignOffset:u,side:d,sideOffset:f,children:p})}),e[12]=c,e[13]=u,e[14]=d,e[15]=f,e[16]=p,e[17]=h):h=e[17],h}function fi(n){const e=V.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(y4,{"data-slot":"context-menu-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function D2e(n){const e=V.c(10);let t,s,r;e[0]!==n?({className:t,inset:s,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);let o;e[4]!==t?(o=G("px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",t),e[4]=t,e[5]=o):o=e[5];let i;return e[6]!==s||e[7]!==r||e[8]!==o?(i=a.jsx(j4,{"data-slot":"context-menu-label","data-inset":s,className:o,...r}),e[6]=s,e[7]=r,e[8]=o,e[9]=i):i=e[9],i}function Rn(n){const e=V.c(12);let t,s,r,o;e[0]!==n?({className:t,inset:s,variant:o,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);const i=o===void 0?"default":o;let l;e[5]!==t?(l=G("group/context-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none transition-colors duration-75 focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive",t),e[5]=t,e[6]=l):l=e[6];let c;return e[7]!==s||e[8]!==r||e[9]!==l||e[10]!==i?(c=a.jsx(w4,{"data-slot":"context-menu-item","data-inset":s,"data-variant":i,className:l,...r}),e[7]=s,e[8]=r,e[9]=l,e[10]=i,e[11]=c):c=e[11],c}function ba(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("-mx-1 my-1 h-px bg-border",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(sx,{"data-slot":"context-menu-separator",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function ufe(n){const e=V.c(22),{children:t,turnIndex:s,branches:r,onRestoreToHere:o,onOpenBranches:i,onBranchFromHere:l}=n;let c;e[0]!==t?(c=a.jsx(Cm,{className:"select-text",children:t}),e[0]=t,e[1]=c):c=e[1];let u;e[2]!==o||e[3]!==s?(u=()=>o(s),e[2]=o,e[3]=s,e[4]=u):u=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx(mx,{"data-icon":"inline-start"}),e[5]=d):d=e[5];let f;e[6]!==u?(f=a.jsx(fi,{children:a.jsxs(Rn,{onClick:u,children:[d,"Restore to this point"]})}),e[6]=u,e[7]=f):f=e[7];let m;e[8]!==r.length||e[9]!==i||e[10]!==s?(m=r.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(ba,{}),a.jsx(fi,{children:a.jsxs(Rn,{onClick:()=>i(s),children:[a.jsx(gx,{"data-icon":"inline-start"}),"View branches (",r.length,")"]})})]}),e[8]=r.length,e[9]=i,e[10]=s,e[11]=m):m=e[11];let p;e[12]!==l||e[13]!==s?(p=l&&a.jsxs(a.Fragment,{children:[a.jsx(ba,{}),a.jsx(fi,{children:a.jsxs(Rn,{onClick:()=>l(s),children:[a.jsx(Es,{"data-icon":"inline-start"}),"Duplicate from here"]})})]}),e[12]=l,e[13]=s,e[14]=p):p=e[14];let h;e[15]!==f||e[16]!==m||e[17]!==p?(h=a.jsxs(_m,{className:"min-w-44",children:[f,m,p]}),e[15]=f,e[16]=m,e[17]=p,e[18]=h):h=e[18];let g;return e[19]!==c||e[20]!==h?(g=a.jsxs(Nm,{children:[c,h]}),e[19]=c,e[20]=h,e[21]=g):g=e[21],g}function dfe(n){const e=V.c(5),{status:t}=n;switch(t){case"thinking":{let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(m8,{className:"size-5 text-warning"}),e[0]=s):s=e[0],s}case"tool_use":{let s;return e[1]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(Ca,{className:"size-5 text-info"}),e[1]=s):s=e[1],s}case"processing":{let s;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(f8,{className:"size-5 text-warning"}),e[2]=s):s=e[2],s}case"compacting":{let s;return e[3]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(Nf,{className:"size-5 text-warning"}),e[3]=s):s=e[3],s}case"completed":{let s;return e[4]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(Pr,{className:"size-5 text-success"}),e[4]=s):s=e[4],s}default:return null}}const W3=2e3,uI=600;function dI(n){const e=V.c(23),{status:t,label:s,fading:r,startTimestamp:o}=n,i=r===void 0?!1:r,l=t.status==="completed",c=i?"opacity-0":"opacity-100";let u;e[0]!==c?(u=G("flex items-center gap-2.5 min-w-0 transition-opacity",c),e[0]=c,e[1]=u):u=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d={transitionDuration:`${uI}ms`},e[2]=d):d=e[2];let f;e[3]!==t.status?(f=a.jsx(dfe,{status:t.status}),e[3]=t.status,e[4]=f):f=e[4];const m=!l&&"text-muted-foreground",p=l&&t.terminalReason&&"text-warning",h=l&&!t.terminalReason&&"text-success";let g;e[5]!==m||e[6]!==p||e[7]!==h?(g=G("text-xs font-medium shrink-0",m,p,h),e[5]=m,e[6]=p,e[7]=h,e[8]=g):g=e[8];let x;e[9]!==s||e[10]!==g?(x=a.jsx("span",{className:g,children:s}),e[9]=s,e[10]=g,e[11]=x):x=e[11];let b;e[12]!==l||e[13]!==o?(b=!l&&o&&a.jsx(tu,{startTimestamp:o}),e[12]=l,e[13]=o,e[14]=b):b=e[14];let w;e[15]!==t.pendingQueue?(w=(t.pendingQueue??0)>0&&a.jsxs("span",{className:"ml-1 shrink-0 text-xs text-muted-foreground",children:["+",t.pendingQueue," queued"]}),e[15]=t.pendingQueue,e[16]=w):w=e[16];let v;return e[17]!==x||e[18]!==b||e[19]!==w||e[20]!==u||e[21]!==f?(v=a.jsxs("div",{className:u,style:d,children:[f,x,b,w]}),e[17]=x,e[18]=b,e[19]=w,e[20]=u,e[21]=f,e[22]=v):v=e[22],v}function ffe(n){var E;const e=V.c(36),{status:t,startTimestamp:s}=n,[r,o]=y.useState(!0);let i;e[0]!==t.backgroundAgents?(i=t.backgroundAgents??[],e[0]=t.backgroundAgents,e[1]=i):i=e[1];const l=i;let c;e[2]!==l?(c=l.filter(hfe),e[2]=l,e[3]=c):c=e[3];const u=c.length;let d;e[4]!==l||e[5]!==s?(d=((E=l.find(pfe))==null?void 0:E.startedAt)??s,e[4]=l,e[5]=s,e[6]=d):d=e[6];const f=d;let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=a.jsx(mi,{className:"size-4 shrink-0 text-info"}),e[7]=m):m=e[7];const p=u<l.length?`Waiting on ${u} of ${l.length} agents`:`Waiting on ${u} agent${u===1?"":"s"}`;let h;e[8]!==p?(h=a.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:p}),e[8]=p,e[9]=h):h=e[9];let g;e[10]!==t.pendingQueue?(g=(t.pendingQueue??0)>0&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:["+",t.pendingQueue," queued"]}),e[10]=t.pendingQueue,e[11]=g):g=e[11];let x;e[12]!==f?(x=f&&a.jsx(tu,{startTimestamp:f}),e[12]=f,e[13]=x):x=e[13];const b=!r&&"-rotate-90";let w;e[14]!==b?(w=G("size-3.5 text-muted-foreground transition-transform",b),e[14]=b,e[15]=w):w=e[15];let v;e[16]!==w?(v=a.jsx(_t,{className:w}),e[16]=w,e[17]=v):v=e[17];let j;e[18]!==v||e[19]!==g||e[20]!==x?(j=a.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2",children:[g,x,v]}),e[18]=v,e[19]=g,e[20]=x,e[21]=j):j=e[21];let k;e[22]!==j||e[23]!==h?(k=a.jsxs(rs,{className:"flex w-full min-w-0 items-center gap-2.5 px-3 py-2 text-left",children:[m,h,j]}),e[22]=j,e[23]=h,e[24]=k):k=e[24];let _;e[25]!==l?(_=l.length>1&&a.jsx(gfe,{agents:l}),e[25]=l,e[26]=_):_=e[26];let N;e[27]!==l?(N=l.map(mfe),e[27]=l,e[28]=N):N=e[28];let S;e[29]!==N?(S=a.jsx(yn,{children:a.jsx("ul",{className:"flex flex-col border-t border-border/40 py-1",children:N})}),e[29]=N,e[30]=S):S=e[30];let C;return e[31]!==r||e[32]!==k||e[33]!==_||e[34]!==S?(C=a.jsxs(vn,{open:r,onOpenChange:o,className:"mx-4 my-3 rounded-lg border border-border/60 bg-muted/20","data-testid":"awaiting-agents",children:[k,_,S]}),e[31]=r,e[32]=k,e[33]=_,e[34]=S,e[35]=C):C=e[35],C}function mfe(n,e){return a.jsx(bfe,{agent:n},n.toolUseId??e)}function pfe(n){return n.startedAt}function hfe(n){return!n.done}function gfe(n){const e=V.c(4),{agents:t}=n;let s;e[0]!==t?(s=t.map(xfe),e[0]=t,e[1]=s):s=e[1];let r;return e[2]!==s?(r=a.jsx("div",{className:"px-3 pb-2.5","aria-hidden":!0,children:a.jsx("div",{className:"flex h-1 gap-0.5",children:s})}),e[2]=s,e[3]=r):r=e[3],r}function xfe(n,e){return a.jsx("span",{className:G("flex-1 rounded-full",n.done?"bg-success":"bg-info/25")},e)}function bfe(n){const e=V.c(21),{agent:t}=n,s=EA(t.done?void 0:t.toolUseId),r=t.done||void 0;let o;e[0]!==t.done?(o=t.done?a.jsx(Pr,{className:"mt-px size-3.5 shrink-0 text-success"}):a.jsx(d8,{className:"mt-px size-3.5 shrink-0 text-info"}),e[0]=t.done,e[1]=o):o=e[1];const i=t.done?"text-muted-foreground":"text-foreground";let l;e[2]!==i?(l=G("truncate text-xs",i),e[2]=i,e[3]=l):l=e[3];const c=t.description||void 0,u=t.description||"Agent";let d;e[4]!==l||e[5]!==c||e[6]!==u?(d=a.jsx("span",{className:l,title:c,children:u}),e[4]=l,e[5]=c,e[6]=u,e[7]=d):d=e[7];let f;e[8]!==s?(f=s&&a.jsx("span",{className:"truncate text-xs text-muted-foreground",title:s,children:s}),e[8]=s,e[9]=f):f=e[9];let m;e[10]!==d||e[11]!==f?(m=a.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[d,f]}),e[10]=d,e[11]=f,e[12]=m):m=e[12];let p;e[13]!==t.done||e[14]!==t.startedAt?(p=t.done?a.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:"Done"}):t.startedAt&&a.jsx(tu,{startTimestamp:t.startedAt,className:"shrink-0"}),e[13]=t.done,e[14]=t.startedAt,e[15]=p):p=e[15];let h;return e[16]!==r||e[17]!==p||e[18]!==o||e[19]!==m?(h=a.jsxs("li",{className:"flex min-w-0 items-start gap-2.5 px-3 py-1.5","data-agent-done":r,children:[o,m,p]}),e[16]=r,e[17]=p,e[18]=o,e[19]=m,e[20]=h):h=e[20],h}function vfe(n){const e=V.c(28),{status:t,durationLabel:s}=n,[r,o]=y.useState("visible");let i,l;if(e[0]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{const h=setTimeout(()=>o("fading"),W3),g=setTimeout(()=>o("ready"),W3+uI);return()=>{clearTimeout(h),clearTimeout(g)}},l=[],e[0]=i,e[1]=l):(i=e[0],l=e[1]),y.useEffect(i,l),r==="ready"){let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx(Pr,{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?Pb(t.terminalReason):"Waiting for your input",e[5]=t.terminalReason,e[6]=b):b=e[6];let w;e[7]!==x||e[8]!==b?(w=a.jsx("span",{className:x,children:b}),e[7]=x,e[8]=b,e[9]=w):w=e[9];let v;e[10]!==s?(v=s&&a.jsx("span",{className:"font-mono text-xs tabular-nums text-muted-foreground",children:s}),e[10]=s,e[11]=v):v=e[11];let j;return e[12]!==w||e[13]!==v?(j=a.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4","data-agent-ready":!0,children:[h,w,v]}),e[12]=w,e[13]=v,e[14]=j):j=e[14],j}let c;e[15]!==t.status||e[16]!==t.terminalReason||e[17]!==t.toolName?(c=Jc(t.status,t.toolName,t.terminalReason)??"Done",e[15]=t.status,e[16]=t.terminalReason,e[17]=t.toolName,e[18]=c):c=e[18];const u=c,d=r==="fading";let f;e[19]!==u||e[20]!==t||e[21]!==d?(f=a.jsx(dI,{status:t,label:u,fading:d}),e[19]=u,e[20]=t,e[21]=d,e[22]=f):f=e[22];let m;e[23]!==s?(m=s&&a.jsxs("span",{className:"font-mono text-xs tabular-nums text-muted-foreground",children:["in ",s]}),e[23]=s,e[24]=m):m=e[24];let p;return e[25]!==f||e[26]!==m?(p=a.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4",children:[f,m]}),e[25]=f,e[26]=m,e[27]=p):p=e[27],p}const yfe=y.memo(function(){const e=V.c(27),{session:t,isLive:s,sseState:r,isCompacting:o,pendingInteraction:i}=kt(),[l,c]=y.useState(!1),[u,d]=y.useState(!1),f=t==null?void 0:t.sessionId,[m,p]=y.useState(f);f!==m&&(p(f),c(!1),d(!1));let h;e:{if(!t||r!=="connected"){h=null;break e}if(o){let R;e[0]===Symbol.for("react.memo_cache_sentinel")?(R={status:"compacting"},e[0]=R):R=e[0],h=R;break e}const $=t.rawMessages;let A;e[1]!==$?(A=Z6($),e[1]=$,e[2]=A):A=e[2],h=A}const g=h;let x,b;e[3]!==g||e[4]!==s||e[5]!==u?(x=()=>{if(!(!g||g.status==="compacting"||g.status==="idle")){if(!s){g.status==="completed"&&!u&&c(!0);return}if(g.status==="completed"){d(!0);return}c(!1),d(!1)}},b=[g,s,u],e[3]=g,e[4]=s,e[5]=u,e[6]=x,e[7]=b):(x=e[6],b=e[7]),y.useEffect(x,b);let w;e:{if(!g){w=null;break e}if(g.status==="compacting"){w=g;break e}if(g.status==="completed"){if(l){w=null;break e}if(!s&&!u){w=null;break e}w=g;break e}if(!s||g.status==="idle"){w=null;break e}w=g}const v=w,j=(v==null?void 0:v.status)==="completed",k=(t==null?void 0:t.turns[t.turns.length-1])??null;let _;e:{if(!j||!k){_=null;break e}let $;if(e[8]!==k){const A=$x(k);$=A!==null?Js(A):null,e[8]=k,e[9]=$}else $=e[9];_=$}const N=_;if(i&&r==="connected"){let $;e[10]===Symbol.for("react.memo_cache_sentinel")?($=a.jsx(px,{className:"size-5 shrink-0 text-info"}),e[10]=$):$=e[10];const A=i.type==="plan"?"Waiting for plan approval":"Waiting for your answer";let R;return e[11]!==A?(R=a.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4",children:[$,a.jsx("span",{className:"text-xs font-medium text-info",children:A})]}),e[11]=A,e[12]=R):R=e[12],R}if(!v)return null;if(j){let $;return e[13]!==v||e[14]!==N?($=a.jsx(vfe,{status:v,durationLabel:N}),e[13]=v,e[14]=N,e[15]=$):$=e[15],$}if(v.status==="awaiting_agents"){const $=k==null?void 0:k.timestamp;let A;return e[16]!==v||e[17]!==$?(A=a.jsx(ffe,{status:v,startTimestamp:$}),e[16]=v,e[17]=$,e[18]=A):A=e[18],A}let S;e[19]!==v.status||e[20]!==v.terminalReason||e[21]!==v.toolName?(S=Jc(v.status,v.toolName,v.terminalReason),e[19]=v.status,e[20]=v.terminalReason,e[21]=v.toolName,e[22]=S):S=e[22];const C=S;if(!C)return null;const E=k==null?void 0:k.timestamp;let T;return e[23]!==v||e[24]!==C||e[25]!==E?(T=a.jsx("div",{className:"flex items-center gap-2.5 py-3 px-4",children:a.jsx(dI,{status:v,label:C,startTimestamp:E})}),e[23]=v,e[24]=C,e[25]=E,e[26]=T):T=e[26],T});function tu(n){const e=V.c(3),{startTimestamp:t,className:s}=n;let r;return e[0]!==s||e[1]!==t?(r=a.jsx(wfe,{startTimestamp:t,className:s},t),e[0]=s,e[1]=t,e[2]=r):r=e[2],r}function wfe(n){const e=V.c(12),{startTimestamp:t,className:s}=n;let r;e[0]!==t?(r=new Date(t).getTime(),e[0]=t,e[1]=r):r=e[1];const o=r,i=y.useRef(null);let l,c;e[2]!==o?(l=()=>{const h=setInterval(()=>{const g=i.current;g&&(g.textContent=Js(Math.max(0,Date.now()-o)))},1e3);return()=>clearInterval(h)},c=[o],e[2]=o,e[3]=l,e[4]=c):(l=e[3],c=e[4]),y.useEffect(l,c);let u;e[5]!==s?(u=G("font-mono text-xs tabular-nums text-muted-foreground",s),e[5]=s,e[6]=u):u=e[6];const d=Math.max(0,Date.now()-o);let f;e[7]!==d?(f=Js(d),e[7]=d,e[8]=f):f=e[8];let m;return e[9]!==u||e[10]!==f?(m=a.jsx("span",{ref:i,className:u,children:f}),e[9]=u,e[10]=f,e[11]=m):m=e[11],m}function Sfe(n,e){var s;if(!e)return!0;const t=e.toLowerCase();if(n.userMessage&&(typeof n.userMessage=="string"?n.userMessage:JSON.stringify(n.userMessage)).toLowerCase().includes(t))return!0;for(const r of n.assistantText)if(r.toLowerCase().includes(t))return!0;for(const r of n.contentBlocks)if(r.kind==="queued_prompt"&&r.content.toLowerCase().includes(t)||r.kind==="agent_message"&&(r.sender.toLowerCase().includes(t)||r.body.toLowerCase().includes(t)))return!0;for(const r of n.thinking)if(r.thinking.toLowerCase().includes(t))return!0;for(const r of n.toolCalls)if(r.name.toLowerCase().includes(t)||JSON.stringify(r.input).toLowerCase().includes(t)||(s=r.result)!=null&&s.toLowerCase().includes(t))return!0;return!1}const kfe=6e5;function jfe(n,e){const t=n[e].timestamp,s=e>0?n[e-1].timestamp:void 0;if(!t||!s)return 0;const r=Date.parse(t)-Date.parse(s);return!Number.isFinite(r)||r<=0?0:Math.min(r,kfe)}function q3(n,e){const t=[],s=[];let r=0,o=0,i=e;for(;i<n.length;){const l=n[i];if(l.kind==="thinking")t.push({kind:"thinking",blocks:l.blocks}),r+=l.blocks.length,o+=jfe(n,i),i++;else if(l.kind==="tool_calls")t.push({kind:"tool_calls",toolCalls:l.toolCalls}),s.push(...l.toolCalls),i++;else break}return{items:t,toolCalls:s,thinkingCount:r,thoughtForMs:o,nextIndex:i}}const fI=y.createContext(null);function bd(n){const e=V.c(3),{value:t,children:s}=n;let r;return e[0]!==s||e[1]!==t?(r=a.jsx(fI.Provider,{value:t,children:s}),e[0]=s,e[1]=t,e[2]=r):r=e[2],r}function Sn(){const n=y.useContext(fI);if(!n)throw new Error("useAppContext must be used within an AppProvider");return n}const $1=new Map,Nfe=300*1e3;function V3(n){const e=$1.get(n);return e?Date.now()>e.expiresAt?($1.delete(n),null):e.data:null}function Cfe(n,e){$1.set(n,{data:e,expiresAt:Date.now()+Nfe})}function _fe(n){const e=V.c(5);let t;e[0]!==n?(t=()=>n?V3(sn(n))??new Map:new Map,e[0]=n,e[1]=t):t=e[1];const[s,r]=y.useState(t),o=y.useRef("");let i,l;return e[2]!==n?(i=()=>{if(!n||lm(window.location.pathname))return;const c=sn(n),u=V3(c);if(u){r(u);return}o.current=n;const d=new AbortController;return Ce(`/api/slash-suggestions?cwd=${encodeURIComponent(n)}`,{signal:d.signal}).then(async f=>{if(d.signal.aborted||o.current!==n||!f.ok)return;const m=await f.json();if(d.signal.aborted||o.current!==n)return;const p=new Map;for(const h of m.suggestions??[])h.type==="skill"&&p.set(h.name,{source:h.source,description:h.description,filePath:h.filePath});Cfe(c,p),r(p)}).catch(Efe),()=>d.abort()},l=[n],e[2]=n,e[3]=i,e[4]=l):(i=e[3],l=e[4]),y.useEffect(i,l),s}function Efe(){}const Tfe=new Set(["queued_prompt","agent_message","plan_mode","recap","task_notification","local_command"]),Afe=new Set(["thinking","tool_calls","sub_agent","background_agent","hook_event"]),Ife=new Set(["AskUserQuestion","ExitPlanMode"]),Pfe=new Set(["text","thinking","tool_calls"]);function $fe(n){return n.kind==="tool_calls"&&n.toolCalls.some(e=>Ife.has(e.name)&&e.result==null)}function Rfe(n,e){for(let t=n.length-1;t>=0;t--){if($fe(n[t]))return t;if(Pfe.has(n[t].kind))break}return e?n.findIndex(t=>t.kind==="tool_calls"&&t.toolCalls.some(s=>s.id===e&&s.asyncQuestion)):-1}const Wu={foldedIndices:[],foldAnchorIndex:-1,foldable:!1,hiddenToolCalls:0};function Ofe(n,e="settled",t){if(n.length===0||!n.some(l=>Afe.has(l.kind)))return Wu;let s=-1;if(e==="settled"){for(let l=n.length-1;l>=0;l--)if(n[l].kind==="text"){s=l;break}if(s===-1)return Wu}const r=Rfe(n,t),o=[];let i=0;for(let l=0;l<n.length;l++){if(l===s||l===r)continue;const c=n[l];Tfe.has(c.kind)||(o.push(l),c.kind==="tool_calls"&&(i+=c.toolCalls.length))}return o.length===0?Wu:{foldedIndices:o,foldAnchorIndex:o[0],foldable:!0,hiddenToolCalls:i}}function Lfe(n,e){return n!==null&&n>0?`Worked for ${Js(n)}`:e>0?`Worked through ${e} step${e===1?"":"s"}`:"Show work"}const mI="border border-border bg-prompt-surface",H3="border-l border-border/40",K3="border-l border-border";function pI(n){const e=V.c(21),{turn:t,index:s,branchCount:r}=n,o=r===void 0?0:r,{state:i,isMobile:l}=Sn(),{activeTurnIndex:c,activeToolCallId:u,expandAll:d,expandToolPayloads:f}=i,{session:m,isLive:p,isSubAgentView:h,undoRedo:g,actions:x,pendingInteraction:b}=kt(),w=p&&m!==null,v=w&&s===((m==null?void 0:m.turns.length)??0)-1;let j=!v;if(v&&m){let T;if(e[0]!==m.rawMessages){const{status:$}=Z6(m.rawMessages);T=$f.has($),e[0]=m.rawMessages,e[1]=T}else T=e[1];j=!T}const k=(m==null?void 0:m.cwd)??"",_=_fe(k),N=(b==null?void 0:b.type)==="question"?b.toolUseId:void 0,S=c===s,C=!g.enabled||h?void 0:g.requestUndo;let E;return e[2]!==x.handleEditCommand||e[3]!==x.handleExpandCommand||e[4]!==x.handleOpenBranches||e[5]!==u||e[6]!==o||e[7]!==k||e[8]!==d||e[9]!==f||e[10]!==s||e[11]!==v||e[12]!==l||e[13]!==w||e[14]!==j||e[15]!==N||e[16]!==_||e[17]!==S||e[18]!==C||e[19]!==t?(E=a.jsx(Dfe,{turn:t,openQuestionId:N,index:s,branchCount:o,isActive:S,activeToolCallId:u,expandAll:d,expandToolPayloads:f,isAgentActive:v,isSessionLive:w,isTurnDone:j,isMobile:l,cwd:k,skillMetadata:_,onRestoreToHere:C,onOpenBranches:x.handleOpenBranches,onEditCommand:x.handleEditCommand,onExpandCommand:x.handleExpandCommand}),e[2]=x.handleEditCommand,e[3]=x.handleExpandCommand,e[4]=x.handleOpenBranches,e[5]=u,e[6]=o,e[7]=k,e[8]=d,e[9]=f,e[10]=s,e[11]=v,e[12]=l,e[13]=w,e[14]=j,e[15]=N,e[16]=_,e[17]=S,e[18]=C,e[19]=t,e[20]=E):E=e[20],E}function Mfe(n){const e=V.c(12),{index:t,children:s}=n,{session:r,isSubAgentView:o,undoRedo:i,actions:l}=kt(),{requestUndo:c,branchesAtTurn:u}=i,{handleOpenBranches:d,handleBranchFromHere:f}=l,m=t>=((r==null?void 0:r.turns.length)??0);if(!i.enabled||o||m||!c||!d){let g;return e[0]!==s?(g=a.jsx(a.Fragment,{children:s}),e[0]=s,e[1]=g):g=e[1],g}let p;e[2]!==u||e[3]!==t?(p=u(t),e[2]=u,e[3]=t,e[4]=p):p=e[4];let h;return e[5]!==s||e[6]!==f||e[7]!==d||e[8]!==t||e[9]!==c||e[10]!==p?(h=a.jsx(ufe,{turnIndex:t,branches:p,onRestoreToHere:c,onOpenBranches:d,onBranchFromHere:f,children:s}),e[5]=s,e[6]=f,e[7]=d,e[8]=t,e[9]=c,e[10]=p,e[11]=h):h=e[11],h}function zfe(n){const e=V.c(5),{turn:t,isTurnDone:s,hiddenToolCalls:r}=n;if(s){let i;return e[0]!==r||e[1]!==t?(i=Lfe($x(t),r),e[0]=r,e[1]=t,e[2]=i):i=e[2],i}if(!t.timestamp)return"Working";let o;return e[3]!==t.timestamp?(o=a.jsxs("span",{className:"inline-flex items-baseline gap-1",children:["Working for",a.jsx(tu,{startTimestamp:t.timestamp,className:"text-xs text-inherit"})]}),e[3]=t.timestamp,e[4]=o):o=e[4],o}const Dfe=y.memo(function(e){const t=V.c(83),{turn:s,index:r,branchCount:o,isActive:i,activeToolCallId:l,expandAll:c,expandToolPayloads:u,isAgentActive:d,isSessionLive:f,isTurnDone:m,isMobile:p,cwd:h,skillMetadata:g,onRestoreToHere:x,onOpenBranches:b,onEditCommand:w,onExpandCommand:v,openQuestionId:j}=e;let k;t[0]!==h||t[1]!==s.subAgentActivity||t[2]!==s.toolCalls?(k=mf(s.toolCalls,h)||s.subAgentActivity.some(K=>mf(K.toolCalls,h)),t[0]=h,t[1]=s.subAgentActivity,t[2]=s.toolCalls,t[3]=k):k=t[3];const _=k,N=m?"settled":"working";let S;t[4]!==N||t[5]!==j||t[6]!==s.contentBlocks?(S=Ofe(s.contentBlocks,N,j),t[4]=N,t[5]=j,t[6]=s.contentBlocks,t[7]=S):S=t[7];const C=S;let E;t[8]!==m?(E=()=>m?void 0:!0,t[8]=m,t[9]=E):E=t[9];const[T,$]=y.useState(E),A=T??(c||!m);let R;e:{if(!C.foldable){let se;t[10]===Symbol.for("react.memo_cache_sentinel")?(se=[],t[10]=se):se=t[10];let J;t[11]===Symbol.for("react.memo_cache_sentinel")?(J=[],t[11]=J):J=t[11];let ne;t[12]===Symbol.for("react.memo_cache_sentinel")?(ne={leadingBlocks:se,trailingBlocks:J},t[12]=ne):ne=t[12],R=ne;break e}const K=C.foldAnchorIndex;let Z;t[13]!==C.foldedIndices?(Z=new Set(C.foldedIndices),t[13]=C.foldedIndices,t[14]=Z):Z=t[14];const Y=Z;let X;t[15]!==K||t[16]!==s.contentBlocks?(X=s.contentBlocks.slice(0,K),t[15]=K,t[16]=s.contentBlocks,t[17]=X):X=t[17];let ee;if(t[18]!==K||t[19]!==Y||t[20]!==s.contentBlocks||t[21]!==A){let se;t[23]!==K||t[24]!==Y||t[25]!==A?(se=(J,ne)=>A||!Y.has(K+ne),t[23]=K,t[24]=Y,t[25]=A,t[26]=se):se=t[26],ee=s.contentBlocks.slice(K).filter(se),t[18]=K,t[19]=Y,t[20]=s.contentBlocks,t[21]=A,t[22]=ee}else ee=t[22];let te;t[27]!==X||t[28]!==ee?(te={leadingBlocks:X,trailingBlocks:ee},t[27]=X,t[28]=ee,t[29]=te):te=t[29],R=te}const{leadingBlocks:P,trailingBlocks:z}=R;let L;t[30]!==l||t[31]!==c||t[32]!==u||t[33]!==d||t[34]!==p||t[35]!==f||t[36]!==g||t[37]!==s.contentBlocks||t[38]!==s.effort||t[39]!==s.id||t[40]!==s.model?(L={turnId:s.id,originalBlocks:s.contentBlocks,model:s.model,effort:s.effort,expandAll:c,expandToolPayloads:u,activeToolCallId:l,isAgentActive:d,isSessionLive:f,isMobile:p,skillMetadata:g},t[30]=l,t[31]=c,t[32]=u,t[33]=d,t[34]=p,t[35]=f,t[36]=g,t[37]=s.contentBlocks,t[38]=s.effort,t[39]=s.id,t[40]=s.model,t[41]=L):L=t[41];const I=L,M=p?"px-0 py-5":"px-4 py-5",F=i&&"rounded-lg ring-1 ring-ring/40";let U;t[42]!==M||t[43]!==F?(U=G("group relative",M,F),t[42]=M,t[43]=F,t[44]=U):U=t[44];let O;t[45]!==o||t[46]!==r||t[47]!==p||t[48]!==m||t[49]!==b||t[50]!==x||t[51]!==s?(O=a.jsx(Ffe,{index:r,turn:s,branchCount:o,isTurnDone:m,isMobile:p,onRestoreToHere:x,onOpenBranches:b}),t[45]=o,t[46]=r,t[47]=p,t[48]=m,t[49]=b,t[50]=x,t[51]=s,t[52]=O):O=t[52];let D;t[53]!==r||t[54]!==w||t[55]!==v||t[56]!==s.timestamp||t[57]!==s.userMessage?(D=s.userMessage&&a.jsx(Mfe,{index:r,children:a.jsx("div",{"data-turn-prompt":!0,className:G("rounded-lg p-3",mI),children:a.jsx(Lb,{content:s.userMessage,timestamp:s.timestamp,onEditCommand:w,onExpandCommand:v})})}),t[53]=r,t[54]=w,t[55]=v,t[56]=s.timestamp,t[57]=s.userMessage,t[58]=D):D=t[58];let B;t[59]!==I||t[60]!==C.foldable||t[61]!==C.hiddenToolCalls||t[62]!==m||t[63]!==P||t[64]!==z||t[65]!==s||t[66]!==A?(B=C.foldable?a.jsxs(a.Fragment,{children:[P.length>0&&a.jsx(Zh,{blocks:P,...I}),a.jsx(gde,{label:a.jsx(zfe,{turn:s,isTurnDone:m,hiddenToolCalls:C.hiddenToolCalls}),expanded:A,onToggle:()=>$(!A)}),z.length>0&&a.jsx(Zh,{blocks:z,...I})]}):a.jsx(Zh,{blocks:s.contentBlocks,...I}),t[59]=I,t[60]=C.foldable,t[61]=C.hiddenToolCalls,t[62]=m,t[63]=P,t[64]=z,t[65]=s,t[66]=A,t[67]=B):B=t[67];let q;t[68]!==h||t[69]!==_||t[70]!==r||t[71]!==m||t[72]!==s?(q=m&&_&&a.jsx(afe,{turn:s,turnIndex:r,cwd:h}),t[68]=h,t[69]=_,t[70]=r,t[71]=m,t[72]=s,t[73]=q):q=t[73];let W;t[74]!==D||t[75]!==B||t[76]!==q?(W=a.jsxs("div",{className:"flex flex-col gap-3",children:[D,B,q]}),t[74]=D,t[75]=B,t[76]=q,t[77]=W):W=t[77];let H;return t[78]!==r||t[79]!==W||t[80]!==U||t[81]!==O?(H=a.jsxs("div",{"data-turn-index":r,className:U,children:[O,W]}),t[78]=r,t[79]=W,t[80]=U,t[81]=O,t[82]=H):H=t[82],H});function Ffe(n){const e=V.c(26),{index:t,turn:s,branchCount:r,isTurnDone:o,isMobile:i,onRestoreToHere:l,onOpenBranches:c}=n,u=!o&&!!s.timestamp;let d;e[0]!==o||e[1]!==s?(d=o?$x(s):null,e[0]=o,e[1]=s,e[2]=d):d=e[2];const f=d,m=i?"mb-2 gap-1.5":"mb-4 gap-2";let p;e[3]!==m?(p=G("flex items-center",m),e[3]=m,e[4]=p):p=e[4];const h=t+1;let g;e[5]!==h?(g=a.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:h}),e[5]=h,e[6]=g):g=e[6];let x;e[7]!==f||e[8]!==u||e[9]!==s.timestamp?(x=a.jsx(Ufe,{durationMs:f,showLiveTimer:u,timestamp:s.timestamp}),e[7]=f,e[8]=u,e[9]=s.timestamp,e[10]=x):x=e[10];let b;e[11]!==t||e[12]!==i||e[13]!==l?(b=l&&a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",onClick:()=>l(t),className:G("ml-auto text-muted-foreground transition-opacity hover:text-foreground",i?"opacity-70":"opacity-0 group-hover:opacity-100"),title:"Undo this turn and all after it",children:[a.jsx(mx,{"data-icon":"inline-start"}),a.jsx("span",{className:"hidden sm:inline",children:"Restore"})]}),e[11]=t,e[12]=i,e[13]=l,e[14]=b):b=e[14];let w;e[15]!==r||e[16]!==t||e[17]!==c||e[18]!==l?(w=r>0&&c&&a.jsx("div",{className:G(!l&&"ml-auto"),children:a.jsx(cfe,{branchCount:r,onClick:()=>c(t)})}),e[15]=r,e[16]=t,e[17]=c,e[18]=l,e[19]=w):w=e[19];let v;return e[20]!==p||e[21]!==g||e[22]!==x||e[23]!==b||e[24]!==w?(v=a.jsxs("div",{className:p,children:[g,x,b,w]}),e[20]=p,e[21]=g,e[22]=x,e[23]=b,e[24]=w,e[25]=v):v=e[25],v}function Ufe(n){const e=V.c(8),{durationMs:t,showLiveTimer:s,timestamp:r}=n;if(t!==null){let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(Io,{className:"size-3","data-icon":"inline-start"}),e[0]=o):o=e[0];let i;e[1]!==t?(i=Js(t),e[1]=t,e[2]=i):i=e[2];let l;return e[3]!==i?(l=a.jsxs("span",{className:"flex items-center gap-1 font-mono text-xs tabular-nums text-muted-foreground",children:[o,i]}),e[3]=i,e[4]=l):l=e[4],l}if(s){let o;e[5]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(Io,{className:"size-3","data-icon":"inline-start"}),e[5]=o):o=e[5];let i;return e[6]!==r?(i=a.jsxs("span",{className:"flex items-center gap-1 font-mono text-xs tabular-nums text-info",children:[o,a.jsx(tu,{startTimestamp:r,className:"tabular-nums"})]}),e[6]=r,e[7]=i):i=e[7],i}return null}function Bfe(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 Zh(n){const e=V.c(13),{blocks:t,turnId:s,originalBlocks:r,model:o,effort:i,expandAll:l,expandToolPayloads:c,activeToolCallId:u,isAgentActive:d,isSessionLive:f,isMobile:m,skillMetadata:p}=n;let h;if(e[0]!==u||e[1]!==t||e[2]!==i||e[3]!==l||e[4]!==c||e[5]!==d||e[6]!==m||e[7]!==f||e[8]!==o||e[9]!==r||e[10]!==p||e[11]!==s){const g=[],x=m?"ml-0 pl-2":"ml-1 pl-3",b=new Map,w=(j,k)=>{const _=Bfe(j)??`at-${k}`,N=b.get(_)??0;return b.set(_,N+1),N===0?_:`${_}#${N}`};let v=0;for(;v<t.length;){const j=t[v];if(j.kind==="thinking"||j.kind==="tool_calls"){const{items:k,toolCalls:_,thinkingCount:N,thoughtForMs:S,nextIndex:C}=q3(t,v),E=k.length===1&&k[0].kind==="tool_calls";g.push(a.jsx("div",{className:G(H3,x),children:a.jsx(P3,{toolCalls:_,expandAll:l,expandToolPayloads:c,activeToolCallId:u,isAgentActive:d,activityItems:E?void 0:k,thinkingCount:N,thoughtForMs:S,skillMetadata:p})},w(j,v))),v=C;continue}if(j.kind==="text"){const{items:k,toolCalls:_,thinkingCount:N,thoughtForMs:S,nextIndex:C}=q3(t,v+1);g.push(a.jsxs("div",{children:[a.jsx("div",{className:G("flex flex-col","gap-3"),children:j.text.map((E,T)=>a.jsx(vle,{text:E,model:o,effort:i,timestamp:j.timestamp,messageKey:`${s}:${r.indexOf(j)}:${T}`},T))}),(_.length>0||N>0)&&a.jsx("div",{className:G("mt-1.5",H3,x),children:a.jsx(P3,{toolCalls:_,expandAll:l,expandToolPayloads:c,activeToolCallId:u,isAgentActive:d,activityItems:N>0?k:void 0,thinkingCount:N,thoughtForMs:S,skillMetadata:p})})]},w(j,v))),v=C;continue}if(j.kind==="queued_prompt"){g.push(a.jsxs("div",{className:G("rounded-lg p-3",mI),children:[a.jsx(Fe,{variant:"outline",className:"mb-2",children:"Queued while working"}),a.jsx(Lb,{content:j.content,timestamp:j.timestamp??""})]},w(j,v))),v++;continue}if(j.kind==="agent_message"){g.push(a.jsx(xle,{sender:j.sender,body:j.body,reply:j.reply,timestamp:j.timestamp,isLive:f},w(j,v))),v++;continue}if(j.kind==="sub_agent"){g.push(a.jsx("div",{className:G(K3,x),children:a.jsx(x3,{messages:j.messages,expandAll:l,label:"Sub-agent activity",countLabel:"subagents active"})},w(j,v))),v++;continue}if(j.kind==="background_agent"){g.push(a.jsx("div",{className:G(K3,x),children:a.jsx(x3,{messages:j.messages,expandAll:l,label:"Background agent activity",countLabel:"agents active"})},w(j,v))),v++;continue}if(j.kind==="hook_event"){g.push(a.jsx(Dle,{events:j.events},w(j,v))),v++;continue}if(j.kind==="plan_mode"){g.push(a.jsx(ude,{plan:j.plan,planFilePath:j.planFilePath,status:j.status,toolCalls:j.toolCalls,expandAll:l,expandToolPayloads:c,isAgentActive:d,skillMetadata:p},w(j,v))),v++;continue}if(j.kind==="recap"){g.push(a.jsx(dde,{content:j.content},w(j,v))),v++;continue}if(j.kind==="task_notification"){g.push(a.jsx(eie,{content:j.content},w(j,v))),v++;continue}if(j.kind==="local_command"){g.push(a.jsx(yae,{content:j.content,contextUsage:j.contextUsage,usageReport:j.usageReport},w(j,v))),v++;continue}v++}h=a.jsx(a.Fragment,{children:g}),e[0]=u,e[1]=t,e[2]=i,e[3]=l,e[4]=c,e[5]=d,e[6]=m,e[7]=f,e[8]=o,e[9]=r,e[10]=p,e[11]=s,e[12]=h}else h=e[12];return h}const Wfe={auto:"auto",manual:"manual",idle:"while idle"};function qfe(n){if(!n)return null;const e=Wfe[n.trigger]??"auto";return n.postTokens!=null?`${e} · ${vt(n.preTokens)} → ${vt(n.postTokens)}`:`${e} · ${vt(n.preTokens)}`}const Vfe=y.memo(function(e){const t=V.c(29),{summary:s,meta:r}=e,[o,i]=y.useState(!1);let l;t[0]!==r?(l=qfe(r),t[0]=r,t[1]=l):l=t[1];const c=l;let u;t[2]!==s?(u=s==null?void 0:s.trim(),t[2]=s,t[3]=u):u=t[3];const d=u;let f;t[4]!==d||t[5]!==o?(f=d&&(o?a.jsx(_t,{className:"size-3","data-icon":"inline-start"}):a.jsx(it,{className:"size-3","data-icon":"inline-start"})),t[4]=d,t[5]=o,t[6]=f):f=t[6];let m,p;t[7]===Symbol.for("react.memo_cache_sentinel")?(m=a.jsx(p8,{className:"size-3","data-icon":"inline-start"}),p=a.jsx("span",{className:"font-medium",children:"Compacted"}),t[7]=m,t[8]=p):(m=t[7],p=t[8]);let h;t[9]!==c?(h=c&&a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"·"}),a.jsx("span",{children:c})]}),t[9]=c,t[10]=h):h=t[10];let g;t[11]!==f||t[12]!==h?(g=a.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground transition-colors group-hover:text-foreground",children:[f,m,p,h]}),t[11]=f,t[12]=h,t[13]=g):g=t[13];const x=g;if(!d){let N;t[14]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx("div",{className:"h-px flex-1 bg-border"}),t[14]=N):N=t[14];let S;t[15]===Symbol.for("react.memo_cache_sentinel")?(S=a.jsx("div",{className:"h-px flex-1 bg-border"}),t[15]=S):S=t[15];let C;return t[16]!==x?(C=a.jsxs("div",{className:"flex items-center gap-3 px-4 py-2",children:[N,x,S]}),t[16]=x,t[17]=C):C=t[17],C}let b,w;t[18]===Symbol.for("react.memo_cache_sentinel")?(b=a.jsx(Q,{type:"button",variant:"ghost",className:"group h-auto w-full gap-3 px-0"}),w=a.jsx("div",{className:"h-px flex-1 bg-border"}),t[18]=b,t[19]=w):(b=t[18],w=t[19]);let v;t[20]===Symbol.for("react.memo_cache_sentinel")?(v=a.jsx("div",{className:"h-px flex-1 bg-border"}),t[20]=v):v=t[20];let j;t[21]!==x?(j=a.jsxs(rs,{render:b,children:[w,x,v]}),t[21]=x,t[22]=j):j=t[22];let k;t[23]!==d?(k=a.jsx(yn,{children:a.jsx("div",{className:"prose prose-sm dark:prose-invert mx-8 mt-2 max-w-none rounded-md border bg-muted/30 px-3 py-2",children:a.jsx(tr,{remarkPlugins:Or,components:As,children:d})})}),t[23]=d,t[24]=k):k=t[24];let _;return t[25]!==o||t[26]!==j||t[27]!==k?(_=a.jsxs(vn,{open:o,onOpenChange:i,className:"px-4 py-2",children:[j,k]}),t[25]=o,t[26]=j,t[27]=k,t[28]=_):_=t[28],_}),Hfe=1.5;function Kfe(n,e){return e<=0?!1:n<e*Hfe}function Gfe(n,e){return n===0&&!e}function Zfe(n,e){return!n||!n.firstKey||e.length<=n.length||e[0]===n.firstKey?!1:e.includes(n.firstKey)}function Yfe(n,e){return e&&e!=="claude"?n.isFragment===!0:n.userMessage===null}const Xfe=/<image\b[^>]*>[\s\S]*?<\/image>|!\[image\]\(<[^>]*>\)|\[audio attachment\]\(<[^>]*>\)/g;function G3(n){return n.replace(Xfe,"").trim()}function Jfe(n,e){const t=n[n.length-1],s=t==null?void 0:t.contentBlocks[t.contentBlocks.length-1];if(!(e!=null&&e.opensOnPrompt)||(s==null?void 0:s.kind)!=="queued_prompt")return n;const r=G3(s.content);return!r||r!==G3(za(e.userMessage))?n:[...n.slice(0,-1),{...t,contentBlocks:t.contentBlocks.slice(0,-1)}]}const Qfe=1e3;function eme(n){const e=new Map;return n.map(t=>{if(!t.contentBlocks.some(r=>r.kind==="agent_message"))return t;const s=t.contentBlocks.filter(r=>{if(r.kind!=="agent_message")return!0;const o=Date.parse(r.timestamp??"");if(Number.isNaN(o))return!0;const i=`${r.sender}\0${r.body}`,l=e.get(i);return l!==void 0&&Math.abs(o-l)<=Qfe?!1:(e.set(i,o),!0)});return s.length===t.contentBlocks.length?t:{...t,contentBlocks:s}})}function hI(n,e,t){const s=new Set(n.map(u=>u.id)),r=e.filter(u=>!s.has(u.id));if(r.length===0)return n;const o=Jfe(r,n[0]),i=n[0],l=o[o.length-1],c=i&&l&&Yfe(i,t)?[...o.slice(0,-1),nme(l,i),...n.slice(1)]:[...o,...n];return RT(hb(eme(c)))}function tme(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 nme(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:tme(n,e),tokenUsage:e.tokenUsage??n.tokenUsage,model:e.model??n.model,compactionSummary:n.compactionSummary??e.compactionSummary,compactionMeta:n.compactionMeta??e.compactionMeta}}function sme(){const n=V.c(10),{session:e,isSubAgentView:t,undoRedo:s}=kt(),{canRedo:r,redoTurnCount:o,redoGhostTurns:i,requestRedoAll:l,requestRedoUpTo:c}=s,u=(e==null?void 0:e.turns.length)??0;if(!s.enabled||t||!r||!l)return null;let d;n[0]!==o||n[1]!==l?(d=a.jsx(ule,{redoTurnCount:o,onRedoAll:l}),n[0]=o,n[1]=l,n[2]=d):d=n[2];let f;n[3]!==i||n[4]!==c||n[5]!==u?(f=i.length>0&&a.jsx("div",{className:"select-none",children:i.map((p,h)=>a.jsxs("div",{className:"group/ghost relative opacity-25 hover:opacity-40 transition-opacity",children:[a.jsx(pI,{turn:p,index:u+h}),c&&a.jsxs(Q,{type:"button",variant:"outline",size:"xs",onClick:()=>c(h),className:"absolute right-4 top-4 text-success opacity-0 transition-opacity group-hover/ghost:opacity-100",children:[a.jsx(h8,{"data-icon":"inline-start"}),"Redo to here"]})]},`ghost-${p.id}`))}),n[3]=i,n[4]=c,n[5]=u,n[6]=f):f=n[6];let m;return n[7]!==d||n[8]!==f?(m=a.jsxs(a.Fragment,{children:[d,f]}),n[7]=d,n[8]=f,n[9]=m):m=n[9],m}function rme(n){const e=V.c(5),{hasMore:t,isLoadingOlder:s}=n;let r;e[0]!==t||e[1]!==s?(r=s?a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(St,{className:"size-3 animate-spin","data-icon":"inline-start"}),"Loading older turns…"]}):t?null:a.jsx("span",{children:"Beginning of session"}),e[0]=t,e[1]=s,e[2]=r):r=e[2];let o;return e[3]!==r?(o=a.jsx("div",{className:"flex h-8 select-none items-center justify-center text-xs text-muted-foreground","data-testid":"history-status",children:r}),e[3]=r,e[4]=o):o=e[4],o}function ome(n){return(n.compactionSummary!=null||n.compactionMeta!=null)&&n.userMessage==null&&n.contentBlocks.length===0}function ime({filteredTurns:n,scrollContainerRef:e,hasMore:t=!1,isLoadingOlder:s=!1,pagingEnabled:r=!1,onLoadMore:o}){const{state:{activeTurnIndex:i}}=Sn(),{undoRedo:l}=kt(),c=y.useRef(null),u=y.useRef(null),[d,f]=y.useState(0),m=y.useMemo(()=>{const v=new Map;return n.map(j=>{const k=v.get(j.turn.id)??0;return v.set(j.turn.id,k+1),{...j,key:k===0?j.turn.id:`${j.turn.id}#${k}`}})},[n]),p=y.useRef(null),h=y.useMemo(()=>Zfe(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,j=u.current;if(!v||!j)return;const k=j.getBoundingClientRect().top-v.getBoundingClientRect().top+v.scrollTop;f(_=>Math.abs(_-k)<1?_:k)},[e,x]),y.useEffect(()=>{if(!t||!o||!r||s)return;const v=e.current;if(!v)return;const j=()=>{Kfe(v.scrollTop,v.clientHeight)&&o()};return j(),v.addEventListener("scroll",j,{passive:!0}),()=>v.removeEventListener("scroll",j)},[t,s,r,o,m.length,e]);const b=y.useMemo(()=>{const v=new Map;for(let j=0;j<m.length;j++)v.set(m[j].index,j);return v},[m]),w=y.useRef(null);return y.useEffect(()=>{var j;if(i===null){w.current=null;return}if(i===w.current)return;w.current=i;const v=b.get(i);v!==void 0&&((j=c.current)==null||j.scrollToIndex(v,{align:"start",smooth:!0}))},[i,b]),a.jsxs(a.Fragment,{children:[x&&a.jsx(rme,{hasMore:t,isLoadingOlder:s}),a.jsx("div",{ref:u,className:"motion-session-enter",children:a.jsx(cle,{ref:c,scrollRef:e,startMargin:d,shift:h,children:m.map(({turn:v,index:j,key:k})=>a.jsxs("div",{"data-turn-index":j,children:[(v.compactionSummary||v.compactionMeta)&&a.jsx(Vfe,{summary:v.compactionSummary,meta:v.compactionMeta}),!ome(v)&&a.jsx(pI,{turn:v,index:j,branchCount:l.branchesAtTurn?l.branchesAtTurn(j).length:0})]},k))})}),a.jsx(sme,{})]})}const ame=y.memo(function(e){const t=V.c(19),{chatScrollRef:s,hasMore:r,isLoadingOlder:o,pagingEnabled:i,onLoadMore:l}=e,{state:c}=Sn(),{searchQuery:u,sessionChangeKey:d}=c,{session:f}=kt(),m=f==null?void 0:f.turns;let p;t[0]!==m?(p=m?m.map(lme):[],t[0]=m,t[1]=p):p=t[1];const h=p;let g;t[2]!==h||t[3]!==u?(g=u?h.filter(j=>{const{turn:k}=j;return Sfe(k,u)}):h,t[2]=h,t[3]=u,t[4]=g):g=t[4];const x=g;let b;t[5]!==x.length||t[6]!==r||t[7]!==u?(b=u?x.length===0:Gfe(x.length,r??!1),t[5]=x.length,t[6]=r,t[7]=u,t[8]=b):b=t[8];const w=b;let v;return t[9]!==s||t[10]!==x||t[11]!==r||t[12]!==o||t[13]!==l||t[14]!==i||t[15]!==u||t[16]!==d||t[17]!==w?(v=a.jsx(Loe,{children:w?a.jsx(Ln,{className:"min-h-64 border-0",children:a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:u?a.jsx(g8,{}):a.jsx(z4,{})}),a.jsx(zn,{children:u?"No matching turns":"No conversation yet"}),a.jsx(Dn,{children:u?"Try a different search term.":"Messages and tool activity will appear here."})]})}):a.jsx(ime,{filteredTurns:x,scrollContainerRef:s,hasMore:r,isLoadingOlder:o,pagingEnabled:i,onLoadMore:l},d)}),t[9]=s,t[10]=x,t[11]=r,t[12]=o,t[13]=l,t[14]=i,t[15]=u,t[16]=d,t[17]=w,t[18]=v):v=t[18],v});function lme(n,e){return{turn:n,index:e}}const cme="[data-turn-index]",gI="[data-turn-prompt]",Z3=1,ume=120,Y3=180;function dme(n,e){if(!n.userMessage)return null;const t=za(n.userMessage),{body:s}=la(t),{remainingText:r}=Hx(s),o=JN(r),i=Kx(o,e);if(i)return i;if(!o){const c=QN(t);if(!c)return null;const u=e5(t);return u?`/${c} ${u}`:`/${c}`}const l=o.split(`
461
- `)[0];return l.length>Y3?`${l.slice(0,Y3)}...`:l}function fme(n,e,t){for(let s=e;s>=0;s--){const r=n[s];if(!r)continue;const o=dme(r,t);if(o)return{index:s,text:o}}return null}function mme(n){const e=n.getBoundingClientRect().top;let t=null,s=0;for(const l of n.querySelectorAll(cme)){const c=l.getBoundingClientRect().top;if(c>e+Z3)break;t=l,s=c}if(!t)return null;const r=Number(t.dataset.turnIndex);if(!Number.isInteger(r))return null;const o=t.querySelector(gI);return(o?o.getBoundingClientRect().bottom>e+Z3:s+ume>e)?null:r}const pme=y.memo(function(e){const t=V.c(23),{session:s,scrollContainerRef:r}=e,[o,i]=y.useState(null);let l,c;t[0]!==r||t[1]!==s.sessionId?(l=()=>{const k=r.current;if(!k)return;let _=null;const N=()=>{_=null;const T=mme(k);i($=>T===null?null:($==null?void 0:$.sessionId)===s.sessionId&&$.index===T?$:{sessionId:s.sessionId,index:T})},S=()=>{_===null&&(_=requestAnimationFrame(N))};i(null),k.addEventListener("scroll",S,{passive:!0});const C=new MutationObserver(S);C.observe(k,{childList:!0,subtree:!0});const E=new ResizeObserver(S);return E.observe(k),k.firstElementChild&&E.observe(k.firstElementChild),S(),()=>{k.removeEventListener("scroll",S),C.disconnect(),E.disconnect(),_!==null&&cancelAnimationFrame(_)}},c=[r,s.sessionId],t[0]=r,t[1]=s.sessionId,t[2]=l,t[3]=c):(l=t[2],c=t[3]),y.useEffect(l,c);const u=$a();let d;e:{if(!o||o.sessionId!==s.sessionId){d=null;break e}let k;t[4]!==u||t[5]!==s.turns||t[6]!==o.index?(k=fme(s.turns,o.index,u),t[4]=u,t[5]=s.turns,t[6]=o.index,t[7]=k):k=t[7],d=k}const f=d;if(!f)return null;let m;t[8]!==f.index||t[9]!==r?(m=()=>{const k=r.current;if(!k)return;const _=k.querySelector(`[data-turn-index="${f.index}"]`),N=(_==null?void 0:_.querySelector(gI))??_;if(!N)return;const S=k.scrollTop+N.getBoundingClientRect().top-k.getBoundingClientRect().top;k.scrollTo({top:Math.max(0,S),behavior:"smooth"})},t[8]=f.index,t[9]=r,t[10]=m):m=t[10];const p=m,h=`Scroll to turn ${f.index+1} prompt`;let g;t[11]===Symbol.for("react.memo_cache_sentinel")?(g=a.jsx(z4,{"data-icon":"inline-start"}),t[11]=g):g=t[11];const x=f.index+1;let b;t[12]!==x?(b=a.jsxs("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:["Turn ",x]}),t[12]=x,t[13]=b):b=t[13];let w;t[14]!==f.text?(w=a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-normal text-foreground/80",children:f.text}),t[14]=f.text,t[15]=w):w=t[15];let v;t[16]===Symbol.for("react.memo_cache_sentinel")?(v=a.jsx(ka,{"data-icon":"inline-end",className:"ml-auto"}),t[16]=v):v=t[16];let j;return t[17]!==f.text||t[18]!==p||t[19]!==h||t[20]!==b||t[21]!==w?(j=a.jsxs(Q,{type:"button",variant:"outline",size:"sm","aria-label":h,title:f.text,className:"motion-slide-down-in absolute left-1/2 top-12 z-20 h-9 max-w-[calc(100%-5rem)] -translate-x-1/2 justify-start gap-2 rounded-full bg-popover px-3 text-left shadow-sm",onClick:p,children:[g,b,w,v]}),t[17]=f.text,t[18]=p,t[19]=h,t[20]=b,t[21]=w,t[22]=j):j=t[22],j});function R1({path:n,dirName:e,command:t}){return qo()?(console.warn("[open-terminal] unavailable for remote devices"),!1):!n&&!e?(console.warn("[open-terminal] no project path available"),!1):(Ce("/api/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,dirName:e,...t?{command:t}:{}})}).then(s=>{s.ok||s.json().then(r=>console.error("[open-terminal]",r.error)).catch(()=>{})}).catch(s=>console.error("[open-terminal] fetch failed:",s)),!0)}const hme={five_hour:"5-hour",seven_day:"weekly",seven_day_opus:"weekly Opus",seven_day_sonnet:"weekly Sonnet",seven_day_overage_included:"weekly",overage:"spend"},gme=1440*60*1e3;function xme(n){return(n&&hme[n])??"usage"}function bme(n){if(n===null)return null;const e=new Date(n*1e3);if(Number.isNaN(e.getTime()))return null;const t=e.getTime()-Date.now()>gme;return e.toLocaleString(void 0,{...t?{weekday:"short"}:{},hour:"numeric",minute:"2-digit"})}function vme(n){return n===void 0?"":n?"Extra usage is on but did not cover this. ":"Extra usage is off for this account. "}function yme(n){const e=V.c(36),{block:t,dirName:s,fileName:r,cwd:o,terminal:i}=n;let l,c;e[0]!==o||e[1]!==s||e[2]!==r?(l=vs(s),c=jx(l.kind,Ed(r),o??void 0),e[0]=o,e[1]=s,e[2]=r,e[3]=l,e[4]=c):(l=e[3],c=e[4]);const u=c;let d;e[5]!==t.resetsAt?(d=bme(t.resetsAt),e[5]=t.resetsAt,e[6]=d):d=e[6];const f=d,m=t.lowPriority&&l.capabilities.lowPriorityInTerminal;let p;e[7]!==m||e[8]!==i?(p=m&&i&&!qo(),e[7]=m,e[8]=i,e[9]=p):p=e[9];const h=p;let g;e[10]===Symbol.for("react.memo_cache_sentinel")?(g=a.jsx(Io,{}),e[10]=g):g=e[10];const x=l.displayName;let b;e[11]!==t.limit?(b=xme(t.limit),e[11]=t.limit,e[12]=b):b=e[12];let w;e[13]!==l.displayName||e[14]!==b?(w=a.jsxs(tn,{children:[x," hit its ",b," limit"]}),e[13]=l.displayName,e[14]=b,e[15]=w):w=e[15];const v=f?`Resets at ${f}. `:"";let j;e[16]!==t.extraUsage?(j=vme(t.extraUsage),e[16]=t.extraUsage,e[17]=j):j=e[17];let k;e[18]!==u||e[19]!==m?(k=m?a.jsxs(a.Fragment,{children:["It can keep this session going before then at lower priority, spending your weekly allowance to do it — a mode that exists only in its own terminal. Resume there with ",a.jsx("code",{className:"font-mono",children:u}),"."]}):a.jsx(a.Fragment,{children:"Nothing here can lift this one; the session continues once the allowance refills."}),e[18]=u,e[19]=m,e[20]=k):k=e[20];let _;e[21]!==k||e[22]!==v||e[23]!==j?(_=a.jsxs("span",{children:[v,j,k]}),e[21]=k,e[22]=v,e[23]=j,e[24]=_):_=e[24];let N;e[25]!==h||e[26]!==u||e[27]!==o||e[28]!==s?(N=h&&a.jsx(Q,{size:"sm",variant:"outline",onClick:()=>R1({path:o??void 0,dirName:s,command:u}),children:"Open in terminal"}),e[25]=h,e[26]=u,e[27]=o,e[28]=s,e[29]=N):N=e[29];let S;e[30]!==_||e[31]!==N?(S=a.jsxs(Rt,{className:"flex flex-col items-start gap-2",children:[_,N]}),e[30]=_,e[31]=N,e[32]=S):S=e[32];let C;return e[33]!==S||e[34]!==w?(C=a.jsxs(jt,{role:"status",className:"rounded-none border-x-0 border-t-0 px-4 py-2",children:[g,w,S]}),e[33]=S,e[34]=w,e[35]=C):C=e[35],C}function wme(n){const e=V.c(14),{block:t,showCursor:s}=n;if(t.blockType==="tool_use"){const l=t.toolName??"tool";let c;return e[0]!==l?(c=a.jsxs("div",{className:"text-xs text-muted-foreground italic py-1",children:["Preparing ",l,"…"]}),e[0]=l,e[1]=c):c=e[1],c}if(t.blockType==="thinking"){if(!t.text)return null;let l;e[2]!==s?(l=s&&a.jsx(X3,{}),e[2]=s,e[3]=l):l=e[3];let c;return e[4]!==t.text||e[5]!==l?(c=a.jsxs("div",{className:"my-2 whitespace-pre-wrap break-words border-l pl-3 text-sm italic leading-relaxed text-muted-foreground",children:[t.text,l]}),e[4]=t.text,e[5]=l,e[6]=c):c=e[6],c}if(!t.text)return null;let r;e[7]!==t.text?(r=a.jsx(AA,{text:t.text}),e[7]=t.text,e[8]=r):r=e[8];let o;e[9]!==s?(o=s&&a.jsx(X3,{}),e[9]=s,e[10]=o):o=e[10];let i;return e[11]!==r||e[12]!==o?(i=a.jsxs("div",{className:"text-sm leading-relaxed break-words my-2",children:[r,o]}),e[11]=r,e[12]=o,e[13]=i):i=e[13],i}function X3(){const n=V.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=a.jsx("span",{className:"ml-0.5 inline-block h-[15px] w-[7px] rounded-[1px] bg-foreground/70 align-text-bottom"}),n[0]=e):e=n[0],e}const Sme=y.memo(function(){const e=V.c(9),t=zb();let s,r,o,i;if(e[0]!==t){i=Symbol.for("react.early_return_sentinel");e:{const c=jle(t);if(c.length===0){i=null;break e}const u=new Map;s="px-4",r="streaming-turn-overlay",o=c.map(d=>{const f=u.get(d.messageId)??0;u.set(d.messageId,f+1);const m=d.blocks.reduce(kme,-1);return a.jsx("div",{children:d.blocks.map((p,h)=>a.jsx(wme,{block:p,showCursor:!d.stopped&&h===m},p.index))},`${d.messageId}:${f}`)})}e[0]=t,e[1]=s,e[2]=r,e[3]=o,e[4]=i}else s=e[1],r=e[2],o=e[3],i=e[4];if(i!==Symbol.for("react.early_return_sentinel"))return i;let l;return e[5]!==s||e[6]!==r||e[7]!==o?(l=a.jsx("div",{className:s,"data-testid":r,children:o}),e[5]=s,e[6]=r,e[7]=o,e[8]=l):l=e[8],l});function kme(n,e,t){return e.blockType!=="tool_use"&&e.text?t:n}class xI extends y.Component{constructor(t){super(t);Ge(this,"handleRetry",()=>{this.setState({hasError:!1,error:null})});this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,s){console.error("ErrorBoundary caught:",t,s.componentStack)}render(){return this.state.hasError?a.jsx("div",{className:"flex justify-center p-8",children:a.jsxs(jt,{variant:"destructive",className:"max-w-md has-data-[slot=alert-action]:pr-2.5",children:[a.jsx(Ir,{}),a.jsx(tn,{children:a.jsx("h3",{children:this.props.fallbackMessage||"Something went wrong"})}),this.state.error&&a.jsx(Rt,{className:"font-mono text-xs",children:this.state.error.message}),a.jsx(Po,{className:"static col-start-2 mt-2",children:a.jsxs(Q,{variant:"outline",size:"sm",onClick:this.handleRetry,children:[a.jsx(Fn,{"data-icon":"inline-start"}),"Try again"]})})]})}):this.props.children}}const J3="find-in-session-highlight",Yh="find-in-session-active";function jme(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 Nme=y.forwardRef(function(e,t){const s=V.c(63),{scrollContainerRef:r}=e,[o,i]=y.useState(!1),[l,c]=y.useState("");let u;s[0]===Symbol.for("react.memo_cache_sentinel")?(u=[],s[0]=u):u=s[0];const[d,f]=y.useState(u),[m,p]=y.useState(-1),h=y.useRef(null);let g;s[1]!==r?(g=()=>{const J=r.current;if(!J)return;J.querySelectorAll(`mark.${J3}`).forEach(Cme)},s[1]=r,s[2]=g):g=s[2];const x=g;let b;s[3]!==x||s[4]!==r?(b=J=>{if(x(),!J||!r.current){f([]),p(-1);return}const ne=r.current,ie=jme(ne),ae=J.toLowerCase(),oe=[];for(const ue of ie){const re=ue.nodeValue||"",de=re.toLowerCase();let fe=0;const le=[];for(;;){const be=de.indexOf(ae,fe);if(be===-1)break;le.push(be),fe=be+1}if(le.length===0)continue;const ce=ue.parentNode;if(!ce)continue;const he=document.createDocumentFragment();let ge=0;for(const be of le){be>ge&&he.appendChild(document.createTextNode(re.slice(ge,be)));const ve=document.createElement("mark");ve.className=J3,ve.textContent=re.slice(be,be+J.length),he.appendChild(ve),oe.push(ve),ge=be+J.length}ge<re.length&&he.appendChild(document.createTextNode(re.slice(ge))),ce.replaceChild(he,ue)}f(oe),oe.length>0?(p(0),oe[0].classList.add(Yh),oe[0].scrollIntoView({block:"center",behavior:"smooth"})):p(-1)},s[3]=x,s[4]=r,s[5]=b):b=s[5];const w=b;let v;s[6]!==m||s[7]!==d?(v=J=>{if(d.length===0)return;m>=0&&m<d.length&&d[m].classList.remove(Yh);const ne=(J%d.length+d.length)%d.length;d[ne].classList.add(Yh),d[ne].scrollIntoView({block:"center",behavior:"smooth"}),p(ne)},s[6]=m,s[7]=d,s[8]=v):v=s[8];const j=v;let k;s[9]!==x?(k=()=>{i(!1),c(""),x(),f([]),p(-1)},s[9]=x,s[10]=k):k=s[10];const _=k;let N,S;s[11]!==_||s[12]!==o?(N=()=>({open:()=>{i(!0),requestAnimationFrame(()=>{var J;return(J=h.current)==null?void 0:J.focus()})},close:_,isOpen:o}),S=[_,o],s[11]=_,s[12]=o,s[13]=N,s[14]=S):(N=s[13],S=s[14]),y.useImperativeHandle(t,N,S);let C,E;s[15]!==w||s[16]!==l?(C=()=>{const J=setTimeout(()=>w(l),150);return()=>clearTimeout(J)},E=[l,w],s[15]=w,s[16]=l,s[17]=C,s[18]=E):(C=s[17],E=s[18]),y.useEffect(C,E);let T,$;s[19]!==x?(T=()=>()=>x(),$=[x],s[19]=x,s[20]=T,s[21]=$):(T=s[20],$=s[21]),y.useEffect(T,$);let A;s[22]!==m||s[23]!==j||s[24]!==_?(A=J=>{J.key==="Escape"?(J.preventDefault(),J.stopPropagation(),_()):J.key==="Enter"&&(J.preventDefault(),J.shiftKey?j(m-1):j(m+1))},s[22]=m,s[23]=j,s[24]=_,s[25]=A):A=s[25];const R=A;if(!o)return null;let P;s[26]===Symbol.for("react.memo_cache_sentinel")?(P=J=>c(J.target.value),s[26]=P):P=s[26];let z;s[27]!==R||s[28]!==l?(z=a.jsx(Go,{ref:h,value:l,onChange:P,onKeyDown:R,placeholder:"Find in conversation","aria-label":"Find in conversation",autoFocus:!0}),s[27]=R,s[28]=l,s[29]=z):z=s[29];const L=l?d.length>0?`${m+1}/${d.length}`:"0/0":"";let I;s[30]!==L?(I=a.jsx(Tr,{align:"inline-end",children:a.jsx("span",{className:"min-w-12 text-center text-xs tabular-nums",children:L})}),s[30]=L,s[31]=I):I=s[31];let M;s[32]!==z||s[33]!==I?(M=a.jsxs(Ko,{className:"w-64",children:[z,I]}),s[32]=z,s[33]=I,s[34]=M):M=s[34];let F;s[35]!==m||s[36]!==j?(F=()=>j(m-1),s[35]=m,s[36]=j,s[37]=F):F=s[37];const U=d.length===0,O=d.length>0?"hover:text-foreground":"cursor-default opacity-40";let D;s[38]!==O?(D=G("text-muted-foreground",O),s[38]=O,s[39]=D):D=s[39];let B;s[40]===Symbol.for("react.memo_cache_sentinel")?(B=a.jsx(ka,{"data-icon":"inline-start"}),s[40]=B):B=s[40];let q;s[41]!==F||s[42]!==U||s[43]!==D?(q=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",onClick:F,disabled:U,className:D,"aria-label":"Previous match",children:B}),s[41]=F,s[42]=U,s[43]=D,s[44]=q):q=s[44];let W;s[45]!==m||s[46]!==j?(W=()=>j(m+1),s[45]=m,s[46]=j,s[47]=W):W=s[47];const H=d.length===0,K=d.length>0?"hover:text-foreground":"cursor-default opacity-40";let Z;s[48]!==K?(Z=G("text-muted-foreground",K),s[48]=K,s[49]=Z):Z=s[49];let Y;s[50]===Symbol.for("react.memo_cache_sentinel")?(Y=a.jsx(_t,{"data-icon":"inline-start"}),s[50]=Y):Y=s[50];let X;s[51]!==W||s[52]!==H||s[53]!==Z?(X=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",onClick:W,disabled:H,className:Z,"aria-label":"Next match",children:Y}),s[51]=W,s[52]=H,s[53]=Z,s[54]=X):X=s[54];let ee;s[55]===Symbol.for("react.memo_cache_sentinel")?(ee=a.jsx(Mt,{"data-icon":"inline-start"}),s[55]=ee):ee=s[55];let te;s[56]!==_?(te=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",onClick:_,className:"text-muted-foreground hover:text-foreground","aria-label":"Close search",children:ee}),s[56]=_,s[57]=te):te=s[57];let se;return s[58]!==M||s[59]!==q||s[60]!==X||s[61]!==te?(se=a.jsxs("div",{className:"motion-slide-down-in absolute right-4 top-12 z-30 flex items-center gap-1 rounded-lg border bg-popover p-2 text-popover-foreground shadow-sm",children:[M,q,X,te]}),s[58]=M,s[59]=q,s[60]=X,s[61]=te,s[62]=se):se=s[62],se});function Cme(n){const e=n.parentNode;e&&(e.replaceChild(document.createTextNode(n.textContent||""),n),e.normalize())}const bI=[1,2,3,4,5,6,7,8,9],F2e=["General","View","Tools"],Em=[{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}},...bI.map(n=>({command:`device.switch.${n}`,label:`Switch to device ${n}`,description:n===1?"Jump to this machine (the local device)":`Jump to the ${n}${n===2?"nd":n===3?"rd":"th"} device in the switcher`,group:"General",defaultShortcut:{key:String(n),platformChord:!0}})),{command:"device.cycle",label:"Cycle devices",description:"Switch to the next device in the switcher",group:"General",defaultShortcut:{key:"0",platformChord:!0}}],vI="cogpit-keybindings";let oi=null;function yI(n=typeof navigator>"u"?"":navigator.platform){return/Mac|iPhone|iPad/i.test(n)}function xc(n){const e=n.toLowerCase();return e==="esc"?"escape":e}function _me(n){if(!n||typeof n!="object")return!1;const e=n;return e.doubleTapModifier==="mod"||typeof e.key=="string"&&e.key.length>0}function Hb(){if(oi)return oi;try{const n=localStorage.getItem(vI);if(!n)return oi={};const e=JSON.parse(n);if(!e||typeof e!="object")return oi={};const t={};for(const s of Em){const r=e[s.command];_me(r)&&(t[s.command]=r)}return oi=t}catch{return oi={}}}function Kb(n){oi=n;try{localStorage.setItem(vI,JSON.stringify(n))}catch{}typeof window<"u"&&window.dispatchEvent(new Event("cogpit-keybindings-changed"))}function nu(n){const e=Em.find(t=>t.command===n);if(!e)throw new Error(`Unknown keybinding command: ${n}`);return Hb()[n]??e.defaultShortcut}function U2e(){return Object.fromEntries(Em.map(n=>[n.command,nu(n.command)]))}function B2e(n,e){const t="doubleTapModifier"in e?{...e}:{...e,key:xc(e.key)};Kb({...Hb(),[n]:t})}function W2e(n){const e={...Hb()};delete e[n],Kb(e)}function q2e(){Kb({})}function V2e(n){return{key:xc(n.key),metaKey:n.metaKey||void 0,ctrlKey:n.ctrlKey||void 0,shiftKey:n.shiftKey||void 0,altKey:n.altKey||void 0}}function wI(n){const e=n;if(!e)return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||e.isContentEditable===!0}function on(n,e){const t=nu(n);return"doubleTapModifier"in t||xc(e.key)!==xc(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 Li(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 Eme(n){const e=yI();return"doubleTapModifier"in n?e?"Double ⌘":"Double Ctrl":n.modKey?e?`${n.shiftKey?"⇧":""}⌘${Li(n.key)}`:`Ctrl+${n.shiftKey?"Shift+":""}${Li(n.key)}`:n.platformChord?e?`⌃⌘${n.shiftKey?"⇧":""}${Li(n.key)}`:`Ctrl+Alt+${n.shiftKey?"Shift+":""}${Li(n.key)}`:e?`${n.ctrlKey?"⌃":""}${n.altKey?"⌥":""}${n.shiftKey?"⇧":""}${n.metaKey?"⌘":""}${Li(n.key)}`:[n.ctrlKey?"Ctrl":null,n.altKey?"Alt":null,n.shiftKey?"Shift":null,n.metaKey?"Meta":null,Li(n.key)].filter(Boolean).join("+")}function Qi(n){return Eme(nu(n))}function Q3(n){if("doubleTapModifier"in n)return[`double-tap:${n.doubleTapModifier}`];const e=(t,s,r,o)=>`${xc(n.key)}|${t}|${s}|${r}|${o}`;return n.modKey?[e(!0,!1,!!n.shiftKey,!!n.altKey),e(!1,!0,!!n.shiftKey,!!n.altKey)]:n.platformChord?[e(!0,!0,!!n.shiftKey,!1),e(!1,!0,!!n.shiftKey,!0)]:[e(!!n.metaKey,!!n.ctrlKey,!!n.shiftKey,!!n.altKey)]}function H2e(n,e){const t=new Set(Q3(n));return Em.find(s=>s.command!==e&&Q3(nu(s.command)).some(r=>t.has(r)))??null}function ej(n){return"doubleTapModifier"in nu(n)?yI()?"Meta":"Control":null}const Tme=bI.map(n=>`device.switch.${n}`),Ame="device.cycle";function Ime(n){const e=Tme.findIndex(t=>on(t,n));return e===-1?null:e+1}function Pme(n){return on(Ame,n)}const O1="cogpit:find-in-conversation",Tm=y.memo(function(e){const t=V.c(87),{searchInputRef:s,hasTodos:r,hasMore:o,isLoadingOlder:i,onLoadMore:l,mobileSearchOpen:c,onMobileSearchClose:u}=e,d=c===void 0?!1:c,{state:f,dispatch:m,isMobile:p}=Sn(),{session:h,sessionSource:g,rateLimit:x,permissions:b,isSubAgentView:w}=kt(),v=Nn("terminal"),{chat:j,scroll:k}=Wf(),{searchQuery:_}=f,{pendingMessages:N}=j,{chatScrollRef:S,observeChatContent:C,handleScroll:E,canScrollDown:T,scrollToBottomInstant:$,initialScrollDone:A}=k,R=y.useRef(null);let P;t[0]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{var we;return(we=R.current)==null?void 0:we.open()},t[0]=P):P=t[0];const z=P;let L,I;t[1]===Symbol.for("react.memo_cache_sentinel")?(L=()=>{const we=function($e){on("findInConversation",$e)&&($e.preventDefault(),z())};return window.addEventListener("keydown",we),window.addEventListener(O1,z),()=>{window.removeEventListener("keydown",we),window.removeEventListener(O1,z)}},I=[z],t[1]=L,t[2]=I):(L=t[1],I=t[2]),y.useEffect(L,I);let M,F;t[3]!==p||t[4]!==d||t[5]!==s?(M=()=>{!p||!d||requestAnimationFrame(()=>{var we;return(we=s.current)==null?void 0:we.focus()})},F=[p,d,s],t[3]=p,t[4]=d,t[5]=s,t[6]=M,t[7]=F):(M=t[6],F=t[7]),y.useEffect(M,F);let U;t[8]!==m||t[9]!==u?(U=()=>{m({type:"SET_SEARCH_QUERY",value:""}),u==null||u()},t[8]=m,t[9]=u,t[10]=U):U=t[10];const O=U,D=h;let B;t[11]!==x||t[12]!==g?(B=x&&g?{block:x,dirName:g.dirName,fileName:g.fileName}:null,t[11]=x,t[12]=g,t[13]=B):B=t[13];const q=B,W=D.turns.length>0||N.length===0;let H;t[14]!==O||t[15]!==m||t[16]!==p||t[17]!==d||t[18]!==s||t[19]!==_?(H=p&&d&&a.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b bg-background px-3 py-2",children:[a.jsxs(Ko,{className:"h-9 flex-1",children:[a.jsx(Go,{ref:s,value:_,onChange:we=>m({type:"SET_SEARCH_QUERY",value:we.target.value}),placeholder:"Search conversation...","aria-label":"Search conversation"}),a.jsx(Tr,{align:"inline-start",children:a.jsx(ss,{})})]}),a.jsx(Q,{variant:"ghost",size:"icon-sm",onClick:O,"aria-label":"Close conversation search",children:a.jsx(Mt,{"data-icon":"inline-start"})})]}),t[14]=O,t[15]=m,t[16]=p,t[17]=d,t[18]=s,t[19]=_,t[20]=H):H=t[20];let K;t[21]!==v||t[22]!==D.cwd||t[23]!==p||t[24]!==b.send||t[25]!==q?(K=q&&a.jsx("div",{className:G("shrink-0",!p&&"pt-10"),children:a.jsx(yme,{...q,cwd:D.cwd,terminal:v&&b.send})}),t[21]=v,t[22]=D.cwd,t[23]=p,t[24]=b.send,t[25]=q,t[26]=K):K=t[26];let Z;t[27]!==S?(Z=a.jsx(Nme,{ref:R,scrollContainerRef:S}),t[27]=S,t[28]=Z):Z=t[28];let Y;t[29]!==S||t[30]!==D?(Y=a.jsx(pme,{session:D,scrollContainerRef:S}),t[29]=S,t[30]=D,t[31]=Y):Y=t[31];const X=p&&"mobile-scroll";let ee;t[32]!==X?(ee=G("h-full overflow-x-hidden overflow-y-auto",X),t[32]=X,t[33]=ee):ee=t[33];let te;t[34]!==p||t[35]!==q?(te=p?"px-3 py-3 pb-5":G("mx-auto w-full max-w-[var(--chat-width)] px-6",q?"pt-4":"pt-14"),t[34]=p,t[35]=q,t[36]=te):te=t[36];let se;t[37]!==r||t[38]!==p?(se=p?void 0:{paddingBottom:`max(var(--session-footer-height, 0px), ${r?12:8}rem)`},t[37]=r,t[38]=p,t[39]=se):se=t[39];let J;t[40]!==S||t[41]!==o||t[42]!==A||t[43]!==i||t[44]!==l||t[45]!==W?(J=W&&a.jsx(ame,{chatScrollRef:S,hasMore:o,isLoadingOlder:i,pagingEnabled:A,onLoadMore:l}),t[40]=S,t[41]=o,t[42]=A,t[43]=i,t[44]=l,t[45]=W,t[46]=J):J=t[46];let ne,ie;t[47]===Symbol.for("react.memo_cache_sentinel")?(ne=a.jsx(Sme,{}),ie=a.jsx(yfe,{}),t[47]=ne,t[48]=ie):(ne=t[47],ie=t[48]);const ae=b.send&&!w;let oe;t[49]!==D.sessionId||t[50]!==D.turns||t[51]!==p||t[52]!==N||t[53]!==ae?(oe=a.jsx(mA,{sessionId:D.sessionId,turns:D.turns,pendingMessages:N,canManage:ae,isMobile:p}),t[49]=D.sessionId,t[50]=D.turns,t[51]=p,t[52]=N,t[53]=ae,t[54]=oe):oe=t[54];let ue;t[55]!==J||t[56]!==oe?(ue=a.jsxs(xI,{fallbackMessage:"Failed to render conversation timeline",children:[J,ne,ie,oe]}),t[55]=J,t[56]=oe,t[57]=ue):ue=t[57];let re;t[58]!==C||t[59]!==te||t[60]!==se||t[61]!==ue?(re=a.jsx("div",{ref:C,className:te,style:se,children:ue}),t[58]=C,t[59]=te,t[60]=se,t[61]=ue,t[62]=re):re=t[62];let de;t[63]!==S||t[64]!==E||t[65]!==ee||t[66]!==re?(de=a.jsx("div",{ref:S,onScroll:E,className:ee,children:re}),t[63]=S,t[64]=E,t[65]=ee,t[66]=re,t[67]=de):de=t[67];const fe=T?"opacity-100 scale-100":"opacity-0 scale-75 pointer-events-none",le=p?"right-3 bottom-3":"right-5";let ce;t[68]!==fe||t[69]!==le?(ce=G("absolute rounded-full shadow-sm transition-[opacity,transform] duration-200 ease-out active:scale-95",fe,le),t[68]=fe,t[69]=le,t[70]=ce):ce=t[70];let he;t[71]!==p?(he=p?void 0:{bottom:"calc(var(--session-footer-height, 0px) + 1.25rem)"},t[71]=p,t[72]=he):he=t[72];let ge;t[73]===Symbol.for("react.memo_cache_sentinel")?(ge=a.jsx(x8,{"data-icon":"inline-start"}),t[73]=ge):ge=t[73];let be;t[74]!==$||t[75]!==ce||t[76]!==he?(be=a.jsx(Q,{size:"icon",className:ce,style:he,onClick:$,"aria-label":"Scroll to bottom",children:ge}),t[74]=$,t[75]=ce,t[76]=he,t[77]=be):be=t[77];let ve;t[78]!==Z||t[79]!==Y||t[80]!==de||t[81]!==be?(ve=a.jsxs("div",{className:"relative min-h-0 flex-1",children:[Z,Y,de,be]}),t[78]=Z,t[79]=Y,t[80]=de,t[81]=be,t[82]=ve):ve=t[82];let Se;return t[83]!==K||t[84]!==ve||t[85]!==H?(Se=a.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[H,K,ve]}),t[83]=K,t[84]=ve,t[85]=H,t[86]=Se):Se=t[86],Se});function $me({open:n,onOpenChange:e,trigger:t,title:s,description:r,confirmLabel:o,destructive:i=!1,onConfirm:l}){const[c,u]=y.useState(!1),[d,f]=y.useState(null);function m(h){c||(f(null),e(h))}async function p(){u(!0),f(null);try{f(await l())}finally{u(!1)}}return a.jsxs(nb,{open:n,onOpenChange:m,children:[t&&a.jsx(Pte,{render:t}),a.jsxs(sb,{size:"sm",children:[a.jsxs(rb,{children:[a.jsx(ib,{children:s}),a.jsx(ab,{children:r})]}),d&&a.jsx(_o,{className:"text-center",children:d}),a.jsxs(ob,{children:[a.jsx(cb,{disabled:c,children:"Cancel"}),a.jsxs(lb,{variant:i?"destructive":"default",disabled:c,onClick:()=>void p(),children:[c&&a.jsx(St,{"data-icon":"inline-start",className:"animate-spin"}),o]})]})]})]})}function Rme(n){const e=V.c(21),{children:t,error:s,busy:r,saveLabel:o,onCancel:i,onSave:l,className:c}=n;let u;e[0]!==c?(u=G("flex flex-col gap-3 border-t px-3 py-3",c),e[0]=c,e[1]=u):u=e[1];let d;e[2]!==s?(d=s&&a.jsx(_o,{children:s}),e[2]=s,e[3]=d):d=e[3];let f;e[4]!==i?(f=a.jsx(Q,{variant:"outline",size:"sm",onClick:i,children:"Cancel"}),e[4]=i,e[5]=f):f=e[5];let m;e[6]!==r||e[7]!==o?(m=r?a.jsx(St,{"data-icon":"inline-start",className:"animate-spin"}):o,e[6]=r,e[7]=o,e[8]=m):m=e[8];let p;e[9]!==r||e[10]!==l||e[11]!==m?(p=a.jsx(Q,{size:"sm",disabled:r,onClick:l,children:m}),e[9]=r,e[10]=l,e[11]=m,e[12]=p):p=e[12];let h;e[13]!==f||e[14]!==p?(h=a.jsxs("div",{className:"flex justify-end gap-1.5",children:[f,p]}),e[13]=f,e[14]=p,e[15]=h):h=e[15];let g;return e[16]!==t||e[17]!==u||e[18]!==d||e[19]!==h?(g=a.jsxs("div",{className:u,children:[t,d,h]}),e[16]=t,e[17]=u,e[18]=d,e[19]=h,e[20]=g):g=e[20],g}const Ome={ArrowUp:-1,ArrowDown:1};function tj(n,e,t){const s=n.filter(r=>r!==e);return s.splice(t,0,e),s}function nj(n,e){return n.length===e.length&&n.every((t,s)=>t===e[s])}function Lme(n,e){const t=V.c(26),[s,r]=y.useState(null),[o,i]=y.useState(null);let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=new Map,t[0]=l):l=t[0];const c=y.useRef(l),u=y.useRef(null),d=y.useRef(0),f=y.useRef(null);let m;t[1]!==s||t[2]!==n?(m=s??[...n],t[1]=s,t[2]=n,t[3]=m):m=t[3];const p=m;let h;t[4]!==n||t[5]!==e?(h={ids:n,onCommit:e},t[4]=n,t[5]=e,t[6]=h):h=t[6];const g=y.useRef(h);let x;t[7]!==n||t[8]!==e?(x=()=>{g.current={ids:n,onCommit:e}},t[7]=n,t[8]=e,t[9]=x):x=t[9],y.useLayoutEffect(x);let b;t[10]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{const L=u.current,I=L&&c.current.get(L.id);if(!L||!I)return;I.style.transform="";const M=I.getBoundingClientRect().top;I.style.transform=`translateY(${d.current-L.grabOffset-M}px)`},t[10]=b):b=t[10];const w=b;let v;t[11]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{w()},t[11]=v):v=t[11];let j;t[12]!==s?(j=[s,w],t[12]=s,t[13]=j):j=t[13],y.useLayoutEffect(v,j);let k;t[14]===Symbol.for("react.memo_cache_sentinel")?(k=L=>I=>{I?c.current.set(L,I):c.current.delete(L)},t[14]=k):k=t[14];const _=k,N=y.useRef(null);let S;t[15]===Symbol.for("react.memo_cache_sentinel")?(S=L=>{var U;const I=u.current;if(!I)return;u.current=null,(U=N.current)==null||U.call(N),N.current=null;const M=c.current.get(I.id);M&&(M.style.transform="");const F=f.current;f.current=null,i(null),r(null),L&&F&&!nj(F,I.startOrder)&&g.current.onCommit(F)},t[15]=S):S=t[15];const C=S;let E,T;t[16]===Symbol.for("react.memo_cache_sentinel")?(T=()=>()=>{var L;return(L=N.current)==null?void 0:L.call(N)},E=[],t[16]=E,t[17]=T):(E=t[16],T=t[17]),y.useEffect(T,E);let $;t[18]===Symbol.for("react.memo_cache_sentinel")?($=L=>{const I=u.current;if(!I||I.pointerId!==L.pointerId)return;d.current=L.clientY;const M=f.current;if(!M)return;const F=M.filter(O=>{var B;if(O===I.id)return!1;const D=(B=c.current.get(O))==null?void 0:B.getBoundingClientRect();return!!D&&D.top+D.height/2<L.clientY}).length,U=tj(M,I.id,F);nj(U,M)||(f.current=U,r(U)),w()},t[18]=$):$=t[18];const A=$;let R;t[19]!==n||t[20]!==e?(R=L=>({onPointerDown:I=>{if(I.button!==0||u.current)return;const M=c.current.get(L);if(!M)return;d.current=I.clientY,u.current={id:L,pointerId:I.pointerId,grabOffset:I.clientY-M.getBoundingClientRect().top,startOrder:[...n]};const F=[...n];f.current=F,i(L),r(F);const U=D=>{D.pointerId===I.pointerId&&C(!0)},O=D=>{D.pointerId===I.pointerId&&C(!1)};window.addEventListener("pointermove",A),window.addEventListener("pointerup",U),window.addEventListener("pointercancel",O),N.current=()=>{window.removeEventListener("pointermove",A),window.removeEventListener("pointerup",U),window.removeEventListener("pointercancel",O)}},onKeyDown:I=>{const M=Ome[I.key];if(M===void 0)return;I.preventDefault();const F=n.indexOf(L),U=F+M;F===-1||U<0||U>=n.length||e(tj(n,L,U))}}),t[19]=n,t[20]=e,t[21]=R):R=t[21];const P=R;let z;return t[22]!==o||t[23]!==P||t[24]!==p?(z={order:p,draggingId:o,rowRef:_,handleProps:P},t[22]=o,t[23]=P,t[24]=p,t[25]=z):z=t[25],z}const L1="cogpit-devices-changed",SI="cogpit:devices-changed";function kI(n){typeof n.connectionRevision=="number"&&dR(n.id,n.connectionRevision)}function M1(n,e,t=!1){window.dispatchEvent(new CustomEvent(L1,{detail:{deviceId:n,connectionRevision:e,removed:t}}));try{localStorage.setItem(SI,JSON.stringify({deviceId:n,connectionRevision:e,removed:t,nonce:`${Date.now()}:${Math.random()}`}))}catch{}}function sj(n){kI(n),M1(n.id,n.connectionRevision)}function rj(n){const e=Kt();e!==Lt&&!n.some(t=>t.id===e)&&Xs(Lt)}function Xh(n,e=""){return`/api/hub/devices/${encodeURIComponent(n)}${e}`}function jI(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.version;if(typeof t=="string")return t}}function Mme(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.signIn;if(t==="account"||t==="password")return t}}function Fa({enabled:n=!0}={}){const[e,t]=y.useState([]),[s,r]=y.useState(!0),[o,i]=y.useState(()=>Kt()),l=y.useRef(0),c=y.useRef(Promise.resolve()),u=y.useRef(0),d=y.useCallback(async()=>{const w=++l.current;if(!n){t([]),r(!1);return}try{const v=await Ur("/api/hub/devices");if(v.status===403&&w===l.current&&rj([]),!v.ok)return;const j=await zs(v);if(w!==l.current)return;const k=Array.isArray(j==null?void 0:j.devices)?j.devices:[];for(const _ of k)kI(_);if(u.current>0)return;t(k),rj(k)}catch{}finally{w===l.current&&r(!1)}},[n]);y.useEffect(()=>{d()},[d]),y.useEffect(()=>{const w=()=>i(Kt()),v=()=>void d(),j=N=>{if(N.key===SI){try{const S=JSON.parse(N.newValue??"null");(S==null?void 0:S.removed)===!0&&typeof S.deviceId=="string"&&Kt()===S.deviceId&&Xs(Lt)}catch{}d()}},k=()=>{l.current+=1,t([]),r(!0),d()},_=()=>{l.current+=1,t([]),r(!1)};return window.addEventListener("cogpit-device-changed",w),window.addEventListener("popstate",w),window.addEventListener(L1,v),window.addEventListener("storage",j),window.addEventListener("cogpit-auth-changed",k),window.addEventListener("cogpit-identity-changed",k),window.addEventListener("cogpit-auth-required",_),()=>{window.removeEventListener("cogpit-device-changed",w),window.removeEventListener("popstate",w),window.removeEventListener(L1,v),window.removeEventListener("storage",j),window.removeEventListener("cogpit-auth-changed",k),window.removeEventListener("cogpit-identity-changed",k),window.removeEventListener("cogpit-auth-required",_)}},[d]);const f=y.useMemo(()=>o===Lt?void 0:e.find(w=>w.id===o),[e,o]),m=y.useCallback(async(w,v,j,k)=>{try{const _=await Ur("/api/hub/devices/probe",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:w,port:v,allowLocalTunnel:j,tls:k})}),N=await zs(_);return(N==null?void 0:N.ok)===!0&&N.hello?{ok:!0,hello:N.hello}:{ok:!1,code:(N==null?void 0:N.code)??"UNREACHABLE",error:typeof(N==null?void 0:N.error)=="string"?N.error:void 0}}catch{return{ok:!1,code:"UNREACHABLE",error:"Could not reach the device."}}},[]),p=y.useCallback(async w=>{try{const v=await Ur("/api/hub/devices",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(w)}),j=await zs(v);if(v.ok&&(j!=null&&j.device)){const k=j.device;return sj(k),{ok:!0,device:k}}return{ok:!1,code:(j==null?void 0:j.code)??"ERROR",error:typeof(j==null?void 0:j.error)=="string"?j.error:"Could not add the device."}}catch{return{ok:!1,code:"ERROR",error:"Could not add the device."}}},[]),h=y.useCallback(async(w,v)=>{try{const j=await Ur(Xh(w),{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(v)}),k=await zs(j);if(j.ok&&(k!=null&&k.device)){const _=k.device;return sj(_),{ok:!0,device:_}}return{ok:!1,code:(k==null?void 0:k.code)??"ERROR",error:typeof(k==null?void 0:k.error)=="string"?k.error:"Could not update the device."}}catch{return{ok:!1,code:"ERROR",error:"Could not update the device."}}},[]),g=y.useCallback(async w=>{try{const v=await Ur(Xh(w),{method:"DELETE"});if(v.ok)return Kt()===w&&Xs(Lt),M1(w,void 0,!0),{ok:!0};const j=await zs(v);return{ok:!1,error:typeof(j==null?void 0:j.error)=="string"?j.error:"Could not remove the device."}}catch{return{ok:!1,error:"Could not remove the device."}}},[]),x=y.useCallback(async w=>{const v=new Map(w.map((C,E)=>[C,E])),j=C=>v.get(C.id)??w.length;t(C=>[...C].sort((E,T)=>j(E)-j(T))),u.current+=1;const k=async()=>{try{const C=await Ur("/api/hub/devices/order",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({ids:w})}),E=await zs(C);return C.ok&&Array.isArray(E==null?void 0:E.devices)?{result:{ok:!0},devices:E.devices}:{result:{ok:!1,error:typeof(E==null?void 0:E.error)=="string"?E.error:"Could not reorder the devices."}}}catch{return{result:{ok:!1,error:"Could not reorder the devices."}}}},_=c.current.then(k);c.current=_.then(()=>{});const{result:N,devices:S}=await _;return u.current-=1,u.current===0&&(S?(t(S),M1("")):d()),N},[d]),b=y.useCallback(async w=>{try{const v=await Ur(Xh(w,"/test"),{method:"POST"});return await zs(v)??{ok:!1,reachable:!1,code:"UNREACHABLE"}}catch{return{ok:!1,reachable:!1,code:"UNREACHABLE"}}},[]);return{devices:e,activeDeviceId:o,activeDevice:f,loading:s,refresh:d,probe:m,addDevice:p,updateDevice:h,removeDevice:g,reorderDevices:x,testDevice:b}}const oj=s_.version,zme=19384,Dme=443,Fme=450,Ume=Qi("device.switch.1").replace(/1$/,"1–9"),Bme=new Set(["BAD_PASSWORD","PASSWORD_REQUIRED","USERNAME_REQUIRES_PASSWORD"]),Wme=new Set(["ACCOUNT_REFUSED"]);function qu(n){const e=n.trim(),t=/^https:\/\//i.test(e),s=e.replace(/^https?:\/\//i,"").replace(/\/.*$/,""),r=/^(.+):(\d+)$/.exec(s),o=r?r[1]:s,i=r?Number(r[2]):void 0;return t?{host:o,port:i,tls:!0}:{host:o,port:i}}function qme(n,e,t){if(n.ok){if(n.hello.signIn==="account"&&n.hello.setupRequired===!0)return{tone:"info",text:"Reachable server — finish its setup before adding it here."};if(n.hello.signIn!=="account"&&n.hello.networkAccess===!1)return{tone:"warn",text:"Cogpit is running but network access is disabled — enable it in that device's settings."};if(n.hello.configured===!1)return{tone:"info",text:"Reachable — this device hasn't finished setup yet and will show its setup screen."};const s=n.hello.name?` "${n.hello.name}"`:"",r=n.hello.version?` (v${n.hello.version})`:"";return{tone:"ok",text:`Found Cogpit${s}${r}.`}}switch(n.code){case"UNREACHABLE":return{tone:"error",text:`Can't reach ${e}:${t}. Is Cogpit running with network access enabled?`};case"LEGACY_NO_HELLO":return{tone:"error",text:"That Cogpit is too old for multi-device — update it."};case"NOT_COGPIT":return{tone:"error",text:"Something responded, but it isn't Cogpit."};case"SELF_ADD":return{tone:"error",text:"That's this machine."};default:return{tone:"error",text:n.error??"Could not reach the device."}}}const NI={ok:"text-success",warn:"text-warning",info:"text-info",error:"text-destructive"};function Vme(n){const e=V.c(10),{tone:t}=n,s=NI[t];let r;e[0]!==s?(r=G("size-3.5 shrink-0",s),e[0]=s,e[1]=r):r=e[1];const o=r;if(t==="ok"){let l;return e[2]!==o?(l=a.jsx(Pr,{"data-icon":"inline-start",className:o}),e[2]=o,e[3]=l):l=e[3],l}if(t==="warn"){let l;return e[4]!==o?(l=a.jsx(Ir,{"data-icon":"inline-start",className:o}),e[4]=o,e[5]=l):l=e[5],l}if(t==="info"){let l;return e[6]!==o?(l=a.jsx(Fn,{"data-icon":"inline-start",className:o}),e[6]=o,e[7]=l):l=e[7],l}let i;return e[8]!==o?(i=a.jsx(Bo,{"data-icon":"inline-start",className:o}),e[8]=o,e[9]=i):i=e[9],i}const Hme={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"};function Kme(n){const e=V.c(119),{device:t,onRename:s,onCredentials:r,onRemove:o,onTest:i,slot:l,rowRef:c,dragging:u,dragHandleProps:d}=n,[f,m]=y.useState(!1),[p,h]=y.useState(t.name),[g,x]=y.useState(!1),[b,w]=y.useState(t.username??""),[v,j]=y.useState(""),[k,_]=y.useState(null),[N,S]=y.useState(!1),[C,E]=y.useState(null);let T,$;e[0]!==t.name?(T=()=>{h(t.name)},$=[t.name],e[0]=t.name,e[1]=T,e[2]=$):(T=e[1],$=e[2]),y.useEffect(T,$);let A,R;e[3]!==t.username?(A=()=>{w(t.username??"")},R=[t.username],e[3]=t.username,e[4]=A,e[5]=R):(A=e[4],R=e[5]),y.useEffect(A,R);let P;e[6]!==t?(P=jI(t),e[6]=t,e[7]=P):P=e[7];const z=P,L=z!==void 0&&z!==oj;let I;e[8]!==t?(I=Mme(t),e[8]=t,e[9]=I):I=e[9];const M=I==="account",F=l<=9;let U;e[10]!==t.id||e[11]!==t.name||e[12]!==p||e[13]!==s?(U=async function(){const ye=p.trim();if(!ye||ye===t.name){m(!1),h(t.name);return}E("rename"),await s(t.id,ye),E(null),m(!1)},e[10]=t.id,e[11]=t.name,e[12]=p,e[13]=s,e[14]=U):U=e[14];const O=U;let D;e[15]!==v||e[16]!==b||e[17]!==t.auth||e[18]!==t.id||e[19]!==t.username||e[20]!==r?(D=async function(){const ye=b.trim(),Re=t.username??"",Ve=ye!==Re,He=v.length>0;if(!Ve&&!He){x(!1),j(""),_(null);return}if(t.auth==="none"&&!He){_("Enter a password when adding an account to an unauthenticated device.");return}const me={};Ve&&(me.username=ye||null),He&&(me.password=v),E("credentials"),_(null);const je=await r(t.id,me);if(E(null),!je.ok){_(je.error);return}x(!1),j("")},e[15]=v,e[16]=b,e[17]=t.auth,e[18]=t.id,e[19]=t.username,e[20]=r,e[21]=D):D=e[21];const B=D,q=u&&"relative z-10 shadow-lg";let W;e[22]!==q?(W=G("rounded-lg border bg-card",q),e[22]=q,e[23]=W):W=e[23];const H=`Reorder ${t.name}`;let K;e[24]===Symbol.for("react.memo_cache_sentinel")?(K=a.jsx(b8,{className:"size-4"}),e[24]=K):K=e[24];let Z;e[25]!==d||e[26]!==H?(Z=a.jsx("button",{type:"button","aria-label":H,title:"Drag to reorder (or use ↑ ↓)",className:"-ml-1 flex size-6 shrink-0 cursor-grab touch-none items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring active:cursor-grabbing",...d,children:K}),e[25]=d,e[26]=H,e[27]=Z):Z=e[27];let Y;e[28]!==F||e[29]!==l?(Y=F?`${Qi(`device.switch.${l}`)} opens this device`:"No shortcut",e[28]=F,e[29]=l,e[30]=Y):Y=e[30];const X=F&&l;let ee;e[31]!==Y||e[32]!==X?(ee=a.jsx("span",{className:"w-4 shrink-0 text-center font-mono text-xs text-muted-foreground",title:Y,children:X}),e[31]=Y,e[32]=X,e[33]=ee):ee=e[33];const te=`Status: ${t.runtime.authState}`,se=Hme[t.runtime.authState];let J;e[34]!==se?(J=G("size-2 shrink-0 rounded-full",se),e[34]=se,e[35]=J):J=e[35];let ne;e[36]!==te||e[37]!==J?(ne=a.jsx("span",{"aria-label":te,className:J}),e[36]=te,e[37]=J,e[38]=ne):ne=e[38];let ie;e[39]!==t.auth||e[40]!==t.name||e[41]!==f||e[42]!==p||e[43]!==O||e[44]!==L||e[45]!==z?(ie=f?a.jsx(On,{value:p,autoFocus:!0,"aria-label":`Rename ${t.name}`,onChange:We=>h(We.target.value),onKeyDown:We=>{We.key==="Enter"&&O(),We.key==="Escape"&&(m(!1),h(t.name))},onBlur:()=>void O(),className:"h-6 text-sm"}):a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:"truncate text-sm text-foreground",children:t.name}),z&&a.jsxs("span",{className:G("shrink-0 font-mono text-xs",L?"text-warning":"text-muted-foreground"),title:L?`Device runs v${z}; hub runs v${oj}`:void 0,children:["v",z,L&&" ≠ hub"]}),t.auth==="none"&&a.jsx(Fe,{variant:"secondary",children:"Unauthenticated"})]}),e[39]=t.auth,e[40]=t.name,e[41]=f,e[42]=p,e[43]=O,e[44]=L,e[45]=z,e[46]=ie):ie=e[46];const ae=t.tls?"https://":"";let oe;e[47]!==t.host||e[48]!==t.port||e[49]!==ae?(oe=a.jsxs("span",{className:"truncate font-mono text-xs text-muted-foreground",children:[ae,t.host,":",t.port]}),e[47]=t.host,e[48]=t.port,e[49]=ae,e[50]=oe):oe=e[50];let ue;e[51]!==M||e[52]!==t.username?(ue=t.username?a.jsxs("span",{className:"truncate text-xs text-muted-foreground",title:t.username,children:["Account: ",t.username]}):M?a.jsx("span",{className:"text-xs text-warning",children:"Account not configured"}):null,e[51]=M,e[52]=t.username,e[53]=ue):ue=e[53];let re;e[54]!==ie||e[55]!==oe||e[56]!==ue?(re=a.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[ie,oe,ue]}),e[54]=ie,e[55]=oe,e[56]=ue,e[57]=re):re=e[57];const de=`Re-test ${t.name}`,fe=C==="test";let le;e[58]!==t.id||e[59]!==i?(le=async()=>{E("test"),await i(t.id),E(null)},e[58]=t.id,e[59]=i,e[60]=le):le=e[60];const ce=C==="test"&&"animate-spin";let he;e[61]!==ce?(he=G(ce),e[61]=ce,e[62]=he):he=e[62];let ge;e[63]!==he?(ge=a.jsx(Fn,{"data-icon":"inline-start",className:he}),e[63]=he,e[64]=ge):ge=e[64];let be;e[65]!==de||e[66]!==fe||e[67]!==le||e[68]!==ge?(be=a.jsx(Q,{variant:"ghost",size:"icon-sm","aria-label":de,disabled:fe,onClick:le,children:ge}),e[65]=de,e[66]=fe,e[67]=le,e[68]=ge,e[69]=be):be=e[69];const ve=`Edit account for ${t.name}`;let Se;e[70]!==t.username?(Se=()=>{x(Gme),w(t.username??""),j(""),_(null)},e[70]=t.username,e[71]=Se):Se=e[71];let we;e[72]===Symbol.for("react.memo_cache_sentinel")?(we=a.jsx(v8,{"data-icon":"inline-start"}),e[72]=we):we=e[72];let Ee;e[73]!==ve||e[74]!==Se?(Ee=a.jsx(Q,{variant:"ghost",size:"icon-sm","aria-label":ve,onClick:Se,children:we}),e[73]=ve,e[74]=Se,e[75]=Ee):Ee=e[75];const $e=`Rename ${t.name}`;let Be,qe;e[76]===Symbol.for("react.memo_cache_sentinel")?(Be=()=>m(!0),qe=a.jsx(yr,{"data-icon":"inline-start"}),e[76]=Be,e[77]=qe):(Be=e[76],qe=e[77]);let ze;e[78]!==$e?(ze=a.jsx(Q,{variant:"ghost",size:"icon-sm","aria-label":$e,onClick:Be,children:qe}),e[78]=$e,e[79]=ze):ze=e[79];const Ie=`Remove ${t.name}`;let Me;e[80]===Symbol.for("react.memo_cache_sentinel")?(Me=a.jsx(kf,{"data-icon":"inline-start"}),e[80]=Me):Me=e[80];let Ue;e[81]!==Ie?(Ue=a.jsx(Q,{variant:"ghost",size:"icon-sm","aria-label":Ie,className:"text-destructive hover:bg-destructive/10 hover:text-destructive",children:Me}),e[81]=Ie,e[82]=Ue):Ue=e[82];let De;e[83]!==t.name?(De=a.jsxs(a.Fragment,{children:["Remove ",t.name,"?"]}),e[83]=t.name,e[84]=De):De=e[84];let Ke;e[85]!==t.id||e[86]!==o?(Ke=async()=>(await o(t.id),null),e[85]=t.id,e[86]=o,e[87]=Ke):Ke=e[87];let Ne;e[88]!==N||e[89]!==Ue||e[90]!==De||e[91]!==Ke?(Ne=a.jsx($me,{open:N,onOpenChange:S,trigger:Ue,title:De,description:"This device will disappear from Cogpit. You can add it again later.",confirmLabel:"Remove device",destructive:!0,onConfirm:Ke}),e[88]=N,e[89]=Ue,e[90]=De,e[91]=Ke,e[92]=Ne):Ne=e[92];let Ae;e[93]!==be||e[94]!==Ee||e[95]!==ze||e[96]!==Ne?(Ae=a.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[be,Ee,ze,Ne]}),e[93]=be,e[94]=Ee,e[95]=ze,e[96]=Ne,e[97]=Ae):Ae=e[97];let Qe;e[98]!==Z||e[99]!==ee||e[100]!==ne||e[101]!==re||e[102]!==Ae?(Qe=a.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2",children:[Z,ee,ne,re,Ae]}),e[98]=Z,e[99]=ee,e[100]=ne,e[101]=re,e[102]=Ae,e[103]=Qe):Qe=e[103];let Je;e[104]!==C||e[105]!==k||e[106]!==v||e[107]!==b||e[108]!==t.id||e[109]!==t.name||e[110]!==t.username||e[111]!==g||e[112]!==B?(Je=g&&a.jsxs(Rme,{error:k,busy:C==="credentials",saveLabel:"Save account",onCancel:()=>{x(!1),w(t.username??""),j(""),_(null)},onSave:()=>void B(),children:[a.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[a.jsxs(fn,{children:[a.jsxs(mn,{htmlFor:`device-username-${t.id}`,children:["Username ",a.jsx("span",{className:"text-muted-foreground/60",children:"(account sign-in)"})]}),a.jsx(On,{id:`device-username-${t.id}`,"aria-label":`Username for ${t.name}`,value:b,onChange:We=>w(We.target.value),placeholder:"Leave empty for password-only auth",autoComplete:"off",spellCheck:!1})]}),a.jsxs(fn,{children:[a.jsxs(mn,{htmlFor:`device-password-${t.id}`,children:["New password ",a.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),a.jsx(On,{id:`device-password-${t.id}`,"aria-label":`New password for ${t.name}`,type:"password",value:v,onChange:We=>j(We.target.value),placeholder:"Leave blank to keep the stored password",autoComplete:"new-password"})]})]}),t.username&&b.trim()===""&&a.jsx("p",{className:"text-xs text-warning",children:"Clearing the username switches this device back to password-only authentication."})]}),e[104]=C,e[105]=k,e[106]=v,e[107]=b,e[108]=t.id,e[109]=t.name,e[110]=t.username,e[111]=g,e[112]=B,e[113]=Je):Je=e[113];let ke;return e[114]!==c||e[115]!==W||e[116]!==Qe||e[117]!==Je?(ke=a.jsxs("div",{ref:c,className:W,children:[Qe,Je]}),e[114]=c,e[115]=W,e[116]=Qe,e[117]=Je,e[118]=ke):ke=e[118],ke}function Gme(n){return!n}function CI(n){var dt,zt;const e=V.c(121),{open:t,initialMode:s,onClose:r}=n,{devices:o,refresh:i,probe:l,addDevice:c,updateDevice:u,removeDevice:d,reorderDevices:f,testDevice:m}=Fa(),[p,h]=y.useState(""),[g,x]=y.useState(""),[b,w]=y.useState(""),[v,j]=y.useState(""),[k,_]=y.useState(!1),[N,S]=y.useState(!1),[C,E]=y.useState(null),[T,$]=y.useState(!1),[A,R]=y.useState(null),P=y.useRef(null),z=y.useRef(0);let L,I;e[0]!==s||e[1]!==t?(L=()=>{t&&(h(""),x(""),w(""),j(""),_(!1),S(!1),E(null),R(null),s==="add"&&requestAnimationFrame(()=>{var st;return(st=P.current)==null?void 0:st.focus()}))},I=[t,s],e[0]=s,e[1]=t,e[2]=L,e[3]=I):(L=e[2],I=e[3]),y.useEffect(L,I);let M;e[4]!==k||e[5]!==g||e[6]!==l?(M=async()=>{const{host:st,port:Et,tls:Tt}=qu(g);if(!st){E(null),S(!1);return}const Jt=z.current=z.current+1;S(!0);const At=await l(st,Et,k,Tt);Jt===z.current&&(E({...qme(At,st,Et??(Tt?Dme:zme)),hello:At.ok?At.hello:void 0}),S(!1))},e[4]=k,e[5]=g,e[6]=l,e[7]=M):M=e[7];const F=M;let U,O;e[8]!==g||e[9]!==t||e[10]!==F?(U=()=>{if(!t)return;if(!qu(g).host){E(null),S(!1);return}const st=window.setTimeout(()=>void F(),Fme);return()=>window.clearTimeout(st)},O=[t,g,F],e[8]=g,e[9]=t,e[10]=F,e[11]=U,e[12]=O):(U=e[11],O=e[12]),y.useEffect(U,O);const D=((dt=C==null?void 0:C.hello)==null?void 0:dt.signIn)==="account",B=D&&((zt=C==null?void 0:C.hello)==null?void 0:zt.setupRequired)===!0,q=D||!k;let W;e:{if(T){W=!1;break e}if(!qu(g).host){W=!1;break e}if(N||!C){W=!1;break e}if(B){W=!1;break e}if(q&&!v){W=!1;break e}if(D&&!b.trim()){W=!1;break e}if((C==null?void 0:C.tone)==="error"){W=!1;break e}W=!0}const H=W;let K;e[13]!==c||e[14]!==k||e[15]!==q||e[16]!==g||e[17]!==p||e[18]!==r||e[19]!==v||e[20]!==D||e[21]!==b?(K=async function(){const{host:Et,port:Tt,tls:Jt}=qu(g);if(!Et)return;$(!0),R(null);const At=await c({name:p.trim()||void 0,host:Et,port:Tt,tls:Jt,username:D?b.trim():void 0,password:q&&v||void 0,allowLocalTunnel:k});if($(!1),At.ok){r(),Xs(At.device.id);return}R({field:Wme.has(At.code)?"username":Bme.has(At.code)?"password":"host",message:At.error})},e[13]=c,e[14]=k,e[15]=q,e[16]=g,e[17]=p,e[18]=r,e[19]=v,e[20]=D,e[21]=b,e[22]=K):K=e[22];const Z=K;let Y;e[23]!==u?(Y=async(st,Et)=>{await u(st,{name:Et})},e[23]=u,e[24]=Y):Y=e[24];const X=Y;let ee;e[25]!==d?(ee=async st=>{await d(st)},e[25]=d,e[26]=ee):ee=e[26];const te=ee;let se;e[27]!==o?(se=o.map(Zme),e[27]=o,e[28]=se):se=e[28];const{order:J,draggingId:ne,rowRef:ie,handleProps:ae}=Lme(se,f);let oe;e[29]!==i||e[30]!==m?(oe=async st=>{await m(st),await i()},e[29]=i,e[30]=m,e[31]=oe):oe=e[31];const ue=oe;let re;e[32]!==r?(re=st=>{st||r()},e[32]=r,e[33]=re):re=e[33];let de;e[34]===Symbol.for("react.memo_cache_sentinel")?(de=a.jsxs(io,{children:[a.jsx(rr,{children:"Devices"}),a.jsxs(or,{children:["Control another Cogpit device from here. The active device is chosen from the header switcher — ",Ume," jumps between devices. Drag a device by its handle to change its number; this machine is always 1."]})]}),e[34]=de):de=e[34];let fe;e[35]!==o||e[36]!==ne||e[37]!==ae||e[38]!==te||e[39]!==X||e[40]!==ue||e[41]!==J||e[42]!==ie||e[43]!==u?(fe=o.length>0&&a.jsx("div",{className:"flex flex-col gap-2",children:J.map((st,Et)=>{const Tt=o.find(Jt=>Jt.id===st);return Tt?a.jsx(Kme,{device:Tt,slot:Et+2,rowRef:ie(Tt.id),dragging:ne===Tt.id,dragHandleProps:ae(Tt.id),onRename:X,onCredentials:u,onRemove:te,onTest:ue},Tt.id):null})}),e[35]=o,e[36]=ne,e[37]=ae,e[38]=te,e[39]=X,e[40]=ue,e[41]=J,e[42]=ie,e[43]=u,e[44]=fe):fe=e[44];let le;e[45]===Symbol.for("react.memo_cache_sentinel")?(le=a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Sr,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),a.jsx("p",{className:"text-sm font-medium text-foreground",children:"Add a device"})]}),e[45]=le):le=e[45];const ce=(A==null?void 0:A.field)==="host";let he,ge;e[46]===Symbol.for("react.memo_cache_sentinel")?(he=a.jsx(mn,{htmlFor:"device-host",children:"Host"}),ge=a.jsx(ia,{children:"Enter a local address or an HTTPS URL."}),e[46]=he,e[47]=ge):(he=e[46],ge=e[47]);let be;e[48]===Symbol.for("react.memo_cache_sentinel")?(be=st=>{z.current=z.current+1,x(st.target.value),w(""),E(null),R(null)},e[48]=be):be=e[48];let ve;e[49]!==F?(ve=()=>void F(),e[49]=F,e[50]=ve):ve=e[50];let Se;e[51]!==g||e[52]!==ve?(Se=a.jsx(On,{id:"device-host",ref:P,value:g,onChange:be,onBlur:ve,placeholder:"192.168.1.42, my-mac.local:19384 or https://cogpit.example.com",spellCheck:!1,autoComplete:"off"}),e[51]=g,e[52]=ve,e[53]=Se):Se=e[53];let we;e[54]!==N?(we=N&&a.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[a.jsx(St,{"data-icon":"inline-start",className:"size-3.5 animate-spin"})," Checking device…"]}),e[54]=N,e[55]=we):we=e[55];let Ee;e[56]!==C||e[57]!==N?(Ee=!N&&C&&a.jsxs("p",{role:"status",className:G("flex items-center gap-1.5 text-xs",NI[C.tone]),children:[a.jsx(Vme,{tone:C.tone}),C.text]}),e[56]=C,e[57]=N,e[58]=Ee):Ee=e[58];let $e;e[59]!==A?($e=(A==null?void 0:A.field)==="host"&&a.jsx(_o,{children:A.message}),e[59]=A,e[60]=$e):$e=e[60];let Be;e[61]!==ce||e[62]!==Se||e[63]!==we||e[64]!==Ee||e[65]!==$e?(Be=a.jsxs(fn,{"data-invalid":ce,children:[he,ge,Se,we,Ee,$e]}),e[61]=ce,e[62]=Se,e[63]=we,e[64]=Ee,e[65]=$e,e[66]=Be):Be=e[66];let qe;e[67]===Symbol.for("react.memo_cache_sentinel")?(qe=a.jsxs(mn,{htmlFor:"device-name",children:["Name ",a.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),e[67]=qe):qe=e[67];let ze;e[68]===Symbol.for("react.memo_cache_sentinel")?(ze=st=>h(st.target.value),e[68]=ze):ze=e[68];let Ie;e[69]!==p?(Ie=a.jsxs(fn,{children:[qe,a.jsx(On,{id:"device-name",value:p,onChange:ze,placeholder:"Defaults to the device's own name"})]}),e[69]=p,e[70]=Ie):Ie=e[70];let Me;e[71]!==A||e[72]!==D||e[73]!==b?(Me=D&&a.jsxs(fn,{"data-invalid":(A==null?void 0:A.field)==="username",children:[a.jsx(mn,{htmlFor:"device-username",children:"Username"}),a.jsx(On,{id:"device-username",value:b,onChange:st=>w(st.target.value),placeholder:"Account username",autoComplete:"username",spellCheck:!1}),a.jsx(ia,{children:"Requests through this hub act as this account on that server."}),(A==null?void 0:A.field)==="username"&&a.jsx(_o,{children:A.message})]}),e[71]=A,e[72]=D,e[73]=b,e[74]=Me):Me=e[74];let Ue;e[75]!==q||e[76]!==v||e[77]!==A||e[78]!==D?(Ue=q&&a.jsxs(fn,{"data-invalid":(A==null?void 0:A.field)==="password",children:[a.jsx(mn,{htmlFor:"device-password",children:"Password"}),a.jsx(On,{id:"device-password",type:"password",value:v,onChange:st=>j(st.target.value),placeholder:D?"Password for that account":"Network access password for that device",autoComplete:D?"current-password":"off"}),(A==null?void 0:A.field)==="password"&&a.jsx(_o,{children:A.message})]}),e[75]=q,e[76]=v,e[77]=A,e[78]=D,e[79]=Ue):Ue=e[79];let De;e[80]!==Be||e[81]!==Ie||e[82]!==Me||e[83]!==Ue?(De=a.jsxs(Ta,{children:[Be,Ie,Me,Ue]}),e[80]=Be,e[81]=Ie,e[82]=Me,e[83]=Ue,e[84]=De):De=e[84];let Ke;e[85]===Symbol.for("react.memo_cache_sentinel")?(Ke=st=>{z.current=z.current+1,_(st===!0),E(null),R(null)},e[85]=Ke):Ke=e[85];let Ne;e[86]!==k?(Ne=a.jsx(uT,{id:"device-local-tunnel",name:"device-local-tunnel",checked:k,onCheckedChange:Ke}),e[86]=k,e[87]=Ne):Ne=e[87];const Ae=D?"":" — no password";let Qe;e[88]!==Ae?(Qe=a.jsxs(mn,{htmlFor:"device-local-tunnel",children:["This is a local tunnel",Ae]}),e[88]=Ae,e[89]=Qe):Qe=e[89];let Je;e[90]!==Ne||e[91]!==Qe?(Je=a.jsxs(fn,{orientation:"horizontal",children:[Ne,Qe]}),e[90]=Ne,e[91]=Qe,e[92]=Je):Je=e[92];let ke;e[93]!==k||e[94]!==D?(ke=k&&a.jsxs(jt,{className:"border-warning/40 bg-warning/10 text-warning",children:[a.jsx(ix,{}),a.jsx(Rt,{className:"text-warning",children:D?a.jsx(a.Fragment,{children:"The loopback address is allowed because the tunnel is local; account sign-in still applies."}):a.jsxs(a.Fragment,{children:["Traffic to this device is forwarded ",a.jsx("strong",{children:"unauthenticated"}),". Only use this for an SSH tunnel or another already-secured local channel."]})})]}),e[93]=k,e[94]=D,e[95]=ke):ke=e[95];let We;e[96]!==r?(We=a.jsx(Q,{variant:"outline",onClick:r,children:"Close"}),e[96]=r,e[97]=We):We=e[97];const ye=!H;let Re;e[98]!==Z?(Re=()=>void Z(),e[98]=Z,e[99]=Re):Re=e[99];let Ve;e[100]!==T?(Ve=T?a.jsxs(a.Fragment,{children:[a.jsx(St,{"data-icon":"inline-start",className:"size-4 animate-spin"})," Adding…"]}):"Add device",e[100]=T,e[101]=Ve):Ve=e[101];let He;e[102]!==ye||e[103]!==Re||e[104]!==Ve?(He=a.jsx(Q,{disabled:ye,onClick:Re,children:Ve}),e[102]=ye,e[103]=Re,e[104]=Ve,e[105]=He):He=e[105];let me;e[106]!==We||e[107]!==He?(me=a.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[We,He]}),e[106]=We,e[107]=He,e[108]=me):me=e[108];let je;e[109]!==De||e[110]!==Je||e[111]!==ke||e[112]!==me?(je=a.jsxs("div",{className:"flex flex-col gap-4 border-t pt-4",children:[le,De,Je,ke,me]}),e[109]=De,e[110]=Je,e[111]=ke,e[112]=me,e[113]=je):je=e[113];let Xe;e[114]!==fe||e[115]!==je?(Xe=a.jsxs(sr,{className:"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-xl",children:[de,fe,je]}),e[114]=fe,e[115]=je,e[116]=Xe):Xe=e[116];let tt;return e[117]!==t||e[118]!==re||e[119]!==Xe?(tt=a.jsx(nr,{open:t,onOpenChange:re,children:Xe}),e[117]=t,e[118]=re,e[119]=Xe,e[120]=tt):tt=e[120],tt}function Zme(n){return n.id}const Yme="Browsing folders needs a newer Cogpit on this machine.";async function _I(n){const e=await Tl(n,`Request failed (${n.status})`);return new Error(n.status===404&&e==="Not found"?Yme:e)}async function Xme(n,e){const t=await Ce(n?`/api/folders?path=${encodeURIComponent(n)}`:"/api/folders",{signal:e});if(!t.ok)throw await _I(t);return await t.json()}async function Jme(n,e){const t=await is("/api/folders",{parent:n,name:e});if(!t.ok)throw await _I(t);return(await t.json()).path}function Qme(n,e=null){const t=epe(n);if(e===null)return t;const s=o=>o.replace(/[\\/]+$/,""),r=t.findIndex(o=>s(o.path)===s(e));return r===-1?t:t.slice(r)}function epe(n){const e=n.split(/[\\/]+/).filter(Boolean);let t,s,r;if(n.startsWith("\\\\")){const[o="",i="",...l]=e;t={label:`\\\\${o}\\${i}`,path:`\\\\${o}\\${i}\\`},s=l,r="\\"}else if(/^[a-z]:/i.test(n)){const[o="",...i]=e;t={label:o,path:`${o}\\`},s=i,r="\\"}else t={label:"/",path:"/"},s=e,r="/";return[t,...s.map((o,i)=>({label:o,path:t.path+s.slice(0,i+1).join(r)}))]}const z1="cogpit-browse-folders";function EI(){window.dispatchEvent(new Event(z1))}function tpe(n){return window.addEventListener(z1,n),()=>window.removeEventListener(z1,n)}const npe=y.lazy(()=>nt(()=>import("./ProjectSwitcherModal-Ph5R0C2t.js"),__vite__mapDeps([25,1,2,3,4])).then(n=>({default:n.ProjectSwitcherModal})));function TI(n){const e=V.c(8),{onNewSession:t,onNewFolder:s,defaultAgentKind:r}=n,[o,i]=y.useState(null);let l,c;if(e[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>tpe(()=>i(!0)),c=[],e[0]=l,e[1]=c):(l=e[0],c=e[1]),y.useEffect(l,c),o===null)return null;let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>i(!1),e[2]=u):u=e[2];let d;return e[3]!==r||e[4]!==s||e[5]!==t||e[6]!==o?(d=a.jsx(y.Suspense,{fallback:null,children:a.jsx(npe,{open:o,onClose:u,onNewSession:t,onNewFolder:s,defaultAgentKind:r,currentProjectDirName:null,currentProjectCwd:null,initialView:"folders"})}),e[3]=r,e[4]=s,e[5]=t,e[6]=o,e[7]=d):d=e[7],d}const spe=/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/;function ij(n,e){if(!spe.test(e))throw new Error(`Invalid Cogpit ${n} id "${e}"`)}function xo(n,e){return`${n}.${e}`}function rpe(n){const e=new Set,t=new Set,s=[];for(const r of n){if(ij("plugin",r.id),e.has(r.id))throw new Error(`Duplicate Cogpit plugin id "${r.id}"`);e.add(r.id);for(const o of r.workspacePanels??[]){ij("panel",o.id);const i=xo(r.id,o.id);if(t.has(i))throw new Error(`Duplicate Cogpit workspace panel id "${i}"`);t.add(i),s.push({...o,id:i,pluginId:r.id,localId:o.id})}}return s.sort((r,o)=>(r.order??100)-(o.order??100)||r.title.localeCompare(o.title))}function Gn({className:n,...e}){return a.jsx("div",{"data-slot":"skeleton",className:G("rounded-md bg-muted motion-safe:animate-in motion-safe:fade-in-0 motion-safe:duration-200 motion-safe:ease-out motion-reduce:animate-none",n),...e})}const ii="cogpit",Ot={worktrees:xo(ii,"worktrees"),projectFiles:xo(ii,"project-files"),browser:xo(ii,"browser"),fileChanges:xo(ii,"file-changes"),sessionInfo:xo(ii,"session-info"),crew:xo(ii,"crew")},ope=y.lazy(()=>nt(()=>import("./CommandPaletteHost-BgKoDHcE.js"),__vite__mapDeps([26,1,2,3,4])).then(n=>({default:n.CommandPaletteHost}))),ipe=y.lazy(()=>nt(()=>import("./index-vyOkk7K_.js"),__vite__mapDeps([27,1,28,2,29,3,4])).then(n=>({default:n.ConfigDialog}))),ape=y.lazy(()=>nt(()=>import("./KeyboardShortcutsDialog-CUUxScBc.js"),__vite__mapDeps([30,1,2,3,4])).then(n=>({default:n.KeyboardShortcutsDialog}))),lpe=y.lazy(()=>nt(()=>import("./ProjectSwitcherModal-Ph5R0C2t.js"),__vite__mapDeps([25,1,2,3,4])).then(n=>({default:n.ProjectSwitcherModal}))),cpe=y.lazy(()=>nt(()=>import("./ThemeSelectorModal-DB69FVzW.js"),__vite__mapDeps([31,1,2,3,4])).then(n=>({default:n.ThemeSelectorModal})));function upe(n){const e=V.c(131),{navigation:t,project:s,chrome:r}=n,{state:o,config:i,theme:l}=Sn(),{session:c,sessionSource:u}=kt(),{devices:d,activeDeviceId:f}=Fa(),[m,p]=y.useState(null);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=xt("manageDevices"),e[0]=h):h=e[0];const g=h,x=qx(),b=o.mainView==="extension"?o.extensionViewId:null;let w;e[1]!==o.pendingCwd||e[2]!==o.pendingDirName?(w=o.pendingCwd??(o.pendingDirName?xs(o.pendingDirName):null),e[1]=o.pendingCwd,e[2]=o.pendingDirName,e[3]=w):w=e[3];const v=w,j=(u==null?void 0:u.dirName)??o.pendingDirName??o.dashboardProject??null,k=r.onKeyboardShortcutsOpenChange;let _,N;e[4]!==k?(_=()=>{const me=function(Xe){on("keyboardShortcuts",Xe)&&(wI(document.activeElement)||(Xe.preventDefault(),k(!0)))};return window.addEventListener("keydown",me),()=>window.removeEventListener("keydown",me)},N=[k],e[4]=k,e[5]=_,e[6]=N):(_=e[5],N=e[6]),y.useEffect(_,N);const S=f===Lt;let C;e[7]!==S?(C={id:Lt,name:"This machine",isLocal:!0,isActive:S},e[7]=S,e[8]=C):C=e[8];let E;if(e[9]!==f||e[10]!==d||e[11]!==C){let me;e[13]!==f?(me=je=>({id:je.id,name:je.name,isLocal:!1,isActive:je.id===f}),e[13]=f,e[14]=me):me=e[14],E=[C,...d.map(me)],e[9]=f,e[10]=d,e[11]=C,e[12]=E}else E=e[12];const T=E,{openMainView:$,closeMainView:A}=t.panels;let R;if(e[15]!==A||e[16]!==x||e[17]!==$||e[18]!==b){let me;e[20]!==A||e[21]!==$||e[22]!==b?(me=je=>{const Xe=je.id===b;return{id:`main-view-${je.id}`,label:`${Xe?"Close":"Open"} ${je.label}`,keywords:je.keywords,icon:je.icon,onSelect:Xe?A:()=>$(je.id)}},e[20]=A,e[21]=$,e[22]=b,e[23]=me):me=e[23],R=x.map(me),e[15]=A,e[16]=x,e[17]=$,e[18]=b,e[19]=R}else R=e[19];const P=R;let z;e[24]!==c||e[25]!==(u==null?void 0:u.agentKind)||e[26]!==(u==null?void 0:u.dirName)?(z=()=>{if(!c)return;const me=(u==null?void 0:u.agentKind)??un((u==null?void 0:u.dirName)??null);Pf(jx(me,c.sessionId,c.cwd))},e[24]=c,e[25]=u==null?void 0:u.agentKind,e[26]=u==null?void 0:u.dirName,e[27]=z):z=e[27];const L=z,I=dpe,M=r.processPanel,F=r.workflowsPanel,U=r.undoDialog,O=r.branchModal,D=i.claudeDir??"";let B;e[28]!==i.handleCloseConfigDialog||e[29]!==i.handleConfigSaved||e[30]!==i.showConfigDialog||e[31]!==D?(B=a.jsx(y.Suspense,{fallback:null,children:a.jsx(ipe,{open:i.showConfigDialog,currentPath:D,onClose:i.handleCloseConfigDialog,onSaved:i.handleConfigSaved})}),e[28]=i.handleCloseConfigDialog,e[29]=i.handleConfigSaved,e[30]=i.showConfigDialog,e[31]=D,e[32]=B):B=e[32];const q=(u==null?void 0:u.dirName)??o.pendingDirName??null,W=(c==null?void 0:c.cwd)??o.pendingCwd??null;let H;e[33]!==i.defaultAgentKind||e[34]!==t.onStartNewFolder||e[35]!==t.onStartNewSession||e[36]!==t.panels.handleCloseProjectSwitcher||e[37]!==t.panels.showProjectSwitcher||e[38]!==q||e[39]!==W?(H=a.jsx(y.Suspense,{fallback:null,children:a.jsx(lpe,{open:t.panels.showProjectSwitcher,onClose:t.panels.handleCloseProjectSwitcher,onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:i.defaultAgentKind,currentProjectDirName:q,currentProjectCwd:W})}),e[33]=i.defaultAgentKind,e[34]=t.onStartNewFolder,e[35]=t.onStartNewSession,e[36]=t.panels.handleCloseProjectSwitcher,e[37]=t.panels.showProjectSwitcher,e[38]=q,e[39]=W,e[40]=H):H=e[40];let K;e[41]!==i.defaultAgentKind||e[42]!==t.onStartNewFolder||e[43]!==t.onStartNewSession?(K=a.jsx(TI,{onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:i.defaultAgentKind}),e[41]=i.defaultAgentKind,e[42]=t.onStartNewFolder,e[43]=t.onStartNewSession,e[44]=K):K=e[44];let Z;e[45]!==t.panels.handleCloseThemeSelector||e[46]!==t.panels.showThemeSelector||e[47]!==l.setPreview||e[48]!==l.setTheme||e[49]!==l.theme?(Z=a.jsx(y.Suspense,{fallback:null,children:a.jsx(cpe,{open:t.panels.showThemeSelector,onClose:t.panels.handleCloseThemeSelector,currentTheme:l.theme,onSelectTheme:l.setTheme,onPreviewTheme:l.setPreview})}),e[45]=t.panels.handleCloseThemeSelector,e[46]=t.panels.showThemeSelector,e[47]=l.setPreview,e[48]=l.setTheme,e[49]=l.theme,e[50]=Z):Z=e[50];const Y=r.commandPaletteOpen,X=r.onCommandPaletteOpenChange,ee=t.actions.handleGoHome,te=t.panels.handleOpenProjectSwitcher,se=t.onOpenPaletteProject,J=t.actions.handleDashboardSelect,ne=t.panels.handleToggleSidebar;let ie,ae,oe;e[51]!==t.panels?(ie=()=>t.panels.toggleWorkspacePanel(Ot.sessionInfo),ae=()=>t.panels.toggleWorkspacePanel(Ot.fileChanges),oe=()=>t.panels.toggleWorkspacePanel(Ot.worktrees),e[51]=t.panels,e[52]=ie,e[53]=ae,e[54]=oe):(ie=e[52],ae=e[53],oe=e[54]);const ue=t.panels.handleToggleMission,re=c?t.handlers.handleDuplicateSession:void 0,de=c?L:void 0,fe=c?I:void 0,le=xt("killAny")?r.onKillAll:void 0,ce=xt("configWrite")?t.panels.handleToggleConfig:void 0,he=i.openConfigDialog;let ge;e[55]!==k?(ge=()=>k(!0),e[55]=k,e[56]=ge):ge=e[56];const be=s.currentCwd?s.onTogglePreview:void 0,ve=xt("hostFiles")&&s.currentCwd?s.onToggleProjectFiles:void 0;let Se;e[57]!==t.panels?(Se=xt("browser")?()=>t.panels.toggleWorkspacePanel(Ot.browser):void 0,e[57]=t.panels,e[58]=Se):Se=e[58];const we=t.panels.handleToggleThemeSelector,Ee=s.onOpenTerminal,$e=r.onFocusComposer,Be=r.onExpandAll,qe=r.onExpandToolPayloads,ze=r.onCollapseAll,Ie=!!(c||o.pendingDirName);let Me;e[59]!==v||e[60]!==(c==null?void 0:c.cwd)||e[61]!==(u==null?void 0:u.dirName)||e[62]!==o.dashboardProject||e[63]!==o.pendingDirName?(Me=xt("terminal")&&!!((c==null?void 0:c.cwd)??v??(u==null?void 0:u.dirName)??o.pendingDirName??o.dashboardProject),e[59]=v,e[60]=c==null?void 0:c.cwd,e[61]=u==null?void 0:u.dirName,e[62]=o.dashboardProject,e[63]=o.pendingDirName,e[64]=Me):Me=e[64];const Ue=!!c;let De;e[65]!==s.hasFileChanges?(De=xt("hostFiles")&&s.hasFileChanges,e[65]=s.hasFileChanges,e[66]=De):De=e[66];const Ke=t.panels.activeWorkspacePanel===Ot.sessionInfo,Ne=t.panels.activeWorkspacePanel===Ot.browser,Ae=t.panels.activeWorkspacePanel===Ot.fileChanges,Qe=t.panels.activeWorkspacePanel===Ot.worktrees,Je=o.mainView==="config",ke=o.mainView==="mission",We=(c==null?void 0:c.cwd)??v??null;let ye;e[67]!==r.commandPaletteOpen||e[68]!==r.onCollapseAll||e[69]!==r.onCommandPaletteOpenChange||e[70]!==r.onExpandAll||e[71]!==r.onExpandToolPayloads||e[72]!==r.onFocusComposer||e[73]!==i.openConfigDialog||e[74]!==j||e[75]!==P||e[76]!==t.actions.handleDashboardSelect||e[77]!==t.actions.handleGoHome||e[78]!==t.onOpenPaletteProject||e[79]!==t.panels.handleOpenProjectSwitcher||e[80]!==t.panels.handleToggleMission||e[81]!==t.panels.handleToggleSidebar||e[82]!==t.panels.handleToggleThemeSelector||e[83]!==t.panels.showSidebar||e[84]!==T||e[85]!==s.launchTerminalRequest||e[86]!==s.onOpenTerminal||e[87]!==s.processPanel.addProcess||e[88]!==s.showProjectFiles||e[89]!==s.supportsWorktrees||e[90]!==ie||e[91]!==ae||e[92]!==oe||e[93]!==re||e[94]!==de||e[95]!==fe||e[96]!==le||e[97]!==ce||e[98]!==ge||e[99]!==be||e[100]!==ve||e[101]!==Se||e[102]!==Ie||e[103]!==Me||e[104]!==Ue||e[105]!==De||e[106]!==Ke||e[107]!==Ne||e[108]!==Ae||e[109]!==Qe||e[110]!==Je||e[111]!==ke||e[112]!==We?(ye=a.jsx(y.Suspense,{fallback:null,children:a.jsx(ope,{open:Y,onOpenChange:X,onGoHome:ee,onNewSession:te,onOpenProject:se,onOpenSession:J,onToggleSidebar:ne,onToggleStats:ie,onToggleFileChanges:ae,onToggleWorktrees:oe,onToggleMissionControl:ue,extraActions:P,onDuplicateSession:re,onCopyResumeCommand:de,onFindInConversation:fe,onKillAll:le,onOpenConfig:ce,onOpenSettings:he,onOpenKeyboardShortcuts:ge,onTogglePreview:be,onToggleProjectFiles:ve,onToggleBrowser:Se,onOpenTheme:we,onOpenTerminal:Ee,onOpenDevices:g?p:void 0,onSwitchDevice:Xs,devices:T,onFocusComposer:$e,onExpandAll:Be,onExpandToolPayloads:qe,onCollapseAll:ze,canFocusComposer:Ie,canOpenTerminal:Me,hasSession:Ue,hasFileChanges:De,supportsWorktrees:s.supportsWorktrees,showSidebar:t.panels.showSidebar,showStats:Ke,showProjectFiles:s.showProjectFiles,showBrowser:Ne,showFileChanges:Ae,showWorktrees:Qe,showConfig:Je,showMission:ke,currentProjectDirName:j,projectCwd:We,onProcessStarted:s.processPanel.addProcess,launchTerminalRequest:s.launchTerminalRequest})}),e[67]=r.commandPaletteOpen,e[68]=r.onCollapseAll,e[69]=r.onCommandPaletteOpenChange,e[70]=r.onExpandAll,e[71]=r.onExpandToolPayloads,e[72]=r.onFocusComposer,e[73]=i.openConfigDialog,e[74]=j,e[75]=P,e[76]=t.actions.handleDashboardSelect,e[77]=t.actions.handleGoHome,e[78]=t.onOpenPaletteProject,e[79]=t.panels.handleOpenProjectSwitcher,e[80]=t.panels.handleToggleMission,e[81]=t.panels.handleToggleSidebar,e[82]=t.panels.handleToggleThemeSelector,e[83]=t.panels.showSidebar,e[84]=T,e[85]=s.launchTerminalRequest,e[86]=s.onOpenTerminal,e[87]=s.processPanel.addProcess,e[88]=s.showProjectFiles,e[89]=s.supportsWorktrees,e[90]=ie,e[91]=ae,e[92]=oe,e[93]=re,e[94]=de,e[95]=fe,e[96]=le,e[97]=ce,e[98]=ge,e[99]=be,e[100]=ve,e[101]=Se,e[102]=Ie,e[103]=Me,e[104]=Ue,e[105]=De,e[106]=Ke,e[107]=Ne,e[108]=Ae,e[109]=Qe,e[110]=Je,e[111]=ke,e[112]=We,e[113]=ye):ye=e[113];let Re;e[114]!==r.keyboardShortcutsOpen||e[115]!==k?(Re=a.jsx(y.Suspense,{fallback:null,children:a.jsx(ape,{open:r.keyboardShortcutsOpen,onOpenChange:k})}),e[114]=r.keyboardShortcutsOpen,e[115]=k,e[116]=Re):Re=e[116];let Ve;e[117]!==m?(Ve=g&&a.jsx(CI,{open:m!==null,initialMode:m??"manage",onClose:()=>p(null)}),e[117]=m,e[118]=Ve):Ve=e[118];let He;return e[119]!==r.branchModal||e[120]!==r.processPanel||e[121]!==r.undoDialog||e[122]!==r.workflowsPanel||e[123]!==B||e[124]!==H||e[125]!==K||e[126]!==Z||e[127]!==ye||e[128]!==Re||e[129]!==Ve?(He=a.jsxs(a.Fragment,{children:[M,F,U,O,B,H,K,Z,ye,Re,Ve]}),e[119]=r.branchModal,e[120]=r.processPanel,e[121]=r.undoDialog,e[122]=r.workflowsPanel,e[123]=B,e[124]=H,e[125]=K,e[126]=Z,e[127]=ye,e[128]=Re,e[129]=Ve,e[130]=He):He=e[130],He}function dpe(){window.dispatchEvent(new Event(O1))}const AI={"github.repository":"cogpit.github.repository","clickup.tasks":"cogpit.clickup.tasks","vercel-deployments.deployments":"cogpit.vercel.deployments"};function aj(n){return n===null?null:AI[n]??n}function II(n,e){return n?e.find(t=>t.id===n)??e.find(t=>t.id===AI[n])??null:null}async function PI(n,e,t){return(await is(`/api/permissions/${encodeURIComponent(n)}/respond`,{requestId:e,behavior:t})).ok}async function fpe(n,e){return(await is(`/api/permissions/${encodeURIComponent(n)}/respond-all`,{behavior:e})).ok}function mpe(n,e,t){return GE("/api/elicitation-answer",{sessionId:n,requestId:e,...t})}function ppe(n,e,t){return GE("/api/user-dialog-answer",{sessionId:n,requestId:e,choice:t})}const hpe=3e3,Gb=y.createContext(null);async function Jh(n){try{const e=await Ce(n);return e.ok?await e.text():void 0}catch{return}}function Qh(n,e){if(!(n===void 0||n===e.current))try{const t=JSON.parse(n);return e.current=n,t}catch{return}}function el(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 Vu(n,e,t){const s=new Map(n),r=(s.get(e)??[]).filter(o=>!t(o));return r.length>0?s.set(e,r):s.delete(e),s}function gpe({children:n}){const[e,t]=y.useState(new Map),[s,r]=y.useState(new Map),[o,i]=y.useState(new Map),[l,c]=y.useState(new Map),[u,d]=y.useState(new Set),[f,m]=y.useState(new Set),p=y.useRef(""),h=y.useRef(""),g=y.useRef(""),x=Mf(),b=IN()!==null,w=y.useRef(x.key);y.useLayoutEffect(()=>{w.current=x.key},[x.key]);const v=y.useCallback(async()=>{const[P,z,L]=await Promise.all([Jh(El("/api/permissions",x)),Jh(El("/api/user-questions",x)),Jh(El("/api/agent-prompts",x))]);if(w.current!==x.key)return;const I=Qh(P,p),M=Qh(z,h),F=Qh(L,g);I&&(t(el(I.bySession)),d(new Set(el(I.plansBySession).keys()))),M&&r(el(M.bySession)),F&&(i(el(F.elicitationsBySession)),c(el(F.dialogsBySession)))},[x]);y.useEffect(()=>{if(b)return;const P=()=>{document.visibilityState==="visible"&&v()};P();const z=setInterval(P,hpe);return document.addEventListener("visibilitychange",P),()=>{clearInterval(z),document.removeEventListener("visibilitychange",P)}},[v,b]);const j=y.useCallback(async(P,z)=>{m(L=>new Set(L).add(P));try{return await z()}finally{m(L=>{const I=new Set(L);return I.delete(P),I}),v()}},[v]),k=y.useCallback((P,z,L)=>j(z,async()=>{await PI(P,z,L).catch(()=>!1)&&(t(M=>Vu(M,P,F=>F.requestId===z)),p.current="")}),[j]),_=y.useCallback((P,z,L)=>j(z,async()=>{const I=await J0(P,z,L);return I.ok&&(r(M=>Vu(M,P,F=>F.toolUseId===z)),h.current=""),I}),[j]),N=y.useCallback((P,z,L)=>j(z,async()=>{const I=await mpe(P,z,L);return I.ok&&(i(M=>Vu(M,P,F=>F.requestId===z)),g.current=""),I}),[j]),S=y.useCallback((P,z,L)=>j(z,async()=>{const I=await ppe(P,z,L);return I.ok&&(c(M=>Vu(M,P,F=>F.requestId===z)),g.current=""),I}),[j]),C=y.useMemo(()=>new Set(e.keys()),[e]),E=y.useMemo(()=>new Set(s.keys()),[s]),T=y.useMemo(()=>new Set(o.keys()),[o]),$=y.useMemo(()=>new Set(l.keys()),[l]),A=y.useCallback(()=>{v()},[v]),R=y.useMemo(()=>({permissionsBySession:e,questionsBySession:s,elicitationsBySession:o,dialogsBySession:l,awaitingPermission:C,awaitingQuestion:E,awaitingElicitation:T,awaitingDialog:$,awaitingPlan:u,responding:f,respond:k,answerQuestion:_,answerElicitation:N,answerDialog:S,refresh:A}),[e,s,o,l,C,E,T,$,u,f,k,_,N,S,A]);return a.jsx(Gb.Provider,{value:R,children:n})}function xpe(){const n=y.useContext(Gb);if(!n)throw new Error("usePendingHumanInput must be used within a PendingHumanInputProvider");return n}function bpe(){return y.useContext(Gb)}function $I(n){var d;const e=V.c(29),t=ir(),s=bpe(),r=r5(n),o=t==null?void 0:t.sessions,i=t==null?void 0:t.procBySession;let l;e[0]!==s?(l=s?{awaitingPermission:s.awaitingPermission,awaitingQuestion:s.awaitingQuestion,awaitingPrompt:new Set([...s.awaitingElicitation,...s.awaitingDialog]),awaitingPlan:s.awaitingPlan}:T9,e[0]=s,e[1]=l):l=e[1];const c=l;let u;if(e[2]!==c||e[3]!==i||e[4]!==n||e[5]!==o||e[6]!==r){e:{if(!n||!o||!i){u=null;break e}let f;if(e[8]!==n||e[9]!==o){let v;e[11]!==n?(v=j=>j.sessionId===n,e[11]=n,e[12]=v):v=e[12],f=o.find(v),e[8]=n,e[9]=o,e[10]=f}else f=e[10];const m=f,p=((d=m==null?void 0:m.crew)==null?void 0:d.rootId)??n;let h;e[13]!==p?(h=v=>{var j;return((j=v.crew)==null?void 0:j.rootId)===p},e[13]=p,e[14]=h):h=e[14];const g=o.filter(h);if(g.length===0){if(r.length===0){u=null;break e}const v=r.length;let j;e[15]!==r?(j=r.filter(vpe),e[15]=r,e[16]=j):j=e[16];let k;e[17]!==p||e[18]!==j.length||e[19]!==r.length?(k={rootId:p,size:v,needsYou:0,working:j.length},e[17]=p,e[18]=j.length,e[19]=r.length,e[20]=k):k=e[20],u=k;break e}let x;e[21]!==c||e[22]!==i?(x=v=>_N(v,i,c),e[21]=c,e[22]=i,e[23]=x):x=e[23];const b=Dx(g,x);let w;e[24]!==b.needsYou||e[25]!==b.size||e[26]!==b.working||e[27]!==p?(w={rootId:p,size:b.size,needsYou:b.needsYou,working:b.working},e[24]=b.needsYou,e[25]=b.size,e[26]=b.working,e[27]=p,e[28]=w):w=e[28],u=w}e[2]=c,e[3]=i,e[4]=n,e[5]=o,e[6]=r,e[7]=u}else u=e[7];return u}function vpe(n){return n.state==="running"}function vd(n){const e=V.c(10),{reason:t,children:s}=n;if(!t)return s;let r;e[0]!==t?(r=a.jsx("span",{className:"inline-flex",tabIndex:0,"aria-label":t}),e[0]=t,e[1]=r):r=e[1];let o;e[2]!==s||e[3]!==r?(o=a.jsx(Zt,{render:r,children:s}),e[2]=s,e[3]=r,e[4]=o):o=e[4];let i;e[5]!==t?(i=a.jsx(Yt,{children:t}),e[5]=t,e[6]=i):i=e[6];let l;return e[7]!==o||e[8]!==i?(l=a.jsxs(Gt,{children:[o,i]}),e[7]=o,e[8]=i,e[9]=l):l=e[9],l}function ype(n){var k;const e=V.c(22),{sessionId:t}=n,s=ir(),{names:r}=Ff();s==null||s.sessions;let o;e[0]!==(s==null?void 0:s.sessions)?(o=new Map(((s==null?void 0:s.sessions)??[]).map(wpe)),e[0]=s==null?void 0:s.sessions,e[1]=o):o=e[1];const i=o;let l,c,u,d;if(e[2]!==i||e[3]!==r||e[4]!==t){d=Symbol.for("react.early_return_sentinel");e:{if(l=(k=i.get(t))==null?void 0:k.crew,!l){d=null;break e}c=i.get(l.parentId),u=$d(l.parentId,i,r)??l.parentTitle??"the session that started it"}e[2]=i,e[3]=r,e[4]=t,e[5]=l,e[6]=c,e[7]=u,e[8]=d}else l=e[5],c=e[6],u=e[7],d=e[8];if(d!==Symbol.for("react.early_return_sentinel"))return d;const f=u;let m;e[9]!==l||e[10]!==c?(m=()=>{c?Ma(pa(c.dirName,c.fileName)):cm(l.parentId)},e[9]=l,e[10]=c,e[11]=m):m=e[11];const p=m,h=`Reports to ${f}`,g=`Open ${f}, which started this session`;let x,b,w;e[12]===Symbol.for("react.memo_cache_sentinel")?(x=G(fs,"h-8 min-w-12 max-w-56 shrink-[4] gap-1.5 px-2.5 text-xs text-muted-foreground hover:text-foreground"),b=a.jsx(dx,{className:"size-3 shrink-0","aria-hidden":"true"}),w=a.jsx("span",{className:"shrink-0 max-[1200px]:hidden",children:"Reports to"}),e[12]=x,e[13]=b,e[14]=w):(x=e[12],b=e[13],w=e[14]);let v;e[15]!==f?(v=a.jsx("span",{className:"truncate font-medium text-foreground",children:f}),e[15]=f,e[16]=v):v=e[16];let j;return e[17]!==p||e[18]!==v||e[19]!==h||e[20]!==g?(j=a.jsxs(Q,{type:"button",variant:"ghost",size:"xs","data-crew-parent":!0,onClick:p,"aria-label":h,title:g,className:x,children:[b,w,v]}),e[17]=p,e[18]=v,e[19]=h,e[20]=g,e[21]=j):j=e[21],j}function wpe(n){return[n.sessionId,n]}const lj=s_.version,Spe={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"},cj={ok:"Reachable",unknown:"Not reachable","bad-password":"Password rejected"};function kpe(n){const e=V.c(6),{state:t}=n,s=cj[t],r=cj[t],o=Spe[t];let i;e[0]!==o?(i=G("size-2 shrink-0 rounded-full",o),e[0]=o,e[1]=i):i=e[1];let l;return e[2]!==s||e[3]!==r||e[4]!==i?(l=a.jsx("span",{"aria-label":s,title:r,className:i}),e[2]=s,e[3]=r,e[4]=i,e[5]=l):l=e[5],l}function uj(n){const e=V.c(2),{slot:t}=n;if(t>9)return null;let s;return e[0]!==t?(s=a.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:t}),e[0]=t,e[1]=s):s=e[1],s}function Zb(n){const e=V.c(51),{compact:t}=n,s=t===void 0?!1:t,{devices:r,activeDeviceId:o,activeDevice:i,refresh:l,testDevice:c}=Fa(),[u,d]=y.useState(null),f=(i==null?void 0:i.name)??"This machine",m=o!==Lt;let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=xt("manageDevices"),e[0]=p):p=e[0];const h=p;let g;e[1]!==r||e[2]!==l||e[3]!==c?(g=O=>{!O||r.length===0||Promise.all(r.map(D=>c(D.id).catch(Npe))).then(()=>l())},e[1]=r,e[2]=l,e[3]=c,e[4]=g):g=e[4];const x=g;if(!s&&r.length===0&&!m)return null;const b=s?"sm":"xs",w=s&&"h-10";let v;e[5]!==w?(v=G("max-w-40 justify-start",w),e[5]=w,e[6]=v):v=e[6];let j;e[7]!==b||e[8]!==v?(j=a.jsx(Q,{variant:"ghost",size:b,"aria-label":"Switch device",className:v}),e[7]=b,e[8]=v,e[9]=j):j=e[9];let k;e[10]!==m?(k=m?a.jsx(ax,{"data-icon":"inline-start"}):a.jsx(bg,{"data-icon":"inline-start"}),e[10]=m,e[11]=k):k=e[11];let _;e[12]!==f?(_=a.jsx("span",{className:"truncate",children:f}),e[12]=f,e[13]=_):_=e[13];let N;e[14]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx(_t,{"data-icon":"inline-end",className:"opacity-60"}),e[14]=N):N=e[14];let S;e[15]!==j||e[16]!==k||e[17]!==_?(S=a.jsxs(Rc,{render:j,children:[k,_,N]}),e[15]=j,e[16]=k,e[17]=_,e[18]=S):S=e[18];let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsx(A5,{children:"Devices"}),e[19]=C):C=e[19];let E,T,$;e[20]===Symbol.for("react.memo_cache_sentinel")?(E=a.jsx(bg,{}),T=a.jsx("span",{className:"flex-1 truncate",children:"This machine"}),$=a.jsx(uj,{slot:1}),e[20]=E,e[21]=T,e[22]=$):(E=e[20],T=e[21],$=e[22]);let A;e[23]!==m?(A=!m&&a.jsx(nn,{className:"ml-auto text-success"}),e[23]=m,e[24]=A):A=e[24];let R;e[25]!==A?(R=a.jsxs(hn,{onClick:jpe,children:[E,T,$,A]}),e[25]=A,e[26]=R):R=e[26];let P;if(e[27]!==o||e[28]!==s||e[29]!==r){let O;e[31]!==o||e[32]!==s?(O=(D,B)=>{const q=jI(D),W=q!==void 0&&q!==lj,H=D.id===o;return a.jsxs(hn,{onClick:()=>Xs(D.id),className:G(s&&"min-h-10"),children:[a.jsx(kpe,{state:D.runtime.authState}),a.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[a.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[a.jsx("span",{className:"truncate",children:D.name}),W&&a.jsxs("span",{className:"shrink-0 font-mono text-xs text-warning",title:`Device runs v${q}; hub runs v${lj}`,children:["v",q]})]}),a.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:[D.host,":",D.port,D.auth==="none"&&" · unauthenticated"]})]}),a.jsx(uj,{slot:B+2}),H&&a.jsx(nn,{className:"ml-auto text-success"})]},D.id)},e[31]=o,e[32]=s,e[33]=O):O=e[33],P=r.map(O),e[27]=o,e[28]=s,e[29]=r,e[30]=P}else P=e[30];let z;e[34]!==R||e[35]!==P?(z=a.jsxs(qr,{children:[C,R,P]}),e[34]=R,e[35]=P,e[36]=z):z=e[36];let L;e[37]!==r.length?(L=h&&a.jsxs(a.Fragment,{children:[a.jsx(Il,{}),a.jsxs(qr,{children:[a.jsxs(hn,{onClick:()=>d("add"),children:[a.jsx(Sr,{}),a.jsx("span",{children:"Add device…"})]}),r.length>0&&a.jsxs(hn,{onClick:()=>d("manage"),children:[a.jsx(rx,{}),a.jsx("span",{children:"Manage devices…"})]})]})]}),e[37]=r.length,e[38]=L):L=e[38];let I;e[39]!==z||e[40]!==L?(I=a.jsxs(Oc,{align:"end",sideOffset:6,className:"w-64",children:[z,L]}),e[39]=z,e[40]=L,e[41]=I):I=e[41];let M;e[42]!==x||e[43]!==S||e[44]!==I?(M=a.jsxs($c,{onOpenChange:x,children:[S,I]}),e[42]=x,e[43]=S,e[44]=I,e[45]=M):M=e[45];let F;e[46]!==u?(F=h&&a.jsx(CI,{open:u!==null,initialMode:u??"manage",onClose:()=>d(null)}),e[46]=u,e[47]=F):F=e[47];let U;return e[48]!==M||e[49]!==F?(U=a.jsxs(a.Fragment,{children:[M,F]}),e[48]=M,e[49]=F,e[50]=U):U=e[50],U}function jpe(){return Xs(Lt)}function Npe(){return null}const Cpe=6e4;function _pe(){const[n,e]=y.useState([]),t=y.useCallback(async s=>{try{const r=await Ce("/api/system-processes");if(r.ok){const o=await r.json();if(s()){const i=(o.processes??[]).filter(l=>l.suspectedLeak);e(l=>JSON.stringify(l)===JSON.stringify(i)?l:i)}}}catch{}},[]);return Ra(t,Cpe),{leaks:n}}const Epe=6e4;function Tpe(n){const e=V.c(23),{onReview:t}=n,{leaks:s}=_pe(),[r,o]=y.useState(!1),i=s.length>0,l=s.reduce(Ipe,0);let c,u;if(e[0]!==i?(c=()=>{if(i){o(!0);return}const C=window.setTimeout(()=>o(!1),Epe);return()=>window.clearTimeout(C)},u=[i],e[0]=i,e[1]=c,e[2]=u):(c=e[1],u=e[2]),y.useEffect(c,u),!i&&!r)return null;const d=Gt,f=i?"destructive":"ghost",m=i?`Review ${s.length} flagged ${s.length===1?"process":"processes"}`:"Leak monitor. No flagged processes",p=!i&&"text-muted-foreground";let h;e[3]!==p?(h=G("mr-1 font-mono",p),e[3]=p,e[4]=h):h=e[4];let g;e[5]!==t||e[6]!==f||e[7]!==m||e[8]!==h?(g=a.jsx(Q,{variant:f,size:"xs","aria-label":m,onClick:t,className:h}),e[5]=t,e[6]=f,e[7]=m,e[8]=h,e[9]=g):g=e[9];let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=a.jsx(y8,{"data-icon":"inline-start"}),e[10]=x):x=e[10];let b;e[11]!==s.length?(b=a.jsx("span",{className:"tabular-nums",children:s.length}),e[11]=s.length,e[12]=b):b=e[12];let w;e[13]!==g||e[14]!==b?(w=a.jsxs(Zt,{render:g,children:[x,b]}),e[13]=g,e[14]=b,e[15]=w):w=e[15];const v=Yt,j="bottom",k="p-3",_=i?a.jsxs("div",{className:"flex min-w-56 flex-col gap-2",children:[a.jsxs("div",{className:"text-xs font-medium",children:["Flagged processes · ",l.toFixed(0),"% CPU"]}),s.slice(0,6).map(Ape),s.length>6&&a.jsxs("div",{className:"text-xs text-muted-foreground",children:["+",s.length-6," more"]}),a.jsx(en,{}),a.jsx("div",{className:"text-xs text-muted-foreground",children:"Review ownership and stop individual processes"})]}):a.jsxs("div",{className:"flex min-w-48 flex-col gap-1",children:[a.jsx("div",{className:"text-xs font-medium",children:"Leak monitor"}),a.jsx("div",{className:"text-xs text-muted-foreground",children:"No flagged processes. Click to open the power monitor."})]});let N;e[16]!==v||e[17]!==_?(N=a.jsx(v,{side:j,className:k,children:_}),e[16]=v,e[17]=_,e[18]=N):N=e[18];let S;return e[19]!==d||e[20]!==w||e[21]!==N?(S=a.jsxs(d,{children:[w,N]}),e[19]=d,e[20]=w,e[21]=N,e[22]=S):S=e[22],S}function Ape(n){return a.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[a.jsxs("span",{className:"truncate text-muted-foreground",children:[n.label," · ",SN(n.ageSeconds)]}),a.jsxs("span",{className:"shrink-0 font-semibold text-destructive",children:[n.cpuPercent.toFixed(0),"%"]})]},n.pid)}function Ipe(n,e){return n+e.cpuPercent}const Ppe=2e3;function va(n){return`${n.toFixed(n<10?1:0)}%`}function gf(n){return`${n.toFixed(0)} MB`}function $pe(n){return n>=10?`${n.toFixed(0)}/s`:n>=1?`${n.toFixed(1)}/s`:`${n.toFixed(2)}/s`}function Rpe(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 Ope(n){const e=V.c(50),{metric:t,onStop:s,stopping:r,onNavigate:o}=n;let i;e[0]!==t.label?(i=a.jsx("span",{className:"truncate text-sm font-medium",children:t.label}),e[0]=t.label,e[1]=i):i=e[1];let l;e[2]!==t.pid?(l=a.jsxs(Fe,{variant:"outline",children:["PID ",t.pid]}),e[2]=t.pid,e[3]=l):l=e[3];let c;e[4]!==t.suspectedLeak||e[5]!==t.warning?(c=t.suspectedLeak&&a.jsx(Fe,{variant:"destructive",children:t.warning==="sustained-cpu"?"sustained high CPU":"possible leak"}),e[4]=t.suspectedLeak,e[5]=t.warning,e[6]=c):c=e[6];let u;e[7]!==t.orphaned||e[8]!==t.suspectedLeak?(u=t.orphaned&&!t.suspectedLeak&&a.jsx(Fe,{variant:"secondary",children:"orphaned"}),e[7]=t.orphaned,e[8]=t.suspectedLeak,e[9]=u):u=e[9];let d;e[10]!==i||e[11]!==l||e[12]!==c||e[13]!==u?(d=a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i,l,c,u]}),e[10]=i,e[11]=l,e[12]=c,e[13]=u,e[14]=d):d=e[14];let f;e[15]!==t.command?(f=a.jsx("p",{className:"mt-1 truncate font-mono text-xs text-muted-foreground",title:t.command,children:t.command}),e[15]=t.command,e[16]=f):f=e[16];let m;e[17]!==t.kind||e[18]!==t.owner||e[19]!==o?(m=t.owner?a.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[t.owner.dirName&&t.owner.fileName?a.jsx("a",{className:"underline",href:pa(t.owner.dirName,t.owner.fileName),onClick:S=>{S.metaKey||S.ctrlKey||S.shiftKey||S.altKey||(S.preventDefault(),Ma(pa(t.owner.dirName,t.owner.fileName)),o())},children:t.owner.title||"Originating session"}):a.jsx("span",{children:"Originating session"}),a.jsxs("div",{className:"break-all",children:[t.owner.sessionId," · task ",t.owner.taskId]})]}):t.kind!=="cogpit"&&a.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Session ownership unknown"}),e[17]=t.kind,e[18]=t.owner,e[19]=o,e[20]=m):m=e[20];let p;e[21]!==d||e[22]!==f||e[23]!==m?(p=a.jsxs("div",{className:"min-w-0 flex-1",children:[d,f,m]}),e[21]=d,e[22]=f,e[23]=m,e[24]=p):p=e[24];let h;e[25]!==t||e[26]!==s||e[27]!==r?(h=t.canStop&&t.identity&&a.jsx(Q,{variant:"destructive",size:"xs",className:"shrink-0",onClick:()=>s(t),disabled:r,"aria-label":`Stop process ${t.pid}`,children:r?"Stopping…":"Stop"}),e[25]=t,e[26]=s,e[27]=r,e[28]=h):h=e[28];const g=t.cpuPercent>=20&&"text-destructive";let x;e[29]!==g?(x=G("font-mono text-sm font-semibold tabular-nums",g),e[29]=g,e[30]=x):x=e[30];let b;e[31]!==t.cpuPercent?(b=va(t.cpuPercent),e[31]=t.cpuPercent,e[32]=b):b=e[32];let w;e[33]!==x||e[34]!==b?(w=a.jsx("div",{className:x,children:b}),e[33]=x,e[34]=b,e[35]=w):w=e[35];let v;e[36]!==t.memoryMb?(v=gf(t.memoryMb),e[36]=t.memoryMb,e[37]=v):v=e[37];let j;e[38]!==t.ageSeconds?(j=SN(t.ageSeconds),e[38]=t.ageSeconds,e[39]=j):j=e[39];let k;e[40]!==v||e[41]!==j?(k=a.jsxs("div",{className:"text-xs text-muted-foreground",children:[v," · ",j]}),e[40]=v,e[41]=j,e[42]=k):k=e[42];let _;e[43]!==w||e[44]!==k?(_=a.jsxs("div",{className:"shrink-0 text-right",children:[w,k]}),e[43]=w,e[44]=k,e[45]=_):_=e[45];let N;return e[46]!==_||e[47]!==p||e[48]!==h?(N=a.jsxs("div",{className:"flex items-start gap-3 py-2.5",children:[p,h,_]}),e[46]=_,e[47]=p,e[48]=h,e[49]=N):N=e[49],N}function Lpe(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 Mpe(n,e,t=0){return t>0?t===1?'1 process needs review. See "Agent and runtime processes" below.':`${t} processes need review. See "Agent and runtime 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 dj(n){const e=V.c(34),{metric:t}=n;let s;e[0]!==t.name?(s=a.jsx("span",{className:"truncate text-sm font-medium",children:t.name}),e[0]=t.name,e[1]=s):s=e[1];let r;e[2]!==t.pid?(r=t.pid>0&&a.jsxs(Fe,{variant:"outline",children:["PID ",t.pid]}),e[2]=t.pid,e[3]=r):r=e[3];let o;e[4]!==s||e[5]!==r?(o=a.jsxs("div",{className:"flex items-center gap-2",children:[s,r]}),e[4]=s,e[5]=r,e[6]=o):o=e[6];let i;e[7]!==t?(i=Lpe(t),e[7]=t,e[8]=i):i=e[8];let l;e[9]!==i?(l=a.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:i}),e[9]=i,e[10]=l):l=e[10];let c;e[11]!==o||e[12]!==l?(c=a.jsxs("div",{className:"min-w-0 flex-1",children:[o,l]}),e[11]=o,e[12]=l,e[13]=c):c=e[13];const u=t.cpuPercent>=50&&"text-destructive";let d;e[14]!==u?(d=G("font-mono text-sm font-semibold tabular-nums",u),e[14]=u,e[15]=d):d=e[15];let f;e[16]!==t.cpuPercent?(f=va(t.cpuPercent),e[16]=t.cpuPercent,e[17]=f):f=e[17];let m;e[18]!==d||e[19]!==f?(m=a.jsx("div",{className:d,children:f}),e[18]=d,e[19]=f,e[20]=m):m=e[20];let p;e[21]!==t.memoryMb?(p=gf(t.memoryMb),e[21]=t.memoryMb,e[22]=p):p=e[22];let h;e[23]!==p?(h=a.jsx("div",{className:"text-xs text-muted-foreground",children:p}),e[23]=p,e[24]=h):h=e[24];let g;e[25]!==t.idleWakeupsPerSecond?(g=t.idleWakeupsPerSecond!==void 0&&t.idleWakeupsPerSecond>0&&a.jsxs("div",{className:"text-xs text-muted-foreground",children:[t.idleWakeupsPerSecond.toFixed(0)," wakeups/s"]}),e[25]=t.idleWakeupsPerSecond,e[26]=g):g=e[26];let x;e[27]!==m||e[28]!==h||e[29]!==g?(x=a.jsxs("div",{className:"shrink-0 text-right",children:[m,h,g]}),e[27]=m,e[28]=h,e[29]=g,e[30]=x):x=e[30];let b;return e[31]!==x||e[32]!==c?(b=a.jsxs("div",{className:"flex items-start gap-3 py-2.5",children:[c,x]}),e[31]=x,e[32]=c,e[33]=b):b=e[33],b}function fj(n){const e=V.c(6),{metrics:t,emptyLabel:s}=n;let r,o;if(e[0]!==s||e[1]!==t){o=Symbol.for("react.early_return_sentinel");e:{const i=t.slice(0,8);if(i.length===0){let l;e[4]!==s?(l=a.jsx("p",{className:"py-3 text-sm text-muted-foreground",children:s}),e[4]=s,e[5]=l):l=e[5],o=l;break e}r=i.map(zpe)}e[0]=s,e[1]=t,e[2]=r,e[3]=o}else r=e[2],o=e[3];return o!==Symbol.for("react.early_return_sentinel")?o:r}function zpe(n,e){const t=Rpe(n.bytesPerSecond);return a.jsxs("div",{children:[e>0&&a.jsx(en,{}),a.jsxs("div",{className:"flex items-center gap-3 py-2.5",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-sm",children:n.name}),a.jsxs("div",{className:"mt-0.5 flex flex-wrap gap-x-2 text-xs text-muted-foreground",children:[a.jsx("span",{children:$pe(n.ratePerSecond)}),t&&a.jsx("span",{children:t}),n.averageDurationMs!==void 0&&a.jsxs("span",{children:[n.averageDurationMs.toFixed(0)," ms avg"]})]})]}),n.active!==void 0&&n.active>0&&a.jsxs(Fe,{variant:"secondary",children:[n.active," open"]})]})]},n.name)}function Dpe(n){const e=V.c(8),{values:t}=n,s=Math.max(100,...t);let r;e[0]!==t?(r=t.map(Fpe).join(", "),e[0]=t,e[1]=r):r=e[1];const o=`Recent Cogpit CPU: ${r}`;let i;e[2]!==s||e[3]!==t?(i=t.length===0?a.jsx("span",{className:"self-center text-xs text-muted-foreground",children:"Collecting samples…"}):t.map((c,u)=>a.jsx("div",{className:G("min-w-1 flex-1 rounded-sm bg-primary/70",c>=80&&"bg-destructive/80"),style:{height:`${Math.max(4,Math.min(100,c/s*100))}%`},title:va(c)},u)),e[2]=s,e[3]=t,e[4]=i):i=e[4];let l;return e[5]!==o||e[6]!==i?(l=a.jsx("div",{className:"flex h-14 items-end gap-1 rounded-md bg-muted/50 p-2",role:"img","aria-label":o,children:i}),e[5]=o,e[6]=i,e[7]=l):l=e[7],l}function Fpe(n){return va(n)}function Upe({open:n,onOpenChange:e}){var $,A;const[t,s]=y.useState(null),[r,o]=y.useState(null),[i,l]=y.useState([]),[c,u]=y.useState(null),[d,f]=y.useState(null),[m,p]=y.useState(!1),[h,g]=y.useState(null),x=y.useRef(!1),[b,w]=no(),v=y.useCallback(async()=>{var F;if(x.current)return;x.current=!0,p(!0);const R=Ce("/api/performance").then(async U=>{if(!U.ok)throw new Error(`Server monitor returned ${U.status}`);return U.json()}),P=((F=window.electronPerformance)==null?void 0:F.getSnapshot())??Promise.resolve(null),[z,L]=await Promise.allSettled([R,P]),I=z.status==="fulfilled"?z.value:null,M=L.status==="fulfilled"?L.value:null;if(I&&o(I),M&&s(M),!I&&!M)u("Performance data is unavailable.");else{u(null);const U=M&&M.processes.length>0?M.processes.reduce((O,D)=>O+D.cpuPercent,0):(I==null?void 0:I.cpuPercent)??0;l(O=>[...O.slice(-29),U])}x.current=!1,p(!1)},[]);y.useEffect(()=>{if(!n)return;const R=()=>{document.visibilityState==="visible"&&v()};R();const P=window.setInterval(R,Ppe);return document.addEventListener("visibilitychange",R),()=>{window.clearInterval(P),document.removeEventListener("visibilitychange",R)}},[n,v]);const j=[...(t==null?void 0:t.processes)??[]].sort((R,P)=>P.cpuPercent-R.cpuPercent),k=j.length>0?j.reduce((R,P)=>R+P.cpuPercent,0):(r==null?void 0:r.cpuPercent)??0,_=j[0],N=(($=r==null?void 0:r.system)==null?void 0:$.processes)??[],S=((A=r==null?void 0:r.system)==null?void 0:A.suspectedLeakCount)??0,C=S>0||k>=80?"High":k>=15?"Active":"Idle",E=async R=>{if(!(!R.identity||h!==null)){f(null),g(R.pid);try{const P=await Ce("/api/system-processes/kill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({processes:[{pid:R.pid,identity:R.identity}]})});if(!P.ok)throw new Error("Could not stop this process.");if(!(await P.json()).killed.includes(R.pid))throw new Error("The process changed or is no longer eligible. Refresh and review it again.");await v()}catch{f("Process was not stopped. Refresh and review its current identity and access.")}finally{g(null)}}},T=()=>{w(JSON.stringify({capturedAt:new Date().toISOString(),electron:t,server:r,cpuHistory:i},null,2))};return a.jsx(nr,{open:n,onOpenChange:e,children:a.jsxs(sr,{className:"h-[min(780px,calc(100vh-2rem))] gap-0 p-0 sm:max-w-3xl",children:[a.jsx(io,{className:"p-5 pb-4",children:a.jsxs("div",{className:"flex items-start gap-3 pr-8",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(rr,{children:"Power & activity monitor"}),a.jsx(Fe,{variant:C==="High"?"destructive":"secondary",children:C})]}),a.jsx(or,{className:"mt-1",children:"Live CPU, memory, and wakeups. Sampling runs only while this window is open."})]}),a.jsxs("div",{className:"flex shrink-0 gap-1",children:[a.jsxs(Q,{variant:"outline",size:"sm",onClick:()=>void v(),disabled:m,children:[a.jsx(Fn,{"data-icon":"inline-start",className:G(m&&"animate-spin")}),"Refresh"]}),a.jsxs(Q,{variant:"outline",size:"sm",onClick:T,disabled:!r&&!t,children:[b?a.jsx(nn,{"data-icon":"inline-start"}):a.jsx(Es,{"data-icon":"inline-start"}),b?"Copied":"Copy data"]})]})]})}),a.jsx(en,{}),a.jsx(Vc,{className:"min-h-0 min-w-0 flex-1",children:a.jsxs("div",{className:"flex flex-col gap-4 p-5",children:[(c||d)&&a.jsx(jt,{variant:"destructive",children:a.jsx(Rt,{children:d||c})}),a.jsxs(Ds,{size:"sm",children:[a.jsxs(gr,{children:[a.jsx(xr,{children:"Current load"}),a.jsx(br,{children:Mpe(k,_,S)}),a.jsx(Dte,{children:a.jsxs("span",{className:G("font-mono text-lg font-semibold tabular-nums",k>=80&&"text-destructive"),children:[va(k)," CPU"]})})]}),a.jsx(Fs,{children:a.jsx(Dpe,{values:i})})]}),a.jsxs(Ds,{size:"sm",children:[a.jsxs(gr,{children:[a.jsx(xr,{children:"Processes"}),a.jsx(br,{children:"Which part of Cogpit is consuming CPU and memory."})]}),a.jsx(Fs,{children:j.length>0?j.map((R,P)=>a.jsxs("div",{children:[P>0&&a.jsx(en,{}),a.jsx(dj,{metric:R})]},R.pid)):r?a.jsx(dj,{metric:{pid:0,name:"Server",type:"Node",cpuPercent:r.cpuPercent,memoryMb:r.memory.rssMb}}):a.jsx("p",{className:"py-3 text-sm text-muted-foreground",children:"Collecting process data…"})})]}),N.length>0&&a.jsxs(Ds,{size:"sm",children:[a.jsxs(gr,{children:[a.jsx(xr,{children:"Agent and runtime processes"}),a.jsx(br,{children:"Agent sessions, browsers, and long-running scripts. Unknown runtimes are flagged after sustained high CPU; stopping them is manual."})]}),a.jsx(Fs,{children:N.map((R,P)=>a.jsxs("div",{children:[P>0&&a.jsx(en,{}),a.jsx(Ope,{metric:R,onStop:z=>void E(z),stopping:h!==null,onNavigate:()=>e(!1)})]},R.pid))})]}),a.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[a.jsxs(Ds,{size:"sm",children:[a.jsxs(gr,{children:[a.jsx(xr,{children:"Server activity"}),a.jsxs(br,{children:["File checks, streams, and agent work over the last ",(r==null?void 0:r.sampleWindowSeconds)??10," seconds."]})]}),a.jsx(Fs,{children:a.jsx(fj,{metrics:(r==null?void 0:r.activities)??[],emptyLabel:"No watched-file or stream activity in this sample."})})]}),a.jsxs(Ds,{size:"sm",children:[a.jsxs(gr,{children:[a.jsx(xr,{children:"API activity"}),a.jsx(br,{children:"Requests ranked by recent frequency and time."})]}),a.jsx(Fs,{children:a.jsx(fj,{metrics:(r==null?void 0:r.requests)??[],emptyLabel:"No API requests in this sample."})})]})]}),r&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Server event loop ",va(r.eventLoopPercent)," · heap ",gf(r.memory.heapUsedMb)," · RSS ",gf(r.memory.rssMb)]})]})})]})})}function Bpe(n){return`${n.title??`Pull request #${n.number}`}
461
+ `)[0];return l.length>Y3?`${l.slice(0,Y3)}...`:l}function fme(n,e,t){for(let s=e;s>=0;s--){const r=n[s];if(!r)continue;const o=dme(r,t);if(o)return{index:s,text:o}}return null}function mme(n){const e=n.getBoundingClientRect().top;let t=null,s=0;for(const l of n.querySelectorAll(cme)){const c=l.getBoundingClientRect().top;if(c>e+Z3)break;t=l,s=c}if(!t)return null;const r=Number(t.dataset.turnIndex);if(!Number.isInteger(r))return null;const o=t.querySelector(gI);return(o?o.getBoundingClientRect().bottom>e+Z3:s+ume>e)?null:r}const pme=y.memo(function(e){const t=V.c(23),{session:s,scrollContainerRef:r}=e,[o,i]=y.useState(null);let l,c;t[0]!==r||t[1]!==s.sessionId?(l=()=>{const k=r.current;if(!k)return;let _=null;const N=()=>{_=null;const T=mme(k);i($=>T===null?null:($==null?void 0:$.sessionId)===s.sessionId&&$.index===T?$:{sessionId:s.sessionId,index:T})},S=()=>{_===null&&(_=requestAnimationFrame(N))};i(null),k.addEventListener("scroll",S,{passive:!0});const C=new MutationObserver(S);C.observe(k,{childList:!0,subtree:!0});const E=new ResizeObserver(S);return E.observe(k),k.firstElementChild&&E.observe(k.firstElementChild),S(),()=>{k.removeEventListener("scroll",S),C.disconnect(),E.disconnect(),_!==null&&cancelAnimationFrame(_)}},c=[r,s.sessionId],t[0]=r,t[1]=s.sessionId,t[2]=l,t[3]=c):(l=t[2],c=t[3]),y.useEffect(l,c);const u=$a();let d;e:{if(!o||o.sessionId!==s.sessionId){d=null;break e}let k;t[4]!==u||t[5]!==s.turns||t[6]!==o.index?(k=fme(s.turns,o.index,u),t[4]=u,t[5]=s.turns,t[6]=o.index,t[7]=k):k=t[7],d=k}const f=d;if(!f)return null;let m;t[8]!==f.index||t[9]!==r?(m=()=>{const k=r.current;if(!k)return;const _=k.querySelector(`[data-turn-index="${f.index}"]`),N=(_==null?void 0:_.querySelector(gI))??_;if(!N)return;const S=k.scrollTop+N.getBoundingClientRect().top-k.getBoundingClientRect().top;k.scrollTo({top:Math.max(0,S),behavior:"smooth"})},t[8]=f.index,t[9]=r,t[10]=m):m=t[10];const p=m,h=`Scroll to turn ${f.index+1} prompt`;let g;t[11]===Symbol.for("react.memo_cache_sentinel")?(g=a.jsx(z4,{"data-icon":"inline-start"}),t[11]=g):g=t[11];const x=f.index+1;let b;t[12]!==x?(b=a.jsxs("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:["Turn ",x]}),t[12]=x,t[13]=b):b=t[13];let w;t[14]!==f.text?(w=a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-normal text-foreground/80",children:f.text}),t[14]=f.text,t[15]=w):w=t[15];let v;t[16]===Symbol.for("react.memo_cache_sentinel")?(v=a.jsx(ka,{"data-icon":"inline-end",className:"ml-auto"}),t[16]=v):v=t[16];let j;return t[17]!==f.text||t[18]!==p||t[19]!==h||t[20]!==b||t[21]!==w?(j=a.jsxs(Q,{type:"button",variant:"outline",size:"sm","aria-label":h,title:f.text,className:"motion-slide-down-in absolute left-1/2 top-12 z-20 h-9 max-w-[calc(100%-5rem)] -translate-x-1/2 justify-start gap-2 rounded-full bg-popover px-3 text-left shadow-sm",onClick:p,children:[g,b,w,v]}),t[17]=f.text,t[18]=p,t[19]=h,t[20]=b,t[21]=w,t[22]=j):j=t[22],j});function R1({path:n,dirName:e,command:t}){return qo()?(console.warn("[open-terminal] unavailable for remote devices"),!1):!n&&!e?(console.warn("[open-terminal] no project path available"),!1):(Ce("/api/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,dirName:e,...t?{command:t}:{}})}).then(s=>{s.ok||s.json().then(r=>console.error("[open-terminal]",r.error)).catch(()=>{})}).catch(s=>console.error("[open-terminal] fetch failed:",s)),!0)}const hme={five_hour:"5-hour",seven_day:"weekly",seven_day_opus:"weekly Opus",seven_day_sonnet:"weekly Sonnet",seven_day_overage_included:"weekly",overage:"spend"},gme=1440*60*1e3;function xme(n){return(n&&hme[n])??"usage"}function bme(n){if(n===null)return null;const e=new Date(n*1e3);if(Number.isNaN(e.getTime()))return null;const t=e.getTime()-Date.now()>gme;return e.toLocaleString(void 0,{...t?{weekday:"short"}:{},hour:"numeric",minute:"2-digit"})}function vme(n){return n===void 0?"":n?"Extra usage is on but did not cover this. ":"Extra usage is off for this account. "}function yme(n){const e=V.c(36),{block:t,dirName:s,fileName:r,cwd:o,terminal:i}=n;let l,c;e[0]!==o||e[1]!==s||e[2]!==r?(l=vs(s),c=jx(l.kind,Ed(r),o??void 0),e[0]=o,e[1]=s,e[2]=r,e[3]=l,e[4]=c):(l=e[3],c=e[4]);const u=c;let d;e[5]!==t.resetsAt?(d=bme(t.resetsAt),e[5]=t.resetsAt,e[6]=d):d=e[6];const f=d,m=t.lowPriority&&l.capabilities.lowPriorityInTerminal;let p;e[7]!==m||e[8]!==i?(p=m&&i&&!qo(),e[7]=m,e[8]=i,e[9]=p):p=e[9];const h=p;let g;e[10]===Symbol.for("react.memo_cache_sentinel")?(g=a.jsx(Io,{}),e[10]=g):g=e[10];const x=l.displayName;let b;e[11]!==t.limit?(b=xme(t.limit),e[11]=t.limit,e[12]=b):b=e[12];let w;e[13]!==l.displayName||e[14]!==b?(w=a.jsxs(tn,{children:[x," hit its ",b," limit"]}),e[13]=l.displayName,e[14]=b,e[15]=w):w=e[15];const v=f?`Resets at ${f}. `:"";let j;e[16]!==t.extraUsage?(j=vme(t.extraUsage),e[16]=t.extraUsage,e[17]=j):j=e[17];let k;e[18]!==u||e[19]!==m?(k=m?a.jsxs(a.Fragment,{children:["It can keep this session going before then at lower priority, spending your weekly allowance to do it — a mode that exists only in its own terminal. Resume there with ",a.jsx("code",{className:"font-mono",children:u}),"."]}):a.jsx(a.Fragment,{children:"Nothing here can lift this one; the session continues once the allowance refills."}),e[18]=u,e[19]=m,e[20]=k):k=e[20];let _;e[21]!==k||e[22]!==v||e[23]!==j?(_=a.jsxs("span",{children:[v,j,k]}),e[21]=k,e[22]=v,e[23]=j,e[24]=_):_=e[24];let N;e[25]!==h||e[26]!==u||e[27]!==o||e[28]!==s?(N=h&&a.jsx(Q,{size:"sm",variant:"outline",onClick:()=>R1({path:o??void 0,dirName:s,command:u}),children:"Open in terminal"}),e[25]=h,e[26]=u,e[27]=o,e[28]=s,e[29]=N):N=e[29];let S;e[30]!==_||e[31]!==N?(S=a.jsxs(Rt,{className:"flex flex-col items-start gap-2",children:[_,N]}),e[30]=_,e[31]=N,e[32]=S):S=e[32];let C;return e[33]!==S||e[34]!==w?(C=a.jsxs(jt,{role:"status",className:"rounded-none border-x-0 border-t-0 px-4 py-2",children:[g,w,S]}),e[33]=S,e[34]=w,e[35]=C):C=e[35],C}function wme(n){const e=V.c(14),{block:t,showCursor:s}=n;if(t.blockType==="tool_use"){const l=t.toolName??"tool";let c;return e[0]!==l?(c=a.jsxs("div",{className:"text-xs text-muted-foreground italic py-1",children:["Preparing ",l,"…"]}),e[0]=l,e[1]=c):c=e[1],c}if(t.blockType==="thinking"){if(!t.text)return null;let l;e[2]!==s?(l=s&&a.jsx(X3,{}),e[2]=s,e[3]=l):l=e[3];let c;return e[4]!==t.text||e[5]!==l?(c=a.jsxs("div",{className:"my-2 whitespace-pre-wrap break-words border-l pl-3 text-sm italic leading-relaxed text-muted-foreground",children:[t.text,l]}),e[4]=t.text,e[5]=l,e[6]=c):c=e[6],c}if(!t.text)return null;let r;e[7]!==t.text?(r=a.jsx(AA,{text:t.text}),e[7]=t.text,e[8]=r):r=e[8];let o;e[9]!==s?(o=s&&a.jsx(X3,{}),e[9]=s,e[10]=o):o=e[10];let i;return e[11]!==r||e[12]!==o?(i=a.jsxs("div",{className:"text-sm leading-relaxed break-words my-2",children:[r,o]}),e[11]=r,e[12]=o,e[13]=i):i=e[13],i}function X3(){const n=V.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=a.jsx("span",{className:"ml-0.5 inline-block h-[15px] w-[7px] rounded-[1px] bg-foreground/70 align-text-bottom"}),n[0]=e):e=n[0],e}const Sme=y.memo(function(){const e=V.c(9),t=zb();let s,r,o,i;if(e[0]!==t){i=Symbol.for("react.early_return_sentinel");e:{const c=jle(t);if(c.length===0){i=null;break e}const u=new Map;s="px-4",r="streaming-turn-overlay",o=c.map(d=>{const f=u.get(d.messageId)??0;u.set(d.messageId,f+1);const m=d.blocks.reduce(kme,-1);return a.jsx("div",{children:d.blocks.map((p,h)=>a.jsx(wme,{block:p,showCursor:!d.stopped&&h===m},p.index))},`${d.messageId}:${f}`)})}e[0]=t,e[1]=s,e[2]=r,e[3]=o,e[4]=i}else s=e[1],r=e[2],o=e[3],i=e[4];if(i!==Symbol.for("react.early_return_sentinel"))return i;let l;return e[5]!==s||e[6]!==r||e[7]!==o?(l=a.jsx("div",{className:s,"data-testid":r,children:o}),e[5]=s,e[6]=r,e[7]=o,e[8]=l):l=e[8],l});function kme(n,e,t){return e.blockType!=="tool_use"&&e.text?t:n}class xI extends y.Component{constructor(t){super(t);Ge(this,"handleRetry",()=>{this.setState({hasError:!1,error:null})});this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,s){console.error("ErrorBoundary caught:",t,s.componentStack)}render(){return this.state.hasError?a.jsx("div",{className:"flex justify-center p-8",children:a.jsxs(jt,{variant:"destructive",className:"max-w-md has-data-[slot=alert-action]:pr-2.5",children:[a.jsx(Ir,{}),a.jsx(tn,{children:a.jsx("h3",{children:this.props.fallbackMessage||"Something went wrong"})}),this.state.error&&a.jsx(Rt,{className:"font-mono text-xs",children:this.state.error.message}),a.jsx(Po,{className:"static col-start-2 mt-2",children:a.jsxs(Q,{variant:"outline",size:"sm",onClick:this.handleRetry,children:[a.jsx(Fn,{"data-icon":"inline-start"}),"Try again"]})})]})}):this.props.children}}const J3="find-in-session-highlight",Yh="find-in-session-active";function jme(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 Nme=y.forwardRef(function(e,t){const s=V.c(63),{scrollContainerRef:r}=e,[o,i]=y.useState(!1),[l,c]=y.useState("");let u;s[0]===Symbol.for("react.memo_cache_sentinel")?(u=[],s[0]=u):u=s[0];const[d,f]=y.useState(u),[m,p]=y.useState(-1),h=y.useRef(null);let g;s[1]!==r?(g=()=>{const J=r.current;if(!J)return;J.querySelectorAll(`mark.${J3}`).forEach(Cme)},s[1]=r,s[2]=g):g=s[2];const x=g;let b;s[3]!==x||s[4]!==r?(b=J=>{if(x(),!J||!r.current){f([]),p(-1);return}const ne=r.current,ie=jme(ne),ae=J.toLowerCase(),oe=[];for(const ue of ie){const re=ue.nodeValue||"",de=re.toLowerCase();let fe=0;const le=[];for(;;){const be=de.indexOf(ae,fe);if(be===-1)break;le.push(be),fe=be+1}if(le.length===0)continue;const ce=ue.parentNode;if(!ce)continue;const he=document.createDocumentFragment();let ge=0;for(const be of le){be>ge&&he.appendChild(document.createTextNode(re.slice(ge,be)));const ve=document.createElement("mark");ve.className=J3,ve.textContent=re.slice(be,be+J.length),he.appendChild(ve),oe.push(ve),ge=be+J.length}ge<re.length&&he.appendChild(document.createTextNode(re.slice(ge))),ce.replaceChild(he,ue)}f(oe),oe.length>0?(p(0),oe[0].classList.add(Yh),oe[0].scrollIntoView({block:"center",behavior:"smooth"})):p(-1)},s[3]=x,s[4]=r,s[5]=b):b=s[5];const w=b;let v;s[6]!==m||s[7]!==d?(v=J=>{if(d.length===0)return;m>=0&&m<d.length&&d[m].classList.remove(Yh);const ne=(J%d.length+d.length)%d.length;d[ne].classList.add(Yh),d[ne].scrollIntoView({block:"center",behavior:"smooth"}),p(ne)},s[6]=m,s[7]=d,s[8]=v):v=s[8];const j=v;let k;s[9]!==x?(k=()=>{i(!1),c(""),x(),f([]),p(-1)},s[9]=x,s[10]=k):k=s[10];const _=k;let N,S;s[11]!==_||s[12]!==o?(N=()=>({open:()=>{i(!0),requestAnimationFrame(()=>{var J;return(J=h.current)==null?void 0:J.focus()})},close:_,isOpen:o}),S=[_,o],s[11]=_,s[12]=o,s[13]=N,s[14]=S):(N=s[13],S=s[14]),y.useImperativeHandle(t,N,S);let C,E;s[15]!==w||s[16]!==l?(C=()=>{const J=setTimeout(()=>w(l),150);return()=>clearTimeout(J)},E=[l,w],s[15]=w,s[16]=l,s[17]=C,s[18]=E):(C=s[17],E=s[18]),y.useEffect(C,E);let T,$;s[19]!==x?(T=()=>()=>x(),$=[x],s[19]=x,s[20]=T,s[21]=$):(T=s[20],$=s[21]),y.useEffect(T,$);let A;s[22]!==m||s[23]!==j||s[24]!==_?(A=J=>{J.key==="Escape"?(J.preventDefault(),J.stopPropagation(),_()):J.key==="Enter"&&(J.preventDefault(),J.shiftKey?j(m-1):j(m+1))},s[22]=m,s[23]=j,s[24]=_,s[25]=A):A=s[25];const R=A;if(!o)return null;let P;s[26]===Symbol.for("react.memo_cache_sentinel")?(P=J=>c(J.target.value),s[26]=P):P=s[26];let z;s[27]!==R||s[28]!==l?(z=a.jsx(Go,{ref:h,value:l,onChange:P,onKeyDown:R,placeholder:"Find in conversation","aria-label":"Find in conversation",autoFocus:!0}),s[27]=R,s[28]=l,s[29]=z):z=s[29];const L=l?d.length>0?`${m+1}/${d.length}`:"0/0":"";let I;s[30]!==L?(I=a.jsx(Tr,{align:"inline-end",children:a.jsx("span",{className:"min-w-12 text-center text-xs tabular-nums",children:L})}),s[30]=L,s[31]=I):I=s[31];let M;s[32]!==z||s[33]!==I?(M=a.jsxs(Ko,{className:"w-64",children:[z,I]}),s[32]=z,s[33]=I,s[34]=M):M=s[34];let F;s[35]!==m||s[36]!==j?(F=()=>j(m-1),s[35]=m,s[36]=j,s[37]=F):F=s[37];const U=d.length===0,O=d.length>0?"hover:text-foreground":"cursor-default opacity-40";let D;s[38]!==O?(D=G("text-muted-foreground",O),s[38]=O,s[39]=D):D=s[39];let B;s[40]===Symbol.for("react.memo_cache_sentinel")?(B=a.jsx(ka,{"data-icon":"inline-start"}),s[40]=B):B=s[40];let q;s[41]!==F||s[42]!==U||s[43]!==D?(q=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",onClick:F,disabled:U,className:D,"aria-label":"Previous match",children:B}),s[41]=F,s[42]=U,s[43]=D,s[44]=q):q=s[44];let W;s[45]!==m||s[46]!==j?(W=()=>j(m+1),s[45]=m,s[46]=j,s[47]=W):W=s[47];const H=d.length===0,K=d.length>0?"hover:text-foreground":"cursor-default opacity-40";let Z;s[48]!==K?(Z=G("text-muted-foreground",K),s[48]=K,s[49]=Z):Z=s[49];let Y;s[50]===Symbol.for("react.memo_cache_sentinel")?(Y=a.jsx(_t,{"data-icon":"inline-start"}),s[50]=Y):Y=s[50];let X;s[51]!==W||s[52]!==H||s[53]!==Z?(X=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",onClick:W,disabled:H,className:Z,"aria-label":"Next match",children:Y}),s[51]=W,s[52]=H,s[53]=Z,s[54]=X):X=s[54];let ee;s[55]===Symbol.for("react.memo_cache_sentinel")?(ee=a.jsx(Mt,{"data-icon":"inline-start"}),s[55]=ee):ee=s[55];let te;s[56]!==_?(te=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",onClick:_,className:"text-muted-foreground hover:text-foreground","aria-label":"Close search",children:ee}),s[56]=_,s[57]=te):te=s[57];let se;return s[58]!==M||s[59]!==q||s[60]!==X||s[61]!==te?(se=a.jsxs("div",{className:"motion-slide-down-in absolute right-4 top-12 z-30 flex items-center gap-1 rounded-lg border bg-popover p-2 text-popover-foreground shadow-sm",children:[M,q,X,te]}),s[58]=M,s[59]=q,s[60]=X,s[61]=te,s[62]=se):se=s[62],se});function Cme(n){const e=n.parentNode;e&&(e.replaceChild(document.createTextNode(n.textContent||""),n),e.normalize())}const bI=[1,2,3,4,5,6,7,8,9],F2e=["General","View","Tools"],Em=[{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}},...bI.map(n=>({command:`device.switch.${n}`,label:`Switch to device ${n}`,description:n===1?"Jump to this machine (the local device)":`Jump to the ${n}${n===2?"nd":n===3?"rd":"th"} device in the switcher`,group:"General",defaultShortcut:{key:String(n),platformChord:!0}})),{command:"device.cycle",label:"Cycle devices",description:"Switch to the next device in the switcher",group:"General",defaultShortcut:{key:"0",platformChord:!0}}],vI="cogpit-keybindings";let oi=null;function yI(n=typeof navigator>"u"?"":navigator.platform){return/Mac|iPhone|iPad/i.test(n)}function xc(n){const e=n.toLowerCase();return e==="esc"?"escape":e}function _me(n){if(!n||typeof n!="object")return!1;const e=n;return e.doubleTapModifier==="mod"||typeof e.key=="string"&&e.key.length>0}function Hb(){if(oi)return oi;try{const n=localStorage.getItem(vI);if(!n)return oi={};const e=JSON.parse(n);if(!e||typeof e!="object")return oi={};const t={};for(const s of Em){const r=e[s.command];_me(r)&&(t[s.command]=r)}return oi=t}catch{return oi={}}}function Kb(n){oi=n;try{localStorage.setItem(vI,JSON.stringify(n))}catch{}typeof window<"u"&&window.dispatchEvent(new Event("cogpit-keybindings-changed"))}function nu(n){const e=Em.find(t=>t.command===n);if(!e)throw new Error(`Unknown keybinding command: ${n}`);return Hb()[n]??e.defaultShortcut}function U2e(){return Object.fromEntries(Em.map(n=>[n.command,nu(n.command)]))}function B2e(n,e){const t="doubleTapModifier"in e?{...e}:{...e,key:xc(e.key)};Kb({...Hb(),[n]:t})}function W2e(n){const e={...Hb()};delete e[n],Kb(e)}function q2e(){Kb({})}function V2e(n){return{key:xc(n.key),metaKey:n.metaKey||void 0,ctrlKey:n.ctrlKey||void 0,shiftKey:n.shiftKey||void 0,altKey:n.altKey||void 0}}function wI(n){const e=n;if(!e)return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||e.isContentEditable===!0}function on(n,e){const t=nu(n);return"doubleTapModifier"in t||xc(e.key)!==xc(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 Li(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 Eme(n){const e=yI();return"doubleTapModifier"in n?e?"Double ⌘":"Double Ctrl":n.modKey?e?`${n.shiftKey?"⇧":""}⌘${Li(n.key)}`:`Ctrl+${n.shiftKey?"Shift+":""}${Li(n.key)}`:n.platformChord?e?`⌃⌘${n.shiftKey?"⇧":""}${Li(n.key)}`:`Ctrl+Alt+${n.shiftKey?"Shift+":""}${Li(n.key)}`:e?`${n.ctrlKey?"⌃":""}${n.altKey?"⌥":""}${n.shiftKey?"⇧":""}${n.metaKey?"⌘":""}${Li(n.key)}`:[n.ctrlKey?"Ctrl":null,n.altKey?"Alt":null,n.shiftKey?"Shift":null,n.metaKey?"Meta":null,Li(n.key)].filter(Boolean).join("+")}function Qi(n){return Eme(nu(n))}function Q3(n){if("doubleTapModifier"in n)return[`double-tap:${n.doubleTapModifier}`];const e=(t,s,r,o)=>`${xc(n.key)}|${t}|${s}|${r}|${o}`;return n.modKey?[e(!0,!1,!!n.shiftKey,!!n.altKey),e(!1,!0,!!n.shiftKey,!!n.altKey)]:n.platformChord?[e(!0,!0,!!n.shiftKey,!1),e(!1,!0,!!n.shiftKey,!0)]:[e(!!n.metaKey,!!n.ctrlKey,!!n.shiftKey,!!n.altKey)]}function H2e(n,e){const t=new Set(Q3(n));return Em.find(s=>s.command!==e&&Q3(nu(s.command)).some(r=>t.has(r)))??null}function ej(n){return"doubleTapModifier"in nu(n)?yI()?"Meta":"Control":null}const Tme=bI.map(n=>`device.switch.${n}`),Ame="device.cycle";function Ime(n){const e=Tme.findIndex(t=>on(t,n));return e===-1?null:e+1}function Pme(n){return on(Ame,n)}const O1="cogpit:find-in-conversation",Tm=y.memo(function(e){const t=V.c(87),{searchInputRef:s,hasTodos:r,hasMore:o,isLoadingOlder:i,onLoadMore:l,mobileSearchOpen:c,onMobileSearchClose:u}=e,d=c===void 0?!1:c,{state:f,dispatch:m,isMobile:p}=Sn(),{session:h,sessionSource:g,rateLimit:x,permissions:b,isSubAgentView:w}=kt(),v=Nn("terminal"),{chat:j,scroll:k}=Wf(),{searchQuery:_}=f,{pendingMessages:N}=j,{chatScrollRef:S,observeChatContent:C,handleScroll:E,canScrollDown:T,scrollToBottomInstant:$,initialScrollDone:A}=k,R=y.useRef(null);let P;t[0]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{var we;return(we=R.current)==null?void 0:we.open()},t[0]=P):P=t[0];const z=P;let L,I;t[1]===Symbol.for("react.memo_cache_sentinel")?(L=()=>{const we=function($e){on("findInConversation",$e)&&($e.preventDefault(),z())};return window.addEventListener("keydown",we),window.addEventListener(O1,z),()=>{window.removeEventListener("keydown",we),window.removeEventListener(O1,z)}},I=[z],t[1]=L,t[2]=I):(L=t[1],I=t[2]),y.useEffect(L,I);let M,F;t[3]!==p||t[4]!==d||t[5]!==s?(M=()=>{!p||!d||requestAnimationFrame(()=>{var we;return(we=s.current)==null?void 0:we.focus()})},F=[p,d,s],t[3]=p,t[4]=d,t[5]=s,t[6]=M,t[7]=F):(M=t[6],F=t[7]),y.useEffect(M,F);let U;t[8]!==m||t[9]!==u?(U=()=>{m({type:"SET_SEARCH_QUERY",value:""}),u==null||u()},t[8]=m,t[9]=u,t[10]=U):U=t[10];const O=U,D=h;let B;t[11]!==x||t[12]!==g?(B=x&&g?{block:x,dirName:g.dirName,fileName:g.fileName}:null,t[11]=x,t[12]=g,t[13]=B):B=t[13];const q=B,W=D.turns.length>0||N.length===0;let H;t[14]!==O||t[15]!==m||t[16]!==p||t[17]!==d||t[18]!==s||t[19]!==_?(H=p&&d&&a.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b bg-background px-3 py-2",children:[a.jsxs(Ko,{className:"h-9 flex-1",children:[a.jsx(Go,{ref:s,value:_,onChange:we=>m({type:"SET_SEARCH_QUERY",value:we.target.value}),placeholder:"Search conversation...","aria-label":"Search conversation"}),a.jsx(Tr,{align:"inline-start",children:a.jsx(ss,{})})]}),a.jsx(Q,{variant:"ghost",size:"icon-sm",onClick:O,"aria-label":"Close conversation search",children:a.jsx(Mt,{"data-icon":"inline-start"})})]}),t[14]=O,t[15]=m,t[16]=p,t[17]=d,t[18]=s,t[19]=_,t[20]=H):H=t[20];let K;t[21]!==v||t[22]!==D.cwd||t[23]!==p||t[24]!==b.send||t[25]!==q?(K=q&&a.jsx("div",{className:G("shrink-0",!p&&"pt-10"),children:a.jsx(yme,{...q,cwd:D.cwd,terminal:v&&b.send})}),t[21]=v,t[22]=D.cwd,t[23]=p,t[24]=b.send,t[25]=q,t[26]=K):K=t[26];let Z;t[27]!==S?(Z=a.jsx(Nme,{ref:R,scrollContainerRef:S}),t[27]=S,t[28]=Z):Z=t[28];let Y;t[29]!==S||t[30]!==D?(Y=a.jsx(pme,{session:D,scrollContainerRef:S}),t[29]=S,t[30]=D,t[31]=Y):Y=t[31];const X=p&&"mobile-scroll";let ee;t[32]!==X?(ee=G("h-full overflow-x-hidden overflow-y-auto",X),t[32]=X,t[33]=ee):ee=t[33];let te;t[34]!==p||t[35]!==q?(te=p?"px-3 py-3 pb-5":G("mx-auto w-full max-w-[var(--chat-width)] px-6",q?"pt-4":"pt-14"),t[34]=p,t[35]=q,t[36]=te):te=t[36];let se;t[37]!==r||t[38]!==p?(se=p?void 0:{paddingBottom:`max(var(--session-footer-height, 0px), ${r?12:8}rem)`},t[37]=r,t[38]=p,t[39]=se):se=t[39];let J;t[40]!==S||t[41]!==o||t[42]!==A||t[43]!==i||t[44]!==l||t[45]!==W?(J=W&&a.jsx(ame,{chatScrollRef:S,hasMore:o,isLoadingOlder:i,pagingEnabled:A,onLoadMore:l}),t[40]=S,t[41]=o,t[42]=A,t[43]=i,t[44]=l,t[45]=W,t[46]=J):J=t[46];let ne,ie;t[47]===Symbol.for("react.memo_cache_sentinel")?(ne=a.jsx(Sme,{}),ie=a.jsx(yfe,{}),t[47]=ne,t[48]=ie):(ne=t[47],ie=t[48]);const ae=b.send&&!w;let oe;t[49]!==D.sessionId||t[50]!==D.turns||t[51]!==p||t[52]!==N||t[53]!==ae?(oe=a.jsx(mA,{sessionId:D.sessionId,turns:D.turns,pendingMessages:N,canManage:ae,isMobile:p}),t[49]=D.sessionId,t[50]=D.turns,t[51]=p,t[52]=N,t[53]=ae,t[54]=oe):oe=t[54];let ue;t[55]!==J||t[56]!==oe?(ue=a.jsxs(xI,{fallbackMessage:"Failed to render conversation timeline",children:[J,ne,ie,oe]}),t[55]=J,t[56]=oe,t[57]=ue):ue=t[57];let re;t[58]!==C||t[59]!==te||t[60]!==se||t[61]!==ue?(re=a.jsx("div",{ref:C,className:te,style:se,children:ue}),t[58]=C,t[59]=te,t[60]=se,t[61]=ue,t[62]=re):re=t[62];let de;t[63]!==S||t[64]!==E||t[65]!==ee||t[66]!==re?(de=a.jsx("div",{ref:S,onScroll:E,className:ee,children:re}),t[63]=S,t[64]=E,t[65]=ee,t[66]=re,t[67]=de):de=t[67];const fe=T?"opacity-100 scale-100":"opacity-0 scale-75 pointer-events-none",le=p?"right-3 bottom-3":"right-5";let ce;t[68]!==fe||t[69]!==le?(ce=G("absolute rounded-full shadow-sm transition-[opacity,transform] duration-200 ease-out active:scale-95",fe,le),t[68]=fe,t[69]=le,t[70]=ce):ce=t[70];let he;t[71]!==p?(he=p?void 0:{bottom:"calc(var(--session-footer-height, 0px) + 1.25rem)"},t[71]=p,t[72]=he):he=t[72];let ge;t[73]===Symbol.for("react.memo_cache_sentinel")?(ge=a.jsx(x8,{"data-icon":"inline-start"}),t[73]=ge):ge=t[73];let be;t[74]!==$||t[75]!==ce||t[76]!==he?(be=a.jsx(Q,{size:"icon",className:ce,style:he,onClick:$,"aria-label":"Scroll to bottom",children:ge}),t[74]=$,t[75]=ce,t[76]=he,t[77]=be):be=t[77];let ve;t[78]!==Z||t[79]!==Y||t[80]!==de||t[81]!==be?(ve=a.jsxs("div",{className:"relative min-h-0 flex-1",children:[Z,Y,de,be]}),t[78]=Z,t[79]=Y,t[80]=de,t[81]=be,t[82]=ve):ve=t[82];let Se;return t[83]!==K||t[84]!==ve||t[85]!==H?(Se=a.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[H,K,ve]}),t[83]=K,t[84]=ve,t[85]=H,t[86]=Se):Se=t[86],Se});function $me({open:n,onOpenChange:e,trigger:t,title:s,description:r,confirmLabel:o,destructive:i=!1,onConfirm:l}){const[c,u]=y.useState(!1),[d,f]=y.useState(null);function m(h){c||(f(null),e(h))}async function p(){u(!0),f(null);try{f(await l())}finally{u(!1)}}return a.jsxs(nb,{open:n,onOpenChange:m,children:[t&&a.jsx(Pte,{render:t}),a.jsxs(sb,{size:"sm",children:[a.jsxs(rb,{children:[a.jsx(ib,{children:s}),a.jsx(ab,{children:r})]}),d&&a.jsx(_o,{className:"text-center",children:d}),a.jsxs(ob,{children:[a.jsx(cb,{disabled:c,children:"Cancel"}),a.jsxs(lb,{variant:i?"destructive":"default",disabled:c,onClick:()=>void p(),children:[c&&a.jsx(St,{"data-icon":"inline-start",className:"animate-spin"}),o]})]})]})]})}function Rme(n){const e=V.c(21),{children:t,error:s,busy:r,saveLabel:o,onCancel:i,onSave:l,className:c}=n;let u;e[0]!==c?(u=G("flex flex-col gap-3 border-t px-3 py-3",c),e[0]=c,e[1]=u):u=e[1];let d;e[2]!==s?(d=s&&a.jsx(_o,{children:s}),e[2]=s,e[3]=d):d=e[3];let f;e[4]!==i?(f=a.jsx(Q,{variant:"outline",size:"sm",onClick:i,children:"Cancel"}),e[4]=i,e[5]=f):f=e[5];let m;e[6]!==r||e[7]!==o?(m=r?a.jsx(St,{"data-icon":"inline-start",className:"animate-spin"}):o,e[6]=r,e[7]=o,e[8]=m):m=e[8];let p;e[9]!==r||e[10]!==l||e[11]!==m?(p=a.jsx(Q,{size:"sm",disabled:r,onClick:l,children:m}),e[9]=r,e[10]=l,e[11]=m,e[12]=p):p=e[12];let h;e[13]!==f||e[14]!==p?(h=a.jsxs("div",{className:"flex justify-end gap-1.5",children:[f,p]}),e[13]=f,e[14]=p,e[15]=h):h=e[15];let g;return e[16]!==t||e[17]!==u||e[18]!==d||e[19]!==h?(g=a.jsxs("div",{className:u,children:[t,d,h]}),e[16]=t,e[17]=u,e[18]=d,e[19]=h,e[20]=g):g=e[20],g}const Ome={ArrowUp:-1,ArrowDown:1};function tj(n,e,t){const s=n.filter(r=>r!==e);return s.splice(t,0,e),s}function nj(n,e){return n.length===e.length&&n.every((t,s)=>t===e[s])}function Lme(n,e){const t=V.c(26),[s,r]=y.useState(null),[o,i]=y.useState(null);let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=new Map,t[0]=l):l=t[0];const c=y.useRef(l),u=y.useRef(null),d=y.useRef(0),f=y.useRef(null);let m;t[1]!==s||t[2]!==n?(m=s??[...n],t[1]=s,t[2]=n,t[3]=m):m=t[3];const p=m;let h;t[4]!==n||t[5]!==e?(h={ids:n,onCommit:e},t[4]=n,t[5]=e,t[6]=h):h=t[6];const g=y.useRef(h);let x;t[7]!==n||t[8]!==e?(x=()=>{g.current={ids:n,onCommit:e}},t[7]=n,t[8]=e,t[9]=x):x=t[9],y.useLayoutEffect(x);let b;t[10]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{const L=u.current,I=L&&c.current.get(L.id);if(!L||!I)return;I.style.transform="";const M=I.getBoundingClientRect().top;I.style.transform=`translateY(${d.current-L.grabOffset-M}px)`},t[10]=b):b=t[10];const w=b;let v;t[11]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{w()},t[11]=v):v=t[11];let j;t[12]!==s?(j=[s,w],t[12]=s,t[13]=j):j=t[13],y.useLayoutEffect(v,j);let k;t[14]===Symbol.for("react.memo_cache_sentinel")?(k=L=>I=>{I?c.current.set(L,I):c.current.delete(L)},t[14]=k):k=t[14];const _=k,N=y.useRef(null);let S;t[15]===Symbol.for("react.memo_cache_sentinel")?(S=L=>{var U;const I=u.current;if(!I)return;u.current=null,(U=N.current)==null||U.call(N),N.current=null;const M=c.current.get(I.id);M&&(M.style.transform="");const F=f.current;f.current=null,i(null),r(null),L&&F&&!nj(F,I.startOrder)&&g.current.onCommit(F)},t[15]=S):S=t[15];const C=S;let E,T;t[16]===Symbol.for("react.memo_cache_sentinel")?(T=()=>()=>{var L;return(L=N.current)==null?void 0:L.call(N)},E=[],t[16]=E,t[17]=T):(E=t[16],T=t[17]),y.useEffect(T,E);let $;t[18]===Symbol.for("react.memo_cache_sentinel")?($=L=>{const I=u.current;if(!I||I.pointerId!==L.pointerId)return;d.current=L.clientY;const M=f.current;if(!M)return;const F=M.filter(O=>{var B;if(O===I.id)return!1;const D=(B=c.current.get(O))==null?void 0:B.getBoundingClientRect();return!!D&&D.top+D.height/2<L.clientY}).length,U=tj(M,I.id,F);nj(U,M)||(f.current=U,r(U)),w()},t[18]=$):$=t[18];const A=$;let R;t[19]!==n||t[20]!==e?(R=L=>({onPointerDown:I=>{if(I.button!==0||u.current)return;const M=c.current.get(L);if(!M)return;d.current=I.clientY,u.current={id:L,pointerId:I.pointerId,grabOffset:I.clientY-M.getBoundingClientRect().top,startOrder:[...n]};const F=[...n];f.current=F,i(L),r(F);const U=D=>{D.pointerId===I.pointerId&&C(!0)},O=D=>{D.pointerId===I.pointerId&&C(!1)};window.addEventListener("pointermove",A),window.addEventListener("pointerup",U),window.addEventListener("pointercancel",O),N.current=()=>{window.removeEventListener("pointermove",A),window.removeEventListener("pointerup",U),window.removeEventListener("pointercancel",O)}},onKeyDown:I=>{const M=Ome[I.key];if(M===void 0)return;I.preventDefault();const F=n.indexOf(L),U=F+M;F===-1||U<0||U>=n.length||e(tj(n,L,U))}}),t[19]=n,t[20]=e,t[21]=R):R=t[21];const P=R;let z;return t[22]!==o||t[23]!==P||t[24]!==p?(z={order:p,draggingId:o,rowRef:_,handleProps:P},t[22]=o,t[23]=P,t[24]=p,t[25]=z):z=t[25],z}const L1="cogpit-devices-changed",SI="cogpit:devices-changed";function kI(n){typeof n.connectionRevision=="number"&&dR(n.id,n.connectionRevision)}function M1(n,e,t=!1){window.dispatchEvent(new CustomEvent(L1,{detail:{deviceId:n,connectionRevision:e,removed:t}}));try{localStorage.setItem(SI,JSON.stringify({deviceId:n,connectionRevision:e,removed:t,nonce:`${Date.now()}:${Math.random()}`}))}catch{}}function sj(n){kI(n),M1(n.id,n.connectionRevision)}function rj(n){const e=Kt();e!==Lt&&!n.some(t=>t.id===e)&&Xs(Lt)}function Xh(n,e=""){return`/api/hub/devices/${encodeURIComponent(n)}${e}`}function jI(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.version;if(typeof t=="string")return t}}function Mme(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.signIn;if(t==="account"||t==="password")return t}}function Fa({enabled:n=!0}={}){const[e,t]=y.useState([]),[s,r]=y.useState(!0),[o,i]=y.useState(()=>Kt()),l=y.useRef(0),c=y.useRef(Promise.resolve()),u=y.useRef(0),d=y.useCallback(async()=>{const w=++l.current;if(!n){t([]),r(!1);return}try{const v=await Ur("/api/hub/devices");if(v.status===403&&w===l.current&&rj([]),!v.ok)return;const j=await zs(v);if(w!==l.current)return;const k=Array.isArray(j==null?void 0:j.devices)?j.devices:[];for(const _ of k)kI(_);if(u.current>0)return;t(k),rj(k)}catch{}finally{w===l.current&&r(!1)}},[n]);y.useEffect(()=>{d()},[d]),y.useEffect(()=>{const w=()=>i(Kt()),v=()=>void d(),j=N=>{if(N.key===SI){try{const S=JSON.parse(N.newValue??"null");(S==null?void 0:S.removed)===!0&&typeof S.deviceId=="string"&&Kt()===S.deviceId&&Xs(Lt)}catch{}d()}},k=()=>{l.current+=1,t([]),r(!0),d()},_=()=>{l.current+=1,t([]),r(!1)};return window.addEventListener("cogpit-device-changed",w),window.addEventListener("popstate",w),window.addEventListener(L1,v),window.addEventListener("storage",j),window.addEventListener("cogpit-auth-changed",k),window.addEventListener("cogpit-identity-changed",k),window.addEventListener("cogpit-auth-required",_),()=>{window.removeEventListener("cogpit-device-changed",w),window.removeEventListener("popstate",w),window.removeEventListener(L1,v),window.removeEventListener("storage",j),window.removeEventListener("cogpit-auth-changed",k),window.removeEventListener("cogpit-identity-changed",k),window.removeEventListener("cogpit-auth-required",_)}},[d]);const f=y.useMemo(()=>o===Lt?void 0:e.find(w=>w.id===o),[e,o]),m=y.useCallback(async(w,v,j,k)=>{try{const _=await Ur("/api/hub/devices/probe",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:w,port:v,allowLocalTunnel:j,tls:k})}),N=await zs(_);return(N==null?void 0:N.ok)===!0&&N.hello?{ok:!0,hello:N.hello}:{ok:!1,code:(N==null?void 0:N.code)??"UNREACHABLE",error:typeof(N==null?void 0:N.error)=="string"?N.error:void 0}}catch{return{ok:!1,code:"UNREACHABLE",error:"Could not reach the device."}}},[]),p=y.useCallback(async w=>{try{const v=await Ur("/api/hub/devices",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(w)}),j=await zs(v);if(v.ok&&(j!=null&&j.device)){const k=j.device;return sj(k),{ok:!0,device:k}}return{ok:!1,code:(j==null?void 0:j.code)??"ERROR",error:typeof(j==null?void 0:j.error)=="string"?j.error:"Could not add the device."}}catch{return{ok:!1,code:"ERROR",error:"Could not add the device."}}},[]),h=y.useCallback(async(w,v)=>{try{const j=await Ur(Xh(w),{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(v)}),k=await zs(j);if(j.ok&&(k!=null&&k.device)){const _=k.device;return sj(_),{ok:!0,device:_}}return{ok:!1,code:(k==null?void 0:k.code)??"ERROR",error:typeof(k==null?void 0:k.error)=="string"?k.error:"Could not update the device."}}catch{return{ok:!1,code:"ERROR",error:"Could not update the device."}}},[]),g=y.useCallback(async w=>{try{const v=await Ur(Xh(w),{method:"DELETE"});if(v.ok)return Kt()===w&&Xs(Lt),M1(w,void 0,!0),{ok:!0};const j=await zs(v);return{ok:!1,error:typeof(j==null?void 0:j.error)=="string"?j.error:"Could not remove the device."}}catch{return{ok:!1,error:"Could not remove the device."}}},[]),x=y.useCallback(async w=>{const v=new Map(w.map((C,E)=>[C,E])),j=C=>v.get(C.id)??w.length;t(C=>[...C].sort((E,T)=>j(E)-j(T))),u.current+=1;const k=async()=>{try{const C=await Ur("/api/hub/devices/order",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({ids:w})}),E=await zs(C);return C.ok&&Array.isArray(E==null?void 0:E.devices)?{result:{ok:!0},devices:E.devices}:{result:{ok:!1,error:typeof(E==null?void 0:E.error)=="string"?E.error:"Could not reorder the devices."}}}catch{return{result:{ok:!1,error:"Could not reorder the devices."}}}},_=c.current.then(k);c.current=_.then(()=>{});const{result:N,devices:S}=await _;return u.current-=1,u.current===0&&(S?(t(S),M1("")):d()),N},[d]),b=y.useCallback(async w=>{try{const v=await Ur(Xh(w,"/test"),{method:"POST"});return await zs(v)??{ok:!1,reachable:!1,code:"UNREACHABLE"}}catch{return{ok:!1,reachable:!1,code:"UNREACHABLE"}}},[]);return{devices:e,activeDeviceId:o,activeDevice:f,loading:s,refresh:d,probe:m,addDevice:p,updateDevice:h,removeDevice:g,reorderDevices:x,testDevice:b}}const oj=s_.version,zme=19384,Dme=443,Fme=450,Ume=Qi("device.switch.1").replace(/1$/,"1–9"),Bme=new Set(["BAD_PASSWORD","PASSWORD_REQUIRED","USERNAME_REQUIRES_PASSWORD"]),Wme=new Set(["ACCOUNT_REFUSED"]);function qu(n){const e=n.trim(),t=/^https:\/\//i.test(e),s=e.replace(/^https?:\/\//i,"").replace(/\/.*$/,""),r=/^(.+):(\d+)$/.exec(s),o=r?r[1]:s,i=r?Number(r[2]):void 0;return t?{host:o,port:i,tls:!0}:{host:o,port:i}}function qme(n,e,t){if(n.ok){if(n.hello.signIn==="account"&&n.hello.setupRequired===!0)return{tone:"info",text:"Reachable server — finish its setup before adding it here."};if(n.hello.signIn!=="account"&&n.hello.networkAccess===!1)return{tone:"warn",text:"Cogpit is running but network access is disabled — enable it in that device's settings."};if(n.hello.configured===!1)return{tone:"info",text:"Reachable — this device hasn't finished setup yet and will show its setup screen."};const s=n.hello.name?` "${n.hello.name}"`:"",r=n.hello.version?` (v${n.hello.version})`:"";return{tone:"ok",text:`Found Cogpit${s}${r}.`}}switch(n.code){case"UNREACHABLE":return{tone:"error",text:`Can't reach ${e}:${t}. Is Cogpit running with network access enabled?`};case"LEGACY_NO_HELLO":return{tone:"error",text:"That Cogpit is too old for multi-device — update it."};case"NOT_COGPIT":return{tone:"error",text:"Something responded, but it isn't Cogpit."};case"SELF_ADD":return{tone:"error",text:"That's this machine."};default:return{tone:"error",text:n.error??"Could not reach the device."}}}const NI={ok:"text-success",warn:"text-warning",info:"text-info",error:"text-destructive"};function Vme(n){const e=V.c(10),{tone:t}=n,s=NI[t];let r;e[0]!==s?(r=G("size-3.5 shrink-0",s),e[0]=s,e[1]=r):r=e[1];const o=r;if(t==="ok"){let l;return e[2]!==o?(l=a.jsx(Pr,{"data-icon":"inline-start",className:o}),e[2]=o,e[3]=l):l=e[3],l}if(t==="warn"){let l;return e[4]!==o?(l=a.jsx(Ir,{"data-icon":"inline-start",className:o}),e[4]=o,e[5]=l):l=e[5],l}if(t==="info"){let l;return e[6]!==o?(l=a.jsx(Fn,{"data-icon":"inline-start",className:o}),e[6]=o,e[7]=l):l=e[7],l}let i;return e[8]!==o?(i=a.jsx(Bo,{"data-icon":"inline-start",className:o}),e[8]=o,e[9]=i):i=e[9],i}const Hme={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"};function Kme(n){const e=V.c(119),{device:t,onRename:s,onCredentials:r,onRemove:o,onTest:i,slot:l,rowRef:c,dragging:u,dragHandleProps:d}=n,[f,m]=y.useState(!1),[p,h]=y.useState(t.name),[g,x]=y.useState(!1),[b,w]=y.useState(t.username??""),[v,j]=y.useState(""),[k,_]=y.useState(null),[N,S]=y.useState(!1),[C,E]=y.useState(null);let T,$;e[0]!==t.name?(T=()=>{h(t.name)},$=[t.name],e[0]=t.name,e[1]=T,e[2]=$):(T=e[1],$=e[2]),y.useEffect(T,$);let A,R;e[3]!==t.username?(A=()=>{w(t.username??"")},R=[t.username],e[3]=t.username,e[4]=A,e[5]=R):(A=e[4],R=e[5]),y.useEffect(A,R);let P;e[6]!==t?(P=jI(t),e[6]=t,e[7]=P):P=e[7];const z=P,L=z!==void 0&&z!==oj;let I;e[8]!==t?(I=Mme(t),e[8]=t,e[9]=I):I=e[9];const M=I==="account",F=l<=9;let U;e[10]!==t.id||e[11]!==t.name||e[12]!==p||e[13]!==s?(U=async function(){const ye=p.trim();if(!ye||ye===t.name){m(!1),h(t.name);return}E("rename"),await s(t.id,ye),E(null),m(!1)},e[10]=t.id,e[11]=t.name,e[12]=p,e[13]=s,e[14]=U):U=e[14];const O=U;let D;e[15]!==v||e[16]!==b||e[17]!==t.auth||e[18]!==t.id||e[19]!==t.username||e[20]!==r?(D=async function(){const ye=b.trim(),Re=t.username??"",Ve=ye!==Re,He=v.length>0;if(!Ve&&!He){x(!1),j(""),_(null);return}if(t.auth==="none"&&!He){_("Enter a password when adding an account to an unauthenticated device.");return}const me={};Ve&&(me.username=ye||null),He&&(me.password=v),E("credentials"),_(null);const je=await r(t.id,me);if(E(null),!je.ok){_(je.error);return}x(!1),j("")},e[15]=v,e[16]=b,e[17]=t.auth,e[18]=t.id,e[19]=t.username,e[20]=r,e[21]=D):D=e[21];const B=D,q=u&&"relative z-10 shadow-lg";let W;e[22]!==q?(W=G("rounded-lg border bg-card",q),e[22]=q,e[23]=W):W=e[23];const H=`Reorder ${t.name}`;let K;e[24]===Symbol.for("react.memo_cache_sentinel")?(K=a.jsx(b8,{className:"size-4"}),e[24]=K):K=e[24];let Z;e[25]!==d||e[26]!==H?(Z=a.jsx("button",{type:"button","aria-label":H,title:"Drag to reorder (or use ↑ ↓)",className:"-ml-1 flex size-6 shrink-0 cursor-grab touch-none items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring active:cursor-grabbing",...d,children:K}),e[25]=d,e[26]=H,e[27]=Z):Z=e[27];let Y;e[28]!==F||e[29]!==l?(Y=F?`${Qi(`device.switch.${l}`)} opens this device`:"No shortcut",e[28]=F,e[29]=l,e[30]=Y):Y=e[30];const X=F&&l;let ee;e[31]!==Y||e[32]!==X?(ee=a.jsx("span",{className:"w-4 shrink-0 text-center font-mono text-xs text-muted-foreground",title:Y,children:X}),e[31]=Y,e[32]=X,e[33]=ee):ee=e[33];const te=`Status: ${t.runtime.authState}`,se=Hme[t.runtime.authState];let J;e[34]!==se?(J=G("size-2 shrink-0 rounded-full",se),e[34]=se,e[35]=J):J=e[35];let ne;e[36]!==te||e[37]!==J?(ne=a.jsx("span",{"aria-label":te,className:J}),e[36]=te,e[37]=J,e[38]=ne):ne=e[38];let ie;e[39]!==t.auth||e[40]!==t.name||e[41]!==f||e[42]!==p||e[43]!==O||e[44]!==L||e[45]!==z?(ie=f?a.jsx(On,{value:p,autoFocus:!0,"aria-label":`Rename ${t.name}`,onChange:We=>h(We.target.value),onKeyDown:We=>{We.key==="Enter"&&O(),We.key==="Escape"&&(m(!1),h(t.name))},onBlur:()=>void O(),className:"h-6 text-sm"}):a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:"truncate text-sm text-foreground",children:t.name}),z&&a.jsxs("span",{className:G("shrink-0 font-mono text-xs",L?"text-warning":"text-muted-foreground"),title:L?`Device runs v${z}; hub runs v${oj}`:void 0,children:["v",z,L&&" ≠ hub"]}),t.auth==="none"&&a.jsx(Fe,{variant:"secondary",children:"Unauthenticated"})]}),e[39]=t.auth,e[40]=t.name,e[41]=f,e[42]=p,e[43]=O,e[44]=L,e[45]=z,e[46]=ie):ie=e[46];const ae=t.tls?"https://":"";let oe;e[47]!==t.host||e[48]!==t.port||e[49]!==ae?(oe=a.jsxs("span",{className:"truncate font-mono text-xs text-muted-foreground",children:[ae,t.host,":",t.port]}),e[47]=t.host,e[48]=t.port,e[49]=ae,e[50]=oe):oe=e[50];let ue;e[51]!==M||e[52]!==t.username?(ue=t.username?a.jsxs("span",{className:"truncate text-xs text-muted-foreground",title:t.username,children:["Account: ",t.username]}):M?a.jsx("span",{className:"text-xs text-warning",children:"Account not configured"}):null,e[51]=M,e[52]=t.username,e[53]=ue):ue=e[53];let re;e[54]!==ie||e[55]!==oe||e[56]!==ue?(re=a.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[ie,oe,ue]}),e[54]=ie,e[55]=oe,e[56]=ue,e[57]=re):re=e[57];const de=`Re-test ${t.name}`,fe=C==="test";let le;e[58]!==t.id||e[59]!==i?(le=async()=>{E("test"),await i(t.id),E(null)},e[58]=t.id,e[59]=i,e[60]=le):le=e[60];const ce=C==="test"&&"animate-spin";let he;e[61]!==ce?(he=G(ce),e[61]=ce,e[62]=he):he=e[62];let ge;e[63]!==he?(ge=a.jsx(Fn,{"data-icon":"inline-start",className:he}),e[63]=he,e[64]=ge):ge=e[64];let be;e[65]!==de||e[66]!==fe||e[67]!==le||e[68]!==ge?(be=a.jsx(Q,{variant:"ghost",size:"icon-sm","aria-label":de,disabled:fe,onClick:le,children:ge}),e[65]=de,e[66]=fe,e[67]=le,e[68]=ge,e[69]=be):be=e[69];const ve=`Edit account for ${t.name}`;let Se;e[70]!==t.username?(Se=()=>{x(Gme),w(t.username??""),j(""),_(null)},e[70]=t.username,e[71]=Se):Se=e[71];let we;e[72]===Symbol.for("react.memo_cache_sentinel")?(we=a.jsx(v8,{"data-icon":"inline-start"}),e[72]=we):we=e[72];let Ee;e[73]!==ve||e[74]!==Se?(Ee=a.jsx(Q,{variant:"ghost",size:"icon-sm","aria-label":ve,onClick:Se,children:we}),e[73]=ve,e[74]=Se,e[75]=Ee):Ee=e[75];const $e=`Rename ${t.name}`;let Be,qe;e[76]===Symbol.for("react.memo_cache_sentinel")?(Be=()=>m(!0),qe=a.jsx(yr,{"data-icon":"inline-start"}),e[76]=Be,e[77]=qe):(Be=e[76],qe=e[77]);let ze;e[78]!==$e?(ze=a.jsx(Q,{variant:"ghost",size:"icon-sm","aria-label":$e,onClick:Be,children:qe}),e[78]=$e,e[79]=ze):ze=e[79];const Ie=`Remove ${t.name}`;let Me;e[80]===Symbol.for("react.memo_cache_sentinel")?(Me=a.jsx(kf,{"data-icon":"inline-start"}),e[80]=Me):Me=e[80];let Ue;e[81]!==Ie?(Ue=a.jsx(Q,{variant:"ghost",size:"icon-sm","aria-label":Ie,className:"text-destructive hover:bg-destructive/10 hover:text-destructive",children:Me}),e[81]=Ie,e[82]=Ue):Ue=e[82];let De;e[83]!==t.name?(De=a.jsxs(a.Fragment,{children:["Remove ",t.name,"?"]}),e[83]=t.name,e[84]=De):De=e[84];let Ke;e[85]!==t.id||e[86]!==o?(Ke=async()=>(await o(t.id),null),e[85]=t.id,e[86]=o,e[87]=Ke):Ke=e[87];let Ne;e[88]!==N||e[89]!==Ue||e[90]!==De||e[91]!==Ke?(Ne=a.jsx($me,{open:N,onOpenChange:S,trigger:Ue,title:De,description:"This device will disappear from Cogpit. You can add it again later.",confirmLabel:"Remove device",destructive:!0,onConfirm:Ke}),e[88]=N,e[89]=Ue,e[90]=De,e[91]=Ke,e[92]=Ne):Ne=e[92];let Ae;e[93]!==be||e[94]!==Ee||e[95]!==ze||e[96]!==Ne?(Ae=a.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[be,Ee,ze,Ne]}),e[93]=be,e[94]=Ee,e[95]=ze,e[96]=Ne,e[97]=Ae):Ae=e[97];let Qe;e[98]!==Z||e[99]!==ee||e[100]!==ne||e[101]!==re||e[102]!==Ae?(Qe=a.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2",children:[Z,ee,ne,re,Ae]}),e[98]=Z,e[99]=ee,e[100]=ne,e[101]=re,e[102]=Ae,e[103]=Qe):Qe=e[103];let Je;e[104]!==C||e[105]!==k||e[106]!==v||e[107]!==b||e[108]!==t.id||e[109]!==t.name||e[110]!==t.username||e[111]!==g||e[112]!==B?(Je=g&&a.jsxs(Rme,{error:k,busy:C==="credentials",saveLabel:"Save account",onCancel:()=>{x(!1),w(t.username??""),j(""),_(null)},onSave:()=>void B(),children:[a.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[a.jsxs(fn,{children:[a.jsxs(mn,{htmlFor:`device-username-${t.id}`,children:["Username ",a.jsx("span",{className:"text-muted-foreground/60",children:"(account sign-in)"})]}),a.jsx(On,{id:`device-username-${t.id}`,"aria-label":`Username for ${t.name}`,value:b,onChange:We=>w(We.target.value),placeholder:"Leave empty for password-only auth",autoComplete:"off",spellCheck:!1})]}),a.jsxs(fn,{children:[a.jsxs(mn,{htmlFor:`device-password-${t.id}`,children:["New password ",a.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),a.jsx(On,{id:`device-password-${t.id}`,"aria-label":`New password for ${t.name}`,type:"password",value:v,onChange:We=>j(We.target.value),placeholder:"Leave blank to keep the stored password",autoComplete:"new-password"})]})]}),t.username&&b.trim()===""&&a.jsx("p",{className:"text-xs text-warning",children:"Clearing the username switches this device back to password-only authentication."})]}),e[104]=C,e[105]=k,e[106]=v,e[107]=b,e[108]=t.id,e[109]=t.name,e[110]=t.username,e[111]=g,e[112]=B,e[113]=Je):Je=e[113];let ke;return e[114]!==c||e[115]!==W||e[116]!==Qe||e[117]!==Je?(ke=a.jsxs("div",{ref:c,className:W,children:[Qe,Je]}),e[114]=c,e[115]=W,e[116]=Qe,e[117]=Je,e[118]=ke):ke=e[118],ke}function Gme(n){return!n}function CI(n){var dt,zt;const e=V.c(121),{open:t,initialMode:s,onClose:r}=n,{devices:o,refresh:i,probe:l,addDevice:c,updateDevice:u,removeDevice:d,reorderDevices:f,testDevice:m}=Fa(),[p,h]=y.useState(""),[g,x]=y.useState(""),[b,w]=y.useState(""),[v,j]=y.useState(""),[k,_]=y.useState(!1),[N,S]=y.useState(!1),[C,E]=y.useState(null),[T,$]=y.useState(!1),[A,R]=y.useState(null),P=y.useRef(null),z=y.useRef(0);let L,I;e[0]!==s||e[1]!==t?(L=()=>{t&&(h(""),x(""),w(""),j(""),_(!1),S(!1),E(null),R(null),s==="add"&&requestAnimationFrame(()=>{var st;return(st=P.current)==null?void 0:st.focus()}))},I=[t,s],e[0]=s,e[1]=t,e[2]=L,e[3]=I):(L=e[2],I=e[3]),y.useEffect(L,I);let M;e[4]!==k||e[5]!==g||e[6]!==l?(M=async()=>{const{host:st,port:Et,tls:Tt}=qu(g);if(!st){E(null),S(!1);return}const Jt=z.current=z.current+1;S(!0);const At=await l(st,Et,k,Tt);Jt===z.current&&(E({...qme(At,st,Et??(Tt?Dme:zme)),hello:At.ok?At.hello:void 0}),S(!1))},e[4]=k,e[5]=g,e[6]=l,e[7]=M):M=e[7];const F=M;let U,O;e[8]!==g||e[9]!==t||e[10]!==F?(U=()=>{if(!t)return;if(!qu(g).host){E(null),S(!1);return}const st=window.setTimeout(()=>void F(),Fme);return()=>window.clearTimeout(st)},O=[t,g,F],e[8]=g,e[9]=t,e[10]=F,e[11]=U,e[12]=O):(U=e[11],O=e[12]),y.useEffect(U,O);const D=((dt=C==null?void 0:C.hello)==null?void 0:dt.signIn)==="account",B=D&&((zt=C==null?void 0:C.hello)==null?void 0:zt.setupRequired)===!0,q=D||!k;let W;e:{if(T){W=!1;break e}if(!qu(g).host){W=!1;break e}if(N||!C){W=!1;break e}if(B){W=!1;break e}if(q&&!v){W=!1;break e}if(D&&!b.trim()){W=!1;break e}if((C==null?void 0:C.tone)==="error"){W=!1;break e}W=!0}const H=W;let K;e[13]!==c||e[14]!==k||e[15]!==q||e[16]!==g||e[17]!==p||e[18]!==r||e[19]!==v||e[20]!==D||e[21]!==b?(K=async function(){const{host:Et,port:Tt,tls:Jt}=qu(g);if(!Et)return;$(!0),R(null);const At=await c({name:p.trim()||void 0,host:Et,port:Tt,tls:Jt,username:D?b.trim():void 0,password:q&&v||void 0,allowLocalTunnel:k});if($(!1),At.ok){r(),Xs(At.device.id);return}R({field:Wme.has(At.code)?"username":Bme.has(At.code)?"password":"host",message:At.error})},e[13]=c,e[14]=k,e[15]=q,e[16]=g,e[17]=p,e[18]=r,e[19]=v,e[20]=D,e[21]=b,e[22]=K):K=e[22];const Z=K;let Y;e[23]!==u?(Y=async(st,Et)=>{await u(st,{name:Et})},e[23]=u,e[24]=Y):Y=e[24];const X=Y;let ee;e[25]!==d?(ee=async st=>{await d(st)},e[25]=d,e[26]=ee):ee=e[26];const te=ee;let se;e[27]!==o?(se=o.map(Zme),e[27]=o,e[28]=se):se=e[28];const{order:J,draggingId:ne,rowRef:ie,handleProps:ae}=Lme(se,f);let oe;e[29]!==i||e[30]!==m?(oe=async st=>{await m(st),await i()},e[29]=i,e[30]=m,e[31]=oe):oe=e[31];const ue=oe;let re;e[32]!==r?(re=st=>{st||r()},e[32]=r,e[33]=re):re=e[33];let de;e[34]===Symbol.for("react.memo_cache_sentinel")?(de=a.jsxs(io,{children:[a.jsx(rr,{children:"Devices"}),a.jsxs(or,{children:["Control another Cogpit device from here. The active device is chosen from the header switcher — ",Ume," jumps between devices. Drag a device by its handle to change its number; this machine is always 1."]})]}),e[34]=de):de=e[34];let fe;e[35]!==o||e[36]!==ne||e[37]!==ae||e[38]!==te||e[39]!==X||e[40]!==ue||e[41]!==J||e[42]!==ie||e[43]!==u?(fe=o.length>0&&a.jsx("div",{className:"flex flex-col gap-2",children:J.map((st,Et)=>{const Tt=o.find(Jt=>Jt.id===st);return Tt?a.jsx(Kme,{device:Tt,slot:Et+2,rowRef:ie(Tt.id),dragging:ne===Tt.id,dragHandleProps:ae(Tt.id),onRename:X,onCredentials:u,onRemove:te,onTest:ue},Tt.id):null})}),e[35]=o,e[36]=ne,e[37]=ae,e[38]=te,e[39]=X,e[40]=ue,e[41]=J,e[42]=ie,e[43]=u,e[44]=fe):fe=e[44];let le;e[45]===Symbol.for("react.memo_cache_sentinel")?(le=a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Sr,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),a.jsx("p",{className:"text-sm font-medium text-foreground",children:"Add a device"})]}),e[45]=le):le=e[45];const ce=(A==null?void 0:A.field)==="host";let he,ge;e[46]===Symbol.for("react.memo_cache_sentinel")?(he=a.jsx(mn,{htmlFor:"device-host",children:"Host"}),ge=a.jsx(ia,{children:"Enter a local address or an HTTPS URL."}),e[46]=he,e[47]=ge):(he=e[46],ge=e[47]);let be;e[48]===Symbol.for("react.memo_cache_sentinel")?(be=st=>{z.current=z.current+1,x(st.target.value),w(""),E(null),R(null)},e[48]=be):be=e[48];let ve;e[49]!==F?(ve=()=>void F(),e[49]=F,e[50]=ve):ve=e[50];let Se;e[51]!==g||e[52]!==ve?(Se=a.jsx(On,{id:"device-host",ref:P,value:g,onChange:be,onBlur:ve,placeholder:"192.168.1.42, my-mac.local:19384 or https://cogpit.example.com",spellCheck:!1,autoComplete:"off"}),e[51]=g,e[52]=ve,e[53]=Se):Se=e[53];let we;e[54]!==N?(we=N&&a.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[a.jsx(St,{"data-icon":"inline-start",className:"size-3.5 animate-spin"})," Checking device…"]}),e[54]=N,e[55]=we):we=e[55];let Ee;e[56]!==C||e[57]!==N?(Ee=!N&&C&&a.jsxs("p",{role:"status",className:G("flex items-center gap-1.5 text-xs",NI[C.tone]),children:[a.jsx(Vme,{tone:C.tone}),C.text]}),e[56]=C,e[57]=N,e[58]=Ee):Ee=e[58];let $e;e[59]!==A?($e=(A==null?void 0:A.field)==="host"&&a.jsx(_o,{children:A.message}),e[59]=A,e[60]=$e):$e=e[60];let Be;e[61]!==ce||e[62]!==Se||e[63]!==we||e[64]!==Ee||e[65]!==$e?(Be=a.jsxs(fn,{"data-invalid":ce,children:[he,ge,Se,we,Ee,$e]}),e[61]=ce,e[62]=Se,e[63]=we,e[64]=Ee,e[65]=$e,e[66]=Be):Be=e[66];let qe;e[67]===Symbol.for("react.memo_cache_sentinel")?(qe=a.jsxs(mn,{htmlFor:"device-name",children:["Name ",a.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),e[67]=qe):qe=e[67];let ze;e[68]===Symbol.for("react.memo_cache_sentinel")?(ze=st=>h(st.target.value),e[68]=ze):ze=e[68];let Ie;e[69]!==p?(Ie=a.jsxs(fn,{children:[qe,a.jsx(On,{id:"device-name",value:p,onChange:ze,placeholder:"Defaults to the device's own name"})]}),e[69]=p,e[70]=Ie):Ie=e[70];let Me;e[71]!==A||e[72]!==D||e[73]!==b?(Me=D&&a.jsxs(fn,{"data-invalid":(A==null?void 0:A.field)==="username",children:[a.jsx(mn,{htmlFor:"device-username",children:"Username"}),a.jsx(On,{id:"device-username",value:b,onChange:st=>w(st.target.value),placeholder:"Account username",autoComplete:"username",spellCheck:!1}),a.jsx(ia,{children:"Requests through this hub act as this account on that server."}),(A==null?void 0:A.field)==="username"&&a.jsx(_o,{children:A.message})]}),e[71]=A,e[72]=D,e[73]=b,e[74]=Me):Me=e[74];let Ue;e[75]!==q||e[76]!==v||e[77]!==A||e[78]!==D?(Ue=q&&a.jsxs(fn,{"data-invalid":(A==null?void 0:A.field)==="password",children:[a.jsx(mn,{htmlFor:"device-password",children:"Password"}),a.jsx(On,{id:"device-password",type:"password",value:v,onChange:st=>j(st.target.value),placeholder:D?"Password for that account":"Network access password for that device",autoComplete:D?"current-password":"off"}),(A==null?void 0:A.field)==="password"&&a.jsx(_o,{children:A.message})]}),e[75]=q,e[76]=v,e[77]=A,e[78]=D,e[79]=Ue):Ue=e[79];let De;e[80]!==Be||e[81]!==Ie||e[82]!==Me||e[83]!==Ue?(De=a.jsxs(Ta,{children:[Be,Ie,Me,Ue]}),e[80]=Be,e[81]=Ie,e[82]=Me,e[83]=Ue,e[84]=De):De=e[84];let Ke;e[85]===Symbol.for("react.memo_cache_sentinel")?(Ke=st=>{z.current=z.current+1,_(st===!0),E(null),R(null)},e[85]=Ke):Ke=e[85];let Ne;e[86]!==k?(Ne=a.jsx(uT,{id:"device-local-tunnel",name:"device-local-tunnel",checked:k,onCheckedChange:Ke}),e[86]=k,e[87]=Ne):Ne=e[87];const Ae=D?"":" — no password";let Qe;e[88]!==Ae?(Qe=a.jsxs(mn,{htmlFor:"device-local-tunnel",children:["This is a local tunnel",Ae]}),e[88]=Ae,e[89]=Qe):Qe=e[89];let Je;e[90]!==Ne||e[91]!==Qe?(Je=a.jsxs(fn,{orientation:"horizontal",children:[Ne,Qe]}),e[90]=Ne,e[91]=Qe,e[92]=Je):Je=e[92];let ke;e[93]!==k||e[94]!==D?(ke=k&&a.jsxs(jt,{className:"border-warning/40 bg-warning/10 text-warning",children:[a.jsx(ix,{}),a.jsx(Rt,{className:"text-warning",children:D?a.jsx(a.Fragment,{children:"The loopback address is allowed because the tunnel is local; account sign-in still applies."}):a.jsxs(a.Fragment,{children:["Traffic to this device is forwarded ",a.jsx("strong",{children:"unauthenticated"}),". Only use this for an SSH tunnel or another already-secured local channel."]})})]}),e[93]=k,e[94]=D,e[95]=ke):ke=e[95];let We;e[96]!==r?(We=a.jsx(Q,{variant:"outline",onClick:r,children:"Close"}),e[96]=r,e[97]=We):We=e[97];const ye=!H;let Re;e[98]!==Z?(Re=()=>void Z(),e[98]=Z,e[99]=Re):Re=e[99];let Ve;e[100]!==T?(Ve=T?a.jsxs(a.Fragment,{children:[a.jsx(St,{"data-icon":"inline-start",className:"size-4 animate-spin"})," Adding…"]}):"Add device",e[100]=T,e[101]=Ve):Ve=e[101];let He;e[102]!==ye||e[103]!==Re||e[104]!==Ve?(He=a.jsx(Q,{disabled:ye,onClick:Re,children:Ve}),e[102]=ye,e[103]=Re,e[104]=Ve,e[105]=He):He=e[105];let me;e[106]!==We||e[107]!==He?(me=a.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[We,He]}),e[106]=We,e[107]=He,e[108]=me):me=e[108];let je;e[109]!==De||e[110]!==Je||e[111]!==ke||e[112]!==me?(je=a.jsxs("div",{className:"flex flex-col gap-4 border-t pt-4",children:[le,De,Je,ke,me]}),e[109]=De,e[110]=Je,e[111]=ke,e[112]=me,e[113]=je):je=e[113];let Xe;e[114]!==fe||e[115]!==je?(Xe=a.jsxs(sr,{className:"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-xl",children:[de,fe,je]}),e[114]=fe,e[115]=je,e[116]=Xe):Xe=e[116];let tt;return e[117]!==t||e[118]!==re||e[119]!==Xe?(tt=a.jsx(nr,{open:t,onOpenChange:re,children:Xe}),e[117]=t,e[118]=re,e[119]=Xe,e[120]=tt):tt=e[120],tt}function Zme(n){return n.id}const Yme="Browsing folders needs a newer Cogpit on this machine.";async function _I(n){const e=await Tl(n,`Request failed (${n.status})`);return new Error(n.status===404&&e==="Not found"?Yme:e)}async function Xme(n,e){const t=await Ce(n?`/api/folders?path=${encodeURIComponent(n)}`:"/api/folders",{signal:e});if(!t.ok)throw await _I(t);return await t.json()}async function Jme(n,e){const t=await is("/api/folders",{parent:n,name:e});if(!t.ok)throw await _I(t);return(await t.json()).path}function Qme(n,e=null){const t=epe(n);if(e===null)return t;const s=o=>o.replace(/[\\/]+$/,""),r=t.findIndex(o=>s(o.path)===s(e));return r===-1?t:t.slice(r)}function epe(n){const e=n.split(/[\\/]+/).filter(Boolean);let t,s,r;if(n.startsWith("\\\\")){const[o="",i="",...l]=e;t={label:`\\\\${o}\\${i}`,path:`\\\\${o}\\${i}\\`},s=l,r="\\"}else if(/^[a-z]:/i.test(n)){const[o="",...i]=e;t={label:o,path:`${o}\\`},s=i,r="\\"}else t={label:"/",path:"/"},s=e,r="/";return[t,...s.map((o,i)=>({label:o,path:t.path+s.slice(0,i+1).join(r)}))]}const z1="cogpit-browse-folders";function EI(){window.dispatchEvent(new Event(z1))}function tpe(n){return window.addEventListener(z1,n),()=>window.removeEventListener(z1,n)}const npe=y.lazy(()=>nt(()=>import("./ProjectSwitcherModal-DB-xcVjM.js"),__vite__mapDeps([25,1,2,3,4])).then(n=>({default:n.ProjectSwitcherModal})));function TI(n){const e=V.c(8),{onNewSession:t,onNewFolder:s,defaultAgentKind:r}=n,[o,i]=y.useState(null);let l,c;if(e[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>tpe(()=>i(!0)),c=[],e[0]=l,e[1]=c):(l=e[0],c=e[1]),y.useEffect(l,c),o===null)return null;let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>i(!1),e[2]=u):u=e[2];let d;return e[3]!==r||e[4]!==s||e[5]!==t||e[6]!==o?(d=a.jsx(y.Suspense,{fallback:null,children:a.jsx(npe,{open:o,onClose:u,onNewSession:t,onNewFolder:s,defaultAgentKind:r,currentProjectDirName:null,currentProjectCwd:null,initialView:"folders"})}),e[3]=r,e[4]=s,e[5]=t,e[6]=o,e[7]=d):d=e[7],d}const spe=/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/;function ij(n,e){if(!spe.test(e))throw new Error(`Invalid Cogpit ${n} id "${e}"`)}function xo(n,e){return`${n}.${e}`}function rpe(n){const e=new Set,t=new Set,s=[];for(const r of n){if(ij("plugin",r.id),e.has(r.id))throw new Error(`Duplicate Cogpit plugin id "${r.id}"`);e.add(r.id);for(const o of r.workspacePanels??[]){ij("panel",o.id);const i=xo(r.id,o.id);if(t.has(i))throw new Error(`Duplicate Cogpit workspace panel id "${i}"`);t.add(i),s.push({...o,id:i,pluginId:r.id,localId:o.id})}}return s.sort((r,o)=>(r.order??100)-(o.order??100)||r.title.localeCompare(o.title))}function Gn({className:n,...e}){return a.jsx("div",{"data-slot":"skeleton",className:G("rounded-md bg-muted motion-safe:animate-in motion-safe:fade-in-0 motion-safe:duration-200 motion-safe:ease-out motion-reduce:animate-none",n),...e})}const ii="cogpit",Ot={worktrees:xo(ii,"worktrees"),projectFiles:xo(ii,"project-files"),browser:xo(ii,"browser"),fileChanges:xo(ii,"file-changes"),sessionInfo:xo(ii,"session-info"),crew:xo(ii,"crew")},ope=y.lazy(()=>nt(()=>import("./CommandPaletteHost-Dig9sRnN.js"),__vite__mapDeps([26,1,2,3,4])).then(n=>({default:n.CommandPaletteHost}))),ipe=y.lazy(()=>nt(()=>import("./index-utwOdTFc.js"),__vite__mapDeps([27,1,28,2,29,3,4])).then(n=>({default:n.ConfigDialog}))),ape=y.lazy(()=>nt(()=>import("./KeyboardShortcutsDialog-CjA8MBfY.js"),__vite__mapDeps([30,1,2,3,4])).then(n=>({default:n.KeyboardShortcutsDialog}))),lpe=y.lazy(()=>nt(()=>import("./ProjectSwitcherModal-DB-xcVjM.js"),__vite__mapDeps([25,1,2,3,4])).then(n=>({default:n.ProjectSwitcherModal}))),cpe=y.lazy(()=>nt(()=>import("./ThemeSelectorModal-B8nIlHO2.js"),__vite__mapDeps([31,1,2,3,4])).then(n=>({default:n.ThemeSelectorModal})));function upe(n){const e=V.c(131),{navigation:t,project:s,chrome:r}=n,{state:o,config:i,theme:l}=Sn(),{session:c,sessionSource:u}=kt(),{devices:d,activeDeviceId:f}=Fa(),[m,p]=y.useState(null);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=xt("manageDevices"),e[0]=h):h=e[0];const g=h,x=qx(),b=o.mainView==="extension"?o.extensionViewId:null;let w;e[1]!==o.pendingCwd||e[2]!==o.pendingDirName?(w=o.pendingCwd??(o.pendingDirName?xs(o.pendingDirName):null),e[1]=o.pendingCwd,e[2]=o.pendingDirName,e[3]=w):w=e[3];const v=w,j=(u==null?void 0:u.dirName)??o.pendingDirName??o.dashboardProject??null,k=r.onKeyboardShortcutsOpenChange;let _,N;e[4]!==k?(_=()=>{const me=function(Xe){on("keyboardShortcuts",Xe)&&(wI(document.activeElement)||(Xe.preventDefault(),k(!0)))};return window.addEventListener("keydown",me),()=>window.removeEventListener("keydown",me)},N=[k],e[4]=k,e[5]=_,e[6]=N):(_=e[5],N=e[6]),y.useEffect(_,N);const S=f===Lt;let C;e[7]!==S?(C={id:Lt,name:"This machine",isLocal:!0,isActive:S},e[7]=S,e[8]=C):C=e[8];let E;if(e[9]!==f||e[10]!==d||e[11]!==C){let me;e[13]!==f?(me=je=>({id:je.id,name:je.name,isLocal:!1,isActive:je.id===f}),e[13]=f,e[14]=me):me=e[14],E=[C,...d.map(me)],e[9]=f,e[10]=d,e[11]=C,e[12]=E}else E=e[12];const T=E,{openMainView:$,closeMainView:A}=t.panels;let R;if(e[15]!==A||e[16]!==x||e[17]!==$||e[18]!==b){let me;e[20]!==A||e[21]!==$||e[22]!==b?(me=je=>{const Xe=je.id===b;return{id:`main-view-${je.id}`,label:`${Xe?"Close":"Open"} ${je.label}`,keywords:je.keywords,icon:je.icon,onSelect:Xe?A:()=>$(je.id)}},e[20]=A,e[21]=$,e[22]=b,e[23]=me):me=e[23],R=x.map(me),e[15]=A,e[16]=x,e[17]=$,e[18]=b,e[19]=R}else R=e[19];const P=R;let z;e[24]!==c||e[25]!==(u==null?void 0:u.agentKind)||e[26]!==(u==null?void 0:u.dirName)?(z=()=>{if(!c)return;const me=(u==null?void 0:u.agentKind)??un((u==null?void 0:u.dirName)??null);Pf(jx(me,c.sessionId,c.cwd))},e[24]=c,e[25]=u==null?void 0:u.agentKind,e[26]=u==null?void 0:u.dirName,e[27]=z):z=e[27];const L=z,I=dpe,M=r.processPanel,F=r.workflowsPanel,U=r.undoDialog,O=r.branchModal,D=i.claudeDir??"";let B;e[28]!==i.handleCloseConfigDialog||e[29]!==i.handleConfigSaved||e[30]!==i.showConfigDialog||e[31]!==D?(B=a.jsx(y.Suspense,{fallback:null,children:a.jsx(ipe,{open:i.showConfigDialog,currentPath:D,onClose:i.handleCloseConfigDialog,onSaved:i.handleConfigSaved})}),e[28]=i.handleCloseConfigDialog,e[29]=i.handleConfigSaved,e[30]=i.showConfigDialog,e[31]=D,e[32]=B):B=e[32];const q=(u==null?void 0:u.dirName)??o.pendingDirName??null,W=(c==null?void 0:c.cwd)??o.pendingCwd??null;let H;e[33]!==i.defaultAgentKind||e[34]!==t.onStartNewFolder||e[35]!==t.onStartNewSession||e[36]!==t.panels.handleCloseProjectSwitcher||e[37]!==t.panels.showProjectSwitcher||e[38]!==q||e[39]!==W?(H=a.jsx(y.Suspense,{fallback:null,children:a.jsx(lpe,{open:t.panels.showProjectSwitcher,onClose:t.panels.handleCloseProjectSwitcher,onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:i.defaultAgentKind,currentProjectDirName:q,currentProjectCwd:W})}),e[33]=i.defaultAgentKind,e[34]=t.onStartNewFolder,e[35]=t.onStartNewSession,e[36]=t.panels.handleCloseProjectSwitcher,e[37]=t.panels.showProjectSwitcher,e[38]=q,e[39]=W,e[40]=H):H=e[40];let K;e[41]!==i.defaultAgentKind||e[42]!==t.onStartNewFolder||e[43]!==t.onStartNewSession?(K=a.jsx(TI,{onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:i.defaultAgentKind}),e[41]=i.defaultAgentKind,e[42]=t.onStartNewFolder,e[43]=t.onStartNewSession,e[44]=K):K=e[44];let Z;e[45]!==t.panels.handleCloseThemeSelector||e[46]!==t.panels.showThemeSelector||e[47]!==l.setPreview||e[48]!==l.setTheme||e[49]!==l.theme?(Z=a.jsx(y.Suspense,{fallback:null,children:a.jsx(cpe,{open:t.panels.showThemeSelector,onClose:t.panels.handleCloseThemeSelector,currentTheme:l.theme,onSelectTheme:l.setTheme,onPreviewTheme:l.setPreview})}),e[45]=t.panels.handleCloseThemeSelector,e[46]=t.panels.showThemeSelector,e[47]=l.setPreview,e[48]=l.setTheme,e[49]=l.theme,e[50]=Z):Z=e[50];const Y=r.commandPaletteOpen,X=r.onCommandPaletteOpenChange,ee=t.actions.handleGoHome,te=t.panels.handleOpenProjectSwitcher,se=t.onOpenPaletteProject,J=t.actions.handleDashboardSelect,ne=t.panels.handleToggleSidebar;let ie,ae,oe;e[51]!==t.panels?(ie=()=>t.panels.toggleWorkspacePanel(Ot.sessionInfo),ae=()=>t.panels.toggleWorkspacePanel(Ot.fileChanges),oe=()=>t.panels.toggleWorkspacePanel(Ot.worktrees),e[51]=t.panels,e[52]=ie,e[53]=ae,e[54]=oe):(ie=e[52],ae=e[53],oe=e[54]);const ue=t.panels.handleToggleMission,re=c?t.handlers.handleDuplicateSession:void 0,de=c?L:void 0,fe=c?I:void 0,le=xt("killAny")?r.onKillAll:void 0,ce=xt("configWrite")?t.panels.handleToggleConfig:void 0,he=i.openConfigDialog;let ge;e[55]!==k?(ge=()=>k(!0),e[55]=k,e[56]=ge):ge=e[56];const be=s.currentCwd?s.onTogglePreview:void 0,ve=xt("hostFiles")&&s.currentCwd?s.onToggleProjectFiles:void 0;let Se;e[57]!==t.panels?(Se=xt("browser")?()=>t.panels.toggleWorkspacePanel(Ot.browser):void 0,e[57]=t.panels,e[58]=Se):Se=e[58];const we=t.panels.handleToggleThemeSelector,Ee=s.onOpenTerminal,$e=r.onFocusComposer,Be=r.onExpandAll,qe=r.onExpandToolPayloads,ze=r.onCollapseAll,Ie=!!(c||o.pendingDirName);let Me;e[59]!==v||e[60]!==(c==null?void 0:c.cwd)||e[61]!==(u==null?void 0:u.dirName)||e[62]!==o.dashboardProject||e[63]!==o.pendingDirName?(Me=xt("terminal")&&!!((c==null?void 0:c.cwd)??v??(u==null?void 0:u.dirName)??o.pendingDirName??o.dashboardProject),e[59]=v,e[60]=c==null?void 0:c.cwd,e[61]=u==null?void 0:u.dirName,e[62]=o.dashboardProject,e[63]=o.pendingDirName,e[64]=Me):Me=e[64];const Ue=!!c;let De;e[65]!==s.hasFileChanges?(De=xt("hostFiles")&&s.hasFileChanges,e[65]=s.hasFileChanges,e[66]=De):De=e[66];const Ke=t.panels.activeWorkspacePanel===Ot.sessionInfo,Ne=t.panels.activeWorkspacePanel===Ot.browser,Ae=t.panels.activeWorkspacePanel===Ot.fileChanges,Qe=t.panels.activeWorkspacePanel===Ot.worktrees,Je=o.mainView==="config",ke=o.mainView==="mission",We=(c==null?void 0:c.cwd)??v??null;let ye;e[67]!==r.commandPaletteOpen||e[68]!==r.onCollapseAll||e[69]!==r.onCommandPaletteOpenChange||e[70]!==r.onExpandAll||e[71]!==r.onExpandToolPayloads||e[72]!==r.onFocusComposer||e[73]!==i.openConfigDialog||e[74]!==j||e[75]!==P||e[76]!==t.actions.handleDashboardSelect||e[77]!==t.actions.handleGoHome||e[78]!==t.onOpenPaletteProject||e[79]!==t.panels.handleOpenProjectSwitcher||e[80]!==t.panels.handleToggleMission||e[81]!==t.panels.handleToggleSidebar||e[82]!==t.panels.handleToggleThemeSelector||e[83]!==t.panels.showSidebar||e[84]!==T||e[85]!==s.launchTerminalRequest||e[86]!==s.onOpenTerminal||e[87]!==s.processPanel.addProcess||e[88]!==s.showProjectFiles||e[89]!==s.supportsWorktrees||e[90]!==ie||e[91]!==ae||e[92]!==oe||e[93]!==re||e[94]!==de||e[95]!==fe||e[96]!==le||e[97]!==ce||e[98]!==ge||e[99]!==be||e[100]!==ve||e[101]!==Se||e[102]!==Ie||e[103]!==Me||e[104]!==Ue||e[105]!==De||e[106]!==Ke||e[107]!==Ne||e[108]!==Ae||e[109]!==Qe||e[110]!==Je||e[111]!==ke||e[112]!==We?(ye=a.jsx(y.Suspense,{fallback:null,children:a.jsx(ope,{open:Y,onOpenChange:X,onGoHome:ee,onNewSession:te,onOpenProject:se,onOpenSession:J,onToggleSidebar:ne,onToggleStats:ie,onToggleFileChanges:ae,onToggleWorktrees:oe,onToggleMissionControl:ue,extraActions:P,onDuplicateSession:re,onCopyResumeCommand:de,onFindInConversation:fe,onKillAll:le,onOpenConfig:ce,onOpenSettings:he,onOpenKeyboardShortcuts:ge,onTogglePreview:be,onToggleProjectFiles:ve,onToggleBrowser:Se,onOpenTheme:we,onOpenTerminal:Ee,onOpenDevices:g?p:void 0,onSwitchDevice:Xs,devices:T,onFocusComposer:$e,onExpandAll:Be,onExpandToolPayloads:qe,onCollapseAll:ze,canFocusComposer:Ie,canOpenTerminal:Me,hasSession:Ue,hasFileChanges:De,supportsWorktrees:s.supportsWorktrees,showSidebar:t.panels.showSidebar,showStats:Ke,showProjectFiles:s.showProjectFiles,showBrowser:Ne,showFileChanges:Ae,showWorktrees:Qe,showConfig:Je,showMission:ke,currentProjectDirName:j,projectCwd:We,onProcessStarted:s.processPanel.addProcess,launchTerminalRequest:s.launchTerminalRequest})}),e[67]=r.commandPaletteOpen,e[68]=r.onCollapseAll,e[69]=r.onCommandPaletteOpenChange,e[70]=r.onExpandAll,e[71]=r.onExpandToolPayloads,e[72]=r.onFocusComposer,e[73]=i.openConfigDialog,e[74]=j,e[75]=P,e[76]=t.actions.handleDashboardSelect,e[77]=t.actions.handleGoHome,e[78]=t.onOpenPaletteProject,e[79]=t.panels.handleOpenProjectSwitcher,e[80]=t.panels.handleToggleMission,e[81]=t.panels.handleToggleSidebar,e[82]=t.panels.handleToggleThemeSelector,e[83]=t.panels.showSidebar,e[84]=T,e[85]=s.launchTerminalRequest,e[86]=s.onOpenTerminal,e[87]=s.processPanel.addProcess,e[88]=s.showProjectFiles,e[89]=s.supportsWorktrees,e[90]=ie,e[91]=ae,e[92]=oe,e[93]=re,e[94]=de,e[95]=fe,e[96]=le,e[97]=ce,e[98]=ge,e[99]=be,e[100]=ve,e[101]=Se,e[102]=Ie,e[103]=Me,e[104]=Ue,e[105]=De,e[106]=Ke,e[107]=Ne,e[108]=Ae,e[109]=Qe,e[110]=Je,e[111]=ke,e[112]=We,e[113]=ye):ye=e[113];let Re;e[114]!==r.keyboardShortcutsOpen||e[115]!==k?(Re=a.jsx(y.Suspense,{fallback:null,children:a.jsx(ape,{open:r.keyboardShortcutsOpen,onOpenChange:k})}),e[114]=r.keyboardShortcutsOpen,e[115]=k,e[116]=Re):Re=e[116];let Ve;e[117]!==m?(Ve=g&&a.jsx(CI,{open:m!==null,initialMode:m??"manage",onClose:()=>p(null)}),e[117]=m,e[118]=Ve):Ve=e[118];let He;return e[119]!==r.branchModal||e[120]!==r.processPanel||e[121]!==r.undoDialog||e[122]!==r.workflowsPanel||e[123]!==B||e[124]!==H||e[125]!==K||e[126]!==Z||e[127]!==ye||e[128]!==Re||e[129]!==Ve?(He=a.jsxs(a.Fragment,{children:[M,F,U,O,B,H,K,Z,ye,Re,Ve]}),e[119]=r.branchModal,e[120]=r.processPanel,e[121]=r.undoDialog,e[122]=r.workflowsPanel,e[123]=B,e[124]=H,e[125]=K,e[126]=Z,e[127]=ye,e[128]=Re,e[129]=Ve,e[130]=He):He=e[130],He}function dpe(){window.dispatchEvent(new Event(O1))}const AI={"github.repository":"cogpit.github.repository","clickup.tasks":"cogpit.clickup.tasks","vercel-deployments.deployments":"cogpit.vercel.deployments"};function aj(n){return n===null?null:AI[n]??n}function II(n,e){return n?e.find(t=>t.id===n)??e.find(t=>t.id===AI[n])??null:null}async function PI(n,e,t){return(await is(`/api/permissions/${encodeURIComponent(n)}/respond`,{requestId:e,behavior:t})).ok}async function fpe(n,e){return(await is(`/api/permissions/${encodeURIComponent(n)}/respond-all`,{behavior:e})).ok}function mpe(n,e,t){return GE("/api/elicitation-answer",{sessionId:n,requestId:e,...t})}function ppe(n,e,t){return GE("/api/user-dialog-answer",{sessionId:n,requestId:e,choice:t})}const hpe=3e3,Gb=y.createContext(null);async function Jh(n){try{const e=await Ce(n);return e.ok?await e.text():void 0}catch{return}}function Qh(n,e){if(!(n===void 0||n===e.current))try{const t=JSON.parse(n);return e.current=n,t}catch{return}}function el(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 Vu(n,e,t){const s=new Map(n),r=(s.get(e)??[]).filter(o=>!t(o));return r.length>0?s.set(e,r):s.delete(e),s}function gpe({children:n}){const[e,t]=y.useState(new Map),[s,r]=y.useState(new Map),[o,i]=y.useState(new Map),[l,c]=y.useState(new Map),[u,d]=y.useState(new Set),[f,m]=y.useState(new Set),p=y.useRef(""),h=y.useRef(""),g=y.useRef(""),x=Mf(),b=IN()!==null,w=y.useRef(x.key);y.useLayoutEffect(()=>{w.current=x.key},[x.key]);const v=y.useCallback(async()=>{const[P,z,L]=await Promise.all([Jh(El("/api/permissions",x)),Jh(El("/api/user-questions",x)),Jh(El("/api/agent-prompts",x))]);if(w.current!==x.key)return;const I=Qh(P,p),M=Qh(z,h),F=Qh(L,g);I&&(t(el(I.bySession)),d(new Set(el(I.plansBySession).keys()))),M&&r(el(M.bySession)),F&&(i(el(F.elicitationsBySession)),c(el(F.dialogsBySession)))},[x]);y.useEffect(()=>{if(b)return;const P=()=>{document.visibilityState==="visible"&&v()};P();const z=setInterval(P,hpe);return document.addEventListener("visibilitychange",P),()=>{clearInterval(z),document.removeEventListener("visibilitychange",P)}},[v,b]);const j=y.useCallback(async(P,z)=>{m(L=>new Set(L).add(P));try{return await z()}finally{m(L=>{const I=new Set(L);return I.delete(P),I}),v()}},[v]),k=y.useCallback((P,z,L)=>j(z,async()=>{await PI(P,z,L).catch(()=>!1)&&(t(M=>Vu(M,P,F=>F.requestId===z)),p.current="")}),[j]),_=y.useCallback((P,z,L)=>j(z,async()=>{const I=await J0(P,z,L);return I.ok&&(r(M=>Vu(M,P,F=>F.toolUseId===z)),h.current=""),I}),[j]),N=y.useCallback((P,z,L)=>j(z,async()=>{const I=await mpe(P,z,L);return I.ok&&(i(M=>Vu(M,P,F=>F.requestId===z)),g.current=""),I}),[j]),S=y.useCallback((P,z,L)=>j(z,async()=>{const I=await ppe(P,z,L);return I.ok&&(c(M=>Vu(M,P,F=>F.requestId===z)),g.current=""),I}),[j]),C=y.useMemo(()=>new Set(e.keys()),[e]),E=y.useMemo(()=>new Set(s.keys()),[s]),T=y.useMemo(()=>new Set(o.keys()),[o]),$=y.useMemo(()=>new Set(l.keys()),[l]),A=y.useCallback(()=>{v()},[v]),R=y.useMemo(()=>({permissionsBySession:e,questionsBySession:s,elicitationsBySession:o,dialogsBySession:l,awaitingPermission:C,awaitingQuestion:E,awaitingElicitation:T,awaitingDialog:$,awaitingPlan:u,responding:f,respond:k,answerQuestion:_,answerElicitation:N,answerDialog:S,refresh:A}),[e,s,o,l,C,E,T,$,u,f,k,_,N,S,A]);return a.jsx(Gb.Provider,{value:R,children:n})}function xpe(){const n=y.useContext(Gb);if(!n)throw new Error("usePendingHumanInput must be used within a PendingHumanInputProvider");return n}function bpe(){return y.useContext(Gb)}function $I(n){var d;const e=V.c(29),t=ir(),s=bpe(),r=r5(n),o=t==null?void 0:t.sessions,i=t==null?void 0:t.procBySession;let l;e[0]!==s?(l=s?{awaitingPermission:s.awaitingPermission,awaitingQuestion:s.awaitingQuestion,awaitingPrompt:new Set([...s.awaitingElicitation,...s.awaitingDialog]),awaitingPlan:s.awaitingPlan}:T9,e[0]=s,e[1]=l):l=e[1];const c=l;let u;if(e[2]!==c||e[3]!==i||e[4]!==n||e[5]!==o||e[6]!==r){e:{if(!n||!o||!i){u=null;break e}let f;if(e[8]!==n||e[9]!==o){let v;e[11]!==n?(v=j=>j.sessionId===n,e[11]=n,e[12]=v):v=e[12],f=o.find(v),e[8]=n,e[9]=o,e[10]=f}else f=e[10];const m=f,p=((d=m==null?void 0:m.crew)==null?void 0:d.rootId)??n;let h;e[13]!==p?(h=v=>{var j;return((j=v.crew)==null?void 0:j.rootId)===p},e[13]=p,e[14]=h):h=e[14];const g=o.filter(h);if(g.length===0){if(r.length===0){u=null;break e}const v=r.length;let j;e[15]!==r?(j=r.filter(vpe),e[15]=r,e[16]=j):j=e[16];let k;e[17]!==p||e[18]!==j.length||e[19]!==r.length?(k={rootId:p,size:v,needsYou:0,working:j.length},e[17]=p,e[18]=j.length,e[19]=r.length,e[20]=k):k=e[20],u=k;break e}let x;e[21]!==c||e[22]!==i?(x=v=>_N(v,i,c),e[21]=c,e[22]=i,e[23]=x):x=e[23];const b=Dx(g,x);let w;e[24]!==b.needsYou||e[25]!==b.size||e[26]!==b.working||e[27]!==p?(w={rootId:p,size:b.size,needsYou:b.needsYou,working:b.working},e[24]=b.needsYou,e[25]=b.size,e[26]=b.working,e[27]=p,e[28]=w):w=e[28],u=w}e[2]=c,e[3]=i,e[4]=n,e[5]=o,e[6]=r,e[7]=u}else u=e[7];return u}function vpe(n){return n.state==="running"}function vd(n){const e=V.c(10),{reason:t,children:s}=n;if(!t)return s;let r;e[0]!==t?(r=a.jsx("span",{className:"inline-flex",tabIndex:0,"aria-label":t}),e[0]=t,e[1]=r):r=e[1];let o;e[2]!==s||e[3]!==r?(o=a.jsx(Zt,{render:r,children:s}),e[2]=s,e[3]=r,e[4]=o):o=e[4];let i;e[5]!==t?(i=a.jsx(Yt,{children:t}),e[5]=t,e[6]=i):i=e[6];let l;return e[7]!==o||e[8]!==i?(l=a.jsxs(Gt,{children:[o,i]}),e[7]=o,e[8]=i,e[9]=l):l=e[9],l}function ype(n){var k;const e=V.c(22),{sessionId:t}=n,s=ir(),{names:r}=Ff();s==null||s.sessions;let o;e[0]!==(s==null?void 0:s.sessions)?(o=new Map(((s==null?void 0:s.sessions)??[]).map(wpe)),e[0]=s==null?void 0:s.sessions,e[1]=o):o=e[1];const i=o;let l,c,u,d;if(e[2]!==i||e[3]!==r||e[4]!==t){d=Symbol.for("react.early_return_sentinel");e:{if(l=(k=i.get(t))==null?void 0:k.crew,!l){d=null;break e}c=i.get(l.parentId),u=$d(l.parentId,i,r)??l.parentTitle??"the session that started it"}e[2]=i,e[3]=r,e[4]=t,e[5]=l,e[6]=c,e[7]=u,e[8]=d}else l=e[5],c=e[6],u=e[7],d=e[8];if(d!==Symbol.for("react.early_return_sentinel"))return d;const f=u;let m;e[9]!==l||e[10]!==c?(m=()=>{c?Ma(pa(c.dirName,c.fileName)):cm(l.parentId)},e[9]=l,e[10]=c,e[11]=m):m=e[11];const p=m,h=`Reports to ${f}`,g=`Open ${f}, which started this session`;let x,b,w;e[12]===Symbol.for("react.memo_cache_sentinel")?(x=G(fs,"h-8 min-w-12 max-w-56 shrink-[4] gap-1.5 px-2.5 text-xs text-muted-foreground hover:text-foreground"),b=a.jsx(dx,{className:"size-3 shrink-0","aria-hidden":"true"}),w=a.jsx("span",{className:"shrink-0 max-[1200px]:hidden",children:"Reports to"}),e[12]=x,e[13]=b,e[14]=w):(x=e[12],b=e[13],w=e[14]);let v;e[15]!==f?(v=a.jsx("span",{className:"truncate font-medium text-foreground",children:f}),e[15]=f,e[16]=v):v=e[16];let j;return e[17]!==p||e[18]!==v||e[19]!==h||e[20]!==g?(j=a.jsxs(Q,{type:"button",variant:"ghost",size:"xs","data-crew-parent":!0,onClick:p,"aria-label":h,title:g,className:x,children:[b,w,v]}),e[17]=p,e[18]=v,e[19]=h,e[20]=g,e[21]=j):j=e[21],j}function wpe(n){return[n.sessionId,n]}const lj=s_.version,Spe={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"},cj={ok:"Reachable",unknown:"Not reachable","bad-password":"Password rejected"};function kpe(n){const e=V.c(6),{state:t}=n,s=cj[t],r=cj[t],o=Spe[t];let i;e[0]!==o?(i=G("size-2 shrink-0 rounded-full",o),e[0]=o,e[1]=i):i=e[1];let l;return e[2]!==s||e[3]!==r||e[4]!==i?(l=a.jsx("span",{"aria-label":s,title:r,className:i}),e[2]=s,e[3]=r,e[4]=i,e[5]=l):l=e[5],l}function uj(n){const e=V.c(2),{slot:t}=n;if(t>9)return null;let s;return e[0]!==t?(s=a.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:t}),e[0]=t,e[1]=s):s=e[1],s}function Zb(n){const e=V.c(51),{compact:t}=n,s=t===void 0?!1:t,{devices:r,activeDeviceId:o,activeDevice:i,refresh:l,testDevice:c}=Fa(),[u,d]=y.useState(null),f=(i==null?void 0:i.name)??"This machine",m=o!==Lt;let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=xt("manageDevices"),e[0]=p):p=e[0];const h=p;let g;e[1]!==r||e[2]!==l||e[3]!==c?(g=O=>{!O||r.length===0||Promise.all(r.map(D=>c(D.id).catch(Npe))).then(()=>l())},e[1]=r,e[2]=l,e[3]=c,e[4]=g):g=e[4];const x=g;if(!s&&r.length===0&&!m)return null;const b=s?"sm":"xs",w=s&&"h-10";let v;e[5]!==w?(v=G("max-w-40 justify-start",w),e[5]=w,e[6]=v):v=e[6];let j;e[7]!==b||e[8]!==v?(j=a.jsx(Q,{variant:"ghost",size:b,"aria-label":"Switch device",className:v}),e[7]=b,e[8]=v,e[9]=j):j=e[9];let k;e[10]!==m?(k=m?a.jsx(ax,{"data-icon":"inline-start"}):a.jsx(bg,{"data-icon":"inline-start"}),e[10]=m,e[11]=k):k=e[11];let _;e[12]!==f?(_=a.jsx("span",{className:"truncate",children:f}),e[12]=f,e[13]=_):_=e[13];let N;e[14]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx(_t,{"data-icon":"inline-end",className:"opacity-60"}),e[14]=N):N=e[14];let S;e[15]!==j||e[16]!==k||e[17]!==_?(S=a.jsxs(Rc,{render:j,children:[k,_,N]}),e[15]=j,e[16]=k,e[17]=_,e[18]=S):S=e[18];let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsx(A5,{children:"Devices"}),e[19]=C):C=e[19];let E,T,$;e[20]===Symbol.for("react.memo_cache_sentinel")?(E=a.jsx(bg,{}),T=a.jsx("span",{className:"flex-1 truncate",children:"This machine"}),$=a.jsx(uj,{slot:1}),e[20]=E,e[21]=T,e[22]=$):(E=e[20],T=e[21],$=e[22]);let A;e[23]!==m?(A=!m&&a.jsx(nn,{className:"ml-auto text-success"}),e[23]=m,e[24]=A):A=e[24];let R;e[25]!==A?(R=a.jsxs(hn,{onClick:jpe,children:[E,T,$,A]}),e[25]=A,e[26]=R):R=e[26];let P;if(e[27]!==o||e[28]!==s||e[29]!==r){let O;e[31]!==o||e[32]!==s?(O=(D,B)=>{const q=jI(D),W=q!==void 0&&q!==lj,H=D.id===o;return a.jsxs(hn,{onClick:()=>Xs(D.id),className:G(s&&"min-h-10"),children:[a.jsx(kpe,{state:D.runtime.authState}),a.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[a.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[a.jsx("span",{className:"truncate",children:D.name}),W&&a.jsxs("span",{className:"shrink-0 font-mono text-xs text-warning",title:`Device runs v${q}; hub runs v${lj}`,children:["v",q]})]}),a.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:[D.host,":",D.port,D.auth==="none"&&" · unauthenticated"]})]}),a.jsx(uj,{slot:B+2}),H&&a.jsx(nn,{className:"ml-auto text-success"})]},D.id)},e[31]=o,e[32]=s,e[33]=O):O=e[33],P=r.map(O),e[27]=o,e[28]=s,e[29]=r,e[30]=P}else P=e[30];let z;e[34]!==R||e[35]!==P?(z=a.jsxs(qr,{children:[C,R,P]}),e[34]=R,e[35]=P,e[36]=z):z=e[36];let L;e[37]!==r.length?(L=h&&a.jsxs(a.Fragment,{children:[a.jsx(Il,{}),a.jsxs(qr,{children:[a.jsxs(hn,{onClick:()=>d("add"),children:[a.jsx(Sr,{}),a.jsx("span",{children:"Add device…"})]}),r.length>0&&a.jsxs(hn,{onClick:()=>d("manage"),children:[a.jsx(rx,{}),a.jsx("span",{children:"Manage devices…"})]})]})]}),e[37]=r.length,e[38]=L):L=e[38];let I;e[39]!==z||e[40]!==L?(I=a.jsxs(Oc,{align:"end",sideOffset:6,className:"w-64",children:[z,L]}),e[39]=z,e[40]=L,e[41]=I):I=e[41];let M;e[42]!==x||e[43]!==S||e[44]!==I?(M=a.jsxs($c,{onOpenChange:x,children:[S,I]}),e[42]=x,e[43]=S,e[44]=I,e[45]=M):M=e[45];let F;e[46]!==u?(F=h&&a.jsx(CI,{open:u!==null,initialMode:u??"manage",onClose:()=>d(null)}),e[46]=u,e[47]=F):F=e[47];let U;return e[48]!==M||e[49]!==F?(U=a.jsxs(a.Fragment,{children:[M,F]}),e[48]=M,e[49]=F,e[50]=U):U=e[50],U}function jpe(){return Xs(Lt)}function Npe(){return null}const Cpe=6e4;function _pe(){const[n,e]=y.useState([]),t=y.useCallback(async s=>{try{const r=await Ce("/api/system-processes");if(r.ok){const o=await r.json();if(s()){const i=(o.processes??[]).filter(l=>l.suspectedLeak);e(l=>JSON.stringify(l)===JSON.stringify(i)?l:i)}}}catch{}},[]);return Ra(t,Cpe),{leaks:n}}const Epe=6e4;function Tpe(n){const e=V.c(23),{onReview:t}=n,{leaks:s}=_pe(),[r,o]=y.useState(!1),i=s.length>0,l=s.reduce(Ipe,0);let c,u;if(e[0]!==i?(c=()=>{if(i){o(!0);return}const C=window.setTimeout(()=>o(!1),Epe);return()=>window.clearTimeout(C)},u=[i],e[0]=i,e[1]=c,e[2]=u):(c=e[1],u=e[2]),y.useEffect(c,u),!i&&!r)return null;const d=Gt,f=i?"destructive":"ghost",m=i?`Review ${s.length} flagged ${s.length===1?"process":"processes"}`:"Leak monitor. No flagged processes",p=!i&&"text-muted-foreground";let h;e[3]!==p?(h=G("mr-1 font-mono",p),e[3]=p,e[4]=h):h=e[4];let g;e[5]!==t||e[6]!==f||e[7]!==m||e[8]!==h?(g=a.jsx(Q,{variant:f,size:"xs","aria-label":m,onClick:t,className:h}),e[5]=t,e[6]=f,e[7]=m,e[8]=h,e[9]=g):g=e[9];let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=a.jsx(y8,{"data-icon":"inline-start"}),e[10]=x):x=e[10];let b;e[11]!==s.length?(b=a.jsx("span",{className:"tabular-nums",children:s.length}),e[11]=s.length,e[12]=b):b=e[12];let w;e[13]!==g||e[14]!==b?(w=a.jsxs(Zt,{render:g,children:[x,b]}),e[13]=g,e[14]=b,e[15]=w):w=e[15];const v=Yt,j="bottom",k="p-3",_=i?a.jsxs("div",{className:"flex min-w-56 flex-col gap-2",children:[a.jsxs("div",{className:"text-xs font-medium",children:["Flagged processes · ",l.toFixed(0),"% CPU"]}),s.slice(0,6).map(Ape),s.length>6&&a.jsxs("div",{className:"text-xs text-muted-foreground",children:["+",s.length-6," more"]}),a.jsx(en,{}),a.jsx("div",{className:"text-xs text-muted-foreground",children:"Review ownership and stop individual processes"})]}):a.jsxs("div",{className:"flex min-w-48 flex-col gap-1",children:[a.jsx("div",{className:"text-xs font-medium",children:"Leak monitor"}),a.jsx("div",{className:"text-xs text-muted-foreground",children:"No flagged processes. Click to open the power monitor."})]});let N;e[16]!==v||e[17]!==_?(N=a.jsx(v,{side:j,className:k,children:_}),e[16]=v,e[17]=_,e[18]=N):N=e[18];let S;return e[19]!==d||e[20]!==w||e[21]!==N?(S=a.jsxs(d,{children:[w,N]}),e[19]=d,e[20]=w,e[21]=N,e[22]=S):S=e[22],S}function Ape(n){return a.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[a.jsxs("span",{className:"truncate text-muted-foreground",children:[n.label," · ",SN(n.ageSeconds)]}),a.jsxs("span",{className:"shrink-0 font-semibold text-destructive",children:[n.cpuPercent.toFixed(0),"%"]})]},n.pid)}function Ipe(n,e){return n+e.cpuPercent}const Ppe=2e3;function va(n){return`${n.toFixed(n<10?1:0)}%`}function gf(n){return`${n.toFixed(0)} MB`}function $pe(n){return n>=10?`${n.toFixed(0)}/s`:n>=1?`${n.toFixed(1)}/s`:`${n.toFixed(2)}/s`}function Rpe(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 Ope(n){const e=V.c(50),{metric:t,onStop:s,stopping:r,onNavigate:o}=n;let i;e[0]!==t.label?(i=a.jsx("span",{className:"truncate text-sm font-medium",children:t.label}),e[0]=t.label,e[1]=i):i=e[1];let l;e[2]!==t.pid?(l=a.jsxs(Fe,{variant:"outline",children:["PID ",t.pid]}),e[2]=t.pid,e[3]=l):l=e[3];let c;e[4]!==t.suspectedLeak||e[5]!==t.warning?(c=t.suspectedLeak&&a.jsx(Fe,{variant:"destructive",children:t.warning==="sustained-cpu"?"sustained high CPU":"possible leak"}),e[4]=t.suspectedLeak,e[5]=t.warning,e[6]=c):c=e[6];let u;e[7]!==t.orphaned||e[8]!==t.suspectedLeak?(u=t.orphaned&&!t.suspectedLeak&&a.jsx(Fe,{variant:"secondary",children:"orphaned"}),e[7]=t.orphaned,e[8]=t.suspectedLeak,e[9]=u):u=e[9];let d;e[10]!==i||e[11]!==l||e[12]!==c||e[13]!==u?(d=a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i,l,c,u]}),e[10]=i,e[11]=l,e[12]=c,e[13]=u,e[14]=d):d=e[14];let f;e[15]!==t.command?(f=a.jsx("p",{className:"mt-1 truncate font-mono text-xs text-muted-foreground",title:t.command,children:t.command}),e[15]=t.command,e[16]=f):f=e[16];let m;e[17]!==t.kind||e[18]!==t.owner||e[19]!==o?(m=t.owner?a.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[t.owner.dirName&&t.owner.fileName?a.jsx("a",{className:"underline",href:pa(t.owner.dirName,t.owner.fileName),onClick:S=>{S.metaKey||S.ctrlKey||S.shiftKey||S.altKey||(S.preventDefault(),Ma(pa(t.owner.dirName,t.owner.fileName)),o())},children:t.owner.title||"Originating session"}):a.jsx("span",{children:"Originating session"}),a.jsxs("div",{className:"break-all",children:[t.owner.sessionId," · task ",t.owner.taskId]})]}):t.kind!=="cogpit"&&a.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Session ownership unknown"}),e[17]=t.kind,e[18]=t.owner,e[19]=o,e[20]=m):m=e[20];let p;e[21]!==d||e[22]!==f||e[23]!==m?(p=a.jsxs("div",{className:"min-w-0 flex-1",children:[d,f,m]}),e[21]=d,e[22]=f,e[23]=m,e[24]=p):p=e[24];let h;e[25]!==t||e[26]!==s||e[27]!==r?(h=t.canStop&&t.identity&&a.jsx(Q,{variant:"destructive",size:"xs",className:"shrink-0",onClick:()=>s(t),disabled:r,"aria-label":`Stop process ${t.pid}`,children:r?"Stopping…":"Stop"}),e[25]=t,e[26]=s,e[27]=r,e[28]=h):h=e[28];const g=t.cpuPercent>=20&&"text-destructive";let x;e[29]!==g?(x=G("font-mono text-sm font-semibold tabular-nums",g),e[29]=g,e[30]=x):x=e[30];let b;e[31]!==t.cpuPercent?(b=va(t.cpuPercent),e[31]=t.cpuPercent,e[32]=b):b=e[32];let w;e[33]!==x||e[34]!==b?(w=a.jsx("div",{className:x,children:b}),e[33]=x,e[34]=b,e[35]=w):w=e[35];let v;e[36]!==t.memoryMb?(v=gf(t.memoryMb),e[36]=t.memoryMb,e[37]=v):v=e[37];let j;e[38]!==t.ageSeconds?(j=SN(t.ageSeconds),e[38]=t.ageSeconds,e[39]=j):j=e[39];let k;e[40]!==v||e[41]!==j?(k=a.jsxs("div",{className:"text-xs text-muted-foreground",children:[v," · ",j]}),e[40]=v,e[41]=j,e[42]=k):k=e[42];let _;e[43]!==w||e[44]!==k?(_=a.jsxs("div",{className:"shrink-0 text-right",children:[w,k]}),e[43]=w,e[44]=k,e[45]=_):_=e[45];let N;return e[46]!==_||e[47]!==p||e[48]!==h?(N=a.jsxs("div",{className:"flex items-start gap-3 py-2.5",children:[p,h,_]}),e[46]=_,e[47]=p,e[48]=h,e[49]=N):N=e[49],N}function Lpe(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 Mpe(n,e,t=0){return t>0?t===1?'1 process needs review. See "Agent and runtime processes" below.':`${t} processes need review. See "Agent and runtime 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 dj(n){const e=V.c(34),{metric:t}=n;let s;e[0]!==t.name?(s=a.jsx("span",{className:"truncate text-sm font-medium",children:t.name}),e[0]=t.name,e[1]=s):s=e[1];let r;e[2]!==t.pid?(r=t.pid>0&&a.jsxs(Fe,{variant:"outline",children:["PID ",t.pid]}),e[2]=t.pid,e[3]=r):r=e[3];let o;e[4]!==s||e[5]!==r?(o=a.jsxs("div",{className:"flex items-center gap-2",children:[s,r]}),e[4]=s,e[5]=r,e[6]=o):o=e[6];let i;e[7]!==t?(i=Lpe(t),e[7]=t,e[8]=i):i=e[8];let l;e[9]!==i?(l=a.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:i}),e[9]=i,e[10]=l):l=e[10];let c;e[11]!==o||e[12]!==l?(c=a.jsxs("div",{className:"min-w-0 flex-1",children:[o,l]}),e[11]=o,e[12]=l,e[13]=c):c=e[13];const u=t.cpuPercent>=50&&"text-destructive";let d;e[14]!==u?(d=G("font-mono text-sm font-semibold tabular-nums",u),e[14]=u,e[15]=d):d=e[15];let f;e[16]!==t.cpuPercent?(f=va(t.cpuPercent),e[16]=t.cpuPercent,e[17]=f):f=e[17];let m;e[18]!==d||e[19]!==f?(m=a.jsx("div",{className:d,children:f}),e[18]=d,e[19]=f,e[20]=m):m=e[20];let p;e[21]!==t.memoryMb?(p=gf(t.memoryMb),e[21]=t.memoryMb,e[22]=p):p=e[22];let h;e[23]!==p?(h=a.jsx("div",{className:"text-xs text-muted-foreground",children:p}),e[23]=p,e[24]=h):h=e[24];let g;e[25]!==t.idleWakeupsPerSecond?(g=t.idleWakeupsPerSecond!==void 0&&t.idleWakeupsPerSecond>0&&a.jsxs("div",{className:"text-xs text-muted-foreground",children:[t.idleWakeupsPerSecond.toFixed(0)," wakeups/s"]}),e[25]=t.idleWakeupsPerSecond,e[26]=g):g=e[26];let x;e[27]!==m||e[28]!==h||e[29]!==g?(x=a.jsxs("div",{className:"shrink-0 text-right",children:[m,h,g]}),e[27]=m,e[28]=h,e[29]=g,e[30]=x):x=e[30];let b;return e[31]!==x||e[32]!==c?(b=a.jsxs("div",{className:"flex items-start gap-3 py-2.5",children:[c,x]}),e[31]=x,e[32]=c,e[33]=b):b=e[33],b}function fj(n){const e=V.c(6),{metrics:t,emptyLabel:s}=n;let r,o;if(e[0]!==s||e[1]!==t){o=Symbol.for("react.early_return_sentinel");e:{const i=t.slice(0,8);if(i.length===0){let l;e[4]!==s?(l=a.jsx("p",{className:"py-3 text-sm text-muted-foreground",children:s}),e[4]=s,e[5]=l):l=e[5],o=l;break e}r=i.map(zpe)}e[0]=s,e[1]=t,e[2]=r,e[3]=o}else r=e[2],o=e[3];return o!==Symbol.for("react.early_return_sentinel")?o:r}function zpe(n,e){const t=Rpe(n.bytesPerSecond);return a.jsxs("div",{children:[e>0&&a.jsx(en,{}),a.jsxs("div",{className:"flex items-center gap-3 py-2.5",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-sm",children:n.name}),a.jsxs("div",{className:"mt-0.5 flex flex-wrap gap-x-2 text-xs text-muted-foreground",children:[a.jsx("span",{children:$pe(n.ratePerSecond)}),t&&a.jsx("span",{children:t}),n.averageDurationMs!==void 0&&a.jsxs("span",{children:[n.averageDurationMs.toFixed(0)," ms avg"]})]})]}),n.active!==void 0&&n.active>0&&a.jsxs(Fe,{variant:"secondary",children:[n.active," open"]})]})]},n.name)}function Dpe(n){const e=V.c(8),{values:t}=n,s=Math.max(100,...t);let r;e[0]!==t?(r=t.map(Fpe).join(", "),e[0]=t,e[1]=r):r=e[1];const o=`Recent Cogpit CPU: ${r}`;let i;e[2]!==s||e[3]!==t?(i=t.length===0?a.jsx("span",{className:"self-center text-xs text-muted-foreground",children:"Collecting samples…"}):t.map((c,u)=>a.jsx("div",{className:G("min-w-1 flex-1 rounded-sm bg-primary/70",c>=80&&"bg-destructive/80"),style:{height:`${Math.max(4,Math.min(100,c/s*100))}%`},title:va(c)},u)),e[2]=s,e[3]=t,e[4]=i):i=e[4];let l;return e[5]!==o||e[6]!==i?(l=a.jsx("div",{className:"flex h-14 items-end gap-1 rounded-md bg-muted/50 p-2",role:"img","aria-label":o,children:i}),e[5]=o,e[6]=i,e[7]=l):l=e[7],l}function Fpe(n){return va(n)}function Upe({open:n,onOpenChange:e}){var $,A;const[t,s]=y.useState(null),[r,o]=y.useState(null),[i,l]=y.useState([]),[c,u]=y.useState(null),[d,f]=y.useState(null),[m,p]=y.useState(!1),[h,g]=y.useState(null),x=y.useRef(!1),[b,w]=no(),v=y.useCallback(async()=>{var F;if(x.current)return;x.current=!0,p(!0);const R=Ce("/api/performance").then(async U=>{if(!U.ok)throw new Error(`Server monitor returned ${U.status}`);return U.json()}),P=((F=window.electronPerformance)==null?void 0:F.getSnapshot())??Promise.resolve(null),[z,L]=await Promise.allSettled([R,P]),I=z.status==="fulfilled"?z.value:null,M=L.status==="fulfilled"?L.value:null;if(I&&o(I),M&&s(M),!I&&!M)u("Performance data is unavailable.");else{u(null);const U=M&&M.processes.length>0?M.processes.reduce((O,D)=>O+D.cpuPercent,0):(I==null?void 0:I.cpuPercent)??0;l(O=>[...O.slice(-29),U])}x.current=!1,p(!1)},[]);y.useEffect(()=>{if(!n)return;const R=()=>{document.visibilityState==="visible"&&v()};R();const P=window.setInterval(R,Ppe);return document.addEventListener("visibilitychange",R),()=>{window.clearInterval(P),document.removeEventListener("visibilitychange",R)}},[n,v]);const j=[...(t==null?void 0:t.processes)??[]].sort((R,P)=>P.cpuPercent-R.cpuPercent),k=j.length>0?j.reduce((R,P)=>R+P.cpuPercent,0):(r==null?void 0:r.cpuPercent)??0,_=j[0],N=(($=r==null?void 0:r.system)==null?void 0:$.processes)??[],S=((A=r==null?void 0:r.system)==null?void 0:A.suspectedLeakCount)??0,C=S>0||k>=80?"High":k>=15?"Active":"Idle",E=async R=>{if(!(!R.identity||h!==null)){f(null),g(R.pid);try{const P=await Ce("/api/system-processes/kill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({processes:[{pid:R.pid,identity:R.identity}]})});if(!P.ok)throw new Error("Could not stop this process.");if(!(await P.json()).killed.includes(R.pid))throw new Error("The process changed or is no longer eligible. Refresh and review it again.");await v()}catch{f("Process was not stopped. Refresh and review its current identity and access.")}finally{g(null)}}},T=()=>{w(JSON.stringify({capturedAt:new Date().toISOString(),electron:t,server:r,cpuHistory:i},null,2))};return a.jsx(nr,{open:n,onOpenChange:e,children:a.jsxs(sr,{className:"h-[min(780px,calc(100vh-2rem))] gap-0 p-0 sm:max-w-3xl",children:[a.jsx(io,{className:"p-5 pb-4",children:a.jsxs("div",{className:"flex items-start gap-3 pr-8",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(rr,{children:"Power & activity monitor"}),a.jsx(Fe,{variant:C==="High"?"destructive":"secondary",children:C})]}),a.jsx(or,{className:"mt-1",children:"Live CPU, memory, and wakeups. Sampling runs only while this window is open."})]}),a.jsxs("div",{className:"flex shrink-0 gap-1",children:[a.jsxs(Q,{variant:"outline",size:"sm",onClick:()=>void v(),disabled:m,children:[a.jsx(Fn,{"data-icon":"inline-start",className:G(m&&"animate-spin")}),"Refresh"]}),a.jsxs(Q,{variant:"outline",size:"sm",onClick:T,disabled:!r&&!t,children:[b?a.jsx(nn,{"data-icon":"inline-start"}):a.jsx(Es,{"data-icon":"inline-start"}),b?"Copied":"Copy data"]})]})]})}),a.jsx(en,{}),a.jsx(Vc,{className:"min-h-0 min-w-0 flex-1",children:a.jsxs("div",{className:"flex flex-col gap-4 p-5",children:[(c||d)&&a.jsx(jt,{variant:"destructive",children:a.jsx(Rt,{children:d||c})}),a.jsxs(Ds,{size:"sm",children:[a.jsxs(gr,{children:[a.jsx(xr,{children:"Current load"}),a.jsx(br,{children:Mpe(k,_,S)}),a.jsx(Dte,{children:a.jsxs("span",{className:G("font-mono text-lg font-semibold tabular-nums",k>=80&&"text-destructive"),children:[va(k)," CPU"]})})]}),a.jsx(Fs,{children:a.jsx(Dpe,{values:i})})]}),a.jsxs(Ds,{size:"sm",children:[a.jsxs(gr,{children:[a.jsx(xr,{children:"Processes"}),a.jsx(br,{children:"Which part of Cogpit is consuming CPU and memory."})]}),a.jsx(Fs,{children:j.length>0?j.map((R,P)=>a.jsxs("div",{children:[P>0&&a.jsx(en,{}),a.jsx(dj,{metric:R})]},R.pid)):r?a.jsx(dj,{metric:{pid:0,name:"Server",type:"Node",cpuPercent:r.cpuPercent,memoryMb:r.memory.rssMb}}):a.jsx("p",{className:"py-3 text-sm text-muted-foreground",children:"Collecting process data…"})})]}),N.length>0&&a.jsxs(Ds,{size:"sm",children:[a.jsxs(gr,{children:[a.jsx(xr,{children:"Agent and runtime processes"}),a.jsx(br,{children:"Agent sessions, browsers, and long-running scripts. Unknown runtimes are flagged after sustained high CPU; stopping them is manual."})]}),a.jsx(Fs,{children:N.map((R,P)=>a.jsxs("div",{children:[P>0&&a.jsx(en,{}),a.jsx(Ope,{metric:R,onStop:z=>void E(z),stopping:h!==null,onNavigate:()=>e(!1)})]},R.pid))})]}),a.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[a.jsxs(Ds,{size:"sm",children:[a.jsxs(gr,{children:[a.jsx(xr,{children:"Server activity"}),a.jsxs(br,{children:["File checks, streams, and agent work over the last ",(r==null?void 0:r.sampleWindowSeconds)??10," seconds."]})]}),a.jsx(Fs,{children:a.jsx(fj,{metrics:(r==null?void 0:r.activities)??[],emptyLabel:"No watched-file or stream activity in this sample."})})]}),a.jsxs(Ds,{size:"sm",children:[a.jsxs(gr,{children:[a.jsx(xr,{children:"API activity"}),a.jsx(br,{children:"Requests ranked by recent frequency and time."})]}),a.jsx(Fs,{children:a.jsx(fj,{metrics:(r==null?void 0:r.requests)??[],emptyLabel:"No API requests in this sample."})})]})]}),r&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Server event loop ",va(r.eventLoopPercent)," · heap ",gf(r.memory.heapUsedMb)," · RSS ",gf(r.memory.rssMb)]})]})})]})})}function Bpe(n){return`${n.title??`Pull request #${n.number}`}
462
462
  ${n.repo}${n.isDraft?" · draft":""}`}function RI(n){return{href:n.url,target:"_blank",rel:"noreferrer",onClick:e=>e.stopPropagation(),"aria-label":`Pull request #${n.number}`,title:Bpe(n)}}function su(n){const e=V.c(17),{pullRequests:t,max:s,compact:r,layout:o}=n,i=s===void 0?3:s,l=o===void 0?"chips":o;if(!(t!=null&&t.length))return null;if(l==="list"){let f;e[0]!==t?(f=t.map(qpe),e[0]=t,e[1]=f):f=e[1];let m;return e[2]!==f?(m=a.jsx("div",{className:"flex flex-col gap-0.5",children:f}),e[2]=f,e[3]=m):m=e[3],m}let c,u;if(e[4]!==r||e[5]!==i||e[6]!==t){const f=t.slice(-i);if(e[9]!==i||e[10]!==t){const p=t.slice(0,-i);c=p.length>0&&a.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",title:p.map(Wpe).join(`
463
463
  `),children:["+",p.length]}),e[9]=i,e[10]=t,e[11]=c}else c=e[11];let m;e[12]!==r?(m=p=>{const h=p.isDraft?D4:cx;return a.jsxs(Fe,{variant:p.isDraft?"outline":"secondary",render:a.jsx("a",{...RI(p)}),className:G("shrink-0",r&&"px-1"),children:[a.jsx(h,{"data-icon":"inline-start"}),"#",p.number]},p.url)},e[12]=r,e[13]=m):m=e[13],u=f.map(m),e[4]=r,e[5]=i,e[6]=t,e[7]=c,e[8]=u}else c=e[7],u=e[8];let d;return e[14]!==c||e[15]!==u?(d=a.jsxs(a.Fragment,{children:[c,u]}),e[14]=c,e[15]=u,e[16]=d):d=e[16],d}function Wpe(n){return`#${n.number} ${n.title??n.repo}`}function qpe(n){const e=n.isDraft?D4:cx;return a.jsxs("a",{...RI(n),className:"flex items-center gap-1 text-foreground hover:underline",children:[a.jsx(e,{className:"size-2.5 shrink-0"}),a.jsxs("span",{className:"shrink-0",children:["#",n.number]}),n.title&&a.jsx("span",{className:"truncate text-muted-foreground",children:n.title})]},n.url)}const Vpe=y.memo(function(e){const t=V.c(34),{session:s,sessionSource:r,isLive:o,pullRequests:i,copied:l,creatingSession:c,onCopyResume:u,onNewSession:d,onDuplicateSession:f,onOpenTerminal:m}=e;let p;if(t[0]!==r){const E=r?$o(r.fileName):null;p=E?Fb(E.agentId):null,t[0]=r,t[1]=p}else p=t[1];const h=p;let g;t[2]!==s.turns?(g=s.turns.some(Gpe),t[2]=s.turns,t[3]=g):g=t[3];const x=g;let b;t[4]!==s.rawMessages||t[5]!==(r==null?void 0:r.dirName)?(b=oa(r==null?void 0:r.dirName).contextWindow?s.rawMessages:[],t[4]=s.rawMessages,t[5]=r==null?void 0:r.dirName,t[6]=b):b=t[6];const w=b;let v;t[7]===Symbol.for("react.memo_cache_sentinel")?(v=a.jsx("div",{className:G(fs,"flex h-8 min-w-0 items-center gap-2 pl-1 pr-3")}),t[7]=v):v=t[7];let j;t[8]!==l||t[9]!==c||t[10]!==u||t[11]!==f||t[12]!==d||t[13]!==m||t[14]!==s||t[15]!==r?(j=r?a.jsx(Kpe,{session:s,sessionSource:r,copied:l,creatingSession:c,onCopyResume:u,onNewSession:d,onDuplicateSession:f,onOpenTerminal:m}):a.jsx("button",{type:"button",onClick:u,className:"truncate rounded-full px-1.5 py-1 text-sm font-medium text-foreground",children:l?"Copied":s.slug||s.sessionId.slice(0,8)}),t[8]=l,t[9]=c,t[10]=u,t[11]=f,t[12]=d,t[13]=m,t[14]=s,t[15]=r,t[16]=j):j=t[16];let k;t[17]!==o?(k=o&&a.jsx(Sm,{"aria-label":"Session is live"}),t[17]=o,t[18]=k):k=t[18];let _;t[19]!==w?(_=a.jsx(cA,{rawMessages:w}),t[19]=w,t[20]=_):_=t[20];let N;t[21]!==j||t[22]!==k||t[23]!==_?(N=a.jsxs(Zt,{delay:200,render:v,children:[j,k,_]}),t[21]=j,t[22]=k,t[23]=_,t[24]=N):N=t[24];let S;t[25]!==i||t[26]!==w||t[27]!==s||t[28]!==h||t[29]!==x?(S=a.jsx(Yt,{role:"tooltip",side:"bottom",align:"start",sideOffset:6,className:"p-3",children:a.jsx(Hpe,{session:s,thinkingEnabled:x,subAgentLabel:h,pullRequests:i,rawMessages:w})}),t[25]=i,t[26]=w,t[27]=s,t[28]=h,t[29]=x,t[30]=S):S=t[30];let C;return t[31]!==N||t[32]!==S?(C=a.jsxs(Gt,{children:[N,S]}),t[31]=N,t[32]=S,t[33]=C):C=t[33],C});function Mi(n){const e=V.c(7),{label:t,children:s}=n;let r;e[0]!==t?(r=a.jsx("span",{className:"w-24 shrink-0 text-muted-foreground",children:t}),e[0]=t,e[1]=r):r=e[1];let o;e[2]!==s?(o=a.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:s}),e[2]=s,e[3]=o):o=e[3];let i;return e[4]!==r||e[5]!==o?(i=a.jsxs("div",{className:"flex gap-3",children:[r,o]}),e[4]=r,e[5]=o,e[6]=i):i=e[6],i}function Hpe(n){const e=V.c(33),{session:t,thinkingEnabled:s,subAgentLabel:r,pullRequests:o,rawMessages:i}=n;let l,c,u,d,f,m,p;if(e[0]!==o||e[1]!==i||e[2]!==t.branchedFrom||e[3]!==t.gitBranch||e[4]!==t.model||e[5]!==r||e[6]!==s){const g=kN(i),x=t.branchedFrom;l="flex min-w-64 max-w-96 flex-col gap-1.5 text-xs",e[14]!==t.model||e[15]!==s?(c=t.model&&a.jsxs(Mi,{label:"Model",children:[a.jsx("span",{children:ao(t.model)}),s&&a.jsx("span",{className:"text-muted-foreground",children:"· thinking"})]}),e[14]=t.model,e[15]=s,e[16]=c):c=e[16],e[17]!==t.gitBranch?(u=t.gitBranch&&a.jsx(Mi,{label:"Branch",children:a.jsx("span",{className:"truncate font-mono",children:t.gitBranch})}),e[17]=t.gitBranch,e[18]=u):u=e[18],e[19]!==o?(d=o.length>0&&a.jsx(Mi,{label:"Pull requests",children:a.jsx(su,{pullRequests:o})}),e[19]=o,e[20]=d):d=e[20],e[21]!==r?(f=r&&a.jsx(Mi,{label:"Agent",children:r}),e[21]=r,e[22]=f):f=e[22],e[23]!==x?(m=x&&a.jsxs(Mi,{label:"Duplicated from",children:[x.sessionId.slice(0,8),x.turnIndex!=null?` at turn ${x.turnIndex+1}`:""]}),e[23]=x,e[24]=m):m=e[24],p=g&&a.jsxs(Mi,{label:"Context",children:[vt(Math.max(0,g.compactAt-g.used))," left before compact ·"," ",vt(g.used)," / ",vt(g.limit)]}),e[0]=o,e[1]=i,e[2]=t.branchedFrom,e[3]=t.gitBranch,e[4]=t.model,e[5]=r,e[6]=s,e[7]=l,e[8]=c,e[9]=u,e[10]=d,e[11]=f,e[12]=m,e[13]=p}else l=e[7],c=e[8],u=e[9],d=e[10],f=e[11],m=e[12],p=e[13];let h;return e[25]!==l||e[26]!==c||e[27]!==u||e[28]!==d||e[29]!==f||e[30]!==m||e[31]!==p?(h=a.jsxs("div",{className:l,children:[c,u,d,f,m,p]}),e[25]=l,e[26]=c,e[27]=u,e[28]=d,e[29]=f,e[30]=m,e[31]=p,e[32]=h):h=e[32],h}function Kpe(n){const e=V.c(55),{session:t,sessionSource:s,copied:r,creatingSession:o,onCopyResume:i,onNewSession:l,onDuplicateSession:c,onOpenTerminal:u}=n,{dispatch:d}=Sn(),f=!!(t.cwd||s.dirName);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=qo(),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?`${_r(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 j;e[10]===Symbol.for("react.memo_cache_sentinel")?(j=xt("hostFiles"),e[10]=j):j=e[10];const k=j;let _;e[11]===Symbol.for("react.memo_cache_sentinel")?(_=k&&(!p||wb()),e[11]=_):_=e[11];const N=_,S=k&&!p;let C;e[12]!==d||e[13]!==s.dirName?(C=function(){y.startTransition(()=>{d({type:"GO_HOME",isMobile:!1}),d({type:"SET_DASHBOARD_PROJECT",dirName:s.dirName})})},e[12]=d,e[13]=s.dirName,e[14]=C):C=e[14];const E=C,T=`Copy resume command for ${b}; open session actions with the context menu`;let $;e[15]!==i||e[16]!==T?($=a.jsx("button",{type:"button",onClick:i,className:"flex min-w-0 max-w-80 items-center gap-1.5 truncate rounded-full px-1.5 py-1 text-sm font-medium text-foreground transition-colors hover:bg-accent","aria-label":T,"aria-haspopup":"menu",title:"Click to copy resume command. Right-click for session actions."}),e[15]=i,e[16]=T,e[17]=$):$=e[17];let A;e[18]!==r||e[19]!==t.cwd||e[20]!==g?(A=r?a.jsxs("span",{className:"flex items-center gap-1.5 text-success",children:[a.jsx(nn,{className:"size-3"})," Copied"]}):a.jsxs(a.Fragment,{children:[t.cwd&&a.jsx("span",{className:"truncate text-muted-foreground",children:_r(t.cwd)}),t.cwd&&a.jsx("span",{className:"text-muted-foreground/50",children:"/"}),a.jsx("span",{className:"truncate",children:g})]}),e[18]=r,e[19]=t.cwd,e[20]=g,e[21]=A):A=e[21];let R;e[22]!==A||e[23]!==$?(R=a.jsx(Cm,{render:$,children:A}),e[22]=A,e[23]=$,e[24]=R):R=e[24];let P;e[25]!==l||e[26]!==t.cwd||e[27]!==s.dirName?(P=()=>l(s.dirName,t.cwd),e[25]=l,e[26]=t.cwd,e[27]=s.dirName,e[28]=P):P=e[28];let z;e[29]!==o?(z=o?a.jsx(Pn,{className:"size-3.5"}):a.jsx(Sr,{className:"size-3.5"}),e[29]=o,e[30]=z):z=e[30];let L;e[31]!==o||e[32]!==P||e[33]!==z?(L=a.jsxs(Rn,{disabled:o,onClick:P,children:[z,"New session in this project"]}),e[31]=o,e[32]=P,e[33]=z,e[34]=L):L=e[34];let I;e[35]!==c?(I=c&&a.jsxs(Rn,{onClick:c,children:[a.jsx(Es,{className:"size-3.5"}),"Duplicate this session"]}),e[35]=c,e[36]=I):I=e[36];let M;e[37]!==f||e[38]!==v?(M=f&&(N||S)&&a.jsxs(a.Fragment,{children:[a.jsx(ba,{}),N&&a.jsxs(Rn,{onClick:()=>c6(v),children:[a.jsx(hx,{className:"size-3.5"}),"Open project in editor"]}),S&&a.jsxs(Rn,{onClick:()=>u6(v),children:[a.jsx(wc,{className:"size-3.5"}),"Reveal in file manager"]})]}),e[37]=f,e[38]=v,e[39]=M):M=e[39];let F;e[40]!==u?(F=u&&!p&&xt("terminal")&&a.jsxs(Rn,{onClick:u,children:[a.jsx(Ca,{className:"size-3.5"}),"Open terminal in project"]}),e[40]=u,e[41]=F):F=e[41];let U;e[42]===Symbol.for("react.memo_cache_sentinel")?(U=a.jsx(ba,{}),e[42]=U):U=e[42];let O;e[43]===Symbol.for("react.memo_cache_sentinel")?(O=a.jsx(Zr,{className:"size-3.5"}),e[43]=O):O=e[43];let D;e[44]!==E?(D=a.jsxs(Rn,{onClick:E,children:[O,"View all sessions in this project"]}),e[44]=E,e[45]=D):D=e[45];let B;e[46]!==L||e[47]!==I||e[48]!==M||e[49]!==F||e[50]!==D?(B=a.jsxs(_m,{className:"min-w-56",children:[L,I,M,F,U,D]}),e[46]=L,e[47]=I,e[48]=M,e[49]=F,e[50]=D,e[51]=B):B=e[51];let q;return e[52]!==R||e[53]!==B?(q=a.jsxs(Nm,{children:[R,B]}),e[52]=R,e[53]=B,e[54]=q):q=e[54],q}function Gpe(n){return n.thinking.length>0}const tl="Could not reach the server";async function Hu(n,e){try{return await Ce(n,e)}catch{return null}}function Zpe(){const n=V.c(15);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],n[0]=e):e=n[0];const[t,s]=y.useState(e),[r,o]=y.useState(null),i=y.useRef(!0);let l,c;n[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>(i.current=!0,()=>{i.current=!1}),c=[],n[1]=l,n[2]=c):(l=n[1],c=n[2]),y.useEffect(l,c);let u;n[3]===Symbol.for("react.memo_cache_sentinel")?(u=async()=>{const _=await Hu("/api/shares");if(!(_!=null&&_.ok))return;const N=await _.json().catch(Qpe);i.current&&Array.isArray(N)&&s(N)},n[3]=u):u=n[3];const d=u;let f,m;n[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{d()},m=[d],n[4]=f,n[5]=m):(f=n[4],m=n[5]),y.useEffect(f,m);let p;n[6]===Symbol.for("react.memo_cache_sentinel")?(p=async _=>{o(null);const N=await Hu("/api/shares",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:_})});if(!(N!=null&&N.ok))return i.current&&o(await Tl(N,tl)),null;const S=await N.json().catch(Jpe);if(!(S!=null&&S.passphrase)||!S.share)return i.current&&o(tl),null;const C=S.share;return i.current&&s(E=>[...E.filter(T=>T.sessionId!==C.sessionId),C]),S.passphrase},n[6]=p):p=n[6];const h=p;let g;n[7]===Symbol.for("react.memo_cache_sentinel")?(g=async _=>{o(null);const N=await Hu(`/api/shares/${encodeURIComponent(_)}/regenerate`,{method:"POST"});if(!(N!=null&&N.ok))return i.current&&o(await Tl(N,tl)),null;const S=await N.json().catch(Xpe);return S!=null&&S.passphrase?(d(),S.passphrase):(i.current&&o(tl),null)},n[7]=g):g=n[7];const x=g;let b;n[8]===Symbol.for("react.memo_cache_sentinel")?(b=async _=>{o(null);const N=await Hu(`/api/shares/${encodeURIComponent(_)}`,{method:"DELETE"});if(!(N!=null&&N.ok)){i.current&&o(await Tl(N,tl));return}i.current&&s(S=>S.filter(C=>C.sessionId!==_))},n[8]=b):b=n[8];const w=b;let v;n[9]!==t?(v=async()=>{const _=t.map(Ype);for(const N of _)await w(N)},n[9]=t,n[10]=v):v=n[10];const j=v;let k;return n[11]!==r||n[12]!==j||n[13]!==t?(k={shares:t,error:r,refresh:d,create:h,regenerate:x,revoke:w,revokeAll:j},n[11]=r,n[12]=j,n[13]=t,n[14]=k):k=n[14],k}function Ype(n){return n.sessionId}function Xpe(){return null}function Jpe(){return null}function Qpe(){return null}const ehe=5e3,the="••••";function nhe(n){return n===0?"No guests connected":n===1?"1 guest connected":`${n} guests connected`}function she({sessionId:n}){const{config:{networkAccessDisabled:e}}=Sn(),{shares:t,error:s,refresh:r,create:o,regenerate:i,revoke:l}=Zpe(),[c,u]=y.useState(!1),[d,f]=y.useState(null),[m,p]=y.useState(!1),[h,g]=no(),[x,b]=no(),w=t.find(_=>_.sessionId===n)??null,v=`${window.location.origin}${yee(n)}`;y.useEffect(()=>f(null),[n]),y.useEffect(()=>{if(!c)return;r();const _=setInterval(()=>void r(),ehe);return()=>clearInterval(_)},[c,r]);async function j(_){p(!0);try{await _()}finally{p(!1)}}const k=e&&a.jsx("p",{className:"text-xs text-muted-foreground",children:"Network access is off, so this link only works on this machine."});return a.jsxs($c,{open:c,onOpenChange:_=>{u(_),_||f(null)},children:[a.jsx(Rc,{render:a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm","aria-label":w?"Session is shared":"Share session",className:G(w&&"bg-primary/15 text-primary hover:bg-primary/25")}),children:a.jsx(w8,{"data-icon":"inline-start"})}),a.jsx(Oc,{align:"end",sideOffset:6,className:"w-80 p-3",children:w?a.jsxs("div",{className:"flex flex-col gap-2.5",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("code",{className:"min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 font-mono text-[11px]",children:v}),a.jsx(Q,{variant:"ghost",size:"icon-xs","aria-label":"Copy link",onClick:()=>g(v),children:h?a.jsx(nn,{"data-icon":"inline-start"}):a.jsx(Es,{"data-icon":"inline-start"})})]}),a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("code",{className:"min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 font-mono text-[11px]",children:d??the}),a.jsx(Q,{variant:"ghost",size:"icon-xs","aria-label":"Regenerate passphrase",disabled:m,onClick:()=>j(async()=>{f(await i(n))}),children:a.jsx(Fn,{"data-icon":"inline-start"})})]}),d?a.jsx(Q,{variant:"secondary",size:"xs",onClick:()=>b(`${v}
464
464
  Passphrase: ${d}`),children:x?"Copied":"Copy link & passphrase"}):a.jsx("p",{className:"text-xs text-muted-foreground",children:"The passphrase is only shown once. Regenerate to get a new one."}),k,s&&a.jsx("p",{className:"text-xs text-destructive",children:s}),a.jsxs("div",{className:"flex items-center justify-between gap-2 border-t pt-2",children:[a.jsx("span",{className:"text-xs text-muted-foreground",children:nhe(w.guests)}),a.jsx(Q,{variant:"ghost",size:"xs",className:"text-destructive hover:text-destructive",disabled:m,onClick:()=>j(async()=>{await l(n),f(null)}),children:"Stop sharing"})]})]}):a.jsxs("div",{className:"flex flex-col gap-2.5",children:[a.jsx("p",{className:"text-xs text-muted-foreground",children:"Anyone with the link and passphrase can read and join this session."}),k,s&&a.jsx("p",{className:"text-xs text-destructive",children:s}),a.jsx(Q,{size:"xs",disabled:m,onClick:()=>j(async()=>{f(await o(n))}),children:"Enable sharing"})]})})]})}function Yb(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 $t(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)?n:void 0}function Zs(n){return typeof n=="number"&&Number.isFinite(n)?n:void 0}function To(n){return typeof n=="string"?n:void 0}function Co(n){return n?Yb(Zs(n.utilization),To(n.resets_at)):void 0}function OI(n){if(n)return{isEnabled:!!n.is_enabled,monthlyLimit:Zs(n.monthly_limit),usedCredits:Zs(n.used_credits),utilization:Zs(n.utilization)}}function rhe(n){return{fiveHour:Co($t(n.five_hour)),sevenDay:Co($t(n.seven_day)),sevenDayOpus:Co($t(n.seven_day_opus)),sevenDaySonnet:Co($t(n.seven_day_sonnet)),extraUsage:OI($t(n.extra_usage)),subscriptionType:To(n.subscriptionType)}}function ohe(n){if(n.available!==!0)return null;const e=$t(n.usage),t=$t(e==null?void 0:e.rate_limits),s=$t(n.account),r={fiveHour:Co($t(t==null?void 0:t.five_hour)),sevenDay:Co($t(t==null?void 0:t.seven_day)),sevenDayOpus:Co($t(t==null?void 0:t.seven_day_opus)),sevenDaySonnet:Co($t(t==null?void 0:t.seven_day_sonnet)),extraUsage:OI($t(t==null?void 0:t.extra_usage)),subscriptionType:To(e==null?void 0:e.subscription_type)??To(s==null?void 0:s.subscriptionType)};return r.fiveHour||r.sevenDay||r.extraUsage||r.subscriptionType?r:null}function ihe(n){const e=Zs(n);if(e!==void 0)return new Date(e<1e10?e*1e3:e).toISOString()}function ahe(n,e){const t=Zs(n);return t===void 0||t<=0?e:t%1440===0?`${t/1440}-day`:t%60===0?`${t/60}-hour`:`${t}-minute`}function mj(n,e){if(n)return Yb(Zs(n.usedPercent),ihe(n.resetsAt),ahe(n.windowDurationMins,e))}const lhe={free:"Free",go:"Go",plus:"Plus",pro:"Pro (More)",prolite:"Pro",promax:"Pro (Max)",team:"Team",business:"Business",ent26:"Enterprise",enterprise:"Enterprise",edu:"Edu",edu_plus:"Edu Plus",edu_pro:"Edu Pro"};function che(n){var d,f,m;if(n.available!==!0)return null;const e=$t((d=$t(n.rateLimits))==null?void 0:d.rateLimits),t=$t((f=$t(n.account))==null?void 0:f.account),s=$t((m=$t(n.usage))==null?void 0:m.summary),r=$t(e==null?void 0:e.credits),o=mj($t(e==null?void 0:e.primary),"Primary"),i=mj($t(e==null?void 0:e.secondary),"Secondary"),l=s==null?void 0:s.lifetimeTokens,c=Zs(l)??(typeof l=="string"&&Number.isSafeInteger(Number(l))?Number(l):void 0),u=To(e==null?void 0:e.planType)??To(t==null?void 0:t.planType);return!o&&!i&&c===void 0?null:{fiveHour:o,sevenDay:i,subscriptionType:u?lhe[u]??u:void 0,lifetimeTokens:c,creditBalance:To(r==null?void 0:r.balance),creditsUnlimited:(r==null?void 0:r.unlimited)===!0}}function pj(n,e){if(!n)return;const t=Zs(n.remainingPercentage),s=Zs(n.usedRequests),r=Zs(n.entitlementRequests);let o;return t!==void 0?o=100-t:n.isUnlimitedEntitlement===!0||r===-1?o=0:s!==void 0&&r!==void 0&&r>0&&(o=s/r*100),Yb(o,To(n.resetDate),e)}function uhe(n){var s;if(n.available!==!0)return null;const e=$t((s=$t(n.quota))==null?void 0:s.quotaSnapshots),t=pj($t(e==null?void 0:e.chat),"Chat")??pj($t(e==null?void 0:e.premium_interactions),"Premium interactions");return t?{fiveHour:t}:null}const dhe={acp:{endpoint:"/api/acp/runtime",read:()=>({})},claude:{endpoint:"/api/claude/runtime",read:ohe,legacy:{endpoint:"/api/usage",read:rhe}},codex:{endpoint:"/api/codex/runtime",read:che},copilot:{endpoint:"/api/copilot/runtime",read:uhe}};function fhe(n){return dhe[n]}const mhe=300*1e3;function phe(n=Wo){const e=Nn("viewUsage"),[t,s]=y.useState(null),[r,o]=y.useState(!1),[i,l]=y.useState(!1),c=y.useRef(0),u=y.useRef(null),d=y.useCallback(async()=>{var h;if(!e)return;const f=++c.current;(h=u.current)==null||h.abort();const m=new AbortController;u.current=m;const p=()=>c.current===f&&!m.signal.aborted;o(!0);try{const g=fhe(n);let x=await Ce(g.endpoint,{signal:m.signal}),b=g.read;if(g.legacy&&!x.ok&&!m.signal.aborted&&(x=await Ce(g.legacy.endpoint,{signal:m.signal}),b=g.legacy.read),!p())return;if(x.status===501||x.status===404){l(!1);return}if(!x.ok){l(!0);return}const w=await x.json();if(!p())return;const v=b(w);l(v!==null),s(v?{...v,agentKind:n,fetchedAt:Date.now()}:null)}catch{}finally{p()&&(u.current=null,o(!1))}},[n,e]);return y.useEffect(()=>{var m;if(s(null),l(!1),!e){o(!1),c.current+=1,(m=u.current)==null||m.abort(),u.current=null;return}d();const f=setInterval(d,mhe);return()=>{var p;clearInterval(f),c.current+=1,(p=u.current)==null||p.abort(),u.current=null}},[n,e,d]),{usage:e?t:null,loading:e&&r,available:e&&i,refresh:d}}function LI(n){return n>=90?"danger":n>=80?"warning":n>=60?"caution":"nominal"}const MI={nominal:"text-muted-foreground",caution:"text-warning",warning:"text-warning",danger:"text-destructive"};function hhe(n){var u;const e=V.c(31),{usage:t}=n;let s,r,o;if(e[0]!==t.agentKind||e[1]!==t.fetchedAt||e[2]!==t.fiveHour||e[3]!==t.sevenDay||e[4]!==t.sevenDayOpus||e[5]!==t.sevenDaySonnet||e[6]!==t.subscriptionType){const d=[];t.fiveHour&&d.push({label:t.fiveHour.label??"5-hour",pct:t.fiveHour.utilization,resetsAt:t.fiveHour.resetsAt}),t.sevenDay&&d.push({label:t.sevenDay.label??"7-day",pct:t.sevenDay.utilization,resetsAt:t.sevenDay.resetsAt}),t.sevenDayOpus&&d.push({label:"Opus",pct:t.sevenDayOpus.utilization,resetsAt:t.sevenDayOpus.resetsAt}),t.sevenDaySonnet&&d.push({label:"Sonnet",pct:t.sevenDaySonnet.utilization,resetsAt:t.sevenDaySonnet.resetsAt}),s="flex min-w-[200px] flex-col gap-2";let f;e[10]!==t.agentKind?(f=t.agentKind?Bf(t.agentKind):"Agent",e[10]=t.agentKind,e[11]=f):f=e[11];let m;e[12]!==f?(m=a.jsxs("span",{className:"text-xs font-medium uppercase tracking-wide",children:[f," usage"]}),e[12]=f,e[13]=m):m=e[13];let p;e[14]!==t.subscriptionType?(p=t.subscriptionType&&a.jsx(Fe,{variant:"secondary",children:t.subscriptionType}),e[14]=t.subscriptionType,e[15]=p):p=e[15],e[16]!==m||e[17]!==p?(r=a.jsxs("div",{className:"flex items-center justify-between",children:[m,p]}),e[16]=m,e[17]=p,e[18]=r):r=e[18],o=d.map(h=>{const g=h.resetsAt&&t.fetchedAt!=null?new Date(h.resetsAt).getTime()-t.fetchedAt:null,x=g!=null?Math.max(0,Math.round(g/36e5)):null,b=LI(h.pct);return a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsxs("div",{className:"flex items-center justify-between text-xs",children:[a.jsx("span",{className:"text-muted-foreground",children:h.label}),a.jsxs("span",{className:G("font-semibold",MI[b]),children:[h.pct.toFixed(1),"%"]})]}),a.jsx(qc,{value:Math.min(h.pct,100)}),x!=null&&a.jsxs("div",{className:"text-xs text-muted-foreground",children:["Resets in ",x,"h"]})]},h.label)}),e[0]=t.agentKind,e[1]=t.fetchedAt,e[2]=t.fiveHour,e[3]=t.sevenDay,e[4]=t.sevenDayOpus,e[5]=t.sevenDaySonnet,e[6]=t.subscriptionType,e[7]=s,e[8]=r,e[9]=o}else s=e[7],r=e[8],o=e[9];let i;e[19]!==t.extraUsage?(i=((u=t.extraUsage)==null?void 0:u.isEnabled)&&t.extraUsage.usedCredits!=null&&t.extraUsage.monthlyLimit!=null&&a.jsxs("div",{className:"flex flex-col gap-1 pt-1 text-xs text-muted-foreground",children:[a.jsx(en,{}),"Extra: $",t.extraUsage.usedCredits.toFixed(2)," / $",t.extraUsage.monthlyLimit.toFixed(2)]}),e[19]=t.extraUsage,e[20]=i):i=e[20];let l;e[21]!==t.creditBalance||e[22]!==t.creditsUnlimited||e[23]!==t.lifetimeTokens?(l=(t.lifetimeTokens!=null||t.creditBalance||t.creditsUnlimited)&&a.jsxs("div",{className:"flex flex-col gap-1 pt-1 text-xs text-muted-foreground",children:[a.jsx(en,{}),t.lifetimeTokens!=null&&a.jsxs("div",{children:["Lifetime: ",vt(t.lifetimeTokens)," tokens"]}),t.creditsUnlimited?a.jsx("div",{children:"Credits: Unlimited"}):t.creditBalance?a.jsxs("div",{children:["Credits: ",t.creditBalance]}):null]}),e[21]=t.creditBalance,e[22]=t.creditsUnlimited,e[23]=t.lifetimeTokens,e[24]=l):l=e[24];let c;return e[25]!==s||e[26]!==r||e[27]!==o||e[28]!==i||e[29]!==l?(c=a.jsxs("div",{className:s,children:[r,o,i,l]}),e[25]=s,e[26]=r,e[27]=o,e[28]=i,e[29]=l,e[30]=c):c=e[30],c}function ghe(n){var j,k;const e=V.c(22),{agentKind:t}=n,s=t===void 0?Wo:t,{usage:r,loading:o,available:i,refresh:l}=phe(s);if(!i||!r)return null;const c=((j=r.fiveHour)==null?void 0:j.utilization)??((k=r.sevenDay)==null?void 0:k.utilization);if(c==null)return null;let u;e[0]!==r.agentKind?(u=r.agentKind?Bf(r.agentKind):"agent",e[0]=r.agentKind,e[1]=u):u=e[1];const d=`Refresh ${u} usage`;let f;e[2]!==o||e[3]!==l||e[4]!==d?(f=a.jsx(Q,{type:"button",variant:"ghost",size:"xs","aria-label":d,onClick:l,disabled:o,className:"mr-1 font-mono"}),e[2]=o,e[3]=l,e[4]=d,e[5]=f):f=e[5];const m=MI[LI(c)],p=o&&"opacity-50";let h;e[6]!==m||e[7]!==p?(h=G("tabular-nums",m,p),e[6]=m,e[7]=p,e[8]=h):h=e[8];let g;e[9]!==c?(g=c.toFixed(0),e[9]=c,e[10]=g):g=e[10];let x;e[11]!==h||e[12]!==g?(x=a.jsxs("span",{className:h,children:[g,"%"]}),e[11]=h,e[12]=g,e[13]=x):x=e[13];let b;e[14]!==f||e[15]!==x?(b=a.jsx(Zt,{render:f,children:x}),e[14]=f,e[15]=x,e[16]=b):b=e[16];let w;e[17]!==r?(w=a.jsx(Yt,{side:"bottom",className:"p-3",children:a.jsx(hhe,{usage:r})}),e[17]=r,e[18]=w):w=e[18];let v;return e[19]!==b||e[20]!==w?(v=a.jsxs(Gt,{children:[b,w]}),e[19]=b,e[20]=w,e[21]=v):v=e[21],v}function xhe(n){const e=V.c(9);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={summary:null,loading:!1,error:null},e[0]=t):t=e[0];const[s,r]=y.useState(t),[o,i]=y.useState(0);let l;e[1]!==n?(l=()=>{const m=new AbortController;r(vhe);const p=Intl.DateTimeFormat().resolvedOptions().timeZone;return Ce(`/api/usage-cost?days=${n}&tz=${encodeURIComponent(p)}`,{signal:m.signal}).then(async h=>{if(!h.ok)throw new Error(`Usage scan failed (${h.status})`);const g=await h.json();r({summary:g,loading:!1,error:null})}).catch(h=>{m.signal.aborted||r(g=>({...g,loading:!1,error:h instanceof Error?h.message:"Usage scan failed"}))}),()=>m.abort()},e[1]=n,e[2]=l):l=e[2];let c;e[3]!==n||e[4]!==o?(c=[n,o],e[3]=n,e[4]=o,e[5]=c):c=e[5],y.useEffect(l,c);let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=()=>i(bhe),e[6]=u):u=e[6];const d=u;let f;return e[7]!==s?(f={...s,refresh:d},e[7]=s,e[8]=f):f=e[8],f}function bhe(n){return n+1}function vhe(n){return{...n,loading:!0,error:null}}function yhe(n){const e=n.trim().toLowerCase().replace(/\[[^\]]*\]$/,""),t=e.lastIndexOf("/");return t===-1?e:e.slice(t+1)}const whe=new Set(["<synthetic>","synthetic","opus","sonnet","haiku","fable"]);function She(n,e){const t=yhe(e);return t.length===0||whe.has(t)?null:n.get(t)??null}function khe(n,e){const t=n.longContextThresholdTokens,s=e.uncachedInputTokens+e.cachedInputTokens+e.cacheCreationTokens,r=t!==null&&s>t;return function(i,l,c){return i<=0?0:c===null||t===null?i*l:n.longContextPricing==="wholeRequest"?i*(r?c:l):i<=t?i*l:t*l+(i-t)*c}}function jhe(n){return n.uncachedInputUsd+n.cachedInputUsd+n.cacheCreationUsd+n.outputUsd}function Nhe(n,e,t,s=null){const r=She(n,e);if(r===null)return null;const o=Math.min(t.cacheCreation1hTokens,t.cacheCreationTokens),i=t.cacheCreationTokens-o,l=khe(r,t),c=s==="fast"?r.fastCostMultiplier:1;return{uncachedInputUsd:c*l(t.uncachedInputTokens,r.inputCostPerToken,r.inputCostPerTokenAboveThreshold),cachedInputUsd:c*l(t.cachedInputTokens,r.cacheReadCostPerToken,r.cacheReadCostPerTokenAboveThreshold),cacheCreationUsd:c*(l(i,r.cacheCreationCostPerToken,r.cacheCreationCostPerTokenAboveThreshold)+o*r.cacheCreation1hCostPerToken),outputUsd:c*l(t.outputTokens,r.outputCostPerToken,r.outputCostPerTokenAboveThreshold)}}function Che(n,e,t,s,r=null){const o=Nhe(n,e,t,r);return o===null?{costUsd:0,costSource:"unpriced"}:{costUsd:jhe(o),costSource:"modelPriced"}}function Xb(n){return n.uncachedInputTokens+n.cachedInputTokens+n.cacheCreationTokens+n.outputTokens}function _he(n,e,t){if(!e)return 0;const{costUsd:s,costSource:r}=Che(n,e,{uncachedInputTokens:t.input_tokens,cachedInputTokens:t.cache_read_input_tokens??0,cacheCreationTokens:t.cache_creation_input_tokens??0,cacheCreation1hTokens:0,outputTokens:t.output_tokens});return r==="unpriced"?0:s}const Ehe=[{days:7,label:"7 days"},{days:30,label:"30 days"},{days:90,label:"90 days"}],ea=v5.map(n=>({key:n,label:Cn(n).displayName,color:NM(n)}));function The(n,e){const t=[],r=Date.parse(`${e}T00:00:00Z`);for(let o=Date.parse(`${n}T00:00:00Z`);o<=r;o+=864e5)t.push(new Date(o).toISOString().slice(0,10));return t}function hj(){return Object.fromEntries(ea.map(({key:n})=>[n,{costUsd:0,tokens:0}]))}function Ahe(n){const e=new Map;for(const r of The(n.sinceDay,n.untilDay))e.set(r,{day:r,byProvider:hj(),costUsd:0,tokens:0});const t=new Map,s={costUsd:0,tokens:0,cacheSavingsUsd:0,byProvider:hj(),days:[],models:[]};for(const r of n.buckets){const o=Xb(r.totals);s.costUsd+=r.costUsd,s.tokens+=o,s.cacheSavingsUsd+=r.cacheSavingsUsd,s.byProvider[r.provider].costUsd+=r.costUsd,s.byProvider[r.provider].tokens+=o;const i=e.get(r.day);i&&(i.byProvider[r.provider].costUsd+=r.costUsd,i.byProvider[r.provider].tokens+=o,i.costUsd+=r.costUsd,i.tokens+=o);const l=`${r.provider}:${r.model}`;let c=t.get(l);c||(c={provider:r.provider,model:r.model,costUsd:0,tokens:0,unpriced:!0},t.set(l,c)),c.costUsd+=r.costUsd,c.tokens+=o,r.costSource!=="unpriced"&&(c.unpriced=!1)}return s.days=[...e.values()],s.models=[...t.values()].sort((r,o)=>o.costUsd-r.costUsd||o.tokens-r.tokens),s}function gj(n){const e=Date.parse(`${n}T00:00:00Z`);return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",timeZone:"UTC"}).format(e)}const eg=720,tg=180,Ihe=18;function Phe(n){const e=V.c(41),{days:t,metric:s}=n,[r,o]=y.useState(null);let i;e[0]!==s?(i=N=>s==="cost"?N.costUsd:N.tokens,e[0]=s,e[1]=i):i=e[1];const l=i;let c;if(e[2]!==t||e[3]!==l){let N;e[5]!==l?(N=S=>l(S),e[5]=l,e[6]=N):N=e[6],c=Math.max(...t.map(N)),e[2]=t,e[3]=l,e[4]=c}else c=e[4];const u=c;if(u<=0){let N;return e[7]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx("div",{className:"flex h-32 items-center justify-center text-xs text-muted-foreground",children:"No activity in this window."}),e[7]=N):N=e[7],N}const d=tg-Ihe,f=eg/t.length,m=Math.max(2,Math.min(28,f-2)),p=r!==null?t[r]:null;let h;e[8]!==p||e[9]!==s||e[10]!==l?(h=p&&a.jsx("div",{className:"pointer-events-none absolute left-0 right-0 top-0 z-10 flex justify-center",children:a.jsxs("div",{className:"rounded-md border bg-popover px-2.5 py-1.5 text-xs text-popover-foreground shadow-xs",children:[a.jsx("span",{className:"font-medium",children:gj(p.day)}),ea.map(N=>{const{key:S,label:C,color:E}=N,T=p.byProvider[S];return l(T)<=0?null:a.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-muted-foreground",children:[a.jsx("span",{"aria-hidden":!0,className:"size-1.5 rounded-full",style:{backgroundColor:E}}),C,": ",s==="cost"?gs(T.costUsd):vt(T.tokens)]},S)}),a.jsx("span",{className:"ml-2 font-medium",children:s==="cost"?gs(p.costUsd):vt(p.tokens)})]})}),e[8]=p,e[9]=s,e[10]=l,e[11]=h):h=e[11];const g=`Daily ${s==="cost"?"raw API cost":"processed tokens"} by provider`;let x,b;e[12]===Symbol.for("react.memo_cache_sentinel")?(x=()=>o(null),b=a.jsx("line",{x1:0,y1:d,x2:eg,y2:d,stroke:"var(--border)",strokeWidth:1}),e[12]=x,e[13]=b):(x=e[12],b=e[13]);let w;if(e[14]!==m||e[15]!==t||e[16]!==r||e[17]!==u||e[18]!==f||e[19]!==l){let N;e[21]!==m||e[22]!==r||e[23]!==u||e[24]!==f||e[25]!==l?(N=(S,C)=>{const E=C*f+(f-m)/2;let T=d;const $=r===C;return a.jsxs("g",{onMouseEnter:()=>o(C),children:[a.jsx("rect",{x:C*f,y:0,width:f,height:d,fill:"transparent"}),$&&a.jsx("rect",{x:C*f,y:0,width:f,height:d,fill:"var(--foreground)",opacity:.05,rx:2}),ea.map(A=>{const{key:R,color:P}=A,z=l(S.byProvider[R]);if(z<=0)return null;const L=z/u*(d-6);return T=T-L,a.jsx("rect",{x:E,y:T,width:m,height:Math.max(1,L-1.5),rx:1.5,fill:P,opacity:$?1:.85},R)})]},S.day)},e[21]=m,e[22]=r,e[23]=u,e[24]=f,e[25]=l,e[26]=N):N=e[26],w=t.map(N),e[14]=m,e[15]=t,e[16]=r,e[17]=u,e[18]=f,e[19]=l,e[20]=w}else w=e[20];let v;if(e[27]!==t||e[28]!==f){let N;e[30]!==t.length||e[31]!==f?(N=(S,C)=>C===0||C===t.length-1||t.length>10&&C%7===0&&C<t.length-3?a.jsx("text",{x:C*f+f/2,y:tg-4,textAnchor:"middle",className:"fill-muted-foreground text-[10px]",children:gj(S.day)},S.day):null,e[30]=t.length,e[31]=f,e[32]=N):N=e[32],v=t.map(N),e[27]=t,e[28]=f,e[29]=v}else v=e[29];let j;e[33]!==g||e[34]!==w||e[35]!==v?(j=a.jsxs("svg",{viewBox:`0 0 ${eg} ${tg}`,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]=j):j=e[36];let k;e[37]===Symbol.for("react.memo_cache_sentinel")?(k=a.jsx("div",{className:"mt-1 flex items-center gap-4",children:ea.map($he)}),e[37]=k):k=e[37];let _;return e[38]!==h||e[39]!==j?(_=a.jsxs("div",{className:"relative",children:[h,j,k]}),e[38]=h,e[39]=j,e[40]=_):_=e[40],_}function $he(n){const{key:e,label:t,color:s}=n;return a.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[a.jsx("span",{"aria-hidden":!0,className:"size-2 rounded-full",style:{backgroundColor:s}}),t]},e)}function ng(n){const e=V.c(7),{label:t,value:s}=n;let r;e[0]!==t?(r=a.jsx("span",{className:"text-xs text-muted-foreground",children:t}),e[0]=t,e[1]=r):r=e[1];let o;e[2]!==s?(o=a.jsx("span",{className:"text-sm font-medium text-foreground tabular-nums",children:s}),e[2]=s,e[3]=o):o=e[3];let i;return e[4]!==r||e[5]!==o?(i=a.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[r,o]}),e[4]=r,e[5]=o,e[6]=i):i=e[6],i}function Rhe(n){const e=V.c(68),{days:t}=n,{summary:s,loading:r,error:o,refresh:i}=xhe(t),[l,c]=y.useState("cost");let u;e[0]!==s?(u=s?Ahe(s):null,e[0]=s,e[1]=u):u=e[1];const d=u;if(o){let U;e[2]!==i?(U=a.jsx(Q,{variant:"outline",size:"sm",onClick:i,children:"Retry"}),e[2]=i,e[3]=U):U=e[3];let O;return e[4]!==o||e[5]!==U?(O=a.jsxs("div",{className:"flex flex-col items-center gap-2 py-10 text-sm text-muted-foreground",children:[o,U]}),e[4]=o,e[5]=U,e[6]=O):O=e[6],O}if(!d||!s){let U;return e[7]===Symbol.for("react.memo_cache_sentinel")?(U=a.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-sm text-muted-foreground",children:[a.jsx(Pn,{className:"size-4"})," Scanning transcripts…"]}),e[7]=U):U=e[7],U}const f=r&&"opacity-60";let m;e[8]!==f?(m=G("flex flex-col gap-5",f),e[8]=f,e[9]=m):m=e[9];let p;e[10]!==d.costUsd||e[11]!==d.tokens||e[12]!==l?(p=l==="cost"?gs(d.costUsd):vt(d.tokens),e[10]=d.costUsd,e[11]=d.tokens,e[12]=l,e[13]=p):p=e[13];let h;e[14]!==p?(h=a.jsx("span",{className:"text-3xl font-semibold text-foreground tabular-nums",children:p}),e[14]=p,e[15]=h):h=e[15];const g=l==="cost"?"raw API price":"processed tokens";let x;e[16]!==s.distinctSessions||e[17]!==g?(x=a.jsxs("span",{className:"text-xs text-muted-foreground",children:[s.distinctSessions," sessions · ",g]}),e[16]=s.distinctSessions,e[17]=g,e[18]=x):x=e[18];let b;e[19]!==h||e[20]!==x?(b=a.jsxs("div",{className:"flex flex-col gap-0.5",children:[h,x]}),e[19]=h,e[20]=x,e[21]=b):b=e[21];let w;e[22]===Symbol.for("react.memo_cache_sentinel")?(w=["cost","tokens"],e[22]=w):w=e[22];let v;e[23]!==l?(v=a.jsx("div",{className:"flex rounded-md border p-0.5",children:w.map(U=>a.jsx(Q,{variant:l===U?"secondary":"ghost",size:"xs",onClick:()=>c(U),children:U==="cost"?"Cost":"Tokens"},U))}),e[23]=l,e[24]=v):v=e[24];let j;e[25]!==d.byProvider||e[26]!==l?(j=ea.map(U=>{const{key:O,label:D}=U,B=d.byProvider[O];return B.costUsd===0&&B.tokens===0?null:a.jsxs("span",{className:"text-xs text-muted-foreground tabular-nums",children:[D,": ",l==="cost"?gs(B.costUsd):vt(B.tokens)]},O)}),e[25]=d.byProvider,e[26]=l,e[27]=j):j=e[27];let k;e[28]!==v||e[29]!==j?(k=a.jsxs("div",{className:"flex flex-col items-end gap-1.5",children:[v,j]}),e[28]=v,e[29]=j,e[30]=k):k=e[30];let _;e[31]!==k||e[32]!==b?(_=a.jsxs("div",{className:"flex items-end justify-between gap-4",children:[b,k]}),e[31]=k,e[32]=b,e[33]=_):_=e[33];let N;e[34]!==d.days||e[35]!==l?(N=a.jsx(Phe,{days:d.days,metric:l}),e[34]=d.days,e[35]=l,e[36]=N):N=e[36];let S;e[37]!==d.tokens?(S=vt(d.tokens),e[37]=d.tokens,e[38]=S):S=e[38];let C;e[39]!==S?(C=a.jsx(ng,{label:"Processed tokens",value:S}),e[39]=S,e[40]=C):C=e[40];let E;e[41]!==d.cacheSavingsUsd?(E=gs(d.cacheSavingsUsd),e[41]=d.cacheSavingsUsd,e[42]=E):E=e[42];let T;e[43]!==E?(T=a.jsx(ng,{label:"Cache savings",value:E}),e[43]=E,e[44]=T):T=e[44];const $=String(s.scannedFiles);let A;e[45]!==$?(A=a.jsx(ng,{label:"Files scanned",value:$}),e[45]=$,e[46]=A):A=e[46];let R;e[47]!==C||e[48]!==T||e[49]!==A?(R=a.jsxs("div",{className:"grid grid-cols-3 gap-x-6 gap-y-3 border-t pt-3",children:[C,T,A]}),e[47]=C,e[48]=T,e[49]=A,e[50]=R):R=e[50];let P;e[51]===Symbol.for("react.memo_cache_sentinel")?(P=a.jsx("thead",{children:a.jsxs("tr",{className:"border-b text-left text-xs text-muted-foreground",children:[a.jsx("th",{className:"py-1.5 font-normal",children:"Model"}),a.jsx("th",{className:"py-1.5 text-right font-normal",children:"Cost"}),a.jsx("th",{className:"py-1.5 text-right font-normal",children:"Share"}),a.jsx("th",{className:"py-1.5 text-right font-normal",children:"Tokens"})]})}),e[51]=P):P=e[51];let z;if(e[52]!==d.costUsd||e[53]!==d.models){let U;e[55]!==d.costUsd?(U=O=>{var D;return a.jsxs("tr",{className:"border-b border-border/50",children:[a.jsx("td",{className:"max-w-56 truncate py-1.5 text-foreground",children:a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{"aria-hidden":!0,className:"size-2 shrink-0 rounded-full",style:{backgroundColor:(D=ea.find(B=>B.key===O.provider))==null?void 0:D.color}}),O.model]})}),a.jsx("td",{className:"py-1.5 text-right text-foreground tabular-nums",children:O.unpriced?"—":gs(O.costUsd)}),a.jsx("td",{className:"py-1.5 text-right text-muted-foreground tabular-nums",children:d.costUsd>0&&!O.unpriced?`${(O.costUsd/d.costUsd*100).toFixed(1)}%`:"—"}),a.jsx("td",{className:"py-1.5 text-right text-muted-foreground tabular-nums",children:vt(O.tokens)})]},`${O.provider}:${O.model}`)},e[55]=d.costUsd,e[56]=U):U=e[56],z=d.models.map(U),e[52]=d.costUsd,e[53]=d.models,e[54]=z}else z=e[54];let L;e[57]!==z?(L=a.jsxs("table",{className:"w-full text-sm",children:[P,a.jsx("tbody",{children:z})]}),e[57]=z,e[58]=L):L=e[58];const I=s.pricing.status==="unavailable"?" (rate table unavailable — costs incomplete)":"";let M;e[59]!==I?(M=a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Raw API-equivalent prices from LiteLLM rates",I," ","— not what a subscription bills."]}),e[59]=I,e[60]=M):M=e[60];let F;return e[61]!==_||e[62]!==N||e[63]!==R||e[64]!==L||e[65]!==M||e[66]!==m?(F=a.jsxs("div",{className:m,children:[_,N,R,L,M]}),e[61]=_,e[62]=N,e[63]=R,e[64]=L,e[65]=M,e[66]=m,e[67]=F):F=e[67],F}function Ohe(n){const e=V.c(15),{open:t,onOpenChange:s}=n,[r,o]=y.useState(30);let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsxs("div",{children:[a.jsx(rr,{children:"API usage"}),a.jsx(or,{children:"What this machine's agent usage would cost at raw API prices."})]}),e[0]=i):i=e[0];let l;e[1]!==r?(l=Ehe.map(m=>a.jsx(Q,{variant:r===m.days?"secondary":"ghost",size:"xs",onClick:()=>o(m.days),children:m.label},m.days)),e[1]=r,e[2]=l):l=e[2];let c;e[3]!==l?(c=a.jsx(io,{children:a.jsxs("div",{className:"flex items-center justify-between gap-4 pr-6",children:[i,a.jsx("div",{className:"flex rounded-md border p-0.5",children:l})]})}),e[3]=l,e[4]=c):c=e[4];let u;e[5]!==r||e[6]!==t?(u=t&&a.jsx(Rhe,{days:r}),e[5]=r,e[6]=t,e[7]=u):u=e[7];let d;e[8]!==c||e[9]!==u?(d=a.jsxs(sr,{className:"max-h-[85vh] overflow-y-auto sm:max-w-3xl",children:[c,u]}),e[8]=c,e[9]=u,e[10]=d):d=e[10];let f;return e[11]!==s||e[12]!==t||e[13]!==d?(f=a.jsx(nr,{open:t,onOpenChange:s,children:d}),e[11]=s,e[12]=t,e[13]=d,e[14]=f):f=e[14],f}const Lhe=15e3;function Mhe(){y.useEffect(()=>{async function n(){var s,r;try{const o=await Ce("/api/notifications?limit=100");if(!o.ok)return;const i=await o.json();if(!Array.isArray(i.notifications))return;(r=(s=Eg()).onInboxRead)==null||r.call(s,i.notifications)}catch{}}n();const e=window.setInterval(()=>void n(),Lhe),t=()=>void n();return window.addEventListener("focus",t),()=>{window.clearInterval(e),window.removeEventListener("focus",t)}},[])}async function zhe(n,e){try{return(await is("/api/archive-sessions",{sessionIds:n,archived:e})).ok}catch{return!1}}function zI(){const n=ir(),e=n==null?void 0:n.setArchived,t=n==null?void 0:n.refresh,s=y.useCallback(async(r,o,i)=>{if(e==null||e(r,o),!await zhe([...r],o)){e==null||e(r,!o),Kn.error(o?"Could not archive session":"Could not restore session");return}t==null||t(),i&&Kn(i,{action:{label:"Undo",onClick:()=>{s(r,!o,null)}}})},[e,t]);return s}function DI(n,e,t){const s=V.c(13),r=ir(),o=zI();if(!r||!t)return null;let i;s[0]!==r||s[1]!==n?(i=r.isArchived(n),s[0]=r,s[1]=n,s[2]=i):i=s[2];const l=i,c=l?"Restore from archive":"Archive session",u=l?Cf:Ns,d=e&&!l?"Stop the session before archiving it":void 0;let f;s[3]!==o||s[4]!==l||s[5]!==n?(f=()=>{o([n],!l,l?"Session restored":"Session archived")},s[3]=o,s[4]=l,s[5]=n,s[6]=f):f=s[6];let m;return s[7]!==l||s[8]!==c||s[9]!==u||s[10]!==d||s[11]!==f?(m={archived:l,label:c,icon:u,disabledReason:d,toggle:f},s[7]=l,s[8]=c,s[9]=u,s[10]=d,s[11]=f,s[12]=m):m=s[12],m}const Dhe=/https:\/\/github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/,Fhe=/(?:^|[\n;&|(`])[ \t]*(?:[A-Za-z_]\w*=\S*[ \t]+)*gh[ \t]+pr[ \t]+create\b/,sg=String.raw`(?:--title|(?:^|\s)-t)(?:=|\s+)`,Uhe=[new RegExp(`${sg}"((?:[^"\\\\]|\\\\.)*)"`),new RegExp(`${sg}'([^']*)'`),new RegExp(`${sg}(\\S+)`)];function Bhe(n){const e=n.command??n.cmd;if(typeof e=="string")return[e];if(Array.isArray(e)){const i=e.filter(l=>typeof l=="string");return[i.join(" "),...i]}const t=n.source;if(typeof t!="string")return[];const s=[],r=/(?:["'](?:cmd|command)["']|\b(?:cmd|command))\s*:\s*"((?:\\.|[^"\\])*)"/g;for(const i of t.matchAll(r))try{s.push(JSON.parse(`"${i[1]}"`))}catch{}const o=/(?:["'](?:cmd|command)["']|\b(?:cmd|command))\s*:\s*`([^`]*)`/g;for(const i of t.matchAll(o))s.push(i[1]);return s}function Whe(n){return Bhe(n).find(e=>Fhe.test(e))??null}function qhe(n){for(const e of Uhe){const t=e.exec(n);if(t)return t[1].replace(/\\(.)/g,"$1")}return null}function Vhe(){const n=[],e=new Set;function t(s){e.has(s.url)||(e.add(s.url),n.push(s))}return{pullRequests:n,add:t,record(s,r,o,i){const l=Dhe.exec(s);l&&t({url:l[0],number:Number(l[3]),repo:`${l[1]}/${l[2]}`,title:qhe(r),isDraft:/(?:^|\s)--draft(?:\s|$)/.test(r),toolCallId:o,timestamp:i})}}}function Hhe(n){const e=Vhe();for(const t of n)for(const s of t.toolCalls){if(s.isError||!s.result)continue;const r=Whe(s.input);r&&e.record(s.result,r,s.id,s.timestamp)}return e.pullRequests}function Khe(...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 ti="flex h-8 items-center px-0.5",Ghe=y.memo(function(e){var me;const t=V.c(123),{showSidebar:s,sidebarRendered:r,sidebarShortcut:o,killing:i,creatingSession:l,onNewSession:c,onDuplicateSession:u,onOpenTerminal:d,onBackToMain:f,onShowWorkflows:m,workflowCount:p,onToggleSidebar:h,onKillAll:g,onOpenSettings:x,onLogout:b,onOpenMainView:w}=e,v=r===void 0?s:r,{config:j}=Sn(),{networkUrl:k,defaultAgentKind:_}=j,{session:N,sessionSource:S,isLive:C,permissions:E,actions:T}=kt(),$=ir(),{AccountControl:A,SessionHeaderActions:R}=$r(),P=Nn("viewUsage");Mhe();const[z,L]=y.useState(!1),[I,M]=y.useState(!1),[F,U]=no(),O=N==null?void 0:N.turns;let D;t[0]!==($==null?void 0:$.sessions)||t[1]!==(N==null?void 0:N.sessionId)?(D=(me=$==null?void 0:$.sessions.find(je=>je.sessionId===(N==null?void 0:N.sessionId)))==null?void 0:me.pullRequests,t[0]=$==null?void 0:$.sessions,t[1]=N==null?void 0:N.sessionId,t[2]=D):D=t[2];const B=D;let q;t[3]!==B||t[4]!==O?(q=Khe(Hhe(O??[]),B),t[3]=B,t[4]=O,t[5]=q):q=t[5];const W=q,H=DI((N==null?void 0:N.sessionId)??"",C,E.archive);let K;t[6]!==_||t[7]!==S?(K=S?S.agentKind??un(S.dirName):_,t[6]=_,t[7]=S,t[8]=K):K=t[8];const Z=K;let Y;t[9]!==S?(Y=S?$o(S.fileName)!==null:!1,t[9]=S,t[10]=Y):Y=t[10];const X=Y;let ee;t[11]!==U||t[12]!==N||t[13]!==(S==null?void 0:S.agentKind)||t[14]!==(S==null?void 0:S.dirName)?(ee=function(){if(!N)return;const Xe=(S==null?void 0:S.agentKind)??un((S==null?void 0:S.dirName)??null);U(jx(Xe,N.sessionId,N.cwd))},t[11]=U,t[12]=N,t[13]=S==null?void 0:S.agentKind,t[14]=S==null?void 0:S.dirName,t[15]=ee):ee=t[15];const te=ee;let se;t[16]!==k?(se=function(){k&&Pf(k).then(Zhe)},t[16]=k,t[17]=se):se=t[17];const J=se;let ne,ie;t[18]===Symbol.for("react.memo_cache_sentinel")?(ie=a.jsx("div",{"aria-hidden":!0,className:"drag-strip absolute inset-x-0 top-0 z-10 h-10"}),ne=a.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-x-0 top-0 z-20 h-16 bg-gradient-to-b from-background from-50% to-transparent"}),t[18]=ne,t[19]=ie):(ne=t[18],ie=t[19]);const ae=!v&&"window-inset-start";let oe;t[20]!==ae?(oe=G("electron-no-drag pointer-events-auto flex min-w-0 items-center gap-1.5",ae),t[20]=ae,t[21]=oe):oe=t[21];let ue;t[22]!==h||t[23]!==s||t[24]!==o?(ue=!s&&a.jsx(xj,{icon:k8,label:`Show sidebar (${o})`,onClick:h}),t[22]=h,t[23]=s,t[24]=o,t[25]=ue):ue=t[25];let re;t[26]!==X||t[27]!==f||t[28]!==N?(re=N&&X&&f&&a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",onClick:f,className:G(fs,"h-8 shrink-0 px-2.5 text-xs text-muted-foreground"),children:[a.jsx(it,{className:"size-3 rotate-180"}),"Main"]}),t[26]=X,t[27]=f,t[28]=N,t[29]=re):re=t[29];let de;t[30]!==F||t[31]!==l||t[32]!==te||t[33]!==C||t[34]!==u||t[35]!==c||t[36]!==d||t[37]!==W||t[38]!==N||t[39]!==S?(de=N&&a.jsx(Vpe,{session:N,sessionSource:S,isLive:C,pullRequests:W,copied:F,creatingSession:l,onCopyResume:te,onNewSession:c,onDuplicateSession:u,onOpenTerminal:d}),t[30]=F,t[31]=l,t[32]=te,t[33]=C,t[34]=u,t[35]=c,t[36]=d,t[37]=W,t[38]=N,t[39]=S,t[40]=de):de=t[40];let fe;t[41]!==X||t[42]!==N?(fe=N&&!X&&a.jsx(ype,{sessionId:N.sessionId}),t[41]=X,t[42]=N,t[43]=fe):fe=t[43];let le;t[44]!==m||t[45]!==N||t[46]!==p?(le=N&&m&&(p??0)>0&&a.jsxs(Q,{variant:"ghost",size:"xs",className:G(fs,"h-8 shrink-0 gap-1 px-2.5 text-[11px] text-muted-foreground hover:text-foreground"),onClick:m,children:[a.jsx(F4,{className:"size-3"}),"Workflows",a.jsx(Fe,{variant:"outline",className:"h-4 min-w-4 justify-center px-1 text-[9px] font-semibold",children:p})]}),t[44]=m,t[45]=N,t[46]=p,t[47]=le):le=t[47];let ce;t[48]!==oe||t[49]!==ue||t[50]!==re||t[51]!==de||t[52]!==fe||t[53]!==le?(ce=a.jsxs("div",{className:oe,children:[ue,re,de,fe,le]}),t[48]=oe,t[49]=ue,t[50]=re,t[51]=de,t[52]=fe,t[53]=le,t[54]=ce):ce=t[54];let he;t[55]===Symbol.for("react.memo_cache_sentinel")?(he=G(fs,ti,"empty:hidden"),t[55]=he):he=t[55];let ge,be;t[56]===Symbol.for("react.memo_cache_sentinel")?(ge=a.jsx("div",{className:he,children:a.jsx(Tpe,{onReview:()=>M(!0)})}),be=G(fs,ti,"empty:hidden"),t[56]=ge,t[57]=be):(ge=t[56],be=t[57]);let ve;t[58]!==Z?(ve=a.jsx("div",{className:be,children:a.jsx(ghe,{agentKind:Z})}),t[58]=Z,t[59]=ve):ve=t[59];let Se;t[60]===Symbol.for("react.memo_cache_sentinel")?(Se=a.jsx("div",{className:G(fs,ti,"empty:hidden"),children:a.jsx(Zb,{})}),t[60]=Se):Se=t[60];let we;t[61]!==Z||t[62]!==N?(we=N&&bn(Z).sharing&&xt("share")&&a.jsx("div",{className:G(fs,ti),children:a.jsx(she,{sessionId:N.sessionId})}),t[61]=Z,t[62]=N,t[63]=we):we=t[63];let Ee;t[64]!==R||t[65]!==X||t[66]!==N?(Ee=N&&!X&&R&&a.jsx("div",{className:G(fs,ti,"empty:hidden"),children:a.jsx(R,{sessionId:N.sessionId})}),t[64]=R,t[65]=X,t[66]=N,t[67]=Ee):Ee=t[67];let $e;t[68]!==H||t[69]!==X||t[70]!==N?($e=N&&!X&&H&&a.jsx(xj,{icon:H.icon,label:H.label,disabledReason:H.disabledReason,onClick:H.toggle}),t[68]=H,t[69]=X,t[70]=N,t[71]=$e):$e=t[71];let Be;t[72]===Symbol.for("react.memo_cache_sentinel")?(Be=G(fs,ti),t[72]=Be):Be=t[72];let qe;t[73]===Symbol.for("react.memo_cache_sentinel")?(qe=a.jsx(Rc,{render:a.jsx(Q,{variant:"ghost",size:"icon-sm","aria-label":"More actions"}),children:a.jsx(B4,{"data-icon":"inline-start"})}),t[73]=qe):qe=t[73];let ze;t[74]!==T||t[75]!==X||t[76]!==E.send||t[77]!==N?(ze=N&&!X&&E.send&&T.handleProviderHandoff&&a.jsxs(a.Fragment,{children:[a.jsx(qr,{children:a.jsxs(hn,{onClick:T.handleProviderHandoff,children:[a.jsx(U4,{}),"Continue with another provider…"]})}),a.jsx(Il,{})]}),t[74]=T,t[75]=X,t[76]=E.send,t[77]=N,t[78]=ze):ze=t[78];let Ie;t[79]!==P?(Ie=P&&a.jsxs(hn,{onClick:()=>L(!0),children:[a.jsx(j8,{}),"Usage & cost…"]}),t[79]=P,t[80]=Ie):Ie=t[80];let Me;t[81]===Symbol.for("react.memo_cache_sentinel")?(Me=a.jsxs(hn,{onClick:()=>M(!0),children:[a.jsx(vg,{}),"Server monitor…"]}),t[81]=Me):Me=t[81];let Ue;t[82]!==J||t[83]!==k?(Ue=k&&a.jsxs(hn,{onClick:J,children:[a.jsx(na,{className:"text-success"}),"Copy network URL",a.jsx("span",{className:"ml-auto truncate pl-2 font-mono text-[11px] text-muted-foreground",children:k})]}),t[82]=J,t[83]=k,t[84]=Ue):Ue=t[84];let De;t[85]!==Ie||t[86]!==Ue?(De=a.jsxs(qr,{children:[Ie,Me,Ue]}),t[85]=Ie,t[86]=Ue,t[87]=De):De=t[87];let Ke;t[88]===Symbol.for("react.memo_cache_sentinel")?(Ke=a.jsx(Il,{}),t[88]=Ke):Ke=t[88];let Ne;t[89]===Symbol.for("react.memo_cache_sentinel")?(Ne=a.jsx(N8,{}),t[89]=Ne):Ne=t[89];let Ae;t[90]!==x?(Ae=a.jsx(qr,{children:a.jsxs(hn,{onClick:x,children:[Ne,"Settings"]})}),t[90]=x,t[91]=Ae):Ae=t[91];let Qe;t[92]!==i||t[93]!==g?(Qe=xt("killAny")&&a.jsxs(a.Fragment,{children:[a.jsx(Il,{}),a.jsx(qr,{children:a.jsxs(hn,{variant:"destructive",onClick:g,disabled:i,children:[a.jsx(S8,{}),i?"Stopping processes…":"Stop all agent processes"]})})]}),t[92]=i,t[93]=g,t[94]=Qe):Qe=t[94];let Je;t[95]!==ze||t[96]!==De||t[97]!==Ae||t[98]!==Qe?(Je=a.jsx("div",{className:Be,children:a.jsxs($c,{children:[qe,a.jsxs(Oc,{align:"end",sideOffset:6,className:"w-64",children:[ze,De,Ke,Ae,Qe]})]})}),t[95]=ze,t[96]=De,t[97]=Ae,t[98]=Qe,t[99]=Je):Je=t[99];let ke;t[100]!==A||t[101]!==b||t[102]!==w?(ke=A&&a.jsx("div",{className:G(fs,ti,"empty:hidden"),children:a.jsx(A,{onLogout:b,onOpenMainView:w})}),t[100]=A,t[101]=b,t[102]=w,t[103]=ke):ke=t[103];let We;t[104]!==ve||t[105]!==we||t[106]!==Ee||t[107]!==$e||t[108]!==Je||t[109]!==ke?(We=a.jsxs("div",{className:"electron-no-drag window-inset-end pointer-events-auto flex shrink-0 items-center gap-1.5",children:[ge,ve,Se,we,Ee,$e,Je,ke]}),t[104]=ve,t[105]=we,t[106]=Ee,t[107]=$e,t[108]=Je,t[109]=ke,t[110]=We):We=t[110];let ye;t[111]!==ce||t[112]!==We?(ye=a.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-30 flex items-start justify-between gap-3 px-3 pt-2",children:[ce,We]}),t[111]=ce,t[112]=We,t[113]=ye):ye=t[113];let Re;t[114]!==P||t[115]!==z?(Re=P&&a.jsx(Ohe,{open:z,onOpenChange:L}),t[114]=P,t[115]=z,t[116]=Re):Re=t[116];let Ve;t[117]!==I?(Ve=a.jsx(Upe,{open:I,onOpenChange:M}),t[117]=I,t[118]=Ve):Ve=t[118];let He;return t[119]!==ye||t[120]!==Re||t[121]!==Ve?(He=a.jsxs(a.Fragment,{children:[ie,ne,ye,Re,Ve]}),t[119]=ye,t[120]=Re,t[121]=Ve,t[122]=He):He=t[122],He});function xj(n){const e=V.c(23),{icon:t,label:s,onClick:r,disabledReason:o}=n;if(o){let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=G(fs,"size-8 shrink-0"),e[0]=m):m=e[0];let p;e[1]!==t?(p=a.jsx(t,{"data-icon":"inline-start"}),e[1]=t,e[2]=p):p=e[2];let h;e[3]!==s||e[4]!==p?(h=a.jsx(Q,{variant:"ghost",size:"icon-sm",disabled:!0,"aria-label":s,className:m,children:p}),e[3]=s,e[4]=p,e[5]=h):h=e[5];let g;return e[6]!==o||e[7]!==h?(g=a.jsx(vd,{reason:o,children:h}),e[6]=o,e[7]=h,e[8]=g):g=e[8],g}let i;e[9]===Symbol.for("react.memo_cache_sentinel")?(i=G(fs,"size-8 shrink-0"),e[9]=i):i=e[9];let l;e[10]!==s||e[11]!==r?(l=a.jsx(Q,{variant:"ghost",size:"icon-sm",onClick:r,"aria-label":s,className:i}),e[10]=s,e[11]=r,e[12]=l):l=e[12];let c;e[13]!==t?(c=a.jsx(t,{"data-icon":"inline-start"}),e[13]=t,e[14]=c):c=e[14];let u;e[15]!==l||e[16]!==c?(u=a.jsx(Zt,{render:l,children:c}),e[15]=l,e[16]=c,e[17]=u):u=e[17];let d;e[18]!==s?(d=a.jsx(Yt,{side:"bottom",children:s}),e[18]=s,e[19]=d):d=e[19];let f;return e[20]!==u||e[21]!==d?(f=a.jsxs(Gt,{children:[u,d]}),e[20]=u,e[21]=d,e[22]=f):f=e[22],f}function Zhe(n){n&&Kn.success("Copied network URL")}const Yhe=y.memo(function(e){const t=V.c(13),{onToggleSidebar:s,onGoHome:r,onOpenCommandPalette:o,sidebarShortcut:i,commandPaletteShortcut:l}=e;let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx("div",{className:"flex-1"}),t[0]=c):c=t[0];let u;t[1]!==r?(u=a.jsx(Dh,{icon:ja,label:"Home",onClick:r,size:"default"}),t[1]=r,t[2]=u):u=t[2];const d=`Search (${l})`;let f;t[3]!==o||t[4]!==d?(f=a.jsx(Dh,{icon:ss,label:d,onClick:o,size:"default"}),t[3]=o,t[4]=d,t[5]=f):f=t[5];const m=`Hide sidebar (${i})`;let p;t[6]!==s||t[7]!==m?(p=a.jsx(Dh,{icon:C8,label:m,onClick:s,size:"default"}),t[6]=s,t[7]=m,t[8]=p):p=t[8];let h;return t[9]!==u||t[10]!==f||t[11]!==p?(h=a.jsxs("div",{className:"electron-drag window-inset-start flex h-12 shrink-0 items-center gap-1 px-2",children:[c,u,f,p]}),t[9]=u,t[10]=f,t[11]=p,t[12]=h):h=t[12],h});function Xhe(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex h-full w-full aria-[orientation=vertical]:flex-col",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(T8,{"data-slot":"resizable-panel-group",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function bj(n){const e=V.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(E8,{"data-slot":"resizable-panel",...t}),e[2]=t,e[3]=s):s=e[3],s}function Jhe(n){const e=V.c(12);let t,s,r;e[0]!==n?({withHandle:r,className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);let o;e[4]!==t?(o=G("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90",t),e[4]=t,e[5]=o):o=e[5];let i;e[6]!==r?(i=r&&a.jsx("div",{className:"z-10 flex h-6 w-1 shrink-0 rounded-lg bg-border"}),e[6]=r,e[7]=i):i=e[7];let l;return e[8]!==s||e[9]!==o||e[10]!==i?(l=a.jsx(_8,{"data-slot":"resizable-handle",className:o,...s,children:i}),e[8]=s,e[9]=o,e[10]=i,e[11]=l):l=e[11],l}const FI=y.createContext(null);function UI(n){const e=V.c(3),{value:t,children:s}=n;let r;return e[0]!==s||e[1]!==t?(r=a.jsx(FI.Provider,{value:t,children:s}),e[0]=s,e[1]=t,e[2]=r):r=e[2],r}function Jb(){const n=y.useContext(FI);if(!n)throw new Error("Built-in workspace panel services are unavailable");return n}function BI(n){const e=V.c(18),{title:t,icon:s,active:r,onClick:o,children:i}=n,l=r&&"bg-sidebar-primary text-sidebar-primary-foreground hover:bg-sidebar-primary/90 hover:text-sidebar-primary-foreground";let c;e[0]!==l?(c=G("relative rounded-md",l),e[0]=l,e[1]=c):c=e[1];let u;e[2]!==r||e[3]!==o||e[4]!==c||e[5]!==t?(u=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm","aria-label":t,"aria-pressed":r,onClick:o,className:c}),e[2]=r,e[3]=o,e[4]=c,e[5]=t,e[6]=u):u=e[6];let d;e[7]!==s?(d=a.jsx(s,{"data-icon":"inline-start"}),e[7]=s,e[8]=d):d=e[8];let f;e[9]!==i||e[10]!==u||e[11]!==d?(f=a.jsxs(Zt,{render:u,children:[d,i]}),e[9]=i,e[10]=u,e[11]=d,e[12]=f):f=e[12];let m;e[13]!==t?(m=a.jsx(Yt,{side:"left",children:t}),e[13]=t,e[14]=m):m=e[14];let p;return e[15]!==f||e[16]!==m?(p=a.jsxs(Gt,{children:[f,m]}),e[15]=f,e[16]=m,e[17]=p):p=e[17],p}function Qb(n,e){return n.filter(t=>{var s;return((s=t.when)==null?void 0:s.call(t,e))??!0})}function Qhe(n){const e=V.c(25),{panels:t,context:s,activePanelId:r,onTogglePanel:o,actions:i}=n;let l;e[0]!==i?(l=i===void 0?[]:i,e[0]=i,e[1]=l):l=e[1];const c=l;let u,d,f,m,p,h;if(e[2]!==c||e[3]!==r||e[4]!==s||e[5]!==o||e[6]!==t){h=Symbol.for("react.early_return_sentinel");e:{const x=Qb(t,s);if(x.length===0&&c.length===0){h=null;break e}u="Workspace panels",d="electron-no-drag flex w-11 shrink-0 flex-col items-center gap-1 border-l bg-sidebar py-2 text-sidebar-foreground",e[13]!==c?(f=c.map(ege),e[13]=c,e[14]=f):f=e[14],m=c.length>0&&x.length>0&&a.jsx("div",{"aria-hidden":!0,className:"my-1 h-px w-6 bg-sidebar-border"});let b;e[15]!==r||e[16]!==s||e[17]!==o?(b=w=>{var _;const v=w.id===r,j=(_=w.badge)==null?void 0:_.call(w,s),k=w.indicator;return a.jsx(BI,{title:w.title,icon:w.icon,active:v,onClick:()=>o(w.id),children:k?a.jsx(k,{...w.indicatorProps,context:s,active:v}):j!=null&&a.jsx(Fe,{className:"absolute -right-1 -top-1 min-w-4 px-1 text-[9px]",variant:"secondary",children:j})},w.id)},e[15]=r,e[16]=s,e[17]=o,e[18]=b):b=e[18],p=x.map(b)}e[2]=c,e[3]=r,e[4]=s,e[5]=o,e[6]=t,e[7]=u,e[8]=d,e[9]=f,e[10]=m,e[11]=p,e[12]=h}else u=e[7],d=e[8],f=e[9],m=e[10],p=e[11],h=e[12];if(h!==Symbol.for("react.early_return_sentinel"))return h;let g;return e[19]!==u||e[20]!==d||e[21]!==f||e[22]!==m||e[23]!==p?(g=a.jsxs("aside",{"aria-label":u,className:d,children:[f,m,p]}),e[19]=u,e[20]=d,e[21]=f,e[22]=m,e[23]=p,e[24]=g):g=e[24],g}function ege(n){return a.jsx(BI,{title:n.title,icon:n.icon,active:n.active,onClick:n.onSelect},n.id)}function WI(n){const e=V.c(20),{panels:t,context:s,activePanelId:r,onClosePanel:o,active:i}=n,l=i===void 0?!0:i;let c;e[0]!==r?(c=()=>new Set([r]),e[0]=r,e[1]=c):c=e[1];const[u,d]=y.useState(c);let f,m;e[2]!==r?(f=()=>{d(g=>{if(g.has(r))return g;const x=new Set(g);return x.add(r),x})},m=[r],e[2]=r,e[3]=f,e[4]=m):(f=e[3],m=e[4]),y.useEffect(f,m);let p;if(e[5]!==r||e[6]!==s||e[7]!==l||e[8]!==o||e[9]!==t||e[10]!==u){let g;e[12]!==r||e[13]!==s||e[14]!==l||e[15]!==o||e[16]!==u?(g=x=>{const b=x.id===r,w=b&&l;if(!b&&(!x.keepAlive||!u.has(x.id)))return null;const v=x.component;return a.jsx("div",{className:G("absolute inset-0 min-h-0",!w&&"hidden"),"aria-hidden":!w,children:a.jsx(v,{...x.componentProps,context:s,active:w,closePanel:o})},x.id)},e[12]=r,e[13]=s,e[14]=l,e[15]=o,e[16]=u,e[17]=g):g=e[17],p=t.map(g),e[5]=r,e[6]=s,e[7]=l,e[8]=o,e[9]=t,e[10]=u,e[11]=p}else p=e[11];let h;return e[18]!==p?(h=a.jsx("div",{className:"relative h-full min-h-0 overflow-hidden bg-canvas",children:p}),e[18]=p,e[19]=h):h=e[19],h}function tge(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 nge(n){const e=V.c(23),{children:t,panels:s,context:r,activePanel:o,services:i,onClosePanel:l,onTogglePanel:c,actions:u}=n;let d;e[0]!==o?(d=o?tge(o.defaultSize):"100%",e[0]=o,e[1]=d):d=e[1];let f;e[2]!==t||e[3]!==d?(f=a.jsx(bj,{defaultSize:d,minSize:"320px",children:t}),e[2]=t,e[3]=d,e[4]=f):f=e[4];let m;e[5]!==o||e[6]!==r||e[7]!==l||e[8]!==s||e[9]!==i?(m=o&&a.jsxs(a.Fragment,{children:[a.jsx(Jhe,{withHandle:!0}),a.jsx(bj,{defaultSize:o.defaultSize??"36%",minSize:o.minSize??"300px",maxSize:o.maxSize??"70%",children:a.jsx(UI,{value:i,children:a.jsx(WI,{panels:s,context:r,activePanelId:o.id,onClosePanel:l})})})]}),e[5]=o,e[6]=r,e[7]=l,e[8]=s,e[9]=i,e[10]=m):m=e[10];let p;e[11]!==f||e[12]!==m?(p=a.jsxs(Xhe,{orientation:"horizontal",className:"min-h-0 min-w-0 w-auto flex-1",children:[f,m]}),e[11]=f,e[12]=m,e[13]=p):p=e[13];const h=(o==null?void 0:o.id)??null;let g;e[14]!==u||e[15]!==r||e[16]!==c||e[17]!==s||e[18]!==h?(g=a.jsx(Qhe,{panels:s,context:r,activePanelId:h,onTogglePanel:c,actions:u}),e[14]=u,e[15]=r,e[16]=c,e[17]=s,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==p||e[21]!==g?(x=a.jsxs(a.Fragment,{children:[p,g]}),e[20]=p,e[21]=g,e[22]=x):x=e[22],x}function qI(n){const e=V.c(7),[t]=y.useState(rge),s=y.useSyncExternalStore(t.subscribe,t.getSnapshot,sge);let r,o;e[0]!==t||e[1]!==n?(r=()=>{if(n)return t.start(),()=>t.stop()},o=[t,n],e[0]=t,e[1]=n,e[2]=r,e[3]=o):(r=e[2],o=e[3]),y.useEffect(r,o);let i;return e[4]!==t||e[5]!==s?(i={client:t,...s},e[4]=t,e[5]=s,e[6]=i):i=e[6],i}function sge(){return Yg}function rge(){return new VV}function Kr(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)?n:null}function dn(n,e=""){return typeof n=="string"?n:e}const oge=new Set(["open","custom","closed","done"]),ige=new Set(["urgent","high","normal","low"]);class age extends Error{constructor(t,s,r){super(r);Ge(this,"status");Ge(this,"code");this.status=t,this.code=s}}function vj(n){return typeof n=="number"?String(n):dn(n)}function ni(n){const e=typeof n=="string"?Number(n):n;return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function lge(n){const e=Kr(n);return e&&e.hidden!==!0&&dn(e.name)||null}function cge(n){return new age(502,"invalid_response",`ClickUp returned an invalid ${n} response`)}function uge(n){const e=Kr(n);if(!e||typeof e.id!="number")return null;const t=dn(e.username)||dn(e.email);return{id:e.id,username:t,initials:dn(e.initials)||t.slice(0,2).toUpperCase(),color:dn(e.color)||null}}function dge(n){const e=Kr(n);if(!e)return null;const t=dn(e.status);if(!t)return null;const s=dn(e.type);return{name:t,type:oge.has(s)?s:"custom",color:dn(e.color,"#d3d3d3"),order:typeof e.orderindex=="number"?e.orderindex:0}}function fge(n){const e=Kr(n),t=dn(e==null?void 0:e.name);return t?{name:t,background:dn(e==null?void 0:e.tag_bg)||null}:null}function mge(n){var t;const e=dn((t=Kr(n))==null?void 0:t.priority);return ige.has(e)?e:null}function pge(n){var i;const e=Kr(n);if(!e)return null;const t=dn(e.id),s=dge(e.status),r=Kr(e.list);if(!t||!s||!r)return null;const o=dn(e.custom_id);return{id:t,customId:o||null,name:dn(e.name,"Untitled task"),description:dn(e.markdown_description)||dn(e.description),status:s,priority:mge(e.priority),url:dn(e.url)||`https://app.clickup.com/t/${t}`,assignees:Array.isArray(e.assignees)?e.assignees.map(uge).filter(l=>l!==null):[],tags:Array.isArray(e.tags)?e.tags.map(fge).filter(l=>l!==null):[],parentId:dn(e.parent)||null,listId:vj(r.id),listName:dn(r.name,"List"),folderName:lge(e.folder),spaceId:vj((i=Kr(e.space))==null?void 0:i.id),createdAt:ni(e.date_created)??0,updatedAt:ni(e.date_updated)??ni(e.date_created)??0,dueAt:ni(e.due_date),startAt:ni(e.start_date),closedAt:ni(e.date_closed)??ni(e.date_done)}}function hge(n){const e=Kr(n);if(!e||!Array.isArray(e.tasks))throw cge("task list");return{tasks:e.tasks.map(pge).filter(t=>t!==null),lastPage:e.last_page!==!1}}const gge="absolute -right-1 -top-1 min-w-4 px-1 text-[9px]",xge="absolute -right-0.5 -top-0.5 size-3 p-0 text-[8px]",bge=new Set(["cogpit.github","cogpit.vercel","cogpit.clickup"]),vge=new Set(["action_required","failure","startup_failure","timed_out"]),yge=new Set(["BUILDING","INITIALIZING","QUEUED"]),wge=new Set(["BLOCKED","CANCELED","ERROR"]);function xf(n,e,t="default"){return n?{text:String(n),label:e,variant:t}:null}function Sge(n,e){var r;const t=n.filter(o=>o.status!=="completed").length;if(t)return xf(t,`${t} active GitHub Actions run${t===1?"":"s"}`);if((r=n[0])!=null&&r.conclusion&&vge.has(n[0].conclusion))return{text:"!",label:"Latest GitHub Actions run failed",variant:"destructive",compact:!0};const s=e.filter(o=>(o.state==="open"||o.state==="draft")&&o.reviewRequested).length;return xf(s,`${s} pull request${s===1?"":"s"} waiting for your review`,"secondary")}function kge(n){const e=n.filter(t=>yge.has(t.state)).length;return e?xf(e,`${e} active Vercel deployment${e===1?"":"s"}`):n[0]&&wge.has(n[0].state)?{text:"!",label:"Latest Vercel deployment failed",variant:"destructive",compact:!0}:null}function jge(n){const e=new Date;e.setHours(0,0,0,0);const t=n.filter(s=>s.status.type!=="closed"&&s.dueAt!==null&&s.dueAt<e.getTime()).length;return xf(t,`${t} overdue ClickUp task${t===1?"":"s"}`,"destructive")}class yj extends Error{}function Nge(n){let e=[],t=[],s=-1/0;return async(r,o)=>{let i=0;async function l(d){const f=await r({protocol:1,type:"request",id:`indicator-${++i}`,method:"integrations.request",params:d});if(o.throwIfAborted(),!f.ok)throw new yj("Integration unavailable");return f.data}if(n==="cogpit.vercel"){const d=await l({integration:"vercel",operation:"deployments",limit:20});return kge(d.deployments)}if(n==="cogpit.github"){const d=await Promise.allSettled([l({integration:"github",operation:"actions",limit:20}),Date.now()-s>=3e4?l({integration:"github",operation:"pulls",limit:30}):Promise.resolve(null)]);o.throwIfAborted();for(const p of d)if(p.status==="rejected"&&!(p.reason instanceof yj))throw p.reason;const[f,m]=d;return f.status==="fulfilled"&&(e=f.value.runs),m.status==="fulfilled"&&m.value!==null&&(t=m.value.pulls,s=Date.now()),Sge(e,t)}const c=await r({protocol:1,type:"request",id:"indicator-status",method:"connections.status",params:{handle:"clickup"}});if(o.throwIfAborted(),!c.configured||!c.selected.workspace)return null;const u=new Map;for(let d=0;d<3;d++){const f=hge(await r({protocol:1,type:"request",id:`indicator-page-${d}`,method:"connections.request",params:{handle:"clickup",operationId:"mine",args:{page:d}}}));o.throwIfAborted();for(const m of f.tasks)u.set(m.id,m);if(f.lastPage)break}return jge([...u.values()])}}function Cge({client:n,pluginId:e,projectId:t,workspacePath:s,activation:r,registryRevision:o,enabled:i=!0}){const l=JSON.stringify([e,t,s,r,o,i]),[c,u]=y.useState(null);y.useEffect(()=>{if(!i||!r||!bge.has(e)||e!=="cogpit.clickup"&&(!t||!s))return;const f=new AbortController,m=Nge(e),p=e==="cogpit.clickup"?6e4:1e4,h=Array.from(crypto.getRandomValues(new Uint8Array(16)),k=>k.toString(16).padStart(2,"0")).join("");let g,x=null,b=!1;function w(){const k=x;x=null,k&&n.revokeLease(k).catch(()=>{})}async function v(){if(b||f.signal.aborted)return;if(document.visibilityState==="hidden"){g=setTimeout(()=>{v()},p);return}b=!0;const k=new AbortController,_=Date.now()+2e4;let N=setTimeout(()=>{k.abort(),w()},2e4);const S=AbortSignal.any([f.signal,k.signal]);try{const C=await n.lease(e,t,h,S,s);x=C.id,S.throwIfAborted();const E=Math.min(_,C.expiresAt)-Date.now();if(E<=0)throw new Error("Plugin lease expired");clearTimeout(N),N=setTimeout(()=>{k.abort(),w()},E);const T=await m($=>(S.throwIfAborted(),n.call(C.id,$,S)),S);S.throwIfAborted(),u({client:n,identity:l,indicator:T})}catch{f.signal.aborted||u({client:n,identity:l,indicator:null})}finally{clearTimeout(N),w(),b=!1,f.signal.aborted||(g=setTimeout(()=>{v()},p))}}function j(){document.visibilityState==="visible"&&!b&&(clearTimeout(g),v())}return v(),document.addEventListener("visibilitychange",j),()=>{f.abort(),clearTimeout(g),document.removeEventListener("visibilitychange",j),w()}},[n,e,t,s,r,o,i,l]);const d=(c==null?void 0:c.client)===n&&c.identity===l?c.indicator:null;return d?a.jsx(Fe,{variant:d.variant,className:d.compact?xge:gge,"aria-label":d.label,children:d.text}):null}function _ge(n){const e=V.c(8),t=y.useRef(null),[s,r]=y.useState(null);let o,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>()=>{var m;(m=t.current)==null||m.finish(!1)},i=[],e[0]=o,e[1]=i):(o=e[0],i=e[1]),y.useEffect(o,i);let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=(m,p)=>{p.throwIfAborted();const h=new URL(m);return m.length>2048||h.protocol!=="https:"||h.username||h.password?Promise.reject(Object.assign(new Error("Only HTTPS links without credentials are supported"),{code:"INVALID_REQUEST"})):t.current?Promise.reject(Object.assign(new Error("A link is already awaiting review"),{code:"RATE_LIMITED"})):new Promise((g,x)=>{const b=()=>w.finish(!1),w={url:h.href,finish(v){t.current===w&&(t.current=null,p.removeEventListener("abort",b),r(null),v&&!p.aborted?g():x(Object.assign(new Error("Opening the link was canceled"),{code:"CANCELED"})))}};t.current=w,p.addEventListener("abort",b,{once:!0}),r(w)})},e[2]=l):l=e[2];const c=l;let u;e[3]!==s||e[4]!==n?(u=s?a.jsx(nr,{open:!0,onOpenChange:m=>{var p;m||(p=t.current)==null||p.finish(!1)},children:a.jsxs(sr,{children:[a.jsxs(rr,{children:["Open link from ",n,"?"]}),a.jsx(or,{children:"This opens a website outside Cogpit."}),a.jsx("p",{className:"max-h-48 overflow-auto break-all rounded-md bg-muted p-3 text-sm",dir:"ltr",children:s==null?void 0:s.url}),a.jsxs(Px,{children:[a.jsx(Q,{variant:"outline",onClick:()=>{var m;return(m=t.current)==null?void 0:m.finish(!1)},children:"Cancel"}),a.jsx(Q,{onClick:()=>{!s||t.current!==s||(window.open(s.url,"_blank","noopener,noreferrer"),s.finish(!0))},children:"Open website"})]})]})}):null,e[3]=s,e[4]=n,e[5]=u):u=e[5];const d=u;let f;return e[6]!==d?(f={openExternal:c,dialog:d},e[6]=d,e[7]=f):f=e[7],f}function Ege(n){const e=V.c(20),t=Y0();let s;e[0]!==n.activation||e[1]!==n.plugin.id||e[2]!==n.plugin.selectedDigest||e[3]!==n.registryRevision?(s=JSON.stringify([n.activation,n.registryRevision,n.plugin.id,n.plugin.selectedDigest]),e[0]=n.activation,e[1]=n.plugin.id,e[2]=n.plugin.selectedDigest,e[3]=n.registryRevision,e[4]=s):s=e[4];const r=s;if(!n.activation||!n.plugin.enabled||t)return null;let o;e[5]!==n?(o=n.openSettings&&n.plugin.manifest.permissions.connections.length>0&&a.jsx(Q,{size:"sm",variant:"ghost",onClick:()=>{var m;return(m=n.openSettings)==null?void 0:m.call(n,n.plugin.id)},children:"Connections"}),e[5]=n,e[6]=o):o=e[6];const i=`Close ${n.title??n.plugin.manifest.name}`;let l;e[7]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(Mt,{className:"size-4"}),e[7]=l):l=e[7];let c;e[8]!==n.closePanel||e[9]!==i?(c=a.jsx(Q,{size:"icon-sm",variant:"ghost","aria-label":i,onClick:n.closePanel,children:l}),e[8]=n.closePanel,e[9]=i,e[10]=c):c=e[10];let u;e[11]!==o||e[12]!==c?(u=a.jsxs("div",{className:"flex items-center justify-end gap-1 border-b px-2 py-1",children:[o,c]}),e[11]=o,e[12]=c,e[13]=u):u=e[13];let d;e[14]!==r||e[15]!==n?(d=a.jsx("div",{className:"min-h-0 flex-1",children:a.jsx(Tge,{...n},r)}),e[14]=r,e[15]=n,e[16]=d):d=e[16];let f;return e[17]!==u||e[18]!==d?(f=a.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[u,d]}),e[17]=u,e[18]=d,e[19]=f):f=e[19],f}function Tge(n){var p,h,g,x,b,w;const e=V.c(36);let t;e[0]!==n.context.projectPath||e[1]!==((p=n.project)==null?void 0:p.id)||e[2]!==((h=n.project)==null?void 0:h.name)?(t=JSON.stringify([(g=n.project)==null?void 0:g.id,(x=n.project)==null?void 0:x.name,n.context.projectPath]),e[0]=n.context.projectPath,e[1]=(b=n.project)==null?void 0:b.id,e[2]=(w=n.project)==null?void 0:w.name,e[3]=t):t=e[3];const s=t;let r;e[4]!==s||e[5]!==n.context.projectPath||e[6]!==n.project?(r={key:s,project:n.project,path:n.context.projectPath},e[4]=s,e[5]=n.context.projectPath,e[6]=n.project,e[7]=r):r=e[7];const o=r;let i;e[8]!==o?(i=[o],e[8]=o,e[9]=i):i=e[9];let l;e[10]!==s?(l=[s],e[10]=s,e[11]=l):l=e[11];let c;e[12]!==i||e[13]!==l?(c={entries:i,recent:l},e[12]=i,e[13]=l,e[14]=c):c=e[14];const[u,d]=y.useState(c);let f=u.entries;if(u.recent.at(-1)!==s){let v;if(e[15]!==u.recent||e[16]!==s){let k;e[18]!==s?(k=_=>_!==s,e[18]=s,e[19]=k):k=e[19],v=[...u.recent.filter(k),s].slice(-3),e[15]=u.recent,e[16]=s,e[17]=v}else v=e[17];const j=v;if(e[20]!==u.entries||e[21]!==o||e[22]!==s||e[23]!==j){let k;e[25]!==j?(k=N=>j.includes(N.key),e[25]=j,e[26]=k):k=e[26],f=u.entries.filter(k);let _;e[27]!==s?(_=N=>N.key===s,e[27]=s,e[28]=_):_=e[28],f.some(_)||(f=[...f,o]),e[20]=u.entries,e[21]=o,e[22]=s,e[23]=j,e[24]=f}else f=e[24];d({entries:f,recent:j})}let m;if(e[29]!==f||e[30]!==s||e[31]!==n){let v;e[33]!==s||e[34]!==n?(v=j=>a.jsx("div",{className:"h-full min-h-0",hidden:j.key!==s,children:a.jsx(Age,{...n,epoch:j.key,project:j.project,context:{...n.context,projectPath:j.path},active:n.active&&j.key===s})},j.key),e[33]=s,e[34]=n,e[35]=v):v=e[35],m=f.map(v),e[29]=f,e[30]=s,e[31]=n,e[32]=m}else m=e[32];return m}function Age(n){var re,de,fe;const e=V.c(73),{client:t,plugin:s,project:r,active:o,title:i,epoch:l,context:c}=n,u=UE(),{openExternal:d,dialog:f}=_ge(s.manifest.name),[m]=y.useState(Pge),p=y.useRef(o),h=y.useRef(c.composePrompt),g=y.useRef(c.openSession),x=y.useRef(null);let b;e[0]!==((re=c.session)==null?void 0:re.sessionId)||e[1]!==c.sessionChangeKey?(b=JSON.stringify([(de=c.session)==null?void 0:de.sessionId,c.sessionChangeKey]),e[0]=(fe=c.session)==null?void 0:fe.sessionId,e[1]=c.sessionChangeKey,e[2]=b):b=e[2];const w=b,[v,j]=y.useState(null),[k,_]=y.useState(null);let N,S;e[3]!==o?(N=()=>{var le;p.current=o,(le=x.current)==null||le.setActive(o)},S=[o],e[3]=o,e[4]=N,e[5]=S):(N=e[4],S=e[5]),y.useLayoutEffect(N,S);let C;e[6]===Symbol.for("react.memo_cache_sentinel")?(C=()=>{var le;(le=x.current)==null||le.resetSession()},e[6]=C):C=e[6];let E;e[7]!==w?(E=[w],e[7]=w,e[8]=E):E=e[8],y.useLayoutEffect(C,E);let T,$;e[9]!==c.composePrompt?(T=()=>{h.current=c.composePrompt},$=[c.composePrompt],e[9]=c.composePrompt,e[10]=T,e[11]=$):(T=e[10],$=e[11]),y.useLayoutEffect(T,$);let A,R;e[12]!==c.openSession?(A=()=>{g.current=c.openSession},R=[c.openSession],e[12]=c.openSession,e[13]=A,e[14]=R):(A=e[13],R=e[14]),y.useLayoutEffect(A,R);const P=s.id,z=s.selectedDigest,L=(r==null?void 0:r.id)??null;let I;e[15]!==c.composePrompt||e[16]!==s.manifest.permissions.composer?(I=s.manifest.permissions.composer.includes("append")&&!!c.composePrompt,e[15]=c.composePrompt,e[16]=s.manifest.permissions.composer,e[17]=I):I=e[17];const M=I;let F;e[18]!==c.openSession||e[19]!==s.manifest.permissions.navigation?(F=s.manifest.permissions.navigation.includes("session")&&!!c.openSession,e[18]=c.openSession,e[19]=s.manifest.permissions.navigation,e[20]=F):F=e[20];const U=F,O=r?c.projectPath:null;let D;e[21]!==s.manifest.permissions.navigation?(D=s.manifest.permissions.navigation.includes("external"),e[21]=s.manifest.permissions.navigation,e[22]=D):D=e[22];const B=D,q=s.manifest.permissions.context.includes("session.identity")&&t.sessionHandle&&O?c.sessionAddress??null:null,W=(q==null?void 0:q.dirName)??null,H=(q==null?void 0:q.fileName)??null,[K,Z]=y.useState(null);let Y,X;e[23]!==t||e[24]!==W||e[25]!==H||e[26]!==v?(Y=()=>{if(!v||!W||!H)return;const le=new AbortController;return t.sessionHandle(v.leaseId,{dirName:W,fileName:H},le.signal).then(ce=>{le.signal.aborted||Z({leaseId:v.leaseId,dirName:W,fileName:H,handle:ce})}).catch(Ige),()=>le.abort()},X=[t,v,W,H],e[23]=t,e[24]=W,e[25]=H,e[26]=v,e[27]=Y,e[28]=X):(Y=e[27],X=e[28]),y.useEffect(Y,X);const ee=K&&v&&K.leaseId===v.leaseId&&K.dirName===W&&K.fileName===H?K.handle:null;let te;e[29]!==M||e[30]!==B||e[31]!==U||e[32]!==t||e[33]!==m||e[34]!==z||e[35]!==d||e[36]!==P||e[37]!==L||e[38]!==O?(te=()=>{const le=DE({client:t,pluginId:P,digest:z,projectId:L,workspacePath:O,contextEpoch:m,active:p.current,...M?{appendDraft:ce=>{var he;return(he=h.current)==null?void 0:he.call(h,ce)}}:{},...U?{openSession:(ce,he)=>{var ge;return(ge=g.current)==null?void 0:ge.call(g,ce,he)}}:{},...B?{openExternal:d}:{},onLoaded:(ce,he)=>j({payload:ce,leaseId:he,runtime:le}),onError:ce=>_(ce.message)});return x.current=le,()=>{le.dispose(),x.current=null}},e[29]=M,e[30]=B,e[31]=U,e[32]=t,e[33]=m,e[34]=z,e[35]=d,e[36]=P,e[37]=L,e[38]=O,e[39]=te):te=e[39];let se;if(e[40]!==M||e[41]!==B||e[42]!==U||e[43]!==t||e[44]!==m||e[45]!==z||e[46]!==l||e[47]!==d||e[48]!==P||e[49]!==L||e[50]!==O?(se=[t,P,z,L,l,m,M,B,d,U,O],e[40]=M,e[41]=B,e[42]=U,e[43]=t,e[44]=m,e[45]=z,e[46]=l,e[47]=d,e[48]=P,e[49]=L,e[50]=O,e[51]=se):se=e[51],y.useLayoutEffect(te,se),k){let le;return e[52]!==k?(le=a.jsx("p",{role:"alert",className:"p-4 text-sm text-destructive",children:k}),e[52]=k,e[53]=le):le=e[53],le}if(!v){let le;return e[54]===Symbol.for("react.memo_cache_sentinel")?(le=a.jsx("p",{role:"status",className:"p-4 text-sm text-muted-foreground",children:"Loading plugin…"}),e[54]=le):le=e[54],le}const J=v.payload,ne=`${l}:${v.leaseId}`;let ie;e[55]!==o||e[56]!==ee||e[57]!==s.manifest||e[58]!==u||e[59]!==r?(ie=FE(s.manifest,r,o,u,ee),e[55]=o,e[56]=ee,e[57]=s.manifest,e[58]=u,e[59]=r,e[60]=ie):ie=e[60];const ae=i??s.manifest.name;let oe;e[61]!==o||e[62]!==z||e[63]!==v.payload||e[64]!==v.runtime.execute||e[65]!==v.runtime.fail||e[66]!==ne||e[67]!==ie||e[68]!==ae?(oe=a.jsx(zE,{payload:J,digest:z,activationKey:ne,context:ie,active:o,title:ae,execute:v.runtime.execute,onError:v.runtime.fail}),e[61]=o,e[62]=z,e[63]=v.payload,e[64]=v.runtime.execute,e[65]=v.runtime.fail,e[66]=ne,e[67]=ie,e[68]=ae,e[69]=oe):oe=e[69];let ue;return e[70]!==f||e[71]!==oe?(ue=a.jsxs(a.Fragment,{children:[oe,f]}),e[70]=f,e[71]=oe,e[72]=ue):ue=e[72],ue}function Ige(){}function Pge(){return Array.from(crypto.getRandomValues(new Uint8Array(16)),$ge).join("")}function $ge(n){return n.toString(16).padStart(2,"0")}function Rge(n,e,t){const s=V.c(16);let r;s[0]===Symbol.for("react.memo_cache_sentinel")?(r={summary:null,loading:!1,error:null},s[0]=r):r=s[0];const[o,i]=y.useState(r),[l,c]=y.useState(0);let u,d;s[1]!==n||s[2]!==e?(u=()=>{i({summary:null,loading:!!(n&&e),error:null})},d=[n,e],s[1]=n,s[2]=e,s[3]=u,s[4]=d):(u=s[3],d=s[4]),y.useEffect(u,d);let f;s[5]!==n||s[6]!==e?(f=()=>{if(!n||!e)return;const x=new AbortController;i(Lge);const b=new URLSearchParams({dirName:n,fileName:e});return Ce(`/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();i({summary:v,loading:!1,error:null})}).catch(w=>{x.signal.aborted||i(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(Oge),s[13]=p):p=s[13];const h=p;let g;return s[14]!==o?(g={...o,refresh:h},s[14]=o,s[15]=g):g=s[15],g}function Oge(n){return n+1}function Lge(n){return{...n,loading:!0,error:null}}function Mge(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 zge(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 Dge(){const n=V.c(3);let e,t;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(Gn,{className:"h-4 w-24"}),a.jsx(Gn,{className:"h-10 w-32"}),a.jsx(Gn,{className:"h-3 w-44"})]}),t=a.jsx(Gn,{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=a.jsxs("div",{className:"flex flex-col gap-5 pt-2",role:"status","aria-label":"Reading session cost",children:[e,t,a.jsxs("div",{className:"flex flex-col gap-3",children:[a.jsx(Gn,{className:"h-8 w-full"}),a.jsx(Gn,{className:"h-8 w-full"}),a.jsx(Gn,{className:"h-8 w-full"})]})]}),n[2]=s):s=n[2],s}function Fge(n){const e=V.c(10),{message:t,retry:s}=n;let r,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(yf,{}),o=a.jsx(tn,{children:"Cost unavailable"}),e[0]=r,e[1]=o):(r=e[0],o=e[1]);let i;e[2]!==t?(i=a.jsx(Rt,{children:t}),e[2]=t,e[3]=i):i=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(Fn,{"data-icon":"inline-start"}),e[4]=l):l=e[4];let c;e[5]!==s?(c=a.jsxs(Q,{variant:"outline",size:"xs",onClick:s,className:"mt-2",children:[l,"Retry"]}),e[5]=s,e[6]=c):c=e[6];let u;return e[7]!==i||e[8]!==c?(u=a.jsxs(jt,{variant:"destructive",className:"mt-2",children:[r,o,i,c]}),e[7]=i,e[8]=c,e[9]=u):u=e[9],u}function Ku(n){const e=V.c(7),{label:t,value:s}=n;let r;e[0]!==t?(r=a.jsx("dt",{className:"text-xs text-muted-foreground",children:t}),e[0]=t,e[1]=r):r=e[1];let o;e[2]!==s?(o=a.jsx("dd",{className:"truncate text-sm font-medium text-foreground tabular-nums",children:s}),e[2]=s,e[3]=o):o=e[3];let i;return e[4]!==r||e[5]!==o?(i=a.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[r,o]}),e[4]=r,e[5]=o,e[6]=i):i=e[6],i}function Uge(n){const e=V.c(22),{row:t,totalCost:s}=n,r=s>0?t.costUsd/s*100:0;let o;e[0]!==t.label?(o=a.jsx(ZE,{children:t.label}),e[0]=t.label,e[1]=o):o=e[1];let i;e[2]!==t.costUsd?(i=a.jsx(YE,{children:()=>gs(t.costUsd)}),e[2]=t.costUsd,e[3]=i):i=e[3];let l;e[4]!==r||e[5]!==o||e[6]!==i?(l=a.jsxs(qc,{value:r,children:[o,i]}),e[4]=r,e[5]=o,e[6]=i,e[7]=l):l=e[7];let c;e[8]!==t.tokens?(c=t.tokens>0?vt(t.tokens):"Reported by provider",e[8]=t.tokens,e[9]=c):c=e[9];let u;e[10]!==c?(u=a.jsx("span",{children:c}),e[10]=c,e[11]=u):u=e[11];let d;e[12]!==r?(d=r>0?`${r.toFixed(1)}%`:"—",e[12]=r,e[13]=d):d=e[13];let f;e[14]!==d?(f=a.jsx("span",{children:d}),e[14]=d,e[15]=f):f=e[15];let m;e[16]!==u||e[17]!==f?(m=a.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs text-muted-foreground tabular-nums",children:[u,f]}),e[16]=u,e[17]=f,e[18]=m):m=e[18];let p;return e[19]!==l||e[20]!==m?(p=a.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 Bge(n){const e=V.c(8),{summary:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.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 r;if(e[1]!==t.costUsd||e[2]!==t.models){let i;e[4]!==t.costUsd?(i=l=>{const c=t.costUsd>0?l.costUsd/t.costUsd*100:0;return a.jsxs("div",{className:"flex flex-col gap-1.5",children:[a.jsxs(qc,{value:c,children:[a.jsx(ZE,{title:l.model,children:ao(l.model)}),a.jsx(YE,{children:()=>l.costSource==="unpriced"?"Unpriced":gs(l.costUsd)})]}),a.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs text-muted-foreground tabular-nums",children:[a.jsxs("span",{children:[l.records," ",l.records===1?"call":"calls"]}),a.jsxs("span",{children:[vt(Xb(l.totals))," tokens"]})]})]},l.model)},e[4]=t.costUsd,e[5]=i):i=e[5],r=t.models.map(i),e[1]=t.costUsd,e[2]=t.models,e[3]=r}else r=e[3];let o;return e[6]!==r?(o=a.jsxs("section",{"aria-labelledby":"cost-models-heading",className:"flex flex-col gap-3",children:[s,a.jsx("div",{className:"flex flex-col gap-3",children:r})]}),e[6]=r,e[7]=o):o=e[7],o}function Wge(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 qge(n){const e=V.c(5),{rows:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.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 r;e[1]!==t?(r=t.map(Vge),e[1]=t,e[2]=r):r=e[2];let o;return e[3]!==r?(o=a.jsxs("section",{"aria-labelledby":"cost-calls-heading",className:"flex flex-col gap-2",children:[s,a.jsx("ol",{className:"flex flex-col gap-0.5",children:r})]}),e[3]=r,e[4]=o):o=e[4],o}function Vge(n){return a.jsxs("li",{className:"flex items-center gap-2 rounded-md px-2 py-1.5 hover:bg-muted/50",children:[a.jsxs("span",{className:"min-w-0 flex-1 truncate text-xs text-foreground",children:["Call ",n.call," · ",ao(n.model)]}),n.isSubagent&&a.jsx(Fe,{variant:"outline",children:"Agent"}),a.jsx("span",{className:"shrink-0 font-mono text-xs text-foreground tabular-nums",children:gs(n.costUsd)})]},`${n.timestamp}:${n.call}`)}function Hge(n){const e=V.c(74),{summary:t}=n;let s;e[0]!==t.provider?(s=b5(t.provider),e[0]=t.provider,e[1]=s):s=e[1];const r=s;let o,i,l,c,u,d;if(e[2]!==r||e[3]!==t){const g=Xb(t.totals),x=zge(t);let b;e[10]!==t.calls?(b=Wge(t.calls),e[10]=t.calls,e[11]=b):b=e[11],d=b;const w=t.providerReportedRecords+t.modelPricedRecords>0;o="flex flex-col gap-5 pt-2";let v;e[12]===Symbol.for("react.memo_cache_sentinel")?(v=a.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 j;e[13]!==r?(j=a.jsx(r,{"aria-hidden":"true"}),e[13]=r,e[14]=j):j=e[14];let k;e[15]!==t.provider?(k=Cn(t.provider),e[15]=t.provider,e[16]=k):k=e[16];let _;e[17]!==k.displayName||e[18]!==j?(_=a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[v,a.jsxs(Fe,{variant:"outline",children:[j,k.displayName]})]}),e[17]=k.displayName,e[18]=j,e[19]=_):_=e[19];let N;e[20]!==w||e[21]!==t.costUsd?(N=w?gs(t.costUsd):"—",e[20]=w,e[21]=t.costUsd,e[22]=N):N=e[22];let S;e[23]!==N?(S=a.jsx("span",{className:"text-4xl font-semibold tracking-tight text-foreground tabular-nums",children:N}),e[23]=N,e[24]=S):S=e[24];const C=t.unpricedRecords>0?"secondary":"outline";let E;e[25]!==t?(E=Mge(t),e[25]=t,e[26]=E):E=e[26];let T;e[27]!==C||e[28]!==E?(T=a.jsx(Fe,{variant:C,children:E}),e[27]=C,e[28]=E,e[29]=T):T=e[29];let $;e[30]!==S||e[31]!==T?($=a.jsxs("div",{className:"flex items-end justify-between gap-3",children:[S,T]}),e[30]=S,e[31]=T,e[32]=$):$=e[32];const A=t.records===1?"model call":"model calls",R=t.includedSubagents>0?` · ${t.includedSubagents} agent ${t.includedSubagents===1?"transcript":"transcripts"}`:"";let P;e[33]!==t.records||e[34]!==A||e[35]!==R?(P=a.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.records," ",A,R]}),e[33]=t.records,e[34]=A,e[35]=R,e[36]=P):P=e[36],e[37]!==_||e[38]!==$||e[39]!==P?(i=a.jsxs("section",{"aria-labelledby":"session-cost-heading",className:"flex flex-col gap-2",children:[_,$,P]}),e[37]=_,e[38]=$,e[39]=P,e[40]=i):i=e[40],e[41]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(en,{}),e[41]=l):l=e[41];const z=vt(g);let L;e[42]!==z?(L=a.jsx(Ku,{label:"Processed tokens",value:z}),e[42]=z,e[43]=L):L=e[43];let I;e[44]!==t.cacheSavingsUsd?(I=gs(t.cacheSavingsUsd),e[44]=t.cacheSavingsUsd,e[45]=I):I=e[45];let M;e[46]!==I?(M=a.jsx(Ku,{label:"Cache savings",value:I}),e[46]=I,e[47]=M):M=e[47];let F;e[48]!==t.totals.cachedInputTokens?(F=vt(t.totals.cachedInputTokens),e[48]=t.totals.cachedInputTokens,e[49]=F):F=e[49];let U;e[50]!==F?(U=a.jsx(Ku,{label:"Cached input",value:F}),e[50]=F,e[51]=U):U=e[51];let O;e[52]!==t.totals.reasoningTokens?(O=vt(t.totals.reasoningTokens),e[52]=t.totals.reasoningTokens,e[53]=O):O=e[53];let D;e[54]!==O?(D=a.jsx(Ku,{label:"Reasoning",value:O}),e[54]=O,e[55]=D):D=e[55],e[56]!==L||e[57]!==M||e[58]!==U||e[59]!==D?(c=a.jsxs("dl",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:[L,M,U,D]}),e[56]=L,e[57]=M,e[58]=U,e[59]=D,e[60]=c):c=e[60],u=x.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(en,{}),a.jsxs("section",{"aria-labelledby":"cost-breakdown-heading",className:"flex flex-col gap-3",children:[a.jsx("h3",{id:"cost-breakdown-heading",className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Cost by token type"}),a.jsx("div",{className:"flex flex-col gap-4",children:x.map(B=>a.jsx(Uge,{row:B,totalCost:t.costUsd},B.label))})]})]}),e[2]=r,e[3]=t,e[4]=o,e[5]=i,e[6]=l,e[7]=c,e[8]=u,e[9]=d}else o=e[4],i=e[5],l=e[6],c=e[7],u=e[8],d=e[9];let f;e[61]!==t?(f=t.models.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(en,{}),a.jsx(Bge,{summary:t})]}),e[61]=t,e[62]=f):f=e[62];let m;e[63]!==d?(m=d.length>=2&&a.jsxs(a.Fragment,{children:[a.jsx(en,{}),a.jsx(qge,{rows:d})]}),e[63]=d,e[64]=m):m=e[64];let p;e[65]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsxs(jt,{children:[a.jsx(yf,{}),a.jsx(tn,{children:"How this is calculated"}),a.jsx(Rt,{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]!==o||e[67]!==i||e[68]!==l||e[69]!==c||e[70]!==u||e[71]!==f||e[72]!==m?(h=a.jsxs("div",{className:o,children:[i,l,c,u,f,m,p]}),e[66]=o,e[67]=i,e[68]=l,e[69]=c,e[70]=u,e[71]=f,e[72]=m,e[73]=h):h=e[73],h}function Kge(n){const e=V.c(7),{dirName:t,fileName:s,revision:r}=n,{summary:o,loading:i,error:l,refresh:c}=Rge(t,s,r);if(l){let d;return e[0]!==l||e[1]!==c?(d=a.jsx(Fge,{message:l,retry:c}),e[0]=l,e[1]=c,e[2]=d):d=e[2],d}if(!o){if(i){let f;return e[3]===Symbol.for("react.memo_cache_sentinel")?(f=a.jsx(Dge,{}),e[3]=f):f=e[3],f}let d;return e[4]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx(Ln,{className:"mt-2 min-h-52",children:a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:a.jsx(A8,{})}),a.jsx(zn,{children:"No transcript cost yet"}),a.jsx(Dn,{children:"Cost appears after the first model response is written."})]})}),e[4]=d):d=e[4],d}let u;return e[5]!==o?(u=a.jsx(Hge,{summary:o}),e[5]=o,e[6]=u):u=e[6],u}function Gge(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 Zge(n){const e=V.c(14),{turns:t,onJumpToTurn:s}=n;let r;e[0]!==t?(r=Gge(t),e[0]=t,e[1]=r):r=e[1];const o=r;if(o.length===0)return null;let i;e[2]!==o.length?(i=a.jsxs(Hc,{children:["Errors (",o.length,")"]}),e[2]=o.length,e[3]=i):i=e[3];let l;if(e[4]!==o||e[5]!==s){let d;e[7]!==s?(d=(f,m)=>a.jsxs(Q,{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:[a.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[a.jsx("span",{className:"font-medium text-destructive",children:f.toolName}),a.jsxs("span",{className:"text-muted-foreground",children:["Turn ",f.turnIndex+1]})]}),a.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]=d):d=e[8],l=o.map(d),e[4]=o,e[5]=s,e[6]=l}else l=e[6];let c;e[9]!==l?(c=a.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 u;return e[11]!==i||e[12]!==c?(u=a.jsxs("section",{children:[i,c]}),e[11]=i,e[12]=c,e[13]=u):u=e[13],u}function wj(n){const e=V.c(44),{agentId:t,subagentType:s,agentName:r,preview:o,isViewing:i,isBackground:l,status:c,durationMs:u,toolUseCount:d,depth:f,disabled:m,onClick:p,onStop:h}=n,g=f===void 0?0:f;let x;e[0]!==t||e[1]!==r||e[2]!==s?(x=r||Fb(t,s),e[0]=t,e[1]=r,e[2]=s,e[3]=x):x=e[3];const b=x;let w;e[4]!==u?(w=u==null?null:u<1e3?`${u}ms`:`${(u/1e3).toFixed(u>=1e4?0:1)}s`,e[4]=u,e[5]=w):w=e[5];const v=w;let j;e[6]!==c?(j=c==="running"?a.jsx(St,{className:"size-3 shrink-0 animate-spin text-success","data-icon":"inline-start"}):c==="done"?a.jsx(Pr,{className:"size-3 shrink-0 text-success","data-icon":"inline-start"}):c==="failed"?a.jsx(Bo,{className:"size-3 shrink-0 text-destructive","data-icon":"inline-start"}):a.jsx(fx,{className:"size-2.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),e[6]=c,e[7]=j):j=e[7];const k=j,_=g===1&&"pl-4",N=g>=2&&"pl-8",S=i?"bg-accent":"hover:bg-muted/40";let C;e[8]!==_||e[9]!==N||e[10]!==S?(C=G("motion-list-item flex w-full items-start border-b border-border text-left transition-colors last:border-b-0",_,N,S),e[8]=_,e[9]=N,e[10]=S,e[11]=C):C=e[11];let E;e[12]!==b?(E=a.jsx(Fe,{variant:"outline",children:b}),e[12]=b,e[13]=E):E=e[13];let T;e[14]!==l?(T=l&&a.jsx(Fe,{variant:"outline",children:"Background"}),e[14]=l,e[15]=T):T=e[15];let $;e[16]!==i?($=i&&a.jsx(Fe,{children:"Viewing"}),e[16]=i,e[17]=$):$=e[17];const A=c==="running"?"active":c;let R;e[18]!==A?(R=a.jsx("span",{className:"ml-auto text-xs uppercase tracking-wide text-muted-foreground",children:A}),e[18]=A,e[19]=R):R=e[19];let P;e[20]!==k||e[21]!==T||e[22]!==$||e[23]!==R||e[24]!==E?(P=a.jsxs("div",{className:"flex items-center gap-1.5",children:[k,E,T,$,R]}),e[20]=k,e[21]=T,e[22]=$,e[23]=R,e[24]=E,e[25]=P):P=e[25];let z;e[26]!==o?(z=o&&a.jsx("p",{className:"mt-1 line-clamp-2 text-xs leading-relaxed text-muted-foreground",children:o}),e[26]=o,e[27]=z):z=e[27];let L;e[28]!==v||e[29]!==d?(L=(v||d!=null)&&a.jsxs("div",{className:"mt-1.5 flex items-center gap-2 text-xs text-muted-foreground",children:[v&&a.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[a.jsx(kd,{className:"size-2.5","data-icon":"inline-start"}),v]}),d!=null&&a.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[a.jsx(Sf,{className:"size-2.5","data-icon":"inline-start"}),d," tools"]})]}),e[28]=v,e[29]=d,e[30]=L):L=e[30];let I;e[31]!==m||e[32]!==p||e[33]!==P||e[34]!==z||e[35]!==L?(I=a.jsxs(Q,{type:"button",variant:"ghost",onClick:p,disabled:m,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,z,L]}),e[31]=m,e[32]=p,e[33]=P,e[34]=z,e[35]=L,e[36]=I):I=e[36];let M;e[37]!==b||e[38]!==h?(M=h&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",className:"m-1",onClick:h,"aria-label":`Stop ${b}`,children:a.jsx(Mt,{"data-icon":"inline-start"})}),e[37]=b,e[38]=h,e[39]=M):M=e[39];let F;return e[40]!==I||e[41]!==M||e[42]!==C?(F=a.jsxs("div",{className:C,children:[I,M]}),e[40]=I,e[41]=M,e[42]=C,e[43]=F):F=e[43],F}function Yge(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 D1(n){return n.split(`
@@ -466,20 +466,20 @@ Passphrase: ${d}`),children:x?"Copied":"Copy link & passphrase"}):a.jsx("p",{cla
466
466
  `&&(t+=l),o++;continue}}if(i===s){s="";continue}if(!s&&(i==="'"||i==='"')){s=i;continue}if(s!=="'"){if(i==="`"||i==="$"&&/[('"{]/.test(l??""))return null;(i==="$"||!s&&/[*?[{}~]/.test(i))&&(r=!1)}t+=i}return s?null:{value:t,start:e,end:o,literal:r}}function h1e(n){const e=[];let t=[],s=0,r=0;const o=()=>({commands:[...e,{words:t,end:n.length,pipeline:s}],complete:!1});for(let i=0;i<n.length;){const l=n[i];if(l==="\\"&&n[i+1]===`
467
467
  `){i+=2;continue}if(l==="#"){const d=n.indexOf(`
468
468
  `,i);e.push({words:t,end:i,pipeline:s}),t.length>0&&r===0&&s++,t=[],i=d<0?n.length:d;continue}if(/[^\S\n]/.test(l)){i++;continue}if(/[;&|()\n]/.test(l)){const d=n[i+1],f=l==="|"&&d!=="|";if(l==="("&&r++,l===")"&&r--,r<0)return o();e.push({words:t,end:i,pipeline:s}),r===0&&!f&&l!=="("&&l!==")"&&(l!==`
469
- `||t.length>0)&&s++,t=[],i+=(l==="&"||l==="|")&&(d===l||f&&d==="&")?2:1;continue}if(/^(?:\d+)?<</.test(n.slice(i)))return o();const c=/^(?:\d+)?(?:>>|>\||>&|<&|<>|[<>])/.exec(n.slice(i));if(c){for(i+=c[0].length;/[^\S\n]/.test(n[i]??"");)i++;const d=Sj(n,i);if(!d||d.end===i)return o();i=d.end;continue}const u=Sj(n,i);if(!u||u.end===i)return o();t.push(u),i=u.end}return e.push({words:t,end:n.length,pipeline:s}),{commands:e,complete:r===0}}const yl="agent-browser",g1e=new Map([["env",new Set(["-i","--ignore-environment","--"])],["command",new Set(["--"])],["exec",new Set(["--"])],["npx",new Set(["-y","--yes","--"])],["bunx",new Set(["--bun","--"])]]),x1e=new Set(["echo","printf","rg","grep","cat","head","tail","wc","ls","stat","file","basename","dirname","cp","mv","rm","mkdir","rmdir","touch"]),b1e=new Set(["commit","log","show","diff","status","add","grep","ls-files","rev-parse"]),v1e=/^(?:if|then|else|elif|fi|while|until|for|select|case|esac|do|done|function|\{|\}|!)$/,y1e=/^[A-Za-z_][A-Za-z_\d]*=/;function VI(n){return n.slice(n.lastIndexOf("/")+1)}function w1e(n,e){var s,r;let t=0;for(;t<n.length;){const o=n[t];if(y1e.test(e.slice(o.start,o.end))){t++;continue}if(!o.literal||v1e.test(o.value))return null;const i=VI(o.value);if(i==="command"&&["-v","-V"].includes((s=n[t+1])==null?void 0:s.value))return-1;const l=g1e.get(i);if(!l)return t;for(t++;(r=n[t])!=null&&r.value.startsWith("-");){if(!n[t].literal||!l.has(n[t].value))return null;if(n[t++].value==="--")break}}return-1}function S1e(n,e,t){const[s,...r]=n;if(r.some(l=>!l.literal))return null;let o=u1e,i=null;for(let l=0;l<r.length;l++){const c=r[l];if(c.value!=="--session"&&!c.value.startsWith("--session="))continue;if(i!==null)return null;const u=c.value==="--session"?r[++l]:c;if(o=c.value==="--session"?u==null?void 0:u.value:c.value.slice(10),!o||!m1e(o)||u!==c&&!/^(?:\s|\\\n)*$/.test(t.slice(c.end,u.start)))return null;i={start:c.start,end:u.end}}return{text:yl+t.slice(s.end,e).trimEnd(),binaryEnd:s.end,browser:o,sessionFlag:i}}function k1e(n){var l;const{commands:e,complete:t}=h1e(n),s=[],r=e.some(({words:c})=>c.some(({value:u})=>u.includes(yl)));if(!t)return{invocations:s,ambiguous:r||n.includes(yl)};const o=new Set(e.filter(({words:c})=>c.some(({value:u})=>u.includes(yl))).map(({pipeline:c})=>c));let i=!1;for(const{words:c,end:u,pipeline:d}of e){const f=w1e(c,n);if(f===null){i||(i=r);continue}if(f<0)continue;const m=VI(c[f].value);if(m!==yl){!(x1e.has(m)||m==="git"&&b1e.has((l=c[f+1])==null?void 0:l.value))&&o.has(d)&&(i=!0);continue}const p=S1e(c.slice(f),u,n);p===null?i=!0:s.push(p)}return{invocations:s,ambiguous:i}}function j1e(n){return k1e(n).invocations}const kj=120,N1e=/(?:^|[._])exec_command$/;function C1e(n){return n==="Bash"||N1e.test(n)}function _1e(n){return Mse(n).filter(e=>C1e(e.name)).map(e=>so(e.input))}function E1e(n){for(const e of _1e(n)){const[t]=j1e(e);if(t===void 0||p1e(t.browser))continue;const{text:s}=t;return{session:t.browser,command:s.length>kj?`${s.slice(0,kj-1)}…`:s,timestamp:n.timestamp,toolCallId:n.id,done:n.result!==null}}return null}function T1e(n){const e=(n==null?void 0:n.turns)??[];for(let t=e.length-1;t>=0;t--){const s=e[t].toolCalls;for(let r=s.length-1;r>=0;r--){const o=E1e(s[r]);if(o)return o}}return null}const jj=1e4,A1e=y.lazy(()=>nt(()=>import("./ProjectFilesPanel-BMSrF4EP.js"),__vite__mapDeps([32,1,33,2,4,3])).then(n=>({default:n.ProjectFilesPanel}))),I1e=y.lazy(()=>nt(()=>import("./WorktreePanel-B_9oCuoW.js"),__vite__mapDeps([34,1,2,3,4])).then(n=>({default:n.WorktreePanel}))),P1e=y.lazy(()=>nt(()=>import("./CrewPanel-zGPJa0nm.js"),__vite__mapDeps([35,1,28,2,3,4])).then(n=>({default:n.CrewPanel}))),$1e=y.lazy(()=>nt(()=>import("./index-CKeIY-uM.js"),__vite__mapDeps([36,1,2,3,4])).then(n=>({default:n.BrowserPanel})));function Am(){const n=V.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=a.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-sm text-muted-foreground",role:"status",children:[a.jsx(Pn,{}),"Loading panel…"]}),n[0]=e):e=n[0],e}function R1e(n){const e=V.c(6),{context:t,closePanel:s}=n,r=Jb(),o=r.projectFilesRoot??t.projectPath;if(!o)return null;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx(Am,{}),e[0]=i):i=e[0];let l;return e[1]!==s||e[2]!==o||e[3]!==r.addProjectContext||e[4]!==r.projectFilesRequest?(l=a.jsx(y.Suspense,{fallback:i,children:a.jsx(A1e,{cwd:o,onClose:s,onAddToPrompt:r.addProjectContext,openRequest:r.projectFilesRequest},o)}),e[1]=s,e[2]=o,e[3]=r.addProjectContext,e[4]=r.projectFilesRequest,e[5]=l):l=e[5],l}function O1e(n){const e=V.c(3),{context:t}=n;if(!t.session)return null;let s;return e[0]!==t.session||e[1]!==t.sessionChangeKey?(s=a.jsx(rfe,{session:t.session,sessionChangeKey:t.sessionChangeKey}),e[0]=t.session,e[1]=t.sessionChangeKey,e[2]=s):s=e[2],s}function L1e(){const n=V.c(7),e=Jb();let t;return n[0]!==e.backgroundAgents||n[1]!==e.jumpToTurn||n[2]!==e.loadSession||n[3]!==e.searchInputRef||n[4]!==e.serversChanged||n[5]!==e.toggleServer?(t=a.jsx(c1e,{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 M1e(n){const e=V.c(3);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=a.jsx(Am,{}),e[0]=t):t=e[0];let s;return e[1]!==n?(s=a.jsx(y.Suspense,{fallback:t,children:a.jsx($1e,{...n})}),e[1]=n,e[2]=s):s=e[2],s}function z1e(n){var u;const e=V.c(8),{context:t}=n,[,s]=y.useState(0);let r;e[0]!==t.session?(r=Date.parse(((u=T1e(t.session))==null?void 0:u.timestamp)??""),e[0]=t.session,e[1]=r):r=e[1];const o=r;let i;e[2]!==o||e[3]!==s?(i=()=>{const d=o+jj-Date.now();if(Number.isNaN(d)||d<=0)return;const f=setTimeout(()=>s(D1e),d);return()=>clearTimeout(f)},e[2]=o,e[3]=s,e[4]=i):i=e[4];let l;if(e[5]!==o?(l=[o],e[5]=o,e[6]=l):l=e[6],y.useEffect(i,l),Number.isNaN(o)||Date.now()-o>=jj)return null;let c;return e[7]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx("span",{role:"status","aria-label":"The agent is using the browser",className:"absolute -right-0.5 -top-0.5 size-2 rounded-full bg-emerald-500"}),e[7]=c):c=e[7],c}function D1e(n){return n+1}function F1e(n){const e=V.c(3);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=a.jsx(Am,{}),e[0]=t):t=e[0];let s;return e[1]!==n?(s=a.jsx(y.Suspense,{fallback:t,children:a.jsx(P1e,{...n})}),e[1]=n,e[2]=s):s=e[2],s}function U1e(n){const e=V.c(5),{context:t}=n,s=t.crew;if(!s)return null;if(s.needsYou>0){const i=`${s.needsYou} ${s.needsYou===1?"session needs":"sessions need"} you`;let l;return e[0]!==s.needsYou||e[1]!==i?(l=a.jsx("span",{role:"status","aria-label":i,className:"absolute -right-1 -top-1 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-warning px-1 text-[9px] font-semibold text-warning-foreground",children:s.needsYou}),e[0]=s.needsYou,e[1]=i,e[2]=l):l=e[2],l}if(s.working===0)return null;const r=`${s.working} ${s.working===1?"session":"sessions"} working`;let o;return e[3]!==r?(o=a.jsx("span",{role:"status","aria-label":r,className:"absolute -right-0.5 -top-0.5 size-2 rounded-full bg-success ring-2 ring-success/30"}),e[3]=r,e[4]=o):o=e[4],o}function B1e(n){const e=V.c(8),{closePanel:t}=n,s=Jb();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Am,{}),e[0]=r):r=e[0];let o;return e[1]!==t||e[2]!==s.openWorktreeSession||e[3]!==s.worktreeDirName||e[4]!==s.worktrees.loading||e[5]!==s.worktrees.refetch||e[6]!==s.worktrees.worktrees?(o=a.jsx(y.Suspense,{fallback:r,children:a.jsx(I1e,{worktrees:s.worktrees.worktrees,loading:s.worktrees.loading,dirName:s.worktreeDirName,onRefetch:s.worktrees.refetch,onOpenSession:s.openWorktreeSession,onClose:t})}),e[1]=t,e[2]=s.openWorktreeSession,e[3]=s.worktreeDirName,e[4]=s.worktrees.loading,e[5]=s.worktrees.refetch,e[6]=s.worktrees.worktrees,e[7]=o):o=e[7],o}const W1e={id:ii,workspacePanels:[{id:"crew",title:"Crew",icon:nx,component:F1e,indicator:U1e,order:1,defaultSize:"30%",minSize:"340px",maxSize:"60%",when:n=>!!n.crew},{id:"worktrees",title:"Worktrees",icon:Gr,component:B1e,order:5,defaultSize:"36%",minSize:"320px",when:n=>n.supportsWorktrees===!0},{id:"project-files",title:"Project files",icon:I8,component:R1e,order:10,defaultSize:"55%",minSize:"340px",maxSize:"75%",keepAlive:!0,when:n=>n.canAccessHostFiles&&n.projectPath!==null},{id:"browser",title:"Browser",icon:na,component:M1e,indicator:z1e,order:15,defaultSize:"46%",minSize:"360px",maxSize:"75%",keepAlive:!0,when:n=>n.canUseBrowser},{id:"file-changes",title:"File changes",icon:yc,component:O1e,order:20,defaultSize:"36%",minSize:"320px",when:n=>n.canAccessHostFiles&&n.hasFileChanges&&n.session!==null},{id:"session-info",title:"Session details",icon:P8,component:L1e,order:30,defaultSize:"36%",minSize:"320px",when:n=>n.session!==null}]},q1e=rpe([W1e]),Nj={"cogpit.github":g4,"cogpit.clickup":O8,"cogpit.vercel":R8,"cogpit.cloudflare":$8};function V1e(n){const e=V.c(6);let t,s;e[0]!==n?({runtime:s,...t}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;return e[3]!==t||e[4]!==s?(r=s?a.jsx(Ege,{...t,...s}):null,e[3]=t,e[4]=s,e[5]=r):r=e[5],r}function H1e(n){var o;const e=V.c(3),{runtime:t,context:s}=n;let r;return e[0]!==s||e[1]!==t?(r=t?a.jsx(Cge,{client:t.client,pluginId:t.plugin.id,projectId:((o=t.project)==null?void 0:o.id)??null,workspacePath:t.project?s.projectPath:null,activation:t.activation,registryRevision:t.registryRevision}):null,e[0]=s,e[1]=t,e[2]=r):r=e[2],r}function K1e({client:n,status:e,activation:t,project:s,legacyPanels:r=q1e,openSettings:o}){const i=[...r];if(!(e!=null&&e.store.available)||e.safeMode||!t||WE())return i;const l=new Set(i.map(u=>u.id)),c=bo();for(const u of e.store.plugins)if(!(!u.enabled||u.scope.type==="projects"&&(!s||!u.scope.projectIds.includes(s.id)))&&_0(u.manifest,c,e.runtime,{allowPrerelease:u.manifest.publisher.startsWith("dev-")}).compatible)for(const d of u.manifest.contributes.panels){const f=xo(u.id,d.id);if(l.has(f)||d.when==="project-selected"&&!s)continue;l.add(f);const m={client:n,plugin:u,activation:t,registryRevision:e.store.revision,project:s,title:d.title,openSettings:o};i.push({id:f,pluginId:u.id,localId:d.id,title:d.title,icon:Nj[u.id]??xx,order:d.order,defaultSize:d.defaultSize,minSize:d.minSize,maxSize:d.maxSize,keepAlive:!0,...Nj[u.id]?{indicator:H1e,indicatorProps:{runtime:m}}:{},component:V1e,componentProps:{runtime:m}})}return i.sort((u,d)=>(u.order??100)-(d.order??100)||u.title.localeCompare(d.title))}function HI(n){const e=V.c(11),{client:t,status:s,activation:r,projectPath:o,openSettings:i}=n,l=Y0();let c;e[0]!==r||e[1]!==t||e[2]!==o||e[3]!==s?(c={client:t,status:s,activation:r,projectPath:o},e[0]=r,e[1]=t,e[2]=o,e[3]=s,e[4]=c):c=e[4];const{project:u,resolving:d}=BE(c),f=l||d?"":r;let m;return e[5]!==t||e[6]!==i||e[7]!==u||e[8]!==s||e[9]!==f?(m=K1e({client:t,status:s,activation:f,project:u,openSettings:i}),e[5]=t,e[6]=i,e[7]=u,e[8]=s,e[9]=f,e[10]=m):m=e[10],m}function Im(n){const e=V.c(7),{floating:t,children:s}=n,r=y.useRef(null);let o,i;if(e[0]!==t?(o=()=>{const c=r.current,u=c==null?void 0:c.parentElement;if(!t||!c||!u)return;const d=u.style.getPropertyValue("--session-footer-height"),f=()=>u.style.setProperty("--session-footer-height",`${c.getBoundingClientRect().height}px`);f();const m=new ResizeObserver(f);return m.observe(c),()=>{m.disconnect(),d?u.style.setProperty("--session-footer-height",d):u.style.removeProperty("--session-footer-height")}},i=[t],e[0]=t,e[1]=o,e[2]=i):(o=e[1],i=e[2]),y.useLayoutEffect(o,i),t){let c;return e[3]!==s?(c=a.jsx("div",{ref:r,className:"pointer-events-none absolute inset-x-0 bottom-0 z-20 flex justify-center bg-gradient-to-t from-canvas via-canvas/70 to-transparent pt-4",children:a.jsx("div",{className:"pointer-events-auto w-full max-w-[var(--chat-width)] px-3 pb-3",children:s})}),e[3]=s,e[4]=c):c=e[4],c}let l;return e[5]!==s?(l=a.jsx("div",{className:"flex w-full shrink-0 justify-center",children:a.jsx("div",{className:"w-full max-w-[var(--chat-width)] px-3 pb-3",children:s})}),e[5]=s,e[6]=l):l=e[6],l}function ya(n){const e=V.c(13),{projectPath:t,fallback:s,className:r}=n,[o,i]=y.useState(null);if(!t||o===t){let m;return e[0]!==s?(m=a.jsx(a.Fragment,{children:s}),e[0]=s,e[1]=m):m=e[1],m}const l=`/api/project-icon?cwd=${encodeURIComponent(t)}`;let c;e[2]!==l?(c=Af(l),e[2]=l,e[3]=c):c=e[3];let u;e[4]!==t?(u=()=>i(t),e[4]=t,e[5]=u):u=e[5];let d;e[6]!==r?(d=G("size-3.5 shrink-0 rounded-[3px] object-contain",r),e[6]=r,e[7]=d):d=e[7];let f;return e[8]!==t||e[9]!==c||e[10]!==u||e[11]!==d?(f=a.jsx("img",{src:c,alt:"","aria-hidden":!0,loading:"lazy",decoding:"async",onError:u,className:d},t),e[8]=t,e[9]=c,e[10]=u,e[11]=d,e[12]=f):f=e[12],f}function KI(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G(t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function GI(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex flex-wrap items-center gap-1.5 text-sm wrap-break-word text-muted-foreground",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("ol",{"data-slot":"breadcrumb-list",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function U1(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("inline-flex items-center gap-1",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("li",{"data-slot":"breadcrumb-item",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function ZI(n){const e=V.c(10);let t,s,r,o;if(e[0]!==n){const{className:c,render:u,...d}=n;t=u,o=m4,s="a",r=f4({className:G("transition-colors hover:text-foreground",c)},d),e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o}else t=e[1],s=e[2],r=e[3],o=e[4];let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i={slot:"breadcrumb-link"},e[5]=i):i=e[5];let l;return e[6]!==t||e[7]!==s||e[8]!==r?(l={defaultTagName:s,props:r,render:t,state:i},e[6]=t,e[7]=s,e[8]=r,e[9]=l):l=e[9],o(l)}function YI(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("font-normal text-foreground",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("span",{"data-slot":"breadcrumb-page",role:"link","aria-disabled":"true","aria-current":"page",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function XI(n){const e=V.c(12);let t,s,r;e[0]!==n?({children:t,className:s,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);let o;e[4]!==s?(o=G("[&>svg]:size-3.5",s),e[4]=s,e[5]=o):o=e[5];let i;e[6]!==t?(i=t??a.jsx(it,{}),e[6]=t,e[7]=i):i=e[7];let l;return e[8]!==r||e[9]!==o||e[10]!==i?(l=a.jsx("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:o,...r,children:i}),e[8]=r,e[9]=o,e[10]=i,e[11]=l):l=e[11],l}const G1e=1e3,Z1e=255;function Y1e(n){for(const e of n){const t=e.codePointAt(0)??0;if(t<32||t===127)return!0}return!1}function X1e(n){return n.trim()===""?"Enter a folder name":n!==n.trim()?"A folder name cannot start or end with a space":n==="."||n===".."?`"${n}" is not a folder name`:n.includes("/")||n.includes("\\")?"A folder name cannot contain / or \\":Y1e(n)?"A folder name cannot contain control characters":new TextEncoder().encode(n).length>Z1e?"That folder name is too long":null}function Cj(n,e){return n instanceof Error&&n.message?n.message:e}function J1e({hostName:n,projectPaths:e,onStart:t,onBack:s}){var D;const[r,o]=y.useState({path:null,request:0}),i=`${r.request}:${r.path??""}`,[l,c]=y.useState(null),[u,d]=y.useState(""),[f,m]=y.useState(""),[p,h]=y.useState(!1),[g,x]=y.useState(""),[b,w]=y.useState(null),[v,j]=y.useState(!1),k=y.useRef(null),_=y.useRef(null),N=y.useRef(null),S=y.useRef(!1);y.useEffect(()=>{const B=new AbortController;return Xme(r.path,B.signal).then(q=>c({request:i,listing:q})).catch(q=>{B.signal.aborted||c({request:i,error:Cj(q,"This folder could not be read")})}),()=>B.abort()},[i,r.path]);const C=(l==null?void 0:l.request)!==i,E=l&&"listing"in l?l.listing:null,T=!C&&l&&"error"in l?l.error:null,$=C?null:(E==null?void 0:E.path)??null,A=u.trim().toLowerCase(),R=(E==null?void 0:E.folders.filter(B=>B.name.toLowerCase().includes(A)))??[],P=R.some(B=>B.path===f)?f:((D=R[0])==null?void 0:D.path)??"",z=E==null?void 0:E.path;y.useEffect(()=>{var q,W;const B=N.current;B&&(B.scrollLeft=B.scrollWidth),S.current&&!((q=k.current)!=null&&q.contains(document.activeElement))&&((W=_.current)==null||W.focus()),S.current=!1},[z]);function L(B){var q;S.current=((q=k.current)==null?void 0:q.contains(document.activeElement))??!1,o(W=>({path:B,request:W.request+1})),d(""),h(!1),x(""),w(null)}function I(){$&&t($)}function M(B){B.key==="Enter"&&(B.metaKey||B.ctrlKey)&&!p?(B.preventDefault(),I()):B.key==="Backspace"&&B.target===_.current&&u===""&&(E!=null&&E.parent)&&!C&&(B.preventDefault(),L(E.parent))}function F(){var B;h(!1),x(""),w(null),(B=_.current)==null||B.focus()}async function U(B){var H;B.preventDefault();const q=g.trim(),W=X1e(q);if(W){w(W);return}if(!(!$||v)){j(!0);try{const K=await Jme($,q);L(K),(H=_.current)==null||H.focus()}catch(K){w(Cj(K,"The folder could not be made"))}finally{j(!1)}}}const O=n?`Folders on ${n}`:"Folders";return a.jsxs("div",{ref:k,onKeyDownCapture:M,className:"flex min-h-0 flex-col bg-popover text-popover-foreground",children:[a.jsxs("div",{className:"flex items-center gap-1 border-b px-2 py-1.5 in-data-[slot=dialog-content]:pr-12",children:[a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",onClick:s,"aria-label":"Back to projects",children:a.jsx(bx,{})}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:O}),E&&E.path!==E.root&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>L(null),"aria-label":"Go to the projects root",title:E.root,children:a.jsx(L8,{})})]}),E&&a.jsx(Q1e,{path:E.path,top:E.confined?E.root:null,listRef:N,onOpen:L}),a.jsxs(Ic,{shouldFilter:!1,label:"Filter folders",value:P,onValueChange:m,className:"rounded-none p-0",children:[a.jsx(o0,{ref:_,autoFocus:!0,placeholder:"Filter folders...",value:u,onValueChange:d}),a.jsx(Pc,{className:"box-content max-h-72 p-1","aria-busy":C,children:T!==null?a.jsx(exe,{message:T,onRetry:()=>L(r.path),onRoot:r.path===null?void 0:()=>L(null)}):E===null?a.jsxs("div",{role:"status",className:"flex items-center justify-center gap-2 py-8 text-sm text-muted-foreground",children:[a.jsx(Pn,{className:"size-4"}),"Loading folders…"]}):R.length===0?a.jsx(Ln,{className:"border-0 py-8",children:a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:a.jsx(Zr,{})}),a.jsx(zn,{children:A?"No folder matches":"No folders here"}),a.jsx(Dn,{children:A?"Try another name.":"Start a session right here, or make a new folder."})]})}):a.jsxs(xi,{className:G("p-0 transition-opacity",C&&"opacity-50"),children:[R.map(B=>a.jsxs(Eo,{value:B.path,onSelect:()=>L(B.path),onMouseDown:q=>q.preventDefault(),className:"motion-list-item h-auto gap-3 px-3 py-2",children:[a.jsx(sa,{className:"size-4 shrink-0 text-muted-foreground"}),a.jsx("span",{className:"min-w-0 flex-1 truncate",children:B.name}),e.has(B.path)&&a.jsx(Fe,{variant:"secondary",children:"Project"}),a.jsx(it,{className:"size-4 shrink-0 text-muted-foreground"})]},B.path)),E.truncated&&a.jsxs("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:["Showing the first ",G1e.toLocaleString()," folders."]})]})})]}),a.jsxs("div",{className:"flex flex-col gap-1.5 border-t p-2",children:[p?a.jsxs("form",{onSubmit:B=>void U(B),className:"flex items-center gap-2",children:[a.jsx(On,{autoFocus:!0,"aria-label":"New folder name",placeholder:"New folder name",value:g,disabled:v,"aria-invalid":b?!0:void 0,onChange:B=>{x(B.target.value),w(null)},onKeyDown:B=>{B.key==="Escape"&&(B.preventDefault(),B.stopPropagation(),F())}}),a.jsxs(Q,{type:"submit",size:"sm",disabled:v||!$||g.trim()==="",children:[v&&a.jsx(Pn,{"data-icon":"inline-start",className:"size-4"}),"Create"]}),a.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:F,children:"Cancel"})]}):a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Q,{type:"button",variant:"ghost",size:"sm",disabled:!$,onClick:()=>h(!0),children:[a.jsx(W4,{"data-icon":"inline-start"}),"New folder"]}),a.jsx(Q,{type:"button",size:"sm",className:"ml-auto",disabled:!$,onClick:I,"aria-keyshortcuts":"Meta+Enter Control+Enter",children:"Start session here"})]}),b&&a.jsx("p",{role:"alert",className:"px-1 text-xs text-destructive",children:b})]})]})}function Q1e(n){const e=V.c(19),{path:t,top:s,listRef:r,onOpen:o}=n;let i,l,c,u,d,f;if(e[0]!==r||e[1]!==o||e[2]!==t||e[3]!==s){const h=Qme(t,s);l=KI,f="border-b px-3 py-1.5",i=GI,c=r,u="no-scrollbar flex-nowrap gap-1 overflow-x-auto text-xs",d=h.map((g,x)=>a.jsxs(y.Fragment,{children:[x>0&&a.jsx(XI,{}),a.jsx(U1,{className:"shrink-0",children:x===h.length-1?a.jsx(YI,{children:g.label}):a.jsx(ZI,{render:a.jsx("button",{type:"button",onClick:()=>o(g.path)}),children:g.label})})]},g.path)),e[0]=r,e[1]=o,e[2]=t,e[3]=s,e[4]=i,e[5]=l,e[6]=c,e[7]=u,e[8]=d,e[9]=f}else i=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=e[9];let m;e[10]!==i||e[11]!==c||e[12]!==u||e[13]!==d?(m=a.jsx(i,{ref:c,className:u,children:d}),e[10]=i,e[11]=c,e[12]=u,e[13]=d,e[14]=m):m=e[14];let p;return e[15]!==l||e[16]!==f||e[17]!==m?(p=a.jsx(l,{className:f,children:m}),e[15]=l,e[16]=f,e[17]=m,e[18]=p):p=e[18],p}function exe(n){const e=V.c(14),{message:t,onRetry:s,onRoot:r}=n;let o,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(Yn,{variant:"icon",children:a.jsx(wr,{})}),i=a.jsx(zn,{children:"This folder could not be opened"}),e[0]=o,e[1]=i):(o=e[0],i=e[1]);let l;e[2]!==t?(l=a.jsxs(Mn,{children:[o,i,a.jsx(Dn,{children:t})]}),e[2]=t,e[3]=l):l=e[3];let c;e[4]!==s?(c=a.jsx(Q,{type:"button",variant:"outline",size:"sm",onClick:s,children:"Try again"}),e[4]=s,e[5]=c):c=e[5];let u;e[6]!==r?(u=r&&a.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:r,children:"Go to the projects root"}),e[6]=r,e[7]=u):u=e[7];let d;e[8]!==c||e[9]!==u?(d=a.jsxs("div",{className:"flex gap-2",children:[c,u]}),e[8]=c,e[9]=u,e[10]=d):d=e[10];let f;return e[11]!==l||e[12]!==d?(f=a.jsxs(Ln,{className:"border-0 py-8",children:[l,d]}),e[11]=l,e[12]=d,e[13]=f):f=e[13],f}function txe(){const n=V.c(7),e=Nn("manageDevices");let t;n[0]!==e?(t={enabled:e},n[0]=e,n[1]=t):t=n[1];const{activeDevice:s}=Fa(t);let r;n[2]!==s?(r=!s&&Ef(),n[2]=s,n[3]=r):r=n[3];const o=r,[i,l]=y.useState(null);let c,u;return n[4]!==o?(c=()=>{if(!o)return;const d=new AbortController;return Ce("/api/hello",{signal:d.signal}).then(zs).then(f=>{typeof(f==null?void 0:f.name)=="string"&&f.name&&l(f.name)}).catch(nxe),()=>d.abort()},u=[o],n[4]=o,n[5]=c,n[6]=u):(c=n[5],u=n[6]),y.useEffect(c,u),(s==null?void 0:s.name)??(o?i:null)}function nxe(){}function _j(n){return n.replace(/[\\/]+$/,"")||n}function JI(n){const e=n.map(s=>({...s,worktrees:[]})),t=new Map;for(const s of e){const r=_j(s.path);!Nr(s.path)&&!t.has(r)&&t.set(r,s)}return e.filter((s,r)=>{const o=Nr(s.path),i=o&&t.get(_j(o.parentPath));return i?(i.worktrees.push(n[r]),!1):!0})}const B1=qN("project-custom-names"),sxe=B1.rename;function ev(){const n=V.c(2),e=y.useSyncExternalStore(B1.subscribe,B1.getSnapshot);let t;return n[0]!==e?(t={names:e,rename:sxe},n[0]=e,n[1]=t):t=n[1],t}const Ej="browse-folders";function wl(n){return n.replace(/[\\/]+$/,"")||n}function rxe(n){const e=V.c(4);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];const[s,r]=y.useState(t);let o,i;return e[1]!==n?(o=()=>{if(!n)return;const l=new AbortController;return Ce("/api/projects",{signal:l.signal}).then(oxe).then(r).catch(()=>{l.signal.aborted||r([])}),()=>l.abort()},i=[n],e[1]=n,e[2]=o,e[3]=i):(o=e[2],i=e[3]),y.useEffect(o,i),s}async function oxe(n){return n.ok?await n.json():[]}function ixe(n){var B;const e=V.c(58),{projects:t,onNewSession:s,onNewFolder:r,defaultAgentKind:o,currentPath:i,initialView:l,children:c}=n,u=l===void 0?"projects":l,[d,f]=y.useState(u),[m,p]=y.useState(""),[h,g]=y.useState(null),{names:x}=ev(),b=txe();let w;if(e[0]!==m||e[1]!==x||e[2]!==t){e:{const q=JI(t);if(!m){w=q;break e}const W=m.toLowerCase();w=q.filter(H=>{var K;return H.path.toLowerCase().includes(W)||H.shortName.toLowerCase().includes(W)||H.dirName.toLowerCase().includes(W)||((K=x[H.dirName])==null?void 0:K.toLowerCase().includes(W))})}e[0]=m,e[1]=x,e[2]=t,e[3]=w}else w=e[3];const v=w;let j,k;e[4]!==m||e[5]!==t?(j=m.trim(),k=(j.startsWith("/")||/^[a-z]:[\\/]/i.test(j)||j.startsWith("\\\\"))&&!t.some(W=>wl(W.path)===wl(j)),e[4]=m,e[5]=t,e[6]=j,e[7]=k):(j=e[6],k=e[7]);const _=k;let N;e[8]!==i?(N=i?wl(((B=Nr(i))==null?void 0:B.parentPath)??i):null,e[8]=i,e[9]=N):N=e[9];const S=N;let C;e[10]!==_||e[11]!==j?(C=_?[`folder:${j}`]:[],e[10]=_,e[11]=j,e[12]=C):C=e[12];let E;e[13]!==v||e[14]!==C?(E=[...C,...v.map(lxe),Ej],e[13]=v,e[14]=C,e[15]=E):E=e[15];const T=E,$=h!==null&&T.includes(h)?h:T[0];if(d==="folders"){let q;e[16]!==t?(q=new Set(t.map(axe)),e[16]=t,e[17]=q):q=e[17];let W;e[18]===Symbol.for("react.memo_cache_sentinel")?(W=()=>f("projects"),e[18]=W):W=e[18];let H;return e[19]!==b||e[20]!==r||e[21]!==q?(H=a.jsx(J1e,{hostName:b,projectPaths:q,onStart:r,onBack:W}),e[19]=b,e[20]=r,e[21]=q,e[22]=H):H=e[22],H}let A;e[23]!==m?(A=a.jsx(o0,{autoFocus:!0,placeholder:"Search projects, paste a folder path, or browse",value:m,onValueChange:p}),e[23]=m,e[24]=A):A=e[24];let R;e[25]!==_||e[26]!==v.length?(R=v.length===0&&!_&&a.jsx(Ln,{className:"border-0 py-8",children:a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:a.jsx(Zr,{})}),a.jsx(zn,{children:"No projects found"}),a.jsx(Dn,{children:"Try another name, paste an absolute path, or browse the folders."})]})}),e[25]=_,e[26]=v.length,e[27]=R):R=e[27];let P;e[28]!==_||e[29]!==o||e[30]!==j||e[31]!==r?(P=_&&a.jsxs(Eo,{value:`folder:${j}`,className:"motion-list-item h-auto gap-3 px-3 py-2.5",onSelect:()=>r(j),children:[a.jsx(W4,{"data-icon":"inline-start",className:"size-4 shrink-0 text-foreground"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"text-sm font-medium",children:"Start in this folder"}),a.jsxs("div",{className:"truncate text-xs text-muted-foreground",children:[j," · ",SM(o)]})]})]}),e[28]=_,e[29]=o,e[30]=j,e[31]=r,e[32]=P):P=e[32];let z;if(e[33]!==S||e[34]!==v||e[35]!==s||e[36]!==x){let q;e[38]!==S||e[39]!==s||e[40]!==x?(q=W=>{const H=x[W.dirName],K=jc(W.path);return a.jsxs(Eo,{value:`project:${W.dirName}`,"data-checked":S!==null&&wl(W.path)===S,className:"motion-list-item h-auto gap-3 px-3 py-2.5",onSelect:()=>s(W.dirName,W.path),children:[a.jsx(ya,{projectPath:W.path,fallback:a.jsx(Zr,{"data-icon":"inline-start",className:"size-4 shrink-0 text-muted-foreground"}),className:"size-4"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-sm font-medium",children:H||K}),a.jsxs("div",{className:"text-xs text-muted-foreground",children:[H&&a.jsx("span",{className:"mr-1.5",children:K}),W.sessionCount," session",W.sessionCount!==1?"s":"",W.lastModified&&a.jsxs(a.Fragment,{children:[" · ",new Date(W.lastModified).toLocaleDateString()]})]})]})]},W.dirName)},e[38]=S,e[39]=s,e[40]=x,e[41]=q):q=e[41],z=v.map(q),e[33]=S,e[34]=v,e[35]=s,e[36]=x,e[37]=z}else z=e[37];let L;e[42]!==z||e[43]!==P?(L=a.jsxs(xi,{className:"p-0",children:[P,z]}),e[42]=z,e[43]=P,e[44]=L):L=e[44];let I,M;e[45]===Symbol.for("react.memo_cache_sentinel")?(I=()=>f("folders"),M=a.jsx(wc,{"data-icon":"inline-start",className:"size-4 shrink-0 text-muted-foreground"}),e[45]=I,e[46]=M):(I=e[45],M=e[46]);const F=b?`Browse folders on ${b}…`:"Browse folders…";let U;e[47]!==F?(U=a.jsx(xi,{className:"sticky -bottom-1 border-t bg-popover p-0 py-1",children:a.jsxs(Eo,{value:Ej,className:"h-auto gap-3 px-3 py-2.5",onSelect:I,children:[M,a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:F})]})}),e[47]=F,e[48]=U):U=e[48];let O;e[49]!==L||e[50]!==U||e[51]!==R?(O=a.jsxs(Pc,{className:"box-content max-h-80 p-1",children:[R,L,U]}),e[49]=L,e[50]=U,e[51]=R,e[52]=O):O=e[52];let D;return e[53]!==c||e[54]!==$||e[55]!==O||e[56]!==A?(D=a.jsxs(Ic,{shouldFilter:!1,value:$,onValueChange:g,className:"rounded-none p-0",children:[A,O,c]}),e[53]=c,e[54]=$,e[55]=O,e[56]=A,e[57]=D):D=e[57],D}function axe(n){return wl(n.path)}function lxe(n){return`project:${n.dirName}`}function QI(n){const e=V.c(13),{projectPath:t,switcher:s}=n;let r;e[0]!==t?(r=t?_r(t):null,e[0]=t,e[1]=r):r=e[1];const o=r;let i;e[2]!==o||e[3]!==t||e[4]!==s?(i=o?a.jsxs(a.Fragment,{children:["What should we build in"," ",a.jsx(cxe,{name:o,projectPath:t,switcher:s}),"?"]}):"What should we build?",e[2]=o,e[3]=t,e[4]=s,e[5]=i):i=e[5];let l;e[6]!==i?(l=a.jsx("h1",{className:"text-balance text-2xl font-semibold tracking-tight text-foreground",children:i}),e[6]=i,e[7]=l):l=e[7];let c;e[8]!==t?(c=t&&a.jsx("p",{className:"font-mono text-xs text-muted-foreground",children:jc(t)}),e[8]=t,e[9]=c):c=e[9];let u;return e[10]!==l||e[11]!==c?(u=a.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 text-center",children:[l,c]}),e[10]=l,e[11]=c,e[12]=u):u=e[12],u}function cxe(n){const e=V.c(24),{name:t,projectPath:s,switcher:r}=n,{onNewSession:o,onNewFolder:i,defaultAgentKind:l}=r,[c,u]=y.useState(!1),d=rxe(c);let f;e[0]!==s?(f=a.jsx(ya,{projectPath:s,fallback:null,className:"size-5"}),e[0]=s,e[1]=f):f=e[1];let m;e[2]!==t?(m=a.jsx("span",{className:"truncate underline decoration-dotted decoration-muted-foreground/50 underline-offset-[6px] transition-colors group-hover/project:decoration-foreground/70 group-data-popup-open/project:decoration-foreground/70",children:t}),e[2]=t,e[3]=m):m=e[3];let p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx(_a,{className:"size-4 shrink-0 text-muted-foreground transition-colors group-hover/project:text-foreground group-data-popup-open/project:text-foreground","aria-hidden":"true"}),e[4]=p):p=e[4];let h;e[5]!==f||e[6]!==m?(h=a.jsxs(Tc,{title:"Switch project",className:"group/project -mx-1 inline-flex max-w-full items-center gap-1.5 rounded-lg px-1.5 align-baseline outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring data-popup-open:bg-accent",children:[f,m,p]}),e[5]=f,e[6]=m,e[7]=h):h=e[7];let g;e[8]!==o?(g=(k,_)=>{u(!1),o(k,_)},e[8]=o,e[9]=g):g=e[9];let x;e[10]!==i?(x=k=>{u(!1),i(k)},e[10]=i,e[11]=x):x=e[11];let b;e[12]===Symbol.for("react.memo_cache_sentinel")?(b=a.jsx("span",{children:"Switch where this session starts"}),e[12]=b):b=e[12];let w;e[13]===Symbol.for("react.memo_cache_sentinel")?(w=a.jsxs("div",{className:"flex items-center justify-between border-t px-3 py-2 text-[11px] text-muted-foreground",children:[b,a.jsx("kbd",{className:"font-mono",children:Qi("newSession")})]}),e[13]=w):w=e[13];let v;e[14]!==l||e[15]!==s||e[16]!==d||e[17]!==g||e[18]!==x?(v=a.jsx(Zx,{align:"center",className:"w-96 max-w-[calc(100vw-2rem)] p-0",children:a.jsx(ixe,{projects:d,currentPath:s,defaultAgentKind:l,onNewSession:g,onNewFolder:x,children:w})}),e[14]=l,e[15]=s,e[16]=d,e[17]=g,e[18]=x,e[19]=v):v=e[19];let j;return e[20]!==c||e[21]!==v||e[22]!==h?(j=a.jsxs(Ec,{open:c,onOpenChange:u,children:[h,v]}),e[20]=c,e[21]=v,e[22]=h,e[23]=j):j=e[23],j}function tv(n){const e=V.c(56),{children:t,sessionLabel:s,customName:r,onDuplicate:o,onDelete:i,onRename:l,onArchive:c,onUnarchive:u,archiveDisabled:d}=n,f=d===void 0?!1:d,[m,p]=y.useState(!1),[h,g]=y.useState(!1),[x,b]=y.useState(""),w=y.useRef(null);let v;e[0]!==r?(v=function(){b(r||""),g(!0),requestAnimationFrame(()=>{var H;return(H=w.current)==null?void 0:H.select()})},e[0]=r,e[1]=v):v=e[1];const j=v;let k;e[2]===Symbol.for("react.memo_cache_sentinel")?(k=a.jsx("div",{className:"w-full"}),e[2]=k):k=e[2];let _;e[3]!==t?(_=a.jsx(Cm,{render:k,children:t}),e[3]=t,e[4]=_):_=e[4];let N;e[5]!==f||e[6]!==c||e[7]!==o||e[8]!==l||e[9]!==u||e[10]!==j?(N=(l||o||c||u)&&a.jsxs(fi,{children:[l&&a.jsxs(Rn,{onClick:j,children:[a.jsx(yr,{"data-icon":"inline-start"}),"Rename session"]}),o&&a.jsxs(Rn,{onClick:o,children:[a.jsx(Es,{"data-icon":"inline-start"}),"Duplicate session"]}),u?a.jsxs(Rn,{onClick:u,children:[a.jsx(Cf,{"data-icon":"inline-start"}),"Restore from archive"]}):c&&a.jsxs(Rn,{onClick:c,disabled:f,children:[a.jsx(Ns,{"data-icon":"inline-start"}),f?"Archive (stop the session first)":"Archive session"]})]}),e[5]=f,e[6]=c,e[7]=o,e[8]=l,e[9]=u,e[10]=j,e[11]=N):N=e[11];let S;e[12]!==c||e[13]!==i||e[14]!==o||e[15]!==l||e[16]!==u?(S=i&&a.jsxs(a.Fragment,{children:[(o||l||c||u)&&a.jsx(ba,{}),a.jsx(fi,{children:a.jsxs(Rn,{variant:"destructive",onClick:()=>p(!0),children:[a.jsx(kf,{"data-icon":"inline-start"}),"Delete session"]})})]}),e[12]=c,e[13]=i,e[14]=o,e[15]=l,e[16]=u,e[17]=S):S=e[17];let C;e[18]!==N||e[19]!==S?(C=a.jsxs(_m,{className:"min-w-44",children:[N,S]}),e[18]=N,e[19]=S,e[20]=C):C=e[20];let E;e[21]!==_||e[22]!==C?(E=a.jsxs(Nm,{children:[_,C]}),e[21]=_,e[22]=C,e[23]=E):E=e[23];let T;e[24]===Symbol.for("react.memo_cache_sentinel")?(T=a.jsx(ib,{children:"Delete session?"}),e[24]=T):T=e[24];let $;e[25]!==s?($=a.jsxs(rb,{children:[T,a.jsxs(ab,{children:["This will permanently delete"," ",a.jsx("span",{className:"font-medium text-foreground",children:s}),". This action cannot be undone."]})]}),e[25]=s,e[26]=$):$=e[26];let A;e[27]===Symbol.for("react.memo_cache_sentinel")?(A=a.jsx(cb,{size:"sm",children:"Cancel"}),e[27]=A):A=e[27];let R;e[28]!==i?(R=a.jsxs(ob,{children:[A,a.jsx(lb,{variant:"destructive",size:"sm",onClick:()=>{i==null||i(),p(!1)},children:"Delete"})]}),e[28]=i,e[29]=R):R=e[29];let P;e[30]!==$||e[31]!==R?(P=a.jsxs(sb,{children:[$,R]}),e[30]=$,e[31]=R,e[32]=P):P=e[32];let z;e[33]!==m||e[34]!==P?(z=a.jsx(nb,{open:m,onOpenChange:p,children:P}),e[33]=m,e[34]=P,e[35]=z):z=e[35];let L;e[36]===Symbol.for("react.memo_cache_sentinel")?(L=a.jsxs(io,{children:[a.jsx(rr,{className:"text-foreground",children:"Rename session"}),a.jsx(or,{className:"text-muted-foreground",children:"Give this session a custom name. Clear to reset to default."})]}),e[36]=L):L=e[36];let I;e[37]!==l||e[38]!==x?(I=W=>{W.preventDefault(),l==null||l(x),g(!1)},e[37]=l,e[38]=x,e[39]=I):I=e[39];let M;e[40]===Symbol.for("react.memo_cache_sentinel")?(M=a.jsx(mn,{htmlFor:"session-rename",children:"Session name"}),e[40]=M):M=e[40];let F;e[41]===Symbol.for("react.memo_cache_sentinel")?(F=W=>b(W.target.value),e[41]=F):F=e[41];let U;e[42]!==x||e[43]!==s?(U=a.jsxs(fn,{children:[M,a.jsx(On,{id:"session-rename",ref:w,value:x,onChange:F,placeholder:s})]}),e[42]=x,e[43]=s,e[44]=U):U=e[44];let O;e[45]===Symbol.for("react.memo_cache_sentinel")?(O=a.jsxs(Px,{children:[a.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:()=>g(!1),children:"Cancel"}),a.jsx(Q,{type:"submit",size:"sm",children:"Save"})]}),e[45]=O):O=e[45];let D;e[46]!==I||e[47]!==U?(D=a.jsxs(sr,{className:"sm:max-w-md",children:[L,a.jsxs("form",{className:"flex flex-col gap-4",onSubmit:I,children:[U,O]})]}),e[46]=I,e[47]=U,e[48]=D):D=e[48];let B;e[49]!==h||e[50]!==D?(B=a.jsx(nr,{open:h,onOpenChange:g,children:D}),e[49]=h,e[50]=D,e[51]=B):B=e[51];let q;return e[52]!==z||e[53]!==B||e[54]!==E?(q=a.jsxs(a.Fragment,{children:[E,z,B]}),e[52]=z,e[53]=B,e[54]=E,e[55]=q):q=e[55],q}function W1(n,e){return Object.freeze({canInteract:n,canOwn:e,send:n,stop:n,answer:n,configure:n,mcp:n,undo:n,archive:e,delete:e})}const ig=W1(!1,!1),uxe={unknown:ig,none:ig,view:ig,interact:W1(!0,!1),own:W1(!0,!0)};function wa(n){return uxe[n]}function Pm(){const n=V.c(3),{enforcesSessionAccess:e}=AN(),t=e===!1?"own":"unknown";let s;return n[0]!==e||n[1]!==t?(s=r=>wa(e!==null&&r?r.level:t),n[0]=e,n[1]=t,n[2]=s):s=n[2],s}function e7(n){const e=V.c(16),{value:t,onChange:s,placeholder:r,loading:o}=n,i=o===void 0?!1:o;let l;e[0]!==i?(l=a.jsx(Tr,{children:i?a.jsx(St,{className:"animate-spin","aria-label":"Searching session history"}):a.jsx(ss,{"aria-hidden":"true"})}),e[0]=i,e[1]=l):l=e[1];let c;e[2]!==s?(c=m=>s(m.target.value),e[2]=s,e[3]=c):c=e[3];let u;e[4]!==i||e[5]!==r||e[6]!==c||e[7]!==t?(u=a.jsx(Go,{type:"search","aria-busy":i,"aria-label":r,value:t,onChange:c,placeholder:r}),e[4]=i,e[5]=r,e[6]=c,e[7]=t,e[8]=u):u=e[8];let d;e[9]!==s||e[10]!==t?(d=t&&a.jsx(Tr,{align:"inline-end",children:a.jsx(dm,{"aria-label":"Clear search",onClick:()=>s(""),size:"icon-xs",children:a.jsx(Mt,{})})}),e[9]=s,e[10]=t,e[11]=d):d=e[11];let f;return e[12]!==l||e[13]!==u||e[14]!==d?(f=a.jsxs(Ko,{className:"w-full sm:max-w-sm",children:[l,u,d]}),e[12]=l,e[13]=u,e[14]=d,e[15]=f):f=e[15],f}function t7(n){const e=V.c(10),{message:t,onRetry:s}=n;let r,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Ir,{"aria-hidden":"true"}),o=a.jsx(tn,{children:"Could not load this data"}),e[0]=r,e[1]=o):(r=e[0],o=e[1]);let i;e[2]!==t?(i=a.jsx(Rt,{children:t}),e[2]=t,e[3]=i):i=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(Fn,{"data-icon":"inline-start"}),e[4]=l):l=e[4];let c;e[5]!==s?(c=a.jsx(Po,{children:a.jsxs(Q,{variant:"ghost",size:"xs",onClick:s,children:[l,"Retry"]})}),e[5]=s,e[6]=c):c=e[6];let u;return e[7]!==i||e[8]!==c?(u=a.jsxs(jt,{variant:"destructive",children:[r,o,i,c]}),e[7]=i,e[8]=c,e[9]=u):u=e[9],u}function n7(n){const e=V.c(5),{count:t,includeMessagePlaceholder:s}=n,r=t===void 0?4:t,o=s===void 0?!1:s;let i;if(e[0]!==r||e[1]!==o){let l;e[3]!==o?(l=(c,u)=>a.jsxs("div",{children:[u>0&&a.jsx(en,{}),a.jsxs("div",{className:"flex items-center gap-3 px-4 py-3.5",children:[a.jsx(Gn,{className:"size-8 shrink-0 rounded-md"}),a.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[a.jsx(Gn,{className:"h-4 w-40 max-w-full"}),o&&a.jsx(Gn,{className:"h-3 w-72 max-w-full"}),a.jsx(Gn,{className:"h-3 w-52 max-w-full"})]}),a.jsx(Gn,{className:"hidden h-5 w-20 sm:block"})]})]},u),e[3]=o,e[4]=l):l=e[4],i=a.jsx("div",{className:"overflow-hidden rounded-lg border","aria-hidden":"true",children:Array.from({length:r},l)}),e[0]=r,e[1]=o,e[2]=i}else i=e[2];return i}function s7(n){const e=V.c(3),{access:t}=n,{SessionBadges:s}=$r();let r;return e[0]!==s||e[1]!==t?(r=s?a.jsx(s,{access:t}):null,e[0]=s,e[1]=t,e[2]=r):r=e[2],r}const Hs={attention:"bg-warning",working:"bg-success ring-2 ring-success/30",idle:"bg-success/40"},dxe=/(?:https?:\/\/)?github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/i,fxe=/^([\w.-]+(?:\/[\w.-]+)?)#(\d+)$/,mxe=/(?:^|\s)#(\d+)(?=\s|$)/,pxe=/^(?:pr|pull\s+request)\s*#?(\d+)$/i;function Gu(n){const e=Number(n);return Number.isSafeInteger(e)&&e>0?e:null}function hxe(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 r7(n){const e=n.trim();if(!e)return null;const t=dxe.exec(e);if(t){const l=Gu(t[3]);return l===null?null:{number:l,repoHint:`${t[1]}/${t[2]}`.toLowerCase()}}const s=fxe.exec(e);if(s){const l=Gu(s[2]);return l===null?null:{number:l,repoHint:s[1].toLowerCase()}}const r=mxe.exec(e);if(r){const l=Gu(r[1]);if(l===null)return null;const c=`${e.slice(0,r.index)} ${e.slice(r.index+r[0].length)}`;return{number:l,repoHint:hxe(c)}}const o=pxe.exec(e);if(!o)return null;const i=Gu(o[1]);return i===null?null:{number:i,repoHint:null}}function Tj(n,e){if(!n)return!1;const t=n.toLowerCase().replace(/\.git$/,"");return t===e||t.endsWith(`/${e}`)||e.endsWith(`/${t}`)}function gxe(n,e){if(!n)return!1;const t=n.toLowerCase().replace(/\.git$/,"").split(/[\\/]/).filter(Boolean).at(-1);if(!t)return!1;const s=t.replace(/[^a-z0-9]/g,"");return e.split("/").some(r=>r.replace(/[^a-z0-9]/g,"")===s)}function xxe(n,e,t=[]){if(n.number!==e.number)return!1;const s=e.repoHint;return s?n.repo&&s.includes("/")?Tj(n.repo,s):Tj(n.repo,s)?!0:t.some(r=>gxe(r,s)):!0}function o7(n,e,t=[]){var o;const s=r7(e);if(s){const i=[n.cwd,n.projectShortName,...t];return((o=n.pullRequests)==null?void 0:o.some(l=>xxe(l,s,i)))??!1}const r=e.trim().toLowerCase();return r?[...t,n.aiTitle,n.name,n.slug,n.customTitle,n.firstUserMessage,n.lastUserMessage,n.model,n.gitBranch,n.agentName,n.teamName,n.sessionId,n.cwd,n.projectShortName].some(i=>i==null?void 0:i.toLowerCase().includes(r)):!0}const bxe=120*1e3;function i7(n){return n?Date.now()-new Date(n).getTime()<bxe:!1}function a7(n,e){const t=n.teamName?n.agentName:"",s=e||n.aiTitle||n.name||t||n.slug||n.firstUserMessage||n.customTitle;return s?Bs(s,70):Bs(n.sessionId,16)}function Aj(n){return n.trim().replace(/\s+/g," ").slice(0,40).toLowerCase()}function vxe(n,e){const t=(n.lastUserMessage||n.firstUserMessage||"").trim();return!t||Aj(t)===Aj(e)?null:Bs(t,220)}function yxe(n,e){return o7(n,e)}function wxe(n,e){if(!n||!e)return null;const t=new Date(e).getTime()-new Date(n).getTime();return t>=6e4?Js(t):null}function Sxe(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(`
470
- `)}function kxe(n){var t;const e=n.cwd?(t=Nr(n.cwd))==null?void 0:t.worktreeName:void 0;return e?{icon:M8,label:e,title:n.cwd}:n.gitBranch?{icon:Gr,label:n.gitBranch}:null}function jxe(n,e){return n.agentStatus==="deferred"?"attention":e?Qc(n.agentStatus)?"idle":"working":null}function Nxe(n){const e=V.c(20),{session:t,live:s}=n;if(t.agentStatus==="deferred"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Fe,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"Needs review"}),e[0]=r):r=e[0],r}if(s){const r=Qc(t.agentStatus);let o;e[1]!==t.agentPendingAgents||e[2]!==t.agentStatus||e[3]!==t.agentTerminalReason||e[4]!==t.agentToolName?(o=Jc(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??"Active",e[1]=t.agentPendingAgents,e[2]=t.agentStatus,e[3]=t.agentTerminalReason,e[4]=t.agentToolName,e[5]=o):o=e[5];const i=o;let l;e[6]!==t.agentStatus?(l=wm(t.agentStatus),e[6]=t.agentStatus,e[7]=l):l=e[7];const c=r?"bg-success/60":"bg-current";let u;e[8]!==c?(u=G("size-1.5 rounded-full",c),e[8]=c,e[9]=u):u=e[9];let d;e[10]!==u?(d=a.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:u}),e[10]=u,e[11]=d):d=e[11];let f;return e[12]!==i||e[13]!==l||e[14]!==d?(f=a.jsxs(Fe,{variant:"secondary",className:l,children:[d,i]}),e[12]=i,e[13]=l,e[14]=d,e[15]=f):f=e[15],f}if(t.agentTerminalReason){let r;e[16]!==t.agentTerminalReason?(r=Pb(t.agentTerminalReason),e[16]=t.agentTerminalReason,e[17]=r):r=e[17];let o;return e[18]!==r?(o=a.jsx(Fe,{variant:"outline",className:"max-w-44 truncate text-warning",children:r}),e[18]=r,e[19]=o):o=e[19],o}return null}function ag(n){const e=V.c(9),{icon:t,title:s,className:r,children:o}=n;let i;e[0]!==r?(i=G("flex items-center gap-1",r),e[0]=r,e[1]=i):i=e[1];let l;e[2]!==t?(l=a.jsx(t,{className:"size-3 shrink-0"}),e[2]=t,e[3]=l):l=e[3];let c;return e[4]!==o||e[5]!==i||e[6]!==l||e[7]!==s?(c=a.jsxs("span",{className:i,title:s,children:[l,o]}),e[4]=o,e[5]=i,e[6]=l,e[7]=s,e[8]=c):c=e[8],c}function Cxe(n){const e=V.c(103),{session:t,customName:s,onSelect:r}=n,o=t.lastActivityAt||t.lastModified;let i,l;e[0]!==o||e[1]!==t?(i=i7(o),l=jxe(t,i),e[0]=o,e[1]=t,e[2]=i,e[3]=l):(i=e[2],l=e[3]);const c=l,u=t.teamName?t.agentName:void 0;let d,f,m,p,h,g,x,b,w,v,j,k,_,N,S;if(e[4]!==s||e[5]!==c||e[6]!==o||e[7]!==i||e[8]!==r||e[9]!==t||e[10]!==u){const I=kxe(t);let M;e[26]!==o||e[27]!==t.timestamp?(M=wxe(t.timestamp,o),e[26]=o,e[27]=t.timestamp,e[28]=M):M=e[28];const F=M,U=t.turnCount??0;let O,D;e[29]!==s||e[30]!==t?(D=a7(t,s),O=vxe(t,D),e[29]=s,e[30]=t,e[31]=O,e[32]=D):(O=e[31],D=e[32]);const B=O;x="motion-list-item group flex w-full items-start gap-3 px-4 py-3 transition-colors hover:bg-muted/50 focus-within:bg-muted",f="button",m=r,e[33]!==t?(p=Sxe(t),e[33]=t,e[34]=p):p=e[34],h="flex min-w-0 flex-1 items-start gap-3 rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring";let q;e[35]===Symbol.for("react.memo_cache_sentinel")?(q=a.jsx(gg,{className:"size-4"}),e[35]=q):q=e[35];let W;e[36]!==c?(W=c&&a.jsx("span",{"aria-hidden":"true","data-status-dot":c,className:G("absolute -top-1 -right-1 size-2 rounded-full ring-2 ring-card",Hs[c])}),e[36]=c,e[37]=W):W=e[37],e[38]!==W?(g=a.jsxs("span",{className:"relative mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-md border bg-muted/40 text-muted-foreground",children:[q,W]}),e[38]=W,e[39]=g):g=e[39],N="flex min-w-0 flex-1 flex-col gap-1";let H;e[40]!==D?(H=a.jsx("span",{className:"truncate text-sm font-medium",children:D}),e[40]=D,e[41]=H):H=e[41];let K;e[42]!==u?(K=u&&a.jsxs(Fe,{variant:"outline",className:"shrink-0",children:[a.jsx(mi,{"data-icon":"inline-start"}),Bs(u,18)]}),e[42]=u,e[43]=K):K=e[43];let Z;e[44]!==t.branchedFrom?(Z=t.branchedFrom&&a.jsxs(Fe,{variant:"outline",className:"shrink-0",title:"Branched from another session",children:[a.jsx(gx,{"data-icon":"inline-start"}),"branch"]}),e[44]=t.branchedFrom,e[45]=Z):Z=e[45];let Y;e[46]!==i||e[47]!==t?(Y=a.jsx(Nxe,{session:t,live:i}),e[46]=i,e[47]=t,e[48]=Y):Y=e[48];let X;e[49]!==o?(X=o&&a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:Cr(o)}),e[49]=o,e[50]=X):X=e[50];let ee;e[51]!==Y||e[52]!==X?(ee=a.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2",children:[Y,X]}),e[51]=Y,e[52]=X,e[53]=ee):ee=e[53],e[54]!==H||e[55]!==K||e[56]!==Z||e[57]!==ee?(S=a.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[H,K,Z,ee]}),e[54]=H,e[55]=K,e[56]=Z,e[57]=ee,e[58]=S):S=e[58],e[59]!==B?(d=B&&a.jsx("span",{className:"line-clamp-1 text-sm text-muted-foreground",children:B}),e[59]=B,e[60]=d):d=e[60],b="flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",e[61]!==t.access?(w=a.jsx(s7,{access:t.access}),e[61]=t.access,e[62]=w):w=e[62],e[63]!==t.model?(v=t.model&&a.jsx(Fe,{variant:"outline",children:ao(t.model)}),e[63]=t.model,e[64]=v):v=e[64],e[65]!==U?(j=U>0&&a.jsxs(ag,{icon:gg,children:[U," ",U===1?"turn":"turns"]}),e[65]=U,e[66]=j):j=e[66],e[67]!==F?(k=F&&a.jsx(ag,{icon:Io,title:"First prompt to last activity",children:F}),e[67]=F,e[68]=k):k=e[68],_=I&&a.jsx(ag,{icon:I.icon,className:"max-w-40 truncate",title:I.title,children:Bs(I.label,22)}),e[4]=s,e[5]=c,e[6]=o,e[7]=i,e[8]=r,e[9]=t,e[10]=u,e[11]=d,e[12]=f,e[13]=m,e[14]=p,e[15]=h,e[16]=g,e[17]=x,e[18]=b,e[19]=w,e[20]=v,e[21]=j,e[22]=k,e[23]=_,e[24]=N,e[25]=S}else d=e[11],f=e[12],m=e[13],p=e[14],h=e[15],g=e[16],x=e[17],b=e[18],w=e[19],v=e[20],j=e[21],k=e[22],_=e[23],N=e[24],S=e[25];let C;e[69]!==t.size?(C=wN(t.size),e[69]=t.size,e[70]=C):C=e[70];let E;e[71]!==C?(E=a.jsx("span",{children:C}),e[71]=C,e[72]=E):E=e[72];let T;e[73]!==E||e[74]!==b||e[75]!==w||e[76]!==v||e[77]!==j||e[78]!==k||e[79]!==_?(T=a.jsxs("span",{className:b,children:[w,v,j,k,_,E]}),e[73]=E,e[74]=b,e[75]=w,e[76]=v,e[77]=j,e[78]=k,e[79]=_,e[80]=T):T=e[80];let $;e[81]!==d||e[82]!==T||e[83]!==N||e[84]!==S?($=a.jsxs("span",{className:N,children:[S,d,T]}),e[81]=d,e[82]=T,e[83]=N,e[84]=S,e[85]=$):$=e[85];let A;e[86]!==f||e[87]!==m||e[88]!==p||e[89]!==h||e[90]!==g||e[91]!==$?(A=a.jsxs("button",{type:f,onClick:m,title:p,className:h,children:[g,$]}),e[86]=f,e[87]=m,e[88]=p,e[89]=h,e[90]=g,e[91]=$,e[92]=A):A=e[92];let R;e[93]!==t.matchedPullRequestNumber||e[94]!==t.pullRequests?(R=t.matchedPullRequestNumber?a.jsxs(Fe,{variant:"outline",children:["Matched #",t.matchedPullRequestNumber]}):a.jsx(su,{pullRequests:t.pullRequests,max:2,compact:!0}),e[93]=t.matchedPullRequestNumber,e[94]=t.pullRequests,e[95]=R):R=e[95];let P;e[96]===Symbol.for("react.memo_cache_sentinel")?(P=a.jsx(it,{className:"size-4 text-muted-foreground transition-transform group-hover:translate-x-0.5"}),e[96]=P):P=e[96];let z;e[97]!==R?(z=a.jsxs("span",{className:"flex shrink-0 items-center gap-2 pt-1.5",children:[R,P]}),e[97]=R,e[98]=z):z=e[98];let L;return e[99]!==x||e[100]!==A||e[101]!==z?(L=a.jsxs("div",{className:x,children:[A,z]}),e[99]=x,e[100]=A,e[101]=z,e[102]=L):L=e[102],L}function _xe(n){const e=V.c(63),{selectedProject:t,filterEmpty:s,sessions:r,sessionsTotal:o,sessionsLoading:i,searchLoading:l,searchFilter:c,setSearchFilter:u,filteredSessions:d,fetchError:f,onSelectSession:m,onNewSession:p,creatingSession:h,onDuplicateSession:g,onDeleteSession:x,onBack:b,onRetryFetch:w,loadMoreSessions:v}=n,{names:j,rename:k}=Ff(),_=Pm();let N;e[0]!==t.path?(N=_r(t.path),e[0]=t.path,e[1]=N):N=e[1];const S=N;let C;e[2]!==b?(C=a.jsx(U1,{children:a.jsx(ZI,{render:a.jsx("button",{type:"button",onClick:b}),children:"Projects"})}),e[2]=b,e[3]=C):C=e[3];let E;e[4]===Symbol.for("react.memo_cache_sentinel")?(E=a.jsx(XI,{}),e[4]=E):E=e[4];let T;e[5]!==S?(T=a.jsx(U1,{className:"min-w-0",children:a.jsx(YI,{className:"truncate",children:S})}),e[5]=S,e[6]=T):T=e[6];let $;e[7]!==C||e[8]!==T?($=a.jsx(KI,{children:a.jsxs(GI,{children:[C,E,T]})}),e[7]=C,e[8]=T,e[9]=$):$=e[9];let A;e[10]!==S?(A=a.jsx("h1",{className:"truncate text-2xl font-semibold tracking-tight",children:S}),e[10]=S,e[11]=A):A=e[11];let R;e[12]!==o?(R=a.jsx(Fe,{variant:"secondary",children:o}),e[12]=o,e[13]=R):R=e[13];let P;e[14]!==A||e[15]!==R?(P=a.jsxs("div",{className:"flex items-center gap-2",children:[A,R]}),e[14]=A,e[15]=R,e[16]=P):P=e[16];let z;e[17]!==t.path?(z=jc(t.path),e[17]=t.path,e[18]=z):z=e[18];let L;e[19]!==z?(L=a.jsx("p",{className:"truncate text-sm text-muted-foreground",children:z}),e[19]=z,e[20]=L):L=e[20];let I;e[21]!==L||e[22]!==P?(I=a.jsxs("header",{className:"flex min-w-0 flex-col gap-1",children:[P,L]}),e[21]=L,e[22]=P,e[23]=I):I=e[23];let M;e[24]!==c||e[25]!==l||e[26]!==u?(M=a.jsx(e7,{value:c,onChange:u,placeholder:"Search sessions or PRs...",loading:l}),e[24]=c,e[25]=l,e[26]=u,e[27]=M):M=e[27];let F;e[28]!==h||e[29]!==p||e[30]!==t.dirName||e[31]!==t.path?(F=p&&a.jsxs(Q,{size:"sm",disabled:h,onClick:()=>p(t.dirName,t.path),children:[h?a.jsx(Pn,{"data-icon":"inline-start"}):a.jsx(Sr,{"data-icon":"inline-start"}),"New Session"]}),e[28]=h,e[29]=p,e[30]=t.dirName,e[31]=t.path,e[32]=F):F=e[32];let U;e[33]!==M||e[34]!==F?(U=a.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[M,F]}),e[33]=M,e[34]=F,e[35]=U):U=e[35];let O;e[36]!==f||e[37]!==w?(O=f&&a.jsx(t7,{message:f,onRetry:w}),e[36]=f,e[37]=w,e[38]=O):O=e[38];let D;e[39]!==s||e[40]!==d||e[41]!==v||e[42]!==x||e[43]!==g||e[44]!==m||e[45]!==_||e[46]!==k||e[47]!==c||e[48]!==l||e[49]!==t.dirName||e[50]!==j||e[51]!==r||e[52]!==i||e[53]!==o?(D=(i||l)&&d.length===0?a.jsx(n7,{includeMessagePlaceholder:!0}):d.length===0?a.jsx(Exe,{searchFilter:c,filterEmpty:s}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"overflow-hidden rounded-lg border bg-card",children:d.map((W,H)=>a.jsxs(y.Fragment,{children:[H>0&&a.jsx(en,{}),a.jsx(tv,{sessionLabel:a7(W),customName:j[W.sessionId],onRename:K=>k(W.sessionId,K),onDuplicate:g?()=>g(t.dirName,W.fileName):void 0,onDelete:x&&_(W.access).delete?()=>x(t.dirName,W.fileName):void 0,children:a.jsx(Cxe,{session:W,customName:j[W.sessionId],onSelect:()=>m(t.dirName,W.fileName)})})]},W.fileName))}),r.length<o&&!c&&a.jsx("div",{className:"flex justify-center",children:a.jsxs(Q,{variant:"outline",size:"sm",disabled:i,onClick:v,children:[i&&a.jsx(Pn,{"data-icon":"inline-start"}),i?"Loading...":"Load more sessions"]})})]}),e[39]=s,e[40]=d,e[41]=v,e[42]=x,e[43]=g,e[44]=m,e[45]=_,e[46]=k,e[47]=c,e[48]=l,e[49]=t.dirName,e[50]=j,e[51]=r,e[52]=i,e[53]=o,e[54]=D):D=e[54];let B;e[55]!==U||e[56]!==O||e[57]!==D?(B=a.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Sessions",children:[U,O,D]}),e[55]=U,e[56]=O,e[57]=D,e[58]=B):B=e[58];let q;return e[59]!==I||e[60]!==B||e[61]!==$?(q=a.jsx(Vc,{className:"h-full",children:a.jsxs("main",{className:"mx-auto flex max-w-6xl flex-col gap-6 px-4 py-6 sm:px-6 sm:pb-10 sm:pt-14",children:[$,I,B]})}),e[59]=I,e[60]=B,e[61]=$,e[62]=q):q=e[62],q}function Exe(n){const e=V.c(8),{searchFilter:t,filterEmpty:s}=n;if(!t&&s)return s;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Yn,{variant:"icon",children:a.jsx(vc,{})}),e[0]=r):r=e[0];const o=t?"No sessions match your search":"No sessions yet";let i;e[1]!==o?(i=a.jsx(zn,{children:o}),e[1]=o,e[2]=i):i=e[2];const l=t?"Try #157, honest-cms #157, or paste a PR URL.":"Start a session in this project and it will appear here.";let c;e[3]!==l?(c=a.jsx(Dn,{children:l}),e[3]=l,e[4]=c):c=e[4];let u;return e[5]!==i||e[6]!==c?(u=a.jsx(Ln,{className:"min-h-72 border",children:a.jsxs(Mn,{children:[r,i,c]})}),e[5]=i,e[6]=c,e[7]=u):u=e[7],u}function l7(n){const e=V.c(40),{children:t,projectLabel:s,customName:r,className:o,onRename:i,archivableCount:l,onArchiveIdle:c}=n,u=l===void 0?0:l,[d,f]=y.useState(!1),[m,p]=y.useState(""),h=y.useRef(null);let g;e[0]!==r?(g=function(){p(r||""),f(!0),requestAnimationFrame(()=>{var M;return(M=h.current)==null?void 0:M.select()})},e[0]=r,e[1]=g):g=e[1];const x=g;let b;e[2]!==o?(b=G("w-full",o),e[2]=o,e[3]=b):b=e[3];let w;e[4]!==b?(w=a.jsx("div",{className:b}),e[4]=b,e[5]=w):w=e[5];let v;e[6]!==t||e[7]!==w?(v=a.jsx(Cm,{render:w,children:t}),e[6]=t,e[7]=w,e[8]=v):v=e[8];let j;e[9]===Symbol.for("react.memo_cache_sentinel")?(j=a.jsx(yr,{"data-icon":"inline-start"}),e[9]=j):j=e[9];let k;e[10]!==x?(k=a.jsx(fi,{children:a.jsxs(Rn,{onClick:x,children:[j,"Rename project"]})}),e[10]=x,e[11]=k):k=e[11];let _;e[12]!==u||e[13]!==c?(_=c&&a.jsxs(a.Fragment,{children:[a.jsx(ba,{}),a.jsx(fi,{children:a.jsxs(Rn,{onClick:c,disabled:u===0,children:[a.jsx(Ns,{"data-icon":"inline-start"}),u>0?`Archive ${u} idle ${u===1?"session":"sessions"}`:"Archive idle sessions"]})})]}),e[12]=u,e[13]=c,e[14]=_):_=e[14];let N;e[15]!==k||e[16]!==_?(N=a.jsxs(_m,{className:"min-w-44",children:[k,_]}),e[15]=k,e[16]=_,e[17]=N):N=e[17];let S;e[18]!==v||e[19]!==N?(S=a.jsxs(Nm,{children:[v,N]}),e[18]=v,e[19]=N,e[20]=S):S=e[20];let C;e[21]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsxs(io,{children:[a.jsx(rr,{className:"text-foreground",children:"Rename project"}),a.jsx(or,{className:"text-muted-foreground",children:"Give this project a custom name. Clear to reset to default."})]}),e[21]=C):C=e[21];let E;e[22]!==i||e[23]!==m?(E=I=>{I.preventDefault(),i(m),f(!1)},e[22]=i,e[23]=m,e[24]=E):E=e[24];let T;e[25]===Symbol.for("react.memo_cache_sentinel")?(T=a.jsx(mn,{htmlFor:"project-rename",children:"Project name"}),e[25]=T):T=e[25];let $;e[26]===Symbol.for("react.memo_cache_sentinel")?($=I=>p(I.target.value),e[26]=$):$=e[26];let A;e[27]!==s||e[28]!==m?(A=a.jsxs(fn,{children:[T,a.jsx(On,{id:"project-rename",ref:h,value:m,onChange:$,placeholder:s})]}),e[27]=s,e[28]=m,e[29]=A):A=e[29];let R;e[30]===Symbol.for("react.memo_cache_sentinel")?(R=a.jsxs(Px,{children:[a.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:()=>f(!1),children:"Cancel"}),a.jsx(Q,{type:"submit",size:"sm",children:"Save"})]}),e[30]=R):R=e[30];let P;e[31]!==E||e[32]!==A?(P=a.jsxs(sr,{className:"sm:max-w-md",children:[C,a.jsxs("form",{className:"flex flex-col gap-4",onSubmit:E,children:[A,R]})]}),e[31]=E,e[32]=A,e[33]=P):P=e[33];let z;e[34]!==d||e[35]!==P?(z=a.jsx(nr,{open:d,onOpenChange:f,children:P}),e[34]=d,e[35]=P,e[36]=z):z=e[36];let L;return e[37]!==S||e[38]!==z?(L=a.jsxs(a.Fragment,{children:[S,z]}),e[37]=S,e[38]=z,e[39]=L):L=e[39],L}function Txe(n){const e=V.c(47),{projects:t,activeSessions:s,loading:r,refreshing:o,searchFilter:i,setSearchFilter:l,fetchError:c,selectedProjectDirName:u,onSelectProject:d,onRefresh:f}=n;let m;if(e[0]!==s){m={};for(const I of s)i7(I.lastModified)&&(m[I.dirName]=(m[I.dirName]||0)+1);e[0]=s,e[1]=m}else m=e[1];const p=m,{names:h,rename:g}=ev();let x;e[2]!==t?(x=JI(t),e[2]=t,e[3]=x):x=e[3];const b=x;let w;e:{if(!i){w=b;break e}let I;if(e[4]!==h||e[5]!==b||e[6]!==i){const M=i.toLowerCase(),F=U=>{var O;return U.path.toLowerCase().includes(M)||U.shortName.toLowerCase().includes(M)||((O=h[U.dirName])==null?void 0:O.toLowerCase().includes(M))};I=b.filter(U=>F(U)||U.worktrees.some(F)),e[4]=h,e[5]=b,e[6]=i,e[7]=I}else I=e[7];w=I}const v=w;let j;e[8]===Symbol.for("react.memo_cache_sentinel")?(j=a.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Projects"}),e[8]=j):j=e[8];let k;e[9]!==b.length?(k=a.jsxs("div",{className:"flex items-center gap-2",children:[j,a.jsx(Fe,{variant:"secondary",children:b.length})]}),e[9]=b.length,e[10]=k):k=e[10];let _;e[11]===Symbol.for("react.memo_cache_sentinel")?(_=a.jsx("p",{className:"text-sm text-muted-foreground",children:"Open a project to browse and resume its sessions."}),e[11]=_):_=e[11];let N;e[12]!==k?(N=a.jsxs("header",{className:"flex flex-col gap-1",children:[k,_]}),e[12]=k,e[13]=N):N=e[13];let S;e[14]!==i||e[15]!==l?(S=a.jsx(e7,{value:i,onChange:l,placeholder:"Filter projects..."}),e[14]=i,e[15]=l,e[16]=S):S=e[16];const C=o&&"animate-spin";let E;e[17]!==C?(E=G(C),e[17]=C,e[18]=E):E=e[18];let T;e[19]!==E?(T=a.jsx(Fn,{"data-icon":"inline-start",className:E}),e[19]=E,e[20]=T):T=e[20];let $;e[21]!==f||e[22]!==o||e[23]!==T?($=a.jsxs(Q,{variant:"outline",size:"sm",onClick:f,disabled:o,"aria-label":"Refresh projects",children:[T,"Refresh"]}),e[21]=f,e[22]=o,e[23]=T,e[24]=$):$=e[24];let A;e[25]!==$||e[26]!==S?(A=a.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[S,$]}),e[25]=$,e[26]=S,e[27]=A):A=e[27];let R;e[28]!==c||e[29]!==f||e[30]!==u?(R=c&&!u&&a.jsx(t7,{message:c,onRetry:f}),e[28]=c,e[29]=f,e[30]=u,e[31]=R):R=e[31];let P;e[32]!==p||e[33]!==v||e[34]!==r||e[35]!==d||e[36]!==h||e[37]!==g||e[38]!==i?(P=r?a.jsx(n7,{}):v.length===0?a.jsxs(Ln,{className:"min-h-72 border",children:[a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:a.jsx(Zr,{})}),a.jsx(zn,{children:i?"No projects match your search":"No projects yet"}),a.jsx(Dn,{children:i?"Try a project name or path.":"Start Claude Code, Codex, or Copilot and its project will appear here."})]}),!i&&a.jsx(_c,{children:a.jsxs(Q,{variant:"outline",size:"sm",onClick:Axe,children:[a.jsx(wc,{"data-icon":"inline-start"}),"Start in a folder"]})})]}):a.jsx("div",{className:"overflow-hidden rounded-lg border bg-card",children:v.map((I,M)=>{const F=p[I.dirName]||0,U=h[I.dirName],O=kM(un(I.dirName));return a.jsxs(y.Fragment,{children:[M>0&&a.jsx(en,{}),a.jsx(l7,{projectLabel:_r(I.path),customName:U,onRename:D=>g(I.dirName,D),children:a.jsxs("button",{type:"button",onClick:()=>d==null?void 0:d(I.dirName),className:"motion-list-item group flex w-full flex-col gap-3 px-4 py-3.5 text-left outline-none transition-colors hover:bg-muted/50 focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset sm:flex-row sm:items-center",children:[a.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-3",children:[a.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-md border bg-muted/40",children:a.jsx(ya,{projectPath:I.path,className:"size-4",fallback:a.jsx(Zr,{className:"size-4 text-muted-foreground"})})}),a.jsxs("span",{className:"min-w-0",children:[a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"truncate text-sm font-medium",children:U||_r(I.path)}),O&&a.jsx(Fe,{variant:"outline",className:"h-5 shrink-0 px-1.5 text-[10px]",children:O})]}),a.jsxs("span",{className:"block truncate text-xs text-muted-foreground",children:[jc(I.path),I.worktrees.length>0&&a.jsxs(a.Fragment,{children:[" · ",I.worktrees.length," ",I.worktrees.length===1?"worktree":"worktrees"]})]})]})]}),a.jsxs("span",{className:"flex items-center gap-4 pl-11 text-sm text-muted-foreground sm:pl-0",children:[F>0&&a.jsxs(Fe,{variant:"secondary",children:[a.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:"size-1.5 rounded-full bg-success"}),F," active"]}),a.jsxs("span",{className:"whitespace-nowrap",children:[I.sessionCount," ",I.sessionCount===1?"session":"sessions"]}),I.lastModified&&a.jsx("span",{className:"hidden w-24 whitespace-nowrap text-right md:inline",children:Cr(I.lastModified)}),a.jsx(it,{className:"size-4 shrink-0 transition-transform group-hover:translate-x-0.5"})]})]})}),I.worktrees.map(D=>a.jsx(Ixe,{worktree:D,customName:h[D.dirName],activeCount:p[D.dirName]||0,onSelect:()=>d==null?void 0:d(D.dirName)},D.dirName))]},I.dirName)})}),e[32]=p,e[33]=v,e[34]=r,e[35]=d,e[36]=h,e[37]=g,e[38]=i,e[39]=P):P=e[39];let z;e[40]!==A||e[41]!==R||e[42]!==P?(z=a.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Projects",children:[A,R,P]}),e[40]=A,e[41]=R,e[42]=P,e[43]=z):z=e[43];let L;return e[44]!==z||e[45]!==N?(L=a.jsx(Vc,{className:"h-full",children:a.jsxs("main",{className:"mx-auto flex max-w-6xl flex-col gap-6 px-4 py-6 sm:px-6 sm:pb-10 sm:pt-14",children:[N,z]})}),e[44]=z,e[45]=N,e[46]=L):L=e[46],L}function Axe(){return EI()}function Ixe(n){var b;const e=V.c(23),{worktree:t,customName:s,activeCount:r,onSelect:o}=n;let i;e[0]!==s||e[1]!==t.path?(i=s||((b=Nr(t.path))==null?void 0:b.worktreeName)||_r(t.path),e[0]=s,e[1]=t.path,e[2]=i):i=e[2];const l=i;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx(Gr,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[3]=c):c=e[3];let u;e[4]!==l?(u=a.jsx("span",{className:"min-w-0 flex-1 truncate text-muted-foreground group-hover:text-foreground",children:l}),e[4]=l,e[5]=u):u=e[5];let d;e[6]!==r?(d=r>0&&a.jsxs(Fe,{variant:"secondary",children:[a.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:"size-1.5 rounded-full bg-success"}),r," active"]}),e[6]=r,e[7]=d):d=e[7];const f=t.sessionCount===1?"session":"sessions";let m;e[8]!==f||e[9]!==t.sessionCount?(m=a.jsxs("span",{className:"whitespace-nowrap",children:[t.sessionCount," ",f]}),e[8]=f,e[9]=t.sessionCount,e[10]=m):m=e[10];let p;e[11]!==t.lastModified?(p=t.lastModified&&a.jsx("span",{className:"hidden w-24 whitespace-nowrap text-right md:inline",children:Cr(t.lastModified)}),e[11]=t.lastModified,e[12]=p):p=e[12];let h;e[13]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx(it,{className:"size-4 shrink-0 transition-transform group-hover:translate-x-0.5"}),e[13]=h):h=e[13];let g;e[14]!==d||e[15]!==m||e[16]!==p?(g=a.jsxs("span",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[d,m,p,h]}),e[14]=d,e[15]=m,e[16]=p,e[17]=g):g=e[17];let x;return e[18]!==o||e[19]!==u||e[20]!==g||e[21]!==t.path?(x=a.jsxs("button",{type:"button",onClick:o,title:t.path,className:"motion-list-item group flex w-full items-center gap-3 py-2 pl-15 pr-4 text-left text-sm outline-none transition-colors hover:bg-muted/50 focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",children:[c,u,g]}),e[18]=o,e[19]=u,e[20]=g,e[21]=t.path,e[22]=x):x=e[22],x}const Pxe=250,$xe=400,Ij={results:null,loading:!1,error:null};function c7(n,e,t){const s=y.useMemo(()=>r7(n),[n]),[r,o]=y.useState(0),[i,l]=y.useState(Ij);y.useEffect(()=>{if(!s){l(Ij);return}const d=new AbortController;l({results:null,loading:!0,error:null});let f=null;const m=async()=>{const h=new URLSearchParams({search:n.trim(),limit:"200"});t&&h.set("project",t);const g=Xr();try{const x=await Ce(zf(h,e),{signal:d.signal});if(!x.ok)throw new Error(`Search failed (${x.status})`);const b=await x.json();if(d.signal.aborted)return;const w=Number(x.headers.get("X-Cogpit-PR-Index-Pending")??"0");if(Number.isFinite(w)&&w>0){f=setTimeout(()=>{m()},$xe);return}const v=Array.isArray(b)?b:[];aa(v,g),l({results:v,loading:!1,error:null})}catch(x){if(d.signal.aborted)return;l({results:[],loading:!1,error:x instanceof Error?x.message:"Search failed"})}},p=setTimeout(()=>{m()},Pxe);return()=>{clearTimeout(p),f&&clearTimeout(f),d.abort()}},[e,t,s,n,r]);const c=y.useCallback(()=>o(d=>d+1),[]),u=s!==null;return y.useEffect(()=>{if(u)return Df(c)},[u,c]),{...i,active:u,refresh:c}}const Rxe=y.memo(function({onSelectSession:e,onNewSession:t,creatingSession:s,selectedProjectDirName:r,onSelectProject:o,onDuplicateSession:i,onDeleteSession:l}){var se;const c=Mf(),u=(se=$r().sessionListFilter)==null?void 0:se.Empty,[d]=y.useState(()=>({projects:Gi(Ql.projects),activeSessions:Gi(td(c.key))})),[f,m]=y.useState(d.projects??[]),[p,h]=y.useState(d.activeSessions??[]),[g,x]=y.useState(d.projects===void 0),[b,w]=y.useState(!1),[v,j]=y.useState(null),[k,_]=y.useState(null),[N,S]=y.useState([]),[C,E]=y.useState(0),[T,$]=y.useState(1),[A,R]=y.useState(!1),[P,z]=y.useState(""),[L,I]=y.useState(null),M=y.useRef(0),F=y.useRef(null),U=y.useRef(null),O=y.useRef(c.key),D=y.useCallback(async()=>{try{const J=await Ce("/api/projects");if(!J.ok)throw new Error("Failed to fetch dashboard data");const ne=await J.json(),ie=Array.isArray(ne)?ne:[];m(ie),_l(Ql.projects,ie),j(null)}catch(J){j(J instanceof Error?J.message:"Failed to load data")}finally{x(!1)}},[]),B=y.useCallback(async()=>{var ie;(ie=U.current)==null||ie.abort();const J=new AbortController;U.current=J;const ne=Xr();try{const ae=await Ce(zf({},c),{signal:J.signal});if(!ae.ok)throw new Error("Failed to fetch dashboard data");const oe=await ae.json();if(J.signal.aborted)return;const ue=Array.isArray(oe)?oe:[];aa(ue,ne),h(ue),_l(td(c.key),ue),_(null)}catch(ae){if(J.signal.aborted)return;_(ae instanceof Error?ae.message:"Failed to load data")}},[c]);y.useEffect(()=>{D()},[D]),y.useEffect(()=>{O.current!==c.key&&(O.current=c.key,h(Gi(td(c.key))??[])),B()},[c,B]);async function q(){w(!0),await Promise.all([D(),B()]),w(!1)}const W=y.useCallback(async(J,ne=1,ie=!1)=>{var de;const ae=++M.current;(de=F.current)==null||de.abort();const oe=new AbortController;F.current=oe;const ue=()=>ae===M.current;R(!0),I(null);const re=Xr();if(!ie){const fe=D9(J,c.key);fe?(S(fe.sessions),E(fe.total),$(1)):S([])}try{const fe=await Ce(El(`/api/sessions/${encodeURIComponent(J)}`,c,{page:String(ne),limit:"20"}),{signal:oe.signal});if(!fe.ok)throw new Error(`Failed to load sessions (${fe.status})`);const le=await fe.json();if(!ue())return;const ce=Array.isArray(le.sessions)?le.sessions:[],he=typeof le.total=="number"?le.total:ce.length;aa(ce,re),S(ge=>ie?[...ge,...ce]:ce),E(he),$(ne),ie||F9(J,c.key,{sessions:ce,total:he})}catch(fe){if(!ue()||oe.signal.aborted)return;I(fe instanceof Error?fe.message:"Failed to load sessions")}finally{ue()&&(F.current=null,R(!1))}},[c]);y.useEffect(()=>{var J;if(!r){M.current+=1,(J=F.current)==null||J.abort(),F.current=null,S([]),E(0),$(1),R(!1);return}W(r)},[r,W]),y.useEffect(()=>{z("")},[r]),y.useEffect(()=>()=>{var J,ne;M.current+=1,(J=F.current)==null||J.abort(),(ne=U.current)==null||ne.abort()},[]),y.useEffect(()=>Df(()=>{B(),r&&W(r)}),[B,W,r]);const H=y.useMemo(()=>{if(!r)return null;const J=f.find(ie=>ie.dirName===r);if(J)return J;const ne=xs(r);return{dirName:r,path:ne,shortName:_r(ne),sessionCount:C,lastModified:null}},[r,f,C]),K=y.useCallback(()=>{o==null||o(null)},[o]),Z=y.useCallback(()=>{r&&W(r,T+1,!0)},[r,T,W]),Y=c7(r?P:"",c,r??void 0),X=y.useMemo(()=>P?N.filter(J=>yxe(J,P)):N,[N,P]),ee=Y.results??X;async function te(J,ne){await(l==null?void 0:l(J,ne))&&(S(ie=>ie.filter(ae=>ae.fileName!==ne)),E(ie=>ie-1))}return H?a.jsx(_xe,{selectedProject:H,filterEmpty:c.key!==null&&u?a.jsx(u,{className:"min-h-72 border"}):null,sessions:N,sessionsTotal:C,sessionsLoading:A,searchLoading:Y.loading,searchFilter:P,setSearchFilter:z,filteredSessions:ee,fetchError:Y.error??L,onSelectSession:e,onNewSession:t,creatingSession:s,onDuplicateSession:i,onDeleteSession:te,onBack:K,onRetryFetch:()=>{if(Y.error){Y.refresh();return}I(null),r&&W(r)},loadMoreSessions:Z}):a.jsx(Txe,{projects:f,activeSessions:p,loading:g,refreshing:b,searchFilter:P,setSearchFilter:z,fetchError:v??k,selectedProjectDirName:r??null,onSelectProject:o,onRefresh:()=>void q()})}),Pj=768;function nv(){const n=V.c(2),[e,t]=y.useState(typeof window<"u"?window.innerWidth<Pj:!1);let s,r;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{const o=window.matchMedia(`(max-width: ${Pj-1}px)`),i=l=>t(l.matches);return o.addEventListener("change",i),t(o.matches),()=>o.removeEventListener("change",i)},r=[],n[0]=s,n[1]=r):(s=n[0],r=n[1]),y.useEffect(s,r),e}const u7=typeof navigator<"u"&&"vibrate"in navigator;function q1(){u7&&navigator.vibrate(10)}function Oxe(){u7&&navigator.vibrate(20)}function Lxe(n){return!!(n.teamName&&n.agentName)}function Mxe(n,e,t,s,r,o,i,l=()=>!0){const c=[],u=[];for(const d of Aa(n)){const f=p=>{l(d)&&c.push({session:d,reason:p})};if(s!=null&&s.has(d.sessionId)){f("permission");continue}if(r!=null&&r.has(d.sessionId)){f("question");continue}if(o!=null&&o.has(d.sessionId)){f("prompt");continue}if(i!=null&&i.has(d.sessionId)){f("plan");continue}if(d.agentStatus==="deferred"){f("deferred");continue}if(Lxe(d))continue;const m=Mx(d,e);if(d.agentStatus==="completed"||!m){t.has(d.sessionId)&&f("done");continue}if(d.agentStatus==="idle"){f("waiting");continue}(!d.agentStatus||$f.has(d.agentStatus))&&u.push(d)}return{needsYou:c,working:u}}function zxe(n,e,t,s,r=()=>!0){const o=[...n.needsYou],i=[...n.working],l=new Map;for(const u of e){const d=t.get(u.sessionId);if(!(d!=null&&d.length))continue;const f=Dx(d,p=>{const h=s(p);return h.state==="needs-you"&&!r(p)?{state:"done"}:h}),m=o.findIndex(p=>p.session.sessionId===u.sessionId);if(f.needsYou>0)if(m>=0)o[m]={...o[m],crew:f};else{o.push({session:u,reason:"crew",crew:f});const p=i.indexOf(u);p>=0&&i.splice(p,1)}else f.working>0&&m<0&&!i.includes(u)&&(i.push(u),l.set(u.sessionId,f))}const c=u=>{var d;return u.reason==="crew"&&((d=u.crew)!=null&&d.longestWaitSince)?Date.parse(u.crew.longestWaitSince):jr(u.session)};return o.sort((u,d)=>c(d)-c(u)),{needsYou:o,working:Aa(i),workingCrews:l}}function d7(n){switch(n.agentStatus){case"tool_use":return n.agentToolName||"Tool";case"thinking":return"Thinking";case"processing":return"Processing";case"compacting":return"Compacting";case"awaiting_agents":return"Agents running";default:return"Running"}}const f7="aw:turnCounts",Dxe=200,$m=new Map;try{const n=localStorage.getItem(f7);if(n){const e=JSON.parse(n);for(const[t,s]of e)$m.set(t,s)}}catch{}function Fxe(){try{const n=[...$m.entries()].slice(-Dxe);localStorage.setItem(f7,JSON.stringify(n))}catch{}}function Uxe(n,e){$m.set(sn(n),e),Fxe()}function m7(n,e){const t=$m.get(sn(n));return Math.max(t??0,e??0)}function sv(n){const e=V.c(51),{session:t,proc:s,statusLabel:r,customName:o,worktreeName:i,projectLabel:l}=n,c=o||t.aiTitle,u=t.firstUserMessage,d=t.lastUserMessage&&t.lastUserMessage!==u?t.lastUserMessage:void 0,f=m7(t.sessionId,t.turnCount);let m;e[0]!==c?(m=c&&a.jsx("span",{className:"font-medium leading-snug text-foreground",children:c}),e[0]=c,e[1]=m):m=e[1];let p;e[2]!==l?(p=l&&a.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[a.jsx(sa,{className:"size-3 shrink-0"}),a.jsx("span",{className:"truncate",children:l})]}),e[2]=l,e[3]=p):p=e[3];let h;e[4]!==t.agentStatus||e[5]!==r?(h=r&&a.jsx("span",{className:G("font-medium",wm(t.agentStatus)),children:r}),e[4]=t.agentStatus,e[5]=r,e[6]=h):h=e[6];let g;e[7]!==t.agentName||e[8]!==t.teamName?(g=t.teamName&&t.agentName&&a.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[a.jsx(er,{className:"size-3"}),t.agentName," · ",t.teamName]}),e[7]=t.agentName,e[8]=t.teamName,e[9]=g):g=e[9];let x;e[10]!==t.archived||e[11]!==t.archivedReason?(x=t.archived&&a.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[a.jsx(Ns,{className:"size-3"}),Ox(t.archivedReason)]}),e[10]=t.archived,e[11]=t.archivedReason,e[12]=x):x=e[12];let b;e[13]!==u||e[14]!==d?(b=u&&a.jsxs("div",{className:"flex flex-col gap-0.5",children:[d&&a.jsx("span",{className:"text-[10px] text-muted-foreground/70",children:"Started with"}),a.jsx("div",{className:"border-l-2 pl-2 text-muted-foreground",children:a.jsx("span",{"data-first-prompt":!0,className:"line-clamp-8 leading-relaxed",children:u})})]}),e[13]=u,e[14]=d,e[15]=b):b=e[15];let w;e[16]!==d?(w=d&&a.jsxs("div",{className:"flex flex-col gap-0.5",children:[a.jsx("span",{className:"text-[10px] text-muted-foreground/70",children:"Latest"}),a.jsx("div",{className:"border-l-2 pl-2 text-muted-foreground",children:a.jsx("span",{"data-last-prompt":!0,className:"line-clamp-4 leading-relaxed",children:d})})]}),e[16]=d,e[17]=w):w=e[17];let v;e[18]!==t.pullRequests?(v=a.jsx(su,{pullRequests:t.pullRequests,layout:"list"}),e[18]=t.pullRequests,e[19]=v):v=e[19];let j;e[20]!==t.gitBranch||e[21]!==i?(j=t.gitBranch&&a.jsxs("span",{className:"flex items-center gap-0.5",children:[a.jsx(Gr,{className:"size-2.5"}),i?`${t.gitBranch} · ${i}`:t.gitBranch]}),e[20]=t.gitBranch,e[21]=i,e[22]=j):j=e[22];let k;e[23]!==f?(k=f>0&&a.jsxs("span",{className:"flex items-center gap-0.5",children:[a.jsx(vc,{className:"size-2.5"}),f," ",f===1?"turn":"turns"]}),e[23]=f,e[24]=k):k=e[24];let _;e[25]!==t.size?(_=wN(t.size),e[25]=t.size,e[26]=_):_=e[26];let N;e[27]!==_?(N=a.jsx("span",{children:_}),e[27]=_,e[28]=N):N=e[28];let S;e[29]!==s?(S=s&&a.jsxs("span",{className:"flex items-center gap-0.5 text-success",children:[a.jsx(z8,{className:"size-2.5"}),s.memMB," MB"]}),e[29]=s,e[30]=S):S=e[30];const C=t.lastActivityAt||t.lastModified;let E;e[31]!==C?(E=Cr(C),e[31]=C,e[32]=E):E=e[32];let T;e[33]!==E?(T=a.jsx("span",{children:E}),e[33]=E,e[34]=T):T=e[34];let $;e[35]!==k||e[36]!==N||e[37]!==S||e[38]!==T||e[39]!==j?($=a.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-muted-foreground",children:[j,k,N,S,T]}),e[35]=k,e[36]=N,e[37]=S,e[38]=T,e[39]=j,e[40]=$):$=e[40];let A;return e[41]!==m||e[42]!==$||e[43]!==p||e[44]!==h||e[45]!==g||e[46]!==x||e[47]!==b||e[48]!==w||e[49]!==v?(A=a.jsxs("div",{className:"flex w-72 flex-col gap-2 text-xs",children:[m,p,h,g,x,b,w,v,$]}),e[41]=m,e[42]=$,e[43]=p,e[44]=h,e[45]=g,e[46]=x,e[47]=b,e[48]=w,e[49]=v,e[50]=A):A=e[50],A}const Bxe=120;function rv(n){const e=V.c(7),t=y.useRef(null);let s,r;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>()=>{t.current&&clearTimeout(t.current)},r=[],e[0]=s,e[1]=r):(s=e[0],r=e[1]),y.useEffect(s,r);let o;e[2]!==n?(o=()=>{n&&(t.current&&clearTimeout(t.current),t.current=setTimeout(n,Bxe))},e[2]=n,e[3]=o):o=e[3];const i=o;let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{t.current&&(clearTimeout(t.current),t.current=null)},e[4]=l):l=e[4];const c=l;let u;return e[5]!==i?(u={onHoverStart:i,onHoverEnd:c},e[5]=i,e[6]=u):u=e[6],u}const Wxe=6;function qxe(n,e){var s;const t=(s=e.workingCrews)==null?void 0:s.get(n.sessionId);return t?`${t.working} in crew`:d7(n)}function Vxe(n){const e=V.c(7),{iso:t}=n,[,s]=y.useState(0);let r;e[0]!==s?(r=()=>{const c=setInterval(()=>s(Hxe),15e3);return()=>clearInterval(c)},e[0]=s,e[1]=r):r=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[2]=o):o=e[2],y.useEffect(r,o);let i;e[3]!==t?(i=Cr(t),e[3]=t,e[4]=i):i=e[4];let l;return e[5]!==i?(l=a.jsx("span",{"data-relative-time":!0,className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:i}),e[5]=i,e[6]=l):l=e[6],l}function Hxe(n){return n+1}const Kxe={permission:{label:"Permission",className:"border-warning/30 bg-warning/10 text-warning"},deferred:{label:"Deferred",className:"border-warning/30 bg-warning/10 text-warning"},question:{label:"Question",className:"border-warning/30 bg-warning/10 text-warning"},prompt:{label:"Input needed",className:"border-warning/30 bg-warning/10 text-warning"},plan:{label:"Review plan",className:"border-warning/30 bg-warning/10 text-warning"},waiting:{label:"Waiting",className:"border-warning/30 bg-warning/10 text-warning"},done:{label:"Done",className:"border-success/30 bg-success/10 text-success"},crew:{label:"Waiting",className:"border-warning/30 bg-warning/10 text-warning"}};function Gxe({reason:n,crew:e}){const t=Kxe[n];return n==="crew"&&e?{...t,label:`${e.needsYou} waiting`}:t}const Zxe={permission:Hs.attention,deferred:Hs.attention,waiting:Hs.attention,question:"bg-warning",prompt:"bg-warning",plan:"bg-warning",done:"bg-success",crew:Hs.attention};function $j(n){const e=V.c(77),{session:t,chip:s,dotClassName:r,cardClassName:o,since:i,isActiveSession:l,proc:c,killingPids:u,customName:d,projectLabel:f,compact:m,onSelect:p,onKill:h,onResume:g,onPrefetch:x}=n,b=m===void 0?!1:m;let w;e[0]!==c||e[1]!==t.dirName?(w=$b(un(t.dirName),c),e[0]=c,e[1]=t.dirName,e[2]=w):w=e[2];const v=w;let j;e[3]!==s||e[4]!==v||e[5]!==t.agentPendingAgents||e[6]!==t.agentStatus||e[7]!==t.agentTerminalReason||e[8]!==t.agentToolName?(j=v?"Read-only":Jc(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??s.label,e[3]=s,e[4]=v,e[5]=t.agentPendingAgents,e[6]=t.agentStatus,e[7]=t.agentTerminalReason,e[8]=t.agentToolName,e[9]=j):j=e[9];const k=j,_=!!g&&!v,{onHoverStart:N,onHoverEnd:S}=rv(x),C=b?"px-2.5 py-2":"border px-2 py-2",E=l&&!b&&"ring-1 ring-ring";let T;e[10]!==o||e[11]!==C||e[12]!==E?(T=G("group relative w-full rounded-md text-left transition-colors",C,o,E),e[10]=o,e[11]=C,e[12]=E,e[13]=T):T=e[13];let $;e[14]!==b||e[15]!==l?($=b&&l&&a.jsx("span",{className:"absolute inset-y-2 left-0 w-0.5 rounded-full bg-primary","aria-hidden":"true"}),e[14]=b,e[15]=l,e[16]=$):$=e[16];const A=_&&"pr-20";let R;e[17]!==A?(R=G("w-full rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",A),e[17]=A,e[18]=R):R=e[18];let P;e[19]!==S||e[20]!==N||e[21]!==p||e[22]!==R?(P=a.jsx("button",{type:"button","data-attention-session":!0,onClick:p,onMouseEnter:N,onMouseLeave:S,onFocus:N,onBlur:S,className:R}),e[19]=S,e[20]=N,e[21]=p,e[22]=R,e[23]=P):P=e[23];const z=b&&"ring-0";let L;e[24]!==r||e[25]!==z?(L=G("size-1.5 shrink-0 rounded-full",r,z),e[24]=r,e[25]=z,e[26]=L):L=e[26];let I;e[27]!==L?(I=a.jsx("span",{className:L,"aria-hidden":"true"}),e[27]=L,e[28]=I):I=e[28];let M;e[29]!==d||e[30]!==t?(M=pi(t,d),e[29]=d,e[30]=t,e[31]=M):M=e[31];let F;e[32]!==M?(F=a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs leading-tight text-foreground",children:M}),e[32]=M,e[33]=F):F=e[33];const U=b?"text-muted-foreground":s.className;let O;e[34]!==U?(O=G("shrink-0",U),e[34]=U,e[35]=O):O=e[35];const D=v?"Read-only":s.label;let B;e[36]!==O||e[37]!==D?(B=a.jsx(Fe,{variant:"outline",className:O,children:D}),e[36]=O,e[37]=D,e[38]=B):B=e[38];let q;e[39]!==b||e[40]!==t.lastActivityAt||e[41]!==t.lastModified||e[42]!==i?(q=!b&&a.jsx(Vxe,{iso:i??(t.lastActivityAt||t.lastModified)}),e[39]=b,e[40]=t.lastActivityAt,e[41]=t.lastModified,e[42]=i,e[43]=q):q=e[43];let W;e[44]!==I||e[45]!==F||e[46]!==B||e[47]!==q?(W=a.jsxs("span",{className:"flex items-center gap-1.5",children:[I,F,B,q]}),e[44]=I,e[45]=F,e[46]=B,e[47]=q,e[48]=W):W=e[48];let H;e[49]!==f?(H=a.jsx("span",{className:"mt-1 block truncate pl-3 text-xs text-muted-foreground",children:f}),e[49]=f,e[50]=H):H=e[50];let K;e[51]!==P||e[52]!==W||e[53]!==H?(K=a.jsxs(Zt,{render:P,children:[W,H]}),e[51]=P,e[52]=W,e[53]=H,e[54]=K):K=e[54];let Z;e[55]!==d||e[56]!==c||e[57]!==t||e[58]!==k?(Z=a.jsx(Yt,{side:"right",className:"max-w-[280px]",children:a.jsx(sv,{session:t,proc:c,statusLabel:k,customName:d})}),e[55]=d,e[56]=c,e[57]=t,e[58]=k,e[59]=Z):Z=e[59];let Y;e[60]!==K||e[61]!==Z?(Y=a.jsxs(Gt,{children:[K,Z]}),e[60]=K,e[61]=Z,e[62]=Y):Y=e[62];let X;e[63]!==_||e[64]!==g?(X=_&&a.jsxs(Q,{type:"button",variant:"outline",size:"xs",onClick:g,className:"absolute bottom-1 right-1 text-warning","aria-label":"Resume to evaluate",children:[a.jsx(Na,{"data-icon":"inline-start"}),"Resume"]}),e[63]=_,e[64]=g,e[65]=X):X=e[65];let ee;e[66]!==v||e[67]!==u||e[68]!==h||e[69]!==c?(ee=c&&h&&!v&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:se=>h(c.pid,se),disabled:u.has(c.pid),className:"absolute right-0 top-0 text-destructive opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",title:`Kill PID ${c.pid}`,"aria-label":`Kill process ${c.pid}`,children:a.jsx(Mt,{"data-icon":"inline-start"})}),e[66]=v,e[67]=u,e[68]=h,e[69]=c,e[70]=ee):ee=e[70];let te;return e[71]!==Y||e[72]!==X||e[73]!==ee||e[74]!==T||e[75]!==$?(te=a.jsxs("div",{className:T,children:[$,Y,X,ee]}),e[71]=Y,e[72]=X,e[73]=ee,e[74]=T,e[75]=$,e[76]=te):te=e[76],te}function Yxe(n){const e=V.c(15),{dotClassName:t,labelClassName:s,label:r,count:o}=n;let i;e[0]!==t?(i=G("size-1.5 rounded-full",t),e[0]=t,e[1]=i):i=e[1];let l;e[2]!==i?(l=a.jsx("span",{className:i,"aria-hidden":"true"}),e[2]=i,e[3]=l):l=e[3];let c;e[4]!==s?(c=G("text-xs font-medium",s),e[4]=s,e[5]=c):c=e[5];let u;e[6]!==r||e[7]!==c?(u=a.jsx("span",{className:c,children:r}),e[6]=r,e[7]=c,e[8]=u):u=e[8];let d;e[9]!==o?(d=a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:o}),e[9]=o,e[10]=d):d=e[10];let f;return e[11]!==l||e[12]!==u||e[13]!==d?(f=a.jsxs("div",{className:"flex items-center gap-1.5 px-0.5",children:[l,u,d]}),e[11]=l,e[12]=u,e[13]=d,e[14]=f):f=e[14],f}function Xxe(n){const e=V.c(28),{groups:t,activeSessionKey:s,procBySession:r,killingPids:o,sessionNames:i,projectNames:l,onSelectSession:c,onKill:u,onResumeSession:d,onPrefetchSession:f}=n,m=Pm(),[p,h]=y.useState(!1);let g;e[0]!==t.working||e[1]!==p?(g=p?t.working:t.working.slice(0,Wxe),e[0]=t.working,e[1]=p,e[2]=g):g=e[2];const x=g,b=t.working.length-x.length;let w;e[3]!==l?(w=C=>l[C.dirName]||Rx(C.cwd||xs(C.dirName)),e[3]=l,e[4]=w):w=e[4];const v=w;let j;e[5]!==s||e[6]!==o||e[7]!==u||e[8]!==f||e[9]!==c||e[10]!==m||e[11]!==r||e[12]!==v||e[13]!==i?(j=C=>{const E=s===`${C.dirName}/${C.fileName}`;return{session:C,isActiveSession:E,proc:r.get(C.sessionId),killingPids:o,customName:i[C.sessionId],projectLabel:v(C),onSelect:()=>c(C.dirName,C.fileName),onKill:m(C.access).stop?u:void 0,onPrefetch:f&&!E?()=>f(C.dirName,C.fileName):void 0}},e[5]=s,e[6]=o,e[7]=u,e[8]=f,e[9]=c,e[10]=m,e[11]=r,e[12]=v,e[13]=i,e[14]=j):j=e[14];const k=j;let _;e[15]!==t.needsYou||e[16]!==d||e[17]!==m||e[18]!==k?(_=t.needsYou.length>0&&a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsx(Yxe,{dotClassName:Hs.attention,labelClassName:"text-warning",label:"Needs you",count:t.needsYou.length}),t.needsYou.map(C=>{var $;const{session:E,reason:T}=C;return a.jsx($j,{...k(E),chip:Gxe(C),since:T==="crew"?($=C.crew)==null?void 0:$.longestWaitSince:void 0,dotClassName:Zxe[T],cardClassName:"border-warning/20 bg-warning/5 hover:bg-warning/10",onResume:T==="deferred"&&d&&m(E.access).send?()=>d(E.sessionId,E.cwd,E.dirName):void 0},`${E.dirName}/${E.fileName}`)})]}),e[15]=t.needsYou,e[16]=d,e[17]=m,e[18]=k,e[19]=_):_=e[19];let N;e[20]!==t||e[21]!==b||e[22]!==k||e[23]!==x?(N=t.working.length>0&&a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsxs("div",{className:"flex items-center justify-between px-1",children:[a.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Working"}),a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:t.working.length})]}),a.jsx("div",{"data-working-list":!0,className:"flex flex-col gap-0.5 overflow-hidden rounded-lg border bg-background p-0.5",children:x.map(C=>a.jsx($j,{...k(C),chip:{label:qxe(C,t),className:""},dotClassName:Hs.working,cardClassName:"hover:bg-accent/50",compact:!0},`${C.dirName}/${C.fileName}`))}),b>0&&a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",onClick:()=>h(!0),className:"justify-start",children:[a.jsx(_t,{"data-icon":"inline-start"}),"Show ",b," more"]})]}),e[20]=t,e[21]=b,e[22]=k,e[23]=x,e[24]=N):N=e[24];let S;return e[25]!==_||e[26]!==N?(S=a.jsxs("div",{className:"flex flex-col gap-2","data-attention-strip":!0,children:[_,N]}),e[25]=_,e[26]=N,e[27]=S):S=e[27],S}function Jxe(n){const e=V.c(49),{loading:t,isMobile:s,searchQuery:r,searchLoading:o,showArchived:i,archivedCount:l,groupCrews:c,onToggleGroupCrews:u,onSearchQueryChange:d,onToggleShowArchived:f,onRefresh:m}=n,p=l===0?"No archived sessions":`${l} archived ${l===1?"session":"sessions"}`;let h;e[0]!==d?(h=F=>d(F.target.value),e[0]=d,e[1]=h):h=e[1];let g;e[2]!==o||e[3]!==r||e[4]!==h?(g=a.jsx(Go,{type:"search",value:r,onChange:h,placeholder:"Search sessions or PRs","aria-label":"Search sessions by project, branch, title, prompt, PR number, or PR URL","aria-busy":o}),e[2]=o,e[3]=r,e[4]=h,e[5]=g):g=e[5];let x;e[6]!==o?(x=a.jsx(Tr,{align:"inline-start",children:o?a.jsx(St,{className:"animate-spin"}):a.jsx(ss,{})}),e[6]=o,e[7]=x):x=e[7];let b;e[8]!==d||e[9]!==r?(b=r&&a.jsx(Tr,{align:"inline-end",children:a.jsx(dm,{size:"icon-xs",onClick:()=>d(""),"aria-label":"Clear session search",children:a.jsx(Mt,{"data-icon":"inline-start"})})}),e[8]=d,e[9]=r,e[10]=b):b=e[10];let w;e[11]!==g||e[12]!==x||e[13]!==b?(w=a.jsxs(Ko,{children:[g,x,b]}),e[11]=g,e[12]=x,e[13]=b,e[14]=w):w=e[14];let v;e[15]!==c||e[16]!==s||e[17]!==u?(v=u&&a.jsxs(Gt,{children:[a.jsx(Zt,{render:a.jsx(Q,{variant:"ghost",size:s?"icon-sm":"icon-xs",onClick:u,"aria-pressed":c,"aria-label":c?"List spawned sessions on their own":"Group spawned sessions",className:G(c&&"bg-accent text-accent-foreground")}),children:a.jsx(M4,{"data-icon":"inline-start"})}),a.jsx(Yt,{side:"bottom",children:c?"Sessions another session started are listed under it":"Group spawned sessions under the session that started them"})]}),e[15]=c,e[16]=s,e[17]=u,e[18]=v):v=e[18];const j=s?"icon-sm":"icon-xs",k=i?"Hide archived sessions":"Show archived sessions",_=i&&"bg-accent text-accent-foreground";let N;e[19]!==_?(N=G(_),e[19]=_,e[20]=N):N=e[20];let S;e[21]!==f||e[22]!==i||e[23]!==N||e[24]!==j||e[25]!==k?(S=a.jsx(Q,{variant:"ghost",size:j,onClick:f,"aria-pressed":i,"aria-label":k,className:N}),e[21]=f,e[22]=i,e[23]=N,e[24]=j,e[25]=k,e[26]=S):S=e[26];let C;e[27]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsx(Ns,{"data-icon":"inline-start"}),e[27]=C):C=e[27];let E;e[28]!==S?(E=a.jsx(Zt,{render:S,children:C}),e[28]=S,e[29]=E):E=e[29];const T=i?"Hide archived":"Show archived";let $;e[30]!==p||e[31]!==T?($=a.jsxs(Yt,{side:"bottom",children:[T," · ",p]}),e[30]=p,e[31]=T,e[32]=$):$=e[32];let A;e[33]!==E||e[34]!==$?(A=a.jsxs(Gt,{children:[E,$]}),e[33]=E,e[34]=$,e[35]=A):A=e[35];const R=s?"icon-sm":"icon-xs",P=t&&"animate-spin";let z;e[36]!==P?(z=G(P),e[36]=P,e[37]=z):z=e[37];let L;e[38]!==z?(L=a.jsx(Fn,{"data-icon":"inline-start",className:z}),e[38]=z,e[39]=L):L=e[39];let I;e[40]!==m||e[41]!==R||e[42]!==L?(I=a.jsx(Q,{variant:"ghost",size:R,onClick:m,"aria-label":"Refresh sessions",children:L}),e[40]=m,e[41]=R,e[42]=L,e[43]=I):I=e[43];let M;return e[44]!==A||e[45]!==I||e[46]!==w||e[47]!==v?(M=a.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b px-2.5 py-2",children:[w,v,A,I]}),e[44]=A,e[45]=I,e[46]=w,e[47]=v,e[48]=M):M=e[48],M}const Qxe=["first","second","third","fourth","fifth"];function e0e(n){const e=V.c(33),{fetchError:t,showEmpty:s,searching:r,loading:o,sessionCount:i,hiddenArchivedCount:l,focusedProject:c,onShowAllProjects:u,filterEmpty:d,onShowArchived:f,onRetry:m}=n,p=c===void 0?null:c,h=d===void 0?null:d,g=!!h;let x;e[0]!==p||e[1]!==l||e[2]!==r||e[3]!==s||e[4]!==g?(x=n0e({showEmpty:s,searching:r,focusedProject:p,hiddenArchivedCount:l,filtered:g}),e[0]=p,e[1]=l,e[2]=r,e[3]=s,e[4]=g,e[5]=x):x=e[5];const b=x;let w;e[6]!==t||e[7]!==m?(w=t&&a.jsxs(jt,{variant:"destructive",children:[a.jsx(Ir,{}),a.jsx(tn,{children:"Could not load sessions"}),a.jsx(Rt,{className:"truncate",children:t}),a.jsx(Po,{children:a.jsx(Q,{variant:"outline",size:"xs",onClick:m,children:"Retry"})})]}),e[6]=t,e[7]=m,e[8]=w):w=e[8];let v;e[9]!==b||e[10]!==l||e[11]!==f?(v=b==="archived"&&a.jsxs(Ln,{className:"min-h-56 px-4 py-8",children:[a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:a.jsx(Ns,{})}),a.jsx(zn,{children:"Everything is archived"}),a.jsx(Dn,{children:l===1?"1 archived session is hidden.":`${l} archived sessions are hidden.`})]}),a.jsxs(Q,{variant:"outline",size:"sm",onClick:f,children:[a.jsx(Ns,{"data-icon":"inline-start"}),"Show archived"]})]}),e[9]=b,e[10]=l,e[11]=f,e[12]=v):v=e[12];let j;e[13]!==b||e[14]!==p||e[15]!==l||e[16]!==u||e[17]!==f||e[18]!==r?(j=b==="focused"&&a.jsxs(Ln,{className:"min-h-56 px-4 py-8",children:[a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:r?a.jsx(ss,{}):a.jsx(vg,{})}),a.jsx(zn,{children:r?`No matching sessions in ${p}`:`No sessions in ${p}`}),a.jsx(Dn,{children:s0e(r,l)})]}),a.jsxs("div",{className:"flex flex-wrap justify-center gap-2",children:[a.jsxs(Q,{variant:"outline",size:"sm",onClick:u,children:[a.jsx(jd,{"data-icon":"inline-start"}),"All projects"]}),!r&&l>0&&a.jsxs(Q,{variant:"ghost",size:"sm",onClick:f,children:[a.jsx(Ns,{"data-icon":"inline-start"}),"Show archived"]})]})]}),e[13]=b,e[14]=p,e[15]=l,e[16]=u,e[17]=f,e[18]=r,e[19]=j):j=e[19];const k=b==="filtered"&&h;let _;e[20]!==b||e[21]!==r?(_=b==="plain"&&a.jsx(Ln,{className:"min-h-56 px-4 py-8",children:a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:r?a.jsx(ss,{}):a.jsx(vg,{})}),a.jsx(zn,{children:r?"No matching sessions":"No sessions yet"}),a.jsx(Dn,{children:r?"Try #157, honest-cms #157, or paste a PR URL.":"Start Claude Code, Codex, or Copilot to see recent work here."})]})}),e[20]=b,e[21]=r,e[22]=_):_=e[22];let N;e[23]!==o||e[24]!==i?(N=o&&i===0&&a.jsx("div",{className:"flex flex-col gap-2 px-2 py-4","aria-label":"Loading sessions",children:Qxe.map(t0e)}),e[23]=o,e[24]=i,e[25]=N):N=e[25];let S;return e[26]!==N||e[27]!==w||e[28]!==v||e[29]!==j||e[30]!==k||e[31]!==_?(S=a.jsxs(a.Fragment,{children:[w,v,j,k,_,N]}),e[26]=N,e[27]=w,e[28]=v,e[29]=j,e[30]=k,e[31]=_,e[32]=S):S=e[32],S}function t0e(n){return a.jsxs("div",{className:"flex items-center gap-2 py-1",children:[a.jsx(Gn,{className:"size-2 shrink-0 rounded-full"}),a.jsx(Gn,{className:"h-4 flex-1"}),a.jsx(Gn,{className:"h-4 w-10"})]},n)}function n0e({showEmpty:n,searching:e,focusedProject:t,hiddenArchivedCount:s,filtered:r}){return n?t!==null?"focused":!e&&s>0?"archived":!e&&r?"filtered":"plain":null}function s0e(n,e){return n?"Try another search, or look across every project.":e>0?"Its sessions may be archived. Start a new one, or look across every project.":"Start a new session here, or look across every project."}const lg=864e5;function r0e(n){const e=new Date(n);return e.setHours(0,0,0,0),e.getTime()}function o0e(n,e=Date.now()){const t=Date.parse(n);if(!Number.isFinite(t))return"Older";const s=r0e(e);return t>=s?"Today":t>=s-lg?"Yesterday":t>=s-6*lg?"Last 7 days":t>=s-29*lg?"Last 30 days":"Older"}const i0e=6,a0e={permission:"permission",question:"question",input:"input",plan:"plan",deferred:"deferred"},Rj={"needs-you":0,working:1,done:2};function l0e(n){const e=V.c(39),{host:t,members:s,counts:r,statusOf:o,open:i,onToggle:l,sessionNames:c,activeSessionKey:u,onSelectSession:d}=n,[f,m]=y.useState(!1);let p;if(e[0]!==u||e[1]!==r.needsYou||e[2]!==r.size||e[3]!==r.working||e[4]!==t||e[5]!==s||e[6]!==d||e[7]!==l||e[8]!==i||e[9]!==c||e[10]!==f||e[11]!==o){const h=new Map([t,...s].map(c0e)),g=I=>!I.crew||I.crew.parentId===t.sessionId||!h.has(I.crew.parentId);let x;e[13]!==g||e[14]!==o?(x=I=>g(I)||o(I).state==="needs-you",e[13]=g,e[14]=o,e[15]=x):x=e[15];const b=s.filter(x);let w;e[16]!==o?(w=(I,M)=>Rj[o(I).state]-Rj[o(M).state]||(o(I).state==="done"?jr(M)-jr(I):0),e[16]=o,e[17]=w):w=e[17];const v=[...b].sort(w);let j;e[18]!==o?(j=I=>o(I).state==="done",e[18]=o,e[19]=j):j=e[19];const k=v.filter(j),_=f?[]:k.slice(i0e),N=v.filter(I=>!_.includes(I)),S=`Crew of ${r.size}${r.needsYou?`, ${r.needsYou} need you`:""}${r.working?`, ${r.working} working`:""}`,C=i?`Hide crew: ${S}`:`Show crew: ${S}`,E=i&&"rotate-90";let T;e[20]!==E?(T=G("size-3 shrink-0 transition-transform duration-150",E),e[20]=E,e[21]=T):T=e[21];let $;e[22]!==T?($=a.jsx(it,{className:T,"aria-hidden":"true"}),e[22]=T,e[23]=$):$=e[23];let A;e[24]===Symbol.for("react.memo_cache_sentinel")?(A=a.jsx("span",{className:"font-medium text-foreground",children:"Crew"}),e[24]=A):A=e[24];let R;e[25]!==r.size?(R=a.jsxs("span",{className:"tabular-nums",children:["· ",r.size]}),e[25]=r.size,e[26]=R):R=e[26];let P;e[27]!==r.needsYou?(P=r.needsYou>0&&a.jsxs("span",{className:"tabular-nums text-warning",children:["· ",r.needsYou," need you"]}),e[27]=r.needsYou,e[28]=P):P=e[28];let z;e[29]!==r.working?(z=r.working>0&&a.jsxs("span",{className:"tabular-nums",children:["· ",r.working," working"]}),e[29]=r.working,e[30]=z):z=e[30];let L;e[31]!==l||e[32]!==i||e[33]!==R||e[34]!==P||e[35]!==z||e[36]!==C||e[37]!==$?(L=a.jsxs("button",{type:"button",onClick:l,"aria-expanded":i,"aria-label":C,className:"flex w-full items-center gap-1.5 rounded-sm py-0.5 text-left text-[11px] text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:[$,A,R,P,z]}),e[31]=l,e[32]=i,e[33]=R,e[34]=P,e[35]=z,e[36]=C,e[37]=$,e[38]=L):L=e[38],p=a.jsxs("div",{"data-crew-fold":!0,className:"mx-3 mb-2 ml-[26px] border-t border-border/60 pt-1.5",children:[L,i&&a.jsxs("ul",{className:"mt-1 ml-1.5 flex flex-col gap-px border-l border-border/70 pl-1.5",children:[N.map(I=>{var H;const M=o(I),F=I9(I.sessionId,s),U=I.crew?h.get(I.crew.parentId):void 0,O=u===`${I.dirName}/${I.fileName}`,D=Pd(I,{customName:c[I.sessionId],parent:U??t}),B=d0e(I,M),W=(!g(I)&&U?` · via ${Pd(U,{customName:c[U.sessionId],parent:h.get(((H=U.crew)==null?void 0:H.parentId)??"")??t})}`:"")||(F>0?` · ${F} ${F===1?"session":"sessions"}`:"");return a.jsx("li",{children:a.jsxs("button",{type:"button","data-crew-member":I.sessionId,"aria-current":O?"true":void 0,"aria-label":`${D}${W}, ${B}`,onClick:()=>d(I.dirName,I.fileName),className:G("flex w-full items-center gap-1.5 rounded-md px-1.5 py-1 text-left text-xs outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring",O&&"bg-accent"),children:[a.jsx("span",{className:G("size-1.5 shrink-0 rounded-full",u0e(M)),"aria-hidden":"true"}),a.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[D,W&&a.jsx("span",{className:"text-muted-foreground/70",children:W})]}),a.jsx("span",{className:G("shrink-0 text-[11px] tabular-nums",M.state==="needs-you"?"text-warning":"text-muted-foreground/80"),children:B})]})},I.sessionId)}),_.length>0&&a.jsx("li",{children:a.jsxs("button",{type:"button",onClick:()=>m(!0),className:"rounded-sm px-1.5 py-1 text-[11px] text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:["Show ",_.length," more done"]})})]})]}),e[0]=u,e[1]=r.needsYou,e[2]=r.size,e[3]=r.working,e[4]=t,e[5]=s,e[6]=d,e[7]=l,e[8]=i,e[9]=c,e[10]=f,e[11]=o,e[12]=p}else p=e[12];return p}function c0e(n){return[n.sessionId,n]}function u0e({state:n}){return n==="needs-you"?Hs.attention:n==="working"?Hs.working:"bg-muted-foreground/50"}function d0e(n,{state:e,need:t}){var o;const s=Cr(n.lastActivityAt||n.lastModified);if(e==="needs-you")return`${a0e[t??"input"]} · ${s}`;if(e==="working")return d7(n);const r=(o=n.pullRequests)==null?void 0:o.at(-1);return r?`#${r.number} · ${s}`:s}const f0e={};function m0e(n){var Lr,_n;const e=V.c(172),{session:t,projectLabel:s,projectPath:r,showProject:o,isActiveSession:i,proc:l,killingPids:c,isNewlyCompleted:u,customName:d,worktreeName:f,teammateCount:m,teammatesCollapsed:p,onToggleTeammates:h,onSelectSession:g,onKill:x,onDuplicateSession:b,onDeleteSession:w,onArchiveSession:v,onUnarchiveSession:j,onRenameSession:k,onPrefetchSession:_,onResumeSession:N,crew:S,lineage:C,sessionNames:E,activeSessionKey:T}=n,$=E===void 0?f0e:E,A=T===void 0?null:T,{isLive:R,isRunning:P,isNativeIdle:z,isDeferred:L,isReadOnly:I,isTeammate:M,isArchived:F,statusLabel:U,dotState:O,justFinished:D}=Rb(t,l,u),[B,q]=y.useState(!1);let W;e[0]!==d||e[1]!==t?(W=NN(t,d),e[0]=d,e[1]=t,e[2]=W):W=e[2];const H=W,K=w9(t,d),Z=o&&!C?s:void 0,Y=p0e(S==null?void 0:S.counts,O),X=S!==void 0&&Date.parse(S.activityAt)>jr(t),ee=t.lastUserMessage||t.firstUserMessage,te=!!ee&&ee!==H,se=m7(t.sessionId,t.turnCount);let J;e[3]!==t.archivedReason?(J=Ox(t.archivedReason),e[3]=t.archivedReason,e[4]=J):J=e[4];const ne=J,ie=F?j&&{label:"Restore from archive",icon:Cf,run:()=>j(t)}:v&&!P&&{label:"Archive session",icon:Ns,run:()=>v(t)},ae=L&&!!N&&!I,oe=!!m&&!!h,ue=!!t.matchedPullRequestNumber||!!((Lr=t.pullRequests)!=null&&Lr.length),re=ae||oe||ue;let de;e[5]!==i||e[6]!==_||e[7]!==t.dirName||e[8]!==t.fileName?(de=_&&!i?()=>_(t.dirName,t.fileName):void 0,e[5]=i,e[6]=_,e[7]=t.dirName,e[8]=t.fileName,e[9]=de):de=e[9];const{onHoverStart:fe,onHoverEnd:le}=rv(de);let ce;e[10]!==N||e[11]!==B||e[12]!==t.cwd||e[13]!==t.dirName||e[14]!==t.sessionId?(ce=()=>{!N||B||(q(!0),N(t.sessionId,t.cwd,t.dirName),setTimeout(()=>q(!1),3e3))},e[10]=N,e[11]=B,e[12]=t.cwd,e[13]=t.dirName,e[14]=t.sessionId,e[15]=ce):ce=e[15];const he=ce,ge=!0,be=F||void 0,ve=G("motion-list-item group relative flex flex-col rounded-lg border transition-colors",h0e(i,D),F&&"opacity-60 hover:opacity-100 focus-within:opacity-100");let Se;e[16]!==C?(Se=C&&a.jsxs("button",{type:"button","data-crew-lineage":!0,onClick:C.onOpenParent,"aria-label":`Open ${C.parentTitle}, which started this session`,className:"flex min-w-0 items-center gap-1.5 rounded-t-lg px-3 pl-[26px] pt-2.5 text-left text-[11px] leading-tight outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:[a.jsx(dx,{className:"size-3 shrink-0 text-muted-foreground","aria-hidden":"true"}),a.jsx("span",{className:"truncate text-foreground/90",children:C.parentTitle}),C.rootTitle&&a.jsxs("span",{className:"truncate text-muted-foreground",children:["· ",C.rootTitle]})]}),e[16]=C,e[17]=Se):Se=e[17];let we;e[18]!==g||e[19]!==t.dirName||e[20]!==t.fileName?(we=()=>g(t.dirName,t.fileName),e[18]=g,e[19]=t.dirName,e[20]=t.fileName,e[21]=we):we=e[21];const Ee=i?"true":void 0,$e=C?"pt-1":"pt-2.5",Be=re||S?"pb-1.5":"pb-2.5";let qe;e[22]!==$e||e[23]!==Be?(qe=G("flex w-full flex-col gap-1.5 rounded-lg px-3 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",$e,Be),e[22]=$e,e[23]=Be,e[24]=qe):qe=e[24];let ze;e[25]!==le||e[26]!==fe||e[27]!==we||e[28]!==Ee||e[29]!==qe?(ze=a.jsx("button",{type:"button","data-live-session":!0,onClick:we,onMouseEnter:fe,onMouseLeave:le,onFocus:fe,onBlur:le,"aria-current":Ee,className:qe}),e[25]=le,e[26]=fe,e[27]=we,e[28]=Ee,e[29]=qe,e[30]=ze):ze=e[30];let Ie;e[31]!==Z||e[32]!==r?(Ie=Z&&a.jsxs("span",{"data-session-project":!0,className:"flex items-center gap-1.5 pl-3.5 text-[11px] leading-tight text-muted-foreground",children:[a.jsx(ya,{projectPath:r,fallback:a.jsx(sa,{className:"size-3 shrink-0","aria-hidden":"true"}),className:"size-3"}),a.jsx("span",{className:"truncate",children:Z})]}),e[31]=Z,e[32]=r,e[33]=Ie):Ie=e[33];let Me;e[34]!==Y?(Me=Y&&a.jsx("span",{"data-status-dot":Y,className:G("size-1.5 rounded-full",Hs[Y])}),e[34]=Y,e[35]=Me):Me=e[35];let Ue;e[36]!==Me?(Ue=a.jsx("span",{className:"mt-[7px] flex w-1.5 shrink-0 justify-center","aria-hidden":"true",children:Me}),e[36]=Me,e[37]=Ue):Ue=e[37];const De=K?"text-muted-foreground":"font-medium text-foreground";let Ke;e[38]!==De?(Ke=G("line-clamp-2 flex-1 text-sm leading-snug",De),e[38]=De,e[39]=Ke):Ke=e[39];let Ne;e[40]!==H||e[41]!==Ke?(Ne=a.jsx("span",{className:Ke,children:H}),e[40]=H,e[41]=Ke,e[42]=Ne):Ne=e[42];let Ae;e[43]!==Ue||e[44]!==Ne?(Ae=a.jsxs("span",{className:"flex items-start gap-2",children:[Ue,Ne]}),e[43]=Ue,e[44]=Ne,e[45]=Ae):Ae=e[45];let Qe;e[46]!==ee||e[47]!==te?(Qe=te&&a.jsx("span",{className:"line-clamp-2 pl-3.5 text-xs leading-relaxed text-muted-foreground",children:ee}),e[46]=ee,e[47]=te,e[48]=Qe):Qe=e[48];let Je;e[49]!==L||e[50]!==R||e[51]!==z||e[52]!==t.agentStatus||e[53]!==U?(Je=R&&!L&&U&&a.jsx(Fe,{variant:"secondary","data-session-live-state":!0,className:G(z?"text-success":wm(t.agentStatus)),children:U}),e[49]=L,e[50]=R,e[51]=z,e[52]=t.agentStatus,e[53]=U,e[54]=Je):Je=e[54];let ke;e[55]!==L?(ke=L&&a.jsx(Fe,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"deferred"}),e[55]=L,e[56]=ke):ke=e[56];let We;e[57]!==H||e[58]!==M||e[59]!==t.agentName?(We=M&&a.jsxs(Fe,{variant:"outline",children:[a.jsx(mi,{"data-icon":"inline-start"}),H!==t.agentName?t.agentName:"Agent"]}),e[57]=H,e[58]=M,e[59]=t.agentName,e[60]=We):We=e[60];let ye;e[61]!==t.access?(ye=a.jsx(s7,{access:t.access}),e[61]=t.access,e[62]=ye):ye=e[62];let Re;e[63]!==f?(Re=f&&a.jsxs(Fe,{variant:"outline",children:[a.jsx(Gr,{"data-icon":"inline-start"}),f]}),e[63]=f,e[64]=Re):Re=e[64];let Ve;e[65]!==t.gitBranch||e[66]!==f?(Ve=t.gitBranch&&!f&&a.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[a.jsx(Gr,{className:"size-3 shrink-0","aria-hidden":"true"}),a.jsx("span",{className:"truncate",children:t.gitBranch})]}),e[65]=t.gitBranch,e[66]=f,e[67]=Ve):Ve=e[67];let He;e[68]!==se?(He=se>0&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(vc,{className:"size-3 shrink-0","aria-hidden":"true"}),se," ",se===1?"turn":"turns"]}),e[68]=se,e[69]=He):He=e[69];let me;e[70]!==ne||e[71]!==F?(me=F&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Ns,{className:"size-3 shrink-0","aria-label":ne,role:"img"}),"Archived"]}),e[70]=ne,e[71]=F,e[72]=me):me=e[72];let je;e[73]!==S||e[74]!==X||e[75]!==t?(je=X?a.jsxs("span",{"data-crew-activity":!0,className:G("ml-auto tabular-nums",CN({...t,lastActivityAt:S.activityAt})&&"text-success"),children:["crew active ",Cr(S.activityAt)]}):a.jsx("span",{className:"ml-auto tabular-nums",children:Cr(t.lastActivityAt||t.lastModified)}),e[73]=S,e[74]=X,e[75]=t,e[76]=je):je=e[76];let Xe;e[77]!==Je||e[78]!==ke||e[79]!==We||e[80]!==ye||e[81]!==Re||e[82]!==Ve||e[83]!==He||e[84]!==me||e[85]!==je?(Xe=a.jsxs("span",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 pl-3.5 text-[11px] text-muted-foreground",children:[Je,ke,We,ye,Re,Ve,He,me,je]}),e[77]=Je,e[78]=ke,e[79]=We,e[80]=ye,e[81]=Re,e[82]=Ve,e[83]=He,e[84]=me,e[85]=je,e[86]=Xe):Xe=e[86];let tt;e[87]!==ze||e[88]!==Ie||e[89]!==Ae||e[90]!==Qe||e[91]!==Xe?(tt=a.jsxs(Zt,{render:ze,children:[Ie,Ae,Qe,Xe]}),e[87]=ze,e[88]=Ie,e[89]=Ae,e[90]=Qe,e[91]=Xe,e[92]=tt):tt=e[92];const dt=Z?void 0:s;let zt;e[93]!==d||e[94]!==l||e[95]!==t||e[96]!==U||e[97]!==dt||e[98]!==f?(zt=a.jsx(Yt,{side:"right",className:"max-w-[320px]",children:a.jsx(sv,{session:t,proc:l,statusLabel:U,customName:d,worktreeName:f,projectLabel:dt})}),e[93]=d,e[94]=l,e[95]=t,e[96]=U,e[97]=dt,e[98]=f,e[99]=zt):zt=e[99];let st;e[100]!==tt||e[101]!==zt?(st=a.jsxs(Gt,{children:[tt,zt]}),e[100]=tt,e[101]=zt,e[102]=st):st=e[102];let Et;e[103]!==ae||e[104]!==he||e[105]!==re||e[106]!==oe||e[107]!==h||e[108]!==B||e[109]!==t.matchedPullRequestNumber||e[110]!==t.pullRequests||e[111]!==m||e[112]!==p?(Et=re&&a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 px-3 pb-2.5 pl-[26px]",children:[t.matchedPullRequestNumber?a.jsxs(Fe,{variant:"outline",className:"px-1",children:["Matched #",t.matchedPullRequestNumber]}):a.jsx(su,{pullRequests:t.pullRequests,max:2,compact:!0}),oe&&a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",onClick:h,"aria-expanded":!p,"aria-label":p?`Show ${m} team agents`:`Hide ${m} team agents`,children:[a.jsx(er,{"data-icon":"inline-start"}),m,a.jsx(it,{"data-icon":"inline-end",className:G("transition-transform duration-150",!p&&"rotate-90")})]}),ae&&a.jsxs(Q,{type:"button",variant:"outline",size:"xs",onClick:he,disabled:B,className:"text-warning",title:"Resume to evaluate deferred permission","aria-label":"Resume to evaluate",children:[a.jsx(Na,{"data-icon":"inline-start"}),"Resume"]})]}),e[103]=ae,e[104]=he,e[105]=re,e[106]=oe,e[107]=h,e[108]=B,e[109]=t.matchedPullRequestNumber,e[110]=t.pullRequests,e[111]=m,e[112]=p,e[113]=Et):Et=e[113];let Tt;e[114]!==A||e[115]!==S||e[116]!==g||e[117]!==t||e[118]!==$?(Tt=S&&a.jsx(l0e,{host:t,members:S.members,counts:S.counts,statusOf:S.statusOf,open:S.open,onToggle:S.onToggle,sessionNames:$,activeSessionKey:A,onSelectSession:g}),e[114]=A,e[115]=S,e[116]=g,e[117]=t,e[118]=$,e[119]=Tt):Tt=e[119];let Jt;e[120]!==ie||e[121]!==S?(Jt=ie&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:ie.run,className:G("absolute right-1.5 bg-popover text-muted-foreground opacity-0 group-focus-within:opacity-100 group-hover:opacity-100 hover:text-foreground",S?"top-1.5":"bottom-1.5"),title:ie.label,"aria-label":ie.label,children:a.jsx(ie.icon,{"data-icon":"inline-start"})}),e[120]=ie,e[121]=S,e[122]=Jt):Jt=e[122];let At;e[123]!==S||e[124]!==F||e[125]!==I||e[126]!==P||e[127]!==c||e[128]!==x||e[129]!==l?(At=l&&x&&P&&!F&&!I&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:Is=>x(l.pid,Is),disabled:c.has(l.pid),className:G("absolute right-1.5 bg-popover text-destructive opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",S?"top-1.5":"bottom-1.5"),title:`Kill PID ${l.pid}`,"aria-label":`Kill process ${l.pid}`,children:a.jsx(Mt,{"data-icon":"inline-start"})}),e[123]=S,e[124]=F,e[125]=I,e[126]=P,e[127]=c,e[128]=x,e[129]=l,e[130]=At):At=e[130];let Qn;e[131]!==Se||e[132]!==st||e[133]!==Et||e[134]!==Tt||e[135]!==Jt||e[136]!==At||e[137]!==be||e[138]!==ve?(Qn=a.jsxs("div",{"data-session-card":ge,"data-archived":be,className:ve,children:[Se,st,Et,Tt,Jt,At]}),e[131]=Se,e[132]=st,e[133]=Et,e[134]=Tt,e[135]=Jt,e[136]=At,e[137]=be,e[138]=ve,e[139]=Qn):Qn=e[139];const kn=Qn;if(b||w||k||v||j){let Is;e[140]!==t.firstUserMessage||e[141]!==t.sessionId||e[142]!==t.slug?(Is=t.slug||((_n=t.firstUserMessage)==null?void 0:_n.slice(0,30))||t.sessionId.slice(0,12),e[140]=t.firstUserMessage,e[141]=t.sessionId,e[142]=t.slug,e[143]=Is):Is=e[143];let Ps;e[144]!==b||e[145]!==t.dirName||e[146]!==t.fileName?(Ps=b?()=>b(t.dirName,t.fileName):void 0,e[144]=b,e[145]=t.dirName,e[146]=t.fileName,e[147]=Ps):Ps=e[147];let cr;e[148]!==w||e[149]!==t?(cr=w?()=>w(t):void 0,e[148]=w,e[149]=t,e[150]=cr):cr=e[150];let ur;e[151]!==k||e[152]!==t.sessionId?(ur=k?ki=>k(t.sessionId,ki):void 0,e[151]=k,e[152]=t.sessionId,e[153]=ur):ur=e[153];let us;e[154]!==F||e[155]!==v||e[156]!==t?(us=v&&!F?()=>v(t):void 0,e[154]=F,e[155]=v,e[156]=t,e[157]=us):us=e[157];let $s;e[158]!==F||e[159]!==j||e[160]!==t?($s=j&&F?()=>j(t):void 0,e[158]=F,e[159]=j,e[160]=t,e[161]=$s):$s=e[161];let Si;return e[162]!==kn||e[163]!==d||e[164]!==P||e[165]!==Is||e[166]!==Ps||e[167]!==cr||e[168]!==ur||e[169]!==us||e[170]!==$s?(Si=a.jsx(tv,{sessionLabel:Is,customName:d,onDuplicate:Ps,onDelete:cr,onRename:ur,onArchive:us,onUnarchive:$s,archiveDisabled:P,children:kn}),e[162]=kn,e[163]=d,e[164]=P,e[165]=Is,e[166]=Ps,e[167]=cr,e[168]=ur,e[169]=us,e[170]=$s,e[171]=Si):Si=e[171],Si}return kn}function p0e(n,e){return n?n.needsYou>0||e==="attention"?"attention":n.working>0?"working":e:e}function h0e(n,e){return n?"border-foreground/15 bg-accent":e?"border-success/30 bg-success/10":"border-border/70 bg-card hover:border-border hover:bg-accent"}function g0e(n){var le;const e=V.c(87),{session:t,isActiveSession:s,proc:r,killingPids:o,isNewlyCompleted:i,customName:l,worktreeName:c,teammateCount:u,teammatesCollapsed:d,onToggleTeammates:f,onSelectSession:m,onKill:p,onDuplicateSession:h,onDeleteSession:g,onArchiveSession:x,onUnarchiveSession:b,onRenameSession:w,onPrefetchSession:v,onResumeSession:j}=n,{isLive:k,isRunning:_,isNativeIdle:N,isDeferred:S,isReadOnly:C,isTeammate:E,isArchived:T,statusLabel:$,dotState:A,justFinished:R}=Rb(t,r,i),[P,z]=y.useState(!1);let L;e[0]!==t.archivedReason?(L=Ox(t.archivedReason),e[0]=t.archivedReason,e[1]=L):L=e[1];const I=L;let M;e[2]!==l||e[3]!==t?(M=pi(t,l),e[2]=l,e[3]=t,e[4]=M):M=e[4];const F=M,U=T?b&&{label:"Restore from archive",icon:Cf,run:()=>b(t)}:x&&!_&&{label:"Archive session",icon:Ns,run:()=>x(t)};let O;e[5]!==s||e[6]!==v||e[7]!==t.dirName||e[8]!==t.fileName?(O=v&&!s?()=>v(t.dirName,t.fileName):void 0,e[5]=s,e[6]=v,e[7]=t.dirName,e[8]=t.fileName,e[9]=O):O=e[9];const{onHoverStart:D,onHoverEnd:B}=rv(O);let q;e[10]!==j||e[11]!==P||e[12]!==t.cwd||e[13]!==t.dirName||e[14]!==t.sessionId?(q=ce=>{ce.stopPropagation(),!(!j||P)&&(z(!0),j(t.sessionId,t.cwd,t.dirName),setTimeout(()=>z(!1),3e3))},e[10]=j,e[11]=P,e[12]=t.cwd,e[13]=t.dirName,e[14]=t.sessionId,e[15]=q):q=e[15];const W=q,H=G("motion-list-item group relative flex min-h-9 w-full items-center gap-1.5 rounded-md px-2.5 py-2 transition-colors",x0e(s,R),T&&"opacity-60 hover:opacity-100 focus-within:opacity-100");let K;e[16]!==m||e[17]!==t.dirName||e[18]!==t.fileName?(K=()=>m(t.dirName,t.fileName),e[16]=m,e[17]=t.dirName,e[18]=t.fileName,e[19]=K):K=e[19];let Z;e[20]!==B||e[21]!==D||e[22]!==K?(Z=a.jsx("button",{type:"button","data-live-session":!0,onClick:K,onMouseEnter:D,onMouseLeave:B,onFocus:D,onBlur:B,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring"}),e[20]=B,e[21]=D,e[22]=K,e[23]=Z):Z=e[23];let Y;e[24]!==F?(Y=a.jsx("span",{className:"flex-1 truncate text-sm leading-tight text-foreground",children:F}),e[24]=F,e[25]=Y):Y=e[25];let X;e[26]!==S?(X=S&&a.jsx(Fe,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"deferred"}),e[26]=S,e[27]=X):X=e[27];let ee;e[28]!==c?(ee=c&&a.jsxs(Fe,{variant:"outline",children:[a.jsx(Gr,{"data-icon":"inline-start"}),c]}),e[28]=c,e[29]=ee):ee=e[29];let te;e[30]!==l||e[31]!==r||e[32]!==t||e[33]!==$||e[34]!==c?(te=a.jsx(Yt,{side:"right",className:"max-w-[280px]",children:a.jsx(sv,{session:t,proc:r,statusLabel:$,customName:l,worktreeName:c})}),e[30]=l,e[31]=r,e[32]=t,e[33]=$,e[34]=c,e[35]=te):te=e[35];let se;e[36]!==f||e[37]!==u||e[38]!==d?(se=!!u&&f&&a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",onClick:f,className:"shrink-0",title:d?"Show team agents":"Hide team agents","aria-label":d?`Show ${u} team agents`:`Hide ${u} team agents`,"aria-expanded":!d,children:[a.jsx(er,{"data-icon":"inline-start"}),u,a.jsx(it,{"data-icon":"inline-end",className:G("transition-transform duration-150",!d&&"rotate-90")})]}),e[36]=f,e[37]=u,e[38]=d,e[39]=se):se=e[39];let J;e[40]!==W||e[41]!==S||e[42]!==C||e[43]!==j||e[44]!==P?(J=S&&j&&!C&&a.jsxs(Q,{type:"button",variant:"outline",size:"xs",onClick:W,disabled:P,className:"shrink-0 text-warning",title:"Resume to evaluate deferred permission","aria-label":"Resume to evaluate",children:[a.jsx(Na,{"data-icon":"inline-start"}),"Resume"]}),e[40]=W,e[41]=S,e[42]=C,e[43]=j,e[44]=P,e[45]=J):J=e[45];let ne;e[46]!==t.matchedPullRequestNumber||e[47]!==t.pullRequests?(ne=t.matchedPullRequestNumber?a.jsxs(Fe,{variant:"outline",className:"shrink-0 px-1",children:["Matched #",t.matchedPullRequestNumber]}):a.jsx(su,{pullRequests:t.pullRequests,max:1,compact:!0}),e[46]=t.matchedPullRequestNumber,e[47]=t.pullRequests,e[48]=ne):ne=e[48];let ie;e[49]!==I||e[50]!==T?(ie=T&&a.jsx(Ns,{className:"size-3 shrink-0 text-muted-foreground","aria-label":I,role:"img"}),e[49]=I,e[50]=T,e[51]=ie):ie=e[51];const ae=t.lastActivityAt||t.lastModified;let oe;e[52]!==ae?(oe=Cr(ae),e[52]=ae,e[53]=oe):oe=e[53];let ue;e[54]!==oe?(ue=a.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:oe}),e[54]=oe,e[55]=ue):ue=e[55];let re;e[56]!==U?(re=U&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:ce=>{ce.stopPropagation(),U.run()},className:"absolute right-0 top-0 bg-popover text-muted-foreground opacity-0 group-focus-within:opacity-100 group-hover:opacity-100 hover:text-foreground",title:U.label,"aria-label":U.label,children:a.jsx(U.icon,{"data-icon":"inline-start"})}),e[56]=U,e[57]=re):re=e[57];let de;e[58]!==T||e[59]!==C||e[60]!==_||e[61]!==o||e[62]!==p||e[63]!==r?(de=r&&p&&_&&!T&&!C&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:ce=>p(r.pid,ce),disabled:o.has(r.pid),className:"absolute right-0 top-0 text-destructive opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",title:`Kill PID ${r.pid}`,"aria-label":`Kill process ${r.pid}`,children:a.jsx(Mt,{"data-icon":"inline-start"})}),e[58]=T,e[59]=C,e[60]=_,e[61]=o,e[62]=p,e[63]=r,e[64]=de):de=e[64];const fe=a.jsxs("div",{className:H,"data-archived":T||void 0,children:[a.jsxs(Gt,{children:[a.jsxs(Zt,{render:Z,children:[a.jsx("span",{className:"flex w-1.5 shrink-0 items-center justify-center","aria-hidden":"true",children:A&&a.jsx("span",{"data-status-dot":A,className:G("size-1.5 rounded-full",Hs[A])})}),Y,E&&a.jsxs(Fe,{variant:"outline",children:[a.jsx(mi,{"data-icon":"inline-start"}),F!==t.agentName?t.agentName:"Agent"]}),k&&!S&&$&&a.jsx(Fe,{variant:"secondary","data-session-live-state":!0,className:G("shrink-0",N&&"text-success",!N&&wm(t.agentStatus)),children:$}),X,ee]}),te]}),se,J,ne,ie,ue,re,de]});if(h||g||w||x||b){let ce;e[65]!==t.firstUserMessage||e[66]!==t.sessionId||e[67]!==t.slug?(ce=t.slug||((le=t.firstUserMessage)==null?void 0:le.slice(0,30))||t.sessionId.slice(0,12),e[65]=t.firstUserMessage,e[66]=t.sessionId,e[67]=t.slug,e[68]=ce):ce=e[68];let he;e[69]!==h||e[70]!==t.dirName||e[71]!==t.fileName?(he=h?()=>h(t.dirName,t.fileName):void 0,e[69]=h,e[70]=t.dirName,e[71]=t.fileName,e[72]=he):he=e[72];let ge;e[73]!==g||e[74]!==t?(ge=g?()=>g(t):void 0,e[73]=g,e[74]=t,e[75]=ge):ge=e[75];let be;e[76]!==w||e[77]!==t.sessionId?(be=w?we=>w(t.sessionId,we):void 0,e[76]=w,e[77]=t.sessionId,e[78]=be):be=e[78];let ve;e[79]!==T||e[80]!==x||e[81]!==t?(ve=x&&!T?()=>x(t):void 0,e[79]=T,e[80]=x,e[81]=t,e[82]=ve):ve=e[82];let Se;return e[83]!==T||e[84]!==b||e[85]!==t?(Se=b&&T?()=>b(t):void 0,e[83]=T,e[84]=b,e[85]=t,e[86]=Se):Se=e[86],a.jsx(tv,{sessionLabel:ce,customName:l,onDuplicate:he,onDelete:ge,onRename:be,onArchive:ve,onUnarchive:Se,archiveDisabled:_,children:fe})}return fe}function x0e(n,e){return n?"bg-accent":e?"bg-success/10":"hover:bg-accent/60"}const b0e={state:"done"};function v0e(n){const e=V.c(84),{sessions:t,pendingSession:s,older:r,showProject:o,groupCrews:i,lineageSessions:l,memberStatusOf:c,activeSessionKey:u,procBySession:d,killingPids:f,newlyCompleted:m,sessionNames:p,projectNames:h,onSelectSession:g,onKill:x,onDuplicateSession:b,onDeleteSession:w,onArchiveSession:v,onUnarchiveSession:j,onRenameSession:k,onPrefetchSession:_,onResumeSession:N}=n,S=i===void 0?!0:i,C=c===void 0?w0e:c,E=Pm();let T,$,A,R;if(e[0]!==S||e[1]!==t){T=S?zx(t):{topLevel:t,crewOf:new Map},$=S9(T.topLevel);const le=be=>{const ve=T.crewOf.get(be.sessionId);return ve?Ly(be,ve):be.lastActivityAt||be.lastModified},ce=new Map($.topLevelSessions.map(be=>[{...be,lastActivityAt:le(be)},be]));R=Aa([...ce.keys()]).map(be=>ce.get(be));const he=Date.now(),ge=R.map(be=>o0e(le(be),he));A=ge.map((be,ve)=>be===ge[ve-1]?null:be),e[0]=S,e[1]=t,e[2]=T,e[3]=$,e[4]=A,e[5]=R}else T=e[2],$=e[3],A=e[4],R=e[5];const P=A;let z;e[6]!==T.crewOf||e[7]!==P||e[8]!==$.teammatesByLead||e[9]!==R?(z={topLevelSessions:R,teammatesByLead:$.teammatesByLead,crewOf:T.crewOf,shelves:P},e[6]=T.crewOf,e[7]=P,e[8]=$.teammatesByLead,e[9]=R,e[10]=z):z=e[10];const{topLevelSessions:L,teammatesByLead:I,crewOf:M,shelves:F}=z;let U,O;e[11]===Symbol.for("react.memo_cache_sentinel")?(U=sn("live-sessions-open-crews"),O=[],e[11]=U,e[12]=O):(U=e[11],O=e[12]);const[D,B]=kr(U,O);let q;e[13]!==D?(q=Array.isArray(D)?D:[],e[13]=D,e[14]=q):q=e[14];let W;e[15]!==q?(W=new Set(q),e[15]=q,e[16]=W):W=e[16];const H=W;let K;e[17]!==D||e[18]!==B?(K=le=>{const ce=Array.isArray(D)?D:[];B(ce.includes(le)?ce.filter(he=>he!==le):[...ce,le])},e[17]=D,e[18]=B,e[19]=K):K=e[19];const Z=K;let Y;e[20]!==l?(Y=l??[],e[20]=l,e[21]=Y):Y=e[21];let X;e[22]!==t||e[23]!==Y?(X=new Map([...Y,...t].map(y0e)),e[22]=t,e[23]=Y,e[24]=X):X=e[24];const ee=X;let te;e[25]===Symbol.for("react.memo_cache_sentinel")?(te=new Set,e[25]=te):te=e[25];const[se,J]=y.useState(te);let ne;e[26]===Symbol.for("react.memo_cache_sentinel")?(ne=le=>{J(ce=>{const he=new Set(ce);return he.has(le)?he.delete(le):he.add(le),he})},e[26]=ne):ne=e[26];const ie=ne;let ae;e[27]!==u||e[28]!==f||e[29]!==m||e[30]!==v||e[31]!==w||e[32]!==b||e[33]!==x||e[34]!==_||e[35]!==k||e[36]!==N||e[37]!==g||e[38]!==j||e[39]!==E||e[40]!==d||e[41]!==p?(ae=le=>{const ce=E(le.access);return{session:le,isActiveSession:u===cg(le),proc:d.get(le.sessionId),killingPids:f,isNewlyCompleted:m.has(le.sessionId),customName:p[le.sessionId],onSelectSession:g,onKill:ce.stop?x:void 0,onDuplicateSession:b,onDeleteSession:ce.delete?w:void 0,onArchiveSession:ce.archive?v:void 0,onUnarchiveSession:ce.archive?j:void 0,onRenameSession:k,onPrefetchSession:_,onResumeSession:ce.send?N:void 0}},e[27]=u,e[28]=f,e[29]=m,e[30]=v,e[31]=w,e[32]=b,e[33]=x,e[34]=_,e[35]=k,e[36]=N,e[37]=g,e[38]=j,e[39]=E,e[40]=d,e[41]=p,e[42]=ae):ae=e[42];const oe=ae;let ue;e[43]!==s?(ue=s&&a.jsx(j0e,{firstMessage:s.firstMessage}),e[43]=s,e[44]=ue):ue=e[44];let re;if(e[45]!==u||e[46]!==se||e[47]!==M||e[48]!==ee||e[49]!==C||e[50]!==g||e[51]!==H||e[52]!==h||e[53]!==oe||e[54]!==p||e[55]!==F||e[56]!==o||e[57]!==I||e[58]!==Z||e[59]!==L){let le;e[61]!==u||e[62]!==se||e[63]!==M||e[64]!==ee||e[65]!==C||e[66]!==g||e[67]!==H||e[68]!==h||e[69]!==oe||e[70]!==p||e[71]!==F||e[72]!==o||e[73]!==I||e[74]!==Z?(le=(ce,he)=>{const ge=cg(ce),be=ce.cwd??xs(ce.dirName),ve=Nr(be),Se=h[ce.dirName]??Nl(ce),we=I.get(ce.sessionId),Ee=se.has(ce.sessionId),$e=F[he],Be=M.get(ce.sessionId),qe=Be&&{members:Be,counts:Dx(Be,C),statusOf:C,activityAt:Ly(ce,Be),open:H.has(ce.sessionId),onToggle:()=>Z(ce.sessionId)},ze=a.jsx(m0e,{...oe(ce),worktreeName:ve==null?void 0:ve.worktreeName,projectLabel:Se,projectPath:(ve==null?void 0:ve.parentPath)??be,showProject:o,teammateCount:we==null?void 0:we.length,teammatesCollapsed:we?Ee:void 0,onToggleTeammates:we?()=>ie(ce.sessionId):void 0,crew:qe,lineage:S0e(ce,ee,p,g),sessionNames:p,activeSessionKey:u});return a.jsxs(y.Fragment,{children:[$e&&a.jsx(k0e,{label:$e}),we&&!Ee?a.jsxs("div",{className:"flex flex-col gap-px",children:[ze,a.jsx("div",{className:"ml-3 flex flex-col gap-px border-l pl-1",children:we.map(Ie=>a.jsx(g0e,{...oe(Ie)},cg(Ie)))})]}):ze]},ge)},e[61]=u,e[62]=se,e[63]=M,e[64]=ee,e[65]=C,e[66]=g,e[67]=H,e[68]=h,e[69]=oe,e[70]=p,e[71]=F,e[72]=o,e[73]=I,e[74]=Z,e[75]=le):le=e[75],re=L.map(le),e[45]=u,e[46]=se,e[47]=M,e[48]=ee,e[49]=C,e[50]=g,e[51]=H,e[52]=h,e[53]=oe,e[54]=p,e[55]=F,e[56]=o,e[57]=I,e[58]=Z,e[59]=L,e[60]=re}else re=e[60];let de;e[76]!==r.canLoad||e[77]!==r.load||e[78]!==r.loading?(de=r.canLoad&&a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",onClick:r.load,disabled:r.loading,className:"justify-start text-muted-foreground",children:[r.loading?a.jsx(St,{"data-icon":"inline-start",className:"animate-spin"}):a.jsx(L4,{"data-icon":"inline-start"}),"Load older sessions"]}),e[76]=r.canLoad,e[77]=r.load,e[78]=r.loading,e[79]=de):de=e[79];let fe;return e[80]!==ue||e[81]!==re||e[82]!==de?(fe=a.jsxs("div",{className:"flex flex-col gap-1.5","data-session-card-list":!0,children:[ue,re,de]}),e[80]=ue,e[81]=re,e[82]=de,e[83]=fe):fe=e[83],fe}function y0e(n){return[n.sessionId,n]}function w0e(){return b0e}function S0e(n,e,t,s){const r=n.crew;if(!r)return;const o=$d(r.parentId,e,t)??r.parentTitle??"Another session",i=r.rootId===r.parentId?void 0:$d(r.rootId,e,t)??r.rootTitle,l=e.get(r.parentId);return{parentTitle:o,...i&&i!==o&&{rootTitle:i},onOpenParent:l?()=>s(l.dirName,l.fileName):()=>void cm(r.parentId)}}function k0e(n){const e=V.c(2),{label:t}=n;let s;return e[0]!==t?(s=a.jsx("div",{"data-recency-divider":!0,className:"px-1 pb-0.5 pt-2 text-[11px] font-medium text-muted-foreground/80 first:pt-0",children:t}),e[0]=t,e[1]=s):s=e[1],s}function j0e(n){const e=V.c(3),{firstMessage:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(St,{className:"size-3 shrink-0 animate-spin text-info"}),e[0]=s):s=e[0];const r=t||"New session";let o;return e[1]!==r?(o=a.jsxs("div",{className:"motion-enter relative flex w-full items-center gap-1.5 rounded-lg border border-border/70 bg-accent px-3 py-2.5 text-left",children:[s,a.jsx("span",{className:"flex-1 truncate text-sm leading-tight text-foreground",children:r})]}),e[1]=r,e[2]=o):o=e[2],o}function cg(n){return`${n.dirName}/${n.fileName}`}function yo(n,e){return`${n} ${n===1?e:`${e}s`}`}function N0e(n){if(!n)return"No sessions listed";const e=yo(n.total,"session"),t=n.live>0?`${e}, ${n.live} live`:e,s=[n.crews>0&&yo(n.crews,"crew"),n.worktrees>0&&yo(n.worktrees,"worktree")].filter(Boolean);return[t,...s].join(" · ")}function Oj(n){const e=V.c(7),{count:t,label:s,className:r}=n;let o;e[0]!==r?(o=G("flex shrink-0 items-center gap-1 font-medium text-warning",r),e[0]=r,e[1]=o):o=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx("span",{className:"size-1.5 rounded-full bg-warning","aria-hidden":"true"}),e[2]=i):i=e[2];let l;return e[3]!==t||e[4]!==s||e[5]!==o?(l=a.jsxs("span",{className:o,"aria-label":s,children:[i,t]}),e[3]=t,e[4]=s,e[5]=o,e[6]=l):l=e[6],l}function C0e(n,e){return e===null?0:n.reduce((t,s)=>s.key===e?t:t+s.needsYou,0)}function _0e(n){const e=V.c(72),{options:t,value:s,focused:r,totalSessions:o,crewCount:i,onChange:l,onNewSession:c,creatingSession:u,onRenameProject:d,archivableCount:f,onArchiveIdle:m}=n,p=i===void 0?0:i,[h,g]=y.useState(!1),x=(r==null?void 0:r.customName)??s;let b;e[0]!==p||e[1]!==r||e[2]!==t.length||e[3]!==o||e[4]!==s?(b=s===null?`${yo(t.length,"project")}, ${yo(o,"session")}${p>0?` · ${yo(p,"crew")}`:""}`:N0e(r),e[0]=p,e[1]=r,e[2]=t.length,e[3]=o,e[4]=s,e[5]=b):b=e[5];const w=b,v=C0e(t,s);let j;e[6]!==l?(j=ee=>{l(ee),g(!1)},e[6]=l,e[7]=j):j=e[7];const k=j,_=s===null?"Choose a project to focus on":`Focused on ${x}. Change project`;let N;e[8]!==(r==null?void 0:r.cwd)||e[9]!==s?(N=s===null?a.jsx(jd,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):a.jsx(ya,{projectPath:(r==null?void 0:r.cwd)??null,fallback:a.jsx(sa,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),className:"size-5"}),e[8]=r==null?void 0:r.cwd,e[9]=s,e[10]=N):N=e[10];const S=s===null?"All projects":x;let C;e[11]!==S?(C=a.jsx("span",{className:"truncate text-sm font-medium leading-tight text-foreground",children:S}),e[11]=S,e[12]=C):C=e[12];let E;e[13]!==w?(E=a.jsx("span",{className:"truncate text-[11px] leading-tight text-muted-foreground",children:w}),e[13]=w,e[14]=E):E=e[14];let T;e[15]!==C||e[16]!==E?(T=a.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[C,E]}),e[15]=C,e[16]=E,e[17]=T):T=e[17];let $;e[18]!==v?($=v>0&&a.jsx(Oj,{count:v,label:v===1?"1 session in another project is waiting for you":`${v} sessions in other projects are waiting for you`,className:"rounded-full border border-warning/30 bg-warning/10 px-1.5 py-0.5 text-[11px]"}),e[18]=v,e[19]=$):$=e[19];let A;e[20]===Symbol.for("react.memo_cache_sentinel")?(A=a.jsx(_a,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[20]=A):A=e[20];let R;e[21]!==$||e[22]!==_||e[23]!==N||e[24]!==T?(R=a.jsxs(Tc,{"aria-label":_,className:"flex h-11 min-w-0 flex-1 items-center gap-2.5 rounded-lg px-2 text-left outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring data-popup-open:bg-accent",children:[N,T,$,A]}),e[21]=$,e[22]=_,e[23]=N,e[24]=T,e[25]=R):R=e[25];const P=R;let z;e[26]!==f||e[27]!==r||e[28]!==m||e[29]!==d||e[30]!==P?(z=r&&d?a.jsx(l7,{projectLabel:r.key,customName:r.customName,className:"flex min-w-0 flex-1",archivableCount:f,onArchiveIdle:m,onRename:ee=>d(r.dirName,ee),children:P}):P,e[26]=f,e[27]=r,e[28]=m,e[29]=d,e[30]=P,e[31]=z):z=e[31];let L;e[32]===Symbol.for("react.memo_cache_sentinel")?(L=a.jsx(o0,{placeholder:"Find a project",autoFocus:!0}),e[32]=L):L=e[32];let I;e[33]===Symbol.for("react.memo_cache_sentinel")?(I=a.jsx(Nz,{children:"No project matches."}),e[33]=I):I=e[33];const M=s===null;let F;e[34]!==k?(F=()=>k(null),e[34]=k,e[35]=F):F=e[35];let U,O;e[36]===Symbol.for("react.memo_cache_sentinel")?(U=a.jsx(jd,{className:"text-muted-foreground","aria-hidden":"true"}),O=a.jsx("span",{className:"flex-1 truncate",children:"All projects"}),e[36]=U,e[37]=O):(U=e[36],O=e[37]);let D;e[38]!==o?(D=a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:o}),e[38]=o,e[39]=D):D=e[39];let B;e[40]!==M||e[41]!==F||e[42]!==D?(B=a.jsx(xi,{children:a.jsxs(Eo,{value:"all-projects","data-checked":M,onSelect:F,className:"gap-2.5",children:[U,O,D]})}),e[40]=M,e[41]=F,e[42]=D,e[43]=B):B=e[43];let q;if(e[44]!==t||e[45]!==k||e[46]!==s){let ee;e[48]!==k||e[49]!==s?(ee=te=>a.jsxs(Eo,{value:te.key,keywords:te.customName?[te.customName]:void 0,"data-checked":s===te.key,onSelect:()=>k(te.key),className:"gap-2.5",children:[a.jsx(ya,{projectPath:te.cwd??null,fallback:a.jsx(sa,{className:"text-muted-foreground","aria-hidden":"true"}),className:"size-4"}),a.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[a.jsx("span",{className:"truncate",children:te.customName??te.key}),te.customName&&a.jsx("span",{className:"truncate text-[11px] text-muted-foreground",children:te.key})]}),te.needsYou>0&&a.jsx(Oj,{count:te.needsYou,label:`${yo(te.needsYou,"session")} waiting for you`,className:"text-xs"}),te.live>0&&a.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs font-medium text-success","aria-label":yo(te.live,"live session"),children:[a.jsx(Sm,{className:"size-1.5","aria-hidden":"true"}),te.live]}),a.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:te.total})]},te.key),e[48]=k,e[49]=s,e[50]=ee):ee=e[50],q=t.map(ee),e[44]=t,e[45]=k,e[46]=s,e[47]=q}else q=e[47];let W;e[51]!==q?(W=a.jsx(xi,{heading:"Projects",children:q}),e[51]=q,e[52]=W):W=e[52];let H;e[53]!==B||e[54]!==W?(H=a.jsx(Zx,{className:"w-(--anchor-width) min-w-72 p-0",children:a.jsxs(Ic,{children:[L,a.jsxs(Pc,{children:[I,B,W]})]})}),e[53]=B,e[54]=W,e[55]=H):H=e[55];let K;e[56]!==h||e[57]!==z||e[58]!==H?(K=a.jsxs(Ec,{open:h,onOpenChange:g,children:[z,H]}),e[56]=h,e[57]=z,e[58]=H,e[59]=K):K=e[59];let Z;e[60]!==u||e[61]!==r||e[62]!==x||e[63]!==c?(Z=r&&c&&a.jsx(Q,{type:"button",variant:"outline",size:"icon-sm",className:"shrink-0",disabled:u,onClick:()=>c(r.dirName,r.cwd),"aria-label":`New session in ${x}`,children:u?a.jsx(St,{"data-icon":"inline-start",className:"animate-spin"}):a.jsx(Sr,{"data-icon":"inline-start"})}),e[60]=u,e[61]=r,e[62]=x,e[63]=c,e[64]=Z):Z=e[64];let Y;e[65]!==u||e[66]!==c?(Y=c&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",className:"shrink-0",disabled:u,onClick:E0e,"aria-label":"Start a session in a folder",title:"Start a session in a folder",children:a.jsx(wc,{"data-icon":"inline-start"})}),e[65]=u,e[66]=c,e[67]=Y):Y=e[67];let X;return e[68]!==K||e[69]!==Z||e[70]!==Y?(X=a.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b px-2 py-1.5",children:[K,Z,Y]}),e[68]=K,e[69]=Z,e[70]=Y,e[71]=X):X=e[71],X}function E0e(){return EI()}function T0e(n,e){return n.reduce((t,s)=>s.isActive?t+1:e.has(s.sessionId)?s.agentStatus==="completed"?t:t+1:t,0)}function A0e(n){const e=Nr(n.cwd??xs(n.dirName));if(!e)return{dirName:n.dirName,cwd:n.cwd};const{parentPath:t}=e;return{dirName:vs(n.dirName).dirName.encode(t),cwd:t}}function I0e(n){const e=n.map(t=>{var s;return(s=Nr(t.cwd??xs(t.dirName)))==null?void 0:s.worktreeName});return new Set(e.filter(Boolean)).size}function P0e(n,e,t,s,r=new Map){return[...C9(n).entries()].map(([o,i])=>{const l=k9(i),c=A0e(l);return{key:o,customName:t[c.dirName],...c,dirNames:[...new Set(i.map(u=>u.dirName))],total:i.length,live:T0e(i,e),needsYou:i.filter(u=>s.has(u.sessionId)).length,worktrees:I0e(i),crews:i.filter(u=>r.has(u.sessionId)).length}})}function Lj(n,e,t=!1){if(e===null)return n;if(!t)return n.filter(i=>Nl(i)===e);const{topLevel:s,crewOf:r}=zx(n),o=new Set;for(const i of s)if(Nl(i)===e){o.add(i);for(const l of r.get(i.sessionId)??[])o.add(l)}for(const i of r.values())for(const l of i)Nl(l)===e&&o.add(l);return n.filter(i=>o.has(i))}function $0e(n,e){if(e.length===0)return n;const t=new Set(n.map(r=>r.sessionId)),s=e.filter(r=>!t.has(r.sessionId));return s.length===0?n:Aa([...n,...s])}const Mj={key:null,sessions:[],loading:!1,loaded:!1};function R0e(n,e){const t=n.dirNames?n.dirNames.map(s=>new URLSearchParams({project:s,limit:"200"})):[new URLSearchParams({limit:"200",perProject:"100"})];if(e)for(const s of t)s.set("archived","include");return t}function O0e(n,e,t){const s=V.c(14),r=n?`${e?"a":"l"}:${t.key??""}:${n.key}`:null,[o,i]=y.useState(Mj),l=o.key===r?o:Mj;let c;s[0]!==t||s[1]!==e||s[2]!==r||s[3]!==n?(c=async()=>{if(r===null||!n)return;i(g=>g.key===r?{...g,loading:!0}:{key:r,sessions:[],loading:!0,loaded:!1});const h=Xr();try{const x=(await Promise.all(R0e(n,e).map(async b=>{const w=await Ce(zf(b,t));if(!w.ok)throw new Error(`Could not load older sessions (${w.status})`);const v=await w.json();return Array.isArray(v)?v:[]}))).flat();aa(x,h),i(b=>b.key===r?{key:r,sessions:x,loading:!1,loaded:!0}:b)}catch(g){const x=g;i(b=>b.key===r?{...b,loading:!1}:b),Kn.error(x instanceof Error?x.message:"Could not load older sessions")}},s[0]=t,s[1]=e,s[2]=r,s[3]=n,s[4]=c):c=s[4];const u=c,{loaded:d}=l;let f,m;s[5]!==u||s[6]!==d?(f=()=>{if(d)return Df(()=>void u())},m=[d,u],s[5]=u,s[6]=d,s[7]=f,s[8]=m):(f=s[7],m=s[8]),y.useEffect(f,m);let p;return s[9]!==l.loading||s[10]!==l.sessions||s[11]!==u||s[12]!==d?(p={sessions:l.sessions,loading:l.loading,loaded:d,load:u},s[9]=l.loading,s[10]=l.sessions,s[11]=u,s[12]=d,s[13]=p):p=s[13],p}const L0e={key:"all"},M0e=y.memo(function({activeSessionKey:e,onSelectSession:t,onDuplicateSession:s,onDeleteSession:r,onNewSession:o,creatingSession:i,pendingSession:l,refreshRef:c,onPrefetchSession:u}){const{names:d,rename:f}=Ff(),{names:m,rename:p}=ev(),h=tb(),g=Nn("terminal"),x=Nn("killAny"),b=Pm(),w=Mf(),{Control:v,Empty:j}=$r().sessionListFilter??{},{sessions:k,procBySession:_,newlyCompleted:N,loading:S,error:C,refresh:E,removeSession:T,acknowledgeCompleted:$,showArchived:A,setShowArchived:R,setSearchActive:P,archivedCount:z}=Vx(),{awaitingPermission:L,awaitingQuestion:I,awaitingElicitation:M,awaitingDialog:F,awaitingPlan:U}=xpe(),O=y.useMemo(()=>new Set([...M,...F]),[M,F]),[D,B]=y.useState(new Set),[q,W]=y.useState(""),[H,K]=kr(sn("live-sessions-project-scope"),null),[Z,Y]=kr(sn("live-sessions-group-crews"),!0),X=Z!==!1,ee=!!q.trim(),te=X&&!ee,se=A||ee;y.useEffect(()=>(P(ee),()=>P(!1)),[ee,P]);const J=y.useRef(new Set),ne=y.useRef(!1),ie=y.useCallback((ye,Re)=>{if(!ne.current)return;const Ve=setTimeout(()=>{J.current.delete(Ve),ne.current&&ye()},Re);J.current.add(Ve)},[]);y.useEffect(()=>{const ye=J.current;return ne.current=!0,()=>{ne.current=!1;for(const Re of ye)clearTimeout(Re);ye.clear()}},[]),y.useEffect(()=>{if(c)return c.current=E,()=>{c.current===E&&(c.current=null)}},[E,c]);const ae=nv(),oe=c7(q,w),ue=y.useMemo(()=>N9(k,se),[k,se]),re=se?0:z,de=y.useMemo(()=>({awaitingPermission:L,awaitingQuestion:I,awaitingPrompt:O,awaitingPlan:U}),[L,I,O,U]),fe=y.useCallback(ye=>_N(ye,_,de),[_,de]),le=y.useMemo(()=>zx(ue),[ue]),ce=y.useMemo(()=>{const ye=Ve=>b(Ve.access).canInteract,Re=Mxe(le.topLevel,_,N,L,I,O,U,ye);return zxe(Re,le.topLevel,le.crewOf,fe,ye)},[le,_,N,L,I,O,U,b,fe]),he=y.useMemo(()=>new Set(ce.needsYou.map(ye=>ye.session.sessionId)),[ce]),ge=X?le.topLevel:ue,be=y.useMemo(()=>P0e(ge,_,m,he,le.crewOf),[ge,_,m,he,le.crewOf]),ve=H===null?null:be.find(ye=>ye.key===H)??null,Se=(ve==null?void 0:ve.customName)??H,we=O0e(H===null?L0e:ve,se,w),Ee=y.useMemo(()=>$0e(Lj(ue,H,te),we.sessions),[ue,H,te,we.sessions]),$e=y.useMemo(()=>ee?Ee.filter(ye=>{const Re=d[ye.sessionId],Ve=m[ye.dirName];return o7(ye,q,[Re,Ve])}):Ee,[Ee,ee,q,d,m]),Be=y.useMemo(()=>oe.results?Lj(oe.results,H,te):$e,[oe.results,H,te,$e]),qe=ce.needsYou.length>0||ce.working.length>0,ze=!ee&&qe&&H===null,Ie=y.useMemo(()=>H===null?[]:Ee.filter(ye=>!ye.archived&&b(ye.access).archive&&!Lx(ye,_.get(ye.sessionId))),[H,Ee,_,b]),Me=H===null||l!=null&&Rx(l.cwd||xs(l.dirName))===H,Ue=y.useRef(!1);y.useEffect(()=>{if(Ue.current||!u||k.length===0)return;Ue.current=!0;const ye=Aa(k).slice(0,3),Re=globalThis,Ve=()=>{for(const je of ye)u(je.dirName,je.fileName)};let He=null,me=null;return typeof Re.requestIdleCallback=="function"?He=Re.requestIdleCallback(Ve,{timeout:1500}):me=setTimeout(Ve,300),()=>{He!=null&&typeof Re.cancelIdleCallback=="function"&&Re.cancelIdleCallback(He),me!=null&&clearTimeout(me)}},[k,u]);const De=y.useCallback(async(ye,Re)=>{Re.stopPropagation(),B(Ve=>new Set(Ve).add(ye));try{if(!(await Ce("/api/kill-process",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pid:ye})})).ok)throw new Error("Could not stop session");ie(E,1500)}catch{Kn.error("Could not stop session")}ie(()=>{B(Ve=>{const He=new Set(Ve);return He.delete(ye),He})},2e3)},[E,ie]);y.useEffect(()=>{const ye=k.find(Re=>`${Re.dirName}/${Re.fileName}`===e);ye&&N.has(ye.sessionId)&&$(ye.sessionId)},[e,k,N,$]);const Ke=y.useCallback(async ye=>{await(r==null?void 0:r(ye.dirName,ye.fileName))&&T(ye.sessionId)},[r,T]),Ne=zI(),Ae=y.useCallback(ye=>{Ne([ye.sessionId],!0,`Archived “${pi(ye,d[ye.sessionId])}”`)},[Ne,d]),Qe=y.useCallback(ye=>{Ne([ye.sessionId],!1,`Restored “${pi(ye,d[ye.sessionId])}”`)},[Ne,d]),Je=y.useCallback(ye=>{if(ye.length===0)return;const Re=ye.map(Ve=>Ve.sessionId);Ne(Re,!0,`Archived ${Re.length} ${Re.length===1?"session":"sessions"}`)},[Ne]),ke=y.useCallback((ye,Re,Ve)=>{const{command:He,args:me}=lR(un(Ve),ye),je=`resume_${crypto.randomUUID().slice(0,8)}`;h.send({type:"spawn",id:je,name:`Resume ${ye.slice(0,8)}`,command:He,args:me,cwd:Re??void 0,metadata:{type:"terminal"}}),ie(E,3e3)},[h,E,ie]),We={activeSessionKey:e,procBySession:_,killingPids:D,newlyCompleted:N,sessionNames:d,projectNames:m,onSelectSession:t,onKill:x?De:void 0,onDuplicateSession:s,onDeleteSession:r?Ke:void 0,onArchiveSession:Ae,onUnarchiveSession:Qe,onRenameSession:f,onPrefetchSession:u,onResumeSession:g?ke:void 0};return a.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[a.jsx(Jxe,{loading:S,isMobile:ae,searchQuery:q,searchLoading:oe.loading,showArchived:A,archivedCount:z,groupCrews:X,onToggleGroupCrews:()=>Y(!X),onSearchQueryChange:W,onToggleShowArchived:()=>R(!A),onRefresh:()=>{Oxe(),E()}}),v&&a.jsx(v,{}),a.jsx(_0e,{options:be,value:H,focused:ve,totalSessions:ge.length,crewCount:X?le.crewOf.size:0,onChange:K,onNewSession:o,creatingSession:i,onRenameProject:p,archivableCount:Ie.length,onArchiveIdle:()=>Je(Ie)}),a.jsx(Vc,{className:"flex-1",children:a.jsxs("div",{className:"flex flex-col gap-4 p-2",children:[a.jsx(e0e,{fetchError:oe.error??C,showEmpty:Be.length===0&&!(l&&Me)&&!S&&!oe.loading&&!C&&!oe.error,searching:ee,loading:S||oe.loading,sessionCount:oe.active?Be.length:ue.length,hiddenArchivedCount:re,focusedProject:Se,onShowAllProjects:()=>K(null),filterEmpty:w.key!==null&&j?a.jsx(j,{className:"min-h-56 px-4 py-8"}):null,onShowArchived:()=>R(!0),onRetry:oe.error?oe.refresh:E}),ze&&a.jsx(Xxe,{groups:ce,activeSessionKey:e,procBySession:_,killingPids:D,sessionNames:d,projectNames:m,onSelectSession:t,onKill:x?De:void 0,onResumeSession:g?ke:void 0,onPrefetchSession:u}),a.jsx(v0e,{...We,sessions:Be,pendingSession:Me?l:null,showProject:H===null,groupCrews:te,lineageSessions:ue,memberStatusOf:fe,older:{canLoad:(H===null||!!ve)&&!we.loaded&&!ee,loading:we.loading,load:we.load}})]})})]})}),z0e=y.memo(function(e){const t=V.c(16),{activeSessionKey:s,onSelectSession:r,onNewSession:o,creatingSession:i,isMobile:l,onDuplicateSession:c,onDeleteSession:u,pendingSession:d,liveSessionsRefreshRef:f,onPrefetchSession:m,header:p}=e,h=l?"w-full":"w-80";let g;t[0]!==h?(g=G("flex h-full shrink-0 flex-col bg-sidebar",h),t[0]=h,t[1]=g):g=t[1];let x;t[2]!==s||t[3]!==i||t[4]!==f||t[5]!==u||t[6]!==c||t[7]!==o||t[8]!==m||t[9]!==r||t[10]!==d?(x=a.jsx(M0e,{activeSessionKey:s,onSelectSession:r,onDuplicateSession:c,onDeleteSession:u,onNewSession:o,creatingSession:i,pendingSession:d,refreshRef:f,onPrefetchSession:m}),t[2]=s,t[3]=i,t[4]=f,t[5]=u,t[6]=c,t[7]=o,t[8]=m,t[9]=r,t[10]=d,t[11]=x):x=t[11];let b;return t[12]!==p||t[13]!==g||t[14]!==x?(b=a.jsxs("aside",{className:g,"aria-label":"Session browser",children:[p,x]}),t[12]=p,t[13]=g,t[14]=x,t[15]=b):b=t[15],b}),D0e=y.lazy(()=>nt(()=>import("./MissionHome-BTxUBbuU.js"),__vite__mapDeps([37,1,2,3,4])).then(n=>({default:n.MissionHome})));function Rm(n){const e=V.c(3),{label:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(Pn,{className:"size-4"}),e[0]=s):s=e[0];let r;return e[1]!==t?(r=a.jsxs("div",{className:"motion-enter flex min-h-0 flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",role:"status",children:[s,t]}),e[1]=t,e[2]=r):r=e[2],r}function p7(n){const e=V.c(12),{navigation:t,mobile:s,header:r}=n,o=s===void 0?!1:s,{sessionSource:i}=kt(),l=i?`${i.dirName}/${i.fileName}`:null;let c;return e[0]!==l||e[1]!==r||e[2]!==o||e[3]!==t.actions.handleDashboardSelect||e[4]!==t.creatingSession||e[5]!==t.handlers.handleDeleteSession||e[6]!==t.handlers.handleDuplicateSessionByPath||e[7]!==t.liveSessionsRefreshRef||e[8]!==t.onPrefetchSession||e[9]!==t.onStartNewSession||e[10]!==t.pendingSession?(c=a.jsx(z0e,{activeSessionKey:l,onSelectSession:t.actions.handleDashboardSelect,onNewSession:t.onStartNewSession,creatingSession:t.creatingSession,pendingSession:t.pendingSession,onDuplicateSession:t.handlers.handleDuplicateSessionByPath,onDeleteSession:t.handlers.handleDeleteSession,liveSessionsRefreshRef:t.liveSessionsRefreshRef,onPrefetchSession:t.onPrefetchSession,isMobile:o,header:r}),e[0]=l,e[1]=r,e[2]=o,e[3]=t.actions.handleDashboardSelect,e[4]=t.creatingSession,e[5]=t.handlers.handleDeleteSession,e[6]=t.handlers.handleDuplicateSessionByPath,e[7]=t.liveSessionsRefreshRef,e[8]=t.onPrefetchSession,e[9]=t.onStartNewSession,e[10]=t.pendingSession,e[11]=c):c=e[11],c}function F0e(n){const e=V.c(8),{navigation:t}=n,{state:s}=Sn();let r;return e[0]!==t.actions.handleDashboardSelect||e[1]!==t.creatingSession||e[2]!==t.handlers.handleDeleteSession||e[3]!==t.handlers.handleDuplicateSessionByPath||e[4]!==t.onSelectProject||e[5]!==t.onStartNewSession||e[6]!==s.dashboardProject?(r=a.jsx(Rxe,{onSelectSession:t.actions.handleDashboardSelect,onNewSession:t.onStartNewSession,creatingSession:t.creatingSession,selectedProjectDirName:s.dashboardProject,onSelectProject:t.onSelectProject,onDuplicateSession:t.handlers.handleDuplicateSessionByPath,onDeleteSession:t.handlers.handleDeleteSession}),e[0]=t.actions.handleDashboardSelect,e[1]=t.creatingSession,e[2]=t.handlers.handleDeleteSession,e[3]=t.handlers.handleDuplicateSessionByPath,e[4]=t.onSelectProject,e[5]=t.onStartNewSession,e[6]=s.dashboardProject,e[7]=r):r=e[7],r}function bf(n){const e=V.c(7),{navigation:t,showProjectHistory:s}=n,r=s===void 0?!1:s,{state:o,config:i}=Sn(),[l,c]=y.useState(!1);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=a.jsx(Rm,{label:"Loading Mission Control…"}),e[0]=u):u=e[0];let d;return e[1]!==l||e[2]!==i||e[3]!==t||e[4]!==r||e[5]!==o?(d=a.jsx(y.Suspense,{fallback:u,children:a.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 flex-col",children:l||r&&o.dashboardProject?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"px-4 pt-12",children:a.jsxs(Q,{variant:"ghost",size:"sm",onClick:()=>{t.onSelectProject(null),c(!1)},children:[a.jsx(bx,{"data-icon":"inline-start"})," Mission Control"]})}),a.jsx(F0e,{navigation:t})]}):a.jsx(D0e,{onOpenSession:t.actions.handleDashboardSelect,onBrowseProjects:()=>c(!0),start:{defaultAgentKind:i.defaultAgentKind,model:t.newSessionModel,onStart:t.onStartNewSessionWith}})})}),e[1]=l,e[2]=i,e[3]=t,e[4]=r,e[5]=o,e[6]=d):d=e[6],d}function h7(n){const e=V.c(8),{view:t,onClose:s}=n,{Component:r}=t,o=`Loading ${t.label}…`;let i;e[0]!==o?(i=a.jsx(Rm,{label:o}),e[0]=o,e[1]=i):i=e[1];let l;e[2]!==r||e[3]!==s?(l=a.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 flex-col",children:a.jsx(r,{onClose:s})}),e[2]=r,e[3]=s,e[4]=l):l=e[4];let c;return e[5]!==i||e[6]!==l?(c=a.jsx(y.Suspense,{fallback:i,children:l}),e[5]=i,e[6]=l,e[7]=c):c=e[7],c}function U0e({mainView:n,hasSession:e,pendingDirName:t,extensionViewAvailable:s}){return n==="config"?"config":n==="mission"?"mission":n==="extension"&&s?"extension":e?"session":t?"pending":"dashboard"}function B0e({sessionCwd:n,pendingPath:e,sessionDirPath:t,dashboardProjectPath:s}){return n??e??t??s??null}function g7({path:n,text:e,startLine:t,endLine:s,comment:r}){if(!e)return`@${n}`;const o=e.includes("```")?"````":"```",i=t===s?`line ${t}`:`lines ${t}-${s}`;return`${r?`Review request: ${r}
469
+ `||t.length>0)&&s++,t=[],i+=(l==="&"||l==="|")&&(d===l||f&&d==="&")?2:1;continue}if(/^(?:\d+)?<</.test(n.slice(i)))return o();const c=/^(?:\d+)?(?:>>|>\||>&|<&|<>|[<>])/.exec(n.slice(i));if(c){for(i+=c[0].length;/[^\S\n]/.test(n[i]??"");)i++;const d=Sj(n,i);if(!d||d.end===i)return o();i=d.end;continue}const u=Sj(n,i);if(!u||u.end===i)return o();t.push(u),i=u.end}return e.push({words:t,end:n.length,pipeline:s}),{commands:e,complete:r===0}}const yl="agent-browser",g1e=new Map([["env",new Set(["-i","--ignore-environment","--"])],["command",new Set(["--"])],["exec",new Set(["--"])],["npx",new Set(["-y","--yes","--"])],["bunx",new Set(["--bun","--"])]]),x1e=new Set(["echo","printf","rg","grep","cat","head","tail","wc","ls","stat","file","basename","dirname","cp","mv","rm","mkdir","rmdir","touch"]),b1e=new Set(["commit","log","show","diff","status","add","grep","ls-files","rev-parse"]),v1e=/^(?:if|then|else|elif|fi|while|until|for|select|case|esac|do|done|function|\{|\}|!)$/,y1e=/^[A-Za-z_][A-Za-z_\d]*=/;function VI(n){return n.slice(n.lastIndexOf("/")+1)}function w1e(n,e){var s,r;let t=0;for(;t<n.length;){const o=n[t];if(y1e.test(e.slice(o.start,o.end))){t++;continue}if(!o.literal||v1e.test(o.value))return null;const i=VI(o.value);if(i==="command"&&["-v","-V"].includes((s=n[t+1])==null?void 0:s.value))return-1;const l=g1e.get(i);if(!l)return t;for(t++;(r=n[t])!=null&&r.value.startsWith("-");){if(!n[t].literal||!l.has(n[t].value))return null;if(n[t++].value==="--")break}}return-1}function S1e(n,e,t){const[s,...r]=n;if(r.some(l=>!l.literal))return null;let o=u1e,i=null;for(let l=0;l<r.length;l++){const c=r[l];if(c.value!=="--session"&&!c.value.startsWith("--session="))continue;if(i!==null)return null;const u=c.value==="--session"?r[++l]:c;if(o=c.value==="--session"?u==null?void 0:u.value:c.value.slice(10),!o||!m1e(o)||u!==c&&!/^(?:\s|\\\n)*$/.test(t.slice(c.end,u.start)))return null;i={start:c.start,end:u.end}}return{text:yl+t.slice(s.end,e).trimEnd(),binaryEnd:s.end,browser:o,sessionFlag:i}}function k1e(n){var l;const{commands:e,complete:t}=h1e(n),s=[],r=e.some(({words:c})=>c.some(({value:u})=>u.includes(yl)));if(!t)return{invocations:s,ambiguous:r||n.includes(yl)};const o=new Set(e.filter(({words:c})=>c.some(({value:u})=>u.includes(yl))).map(({pipeline:c})=>c));let i=!1;for(const{words:c,end:u,pipeline:d}of e){const f=w1e(c,n);if(f===null){i||(i=r);continue}if(f<0)continue;const m=VI(c[f].value);if(m!==yl){!(x1e.has(m)||m==="git"&&b1e.has((l=c[f+1])==null?void 0:l.value))&&o.has(d)&&(i=!0);continue}const p=S1e(c.slice(f),u,n);p===null?i=!0:s.push(p)}return{invocations:s,ambiguous:i}}function j1e(n){return k1e(n).invocations}const kj=120,N1e=/(?:^|[._])exec_command$/;function C1e(n){return n==="Bash"||N1e.test(n)}function _1e(n){return Mse(n).filter(e=>C1e(e.name)).map(e=>so(e.input))}function E1e(n){for(const e of _1e(n)){const[t]=j1e(e);if(t===void 0||p1e(t.browser))continue;const{text:s}=t;return{session:t.browser,command:s.length>kj?`${s.slice(0,kj-1)}…`:s,timestamp:n.timestamp,toolCallId:n.id,done:n.result!==null}}return null}function T1e(n){const e=(n==null?void 0:n.turns)??[];for(let t=e.length-1;t>=0;t--){const s=e[t].toolCalls;for(let r=s.length-1;r>=0;r--){const o=E1e(s[r]);if(o)return o}}return null}const jj=1e4,A1e=y.lazy(()=>nt(()=>import("./ProjectFilesPanel-CwBgFc0T.js"),__vite__mapDeps([32,1,33,2,4,3])).then(n=>({default:n.ProjectFilesPanel}))),I1e=y.lazy(()=>nt(()=>import("./WorktreePanel-DYxBPlno.js"),__vite__mapDeps([34,1,2,3,4])).then(n=>({default:n.WorktreePanel}))),P1e=y.lazy(()=>nt(()=>import("./CrewPanel-CyCZndfq.js"),__vite__mapDeps([35,1,28,2,3,4])).then(n=>({default:n.CrewPanel}))),$1e=y.lazy(()=>nt(()=>import("./index-B1Aq64LJ.js"),__vite__mapDeps([36,1,2,3,4])).then(n=>({default:n.BrowserPanel})));function Am(){const n=V.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=a.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-sm text-muted-foreground",role:"status",children:[a.jsx(Pn,{}),"Loading panel…"]}),n[0]=e):e=n[0],e}function R1e(n){const e=V.c(6),{context:t,closePanel:s}=n,r=Jb(),o=r.projectFilesRoot??t.projectPath;if(!o)return null;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx(Am,{}),e[0]=i):i=e[0];let l;return e[1]!==s||e[2]!==o||e[3]!==r.addProjectContext||e[4]!==r.projectFilesRequest?(l=a.jsx(y.Suspense,{fallback:i,children:a.jsx(A1e,{cwd:o,onClose:s,onAddToPrompt:r.addProjectContext,openRequest:r.projectFilesRequest},o)}),e[1]=s,e[2]=o,e[3]=r.addProjectContext,e[4]=r.projectFilesRequest,e[5]=l):l=e[5],l}function O1e(n){const e=V.c(3),{context:t}=n;if(!t.session)return null;let s;return e[0]!==t.session||e[1]!==t.sessionChangeKey?(s=a.jsx(rfe,{session:t.session,sessionChangeKey:t.sessionChangeKey}),e[0]=t.session,e[1]=t.sessionChangeKey,e[2]=s):s=e[2],s}function L1e(){const n=V.c(7),e=Jb();let t;return n[0]!==e.backgroundAgents||n[1]!==e.jumpToTurn||n[2]!==e.loadSession||n[3]!==e.searchInputRef||n[4]!==e.serversChanged||n[5]!==e.toggleServer?(t=a.jsx(c1e,{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 M1e(n){const e=V.c(3);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=a.jsx(Am,{}),e[0]=t):t=e[0];let s;return e[1]!==n?(s=a.jsx(y.Suspense,{fallback:t,children:a.jsx($1e,{...n})}),e[1]=n,e[2]=s):s=e[2],s}function z1e(n){var u;const e=V.c(8),{context:t}=n,[,s]=y.useState(0);let r;e[0]!==t.session?(r=Date.parse(((u=T1e(t.session))==null?void 0:u.timestamp)??""),e[0]=t.session,e[1]=r):r=e[1];const o=r;let i;e[2]!==o||e[3]!==s?(i=()=>{const d=o+jj-Date.now();if(Number.isNaN(d)||d<=0)return;const f=setTimeout(()=>s(D1e),d);return()=>clearTimeout(f)},e[2]=o,e[3]=s,e[4]=i):i=e[4];let l;if(e[5]!==o?(l=[o],e[5]=o,e[6]=l):l=e[6],y.useEffect(i,l),Number.isNaN(o)||Date.now()-o>=jj)return null;let c;return e[7]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx("span",{role:"status","aria-label":"The agent is using the browser",className:"absolute -right-0.5 -top-0.5 size-2 rounded-full bg-emerald-500"}),e[7]=c):c=e[7],c}function D1e(n){return n+1}function F1e(n){const e=V.c(3);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=a.jsx(Am,{}),e[0]=t):t=e[0];let s;return e[1]!==n?(s=a.jsx(y.Suspense,{fallback:t,children:a.jsx(P1e,{...n})}),e[1]=n,e[2]=s):s=e[2],s}function U1e(n){const e=V.c(5),{context:t}=n,s=t.crew;if(!s)return null;if(s.needsYou>0){const i=`${s.needsYou} ${s.needsYou===1?"session needs":"sessions need"} you`;let l;return e[0]!==s.needsYou||e[1]!==i?(l=a.jsx("span",{role:"status","aria-label":i,className:"absolute -right-1 -top-1 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-warning px-1 text-[9px] font-semibold text-warning-foreground",children:s.needsYou}),e[0]=s.needsYou,e[1]=i,e[2]=l):l=e[2],l}if(s.working===0)return null;const r=`${s.working} ${s.working===1?"session":"sessions"} working`;let o;return e[3]!==r?(o=a.jsx("span",{role:"status","aria-label":r,className:"absolute -right-0.5 -top-0.5 size-2 rounded-full bg-success ring-2 ring-success/30"}),e[3]=r,e[4]=o):o=e[4],o}function B1e(n){const e=V.c(8),{closePanel:t}=n,s=Jb();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Am,{}),e[0]=r):r=e[0];let o;return e[1]!==t||e[2]!==s.openWorktreeSession||e[3]!==s.worktreeDirName||e[4]!==s.worktrees.loading||e[5]!==s.worktrees.refetch||e[6]!==s.worktrees.worktrees?(o=a.jsx(y.Suspense,{fallback:r,children:a.jsx(I1e,{worktrees:s.worktrees.worktrees,loading:s.worktrees.loading,dirName:s.worktreeDirName,onRefetch:s.worktrees.refetch,onOpenSession:s.openWorktreeSession,onClose:t})}),e[1]=t,e[2]=s.openWorktreeSession,e[3]=s.worktreeDirName,e[4]=s.worktrees.loading,e[5]=s.worktrees.refetch,e[6]=s.worktrees.worktrees,e[7]=o):o=e[7],o}const W1e={id:ii,workspacePanels:[{id:"crew",title:"Crew",icon:nx,component:F1e,indicator:U1e,order:1,defaultSize:"30%",minSize:"340px",maxSize:"60%",when:n=>!!n.crew},{id:"worktrees",title:"Worktrees",icon:Gr,component:B1e,order:5,defaultSize:"36%",minSize:"320px",when:n=>n.supportsWorktrees===!0},{id:"project-files",title:"Project files",icon:I8,component:R1e,order:10,defaultSize:"55%",minSize:"340px",maxSize:"75%",keepAlive:!0,when:n=>n.canAccessHostFiles&&n.projectPath!==null},{id:"browser",title:"Browser",icon:na,component:M1e,indicator:z1e,order:15,defaultSize:"46%",minSize:"360px",maxSize:"75%",keepAlive:!0,when:n=>n.canUseBrowser},{id:"file-changes",title:"File changes",icon:yc,component:O1e,order:20,defaultSize:"36%",minSize:"320px",when:n=>n.canAccessHostFiles&&n.hasFileChanges&&n.session!==null},{id:"session-info",title:"Session details",icon:P8,component:L1e,order:30,defaultSize:"36%",minSize:"320px",when:n=>n.session!==null}]},q1e=rpe([W1e]),Nj={"cogpit.github":g4,"cogpit.clickup":O8,"cogpit.vercel":R8,"cogpit.cloudflare":$8};function V1e(n){const e=V.c(6);let t,s;e[0]!==n?({runtime:s,...t}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;return e[3]!==t||e[4]!==s?(r=s?a.jsx(Ege,{...t,...s}):null,e[3]=t,e[4]=s,e[5]=r):r=e[5],r}function H1e(n){var o;const e=V.c(3),{runtime:t,context:s}=n;let r;return e[0]!==s||e[1]!==t?(r=t?a.jsx(Cge,{client:t.client,pluginId:t.plugin.id,projectId:((o=t.project)==null?void 0:o.id)??null,workspacePath:t.project?s.projectPath:null,activation:t.activation,registryRevision:t.registryRevision}):null,e[0]=s,e[1]=t,e[2]=r):r=e[2],r}function K1e({client:n,status:e,activation:t,project:s,legacyPanels:r=q1e,openSettings:o}){const i=[...r];if(!(e!=null&&e.store.available)||e.safeMode||!t||WE())return i;const l=new Set(i.map(u=>u.id)),c=bo();for(const u of e.store.plugins)if(!(!u.enabled||u.scope.type==="projects"&&(!s||!u.scope.projectIds.includes(s.id)))&&_0(u.manifest,c,e.runtime,{allowPrerelease:u.manifest.publisher.startsWith("dev-")}).compatible)for(const d of u.manifest.contributes.panels){const f=xo(u.id,d.id);if(l.has(f)||d.when==="project-selected"&&!s)continue;l.add(f);const m={client:n,plugin:u,activation:t,registryRevision:e.store.revision,project:s,title:d.title,openSettings:o};i.push({id:f,pluginId:u.id,localId:d.id,title:d.title,icon:Nj[u.id]??xx,order:d.order,defaultSize:d.defaultSize,minSize:d.minSize,maxSize:d.maxSize,keepAlive:!0,...Nj[u.id]?{indicator:H1e,indicatorProps:{runtime:m}}:{},component:V1e,componentProps:{runtime:m}})}return i.sort((u,d)=>(u.order??100)-(d.order??100)||u.title.localeCompare(d.title))}function HI(n){const e=V.c(11),{client:t,status:s,activation:r,projectPath:o,openSettings:i}=n,l=Y0();let c;e[0]!==r||e[1]!==t||e[2]!==o||e[3]!==s?(c={client:t,status:s,activation:r,projectPath:o},e[0]=r,e[1]=t,e[2]=o,e[3]=s,e[4]=c):c=e[4];const{project:u,resolving:d}=BE(c),f=l||d?"":r;let m;return e[5]!==t||e[6]!==i||e[7]!==u||e[8]!==s||e[9]!==f?(m=K1e({client:t,status:s,activation:f,project:u,openSettings:i}),e[5]=t,e[6]=i,e[7]=u,e[8]=s,e[9]=f,e[10]=m):m=e[10],m}function Im(n){const e=V.c(7),{floating:t,children:s}=n,r=y.useRef(null);let o,i;if(e[0]!==t?(o=()=>{const c=r.current,u=c==null?void 0:c.parentElement;if(!t||!c||!u)return;const d=u.style.getPropertyValue("--session-footer-height"),f=()=>u.style.setProperty("--session-footer-height",`${c.getBoundingClientRect().height}px`);f();const m=new ResizeObserver(f);return m.observe(c),()=>{m.disconnect(),d?u.style.setProperty("--session-footer-height",d):u.style.removeProperty("--session-footer-height")}},i=[t],e[0]=t,e[1]=o,e[2]=i):(o=e[1],i=e[2]),y.useLayoutEffect(o,i),t){let c;return e[3]!==s?(c=a.jsx("div",{ref:r,className:"pointer-events-none absolute inset-x-0 bottom-0 z-20 flex justify-center bg-gradient-to-t from-canvas via-canvas/70 to-transparent pt-4",children:a.jsx("div",{className:"pointer-events-auto w-full max-w-[var(--chat-width)] px-3 pb-3",children:s})}),e[3]=s,e[4]=c):c=e[4],c}let l;return e[5]!==s?(l=a.jsx("div",{className:"flex w-full shrink-0 justify-center",children:a.jsx("div",{className:"w-full max-w-[var(--chat-width)] px-3 pb-3",children:s})}),e[5]=s,e[6]=l):l=e[6],l}function ya(n){const e=V.c(13),{projectPath:t,fallback:s,className:r}=n,[o,i]=y.useState(null);if(!t||o===t){let m;return e[0]!==s?(m=a.jsx(a.Fragment,{children:s}),e[0]=s,e[1]=m):m=e[1],m}const l=`/api/project-icon?cwd=${encodeURIComponent(t)}`;let c;e[2]!==l?(c=Af(l),e[2]=l,e[3]=c):c=e[3];let u;e[4]!==t?(u=()=>i(t),e[4]=t,e[5]=u):u=e[5];let d;e[6]!==r?(d=G("size-3.5 shrink-0 rounded-[3px] object-contain",r),e[6]=r,e[7]=d):d=e[7];let f;return e[8]!==t||e[9]!==c||e[10]!==u||e[11]!==d?(f=a.jsx("img",{src:c,alt:"","aria-hidden":!0,loading:"lazy",decoding:"async",onError:u,className:d},t),e[8]=t,e[9]=c,e[10]=u,e[11]=d,e[12]=f):f=e[12],f}function KI(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G(t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function GI(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex flex-wrap items-center gap-1.5 text-sm wrap-break-word text-muted-foreground",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("ol",{"data-slot":"breadcrumb-list",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function U1(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("inline-flex items-center gap-1",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("li",{"data-slot":"breadcrumb-item",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function ZI(n){const e=V.c(10);let t,s,r,o;if(e[0]!==n){const{className:c,render:u,...d}=n;t=u,o=m4,s="a",r=f4({className:G("transition-colors hover:text-foreground",c)},d),e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o}else t=e[1],s=e[2],r=e[3],o=e[4];let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i={slot:"breadcrumb-link"},e[5]=i):i=e[5];let l;return e[6]!==t||e[7]!==s||e[8]!==r?(l={defaultTagName:s,props:r,render:t,state:i},e[6]=t,e[7]=s,e[8]=r,e[9]=l):l=e[9],o(l)}function YI(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("font-normal text-foreground",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("span",{"data-slot":"breadcrumb-page",role:"link","aria-disabled":"true","aria-current":"page",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function XI(n){const e=V.c(12);let t,s,r;e[0]!==n?({children:t,className:s,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);let o;e[4]!==s?(o=G("[&>svg]:size-3.5",s),e[4]=s,e[5]=o):o=e[5];let i;e[6]!==t?(i=t??a.jsx(it,{}),e[6]=t,e[7]=i):i=e[7];let l;return e[8]!==r||e[9]!==o||e[10]!==i?(l=a.jsx("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:o,...r,children:i}),e[8]=r,e[9]=o,e[10]=i,e[11]=l):l=e[11],l}const G1e=1e3,Z1e=255;function Y1e(n){for(const e of n){const t=e.codePointAt(0)??0;if(t<32||t===127)return!0}return!1}function X1e(n){return n.trim()===""?"Enter a folder name":n!==n.trim()?"A folder name cannot start or end with a space":n==="."||n===".."?`"${n}" is not a folder name`:n.includes("/")||n.includes("\\")?"A folder name cannot contain / or \\":Y1e(n)?"A folder name cannot contain control characters":new TextEncoder().encode(n).length>Z1e?"That folder name is too long":null}function Cj(n,e){return n instanceof Error&&n.message?n.message:e}function J1e({hostName:n,projectPaths:e,onStart:t,onBack:s}){var D;const[r,o]=y.useState({path:null,request:0}),i=`${r.request}:${r.path??""}`,[l,c]=y.useState(null),[u,d]=y.useState(""),[f,m]=y.useState(""),[p,h]=y.useState(!1),[g,x]=y.useState(""),[b,w]=y.useState(null),[v,j]=y.useState(!1),k=y.useRef(null),_=y.useRef(null),N=y.useRef(null),S=y.useRef(!1);y.useEffect(()=>{const B=new AbortController;return Xme(r.path,B.signal).then(q=>c({request:i,listing:q})).catch(q=>{B.signal.aborted||c({request:i,error:Cj(q,"This folder could not be read")})}),()=>B.abort()},[i,r.path]);const C=(l==null?void 0:l.request)!==i,E=l&&"listing"in l?l.listing:null,T=!C&&l&&"error"in l?l.error:null,$=C?null:(E==null?void 0:E.path)??null,A=u.trim().toLowerCase(),R=(E==null?void 0:E.folders.filter(B=>B.name.toLowerCase().includes(A)))??[],P=R.some(B=>B.path===f)?f:((D=R[0])==null?void 0:D.path)??"",z=E==null?void 0:E.path;y.useEffect(()=>{var q,W;const B=N.current;B&&(B.scrollLeft=B.scrollWidth),S.current&&!((q=k.current)!=null&&q.contains(document.activeElement))&&((W=_.current)==null||W.focus()),S.current=!1},[z]);function L(B){var q;S.current=((q=k.current)==null?void 0:q.contains(document.activeElement))??!1,o(W=>({path:B,request:W.request+1})),d(""),h(!1),x(""),w(null)}function I(){$&&t($)}function M(B){B.key==="Enter"&&(B.metaKey||B.ctrlKey)&&!p?(B.preventDefault(),I()):B.key==="Backspace"&&B.target===_.current&&u===""&&(E!=null&&E.parent)&&!C&&(B.preventDefault(),L(E.parent))}function F(){var B;h(!1),x(""),w(null),(B=_.current)==null||B.focus()}async function U(B){var H;B.preventDefault();const q=g.trim(),W=X1e(q);if(W){w(W);return}if(!(!$||v)){j(!0);try{const K=await Jme($,q);L(K),(H=_.current)==null||H.focus()}catch(K){w(Cj(K,"The folder could not be made"))}finally{j(!1)}}}const O=n?`Folders on ${n}`:"Folders";return a.jsxs("div",{ref:k,onKeyDownCapture:M,className:"flex min-h-0 flex-col bg-popover text-popover-foreground",children:[a.jsxs("div",{className:"flex items-center gap-1 border-b px-2 py-1.5 in-data-[slot=dialog-content]:pr-12",children:[a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",onClick:s,"aria-label":"Back to projects",children:a.jsx(bx,{})}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:O}),E&&E.path!==E.root&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>L(null),"aria-label":"Go to the projects root",title:E.root,children:a.jsx(L8,{})})]}),E&&a.jsx(Q1e,{path:E.path,top:E.confined?E.root:null,listRef:N,onOpen:L}),a.jsxs(Ic,{shouldFilter:!1,label:"Filter folders",value:P,onValueChange:m,className:"rounded-none p-0",children:[a.jsx(o0,{ref:_,autoFocus:!0,placeholder:"Filter folders...",value:u,onValueChange:d}),a.jsx(Pc,{className:"box-content max-h-72 p-1","aria-busy":C,children:T!==null?a.jsx(exe,{message:T,onRetry:()=>L(r.path),onRoot:r.path===null?void 0:()=>L(null)}):E===null?a.jsxs("div",{role:"status",className:"flex items-center justify-center gap-2 py-8 text-sm text-muted-foreground",children:[a.jsx(Pn,{className:"size-4"}),"Loading folders…"]}):R.length===0?a.jsx(Ln,{className:"border-0 py-8",children:a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:a.jsx(Zr,{})}),a.jsx(zn,{children:A?"No folder matches":"No folders here"}),a.jsx(Dn,{children:A?"Try another name.":"Start a session right here, or make a new folder."})]})}):a.jsxs(xi,{className:G("p-0 transition-opacity",C&&"opacity-50"),children:[R.map(B=>a.jsxs(Eo,{value:B.path,onSelect:()=>L(B.path),onMouseDown:q=>q.preventDefault(),className:"motion-list-item h-auto gap-3 px-3 py-2",children:[a.jsx(sa,{className:"size-4 shrink-0 text-muted-foreground"}),a.jsx("span",{className:"min-w-0 flex-1 truncate",children:B.name}),e.has(B.path)&&a.jsx(Fe,{variant:"secondary",children:"Project"}),a.jsx(it,{className:"size-4 shrink-0 text-muted-foreground"})]},B.path)),E.truncated&&a.jsxs("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:["Showing the first ",G1e.toLocaleString()," folders."]})]})})]}),a.jsxs("div",{className:"flex flex-col gap-1.5 border-t p-2",children:[p?a.jsxs("form",{onSubmit:B=>void U(B),className:"flex items-center gap-2",children:[a.jsx(On,{autoFocus:!0,"aria-label":"New folder name",placeholder:"New folder name",value:g,disabled:v,"aria-invalid":b?!0:void 0,onChange:B=>{x(B.target.value),w(null)},onKeyDown:B=>{B.key==="Escape"&&(B.preventDefault(),B.stopPropagation(),F())}}),a.jsxs(Q,{type:"submit",size:"sm",disabled:v||!$||g.trim()==="",children:[v&&a.jsx(Pn,{"data-icon":"inline-start",className:"size-4"}),"Create"]}),a.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:F,children:"Cancel"})]}):a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Q,{type:"button",variant:"ghost",size:"sm",disabled:!$,onClick:()=>h(!0),children:[a.jsx(W4,{"data-icon":"inline-start"}),"New folder"]}),a.jsx(Q,{type:"button",size:"sm",className:"ml-auto",disabled:!$,onClick:I,"aria-keyshortcuts":"Meta+Enter Control+Enter",children:"Start session here"})]}),b&&a.jsx("p",{role:"alert",className:"px-1 text-xs text-destructive",children:b})]})]})}function Q1e(n){const e=V.c(19),{path:t,top:s,listRef:r,onOpen:o}=n;let i,l,c,u,d,f;if(e[0]!==r||e[1]!==o||e[2]!==t||e[3]!==s){const h=Qme(t,s);l=KI,f="border-b px-3 py-1.5",i=GI,c=r,u="no-scrollbar flex-nowrap gap-1 overflow-x-auto text-xs",d=h.map((g,x)=>a.jsxs(y.Fragment,{children:[x>0&&a.jsx(XI,{}),a.jsx(U1,{className:"shrink-0",children:x===h.length-1?a.jsx(YI,{children:g.label}):a.jsx(ZI,{render:a.jsx("button",{type:"button",onClick:()=>o(g.path)}),children:g.label})})]},g.path)),e[0]=r,e[1]=o,e[2]=t,e[3]=s,e[4]=i,e[5]=l,e[6]=c,e[7]=u,e[8]=d,e[9]=f}else i=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=e[9];let m;e[10]!==i||e[11]!==c||e[12]!==u||e[13]!==d?(m=a.jsx(i,{ref:c,className:u,children:d}),e[10]=i,e[11]=c,e[12]=u,e[13]=d,e[14]=m):m=e[14];let p;return e[15]!==l||e[16]!==f||e[17]!==m?(p=a.jsx(l,{className:f,children:m}),e[15]=l,e[16]=f,e[17]=m,e[18]=p):p=e[18],p}function exe(n){const e=V.c(14),{message:t,onRetry:s,onRoot:r}=n;let o,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(Yn,{variant:"icon",children:a.jsx(wr,{})}),i=a.jsx(zn,{children:"This folder could not be opened"}),e[0]=o,e[1]=i):(o=e[0],i=e[1]);let l;e[2]!==t?(l=a.jsxs(Mn,{children:[o,i,a.jsx(Dn,{children:t})]}),e[2]=t,e[3]=l):l=e[3];let c;e[4]!==s?(c=a.jsx(Q,{type:"button",variant:"outline",size:"sm",onClick:s,children:"Try again"}),e[4]=s,e[5]=c):c=e[5];let u;e[6]!==r?(u=r&&a.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:r,children:"Go to the projects root"}),e[6]=r,e[7]=u):u=e[7];let d;e[8]!==c||e[9]!==u?(d=a.jsxs("div",{className:"flex gap-2",children:[c,u]}),e[8]=c,e[9]=u,e[10]=d):d=e[10];let f;return e[11]!==l||e[12]!==d?(f=a.jsxs(Ln,{className:"border-0 py-8",children:[l,d]}),e[11]=l,e[12]=d,e[13]=f):f=e[13],f}function txe(){const n=V.c(7),e=Nn("manageDevices");let t;n[0]!==e?(t={enabled:e},n[0]=e,n[1]=t):t=n[1];const{activeDevice:s}=Fa(t);let r;n[2]!==s?(r=!s&&Ef(),n[2]=s,n[3]=r):r=n[3];const o=r,[i,l]=y.useState(null);let c,u;return n[4]!==o?(c=()=>{if(!o)return;const d=new AbortController;return Ce("/api/hello",{signal:d.signal}).then(zs).then(f=>{typeof(f==null?void 0:f.name)=="string"&&f.name&&l(f.name)}).catch(nxe),()=>d.abort()},u=[o],n[4]=o,n[5]=c,n[6]=u):(c=n[5],u=n[6]),y.useEffect(c,u),(s==null?void 0:s.name)??(o?i:null)}function nxe(){}function _j(n){return n.replace(/[\\/]+$/,"")||n}function JI(n){const e=n.map(s=>({...s,worktrees:[]})),t=new Map;for(const s of e){const r=_j(s.path);!Nr(s.path)&&!t.has(r)&&t.set(r,s)}return e.filter((s,r)=>{const o=Nr(s.path),i=o&&t.get(_j(o.parentPath));return i?(i.worktrees.push(n[r]),!1):!0})}const B1=qN("project-custom-names"),sxe=B1.rename;function ev(){const n=V.c(2),e=y.useSyncExternalStore(B1.subscribe,B1.getSnapshot);let t;return n[0]!==e?(t={names:e,rename:sxe},n[0]=e,n[1]=t):t=n[1],t}const Ej="browse-folders";function wl(n){return n.replace(/[\\/]+$/,"")||n}function rxe(n){const e=V.c(4);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];const[s,r]=y.useState(t);let o,i;return e[1]!==n?(o=()=>{if(!n)return;const l=new AbortController;return Ce("/api/projects",{signal:l.signal}).then(oxe).then(r).catch(()=>{l.signal.aborted||r([])}),()=>l.abort()},i=[n],e[1]=n,e[2]=o,e[3]=i):(o=e[2],i=e[3]),y.useEffect(o,i),s}async function oxe(n){return n.ok?await n.json():[]}function ixe(n){var B;const e=V.c(58),{projects:t,onNewSession:s,onNewFolder:r,defaultAgentKind:o,currentPath:i,initialView:l,children:c}=n,u=l===void 0?"projects":l,[d,f]=y.useState(u),[m,p]=y.useState(""),[h,g]=y.useState(null),{names:x}=ev(),b=txe();let w;if(e[0]!==m||e[1]!==x||e[2]!==t){e:{const q=JI(t);if(!m){w=q;break e}const W=m.toLowerCase();w=q.filter(H=>{var K;return H.path.toLowerCase().includes(W)||H.shortName.toLowerCase().includes(W)||H.dirName.toLowerCase().includes(W)||((K=x[H.dirName])==null?void 0:K.toLowerCase().includes(W))})}e[0]=m,e[1]=x,e[2]=t,e[3]=w}else w=e[3];const v=w;let j,k;e[4]!==m||e[5]!==t?(j=m.trim(),k=(j.startsWith("/")||/^[a-z]:[\\/]/i.test(j)||j.startsWith("\\\\"))&&!t.some(W=>wl(W.path)===wl(j)),e[4]=m,e[5]=t,e[6]=j,e[7]=k):(j=e[6],k=e[7]);const _=k;let N;e[8]!==i?(N=i?wl(((B=Nr(i))==null?void 0:B.parentPath)??i):null,e[8]=i,e[9]=N):N=e[9];const S=N;let C;e[10]!==_||e[11]!==j?(C=_?[`folder:${j}`]:[],e[10]=_,e[11]=j,e[12]=C):C=e[12];let E;e[13]!==v||e[14]!==C?(E=[...C,...v.map(lxe),Ej],e[13]=v,e[14]=C,e[15]=E):E=e[15];const T=E,$=h!==null&&T.includes(h)?h:T[0];if(d==="folders"){let q;e[16]!==t?(q=new Set(t.map(axe)),e[16]=t,e[17]=q):q=e[17];let W;e[18]===Symbol.for("react.memo_cache_sentinel")?(W=()=>f("projects"),e[18]=W):W=e[18];let H;return e[19]!==b||e[20]!==r||e[21]!==q?(H=a.jsx(J1e,{hostName:b,projectPaths:q,onStart:r,onBack:W}),e[19]=b,e[20]=r,e[21]=q,e[22]=H):H=e[22],H}let A;e[23]!==m?(A=a.jsx(o0,{autoFocus:!0,placeholder:"Search projects, paste a folder path, or browse",value:m,onValueChange:p}),e[23]=m,e[24]=A):A=e[24];let R;e[25]!==_||e[26]!==v.length?(R=v.length===0&&!_&&a.jsx(Ln,{className:"border-0 py-8",children:a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:a.jsx(Zr,{})}),a.jsx(zn,{children:"No projects found"}),a.jsx(Dn,{children:"Try another name, paste an absolute path, or browse the folders."})]})}),e[25]=_,e[26]=v.length,e[27]=R):R=e[27];let P;e[28]!==_||e[29]!==o||e[30]!==j||e[31]!==r?(P=_&&a.jsxs(Eo,{value:`folder:${j}`,className:"motion-list-item h-auto gap-3 px-3 py-2.5",onSelect:()=>r(j),children:[a.jsx(W4,{"data-icon":"inline-start",className:"size-4 shrink-0 text-foreground"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"text-sm font-medium",children:"Start in this folder"}),a.jsxs("div",{className:"truncate text-xs text-muted-foreground",children:[j," · ",SM(o)]})]})]}),e[28]=_,e[29]=o,e[30]=j,e[31]=r,e[32]=P):P=e[32];let z;if(e[33]!==S||e[34]!==v||e[35]!==s||e[36]!==x){let q;e[38]!==S||e[39]!==s||e[40]!==x?(q=W=>{const H=x[W.dirName],K=jc(W.path);return a.jsxs(Eo,{value:`project:${W.dirName}`,"data-checked":S!==null&&wl(W.path)===S,className:"motion-list-item h-auto gap-3 px-3 py-2.5",onSelect:()=>s(W.dirName,W.path),children:[a.jsx(ya,{projectPath:W.path,fallback:a.jsx(Zr,{"data-icon":"inline-start",className:"size-4 shrink-0 text-muted-foreground"}),className:"size-4"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-sm font-medium",children:H||K}),a.jsxs("div",{className:"text-xs text-muted-foreground",children:[H&&a.jsx("span",{className:"mr-1.5",children:K}),W.sessionCount," session",W.sessionCount!==1?"s":"",W.lastModified&&a.jsxs(a.Fragment,{children:[" · ",new Date(W.lastModified).toLocaleDateString()]})]})]})]},W.dirName)},e[38]=S,e[39]=s,e[40]=x,e[41]=q):q=e[41],z=v.map(q),e[33]=S,e[34]=v,e[35]=s,e[36]=x,e[37]=z}else z=e[37];let L;e[42]!==z||e[43]!==P?(L=a.jsxs(xi,{className:"p-0",children:[P,z]}),e[42]=z,e[43]=P,e[44]=L):L=e[44];let I,M;e[45]===Symbol.for("react.memo_cache_sentinel")?(I=()=>f("folders"),M=a.jsx(wc,{"data-icon":"inline-start",className:"size-4 shrink-0 text-muted-foreground"}),e[45]=I,e[46]=M):(I=e[45],M=e[46]);const F=b?`Browse folders on ${b}…`:"Browse folders…";let U;e[47]!==F?(U=a.jsx(xi,{className:"sticky -bottom-1 border-t bg-popover p-0 py-1",children:a.jsxs(Eo,{value:Ej,className:"h-auto gap-3 px-3 py-2.5",onSelect:I,children:[M,a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:F})]})}),e[47]=F,e[48]=U):U=e[48];let O;e[49]!==L||e[50]!==U||e[51]!==R?(O=a.jsxs(Pc,{className:"box-content max-h-80 p-1",children:[R,L,U]}),e[49]=L,e[50]=U,e[51]=R,e[52]=O):O=e[52];let D;return e[53]!==c||e[54]!==$||e[55]!==O||e[56]!==A?(D=a.jsxs(Ic,{shouldFilter:!1,value:$,onValueChange:g,className:"rounded-none p-0",children:[A,O,c]}),e[53]=c,e[54]=$,e[55]=O,e[56]=A,e[57]=D):D=e[57],D}function axe(n){return wl(n.path)}function lxe(n){return`project:${n.dirName}`}function QI(n){const e=V.c(13),{projectPath:t,switcher:s}=n;let r;e[0]!==t?(r=t?_r(t):null,e[0]=t,e[1]=r):r=e[1];const o=r;let i;e[2]!==o||e[3]!==t||e[4]!==s?(i=o?a.jsxs(a.Fragment,{children:["What should we build in"," ",a.jsx(cxe,{name:o,projectPath:t,switcher:s}),"?"]}):"What should we build?",e[2]=o,e[3]=t,e[4]=s,e[5]=i):i=e[5];let l;e[6]!==i?(l=a.jsx("h1",{className:"text-balance text-2xl font-semibold tracking-tight text-foreground",children:i}),e[6]=i,e[7]=l):l=e[7];let c;e[8]!==t?(c=t&&a.jsx("p",{className:"font-mono text-xs text-muted-foreground",children:jc(t)}),e[8]=t,e[9]=c):c=e[9];let u;return e[10]!==l||e[11]!==c?(u=a.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 text-center",children:[l,c]}),e[10]=l,e[11]=c,e[12]=u):u=e[12],u}function cxe(n){const e=V.c(24),{name:t,projectPath:s,switcher:r}=n,{onNewSession:o,onNewFolder:i,defaultAgentKind:l}=r,[c,u]=y.useState(!1),d=rxe(c);let f;e[0]!==s?(f=a.jsx(ya,{projectPath:s,fallback:null,className:"size-5"}),e[0]=s,e[1]=f):f=e[1];let m;e[2]!==t?(m=a.jsx("span",{className:"truncate underline decoration-dotted decoration-muted-foreground/50 underline-offset-[6px] transition-colors group-hover/project:decoration-foreground/70 group-data-popup-open/project:decoration-foreground/70",children:t}),e[2]=t,e[3]=m):m=e[3];let p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx(_a,{className:"size-4 shrink-0 text-muted-foreground transition-colors group-hover/project:text-foreground group-data-popup-open/project:text-foreground","aria-hidden":"true"}),e[4]=p):p=e[4];let h;e[5]!==f||e[6]!==m?(h=a.jsxs(Tc,{title:"Switch project",className:"group/project -mx-1 inline-flex max-w-full items-center gap-1.5 rounded-lg px-1.5 align-baseline outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring data-popup-open:bg-accent",children:[f,m,p]}),e[5]=f,e[6]=m,e[7]=h):h=e[7];let g;e[8]!==o?(g=(k,_)=>{u(!1),o(k,_)},e[8]=o,e[9]=g):g=e[9];let x;e[10]!==i?(x=k=>{u(!1),i(k)},e[10]=i,e[11]=x):x=e[11];let b;e[12]===Symbol.for("react.memo_cache_sentinel")?(b=a.jsx("span",{children:"Switch where this session starts"}),e[12]=b):b=e[12];let w;e[13]===Symbol.for("react.memo_cache_sentinel")?(w=a.jsxs("div",{className:"flex items-center justify-between border-t px-3 py-2 text-[11px] text-muted-foreground",children:[b,a.jsx("kbd",{className:"font-mono",children:Qi("newSession")})]}),e[13]=w):w=e[13];let v;e[14]!==l||e[15]!==s||e[16]!==d||e[17]!==g||e[18]!==x?(v=a.jsx(Zx,{align:"center",className:"w-96 max-w-[calc(100vw-2rem)] p-0",children:a.jsx(ixe,{projects:d,currentPath:s,defaultAgentKind:l,onNewSession:g,onNewFolder:x,children:w})}),e[14]=l,e[15]=s,e[16]=d,e[17]=g,e[18]=x,e[19]=v):v=e[19];let j;return e[20]!==c||e[21]!==v||e[22]!==h?(j=a.jsxs(Ec,{open:c,onOpenChange:u,children:[h,v]}),e[20]=c,e[21]=v,e[22]=h,e[23]=j):j=e[23],j}function tv(n){const e=V.c(56),{children:t,sessionLabel:s,customName:r,onDuplicate:o,onDelete:i,onRename:l,onArchive:c,onUnarchive:u,archiveDisabled:d}=n,f=d===void 0?!1:d,[m,p]=y.useState(!1),[h,g]=y.useState(!1),[x,b]=y.useState(""),w=y.useRef(null);let v;e[0]!==r?(v=function(){b(r||""),g(!0),requestAnimationFrame(()=>{var H;return(H=w.current)==null?void 0:H.select()})},e[0]=r,e[1]=v):v=e[1];const j=v;let k;e[2]===Symbol.for("react.memo_cache_sentinel")?(k=a.jsx("div",{className:"w-full"}),e[2]=k):k=e[2];let _;e[3]!==t?(_=a.jsx(Cm,{render:k,children:t}),e[3]=t,e[4]=_):_=e[4];let N;e[5]!==f||e[6]!==c||e[7]!==o||e[8]!==l||e[9]!==u||e[10]!==j?(N=(l||o||c||u)&&a.jsxs(fi,{children:[l&&a.jsxs(Rn,{onClick:j,children:[a.jsx(yr,{"data-icon":"inline-start"}),"Rename session"]}),o&&a.jsxs(Rn,{onClick:o,children:[a.jsx(Es,{"data-icon":"inline-start"}),"Duplicate session"]}),u?a.jsxs(Rn,{onClick:u,children:[a.jsx(Cf,{"data-icon":"inline-start"}),"Restore from archive"]}):c&&a.jsxs(Rn,{onClick:c,disabled:f,children:[a.jsx(Ns,{"data-icon":"inline-start"}),f?"Archive (stop the session first)":"Archive session"]})]}),e[5]=f,e[6]=c,e[7]=o,e[8]=l,e[9]=u,e[10]=j,e[11]=N):N=e[11];let S;e[12]!==c||e[13]!==i||e[14]!==o||e[15]!==l||e[16]!==u?(S=i&&a.jsxs(a.Fragment,{children:[(o||l||c||u)&&a.jsx(ba,{}),a.jsx(fi,{children:a.jsxs(Rn,{variant:"destructive",onClick:()=>p(!0),children:[a.jsx(kf,{"data-icon":"inline-start"}),"Delete session"]})})]}),e[12]=c,e[13]=i,e[14]=o,e[15]=l,e[16]=u,e[17]=S):S=e[17];let C;e[18]!==N||e[19]!==S?(C=a.jsxs(_m,{className:"min-w-44",children:[N,S]}),e[18]=N,e[19]=S,e[20]=C):C=e[20];let E;e[21]!==_||e[22]!==C?(E=a.jsxs(Nm,{children:[_,C]}),e[21]=_,e[22]=C,e[23]=E):E=e[23];let T;e[24]===Symbol.for("react.memo_cache_sentinel")?(T=a.jsx(ib,{children:"Delete session?"}),e[24]=T):T=e[24];let $;e[25]!==s?($=a.jsxs(rb,{children:[T,a.jsxs(ab,{children:["This will permanently delete"," ",a.jsx("span",{className:"font-medium text-foreground",children:s}),". This action cannot be undone."]})]}),e[25]=s,e[26]=$):$=e[26];let A;e[27]===Symbol.for("react.memo_cache_sentinel")?(A=a.jsx(cb,{size:"sm",children:"Cancel"}),e[27]=A):A=e[27];let R;e[28]!==i?(R=a.jsxs(ob,{children:[A,a.jsx(lb,{variant:"destructive",size:"sm",onClick:()=>{i==null||i(),p(!1)},children:"Delete"})]}),e[28]=i,e[29]=R):R=e[29];let P;e[30]!==$||e[31]!==R?(P=a.jsxs(sb,{children:[$,R]}),e[30]=$,e[31]=R,e[32]=P):P=e[32];let z;e[33]!==m||e[34]!==P?(z=a.jsx(nb,{open:m,onOpenChange:p,children:P}),e[33]=m,e[34]=P,e[35]=z):z=e[35];let L;e[36]===Symbol.for("react.memo_cache_sentinel")?(L=a.jsxs(io,{children:[a.jsx(rr,{className:"text-foreground",children:"Rename session"}),a.jsx(or,{className:"text-muted-foreground",children:"Give this session a custom name. Clear to reset to default."})]}),e[36]=L):L=e[36];let I;e[37]!==l||e[38]!==x?(I=W=>{W.preventDefault(),l==null||l(x),g(!1)},e[37]=l,e[38]=x,e[39]=I):I=e[39];let M;e[40]===Symbol.for("react.memo_cache_sentinel")?(M=a.jsx(mn,{htmlFor:"session-rename",children:"Session name"}),e[40]=M):M=e[40];let F;e[41]===Symbol.for("react.memo_cache_sentinel")?(F=W=>b(W.target.value),e[41]=F):F=e[41];let U;e[42]!==x||e[43]!==s?(U=a.jsxs(fn,{children:[M,a.jsx(On,{id:"session-rename",ref:w,value:x,onChange:F,placeholder:s})]}),e[42]=x,e[43]=s,e[44]=U):U=e[44];let O;e[45]===Symbol.for("react.memo_cache_sentinel")?(O=a.jsxs(Px,{children:[a.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:()=>g(!1),children:"Cancel"}),a.jsx(Q,{type:"submit",size:"sm",children:"Save"})]}),e[45]=O):O=e[45];let D;e[46]!==I||e[47]!==U?(D=a.jsxs(sr,{className:"sm:max-w-md",children:[L,a.jsxs("form",{className:"flex flex-col gap-4",onSubmit:I,children:[U,O]})]}),e[46]=I,e[47]=U,e[48]=D):D=e[48];let B;e[49]!==h||e[50]!==D?(B=a.jsx(nr,{open:h,onOpenChange:g,children:D}),e[49]=h,e[50]=D,e[51]=B):B=e[51];let q;return e[52]!==z||e[53]!==B||e[54]!==E?(q=a.jsxs(a.Fragment,{children:[E,z,B]}),e[52]=z,e[53]=B,e[54]=E,e[55]=q):q=e[55],q}function W1(n,e){return Object.freeze({canInteract:n,canOwn:e,send:n,stop:n,answer:n,configure:n,mcp:n,undo:n,archive:e,delete:e})}const ig=W1(!1,!1),uxe={unknown:ig,none:ig,view:ig,interact:W1(!0,!1),own:W1(!0,!0)};function wa(n){return uxe[n]}function Pm(){const n=V.c(3),{enforcesSessionAccess:e}=AN(),t=e===!1?"own":"unknown";let s;return n[0]!==e||n[1]!==t?(s=r=>wa(e!==null&&r?r.level:t),n[0]=e,n[1]=t,n[2]=s):s=n[2],s}function e7(n){const e=V.c(16),{value:t,onChange:s,placeholder:r,loading:o}=n,i=o===void 0?!1:o;let l;e[0]!==i?(l=a.jsx(Tr,{children:i?a.jsx(St,{className:"animate-spin","aria-label":"Searching session history"}):a.jsx(ss,{"aria-hidden":"true"})}),e[0]=i,e[1]=l):l=e[1];let c;e[2]!==s?(c=m=>s(m.target.value),e[2]=s,e[3]=c):c=e[3];let u;e[4]!==i||e[5]!==r||e[6]!==c||e[7]!==t?(u=a.jsx(Go,{type:"search","aria-busy":i,"aria-label":r,value:t,onChange:c,placeholder:r}),e[4]=i,e[5]=r,e[6]=c,e[7]=t,e[8]=u):u=e[8];let d;e[9]!==s||e[10]!==t?(d=t&&a.jsx(Tr,{align:"inline-end",children:a.jsx(dm,{"aria-label":"Clear search",onClick:()=>s(""),size:"icon-xs",children:a.jsx(Mt,{})})}),e[9]=s,e[10]=t,e[11]=d):d=e[11];let f;return e[12]!==l||e[13]!==u||e[14]!==d?(f=a.jsxs(Ko,{className:"w-full sm:max-w-sm",children:[l,u,d]}),e[12]=l,e[13]=u,e[14]=d,e[15]=f):f=e[15],f}function t7(n){const e=V.c(10),{message:t,onRetry:s}=n;let r,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Ir,{"aria-hidden":"true"}),o=a.jsx(tn,{children:"Could not load this data"}),e[0]=r,e[1]=o):(r=e[0],o=e[1]);let i;e[2]!==t?(i=a.jsx(Rt,{children:t}),e[2]=t,e[3]=i):i=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(Fn,{"data-icon":"inline-start"}),e[4]=l):l=e[4];let c;e[5]!==s?(c=a.jsx(Po,{children:a.jsxs(Q,{variant:"ghost",size:"xs",onClick:s,children:[l,"Retry"]})}),e[5]=s,e[6]=c):c=e[6];let u;return e[7]!==i||e[8]!==c?(u=a.jsxs(jt,{variant:"destructive",children:[r,o,i,c]}),e[7]=i,e[8]=c,e[9]=u):u=e[9],u}function n7(n){const e=V.c(5),{count:t,includeMessagePlaceholder:s}=n,r=t===void 0?4:t,o=s===void 0?!1:s;let i;if(e[0]!==r||e[1]!==o){let l;e[3]!==o?(l=(c,u)=>a.jsxs("div",{children:[u>0&&a.jsx(en,{}),a.jsxs("div",{className:"flex items-center gap-3 px-4 py-3.5",children:[a.jsx(Gn,{className:"size-8 shrink-0 rounded-md"}),a.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[a.jsx(Gn,{className:"h-4 w-40 max-w-full"}),o&&a.jsx(Gn,{className:"h-3 w-72 max-w-full"}),a.jsx(Gn,{className:"h-3 w-52 max-w-full"})]}),a.jsx(Gn,{className:"hidden h-5 w-20 sm:block"})]})]},u),e[3]=o,e[4]=l):l=e[4],i=a.jsx("div",{className:"overflow-hidden rounded-lg border","aria-hidden":"true",children:Array.from({length:r},l)}),e[0]=r,e[1]=o,e[2]=i}else i=e[2];return i}function s7(n){const e=V.c(3),{access:t}=n,{SessionBadges:s}=$r();let r;return e[0]!==s||e[1]!==t?(r=s?a.jsx(s,{access:t}):null,e[0]=s,e[1]=t,e[2]=r):r=e[2],r}const Hs={attention:"bg-warning",working:"bg-success ring-2 ring-success/30",idle:"bg-success/40"},dxe=/(?:https?:\/\/)?github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/i,fxe=/^([\w.-]+(?:\/[\w.-]+)?)#(\d+)$/,mxe=/(?:^|\s)#(\d+)(?=\s|$)/,pxe=/^(?:pr|pull\s+request)\s*#?(\d+)$/i;function Gu(n){const e=Number(n);return Number.isSafeInteger(e)&&e>0?e:null}function hxe(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 r7(n){const e=n.trim();if(!e)return null;const t=dxe.exec(e);if(t){const l=Gu(t[3]);return l===null?null:{number:l,repoHint:`${t[1]}/${t[2]}`.toLowerCase()}}const s=fxe.exec(e);if(s){const l=Gu(s[2]);return l===null?null:{number:l,repoHint:s[1].toLowerCase()}}const r=mxe.exec(e);if(r){const l=Gu(r[1]);if(l===null)return null;const c=`${e.slice(0,r.index)} ${e.slice(r.index+r[0].length)}`;return{number:l,repoHint:hxe(c)}}const o=pxe.exec(e);if(!o)return null;const i=Gu(o[1]);return i===null?null:{number:i,repoHint:null}}function Tj(n,e){if(!n)return!1;const t=n.toLowerCase().replace(/\.git$/,"");return t===e||t.endsWith(`/${e}`)||e.endsWith(`/${t}`)}function gxe(n,e){if(!n)return!1;const t=n.toLowerCase().replace(/\.git$/,"").split(/[\\/]/).filter(Boolean).at(-1);if(!t)return!1;const s=t.replace(/[^a-z0-9]/g,"");return e.split("/").some(r=>r.replace(/[^a-z0-9]/g,"")===s)}function xxe(n,e,t=[]){if(n.number!==e.number)return!1;const s=e.repoHint;return s?n.repo&&s.includes("/")?Tj(n.repo,s):Tj(n.repo,s)?!0:t.some(r=>gxe(r,s)):!0}function o7(n,e,t=[]){var o;const s=r7(e);if(s){const i=[n.cwd,n.projectShortName,...t];return((o=n.pullRequests)==null?void 0:o.some(l=>xxe(l,s,i)))??!1}const r=e.trim().toLowerCase();return r?[...t,n.aiTitle,n.name,n.slug,n.customTitle,n.firstUserMessage,n.lastUserMessage,n.model,n.gitBranch,n.agentName,n.teamName,n.sessionId,n.cwd,n.projectShortName].some(i=>i==null?void 0:i.toLowerCase().includes(r)):!0}const bxe=120*1e3;function i7(n){return n?Date.now()-new Date(n).getTime()<bxe:!1}function a7(n,e){const t=n.teamName?n.agentName:"",s=e||n.aiTitle||n.name||t||n.slug||n.firstUserMessage||n.customTitle;return s?Bs(s,70):Bs(n.sessionId,16)}function Aj(n){return n.trim().replace(/\s+/g," ").slice(0,40).toLowerCase()}function vxe(n,e){const t=(n.lastUserMessage||n.firstUserMessage||"").trim();return!t||Aj(t)===Aj(e)?null:Bs(t,220)}function yxe(n,e){return o7(n,e)}function wxe(n,e){if(!n||!e)return null;const t=new Date(e).getTime()-new Date(n).getTime();return t>=6e4?Js(t):null}function Sxe(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(`
470
+ `)}function kxe(n){var t;const e=n.cwd?(t=Nr(n.cwd))==null?void 0:t.worktreeName:void 0;return e?{icon:M8,label:e,title:n.cwd}:n.gitBranch?{icon:Gr,label:n.gitBranch}:null}function jxe(n,e){return n.agentStatus==="deferred"?"attention":e?Qc(n.agentStatus)?"idle":"working":null}function Nxe(n){const e=V.c(20),{session:t,live:s}=n;if(t.agentStatus==="deferred"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Fe,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"Needs review"}),e[0]=r):r=e[0],r}if(s){const r=Qc(t.agentStatus);let o;e[1]!==t.agentPendingAgents||e[2]!==t.agentStatus||e[3]!==t.agentTerminalReason||e[4]!==t.agentToolName?(o=Jc(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??"Active",e[1]=t.agentPendingAgents,e[2]=t.agentStatus,e[3]=t.agentTerminalReason,e[4]=t.agentToolName,e[5]=o):o=e[5];const i=o;let l;e[6]!==t.agentStatus?(l=wm(t.agentStatus),e[6]=t.agentStatus,e[7]=l):l=e[7];const c=r?"bg-success/60":"bg-current";let u;e[8]!==c?(u=G("size-1.5 rounded-full",c),e[8]=c,e[9]=u):u=e[9];let d;e[10]!==u?(d=a.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:u}),e[10]=u,e[11]=d):d=e[11];let f;return e[12]!==i||e[13]!==l||e[14]!==d?(f=a.jsxs(Fe,{variant:"secondary",className:l,children:[d,i]}),e[12]=i,e[13]=l,e[14]=d,e[15]=f):f=e[15],f}if(t.agentTerminalReason){let r;e[16]!==t.agentTerminalReason?(r=Pb(t.agentTerminalReason),e[16]=t.agentTerminalReason,e[17]=r):r=e[17];let o;return e[18]!==r?(o=a.jsx(Fe,{variant:"outline",className:"max-w-44 truncate text-warning",children:r}),e[18]=r,e[19]=o):o=e[19],o}return null}function ag(n){const e=V.c(9),{icon:t,title:s,className:r,children:o}=n;let i;e[0]!==r?(i=G("flex items-center gap-1",r),e[0]=r,e[1]=i):i=e[1];let l;e[2]!==t?(l=a.jsx(t,{className:"size-3 shrink-0"}),e[2]=t,e[3]=l):l=e[3];let c;return e[4]!==o||e[5]!==i||e[6]!==l||e[7]!==s?(c=a.jsxs("span",{className:i,title:s,children:[l,o]}),e[4]=o,e[5]=i,e[6]=l,e[7]=s,e[8]=c):c=e[8],c}function Cxe(n){const e=V.c(103),{session:t,customName:s,onSelect:r}=n,o=t.lastActivityAt||t.lastModified;let i,l;e[0]!==o||e[1]!==t?(i=i7(o),l=jxe(t,i),e[0]=o,e[1]=t,e[2]=i,e[3]=l):(i=e[2],l=e[3]);const c=l,u=t.teamName?t.agentName:void 0;let d,f,m,p,h,g,x,b,w,v,j,k,_,N,S;if(e[4]!==s||e[5]!==c||e[6]!==o||e[7]!==i||e[8]!==r||e[9]!==t||e[10]!==u){const I=kxe(t);let M;e[26]!==o||e[27]!==t.timestamp?(M=wxe(t.timestamp,o),e[26]=o,e[27]=t.timestamp,e[28]=M):M=e[28];const F=M,U=t.turnCount??0;let O,D;e[29]!==s||e[30]!==t?(D=a7(t,s),O=vxe(t,D),e[29]=s,e[30]=t,e[31]=O,e[32]=D):(O=e[31],D=e[32]);const B=O;x="motion-list-item group flex w-full items-start gap-3 px-4 py-3 transition-colors hover:bg-muted/50 focus-within:bg-muted",f="button",m=r,e[33]!==t?(p=Sxe(t),e[33]=t,e[34]=p):p=e[34],h="flex min-w-0 flex-1 items-start gap-3 rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring";let q;e[35]===Symbol.for("react.memo_cache_sentinel")?(q=a.jsx(gg,{className:"size-4"}),e[35]=q):q=e[35];let W;e[36]!==c?(W=c&&a.jsx("span",{"aria-hidden":"true","data-status-dot":c,className:G("absolute -top-1 -right-1 size-2 rounded-full ring-2 ring-card",Hs[c])}),e[36]=c,e[37]=W):W=e[37],e[38]!==W?(g=a.jsxs("span",{className:"relative mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-md border bg-muted/40 text-muted-foreground",children:[q,W]}),e[38]=W,e[39]=g):g=e[39],N="flex min-w-0 flex-1 flex-col gap-1";let H;e[40]!==D?(H=a.jsx("span",{className:"truncate text-sm font-medium",children:D}),e[40]=D,e[41]=H):H=e[41];let K;e[42]!==u?(K=u&&a.jsxs(Fe,{variant:"outline",className:"shrink-0",children:[a.jsx(mi,{"data-icon":"inline-start"}),Bs(u,18)]}),e[42]=u,e[43]=K):K=e[43];let Z;e[44]!==t.branchedFrom?(Z=t.branchedFrom&&a.jsxs(Fe,{variant:"outline",className:"shrink-0",title:"Branched from another session",children:[a.jsx(gx,{"data-icon":"inline-start"}),"branch"]}),e[44]=t.branchedFrom,e[45]=Z):Z=e[45];let Y;e[46]!==i||e[47]!==t?(Y=a.jsx(Nxe,{session:t,live:i}),e[46]=i,e[47]=t,e[48]=Y):Y=e[48];let X;e[49]!==o?(X=o&&a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:Cr(o)}),e[49]=o,e[50]=X):X=e[50];let ee;e[51]!==Y||e[52]!==X?(ee=a.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2",children:[Y,X]}),e[51]=Y,e[52]=X,e[53]=ee):ee=e[53],e[54]!==H||e[55]!==K||e[56]!==Z||e[57]!==ee?(S=a.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[H,K,Z,ee]}),e[54]=H,e[55]=K,e[56]=Z,e[57]=ee,e[58]=S):S=e[58],e[59]!==B?(d=B&&a.jsx("span",{className:"line-clamp-1 text-sm text-muted-foreground",children:B}),e[59]=B,e[60]=d):d=e[60],b="flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",e[61]!==t.access?(w=a.jsx(s7,{access:t.access}),e[61]=t.access,e[62]=w):w=e[62],e[63]!==t.model?(v=t.model&&a.jsx(Fe,{variant:"outline",children:ao(t.model)}),e[63]=t.model,e[64]=v):v=e[64],e[65]!==U?(j=U>0&&a.jsxs(ag,{icon:gg,children:[U," ",U===1?"turn":"turns"]}),e[65]=U,e[66]=j):j=e[66],e[67]!==F?(k=F&&a.jsx(ag,{icon:Io,title:"First prompt to last activity",children:F}),e[67]=F,e[68]=k):k=e[68],_=I&&a.jsx(ag,{icon:I.icon,className:"max-w-40 truncate",title:I.title,children:Bs(I.label,22)}),e[4]=s,e[5]=c,e[6]=o,e[7]=i,e[8]=r,e[9]=t,e[10]=u,e[11]=d,e[12]=f,e[13]=m,e[14]=p,e[15]=h,e[16]=g,e[17]=x,e[18]=b,e[19]=w,e[20]=v,e[21]=j,e[22]=k,e[23]=_,e[24]=N,e[25]=S}else d=e[11],f=e[12],m=e[13],p=e[14],h=e[15],g=e[16],x=e[17],b=e[18],w=e[19],v=e[20],j=e[21],k=e[22],_=e[23],N=e[24],S=e[25];let C;e[69]!==t.size?(C=wN(t.size),e[69]=t.size,e[70]=C):C=e[70];let E;e[71]!==C?(E=a.jsx("span",{children:C}),e[71]=C,e[72]=E):E=e[72];let T;e[73]!==E||e[74]!==b||e[75]!==w||e[76]!==v||e[77]!==j||e[78]!==k||e[79]!==_?(T=a.jsxs("span",{className:b,children:[w,v,j,k,_,E]}),e[73]=E,e[74]=b,e[75]=w,e[76]=v,e[77]=j,e[78]=k,e[79]=_,e[80]=T):T=e[80];let $;e[81]!==d||e[82]!==T||e[83]!==N||e[84]!==S?($=a.jsxs("span",{className:N,children:[S,d,T]}),e[81]=d,e[82]=T,e[83]=N,e[84]=S,e[85]=$):$=e[85];let A;e[86]!==f||e[87]!==m||e[88]!==p||e[89]!==h||e[90]!==g||e[91]!==$?(A=a.jsxs("button",{type:f,onClick:m,title:p,className:h,children:[g,$]}),e[86]=f,e[87]=m,e[88]=p,e[89]=h,e[90]=g,e[91]=$,e[92]=A):A=e[92];let R;e[93]!==t.matchedPullRequestNumber||e[94]!==t.pullRequests?(R=t.matchedPullRequestNumber?a.jsxs(Fe,{variant:"outline",children:["Matched #",t.matchedPullRequestNumber]}):a.jsx(su,{pullRequests:t.pullRequests,max:2,compact:!0}),e[93]=t.matchedPullRequestNumber,e[94]=t.pullRequests,e[95]=R):R=e[95];let P;e[96]===Symbol.for("react.memo_cache_sentinel")?(P=a.jsx(it,{className:"size-4 text-muted-foreground transition-transform group-hover:translate-x-0.5"}),e[96]=P):P=e[96];let z;e[97]!==R?(z=a.jsxs("span",{className:"flex shrink-0 items-center gap-2 pt-1.5",children:[R,P]}),e[97]=R,e[98]=z):z=e[98];let L;return e[99]!==x||e[100]!==A||e[101]!==z?(L=a.jsxs("div",{className:x,children:[A,z]}),e[99]=x,e[100]=A,e[101]=z,e[102]=L):L=e[102],L}function _xe(n){const e=V.c(63),{selectedProject:t,filterEmpty:s,sessions:r,sessionsTotal:o,sessionsLoading:i,searchLoading:l,searchFilter:c,setSearchFilter:u,filteredSessions:d,fetchError:f,onSelectSession:m,onNewSession:p,creatingSession:h,onDuplicateSession:g,onDeleteSession:x,onBack:b,onRetryFetch:w,loadMoreSessions:v}=n,{names:j,rename:k}=Ff(),_=Pm();let N;e[0]!==t.path?(N=_r(t.path),e[0]=t.path,e[1]=N):N=e[1];const S=N;let C;e[2]!==b?(C=a.jsx(U1,{children:a.jsx(ZI,{render:a.jsx("button",{type:"button",onClick:b}),children:"Projects"})}),e[2]=b,e[3]=C):C=e[3];let E;e[4]===Symbol.for("react.memo_cache_sentinel")?(E=a.jsx(XI,{}),e[4]=E):E=e[4];let T;e[5]!==S?(T=a.jsx(U1,{className:"min-w-0",children:a.jsx(YI,{className:"truncate",children:S})}),e[5]=S,e[6]=T):T=e[6];let $;e[7]!==C||e[8]!==T?($=a.jsx(KI,{children:a.jsxs(GI,{children:[C,E,T]})}),e[7]=C,e[8]=T,e[9]=$):$=e[9];let A;e[10]!==S?(A=a.jsx("h1",{className:"truncate text-2xl font-semibold tracking-tight",children:S}),e[10]=S,e[11]=A):A=e[11];let R;e[12]!==o?(R=a.jsx(Fe,{variant:"secondary",children:o}),e[12]=o,e[13]=R):R=e[13];let P;e[14]!==A||e[15]!==R?(P=a.jsxs("div",{className:"flex items-center gap-2",children:[A,R]}),e[14]=A,e[15]=R,e[16]=P):P=e[16];let z;e[17]!==t.path?(z=jc(t.path),e[17]=t.path,e[18]=z):z=e[18];let L;e[19]!==z?(L=a.jsx("p",{className:"truncate text-sm text-muted-foreground",children:z}),e[19]=z,e[20]=L):L=e[20];let I;e[21]!==L||e[22]!==P?(I=a.jsxs("header",{className:"flex min-w-0 flex-col gap-1",children:[P,L]}),e[21]=L,e[22]=P,e[23]=I):I=e[23];let M;e[24]!==c||e[25]!==l||e[26]!==u?(M=a.jsx(e7,{value:c,onChange:u,placeholder:"Search sessions or PRs...",loading:l}),e[24]=c,e[25]=l,e[26]=u,e[27]=M):M=e[27];let F;e[28]!==h||e[29]!==p||e[30]!==t.dirName||e[31]!==t.path?(F=p&&a.jsxs(Q,{size:"sm",disabled:h,onClick:()=>p(t.dirName,t.path),children:[h?a.jsx(Pn,{"data-icon":"inline-start"}):a.jsx(Sr,{"data-icon":"inline-start"}),"New Session"]}),e[28]=h,e[29]=p,e[30]=t.dirName,e[31]=t.path,e[32]=F):F=e[32];let U;e[33]!==M||e[34]!==F?(U=a.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[M,F]}),e[33]=M,e[34]=F,e[35]=U):U=e[35];let O;e[36]!==f||e[37]!==w?(O=f&&a.jsx(t7,{message:f,onRetry:w}),e[36]=f,e[37]=w,e[38]=O):O=e[38];let D;e[39]!==s||e[40]!==d||e[41]!==v||e[42]!==x||e[43]!==g||e[44]!==m||e[45]!==_||e[46]!==k||e[47]!==c||e[48]!==l||e[49]!==t.dirName||e[50]!==j||e[51]!==r||e[52]!==i||e[53]!==o?(D=(i||l)&&d.length===0?a.jsx(n7,{includeMessagePlaceholder:!0}):d.length===0?a.jsx(Exe,{searchFilter:c,filterEmpty:s}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"overflow-hidden rounded-lg border bg-card",children:d.map((W,H)=>a.jsxs(y.Fragment,{children:[H>0&&a.jsx(en,{}),a.jsx(tv,{sessionLabel:a7(W),customName:j[W.sessionId],onRename:K=>k(W.sessionId,K),onDuplicate:g?()=>g(t.dirName,W.fileName):void 0,onDelete:x&&_(W.access).delete?()=>x(t.dirName,W.fileName):void 0,children:a.jsx(Cxe,{session:W,customName:j[W.sessionId],onSelect:()=>m(t.dirName,W.fileName)})})]},W.fileName))}),r.length<o&&!c&&a.jsx("div",{className:"flex justify-center",children:a.jsxs(Q,{variant:"outline",size:"sm",disabled:i,onClick:v,children:[i&&a.jsx(Pn,{"data-icon":"inline-start"}),i?"Loading...":"Load more sessions"]})})]}),e[39]=s,e[40]=d,e[41]=v,e[42]=x,e[43]=g,e[44]=m,e[45]=_,e[46]=k,e[47]=c,e[48]=l,e[49]=t.dirName,e[50]=j,e[51]=r,e[52]=i,e[53]=o,e[54]=D):D=e[54];let B;e[55]!==U||e[56]!==O||e[57]!==D?(B=a.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Sessions",children:[U,O,D]}),e[55]=U,e[56]=O,e[57]=D,e[58]=B):B=e[58];let q;return e[59]!==I||e[60]!==B||e[61]!==$?(q=a.jsx(Vc,{className:"h-full",children:a.jsxs("main",{className:"mx-auto flex max-w-6xl flex-col gap-6 px-4 py-6 sm:px-6 sm:pb-10 sm:pt-14",children:[$,I,B]})}),e[59]=I,e[60]=B,e[61]=$,e[62]=q):q=e[62],q}function Exe(n){const e=V.c(8),{searchFilter:t,filterEmpty:s}=n;if(!t&&s)return s;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Yn,{variant:"icon",children:a.jsx(vc,{})}),e[0]=r):r=e[0];const o=t?"No sessions match your search":"No sessions yet";let i;e[1]!==o?(i=a.jsx(zn,{children:o}),e[1]=o,e[2]=i):i=e[2];const l=t?"Try #157, honest-cms #157, or paste a PR URL.":"Start a session in this project and it will appear here.";let c;e[3]!==l?(c=a.jsx(Dn,{children:l}),e[3]=l,e[4]=c):c=e[4];let u;return e[5]!==i||e[6]!==c?(u=a.jsx(Ln,{className:"min-h-72 border",children:a.jsxs(Mn,{children:[r,i,c]})}),e[5]=i,e[6]=c,e[7]=u):u=e[7],u}function l7(n){const e=V.c(40),{children:t,projectLabel:s,customName:r,className:o,onRename:i,archivableCount:l,onArchiveIdle:c}=n,u=l===void 0?0:l,[d,f]=y.useState(!1),[m,p]=y.useState(""),h=y.useRef(null);let g;e[0]!==r?(g=function(){p(r||""),f(!0),requestAnimationFrame(()=>{var M;return(M=h.current)==null?void 0:M.select()})},e[0]=r,e[1]=g):g=e[1];const x=g;let b;e[2]!==o?(b=G("w-full",o),e[2]=o,e[3]=b):b=e[3];let w;e[4]!==b?(w=a.jsx("div",{className:b}),e[4]=b,e[5]=w):w=e[5];let v;e[6]!==t||e[7]!==w?(v=a.jsx(Cm,{render:w,children:t}),e[6]=t,e[7]=w,e[8]=v):v=e[8];let j;e[9]===Symbol.for("react.memo_cache_sentinel")?(j=a.jsx(yr,{"data-icon":"inline-start"}),e[9]=j):j=e[9];let k;e[10]!==x?(k=a.jsx(fi,{children:a.jsxs(Rn,{onClick:x,children:[j,"Rename project"]})}),e[10]=x,e[11]=k):k=e[11];let _;e[12]!==u||e[13]!==c?(_=c&&a.jsxs(a.Fragment,{children:[a.jsx(ba,{}),a.jsx(fi,{children:a.jsxs(Rn,{onClick:c,disabled:u===0,children:[a.jsx(Ns,{"data-icon":"inline-start"}),u>0?`Archive ${u} idle ${u===1?"session":"sessions"}`:"Archive idle sessions"]})})]}),e[12]=u,e[13]=c,e[14]=_):_=e[14];let N;e[15]!==k||e[16]!==_?(N=a.jsxs(_m,{className:"min-w-44",children:[k,_]}),e[15]=k,e[16]=_,e[17]=N):N=e[17];let S;e[18]!==v||e[19]!==N?(S=a.jsxs(Nm,{children:[v,N]}),e[18]=v,e[19]=N,e[20]=S):S=e[20];let C;e[21]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsxs(io,{children:[a.jsx(rr,{className:"text-foreground",children:"Rename project"}),a.jsx(or,{className:"text-muted-foreground",children:"Give this project a custom name. Clear to reset to default."})]}),e[21]=C):C=e[21];let E;e[22]!==i||e[23]!==m?(E=I=>{I.preventDefault(),i(m),f(!1)},e[22]=i,e[23]=m,e[24]=E):E=e[24];let T;e[25]===Symbol.for("react.memo_cache_sentinel")?(T=a.jsx(mn,{htmlFor:"project-rename",children:"Project name"}),e[25]=T):T=e[25];let $;e[26]===Symbol.for("react.memo_cache_sentinel")?($=I=>p(I.target.value),e[26]=$):$=e[26];let A;e[27]!==s||e[28]!==m?(A=a.jsxs(fn,{children:[T,a.jsx(On,{id:"project-rename",ref:h,value:m,onChange:$,placeholder:s})]}),e[27]=s,e[28]=m,e[29]=A):A=e[29];let R;e[30]===Symbol.for("react.memo_cache_sentinel")?(R=a.jsxs(Px,{children:[a.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:()=>f(!1),children:"Cancel"}),a.jsx(Q,{type:"submit",size:"sm",children:"Save"})]}),e[30]=R):R=e[30];let P;e[31]!==E||e[32]!==A?(P=a.jsxs(sr,{className:"sm:max-w-md",children:[C,a.jsxs("form",{className:"flex flex-col gap-4",onSubmit:E,children:[A,R]})]}),e[31]=E,e[32]=A,e[33]=P):P=e[33];let z;e[34]!==d||e[35]!==P?(z=a.jsx(nr,{open:d,onOpenChange:f,children:P}),e[34]=d,e[35]=P,e[36]=z):z=e[36];let L;return e[37]!==S||e[38]!==z?(L=a.jsxs(a.Fragment,{children:[S,z]}),e[37]=S,e[38]=z,e[39]=L):L=e[39],L}function Txe(n){const e=V.c(47),{projects:t,activeSessions:s,loading:r,refreshing:o,searchFilter:i,setSearchFilter:l,fetchError:c,selectedProjectDirName:u,onSelectProject:d,onRefresh:f}=n;let m;if(e[0]!==s){m={};for(const I of s)i7(I.lastModified)&&(m[I.dirName]=(m[I.dirName]||0)+1);e[0]=s,e[1]=m}else m=e[1];const p=m,{names:h,rename:g}=ev();let x;e[2]!==t?(x=JI(t),e[2]=t,e[3]=x):x=e[3];const b=x;let w;e:{if(!i){w=b;break e}let I;if(e[4]!==h||e[5]!==b||e[6]!==i){const M=i.toLowerCase(),F=U=>{var O;return U.path.toLowerCase().includes(M)||U.shortName.toLowerCase().includes(M)||((O=h[U.dirName])==null?void 0:O.toLowerCase().includes(M))};I=b.filter(U=>F(U)||U.worktrees.some(F)),e[4]=h,e[5]=b,e[6]=i,e[7]=I}else I=e[7];w=I}const v=w;let j;e[8]===Symbol.for("react.memo_cache_sentinel")?(j=a.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Projects"}),e[8]=j):j=e[8];let k;e[9]!==b.length?(k=a.jsxs("div",{className:"flex items-center gap-2",children:[j,a.jsx(Fe,{variant:"secondary",children:b.length})]}),e[9]=b.length,e[10]=k):k=e[10];let _;e[11]===Symbol.for("react.memo_cache_sentinel")?(_=a.jsx("p",{className:"text-sm text-muted-foreground",children:"Open a project to browse and resume its sessions."}),e[11]=_):_=e[11];let N;e[12]!==k?(N=a.jsxs("header",{className:"flex flex-col gap-1",children:[k,_]}),e[12]=k,e[13]=N):N=e[13];let S;e[14]!==i||e[15]!==l?(S=a.jsx(e7,{value:i,onChange:l,placeholder:"Filter projects..."}),e[14]=i,e[15]=l,e[16]=S):S=e[16];const C=o&&"animate-spin";let E;e[17]!==C?(E=G(C),e[17]=C,e[18]=E):E=e[18];let T;e[19]!==E?(T=a.jsx(Fn,{"data-icon":"inline-start",className:E}),e[19]=E,e[20]=T):T=e[20];let $;e[21]!==f||e[22]!==o||e[23]!==T?($=a.jsxs(Q,{variant:"outline",size:"sm",onClick:f,disabled:o,"aria-label":"Refresh projects",children:[T,"Refresh"]}),e[21]=f,e[22]=o,e[23]=T,e[24]=$):$=e[24];let A;e[25]!==$||e[26]!==S?(A=a.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[S,$]}),e[25]=$,e[26]=S,e[27]=A):A=e[27];let R;e[28]!==c||e[29]!==f||e[30]!==u?(R=c&&!u&&a.jsx(t7,{message:c,onRetry:f}),e[28]=c,e[29]=f,e[30]=u,e[31]=R):R=e[31];let P;e[32]!==p||e[33]!==v||e[34]!==r||e[35]!==d||e[36]!==h||e[37]!==g||e[38]!==i?(P=r?a.jsx(n7,{}):v.length===0?a.jsxs(Ln,{className:"min-h-72 border",children:[a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:a.jsx(Zr,{})}),a.jsx(zn,{children:i?"No projects match your search":"No projects yet"}),a.jsx(Dn,{children:i?"Try a project name or path.":"Start Claude Code, Codex, or Copilot and its project will appear here."})]}),!i&&a.jsx(_c,{children:a.jsxs(Q,{variant:"outline",size:"sm",onClick:Axe,children:[a.jsx(wc,{"data-icon":"inline-start"}),"Start in a folder"]})})]}):a.jsx("div",{className:"overflow-hidden rounded-lg border bg-card",children:v.map((I,M)=>{const F=p[I.dirName]||0,U=h[I.dirName],O=kM(un(I.dirName));return a.jsxs(y.Fragment,{children:[M>0&&a.jsx(en,{}),a.jsx(l7,{projectLabel:_r(I.path),customName:U,onRename:D=>g(I.dirName,D),children:a.jsxs("button",{type:"button",onClick:()=>d==null?void 0:d(I.dirName),className:"motion-list-item group flex w-full flex-col gap-3 px-4 py-3.5 text-left outline-none transition-colors hover:bg-muted/50 focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset sm:flex-row sm:items-center",children:[a.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-3",children:[a.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-md border bg-muted/40",children:a.jsx(ya,{projectPath:I.path,className:"size-4",fallback:a.jsx(Zr,{className:"size-4 text-muted-foreground"})})}),a.jsxs("span",{className:"min-w-0",children:[a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"truncate text-sm font-medium",children:U||_r(I.path)}),O&&a.jsx(Fe,{variant:"outline",className:"h-5 shrink-0 px-1.5 text-[10px]",children:O})]}),a.jsxs("span",{className:"block truncate text-xs text-muted-foreground",children:[jc(I.path),I.worktrees.length>0&&a.jsxs(a.Fragment,{children:[" · ",I.worktrees.length," ",I.worktrees.length===1?"worktree":"worktrees"]})]})]})]}),a.jsxs("span",{className:"flex items-center gap-4 pl-11 text-sm text-muted-foreground sm:pl-0",children:[F>0&&a.jsxs(Fe,{variant:"secondary",children:[a.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:"size-1.5 rounded-full bg-success"}),F," active"]}),a.jsxs("span",{className:"whitespace-nowrap",children:[I.sessionCount," ",I.sessionCount===1?"session":"sessions"]}),I.lastModified&&a.jsx("span",{className:"hidden w-24 whitespace-nowrap text-right md:inline",children:Cr(I.lastModified)}),a.jsx(it,{className:"size-4 shrink-0 transition-transform group-hover:translate-x-0.5"})]})]})}),I.worktrees.map(D=>a.jsx(Ixe,{worktree:D,customName:h[D.dirName],activeCount:p[D.dirName]||0,onSelect:()=>d==null?void 0:d(D.dirName)},D.dirName))]},I.dirName)})}),e[32]=p,e[33]=v,e[34]=r,e[35]=d,e[36]=h,e[37]=g,e[38]=i,e[39]=P):P=e[39];let z;e[40]!==A||e[41]!==R||e[42]!==P?(z=a.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Projects",children:[A,R,P]}),e[40]=A,e[41]=R,e[42]=P,e[43]=z):z=e[43];let L;return e[44]!==z||e[45]!==N?(L=a.jsx(Vc,{className:"h-full",children:a.jsxs("main",{className:"mx-auto flex max-w-6xl flex-col gap-6 px-4 py-6 sm:px-6 sm:pb-10 sm:pt-14",children:[N,z]})}),e[44]=z,e[45]=N,e[46]=L):L=e[46],L}function Axe(){return EI()}function Ixe(n){var b;const e=V.c(23),{worktree:t,customName:s,activeCount:r,onSelect:o}=n;let i;e[0]!==s||e[1]!==t.path?(i=s||((b=Nr(t.path))==null?void 0:b.worktreeName)||_r(t.path),e[0]=s,e[1]=t.path,e[2]=i):i=e[2];const l=i;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx(Gr,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[3]=c):c=e[3];let u;e[4]!==l?(u=a.jsx("span",{className:"min-w-0 flex-1 truncate text-muted-foreground group-hover:text-foreground",children:l}),e[4]=l,e[5]=u):u=e[5];let d;e[6]!==r?(d=r>0&&a.jsxs(Fe,{variant:"secondary",children:[a.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:"size-1.5 rounded-full bg-success"}),r," active"]}),e[6]=r,e[7]=d):d=e[7];const f=t.sessionCount===1?"session":"sessions";let m;e[8]!==f||e[9]!==t.sessionCount?(m=a.jsxs("span",{className:"whitespace-nowrap",children:[t.sessionCount," ",f]}),e[8]=f,e[9]=t.sessionCount,e[10]=m):m=e[10];let p;e[11]!==t.lastModified?(p=t.lastModified&&a.jsx("span",{className:"hidden w-24 whitespace-nowrap text-right md:inline",children:Cr(t.lastModified)}),e[11]=t.lastModified,e[12]=p):p=e[12];let h;e[13]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx(it,{className:"size-4 shrink-0 transition-transform group-hover:translate-x-0.5"}),e[13]=h):h=e[13];let g;e[14]!==d||e[15]!==m||e[16]!==p?(g=a.jsxs("span",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[d,m,p,h]}),e[14]=d,e[15]=m,e[16]=p,e[17]=g):g=e[17];let x;return e[18]!==o||e[19]!==u||e[20]!==g||e[21]!==t.path?(x=a.jsxs("button",{type:"button",onClick:o,title:t.path,className:"motion-list-item group flex w-full items-center gap-3 py-2 pl-15 pr-4 text-left text-sm outline-none transition-colors hover:bg-muted/50 focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",children:[c,u,g]}),e[18]=o,e[19]=u,e[20]=g,e[21]=t.path,e[22]=x):x=e[22],x}const Pxe=250,$xe=400,Ij={results:null,loading:!1,error:null};function c7(n,e,t){const s=y.useMemo(()=>r7(n),[n]),[r,o]=y.useState(0),[i,l]=y.useState(Ij);y.useEffect(()=>{if(!s){l(Ij);return}const d=new AbortController;l({results:null,loading:!0,error:null});let f=null;const m=async()=>{const h=new URLSearchParams({search:n.trim(),limit:"200"});t&&h.set("project",t);const g=Xr();try{const x=await Ce(zf(h,e),{signal:d.signal});if(!x.ok)throw new Error(`Search failed (${x.status})`);const b=await x.json();if(d.signal.aborted)return;const w=Number(x.headers.get("X-Cogpit-PR-Index-Pending")??"0");if(Number.isFinite(w)&&w>0){f=setTimeout(()=>{m()},$xe);return}const v=Array.isArray(b)?b:[];aa(v,g),l({results:v,loading:!1,error:null})}catch(x){if(d.signal.aborted)return;l({results:[],loading:!1,error:x instanceof Error?x.message:"Search failed"})}},p=setTimeout(()=>{m()},Pxe);return()=>{clearTimeout(p),f&&clearTimeout(f),d.abort()}},[e,t,s,n,r]);const c=y.useCallback(()=>o(d=>d+1),[]),u=s!==null;return y.useEffect(()=>{if(u)return Df(c)},[u,c]),{...i,active:u,refresh:c}}const Rxe=y.memo(function({onSelectSession:e,onNewSession:t,creatingSession:s,selectedProjectDirName:r,onSelectProject:o,onDuplicateSession:i,onDeleteSession:l}){var se;const c=Mf(),u=(se=$r().sessionListFilter)==null?void 0:se.Empty,[d]=y.useState(()=>({projects:Gi(Ql.projects),activeSessions:Gi(td(c.key))})),[f,m]=y.useState(d.projects??[]),[p,h]=y.useState(d.activeSessions??[]),[g,x]=y.useState(d.projects===void 0),[b,w]=y.useState(!1),[v,j]=y.useState(null),[k,_]=y.useState(null),[N,S]=y.useState([]),[C,E]=y.useState(0),[T,$]=y.useState(1),[A,R]=y.useState(!1),[P,z]=y.useState(""),[L,I]=y.useState(null),M=y.useRef(0),F=y.useRef(null),U=y.useRef(null),O=y.useRef(c.key),D=y.useCallback(async()=>{try{const J=await Ce("/api/projects");if(!J.ok)throw new Error("Failed to fetch dashboard data");const ne=await J.json(),ie=Array.isArray(ne)?ne:[];m(ie),_l(Ql.projects,ie),j(null)}catch(J){j(J instanceof Error?J.message:"Failed to load data")}finally{x(!1)}},[]),B=y.useCallback(async()=>{var ie;(ie=U.current)==null||ie.abort();const J=new AbortController;U.current=J;const ne=Xr();try{const ae=await Ce(zf({},c),{signal:J.signal});if(!ae.ok)throw new Error("Failed to fetch dashboard data");const oe=await ae.json();if(J.signal.aborted)return;const ue=Array.isArray(oe)?oe:[];aa(ue,ne),h(ue),_l(td(c.key),ue),_(null)}catch(ae){if(J.signal.aborted)return;_(ae instanceof Error?ae.message:"Failed to load data")}},[c]);y.useEffect(()=>{D()},[D]),y.useEffect(()=>{O.current!==c.key&&(O.current=c.key,h(Gi(td(c.key))??[])),B()},[c,B]);async function q(){w(!0),await Promise.all([D(),B()]),w(!1)}const W=y.useCallback(async(J,ne=1,ie=!1)=>{var de;const ae=++M.current;(de=F.current)==null||de.abort();const oe=new AbortController;F.current=oe;const ue=()=>ae===M.current;R(!0),I(null);const re=Xr();if(!ie){const fe=D9(J,c.key);fe?(S(fe.sessions),E(fe.total),$(1)):S([])}try{const fe=await Ce(El(`/api/sessions/${encodeURIComponent(J)}`,c,{page:String(ne),limit:"20"}),{signal:oe.signal});if(!fe.ok)throw new Error(`Failed to load sessions (${fe.status})`);const le=await fe.json();if(!ue())return;const ce=Array.isArray(le.sessions)?le.sessions:[],he=typeof le.total=="number"?le.total:ce.length;aa(ce,re),S(ge=>ie?[...ge,...ce]:ce),E(he),$(ne),ie||F9(J,c.key,{sessions:ce,total:he})}catch(fe){if(!ue()||oe.signal.aborted)return;I(fe instanceof Error?fe.message:"Failed to load sessions")}finally{ue()&&(F.current=null,R(!1))}},[c]);y.useEffect(()=>{var J;if(!r){M.current+=1,(J=F.current)==null||J.abort(),F.current=null,S([]),E(0),$(1),R(!1);return}W(r)},[r,W]),y.useEffect(()=>{z("")},[r]),y.useEffect(()=>()=>{var J,ne;M.current+=1,(J=F.current)==null||J.abort(),(ne=U.current)==null||ne.abort()},[]),y.useEffect(()=>Df(()=>{B(),r&&W(r)}),[B,W,r]);const H=y.useMemo(()=>{if(!r)return null;const J=f.find(ie=>ie.dirName===r);if(J)return J;const ne=xs(r);return{dirName:r,path:ne,shortName:_r(ne),sessionCount:C,lastModified:null}},[r,f,C]),K=y.useCallback(()=>{o==null||o(null)},[o]),Z=y.useCallback(()=>{r&&W(r,T+1,!0)},[r,T,W]),Y=c7(r?P:"",c,r??void 0),X=y.useMemo(()=>P?N.filter(J=>yxe(J,P)):N,[N,P]),ee=Y.results??X;async function te(J,ne){await(l==null?void 0:l(J,ne))&&(S(ie=>ie.filter(ae=>ae.fileName!==ne)),E(ie=>ie-1))}return H?a.jsx(_xe,{selectedProject:H,filterEmpty:c.key!==null&&u?a.jsx(u,{className:"min-h-72 border"}):null,sessions:N,sessionsTotal:C,sessionsLoading:A,searchLoading:Y.loading,searchFilter:P,setSearchFilter:z,filteredSessions:ee,fetchError:Y.error??L,onSelectSession:e,onNewSession:t,creatingSession:s,onDuplicateSession:i,onDeleteSession:te,onBack:K,onRetryFetch:()=>{if(Y.error){Y.refresh();return}I(null),r&&W(r)},loadMoreSessions:Z}):a.jsx(Txe,{projects:f,activeSessions:p,loading:g,refreshing:b,searchFilter:P,setSearchFilter:z,fetchError:v??k,selectedProjectDirName:r??null,onSelectProject:o,onRefresh:()=>void q()})}),Pj=768;function nv(){const n=V.c(2),[e,t]=y.useState(typeof window<"u"?window.innerWidth<Pj:!1);let s,r;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{const o=window.matchMedia(`(max-width: ${Pj-1}px)`),i=l=>t(l.matches);return o.addEventListener("change",i),t(o.matches),()=>o.removeEventListener("change",i)},r=[],n[0]=s,n[1]=r):(s=n[0],r=n[1]),y.useEffect(s,r),e}const u7=typeof navigator<"u"&&"vibrate"in navigator;function q1(){u7&&navigator.vibrate(10)}function Oxe(){u7&&navigator.vibrate(20)}function Lxe(n){return!!(n.teamName&&n.agentName)}function Mxe(n,e,t,s,r,o,i,l=()=>!0){const c=[],u=[];for(const d of Aa(n)){const f=p=>{l(d)&&c.push({session:d,reason:p})};if(s!=null&&s.has(d.sessionId)){f("permission");continue}if(r!=null&&r.has(d.sessionId)){f("question");continue}if(o!=null&&o.has(d.sessionId)){f("prompt");continue}if(i!=null&&i.has(d.sessionId)){f("plan");continue}if(d.agentStatus==="deferred"){f("deferred");continue}if(Lxe(d))continue;const m=Mx(d,e);if(d.agentStatus==="completed"||!m){t.has(d.sessionId)&&f("done");continue}if(d.agentStatus==="idle"){f("waiting");continue}(!d.agentStatus||$f.has(d.agentStatus))&&u.push(d)}return{needsYou:c,working:u}}function zxe(n,e,t,s,r=()=>!0){const o=[...n.needsYou],i=[...n.working],l=new Map;for(const u of e){const d=t.get(u.sessionId);if(!(d!=null&&d.length))continue;const f=Dx(d,p=>{const h=s(p);return h.state==="needs-you"&&!r(p)?{state:"done"}:h}),m=o.findIndex(p=>p.session.sessionId===u.sessionId);if(f.needsYou>0)if(m>=0)o[m]={...o[m],crew:f};else{o.push({session:u,reason:"crew",crew:f});const p=i.indexOf(u);p>=0&&i.splice(p,1)}else f.working>0&&m<0&&!i.includes(u)&&(i.push(u),l.set(u.sessionId,f))}const c=u=>{var d;return u.reason==="crew"&&((d=u.crew)!=null&&d.longestWaitSince)?Date.parse(u.crew.longestWaitSince):jr(u.session)};return o.sort((u,d)=>c(d)-c(u)),{needsYou:o,working:Aa(i),workingCrews:l}}function d7(n){switch(n.agentStatus){case"tool_use":return n.agentToolName||"Tool";case"thinking":return"Thinking";case"processing":return"Processing";case"compacting":return"Compacting";case"awaiting_agents":return"Agents running";default:return"Running"}}const f7="aw:turnCounts",Dxe=200,$m=new Map;try{const n=localStorage.getItem(f7);if(n){const e=JSON.parse(n);for(const[t,s]of e)$m.set(t,s)}}catch{}function Fxe(){try{const n=[...$m.entries()].slice(-Dxe);localStorage.setItem(f7,JSON.stringify(n))}catch{}}function Uxe(n,e){$m.set(sn(n),e),Fxe()}function m7(n,e){const t=$m.get(sn(n));return Math.max(t??0,e??0)}function sv(n){const e=V.c(51),{session:t,proc:s,statusLabel:r,customName:o,worktreeName:i,projectLabel:l}=n,c=o||t.aiTitle,u=t.firstUserMessage,d=t.lastUserMessage&&t.lastUserMessage!==u?t.lastUserMessage:void 0,f=m7(t.sessionId,t.turnCount);let m;e[0]!==c?(m=c&&a.jsx("span",{className:"font-medium leading-snug text-foreground",children:c}),e[0]=c,e[1]=m):m=e[1];let p;e[2]!==l?(p=l&&a.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[a.jsx(sa,{className:"size-3 shrink-0"}),a.jsx("span",{className:"truncate",children:l})]}),e[2]=l,e[3]=p):p=e[3];let h;e[4]!==t.agentStatus||e[5]!==r?(h=r&&a.jsx("span",{className:G("font-medium",wm(t.agentStatus)),children:r}),e[4]=t.agentStatus,e[5]=r,e[6]=h):h=e[6];let g;e[7]!==t.agentName||e[8]!==t.teamName?(g=t.teamName&&t.agentName&&a.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[a.jsx(er,{className:"size-3"}),t.agentName," · ",t.teamName]}),e[7]=t.agentName,e[8]=t.teamName,e[9]=g):g=e[9];let x;e[10]!==t.archived||e[11]!==t.archivedReason?(x=t.archived&&a.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[a.jsx(Ns,{className:"size-3"}),Ox(t.archivedReason)]}),e[10]=t.archived,e[11]=t.archivedReason,e[12]=x):x=e[12];let b;e[13]!==u||e[14]!==d?(b=u&&a.jsxs("div",{className:"flex flex-col gap-0.5",children:[d&&a.jsx("span",{className:"text-[10px] text-muted-foreground/70",children:"Started with"}),a.jsx("div",{className:"border-l-2 pl-2 text-muted-foreground",children:a.jsx("span",{"data-first-prompt":!0,className:"line-clamp-8 leading-relaxed",children:u})})]}),e[13]=u,e[14]=d,e[15]=b):b=e[15];let w;e[16]!==d?(w=d&&a.jsxs("div",{className:"flex flex-col gap-0.5",children:[a.jsx("span",{className:"text-[10px] text-muted-foreground/70",children:"Latest"}),a.jsx("div",{className:"border-l-2 pl-2 text-muted-foreground",children:a.jsx("span",{"data-last-prompt":!0,className:"line-clamp-4 leading-relaxed",children:d})})]}),e[16]=d,e[17]=w):w=e[17];let v;e[18]!==t.pullRequests?(v=a.jsx(su,{pullRequests:t.pullRequests,layout:"list"}),e[18]=t.pullRequests,e[19]=v):v=e[19];let j;e[20]!==t.gitBranch||e[21]!==i?(j=t.gitBranch&&a.jsxs("span",{className:"flex items-center gap-0.5",children:[a.jsx(Gr,{className:"size-2.5"}),i?`${t.gitBranch} · ${i}`:t.gitBranch]}),e[20]=t.gitBranch,e[21]=i,e[22]=j):j=e[22];let k;e[23]!==f?(k=f>0&&a.jsxs("span",{className:"flex items-center gap-0.5",children:[a.jsx(vc,{className:"size-2.5"}),f," ",f===1?"turn":"turns"]}),e[23]=f,e[24]=k):k=e[24];let _;e[25]!==t.size?(_=wN(t.size),e[25]=t.size,e[26]=_):_=e[26];let N;e[27]!==_?(N=a.jsx("span",{children:_}),e[27]=_,e[28]=N):N=e[28];let S;e[29]!==s?(S=s&&a.jsxs("span",{className:"flex items-center gap-0.5 text-success",children:[a.jsx(z8,{className:"size-2.5"}),s.memMB," MB"]}),e[29]=s,e[30]=S):S=e[30];const C=t.lastActivityAt||t.lastModified;let E;e[31]!==C?(E=Cr(C),e[31]=C,e[32]=E):E=e[32];let T;e[33]!==E?(T=a.jsx("span",{children:E}),e[33]=E,e[34]=T):T=e[34];let $;e[35]!==k||e[36]!==N||e[37]!==S||e[38]!==T||e[39]!==j?($=a.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-muted-foreground",children:[j,k,N,S,T]}),e[35]=k,e[36]=N,e[37]=S,e[38]=T,e[39]=j,e[40]=$):$=e[40];let A;return e[41]!==m||e[42]!==$||e[43]!==p||e[44]!==h||e[45]!==g||e[46]!==x||e[47]!==b||e[48]!==w||e[49]!==v?(A=a.jsxs("div",{className:"flex w-72 flex-col gap-2 text-xs",children:[m,p,h,g,x,b,w,v,$]}),e[41]=m,e[42]=$,e[43]=p,e[44]=h,e[45]=g,e[46]=x,e[47]=b,e[48]=w,e[49]=v,e[50]=A):A=e[50],A}const Bxe=120;function rv(n){const e=V.c(7),t=y.useRef(null);let s,r;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>()=>{t.current&&clearTimeout(t.current)},r=[],e[0]=s,e[1]=r):(s=e[0],r=e[1]),y.useEffect(s,r);let o;e[2]!==n?(o=()=>{n&&(t.current&&clearTimeout(t.current),t.current=setTimeout(n,Bxe))},e[2]=n,e[3]=o):o=e[3];const i=o;let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{t.current&&(clearTimeout(t.current),t.current=null)},e[4]=l):l=e[4];const c=l;let u;return e[5]!==i?(u={onHoverStart:i,onHoverEnd:c},e[5]=i,e[6]=u):u=e[6],u}const Wxe=6;function qxe(n,e){var s;const t=(s=e.workingCrews)==null?void 0:s.get(n.sessionId);return t?`${t.working} in crew`:d7(n)}function Vxe(n){const e=V.c(7),{iso:t}=n,[,s]=y.useState(0);let r;e[0]!==s?(r=()=>{const c=setInterval(()=>s(Hxe),15e3);return()=>clearInterval(c)},e[0]=s,e[1]=r):r=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[2]=o):o=e[2],y.useEffect(r,o);let i;e[3]!==t?(i=Cr(t),e[3]=t,e[4]=i):i=e[4];let l;return e[5]!==i?(l=a.jsx("span",{"data-relative-time":!0,className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:i}),e[5]=i,e[6]=l):l=e[6],l}function Hxe(n){return n+1}const Kxe={permission:{label:"Permission",className:"border-warning/30 bg-warning/10 text-warning"},deferred:{label:"Deferred",className:"border-warning/30 bg-warning/10 text-warning"},question:{label:"Question",className:"border-warning/30 bg-warning/10 text-warning"},prompt:{label:"Input needed",className:"border-warning/30 bg-warning/10 text-warning"},plan:{label:"Review plan",className:"border-warning/30 bg-warning/10 text-warning"},waiting:{label:"Waiting",className:"border-warning/30 bg-warning/10 text-warning"},done:{label:"Done",className:"border-success/30 bg-success/10 text-success"},crew:{label:"Waiting",className:"border-warning/30 bg-warning/10 text-warning"}};function Gxe({reason:n,crew:e}){const t=Kxe[n];return n==="crew"&&e?{...t,label:`${e.needsYou} waiting`}:t}const Zxe={permission:Hs.attention,deferred:Hs.attention,waiting:Hs.attention,question:"bg-warning",prompt:"bg-warning",plan:"bg-warning",done:"bg-success",crew:Hs.attention};function $j(n){const e=V.c(77),{session:t,chip:s,dotClassName:r,cardClassName:o,since:i,isActiveSession:l,proc:c,killingPids:u,customName:d,projectLabel:f,compact:m,onSelect:p,onKill:h,onResume:g,onPrefetch:x}=n,b=m===void 0?!1:m;let w;e[0]!==c||e[1]!==t.dirName?(w=$b(un(t.dirName),c),e[0]=c,e[1]=t.dirName,e[2]=w):w=e[2];const v=w;let j;e[3]!==s||e[4]!==v||e[5]!==t.agentPendingAgents||e[6]!==t.agentStatus||e[7]!==t.agentTerminalReason||e[8]!==t.agentToolName?(j=v?"Read-only":Jc(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??s.label,e[3]=s,e[4]=v,e[5]=t.agentPendingAgents,e[6]=t.agentStatus,e[7]=t.agentTerminalReason,e[8]=t.agentToolName,e[9]=j):j=e[9];const k=j,_=!!g&&!v,{onHoverStart:N,onHoverEnd:S}=rv(x),C=b?"px-2.5 py-2":"border px-2 py-2",E=l&&!b&&"ring-1 ring-ring";let T;e[10]!==o||e[11]!==C||e[12]!==E?(T=G("group relative w-full rounded-md text-left transition-colors",C,o,E),e[10]=o,e[11]=C,e[12]=E,e[13]=T):T=e[13];let $;e[14]!==b||e[15]!==l?($=b&&l&&a.jsx("span",{className:"absolute inset-y-2 left-0 w-0.5 rounded-full bg-primary","aria-hidden":"true"}),e[14]=b,e[15]=l,e[16]=$):$=e[16];const A=_&&"pr-20";let R;e[17]!==A?(R=G("w-full rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",A),e[17]=A,e[18]=R):R=e[18];let P;e[19]!==S||e[20]!==N||e[21]!==p||e[22]!==R?(P=a.jsx("button",{type:"button","data-attention-session":!0,onClick:p,onMouseEnter:N,onMouseLeave:S,onFocus:N,onBlur:S,className:R}),e[19]=S,e[20]=N,e[21]=p,e[22]=R,e[23]=P):P=e[23];const z=b&&"ring-0";let L;e[24]!==r||e[25]!==z?(L=G("size-1.5 shrink-0 rounded-full",r,z),e[24]=r,e[25]=z,e[26]=L):L=e[26];let I;e[27]!==L?(I=a.jsx("span",{className:L,"aria-hidden":"true"}),e[27]=L,e[28]=I):I=e[28];let M;e[29]!==d||e[30]!==t?(M=pi(t,d),e[29]=d,e[30]=t,e[31]=M):M=e[31];let F;e[32]!==M?(F=a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs leading-tight text-foreground",children:M}),e[32]=M,e[33]=F):F=e[33];const U=b?"text-muted-foreground":s.className;let O;e[34]!==U?(O=G("shrink-0",U),e[34]=U,e[35]=O):O=e[35];const D=v?"Read-only":s.label;let B;e[36]!==O||e[37]!==D?(B=a.jsx(Fe,{variant:"outline",className:O,children:D}),e[36]=O,e[37]=D,e[38]=B):B=e[38];let q;e[39]!==b||e[40]!==t.lastActivityAt||e[41]!==t.lastModified||e[42]!==i?(q=!b&&a.jsx(Vxe,{iso:i??(t.lastActivityAt||t.lastModified)}),e[39]=b,e[40]=t.lastActivityAt,e[41]=t.lastModified,e[42]=i,e[43]=q):q=e[43];let W;e[44]!==I||e[45]!==F||e[46]!==B||e[47]!==q?(W=a.jsxs("span",{className:"flex items-center gap-1.5",children:[I,F,B,q]}),e[44]=I,e[45]=F,e[46]=B,e[47]=q,e[48]=W):W=e[48];let H;e[49]!==f?(H=a.jsx("span",{className:"mt-1 block truncate pl-3 text-xs text-muted-foreground",children:f}),e[49]=f,e[50]=H):H=e[50];let K;e[51]!==P||e[52]!==W||e[53]!==H?(K=a.jsxs(Zt,{render:P,children:[W,H]}),e[51]=P,e[52]=W,e[53]=H,e[54]=K):K=e[54];let Z;e[55]!==d||e[56]!==c||e[57]!==t||e[58]!==k?(Z=a.jsx(Yt,{side:"right",className:"max-w-[280px]",children:a.jsx(sv,{session:t,proc:c,statusLabel:k,customName:d})}),e[55]=d,e[56]=c,e[57]=t,e[58]=k,e[59]=Z):Z=e[59];let Y;e[60]!==K||e[61]!==Z?(Y=a.jsxs(Gt,{children:[K,Z]}),e[60]=K,e[61]=Z,e[62]=Y):Y=e[62];let X;e[63]!==_||e[64]!==g?(X=_&&a.jsxs(Q,{type:"button",variant:"outline",size:"xs",onClick:g,className:"absolute bottom-1 right-1 text-warning","aria-label":"Resume to evaluate",children:[a.jsx(Na,{"data-icon":"inline-start"}),"Resume"]}),e[63]=_,e[64]=g,e[65]=X):X=e[65];let ee;e[66]!==v||e[67]!==u||e[68]!==h||e[69]!==c?(ee=c&&h&&!v&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:se=>h(c.pid,se),disabled:u.has(c.pid),className:"absolute right-0 top-0 text-destructive opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",title:`Kill PID ${c.pid}`,"aria-label":`Kill process ${c.pid}`,children:a.jsx(Mt,{"data-icon":"inline-start"})}),e[66]=v,e[67]=u,e[68]=h,e[69]=c,e[70]=ee):ee=e[70];let te;return e[71]!==Y||e[72]!==X||e[73]!==ee||e[74]!==T||e[75]!==$?(te=a.jsxs("div",{className:T,children:[$,Y,X,ee]}),e[71]=Y,e[72]=X,e[73]=ee,e[74]=T,e[75]=$,e[76]=te):te=e[76],te}function Yxe(n){const e=V.c(15),{dotClassName:t,labelClassName:s,label:r,count:o}=n;let i;e[0]!==t?(i=G("size-1.5 rounded-full",t),e[0]=t,e[1]=i):i=e[1];let l;e[2]!==i?(l=a.jsx("span",{className:i,"aria-hidden":"true"}),e[2]=i,e[3]=l):l=e[3];let c;e[4]!==s?(c=G("text-xs font-medium",s),e[4]=s,e[5]=c):c=e[5];let u;e[6]!==r||e[7]!==c?(u=a.jsx("span",{className:c,children:r}),e[6]=r,e[7]=c,e[8]=u):u=e[8];let d;e[9]!==o?(d=a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:o}),e[9]=o,e[10]=d):d=e[10];let f;return e[11]!==l||e[12]!==u||e[13]!==d?(f=a.jsxs("div",{className:"flex items-center gap-1.5 px-0.5",children:[l,u,d]}),e[11]=l,e[12]=u,e[13]=d,e[14]=f):f=e[14],f}function Xxe(n){const e=V.c(28),{groups:t,activeSessionKey:s,procBySession:r,killingPids:o,sessionNames:i,projectNames:l,onSelectSession:c,onKill:u,onResumeSession:d,onPrefetchSession:f}=n,m=Pm(),[p,h]=y.useState(!1);let g;e[0]!==t.working||e[1]!==p?(g=p?t.working:t.working.slice(0,Wxe),e[0]=t.working,e[1]=p,e[2]=g):g=e[2];const x=g,b=t.working.length-x.length;let w;e[3]!==l?(w=C=>l[C.dirName]||Rx(C.cwd||xs(C.dirName)),e[3]=l,e[4]=w):w=e[4];const v=w;let j;e[5]!==s||e[6]!==o||e[7]!==u||e[8]!==f||e[9]!==c||e[10]!==m||e[11]!==r||e[12]!==v||e[13]!==i?(j=C=>{const E=s===`${C.dirName}/${C.fileName}`;return{session:C,isActiveSession:E,proc:r.get(C.sessionId),killingPids:o,customName:i[C.sessionId],projectLabel:v(C),onSelect:()=>c(C.dirName,C.fileName),onKill:m(C.access).stop?u:void 0,onPrefetch:f&&!E?()=>f(C.dirName,C.fileName):void 0}},e[5]=s,e[6]=o,e[7]=u,e[8]=f,e[9]=c,e[10]=m,e[11]=r,e[12]=v,e[13]=i,e[14]=j):j=e[14];const k=j;let _;e[15]!==t.needsYou||e[16]!==d||e[17]!==m||e[18]!==k?(_=t.needsYou.length>0&&a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsx(Yxe,{dotClassName:Hs.attention,labelClassName:"text-warning",label:"Needs you",count:t.needsYou.length}),t.needsYou.map(C=>{var $;const{session:E,reason:T}=C;return a.jsx($j,{...k(E),chip:Gxe(C),since:T==="crew"?($=C.crew)==null?void 0:$.longestWaitSince:void 0,dotClassName:Zxe[T],cardClassName:"border-warning/20 bg-warning/5 hover:bg-warning/10",onResume:T==="deferred"&&d&&m(E.access).send?()=>d(E.sessionId,E.cwd,E.dirName):void 0},`${E.dirName}/${E.fileName}`)})]}),e[15]=t.needsYou,e[16]=d,e[17]=m,e[18]=k,e[19]=_):_=e[19];let N;e[20]!==t||e[21]!==b||e[22]!==k||e[23]!==x?(N=t.working.length>0&&a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsxs("div",{className:"flex items-center justify-between px-1",children:[a.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Working"}),a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:t.working.length})]}),a.jsx("div",{"data-working-list":!0,className:"flex flex-col gap-0.5 overflow-hidden rounded-lg border bg-background p-0.5",children:x.map(C=>a.jsx($j,{...k(C),chip:{label:qxe(C,t),className:""},dotClassName:Hs.working,cardClassName:"hover:bg-accent/50",compact:!0},`${C.dirName}/${C.fileName}`))}),b>0&&a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",onClick:()=>h(!0),className:"justify-start",children:[a.jsx(_t,{"data-icon":"inline-start"}),"Show ",b," more"]})]}),e[20]=t,e[21]=b,e[22]=k,e[23]=x,e[24]=N):N=e[24];let S;return e[25]!==_||e[26]!==N?(S=a.jsxs("div",{className:"flex flex-col gap-2","data-attention-strip":!0,children:[_,N]}),e[25]=_,e[26]=N,e[27]=S):S=e[27],S}function Jxe(n){const e=V.c(49),{loading:t,isMobile:s,searchQuery:r,searchLoading:o,showArchived:i,archivedCount:l,groupCrews:c,onToggleGroupCrews:u,onSearchQueryChange:d,onToggleShowArchived:f,onRefresh:m}=n,p=l===0?"No archived sessions":`${l} archived ${l===1?"session":"sessions"}`;let h;e[0]!==d?(h=F=>d(F.target.value),e[0]=d,e[1]=h):h=e[1];let g;e[2]!==o||e[3]!==r||e[4]!==h?(g=a.jsx(Go,{type:"search",value:r,onChange:h,placeholder:"Search sessions or PRs","aria-label":"Search sessions by project, branch, title, prompt, PR number, or PR URL","aria-busy":o}),e[2]=o,e[3]=r,e[4]=h,e[5]=g):g=e[5];let x;e[6]!==o?(x=a.jsx(Tr,{align:"inline-start",children:o?a.jsx(St,{className:"animate-spin"}):a.jsx(ss,{})}),e[6]=o,e[7]=x):x=e[7];let b;e[8]!==d||e[9]!==r?(b=r&&a.jsx(Tr,{align:"inline-end",children:a.jsx(dm,{size:"icon-xs",onClick:()=>d(""),"aria-label":"Clear session search",children:a.jsx(Mt,{"data-icon":"inline-start"})})}),e[8]=d,e[9]=r,e[10]=b):b=e[10];let w;e[11]!==g||e[12]!==x||e[13]!==b?(w=a.jsxs(Ko,{children:[g,x,b]}),e[11]=g,e[12]=x,e[13]=b,e[14]=w):w=e[14];let v;e[15]!==c||e[16]!==s||e[17]!==u?(v=u&&a.jsxs(Gt,{children:[a.jsx(Zt,{render:a.jsx(Q,{variant:"ghost",size:s?"icon-sm":"icon-xs",onClick:u,"aria-pressed":c,"aria-label":c?"List spawned sessions on their own":"Group spawned sessions",className:G(c&&"bg-accent text-accent-foreground")}),children:a.jsx(M4,{"data-icon":"inline-start"})}),a.jsx(Yt,{side:"bottom",children:c?"Sessions another session started are listed under it":"Group spawned sessions under the session that started them"})]}),e[15]=c,e[16]=s,e[17]=u,e[18]=v):v=e[18];const j=s?"icon-sm":"icon-xs",k=i?"Hide archived sessions":"Show archived sessions",_=i&&"bg-accent text-accent-foreground";let N;e[19]!==_?(N=G(_),e[19]=_,e[20]=N):N=e[20];let S;e[21]!==f||e[22]!==i||e[23]!==N||e[24]!==j||e[25]!==k?(S=a.jsx(Q,{variant:"ghost",size:j,onClick:f,"aria-pressed":i,"aria-label":k,className:N}),e[21]=f,e[22]=i,e[23]=N,e[24]=j,e[25]=k,e[26]=S):S=e[26];let C;e[27]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsx(Ns,{"data-icon":"inline-start"}),e[27]=C):C=e[27];let E;e[28]!==S?(E=a.jsx(Zt,{render:S,children:C}),e[28]=S,e[29]=E):E=e[29];const T=i?"Hide archived":"Show archived";let $;e[30]!==p||e[31]!==T?($=a.jsxs(Yt,{side:"bottom",children:[T," · ",p]}),e[30]=p,e[31]=T,e[32]=$):$=e[32];let A;e[33]!==E||e[34]!==$?(A=a.jsxs(Gt,{children:[E,$]}),e[33]=E,e[34]=$,e[35]=A):A=e[35];const R=s?"icon-sm":"icon-xs",P=t&&"animate-spin";let z;e[36]!==P?(z=G(P),e[36]=P,e[37]=z):z=e[37];let L;e[38]!==z?(L=a.jsx(Fn,{"data-icon":"inline-start",className:z}),e[38]=z,e[39]=L):L=e[39];let I;e[40]!==m||e[41]!==R||e[42]!==L?(I=a.jsx(Q,{variant:"ghost",size:R,onClick:m,"aria-label":"Refresh sessions",children:L}),e[40]=m,e[41]=R,e[42]=L,e[43]=I):I=e[43];let M;return e[44]!==A||e[45]!==I||e[46]!==w||e[47]!==v?(M=a.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b px-2.5 py-2",children:[w,v,A,I]}),e[44]=A,e[45]=I,e[46]=w,e[47]=v,e[48]=M):M=e[48],M}const Qxe=["first","second","third","fourth","fifth"];function e0e(n){const e=V.c(33),{fetchError:t,showEmpty:s,searching:r,loading:o,sessionCount:i,hiddenArchivedCount:l,focusedProject:c,onShowAllProjects:u,filterEmpty:d,onShowArchived:f,onRetry:m}=n,p=c===void 0?null:c,h=d===void 0?null:d,g=!!h;let x;e[0]!==p||e[1]!==l||e[2]!==r||e[3]!==s||e[4]!==g?(x=n0e({showEmpty:s,searching:r,focusedProject:p,hiddenArchivedCount:l,filtered:g}),e[0]=p,e[1]=l,e[2]=r,e[3]=s,e[4]=g,e[5]=x):x=e[5];const b=x;let w;e[6]!==t||e[7]!==m?(w=t&&a.jsxs(jt,{variant:"destructive",children:[a.jsx(Ir,{}),a.jsx(tn,{children:"Could not load sessions"}),a.jsx(Rt,{className:"truncate",children:t}),a.jsx(Po,{children:a.jsx(Q,{variant:"outline",size:"xs",onClick:m,children:"Retry"})})]}),e[6]=t,e[7]=m,e[8]=w):w=e[8];let v;e[9]!==b||e[10]!==l||e[11]!==f?(v=b==="archived"&&a.jsxs(Ln,{className:"min-h-56 px-4 py-8",children:[a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:a.jsx(Ns,{})}),a.jsx(zn,{children:"Everything is archived"}),a.jsx(Dn,{children:l===1?"1 archived session is hidden.":`${l} archived sessions are hidden.`})]}),a.jsxs(Q,{variant:"outline",size:"sm",onClick:f,children:[a.jsx(Ns,{"data-icon":"inline-start"}),"Show archived"]})]}),e[9]=b,e[10]=l,e[11]=f,e[12]=v):v=e[12];let j;e[13]!==b||e[14]!==p||e[15]!==l||e[16]!==u||e[17]!==f||e[18]!==r?(j=b==="focused"&&a.jsxs(Ln,{className:"min-h-56 px-4 py-8",children:[a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:r?a.jsx(ss,{}):a.jsx(vg,{})}),a.jsx(zn,{children:r?`No matching sessions in ${p}`:`No sessions in ${p}`}),a.jsx(Dn,{children:s0e(r,l)})]}),a.jsxs("div",{className:"flex flex-wrap justify-center gap-2",children:[a.jsxs(Q,{variant:"outline",size:"sm",onClick:u,children:[a.jsx(jd,{"data-icon":"inline-start"}),"All projects"]}),!r&&l>0&&a.jsxs(Q,{variant:"ghost",size:"sm",onClick:f,children:[a.jsx(Ns,{"data-icon":"inline-start"}),"Show archived"]})]})]}),e[13]=b,e[14]=p,e[15]=l,e[16]=u,e[17]=f,e[18]=r,e[19]=j):j=e[19];const k=b==="filtered"&&h;let _;e[20]!==b||e[21]!==r?(_=b==="plain"&&a.jsx(Ln,{className:"min-h-56 px-4 py-8",children:a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:r?a.jsx(ss,{}):a.jsx(vg,{})}),a.jsx(zn,{children:r?"No matching sessions":"No sessions yet"}),a.jsx(Dn,{children:r?"Try #157, honest-cms #157, or paste a PR URL.":"Start Claude Code, Codex, or Copilot to see recent work here."})]})}),e[20]=b,e[21]=r,e[22]=_):_=e[22];let N;e[23]!==o||e[24]!==i?(N=o&&i===0&&a.jsx("div",{className:"flex flex-col gap-2 px-2 py-4","aria-label":"Loading sessions",children:Qxe.map(t0e)}),e[23]=o,e[24]=i,e[25]=N):N=e[25];let S;return e[26]!==N||e[27]!==w||e[28]!==v||e[29]!==j||e[30]!==k||e[31]!==_?(S=a.jsxs(a.Fragment,{children:[w,v,j,k,_,N]}),e[26]=N,e[27]=w,e[28]=v,e[29]=j,e[30]=k,e[31]=_,e[32]=S):S=e[32],S}function t0e(n){return a.jsxs("div",{className:"flex items-center gap-2 py-1",children:[a.jsx(Gn,{className:"size-2 shrink-0 rounded-full"}),a.jsx(Gn,{className:"h-4 flex-1"}),a.jsx(Gn,{className:"h-4 w-10"})]},n)}function n0e({showEmpty:n,searching:e,focusedProject:t,hiddenArchivedCount:s,filtered:r}){return n?t!==null?"focused":!e&&s>0?"archived":!e&&r?"filtered":"plain":null}function s0e(n,e){return n?"Try another search, or look across every project.":e>0?"Its sessions may be archived. Start a new one, or look across every project.":"Start a new session here, or look across every project."}const lg=864e5;function r0e(n){const e=new Date(n);return e.setHours(0,0,0,0),e.getTime()}function o0e(n,e=Date.now()){const t=Date.parse(n);if(!Number.isFinite(t))return"Older";const s=r0e(e);return t>=s?"Today":t>=s-lg?"Yesterday":t>=s-6*lg?"Last 7 days":t>=s-29*lg?"Last 30 days":"Older"}const i0e=6,a0e={permission:"permission",question:"question",input:"input",plan:"plan",deferred:"deferred"},Rj={"needs-you":0,working:1,done:2};function l0e(n){const e=V.c(39),{host:t,members:s,counts:r,statusOf:o,open:i,onToggle:l,sessionNames:c,activeSessionKey:u,onSelectSession:d}=n,[f,m]=y.useState(!1);let p;if(e[0]!==u||e[1]!==r.needsYou||e[2]!==r.size||e[3]!==r.working||e[4]!==t||e[5]!==s||e[6]!==d||e[7]!==l||e[8]!==i||e[9]!==c||e[10]!==f||e[11]!==o){const h=new Map([t,...s].map(c0e)),g=I=>!I.crew||I.crew.parentId===t.sessionId||!h.has(I.crew.parentId);let x;e[13]!==g||e[14]!==o?(x=I=>g(I)||o(I).state==="needs-you",e[13]=g,e[14]=o,e[15]=x):x=e[15];const b=s.filter(x);let w;e[16]!==o?(w=(I,M)=>Rj[o(I).state]-Rj[o(M).state]||(o(I).state==="done"?jr(M)-jr(I):0),e[16]=o,e[17]=w):w=e[17];const v=[...b].sort(w);let j;e[18]!==o?(j=I=>o(I).state==="done",e[18]=o,e[19]=j):j=e[19];const k=v.filter(j),_=f?[]:k.slice(i0e),N=v.filter(I=>!_.includes(I)),S=`Crew of ${r.size}${r.needsYou?`, ${r.needsYou} need you`:""}${r.working?`, ${r.working} working`:""}`,C=i?`Hide crew: ${S}`:`Show crew: ${S}`,E=i&&"rotate-90";let T;e[20]!==E?(T=G("size-3 shrink-0 transition-transform duration-150",E),e[20]=E,e[21]=T):T=e[21];let $;e[22]!==T?($=a.jsx(it,{className:T,"aria-hidden":"true"}),e[22]=T,e[23]=$):$=e[23];let A;e[24]===Symbol.for("react.memo_cache_sentinel")?(A=a.jsx("span",{className:"font-medium text-foreground",children:"Crew"}),e[24]=A):A=e[24];let R;e[25]!==r.size?(R=a.jsxs("span",{className:"tabular-nums",children:["· ",r.size]}),e[25]=r.size,e[26]=R):R=e[26];let P;e[27]!==r.needsYou?(P=r.needsYou>0&&a.jsxs("span",{className:"tabular-nums text-warning",children:["· ",r.needsYou," need you"]}),e[27]=r.needsYou,e[28]=P):P=e[28];let z;e[29]!==r.working?(z=r.working>0&&a.jsxs("span",{className:"tabular-nums",children:["· ",r.working," working"]}),e[29]=r.working,e[30]=z):z=e[30];let L;e[31]!==l||e[32]!==i||e[33]!==R||e[34]!==P||e[35]!==z||e[36]!==C||e[37]!==$?(L=a.jsxs("button",{type:"button",onClick:l,"aria-expanded":i,"aria-label":C,className:"flex w-full items-center gap-1.5 rounded-sm py-0.5 text-left text-[11px] text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:[$,A,R,P,z]}),e[31]=l,e[32]=i,e[33]=R,e[34]=P,e[35]=z,e[36]=C,e[37]=$,e[38]=L):L=e[38],p=a.jsxs("div",{"data-crew-fold":!0,className:"mx-3 mb-2 ml-[26px] border-t border-border/60 pt-1.5",children:[L,i&&a.jsxs("ul",{className:"mt-1 ml-1.5 flex flex-col gap-px border-l border-border/70 pl-1.5",children:[N.map(I=>{var H;const M=o(I),F=I9(I.sessionId,s),U=I.crew?h.get(I.crew.parentId):void 0,O=u===`${I.dirName}/${I.fileName}`,D=Pd(I,{customName:c[I.sessionId],parent:U??t}),B=d0e(I,M),W=(!g(I)&&U?` · via ${Pd(U,{customName:c[U.sessionId],parent:h.get(((H=U.crew)==null?void 0:H.parentId)??"")??t})}`:"")||(F>0?` · ${F} ${F===1?"session":"sessions"}`:"");return a.jsx("li",{children:a.jsxs("button",{type:"button","data-crew-member":I.sessionId,"aria-current":O?"true":void 0,"aria-label":`${D}${W}, ${B}`,onClick:()=>d(I.dirName,I.fileName),className:G("flex w-full items-center gap-1.5 rounded-md px-1.5 py-1 text-left text-xs outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring",O&&"bg-accent"),children:[a.jsx("span",{className:G("size-1.5 shrink-0 rounded-full",u0e(M)),"aria-hidden":"true"}),a.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[D,W&&a.jsx("span",{className:"text-muted-foreground/70",children:W})]}),a.jsx("span",{className:G("shrink-0 text-[11px] tabular-nums",M.state==="needs-you"?"text-warning":"text-muted-foreground/80"),children:B})]})},I.sessionId)}),_.length>0&&a.jsx("li",{children:a.jsxs("button",{type:"button",onClick:()=>m(!0),className:"rounded-sm px-1.5 py-1 text-[11px] text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:["Show ",_.length," more done"]})})]})]}),e[0]=u,e[1]=r.needsYou,e[2]=r.size,e[3]=r.working,e[4]=t,e[5]=s,e[6]=d,e[7]=l,e[8]=i,e[9]=c,e[10]=f,e[11]=o,e[12]=p}else p=e[12];return p}function c0e(n){return[n.sessionId,n]}function u0e({state:n}){return n==="needs-you"?Hs.attention:n==="working"?Hs.working:"bg-muted-foreground/50"}function d0e(n,{state:e,need:t}){var o;const s=Cr(n.lastActivityAt||n.lastModified);if(e==="needs-you")return`${a0e[t??"input"]} · ${s}`;if(e==="working")return d7(n);const r=(o=n.pullRequests)==null?void 0:o.at(-1);return r?`#${r.number} · ${s}`:s}const f0e={};function m0e(n){var Lr,_n;const e=V.c(172),{session:t,projectLabel:s,projectPath:r,showProject:o,isActiveSession:i,proc:l,killingPids:c,isNewlyCompleted:u,customName:d,worktreeName:f,teammateCount:m,teammatesCollapsed:p,onToggleTeammates:h,onSelectSession:g,onKill:x,onDuplicateSession:b,onDeleteSession:w,onArchiveSession:v,onUnarchiveSession:j,onRenameSession:k,onPrefetchSession:_,onResumeSession:N,crew:S,lineage:C,sessionNames:E,activeSessionKey:T}=n,$=E===void 0?f0e:E,A=T===void 0?null:T,{isLive:R,isRunning:P,isNativeIdle:z,isDeferred:L,isReadOnly:I,isTeammate:M,isArchived:F,statusLabel:U,dotState:O,justFinished:D}=Rb(t,l,u),[B,q]=y.useState(!1);let W;e[0]!==d||e[1]!==t?(W=NN(t,d),e[0]=d,e[1]=t,e[2]=W):W=e[2];const H=W,K=w9(t,d),Z=o&&!C?s:void 0,Y=p0e(S==null?void 0:S.counts,O),X=S!==void 0&&Date.parse(S.activityAt)>jr(t),ee=t.lastUserMessage||t.firstUserMessage,te=!!ee&&ee!==H,se=m7(t.sessionId,t.turnCount);let J;e[3]!==t.archivedReason?(J=Ox(t.archivedReason),e[3]=t.archivedReason,e[4]=J):J=e[4];const ne=J,ie=F?j&&{label:"Restore from archive",icon:Cf,run:()=>j(t)}:v&&!P&&{label:"Archive session",icon:Ns,run:()=>v(t)},ae=L&&!!N&&!I,oe=!!m&&!!h,ue=!!t.matchedPullRequestNumber||!!((Lr=t.pullRequests)!=null&&Lr.length),re=ae||oe||ue;let de;e[5]!==i||e[6]!==_||e[7]!==t.dirName||e[8]!==t.fileName?(de=_&&!i?()=>_(t.dirName,t.fileName):void 0,e[5]=i,e[6]=_,e[7]=t.dirName,e[8]=t.fileName,e[9]=de):de=e[9];const{onHoverStart:fe,onHoverEnd:le}=rv(de);let ce;e[10]!==N||e[11]!==B||e[12]!==t.cwd||e[13]!==t.dirName||e[14]!==t.sessionId?(ce=()=>{!N||B||(q(!0),N(t.sessionId,t.cwd,t.dirName),setTimeout(()=>q(!1),3e3))},e[10]=N,e[11]=B,e[12]=t.cwd,e[13]=t.dirName,e[14]=t.sessionId,e[15]=ce):ce=e[15];const he=ce,ge=!0,be=F||void 0,ve=G("motion-list-item group relative flex flex-col rounded-lg border transition-colors",h0e(i,D),F&&"opacity-60 hover:opacity-100 focus-within:opacity-100");let Se;e[16]!==C?(Se=C&&a.jsxs("button",{type:"button","data-crew-lineage":!0,onClick:C.onOpenParent,"aria-label":`Open ${C.parentTitle}, which started this session`,className:"flex min-w-0 items-center gap-1.5 rounded-t-lg px-3 pl-[26px] pt-2.5 text-left text-[11px] leading-tight outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:[a.jsx(dx,{className:"size-3 shrink-0 text-muted-foreground","aria-hidden":"true"}),a.jsx("span",{className:"truncate text-foreground/90",children:C.parentTitle}),C.rootTitle&&a.jsxs("span",{className:"truncate text-muted-foreground",children:["· ",C.rootTitle]})]}),e[16]=C,e[17]=Se):Se=e[17];let we;e[18]!==g||e[19]!==t.dirName||e[20]!==t.fileName?(we=()=>g(t.dirName,t.fileName),e[18]=g,e[19]=t.dirName,e[20]=t.fileName,e[21]=we):we=e[21];const Ee=i?"true":void 0,$e=C?"pt-1":"pt-2.5",Be=re||S?"pb-1.5":"pb-2.5";let qe;e[22]!==$e||e[23]!==Be?(qe=G("flex w-full flex-col gap-1.5 rounded-lg px-3 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",$e,Be),e[22]=$e,e[23]=Be,e[24]=qe):qe=e[24];let ze;e[25]!==le||e[26]!==fe||e[27]!==we||e[28]!==Ee||e[29]!==qe?(ze=a.jsx("button",{type:"button","data-live-session":!0,onClick:we,onMouseEnter:fe,onMouseLeave:le,onFocus:fe,onBlur:le,"aria-current":Ee,className:qe}),e[25]=le,e[26]=fe,e[27]=we,e[28]=Ee,e[29]=qe,e[30]=ze):ze=e[30];let Ie;e[31]!==Z||e[32]!==r?(Ie=Z&&a.jsxs("span",{"data-session-project":!0,className:"flex items-center gap-1.5 pl-3.5 text-[11px] leading-tight text-muted-foreground",children:[a.jsx(ya,{projectPath:r,fallback:a.jsx(sa,{className:"size-3 shrink-0","aria-hidden":"true"}),className:"size-3"}),a.jsx("span",{className:"truncate",children:Z})]}),e[31]=Z,e[32]=r,e[33]=Ie):Ie=e[33];let Me;e[34]!==Y?(Me=Y&&a.jsx("span",{"data-status-dot":Y,className:G("size-1.5 rounded-full",Hs[Y])}),e[34]=Y,e[35]=Me):Me=e[35];let Ue;e[36]!==Me?(Ue=a.jsx("span",{className:"mt-[7px] flex w-1.5 shrink-0 justify-center","aria-hidden":"true",children:Me}),e[36]=Me,e[37]=Ue):Ue=e[37];const De=K?"text-muted-foreground":"font-medium text-foreground";let Ke;e[38]!==De?(Ke=G("line-clamp-2 flex-1 text-sm leading-snug",De),e[38]=De,e[39]=Ke):Ke=e[39];let Ne;e[40]!==H||e[41]!==Ke?(Ne=a.jsx("span",{className:Ke,children:H}),e[40]=H,e[41]=Ke,e[42]=Ne):Ne=e[42];let Ae;e[43]!==Ue||e[44]!==Ne?(Ae=a.jsxs("span",{className:"flex items-start gap-2",children:[Ue,Ne]}),e[43]=Ue,e[44]=Ne,e[45]=Ae):Ae=e[45];let Qe;e[46]!==ee||e[47]!==te?(Qe=te&&a.jsx("span",{className:"line-clamp-2 pl-3.5 text-xs leading-relaxed text-muted-foreground",children:ee}),e[46]=ee,e[47]=te,e[48]=Qe):Qe=e[48];let Je;e[49]!==L||e[50]!==R||e[51]!==z||e[52]!==t.agentStatus||e[53]!==U?(Je=R&&!L&&U&&a.jsx(Fe,{variant:"secondary","data-session-live-state":!0,className:G(z?"text-success":wm(t.agentStatus)),children:U}),e[49]=L,e[50]=R,e[51]=z,e[52]=t.agentStatus,e[53]=U,e[54]=Je):Je=e[54];let ke;e[55]!==L?(ke=L&&a.jsx(Fe,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"deferred"}),e[55]=L,e[56]=ke):ke=e[56];let We;e[57]!==H||e[58]!==M||e[59]!==t.agentName?(We=M&&a.jsxs(Fe,{variant:"outline",children:[a.jsx(mi,{"data-icon":"inline-start"}),H!==t.agentName?t.agentName:"Agent"]}),e[57]=H,e[58]=M,e[59]=t.agentName,e[60]=We):We=e[60];let ye;e[61]!==t.access?(ye=a.jsx(s7,{access:t.access}),e[61]=t.access,e[62]=ye):ye=e[62];let Re;e[63]!==f?(Re=f&&a.jsxs(Fe,{variant:"outline",children:[a.jsx(Gr,{"data-icon":"inline-start"}),f]}),e[63]=f,e[64]=Re):Re=e[64];let Ve;e[65]!==t.gitBranch||e[66]!==f?(Ve=t.gitBranch&&!f&&a.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[a.jsx(Gr,{className:"size-3 shrink-0","aria-hidden":"true"}),a.jsx("span",{className:"truncate",children:t.gitBranch})]}),e[65]=t.gitBranch,e[66]=f,e[67]=Ve):Ve=e[67];let He;e[68]!==se?(He=se>0&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(vc,{className:"size-3 shrink-0","aria-hidden":"true"}),se," ",se===1?"turn":"turns"]}),e[68]=se,e[69]=He):He=e[69];let me;e[70]!==ne||e[71]!==F?(me=F&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Ns,{className:"size-3 shrink-0","aria-label":ne,role:"img"}),"Archived"]}),e[70]=ne,e[71]=F,e[72]=me):me=e[72];let je;e[73]!==S||e[74]!==X||e[75]!==t?(je=X?a.jsxs("span",{"data-crew-activity":!0,className:G("ml-auto tabular-nums",CN({...t,lastActivityAt:S.activityAt})&&"text-success"),children:["crew active ",Cr(S.activityAt)]}):a.jsx("span",{className:"ml-auto tabular-nums",children:Cr(t.lastActivityAt||t.lastModified)}),e[73]=S,e[74]=X,e[75]=t,e[76]=je):je=e[76];let Xe;e[77]!==Je||e[78]!==ke||e[79]!==We||e[80]!==ye||e[81]!==Re||e[82]!==Ve||e[83]!==He||e[84]!==me||e[85]!==je?(Xe=a.jsxs("span",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 pl-3.5 text-[11px] text-muted-foreground",children:[Je,ke,We,ye,Re,Ve,He,me,je]}),e[77]=Je,e[78]=ke,e[79]=We,e[80]=ye,e[81]=Re,e[82]=Ve,e[83]=He,e[84]=me,e[85]=je,e[86]=Xe):Xe=e[86];let tt;e[87]!==ze||e[88]!==Ie||e[89]!==Ae||e[90]!==Qe||e[91]!==Xe?(tt=a.jsxs(Zt,{render:ze,children:[Ie,Ae,Qe,Xe]}),e[87]=ze,e[88]=Ie,e[89]=Ae,e[90]=Qe,e[91]=Xe,e[92]=tt):tt=e[92];const dt=Z?void 0:s;let zt;e[93]!==d||e[94]!==l||e[95]!==t||e[96]!==U||e[97]!==dt||e[98]!==f?(zt=a.jsx(Yt,{side:"right",className:"max-w-[320px]",children:a.jsx(sv,{session:t,proc:l,statusLabel:U,customName:d,worktreeName:f,projectLabel:dt})}),e[93]=d,e[94]=l,e[95]=t,e[96]=U,e[97]=dt,e[98]=f,e[99]=zt):zt=e[99];let st;e[100]!==tt||e[101]!==zt?(st=a.jsxs(Gt,{children:[tt,zt]}),e[100]=tt,e[101]=zt,e[102]=st):st=e[102];let Et;e[103]!==ae||e[104]!==he||e[105]!==re||e[106]!==oe||e[107]!==h||e[108]!==B||e[109]!==t.matchedPullRequestNumber||e[110]!==t.pullRequests||e[111]!==m||e[112]!==p?(Et=re&&a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 px-3 pb-2.5 pl-[26px]",children:[t.matchedPullRequestNumber?a.jsxs(Fe,{variant:"outline",className:"px-1",children:["Matched #",t.matchedPullRequestNumber]}):a.jsx(su,{pullRequests:t.pullRequests,max:2,compact:!0}),oe&&a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",onClick:h,"aria-expanded":!p,"aria-label":p?`Show ${m} team agents`:`Hide ${m} team agents`,children:[a.jsx(er,{"data-icon":"inline-start"}),m,a.jsx(it,{"data-icon":"inline-end",className:G("transition-transform duration-150",!p&&"rotate-90")})]}),ae&&a.jsxs(Q,{type:"button",variant:"outline",size:"xs",onClick:he,disabled:B,className:"text-warning",title:"Resume to evaluate deferred permission","aria-label":"Resume to evaluate",children:[a.jsx(Na,{"data-icon":"inline-start"}),"Resume"]})]}),e[103]=ae,e[104]=he,e[105]=re,e[106]=oe,e[107]=h,e[108]=B,e[109]=t.matchedPullRequestNumber,e[110]=t.pullRequests,e[111]=m,e[112]=p,e[113]=Et):Et=e[113];let Tt;e[114]!==A||e[115]!==S||e[116]!==g||e[117]!==t||e[118]!==$?(Tt=S&&a.jsx(l0e,{host:t,members:S.members,counts:S.counts,statusOf:S.statusOf,open:S.open,onToggle:S.onToggle,sessionNames:$,activeSessionKey:A,onSelectSession:g}),e[114]=A,e[115]=S,e[116]=g,e[117]=t,e[118]=$,e[119]=Tt):Tt=e[119];let Jt;e[120]!==ie||e[121]!==S?(Jt=ie&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:ie.run,className:G("absolute right-1.5 bg-popover text-muted-foreground opacity-0 group-focus-within:opacity-100 group-hover:opacity-100 hover:text-foreground",S?"top-1.5":"bottom-1.5"),title:ie.label,"aria-label":ie.label,children:a.jsx(ie.icon,{"data-icon":"inline-start"})}),e[120]=ie,e[121]=S,e[122]=Jt):Jt=e[122];let At;e[123]!==S||e[124]!==F||e[125]!==I||e[126]!==P||e[127]!==c||e[128]!==x||e[129]!==l?(At=l&&x&&P&&!F&&!I&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:Is=>x(l.pid,Is),disabled:c.has(l.pid),className:G("absolute right-1.5 bg-popover text-destructive opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",S?"top-1.5":"bottom-1.5"),title:`Kill PID ${l.pid}`,"aria-label":`Kill process ${l.pid}`,children:a.jsx(Mt,{"data-icon":"inline-start"})}),e[123]=S,e[124]=F,e[125]=I,e[126]=P,e[127]=c,e[128]=x,e[129]=l,e[130]=At):At=e[130];let Qn;e[131]!==Se||e[132]!==st||e[133]!==Et||e[134]!==Tt||e[135]!==Jt||e[136]!==At||e[137]!==be||e[138]!==ve?(Qn=a.jsxs("div",{"data-session-card":ge,"data-archived":be,className:ve,children:[Se,st,Et,Tt,Jt,At]}),e[131]=Se,e[132]=st,e[133]=Et,e[134]=Tt,e[135]=Jt,e[136]=At,e[137]=be,e[138]=ve,e[139]=Qn):Qn=e[139];const kn=Qn;if(b||w||k||v||j){let Is;e[140]!==t.firstUserMessage||e[141]!==t.sessionId||e[142]!==t.slug?(Is=t.slug||((_n=t.firstUserMessage)==null?void 0:_n.slice(0,30))||t.sessionId.slice(0,12),e[140]=t.firstUserMessage,e[141]=t.sessionId,e[142]=t.slug,e[143]=Is):Is=e[143];let Ps;e[144]!==b||e[145]!==t.dirName||e[146]!==t.fileName?(Ps=b?()=>b(t.dirName,t.fileName):void 0,e[144]=b,e[145]=t.dirName,e[146]=t.fileName,e[147]=Ps):Ps=e[147];let cr;e[148]!==w||e[149]!==t?(cr=w?()=>w(t):void 0,e[148]=w,e[149]=t,e[150]=cr):cr=e[150];let ur;e[151]!==k||e[152]!==t.sessionId?(ur=k?ki=>k(t.sessionId,ki):void 0,e[151]=k,e[152]=t.sessionId,e[153]=ur):ur=e[153];let us;e[154]!==F||e[155]!==v||e[156]!==t?(us=v&&!F?()=>v(t):void 0,e[154]=F,e[155]=v,e[156]=t,e[157]=us):us=e[157];let $s;e[158]!==F||e[159]!==j||e[160]!==t?($s=j&&F?()=>j(t):void 0,e[158]=F,e[159]=j,e[160]=t,e[161]=$s):$s=e[161];let Si;return e[162]!==kn||e[163]!==d||e[164]!==P||e[165]!==Is||e[166]!==Ps||e[167]!==cr||e[168]!==ur||e[169]!==us||e[170]!==$s?(Si=a.jsx(tv,{sessionLabel:Is,customName:d,onDuplicate:Ps,onDelete:cr,onRename:ur,onArchive:us,onUnarchive:$s,archiveDisabled:P,children:kn}),e[162]=kn,e[163]=d,e[164]=P,e[165]=Is,e[166]=Ps,e[167]=cr,e[168]=ur,e[169]=us,e[170]=$s,e[171]=Si):Si=e[171],Si}return kn}function p0e(n,e){return n?n.needsYou>0||e==="attention"?"attention":n.working>0?"working":e:e}function h0e(n,e){return n?"border-foreground/15 bg-accent":e?"border-success/30 bg-success/10":"border-border/70 bg-card hover:border-border hover:bg-accent"}function g0e(n){var le;const e=V.c(87),{session:t,isActiveSession:s,proc:r,killingPids:o,isNewlyCompleted:i,customName:l,worktreeName:c,teammateCount:u,teammatesCollapsed:d,onToggleTeammates:f,onSelectSession:m,onKill:p,onDuplicateSession:h,onDeleteSession:g,onArchiveSession:x,onUnarchiveSession:b,onRenameSession:w,onPrefetchSession:v,onResumeSession:j}=n,{isLive:k,isRunning:_,isNativeIdle:N,isDeferred:S,isReadOnly:C,isTeammate:E,isArchived:T,statusLabel:$,dotState:A,justFinished:R}=Rb(t,r,i),[P,z]=y.useState(!1);let L;e[0]!==t.archivedReason?(L=Ox(t.archivedReason),e[0]=t.archivedReason,e[1]=L):L=e[1];const I=L;let M;e[2]!==l||e[3]!==t?(M=pi(t,l),e[2]=l,e[3]=t,e[4]=M):M=e[4];const F=M,U=T?b&&{label:"Restore from archive",icon:Cf,run:()=>b(t)}:x&&!_&&{label:"Archive session",icon:Ns,run:()=>x(t)};let O;e[5]!==s||e[6]!==v||e[7]!==t.dirName||e[8]!==t.fileName?(O=v&&!s?()=>v(t.dirName,t.fileName):void 0,e[5]=s,e[6]=v,e[7]=t.dirName,e[8]=t.fileName,e[9]=O):O=e[9];const{onHoverStart:D,onHoverEnd:B}=rv(O);let q;e[10]!==j||e[11]!==P||e[12]!==t.cwd||e[13]!==t.dirName||e[14]!==t.sessionId?(q=ce=>{ce.stopPropagation(),!(!j||P)&&(z(!0),j(t.sessionId,t.cwd,t.dirName),setTimeout(()=>z(!1),3e3))},e[10]=j,e[11]=P,e[12]=t.cwd,e[13]=t.dirName,e[14]=t.sessionId,e[15]=q):q=e[15];const W=q,H=G("motion-list-item group relative flex min-h-9 w-full items-center gap-1.5 rounded-md px-2.5 py-2 transition-colors",x0e(s,R),T&&"opacity-60 hover:opacity-100 focus-within:opacity-100");let K;e[16]!==m||e[17]!==t.dirName||e[18]!==t.fileName?(K=()=>m(t.dirName,t.fileName),e[16]=m,e[17]=t.dirName,e[18]=t.fileName,e[19]=K):K=e[19];let Z;e[20]!==B||e[21]!==D||e[22]!==K?(Z=a.jsx("button",{type:"button","data-live-session":!0,onClick:K,onMouseEnter:D,onMouseLeave:B,onFocus:D,onBlur:B,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring"}),e[20]=B,e[21]=D,e[22]=K,e[23]=Z):Z=e[23];let Y;e[24]!==F?(Y=a.jsx("span",{className:"flex-1 truncate text-sm leading-tight text-foreground",children:F}),e[24]=F,e[25]=Y):Y=e[25];let X;e[26]!==S?(X=S&&a.jsx(Fe,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"deferred"}),e[26]=S,e[27]=X):X=e[27];let ee;e[28]!==c?(ee=c&&a.jsxs(Fe,{variant:"outline",children:[a.jsx(Gr,{"data-icon":"inline-start"}),c]}),e[28]=c,e[29]=ee):ee=e[29];let te;e[30]!==l||e[31]!==r||e[32]!==t||e[33]!==$||e[34]!==c?(te=a.jsx(Yt,{side:"right",className:"max-w-[280px]",children:a.jsx(sv,{session:t,proc:r,statusLabel:$,customName:l,worktreeName:c})}),e[30]=l,e[31]=r,e[32]=t,e[33]=$,e[34]=c,e[35]=te):te=e[35];let se;e[36]!==f||e[37]!==u||e[38]!==d?(se=!!u&&f&&a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",onClick:f,className:"shrink-0",title:d?"Show team agents":"Hide team agents","aria-label":d?`Show ${u} team agents`:`Hide ${u} team agents`,"aria-expanded":!d,children:[a.jsx(er,{"data-icon":"inline-start"}),u,a.jsx(it,{"data-icon":"inline-end",className:G("transition-transform duration-150",!d&&"rotate-90")})]}),e[36]=f,e[37]=u,e[38]=d,e[39]=se):se=e[39];let J;e[40]!==W||e[41]!==S||e[42]!==C||e[43]!==j||e[44]!==P?(J=S&&j&&!C&&a.jsxs(Q,{type:"button",variant:"outline",size:"xs",onClick:W,disabled:P,className:"shrink-0 text-warning",title:"Resume to evaluate deferred permission","aria-label":"Resume to evaluate",children:[a.jsx(Na,{"data-icon":"inline-start"}),"Resume"]}),e[40]=W,e[41]=S,e[42]=C,e[43]=j,e[44]=P,e[45]=J):J=e[45];let ne;e[46]!==t.matchedPullRequestNumber||e[47]!==t.pullRequests?(ne=t.matchedPullRequestNumber?a.jsxs(Fe,{variant:"outline",className:"shrink-0 px-1",children:["Matched #",t.matchedPullRequestNumber]}):a.jsx(su,{pullRequests:t.pullRequests,max:1,compact:!0}),e[46]=t.matchedPullRequestNumber,e[47]=t.pullRequests,e[48]=ne):ne=e[48];let ie;e[49]!==I||e[50]!==T?(ie=T&&a.jsx(Ns,{className:"size-3 shrink-0 text-muted-foreground","aria-label":I,role:"img"}),e[49]=I,e[50]=T,e[51]=ie):ie=e[51];const ae=t.lastActivityAt||t.lastModified;let oe;e[52]!==ae?(oe=Cr(ae),e[52]=ae,e[53]=oe):oe=e[53];let ue;e[54]!==oe?(ue=a.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:oe}),e[54]=oe,e[55]=ue):ue=e[55];let re;e[56]!==U?(re=U&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:ce=>{ce.stopPropagation(),U.run()},className:"absolute right-0 top-0 bg-popover text-muted-foreground opacity-0 group-focus-within:opacity-100 group-hover:opacity-100 hover:text-foreground",title:U.label,"aria-label":U.label,children:a.jsx(U.icon,{"data-icon":"inline-start"})}),e[56]=U,e[57]=re):re=e[57];let de;e[58]!==T||e[59]!==C||e[60]!==_||e[61]!==o||e[62]!==p||e[63]!==r?(de=r&&p&&_&&!T&&!C&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:ce=>p(r.pid,ce),disabled:o.has(r.pid),className:"absolute right-0 top-0 text-destructive opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",title:`Kill PID ${r.pid}`,"aria-label":`Kill process ${r.pid}`,children:a.jsx(Mt,{"data-icon":"inline-start"})}),e[58]=T,e[59]=C,e[60]=_,e[61]=o,e[62]=p,e[63]=r,e[64]=de):de=e[64];const fe=a.jsxs("div",{className:H,"data-archived":T||void 0,children:[a.jsxs(Gt,{children:[a.jsxs(Zt,{render:Z,children:[a.jsx("span",{className:"flex w-1.5 shrink-0 items-center justify-center","aria-hidden":"true",children:A&&a.jsx("span",{"data-status-dot":A,className:G("size-1.5 rounded-full",Hs[A])})}),Y,E&&a.jsxs(Fe,{variant:"outline",children:[a.jsx(mi,{"data-icon":"inline-start"}),F!==t.agentName?t.agentName:"Agent"]}),k&&!S&&$&&a.jsx(Fe,{variant:"secondary","data-session-live-state":!0,className:G("shrink-0",N&&"text-success",!N&&wm(t.agentStatus)),children:$}),X,ee]}),te]}),se,J,ne,ie,ue,re,de]});if(h||g||w||x||b){let ce;e[65]!==t.firstUserMessage||e[66]!==t.sessionId||e[67]!==t.slug?(ce=t.slug||((le=t.firstUserMessage)==null?void 0:le.slice(0,30))||t.sessionId.slice(0,12),e[65]=t.firstUserMessage,e[66]=t.sessionId,e[67]=t.slug,e[68]=ce):ce=e[68];let he;e[69]!==h||e[70]!==t.dirName||e[71]!==t.fileName?(he=h?()=>h(t.dirName,t.fileName):void 0,e[69]=h,e[70]=t.dirName,e[71]=t.fileName,e[72]=he):he=e[72];let ge;e[73]!==g||e[74]!==t?(ge=g?()=>g(t):void 0,e[73]=g,e[74]=t,e[75]=ge):ge=e[75];let be;e[76]!==w||e[77]!==t.sessionId?(be=w?we=>w(t.sessionId,we):void 0,e[76]=w,e[77]=t.sessionId,e[78]=be):be=e[78];let ve;e[79]!==T||e[80]!==x||e[81]!==t?(ve=x&&!T?()=>x(t):void 0,e[79]=T,e[80]=x,e[81]=t,e[82]=ve):ve=e[82];let Se;return e[83]!==T||e[84]!==b||e[85]!==t?(Se=b&&T?()=>b(t):void 0,e[83]=T,e[84]=b,e[85]=t,e[86]=Se):Se=e[86],a.jsx(tv,{sessionLabel:ce,customName:l,onDuplicate:he,onDelete:ge,onRename:be,onArchive:ve,onUnarchive:Se,archiveDisabled:_,children:fe})}return fe}function x0e(n,e){return n?"bg-accent":e?"bg-success/10":"hover:bg-accent/60"}const b0e={state:"done"};function v0e(n){const e=V.c(84),{sessions:t,pendingSession:s,older:r,showProject:o,groupCrews:i,lineageSessions:l,memberStatusOf:c,activeSessionKey:u,procBySession:d,killingPids:f,newlyCompleted:m,sessionNames:p,projectNames:h,onSelectSession:g,onKill:x,onDuplicateSession:b,onDeleteSession:w,onArchiveSession:v,onUnarchiveSession:j,onRenameSession:k,onPrefetchSession:_,onResumeSession:N}=n,S=i===void 0?!0:i,C=c===void 0?w0e:c,E=Pm();let T,$,A,R;if(e[0]!==S||e[1]!==t){T=S?zx(t):{topLevel:t,crewOf:new Map},$=S9(T.topLevel);const le=be=>{const ve=T.crewOf.get(be.sessionId);return ve?Ly(be,ve):be.lastActivityAt||be.lastModified},ce=new Map($.topLevelSessions.map(be=>[{...be,lastActivityAt:le(be)},be]));R=Aa([...ce.keys()]).map(be=>ce.get(be));const he=Date.now(),ge=R.map(be=>o0e(le(be),he));A=ge.map((be,ve)=>be===ge[ve-1]?null:be),e[0]=S,e[1]=t,e[2]=T,e[3]=$,e[4]=A,e[5]=R}else T=e[2],$=e[3],A=e[4],R=e[5];const P=A;let z;e[6]!==T.crewOf||e[7]!==P||e[8]!==$.teammatesByLead||e[9]!==R?(z={topLevelSessions:R,teammatesByLead:$.teammatesByLead,crewOf:T.crewOf,shelves:P},e[6]=T.crewOf,e[7]=P,e[8]=$.teammatesByLead,e[9]=R,e[10]=z):z=e[10];const{topLevelSessions:L,teammatesByLead:I,crewOf:M,shelves:F}=z;let U,O;e[11]===Symbol.for("react.memo_cache_sentinel")?(U=sn("live-sessions-open-crews"),O=[],e[11]=U,e[12]=O):(U=e[11],O=e[12]);const[D,B]=kr(U,O);let q;e[13]!==D?(q=Array.isArray(D)?D:[],e[13]=D,e[14]=q):q=e[14];let W;e[15]!==q?(W=new Set(q),e[15]=q,e[16]=W):W=e[16];const H=W;let K;e[17]!==D||e[18]!==B?(K=le=>{const ce=Array.isArray(D)?D:[];B(ce.includes(le)?ce.filter(he=>he!==le):[...ce,le])},e[17]=D,e[18]=B,e[19]=K):K=e[19];const Z=K;let Y;e[20]!==l?(Y=l??[],e[20]=l,e[21]=Y):Y=e[21];let X;e[22]!==t||e[23]!==Y?(X=new Map([...Y,...t].map(y0e)),e[22]=t,e[23]=Y,e[24]=X):X=e[24];const ee=X;let te;e[25]===Symbol.for("react.memo_cache_sentinel")?(te=new Set,e[25]=te):te=e[25];const[se,J]=y.useState(te);let ne;e[26]===Symbol.for("react.memo_cache_sentinel")?(ne=le=>{J(ce=>{const he=new Set(ce);return he.has(le)?he.delete(le):he.add(le),he})},e[26]=ne):ne=e[26];const ie=ne;let ae;e[27]!==u||e[28]!==f||e[29]!==m||e[30]!==v||e[31]!==w||e[32]!==b||e[33]!==x||e[34]!==_||e[35]!==k||e[36]!==N||e[37]!==g||e[38]!==j||e[39]!==E||e[40]!==d||e[41]!==p?(ae=le=>{const ce=E(le.access);return{session:le,isActiveSession:u===cg(le),proc:d.get(le.sessionId),killingPids:f,isNewlyCompleted:m.has(le.sessionId),customName:p[le.sessionId],onSelectSession:g,onKill:ce.stop?x:void 0,onDuplicateSession:b,onDeleteSession:ce.delete?w:void 0,onArchiveSession:ce.archive?v:void 0,onUnarchiveSession:ce.archive?j:void 0,onRenameSession:k,onPrefetchSession:_,onResumeSession:ce.send?N:void 0}},e[27]=u,e[28]=f,e[29]=m,e[30]=v,e[31]=w,e[32]=b,e[33]=x,e[34]=_,e[35]=k,e[36]=N,e[37]=g,e[38]=j,e[39]=E,e[40]=d,e[41]=p,e[42]=ae):ae=e[42];const oe=ae;let ue;e[43]!==s?(ue=s&&a.jsx(j0e,{firstMessage:s.firstMessage}),e[43]=s,e[44]=ue):ue=e[44];let re;if(e[45]!==u||e[46]!==se||e[47]!==M||e[48]!==ee||e[49]!==C||e[50]!==g||e[51]!==H||e[52]!==h||e[53]!==oe||e[54]!==p||e[55]!==F||e[56]!==o||e[57]!==I||e[58]!==Z||e[59]!==L){let le;e[61]!==u||e[62]!==se||e[63]!==M||e[64]!==ee||e[65]!==C||e[66]!==g||e[67]!==H||e[68]!==h||e[69]!==oe||e[70]!==p||e[71]!==F||e[72]!==o||e[73]!==I||e[74]!==Z?(le=(ce,he)=>{const ge=cg(ce),be=ce.cwd??xs(ce.dirName),ve=Nr(be),Se=h[ce.dirName]??Nl(ce),we=I.get(ce.sessionId),Ee=se.has(ce.sessionId),$e=F[he],Be=M.get(ce.sessionId),qe=Be&&{members:Be,counts:Dx(Be,C),statusOf:C,activityAt:Ly(ce,Be),open:H.has(ce.sessionId),onToggle:()=>Z(ce.sessionId)},ze=a.jsx(m0e,{...oe(ce),worktreeName:ve==null?void 0:ve.worktreeName,projectLabel:Se,projectPath:(ve==null?void 0:ve.parentPath)??be,showProject:o,teammateCount:we==null?void 0:we.length,teammatesCollapsed:we?Ee:void 0,onToggleTeammates:we?()=>ie(ce.sessionId):void 0,crew:qe,lineage:S0e(ce,ee,p,g),sessionNames:p,activeSessionKey:u});return a.jsxs(y.Fragment,{children:[$e&&a.jsx(k0e,{label:$e}),we&&!Ee?a.jsxs("div",{className:"flex flex-col gap-px",children:[ze,a.jsx("div",{className:"ml-3 flex flex-col gap-px border-l pl-1",children:we.map(Ie=>a.jsx(g0e,{...oe(Ie)},cg(Ie)))})]}):ze]},ge)},e[61]=u,e[62]=se,e[63]=M,e[64]=ee,e[65]=C,e[66]=g,e[67]=H,e[68]=h,e[69]=oe,e[70]=p,e[71]=F,e[72]=o,e[73]=I,e[74]=Z,e[75]=le):le=e[75],re=L.map(le),e[45]=u,e[46]=se,e[47]=M,e[48]=ee,e[49]=C,e[50]=g,e[51]=H,e[52]=h,e[53]=oe,e[54]=p,e[55]=F,e[56]=o,e[57]=I,e[58]=Z,e[59]=L,e[60]=re}else re=e[60];let de;e[76]!==r.canLoad||e[77]!==r.load||e[78]!==r.loading?(de=r.canLoad&&a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",onClick:r.load,disabled:r.loading,className:"justify-start text-muted-foreground",children:[r.loading?a.jsx(St,{"data-icon":"inline-start",className:"animate-spin"}):a.jsx(L4,{"data-icon":"inline-start"}),"Load older sessions"]}),e[76]=r.canLoad,e[77]=r.load,e[78]=r.loading,e[79]=de):de=e[79];let fe;return e[80]!==ue||e[81]!==re||e[82]!==de?(fe=a.jsxs("div",{className:"flex flex-col gap-1.5","data-session-card-list":!0,children:[ue,re,de]}),e[80]=ue,e[81]=re,e[82]=de,e[83]=fe):fe=e[83],fe}function y0e(n){return[n.sessionId,n]}function w0e(){return b0e}function S0e(n,e,t,s){const r=n.crew;if(!r)return;const o=$d(r.parentId,e,t)??r.parentTitle??"Another session",i=r.rootId===r.parentId?void 0:$d(r.rootId,e,t)??r.rootTitle,l=e.get(r.parentId);return{parentTitle:o,...i&&i!==o&&{rootTitle:i},onOpenParent:l?()=>s(l.dirName,l.fileName):()=>void cm(r.parentId)}}function k0e(n){const e=V.c(2),{label:t}=n;let s;return e[0]!==t?(s=a.jsx("div",{"data-recency-divider":!0,className:"px-1 pb-0.5 pt-2 text-[11px] font-medium text-muted-foreground/80 first:pt-0",children:t}),e[0]=t,e[1]=s):s=e[1],s}function j0e(n){const e=V.c(3),{firstMessage:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(St,{className:"size-3 shrink-0 animate-spin text-info"}),e[0]=s):s=e[0];const r=t||"New session";let o;return e[1]!==r?(o=a.jsxs("div",{className:"motion-enter relative flex w-full items-center gap-1.5 rounded-lg border border-border/70 bg-accent px-3 py-2.5 text-left",children:[s,a.jsx("span",{className:"flex-1 truncate text-sm leading-tight text-foreground",children:r})]}),e[1]=r,e[2]=o):o=e[2],o}function cg(n){return`${n.dirName}/${n.fileName}`}function yo(n,e){return`${n} ${n===1?e:`${e}s`}`}function N0e(n){if(!n)return"No sessions listed";const e=yo(n.total,"session"),t=n.live>0?`${e}, ${n.live} live`:e,s=[n.crews>0&&yo(n.crews,"crew"),n.worktrees>0&&yo(n.worktrees,"worktree")].filter(Boolean);return[t,...s].join(" · ")}function Oj(n){const e=V.c(7),{count:t,label:s,className:r}=n;let o;e[0]!==r?(o=G("flex shrink-0 items-center gap-1 font-medium text-warning",r),e[0]=r,e[1]=o):o=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx("span",{className:"size-1.5 rounded-full bg-warning","aria-hidden":"true"}),e[2]=i):i=e[2];let l;return e[3]!==t||e[4]!==s||e[5]!==o?(l=a.jsxs("span",{className:o,"aria-label":s,children:[i,t]}),e[3]=t,e[4]=s,e[5]=o,e[6]=l):l=e[6],l}function C0e(n,e){return e===null?0:n.reduce((t,s)=>s.key===e?t:t+s.needsYou,0)}function _0e(n){const e=V.c(72),{options:t,value:s,focused:r,totalSessions:o,crewCount:i,onChange:l,onNewSession:c,creatingSession:u,onRenameProject:d,archivableCount:f,onArchiveIdle:m}=n,p=i===void 0?0:i,[h,g]=y.useState(!1),x=(r==null?void 0:r.customName)??s;let b;e[0]!==p||e[1]!==r||e[2]!==t.length||e[3]!==o||e[4]!==s?(b=s===null?`${yo(t.length,"project")}, ${yo(o,"session")}${p>0?` · ${yo(p,"crew")}`:""}`:N0e(r),e[0]=p,e[1]=r,e[2]=t.length,e[3]=o,e[4]=s,e[5]=b):b=e[5];const w=b,v=C0e(t,s);let j;e[6]!==l?(j=ee=>{l(ee),g(!1)},e[6]=l,e[7]=j):j=e[7];const k=j,_=s===null?"Choose a project to focus on":`Focused on ${x}. Change project`;let N;e[8]!==(r==null?void 0:r.cwd)||e[9]!==s?(N=s===null?a.jsx(jd,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):a.jsx(ya,{projectPath:(r==null?void 0:r.cwd)??null,fallback:a.jsx(sa,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),className:"size-5"}),e[8]=r==null?void 0:r.cwd,e[9]=s,e[10]=N):N=e[10];const S=s===null?"All projects":x;let C;e[11]!==S?(C=a.jsx("span",{className:"truncate text-sm font-medium leading-tight text-foreground",children:S}),e[11]=S,e[12]=C):C=e[12];let E;e[13]!==w?(E=a.jsx("span",{className:"truncate text-[11px] leading-tight text-muted-foreground",children:w}),e[13]=w,e[14]=E):E=e[14];let T;e[15]!==C||e[16]!==E?(T=a.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[C,E]}),e[15]=C,e[16]=E,e[17]=T):T=e[17];let $;e[18]!==v?($=v>0&&a.jsx(Oj,{count:v,label:v===1?"1 session in another project is waiting for you":`${v} sessions in other projects are waiting for you`,className:"rounded-full border border-warning/30 bg-warning/10 px-1.5 py-0.5 text-[11px]"}),e[18]=v,e[19]=$):$=e[19];let A;e[20]===Symbol.for("react.memo_cache_sentinel")?(A=a.jsx(_a,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[20]=A):A=e[20];let R;e[21]!==$||e[22]!==_||e[23]!==N||e[24]!==T?(R=a.jsxs(Tc,{"aria-label":_,className:"flex h-11 min-w-0 flex-1 items-center gap-2.5 rounded-lg px-2 text-left outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring data-popup-open:bg-accent",children:[N,T,$,A]}),e[21]=$,e[22]=_,e[23]=N,e[24]=T,e[25]=R):R=e[25];const P=R;let z;e[26]!==f||e[27]!==r||e[28]!==m||e[29]!==d||e[30]!==P?(z=r&&d?a.jsx(l7,{projectLabel:r.key,customName:r.customName,className:"flex min-w-0 flex-1",archivableCount:f,onArchiveIdle:m,onRename:ee=>d(r.dirName,ee),children:P}):P,e[26]=f,e[27]=r,e[28]=m,e[29]=d,e[30]=P,e[31]=z):z=e[31];let L;e[32]===Symbol.for("react.memo_cache_sentinel")?(L=a.jsx(o0,{placeholder:"Find a project",autoFocus:!0}),e[32]=L):L=e[32];let I;e[33]===Symbol.for("react.memo_cache_sentinel")?(I=a.jsx(Nz,{children:"No project matches."}),e[33]=I):I=e[33];const M=s===null;let F;e[34]!==k?(F=()=>k(null),e[34]=k,e[35]=F):F=e[35];let U,O;e[36]===Symbol.for("react.memo_cache_sentinel")?(U=a.jsx(jd,{className:"text-muted-foreground","aria-hidden":"true"}),O=a.jsx("span",{className:"flex-1 truncate",children:"All projects"}),e[36]=U,e[37]=O):(U=e[36],O=e[37]);let D;e[38]!==o?(D=a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:o}),e[38]=o,e[39]=D):D=e[39];let B;e[40]!==M||e[41]!==F||e[42]!==D?(B=a.jsx(xi,{children:a.jsxs(Eo,{value:"all-projects","data-checked":M,onSelect:F,className:"gap-2.5",children:[U,O,D]})}),e[40]=M,e[41]=F,e[42]=D,e[43]=B):B=e[43];let q;if(e[44]!==t||e[45]!==k||e[46]!==s){let ee;e[48]!==k||e[49]!==s?(ee=te=>a.jsxs(Eo,{value:te.key,keywords:te.customName?[te.customName]:void 0,"data-checked":s===te.key,onSelect:()=>k(te.key),className:"gap-2.5",children:[a.jsx(ya,{projectPath:te.cwd??null,fallback:a.jsx(sa,{className:"text-muted-foreground","aria-hidden":"true"}),className:"size-4"}),a.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[a.jsx("span",{className:"truncate",children:te.customName??te.key}),te.customName&&a.jsx("span",{className:"truncate text-[11px] text-muted-foreground",children:te.key})]}),te.needsYou>0&&a.jsx(Oj,{count:te.needsYou,label:`${yo(te.needsYou,"session")} waiting for you`,className:"text-xs"}),te.live>0&&a.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs font-medium text-success","aria-label":yo(te.live,"live session"),children:[a.jsx(Sm,{className:"size-1.5","aria-hidden":"true"}),te.live]}),a.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:te.total})]},te.key),e[48]=k,e[49]=s,e[50]=ee):ee=e[50],q=t.map(ee),e[44]=t,e[45]=k,e[46]=s,e[47]=q}else q=e[47];let W;e[51]!==q?(W=a.jsx(xi,{heading:"Projects",children:q}),e[51]=q,e[52]=W):W=e[52];let H;e[53]!==B||e[54]!==W?(H=a.jsx(Zx,{className:"w-(--anchor-width) min-w-72 p-0",children:a.jsxs(Ic,{children:[L,a.jsxs(Pc,{children:[I,B,W]})]})}),e[53]=B,e[54]=W,e[55]=H):H=e[55];let K;e[56]!==h||e[57]!==z||e[58]!==H?(K=a.jsxs(Ec,{open:h,onOpenChange:g,children:[z,H]}),e[56]=h,e[57]=z,e[58]=H,e[59]=K):K=e[59];let Z;e[60]!==u||e[61]!==r||e[62]!==x||e[63]!==c?(Z=r&&c&&a.jsx(Q,{type:"button",variant:"outline",size:"icon-sm",className:"shrink-0",disabled:u,onClick:()=>c(r.dirName,r.cwd),"aria-label":`New session in ${x}`,children:u?a.jsx(St,{"data-icon":"inline-start",className:"animate-spin"}):a.jsx(Sr,{"data-icon":"inline-start"})}),e[60]=u,e[61]=r,e[62]=x,e[63]=c,e[64]=Z):Z=e[64];let Y;e[65]!==u||e[66]!==c?(Y=c&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",className:"shrink-0",disabled:u,onClick:E0e,"aria-label":"Start a session in a folder",title:"Start a session in a folder",children:a.jsx(wc,{"data-icon":"inline-start"})}),e[65]=u,e[66]=c,e[67]=Y):Y=e[67];let X;return e[68]!==K||e[69]!==Z||e[70]!==Y?(X=a.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b px-2 py-1.5",children:[K,Z,Y]}),e[68]=K,e[69]=Z,e[70]=Y,e[71]=X):X=e[71],X}function E0e(){return EI()}function T0e(n,e){return n.reduce((t,s)=>s.isActive?t+1:e.has(s.sessionId)?s.agentStatus==="completed"?t:t+1:t,0)}function A0e(n){const e=Nr(n.cwd??xs(n.dirName));if(!e)return{dirName:n.dirName,cwd:n.cwd};const{parentPath:t}=e;return{dirName:vs(n.dirName).dirName.encode(t),cwd:t}}function I0e(n){const e=n.map(t=>{var s;return(s=Nr(t.cwd??xs(t.dirName)))==null?void 0:s.worktreeName});return new Set(e.filter(Boolean)).size}function P0e(n,e,t,s,r=new Map){return[...C9(n).entries()].map(([o,i])=>{const l=k9(i),c=A0e(l);return{key:o,customName:t[c.dirName],...c,dirNames:[...new Set(i.map(u=>u.dirName))],total:i.length,live:T0e(i,e),needsYou:i.filter(u=>s.has(u.sessionId)).length,worktrees:I0e(i),crews:i.filter(u=>r.has(u.sessionId)).length}})}function Lj(n,e,t=!1){if(e===null)return n;if(!t)return n.filter(i=>Nl(i)===e);const{topLevel:s,crewOf:r}=zx(n),o=new Set;for(const i of s)if(Nl(i)===e){o.add(i);for(const l of r.get(i.sessionId)??[])o.add(l)}for(const i of r.values())for(const l of i)Nl(l)===e&&o.add(l);return n.filter(i=>o.has(i))}function $0e(n,e){if(e.length===0)return n;const t=new Set(n.map(r=>r.sessionId)),s=e.filter(r=>!t.has(r.sessionId));return s.length===0?n:Aa([...n,...s])}const Mj={key:null,sessions:[],loading:!1,loaded:!1};function R0e(n,e){const t=n.dirNames?n.dirNames.map(s=>new URLSearchParams({project:s,limit:"200"})):[new URLSearchParams({limit:"200",perProject:"100"})];if(e)for(const s of t)s.set("archived","include");return t}function O0e(n,e,t){const s=V.c(14),r=n?`${e?"a":"l"}:${t.key??""}:${n.key}`:null,[o,i]=y.useState(Mj),l=o.key===r?o:Mj;let c;s[0]!==t||s[1]!==e||s[2]!==r||s[3]!==n?(c=async()=>{if(r===null||!n)return;i(g=>g.key===r?{...g,loading:!0}:{key:r,sessions:[],loading:!0,loaded:!1});const h=Xr();try{const x=(await Promise.all(R0e(n,e).map(async b=>{const w=await Ce(zf(b,t));if(!w.ok)throw new Error(`Could not load older sessions (${w.status})`);const v=await w.json();return Array.isArray(v)?v:[]}))).flat();aa(x,h),i(b=>b.key===r?{key:r,sessions:x,loading:!1,loaded:!0}:b)}catch(g){const x=g;i(b=>b.key===r?{...b,loading:!1}:b),Kn.error(x instanceof Error?x.message:"Could not load older sessions")}},s[0]=t,s[1]=e,s[2]=r,s[3]=n,s[4]=c):c=s[4];const u=c,{loaded:d}=l;let f,m;s[5]!==u||s[6]!==d?(f=()=>{if(d)return Df(()=>void u())},m=[d,u],s[5]=u,s[6]=d,s[7]=f,s[8]=m):(f=s[7],m=s[8]),y.useEffect(f,m);let p;return s[9]!==l.loading||s[10]!==l.sessions||s[11]!==u||s[12]!==d?(p={sessions:l.sessions,loading:l.loading,loaded:d,load:u},s[9]=l.loading,s[10]=l.sessions,s[11]=u,s[12]=d,s[13]=p):p=s[13],p}const L0e={key:"all"},M0e=y.memo(function({activeSessionKey:e,onSelectSession:t,onDuplicateSession:s,onDeleteSession:r,onNewSession:o,creatingSession:i,pendingSession:l,refreshRef:c,onPrefetchSession:u}){const{names:d,rename:f}=Ff(),{names:m,rename:p}=ev(),h=tb(),g=Nn("terminal"),x=Nn("killAny"),b=Pm(),w=Mf(),{Control:v,Empty:j}=$r().sessionListFilter??{},{sessions:k,procBySession:_,newlyCompleted:N,loading:S,error:C,refresh:E,removeSession:T,acknowledgeCompleted:$,showArchived:A,setShowArchived:R,setSearchActive:P,archivedCount:z}=Vx(),{awaitingPermission:L,awaitingQuestion:I,awaitingElicitation:M,awaitingDialog:F,awaitingPlan:U}=xpe(),O=y.useMemo(()=>new Set([...M,...F]),[M,F]),[D,B]=y.useState(new Set),[q,W]=y.useState(""),[H,K]=kr(sn("live-sessions-project-scope"),null),[Z,Y]=kr(sn("live-sessions-group-crews"),!0),X=Z!==!1,ee=!!q.trim(),te=X&&!ee,se=A||ee;y.useEffect(()=>(P(ee),()=>P(!1)),[ee,P]);const J=y.useRef(new Set),ne=y.useRef(!1),ie=y.useCallback((ye,Re)=>{if(!ne.current)return;const Ve=setTimeout(()=>{J.current.delete(Ve),ne.current&&ye()},Re);J.current.add(Ve)},[]);y.useEffect(()=>{const ye=J.current;return ne.current=!0,()=>{ne.current=!1;for(const Re of ye)clearTimeout(Re);ye.clear()}},[]),y.useEffect(()=>{if(c)return c.current=E,()=>{c.current===E&&(c.current=null)}},[E,c]);const ae=nv(),oe=c7(q,w),ue=y.useMemo(()=>N9(k,se),[k,se]),re=se?0:z,de=y.useMemo(()=>({awaitingPermission:L,awaitingQuestion:I,awaitingPrompt:O,awaitingPlan:U}),[L,I,O,U]),fe=y.useCallback(ye=>_N(ye,_,de),[_,de]),le=y.useMemo(()=>zx(ue),[ue]),ce=y.useMemo(()=>{const ye=Ve=>b(Ve.access).canInteract,Re=Mxe(le.topLevel,_,N,L,I,O,U,ye);return zxe(Re,le.topLevel,le.crewOf,fe,ye)},[le,_,N,L,I,O,U,b,fe]),he=y.useMemo(()=>new Set(ce.needsYou.map(ye=>ye.session.sessionId)),[ce]),ge=X?le.topLevel:ue,be=y.useMemo(()=>P0e(ge,_,m,he,le.crewOf),[ge,_,m,he,le.crewOf]),ve=H===null?null:be.find(ye=>ye.key===H)??null,Se=(ve==null?void 0:ve.customName)??H,we=O0e(H===null?L0e:ve,se,w),Ee=y.useMemo(()=>$0e(Lj(ue,H,te),we.sessions),[ue,H,te,we.sessions]),$e=y.useMemo(()=>ee?Ee.filter(ye=>{const Re=d[ye.sessionId],Ve=m[ye.dirName];return o7(ye,q,[Re,Ve])}):Ee,[Ee,ee,q,d,m]),Be=y.useMemo(()=>oe.results?Lj(oe.results,H,te):$e,[oe.results,H,te,$e]),qe=ce.needsYou.length>0||ce.working.length>0,ze=!ee&&qe&&H===null,Ie=y.useMemo(()=>H===null?[]:Ee.filter(ye=>!ye.archived&&b(ye.access).archive&&!Lx(ye,_.get(ye.sessionId))),[H,Ee,_,b]),Me=H===null||l!=null&&Rx(l.cwd||xs(l.dirName))===H,Ue=y.useRef(!1);y.useEffect(()=>{if(Ue.current||!u||k.length===0)return;Ue.current=!0;const ye=Aa(k).slice(0,3),Re=globalThis,Ve=()=>{for(const je of ye)u(je.dirName,je.fileName)};let He=null,me=null;return typeof Re.requestIdleCallback=="function"?He=Re.requestIdleCallback(Ve,{timeout:1500}):me=setTimeout(Ve,300),()=>{He!=null&&typeof Re.cancelIdleCallback=="function"&&Re.cancelIdleCallback(He),me!=null&&clearTimeout(me)}},[k,u]);const De=y.useCallback(async(ye,Re)=>{Re.stopPropagation(),B(Ve=>new Set(Ve).add(ye));try{if(!(await Ce("/api/kill-process",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pid:ye})})).ok)throw new Error("Could not stop session");ie(E,1500)}catch{Kn.error("Could not stop session")}ie(()=>{B(Ve=>{const He=new Set(Ve);return He.delete(ye),He})},2e3)},[E,ie]);y.useEffect(()=>{const ye=k.find(Re=>`${Re.dirName}/${Re.fileName}`===e);ye&&N.has(ye.sessionId)&&$(ye.sessionId)},[e,k,N,$]);const Ke=y.useCallback(async ye=>{await(r==null?void 0:r(ye.dirName,ye.fileName))&&T(ye.sessionId)},[r,T]),Ne=zI(),Ae=y.useCallback(ye=>{Ne([ye.sessionId],!0,`Archived “${pi(ye,d[ye.sessionId])}”`)},[Ne,d]),Qe=y.useCallback(ye=>{Ne([ye.sessionId],!1,`Restored “${pi(ye,d[ye.sessionId])}”`)},[Ne,d]),Je=y.useCallback(ye=>{if(ye.length===0)return;const Re=ye.map(Ve=>Ve.sessionId);Ne(Re,!0,`Archived ${Re.length} ${Re.length===1?"session":"sessions"}`)},[Ne]),ke=y.useCallback((ye,Re,Ve)=>{const{command:He,args:me}=lR(un(Ve),ye),je=`resume_${crypto.randomUUID().slice(0,8)}`;h.send({type:"spawn",id:je,name:`Resume ${ye.slice(0,8)}`,command:He,args:me,cwd:Re??void 0,metadata:{type:"terminal"}}),ie(E,3e3)},[h,E,ie]),We={activeSessionKey:e,procBySession:_,killingPids:D,newlyCompleted:N,sessionNames:d,projectNames:m,onSelectSession:t,onKill:x?De:void 0,onDuplicateSession:s,onDeleteSession:r?Ke:void 0,onArchiveSession:Ae,onUnarchiveSession:Qe,onRenameSession:f,onPrefetchSession:u,onResumeSession:g?ke:void 0};return a.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[a.jsx(Jxe,{loading:S,isMobile:ae,searchQuery:q,searchLoading:oe.loading,showArchived:A,archivedCount:z,groupCrews:X,onToggleGroupCrews:()=>Y(!X),onSearchQueryChange:W,onToggleShowArchived:()=>R(!A),onRefresh:()=>{Oxe(),E()}}),v&&a.jsx(v,{}),a.jsx(_0e,{options:be,value:H,focused:ve,totalSessions:ge.length,crewCount:X?le.crewOf.size:0,onChange:K,onNewSession:o,creatingSession:i,onRenameProject:p,archivableCount:Ie.length,onArchiveIdle:()=>Je(Ie)}),a.jsx(Vc,{className:"flex-1",children:a.jsxs("div",{className:"flex flex-col gap-4 p-2",children:[a.jsx(e0e,{fetchError:oe.error??C,showEmpty:Be.length===0&&!(l&&Me)&&!S&&!oe.loading&&!C&&!oe.error,searching:ee,loading:S||oe.loading,sessionCount:oe.active?Be.length:ue.length,hiddenArchivedCount:re,focusedProject:Se,onShowAllProjects:()=>K(null),filterEmpty:w.key!==null&&j?a.jsx(j,{className:"min-h-56 px-4 py-8"}):null,onShowArchived:()=>R(!0),onRetry:oe.error?oe.refresh:E}),ze&&a.jsx(Xxe,{groups:ce,activeSessionKey:e,procBySession:_,killingPids:D,sessionNames:d,projectNames:m,onSelectSession:t,onKill:x?De:void 0,onResumeSession:g?ke:void 0,onPrefetchSession:u}),a.jsx(v0e,{...We,sessions:Be,pendingSession:Me?l:null,showProject:H===null,groupCrews:te,lineageSessions:ue,memberStatusOf:fe,older:{canLoad:(H===null||!!ve)&&!we.loaded&&!ee,loading:we.loading,load:we.load}})]})})]})}),z0e=y.memo(function(e){const t=V.c(16),{activeSessionKey:s,onSelectSession:r,onNewSession:o,creatingSession:i,isMobile:l,onDuplicateSession:c,onDeleteSession:u,pendingSession:d,liveSessionsRefreshRef:f,onPrefetchSession:m,header:p}=e,h=l?"w-full":"w-80";let g;t[0]!==h?(g=G("flex h-full shrink-0 flex-col bg-sidebar",h),t[0]=h,t[1]=g):g=t[1];let x;t[2]!==s||t[3]!==i||t[4]!==f||t[5]!==u||t[6]!==c||t[7]!==o||t[8]!==m||t[9]!==r||t[10]!==d?(x=a.jsx(M0e,{activeSessionKey:s,onSelectSession:r,onDuplicateSession:c,onDeleteSession:u,onNewSession:o,creatingSession:i,pendingSession:d,refreshRef:f,onPrefetchSession:m}),t[2]=s,t[3]=i,t[4]=f,t[5]=u,t[6]=c,t[7]=o,t[8]=m,t[9]=r,t[10]=d,t[11]=x):x=t[11];let b;return t[12]!==p||t[13]!==g||t[14]!==x?(b=a.jsxs("aside",{className:g,"aria-label":"Session browser",children:[p,x]}),t[12]=p,t[13]=g,t[14]=x,t[15]=b):b=t[15],b}),D0e=y.lazy(()=>nt(()=>import("./MissionHome-CK5zZCld.js"),__vite__mapDeps([37,1,2,3,4])).then(n=>({default:n.MissionHome})));function Rm(n){const e=V.c(3),{label:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(Pn,{className:"size-4"}),e[0]=s):s=e[0];let r;return e[1]!==t?(r=a.jsxs("div",{className:"motion-enter flex min-h-0 flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",role:"status",children:[s,t]}),e[1]=t,e[2]=r):r=e[2],r}function p7(n){const e=V.c(12),{navigation:t,mobile:s,header:r}=n,o=s===void 0?!1:s,{sessionSource:i}=kt(),l=i?`${i.dirName}/${i.fileName}`:null;let c;return e[0]!==l||e[1]!==r||e[2]!==o||e[3]!==t.actions.handleDashboardSelect||e[4]!==t.creatingSession||e[5]!==t.handlers.handleDeleteSession||e[6]!==t.handlers.handleDuplicateSessionByPath||e[7]!==t.liveSessionsRefreshRef||e[8]!==t.onPrefetchSession||e[9]!==t.onStartNewSession||e[10]!==t.pendingSession?(c=a.jsx(z0e,{activeSessionKey:l,onSelectSession:t.actions.handleDashboardSelect,onNewSession:t.onStartNewSession,creatingSession:t.creatingSession,pendingSession:t.pendingSession,onDuplicateSession:t.handlers.handleDuplicateSessionByPath,onDeleteSession:t.handlers.handleDeleteSession,liveSessionsRefreshRef:t.liveSessionsRefreshRef,onPrefetchSession:t.onPrefetchSession,isMobile:o,header:r}),e[0]=l,e[1]=r,e[2]=o,e[3]=t.actions.handleDashboardSelect,e[4]=t.creatingSession,e[5]=t.handlers.handleDeleteSession,e[6]=t.handlers.handleDuplicateSessionByPath,e[7]=t.liveSessionsRefreshRef,e[8]=t.onPrefetchSession,e[9]=t.onStartNewSession,e[10]=t.pendingSession,e[11]=c):c=e[11],c}function F0e(n){const e=V.c(8),{navigation:t}=n,{state:s}=Sn();let r;return e[0]!==t.actions.handleDashboardSelect||e[1]!==t.creatingSession||e[2]!==t.handlers.handleDeleteSession||e[3]!==t.handlers.handleDuplicateSessionByPath||e[4]!==t.onSelectProject||e[5]!==t.onStartNewSession||e[6]!==s.dashboardProject?(r=a.jsx(Rxe,{onSelectSession:t.actions.handleDashboardSelect,onNewSession:t.onStartNewSession,creatingSession:t.creatingSession,selectedProjectDirName:s.dashboardProject,onSelectProject:t.onSelectProject,onDuplicateSession:t.handlers.handleDuplicateSessionByPath,onDeleteSession:t.handlers.handleDeleteSession}),e[0]=t.actions.handleDashboardSelect,e[1]=t.creatingSession,e[2]=t.handlers.handleDeleteSession,e[3]=t.handlers.handleDuplicateSessionByPath,e[4]=t.onSelectProject,e[5]=t.onStartNewSession,e[6]=s.dashboardProject,e[7]=r):r=e[7],r}function bf(n){const e=V.c(7),{navigation:t,showProjectHistory:s}=n,r=s===void 0?!1:s,{state:o,config:i}=Sn(),[l,c]=y.useState(!1);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=a.jsx(Rm,{label:"Loading Mission Control…"}),e[0]=u):u=e[0];let d;return e[1]!==l||e[2]!==i||e[3]!==t||e[4]!==r||e[5]!==o?(d=a.jsx(y.Suspense,{fallback:u,children:a.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 flex-col",children:l||r&&o.dashboardProject?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"px-4 pt-12",children:a.jsxs(Q,{variant:"ghost",size:"sm",onClick:()=>{t.onSelectProject(null),c(!1)},children:[a.jsx(bx,{"data-icon":"inline-start"})," Mission Control"]})}),a.jsx(F0e,{navigation:t})]}):a.jsx(D0e,{onOpenSession:t.actions.handleDashboardSelect,onBrowseProjects:()=>c(!0),start:{defaultAgentKind:i.defaultAgentKind,model:t.newSessionModel,onStart:t.onStartNewSessionWith}})})}),e[1]=l,e[2]=i,e[3]=t,e[4]=r,e[5]=o,e[6]=d):d=e[6],d}function h7(n){const e=V.c(8),{view:t,onClose:s}=n,{Component:r}=t,o=`Loading ${t.label}…`;let i;e[0]!==o?(i=a.jsx(Rm,{label:o}),e[0]=o,e[1]=i):i=e[1];let l;e[2]!==r||e[3]!==s?(l=a.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 flex-col",children:a.jsx(r,{onClose:s})}),e[2]=r,e[3]=s,e[4]=l):l=e[4];let c;return e[5]!==i||e[6]!==l?(c=a.jsx(y.Suspense,{fallback:i,children:l}),e[5]=i,e[6]=l,e[7]=c):c=e[7],c}function U0e({mainView:n,hasSession:e,pendingDirName:t,extensionViewAvailable:s}){return n==="config"?"config":n==="mission"?"mission":n==="extension"&&s?"extension":e?"session":t?"pending":"dashboard"}function B0e({sessionCwd:n,pendingPath:e,sessionDirPath:t,dashboardProjectPath:s}){return n??e??t??s??null}function g7({path:n,text:e,startLine:t,endLine:s,comment:r}){if(!e)return`@${n}`;const o=e.includes("```")?"````":"```",i=t===s?`line ${t}`:`lines ${t}-${s}`;return`${r?`Review request: ${r}
471
471
  `:""}${n} (${i})
472
472
  ${o}
473
473
  ${e}
474
- ${o}`}const W0e=y.lazy(()=>nt(()=>import("./ConfigBrowser-Bg_4DTXP.js"),__vite__mapDeps([38,1,2,33,3,4])).then(n=>({default:n.ConfigBrowser}))),q0e=y.lazy(()=>nt(()=>import("./PreviewPanel-u6bXlEMm.js"),__vite__mapDeps([39,1,2,3,4])).then(n=>({default:n.PreviewPanel}))),V0e=y.lazy(()=>nt(()=>import("./PluginsDialog-XdukDCaQ.js"),__vite__mapDeps([40,1,2,3,4])).then(n=>({default:n.PluginsDialog})));function H0e(n){const e=V.c(20),{sessionView:t,floatingChrome:s}=n,{session:r}=kt();if(!r)return null;let o;e[0]!==t.teamMembersBar?(o=t.teamMembersBar&&a.jsx("div",{className:"pt-10",children:t.teamMembersBar}),e[0]=t.teamMembersBar,e[1]=o):o=e[1];const i=!!t.todoProgress&&t.todosExpanded;let l;e[2]!==t.hasMoreTurns||e[3]!==t.isLoadingOlderTurns||e[4]!==t.onLoadMoreTurns||e[5]!==t.searchInputRef||e[6]!==i?(l=a.jsx(Tm,{searchInputRef:t.searchInputRef,hasTodos:i,hasMore:t.hasMoreTurns,isLoadingOlder:t.isLoadingOlderTurns,onLoadMore:t.onLoadMoreTurns}),e[2]=t.hasMoreTurns,e[3]=t.isLoadingOlderTurns,e[4]=t.onLoadMoreTurns,e[5]=t.searchInputRef,e[6]=i,e[7]=l):l=e[7];let c;e[8]!==t.onTodosExpandedChange||e[9]!==t.todoProgress||e[10]!==t.todosExpanded?(c=t.todoProgress&&a.jsx(pA,{progress:t.todoProgress,expanded:t.todosExpanded,onExpandedChange:t.onTodosExpandedChange}),e[8]=t.onTodosExpandedChange,e[9]=t.todoProgress,e[10]=t.todosExpanded,e[11]=c):c=e[11];let u;e[12]!==t.activeComposer||e[13]!==c?(u=a.jsxs(Im,{floating:!0,children:[c,t.activeComposer]}),e[12]=t.activeComposer,e[13]=c,e[14]=u):u=e[14];let d;return e[15]!==s||e[16]!==o||e[17]!==l||e[18]!==u?(d=a.jsx("div",{className:"flex min-h-0 flex-1",children:a.jsxs("div",{className:"relative flex h-full min-h-0 flex-1 flex-col",children:[s,o,l,u]})}),e[15]=s,e[16]=o,e[17]=l,e[18]=u,e[19]=d):d=e[19],d}function K0e(n){const e=V.c(41),{navigation:t,sessionView:s,project:r,view:o,extensionView:i,floatingChrome:l}=n,{state:c,config:u}=Sn(),{session:d,sessionSource:f}=kt();let m,p;if(e[0]!==(d==null?void 0:d.cwd)||e[1]!==f||e[2]!==c.configFilePath||e[3]!==c.dashboardProject||e[4]!==c.pendingCwd||e[5]!==c.pendingDirName||e[6]!==o){p=Symbol.for("react.early_return_sentinel");e:if(m=c.pendingCwd??(c.pendingDirName?xs(c.pendingDirName):null),o==="config"){let g;e[9]===Symbol.for("react.memo_cache_sentinel")?(g=a.jsx(Rm,{label:"Loading configuration…"}),e[9]=g):g=e[9];const x=a.jsx(W0e,{projectPath:B0e({sessionCwd:d==null?void 0:d.cwd,pendingPath:m,sessionDirPath:f!=null&&f.dirName?xs(f.dirName):null,dashboardProjectPath:c.dashboardProject?xs(c.dashboardProject):null}),initialFilePath:c.configFilePath});let b;e[10]!==x?(b=a.jsx(y.Suspense,{fallback:g,children:a.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 pt-10",children:x})}),e[10]=x,e[11]=b):b=e[11],p=b;break e}e[0]=d==null?void 0:d.cwd,e[1]=f,e[2]=c.configFilePath,e[3]=c.dashboardProject,e[4]=c.pendingCwd,e[5]=c.pendingDirName,e[6]=o,e[7]=m,e[8]=p}else m=e[7],p=e[8];if(p!==Symbol.for("react.early_return_sentinel"))return p;if(o==="mission"){let g;return e[12]!==t?(g=a.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:a.jsx(bf,{navigation:t})}),e[12]=t,e[13]=g):g=e[13],g}if(o==="extension"&&i){let g;return e[14]!==i||e[15]!==t.panels.closeMainView?(g=a.jsx("div",{className:"flex min-h-0 flex-1 flex-col pt-10",children:a.jsx(h7,{view:i,onClose:t.panels.closeMainView})}),e[14]=i,e[15]=t.panels.closeMainView,e[16]=g):g=e[16],g}if(o==="session"){let g;return e[17]!==l||e[18]!==s?(g=a.jsx(H0e,{sessionView:s,floatingChrome:l}),e[17]=l,e[18]=s,e[19]=g):g=e[19],g}if(o==="pending"){const g=s.pendingTurns.length>0,x=qo()?"Only on the machine running this session":void 0;let b;e[20]===Symbol.for("react.memo_cache_sentinel")?(b=wb()?void 0:x,e[20]=b):b=e[20];const w=b,v=!g&&"justify-center gap-4";let j;e[21]!==v?(j=G("flex min-h-0 min-w-0 flex-1 flex-col",v),e[21]=v,e[22]=j):j=e[22];let k;e[23]!==u||e[24]!==g||e[25]!==t||e[26]!==m||e[27]!==s.pendingTurns?(k=g?a.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-14",children:a.jsx("div",{className:"mx-auto w-full max-w-[var(--chat-width)]",children:s.pendingTurns})}):a.jsx(QI,{projectPath:m,switcher:{onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:u.defaultAgentKind}}),e[23]=u,e[24]=g,e[25]=t,e[26]=m,e[27]=s.pendingTurns,e[28]=k):k=e[28];let _;e[29]!==s.pendingComposer?(_=a.jsx(Im,{children:s.pendingComposer}),e[29]=s.pendingComposer,e[30]=_):_=e[30];let N;e[31]!==g||e[32]!==r?(N=!g&&a.jsxs("div",{className:"flex items-center justify-center gap-2",children:[xt("terminal")&&a.jsx(vd,{reason:x,children:a.jsxs(Q,{variant:"outline",size:"xs",disabled:!!x,onClick:r.onOpenTerminal,children:[a.jsx(Ca,{"data-icon":"inline-start"}),"Terminal"]})}),xt("hostFiles")&&a.jsxs(a.Fragment,{children:[a.jsx(vd,{reason:w,children:a.jsxs(Q,{variant:"outline",size:"xs",disabled:!!w,onClick:()=>c6(r.pendingProject),children:[a.jsx(hx,{"data-icon":"inline-start"}),"Open in editor"]})}),a.jsx(vd,{reason:x,children:a.jsxs(Q,{variant:"outline",size:"xs",disabled:!!x,onClick:()=>u6(r.pendingProject),children:[a.jsx(wc,{"data-icon":"inline-start"}),"Reveal in files"]})})]})]}),e[31]=g,e[32]=r,e[33]=N):N=e[33];let S;return e[34]!==j||e[35]!==k||e[36]!==_||e[37]!==N?(S=a.jsxs("div",{className:j,children:[k,_,N]}),e[34]=j,e[35]=k,e[36]=_,e[37]=N,e[38]=S):S=e[38],S}let h;return e[39]!==t?(h=a.jsx(bf,{navigation:t,showProjectHistory:!0}),e[39]=t,e[40]=h):h=e[40],h}function G0e(n){const e=V.c(129),{navigation:t,sessionView:s,project:r,chrome:o}=n,{state:i,config:l}=Sn(),{session:c,sessionSource:u}=kt(),d=$I((c==null?void 0:c.sessionId)??null),[f,m]=y.useState(Z0e),[p,h]=y.useState();let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=Ue=>{h(Ue),m(!0)},e[0]=g):g=e[0];const x=g;let b;e[1]===Symbol.for("react.memo_cache_sentinel")?(b=xt("configWrite"),e[1]=b):b=e[1];const w=qI(b),v=r.currentCwd??null;let j;e[2]!==w||e[3]!==v?(j={...w,projectPath:v,openSettings:x},e[2]=w,e[3]=v,e[4]=j):j=e[4];const k=HI(j),_=zN(i.mainView==="extension"?i.extensionViewId:null);let N;e[5]!==s.chatInputRef?(N=function(De){var Ne,Ae,Qe;const Ke=((Ne=s.chatInputRef.current)==null?void 0:Ne.getText().trimEnd())??"";(Ae=s.chatInputRef.current)==null||Ae.setText(Ke?`${Ke}
474
+ ${o}`}const W0e=y.lazy(()=>nt(()=>import("./ConfigBrowser-C_4UyHta.js"),__vite__mapDeps([38,1,2,33,3,4])).then(n=>({default:n.ConfigBrowser}))),q0e=y.lazy(()=>nt(()=>import("./PreviewPanel-CXOXFWWK.js"),__vite__mapDeps([39,1,2,3,4])).then(n=>({default:n.PreviewPanel}))),V0e=y.lazy(()=>nt(()=>import("./PluginsDialog-BHKZ3Esx.js"),__vite__mapDeps([40,1,2,3,4])).then(n=>({default:n.PluginsDialog})));function H0e(n){const e=V.c(20),{sessionView:t,floatingChrome:s}=n,{session:r}=kt();if(!r)return null;let o;e[0]!==t.teamMembersBar?(o=t.teamMembersBar&&a.jsx("div",{className:"pt-10",children:t.teamMembersBar}),e[0]=t.teamMembersBar,e[1]=o):o=e[1];const i=!!t.todoProgress&&t.todosExpanded;let l;e[2]!==t.hasMoreTurns||e[3]!==t.isLoadingOlderTurns||e[4]!==t.onLoadMoreTurns||e[5]!==t.searchInputRef||e[6]!==i?(l=a.jsx(Tm,{searchInputRef:t.searchInputRef,hasTodos:i,hasMore:t.hasMoreTurns,isLoadingOlder:t.isLoadingOlderTurns,onLoadMore:t.onLoadMoreTurns}),e[2]=t.hasMoreTurns,e[3]=t.isLoadingOlderTurns,e[4]=t.onLoadMoreTurns,e[5]=t.searchInputRef,e[6]=i,e[7]=l):l=e[7];let c;e[8]!==t.onTodosExpandedChange||e[9]!==t.todoProgress||e[10]!==t.todosExpanded?(c=t.todoProgress&&a.jsx(pA,{progress:t.todoProgress,expanded:t.todosExpanded,onExpandedChange:t.onTodosExpandedChange}),e[8]=t.onTodosExpandedChange,e[9]=t.todoProgress,e[10]=t.todosExpanded,e[11]=c):c=e[11];let u;e[12]!==t.activeComposer||e[13]!==c?(u=a.jsxs(Im,{floating:!0,children:[c,t.activeComposer]}),e[12]=t.activeComposer,e[13]=c,e[14]=u):u=e[14];let d;return e[15]!==s||e[16]!==o||e[17]!==l||e[18]!==u?(d=a.jsx("div",{className:"flex min-h-0 flex-1",children:a.jsxs("div",{className:"relative flex h-full min-h-0 flex-1 flex-col",children:[s,o,l,u]})}),e[15]=s,e[16]=o,e[17]=l,e[18]=u,e[19]=d):d=e[19],d}function K0e(n){const e=V.c(41),{navigation:t,sessionView:s,project:r,view:o,extensionView:i,floatingChrome:l}=n,{state:c,config:u}=Sn(),{session:d,sessionSource:f}=kt();let m,p;if(e[0]!==(d==null?void 0:d.cwd)||e[1]!==f||e[2]!==c.configFilePath||e[3]!==c.dashboardProject||e[4]!==c.pendingCwd||e[5]!==c.pendingDirName||e[6]!==o){p=Symbol.for("react.early_return_sentinel");e:if(m=c.pendingCwd??(c.pendingDirName?xs(c.pendingDirName):null),o==="config"){let g;e[9]===Symbol.for("react.memo_cache_sentinel")?(g=a.jsx(Rm,{label:"Loading configuration…"}),e[9]=g):g=e[9];const x=a.jsx(W0e,{projectPath:B0e({sessionCwd:d==null?void 0:d.cwd,pendingPath:m,sessionDirPath:f!=null&&f.dirName?xs(f.dirName):null,dashboardProjectPath:c.dashboardProject?xs(c.dashboardProject):null}),initialFilePath:c.configFilePath});let b;e[10]!==x?(b=a.jsx(y.Suspense,{fallback:g,children:a.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 pt-10",children:x})}),e[10]=x,e[11]=b):b=e[11],p=b;break e}e[0]=d==null?void 0:d.cwd,e[1]=f,e[2]=c.configFilePath,e[3]=c.dashboardProject,e[4]=c.pendingCwd,e[5]=c.pendingDirName,e[6]=o,e[7]=m,e[8]=p}else m=e[7],p=e[8];if(p!==Symbol.for("react.early_return_sentinel"))return p;if(o==="mission"){let g;return e[12]!==t?(g=a.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:a.jsx(bf,{navigation:t})}),e[12]=t,e[13]=g):g=e[13],g}if(o==="extension"&&i){let g;return e[14]!==i||e[15]!==t.panels.closeMainView?(g=a.jsx("div",{className:"flex min-h-0 flex-1 flex-col pt-10",children:a.jsx(h7,{view:i,onClose:t.panels.closeMainView})}),e[14]=i,e[15]=t.panels.closeMainView,e[16]=g):g=e[16],g}if(o==="session"){let g;return e[17]!==l||e[18]!==s?(g=a.jsx(H0e,{sessionView:s,floatingChrome:l}),e[17]=l,e[18]=s,e[19]=g):g=e[19],g}if(o==="pending"){const g=s.pendingTurns.length>0,x=qo()?"Only on the machine running this session":void 0;let b;e[20]===Symbol.for("react.memo_cache_sentinel")?(b=wb()?void 0:x,e[20]=b):b=e[20];const w=b,v=!g&&"justify-center gap-4";let j;e[21]!==v?(j=G("flex min-h-0 min-w-0 flex-1 flex-col",v),e[21]=v,e[22]=j):j=e[22];let k;e[23]!==u||e[24]!==g||e[25]!==t||e[26]!==m||e[27]!==s.pendingTurns?(k=g?a.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-14",children:a.jsx("div",{className:"mx-auto w-full max-w-[var(--chat-width)]",children:s.pendingTurns})}):a.jsx(QI,{projectPath:m,switcher:{onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:u.defaultAgentKind}}),e[23]=u,e[24]=g,e[25]=t,e[26]=m,e[27]=s.pendingTurns,e[28]=k):k=e[28];let _;e[29]!==s.pendingComposer?(_=a.jsx(Im,{children:s.pendingComposer}),e[29]=s.pendingComposer,e[30]=_):_=e[30];let N;e[31]!==g||e[32]!==r?(N=!g&&a.jsxs("div",{className:"flex items-center justify-center gap-2",children:[xt("terminal")&&a.jsx(vd,{reason:x,children:a.jsxs(Q,{variant:"outline",size:"xs",disabled:!!x,onClick:r.onOpenTerminal,children:[a.jsx(Ca,{"data-icon":"inline-start"}),"Terminal"]})}),xt("hostFiles")&&a.jsxs(a.Fragment,{children:[a.jsx(vd,{reason:w,children:a.jsxs(Q,{variant:"outline",size:"xs",disabled:!!w,onClick:()=>c6(r.pendingProject),children:[a.jsx(hx,{"data-icon":"inline-start"}),"Open in editor"]})}),a.jsx(vd,{reason:x,children:a.jsxs(Q,{variant:"outline",size:"xs",disabled:!!x,onClick:()=>u6(r.pendingProject),children:[a.jsx(wc,{"data-icon":"inline-start"}),"Reveal in files"]})})]})]}),e[31]=g,e[32]=r,e[33]=N):N=e[33];let S;return e[34]!==j||e[35]!==k||e[36]!==_||e[37]!==N?(S=a.jsxs("div",{className:j,children:[k,_,N]}),e[34]=j,e[35]=k,e[36]=_,e[37]=N,e[38]=S):S=e[38],S}let h;return e[39]!==t?(h=a.jsx(bf,{navigation:t,showProjectHistory:!0}),e[39]=t,e[40]=h):h=e[40],h}function G0e(n){const e=V.c(129),{navigation:t,sessionView:s,project:r,chrome:o}=n,{state:i,config:l}=Sn(),{session:c,sessionSource:u}=kt(),d=$I((c==null?void 0:c.sessionId)??null),[f,m]=y.useState(Z0e),[p,h]=y.useState();let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=Ue=>{h(Ue),m(!0)},e[0]=g):g=e[0];const x=g;let b;e[1]===Symbol.for("react.memo_cache_sentinel")?(b=xt("configWrite"),e[1]=b):b=e[1];const w=qI(b),v=r.currentCwd??null;let j;e[2]!==w||e[3]!==v?(j={...w,projectPath:v,openSettings:x},e[2]=w,e[3]=v,e[4]=j):j=e[4];const k=HI(j),_=zN(i.mainView==="extension"?i.extensionViewId:null);let N;e[5]!==s.chatInputRef?(N=function(De){var Ne,Ae,Qe;const Ke=((Ne=s.chatInputRef.current)==null?void 0:Ne.getText().trimEnd())??"";(Ae=s.chatInputRef.current)==null||Ae.setText(Ke?`${Ke}
475
475
 
476
476
  ${De}
477
477
  `:`${De}
478
- `),(Qe=s.chatInputRef.current)==null||Qe.focus()},e[5]=s.chatInputRef,e[6]=N):N=e[6];const S=N;let C;e[7]!==S?(C=function(De){const{path:Ke,text:Ne,startLine:Ae,endLine:Qe,comment:Je}=De;S(g7({path:Ke,text:Ne,startLine:Ae,endLine:Qe,comment:Je}))},e[7]=S,e[8]=C):C=e[8];const E=C,T=i.mainView,$=!!c,A=_!==null;let R;e[9]!==i.mainView||e[10]!==i.pendingDirName||e[11]!==$||e[12]!==A?(R=U0e({mainView:T,hasSession:$,pendingDirName:i.pendingDirName,extensionViewAvailable:A}),e[9]=i.mainView,e[10]=i.pendingDirName,e[11]=$,e[12]=A,e[13]=R):R=e[13];const P=R,z=t.panels.handleToggleSidebar,L=t.actions.handleGoHome,I=o.onOpenCommandPalette;let M,F;e[14]===Symbol.for("react.memo_cache_sentinel")?(M=Qi("toggleSidebar"),F=Qi("commandPalette"),e[14]=M,e[15]=F):(M=e[14],F=e[15]);let U;e[16]!==o.onOpenCommandPalette||e[17]!==t.actions.handleGoHome||e[18]!==t.panels.handleToggleSidebar?(U=a.jsx(Yhe,{onToggleSidebar:z,onGoHome:L,onOpenCommandPalette:I,sidebarShortcut:M,commandPaletteShortcut:F}),e[16]=o.onOpenCommandPalette,e[17]=t.actions.handleGoHome,e[18]=t.panels.handleToggleSidebar,e[19]=U):U=e[19];const O=U,D=P==="mission"||P==="dashboard"&&!i.dashboardProject;let B;e[20]===Symbol.for("react.memo_cache_sentinel")?(B=new Set,e[20]=B):B=e[20];const q=y.useRef(B),W=t.panels.openWorkspacePanel;let H,K;e[21]!==D||e[22]!==d||e[23]!==W?(H=()=>{D||!d||q.current.has(d.rootId)||(q.current.add(d.rootId),W(Ot.crew))},K=[D,d,W],e[21]=D,e[22]=d,e[23]=W,e[24]=H,e[25]=K):(H=e[24],K=e[25]),y.useEffect(H,K);const Z=t.panels.showSidebar&&i.mainView!=="config"&&!D;let Y,X,ee;e[26]!==S||e[27]!==D||e[28]!==t.handlers.handleLoadSessionScrollAware||e[29]!==t.panels.activeWorkspacePanel||e[30]!==d||e[31]!==r.currentCwd||e[32]!==r.hasFileChanges||e[33]!==r.supportsWorktrees||e[34]!==c||e[35]!==u||e[36]!==i.mainView||e[37]!==i.sessionChangeKey||e[38]!==k?(Y={session:c,sessionAddress:u?{dirName:u.dirName,fileName:u.fileName}:null,sessionChangeKey:i.sessionChangeKey,projectPath:r.currentCwd??null,hasFileChanges:r.hasFileChanges,canAccessHostFiles:xt("hostFiles"),canUseBrowser:xt("browser"),supportsWorktrees:r.supportsWorktrees,openSession:t.handlers.handleLoadSessionScrollAware,composePrompt:S,crew:d},ee=Qb(k,Y),X=i.mainView==="sessions"&&!D?II(t.panels.activeWorkspacePanel,ee):null,e[26]=S,e[27]=D,e[28]=t.handlers.handleLoadSessionScrollAware,e[29]=t.panels.activeWorkspacePanel,e[30]=d,e[31]=r.currentCwd,e[32]=r.hasFileChanges,e[33]=r.supportsWorktrees,e[34]=c,e[35]=u,e[36]=i.mainView,e[37]=i.sessionChangeKey,e[38]=k,e[39]=Y,e[40]=X,e[41]=ee):(Y=e[39],X=e[40],ee=e[41]);const te=X,se=(u==null?void 0:u.dirName)??i.pendingDirName??i.dashboardProject??null;let J;e[42]!==t.panels||e[43]!==r?(J=function(De){r.showPreview&&r.onCloseRightWorkspace(),t.panels.toggleWorkspacePanel(De)},e[42]=t.panels,e[43]=r,e[44]=J):J=e[44];const ne=J;let ie;e[45]!==t.actions||e[46]!==t.panels?(ie=function(De){t.actions.handleDashboardSelect(De.dirName,`${De.sessionId}.jsonl`),t.panels.closeWorkspacePanel()},e[45]=t.actions,e[46]=t.panels,e[47]=ie):ie=e[47];const ae=ie,oe=t.panels.showSidebar;let ue;e[48]===Symbol.for("react.memo_cache_sentinel")?(ue=Qi("toggleSidebar"),e[48]=ue):ue=e[48];let re;e[49]!==o.killing||e[50]!==o.onKillAll||e[51]!==o.onLogout||e[52]!==l.openConfigDialog||e[53]!==t.creatingSession||e[54]!==t.handlers.handleDuplicateSession||e[55]!==t.onStartNewSession||e[56]!==t.panels.handleToggleSidebar||e[57]!==t.panels.openMainView||e[58]!==t.panels.showSidebar||e[59]!==r.onOpenTerminal||e[60]!==s.onBackToMain||e[61]!==s.onShowWorkflows||e[62]!==s.workflowCount||e[63]!==Z?(re=a.jsx(Ghe,{showSidebar:oe,sidebarRendered:Z,sidebarShortcut:ue,killing:o.killing,creatingSession:t.creatingSession,onNewSession:t.onStartNewSession,onDuplicateSession:t.handlers.handleDuplicateSession,onOpenTerminal:r.onOpenTerminal,onBackToMain:s.onBackToMain,onShowWorkflows:s.onShowWorkflows,workflowCount:s.workflowCount,onToggleSidebar:t.panels.handleToggleSidebar,onKillAll:o.onKillAll,onOpenSettings:l.openConfigDialog,onLogout:o.onLogout,onOpenMainView:t.panels.openMainView}),e[49]=o.killing,e[50]=o.onKillAll,e[51]=o.onLogout,e[52]=l.openConfigDialog,e[53]=t.creatingSession,e[54]=t.handlers.handleDuplicateSession,e[55]=t.onStartNewSession,e[56]=t.panels.handleToggleSidebar,e[57]=t.panels.openMainView,e[58]=t.panels.showSidebar,e[59]=r.onOpenTerminal,e[60]=s.onBackToMain,e[61]=s.onShowWorkflows,e[62]=s.workflowCount,e[63]=Z,e[64]=re):re=e[64];const de=re,fe=r.currentCwd??null;let le;e[65]!==t||e[66]!==O||e[67]!==Z?(le=Z&&a.jsx("div",{className:"view-transition-sidebar panel-enter w-80 shrink-0 border-r bg-sidebar text-sidebar-foreground",children:a.jsx(p7,{navigation:t,header:O})}),e[65]=t,e[66]=O,e[67]=Z,e[68]=le):le=e[68];const ce=te??null,he=r.projectFilesRoot??r.currentCwd??null;let ge;e[69]!==E||e[70]!==t.actions.handleJumpToTurn||e[71]!==t.handlers.handleLoadSessionScrollAware||e[72]!==ae||e[73]!==r.backgroundAgents||e[74]!==r.processPanel.handleServersChanged||e[75]!==r.processPanel.handleToggleServer||e[76]!==r.projectFilesRequest||e[77]!==r.worktrees||e[78]!==s.searchInputRef||e[79]!==he||e[80]!==se?(ge={projectFilesRoot:he,projectFilesRequest:r.projectFilesRequest,backgroundAgents:r.backgroundAgents,searchInputRef:s.searchInputRef,addProjectContext:E,jumpToTurn:t.actions.handleJumpToTurn,toggleServer:r.processPanel.handleToggleServer,serversChanged:r.processPanel.handleServersChanged,loadSession:t.handlers.handleLoadSessionScrollAware,worktrees:r.worktrees,worktreeDirName:se,openWorktreeSession:ae},e[69]=E,e[70]=t.actions.handleJumpToTurn,e[71]=t.handlers.handleLoadSessionScrollAware,e[72]=ae,e[73]=r.backgroundAgents,e[74]=r.processPanel.handleServersChanged,e[75]=r.processPanel.handleToggleServer,e[76]=r.projectFilesRequest,e[77]=r.worktrees,e[78]=s.searchInputRef,e[79]=he,e[80]=se,e[81]=ge):ge=e[81];let be;e[82]!==D||e[83]!==t.panels.handleToggleMission?(be={id:"mission-control",title:"Mission Control",icon:q4,active:D,onSelect:t.panels.handleToggleMission},e[82]=D,e[83]=t.panels.handleToggleMission,e[84]=be):be=e[84];let ve;e[85]!==t.panels.handleToggleConfig||e[86]!==f||e[87]!==i.mainView?(ve=xt("configWrite")?[{id:"plugins",title:"Plugins",icon:xx,active:f,onSelect:()=>m(!0)},{id:"config",title:"Config",icon:V4,active:i.mainView==="config",onSelect:t.panels.handleToggleConfig}]:[],e[85]=t.panels.handleToggleConfig,e[86]=f,e[87]=i.mainView,e[88]=ve):ve=e[88];let Se;e[89]!==be||e[90]!==ve?(Se=[be,...ve],e[89]=be,e[90]=ve,e[91]=Se):Se=e[91];const we=P!=="session"&&de;let Ee;e[92]!==_||e[93]!==de||e[94]!==t||e[95]!==r||e[96]!==s||e[97]!==P?(Ee=a.jsx(K0e,{navigation:t,sessionView:s,project:r,view:P,extensionView:_,floatingChrome:de}),e[92]=_,e[93]=de,e[94]=t,e[95]=r,e[96]=s,e[97]=P,e[98]=Ee):Ee=e[98];let $e;e[99]!==we||e[100]!==Ee?($e=a.jsxs("main",{className:"app-view-transition relative flex size-full min-w-0 flex-col overflow-hidden",children:[we,Ee]}),e[99]=we,e[100]=Ee,e[101]=$e):$e=e[101];let Be;e[102]!==t.panels.closeWorkspacePanel||e[103]!==Y||e[104]!==ce||e[105]!==ge||e[106]!==Se||e[107]!==$e||e[108]!==ne||e[109]!==ee?(Be=a.jsx(nge,{panels:ee,context:Y,activePanel:ce,services:ge,onClosePanel:t.panels.closeWorkspacePanel,onTogglePanel:ne,actions:Se,children:$e}),e[102]=t.panels.closeWorkspacePanel,e[103]=Y,e[104]=ce,e[105]=ge,e[106]=Se,e[107]=$e,e[108]=ne,e[109]=ee,e[110]=Be):Be=e[110];let qe;e[111]!==r.currentCwd||e[112]!==r.onCloseRightWorkspace||e[113]!==r.showPreview?(qe=r.showPreview&&r.currentCwd&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(q0e,{cwd:r.currentCwd,onClose:r.onCloseRightWorkspace})}),e[111]=r.currentCwd,e[112]=r.onCloseRightWorkspace,e[113]=r.showPreview,e[114]=qe):qe=e[114];let ze;e[115]!==p||e[116]!==f||e[117]!==r.currentCwd||e[118]!==w?(ze=f&&xt("configWrite")&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(V0e,{client:w.client,state:w,currentPath:r.currentCwd??null,initialPluginId:p,onClose:()=>{m(!1),h(void 0)}})}),e[115]=p,e[116]=f,e[117]=r.currentCwd,e[118]=w,e[119]=ze):ze=e[119];let Ie;e[120]!==le||e[121]!==Be||e[122]!==qe||e[123]!==ze?(Ie=a.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[le,Be,qe,ze]}),e[120]=le,e[121]=Be,e[122]=qe,e[123]=ze,e[124]=Ie):Ie=e[124];let Me;return e[125]!==w||e[126]!==fe||e[127]!==Ie?(Me=a.jsx(qE,{runtime:w,workspacePath:fe,children:Ie}),e[125]=w,e[126]=fe,e[127]=Ie,e[128]=Me):Me=e[128],Me}function Z0e(){return new URLSearchParams(window.location.search).get("pluginSafeMode")==="1"}function Y0e(n){const e=V.c(15),{navigation:t,sessionView:s,project:r,chrome:o}=n;let i,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx(xA,{}),l=a.jsx(gA,{}),e[0]=i,e[1]=l):(i=e[0],l=e[1]);let c;e[2]!==o||e[3]!==t||e[4]!==r||e[5]!==s?(c=a.jsx(G0e,{navigation:t,sessionView:s,project:r,chrome:o}),e[2]=o,e[3]=t,e[4]=r,e[5]=s,e[6]=c):c=e[6];let u;e[7]!==o||e[8]!==t||e[9]!==r?(u=a.jsx(upe,{navigation:t,project:r,chrome:o}),e[7]=o,e[8]=t,e[9]=r,e[10]=u):u=e[10];let d;return e[11]!==o.backgroundServers||e[12]!==c||e[13]!==u?(d=a.jsxs("div",{className:"flex h-dvh flex-col bg-canvas text-foreground",children:[o.backgroundServers,i,l,c,u]}),e[11]=o.backgroundServers,e[12]=c,e[13]=u,e[14]=d):d=e[14],d}const X0e=[{id:"sessions",label:"Sessions",icon:Zr},{id:"chat",label:"Chat",icon:vc},{id:"workspace",label:"Workspace",icon:D8}],J0e=y.memo(function(e){const t=V.c(6),{activeTab:s,onTabChange:r}=e,{isLive:o}=kt();let i;t[0]!==s||t[1]!==o||t[2]!==r?(i=X0e.map(c=>{const u=c.icon,d=s===c.id;return a.jsx("button",{type:"button","aria-current":d?"page":void 0,"aria-label":c.label,title:c.label,onClick:()=>{q1(),r(c.id)},className:G("flex min-h-14 flex-1 items-center justify-center outline-none transition-[color,transform] duration-150 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset motion-reduce:transition-none",d?"text-foreground":"text-muted-foreground hover:text-foreground"),children:a.jsxs("div",{className:G("relative flex size-9 items-center justify-center rounded-md transition-[background-color,transform,scale] duration-150 ease-out motion-reduce:transition-none",d?"scale-100 bg-accent":"scale-95"),children:[a.jsx(u,{className:G("size-[18px] transition-transform duration-150 ease-out motion-reduce:transition-none",d&&"scale-110"),"aria-hidden":"true"}),c.id==="chat"&&o&&!d&&a.jsx(Sm,{"aria-label":"Session is live",className:"absolute right-0.5 top-0.5 size-1.5 ring-2 ring-background"})]})},c.id)}),t[0]=s,t[1]=o,t[2]=r,t[3]=i):i=t[3];let l;return t[4]!==i?(l=a.jsx("nav",{className:"flex shrink-0 items-stretch border-t bg-background pb-[env(safe-area-inset-bottom)]","aria-label":"Navigation",children:i}),t[4]=i,t[5]=l):l=t[5],l});function Q0e(n){const e=V.c(77),{session:t,sessionSource:s,isSubAgentView:r,isLive:o,canArchive:i,onProviderHandoff:l,claudeRawMessages:c,headerAccessory:u,creatingSession:d,onNewSession:f,onDuplicateSession:m,onBackToMain:p,onShowFileChanges:h,hasFileChanges:g,onShowWorkflows:x,workflowCount:b,onSearch:w,expandAll:v,onToggleExpandAll:j}=n,k=DI(t.sessionId,o,i);let _;e[0]!==f||e[1]!==t.cwd||e[2]!==s?(_=()=>{s&&f(s.dirName,t.cwd)},e[0]=f,e[1]=t.cwd,e[2]=s,e[3]=_):_=e[3];const N=_;let S;e[4]!==r||e[5]!==p?(S=r&&p&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",onClick:p,"aria-label":"Back to main agent",children:a.jsx(lx,{"data-icon":"inline-start"})}),e[4]=r,e[5]=p,e[6]=S):S=e[6];let C,E;e[7]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsx(Zb,{compact:!0}),E=a.jsx(en,{orientation:"vertical",className:"h-4"}),e[7]=C,e[8]=E):(C=e[7],E=e[8]);let T;e[9]!==c?(T=a.jsx(cA,{rawMessages:c,warnOnly:!0}),e[9]=c,e[10]=T):T=e[10];let $;e[11]!==t.cwd?($=t.cwd?_r(t.cwd):"Session",e[11]=t.cwd,e[12]=$):$=e[12];let A;e[13]!==$?(A=a.jsx("span",{className:"truncate text-xs font-medium text-muted-foreground",children:$}),e[13]=$,e[14]=A):A=e[14];let R;e[15]!==o?(R=o&&a.jsx(Sm,{"aria-label":"Session is live"}),e[15]=o,e[16]=R):R=e[16];let P;e[17]!==A||e[18]!==R?(P=a.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-center gap-1.5",children:[A,R]}),e[17]=A,e[18]=R,e[19]=P):P=e[19];let z;e[20]===Symbol.for("react.memo_cache_sentinel")?(z=a.jsx(Rc,{render:a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Session actions"}),children:a.jsx(B4,{"data-icon":"inline-start"})}),e[20]=z):z=e[20];let L;e[21]!==t.cwd?(L=t.cwd?_r(t.cwd):"Current session",e[21]=t.cwd,e[22]=L):L=e[22];let I;e[23]!==L?(I=a.jsx("span",{className:"truncate text-foreground",children:L}),e[23]=L,e[24]=I):I=e[24];let M;e[25]!==t.gitBranch||e[26]!==t.model?(M=[t.model,t.gitBranch].filter(Boolean).join(" · ")||"Session actions",e[25]=t.gitBranch,e[26]=t.model,e[27]=M):M=e[27];let F;e[28]!==M?(F=a.jsx("span",{className:"truncate font-normal",children:M}),e[28]=M,e[29]=F):F=e[29];let U;e[30]!==I||e[31]!==F?(U=a.jsxs(A5,{className:"flex flex-col gap-0.5",children:[I,F]}),e[30]=I,e[31]=F,e[32]=U):U=e[32];let O;e[33]!==d||e[34]!==N||e[35]!==s?(O=s&&a.jsxs(hn,{onClick:N,disabled:d,children:[d?a.jsx(Pn,{}):a.jsx(Sr,{}),a.jsx("span",{children:"New session"})]}),e[33]=d,e[34]=N,e[35]=s,e[36]=O):O=e[36];let D;e[37]!==m?(D=m&&a.jsxs(hn,{onClick:m,children:[a.jsx(Es,{}),a.jsx("span",{children:"Duplicate session"})]}),e[37]=m,e[38]=D):D=e[38];let B;e[39]!==r||e[40]!==l?(B=l&&!r&&a.jsxs(hn,{onClick:l,children:[a.jsx(U4,{}),a.jsx("span",{children:"Continue with another provider…"})]}),e[39]=r,e[40]=l,e[41]=B):B=e[41];let q;e[42]!==k||e[43]!==r?(q=k&&!r&&a.jsxs(hn,{onClick:k.toggle,disabled:!!k.disabledReason,children:[a.jsx(k.icon,{}),a.jsxs("span",{className:"flex flex-col",children:[k.label,k.disabledReason&&a.jsx("span",{className:"text-xs text-muted-foreground",children:k.disabledReason})]})]}),e[42]=k,e[43]=r,e[44]=q):q=e[44];let W;e[45]!==U||e[46]!==O||e[47]!==D||e[48]!==B||e[49]!==q?(W=a.jsxs(qr,{children:[U,O,D,B,q]}),e[45]=U,e[46]=O,e[47]=D,e[48]=B,e[49]=q,e[50]=W):W=e[50];let H;e[51]===Symbol.for("react.memo_cache_sentinel")?(H=a.jsx(Il,{}),e[51]=H):H=e[51];let K;e[52]!==w?(K=w&&a.jsxs(hn,{onClick:w,children:[a.jsx(ss,{}),a.jsx("span",{children:"Search conversation"})]}),e[52]=w,e[53]=K):K=e[53];let Z;e[54]!==v||e[55]!==j?(Z=j&&a.jsxs(hn,{onClick:j,children:[v?a.jsx(Nf,{}):a.jsx(_a,{}),a.jsx("span",{children:v?"Collapse tool calls":"Expand tool calls"})]}),e[54]=v,e[55]=j,e[56]=Z):Z=e[56];let Y;e[57]!==g||e[58]!==h?(Y=g&&h&&a.jsxs(hn,{onClick:h,children:[a.jsx(yc,{}),a.jsx("span",{children:"File changes"})]}),e[57]=g,e[58]=h,e[59]=Y):Y=e[59];let X;e[60]!==x||e[61]!==b?(X=x&&(b??0)>0&&a.jsxs(hn,{onClick:x,children:[a.jsx(F4,{}),a.jsx("span",{className:"flex-1",children:"Workflows"}),a.jsx(Fe,{variant:"secondary",children:b})]}),e[60]=x,e[61]=b,e[62]=X):X=e[62];let ee;e[63]!==K||e[64]!==Z||e[65]!==Y||e[66]!==X?(ee=a.jsxs(qr,{children:[K,Z,Y,X]}),e[63]=K,e[64]=Z,e[65]=Y,e[66]=X,e[67]=ee):ee=e[67];let te;e[68]!==W||e[69]!==ee?(te=a.jsxs($c,{children:[z,a.jsxs(Oc,{align:"end",sideOffset:6,className:"w-72",children:[W,H,ee]})]}),e[68]=W,e[69]=ee,e[70]=te):te=e[70];let se;return e[71]!==u||e[72]!==S||e[73]!==te||e[74]!==T||e[75]!==P?(se=a.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-1.5 border-b bg-background px-2",children:[S,C,E,T,P,u,te]}),e[71]=u,e[72]=S,e[73]=te,e[74]=T,e[75]=P,e[76]=se):se=e[76],se}const ebe=y.memo(function(e){const t=V.c(14),{isMobile:s}=Sn(),{session:r,sessionSource:o,isLive:i,permissions:l,actions:c}=kt();if(!s||!r)return null;let u;t[0]!==o?(u=o?$o(o.fileName):null,t[0]=o,t[1]=u):u=t[1];const d=u;let f;t[2]!==r||t[3]!==(o==null?void 0:o.dirName)?(f=oa(o==null?void 0:o.dirName).contextWindow?r.rawMessages:[],t[2]=r,t[3]=o==null?void 0:o.dirName,t[4]=f):f=t[4];const m=f,p=d!==null,h=l.send&&d===null?c.handleProviderHandoff:void 0;let g;return t[5]!==m||t[6]!==i||t[7]!==l.archive||t[8]!==e||t[9]!==r||t[10]!==o||t[11]!==p||t[12]!==h?(g=a.jsx(Q0e,{...e,session:r,sessionSource:o,isSubAgentView:p,isLive:i,canArchive:l.archive,onProviderHandoff:h,claudeRawMessages:m}),t[5]=m,t[6]=i,t[7]=l.archive,t[8]=e,t[9]=r,t[10]=o,t[11]=p,t[12]=h,t[13]=g):g=t[13],g}),tbe=50;function nbe({onSwipeLeft:n,onSwipeRight:e}){const t=y.useRef(null),s=y.useRef(null),r=y.useRef(n),o=y.useRef(e);return r.current=n,o.current=e,y.useEffect(()=>{const i=t.current;if(!i)return;function l(u){const d=u.touches[0];s.current={x:d.clientX,y:d.clientY}}function c(u){var p,h;if(!s.current)return;const d=u.changedTouches[0],f=d.clientX-s.current.x,m=d.clientY-s.current.y;s.current=null,!(Math.abs(f)<tbe||Math.abs(f)<Math.abs(m))&&(f>0?(p=o.current)==null||p.call(o):(h=r.current)==null||h.call(r))}return i.addEventListener("touchstart",l,{passive:!0}),i.addEventListener("touchend",c,{passive:!0}),()=>{i.removeEventListener("touchstart",l),i.removeEventListener("touchend",c)}},[]),t}const zj=["sessions","chat","workspace"];function Dj(n,e,t){const s=n.indexOf(e);return s===-1?null:n[s+t]??null}function sbe(n){var P;const e=V.c(46),{panels:t,context:s,activePanelId:r,active:o,onSelectPanel:i,onClosePanel:l,actions:c,actionContent:u}=n;let d;e[0]!==c?(d=c===void 0?[]:c,e[0]=c,e[1]=d):d=e[1];const f=d;let m,p,h,g,x,b,w,v;if(e[2]!==f||e[3]!==r||e[4]!==s||e[5]!==l||e[6]!==i||e[7]!==t){p=Qb(t,s);let z;e[16]!==r?(z=U=>U.id===r,e[16]=r,e[17]=z):z=e[17],h=p.find(z);let L;e[18]!==f?(L=f.find(obe),e[18]=f,e[19]=L):L=e[19],m=L,v=(m==null?void 0:m.title)??(h==null?void 0:h.title);let I;e[20]!==s.projectPath?(I=(P=s.projectPath)==null?void 0:P.split(/[/\\]/).filter(Boolean).at(-1),e[20]=s.projectPath,e[21]=I):I=e[21];const M=I;g="Workspace",x="flex min-h-0 min-w-0 flex-1 flex-col";const F=v?a.jsxs(a.Fragment,{children:[a.jsx(Q,{variant:"ghost",size:"icon-lg",onClick:l,"aria-label":"All workspace tools",children:a.jsx(bx,{"data-icon":"inline-start"})}),a.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:v}),a.jsx(Q,{variant:"outline",onClick:l,children:"Switch"})]}):a.jsxs("div",{className:"flex min-w-0 flex-1 items-baseline justify-between gap-3",children:[a.jsx("h1",{className:"text-base font-medium",children:"Workspace"}),M&&a.jsx("span",{className:"truncate text-xs text-muted-foreground",title:s.projectPath??void 0,children:M})]});e[22]!==F?(b=a.jsx("header",{className:"flex min-h-14 shrink-0 items-center gap-2 border-b px-3",children:F}),e[22]=F,e[23]=b):b=e[23],w=!v&&a.jsx("div",{className:"mobile-scroll min-h-0 flex-1 overflow-y-auto p-3",children:a.jsxs("nav",{"aria-label":"Workspace tools",className:"grid grid-cols-2 gap-2",children:[p.map(U=>{var q;const O=U.icon,D=U.indicator,B=(q=U.badge)==null?void 0:q.call(U,s);return a.jsxs(Q,{variant:"outline","aria-label":U.title,className:"h-auto min-h-24 min-w-0 flex-col items-start justify-between gap-3 whitespace-normal p-3 text-left",onClick:()=>i(U.id),children:[a.jsxs("span",{className:"flex w-full items-center justify-between gap-2",children:[a.jsxs("span",{className:"relative",children:[a.jsx(O,{"data-icon":"inline-start"}),D&&a.jsx(D,{context:s,active:!1})]}),B!=null&&a.jsx(Fe,{variant:"secondary",children:B})]}),a.jsxs("span",{className:"flex w-full items-center justify-between gap-2",children:[a.jsx("span",{children:U.title}),a.jsx(it,{"data-icon":"inline-end"})]})]},U.id)}),f.map(rbe)]})}),e[2]=f,e[3]=r,e[4]=s,e[5]=l,e[6]=i,e[7]=t,e[8]=m,e[9]=p,e[10]=h,e[11]=g,e[12]=x,e[13]=b,e[14]=w,e[15]=v}else m=e[8],p=e[9],h=e[10],g=e[11],x=e[12],b=e[13],w=e[14],v=e[15];const j=v?"relative min-h-0 flex-1":"hidden",k=(m==null?void 0:m.id)??(h==null?void 0:h.id)??"workspace",_=m&&u;let N;e[24]!==k||e[25]!==_?(N=a.jsx(xI,{fallbackMessage:"Couldn't open this workspace tool",children:_},k),e[24]=k,e[25]=_,e[26]=N):N=e[26];const S=m?"hidden":"h-full min-h-0",C=(h==null?void 0:h.id)??"",E=o&&!m;let T;e[27]!==p||e[28]!==s||e[29]!==l||e[30]!==C||e[31]!==E?(T=a.jsx(WI,{panels:p,context:s,activePanelId:C,active:E,onClosePanel:l}),e[27]=p,e[28]=s,e[29]=l,e[30]=C,e[31]=E,e[32]=T):T=e[32];let $;e[33]!==S||e[34]!==T?($=a.jsx("div",{className:S,children:T}),e[33]=S,e[34]=T,e[35]=$):$=e[35];let A;e[36]!==N||e[37]!==$||e[38]!==j?(A=a.jsxs("div",{className:j,children:[N,$]}),e[36]=N,e[37]=$,e[38]=j,e[39]=A):A=e[39];let R;return e[40]!==A||e[41]!==g||e[42]!==x||e[43]!==b||e[44]!==w?(R=a.jsxs("section",{"aria-label":g,className:x,children:[b,w,A]}),e[40]=A,e[41]=g,e[42]=x,e[43]=b,e[44]=w,e[45]=R):R=e[45],R}function rbe(n){const{id:e,title:t,icon:s,onSelect:r}=n;return a.jsxs(Q,{variant:"outline",className:"h-auto min-h-24 min-w-0 flex-col items-start justify-between gap-3 whitespace-normal p-3 text-left",onClick:r,children:[a.jsx(s,{"data-icon":"inline-start"}),a.jsxs("span",{className:"flex w-full items-center justify-between gap-2",children:[a.jsx("span",{children:t}),a.jsx(it,{"data-icon":"inline-end"})]})]},e)}function obe(n){return n.active}const ibe=y.lazy(()=>nt(()=>import("./PluginsDialog-XdukDCaQ.js"),__vite__mapDeps([40,1,2,3,4])).then(n=>({default:n.PluginsDialog}))),abe=y.lazy(()=>nt(()=>import("./ConfigBrowser-Bg_4DTXP.js"),__vite__mapDeps([38,1,2,33,3,4])).then(n=>({default:n.ConfigBrowser})));function lbe(n){var re;const e=V.c(94),{navigation:t,sessionView:s,project:r,active:o}=n,{state:i}=Sn(),{session:l,sessionSource:c}=kt(),u=$I((l==null?void 0:l.sessionId)??null),d=Nn("hostFiles"),f=Nn("browser"),m=Nn("configWrite"),[p,h]=y.useState(cbe),[g,x]=y.useState();let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=de=>{x(de),h(!0)},e[0]=b):b=e[0];const w=b,v=qI(m),j=r.currentCwd??null;let k;e[1]!==v||e[2]!==j?(k={...v,projectPath:j,openSettings:w},e[1]=v,e[2]=j,e[3]=k):k=e[3];const _=HI(k),[N,S]=y.useState(null),{panels:C}=t,E=C.activeWorkspacePanel===null?N:null,T=(c==null?void 0:c.dirName)??i.pendingDirName??i.dashboardProject;let $;e[4]!==C?($=function(){S(null),C.closeWorkspacePanel()},e[4]=C,e[5]=$):$=e[5];const A=$;let R;e[6]!==C?(R=function(fe){C.closeWorkspacePanel(),S(fe)},e[6]=C,e[7]=R):R=e[7];const P=R;let z;e[8]!==t.actions||e[9]!==s.chatInputRef?(z=function(fe){const le=s.chatInputRef.current,ce=(le==null?void 0:le.getText().trimEnd())??"";le==null||le.setText(ce?`${ce}
478
+ `),(Qe=s.chatInputRef.current)==null||Qe.focus()},e[5]=s.chatInputRef,e[6]=N):N=e[6];const S=N;let C;e[7]!==S?(C=function(De){const{path:Ke,text:Ne,startLine:Ae,endLine:Qe,comment:Je}=De;S(g7({path:Ke,text:Ne,startLine:Ae,endLine:Qe,comment:Je}))},e[7]=S,e[8]=C):C=e[8];const E=C,T=i.mainView,$=!!c,A=_!==null;let R;e[9]!==i.mainView||e[10]!==i.pendingDirName||e[11]!==$||e[12]!==A?(R=U0e({mainView:T,hasSession:$,pendingDirName:i.pendingDirName,extensionViewAvailable:A}),e[9]=i.mainView,e[10]=i.pendingDirName,e[11]=$,e[12]=A,e[13]=R):R=e[13];const P=R,z=t.panels.handleToggleSidebar,L=t.actions.handleGoHome,I=o.onOpenCommandPalette;let M,F;e[14]===Symbol.for("react.memo_cache_sentinel")?(M=Qi("toggleSidebar"),F=Qi("commandPalette"),e[14]=M,e[15]=F):(M=e[14],F=e[15]);let U;e[16]!==o.onOpenCommandPalette||e[17]!==t.actions.handleGoHome||e[18]!==t.panels.handleToggleSidebar?(U=a.jsx(Yhe,{onToggleSidebar:z,onGoHome:L,onOpenCommandPalette:I,sidebarShortcut:M,commandPaletteShortcut:F}),e[16]=o.onOpenCommandPalette,e[17]=t.actions.handleGoHome,e[18]=t.panels.handleToggleSidebar,e[19]=U):U=e[19];const O=U,D=P==="mission"||P==="dashboard"&&!i.dashboardProject;let B;e[20]===Symbol.for("react.memo_cache_sentinel")?(B=new Set,e[20]=B):B=e[20];const q=y.useRef(B),W=t.panels.openWorkspacePanel;let H,K;e[21]!==D||e[22]!==d||e[23]!==W?(H=()=>{D||!d||q.current.has(d.rootId)||(q.current.add(d.rootId),W(Ot.crew))},K=[D,d,W],e[21]=D,e[22]=d,e[23]=W,e[24]=H,e[25]=K):(H=e[24],K=e[25]),y.useEffect(H,K);const Z=t.panels.showSidebar&&i.mainView!=="config"&&!D;let Y,X,ee;e[26]!==S||e[27]!==D||e[28]!==t.handlers.handleLoadSessionScrollAware||e[29]!==t.panels.activeWorkspacePanel||e[30]!==d||e[31]!==r.currentCwd||e[32]!==r.hasFileChanges||e[33]!==r.supportsWorktrees||e[34]!==c||e[35]!==u||e[36]!==i.mainView||e[37]!==i.sessionChangeKey||e[38]!==k?(Y={session:c,sessionAddress:u?{dirName:u.dirName,fileName:u.fileName}:null,sessionChangeKey:i.sessionChangeKey,projectPath:r.currentCwd??null,hasFileChanges:r.hasFileChanges,canAccessHostFiles:xt("hostFiles"),canUseBrowser:xt("browser"),supportsWorktrees:r.supportsWorktrees,openSession:t.handlers.handleLoadSessionScrollAware,composePrompt:S,crew:d},ee=Qb(k,Y),X=i.mainView==="sessions"&&!D?II(t.panels.activeWorkspacePanel,ee):null,e[26]=S,e[27]=D,e[28]=t.handlers.handleLoadSessionScrollAware,e[29]=t.panels.activeWorkspacePanel,e[30]=d,e[31]=r.currentCwd,e[32]=r.hasFileChanges,e[33]=r.supportsWorktrees,e[34]=c,e[35]=u,e[36]=i.mainView,e[37]=i.sessionChangeKey,e[38]=k,e[39]=Y,e[40]=X,e[41]=ee):(Y=e[39],X=e[40],ee=e[41]);const te=X,se=(u==null?void 0:u.dirName)??i.pendingDirName??i.dashboardProject??null;let J;e[42]!==t.panels||e[43]!==r?(J=function(De){r.showPreview&&r.onCloseRightWorkspace(),t.panels.toggleWorkspacePanel(De)},e[42]=t.panels,e[43]=r,e[44]=J):J=e[44];const ne=J;let ie;e[45]!==t.actions||e[46]!==t.panels?(ie=function(De){t.actions.handleDashboardSelect(De.dirName,`${De.sessionId}.jsonl`),t.panels.closeWorkspacePanel()},e[45]=t.actions,e[46]=t.panels,e[47]=ie):ie=e[47];const ae=ie,oe=t.panels.showSidebar;let ue;e[48]===Symbol.for("react.memo_cache_sentinel")?(ue=Qi("toggleSidebar"),e[48]=ue):ue=e[48];let re;e[49]!==o.killing||e[50]!==o.onKillAll||e[51]!==o.onLogout||e[52]!==l.openConfigDialog||e[53]!==t.creatingSession||e[54]!==t.handlers.handleDuplicateSession||e[55]!==t.onStartNewSession||e[56]!==t.panels.handleToggleSidebar||e[57]!==t.panels.openMainView||e[58]!==t.panels.showSidebar||e[59]!==r.onOpenTerminal||e[60]!==s.onBackToMain||e[61]!==s.onShowWorkflows||e[62]!==s.workflowCount||e[63]!==Z?(re=a.jsx(Ghe,{showSidebar:oe,sidebarRendered:Z,sidebarShortcut:ue,killing:o.killing,creatingSession:t.creatingSession,onNewSession:t.onStartNewSession,onDuplicateSession:t.handlers.handleDuplicateSession,onOpenTerminal:r.onOpenTerminal,onBackToMain:s.onBackToMain,onShowWorkflows:s.onShowWorkflows,workflowCount:s.workflowCount,onToggleSidebar:t.panels.handleToggleSidebar,onKillAll:o.onKillAll,onOpenSettings:l.openConfigDialog,onLogout:o.onLogout,onOpenMainView:t.panels.openMainView}),e[49]=o.killing,e[50]=o.onKillAll,e[51]=o.onLogout,e[52]=l.openConfigDialog,e[53]=t.creatingSession,e[54]=t.handlers.handleDuplicateSession,e[55]=t.onStartNewSession,e[56]=t.panels.handleToggleSidebar,e[57]=t.panels.openMainView,e[58]=t.panels.showSidebar,e[59]=r.onOpenTerminal,e[60]=s.onBackToMain,e[61]=s.onShowWorkflows,e[62]=s.workflowCount,e[63]=Z,e[64]=re):re=e[64];const de=re,fe=r.currentCwd??null;let le;e[65]!==t||e[66]!==O||e[67]!==Z?(le=Z&&a.jsx("div",{className:"view-transition-sidebar panel-enter w-80 shrink-0 border-r bg-sidebar text-sidebar-foreground",children:a.jsx(p7,{navigation:t,header:O})}),e[65]=t,e[66]=O,e[67]=Z,e[68]=le):le=e[68];const ce=te??null,he=r.projectFilesRoot??r.currentCwd??null;let ge;e[69]!==E||e[70]!==t.actions.handleJumpToTurn||e[71]!==t.handlers.handleLoadSessionScrollAware||e[72]!==ae||e[73]!==r.backgroundAgents||e[74]!==r.processPanel.handleServersChanged||e[75]!==r.processPanel.handleToggleServer||e[76]!==r.projectFilesRequest||e[77]!==r.worktrees||e[78]!==s.searchInputRef||e[79]!==he||e[80]!==se?(ge={projectFilesRoot:he,projectFilesRequest:r.projectFilesRequest,backgroundAgents:r.backgroundAgents,searchInputRef:s.searchInputRef,addProjectContext:E,jumpToTurn:t.actions.handleJumpToTurn,toggleServer:r.processPanel.handleToggleServer,serversChanged:r.processPanel.handleServersChanged,loadSession:t.handlers.handleLoadSessionScrollAware,worktrees:r.worktrees,worktreeDirName:se,openWorktreeSession:ae},e[69]=E,e[70]=t.actions.handleJumpToTurn,e[71]=t.handlers.handleLoadSessionScrollAware,e[72]=ae,e[73]=r.backgroundAgents,e[74]=r.processPanel.handleServersChanged,e[75]=r.processPanel.handleToggleServer,e[76]=r.projectFilesRequest,e[77]=r.worktrees,e[78]=s.searchInputRef,e[79]=he,e[80]=se,e[81]=ge):ge=e[81];let be;e[82]!==D||e[83]!==t.panels.handleToggleMission?(be={id:"mission-control",title:"Mission Control",icon:q4,active:D,onSelect:t.panels.handleToggleMission},e[82]=D,e[83]=t.panels.handleToggleMission,e[84]=be):be=e[84];let ve;e[85]!==t.panels.handleToggleConfig||e[86]!==f||e[87]!==i.mainView?(ve=xt("configWrite")?[{id:"plugins",title:"Plugins",icon:xx,active:f,onSelect:()=>m(!0)},{id:"config",title:"Config",icon:V4,active:i.mainView==="config",onSelect:t.panels.handleToggleConfig}]:[],e[85]=t.panels.handleToggleConfig,e[86]=f,e[87]=i.mainView,e[88]=ve):ve=e[88];let Se;e[89]!==be||e[90]!==ve?(Se=[be,...ve],e[89]=be,e[90]=ve,e[91]=Se):Se=e[91];const we=P!=="session"&&de;let Ee;e[92]!==_||e[93]!==de||e[94]!==t||e[95]!==r||e[96]!==s||e[97]!==P?(Ee=a.jsx(K0e,{navigation:t,sessionView:s,project:r,view:P,extensionView:_,floatingChrome:de}),e[92]=_,e[93]=de,e[94]=t,e[95]=r,e[96]=s,e[97]=P,e[98]=Ee):Ee=e[98];let $e;e[99]!==we||e[100]!==Ee?($e=a.jsxs("main",{className:"app-view-transition relative flex size-full min-w-0 flex-col overflow-hidden",children:[we,Ee]}),e[99]=we,e[100]=Ee,e[101]=$e):$e=e[101];let Be;e[102]!==t.panels.closeWorkspacePanel||e[103]!==Y||e[104]!==ce||e[105]!==ge||e[106]!==Se||e[107]!==$e||e[108]!==ne||e[109]!==ee?(Be=a.jsx(nge,{panels:ee,context:Y,activePanel:ce,services:ge,onClosePanel:t.panels.closeWorkspacePanel,onTogglePanel:ne,actions:Se,children:$e}),e[102]=t.panels.closeWorkspacePanel,e[103]=Y,e[104]=ce,e[105]=ge,e[106]=Se,e[107]=$e,e[108]=ne,e[109]=ee,e[110]=Be):Be=e[110];let qe;e[111]!==r.currentCwd||e[112]!==r.onCloseRightWorkspace||e[113]!==r.showPreview?(qe=r.showPreview&&r.currentCwd&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(q0e,{cwd:r.currentCwd,onClose:r.onCloseRightWorkspace})}),e[111]=r.currentCwd,e[112]=r.onCloseRightWorkspace,e[113]=r.showPreview,e[114]=qe):qe=e[114];let ze;e[115]!==p||e[116]!==f||e[117]!==r.currentCwd||e[118]!==w?(ze=f&&xt("configWrite")&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(V0e,{client:w.client,state:w,currentPath:r.currentCwd??null,initialPluginId:p,onClose:()=>{m(!1),h(void 0)}})}),e[115]=p,e[116]=f,e[117]=r.currentCwd,e[118]=w,e[119]=ze):ze=e[119];let Ie;e[120]!==le||e[121]!==Be||e[122]!==qe||e[123]!==ze?(Ie=a.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[le,Be,qe,ze]}),e[120]=le,e[121]=Be,e[122]=qe,e[123]=ze,e[124]=Ie):Ie=e[124];let Me;return e[125]!==w||e[126]!==fe||e[127]!==Ie?(Me=a.jsx(qE,{runtime:w,workspacePath:fe,children:Ie}),e[125]=w,e[126]=fe,e[127]=Ie,e[128]=Me):Me=e[128],Me}function Z0e(){return new URLSearchParams(window.location.search).get("pluginSafeMode")==="1"}function Y0e(n){const e=V.c(15),{navigation:t,sessionView:s,project:r,chrome:o}=n;let i,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx(xA,{}),l=a.jsx(gA,{}),e[0]=i,e[1]=l):(i=e[0],l=e[1]);let c;e[2]!==o||e[3]!==t||e[4]!==r||e[5]!==s?(c=a.jsx(G0e,{navigation:t,sessionView:s,project:r,chrome:o}),e[2]=o,e[3]=t,e[4]=r,e[5]=s,e[6]=c):c=e[6];let u;e[7]!==o||e[8]!==t||e[9]!==r?(u=a.jsx(upe,{navigation:t,project:r,chrome:o}),e[7]=o,e[8]=t,e[9]=r,e[10]=u):u=e[10];let d;return e[11]!==o.backgroundServers||e[12]!==c||e[13]!==u?(d=a.jsxs("div",{className:"flex h-dvh flex-col bg-canvas text-foreground",children:[o.backgroundServers,i,l,c,u]}),e[11]=o.backgroundServers,e[12]=c,e[13]=u,e[14]=d):d=e[14],d}const X0e=[{id:"sessions",label:"Sessions",icon:Zr},{id:"chat",label:"Chat",icon:vc},{id:"workspace",label:"Workspace",icon:D8}],J0e=y.memo(function(e){const t=V.c(6),{activeTab:s,onTabChange:r}=e,{isLive:o}=kt();let i;t[0]!==s||t[1]!==o||t[2]!==r?(i=X0e.map(c=>{const u=c.icon,d=s===c.id;return a.jsx("button",{type:"button","aria-current":d?"page":void 0,"aria-label":c.label,title:c.label,onClick:()=>{q1(),r(c.id)},className:G("flex min-h-14 flex-1 items-center justify-center outline-none transition-[color,transform] duration-150 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset motion-reduce:transition-none",d?"text-foreground":"text-muted-foreground hover:text-foreground"),children:a.jsxs("div",{className:G("relative flex size-9 items-center justify-center rounded-md transition-[background-color,transform,scale] duration-150 ease-out motion-reduce:transition-none",d?"scale-100 bg-accent":"scale-95"),children:[a.jsx(u,{className:G("size-[18px] transition-transform duration-150 ease-out motion-reduce:transition-none",d&&"scale-110"),"aria-hidden":"true"}),c.id==="chat"&&o&&!d&&a.jsx(Sm,{"aria-label":"Session is live",className:"absolute right-0.5 top-0.5 size-1.5 ring-2 ring-background"})]})},c.id)}),t[0]=s,t[1]=o,t[2]=r,t[3]=i):i=t[3];let l;return t[4]!==i?(l=a.jsx("nav",{className:"flex shrink-0 items-stretch border-t bg-background pb-[env(safe-area-inset-bottom)]","aria-label":"Navigation",children:i}),t[4]=i,t[5]=l):l=t[5],l});function Q0e(n){const e=V.c(77),{session:t,sessionSource:s,isSubAgentView:r,isLive:o,canArchive:i,onProviderHandoff:l,claudeRawMessages:c,headerAccessory:u,creatingSession:d,onNewSession:f,onDuplicateSession:m,onBackToMain:p,onShowFileChanges:h,hasFileChanges:g,onShowWorkflows:x,workflowCount:b,onSearch:w,expandAll:v,onToggleExpandAll:j}=n,k=DI(t.sessionId,o,i);let _;e[0]!==f||e[1]!==t.cwd||e[2]!==s?(_=()=>{s&&f(s.dirName,t.cwd)},e[0]=f,e[1]=t.cwd,e[2]=s,e[3]=_):_=e[3];const N=_;let S;e[4]!==r||e[5]!==p?(S=r&&p&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",onClick:p,"aria-label":"Back to main agent",children:a.jsx(lx,{"data-icon":"inline-start"})}),e[4]=r,e[5]=p,e[6]=S):S=e[6];let C,E;e[7]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsx(Zb,{compact:!0}),E=a.jsx(en,{orientation:"vertical",className:"h-4"}),e[7]=C,e[8]=E):(C=e[7],E=e[8]);let T;e[9]!==c?(T=a.jsx(cA,{rawMessages:c,warnOnly:!0}),e[9]=c,e[10]=T):T=e[10];let $;e[11]!==t.cwd?($=t.cwd?_r(t.cwd):"Session",e[11]=t.cwd,e[12]=$):$=e[12];let A;e[13]!==$?(A=a.jsx("span",{className:"truncate text-xs font-medium text-muted-foreground",children:$}),e[13]=$,e[14]=A):A=e[14];let R;e[15]!==o?(R=o&&a.jsx(Sm,{"aria-label":"Session is live"}),e[15]=o,e[16]=R):R=e[16];let P;e[17]!==A||e[18]!==R?(P=a.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-center gap-1.5",children:[A,R]}),e[17]=A,e[18]=R,e[19]=P):P=e[19];let z;e[20]===Symbol.for("react.memo_cache_sentinel")?(z=a.jsx(Rc,{render:a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Session actions"}),children:a.jsx(B4,{"data-icon":"inline-start"})}),e[20]=z):z=e[20];let L;e[21]!==t.cwd?(L=t.cwd?_r(t.cwd):"Current session",e[21]=t.cwd,e[22]=L):L=e[22];let I;e[23]!==L?(I=a.jsx("span",{className:"truncate text-foreground",children:L}),e[23]=L,e[24]=I):I=e[24];let M;e[25]!==t.gitBranch||e[26]!==t.model?(M=[t.model,t.gitBranch].filter(Boolean).join(" · ")||"Session actions",e[25]=t.gitBranch,e[26]=t.model,e[27]=M):M=e[27];let F;e[28]!==M?(F=a.jsx("span",{className:"truncate font-normal",children:M}),e[28]=M,e[29]=F):F=e[29];let U;e[30]!==I||e[31]!==F?(U=a.jsxs(A5,{className:"flex flex-col gap-0.5",children:[I,F]}),e[30]=I,e[31]=F,e[32]=U):U=e[32];let O;e[33]!==d||e[34]!==N||e[35]!==s?(O=s&&a.jsxs(hn,{onClick:N,disabled:d,children:[d?a.jsx(Pn,{}):a.jsx(Sr,{}),a.jsx("span",{children:"New session"})]}),e[33]=d,e[34]=N,e[35]=s,e[36]=O):O=e[36];let D;e[37]!==m?(D=m&&a.jsxs(hn,{onClick:m,children:[a.jsx(Es,{}),a.jsx("span",{children:"Duplicate session"})]}),e[37]=m,e[38]=D):D=e[38];let B;e[39]!==r||e[40]!==l?(B=l&&!r&&a.jsxs(hn,{onClick:l,children:[a.jsx(U4,{}),a.jsx("span",{children:"Continue with another provider…"})]}),e[39]=r,e[40]=l,e[41]=B):B=e[41];let q;e[42]!==k||e[43]!==r?(q=k&&!r&&a.jsxs(hn,{onClick:k.toggle,disabled:!!k.disabledReason,children:[a.jsx(k.icon,{}),a.jsxs("span",{className:"flex flex-col",children:[k.label,k.disabledReason&&a.jsx("span",{className:"text-xs text-muted-foreground",children:k.disabledReason})]})]}),e[42]=k,e[43]=r,e[44]=q):q=e[44];let W;e[45]!==U||e[46]!==O||e[47]!==D||e[48]!==B||e[49]!==q?(W=a.jsxs(qr,{children:[U,O,D,B,q]}),e[45]=U,e[46]=O,e[47]=D,e[48]=B,e[49]=q,e[50]=W):W=e[50];let H;e[51]===Symbol.for("react.memo_cache_sentinel")?(H=a.jsx(Il,{}),e[51]=H):H=e[51];let K;e[52]!==w?(K=w&&a.jsxs(hn,{onClick:w,children:[a.jsx(ss,{}),a.jsx("span",{children:"Search conversation"})]}),e[52]=w,e[53]=K):K=e[53];let Z;e[54]!==v||e[55]!==j?(Z=j&&a.jsxs(hn,{onClick:j,children:[v?a.jsx(Nf,{}):a.jsx(_a,{}),a.jsx("span",{children:v?"Collapse tool calls":"Expand tool calls"})]}),e[54]=v,e[55]=j,e[56]=Z):Z=e[56];let Y;e[57]!==g||e[58]!==h?(Y=g&&h&&a.jsxs(hn,{onClick:h,children:[a.jsx(yc,{}),a.jsx("span",{children:"File changes"})]}),e[57]=g,e[58]=h,e[59]=Y):Y=e[59];let X;e[60]!==x||e[61]!==b?(X=x&&(b??0)>0&&a.jsxs(hn,{onClick:x,children:[a.jsx(F4,{}),a.jsx("span",{className:"flex-1",children:"Workflows"}),a.jsx(Fe,{variant:"secondary",children:b})]}),e[60]=x,e[61]=b,e[62]=X):X=e[62];let ee;e[63]!==K||e[64]!==Z||e[65]!==Y||e[66]!==X?(ee=a.jsxs(qr,{children:[K,Z,Y,X]}),e[63]=K,e[64]=Z,e[65]=Y,e[66]=X,e[67]=ee):ee=e[67];let te;e[68]!==W||e[69]!==ee?(te=a.jsxs($c,{children:[z,a.jsxs(Oc,{align:"end",sideOffset:6,className:"w-72",children:[W,H,ee]})]}),e[68]=W,e[69]=ee,e[70]=te):te=e[70];let se;return e[71]!==u||e[72]!==S||e[73]!==te||e[74]!==T||e[75]!==P?(se=a.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-1.5 border-b bg-background px-2",children:[S,C,E,T,P,u,te]}),e[71]=u,e[72]=S,e[73]=te,e[74]=T,e[75]=P,e[76]=se):se=e[76],se}const ebe=y.memo(function(e){const t=V.c(14),{isMobile:s}=Sn(),{session:r,sessionSource:o,isLive:i,permissions:l,actions:c}=kt();if(!s||!r)return null;let u;t[0]!==o?(u=o?$o(o.fileName):null,t[0]=o,t[1]=u):u=t[1];const d=u;let f;t[2]!==r||t[3]!==(o==null?void 0:o.dirName)?(f=oa(o==null?void 0:o.dirName).contextWindow?r.rawMessages:[],t[2]=r,t[3]=o==null?void 0:o.dirName,t[4]=f):f=t[4];const m=f,p=d!==null,h=l.send&&d===null?c.handleProviderHandoff:void 0;let g;return t[5]!==m||t[6]!==i||t[7]!==l.archive||t[8]!==e||t[9]!==r||t[10]!==o||t[11]!==p||t[12]!==h?(g=a.jsx(Q0e,{...e,session:r,sessionSource:o,isSubAgentView:p,isLive:i,canArchive:l.archive,onProviderHandoff:h,claudeRawMessages:m}),t[5]=m,t[6]=i,t[7]=l.archive,t[8]=e,t[9]=r,t[10]=o,t[11]=p,t[12]=h,t[13]=g):g=t[13],g}),tbe=50;function nbe({onSwipeLeft:n,onSwipeRight:e}){const t=y.useRef(null),s=y.useRef(null),r=y.useRef(n),o=y.useRef(e);return r.current=n,o.current=e,y.useEffect(()=>{const i=t.current;if(!i)return;function l(u){const d=u.touches[0];s.current={x:d.clientX,y:d.clientY}}function c(u){var p,h;if(!s.current)return;const d=u.changedTouches[0],f=d.clientX-s.current.x,m=d.clientY-s.current.y;s.current=null,!(Math.abs(f)<tbe||Math.abs(f)<Math.abs(m))&&(f>0?(p=o.current)==null||p.call(o):(h=r.current)==null||h.call(r))}return i.addEventListener("touchstart",l,{passive:!0}),i.addEventListener("touchend",c,{passive:!0}),()=>{i.removeEventListener("touchstart",l),i.removeEventListener("touchend",c)}},[]),t}const zj=["sessions","chat","workspace"];function Dj(n,e,t){const s=n.indexOf(e);return s===-1?null:n[s+t]??null}function sbe(n){var P;const e=V.c(46),{panels:t,context:s,activePanelId:r,active:o,onSelectPanel:i,onClosePanel:l,actions:c,actionContent:u}=n;let d;e[0]!==c?(d=c===void 0?[]:c,e[0]=c,e[1]=d):d=e[1];const f=d;let m,p,h,g,x,b,w,v;if(e[2]!==f||e[3]!==r||e[4]!==s||e[5]!==l||e[6]!==i||e[7]!==t){p=Qb(t,s);let z;e[16]!==r?(z=U=>U.id===r,e[16]=r,e[17]=z):z=e[17],h=p.find(z);let L;e[18]!==f?(L=f.find(obe),e[18]=f,e[19]=L):L=e[19],m=L,v=(m==null?void 0:m.title)??(h==null?void 0:h.title);let I;e[20]!==s.projectPath?(I=(P=s.projectPath)==null?void 0:P.split(/[/\\]/).filter(Boolean).at(-1),e[20]=s.projectPath,e[21]=I):I=e[21];const M=I;g="Workspace",x="flex min-h-0 min-w-0 flex-1 flex-col";const F=v?a.jsxs(a.Fragment,{children:[a.jsx(Q,{variant:"ghost",size:"icon-lg",onClick:l,"aria-label":"All workspace tools",children:a.jsx(bx,{"data-icon":"inline-start"})}),a.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:v}),a.jsx(Q,{variant:"outline",onClick:l,children:"Switch"})]}):a.jsxs("div",{className:"flex min-w-0 flex-1 items-baseline justify-between gap-3",children:[a.jsx("h1",{className:"text-base font-medium",children:"Workspace"}),M&&a.jsx("span",{className:"truncate text-xs text-muted-foreground",title:s.projectPath??void 0,children:M})]});e[22]!==F?(b=a.jsx("header",{className:"flex min-h-14 shrink-0 items-center gap-2 border-b px-3",children:F}),e[22]=F,e[23]=b):b=e[23],w=!v&&a.jsx("div",{className:"mobile-scroll min-h-0 flex-1 overflow-y-auto p-3",children:a.jsxs("nav",{"aria-label":"Workspace tools",className:"grid grid-cols-2 gap-2",children:[p.map(U=>{var q;const O=U.icon,D=U.indicator,B=(q=U.badge)==null?void 0:q.call(U,s);return a.jsxs(Q,{variant:"outline","aria-label":U.title,className:"h-auto min-h-24 min-w-0 flex-col items-start justify-between gap-3 whitespace-normal p-3 text-left",onClick:()=>i(U.id),children:[a.jsxs("span",{className:"flex w-full items-center justify-between gap-2",children:[a.jsxs("span",{className:"relative",children:[a.jsx(O,{"data-icon":"inline-start"}),D&&a.jsx(D,{context:s,active:!1})]}),B!=null&&a.jsx(Fe,{variant:"secondary",children:B})]}),a.jsxs("span",{className:"flex w-full items-center justify-between gap-2",children:[a.jsx("span",{children:U.title}),a.jsx(it,{"data-icon":"inline-end"})]})]},U.id)}),f.map(rbe)]})}),e[2]=f,e[3]=r,e[4]=s,e[5]=l,e[6]=i,e[7]=t,e[8]=m,e[9]=p,e[10]=h,e[11]=g,e[12]=x,e[13]=b,e[14]=w,e[15]=v}else m=e[8],p=e[9],h=e[10],g=e[11],x=e[12],b=e[13],w=e[14],v=e[15];const j=v?"relative min-h-0 flex-1":"hidden",k=(m==null?void 0:m.id)??(h==null?void 0:h.id)??"workspace",_=m&&u;let N;e[24]!==k||e[25]!==_?(N=a.jsx(xI,{fallbackMessage:"Couldn't open this workspace tool",children:_},k),e[24]=k,e[25]=_,e[26]=N):N=e[26];const S=m?"hidden":"h-full min-h-0",C=(h==null?void 0:h.id)??"",E=o&&!m;let T;e[27]!==p||e[28]!==s||e[29]!==l||e[30]!==C||e[31]!==E?(T=a.jsx(WI,{panels:p,context:s,activePanelId:C,active:E,onClosePanel:l}),e[27]=p,e[28]=s,e[29]=l,e[30]=C,e[31]=E,e[32]=T):T=e[32];let $;e[33]!==S||e[34]!==T?($=a.jsx("div",{className:S,children:T}),e[33]=S,e[34]=T,e[35]=$):$=e[35];let A;e[36]!==N||e[37]!==$||e[38]!==j?(A=a.jsxs("div",{className:j,children:[N,$]}),e[36]=N,e[37]=$,e[38]=j,e[39]=A):A=e[39];let R;return e[40]!==A||e[41]!==g||e[42]!==x||e[43]!==b||e[44]!==w?(R=a.jsxs("section",{"aria-label":g,className:x,children:[b,w,A]}),e[40]=A,e[41]=g,e[42]=x,e[43]=b,e[44]=w,e[45]=R):R=e[45],R}function rbe(n){const{id:e,title:t,icon:s,onSelect:r}=n;return a.jsxs(Q,{variant:"outline",className:"h-auto min-h-24 min-w-0 flex-col items-start justify-between gap-3 whitespace-normal p-3 text-left",onClick:r,children:[a.jsx(s,{"data-icon":"inline-start"}),a.jsxs("span",{className:"flex w-full items-center justify-between gap-2",children:[a.jsx("span",{children:t}),a.jsx(it,{"data-icon":"inline-end"})]})]},e)}function obe(n){return n.active}const ibe=y.lazy(()=>nt(()=>import("./PluginsDialog-BHKZ3Esx.js"),__vite__mapDeps([40,1,2,3,4])).then(n=>({default:n.PluginsDialog}))),abe=y.lazy(()=>nt(()=>import("./ConfigBrowser-C_4UyHta.js"),__vite__mapDeps([38,1,2,33,3,4])).then(n=>({default:n.ConfigBrowser})));function lbe(n){var re;const e=V.c(94),{navigation:t,sessionView:s,project:r,active:o}=n,{state:i}=Sn(),{session:l,sessionSource:c}=kt(),u=$I((l==null?void 0:l.sessionId)??null),d=Nn("hostFiles"),f=Nn("browser"),m=Nn("configWrite"),[p,h]=y.useState(cbe),[g,x]=y.useState();let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=de=>{x(de),h(!0)},e[0]=b):b=e[0];const w=b,v=qI(m),j=r.currentCwd??null;let k;e[1]!==v||e[2]!==j?(k={...v,projectPath:j,openSettings:w},e[1]=v,e[2]=j,e[3]=k):k=e[3];const _=HI(k),[N,S]=y.useState(null),{panels:C}=t,E=C.activeWorkspacePanel===null?N:null,T=(c==null?void 0:c.dirName)??i.pendingDirName??i.dashboardProject;let $;e[4]!==C?($=function(){S(null),C.closeWorkspacePanel()},e[4]=C,e[5]=$):$=e[5];const A=$;let R;e[6]!==C?(R=function(fe){C.closeWorkspacePanel(),S(fe)},e[6]=C,e[7]=R):R=e[7];const P=R;let z;e[8]!==t.actions||e[9]!==s.chatInputRef?(z=function(fe){const le=s.chatInputRef.current,ce=(le==null?void 0:le.getText().trimEnd())??"";le==null||le.setText(ce?`${ce}
479
479
 
480
480
  ${fe}
481
481
  `:`${fe}
482
- `),t.actions.handleMobileTabChange("chat"),requestAnimationFrame(()=>le==null?void 0:le.focus())},e[8]=t.actions,e[9]=s.chatInputRef,e[10]=z):z=e[10];const L=z;let I;e[11]!==c?(I=c?{dirName:c.dirName,fileName:c.fileName}:null,e[11]=c,e[12]=I):I=e[12];const M=r.currentCwd??null;let F;e[13]!==d||e[14]!==f||e[15]!==L||e[16]!==t.handlers.handleLoadSessionScrollAware||e[17]!==u||e[18]!==r.hasFileChanges||e[19]!==r.supportsWorktrees||e[20]!==l||e[21]!==i.sessionChangeKey||e[22]!==I||e[23]!==M?(F={session:l,sessionAddress:I,sessionChangeKey:i.sessionChangeKey,projectPath:M,hasFileChanges:r.hasFileChanges,canAccessHostFiles:d,canUseBrowser:f,supportsWorktrees:r.supportsWorktrees,openSession:t.handlers.handleLoadSessionScrollAware,composePrompt:L,crew:u},e[13]=d,e[14]=f,e[15]=L,e[16]=t.handlers.handleLoadSessionScrollAware,e[17]=u,e[18]=r.hasFileChanges,e[19]=r.supportsWorktrees,e[20]=l,e[21]=i.sessionChangeKey,e[22]=I,e[23]=M,e[24]=F):F=e[24];const U=F,O=r.currentCwd??null,D=r.projectFilesRoot??r.currentCwd??null;let B;e[25]!==L?(B=de=>L(g7(de)),e[25]=L,e[26]=B):B=e[26];let q;e[27]!==t.actions||e[28]!==r.processPanel?(q=(...de)=>{const fe=de;r.processPanel.handleToggleServer(...fe),t.actions.handleMobileTabChange("chat")},e[27]=t.actions,e[28]=r.processPanel,e[29]=q):q=e[29];let W;e[30]!==t.actions?(W=de=>{t.actions.handleDashboardSelect(de.dirName,`${de.sessionId}.jsonl`)},e[30]=t.actions,e[31]=W):W=e[31];let H;e[32]!==t.handlers.handleLoadSessionScrollAware||e[33]!==t.handlers.handleMobileJumpToTurn||e[34]!==r.backgroundAgents||e[35]!==r.processPanel.handleServersChanged||e[36]!==r.projectFilesRequest||e[37]!==r.worktrees||e[38]!==s.searchInputRef||e[39]!==D||e[40]!==B||e[41]!==q||e[42]!==W||e[43]!==T?(H={projectFilesRoot:D,projectFilesRequest:r.projectFilesRequest,backgroundAgents:r.backgroundAgents,searchInputRef:s.searchInputRef,addProjectContext:B,jumpToTurn:t.handlers.handleMobileJumpToTurn,toggleServer:q,serversChanged:r.processPanel.handleServersChanged,loadSession:t.handlers.handleLoadSessionScrollAware,worktrees:r.worktrees,worktreeDirName:T,openWorktreeSession:W},e[32]=t.handlers.handleLoadSessionScrollAware,e[33]=t.handlers.handleMobileJumpToTurn,e[34]=r.backgroundAgents,e[35]=r.processPanel.handleServersChanged,e[36]=r.projectFilesRequest,e[37]=r.worktrees,e[38]=s.searchInputRef,e[39]=D,e[40]=B,e[41]=q,e[42]=W,e[43]=T,e[44]=H):H=e[44];let K;e[45]!==C.activeWorkspacePanel||e[46]!==_?(K=((re=II(C.activeWorkspacePanel,_))==null?void 0:re.id)??C.activeWorkspacePanel,e[45]=C.activeWorkspacePanel,e[46]=_,e[47]=K):K=e[47];let Z;e[48]!==C?(Z=de=>{S(null),C.openWorkspacePanel(de)},e[48]=C,e[49]=Z):Z=e[49];let Y;e[50]!==m?(Y=m?[{id:"plugins",title:"Plugins",icon:xx,active:!1,onSelect:()=>h(!0)}]:[],e[50]=m,e[51]=Y):Y=e[51];const X=E==="mission";let ee;e[52]!==P?(ee=()=>P("mission"),e[52]=P,e[53]=ee):ee=e[53];let te;e[54]!==X||e[55]!==ee?(te={id:"mission",title:"Mission Control",icon:q4,active:X,onSelect:ee},e[54]=X,e[55]=ee,e[56]=te):te=e[56];let se;e[57]!==m||e[58]!==P||e[59]!==E?(se=m?[{id:"config",title:"Config",icon:V4,active:E==="config",onSelect:()=>P("config")}]:[],e[57]=m,e[58]=P,e[59]=E,e[60]=se):se=e[60];let J;e[61]!==Y||e[62]!==te||e[63]!==se?(J=[...Y,te,...se],e[61]=Y,e[62]=te,e[63]=se,e[64]=J):J=e[64];let ne;e[65]!==m||e[66]!==t||e[67]!==r.currentCwd||e[68]!==E||e[69]!==i.configFilePath?(ne=E==="mission"?a.jsx("div",{className:"flex h-full min-h-0 flex-col",children:a.jsx(bf,{navigation:t})}):E==="config"&&m?a.jsx(y.Suspense,{fallback:a.jsx(Rm,{label:"Loading configuration…"}),children:a.jsx("div",{className:"flex h-full min-h-0",children:a.jsx(abe,{projectPath:r.currentCwd??null,initialFilePath:i.configFilePath})})}):null,e[65]=m,e[66]=t,e[67]=r.currentCwd,e[68]=E,e[69]=i.configFilePath,e[70]=ne):ne=e[70];let ie;e[71]!==o||e[72]!==A||e[73]!==U||e[74]!==K||e[75]!==Z||e[76]!==J||e[77]!==ne||e[78]!==_?(ie=a.jsx(sbe,{panels:_,context:U,activePanelId:K,active:o,onSelectPanel:Z,onClosePanel:A,actions:J,actionContent:ne}),e[71]=o,e[72]=A,e[73]=U,e[74]=K,e[75]=Z,e[76]=J,e[77]=ne,e[78]=_,e[79]=ie):ie=e[79];let ae;e[80]!==m||e[81]!==g||e[82]!==p||e[83]!==r.currentCwd||e[84]!==v?(ae=p&&m&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(ibe,{client:v.client,state:v,currentPath:r.currentCwd??null,initialPluginId:g,onClose:()=>{h(!1),x(void 0)}})}),e[80]=m,e[81]=g,e[82]=p,e[83]=r.currentCwd,e[84]=v,e[85]=ae):ae=e[85];let oe;e[86]!==H||e[87]!==ie||e[88]!==ae?(oe=a.jsxs(UI,{value:H,children:[ie,ae]}),e[86]=H,e[87]=ie,e[88]=ae,e[89]=oe):oe=e[89];let ue;return e[90]!==v||e[91]!==O||e[92]!==oe?(ue=a.jsx(qE,{runtime:v,workspacePath:O,children:oe}),e[90]=v,e[91]=O,e[92]=oe,e[93]=ue):ue=e[93],ue}function cbe(){return new URLSearchParams(window.location.search).get("pluginSafeMode")==="1"}const ube=y.lazy(()=>nt(()=>import("./MobileFileChanges-BN7bdxse.js"),__vite__mapDeps([41,1,2,3,4])).then(n=>({default:n.MobileFileChanges})));function dbe(n){const e=V.c(79),{navigation:t,sessionView:s,project:r,chrome:o}=n,{state:i,config:l}=Sn(),{session:c}=kt(),[u,d]=y.useState(!1),{AccountControl:f}=$r(),m=zN(i.mainView==="extension"?i.extensionViewId:null),p=i.mobileTab==="workspace"||(m==null?void 0:m.locksSwipe)===!0;let h;e[0]!==t.actions||e[1]!==i.mobileTab||e[2]!==p?(h={onSwipeLeft:()=>{if(p)return;const K=Dj(zj,i.mobileTab,1);K&&(q1(),t.actions.handleMobileTabChange(K))},onSwipeRight:()=>{if(p)return;const K=Dj(zj,i.mobileTab,-1);K&&(q1(),t.actions.handleMobileTabChange(K))}},e[0]=t.actions,e[1]=i.mobileTab,e[2]=p,e[3]=h):h=e[3];const g=nbe(h);let x;e[4]!==f||e[5]!==o.onLogout||e[6]!==t.panels?(x=f&&a.jsx(f,{mobile:!0,onLogout:o.onLogout,onOpenMainView:t.panels.openMainView,className:"ml-auto"}),e[4]=f,e[5]=o.onLogout,e[6]=t.panels,e[7]=x):x=e[7];const b=x;let w;e[8]!==m||e[9]!==t.actions||e[10]!==t.panels?(w=K=>{d(!1),m&&t.panels.closeMainView(),t.actions.handleMobileTabChange(K)},e[8]=m,e[9]=t.actions,e[10]=t.panels,e[11]=w):w=e[11];const v=w,j=o.backgroundServers;let k,_;e[12]===Symbol.for("react.memo_cache_sentinel")?(k=a.jsx(xA,{}),_=a.jsx(gA,{}),e[12]=k,e[13]=_):(k=e[12],_=e[13]);let N;e[14]!==b||e[15]!==c||e[16]!==i.mobileTab?(N=!(i.mobileTab==="chat"&&c)&&a.jsxs("div",{className:"motion-slide-down-in flex h-12 shrink-0 items-center border-b bg-background px-2",children:[a.jsx(Zb,{compact:!0}),b]}),e[14]=b,e[15]=c,e[16]=i.mobileTab,e[17]=N):N=e[17];let S;e[18]!==t||e[19]!==i.mobileTab?(S=i.mobileTab==="sessions"&&a.jsx(p7,{navigation:t,mobile:!0}),e[18]=t,e[19]=i.mobileTab,e[20]=S):S=e[20];const C=i.mobileTab!=="chat",E=i.mobileTab!=="chat",T=i.mobileTab!=="chat"&&"invisible pointer-events-none";let $;e[21]!==T?($=G("absolute inset-0 flex min-h-0 min-w-0 flex-col",T),e[21]=T,e[22]=$):$=e[22];let A;e[23]!==o||e[24]!==b||e[25]!==t||e[26]!==r||e[27]!==u||e[28]!==s?(A=a.jsx(fbe,{navigation:t,sessionView:s,project:r,chrome:o,headerAccessory:b,searchOpen:u,onSearchOpenChange:d}),e[23]=o,e[24]=b,e[25]=t,e[26]=r,e[27]=u,e[28]=s,e[29]=A):A=e[29];let R;e[30]!==E||e[31]!==$||e[32]!==A||e[33]!==C?(R=a.jsx("div",{"aria-hidden":C,inert:E,className:$,children:A}),e[30]=E,e[31]=$,e[32]=A,e[33]=C,e[34]=R):R=e[34];const P=i.mobileTab!=="workspace",z=i.mobileTab!=="workspace",L=i.mobileTab!=="workspace"&&"hidden";let I;e[35]!==L?(I=G("absolute inset-0 flex min-h-0 min-w-0 flex-col",L),e[35]=L,e[36]=I):I=e[36];const M=i.mobileTab==="workspace";let F;e[37]!==o||e[38]!==t||e[39]!==r||e[40]!==s||e[41]!==M?(F=a.jsx(lbe,{navigation:t,sessionView:s,project:r,chrome:o,active:M}),e[37]=o,e[38]=t,e[39]=r,e[40]=s,e[41]=M,e[42]=F):F=e[42];let U;e[43]!==P||e[44]!==z||e[45]!==I||e[46]!==F?(U=a.jsx("div",{"aria-hidden":P,inert:z,className:I,children:F}),e[43]=P,e[44]=z,e[45]=I,e[46]=F,e[47]=U):U=e[47];let O;e[48]!==m||e[49]!==t.panels?(O=m&&a.jsx("div",{className:"absolute inset-0 z-10 flex min-h-0 min-w-0 flex-col bg-canvas",children:a.jsx(h7,{view:m,onClose:t.panels.closeMainView})}),e[48]=m,e[49]=t.panels,e[50]=O):O=e[50];let D;e[51]!==g||e[52]!==R||e[53]!==U||e[54]!==O||e[55]!==S?(D=a.jsxs("main",{ref:g,className:"app-view-transition relative flex flex-1 min-h-0 overflow-hidden",children:[S,R,U,O]}),e[51]=g,e[52]=R,e[53]=U,e[54]=O,e[55]=S,e[56]=D):D=e[56];let B;e[57]!==v||e[58]!==i.mobileTab?(B=a.jsx(J0e,{activeTab:i.mobileTab,onTabChange:v}),e[57]=v,e[58]=i.mobileTab,e[59]=B):B=e[59];let q;e[60]!==l.defaultAgentKind||e[61]!==t.onStartNewFolder||e[62]!==t.onStartNewSession?(q=a.jsx(TI,{onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:l.defaultAgentKind}),e[60]=l.defaultAgentKind,e[61]=t.onStartNewFolder,e[62]=t.onStartNewSession,e[63]=q):q=e[63];let W;e[64]!==o||e[65]!==r||e[66]!==c||e[67]!==i.sessionChangeKey?(W=c&&r.hasFileChanges&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(ube,{open:o.fileChangesOpen,onClose:()=>o.onFileChangesOpenChange(!1),session:c,sessionChangeKey:i.sessionChangeKey})}),e[64]=o,e[65]=r,e[66]=c,e[67]=i.sessionChangeKey,e[68]=W):W=e[68];let H;return e[69]!==o.backgroundServers||e[70]!==o.branchModal||e[71]!==o.undoDialog||e[72]!==o.workflowsPanel||e[73]!==D||e[74]!==B||e[75]!==q||e[76]!==W||e[77]!==N?(H=a.jsxs("div",{className:"flex h-dvh flex-col bg-canvas text-foreground",children:[j,k,_,N,D,o.workflowsPanel,B,o.undoDialog,o.branchModal,q,W]}),e[69]=o.backgroundServers,e[70]=o.branchModal,e[71]=o.undoDialog,e[72]=o.workflowsPanel,e[73]=D,e[74]=B,e[75]=q,e[76]=W,e[77]=N,e[78]=H):H=e[78],H}function fbe(n){const e=V.c(23),{navigation:t,sessionView:s,project:r,chrome:o,headerAccessory:i,searchOpen:l,onSearchOpenChange:c}=n,{state:u,config:d}=Sn(),{session:f,isSubAgentView:m}=kt();let p;e[0]!==o||e[1]!==d||e[2]!==i||e[3]!==m||e[4]!==t||e[5]!==c||e[6]!==r||e[7]!==l||e[8]!==f||e[9]!==s||e[10]!==u.expandAll||e[11]!==u.pendingDirName?(p=f?a.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[s.teamMembersBar,a.jsx(ebe,{headerAccessory:i,creatingSession:t.creatingSession,onNewSession:t.onStartNewSession,onDuplicateSession:t.handlers.handleDuplicateSession,onBackToMain:m?s.onBackToMain:void 0,onShowFileChanges:()=>o.onFileChangesOpenChange(!0),hasFileChanges:r.hasFileChanges,onShowWorkflows:s.onShowWorkflows,workflowCount:s.workflowCount,onSearch:()=>c(!0),expandAll:u.expandAll,onToggleExpandAll:s.onToggleExpandAll}),a.jsx(Tm,{searchInputRef:s.searchInputRef,hasMore:s.hasMoreTurns,isLoadingOlder:s.isLoadingOlderTurns,onLoadMore:s.onLoadMoreTurns,mobileSearchOpen:l,onMobileSearchClose:()=>c(!1)})]}):u.pendingDirName?a.jsx("div",{className:"flex flex-1 min-h-0 flex-col",children:s.pendingTurns.length>0?a.jsx("div",{className:"flex-1 overflow-y-auto px-1 py-3",children:s.pendingTurns}):a.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-4 px-4",children:[a.jsx(QI,{projectPath:s.pendingPath??null,switcher:{onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:d.defaultAgentKind}}),xt("terminal")&&a.jsxs(Q,{variant:"outline",size:"xs",onClick:r.onOpenTerminal,children:[a.jsx(Ca,{"data-icon":"inline-start"}),"Terminal"]})]})}):a.jsx(bf,{navigation:t}),e[0]=o,e[1]=d,e[2]=i,e[3]=m,e[4]=t,e[5]=c,e[6]=r,e[7]=l,e[8]=f,e[9]=s,e[10]=u.expandAll,e[11]=u.pendingDirName,e[12]=p):p=e[12];let h;e[13]!==f||e[14]!==s||e[15]!==u.pendingDirName?(h=(f||u.pendingDirName)&&a.jsxs(a.Fragment,{children:[s.todoProgress,f?s.activeComposer:s.pendingComposer]}),e[13]=f,e[14]=s,e[15]=u.pendingDirName,e[16]=h):h=e[16];let g;e[17]!==o.processPanel||e[18]!==h?(g=a.jsxs("div",{className:"shrink-0",children:[o.processPanel,h]}),e[17]=o.processPanel,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==p||e[21]!==g?(x=a.jsxs(a.Fragment,{children:[p,g]}),e[20]=p,e[21]=g,e[22]=x):x=e[22],x}function mbe(n){const e=V.c(10),{sessionId:t,loadError:s,searchInputRef:r,activeComposer:o,hasMoreTurns:i,isLoadingOlderTurns:l,onLoadMoreTurns:c}=n,{isMobile:u}=Sn(),{session:d}=kt();let f;return e[0]!==o||e[1]!==i||e[2]!==l||e[3]!==u||e[4]!==s||e[5]!==c||e[6]!==r||e[7]!==d||e[8]!==t?(f=a.jsx("div",{className:"flex h-dvh flex-col overflow-hidden bg-canvas text-foreground",children:d?a.jsxs("main",{className:"relative flex min-h-0 flex-1 flex-col",children:[a.jsx(Tm,{searchInputRef:r,hasMore:i,isLoadingOlder:l,onLoadMore:c}),u?o:a.jsx(Im,{floating:!0,children:o})]}):a.jsx("main",{className:"flex min-h-0 flex-1 items-center justify-center p-6",children:a.jsx(Ln,{className:"max-w-md",children:a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:s?a.jsx(wr,{}):a.jsx(St,{className:"animate-spin"})}),a.jsx(zn,{children:s?"Unable to open session":"Opening session"}),a.jsx(Dn,{children:s??`Looking for ${t} in your local Claude, Codex, and Copilot history.`})]})})})}),e[0]=o,e[1]=i,e[2]=l,e[3]=u,e[4]=s,e[5]=c,e[6]=r,e[7]=d,e[8]=t,e[9]=f):f=e[9],f}function pbe(){let n=ui;const e=new Set;return{snapshot:()=>n,subscribe(t){return e.add(t),()=>{e.delete(t)}},publish(t){if(t!==n){n=t;for(const s of e)s()}}}}const hbe=5;function x7(){const n=cn(),e=Zn();return e===null?n:`${n}:${e}`}function Zu(n,e){return`${x7()}:${n}/${e}`}class gbe{constructor(){Ge(this,"cache",new Map)}get(e,t){const s=Zu(e,t),r=this.cache.get(s);return r&&(r.lastAccessed=Date.now()),r}set(e,t,s,r,o,i,l,c){const u=Zu(e,t);!this.cache.has(u)&&this.cache.size>=hbe&&this.evictLRU(),this.cache.set(u,{parsed:s,olderTurns:[],source:{dirName:e,fileName:t,rawText:r,agentKind:l,...c!==void 0?{watchOffset:c}:{}},nextByteOffset:o,hasMore:i,lastAccessed:Date.now()})}update(e,t,s){const r=Zu(e,t),o=this.cache.get(r);o&&(s.parsed!==void 0&&(o.parsed=s.parsed),s.olderTurns!==void 0&&(o.olderTurns=s.olderTurns),s.nextByteOffset!==void 0&&(o.nextByteOffset=s.nextByteOffset),s.hasMore!==void 0&&(o.hasMore=s.hasMore),s.lastAccessed!==void 0&&(o.lastAccessed=s.lastAccessed),s.source&&(o.source={...o.source,...s.source}))}evict(e,t){e!==void 0&&t!==void 0?this.cache.delete(Zu(e,t)):this.evictLRU()}evictSession(e){const t=`${x7()}:`;for(const[s,{source:r}]of this.cache)s.startsWith(t)&&kx(r.dirName,r.fileName)===e&&this.cache.delete(s)}clear(){this.cache.clear()}evictLRU(){let e,t=1/0;for(const[s,r]of this.cache)r.lastAccessed<t&&(t=r.lastAccessed,e=s);e!==void 0&&this.cache.delete(e)}}const js=new gbe,Fj={};function b7(n,e,t,s,r,o){const[i,l]=y.useState(!1),[c,u]=y.useState("disconnected"),[d,f]=y.useState(!1),[m,p]=y.useState(null),[h,g]=y.useState(Fj),[x,b]=y.useState(null),[w,v]=y.useState(null),[j]=y.useState(pbe),k=y.useRef(""),_=y.useRef(null),N=y.useRef(ui),S=y.useRef("disconnected"),C=y.useRef(e);C.current=e;const E=y.useRef(r);E.current=r;const T=y.useRef(t);T.current=t;const $=y.useRef(s);$.current=s;const A=y.useRef(o??null);A.current=o??null;const R=y.useRef(!1),P=(n==null?void 0:n.dirName)??null,z=(n==null?void 0:n.fileName)??null,L=(n==null?void 0:n.rawText)??"",I=(n==null?void 0:n.watchOffset)??new TextEncoder().encode(L).byteLength;return y.useEffect(()=>{if(k.current=L,!L){_.current=null,l(!1);return}const M=A.current;if(M){_.current=M;return}T.current(L).then(F=>{_.current=ra(F,Yr(n==null?void 0:n.dirName).instanceId)})},[L,n==null?void 0:n.dirName]),y.useEffect(()=>{if(b(null),v(null),!P||!z){l(!1),u("disconnected");return}u("connecting");const M=`/api/watch/${encodeURIComponent(P)}/${encodeURIComponent(z)}?offset=${I}`,F=eb(M),U=F.source;let O=null;const D=(ue=3e4)=>{O&&clearTimeout(O),O=setTimeout(()=>{l(!1),f(!1)},ue)};let B="",q=I,W=!1,H=!1,K=!1,Z=null;const Y=()=>{K=!1,Z=null,_.current&&C.current(_.current)},X=()=>{K||(K=!0,Z=requestAnimationFrame(Y))};let ee=!1,te=null,se=null;const J=()=>{ee=!1,te=null,j.publish(N.current)},ne=()=>{ee||(ee=!0,te=requestAnimationFrame(J))},ie=ue=>{ue!==N.current&&(N.current=ue,ne(),ue.length>0&&!se&&(se=setInterval(()=>{const re=kle(N.current);re!==N.current&&(N.current=re,ne()),N.current.length===0&&se&&(clearInterval(se),se=null)},5e3)))},ae=()=>{ie(ui),g(Fj)},oe=()=>{if(H||W||!B)return;const ue=B;B="",W=!0;const re=_.current;(re?$.current(re,ue):T.current(k.current)).then(fe=>{const le=ra(fe,Yr(P).instanceId);H||(_.current=le,P&&z&&js.update(P,z,{parsed:le,source:{rawText:k.current,watchOffset:q}}),X())}).catch(fe=>{console.error("[useLiveSession] worker parse failed:",fe)}).finally(()=>{W=!1,!H&&B&&oe()})};return U.onopen=()=>{var ue;if(S.current!=="connected"){const re=R.current;R.current=!1,S.current="connected",u("connected"),re&&((ue=E.current)==null||ue.call(E))}},U.onmessage=ue=>{try{S.current!=="connected"&&(S.current="connected",u("connected"));const re=JSON.parse(ue.data);if(re.type==="init")re.recentlyActive?(l(!0),D(5e3)):D();else if(re.type==="compacting")re.active&&(l(!0),ae(),D()),f(re.active===!0);else if(re.type==="subagent_activity")l(!0),D();else if(re.type==="runtime_activity")l(!0),D();else if(re.type==="stream_snapshot")l(!0),D(),ie(yle(re.messages??[]));else if(re.type==="stream_delta")l(!0),D(),p(null),b(null),v(null),ie(wle(N.current,re.events??[]));else if(re.type==="rate_limit")v(re.block??null);else if(re.type==="agent_progress")l(!0),D(),g(de=>({...de,[re.toolUseId]:re.summary}));else if(re.type==="prompt_suggestion")b(typeof re.suggestion=="string"?re.suggestion:null);else if(re.type==="turn_error")p(typeof re.message=="string"?re.message:"The turn failed");else if(re.type==="stream_clear")ae(),f(!1);else if(re.type==="lines"){if(typeof re.skippedBytes=="number"&&(q+=re.skippedBytes),re.lines.length===0)return;l(!0),f(!1),D(),ie(Sle(N.current,re.lines));const de=re.lines.join(`
482
+ `),t.actions.handleMobileTabChange("chat"),requestAnimationFrame(()=>le==null?void 0:le.focus())},e[8]=t.actions,e[9]=s.chatInputRef,e[10]=z):z=e[10];const L=z;let I;e[11]!==c?(I=c?{dirName:c.dirName,fileName:c.fileName}:null,e[11]=c,e[12]=I):I=e[12];const M=r.currentCwd??null;let F;e[13]!==d||e[14]!==f||e[15]!==L||e[16]!==t.handlers.handleLoadSessionScrollAware||e[17]!==u||e[18]!==r.hasFileChanges||e[19]!==r.supportsWorktrees||e[20]!==l||e[21]!==i.sessionChangeKey||e[22]!==I||e[23]!==M?(F={session:l,sessionAddress:I,sessionChangeKey:i.sessionChangeKey,projectPath:M,hasFileChanges:r.hasFileChanges,canAccessHostFiles:d,canUseBrowser:f,supportsWorktrees:r.supportsWorktrees,openSession:t.handlers.handleLoadSessionScrollAware,composePrompt:L,crew:u},e[13]=d,e[14]=f,e[15]=L,e[16]=t.handlers.handleLoadSessionScrollAware,e[17]=u,e[18]=r.hasFileChanges,e[19]=r.supportsWorktrees,e[20]=l,e[21]=i.sessionChangeKey,e[22]=I,e[23]=M,e[24]=F):F=e[24];const U=F,O=r.currentCwd??null,D=r.projectFilesRoot??r.currentCwd??null;let B;e[25]!==L?(B=de=>L(g7(de)),e[25]=L,e[26]=B):B=e[26];let q;e[27]!==t.actions||e[28]!==r.processPanel?(q=(...de)=>{const fe=de;r.processPanel.handleToggleServer(...fe),t.actions.handleMobileTabChange("chat")},e[27]=t.actions,e[28]=r.processPanel,e[29]=q):q=e[29];let W;e[30]!==t.actions?(W=de=>{t.actions.handleDashboardSelect(de.dirName,`${de.sessionId}.jsonl`)},e[30]=t.actions,e[31]=W):W=e[31];let H;e[32]!==t.handlers.handleLoadSessionScrollAware||e[33]!==t.handlers.handleMobileJumpToTurn||e[34]!==r.backgroundAgents||e[35]!==r.processPanel.handleServersChanged||e[36]!==r.projectFilesRequest||e[37]!==r.worktrees||e[38]!==s.searchInputRef||e[39]!==D||e[40]!==B||e[41]!==q||e[42]!==W||e[43]!==T?(H={projectFilesRoot:D,projectFilesRequest:r.projectFilesRequest,backgroundAgents:r.backgroundAgents,searchInputRef:s.searchInputRef,addProjectContext:B,jumpToTurn:t.handlers.handleMobileJumpToTurn,toggleServer:q,serversChanged:r.processPanel.handleServersChanged,loadSession:t.handlers.handleLoadSessionScrollAware,worktrees:r.worktrees,worktreeDirName:T,openWorktreeSession:W},e[32]=t.handlers.handleLoadSessionScrollAware,e[33]=t.handlers.handleMobileJumpToTurn,e[34]=r.backgroundAgents,e[35]=r.processPanel.handleServersChanged,e[36]=r.projectFilesRequest,e[37]=r.worktrees,e[38]=s.searchInputRef,e[39]=D,e[40]=B,e[41]=q,e[42]=W,e[43]=T,e[44]=H):H=e[44];let K;e[45]!==C.activeWorkspacePanel||e[46]!==_?(K=((re=II(C.activeWorkspacePanel,_))==null?void 0:re.id)??C.activeWorkspacePanel,e[45]=C.activeWorkspacePanel,e[46]=_,e[47]=K):K=e[47];let Z;e[48]!==C?(Z=de=>{S(null),C.openWorkspacePanel(de)},e[48]=C,e[49]=Z):Z=e[49];let Y;e[50]!==m?(Y=m?[{id:"plugins",title:"Plugins",icon:xx,active:!1,onSelect:()=>h(!0)}]:[],e[50]=m,e[51]=Y):Y=e[51];const X=E==="mission";let ee;e[52]!==P?(ee=()=>P("mission"),e[52]=P,e[53]=ee):ee=e[53];let te;e[54]!==X||e[55]!==ee?(te={id:"mission",title:"Mission Control",icon:q4,active:X,onSelect:ee},e[54]=X,e[55]=ee,e[56]=te):te=e[56];let se;e[57]!==m||e[58]!==P||e[59]!==E?(se=m?[{id:"config",title:"Config",icon:V4,active:E==="config",onSelect:()=>P("config")}]:[],e[57]=m,e[58]=P,e[59]=E,e[60]=se):se=e[60];let J;e[61]!==Y||e[62]!==te||e[63]!==se?(J=[...Y,te,...se],e[61]=Y,e[62]=te,e[63]=se,e[64]=J):J=e[64];let ne;e[65]!==m||e[66]!==t||e[67]!==r.currentCwd||e[68]!==E||e[69]!==i.configFilePath?(ne=E==="mission"?a.jsx("div",{className:"flex h-full min-h-0 flex-col",children:a.jsx(bf,{navigation:t})}):E==="config"&&m?a.jsx(y.Suspense,{fallback:a.jsx(Rm,{label:"Loading configuration…"}),children:a.jsx("div",{className:"flex h-full min-h-0",children:a.jsx(abe,{projectPath:r.currentCwd??null,initialFilePath:i.configFilePath})})}):null,e[65]=m,e[66]=t,e[67]=r.currentCwd,e[68]=E,e[69]=i.configFilePath,e[70]=ne):ne=e[70];let ie;e[71]!==o||e[72]!==A||e[73]!==U||e[74]!==K||e[75]!==Z||e[76]!==J||e[77]!==ne||e[78]!==_?(ie=a.jsx(sbe,{panels:_,context:U,activePanelId:K,active:o,onSelectPanel:Z,onClosePanel:A,actions:J,actionContent:ne}),e[71]=o,e[72]=A,e[73]=U,e[74]=K,e[75]=Z,e[76]=J,e[77]=ne,e[78]=_,e[79]=ie):ie=e[79];let ae;e[80]!==m||e[81]!==g||e[82]!==p||e[83]!==r.currentCwd||e[84]!==v?(ae=p&&m&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(ibe,{client:v.client,state:v,currentPath:r.currentCwd??null,initialPluginId:g,onClose:()=>{h(!1),x(void 0)}})}),e[80]=m,e[81]=g,e[82]=p,e[83]=r.currentCwd,e[84]=v,e[85]=ae):ae=e[85];let oe;e[86]!==H||e[87]!==ie||e[88]!==ae?(oe=a.jsxs(UI,{value:H,children:[ie,ae]}),e[86]=H,e[87]=ie,e[88]=ae,e[89]=oe):oe=e[89];let ue;return e[90]!==v||e[91]!==O||e[92]!==oe?(ue=a.jsx(qE,{runtime:v,workspacePath:O,children:oe}),e[90]=v,e[91]=O,e[92]=oe,e[93]=ue):ue=e[93],ue}function cbe(){return new URLSearchParams(window.location.search).get("pluginSafeMode")==="1"}const ube=y.lazy(()=>nt(()=>import("./MobileFileChanges-DyjwWXMW.js"),__vite__mapDeps([41,1,2,3,4])).then(n=>({default:n.MobileFileChanges})));function dbe(n){const e=V.c(79),{navigation:t,sessionView:s,project:r,chrome:o}=n,{state:i,config:l}=Sn(),{session:c}=kt(),[u,d]=y.useState(!1),{AccountControl:f}=$r(),m=zN(i.mainView==="extension"?i.extensionViewId:null),p=i.mobileTab==="workspace"||(m==null?void 0:m.locksSwipe)===!0;let h;e[0]!==t.actions||e[1]!==i.mobileTab||e[2]!==p?(h={onSwipeLeft:()=>{if(p)return;const K=Dj(zj,i.mobileTab,1);K&&(q1(),t.actions.handleMobileTabChange(K))},onSwipeRight:()=>{if(p)return;const K=Dj(zj,i.mobileTab,-1);K&&(q1(),t.actions.handleMobileTabChange(K))}},e[0]=t.actions,e[1]=i.mobileTab,e[2]=p,e[3]=h):h=e[3];const g=nbe(h);let x;e[4]!==f||e[5]!==o.onLogout||e[6]!==t.panels?(x=f&&a.jsx(f,{mobile:!0,onLogout:o.onLogout,onOpenMainView:t.panels.openMainView,className:"ml-auto"}),e[4]=f,e[5]=o.onLogout,e[6]=t.panels,e[7]=x):x=e[7];const b=x;let w;e[8]!==m||e[9]!==t.actions||e[10]!==t.panels?(w=K=>{d(!1),m&&t.panels.closeMainView(),t.actions.handleMobileTabChange(K)},e[8]=m,e[9]=t.actions,e[10]=t.panels,e[11]=w):w=e[11];const v=w,j=o.backgroundServers;let k,_;e[12]===Symbol.for("react.memo_cache_sentinel")?(k=a.jsx(xA,{}),_=a.jsx(gA,{}),e[12]=k,e[13]=_):(k=e[12],_=e[13]);let N;e[14]!==b||e[15]!==c||e[16]!==i.mobileTab?(N=!(i.mobileTab==="chat"&&c)&&a.jsxs("div",{className:"motion-slide-down-in flex h-12 shrink-0 items-center border-b bg-background px-2",children:[a.jsx(Zb,{compact:!0}),b]}),e[14]=b,e[15]=c,e[16]=i.mobileTab,e[17]=N):N=e[17];let S;e[18]!==t||e[19]!==i.mobileTab?(S=i.mobileTab==="sessions"&&a.jsx(p7,{navigation:t,mobile:!0}),e[18]=t,e[19]=i.mobileTab,e[20]=S):S=e[20];const C=i.mobileTab!=="chat",E=i.mobileTab!=="chat",T=i.mobileTab!=="chat"&&"invisible pointer-events-none";let $;e[21]!==T?($=G("absolute inset-0 flex min-h-0 min-w-0 flex-col",T),e[21]=T,e[22]=$):$=e[22];let A;e[23]!==o||e[24]!==b||e[25]!==t||e[26]!==r||e[27]!==u||e[28]!==s?(A=a.jsx(fbe,{navigation:t,sessionView:s,project:r,chrome:o,headerAccessory:b,searchOpen:u,onSearchOpenChange:d}),e[23]=o,e[24]=b,e[25]=t,e[26]=r,e[27]=u,e[28]=s,e[29]=A):A=e[29];let R;e[30]!==E||e[31]!==$||e[32]!==A||e[33]!==C?(R=a.jsx("div",{"aria-hidden":C,inert:E,className:$,children:A}),e[30]=E,e[31]=$,e[32]=A,e[33]=C,e[34]=R):R=e[34];const P=i.mobileTab!=="workspace",z=i.mobileTab!=="workspace",L=i.mobileTab!=="workspace"&&"hidden";let I;e[35]!==L?(I=G("absolute inset-0 flex min-h-0 min-w-0 flex-col",L),e[35]=L,e[36]=I):I=e[36];const M=i.mobileTab==="workspace";let F;e[37]!==o||e[38]!==t||e[39]!==r||e[40]!==s||e[41]!==M?(F=a.jsx(lbe,{navigation:t,sessionView:s,project:r,chrome:o,active:M}),e[37]=o,e[38]=t,e[39]=r,e[40]=s,e[41]=M,e[42]=F):F=e[42];let U;e[43]!==P||e[44]!==z||e[45]!==I||e[46]!==F?(U=a.jsx("div",{"aria-hidden":P,inert:z,className:I,children:F}),e[43]=P,e[44]=z,e[45]=I,e[46]=F,e[47]=U):U=e[47];let O;e[48]!==m||e[49]!==t.panels?(O=m&&a.jsx("div",{className:"absolute inset-0 z-10 flex min-h-0 min-w-0 flex-col bg-canvas",children:a.jsx(h7,{view:m,onClose:t.panels.closeMainView})}),e[48]=m,e[49]=t.panels,e[50]=O):O=e[50];let D;e[51]!==g||e[52]!==R||e[53]!==U||e[54]!==O||e[55]!==S?(D=a.jsxs("main",{ref:g,className:"app-view-transition relative flex flex-1 min-h-0 overflow-hidden",children:[S,R,U,O]}),e[51]=g,e[52]=R,e[53]=U,e[54]=O,e[55]=S,e[56]=D):D=e[56];let B;e[57]!==v||e[58]!==i.mobileTab?(B=a.jsx(J0e,{activeTab:i.mobileTab,onTabChange:v}),e[57]=v,e[58]=i.mobileTab,e[59]=B):B=e[59];let q;e[60]!==l.defaultAgentKind||e[61]!==t.onStartNewFolder||e[62]!==t.onStartNewSession?(q=a.jsx(TI,{onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:l.defaultAgentKind}),e[60]=l.defaultAgentKind,e[61]=t.onStartNewFolder,e[62]=t.onStartNewSession,e[63]=q):q=e[63];let W;e[64]!==o||e[65]!==r||e[66]!==c||e[67]!==i.sessionChangeKey?(W=c&&r.hasFileChanges&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(ube,{open:o.fileChangesOpen,onClose:()=>o.onFileChangesOpenChange(!1),session:c,sessionChangeKey:i.sessionChangeKey})}),e[64]=o,e[65]=r,e[66]=c,e[67]=i.sessionChangeKey,e[68]=W):W=e[68];let H;return e[69]!==o.backgroundServers||e[70]!==o.branchModal||e[71]!==o.undoDialog||e[72]!==o.workflowsPanel||e[73]!==D||e[74]!==B||e[75]!==q||e[76]!==W||e[77]!==N?(H=a.jsxs("div",{className:"flex h-dvh flex-col bg-canvas text-foreground",children:[j,k,_,N,D,o.workflowsPanel,B,o.undoDialog,o.branchModal,q,W]}),e[69]=o.backgroundServers,e[70]=o.branchModal,e[71]=o.undoDialog,e[72]=o.workflowsPanel,e[73]=D,e[74]=B,e[75]=q,e[76]=W,e[77]=N,e[78]=H):H=e[78],H}function fbe(n){const e=V.c(23),{navigation:t,sessionView:s,project:r,chrome:o,headerAccessory:i,searchOpen:l,onSearchOpenChange:c}=n,{state:u,config:d}=Sn(),{session:f,isSubAgentView:m}=kt();let p;e[0]!==o||e[1]!==d||e[2]!==i||e[3]!==m||e[4]!==t||e[5]!==c||e[6]!==r||e[7]!==l||e[8]!==f||e[9]!==s||e[10]!==u.expandAll||e[11]!==u.pendingDirName?(p=f?a.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[s.teamMembersBar,a.jsx(ebe,{headerAccessory:i,creatingSession:t.creatingSession,onNewSession:t.onStartNewSession,onDuplicateSession:t.handlers.handleDuplicateSession,onBackToMain:m?s.onBackToMain:void 0,onShowFileChanges:()=>o.onFileChangesOpenChange(!0),hasFileChanges:r.hasFileChanges,onShowWorkflows:s.onShowWorkflows,workflowCount:s.workflowCount,onSearch:()=>c(!0),expandAll:u.expandAll,onToggleExpandAll:s.onToggleExpandAll}),a.jsx(Tm,{searchInputRef:s.searchInputRef,hasMore:s.hasMoreTurns,isLoadingOlder:s.isLoadingOlderTurns,onLoadMore:s.onLoadMoreTurns,mobileSearchOpen:l,onMobileSearchClose:()=>c(!1)})]}):u.pendingDirName?a.jsx("div",{className:"flex flex-1 min-h-0 flex-col",children:s.pendingTurns.length>0?a.jsx("div",{className:"flex-1 overflow-y-auto px-1 py-3",children:s.pendingTurns}):a.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-4 px-4",children:[a.jsx(QI,{projectPath:s.pendingPath??null,switcher:{onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:d.defaultAgentKind}}),xt("terminal")&&a.jsxs(Q,{variant:"outline",size:"xs",onClick:r.onOpenTerminal,children:[a.jsx(Ca,{"data-icon":"inline-start"}),"Terminal"]})]})}):a.jsx(bf,{navigation:t}),e[0]=o,e[1]=d,e[2]=i,e[3]=m,e[4]=t,e[5]=c,e[6]=r,e[7]=l,e[8]=f,e[9]=s,e[10]=u.expandAll,e[11]=u.pendingDirName,e[12]=p):p=e[12];let h;e[13]!==f||e[14]!==s||e[15]!==u.pendingDirName?(h=(f||u.pendingDirName)&&a.jsxs(a.Fragment,{children:[s.todoProgress,f?s.activeComposer:s.pendingComposer]}),e[13]=f,e[14]=s,e[15]=u.pendingDirName,e[16]=h):h=e[16];let g;e[17]!==o.processPanel||e[18]!==h?(g=a.jsxs("div",{className:"shrink-0",children:[o.processPanel,h]}),e[17]=o.processPanel,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==p||e[21]!==g?(x=a.jsxs(a.Fragment,{children:[p,g]}),e[20]=p,e[21]=g,e[22]=x):x=e[22],x}function mbe(n){const e=V.c(10),{sessionId:t,loadError:s,searchInputRef:r,activeComposer:o,hasMoreTurns:i,isLoadingOlderTurns:l,onLoadMoreTurns:c}=n,{isMobile:u}=Sn(),{session:d}=kt();let f;return e[0]!==o||e[1]!==i||e[2]!==l||e[3]!==u||e[4]!==s||e[5]!==c||e[6]!==r||e[7]!==d||e[8]!==t?(f=a.jsx("div",{className:"flex h-dvh flex-col overflow-hidden bg-canvas text-foreground",children:d?a.jsxs("main",{className:"relative flex min-h-0 flex-1 flex-col",children:[a.jsx(Tm,{searchInputRef:r,hasMore:i,isLoadingOlder:l,onLoadMore:c}),u?o:a.jsx(Im,{floating:!0,children:o})]}):a.jsx("main",{className:"flex min-h-0 flex-1 items-center justify-center p-6",children:a.jsx(Ln,{className:"max-w-md",children:a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:s?a.jsx(wr,{}):a.jsx(St,{className:"animate-spin"})}),a.jsx(zn,{children:s?"Unable to open session":"Opening session"}),a.jsx(Dn,{children:s??`Looking for ${t} in your local Claude, Codex, and Copilot history.`})]})})})}),e[0]=o,e[1]=i,e[2]=l,e[3]=u,e[4]=s,e[5]=c,e[6]=r,e[7]=d,e[8]=t,e[9]=f):f=e[9],f}function pbe(){let n=ui;const e=new Set;return{snapshot:()=>n,subscribe(t){return e.add(t),()=>{e.delete(t)}},publish(t){if(t!==n){n=t;for(const s of e)s()}}}}const hbe=5;function x7(){const n=cn(),e=Zn();return e===null?n:`${n}:${e}`}function Zu(n,e){return`${x7()}:${n}/${e}`}class gbe{constructor(){Ge(this,"cache",new Map)}get(e,t){const s=Zu(e,t),r=this.cache.get(s);return r&&(r.lastAccessed=Date.now()),r}set(e,t,s,r,o,i,l,c){const u=Zu(e,t);!this.cache.has(u)&&this.cache.size>=hbe&&this.evictLRU(),this.cache.set(u,{parsed:s,olderTurns:[],source:{dirName:e,fileName:t,rawText:r,agentKind:l,...c!==void 0?{watchOffset:c}:{}},nextByteOffset:o,hasMore:i,lastAccessed:Date.now()})}update(e,t,s){const r=Zu(e,t),o=this.cache.get(r);o&&(s.parsed!==void 0&&(o.parsed=s.parsed),s.olderTurns!==void 0&&(o.olderTurns=s.olderTurns),s.nextByteOffset!==void 0&&(o.nextByteOffset=s.nextByteOffset),s.hasMore!==void 0&&(o.hasMore=s.hasMore),s.lastAccessed!==void 0&&(o.lastAccessed=s.lastAccessed),s.source&&(o.source={...o.source,...s.source}))}evict(e,t){e!==void 0&&t!==void 0?this.cache.delete(Zu(e,t)):this.evictLRU()}evictSession(e){const t=`${x7()}:`;for(const[s,{source:r}]of this.cache)s.startsWith(t)&&kx(r.dirName,r.fileName)===e&&this.cache.delete(s)}clear(){this.cache.clear()}evictLRU(){let e,t=1/0;for(const[s,r]of this.cache)r.lastAccessed<t&&(t=r.lastAccessed,e=s);e!==void 0&&this.cache.delete(e)}}const js=new gbe,Fj={};function b7(n,e,t,s,r,o){const[i,l]=y.useState(!1),[c,u]=y.useState("disconnected"),[d,f]=y.useState(!1),[m,p]=y.useState(null),[h,g]=y.useState(Fj),[x,b]=y.useState(null),[w,v]=y.useState(null),[j]=y.useState(pbe),k=y.useRef(""),_=y.useRef(null),N=y.useRef(ui),S=y.useRef("disconnected"),C=y.useRef(e);C.current=e;const E=y.useRef(r);E.current=r;const T=y.useRef(t);T.current=t;const $=y.useRef(s);$.current=s;const A=y.useRef(o??null);A.current=o??null;const R=y.useRef(!1),P=(n==null?void 0:n.dirName)??null,z=(n==null?void 0:n.fileName)??null,L=(n==null?void 0:n.rawText)??"",I=(n==null?void 0:n.watchOffset)??new TextEncoder().encode(L).byteLength;return y.useEffect(()=>{if(k.current=L,!L){_.current=null,l(!1);return}const M=A.current;if(M){_.current=M;return}T.current(L).then(F=>{_.current=ra(F,Yr(n==null?void 0:n.dirName).instanceId)})},[L,n==null?void 0:n.dirName]),y.useEffect(()=>{if(b(null),v(null),!P||!z){l(!1),u("disconnected");return}u("connecting");const M=`/api/watch/${encodeURIComponent(P)}/${encodeURIComponent(z)}?offset=${I}`,F=eb(M),U=F.source;let O=null;const D=(ue=3e4)=>{O&&clearTimeout(O),O=setTimeout(()=>{l(!1),f(!1)},ue)};let B="",q=I,W=!1,H=!1,K=!1,Z=null;const Y=()=>{K=!1,Z=null,_.current&&C.current(_.current)},X=()=>{K||(K=!0,Z=requestAnimationFrame(Y))};let ee=!1,te=null,se=null;const J=()=>{ee=!1,te=null,j.publish(N.current)},ne=()=>{ee||(ee=!0,te=requestAnimationFrame(J))},ie=ue=>{ue!==N.current&&(N.current=ue,ne(),ue.length>0&&!se&&(se=setInterval(()=>{const re=kle(N.current);re!==N.current&&(N.current=re,ne()),N.current.length===0&&se&&(clearInterval(se),se=null)},5e3)))},ae=()=>{ie(ui),g(Fj)},oe=()=>{if(H||W||!B)return;const ue=B;B="",W=!0;const re=_.current;(re?$.current(re,ue):T.current(k.current)).then(fe=>{const le=ra(fe,Yr(P).instanceId);H||(_.current=le,P&&z&&js.update(P,z,{parsed:le,source:{rawText:k.current,watchOffset:q}}),X())}).catch(fe=>{console.error("[useLiveSession] worker parse failed:",fe)}).finally(()=>{W=!1,!H&&B&&oe()})};return U.onopen=()=>{var ue;if(S.current!=="connected"){const re=R.current;R.current=!1,S.current="connected",u("connected"),re&&((ue=E.current)==null||ue.call(E))}},U.onmessage=ue=>{try{S.current!=="connected"&&(S.current="connected",u("connected"));const re=JSON.parse(ue.data);if(re.type==="init")re.recentlyActive?(l(!0),D(5e3)):D();else if(re.type==="compacting")re.active&&(l(!0),ae(),D()),f(re.active===!0);else if(re.type==="subagent_activity")l(!0),D();else if(re.type==="runtime_activity")l(!0),D();else if(re.type==="stream_snapshot")l(!0),D(),ie(yle(re.messages??[]));else if(re.type==="stream_delta")l(!0),D(),p(null),b(null),v(null),ie(wle(N.current,re.events??[]));else if(re.type==="rate_limit")v(re.block??null);else if(re.type==="agent_progress")l(!0),D(),g(de=>({...de,[re.toolUseId]:re.summary}));else if(re.type==="prompt_suggestion")b(typeof re.suggestion=="string"?re.suggestion:null);else if(re.type==="turn_error")p(typeof re.message=="string"?re.message:"The turn failed");else if(re.type==="stream_clear")ae(),f(!1);else if(re.type==="lines"){if(typeof re.skippedBytes=="number"&&(q+=re.skippedBytes),re.lines.length===0)return;l(!0),f(!1),D(),ie(Sle(N.current,re.lines));const de=re.lines.join(`
483
483
  `)+`
484
484
  `;q+=new TextEncoder().encode(de).byteLength,k.current+=de,B+=de,oe()}}catch(re){console.error("[useLiveSession] Error processing SSE message:",re)}},U.onerror=()=>{l(!1),f(!1),R.current=S.current==="connected",S.current="disconnected",u("disconnected"),ae()},()=>{H=!0,F.close(),l(!1),S.current="disconnected",u("disconnected"),O&&clearTimeout(O),Z!==null&&cancelAnimationFrame(Z),te!==null&&cancelAnimationFrame(te),se&&clearInterval(se),N.current=ui,j.publish(ui)}},[P,z,L,I,j]),{isLive:i,sseState:c,isCompacting:d,streamingOverlayStore:j,turnError:m,agentProgress:h,promptSuggestion:x,rateLimit:w}}const xbe=3e4;function v7(n,e,t){const s=V.c(12);let r;s[0]!==t?(r=t===void 0?{}:t,s[0]=t,s[1]=r):r=s[1];const{onLost:o,staleAfterMs:i}=r,l=i===void 0?xbe:i,[c,u]=y.useState(!1),d=y.useRef(e),f=y.useRef(o);let m,p;s[2]!==o||s[3]!==e?(m=()=>{d.current=e,f.current=o},p=[e,o],s[2]=o,s[3]=e,s[4]=m,s[5]=p):(m=s[4],p=s[5]),y.useEffect(m,p);let h,g;s[6]!==l||s[7]!==n?(h=()=>{if(!n){u(!1);return}let b=!0,w=null;const v=eb(n,{onLost:()=>{var _;return(_=f.current)==null?void 0:_.call(f)}}),j=v.source;u(!1);const k=()=>{w&&clearTimeout(w),w=setTimeout(()=>{b&&u(!1)},l)};return j.onmessage=_=>{if(b)try{const N=JSON.parse(_.data);N.type==="init"?k():N.type==="update"&&(u(!0),k(),d.current())}catch{}},j.onerror=()=>{b&&u(!1)},()=>{b=!1,v.close(),w&&clearTimeout(w)}},g=[n,l],s[6]=l,s[7]=n,s[8]=h,s[9]=g):(h=s[8],g=s[9]),y.useEffect(h,g);let x;return s[10]!==c?(x={isLive:c},s[10]=c,s[11]=x):x=s[11],x}function bbe(n,e,t){const s=V.c(2),r=n?`/api/team-watch/${encodeURIComponent(n)}`:null;let o;return s[0]!==t?(o={onLost:t},s[0]=t,s[1]=o):o=s[1],v7(r,e,o)}function vbe(n,e){const[t,s]=y.useState(null),r=y.useRef(null),o=(()=>{if(!n)return null;let c,u=null;const d=n.match(/^([^/]+)\/subagents\/(.+)$/);d?(c=d[1],u=d[2]):c=n.replace(".jsonl","");const f=new URLSearchParams({leadSessionId:c});return u&&f.set("subagentFile",u),e&&f.set("dirName",e),f.toString()})();r.current=o;const i=y.useCallback(async()=>{const c=r.current;if(c)try{const u=await Ce(`/api/session-team?${c}`);if(!u.ok){s(null);return}const d=await u.json();s(d?{teamName:d.teamName,config:d.config,currentMemberName:d.currentMemberName||null}:null)}catch{s(null)}},[]);y.useEffect(()=>{if(!n){s(null);return}i()},[n,i]);const l=y.useCallback(()=>s(null),[]);return bbe((t==null?void 0:t.teamName)??null,i,l),t}function ybe(n,e,t,s){let r=null;return n&&e&&(r=`/api/workflow-watch/${encodeURIComponent(n)}/${encodeURIComponent(e)}`,t&&(r=r+`/${encodeURIComponent(t)}`)),v7(r,s)}function wbe(n,e,t=!0){const[s,r]=y.useState([]),[o,i]=y.useState(!1),l=y.useRef(0),c=!!n&&!!e,u=y.useCallback(async()=>{const m=++l.current;if(!c){r([]);return}try{const p=await Ce(`/api/workflows/${encodeURIComponent(n)}/${encodeURIComponent(e)}`);if(!p.ok){m===l.current&&r([]);return}const h=await p.json();m===l.current&&r(Array.isArray(h)?h:[])}catch{m===l.current&&r([])}finally{m===l.current&&i(!1)}},[c,n,e]);y.useEffect(()=>{if(!c){r([]),i(!1);return}i(!0),u()},[c,u]);const d=c&&(t||s.length>0),{isLive:f}=ybe(d?n:null,d?e:null,null,u);return{workflows:s,loading:o,isLive:f,refetch:u}}function Sbe(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 V1(n,e){const t=await n.json().catch(()=>({}));return{message:typeof t.error=="string"&&t.error?t.error:e,code:typeof t.code=="string"?t.code:null}}async function Uj(n){if(n.status!==202)return null;const e=await n.clone().json().catch(()=>null);return(e==null?void 0:e.receipt)??null}async function y7(n,e){const{model:t,agentKind:s,errorFallback:r,onModelRejected:o}=e,i=m=>typeof r=="function"?r(m):r;let c=await n(s==="copilot"?t||"auto":t||void 0),u=c.ok?null:await V1(c,i(c)),d=!1,f=await Uj(c);return f&&s==="codex"&&t&&(d=!0,kbe(f,n,e)),!c.ok&&s==="codex"&&t&&Sbe(u==null?void 0:u.message)&&(o==null||o(t),c=await n(void 0),u=c.ok?null:await V1(c,i(c)),f=await Uj(c)),{res:c,errorMessage:(u==null?void 0:u.message)??null,errorCode:(u==null?void 0:u.code)??null,observingReceipt:d,receipt:f}}function kbe(n,e,t){var u;const s=If(n.sessionId);let r=!1,o=()=>{};const i=()=>{var d,f;r||(r=!0,clearTimeout(l),o(),(d=t.signal)==null||d.removeEventListener("abort",i),(f=t.onReceiptSettled)==null||f.call(t))},l=setTimeout(i,1440*60*1e3),c=()=>{var m,p,h;if(r)return;const d=s.snapshot();if((m=t.signal)!=null&&m.aborted||d.error==="Account or device changed"||/Queue unavailable \((401|403|404)\)/.test(d.error??"")){i();return}if(d.freshness!=="current")return;const f=d.commands.find(g=>g.id===n.id);!f||!["failed","completed","cancelled","unknown"].includes(f.state)||(i(),!(f.state!=="failed"||f.errorCode!=="MODEL_REJECTED"||f.delivery||f.turnId||((p=d.conversation)==null?void 0:p.revision)!==n.bindingRevision||d.conversation.binding.sessionId!==n.sessionId)&&((h=t.onModelRejected)==null||h.call(t,t.model),e(void 0).then(async g=>{var x;g.ok||(x=t.onDeliveryError)==null||x.call(t,(await V1(g,"The default model could not accept the message")).message)}).catch(g=>{var x;(x=t.onDeliveryError)==null||x.call(t,g instanceof Error?g.message:"Fallback delivery could not be confirmed")})))};o=s.subscribe(c),(u=t.signal)==null||u.addEventListener("abort",i,{once:!0}),c()}const jbe=[];function Nbe({sessionSource:n,parsedSessionId:e,cwd:t,permissions:s,onPermissionsApplied:r,model:o,effort:i,contextWindowTokens:l,fastMode:c,ultracode:u,settingsChange:d=jbe,onSettingsChangeSent:f,mcpConfig:m,onModelRejected:p,readOnly:h=!1,onCreateSession:g}){const[x,b]=y.useState("idle"),[w,v]=y.useState(),[j,k]=y.useState([]),_=y.useRef(null),N=y.useRef(new Set),S=y.useRef(null),C=y.useRef(!1),E=n!=null&&n.fileName?Ed(n.fileName):null,T=e||E,$=n?un(n.dirName):null,A=y.useCallback(()=>{var F;for(const U of N.current)U.abort();N.current.clear(),(F=_.current)==null||F.abort(),_.current=null,C.current=!1,b("idle"),v(void 0),k([])},[]);y.useEffect(()=>{var F;S.current!==T&&(C.current?(C.current=!1,(F=_.current)==null||F.abort(),_.current=null,b("idle"),v(void 0)):A(),S.current=T)},[T,A]),y.useEffect(()=>{const F=N.current;return()=>{var U;for(const O of F)O.abort();(U=_.current)==null||U.abort()}},[]),y.useEffect(()=>{h&&A()},[h,A]);const R=y.useCallback(async(F,U)=>{if(h)return!1;if(!T&&g){k(D=>[...D,F]),b("connected"),v(void 0),C.current=!0,r==null||r();try{if(!await g(F,U))return C.current=!1,b("idle"),k([]),!0;b("idle")}catch(D){C.current=!1,v(D instanceof Error?D.message:"Failed to create session"),b("error"),k([])}return!0}if(!T)return!0;k(D=>[...D,F]),b("connected"),v(void 0),r==null||r();const O=new AbortController;N.current.add(O),_.current=O;try{const D={sessionId:T,message:F,images:U||void 0,cwd:t||void 0,permissions:s,effort:i||void 0,contextWindowTokens:l,fastMode:c||d.includes("fastMode")?c:void 0,ultracode:u||d.includes("ultracode")?u:void 0,mcpConfig:m||void 0,settingsChange:d.length>0?d:void 0},{res:B,errorMessage:q,observingReceipt:W,receipt:H}=await y7(K=>KE("/api/send-message",{...D,model:K},O.signal),{model:o,agentKind:$,errorFallback:K=>`Request failed (${K.status})`,onModelRejected:p,signal:O.signal,onReceiptSettled:()=>N.current.delete(O),onDeliveryError:K=>{_.current===O&&(v(K),b("error"))}});return W||N.current.delete(O),H&&OR(H)&&k(K=>{const Z=K.lastIndexOf(F);return Z<0?K:K.filter((Y,X)=>X!==Z)}),_.current===O&&(B.ok?b("idle"):(v(q||`Request failed (${B.status})`),b("error"),k(K=>K.slice(0,-1)))),B.ok&&d.length>0&&(f==null||f()),B.ok&&!yR(B)}catch(D){return N.current.delete(O),D instanceof Error&&D.name==="AbortError"?!0:(_.current===O&&(v(D instanceof Error?D.message:"Unknown error"),b("error"),k(B=>B.slice(0,-1))),!1)}},[T,$,t,s,r,o,i,l,c,u,d,f,m,p,h,g]),P=y.useCallback(()=>{A()},[A]),z=y.useCallback(()=>{!T||h||Ce("/api/interrupt-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:T})}).catch(()=>{})},[T,h]),L=y.useCallback(()=>{var F;(F=_.current)==null||F.abort(),_.current=null,z(),b("idle"),k([])},[z]),I=L,M=y.useCallback((F=1)=>{k(U=>U.slice(F))},[]);return{status:x,error:w,pendingMessages:j,sendMessage:R,disconnect:P,interrupt:L,stopAgent:I,consumePending:M,isConnected:x==="connected"}}const Bi={expandAll:!1,expandToolPayloads:!1},Cbe={session:null,windowTurns:[],olderTurns:[],sessionSource:null,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...Bi,sessionChangeKey:0,currentMemberName:null,loadingMember:null,mainView:"sessions",extensionViewId:null,configFilePath:null,mobileTab:"sessions",dashboardProject:null};function Bj(n,e,t,s){const r=hI(e,t,s);return r===n.turns?n:{...n,turns:r}}function Yu(n){return{session:n,windowTurns:(n==null?void 0:n.turns)??[],olderTurns:[]}}function _be(n,e){var t,s;switch(e.type){case"LOAD_SESSION":case"FINALIZE_SESSION":case"INIT_PENDING_SESSION":{const r=e.type==="INIT_PENDING_SESSION";return{...n,...Yu(r?null:e.session),sessionSource:r?null:e.source,pendingDirName:r?e.dirName:null,pendingCwd:r?e.cwd??null:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...Bi,mainView:"sessions",currentMemberName:null,dashboardProject:null,sessionChangeKey:n.sessionChangeKey+1,mobileTab:e.isMobile?"chat":n.mobileTab}}case"GO_HOME":case"CLOSE_SESSION":{const r=e.type==="GO_HOME";return{...n,...Yu(null),sessionSource:null,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...Bi,mainView:r?"sessions":n.mainView,currentMemberName:null,dashboardProject:null,mobileTab:e.isMobile&&(r||n.mobileTab==="chat")?"sessions":n.mobileTab}}case"SWITCH_TEAM_MEMBER":return{...n,...Yu(e.session),sessionSource:e.source,activeTurnIndex:null,searchQuery:"",...Bi,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,...Bi};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,...Bi}:{...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:Bj(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:Bj(n.session,n.windowTurns,e.turns,(s=n.sessionSource)==null?void 0:s.agentKind)};case"RELOAD_SESSION_CONTENT":return{...n,...Yu(e.session),sessionSource:e.source,sessionChangeKey:n.sessionChangeKey+1};case"SET_CURRENT_MEMBER_NAME":return n.currentMemberName===e.name?n:{...n,currentMemberName:e.name};case"GUARD_MOBILE_TAB":{let r=n.mobileTab;return!e.hasSession&&r==="chat"&&(r="sessions"),r!==n.mobileTab?{...n,mobileTab:r}:n}case"SET_LOADING_MEMBER":return n.loadingMember===e.name?n:{...n,loadingMember:e.name};case"SET_DASHBOARD_PROJECT":return n.dashboardProject===e.dirName?n:{...n,dashboardProject:e.dirName};case"OPEN_CONFIG":return{...n,mainView:"config",configFilePath:e.filePath??null};case"CLOSE_CONFIG":return{...n,mainView:"sessions",configFilePath:null};case"OPEN_MISSION":return{...n,mainView:"mission"};case"CLOSE_MISSION":return{...n,mainView:"sessions"};case"OPEN_EXTENSION_VIEW":return{...n,mainView:"extension",extensionViewId:e.id};case"CLOSE_EXTENSION_VIEW":return{...n,mainView:"sessions",extensionViewId:null};default:return n}}function w7(){return y.useReducer(_be,Cbe)}function Wj(n){n(),requestAnimationFrame(()=>{n(),requestAnimationFrame(n)})}function S7({session:n,isLive:e,pendingMessages:t,consumePending:s,sessionChangeKey:r}){const o=y.useRef(null),i=y.useRef(!0),l=y.useRef(!1),c=y.useRef(0),u=y.useRef(!1),d=y.useRef(!1),f=y.useRef(0),m=y.useRef(0),p=y.useRef(0),h=y.useMemo(()=>(n==null?void 0:n.turns.flatMap(O=>O.contentBlocks.flatMap(D=>D.kind==="queued_prompt"?[{id:JSON.stringify([D.timestamp??"",D.content]),content:D.content}]:[])))??[],[n==null?void 0:n.turns]),g=y.useRef(null),x=y.useRef(!1),[b,w]=y.useState(!1),[v,j]=y.useState(null),k=y.useCallback(()=>{c.current++,u.current=!1,i.current=!1,l.current=!1},[]),_=y.useCallback(()=>{i.current=!0;const O=c.current;requestAnimationFrame(()=>{if(O!==c.current||!i.current)return;const D=o.current;D&&(D.scrollTop=D.scrollHeight,f.current=D.scrollTop,m.current=D.scrollHeight)})},[]),N=y.useCallback(()=>{const O=++c.current;i.current=!0,l.current=!1,Wj(()=>{if(O!==c.current)return;const D=o.current;D&&(D.scrollTop=D.scrollHeight,f.current=D.scrollTop,m.current=D.scrollHeight)})},[]),S=y.useCallback(()=>{x.current=!0},[]),C=y.useRef(!1),E=y.useCallback(()=>{const O=o.current;if(!O)return;const D=O.scrollHeight-O.scrollTop-O.clientHeight>10;D!==C.current&&(C.current=D,w(D))},[]),[T,$]=y.useState(null);y.useEffect(()=>{if(!T)return;let O=0;const D=new ResizeObserver(()=>{cancelAnimationFrame(O),O=requestAnimationFrame(()=>{const B=o.current;B&&i.current&&(B.scrollTop=B.scrollHeight,f.current=B.scrollTop,m.current=B.scrollHeight),E()})});return D.observe(T,{box:"border-box"}),()=>{D.disconnect(),cancelAnimationFrame(O)}},[T,E]);const A=y.useCallback(()=>{const O=o.current;if(!O)return;const D=O.scrollHeight-O.scrollTop-O.clientHeight;D>2&&(m.current===0||O.scrollHeight===m.current&&O.scrollTop<f.current)?k():D<=2&&(u.current||d.current&&O.scrollTop>f.current)&&(i.current=!0,u.current=!1),f.current=O.scrollTop,m.current=O.scrollHeight,E()},[k,E]);y.useEffect(()=>{const O=o.current;if(!T||!O)return;let D=0;const B=()=>{u.current=!0,O.scrollHeight-O.scrollTop-O.clientHeight<=2&&(i.current=!0,u.current=!1)},q=X=>{X.deltaY<0?k():X.deltaY>0&&B()},W=()=>{d.current=!0},H=()=>{d.current=!1},K=X=>{var ee;D=((ee=X.touches[0])==null?void 0:ee.clientY)??0},Z=X=>{var te;const ee=((te=X.touches[0])==null?void 0:te.clientY)??D;ee>D?k():ee<D&&B(),D=ee},Y=X=>{X.target instanceof Element&&X.target.closest("input, textarea, select, [contenteditable=true]")||(["ArrowUp","PageUp","Home"].includes(X.key)||X.key===" "&&X.shiftKey?k():["ArrowDown","PageDown","End"," "].includes(X.key)&&B())};return O.addEventListener("wheel",q,{passive:!0}),O.addEventListener("touchstart",K,{passive:!0}),O.addEventListener("touchmove",Z,{passive:!0}),O.addEventListener("keydown",Y),O.addEventListener("pointerdown",W),document.addEventListener("pointerup",H),()=>{O.removeEventListener("wheel",q),O.removeEventListener("touchstart",K),O.removeEventListener("touchmove",Z),O.removeEventListener("keydown",Y),O.removeEventListener("pointerdown",W),document.removeEventListener("pointerup",H)}},[T,k]);const R=y.useCallback(O=>{p.current=O},[]),P=y.useRef(r);y.useEffect(()=>{if(r===P.current)return;P.current=r;const O=x.current;x.current=!1;const D=++c.current,B=()=>{if(D!==c.current)return;const W=o.current;W&&(O?(W.scrollTop=0,i.current=!1):(W.scrollTop=W.scrollHeight,i.current=!0),f.current=W.scrollTop,m.current=W.scrollHeight,l.current=!1)};Wj(B);const q=setTimeout(()=>{B(),j(r)},150);return()=>clearTimeout(q)},[r]);const z=t.length;y.useEffect(()=>{z>0&&(l.current=!0,_())},[z,_]),y.useEffect(()=>{const O=(n==null?void 0:n.sessionId)??null,D=g.current,B=new Set(h.map(H=>H.id));if(!D||D.sessionId!==O){g.current={sessionId:O,ids:B};return}const q=h.filter(H=>!D.ids.has(H.id));if(g.current={sessionId:O,ids:B},q.length===0||z===0)return;let W=0;for(const H of q){const K=t[W];(K===H.content||(K==null?void 0:K.trim())===""&&H.content.length>0)&&W++}W>0&&s(W)},[n==null?void 0:n.sessionId,h,t,z,s]);const L=(n==null?void 0:n.turns.length)??0;y.useEffect(()=>{if(L===0)return;const O=L-p.current;O>0&&(z>0&&s(Math.min(O,z)),(l.current||i.current)&&(_(),l.current=!1)),p.current=L},[L,z,s,_]);const I=n==null?void 0:n.turns.at(-1),M=(I==null?void 0:I.toolCalls.length)??0,F=(I==null?void 0:I.assistantText.length)??0;y.useEffect(()=>{if(!n||!e)return;if(i.current){const D=o.current;D&&(D.scrollTop=D.scrollHeight,f.current=D.scrollTop,m.current=D.scrollHeight)}const O=requestAnimationFrame(E);return()=>cancelAnimationFrame(O)},[L,M,F,e,E]);const U=v===r;return y.useMemo(()=>({chatScrollRef:o,observeChatContent:$,canScrollDown:b,initialScrollDone:U,handleScroll:A,scrollToBottomInstant:N,requestScrollToTop:S,resetTurnCount:R}),[$,b,U,A,N,S,R])}async function k7(n,e,t,s,{background:r=!1}={}){const o=await Ce(`/api/sessions/${encodeURIComponent(n)}/${encodeURIComponent(e)}?tail=30`,{background:r});if(!o.ok)throw new Error(`Failed to load ${s} (${o.status})`);const i=await o.json(),l=new Set(i.headerLines),c=i.tailLines.filter(f=>!l.has(f)),u=[...i.headerLines,...c].join(`
485
485
  `);return{parsed:ra(await t(u),Yr(n).instanceId),source:{dirName:n,fileName:e,rawText:u,agentKind:un(n),watchOffset:i.totalSize},byteOffset:i.byteOffset,hasMore:i.hasMore}}async function Sa(n,e,t,s,r={}){const o=js.get(n,e);if(o)return{parsed:o.parsed,source:o.source};const i=cn(),l=Zn(),{parsed:c,source:u,byteOffset:d,hasMore:f}=await k7(n,e,t,s,r);if(cn()!==i||Zn()!==l)return{parsed:c,source:u};const m=js.get(n,e);return m?{parsed:m.parsed,source:m.source}:(js.set(n,e,c,u.rawText,d,f,u.agentKind,u.watchOffset),{parsed:c,source:u})}async function j7(n,e,t,s){js.evict(n,e);const r=cn(),o=Zn(),{parsed:i,source:l,byteOffset:c,hasMore:u}=await k7(n,e,t,s);return cn()===r&&Zn()===o&&js.set(n,e,i,l.rawText,c,u,l.agentKind,l.watchOffset),{parsed:i,source:l}}function Ebe({dispatch:n,isMobile:e,mobileTab:t="sessions",teamContext:s,scrollToBottomInstant:r,resetTurnCount:o,workerParse:i,onBeforeSwitch:l}){const[c,u]=y.useState(null),d=y.useCallback((w,v)=>{u(null),y.startTransition(()=>{n({type:"LOAD_SESSION",session:w,source:v,isMobile:e})}),o(w.turns.length),Uxe(w.sessionId,w.turns.length),r()},[n,e,o,r]),f=y.useCallback(async(w,v)=>{l==null||l(),u(null);try{const{parsed:j,source:k}=await Sa(w,v,i,"session");d(j,k)}catch(j){u(j instanceof Error?j.message:"Failed to load session")}},[d,i,l]),m=y.useCallback(async w=>{if(s){l==null||l(),u(null),n({type:"SET_LOADING_MEMBER",name:w.name});try{const v=await Ce(`/api/team-member-session/${encodeURIComponent(s.teamName)}/${encodeURIComponent(w.name)}`);if(!v.ok)throw new Error(`Failed to find session for ${w.name}`);const{dirName:j,fileName:k}=await v.json(),{parsed:_,source:N}=await Sa(j,k,i,`session for ${w.name}`);y.startTransition(()=>{n({type:"SWITCH_TEAM_MEMBER",session:_,source:N,memberName:w.name})}),o(_.turns.length),r()}catch(v){u(v instanceof Error?v.message:"Failed to switch team member")}finally{n({type:"SET_LOADING_MEMBER",name:null})}}},[n,s,o,r,i,l]),p=y.useCallback(()=>u(null),[]),h=y.useCallback(()=>{y.startTransition(()=>{n({type:"GO_HOME",isMobile:e})})},[n,e]),g=y.useCallback(()=>{y.startTransition(()=>{n({type:"CLOSE_SESSION",isMobile:e})})},[n,e]),x=y.useCallback((w,v)=>{n({type:"JUMP_TO_TURN",index:w,toolCallId:v})},[n]),b=y.useCallback(w=>{w!==t&&n({type:"SET_MOBILE_TAB",tab:w})},[n,t]);return{loadError:c,clearLoadError:p,handleLoadSession:d,handleDashboardSelect:f,handleTeamMemberSwitch:m,handleGoHome:h,handleCloseSession:g,handleJumpToTurn:x,handleMobileTabChange:b}}const Tbe=/^\/preview\/([^/]+)\/?$/;function ov(n){const e=Tbe.exec(n);if(!e)return null;try{const t=decodeURIComponent(e[1]);return t.length>0?t:null}catch{return null}}function H1(){const n=Nx();return n?`${n}/`:"/"}function N7(n){const e=/^\/d\/[^/]+(\/.*)?$/.exec(n);return e?e[1]||"/":n}function Abe(n,e){return aR(n,e)}function Ibe(n){const e=Nx();return n.sessionSource?pa(n.sessionSource.dirName,n.sessionSource.fileName):n.pendingDirName?`${e}/${encodeURIComponent(n.pendingDirName)}`:n.dashboardProject?`${e}/${encodeURIComponent(n.dashboardProject)}`:H1()}function qj(n){const e=N7(n),t=ov(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 Pbe({state:n,dispatch:e,isMobile:t,resetTurnCount:s,scrollToBottomInstant:r,workerParse:o}){const[i,l]=y.useState(null),c=y.useRef(0),u=y.useRef(window.location.pathname),d=y.useRef(!1),f=y.useCallback(async m=>{c.current++;try{if(m.type==="preview"&&m.sessionId){l(null);try{const p=await Ce(`/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 Sa(h.dirName,h.fileName,o,"session preview");e({type:"LOAD_SESSION",session:g.parsed,source:g.source,isMobile:t}),s(g.parsed.turns.length),r()}catch(p){e({type:"GO_HOME",isMobile:t}),l(p instanceof Error?p.message:"Failed to load session preview.")}}else if(m.type==="session"&&m.dirName&&m.sessionId){l(null);const p=Abe(m.dirName,m.sessionId);let h;try{h=await Sa(m.dirName,p,o,"session")}catch{e({type:"GO_HOME",isMobile:t});const g=H1();window.history.replaceState(null,"",g),u.current=g,Va(Kt(),g);return}e({type:"LOAD_SESSION",session:h.parsed,source:h.source,isMobile:t}),s(h.parsed.turns.length),r()}else if(m.type==="project"&&m.dirName)l(null),e({type:"SET_DASHBOARD_PROJECT",dirName:m.dirName});else if(l(null),e({type:"GO_HOME",isMobile:t}),m.normalizeHome){const p=H1();window.history.replaceState(null,"",p),u.current=p,Va(Kt(),p)}}finally{c.current--}},[e,t,s,r,o]);return y.useEffect(()=>{if(d.current)return;d.current=!0,Va(Kt(),window.location.pathname);const m=qj(window.location.pathname);(m.type!=="home"||m.normalizeHome)&&f(m)},[f]),y.useEffect(()=>{if(c.current>0||ov(N7(window.location.pathname)))return;const m=Ibe(n);m!==u.current&&(window.history.pushState(null,"",m),u.current=m,Va(Kt(),m))},[n.sessionSource,n.pendingDirName,n.mainView,n.dashboardProject]),y.useEffect(()=>{const m=()=>{const p=qj(window.location.pathname);u.current=window.location.pathname,Va(Kt(),window.location.pathname),f(p)};return window.addEventListener("popstate",m),()=>window.removeEventListener("popstate",m)},[f]),{previewLoadError:i}}const $be=400;function Vj(){return Array.from(document.querySelectorAll("[data-live-session]"))}function Rbe(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 Hj(n){n.focus({preventScroll:!0});const e=Rbe(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 Obe(n){const e=V.c(20),{isMobile:t,searchInputRef:s,chatInputRef:r,dispatch:o,onToggleSidebar:i,onToggleRightSidebar:l,onToggleMissionControl:c,onOpenCommandPalette:u,onOpenProjectSwitcher:d,onOpenThemeSelector:f,onOpenTerminal:m,onToggleIntegratedTerminal:p,onTogglePreview:h,onToggleProjectFiles:g,onHistoryBack:x,onHistoryForward:b,onNavigateToSession:w,onCommitNavigation:v}=n;let j,k;e[0]!==r||e[1]!==o||e[2]!==t||e[3]!==v||e[4]!==x||e[5]!==b||e[6]!==w||e[7]!==u||e[8]!==d||e[9]!==m||e[10]!==f||e[11]!==p||e[12]!==c||e[13]!==h||e[14]!==g||e[15]!==l||e[16]!==i||e[17]!==s?(j=()=>{if(t)return;let _=!1,N=!1,S=null;const C=function(A){var L,I;const R=ej("missionControl");if(R){if(A.key===R){A.repeat||(_=!0,N=A.shiftKey||A.altKey||(R==="Meta"?A.ctrlKey:A.metaKey));return}_&&(N=!0),S=null}if(on("commandPalette",A)){A.preventDefault(),u==null||u();return}if(on("integratedTerminal",A)){if(!xt("terminal"))return;A.preventDefault(),p();return}if(on("preview",A)){A.preventDefault(),h();return}if(on("projectFiles",A)){if(!xt("hostFiles"))return;A.preventDefault(),g();return}if(on("expandAll",A)){A.preventDefault(),o({type:"SET_EXPAND_ALL",value:!0});return}if(on("expandToolPayloads",A)){A.preventDefault(),o({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0});return}if(on("toggleSidebar",A)){A.preventDefault(),i();return}if(on("toggleStats",A)){A.preventDefault(),l();return}if(on("missionControl",A)){A.preventDefault(),c();return}if(on("newSession",A)&&(A.preventDefault(),d()),on("themeSelector",A)&&(A.preventDefault(),f()),on("systemTerminal",A)){if(!xt("terminal"))return;A.preventDefault(),m()}if(A.key==="Escape"&&(o({type:"SET_SEARCH_QUERY",value:""}),(L=s.current)==null||L.blur()),(A.metaKey||A.ctrlKey)&&A.shiftKey&&A.code.startsWith("Digit")){const M=parseInt(A.code.charAt(5),10);if(M>=1&&M<=9){A.preventDefault();const U=Vj()[M-1];U&&(Hj(U),U.click())}}const P=on("recentSessionForward",A);if(P||on("recentSessionBack",A)){A.preventDefault();const M=P?b():x();M&&w(M.dirName,M.fileName)}on("focusComposer",A)&&!wI(document.activeElement)&&(A.preventDefault(),(I=r.current)==null||I.focus());const z=on("nextLiveSession",A);if(z||on("prevLiveSession",A)){A.preventDefault();const M=Vj();if(M.length===0)return;const F=M.findIndex(Lbe);let U;F===-1?U=z?0:M.length-1:U=Math.max(0,Math.min(M.length-1,F+(z?1:-1))),Hj(M[U])}},E=function(A){const R=ej("missionControl");if(R&&A.key===R&&_){const P=!N;if(_=!1,N=!1,P){const z=Date.now();S!==null&&z-S<=$be?(S=null,A.preventDefault(),c()):S=z}else S=null}A.key==="Control"&&(v==null||v())},T=function(){_=!1,N=!1,S=null};return window.addEventListener("keydown",C),window.addEventListener("keyup",E),window.addEventListener("blur",T),()=>{window.removeEventListener("keydown",C),window.removeEventListener("keyup",E),window.removeEventListener("blur",T)}},k=[t,s,r,o,i,l,c,u,d,f,m,p,h,g,x,b,w,v],e[0]=r,e[1]=o,e[2]=t,e[3]=v,e[4]=x,e[5]=b,e[6]=w,e[7]=u,e[8]=d,e[9]=m,e[10]=f,e[11]=p,e[12]=c,e[13]=h,e[14]=g,e[15]=l,e[16]=i,e[17]=s,e[18]=j,e[19]=k):(j=e[18],k=e[19]),y.useEffect(j,k)}function Lbe(n){return n===document.activeElement}function C7(){const n=V.c(7),[e,t]=y.useState(GL),[s,r]=y.useState(null);let o;n[0]===Symbol.for("react.memo_cache_sentinel")?(o=f=>{ZL(f),t(f),r(null)},n[0]=o):o=n[0];const i=o,l=s??e;let c,u;n[1]!==l?(c=()=>YL(l),u=[l],n[1]=l,n[2]=c,n[3]=u):(c=n[2],u=n[3]),y.useEffect(c,u);let d;return n[4]!==l||n[5]!==e?(d={theme:e,activeTheme:l,setTheme:i,setPreview:r},n[4]=l,n[5]=e,n[6]=d):d=n[6],d}const Mbe="cogpit-session-history",K1=50;function _7(){return sn(Mbe)}function zbe(){try{const n=localStorage.getItem(_7());if(!n)return[];const e=JSON.parse(n);if(Array.isArray(e))return e.slice(0,K1)}catch{}return[]}function ug(n){try{localStorage.setItem(_7(),JSON.stringify(n))}catch{}}function Dbe(){const n=V.c(7);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=zbe(),n[0]=e):e=n[0];const t=y.useRef(e),s=y.useRef(0),r=y.useRef(!1);let o;n[1]===Symbol.for("react.memo_cache_sentinel")?(o=(x,b)=>{if(r.current){r.current=!1;return}const w=`${x}/${b}`;t.current=t.current.filter(v=>`${v.dirName}/${v.fileName}`!==w),t.current.unshift({dirName:x,fileName:b}),t.current.length>K1&&(t.current.length=K1),s.current=0,ug(t.current)},n[1]=o):o=n[1];const i=o;let l;n[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{if(t.current.length<=1)return null;const x=(s.current+1)%t.current.length;return s.current=x,r.current=!0,t.current[x]},n[2]=l):l=n[2];const c=l;let u;n[3]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{if(t.current.length<=1)return null;const x=(s.current-1+t.current.length)%t.current.length;return s.current=x,r.current=!0,t.current[x]},n[3]=u):u=n[3];const d=u;let f;n[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{if(s.current===0){r.current=!1;return}const x=t.current[s.current];x&&(t.current.splice(s.current,1),t.current.unshift(x),ug(t.current)),s.current=0,r.current=!1},n[4]=f):f=n[4];const m=f;let p;n[5]===Symbol.for("react.memo_cache_sentinel")?(p=x=>{const b=t.current.filter(w=>kx(w.dirName,w.fileName)!==x);b.length!==t.current.length&&(t.current=b,s.current=0,ug(b))},n[5]=p):p=n[5];const h=p;let g;return n[6]===Symbol.for("react.memo_cache_sentinel")?(g={push:i,goBack:c,goForward:d,commitNavigation:m,forget:h},n[6]=g):g=n[6],g}const Fbe="You no longer have access to this session",Ube="You don't have access to this session";function Bbe(n){const e=V.c(7),{openSessionId:t,leave:s,forgetVisits:r}=n,{removeSession:o}=Vx();let i,l;e[0]!==r||e[1]!==s||e[2]!==t||e[3]!==o?(i=()=>{const u=function(p){js.evictSession(p),U9(p),cO(p),o(p),r(p),BN(),p===t&&s()},d=kR((m,p)=>{const h=oO(m)?Fbe:Ube;u(m),!(p&&m!==t)&&NR(m).then(g=>{g||Kn.error(h,{id:`session-access-lost:${m}`})})}),f=CR(u);return()=>{d(),f()}},l=[t,s,r,o],e[0]=r,e[1]=s,e[2]=t,e[3]=o,e[4]=i,e[5]=l):(i=e[4],l=e[5]),y.useEffect(i,l);let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[6]=c):c=e[6],y.useEffect(Wbe,c)}function Wbe(){return lN(qbe)}function qbe(){return BN()}const Kj={mode:"bypassPermissions",allowedTools:[],disallowedTools:[]},Vbe="cogpit:permissions";function E7(){return sn(Vbe)}function Gj(){try{const n=localStorage.getItem(E7());if(n){const e=JSON.parse(n);return{mode:e.mode||Kj.mode,allowedTools:Array.isArray(e.allowedTools)?e.allowedTools:[],disallowedTools:Array.isArray(e.disallowedTools)?e.disallowedTools:[]}}}catch{}return Kj}function Hbe(n){localStorage.setItem(E7(),JSON.stringify(n))}function T7(n,e){const t=x5(n);return(t.find(s=>s.value===e)??t[0]).value}function Zj(n,e){return{...e,mode:T7(n,e.mode),...!bn(n).toolPermissionRules&&{allowedTools:[],disallowedTools:[]}}}function Kbe(n){const e=V.c(25),t=n===void 0?Wo:n,[s,r]=y.useState(Gj),[o,i]=y.useState(Gj);let l;e[0]!==t||e[1]!==s?(l=Zj(t,s),e[0]=t,e[1]=s,e[2]=l):l=e[2];const c=l;let u;e[3]!==t||e[4]!==o?(u=Zj(t,o),e[3]=t,e[4]=o,e[5]=u):u=e[5];const d=u,f=y.useRef(!0);let m,p;e[6]!==s?(m=()=>{if(f.current){f.current=!1;return}Hbe(s)},p=[s],e[6]=s,e[7]=m,e[8]=p):(m=e[7],p=e[8]),y.useEffect(m,p);let h;e[9]!==d.allowedTools||e[10]!==d.disallowedTools||e[11]!==d.mode||e[12]!==c.allowedTools||e[13]!==c.disallowedTools||e[14]!==c.mode?(h=c.mode!==d.mode||JSON.stringify(c.allowedTools)!==JSON.stringify(d.allowedTools)||JSON.stringify(c.disallowedTools)!==JSON.stringify(d.disallowedTools),e[9]=d.allowedTools,e[10]=d.disallowedTools,e[11]=d.mode,e[12]=c.allowedTools,e[13]=c.disallowedTools,e[14]=c.mode,e[15]=h):h=e[15];const g=h;let x;e[16]!==t?(x=k=>{r(_=>({..._,mode:T7(t,k)}))},e[16]=t,e[17]=x):x=e[17];const b=x;let w;e[18]!==c?(w=()=>{i(c)},e[18]=c,e[19]=w):w=e[19];const v=w;let j;return e[20]!==c||e[21]!==g||e[22]!==v||e[23]!==b?(j={config:c,hasPendingChanges:g,setMode:b,markApplied:v},e[20]=c,e[21]=g,e[22]=v,e[23]=b,e[24]=j):j=e[24],j}const Gbe=2e3;function Zbe(n,e){return n.length!==e.length?!1:JSON.stringify(n)===JSON.stringify(e)}function Ybe(n){const[e,t]=y.useState([]),[s,r]=y.useState(null),[o,i]=y.useState(new Set);y.useEffect(()=>{if(!n){t([]),r(null);return}let u=!1;const d=async()=>{if(!u)try{const h=await Ce(`/api/permissions/${encodeURIComponent(n)}`);if(u)return;if(h.ok){const g=await h.json();if(u)return;t(b=>Zbe(b,g.permissions)?b:g.permissions);const x=g.plan?{type:"plan",provider:"copilot",...g.plan}:null;r(b=>JSON.stringify(b)===JSON.stringify(x)?b:x)}}catch{}},f=()=>{(typeof document>"u"||document.visibilityState==="visible")&&d()},m=()=>{document.visibilityState==="visible"&&d()};f();const p=setInterval(f,Gbe);return document.addEventListener("visibilitychange",m),()=>{u=!0,clearInterval(p),document.removeEventListener("visibilitychange",m)}},[n]);const l=y.useCallback(async(u,d)=>{if(n){i(f=>new Set(f).add(u));try{await PI(n,u,d)&&t(f=>f.filter(m=>m.requestId!==u))}finally{i(f=>{const m=new Set(f);return m.delete(u),m})}}},[n]),c=y.useCallback(async u=>{if(n)try{await fpe(n,u)&&t([])}catch{}},[n]);return{requests:e,plan:s,responding:o,respond:l,respondAll:c}}async function Xbe(n,e){const t=await is(`/api/copilot-history/${encodeURIComponent(n)}/preview`,{eventId:e});return t.ok?await t.json():null}async function Jbe(n,e,t){const s=await is(`/api/copilot-history/${encodeURIComponent(n)}/rewind`,{eventId:e,mode:t}),r=await s.json().catch(()=>null);return!s.ok||(r==null?void 0:r.outcome)!=="success"?{ok:!1,error:(r==null?void 0:r.error)||`Copilot rewind failed${r!=null&&r.outcome?`: ${r.outcome}`:""}`}:{ok:!0}}function Qbe(n){return n.file_path??n.path??""}function A7(n){const e=[];for(const t of n.toolCalls){if(t.isError||t.awaitingReview||vde(t))continue;const s=Qbe(t.input);if(s){if(t.name==="Edit"){const r=t.input.old_string,o=t.input.new_string;r!==void 0&&o!==void 0&&e.push({type:"Edit",filePath:s,oldString:r,newString:o,replaceAll:t.input.replace_all??!1})}else if(t.name==="Write"){const r=t.input.content;r!==void 0&&e.push({type:"Write",filePath:s,content:r})}}}return e}function eve(n,e){return{index:e,id:n.id,userMessage:za(n.userMessage),toolCalls:A7(n),thinkingBlocks:n.thinking.map(t=>t.thinking),assistantText:[...n.assistantText],timestamp:n.timestamp,model:n.model}}function vf(n,e,t){const s=[];for(let r=e;r>t;r--){const o=n[r];if(!o)continue;const i=A7(o);for(let l=i.length-1;l>=0;l--){const c=i[l];c&&(c.type==="Edit"?s.push({type:"reverse-edit",filePath:c.filePath,oldString:c.newString,newString:c.oldString,replaceAll:c.replaceAll,turnIndex:r}):c.type==="Write"&&s.push({type:"delete-write",filePath:c.filePath,content:c.content,turnIndex:r}))}}return s}function tve(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 Bl(n,e){const t=[],s=e!==void 0?e+1:n.length;for(let r=0;r<s;r++){const o=n[r];o&&t.push(...tve(o.toolCalls,o.index))}return t}function I7(n,e,t,s,r){var c;const o=[];for(let u=e+1;u<n.length;u++){const d=n[u];d&&o.push(eve(d,u))}const i=((c=o[0])==null?void 0:c.userMessage)||"Untitled branch",l=i.length>60?i.slice(0,57)+"...":i;return{id:crypto.randomUUID(),createdAt:new Date().toISOString(),branchPointTurnIndex:e,...r!==void 0?{branchPointTurnId:r}:{},label:l,turns:o,jsonlLines:t,...s&&s.length>0?{childBranches:s}:{}}}const nve=-2;function sve(n,e){const t=new Map(e.map((o,i)=>[o.id,i]));let s=!1;const r=n.map(o=>{const{branchPointTurnId:i}=o;if(i===void 0)return o;const l=i===null?-1:t.get(i)??nve;return l===o.branchPointTurnIndex?o:(s=!0,{...o,branchPointTurnIndex:l})});return s?r:n}function rve(n){return(n.childBranches??[]).map(e=>{if(typeof e.branchPointTurnId!="string")return e;const t=n.turns.findIndex(s=>s.id===e.branchPointTurnId);return t<0?e:{...e,branchPointTurnIndex:n.branchPointTurnIndex+1+t}})}function P7(n,e){const t=[],s=[];for(const r of n)r.branchPointTurnIndex>e?s.push(r):t.push(r);return{retained:t,scooped:s}}function ove(n,e,t){const s=e+t,r=[],o=[];for(const i of n)i.branchPointTurnIndex<=s?r.push(i):o.push(i);return{restored:r,remaining:o}}function ive(n){const e=new Set(n.map(t=>t.filePath));return{fileCount:e.size,filePaths:[...e],operationCount:n.length}}function ave(n){return{sessionId:n,branches:[],activeBranchId:null}}function Xu(n,e){return{...ive(n),turnCount:e}}function lve(n,e,t){return s6(e6(un(t)),n,e)}function cve(n,e,t,s,r,o){var c,u;const i=e6(un(o)),l=Lse(i,n);if(l){const d=e?l.findLastIndex(m=>m.id===e.id):-1;if(d>=0)return{cutoffLine:((c=l[d+1])==null?void 0:c.line)??n.length,branchPointTurnId:l[d].id};const f=t?l.findIndex(m=>m.id===t.id):-1;if(f>=0)return{cutoffLine:l[f].line,branchPointTurnId:((u=l[f-1])==null?void 0:u.id)??null}}return bb(i,n).length>r?null:{cutoffLine:s6(i,n,s),branchPointTurnId:void 0}}class Hi extends Error{constructor(){super("abort")}}const $7="Unable to locate the selected turn in the current session file";function R7(n,e,t,s,r){const o=cve(t,n.turns[s-1],n.turns[s],s,n.turns.length,e.dirName);if(!o)throw r($7),new Hi;return o}async function uve(n,e,t,s,r,o,i){var v;const l=n.targetTurnIndex,c=vf(e.turns,e.turns.length-1,l),u=l+1,d=r.split(`
@@ -489,7 +489,7 @@ ${fe}
489
489
  `).filter(Boolean).length},state:h})}const mve=[];function L7(n,e,t,s=!0){const[r,o]=y.useState(null),[i,l]=y.useState(null),[c,u]=y.useState(!1),[d,f]=y.useState(null),m=y.useRef(null),p=y.useRef(0);y.useEffect(()=>{if(p.current+=1,!s||!n){o(null),l(null),f(null),m.current=null;return}if(n.sessionId===m.current)return;if(m.current=n.sessionId,!oa(e==null?void 0:e.dirName).redo){o(null);return}const A=n.sessionId,R=new AbortController;return Ce(`/api/undo-state/${encodeURIComponent(A)}`,{signal:R.signal}).then(P=>P.ok?P.json():null).then(P=>{m.current===A&&o(P??null)}).catch(P=>{P instanceof Error&&P.name==="AbortError"||m.current===A&&o(null)}),()=>R.abort()},[s,n==null?void 0:n.sessionId]);const h=y.useCallback(async A=>{try{const R=await Ce("/api/undo/transaction",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({operations:A.operations,session:{dirName:A.sessionSource.dirName,fileName:A.sessionSource.fileName,mutation:A.sessionMutation},state:A.state,checkpoint:A.checkpoint})}),P=await R.json().catch(()=>null);if(!R.ok)throw f((P==null?void 0:P.error)||"Undo transaction failed"),new Hi;o(A.state)}catch(R){throw R instanceof Hi?R:(f(String(R)),new Hi)}},[]),g=(r==null?void 0:r.branches)??mve,x=n==null?void 0:n.turns,b=y.useMemo(()=>x?sve(g,x):g,[g,x]),{canRedo:w,redoTurnCount:v,redoBranch:j}=y.useMemo(()=>{if(!n||b.length===0)return{canRedo:!1,redoTurnCount:0,redoBranch:null};for(let A=b.length-1;A>=0;A--){const R=b[A];if(R.branchPointTurnIndex+1===n.turns.length)return{canRedo:!0,redoTurnCount:R.turns.length,redoBranch:R}}return{canRedo:!1,redoTurnCount:0,redoBranch:null}},[n,b]),k=y.useMemo(()=>{if(!j||j.jsonlLines.length===0)return[];try{return xm(j.jsonlLines.join(`
490
490
  `)).turns}catch{return[]}},[j]),_=y.useCallback(A=>b.filter(R=>R.branchPointTurnIndex===A),[b]),N=y.useCallback(A=>{if(!s||!n)return;const R=A-1;if(R>=n.turns.length-1||R<-1)return;if(oa(e==null?void 0:e.dirName).nativeRewind){const z=n.turns[A];if(!z)return;const L=n.sessionId,I=++p.current,M=()=>p.current===I&&m.current===L,F=z.id.includes("@")?z.id.slice(z.id.lastIndexOf("@")+1):z.id,U=n.turns.length-A;Xbe(n.sessionId,F).then(O=>{var q;if(!M())return;const D=((q=O==null?void 0:O.files)==null?void 0:q.map(({path:W})=>W).filter(W=>typeof W=="string"))??[],B=O!=null&&O.available?O.fileCount??D.length:0;l({type:"undo",summary:{turnCount:U,fileCount:B,filePaths:D,operationCount:B},targetTurnIndex:R,nativeRewind:{eventId:F,mode:"conversation",filesAvailable:!!(O!=null&&O.available&&B>0)}})}).catch(()=>{M()&&l({type:"undo",summary:{turnCount:U,fileCount:0,filePaths:[],operationCount:0},targetTurnIndex:R,nativeRewind:{eventId:F,mode:"conversation"}})});return}const P=vf(n.turns,n.turns.length-1,R);l({type:"undo",summary:Xu(P,n.turns.length-1-R),targetTurnIndex:R})},[s,n,e==null?void 0:e.dirName]),S=y.useCallback(()=>{if(!s||!w||!j||!n)return;const A=Bl(j.turns);l({type:"redo",summary:Xu(A,j.turns.length),targetTurnIndex:j.branchPointTurnIndex+j.turns.length,branchId:j.id})},[s,w,j,n]),C=y.useCallback(A=>{if(!s||!w||!j||!n)return;const R=A+1,P=Bl(j.turns,A);l({type:"redo",summary:Xu(P,R),targetTurnIndex:j.branchPointTurnIndex+R,branchId:j.id,redoUpToArchiveIndex:A})},[s,w,j,n]),E=y.useCallback((A,R)=>{if(!s||!n)return;const P=b.find(M=>M.id===A);if(!P)return;const z=R??P.turns.length-1,L=n.turns.length>P.branchPointTurnIndex+1?vf(n.turns,n.turns.length-1,P.branchPointTurnIndex):[],I=Bl(P.turns,z);l({type:"branch-switch",summary:Xu([...L,...I],z+1),targetTurnIndex:P.branchPointTurnIndex,branchId:A,branchTurnIndex:z})},[s,n,b]),T=y.useCallback(async(A=!1)=>{if(!s||!i||!n||!e){l(null);return}u(!0),f(null);try{if(i.nativeRewind){const L=A&&i.nativeRewind.filesAvailable?"conversation-and-files":"conversation",I=await Jbe(n.sessionId,i.nativeRewind.eventId,L);if(!I.ok){f(I.error);return}await t(),l(null);return}const R={...r??ave(n.sessionId),branches:b},P=await Ce(`/api/sessions/${encodeURIComponent(e.dirName)}/${encodeURIComponent(e.fileName)}`);if(!P.ok){f("Failed to read session file");return}const z=await P.text();if(i.type==="undo")await uve(i,n,e,R,z,h,f);else if(i.type==="redo"){const L=b.find(I=>I.id===i.branchId);if(!L){l(null);return}await dve(i,e,R,L,z,h)}else if(i.type==="branch-switch"){const L=b.find(I=>I.id===i.branchId);if(!L){l(null);return}await fve(n,e,R,L,z,i,h,f)}try{await Ce("/api/stop-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:n.sessionId})})}catch{}await t(),l(null)}catch(R){if(!(R instanceof Hi))throw R}finally{u(!1)}},[s,i,n,e,r,b,h,t]),$=y.useCallback(()=>{p.current+=1,l(null),f(null)},[]);return{enabled:s,undoState:r,canRedo:w,redoTurnCount:v,redoGhostTurns:k,branches:b,branchesAtTurn:_,requestUndo:N,requestRedoAll:S,requestRedoUpTo:C,requestBranchSwitch:E,confirmState:i,confirmApply:T,confirmCancel:$,isApplying:c,applyError:d}}async function pve(n){try{const t=await(await Ur("/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 hve(n){const e=await Ce("/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:oR(t==null?void 0:t.mode,Wo),useBuiltInEditor:(t==null?void 0:t.useBuiltInEditor)===!0}}function gve(){const n=V.c(26),[e,t]=y.useState(!0),[s,r]=y.useState(null),[o,i]=y.useState(null),[l,c]=y.useState(Wo),[u,d]=y.useState(!1),[f,m]=y.useState(null),[p,h]=y.useState(!1),[g,x]=y.useState(0),b=y.useRef(null);let w;n[0]===Symbol.for("react.memo_cache_sentinel")?(w=D=>{i(D.claudeDir),c(D.defaultAgentKind),Vse(D.useBuiltInEditor)},n[0]=w):w=n[0];const v=w;let j;n[1]===Symbol.for("react.memo_cache_sentinel")?(j=async()=>{var q;(q=b.current)==null||q.abort();const D=new AbortController;b.current=D;const B=await pve(D.signal);D.signal.aborted||b.current!==D||(m(B.url),h(B.disabled))},n[1]=j):j=n[1];const k=j;let _,N;n[2]===Symbol.for("react.memo_cache_sentinel")?(_=()=>()=>{var D;(D=b.current)==null||D.abort()},N=[],n[2]=_,n[3]=N):(_=n[2],N=n[3]),y.useEffect(_,N);let S;n[4]===Symbol.for("react.memo_cache_sentinel")?(S=()=>{const D=new AbortController;return t(!0),r(null),hve(D.signal).then(v).catch(B=>{B instanceof Error&&B.name==="AbortError"||(i(null),r(B instanceof Error?B.message:"Failed to load configuration"))}).finally(()=>{D.signal.aborted||t(!1)}),()=>D.abort()},n[4]=S):S=n[4];let C;n[5]!==g?(C=[v,g],n[5]=g,n[6]=C):C=n[6],y.useEffect(S,C);let E,T;n[7]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{const D=()=>x(vve);return window.addEventListener("cogpit-auth-changed",D),()=>window.removeEventListener("cogpit-auth-changed",D)},T=[],n[7]=E,n[8]=T):(E=n[7],T=n[8]),y.useEffect(E,T);let $;n[9]===Symbol.for("react.memo_cache_sentinel")?($=()=>{k()},n[9]=$):$=n[9];let A;n[10]!==o?(A=[o,k],n[10]=o,n[11]=A):A=n[11],y.useEffect($,A);let R;n[12]===Symbol.for("react.memo_cache_sentinel")?(R=()=>d(!1),n[12]=R):R=n[12];const P=R;let z;n[13]!==o?(z=D=>{if(d(!1),D!==o){i(D),window.location.reload();return}x(bve),k()},n[13]=o,n[14]=z):z=n[14];const L=z;let I;n[15]===Symbol.for("react.memo_cache_sentinel")?(I=()=>d(!0),n[15]=I):I=n[15];const M=I;let F;n[16]===Symbol.for("react.memo_cache_sentinel")?(F=()=>x(xve),n[16]=F):F=n[16];const U=F;let O;return n[17]!==o||n[18]!==s||n[19]!==e||n[20]!==l||n[21]!==L||n[22]!==p||n[23]!==f||n[24]!==u?(O={configLoading:e,configError:s,claudeDir:o,defaultAgentKind:l,setClaudeDir:i,showConfigDialog:u,openConfigDialog:M,handleCloseConfigDialog:P,handleConfigSaved:L,retryConfig:U,networkUrl:f,networkAccessDisabled:p},n[17]=o,n[18]=s,n[19]=e,n[20]=l,n[21]=L,n[22]=p,n[23]=f,n[24]=u,n[25]=O):O=n[25],O}function xve(n){return n+1}function bve(n){return n+1}function vve(n){return n+1}const Yj={authenticated:!0,edition:"personal",user:null,capabilities:_x},yd={authenticated:!1,edition:null,user:null,capabilities:Ea,checked:!1},yve=Object.keys(_x);function Xj(n,e){return n!==null&&n.edition===e&&n.authenticated&&(e==="personal"?n.user===null:n.user!==null)&&yve.every(t=>{var s;return typeof((s=n.capabilities)==null?void 0:s[t])=="boolean"})}function wve(n,e){const t={};for(const[s,r]of Object.entries(e))t[s]=r===!0&&n[s]!==!1;return{...Ea,...t}}function Sve(n){const e=n==null?void 0:n.capabilities;return!n||!e||typeof e.browser=="boolean"?n:{...n,capabilities:{...e,browser:e.hostFiles===!0}}}async function Jj(n,e){try{const t=await n("/api/me",{signal:e});return t.ok?Sve(await t.json()):null}catch{return null}}async function kve(n){try{const e=await Ce("/api/hello",{signal:n});if(!e.ok)return null;const t=await e.json();return eN(t.edition)?t.edition:"personal"}catch{return null}}function zi(n,e){return Cl(n,e),uR((e==null?void 0:e.id)??null),n?{...n,checked:!0}:yd}function jve(n){const e=V.c(11),[t,s]=y.useState(yd),[r,o]=y.useState(0),i=y.useRef(null),l=y.useRef(!1);let c;e[0]!==n?(c=()=>{var N;if((N=i.current)==null||N.abort(),n===null){l.current=!1,Cl(null),s(yd);return}const b=l.current;l.current=!1,Cl(null),s(S=>b?{...S,capabilities:Ea,checked:!1}:yd);const w=new AbortController;i.current=w;const v=qo(),j=Jj(Ur,w.signal),k=v?kve(w.signal):Promise.resolve(n),_=v?Jj(Ce,w.signal):Promise.resolve(null);return Promise.all([j,k,_]).then(S=>{const[C,E,T]=S;if(w.signal.aborted)return;const $=Xj(C,n)?C:n==="personal"?Yj:null;if(v&&($!=null&&$.gate)){Xs(Lt);return}if(!$||E===null){s(zi(null,null));return}if(!v){s(zi($,$.user));return}const A=Xj(T,E)?T:E==="personal"?Yj:null;if(!A){s(zi(null,null));return}s(zi({authenticated:A.authenticated,edition:A.edition,user:A.user,capabilities:wve($.capabilities,A.capabilities),...A.enforcesSessionAccess&&{enforcesSessionAccess:!0},...A.gate&&{gate:A.gate}},$.user))}).catch(()=>{w.signal.aborted||s(zi(null,null))}),()=>{w.abort(),i.current===w&&(i.current=null)}},e[0]=n,e[1]=c):c=e[1];let u;e[2]!==n||e[3]!==r?(u=[n,r],e[2]=n,e[3]=r,e[4]=u):u=e[4],y.useEffect(c,u);let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{var b;(b=i.current)==null||b.abort(),l.current=!0,Cl(null),s(_ve),o(Cve)},e[5]=d):d=e[5];const f=d;let m,p;e[6]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{const b=()=>{var v;(v=i.current)==null||v.abort(),l.current=!1,s(zi(null,null)),o(Nve)},w=v=>{var _;const j=Kt();if(j===Lt)return;const k=(_=v.detail)==null?void 0:_.deviceId;k&&k!==j||f()};return window.addEventListener("cogpit-auth-changed",b),window.addEventListener("cogpit-devices-changed",w),()=>{window.removeEventListener("cogpit-auth-changed",b),window.removeEventListener("cogpit-devices-changed",w)}},p=[f],e[6]=m,e[7]=p):(m=e[6],p=e[7]),y.useEffect(m,p);const h=t.checked&&!t.gate;let g,x;return e[8]!==h?(g=()=>{if(h)return hR(f)},x=[h,f],e[8]=h,e[9]=g,e[10]=x):(g=e[9],x=e[10]),y.useEffect(g,x),t}function Nve(n){return n+1}function Cve(n){return n+1}function _ve(n){return{...n,capabilities:Ea,checked:!1}}const Eve=3e4;function Tve(n){const[e,t]=y.useState(()=>({dirName:n,worktrees:[],loading:n!==null,error:null})),s=y.useRef(0),r=y.useCallback(async()=>{if(!n)return;const i=++s.current;t(l=>l.dirName===n&&l.loading?l:{dirName:n,worktrees:l.dirName===n?l.worktrees:[],loading:!0,error:l.dirName===n?l.error:null});try{const l=await Ce(`/api/worktrees/${encodeURIComponent(n)}`);if(i!==s.current)return;if(l.ok){const c=await l.json();if(i!==s.current)return;t({dirName:n,worktrees:c,loading:!1,error:null});return}t(c=>c.dirName===n?{...c,loading:!1,error:"Failed to fetch worktrees"}:c)}catch(l){if(i!==s.current)return;t(c=>c.dirName===n?{...c,loading:!1,error:l instanceof Error?l.message:"Unknown error"}:c)}},[n]);y.useEffect(()=>{if(!n){s.current+=1;return}r();const i=setInterval(()=>void r(),Eve);return()=>{clearInterval(i),s.current+=1}},[n,r]);const o=e.dirName===n?e:{worktrees:[],loading:n!==null,error:null};return{worktrees:o.worktrees,loading:o.loading,error:o.error,refetch:r}}function Ave(){const n=V.c(3),[e,t]=y.useState(!1);let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=async()=>{t(!0);try{await Ce("/api/kill-all",{method:"POST"})}catch{}setTimeout(()=>t(!1),1500)},n[0]=s):s=n[0];const r=s;let o;return n[1]!==e?(o={killing:e,handleKillAll:r},n[1]=e,n[2]=o):o=n[2],o}function Ive(n,e){return n?`${n}.jsonl`:e??null}async function M7(n){await D7(n);try{const e=await Ce(`/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 Pve=300,Wl=new Map,Sl=new Map;function $ve(n,e,t){const s=(Sl.get(n)??Promise.resolve(!0)).then(async()=>{try{return(await is(`/api/session-config/${encodeURIComponent(e)}`,t,{method:"PUT"})).ok}catch{return!1}});return Sl.set(n,s),s.then(()=>{Sl.get(n)===s&&Sl.delete(n)}),s}function Rve(){let n;return{stored:new Promise(t=>{n=t}),answer:n}}function z7(n,e,t){clearTimeout(t.timer),Wl.delete(n);const s=$ve(n,e,t.patch);return s.then(t.answer),s}async function D7(n){const e=sn(n),t=Wl.get(e);await(t?z7(e,n,t):Sl.get(e))}function G1(n,e){const t=sn(n),s=Wl.get(t);s&&clearTimeout(s.timer);const{stored:r,answer:o}=s??Rve(),i={patch:s?{...s.patch,...e}:e,stored:r,answer:o,timer:setTimeout(()=>{sn(n)===t?z7(t,n,i):(Wl.delete(t),i.answer(!1))},Pve)};return Wl.set(t,i),r}function Z1(n){return new Set(n.filter(e=>e.status==="connected").map(e=>e.name))}async function Qj(n){const e=await M7(n);return Array.isArray(e==null?void 0:e.mcpServers)?e.mcpServers:null}function dg(n,e){G1(n,{mcpServers:e})}async function Ove(n){if(!n.ok)return null;const e=await n.json();return{servers:e.servers??[],configs:e.configs??{}}}async function e4(n,e){try{const t=await Ce(n,{signal:e});if(e.aborted)return null;const s=await Ove(t);return e.aborted?null:s}catch{return null}}async function t4(n,e,t){const s=Z1(t);if(s.size===0)return[];if(n){const r=await Qj(n);if(r)return r.filter(o=>s.has(o))}if(e&&n!==e){const r=await Qj(e);if(r)return r.filter(o=>s.has(o))}return[...s]}function Lve(n,e,t,s=!0){const[r,o]=y.useState([]),[i,l]=y.useState({}),[c,u]=y.useState([]),[d,f]=y.useState(!1),[m,p]=y.useState(!1),h=y.useRef(null),g=y.useRef(e);g.current=e;const x=t??e??null,b=y.useRef(x);b.current=x;const w=y.useRef(void 0);y.useEffect(()=>{var S,C;if(!s||!n){(S=h.current)==null||S.abort(),w.current=void 0,o([]),l({}),u([]),f(!1),p(!1);return}const N=new AbortController;return(C=h.current)==null||C.abort(),o([]),l({}),u([]),f(!0),p(!1),w.current=n,e4(`/api/mcp-servers?cwd=${encodeURIComponent(n)}`,N.signal).then(async E=>{if(N.signal.aborted||w.current!==n||!E)return;o(E.servers),l(E.configs);const T=await t4(b.current,g.current,E.servers);N.signal.aborted||w.current!==n||u(T)}).finally(()=>{N.signal.aborted||w.current!==n||(f(!1),p(!0))}),()=>N.abort()},[n,s]),y.useEffect(()=>()=>{var N;return(N=h.current)==null?void 0:N.abort()},[]),y.useEffect(()=>{if(r.length===0||!x)return;let N=!1;return t4(x,e,r).then(S=>{N||b.current!==x||u(S)}),()=>{N=!0}},[x]);const v=y.useCallback(N=>{u(S=>{const C=S.includes(N)?S.filter(E=>E!==N):[...S,N];return b.current&&dg(b.current,C),C})},[]),j=y.useCallback(N=>{u(()=>(b.current&&dg(b.current,N),N))},[]),k=y.useCallback(()=>{var S;if(!s||!n)return;(S=h.current)==null||S.abort();const N=new AbortController;h.current=N,f(!0),e4(`/api/mcp-servers?cwd=${encodeURIComponent(n)}&refresh=1`,N.signal).then(C=>{if(N.signal.aborted||w.current!==n||!C)return;o(C.servers),l(C.configs);const E=Z1(C.servers);u(T=>{const $=T.filter(A=>E.has(A));return b.current&&dg(b.current,$),$})}).finally(()=>{N.signal.aborted||h.current!==N||f(!1)})},[n,s]),_=y.useMemo(()=>{if(r.length===0)return null;const N=Z1(r);if(c.length===N.size&&N.size>0&&c.every(E=>N.has(E))||!c.every(E=>i[E]))return null;const C=Object.fromEntries(c.map(E=>[E,i[E]]));return JSON.stringify({mcpServers:C})},[c,i,r]);return{servers:r,selectedServers:c,mcpConfigJson:_,loading:d,loaded:m,toggleServer:v,setSelection:j,refresh:k}}function Mve(n){var s,r;const e=V.c(12);let t;e:{if(!n){t=null;break e}let o=null,i;if(e[0]!==o||e[1]!==n.turns){const p=new Map;let h=0;for(const g of n.turns)for(const x of g.toolCalls){if(x.name==="TodoWrite"){const b=x.input;Array.isArray(b.todos)&&(o=b.todos);continue}if(x.name==="TaskCreate"){const b=x.input;h=h+1;const v=((r=(s=x.result)==null?void 0:s.match(/(?:Task\s*#?|task[_ ]?id["': ]+)(\d+)/i))==null?void 0:r[1])??String(h);p.set(v,{id:v,content:b.subject||b.description||`Task ${v}`,activeForm:b.activeForm||b.subject||`Working on task ${v}`,status:"pending",owner:b.owner});continue}if(x.name==="TaskUpdate"){const b=x.input,w=String(b.taskId??"");if(!w)continue;if(b.status==="deleted"){p.delete(w);continue}const v=p.get(w)??{id:w,content:b.subject||b.description||`Task ${w}`,activeForm:b.activeForm||b.subject||`Working on task ${w}`,status:"pending"};p.set(w,{...v,content:b.subject||b.description||v.content,activeForm:b.activeForm||v.activeForm,status:b.status||v.status,owner:b.owner??v.owner,blockedBy:b.addBlockedBy?[...new Set([...v.blockedBy??[],...b.addBlockedBy])]:v.blockedBy})}}i=p.size>0?[...p.values()]:o,e[0]=o,e[1]=n.turns,e[2]=i,e[3]=o}else i=e[2],o=e[3];const l=i;if(!l||l.length===0){t=null;break e}let c;e[4]!==l?(c=l.filter(Dve),e[4]=l,e[5]=c):c=e[5];const u=c.length;let d;e[6]!==l?(d=l.find(zve)??null,e[6]=l,e[7]=d):d=e[7];const f=d;let m;e[8]!==u||e[9]!==f||e[10]!==l?(m={todos:l,completed:u,total:l.length,inProgress:f},e[8]=u,e[9]=f,e[10]=l,e[11]=m):m=e[11],t=m}return t}function zve(n){return n.status==="in_progress"}function Dve(n){return n.status==="completed"}const Fve=[];function Uve(n){const e=V.c(2),[t,s]=y.useState(null);let r;return e[0]!==n?(r=async i=>{if(n)try{const l=await Ce(`/api/background-agents?cwd=${encodeURIComponent(n)}`);if(!l.ok)return;const c=await l.json();if(!i())return;s(u=>(u==null?void 0:u.cwd)===n&&JSON.stringify(u.agents)===JSON.stringify(c)?u:{cwd:n,agents:c})}catch{}},e[0]=n,e[1]=r):r=e[1],Ra(n?r:null,5e3),t&&t.cwd===n?t.agents:Fve}function Bve(n,e){const t=V.c(8),s=e===void 0?!0:e;let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=[],t[0]=r):r=t[0];const[o,i]=y.useState(r),[l,c]=y.useState(!1),u=y.useRef(void 0);let d,f;t[1]!==n||t[2]!==s?(d=()=>{if(!s){u.current=void 0,i([]),c(!1);return}if(u.current===n)return;u.current=n,c(!0);const p=n?`?cwd=${encodeURIComponent(n)}`:"";Ce(`/api/slash-suggestions${p}`).then(Wve).then(h=>i(h.suggestions||[])).catch(()=>i([])).finally(()=>c(!1))},f=[n,s],t[1]=n,t[2]=s,t[3]=d,t[4]=f):(d=t[3],f=t[4]),y.useEffect(d,f);let m;return t[5]!==l||t[6]!==o?(m={suggestions:o,loading:l},t[5]=l,t[6]=o,t[7]=m):m=t[7],m}function Wve(n){return n.json()}function n4(n,e){const t=V.c(6),[s,r]=kr(n,e),o=typeof s=="boolean"?s:e;let i;t[0]!==e||t[1]!==r?(i=u=>{r(d=>typeof u=="function"?u(typeof d=="boolean"?d:e):u)},t[0]=e,t[1]=r,t[2]=i):i=t[2];const l=i;let c;return t[3]!==l||t[4]!==o?(c=[o,l],t[3]=l,t[4]=o,t[5]=c):c=t[5],c}const s4={config:{type:"CLOSE_CONFIG"},mission:{type:"CLOSE_MISSION"},extension:{type:"CLOSE_EXTENSION_VIEW"}};function r4(){if(typeof window>"u")return Ot.fileChanges;try{if(JSON.parse(localStorage.getItem("panel-worktrees-visible")??"false")===!0)return Ot.worktrees;if(JSON.parse(localStorage.getItem("panel-stats-visible")??"false")===!0)return Ot.sessionInfo;if(JSON.parse(localStorage.getItem("panel-file-changes-visible")??"true")===!1)return null}catch{}return Ot.fileChanges}function qve(n,e){const t=V.c(53),[s,r]=n4("panel-sidebar-visible",!0),[o,i]=n4("panel-workflows-visible",!1);let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=r4(),t[0]=l):l=t[0];const[c,u]=kr("workspace-panel-active",l);let d;t[1]!==c?(d=typeof c=="string"||c===null?c:r4(),t[1]=c,t[2]=d):d=t[2];const f=d,[m,p]=y.useState(!1),[h,g]=y.useState(!1),{mainView:x}=n;let b;t[3]!==r||t[4]!==s?(b=()=>{y.startTransition(()=>r(!s))},t[3]=r,t[4]=s,t[5]=b):b=t[5];const w=b;let v;t[6]!==e||t[7]!==x||t[8]!==u?(v=se=>{y.startTransition(()=>{const J=x!=="sessions";J&&e(s4[x]),u(ne=>J||aj(ne)!==aj(se)?se:null)})},t[6]=e,t[7]=x,t[8]=u,t[9]=v):v=t[9];const j=v;let k;t[10]!==e||t[11]!==x||t[12]!==u?(k=se=>{y.startTransition(()=>{x!=="sessions"&&e(s4[x]),u(se)})},t[10]=e,t[11]=x,t[12]=u,t[13]=k):k=t[13];const _=k;let N;t[14]!==u?(N=()=>{y.startTransition(()=>u(null))},t[14]=u,t[15]=N):N=t[15];const S=N;let C;t[16]!==e||t[17]!==x?(C=()=>{const se=x==="config";y.startTransition(()=>{e({type:se?"CLOSE_CONFIG":"OPEN_CONFIG"})})},t[16]=e,t[17]=x,t[18]=C):C=t[18];const E=C;let T;t[19]!==e||t[20]!==x?(T=()=>{const se=x==="mission";y.startTransition(()=>{e({type:se?"CLOSE_MISSION":"OPEN_MISSION"})})},t[19]=e,t[20]=x,t[21]=T):T=t[21];const $=T;let A;t[22]!==e?(A=se=>{y.startTransition(()=>e({type:"OPEN_EXTENSION_VIEW",id:se}))},t[22]=e,t[23]=A):A=t[23];const R=A;let P;t[24]!==e?(P=()=>{y.startTransition(()=>e({type:"CLOSE_EXTENSION_VIEW"}))},t[24]=e,t[25]=P):P=t[25];const z=P,L=qx();let I;t[26]===Symbol.for("react.memo_cache_sentinel")?(I=new Set,t[26]=I):I=t[26];const M=y.useRef(I),F=y.useRef(!1);let U,O;t[27]!==L||t[28]!==R?(U=()=>{var J;if(F.current)return;const se=M.current;for(const ne of L)if(!se.has(ne.id)&&(se.add(ne.id),(J=ne.openOnStart)!=null&&J.call(ne))){F.current=!0,R(ne.id);return}},O=[L,R],t[27]=L,t[28]=R,t[29]=U,t[30]=O):(U=t[29],O=t[30]),y.useEffect(U,O);let D;t[31]!==e?(D=se=>{y.startTransition(()=>{e({type:"OPEN_CONFIG",filePath:se})})},t[31]=e,t[32]=D):D=t[32];const B=D;let q;t[33]===Symbol.for("react.memo_cache_sentinel")?(q=()=>p(!0),t[33]=q):q=t[33];const W=q;let H;t[34]===Symbol.for("react.memo_cache_sentinel")?(H=()=>p(!1),t[34]=H):H=t[34];const K=H;let Z;t[35]===Symbol.for("react.memo_cache_sentinel")?(Z=()=>g(Vve),t[35]=Z):Z=t[35];const Y=Z;let X;t[36]===Symbol.for("react.memo_cache_sentinel")?(X=()=>g(!1),t[36]=X):X=t[36];const ee=X;let te;return t[37]!==f||t[38]!==z||t[39]!==S||t[40]!==B||t[41]!==E||t[42]!==$||t[43]!==w||t[44]!==R||t[45]!==_||t[46]!==i||t[47]!==m||t[48]!==s||t[49]!==h||t[50]!==o||t[51]!==j?(te={showSidebar:s,showWorkflows:o,activeWorkspacePanel:f,showProjectSwitcher:m,showThemeSelector:h,handleToggleSidebar:w,toggleWorkspacePanel:j,openWorkspacePanel:_,closeWorkspacePanel:S,handleToggleConfig:E,handleToggleMission:$,openMainView:R,closeMainView:z,handleEditConfig:B,handleOpenProjectSwitcher:W,handleCloseProjectSwitcher:K,handleToggleThemeSelector:Y,handleCloseThemeSelector:ee,setShowWorkflows:i},t[37]=f,t[38]=z,t[39]=S,t[40]=B,t[41]=E,t[42]=$,t[43]=w,t[44]=R,t[45]=_,t[46]=i,t[47]=m,t[48]=s,t[49]=h,t[50]=o,t[51]=j,t[52]=te):te=t[52],te}function Vve(n){return!n}async function Hve(n,e){let t;try{t=await is("/api/delete-session",{dirName:n,fileName:e})}catch{return Kn.error("Could not delete session"),!1}return t.ok||t.status===404?!0:(Kn.error(await Tl(t,"Could not delete session")),!1)}function Kve(n){var ee;const{state:e,dispatch:t,isMobile:s,handleJumpToTurn:r,markPermissionsApplied:o,hasPermsPendingChanges:i,permissionsConfig:l,settingsChange:c,onSettingsChangeSent:u,selectedModel:d,selectedEffort:f,fastMode:m,ultracode:p,mcpConfig:h,scrollRequestScrollToTop:g,handleDashboardSelect:x,workerParse:b,canInteract:w}=n,v=y.useCallback(async()=>{if(!e.sessionSource)return;const{dirName:te,fileName:se}=e.sessionSource;try{const{parsed:J,source:ne}=await j7(te,se,b,"session");t({type:"RELOAD_SESSION_CONTENT",session:J,source:ne})}catch{}},[e.sessionSource,t,b]),[j,k]=y.useState(null),_=y.useCallback(te=>k(te),[]),N=y.useCallback(()=>k(null),[]),S=y.useCallback(async te=>{try{const se=await Ce("/api/branch-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(te)});if(!se.ok)return;const J=await se.json();UN(J.sessionId);const{parsed:ne,source:ie}=await Sa(J.dirName,J.fileName,b,"session");t({type:"LOAD_SESSION",session:ne,source:ie,isMobile:s})}catch{}},[t,s,b]),C=y.useCallback((te,se)=>S({dirName:te,fileName:se}),[S]),E=y.useCallback(()=>{e.sessionSource&&C(e.sessionSource.dirName,e.sessionSource.fileName)},[e.sessionSource,C]),T=y.useCallback((te,se)=>{const J=Hve(te,se),ne=iR(te,se);return ne?jR(ne,J):J},[]),$=y.useCallback(async te=>{var ie,ae;if(!e.sessionSource)return;const{dirName:se,fileName:J}=e.sessionSource,ne=(ae=(ie=e.session)==null?void 0:ie.turns[te])==null?void 0:ae.id;await S({dirName:se,fileName:J,turnIndex:te,turnUuid:ne})},[e.sessionSource,e.session,S]),A=y.useCallback((te,se)=>{r(te,se),t({type:"SET_MOBILE_TAB",tab:"chat"})},[r,t]),[R,P]=y.useState({}),z=y.useRef(d);z.current=d;const L=y.useRef(f);L.current=f;const I=y.useRef(h);I.current=h;const M=y.useRef(m);M.current=m;const F=y.useRef(p);F.current=p;const U=y.useRef(l);U.current=l;const O=y.useRef(c);O.current=c;const D=y.useRef(u);D.current=u;const B=((ee=e.session)==null?void 0:ee.sessionId)??null,q=y.useRef(null);y.useEffect(()=>{B!==q.current&&(q.current=B,B&&P(te=>B in te?te:{...te,[B]:{model:z.current,effort:L.current,fastMode:M.current,ultracode:F.current,mcpConfig:I.current}}))},[B]);const W=B?R[B]:void 0,H=h!==((W==null?void 0:W.mcpConfig)??null),K=W!=null&&(d!==W.model||f!==W.effort||m!==W.fastMode||p!==W.ultracode||i||H),Z=y.useCallback(async()=>{var de,fe;if(!B||!w)return;const te=z.current,se=L.current,J=M.current,ne=F.current,ie=I.current,ae=U.current,oe=O.current,ue=D.current,re=((de=e.sessionSource)==null?void 0:de.agentKind)??un(((fe=e.sessionSource)==null?void 0:fe.dirName)??null);bn(re).settingsApply==="live"&&(await Ce(`/api/claude/settings/${encodeURIComponent(B)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:te,effort:se,fastMode:J,ultracode:ne,mcpConfig:ie,...ae&&{permissionMode:ae.mode,allowedTools:ae.allowedTools,disallowedTools:ae.disallowedTools},...oe.length>0&&{settingsChange:oe}})})).ok&&oe.length>0&&ue(),P(le=>({...le,[B]:{model:te,effort:se,fastMode:J,ultracode:ne,mcpConfig:ie}})),o()},[B,w,e.sessionSource,o]),Y=y.useCallback(async()=>{if(!(!B||!w))try{await Ce("/api/stop-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:B})})}catch{}},[B,w]),X=y.useCallback((te,se)=>{$o(se)&&g(),x(te,se)},[g,x]);return{reloadSession:v,branchModalTurn:j,setBranchModalTurn:k,handleOpenBranches:_,handleCloseBranchModal:N,handleDuplicateSessionByPath:C,handleDuplicateSession:E,handleDeleteSession:T,handleBranchFromHere:$,handleMobileJumpToTurn:A,hasSettingsChanges:K,handleApplySettings:Z,handleStopSession:Y,handleLoadSessionScrollAware:X}}function F7(){const n=V.c(6),e=y.useRef(null);let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t=new Map,n[0]=t):t=n[0];const s=y.useRef(t),r=y.useRef(0);let o,i;n[1]===Symbol.for("react.memo_cache_sentinel")?(o=()=>{const m=s.current,p=new Worker(new URL("/assets/session-parser.worker-B1_qLRIm.js",import.meta.url),{type:"module"});return p.onmessage=h=>{const g=h.data,x=m.get(g.id);x&&(m.delete(g.id),g.type==="result"?x.resolve(g.session):x.reject(new Error(g.error)))},p.onerror=h=>{for(const[,g]of m)g.reject(new Error(`Worker error: ${h.message}`));m.clear()},e.current=p,()=>{p.terminate(),e.current=null;for(const[,h]of m)h.reject(new Error("Worker terminated"));m.clear()}},i=[],n[1]=o,n[2]=i):(o=n[1],i=n[2]),y.useEffect(o,i);let l;n[3]===Symbol.for("react.memo_cache_sentinel")?(l=m=>{const p=e.current;return p?new Promise((h,g)=>{r.current=r.current+1;const x=r.current;s.current.set(x,{resolve:h,reject:g}),p.postMessage({type:"parse",id:x,text:m})}):Promise.resolve().then(()=>xm(m))},n[3]=l):l=n[3];const c=l;let u;n[4]===Symbol.for("react.memo_cache_sentinel")?(u=(m,p)=>{const h=e.current;return h?new Promise((g,x)=>{r.current=r.current+1;const b=r.current;s.current.set(b,{resolve:g,reject:x}),h.postMessage({type:"append",id:b,existing:m,newText:p})}):Promise.resolve().then(()=>Wse(m,p))},n[4]=u):u=n[4];const d=u;let f;return n[5]===Symbol.for("react.memo_cache_sentinel")?(f={parse:c,append:d},n[5]=f):f=n[5],f}const Gve=30;function U7({dirName:n,fileName:e,sessionChangeKey:t,workerParse:s,onOlderTurns:r}){const[o,i]=y.useState(!1),[l,c]=y.useState(!1),u=y.useRef(""),d=y.useRef(null),f=`${n??""}::${e??""}::${t}`;return y.useEffect(()=>{u.current=f,d.current=null,c(!1);const p=n&&e?js.get(n,e):void 0;i((p==null?void 0:p.hasMore)??!1),p&&p.olderTurns.length>0&&r(p.olderTurns)},[f,n,e,t,r]),{loadMore:y.useCallback(async()=>{if(!n||!e||d.current)return 0;const p=`${n}::${e}::${t}`,h=js.get(n,e);if(!(h!=null&&h.hasMore))return u.current===p&&i(!1),0;const g=Symbol("paging-flight");d.current=g,c(!0);try{const x=await Ce(`/api/sessions/${encodeURIComponent(n)}/${encodeURIComponent(e)}?before=${h.nextByteOffset}&count=${Gve}`);if(!x.ok)return 0;const b=await x.json(),w=b.lines.length>0&&b.hasMore;if(u.current===p&&i(w),b.lines.length===0)return js.update(n,e,{hasMore:w,nextByteOffset:b.byteOffset}),0;const v=new Set(b.headerLines),j=b.lines.filter(N=>!v.has(N)),k=await s([...b.headerLines,...j].join(`
491
491
  `)),_=hI(h.olderTurns,k.turns,h.source.agentKind);return js.update(n,e,{hasMore:w,nextByteOffset:b.byteOffset,olderTurns:_}),u.current!==p?0:(r(_),k.turns.length)}finally{d.current===g&&(d.current=null,u.current===p&&c(!1))}},[n,e,t,s,r]),hasMore:o,isLoadingOlder:l}}function Zve(n){const e=V.c(48),{agentKind:t,session:s,sessionSource:r,pendingDirName:o,isLive:i}=n,l=t??Wo,[c,u]=y.useState(""),[d,f]=y.useState(""),[m,p]=y.useState(null),[h,g]=y.useState(!1),[x,b]=y.useState(!1),w=(r==null?void 0:r.dirName)??o;let v;e[0]!==w?(v=Yr(w),e[0]=w,e[1]=v):v=e[1];const{options:j,fastTier:k,imageInput:_,normalizeEffort:N}=d5(l,c,v.instanceId),S=c||(s==null?void 0:s.model);let C;e[2]!==l||e[3]!==S?(C=JR(l,S),e[2]=l,e[3]=S,e[4]=C):C=e[4];const E=C,T=x&&E;let $;e[5]!==N||e[6]!==d?($=N(d),e[5]=N,e[6]=d,e[7]=$):$=e[7];const A=$,R=!!k,P=R&&h,[z,L]=y.useState(null),I=y.useRef(null),M=(r==null?void 0:r.fileName)??null,F=y.useRef(M);let U,O;e[8]!==M?(U=()=>{const ae=F.current;F.current=M,!(ae===null||ae===M)&&(b(!1),p(null))},O=[M],e[8]=M,e[9]=U,e[10]=O):(U=e[9],O=e[10]),y.useEffect(U,O);let D,B;e[11]!==o?(D=()=>{o&&(b(!1),p(null))},B=[o],e[11]=o,e[12]=D,e[13]=B):(D=e[12],B=e[13]),y.useEffect(D,B);let q;e[14]!==l?(q=ae=>{u(oe=>oe===ae?"":oe),L(`${ae} is unavailable for this account. Cogpit retried the turn with ${Cn(l).displayName}'s default model.`)},e[14]=l,e[15]=q):q=e[15];const W=q;let H;e[16]===Symbol.for("react.memo_cache_sentinel")?(H=()=>{L(null)},e[16]=H):H=e[16];const K=H;let Z,Y;e[17]!==j||e[18]!==o||e[19]!==c||e[20]!==r?(Z=()=>{c&&(!r&&!o||j.some(ae=>ae.value===c)||u(""))},Y=[j,c,r,o],e[17]=j,e[18]=o,e[19]=c,e[20]=r,e[21]=Z,e[22]=Y):(Z=e[21],Y=e[22]),y.useEffect(Z,Y);let X,ee;e[23]!==z?(X=()=>{if(!z)return;const ae=setTimeout(()=>L(null),12e3);return()=>clearTimeout(ae)},ee=[z],e[23]=z,e[24]=X,e[25]=ee):(X=e[24],ee=e[25]),y.useEffect(X,ee);const te=s==null?void 0:s.rawMessages;let se,J;e[26]!==l||e[27]!==i||e[28]!==te?(se=()=>{if(!i||!te||!bn(l).modelFallbackNotices)return;let ae;for(let fe=te.length-1;fe>=0;fe=fe-1,fe){const le=te[fe];if(le.type==="system"&&le.subtype==="model_refusal_fallback"){ae=le;break}}if(!ae)return;const oe=typeof ae.uuid=="string"?ae.uuid:`${String(ae.original_model)}:${String(ae.fallback_model)}:${String(ae.request_id)}`;if(I.current===oe)return;I.current=oe;const ue=typeof ae.original_model=="string"?ae.original_model:"Fable",re=typeof ae.fallback_model=="string"?ae.fallback_model:"Opus",de=typeof ae.api_refusal_explanation=="string"?` ${ae.api_refusal_explanation}`:"";L(`${ue} could not handle this request, so Claude continued with ${re}.${de}`)},J=[i,te,l],e[26]=l,e[27]=i,e[28]=te,e[29]=se,e[30]=J):(se=e[29],J=e[30]),y.useEffect(se,J);let ne;e[31]!==l?(ne=bn(l),e[31]=l,e[32]=ne):ne=e[32];let ie;return e[33]!==m||e[34]!==A||e[35]!==P||e[36]!==R||e[37]!==h||e[38]!==W||e[39]!==_||e[40]!==z||e[41]!==d||e[42]!==c||e[43]!==ne.configurableContextWindow||e[44]!==T||e[45]!==E||e[46]!==x?(ie={contextWindowTokens:m,setContextWindowTokens:p,contextWindowAvailable:ne.configurableContextWindow,selectedModel:c,setSelectedModel:u,selectedEffort:d,setSelectedEffort:f,fastModeEnabled:h,ultracodeEnabled:x,effectiveEffort:A,fastModeAvailable:R,fastModeActive:P,setFastModeEnabled:g,ultracodeAvailable:E,ultracodeActive:T,setUltracodeEnabled:b,imageInputAvailable:_,modelFallbackNotice:z,dismissModelFallbackNotice:K,handleModelRejected:W},e[33]=m,e[34]=A,e[35]=P,e[36]=R,e[37]=h,e[38]=W,e[39]=_,e[40]=z,e[41]=d,e[42]=c,e[43]=ne.configurableContextWindow,e[44]=T,e[45]=E,e[46]=x,e[47]=ie):ie=e[47],ie}const ta=["permissionMode","model","effort","contextWindowTokens","fastMode","ultracode"];function Yve(n){return ta.some(e=>e===n)}function Xve(n){return JSON.stringify(n,[...ta])}function nl(n,e){return ta.filter(t=>n[t]!==e[t])}function Ju(n,e){const t={};for(const s of e)Object.assign(t,{[s]:n[s]});return t}function Jve(n,e){return{model:n.model??e.model,effort:n.effort??e.effort,contextWindowTokens:n.contextWindowTokens??null,fastMode:n.fastMode??e.fastMode,ultracode:n.ultracode??e.ultracode,permissionMode:n.permissionMode??e.permissionMode}}function Qve({sessionKey:n,sessionId:e,values:t,access:s,onHydrate:r}){const[o,i]=y.useState(null),l=y.useRef(null),c=y.useRef(0),u=y.useRef(r);u.current=r;const d=y.useRef(t);d.current=t;const f=y.useRef(s);f.current=s;const m=y.useCallback((w,v)=>{const j=l.current;if((j==null?void 0:j.key)!==w||!wa(f.current).configure)return;const k=nl(j.values,v);if(k.length===0)return;const _=Ju(v,k);l.current={key:w,values:v},G1(w,_).then(N=>{N&&i(S=>(S==null?void 0:S.key)===w?{key:w,values:{...S.values,..._}}:S)})},[]),p=y.useCallback(w=>{var _;const v=++c.current,j=d.current,k=((_=l.current)==null?void 0:_.key)===w?l.current.values:null;M7(w).then(N=>{if(v!==c.current||N===null)return;const S=d.current,C=wa(f.current).configure;if(!ta.some(A=>N[A]!==void 0)){if(l.current={key:w,values:S},i({key:w,values:S}),!C)return;const A=f.current==="own"?ta:ta.filter(R=>R!=="permissionMode");G1(w,Ju(S,A));return}const E=Jve(N,k??S),T=k?[...new Set([...nl(k,j),...nl(j,S)])]:[],$={...E,...Ju(S,T)};(!k||nl(S,$).length>0)&&u.current({...N,...Ju(S,T)}),l.current={key:w,values:E},i({key:w,values:E}),m(w,$)})},[m]);y.useEffect(()=>{var w;if(((w=l.current)==null?void 0:w.key)!==n&&(l.current=null),!!n)return p(n),()=>{c.current+=1}},[n,s,p]),y.useEffect(()=>{if(!n)return;const w=()=>p(n),v=e?rte(e,w):void 0;let j=document.visibilityState==="hidden";function k(){j&&(j=!1,w())}function _(){document.visibilityState==="hidden"?j=!0:k()}return document.addEventListener("visibilitychange",_),window.addEventListener("focus",k),()=>{v==null||v(),document.removeEventListener("visibilitychange",_),window.removeEventListener("focus",k)}},[n,e,p]);const h=Xve(t);y.useEffect(()=>{n&&m(n,d.current)},[h,n,m]);const g=(o==null?void 0:o.key)===n?nl(o.values,t).join():"",x=y.useMemo(()=>g.split(",").filter(Yve),[g]),b=y.useCallback(()=>{n&&D7(n)},[n]);return{picked:x,settlePicked:b}}function eye(n){const[e,t]=y.useState(new Map),[s,r]=y.useState(null),[o,i]=y.useState(!0),l=y.useRef(new Map),c=y.useRef(null);y.useEffect(()=>{const x=n??null,b=c.current;if(b&&b!==x&&l.current.set(b,{activeId:s,collapsed:o}),x!==b){const w=x?l.current.get(x):null;w?(r(w.activeId),i(w.collapsed)):(r(null),i(!0))}c.current=x},[n]);const u=y.useCallback(()=>i(x=>!x),[]),d=y.useCallback(x=>{t(b=>{const w=new Map(b);return w.set(x.id,x),w}),r(x.id),i(!1)},[]),f=y.useCallback(x=>{t(b=>{const w=new Map(b);return w.delete(x),r(v=>{if(v!==x)return v;const j=[...w.keys()];return j.length>0?j[j.length-1]:null}),w})},[]),m=y.useCallback(x=>{r(x),i(!1)},[]),p=y.useCallback((x,b)=>{t(w=>{const v=w.get(x);if(!v||v.status===b)return w;const j=new Map(w);return j.set(x,{...v,status:b}),j})},[]),h=y.useCallback(x=>{t(b=>{let w=!1;const v=new Map(b),j=new Set(x.map(k=>k.id));for(const[k,_]of v)_.type==="task"&&!j.has(k)&&(v.delete(k),w=!0);for(const k of x){const _=v.get(k.id);_?(_.name!==k.title||_.outputPath!==k.outputPath)&&(v.set(k.id,{..._,name:k.title,outputPath:k.outputPath}),w=!0):(v.set(k.id,{id:k.id,name:k.title,type:"task",status:"running",outputPath:k.outputPath}),w=!0)}return w?v:b})},[]),g=y.useCallback((x,b,w)=>{b&&w&&t(v=>{if(v.has(x))return v;const j=new Map(v);return j.set(x,{id:x,name:w,type:"task",status:"running",outputPath:b}),j}),r(v=>v===x?(i(!0),v):(i(!1),x))},[]);return{processes:e,activeProcessId:s,collapsed:o,toggleCollapse:u,addProcess:d,removeProcess:f,setActive:m,updateProcessStatus:p,handleServersChanged:h,handleToggleServer:g}}function tye(n){const e=V.c(52),{sessionId:t,sessionCwd:s,pendingPath:r,sessionDirName:o,pendingDirName:i,dashboardProject:l,supportsFileWorkspace:c,activeWorkspacePanel:u,openWorkspacePanel:d,closeWorkspacePanel:f}=n,m=eye(t),[p,h]=y.useState(null),[g,x]=y.useState(0),b=y.useRef(0),w=s??r??void 0,v=!!(w&&(p==null?void 0:p.kind)==="preview"&&p.cwd===w),j=(p==null?void 0:p.kind)==="project-files"&&p.anchorCwd===(w??null)?p:null;let k;e[0]!==i||e[1]!==r?(k={path:r,dirName:i},e[0]=i,e[1]=r,e[2]=k):k=e[2];const _=k;let N;e[3]!==l||e[4]!==i||e[5]!==r||e[6]!==s||e[7]!==o?(N=()=>({path:s??r??void 0,dirName:o??i??l??void 0}),e[3]=l,e[4]=i,e[5]=r,e[6]=s,e[7]=o,e[8]=N):N=e[8];const S=N;let C;e[9]!==S?(C=()=>{R1(S())},e[9]=S,e[10]=C):C=e[10];const E=C;let T;e[11]!==S?(T=X=>{R1({...S(),command:"claude /mcp"})},e[11]=S,e[12]=T):T=e[12];const $=T;let A;e[13]!==r||e[14]!==m||e[15]!==s?(A=()=>{const ee=[...m.processes.values()].filter(rye).at(-1);if(!ee){(s??r)&&x(sye);return}m.activeProcessId===ee.id&&!m.collapsed?m.toggleCollapse():m.setActive(ee.id)},e[13]=r,e[14]=m,e[15]=s,e[16]=A):A=e[16];const R=A;let P;e[17]!==r||e[18]!==s?(P=()=>{(s??r)&&x(nye)},e[17]=r,e[18]=s,e[19]=P):P=e[19];const z=P;let L;e[20]!==f||e[21]!==w||e[22]!==v?(L=()=>{w&&y.startTransition(()=>{f(),h(v?null:{kind:"preview",cwd:w})})},e[20]=f,e[21]=w,e[22]=v,e[23]=L):L=e[23];const I=L;let M;e[24]!==u||e[25]!==f||e[26]!==w||e[27]!==d?(M=()=>{if(w){if(u===Ot.projectFiles){f();return}y.startTransition(()=>{h({kind:"project-files",root:w,anchorCwd:w,request:null}),d(Ot.projectFiles)})}},e[24]=u,e[25]=f,e[26]=w,e[27]=d,e[28]=M):M=e[28];const F=M;let U;e[29]!==w||e[30]!==d||e[31]!==c?(U=X=>{if(!c)return!1;const ee=Kse(X,w);if(!ee)return!1;b.current=b.current+1;const te=b.current;return y.startTransition(()=>h({kind:"project-files",root:ee.root,anchorCwd:w??null,request:ee.file?{file:ee.file,mode:ee.mode,line:ee.line,token:te}:null})),d(Ot.projectFiles),!0},e[29]=w,e[30]=d,e[31]=c,e[32]=U):U=e[32];const O=U;let D,B;e[33]!==O?(D=()=>Hse(O),B=[O],e[33]=O,e[34]=D,e[35]=B):(D=e[34],B=e[35]),y.useEffect(D,B);let q;e[36]===Symbol.for("react.memo_cache_sentinel")?(q=()=>{y.startTransition(()=>h(null))},e[36]=q):q=e[36];const W=q,H=!!(w&&u===Ot.projectFiles),K=j==null?void 0:j.root,Z=(j==null?void 0:j.request)??null;let Y;return e[37]!==w||e[38]!==$||e[39]!==z||e[40]!==E||e[41]!==R||e[42]!==I||e[43]!==F||e[44]!==g||e[45]!==_||e[46]!==m||e[47]!==v||e[48]!==H||e[49]!==K||e[50]!==Z?(Y={processPanel:m,currentCwd:w,showPreview:v,showProjectFiles:H,projectFilesRoot:K,projectFilesRequest:Z,launchTerminalRequest:g,pendingProject:_,handleOpenTerminal:E,handleMcpAuth:$,handleToggleIntegratedTerminal:R,handleNewIntegratedTerminal:z,handleTogglePreview:I,handleToggleProjectFiles:F,closeRightWorkspace:W},e[37]=w,e[38]=$,e[39]=z,e[40]=E,e[41]=R,e[42]=I,e[43]=F,e[44]=g,e[45]=_,e[46]=m,e[47]=v,e[48]=H,e[49]=K,e[50]=Z,e[51]=Y):Y=e[51],Y}function nye(n){return n+1}function sye(n){return n+1}function rye(n){return n.type==="terminal"}function oye(n){const e=n.replace(/<[^>]+>[\s\S]*?<\/[^>]+>/g,"").trim();if(!e)return"";const t=e.split(`
492
- `)[0].trim();return t.length<=60?t:t.slice(0,57)+"..."}const iye={totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:0};function B7(n,e){return{dirName:n.dirName,fileName:n.fileName,rawText:e,agentKind:un(n.dirName)}}function aye(n){return{sessionId:n.sessionId,version:"",gitBranch:"",cwd:"",slug:"",name:"",model:"",turns:[],stats:{...iye},rawMessages:[],agentKind:un(n.dirName)}}function W7(n,e){if(!(n!=null&&n.trim()))return null;try{return{rawText:n,parsed:ra(xm(n),Yr(e).instanceId)}}catch{return null}}async function lye(n,e,t=3,s=100,r=!0){if(r){const o=W7(n.initialContent,n.dirName);if(o)return o}for(let o=0;o<t;o++){if(e.signal.aborted)throw new DOMException("Aborted","AbortError");const i=await Ce(`/api/sessions/${encodeURIComponent(n.dirName)}/${encodeURIComponent(n.fileName)}`,{signal:e.signal});if(i.ok){const l=await i.text();if(l.trim())try{return{rawText:l,parsed:ra(xm(l),Yr(n.dirName).instanceId)}}catch{}}o<t-1&&await new Promise(l=>setTimeout(l,s))}return null}async function cye(n,e,t,s){let r=s;for(let o=0;o<30;o++){if(e.signal.aborted)return;const i=await lye(n,e,1,0,!1);if(i&&i.rawText!==r){t({type:"RELOAD_SESSION_CONTENT",session:i.parsed,source:B7(n,i.rawText)});return}r=(i==null?void 0:i.rawText)??r,await new Promise(l=>setTimeout(l,200))}}async function uye(n,e,t,s,r){const o=W7(n.initialContent,n.dirName),i=(o==null?void 0:o.rawText)??"",l=(o==null?void 0:o.parsed)??aye(n),c=B7(n,i);return t({type:"FINALIZE_SESSION",session:l,source:c,isMobile:s}),r(l,c),cye(n,e,t,i),n.sessionId}function dye(n){return n.access?n.access.mine:!0}async function fye(n,e,t,s){const r=Xr(),o=await Ce(`/api/sessions/${encodeURIComponent(n)}?page=1&limit=10`,{signal:s.signal});if(!o.ok)return null;const i=await o.json();aa(i.sessions??[],r);const l=t-3e4,c=e.trim(),u=(i.sessions??[]).filter(f=>{const m=f.lastModified?new Date(f.lastModified).getTime():0;return Number.isFinite(m)&&m>=l&&dye(f)}),d=u.find(f=>{var m,p;return((m=f.firstUserMessage)==null?void 0:m.trim())===c||((p=f.lastUserMessage)==null?void 0:p.trim())===c})??u[0];return d?{dirName:n,fileName:d.fileName,sessionId:d.sessionId}:null}function mye({permissionsConfig:n,dispatch:e,isMobile:t,onSessionFinalized:s,onCreateStarted:r,onModelRejected:o,model:i,effort:l,contextWindowTokens:c,fastMode:u,ultracode:d,mcpConfig:f}){const[m,p]=y.useState(!1),[h,g]=y.useState(null),[x,b]=y.useState(!1),w=y.useRef(null),v=y.useRef(null),j=y.useRef(null),k=y.useCallback((C,E)=>{v.current=C,j.current=E??null,g(null),p(!1),e({type:"INIT_PENDING_SESSION",dirName:C,cwd:E,isMobile:t})},[e,t]),_=y.useCallback(async(C,E)=>{var I;const T=v.current;if(!T)return null;const $=un(T),A=j.current;(I=w.current)==null||I.abort();const R=new AbortController;w.current=R,p(!0),g(null),r==null||r(C);const P=Date.now(),z=oye(C);async function L(M){v.current=null,j.current=null,UN(M.sessionId);const F=await uye(M,R,e,t,s);return z&&F&&VN(F,z),F}try{const M=Cn($),{capabilities:F}=M,U={dirName:T,cwd:M.dirName.lossy?A??void 0:void 0,message:C,images:E,permissions:n,effort:l||void 0,contextWindowTokens:c,fastMode:u?!0:void 0,ultracode:F.ultracode&&d?!0:void 0,name:F.namedSessions&&z||void 0,worktreeName:F.worktrees&&x?e9(C):void 0,mcpConfig:F.mcp&&f||void 0},{res:O,errorMessage:D,errorCode:B}=await y7(q=>Ce("/api/create-and-send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...U,model:q}),signal:R.signal}),{model:i,agentKind:$,errorFallback:"Unknown error",onModelRejected:o});if(!O.ok){if($==="codex"&&B!=="SESSION_UNCONFIRMED"){const q=await fye(T,C,P,R);if(q)return await L(q)}return g(D||`Failed to create session (${O.status})`),null}return await L(await O.json())}catch(M){return R.signal.aborted||g(M instanceof Error?M.message:"Failed to create session"),null}finally{R.signal.aborted||p(!1)}},[n,i,l,c,u,d,f,x,e,t,s,r,o]),N=y.useCallback(()=>g(null),[]),S=y.useCallback(()=>{var C;(C=w.current)==null||C.abort(),w.current=null,v.current=null,j.current=null,p(!1),g(null)},[]);return{creatingSession:m,createError:h,clearCreateError:N,handleNewSession:k,createAndSend:_,cancelCreation:S,worktreeEnabled:x,setWorktreeEnabled:b}}function pye(n){const e=V.c(41),{permissionsConfig:t,dispatch:s,isMobile:r,defaultAgentKind:o,pendingDirName:i,pendingCwd:l,model:c,effort:u,contextWindowTokens:d,fastMode:f,ultracode:m,mcpConfig:p,onModelRejected:h}=n,g=y.useRef(null),x=y.useRef(null),[b,w]=y.useState(null);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=W=>{var H;(H=g.current)==null||H.call(g,W),setTimeout(()=>{var K;return(K=x.current)==null?void 0:K.call(x)},300),setTimeout(()=>{var K;return(K=x.current)==null?void 0:K.call(x)},2e3)},e[0]=v):v=e[0];let j;e[1]!==d||e[2]!==s||e[3]!==u||e[4]!==f||e[5]!==r||e[6]!==p||e[7]!==c||e[8]!==h||e[9]!==t||e[10]!==m?(j={permissionsConfig:t,dispatch:s,isMobile:r,onSessionFinalized:v,onCreateStarted:w,onModelRejected:h,model:c,effort:u,contextWindowTokens:d,fastMode:f,ultracode:m,mcpConfig:p},e[1]=d,e[2]=s,e[3]=u,e[4]=f,e[5]=r,e[6]=p,e[7]=c,e[8]=h,e[9]=t,e[10]=m,e[11]=j):j=e[11];const k=mye(j),_=k.handleNewSession,[N,S]=y.useState(null);let C;e[12]===Symbol.for("react.memo_cache_sentinel")?(C=new Map,e[12]=C):C=e[12];const E=y.useRef(C),T=hye;let $;e[13]===Symbol.for("react.memo_cache_sentinel")?($=async W=>{if(pu===null)return null;const H=E.current;if(H.has(W))return H.get(W)??null;const K=cR(await T(),W,pu);return H.set(W,K),K},e[13]=$):$=e[13];const A=$;let R;e[14]!==_?(R=async(W,H)=>{var X;const K=H??((X=(await T()).find(ee=>ee.dirName===W))==null?void 0:X.path)??null;if(!K){S(null),_(W);return}if(Yr(W).instanceId!=="default"){S({discoveredDirName:null,cwd:K}),_(W,K);return}const Z=un(W)===pu?pu:null,Y=Z?Gm(Z,K):await A(K);S({discoveredDirName:Y,cwd:K}),_(Z&&Y?Y:W,K)},e[14]=_,e[15]=R):R=e[15];const P=R;let z;e[16]!==o||e[17]!==P?(z=W=>{const H=Gm(o,W);P(H,W)},e[16]=o,e[17]=P,e[18]=z):z=e[18];const L=z;let I;e[19]!==_||e[20]!==N?(I=W=>{if(!N)return;const H=Gm(W,N.cwd,N.discoveredDirName??void 0);_(H,N.cwd)},e[19]=_,e[20]=N,e[21]=I):I=e[21];const M=I;let F;e:{if(!k.creatingSession||!i){F=null;break e}const W=b??void 0;let H;e[22]!==l||e[23]!==i||e[24]!==W?(H={dirName:i,cwd:l,firstMessage:W},e[22]=l,e[23]=i,e[24]=W,e[25]=H):H=e[25],F=H}const U=F;let O,D;e[26]!==i?(D=()=>{i||(w(null),S(null))},O=[i],e[26]=i,e[27]=O,e[28]=D):(O=e[27],D=e[28]),y.useEffect(D,O);const B=N?M:void 0;let q;return e[29]!==L||e[30]!==P||e[31]!==k.cancelCreation||e[32]!==k.clearCreateError||e[33]!==k.createAndSend||e[34]!==k.createError||e[35]!==k.creatingSession||e[36]!==k.setWorktreeEnabled||e[37]!==k.worktreeEnabled||e[38]!==U||e[39]!==B?(q={creatingSession:k.creatingSession,createError:k.createError,clearCreateError:k.clearCreateError,createAndSend:k.createAndSend,cancelCreation:k.cancelCreation,worktreeEnabled:k.worktreeEnabled,setWorktreeEnabled:k.setWorktreeEnabled,sessionFinalizedRef:g,liveSessionsRefreshRef:x,pendingSessionInfo:U,pendingAgentKindChange:B,handleStartNewSession:P,handleStartNewFolder:L},e[29]=L,e[30]=P,e[31]=k.cancelCreation,e[32]=k.clearCreateError,e[33]=k.createAndSend,e[34]=k.createError,e[35]=k.creatingSession,e[36]=k.setWorktreeEnabled,e[37]=k.worktreeEnabled,e[38]=U,e[39]=B,e[40]=q):q=e[40],q}async function hye(){try{const n=await Ce("/api/projects");return n.ok?await n.json():[]}catch{return[]}}const fg=new Set;function gye(n,e){const t=cn(),s=Zn();return`${s===null?t:`${t}:${s}`}:${n}/${e}`}async function xye(n,e,t){const s=gye(n,e);if(!fg.has(s)&&!js.get(n,e)){fg.add(s);try{await Sa(n,e,t,"session prefetch",{background:!0})}catch{}finally{fg.delete(s)}}}function bye({onAuthenticated:n,setupRequired:e=!1}){const[t,s]=y.useState(null),[r,o]=y.useState(""),[i,l]=y.useState(""),[c,u]=y.useState(!1),[d,f]=y.useState(null),[m,p]=y.useState(!1),h=t==="account",{LoginNotice:g}=$r();y.useEffect(()=>{let w=!1;return fN().then(v=>{w||s(v)}),()=>{w=!0}},[]);const x=y.useCallback(async w=>{if(w.preventDefault(),!(!i.trim()||h&&!r.trim())){p(!0),f(null);try{const v=await fetch("/api/auth/verify",h?{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json","X-Cogpit-Client":"1"},body:JSON.stringify({username:r.trim(),password:i})}:{method:"POST",credentials:"same-origin",cache:"no-store",headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json","X-Cogpit-Client":"1"}}),j=await v.json();v.ok&&j.valid?(Tf(),l(""),o(""),n()):f(j.error||(h?"Invalid credentials":"Invalid password"))}catch{f("Failed to connect to server")}finally{p(!1)}}},[h,n,i,r]),b=m||!i.trim()||h&&!r.trim();return a.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-canvas px-4 py-8",children:a.jsx("form",{onSubmit:x,className:"w-full max-w-sm",children:a.jsxs(Ds,{children:[a.jsxs(gr,{children:[a.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:a.jsx(F8,{className:"size-4"})}),a.jsx(xr,{children:"Sign in to Cogpit"}),a.jsx(br,{children:h?"Sign in with your account to continue.":"Enter the server password to continue."})]}),t===null?a.jsx(Fs,{children:a.jsx("div",{className:"flex min-h-24 items-center justify-center",role:"status","aria-label":"Checking server",children:a.jsx(Pn,{className:"size-5 text-muted-foreground"})})}):a.jsxs(a.Fragment,{children:[a.jsxs(Fs,{className:"flex flex-col gap-4",children:[e&&a.jsxs(jt,{children:[a.jsx(yf,{"aria-hidden":"true"}),a.jsx(Rt,{children:"This server has no accounts yet."})]}),a.jsxs(Ta,{children:[h&&a.jsxs(fn,{children:[a.jsx(mn,{htmlFor:"login-username",children:"Username"}),a.jsx(On,{id:"login-username",type:"text",value:r,onChange:w=>o(w.target.value),placeholder:"Username",autoComplete:"username",autoFocus:!0})]}),a.jsxs(fn,{children:[a.jsx(mn,{htmlFor:"login-password",children:"Password"}),a.jsxs(Ko,{children:[a.jsx(Go,{id:"login-password",type:c?"text":"password",value:i,onChange:w=>l(w.target.value),placeholder:"Password",autoComplete:"current-password",autoFocus:!h}),a.jsx(Tr,{align:"inline-end",children:a.jsx(dm,{size:"icon-xs",onClick:()=>u(w=>!w),"aria-label":c?"Hide password":"Show password",children:c?a.jsx(ux,{}):a.jsx(ja,{})})})]})]})]}),h&&g&&a.jsx(g,{}),d&&a.jsxs(jt,{variant:"destructive",children:[a.jsx(wr,{"aria-hidden":"true"}),a.jsx(tn,{children:"Sign in failed"}),a.jsx(Rt,{children:d})]})]}),a.jsx(um,{children:a.jsxs(Q,{type:"submit",className:"w-full",disabled:b,children:[m&&a.jsx(Pn,{"data-icon":"inline-start"}),"Connect"]})})]})]})})})}function vye(){const n=V.c(18);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=Ef(),n[0]=e):e=n[0];const t=e,[s,r]=y.useState(null),[o,i]=y.useState(!1),[l,c]=y.useState(!1),u=y.useRef(0);let d,f;n[1]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{let $=!1;return dN().then(A=>{$||r(A)}),()=>{$=!0}},f=[],n[1]=d,n[2]=f):(d=n[1],f=n[2]),y.useEffect(d,f);const m=t?!0:s===null?null:s.signIn==="account";let p,h;n[3]!==m?(p=()=>{if(m===null)return;if(!m){i(!0),c(!0);return}let $=!1;const A=u.current;return IR().then(R=>{!$&&u.current===A&&(i(R),c(!0))}),()=>{$=!0}},h=[m],n[3]=m,n[4]=p,n[5]=h):(p=n[4],h=n[5]),y.useEffect(p,h);let g;n[6]!==(s==null?void 0:s.signIn)?(g=()=>{let $=!1;const A=()=>{const R=u.current=u.current+1,P=()=>{$||u.current!==R||(i(!1),c(!0))};if(t||(s==null?void 0:s.signIn)==="account"){P();return}_y().then(z=>{$||u.current!==R||(r(z),z.signIn==="account"&&P())})};return window.addEventListener("cogpit-auth-required",A),()=>{$=!0,window.removeEventListener("cogpit-auth-required",A)}},n[6]=s==null?void 0:s.signIn,n[7]=g):g=n[7];const x=s==null?void 0:s.signIn;let b;n[8]!==x?(b=[x,t],n[8]=x,n[9]=b):b=n[9],y.useEffect(g,b);let w;n[10]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{u.current=u.current+1,i(!0),c(!0),window.dispatchEvent(new Event("cogpit-auth-changed"))},n[10]=w):w=n[10];const v=w;let j;n[11]===Symbol.for("react.memo_cache_sentinel")?(j=async()=>{r(await _y())},n[11]=j):j=n[11];const k=j;let _;n[12]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{B9(),u.current=u.current+1,i(!1),c(!0),PR().finally(yye)},n[12]=_):_=n[12];const N=_,S=(s==null?void 0:s.edition)??null,C=l&&s!==null,E=(s==null?void 0:s.setupRequired)===!0;let T;return n[13]!==o||n[14]!==S||n[15]!==C||n[16]!==E?(T={isRemote:t,edition:S,authChecked:C,authenticated:o,setupRequired:E,handleAuthenticated:v,refreshServerState:k,logout:N},n[13]=o,n[14]=S,n[15]=C,n[16]=E,n[17]=T):T=n[17],T}function yye(){window.dispatchEvent(new Event("cogpit-auth-changed"))}function wye(n){const e=V.c(18),{onRestored:t,onLogout:s}=n,{activeDevice:r,activeDeviceId:o}=Fa();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=qo(),e[0]=i):i=e[0];const l=i,c=l?(r==null?void 0:r.name)??o:"This server";let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u=a.jsx(Yn,{variant:"icon",children:a.jsx(ix,{className:"text-destructive"})}),e[1]=u):u=e[1];let d;e[2]!==c?(d=a.jsxs(zn,{children:[c," isn’t available to your account right now"]}),e[2]=c,e[3]=d):d=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=a.jsx(Dn,{children:"Its administrator can let you back in. Check again once they have."}),e[4]=f):f=e[4];let m;e[5]!==d?(m=a.jsxs(Mn,{children:[u,d,f]}),e[5]=d,e[6]=m):m=e[6];let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx(Fn,{"data-icon":"inline-start"}),e[7]=p):p=e[7];let h;e[8]!==t?(h=a.jsxs(Q,{size:"sm",onClick:t,children:[p,"Check again"]}),e[8]=t,e[9]=h):h=e[9];let g;e[10]!==s?(g=l?a.jsxs(Q,{variant:"outline",size:"sm",onClick:Sye,children:[a.jsx(bg,{"data-icon":"inline-start"}),"Switch to this machine"]}):a.jsxs(Q,{variant:"outline",size:"sm",onClick:s,children:[a.jsx(U8,{"data-icon":"inline-start"}),"Sign out"]}),e[10]=s,e[11]=g):g=e[11];let x;e[12]!==h||e[13]!==g?(x=a.jsxs(_c,{className:"flex-row justify-center",children:[h,g]}),e[12]=h,e[13]=g,e[14]=x):x=e[14];let b;return e[15]!==m||e[16]!==x?(b=a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas text-foreground",children:a.jsxs(Ln,{children:[m,x]})}),e[15]=m,e[16]=x,e[17]=b):b=e[17],b}function Sye(){return Xs(Lt)}function kye(n){const e=V.c(4),{onRetry:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:a.jsx(B8,{className:"text-destructive"})}),a.jsx(zn,{children:"Cogpit couldn’t finish loading"}),a.jsx(Dn,{children:"Part of this server’s interface didn’t download. Check your connection and try again."})]}),e[0]=s):s=e[0];let r;e[1]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Fn,{"data-icon":"inline-start"}),e[1]=r):r=e[1];let o;return e[2]!==t?(o=a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas text-foreground",children:a.jsxs(Ln,{children:[s,a.jsx(_c,{className:"flex-row justify-center",children:a.jsxs(Q,{size:"sm",onClick:t,children:[r,"Retry"]})})]})}),e[2]=t,e[3]=o):o=e[3],o}const Y1="cogpit:edition-ui-reloaded";let mg=null;function jye(){return mg??(mg=nt(()=>import("./edition-ui-ZYzlZ7yi.js"),__vite__mapDeps([42,1,2,29,3,4])).then(n=>n.default,n=>{throw mg=null,n})),mg}function Nye(){try{if(sessionStorage.getItem(Y1)!==null)return!1;sessionStorage.setItem(Y1,"1")}catch{return!1}return window.location.reload(),!0}function q7(){try{sessionStorage.removeItem(Y1)}catch{}}async function Cye(n,e){let t;try{t=await jye()}catch{return e&&Nye()?"reloading":"failed"}return q7(),(t==null?void 0:t.edition)===n?t:null}async function V7(n,e,t){V9();const s=await Cye(n,t);s!=="reloading"&&(s==="failed"&&e?(q7(),K9()):s===null||s==="failed"?H9():q9(s))}async function _ye(n,{required:e=!1}={}){if(n==="personal")return;const t=ec();t==="installed"||t==="loading"||t==="failed"||await V7(n,e,!0)}async function Eye(n){ec()==="failed"&&await V7(n,!0,!1)}function o4(n){return n==="personal"?null:n}function Tye(n,e){const t=V.c(16),s=y.useSyncExternalStore(Wx,ec,ec);let r;t[0]!==n?(r=o4(n),t[0]=n,t[1]=r):r=t[1];const o=r;let i;t[2]!==e||t[3]!==o?(i=o??o4(e),t[2]=e,t[3]=o,t[4]=i):i=t[4];const l=i,c=o!==null;let u,d;t[5]!==c||t[6]!==l?(u=()=>{l!==null&&_ye(l,{required:c})},d=[l,c],t[5]=c,t[6]=l,t[7]=u,t[8]=d):(u=t[7],d=t[8]),y.useEffect(u,d);let f;t[9]!==l?(f=()=>{l!==null&&Eye(l)},t[9]=l,t[10]=f):f=t[10];const m=f,p=s==="installed"||s==="unavailable",h=o===null||p,g=l===null||p,x=c&&s==="failed";let b;return t[11]!==m||t[12]!==h||t[13]!==g||t[14]!==x?(b={serverReady:h,ready:g,failed:x,retry:m},t[11]=m,t[12]=h,t[13]=g,t[14]=x,t[15]=b):b=t[15],b}const H7={level:"own"},i4={level:"unknown"},Aye={none:{level:"none"},view:{level:"view"},interact:{level:"interact"},own:H7};function Iye(n){const e=V.c(5),{enforcesSessionAccess:t}=AN(),s=t?n:null;let r;e[0]!==s?(r=()=>s?rO(s):void 0,e[0]=s,e[1]=r):r=e[1];const o=r,i=y.useSyncExternalStore(iO,o,o);let l,c;return e[2]!==s?(l=()=>s?uO(s):void 0,c=[s],e[2]=s,e[3]=l,e[4]=c):(l=e[3],c=e[4]),y.useEffect(l,c),t===null?i4:s?i?Aye[i]:i4:H7}function Pye({level:n}){return n==="unknown"?{kind:"checking"}:n==="none"?{kind:"no-access"}:wa(n).canInteract?null:{kind:"view-only"}}function $ye(n){const e=V.c(8),{reason:t}=n;switch(t.kind){case"subagent":{let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(wd,{icon:mi,children:"Viewing sub-agent session (read-only)"}),e[0]=s):s=e[0],s}case"external":{let s;e[1]!==t.agentKind?(s=CM(t.agentKind),e[1]=t.agentKind,e[2]=s):s=e[2];let r;return e[3]!==s?(r=a.jsx(wd,{icon:mi,status:!0,children:s}),e[3]=s,e[4]=r):r=e[4],r}case"no-access":{let s;return e[5]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(wd,{icon:q8,status:!0,children:"You don't have access to this session"}),e[5]=s):s=e[5],s}case"checking":{let s;return e[6]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(a4,{icon:W8,children:"Checking access…"}),e[6]=s):s=e[6],s}case"view-only":{let s;return e[7]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(a4,{icon:ja,children:a.jsx(Rye,{})}),e[7]=s):s=e[7],s}}}function Rye(){const n=V.c(3),{ReadOnlyNote:e}=$r(),{session:t}=kt();let s;return n[0]!==e||n[1]!==t?(s=e&&t?a.jsx(e,{sessionId:t.sessionId}):"View only",n[0]=e,n[1]=t,n[2]=s):s=n[2],s}function a4(n){const e=V.c(4),{icon:t,children:s}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Oye,{}),e[0]=r):r=e[0];let o;return e[1]!==s||e[2]!==t?(o=a.jsxs("div",{className:"shrink-0",children:[r,a.jsx(wd,{icon:t,status:!0,children:s})]}),e[1]=s,e[2]=t,e[3]=o):o=e[3],o}function Oye(){const n=V.c(7),{pendingInteraction:e,permissionRequests:t}=kt(),s=(e==null?void 0:e.type)==="plan"?e:null;if(!s&&t.length===0)return null;let r;n[0]!==s?(r=s&&a.jsx(I5,{allowedPrompts:s.allowedPrompts,summary:s.summary,planContent:s.planContent}),n[0]=s,n[1]=r):r=n[1];let o;n[2]!==t?(o=t.length>0&&a.jsx("div",{className:"mb-2 overflow-hidden rounded-xl border border-warning/40 bg-popover",children:a.jsx(P5,{requests:t})}),n[2]=t,n[3]=o):o=n[3];let i;return n[4]!==r||n[5]!==o?(i=a.jsxs("div",{className:"px-3 pt-2",children:[r,o]}),n[4]=r,n[5]=o,n[6]=i):i=n[6],i}function wd(n){const e=V.c(8),{icon:t,status:s,children:r}=n,i=(s===void 0?!1:s)?"status":void 0;let l;e[0]!==t?(l=a.jsx(t,{"data-icon":"inline-start",className:"size-3.5 text-muted-foreground"}),e[0]=t,e[1]=l):l=e[1];let c;e[2]!==r?(c=a.jsx("span",{className:"text-xs text-muted-foreground",children:r}),e[2]=r,e[3]=c):c=e[3];let u;return e[4]!==i||e[5]!==l||e[6]!==c?(u=a.jsxs("div",{role:i,className:"flex shrink-0 items-center justify-center gap-2 border-t bg-card px-4 py-2.5",children:[l,c]}),e[4]=i,e[5]=l,e[6]=c,e[7]=u):u=e[7],u}const Lye=y.lazy(()=>nt(()=>import("./index-C1aZnlGg.js"),__vite__mapDeps([43,1,2,3,4])).then(n=>({default:n.BranchModal}))),Mye=y.lazy(()=>nt(()=>import("./WorkflowsPanel-DFIpG32k.js"),__vite__mapDeps([44,1,4,2,3])).then(n=>({default:n.WorkflowsPanel})));function zye(){window.location.reload()}function Dye(){var Bv,Wv,qv,Vv,Hv,Kv,Gv,Zv,Yv,Xv,Jv,Qv,ey,ty,ny,sy,ry,oy,iy,ay,ly,cy,uy,dy,fy,my;const n=ov(window.location.pathname),e=gve(),t=vye(),s=jve(t.edition),r=Tye(t.edition,s.edition),o=$r(),i=s.checked&&(s.edition==="personal"||s.user!==null),l=i&&s.capabilities.configWrite,c=i&&s.capabilities.hostFiles,u=i&&s.capabilities.terminal,d=nv(),f=C7(),[m,p]=w7(),{procBySession:h}=Vx(),{parse:g,append:x}=F7(),b=y.useCallback(Oe=>{p({type:"SET_OLDER_TURNS",turns:Oe})},[p]),w=y.useCallback((Oe,ct)=>{xye(Oe,ct,g)},[g]),v=U7({dirName:((Bv=m.sessionSource)==null?void 0:Bv.dirName)??null,fileName:((Wv=m.sessionSource)==null?void 0:Wv.fileName)??null,sessionChangeKey:m.sessionChangeKey,workerParse:g,onOlderTurns:b}),{loadMore:j}=v,k=!!m.searchQuery&&v.hasMore,_=((qv=m.session)==null?void 0:qv.turns.length)??0;y.useEffect(()=>{k&&j()},[k,j,_]);const N=qve(m,p),S=y.useRef(null),C=y.useRef(null),[E,T]=y.useState(!1),[$,A]=y.useState(!1),R=y.useCallback(()=>p({type:"TOGGLE_EXPAND_ALL"}),[p]),P=y.useCallback(()=>T(!0),[]),z=y.useCallback(()=>{var Oe;return(Oe=C.current)==null?void 0:Oe.focus()},[]),L=y.useCallback(()=>p({type:"SET_EXPAND_ALL",value:!0}),[p]),I=y.useCallback(()=>p({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0}),[p]),M=y.useCallback(()=>p({type:"SET_EXPAND_ALL",value:!1}),[p]),F=N.toggleWorkspacePanel,U=y.useCallback(()=>F(Ot.sessionInfo),[F]),O=y.useCallback(Oe=>{y.startTransition(()=>{p({type:"SET_DASHBOARD_PROJECT",dirName:Oe})})},[p]),D=m.pendingCwd??(m.pendingDirName?xs(m.pendingDirName):null),B=((Vv=m.sessionSource)==null?void 0:Vv.agentKind)??un(((Hv=m.sessionSource)==null?void 0:Hv.dirName)??m.pendingDirName??null),q=(Kv=m.session)!=null&&Kv.sessionId?h.get(m.session.sessionId):void 0,W=bn(B),H=$b(B,q),K=Iye(((Gv=m.session)==null?void 0:Gv.sessionId)??null),Z=wa(K.level),Y=W.worktrees,X=W.mcp&&l&&Z.mcp,ee=Bve(l?((Zv=m.session)==null?void 0:Zv.cwd)??D??void 0:void 0,l&&W.slashCommands),te=y.useCallback(Oe=>{if(!l)return;const ct=ee.suggestions.find(rn=>rn.name===Oe);y.startTransition(()=>{p({type:"OPEN_CONFIG",filePath:ct==null?void 0:ct.filePath})})},[l,p,ee.suggestions]),se=y.useCallback(async(Oe,ct)=>{if(!l)return null;const rn=ee.suggestions.find(zr=>zr.name===Oe);if(!(rn!=null&&rn.filePath))return null;try{const zr=await Ce("/api/expand-command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:rn.filePath,args:ct||""})});return zr.ok?(await zr.json()).content??null:null}catch{return null}},[l,ee.suggestions]),J=N.openWorkspacePanel,ne=y.useCallback(Oe=>{J(Oe),d&&p({type:"SET_MOBILE_TAB",tab:"workspace"})},[J,d,p]),ie=y.useCallback(()=>ne(Ot.crew),[ne]),ae=N.activeWorkspacePanel===Ot.crew&&(!d||m.mobileTab==="workspace"),{processPanel:oe,currentCwd:ue,showPreview:re,showProjectFiles:de,projectFilesRoot:fe,projectFilesRequest:le,launchTerminalRequest:ce,pendingProject:he,handleOpenTerminal:ge,handleMcpAuth:be,handleToggleIntegratedTerminal:ve,handleNewIntegratedTerminal:Se,handleTogglePreview:we,handleToggleProjectFiles:Ee,closeRightWorkspace:$e}=tye({sessionId:(Yv=m.session)==null?void 0:Yv.sessionId,sessionCwd:(Xv=m.session)==null?void 0:Xv.cwd,pendingPath:D,sessionDirName:(Jv=m.sessionSource)==null?void 0:Jv.dirName,pendingDirName:m.pendingDirName,dashboardProject:m.dashboardProject,supportsFileWorkspace:c,activeWorkspacePanel:N.activeWorkspacePanel,openWorkspacePanel:ne,closeWorkspacePanel:N.closeWorkspacePanel}),Be=Mve(m.session??null),[qe,ze]=y.useState(!1),Ie=((Qv=m.sessionSource)==null?void 0:Qv.dirName)??m.pendingDirName??m.dashboardProject??null,{activeWorkspacePanel:Me,closeWorkspacePanel:Ue,showWorkflows:De}=N,Ke=Tve(i&&Y&&m.mainView==="sessions"&&Me===Ot.worktrees?Ie:null),Ne=y.useMemo(()=>{const Oe=m.session;return Oe?Oe.turns.some(ct=>mf(ct.toolCalls,Oe.cwd)||ct.subAgentActivity.some(rn=>mf(rn.toolCalls,Oe.cwd))):!1},[m.session]),Ae=y.useMemo(()=>{if(!m.session||!W.workflows)return 0;let Oe=0;for(const ct of m.session.turns)for(const rn of ct.toolCalls)rn.name==="Workflow"&&Oe++;return Oe},[m.session,W.workflows]),Qe=Ae>0,Je=y.useMemo(()=>{const Oe=m.sessionSource;return!Oe||!W.workflows||$o(Oe.fileName)?{dirName:null,sessionId:null}:{dirName:Oe.dirName,sessionId:Ed(Oe.fileName)}},[m.sessionSource,W.workflows]),ke=wbe(Je.dirName,Je.sessionId,Qe),We=Qe||ke.workflows.length>0,ye=ke.workflows.length||Ae,Re=N.setShowWorkflows,Ve=y.useCallback(()=>Re(!0),[Re]),[He,me]=y.useState(!1);y.useEffect(()=>{if(!c)return;const Oe=()=>{d?me(!0):J(Ot.fileChanges)};return window.addEventListener(gc,Oe),()=>window.removeEventListener(gc,Oe)},[c,J,d]);const je=y.useMemo(()=>m.session?r6(m.session):null,[m.session]),Xe=y.useRef(null),{isLive:tt,sseState:dt,isCompacting:zt,streamingOverlayStore:st,turnError:Et,agentProgress:Tt,promptSuggestion:Jt,rateLimit:At}=b7(m.sessionSource,Oe=>{y.startTransition(()=>{p({type:"UPDATE_SESSION",session:Oe})})},g,x,()=>{var Oe;return(Oe=Xe.current)==null?void 0:Oe.call(Xe)},m.session),Qn=Uve(((ey=m.session)==null?void 0:ey.cwd)??null),kn=Kbe(B),Lr=kn.setMode,_n=Ybe(H?null:((ty=m.session)==null?void 0:ty.sessionId)??null),Is=H?null:_n.plan??je,{contextWindowTokens:Ps,setContextWindowTokens:cr,contextWindowAvailable:ur,selectedModel:us,setSelectedModel:$s,selectedEffort:Si,setSelectedEffort:ki,fastModeEnabled:Z7,ultracodeEnabled:Y7,effectiveEffort:Ua,fastModeAvailable:X7,fastModeActive:ru,setFastModeEnabled:Om,ultracodeAvailable:J7,ultracodeActive:ou,setUltracodeEnabled:Lm,imageInputAvailable:iv,modelFallbackNotice:Q7,dismissModelFallbackNotice:av,handleModelRejected:lv}=Zve({agentKind:B,session:m.session,sessionSource:m.sessionSource,pendingDirName:m.pendingDirName,isLive:tt}),cv=Ive((ny=m.session)==null?void 0:ny.sessionId,(sy=m.sessionSource)==null?void 0:sy.fileName),Ba=Qve({sessionKey:cv,sessionId:((ry=m.session)==null?void 0:ry.sessionId)??null,access:K.level,values:{model:us,effort:Si,contextWindowTokens:Ps,fastMode:Z7,ultracode:Y7,permissionMode:kn.config.mode},onHydrate:y.useCallback(Oe=>{cr(Oe.contextWindowTokens??null),Oe.model!==void 0&&$s(Oe.model),Oe.effort!==void 0&&ki(Oe.effort),Oe.fastMode!==void 0&&Om(Oe.fastMode),Oe.ultracode!==void 0&&Lm(Oe.ultracode),Oe.permissionMode&&Lr(Oe.permissionMode)},[cr,$s,ki,Om,Lm,Lr])}),uv=Ba.picked.includes("permissionMode")?kn.config:void 0,ds=Lve(X?ue:void 0,X?Ie??void 0:void 0,X?cv??void 0:void 0,X);y.useEffect(()=>{!Y&&Me===Ot.worktrees&&Ue()},[Y,Me,Ue]),y.useEffect(()=>{De&&!We&&Re(!1)},[De,We,Re]);const{creatingSession:dv,createError:fv,clearCreateError:eP,createAndSend:tP,cancelCreation:mv,worktreeEnabled:nP,setWorktreeEnabled:sP,sessionFinalizedRef:iu,liveSessionsRefreshRef:pv,pendingSessionInfo:hv,pendingAgentKindChange:rP,handleStartNewSession:au,handleStartNewFolder:gv}=pye({permissionsConfig:kn.config,dispatch:p,isMobile:d,defaultAgentKind:e.defaultAgentKind,pendingDirName:m.pendingDirName,pendingCwd:m.pendingCwd,onModelRejected:lv,model:us,effort:Ua,contextWindowTokens:ur?Ps:void 0,fastMode:ru,ultracode:ou,mcpConfig:X?ds.mcpConfigJson:null}),Dt=Nbe({sessionSource:m.sessionSource,parsedSessionId:((oy=m.session)==null?void 0:oy.sessionId)??null,cwd:(iy=m.session)==null?void 0:iy.cwd,permissions:uv,onPermissionsApplied:kn.markApplied,settingsChange:Ba.picked,onSettingsChangeSent:Ba.settlePicked,model:us,effort:Ua,contextWindowTokens:ur?Ps:void 0,fastMode:ru,ultracode:ou,mcpConfig:X?ds.mcpConfigJson:null,onModelRejected:lv,readOnly:H||!Z.send,onCreateSession:m.pendingDirName?tP:void 0}),[Mm,xv]=y.useState(null),bv=y.useCallback(async(Oe,ct,rn)=>{await au(Oe,ct),xv(rn)},[au]),vv=Dt.sendMessage;y.useEffect(()=>{!Mm||!m.pendingDirName||(xv(null),vv(Mm))},[Mm,m.pendingDirName,vv]);const yv={selectedModel:us,onModelChange:$s,selectedEffort:Ua,onEffortChange:ki},En=vbe(W.agentTeams?((ay=m.sessionSource)==null?void 0:ay.fileName)??null:null,((ly=m.sessionSource)==null?void 0:ly.dirName)??null);y.useEffect(()=>{En!=null&&En.currentMemberName?p({type:"SET_CURRENT_MEMBER_NAME",name:En.currentMemberName}):En||p({type:"SET_CURRENT_MEMBER_NAME",name:null})},[En==null?void 0:En.currentMemberName,En,p]),y.useEffect(()=>{d&&p({type:"GUARD_MOBILE_TAB",hasSession:!!m.session||!!m.pendingDirName})},[m.session,m.pendingDirName,m.mobileTab,d,p]);const dr=S7({session:m.session,isLive:tt,pendingMessages:Dt.pendingMessages,consumePending:Dt.consumePending,sessionChangeKey:m.sessionChangeKey}),wv=dr.chatScrollRef,Sv=dr.resetTurnCount,kv=dr.scrollToBottomInstant,oP=y.useCallback(Oe=>{ze(Oe),requestAnimationFrame(()=>{const ct=wv.current;ct&&ct.scrollTo({top:ct.scrollTop+(Oe?64:-64),behavior:"smooth"})})},[wv]);y.useLayoutEffect(()=>{const Oe=ct=>{Sv(0),kv()};return iu.current=Oe,()=>{iu.current===Oe&&(iu.current=null)}},[Sv,kv,iu]);const iP=y.useCallback(()=>{Dt.disconnect(),mv()},[Dt.disconnect,mv]),ys=Ebe({dispatch:p,isMobile:d,mobileTab:m.mobileTab,teamContext:En,scrollToBottomInstant:dr.scrollToBottomInstant,resetTurnCount:dr.resetTurnCount,workerParse:g,onBeforeSwitch:iP}),aP=y.useCallback(Oe=>{y.startTransition(()=>{p({type:"GO_HOME",isMobile:d}),p({type:"SET_DASHBOARD_PROJECT",dirName:Oe})})},[p,d]),{previewLoadError:lP}=Pbe({state:m,dispatch:p,isMobile:d,resetTurnCount:dr.resetTurnCount,scrollToBottomInstant:dr.scrollToBottomInstant,workerParse:g}),Wa=Dbe();Bbe({openSessionId:(m.sessionSource&&kx(m.sessionSource.dirName,m.sessionSource.fileName))??((cy=m.session)==null?void 0:cy.sessionId)??null,leave:ys.handleCloseSession,forgetVisits:Wa.forget});const jv=Wa.push;y.useEffect(()=>{m.sessionSource&&jv(m.sessionSource.dirName,m.sessionSource.fileName)},[m.sessionSource,jv]);const Vt=Kve({state:{session:m.session,sessionSource:m.sessionSource},dispatch:p,isMobile:d,handleJumpToTurn:ys.handleJumpToTurn,markPermissionsApplied:kn.markApplied,hasPermsPendingChanges:kn.hasPendingChanges,permissionsConfig:uv,settingsChange:Ba.picked,onSettingsChangeSent:Ba.settlePicked,selectedModel:us,selectedEffort:Ua,fastMode:ru,ultracode:ou,mcpConfig:X?ds.mcpConfigJson:null,scrollRequestScrollToTop:dr.requestScrollToTop,handleDashboardSelect:ys.handleDashboardSelect,workerParse:g,canInteract:Z.canInteract}),{hasSettingsChanges:Nv,handleApplySettings:Cv}=Vt,_v=X&&ds.mcpConfigJson!==null,Ev=y.useRef(!1);y.useEffect(()=>{var rn;const Oe=ds.loaded&&!Ev.current;Ev.current=ds.loaded;const ct=(rn=m.session)==null?void 0:rn.sessionId;Oe&&ct&&_v&&Nv&&Cv()},[ds.loaded,_v,Nv,Cv,(uy=m.session)==null?void 0:uy.sessionId]),y.useLayoutEffect(()=>(Xe.current=Vt.reloadSession,()=>{Xe.current===Vt.reloadSession&&(Xe.current=null)}),[Vt.reloadSession]);const Mr=L7(m.session,m.sessionSource,Vt.reloadSession,c&&Z.undo),lu=Mr.requestBranchSwitch,cu=Vt.setBranchModalTurn,cP=y.useCallback((Oe,ct)=>{lu(Oe,ct),cu(null)},[lu,cu]),uP=y.useCallback(Oe=>{lu(Oe),cu(null)},[lu,cu]);Obe({isMobile:d,searchInputRef:S,chatInputRef:C,dispatch:p,onToggleSidebar:N.handleToggleSidebar,onToggleRightSidebar:U,onToggleMissionControl:N.handleToggleMission,onOpenCommandPalette:P,onOpenProjectSwitcher:N.handleOpenProjectSwitcher,onOpenThemeSelector:N.handleToggleThemeSelector,onOpenTerminal:ge,onToggleIntegratedTerminal:ve,onTogglePreview:we,onToggleProjectFiles:Ee,onHistoryBack:Wa.goBack,onHistoryForward:Wa.goForward,onNavigateToSession:ys.handleDashboardSelect,onCommitNavigation:Wa.commitNavigation});const{killing:dP,handleKillAll:fP}=Ave(),co=m.sessionSource?$o(m.sessionSource.fileName):null,mP=co!==null&&!!(En!=null&&En.currentMemberName),zm=co!==null&&!mP,uu=ys.handleDashboardSelect,Tv=y.useCallback(()=>{!m.sessionSource||!co||uu(m.sessionSource.dirName,co.parentFileName)},[m.sessionSource,co,uu]);y.useEffect(()=>{const Oe=ct=>{const{agentId:rn}=ct.detail??{};if(!rn||!m.sessionSource||!W.subagentTranscripts)return;const zr=co?co.parentSessionId:Ed(m.sessionSource.fileName);uu(m.sessionSource.dirName,`${zr}/subagents/agent-${rn}.jsonl`)};return window.addEventListener(hf,Oe),()=>window.removeEventListener(hf,Oe)},[m.sessionSource,co,uu,W.subagentTranscripts]);const[pP,Av]=y.useState(null),hP=Vt.branchModalTurn!==null,ji=Vt.branchModalTurn??pP;y.useEffect(()=>{Vt.branchModalTurn!==null&&Av(Vt.branchModalTurn)},[Vt.branchModalTurn]);const Iv=ji!==null?Mr.branchesAtTurn(ji):[];let Ni=null;zm?Ni={kind:"subagent"}:H?Ni={kind:"external",agentKind:B}:Ni=Pye(K);const Dm=Ni&&a.jsx($ye,{reason:Ni}),uo=((dy=m.session)==null?void 0:dy.sessionId)??null,Ci=uo!==null&&Ni===null&&m.mainView==="sessions"&&(!d||m.mobileTab==="chat"),[gP,Fm]=y.useState(null);y.useEffect(()=>{Fm(null)},[uo,Ci]);const Pv=y.useCallback(()=>{Ci&&Fm(uo)},[uo,Ci]),xP=y.useCallback(Oe=>{Fm(ct=>Oe?uo:ct===uo?null:ct)},[uo]),bP=ys.loadError||fv||null;let Um;ys.loadError?Um=ys.clearLoadError:fv&&(Um=eP);const vP=!!(m.session&&m.sessionSource&&dt==="disconnected"),Bm=y.useMemo(()=>({state:m,dispatch:p,config:e,theme:f,isMobile:d}),[m.activeTurnIndex,m.activeToolCallId,m.searchQuery,m.expandAll,m.expandToolPayloads,m.mainView,m.extensionViewId,m.mobileTab,m.dashboardProject,m.pendingDirName,m.pendingCwd,m.currentMemberName,m.loadingMember,m.configFilePath,m.sessionChangeKey,p,e,f,d]),Wm=y.useMemo(()=>({session:m.session,sessionSource:m.sessionSource,isLive:tt,sseState:dt,isCompacting:zt,turnError:Et,promptSuggestion:Jt,rateLimit:At,undoRedo:Mr,pendingInteraction:Is,permissionRequests:_n.requests,permissionResponding:_n.responding,respondPermission:_n.respond,respondAllPermissions:_n.respondAll,isSubAgentView:zm,permissions:Z,slashSuggestions:ee.suggestions,slashSuggestionsLoading:ee.loading,actions:{handleStopSession:Vt.handleStopSession,handleEditConfig:l?N.handleEditConfig:void 0,handleEditCommand:l?te:void 0,handleExpandCommand:l?se:void 0,handleOpenBranches:Vt.handleOpenBranches,handleBranchFromHere:Vt.handleBranchFromHere,handleToggleExpandAll:R,handleLoadSession:Vt.handleLoadSessionScrollAware,handleProviderHandoff:Ci?Pv:void 0}}),[m.session,m.sessionSource,tt,dt,zt,Et,Jt,At,Mr,Is,zm,Z,_n.requests,_n.responding,_n.respond,_n.respondAll,ee.suggestions,ee.loading,Vt.handleStopSession,l,N.handleEditConfig,te,se,Vt.handleOpenBranches,Vt.handleBranchFromHere,R,Vt.handleLoadSessionScrollAware,Ci,Pv]),qm=y.useMemo(()=>({chat:{status:Dt.status,error:Dt.error,pendingMessages:Dt.pendingMessages,isConnected:Dt.isConnected,sendMessage:Dt.sendMessage,interrupt:Dt.interrupt,stopAgent:Dt.stopAgent,consumePending:Dt.consumePending},scroll:dr}),[Dt.status,Dt.error,Dt.pendingMessages,Dt.isConnected,Dt.sendMessage,Dt.interrupt,Dt.stopAgent,Dt.consumePending,dr]),qa=!!m.pendingDirName&&!m.session;if(y.useEffect(()=>{if(!qa||d)return;const Oe=requestAnimationFrame(()=>{var ct;return(ct=C.current)==null?void 0:ct.focus()});return()=>cancelAnimationFrame(Oe)},[qa,d,m.pendingDirName]),r.failed)return a.jsx(kye,{onRetry:r.retry});if(!t.authChecked||!r.serverReady)return a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas",role:"status","aria-label":"Checking authentication",children:a.jsx(St,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(!t.authenticated){const Oe=o.SetupScreen;return t.setupRequired&&Oe?a.jsx(Oe,{onAuthenticated:t.handleAuthenticated,onSetupClosed:t.refreshServerState}):a.jsx(bye,{onAuthenticated:t.handleAuthenticated,setupRequired:t.setupRequired})}if(!i||!r.ready)return a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas",role:"status","aria-label":"Loading identity",children:a.jsx(St,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(s.gate){const Oe=o.GateScreen??wye;return a.jsxs(a.Fragment,{children:[a.jsx(Oe,{gate:s.gate,onRestored:zye,onLogout:t.logout}),a.jsx(Qy,{activeError:null,modelFallbackNotice:null,dismissModelFallbackNotice:av,connectionLost:!1,theme:f.activeTheme})]})}if(e.configLoading)return a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas",role:"status","aria-label":"Loading",children:a.jsx(St,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(e.configError)return a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas text-foreground",children:a.jsxs(Ln,{children:[a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:a.jsx(Ir,{className:"text-destructive"})}),a.jsx(zn,{children:"Failed to connect"}),a.jsx(Dn,{children:e.configError})]}),a.jsx(_c,{children:a.jsxs(Q,{variant:"outline",size:"sm",onClick:e.retryConfig,children:[a.jsx(Fn,{"data-icon":"inline-start"}),"Retry"]})})]})});if(!e.claudeDir)return l?a.jsx(Kte,{onConfigured:e.setClaudeDir}):a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas text-sm text-muted-foreground",children:"Cogpit is waiting for an administrator to finish server setup."});const Vm=a.jsx(Qy,{activeError:bP,clearActiveError:Um,modelFallbackNotice:Q7,dismissModelFallbackNotice:av,connectionLost:vP,theme:f.activeTheme}),$v=c?a.jsx(zte,{state:Mr.confirmState,isApplying:Mr.isApplying,applyError:Mr.applyError,onConfirm:Mr.confirmApply,onCancel:Mr.confirmCancel}):null,yP=ji!==null&&m.session?m.session.turns.slice(ji):[],Rv=c&&ji!==null&&Iv.length>0&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(Lye,{open:hP,branches:Iv,branchPointTurnIndex:ji,currentTurns:yP,onClose:Vt.handleCloseBranchModal,onCloseComplete:()=>Av(null),onRedoToTurn:cP,onRedoEntireBranch:uP})}),Ov=u&&a.jsx(_te,{processes:oe.processes,activeProcessId:oe.activeProcessId,collapsed:oe.collapsed,onSetActive:oe.setActive,onRemove:oe.removeProcess,onToggleCollapse:oe.toggleCollapse,onRequestTerminal:xt("terminal")?Se:void 0,onAddTerminalContext:Oe=>{var py,hy,gy;const ct=Oe.trim();if(!ct)return;const rn=ct.includes("```")?"````":"```",zr=`${rn}terminal
492
+ `)[0].trim();return t.length<=60?t:t.slice(0,57)+"..."}const iye={totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:0};function B7(n,e){return{dirName:n.dirName,fileName:n.fileName,rawText:e,agentKind:un(n.dirName)}}function aye(n){return{sessionId:n.sessionId,version:"",gitBranch:"",cwd:"",slug:"",name:"",model:"",turns:[],stats:{...iye},rawMessages:[],agentKind:un(n.dirName)}}function W7(n,e){if(!(n!=null&&n.trim()))return null;try{return{rawText:n,parsed:ra(xm(n),Yr(e).instanceId)}}catch{return null}}async function lye(n,e,t=3,s=100,r=!0){if(r){const o=W7(n.initialContent,n.dirName);if(o)return o}for(let o=0;o<t;o++){if(e.signal.aborted)throw new DOMException("Aborted","AbortError");const i=await Ce(`/api/sessions/${encodeURIComponent(n.dirName)}/${encodeURIComponent(n.fileName)}`,{signal:e.signal});if(i.ok){const l=await i.text();if(l.trim())try{return{rawText:l,parsed:ra(xm(l),Yr(n.dirName).instanceId)}}catch{}}o<t-1&&await new Promise(l=>setTimeout(l,s))}return null}async function cye(n,e,t,s){let r=s;for(let o=0;o<30;o++){if(e.signal.aborted)return;const i=await lye(n,e,1,0,!1);if(i&&i.rawText!==r){t({type:"RELOAD_SESSION_CONTENT",session:i.parsed,source:B7(n,i.rawText)});return}r=(i==null?void 0:i.rawText)??r,await new Promise(l=>setTimeout(l,200))}}async function uye(n,e,t,s,r){const o=W7(n.initialContent,n.dirName),i=(o==null?void 0:o.rawText)??"",l=(o==null?void 0:o.parsed)??aye(n),c=B7(n,i);return t({type:"FINALIZE_SESSION",session:l,source:c,isMobile:s}),r(l,c),cye(n,e,t,i),n.sessionId}function dye(n){return n.access?n.access.mine:!0}async function fye(n,e,t,s){const r=Xr(),o=await Ce(`/api/sessions/${encodeURIComponent(n)}?page=1&limit=10`,{signal:s.signal});if(!o.ok)return null;const i=await o.json();aa(i.sessions??[],r);const l=t-3e4,c=e.trim(),u=(i.sessions??[]).filter(f=>{const m=f.lastModified?new Date(f.lastModified).getTime():0;return Number.isFinite(m)&&m>=l&&dye(f)}),d=u.find(f=>{var m,p;return((m=f.firstUserMessage)==null?void 0:m.trim())===c||((p=f.lastUserMessage)==null?void 0:p.trim())===c})??u[0];return d?{dirName:n,fileName:d.fileName,sessionId:d.sessionId}:null}function mye({permissionsConfig:n,dispatch:e,isMobile:t,onSessionFinalized:s,onCreateStarted:r,onModelRejected:o,model:i,effort:l,contextWindowTokens:c,fastMode:u,ultracode:d,mcpConfig:f}){const[m,p]=y.useState(!1),[h,g]=y.useState(null),[x,b]=y.useState(!1),w=y.useRef(null),v=y.useRef(null),j=y.useRef(null),k=y.useCallback((C,E)=>{v.current=C,j.current=E??null,g(null),p(!1),e({type:"INIT_PENDING_SESSION",dirName:C,cwd:E,isMobile:t})},[e,t]),_=y.useCallback(async(C,E)=>{var I;const T=v.current;if(!T)return null;const $=un(T),A=j.current;(I=w.current)==null||I.abort();const R=new AbortController;w.current=R,p(!0),g(null),r==null||r(C);const P=Date.now(),z=oye(C);async function L(M){v.current=null,j.current=null,UN(M.sessionId);const F=await uye(M,R,e,t,s);return z&&F&&VN(F,z),F}try{const M=Cn($),{capabilities:F}=M,U={dirName:T,cwd:M.dirName.lossy?A??void 0:void 0,message:C,images:E,permissions:n,effort:l||void 0,contextWindowTokens:c,fastMode:u?!0:void 0,ultracode:F.ultracode&&d?!0:void 0,name:F.namedSessions&&z||void 0,worktreeName:F.worktrees&&x?e9(C):void 0,mcpConfig:F.mcp&&f||void 0},{res:O,errorMessage:D,errorCode:B}=await y7(q=>Ce("/api/create-and-send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...U,model:q}),signal:R.signal}),{model:i,agentKind:$,errorFallback:"Unknown error",onModelRejected:o});if(!O.ok){if($==="codex"&&B!=="SESSION_UNCONFIRMED"){const q=await fye(T,C,P,R);if(q)return await L(q)}return g(D||`Failed to create session (${O.status})`),null}return await L(await O.json())}catch(M){return R.signal.aborted||g(M instanceof Error?M.message:"Failed to create session"),null}finally{R.signal.aborted||p(!1)}},[n,i,l,c,u,d,f,x,e,t,s,r,o]),N=y.useCallback(()=>g(null),[]),S=y.useCallback(()=>{var C;(C=w.current)==null||C.abort(),w.current=null,v.current=null,j.current=null,p(!1),g(null)},[]);return{creatingSession:m,createError:h,clearCreateError:N,handleNewSession:k,createAndSend:_,cancelCreation:S,worktreeEnabled:x,setWorktreeEnabled:b}}function pye(n){const e=V.c(41),{permissionsConfig:t,dispatch:s,isMobile:r,defaultAgentKind:o,pendingDirName:i,pendingCwd:l,model:c,effort:u,contextWindowTokens:d,fastMode:f,ultracode:m,mcpConfig:p,onModelRejected:h}=n,g=y.useRef(null),x=y.useRef(null),[b,w]=y.useState(null);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=W=>{var H;(H=g.current)==null||H.call(g,W),setTimeout(()=>{var K;return(K=x.current)==null?void 0:K.call(x)},300),setTimeout(()=>{var K;return(K=x.current)==null?void 0:K.call(x)},2e3)},e[0]=v):v=e[0];let j;e[1]!==d||e[2]!==s||e[3]!==u||e[4]!==f||e[5]!==r||e[6]!==p||e[7]!==c||e[8]!==h||e[9]!==t||e[10]!==m?(j={permissionsConfig:t,dispatch:s,isMobile:r,onSessionFinalized:v,onCreateStarted:w,onModelRejected:h,model:c,effort:u,contextWindowTokens:d,fastMode:f,ultracode:m,mcpConfig:p},e[1]=d,e[2]=s,e[3]=u,e[4]=f,e[5]=r,e[6]=p,e[7]=c,e[8]=h,e[9]=t,e[10]=m,e[11]=j):j=e[11];const k=mye(j),_=k.handleNewSession,[N,S]=y.useState(null);let C;e[12]===Symbol.for("react.memo_cache_sentinel")?(C=new Map,e[12]=C):C=e[12];const E=y.useRef(C),T=hye;let $;e[13]===Symbol.for("react.memo_cache_sentinel")?($=async W=>{if(pu===null)return null;const H=E.current;if(H.has(W))return H.get(W)??null;const K=cR(await T(),W,pu);return H.set(W,K),K},e[13]=$):$=e[13];const A=$;let R;e[14]!==_?(R=async(W,H)=>{var X;const K=H??((X=(await T()).find(ee=>ee.dirName===W))==null?void 0:X.path)??null;if(!K){S(null),_(W);return}if(Yr(W).instanceId!=="default"){S({discoveredDirName:null,cwd:K}),_(W,K);return}const Z=un(W)===pu?pu:null,Y=Z?Gm(Z,K):await A(K);S({discoveredDirName:Y,cwd:K}),_(Z&&Y?Y:W,K)},e[14]=_,e[15]=R):R=e[15];const P=R;let z;e[16]!==o||e[17]!==P?(z=W=>{const H=Gm(o,W);P(H,W)},e[16]=o,e[17]=P,e[18]=z):z=e[18];const L=z;let I;e[19]!==_||e[20]!==N?(I=W=>{if(!N)return;const H=Gm(W,N.cwd,N.discoveredDirName??void 0);_(H,N.cwd)},e[19]=_,e[20]=N,e[21]=I):I=e[21];const M=I;let F;e:{if(!k.creatingSession||!i){F=null;break e}const W=b??void 0;let H;e[22]!==l||e[23]!==i||e[24]!==W?(H={dirName:i,cwd:l,firstMessage:W},e[22]=l,e[23]=i,e[24]=W,e[25]=H):H=e[25],F=H}const U=F;let O,D;e[26]!==i?(D=()=>{i||(w(null),S(null))},O=[i],e[26]=i,e[27]=O,e[28]=D):(O=e[27],D=e[28]),y.useEffect(D,O);const B=N?M:void 0;let q;return e[29]!==L||e[30]!==P||e[31]!==k.cancelCreation||e[32]!==k.clearCreateError||e[33]!==k.createAndSend||e[34]!==k.createError||e[35]!==k.creatingSession||e[36]!==k.setWorktreeEnabled||e[37]!==k.worktreeEnabled||e[38]!==U||e[39]!==B?(q={creatingSession:k.creatingSession,createError:k.createError,clearCreateError:k.clearCreateError,createAndSend:k.createAndSend,cancelCreation:k.cancelCreation,worktreeEnabled:k.worktreeEnabled,setWorktreeEnabled:k.setWorktreeEnabled,sessionFinalizedRef:g,liveSessionsRefreshRef:x,pendingSessionInfo:U,pendingAgentKindChange:B,handleStartNewSession:P,handleStartNewFolder:L},e[29]=L,e[30]=P,e[31]=k.cancelCreation,e[32]=k.clearCreateError,e[33]=k.createAndSend,e[34]=k.createError,e[35]=k.creatingSession,e[36]=k.setWorktreeEnabled,e[37]=k.worktreeEnabled,e[38]=U,e[39]=B,e[40]=q):q=e[40],q}async function hye(){try{const n=await Ce("/api/projects");return n.ok?await n.json():[]}catch{return[]}}const fg=new Set;function gye(n,e){const t=cn(),s=Zn();return`${s===null?t:`${t}:${s}`}:${n}/${e}`}async function xye(n,e,t){const s=gye(n,e);if(!fg.has(s)&&!js.get(n,e)){fg.add(s);try{await Sa(n,e,t,"session prefetch",{background:!0})}catch{}finally{fg.delete(s)}}}function bye({onAuthenticated:n,setupRequired:e=!1}){const[t,s]=y.useState(null),[r,o]=y.useState(""),[i,l]=y.useState(""),[c,u]=y.useState(!1),[d,f]=y.useState(null),[m,p]=y.useState(!1),h=t==="account",{LoginNotice:g}=$r();y.useEffect(()=>{let w=!1;return fN().then(v=>{w||s(v)}),()=>{w=!0}},[]);const x=y.useCallback(async w=>{if(w.preventDefault(),!(!i.trim()||h&&!r.trim())){p(!0),f(null);try{const v=await fetch("/api/auth/verify",h?{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json","X-Cogpit-Client":"1"},body:JSON.stringify({username:r.trim(),password:i})}:{method:"POST",credentials:"same-origin",cache:"no-store",headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json","X-Cogpit-Client":"1"}}),j=await v.json();v.ok&&j.valid?(Tf(),l(""),o(""),n()):f(j.error||(h?"Invalid credentials":"Invalid password"))}catch{f("Failed to connect to server")}finally{p(!1)}}},[h,n,i,r]),b=m||!i.trim()||h&&!r.trim();return a.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-canvas px-4 py-8",children:a.jsx("form",{onSubmit:x,className:"w-full max-w-sm",children:a.jsxs(Ds,{children:[a.jsxs(gr,{children:[a.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:a.jsx(F8,{className:"size-4"})}),a.jsx(xr,{children:"Sign in to Cogpit"}),a.jsx(br,{children:h?"Sign in with your account to continue.":"Enter the server password to continue."})]}),t===null?a.jsx(Fs,{children:a.jsx("div",{className:"flex min-h-24 items-center justify-center",role:"status","aria-label":"Checking server",children:a.jsx(Pn,{className:"size-5 text-muted-foreground"})})}):a.jsxs(a.Fragment,{children:[a.jsxs(Fs,{className:"flex flex-col gap-4",children:[e&&a.jsxs(jt,{children:[a.jsx(yf,{"aria-hidden":"true"}),a.jsx(Rt,{children:"This server has no accounts yet."})]}),a.jsxs(Ta,{children:[h&&a.jsxs(fn,{children:[a.jsx(mn,{htmlFor:"login-username",children:"Username"}),a.jsx(On,{id:"login-username",type:"text",value:r,onChange:w=>o(w.target.value),placeholder:"Username",autoComplete:"username",autoFocus:!0})]}),a.jsxs(fn,{children:[a.jsx(mn,{htmlFor:"login-password",children:"Password"}),a.jsxs(Ko,{children:[a.jsx(Go,{id:"login-password",type:c?"text":"password",value:i,onChange:w=>l(w.target.value),placeholder:"Password",autoComplete:"current-password",autoFocus:!h}),a.jsx(Tr,{align:"inline-end",children:a.jsx(dm,{size:"icon-xs",onClick:()=>u(w=>!w),"aria-label":c?"Hide password":"Show password",children:c?a.jsx(ux,{}):a.jsx(ja,{})})})]})]})]}),h&&g&&a.jsx(g,{}),d&&a.jsxs(jt,{variant:"destructive",children:[a.jsx(wr,{"aria-hidden":"true"}),a.jsx(tn,{children:"Sign in failed"}),a.jsx(Rt,{children:d})]})]}),a.jsx(um,{children:a.jsxs(Q,{type:"submit",className:"w-full",disabled:b,children:[m&&a.jsx(Pn,{"data-icon":"inline-start"}),"Connect"]})})]})]})})})}function vye(){const n=V.c(18);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=Ef(),n[0]=e):e=n[0];const t=e,[s,r]=y.useState(null),[o,i]=y.useState(!1),[l,c]=y.useState(!1),u=y.useRef(0);let d,f;n[1]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{let $=!1;return dN().then(A=>{$||r(A)}),()=>{$=!0}},f=[],n[1]=d,n[2]=f):(d=n[1],f=n[2]),y.useEffect(d,f);const m=t?!0:s===null?null:s.signIn==="account";let p,h;n[3]!==m?(p=()=>{if(m===null)return;if(!m){i(!0),c(!0);return}let $=!1;const A=u.current;return IR().then(R=>{!$&&u.current===A&&(i(R),c(!0))}),()=>{$=!0}},h=[m],n[3]=m,n[4]=p,n[5]=h):(p=n[4],h=n[5]),y.useEffect(p,h);let g;n[6]!==(s==null?void 0:s.signIn)?(g=()=>{let $=!1;const A=()=>{const R=u.current=u.current+1,P=()=>{$||u.current!==R||(i(!1),c(!0))};if(t||(s==null?void 0:s.signIn)==="account"){P();return}_y().then(z=>{$||u.current!==R||(r(z),z.signIn==="account"&&P())})};return window.addEventListener("cogpit-auth-required",A),()=>{$=!0,window.removeEventListener("cogpit-auth-required",A)}},n[6]=s==null?void 0:s.signIn,n[7]=g):g=n[7];const x=s==null?void 0:s.signIn;let b;n[8]!==x?(b=[x,t],n[8]=x,n[9]=b):b=n[9],y.useEffect(g,b);let w;n[10]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{u.current=u.current+1,i(!0),c(!0),window.dispatchEvent(new Event("cogpit-auth-changed"))},n[10]=w):w=n[10];const v=w;let j;n[11]===Symbol.for("react.memo_cache_sentinel")?(j=async()=>{r(await _y())},n[11]=j):j=n[11];const k=j;let _;n[12]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{B9(),u.current=u.current+1,i(!1),c(!0),PR().finally(yye)},n[12]=_):_=n[12];const N=_,S=(s==null?void 0:s.edition)??null,C=l&&s!==null,E=(s==null?void 0:s.setupRequired)===!0;let T;return n[13]!==o||n[14]!==S||n[15]!==C||n[16]!==E?(T={isRemote:t,edition:S,authChecked:C,authenticated:o,setupRequired:E,handleAuthenticated:v,refreshServerState:k,logout:N},n[13]=o,n[14]=S,n[15]=C,n[16]=E,n[17]=T):T=n[17],T}function yye(){window.dispatchEvent(new Event("cogpit-auth-changed"))}function wye(n){const e=V.c(18),{onRestored:t,onLogout:s}=n,{activeDevice:r,activeDeviceId:o}=Fa();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=qo(),e[0]=i):i=e[0];const l=i,c=l?(r==null?void 0:r.name)??o:"This server";let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u=a.jsx(Yn,{variant:"icon",children:a.jsx(ix,{className:"text-destructive"})}),e[1]=u):u=e[1];let d;e[2]!==c?(d=a.jsxs(zn,{children:[c," isn’t available to your account right now"]}),e[2]=c,e[3]=d):d=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=a.jsx(Dn,{children:"Its administrator can let you back in. Check again once they have."}),e[4]=f):f=e[4];let m;e[5]!==d?(m=a.jsxs(Mn,{children:[u,d,f]}),e[5]=d,e[6]=m):m=e[6];let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx(Fn,{"data-icon":"inline-start"}),e[7]=p):p=e[7];let h;e[8]!==t?(h=a.jsxs(Q,{size:"sm",onClick:t,children:[p,"Check again"]}),e[8]=t,e[9]=h):h=e[9];let g;e[10]!==s?(g=l?a.jsxs(Q,{variant:"outline",size:"sm",onClick:Sye,children:[a.jsx(bg,{"data-icon":"inline-start"}),"Switch to this machine"]}):a.jsxs(Q,{variant:"outline",size:"sm",onClick:s,children:[a.jsx(U8,{"data-icon":"inline-start"}),"Sign out"]}),e[10]=s,e[11]=g):g=e[11];let x;e[12]!==h||e[13]!==g?(x=a.jsxs(_c,{className:"flex-row justify-center",children:[h,g]}),e[12]=h,e[13]=g,e[14]=x):x=e[14];let b;return e[15]!==m||e[16]!==x?(b=a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas text-foreground",children:a.jsxs(Ln,{children:[m,x]})}),e[15]=m,e[16]=x,e[17]=b):b=e[17],b}function Sye(){return Xs(Lt)}function kye(n){const e=V.c(4),{onRetry:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:a.jsx(B8,{className:"text-destructive"})}),a.jsx(zn,{children:"Cogpit couldn’t finish loading"}),a.jsx(Dn,{children:"Part of this server’s interface didn’t download. Check your connection and try again."})]}),e[0]=s):s=e[0];let r;e[1]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Fn,{"data-icon":"inline-start"}),e[1]=r):r=e[1];let o;return e[2]!==t?(o=a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas text-foreground",children:a.jsxs(Ln,{children:[s,a.jsx(_c,{className:"flex-row justify-center",children:a.jsxs(Q,{size:"sm",onClick:t,children:[r,"Retry"]})})]})}),e[2]=t,e[3]=o):o=e[3],o}const Y1="cogpit:edition-ui-reloaded";let mg=null;function jye(){return mg??(mg=nt(()=>import("./edition-ui-CXQDiuhB.js"),__vite__mapDeps([42,1,2,29,3,4])).then(n=>n.default,n=>{throw mg=null,n})),mg}function Nye(){try{if(sessionStorage.getItem(Y1)!==null)return!1;sessionStorage.setItem(Y1,"1")}catch{return!1}return window.location.reload(),!0}function q7(){try{sessionStorage.removeItem(Y1)}catch{}}async function Cye(n,e){let t;try{t=await jye()}catch{return e&&Nye()?"reloading":"failed"}return q7(),(t==null?void 0:t.edition)===n?t:null}async function V7(n,e,t){V9();const s=await Cye(n,t);s!=="reloading"&&(s==="failed"&&e?(q7(),K9()):s===null||s==="failed"?H9():q9(s))}async function _ye(n,{required:e=!1}={}){if(n==="personal")return;const t=ec();t==="installed"||t==="loading"||t==="failed"||await V7(n,e,!0)}async function Eye(n){ec()==="failed"&&await V7(n,!0,!1)}function o4(n){return n==="personal"?null:n}function Tye(n,e){const t=V.c(16),s=y.useSyncExternalStore(Wx,ec,ec);let r;t[0]!==n?(r=o4(n),t[0]=n,t[1]=r):r=t[1];const o=r;let i;t[2]!==e||t[3]!==o?(i=o??o4(e),t[2]=e,t[3]=o,t[4]=i):i=t[4];const l=i,c=o!==null;let u,d;t[5]!==c||t[6]!==l?(u=()=>{l!==null&&_ye(l,{required:c})},d=[l,c],t[5]=c,t[6]=l,t[7]=u,t[8]=d):(u=t[7],d=t[8]),y.useEffect(u,d);let f;t[9]!==l?(f=()=>{l!==null&&Eye(l)},t[9]=l,t[10]=f):f=t[10];const m=f,p=s==="installed"||s==="unavailable",h=o===null||p,g=l===null||p,x=c&&s==="failed";let b;return t[11]!==m||t[12]!==h||t[13]!==g||t[14]!==x?(b={serverReady:h,ready:g,failed:x,retry:m},t[11]=m,t[12]=h,t[13]=g,t[14]=x,t[15]=b):b=t[15],b}const H7={level:"own"},i4={level:"unknown"},Aye={none:{level:"none"},view:{level:"view"},interact:{level:"interact"},own:H7};function Iye(n){const e=V.c(5),{enforcesSessionAccess:t}=AN(),s=t?n:null;let r;e[0]!==s?(r=()=>s?rO(s):void 0,e[0]=s,e[1]=r):r=e[1];const o=r,i=y.useSyncExternalStore(iO,o,o);let l,c;return e[2]!==s?(l=()=>s?uO(s):void 0,c=[s],e[2]=s,e[3]=l,e[4]=c):(l=e[3],c=e[4]),y.useEffect(l,c),t===null?i4:s?i?Aye[i]:i4:H7}function Pye({level:n}){return n==="unknown"?{kind:"checking"}:n==="none"?{kind:"no-access"}:wa(n).canInteract?null:{kind:"view-only"}}function $ye(n){const e=V.c(8),{reason:t}=n;switch(t.kind){case"subagent":{let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(wd,{icon:mi,children:"Viewing sub-agent session (read-only)"}),e[0]=s):s=e[0],s}case"external":{let s;e[1]!==t.agentKind?(s=CM(t.agentKind),e[1]=t.agentKind,e[2]=s):s=e[2];let r;return e[3]!==s?(r=a.jsx(wd,{icon:mi,status:!0,children:s}),e[3]=s,e[4]=r):r=e[4],r}case"no-access":{let s;return e[5]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(wd,{icon:q8,status:!0,children:"You don't have access to this session"}),e[5]=s):s=e[5],s}case"checking":{let s;return e[6]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(a4,{icon:W8,children:"Checking access…"}),e[6]=s):s=e[6],s}case"view-only":{let s;return e[7]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(a4,{icon:ja,children:a.jsx(Rye,{})}),e[7]=s):s=e[7],s}}}function Rye(){const n=V.c(3),{ReadOnlyNote:e}=$r(),{session:t}=kt();let s;return n[0]!==e||n[1]!==t?(s=e&&t?a.jsx(e,{sessionId:t.sessionId}):"View only",n[0]=e,n[1]=t,n[2]=s):s=n[2],s}function a4(n){const e=V.c(4),{icon:t,children:s}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Oye,{}),e[0]=r):r=e[0];let o;return e[1]!==s||e[2]!==t?(o=a.jsxs("div",{className:"shrink-0",children:[r,a.jsx(wd,{icon:t,status:!0,children:s})]}),e[1]=s,e[2]=t,e[3]=o):o=e[3],o}function Oye(){const n=V.c(7),{pendingInteraction:e,permissionRequests:t}=kt(),s=(e==null?void 0:e.type)==="plan"?e:null;if(!s&&t.length===0)return null;let r;n[0]!==s?(r=s&&a.jsx(I5,{allowedPrompts:s.allowedPrompts,summary:s.summary,planContent:s.planContent}),n[0]=s,n[1]=r):r=n[1];let o;n[2]!==t?(o=t.length>0&&a.jsx("div",{className:"mb-2 overflow-hidden rounded-xl border border-warning/40 bg-popover",children:a.jsx(P5,{requests:t})}),n[2]=t,n[3]=o):o=n[3];let i;return n[4]!==r||n[5]!==o?(i=a.jsxs("div",{className:"px-3 pt-2",children:[r,o]}),n[4]=r,n[5]=o,n[6]=i):i=n[6],i}function wd(n){const e=V.c(8),{icon:t,status:s,children:r}=n,i=(s===void 0?!1:s)?"status":void 0;let l;e[0]!==t?(l=a.jsx(t,{"data-icon":"inline-start",className:"size-3.5 text-muted-foreground"}),e[0]=t,e[1]=l):l=e[1];let c;e[2]!==r?(c=a.jsx("span",{className:"text-xs text-muted-foreground",children:r}),e[2]=r,e[3]=c):c=e[3];let u;return e[4]!==i||e[5]!==l||e[6]!==c?(u=a.jsxs("div",{role:i,className:"flex shrink-0 items-center justify-center gap-2 border-t bg-card px-4 py-2.5",children:[l,c]}),e[4]=i,e[5]=l,e[6]=c,e[7]=u):u=e[7],u}const Lye=y.lazy(()=>nt(()=>import("./index-C0oae6L9.js"),__vite__mapDeps([43,1,2,3,4])).then(n=>({default:n.BranchModal}))),Mye=y.lazy(()=>nt(()=>import("./WorkflowsPanel-BZhR5Ld-.js"),__vite__mapDeps([44,1,4,2,3])).then(n=>({default:n.WorkflowsPanel})));function zye(){window.location.reload()}function Dye(){var Bv,Wv,qv,Vv,Hv,Kv,Gv,Zv,Yv,Xv,Jv,Qv,ey,ty,ny,sy,ry,oy,iy,ay,ly,cy,uy,dy,fy,my;const n=ov(window.location.pathname),e=gve(),t=vye(),s=jve(t.edition),r=Tye(t.edition,s.edition),o=$r(),i=s.checked&&(s.edition==="personal"||s.user!==null),l=i&&s.capabilities.configWrite,c=i&&s.capabilities.hostFiles,u=i&&s.capabilities.terminal,d=nv(),f=C7(),[m,p]=w7(),{procBySession:h}=Vx(),{parse:g,append:x}=F7(),b=y.useCallback(Oe=>{p({type:"SET_OLDER_TURNS",turns:Oe})},[p]),w=y.useCallback((Oe,ct)=>{xye(Oe,ct,g)},[g]),v=U7({dirName:((Bv=m.sessionSource)==null?void 0:Bv.dirName)??null,fileName:((Wv=m.sessionSource)==null?void 0:Wv.fileName)??null,sessionChangeKey:m.sessionChangeKey,workerParse:g,onOlderTurns:b}),{loadMore:j}=v,k=!!m.searchQuery&&v.hasMore,_=((qv=m.session)==null?void 0:qv.turns.length)??0;y.useEffect(()=>{k&&j()},[k,j,_]);const N=qve(m,p),S=y.useRef(null),C=y.useRef(null),[E,T]=y.useState(!1),[$,A]=y.useState(!1),R=y.useCallback(()=>p({type:"TOGGLE_EXPAND_ALL"}),[p]),P=y.useCallback(()=>T(!0),[]),z=y.useCallback(()=>{var Oe;return(Oe=C.current)==null?void 0:Oe.focus()},[]),L=y.useCallback(()=>p({type:"SET_EXPAND_ALL",value:!0}),[p]),I=y.useCallback(()=>p({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0}),[p]),M=y.useCallback(()=>p({type:"SET_EXPAND_ALL",value:!1}),[p]),F=N.toggleWorkspacePanel,U=y.useCallback(()=>F(Ot.sessionInfo),[F]),O=y.useCallback(Oe=>{y.startTransition(()=>{p({type:"SET_DASHBOARD_PROJECT",dirName:Oe})})},[p]),D=m.pendingCwd??(m.pendingDirName?xs(m.pendingDirName):null),B=((Vv=m.sessionSource)==null?void 0:Vv.agentKind)??un(((Hv=m.sessionSource)==null?void 0:Hv.dirName)??m.pendingDirName??null),q=(Kv=m.session)!=null&&Kv.sessionId?h.get(m.session.sessionId):void 0,W=bn(B),H=$b(B,q),K=Iye(((Gv=m.session)==null?void 0:Gv.sessionId)??null),Z=wa(K.level),Y=W.worktrees,X=W.mcp&&l&&Z.mcp,ee=Bve(l?((Zv=m.session)==null?void 0:Zv.cwd)??D??void 0:void 0,l&&W.slashCommands),te=y.useCallback(Oe=>{if(!l)return;const ct=ee.suggestions.find(rn=>rn.name===Oe);y.startTransition(()=>{p({type:"OPEN_CONFIG",filePath:ct==null?void 0:ct.filePath})})},[l,p,ee.suggestions]),se=y.useCallback(async(Oe,ct)=>{if(!l)return null;const rn=ee.suggestions.find(zr=>zr.name===Oe);if(!(rn!=null&&rn.filePath))return null;try{const zr=await Ce("/api/expand-command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:rn.filePath,args:ct||""})});return zr.ok?(await zr.json()).content??null:null}catch{return null}},[l,ee.suggestions]),J=N.openWorkspacePanel,ne=y.useCallback(Oe=>{J(Oe),d&&p({type:"SET_MOBILE_TAB",tab:"workspace"})},[J,d,p]),ie=y.useCallback(()=>ne(Ot.crew),[ne]),ae=N.activeWorkspacePanel===Ot.crew&&(!d||m.mobileTab==="workspace"),{processPanel:oe,currentCwd:ue,showPreview:re,showProjectFiles:de,projectFilesRoot:fe,projectFilesRequest:le,launchTerminalRequest:ce,pendingProject:he,handleOpenTerminal:ge,handleMcpAuth:be,handleToggleIntegratedTerminal:ve,handleNewIntegratedTerminal:Se,handleTogglePreview:we,handleToggleProjectFiles:Ee,closeRightWorkspace:$e}=tye({sessionId:(Yv=m.session)==null?void 0:Yv.sessionId,sessionCwd:(Xv=m.session)==null?void 0:Xv.cwd,pendingPath:D,sessionDirName:(Jv=m.sessionSource)==null?void 0:Jv.dirName,pendingDirName:m.pendingDirName,dashboardProject:m.dashboardProject,supportsFileWorkspace:c,activeWorkspacePanel:N.activeWorkspacePanel,openWorkspacePanel:ne,closeWorkspacePanel:N.closeWorkspacePanel}),Be=Mve(m.session??null),[qe,ze]=y.useState(!1),Ie=((Qv=m.sessionSource)==null?void 0:Qv.dirName)??m.pendingDirName??m.dashboardProject??null,{activeWorkspacePanel:Me,closeWorkspacePanel:Ue,showWorkflows:De}=N,Ke=Tve(i&&Y&&m.mainView==="sessions"&&Me===Ot.worktrees?Ie:null),Ne=y.useMemo(()=>{const Oe=m.session;return Oe?Oe.turns.some(ct=>mf(ct.toolCalls,Oe.cwd)||ct.subAgentActivity.some(rn=>mf(rn.toolCalls,Oe.cwd))):!1},[m.session]),Ae=y.useMemo(()=>{if(!m.session||!W.workflows)return 0;let Oe=0;for(const ct of m.session.turns)for(const rn of ct.toolCalls)rn.name==="Workflow"&&Oe++;return Oe},[m.session,W.workflows]),Qe=Ae>0,Je=y.useMemo(()=>{const Oe=m.sessionSource;return!Oe||!W.workflows||$o(Oe.fileName)?{dirName:null,sessionId:null}:{dirName:Oe.dirName,sessionId:Ed(Oe.fileName)}},[m.sessionSource,W.workflows]),ke=wbe(Je.dirName,Je.sessionId,Qe),We=Qe||ke.workflows.length>0,ye=ke.workflows.length||Ae,Re=N.setShowWorkflows,Ve=y.useCallback(()=>Re(!0),[Re]),[He,me]=y.useState(!1);y.useEffect(()=>{if(!c)return;const Oe=()=>{d?me(!0):J(Ot.fileChanges)};return window.addEventListener(gc,Oe),()=>window.removeEventListener(gc,Oe)},[c,J,d]);const je=y.useMemo(()=>m.session?r6(m.session):null,[m.session]),Xe=y.useRef(null),{isLive:tt,sseState:dt,isCompacting:zt,streamingOverlayStore:st,turnError:Et,agentProgress:Tt,promptSuggestion:Jt,rateLimit:At}=b7(m.sessionSource,Oe=>{y.startTransition(()=>{p({type:"UPDATE_SESSION",session:Oe})})},g,x,()=>{var Oe;return(Oe=Xe.current)==null?void 0:Oe.call(Xe)},m.session),Qn=Uve(((ey=m.session)==null?void 0:ey.cwd)??null),kn=Kbe(B),Lr=kn.setMode,_n=Ybe(H?null:((ty=m.session)==null?void 0:ty.sessionId)??null),Is=H?null:_n.plan??je,{contextWindowTokens:Ps,setContextWindowTokens:cr,contextWindowAvailable:ur,selectedModel:us,setSelectedModel:$s,selectedEffort:Si,setSelectedEffort:ki,fastModeEnabled:Z7,ultracodeEnabled:Y7,effectiveEffort:Ua,fastModeAvailable:X7,fastModeActive:ru,setFastModeEnabled:Om,ultracodeAvailable:J7,ultracodeActive:ou,setUltracodeEnabled:Lm,imageInputAvailable:iv,modelFallbackNotice:Q7,dismissModelFallbackNotice:av,handleModelRejected:lv}=Zve({agentKind:B,session:m.session,sessionSource:m.sessionSource,pendingDirName:m.pendingDirName,isLive:tt}),cv=Ive((ny=m.session)==null?void 0:ny.sessionId,(sy=m.sessionSource)==null?void 0:sy.fileName),Ba=Qve({sessionKey:cv,sessionId:((ry=m.session)==null?void 0:ry.sessionId)??null,access:K.level,values:{model:us,effort:Si,contextWindowTokens:Ps,fastMode:Z7,ultracode:Y7,permissionMode:kn.config.mode},onHydrate:y.useCallback(Oe=>{cr(Oe.contextWindowTokens??null),Oe.model!==void 0&&$s(Oe.model),Oe.effort!==void 0&&ki(Oe.effort),Oe.fastMode!==void 0&&Om(Oe.fastMode),Oe.ultracode!==void 0&&Lm(Oe.ultracode),Oe.permissionMode&&Lr(Oe.permissionMode)},[cr,$s,ki,Om,Lm,Lr])}),uv=Ba.picked.includes("permissionMode")?kn.config:void 0,ds=Lve(X?ue:void 0,X?Ie??void 0:void 0,X?cv??void 0:void 0,X);y.useEffect(()=>{!Y&&Me===Ot.worktrees&&Ue()},[Y,Me,Ue]),y.useEffect(()=>{De&&!We&&Re(!1)},[De,We,Re]);const{creatingSession:dv,createError:fv,clearCreateError:eP,createAndSend:tP,cancelCreation:mv,worktreeEnabled:nP,setWorktreeEnabled:sP,sessionFinalizedRef:iu,liveSessionsRefreshRef:pv,pendingSessionInfo:hv,pendingAgentKindChange:rP,handleStartNewSession:au,handleStartNewFolder:gv}=pye({permissionsConfig:kn.config,dispatch:p,isMobile:d,defaultAgentKind:e.defaultAgentKind,pendingDirName:m.pendingDirName,pendingCwd:m.pendingCwd,onModelRejected:lv,model:us,effort:Ua,contextWindowTokens:ur?Ps:void 0,fastMode:ru,ultracode:ou,mcpConfig:X?ds.mcpConfigJson:null}),Dt=Nbe({sessionSource:m.sessionSource,parsedSessionId:((oy=m.session)==null?void 0:oy.sessionId)??null,cwd:(iy=m.session)==null?void 0:iy.cwd,permissions:uv,onPermissionsApplied:kn.markApplied,settingsChange:Ba.picked,onSettingsChangeSent:Ba.settlePicked,model:us,effort:Ua,contextWindowTokens:ur?Ps:void 0,fastMode:ru,ultracode:ou,mcpConfig:X?ds.mcpConfigJson:null,onModelRejected:lv,readOnly:H||!Z.send,onCreateSession:m.pendingDirName?tP:void 0}),[Mm,xv]=y.useState(null),bv=y.useCallback(async(Oe,ct,rn)=>{await au(Oe,ct),xv(rn)},[au]),vv=Dt.sendMessage;y.useEffect(()=>{!Mm||!m.pendingDirName||(xv(null),vv(Mm))},[Mm,m.pendingDirName,vv]);const yv={selectedModel:us,onModelChange:$s,selectedEffort:Ua,onEffortChange:ki},En=vbe(W.agentTeams?((ay=m.sessionSource)==null?void 0:ay.fileName)??null:null,((ly=m.sessionSource)==null?void 0:ly.dirName)??null);y.useEffect(()=>{En!=null&&En.currentMemberName?p({type:"SET_CURRENT_MEMBER_NAME",name:En.currentMemberName}):En||p({type:"SET_CURRENT_MEMBER_NAME",name:null})},[En==null?void 0:En.currentMemberName,En,p]),y.useEffect(()=>{d&&p({type:"GUARD_MOBILE_TAB",hasSession:!!m.session||!!m.pendingDirName})},[m.session,m.pendingDirName,m.mobileTab,d,p]);const dr=S7({session:m.session,isLive:tt,pendingMessages:Dt.pendingMessages,consumePending:Dt.consumePending,sessionChangeKey:m.sessionChangeKey}),wv=dr.chatScrollRef,Sv=dr.resetTurnCount,kv=dr.scrollToBottomInstant,oP=y.useCallback(Oe=>{ze(Oe),requestAnimationFrame(()=>{const ct=wv.current;ct&&ct.scrollTo({top:ct.scrollTop+(Oe?64:-64),behavior:"smooth"})})},[wv]);y.useLayoutEffect(()=>{const Oe=ct=>{Sv(0),kv()};return iu.current=Oe,()=>{iu.current===Oe&&(iu.current=null)}},[Sv,kv,iu]);const iP=y.useCallback(()=>{Dt.disconnect(),mv()},[Dt.disconnect,mv]),ys=Ebe({dispatch:p,isMobile:d,mobileTab:m.mobileTab,teamContext:En,scrollToBottomInstant:dr.scrollToBottomInstant,resetTurnCount:dr.resetTurnCount,workerParse:g,onBeforeSwitch:iP}),aP=y.useCallback(Oe=>{y.startTransition(()=>{p({type:"GO_HOME",isMobile:d}),p({type:"SET_DASHBOARD_PROJECT",dirName:Oe})})},[p,d]),{previewLoadError:lP}=Pbe({state:m,dispatch:p,isMobile:d,resetTurnCount:dr.resetTurnCount,scrollToBottomInstant:dr.scrollToBottomInstant,workerParse:g}),Wa=Dbe();Bbe({openSessionId:(m.sessionSource&&kx(m.sessionSource.dirName,m.sessionSource.fileName))??((cy=m.session)==null?void 0:cy.sessionId)??null,leave:ys.handleCloseSession,forgetVisits:Wa.forget});const jv=Wa.push;y.useEffect(()=>{m.sessionSource&&jv(m.sessionSource.dirName,m.sessionSource.fileName)},[m.sessionSource,jv]);const Vt=Kve({state:{session:m.session,sessionSource:m.sessionSource},dispatch:p,isMobile:d,handleJumpToTurn:ys.handleJumpToTurn,markPermissionsApplied:kn.markApplied,hasPermsPendingChanges:kn.hasPendingChanges,permissionsConfig:uv,settingsChange:Ba.picked,onSettingsChangeSent:Ba.settlePicked,selectedModel:us,selectedEffort:Ua,fastMode:ru,ultracode:ou,mcpConfig:X?ds.mcpConfigJson:null,scrollRequestScrollToTop:dr.requestScrollToTop,handleDashboardSelect:ys.handleDashboardSelect,workerParse:g,canInteract:Z.canInteract}),{hasSettingsChanges:Nv,handleApplySettings:Cv}=Vt,_v=X&&ds.mcpConfigJson!==null,Ev=y.useRef(!1);y.useEffect(()=>{var rn;const Oe=ds.loaded&&!Ev.current;Ev.current=ds.loaded;const ct=(rn=m.session)==null?void 0:rn.sessionId;Oe&&ct&&_v&&Nv&&Cv()},[ds.loaded,_v,Nv,Cv,(uy=m.session)==null?void 0:uy.sessionId]),y.useLayoutEffect(()=>(Xe.current=Vt.reloadSession,()=>{Xe.current===Vt.reloadSession&&(Xe.current=null)}),[Vt.reloadSession]);const Mr=L7(m.session,m.sessionSource,Vt.reloadSession,c&&Z.undo),lu=Mr.requestBranchSwitch,cu=Vt.setBranchModalTurn,cP=y.useCallback((Oe,ct)=>{lu(Oe,ct),cu(null)},[lu,cu]),uP=y.useCallback(Oe=>{lu(Oe),cu(null)},[lu,cu]);Obe({isMobile:d,searchInputRef:S,chatInputRef:C,dispatch:p,onToggleSidebar:N.handleToggleSidebar,onToggleRightSidebar:U,onToggleMissionControl:N.handleToggleMission,onOpenCommandPalette:P,onOpenProjectSwitcher:N.handleOpenProjectSwitcher,onOpenThemeSelector:N.handleToggleThemeSelector,onOpenTerminal:ge,onToggleIntegratedTerminal:ve,onTogglePreview:we,onToggleProjectFiles:Ee,onHistoryBack:Wa.goBack,onHistoryForward:Wa.goForward,onNavigateToSession:ys.handleDashboardSelect,onCommitNavigation:Wa.commitNavigation});const{killing:dP,handleKillAll:fP}=Ave(),co=m.sessionSource?$o(m.sessionSource.fileName):null,mP=co!==null&&!!(En!=null&&En.currentMemberName),zm=co!==null&&!mP,uu=ys.handleDashboardSelect,Tv=y.useCallback(()=>{!m.sessionSource||!co||uu(m.sessionSource.dirName,co.parentFileName)},[m.sessionSource,co,uu]);y.useEffect(()=>{const Oe=ct=>{const{agentId:rn}=ct.detail??{};if(!rn||!m.sessionSource||!W.subagentTranscripts)return;const zr=co?co.parentSessionId:Ed(m.sessionSource.fileName);uu(m.sessionSource.dirName,`${zr}/subagents/agent-${rn}.jsonl`)};return window.addEventListener(hf,Oe),()=>window.removeEventListener(hf,Oe)},[m.sessionSource,co,uu,W.subagentTranscripts]);const[pP,Av]=y.useState(null),hP=Vt.branchModalTurn!==null,ji=Vt.branchModalTurn??pP;y.useEffect(()=>{Vt.branchModalTurn!==null&&Av(Vt.branchModalTurn)},[Vt.branchModalTurn]);const Iv=ji!==null?Mr.branchesAtTurn(ji):[];let Ni=null;zm?Ni={kind:"subagent"}:H?Ni={kind:"external",agentKind:B}:Ni=Pye(K);const Dm=Ni&&a.jsx($ye,{reason:Ni}),uo=((dy=m.session)==null?void 0:dy.sessionId)??null,Ci=uo!==null&&Ni===null&&m.mainView==="sessions"&&(!d||m.mobileTab==="chat"),[gP,Fm]=y.useState(null);y.useEffect(()=>{Fm(null)},[uo,Ci]);const Pv=y.useCallback(()=>{Ci&&Fm(uo)},[uo,Ci]),xP=y.useCallback(Oe=>{Fm(ct=>Oe?uo:ct===uo?null:ct)},[uo]),bP=ys.loadError||fv||null;let Um;ys.loadError?Um=ys.clearLoadError:fv&&(Um=eP);const vP=!!(m.session&&m.sessionSource&&dt==="disconnected"),Bm=y.useMemo(()=>({state:m,dispatch:p,config:e,theme:f,isMobile:d}),[m.activeTurnIndex,m.activeToolCallId,m.searchQuery,m.expandAll,m.expandToolPayloads,m.mainView,m.extensionViewId,m.mobileTab,m.dashboardProject,m.pendingDirName,m.pendingCwd,m.currentMemberName,m.loadingMember,m.configFilePath,m.sessionChangeKey,p,e,f,d]),Wm=y.useMemo(()=>({session:m.session,sessionSource:m.sessionSource,isLive:tt,sseState:dt,isCompacting:zt,turnError:Et,promptSuggestion:Jt,rateLimit:At,undoRedo:Mr,pendingInteraction:Is,permissionRequests:_n.requests,permissionResponding:_n.responding,respondPermission:_n.respond,respondAllPermissions:_n.respondAll,isSubAgentView:zm,permissions:Z,slashSuggestions:ee.suggestions,slashSuggestionsLoading:ee.loading,actions:{handleStopSession:Vt.handleStopSession,handleEditConfig:l?N.handleEditConfig:void 0,handleEditCommand:l?te:void 0,handleExpandCommand:l?se:void 0,handleOpenBranches:Vt.handleOpenBranches,handleBranchFromHere:Vt.handleBranchFromHere,handleToggleExpandAll:R,handleLoadSession:Vt.handleLoadSessionScrollAware,handleProviderHandoff:Ci?Pv:void 0}}),[m.session,m.sessionSource,tt,dt,zt,Et,Jt,At,Mr,Is,zm,Z,_n.requests,_n.responding,_n.respond,_n.respondAll,ee.suggestions,ee.loading,Vt.handleStopSession,l,N.handleEditConfig,te,se,Vt.handleOpenBranches,Vt.handleBranchFromHere,R,Vt.handleLoadSessionScrollAware,Ci,Pv]),qm=y.useMemo(()=>({chat:{status:Dt.status,error:Dt.error,pendingMessages:Dt.pendingMessages,isConnected:Dt.isConnected,sendMessage:Dt.sendMessage,interrupt:Dt.interrupt,stopAgent:Dt.stopAgent,consumePending:Dt.consumePending},scroll:dr}),[Dt.status,Dt.error,Dt.pendingMessages,Dt.isConnected,Dt.sendMessage,Dt.interrupt,Dt.stopAgent,Dt.consumePending,dr]),qa=!!m.pendingDirName&&!m.session;if(y.useEffect(()=>{if(!qa||d)return;const Oe=requestAnimationFrame(()=>{var ct;return(ct=C.current)==null?void 0:ct.focus()});return()=>cancelAnimationFrame(Oe)},[qa,d,m.pendingDirName]),r.failed)return a.jsx(kye,{onRetry:r.retry});if(!t.authChecked||!r.serverReady)return a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas",role:"status","aria-label":"Checking authentication",children:a.jsx(St,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(!t.authenticated){const Oe=o.SetupScreen;return t.setupRequired&&Oe?a.jsx(Oe,{onAuthenticated:t.handleAuthenticated,onSetupClosed:t.refreshServerState}):a.jsx(bye,{onAuthenticated:t.handleAuthenticated,setupRequired:t.setupRequired})}if(!i||!r.ready)return a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas",role:"status","aria-label":"Loading identity",children:a.jsx(St,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(s.gate){const Oe=o.GateScreen??wye;return a.jsxs(a.Fragment,{children:[a.jsx(Oe,{gate:s.gate,onRestored:zye,onLogout:t.logout}),a.jsx(Qy,{activeError:null,modelFallbackNotice:null,dismissModelFallbackNotice:av,connectionLost:!1,theme:f.activeTheme})]})}if(e.configLoading)return a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas",role:"status","aria-label":"Loading",children:a.jsx(St,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(e.configError)return a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas text-foreground",children:a.jsxs(Ln,{children:[a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:a.jsx(Ir,{className:"text-destructive"})}),a.jsx(zn,{children:"Failed to connect"}),a.jsx(Dn,{children:e.configError})]}),a.jsx(_c,{children:a.jsxs(Q,{variant:"outline",size:"sm",onClick:e.retryConfig,children:[a.jsx(Fn,{"data-icon":"inline-start"}),"Retry"]})})]})});if(!e.claudeDir)return l?a.jsx(Kte,{onConfigured:e.setClaudeDir}):a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas text-sm text-muted-foreground",children:"Cogpit is waiting for an administrator to finish server setup."});const Vm=a.jsx(Qy,{activeError:bP,clearActiveError:Um,modelFallbackNotice:Q7,dismissModelFallbackNotice:av,connectionLost:vP,theme:f.activeTheme}),$v=c?a.jsx(zte,{state:Mr.confirmState,isApplying:Mr.isApplying,applyError:Mr.applyError,onConfirm:Mr.confirmApply,onCancel:Mr.confirmCancel}):null,yP=ji!==null&&m.session?m.session.turns.slice(ji):[],Rv=c&&ji!==null&&Iv.length>0&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(Lye,{open:hP,branches:Iv,branchPointTurnIndex:ji,currentTurns:yP,onClose:Vt.handleCloseBranchModal,onCloseComplete:()=>Av(null),onRedoToTurn:cP,onRedoEntireBranch:uP})}),Ov=u&&a.jsx(_te,{processes:oe.processes,activeProcessId:oe.activeProcessId,collapsed:oe.collapsed,onSetActive:oe.setActive,onRemove:oe.removeProcess,onToggleCollapse:oe.toggleCollapse,onRequestTerminal:xt("terminal")?Se:void 0,onAddTerminalContext:Oe=>{var py,hy,gy;const ct=Oe.trim();if(!ct)return;const rn=ct.includes("```")?"````":"```",zr=`${rn}terminal
493
493
  ${ct}
494
494
  ${rn}`,Hm=((py=C.current)==null?void 0:py.getText().trimEnd())??"";(hy=C.current)==null||hy.setText(Hm?`${Hm}
495
495