cogpit 2.4.0 → 2.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/dist/cli.js +1104 -489
  2. package/dist/web/assets/{CommandPaletteHost-DU1jhhYG.js → CommandPaletteHost-DJghey7B.js} +1 -1
  3. package/dist/web/assets/{ConfigBrowser-CTZR8nw6.js → ConfigBrowser-x0UdXG0K.js} +1 -1
  4. package/dist/web/assets/{HighlightedEditor-CNTtimUO.js → HighlightedEditor-D0TDZx8S.js} +1 -1
  5. package/dist/web/assets/{KeyboardShortcutsDialog-DtTE4xjZ.js → KeyboardShortcutsDialog-2606YXAx.js} +1 -1
  6. package/dist/web/assets/{MobileFileChanges-DaJh6sQ7.js → MobileFileChanges-B4dwGXMS.js} +1 -1
  7. package/dist/web/assets/{PreviewPanel-BOL9gNaQ.js → PreviewPanel-CJdf-VLC.js} +1 -1
  8. package/dist/web/assets/{ProjectFilesPanel-CBFFT9qJ.js → ProjectFilesPanel-3GzuQyp3.js} +1 -1
  9. package/dist/web/assets/{ProjectSwitcherModal-UUQMoktd.js → ProjectSwitcherModal-D8boI2Qx.js} +1 -1
  10. package/dist/web/assets/{TerminalOutput-T82q4Tf9.js → TerminalOutput-C-6RWc6C.js} +1 -1
  11. package/dist/web/assets/{ThemeSelectorModal-rFVnzZuC.js → ThemeSelectorModal-DZ9JuT6j.js} +1 -1
  12. package/dist/web/assets/{WorkflowsPanel-COZwo8h-.js → WorkflowsPanel-i3GanFyN.js} +1 -1
  13. package/dist/web/assets/{WorktreePanel-DvZNvNhH.js → WorktreePanel-D-BUTFL2.js} +1 -1
  14. package/dist/web/assets/{index-CpHg1sRc.js → index-BBKPLXTq.js} +1 -1
  15. package/dist/web/assets/index-CMQcske6.js +1 -0
  16. package/dist/web/assets/index-C_0XOtqJ.css +1 -0
  17. package/dist/web/assets/index-D6p4gVB_.js +154 -0
  18. package/dist/web/assets/{index-BhjwMUil.js → index-ztb2qsgi.js} +1 -1
  19. package/dist/web/assets/{session-parser.worker-QY58jiXs.js → session-parser.worker-D3MwyNH5.js} +1 -1
  20. package/dist/web/assets/{vendor-ui-B9m2oOMV.js → vendor-ui-RwWl1mlR.js} +175 -160
  21. package/dist/web/index.html +3 -3
  22. package/package.json +1 -1
  23. package/dist/web/assets/index-CghBqEmp.js +0 -153
  24. package/dist/web/assets/index-XlQRZ_Un.js +0 -1
  25. package/dist/web/assets/index-f2DFkgKZ.css +0 -1
@@ -1,153 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalOutput-T82q4Tf9.js","assets/vendor-react-gGw_S5I_.js","assets/vendor-ui-B9m2oOMV.js","assets/vendor-shiki-DOn6sF-i.js","assets/vendor-markdown-BE1gYnO9.js","assets/TerminalOutput-6GBZ9nXN.css","assets/html-GMplVEZG.js","assets/javascript-wDzz0qaB.js","assets/css-DPfMkruS.js","assets/cpp-BRuaLJcg.js","assets/c-BIGW1oBm.js","assets/sql-BLtJtn59.js","assets/ruby-B0Tyh1qT.js","assets/xml-D2mA2LmW.js","assets/java-CylS5w8V.js","assets/typescript-BPQ3VLAy.js","assets/jsx-g9-lgVsj.js","assets/tsx-COt5Ahok.js","assets/bash-Yzrsuije.js","assets/yaml-Buea-lGh.js","assets/php-aq0itWAE.js","assets/json-Cp-IABpG.js","assets/vue-DVfSmUF7.js","assets/svelte-DZMnMd3x.js","assets/scss-OYdSNvt2.js","assets/CommandPaletteHost-DU1jhhYG.js","assets/index-XlQRZ_Un.js","assets/KeyboardShortcutsDialog-DtTE4xjZ.js","assets/ProjectSwitcherModal-UUQMoktd.js","assets/ThemeSelectorModal-rFVnzZuC.js","assets/ProjectFilesPanel-CBFFT9qJ.js","assets/HighlightedEditor-CNTtimUO.js","assets/WorktreePanel-DvZNvNhH.js","assets/index-CpHg1sRc.js","assets/ConfigBrowser-CTZR8nw6.js","assets/PreviewPanel-BOL9gNaQ.js","assets/MobileFileChanges-DaJh6sQ7.js","assets/index-BhjwMUil.js","assets/WorkflowsPanel-COZwo8h-.js"])))=>i.map(i=>d[i]);
2
- var vv=Object.defineProperty;var yv=(n,e,t)=>e in n?vv(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var ai=(n,e,t)=>yv(n,typeof e!="symbol"?e+"":e,t);import{c as B,j as r,d as be,e as wv,r as y,a as jv,f as Sv}from"./vendor-react-gGw_S5I_.js";import{au as Nv,av as kv,aw as Cv,ax as es,ad as ot,ay as _v,i as xn,az as Uc,ar as Bn,aA as Oh,aB as Tv,aC as Ev,aD as Pv,aE as Dh,aF as Lh,aG as Wc,aH as zh,aI as Fh,aJ as Av,O as mt,aK as Bh,aL as Rv,aM as Iv,aN as $v,aO as Uh,J as Nr,a1 as yo,$ as tt,b as Ot,ai as Mv,aP as Wh,aQ as Di,G as Dn,aR as Ov,aS as Dv,aT as Lv,aU as zv,aV as Fv,aW as Bv,aX as Uv,aY as Wv,aZ as Hv,a_ as Kv,a$ as qv,b0 as Vv,b1 as Gv,b2 as Yv,b3 as kr,b4 as Hc,b5 as Kc,b6 as qc,b7 as Hh,b8 as Vc,b9 as aa,X as rt,ba as Gc,bb as Xv,N as Yc,bc as ts,bd as Jv,be as Kh,bf as qh,bg as xo,bh as Ts,bi as Qv,bj as Zv,bk as ey,bl as ty,bm as rr,S as gn,B as wo,m as Vh,bn as Vs,bo as Gh,bp as ny,bq as sy,br as oy,ae as Cr,bs as ry,W as la,ak as tc,a8 as ys,bt as nc,bu as iy,bv as ay,bw as ly,bx as cy,by as dy,bz as uy,bA as fy,bB as Xc,bC as my,bD as tn,D as An,bE as py,bF as hy,bG as gy,bH as xy,bI as by,bJ as vy,bK as ir,bL as _r,bM as yy,o as ca,bN as wy,bO as jy,bP as Sy,bQ as Ny,bR as ky,bS as Cy,bT as _y,bU as Ty,bV as Ey,bW as Py,C as Je,P as Ln,A as Gs,d as Yh,bX as Ay,bY as Ry,bZ as Iy,b_ as $y,F as jo,af as Ys,b$ as My,c0 as Xh,U as Jc,f as da,a7 as ua,c1 as Oy,c2 as Qc,c3 as sc,c4 as Dy,R as Zc,c5 as Ly,c6 as zy,Y as Fs,c as Jh,c7 as Fy,v as fa,c8 as Po,_ as Ei,c9 as By,ca as Uy,cb as Qh,cc as Wy,cd as Hy,ce as li,cf as Is,ag as Rf,l as Tr,cg as Ky,a2 as qy,ch as Vy,as as Gy,w as ma,ci as Yy,Q as ed,cj as Xy,ck as Jy,cl as Qy,cm as Zy,cn as e3,co as t3,cp as n3,cq as Zh,cr as s3,cs as o3,ap as r3,r as If,ct as i3,cu as $f,p as pa,cv as a3,cw as td,n as Er,I as eg,cx as l3,a3 as nd,u as c3,cy as d3,cz as tg,s as ng,at as sg,y as u3,cA as f3,cB as m3,cC as p3,cD as h3,cE as g3,cF as x3,cG as zn,cH as og,cI as rg,cJ as sd,cK as b3,cL as v3,j as y3,cM as ig,cN as w3,cO as oc,cP as j3,cQ as S3,cR as ag,cS as N3,h as k3,cT as C3,cU as _3,ab as T3,L as E3,z as P3,an as A3,cV as R3,aa as I3,cW as $3}from"./vendor-ui-B9m2oOMV.js";import{c as M3,a as O3}from"./vendor-shiki-DOn6sF-i.js";import{r as ha,M as Un}from"./vendor-markdown-BE1gYnO9.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))s(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&s(a)}).observe(document,{childList:!0,subtree:!0});function t(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function s(o){if(o.ep)return;o.ep=!0;const i=t(o);fetch(o.href,i)}})();const D3="modulepreload",L3=function(n){return"/"+n},Mf={},qe=function(e,t,s){let o=Promise.resolve();if(t&&t.length>0){let a=function(d){return Promise.all(d.map(u=>Promise.resolve(u).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),c=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));o=a(t.map(d=>{if(d=L3(d),d in Mf)return;Mf[d]=!0;const u=d.endsWith(".css"),f=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${f}`))return;const m=document.createElement("link");if(m.rel=u?"stylesheet":D3,u||(m.as="script"),m.crossOrigin="",m.href=d,c&&m.setAttribute("nonce",c),document.head.appendChild(m),u)return new Promise((p,h)=>{m.addEventListener("load",p),m.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${d}`)))})}))}function i(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return o.then(a=>{for(const l of a||[])l.status==="rejected"&&i(l.reason);return e().catch(i)})},ws=["codex","copilot","claude"],rc="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";function z3(n,e){const t=new TextEncoder().encode(e);let s="";for(const i of t)s+=String.fromCharCode(i);const o=btoa(s).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return`${n}${o}`}function F3(n,e){if(!e.startsWith(n))return null;try{const t=e.slice(n.length).replace(/-/g,"+").replace(/_/g,"/"),s=atob(t),o=Uint8Array.from(s,i=>i.charCodeAt(0));return new TextDecoder().decode(o)}catch{return null}}function lg(n){return{lossy:!1,owns:e=>typeof e=="string"&&e.startsWith(n),encode:e=>z3(n,e),decode:e=>F3(n,e)}}function cg(n){const e=new RegExp(`(${rc})\\.jsonl$`,"i").exec(n);return e?e[1]:null}const dg={urlId:n=>n.replace(/\.jsonl$/,""),fileNameFromUrlId:n=>n.endsWith(".jsonl")?n:`${n}.jsonl`};function ug(n){return`'${n.replace(/'/g,"'\\''")}'`}function ar(n,e){return e?[n,e]:[]}function Li(n,e){var t;return((t=e.exec(n))==null?void 0:t[1])??null}const zi="[0-9a-f-]{36}",fg="codex__",mg="copilot__",B3=new Set(["default","plan","acceptEdits","dontAsk","auto"]),pg={kind:"claude",displayName:"Claude Code",binName:"claude",dirName:{lossy:!0,owns:n=>typeof n=="string"&&!n.startsWith(fg)&&!n.startsWith(mg),encode:n=>(n.replace(/[\\/]+$/,"")||n).replace(/[^a-zA-Z0-9]/g,"-"),decode:n=>{const e=/^([A-Za-z])--(.*)$/.exec(n);return e?`${e[1]}:\\${e[2].replace(/-/g,"\\")}`:"/"+n.replace(/^-/,"").replace(/-/g,"/")}},sessionFile:{name:n=>`${n}.jsonl`,sessionId:cg,...dg},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"]:[...B3.has(n.mode)?["--permission-mode",n.mode]:[],...(n.allowedTools??[]).flatMap(e=>["--allowedTools",e]),...(n.disallowedTools??[]).flatMap(e=>["--disallowedTools",e])]:["--permission-mode","default"],model:n=>ar("--model",n),effort:n=>ar("--effort",n),fastTier:()=>[]},serviceTier:null,cli:{packageName:"@anthropic-ai/claude-code",homebrew:{name:"claude-code",cask:!1},wingetId:null,versionArgs:["--version"],selfUpdate:{args:["update"],matches:n=>n.endsWith("/.local/bin/claude")||n.endsWith("/.local/bin/claude.exe")||n.includes("/.local/share/claude/")},bundledBySdk:!0,homeDirName:".claude",homeEnvVar:null,installMarker:"projects",homeIsDiscoverable:!1,process:{by:"command",sessionIdFromCommand:n=>Li(n,new RegExp(`--resume(?:=|\\s+)(${zi})`))??Li(n,new RegExp(`--session-id(?:=|\\s+)(${zi})`))}},config:{rootDirName:".claude",instructions:[{in:"scope",path:"CLAUDE.md",scopes:["global","project"]},{in:"root",path:"CLAUDE.md",label:".claude/CLAUDE.md",scopes:["project"]}],settings:[{in:"root",path:"settings.json",scopes:["global"]},{in:"root",path:"settings.local.json",scopes:["project"]}],skillsDir:"skills",agentsDir:"agents",commandsDir:"commands",themesDir:"themes",pluginsDir:"plugins"},contextWindow:{defaultLimit:1e6,limits:[{match:"claude-haiku-4-5",limit:2e5},{match:"claude-haiku-4-1",limit:2e5},{match:"claude-sonnet-4-5",limit:2e5},{match:"claude-opus-4-5",limit:2e5},{match:"claude-opus-4-1",limit:2e5}],compactBuffer:33e3,extendedContext:{marker:"[1m]",limit:1e6}},capabilities:{worktrees:!0,mcp:!0,slashCommands:!0,workflows:!0,agentTeams:!0,subagentTranscripts:!0,nestedSubagents:!1,sharing:!0,goals:"transcript",undo:!0,redo:!0,nativeRewind:!1,fileCheckpoints:!0,reasoningEffort:!0,fastTier:!0,imageInput:!0,planMode:!0,midTurnSteering:!1,stopSession:!0,ultracode:!0,contextWindow:!0,externalProcesses:!1,modelFallbackNotices:!0,autoPermissionMode:"per-model",settingsApply:"live",turnLiveness:"transcript",tokenStreaming:!0,nativeFork:!1,namedSessions:!0}},Of={appServerValue:"priority",cliConfigValue:"fast"},U3={kind:"codex",displayName:"Codex",binName:"codex",dirName:lg(fg),sessionFile:{name:(n,e=new Date)=>{const t=String(e.getFullYear()),s=String(e.getMonth()+1).padStart(2,"0"),o=String(e.getDate()).padStart(2,"0"),i=String(e.getHours()).padStart(2,"0"),a=String(e.getMinutes()).padStart(2,"0"),l=String(e.getSeconds()).padStart(2,"0");return`${t}/${s}/${o}/rollout-${t}-${s}-${o}T${i}-${a}-${l}-${n}.jsonl`},sessionId:cg,...dg},metadataFromHead:!1,resume:{command:(n,e)=>e?`codex -C ${ug(e)} resume ${n}`:`codex resume ${n}`,args:n=>["resume",n]},launchArgs:{permissions:n=>{const e=(n==null?void 0:n.mode)||"default";return e==="bypassPermissions"?["--dangerously-bypass-approvals-and-sandbox"]:["--sandbox",e==="plan"?"read-only":"workspace-write","-c",'approval_policy="never"']},model:n=>ar("-m",n),effort:n=>n?["-c",`model_reasoning_effort=${JSON.stringify(n)}`]:[],fastTier:n=>n?["-c",`service_tier=${JSON.stringify(Of.cliConfigValue)}`,"--enable","fast_mode"]:[]},serviceTier:Of,cli:{packageName:"@openai/codex",homebrew:{name:"codex",cask:!1},wingetId:null,versionArgs:["--version"],selfUpdate:null,bundledBySdk:!1,homeDirName:".codex",homeEnvVar:"CODEX_HOME",installMarker:"",homeIsDiscoverable:!0,process:{by:"command",sessionIdFromCommand:n=>Li(n,new RegExp(`codex(?:\\s+\\S+)*\\s+exec\\s+resume\\s+(${zi})`))}},config:{rootDirName:".codex",instructions:[{in:"scope",path:"AGENTS.md",scopes:["global","project"]}],settings:[{in:"root",path:"config.toml",scopes:["global","project"]}],skillsDir:"skills",agentsDir:"agents",commandsDir:"prompts",themesDir:null,pluginsDir:null},contextWindow:{defaultLimit:272e3,limits:[],compactBuffer:0,extendedContext:null},capabilities:{worktrees:!1,mcp:!1,slashCommands:!1,workflows:!1,agentTeams:!1,subagentTranscripts:!0,nestedSubagents:!0,sharing:!1,goals:"thread-api",undo:!0,redo:!0,nativeRewind:!1,fileCheckpoints:!1,reasoningEffort:!0,fastTier:!0,imageInput:!0,planMode:!0,midTurnSteering:!0,stopSession:!1,ultracode:!1,contextWindow:!1,externalProcesses:!1,modelFallbackNotices:!1,autoPermissionMode:"never",settingsApply:"next-turn",turnLiveness:"runtime",tokenStreaming:!0,nativeFork:!1,namedSessions:!1}},W3={kind:"copilot",displayName:"GitHub Copilot CLI",binName:"copilot",dirName:lg(mg),sessionFile:{name:n=>`${n}/events.jsonl`,sessionId:n=>{const e=new RegExp(`^(${rc})/events\\.jsonl$`,"i").exec(n);return e?e[1]:null},urlId:n=>{const e=new RegExp(`^(${rc})/events\\.jsonl$`,"i").exec(n);return e?e[1]:n.replace(/\.jsonl$/,"")},fileNameFromUrlId:n=>n.endsWith(".jsonl")?n:`${n}/events.jsonl`},metadataFromHead:!0,resume:{command:(n,e)=>e?`copilot -C ${ug(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=>ar("--model",n),effort:n=>ar("--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=>Li(n,new RegExp(`--resume(?:=|\\s+)(${zi})`))}},config:{rootDirName:".copilot",instructions:[{in:"scope",path:"AGENTS.md",scopes:["global","project"]}],settings:[{in:"root",path:"config.json",scopes:["global"]}],skillsDir:"skills",agentsDir:null,commandsDir:null,themesDir:null,pluginsDir:null},contextWindow:{defaultLimit:2e5,limits:[],compactBuffer:0,extendedContext:null},capabilities:{worktrees:!1,mcp:!1,slashCommands:!1,workflows:!1,agentTeams:!1,subagentTranscripts:!1,nestedSubagents:!1,sharing:!1,goals:!1,undo:!0,redo:!1,nativeRewind:!0,fileCheckpoints:!1,reasoningEffort:!1,fastTier:!1,imageInput:!1,planMode:!0,midTurnSteering:!0,stopSession:!0,ultracode:!1,contextWindow:!1,externalProcesses:!0,modelFallbackNotices:!1,autoPermissionMode:"always",settingsApply:"next-turn",turnLiveness:"runtime",tokenStreaming:!1,nativeFork:!0,namedSessions:!0}},lr=Object.freeze({claude:pg,codex:U3,copilot:W3});function nn(n){return lr[n]}function ga(){return ws.map(n=>lr[n])}function H3(n,e){const t=ga().filter(n);if(t.length!==1)throw new Error(`Expected exactly one agent with ${e}, found ${t.length}`);return t[0]}function Es(n){for(const e of ws)if(e!=="claude"&&lr[e].dirName.owns(n))return lr[e];return pg}function Et(n){return Es(n).kind}function al(n,e,t){const s=lr[n].dirName;return t&&s.lossy?t:s.encode(e)}const Xs=Es(null).kind;var $h;const ci=(($h=ga().find(n=>n.dirName.lossy))==null?void 0:$h.kind)??null;function So(n){return Es(n).capabilities}function qt(n){return nn(n).capabilities}function K3(n,e){return ws.find(t=>t===n)??e}function ic(n){for(const e of ga()){const t=e.sessionFile.sessionId(n);if(t)return t}return n.replace(/\.jsonl$/,"")}function q3(n,e){return Es(n).sessionFile.urlId(e)}function V3(n,e){return Es(n).sessionFile.fileNameFromUrlId(e)}function hg(n,e,t){return nn(n).resume.command(e,t)}function G3(n,e){const t=nn(n);return{command:t.binName,args:[...t.resume.args(e)]}}function Df(n){return n.replace(/\/+$/,"")||"/"}function Y3(n,e,t){var o;const s=Df(e);return((o=n.find(i=>Es(i.dirName).kind===t&&Df(i.path)===s))==null?void 0:o.dirName)??null}const X3=[{value:"",label:"Default"},{value:"fable",label:"Fable"},{value:"fable[1m]",label:"Fable 1M"},{value:"opus",label:"Opus"},{value:"opus[1m]",label:"Opus 1M"},{value:"sonnet",label:"Sonnet"},{value:"sonnet[1m]",label:"Sonnet 1M"},{value:"haiku",label:"Haiku"}],od=[{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"}],gg=[...od,{value:"ultra",label:"Ultra",description:"Maximum reasoning with automatic task delegation"}],di=od.slice(0,4);var Mh;const Ho=[{value:((Mh=nn("codex").serviceTier)==null?void 0:Mh.appServerValue)??"priority",label:"Fast",description:"1.5× speed with increased usage"}],Lf={isDefault:!0,defaultReasoningEffort:"medium",supportedReasoningEfforts:gg,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:Ho},J3=[{value:"",label:"Default",description:"Use Codex's recommended model (GPT-5.6 Sol)",resolvedModel:"gpt-5.6-sol",...Lf},{value:"gpt-5.6-sol",label:"GPT-5.6 Sol",description:"Flagship model for the most ambitious work",...Lf},{value:"gpt-5.6-terra",label:"GPT-5.6 Terra",description:"Balanced model for everyday work",defaultReasoningEffort:"medium",supportedReasoningEfforts:gg,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:Ho},{value:"gpt-5.6-luna",label:"GPT-5.6 Luna",description:"Fastest, most cost-efficient model",defaultReasoningEffort:"medium",supportedReasoningEfforts:od,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:Ho},{value:"gpt-5.5",label:"GPT-5.5",description:"Frontier model for complex real-world work",defaultReasoningEffort:"medium",supportedReasoningEfforts:di,inputModalities:["text","image"],supportsPersonality:!0,serviceTiers:Ho},{value:"gpt-5.4",label:"GPT-5.4",description:"Strong model for everyday coding",defaultReasoningEffort:"medium",supportedReasoningEfforts:di,inputModalities:["text","image"],supportsPersonality:!0,serviceTiers:Ho},{value:"gpt-5.4-mini",label:"GPT-5.4 Mini",description:"Small, fast model for simpler tasks",defaultReasoningEffort:"medium",supportedReasoningEfforts:di,inputModalities:["text","image"],supportsPersonality:!0},{value:"gpt-5.3-codex-spark",label:"GPT-5.3 Codex Spark",description:"Ultra-fast text-only coding model",defaultReasoningEffort:"high",supportedReasoningEfforts:di,inputModalities:["text"],supportsPersonality:!0}],Q3=[{value:"",label:"Default",supportsEffort:!1,inputModalities:["text"]},{value:"auto",label:"Auto",description:"Let Copilot choose the best available model",supportsEffort:!1,inputModalities:["text"]}],Z3={claude:X3,codex:J3,copilot:Q3};function ew(n){return Z3[n]}function q(...n){return Nv(kv(n))}const xg=new Map,ac=new Set;function tw(n,e){!Array.isArray(e)||e.length===0||(xg.set(n,e),ac.forEach(t=>t()))}function nw(n){return ac.add(n),()=>ac.delete(n)}const ll="high",sw=[{value:"low",label:"Light"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"xhigh",label:"Extra High"},{value:"max",label:"Max"}];function bg(n){return xg.get(n)??ew(n)}function Pr(n,e){const t=bg(n);return e?t.find(s=>s.value===e):t.find(s=>s.value!==""&&s.isDefault)??t.find(s=>s.value==="")??t.find(s=>s.value!=="")}function vg(n,e){const t=Pr(n,e),s=t==null?void 0:t.supportedReasoningEfforts;return s&&s.length>0?s:(t==null?void 0:t.supportsEffort)===!1||!qt(n).reasoningEffort?[]:sw}function ow(n,e){var t;return((t=Pr(n,e))==null?void 0:t.serviceTiers)??[]}function yg(n,e){return ow(n,e).find(t=>t.value==="fast"||t.value==="priority"||t.label.toLowerCase()==="fast")}function rw(n,e){var s;const t=(s=Pr(n,e))==null?void 0:s.inputModalities;return t?t.includes("image"):qt(n).imageInput}function iw(n,e){var s;const t=qt(n).autoPermissionMode;return t==="always"?!0:t==="never"?!1:((s=Pr(n,e))==null?void 0:s.supportsAutoMode)===!0}function aw(n,e){return qt(n).ultracode?!(e??"").toLowerCase().startsWith("haiku"):!1}function xa(n,e,t){var l,c;const s=vg(n,t);if(s.length===0)return"";const o=(l=Pr(n,t))==null?void 0:l.defaultReasoningEffort,i=o&&s.some(d=>d.value===o)?o:s.some(d=>d.value===ll)?ll:((c=s[0])==null?void 0:c.value)??ll,a=e||i;return s.some(d=>d.value===a)?a:i}function lw(n){return n.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").slice(0,40).replace(/-$/,"")}async function Ar(n){try{return await navigator.clipboard.writeText(n),!0}catch{const e=document.createElement("textarea");e.value=n,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select();const t=document.execCommand("copy");return document.body.removeChild(e),t}}const cw=es("inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium outline-none transition-[color,background-color,border-color,box-shadow,transform,scale] duration-100 ease-out active:scale-[0.98] disabled:pointer-events-none disabled:opacity-50 motion-reduce:transition-none motion-reduce:active:scale-100 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/20 aria-invalid:border-destructive aria-invalid:ring-[3px] aria-invalid:ring-destructive/20",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20",outline:"border border-input bg-background shadow-xs hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",xs:"h-7 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-xs":"size-7 rounded-md [&_svg:not([class*='size-'])]:size-3.5","icon-sm":"size-7","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function ee(n){const e=B.c(12);let t,s,o,i;e[0]!==n?({className:t,variant:i,size:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);let a;e[5]!==t||e[6]!==o||e[7]!==i?(a=q(cw({variant:i,size:o,className:t})),e[5]=t,e[6]=o,e[7]=i,e[8]=a):a=e[8];let l;return e[9]!==s||e[10]!==a?(l=r.jsx(Cv,{"data-slot":"button",className:a,...s}),e[9]=s,e[10]=a,e[11]=l):l=e[11],l}function ln(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("flex w-full min-w-0 flex-1 flex-col items-center justify-center gap-4 rounded-xl border-dashed p-6 text-center text-balance motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-bottom-1 motion-safe:duration-200 motion-safe:ease-out motion-reduce:animate-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"empty",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function cn(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("flex max-w-sm flex-col items-center gap-2",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"empty-header",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const dw=es("mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0",{variants:{variant:{default:"bg-transparent",icon:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted text-foreground [&_svg:not([class*='size-'])]:size-4"}},defaultVariants:{variant:"default"}});function bn(n){const e=B.c(11);let t,s,o;e[0]!==n?({className:t,variant:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"default":o;let a;e[4]!==t||e[5]!==i?(a=q(dw({variant:i,className:t})),e[4]=t,e[5]=i,e[6]=a):a=e[6];let l;return e[7]!==s||e[8]!==a||e[9]!==i?(l=r.jsx("div",{"data-slot":"empty-icon","data-variant":i,className:a,...s}),e[7]=s,e[8]=a,e[9]=i,e[10]=l):l=e[10],l}function dn(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("text-sm font-medium tracking-tight",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"empty-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function vn(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"empty-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function wg(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("flex w-full max-w-sm min-w-0 flex-col items-center gap-2.5 text-sm text-balance",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"empty-content",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function uw(n){if(typeof document>"u")return;let e=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style");t.type="text/css",e.appendChild(t),t.styleSheet?t.styleSheet.cssText=n:t.appendChild(document.createTextNode(n))}const fw=n=>{switch(n){case"success":return hw;case"info":return xw;case"warning":return gw;case"error":return bw;default:return null}},mw=Array(12).fill(0),pw=({visible:n,className:e})=>be.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":n},be.createElement("div",{className:"sonner-spinner"},mw.map((t,s)=>be.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${s}`})))),hw=be.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},be.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),gw=be.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},be.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),xw=be.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},be.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),bw=be.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},be.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),vw=be.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true"},be.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),be.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),yw=()=>{const[n,e]=be.useState(document.hidden);return be.useEffect(()=>{const t=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[]),n};let ww=1;const jw=100,zf=n=>{var e;return typeof(n==null?void 0:n.id)=="number"||(n==null||(e=n.id)==null?void 0:e.length)>0?n.id:ww++};class Sw{constructor(){this.subscribe=e=>(this.subscribers.push(e),this.getActiveToasts().forEach(t=>e(t)),()=>{const t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e],this.trimHistory()},this.trimHistory=()=>{let e=this.toasts.length-jw;e<=0||(this.toasts=this.toasts.filter(t=>e>0&&this.dismissedToasts.has(t.id)?(this.dismissedToasts.delete(t.id),e--,!1):!0))},this.create=e=>{const{message:t,...s}=e,o=zf(e),i=this.pendingDismissals.get(o);i!==void 0&&(cancelAnimationFrame(i),this.pendingDismissals.delete(o),this.dismissedToasts.delete(o));const a=this.dismissedToasts.has(o),l=e.dismissible===void 0?!0:e.dismissible;return a&&(this.dismissedToasts.delete(o),this.toasts=this.toasts.filter(d=>d.id!==o)),(a?void 0:this.toasts.find(d=>d.id===o))?this.toasts=this.toasts.map(d=>d.id===o?(this.publish({...d,...e,id:o,title:t}),{...d,...e,id:o,dismissible:l,title:t}):d):this.addToast({title:t,...s,dismissible:l,id:o}),o},this.dismiss=e=>{if(e==null)return this.getActiveToasts().forEach(s=>{this.dismissedToasts.add(s.id),this.subscribers.forEach(o=>o({id:s.id,dismiss:!0}))}),e;this.dismissedToasts.add(e);const t=this.pendingDismissals.get(e);return t!==void 0&&cancelAnimationFrame(t),this.pendingDismissals.set(e,requestAnimationFrame(()=>{this.pendingDismissals.delete(e),this.subscribers.forEach(s=>s({id:e,dismiss:!0}))})),e},this.message=(e,t)=>this.create({...t,message:e,type:void 0}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let s;t.loading!==void 0&&(s=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));const o=Promise.resolve(e instanceof Function?e():e);let i=s!==void 0,a;const l=o.then(async d=>{if(a=["resolve",d],be.isValidElement(d))i=!1,this.create({id:s,type:"default",message:d});else if(kw(d)&&!d.ok){i=!1;const f=typeof t.error=="function"?await t.error(`HTTP error! status: ${d.status}`):t.error,m=typeof t.description=="function"?await t.description(`HTTP error! status: ${d.status}`):t.description,h=typeof f=="object"&&!be.isValidElement(f)?f:{message:f};this.create({id:s,type:"error",description:m,...h})}else if(d instanceof Error){i=!1;const f=typeof t.error=="function"?await t.error(d):t.error,m=typeof t.description=="function"?await t.description(d):t.description,h=typeof f=="object"&&!be.isValidElement(f)?f:{message:f};this.create({id:s,type:"error",description:m,...h})}else if(t.success!==void 0){i=!1;const f=typeof t.success=="function"?await t.success(d):t.success,m=typeof t.description=="function"?await t.description(d):t.description,h=typeof f=="object"&&!be.isValidElement(f)?f:{message:f};this.create({id:s,type:"success",description:m,...h})}}).catch(async d=>{if(a=["reject",d],t.error!==void 0){i=!1;const u=typeof t.error=="function"?await t.error(d):t.error,f=typeof t.description=="function"?await t.description(d):t.description,p=typeof u=="object"&&!be.isValidElement(u)?u:{message:u};this.create({id:s,type:"error",description:f,...p})}}).finally(()=>{i&&(this.dismiss(s),s=void 0),t.finally==null||t.finally.call(t)}),c=()=>new Promise((d,u)=>l.then(()=>a[0]==="reject"?u(a[1]):d(a[1])).catch(u));return typeof s!="string"&&typeof s!="number"?{unwrap:c}:Object.assign(s,{unwrap:c})},this.custom=(e,t)=>{const s=zf(t);return this.create({...t,jsx:e(s),id:s,type:void 0}),s},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set,this.pendingDismissals=new Map}}const Xt=new Sw,Nw=(n,e)=>Xt.message(n,e),kw=n=>n&&typeof n=="object"&&"ok"in n&&typeof n.ok=="boolean"&&"status"in n&&typeof n.status=="number",Cw=Nw,_w=()=>Xt.toasts,Tw=()=>Xt.getActiveToasts(),$s=Object.assign(Cw,{success:Xt.success,info:Xt.info,warning:Xt.warning,error:Xt.error,custom:Xt.custom,message:Xt.message,promise:Xt.promise,dismiss:Xt.dismiss,loading:Xt.loading},{getHistory:_w,getToasts:Tw});uw("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--normal-text);background:var(--normal-bg);border:1px solid var(--normal-border);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{-webkit-user-select:none;user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function ui(n){return n.label!==void 0}const Ew=3,Pw="24px",Aw="16px",Ff=4e3,Rw=356,Iw=14,$w=45,Mw=200;function $n(...n){return n.filter(Boolean).join(" ")}function Ow(n){const[e,t]=n.split("-"),s=[];return e&&s.push(e),t&&s.push(t),s}const Dw=n=>{var e,t,s,o,i,a,l,c,d;const{invert:u,toast:f,unstyled:m,interacting:p,setHeights:h,visibleToasts:g,heights:x,index:b,toasts:w,expanded:v,removeToast:S,defaultRichColors:j,closeButton:k,style:C,cancelButtonStyle:N,actionButtonStyle:_,className:P="",descriptionClassName:A="",duration:T,position:E,gap:R,expandByDefault:$,classNames:I,icons:M,closeButtonAriaLabel:D="Close toast"}=n,[O,L]=be.useState(null),[F,z]=be.useState(null),[W,U]=be.useState(!1),[H,K]=be.useState(!1),[V,Y]=be.useState(!1),[G,J]=be.useState(!1),[Q,X]=be.useState(!1),[Z,te]=be.useState(0),[ne,re]=be.useState(0),ie=be.useRef(f.duration||T||Ff),ae=be.useRef(null),se=be.useRef(null),ue=b===0,le=b+1<=g,de=f.type,pe=de??"default",he=f.dismissible!==!1,ce=f.className||"",ye=f.descriptionClassName||"",xe=be.useMemo(()=>x.findIndex(oe=>oe.toastId===f.id)||0,[x,f.id]),me=be.useMemo(()=>{var oe;return(oe=f.closeButton)!=null?oe:k},[f.closeButton,k]),je=be.useMemo(()=>f.duration||T||Ff,[f.duration,T]),Se=be.useRef(0),Pe=be.useRef(0),Re=be.useRef(0),Ie=be.useRef(null),[De,Le]=E.split("-"),ze=be.useMemo(()=>x.reduce((oe,ge,Ee)=>Ee>=xe?oe:oe+ge.height,0),[x,xe]),Te=yw(),Ce=be.useMemo(()=>{var oe;return(oe=n.swipeDirections)!=null?oe:Ow(E)},[n.swipeDirections,E]),We=f.invert||u,Fe=de==="loading";Pe.current=be.useMemo(()=>xe*R+ze,[xe,ze]),be.useEffect(()=>{ie.current=je},[je]),be.useEffect(()=>{U(!0)},[]),be.useEffect(()=>{const oe=se.current;if(oe){const ge=oe.getBoundingClientRect().height;return re(ge),h(Ee=>[{toastId:f.id,height:ge,position:f.position},...Ee]),()=>h(Ee=>Ee.filter($e=>$e.toastId!==f.id))}},[h,f.id]),be.useLayoutEffect(()=>{if(!W)return;const oe=se.current,ge=oe.style.height;oe.style.height="auto";const Ee=oe.getBoundingClientRect().height;oe.style.height=ge,re(Ee),h($e=>$e.find(Ke=>Ke.toastId===f.id)?$e.map(Ke=>Ke.toastId===f.id?{...Ke,height:Ee}:Ke):[{toastId:f.id,height:Ee,position:f.position},...$e])},[W,f.title,f.description,h,f.id,f.jsx,f.action,f.cancel]);const Ne=be.useCallback(()=>{K(!0),te(Pe.current),h(oe=>oe.filter(ge=>ge.toastId!==f.id)),setTimeout(()=>{S(f)},Mw)},[f,S,h,Pe]);be.useEffect(()=>{if(f.promise&&de==="loading"||f.duration===1/0||f.type==="loading")return;let oe;return v||p||Te?(()=>{if(Re.current<Se.current){const $e=new Date().getTime()-Se.current;ie.current=ie.current-$e}Re.current=new Date().getTime()})():(()=>{ie.current!==1/0&&(Se.current=new Date().getTime(),oe=setTimeout(()=>{f.onAutoClose==null||f.onAutoClose.call(f,f),Ne()},ie.current))})(),()=>clearTimeout(oe)},[v,p,f,de,Te,Ne]),be.useEffect(()=>{f.delete&&(Ne(),f.onDismiss==null||f.onDismiss.call(f,f))},[Ne,f.delete]);function fe(){var oe;if(M!=null&&M.loading){var ge;return be.createElement("div",{className:$n(I==null?void 0:I.loader,f==null||(ge=f.classNames)==null?void 0:ge.loader,"sonner-loader"),"data-visible":de==="loading"},M.loading)}return be.createElement(pw,{className:$n(I==null?void 0:I.loader,f==null||(oe=f.classNames)==null?void 0:oe.loader),visible:de==="loading"})}const Oe=f.icon||(M==null?void 0:M[de])||fw(de);var Ae,Be;return be.createElement("li",{tabIndex:0,ref:se,className:$n(P,ce,I==null?void 0:I.toast,f==null||(e=f.classNames)==null?void 0:e.toast,I==null?void 0:I[pe],f==null||(t=f.classNames)==null?void 0:t[pe]),"data-sonner-toast":"","data-rich-colors":(Ae=f.richColors)!=null?Ae:j,"data-styled":!(f.jsx||f.unstyled||m),"data-mounted":W,"data-promise":!!f.promise,"data-swiped":Q,"data-removed":H,"data-visible":le,"data-y-position":De,"data-x-position":Le,"data-index":b,"data-front":ue,"data-swiping":V,"data-dismissible":he,"data-type":de,"data-invert":We,"data-swipe-out":G,"data-swipe-direction":F,"data-expanded":!!(v||$&&W),"data-testid":f.testId,style:{"--index":b,"--toasts-before":b,"--z-index":w.length-b,"--offset":`${H?Z:Pe.current}px`,"--initial-height":$?"auto":`${ne}px`,...C,...f.style},onDragEnd:()=>{Y(!1),L(null),Ie.current=null},onPointerDown:oe=>{oe.button!==2&&(Fe||!he||(ae.current=new Date,te(Pe.current),oe.target.setPointerCapture(oe.pointerId),oe.target.tagName!=="BUTTON"&&(Y(!0),Ie.current={x:oe.clientX,y:oe.clientY})))},onPointerUp:()=>{var oe,ge,Ee;if(G||!he)return;Ie.current=null;const $e=Number(((oe=se.current)==null?void 0:oe.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),He=Number(((ge=se.current)==null?void 0:ge.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Ke=new Date().getTime()-((Ee=ae.current)==null?void 0:Ee.getTime()),nt=O==="x"?$e:He,Ye=Math.abs(nt)/Ke;if((O==="x"?Ce.includes($e>0?"right":"left"):Ce.includes(He>0?"bottom":"top"))&&(Math.abs(nt)>=$w||Ye>.11)){te(Pe.current),f.onDismiss==null||f.onDismiss.call(f,f),z(O==="x"?$e>0?"right":"left":He>0?"down":"up"),Ne(),J(!0);return}else{var Ue,st;(Ue=se.current)==null||Ue.style.setProperty("--swipe-amount-x","0px"),(st=se.current)==null||st.style.setProperty("--swipe-amount-y","0px")}X(!1),Y(!1),L(null)},onPointerMove:oe=>{var ge,Ee,$e;if(!Ie.current||!he||((ge=window.getSelection())==null?void 0:ge.toString().length)>0)return;const Ke=oe.clientY-Ie.current.y,nt=oe.clientX-Ie.current.x;!O&&(Math.abs(nt)>1||Math.abs(Ke)>1)&&L(Math.abs(nt)>Math.abs(Ke)?"x":"y");let Ye={x:0,y:0};const Me=Ue=>1/(1.5+Math.abs(Ue)/20);if(O==="y"){if(Ce.includes("top")||Ce.includes("bottom"))if(Ce.includes("top")&&Ke<0||Ce.includes("bottom")&&Ke>0)Ye.y=Ke;else{const Ue=Ke*Me(Ke);Ye.y=Math.abs(Ue)<Math.abs(Ke)?Ue:Ke}}else if(O==="x"&&(Ce.includes("left")||Ce.includes("right")))if(Ce.includes("left")&&nt<0||Ce.includes("right")&&nt>0)Ye.x=nt;else{const Ue=nt*Me(nt);Ye.x=Math.abs(Ue)<Math.abs(nt)?Ue:nt}(Math.abs(Ye.x)>0||Math.abs(Ye.y)>0)&&X(!0),(Ee=se.current)==null||Ee.style.setProperty("--swipe-amount-x",`${Ye.x}px`),($e=se.current)==null||$e.style.setProperty("--swipe-amount-y",`${Ye.y}px`)}},me&&!f.jsx&&de!=="loading"?be.createElement("button",{"aria-label":D,"data-disabled":Fe,"data-close-button":!0,onClick:Fe||!he?()=>{}:()=>{Ne(),f.onDismiss==null||f.onDismiss.call(f,f)},className:$n(I==null?void 0:I.closeButton,f==null||(s=f.classNames)==null?void 0:s.closeButton)},(Be=M==null?void 0:M.close)!=null?Be:vw):null,(de||f.icon||f.promise)&&f.icon!==null&&((M==null?void 0:M[de])!==null||f.icon)?be.createElement("div",{"data-icon":"",className:$n(I==null?void 0:I.icon,f==null||(o=f.classNames)==null?void 0:o.icon)},de==="loading"?f.icon||fe():f.promise?fe():null,de!=="loading"?Oe:null):null,be.createElement("div",{"data-content":"",className:$n(I==null?void 0:I.content,f==null||(i=f.classNames)==null?void 0:i.content)},be.createElement("div",{"data-title":"",className:$n(I==null?void 0:I.title,f==null||(a=f.classNames)==null?void 0:a.title)},f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title),f.description?be.createElement("div",{"data-description":"",className:$n(A,ye,I==null?void 0:I.description,f==null||(l=f.classNames)==null?void 0:l.description)},typeof f.description=="function"?f.description():f.description):null),be.isValidElement(f.cancel)?f.cancel:f.cancel&&ui(f.cancel)?be.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||N,onClick:oe=>{ui(f.cancel)&&he&&(f.cancel.onClick==null||f.cancel.onClick.call(f.cancel,oe),Ne())},className:$n(I==null?void 0:I.cancelButton,f==null||(c=f.classNames)==null?void 0:c.cancelButton)},f.cancel.label):null,be.isValidElement(f.action)?f.action:f.action&&ui(f.action)?be.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||_,onClick:oe=>{ui(f.action)&&(f.action.onClick==null||f.action.onClick.call(f.action,oe),!oe.defaultPrevented&&Ne())},className:$n(I==null?void 0:I.actionButton,f==null||(d=f.classNames)==null?void 0:d.actionButton)},f.action.label):null)};function Bf(){if(typeof window>"u"||typeof document>"u")return"ltr";const n=document.documentElement.getAttribute("dir");return n==="auto"||!n?window.getComputedStyle(document.documentElement).direction:n}function Lw(n,e){const t={};return[n,e].forEach((s,o)=>{const i=o===1,a=i?"--mobile-offset":"--offset",l=i?Aw:Pw;function c(d){["top","right","bottom","left"].forEach(u=>{t[`${a}-${u}`]=typeof d=="number"?`${d}px`:d})}typeof s=="number"||typeof s=="string"?c(s):typeof s=="object"?["top","right","bottom","left"].forEach(d=>{s[d]===void 0?t[`${a}-${d}`]=l:t[`${a}-${d}`]=typeof s[d]=="number"?`${s[d]}px`:s[d]}):c(l)}),t}const zw=be.forwardRef(function(e,t){const{id:s,invert:o,position:i="bottom-right",hotkey:a=["altKey","KeyT"],expand:l,closeButton:c,className:d,offset:u,mobileOffset:f,theme:m="light",richColors:p,duration:h,style:g,visibleToasts:x=Ew,toastOptions:b,dir:w=Bf(),gap:v=Iw,icons:S,customAriaLabel:j,containerAriaLabel:k="Notifications"}=e,[C,N]=be.useState([]),_=be.useMemo(()=>s?C.filter(U=>U.toasterId===s):C.filter(U=>!U.toasterId),[C,s]),P=be.useMemo(()=>Array.from(new Set([i].concat(_.filter(U=>U.position).map(U=>U.position)))),[_,i]),[A,T]=be.useState([]),[E,R]=be.useState(!1),[$,I]=be.useState(!1),[M,D]=be.useState(m!=="system"?m:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),O=be.useRef(null),L=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),F=be.useRef(null),z=be.useRef(!1),W=be.useCallback(U=>{N(H=>{var K;return(K=H.find(V=>V.id===U.id))!=null&&K.delete||Xt.dismiss(U.id),H.filter(({id:V})=>V!==U.id)})},[]);return be.useEffect(()=>Xt.subscribe(U=>{if(U.dismiss){requestAnimationFrame(()=>{N(H=>H.map(K=>K.id===U.id?{...K,delete:!0}:K))});return}setTimeout(()=>{wv.flushSync(()=>{N(H=>{const K=H.findIndex(V=>V.id===U.id);return K!==-1?[...H.slice(0,K),{...H[K],...U},...H.slice(K+1)]:[U,...H]})})})}),[]),be.useEffect(()=>{if(m!=="system"){D(m);return}if(m==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?D("dark"):D("light")),typeof window>"u")return;const U=window.matchMedia("(prefers-color-scheme: dark)");try{U.addEventListener("change",({matches:H})=>{D(H?"dark":"light")})}catch{U.addListener(({matches:K})=>{try{D(K?"dark":"light")}catch(V){console.error(V)}})}},[m]),be.useEffect(()=>{C.length<=1&&R(!1)},[C]),be.useEffect(()=>{const U=H=>{var K;if(a.length>0&&a.every(G=>H[G]||H.code===G)){var Y;R(!0),(Y=O.current)==null||Y.focus()}H.code==="Escape"&&(document.activeElement===O.current||(K=O.current)!=null&&K.contains(document.activeElement))&&R(!1)};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[a]),be.useEffect(()=>{if(O.current)return()=>{F.current&&(F.current.focus({preventScroll:!0}),F.current=null,z.current=!1)}},[O.current]),be.createElement("section",{ref:t,"aria-label":j??`${k} ${L}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0,"data-react-aria-top-layer":!0},P.map((U,H)=>{var K;const[V,Y]=U.split("-");return _.length?be.createElement("ol",{key:U,dir:w==="auto"?Bf():w,tabIndex:-1,ref:O,className:d,"data-sonner-toaster":!0,"data-sonner-theme":M,"data-y-position":V,"data-x-position":Y,style:{"--front-toast-height":`${((K=A[0])==null?void 0:K.height)||0}px`,"--width":`${Rw}px`,"--gap":`${v}px`,...g,...Lw(u,f)},onBlur:G=>{z.current&&!G.currentTarget.contains(G.relatedTarget)&&(z.current=!1,F.current&&(F.current.focus({preventScroll:!0}),F.current=null))},onFocus:G=>{G.target instanceof HTMLElement&&G.target.dataset.dismissible==="false"||z.current||(z.current=!0,F.current=G.relatedTarget)},onMouseEnter:()=>R(!0),onMouseMove:()=>R(!0),onMouseLeave:()=>{$||R(!1)},onDragEnd:()=>R(!1),onPointerDown:G=>{G.target instanceof HTMLElement&&G.target.dataset.dismissible==="false"||I(!0)},onPointerUp:()=>I(!1)},_.filter(G=>!G.position&&H===0||G.position===U).map((G,J)=>{var Q,X;return be.createElement(Dw,{key:G.id,icons:S,index:J,toast:G,defaultRichColors:p,duration:(Q=b==null?void 0:b.duration)!=null?Q:h,className:b==null?void 0:b.className,descriptionClassName:b==null?void 0:b.descriptionClassName,invert:o,visibleToasts:x,closeButton:(X=b==null?void 0:b.closeButton)!=null?X:c,interacting:$,position:U,style:b==null?void 0:b.style,unstyled:b==null?void 0:b.unstyled,classNames:b==null?void 0:b.classNames,cancelButtonStyle:b==null?void 0:b.cancelButtonStyle,actionButtonStyle:b==null?void 0:b.actionButtonStyle,closeButtonAriaLabel:b==null?void 0:b.closeButtonAriaLabel,removeToast:W,toasts:_.filter(Z=>Z.position==G.position),heights:A.filter(Z=>Z.position==G.position),setHeights:T,expandByDefault:l,gap:v,expanded:E,swipeDirections:e.swipeDirections})})):null}))}),Fw=n=>{const e=B.c(6);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s,o;e[2]===Symbol.for("react.memo_cache_sentinel")?(s={success:r.jsx(Bn,{className:"size-4"}),info:r.jsx(Uc,{className:"size-4"}),warning:r.jsx(xn,{className:"size-4"}),error:r.jsx(_v,{className:"size-4"}),loading:r.jsx(ot,{className:"size-4 animate-spin"})},o={"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)"},e[2]=s,e[3]=o):(s=e[2],o=e[3]);let i;return e[4]!==t?(i=r.jsx(zw,{className:"toaster group",icons:s,style:o,...t}),e[4]=t,e[5]=i):i=e[5],i};function Bw(n){const e=B.c(13),{activeError:t,clearActiveError:s,modelFallbackNotice:o,dismissModelFallbackNotice:i,connectionLost:a,theme:l}=n;let c,d;e[0]!==t||e[1]!==s?(c=()=>{if(!t){$s.dismiss("app-error");return}$s.error(t,{id:"app-error",duration:8e3,onDismiss:s,onAutoClose:s})},d=[t,s],e[0]=t,e[1]=s,e[2]=c,e[3]=d):(c=e[2],d=e[3]),y.useEffect(c,d);let u,f;e[4]!==i||e[5]!==o?(u=()=>{if(!o){$s.dismiss("model-fallback");return}$s.warning(o,{id:"model-fallback",duration:1/0,onDismiss:i})},f=[i,o],e[4]=i,e[5]=o,e[6]=u,e[7]=f):(u=e[6],f=e[7]),y.useEffect(u,f);let m,p;e[8]!==a?(m=()=>{if(!a){$s.dismiss("session-connection");return}$s.warning("Connection lost",{id:"session-connection",description:"Reconnecting to the live session…",duration:1/0})},p=[a],e[8]=a,e[9]=m,e[10]=p):(m=e[9],p=e[10]),y.useEffect(m,p);const h=l==="light"?"light":"dark";let g;return e[11]!==h?(g=r.jsx(Fw,{theme:h,position:"bottom-center",closeButton:!0,visibleToasts:3}),e[11]=h,e[12]=g):g=e[12],g}const Ct="local",jg="cogpit-last-path::",lc=new Map;function yt(){var t;const n=typeof window<"u"?(t=window.location)==null?void 0:t.pathname:void 0;if(!n)return Ct;const e=/^\/d\/([^/]+)/.exec(n);return e?e[1]:Ct}function Bs(){return yt()!==Ct}function Sg(){const n=yt();return n===Ct?"":`/hub/${n}`}function Ng(n){const e=Sg();return!e||n.startsWith("/api/hub/")||n.startsWith("/api/auth/")?n:n.startsWith("/api")||n.startsWith("/__pty")?`${e}${n}`:n}let cr=null;function kg(n){n!==cr&&(cr=n,window.dispatchEvent(new Event("cogpit-identity-changed")))}function js(){return cr}function Pi(n){return n===Ct?0:lc.get(n)??0}function Uw(n,e){if(n===Ct||!Number.isSafeInteger(e)||e<0)return!1;const t=lc.get(n);return t!==void 0&&e<=t?!1:(lc.set(n,e),window.dispatchEvent(new CustomEvent("cogpit-device-scope-changed",{detail:{deviceId:n,connectionRevision:e}})),!0)}function Nn(){const n=yt(),e=Pi(n);return e===0?n:`${n}@${e}`}function Kt(n){const e=yt(),t=Nn();return cr!==null?`${n}::${t}::${cr}`:e===Ct?n:`${n}::${t}`}function Oo(n,e){sessionStorage.setItem(`${jg}${n}`,e)}function Ss(n){const t=sessionStorage.getItem(`${jg}${n}`)??(n===Ct?"/":`/d/${n}/`);window.history.pushState(null,"",t),window.dispatchEvent(new Event("cogpit-device-changed"))}const Uf="cogpit-network-token",Ww=new Set(["localhost","127.0.0.1","::1","0:0:0:0:0:0:0:1"]);function ba(){const n=window.location.hostname.toLowerCase(),e=n.startsWith("[")&&n.endsWith("]")?n.slice(1,-1):n;return!Ww.has(e)}function va(){try{localStorage.removeItem(Uf),sessionStorage.removeItem(Uf)}catch{}}typeof window<"u"&&va();const Hw={edition:"personal",needsBootstrap:!1};let dr=null,bo=null;function Cg(){return fetch("/api/hello",{method:"GET",credentials:"same-origin",cache:"no-store",headers:{"X-Cogpit-Client":"1"}}).then(async n=>{if(!n.ok)throw new Error(`Hello handshake failed (${n.status})`);const e=await n.json();return bo=e.edition==="team"?"team":"personal",{edition:bo,needsBootstrap:bo==="team"&&e.needsBootstrap===!0}}).catch(()=>(dr=null,Hw))}function _g(){return dr??(dr=Cg()),dr}function Wf(){return dr=Cg(),dr}function Tg(){return _g().then(n=>n.edition)}async function Kw(){if(!ba()&&bo!=="team")return!0;try{return(await fetch("/api/auth/session",{method:"GET",credentials:"same-origin",cache:"no-store",headers:{"X-Cogpit-Client":"1"}})).ok}catch{return!1}}async function qw(){try{await fetch("/api/auth/logout",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"X-Cogpit-Client":"1"}})}finally{va()}}function Hf(){return va(),window.dispatchEvent(new Event("cogpit-auth-required")),Promise.reject(new Error("Authentication required"))}function Eg(n,e,t){t&&typeof n=="string"&&n.startsWith("/api")&&(n=Ng(n));const s=new Headers(e==null?void 0:e.headers);return s.delete("Authorization"),s.set("X-Cogpit-Client","1"),fetch(n,{...e,headers:s,credentials:"same-origin"}).then(o=>{if(o.status===401){if(ba()||bo==="team")return Hf();if(bo===null)return Tg().then(i=>i==="team"?Hf():o)}if(o.status===502){const i=o.headers.get("X-Cogpit-Hub-Error"),a=o.headers.get("X-Cogpit-Device");a&&(i==="DEVICE_UNREACHABLE"||i==="DEVICE_AUTH_FAILED")&&window.dispatchEvent(new CustomEvent("cogpit-device-unreachable",{detail:{deviceId:a,reason:i}}))}return o})}function ve(n,e){return Eg(n,e,!0)}function fs(n,e){return Eg(n,e,!1)}function Rr(n){return Ng(n)}let Kf=!1;function Vw(n){return Array.isArray(n)&&n.length>0&&n.every(e=>e&&typeof e=="object"&&typeof e.value=="string"&&typeof e.label=="string")}async function Gw(){if(!Kf){Kf=!0;try{const n=await ve("/api/models");if(!n.ok)return;const e=await n.json();for(const t of ws){const s=e==null?void 0:e[t];Vw(s)&&tw(t,s)}}catch{}}}function Pg(n){const e=B.c(3);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0],y.useEffect(Yw,t);let s;return e[1]!==n?(s=()=>bg(n),e[1]=n,e[2]=s):s=e[2],y.useSyncExternalStore(nw,s)}function Yw(){Gw()}function Wn(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(Ev,{"data-slot":"dropdown-menu",...t}),e[2]=t,e[3]=s):s=e[3],s}function Hn(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(Pv,{"data-slot":"dropdown-menu-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function Kn(n){const e=B.c(18);let t,s,o,i,a,l;e[0]!==n?({align:o,alignOffset:i,side:a,sideOffset:l,className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a,e[6]=l):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5],l=e[6]);const c=o===void 0?"start":o,d=i===void 0?0:i,u=a===void 0?"bottom":a,f=l===void 0?4:l;let m;e[7]!==t?(m=q("z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 ease-out outline-none data-[side=bottom]:slide-in-from-top-1 data-[side=inline-end]:slide-in-from-left-1 data-[side=inline-start]:slide-in-from-right-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",t),e[7]=t,e[8]=m):m=e[8];let p;e[9]!==s||e[10]!==m?(p=r.jsx(Dh,{"data-slot":"dropdown-menu-content",className:m,...s}),e[9]=s,e[10]=m,e[11]=p):p=e[11];let h;return e[12]!==c||e[13]!==d||e[14]!==u||e[15]!==f||e[16]!==p?(h=r.jsx(zh,{children:r.jsx(Fh,{className:"isolate z-50 outline-none",align:c,alignOffset:d,side:u,sideOffset:f,children:p})}),e[12]=c,e[13]=d,e[14]=u,e[15]=f,e[16]=p,e[17]=h):h=e[17],h}function en(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(Lh,{"data-slot":"dropdown-menu-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function Us(n){const e=B.c(10);let t,s,o;e[0]!==n?({className:t,inset:s,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==t?(i=q("px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",t),e[4]=t,e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o||e[8]!==i?(a=r.jsx(Bh,{"data-slot":"dropdown-menu-label","data-inset":s,className:i,...o}),e[6]=s,e[7]=o,e[8]=i,e[9]=a):a=e[9],a}function _t(n){const e=B.c(12);let t,s,o,i;e[0]!==n?({className:t,inset:s,variant:i,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);const a=i===void 0?"default":i;let l;e[5]!==t?(l=q("group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none transition-colors duration-75 focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",t),e[5]=t,e[6]=l):l=e[6];let c;return e[7]!==s||e[8]!==o||e[9]!==l||e[10]!==a?(c=r.jsx(Oh,{"data-slot":"dropdown-menu-item","data-inset":s,"data-variant":a,className:l,...o}),e[7]=s,e[8]=o,e[9]=l,e[10]=a,e[11]=c):c=e[11],c}function Xw(n){const e=B.c(15);let t,s,o,i,a;e[0]!==n?({className:o,children:s,checked:t,inset:i,...a}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5]);let l;e[6]!==o?(l=q("relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none transition-colors duration-75 focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",o),e[6]=o,e[7]=l):l=e[7];let c;e[8]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx("span",{className:"pointer-events-none absolute right-2 flex items-center justify-center","data-slot":"dropdown-menu-checkbox-item-indicator",children:r.jsx($v,{className:"transition-[opacity,transform,scale] duration-100 ease-out motion-safe:data-starting-style:scale-75 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:scale-75 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none",children:r.jsx(mt,{})})}),e[8]=c):c=e[8];let d;return e[9]!==t||e[10]!==s||e[11]!==i||e[12]!==a||e[13]!==l?(d=r.jsxs(Rv,{"data-slot":"dropdown-menu-checkbox-item","data-inset":i,className:l,checked:t,...a,children:[c,s]}),e[9]=t,e[10]=s,e[11]=i,e[12]=a,e[13]=l,e[14]=d):d=e[14],d}function Fi(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(Iv,{"data-slot":"dropdown-menu-radio-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function rd(n){const e=B.c(15);let t,s,o,i,a;e[0]!==n?({className:s,children:t,inset:o,closeOnClick:a,...i}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5]);const l=a===void 0?!0:a;let c;e[6]!==s?(c=q("relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none transition-colors duration-75 focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",s),e[6]=s,e[7]=c):c=e[7];let d;e[8]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx("span",{className:"pointer-events-none absolute right-2 flex items-center justify-center","data-slot":"dropdown-menu-radio-item-indicator",children:r.jsx(Av,{className:"transition-[opacity,transform,scale] duration-100 ease-out motion-safe:data-starting-style:scale-75 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:scale-75 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none",children:r.jsx(mt,{})})}),e[8]=d):d=e[8];let u;return e[9]!==t||e[10]!==l||e[11]!==o||e[12]!==i||e[13]!==c?(u=r.jsxs(Tv,{"data-slot":"dropdown-menu-radio-item","data-inset":o,closeOnClick:l,className:c,...i,children:[d,t]}),e[9]=t,e[10]=l,e[11]=o,e[12]=i,e[13]=c,e[14]=u):u=e[14],u}function ur(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("-mx-1 my-1 h-px bg-border",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Wc,{"data-slot":"dropdown-menu-separator",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}nn("claude").contextWindow.compactBuffer;function Jw(n,e){var a;const{defaultLimit:t,limits:s,extendedContext:o}=nn(e).contextWindow,i=n.trim().toLowerCase();return o&&i.includes(o.marker)?o.limit:((a=s.find(l=>i.includes(l.match)))==null?void 0:a.limit)??t}function Qw(n,e,t){const s=typeof n.input_tokens=="number"?n.input_tokens:0,o=typeof n.cache_creation_input_tokens=="number"?n.cache_creation_input_tokens:0,i=typeof n.cache_read_input_tokens=="number"?n.cache_read_input_tokens:0,a=s+o+i,l=Jw(e,t),c=l-nn(t).contextWindow.compactBuffer;return{used:a,limit:l,compactAt:c,percent:Math.min(100,a/c*100),percentAbsolute:Math.min(100,a/l*100)}}function mn(n){return Number.isFinite(n)?n<.01?`$${n.toFixed(4)}`:n<1?`$${n.toFixed(3)}`:`$${n.toFixed(2)}`:"—"}const Zw=["fable","mythos","opus","sonnet","haiku"];function qf(n){return n.charAt(0).toUpperCase()+n.slice(1)}function Js(n){if(!n)return"unknown";const e=n.toLowerCase(),t=/\[1m\]$/.test(e)?" 1M":"",s=e.replace(/\[[^\]]*\]$/,"");for(const o of Zw){const i=s.match(new RegExp(`${o}(?:-(\\d+)(?:-(\\d{1,2}))?(?!\\d))?`));if(!i)continue;const a=i[1]?` ${i[1]}${i[2]?`.${i[2]}`:""}`:"";return`${qf(o)}${a}${t}`}if(s.startsWith("gpt-")){const[o,...i]=s.slice(4).split("-"),a=i.map(qf).join(" ");return`GPT-${o}${a?` ${a}`:""}${t}`}return n.length>20?n.slice(0,20)+"...":n}function ut(n){return n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}k`:String(n)}function Fn(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 ej(n){if(n<60)return`${n}s`;const e=Math.floor(n/60),t=n%60;return`${e}m ${t}s`}function Ag(n){return n>=1e6?`${(n/1e6).toFixed(1)}MB`:n>=1e3?`${(n/1e3).toFixed(0)}KB`:`${n}B`}function Ir(n){const e=Date.now()-new Date(n).getTime(),t=Math.floor(e/6e4);if(t<1)return"now";if(t<60)return`${t}m`;const s=Math.floor(t/60);if(s<24)return`${s}h`;const o=Math.floor(s/24);return o<7?`${o}d`:new Date(n).toLocaleDateString()}function id(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 ad(n){if(n.durationMs!==null)return n.durationMs;if(!n.timestamp)return null;let e=0,t=n.timestamp,s="";const o=a=>{a&&a>s&&(s=a)},i=()=>{if(!s)return;const a=new Date(s).getTime()-new Date(t).getTime();a>0&&(e+=a),s=""};for(const a of n.contentBlocks){if(a.kind==="task_notification"){i(),a.timestamp&&(t=a.timestamp);continue}if(o(a.timestamp),a.kind==="tool_calls"||a.kind==="plan_mode")for(const l of a.toolCalls)o(l.timestamp)}return i(),e>0?e:null}function kn(n,e){return n.length<=e?n:n.slice(0,e)+"..."}function _n(n){return Es(n).dirName.decode(n)??n}function ya(n,e=2){const t=n.replace(/\/+$/,"").split("/").filter(Boolean);return t.length<=e?n:t.slice(-e).join("/")}function wa(n){const e="/.worktrees/",t=n.indexOf(e);if(t===-1)return null;const s=n.slice(t+e.length).split("/")[0];return s?{parentPath:n.slice(0,t),worktreeName:s}:null}function Qn(n){return n.replace(/\/+$/,"").split("/").at(-1)??n}function Ns(n){const e=n.match(/^([^/]+)\/subagents\/agent-([^.]+)\.jsonl$/);return e?{parentSessionId:e[1],agentId:e[2],parentFileName:`${e[1]}.jsonl`}:null}function Rg(n){for(let e=n.length-1;e>=0;e--){const t=n[e];if(t.type==="assistant")return Qw(t.message.usage,t.message.model??"","claude")}return null}const Ig={claude:yo,codex:Nr,copilot:Uh},ld={claude:"Claude",codex:"Codex",copilot:"Copilot"},tj={claude:"Claude",codex:"Codex",copilot:"GitHub Copilot"},nj={claude:null,codex:"Codex",copilot:"Copilot"},sj={claude:{letter:"C",label:"Loaded by Claude Code"},codex:{letter:"X",label:"Loaded by Codex CLI"},copilot:{letter:"G",label:"Loaded by GitHub Copilot CLI"}},oj={claude:"var(--chart-1)",codex:"var(--chart-2)",copilot:"var(--chart-3)"},rj={claude:"Interrupt agent",codex:"Stop active turn",copilot:"Stop Copilot turn"},ij={claude:[{value:"default",label:"Ask",description:"Ask before sensitive actions"},{value:"plan",label:"Plan",description:"Read and plan without changing files"},{value:"acceptEdits",label:"Accept Edits",description:"Allow file edits; ask for other actions"},{value:"auto",label:"Auto",description:"Run autonomously with classifier safeguards"},{value:"dontAsk",label:"Don't Ask",description:"Deny actions that need approval"},{value:"bypassPermissions",label:"Full access",description:"Skip permission checks"}],codex:[{value:"default",label:"Workspace",description:"Write inside the project sandbox"},{value:"plan",label:"Read only",description:"Inspect and plan without writing"},{value:"bypassPermissions",label:"Full access",description:"No sandbox or approval checks"}],copilot:[{value:"default",label:"Ask",description:"Ask before running tools or changing files"},{value:"plan",label:"Plan",description:"Explore and plan without changing project files"},{value:"auto",label:"Autopilot",description:"Implement autonomously until the task is complete"},{value:"bypassPermissions",label:"Full access",description:"Allow tools, paths, and URLs without asking"}]};function aj(n){return ij[n]}function lj(n){return Ig[n]}function ja(n){return ld[n]}function LL(n){return tj[n]}function cj(n){return nj[n]}function zL(n){return sj[n]}function dj(n){return rj[n]}function uj(n){return oj[n]}const Vf=Es(null).kind,$g=[Vf,...ws.filter(n=>n!==Vf)];function fj(n){return`This ${ld[n]} session is controlled by another process. Cogpit can only view it.`}const cc=$g.map(n=>({value:n,label:ld[n],Icon:Ig[n]}));function mj(n,e){const t=e==null?void 0:e.filter(s=>s.value!=="");return(t==null?void 0:t.find(s=>s.value===n))??(t==null?void 0:t.find(s=>s.resolvedModel===n))}function pj(n){var t;const e=(t=n.find(s=>s.value===""))==null?void 0:t.resolvedModel;return e?cd(e,n):"Default"}function cd(n,e){var t;return((t=mj(n,e))==null?void 0:t.label)??Js(n)}function Mg(n){const e=B.c(11),{option:t,descriptionWidth:s}=n,o=s===void 0?"max-w-64":s,i=t.menuLabel??t.label;let a;e[0]!==i?(a=r.jsx("span",{children:i}),e[0]=i,e[1]=a):a=e[1];let l;e[2]!==o||e[3]!==t.description?(l=t.description&&r.jsx("span",{className:q(o,"truncate text-xs font-normal text-muted-foreground"),children:t.description}),e[2]=o,e[3]=t.description,e[4]=l):l=e[4];let c;e[5]!==a||e[6]!==l?(c=r.jsxs("span",{className:"flex min-w-0 flex-col items-start",children:[a,l]}),e[5]=a,e[6]=l,e[7]=c):c=e[7];let d;return e[8]!==t.value||e[9]!==c?(d=r.jsx(rd,{value:t.value,className:"items-start py-2",children:c}),e[8]=t.value,e[9]=c,e[10]=d):d=e[10],d}function hj(n){var A,T;const e=B.c(33),{agentKind:t,onAgentKindChange:s,value:o,fallbackLabel:i,options:a,onChange:l}=n;let c;e[0]!==t?(c=((A=cc.find(E=>E.value===t))==null?void 0:A.label)??t,e[0]=t,e[1]=c):c=e[1];const d=c;let u;e[2]!==i||e[3]!==a||e[4]!==o?(u=((T=a.find(E=>E.value===o))==null?void 0:T.label)??i,e[2]=i,e[3]=a,e[4]=o,e[5]=u):u=e[5];const f=u;let m;e[6]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(ee,{type:"button",variant:"ghost",size:"xs"}),e[6]=m):m=e[6];const p=`${d} / ${f}`;let h;e[7]!==p?(h=r.jsx("span",{className:"truncate",children:p}),e[7]=p,e[8]=h):h=e[8];let g;e[9]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx(tt,{"data-icon":"inline-end"}),e[9]=g):g=e[9];let x;e[10]!==h?(x=r.jsxs(Hn,{render:m,children:[h,g]}),e[10]=h,e[11]=x):x=e[11];let b;e[12]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx(Us,{children:"Agent"}),e[12]=b):b=e[12];let w;e[13]!==s?(w=E=>s(E),e[13]=s,e[14]=w):w=e[14];let v;e[15]===Symbol.for("react.memo_cache_sentinel")?(v=cc.map(xj),e[15]=v):v=e[15];let S;e[16]!==t||e[17]!==w?(S=r.jsxs(en,{children:[b,r.jsx(Fi,{value:t,onValueChange:w,children:v})]}),e[16]=t,e[17]=w,e[18]=S):S=e[18];let j;e[19]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(ur,{}),e[19]=j):j=e[19];let k;e[20]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(Us,{children:"Model"}),e[20]=k):k=e[20];let C;e[21]!==a?(C=a.map(gj),e[21]=a,e[22]=C):C=e[22];let N;e[23]!==l||e[24]!==C||e[25]!==o?(N=r.jsxs(en,{children:[k,r.jsx(Fi,{value:o,onValueChange:l,children:C})]}),e[23]=l,e[24]=C,e[25]=o,e[26]=N):N=e[26];let _;e[27]!==S||e[28]!==N?(_=r.jsxs(Kn,{"aria-label":"Agent and model",className:"w-80",children:[S,j,N]}),e[27]=S,e[28]=N,e[29]=_):_=e[29];let P;return e[30]!==_||e[31]!==x?(P=r.jsxs(Wn,{children:[x,_]}),e[30]=_,e[31]=x,e[32]=P):P=e[32],P}function gj(n){return r.jsx(Mg,{option:n,descriptionWidth:"max-w-80"},n.value)}function xj(n){const e=n.Icon;return r.jsxs(rd,{value:n.value,children:[r.jsx(e,{}),n.label]},n.value)}function bj(n){const e=B.c(44),{servers:t,selected:s,onToggle:o,onRefresh:i,loading:a,onAuth:l}=n;let c;e[0]!==t?(c=t.filter(vj),e[0]=t,e[1]=c):c=e[1];const d=c.length;let u;e[2]!==s?(u=new Set(s),e[2]=s,e[3]=u):u=e[3];const f=u,m=y.useId();let p,h;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(ee,{type:"button",variant:"ghost",size:"xs"}),h=r.jsx(Mv,{"data-icon":"inline-start"}),e[4]=p,e[5]=h):(p=e[4],h=e[5]);const g=a&&t.length===0?"MCPs":`MCPs ${s.length}/${d}`;let x;e[6]!==g?(x=r.jsx("span",{className:"truncate",children:g}),e[6]=g,e[7]=x):x=e[7];let b;e[8]!==a||e[9]!==t.length?(b=a&&t.length===0?r.jsx(Ot,{"data-icon":"inline-end",className:"animate-spin"}):r.jsx(tt,{"data-icon":"inline-end"}),e[8]=a,e[9]=t.length,e[10]=b):b=e[10];let w;e[11]!==x||e[12]!==b?(w=r.jsxs(Hn,{render:p,children:[h,x,b]}),e[11]=x,e[12]=b,e[13]=w):w=e[13];let v;e[14]!==m?(v=r.jsx(Us,{id:m,children:"MCP servers"}),e[14]=m,e[15]=v):v=e[15];const S=a?"animate-spin":void 0;let j;e[16]!==S?(j=r.jsx(Ot,{"data-icon":"inline-start",className:S}),e[16]=S,e[17]=j):j=e[17];let k;e[18]!==i||e[19]!==j?(k=r.jsxs(_t,{closeOnClick:!1,onClick:i,children:[j,"Refresh status"]}),e[18]=i,e[19]=j,e[20]=k):k=e[20];let C;e[21]!==a||e[22]!==t.length?(C=t.length===0&&r.jsx(_t,{disabled:!0,children:a?"Loading...":"No MCP servers configured"}),e[21]=a,e[22]=t.length,e[23]=C):C=e[23];let N;if(e[24]!==l||e[25]!==o||e[26]!==f||e[27]!==t){let T;e[29]!==l||e[30]!==o||e[31]!==f?(T=E=>E.status!=="connected"?r.jsxs(_t,{onClick:()=>l(E.name),className:"items-center",children:[r.jsx("span",{className:"size-2 rounded-full bg-warning"}),r.jsx("span",{className:"min-w-0 flex-1 truncate",children:E.name}),r.jsx("span",{className:"text-xs text-warning",children:"Needs auth"})]},E.name):r.jsxs(Xw,{checked:f.has(E.name),onCheckedChange:()=>o(E.name),children:[r.jsx("span",{className:"size-2 rounded-full bg-success"}),r.jsx("span",{className:"truncate",children:E.name})]},E.name),e[29]=l,e[30]=o,e[31]=f,e[32]=T):T=e[32],N=t.map(T),e[24]=l,e[25]=o,e[26]=f,e[27]=t,e[28]=N}else N=e[28];let _;e[33]!==k||e[34]!==C||e[35]!==N||e[36]!==v?(_=r.jsxs(en,{children:[v,k,C,N]}),e[33]=k,e[34]=C,e[35]=N,e[36]=v,e[37]=_):_=e[37];let P;e[38]!==m||e[39]!==_?(P=r.jsx(Kn,{"aria-labelledby":m,className:"w-64",children:_}),e[38]=m,e[39]=_,e[40]=P):P=e[40];let A;return e[41]!==P||e[42]!==w?(A=r.jsxs(Wn,{children:[w,P]}),e[41]=P,e[42]=w,e[43]=A):A=e[43],A}function vj(n){return n.status==="connected"}function Gf(n){var k;const e=B.c(31),{value:t,fallbackLabel:s,options:o,onChange:i,disabled:a,title:l,ariaLabel:c}=n;let d;e[0]!==s||e[1]!==o||e[2]!==t?(d=((k=o.find(C=>C.value===t))==null?void 0:k.label)??s,e[0]=s,e[1]=o,e[2]=t,e[3]=d):d=e[3];const u=d,f=y.useId();let m;e[4]!==l?(m=r.jsx(ee,{type:"button",variant:"ghost",size:"xs",title:l}),e[4]=l,e[5]=m):m=e[5];let p;e[6]!==u?(p=r.jsx("span",{className:"truncate",children:u}),e[6]=u,e[7]=p):p=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(tt,{"data-icon":"inline-end"}),e[8]=h):h=e[8];let g;e[9]!==a||e[10]!==m||e[11]!==p?(g=r.jsxs(Hn,{disabled:a,render:m,children:[p,h]}),e[9]=a,e[10]=m,e[11]=p,e[12]=g):g=e[12];let x;e[13]!==c||e[14]!==f?(x=r.jsx(Us,{id:f,className:"sr-only",children:c}),e[13]=c,e[14]=f,e[15]=x):x=e[15];let b;e[16]!==o?(b=o.map(yj),e[16]=o,e[17]=b):b=e[17];let w;e[18]!==i||e[19]!==b||e[20]!==t?(w=r.jsx(Fi,{value:t,onValueChange:i,children:b}),e[18]=i,e[19]=b,e[20]=t,e[21]=w):w=e[21];let v;e[22]!==x||e[23]!==w?(v=r.jsxs(en,{children:[x,w]}),e[22]=x,e[23]=w,e[24]=v):v=e[24];let S;e[25]!==f||e[26]!==v?(S=r.jsx(Kn,{"aria-labelledby":f,className:"w-48",children:v}),e[25]=f,e[26]=v,e[27]=S):S=e[27];let j;return e[28]!==S||e[29]!==g?(j=r.jsxs(Wn,{children:[g,S]}),e[28]=S,e[29]=g,e[30]=j):j=e[30],j}function yj(n){return r.jsx(Mg,{option:n},n.value)}function Og(n,e){return aj(n).filter(t=>t.value!=="auto"||e)}function wj(n){const e=B.c(39),{agentKind:t,mode:s,onChange:o,autoAvailable:i}=n,a=i===void 0?!1:i;let l,c,d,u,f,m,p,h,g,x,b;if(e[0]!==t||e[1]!==a||e[2]!==s||e[3]!==o){const k=Og(t,a),C=k.find(A=>A.value===s)??k[0];u=Wn;let N,_;e[15]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(ee,{type:"button",variant:"ghost",size:"xs"}),N=r.jsx(Wh,{"data-icon":"inline-start"}),e[15]=N,e[16]=_):(N=e[15],_=e[16]);let P;e[17]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(tt,{"data-icon":"inline-end"}),e[17]=P):P=e[17],b=r.jsxs(Hn,{render:_,children:[N,r.jsx("span",{className:"truncate",children:C.label}),P]}),d=Kn,g="Access policy",x="w-72",c=en,e[18]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(Us,{children:"Permissions"}),e[18]=h):h=e[18],l=Fi,f=s,e[19]!==o?(m=A=>o(A),e[19]=o,e[20]=m):m=e[20],p=k.map(jj),e[0]=t,e[1]=a,e[2]=s,e[3]=o,e[4]=l,e[5]=c,e[6]=d,e[7]=u,e[8]=f,e[9]=m,e[10]=p,e[11]=h,e[12]=g,e[13]=x,e[14]=b}else l=e[4],c=e[5],d=e[6],u=e[7],f=e[8],m=e[9],p=e[10],h=e[11],g=e[12],x=e[13],b=e[14];let w;e[21]!==l||e[22]!==f||e[23]!==m||e[24]!==p?(w=r.jsx(l,{value:f,onValueChange:m,children:p}),e[21]=l,e[22]=f,e[23]=m,e[24]=p,e[25]=w):w=e[25];let v;e[26]!==c||e[27]!==h||e[28]!==w?(v=r.jsxs(c,{children:[h,w]}),e[26]=c,e[27]=h,e[28]=w,e[29]=v):v=e[29];let S;e[30]!==d||e[31]!==v||e[32]!==g||e[33]!==x?(S=r.jsx(d,{"aria-label":g,className:x,children:v}),e[30]=d,e[31]=v,e[32]=g,e[33]=x,e[34]=S):S=e[34];let j;return e[35]!==u||e[36]!==S||e[37]!==b?(j=r.jsxs(u,{children:[b,S]}),e[35]=u,e[36]=S,e[37]=b,e[38]=j):j=e[38],j}function jj(n){return r.jsx(rd,{value:n.value,className:"items-start py-2",children:r.jsxs("span",{className:"flex min-w-0 flex-col items-start",children:[r.jsx("span",{children:n.label}),r.jsx("span",{className:"max-w-64 truncate text-xs font-normal text-muted-foreground",children:n.description})]})},n.value)}function Sj(n){const e=B.c(62),{agentKind:t,onAgentKindChange:s,selectedModel:o,resolvedDefaultName:i,modelOptions:a,onModelChange:l,selectedEffort:c,effortOptions:d,onEffortChange:u,fastTier:f,fastModeEnabled:m,onFastModeEnabledChange:p,isNewSession:h,worktreeEnabled:g,onWorktreeEnabledChange:x,ultracodeEnabled:b,onUltracodeEnabledChange:w,autoModeAvailable:v,permissionMode:S,onPermissionModeChange:j,mcpServers:k,selectedMcpServers:C,onToggleMcpServer:N,onRefreshMcpServers:_,mcpLoading:P,onMcpAuth:A,changeAndApply:T,trailingExtra:E}=n;let R;e[0]!==t?(R=qt(t),e[0]=t,e[1]=R):R=e[1];const{worktrees:$,ultracode:I,settingsApply:M}=R,D=y.useId(),O=h?void 0:M==="live"?"Changes apply live":"Changes apply next turn",L=O?D:void 0;let F;e[2]!==O||e[3]!==D?(F=O&&r.jsx("span",{id:D,className:"sr-only",children:O}),e[2]=O,e[3]=D,e[4]=F):F=e[4];let z;e[5]!==t||e[6]!==a||e[7]!==s||e[8]!==l||e[9]!==i||e[10]!==o?(z=s?r.jsx(hj,{agentKind:t,onAgentKindChange:s,value:o,fallbackLabel:i,options:a,onChange:l}):r.jsx(Gf,{value:o,fallbackLabel:"Model",ariaLabel:"Model",options:a,onChange:l}),e[5]=t,e[6]=a,e[7]=s,e[8]=l,e[9]=i,e[10]=o,e[11]=z):z=e[11];let W;e[12]!==t||e[13]!==d||e[14]!==u||e[15]!==c||e[16]!==o||e[17]!==b?(W=d.length>0&&r.jsx(Gf,{value:xa(t,c,o),fallbackLabel:"Effort",ariaLabel:"Reasoning effort",options:d,onChange:u,disabled:b,title:b?"Effort is pinned to XHigh while Ultracode is on":void 0}),e[12]=t,e[13]=d,e[14]=u,e[15]=c,e[16]=o,e[17]=b,e[18]=W):W=e[18];let U;e[19]!==T||e[20]!==m||e[21]!==f||e[22]!==p?(U=f&&p&&r.jsxs(ee,{type:"button",variant:m?"secondary":"ghost",size:"xs","aria-pressed":!!m,onClick:()=>T(()=>p(!m)),title:f.description,children:[r.jsx(Di,{"data-icon":"inline-start",className:q(m&&"fill-current")}),m?"Fast":"Standard"]}),e[19]=T,e[20]=m,e[21]=f,e[22]=p,e[23]=U):U=e[23];let H;e[24]!==t||e[25]!==v||e[26]!==T||e[27]!==j||e[28]!==S?(H=j&&S&&r.jsx(wj,{agentKind:t,mode:S,onChange:Q=>T(()=>j(Q)),autoAvailable:v}),e[24]=t,e[25]=v,e[26]=T,e[27]=j,e[28]=S,e[29]=H):H=e[29];let K;e[30]!==h||e[31]!==x||e[32]!==$||e[33]!==g?(K=$&&h&&x&&r.jsxs(ee,{type:"button",variant:g?"secondary":"ghost",size:"xs","aria-pressed":!!g,onClick:()=>x(!g),children:[r.jsx(Dn,{"data-icon":"inline-start"}),"Worktree"]}),e[30]=h,e[31]=x,e[32]=$,e[33]=g,e[34]=K):K=e[34];let V;e[35]!==T||e[36]!==w||e[37]!==I||e[38]!==b?(V=I&&w&&r.jsxs(ee,{type:"button",variant:b?"secondary":"ghost",size:"xs","aria-pressed":!!b,onClick:()=>T(()=>w(!b)),title:"Ultracode: XHigh effort + standing multi-agent workflow orchestration",children:[r.jsx(Di,{"data-icon":"inline-start",className:q(b&&"fill-current")}),"Ultracode"]}),e[35]=T,e[36]=w,e[37]=I,e[38]=b,e[39]=V):V=e[39];let Y;e[40]!==T||e[41]!==P||e[42]!==k||e[43]!==A||e[44]!==_||e[45]!==N||e[46]!==C?(Y=N&&_&&A&&(P||k&&k.length>0)&&r.jsx(bj,{servers:k??[],selected:C??[],onToggle:Q=>T(()=>N(Q)),onRefresh:_,loading:P??!1,onAuth:A}),e[40]=T,e[41]=P,e[42]=k,e[43]=A,e[44]=_,e[45]=N,e[46]=C,e[47]=Y):Y=e[47];let G;e[48]!==Y||e[49]!==z||e[50]!==W||e[51]!==U||e[52]!==H||e[53]!==K||e[54]!==V||e[55]!==E?(G=r.jsxs("div",{className:"flex w-full flex-wrap items-center gap-1.5",children:[z,W,U,H,K,V,Y,E]}),e[48]=Y,e[49]=z,e[50]=W,e[51]=U,e[52]=H,e[53]=K,e[54]=V,e[55]=E,e[56]=G):G=e[56];let J;return e[57]!==O||e[58]!==G||e[59]!==L||e[60]!==F?(J=r.jsxs("div",{className:"flex items-center pb-1.5 pl-6 pr-3",role:"group",title:O,"aria-describedby":L,children:[F,G]}),e[57]=O,e[58]=G,e[59]=L,e[60]=F,e[61]=J):J=e[61],J}function St(n){const e=B.c(10);let t,s,o;e[0]!==n?({className:t,orientation:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"horizontal":o;let a;e[4]!==t?(a=q("shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px data-[orientation=vertical]:self-stretch",t),e[4]=t,e[5]=a):a=e[5];let l;return e[6]!==i||e[7]!==s||e[8]!==a?(l=r.jsx(Wc,{"data-slot":"separator",orientation:i,className:a,...s}),e[6]=i,e[7]=s,e[8]=a,e[9]=l):l=e[9],l}function Nj(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("label",{"data-slot":"label",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function kj(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("flex flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("fieldset",{"data-slot":"field-set",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Cj(n){const e=B.c(10);let t,s,o;e[0]!==n?({className:t,variant:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"legend":o;let a;e[4]!==t?(a=q("mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base",t),e[4]=t,e[5]=a):a=e[5];let l;return e[6]!==s||e[7]!==a||e[8]!==i?(l=r.jsx("legend",{"data-slot":"field-legend","data-variant":i,className:a,...s}),e[6]=s,e[7]=a,e[8]=i,e[9]=l):l=e[9],l}function Ao(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("group/field-group @container/field-group flex w-full flex-col gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"field-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const _j=es("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 wt(n){const e=B.c(11);let t,s,o;e[0]!==n?({className:t,orientation:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"vertical":o;let a;e[4]!==t||e[5]!==i?(a=q(_j({orientation:i}),t),e[4]=t,e[5]=i,e[6]=a):a=e[6];let l;return e[7]!==i||e[8]!==s||e[9]!==a?(l=r.jsx("div",{role:"group","data-slot":"field","data-orientation":i,className:a,...s}),e[7]=i,e[8]=s,e[9]=a,e[10]=l):l=e[10],l}function FL(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("group/field-content flex flex-1 flex-col gap-0.5 leading-snug",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"field-content",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function jt(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border has-[>[data-slot=field]]:not-has-[:disabled,[data-disabled]]:hover:bg-muted/50 has-[>[data-slot=field]]:has-[:focus-visible]:border-ring has-[>[data-slot=field]]:has-[:focus-visible]:ring-3 has-[>[data-slot=field]]:has-[:focus-visible]:ring-ring/50 *:data-[slot=field]:p-2.5 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10","has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Nj,{"data-slot":"field-label",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function No(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("text-left text-sm leading-normal font-normal text-muted-foreground group-data-[orientation=horizontal]/field:text-balance [[data-variant=legend]+&]:-mt-1.5","last:mt-0 nth-last-2:-mt-1","[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("p",{"data-slot":"field-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function bs(n){var u;const e=B.c(15);let t,s,o,i;e[0]!==n?({className:s,children:t,errors:o,...i}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);let a;e:{if(t){a=t;break e}if(!(o!=null&&o.length)){a=null;break e}let f;e[5]!==o?(f=[...new Map(o.map(Ej)).values()],e[5]=o,e[6]=f):f=e[6];const m=f;if((m==null?void 0:m.length)==1){a=(u=m[0])==null?void 0:u.message;break e}let p;e[7]!==m?(p=r.jsx("ul",{className:"ml-4 flex list-disc flex-col gap-1",children:m.map(Tj)}),e[7]=m,e[8]=p):p=e[8],a=p}const l=a;if(!l)return null;let c;e[9]!==s?(c=q("text-sm font-normal text-destructive",s),e[9]=s,e[10]=c):c=e[10];let d;return e[11]!==l||e[12]!==i||e[13]!==c?(d=r.jsx("div",{role:"alert","data-slot":"field-error",className:c,...i,children:l}),e[11]=l,e[12]=i,e[13]=c,e[14]=d):d=e[14],d}function Tj(n,e){return(n==null?void 0:n.message)&&r.jsx("li",{children:n.message},e)}function Ej(n){return[n==null?void 0:n.message,n]}const Pj=zv;function Aj(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("scroll-my-1 p-1",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Wv,{"data-slot":"select-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Rj(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("flex flex-1 text-left",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Fv,{"data-slot":"select-value",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Ij(n){const e=B.c(13);let t,s,o,i;e[0]!==n?({className:s,size:i,children:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);const a=i===void 0?"default":i;let l;e[5]!==s?(l=q("group/select-trigger flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap outline-none transition-[color,background-color,border-color,box-shadow,transform,scale] duration-100 ease-out select-none data-pressed:scale-[0.98] focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 motion-reduce:transition-none motion-reduce:data-pressed:scale-100 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",s),e[5]=s,e[6]=l):l=e[6];let c;e[7]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(Hv,{render:r.jsx(tt,{className:"pointer-events-none size-4 text-muted-foreground transition-transform duration-150 ease-out group-data-popup-open/select-trigger:rotate-180 motion-reduce:transition-none"})}),e[7]=c):c=e[7];let d;return e[8]!==t||e[9]!==o||e[10]!==a||e[11]!==l?(d=r.jsxs(Bv,{"data-slot":"select-trigger","data-size":a,className:l,...o,children:[t,c]}),e[8]=t,e[9]=o,e[10]=a,e[11]=l,e[12]=d):d=e[12],d}function $j(n){const e=B.c(26);let t,s,o,i,a,l,c,d;e[0]!==n?({className:s,children:t,side:i,sideOffset:a,align:l,alignOffset:c,alignItemWithTrigger:d,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a,e[6]=l,e[7]=c,e[8]=d):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5],l=e[6],c=e[7],d=e[8]);const u=i===void 0?"bottom":i,f=a===void 0?4:a,m=l===void 0?"center":l,p=c===void 0?0:c,h=d===void 0?!0:d;let g;e[9]!==s?(g=q("relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 ease-out data-[side=none]:animate-none data-[side=bottom]:slide-in-from-top-1 data-[side=inline-end]:slide-in-from-left-1 data-[side=inline-start]:slide-in-from-right-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",s),e[9]=s,e[10]=g):g=e[10];let x;e[11]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(Oj,{}),e[11]=x):x=e[11];let b;e[12]!==t?(b=r.jsx(Kv,{children:t}),e[12]=t,e[13]=b):b=e[13];let w;e[14]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(Dj,{}),e[14]=w):w=e[14];let v;e[15]!==o||e[16]!==g||e[17]!==b?(v=r.jsxs(Uv,{"data-slot":"select-content",className:g,...o,children:[x,b,w]}),e[15]=o,e[16]=g,e[17]=b,e[18]=v):v=e[18];let S;return e[19]!==m||e[20]!==h||e[21]!==p||e[22]!==u||e[23]!==f||e[24]!==v?(S=r.jsx(qv,{children:r.jsx(Vv,{side:u,sideOffset:f,align:m,alignOffset:p,alignItemWithTrigger:h,className:"isolate z-50",children:v})}),e[19]=m,e[20]=h,e[21]=p,e[22]=u,e[23]=f,e[24]=v,e[25]=S):S=e[25],S}function Mj(n){const e=B.c(13);let t,s,o;e[0]!==n?({className:s,children:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==s?(i=q("relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none transition-colors duration-75 focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",s),e[4]=s,e[5]=i):i=e[5];let a;e[6]!==t?(a=r.jsx(Dv,{className:"flex flex-1 shrink-0 gap-2 whitespace-nowrap",children:t}),e[6]=t,e[7]=a):a=e[7];let l;e[8]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Lv,{className:"transition-[opacity,transform,scale] duration-100 ease-out motion-safe:data-starting-style:scale-75 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:scale-75 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none",render:r.jsx("span",{className:"pointer-events-none absolute right-2 flex size-4 items-center justify-center"}),children:r.jsx(mt,{className:"pointer-events-none"})}),e[8]=l):l=e[8];let c;return e[9]!==o||e[10]!==i||e[11]!==a?(c=r.jsxs(Ov,{"data-slot":"select-item",className:i,...o,children:[a,l]}),e[9]=o,e[10]=i,e[11]=a,e[12]=c):c=e[12],c}function Oj(n){const e=B.c(9);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 transition-opacity duration-100 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none [&_svg:not([class*='size-'])]:size-4",t),e[3]=t,e[4]=o):o=e[4];let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(kr,{}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.jsx(Gv,{"data-slot":"select-scroll-up-button",className:o,...s,children:i}),e[6]=s,e[7]=o,e[8]=a):a=e[8],a}function Dj(n){const e=B.c(9);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 transition-opacity duration-100 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none [&_svg:not([class*='size-'])]:size-4",t),e[3]=t,e[4]=o):o=e[4];let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(tt,{}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.jsx(Yv,{"data-slot":"select-scroll-down-button",className:o,...s,children:i}),e[6]=s,e[7]=o,e[8]=a):a=e[8],a}function Lj(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(Hh,{"data-slot":"sheet",...t}),e[2]=t,e[3]=s):s=e[3],s}function zj(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(Xv,{"data-slot":"sheet-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function Fj(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(aa,{"data-slot":"sheet-close",...t}),e[2]=t,e[3]=s):s=e[3],s}function Bj(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(Vc,{"data-slot":"sheet-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function Uj(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("fixed inset-0 z-50 bg-black/55 duration-200 ease-out data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0 data-closed:duration-150 data-closed:ease-in motion-reduce:animate-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Gc,{"data-slot":"sheet-overlay",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Wj(n){const e=B.c(17);let t,s,o,i,a;e[0]!==n?({className:s,children:t,side:i,showCloseButton:a,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5]);const l=i===void 0?"right":i,c=a===void 0?!0:a;let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Uj,{}),e[6]=d):d=e[6];let u;e[7]!==s?(u=q("fixed z-50 flex flex-col border-border bg-popover text-popover-foreground shadow-lg duration-200 ease-out data-closed:duration-150 data-closed:ease-in motion-reduce:animate-none","data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-full data-[side=right]:max-w-[560px] data-[side=right]:border-l","data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-full data-[side=left]:max-w-[560px] data-[side=left]:border-r","data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t","data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b","data-open:animate-in data-open:fade-in-0 data-[side=right]:data-open:slide-in-from-right data-[side=left]:data-open:slide-in-from-left data-[side=bottom]:data-open:slide-in-from-bottom data-[side=top]:data-open:slide-in-from-top","data-closed:animate-out data-closed:fade-out-0 data-[side=right]:data-closed:slide-out-to-right data-[side=left]:data-closed:slide-out-to-left data-[side=bottom]:data-closed:slide-out-to-bottom data-[side=top]:data-closed:slide-out-to-top",s),e[7]=s,e[8]=u):u=e[8];let f;e[9]!==c?(f=c&&r.jsxs(aa,{className:"absolute top-4 right-4 inline-flex size-7 items-center justify-center rounded-md text-muted-foreground outline-none transition-[color,background-color,transform,scale] duration-100 ease-out hover:bg-accent hover:text-foreground active:scale-90 focus-visible:ring-[3px] focus-visible:ring-ring/20 disabled:pointer-events-none motion-reduce:transition-none motion-reduce:active:scale-100",children:[r.jsx(rt,{"data-icon":"inline-start",className:"size-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]}),e[9]=c,e[10]=f):f=e[10];let m;return e[11]!==t||e[12]!==o||e[13]!==l||e[14]!==u||e[15]!==f?(m=r.jsxs(Bj,{children:[d,r.jsxs(qc,{"data-slot":"sheet-content","data-side":l,className:u,...o,children:[t,f]})]}),e[11]=t,e[12]=o,e[13]=l,e[14]=u,e[15]=f,e[16]=m):m=e[16],m}function Hj(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("flex flex-col gap-1.5 border-b p-4",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"sheet-header",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Kj(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("text-sm font-medium",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Hc,{"data-slot":"sheet-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function qj(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("text-sm text-muted-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Kc,{"data-slot":"sheet-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Qo(n){const e=B.c(10),{label:t,children:s,wide:o}=n,a=(o===void 0?!1:o)&&"col-span-2";let l;e[0]!==a?(l=q("min-w-0 gap-1 py-1",a),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==t?(c=r.jsx(jt,{className:"text-xs text-muted-foreground",children:t}),e[2]=t,e[3]=c):c=e[3];let d;e[4]!==s?(d=r.jsx("div",{className:"min-w-0 [&>button]:w-full [&>button]:justify-between",children:s}),e[4]=s,e[5]=d):d=e[5];let u;return e[6]!==l||e[7]!==c||e[8]!==d?(u=r.jsxs(wt,{className:l,children:[c,d]}),e[6]=l,e[7]=c,e[8]=d,e[9]=u):u=e[9],u}function fi(n){const e=B.c(19),{label:t,ariaLabel:s,value:o,options:i,onChange:a,disabled:l,title:c}=n;let d;e[0]!==a?(d=x=>{x!==null&&a(x)},e[0]=a,e[1]=d):d=e[1];let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Rj,{}),e[2]=u):u=e[2];let f;e[3]!==s||e[4]!==c?(f=r.jsx(Ij,{"aria-label":s,title:c,className:"h-10 w-full",children:u}),e[3]=s,e[4]=c,e[5]=f):f=e[5];let m;e[6]!==i?(m=i.map(Vj),e[6]=i,e[7]=m):m=e[7];let p;e[8]!==m?(p=r.jsx($j,{children:r.jsx(Aj,{children:m})}),e[8]=m,e[9]=p):p=e[9];let h;e[10]!==l||e[11]!==d||e[12]!==f||e[13]!==p||e[14]!==o?(h=r.jsxs(Pj,{value:o,onValueChange:d,disabled:l,children:[f,p]}),e[10]=l,e[11]=d,e[12]=f,e[13]=p,e[14]=o,e[15]=h):h=e[15];let g;return e[16]!==t||e[17]!==h?(g=r.jsx(Qo,{label:t,children:h}),e[16]=t,e[17]=h,e[18]=g):g=e[18],g}function Vj(n){return r.jsx(Mj,{value:n.value,children:n.menuLabel??n.label},n.value||"default")}function Gj(n){const e=B.c(32),{agentKind:t,onAgentKindChange:s,selectedModel:o,onModelChange:i,modelOptions:a,selectedEffort:l,onEffortChange:c,effortOptions:d,ultracodeEnabled:u,fastTier:f,fastModeEnabled:m,onFastModeEnabledChange:p,permissionMode:h,permissionOptions:g,onPermissionModeChange:x,changeAndApply:b}=n;let w;e[0]!==t||e[1]!==l||e[2]!==o?(w=xa(t,l,o),e[0]=t,e[1]=l,e[2]=o,e[3]=w):w=e[3];const v=w;let S;e[4]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx("h3",{id:"mobile-model-controls",className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Model and behavior"}),e[4]=S):S=e[4];let j;e[5]!==t||e[6]!==s?(j=s&&r.jsx(fi,{label:"Agent",ariaLabel:"Agent",value:t,options:cc,onChange:A=>s(A)}),e[5]=t,e[6]=s,e[7]=j):j=e[7];let k;e[8]!==a||e[9]!==i||e[10]!==o?(k=r.jsx(fi,{label:"Model",ariaLabel:"Model",value:o,options:a,onChange:i}),e[8]=a,e[9]=i,e[10]=o,e[11]=k):k=e[11];let C;e[12]!==d||e[13]!==v||e[14]!==c||e[15]!==u?(C=d.length>0&&r.jsx(fi,{label:"Reasoning",ariaLabel:"Reasoning effort",value:v,options:d,onChange:c,disabled:u,title:u?"Effort is pinned to XHigh while Ultracode is on":void 0}),e[12]=d,e[13]=v,e[14]=c,e[15]=u,e[16]=C):C=e[16];let N;e[17]!==b||e[18]!==m||e[19]!==f||e[20]!==p?(N=f&&p&&r.jsx(Qo,{label:"Speed",children:r.jsxs(ee,{type:"button",variant:m?"secondary":"ghost","aria-pressed":!!m,onClick:()=>b(()=>p(!m)),title:f.description,className:"h-10 justify-start",children:[r.jsx(Di,{"data-icon":"inline-start",className:q(m&&"fill-current")}),m?"Fast":"Standard"]})}),e[17]=b,e[18]=m,e[19]=f,e[20]=p,e[21]=N):N=e[21];let _;e[22]!==x||e[23]!==h||e[24]!==g?(_=x&&h&&r.jsx(fi,{label:"Access",ariaLabel:"Access policy",value:h,options:g,onChange:A=>x(A)}),e[22]=x,e[23]=h,e[24]=g,e[25]=_):_=e[25];let P;return e[26]!==j||e[27]!==k||e[28]!==C||e[29]!==N||e[30]!==_?(P=r.jsxs("section",{"aria-labelledby":"mobile-model-controls",className:"flex flex-col gap-2",children:[S,r.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[j,k,C,N,_]})]}),e[26]=j,e[27]=k,e[28]=C,e[29]=N,e[30]=_,e[31]=P):P=e[31],P}function Yj(n){const e=B.c(30),{agentKind:t,isNewSession:s,worktreeEnabled:o,onWorktreeEnabledChange:i,ultracodeEnabled:a,onUltracodeEnabledChange:l,mcpServers:c,selectedMcpServers:d,onToggleMcpServer:u,onRefreshMcpServers:f,mcpLoading:m,onMcpAuth:p,changeAndApply:h}=n;let g;e[0]!==t?(g=qt(t),e[0]=t,e[1]=g):g=e[1];const{worktrees:x,ultracode:b}=g,w=!!(u&&f&&p&&(m||c&&c.length>0)),v=!!(x&&s&&i||b&&l||w);let S;e[2]!==d?(S=d??[],e[2]=d,e[3]=S):S=e[3];let j;e[4]!==S?(j=new Set(S),e[4]=S,e[5]=j):j=e[5];const k=j;if(!v)return null;let C;e[6]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx("h3",{id:"mobile-advanced-controls",className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Advanced"}),e[6]=C):C=e[6];let N;e[7]!==s||e[8]!==i||e[9]!==x||e[10]!==o?(N=x&&s&&i&&r.jsx(Qo,{label:"Isolation",children:r.jsxs(ee,{type:"button",variant:o?"secondary":"ghost","aria-pressed":!!o,onClick:()=>i(!o),className:"h-10 justify-start",children:[r.jsx(Dn,{"data-icon":"inline-start"}),"Worktree"]})}),e[7]=s,e[8]=i,e[9]=x,e[10]=o,e[11]=N):N=e[11];let _;e[12]!==h||e[13]!==l||e[14]!==b||e[15]!==a?(_=b&&l&&r.jsx(Qo,{label:"Workflow",children:r.jsxs(ee,{type:"button",variant:a?"secondary":"ghost","aria-pressed":!!a,onClick:()=>h(()=>l(!a)),className:"h-10 justify-start",children:[r.jsx(Di,{"data-icon":"inline-start",className:q(a&&"fill-current")}),"Ultracode"]})}),e[12]=h,e[13]=l,e[14]=b,e[15]=a,e[16]=_):_=e[16];let P;e[17]!==h||e[18]!==m||e[19]!==c||e[20]!==p||e[21]!==f||e[22]!==u||e[23]!==k||e[24]!==w?(P=w&&u&&f&&p&&r.jsx(Qo,{label:"Connections",wide:!0,children:r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsxs(ee,{type:"button",variant:"ghost",onClick:f,className:"min-h-10 justify-start",children:[r.jsx(Ot,{"data-icon":"inline-start",className:q(m&&"animate-spin")}),"Refresh MCP status"]}),(c??[]).map(T=>{const E=k.has(T.name),R=T.status==="connected";return r.jsxs(ee,{type:"button",variant:"ghost","aria-pressed":R?E:void 0,onClick:()=>R?h(()=>u(T.name)):p(T.name),className:"min-h-10 justify-start text-left",children:[r.jsx("span",{className:q("size-2 shrink-0 rounded-full",R&&E?"bg-success":R?"bg-muted-foreground":"bg-warning")}),r.jsx("span",{className:"min-w-0 flex-1 truncate",children:T.name}),r.jsx("span",{className:"text-xs text-muted-foreground",children:R?E?"On":"Off":"Connect"})]},T.name)})]})}),e[17]=h,e[18]=m,e[19]=c,e[20]=p,e[21]=f,e[22]=u,e[23]=k,e[24]=w,e[25]=P):P=e[25];let A;return e[26]!==N||e[27]!==_||e[28]!==P?(A=r.jsxs("section",{"aria-labelledby":"mobile-advanced-controls",className:"flex flex-col gap-2",children:[C,r.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[N,_,P]})]}),e[26]=N,e[27]=_,e[28]=P,e[29]=A):A=e[29],A}function Xj(n){var ue,le;const e=B.c(78),{open:t,onOpenChange:s,agentKind:o,onAgentKindChange:i,selectedModel:a,resolvedDefaultName:l,catalogOptions:c,modelOptions:d,onModelChange:u,selectedEffort:f,effortOptions:m,onEffortChange:p,fastTier:h,fastModeEnabled:g,onFastModeEnabledChange:x,isNewSession:b,worktreeEnabled:w,onWorktreeEnabledChange:v,ultracodeEnabled:S,onUltracodeEnabledChange:j,autoModeAvailable:k,permissionMode:C,onPermissionModeChange:N,mcpServers:_,selectedMcpServers:P,onToggleMcpServer:A,onRefreshMcpServers:T,mcpLoading:E,onMcpAuth:R,mobileExtra:$,changeAndApply:I}=n;let M;e[0]!==o||e[1]!==f||e[2]!==a?(M=xa(o,f,a),e[0]=o,e[1]=f,e[2]=a,e[3]=M):M=e[3];const D=M;let O,L;e[4]!==o||e[5]!==k||e[6]!==C?(O=Og(o,k),L=(ue=O.find(de=>de.value===C))==null?void 0:ue.label,e[4]=o,e[5]=k,e[6]=C,e[7]=O,e[8]=L):(O=e[7],L=e[8]);const F=L;let z;e[9]!==c||e[10]!==l||e[11]!==a?(z=a?cd(a,c):l,e[9]=c,e[10]=l,e[11]=a,e[12]=z):z=e[12];let W;e[13]!==m||e[14]!==D?(W=(le=m.find(de=>de.value===D))==null?void 0:le.label,e[13]=m,e[14]=D,e[15]=W):W=e[15];let U;e[16]!==F||e[17]!==z||e[18]!==W?(U=[z,W,F].filter(Boolean),e[16]=F,e[17]=z,e[18]=W,e[19]=U):U=e[19];const H=U.join(" · ");let K;e[20]!==I||e[21]!==N?(K=de=>{N&&I(()=>N(de))},e[20]=I,e[21]=N,e[22]=K):K=e[22];const V=K;let Y;e[23]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx(zj,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"ml-0.5 shrink-0 rounded-full text-muted-foreground","aria-label":"Session controls",title:"Session controls"}),children:r.jsx(Yc,{})}),e[23]=Y):Y=e[23];let G;e[24]===Symbol.for("react.memo_cache_sentinel")?(G=r.jsx(Kj,{children:"Session controls"}),e[24]=G):G=e[24];let J;e[25]!==H?(J=r.jsx(qj,{className:"truncate text-xs",children:H}),e[25]=H,e[26]=J):J=e[26];let Q;e[27]===Symbol.for("react.memo_cache_sentinel")?(Q=r.jsx(Fj,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"icon-lg",className:"absolute right-2 top-2","aria-label":"Close session controls"}),children:r.jsx(rt,{})}),e[27]=Q):Q=e[27];let X;e[28]!==J?(X=r.jsxs(Hj,{className:"gap-1 px-4 pb-3 pt-4",children:[G,J,Q]}),e[28]=J,e[29]=X):X=e[29];let Z;e[30]!==o||e[31]!==I||e[32]!==V||e[33]!==m||e[34]!==g||e[35]!==h||e[36]!==d||e[37]!==i||e[38]!==p||e[39]!==x||e[40]!==u||e[41]!==C||e[42]!==O||e[43]!==f||e[44]!==a||e[45]!==S?(Z=r.jsx(Gj,{agentKind:o,onAgentKindChange:i,selectedModel:a,onModelChange:u,modelOptions:d,selectedEffort:f,onEffortChange:p,effortOptions:m,ultracodeEnabled:S,fastTier:h,fastModeEnabled:g,onFastModeEnabledChange:x,permissionMode:C,permissionOptions:O,onPermissionModeChange:V,changeAndApply:I}),e[30]=o,e[31]=I,e[32]=V,e[33]=m,e[34]=g,e[35]=h,e[36]=d,e[37]=i,e[38]=p,e[39]=x,e[40]=u,e[41]=C,e[42]=O,e[43]=f,e[44]=a,e[45]=S,e[46]=Z):Z=e[46];let te;e[47]!==o||e[48]!==I||e[49]!==b||e[50]!==E||e[51]!==_||e[52]!==R||e[53]!==T||e[54]!==A||e[55]!==j||e[56]!==v||e[57]!==P||e[58]!==S||e[59]!==w?(te=r.jsx(Yj,{agentKind:o,isNewSession:b,worktreeEnabled:w,onWorktreeEnabledChange:v,ultracodeEnabled:S,onUltracodeEnabledChange:j,mcpServers:_,selectedMcpServers:P,onToggleMcpServer:A,onRefreshMcpServers:T,mcpLoading:E,onMcpAuth:R,changeAndApply:I}),e[47]=o,e[48]=I,e[49]=b,e[50]=E,e[51]=_,e[52]=R,e[53]=T,e[54]=A,e[55]=j,e[56]=v,e[57]=P,e[58]=S,e[59]=w,e[60]=te):te=e[60];let ne;e[61]!==$?(ne=$&&r.jsxs("section",{"aria-labelledby":"mobile-goal-controls",className:"flex flex-col gap-2 pt-1",children:[r.jsx(St,{className:"mb-3"}),r.jsx("h3",{id:"mobile-goal-controls",className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Long-running goal"}),r.jsx("div",{className:"[&>*]:mx-0 [&>*]:mb-0 [&_button]:min-h-10",children:$})]}),e[61]=$,e[62]=ne):ne=e[62];let re;e[63]!==o||e[64]!==b?(re=!b&&r.jsx("p",{className:"text-xs text-muted-foreground",children:qt(o).settingsApply==="live"?"Changes apply live.":"Changes apply on the next turn."}),e[63]=o,e[64]=b,e[65]=re):re=e[65];let ie;e[66]!==Z||e[67]!==te||e[68]!==ne||e[69]!==re?(ie=r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-4 py-4",children:[Z,te,ne,re]}),e[66]=Z,e[67]=te,e[68]=ne,e[69]=re,e[70]=ie):ie=e[70];let ae;e[71]!==X||e[72]!==ie?(ae=r.jsxs(Wj,{side:"bottom",className:"max-h-[82dvh] overflow-hidden rounded-t-2xl pb-[env(safe-area-inset-bottom)]",showCloseButton:!1,children:[X,ie]}),e[71]=X,e[72]=ie,e[73]=ae):ae=e[73];let se;return e[74]!==s||e[75]!==t||e[76]!==ae?(se=r.jsx(r.Fragment,{children:r.jsxs(Lj,{open:t,onOpenChange:s,children:[Y,ae]})}),e[74]=s,e[75]=t,e[76]=ae,e[77]=se):se=e[77],se}const Jj=y.memo(function(e){const t=B.c(58),{agentKind:s,onAgentKindChange:o,selectedModel:i,onModelChange:a,selectedEffort:l,onEffortChange:c,fastModeEnabled:d,onFastModeEnabledChange:u,isNewSession:f,worktreeEnabled:m,onWorktreeEnabledChange:p,ultracodeEnabled:h,onUltracodeEnabledChange:g,onApplySettings:x,activeModelId:b,mcpServers:w,selectedMcpServers:v,onToggleMcpServer:S,onRefreshMcpServers:j,mcpLoading:k,onMcpAuth:C,permissionMode:N,onPermissionModeChange:_,mobileExtra:P,trailingExtra:A,mobile:T}=e,E=s===void 0?Xs:s,R=T===void 0?!1:T,[$,I]=y.useState(!1);let M;t[0]!==f||t[1]!==x?(M=se=>{se(),!f&&x&&setTimeout(()=>x(),0)},t[0]=f,t[1]=x,t[2]=M):M=t[2];const D=M;let O;t[3]!==D||t[4]!==a?(O=se=>D(()=>a(se)),t[3]=D,t[4]=a,t[5]=O):O=t[5];const L=O;let F;t[6]!==D||t[7]!==c?(F=se=>D(()=>c(se)),t[6]=D,t[7]=c,t[8]=F):F=t[8];const z=F,W=Pg(E),U=(b==null?void 0:b.toLowerCase().startsWith("gpt-"))??!1,K=b&&(E==="copilot"||U===(E==="codex"))?b:void 0;let V,Y;t[9]!==W||t[10]!==K?(V=K?cd(K,W):pj(W),Y=W.map(se=>{const ue=[se.description,se.availabilityMessage].filter(Boolean).join(" · ")||void 0;return se.value===""?{...se,description:ue,label:V,menuLabel:se.label}:{...se,description:ue}}),t[9]=W,t[10]=K,t[11]=V,t[12]=Y):(V=t[11],Y=t[12]);const G=Y;let J;t[13]!==E||t[14]!==i?(J=vg(E,i),t[13]=E,t[14]=i,t[15]=J):J=t[15];const Q=J;let X;t[16]!==E||t[17]!==i?(X=yg(E,i),t[16]=E,t[17]=i,t[18]=X):X=t[18];const Z=X;let te;t[19]!==E||t[20]!==i?(te=iw(E,i),t[19]=E,t[20]=i,t[21]=te):te=t[21];const ne=te;let re;t[22]!==E||t[23]!==ne||t[24]!==D||t[25]!==Q||t[26]!==d||t[27]!==Z||t[28]!==z||t[29]!==L||t[30]!==f||t[31]!==k||t[32]!==w||t[33]!==G||t[34]!==o||t[35]!==u||t[36]!==C||t[37]!==_||t[38]!==j||t[39]!==S||t[40]!==g||t[41]!==p||t[42]!==N||t[43]!==V||t[44]!==l||t[45]!==v||t[46]!==i||t[47]!==h||t[48]!==m?(re={agentKind:E,onAgentKindChange:o,selectedModel:i,resolvedDefaultName:V,modelOptions:G,onModelChange:L,selectedEffort:l,effortOptions:Q,onEffortChange:z,fastTier:Z,fastModeEnabled:d,onFastModeEnabledChange:u,isNewSession:f,worktreeEnabled:m,onWorktreeEnabledChange:p,ultracodeEnabled:h,onUltracodeEnabledChange:g,autoModeAvailable:ne,permissionMode:N,onPermissionModeChange:_,mcpServers:w,selectedMcpServers:v,onToggleMcpServer:S,onRefreshMcpServers:j,mcpLoading:k,onMcpAuth:C,changeAndApply:D},t[22]=E,t[23]=ne,t[24]=D,t[25]=Q,t[26]=d,t[27]=Z,t[28]=z,t[29]=L,t[30]=f,t[31]=k,t[32]=w,t[33]=G,t[34]=o,t[35]=u,t[36]=C,t[37]=_,t[38]=j,t[39]=S,t[40]=g,t[41]=p,t[42]=N,t[43]=V,t[44]=l,t[45]=v,t[46]=i,t[47]=h,t[48]=m,t[49]=re):re=t[49];const ie=re;if(R){let se;return t[50]!==W||t[51]!==ie||t[52]!==P||t[53]!==$?(se=r.jsx(Xj,{...ie,open:$,onOpenChange:I,catalogOptions:W,mobileExtra:P}),t[50]=W,t[51]=ie,t[52]=P,t[53]=$,t[54]=se):se=t[54],se}let ae;return t[55]!==ie||t[56]!==A?(ae=r.jsx(Sj,{...ie,trailingExtra:A}),t[55]=ie,t[56]=A,t[57]=ae):ae=t[57],ae});function Dg(n){return n.agentType==="team-lead"}function Qj(n){return Dg(n)?void 0:n.color}const Zj={blue:"bg-blue-500",green:"bg-green-500",yellow:"bg-yellow-500",purple:"bg-purple-500",orange:"bg-orange-500"};function eS(n){return n?Zj[n]??"bg-zinc-400":"bg-zinc-400"}const tS=y.memo(function(e){const t=B.c(18),{teamName:s,members:o,currentMemberName:i,loadingMember:a,onMemberClick:l}=e;let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(ts,{className:"size-3"}),t[0]=c):c=t[0];let d;t[1]!==s?(d=r.jsxs("div",{className:"flex shrink-0 items-center gap-1.5 text-xs font-medium text-muted-foreground",children:[c,r.jsx("span",{className:"max-w-[120px] truncate",children:s})]}),t[1]=s,t[2]=d):d=t[2];let u;t[3]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(St,{orientation:"vertical",className:"h-3.5"}),t[3]=u):u=t[3];let f;if(t[4]!==i||t[5]!==a||t[6]!==o||t[7]!==l){let h;t[9]!==i||t[10]!==a||t[11]!==l?(h=g=>{const x=g.name===i,b=g.name===a,w=eS(Qj(g));return r.jsxs(ee,{variant:"ghost",size:"xs",onClick:()=>l(g),disabled:b,className:q("whitespace-nowrap",x?"bg-accent text-accent-foreground":"text-muted-foreground"),children:[b?r.jsx(ot,{"data-icon":"inline-start",className:"animate-spin"}):r.jsx("span",{className:q("inline-flex size-1.5 shrink-0 rounded-full",w)}),r.jsx("span",{children:g.name}),Dg(g)&&r.jsx(Jv,{"data-icon":"inline-end",className:"text-warning"})]},g.agentId)},t[9]=i,t[10]=a,t[11]=l,t[12]=h):h=t[12],f=o.map(h),t[4]=i,t[5]=a,t[6]=o,t[7]=l,t[8]=f}else f=t[8];let m;t[13]!==f?(m=r.jsx("div",{className:"flex items-center gap-1",children:f}),t[13]=f,t[14]=m):m=t[14];let p;return t[15]!==d||t[16]!==m?(p=r.jsxs("div",{className:"flex shrink-0 items-center gap-2 overflow-x-auto border-b bg-background px-3 py-2",children:[d,u,m]}),t[15]=d,t[16]=m,t[17]=p):p=t[17],p});function Lg(n){const e=B.c(3),t=y.useRef(null),[s,o]=y.useState(0);let i,a;return e[0]!==n?(i=()=>{if(!n){t.current=null,o(0);return}t.current=Date.now(),o(0);const l=setInterval(()=>{t.current!==null&&o(Math.floor((Date.now()-t.current)/1e3))},1e3);return()=>clearInterval(l)},a=[n],e[0]=n,e[1]=i,e[2]=a):(i=e[1],a=e[2]),y.useEffect(i,a),s}const zg=y.createContext(null),Fg=y.createContext(null);function Ai(n){const e=B.c(6),{value:t,chatValue:s,children:o}=n;let i;e[0]!==s||e[1]!==o?(i=r.jsx(Fg.Provider,{value:s,children:o}),e[0]=s,e[1]=o,e[2]=i):i=e[2];let a;return e[3]!==i||e[4]!==t?(a=r.jsx(zg.Provider,{value:t,children:i}),e[3]=i,e[4]=t,e[5]=a):a=e[5],a}function it(){const n=y.useContext(zg);if(!n)throw new Error("useSessionContext must be used within a SessionProvider");return n}function $r(){const n=y.useContext(Fg);if(!n)throw new Error("useSessionChatContext must be used within a SessionProvider");return n}const nS=es("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 _e(n){const e=B.c(13);let t,s,o,i,a;if(e[0]!==n){const{className:d,variant:u,render:f,...m}=n;t=f,a=u===void 0?"default":u,i=qh,s="span",o=Kh({className:q(nS({variant:a}),d)},m),e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a}else t=e[1],s=e[2],o=e[3],i=e[4],a=e[5];let l;e[6]!==a?(l={slot:"badge",variant:a},e[6]=a,e[7]=l):l=e[7];let c;return e[8]!==t||e[9]!==s||e[10]!==o||e[11]!==l?(c={defaultTagName:s,props:o,render:t,state:l},e[8]=t,e[9]=s,e[10]=o,e[11]=l,e[12]=c):c=e[12],i(c)}var Yf=1,sS=.9,oS=.8,rS=.17,cl=.1,dl=.999,iS=.9999,aS=.99,lS=/[\\\/_+.#"@\[\(\{&]/,cS=/[\\\/_+.#"@\[\(\{&]/g,dS=/[\s-]/,Bg=/[\s-]/g;function dc(n,e,t,s,o,i,a){if(i===e.length)return o===n.length?Yf:aS;var l=`${o},${i}`;if(a[l]!==void 0)return a[l];for(var c=s.charAt(i),d=t.indexOf(c,o),u=0,f,m,p,h;d>=0;)f=dc(n,e,t,s,d+1,i+1,a),f>u&&(d===o?f*=Yf:lS.test(n.charAt(d-1))?(f*=oS,p=n.slice(o,d-1).match(cS),p&&o>0&&(f*=Math.pow(dl,p.length))):dS.test(n.charAt(d-1))?(f*=sS,h=n.slice(o,d-1).match(Bg),h&&o>0&&(f*=Math.pow(dl,h.length))):(f*=rS,o>0&&(f*=Math.pow(dl,d-o))),n.charAt(d)!==e.charAt(i)&&(f*=iS)),(f<cl&&t.charAt(d-1)===s.charAt(i+1)||s.charAt(i+1)===s.charAt(i)&&t.charAt(d-1)!==s.charAt(i))&&(m=dc(n,e,t,s,d+1,i+2,a),m*cl>f&&(f=m*cl)),f>u&&(u=f),d=t.indexOf(c,d+1);return a[l]=u,u}function Xf(n){return n.toLowerCase().replace(Bg," ")}function uS(n,e,t){return n=t&&t.length>0?`${n+" "+t.join(" ")}`:n,dc(n,e,Xf(n),Xf(e),0,0,{})}var Do='[cmdk-group=""]',ul='[cmdk-group-items=""]',fS='[cmdk-group-heading=""]',Ug='[cmdk-item=""]',Jf=`${Ug}:not([aria-disabled="true"])`,uc="cmdk-item-select",fo="data-value",mS=(n,e,t)=>uS(n,e,t),Wg=y.createContext(void 0),Mr=()=>y.useContext(Wg),Hg=y.createContext(void 0),dd=()=>y.useContext(Hg),Kg=y.createContext(void 0),qg=y.forwardRef((n,e)=>{let t=mo(()=>{var z,W;return{search:"",value:(W=(z=n.value)!=null?z:n.defaultValue)!=null?W:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),s=mo(()=>new Set),o=mo(()=>new Map),i=mo(()=>new Map),a=mo(()=>new Set),l=Vg(n),{label:c,children:d,value:u,onValueChange:f,filter:m,shouldFilter:p,loop:h,disablePointerSelection:g=!1,vimBindings:x=!0,...b}=n,w=xo(),v=xo(),S=xo(),j=y.useRef(null),k=NS();Ws(()=>{if(u!==void 0){let z=u.trim();t.current.value=z,C.emit()}},[u]),Ws(()=>{k(6,E)},[]);let C=y.useMemo(()=>({subscribe:z=>(a.current.add(z),()=>a.current.delete(z)),snapshot:()=>t.current,setState:(z,W,U)=>{var H,K,V,Y;if(!Object.is(t.current[z],W)){if(t.current[z]=W,z==="search")T(),P(),k(1,A);else if(z==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let G=document.getElementById(S);G?G.focus():(H=document.getElementById(w))==null||H.focus()}if(k(7,()=>{var G;t.current.selectedItemId=(G=R())==null?void 0:G.id,C.emit()}),U||k(5,E),((K=l.current)==null?void 0:K.value)!==void 0){let G=W??"";(Y=(V=l.current).onValueChange)==null||Y.call(V,G);return}}C.emit()}},emit:()=>{a.current.forEach(z=>z())}}),[]),N=y.useMemo(()=>({value:(z,W,U)=>{var H;W!==((H=i.current.get(z))==null?void 0:H.value)&&(i.current.set(z,{value:W,keywords:U}),t.current.filtered.items.set(z,_(W,U)),k(2,()=>{P(),C.emit()}))},item:(z,W)=>(s.current.add(z),W&&(o.current.has(W)?o.current.get(W).add(z):o.current.set(W,new Set([z]))),k(3,()=>{T(),P(),t.current.value||A(),C.emit()}),()=>{i.current.delete(z),s.current.delete(z),t.current.filtered.items.delete(z);let U=R();k(4,()=>{T(),(U==null?void 0:U.getAttribute("id"))===z&&A(),C.emit()})}),group:z=>(o.current.has(z)||o.current.set(z,new Set),()=>{i.current.delete(z),o.current.delete(z)}),filter:()=>l.current.shouldFilter,label:c||n["aria-label"],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:w,inputId:S,labelId:v,listInnerRef:j}),[]);function _(z,W){var U,H;let K=(H=(U=l.current)==null?void 0:U.filter)!=null?H:mS;return z?K(z,t.current.search,W):0}function P(){if(!t.current.search||l.current.shouldFilter===!1)return;let z=t.current.filtered.items,W=[];t.current.filtered.groups.forEach(H=>{let K=o.current.get(H),V=0;K.forEach(Y=>{let G=z.get(Y);V=Math.max(G,V)}),W.push([H,V])});let U=j.current;$().sort((H,K)=>{var V,Y;let G=H.getAttribute("id"),J=K.getAttribute("id");return((V=z.get(J))!=null?V:0)-((Y=z.get(G))!=null?Y:0)}).forEach(H=>{let K=H.closest(ul);K?K.appendChild(H.parentElement===K?H:H.closest(`${ul} > *`)):U.appendChild(H.parentElement===U?H:H.closest(`${ul} > *`))}),W.sort((H,K)=>K[1]-H[1]).forEach(H=>{var K;let V=(K=j.current)==null?void 0:K.querySelector(`${Do}[${fo}="${encodeURIComponent(H[0])}"]`);V==null||V.parentElement.appendChild(V)})}function A(){let z=$().find(U=>U.getAttribute("aria-disabled")!=="true"),W=z==null?void 0:z.getAttribute(fo);C.setState("value",W||void 0)}function T(){var z,W,U,H;if(!t.current.search||l.current.shouldFilter===!1){t.current.filtered.count=s.current.size;return}t.current.filtered.groups=new Set;let K=0;for(let V of s.current){let Y=(W=(z=i.current.get(V))==null?void 0:z.value)!=null?W:"",G=(H=(U=i.current.get(V))==null?void 0:U.keywords)!=null?H:[],J=_(Y,G);t.current.filtered.items.set(V,J),J>0&&K++}for(let[V,Y]of o.current)for(let G of Y)if(t.current.filtered.items.get(G)>0){t.current.filtered.groups.add(V);break}t.current.filtered.count=K}function E(){var z,W,U;let H=R();H&&(((z=H.parentElement)==null?void 0:z.firstChild)===H&&((U=(W=H.closest(Do))==null?void 0:W.querySelector(fS))==null||U.scrollIntoView({block:"nearest"})),H.scrollIntoView({block:"nearest"}))}function R(){var z;return(z=j.current)==null?void 0:z.querySelector(`${Ug}[aria-selected="true"]`)}function $(){var z;return Array.from(((z=j.current)==null?void 0:z.querySelectorAll(Jf))||[])}function I(z){let W=$()[z];W&&C.setState("value",W.getAttribute(fo))}function M(z){var W;let U=R(),H=$(),K=H.findIndex(Y=>Y===U),V=H[K+z];(W=l.current)!=null&&W.loop&&(V=K+z<0?H[H.length-1]:K+z===H.length?H[0]:H[K+z]),V&&C.setState("value",V.getAttribute(fo))}function D(z){let W=R(),U=W==null?void 0:W.closest(Do),H;for(;U&&!H;)U=z>0?jS(U,Do):SS(U,Do),H=U==null?void 0:U.querySelector(Jf);H?C.setState("value",H.getAttribute(fo)):M(z)}let O=()=>I($().length-1),L=z=>{z.preventDefault(),z.metaKey?O():z.altKey?D(1):M(1)},F=z=>{z.preventDefault(),z.metaKey?I(0):z.altKey?D(-1):M(-1)};return y.createElement(Ts.div,{ref:e,tabIndex:-1,...b,"cmdk-root":"",onKeyDown:z=>{var W;(W=b.onKeyDown)==null||W.call(b,z);let U=z.nativeEvent.isComposing||z.keyCode===229;if(!(z.defaultPrevented||U))switch(z.key){case"n":case"j":{x&&z.ctrlKey&&L(z);break}case"ArrowDown":{L(z);break}case"p":case"k":{x&&z.ctrlKey&&F(z);break}case"ArrowUp":{F(z);break}case"Home":{z.preventDefault(),I(0);break}case"End":{z.preventDefault(),O();break}case"Enter":{z.preventDefault();let H=R();if(H){let K=new Event(uc);H.dispatchEvent(K)}}}}},y.createElement("label",{"cmdk-label":"",htmlFor:N.inputId,id:N.labelId,style:CS},c),Sa(n,z=>y.createElement(Hg.Provider,{value:C},y.createElement(Wg.Provider,{value:N},z))))}),pS=y.forwardRef((n,e)=>{var t,s;let o=xo(),i=y.useRef(null),a=y.useContext(Kg),l=Mr(),c=Vg(n),d=(s=(t=c.current)==null?void 0:t.forceMount)!=null?s:a==null?void 0:a.forceMount;Ws(()=>{if(!d)return l.item(o,a==null?void 0:a.id)},[d]);let u=Gg(o,i,[n.value,n.children,i],n.keywords),f=dd(),m=ks(k=>k.value&&k.value===u.current),p=ks(k=>d||l.filter()===!1?!0:k.search?k.filtered.items.get(o)>0:!0);y.useEffect(()=>{let k=i.current;if(!(!k||n.disabled))return k.addEventListener(uc,h),()=>k.removeEventListener(uc,h)},[p,n.onSelect,n.disabled]);function h(){var k,C;g(),(C=(k=c.current).onSelect)==null||C.call(k,u.current)}function g(){f.setState("value",u.current,!0)}if(!p)return null;let{disabled:x,value:b,onSelect:w,forceMount:v,keywords:S,...j}=n;return y.createElement(Ts.div,{ref:rr(i,e),...j,id:o,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!m,"data-disabled":!!x,"data-selected":!!m,onPointerMove:x||l.getDisablePointerSelection()?void 0:g,onClick:x?void 0:h},n.children)}),hS=y.forwardRef((n,e)=>{let{heading:t,children:s,forceMount:o,...i}=n,a=xo(),l=y.useRef(null),c=y.useRef(null),d=xo(),u=Mr(),f=ks(p=>o||u.filter()===!1?!0:p.search?p.filtered.groups.has(a):!0);Ws(()=>u.group(a),[]),Gg(a,l,[n.value,n.heading,c]);let m=y.useMemo(()=>({id:a,forceMount:o}),[o]);return y.createElement(Ts.div,{ref:rr(l,e),...i,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},t&&y.createElement("div",{ref:c,"cmdk-group-heading":"","aria-hidden":!0,id:d},t),Sa(n,p=>y.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":t?d:void 0},y.createElement(Kg.Provider,{value:m},p))))}),gS=y.forwardRef((n,e)=>{let{alwaysRender:t,...s}=n,o=y.useRef(null),i=ks(a=>!a.search);return!t&&!i?null:y.createElement(Ts.div,{ref:rr(o,e),...s,"cmdk-separator":"",role:"separator"})}),xS=y.forwardRef((n,e)=>{let{onValueChange:t,...s}=n,o=n.value!=null,i=dd(),a=ks(d=>d.search),l=ks(d=>d.selectedItemId),c=Mr();return y.useEffect(()=>{n.value!=null&&i.setState("search",n.value)},[n.value]),y.createElement(Ts.input,{ref:e,...s,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":l,id:c.inputId,type:"text",value:o?n.value:a,onChange:d=>{o||i.setState("search",d.target.value),t==null||t(d.target.value)}})}),bS=y.forwardRef((n,e)=>{let{children:t,label:s="Suggestions",...o}=n,i=y.useRef(null),a=y.useRef(null),l=ks(d=>d.selectedItemId),c=Mr();return y.useEffect(()=>{if(a.current&&i.current){let d=a.current,u=i.current,f,m=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let p=d.offsetHeight;u.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return m.observe(d),()=>{cancelAnimationFrame(f),m.unobserve(d)}}},[]),y.createElement(Ts.div,{ref:rr(i,e),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":s,id:c.listId},Sa(n,d=>y.createElement("div",{ref:rr(a,c.listInnerRef),"cmdk-list-sizer":""},d)))}),vS=y.forwardRef((n,e)=>{let{open:t,onOpenChange:s,overlayClassName:o,contentClassName:i,container:a,...l}=n;return y.createElement(Qv,{open:t,onOpenChange:s},y.createElement(Zv,{container:a},y.createElement(ey,{"cmdk-overlay":"",className:o}),y.createElement(ty,{"aria-label":n.label,"cmdk-dialog":"",className:i},y.createElement(qg,{ref:e,...l}))))}),yS=y.forwardRef((n,e)=>ks(t=>t.filtered.count===0)?y.createElement(Ts.div,{ref:e,...n,"cmdk-empty":"",role:"presentation"}):null),wS=y.forwardRef((n,e)=>{let{progress:t,children:s,label:o="Loading...",...i}=n;return y.createElement(Ts.div,{ref:e,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Sa(n,a=>y.createElement("div",{"aria-hidden":!0},a)))}),Ro=Object.assign(qg,{List:bS,Item:pS,Input:xS,Group:hS,Separator:gS,Dialog:vS,Empty:yS,Loading:wS});function jS(n,e){let t=n.nextElementSibling;for(;t;){if(t.matches(e))return t;t=t.nextElementSibling}}function SS(n,e){let t=n.previousElementSibling;for(;t;){if(t.matches(e))return t;t=t.previousElementSibling}}function Vg(n){let e=y.useRef(n);return Ws(()=>{e.current=n}),e}var Ws=typeof window>"u"?y.useEffect:y.useLayoutEffect;function mo(n){let e=y.useRef();return e.current===void 0&&(e.current=n()),e}function ks(n){let e=dd(),t=()=>n(e.snapshot());return y.useSyncExternalStore(e.subscribe,t,t)}function Gg(n,e,t,s=[]){let o=y.useRef(),i=Mr();return Ws(()=>{var a;let l=(()=>{var d;for(let u of t){if(typeof u=="string")return u.trim();if(typeof u=="object"&&"current"in u)return u.current?(d=u.current.textContent)==null?void 0:d.trim():o.current}})(),c=s.map(d=>d.trim());i.value(n,l,c),(a=e.current)==null||a.setAttribute(fo,l),o.current=l}),o}var NS=()=>{let[n,e]=y.useState(),t=mo(()=>new Map);return Ws(()=>{t.current.forEach(s=>s()),t.current=new Map},[n]),(s,o)=>{t.current.set(s,o),e({})}};function kS(n){let e=n.type;return typeof e=="function"?e(n.props):"render"in e?e.render(n.props):n}function Sa({asChild:n,children:e},t){return n&&y.isValidElement(e)?y.cloneElement(kS(e),{ref:e.ref},t(e.props.children)):t(e)}var CS={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function ns(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(Hh,{"data-slot":"dialog",...t}),e[2]=t,e[3]=s):s=e[3],s}function _S(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(Vc,{"data-slot":"dialog-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function TS(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("fixed inset-0 z-50 bg-black/55 duration-150 ease-out data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0 data-closed:duration-100 data-closed:ease-in motion-reduce:animate-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Gc,{"data-slot":"dialog-overlay",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function ss(n){const e=B.c(15);let t,s,o,i;e[0]!==n?({className:s,children:t,showCloseButton:i,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);const a=i===void 0?!0:i;let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(TS,{}),e[5]=l):l=e[5];let c;e[6]!==s?(c=q("fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl border bg-popover p-6 text-popover-foreground shadow-lg duration-150 ease-out sm:max-w-lg data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-100 data-closed:ease-in motion-reduce:animate-none",s),e[6]=s,e[7]=c):c=e[7];let d;e[8]!==a?(d=a&&r.jsxs(aa,{className:"absolute top-4 right-4 inline-flex size-7 items-center justify-center rounded-md text-muted-foreground outline-none transition-[color,background-color,transform,scale] duration-100 ease-out hover:bg-accent hover:text-foreground active:scale-90 focus-visible:ring-[3px] focus-visible:ring-ring/20 disabled:pointer-events-none motion-reduce:transition-none motion-reduce:active:scale-100",children:[r.jsx(rt,{"data-icon":"inline-start",className:"size-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]}),e[8]=a,e[9]=d):d=e[9];let u;return e[10]!==t||e[11]!==o||e[12]!==c||e[13]!==d?(u=r.jsxs(_S,{children:[l,r.jsxs(qc,{"data-slot":"dialog-content",className:c,...o,children:[t,d]})]}),e[10]=t,e[11]=o,e[12]=c,e[13]=d,e[14]=u):u=e[14],u}function Ps(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("flex flex-col gap-2 text-center sm:text-left",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"dialog-header",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Yg(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"dialog-footer",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function os(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("text-lg leading-none font-semibold",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Hc,{"data-slot":"dialog-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function rs(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("text-muted-foreground text-sm",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Kc,{"data-slot":"dialog-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Xg(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("flex size-full flex-col overflow-hidden rounded-xl! bg-popover p-1 text-popover-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Ro,{"data-slot":"command",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function BL(n){const e=B.c(24);let t,s,o,i,a,l;e[0]!==n?({title:i,description:a,children:t,className:s,showCloseButton:l,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a,e[6]=l):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5],l=e[6]);const c=i===void 0?"Command Palette":i,d=a===void 0?"Search for a command to run...":a,u=l===void 0?!1:l;let f;e[7]!==s?(f=q("top-1/3 translate-y-0 overflow-hidden rounded-xl! p-0",s),e[7]=s,e[8]=f):f=e[8];let m;e[9]!==c?(m=r.jsx(os,{children:c}),e[9]=c,e[10]=m):m=e[10];let p;e[11]!==d?(p=r.jsx(rs,{children:d}),e[11]=d,e[12]=p):p=e[12];let h;e[13]!==m||e[14]!==p?(h=r.jsxs(Ps,{className:"sr-only",children:[m,p]}),e[13]=m,e[14]=p,e[15]=h):h=e[15];let g;e[16]!==t||e[17]!==u||e[18]!==f||e[19]!==h?(g=r.jsxs(ss,{className:f,showCloseButton:u,children:[h,t]}),e[16]=t,e[17]=u,e[18]=f,e[19]=h,e[20]=g):g=e[20];let x;return e[21]!==o||e[22]!==g?(x=r.jsx(ns,{...o,children:g}),e[21]=o,e[22]=g,e[23]=x):x=e[23],x}function UL(n){const e=B.c(9);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(gn,{className:"size-4 shrink-0 text-muted-foreground"}),e[3]=o):o=e[3];let i;e[4]!==t?(i=q("min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),e[4]=t,e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==i?(a=r.jsxs("div",{"data-slot":"command-input-wrapper",className:"flex h-11 items-center gap-2 border-b px-3",children:[o,r.jsx(Ro.Input,{"data-slot":"command-input",className:i,...s})]}),e[6]=s,e[7]=i,e[8]=a):a=e[8],a}function Jg(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("no-scrollbar h-(--cmdk-list-height) max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none transition-[height] duration-100 ease-out motion-reduce:transition-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Ro.List,{"data-slot":"command-list",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function WL(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("py-6 text-center text-sm motion-safe:animate-in motion-safe:fade-in-0 motion-safe:duration-100 motion-reduce:animate-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Ro.Empty,{"data-slot":"command-empty",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Qg(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("overflow-hidden p-1 text-foreground **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Ro.Group,{"data-slot":"command-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Zg(n){const e=B.c(11);let t,s,o;e[0]!==n?({className:s,children:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==s?(i=q("group/command-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none transition-colors duration-75 in-data-[slot=dialog-content]:rounded-lg! data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-selected:bg-muted data-selected:text-foreground motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-selected:*:[svg]:text-foreground",s),e[4]=s,e[5]=i):i=e[5];let a;e[6]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(mt,{className:"ml-auto scale-75 opacity-0 transition-[opacity,transform,scale] duration-100 ease-out group-has-data-[slot=command-shortcut]/command-item:hidden group-data-[checked=true]/command-item:scale-100 group-data-[checked=true]/command-item:opacity-100 motion-reduce:transition-none"}),e[6]=a):a=e[6];let l;return e[7]!==t||e[8]!==o||e[9]!==i?(l=r.jsxs(Ro.Item,{"data-slot":"command-item",className:i,...o,children:[t,a]}),e[7]=t,e[8]=o,e[9]=i,e[10]=l):l=e[10],l}function ES(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("ml-auto text-xs tracking-widest text-muted-foreground group-data-selected/command-item:text-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("span",{"data-slot":"command-shortcut",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function PS(n){return r.jsx(_e,{variant:n.source==="built-in"?"secondary":"outline",children:n.source})}const AS=y.memo(function(e){const t=B.c(38),{suggestions:s,filter:o,loading:i,selectedIndex:a,onSelect:l,onHover:c,onEdit:d}=e;let u;t[0]===Symbol.for("react.memo_cache_sentinel")?(u=new Map,t[0]=u):u=t[0];const f=y.useRef(u);let m,p;if(t[1]!==a?(m=()=>{var A;const P=f.current.get(a);P&&((A=P.scrollIntoView)==null||A.call(P,{block:"nearest"}))},p=[a],t[1]=a,t[2]=m,t[3]=p):(m=t[2],p=t[3]),y.useEffect(m,p),i){let P;return t[4]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx("div",{className:"motion-popover-in absolute bottom-full left-0 right-0 z-50 mx-auto mb-2 max-w-[var(--chat-width)]",children:r.jsxs("div",{className:"flex items-center gap-2 rounded-lg border bg-popover p-3 text-popover-foreground shadow-sm",children:[r.jsx(ot,{className:"size-3.5 animate-spin text-muted-foreground"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading suggestions..."})]})}),t[4]=P):P=t[4],P}if(s.length===0){const P=o?`No commands or skills matching "${o}"`:"No commands or skills found";let A;return t[5]!==P?(A=r.jsx("div",{className:"motion-popover-in absolute bottom-full left-0 right-0 z-50 mx-auto mb-2 max-w-[var(--chat-width)]",children:r.jsx("div",{className:"rounded-lg border bg-popover p-3 text-popover-foreground shadow-sm",children:r.jsx("span",{className:"text-xs text-muted-foreground",children:P})})}),t[5]=P,t[6]=A):A=t[6],A}let h,g,x,b,w,v,S,j,k;if(t[7]!==d||t[8]!==c||t[9]!==l||t[10]!==a||t[11]!==s){const P=s.filter(IS),A=[{heading:"Commands",suggestions:P,offset:0},{heading:"Skills",suggestions:s.filter($S),offset:P.length}];x="motion-popover-in absolute bottom-full left-0 right-0 z-50 mx-auto mb-2 max-w-[var(--chat-width)]",g=Xg,w="slash-suggestions",v=s[a]?`${s[a].type}-${s[a].name}`:void 0,t[21]!==c||t[22]!==s?(S=T=>{const E=s.findIndex(R=>`${R.type}-${R.name}`===T);E>=0&&c(E)},t[21]=c,t[22]=s,t[23]=S):S=t[23],j=!1,k="border shadow-sm",h=Jg,b=A.map(T=>T.suggestions.length>0&&r.jsx(Qg,{heading:T.heading,children:T.suggestions.map((E,R)=>{const $=T.offset+R;return r.jsx(RS,{suggestion:E,index:$,isSelected:$===a,onSelect:l,onHover:c,onEdit:d,itemRefs:f},`${E.type}-${E.name}`)})},T.heading)),t[7]=d,t[8]=c,t[9]=l,t[10]=a,t[11]=s,t[12]=h,t[13]=g,t[14]=x,t[15]=b,t[16]=w,t[17]=v,t[18]=S,t[19]=j,t[20]=k}else h=t[12],g=t[13],x=t[14],b=t[15],w=t[16],v=t[17],S=t[18],j=t[19],k=t[20];let C;t[24]!==h||t[25]!==b?(C=r.jsx(h,{children:b}),t[24]=h,t[25]=b,t[26]=C):C=t[26];let N;t[27]!==g||t[28]!==C||t[29]!==w||t[30]!==v||t[31]!==S||t[32]!==j||t[33]!==k?(N=r.jsx(g,{id:w,value:v,onValueChange:S,shouldFilter:j,className:k,children:C}),t[27]=g,t[28]=C,t[29]=w,t[30]=v,t[31]=S,t[32]=j,t[33]=k,t[34]=N):N=t[34];let _;return t[35]!==x||t[36]!==N?(_=r.jsx("div",{className:x,children:N}),t[35]=x,t[36]=N,t[37]=_):_=t[37],_});function RS({suggestion:n,index:e,isSelected:t,onSelect:s,onHover:o,onEdit:i,itemRefs:a}){const l=y.useCallback(c=>{c?(c.id=`slash-suggestion-${e}`,a.current.set(e,c)):a.current.delete(e)},[e,a]);return r.jsxs("div",{className:"group/suggestion relative",children:[r.jsxs(Zg,{ref:l,value:`${n.type}-${n.name}`,className:"items-start gap-2.5 px-2 py-2 pr-10",onMouseEnter:()=>o(e),onSelect:()=>s(n),onMouseDown:c=>{c.preventDefault()},children:[r.jsx("div",{className:"mt-0.5 shrink-0",children:n.type==="command"?r.jsx(wo,{className:"size-4 text-muted-foreground"}):r.jsx(Vh,{className:"size-4 text-muted-foreground"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("span",{className:"font-mono text-sm font-medium text-foreground",children:["/",n.name]}),PS(n)]}),n.description&&r.jsx("p",{className:"mt-0.5 line-clamp-1 text-xs text-muted-foreground",children:n.description})]}),t&&r.jsx(ES,{className:i&&n.filePath?"mr-6":void 0,children:"Enter"})]}),i&&n.filePath&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",className:"absolute right-1.5 top-1/2 -translate-y-1/2 opacity-0 transition-opacity group-hover/suggestion:opacity-100 focus-visible:opacity-100",onMouseDown:c=>{c.preventDefault(),c.stopPropagation()},onClick:c=>{c.preventDefault(),c.stopPropagation(),i(n.filePath)},"aria-label":`Edit ${n.name}`,children:r.jsx(Vs,{"data-icon":"inline-start"})})]})}function IS(n){return n.type==="command"}function $S(n){return n.type==="skill"}function MS(n){const e=B.c(25),{files:t,query:s,loading:o,selectedIndex:i,onSelect:a,onHover:l}=n;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=new Map,e[0]=c):c=e[0];const d=y.useRef(c);let u,f;e[1]!==i?(u=()=>{var v,S;(S=(v=d.current.get(i))==null?void 0:v.scrollIntoView)==null||S.call(v,{block:"nearest"})},f=[i],e[1]=i,e[2]=u,e[3]=f):(u=e[2],f=e[3]),y.useEffect(u,f);const m=t[i];let p;e[4]!==t||e[5]!==l?(p=v=>{const S=t.indexOf(v);S>=0&&l(S)},e[4]=t,e[5]=l,e[6]=p):p=e[6];let h;e[7]!==o?(h=o&&r.jsx(ot,{"data-icon":"inline-end","aria-label":"Loading project files",className:"size-3.5 animate-spin"}),e[7]=o,e[8]=h):h=e[8];let g;e[9]!==h?(g=r.jsxs("span",{className:"flex items-center justify-between",children:["Project files",h]}),e[9]=h,e[10]=g):g=e[10];let x;e[11]!==t||e[12]!==o||e[13]!==l||e[14]!==a||e[15]!==s||e[16]!==i?(x=!o&&t.length===0?r.jsx("p",{className:"px-2 py-3 text-xs text-muted-foreground",children:s?`No files matching “${s}”`:"No project files found"}):t.map((v,S)=>r.jsxs(Zg,{ref:j=>{j?(j.id=`file-suggestion-${S}`,d.current.set(S,j)):d.current.delete(S)},value:v,onMouseEnter:()=>l(S),onSelect:()=>a(v),onMouseDown:OS,children:[r.jsx(Gh,{"data-icon":"inline-start","aria-hidden":"true",className:"size-3.5 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:v}),S===i&&r.jsx("span",{className:"text-xs text-muted-foreground",children:"↵"})]},v)),e[11]=t,e[12]=o,e[13]=l,e[14]=a,e[15]=s,e[16]=i,e[17]=x):x=e[17];let b;e[18]!==g||e[19]!==x?(b=r.jsx(Jg,{className:"max-h-70",children:r.jsx(Qg,{heading:g,children:x})}),e[18]=g,e[19]=x,e[20]=b):b=e[20];let w;return e[21]!==m||e[22]!==p||e[23]!==b?(w=r.jsx("div",{className:"motion-popover-in absolute bottom-full left-0 right-0 z-50 mx-auto mb-1.5 max-w-[var(--chat-width)]",children:r.jsx(Xg,{id:"file-suggestions",value:m,onValueChange:p,shouldFilter:!1,className:"border shadow-sm",children:b})}),e[21]=m,e[22]=p,e[23]=b,e[24]=w):w=e[24],w}function OS(n){return n.preventDefault()}const DS=es("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 ht(n){const e=B.c(10);let t,s,o;e[0]!==n?({className:t,variant:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==t||e[5]!==o?(i=q(DS({variant:o}),t),e[4]=t,e[5]=o,e[6]=i):i=e[6];let a;return e[7]!==s||e[8]!==i?(a=r.jsx("div",{"data-slot":"alert",role:"alert",className:i,...s}),e[7]=s,e[8]=i,e[9]=a):a=e[9],a}function Tt(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("font-medium group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"alert-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function gt(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("text-sm text-balance text-muted-foreground md:text-pretty [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"alert-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Cs(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("absolute top-2 right-2",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"alert-action",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function ct(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(sy,{"data-slot":"collapsible",...t}),e[2]=t,e[3]=s):s=e[3],s}function Mt(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(oy,{"data-slot":"collapsible-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function dt(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("h-[var(--collapsible-panel-height)] overflow-hidden opacity-100 transition-[height,opacity] duration-150 ease-out [&[hidden]:not([hidden='until-found'])]:hidden motion-safe:data-starting-style:h-0 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:h-0 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(ny,{"data-slot":"collapsible-content",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const LS={exit_only:"Exit plan mode",interactive:"Implement interactively",autopilot:"Implement with Autopilot",autopilot_fleet:"Implement with Fleet"};function Qf(n){return LS[n]??n.replaceAll("_"," ")}function zS(n){const e=B.c(46),{allowedPrompts:t,summary:s,planContent:o,actions:i,recommendedAction:a,responding:l,responseError:c,onApprove:d,onReject:u}=n;let f,m,p,h,g,x,b,w,v,S;if(e[0]!==d||e[1]!==a||e[2]!==s||e[3]!==i||e[4]!==l){const A=i===void 0?[]:i;p=l===void 0?!1:l;const T=a??A[0],E=A.filter(I=>I!==T);m=ht,b="mb-3 pr-44",e[15]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(Cr,{}),v=r.jsx(Tt,{children:"Plan ready for review"}),e[15]=w,e[16]=v):(w=e[15],v=e[16]);const R=s||"Approve the plan or ask the agent to revise it.";e[17]!==R?(S=r.jsx(gt,{children:R}),e[17]=R,e[18]=S):S=e[18],f=Cs,h="flex gap-2";let $;e[19]!==p?($=p&&r.jsx(ot,{className:"animate-spin","data-icon":"inline-start"}),e[19]=p,e[20]=$):$=e[20],g=r.jsxs(ee,{size:"sm",disabled:p,onClick:()=>d(T),children:[$,p?"Sending...":T?Qf(T):"Approve"]}),x=E.length>0&&r.jsxs(Wn,{children:[r.jsx(Hn,{render:r.jsx(ee,{type:"button",variant:"outline",size:"icon-sm","aria-label":"Other plan actions",disabled:p}),children:r.jsx(tt,{"data-icon":"icon"})}),r.jsx(Kn,{align:"end",children:r.jsx(en,{children:E.map(I=>r.jsx(_t,{onClick:()=>d(I),children:Qf(I)},I))})})]}),e[0]=d,e[1]=a,e[2]=s,e[3]=i,e[4]=l,e[5]=f,e[6]=m,e[7]=p,e[8]=h,e[9]=g,e[10]=x,e[11]=b,e[12]=w,e[13]=v,e[14]=S}else f=e[5],m=e[6],p=e[7],h=e[8],g=e[9],x=e[10],b=e[11],w=e[12],v=e[13],S=e[14];let j;e[21]!==u||e[22]!==p?(j=r.jsx(ee,{variant:"ghost",size:"sm",disabled:p,onClick:u,children:"Reject"}),e[21]=u,e[22]=p,e[23]=j):j=e[23];let k;e[24]!==f||e[25]!==j||e[26]!==h||e[27]!==g||e[28]!==x?(k=r.jsxs(f,{className:h,children:[g,x,j]}),e[24]=f,e[25]=j,e[26]=h,e[27]=g,e[28]=x,e[29]=k):k=e[29];let C;e[30]!==c?(C=c&&r.jsx("div",{role:"alert",className:"col-span-full mt-2 text-xs text-destructive",children:c}),e[30]=c,e[31]=C):C=e[31];let N;e[32]!==o?(N=o&&r.jsxs(ct,{className:"col-span-full mt-2",children:[r.jsx(Mt,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"xs"}),children:"Review full plan"}),r.jsx(dt,{children:r.jsx("pre",{className:"mt-2 max-h-64 overflow-auto whitespace-pre-wrap rounded-md bg-muted p-3 text-xs text-foreground",children:o})})]}),e[32]=o,e[33]=N):N=e[33];let _;e[34]!==t?(_=t&&t.length>0&&r.jsxs("div",{className:"col-span-full mt-2 flex flex-wrap gap-1",children:[r.jsx("span",{className:"mr-1 self-center text-xs text-muted-foreground",children:"Permissions requested:"}),t.map(FS)]}),e[34]=t,e[35]=_):_=e[35];let P;return e[36]!==m||e[37]!==k||e[38]!==C||e[39]!==N||e[40]!==_||e[41]!==b||e[42]!==w||e[43]!==v||e[44]!==S?(P=r.jsxs(m,{className:b,children:[w,v,S,k,C,N,_]}),e[36]=m,e[37]=k,e[38]=C,e[39]=N,e[40]=_,e[41]=b,e[42]=w,e[43]=v,e[44]=S,e[45]=P):P=e[45],P}function FS(n,e){return r.jsx(_e,{variant:"outline",children:n.prompt},e)}const BS=["allow","allow_always","deny"];function mi(n,e){return(n.availableDecisions??BS).includes(e)}function US(n){switch(n){case"Bash":return{label:"Run command",icon:wo,tone:"cmd"};case"Edit":return{label:"Edit file",icon:nc,tone:"write"};case"Write":return{label:"Write file",icon:nc,tone:"write"};case"Read":return{label:"Read file",icon:ys,tone:"read"};case"Glob":return{label:"File search",icon:gn,tone:"search"};case"Grep":return{label:"Content search",icon:gn,tone:"search"};case"WebFetch":return{label:"Fetch URL",icon:tc,tone:"net"};case"WebSearch":return{label:"Web search",icon:tc,tone:"net"};default:return{label:n,icon:la,tone:"other"}}}function WS(n,e){if(n==="Bash"&&typeof e.command=="string")return e.command;if((n==="Edit"||n==="Write"||n==="Read")&&typeof e.file_path=="string")return e.file_path;if((n==="Glob"||n==="Grep")&&typeof e.pattern=="string")return e.pattern;if(n==="WebFetch"&&typeof e.url=="string")return e.url;if(n==="WebSearch"&&typeof e.query=="string")return e.query;const t=Object.keys(e).slice(0,2);return t.length===0?null:t.flatMap(s=>{const o=e[s],i=typeof o=="string"?o:JSON.stringify(o);return i?[i.length>160?i.slice(0,157)+"…":i]:[]}).join(" · ")}function HS({requests:n,responding:e,onRespond:t,onRespondAll:s}){var w;const o=n[0],i=n.length,a=o?mi(o,"allow"):!1,l=o?mi(o,"allow_always"):!1,c=o?mi(o,"deny"):!1,d=i>1&&n.every(v=>mi(v,"allow")),u=y.useEffectEvent(v=>{if(!o)return;const S=v.target;if(S&&(S.tagName==="INPUT"||S.tagName==="TEXTAREA"||S.isContentEditable)||v.metaKey||v.ctrlKey||v.altKey)return;const j=v.key.toLowerCase();j==="a"&&v.shiftKey&&d?(v.preventDefault(),s("allow")):j==="a"&&a?(v.preventDefault(),t(o.requestId,"allow")):j==="s"&&l?(v.preventDefault(),t(o.requestId,"allow_always")):j==="d"&&c&&(v.preventDefault(),t(o.requestId,"deny"))});y.useEffect(()=>{const v=S=>u(S);return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[]);const f=o?US(o.toolName):null,m=o?WS(o.toolName,o.input):null,p=(o==null?void 0:o.decisionReason)||(o==null?void 0:o.description)||(o==null?void 0:o.blockedPath),h=(((w=o==null?void 0:o.suggestions)==null?void 0:w.length)??0)>0;if(!o||!f)return null;const g=f.icon,x=e.has(o.requestId),b=i>1;return r.jsx("div",{className:"motion-slide-down-in border-b border-warning/20 bg-warning/5",children:r.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[r.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r.jsx("div",{className:"flex size-7 items-center justify-center rounded-md bg-warning/10 text-warning",children:r.jsx(Wh,{className:"size-4"})}),r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(g,{className:"size-4 text-muted-foreground"}),r.jsx("span",{className:"text-sm font-medium text-foreground",children:f.label})]})]}),m&&r.jsx("div",{className:"min-w-0 flex-1",children:r.jsx("code",{className:"block truncate rounded-md border bg-muted/40 px-2 py-1 font-mono text-xs text-muted-foreground",children:m})}),p&&p!==m&&r.jsx("p",{className:"hidden max-w-64 truncate text-xs text-muted-foreground xl:block",title:p,children:p}),b&&r.jsxs(_e,{variant:"outline",className:"shrink-0 tabular-nums",children:["+",i-1," more"]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[c&&r.jsxs(ee,{variant:"ghost",size:"sm",className:"text-destructive",disabled:x,onClick:()=>t(o.requestId,"deny"),title:"Deny (D)",children:[r.jsx(rt,{"data-icon":"inline-start"}),"Deny",r.jsx("kbd",{className:"ml-0.5 font-mono text-xs text-muted-foreground",children:"D"})]}),l&&r.jsxs(ee,{variant:"outline",size:"sm",disabled:x,onClick:()=>t(o.requestId,"allow_always"),title:h?"Apply Claude's suggested scoped permission rule (S)":`Allow ${o.toolName} for this session (S)`,children:[r.jsx(ry,{"data-icon":"inline-start"}),h?"Remember rule":"Session",r.jsx("kbd",{className:"ml-0.5 font-mono text-xs text-muted-foreground",children:"S"})]}),d&&r.jsxs(ee,{variant:"secondary",size:"sm",disabled:x,onClick:()=>s("allow"),title:"Allow all pending (⇧A)",children:["Allow all",r.jsx("kbd",{className:"ml-0.5 font-mono text-xs text-muted-foreground",children:"⇧A"})]}),a&&r.jsxs(ee,{size:"sm",disabled:x,onClick:()=>t(o.requestId,"allow"),title:"Allow once (A)",children:[r.jsx(mt,{"data-icon":"inline-start"}),"Allow",r.jsx("kbd",{className:"ml-0.5 font-mono text-xs opacity-70",children:"A"})]}),!a&&!l&&!c&&r.jsx("span",{className:"text-xs text-muted-foreground",children:"Resolve this approval in Codex"})]})]})})}const KS=1568,qS=.85,Zf=35e5;function VS(n,e){let{width:t,height:s}=n;const o=Math.min(1,KS/Math.max(t,s));t=Math.round(t*o),s=Math.round(s*o);const i=document.createElement("canvas");i.width=t,i.height=s,i.getContext("2d").drawImage(n,0,0,t,s);const l=e==="image/jpeg"||e==="image/webp",c=l?"image/jpeg":"image/png";let d=i.toDataURL(c,l?qS:void 0),u=d.split(",")[1];if(u.length>Zf){let f=l?.7:.8;for(;u.length>Zf&&f>.3;)d=i.toDataURL("image/jpeg",f),u=d.split(",")[1],f-=.1;return{dataUrl:d,base64:u,mediaType:"image/jpeg"}}return{dataUrl:d,base64:u,mediaType:c}}function GS(n){const e=B.c(24),t=n===void 0?!0:n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=[],e[0]=s):s=e[0];const[o,i]=y.useState(s),[a,l]=y.useState(!1),[c,d]=y.useState(!1),u=y.useRef(t);let f,m;e[1]!==t?(f=()=>{u.current=t},m=[t],e[1]=t,e[2]=f,e[3]=m):(f=e[2],m=e[3]),y.useEffect(f,m);let p;e[4]!==t?(p=I=>{const M=Array.from(I).filter(JS);if(!t){M.length>0&&d(!0);return}d(!1);for(const D of M){const O=new FileReader;O.onload=()=>{if(!u.current){d(!0);return}const L=O.result,F=new Image;F.onload=()=>{if(!u.current){d(!0);return}const z=VS(F,D.type);i(W=>[...W,{id:crypto.randomUUID(),file:D,preview:z.dataUrl,data:z.base64,mediaType:z.mediaType}])},F.src=L},O.onerror=()=>{console.warn(`Failed to read image file: ${D.name}`)},O.readAsDataURL(D)}},e[4]=t,e[5]=p):p=e[5];const h=p;let g;e[6]===Symbol.for("react.memo_cache_sentinel")?(g=I=>{i(M=>M.filter((D,O)=>O!==I)),d(!1)},e[6]=g):g=e[6];const x=g;let b;e[7]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{i([]),d(!1)},e[7]=b):b=e[7];const w=b;let v;e[8]===Symbol.for("react.memo_cache_sentinel")?(v=()=>d(!1),e[8]=v):v=e[8];const S=v;let j;e[9]!==t?(j=I=>{I.preventDefault(),t&&l(!0)},e[9]=t,e[10]=j):j=e[10];const k=j;let C;e[11]===Symbol.for("react.memo_cache_sentinel")?(C=I=>{I.preventDefault(),I.currentTarget.contains(I.relatedTarget)||l(!1)},e[11]=C):C=e[11];const N=C;let _;e[12]!==h?(_=I=>{I.preventDefault(),l(!1),I.dataTransfer.files.length>0&&h(I.dataTransfer.files)},e[12]=h,e[13]=_):_=e[13];const P=_;let A;e[14]!==h?(A=I=>{var L;const M=(L=I.clipboardData)==null?void 0:L.items;if(!M)return;const D=Array.from(M).filter(XS);if(D.length===0)return;I.preventDefault();const O=D.map(YS).filter(Boolean);h(O)},e[14]=h,e[15]=A):A=e[15];const T=A,E=!t&&o.length>0?"The selected model does not accept images. Switch models or remove the attachments.":!t&&c?"The selected model does not accept the image you tried to add.":null,R=!t&&o.length>0;let $;return e[16]!==k||e[17]!==P||e[18]!==T||e[19]!==o||e[20]!==a||e[21]!==E||e[22]!==R?($={images:o,isDragOver:a,imageError:E,hasUnsupportedAttachments:R,dismissImageError:S,removeImage:x,clearImages:w,handleDragOver:k,handleDragLeave:N,handleDrop:P,handlePaste:T},e[16]=k,e[17]=P,e[18]=T,e[19]=o,e[20]=a,e[21]=E,e[22]=R,e[23]=$):$=e[23],$}function YS(n){return n.getAsFile()}function XS(n){return n.type.startsWith("image/")}function JS(n){return n.type.startsWith("image/")}function QS(n){const e=B.c(6);let t,s;e[0]!==n?({delay:s,...t}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);const o=s===void 0?0:s;let i;return e[3]!==o||e[4]!==t?(i=r.jsx(cy,{"data-slot":"tooltip-provider",delay:o,...t}),e[3]=o,e[4]=t,e[5]=i):i=e[5],i}function At(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(QS,{children:r.jsx(ly,{"data-slot":"tooltip",...t})}),e[2]=t,e[3]=s):s=e[3],s}function Rt(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(iy,{"data-slot":"tooltip-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function It(n){const e=B.c(20);let t,s,o,i,a,l,c;e[0]!==n?({className:s,side:i,sideOffset:a,align:l,alignOffset:c,children:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a,e[6]=l,e[7]=c):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5],l=e[6],c=e[7]);const d=i===void 0?"top":i,u=a===void 0?4:a,f=l===void 0?"center":l,m=c===void 0?0:c;let p;e[8]!==s?(p=q("z-50 w-fit origin-(--transform-origin) overflow-hidden rounded-md bg-popover px-2.5 py-1.5 text-xs text-popover-foreground shadow-md ring-1 ring-foreground/10 text-balance duration-100 ease-out data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",s),e[8]=s,e[9]=p):p=e[9];let h;e[10]!==t||e[11]!==o||e[12]!==p?(h=r.jsx(ay,{"data-slot":"tooltip-content",className:p,...o,children:t}),e[10]=t,e[11]=o,e[12]=p,e[13]=h):h=e[13];let g;return e[14]!==f||e[15]!==m||e[16]!==d||e[17]!==u||e[18]!==h?(g=r.jsx(dy,{children:r.jsx(uy,{align:f,alignOffset:m,side:d,sideOffset:u,className:"isolate z-50",children:h})}),e[14]=f,e[15]=m,e[16]=d,e[17]=u,e[18]=h,e[19]=g):g=e[19],g}const Mn="rounded-full border bg-background/80 shadow-sm backdrop-blur",Na=y.memo(function(e){const t=B.c(8);let s,o;t[0]!==e?({className:s,...o}=e,t[0]=e,t[1]=s,t[2]=o):(s=t[1],o=t[2]);let i;t[3]!==s?(i=q("inline-block size-2 shrink-0 rounded-full bg-success",s),t[3]=s,t[4]=i):i=t[4];let a;return t[5]!==o||t[6]!==i?(a=r.jsx("span",{className:i,...o}),t[5]=o,t[6]=i,t[7]=a):a=t[7],a}),fl=y.memo(function(e){const t=B.c(17),{icon:s,label:o,onClick:i,disabled:a,className:l,iconClassName:c,size:d}=e,f=(d===void 0?"sm":d)==="sm"?"icon-xs":"icon-sm";let m;t[0]!==l||t[1]!==a||t[2]!==o||t[3]!==i||t[4]!==f?(m=r.jsx(ee,{variant:"ghost",size:f,className:l,onClick:i,disabled:a,"aria-label":o}),t[0]=l,t[1]=a,t[2]=o,t[3]=i,t[4]=f,t[5]=m):m=t[5];let p;t[6]!==s||t[7]!==c?(p=r.jsx(s,{"data-icon":"inline-start",className:c}),t[6]=s,t[7]=c,t[8]=p):p=t[8];let h;t[9]!==m||t[10]!==p?(h=r.jsx(Rt,{render:m,children:p}),t[9]=m,t[10]=p,t[11]=h):h=t[11];let g;t[12]!==o?(g=r.jsx(It,{children:o}),t[12]=o,t[13]=g):g=t[13];let x;return t[14]!==h||t[15]!==g?(x=r.jsxs(At,{children:[h,g]}),t[14]=h,t[15]=g,t[16]=x):x=t[16],x});function ZS(n){return n<10?"critical":n<30?"warning":"healthy"}const e4={critical:"border-destructive/30 bg-destructive/10 text-destructive",warning:"border-warning/30 bg-warning/10 text-warning",healthy:"text-muted-foreground"},e1=y.memo(function(e){const t=B.c(54),{rawMessages:s,showRemaining:o,showTooltip:i,warnOnly:a}=e,l=o===void 0?!1:o,c=i===void 0?!1:i,d=a===void 0?!1:a;let u,f,m,p,h,g,x,b,w,v,S,j,k;if(t[0]!==s||t[1]!==l||t[2]!==c||t[3]!==d){x=Symbol.for("react.early_return_sentinel");e:{const P=Rg(s);if(!P){x=null;break e}const A=Math.max(0,100-P.percent),T=ZS(A);if(d&&T==="healthy"){x=null;break e}const E=Math.max(0,P.compactAt-P.used);let R;t[17]!==A||t[18]!==E||t[19]!==l?(R=l?`${A.toFixed(0)}% · ${ut(E)}`:`${A.toFixed(0)}%`,t[17]=A,t[18]=E,t[19]=l,t[20]=R):R=t[20];const $=R,I=e4[T],M=l&&"gap-1";let D;t[21]!==I||t[22]!==M?(D=q("shrink-0 tabular-nums",I,M),t[21]=I,t[22]=M,t[23]=D):D=t[23];let O;t[24]!==$||t[25]!==D?(O=r.jsx(_e,{variant:"outline",className:D,children:$}),t[24]=$,t[25]=D,t[26]=O):O=t[26];const L=O;if(!c){x=L;break e}f=At,t[27]!==L?(g=r.jsx(Rt,{render:L}),t[27]=L,t[28]=g):g=t[28],u=It,m="flex flex-col gap-1 text-xs",t[29]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx("div",{className:"font-medium",children:"Context before auto-compact"}),t[29]=p):p=t[29];let F;t[30]!==E?(F=ut(E),t[30]=E,t[31]=F):F=t[31];let z;t[32]!==A?(z=A.toFixed(1),t[32]=A,t[33]=z):z=t[33],t[34]!==F||t[35]!==z?(h=r.jsxs("div",{children:[F," remaining (",z,"%)"]}),t[34]=F,t[35]=z,t[36]=h):h=t[36],b="text-muted-foreground",w=ut(P.used),v=" / ",S=ut(P.limit),j=" tokens used (",k=P.percentAbsolute.toFixed(1)}t[0]=s,t[1]=l,t[2]=c,t[3]=d,t[4]=u,t[5]=f,t[6]=m,t[7]=p,t[8]=h,t[9]=g,t[10]=x,t[11]=b,t[12]=w,t[13]=v,t[14]=S,t[15]=j,t[16]=k}else u=t[4],f=t[5],m=t[6],p=t[7],h=t[8],g=t[9],x=t[10],b=t[11],w=t[12],v=t[13],S=t[14],j=t[15],k=t[16];if(x!==Symbol.for("react.early_return_sentinel"))return x;let C;t[37]!==b||t[38]!==w||t[39]!==v||t[40]!==S||t[41]!==j||t[42]!==k?(C=r.jsxs("div",{className:b,children:[w,v,S,j,k,"%)"]}),t[37]=b,t[38]=w,t[39]=v,t[40]=S,t[41]=j,t[42]=k,t[43]=C):C=t[43];let N;t[44]!==u||t[45]!==m||t[46]!==p||t[47]!==h||t[48]!==C?(N=r.jsxs(u,{className:m,children:[p,h,C]}),t[44]=u,t[45]=m,t[46]=p,t[47]=h,t[48]=C,t[49]=N):N=t[49];let _;return t[50]!==f||t[51]!==g||t[52]!==N?(_=r.jsxs(f,{children:[g,N]}),t[50]=f,t[51]=g,t[52]=N,t[53]=_):_=t[53],_});function t4(n){const e=B.c(7),{isPlanApproval:t,isUserQuestion:s,elapsedSec:o}=n,{isLive:i}=it(),{chat:a}=$r(),{isConnected:l}=a,c=l||i;let d;e[0]!==o||e[1]!==t||e[2]!==s||e[3]!==c?(d=c&&!t&&!s&&r.jsxs("div",{className:"motion-enter mr-1 flex items-center gap-1.5",children:[o>0&&r.jsx("span",{className:"font-mono text-xs tabular-nums text-muted-foreground",children:ej(o)}),r.jsx(Na,{})]}),e[0]=o,e[1]=t,e[2]=s,e[3]=c,e[4]=d):d=e[4];let u;return e[5]!==d?(u=r.jsx(r.Fragment,{children:d}),e[5]=d,e[6]=u):u=e[6],u}function n4(n){const e=B.c(26),{hasContent:t,onSubmit:s,submitLabel:o}=n,i=o===void 0?"Send message":o,{isLive:a,sessionSource:l,actions:c}=it(),{handleStopSession:d}=c,{chat:u}=$r(),{isConnected:f,interrupt:m}=u,p=f||a;let h;e[0]!==(l==null?void 0:l.agentKind)||e[1]!==(l==null?void 0:l.dirName)?(h=(l==null?void 0:l.agentKind)??Et((l==null?void 0:l.dirName)??null),e[0]=l==null?void 0:l.agentKind,e[1]=l==null?void 0:l.dirName,e[2]=h):h=e[2];const g=h;let x;e[3]!==g?(x=dj(g),e[3]=g,e[4]=x):x=e[4];const b=x;let w;e[5]!==b||e[6]!==m||e[7]!==p?(w=p&&r.jsxs(At,{children:[r.jsx(Rt,{render:r.jsx(ee,{variant:"outline",size:"icon-sm",className:"motion-enter shrink-0 rounded-full text-warning",onClick:m,"aria-label":b,title:b}),children:r.jsx(Xc,{"data-icon":"inline-start",className:"fill-current"})}),r.jsxs(It,{children:[b," (Esc)"]})]}),e[5]=b,e[6]=m,e[7]=p,e[8]=w):w=e[8];let v;e[9]!==g||e[10]!==d||e[11]!==p?(v=p&&qt(g).stopSession&&r.jsxs(At,{children:[r.jsx(Rt,{render:r.jsx(ee,{variant:"ghost",size:"icon-sm",className:"motion-enter shrink-0 rounded-full text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:d,"aria-label":"Stop session",title:"Stop session"}),children:r.jsx(fy,{"data-icon":"inline-start"})}),r.jsx(It,{children:"Stop session"})]}),e[9]=g,e[10]=d,e[11]=p,e[12]=v):v=e[12];const S=t?"default":"secondary",j=!t&&"text-muted-foreground";let k;e[13]!==j?(k=q("shrink-0 rounded-full",j),e[13]=j,e[14]=k):k=e[14];const C=!t;let N;e[15]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(my,{"data-icon":"inline-start"}),e[15]=N):N=e[15];let _;e[16]!==s||e[17]!==i||e[18]!==k||e[19]!==C||e[20]!==S?(_=r.jsx(ee,{variant:S,size:"icon-sm",className:k,disabled:C,onClick:s,"aria-label":i,title:i,children:N}),e[16]=s,e[17]=i,e[18]=k,e[19]=C,e[20]=S,e[21]=_):_=e[21];let P;return e[22]!==_||e[23]!==w||e[24]!==v?(P=r.jsxs("div",{className:"flex items-center gap-1",children:[w,v,_]}),e[22]=_,e[23]=w,e[24]=v,e[25]=P):P=e[25],P}function em(n){const e=B.c(34),{error:t}=n,[s,o]=y.useState(!1),[i,a]=y.useState(!1);let l;e[0]!==t?(l=t.split(`
3
- `),e[0]=t,e[1]=l):l=e[1];const c=l[0];let d;e[2]!==t||e[3]!==c?(d=t.includes(`
4
- `)||t.length>c.length,e[2]=t,e[3]=c,e[4]=d):d=e[4];const u=d;let f;e[5]!==t?(f=async()=>{try{await navigator.clipboard.writeText(t),a(!0),setTimeout(()=>a(!1),1500)}catch{}},e[5]=t,e[6]=f):f=e[6];const m=f;let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=()=>o(!0),e[7]=p):p=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(tn,{"data-icon":"inline-start"}),e[8]=h):h=e[8];let g;e[9]!==c?(g=r.jsx("span",{className:"truncate",children:c}),e[9]=c,e[10]=g):g=e[10];let x;e[11]!==u?(x=u&&r.jsx("span",{className:"shrink-0 opacity-60",children:"(details)"}),e[11]=u,e[12]=x):x=e[12];let b;e[13]!==g||e[14]!==x?(b=r.jsxs(ee,{type:"button",variant:"ghost",size:"sm",onClick:p,title:"Click to view the full error",className:"motion-enter mt-1 w-full justify-start text-destructive",children:[h,g,x]}),e[13]=g,e[14]=x,e[15]=b):b=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsxs(Ps,{children:[r.jsxs(os,{className:"flex items-center gap-2 text-destructive",children:[r.jsx(tn,{className:"size-4"}),"Error details"]}),r.jsx(rs,{children:"The full output from the failed request, including the underlying process stderr."})]}),e[16]=w):w=e[16];let v;e[17]!==t?(v=r.jsx("pre",{className:"max-h-[50vh] select-text overflow-auto whitespace-pre-wrap break-words rounded-md border bg-muted/30 p-3 font-mono text-xs text-destructive",children:t}),e[17]=t,e[18]=v):v=e[18];let S;e[19]!==i?(S=i?r.jsx(mt,{"data-icon":"inline-start"}):r.jsx(An,{"data-icon":"inline-start"}),e[19]=i,e[20]=S):S=e[20];const j=i?"Copied":"Copy";let k;e[21]!==m||e[22]!==S||e[23]!==j?(k=r.jsx("div",{className:"flex justify-end",children:r.jsxs(ee,{type:"button",variant:"outline",size:"sm",onClick:m,children:[S,j]})}),e[21]=m,e[22]=S,e[23]=j,e[24]=k):k=e[24];let C;e[25]!==v||e[26]!==k?(C=r.jsxs(ss,{className:"max-w-2xl",children:[w,v,k]}),e[25]=v,e[26]=k,e[27]=C):C=e[27];let N;e[28]!==s||e[29]!==C?(N=r.jsx(ns,{open:s,onOpenChange:o,children:C}),e[28]=s,e[29]=C,e[30]=N):N=e[30];let _;return e[31]!==N||e[32]!==b?(_=r.jsxs(r.Fragment,{children:[b,N]}),e[31]=N,e[32]=b,e[33]=_):_=e[33],_}function s4(n){const e=B.c(17),{suggestion:t,onAccept:s}=n,[o,i]=y.useState(null);if(!t||t===o)return null;let a;e[0]!==s||e[1]!==t?(a=()=>{i(t),s(t)},e[0]=s,e[1]=t,e[2]=a):a=e[2];let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Vh,{"data-icon":"inline-start"}),e[3]=l):l=e[3];let c;e[4]!==t?(c=r.jsx("span",{className:"truncate",children:t}),e[4]=t,e[5]=c):c=e[5];let d;e[6]!==a||e[7]!==c?(d=r.jsxs(ee,{type:"button",variant:"ghost",size:"sm",title:"Put this in the composer",onClick:a,className:"min-w-0 flex-1 justify-start text-muted-foreground",children:[l,c]}),e[6]=a,e[7]=c,e[8]=d):d=e[8];let u;e[9]!==t?(u=()=>i(t),e[9]=t,e[10]=u):u=e[10];let f;e[11]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(rt,{}),e[11]=f):f=e[11];let m;e[12]!==u?(m=r.jsx(ee,{type:"button",variant:"ghost",size:"icon","aria-label":"Dismiss suggestion",onClick:u,className:"shrink-0 text-muted-foreground",children:f}),e[12]=u,e[13]=m):m=e[13];let p;return e[14]!==d||e[15]!==m?(p=r.jsxs("div",{className:"motion-enter mb-1 flex items-center gap-1",children:[d,m]}),e[14]=d,e[15]=m,e[16]=p):p=e[16],p}function o4(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 r4(n,e,t){return`${n.slice(0,e.start)}@${t} `}const ka={terminal:!0,configWrite:!0,hostFiles:!0,manageUsers:!0,manageWorkspaces:!0,manageDevices:!0,killAny:!0,viewAllSessions:!0,viewUsage:!0,share:!0,runFlows:!0},Or={terminal:!1,configWrite:!1,hostFiles:!1,manageUsers:!1,manageWorkspaces:!1,manageDevices:!1,killAny:!1,viewAllSessions:!1,viewUsage:!1,share:!1,runFlows:!1};let t1=ka;const fc=new Set;function go(n){t1=(n==null?void 0:n.capabilities)??ka;for(const e of fc)e()}function lt(n){return t1[n]}function i4(n){return fc.add(n),()=>fc.delete(n)}function En(n){const e=B.c(3);let t,s;return e[0]!==n?(t=()=>lt(n),s=()=>lt(n),e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]),y.useSyncExternalStore(i4,t,s)}function a4(n){const e=n.files;return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function l4(n,e,t){const s=En("hostFiles"),[o,i]=y.useState([]),[a,l]=y.useState(!1);return y.useEffect(()=>{if(!s||!t||!n){i([]),l(!1);return}const c=new AbortController,d=window.setTimeout(async()=>{l(!0);try{const u=await ve(`/api/project-files?cwd=${encodeURIComponent(n)}&q=${encodeURIComponent(e)}&limit=30`,{signal:c.signal});if(!u.ok)throw new Error(`Request failed (${u.status})`);const f=await u.json();c.signal.aborted||i(a4(f))}catch{c.signal.aborted||i([])}finally{c.signal.aborted||l(!1)}},120);return()=>{window.clearTimeout(d),c.abort()}},[s,n,t,e]),{files:o,loading:a}}const mc="cogpit-share-revoked";function c4(){window.dispatchEvent(new Event(mc))}async function n1(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&&c4(),s}function Dr(n,e){return n1(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e??{})})}async function d4(){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 u4(n,e){return Dr("/api/share/send-message",e!=null&&e.length?{message:n,images:e}:{message:n})}function f4(){return Dr("/api/share/interrupt")}function m4(){return Dr("/api/share/stop")}async function p4(n,e){return(await Dr("/api/share/permission",{requestId:n,behavior:e})).ok}async function h4(n,e){try{const t=await Dr("/api/share/answer",{toolUseId:n,answers:e});return{ok:t.ok,gone:t.status===404}}catch{return{ok:!1,gone:!1}}}async function g4(){try{const n=await n1("/api/share/pending");if(!n.ok)return null;const e=await n.json();return Array.isArray(e.permissions)?e.permissions:[]}catch{return null}}const x4=/^\/shared\/([^/]+)\/?$/;function s1(n){const e=x4.exec(n);if(!e)return null;try{return decodeURIComponent(e[1])||null}catch{return null}}function Ca(n){return s1(n)!==null}function b4(n){return`/shared/${encodeURIComponent(n)}`}function HL(n){return[...n].join(", ")}async function ud(n,e,t){if(Ca(window.location.pathname))return h4(e,t);try{const s=await ve("/api/ask-user-answer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:n,toolUseId:e,answers:t})});return{ok:s.ok,gone:s.status===404}}catch{return{ok:!1,gone:!1}}}async function v4(n,e,t){try{return(await ve(`/api/permissions/${encodeURIComponent(n)}/plan`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:e,...t})})).ok}catch{return!1}}function _a(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("textarea",{"data-slot":"textarea",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function pi(n,e){if(!n)return!1;const t=n.offsetHeight;n.style.transition="none",n.style.height="auto";const s=Math.min(n.scrollHeight,200);let o;if(e){const a=n.style.width;n.style.width=`${Math.max(100,n.offsetWidth-140)}px`,o=n.scrollHeight>48,n.style.width=a}else o=s>44;return t!==s&&(n.style.height=t+"px",n.offsetHeight,n.style.transition="height 150ms ease"),n.style.height=s+"px",o}function y4(n,e,t,s,o,i){return s?"Resolve approval to continue...":n?"Provide feedback to request changes...":e?"Type a custom response...":i?o?"Steer…":"Message…":o?"Steer the active turn… (Enter to send)":t?"Message... (Enter to send)":"Send a message... (Enter to send)"}function w4(n,e,t){return t?"border-warning/40 focus-within:border-warning/60 focus-within:ring-warning/15":n||e?"border-info/40 focus-within:border-info/60 focus-within:ring-info/15":"border-input focus-within:border-ring focus-within:ring-ring/20"}const pc=y.memo(y.forwardRef(function({allowImages:e=!0,agentKind:t,projectCwd:s,leadingAccessory:o,compact:i=!1},a){var Be;const l=En("hostFiles"),{session:c,isLive:d,actions:{handleEditConfig:u},pendingInteraction:f,permissionRequests:m,permissionResponding:p,respondPermission:h,respondAllPermissions:g,slashSuggestions:x,slashSuggestionsLoading:b,turnError:w,promptSuggestion:v}=it(),{chat:{status:S,error:j,isConnected:k,sendMessage:C,interrupt:N}}=$r(),_=k||d,[P,A]=y.useState(""),[T,E]=y.useState(!1),[R,$]=y.useState(!1),[I,M]=y.useState(null),D=y.useRef(null),O=y.useRef(null),L=y.useRef(!1),F=y.useRef(""),z=y.useRef(null);y.useEffect(()=>{F.current=P},[P]);const W=y.useCallback(oe=>{L.current=oe,E(oe)},[]),{images:U,isDragOver:H,imageError:K,hasUnsupportedAttachments:V,dismissImageError:Y,removeImage:G,clearImages:J,handleDragOver:Q,handleDragLeave:X,handleDrop:Z,handlePaste:te}=GS(e),[ne,re]=y.useState(0),[ie,ae]=y.useState(0),[se,ue]=y.useState(!1),le=P.startsWith("/")&&!P.includes(" "),de=le?P.slice(1):"",pe=y.useMemo(()=>{if(!le)return[];const oe=de.toLowerCase(),ge=x.filter(He=>oe?He.name.toLowerCase().includes(oe)||He.description.toLowerCase().includes(oe):!0),Ee=ge.filter(He=>He.type==="command"),$e=ge.filter(He=>He.type==="skill");return[...Ee,...$e]},[le,de,x]),he=y.useMemo(()=>o4(P),[P]),ce=!!(l&&he&&s&&!se),ye=l4(s,(he==null?void 0:he.query)??"",ce);y.useEffect(()=>{re(0)},[de]),y.useEffect(()=>{ae(0)},[he==null?void 0:he.query]);const xe=Lg(k),me=(f==null?void 0:f.type)==="plan"?f.requestId??null:null;y.useEffect(()=>{O.current=me,D.current=null,$(!1),M(null)},[me]);const je=y.useCallback(async oe=>{const ge=f;if(!(c!=null&&c.sessionId)||(ge==null?void 0:ge.type)!=="question")return;const Ee=ge.questions[0];if(!Ee||!oe.trim())return;(await ud(c.sessionId,ge.toolUseId,{[Ee.question]:oe})).ok||C(oe)},[f,c==null?void 0:c.sessionId,C]),Se=y.useCallback(async(oe,ge,Ee)=>{const $e=f;if(($e==null?void 0:$e.type)==="plan"&&$e.provider==="copilot"&&$e.requestId&&(c!=null&&c.sessionId)){const He=$e.requestId;if(D.current)return!1;D.current=He,$(!0),M(null);try{const Ke=await v4(c.sessionId,He,{approved:oe,...ge?{selectedAction:ge}:{},...Ee?{feedback:Ee}:{}});return!Ke&&O.current===He&&M("Couldn't send the plan response. Try again."),Ke}finally{D.current===He&&(D.current=null,$(!1))}}return C(oe?"yes":Ee||"no"),!0},[f,c==null?void 0:c.sessionId,C]),Pe=y.useCallback(()=>{requestAnimationFrame(()=>{const oe=z.current;oe&&(oe.focus(),oe.selectionStart=oe.selectionEnd=oe.value.length,W(pi(oe,L.current)))})},[W]),Re=y.useCallback(oe=>{A(`/${oe.name} `),re(0),Pe()},[Pe]),Ie=y.useCallback(oe=>{A(oe),Pe()},[Pe]),De=y.useCallback(oe=>{if(!he)return;const ge=r4(P,he,oe);A(ge),ue(!0),ae(0),requestAnimationFrame(()=>{const Ee=z.current;Ee&&(Ee.focus(),Ee.selectionStart=Ee.selectionEnd=Ee.value.length,W(pi(Ee,L.current)))})},[he,P,W]),Le=y.useCallback(async()=>{const oe=P.trim();if(!oe&&U.length===0||!e&&U.length>0)return;if((f==null?void 0:f.type)==="question"){je(oe),A(""),W(!1),z.current&&(z.current.style.height="auto");return}if((f==null?void 0:f.type)==="plan"&&f.provider==="copilot"){if(!oe||!await Se(!1,void 0,oe))return;A(""),W(!1),z.current&&(z.current.style.height="auto");return}const ge=e&&U.length>0?U.map(Ee=>({data:Ee.data,mediaType:Ee.mediaType})):void 0;C(oe,ge),A(""),J(),W(!1),z.current&&(z.current.style.height="auto")},[P,U,e,C,J,W,f,je,Se]),ze=y.useCallback(oe=>{if(ce&&oe.key==="Escape"){oe.preventDefault(),ue(!0);return}if(ce&&ye.files.length>0){if(oe.key==="ArrowDown"){oe.preventDefault(),ae(ge=>ge<ye.files.length-1?ge+1:0);return}if(oe.key==="ArrowUp"){oe.preventDefault(),ae(ge=>ge>0?ge-1:ye.files.length-1);return}if(oe.key==="Tab"||oe.key==="Enter"&&!oe.shiftKey){oe.preventDefault();const ge=ye.files[ie];ge&&De(ge);return}}if(le&&pe.length>0){if(oe.key==="ArrowDown"){oe.preventDefault(),re(ge=>ge<pe.length-1?ge+1:0);return}if(oe.key==="ArrowUp"){oe.preventDefault(),re(ge=>ge>0?ge-1:pe.length-1);return}if(oe.key==="Tab"||oe.key==="Enter"&&!oe.shiftKey){oe.preventDefault();const ge=pe[ne];ge&&Re(ge);return}if(oe.key==="Escape"){oe.preventDefault(),A("");return}}if(oe.key==="Escape"&&_&&N){oe.preventDefault(),N();return}oe.key==="Enter"&&!oe.shiftKey&&(oe.preventDefault(),Le())},[Le,_,N,ce,ye.files,ie,De,le,pe,ne,Re]),Te=y.useCallback(oe=>{A(oe.target.value),ue(!1),W(pi(oe.target,L.current))},[W]);y.useImperativeHandle(a,()=>({focus:()=>{var oe;return(oe=z.current)==null?void 0:oe.focus()},getText:()=>F.current,setText:oe=>{A(oe),ue(!1),requestAnimationFrame(()=>W(pi(z.current,L.current)))}}),[W]);const Ce=(f==null?void 0:f.type)==="plan",We=(f==null?void 0:f.type)==="question",Fe=m.length>0,Ne=(P.trim().length>0||U.length>0)&&!V,fe=qt(t??Xs).midTurnSteering&&_,Oe=ce?"file-suggestions":le?"slash-suggestions":void 0,Ae=ce&&ye.files[ie]?`file-suggestion-${ie}`:le&&pe[ne]?`slash-suggestion-${ne}`:void 0;return r.jsxs("div",{className:q("relative bg-background pb-0",i?"px-2 pt-2":"px-3 pt-2",H&&"ring-2 ring-info/40 ring-inset"),onDragOver:Q,onDragLeave:X,onDrop:Z,children:[H&&r.jsx("div",{className:"motion-enter pointer-events-none absolute inset-0 flex items-center justify-center rounded-lg border-2 border-dashed border-info/40 bg-info/10",children:r.jsx("span",{className:"text-sm font-medium text-info",children:"Drop images here"})}),le&&r.jsx(AS,{suggestions:pe,filter:de,loading:b,selectedIndex:ne,onSelect:Re,onHover:re,onEdit:u}),ce&&r.jsx(MS,{files:ye.files,query:(he==null?void 0:he.query)??"",loading:ye.loading,selectedIndex:ie,onSelect:De,onHover:ae}),r.jsxs("div",{children:[Ce&&r.jsx(zS,{allowedPrompts:f.allowedPrompts,summary:f.summary,planContent:f.planContent,actions:f.actions,recommendedAction:f.recommendedAction,responding:R,responseError:I,onApprove:oe=>{Se(!0,oe)},onReject:()=>{Se(!1)}}),r.jsx(s4,{suggestion:v,onAccept:Ie}),U.length>0&&r.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:U.map((oe,ge)=>r.jsxs("div",{className:"motion-list-item relative group/thumb",children:[r.jsx("img",{src:oe.preview,alt:`Upload ${ge+1}`,className:"h-16 w-auto rounded-md border bg-muted object-contain"}),r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>G(ge),className:"absolute -right-1.5 -top-1.5 size-5 rounded-full border bg-background p-0 text-muted-foreground opacity-100 hover:bg-destructive hover:text-destructive-foreground sm:opacity-0 sm:group-hover/thumb:opacity-100 sm:focus-visible:opacity-100","aria-label":`Remove image ${ge+1}`,children:r.jsx(rt,{className:"size-3","data-icon":"icon"})})]},oe.id))}),K&&r.jsxs("div",{role:"status","aria-live":"polite",className:"motion-enter mb-2 flex items-center gap-2 text-xs text-warning",children:[r.jsx("span",{className:"flex-1",children:K}),!V&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:Y,className:"text-muted-foreground","aria-label":"Dismiss image notice",children:r.jsx(rt,{"data-icon":"icon"})})]}),r.jsxs("div",{className:q("relative overflow-hidden rounded-xl border bg-prompt-surface shadow-xs",w4(Ce,We,Fe),"focus-within:ring-3"),children:[Fe&&r.jsx(HS,{requests:m,responding:p,onRespond:h,onRespondAll:g},(Be=m[0])==null?void 0:Be.requestId),r.jsxs("div",{className:q("grid min-w-0 items-end",T?"grid-cols-[1fr_auto]":"grid-cols-[auto_minmax(0,1fr)_auto]"),children:[o&&r.jsx("div",{className:q("flex shrink-0 items-center",T?"col-start-1 row-start-2 pl-0.5 pb-0.5":"col-start-1 row-start-1"),children:o}),r.jsx(_a,{ref:z,value:P,onChange:Te,onKeyDown:ze,onPaste:te,onFocus:()=>{setTimeout(()=>{var oe;return(oe=z.current)==null?void 0:oe.scrollIntoView({behavior:"smooth",block:"center"})},300)},placeholder:y4(Ce,We,k,Fe,fe,i),"aria-label":"Message",role:"combobox","aria-autocomplete":"list","aria-expanded":!!Oe,"aria-controls":Oe,"aria-activedescendant":Ae,rows:1,className:q("min-h-0 w-full resize-none rounded-none border-0 bg-transparent text-foreground shadow-none placeholder:text-muted-foreground focus-visible:border-transparent focus-visible:ring-0 dark:bg-transparent",T?q("col-span-2 row-start-1",i?"py-2.5 pr-3":"py-3 pr-4"):q("col-start-2 row-start-1",i?"py-2 pr-1":"py-2.5 pr-2"),i?"pl-2 text-sm":"pl-4 text-sm")}),r.jsxs("div",{className:q("flex shrink-0 items-center justify-end",T?"col-start-2 row-start-2 px-1.5 pb-1.5":"col-start-3 row-start-1 pr-1.5 pb-1.5"),children:[r.jsx(t4,{isPlanApproval:Ce,isUserQuestion:We,elapsedSec:xe}),r.jsx(n4,{hasContent:Ne,onSubmit:Le,submitLabel:fe?"Steer active turn":"Send message"})]})]})]}),S==="error"&&j&&r.jsx(em,{error:j},j),w&&r.jsx(em,{error:w},w)]})]})}));function j4(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)?n:null}function S4(n){for(let e=n.length-1;e>=0;e-=1){const t=n[e];if(t.type!=="attachment")continue;const s=j4(t.attachment);if((s==null?void 0:s.type)!=="goal_status")continue;const o=typeof s.condition=="string"?s.condition:"",i=s.met===!0,a=s.failed===!0;return s.sentinel===!0&&i||!o?null:{condition:o,status:a?"failed":i?"achieved":"active",reason:typeof s.reason=="string"?s.reason:void 0,iterations:typeof s.iterations=="number"?s.iterations:0,durationMs:typeof s.durationMs=="number"?s.durationMs:0,tokens:typeof s.tokens=="number"?s.tokens:0}}return null}function hi(n){return`/api/codex/goals/${encodeURIComponent(n)}`}function Ht(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(py,{"data-slot":"input",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Lr(n){const e=B.c(13);let t,s,o,i;e[0]!==n?({className:s,children:t,value:i,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);let a;e[5]!==s?(a=q("flex flex-wrap gap-3",s),e[5]=s,e[6]=a):a=e[6];let l;e[7]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(N4,{children:r.jsx(k4,{})}),e[7]=l):l=e[7];let c;return e[8]!==t||e[9]!==o||e[10]!==a||e[11]!==i?(c=r.jsxs(hy,{value:i,"data-slot":"progress",className:a,...o,children:[t,l]}),e[8]=t,e[9]=o,e[10]=a,e[11]=i,e[12]=c):c=e[12],c}function N4(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("relative flex h-1 w-full items-center overflow-x-hidden rounded-full bg-muted",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(gy,{className:o,"data-slot":"progress-track",...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function k4(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("h-full bg-primary transition-[width] duration-150 ease-out motion-reduce:transition-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(xy,{"data-slot":"progress-indicator",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function o1(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("text-sm font-medium",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(by,{className:o,"data-slot":"progress-label",...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function r1(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("ml-auto text-sm text-muted-foreground tabular-nums",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(vy,{className:o,"data-slot":"progress-value",...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const C4={section:null,canCreate:!1,beginEditing:()=>{}},fd=y.createContext(C4);function i1(){return y.useContext(fd)}const a1="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-1",l1="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-2";function _4(n){return n==="usageLimited"?"Usage limited":n==="budgetLimited"?"Budget limited":n.charAt(0).toUpperCase()+n.slice(1)}function T4(n){return n==="complete"?"secondary":n==="blocked"||n.endsWith("Limited")?"destructive":n==="paused"?"outline":"default"}function E4({agentKind:n,threadId:e,children:t}){const s=ja(n),[o,i]=y.useState(null),[a,l]=y.useState(!0),[c,d]=y.useState(!1),[u,f]=y.useState(""),[m,p]=y.useState(""),[h,g]=y.useState(!1),[x,b]=y.useState(null),w=y.useCallback(async P=>{try{const A=await ve(hi(e),{signal:P});if(A.status===404||A.status===501){l(!1);return}if(!A.ok)return;const T=await A.json();i(T.goal),l(!0)}catch{}},[e]);y.useEffect(()=>{const P=new AbortController;w(P.signal);const A=a?setInterval(()=>void w(),1e4):void 0;return()=>{P.abort(),A!==void 0&&clearInterval(A)}},[w,a]);const v=y.useCallback(()=>{var P;f((o==null?void 0:o.objective)??""),p(((P=o==null?void 0:o.tokenBudget)==null?void 0:P.toString())??""),b(null),d(!0)},[o]),S=async()=>{const P=u.trim();if(!P)return;const A=m.trim()?Number(m):null;if(A!==null&&(!Number.isSafeInteger(A)||A<=0)){b("Token budget must be a positive whole number");return}g(!0),b(null);try{const T=await ve(hi(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({objective:P,status:(o==null?void 0:o.status)==="complete"?"active":(o==null?void 0:o.status)??"active",tokenBudget:A})}),E=await T.json();if(!T.ok)throw new Error(E.error||"Could not save goal");i(E.goal),d(!1)}catch(T){b(T instanceof Error?T.message:"Could not save goal")}finally{g(!1)}},j=async P=>{if(o){g(!0);try{const A=await ve(hi(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:P})});A.ok&&i((await A.json()).goal)}finally{g(!1)}}},k=async()=>{g(!0);try{(await ve(hi(e),{method:"DELETE"})).ok&&(i(null),d(!1))}finally{g(!1)}},C=o!=null&&o.tokenBudget?Math.min(100,o.tokensUsed/o.tokenBudget*100):null;let N=null;if(a&&c)N=r.jsxs("form",{className:l1,onSubmit:P=>{P.preventDefault(),S()},children:[r.jsxs("div",{className:"mb-2 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[r.jsx(ir,{className:"size-3.5","data-icon":"inline-start"}),o?"Edit long-running goal":"Set a long-running goal"]}),r.jsxs(Ao,{className:"gap-2",children:[r.jsxs(wt,{children:[r.jsx(jt,{className:"sr-only",htmlFor:"goal-objective",children:"Goal objective"}),r.jsx(_a,{id:"goal-objective",value:u,onChange:P=>f(P.target.value),placeholder:`What should ${s} keep working toward?`,rows:2,autoFocus:!0})]}),r.jsxs(wt,{orientation:"horizontal","data-invalid":!!x,children:[r.jsx(jt,{className:"text-xs text-muted-foreground",htmlFor:"goal-budget",children:"Token budget"}),r.jsx(Ht,{id:"goal-budget",type:"number",min:1,step:1,value:m,onChange:P=>p(P.target.value),placeholder:"Optional",className:"ml-auto h-8 w-28","aria-invalid":!!x})]})]}),r.jsx(bs,{className:"mt-1.5",children:x}),r.jsxs("div",{className:"mt-2 flex items-center justify-end gap-1",children:[r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>d(!1),children:[r.jsx(rt,{"data-icon":"inline-start"}),"Cancel"]}),r.jsxs(ee,{type:"submit",size:"xs",disabled:h||!u.trim(),children:[r.jsx(mt,{"data-icon":"inline-start"}),"Save goal"]})]})]});else if(a&&o){const P=o.status==="paused",A=o.status==="complete";N=r.jsxs("section",{className:a1,"aria-label":`${s} goal`,children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ir,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",title:o.objective,children:o.objective}),r.jsx(_e,{variant:T4(o.status),children:_4(o.status)}),r.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[ut(o.tokensUsed),o.tokenBudget?` / ${ut(o.tokenBudget)}`:""," · ",Math.max(0,Math.round(o.timeUsedSeconds/60)),"m"]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[P&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void j("active"),disabled:h,"aria-label":"Resume goal",children:r.jsx(_r,{"data-icon":"icon"})}),!P&&!A&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void j("paused"),disabled:h,"aria-label":"Pause goal",children:r.jsx(yy,{"data-icon":"icon"})}),!A&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void j("complete"),disabled:h,"aria-label":"Mark goal complete",children:r.jsx(mt,{"data-icon":"icon"})}),r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:v,"aria-label":"Edit goal",children:r.jsx(Vs,{"data-icon":"icon"})}),r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void k(),disabled:h,className:"text-destructive","aria-label":"Clear goal",children:r.jsx(ca,{"data-icon":"icon"})})]})]}),C!==null&&r.jsx(Lr,{className:"mt-1 mb-0.5",value:C,"aria-label":`${C.toFixed(0)}% of goal token budget used`})]})}const _=y.useMemo(()=>({section:N,canCreate:a&&!o&&!c,beginEditing:v}),[N,a,o,c,v]);return r.jsx(fd.Provider,{value:_,children:t})}function P4(n){switch(n){case"active":return"Goal active";case"achieved":return"Achieved";default:return"Needs attention"}}function A4(n){switch(n){case"failed":return"destructive";case"achieved":return"secondary";default:return"outline"}}function R4(n){const e=B.c(84),{agentKind:t,session:s,onSendCommand:o,children:i}=n;let a;e[0]!==t?(a=ja(t),e[0]=t,e[1]=a):a=e[1];const l=a;let c;e[2]!==s.rawMessages?(c=S4(s.rawMessages),e[2]=s.rawMessages,e[3]=c):c=e[3];const d=c,[u,f]=y.useState(),[m,p]=y.useState(!1),[h,g]=y.useState(""),[x,b]=y.useState(null),w=d?`${d.status}\0${d.condition}`:"",[v,S]=y.useState(w);v!==w&&(S(w),f(void 0));const j=u!==void 0?u:d;let k;e[4]!==(j==null?void 0:j.condition)?(k=()=>{g((j==null?void 0:j.condition)??""),b(null),p(!0)},e[4]=j==null?void 0:j.condition,e[5]=k):k=e[5];const C=k;let N;e[6]!==h||e[7]!==o?(N=()=>{const M=h.trim();if(M){if(M.length>4e3){b("Goal conditions can be at most 4,000 characters");return}f({condition:M,status:"active",iterations:0,durationMs:0,tokens:0}),p(!1),o(`/goal ${M}`)}},e[6]=h,e[7]=o,e[8]=N):N=e[8];const _=N;let P;e[9]!==o?(P=()=>{f(null),p(!1),o("/goal clear")},e[9]=o,e[10]=P):P=e[10];const A=P;let T;if(e[11]!==l||e[12]!==C||e[13]!==A||e[14]!==h||e[15]!==m||e[16]!==x||e[17]!==j||e[18]!==_){if(T=null,m){let M;e[20]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(ir,{className:"size-3.5","data-icon":"inline-start"}),e[20]=M):M=e[20];const D=j?"Replace goal":"Set a long-running goal";let O;e[21]!==D?(O=r.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[M,D]}),e[21]=D,e[22]=O):O=e[22];const L=!!x;let F;e[23]===Symbol.for("react.memo_cache_sentinel")?(F=r.jsx(jt,{className:"sr-only",htmlFor:"goal-condition",children:"Goal condition"}),e[23]=F):F=e[23];let z;e[24]===Symbol.for("react.memo_cache_sentinel")?(z=Z=>g(Z.target.value),e[24]=z):z=e[24];const W=`A measurable condition ${l} should keep working toward…`,U=!!x;let H;e[25]!==h||e[26]!==W||e[27]!==U?(H=r.jsx(_a,{id:"goal-condition",value:h,onChange:z,placeholder:W,rows:2,maxLength:4e3,"aria-invalid":U,autoFocus:!0}),e[25]=h,e[26]=W,e[27]=U,e[28]=H):H=e[28];let K;e[29]!==x?(K=r.jsx(bs,{children:x}),e[29]=x,e[30]=K):K=e[30];let V;e[31]!==H||e[32]!==K||e[33]!==L?(V=r.jsxs(wt,{"data-invalid":L,children:[F,H,K]}),e[31]=H,e[32]=K,e[33]=L,e[34]=V):V=e[34];let Y;e[35]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>p(!1),children:[r.jsx(rt,{"data-icon":"inline-start"}),"Cancel"]}),e[35]=Y):Y=e[35];let G;e[36]!==h?(G=h.trim(),e[36]=h,e[37]=G):G=e[37];const J=!G;let Q;e[38]===Symbol.for("react.memo_cache_sentinel")?(Q=r.jsx(mt,{"data-icon":"inline-start"}),e[38]=Q):Q=e[38];let X;e[39]!==_||e[40]!==J?(X=r.jsxs("div",{className:"mt-2 flex items-center justify-end gap-1",children:[Y,r.jsxs(ee,{type:"button",size:"xs",onClick:_,disabled:J,children:[Q,"Start goal"]})]}),e[39]=_,e[40]=J,e[41]=X):X=e[41],T=r.jsxs("section",{className:l1,"aria-label":`${l} goal editor`,children:[O,V,X]})}else if(j){let M;e[42]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(ir,{className:"size-3.5 shrink-0 text-primary","data-icon":"inline-start"}),e[42]=M):M=e[42];let D;e[43]!==j.condition?(D=r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",title:j.condition,children:j.condition}),e[43]=j.condition,e[44]=D):D=e[44];let O;e[45]!==j.status?(O=A4(j.status),e[45]=j.status,e[46]=O):O=e[46];let L;e[47]!==j.status?(L=P4(j.status),e[47]=j.status,e[48]=L):L=e[48];let F;e[49]!==O||e[50]!==L?(F=r.jsx(_e,{variant:O,children:L}),e[49]=O,e[50]=L,e[51]=F):F=e[51];const z=j.iterations,W=j.iterations===1?"":"s";let U;e[52]!==j.tokens?(U=ut(j.tokens),e[52]=j.tokens,e[53]=U):U=e[53];let H;e[54]!==j.durationMs?(H=Math.round(j.durationMs/6e4),e[54]=j.durationMs,e[55]=H):H=e[55];const K=Math.max(0,H);let V;e[56]!==j.iterations||e[57]!==W||e[58]!==U||e[59]!==K?(V=r.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[z," turn",W," · ",U," · ",K,"m"]}),e[56]=j.iterations,e[57]=W,e[58]=U,e[59]=K,e[60]=V):V=e[60];let Y;e[61]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx(Vs,{"data-icon":"icon"}),e[61]=Y):Y=e[61];let G;e[62]!==C?(G=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:C,"aria-label":"Replace goal",children:Y}),e[62]=C,e[63]=G):G=e[63];let J;e[64]===Symbol.for("react.memo_cache_sentinel")?(J=r.jsx(ca,{"data-icon":"icon"}),e[64]=J):J=e[64];let Q;e[65]!==A?(Q=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:A,"aria-label":"Clear goal",children:J}),e[65]=A,e[66]=Q):Q=e[66];let X;e[67]!==G||e[68]!==Q?(X=r.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[G,Q]}),e[67]=G,e[68]=Q,e[69]=X):X=e[69];let Z;e[70]!==F||e[71]!==V||e[72]!==X||e[73]!==D?(Z=r.jsxs("div",{className:"flex items-center gap-2",children:[M,D,F,V,X]}),e[70]=F,e[71]=V,e[72]=X,e[73]=D,e[74]=Z):Z=e[74];let te;e[75]!==j.reason?(te=j.reason&&r.jsx("p",{className:"line-clamp-2 pb-0.5 pl-5 text-xs text-muted-foreground",children:j.reason}),e[75]=j.reason,e[76]=te):te=e[76],T=r.jsxs("section",{className:a1,"aria-label":`${l} goal`,children:[Z,te]})}e[11]=l,e[12]=C,e[13]=A,e[14]=h,e[15]=m,e[16]=x,e[17]=j,e[18]=_,e[19]=T}else T=e[19];const E=!j&&!m;let R;e[77]!==C||e[78]!==T||e[79]!==E?(R={section:T,canCreate:E,beginEditing:C},e[77]=C,e[78]=T,e[79]=E,e[80]=R):R=e[80];const $=R;let I;return e[81]!==i||e[82]!==$?(I=r.jsx(fd.Provider,{value:$,children:i}),e[81]=i,e[82]=$,e[83]=I):I=e[83],I}function I4(n){const e=B.c(9),{agentKind:t,session:s,onSendCommand:o,children:i}=n,a=qt(t).goals;if(a==="thread-api"){let l;return e[0]!==t||e[1]!==i||e[2]!==s.sessionId?(l=r.jsx(E4,{agentKind:t,threadId:s.sessionId,children:i}),e[0]=t,e[1]=i,e[2]=s.sessionId,e[3]=l):l=e[3],l}if(a==="transcript"){let l;return e[4]!==t||e[5]!==i||e[6]!==o||e[7]!==s?(l=r.jsx(R4,{agentKind:t,session:s,onSendCommand:o,children:i}),e[4]=t,e[5]=i,e[6]=o,e[7]=s,e[8]=l):l=e[8],l}return i}function c1(){return i1().section}function d1(){const n=B.c(3),{canCreate:e,beginEditing:t}=i1();if(!e)return null;let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(ir,{"data-icon":"inline-start"}),n[0]=s):s=n[0];let o;return n[1]!==t?(o=r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:t,title:"Set a long-running goal for this session",children:[s,"Set goal"]}),n[1]=t,n[2]=o):o=n[2],o}function $4(){const n=B.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs(r.Fragment,{children:[r.jsx(c1,{}),r.jsx(d1,{})]}),n[0]=e):e=n[0],e}const M4=/\x1b\].*?(?:\x07|\x1b\\)/g,O4=/\x1b\[[0-9;]*[A-Za-z]/g,D4=/\x1b[()][AB012]/g,L4=/\[2K\[1G/g;function u1(n){return n.replace(M4,"").replace(O4,"").replace(D4,"").replace(L4,`
5
- `).replace(/\r/g,"")}function is(n){const e=B.c(14);let t,s,o;e[0]!==n?({className:s,children:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==s?(i=q("relative overflow-hidden",s),e[4]=s,e[5]=i):i=e[5];let a;e[6]!==t?(a=r.jsx(jy,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:t}),e[6]=t,e[7]=a):a=e[7];let l,c;e[8]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(z4,{}),c=r.jsx(Sy,{}),e[8]=l,e[9]=c):(l=e[8],c=e[9]);let d;return e[10]!==o||e[11]!==i||e[12]!==a?(d=r.jsxs(wy,{"data-slot":"scroll-area",className:i,...o,children:[a,l,c]}),e[10]=o,e[11]=i,e[12]=a,e[13]=d):d=e[13],d}function z4(n){const e=B.c(11);let t,s,o;e[0]!==n?({className:t,orientation:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"vertical":o;let a;e[4]!==t?(a=q("flex touch-none p-px transition-colors select-none data-[orientation=horizontal]:h-2.5 data-[orientation=horizontal]:flex-col data-[orientation=horizontal]:border-t data-[orientation=horizontal]:border-t-transparent data-[orientation=vertical]:h-full data-[orientation=vertical]:w-2.5 data-[orientation=vertical]:border-l data-[orientation=vertical]:border-l-transparent",t),e[4]=t,e[5]=a):a=e[5];let l;e[6]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(ky,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"}),e[6]=l):l=e[6];let c;return e[7]!==i||e[8]!==s||e[9]!==a?(c=r.jsx(Ny,{"data-slot":"scroll-area-scrollbar","data-orientation":i,orientation:i,className:a,...s,children:l}),e[7]=i,e[8]=s,e[9]=a,e[10]=c):c=e[10],c}function f1(n){const e=B.c(10);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("size-5",t),e[3]=t,e[4]=o):o=e[4];let i,a;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.2"}),a=r.jsx("path",{className:"status-icon-spin",d:"M12 2A10 10 0 0 1 22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),e[5]=i,e[6]=a):(i=e[5],a=e[6]);let l;return e[7]!==s||e[8]!==o?(l=r.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",className:o,...s,children:[i,a]}),e[7]=s,e[8]=o,e[9]=l):l=e[9],l}function F4(n){const e=B.c(9);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("size-5",t),e[3]=t,e[4]=o):o=e[4];let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("path",{className:"status-icon-complete",d:"M20 6L9 17L4 12"}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:o,...s,children:i}),e[6]=s,e[7]=o,e[8]=a):a=e[8],a}function B4(n){const e=B.c(10);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("size-5",t),e[3]=t,e[4]=o):o=e[4];let i,a;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a=r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"}),e[5]=i,e[6]=a):(i=e[5],a=e[6]);let l;return e[7]!==s||e[8]!==o?(l=r.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:o,...s,children:[i,a]}),e[7]=s,e[8]=o,e[9]=l):l=e[9],l}function U4(n){const e=B.c(11);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("size-5",t),e[3]=t,e[4]=o):o=e[4];let i,a,l;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.1"}),a=r.jsx("path",{className:"status-icon-spin",d:"M12 2A10 10 0 0 1 22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),l=r.jsx("path",{className:"status-icon-spin",d:"M12 22A10 10 0 0 1 2 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),e[5]=i,e[6]=a,e[7]=l):(i=e[5],a=e[6],l=e[7]);let c;return e[8]!==s||e[9]!==o?(c=r.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",className:o,...s,children:[i,a,l]}),e[8]=s,e[9]=o,e[10]=c):c=e[10],c}function xt(n){const e=B.c(10);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o,i;if(e[3]!==t){const l=t==null?void 0:t.replace(/\banimate-spin\b/g,"").trim();o=f1,i=q(l),e[3]=t,e[4]=o,e[5]=i}else o=e[4],i=e[5];let a;return e[6]!==o||e[7]!==s||e[8]!==i?(a=r.jsx(o,{className:i,...s}),e[6]=o,e[7]=s,e[8]=i,e[9]=a):a=e[9],a}function W4(n){const e=En("hostFiles"),[t,s]=y.useState([]),[o,i]=y.useState(!1),a=y.useCallback(async()=>{if(!e||!n){s([]);return}i(!0);try{const l=await ve(`/api/scripts?dir=${encodeURIComponent(n)}`);if(l.ok){const c=await l.json();s(c)}}catch{}finally{i(!1)}},[e,n]);return y.useEffect(()=>{a()},[a]),{scripts:t,loading:o,refresh:a}}const tm=500,H4=5e3;function K4(n){const e=B.c(29),t=n===void 0?!0:n,[s,o]=y.useState("disconnected");let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=[],e[0]=i):i=e[0];const[a,l]=y.useState(i),c=y.useRef(null);let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=new Map,e[1]=d):d=e[1];const u=y.useRef(d),f=y.useRef(tm),m=y.useRef(null),p=y.useRef(!1),h=y.useRef(q4);let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=L=>{var W;const F=L.type,z=L.id;if(F==="sessions"){l(L.sessions??[]);return}z&&((W=u.current.get(z))==null||W(F,L))},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 L=function(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}${Sg()}/__pty`},F=function(){if(p.current||c.current&&c.current.readyState!==WebSocket.CLOSED)return;o("connecting");const W=new WebSocket(L());c.current=W,W.onopen=()=>{if(p.current){W.close();return}f.current=tm,o("connected"),W.send(JSON.stringify({type:"list"}))},W.onmessage=U=>{try{const H=JSON.parse(U.data);x(H)}catch{}},W.onclose=()=>{if(p.current)return;o("disconnected"),c.current=null;const U=f.current;f.current=Math.min(U*2,H4),m.current=setTimeout(()=>h.current(),U)}};return h.current=F,F(),()=>{p.current=!0,m.current&&(clearTimeout(m.current),m.current=null),c.current&&(c.current.onclose=null,c.current.close(),c.current=null)}},w=[t,x],e[3]=t,e[4]=b,e[5]=w):(b=e[4],w=e[5]),y.useEffect(b,w);let v;e[6]!==t?(v=L=>{if(!t)return;const F=c.current;F&&F.readyState===WebSocket.OPEN&&F.send(JSON.stringify(L))},e[6]=t,e[7]=v):v=e[7];const S=v;let j;e[8]===Symbol.for("react.memo_cache_sentinel")?(j=(L,F)=>{u.current.set(L,F)},e[8]=j):j=e[8];const k=j;let C;e[9]===Symbol.for("react.memo_cache_sentinel")?(C=L=>{u.current.delete(L)},e[9]=C):C=e[9];const N=C;let _;e[10]!==S?(_=L=>{const F=L===void 0?{}:L,z=`pty_${crypto.randomUUID().slice(0,8)}`;return S({type:"spawn",id:z,name:F.name??"Terminal",cwd:F.cwd,metadata:{type:"terminal"}}),z},e[10]=S,e[11]=_):_=e[11];const P=_;let A;e[12]!==S?(A=L=>{const F=`script_${crypto.randomUUID().slice(0,8)}`;return S({type:"spawn",id:F,name:L.name,cwd:L.cwd,args:["run",L.scriptName],command:"bun",metadata:{type:"script",source:L.source,scriptName:L.scriptName}}),F},e[12]=S,e[13]=A):A=e[13];const T=A;let E;e[14]!==S?(E=L=>{S({type:"kill",id:L})},e[14]=S,e[15]=E):E=e[15];const R=E;let $;e[16]!==S?($=(L,F)=>{S({type:"input",id:L,data:F})},e[16]=S,e[17]=$):$=e[17];const I=$;let M;e[18]!==S?(M=(L,F,z)=>{S({type:"resize",id:L,cols:F,rows:z})},e[18]=S,e[19]=M):M=e[19];const D=M;let O;return e[20]!==R||e[21]!==D||e[22]!==S||e[23]!==a||e[24]!==T||e[25]!==P||e[26]!==s||e[27]!==I?(O={status:s,send:S,subscribe:k,unsubscribe:N,sessions:a,spawnTerminal:P,spawnScript:T,killSession:R,writeInput:I,resize:D},e[20]=R,e[21]=D,e[22]=S,e[23]=a,e[24]=T,e[25]=P,e[26]=s,e[27]=I,e[28]=O):O=e[28],O}function q4(){}const m1=y.createContext(null);function ml(n){const e=B.c(3),{children:t,enabled:s}=n,i=K4(s===void 0?!0:s);let a;return e[0]!==t||e[1]!==i?(a=r.jsx(m1.Provider,{value:i,children:t}),e[0]=t,e[1]=i,e[2]=a):a=e[2],a}function md(){const n=y.useContext(m1);if(!n)throw new Error("usePty must be used within a PtyProvider");return n}function V4(n){var u;const e=B.c(11),t=md();let s;if(e[0]!==t.sessions){s=new Map;for(const f of t.sessions)((u=f.metadata)==null?void 0:u.type)==="script"&&s.set(f.id,{id:f.id,name:f.name,cwd:f.cwd,status:f.status==="running"?"running":"stopped",source:f.metadata.source??"root/"});e[0]=t.sessions,e[1]=s}else s=e[1];const o=s;let i;e[2]!==n||e[3]!==t?(i=(f,m,p)=>{const h=t.spawnScript({name:f,cwd:m,source:p,scriptName:f}),g=p==="root/"?f:`${p.replace(/\/$/,"")}:${f}`;n==null||n({id:h,name:g,type:"script",status:"running",source:p})},e[2]=n,e[3]=t,e[4]=i):i=e[4];const a=i;let l;e[5]!==t?(l=f=>{t.killSession(f)},e[5]=t,e[6]=l):l=e[6];const c=l;let d;return e[7]!==a||e[8]!==o||e[9]!==c?(d={runningProcesses:o,runScript:a,stopScript:c},e[7]=a,e[8]=o,e[9]=c,e[10]=d):d=e[10],d}function G4(n){const e=B.c(14),{script:t,status:s,onRun:o,onStop:i}=n,a=s==="running";let l="bg-transparent";a?l="bg-primary":s==="errored"&&(l="bg-destructive");const c=a?i:o,d=a?`Stop ${t.name}`:`Run: ${t.command}`;let u;e[0]!==l?(u=q("size-1.5 shrink-0 rounded-full",l),e[0]=l,e[1]=u):u=e[1];let f;e[2]!==u?(f=r.jsx("span",{className:u}),e[2]=u,e[3]=f):f=e[3];let m;e[4]!==t.name?(m=r.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:t.name}),e[4]=t.name,e[5]=m):m=e[5];let p;e[6]!==a?(p=a?r.jsx(Xc,{"data-icon":"inline-end",className:"fill-current text-destructive"}):r.jsx(_r,{"data-icon":"inline-end",className:"opacity-0 text-muted-foreground transition-opacity group-hover:opacity-100"}),e[6]=a,e[7]=p):p=e[7];let h;return e[8]!==c||e[9]!==d||e[10]!==f||e[11]!==m||e[12]!==p?(h=r.jsxs(ee,{type:"button",variant:"ghost",size:"sm",className:"motion-list-item group w-full justify-start px-2",onClick:c,title:d,children:[f,m,p]}),e[8]=c,e[9]=d,e[10]=f,e[11]=m,e[12]=p,e[13]=h):h=e[13],h}const Y4=y.memo(function(e){const t=B.c(42),{projectDir:s,onProcessStarted:o}=e,[i,a]=y.useState(!1),[l,c]=y.useState("");let d;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=new Set,t[0]=d):d=t[0];const[u,f]=y.useState(d),{scripts:m,loading:p}=W4(s),{runningProcesses:h,runScript:g,stopScript:x}=V4(o);let b;if(t[1]!==m||t[2]!==l){const F=l.trim().toLowerCase(),z=F?m.filter(W=>W.name.toLowerCase().includes(F)||W.dirLabel.toLowerCase().includes(F)):m;b=new Map;for(const W of z){const U=b.get(W.dirLabel)??[];U.push(W),b.set(W.dirLabel,U)}t[1]=m,t[2]=l,t[3]=b}else b=t[3];const w=b;let v;if(t[4]!==h){v=new Map;for(const[F,z]of h)v.set(`${z.name}:${z.cwd}`,{id:F,status:z.status});t[4]=h,t[5]=v}else v=t[5];const S=v;if(!s||!p&&m.length===0)return null;let j;t[6]===Symbol.for("react.memo_cache_sentinel")?(j=function(z){f(W=>{const U=new Set(W);return U.has(z)?U.delete(z):U.add(z),U})},t[6]=j):j=t[6];const k=j;let C;t[7]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx("span",{className:"flex-1 text-xs font-medium text-muted-foreground",children:"Scripts"}),t[7]=C):C=t[7];let N;t[8]!==p?(N=p&&r.jsx(xt,{className:"size-3 text-muted-foreground","aria-label":"Loading scripts"}),t[8]=p,t[9]=N):N=t[9];const _=i?"Close script search":"Search scripts";let P,A;t[10]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{a(X4),c("")},A=r.jsx(gn,{}),t[10]=P,t[11]=A):(P=t[10],A=t[11]);let T;t[12]!==i||t[13]!==_?(T=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm","aria-label":_,"aria-expanded":i,onClick:P,children:A}),t[12]=i,t[13]=_,t[14]=T):T=t[14];let E;t[15]!==N||t[16]!==T?(E=r.jsxs("div",{className:"flex h-8 shrink-0 items-center gap-2 px-2",children:[C,N,T]}),t[15]=N,t[16]=T,t[17]=E):E=t[17];let R;t[18]!==i||t[19]!==l?(R=i&&r.jsx("div",{className:"motion-slide-down-in px-2 pb-2",children:r.jsx(Ht,{type:"search",value:l,onChange:F=>c(F.target.value),placeholder:"Filter scripts...","aria-label":"Filter scripts",className:"h-7",autoFocus:!0})}),t[18]=i,t[19]=l,t[20]=R):R=t[20];let $;t[21]!==u||t[22]!==w||t[23]!==g||t[24]!==S||t[25]!==l||t[26]!==x?($=[...w.entries()].map(F=>{const[z,W]=F,U=u.has(z)||!!l,H=W.filter(J4),K=W.filter(Q4),V=U?W:H.length>0?H:W.slice(0,1);return r.jsxs("div",{className:"flex flex-col gap-0.5 pb-1",children:[w.size>1&&r.jsx("div",{className:"truncate px-2 pt-1 text-xs text-muted-foreground",children:z}),V.map(Y=>{const G=S.get(`${Y.name}:${Y.dir}`);return r.jsx(G4,{script:Y,status:(G==null?void 0:G.status)??null,onRun:()=>g(Y.name,Y.dir,Y.dirLabel),onStop:()=>{G&&x(G.id)}},`${z}:${Y.name}`)}),!l&&K.length>0&&r.jsx(ee,{type:"button",variant:"link",size:"sm",className:"h-auto justify-start px-2 py-1",onClick:()=>k(z),children:U?"Show less":`Show ${K.length} more`})]},z)}),t[21]=u,t[22]=w,t[23]=g,t[24]=S,t[25]=l,t[26]=x,t[27]=$):$=t[27];let I;t[28]!==w.size||t[29]!==p||t[30]!==l?(I=!p&&w.size===0&&l&&r.jsx(ln,{className:"gap-1 p-3",children:r.jsxs(cn,{className:"gap-1",children:[r.jsx(dn,{children:"No matching scripts"}),r.jsx(vn,{children:"Try another name."})]})}),t[28]=w.size,t[29]=p,t[30]=l,t[31]=I):I=t[31];let M;t[32]!==$||t[33]!==I?(M=r.jsxs(is,{className:"min-h-0 flex-1 px-1 pb-1",children:[$,I]}),t[32]=$,t[33]=I,t[34]=M):M=t[34];let D;t[35]!==R||t[36]!==M||t[37]!==E?(D=r.jsxs("section",{className:"flex w-56 shrink-0 flex-col","aria-label":"Scripts",children:[E,R,M]}),t[35]=R,t[36]=M,t[37]=E,t[38]=D):D=t[38];let O;t[39]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsx(St,{orientation:"vertical"}),t[39]=O):O=t[39];let L;return t[40]!==D?(L=r.jsxs(r.Fragment,{children:[D,O]}),t[40]=D,t[41]=L):L=t[41],L});function X4(n){return!n}function J4(n){return n.isCommon}function Q4(n){return!n.isCommon}function pd(n){const e=B.c(10);let t,s,o;e[0]!==n?({className:t,orientation:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"horizontal":o;let a;e[4]!==t?(a=q("group/tabs relative flex gap-2 data-[orientation=horizontal]:flex-col","has-[>[data-slot=tabs-content]]:grid has-[>[data-slot=tabs-content]]:grid-cols-1 [&>[data-slot=tabs-list]]:col-start-1 [&>[data-slot=tabs-list]]:row-start-1 [&>[data-slot=tabs-content]]:col-start-1 [&>[data-slot=tabs-content]]:row-start-2","data-[orientation=vertical]:has-[>[data-slot=tabs-content]]:grid-cols-[auto_minmax(0,1fr)] data-[orientation=vertical]:[&>[data-slot=tabs-content]]:col-start-2 data-[orientation=vertical]:[&>[data-slot=tabs-content]]:row-start-1",t),e[4]=t,e[5]=a):a=e[5];let l;return e[6]!==i||e[7]!==s||e[8]!==a?(l=r.jsx(Ty,{"data-slot":"tabs","data-orientation":i,className:a,...s}),e[6]=i,e[7]=s,e[8]=a,e[9]=l):l=e[9],l}const Z4=es("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 hd(n){const e=B.c(17);let t,s,o,i;e[0]!==n?({className:s,children:t,variant:i,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);const a=i===void 0?"default":i;let l;e[5]!==s||e[6]!==a?(l=q(Z4({variant:a}),"relative isolate",s),e[5]=s,e[6]=a,e[7]=l):l=e[7];let c;e[8]===Symbol.for("react.memo_cache_sentinel")?(c=q("pointer-events-none absolute top-0 left-0 z-0 h-(--active-tab-height) w-(--active-tab-width) translate-x-(--active-tab-left) translate-y-(--active-tab-top) transition-[translate,width,height] duration-150 ease-out motion-reduce:transition-none after:absolute after:content-['']","data-[variant=default]:after:inset-0 data-[variant=default]:after:rounded-md data-[variant=default]:after:bg-background data-[variant=default]:after:shadow-sm","data-[variant=line]:after:bg-foreground data-[variant=line]:data-[orientation=horizontal]:after:inset-x-0 data-[variant=line]:data-[orientation=horizontal]:after:-bottom-[5px] data-[variant=line]:data-[orientation=horizontal]:after:h-0.5 data-[variant=line]:data-[orientation=vertical]:after:inset-y-0 data-[variant=line]:data-[orientation=vertical]:after:-right-1 data-[variant=line]:data-[orientation=vertical]:after:w-0.5"),e[8]=c):c=e[8];let d;e[9]!==a?(d=r.jsx(Py,{"data-slot":"tabs-indicator","data-variant":a,className:c}),e[9]=a,e[10]=d):d=e[10];let u;return e[11]!==t||e[12]!==o||e[13]!==l||e[14]!==d||e[15]!==a?(u=r.jsxs(_y,{"data-slot":"tabs-list","data-variant":a,className:l,...o,children:[t,d]}),e[11]=t,e[12]=o,e[13]=l,e[14]=d,e[15]=a,e[16]=u):u=e[16],u}function ms(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("relative z-10 inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 outline-none transition-[color,border-color,box-shadow,transform,scale] duration-100 ease-out group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground active:scale-[0.98] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-active:text-foreground dark:text-muted-foreground dark:hover:text-foreground dark:data-active:text-foreground motion-reduce:transition-none motion-reduce:active:scale-100 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Ey,{"data-slot":"tabs-trigger",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function ps(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("flex-1 text-sm outline-none transition-[opacity,translate] duration-150 ease-out motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none","motion-safe:data-starting-style:data-[activation-direction=left]:translate-x-[-0.25rem] motion-safe:data-starting-style:data-[activation-direction=right]:translate-x-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=left]:translate-x-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=right]:translate-x-[-0.25rem]","motion-safe:data-starting-style:data-[activation-direction=up]:translate-y-[-0.25rem] motion-safe:data-starting-style:data-[activation-direction=down]:translate-y-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=up]:translate-y-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=down]:translate-y-[-0.25rem]",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Cy,{"data-slot":"tabs-content",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const e5=y.lazy(()=>qe(()=>import("./TerminalOutput-T82q4Tf9.js"),__vite__mapDeps([0,1,2,3,4,5])).then(n=>({default:n.TerminalOutput})));function t5({process:n}){const[e,t]=y.useState(""),[s,o]=y.useState(!1),i=y.useRef(null);return y.useEffect(()=>{let a;if(n.type==="task"&&n.outputPath)a=Rr(`/api/task-output?path=${encodeURIComponent(n.outputPath)}`);else return;t(""),o(!1);const l=new EventSource(a);return l.onopen=()=>o(!0),l.onmessage=c=>{try{const d=JSON.parse(c.data);if(d.type==="output"&&d.text){const u=u1(d.text);u&&t(f=>{const m=f+u;return m.length>1e5?m.slice(-1e5):m})}}catch{}},l.onerror=()=>{},()=>l.close()},[n.id,n.type,n.outputPath]),y.useEffect(()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight)},[e]),r.jsx("pre",{ref:i,className:"flex-1 overflow-auto bg-background px-3 py-2 font-mono text-xs leading-relaxed text-foreground whitespace-pre-wrap break-words",children:e||r.jsx("span",{className:"text-muted-foreground",children:s?"Waiting for output...":"Connecting..."})})}function n5(n){const e=B.c(34),{process:t,isActive:s,onSelectActive:o,onClose:i,mobile:a}=n,l=t.source??t.name,c=t.id,d=t.name;let u;e[0]!==s||e[1]!==o?(u=()=>{s&&o()},e[0]=s,e[1]=o,e[2]=u):u=e[2];const f=a?"gap-1 px-1.5":"gap-1.5 px-2";let m;e[3]!==f?(m=q("h-6 min-w-0 justify-start py-0 text-xs",f),e[3]=f,e[4]=m):m=e[4];let p;e[5]!==t.status?(p=t.status==="running"&&r.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full bg-success"}),e[5]=t.status,e[6]=p):p=e[6];let h;e[7]!==t.status?(h=t.status==="errored"&&r.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full bg-destructive"}),e[7]=t.status,e[8]=h):h=e[8];let g;e[9]!==t.name?(g=r.jsx("span",{className:"truncate max-w-[100px]",children:t.name}),e[9]=t.name,e[10]=g):g=e[10];const x=a&&"hidden";let b;e[11]!==x?(b=q("px-1 py-0 font-normal",x),e[11]=x,e[12]=b):b=e[12];let w;e[13]!==t.type||e[14]!==b?(w=r.jsx(_e,{variant:"secondary",className:b,children:t.type}),e[13]=t.type,e[14]=b,e[15]=w):w=e[15];let v;e[16]!==t.id||e[17]!==t.name||e[18]!==w||e[19]!==u||e[20]!==m||e[21]!==p||e[22]!==h||e[23]!==g?(v=r.jsxs(ms,{value:c,"aria-label":d,onClick:u,className:m,children:[p,h,g,w]}),e[16]=t.id,e[17]=t.name,e[18]=w,e[19]=u,e[20]=m,e[21]=p,e[22]=h,e[23]=g,e[24]=v):v=e[24];const S=`Close ${t.name}`,j=`Close ${t.name}`;let k;e[25]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(rt,{"data-icon":"inline-start"}),e[25]=k):k=e[25];let C;e[26]!==i||e[27]!==S||e[28]!==j?(C=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs","aria-label":S,title:j,onClick:i,className:"mr-0.5 text-muted-foreground",children:k}),e[26]=i,e[27]=S,e[28]=j,e[29]=C):C=e[29];let N;return e[30]!==l||e[31]!==v||e[32]!==C?(N=r.jsxs("div",{title:l,className:"inline-flex h-6 shrink-0 items-center",children:[v,C]}),e[30]=l,e[31]=v,e[32]=C,e[33]=N):N=e[33],N}const p1=100,h1=600,s5=200,g1="process-panel-height";function o5(){try{const n=localStorage.getItem(g1);if(n)return Math.min(h1,Math.max(p1,Number(n)))}catch{}return s5}const r5=y.memo(function(e){const t=B.c(89),{processes:s,activeProcessId:o,collapsed:i,onSetActive:a,onRemove:l,onToggleCollapse:c,onRequestTerminal:d,onAddTerminalContext:u,onUpdateStatus:f,projectDir:m,onProcessStarted:p,mobile:h}=e,g=h===void 0?!1:h,x=md(),[b,w]=y.useState(o5),v=y.useRef(null);let S,j;t[0]!==f||t[1]!==x.sessions?(S=()=>{for(const ce of x.sessions)ce.status==="exited"&&(f==null||f(ce.id,"stopped"))},j=[x.sessions,f],t[0]=f,t[1]=x.sessions,t[2]=S,t[3]=j):(S=t[2],j=t[3]),y.useEffect(S,j);let k;t[4]!==l||t[5]!==x?(k=ce=>{ce.type!=="task"&&x.killSession(ce.id),l(ce.id)},t[4]=l,t[5]=x,t[6]=k):k=t[6];const C=k;let N;t[7]!==b?(N=ce=>{ce.preventDefault(),v.current={startY:ce.clientY,startH:b},ce.target.setPointerCapture(ce.pointerId)},t[7]=b,t[8]=N):N=t[8];const _=N;let P;t[9]===Symbol.for("react.memo_cache_sentinel")?(P=ce=>{if(!v.current)return;const ye=v.current.startY-ce.clientY,xe=Math.min(h1,Math.max(p1,v.current.startH+ye));w(xe)},t[9]=P):P=t[9];const A=P;let T;t[10]!==b?(T=()=>{if(v.current){v.current=null;try{localStorage.setItem(g1,String(b))}catch{}}},t[10]=b,t[11]=T):T=t[11];const E=T;let R;t[12]!==o||t[13]!==s?(R=o?s.get(o):null,t[12]=o,t[13]=s,t[14]=R):R=t[14];const $=R;let I;t[15]!==s?(I=[...s.values()],t[15]=s,t[16]=I):I=t[16];const M=I;let D;t[17]!==a?(D=ce=>{typeof ce=="string"&&a(ce)},t[17]=a,t[18]=D):D=t[18];let O;t[19]!==$||t[20]!==i||t[21]!==g||t[22]!==_||t[23]!==E?(O=!g&&!i&&$&&r.jsx("div",{className:"h-1 cursor-row-resize transition-colors hover:bg-accent active:bg-muted-foreground/30",onPointerDown:_,onPointerMove:A,onPointerUp:E,onPointerCancel:E}),t[19]=$,t[20]=i,t[21]=g,t[22]=_,t[23]=E,t[24]=O):O=t[24];const L=g?"h-7 gap-1 px-2":"h-8 gap-2 px-3";let F;t[25]!==L?(F=q("flex shrink-0 items-center border-b bg-card",L),t[25]=L,t[26]=F):F=t[26];const z=i?"Expand terminal panel":"Collapse terminal panel",W=!i;let U;t[27]!==i?(U=i?r.jsx(Je,{"data-icon":"inline-start"}):r.jsx(tt,{"data-icon":"inline-start"}),t[27]=i,t[28]=U):U=t[28];const H=g&&"sr-only";let K;t[29]!==H?(K=q(H),t[29]=H,t[30]=K):K=t[30];let V;t[31]!==K?(V=r.jsx("span",{className:K,children:"Terminal"}),t[31]=K,t[32]=V):V=t[32];let Y;t[33]!==c||t[34]!==z||t[35]!==W||t[36]!==U||t[37]!==V?(Y=r.jsxs(ee,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2",onClick:c,"aria-label":z,"aria-expanded":W,children:[U,V]}),t[33]=c,t[34]=z,t[35]=W,t[36]=U,t[37]=V,t[38]=Y):Y=t[38];const G=!g&&"ml-2";let J;t[39]!==G?(J=q("min-w-0 flex-1 justify-start overflow-x-auto no-scrollbar",G),t[39]=G,t[40]=J):J=t[40];let Q;t[41]!==o||t[42]!==C||t[43]!==g||t[44]!==a||t[45]!==M?(Q=M.map(ce=>r.jsx(n5,{process:ce,isActive:ce.id===o,onSelectActive:()=>a(ce.id),onClose:()=>C(ce),mobile:g},ce.id)),t[41]=o,t[42]=C,t[43]=g,t[44]=a,t[45]=M,t[46]=Q):Q=t[46];let X;t[47]!==J||t[48]!==Q?(X=r.jsx(hd,{variant:"default","aria-label":"Open processes",className:J,children:Q}),t[47]=J,t[48]=Q,t[49]=X):X=t[49];let Z;t[50]!==d||t[51]!==m?(Z=d&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",disabled:!m,onClick:d,"aria-label":"New terminal",title:m?"New terminal":"Open a project to start a terminal",children:r.jsx(Ln,{})}),t[50]=d,t[51]=m,t[52]=Z):Z=t[52];let te;t[53]!==F||t[54]!==Y||t[55]!==X||t[56]!==Z?(te=r.jsxs("div",{className:F,children:[Y,X,Z]}),t[53]=F,t[54]=Y,t[55]=X,t[56]=Z,t[57]=te):te=t[57];const ne=!i,re=g?"min(36dvh, 260px)":b;let ie;t[58]!==re?(ie={height:re},t[58]=re,t[59]=ie):ie=t[59];let ae;t[60]!==g||t[61]!==p||t[62]!==m?(ae=!g&&r.jsx(Y4,{projectDir:m,onProcessStarted:p}),t[60]=g,t[61]=p,t[62]=m,t[63]=ae):ae=t[63];let se;t[64]!==C||t[65]!==u||t[66]!==d||t[67]!==M?(se=M.map(ce=>r.jsx(ps,{value:ce.id,className:"col-start-1 row-start-1 flex min-h-0 flex-col",children:ce.type==="task"?r.jsx(t5,{process:ce}):r.jsx(y.Suspense,{fallback:r.jsx("div",{className:"flex size-full items-center justify-center text-xs text-muted-foreground",children:"Loading terminal…"}),children:r.jsx(e5,{processId:ce.id,autoFocus:!0,onRequestNew:d,onRequestClose:()=>C(ce),onAddContext:u})})},ce.id)),t[64]=C,t[65]=u,t[66]=d,t[67]=M,t[68]=se):se=t[68];let ue;t[69]!==$||t[70]!==d||t[71]!==m?(ue=!$&&r.jsxs(ln,{className:"col-start-1 row-start-1 rounded-none",children:[r.jsxs(cn,{children:[r.jsx(bn,{variant:"icon",children:r.jsx(Gs,{})}),r.jsx(dn,{children:"No terminal open"}),r.jsx(vn,{children:"Start a terminal here or run a project script from the left."})]}),d&&m&&r.jsx(wg,{children:r.jsxs(ee,{type:"button",size:"sm",onClick:d,children:[r.jsx(Ln,{"data-icon":"inline-start"}),"New terminal"]})})]}),t[69]=$,t[70]=d,t[71]=m,t[72]=ue):ue=t[72];let le;t[73]!==se||t[74]!==ue?(le=r.jsxs("div",{className:"grid min-h-0 min-w-0 flex-1 grid-cols-1",children:[se,ue]}),t[73]=se,t[74]=ue,t[75]=le):le=t[75];let de;t[76]!==ie||t[77]!==ae||t[78]!==le?(de=r.jsx(dt,{children:r.jsxs("div",{className:"flex min-h-0",style:ie,children:[ae,le]})}),t[76]=ie,t[77]=ae,t[78]=le,t[79]=de):de=t[79];let pe;t[80]!==ne||t[81]!==de?(pe=r.jsx(ct,{open:ne,className:"min-h-0",children:de}),t[80]=ne,t[81]=de,t[82]=pe):pe=t[82];let he;return t[83]!==o||t[84]!==D||t[85]!==O||t[86]!==te||t[87]!==pe?(he=r.jsxs(pd,{value:o,onValueChange:D,className:"shrink-0 gap-0 border-t bg-background",children:[O,te,pe]}),t[83]=o,t[84]=D,t[85]=O,t[86]=te,t[87]=pe,t[88]=he):he=t[88],he});function zr(n){const e=B.c(2),{children:t}=n;let s;return e[0]!==t?(s=r.jsx("h3",{className:"mb-3 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:t}),e[0]=t,e[1]=s):s=e[1],s}const i5=/(?::(\d{4,5}))|(?:port\s+(\d{4,5}))|(?:localhost:(\d{4,5}))/gi;function a5(n){const e=new Set;for(const t of n.matchAll(i5)){const s=parseInt(t[1]||t[2]||t[3],10);s>0&&s<65536&&e.add(s)}return[...e]}function l5(n){var s;const e=B.c(2);let t;if(e[0]!==n){t=new Map;for(let o=0;o<n.length;o++)for(const i of n[o].toolCalls){if(i.name!=="Bash"||!i.input.run_in_background)continue;const a=i.input.command||"",l=i.input.description||"",c=((s=n[o].assistantText)==null?void 0:s.join(" "))||"",d=[a,l,i.result||"",c].join(" "),u=a5(d);if(u.length===0){const p=a.toLowerCase();(p.includes("run dev")||p.includes("next dev")||p.includes("vite"))&&u.push(3e3)}const f=(i.result||"").match(/Output is being written to:\s*(\S+)/),m=f?f[1]:null;for(const p of u)t.set(p,{description:l||a.replace(/^cd\s+"[^"]*"\s*&&\s*/,"").slice(0,60),outputPath:m})}e[0]=n,e[1]=t}else t=e[1];return t}function nm(n){var e;return((e=n.preview.split(`
6
- `).find(t=>t.trim()))==null?void 0:e.trim())||`Task ${n.id}`}function c5(n){const e=B.c(10),{port:t,isActive:s}=n,o=s?"bg-success":"bg-muted-foreground/40";let i;e[0]!==o?(i=q("inline-block size-1.5 rounded-full",o),e[0]=o,e[1]=i):i=e[1];let a;e[2]!==i?(a=r.jsx("span",{className:i}),e[2]=i,e[3]=a):a=e[3];const l=s?"text-success":"text-muted-foreground";let c;e[4]!==t||e[5]!==l?(c=r.jsxs("span",{className:l,children:[":",t]}),e[4]=t,e[5]=l,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=r.jsxs(_e,{variant:"secondary",className:"font-mono",children:[a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d}function x1({cwd:n,turns:e,onToggleServer:t,onServersChanged:s}){const[o,i]=y.useState([]),a=l5(e);y.useEffect(()=>{if(!n)return;let c=!1;async function d(){try{const f=await ve(`/api/background-tasks?cwd=${encodeURIComponent(n)}`);if(c)return;if(f.ok){const h=await f.json();if(c)return;if(h.length>0){i(h);return}}if(a.size===0){i([]);return}const m=[...a.keys()],p=await ve(`/api/check-ports?ports=${m.join(",")}`);if(c)return;if(p.ok){const h=await p.json();if(c)return;const g=[],x=new Set;for(const[b,w]of a)!h[b]||x.has(b)||(x.add(b),g.push({id:`port-${b}`,outputPath:w.outputPath,ports:[b],portStatus:{[b]:!0},preview:w.description}));i(g)}}catch{}}d();const u=setInterval(d,1e4);return()=>{c=!0,clearInterval(u)}},[n,a]);const l=y.useCallback(async c=>{try{await ve("/api/kill-port",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({port:c})}),setTimeout(()=>{i(d=>d.filter(u=>!u.ports.includes(c)))},1500)}catch{}},[]);return y.useEffect(()=>{if(!s)return;const c=o.filter(d=>d.outputPath).map(d=>({id:d.id,outputPath:d.outputPath,title:nm(d)}));s(c)},[o,s]),o.length===0?null:r.jsxs("section",{children:[r.jsxs(zr,{children:["Active Servers (",o.length,")"]}),r.jsx("div",{className:"flex flex-col gap-1.5",children:o.map(c=>{const d=c.ports.filter(f=>c.portStatus[f]),u=nm(c);return r.jsxs("div",{className:"border-b border-border px-2 py-2 last:border-b-0",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(Yh,{className:"size-3 shrink-0 text-success","data-icon":"inline-start"}),r.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:u})]}),r.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[c.ports.map(f=>r.jsx(c5,{port:f,isActive:c.portStatus[f]},f)),r.jsx("div",{className:"flex-1"}),c.outputPath&&r.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:()=>t==null?void 0:t(c.id,c.outputPath,u),title:"View server output","aria-label":"View server output",children:r.jsx(Gs,{"data-icon":"inline-start"})}),d.length>0&&r.jsxs(ee,{variant:"ghost",size:"xs",className:"text-destructive",onClick:()=>d.forEach(f=>l(f)),title:"Stop server","aria-label":"Stop server",children:[r.jsx(Xc,{"data-icon":"inline-start",className:"fill-current"}),r.jsx("span",{children:"Stop"})]})]})]},c.id)})})]})}function gd(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(Ay,{"data-slot":"alert-dialog",...t}),e[2]=t,e[3]=s):s=e[3],s}function d5(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(Ry,{"data-slot":"alert-dialog-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function u5(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(Vc,{"data-slot":"alert-dialog-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function f5(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("fixed inset-0 isolate z-50 bg-black/55 duration-150 ease-out data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0 data-closed:duration-100 data-closed:ease-in motion-reduce:animate-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Gc,{"data-slot":"alert-dialog-overlay",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function xd(n){const e=B.c(11);let t,s,o;e[0]!==n?({className:t,size:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"default":o;let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(f5,{}),e[4]=a):a=e[4];let l;e[5]!==t?(l=q("group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl border bg-popover p-4 text-popover-foreground shadow-lg duration-150 ease-out outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-100 data-closed:ease-in motion-reduce:animate-none",t),e[5]=t,e[6]=l):l=e[6];let c;return e[7]!==s||e[8]!==i||e[9]!==l?(c=r.jsxs(u5,{children:[a,r.jsx(qc,{"data-slot":"alert-dialog-content","data-size":i,className:l,...s})]}),e[7]=s,e[8]=i,e[9]=l,e[10]=c):c=e[10],c}function bd(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"alert-dialog-header",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function vd(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"alert-dialog-footer",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function m5(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("mb-2 inline-flex size-10 items-center justify-center rounded-md bg-muted sm:group-data-[size=default]/alert-dialog-content:row-span-2 *:[svg:not([class*='size-'])]:size-6",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"alert-dialog-media",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function yd(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Hc,{"data-slot":"alert-dialog-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function wd(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Kc,{"data-slot":"alert-dialog-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function jd(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q(t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(ee,{"data-slot":"alert-dialog-action",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Sd(n){const e=B.c(14);let t,s,o,i;e[0]!==n?({className:t,variant:o,size:i,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);const a=o===void 0?"outline":o,l=i===void 0?"default":i;let c;e[5]!==t?(c=q(t),e[5]=t,e[6]=c):c=e[6];let d;e[7]!==l||e[8]!==a?(d=r.jsx(ee,{variant:a,size:l}),e[7]=l,e[8]=a,e[9]=d):d=e[9];let u;return e[10]!==s||e[11]!==c||e[12]!==d?(u=r.jsx(aa,{"data-slot":"alert-dialog-cancel",className:c,render:d,...s}),e[10]=s,e[11]=c,e[12]=d,e[13]=u):u=e[13],u}function b1(n){const e=B.c(9);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input outline-none transition-[color,background-color,border-color,box-shadow,transform,scale] duration-100 ease-out active:scale-90 group-has-disabled/field:opacity-50 group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary motion-reduce:transition-none motion-reduce:active:scale-100 dark:data-checked:bg-primary",t),e[3]=t,e[4]=o):o=e[4];let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx($y,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-[opacity,transform,scale] duration-100 ease-out motion-safe:data-starting-style:scale-75 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:scale-75 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none [&>svg]:size-3.5",children:r.jsx(mt,{})}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.jsx(Iy,{"data-slot":"checkbox",className:o,...s,children:i}),e[6]=s,e[7]=o,e[8]=a):a=e[8],a}const p5={undo:"Undo turns?",redo:"Redo turns?","branch-switch":"Switch branch?"},h5={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 g5({state:n,isApplying:e,applyError:t,onConfirm:s,onCancel:o}){var f,m;const i=y.useRef(n),[a,l]=y.useState({key:"",selected:!1});y.useEffect(()=>{n&&(i.current=n)},[n]);const c=n??i.current;if(!c)return null;const d=((f=c.nativeRewind)==null?void 0:f.eventId)??`${c.type}:${c.targetTurnIndex}:${c.branchId??""}`,u=a.key===d&&a.selected;return r.jsx(gd,{open:n!==null,onOpenChange:p=>{p||o()},onOpenChangeComplete:p=>{p||(i.current=null,l({key:"",selected:!1}))},children:r.jsxs(xd,{children:[r.jsxs(bd,{children:[r.jsx(m5,{children:r.jsx(xn,{className:"text-warning"})}),r.jsx(yd,{children:p5[c.type]}),r.jsx(wd,{children:c.nativeRewind?u?"This removes the selected turn and everything after it, restoring captured files.":"This removes the selected turn and everything after it. Files stay unchanged.":h5[c.type]})]}),r.jsxs("div",{className:"flex flex-col gap-2 py-2",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsx("span",{className:"text-muted-foreground",children:"Turns affected"}),r.jsx("span",{className:"text-foreground font-mono",children:c.summary.turnCount})]}),r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsx("span",{className:"text-muted-foreground",children:"Files affected"}),r.jsx("span",{className:"text-foreground font-mono",children:c.summary.fileCount})]}),r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsx("span",{className:"text-muted-foreground",children:"Operations"}),r.jsx("span",{className:"text-foreground font-mono",children:c.summary.operationCount})]}),c.summary.filePaths.length>0&&r.jsx("div",{className:"mt-2 max-h-32 overflow-y-auto rounded-md border bg-muted/30 p-2",children:c.summary.filePaths.map(p=>r.jsx("div",{className:"truncate font-mono text-xs text-muted-foreground",children:p},p))}),((m=c.nativeRewind)==null?void 0:m.filesAvailable)&&r.jsxs("label",{className:"mt-2 flex items-center gap-2 text-sm text-foreground",children:[r.jsx(b1,{checked:u,disabled:e,onCheckedChange:p=>l({key:d,selected:p===!0})}),"Restore captured file changes"]})]}),t&&r.jsx(ht,{variant:"destructive",children:r.jsx(gt,{children:t})}),r.jsxs(vd,{children:[r.jsx(Sd,{onClick:o,disabled:e,children:"Cancel"}),r.jsx(jd,{onClick:()=>s(u),disabled:e,children:e?r.jsxs(r.Fragment,{children:[r.jsx(ot,{"data-icon":"inline-start",className:"animate-spin"}),"Applying..."]}):c.type==="undo"?"Undo":c.type==="redo"?"Redo":"Switch"})]})]})})}function Jt(n){const e=B.c(10);let t,s,o;e[0]!==n?({className:t,size:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"default":o;let a;e[4]!==t?(a=q("group/card flex flex-col gap-4 overflow-hidden rounded-xl bg-card py-4 text-sm text-card-foreground ring-1 ring-foreground/10 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",t),e[4]=t,e[5]=a):a=e[5];let l;return e[6]!==s||e[7]!==i||e[8]!==a?(l=r.jsx("div",{"data-slot":"card","data-size":i,className:a,...s}),e[6]=s,e[7]=i,e[8]=a,e[9]=l):l=e[9],l}function rn(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"card-header",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function an(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"card-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function fn(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("text-sm text-muted-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"card-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Nd(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("col-start-2 row-span-2 row-start-1 self-start justify-self-end",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"card-action",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Qt(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("px-4 group-data-[size=sm]/card:px-3",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"card-content",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Io(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("flex items-center rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/card:p-3",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"card-footer",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function as(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"input-group",role:"group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const x5=es("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",{variants:{align:{"inline-start":"order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]","inline-end":"order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]","block-start":"order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2","block-end":"order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2"}},defaultVariants:{align:"inline-start"}});function Pn(n){const e=B.c(11);let t,s,o;e[0]!==n?({className:t,align:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"inline-start":o;let a;e[4]!==i||e[5]!==t?(a=q(x5({align:i}),t),e[4]=i,e[5]=t,e[6]=a):a=e[6];let l;return e[7]!==i||e[8]!==s||e[9]!==a?(l=r.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":i,className:a,onClick:b5,...s}),e[7]=i,e[8]=s,e[9]=a,e[10]=l):l=e[10],l}function b5(n){var e,t;n.target.closest("button")||(t=(e=n.currentTarget.parentElement)==null?void 0:e.querySelector("input"))==null||t.focus()}const v5=es("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 Fr(n){const e=B.c(15);let t,s,o,i,a;e[0]!==n?({className:t,type:o,variant:i,size:a,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5]);const l=o===void 0?"button":o,c=i===void 0?"ghost":i,d=a===void 0?"xs":a;let u;e[6]!==t||e[7]!==d?(u=q(v5({size:d}),t),e[6]=t,e[7]=d,e[8]=u):u=e[8];let f;return e[9]!==s||e[10]!==d||e[11]!==u||e[12]!==l||e[13]!==c?(f=r.jsx(ee,{type:l,"data-size":d,variant:c,className:u,...s}),e[9]=s,e[10]=d,e[11]=u,e[12]=l,e[13]=c,e[14]=f):f=e[14],f}function ls(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Ht,{"data-slot":"input-group-control",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function y5(){const[n,e]=y.useState("idle"),[t,s]=y.useState(null),o=y.useRef(void 0),i=y.useCallback(async d=>{if(!d.trim()){e("idle"),s(null);return}e("validating"),s(null);try{const f=await(await ve(`/api/config/validate?path=${encodeURIComponent(d)}`)).json();f.valid?(e("valid"),s(null)):(e("invalid"),s(f.error||"Invalid path"))}catch{e("invalid"),s("Failed to validate path")}},[]),a=y.useCallback(d=>{clearTimeout(o.current),o.current=setTimeout(()=>i(d),400)},[i]),l=y.useCallback(()=>{e("idle"),s(null),clearTimeout(o.current)},[]),c=y.useCallback(async(d,u)=>{try{const f=await ve("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({claudeDir:d,...u})}),m=await f.json();return f.ok&&m.success?{success:!0,claudeDir:m.claudeDir}:(s(m.error||"Failed to save"),e("invalid"),{success:!1,error:m.error})}catch{return s("Failed to save configuration"),{success:!1,error:"Network error"}}},[]);return y.useEffect(()=>()=>clearTimeout(o.current),[]),{status:n,error:t,debouncedValidate:a,validate:i,reset:l,save:c}}const po=H3(n=>!n.cli.homeIsDiscoverable,"a home Cogpit has to be told about"),v1=ga().filter(n=>n.cli.homeIsDiscoverable);function y1(n){return n.flatMap((e,t)=>t===0?[e]:[t===n.length-1?" and ":", ",e])}function w1(n){const e=B.c(2),{children:t}=n;let s;return e[0]!==t?(s=r.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-xs text-foreground",children:t}),e[0]=t,e[1]=s):s=e[1],s}const w5=y1(v1.map(n=>n.displayName)),j5=y1(v1.map(n=>r.jsx(w1,{children:["~",n.cli.homeDirName,n.cli.installMarker].filter(Boolean).join("/")},n.kind))),S5=`~/${po.cli.homeDirName}`;function N5(n){const e=B.c(46),{onConfigured:t}=n,[s,o]=y.useState(""),[i,a]=y.useState(!1),{status:l,error:c,debouncedValidate:d,save:u}=y5();let f;e[0]!==d?(f=O=>{const L=O.target.value;o(L),d(L)},e[0]=d,e[1]=f):f=e[1];const m=f;let p;e[2]!==t||e[3]!==s||e[4]!==u?(p=async()=>{a(!0);const O=await u(s);O.success&&O.claudeDir&&t(O.claudeDir),a(!1)},e[2]=t,e[3]=s,e[4]=u,e[5]=p):p=e[5];const h=p;let g;e[6]!==h||e[7]!==i||e[8]!==l?(g=O=>{O.preventDefault(),l==="valid"&&!i&&h()},e[6]=h,e[7]=i,e[8]=l,e[9]=g):g=e[9];let x,b;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:r.jsx(Yc,{className:"size-4"})}),b=r.jsx(an,{children:"Connect your coding agent"}),e[10]=x,e[11]=b):(x=e[10],b=e[11]);let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsxs(rn,{children:[x,b,r.jsxs(fn,{children:["Cogpit detects ",w5," automatically. Existing histories live in"," ",j5,"."," ","For ",po.displayName,", enter its data directory, usually"," ",r.jsx(w1,{children:S5}),"."]})]}),e[12]=w):w=e[12];const v=l==="invalid";let S;e[13]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsxs(jt,{htmlFor:"agent-data-directory",children:[po.displayName," data directory"]}),e[13]=S):S=e[13];let j;e[14]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(Pn,{children:r.jsx(jo,{"aria-hidden":"true"})}),e[14]=j):j=e[14];const k=l==="invalid";let C;e[15]!==m||e[16]!==s||e[17]!==k?(C=r.jsxs(as,{children:[j,r.jsx(ls,{id:"agent-data-directory",value:s,onChange:m,placeholder:`/Users/you/${po.cli.homeDirName}`,autoFocus:!0,"aria-invalid":k,"aria-describedby":"agent-directory-status"})]}),e[15]=m,e[16]=s,e[17]=k,e[18]=C):C=e[18];let N;e[19]!==l?(N=l==="validating"&&r.jsxs(No,{className:"flex items-center gap-2",children:[r.jsx(xt,{className:"size-4"}),"Checking path..."]}),e[19]=l,e[20]=N):N=e[20];let _;e[21]!==l?(_=l==="valid"&&r.jsxs(No,{className:"flex items-center gap-2 text-success",children:[r.jsx(Cr,{className:"size-4"}),po.displayName," history found"]}),e[21]=l,e[22]=_):_=e[22];let P;e[23]!==c||e[24]!==l?(P=l==="invalid"&&c&&r.jsxs(bs,{className:"flex items-center gap-2",children:[r.jsx(Ys,{className:"size-4"}),c]}),e[23]=c,e[24]=l,e[25]=P):P=e[25];let A;e[26]!==N||e[27]!==_||e[28]!==P?(A=r.jsxs("div",{id:"agent-directory-status",className:"min-h-5",role:"status","aria-live":"polite",children:[N,_,P]}),e[26]=N,e[27]=_,e[28]=P,e[29]=A):A=e[29];let T;e[30]!==C||e[31]!==A||e[32]!==v?(T=r.jsx(Qt,{children:r.jsx(Ao,{children:r.jsxs(wt,{"data-invalid":v,children:[S,C,A]})})}),e[30]=C,e[31]=A,e[32]=v,e[33]=T):T=e[33];const E=l!=="valid"||i;let R;e[34]!==i?(R=i&&r.jsx(xt,{"data-icon":"inline-start"}),e[34]=i,e[35]=R):R=e[35];const $=i?"Saving...":`Connect ${po.displayName}`;let I;e[36]!==E||e[37]!==R||e[38]!==$?(I=r.jsx(Io,{children:r.jsxs(ee,{type:"submit",className:"w-full",disabled:E,children:[R,$]})}),e[36]=E,e[37]=R,e[38]=$,e[39]=I):I=e[39];let M;e[40]!==T||e[41]!==I?(M=r.jsxs(Jt,{children:[w,T,I]}),e[40]=T,e[41]=I,e[42]=M):M=e[42];let D;return e[43]!==M||e[44]!==g?(D=r.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-4 py-8 text-foreground",children:r.jsx("form",{className:"w-full max-w-lg",onSubmit:g,children:M})}),e[43]=M,e[44]=g,e[45]=D):D=e[45],D}const j1=/^[a-z]:[\\/]/i;function kd(n){return(j1.test(n)?n.replace(/\\/g,"/"):n).replace(/\/+$/,"")||"/"}function sm(n){const e=kd(n);return j1.test(n)?e.toLowerCase():e}function k5(n){const e=kd(n),t=e.lastIndexOf("/");return t<0?e:t===0?"/":e.slice(0,t)}function om(n,e){const t=sm(n),s=sm(e);if(t===s)return"";const o=t==="/"?"/":`${t}/`;return s.startsWith(o)?kd(e).slice(o.length):null}let Cd=!1;function C5(n){Cd=n}function _d(){return Cd}let Zo=null;function _5(n){return Zo=n,()=>{Zo===n&&(Zo=null)}}function T5(n,e){if(!n.path)return null;if(n.kind==="project")return{root:n.path,file:null,mode:"edit"};if(e){const o=om(e,n.path);if(o)return{root:e,file:o,mode:rm(n),line:n.line}}const t=k5(n.path),s=om(t,n.path);return s?{root:t,file:s,mode:rm(n),line:n.line}:null}function rm(n){return n.mode==="diff"?"diff":"edit"}function S1(n){return Cd&&Zo!==null&&Zo(n)}function N1(n,e){ve(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).catch(()=>{})}function fr(n,e={}){if(lt("hostFiles")&&!S1({kind:"file",path:n,...e})){if(Bs()){Ar(n);return}N1("/api/open-in-editor",{path:n,mode:e.mode??"file",line:e.line,column:e.column})}}function k1(n){lt("hostFiles")&&(n.path&&S1({kind:"project",path:n.path})||_1("/api/open-in-editor",n))}function C1(n){lt("hostFiles")&&_1("/api/reveal-in-folder",n)}function _1(n,e){!e.path&&!e.dirName||N1(n,{path:e.path||void 0,dirName:e.dirName||void 0})}let pl=null;const hc=new Set,gi=new Map,im=["typescript","tsx","javascript","jsx","json","css","html","python","bash","yaml","markdown"],T1={typescript:()=>qe(()=>import("./typescript-BPQ3VLAy.js"),[]),tsx:()=>qe(()=>import("./tsx-COt5Ahok.js"),[]),javascript:()=>qe(()=>import("./javascript-wDzz0qaB.js"),[]),jsx:()=>qe(()=>import("./jsx-g9-lgVsj.js"),[]),json:()=>qe(()=>import("./json-Cp-IABpG.js"),[]),css:()=>qe(()=>import("./css-DPfMkruS.js"),[]),html:()=>qe(()=>import("./html-GMplVEZG.js"),__vite__mapDeps([6,7,8])),python:()=>qe(()=>import("./python-B6aJPvgy.js"),[]),bash:()=>qe(()=>import("./bash-Yzrsuije.js"),[]),yaml:()=>qe(()=>import("./yaml-Buea-lGh.js"),[]),markdown:()=>qe(()=>import("./markdown-Cvjx9yec.js"),[]),rust:()=>qe(()=>import("./rust-B1yitclQ.js"),[]),go:()=>qe(()=>import("./go-CxLEBnE3.js"),[]),toml:()=>qe(()=>import("./toml-vGWfd6FD.js"),[]),sql:()=>qe(()=>import("./sql-BLtJtn59.js"),[]),c:()=>qe(()=>import("./c-BIGW1oBm.js"),[]),cpp:()=>qe(()=>import("./cpp-BRuaLJcg.js"),__vite__mapDeps([9,10,11])),java:()=>qe(()=>import("./java-CylS5w8V.js"),[]),ruby:()=>qe(()=>import("./ruby-B0Tyh1qT.js"),__vite__mapDeps([12,6,7,8,13,14,11,15,16,17,9,10,18,19])),swift:()=>qe(()=>import("./swift-D82vCrfD.js"),[]),kotlin:()=>qe(()=>import("./kotlin-BdnUsdx6.js"),[]),php:()=>qe(()=>import("./php-aq0itWAE.js"),__vite__mapDeps([20,6,7,8,13,14,11,21])),vue:()=>qe(()=>import("./vue-DVfSmUF7.js"),__vite__mapDeps([22,8,7,15,21,6])),svelte:()=>qe(()=>import("./svelte-DZMnMd3x.js"),__vite__mapDeps([23,7,15,8])),scss:()=>qe(()=>import("./scss-OYdSNvt2.js"),__vite__mapDeps([24,8]))};function E1(){return pl||(pl=(async()=>{const[n,e,...t]=await Promise.all([qe(()=>import("./github-dark-DHJKELXO.js"),[]).then(o=>o.default),qe(()=>import("./github-light-DAi9KRSo.js"),[]).then(o=>o.default),...im.map(o=>T1[o]().then(i=>i.default))]),s=await M3({themes:[n,e],langs:t,engine:O3()});for(const o of im)hc.add(o);return s})()),pl}async function P1(n,e){if(hc.has(e))return;if(gi.has(e))return gi.get(e);const t=T1[e];if(!t)return;const s=t().then(async o=>{await n.loadLanguage(o.default),hc.add(e)}).finally(()=>gi.delete(e));gi.set(e,s),await s}const E5={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 A1(n){var t;const e=((t=n.split(".").pop())==null?void 0:t.toLowerCase())??"";return E5[e]??null}async function Td(n,e,t){try{const s=await E1();await P1(s,e);const o=t?"github-dark":"github-light";return s.codeToTokens(n,{lang:e,theme:o}).tokens}catch{return null}}function Br(){const n=B.c(2),[e,t]=y.useState(P5);let s,o;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{const i=document.documentElement,a=()=>t(i.classList.contains("dark")),l=new MutationObserver(a);return l.observe(i,{attributes:!0,attributeFilter:["class"]}),()=>l.disconnect()},o=[],n[0]=s,n[1]=o):(s=n[0],o=n[1]),y.useEffect(s,o),e}function P5(){return typeof document<"u"&&document.documentElement.classList.contains("dark")}const A5={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 R5(n){return A5[n.toLowerCase()]??n}function I5(n){if(!n)return null;const e=n.match(/language-(\S+)/);return(e==null?void 0:e[1])??null}function $5(n){const e=B.c(10),{text:t}=n,[s,o]=y.useState(!1),i=y.useRef(null),a=y.useRef(0);let l,c;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>()=>{a.current=a.current+1,i.current&&clearTimeout(i.current)},c=[],e[0]=l,e[1]=c):(l=e[0],c=e[1]),y.useEffect(l,c);let d;e[2]!==t?(d=function(){const g=a.current=a.current+1;Ar(t).then(x=>{x&&g===a.current&&(i.current&&clearTimeout(i.current),o(!0),i.current=setTimeout(()=>{i.current=null,o(!1)},2e3))})},e[2]=t,e[3]=d):d=e[3];const u=d,f=s?"Copied":"Copy code";let m;e[4]!==s?(m=s?r.jsxs(r.Fragment,{children:[r.jsx(mt,{className:"text-success","data-icon":"inline-start"}),r.jsx("span",{className:"text-success",children:"Copied"})]}):r.jsx(An,{"data-icon":"icon"}),e[4]=s,e[5]=m):m=e[5];let p;return e[6]!==u||e[7]!==f||e[8]!==m?(p=r.jsx(ee,{type:"button",variant:"ghost",size:"xs",onClick:u,className:"text-muted-foreground",title:"Copy code","aria-label":f,children:m}),e[6]=u,e[7]=f,e[8]=m,e[9]=p):p=e[9],p}function M5(n){const e=B.c(2),{num:t}=n;let s;return e[0]!==t?(s=r.jsx("span",{className:"mr-3 inline-block w-8 select-none text-right text-xs text-muted-foreground/60",children:t}),e[0]=t,e[1]=s):s=e[1],s}function O5(n){const e=B.c(16);let t,s,o;if(e[0]!==n){const{children:m,className:p,node:h,...g}=n;t=m,s=p,o=g,e[0]=n,e[1]=t,e[2]=s,e[3]=o}else t=e[1],s=e[2],o=e[3];const i=!s&&typeof t=="string"&&!t.includes(`
7
- `);let a;e[4]!==s?(a=I5(s),e[4]=s,e[5]=a):a=e[5];const l=a,c=String(t);let d;if(e[6]!==c){let m;e[8]===Symbol.for("react.memo_cache_sentinel")?(m=/\n$/,e[8]=m):m=e[8],d=c.replace(m,""),e[6]=c,e[7]=d}else d=e[7];const u=d;if(i){let m;return e[9]!==t||e[10]!==o?(m=r.jsx("code",{className:"rounded-md border border-border bg-muted px-1.5 py-0.5 font-mono text-[0.9em] text-foreground",...o,children:t}),e[9]=t,e[10]=o,e[11]=m):m=e[11],m}let f;return e[12]!==u||e[13]!==l||e[14]!==o?(f=r.jsx(D5,{code:u,lang:l,...o}),e[12]=u,e[13]=l,e[14]=o,e[15]=f):f=e[15],f}function D5(n){const e=B.c(35);let t,s,o;e[0]!==n?({code:t,lang:s,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=Br(),[a,l]=y.useState(null),[c,d]=y.useState(!1),u=t.split(`
8
- `),f=u.length,m=f>30,p=s?`${s}\0${i?"dark":"light"}\0${t}`:null,h=(a==null?void 0:a.key)===p?a.lines:null;let g,x;e[4]!==t||e[5]!==p||e[6]!==i||e[7]!==s?(g=()=>{if(!s||!p)return;let T=!1;return Td(t,s,i).then(E=>{T||l({key:p,lines:E})}),()=>{T=!0}},x=[t,s,i,p],e[4]=t,e[5]=p,e[6]=i,e[7]=s,e[8]=g,e[9]=x):(g=e[8],x=e[9]),y.useEffect(g,x);const b=c?Je:tt,w="my-3 overflow-hidden rounded-lg border border-border bg-muted/20";let v;e[10]!==b||e[11]!==c||e[12]!==m?(v=m&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>d(!c),className:"text-muted-foreground","aria-label":c?"Expand code":"Collapse code",children:r.jsx(b,{"data-icon":"icon"})}),e[10]=b,e[11]=c,e[12]=m,e[13]=v):v=e[13];let S;e[14]!==s?(S=s&&r.jsx(_e,{variant:"ghost",className:"px-0 uppercase tracking-wide text-muted-foreground",children:R5(s)}),e[14]=s,e[15]=S):S=e[15];let j;e[16]!==m||e[17]!==f?(j=m&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:[f," lines"]}),e[16]=m,e[17]=f,e[18]=j):j=e[18];let k;e[19]!==v||e[20]!==S||e[21]!==j?(k=r.jsxs("div",{className:"flex items-center gap-2",children:[v,S,j]}),e[19]=v,e[20]=S,e[21]=j,e[22]=k):k=e[22];let C;e[23]!==t?(C=r.jsx($5,{text:t}),e[23]=t,e[24]=C):C=e[24];let N;e[25]!==k||e[26]!==C?(N=r.jsxs("div",{className:"flex items-center justify-between border-b border-border bg-muted/40 px-3 py-1.5",children:[k,C]}),e[25]=k,e[26]=C,e[27]=N):N=e[27];const _=!c&&r.jsx("div",{className:"overflow-x-auto",children:r.jsx("pre",{className:"m-0 p-3 font-mono text-xs leading-relaxed",children:r.jsx("code",{className:q("block",!h&&"text-foreground/90"),...o,children:u.map((T,E)=>{const R=h==null?void 0:h[E];return r.jsxs("span",{className:"block",children:[r.jsx(M5,{num:E+1}),R?R.map(L5):T||" "]},E)})})})});let P;e[28]!==c||e[29]!==f?(P=c&&r.jsxs(ee,{type:"button",variant:"ghost",size:"sm",onClick:()=>d(!1),className:"h-auto w-full justify-start rounded-none px-3 py-2 text-xs text-muted-foreground","aria-label":`Expand ${f} lines of code`,children:["Show ",f," lines..."]}),e[28]=c,e[29]=f,e[30]=P):P=e[30];let A;return e[31]!==_||e[32]!==P||e[33]!==N?(A=r.jsxs("div",{className:w,children:[N,_,P]}),e[31]=_,e[32]=P,e[33]=N,e[34]=A):A=e[34],A}function L5(n,e){return r.jsx("span",{style:{color:n.color},children:n.content},e)}var Ds=function(n,e){return Number(n.toFixed(e))},z5=function(n,e){return e},Qe=function(n,e,t){t&&typeof t=="function"&&t(n,e)},F5=function(n){return-Math.cos(n*Math.PI)/2+.5},B5=function(n){return n},U5=function(n){return n*n},W5=function(n){return n*(2-n)},H5=function(n){return n<.5?2*n*n:-1+(4-2*n)*n},K5=function(n){return n*n*n},q5=function(n){return--n*n*n+1},V5=function(n){return n<.5?4*n*n*n:(n-1)*(2*n-2)*(2*n-2)+1},G5=function(n){return n*n*n*n},Y5=function(n){return 1- --n*n*n*n},X5=function(n){return n<.5?8*n*n*n*n:1-8*--n*n*n*n},J5=function(n){return n*n*n*n*n},Q5=function(n){return 1+--n*n*n*n*n},Z5=function(n){return n<.5?16*n*n*n*n*n:1+16*--n*n*n*n*n},R1={easeOut:F5,linear:B5,easeInQuad:U5,easeOutQuad:W5,easeInOutQuad:H5,easeInCubic:K5,easeOutCubic:q5,easeInOutCubic:V5,easeInQuart:G5,easeOutQuart:Y5,easeInOutQuart:X5,easeInQuint:J5,easeOutQuint:Q5,easeInOutQuint:Z5},I1=function(n){typeof n=="number"&&cancelAnimationFrame(n)},Sn=function(n){n.mounted&&(I1(n.animation),n.isAnimating=!1,n.animation=null,n.velocity=null)};function $1(n,e,t,s){if(n.mounted){var o=new Date().getTime(),i=1;Sn(n),n.animation=function(){if(!n.mounted)return I1(n.animation);var a=new Date().getTime()-o,l=a/t,c=R1[e],d=c(l);a>=t?(s(i),n.animation=null):n.animation&&(s(d),requestAnimationFrame(n.animation))},requestAnimationFrame(n.animation)}}function eN(n){var e=n.scale,t=n.positionX,s=n.positionY;return!(Number.isNaN(e)||Number.isNaN(t)||Number.isNaN(s))}function As(n,e,t,s){var o=eN(e);if(!(!n.mounted||!o)){var i=n.setState,a=n.state,l=a.scale,c=a.positionX,d=a.positionY,u=e.scale-l,f=e.positionX-c,m=e.positionY-d;t===0?i(e.scale,e.positionX,e.positionY):$1(n,s,t,function(p){p!==1?n.isAnimating=!0:n.isAnimating=!1;var h=l+u*p,g=c+f*p,x=d+m*p;i(h,g,x)})}}function tN(n,e,t){var s=n.offsetWidth,o=n.offsetHeight,i=e.offsetWidth,a=e.offsetHeight,l=i*t,c=a*t,d=s-l,u=o-c;return{wrapperWidth:s,wrapperHeight:o,newContentWidth:l,newDiffWidth:d,newContentHeight:c,newDiffHeight:u}}var nN=function(n,e,t,s,o,i,a){var l=n>e?t*(a?.5:1):0,c=s>o?i*(a?.5:1):0,d=n-e-l,u=l,f=s-o-c,m=c;return{minPositionX:d,maxPositionX:u,minPositionY:f,maxPositionY:m,scaleWidthFactor:l,scaleHeightFactor:c}},Ed=function(n,e){var t=n.wrapperComponent,s=n.contentComponent,o=n.setup,i=o.centerZoomedOut,a=o.disablePadding;if(!t||!s)throw new Error("Components are not mounted");var l=tN(t,s,e),c=l.wrapperWidth,d=l.wrapperHeight,u=l.newContentWidth,f=l.newContentHeight,m=l.newDiffWidth,p=l.newDiffHeight,h=nN(c,u,m,d,f,p,!!i),g=c>=u&&d>=f;a&&g&&!i&&(h.minPositionX=0,h.maxPositionX=0,h.minPositionY=0,h.maxPositionY=0);var x=n.setup,b=x.minPositionX,w=x.maxPositionX,v=x.minPositionY,S=x.maxPositionY;return b!=null&&(h.minPositionX=c*(1-e)+b*e),w!=null&&(h.maxPositionX=w*e),v!=null&&(h.minPositionY=d*(1-e)+v*e),S!=null&&(h.maxPositionY=S*e),h},mr=function(n,e,t,s){return s?n<e?Ds(e,2):n>t?Ds(t,2):Ds(n,2):Ds(n,2)},ko=function(n,e){var t=Ed(n,e);return n.bounds=t,t};function Ur(n,e,t,s,o,i,a){var l=t.minPositionX,c=t.minPositionY,d=t.maxPositionX,u=t.maxPositionY,f=0,m=0;a&&(f=o,m=i);var p=mr(n,l-f,d+f,s),h=mr(e,c-m,u+m,s);return{x:p,y:h}}function Ta(n,e,t,s,o,i){var a=n.state,l=a.scale,c=a.positionX,d=a.positionY,u=s-l;if(!Number.isFinite(e)||!Number.isFinite(t))return console.error("Mouse X and Y position were not provided!"),{x:c,y:d};var f=c-e*u,m=d-t*u,p=Ur(f,m,o,i,0,0,null);return p}var am=1e-7;function Wr(n,e,t,s,o){var i=o?s:0,a=Math.max(e-i,am),l=t+i;return!Number.isNaN(t)&&n>=l?l:!Number.isNaN(e)&&n<=a?a:Math.max(n,am)}var lm=function(n,e){var t=n.setup.panning.excluded,s=n.isInitialized,o=n.wrapperComponent,i=e.target,a="shadowRoot"in i&&"composedPath"in e,l=a?e.composedPath().some(function(u){return u instanceof Element?o==null?void 0:o.contains(u):!1}):o==null?void 0:o.contains(i),c=s&&i&&l;if(!c)return!1;var d=Hr(i,t);return!(d||i.getAttribute("draggable")==="true"||i.getAttribute("contenteditable")==="true"||i.isContentEditable)},cm=function(n){var e=n.isInitialized,t=n.isPanning,s=n.setup,o=s.panning.disabled,i=e&&t&&!o;return!!i},sN=function(n,e){var t=n.state,s=t.positionX,o=t.positionY;n.isPanning=!0;var i=e.clientX,a=e.clientY;n.startCoords={x:i-s,y:a-o}},oN=function(n,e){var t=e.touches,s=n.state,o=s.positionX,i=s.positionY;n.isPanning=!0;var a=t.length===1;if(a){var l=t[0].clientX,c=t[0].clientY;n.startCoords={x:l-o,y:c-i}}};function rN(n){var e=n.state,t=e.positionX,s=e.positionY,o=e.scale,i=n.setup,a=i.disabled,l=i.limitToBounds,c=i.centerZoomedOut,d=n.wrapperComponent;if(!(a||!d||!n.bounds)){var u=n.bounds,f=u.maxPositionX,m=u.minPositionX,p=u.maxPositionY,h=u.minPositionY,g=t>f||t<m,x=s>p||s<h,b=t>f?d.offsetWidth:n.setup.minPositionX||0,w=s>p?d.offsetHeight:n.setup.minPositionY||0,v=Ta(n,b,w,o,n.bounds,l||c),S=v.x,j=v.y;return{scale:o,positionX:g?S:t,positionY:x?j:s}}}function M1(n,e,t,s,o){var i=n.setup.limitToBounds,a=n.wrapperComponent,l=n.bounds,c=n.state,d=c.scale,u=c.positionX,f=c.positionY;if(!(a===null||l===null||e===u&&t===f)){var m=Ur(e,t,l,i,s,o,a),p=m.x,h=m.y;n.setState(d,p,h)}}var iN=function(n,e,t){var s=n.startCoords,o=n.state,i=n.setup.panning,a=i.lockAxisX,l=i.lockAxisY,c=o.positionX,d=o.positionY;if(!s)return{x:c,y:d};var u=e-s.x,f=t-s.y,m=a?c:u,p=l?d:f;return{x:m,y:p}},_s=function(n,e,t){var s=n.setup,o=n.state,i=s.minScale,a=s.disablePadding,l=s.centerZoomedOut,c=t??o.scale;return e>0&&c>=i&&!a&&!l?e:0},hs;(function(n){n.TRACK_PAD="track_pad",n.MOUSE="mouse",n.TOUCH="touch"})(hs||(hs={}));var aN=function(n){var e=n.mounted,t=n.wrapperComponent,s=n.contentComponent,o=n.setup,i=o.disabled,a=o.velocityAnimation,l=o.limitToBounds,c=n.state.scale,d=a.disabled;if(d||i||!e||!t||!s)return!1;if(!l)return!0;var u=t.offsetWidth<s.offsetWidth*c||t.offsetHeight<s.offsetHeight*c;return u},lN=function(n){var e=n.mounted,t=n.velocity,s=n.bounds,o=n.setup,i=o.disabled,a=o.velocityAnimation,l=a.disabled,c=!l&&!i&&e;return!(!c||!t||!s)};function cN(n,e){var t=n.setup.velocityAnimation,s=t.animationTime,o=t.maxAnimationTime,i=t.inertia;return Math.min(s*Math.max(1,Math.abs(e/i)),o)}function dm(n,e,t,s,o,i,a,l,c,d){if(o){if(e>a&&t>a){var u=a+(n-a)*d;return u>c?c:u<a?a:u}if(e<i&&t<i){var u=i+(n-i)*d;return u<l?l:u>i?i:u}}return s?e:mr(n,i,a,o)}function dN(n){var e=1,t=n.offsetWidth/window.innerWidth;return Number.isNaN(t)?e:Math.min(e,t)}var hl=function(n,e,t){var s=0,o=n*t;return Number.isNaN(o)?s:n<0?Math.max(o,-e):Math.min(o,e)};function uN(n,e,t){var s,o,i=aN(n);if(i){var a=n.lastMousePosition,l=n.velocityTime,c=n.setup,d=n.wrapperComponent,u=c.velocityAnimation,f=u.maxStrengthMouse,m=u.maxStrengthTouch,p=u.sensitivityTouch,h=u.sensitivityMouse,g=Date.now();if(a&&l&&d){var x=dN(d),b=(s={},s[hs.TOUCH]=p,s[hs.MOUSE]=h,s)[t],w=(o={},o[hs.TOUCH]=m,o[hs.MOUSE]=f,o)[t],v=e.x-a.x,S=e.y-a.y,j=hl(v/x,w,b),k=hl(S/x,w,b),C=g-l,N=v*v+S*S,_=hl(Math.sqrt(N)/C,w,b);n.velocity={velocityX:j,velocityY:k,total:_}}n.lastMousePosition=e,n.velocityTime=g}}function fN(n){var e=n.velocity,t=n.bounds,s=n.setup,o=n.wrapperComponent,i=lN(n);if(!(!i||!e||!t||!o)){var a=e.velocityX,l=e.velocityY,c=e.total,d=t.maxPositionX,u=t.minPositionX,f=t.maxPositionY,m=t.minPositionY,p=s.limitToBounds,h=s.autoAlignment,g=s.zoomAnimation,x=s.panning,b=x.lockAxisY,w=x.lockAxisX,v=g.animationType,S=h.sizeX,j=h.sizeY,k=h.velocityAlignmentTime,C=k,N=cN(n,c),_=Math.max(N,C),P=_s(n,S),A=_s(n,j),T=P*o.offsetWidth/100,E=A*o.offsetHeight/100,R=d+T,$=u-T,I=f+E,M=m-E,D=n.state,O=new Date().getTime();$1(n,v,_,function(L){var F=n.state,z=F.scale,W=F.positionX,U=F.positionY,H=new Date().getTime()-O,K=H/C,V=R1[h.animationType],Y=1-V(Math.min(1,K)),G=1-L,J=W+a*G,Q=U+l*G,X=dm(J,D.positionX,W,w,p,u,d,$,R,Y),Z=dm(Q,D.positionY,U,b,p,m,f,M,I,Y);if(W!==J||U!==Q){n.setState(z,X,Z);var te=n.props.onPanning;te&&te(Xe(n),{})}})}}function um(n,e){var t=n.state,s=t.scale,o=t.positionX,i=t.positionY;n.panStartPosition={x:o,y:i},Sn(n),ko(n,s),window.TouchEvent!==void 0&&e instanceof TouchEvent?oN(n,e):sN(n,e)}function O1(n,e){var t=n.state.scale,s=n.setup,o=s.minScale,i=s.autoAlignment,a=i.disabled,l=i.sizeX,c=i.sizeY,d=i.animationTime,u=i.animationType,f=a||t<o||!l&&!c;if(!f){var m=rN(n);m&&As(n,m,d,u)}}function fm(n,e,t,s){var o=n.startCoords,i=n.setup,a=i.autoAlignment,l=a.sizeX,c=a.sizeY;if(o){var d=iN(n,e,t),u=d.x,f=d.y,m=_s(n,l),p=_s(n,c);uN(n,{x:u,y:f},s),M1(n,u,f,m,p)}}function mN(n,e){if(n.isPanning){var t=n.velocity,s=n.wrapperComponent,o=n.contentComponent;n.isPanning=!1;var i=n.state,a=i.positionX,l=i.positionY,c=i.scale,d=n.panStartPosition;if(n.panStartPosition=null,d){var u=a-d.x,f=l-d.y;if(u*u+f*f<=25)return}n.isAnimating=!1,n.animation=null;var m=(s==null?void 0:s.offsetWidth)||0,p=(s==null?void 0:s.offsetHeight)||0,h=((o==null?void 0:o.offsetWidth)||0)*c,g=((o==null?void 0:o.offsetHeight)||0)*c,x=!n.setup.limitToBounds||m<h||p<g,b=!e&&t&&t.total>.1&&x;b?fN(n):O1(n)}}function Pd(n,e,t,s){var o=n.setup,i=o.minScale,a=o.maxScale,l=o.limitToBounds,c=Wr(Ds(e,2),i,a,0,!1),d=ko(n,c),u=Ta(n,t,s,c,d,l),f=u.x,m=u.y;return{scale:c,positionX:f,positionY:m}}function Ad(n,e,t){var s=n.state.scale,o=n.wrapperComponent,i=n.setup,a=i.minScale,l=i.maxScale,c=i.limitToBounds,d=i.zoomAnimation,u=d.disabled,f=d.animationTime,m=d.animationType,p=s>=a&&s<=l,h=u||p;if((s>=1||c)&&O1(n),!(h||!o||!n.mounted)){var g=e||o.offsetWidth/2,x=t||o.offsetHeight/2,b=s<a?a:l,w=Pd(n,b,g,x);w&&As(n,w,f,m)}}var pn=function(){return pn=Object.assign||function(e){for(var t,s=1,o=arguments.length;s<o;s++){t=arguments[s];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},pn.apply(this,arguments)};function mm(n,e,t){for(var s=0,o=e.length,i;s<o;s++)(i||!(s in e))&&(i||(i=Array.prototype.slice.call(e,0,s)),i[s]=e[s]);return n.concat(i||Array.prototype.slice.call(e))}var gl={scale:1,positionX:0,positionY:0},Os={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"}},gc={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},D1=function(n){var e,t,s,o,i,a,l,c,d,u=Math.max((e=n.minScale)!==null&&e!==void 0?e:Os.minScale,1e-7),f=(t=n.maxScale)!==null&&t!==void 0?t:Os.maxScale,m=(s=n.initialScale)!==null&&s!==void 0?s:gl.scale,p=Math.min(Math.max(m,u),f),h=mr((o=n.initialPositionX)!==null&&o!==void 0?o:gl.positionX,(i=n.minPositionX)!==null&&i!==void 0?i:-1/0,(a=n.maxPositionX)!==null&&a!==void 0?a:1/0,n.minPositionX!=null||n.maxPositionX!=null),g=mr((l=n.initialPositionY)!==null&&l!==void 0?l:gl.positionY,(c=n.minPositionY)!==null&&c!==void 0?c:-1/0,(d=n.maxPositionY)!==null&&d!==void 0?d:1/0,n.minPositionY!=null||n.maxPositionY!=null);return{previousScale:p,scale:p,positionX:h,positionY:g}},pm=function(n){var e=pn({},Os);return Object.keys(n).forEach(function(t){var s=t,o=typeof n[s]<"u",i=typeof Os[s]<"u";if(i&&o){var a=Object.prototype.toString.call(Os[s]),l=a==="[object Object]",c=a==="[object Array]";l?e[s]=pn(pn({},Os[s]),n[s]):c?e[s]=mm(mm([],Os[s],!0),n[s]):e[s]=n[s]}}),e.minScale<=0&&(e.minScale=1e-7),e},L1=function(n,e,t){var s=n.state.scale,o=n.wrapperComponent,i=n.setup,a=i.maxScale,l=i.minScale,c=i.zoomAnimation,d=i.smooth,u=c.size;if(!o)throw new Error("Wrapper is not mounted");var f=d?s*Math.exp(e*t):s+e*t,m=Wr(Ds(f,3),l,a,u,!1);return m};function z1(n,e,t,s,o){var i,a,l=n.wrapperComponent,c=n.state,d=c.scale,u=c.positionX,f=c.positionY,m=n.setup.zoomAnimation;if(!l)return console.error("No WrapperComponent found");var p=m.disabled?0:s,h=l.offsetWidth,g=l.offsetHeight,x=(h/2-u)/d,b=(g/2-f)/d,w=L1(n,e,t),v=Pd(n,w,x,b);if(!v)return console.error("Error during zoom event. New transformation state was not calculated.");var S=n.props,j=S.onZoomStart,k=S.onZoom,C=S.onZoomStop,N=new MouseEvent("mousemove",{bubbles:!0}),_=Xe(n);Qe(_,N,j),Qe(_,N,k),As(n,v,p,o);var P=(a=(i=l.ownerDocument)===null||i===void 0?void 0:i.defaultView)!==null&&a!==void 0?a:typeof window<"u"?window:null;P&&P.setTimeout(function(){n.mounted&&Qe(Xe(n),N,C)},p)}function F1(n,e,t,s){var o,i,a=n.setup,l=n.wrapperComponent,c=n.contentComponent,d=a.limitToBounds,u=a.centerOnInit,f=D1(n.props),m=n.state,p=m.scale,h=m.positionX,g=m.positionY;if(l){var x=f.positionX,b=f.positionY;if(u&&c){var w=Rd(f.scale,l,c);x=w.positionX,b=w.positionY}var v=Ed(n,f.scale),S=Ur(x,b,v,d,0,0,l),j={scale:f.scale,positionX:S.x,positionY:S.y};if(!(p===f.scale&&h===f.positionX&&g===f.positionY)){s==null||s();var k=n.props,C=k.onZoomStart,N=k.onZoom,_=k.onZoomStop,P=new MouseEvent("mousemove",{bubbles:!0}),A=Xe(n);Qe(A,P,C),Qe(A,P,N),As(n,j,e,t);var T=(i=(o=l.ownerDocument)===null||o===void 0?void 0:o.defaultView)!==null&&i!==void 0?i:typeof window<"u"?window:null;T&&T.setTimeout(function(){n.mounted&&Qe(Xe(n),P,_)},e)}}}function pN(n,e,t,s){var o=n.getBoundingClientRect(),i=e.getBoundingClientRect(),a=t.getBoundingClientRect(),l=i.x*s.scale,c=i.y*s.scale;return{x:(o.x-a.x+l)/s.scale,y:(o.y-a.y+c)/s.scale}}function hN(n,e,t,s,o){s===void 0&&(s=0),o===void 0&&(o=0);var i=n.wrapperComponent,a=n.contentComponent,l=n.state,c=n.setup,d=c.limitToBounds,u=c.minScale,f=c.maxScale;if(!i||!a)return l;var m=i.getBoundingClientRect(),p=e.getBoundingClientRect(),h=pN(e,i,a,l),g=h.x,x=h.y,b=p.width/l.scale,w=p.height/l.scale,v=i.offsetWidth/b,S=i.offsetHeight/w,j=Wr(t||Math.min(v,S),u,f,0,!1),k=(m.width-b*j)/2,C=(m.height-w*j)/2,N=(m.left-g)*j+k+s,_=(m.top-x)*j+C+o,P=Ed(n,j),A=Ur(N,_,P,d,0,0,i),T=A.x,E=A.y;return{positionX:T,positionY:E,scale:j}}var gN=function(n){return function(e,t,s){e===void 0&&(e=.5),t===void 0&&(t=300),s===void 0&&(s="easeOut"),z1(n,1,e,t,s)}},xN=function(n){return function(e,t,s){e===void 0&&(e=.5),t===void 0&&(t=300),s===void 0&&(s="easeOut"),z1(n,-1,e,t,s)}},bN=function(n){return function(e,t,s,o,i){o===void 0&&(o=300),i===void 0&&(i="easeOut");var a=n.state,l=a.positionX,c=a.positionY,d=a.scale,u=n.wrapperComponent,f=n.contentComponent,m=n.setup.disabled;if(!(m||!u||!f)){var p={positionX:Number.isNaN(e)?l:e,positionY:Number.isNaN(t)?c:t,scale:Number.isNaN(s)?d:s};As(n,p,o,i)}}},vN=function(n){return function(e,t){e===void 0&&(e=200),t===void 0&&(t="easeOut"),F1(n,e,t)}},yN=function(n){return function(e,t,s){t===void 0&&(t=200),s===void 0&&(s="easeOut");var o=n.state,i=n.wrapperComponent,a=n.contentComponent;if(i&&a){var l=Rd(e||o.scale,i,a);As(n,l,t,s)}}},wN=function(n){return function(e,t,s,o,i,a){s===void 0&&(s=600),o===void 0&&(o="easeOut"),i===void 0&&(i=0),a===void 0&&(a=0),Sn(n);var l=n.wrapperComponent,c=typeof e=="string"?document.getElementById(e):e;if(l&&c&&l.contains(c)){var d=hN(n,c,t,i,a);As(n,d,s,o)}}},xc=function(n){return{instance:n,state:n.state,zoomIn:gN(n),zoomOut:xN(n),setTransform:bN(n),resetTransform:vN(n),centerView:yN(n),zoomToElement:wN(n)}},jN=function(n){return{instance:n,state:n.state}},Xe=function(n){var e={};return Object.assign(e,jN(n)),Object.assign(e,xc(n)),e},xl=!1;function bl(){try{var n={get passive(){return xl=!0,!1}};return n}catch{return xl=!1,xl}}var xi=".".concat(gc.wrapperClass),Hr=function(n,e){return e.some(function(t){return n.matches("".concat(xi," ").concat(t,", ").concat(xi," .").concat(t,", ").concat(xi," ").concat(t," *, ").concat(xi," .").concat(t," *"))})},pr=function(n){n&&clearTimeout(n)},SN=function(n){return Number.parseFloat(n.toFixed(8))},B1=function(n,e,t){var s=SN(t);return"translate(".concat(n,"px, ").concat(e,"px) scale(").concat(s,")")},Rd=function(n,e,t){var s=t.offsetWidth*n,o=t.offsetHeight*n,i=(e.offsetWidth-s)/2,a=(e.offsetHeight-o)/2;return{scale:n,positionX:i,positionY:a}};function NN(n,e){n!=null&&(typeof n=="function"?n(e):n.current=e)}function kN(n){return function(e){n.forEach(function(t){typeof t=="function"?t(e):t!=null&&(t.current=e)})}}var U1=function(n,e){var t=n.setup.wheel,s=t.disabled,o=t.wheelDisabled,i=t.touchPadDisabled,a=t.excluded,l=n.isInitialized,c=n.isPanning,d=e.target,u=l&&!c&&!s&&d;if(!u||o&&!e.ctrlKey||i&&e.ctrlKey)return!1;var f=Hr(d,a);if(f)return!1;var m=n.isPressingKeys(n.setup.wheel.activationKeys);return!!m},CN=function(n,e){var t=n.setup,s=t.disabled,o=t.trackPadPanning,i=o.activationKeys,a=o.excluded;if(!n.wrapperComponent||!n.contentComponent||s||o.disabled||e.ctrlKey)return!1;var l=U1(n,e);if(l)return!1;var c=e.target,d=Hr(c,a);if(d)return!1;var u=n.isPressingKeys(i);return!!u},_N=function(n){return n?n.deltaY<0?1:-1:0};function TN(n,e){var t=_N(n),s=z5(e,t);return s}function W1(n,e,t){var s=e.getBoundingClientRect(),o=0,i=0;if("clientX"in n)o=(n.clientX-s.left)/t,i=(n.clientY-s.top)/t;else{var a=n.touches[0];o=(a.clientX-s.left)/t,i=(a.clientY-s.top)/t}return Number.isNaN(o)||Number.isNaN(i)?(console.error("No mouse or touch offset found"),{x:0,y:0}):{x:o,y:i}}var EN=function(n,e,t,s,o){var i=n.state.scale,a=n.wrapperComponent,l=n.setup,c=l.maxScale,d=l.minScale,u=l.zoomAnimation,f=l.disablePadding,m=u.size,p=u.disabled;if(!a)throw new Error("Wrapper is not mounted");var h=i+e*t,g=s?!1:!p,x=Wr(h,d,c,m,g&&!f);return x},H1=function(n,e){var t=n.previousWheelEvent,s=n.state.scale,o=n.setup,i=o.maxScale,a=o.minScale;return t?s<i||s>a||Math.sign(t.deltaY)!==Math.sign(e.deltaY)||t.deltaY>0&&t.deltaY<e.deltaY||t.deltaY<0&&t.deltaY>e.deltaY||Math.sign(t.deltaY)!==Math.sign(e.deltaY):!1},PN=function(n,e){var t=n.setup.pinch,s=t.disabled,o=t.excluded,i=n.isInitialized,a=e.target,l=i&&!s&&a;if(!l)return!1;var c=Hr(a,o);return!c},AN=function(n){var e=n.setup.pinch.disabled,t=n.isInitialized,s=n.pinchStartDistance,o=t&&!e&&s!==null;return!!o},RN=function(n,e,t){var s=t.getBoundingClientRect(),o=n.touches,i=o[0].clientX-s.left,a=o[0].clientY-s.top,l=o[1].clientX-s.left,c=o[1].clientY-s.top;return{x:(i+l)/2/e,y:(a+c)/2/e}},K1=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))},IN=5,$N=function(n,e){var t=n.pinchStartScale,s=n.pinchStartDistance,o=n.setup,i=o.maxScale,a=o.minScale,l=o.zoomAnimation,c=o.disablePadding,d=o.pinch,u=l.size,f=l.disabled,m=d.step;if(!t||s===null)throw new Error("Pinch touches distance was not provided");if(e<0)return n.state.scale;var p=e/s,h=p*t,g=(h-t)*(m/IN),x=t+g,b=x===1/0?0:Ds(x,10);return Wr(b,a,i,u,!f&&!c)},q1=160,V1=100,MN=function(n,e){var t=n.props,s=t.onWheelStart,o=t.onZoomStart;n.wheelStopEventTimer||(Sn(n),Qe(Xe(n),e,s),Qe(Xe(n),e,o))},ON=function(n,e){var t=n.props,s=t.onWheel,o=t.onZoom,i=n.contentComponent,a=n.setup,l=n.state,c=l.scale,d=a.limitToBounds,u=a.centerZoomedOut,f=a.zoomAnimation,m=a.wheel,p=a.disablePadding,h=a.smooth,g=f.size,x=f.disabled,b=m.step;if(!i)throw new Error("Component not mounted");e.cancelable&&e.preventDefault(),e.stopPropagation();var w=TN(e,null),v=h?b*Math.abs(e.deltaY):b,S=EN(n,w,v,!e.ctrlKey);if(c!==S){var j=ko(n,S),k=W1(e,i,c),C=x||g===0||u||p,N=d&&C,_=Ta(n,k.x,k.y,S,j,N),P=_.x,A=_.y;n.previousWheelEvent=e,n.setState(S,P,A),Qe(Xe(n),e,s),Qe(Xe(n),e,o)}},DN=function(n,e){var t=n.props,s=t.onWheelStop,o=t.onZoomStop;pr(n.wheelAnimationTimer),n.wheelAnimationTimer=setTimeout(function(){n.mounted&&(Ad(n,e.x,e.y),n.wheelAnimationTimer=null)},V1);var i=H1(n,e);i&&(pr(n.wheelStopEventTimer),n.wheelStopEventTimer=setTimeout(function(){n.mounted&&(n.wheelStopEventTimer=null,Qe(Xe(n),e,s),Qe(Xe(n),e,o))},q1))},LN=function(n,e){var t=n.props,s=t.onWheelStart,o=t.onPanningStart;n.wheelStopEventTimer||(Sn(n),Qe(Xe(n),e,s),Qe(Xe(n),e,o))},zN=function(n,e){var t=n.props,s=t.onWheelStop,o=t.onPanningStop;pr(n.wheelAnimationTimer),n.wheelAnimationTimer=setTimeout(function(){n.mounted&&(Ad(n,e.x,e.y),n.wheelAnimationTimer=null)},V1);var i=H1(n,e);i&&(pr(n.wheelStopEventTimer),n.wheelStopEventTimer=setTimeout(function(){n.mounted&&(n.wheelStopEventTimer=null,Qe(Xe(n),e,s),Qe(Xe(n),e,o))},q1))},G1=function(n){for(var e=0,t=0,s=0;s<2;s+=1)e+=n.touches[s].clientX,t+=n.touches[s].clientY;var o=e/2,i=t/2;return{x:o,y:i}},FN=function(n,e){var t=K1(e);n.pinchStartDistance=t,n.lastDistance=t,n.pinchStartScale=n.state.scale,n.isPanning=!1,n.isPinching=!0,n.pinchPreviousCenter=G1(e),Sn(n)},BN=function(n,e){var t=n.contentComponent,s=n.pinchStartDistance,o=n.wrapperComponent,i=n.pinchPreviousCenter,a=n.state.scale,l=n.setup,c=l.limitToBounds,d=l.centerZoomedOut,u=l.zoomAnimation,f=l.autoAlignment,m=l.pinch,p=l.panning,h=u.disabled,g=u.size,x=m.allowPanning;if(!(s===null||!t)){var b=RN(e,a,t);if(!(!Number.isFinite(b.x)||!Number.isFinite(b.y))){var w=K1(e),v=$N(n,w),S=G1(e),j=a/v,k=(S.x-((i==null?void 0:i.x)||0))*j,C=(S.y-((i==null?void 0:i.y)||0))*j;if(!(v===a&&k===0&&C===0)){n.pinchPreviousCenter=S;var N=ko(n,v),_=h||g===0||d,P=c&&_,A=Ta(n,b.x,b.y,v,N,P),T=A.x,E=A.y;if(n.pinchMidpoint=b,n.lastDistance=w,p.disabled||!x)n.setState(v,T,E);else{var R=f.sizeX,$=f.sizeY,I=_s(n,R,v),M=_s(n,$,v),D=T+k,O=E+C,L=Ur(D,O,N,c,I,M,o),F=L.x,z=L.y;n.setState(v,F,z)}}}}},UN=function(n){var e=n.pinchMidpoint;n.velocity=null,n.lastDistance=null,n.pinchMidpoint=null,n.pinchStartScale=null,n.pinchStartDistance=null,n.isPinching=!1,Ad(n,e==null?void 0:e.x,e==null?void 0:e.y)},Y1=function(n,e){var t=n.props.onZoomStop,s=n.setup.doubleClick.animationTime;pr(n.doubleClickStopEventTimer),n.doubleClickStopEventTimer=setTimeout(function(){n.doubleClickStopEventTimer=null,Qe(Xe(n),e,t)},s)},WN=function(n,e){var t=n.props,s=t.onZoomStart,o=t.onZoom,i=n.setup.doubleClick,a=i.animationTime,l=i.animationType;Qe(Xe(n),e,s),F1(n,a,l,function(){return Qe(Xe(n),e,o)}),Y1(n,e)};function HN(n,e){return n==="toggle"?e===1?1:-1:n==="zoomOut"?-1:1}function KN(n,e){var t=n.setup,s=n.doubleClickStopEventTimer,o=n.state,i=n.contentComponent,a=o.scale,l=n.props,c=l.onZoomStart,d=l.onZoom,u=t.doubleClick,f=u.disabled,m=u.mode,p=u.step,h=u.animationTime,g=u.animationType;if(!f&&!s){if(m==="reset")return WN(n,e);if(!i)return console.error("No ContentComponent found");var x=HN(m,n.state.scale),b=L1(n,x,p);if(a!==b){Qe(Xe(n),e,c);var w=W1(e,i,a),v=Pd(n,b,w.x,w.y);if(!v)return console.error("Error during zoom event. New transformation state was not calculated.");Qe(Xe(n),e,d),As(n,v,h,g),Y1(n,e)}}}var qN=function(n,e){var t=n.isInitialized,s=n.setup,o=n.wrapperComponent,i=s.doubleClick,a=i.disabled,l=i.excluded,c=e.target,d=o==null?void 0:o.contains(c),u=t&&c&&d&&!a;if(!u)return!1;var f=Hr(c,l);return!f},VN=(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&&ko(t,t.state.scale),t.setup=pm(s)},this.initializeWindowEvents=function(){var s,o,i,a,l=bl(),c=(s=t.wrapperComponent)===null||s===void 0?void 0:s.ownerDocument,d=c==null?void 0:c.defaultView;(o=t.wrapperComponent)===null||o===void 0||o.addEventListener("wheel",t.onWheelPanning,l),(i=t.wrapperComponent)===null||i===void 0||i.addEventListener("keyup",t.setKeyUnPressed,l),(a=t.wrapperComponent)===null||a===void 0||a.addEventListener("keydown",t.setKeyPressed,l),d==null||d.addEventListener("mousedown",t.onPanningStart,l),d==null||d.addEventListener("mousemove",t.onPanning,l),d==null||d.addEventListener("mouseup",t.onPanningStop,l),c==null||c.addEventListener("mouseleave",t.clearPanning,l),d==null||d.addEventListener("keyup",t.setKeyUnPressed,l),d==null||d.addEventListener("keydown",t.setKeyPressed,l),d==null||d.addEventListener("blur",t.handleWindowBlur)},this.cleanupWindowEvents=function(){var s,o,i,a,l,c=bl(),d=(s=t.wrapperComponent)===null||s===void 0?void 0:s.ownerDocument,u=d==null?void 0:d.defaultView;u==null||u.removeEventListener("mousedown",t.onPanningStart,c),u==null||u.removeEventListener("mousemove",t.onPanning,c),u==null||u.removeEventListener("mouseup",t.onPanningStop,c),d==null||d.removeEventListener("mouseleave",t.clearPanning,c),u==null||u.removeEventListener("keyup",t.setKeyUnPressed,c),u==null||u.removeEventListener("keydown",t.setKeyPressed,c),u==null||u.removeEventListener("blur",t.handleWindowBlur),document.removeEventListener("mouseleave",t.clearPanning,c),(o=t.wrapperComponent)===null||o===void 0||o.removeEventListener("wheel",t.onWheelPanning,c),(i=t.wrapperComponent)===null||i===void 0||i.removeEventListener("keyup",t.setKeyUnPressed,c),(a=t.wrapperComponent)===null||a===void 0||a.removeEventListener("keydown",t.setKeyPressed,c),Sn(t),(l=t.observer)===null||l===void 0||l.disconnect()},this.handleInitializeWrapperEvents=function(s){var o=bl();s.addEventListener("wheel",t.onWheelZoom,o),s.addEventListener("dblclick",t.onDoubleClick,o),s.addEventListener("touchstart",t.onTouchPanningStart,o),s.addEventListener("touchmove",t.onTouchPanning,o),s.addEventListener("touchend",t.onTouchPanningStop,o)},this.handleInitialize=function(s){var o=t.setup.centerOnInit;t.applyTransformation(),t.onInitCallbacks.forEach(function(i){return i(Xe(t))}),o&&(t.setCenter(),t.observer=new ResizeObserver(function(){var i,a=s.offsetWidth,l=s.offsetHeight;(a>0||l>0)&&(t.onInitCallbacks.forEach(function(c){return c(Xe(t))}),t.setCenter(),(i=t.observer)===null||i===void 0||i.disconnect())}),setTimeout(function(){var i;(i=t.observer)===null||i===void 0||i.disconnect()},5e3),t.observer.observe(s))},this.onWheelZoom=function(s){var o=t.setup.disabled;if(!o){t.syncModifierKeys(s);var i=U1(t,s);i&&(MN(t,s),ON(t,s),DN(t,s))}},this.onWheelPanning=function(s){var o=t.props.onPanning,i=t.setup.trackPadPanning,a=i.lockAxisX,l=i.lockAxisY;t.syncModifierKeys(s);var c=CN(t,s);if(c){s.cancelable&&s.preventDefault(),s.stopPropagation();var d=t.state,u=d.positionX,f=d.positionY,m=u-s.deltaX,p=f-s.deltaY,h=a?u:m,g=l?f:p,x=t.setup.autoAlignment,b=x.sizeX,w=x.sizeY,v=_s(t,b),S=_s(t,w);h===u&&g===f||(LN(t,s),M1(t,h,g,v,S),Qe(Xe(t),s,o),zN(t,s))}},this.onPanningStart=function(s){var o=t.setup.disabled,i=t.props.onPanningStart;if(!o){t.syncModifierKeys(s);var a=lm(t,s);if(a){var l=t.isPressingKeys(t.setup.panning.activationKeys);l&&(s.button===0&&!t.setup.panning.allowLeftClickPan||s.button===1&&!t.setup.panning.allowMiddleClickPan||s.button===2&&!t.setup.panning.allowRightClickPan||(s.cancelable&&s.preventDefault(),s.stopPropagation(),Sn(t),um(t,s),Qe(Xe(t),s,i)))}}},this.onPanning=function(s){var o=t.setup.disabled,i=t.props.onPanning;if(!o){if(t.syncModifierKeys(s),t.isPanning&&s.buttons===0){t.clearPanning(s);return}var a=cm(t);if(a){var l=t.isPressingKeys(t.setup.panning.activationKeys);l&&(s.cancelable&&s.preventDefault(),s.stopPropagation(),fm(t,s.clientX,s.clientY,hs.MOUSE),Qe(Xe(t),s,i))}}},this.onPanningStop=function(s){var o=t.setup.panning.velocityDisabled,i=t.props.onPanningStop;t.isPanning&&(mN(t,o),Qe(Xe(t),s,i))},this.onPinchStart=function(s){var o=t.setup.disabled,i=t.props.onPinchStart;if(!o){var a=PN(t,s);a&&(FN(t,s),Sn(t),Qe(Xe(t),s,i))}},this.onPinch=function(s){var o=t.setup.disabled,i=t.props.onPinch;if(!o){var a=AN(t);a&&(s.cancelable&&s.preventDefault(),s.stopPropagation(),BN(t,s),Qe(Xe(t),s,i))}},this.onPinchStop=function(s){var o=t.props.onPinchStop;t.pinchStartScale&&(UN(t),Qe(Xe(t),s,o))},this.onTouchPanningStart=function(s){var o=t.setup,i=o.disabled,a=o.doubleClick,l=t.props.onPanningStart;if(!i){var c=!(a!=null&&a.disabled),d=t.lastTouch&&+new Date-t.lastTouch<200;if(c&&d&&s.touches.length===1)t.onDoubleClick(s);else{t.lastTouch=+new Date,Sn(t);var u=s.touches,f=u.length===1,m=u.length===2,p=lm(t,s);if(f){if(!p)return;Sn(t),um(t,s),Qe(Xe(t),s,l)}m&&t.onPinchStart(s)}}},this.onTouchPanning=function(s){var o=t.setup.disabled,i=t.props.onPanning;if(t.isPanning&&s.touches.length===1){if(o)return;var a=cm(t);if(!a)return;s.cancelable&&s.preventDefault(),s.stopPropagation();var l=s.touches[0];fm(t,l.clientX,l.clientY,hs.TOUCH),Qe(Xe(t),s,i)}else s.touches.length>1&&t.onPinch(s)},this.onTouchPanningStop=function(s){t.onPanningStop(s),t.onPinchStop(s)},this.onDoubleClick=function(s){var o=t.setup.disabled;if(!o){var i=qN(t,s);i&&KN(t,s)}},this.clearPanning=function(s){t.isPanning&&t.onPanningStop(s)},this.handleWindowBlur=function(){t.pressedKeys={},t.isPanning&&(t.isPanning=!1,t.startCoords=null)},this.syncModifierKeys=function(s){var o=s.ctrlKey,i=s.metaKey,a=s.shiftKey,l=s.altKey;typeof o=="boolean"&&(t.pressedKeys.Control=o),typeof i=="boolean"&&(t.pressedKeys.Meta=i),typeof a=="boolean"&&(t.pressedKeys.Shift=a),typeof l=="boolean"&&(t.pressedKeys.Alt=l)},this.setKeyPressed=function(s){t.pressedKeys[s.key]=!0},this.setKeyUnPressed=function(s){t.pressedKeys[s.key]=!1},this.isPressingKeys=function(s){return typeof s=="function"?s(Object.entries(t.pressedKeys).filter(function(o){var i=o[1];return i}).map(function(o){var i=o[0];return i})):s.length?!!s.every(function(o){return t.pressedKeys[o]}):!0},this.setCenter=function(){if(t.wrapperComponent&&t.contentComponent){var s=Rd(t.state.scale,t.wrapperComponent,t.contentComponent);t.setState(s.scale,s.positionX,s.positionY)}},this.handleTransformStyles=function(s,o,i){return t.props.customTransform?t.props.customTransform(s,o,i):B1(s,o,i)},this.getContext=function(){return Xe(t)},this.applyTransformation=function(){if(!(!t.mounted||!t.contentComponent)){var s=t.state,o=s.scale,i=s.positionX,a=s.positionY,l=t.handleTransformStyles(i,a,o);t.props.detached||(t.contentComponent.style.transform=l),t.onTransformCallbacks.forEach(function(c){return c({scale:o,positionX:i,positionY:a,previousScale:t.state.previousScale,ref:Xe(t)})})}},this.setState=function(s,o,i){var a=t.props.onTransform;if(!Number.isNaN(s)&&!Number.isNaN(o)&&!Number.isNaN(i)){var l=Math.max(s,1e-7);l!==t.state.scale&&(t.state.previousScale=t.state.scale,t.state.scale=l),t.state.positionX=o,t.state.positionY=i,t.applyTransformation();var c=Xe(t);t.onChangeCallbacks.forEach(function(d){return d(c)}),Qe(c,{scale:t.state.scale,positionX:o,positionY:i},a)}else console.error("Detected NaN set state values")},this.onTransform=function(s){return t.onTransformCallbacks.has(s)||t.onTransformCallbacks.add(s),function(){t.onTransformCallbacks.delete(s)}},this.onChange=function(s){return t.onChangeCallbacks.has(s)||t.onChangeCallbacks.add(s),function(){t.onChangeCallbacks.delete(s)}},this.onInit=function(s){return t.onInitCallbacks.has(s)||t.onInitCallbacks.add(s),function(){t.onInitCallbacks.delete(s)}},this.init=function(s,o){t.cleanupWindowEvents(),t.wrapperComponent=s,t.contentComponent=o,ko(t,t.state.scale),t.handleInitializeWrapperEvents(s),t.handleInitialize(o),t.initializeWindowEvents(),t.isInitialized=!0;var i=Xe(t);Qe(i,void 0,t.props.onInit),NN(t.props.ref,i)},this.props=e,this.setup=pm(this.props),this.state=D1(this.props)}return n})(),Ea=be.createContext(null),GN=function(n,e){return typeof n=="function"?n(e):n},YN=be.forwardRef(function(n,e){var t=y.useRef(new VN(n)).current,s=GN(n.children,xc(t));return y.useImperativeHandle(e,function(){return xc(t)},[t]),y.useEffect(function(){t.update(n)},[t,n]),r.jsx(Ea.Provider,pn({value:t},{children:s}))});be.forwardRef(function(n,e){var t=y.useRef(null),s=y.useContext(Ea);return y.useEffect(function(){return s.onChange(function(o){if(t.current){var i=0,a=0;t.current.style.transform=s.handleTransformStyles(i,a,1/o.instance.state.scale)}})},[s]),r.jsx("div",pn({},n,{ref:kN([t,e])}))});function XN(n,e){e===void 0&&(e={});var t=e.insertAt;if(!(typeof document>"u")){var s=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css",t==="top"&&s.firstChild?s.insertBefore(o,s.firstChild):s.appendChild(o),o.styleSheet?o.styleSheet.cssText=n:o.appendChild(document.createTextNode(n))}}var JN=`.transform-component-module_wrapper__SPB86 {
9
- position: relative;
10
- width: -moz-fit-content;
11
- width: fit-content;
12
- height: -moz-fit-content;
13
- height: fit-content;
14
- overflow: hidden;
15
- -webkit-touch-callout: none; /* iOS Safari */
16
- -webkit-user-select: none; /* Safari */
17
- -khtml-user-select: none; /* Konqueror HTML */
18
- -moz-user-select: none; /* Firefox */
19
- -ms-user-select: none; /* Internet Explorer/Edge */
20
- user-select: none;
21
- margin: 0;
22
- padding: 0;
23
- transform: translate3d(0, 0, 0);
24
- }
25
- .transform-component-module_content__FBWxo {
26
- display: flex;
27
- flex-wrap: wrap;
28
- width: -moz-fit-content;
29
- width: fit-content;
30
- height: -moz-fit-content;
31
- height: fit-content;
32
- margin: 0;
33
- padding: 0;
34
- transform-origin: 0% 0%;
35
- }
36
- .transform-component-module_content__FBWxo img {
37
- pointer-events: none;
38
- }
39
- .transform-component-module_infiniteGrid__Z-aP3 {
40
- position: absolute;
41
- inset: 0;
42
- pointer-events: none;
43
- background-image: radial-gradient(
44
- circle,
45
- rgba(0, 0, 0, 0.12) 1px,
46
- transparent 1px
47
- );
48
- background-size: 20px 20px;
49
- background-position: 0 0;
50
- }
51
- `,vl={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo",infiniteGrid:"transform-component-module_infiniteGrid__Z-aP3"};XN(JN);var QN=function(n){var e=n.children,t=n.wrapperClass,s=t===void 0?"":t,o=n.contentClass,i=o===void 0?"":o,a=n.wrapperStyle,l=n.contentStyle,c=n.wrapperProps,d=c===void 0?{}:c,u=n.contentProps,f=u===void 0?{}:u,m=n.infinite,p=m===void 0?!1:m,h=y.useContext(Ea),g=h.init,x=h.cleanupWindowEvents,b=y.useRef(null),w=y.useRef(null),v=y.useRef(null);return y.useEffect(function(){var S=b.current,j=w.current;return S!==null&&j!==null&&g&&(g==null||g(S,j)),function(){x==null||x()}},[]),y.useEffect(function(){if(p){var S=v.current;if(S){var j=function(){var k=h.state,C=k.positionX,N=k.positionY;S.style.backgroundPosition="".concat(C,"px ").concat(N,"px")};return j(),h.onChange(j)}}},[p,h]),r.jsxs("div",pn({},d,{ref:b,className:"".concat(gc.wrapperClass," ").concat(vl.wrapper," ").concat(s),style:a},{children:[p&&r.jsx("div",{ref:v,className:vl.infiniteGrid,"aria-hidden":!0}),r.jsx("div",pn({},f,{ref:w,className:"".concat(gc.contentClass," ").concat(vl.content," ").concat(i),style:pn(pn({},l),{transform:B1(h.state.positionX,h.state.positionY,h.state.scale)})},{children:e}))]}))};function ZN(n,e){var t=Math.max(0,Math.min(n.x+n.width,e.x+e.width)-Math.max(n.x,e.x)),s=Math.max(0,Math.min(n.y+n.height,e.y+e.height)-Math.max(n.y,e.y));return t*s}function ek(n){var e=n.elementX,t=n.elementY,s=n.elementWidth,o=n.elementHeight,i=n.scale,a=n.positionX,l=n.positionY,c=n.viewportWidth,d=n.viewportHeight,u=n.margin,f=u===void 0?0:u,m=n.threshold,p=m===void 0?0:m,h={x:-f,y:-f,width:c+2*f,height:d+2*f},g={x:e*i+a,y:t*i+l,width:s*i,height:o*i};if(p<=0){var x=g.x<h.x+h.width&&g.x+g.width>h.x,b=g.y<h.y+h.height&&g.y+g.height>h.y;return x&&b}var w=g.width*g.height;if(w<=0)return!1;var v=ZN(h,g);return v/w>=p}be.forwardRef(function(n,e){var t=n.x,s=n.y,o=n.width,i=n.height,a=n.margin,l=a===void 0?0:a,c=n.threshold,d=c===void 0?0:c,u=n.placeholder,f=u===void 0?null:u,m=n.onShow,p=n.onHide,h=n.children,g=n.className,x=n.style,b=y.useContext(Ea),w=y.useState(!1),v=w[0],S=w[1],j=y.useRef(!1),k=y.useRef(m),C=y.useRef(p);return k.current=m,C.current=p,y.useEffect(function(){var N=function(){var A,T,E=b.wrapperComponent;if(E){var R=ek({elementX:t,elementY:s,elementWidth:o,elementHeight:i,scale:b.state.scale,positionX:b.state.positionX,positionY:b.state.positionY,viewportWidth:E.offsetWidth,viewportHeight:E.offsetHeight,margin:l,threshold:d});R!==j.current&&(j.current=R,S(R),R?(A=k.current)===null||A===void 0||A.call(k):(T=C.current)===null||T===void 0||T.call(C))}};N();var _=b.onChange(N),P;return b.wrapperComponent||(P=b.onInit(function(){return N()})),function(){_(),P==null||P()}},[b,t,s,o,i,l,d]),v?r.jsx("div",pn({ref:e,className:g,style:x},{children:h})):f?r.jsx(r.Fragment,{children:f}):null});const hm=8,tk=56;function Lo(n){const e=B.c(8),{label:t,disabled:s,onClick:o,children:i,className:a}=n;let l;e[0]!==a?(l=q("size-8 border border-white/10 bg-white/[0.06] text-white/75","hover:bg-white/10 hover:text-white focus-visible:ring-white/40","disabled:pointer-events-none disabled:opacity-30",a),e[0]=a,e[1]=l):l=e[1];let c;return e[2]!==i||e[3]!==s||e[4]!==t||e[5]!==o||e[6]!==l?(c=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:o,disabled:s,"aria-label":t,title:t,className:l,children:i}),e[2]=i,e[3]=s,e[4]=t,e[5]=o,e[6]=l,e[7]=c):c=e[7],c}function Id(n){const e=B.c(101),{open:t,images:s,initialIndex:o,onClose:i,onCloseComplete:a}=n,l=t===void 0?!0:t,c=Math.min(Math.max(o,0),Math.max(s.length-1,0)),[d,u]=y.useState(c),[f,m]=y.useState(100),p=y.useRef(null),h=y.useRef(null),g=s[d];let x;e[0]!==s.length?(x=fe=>{u(Math.min(Math.max(fe,0),s.length-1)),m(100)},e[0]=s.length,e[1]=x):x=e[1];const b=x;let w;e[2]!==b||e[3]!==d?(w=()=>b(d-1),e[2]=b,e[3]=d,e[4]=w):w=e[4];const v=w;let S;e[5]!==b||e[6]!==d?(S=()=>b(d+1),e[5]=b,e[6]=d,e[7]=S):S=e[7];const j=S;if(!g)return null;const k=s.length>1,C=d>0,N=d<s.length-1,_=f>100;let P;e[8]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{var fe;return(fe=p.current)==null?void 0:fe.zoomIn()},e[8]=P):P=e[8];const A=P;let T;e[9]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{var fe;return(fe=p.current)==null?void 0:fe.zoomOut()},e[9]=T):T=e[9];const E=T;let R;e[10]===Symbol.for("react.memo_cache_sentinel")?(R=()=>{var fe;return(fe=p.current)==null?void 0:fe.resetTransform()},e[10]=R):R=e[10];const $=R;let I;e[11]!==N||e[12]!==C||e[13]!==j||e[14]!==v?(I=fe=>{fe.key==="ArrowLeft"&&C?(fe.preventDefault(),v()):fe.key==="ArrowRight"&&N?(fe.preventDefault(),j()):fe.key==="+"||fe.key==="="?(fe.preventDefault(),A()):fe.key==="-"?(fe.preventDefault(),E()):fe.key==="0"&&(fe.preventDefault(),$())},e[11]=N,e[12]=C,e[13]=j,e[14]=v,e[15]=I):I=e[15];const M=I;let D;e[16]===Symbol.for("react.memo_cache_sentinel")?(D=fe=>{if(fe.pointerType==="mouse"||fe.isPrimary===!1){h.current=null;return}h.current={x:fe.clientX,y:fe.clientY}},e[16]=D):D=e[16];const O=D;let L;e[17]!==N||e[18]!==C||e[19]!==j||e[20]!==v?(L=fe=>{var ge;const Oe=h.current;h.current=null;const Ae=((ge=p.current)==null?void 0:ge.instance.state.scale)??1;if(!Oe||Ae>1.01)return;const Be=fe.clientX-Oe.x,oe=fe.clientY-Oe.y;Math.abs(Be)<tk||Math.abs(Be)<Math.abs(oe)||(Be>0&&C&&v(),Be<0&&N&&j())},e[17]=N,e[18]=C,e[19]=j,e[20]=v,e[21]=L):L=e[21];const F=L;let z;e[22]!==i?(z=fe=>{fe||i()},e[22]=i,e[23]=z):z=e[23];let W;e[24]!==a?(W=fe=>{fe||a==null||a()},e[24]=a,e[25]=W):W=e[25];let U,H,K;e[26]===Symbol.for("react.memo_cache_sentinel")?(U=q("flex h-[calc(100dvh-1rem)] w-[calc(100vw-1rem)] max-w-none flex-col gap-0 overflow-hidden rounded-xl border-white/10 bg-black p-0 text-white","sm:h-[min(820px,calc(100dvh-2rem))] sm:w-[min(1120px,calc(100vw-2rem))] sm:max-w-none"),H=r.jsx(os,{className:"sr-only",children:"Image viewer"}),K=r.jsx(rs,{className:"sr-only",children:"View and navigate images from this session."}),e[26]=U,e[27]=H,e[28]=K):(U=e[26],H=e[27],K=e[28]);let V;e[29]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-md bg-white/[0.06]",children:r.jsx(My,{className:"size-3.5 text-white/65","data-icon":"icon"})}),e[29]=V):V=e[29];const Y=g.label||g.alt||"Session image";let G;e[30]!==Y?(G=r.jsx("div",{className:"truncate text-xs font-medium text-white/90",children:Y}),e[30]=Y,e[31]=G):G=e[31];let J;e[32]!==k||e[33]!==s.length||e[34]!==d?(J=k&&r.jsxs("div",{className:"text-xs tabular-nums text-white/50",children:[d+1," of ",s.length]}),e[32]=k,e[33]=s.length,e[34]=d,e[35]=J):J=e[35];let Q;e[36]!==G||e[37]!==J?(Q=r.jsxs("div",{className:"min-w-0 flex-1",children:[G,J]}),e[36]=G,e[37]=J,e[38]=Q):Q=e[38];const X=f<=100;let Z;e[39]===Symbol.for("react.memo_cache_sentinel")?(Z=r.jsx(Xh,{className:"size-3.5","data-icon":"icon"}),e[39]=Z):Z=e[39];let te;e[40]!==X?(te=r.jsx(Lo,{label:"Zoom out",disabled:X,onClick:E,children:Z}),e[40]=X,e[41]=te):te=e[41];let ne;e[42]!==f?(ne=r.jsxs(ee,{type:"button",variant:"ghost",size:"sm",onClick:$,className:"min-w-12 px-1.5 font-mono text-xs tabular-nums text-white/60 hover:bg-white/[0.06] hover:text-white","aria-label":"Reset zoom",title:"Reset zoom",children:[f,"%"]}),e[42]=f,e[43]=ne):ne=e[43];const re=f>=hm*100;let ie;e[44]===Symbol.for("react.memo_cache_sentinel")?(ie=r.jsx(Ln,{className:"size-3.5","data-icon":"icon"}),e[44]=ie):ie=e[44];let ae;e[45]!==re?(ae=r.jsx(Lo,{label:"Zoom in",disabled:re,onClick:A,children:ie}),e[45]=re,e[46]=ae):ae=e[46];let se;e[47]===Symbol.for("react.memo_cache_sentinel")?(se=r.jsx("div",{className:"mx-1 h-5 w-px bg-white/10"}),e[47]=se):se=e[47];let ue;e[48]===Symbol.for("react.memo_cache_sentinel")?(ue=r.jsx(rt,{className:"size-4","data-icon":"icon"}),e[48]=ue):ue=e[48];let le;e[49]!==i?(le=r.jsx(Lo,{label:"Close image viewer",onClick:i,children:ue}),e[49]=i,e[50]=le):le=e[50];let de;e[51]!==te||e[52]!==ne||e[53]!==ae||e[54]!==le?(de=r.jsxs("div",{className:"flex items-center gap-1",children:[te,ne,ae,se,le]}),e[51]=te,e[52]=ne,e[53]=ae,e[54]=le,e[55]=de):de=e[55];let pe;e[56]!==Q||e[57]!==de?(pe=r.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b border-white/10 bg-black/20 px-2.5 sm:px-3",children:[V,Q,de]}),e[56]=Q,e[57]=de,e[58]=pe):pe=e[58];const he=g.id;let ce,ye,xe;e[59]===Symbol.for("react.memo_cache_sentinel")?(ce={mode:"toggle"},ye={step:.005},xe=(fe,Oe)=>m(Math.round(Oe.scale*100)),e[59]=ce,e[60]=ye,e[61]=xe):(ce=e[59],ye=e[60],xe=e[61]);let me,je;e[62]===Symbol.for("react.memo_cache_sentinel")?(me={width:"100%",height:"100%"},je={width:"100%",height:"100%"},e[62]=me,e[63]=je):(me=e[62],je=e[63]);const Se=g.src,Pe=g.alt,Re=_?"cursor-grab active:cursor-grabbing":"cursor-zoom-in";let Ie;e[64]!==Re?(Ie=q("max-h-full max-w-full select-none object-contain",Re),e[64]=Re,e[65]=Ie):Ie=e[65];let De;e[66]!==g.alt||e[67]!==g.src||e[68]!==Ie?(De=r.jsx(QN,{wrapperStyle:me,contentStyle:je,contentClass:"flex items-center justify-center p-3 sm:p-6",children:r.jsx("img",{src:Se,alt:Pe,draggable:!1,className:Ie})}),e[66]=g.alt,e[67]=g.src,e[68]=Ie,e[69]=De):De=e[69];let Le;e[70]!==g.id||e[71]!==De?(Le=r.jsx(YN,{ref:p,minScale:1,maxScale:hm,centerOnInit:!0,centerZoomedOut:!0,doubleClick:ce,wheel:ye,onTransform:xe,children:De},he),e[70]=g.id,e[71]=De,e[72]=Le):Le=e[72];let ze;e[73]!==N||e[74]!==C||e[75]!==j||e[76]!==v||e[77]!==k?(ze=k&&r.jsxs(r.Fragment,{children:[r.jsx(Lo,{label:"Previous image",disabled:!C,onClick:v,className:"absolute left-2 top-1/2 size-10 -translate-y-1/2 rounded-full bg-black/45 backdrop-blur sm:left-3",children:r.jsx(Jc,{className:"size-5","data-icon":"icon"})}),r.jsx(Lo,{label:"Next image",disabled:!N,onClick:j,className:"absolute right-2 top-1/2 size-10 -translate-y-1/2 rounded-full bg-black/45 backdrop-blur sm:right-3",children:r.jsx(Je,{className:"size-5","data-icon":"icon"})})]}),e[73]=N,e[74]=C,e[75]=j,e[76]=v,e[77]=k,e[78]=ze):ze=e[78];let Te;e[79]!==f?(Te=f===100&&r.jsxs("div",{className:"pointer-events-none absolute bottom-2 left-1/2 hidden -translate-x-1/2 items-center gap-1.5 rounded-full bg-black/60 px-2.5 py-1 text-xs text-white/60 sm:flex",children:[r.jsx(da,{className:"size-3","data-icon":"inline-start"}),"Scroll or double-click to zoom · drag to pan"]}),e[79]=f,e[80]=Te):Te=e[80];let Ce;e[81]!==F||e[82]!==Le||e[83]!==ze||e[84]!==Te?(Ce=r.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden bg-black",onPointerDown:O,onPointerUp:F,children:[Le,ze,Te]}),e[81]=F,e[82]=Le,e[83]=ze,e[84]=Te,e[85]=Ce):Ce=e[85];let We;e[86]!==b||e[87]!==k||e[88]!==s||e[89]!==d?(We=k&&r.jsx("footer",{className:"shrink-0 border-t border-white/10 bg-black/25 px-2 py-2",children:r.jsx("div",{className:"flex gap-1.5 overflow-x-auto overscroll-x-contain pb-0.5",children:s.map((fe,Oe)=>r.jsxs(ee,{type:"button",variant:"ghost",onClick:()=>b(Oe),"aria-label":`View image ${Oe+1}`,"aria-current":Oe===d?"true":void 0,className:q("relative size-12 shrink-0 overflow-hidden rounded-md border bg-white/[0.04] p-0.5 sm:h-14 sm:w-[4.5rem]",Oe===d?"border-white ring-1 ring-white/40":"border-white/10 opacity-55 hover:border-white/25 hover:opacity-90"),children:[r.jsx("img",{src:fe.src,alt:"",draggable:!1,className:"size-full rounded-[3px] object-cover"}),r.jsx("span",{className:"absolute bottom-0.5 right-0.5 rounded bg-black/70 px-1 font-mono text-xs text-white/80",children:Oe+1})]},`${fe.id}-${Oe}`))})}),e[86]=b,e[87]=k,e[88]=s,e[89]=d,e[90]=We):We=e[90];let Fe;e[91]!==M||e[92]!==pe||e[93]!==Ce||e[94]!==We?(Fe=r.jsxs(ss,{showCloseButton:!1,onKeyDown:M,className:U,children:[H,K,pe,Ce,We]}),e[91]=M,e[92]=pe,e[93]=Ce,e[94]=We,e[95]=Fe):Fe=e[95];let Ne;return e[96]!==l||e[97]!==z||e[98]!==W||e[99]!==Fe?(Ne=r.jsx(ns,{open:l,onOpenChange:z,onOpenChangeComplete:W,children:Fe}),e[96]=l,e[97]=z,e[98]=W,e[99]=Fe,e[100]=Ne):Ne=e[100],Ne}function bc(n){return n.type==="user"}function $d(n){return n.type==="assistant"}function gm(n){return n.type==="progress"}function xm(n){return n.type==="system"}function X1(n){return n.type==="summary"}function nk(n){return n.type==="queue-operation"}function J1(n){return n.type==="attachment"}function sk(n){return n.type==="user"&&n.isCompactSummary===!0}function Q1(n){return n.type==="system"&&n.subtype==="compact_boundary"}function bm(n,e){let t=0;for(const s of n)e[s.name]=(e[s.name]??0)+1,s.isError&&t++;return t}function vm(n,e){n.totalInputTokens+=e.input_tokens,n.totalOutputTokens+=e.output_tokens,n.totalCacheCreationTokens+=e.cache_creation_input_tokens??0,n.totalCacheReadTokens+=e.cache_read_input_tokens??0}function Pa(n){return{totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:n}}function Aa(n){const e=Pa(n.length);for(const t of n){t.tokenUsage&&vm(e,t.tokenUsage),t.durationMs&&(e.totalDurationMs+=t.durationMs),e.errorCount+=bm(t.toolCalls,e.toolCallCounts);for(const s of t.subAgentActivity)e.errorCount+=bm(s.toolCalls,e.toolCallCounts),s.tokenUsage&&vm(e,s.tokenUsage)}return e}const ok=/<(agent-message|teammate-message)([^>]*)>([\s\S]*?)<\/\1>/g,rk=[/\bteammate_id=(?:"([^"]*)"|'([^']*)')/,/\bfrom=(?:"([^"]*)"|'([^']*)')/];function ik(n){for(const e of rk){const t=n.match(e),s=(t==null?void 0:t[1])??(t==null?void 0:t[2]);if(s)return s}return null}function ak(n){return n.replace(/^\s*<(?:agent-message|teammate-message)\b[^>]*>/,"").replace(/<\/(?:agent-message|teammate-message)>\s*$/,"").trim()}function hr(n){let e=null,t=!1;const s=n.replace(ok,(o,i,a,l)=>(t=!0,e===null&&(e=ik(a)),l.trim()));return{sender:e,matched:t,body:t?s.trim():n}}const lk=[/\bblocking question\b/,/\bbefore i touch\b/,/\bshould i\b/,/\btell me one of\b/,/\byour call\b/,/\bwho owns\b/,/\bconfirm whether\b/],ck=[/(?:^|[,;:.!?—–-]\s*)tell me\b/,/(?:^|[,;:.!?—–-]\s*)say so\b/],dk=200,uk=/\bhttps?:\/\/\S+/g;function fk(n){const e=n.trim();if(!e)return!1;const t=e.slice(0,dk).toLowerCase();if(lk.some(i=>i.test(t)))return!0;const o=e.slice(e.lastIndexOf(`
52
- `)+1).slice(-200).replace(uk,"").toLowerCase();return o.includes("?")||ck.some(i=>i.test(o))}function Ra(n){return typeof n=="string"?n:n.filter(e=>e.type==="text").map(e=>e.text).join(`
53
- `)}function ym(n){return n?typeof n=="string"?n:n.map(e=>e.type==="text"?e.text:"").filter(Boolean).join(`
54
- `):""}function Z1(n){if(!(n!=null&&n.trim()))return!1;const e=n.trimStart();return e.startsWith("<")?!e.includes("<task-notification>")&&!e.startsWith("<system-reminder>")&&!e.startsWith("<local-command-"):!0}const mk=/<task-notification>[\s\S]*?<\/task-notification>/g,pk=/<[^>]*>/g;function hk(n){var t;if(((t=n.origin)==null?void 0:t.kind)==="task-notification")return!0;const e=Ra(n.message.content);return e.includes("<task-notification>")?e.replace(mk,"").replace(pk,"").trim()==="":!1}function gk(n){if(!J1(n))return null;const e=n.attachment;if(!e||e.type!=="queued_command"||e.commandMode!=="prompt")return null;const t=e.prompt;if(t==null)return null;const s=typeof t=="string"?t:Ra(t);if(!Z1(s))return null;const o=e.origin;if((o==null?void 0:o.kind)==="peer"){const a=o.name??o.from??null;if(a)return{raw:s,sender:a,body:o.body??hr(s).body}}if((o==null?void 0:o.kind)==="human")return{raw:s,sender:null,body:s};const i=hr(s);return{raw:s,sender:i.sender,body:i.body}}const xk=[["attributionAgent","agent"],["attributionSkill","skill"],["attributionPlugin","plugin"],["attributionMcpServer","mcpServer"],["attributionMcpTool","mcpTool"]];function bk(n,e){let t=n;for(const[s,o]of xk){const i=e[s];typeof i!="string"||!i||(t={...t,[o]:i})}return t}function vk(n,e){var s,o;if(!n)return{...e};const t=(((s=n.output_tokens_details)==null?void 0:s.thinking_tokens)??0)+(((o=e.output_tokens_details)==null?void 0:o.thinking_tokens)??0);return{input_tokens:n.input_tokens+e.input_tokens,output_tokens:n.output_tokens+e.output_tokens,cache_creation_input_tokens:(n.cache_creation_input_tokens??0)+(e.cache_creation_input_tokens??0),cache_read_input_tokens:(n.cache_read_input_tokens??0)+(e.cache_read_input_tokens??0),speed:e.speed??n.speed,...n.output_tokens_details||e.output_tokens_details?{output_tokens_details:{thinking_tokens:t}}:{}}}const yk=/^This session is being continued from a previous conversation[\s\S]*?\n\nSummary:\s*\n/,wk=/\n+(?:If you need specific details from before compaction|(?:Please c|C)ontinue the conversation from where it left off)[\s\S]*$/;function jk(n){return Ra(n).trim().replace(yk,"").replace(wk,"").trim()}function Sk(n){if(n)return{trigger:n.trigger,preTokens:n.preTokens,postTokens:n.postTokens}}function bi(n,e){return{id:n.uuid??crypto.randomUUID(),userMessage:e,contentBlocks:[],thinking:[],assistantText:[],toolCalls:[],subAgentActivity:[],timestamp:n.timestamp??"",durationMs:null,tokenUsage:null,model:null}}function Nk(n){const e=[];let t=0;for(;t<n.length;){const s=n[t];if(s.kind==="tool_calls"){const o=s.toolCalls.findIndex(i=>i.name==="EnterPlanMode");if(o!==-1){const i=s.toolCalls[o],a=String(i.input.plan??""),l=s.timestamp,c=s.toolCalls.slice(0,o);c.length>0&&e.push({kind:"tool_calls",toolCalls:c,timestamp:s.timestamp});const d=[],u=s.toolCalls.slice(o+1),f=u.findIndex(m=>m.name==="ExitPlanMode");if(f!==-1){d.push(...u.slice(0,f));const m=u[f],p=m.input.path?String(m.input.path):void 0;let h="pending";m.result!==null&&(h=m.isError?"rejected":"approved"),e.push({kind:"plan_mode",plan:a,planFilePath:p,status:h,toolCalls:d,timestamp:l});const g=u.slice(f+1);g.length>0&&e.push({kind:"tool_calls",toolCalls:g,timestamp:s.timestamp}),t++;continue}else{d.push(...u);let m,p,h="pending",g=t+1;const x=[];for(;g<n.length;){const b=n[g];if(b.kind==="tool_calls"){const w=b.toolCalls.findIndex(v=>v.name==="ExitPlanMode");if(w!==-1){d.push(...b.toolCalls.slice(0,w)),m=b.toolCalls[w],p=m.input.path?String(m.input.path):void 0,m.result!==null&&(h=m.isError?"rejected":"approved");const v=b.toolCalls.slice(w+1);e.push({kind:"plan_mode",plan:a,planFilePath:p,status:h,toolCalls:d,timestamp:l}),e.push(...x),v.length>0&&e.push({kind:"tool_calls",toolCalls:v,timestamp:b.timestamp}),t=g+1;break}else d.push(...b.toolCalls),g++}else if(b.kind==="hook_event"||b.kind==="text"||b.kind==="queued_prompt"||b.kind==="agent_message")x.push(b),g++;else break}m||(e.push({kind:"plan_mode",plan:a,planFilePath:void 0,status:"pending",toolCalls:d,timestamp:l}),e.push(...x),t=g);continue}}}e.push(s),t++}return e}function kk(n){return n.contentBlocks.some(e=>e.kind==="agent_message")?{...n,contentBlocks:n.contentBlocks.map(e=>{if(e.kind!=="agent_message")return e;const{reply:t,...s}=e;return s})}:n}function Md(n){var s;const e=n.map(kk),t=new Map;for(const o of e)for(const i of o.contentBlocks){if(i.kind==="agent_message"){const a=t.get(i.sender);a?a.push(i):t.set(i.sender,[i]);continue}if(i.kind==="tool_calls")for(const a of i.toolCalls){if(a.name!=="SendMessage")continue;const l=a.input.to;if(typeof l!="string"||!l)continue;const c=(s=t.get(l))==null?void 0:s.shift();if(!c)continue;const d=a.input.summary;c.reply={summary:typeof d=="string"?d:"",timestamp:a.timestamp||i.timestamp||""}}}return e}function Ck(n){const e=[];let t=!1;for(let s=0;s<n.length;s++){const o=n[s];if(X1(o)||Q1(o)){t=!1;continue}if(bc(o)&&!o.isMeta){const i=o.message.content;if(t&&Array.isArray(i)&&i.some(l=>l.type==="tool_result"))continue;e.push(s),t=!0;continue}$d(o)&&!t&&(e.push(s),t=!0)}return e}function ex(n){var k,C;const e=[],t=[];let s=null,o=0,i=null,a=null;function l(N){a&&(N.compactionSummary=a.summary,N.compactionMeta=a.meta,a=null)}let c=null;const d=new Map,u=new Set,f=new Map,m=new Map,p=new Set,h=new Map,g=[],x=new Map;function b(N,_){let P=x.get(N);P||(P=new Map,x.set(N,P)),P.set(_,(P.get(_)??0)+1)}function w(N,_){const P=x.get(N),A=P==null?void 0:P.get(_);return!P||!A?!1:(A===1?P.delete(_):P.set(_,A-1),!0)}function v(){for(const N of g)N.turn.contentBlocks.push(N.sender?{kind:"agent_message",sender:N.sender,body:N.body,timestamp:N.timestamp}:{kind:"queued_prompt",content:N.content,timestamp:N.timestamp});g.length=0}function S(N){if(!i)return;const _=f.get(N);if(!_||_.length===0)return;i.subAgentActivity.push(..._),f.delete(N);const P=p.has(N)?"background_agent":"sub_agent",A=m.get(N);if(A)A.messages.push(..._);else{const T={kind:P,messages:[..._]};i.contentBlocks.push(T),m.set(N,T)}}function j(){if(i){for(const N of i.toolCalls)S(N.id);for(const[N]of f)S(N);for(const N of i.contentBlocks)if(N.kind==="hook_event")for(const _ of N.events){if(!(_.eventName==="PostToolUse"||_.eventName.startsWith("PostToolUse:"))||!_.toolUseId)continue;const A=i.toolCalls.find(T=>T.id===_.toolUseId);A&&(_.updatedToolOutput&&(A.outputReplacedByHook=!0),_.durationMs!==void 0&&(A.hookDurationMs=(A.hookDurationMs??0)+_.durationMs))}i.contentBlocks=Nk(i.contentBlocks),e.push(i),s!==null&&t.push(s),s=null,i=null,m.clear()}}for(o=0;o<n.length;o++){const N=n[o];if(X1(N)){j(),a={summary:N.summary};continue}if(Q1(N)){j(),a={meta:Sk(N.compactMetadata)};continue}if(sk(N)){j(),s=o,i=bi(N,null),i.compactionSummary=jk(N.message.content),i.compactionMeta=a==null?void 0:a.meta,a=null;continue}if(xm(N)&&N.subtype==="away_summary"&&N.content){c={content:N.content,timestamp:N.timestamp};continue}if(nk(N)){if(i&&N.operation==="enqueue"&&Z1(N.content)){const _=hr(N.content);g.push({turn:i,content:N.content,timestamp:N.timestamp,sender:_.sender,body:_.body}),b(i,N.content)}continue}if(J1(N)){const _=gk(N);i&&_!==null&&!w(i,_.raw)&&g.push({turn:i,content:_.raw,timestamp:((k=N.attachment)==null?void 0:k.timestamp)??N.timestamp,sender:_.sender,body:_.body});continue}if(g.length>0){const _=bc(N)&&!N.isMeta?N.message.content:null;if(typeof _=="string"){const P=g.findIndex(A=>A.content===_);if(P>=0){const[A]=g.splice(P,1);w(A.turn,A.content)}}v()}if(bc(N)&&!N.isMeta){const _=N.message.content;if(typeof _!="string"&&Array.isArray(_)&&_.some(A=>A.type==="tool_result")&&i){for(const T of _)if(T.type==="tool_result"){const E=d.get(T.tool_use_id);E&&(E.turn.toolCalls[E.index].result=ym(T.content),E.turn.toolCalls[E.index].isError=T.is_error===!0,d.delete(T.tool_use_id))}const A=N.toolUseResult;if(A!=null&&A.agentId){const T=((C=_.find(D=>D.type==="tool_result"))==null?void 0:C.tool_use_id)??"",E=h.get(T),R=p.has(T),$=[];if(Array.isArray(A.content))for(const D of A.content)D.type==="text"&&$.push(D.text);const I={agentId:A.agentId,parentToolUseId:T||void 0,agentName:(E==null?void 0:E.name)??null,subagentType:(E==null?void 0:E.subagentType)??null,type:"assistant",content:A.content,toolCalls:[],thinking:[],text:$,timestamp:N.timestamp??"",tokenUsage:A.usage?{input_tokens:A.usage.input_tokens??0,output_tokens:A.usage.output_tokens??0,cache_creation_input_tokens:A.usage.cache_creation_input_tokens??0,cache_read_input_tokens:A.usage.cache_read_input_tokens??0}:null,model:null,isBackground:R,prompt:A.prompt,status:A.status,durationMs:A.totalDurationMs,toolUseCount:A.totalToolUseCount};if(!m.get(T)){i.subAgentActivity.push(I);const O={kind:R?"background_agent":"sub_agent",messages:[I]};i.contentBlocks.push(O),m.set(T,O)}}continue}if(hk(N)){const P={kind:"task_notification",content:Ra(_),timestamp:N.timestamp};if(i){i.contentBlocks.push(P);continue}s=o,i=bi(N,null),i.contentBlocks.push(P),l(i);continue}j(),s=o,i=bi(N,N.message.content),l(i),c&&(i.contentBlocks.push({kind:"recap",content:c.content,timestamp:c.timestamp}),c=null);continue}if($d(N)){let _=function(){R.length>0&&($.contentBlocks.push({kind:"tool_calls",toolCalls:[...R],timestamp:T}),R.length=0)},P=function(){if(E.length>0){const I=$.contentBlocks[$.contentBlocks.length-1];I&&I.kind==="thinking"?I.blocks.push(...E):$.contentBlocks.push({kind:"thinking",blocks:[...E],timestamp:T}),E.length=0}};i||(s=o,i=bi(N,null),l(i)),i.model=N.message.model,N.effort&&(i.effort=N.effort),i.attribution=bk(i.attribution,N);const A=N.message.id;u.has(A)||(u.add(A),i.tokenUsage=vk(i.tokenUsage,N.message.usage));const T=N.timestamp??"",E=[],R=[],$=i;for(const I of N.message.content)if(I.type==="thinking"){_();const M=I;if(!M.thinking)continue;i.thinking.push(M),E.push(M)}else if(I.type==="text"){_(),P();const M=/<thinking>([\s\S]*?)<\/thinking>/g;let D=I.text,O;for(;(O=M.exec(I.text))!==null;){const L=O[1].trim();if(L){const F={type:"thinking",thinking:L,signature:""};i.thinking.push(F),i.contentBlocks.push({kind:"thinking",blocks:[F],timestamp:T})}D=D.replace(O[0],"")}if(D=D.trim(),D){i.assistantText.push(D);const L=i.contentBlocks[i.contentBlocks.length-1];L&&L.kind==="text"?L.text.push(D):i.contentBlocks.push({kind:"text",text:[D],timestamp:T})}}else if(I.type==="tool_use"){P();const M={id:I.id,name:I.name,input:I.input,result:null,isError:!1,timestamp:N.timestamp??""},D=i.toolCalls.length;if(i.toolCalls.push(M),R.push(M),d.set(I.id,{turn:i,index:D}),I.name==="Task"||I.name==="Agent"){const O=I.input;O.run_in_background===!0&&p.add(I.id),h.set(I.id,{name:O.name??null,subagentType:O.subagent_type??null})}}P(),_();continue}if(gm(N)&&N.data.type==="agent_progress"){const _=N.data,P=N.parentToolUseID??"";let A=null;if(_.message.type==="assistant"){const I=_.message.message,M=I.id,D=I.usage;D&&M&&!u.has(M)&&(u.add(M),A={input_tokens:D.input_tokens??0,output_tokens:D.output_tokens??0,cache_creation_input_tokens:D.cache_creation_input_tokens??0,cache_read_input_tokens:D.cache_read_input_tokens??0})}const T=_.message.type==="assistant"?_.message.message.model??null:null,E=h.get(P),R={agentId:_.agentId,parentToolUseId:P||void 0,agentName:(E==null?void 0:E.name)??null,subagentType:(E==null?void 0:E.subagentType)??null,type:_.message.type,content:_.message.message.content,toolCalls:[],thinking:[],text:[],timestamp:_.message.timestamp??N.timestamp??"",tokenUsage:A,model:T,isBackground:p.has(P)};if(_.message.type==="assistant"){const I=_.message.message.content;if(Array.isArray(I))for(const M of I)M.type==="thinking"?R.thinking.push(M.thinking):M.type==="text"?R.text.push(M.text):M.type==="tool_use"&&R.toolCalls.push({id:M.id,name:M.name,input:M.input,result:null,isError:!1,timestamp:_.message.timestamp??N.timestamp??""})}else if(_.message.type==="user"){const I=_.message.message.content;if(Array.isArray(I)){for(const M of I)if(M.type==="tool_result"){const D=f.get(P);if(D)for(const O of D){const L=O.toolCalls.find(F=>F.id===M.tool_use_id);L&&(L.result=ym(M.content),L.isError=M.is_error===!0)}}}}let $=f.get(P);$||($=[],f.set(P,$)),$.push(R),i&&S(P);continue}if(gm(N)&&N.data.type==="hook_progress"){const _=N.data,P=String(_.hook_event_name??_.hookEvent??"unknown"),A=_.hookSpecificOutput,T={eventName:P,source:_.source!==void 0?String(_.source):void 0,toolName:_.tool_name!==void 0?String(_.tool_name):void 0,toolUseId:_.tool_use_id!==void 0?String(_.tool_use_id):void 0,command:_.command!==void 0?String(_.command):void 0,output:_.output!==void 0?String(_.output):void 0,stderr:_.stderr!==void 0?String(_.stderr):void 0,exitCode:_.exit_code!==void 0?Number(_.exit_code):void 0,decision:_.decision!==void 0?String(_.decision):void 0,durationMs:_.duration_ms!==void 0?Number(_.duration_ms):void 0,updatedToolOutput:(A==null?void 0:A.updatedToolOutput)!==void 0?String(A.updatedToolOutput):void 0,sessionTitle:(A==null?void 0:A.sessionTitle)!==void 0?String(A.sessionTitle):void 0,worktreePath:(A==null?void 0:A.worktreePath)!==void 0?String(A.worktreePath):void 0,timestamp:N.timestamp??""};if(i){const E=i.contentBlocks[i.contentBlocks.length-1];E&&E.kind==="hook_event"?E.events.push(T):i.contentBlocks.push({kind:"hook_event",events:[T],timestamp:N.timestamp})}continue}if(xm(N)&&N.subtype==="turn_duration"&&i){N.durationMs!==void 0&&N.durationMs!==null&&(i.durationMs=(i.durationMs??0)+N.durationMs);continue}}return v(),j(),{turns:Md(e),turnStartIndices:t}}function tx(n){return ex(n).turns}function wm(){return!0}function nx(n){const e=[];for(const t of n){const s=t.trim();if(s)try{e.push(JSON.parse(s))}catch{}}return e}function sx(n){return nx(n.split(`
55
- `))}function ox(n){const e={sessionId:"",version:"",gitBranch:"",cwd:"",slug:"",name:"",model:"",branchedFrom:void 0};for(const t of n)if(t.sessionId&&!e.sessionId&&(e.sessionId=t.sessionId),t.version&&!e.version&&(e.version=t.version),t.gitBranch&&!e.gitBranch&&(e.gitBranch=t.gitBranch),t.cwd&&!e.cwd&&(e.cwd=t.cwd),t.slug&&!e.slug&&(e.slug=t.slug),t.name&&!e.name&&(e.name=t.name),t.branchedFrom&&!e.branchedFrom&&(e.branchedFrom=t.branchedFrom),$d(t)&&t.message.model&&!e.model&&(e.model=t.message.model),e.sessionId&&e.version&&e.gitBranch&&e.cwd&&e.model)break;return e}function _k(n){return ox(nx(n))}function Tk(n,e){const t=sx(n),s=ox(t),o=tx(t),i=e!=null&&e.skipStats?Pa(o.length):Aa(o);return{...s,turns:o,stats:i,rawMessages:e!=null&&e.skipStats?[]:t,agentKind:"claude"}}function Ek(n,e){const t=sx(e);if(t.length===0)return n;const s=n.rawMessages,o=[...s,...t],i=Ck(s),a=Math.max(0,n.turns.length-i.length);let l=Math.max(0,i.length-1);const c=new Set;for(const h of t)if(h.type==="progress"){const g=h.parentToolUseID;g&&c.add(g)}if(c.size>0)for(let h=l-1;h>=0;h--){const g=n.turns[a+h];if(g!=null&&g.toolCalls.some(x=>c.has(x.id))){l=h;break}}const d=i[l]??s.length,u=n.turns.slice(0,a+l),f=tx(o.slice(d)),m=Md([...u,...f]),p=Aa(m);return{sessionId:n.sessionId,version:n.version,gitBranch:n.gitBranch,cwd:n.cwd,slug:n.slug,name:n.name,model:n.model||m.length>0&&m[m.length-1].model||"",turns:m,stats:p,rawMessages:o,branchedFrom:n.branchedFrom,agentKind:n.agentKind}}const rx="<task-notification>",Pk=/<task-id>([^<]+)<\/task-id>/g,Ak=/<tool-use-id>([^<]+)<\/tool-use-id>/g;function On(n){return typeof n=="object"&&n!==null}function Rk(n){const e=On(n.message)?n.message:null,t=e==null?void 0:e.content;return typeof t=="string"?[t]:Array.isArray(t)?t.filter(s=>On(s)&&typeof s.text=="string").map(s=>s.text):[]}function Ik(n){const e=[],t=new Set,s=new Set,o=new Set;function i(a,l){if(a.includes(rx)){for(const c of a.matchAll(Pk))t.add(c[1]),l==null||l.add(c[1]);for(const c of a.matchAll(Ak))t.add(c[1]),l==null||l.add(c[1])}}for(const a of n){if(a.type==="user"){const l=On(a.toolUseResult)?a.toolUseResult:null;if((l==null?void 0:l.status)==="async_launched"){const c=On(a.message)?a.message:null,u=(Array.isArray(c==null?void 0:c.content)?c.content:[]).filter(p=>On(p)&&p.type==="tool_result").map(p=>p.tool_use_id),f=[l.agentId,l.taskId,...u].filter(p=>typeof p=="string"&&p.length>0),m=[l.description,l.workflowName,l.summary].find(p=>typeof p=="string"&&p.length>0)??"";f.length>0&&e.push({ids:f,description:m})}for(const c of Rk(a))i(c,o);continue}if(a.type==="assistant"){const l=On(a.message)?a.message:null,c=Array.isArray(l==null?void 0:l.content)?l.content:[];for(const d of c){if(!On(d)||d.type!=="tool_use"||d.name!=="TaskStop")continue;const u=On(d.input)?d.input:null,f=(u==null?void 0:u.task_id)??(u==null?void 0:u.shell_id);typeof f=="string"&&t.add(f)}continue}if(a.type==="attachment"){const l=On(a.attachment)?a.attachment:null;typeof(l==null?void 0:l.prompt)=="string"&&i(l.prompt,o);continue}if(a.type==="queue-operation"&&typeof a.content=="string"){const l=a.operation;i(a.content,l==="enqueue"?s:o)}}return{pendingDescriptions:e.filter(a=>!a.ids.some(l=>t.has(l))).map(a=>a.description),undeliveredNotifications:[...s].filter(a=>!o.has(a)).length}}function $k(n,e){return{status:"awaiting_agents",pendingQueue:e,pendingAgents:n.length,pendingAgentDescriptions:n.filter(t=>t.length>0)}}function Mk(n){var a,l;let e=0,t=null,s=!1;function o(c,d){const u={status:c,pendingQueue:Math.max(0,e)};return d&&(u.toolName=d),u}function i(){return t??(t=Ik(n))}for(let c=n.length-1;c>=0;c--){const d=n[c];if(d.type!=="queue-operation"){if(d.type==="progress"){const u=d.data;if((u==null?void 0:u.type)==="hook_progress"&&(u.decision??((a=u.hookSpecificOutput)==null?void 0:a.permissionDecision))==="defer")return o("deferred");break}break}}for(let c=n.length-1;c>=0;c--){const d=n[c];if(d.type==="queue-operation"){if(typeof d.content=="string"&&d.content.includes(rx))continue;const u=d.operation;u==="enqueue"?e++:(u==="dequeue"||u==="remove")&&e--;continue}if(d.type==="attachment"){const u=On(d.attachment)?d.attachment:null;(u==null?void 0:u.commandMode)==="task-notification"&&(s=!0);continue}if(d.type==="assistant"){const u=d.message,f=u==null?void 0:u.stop_reason;if(f==="end_turn"){const m=i();if(s||m.undeliveredNotifications>0)return o("processing");if(m.pendingDescriptions.length>0)return $k(m.pendingDescriptions,Math.max(0,e));let p=!1;for(let h=c-1;h>=0;h--){const g=n[h];if(g.type==="user"&&!g.isMeta){p=!0;break}}return o(p?"completed":"idle")}if(f==="tool_use"){const m=u==null?void 0:u.content,p=(l=m==null?void 0:m.findLast)==null?void 0:l.call(m,h=>h.type==="tool_use");return o("tool_use",p==null?void 0:p.name)}return o("thinking")}if(d.type==="user"){if(d.isMeta)continue;return o("processing")}if(d.type==="system"&&d.subtype==="terminal_reason"){const u=d.reason;if(u)return{status:"completed",terminalReason:u,pendingQueue:Math.max(0,e)};continue}d.type!=="summary"&&d.type==="system"&&d.subtype}return{status:"idle"}}function Ok(n,e,t){const s=typeof n.sessionId=="string"?n.sessionId:"";return{record:{...n,sessionId:e,branchedFrom:{sessionId:s,turnIndex:t}},originalId:s}}function Dk(n){return ex(n).turnStartIndices}function ix(n,e,t){if(!e)return;n.assistantText.push(e);const s=n.contentBlocks[n.contentBlocks.length-1];if((s==null?void 0:s.kind)==="text"){s.text.push(e);return}n.contentBlocks.push({kind:"text",text:[e],timestamp:t})}const jm={0:"\0",b:"\b",f:"\f",n:`
56
- `,r:"\r",t:" ",v:"\v"};function Lk(n){return!!(n&&/[A-Za-z_$]/.test(n))}function Bi(n){return!!(n&&/[\w$]/.test(n))}function Zn(n,e){const t=n[e];if(t!=='"'&&t!=="'"&&t!=="`")return null;let s="",o=e+1;for(;o<n.length;){const i=n[o];if(i===t)return{endIndex:o+1,value:s};if(i!=="\\"){s+=i,o++;continue}if(o++,o>=n.length)return null;const a=n[o];if(a in jm){s+=jm[a],o++;continue}if(a===`
57
- `){o++;continue}if(a==="\r"){o+=n[o+1]===`
58
- `?2:1;continue}if(a==="x"&&/^[0-9a-fA-F]{2}$/.test(n.slice(o+1,o+3))){s+=String.fromCharCode(Number.parseInt(n.slice(o+1,o+3),16)),o+=3;continue}if(a==="u"){const l=n.slice(o+1).match(/^\{([0-9a-fA-F]+)\}/);if(l){const d=Number.parseInt(l[1],16);if(Number.isFinite(d)&&d<=1114111){s+=String.fromCodePoint(d),o+=l[0].length+1;continue}}const c=n.slice(o+1,o+5);if(/^[0-9a-fA-F]{4}$/.test(c)){s+=String.fromCharCode(Number.parseInt(c,16)),o+=5;continue}}s+=a,o++}return null}const gs={"(":")","[":"]","{":"}"};function Od(n,e){if(n[e]!=="/")return null;if(n[e+1]==="/"){const t=n.indexOf(`
59
- `,e+2);return t===-1?n.length:t+1}if(n[e+1]==="*"){const t=n.indexOf("*/",e+2);return t===-1?n.length:t+2}return null}function Ia(n,e){const t=Zn(n,e);if(t)return{endIndex:t.endIndex,isString:!0};const s=Od(n,e);return s===null?null:{endIndex:s,isString:!1}}function Zt(n,e){let t=e;for(;t<n.length;){if(/\s/.test(n[t])){t++;continue}const s=Od(n,t);if(s===null)break;t=s}return t}function $a(n,e){const t=n[e];if(!gs[t])return null;const s=[gs[t]];for(let o=e+1;o<n.length;o++){const i=Ia(n,o);if(i){o=i.endIndex-1;continue}const a=n[o];if(gs[a]){s.push(gs[a]);continue}if(a===s.at(-1)&&(s.pop(),s.length===0))return o}return null}function ax(n,e){if(!Lk(n[e]))return null;let t=e+1;for(;Bi(n[t]);)t++;return{value:n.slice(e,t),endIndex:t}}function zk(n,e,t){var u;const s=(u=t.trim().match(/^([A-Za-z_$][\w$]*)$/))==null?void 0:u[1];if(!s)return t;const o=n.slice(0,e),i=new RegExp(`\\b(?:const|let|var)\\s+${s.replace(/[$]/g,"\\$")}\\s*=`,"g"),a=[...o.matchAll(i)].at(-1);if(!a||a.index===void 0)return t;const l=Zt(o,a.index+a[0].length),c=o[l];if(c==="{"||c==="["||c==="("){const f=$a(o,l);if(f!==null)return o.slice(l,f+1).trim()}const d=Zn(o,l);return d?o.slice(l,d.endIndex).trim():t}function Fk(n){const e=[];for(let t=0;t<n.length;t++){const s=Ia(n,t);if(s){t=s.endIndex-1;continue}if(!n.startsWith("tools",t)||Bi(n[t-1])||Bi(n[t+5]))continue;let o=Zt(n,t+5),i="";if(n[o]==="."){o=Zt(n,o+1);const c=ax(n,o);if(!c)continue;i=c.value,o=c.endIndex}else if(n[o]==="["){o=Zt(n,o+1);const c=Zn(n,o);if(!c||(o=Zt(n,c.endIndex),n[o]!=="]"))continue;i=c.value,o++}else continue;if(o=Zt(n,o),n[o]!=="(")continue;const a=$a(n,o);if(a===null){e.push({name:i,argumentSource:n.slice(o+1).trim(),startIndex:t});break}const l=n.slice(o+1,a).trim();e.push({name:i,argumentSource:zk(n,t,l),startIndex:t})}return e}function lx(n,e){return Zn(n,e)??ax(n,e)}function Bk(n,e,t){const s=[];for(let o=e;o<t;o++){const i=Ia(n,o);if(i){o=i.endIndex-1;continue}const a=n[o];if(gs[a]){s.push(gs[a]);continue}if(s.length>0&&a===s.at(-1)){s.pop();continue}if(s.length===0&&a===",")return o}return t}function Dd(n,e){let t=Zt(n,0);for(;n[t]==="(";)t=Zt(n,t+1);if(n[t]!=="{")return null;const s=$a(n,t);if(s===null)return null;let o=t+1;for(;o<s;){if(o=Zt(n,o),n[o]===","){o++;continue}const i=lx(n,o);if(!i){o++;continue}if(o=Zt(n,i.endIndex),n[o]!==":"){o++;continue}const a=Zt(n,o+1),l=Bk(n,a,s);if(i.value===e)return n.slice(a,l).trim();o=l+1}return null}function cx(n,e,t){const s=[];for(let o=0;o<n.length;o++){const i=Od(n,o);if(i!==null){o=i-1;continue}const a=lx(n,o);if(a){if(a.value===e&&!Bi(n[o-1])){const l=Zt(n,a.endIndex);if(n[l]===":"){const c=t(Zt(n,l+1));c!==null&&s.push(c)}}o=a.endIndex-1}}return s}function Ld(n,e){return cx(n,e,t=>{var s;return((s=Zn(n,t))==null?void 0:s.value)??null})}function dx(n,e){return cx(n,e,t=>{const s=n.slice(t).match(/^-?[\d_]+(?:\.\d+)?/);if(!s)return null;const o=Number(s[0].replaceAll("_",""));return Number.isFinite(o)?o:null})}function ux(n){const e=Zt(n,0);if(!n.slice(e).trim())return 0;if(n[e]!=="[")return 1;const t=$a(n,e);if(t===null)return 1;let s=0,o=!1;const i=[];for(let a=e+1;a<t;a++){const l=Ia(n,a);if(l){o||(o=l.isString),a=l.endIndex-1;continue}const c=n[a];gs[c]?(o=!0,i.push(gs[c])):i.length>0&&c===i.at(-1)?i.pop():i.length===0&&c===","?(o&&s++,o=!1):/\s/.test(c)||(o=!0)}return s+(o?1:0)}function Sm(n){return n.includes("*** Begin Patch")&&n.includes("*** End Patch")}function Uk(n){if(!n.includes("apply_patch")||!n.includes("*** Begin Patch"))return[];const e=new Map;for(let a=0;a<n.length;a++){const l=Zn(n,a);if(l){if(Sm(l.value)){const c=n.slice(0,a).match(/(?:^|[;\n])\s*(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*$/);c&&e.set(c[1],l.value)}a=l.endIndex-1}}const t=[],s=new Set,o=/\btools\s*\.\s*apply_patch\s*\(/g;let i;for(;(i=o.exec(n))!==null;){let a=i.index+i[0].length;for(;/\s/.test(n[a]??"");)a++;const l=Zn(n,a),c=l?null:n.slice(a).match(/^([A-Za-z_$][\w$]*)/),d=(l==null?void 0:l.value)??(c?e.get(c[1]):void 0);!d||!Sm(d)||s.has(d)||(s.add(d),t.push(d))}return t}function Nm(n,e){if(!e||n.startsWith("/")||/^[A-Za-z]:[\\/]/.test(n))return n;const t=e.replace(/[\\/]+$/,""),s=n.replace(/^\.[\\/]/,"");return/^[A-Za-z]:[\\/]/.test(e)?`${t}\\${s.replace(/\//g,"\\")}`:`${t}/${s}`}function km(n,e,t,s=""){var c,d;const o=[],i=/^\*\*\*\s+(Update File|Add File|Delete File):\s*(.+)$/gm,a=[];let l;for(;(l=i.exec(n))!==null;)a.push({action:l[1],filePath:l[2].trim(),headerIdx:l.index,startIdx:l.index+l[0].length});for(let u=0;u<a.length;u++){const f=a[u],m=u+1<a.length?a[u+1].headerIdx:n.length,p=n.slice(f.startIdx,m),h=(d=(c=p.match(/^\*\*\*\s+Move to:\s*(.+)$/m))==null?void 0:c[1])==null?void 0:d.trim(),g=Nm(f.filePath,s),x=Nm(h||f.filePath,s),b=p.split(/^@@.*$/m).filter(j=>j.trim()),w=[],v=[];for(const j of b)for(const k of j.split(`
60
- `))k.startsWith("-")?w.push(k.slice(1)):k.startsWith("+")?v.push(k.slice(1)):k.startsWith(" ")&&(w.push(k.slice(1)),v.push(k.slice(1)));const S=a.length>1?`${e}:file-${u}`:e;f.action==="Add File"?o.push({id:S,name:"Write",input:{file_path:x,content:v.join(`
61
- `)},result:null,isError:!1,timestamp:t}):f.action==="Delete File"?o.push({id:S,name:"Edit",input:{file_path:x,old_string:w.join(`
62
- `),new_string:""},result:null,isError:!1,timestamp:t}):o.push({id:S,name:"Edit",input:{file_path:x,...h?{old_path:g}:{},old_string:w.join(`
63
- `),new_string:v.join(`
64
- `)},result:null,isError:!1,timestamp:t})}return o}function fx(n,e,t,s,o=""){return n==="apply_patch"?km(e,t,s,o):Uk(e).flatMap((i,a)=>km(i,`${t}:patch-${a}`,s,o))}function Wk(n,e,t){var l;if(!e||!/(?:apply[_ ]patch|invalid patch|invalid context|failed to (?:apply|find)|could not apply)/i.test(n))return new Set;const s=new Map;for(const c of t){const d=(l=c.id.match(/:patch-(\d+)(?::file-\d+)?$/))==null?void 0:l[1];if(d===void 0)continue;const u=Number(d),f=s.get(u)??[];f.push(c),s.set(u,f)}if(s.size===0)return new Set(t.map(c=>c.id));const o=n.toLowerCase().replaceAll("\\","/"),i=new Set;for(const[c,d]of s)d.some(u=>{const f=String(u.input.file_path??"").toLowerCase().replaceAll("\\","/");if(!f)return!1;const p=f.split("/").filter(Boolean).slice(-2).join("/");return o.includes(f)||p.includes("/")&&o.includes(p)})&&i.add(c);for(const c of o.matchAll(/\bpatch\s*(?:#|-)?\s*(\d+)\b/g)){const d=Number(c[1]);s.has(d)&&i.add(d)}i.size===0&&i.add(Math.max(...s.keys()));const a=Math.min(...i);for(const c of s.keys())c>=a&&i.add(c);return new Set([...i].flatMap(c=>{var d;return((d=s.get(c))==null?void 0:d.map(u=>u.id))??[]}))}function zd(n){return typeof n=="object"&&n!==null}const Hk=new Map([["spawn_agent","spawn_agent"],["spawnAgent","spawn_agent"],["wait_agent","wait_agent"],["waitAgent","wait_agent"],["send_message","send_message"],["sendMessage","send_message"],["followup_task","followup_task"],["followupTask","followup_task"],["list_agents","list_agents"],["listAgents","list_agents"],["interrupt_agent","interrupt_agent"],["interruptAgent","interrupt_agent"]]);function gr(n){const e=n.split(/(?:__|[.:/])+/).filter(Boolean).at(-1)??n;return Hk.get(e)??n}function vc(n){if(!n)return!1;const e=n.match(/Process exited with code (\d+)/);if(e)return e[1]!=="0";const t=n.replace(/\b0\s+(?:fail(?:ed|ures?)?|errors?)\b/gi,"").replace(/\bno\s+(?:failures?|errors?)\b/gi,"");return/\b(error|failed|exception)\b/i.test(t)}function Kk(n){return{todos:(Array.isArray(n.plan)?n.plan:[]).filter(s=>zd(s)).map(s=>({content:typeof s.step=="string"?s.step:"",status:typeof s.status=="string"?s.status:"pending",activeForm:typeof s.step=="string"?s.step:""}))}}function qk(n){return typeof n=="string"?n:Array.isArray(n)?n.filter(e=>zd(e)&&typeof e.text=="string").map(e=>e.text).join(""):""}function mx(n){const e=qk(n);if(!e)return{text:"",isError:!1};try{const t=JSON.parse(e),s=typeof t.output=="string"?t.output:e,o=zd(t.metadata)?t.metadata:null,i=o?o.exit_code!==0&&o.exit_code!==void 0:vc(s);return{text:s,isError:i}}catch{return{text:e,isError:vc(e)}}}const Vk=["# AGENTS.md instructions for ","<recommended_plugins>","<environment_context>","<permissions instructions>","<collaboration_mode>","<skills_instructions>"];function Gk(n){var e,t;return((t=(e=globalThis.crypto)==null?void 0:e.randomUUID)==null?void 0:t.call(e))??`${n}-${Math.random().toString(36).slice(2,10)}`}function Fd(n){try{return JSON.parse(n)}catch{return null}}function et(n){return typeof n=="object"&&n!==null}function Co(n){return!n||typeof n.type!="string"?!1:n.type==="session_meta"||n.type==="turn_context"||n.type==="event_msg"||n.type==="response_item"||n.type==="inter_agent_communication_metadata"||n.type==="compacted"||n.type==="world_state"}function Ui(n,e){const t=n==null?void 0:n.content;return Array.isArray(t)?t.filter(s=>et(s)&&s.type===e&&typeof s.text=="string").map(s=>s.text).join(`
65
- `).trim():""}const Yk=/^data:(image\/(?:png|jpeg|gif|webp));base64,(.+)$/is,Xk=/^data:(audio\/(?:wav|x-wav|mpeg|mp4|webm|ogg));base64,(.+)$/is;function px(n){if(typeof n!="string")return null;const e=Yk.exec(n);return!(e!=null&&e[1])||!e[2]?null:{type:"image",source:{type:"base64",media_type:e[1].toLowerCase(),data:e[2]}}}function hx(n){if(typeof n!="string")return null;const e=Xk.exec(n);return!(e!=null&&e[1])||!e[2]?null:{type:"audio",source:{type:"base64",media_type:e[1].toLowerCase(),data:e[2]}}}function Jk(n){return Array.isArray(n.images)?n.images.map(px).filter(e=>e!==null):[]}function Qk(n){return Array.isArray(n.audio)?n.audio.map(hx).filter(e=>e!==null):[]}function gx(n){return Array.isArray(n.content)?n.content.filter(e=>et(e)&&e.type==="input_image").map(e=>px(e.image_url)).filter(e=>e!==null):[]}function xx(n){return Array.isArray(n.content)?n.content.filter(e=>et(e)&&e.type==="input_audio").map(e=>hx(e.audio_url)).filter(e=>e!==null):[]}function Cm(n,e,t=[],s=[],o=[]){const i=[...s.map(l=>`
66
- ![image](<${l}>)`),...o.map(l=>`
67
- [audio attachment](<${l}>)`)].join(""),a=n+i;return e.length===0&&t.length===0?a:[...e,...t,...a?[{type:"text",text:a}]:[]]}function Zk(n){var a,l;const e=Ui(n,"input_text");if(!e)return{messageType:null,text:""};const t=e.match(/\r?\nPayload:\s*(?:\r?\n|$)/);if(!e.startsWith("Message Type:")||!t||t.index===void 0)return{messageType:null,text:e.trim()};const o=((l=(a=e.slice(0,t.index).match(/^Message Type:\s*([^\r\n]+)/))==null?void 0:a[1])==null?void 0:l.trim().toUpperCase())??null,i=e.slice(t.index+t[0].length).trim();return{messageType:o,text:i}}function zo(n){return n.split(/[\\/]/).filter(Boolean).at(-1)??null}function eC(n){if(typeof n!="string")return"";const e=n.trim();return/^gAAAAA[A-Za-z0-9_-]+$/.test(e)?"":e}function yc(n){const e=n.trim();return!e||Vk.some(t=>e.startsWith(t))?"":e}function tC(n,e){return n?{input_tokens:n.input_tokens+e.input_tokens,output_tokens:n.output_tokens+e.output_tokens,cache_creation_input_tokens:(n.cache_creation_input_tokens??0)+(e.cache_creation_input_tokens??0),cache_read_input_tokens:(n.cache_read_input_tokens??0)+(e.cache_read_input_tokens??0)}:{...e}}function nC(n){if(!et(n))return null;const e=typeof n.input_tokens=="number"?n.input_tokens:0,t=typeof n.output_tokens=="number"?n.output_tokens:0,s=typeof n.cache_write_input_tokens=="number"?n.cache_write_input_tokens:typeof n.cache_creation_input_tokens=="number"?n.cache_creation_input_tokens:0,o=typeof n.cached_input_tokens=="number"?Math.max(0,n.cached_input_tokens):null,i=o??(typeof n.cache_read_input_tokens=="number"?n.cache_read_input_tokens:0),a=o===null?e:Math.max(0,e-o);return a===0&&t===0&&s===0&&i===0?null:{input_tokens:a,output_tokens:t,cache_creation_input_tokens:s,cache_read_input_tokens:i}}function sC(n,e,t){if(!e)return;const s={type:"thinking",thinking:e,signature:""};n.thinking.push(s);const o=n.contentBlocks[n.contentBlocks.length-1];if(o&&o.kind==="thinking"){o.blocks.push(s);return}n.contentBlocks.push({kind:"thinking",blocks:[s],timestamp:t})}function to(n,e,t){n.toolCalls.push(e);const s=n.contentBlocks[n.contentBlocks.length-1];if(s&&s.kind==="tool_calls"&&s.timestamp===t){s.toolCalls.push(e);return}n.contentBlocks.push({kind:"tool_calls",toolCalls:[e],timestamp:t})}function oC(n,e,t){if(!e||!(e.userMessage!==null||e.assistantText.length>0||e.toolCalls.length>0||e.thinking.length>0||e.subAgentActivity.length>0))return null;if(e.timestamp&&t){const o=new Date(e.timestamp).getTime(),i=new Date(t).getTime();Number.isFinite(o)&&Number.isFinite(i)&&i>=o&&(e.durationMs=i-o)}return n.push(e),null}function _m(n){if(typeof n!="string"||!n.trim())return{};try{const e=JSON.parse(n);return et(e)?e:{value:e}}catch{return{raw:n}}}function Fo(n){if(typeof n=="string")return n;try{return JSON.stringify(n)}catch{return String(n??"")}}function Tm(...n){return n.find(e=>typeof e=="string")}function rC(n){return n.startsWith("exec-")}function iC(n){if(!et(n))return{text:Fo(n),isError:!1};if("Err"in n)return{text:Fo(n.Err),isError:!0};const e=et(n.Ok)?n.Ok:null;if(!e)return{text:Fo(n),isError:!1};const t=mx(e.content);return{text:t.text||(e.structuredContent!==void 0?Fo(e.structuredContent):Fo(e)),isError:e.isError===!0||t.isError}}function aC(n,e,t){return{id:n?`${n}@${e}`:Gk("codex-turn"),userMessage:null,contentBlocks:[],thinking:[],assistantText:[],toolCalls:[],subAgentActivity:[],timestamp:e,durationMs:null,tokenUsage:null,model:t}}function bx(n){return n.type==="event_msg"&&et(n.payload)&&n.payload.type==="user_message"&&typeof n.payload.message=="string"?yc(n.payload.message):n.type==="response_item"&&et(n.payload)&&n.payload.type==="message"&&n.payload.role==="user"?yc(Ui(n.payload,"input_text")):""}function lC(n,e){if(n.type==="session_meta"||n.type==="event_msg"&&(e==null?void 0:e.type)==="task_started")return!1;if(n.type==="response_item"&&(e==null?void 0:e.type)==="message"){if(e.role==="developer"||e.role==="system")return!1;if(e.role==="user")return bx(n)!==""||gx(e).length>0||xx(e).length>0}return!0}function vx(n){let e="",t="",s="",o="",i="",a,l="",c="",d="",u="",f=0,m=!1,p=null,h="/root",g="";for(const x of n){if(!et(x.payload))continue;if(x.type==="session_meta"){if(e||(e=typeof x.payload.id=="string"?x.payload.id:""),t||(t=typeof x.payload.cli_version=="string"?x.payload.cli_version:""),o||(o=typeof x.payload.cwd=="string"?x.payload.cwd:""),!a&&et(x.payload.branchedFrom)){const S=typeof x.payload.branchedFrom.sessionId=="string"?x.payload.branchedFrom.sessionId:"";S&&(a={sessionId:S,turnIndex:typeof x.payload.branchedFrom.turnIndex=="number"?x.payload.branchedFrom.turnIndex:null})}const w=et(x.payload.source)?x.payload.source:null;if(w&&et(w.subagent)){m=!0;const S=et(w.subagent.thread_spawn)?w.subagent.thread_spawn:null;S&&typeof S.agent_path=="string"&&(h=S.agent_path)}typeof x.payload.forked_from_id=="string"&&x.payload.forked_from_id&&(p=x.payload.forked_from_id);const v=et(x.payload.git)?x.payload.git:null;s||(s=v&&typeof v.branch=="string"?v.branch:"")}x.type==="turn_context"&&(i||(i=typeof x.payload.model=="string"?x.payload.model:""),o||(o=typeof x.payload.cwd=="string"?x.payload.cwd:""));const b=bx(x);b&&b!==g&&(l||(l=b),c=b,g=b,f++,d||(d=x.timestamp??""),u=x.timestamp??u)}return u===""&&(u=d),{sessionId:e,version:t,gitBranch:s,cwd:o,model:i,slug:"",name:"",branchedFrom:a,firstUserMessage:l,lastUserMessage:c,timestamp:d,lastTimestamp:u,turnCount:f,isSubagent:m,parentSessionId:p,agentPath:h}}function yx(n){for(const e of n.split(`
68
- `)){const t=e.trim();if(t)return Co(Fd(t))}return!1}function cC(n){return Co(n[0]??null)}function dC(n){const e=n.map(Fd).filter(Co);return vx(e)}function wx(n,e){const t=vx(n.filter(Co)),s=[],o=new Map,i=new Map,a=new Map,l=new Map,c=new Map,d=new Map,u=new Map,f=new Map;function m(P,A,T,E={}){const R=c.get(P);let $=f.get(P);if(!$){const M={agentId:P,parentToolUseId:(R==null?void 0:R.parentToolCallId)||void 0,agentName:(R==null?void 0:R.nickname)??(R!=null&&R.agentPath?zo(R.agentPath):null),subagentType:(R==null?void 0:R.agentType)??null,type:"assistant",content:null,toolCalls:[],thinking:[],text:[],timestamp:(R==null?void 0:R.timestamp)??T,tokenUsage:null,model:(R==null?void 0:R.model)??null,isBackground:!1,prompt:(R==null?void 0:R.message)||void 0,status:E.status??"running"};A.subAgentActivity.push(M);const D=A.contentBlocks[A.contentBlocks.length-1];(D==null?void 0:D.kind)==="sub_agent"?D.messages.push(M):A.contentBlocks.push({kind:"sub_agent",messages:[M],timestamp:T}),$={message:M,turn:A},f.set(P,$)}const I=$.message;if(R&&(I.parentToolUseId=R.parentToolCallId||I.parentToolUseId,I.agentName=R.nickname??(R.agentPath?zo(R.agentPath):I.agentName),I.subagentType=R.agentType,I.model=R.model,I.prompt=R.message||I.prompt),E.text&&!I.text.includes(E.text)&&(I.text.push(E.text),I.content=I.text.join(`
69
-
70
- `)),E.status){const M=new Set(["completed","failed","interrupted"]);if(E.status==="running"&&I.status&&M.has(I.status)||(I.status=E.status),M.has(E.status)&&I.timestamp&&T){const D=new Date(I.timestamp).getTime(),O=new Date(T).getTime();Number.isFinite(D)&&Number.isFinite(O)&&O>=D&&(I.durationMs=O-D)}}return I}let p=null,h=null,g=t.model||null,x="",b=null,w=!1;const v=[];let S=0,j=null,k=null;function C(P){const A=s.length,T=oC(s,P,x);return s.length>A&&k!==null&&v.push(k),k=null,T}function N(P,A,T){const E=aC(P,A,T);return k=j??S,j=null,w||(E.isFragment=!0),b&&(E.compactionSummary=b,b=null),E}function _(P,A,T,E,R){const $=i.get(A);if($){$.input={...$.input,...T},$.result=E,$.isError=E==="failed";return}const I={id:A,name:"WebSearch",input:T,result:E,isError:E==="failed",timestamp:R};i.set(A,I),to(P,I,R)}for(let P=0;P<n.length;P++){const A=n[P];if(!Co(A))continue;S=P;const T=et(A.payload)?A.payload:void 0,E=A.timestamp??"";if(A.type==="compacted"){p=C(p),b="Conversation compacted",x=E;continue}if(A.type!=="world_state"){if(A.type==="turn_context"){p=C(p),j=P,h=typeof(T==null?void 0:T.turn_id)=="string"?T.turn_id:null,g=typeof(T==null?void 0:T.model)=="string"?T.model:g,x=E,w=!0;continue}if(A.type==="event_msg"&&(T==null?void 0:T.type)==="user_message"&&typeof T.message=="string"){p&&(p.assistantText.length>0||p.toolCalls.length>0||p.thinking.length>0)&&(p=C(p)),w=!0,p??(p=N(h,E,g));const R=(Array.isArray(T.local_images)?T.local_images:[]).filter(I=>typeof I=="string"&&I.length>0),$=(Array.isArray(T.local_audio)?T.local_audio:[]).filter(I=>typeof I=="string"&&I.length>0);p.userMessage=Cm(T.message,Jk(T),Qk(T),R,$),p.isFragment=!1,p.timestamp=p.timestamp||E,x=E;continue}if(!(!p&&!lC(A,T))){if(p??(p=N(h,E,g)),!p.model&&g&&(p.model=g),p.timestamp||(p.timestamp=E),E&&(x=E),A.type==="event_msg"&&(T==null?void 0:T.type)==="token_count"){const R=et(T.info)?T.info:null,$=R?nC(R.last_token_usage):null;$&&(p.tokenUsage=tC(p.tokenUsage,$));continue}if(A.type==="event_msg"&&(T==null?void 0:T.type)==="web_search_end"&&typeof T.call_id=="string"){const R={};typeof T.query=="string"&&T.query&&(R.query=T.query),et(T.action)&&(R.action=T.action),_(p,T.call_id,R,"completed",E);continue}if(A.type==="event_msg"&&(T==null?void 0:T.type)==="mcp_tool_call_end"&&typeof T.call_id=="string"&&et(T.invocation)){const R=T.invocation,$=typeof R.server=="string"?R.server:"mcp",I=typeof R.tool=="string"?R.tool:"tool",M=et(R.arguments)?R.arguments:{},D=iC(T.result),O=o.get(T.call_id);O?(O.result=D.text,O.isError=D.isError,o.delete(T.call_id)):rC(T.call_id)||to(p,{id:T.call_id,name:`mcp__${$}__${I}`,input:M,result:D.text,isError:D.isError,timestamp:E},E);continue}if(A.type==="event_msg"&&(T==null?void 0:T.type)==="sub_agent_activity"&&typeof T.agent_thread_id=="string"&&typeof T.agent_path=="string"){const R=T.agent_thread_id,$=typeof T.event_id=="string"?T.event_id:"",I=typeof T.kind=="string"?T.kind:"started",M=$?l.get($):void 0,D=d.get(T.agent_path),O=c.get(R)??(D?c.get(D):void 0);if(I!=="started"&&!O&&!M)continue;if(D&&D!==R&&!f.has(R)){const z=f.get(D);z&&(z.message.agentId=R,f.delete(D),f.set(R,z)),c.delete(D)}const L={agentId:R,nickname:(O==null?void 0:O.nickname)??zo(T.agent_path)??(M==null?void 0:M.taskName)??null,agentPath:T.agent_path,message:(O==null?void 0:O.message)??(M==null?void 0:M.message)??"",model:(O==null?void 0:O.model)??(M==null?void 0:M.model)??null,agentType:(O==null?void 0:O.agentType)??(M==null?void 0:M.agentType)??null,timestamp:(O==null?void 0:O.timestamp)??(E||(M==null?void 0:M.timestamp)||""),parentToolCallId:(O==null?void 0:O.parentToolCallId)??$};c.set(R,L),d.set(T.agent_path,R),$&&(I==="started"||M)&&u.set($,R),m(R,p,E,{status:I==="interrupted"?"interrupted":"running"});continue}if(!(A.type!=="response_item"||!T)){if(T.type==="reasoning"){const R=Array.isArray(T.summary)?T.summary.filter($=>typeof $=="string").join(`
71
- `):"";sC(p,R.trim(),E);continue}if(T.type==="message"&&T.role==="assistant"){ix(p,Ui(T,"output_text"),E);continue}if(T.type==="message"&&T.role==="user"&&p.userMessage===null){const R=yc(Ui(T,"input_text")),$=gx(T),I=xx(T);(R||$.length>0||I.length>0)&&(p.userMessage=Cm(R,$,I),p.isFragment=!1,w=!0);continue}if(T.type==="web_search_call"&&typeof T.id=="string"){const R={};et(T.action)&&(R.action=T.action);const $=typeof T.status=="string"?T.status:"completed";_(p,T.id,R,$,E);continue}if(T.type==="tool_search_call"){const R=Tm(T.call_id,T.id)??"";if(R){const $={id:R,name:"ToolSearch",input:et(T.arguments)?T.arguments:{},result:null,isError:!1,timestamp:E};o.set(R,$),to(p,$,E)}continue}if(T.type==="tool_search_output"&&typeof T.call_id=="string"){const R=o.get(T.call_id);if(R){const $=Array.isArray(T.tools)?T.tools:[],I=$.filter(et).map(O=>Tm(O.name)??"").filter(Boolean),M=I.length>0?I.length:$.length,D=`Found ${M} tool${M===1?"":"s"}`;R.result=I.length>0?`${D}: ${I.join(", ")}`:D,R.isError=T.status==="failed",o.delete(T.call_id)}continue}if(T.type==="agent_message"&&typeof T.author=="string"){const R=T.author,$=typeof T.recipient=="string"?T.recipient:null,I=Zk(T);if(I.messageType==="NEW_TASK")continue;const M=d.get(R),D=R.startsWith(`${t.agentPath}/`)&&($===null||$===t.agentPath);if(!M&&!D)continue;const O=M??R;M||(c.set(O,{agentId:O,nickname:zo(R),agentPath:R,message:"",model:null,agentType:null,timestamp:E,parentToolCallId:""}),d.set(R,O));let L;I.messageType==="FINAL_ANSWER"?L="completed":I.messageType==="ERROR"||I.messageType==="FAILED"?L="failed":I.messageType==="INTERRUPTED"?L="interrupted":I.messageType==="MESSAGE"&&(L="running"),m(O,p,E,{status:L,text:I.text||void 0});continue}if(T.type==="function_call"&&typeof T.call_id=="string"){const R=typeof T.name=="string"?T.name:"tool",$=gr(R),I=_m(T.arguments);let M=$,D=I;$==="exec_command"?M="Bash":$==="update_plan"&&(M="TodoWrite",D=Kk(I)),$==="spawn_agent"&&l.set(T.call_id,{callId:T.call_id,message:eC(I.message),taskName:typeof I.task_name=="string"?I.task_name:null,model:typeof I.model=="string"?I.model:null,agentType:typeof I.agent_type=="string"?I.agent_type:null,timestamp:E});const O={id:T.call_id,name:M,input:D,result:null,isError:!1,timestamp:E};o.set(O.id,O),to(p,O,E);continue}if(T.type==="function_call_output"&&typeof T.call_id=="string"){const R=o.get(T.call_id);if(!R)continue;const $=typeof T.output=="string"?T.output:null;if(R.result=$,R.isError=vc($),o.delete(T.call_id),R.name==="spawn_agent"&&$)try{const I=JSON.parse($),M=typeof I.agent_id=="string"?I.agent_id:u.get(R.id)??"",D=typeof I.task_name=="string"?I.task_name:null,O=typeof I.nickname=="string"?I.nickname:D?zo(D):null;if(M){const L=l.get(R.id),F=c.get(M),z={agentId:M,nickname:O??(F==null?void 0:F.nickname)??(L==null?void 0:L.taskName)??null,agentPath:D??(F==null?void 0:F.agentPath)??null,message:(F==null?void 0:F.message)??(L==null?void 0:L.message)??"",model:(F==null?void 0:F.model)??(L==null?void 0:L.model)??null,agentType:(F==null?void 0:F.agentType)??(L==null?void 0:L.agentType)??null,timestamp:(F==null?void 0:F.timestamp)??(L==null?void 0:L.timestamp)??E,parentToolCallId:(F==null?void 0:F.parentToolCallId)??R.id};c.set(M,z),u.set(R.id,M),z.agentPath&&d.set(z.agentPath,M),m(M,p,E,{status:"running"})}}catch{}if(R.name==="wait_agent"&&$&&p)try{const I=JSON.parse($),M=et(I.status)?I.status:{};for(const[D,O]of Object.entries(M)){const L=et(O)?O:{},F=typeof L.completed=="string"?L.completed:"",z=typeof L.failed=="string"?L.failed:typeof L.error=="string"?L.error:"",W=typeof L.interrupted=="string"?L.interrupted:"",U=F?"completed":z?"failed":W?"interrupted":typeof L.status=="string"?L.status:"running";c.has(D)||c.set(D,{agentId:D,nickname:null,agentPath:null,message:"",model:null,agentType:null,timestamp:E,parentToolCallId:""}),m(D,p,E,{status:U,text:F||z||W||void 0})}}catch{}continue}if(T.type==="custom_tool_call"&&typeof T.call_id=="string"){const R=typeof T.name=="string"?T.name:"tool",$=typeof T.input=="string"?T.input:"",I=T.call_id,M=$?fx(R,$,I,E,t.cwd):[];if(R!=="apply_patch"){const D={id:I,name:R==="exec_command"?"Bash":R,input:_m($),result:null,isError:!1,timestamp:E};o.set(D.id,D),to(p,D,E)}for(const D of M)o.set(D.id,D),to(p,D,E);M.length>0&&a.set(I,{calls:M,direct:R==="apply_patch"});continue}if(T.type==="custom_tool_call_output"&&typeof T.call_id=="string"){const R=T.call_id,{text:$,isError:I}=mx(T.output),M=a.get(R);if(M){const O=M.direct&&I?new Set(M.calls.map(L=>L.id)):Wk($,I,M.calls);for(const L of M.calls){const F=o.get(L.id);F&&(F.result=$,F.isError=O.has(F.id),o.delete(F.id))}a.delete(R)}const D=o.get(R);D&&(D.result=$,D.isError=I,o.delete(R));continue}}}}}return C(p),{turnStartIndices:v,sessionId:t.sessionId,version:t.version,gitBranch:t.gitBranch,cwd:t.cwd,slug:t.slug,name:"",model:t.model,turns:s,stats:e!=null&&e.skipStats?Pa(s.length):Aa(s),rawMessages:e!=null&&e.skipStats?[]:n,branchedFrom:t.branchedFrom,agentKind:"codex"}}function Bd(n,e){const t=n.split(`
72
- `).map(i=>i.trim()).filter(Boolean).map(Fd).filter(Co),{turnStartIndices:s,...o}=wx(t,e);return o}function uC(n,e){const t=n.rawMessages.map(s=>JSON.stringify(s)).join(`
73
- `);return Bd(t?`${t}
74
- ${e}`:e)}const fC=new Set(["FINAL_ANSWER","ERROR","FAILED","INTERRUPTED"]);function mC(n){const e=n.content;return Array.isArray(e)?e.filter(t=>et(t)&&t.type==="input_text"&&typeof t.text=="string").map(t=>t.text).join(`
75
- `):""}function vi(n){if(typeof n!="string")return null;try{const e=JSON.parse(n);return et(e)?e:null}catch{return null}}function pC(n){var c,d;const e=new Map,t=new Set,s=new Map,o=new Map,i=new Set,a=new Map;function l(u,f){t.has(u)||e.set(u,e.get(u)||f)}for(const u of n){const f=et(u.payload)?u.payload:null;if(f){if(u.type==="event_msg"&&f.type==="sub_agent_activity"&&typeof f.agent_thread_id=="string"&&typeof f.agent_path=="string"){const m=f.agent_thread_id,p=typeof f.kind=="string"?f.kind:"started",h=typeof f.event_id=="string"?f.event_id:"",g=s.get(f.agent_path),x=e.has(m)||t.has(m)||g!==void 0||o.has(h);if(p!=="started"&&!x)continue;g&&g!==m&&(e.has(g)&&(l(m,e.get(g)??""),e.delete(g)),t.has(g)&&t.add(m)),s.set(f.agent_path,m),p==="interrupted"?(t.add(m),e.delete(m)):l(m,o.get(h)??"");continue}if(u.type==="response_item"){if(f.type==="function_call"&&typeof f.call_id=="string"){const m=gr(typeof f.name=="string"?f.name:"");if(m==="spawn_agent"){const p=vi(f.arguments);o.set(f.call_id,typeof(p==null?void 0:p.task_name)=="string"?p.task_name:"")}else if(m==="wait_agent")i.add(f.call_id);else if(m==="interrupt_agent"){const p=vi(f.arguments),h=[p==null?void 0:p.agent_id,...Array.isArray(p==null?void 0:p.agent_ids)?p.agent_ids:[]].filter(g=>typeof g=="string");a.set(f.call_id,h)}continue}if(f.type==="function_call_output"&&typeof f.call_id=="string"){const m=f.call_id;if(o.has(m)){const p=vi(f.output),h=typeof(p==null?void 0:p.agent_id)=="string"?p.agent_id:"";if(h){l(h,o.get(m)??"");const g=typeof(p==null?void 0:p.task_name)=="string"?p.task_name:"";g&&!s.has(g)&&s.set(g,h)}}else if(i.has(m)){const p=vi(f.output),h=et(p==null?void 0:p.status)?p.status:{};for(const[g,x]of Object.entries(h)){const b=et(x)?x:{},w=typeof b.status=="string"?b.status:"";(typeof b.completed=="string"||typeof b.failed=="string"||typeof b.error=="string"||typeof b.interrupted=="string"||w==="completed"||w==="failed"||w==="interrupted")&&(t.add(g),e.delete(g))}}else if(a.has(m))for(const p of a.get(m)??[])t.add(p),e.delete(p);continue}if(f.type==="agent_message"&&typeof f.author=="string"){const p=((d=(c=mC(f).match(/^Message Type:\s*([^\r\n]+)/))==null?void 0:c[1])==null?void 0:d.trim().toUpperCase())??"";if(!fC.has(p))continue;const h=s.get(f.author)??f.author;t.add(h),e.delete(h)}}}}return[...e.entries()].filter(([u])=>!t.has(u)).map(([,u])=>u)}function hC(n){for(let e=n.length-1;e>=0;e--){const t=n[e];if(t.type==="event_msg"){const s=t.payload;switch(s==null?void 0:s.type){case"task_complete":{const o=pC(n);return o.length>0?{status:"awaiting_agents",pendingQueue:0,pendingAgents:o.length,pendingAgentDescriptions:o.filter(i=>i.length>0)}:{status:"completed"}}case"task_started":return{status:"processing"};case"agent_message":return{status:"thinking"};case"token_count":continue}}if(t.type==="response_item"){const s=t.payload;if(!s)continue;if(s.type==="function_call")return{status:"tool_use",toolName:s.name?gr(s.name):s.name};if(s.type==="message"){if(s.role==="assistant")return{status:"thinking"};if(s.role==="user")return{status:"processing"}}}}return{status:"idle"}}function gC(n,e,t){const s=et(n.payload)?{...n.payload}:{},o=typeof s.id=="string"?s.id:"";return s.id=e,s.branchedFrom={sessionId:o,turnIndex:t},{record:{...n,payload:s},originalId:o}}function xC(n){return wx(n,{skipStats:!0}).turnStartIndices}const bC=/^(?:assistant|auto_mode|auto_mode_switch|background_tasks|canvas|command|custom|elicitation|exit_plan_mode|extensions|external_tool|factory|hook|managed_settings|mcp|model|pending_messages|permission|sampling|session|skill|subagent|system|tool|ui|user_input)\./;function $t(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function jx(n){return typeof n.agentId!="string"||n.agentId.length===0}function Sx(n){return!$t(n)||typeof n.type!="string"||!$t(n.data)?!1:n.type==="abort"||n.type==="binary_asset"||n.type==="user.message"||bC.test(n.type)}function Nx(n){try{const e=JSON.parse(n);return Sx(e)?e:null}catch{return null}}function vC(n){return n.split(`
76
- `).map(e=>e.trim()).filter(Boolean).map(Nx).filter(e=>e!==null)}function we(...n){return n.find(e=>typeof e=="string")??""}function Xn(n){return typeof n=="number"&&Number.isFinite(n)?n:0}function Ko(n){return typeof n.timestamp=="string"?n.timestamp:""}function ds(n,e){var t,s;return typeof n.id=="string"&&n.id?n.id:((s=(t=globalThis.crypto)==null?void 0:t.randomUUID)==null?void 0:s.call(t))??`${e}-${Math.random().toString(36).slice(2,10)}`}function Em(n){const e=ds(n,"copilot-turn"),t=we(n.data.turnId);return t?`${t}@${e}`:e}function yl(n,e){if(!$t(n))return;const t=we(n.cwd),s=we(n.branch);t&&(e.cwd=t),s&&(e.gitBranch=s)}function kx(n){const e={sessionId:"",version:"",gitBranch:"",cwd:"",model:"",slug:"",name:"",firstUserMessage:"",lastUserMessage:"",timestamp:"",lastTimestamp:"",turnCount:0,isSubagent:!1,parentSessionId:null};for(const t of n){if(!jx(t))continue;const{data:s}=t,o=Ko(t);if(o&&(e.lastTimestamp=o),t.type==="session.start"){e.sessionId||(e.sessionId=we(s.sessionId)),e.version||(e.version=we(s.copilotVersion)||(typeof s.version=="number"?String(s.version):we(s.version))),yl(s.context,e),e.model=we(s.selectedModel)||e.model;continue}if(t.type==="session.resume"){yl(s.context,e),e.model=we(s.selectedModel)||e.model;continue}if(t.type==="session.context_changed"){yl(s,e);continue}if(t.type==="session.auto_mode_resolved"){e.model=we(s.chosenModel)||e.model;continue}if(t.type==="session.model_change"){e.model=we(s.newModel)||e.model;continue}if(t.type==="session.title_changed"){e.name=we(s.title)||e.name;continue}if(t.type==="session.shutdown"){e.model=we(s.currentModel)||e.model;continue}if((t.type==="assistant.turn_start"||t.type==="assistant.turn_end"||t.type==="assistant.message"||t.type==="assistant.usage"||t.type==="tool.execution_start"||t.type==="tool.execution_complete")&&(e.model=we(s.model)||e.model),t.type!=="user.message")continue;e.turnCount++,e.timestamp||(e.timestamp=o);const i=we(s.content).trim();i&&(e.firstUserMessage||(e.firstUserMessage=i),e.lastUserMessage=i)}return e.lastTimestamp||(e.lastTimestamp=e.timestamp),e}function yC(n){for(const e of n.split(`
77
- `)){const t=e.trim();if(t)try{const s=JSON.parse(t);if(Sx(s))return!0}catch{}}return!1}function wC(n){var e;return MC((e=n[0])==null?void 0:e.type)}function jC(n){const e=n.map(t=>Nx(t.trim())).filter(t=>t!==null);return kx(e)}function wl(n){if(typeof n=="string")return n;if(n===void 0)return"";try{return JSON.stringify(n)}catch{return String(n)}}function Pm(n){return typeof n=="string"?n:Array.isArray(n)?n.flatMap(e=>{const t=typeof e=="string"?e:$t(e)?we(e.text,e.content):"";return t?[t]:[]}).join(`
78
- `):""}function SC(n){const e=new Map;for(const t of n){if(t.type!=="session.binary_asset"&&t.type!=="binary_asset")continue;const s=we(t.data.assetId),o=we(t.data.data),i=we(t.data.mimeType);s&&o&&i&&e.set(s,{data:o,mimeType:i})}return e}function NC(n,e){if(!$t(n))return null;const t=e.get(we(n.assetId)),s=we(n.mimeType,t==null?void 0:t.mimeType).toLowerCase(),o=we(n.data,t==null?void 0:t.data);return!s.startsWith("image/")||!o?null:{type:"image",source:{type:"base64",media_type:s,data:o}}}function Cx(n,e){if(!Array.isArray(n))return[];const t=[],s=new Set;for(const o of n){const i=NC(o,e);if(!i)continue;const a=`${i.source.media_type}:${i.source.data}`;s.has(a)||(s.add(a),t.push(i))}return t}function kC(n,e){const t=we(n.content),s=Cx(n.attachments,e);return s.length===0?t:[...s,...t?[{type:"text",text:t}]:[]]}function CC(n,e){return $t(n.result)?Cx([...Array.isArray(n.result.contents)?n.result.contents:[],...Array.isArray(n.result.binaryResultsForLlm)?n.result.binaryResultsForLlm:[]],e):[]}function Ri(n,e){var o,i;if(!n)return{...e};const t=((o=n.output_tokens_details)==null?void 0:o.thinking_tokens)??0,s=((i=e.output_tokens_details)==null?void 0:i.thinking_tokens)??0;return{input_tokens:n.input_tokens+e.input_tokens,output_tokens:n.output_tokens+e.output_tokens,cache_creation_input_tokens:(n.cache_creation_input_tokens??0)+(e.cache_creation_input_tokens??0),cache_read_input_tokens:(n.cache_read_input_tokens??0)+(e.cache_read_input_tokens??0),...t||s?{output_tokens_details:{thinking_tokens:t+s}}:{}}}function wc(n,e=!1){const t=Xn(n.cacheWriteTokens),s=Xn(n.cacheReadTokens),o=Xn(n.inputTokens),i={input_tokens:e?Math.max(0,o-t-s):o,output_tokens:Xn(n.outputTokens),cache_creation_input_tokens:t,cache_read_input_tokens:s},a=Xn(n.reasoningTokens);return a&&(i.output_tokens_details={thinking_tokens:a}),i.input_tokens===0&&i.output_tokens===0&&i.cache_creation_input_tokens===0&&i.cache_read_input_tokens===0&&a===0?null:i}function _C(n){if(!$t(n.modelMetrics))return null;let e=null;for(const t of Object.values(n.modelMetrics)){if(!$t(t)||!$t(t.usage))continue;const s=wc(t.usage,!0);s&&(e=Ri(e,s))}return e}function TC(n){if(typeof n=="string")return{label:n};if(!$t(n))return null;const e=we(n.label,n.title,n.value,n.name);if(!e)return null;const t=we(n.description);return t?{label:e,description:t}:{label:e}}function EC(n){return Array.isArray(n)?n.map(TC).filter(e=>e!==null):[]}function PC(n){if(!$t(n))return null;const e=we(n.question,n.prompt,n.text,n.message);if(!e)return null;const t=we(n.header,n.title),s=typeof n.multiSelect=="boolean"?n.multiSelect:typeof n.multi_select=="boolean"?n.multi_select:void 0;return{question:e,...t?{header:t}:{},options:EC(n.options??n.choices),...s===void 0?{}:{multiSelect:s}}}function AC(n){const t=(Array.isArray(n.questions)?n.questions:[n]).map(PC).filter(s=>s!==null);return t.length>0?{...n,questions:t}:n}function qo(n){switch(n.toLowerCase().replace(/-/g,"_")){case"ask_user":return"AskUserQuestion";case"bash":case"powershell":case"shell":return"Bash";case"create":return"Write";case"edit":return"Edit";default:return n}}function Wi(n,e){const t=$t(e)?e:e===void 0?{}:{value:e};return n==="AskUserQuestion"?AC(t):n==="Edit"?{...t,file_path:we(t.file_path,t.path),old_string:we(t.old_string,t.old_str),new_string:we(t.new_string,t.new_str)}:n==="Write"?{...t,file_path:we(t.file_path,t.path),content:we(t.content,t.file_text)}:n==="Bash"&&typeof t.command!="string"&&typeof t.cmd=="string"?{...t,command:t.cmd}:t}function RC(n){const e=n.error;if(typeof e=="string")return e;if($t(e)){const s=we(e.message,e.code);if(s)return s}const t=n.result;if(typeof t=="string")return t;if(!$t(t))return t===void 0?"":wl(t);if(typeof t.detailedContent=="string")return t.detailedContent;if(typeof t.content=="string")return t.content;if(Array.isArray(t.contents)){const s=t.contents.flatMap(o=>{const i=typeof o=="string"?o:$t(o)?we(o.text,o.content,o.output):"";return i?[i]:[]}).join(`
79
- `);if(s)return s}return t.structuredContent!==void 0?wl(t.structuredContent):wl(t)}function Am(n,e,t,s){if(!e||n.thinking.some(a=>a.thinking===e))return;const o={type:"thinking",thinking:e,signature:s};n.thinking.push(o);const i=n.contentBlocks[n.contentBlocks.length-1];if((i==null?void 0:i.kind)==="thinking"){i.blocks.push(o);return}n.contentBlocks.push({kind:"thinking",blocks:[o],timestamp:t})}function yi(n,e,t){n.toolCalls.push(e);const s=n.contentBlocks[n.contentBlocks.length-1];if((s==null?void 0:s.kind)==="tool_calls"){s.toolCalls.push(e);return}n.contentBlocks.push({kind:"tool_calls",toolCalls:[e],timestamp:t})}function Vo(n,e,t,s){return{id:n,name:e,input:t,result:null,isError:!1,timestamp:s}}function Rm(n,e,t){if(!Array.isArray(n))return[];const s=[];for(const o of n){if(!$t(o))continue;const i=we(o.toolCallId),a=we(o.name);if(!i||!a||t(i))continue;const l=qo(a);s.push(Vo(i,l,Wi(l,o.arguments),e))}return s}function Im(n,e,t,s){n.name=e,n.input=Wi(e,t),n.timestamp=s||n.timestamp}function $m(n,e,t){n.result=RC(e);const s=CC(e,t);s.length>0&&(n.resultImages=s),n.isError=e.success===!1||e.error!==void 0&&e.error!==null}function Mm(n,e,t,s,o,i){return{id:n,userMessage:t,contentBlocks:[],thinking:[],assistantText:[],toolCalls:[],subAgentActivity:[],timestamp:e,durationMs:null,tokenUsage:null,model:s,...o?{effort:o}:{},...i?{isFragment:!0}:{}}}function IC(n){return n.userMessage!==null||n.assistantText.length>0||n.thinking.length>0||n.toolCalls.length>0||n.subAgentActivity.length>0}function _x(n,e){const t=vC(n),s=kx(t),o=SC(t),i=[],a=new Map,l=new Map,c=new Map,d=new WeakMap,u=new WeakMap;let f=null,m=null,p,h=!1,g=!1,x=null;function b(C,N){N&&d.set(C,N)}function w(C){return f||(f=Mm(Em(C),Ko(C),null,m,p,!0)),f}function v(){f&&(IC(f)&&i.push(f),f=null)}function S(C){var $;const N=typeof C.agentId=="string"?C.agentId:"";if(!N)return null;const _=l.get(N);if(_)return _.message;const P=C.data,A=we(P.toolCallId),T=A?(($=a.get(A))==null?void 0:$.turn)??f:f;if(!T)return null;const E=we(P.executionMode),R={agentId:N,...A?{parentToolUseId:A}:{},agentName:we(P.agentDisplayName,P.agentName)||null,subagentType:we(P.agentType,P.agentName)||null,type:"assistant",content:null,toolCalls:[],thinking:[],text:[],timestamp:Ko(C),tokenUsage:null,model:we(P.model)||null,isBackground:E==="background",...we(P.description)?{prompt:we(P.description)}:{},status:"running"};return T.subAgentActivity.push(R),T.contentBlocks.push({kind:R.isBackground?"background_agent":"sub_agent",messages:[R],timestamp:R.timestamp}),l.set(N,{message:R,turn:T}),R}function j(C){if(jx(C))return!1;const N=S(C);if(!N)return!0;const{data:_}=C,P=Ko(C);if(C.type==="subagent.started"||C.type==="subagent.configured")return N.parentToolUseId||(N.parentToolUseId=we(_.toolCallId)||void 0),N.agentName=we(_.agentDisplayName,_.agentName)||N.agentName,N.subagentType=we(_.agentType,_.agentName)||N.subagentType,N.model=we(_.model)||N.model,N.prompt||(N.prompt=we(_.description)||void 0),N.isBackground||(N.isBackground=we(_.executionMode)==="background"),N.status="running",!0;if(C.type==="subagent.completed"||C.type==="subagent.failed"){N.agentName=we(_.agentDisplayName,_.agentName)||N.agentName,N.subagentType=we(_.agentType,_.agentName)||N.subagentType,N.model=we(_.model)||N.model,N.durationMs=Xn(_.durationMs)||N.durationMs,N.toolUseCount=Xn(_.totalToolCalls)||N.toolUseCount,N.status=C.type==="subagent.completed"?"completed":"failed";const A=we(_.error,_.message);return A&&!N.text.includes(A)&&N.text.push(A),!0}if(C.type==="user.message")return N.prompt||(N.prompt=we(_.content)||void 0),!0;if(C.type==="assistant.reasoning"){const A=we(_.content);return A&&!N.thinking.includes(A)&&N.thinking.push(A),!0}if(C.type==="assistant.message"){N.model=we(_.model)||N.model;const A=we(_.reasoningText);A&&!N.thinking.includes(A)&&N.thinking.push(A);const T=Pm(_.content);T&&!N.text.includes(T)&&N.text.push(T);for(const E of Rm(_.toolRequests,P,R=>c.has(R)))N.toolCalls.push(E),c.set(E.id,{call:E,message:N});return!0}if(C.type==="assistant.usage"){N.model=we(_.model)||N.model;const A=wc(_);return A&&(N.tokenUsage=Ri(N.tokenUsage,A)),!0}if(C.type==="tool.execution_start"){const A=we(_.toolCallId)||ds(C,"copilot-agent-tool"),T=we(_.toolName)||"Tool",E=qo(T),R=c.get(A);if(R)Im(R.call,E,_.arguments,P);else{const $=Vo(A,E,Wi(E,_.arguments),P);N.toolCalls.push($),c.set(A,{call:$,message:N})}return!0}if(C.type==="tool.execution_complete"){const A=we(_.toolCallId)||ds(C,"copilot-agent-tool");let T=c.get(A);if(!T){const E=we(_.toolName)||"Tool",R=qo(E),$=Vo(A,R,{},P);N.toolCalls.push($),T={call:$,message:N}}return $m(T.call,_,o),c.delete(A),!0}return!0}for(const C of t){if(j(C))continue;const{data:N}=C,_=Ko(C);if(C.type==="session.start"||C.type==="session.resume"){m=we(N.selectedModel)||m,p=we(N.reasoningEffort)||p;continue}if(C.type==="session.auto_mode_resolved"){m=we(N.chosenModel)||m,f&&(f.model=m);continue}if(C.type==="session.model_change"){m=we(N.newModel)||m;const P=N.reasoningEffort;typeof P=="string"&&(p=P),f&&(f.model=m,p&&(f.effort=p));continue}if(C.type==="session.shutdown"){m=we(N.currentModel)||m,f&&!f.model&&(f.model=m),x=_C(N)??x;const P=Xn(N.totalApiDurationMs);f&&!g&&P&&u.set(f,P);continue}if(C.type==="user.message"){v(),f=Mm(Em(C),_,kC(N,o),m,p,!1),b(f,_);continue}if(C.type==="assistant.turn_start"){m=we(N.model)||m;const P=w(C);P.model=m,p&&(P.effort=p),b(P,_);continue}if(C.type==="assistant.reasoning"){const P=w(C);Am(P,we(N.content),_,we(N.reasoningId)||ds(C,"copilot-thinking")),b(P,_);continue}if(C.type==="assistant.message"){m=we(N.model)||m;const P=w(C);P.model=m,p&&(P.effort=p),Am(P,we(N.reasoningText),_,ds(C,"copilot-thinking")),ix(P,Pm(N.content),_);for(const A of Rm(N.toolRequests,_,T=>a.has(T)))yi(P,A,_),a.set(A.id,{call:A,turn:P});b(P,_);continue}if(C.type==="assistant.usage"){m=we(N.model)||m,p=we(N.reasoningEffort)||p;const P=wc(N),A=Xn(N.duration);P&&(h=!0),A&&(g=!0);const T=w(C);T.model=m,p&&(T.effort=p),P&&(T.tokenUsage=Ri(T.tokenUsage,P)),A&&u.set(T,(u.get(T)??0)+A),b(T,_);continue}if(C.type==="tool.execution_start"){m=we(N.model)||m;const P=w(C);P.model=m;const A=we(N.toolCallId)||ds(C,"copilot-tool"),T=we(N.toolName)||"Tool",E=qo(T),R=a.get(A);if(R)Im(R.call,E,N.arguments,_);else{const $=Vo(A,E,Wi(E,N.arguments),_);yi(P,$,_),a.set(A,{call:$,turn:P})}b(P,_);continue}if(C.type==="tool.execution_complete"){m=we(N.model)||m;const P=we(N.toolCallId)||ds(C,"copilot-tool");let A=a.get(P);if(!A){const T=w(C),E=we(N.toolName)||"Tool",R=qo(E),$=Vo(P,R,{},_);yi(T,$,_),A={call:$,turn:T}}$m(A.call,N,o),a.delete(P),b(A.turn,_);continue}if(C.type==="session.error"){const P=w(C),T={errorType:we(N.errorType)||"unknown"};typeof N.statusCode=="number"&&(T.statusCode=N.statusCode),typeof N.errorCode=="string"&&(T.errorCode=N.errorCode),yi(P,{id:ds(C,"copilot-error"),name:"Error",input:T,result:we(N.message)||"Copilot session error",isError:!0,timestamp:_},_),b(P,_);continue}(C.type==="assistant.turn_end"||C.type==="assistant.idle"||C.type==="session.idle")&&f&&b(f,_)}if(v(),!h&&x&&i.length===1&&(i[0].tokenUsage=Ri(i[0].tokenUsage,x)),s.model)for(const C of i)C.model||(C.model=s.model);for(const C of i){const N=d.get(C),_=Date.parse(C.timestamp),P=N?Date.parse(N):Number.NaN;if(Number.isFinite(_)&&Number.isFinite(P)&&P>=_)C.durationMs=P-_;else{const A=u.get(C)??0;A&&(C.durationMs=A)}}const k=e!=null&&e.skipStats?Pa(i.length):Aa(i);return!(e!=null&&e.skipStats)&&!h&&x&&i.length>1&&(k.totalInputTokens=x.input_tokens,k.totalOutputTokens=x.output_tokens,k.totalCacheCreationTokens=x.cache_creation_input_tokens??0,k.totalCacheReadTokens=x.cache_read_input_tokens??0),{sessionId:s.sessionId,version:s.version,gitBranch:s.gitBranch,cwd:s.cwd,slug:s.slug,name:s.name,model:s.model,turns:i,stats:k,rawMessages:e!=null&&e.skipStats?[]:t,agentKind:"copilot"}}function $C(n,e){const t=n.rawMessages.map(s=>JSON.stringify(s)).join(`
80
- `);return _x(t?`${t}
81
- ${e}`:e)}function MC(n){return typeof n=="string"&&(n==="abort"||n==="binary_asset"||n==="user.message"||n.startsWith("assistant.")||n.startsWith("permission.")||n.startsWith("session.")||n.startsWith("subagent.")||n.startsWith("tool.")||n.startsWith("user_input."))}function OC(n){const e=new Map;for(const o of n){const i=typeof o.agentId=="string"?o.agentId:"";if(!i&&(o.type==="abort"||o.type==="session.shutdown"||o.type==="session.error")){e.clear();continue}if(!i||!o.type.startsWith("subagent."))continue;const a=$t(o.data)?o.data:{};if(o.type==="subagent.completed"||o.type==="subagent.failed"){e.delete(i);continue}if(o.type==="subagent.started"||o.type==="subagent.configured"){const l=[a.agentDisplayName,a.description,a.agentName].find(c=>typeof c=="string")??"";e.set(i,l||e.get(i)||"")}}if(e.size>0){const o=[...e.values()];return{status:"awaiting_agents",pendingQueue:0,pendingAgents:o.length,pendingAgentDescriptions:o.filter(i=>i.length>0)}}let t=!1;const s=new Set;for(let o=n.length-1;o>=0;o--){const i=n[o];if(typeof i.agentId=="string"&&i.agentId)continue;const a=$t(i.data)?i.data:{};switch(i.type){case"abort":case"session.shutdown":return{status:"completed"};case"assistant.turn_end":{for(let l=o-1;l>=0;l--){const c=n[l];if(typeof c.agentId=="string"&&c.agentId)continue;if(c.type==="user.message")break;if(c.type==="abort")return{status:"completed"};if(c.type!=="assistant.message")continue;const d=$t(c.data)?c.data:{};return Array.isArray(d.toolRequests)&&d.toolRequests.length>0?{status:"processing"}:{status:"completed"}}return{status:"processing"}}case"session.error":return{status:"completed",terminalReason:typeof a.message=="string"?a.message:"Copilot session error"};case"assistant.idle":case"session.idle":return{status:t?"completed":"idle"};case"permission.completed":{const l=typeof a.requestId=="string"?a.requestId:"";l&&s.add(l);continue}case"permission.requested":{const l=typeof a.requestId=="string"?a.requestId:"";if(l&&s.has(l))continue;return{status:"deferred"}}case"user_input.requested":return{status:"tool_use",toolName:"AskUserQuestion"};case"tool.execution_start":return s.size>0?{status:"thinking"}:{status:"tool_use",toolName:typeof a.toolName=="string"?gr(a.toolName):typeof a.name=="string"?gr(a.name):void 0};case"tool.execution_complete":return{status:"thinking"};case"assistant.turn_start":return{status:"processing"};case"assistant.message":case"assistant.message_delta":case"assistant.reasoning":case"assistant.reasoning_delta":return{status:"thinking"};case"user.message":return t=!0,{status:"processing"};case"session.start":case"session.resume":return{status:t?"processing":"idle"}}}return{status:"idle"}}function DC(){throw new Error("Copilot sessions branch through the CLI's fork API, not by copying the transcript")}function LC(n){const e=[];for(let t=0;t<n.length;t++){const s=n[t];if(s.type!=="user.message"||typeof s.agentId=="string")continue;const o=s.data;!o||typeof o!="object"||Array.isArray(o)||typeof s.id!="string"||!s.id||e.push(t)}return e}const Tx=ws[ws.length-1],zC={kind:"codex",descriptor:nn("codex"),detectsText:yx,detectsRecords:cC,parse:Bd,append:uC,metadataFromLines:dC,status:hC,brandBranch:gC,turnBoundaries:xC},FC={kind:"copilot",descriptor:nn("copilot"),detectsText:yC,detectsRecords:wC,parse:_x,append:$C,metadataFromLines:jC,status:OC,brandBranch:DC,turnBoundaries:LC},BC={kind:"claude",descriptor:nn("claude"),detectsText:wm,detectsRecords:wm,parse:Tk,append:Ek,metadataFromLines:_k,status:Mk,brandBranch:Ok,turnBoundaries:Dk},UC=Object.freeze({claude:BC,codex:zC,copilot:FC});function WC(n){function e(t){for(const s of ws){const o=n[s];if(t(o))return o}return n[Tx]}return{formatFor:t=>n[t],formatForText:t=>e(s=>s.detectsText(t)),formatForRecords:t=>e(s=>s.detectsRecords(t))}}const Ud=WC(UC);function Ex(n){return Ud.formatFor(n)}function Px(n){return Ud.formatForText(n)}function Ax(n){return Ud.formatForRecords(n)}function Rx(n,e){const t=e.map(s=>{try{const o=JSON.parse(s);return o&&typeof o=="object"&&!Array.isArray(o)?o:{}}catch{return{}}});return n.turnBoundaries(t)}function Ix(n,e,t){return Rx(n,e)[t]??e.length}function HC(n,e,t){let s=-1;for(let o=0;o<e.length;o++)if(e[o].includes(t))try{const i=JSON.parse(e[o]);if((i==null?void 0:i.uuid)===t){s=o;break}}catch{}return s<0?null:Rx(n,e).find(o=>o>s)??"keep-all"}function KC(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 qC(n,e){const t=n.contentBlocks,s=t.findIndex(o=>o.kind==="tool_calls"&&o.toolCalls.some(i=>i.id===e));return s===-1?!1:t.slice(s+1).some(o=>o.kind==="text"||o.kind==="thinking"||o.kind==="tool_calls")}function $x(n){const{turns:e}=n;if(e.length===0)return null;const t=e[e.length-1];if(!t||t.toolCalls.length===0)return null;const s=t.toolCalls[t.toolCalls.length-1];if(!s)return null;const{name:o}=s;if(o!=="ExitPlanMode"&&o!=="AskUserQuestion"||s.result!==null&&!s.isError||KC(e,o)||s.isError&&qC(t,s.id))return null;const i=s.input;if(o==="ExitPlanMode")return{type:"plan",allowedPrompts:i.allowedPrompts};const a=i.questions;return a&&a.length>0?{type:"question",toolUseId:s.id,questions:a}:null}function VC(n){return typeof n=="string"?n:n.filter(e=>e.type==="text").map(e=>e.text).join(`
82
- `)}function Ma(n,e){return Px(n).parse(n,e)}function GC(n,e){const t=Ax(n.rawMessages);return(t.kind===Tx?Px(e):t).append(n,e)}function Oa(n){return n===null?"":typeof n=="string"?n:VC(n)}function Mx(n){return n===null||typeof n=="string"?[]:n.filter(e=>e.type==="image")}const Ox=y.createContext(null);function YC(n){const e=[];for(let t=0;t<n.length;t+=1){const s=n[t],o=Mx(s.userMessage);for(let i=0;i<o.length;i+=1){const a=o[i];e.push({id:`${s.id}:attachment:${i}`,src:`data:${a.source.media_type};base64,${a.source.data}`,alt:`Attachment ${i+1} from turn ${t+1}`,label:`Turn ${t+1} · Image ${i+1}`})}}return e}function XC(n){const e=B.c(10),{images:t,children:s}=n,[o,i]=y.useState(null);let a;e[0]!==t?(a=m=>{const p=t.findIndex(g=>g.src===m.src),h=p>=0?t:[...t,{...m,id:m.id??`supplemental-image-${t.length}`}];i(g=>({key:((g==null?void 0:g.key)??0)+1,open:!0,images:h,index:p>=0?p:h.length-1}))},e[0]=t,e[1]=a):a=e[1];const l=a;let c;e[2]!==l?(c={openImage:l},e[2]=l,e[3]=c):c=e[3];const d=c;let u;e[4]!==o?(u=o&&r.jsx(Id,{open:o.open,images:o.images,initialIndex:o.index,onClose:()=>i(JC),onCloseComplete:()=>i(null)},o.key),e[4]=o,e[5]=u):u=e[5];let f;return e[6]!==s||e[7]!==u||e[8]!==d?(f=r.jsxs(Ox.Provider,{value:d,children:[s,u]}),e[6]=s,e[7]=u,e[8]=d,e[9]=f):f=e[9],f}function JC(n){return n?{...n,open:!1}:null}function QC(n){const e=B.c(7),{children:t}=n,{session:s}=it();s==null||s.turns;let o;e[0]!==(s==null?void 0:s.turns)?(o=(s==null?void 0:s.turns)??[],e[0]=s==null?void 0:s.turns,e[1]=o):o=e[1];let i;e[2]!==o?(i=YC(o),e[2]=o,e[3]=i):i=e[3];const a=i;let l;return e[4]!==t||e[5]!==a?(l=r.jsx(XC,{images:a,children:t}),e[4]=t,e[5]=a,e[6]=l):l=e[6],l}function Dx(){return y.useContext(Ox)}const Lx=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp",".ico",".avif"]);function ZC(n){if(!n)return!1;const e=n.lastIndexOf(".");return e===-1?!1:Lx.has(n.slice(e).toLowerCase())}function Wd(n){return!n||n.startsWith("http://")||n.startsWith("https://")||n.startsWith("data:")||!n.startsWith("/")?!1:ZC(n)}function e6(n){return n&&(Wd(n)?Rr(`/api/local-file?path=${encodeURIComponent(n)}`):n)}function jc(n){const e=B.c(41),{src:t,alt:s,id:o,className:i,thumbnailClassName:a}=n,l=o===void 0?"markdown-image":o,c=En("hostFiles"),[d,u]=y.useState(!1),[f,m]=y.useState(!1),[p,h]=y.useState(),g=Dx();let x;e[0]!==c||e[1]!==t?(x=Wd(t)&&!c,e[0]=c,e[1]=t,e[2]=x):x=e[2];const b=x;let w;e[3]!==b||e[4]!==t?(w=b?void 0:e6(t),e[3]=b,e[4]=t,e[5]=w):w=e[5];const v=w;let S;e[6]!==s||e[7]!==l||e[8]!==v?(S=v?{id:l,src:v,alt:s??"Rendered image",label:s||"Rendered image"}:null,e[6]=s,e[7]=l,e[8]=v,e[9]=S):S=e[9];const j=S;let k;e[10]!==g||e[11]!==j?(k=()=>{j&&(g?g.openImage(j):(m(!0),u(!0)))},e[10]=g,e[11]=j,e[12]=k):k=e[12];const C=k;if(b){let D;return e[13]!==s?(D=s?r.jsx("span",{className:"text-muted-foreground",children:s}):null,e[13]=s,e[14]=D):D=e[14],D}if(v&&p===v){const D=s?`: ${s}`:"";let O;return e[15]!==D?(O=r.jsxs("span",{role:"status",className:"my-3 block text-xs text-muted-foreground",children:["Image unavailable",D]}),e[15]=D,e[16]=O):O=e[16],O}const N=`Open ${s||"rendered image"}`;let _;e[17]!==i?(_=q("group/image relative my-3 block h-auto max-w-full overflow-hidden rounded-lg border border-border bg-background p-1 transition-colors hover:bg-muted focus-visible:ring-ring/40",i),e[17]=i,e[18]=_):_=e[18];const P=s??"";let A;e[19]!==v?(A=()=>h(v),e[19]=v,e[20]=A):A=e[20];let T;e[21]!==a?(T=q("max-h-96 max-w-full rounded-lg object-contain",a),e[21]=a,e[22]=T):T=e[22];let E;e[23]!==v||e[24]!==T||e[25]!==P||e[26]!==A?(E=r.jsx("img",{src:v,alt:P,loading:"lazy",decoding:"async",onError:A,className:T}),e[23]=v,e[24]=T,e[25]=P,e[26]=A,e[27]=E):E=e[27];let R;e[28]===Symbol.for("react.memo_cache_sentinel")?(R=r.jsx("span",{className:"absolute right-2 top-2 flex size-7 items-center justify-center rounded-md border border-white/10 bg-black/45 text-white/70 opacity-80 backdrop-blur transition-[color,background-color,opacity] group-hover/image:bg-black/65 group-hover/image:text-white sm:opacity-0 sm:group-hover/image:opacity-100 sm:group-focus-visible/image:opacity-100",children:r.jsx(da,{className:"size-3.5","data-icon":"icon"})}),e[28]=R):R=e[28];let $;e[29]!==C||e[30]!==E||e[31]!==N||e[32]!==_?($=r.jsxs(ee,{type:"button",variant:"ghost",onClick:C,"aria-label":N,className:_,children:[E,R]}),e[29]=C,e[30]=E,e[31]=N,e[32]=_,e[33]=$):$=e[33];let I;e[34]!==d||e[35]!==f||e[36]!==j?(I=f&&j&&r.jsx(Id,{open:d,images:[j],initialIndex:0,onClose:()=>u(!1),onCloseComplete:()=>m(!1)}),e[34]=d,e[35]=f,e[36]=j,e[37]=I):I=e[37];let M;return e[38]!==$||e[39]!==I?(M=r.jsxs(r.Fragment,{children:[$,I]}),e[38]=$,e[39]=I,e[40]=M):M=e[40],M}function t6(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("w-full caption-bottom text-sm",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:r.jsx("table",{"data-slot":"table",className:o,...s})}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function n6(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("[&_tr]:border-b",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("thead",{"data-slot":"table-header",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function s6(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("[&_tr:last-child]:border-0",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("tbody",{"data-slot":"table-body",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function o6(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("tr",{"data-slot":"table-row",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function r6(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("th",{"data-slot":"table-head",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function i6(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("td",{"data-slot":"table-cell",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function a6(n){if(!n)return null;let e=n;if(e.toLowerCase().startsWith("file://"))try{const l=new URL(e);e=`${l.pathname}${l.hash}`}catch{return null}const t=e.startsWith("/")&&!e.startsWith("//"),s=/^\/?[a-z]:[\\/]/i.test(e);if(!t&&!s)return null;let o,i;const a=e.match(/#L(\d+)(?:C(\d+))?$/i);if(a)o=Number(a[1]),i=a[2]?Number(a[2]):void 0,e=e.slice(0,-a[0].length);else{const l=e.match(/:(\d+)(?::(\d+))?$/);l&&(o=Number(l[1]),i=l[2]?Number(l[2]):void 0,e=e.slice(0,-l[0].length))}try{e=decodeURIComponent(e)}catch{return null}return/^\/[a-z]:[\\/]/i.test(e)&&(e=e.slice(1)),{path:e,line:o,column:i}}function l6(n){const e=B.c(17);let t,s,o;e[0]!==n?({href:s,children:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=En("hostFiles");let a;e[4]!==s?(a=a6(s),e[4]=s,e[5]=a):a=e[5];const l=a;if(l&&!i){let f;return e[6]!==t||e[7]!==s?(f=r.jsx("span",{className:"text-muted-foreground",title:s,children:t}),e[6]=t,e[7]=s,e[8]=f):f=e[8],f}let c;e[9]!==l||e[10]!==s?(c=f=>{s&&(f.preventDefault(),l?fr(l.path,{line:l.line,column:l.column}):window.open(s,"_blank","noopener,noreferrer"))},e[9]=l,e[10]=s,e[11]=c):c=e[11];const d=c;let u;return e[12]!==t||e[13]!==d||e[14]!==s||e[15]!==o?(u=r.jsx("a",{href:s,onClick:d,className:"text-primary underline decoration-primary/30 hover:decoration-primary/60 cursor-pointer transition-colors",title:s,...o,children:t}),e[12]=t,e[13]=d,e[14]=s,e[15]=o,e[16]=u):u=e[16],u}const c6=[...Lx].map(n=>n.slice(1)).join("|"),d6=new RegExp(`^([ \\t]*)(\\/[^\\s]+\\.(?:${c6}))[ \\t]*$`,"gim");function zx(n){return n.replace(d6,(e,t,s)=>`${t}![${s}](${s})`)}const qn={code:O5,pre({children:n}){return r.jsx(r.Fragment,{children:n})},a:l6,h1({children:n}){return r.jsx("h1",{className:"text-xl font-semibold mt-6 mb-3 pb-2 border-b border-border/40 text-foreground first:mt-0",children:n})},h2({children:n}){return r.jsx("h2",{className:"text-lg font-semibold mt-5 mb-2 pb-1.5 border-b border-border/30 text-foreground first:mt-0",children:n})},h3({children:n}){return r.jsx("h3",{className:"text-base font-semibold mt-4 mb-2 text-foreground first:mt-0",children:n})},h4({children:n}){return r.jsx("h4",{className:"text-sm font-semibold mt-3 mb-1.5 text-foreground first:mt-0",children:n})},h5({children:n}){return r.jsx("h5",{className:"text-sm font-medium mt-3 mb-1 text-foreground first:mt-0",children:n})},h6({children:n}){return r.jsx("h6",{className:"text-xs font-medium mt-3 mb-1 text-muted-foreground first:mt-0",children:n})},p({children:n}){return r.jsx("p",{className:"my-1.5 leading-[1.55] text-foreground/90 first:mt-0 last:mb-0 md:my-2 md:leading-relaxed",children:n})},blockquote({children:n}){return r.jsx("blockquote",{className:"my-2 rounded-r-md border-l-2 border-border bg-muted/30 py-1.5 pl-3 pr-2.5 text-foreground/80 [&>p]:my-1 md:my-3 md:py-2 md:pl-4 md:pr-3",children:n})},ul({children:n}){return r.jsx("ul",{className:"my-1.5 flex list-disc flex-col gap-0.5 pl-5 marker:text-muted-foreground/50 [&_ol]:my-1 [&_ul]:my-1 md:my-2 md:gap-1 md:pl-6",children:n})},ol({children:n}){return r.jsx("ol",{className:"my-1.5 flex list-decimal flex-col gap-0.5 pl-5 marker:text-muted-foreground/50 [&_ol]:my-1 [&_ul]:my-1 md:my-2 md:gap-1 md:pl-6",children:n})},li({children:n}){return r.jsx("li",{className:"pl-1 leading-[1.55] text-foreground/90 md:leading-relaxed",children:n})},hr(){return r.jsx(St,{className:"my-4"})},table({children:n}){return r.jsx("div",{className:"my-3 overflow-x-auto rounded-lg border border-border/40",children:r.jsx(t6,{className:"border-collapse text-sm",children:n})})},thead({children:n}){return r.jsx(n6,{className:"bg-muted/50",children:n})},tbody({children:n}){return r.jsx(s6,{children:n})},tr({children:n}){return r.jsx(o6,{className:"even:bg-muted/20",children:n})},th({children:n}){return r.jsx(r6,{className:"h-9 px-3 py-2 text-xs font-medium text-muted-foreground",children:n})},td({children:n}){return r.jsx(i6,{className:"px-3 py-2 text-foreground/90",children:n})},strong({children:n}){return r.jsx("strong",{className:"font-semibold text-foreground",children:n})},em({children:n}){return r.jsx("em",{className:"italic text-foreground/90",children:n})},del({children:n}){return r.jsx("del",{className:"line-through text-muted-foreground",children:n})},img:jc,input({checked:n,...e}){return r.jsx("input",{type:"checkbox",checked:n,readOnly:!0,className:"mr-2 rounded border-border accent-primary",...e})}},Qs=[ha],u6=["system-reminder","local-command-caveat","command-name","command-message","command-args","env","claude_background_info","fast_mode_info","gitStatus","user-prompt-submit-hook"],f6=u6.join("|");function Fx(){return new RegExp(`<(${f6})[^>]*>[\\s\\S]*?<\\/\\1>`,"g")}function Hd(n){return n.replace(Fx(),"").trim()}function m6(n){return Fx().test(n)}const p6=/<command-message>([^<]+)<\/command-message>/,h6=/<command-name>([\s\S]*?)<\/command-name>/,g6=/<command-args>([\s\S]*?)<\/command-args>/;function Bx(n){const e=n.match(p6);if(e)return e[1];const t=n.match(h6);return t?t[1].trim().replace(/^\//,""):null}function Ux(n){const e=n.match(g6);if(!e)return null;const t=e[1].trim();return t.length>0?t:null}const Wx={"local-command-stdout":"stdout","local-command-stderr":"stderr","bash-input":"input","bash-stdout":"stdout","bash-stderr":"stderr"},x6=new RegExp(`<(${Object.keys(Wx).join("|")})>([\\s\\S]*?)<\\/\\1>`,"g");function b6(n){const e=[],t=n.replace(x6,(s,o,i)=>(e.push({text:u1(i).trim(),stream:Wx[o]}),"")).trim();return{outputs:e,remainingText:t}}const v6=/<task-notification>([\s\S]*?)<\/task-notification>/g;function no(n,e){const t=n.match(new RegExp(`<${e}>([\\s\\S]*?)<\\/${e}>`));return t?t[1].trim():""}function xr(n){const e=[],t=n.replace(v6,(s,o)=>(e.push({taskId:no(o,"task-id"),toolUseId:no(o,"tool-use-id"),outputFile:no(o,"output-file"),status:no(o,"status"),summary:no(o,"summary"),result:no(o,"result")}),"")).trim();return{notifications:e,remainingText:t}}const y6=/\[Request interrupted by user[^\]]*\]/g;function Hx(n){const e=[],t=n.replace(y6,s=>(e.push(s),"")).trim();return{interrupts:e,remainingText:t}}const Om="[SYSTEM NOTIFICATION - NOT USER INPUT]";function Kx(n){const e=n.indexOf(Om);if(e===-1)return{text:n,isSystemNotification:!1};const t=e+Om.length,s=n.indexOf(`
83
-
84
- `,t),o=s===-1?t:s+2;return{text:(n.slice(0,e)+n.slice(o)).trim(),isSystemNotification:!0}}const Dm={Icon:B4,color:"text-destructive",bg:"border-destructive/20 bg-destructive/5",badgeVariant:"destructive"},Lm={completed:{Icon:F4,color:"text-success",bg:"border-success/20 bg-success/5",badgeVariant:"secondary",label:"Completed"},failed:{...Dm,label:"Failed"},error:{...Dm,label:"Error"},running:{Icon:U4,color:"text-warning",bg:"border-warning/20 bg-warning/5",badgeVariant:"outline",label:"Running"}};function qx(n){const e=B.c(32),{notification:t}=n,[s,o]=y.useState(!1),i=Lm[t.status]??Lm.running,{Icon:a}=i,l=t.result.length>0||t.outputFile.length>0,c=s?tt:Je;let d;e[0]!==i.bg?(d=q("my-1 rounded-lg border p-3",i.bg),e[0]=i.bg,e[1]=d):d=e[1];let u;e[2]!==i.color?(u=q("mt-0.5 size-4 shrink-0",i.color),e[2]=i.color,e[3]=u):u=e[3];let f;e[4]!==a||e[5]!==u?(f=r.jsx(a,{className:u}),e[4]=a,e[5]=u,e[6]=f):f=e[6];let m;e[7]!==t.summary?(m=r.jsx("span",{className:"text-sm font-medium text-foreground",children:t.summary}),e[7]=t.summary,e[8]=m):m=e[8];let p;e[9]!==i.badgeVariant||e[10]!==i.color||e[11]!==i.label?(p=r.jsx(_e,{variant:i.badgeVariant,className:i.color,children:i.label}),e[9]=i.badgeVariant,e[10]=i.color,e[11]=i.label,e[12]=p):p=e[12];let h;e[13]!==m||e[14]!==p?(h=r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[m,p]}),e[13]=m,e[14]=p,e[15]=h):h=e[15];let g;e[16]!==c||e[17]!==s||e[18]!==l||e[19]!==t.outputFile||e[20]!==t.result?(g=l&&r.jsxs(r.Fragment,{children:[r.jsxs(Mt,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"mt-1.5 -ml-2 text-muted-foreground"}),children:[r.jsx(c,{"data-icon":"inline-start"}),s?"Hide detail":"Show detail"]}),r.jsx(dt,{children:r.jsxs("div",{className:"mt-2 border-t border-border/30 pt-2 text-sm text-foreground/90",children:[t.result&&r.jsx(Un,{components:qn,remarkPlugins:Qs,children:t.result}),t.outputFile&&r.jsxs("div",{className:"mt-2",children:[r.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Output file"}),r.jsx("div",{className:"mt-1 select-all break-all rounded bg-muted px-2 py-1 font-mono text-xs text-muted-foreground",children:t.outputFile})]})]})})]}),e[16]=c,e[17]=s,e[18]=l,e[19]=t.outputFile,e[20]=t.result,e[21]=g):g=e[21];let x;e[22]!==h||e[23]!==g?(x=r.jsxs("div",{className:"min-w-0 flex-1",children:[h,g]}),e[22]=h,e[23]=g,e[24]=x):x=e[24];let b;e[25]!==f||e[26]!==x?(b=r.jsxs("div",{className:"flex items-start gap-2",children:[f,x]}),e[25]=f,e[26]=x,e[27]=b):b=e[27];let w;return e[28]!==s||e[29]!==d||e[30]!==b?(w=r.jsx(ct,{open:s,onOpenChange:o,className:d,children:b}),e[28]=s,e[29]=d,e[30]=b,e[31]=w):w=e[31],w}function w6(n){const e=B.c(7),{content:t}=n;let s,o,i;if(e[0]!==t){i=Symbol.for("react.early_return_sentinel");e:{const{notifications:l}=xr(t);if(l.length===0){i=null;break e}s="flex flex-col",o=l.map(j6)}e[0]=t,e[1]=s,e[2]=o,e[3]=i}else s=e[1],o=e[2],i=e[3];if(i!==Symbol.for("react.early_return_sentinel"))return i;let a;return e[4]!==s||e[5]!==o?(a=r.jsx("div",{className:s,children:o}),e[4]=s,e[5]=o,e[6]=a):a=e[6],a}function j6(n,e){return r.jsx(qx,{notification:n},n.taskId||`notification-${e}`)}function S6(n){const e=B.c(15),{output:t}=n,s=t.stream==="stderr",o=t.stream==="input",i=s&&"border-destructive/20 bg-destructive/5 text-destructive",a=o&&"border-border bg-muted/50 text-foreground",l=!s&&!o&&"border-border bg-muted/40 text-muted-foreground";let c;e[0]!==i||e[1]!==a||e[2]!==l?(c=q("rounded-md border px-3 py-2 my-1 font-mono text-xs",i,a,l),e[0]=i,e[1]=a,e[2]=l,e[3]=c):c=e[3];let d;e[4]!==s||e[5]!==o?(d=o?r.jsx(Je,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}):r.jsx(wo,{className:q("size-3 shrink-0",s?"text-destructive":"text-muted-foreground"),"data-icon":"inline-start"}),e[4]=s,e[5]=o,e[6]=d):d=e[6];let u;e[7]!==t.text?(u=r.jsx("span",{className:"whitespace-pre-wrap break-words",children:t.text}),e[7]=t.text,e[8]=u):u=e[8];let f;e[9]!==d||e[10]!==u?(f=r.jsxs("div",{className:"flex items-center gap-1.5",children:[d,u]}),e[9]=d,e[10]=u,e[11]=f):f=e[11];let m;return e[12]!==c||e[13]!==f?(m=r.jsx("div",{className:c,children:f}),e[12]=c,e[13]=f,e[14]=m):m=e[14],m}function N6(n){const e=B.c(6),{loading:t,content:s}=n;let o;if(t){let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground/60 font-mono",children:[r.jsx(f1,{className:"w-3 h-3 text-muted-foreground/60"})," Loading..."]}),e[0]=a):a=e[0],o=a}else if(s){let a;e[1]!==s?(a=r.jsx(Un,{components:qn,remarkPlugins:Qs,children:s}),e[1]=s,e[2]=a):a=e[2],o=a}else{let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("span",{className:"text-muted-foreground/60 font-mono",children:"Could not load command content"}),e[3]=a):a=e[3],o=a}let i;return e[4]!==o?(i=r.jsx("div",{className:"mt-2 max-h-80 overflow-auto rounded-md border border-border bg-muted/40 p-3 text-xs text-muted-foreground",children:o}),e[4]=o,e[5]=i):i=e[5],i}const Kd=y.memo(function({content:e,timestamp:t,onEditCommand:s,onExpandCommand:o,compact:i=!1}){const a=Dx(),[l,c]=y.useState(!1),[d,u]=y.useState(!1),[f,m]=y.useState(!1),[p,h]=y.useState(null),[g,x]=y.useState(!1),[b,w]=y.useState(null),v=y.useMemo(()=>Oa(e),[e]),S=y.useMemo(()=>Bx(v),[v]),j=y.useMemo(()=>Ux(v),[v]),{sender:k,body:C,matched:N}=y.useMemo(()=>hr(v),[v]),_=y.useMemo(()=>Hd(C),[C]),{text:P,isSystemNotification:A}=y.useMemo(()=>Kx(_),[_]),{notifications:T,remainingText:E}=y.useMemo(()=>xr(P),[P]),{outputs:R,remainingText:$}=y.useMemo(()=>b6(E),[E]),{interrupts:I,remainingText:M}=y.useMemo(()=>Hx($),[$]),D=y.useCallback(async V=>{if(!V){m(!1);return}if(p!==null){m(!0);return}if(!(!o||!S)){x(!0),m(!0);try{const Y=await o(S,j??void 0);h(Y)}finally{x(!1)}}},[p,o,S,j]),O=y.useMemo(()=>Mx(e),[e]),L=y.useMemo(()=>O.map(V=>`data:${V.source.media_type};base64,${V.source.data}`),[O]),F=y.useMemo(()=>L.map((V,Y)=>({id:`message-attachment-${Y}`,src:V,alt:`Attachment ${Y+1}`,label:L.length>1?`Attachment ${Y+1}`:"Attached image"})),[L]),z=y.useMemo(()=>m6(v)||A||N,[v,A,N]),W=d?v:M,H=W.length>500&&!l?W.slice(0,500)+"...":W,K=V=>{const Y=F[V];Y&&(a?a.openImage(Y):w({index:V,open:!0}))};return r.jsxs("div",{className:"group",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"flex items-center gap-2 mb-1",children:z&&r.jsx(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>u(!d),className:"-ml-2 text-muted-foreground",children:d?r.jsxs(r.Fragment,{children:[r.jsx(ua,{"data-icon":"inline-start"})," Hide raw"]}):r.jsxs(r.Fragment,{children:[r.jsx(ys,{"data-icon":"inline-start"})," Show raw"]})})}),!d&&A&&r.jsx("div",{className:"mb-2",children:r.jsxs(_e,{variant:"outline",className:"text-muted-foreground",children:[r.jsx(wo,{"data-icon":"inline-start"}),"System event"]})}),!d&&N&&r.jsx("div",{className:"mb-2",children:r.jsxs(_e,{variant:"outline",className:"text-muted-foreground",children:[r.jsx(ts,{"data-icon":"inline-start"}),k?`From ${k}`:"Teammate message"]})}),S&&r.jsxs(ct,{open:f,onOpenChange:V=>void D(V),className:"mb-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(_e,{variant:"outline",className:"font-mono text-foreground",children:[r.jsx(wo,{"data-icon":"inline-start"}),"/",S,j&&r.jsx("span",{className:"text-muted-foreground",children:j})]}),o&&r.jsxs(Mt,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"text-muted-foreground"}),children:[f?r.jsx(tt,{"data-icon":"inline-start"}):r.jsx(Je,{"data-icon":"inline-start"}),f?"Collapse":"Expand"]}),f&&s&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>s(S),className:"text-muted-foreground",children:[r.jsx(Vs,{"data-icon":"inline-start"}),"Edit"]})]}),r.jsx(dt,{children:r.jsx(N6,{loading:g,content:p})})]}),L.length>0&&r.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:L.map((V,Y)=>r.jsxs(ee,{type:"button",variant:"ghost",onClick:()=>K(Y),"aria-label":`Open attached image ${Y+1}`,className:q("group/image relative h-auto max-w-full overflow-hidden rounded-lg border border-border bg-background p-1 text-left","transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40"),children:[r.jsx("img",{src:V,alt:`Attachment ${Y+1}`,loading:"lazy",decoding:"async",className:"max-h-64 max-w-full rounded-lg object-contain sm:max-w-md"}),r.jsx("span",{className:"absolute right-2 top-2 flex size-7 items-center justify-center rounded-md border border-white/10 bg-black/45 text-white/70 opacity-80 backdrop-blur transition-[color,background-color,opacity] group-hover/image:bg-black/65 group-hover/image:text-white sm:opacity-0 sm:group-hover/image:opacity-100 sm:group-focus-visible/image:opacity-100",children:r.jsx(da,{className:"size-3.5","data-icon":"icon"})}),L.length>1&&r.jsxs("span",{className:"absolute bottom-2 right-2 rounded-md bg-black/55 px-1.5 py-0.5 font-mono text-xs text-white/80",children:[Y+1," / ",L.length]})]},`${O[Y].source.media_type}-${O[Y].source.data.slice(0,24)}-${Y}`))}),!d&&T.length>0&&r.jsx("div",{className:"mb-2 flex flex-col gap-2",children:T.map(V=>r.jsx(qx,{notification:V},V.taskId))}),!d&&R.length>0&&r.jsx("div",{className:"mb-2 flex flex-col gap-1",children:R.map((V,Y)=>r.jsx(S6,{output:V},Y))}),!d&&I.length>0&&r.jsx("div",{className:"mb-2 flex flex-col gap-1",children:I.map((V,Y)=>r.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-destructive",children:[r.jsx(Oy,{className:"size-3 shrink-0","data-icon":"inline-start"}),r.jsx("span",{children:V})]},Y))}),H&&r.jsx("div",{className:"max-w-none overflow-hidden break-words text-sm leading-relaxed",children:r.jsx(Un,{components:qn,remarkPlugins:Qs,children:H})}),W.length>500&&r.jsx(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>c(!l),className:"mt-1 -ml-2 text-muted-foreground",children:l?r.jsxs(r.Fragment,{children:[r.jsx(tt,{"data-icon":"inline-start"})," Show less"]}):r.jsxs(r.Fragment,{children:[r.jsx(Je,{"data-icon":"inline-start"})," Show more"]})}),!i&&t&&r.jsx("div",{className:"flex items-center mt-1.5 ml-auto",children:r.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(t).toLocaleTimeString()})})]}),b!==null&&r.jsx(Id,{open:b.open,images:F,initialIndex:b.index,onClose:()=>w(V=>V?{...V,open:!1}:null),onCloseComplete:()=>w(null)},b.index)]})}),Vx=y.memo(function(e){const t=B.c(10),{message:s,turnNumber:o}=e;let i;t[0]!==o?(i=r.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:["Turn ",o]}),t[0]=o,t[1]=i):i=t[1];let a;t[2]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(_e,{variant:"outline",children:"Queued"}),t[2]=a):a=t[2];let l;t[3]!==i?(l=r.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[i,a]}),t[3]=i,t[4]=l):l=t[4];let c;t[5]!==s?(c=r.jsx("div",{className:"rounded-lg border border-dashed bg-prompt-surface p-3",children:r.jsx(Kd,{content:s,timestamp:""})}),t[5]=s,t[6]=c):c=t[6];let d;return t[7]!==l||t[8]!==c?(d=r.jsxs("div",{className:"motion-enter group relative px-4 py-5",children:[l,c]}),t[7]=l,t[8]=c,t[9]=d):d=t[9],d}),Gx=y.memo(function(e){const t=B.c(30),{progress:s,expanded:o,onExpandedChange:i}=e,[a,l]=y.useState(!1),c=o??a,{todos:d,completed:u,total:f}=s,m=f>0?u/f*100:0;let p;t[0]!==i?(p=P=>{i==null||i(P),l(P)},t[0]=i,t[1]=p):p=t[1];let h;t[2]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(ee,{type:"button",variant:"ghost",className:"h-auto w-full justify-start rounded-none px-3 py-2"}),t[2]=h):h=t[2];let g;t[3]!==c?(g=c?r.jsx(tt,{"data-icon":"inline-start"}):r.jsx(kr,{"data-icon":"inline-start"}),t[3]=c,t[4]=g):g=t[4];let x;t[5]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx("span",{className:"text-sm font-medium",children:"Tasks"}),t[5]=x):x=t[5];let b;t[6]!==u||t[7]!==f?(b=r.jsxs("span",{className:"font-mono text-xs tabular-nums text-muted-foreground",children:[u,"/",f]}),t[6]=u,t[7]=f,t[8]=b):b=t[8];let w;t[9]!==m?(w=m.toFixed(0),t[9]=m,t[10]=w):w=t[10];const v=`${w}% of tasks complete`;let S;t[11]!==m||t[12]!==v?(S=r.jsx(Lr,{value:m,className:"max-w-[200px] flex-1","aria-label":v}),t[11]=m,t[12]=v,t[13]=S):S=t[13];let j;t[14]!==s.inProgress?(j=s.inProgress&&r.jsxs("span",{className:"flex min-w-0 items-center gap-1 truncate text-xs text-info",children:[r.jsx(ot,{className:"size-3 shrink-0 animate-spin"}),r.jsx("span",{className:"truncate",children:s.inProgress.activeForm})]}),t[14]=s.inProgress,t[15]=j):j=t[15];let k;t[16]!==g||t[17]!==b||t[18]!==S||t[19]!==j?(k=r.jsxs(Mt,{render:h,children:[g,x,b,S,j]}),t[16]=g,t[17]=b,t[18]=S,t[19]=j,t[20]=k):k=t[20];let C;t[21]!==d?(C=d.map(k6),t[21]=d,t[22]=C):C=t[22];let N;t[23]!==C?(N=r.jsx(dt,{children:r.jsx("div",{className:"px-3 pb-3 pt-1",children:r.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:C})})}),t[23]=C,t[24]=N):N=t[24];let _;return t[25]!==c||t[26]!==p||t[27]!==k||t[28]!==N?(_=r.jsxs(ct,{open:c,onOpenChange:p,className:"shrink-0 border-t bg-background",children:[k,N]}),t[25]=c,t[26]=p,t[27]=k,t[28]=N,t[29]=_):_=t[29],_});function k6(n,e){return r.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[n.status==="completed"?r.jsx(Bn,{className:"size-3 shrink-0 text-success"}):n.status==="in_progress"?r.jsx(ot,{className:"size-3 shrink-0 animate-spin text-info"}):r.jsx(Qc,{className:"size-3 shrink-0 text-muted-foreground"}),r.jsx("span",{className:q("truncate text-xs",n.status==="in_progress"?"text-foreground":"text-muted-foreground",n.status==="completed"&&"line-through"),children:n.content}),n.owner&&r.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:n.owner})]},n.id??e)}function Kr(n,e){const t=B.c(8);let s;t[0]!==e||t[1]!==n?(s=()=>{if(typeof window>"u")return e;try{const d=localStorage.getItem(n);return d===null?e:JSON.parse(d)}catch{return e}},t[0]=e,t[1]=n,t[2]=s):s=t[2];const[o,i]=y.useState(s);let a;t[3]!==n?(a=d=>{i(u=>{const f=typeof d=="function"?d(u):d;try{localStorage.setItem(n,JSON.stringify(f))}catch(m){const p=m;console.warn(`useLocalStorage: failed to serialize value for key "${n}"`,p)}return f})},t[3]=n,t[4]=a):a=t[4];const l=a;let c;return t[5]!==l||t[6]!==o?(c=[o,l],t[5]=l,t[6]=o,t[7]=c):c=t[7],c}function Yx(n){return`${n.provider}:${n.latestVersion??"unknown"}`}function C6(n,e){const t=e.split(":")[0];return[...n.filter(s=>s.split(":")[0]!==t),e]}const _6="cogpit:provider-update-dismissals:v1";function T6(n,e){return n.filter(t=>t.status==="behind"&&!e.includes(Yx(t)))}async function E6(n){const e=await ve("/api/provider-updates",{signal:n});if(!e.ok)throw new Error(`Provider update check failed (${e.status})`);return(await e.json()).providers??[]}async function P6(n){const e=await ve("/api/provider-updates/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:n})}),t=await e.json();if(!t.status)throw new Error(t.error??`Update failed (${e.status})`);return t}const A6=360*60*1e3;function R6(){const[n,e]=y.useState([]),[t,s]=Kr(_6,[]),[o,i]=y.useState(null),[a,l]=y.useState(null);y.useEffect(()=>{const u=new AbortController,f=()=>{E6(u.signal).then(e).catch(()=>{})};f();const m=setInterval(f,A6);return()=>{u.abort(),clearInterval(m)}},[]);const c=y.useCallback(async u=>{i(u),l(null);try{const f=await P6(u);l(f),e(m=>m.map(p=>p.provider===u?f.info:p))}catch(f){l({provider:u,status:"failed",message:f instanceof Error?f.message:"Update failed.",output:null})}finally{i(null)}},[]),d=y.useCallback(u=>{s(f=>C6(f,Yx(u)))},[s]);return{pending:T6(n,t),updating:o,outcome:a,update:c,dismiss:d,clearOutcome:y.useCallback(()=>l(null),[])}}const I6=5e3,$6={warning:"border-warning/30 bg-warning/10 text-warning",destructive:"border-destructive/30 bg-destructive/10 text-destructive",success:"border-success/30 bg-success/10 text-success"};function jl(n){return`grid-cols-[auto_minmax(0,1fr)_auto] rounded-none border-x-0 border-t-0 px-4 py-2 ${$6[n]}`}function zm(n){const e=n.currentVersion?`v${n.currentVersion}`:"an older build";return`${n.displayName} ${e} → v${n.latestVersion}`}function Xx(){const n=B.c(39),{pending:e,updating:t,outcome:s,update:o,dismiss:i,clearOutcome:a}=R6(),l=lt("configWrite"),c=(s==null?void 0:s.status)==="succeeded";let d,u;if(n[0]!==a||n[1]!==c?(d=()=>{if(!c)return;const E=setTimeout(a,I6);return()=>clearTimeout(E)},u=[c,a],n[0]=a,n[1]=c,n[2]=d,n[3]=u):(d=n[2],u=n[3]),y.useEffect(d,u),s){let E;return n[4]!==a||n[5]!==s.message||n[6]!==c?(E=c?r.jsxs(ht,{className:jl("success"),children:[r.jsx(Cr,{}),r.jsx(Tt,{children:s.message}),r.jsx(gt,{className:"text-success/80",children:"New sessions will use the updated CLI."})]}):r.jsxs(ht,{className:jl("destructive"),children:[r.jsx(Ys,{}),r.jsx(Tt,{children:"Update did not complete"}),r.jsx(gt,{className:"text-destructive/80",children:s.message}),r.jsx(Cs,{className:"static col-start-3 row-span-2 row-start-1 self-center",children:r.jsx(ee,{variant:"ghost",size:"xs",onClick:a,children:"Dismiss"})})]}),n[4]=a,n[5]=s.message,n[6]=c,n[7]=E):E=n[7],E}if(e.length===0)return null;const f=e[0],m=e.filter(E=>E.updateCommand!==null&&l),p=ht;let h;n[8]===Symbol.for("react.memo_cache_sentinel")?(h=jl("warning"),n[8]=h):h=n[8];let g;n[9]!==t?(g=t?r.jsx(ot,{className:"animate-spin"}):r.jsx(xn,{}),n[9]=t,n[10]=g):g=n[10];let x;n[11]!==f||n[12]!==e?(x=e.length===1?zm(f):`${e.map(M6).join(" and ")} are out of date`,n[11]=f,n[12]=e,n[13]=x):x=n[13];let b;n[14]!==x?(b=r.jsx(Tt,{children:x}),n[14]=x,n[15]=b):b=n[15];const w=e.length>1?e.map(zm).join(" · "):m.length===1?`Cogpit can run \`${f.updateCommand}\` for you.`:f.updateCommand?`Run \`${f.updateCommand}\` to upgrade.`:"Update it with whatever installed it — Cogpit could not tell.";let v;n[16]!==w?(v=r.jsx(gt,{className:"text-warning/80",children:w}),n[16]=w,n[17]=v):v=n[17];const S=Cs,j="static col-start-3 row-span-2 row-start-1 flex items-center gap-2 self-center";let k;n[18]!==e.length||n[19]!==o||n[20]!==t?(k=E=>r.jsxs(ee,{variant:"outline",size:"xs",disabled:t!==null,onClick:()=>void o(E.provider),children:[r.jsx(sc,{"data-icon":"inline-start"}),t===E.provider?"Updating…":e.length===1?"Update":`Update ${E.displayName}`]},E.provider),n[18]=e.length,n[19]=o,n[20]=t,n[21]=k):k=n[21];const C=m.map(k),N=t!==null;let _;n[22]!==i||n[23]!==e?(_=()=>e.forEach(i),n[22]=i,n[23]=e,n[24]=_):_=n[24];let P;n[25]!==N||n[26]!==_?(P=r.jsx(ee,{variant:"ghost",size:"xs",disabled:N,onClick:_,className:"whitespace-nowrap text-muted-foreground",children:"Don't show again"}),n[25]=N,n[26]=_,n[27]=P):P=n[27];let A;n[28]!==S||n[29]!==C||n[30]!==P?(A=r.jsxs(S,{className:j,children:[C,P]}),n[28]=S,n[29]=C,n[30]=P,n[31]=A):A=n[31];let T;return n[32]!==p||n[33]!==A||n[34]!==h||n[35]!==g||n[36]!==b||n[37]!==v?(T=r.jsxs(p,{className:h,children:[g,b,v,A]}),n[32]=p,n[33]=A,n[34]=h,n[35]=g,n[36]=b,n[37]=v,n[38]=T):T=n[38],T}function M6(n){return n.displayName}function Jx(){const n=B.c(27),[e,t]=y.useState(null),[s,o]=y.useState(null),[i,a]=y.useState(!1);let l,c;if(n[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{const d=window.electronUpdater;d&&(d.onUpdateAvailable(u=>{t(u)}),d.onUpdateDownloaded(u=>{o(u)}))},c=[],n[0]=l,n[1]=c):(l=n[0],c=n[1]),y.useEffect(l,c),s&&!i){let d;n[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(sc,{}),n[2]=d):d=n[2];let u;n[3]!==s.version?(u=r.jsxs(Tt,{children:["Cogpit v",s.version," is ready"]}),n[3]=s.version,n[4]=u):u=n[4];let f;n[5]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(gt,{className:"text-success/80",children:"Restart to apply the update."}),n[5]=f):f=n[5];let m;n[6]===Symbol.for("react.memo_cache_sentinel")?(m=()=>a(!0),n[6]=m):m=n[6];let p;n[7]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(Cs,{className:"static col-start-3 row-span-2 row-start-1 self-center",children:r.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:m,"aria-label":"Dismiss update",children:r.jsx(rt,{"data-icon":"inline-start"})})}),n[7]=p):p=n[7];let h;return n[8]!==u?(h=r.jsxs(ht,{className:"grid-cols-[auto_minmax(0,1fr)_auto] rounded-none border-x-0 border-t-0 border-success/30 bg-success/10 px-4 py-2 pr-4 text-success has-data-[slot=alert-action]:pr-4",children:[d,u,f,p]}),n[8]=u,n[9]=h):h=n[9],h}if(e&&!i){let d;n[10]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(sc,{}),n[10]=d):d=n[10];let u;n[11]!==e.version?(u=r.jsxs(Tt,{children:["Cogpit v",e.version," is available"]}),n[11]=e.version,n[12]=u):u=n[12];let f;n[13]!==e.platform?(f=e.platform!=="mac"&&r.jsx(gt,{children:"Update through your package manager."}),n[13]=e.platform,n[14]=f):f=n[14];let m;n[15]!==e.platform||n[16]!==e.url?(m=e.platform==="mac"&&r.jsxs(ee,{variant:"outline",size:"xs",render:r.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer"}),nativeButton:!1,children:[r.jsx(Dy,{"data-icon":"inline-start"}),"Download"]}),n[15]=e.platform,n[16]=e.url,n[17]=m):m=n[17];let p;n[18]!==e.version?(p=r.jsx(ee,{variant:"ghost",size:"xs",onClick:()=>{var x;a(!0),(x=window.electronUpdater)==null||x.dismissVersion(e.version)},className:"whitespace-nowrap text-muted-foreground",children:"Don't show again"}),n[18]=e.version,n[19]=p):p=n[19];let h;n[20]!==m||n[21]!==p?(h=r.jsxs(Cs,{className:"static col-start-3 row-span-2 row-start-1 flex items-center gap-2 self-center",children:[m,p]}),n[20]=m,n[21]=p,n[22]=h):h=n[22];let g;return n[23]!==u||n[24]!==f||n[25]!==h?(g=r.jsxs(ht,{className:"grid-cols-[auto_minmax(0,1fr)_auto] rounded-none border-x-0 border-t-0 border-info/30 bg-info/10 px-4 py-2 pr-4 text-info has-data-[slot=alert-action]:pr-4",children:[d,u,f,h]}),n[23]=u,n[24]=f,n[25]=h,n[26]=g):g=n[26],g}return null}const Qx=y.createContext(null);function Ii(n){const e=B.c(3),{value:t,children:s}=n;let o;return e[0]!==s||e[1]!==t?(o=r.jsx(Qx.Provider,{value:t,children:s}),e[0]=s,e[1]=t,e[2]=o):o=e[2],o}function zt(){const n=y.useContext(Qx);if(!n)throw new Error("useAppContext must be used within an AppProvider");return n}const br=null,{min:Ls,max:jn,abs:Fm,floor:O6}=Math,Zx=(n,e,t)=>Ls(t,jn(e,n)),e0=n=>[...n].sort((e,t)=>e-t),t0=typeof queueMicrotask=="function"?queueMicrotask:n=>{Promise.resolve().then(n)},Sc=()=>{let n;return[new Promise(e=>{n=e}),n]},n0=n=>{let e;return()=>(n&&(e=n(),n=void 0),e)},er=(n,e,t)=>{const s=t?"unshift":"push";for(let o=0;o<e;o++)n[s](-1);return n},s0=(n,e)=>{const t=n.t[e];return t===-1?n.o:t},D6=(n,e,t)=>{const s=n.t[e]===-1;return n.t[e]=t,n.i=Ls(e,n.i),s},$i=(n,e)=>{if(!n.l)return 0;if(n.i>=e)return n.u[e];n.i<0&&(n.u[0]=0,n.i=0);let t=n.i,s=n.u[t];for(;t<e;)s+=s0(n,t),n.u[++t]=s;return n.i=e,s},so=(n,e,t=0,s=n.l-1)=>{let o=t;for(;t<=s;){const i=O6((t+s)/2);$i(n,i)<=e?(o=i,t=i+1):s=i-1}return Zx(o,0,n.l-1)},Bm=(n,e,t)=>{const s=e-n.l;return n.i=t?-1:Ls(e-1,n.i),n.l=e,s>0?(er(n.u,s),er(n.t,s,t),n.o*s):(n.u.splice(s),(t?n.t.splice(0,-s):n.t.splice(s)).reduce((o,i)=>o-(i===-1?n.o:i),0))},L6=typeof window<"u",z6=n=>n.documentElement,F6=n=>n.ownerDocument,B6=n=>n.defaultView,o0=n0(()=>!!/iP(hone|od|ad)/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>0),U6=n0(()=>"scrollBehavior"in z6(document).style),W6=n=>jn(n.h(),n.p()),H6=(n,e=40,t=0,s,o=!1)=>{let i=!!t,a=1,l=0,c=0,d=0,u=0,f=0,m=0,p=0,h=0,g=br,x=[0,i?jn(t-1,0):-1],b=0,w=!1;const v=((E,R,$)=>({o:R,t:$?er($.slice(0,Ls(E,$.length)),jn(0,E-$.length)):er([],E),l:E,i:-1,u:er([],E+1)}))(n,s?s[1]:e,s&&s[0]),S=new Set,j=()=>d-c,k=()=>j()+f+u,C=(E,R)=>(($,I,M,D)=>{if(D=Ls(D,$.l-1),$i($,D)<=I){const O=so($,M,D);return[so($,I,D,O),O]}{const O=so($,I,void 0,D);return[O,so($,M,O)]}})(v,E,R,x[0]),N=()=>$i(v,v.l),_=(E,R)=>{const $=$i(v,E)-f;return R?N()-$-P(E):$},P=E=>s0(v,E),A=(E,R=-1)=>v.t[E]===R,T=E=>{E&&(o0()&&p!==0||g&&h===1?f+=E:u+=E)};return{v:()=>{S.clear()},m:()=>a,_:()=>(E=>[E.t.slice(),E.o])(v),S:(E=200)=>{if(!w||i)return x;let R,$;if(m)[R,$]=x;else{let I=jn(0,k()),M=I+l;o||(E=jn(0,E),p!==1&&(I-=E),p!==2&&(M+=E)),[R,$]=x=C(jn(0,I),jn(0,M)),g&&(R=Ls(R,g[0]),$=jn($,g[1]))}return[jn(R,0),Ls($,v.l-1)]},$:E=>so(v,E-c),I:A,k:_,R:P,T:()=>v.l,C:()=>d,M:()=>p!==0,p:()=>l,O:()=>c,h:N,H:()=>(m=u,u=0,[m,h===2]),W:(E,R)=>{const $=[E,R];return S.add($),()=>{S.delete($)}},B:(E,R)=>{let $,I,M=0;switch(E){case 1:{if(R===d&&h===0)break;const D=m;m=0;const O=R-d,L=Fm(O);D&&L<Fm(D)+1||h!==0||(p=O<0?2:1),i&&(i=!1),d=R,M=4;const F=j();F>=-l&&F<=N()&&(M+=1,I=L>l);break}case 2:M=8,p!==0&&($=!0,M+=1),p=0,h=0,g=br;break;case 3:{const D=R.filter(([O,L])=>!A(O,L));if(!D.length)break;T(D.reduce((O,[L,F])=>{let z;if(h===2)z=!0;else if(g&&h===1)z=L<g[0];else{const W=j(),U=_(L),H=P(L);z=p!==1&&h===0?U+H<=W:U<W&&U+H<W+l}return z&&(O+=F-P(L)),O},0));for(const[O,L]of D){const F=P(O),z=D6(v,O,L);o&&(b+=z?L:L-F)}o&&l&&b>l&&(T(((O,L)=>{let F=0;const z=[];O.t.forEach((Y,G)=>{Y!==-1&&(z.push(Y),G<L&&F++)}),O.i=-1;const W=e0(z),U=W.length,H=U/2|0,K=U%2==0?(W[H-1]+W[H])/2:W[H],V=O.o;return((O.o=K)-V)*jn(L-F,0)})(v,so(v,k()))),o=!1),M=3,I=!0;break}case 4:l!==R&&(l||(w=I=!0),l=R,M=3);break;case 5:R[1]?(T(Bm(v,R[0],!0)),h=2,M=1):(Bm(v,R[0]),M=1);break;case 6:c=R;break;case 7:h=1;break;case 8:g=C(R,R+l),M=1}M&&(a=1+(2147483647&a),$&&f&&(u+=f,f=0),S.forEach(([D,O])=>{M&D&&O(I)}))}}},qd=setTimeout,Sl=(n,e)=>e?-n:n,K6=(n,e,t,s,o,i)=>{const a=Date.now;let l=0,c=!1,d=!1,u=!1,f=!1;const m=(()=>{let b;const w=()=>{b!=br&&clearTimeout(b)},v=()=>{w(),b=qd(()=>{b=br,(()=>{if(c||d)return c=!1,void m();u=!1,n.B(2)})()},150)};return v.J=w,v})(),p=()=>{l=a(),u&&(f=!0),n.B(1,s()),m()},h=b=>{if(c||!n.M()||b.ctrlKey)return;const w=a()-l;150>w&&50<w&&(t?b.deltaX:b.deltaY)&&(c=!0)},g=()=>{d=!0,u=f=!1},x=()=>{d=!1,o0()&&(u=!0)};return e.addEventListener("scroll",p),e.addEventListener("wheel",h,{passive:!0}),e.addEventListener("touchstart",g,{passive:!0}),e.addEventListener("touchend",x,{passive:!0}),{A:()=>{e.removeEventListener("scroll",p),e.removeEventListener("wheel",h),e.removeEventListener("touchstart",g),e.removeEventListener("touchend",x),m.J()},L:()=>{const[b,w]=n.H();b&&(o(b,w,f),f=!1,w&&n.p()>n.h()&&n.B(1,s()))}}},q6=(n,e,t)=>{let s;return[async(o,i)=>{if(!await e())return;s&&s();const a=()=>{const[l,c]=Sc();return s=()=>{c(!1)},n.p()&&qd(s,150),[l,n.W(2,()=>{c(!0)})]};if(i&&U6())n.B(8,o()),t0(async()=>{for(;;){let l=!0;for(let[u,f]=n.S();u<=f;u++)if(n.I(u)){l=!1;break}if(l)break;const[c,d]=a();try{if(!await c)return}finally{d()}}n.B(7),t(o(),i)});else for(;;){const[l,c]=a();try{if(n.B(7),t(o()),!await l)return}finally{c()}}},()=>{s&&s()}]},V6=(n,e)=>{let t,s,o=Sc(),i=!1;const a=e?"scrollLeft":"scrollTop",l=e?"overflowX":"overflowY",[c,d]=q6(n,()=>o[0],(u,f)=>{u=Sl(u,i),f?t.scrollTo({[e?"left":"top"]:u,behavior:"smooth"}):t[a]=u});return{N(u,f){t=f,e&&(i=getComputedStyle(f).direction==="rtl"),s=K6(n,f,e,()=>Sl(f[a],i),(m,p,h)=>{if(h){const g=f.style,x=g[l];g[l]="hidden",qd(()=>{g[l]=x})}f[a]=Sl(n.C()+m,i),p&&d()}),o[1](!0)},v(){s&&s.A(),o[1](!1),o=Sc()},P:()=>i,V(u){c(()=>u)},X(u){u+=n.C(),c(()=>u)},Y(u,{align:f,smooth:m,offset:p=0}={}){if(u=Zx(u,0,n.T()-1),f==="nearest"){const h=n.k(u),g=n.C();if(h<g)f="start";else{if(!(h+n.R(u)>g+n.p()))return;f="end"}}c(()=>p+n.O()+n.k(u)+(f==="end"?n.R(u)-n.p():f==="center"?(n.R(u)-n.p())/2:0),m)},q:()=>{s&&s.L()}}},G6=n=>{let e;return{j(t){(e||(e=new(B6(F6(t))).ResizeObserver(n))).observe(t)},D(t){e.unobserve(t)},A(){e&&e.disconnect()}}},Y6=(n,e)=>{let t;const s=e?"width":"height",o=new WeakMap,i=G6(a=>{const l=[];for(const{target:c,contentRect:d}of a)if(c.offsetParent)if(c===t)n.B(4,d[s]);else{const u=o.get(c);u!=br&&l.push([u,d[s]])}l.length&&n.B(3,l)});return{G(a){i.j(t=a)},U:(a,l)=>(o.set(a,l),i.j(a),()=>{o.delete(a),i.D(a)}),v:i.A}},Hi=L6?y.useLayoutEffect:y.useEffect,sn="current",r0=(n,e)=>{if(Array.isArray(n))for(const t of n)r0(t,e);else n==null||typeof n=="boolean"||e.push(n)},X6=(n,e)=>{const t=n.key;return t??"_"+e},J6=n=>{const e=y.useRef(null);return e[sn]||(e[sn]=n())},Um=n=>{const e=y.useRef(n);return Hi(()=>{e[sn]=n},[n]),e},Q6=y.memo(({Z:n,ee:e,te:t,oe:s,ne:o,re:i,se:a,ie:l})=>{const c=y.useRef(null);Hi(()=>e(c[sn],t),[t]);const d=y.useMemo(()=>{const u={contain:"layout style",position:o&&l?void 0:"absolute",[a?"height":"width"]:"100%",[a?"top":"left"]:0,[a?"left":"top"]:s,visibility:!o||l?void 0:"hidden"};return a&&(u.display="inline-flex"),u},[s,o,l,a]);return r.jsx(i,typeof i=="string"?{ref:c,style:d,children:n}:{ref:c,style:d,index:t,children:n})}),Z6=(n,e)=>y.useMemo(()=>{if(typeof n=="function")return[s=>n(e[s],s),e.length];const t=(s=>{const o=[];return r0(s,o),o})(n);return[s=>t[s],t.length]},[n,e]),e_=y.forwardRef(({children:n,data:e,bufferSize:t,itemSize:s,shift:o,horizontal:i,keepMounted:a,cache:l,startMargin:c=0,ssrCount:d,as:u="div",item:f="div",scrollRef:m,onScroll:p,onScrollEnd:h},g)=>{const[x,b]=Z6(n,e),w=y.useRef(null),v=y.useRef(!!d),S=Um(p),j=Um(h),[k,C,N,_]=J6(()=>{const M=!!i,D=H6(b,s,d,l,!s);return[D,Y6(D,M),V6(D,M),M]});b!==k.T()&&k.B(5,[b,o]),c!==k.O()&&k.B(6,c);const[P,A]=y.useReducer(k.m,void 0,k.m),T=k.M(),E=k.h(),R=N.P(),$=[],I=M=>{const D=x(M);return r.jsx(Q6,{ee:C.U,te:M,oe:k.k(M,R),ne:k.I(M),re:f,Z:D,se:_,ie:v[sn]},X6(D,M))};if(Hi(()=>{v[sn]=!1,k.W(1,O=>{O?jv.flushSync(A):A()}),k.W(4,()=>{S[sn]&&S[sn](k.C())}),k.W(8,()=>{j[sn]&&j[sn]()});const M=w[sn],D=O=>{C.G(O),N.N(M,O)};return m?t0(()=>{m[sn]&&D(m[sn])}):D(M.parentElement),()=>{k.v(),C.v(),N.v()}},[]),Hi(()=>{N.q()},[P]),y.useImperativeHandle(g,()=>({get cache(){return k._()},get scrollOffset(){return k.C()},get scrollSize(){return W6(k)},get viewportSize(){return k.p()},findItemIndex:k.$,getItemOffset:k.k,getItemSize:k.R,scrollToIndex:N.Y,scrollTo:N.V,scrollBy:N.X}),[]),a){const M=new Set(a);for(let[D,O]=k.S(t);D<=O;D++)M.add(D);e0([...M]).forEach(D=>{$.push(I(D))})}else for(let[M,D]=k.S(t);M<=D;M++)$.push(I(M));return r.jsx(u,{ref:w,style:{contain:"size style",overflowAnchor:"none",flex:"none",position:"relative",width:_?E:"100%",height:_?"100%":E,pointerEvents:T?"none":void 0},children:$})});function t_(n){const e=B.c(15),{redoTurnCount:t,onRedoAll:s}=n;if(t<=0)return null;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(Zc,{className:"size-4","data-icon":"inline-start"}),e[0]=o):o=e[0];let i;e[1]!==t?(i=r.jsx("span",{className:"font-mono",children:t}),e[1]=t,e[2]=i):i=e[2];const a=t!==1?"s":"";let l;e[3]!==a?(l=r.jsxs("span",{children:["turn",a," archived"]}),e[3]=a,e[4]=l):l=e[4];let c;e[5]!==i||e[6]!==l?(c=r.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-muted-foreground",children:[o,i,l]}),e[5]=i,e[6]=l,e[7]=c):c=e[7];let d;e[8]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(St,{orientation:"vertical",className:"h-4"}),e[8]=d):d=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Ly,{"data-icon":"inline-start"}),e[9]=u):u=e[9];let f;e[10]!==s?(f=r.jsxs(ee,{variant:"default",size:"sm",onClick:s,children:[u,"Redo all"]}),e[10]=s,e[11]=f):f=e[11];let m;return e[12]!==c||e[13]!==f?(m=r.jsxs("div",{className:"sticky bottom-0 flex items-center justify-center gap-3 border-t border-border bg-background/95 px-4 py-2",role:"status",children:[c,d,f]}),e[12]=c,e[13]=f,e[14]=m):m=e[14],m}const Wm=new Map;function n_(n){let e=Wm.get(n);if(!e){const t=new Map;e={observer:new IntersectionObserver(o=>{var i;for(const a of o)(i=t.get(a.target))==null||i(a.isIntersecting)},{rootMargin:n}),callbacks:t},Wm.set(n,e)}return e}function i0(n){const e=B.c(5),t="100%",s=y.useRef(null),[o,i]=y.useState(!0);let a,l;e[0]!==t?(a=()=>{const d=s.current;if(!d)return;const{observer:u,callbacks:f}=n_(t);return f.set(d,i),u.observe(d),()=>{u.unobserve(d),f.delete(d)}},l=[t],e[0]=t,e[1]=a,e[2]=l):(a=e[1],l=e[2]),y.useEffect(a,l);let c;return e[3]!==o?(c={ref:s,isNear:o},e[3]=o,e[4]=c):c=e[4],c}function Ki(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 Hm(n){const e=Ki(n.lastActivityAt);return e!==Number.NEGATIVE_INFINITY?e:Ki(n.lastModified)}function Km(n,e){return n===e?0:e-n}function qm(n){return[n.dirName??"",n.fileName??"",n.sessionId??""].join("/")}function s_(n,e){const t=Km(Hm(n),Hm(e));if(t!==0)return t;const s=Km(Ki(n.lastModified),Ki(e.lastModified));return s!==0?s:qm(n).localeCompare(qm(e))}function Vd(n){return[...n].sort(s_)}function a0(n,e){const t=!!(n.teamName&&n.agentName);return e||kn(n.aiTitle||(t?n.agentName:"")||n.lastUserMessage||n.firstUserMessage||n.slug||n.sessionId,50)}const o_="Unknown project";function Gd(n){const e=wa(n);return ya(e?e.parentPath:n,2)||o_}function r_(n){return Gd(n.cwd||_n(n.dirName))}function i_(n){const e=Vd(n),t=new Map;for(const s of e){const o=r_(s),i=t.get(o);i?i.push(s):t.set(o,[s])}return t}function l0(n,e){return n.isActive?!0:e.has(n.sessionId)?n.agentStatus!=="completed":!1}function a_(n,e,t){let s=-1;return n.forEach((o,i)=>{l0(o,e)&&(s=i)}),Math.max(t,s+1)}const Yd=new Set(["thinking","tool_use","processing","compacting","awaiting_agents"]),l_=12e4;function c_(n,e=Date.now()){const t=Date.parse(n.lastActivityAt||n.lastModified);return Number.isFinite(t)&&e-t<l_}function c0(n,e,t=Date.now()){return l0(n,e)?!0:n.agentStatus==="completed"||!n.agentStatus?!1:c_(n,t)}function d_(n,e,t=Date.now()){return n.some(s=>c0(s,e,t))}const u_="cogpit:session-list-cache",f_=10080*60*1e3,m_=24,Jn={projects:"projects",activeSessions:"active-sessions",runningProcesses:"running-processes"},Nc=new Map;function p_(){return{version:1,entries:{}}}function d0(){return Kt(u_)}function u0(){const n=d0(),e=Nc.get(n);if(e)return e;let t=p_();try{const s=localStorage.getItem(n);if(s){const o=JSON.parse(s);o.version===1&&o.entries&&typeof o.entries=="object"&&(t=o)}}catch{}return Nc.set(n,t),t}function f0(n){const e=u0().entries[n];if(!(!e||Date.now()-e.savedAt>f_))return e.value}function m0(n,e){const t=d0(),o={...u0().entries,[n]:{savedAt:Date.now(),value:e}},i=Object.entries(o).sort(([,l],[,c])=>c.savedAt-l.savedAt),a={version:1,entries:Object.fromEntries(i.slice(0,m_))};Nc.set(t,a);try{localStorage.setItem(t,JSON.stringify(a))}catch{}}function qi(n){const e=f0(n);return Array.isArray(e)?e:void 0}function tr(n,e){m0(n,e)}function p0(n){return`sessions:${n}`}function h_(n){const e=f0(p0(n));if(!e||typeof e!="object")return;const t=e;if(!(!Array.isArray(t.sessions)||typeof t.total!="number"))return t}function g_(n,e){m0(p0(n),e)}const x_=2e4;function b_(n){const e=new Map;for(const t of n){if(!t.sessionId)continue;const s=e.get(t.sessionId);(!s||t.memMB>s.memMB)&&e.set(t.sessionId,t)}return e}const h0=y.createContext(null);function v_({children:n}){const[e]=y.useState(Nn),[t,s]=y.useState(()=>qi(Jn.activeSessions)??[]),[o,i]=y.useState(()=>qi(Jn.runningProcesses)??[]),[a,l]=y.useState(!1),[c,d]=y.useState(null),[u,f]=y.useState(new Set),m=y.useRef(null),p=y.useRef(null),h=y.useRef(!1);y.useEffect(()=>(h.current=!0,()=>{var k;h.current=!1,(k=p.current)==null||k.abort(),p.current=null}),[]);const g=y.useCallback(async()=>{var N;if(!h.current||Nn()!==e)return;(N=p.current)==null||N.abort();const k=new AbortController;p.current=k;const C=()=>h.current&&!k.signal.aborted&&p.current===k&&Nn()===e;l(!0);try{const[_,P]=await Promise.all([ve("/api/active-sessions",{signal:k.signal}),ve("/api/running-processes",{signal:k.signal})]);if(!C())return;if(!_.ok||!P.ok)throw new Error("Failed to fetch live data");const[A,T]=await Promise.all([_.json(),P.json()]);if(!C())return;const E=Array.isArray(A)?A:[],R=Array.isArray(T)?T:[];s(E),i(R),tr(Jn.activeSessions,E),tr(Jn.runningProcesses,R),d(null)}catch(_){if(!C())return;d(_ instanceof Error?_.message:"Failed to load data")}finally{C()&&l(!1),p.current===k&&(p.current=null)}},[e]),x=y.useCallback(()=>{g()},[g]);y.useEffect(()=>{x()},[x]);const b=y.useMemo(()=>b_(o),[o]),w=y.useMemo(()=>d_(t,b),[t,b]);y.useEffect(()=>(window.addEventListener("focus",x),()=>window.removeEventListener("focus",x)),[x]),y.useEffect(()=>{if(!w)return;const k=setInterval(()=>{document.visibilityState==="visible"&&x()},x_);return()=>clearInterval(k)},[w,x]),y.useEffect(()=>{if(t.length===0)return;const k=m.current,C=new Map;for(const N of t)N.agentStatus&&b.has(N.sessionId)&&C.set(N.sessionId,N.agentStatus);k!==null&&f(N=>{let _=null;for(const[P,A]of C)A==="completed"&&k.get(P)!=="completed"&&(_??(_=new Set(N)),_.add(P));for(const P of N)C.get(P)!=="completed"&&(_??(_=new Set(N)),_.delete(P));return _??N}),m.current=C},[t,b]);const v=y.useCallback(k=>{f(C=>{if(!C.has(k))return C;const N=new Set(C);return N.delete(k),N})},[]),S=y.useCallback(k=>{s(C=>{const N=C.filter(_=>_.sessionId!==k);return Nn()===e&&tr(Jn.activeSessions,N),N})},[e]),j=y.useMemo(()=>({sessions:t,processes:o,procBySession:b,newlyCompleted:u,loading:a,error:c,refresh:x,removeSession:S,acknowledgeCompleted:v}),[t,o,b,u,a,c,x,S,v]);return r.jsx(h0.Provider,{value:j,children:n})}function g0(){const n=Xd();if(!n)throw new Error("useSessionInventory must be used within a SessionInventoryProvider");return n}function Xd(){return y.useContext(h0)}const Vm=[20,50,80,110,140,170,200,230,260,290,320,350];function y_(n){let e=2166136261;for(let t=0;t<n.length;t++)e^=n.charCodeAt(t),e=Math.imul(e,16777619);return Vm[(e>>>0)%Vm.length]}function Nl(n){const e=[];let t=!1;for(const s of n.split(`
85
- `)){if(/^\s*(```|~~~)/.test(s)){t=!t;continue}let o=s;if(!t){if(o=o.replace(/^\s{0,3}#{1,6}\s+/,"").replace(/^\s*>\s?/,"").replace(/^\s*(?:[-*+]|\d+[.)])\s+/,""),/^\s*(?:[-*_]\s*){3,}$/.test(o))continue;o=o.replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]*)\]\[[^\]]*\]/g,"$1").replace(/(\*\*|__|~~)(.*?)\1/g,"$2").replace(new RegExp("(?<![\\w*])[*_](?=\\S)([^*_]+?)(?<=\\S)[*_](?![\\w*])","g"),"$1").replace(/`+/g,"")}const i=o.trim();i&&e.push(i)}return e.join(" ")}function w_(n){const e=n.split(`
86
- `);let t=0;for(;t<e.length&&e[t].trim()==="";)t++;const s=Nl(e[t]??"");return s?{subject:s,preview:Nl(e.slice(t+1).join(`
87
- `))}:{subject:Nl(n),preview:""}}function kc(n){if(!n)return null;const e=new Date(n).getTime();return Number.isNaN(e)?null:e}function j_(n,e){return n===null||e===null||e<n?null:e-n}function S_(n){const e=kc(n);return e===null?null:new Date(e).toLocaleTimeString()}function N_(n){var s;const e=(s=Xd())==null?void 0:s.sessions;let t;e:{if(!n||!e){t=null;break e}const o=e.filter(a=>a.agentName===n);if(o.length!==1){t=null;break e}const i=o[0].agentStatus;if(!i){t=null;break e}t=Yd.has(i)?"working":"idle"}return t}const k_=y.memo(function(e){const t=B.c(48),{sender:s,body:o,timestamp:i,reply:a,isLive:l}=e,[c,d]=y.useState(!1);let u;t[0]!==o?(u=ak(o),t[0]=o,t[1]=u):u=t[1];const f=u;let m;t[2]!==f?(m=w_(f),t[2]=f,t[3]=m):m=t[3];const{subject:p,preview:h}=m;let g;t[4]!==i?(g=S_(i),t[4]=i,t[5]=g):g=t[5];const x=g,b=N_(s);let w;t[6]!==f?(w=fk(f),t[6]=f,t[7]=w):w=t[7];const v=w,S=v&&!a,j=kc(i),k=a?j_(j,kc(a.timestamp)):null,C=!a&&l===!0,N=!!a||v;Lg(C&&N);const _=!0;let P;t[8]!==s?(P=y_(s),t[8]=s,t[9]=P):P=t[9];const A=String(P);let T;t[10]!==A?(T={"--agent-hue":A},t[10]=A,t[11]=T):T=t[11];const E=T,R="my-2 rounded-lg border border-l-[3px] border-border bg-card px-3 py-2 [border-left-color:oklch(0.52_0.16_var(--agent-hue))] dark:[border-left-color:oklch(0.74_0.14_var(--agent-hue))]";let $;t[12]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx(zy,{className:"size-3.5 shrink-0 text-[oklch(0.52_0.16_var(--agent-hue))] dark:text-[oklch(0.74_0.14_var(--agent-hue))]","data-icon":"inline-start"}),t[12]=$):$=t[12];let I;t[13]!==s?(I=r.jsx("span",{className:"truncate font-mono text-xs font-medium text-[oklch(0.52_0.16_var(--agent-hue))] dark:text-[oklch(0.74_0.14_var(--agent-hue))]",children:s}),t[13]=s,t[14]=I):I=t[14];let M;t[15]!==b||t[16]!==s?(M=b&&r.jsx("span",{"data-testid":"agent-liveness","data-live":b,title:b==="working"?`${s} is working now`:`${s} is idle`,className:`inline-flex size-1.5 shrink-0 rounded-full ${b==="working"?"animate-pulse bg-warning":"bg-success"}`}),t[15]=b,t[16]=s,t[17]=M):M=t[17];let D;t[18]!==I||t[19]!==M?(D=r.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[$,I,M]}),t[18]=I,t[19]=M,t[20]=D):D=t[20];let O;t[21]!==S?(O=S&&r.jsx(_e,{variant:"outline",className:"h-4 border-warning/30 bg-warning/10 px-1.5 text-[10px] tracking-wide text-warning uppercase",children:"Needs you"}),t[21]=S,t[22]=O):O=t[22];let L;t[23]!==x?(L=x&&r.jsx("span",{className:"text-xs text-muted-foreground",children:x}),t[23]=x,t[24]=L):L=t[24];let F;t[25]!==O||t[26]!==L?(F=r.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[O,L]}),t[25]=O,t[26]=L,t[27]=F):F=t[27];let z;t[28]!==D||t[29]!==F?(z=r.jsxs("div",{className:"flex items-center gap-2",children:[D,F]}),t[28]=D,t[29]=F,t[30]=z):z=t[30];let W;t[31]!==f||t[32]!==c||t[33]!==h||t[34]!==p?(W=c?r.jsx("div",{"data-testid":"agent-message-body",className:"mt-1.5 max-w-none overflow-hidden break-words text-sm leading-relaxed",children:r.jsx(Un,{components:qn,remarkPlugins:Qs,children:f})}):r.jsxs(r.Fragment,{children:[r.jsx("p",{"data-testid":"agent-message-subject",className:"mt-1 line-clamp-2 break-words text-sm font-medium text-foreground",children:p}),h&&r.jsx("p",{"data-testid":"agent-message-preview",className:"mt-0.5 line-clamp-2 break-words text-xs leading-relaxed text-muted-foreground",children:h})]}),t[31]=f,t[32]=c,t[33]=h,t[34]=p,t[35]=W):W=t[35];const U="mt-1.5 flex items-center justify-end gap-2",H=N&&r.jsx("p",{"data-testid":"agent-message-state",className:`min-w-0 flex-1 truncate text-xs ${C?"text-warning":"text-muted-foreground"}`,children:a?r.jsxs(r.Fragment,{children:[k===null?"You replied":`You replied ${Fn(k)} later`,a.summary&&` · "${a.summary}"`]}):C?j===null?"Awaiting your reply":`Awaiting your reply · ${Fn(Math.max(0,Date.now()-j))}`:"Never answered"});let K;t[36]===Symbol.for("react.memo_cache_sentinel")?(K=()=>d(C_),t[36]=K):K=t[36];let V;t[37]!==f||t[38]!==c?(V=r.jsx(ee,{type:"button",variant:"ghost",size:"xs",onClick:K,className:"-mr-2 text-muted-foreground",children:c?r.jsxs(r.Fragment,{children:[r.jsx(tt,{"data-icon":"inline-start"})," Collapse"]}):r.jsxs(r.Fragment,{children:[r.jsx(Je,{"data-icon":"inline-start"})," Expand ·"," ",f.length.toLocaleString("en-US")," ",f.length===1?"char":"chars"]})}),t[37]=f,t[38]=c,t[39]=V):V=t[39];let Y;t[40]!==H||t[41]!==V?(Y=r.jsxs("div",{className:U,children:[H,V]}),t[40]=H,t[41]=V,t[42]=Y):Y=t[42];let G;return t[43]!==z||t[44]!==W||t[45]!==Y||t[46]!==E?(G=r.jsxs("div",{"data-agent-rail":_,style:E,className:R,children:[z,W,Y]}),t[43]=z,t[44]=W,t[45]=Y,t[46]=E,t[47]=G):G=t[47],G});function C_(n){return!n}const __=1500;function Hs(){const n=B.c(5),[e,t]=y.useState(!1),s=y.useRef(null);let o,i;n[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>()=>{s.current&&clearTimeout(s.current)},i=[],n[0]=o,n[1]=i):(o=n[0],i=n[1]),y.useEffect(o,i);let a;n[2]===Symbol.for("react.memo_cache_sentinel")?(a=async d=>{await Ar(d)&&(t(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>t(!1),__))},n[2]=a):a=n[2];const l=a;let c;return n[3]!==e?(c=[e,l],n[3]=e,n[4]=c):c=n[4],c}const T_=y.memo(function(e){const t=B.c(20),{text:s,model:o,effort:i,timestamp:a,compact:l}=e,c=l===void 0?!1:l;let d;t[0]!==s?(d=zx(s),t[0]=s,t[1]=d):d=t[1];const u=d,[f,m]=Hs();if(!s)return null;let p;t[2]!==c||t[3]!==f||t[4]!==m||t[5]!==i||t[6]!==o||t[7]!==s||t[8]!==a?(p=!c&&r.jsxs("div",{className:"mb-1 flex min-h-6 items-center justify-end gap-1.5",children:[o&&r.jsx("span",{className:"text-xs text-muted-foreground",children:Js(o)}),i&&r.jsx("span",{className:"text-xs text-muted-foreground",title:`Reasoning effort: ${i}`,children:i}),(o||i)&&a&&r.jsx("span",{className:"text-xs text-muted-foreground",children:"·"}),a&&r.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(a).toLocaleTimeString()}),r.jsx(ee,{variant:"ghost",size:"icon-sm",className:"opacity-60 transition-opacity hover:opacity-100 focus-visible:opacity-100 sm:opacity-0 sm:group-hover:opacity-100",onClick:()=>m(s),"aria-label":f?"Response copied":"Copy response",title:f?"Copied":"Copy response",children:f?r.jsx(mt,{"data-icon":"inline-start"}):r.jsx(An,{"data-icon":"inline-start"})})]}),t[2]=c,t[3]=f,t[4]=m,t[5]=i,t[6]=o,t[7]=s,t[8]=a,t[9]=p):p=t[9];const h=c&&"leading-relaxed";let g;t[10]!==h?(g=q("overflow-hidden break-words text-sm",h),t[10]=h,t[11]=g):g=t[11];let x;t[12]!==u?(x=r.jsx(Un,{components:qn,remarkPlugins:Qs,children:u}),t[12]=u,t[13]=x):x=t[13];let b;t[14]!==g||t[15]!==x?(b=r.jsx("div",{className:g,children:x}),t[14]=g,t[15]=x,t[16]=b):b=t[16];let w;return t[17]!==p||t[18]!==b?(w=r.jsxs("div",{className:"group",children:[p,b]}),t[17]=p,t[18]=b,t[19]=w):w=t[19],w}),ho=[];function E_(n){return n.map(e=>({messageId:e.messageId,parentToolUseId:e.parentToolUseId,stopped:e.stopped,...e.stopped?{stoppedAt:Date.now()}:{},blocks:e.blocks.map(t=>({...t}))}))}function P_(n,e){if(e.length===0)return n;const t=n.slice(),s=new Map,o=i=>{let a=s.get(i.messageId);if(a)return a;const l=t.findIndex(c=>c.messageId===i.messageId);return l>=0?(a={...t[l],blocks:t[l].blocks.map(c=>({...c}))},t[l]=a):(a={messageId:i.messageId,parentToolUseId:i.parentToolUseId,stopped:!1,blocks:[]},t.push(a)),s.set(i.messageId,a),a};for(const i of e){const a=o(i);if(i.event==="message_stop"){a.stopped=!0,a.stoppedAt=Date.now();continue}let l=a.blocks.find(c=>c.index===i.blockIndex);l||(l={index:i.blockIndex,blockType:i.blockType,...i.toolName?{toolName:i.toolName}:{},text:""},a.blocks.push(l)),i.delta&&(l.text+=i.delta)}return t}const Gm=/"id"\s*:\s*"(msg_[A-Za-z0-9]+)"/g;function A_(n,e){if(n.length===0||e.length===0)return n;const t=new Set;for(const o of e){Gm.lastIndex=0;let i;for(;(i=Gm.exec(o))!==null;)t.add(i[1])}if(t.size===0)return n;const s=n.filter(o=>o.parentToolUseId!==null||!t.has(o.messageId));return s.length===n.length?n:s}function R_(n,e=1e4,t=Date.now()){if(n.length===0)return n;const s=n.filter(o=>o.parentToolUseId!==null||!(o.stopped&&o.stoppedAt!==void 0&&t-o.stoppedAt>e));return s.length===n.length?n:s}function I_(n){return n.filter(e=>e.parentToolUseId===null)}function $_(n,e){return n.filter(t=>t.parentToolUseId===e)}const x0={},b0=y.createContext(ho),v0=y.createContext(x0);function kl(n){const e=B.c(6),{value:t,agentProgress:s,children:o}=n,i=s===void 0?x0:s;let a;e[0]!==i||e[1]!==o?(a=r.jsx(v0.Provider,{value:i,children:o}),e[0]=i,e[1]=o,e[2]=a):a=e[2];let l;return e[3]!==a||e[4]!==t?(l=r.jsx(b0.Provider,{value:t,children:a}),e[3]=a,e[4]=t,e[5]=l):l=e[5],l}function Jd(){return y.useContext(b0)}function M_(n){return y.useContext(v0)[n]??null}function oo(n){return function({children:t}){return r.jsx(n,{className:"mt-2 mb-1 text-xs font-semibold text-foreground first:mt-0",children:t})}}const y0={...qn,code({className:n,children:e}){return!n&&typeof e=="string"&&!e.includes(`
88
- `)?r.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[0.9em] text-foreground",children:e}):r.jsx("pre",{className:"my-1.5 overflow-x-auto rounded-md border bg-muted/30 p-2 font-mono text-xs leading-relaxed",children:r.jsx("code",{children:String(e).replace(/\n$/,"")})})},img:()=>null},O_={...y0,h1:oo("h1"),h2:oo("h2"),h3:oo("h3"),h4:oo("h4"),h5:oo("h5"),h6:oo("h6")},Qd=y.memo(function(e){const t=B.c(3),{text:s,compactHeadings:o}=e,a=(o===void 0?!1:o)?O_:y0;let l;return t[0]!==a||t[1]!==s?(l=r.jsx(Un,{components:a,remarkPlugins:Qs,children:s}),t[0]=a,t[1]=s,t[2]=l):l=t[2],l}),Ym=400,D_=24,Zd=y.memo(function(e){const t=B.c(24),{toolUseId:s}=e,o=Jd(),i=M_(s),a=y.useRef(null),[l,c]=y.useState(!0);let d,u,f;if(t[0]!==l||t[1]!==o||t[2]!==s){f=$_(o,s).flatMap(L_).filter(z_).map(F_).join(`
89
- `);const k=f.split(`
90
- `);d=l&&k.length>Ym,u=d?k.slice(-Ym).join(`
91
- `):f,t[0]=l,t[1]=o,t[2]=s,t[3]=d,t[4]=u,t[5]=f}else d=t[3],u=t[4],f=t[5];const m=u;let p;t[6]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{const k=a.current;if(!k)return;const C=k.scrollHeight-k.scrollTop-k.clientHeight<D_;c(N=>N===C?N:C)},t[6]=p):p=t[6];const h=p;let g;t[7]!==l?(g=()=>{const k=a.current;if(!k||!l)return;const C=k.scrollHeight-k.clientHeight;k.scrollTop!==C&&(k.scrollTop=C)},t[7]=l,t[8]=g):g=t[8];let x;if(t[9]!==l||t[10]!==m?(x=[m,l],t[9]=l,t[10]=m,t[11]=x):x=t[11],y.useLayoutEffect(g,x),!f&&!i)return null;const b=i?"live-subagent-summary":void 0;let w;t[12]!==i?(w=i??r.jsx("span",{className:"uppercase tracking-wide",children:"Live"}),t[12]=i,t[13]=w):w=t[13];let v;t[14]!==b||t[15]!==w?(v=r.jsx("div",{"data-testid":b,className:"mb-1 text-xs font-medium text-muted-foreground",children:w}),t[14]=b,t[15]=w,t[16]=v):v=t[16];let S;t[17]!==d||t[18]!==m||t[19]!==f?(S=f&&r.jsxs("div",{ref:a,onScroll:h,"data-testid":"live-subagent-scroll",role:"region","aria-label":"Live sub-agent output",tabIndex:0,className:"text-xs break-words max-h-64 overflow-y-auto overscroll-contain pr-1",children:[d&&r.jsx("div",{className:"text-muted-foreground/50",children:"…"}),r.jsx(Qd,{text:m,compactHeadings:!0})]}),t[17]=d,t[18]=m,t[19]=f,t[20]=S):S=t[20];let j;return t[21]!==v||t[22]!==S?(j=r.jsxs("div",{className:"mt-2 rounded-md border bg-muted/30 px-3 py-2","data-testid":"live-subagent-transcript",children:[v,S]}),t[21]=v,t[22]=S,t[23]=j):j=t[23],j});function L_(n){return n.blocks}function z_(n){return n.blockType!=="tool_use"&&n.text}function F_(n){return n.text}function Xm(n){return n.length>8?n.slice(0,8):n}function eu(n,e,t){const s=e??t;return s?`${s} - ${Xm(n)}`:Xm(n)}function B_(n){const e=new Map;for(const t of n)e.has(t.agentId)||e.set(t.agentId,eu(t.agentId,t.subagentType,t.agentName));return e}function U_(n){const e=new Map;for(const s of n)s.parentToolUseId&&!e.has(s.agentId)&&e.set(s.agentId,s.parentToolUseId);const t=new Map;for(const s of e.values())t.set(s,(t.get(s)??0)+1);for(const[s,o]of e)(t.get(o)??0)>1&&e.delete(s);return e}function W_(n){return n?typeof n=="string"?n:n.map(e=>e.type==="text"?e.text:"").filter(Boolean).join(`
92
- `):""}function w0(n,e){if(yx(n))return Bd(n).turns.filter(i=>i.assistantText.length>0||i.thinking.length>0||i.toolCalls.length>0).map(i=>({agentId:e,agentName:null,subagentType:null,type:"assistant",content:i.assistantText.join(`
93
-
94
- `),toolCalls:i.toolCalls,thinking:i.thinking.map(a=>a.thinking),text:[...i.assistantText],timestamp:i.timestamp,tokenUsage:i.tokenUsage,model:i.model,isBackground:!0}));const t=[],s=new Map;for(const o of n.split(`
95
- `)){const i=o.trim();if(!i)continue;let a;try{a=JSON.parse(i)}catch{continue}const l=a.type;if(l!=="user"&&l!=="assistant")continue;const c=a.message;if(!c)continue;const d=c.content,u=a.timestamp??"";if(l==="assistant"){const f={agentId:e,agentName:null,subagentType:null,type:"assistant",content:d,toolCalls:[],thinking:[],text:[],timestamp:u,tokenUsage:c.usage?{input_tokens:c.usage.input_tokens??0,output_tokens:c.usage.output_tokens??0,cache_creation_input_tokens:c.usage.cache_creation_input_tokens??0,cache_read_input_tokens:c.usage.cache_read_input_tokens??0}:null,model:c.model??null,isBackground:!0};if(Array.isArray(d)){for(const m of d)if(m.type==="thinking")f.thinking.push(m.thinking);else if(m.type==="text")f.text.push(m.text);else if(m.type==="tool_use"){const p={id:m.id,name:m.name,input:m.input,result:null,isError:!1,timestamp:u};f.toolCalls.push(p),s.set(m.id,p)}}t.push(f)}else if(l==="user"&&Array.isArray(d)){for(const f of d)if(f.type==="tool_result"){const m=s.get(f.tool_use_id);m&&(m.result=W_(f.content),m.isError=f.is_error??!1)}}}return t}const Cl=new Map;function H_(n,e){const t=B.c(21),{session:s,sessionSource:o,isLive:i}=it();let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=new Map,t[0]=a):a=t[0];const[l,c]=y.useState(a),[d,u]=y.useState(!1);let f;t[1]===Symbol.for("react.memo_cache_sentinel")?(f=new Set,t[1]=f):f=t[1];const m=y.useRef(f);let p;if(t[2]!==i||t[3]!==n){let _;t[5]!==i?(_=P=>P.text.length>0||P.thinking.length>0||P.toolCalls.length>0?!1:i?P.durationMs!=null:P.status==="async_launched",t[5]=i,t[6]=_):_=t[6],p=n.filter(_),t[2]=i,t[3]=n,t[4]=p}else p=t[4];const h=p,g=o==null?void 0:o.dirName,x=s==null?void 0:s.sessionId;let b;t[7]===Symbol.for("react.memo_cache_sentinel")?(b=Ca(window.location.pathname),t[7]=b):b=t[7];const w=b;let v,S;t[8]!==h||t[9]!==g||t[10]!==e||t[11]!==x?(v=()=>{if(w||!e||!g||!x||h.length===0)return;const _=[];for(const T of h){const E=Kt(`${g}/${x}/${T.agentId}`);if(!m.current.has(E)){if(Cl.has(E)){c(R=>{const $=new Map(R);return $.set(T.agentId,Cl.get(E)),$}),m.current.add(E);continue}_.push({agentId:T.agentId,cacheKey:E})}}if(_.length===0)return;let P=!1;return u(!0),async function(){const E=new Map;await Promise.all(_.map(async R=>{const{agentId:$,cacheKey:I}=R;try{const M=`/api/sessions/${encodeURIComponent(g)}/${encodeURIComponent(x)}/subagents/agent-${encodeURIComponent($)}.jsonl`,D=await ve(M);if(!D.ok)return;const O=await D.text(),L=w0(O,$);Cl.set(I,L),m.current.add(I),E.set($,L)}catch{}})),!P&&E.size>0&&c(R=>{const $=new Map(R);for(const[I,M]of E)$.set(I,M);return $}),P||u(!1)}(),()=>{P=!0}},S=[w,e,g,x,h],t[8]=h,t[9]=g,t[10]=e,t[11]=x,t[12]=v,t[13]=S):(v=t[12],S=t[13]),y.useEffect(v,S);let j;e:{if(l.size===0&&h.length===0){j=n;break e}let _;if(t[14]!==l||t[15]!==n){_=[];for(const P of n){const A=l.get(P.agentId);if(A&&A.length>0&&(P.status==="async_launched"||P.durationMs!=null)){const T={...A[0],durationMs:P.durationMs,toolUseCount:P.toolUseCount,status:P.status,prompt:P.prompt,agentName:P.agentName,subagentType:P.subagentType};_.push(T,...A.slice(1))}else _.push(P)}t[14]=l,t[15]=n,t[16]=_}else _=t[16];j=_}const k=j,C=w&&e&&h.length>0;let N;return t[17]!==k||t[18]!==d||t[19]!==C?(N={enrichedMessages:k,isLoading:d,unavailable:C},t[17]=k,t[18]=d,t[19]=C,t[20]=N):N=t[20],N}const j0=y.memo(function(e){const t=B.c(74),{messages:s,expandAll:o,label:i,countLabel:a,lazyLoad:l}=e,c=l===void 0?!1:l,[d,u]=y.useState(!1),f=o||d,{sessionSource:m,actions:p}=it(),h=m==null?void 0:m.dirName;let g;t[0]!==h?(g=So(h),t[0]=h,t[1]=g):g=t[1];const x=g.subagentTranscripts,{enrichedMessages:b,isLoading:w,unavailable:v}=H_(s,c&&f&&x);let S;e:{if(!(m!=null&&m.fileName)){S=null;break e}let X;t[2]!==m.fileName?(X=Ns(m.fileName),t[2]=m.fileName,t[3]=X):X=t[3];const Z=X;if(Z){S=Z.parentSessionId;break e}let te;if(t[4]!==m.fileName){let re;t[6]===Symbol.for("react.memo_cache_sentinel")?(re=/^([^/]+)\.jsonl$/,t[6]=re):re=t[6],te=m.fileName.match(re),t[4]=m.fileName,t[5]=te}else te=t[5];const ne=te;S=(ne==null?void 0:ne[1])??null}const j=S;let k;t[7]!==b?(k=new Set(b.map(q_)),t[7]=b,t[8]=k):k=t[8];let C;t[9]!==k?(C=[...k],t[9]=k,t[10]=C):C=t[10];const N=C;let _;t[11]!==b?(_=B_(b),t[11]=b,t[12]=_):_=t[12];const P=_;let A;if(t[13]!==b||t[14]!==s){A=new Map;for(const X of[...s,...b]){const Z=A.get(X.agentId)??{};X.durationMs!=null&&(Z.durationMs=X.durationMs),X.toolUseCount!=null&&(Z.toolUseCount=X.toolUseCount),X.status&&(Z.status=X.status),A.set(X.agentId,Z)}t[13]=b,t[14]=s,t[15]=A}else A=t[15];const T=A;let E;t[16]!==b||t[17]!==s?(E=U_([...s,...b]),t[16]=b,t[17]=s,t[18]=E):E=t[18];const R=E;let $,I;if(t[19]!==b){I=new Map,$=new Map;for(const X of b)$.set(X.agentId,X),X.text.length>0&&I.set(X.agentId,X);t[19]=b,t[20]=$,t[21]=I}else $=t[20],I=t[21];let M;if(t[22]!==N||t[23]!==$||t[24]!==I){M=new Map;for(const X of N){const Z=I.get(X)??$.get(X);Z&&M.set(X,Z)}t[22]=N,t[23]=$,t[24]=I,t[25]=M}else M=t[25];const D=M;let O;e:{let X=0,Z=0,te=!1,ne=!0;for(const ie of s)ie.durationMs!=null&&(X=X+ie.durationMs,te=!0),ie.toolUseCount!=null&&(Z=Z+ie.toolUseCount),ie.status&&ie.status!=="completed"&&(ne=!1);if(!te){O=null;break e}let re;t[26]!==ne||t[27]!==X||t[28]!==Z?(re={totalDuration:X,totalToolUses:Z,allCompleted:ne},t[26]=ne,t[27]=X,t[28]=Z,t[29]=re):re=t[29],O=re}const L=O;if(s.length===0)return null;let F;t[30]!==d?(F=()=>u(!d),t[30]=d,t[31]=F):F=t[31];let z;t[32]!==f?(z=f?r.jsx(tt,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}):r.jsx(Je,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),t[32]=f,t[33]=z):z=t[33];let W;t[34]===Symbol.for("react.memo_cache_sentinel")?(W=r.jsx(ts,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),t[34]=W):W=t[34];let U;t[35]!==i?(U=r.jsx("span",{className:"text-xs font-medium text-foreground",children:i}),t[35]=i,t[36]=U):U=t[36];let H;t[37]!==N.length||t[38]!==a?(H=N.length>1&&r.jsxs(_e,{variant:"secondary",children:[N.length," ",a]}),t[37]=N.length,t[38]=a,t[39]=H):H=t[39];let K;t[40]!==N||t[41]!==P?(K=N.map(X=>r.jsx(_e,{variant:"outline",children:P.get(X)},X)),t[40]=N,t[41]=P,t[42]=K):K=t[42];let V;t[43]!==N.length||t[44]!==L?(V=L?r.jsxs("span",{className:"inline-flex items-center gap-2 text-xs text-muted-foreground",children:[L.allCompleted?r.jsx(Bn,{className:"size-3 text-success","data-icon":"inline-start"}):r.jsx(Ys,{className:"size-3 text-destructive","data-icon":"inline-start"}),r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(Fs,{className:"size-3","data-icon":"inline-start"}),Fn(L.totalDuration)]}),L.totalToolUses>0&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(la,{className:"size-3","data-icon":"inline-start"}),L.totalToolUses]})]}):r.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",N.length," agent",N.length!==1?"s":"",")"]}),t[43]=N.length,t[44]=L,t[45]=V):V=t[45];let Y;t[46]!==F||t[47]!==z||t[48]!==U||t[49]!==H||t[50]!==K||t[51]!==V?(Y=r.jsxs(ee,{type:"button",variant:"ghost",onClick:F,className:"h-auto w-full min-w-0 flex-wrap justify-start gap-2 px-0 py-1 text-left whitespace-normal",children:[z,W,U,H,K,V]}),t[46]=F,t[47]=z,t[48]=U,t[49]=H,t[50]=K,t[51]=V,t[52]=Y):Y=t[52];let G;t[53]!==N||t[54]!==f||t[55]!==R?(G=!f&&N.map(X=>{const Z=R.get(X);return Z?r.jsx(Zd,{toolUseId:Z},X):null}),t[53]=N,t[54]=f,t[55]=R,t[56]=G):G=t[56];let J;t[57]!==p||t[58]!==N||t[59]!==P||t[60]!==D||t[61]!==x||t[62]!==w||t[63]!==f||t[64]!==j||t[65]!==R||t[66]!==m||t[67]!==T||t[68]!==v?(J=f&&r.jsxs("div",{className:"motion-enter mt-2 flex flex-col gap-2",children:[v?r.jsx("div",{className:"py-1 text-xs italic text-muted-foreground",children:"Sub-agent transcripts aren't available in a shared session."}):w&&r.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground py-1",children:[r.jsx(ot,{className:"size-3 animate-spin"}),"Loading agent output..."]}),N.map(X=>{const Z=D.get(X),te=T.get(X),ne=x&&!!m&&!!j&&!v;return r.jsx(K_,{agentLabel:P.get(X)??X,message:Z,stats:te,parentToolUseId:R.get(X),canNavigate:ne,onOpen:()=>{ne&&p.handleLoadSession(m.dirName,`${j}/subagents/agent-${X}.jsonl`)}},X)})]}),t[57]=p,t[58]=N,t[59]=P,t[60]=D,t[61]=x,t[62]=w,t[63]=f,t[64]=j,t[65]=R,t[66]=m,t[67]=T,t[68]=v,t[69]=J):J=t[69];let Q;return t[70]!==Y||t[71]!==G||t[72]!==J?(Q=r.jsxs("div",{children:[Y,G,J]}),t[70]=Y,t[71]=G,t[72]=J,t[73]=Q):Q=t[73],Q});function K_(n){const e=B.c(22),{agentLabel:t,message:s,stats:o,parentToolUseId:i,canNavigate:a,onOpen:l}=n,c=s==null?void 0:s.text;let d;e[0]!==c?(d=zx((c??[]).join(`
96
-
97
- `)),e[0]=c,e[1]=d):d=e[1];const u=d,f=((c==null?void 0:c.length)??0)>0,m=(o==null?void 0:o.status)!=null&&o.status!=="completed"&&o.status!=="async_launched",p=(o==null?void 0:o.status)==="completed";let h;e[2]!==t?(h=r.jsx(_e,{variant:"outline",children:t}),e[2]=t,e[3]=h):h=e[3];let g;e[4]!==p||e[5]!==o?(g=o&&r.jsxs("span",{className:"inline-flex items-center gap-2 text-xs text-muted-foreground",children:[p&&r.jsx(Bn,{className:"size-3 text-success"}),o.durationMs!=null&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(Fs,{className:"size-3"}),Fn(o.durationMs)]}),o.toolUseCount!=null&&o.toolUseCount>0&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(la,{className:"size-3"}),o.toolUseCount]})]}),e[4]=p,e[5]=o,e[6]=g):g=e[6];let x;e[7]!==a||e[8]!==l?(x=a&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:l,className:"ml-auto",title:"Open this sub-agent's full chat session",children:[r.jsx(Jh,{"data-icon":"inline-start"}),"Open chat"]}),e[7]=a,e[8]=l,e[9]=x):x=e[9];let b;e[10]!==h||e[11]!==g||e[12]!==x?(b=r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[h,g,x]}),e[10]=h,e[11]=g,e[12]=x,e[13]=b):b=e[13];let w;e[14]!==f||e[15]!==m||e[16]!==u||e[17]!==i?(w=f?r.jsx("div",{className:"text-xs break-words overflow-hidden",children:r.jsx(Un,{components:qn,remarkPlugins:Qs,children:u})}):r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("div",{className:"inline-flex items-center gap-1.5 text-xs italic text-muted-foreground",children:m?r.jsxs(r.Fragment,{children:[r.jsx(ot,{className:"size-3 animate-spin"}),"Working — no return yet"]}):r.jsx(r.Fragment,{children:"No return message from this agent"})}),i&&r.jsx(Zd,{toolUseId:i})]}),e[14]=f,e[15]=m,e[16]=u,e[17]=i,e[18]=w):w=e[18];let v;return e[19]!==b||e[20]!==w?(v=r.jsx("div",{className:"border-l pl-3",children:r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[b,w]})}),e[19]=b,e[20]=w,e[21]=v):v=e[21],v}function q_(n){return n.agentId}const V_=y.memo(function(e){const t=B.c(3),{messages:s,expandAll:o}=e;let i;return t[0]!==o||t[1]!==s?(i=r.jsx(j0,{messages:s,expandAll:o,label:"Sub-agent activity",countLabel:"subagents active",lazyLoad:!0}),t[0]=o,t[1]=s,t[2]=i):i=t[2],i}),G_=y.memo(function(e){const t=B.c(3),{messages:s,expandAll:o}=e;let i;return t[0]!==o||t[1]!==s?(i=r.jsx(j0,{messages:s,expandAll:o,label:"Background agent activity",countLabel:"agents active",lazyLoad:!0}),t[0]=o,t[1]=s,t[2]=i):i=t[2],i}),Y_=new Set(["StopFailure","PermissionDenied","PostToolUseFailure"]),X_=y.memo(function(e){const t=B.c(30),{events:s}=e,[o,i]=y.useState(!1);if(s.length===0)return null;let a;t[0]!==s?(a=s.some(J_),t[0]=s,t[1]=a):a=t[1];const l=a,c=o?tt:Je,d=l?"border-destructive/20 bg-destructive/5":"bg-muted/30";let u;t[2]!==d?(u=q("my-1 rounded-md border px-2 py-1 text-xs",d),t[2]=d,t[3]=u):u=t[3];let f;t[4]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(ee,{type:"button",variant:"ghost",size:"sm",className:"h-auto w-full justify-start px-0 py-0 text-left font-normal text-muted-foreground"}),t[4]=f):f=t[4];let m;t[5]!==c?(m=r.jsx(c,{className:"size-3 shrink-0","data-icon":"inline-start"}),t[5]=c,t[6]=m):m=t[6];let p;t[7]!==l?(p=l?r.jsx(tn,{className:"size-3 text-destructive","data-icon":"inline-start"}):r.jsx(Fy,{className:"size-3","data-icon":"inline-start"}),t[7]=l,t[8]=p):p=t[8];const h=s.length===1?"":"s";let g;t[9]!==s.length||t[10]!==h?(g=r.jsxs("span",{className:"font-mono",children:[s.length," hook event",h]}),t[9]=s.length,t[10]=h,t[11]=g):g=t[11];let x;t[12]!==s?(x=s.map(Q_).join(", "),t[12]=s,t[13]=x):x=t[13];let b;t[14]!==x?(b=r.jsx("span",{className:"truncate text-muted-foreground/60",children:x}),t[14]=x,t[15]=b):b=t[15];let w;t[16]!==b||t[17]!==m||t[18]!==p||t[19]!==g?(w=r.jsxs(Mt,{render:f,children:[m,p,g,b]}),t[16]=b,t[17]=m,t[18]=p,t[19]=g,t[20]=w):w=t[20];let v;t[21]!==s?(v=s.map(Z_),t[21]=s,t[22]=v):v=t[22];let S;t[23]!==v?(S=r.jsx(dt,{children:r.jsx("ul",{className:"ml-5 mt-1 flex flex-col gap-0.5 font-mono",children:v})}),t[23]=v,t[24]=S):S=t[24];let j;return t[25]!==o||t[26]!==w||t[27]!==S||t[28]!==u?(j=r.jsxs(ct,{open:o,onOpenChange:i,className:u,children:[w,S]}),t[25]=o,t[26]=w,t[27]=S,t[28]=u,t[29]=j):j=t[29],j});function J_(n){return Y_.has(n.eventName)||n.exitCode!==void 0&&n.exitCode!==0}function Q_(n){return n.eventName}function Z_(n,e){return r.jsxs("li",{className:"text-muted-foreground/80",children:[r.jsx("span",{className:"text-foreground",children:n.eventName}),n.toolName&&r.jsxs("span",{children:[" · ",n.toolName]}),n.source&&r.jsxs("span",{className:"text-muted-foreground/50",children:[" (",n.source,")"]}),n.decision&&r.jsxs("span",{className:"text-warning",children:[" → ",n.decision]}),n.durationMs!==void 0&&r.jsxs("span",{className:"text-muted-foreground/50",children:[" ",n.durationMs,"ms"]}),n.exitCode!==void 0&&n.exitCode!==0&&r.jsxs("span",{className:"text-destructive",children:[" exit ",n.exitCode]}),n.stderr&&r.jsx("pre",{className:"ml-2 mt-0.5 whitespace-pre-wrap text-destructive",children:n.stderr.slice(0,500)}),n.updatedToolOutput&&r.jsx("span",{className:"text-info",children:" · output replaced by hook"}),n.sessionTitle&&r.jsxs("span",{className:"text-foreground",children:[" · title: ",n.sessionTitle]}),n.worktreePath&&r.jsxs("span",{className:"text-success",children:[" · path: ",n.worktreePath]})]},e)}const Jm=768;function Da(){const n=B.c(2),[e,t]=y.useState(typeof window<"u"?window.innerWidth<Jm:!1);let s,o;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{const i=window.matchMedia(`(max-width: ${Jm-1}px)`),a=l=>t(l.matches);return i.addEventListener("change",a),t(i.matches),()=>i.removeEventListener("change",a)},o=[],n[0]=s,n[1]=o):(s=n[0],o=n[1]),y.useEffect(s,o),e}const eT=24,Bo=[];function tT(n,e){for(let s=0;s<Bo.length;s++){const o=Bo[s];if(o.oldStr===n&&o.newStr===e)return o.result}const t=sT(n,e);return Bo.length>=eT&&Bo.shift(),Bo.push({oldStr:n,newStr:e,result:t}),t}const nT=25e4;function sT(n,e){const t=n.split(`
98
- `),s=e.split(`
99
- `),o=t.length,i=s.length;let a=0;for(;a<o&&a<i&&t[a]===s[a];)a++;let l=0;for(;l<o-a&&l<i-a&&t[o-1-l]===s[i-1-l];)l++;const c=o-a-l,d=i-a-l,u=[];for(let f=0;f<a;f++)u.push({type:"unchanged",text:t[f],oldIdx:f,newIdx:f});if(!(c===0&&d===0))if(c===0)for(let f=0;f<d;f++)u.push({type:"added",text:s[a+f],newIdx:a+f});else if(d===0)for(let f=0;f<c;f++)u.push({type:"removed",text:t[a+f],oldIdx:a+f});else if(c*d>nT){for(let f=0;f<c;f++)u.push({type:"removed",text:t[a+f],oldIdx:a+f});for(let f=0;f<d;f++)u.push({type:"added",text:s[a+f],newIdx:a+f})}else{const f=d+1,m=new Int32Array((c+1)*f);for(let x=1;x<=c;x++){const b=t[a+x-1],w=x*f,v=w-f;for(let S=1;S<=d;S++)if(b===s[a+S-1])m[w+S]=m[v+S-1]+1;else{const j=m[v+S],k=m[w+S-1];m[w+S]=j>k?j:k}}const p=[];let h=c,g=d;for(;h>0||g>0;)h>0&&g>0&&t[a+h-1]===s[a+g-1]?(p.push({type:"unchanged",text:t[a+h-1],oldIdx:a+h-1,newIdx:a+g-1}),h--,g--):g>0&&(h===0||m[h*f+g-1]>=m[(h-1)*f+g])?(p.push({type:"added",text:s[a+g-1],newIdx:a+g-1}),g--):(p.push({type:"removed",text:t[a+h-1],oldIdx:a+h-1}),h--);p.reverse(),u.push(...p)}for(let f=0;f<l;f++){const m=o-l+f,p=i-l+f;u.push({type:"unchanged",text:t[m],oldIdx:m,newIdx:p})}return u}function oT(n,e,t,s){const o=B.c(9),[i,a]=y.useState(null),[l,c]=y.useState(null);let d,u;o[0]!==t||o[1]!==s||o[2]!==e||o[3]!==n?(d=()=>{const m=A1(t);if(!m){a(null),c(null);return}const p=s?"github-dark":"github-light";let h=!1;const g=requestAnimationFrame(()=>{h||E1().then(async x=>{if(h||(await P1(x,m),h))return;const b=x.codeToTokens(n,{lang:m,theme:p});if(h)return;a(b.tokens);const w=x.codeToTokens(e,{lang:m,theme:p});h||c(w.tokens)}).catch(x=>{console.warn("[EditDiffView] highlight failed:",x),h||(a(null),c(null))})});return()=>{h=!0,cancelAnimationFrame(g)}},u=[n,e,t,s],o[0]=t,o[1]=s,o[2]=e,o[3]=n,o[4]=d,o[5]=u):(d=o[4],u=o[5]),y.useEffect(d,u);let f;return o[6]!==l||o[7]!==i?(f={oldTokens:i,newTokens:l},o[6]=l,o[7]=i,o[8]=f):f=o[8],f}const rT={removed:"bg-destructive/10",added:"bg-success/10",unchanged:""},Qm={removed:"border-destructive/20 text-destructive/70",added:"border-success/20 text-success/70",unchanged:"border-border text-muted-foreground"},iT={removed:"text-destructive",added:"text-success",unchanged:"text-muted-foreground"};function aT(n,e){return n.map((t,s)=>r.jsx("span",{style:{color:t.color},className:q(e&&"opacity-50"),children:t.content},s))}function lT(n,e,t){switch(n.type){case"removed":return e==null?void 0:e[n.oldIdx??-1];case"added":return t==null?void 0:t[n.newIdx??-1];case"unchanged":return(t==null?void 0:t[n.newIdx??-1])??(e==null?void 0:e[n.oldIdx??-1])}}function cT(n){const e=B.c(3),{type:t}=n;switch(t){case"removed":{let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Xh,{className:"inline size-3","data-icon":"icon"}),e[0]=s):s=e[0],s}case"added":{let s;return e[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Ln,{className:"inline size-3","data-icon":"icon"}),e[1]=s):s=e[1],s}default:{let s;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx("span",{className:"inline-block size-3","aria-hidden":"true"}),e[2]=s):s=e[2],s}}}const _l=3;function dT(n){if(n.length===0)return[];const e=new Set;for(let i=0;i<n.length;i++)n[i].type!=="unchanged"&&e.add(i);if(e.size===0||n.length<=_l*2+3)return n.map((i,a)=>({kind:"line",line:i,originalIdx:a}));const t=new Set;for(const i of e)for(let a=Math.max(0,i-_l);a<=Math.min(n.length-1,i+_l);a++)t.add(a);const s=[];let o=0;for(;o<n.length;)if(t.has(o))s.push({kind:"line",line:n[o],originalIdx:o}),o++;else{const i=o;let a=0;for(;o<n.length&&!t.has(o);)a++,o++;s.push({kind:"separator",count:a,fromIdx:i,toIdx:o-1})}return s}function uT(n){const e=B.c(7),{count:t,onExpand:s}=n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(fa,{className:"shrink-0","data-icon":"inline-start"}),e[0]=o):o=e[0];let i;e[1]!==t?(i=r.jsxs("span",{className:"font-mono",children:[t," unchanged lines"]}),e[1]=t,e[2]=i):i=e[2];let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("span",{className:"flex-1 border-b border-border"}),e[3]=a):a=e[3];let l;return e[4]!==s||e[5]!==i?(l=r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:s,className:"h-auto w-full justify-start rounded-none px-2 py-1 text-xs text-muted-foreground",children:[o,i,a]}),e[4]=s,e[5]=i,e[6]=l):l=e[6],l}const Zm=y.memo(function(e){const t=B.c(33),{line:s,lineNum:o,oldTokens:i,newTokens:a}=e;let l,c,d,u,f,m;if(t[0]!==s||t[1]!==o||t[2]!==a||t[3]!==i){m=lT(s,i,a);const x=rT[s.type];t[10]!==x?(d=q("flex",x),t[10]=x,t[11]=d):d=t[11];const b=Qm[s.type];let w;t[12]!==b?(w=q("w-8 shrink-0 select-none border-r pr-1 text-right text-xs leading-relaxed tabular-nums",b),t[12]=b,t[13]=w):w=t[13],t[14]!==o||t[15]!==w?(u=r.jsx("span",{className:w,children:o}),t[14]=o,t[15]=w,t[16]=u):u=t[16];const v=Qm[s.type];let S;t[17]!==v?(S=q("select-none shrink-0 w-5 text-right pr-1 border-r",v),t[17]=v,t[18]=S):S=t[18];let j;t[19]!==s.type?(j=r.jsx(cT,{type:s.type}),t[19]=s.type,t[20]=j):j=t[20],t[21]!==S||t[22]!==j?(f=r.jsx("span",{className:S,children:j}),t[21]=S,t[22]=j,t[23]=f):f=t[23],l="pl-2 whitespace-pre",c=m?aT(m,s.type==="unchanged"):r.jsx("span",{className:iT[s.type],children:s.text||" "}),t[0]=s,t[1]=o,t[2]=a,t[3]=i,t[4]=l,t[5]=c,t[6]=d,t[7]=u,t[8]=f,t[9]=m}else l=t[4],c=t[5],d=t[6],u=t[7],f=t[8],m=t[9];const p=m&&m.length===0&&" ";let h;t[24]!==l||t[25]!==c||t[26]!==p?(h=r.jsxs("span",{className:l,children:[c,p]}),t[24]=l,t[25]=c,t[26]=p,t[27]=h):h=t[27];let g;return t[28]!==d||t[29]!==u||t[30]!==f||t[31]!==h?(g=r.jsxs("div",{className:d,children:[u,f,h]}),t[28]=d,t[29]=u,t[30]=f,t[31]=h,t[32]=g):g=t[32],g}),ep=120,tp=60,fT=120;function np(n){const e=B.c(34),{lines:t,oldTokens:s,newTokens:o,compact:i,startLine:a}=n,l=a===void 0?1:a;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=new Set,e[0]=c):c=e[0];const[d,u]=y.useState(c);let f;e[1]!==t?(f=dT(t),e[1]=t,e[2]=f):f=e[2];const m=f,p=m.length>ep,[h,g]=y.useState(p?tp:m.length);let x;e[3]!==m.length?(x=()=>{g(m.length>ep?tp:m.length)},e[3]=m.length,e[4]=x):x=e[4];let b;e[5]!==m?(b=[m],e[5]=m,e[6]=b):b=e[6],y.useEffect(x,b);let w,v;e[7]!==m.length||e[8]!==h?(w=()=>{if(h>=m.length)return;const T=requestAnimationFrame(()=>{g(E=>Math.min(E+fT,m.length))});return()=>cancelAnimationFrame(T)},v=[h,m.length],e[7]=m.length,e[8]=h,e[9]=w,e[10]=v):(w=e[9],v=e[10]),y.useEffect(w,v);let S;e[11]===Symbol.for("react.memo_cache_sentinel")?(S=T=>{u(E=>new Set(E).add(T))},e[11]=S):S=e[11];const j=S;let k;e[12]!==m||e[13]!==p||e[14]!==h?(k=p?m.slice(0,h):m,e[12]=m,e[13]=p,e[14]=h,e[15]=k):k=e[15];const C=k,N=i&&"max-h-64 overflow-y-auto";let _;e[16]!==N?(_=q("overflow-x-auto font-mono text-xs leading-relaxed",N),e[16]=N,e[17]=_):_=e[17];let P;if(e[18]!==d||e[19]!==C||e[20]!==t||e[21]!==o||e[22]!==s||e[23]!==l){let T;e[25]!==d||e[26]!==t||e[27]!==o||e[28]!==s||e[29]!==l?(T=(E,R)=>{if(E.kind==="separator")return d.has(E.fromIdx)?t.slice(E.fromIdx,E.toIdx+1).map((M,D)=>{const O=E.fromIdx+D;return r.jsx(Zm,{line:M,lineNum:M.type==="removed"?(M.oldIdx??0)+l:(M.newIdx??0)+l,oldTokens:s,newTokens:o},`exp-${O}`)}):r.jsx(uT,{count:E.count,onExpand:()=>j(E.fromIdx)},`sep-${R}`);const{line:$}=E,I=$.type==="removed"?($.oldIdx??0)+l:($.newIdx??0)+l;return r.jsx(Zm,{line:$,lineNum:I,oldTokens:s,newTokens:o},R)},e[25]=d,e[26]=t,e[27]=o,e[28]=s,e[29]=l,e[30]=T):T=e[30],P=C.map(T),e[18]=d,e[19]=C,e[20]=t,e[21]=o,e[22]=s,e[23]=l,e[24]=P}else P=e[24];let A;return e[31]!==_||e[32]!==P?(A=r.jsx("div",{className:_,children:P}),e[31]=_,e[32]=P,e[33]=A):A=e[33],A}function sp(n){const e=B.c(11),{lines:t}=n;let s=0,o=0;for(const m of t)m.type==="added"?s++:m.type==="removed"&&o++;let i;e[0]!==s||e[1]!==o?(i={added:s,removed:o},e[0]=s,e[1]=o,e[2]=i):i=e[2];const{added:a,removed:l}=i;let c;e[3]!==l?(c=l>0&&r.jsxs("span",{className:"text-destructive",children:["-",l]}),e[3]=l,e[4]=c):c=e[4];const d=l>0&&a>0&&" ";let u;e[5]!==a?(u=a>0&&r.jsxs("span",{className:"text-success",children:["+",a]}),e[5]=a,e[6]=u):u=e[6];let f;return e[7]!==c||e[8]!==d||e[9]!==u?(f=r.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:[c,d,u]}),e[7]=c,e[8]=d,e[9]=u,e[10]=f):f=e[10],f}function tu(n){const e=B.c(34),{oldString:t,newString:s,filePath:o,compact:i,startLine:a,hideHeader:l}=n,c=i===void 0?!0:i,d=a===void 0?1:a,u=l===void 0?!1:l,[f,m]=y.useState(!1),p=Br();let h;e[0]!==s||e[1]!==t?(h=tT(t,s),e[0]=s,e[1]=t,e[2]=h):h=e[2];const g=h,{oldTokens:x,newTokens:b}=oT(t,s,o,p);let w;e[3]!==o?(w=o.split("/").slice(-3).join("/"),e[3]=o,e[4]=w):w=e[4];const v=w,S=c&&"mt-1.5",j=u&&"border-0 rounded-none";let k;e[5]!==S||e[6]!==j?(k=q("overflow-hidden rounded border border-border bg-muted/20",S,j),e[5]=S,e[6]=j,e[7]=k):k=e[7];let C;e[8]!==u||e[9]!==c||e[10]!==g||e[11]!==v?(C=!u&&r.jsxs("div",{className:"flex items-center justify-between border-b border-border bg-muted/40 px-2 py-1",children:[r.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",children:v}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(sp,{lines:g}),c&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>m(!0),className:"text-muted-foreground",title:"Expand diff","aria-label":"Expand diff",children:r.jsx(da,{"data-icon":"icon"})})]})]}),e[8]=u,e[9]=c,e[10]=g,e[11]=v,e[12]=C):C=e[12];let N;e[13]!==c||e[14]!==g||e[15]!==b||e[16]!==x||e[17]!==d?(N=r.jsx(np,{lines:g,oldTokens:x,newTokens:b,compact:c,startLine:d}),e[13]=c,e[14]=g,e[15]=b,e[16]=x,e[17]=d,e[18]=N):N=e[18];let _;e[19]!==N||e[20]!==k||e[21]!==C?(_=r.jsxs("div",{className:k,children:[C,N]}),e[19]=N,e[20]=k,e[21]=C,e[22]=_):_=e[22];let P;e[23]!==o||e[24]!==c||e[25]!==g||e[26]!==f||e[27]!==b||e[28]!==x||e[29]!==d?(P=c&&r.jsx(ns,{open:f,onOpenChange:m,children:r.jsxs(ss,{className:"flex max-h-[85vh] flex-col border-border bg-background sm:max-w-4xl",children:[r.jsxs(Ps,{children:[r.jsxs(os,{className:"font-mono text-sm text-foreground flex items-center gap-3",children:[o,r.jsx(sp,{lines:g})]}),r.jsx(rs,{className:"sr-only",children:"Diff view for edit operation"})]}),r.jsx("div",{className:"flex-1 overflow-auto rounded border border-border bg-background",children:r.jsx(np,{lines:g,oldTokens:x,newTokens:b,startLine:d})})]})}),e[23]=o,e[24]=c,e[25]=g,e[26]=f,e[27]=b,e[28]=x,e[29]=d,e[30]=P):P=e[30];let A;return e[31]!==_||e[32]!==P?(A=r.jsxs(r.Fragment,{children:[_,P]}),e[31]=_,e[32]=P,e[33]=A):A=e[33],A}function mT(n){return n<1e3?`${n} ms`:n%6e4===0?`${n/6e4} min`:n%1e3===0?`${n/1e3} sec`:`${(n/1e3).toFixed(1)} sec`}function pT(n){return n.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase())}function hT(n){const e=B.c(4),t=Br(),[s,o]=y.useState(null);let i,a;return e[0]!==n||e[1]!==t?(i=()=>{let l=!1;return Td(n,"typescript",t).then(c=>{!l&&c&&c.length>0&&o(c)}),()=>{l=!0}},a=[n,t],e[0]=n,e[1]=t,e[2]=i,e[3]=a):(i=e[2],a=e[3]),y.useEffect(i,a),s}function op(n,e){const t=n.match(new RegExp(`\\b${e}\\s*:\\s*([\\d_]+)`));if(!t)return null;const s=Number(t[1].replace(/_/g,""));return Number.isFinite(s)?s:null}function gT(n,e){const t=n.match(new RegExp(`\\b${e}\\s*:\\s*["']([^"']+)["']`));return(t==null?void 0:t[1])??null}function xT(n){const e=[],t=new Set(Array.from(n.matchAll(/\btools\.([A-Za-z_$][\w$]*)\s*\(/g),a=>a[1]));for(const a of t)e.push({key:`tool-${a}`,label:"Tool",value:pT(a)});const s=gT(n,"workdir");s&&e.push({key:"workdir",label:"Working directory",value:s});const o=op(n,"yield_time_ms");o!==null&&e.push({key:"yield-time",label:"Yield",value:mT(o),icon:Po});const i=op(n,"max_output_tokens");return i!==null&&e.push({key:"output-limit",label:"Output limit",value:`${i.toLocaleString()} tokens`}),e}function rp(n){const e=B.c(49),{input:t}=n,s=String(t.raw??""),o=xT(s),[i,a]=Hs(),l=hT(s);let c,d,u,f,m,p,h,g,x,b;if(e[0]!==i||e[1]!==a||e[2]!==s||e[3]!==l){const N=s.split(`
100
- `);d=Jt,g="sm",x="mt-1.5";let _;e[14]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsxs(an,{className:"flex items-center gap-2",children:[r.jsx(Nr,{className:"size-4","aria-hidden":"true"}),"Tool script"]}),e[14]=_):_=e[14];let P;e[15]!==a||e[16]!==s?(P=()=>a(s),e[15]=a,e[16]=s,e[17]=P):P=e[17];const A=i?"Tool script copied":"Copy script",T=i?"Copied":"Copy script";let E;e[18]!==i?(E=i?r.jsx(mt,{"data-icon":"inline-start","aria-hidden":"true"}):r.jsx(An,{"data-icon":"inline-start","aria-hidden":"true"}),e[18]=i,e[19]=E):E=e[19],e[20]!==P||e[21]!==A||e[22]!==T||e[23]!==E?(b=r.jsxs(rn,{children:[_,r.jsx(Nd,{children:r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:P,"aria-label":A,title:T,children:E})})]}),e[20]=P,e[21]=A,e[22]=T,e[23]=E,e[24]=b):b=e[24],c=Qt,h="overflow-x-auto rounded-md bg-muted/50 p-3",p="m-0 min-w-0 whitespace-pre-wrap break-words font-mono text-xs leading-relaxed [overflow-wrap:anywhere]",u="Codex exec script";const R=!l&&"text-foreground";e[25]!==R?(f=q("block",R),e[25]=R,e[26]=f):f=e[26];let $;e[27]!==l?($=(I,M)=>{const D=l==null?void 0:l[M];return r.jsx("span",{className:"block min-h-lh",children:D?D.map(vT):I||" "},M)},e[27]=l,e[28]=$):$=e[28],m=N.map($),e[0]=i,e[1]=a,e[2]=s,e[3]=l,e[4]=c,e[5]=d,e[6]=u,e[7]=f,e[8]=m,e[9]=p,e[10]=h,e[11]=g,e[12]=x,e[13]=b}else c=e[4],d=e[5],u=e[6],f=e[7],m=e[8],p=e[9],h=e[10],g=e[11],x=e[12],b=e[13];let w;e[29]!==u||e[30]!==f||e[31]!==m?(w=r.jsx("code",{"aria-label":u,className:f,children:m}),e[29]=u,e[30]=f,e[31]=m,e[32]=w):w=e[32];let v;e[33]!==p||e[34]!==w?(v=r.jsx("pre",{className:p,children:w}),e[33]=p,e[34]=w,e[35]=v):v=e[35];let S;e[36]!==v||e[37]!==h?(S=r.jsx("div",{className:h,children:v}),e[36]=v,e[37]=h,e[38]=S):S=e[38];let j;e[39]!==c||e[40]!==S?(j=r.jsx(c,{children:S}),e[39]=c,e[40]=S,e[41]=j):j=e[41];const k=o.length>0&&r.jsx(Io,{className:"items-stretch",children:r.jsx("dl",{className:"grid w-full gap-1.5","aria-label":"Tool script options",children:o.map(bT)})});let C;return e[42]!==d||e[43]!==j||e[44]!==k||e[45]!==g||e[46]!==x||e[47]!==b?(C=r.jsxs(d,{size:g,className:x,children:[b,j,k]}),e[42]=d,e[43]=j,e[44]=k,e[45]=g,e[46]=x,e[47]=b,e[48]=C):C=e[48],C}function bT(n){const e=n.icon;return r.jsxs("div",{className:"grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-start gap-2 text-xs",children:[r.jsxs("dt",{className:"flex items-center gap-1 text-muted-foreground",children:[e&&r.jsx(e,{className:"size-3","aria-hidden":"true"}),n.label]}),r.jsx("dd",{className:"min-w-0 break-all font-mono text-card-foreground",children:n.value})]},n.key)}function vT(n,e){return r.jsx("span",{style:{color:n.color},children:n.content},e)}const yT=/(?:^|;|&&)\s*echo\s+(["']?)---([\w.-]*)\1\s*(?=;|&&|$)/g;function ip(n){return n.replace(/^\s*(?:;|&&)/,"").trim()}function wT(n,e){const t=[],s=[];let o=0;for(const l of n.matchAll(yT)){const c=ip(n.slice(o,l.index));c&&t.push({label:s.at(-1)??"",command:c,chunk:s.length}),s.push(l[2]),o=l.index+l[0].length}if(s.length===0)return null;const i=ip(n.slice(o));if(i&&t.push({label:s.at(-1)??"",command:i,chunk:s.length}),t.length<2)return null;const a=e===null?null:jT(e,s);return a!==null&&a.length<2?null:t.map(({chunk:l,...c})=>({...c,output:a!==null&&l<a.length?a[l]:null}))}function jT(n,e){const t=[[]];let s=0;for(const o of n.split(/\r\n|\r|\n/))s<e.length&&o===`---${e[s]}`?(t.push([]),s++):t[t.length-1].push(o);return t.map(o=>o.join(`
101
- `).trim())}const ST=new Set(["mv","cp","rm","mkdir","touch","tee","ln","chmod","chown","install","rsync"]),NT=/(?:^|[^\d&])>{1,2}(?!\s*&|\s*\/dev\/null)/,kT=/\|\||&&|[|;\n]/,CT=new Set(["echo","printf","true","false",":"]),_T=new Set(["find","grep","rg","ag","ack","locate","which","whereis"]),TT=new Set(["cat","head","tail","less","more","wc","stat","file","strings","jq","awk","cut","sort","uniq","tr","sed","diff","xxd","od"]),ET=new Set(["ls","tree","du"]),PT=new Set(["xargs","sudo","env","time","nohup","command"]);function AT(n){const e=n.split(/\s+/);for(;e.length>1&&(PT.has(e[0])||/^-/.test(e[0]));)e.shift();const[t,...s]=e;return ST.has(t)||t==="sed"&&s.some(o=>/^-[a-zA-Z]*i/.test(o))||/^python3?$/.test(t)&&s[0]==="-"||t==="git"&&/^(add|commit|checkout|reset|push|stash|rebase|merge|rm|mv)$/.test(s[0]??"")?!0:NT.test(n)}const S0=/<<-?\s*['"]?\w+['"]?/,RT=/'[^']*'|"(?:[^"\\]|\\.)*"/g;function IT(n){return n.split(S0)[0].replace(RT,'""').split(kT).map(e=>e.trim()).filter(Boolean)}function $T(n){const e=IT(n);if(e.some(AT))return"write";let t=!1,s=!1,o=!1;for(const i of e){const a=i.split(/\s+/)[0];if(!(!a||CT.has(a)))if(_T.has(a))t=!0;else if(TT.has(a))s=!0;else if(ET.has(a))o=!0;else return"run"}return o?"list":t?"search":s?"read":"run"}const MT=/^["']?((?:~|\.{1,2})?\/?[\w.@+-]+(?:\/[\w.@+*{}-]+)+\/?|[\w@+-]+\.(?:[cm]?[jt]sx?|json|md|mdx|py|rb|go|rs|sh|zsh|ya?ml|toml|css|scss|html|txt|sql|swift|kt|java|plist|lock))["']?[,:;]?$/;function N0(n){const e=new Set;for(const t of n.split(S0)[0].split(/\s+/)){const s=t.match(MT);if(!s)continue;const o=s[1];o.includes("*")||o.includes("{")||o.startsWith("-")||e.add(o)}return[...e]}const OT=/^(?:cat|head(?:\s+-n?\s*\d+)?|tail(?:\s+-n?\s*\d+)?|sed\s+-n\s+(\d+),(\d+)p)\s+(["']?)(\S+)\3(?:\s*\|\s*(?:head|tail)(?:\s+-n?\s*\d+)?)?$/;function DT(n){const e=n.trim().match(OT);if(!e)return null;const[,t,s,,o]=e;return N0(o).length?t?{path:o,from:Number(t),to:Number(s)}:{path:o}:null}const LT=/(?:No such file or directory|command not found|no matches found|Permission denied|is not recognized as an internal|Traceback \(most recent call last\)|^fatal: |^npm ERR!|^error: |^ERROR: |exited with code [1-9]\d*|^FAIL\b)/m;function zT(n,e){return!e||n==="read"&&e.split(`
102
- `).length>3?!1:LT.test(e)}function k0(n){const e=$T(n.command);return{kind:e,paths:N0(n.command),readFile:e==="read"?DT(n.command):null,failed:zT(e,n.output)}}const FT="max-h-96 overflow-y-auto whitespace-pre-wrap break-all rounded-md border bg-muted/30 p-2 font-mono text-xs leading-relaxed text-muted-foreground",BT="whitespace-pre-wrap break-all border-l border-border pl-3 font-mono text-[11px] leading-relaxed text-muted-foreground";function C0(n,e,t){const s=B.c(5),[o,i]=y.useState(null);let a,l;return s[0]!==n||s[1]!==t||s[2]!==e?(a=()=>{if(!e){i(null);return}let c=!1;return Td(n,e,t).then(d=>{c||i(d)}),()=>{c=!0}},l=[n,e,t],s[0]=n,s[1]=t,s[2]=e,s[3]=a,s[4]=l):(a=s[3],l=s[4]),y.useEffect(a,l),o}function _0(n){const e=B.c(12),{lines:t,tokens:s,lineNums:o,variant:i}=n,a=i==="boxed"?FT:BT;let l;if(e[0]!==o||e[1]!==t||e[2]!==s){let u;e[4]!==o||e[5]!==s?(u=(f,m)=>{const p=s==null?void 0:s[m];return r.jsxs("span",{className:"block",children:[(o==null?void 0:o[m])&&r.jsx("span",{className:"inline-block w-10 text-right mr-2 text-muted-foreground/30 select-none",children:o[m]}),p?p.map(UT):f||" "]},m)},e[4]=o,e[5]=s,e[6]=u):u=e[6],l=t.map(u),e[0]=o,e[1]=t,e[2]=s,e[3]=l}else l=e[3];let c;e[7]!==l?(c=r.jsx("code",{className:"block",children:l}),e[7]=l,e[8]=c):c=e[8];let d;return e[9]!==a||e[10]!==c?(d=r.jsx("pre",{className:a,children:c}),e[9]=a,e[10]=c,e[11]=d):d=e[11],d}function UT(n,e){return r.jsx("span",{style:{color:n.color},children:n.content},e)}const WT=/^(\s*\d+)→(.*)$/;function T0(n){return n.split(/\r\n|\r|\n/)}function HT(n){const e=[],t=[];for(const s of T0(n)){const o=s.match(WT);o?(e.push(o[1]),t.push(o[2])):(e.push(""),t.push(s))}return{lineNums:e,codeLines:t}}function E0(n){const e=B.c(14),{result:t,filePath:s,expanded:o,variant:i}=n,a=i===void 0?"boxed":i,l=Br();let c;e[0]!==s?(c=A1(s),e[0]=s,e[1]=c):c=e[1];const d=c;let u;e[2]!==o||e[3]!==t?(u=o?t:t.slice(0,500),e[2]=o,e[3]=t,e[4]=u):u=e[4];const f=u;let m;e[5]!==f?(m=HT(f),e[5]=f,e[6]=m):m=e[6];const{lineNums:p,codeLines:h}=m;let g;e[7]!==h?(g=h.join(`
103
- `),e[7]=h,e[8]=g):g=e[8];const b=C0(g,d,l);let w;return e[9]!==h||e[10]!==p||e[11]!==b||e[12]!==a?(w=r.jsx(_0,{lines:h,tokens:b,lineNums:p,variant:a}),e[9]=h,e[10]=p,e[11]=b,e[12]=a,e[13]=w):w=e[13],w}function P0(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 Cc(n){const e=B.c(12),{result:t,expanded:s,alreadyPretty:o,variant:i}=n,a=i===void 0?"boxed":i,l=Br();let c;e[0]!==o||e[1]!==t?(c=o?t:P0(t)??t,e[0]=o,e[1]=t,e[2]=c):c=e[2];const d=c;let u;e[3]!==s||e[4]!==d?(u=s?d:d.slice(0,2e3),e[3]=s,e[4]=d,e[5]=u):u=e[5];const f=u;let m;e[6]!==f?(m=T0(f),e[6]=f,e[7]=m):m=e[7];const p=m,h=C0(f,"json",l);let g;return e[8]!==p||e[9]!==h||e[10]!==a?(g=r.jsx(_0,{lines:p,tokens:h,variant:a}),e[8]=p,e[9]=h,e[10]=a,e[11]=g):g=e[11],g}function A0(n){var e;return n.label||((e=n.command.match(/^[\w.-]+/))==null?void 0:e[0])||"…"}function KT(n){const e=[],t=new Map;for(const s of n){const o=A0(s),i=k0(s).failed?"failed":"muted",a=t.get(o);if(a){a.count++,i==="failed"&&(a.tone="failed");continue}const l={name:o,tone:i,count:1};e.push(l),t.set(o,l)}return e}const R0={muted:"text-muted-foreground",failed:"border-destructive/30 text-destructive"},Vi={read:{icon:Ei,label:"read",plural:"reads"},search:{icon:gn,label:"search",plural:"searches"},list:{icon:jo,label:"list",plural:"lists"},run:{icon:_r,label:"run",plural:"runs"},write:{icon:nc,label:"write",plural:"writes"}},qT=["read","search","list","run","write"],VT=new Set(["command","cmd","description","timeout","run_in_background"]);function I0(n){return String(n.input.command??n.input.cmd??"")}function $0(n){const e=I0(n);return wT(e,n.result)??[{label:"",command:e,output:n.result}]}function GT(n,e,t){if(!n.isError||t.some(o=>o.failed))return-1;const s=e.findLastIndex(o=>o.output!==null);return s>=0?s:e.length-1}function YT(n){return typeof n!="number"||!Number.isFinite(n)?String(n):n<1e3?`${n} ms timeout`:n%6e4===0?`${n/6e4} min timeout`:n%1e3===0?`${n/1e3} sec timeout`:`${(n/1e3).toFixed(1)} sec timeout`}function XT(n){return n.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase())}function JT(n){if(typeof n=="string")return n;if(n===null)return"null";if(n===void 0)return"undefined";try{return JSON.stringify(n)}catch{return String(n)}}function QT(n){const e=[];n.timeout!==void 0&&e.push(YT(n.timeout)),typeof n.run_in_background=="boolean"&&e.push(n.run_in_background?"Background":"Foreground");for(const[t,s]of Object.entries(n))VT.has(t)||s===void 0||e.push(`${XT(t)} ${JT(s)}`);return e}function ZT(n,e){const t=$0(n),s=t.map(k0),o=GT(n,t,s);return{toolCall:n,command:I0(n),description:typeof n.input.description=="string"?n.input.description:void 0,rows:t.map((i,a)=>({section:i,analysis:s[a],failed:s[a].failed||a===o,pending:e&&n.result===null&&a===t.length-1})),options:QT(n.input)}}function M0(n){return n?n.split(`
104
- `).length:0}function e7(n){if(n.pending)return"running";if(n.section.output===null)return"not run";if(n.section.output==="")return"no output";const e=M0(n.section.output);return e===1?"1 line":`${e} lines`}function t7(n,e){return n.startsWith("/")?n:n.startsWith("~")||!e?null:`${e.replace(/\/$/,"")}/${n.replace(/^\.\//,"")}`}function O0(n){const e=B.c(12),{path:t,line:s,cwd:o,children:i}=n;let a;e[0]!==o||e[1]!==t?(a=t7(t,o),e[0]=o,e[1]=t,e[2]=a):a=e[2];const l=a;if(!l||!lt("hostFiles")){let f;return e[3]!==i?(f=r.jsx(r.Fragment,{children:i}),e[3]=i,e[4]=f):f=e[4],f}const c=`Open ${l}${s?`:${s}`:""}`;let d;e[5]!==s||e[6]!==l?(d=f=>{f.stopPropagation(),fr(l,s?{line:s}:{})},e[5]=s,e[6]=l,e[7]=d):d=e[7];let u;return e[8]!==i||e[9]!==c||e[10]!==d?(u=r.jsx("button",{type:"button",className:"rounded-sm underline decoration-dotted decoration-muted-foreground/60 underline-offset-2 hover:bg-muted hover:text-foreground hover:decoration-solid",title:c,onClick:d,children:i}),e[8]=i,e[9]=c,e[10]=d,e[11]=u):u=e[11],u}function n7(n){const e=B.c(13),{command:t,paths:s,cwd:o}=n;if(s.length===0){let d;return e[0]!==t?(d=r.jsx(r.Fragment,{children:t}),e[0]=t,e[1]=d):d=e[1],d}let i;e[2]!==s?(i=new Set(s),e[2]=s,e[3]=i):i=e[3];const a=i;let l;if(e[4]!==t||e[5]!==o||e[6]!==a){let d;e[8]!==o||e[9]!==a?(d=(u,f)=>{const m=u.replace(/^["']|["']?[,:;]?$/g,"");return a.has(m)?r.jsx(O0,{path:m,cwd:o,children:u},f):u},e[8]=o,e[9]=a,e[10]=d):d=e[10],l=t.split(/(\s+)/).map(d),e[4]=t,e[5]=o,e[6]=a,e[7]=l}else l=e[7];let c;return e[11]!==l?(c=r.jsx(r.Fragment,{children:l}),e[11]=l,e[12]=c):c=e[12],c}const s7=/^([^\s:]+):(\d+)([:-])/,Tl="mb-1.5 ml-6 max-h-96 overflow-y-auto whitespace-pre-wrap break-all border-l pl-3 font-mono text-[11px] leading-relaxed text-muted-foreground";function o7(n){const e=B.c(16),{row:t,cwd:s}=n,o=t.section.output??"";if(t.analysis.readFile&&!t.failed){let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=q(Tl,"pl-0 [&_pre]:border-0 [&_pre]:pl-3"),e[0]=c):c=e[0];let d;return e[1]!==o||e[2]!==t.analysis.readFile.path?(d=r.jsx("div",{className:c,children:r.jsx(E0,{result:o,filePath:t.analysis.readFile.path,expanded:!0,variant:"unboxed"})}),e[1]=o,e[2]=t.analysis.readFile.path,e[3]=d):d=e[3],d}if(t.analysis.kind==="search"&&!t.failed){let c;if(e[4]!==s||e[5]!==o){let u;e[7]!==s?(u=(f,m)=>{const p=f.match(s7);return r.jsx("span",{className:"block",children:p?r.jsxs(r.Fragment,{children:[r.jsxs(O0,{path:p[1],line:Number(p[2]),cwd:s,children:[p[1],":",p[2]]}),f.slice(p[1].length+p[2].length+1)]}):f||" "},m)},e[7]=s,e[8]=u):u=e[8],c=o.split(`
105
- `).map(u),e[4]=s,e[5]=o,e[6]=c}else c=e[6];let d;return e[9]!==c?(d=r.jsx("pre",{className:Tl,children:c}),e[9]=c,e[10]=d):d=e[10],d}const i=t.failed&&"border-destructive/30 text-destructive";let a;e[11]!==i?(a=q(Tl,i),e[11]=i,e[12]=a):a=e[12];let l;return e[13]!==o||e[14]!==a?(l=r.jsx("pre",{className:a,children:o}),e[13]=o,e[14]=a,e[15]=l):l=e[15],l}function r7(n){var W;const e=B.c(56),{row:t,index:s,defaultOpen:o,cwd:i}=n,[a,l]=y.useState(o);let c;e[0]!==t.section?(c=A0(t.section),e[0]=t.section,e[1]=c):c=e[1];const d=c,u=t.section.output!==null&&t.section.output!=="",f=`${d} section: ${t.section.command}`,m=Vi[t.analysis.kind].icon,p=t.failed&&"text-destructive";let h;e[2]!==p?(h=q("w-4 shrink-0 text-right font-mono text-[10px] tabular-nums text-muted-foreground/60",p),e[2]=p,e[3]=h):h=e[3];const g=s+1;let x;e[4]!==h||e[5]!==g?(x=r.jsx("span",{className:h,"aria-hidden":"true",children:g}),e[4]=h,e[5]=g,e[6]=x):x=e[6];const b=Vi[t.analysis.kind];let w;e[7]!==m||e[8]!==b.label?(w=r.jsx(m,{className:"size-3 shrink-0 text-muted-foreground","aria-label":b.label}),e[7]=m,e[8]=b.label,e[9]=w):w=e[9];const v=t.failed&&R0.failed;let S;e[10]!==v?(S=q("h-5 shrink-0 px-1.5 font-mono text-[10px] text-muted-foreground",v),e[10]=v,e[11]=S):S=e[11];let j;e[12]!==d||e[13]!==S?(j=r.jsx(_e,{variant:"outline",className:S,children:d}),e[12]=d,e[13]=S,e[14]=j):j=e[14];let k;e[15]!==i||e[16]!==t.analysis.paths||e[17]!==t.section.command?(k=r.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground/85",children:r.jsx(n7,{command:t.section.command,paths:t.analysis.paths,cwd:i})}),e[15]=i,e[16]=t.analysis.paths,e[17]=t.section.command,e[18]=k):k=e[18];let C;e[19]!==t.analysis.readFile?(C=((W=t.analysis.readFile)==null?void 0:W.from)&&r.jsxs("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground/60",children:["L",t.analysis.readFile.from,"–",t.analysis.readFile.to]}),e[19]=t.analysis.readFile,e[20]=C):C=e[20];const N=t.failed&&"font-medium text-destructive";let _;e[21]!==N?(_=q("shrink-0 text-[10px] tabular-nums text-muted-foreground",N),e[21]=N,e[22]=_):_=e[22];let P;e[23]!==t?(P=t.failed?"failed":e7(t),e[23]=t,e[24]=P):P=e[24];let A;e[25]!==_||e[26]!==P?(A=r.jsx("span",{className:_,children:P}),e[25]=_,e[26]=P,e[27]=A):A=e[27];const T=a&&"rotate-90",E=!u&&"invisible";let R;e[28]!==T||e[29]!==E?(R=q("size-3 shrink-0 text-muted-foreground/60 transition-transform",T,E),e[28]=T,e[29]=E,e[30]=R):R=e[30];let $;e[31]!==R?($=r.jsx(Je,{className:R,"aria-hidden":"true"}),e[31]=R,e[32]=$):$=e[32];let I;e[33]!==j||e[34]!==k||e[35]!==C||e[36]!==A||e[37]!==$||e[38]!==x||e[39]!==w?(I=r.jsxs(r.Fragment,{children:[x,w,j,k,C,A,$]}),e[33]=j,e[34]=k,e[35]=C,e[36]=A,e[37]=$,e[38]=x,e[39]=w,e[40]=I):I=e[40];const M=I;if(!u){let U;return e[41]!==M||e[42]!==f?(U=r.jsx("div",{className:"group/row flex w-full items-center gap-2 py-2 text-left","aria-label":f,children:M}),e[41]=M,e[42]=f,e[43]=U):U=e[43],U}let D,O;e[44]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx("div",{role:"button",tabIndex:0}),O=q("group/row flex w-full items-center gap-2 py-2 text-left","cursor-pointer rounded-sm hover:bg-muted/40"),e[44]=D,e[45]=O):(D=e[44],O=e[45]);let L;e[46]!==M||e[47]!==f?(L=r.jsx(Mt,{nativeButton:!1,render:D,className:O,"aria-label":f,children:M}),e[46]=M,e[47]=f,e[48]=L):L=e[48];let F;e[49]!==i||e[50]!==t?(F=r.jsx(dt,{children:r.jsx(o7,{row:t,cwd:i})}),e[49]=i,e[50]=t,e[51]=F):F=e[51];let z;return e[52]!==a||e[53]!==L||e[54]!==F?(z=r.jsxs(ct,{open:a,onOpenChange:l,children:[L,F]}),e[52]=a,e[53]=L,e[54]=F,e[55]=z):z=e[55],z}function i7(n){const e=new Map;for(const{analysis:t}of n)e.set(t.kind,(e.get(t.kind)??0)+1);return qT.filter(t=>e.has(t)).map(t=>{const s=e.get(t)??0;return`${s} ${s===1?Vi[t].label:Vi[t].plural}`}).join(" · ")}function a7(n){const e=B.c(10),{call:t,index:s}=n,o=s+1;let i;e[0]!==o?(i=r.jsxs("span",{className:"font-medium text-foreground/70",children:["Call ",o]}),e[0]=o,e[1]=i):i=e[1];let a;e[2]!==t.description?(a=t.description&&r.jsx("span",{children:t.description}),e[2]=t.description,e[3]=a):a=e[3];let l;e[4]!==t.options?(l=t.options.map(l7),e[4]=t.options,e[5]=l):l=e[5];let c;return e[6]!==i||e[7]!==a||e[8]!==l?(c=r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 pb-1 pt-2 text-[11px] text-muted-foreground",children:[i,a,l]}),e[6]=i,e[7]=a,e[8]=l,e[9]=c):c=e[9],c}function l7(n){return r.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/70",children:n},n)}function ap(n){const e=B.c(51),{toolCalls:t,cwd:s,expandAll:o,isAgentActive:i}=n,a=o===void 0?!1:o,l=i===void 0?!1:i;let c;if(e[0]!==l||e[1]!==t){let K;e[3]!==l?(K=V=>ZT(V,l),e[3]=l,e[4]=K):K=e[4],c=t.map(K),e[0]=l,e[1]=t,e[2]=c}else c=e[2];const d=c,u=d.flatMap(h7),f=u.length,m=u.reduce(p7,0),p=u.filter(m7).length,h=u.filter(f7).length,[g,x]=Hs();let b;e[5]!==d?(b=d.map(u7).join(`
106
-
107
- `),e[5]=d,e[6]=b):b=e[6];const w=b,v=d.length===1?d[0].description:void 0;let S;e[7]!==d[0]||e[8]!==d.length?(S=d.length===1?d[0].options:[],e[7]=d[0],e[8]=d.length,e[9]=S):S=e[9];const j=S;let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(wo,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),e[10]=k):k=e[10];const C=fn,N="flex flex-wrap items-center gap-x-2 gap-y-1";let _;e[11]!==d.length?(_=d.length>1&&r.jsxs("span",{children:[d.length," calls"]}),e[11]=d.length,e[12]=_):_=e[12];const P=i7(u);let A;e[13]!==P?(A=r.jsx("span",{children:P}),e[13]=P,e[14]=A):A=e[14];let T;e[15]!==v?(T=v&&r.jsx("span",{className:"text-foreground/70",children:v}),e[15]=v,e[16]=T):T=e[16];let E;e[17]!==j?(E=j.map(d7),e[17]=j,e[18]=E):E=e[18];const R=m===1?"line":"lines";let $;e[19]!==p?($=p>0&&r.jsxs("span",{className:"font-medium text-destructive",children:[" · ",p," failed"]}),e[19]=p,e[20]=$):$=e[20];let I;e[21]!==h?(I=h>0&&r.jsxs("span",{children:[" · ",h," not run"]}),e[21]=h,e[22]=I):I=e[22];let M;e[23]!==R||e[24]!==$||e[25]!==I||e[26]!==m?(M=r.jsxs("span",{className:"ml-auto tabular-nums",children:[m," ",R,$,I]}),e[23]=R,e[24]=$,e[25]=I,e[26]=m,e[27]=M):M=e[27];let D;e[28]!==C||e[29]!==A||e[30]!==T||e[31]!==E||e[32]!==M||e[33]!==_?(D=r.jsxs(C,{className:N,children:[_,A,T,E,M]}),e[28]=C,e[29]=A,e[30]=T,e[31]=E,e[32]=M,e[33]=_,e[34]=D):D=e[34];let O;e[35]!==w||e[36]!==x?(O=()=>x(w),e[35]=w,e[36]=x,e[37]=O):O=e[37];const L=g?"Commands copied":f===1?"Copy command":"Copy commands",F=g?"Copied":f===1?"Copy command":"Copy commands";let z;e[38]!==g?(z=g?r.jsx(mt,{"data-icon":"inline-start","aria-hidden":"true"}):r.jsx(An,{"data-icon":"inline-start","aria-hidden":"true"}),e[38]=g,e[39]=z):z=e[39];let W;e[40]!==O||e[41]!==L||e[42]!==F||e[43]!==z?(W=r.jsx(Nd,{children:r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:O,"aria-label":L,title:F,children:z})}),e[40]=O,e[41]=L,e[42]=F,e[43]=z,e[44]=W):W=e[44];let U;e[45]!==d||e[46]!==s||e[47]!==a?(U=d.map((K,V)=>{const Y=d.slice(0,V).reduce(c7,0);return r.jsxs("div",{children:[V>0&&r.jsx(St,{}),d.length>1&&r.jsx(a7,{call:K,index:V}),K.rows.map((G,J)=>r.jsx(r7,{row:G,index:Y+J,defaultOpen:a,cwd:s},J))]},K.toolCall.id)}),e[45]=d,e[46]=s,e[47]=a,e[48]=U):U=e[48];let H;return e[49]!==U?(H=r.jsx(Qt,{children:r.jsx("div",{"aria-label":"Command sections",children:U})}),e[49]=U,e[50]=H):H=e[50],r.jsxs(Jt,{size:"sm",className:"mt-1.5",role:"region","aria-label":f===1?"Bash command":"Bash commands",children:[r.jsxs(rn,{children:[r.jsxs(an,{className:"flex items-center gap-2",children:[k,f," ",f===1?"command":"commands"]}),D,W]}),H]})}function c7(n,e){return n+e.rows.length}function d7(n){return r.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/70",children:n},n)}function u7(n){return n.command}function f7(n){return n.section.output===null&&!n.pending}function m7(n){return n.failed}function p7(n,e){return n+M0(e.section.output)}function h7(n){return n.rows}const g7=es("group/toggle inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap outline-none transition-[color,background-color,border-color,box-shadow,transform,scale] duration-100 ease-out hover:bg-muted hover:text-foreground active:scale-[0.96] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-pressed:bg-muted motion-reduce:transition-none motion-reduce:active:scale-100 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-muted"},size:{default:"h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",sm:"h-7 min-w-7 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2"}},defaultVariants:{variant:"default",size:"default"}}),D0=y.createContext({size:"default",variant:"default",spacing:2,orientation:"horizontal"});function x7(n){const e=B.c(29);let t,s,o,i,a,l,c;e[0]!==n?({className:s,variant:c,size:i,spacing:a,orientation:l,children:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a,e[6]=l,e[7]=c):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5],l=e[6],c=e[7]);const d=a===void 0?2:a,u=l===void 0?"horizontal":l;let f;e[8]!==d?(f={"--gap":d},e[8]=d,e[9]=f):f=e[9];const m=f;let p;e[10]!==s?(p=q("group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-[orientation=vertical]:flex-col data-[orientation=vertical]:items-stretch",s),e[10]=s,e[11]=p):p=e[11];let h;e[12]!==u||e[13]!==i||e[14]!==d||e[15]!==c?(h={variant:c,size:i,spacing:d,orientation:u},e[12]=u,e[13]=i,e[14]=d,e[15]=c,e[16]=h):h=e[16];let g;e[17]!==t||e[18]!==h?(g=r.jsx(D0.Provider,{value:h,children:t}),e[17]=t,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==u||e[21]!==o||e[22]!==i||e[23]!==d||e[24]!==m||e[25]!==p||e[26]!==g||e[27]!==c?(x=r.jsx(Uy,{"data-slot":"toggle-group","data-variant":c,"data-size":i,"data-spacing":d,"data-orientation":u,orientation:u,style:m,className:p,...o,children:g}),e[20]=u,e[21]=o,e[22]=i,e[23]=d,e[24]=m,e[25]=p,e[26]=g,e[27]=c,e[28]=x):x=e[28],x}function b7(n){const e=B.c(19);let t,s,o,i,a;e[0]!==n?({className:s,children:t,variant:i,size:a,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5]);const l=i===void 0?"default":i,c=a===void 0?"default":a,d=y.useContext(D0),u=d.variant||l,f=d.size||c,m=d.spacing;let p;e[6]!==s||e[7]!==d.size||e[8]!==d.variant||e[9]!==c||e[10]!==l?(p=q("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",g7({variant:d.variant||l,size:d.size||c}),s),e[6]=s,e[7]=d.size,e[8]=d.variant,e[9]=c,e[10]=l,e[11]=p):p=e[11];let h;return e[12]!==t||e[13]!==d.spacing||e[14]!==o||e[15]!==u||e[16]!==f||e[17]!==p?(h=r.jsx(By,{"data-slot":"toggle-group-item","data-variant":u,"data-size":f,"data-spacing":m,className:p,...o,children:t}),e[12]=t,e[13]=d.spacing,e[14]=o,e[15]=u,e[16]=f,e[17]=p,e[18]=h):h=e[18],h}function v7(n){const e=B.c(31),{toolCall:t,sessionId:s,embedded:o}=n,i=o===void 0?!1:o;let a;e[0]!==t.input.questions?(a=t.input.questions??[],e[0]=t.input.questions,e[1]=a):a=e[1];const l=a;let c;e[2]!==l?(c=()=>Object.fromEntries(l.map(y7)),e[2]=l,e[3]=c):c=e[3];const[d,u]=y.useState(c),[f,m]=y.useState(!1),[p,h]=y.useState(!1),{chat:g}=$r(),{sendMessage:x}=g;if(l.length===0)return null;let b;e[4]!==d||e[5]!==l||e[6]!==x?(b=()=>{const T=l.map(E=>{var $;const R=($=d[E.question])==null?void 0:$.trim();return R?l.length>1?`${E.question}
108
- ${R}`:R:null}).filter(Boolean).join(`
109
-
110
- `);T&&x(T),h(!0)},e[4]=d,e[5]=l,e[6]=x,e[7]=b):b=e[7];const w=b;let v;if(e[8]!==d||e[9]!==w||e[10]!==s||e[11]!==t.id){const T=async E=>{E.preventDefault(),m(!0);try{(await ud(s,t.id,d)).ok?h(!0):w()}catch{w()}m(!1)};v=E=>{T(E)},e[8]=d,e[9]=w,e[10]=s,e[11]=t.id,e[12]=v}else v=e[12];const S=!i&&"mt-2 rounded-md border bg-card p-3",j=p&&"pointer-events-none opacity-50";let k;e[13]!==S||e[14]!==j?(k=q("flex flex-col gap-3",S,j),e[13]=S,e[14]=j,e[15]=k):k=e[15];let C;if(e[16]!==d||e[17]!==l||e[18]!==t.id){let T;e[20]!==d||e[21]!==t.id?(T=(E,R)=>{const $=E.options&&E.options.length>0,I=new Set(E.multiSelect?(d[E.question]??"").split(", ").filter(Boolean):[]),M=`ask-user-answer-${t.id}-${R}`;return r.jsxs(kj,{className:"gap-2 border-b border-border pb-3 last:border-b-0 last:pb-0",children:[(E.header||E.question)&&r.jsxs(Cj,{variant:"label",className:"flex flex-col items-start gap-1",children:[E.header&&r.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:E.header}),r.jsx("span",{className:"text-sm leading-relaxed text-foreground",children:E.question})]}),$?r.jsx(x7,{multiple:E.multiSelect,orientation:"vertical",variant:"outline",value:E.multiSelect?Array.from(I):d[E.question]?[d[E.question]]:[],onValueChange:D=>{if(!E.multiSelect&&D.length===0)return;const O=E.multiSelect?D.join(", "):D[0];u({...d,[E.question]:O})},className:"grid w-full gap-1.5",children:E.options.map((D,O)=>{const L=E.multiSelect?I.has(D.label):d[E.question]===D.label;return r.jsxs(b7,{value:D.label,"aria-label":D.label,className:"h-auto w-full justify-start whitespace-normal px-3 py-2.5 text-left",children:[r.jsx("span",{className:q("mt-0.5 flex size-4 shrink-0 items-center justify-center border",E.multiSelect?"rounded":"rounded-full",L?"border-primary bg-primary text-primary-foreground":"border-muted-foreground/30"),"aria-hidden":"true",children:L&&r.jsx(mt,{className:"size-3",strokeWidth:3,"data-icon":"icon"})}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block text-xs font-medium",children:D.label}),D.description&&r.jsx("span",{className:"mt-0.5 block text-xs leading-relaxed text-muted-foreground",children:D.description})]})]},O)})}):r.jsxs(wt,{children:[r.jsx(jt,{htmlFor:M,children:"Answer"}),r.jsx(_a,{id:M,value:d[E.question]??"",onChange:D=>{u({...d,[E.question]:D.target.value})},rows:2,placeholder:"Type your answer..."})]})]},R)},e[20]=d,e[21]=t.id,e[22]=T):T=e[22],C=l.map(T),e[16]=d,e[17]=l,e[18]=t.id,e[19]=C}else C=e[19];const N=f||p,_=p?"Sent":f?"Sending...":"Send answer";let P;e[23]!==N||e[24]!==_?(P=r.jsx(ee,{type:"submit",size:"sm",disabled:N,children:_}),e[23]=N,e[24]=_,e[25]=P):P=e[25];let A;return e[26]!==C||e[27]!==P||e[28]!==v||e[29]!==k?(A=r.jsxs("form",{onSubmit:v,className:k,children:[C,P]}),e[26]=C,e[27]=P,e[28]=v,e[29]=k,e[30]=A):A=e[30],A}function y7(n){return[n.question,""]}function w7(n){return Array.isArray(n.input.questions)?n.input.questions.filter(e=>typeof e=="object"&&e!==null&&typeof e.question=="string"):[]}function lp(n){try{return JSON.parse(`"${n}"`)}catch{return n.replace(/\\"/g,'"').replace(/\\\\/g,"\\")}}function j7(n){const e={},t=/"((?:\\.|[^"\\])*)"\s*=\s*"((?:\\.|[^"\\])*)"/g;let s;for(;(s=t.exec(n))!==null;)e[lp(s[1])]=lp(s[2]);return e}function S7(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function N7(n,e){const t=(n.options??[]).filter(s=>{const o=s.label.trim();return o?new RegExp(`(^|[^\\p{L}\\p{N}])${S7(o)}(?=$|[^\\p{L}\\p{N}])`,"iu").test(e):!1});return t.length===1?t[0].label:void 0}function k7(n,e){const t=n.input.answers;if(typeof t=="object"&&t!==null&&!Array.isArray(t)){const o=Object.entries(t).filter(i=>typeof i[1]=="string");if(o.length>0)return Object.fromEntries(o)}if(!n.result)return{};const s=j7(n.result);for(const o of e)if(s[o.question]===void 0){const i=N7(o,n.result);i!==void 0&&(s[o.question]=i)}return s}function cp(n,e,t){return e===void 0?!1:n.multiSelect?e.split(/,\s*/).includes(t):e===t}function C7(n){const e=B.c(30),{question:t,answer:s,index:o,completed:i}=n;let a;e[0]!==t.options?(a=t.options??[],e[0]=t.options,e[1]=a):a=e[1];const l=a;let c;if(e[2]!==s||e[3]!==l||e[4]!==t){let v;e[6]!==s||e[7]!==t?(v=S=>cp(t,s,S.label),e[6]=s,e[7]=t,e[8]=v):v=e[8],c=l.filter(v),e[2]=s,e[3]=l,e[4]=t,e[5]=c}else c=e[5];const d=c.length,u=i&&s!==void 0&&d===0,f=o+1;let m;e[9]!==f?(m=r.jsx(_e,{variant:"outline",className:"size-5 rounded-full p-0 font-mono text-muted-foreground",children:f}),e[9]=f,e[10]=m):m=e[10];let p;e[11]!==t.header?(p=t.header&&r.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:t.header}),e[11]=t.header,e[12]=p):p=e[12];let h;e[13]!==m||e[14]!==p?(h=r.jsxs("div",{className:"mb-1.5 flex items-center gap-2",children:[m,p]}),e[13]=m,e[14]=p,e[15]=h):h=e[15];let g;e[16]!==t.question?(g=r.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:t.question}),e[16]=t.question,e[17]=g):g=e[17];let x;e[18]!==s||e[19]!==l||e[20]!==t?(x=l.length>0&&r.jsx("div",{className:"mt-2 flex flex-col divide-y divide-border",children:l.map((v,S)=>{const j=cp(t,s,v.label);return r.jsxs("div",{className:q("flex items-start gap-2.5 py-2",j?"text-foreground":"text-muted-foreground"),children:[r.jsx("span",{className:q("mt-0.5 flex size-4 shrink-0 items-center justify-center border",t.multiSelect?"rounded":"rounded-full",j?"border-primary bg-primary text-primary-foreground":"border-muted-foreground/30"),"aria-hidden":"true",children:j&&r.jsx(mt,{className:"size-3",strokeWidth:3,"data-icon":"icon"})}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsxs("span",{className:"block text-xs font-medium",children:[v.label,j&&r.jsx(_e,{variant:"secondary",className:"ml-2",children:"Selected"})]}),v.description&&r.jsx("span",{className:"mt-0.5 block text-xs leading-relaxed text-muted-foreground",children:v.description})]})]},`${v.label}-${S}`)})}),e[18]=s,e[19]=l,e[20]=t,e[21]=x):x=e[21];let b;e[22]!==s||e[23]!==u?(b=u&&r.jsxs("div",{className:"mt-2 border-l-2 border-border pl-3",children:[r.jsx("div",{className:"mb-0.5 text-xs font-medium text-muted-foreground",children:"Answer"}),r.jsx("p",{className:"whitespace-pre-wrap break-words text-sm leading-relaxed text-foreground/90",children:s.trim()||"No answer provided"})]}),e[22]=s,e[23]=u,e[24]=b):b=e[24];let w;return e[25]!==h||e[26]!==g||e[27]!==x||e[28]!==b?(w=r.jsxs("div",{className:"border-b border-border py-3 last:border-b-0",children:[h,g,x,b]}),e[25]=h,e[26]=g,e[27]=x,e[28]=b,e[29]=w):w=e[29],w}function _7(n){const e=B.c(61),{toolCall:t,expandToolPayloads:s,isAwaitingAnswer:o,sessionId:i}=n,[a,l]=y.useState(!1);let c;e[0]!==t?(c=w7(t),e[0]=t,e[1]=c):c=e[1];const d=c;let u;e[2]!==d||e[3]!==t?(u=k7(t,d),e[2]=d,e[3]=t,e[4]=u):u=e[4];const f=u,m=s||a,p=t.result!==null&&!t.isError,h=t.result===null&&o&&!!i&&d.length>0;let g;e[5]!==f?(g=Object.keys(f),e[5]=f,e[6]=g):g=e[6];const x=g.length>0,b=t.isError?tn:p?Bn:Po,w=t.isError?"Not answered":p?"Answered":h?"Waiting for answer":"No answer recorded",v=t.isError&&"border-destructive/30";let S;e[7]!==v?(S=q("my-1 overflow-hidden rounded-lg border bg-card",v),e[7]=v,e[8]=S):S=e[8];let j;e[9]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(Qh,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground","data-icon":"inline-start"}),e[9]=j):j=e[9];let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx("h3",{className:"text-sm font-medium text-foreground",children:"Decision requested"}),e[10]=k):k=e[10];const C=d.length===1?"question":"questions";let N;e[11]!==d.length||e[12]!==C?(N=r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[k,r.jsxs("span",{className:"text-xs text-muted-foreground",children:[d.length," ",C]})]}),e[11]=d.length,e[12]=C,e[13]=N):N=e[13];const _=t.isError?"destructive":p?"secondary":"outline";let P;e[14]!==b?(P=r.jsx(b,{"data-icon":"inline-start"}),e[14]=b,e[15]=P):P=e[15];let A;e[16]!==w||e[17]!==_||e[18]!==P?(A=r.jsxs(_e,{variant:_,children:[P,w]}),e[16]=w,e[17]=_,e[18]=P,e[19]=A):A=e[19];let T;e[20]!==A||e[21]!==N?(T=r.jsxs("div",{className:"min-w-0 flex-1",children:[N,A]}),e[20]=A,e[21]=N,e[22]=T):T=e[22];let E;e[23]!==t.timestamp?(E=t.timestamp&&r.jsx("time",{className:"hidden shrink-0 pt-0.5 font-mono text-xs tabular-nums text-muted-foreground sm:block",children:new Date(t.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),e[23]=t.timestamp,e[24]=E):E=e[24];let R;e[25]!==T||e[26]!==E?(R=r.jsxs("header",{className:"flex items-start gap-2.5 border-b px-3 py-2.5",children:[j,T,E]}),e[25]=T,e[26]=E,e[27]=R):R=e[27];let $;e[28]!==f||e[29]!==h||e[30]!==d||e[31]!==i||e[32]!==t?($=h&&i?r.jsx(v7,{toolCall:t,sessionId:i,embedded:!0}):d.length>0?d.map((U,H)=>r.jsx(C7,{question:U,answer:f[U.question],index:H,completed:t.result!==null},`${U.question}-${H}`)):r.jsx("p",{className:"py-3 text-sm text-muted-foreground",children:"Question details are unavailable."}),e[28]=f,e[29]=h,e[30]=d,e[31]=i,e[32]=t,e[33]=$):$=e[33];let I;e[34]!==x||e[35]!==t.isError||e[36]!==t.result?(I=t.result!==null&&!x&&r.jsxs("div",{className:q("border-t border-border py-3",t.isError?"text-destructive":"text-muted-foreground"),children:[r.jsx("div",{className:"mb-0.5 text-xs font-semibold uppercase tracking-wide opacity-70",children:"Recorded response"}),r.jsx("p",{className:"whitespace-pre-wrap break-words text-sm leading-relaxed",children:t.result})]}),e[34]=x,e[35]=t.isError,e[36]=t.result,e[37]=I):I=e[37];let M;e[38]!==$||e[39]!==I?(M=r.jsxs("div",{className:"px-3",children:[$,I]}),e[38]=$,e[39]=I,e[40]=M):M=e[40];let D;e[41]!==s?(D=()=>{s||l(T7)},e[41]=s,e[42]=D):D=e[42];let O;e[43]!==m?(O=m?r.jsx(tt,{"data-icon":"inline-start"}):r.jsx(Je,{"data-icon":"inline-start"}),e[43]=m,e[44]=O):O=e[44];let L;e[45]!==m||e[46]!==D||e[47]!==O?(L=r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:D,className:"-ml-2 text-muted-foreground","aria-expanded":m,children:[O,"Raw details"]}),e[45]=m,e[46]=D,e[47]=O,e[48]=L):L=e[48];let F;e[49]!==m||e[50]!==t.input||e[51]!==t.result?(F=m&&r.jsxs("div",{className:"mt-1.5 grid gap-2 pb-1.5 lg:grid-cols-2",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Input"}),r.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap break-words rounded-md border bg-muted/30 p-2 font-mono text-xs leading-relaxed text-muted-foreground",children:JSON.stringify(t.input,null,2)})]}),t.result!==null&&r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Result"}),r.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap break-words rounded-md border bg-muted/30 p-2 font-mono text-xs leading-relaxed text-muted-foreground",children:t.result})]})]}),e[49]=m,e[50]=t.input,e[51]=t.result,e[52]=F):F=e[52];let z;e[53]!==L||e[54]!==F?(z=r.jsxs("div",{className:"border-t px-3 py-1.5",children:[L,F]}),e[53]=L,e[54]=F,e[55]=z):z=e[55];let W;return e[56]!==R||e[57]!==M||e[58]!==z||e[59]!==S?(W=r.jsxs("section",{className:S,"aria-label":"Question history",children:[R,M,z]}),e[56]=R,e[57]=M,e[58]=z,e[59]=S,e[60]=W):W=e[60],W}function T7(n){return!n}const E7={spawn_agent:{label:"Spawn agent",styleName:"Task"},wait_agent:{label:"Wait for agents",styleName:"Task"},send_message:{label:"Message agent",styleName:"Task"},followup_task:{label:"Follow up",styleName:"Task"},list_agents:{label:"List agents",styleName:"Task"},interrupt_agent:{label:"Interrupt agent",styleName:"Task"},tool_search:{label:"Find tools",styleName:"ToolSearch"},list_mcp_resources:{label:"List MCP resources",styleName:"Mcp"},list_mcp_resource_templates:{label:"List MCP templates",styleName:"Mcp"},read_mcp_resource:{label:"Read MCP resource",styleName:"Mcp"},request_plugin_install:{label:"Install plugin",styleName:"Mcp"},create_goal:{label:"Create goal",styleName:"TodoWrite"},get_goal:{label:"Check goal",styleName:"TodoWrite"},update_goal:{label:"Update goal",styleName:"TodoWrite"},view_image:{label:"View image",styleName:"Read"}};function P7(n){return typeof n=="object"&&n!==null}function hn(...n){return n.find(e=>typeof e=="string")??""}function _o(n,e=140){const t=n.replace(/\s+/g," ").trim();return t.length>e?`${t.slice(0,e-1)}…`:t}function nu(n){const e=[],t=new Set;for(const s of n){const o=s.trim();!o||t.has(o)||(t.add(o),e.push(o))}return e}function qr(n,e=""){const t=nu(n);if(t.length===0)return e;const s=_o(t[0]);return t.length===1?s:`${s} · +${t.length-1} more`}function su(n,e){return n===1?`1 ${e}`:`${n} ${e}${/(?:ch|sh|s|x|z)$/.test(e)?"es":"s"}`}const dp={mcp:"MCP",api:"API",url:"URL",openai:"OpenAI",figma:"Figma",clickup:"ClickUp"};function Gi(n,e=!1){const t=n.replace(/^mcp__/,"").replace(/__/g," ").replace(/[_./:-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim().split(/\s+/).filter(Boolean).map(o=>{const i=o.toLowerCase();return dp[i]?dp[i]:e?i[0].toUpperCase()+i.slice(1):i});if(t.length===0)return"Tool";const s=t.join(" ");return s[0].toUpperCase()+s.slice(1)}function A7(n){if(!n)return null;const e=n.trim(),t=Zn(e,0);return(t==null?void 0:t.endIndex)===e.length?t.value:null}function Yt(n,...e){for(const t of e){const s=A7(Dd(n,t));if(s)return s;const o=Ld(n,t)[0];if(o)return o}return""}function R7(n,...e){for(const t of e){const s=dx(n,t)[0];if(s!==void 0)return s}return null}function Yi(n){return Yt(n,"description","query","q","cmd","command","file_path","path","uri","url","pattern","prompt","objective","message","location","ticker","target","task_name","plugin_id","server","status","id")}const I7=[{key:"search_query",label:"Search web",noun:"search",summaryGroups:[["q","query"]]},{key:"image_query",label:"Search images",noun:"image search",summaryGroups:[["q","query"]]},{key:"open",label:"Open page",noun:"page",summaryGroups:[["ref_id","url"]],detail:{property:"lineno",format:n=>`line ${n}`}},{key:"click",label:"Open link",noun:"link",summaryGroups:[["ref_id"]],detail:{property:"id",format:n=>`link ${n}`}},{key:"find",label:"Find on page",noun:"find",summaryGroups:[["pattern"],["ref_id","url"]]},{key:"screenshot",label:"Capture page",noun:"capture",summaryGroups:[["ref_id"]],detail:{property:"pageno",format:n=>`page ${n+1}`}},{key:"finance",label:"Check markets",noun:"quote",summaryGroups:[["ticker"]]},{key:"weather",label:"Check weather",noun:"forecast",summaryGroups:[["location"]]},{key:"sports",label:"Check sports",noun:"sports lookup",summaryGroups:[["league","team"]],countProperties:["league"]},{key:"time",label:"Check time",noun:"time lookup",summaryGroups:[["utc_offset"]]}];function up(n,e){return e.flatMap(t=>Ld(n,t))}function $7(n,e){const t=e.summaryGroups.map(i=>up(n,i)),s=e.detail?dx(n,e.detail.property):[],o=e.countProperties?up(n,e.countProperties):t[0];return{label:e.label,noun:e.noun,summary:[...t.map(i=>qr(i)),e.detail&&s.length>0?e.detail.format(s[0]):""].filter(Boolean).join(" · "),count:Math.max(ux(n),nu(o).length,s.length,1)}}function M7(n){const e=[];for(const t of I7){const s=Dd(n,t.key);s&&e.push($7(s,t))}return e}function O7(n){const e=M7(n);return e.length===0?{label:"Browse web",summary:Yi(n),styleName:"WebSearch"}:e.length===1?{label:e[0].label,summary:e[0].summary,styleName:"WebSearch"}:{label:"Browse web",summary:e.map(t=>su(t.count,t.noun)).join(" · "),styleName:"WebSearch"}}function L0(n){if(!n.startsWith("mcp__"))return null;const[,e,...t]=n.split("__");return!e||t.length===0?null:{server:Gi(e,!0),action:Gi(t.join(" "))}}function D7(n,e){const t=L0(n);if(!t)return{label:Gi(n),summary:Yi(e),styleName:"Mcp"};const s=Yi(e);return{label:t.server,summary:[t.action,s].filter(Boolean).join(" · "),styleName:"Mcp"}}function L7(n){const e=Zn(n.trim(),0),t=(e==null?void 0:e.value)??n,s=nu(Array.from(t.matchAll(/^\*\*\*\s+(?:Update|Add|Delete) File:\s*(.+)$/gm),o=>o[1]));return qr(s,s.length>0?su(s.length,"file"):"")}function z7(n){const e=n.argumentSource;switch(n.name){case"exec_command":return{label:"Run command",summary:Yt(e,"cmd","command"),styleName:"Bash"};case"write_stdin":{const t=R7(e,"session_id"),s=Yt(e,"chars");return{label:"Continue command",summary:[t!==null?`session ${t}`:"",s?_o(s,60):""].filter(Boolean).join(" · "),styleName:"Bash"}}case"apply_patch":return{label:"Apply patch",summary:L7(e),styleName:"Edit"};case"web__run":case"web_search":return O7(e);case"view_image":return{label:"View image",summary:Yt(e,"path"),styleName:"Read"};case"update_plan":{const t=Dd(e,"plan"),s=t?ux(t):0;return{label:"Update plan",summary:s>0?su(s,"step"):Yt(e,"explanation"),styleName:"TodoWrite"}}case"create_goal":return{label:"Create goal",summary:Yt(e,"objective"),styleName:"TodoWrite"};case"get_goal":return{label:"Check goal",summary:"",styleName:"TodoWrite"};case"update_goal":return{label:"Update goal",summary:Yt(e,"status"),styleName:"TodoWrite"};case"list_mcp_resources":return{label:"List MCP resources",summary:Yt(e,"server"),styleName:"Mcp"};case"list_mcp_resource_templates":return{label:"List MCP templates",summary:Yt(e,"server"),styleName:"Mcp"};case"read_mcp_resource":return{label:"Read MCP resource",summary:[Yt(e,"server"),Yt(e,"uri")].filter(Boolean).join(" · "),styleName:"Mcp"};case"request_plugin_install":return{label:"Install plugin",summary:Yt(e,"plugin_id"),styleName:"Mcp"};case"tool_search":return{label:"Find tools",summary:Yt(e,"query"),styleName:"ToolSearch"};case"image_gen__imagegen":return{label:"Generate image",summary:Yt(e,"prompt"),styleName:"Image"};default:return n.name.startsWith("mcp__")?D7(n.name,e):{label:Gi(n.name),summary:Yi(e),styleName:n.name}}}function z0(n){return typeof n.input.raw=="string"&&/(?:^|__|[.:/])exec$/.test(n.name)}function F7(n){const e=Fk(n);if(e.length===0)return{label:"Run tool script",summary:"",styleName:"exec"};const t=e.map(z7),s=t[0];if(t.every(i=>i.label===s.label)){const i=qr(t.map(a=>a.summary));return{label:s.label,summary:e.length===1?i:[`×${e.length}`,i].filter(Boolean).join(" · "),styleName:s.styleName}}const o=new Map;for(const i of t)o.set(i.label,(o.get(i.label)??0)+1);return{label:"Run tools",summary:[...o].map(([i,a])=>a>1?`${i} ×${a}`:i).join(" · "),styleName:"exec"}}function B7(n){const e=P7(n.action)?n.action:null,t=typeof(e==null?void 0:e.type)=="string"?e.type:"search";if(t==="open_page"||t==="openPage")return{label:"Open page",summary:hn(e==null?void 0:e.url,n.query),styleName:"WebSearch"};if(t==="find_in_page"||t==="findInPage")return{label:"Find on page",summary:[hn(e==null?void 0:e.pattern),hn(e==null?void 0:e.url)].filter(Boolean).join(" · "),styleName:"WebSearch"};const s=Array.isArray(e==null?void 0:e.queries)?e.queries.filter(i=>typeof i=="string"):[],o=hn(e==null?void 0:e.query,n.query);return{label:"Search web",summary:qr([o,...s]),styleName:"WebSearch"}}const U7=["summary","headline","verdict","title"];function W7(n){const e=hn(...U7.map(t=>n[t]));if(e)return _o(e);for(const[t,s]of Object.entries(n)){if(!Array.isArray(s))continue;const o=s.length===1&&t.endsWith("s")?t.slice(0,-1):t;return`${s.length} ${o}`}return""}function H7(n){const e=hn(n.description);if(e)return _o(e);const t=hn(n.script);return(t?Ld(t,"name")[0]??"":"")||hn(n.scriptPath)}function fp(n){const e=Object.keys(n);if(e.length===0)return"";const t=n[e[0]];return typeof t!="string"?"":t.length>80?t.slice(0,80)+"...":t}function mp(n){var t;const e=n.input;switch(n.name){case"Read":case"Write":case"Edit":return String(e.file_path??e.path??"");case"Bash":return String(e.command??e.cmd??"");case"Grep":case"Glob":return String(e.pattern??"");case"Task":case"Agent":return String(e.description??e.prompt??"");case"WebFetch":return String(e.url??"");case"NotebookEdit":return String(e.notebook_path??"");case"EnterPlanMode":return"Entered plan mode";case"ExitPlanMode":return"Waiting for plan approval";case"AskUserQuestion":{const s=e.questions;return((t=s==null?void 0:s[0])==null?void 0:t.question)??""}case"Monitor":{const s=String(e.bash_id??""),o=e.filter?` · filter=${e.filter}`:"";return`${s}${o}`}case"CronCreate":{const s=String(e.schedule??e.cron??""),o=String(e.prompt??""),i=o.length>60?o.slice(0,60)+"...":o;return s&&i?`${s} → ${i}`:s||i}case"CronList":return"";case"CronDelete":return String(e.id??e.cron_id??"");case"ScheduleWakeup":{const s=Number(e.delaySeconds??0),o=Math.round(s/60),i=s>=3600?`${Math.round(s/3600)}h`:s>=60?`${o}m`:`${s}s`,a=e.reason?` · ${e.reason}`:"";return`in ${i}${a}`}case"RemoteTrigger":{const s=String(e.action??""),o=String(e.id??e.trigger_id??"");return[s,o].filter(Boolean).join(" ")}case"PushNotification":return String(e.title??e.body??"");case"EnterWorktree":{const s=String(e.name??e.branch??""),o=e.path?` (${e.path})`:"";return`${s}${o}`}case"ExitWorktree":return String(e.name??e.branch??"");case"Skill":return String(e.skill??e.name??"");case"ToolSearch":return String(e.query??"");case"SendMessage":{const s=hn(e.to,e.recipient),o=_o(hn(e.summary,e.message,e.content));return[s,o].filter(Boolean).join(" · ")}case"ListAgents":case"TaskList":return"";case"TaskCreate":return _o(hn(e.subject,e.description));case"TaskUpdate":{const s=String(e.taskId??""),o=Array.isArray(e.addBlockedBy)?e.addBlockedBy.filter(a=>typeof a=="string"):[],i=hn(e.status)||(o.length>0?`blocked by ${o.join(", ")}`:"");return i?`${s} → ${i}`:s}case"TaskOutput":case"TaskStop":return String(e.task_id??"");case"Workflow":return H7(e);case"StructuredOutput":case"ReportFindings":case"DesignSync":case"Artifact":case"LSP":return W7(e)||fp(e);case"spawn_agent":return String(e.task_name??e.message??"");case"wait_agent":{const s=Array.isArray(e.ids)?e.ids.filter(o=>typeof o=="string"):[];return qr(s)}case"send_message":case"followup_task":return[e.target,e.message].filter(s=>typeof s=="string").join(" · ");case"list_agents":return String(e.path_prefix??"");case"interrupt_agent":return String(e.target??"");case"list_mcp_resources":case"list_mcp_resource_templates":return String(e.server??"");case"read_mcp_resource":return[e.server,e.uri].filter(s=>typeof s=="string").join(" · ");case"request_plugin_install":return String(e.plugin_id??"");case"create_goal":return String(e.objective??"");case"update_goal":return String(e.status??"");case"view_image":return String(e.path??"");default:return fp(e)}}function La(n){if(z0(n))return F7(n.input.raw);if(n.name==="WebSearch")return B7(n.input);const e=L0(n.name);if(e)return{label:e.server,summary:[e.action,mp(n)].filter(Boolean).join(" · "),styleName:"Mcp"};const t=E7[n.name];return{label:(t==null?void 0:t.label)??n.name,summary:mp(n),styleName:(t==null?void 0:t.styleName)??n.name}}function K7(n){return La(n).summary}const q7={mutating:"text-foreground",readOnly:"text-muted-foreground"},V7="text-destructive",pp=8,G7=4,Y7="whitespace-pre-wrap break-all border-l border-border pl-3 font-mono text-[11px] leading-relaxed text-muted-foreground",X7="max-h-96 overflow-y-auto whitespace-pre-wrap break-all rounded-md border p-2 font-mono text-xs leading-relaxed";function J7(n){return n.split(/\r\n|\r|\n/)}const Q7={Write:"mutating",Edit:"mutating",Bash:"mutating",exec:"mutating",Task:"mutating",Skill:"mutating",TodoWrite:"mutating",Image:"mutating",AskUserQuestion:"mutating",CronCreate:"mutating",CronDelete:"mutating",ScheduleWakeup:"mutating",RemoteTrigger:"mutating",PushNotification:"mutating",EnterWorktree:"mutating",ExitWorktree:"mutating",Agent:"mutating",SendMessage:"mutating",EndConversation:"mutating",TaskCreate:"mutating",TaskUpdate:"mutating",TaskStop:"mutating",Workflow:"mutating",Read:"readOnly",Grep:"readOnly",Glob:"readOnly",WebFetch:"readOnly",WebSearch:"readOnly",ToolSearch:"readOnly",Monitor:"readOnly",CronList:"readOnly",Mcp:"readOnly",EnterPlanMode:"readOnly",ExitPlanMode:"readOnly",ListAgents:"readOnly",TaskList:"readOnly",TaskOutput:"readOnly",LSP:"readOnly",StructuredOutput:"readOnly",ReportFindings:"readOnly"},Z7="readOnly";function e8(n){return Q7[n]??Z7}function F0(n,e=!1){return e?V7:q7[e8(n)]}function El(n){const e=B.c(8),{isOpen:t,onClick:s,label:o,controlsId:i}=n,a=t?tt:Je;let l;e[0]!==a?(l=r.jsx(a,{"data-icon":"inline-start"}),e[0]=a,e[1]=l):l=e[1];let c;return e[2]!==i||e[3]!==t||e[4]!==o||e[5]!==s||e[6]!==l?(c=r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:s,className:"-ml-2 text-muted-foreground","aria-expanded":t,"aria-controls":i,children:[l,o]}),e[2]=i,e[3]=t,e[4]=o,e[5]=s,e[6]=l,e[7]=c):c=e[7],c}function B0(n){const e=B.c(2),{toolCall:t,isAgentActive:s}=n;if(t.isError){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(Ys,{role:"img","aria-label":"Tool call failed",className:"size-4 text-destructive","data-icon":"icon"}),e[0]=o):o=e[0],o}if(t.result===null&&s){let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(ot,{role:"img","aria-label":"Tool call running",className:"size-4 animate-spin text-info","data-icon":"icon"}),e[1]=o):o=e[1],o}return null}function t8(n){const e=B.c(30),{toolCall:t,resultExpanded:s,onToggleExpanded:o,isMobile:i}=n,a=t.result??"",l=a.length>1e3,c=l&&!s?a.slice(0,500)+"...":a;let d;e[0]!==a||e[1]!==t.isError||e[2]!==t.name?(d=!t.isError&&t.name!=="Read"?P0(a):null,e[0]=a,e[1]=t.isError,e[2]=t.name,e[3]=d):d=e[3];const u=d,f=u??a;let m;e[4]!==f?(m=J7(f),e[4]=f,e[5]=m):m=e[5];const p=m,h=Math.max(0,p.length-pp);let g;e[6]!==p||e[7]!==f||e[8]!==s?(g=s?f:p.slice(0,pp).join(`
111
- `),e[6]=p,e[7]=f,e[8]=s,e[9]=g):g=e[9];const x=g,b=i?l:h>0,w=!i||!l||s,v=i?"boxed":"unboxed";let S;e[10]!==x||e[11]!==w||e[12]!==v||e[13]!==i||e[14]!==c||e[15]!==u||e[16]!==a||e[17]!==t.input||e[18]!==t.isError||e[19]!==t.name?(S=t.name==="Read"&&!t.isError&&typeof t.input.file_path=="string"?r.jsx(E0,{result:i?a:x,filePath:t.input.file_path,expanded:w,variant:v}):u!==null?r.jsx(Cc,{result:i?u:x,expanded:w,alreadyPretty:!0,variant:v}):r.jsx("pre",{className:q(i?X7:Y7,t.isError?q("border-destructive/20 text-destructive",i&&"bg-destructive/5"):i&&"border-border bg-muted/30 text-muted-foreground"),children:i?c:x}),e[10]=x,e[11]=w,e[12]=v,e[13]=i,e[14]=c,e[15]=u,e[16]=a,e[17]=t.input,e[18]=t.isError,e[19]=t.name,e[20]=S):S=e[20];let j;e[21]!==h||e[22]!==i||e[23]!==o||e[24]!==s||e[25]!==b?(j=b&&r.jsx("button",{type:"button",onClick:o,className:"mt-1 text-[10px] text-muted-foreground hover:text-foreground transition-colors",children:s?"Show less":i?"Show more":`+${h} lines`}),e[21]=h,e[22]=i,e[23]=o,e[24]=s,e[25]=b,e[26]=j):j=e[26];let k;return e[27]!==S||e[28]!==j?(k=r.jsxs("div",{className:"mt-1.5",children:[S,j]}),e[27]=S,e[28]=j,e[29]=k):k=e[29],k}function n8(n){const e=B.c(12),{chips:t}=n;let s,o,i,a;if(e[0]!==t){const d=t.slice(0,G7);s=t.length-d.length,o="flex min-w-0 items-center gap-1 overflow-hidden",i=`Sections: ${t.map(o8).join(", ")}`,a=d.map(s8),e[0]=t,e[1]=s,e[2]=o,e[3]=i,e[4]=a}else s=e[1],o=e[2],i=e[3],a=e[4];let l;e[5]!==s?(l=s>0&&r.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:["+",s]}),e[5]=s,e[6]=l):l=e[6];let c;return e[7]!==o||e[8]!==i||e[9]!==a||e[10]!==l?(c=r.jsxs("span",{className:o,"aria-label":i,children:[a,l]}),e[7]=o,e[8]=i,e[9]=a,e[10]=l,e[11]=c):c=e[11],c}function s8(n,e){return r.jsxs(_e,{variant:"outline",className:q("h-4 shrink-0 px-1.5 font-mono text-[10px]",R0[n.tone]),children:[n.name,n.count>1?` ×${n.count}`:""]},e)}function o8(n){return`${n.name}${n.count>1?` ×${n.count}`:""}`}function U0(n){const e=B.c(7),{chips:t,summary:s,isMobile:o}=n;if(t){let c;return e[0]!==t?(c=r.jsx(n8,{chips:t}),e[0]=t,e[1]=c):c=e[1],c}if(!s)return null;const i=o?"text-[11px]":"text-xs";let a;e[2]!==i?(a=q("truncate font-mono text-muted-foreground",i),e[2]=i,e[3]=a):a=e[3];let l;return e[4]!==s||e[5]!==a?(l=r.jsx("span",{className:a,children:s}),e[4]=s,e[5]=a,e[6]=l):l=e[6],l}function hp(n){const e=B.c(36),{toolCall:t,isMobile:s,isAgentActive:o,displayName:i,summary:a,sectionChips:l,nameTitle:c,nameClass:d,timeLabel:u,timeIso:f}=n;let m;e[0]!==f||e[1]!==u?(m=u&&r.jsx("time",{className:"sr-only",dateTime:f,children:u}),e[0]=f,e[1]=u,e[2]=m):m=e[2];const p=s?"gap-1.5":"gap-2";let h;e[3]!==p?(h=q("flex min-w-0 flex-1 items-center",p),e[3]=p,e[4]=h):h=e[4];const g=s?"text-[10px]":"text-[11px]";let x;e[5]!==d||e[6]!==g?(x=q("shrink-0 font-mono",g,d),e[5]=d,e[6]=g,e[7]=x):x=e[7];let b;e[8]!==i||e[9]!==c||e[10]!==x?(b=r.jsx("span",{className:x,title:c,children:i}),e[8]=i,e[9]=c,e[10]=x,e[11]=b):b=e[11];let w;e[12]!==l||e[13]!==s||e[14]!==a?(w=r.jsx(U0,{chips:l,summary:a,isMobile:s}),e[12]=l,e[13]=s,e[14]=a,e[15]=w):w=e[15];let v;e[16]!==h||e[17]!==b||e[18]!==w?(v=r.jsxs("div",{className:h,children:[b,w]}),e[16]=h,e[17]=b,e[18]=w,e[19]=v):v=e[19];let S;e[20]!==s||e[21]!==t.hookDurationMs?(S=t.hookDurationMs!==void 0&&t.hookDurationMs>0&&!s&&r.jsxs("span",{className:"text-[10px] text-muted-foreground/50 tabular-nums",title:"PostToolUse hook duration",children:[t.hookDurationMs,"ms"]}),e[20]=s,e[21]=t.hookDurationMs,e[22]=S):S=e[22];let j;e[23]!==t.outputReplacedByHook?(j=t.outputReplacedByHook&&r.jsx("span",{className:"text-[10px] text-blue-400",title:"Output replaced by hook",children:"hook"}),e[23]=t.outputReplacedByHook,e[24]=j):j=e[24];let k;e[25]!==o||e[26]!==t?(k=r.jsx(B0,{toolCall:t,isAgentActive:o}),e[25]=o,e[26]=t,e[27]=k):k=e[27];let C;e[28]!==j||e[29]!==k||e[30]!==S?(C=r.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[S,j,k]}),e[28]=j,e[29]=k,e[30]=S,e[31]=C):C=e[31];let N;return e[32]!==m||e[33]!==C||e[34]!==v?(N=r.jsxs(r.Fragment,{children:[m,v,C]}),e[32]=m,e[33]=C,e[34]=v,e[35]=N):N=e[35],N}function r8(n){if(n.isError)return null;const e=n.name==="Read"?n.input.file_path:n.name==="view_image"?n.input.path:null;return typeof e=="string"&&Wd(e)?e:null}function gp(n){const e=B.c(4),{toolCall:t}=n,s=t.input.old_string,o=t.input.new_string,i=t.input.file_path;let a;return e[0]!==s||e[1]!==o||e[2]!==i?(a=r.jsx(tu,{oldString:s,newString:o,filePath:i}),e[0]=s,e[1]=o,e[2]=i,e[3]=a):a=e[3],a}const i8={AskUserQuestion:"Question",Bash:"Command",exec:"Command",Task:"Agent",WebFetch:"Fetch",WebSearch:"Search",EnterPlanMode:"Plan mode",ExitPlanMode:"Plan review",ToolSearch:"Tool search"},W0=y.memo(function(e){var Le,ze;const t=B.c(164),{toolCall:s,groupedBashCalls:o,expandAll:i,expandToolPayloads:a,isAgentActive:l,skillMetadata:c}=e,d=a===void 0?!1:a,{session:u,pendingInteraction:f}=it(),m=Da(),[p,h]=y.useState(!1),[g,x]=y.useState(!1),[b,w]=y.useState(!1),[v,S]=y.useState(!1),[j,k]=y.useState(!1),[C,N]=y.useState(!1),_=y.useId(),P=y.useId(),A=y.useId(),T=y.useId(),E=y.useId(),[R,$]=y.useState(!1);let I;t[0]!==o||t[1]!==s?(I=o??(s.name==="Bash"?[s]:[]),t[0]=o,t[1]=s,t[2]=I):I=t[2];const M=I;let D;t[3]!==M||t[4]!==l||t[5]!==s.result?(D=(M.length>0?M.every(a8):s.result!==null)||!l,t[3]=M,t[4]=l,t[5]=s.result,t[6]=D):D=t[6];const L=m&&D&&!i&&!R;let F;t[7]!==s?(F=La(s),t[7]=s,t[8]=F):F=t[8];const z=F;let W;t[9]!==s?(W=z0(s),t[9]=s,t[10]=W):W=t[10];const U=W;let H;t[11]!==M?(H=M.length>0?M.flatMap($0):null,t[11]=M,t[12]=H):H=t[12];const K=H;let V;t[13]!==K?(V=K?KT(K):void 0,t[13]=K,t[14]=V):V=t[14];const Y=V,G=m&&z.label===s.name?i8[s.name]??s.name:z.label,J=M.length>1?`${G} ×${M.length}`:G,Q=z.label===s.name?s.name:`${z.label} (${s.name})`;let X,Z,te,ne,re,ie,ae,se,ue,le,de,pe,he,ce;if(t[15]!==M||t[16]!==Y||t[17]!==T||t[18]!==j||t[19]!==v||t[20]!==J||t[21]!==i||t[22]!==d||t[23]!==p||t[24]!==l||t[25]!==U||t[26]!==L||t[27]!==m||t[28]!==Q||t[29]!==f||t[30]!==z.styleName||t[31]!==z.summary||t[32]!==b||t[33]!==g||t[34]!==(K==null?void 0:K.length)||t[35]!==(u==null?void 0:u.sessionId)||t[36]!==c||t[37]!==s){pe=Symbol.for("react.early_return_sentinel");e:{const Te=F0(z.styleName,s.isError||M.some(l8));let Ce;t:{if(M.length<=1){Ce=s;break t}const Ye=M.some(c8)?null:s.result;let Me;t[52]!==M?(Me=M.some(d8),t[52]=M,t[53]=Me):Me=t[53];let Ue;t[54]!==M?(Ue=M.some(u8),t[54]=M,t[55]=Ue):Ue=t[55];let st;t[56]!==M?(st=M.reduce(f8,0),t[56]=M,t[57]=st):st=t[57];let Vt;t[58]!==Ye||t[59]!==Me||t[60]!==Ue||t[61]!==st||t[62]!==s?(Vt={...s,result:Ye,isError:Me,outputReplacedByHook:Ue,hookDurationMs:st},t[58]=Ye,t[59]=Me,t[60]=Ue,t[61]=st,t[62]=s,t[63]=Vt):Vt=t[63],Ce=Vt}const We=Ce;let Fe;t[64]!==s.timestamp?(Fe=s.timestamp?new Date(s.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}):void 0,t[64]=s.timestamp,t[65]=Fe):Fe=t[65];const Ne=Fe;let fe;t[66]!==s.timestamp?(fe=s.timestamp?new Date(s.timestamp).toISOString():void 0,t[66]=s.timestamp,t[67]=fe):fe=t[67];const Oe=fe;te=d||m&&i,ae=te||p,se=te||g,ie=te||v;const Ae=M.length>1?`${(K==null?void 0:K.length)??M.length} commands`:z.summary;let Be;t[68]!==c||t[69]!==Ae||t[70]!==s.name?(Be=s.name==="Skill"&&c?c.get(Ae)??null:null,t[68]=c,t[69]=Ae,t[70]=s.name,t[71]=Be):Be=t[71],le=Be,ue=le==null?void 0:le.filePath,Z=s.name==="Edit"&&typeof s.input.old_string=="string"&&typeof s.input.new_string=="string"&&typeof s.input.file_path=="string",X=Z?"diff":s.name==="Bash"||U?"command":"result",re=d||j;const oe=r8(s),ge=oe!==null&&((Le=s.result)==null?void 0:Le.trim())==="";let Ee;t[72]!==M.length||t[73]!==ge||t[74]!==m||t[75]!==b||t[76]!==s?(Ee=s.result!==null&&!ge&&M.length===0?r.jsx(t8,{toolCall:s,resultExpanded:b,onToggleExpanded:()=>w(!b),isMobile:m}):null,t[72]=M.length,t[73]=ge,t[74]=m,t[75]=b,t[76]=s,t[77]=Ee):Ee=t[77],ne=Ee;let $e;t[78]!==L?($e=()=>{L&&$(!0)},t[78]=L,t[79]=$e):$e=t[79];const He=$e;if(s.name==="AskUserQuestion"){const Ye=(f==null?void 0:f.type)==="question"&&f.toolUseId===s.id,Me=u==null?void 0:u.sessionId;let Ue;t[80]!==te||t[81]!==Ye||t[82]!==Me||t[83]!==s?(Ue=r.jsx(_7,{toolCall:s,expandToolPayloads:te,isAwaitingAnswer:Ye,sessionId:Me}),t[80]=te,t[81]=Ye,t[82]=Me,t[83]=s,t[84]=Ue):Ue=t[84],pe=Ue;break e}const Ke=L?"py-1":"py-1.5",nt=We.isError&&!L&&"rounded-md bg-destructive/5 px-2";t[85]!==Ke||t[86]!==nt?(he=q(Ke,nt),t[85]=Ke,t[86]=nt,t[87]=he):he=t[87],ce=L?r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",className:"h-auto w-full justify-start px-1 py-1 text-left",onClick:He,"aria-label":`Expand ${J} tool call`,title:Ne,children:[r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[r.jsx("span",{className:q("shrink-0 font-mono text-xs",Te),title:Q,children:J}),r.jsx(U0,{chips:Y,summary:Ae})]}),r.jsx(Je,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-end"}),r.jsx(B0,{toolCall:We,isAgentActive:l})]}):m?r.jsx("div",{className:"flex items-center gap-1.5",title:Ne,children:r.jsx(hp,{toolCall:We,isMobile:!0,isAgentActive:l,displayName:J,summary:Ae,sectionChips:Y,nameTitle:Q,nameClass:Te,timeLabel:Ne,timeIso:Oe})}):r.jsx("button",{type:"button",className:"flex w-full items-center gap-2 rounded-sm text-left hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",title:Ne,"aria-label":`Toggle ${J} details${Ae?`: ${Ae}`:""}`,"aria-expanded":re,"aria-controls":T,onClick:()=>{d||k(m8)},children:r.jsx(hp,{toolCall:We,isMobile:!1,isAgentActive:l,displayName:J,summary:Ae,sectionChips:Y,nameTitle:Q,nameClass:Te,timeLabel:Ne,timeIso:Oe})}),de=ge&&!L&&r.jsx(jc,{src:oe,alt:oe.slice(oe.lastIndexOf("/")+1),id:`tool-image:${s.id}`,className:"my-1.5",thumbnailClassName:"max-h-40"})}t[15]=M,t[16]=Y,t[17]=T,t[18]=j,t[19]=v,t[20]=J,t[21]=i,t[22]=d,t[23]=p,t[24]=l,t[25]=U,t[26]=L,t[27]=m,t[28]=Q,t[29]=f,t[30]=z.styleName,t[31]=z.summary,t[32]=b,t[33]=g,t[34]=K==null?void 0:K.length,t[35]=u==null?void 0:u.sessionId,t[36]=c,t[37]=s,t[38]=X,t[39]=Z,t[40]=te,t[41]=ne,t[42]=re,t[43]=ie,t[44]=ae,t[45]=se,t[46]=ue,t[47]=le,t[48]=de,t[49]=pe,t[50]=he,t[51]=ce}else X=t[38],Z=t[39],te=t[40],ne=t[41],re=t[42],ie=t[43],ae=t[44],se=t[45],ue=t[46],le=t[47],de=t[48],pe=t[49],he=t[50],ce=t[51];if(pe!==Symbol.for("react.early_return_sentinel"))return pe;let ye;t[88]!==L||t[89]!==s.id||t[90]!==s.resultImages?(ye=!L&&((ze=s.resultImages)==null?void 0:ze.map((Te,Ce)=>r.jsx(jc,{src:`data:${Te.source.media_type};base64,${Te.source.data}`,alt:`Tool result image ${Ce+1}`,id:`tool-result-image:${s.id}:${Ce}`,className:"my-1.5",thumbnailClassName:"max-h-40"},`${Te.source.media_type}-${Te.source.data.length}-${Te.source.data.slice(0,32)}-${Te.source.data.slice(-32)}`))),t[88]=L,t[89]=s.id,t[90]=s.resultImages,t[91]=ye):ye=t[91];let xe;t[92]!==L||t[93]!==ue||t[94]!==le?(xe=le&&!L&&r.jsxs("div",{className:"mt-1 flex items-center gap-2 font-mono text-xs text-muted-foreground",children:[r.jsxs("span",{children:["source: ",le.source]}),ue&&(!Bs()||_d())&&r.jsxs(ee,{type:"button",variant:"link",size:"xs",onClick:Te=>{Te.stopPropagation(),fr(ue)},className:"h-auto px-0 text-muted-foreground",title:ue,children:[r.jsx(Jh,{"data-icon":"inline-start"}),"Open SKILL.md"]})]}),t[92]=L,t[93]=ue,t[94]=le,t[95]=xe):xe=t[95];let me;t[96]!==v||t[97]!==Z||t[98]!==p||t[99]!==L||t[100]!==m||t[101]!==_||t[102]!==P||t[103]!==A||t[104]!==ne||t[105]!==g||t[106]!==ie||t[107]!==ae||t[108]!==se?(me=m&&!L&&r.jsxs("div",{className:"flex gap-3 mt-1",children:[Z&&r.jsx(El,{isOpen:ie,onClick:()=>S(!v),label:"Diff",controlsId:_}),r.jsx(El,{isOpen:ae,onClick:()=>h(!p),label:"Input",controlsId:P}),ne&&r.jsx(El,{isOpen:se,onClick:()=>x(!g),label:"Result",controlsId:A})]}),t[96]=v,t[97]=Z,t[98]=p,t[99]=L,t[100]=m,t[101]=_,t[102]=P,t[103]=A,t[104]=ne,t[105]=g,t[106]=ie,t[107]=ae,t[108]=se,t[109]=me):me=t[109];let je;t[110]!==Z||t[111]!==L||t[112]!==m||t[113]!==_||t[114]!==ie||t[115]!==s?(je=m&&!L&&Z&&r.jsx(ct,{open:ie,children:r.jsx(dt,{id:_,children:r.jsx(gp,{toolCall:s})})}),t[110]=Z,t[111]=L,t[112]=m,t[113]=_,t[114]=ie,t[115]=s,t[116]=je):je=t[116];let Se;t[117]!==M||t[118]!==l||t[119]!==U||t[120]!==L||t[121]!==m||t[122]!==P||t[123]!==te||t[124]!==(u==null?void 0:u.cwd)||t[125]!==ae||t[126]!==s.input?(Se=m&&!L&&r.jsx(ct,{open:ae,children:r.jsx(dt,{id:P,children:M.length>0?r.jsx(ap,{toolCalls:M,cwd:u==null?void 0:u.cwd,expandAll:te,isAgentActive:!!l}):U?r.jsx(rp,{input:s.input}):r.jsx(Cc,{result:JSON.stringify(s.input),expanded:!0})})}),t[117]=M,t[118]=l,t[119]=U,t[120]=L,t[121]=m,t[122]=P,t[123]=te,t[124]=u==null?void 0:u.cwd,t[125]=ae,t[126]=s.input,t[127]=Se):Se=t[127];let Pe;t[128]!==s.id||t[129]!==s.name||t[130]!==s.result?(Pe=(s.name==="Task"||s.name==="Agent")&&s.result===null&&r.jsx(Zd,{toolUseId:s.id}),t[128]=s.id,t[129]=s.name,t[130]=s.result,t[131]=Pe):Pe=t[131];let Re;t[132]!==L||t[133]!==m||t[134]!==A||t[135]!==ne||t[136]!==se?(Re=m&&!L&&ne&&r.jsx(ct,{open:se,children:r.jsx(dt,{id:A,children:ne})}),t[132]=L,t[133]=m,t[134]=A,t[135]=ne,t[136]=se,t[137]=Re):Re=t[137];let Ie;t[138]!==M||t[139]!==E||t[140]!==C||t[141]!==T||t[142]!==X||t[143]!==d||t[144]!==Z||t[145]!==l||t[146]!==m||t[147]!==ne||t[148]!==(u==null?void 0:u.cwd)||t[149]!==re||t[150]!==s?(Ie=!m&&r.jsx(ct,{open:re,children:r.jsxs(dt,{id:T,onClick:p8,children:[X==="diff"&&Z&&r.jsx(gp,{toolCall:s}),X==="command"&&(M.length>0?r.jsx(ap,{toolCalls:M,cwd:u==null?void 0:u.cwd,expandAll:d,isAgentActive:!!l}):r.jsx(rp,{input:s.input})),(X==="result"||X==="command")&&ne,r.jsx("button",{type:"button",className:"mt-1 text-[10px] text-muted-foreground/50 transition-colors hover:text-muted-foreground","aria-expanded":C,"aria-controls":E,onClick:Te=>{Te.stopPropagation(),N(h8)},children:"input"}),r.jsx(ct,{open:C,children:r.jsx(dt,{id:E,children:r.jsx(Cc,{result:JSON.stringify(M.length>1?M.map(g8):s.input),expanded:!0})})})]})}),t[138]=M,t[139]=E,t[140]=C,t[141]=T,t[142]=X,t[143]=d,t[144]=Z,t[145]=l,t[146]=m,t[147]=ne,t[148]=u==null?void 0:u.cwd,t[149]=re,t[150]=s,t[151]=Ie):Ie=t[151];let De;return t[152]!==de||t[153]!==ye||t[154]!==xe||t[155]!==me||t[156]!==je||t[157]!==Se||t[158]!==Pe||t[159]!==Re||t[160]!==Ie||t[161]!==he||t[162]!==ce?(De=r.jsxs("div",{className:he,children:[ce,de,ye,xe,me,je,Se,Pe,Re,Ie]}),t[152]=de,t[153]=ye,t[154]=xe,t[155]=me,t[156]=je,t[157]=Se,t[158]=Pe,t[159]=Re,t[160]=Ie,t[161]=he,t[162]=ce,t[163]=De):De=t[163],De});function a8(n){return n.result!==null}function l8(n){return n.isError}function c8(n){return n.result===null}function d8(n){return n.isError}function u8(n){return n.outputReplacedByHook}function f8(n,e){return n+(e.hookDurationMs??0)}function m8(n){return!n}function p8(n){return n.stopPropagation()}function h8(n){return!n}function g8(n){return n.input}const x8=y.memo(function({plan:e,planFilePath:t,status:s,toolCalls:o,expandAll:i=!1,expandToolPayloads:a=!1,isAgentActive:l,skillMetadata:c}){const[d,u]=y.useState(!0),f=o.some(S=>S.name==="AskUserQuestion"&&S.result===null),[m,p]=y.useState(null),h=y.useRef(f);y.useEffect(()=>{f&&(h.current=!0)},[f]);const g=i||d,x=i||(m??(f||h.current)),b=s==="approved"?Cr:s==="rejected"?Ys:Fs,w=g?tt:Je,v=x?tt:Je;return r.jsxs(ct,{open:g,onOpenChange:u,className:q("my-2 rounded-lg border",s==="approved"?"border-success/20 bg-success/5":s==="rejected"?"border-destructive/20 bg-destructive/5":"border-warning/20 bg-warning/5"),children:[r.jsxs(Mt,{render:r.jsx(ee,{type:"button",variant:"ghost",className:"h-auto w-full justify-start rounded-b-none p-2 text-left"}),children:[r.jsx(w,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),r.jsx(Wy,{className:"size-4 text-muted-foreground","data-icon":"inline-start"}),r.jsx("span",{className:"text-sm font-medium",children:"Plan Mode"}),r.jsx(b,{className:q("size-4",s==="approved"?"text-success":s==="rejected"?"text-destructive":"text-warning")}),r.jsx("span",{className:"text-xs text-muted-foreground capitalize",children:s}),t&&r.jsx("span",{className:"ml-auto truncate font-mono text-xs text-muted-foreground",children:t})]}),r.jsx(dt,{children:r.jsxs("div",{className:"px-3 pb-2",children:[r.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none border-t pt-2",children:r.jsx(Un,{remarkPlugins:[ha],components:qn,children:e})}),o.length>0&&r.jsxs(ct,{open:x,onOpenChange:p,className:"mt-2",children:[r.jsxs(Mt,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"-ml-2 text-muted-foreground"}),children:[r.jsx(v,{"data-icon":"inline-start"}),o.length," call",o.length===1?"":"s"," during planning"]}),r.jsx(dt,{children:r.jsx("div",{className:"ml-4 mt-1 flex flex-col gap-1",children:o.map(S=>r.jsx(W0,{toolCall:S,expandAll:i,expandToolPayloads:a,isAgentActive:l,skillMetadata:c},S.id))})})]})]})})]})}),b8=y.memo(function(e){const t=B.c(14),{content:s}=e,[o,i]=y.useState(!0),a=o?tt:Je;let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(ee,{type:"button",variant:"ghost",className:"h-auto w-full justify-start rounded-b-none p-2 text-left"}),t[0]=l):l=t[0];let c;t[1]!==a?(c=r.jsx(a,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),t[1]=a,t[2]=c):c=t[2];let d,u;t[3]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Hy,{className:"size-4 text-muted-foreground","data-icon":"inline-start"}),u=r.jsx("span",{className:"text-sm font-medium",children:"Session recap"}),t[3]=d,t[4]=u):(d=t[3],u=t[4]);let f;t[5]!==c?(f=r.jsxs(Mt,{render:l,children:[c,d,u]}),t[5]=c,t[6]=f):f=t[6];let m;t[7]===Symbol.for("react.memo_cache_sentinel")?(m=[ha],t[7]=m):m=t[7];let p;t[8]!==s?(p=r.jsx(dt,{children:r.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none border-t px-3 pb-2 pt-2",children:r.jsx(Un,{remarkPlugins:m,components:qn,children:s})})}),t[8]=s,t[9]=p):p=t[9];let h;return t[10]!==o||t[11]!==f||t[12]!==p?(h=r.jsxs(ct,{open:o,onOpenChange:i,className:"my-2 rounded-lg border bg-card",children:[f,p]}),t[10]=o,t[11]=f,t[12]=p,t[13]=h):h=t[13],h}),Pl=1;function xp(n,e){return!e||n.length<=Pl?{visible:[...n],hidden:0}:{visible:n.slice(-Pl),hidden:n.length-Pl}}function v8(n){return`${n} earlier step${n===1?"":"s"}`}const y8=y.memo(function(e){const t=B.c(15),{blocks:s,expandAll:o}=e,[i,a]=y.useState(!1),l=o||i;if(s.length===0)return null;let c;t[0]!==o?(c=p=>{o||a(p)},t[0]=o,t[1]=c):c=t[1];let d;t[2]!==s.length||t[3]!==o||t[4]!==l?(d=!o&&r.jsxs(Mt,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"-ml-2 text-muted-foreground"}),children:[l?r.jsx(tt,{"data-icon":"inline-start"}):r.jsx(Je,{"data-icon":"inline-start"}),r.jsxs("span",{children:["Thinking... (",s.length," block",s.length>1?"s":"",")"]})]}),t[2]=s.length,t[3]=o,t[4]=l,t[5]=d):d=t[5];let u;t[6]!==s?(u=s.map(w8),t[6]=s,t[7]=u):u=t[7];let f;t[8]!==u?(f=r.jsx(dt,{className:"mt-1 flex flex-col gap-2",children:u}),t[8]=u,t[9]=f):f=t[9];let m;return t[10]!==l||t[11]!==c||t[12]!==d||t[13]!==f?(m=r.jsxs(ct,{open:l,onOpenChange:c,children:[d,f]}),t[10]=l,t[11]=c,t[12]=d,t[13]=f,t[14]=m):m=t[14],m});function w8(n,e){return r.jsx("pre",{className:"text-xs text-muted-foreground/70 font-mono whitespace-pre-wrap break-words max-h-96 overflow-y-auto",children:n.thinking},e)}function vr(n,e){if(!n&&!e)return{add:0,del:0};const t=n?n.split(`
112
- `):[],s=e?e.split(`
113
- `):[];if(t.length===0)return{add:s.length,del:0};if(s.length===0)return{add:0,del:t.length};const o=t.length,i=s.length;let a=0;for(;a<o&&a<i&&t[a]===s[a];)a++;let l=0;for(;l<o-a&&l<i-a&&t[o-1-l]===s[i-1-l];)l++;const c=o-a-l,d=i-a-l;if(c===0)return{add:d,del:0};if(d===0)return{add:0,del:c};let u=new Array(d+1).fill(0),f=new Array(d+1).fill(0);for(let p=1;p<=c;p++){f[0]=0;const h=t[a+p-1];for(let g=1;g<=d;g++)h===s[a+g-1]?f[g]=u[g-1]+1:f[g]=u[g]>f[g-1]?u[g]:f[g-1];[u,f]=[f,u]}const m=u[d];return{add:d-m,del:c-m}}function j8(n){let e=[];for(const a of n){if(a.isWrite){e=[{original:a.newString,current:a.newString}];continue}if(!a.oldString){e.push({original:a.oldString,current:a.newString});continue}let l=!1;for(const c of e){const d=c.current.indexOf(a.oldString);if(d!==-1){c.current=c.current.slice(0,d)+a.newString+c.current.slice(d+a.oldString.length),l=!0;break}}l||e.some(d=>d.original.includes(a.oldString)&&!d.current.includes(a.oldString))||e.push({original:a.oldString,current:a.newString})}const t=e.filter(a=>a.original!==a.current);if(t.length===0){if(n.some(l=>l.isWrite)&&e.length>0){const l=e.map(c=>c.current).join(`
114
- `);if(l){const c=vr("",l);return{originalStr:"",currentStr:l,addCount:c.add,delCount:c.del}}}return{originalStr:"",currentStr:"",addCount:0,delCount:0}}const s=t.map(a=>a.original).join(`
115
- `),o=t.map(a=>a.current).join(`
116
- `),i=vr(s,o);return{originalStr:s,currentStr:o,addCount:i.add,delCount:i.del}}const S8=new Set(["echo","printf","true","false",":"]),N8=new Set(["find","grep","rg","ag","ack","locate","which","whereis"]),k8=new Set(["cat","head","tail","less","more","wc","stat","file","strings","jq","awk","cut","sort","uniq","tr"]),C8=new Set(["ls","tree","du"]);function _8(n){return n.split(/\|\||&&|[|;\n]/).map(e=>e.trim()).filter(Boolean)}function T8(n){const e=_8(n);let t=!1,s=!1,o=!1,i=!1;for(const a of e){const l=a.split(/\s+/)[0];if(!(!l||S8.has(l)))if(i=!0,N8.has(l))t=!0;else if(k8.has(l))s=!0;else if(C8.has(l))o=!0;else return"shell"}return i?o?"list":t?"search":s?"read":"shell":"shell"}const E8=/[\\/]claude(?:-\d+)?[\\/](?:[^\\/]+[\\/])+scratchpad[\\/]/i;function P8(n){return E8.test(n)}const A8=new Set(["Grep","Glob"]),R8=new Set(["Bash","PowerShell"]),I8=new Set(["Edit","Write","NotebookEdit","MultiEdit"]),$8=new Set(["Task","Agent"]);function bp(n){const e=n.file_path??n.path;return typeof e=="string"?e:null}function M8(n){return typeof n.command=="string"?n.command:null}function O8(n){if(!n.startsWith("mcp__"))return null;const e=n.split("__")[1];return e?e.replace(/^claude[._]ai[._]/i,"").replace(/_/g," "):null}function D8(n,e){if(Array.isArray(e.edits)){let i=0,a=0;for(const l of e.edits){if(!l||typeof l!="object")continue;const{old_string:c,new_string:d}=l,u=vr(typeof c=="string"?c:"",typeof d=="string"?d:"");i+=u.add,a+=u.del}return{added:i,removed:a}}const t=n==="Edit"&&typeof e.old_string=="string"?e.old_string:"",s=typeof e.new_string=="string"?e.new_string:typeof e.content=="string"?e.content:typeof e.new_source=="string"?e.new_source:"",o=vr(t,s);return{added:o.add,removed:o.del}}function ro(n,e,t=`${e}s`){return`${n} ${n===1?e:t}`}function L8(n){const e=Math.max(1,Math.floor(n/1e3));if(e<60)return`${e}s`;const t=Math.floor(e/60),s=e%60;if(t<60)return s>0?`${t}m ${s}s`:`${t}m`;const o=Math.floor(t/60),i=t%60;return i>0?`${o}h ${i}m`:`${o}h`}function z8(n,e={}){const t=new Set,s=new Set,o=new Set;let i=0,a=0,l=0,c=0,d=0,u=0,f=0,m=0,p=0,h=0,g=0,x=0;for(const j of n){const k=O8(j.name);if(k){p+=1,o.add(k);continue}if(I8.has(j.name)){const C=bp(j.input),N=D8(j.name,j.input);C&&P8(C)?(l+=1,c+=N.added,d+=N.removed):(t.add(C??j.id),i+=N.added,a+=N.removed);continue}if(j.name==="Read"){const C=bp(j.input);C?s.add(C):f+=1;continue}if(A8.has(j.name)){u+=1;continue}if(R8.has(j.name)){const C=M8(j.input);switch(C===null?"shell":T8(C)){case"search":u+=1;break;case"list":m+=1;break;case"read":f+=1;break;default:x+=1}continue}if($8.has(j.name)){h+=1;continue}g+=1}const b=s.size>0?s.size:f,w=[],v=(j,k,C=0,N=0)=>{w.push(C>0||N>0?{key:j,text:k,added:C,removed:N}:{key:j,text:k})},S=e.thoughtForMs??0;if(S>0&&v("thought",`thought for ${L8(S)}`),t.size>0&&v("edit",`edited ${ro(t.size,"file")}`,i,a),l>0&&v("scratchpad",`made ${l} scratchpad ${l===1?"edit":"edits"}`,c,d),u>0&&v("search",`searched for ${ro(u,"pattern")}`),b>0&&v("read",`read ${ro(b,"file")}`),m>0&&v("list",`listed ${ro(m,"directory","directories")}`),p>0){const j=[...o].join(", ")||"MCP";v("mcp",p>1?`called ${j} ${p} times`:`called ${j}`)}return h>0&&v("agent",`ran ${ro(h,"agent")}`),g>0&&v("other",`called ${ro(g,"tool")}`),x>0&&v("bash",`ran ${x} shell ${x===1?"command":"commands"}`),{clauses:w}}const vp="text-muted-foreground";function yp(n){const e=B.c(4),{summary:t}=n;let s;e[0]!==t.clauses?(s=t.clauses.map(F8),e[0]=t.clauses,e[1]=s):s=e[1];let o;return e[2]!==s?(o=r.jsx("span",{className:"text-xs text-muted-foreground",children:s}),e[2]=s,e[3]=o):o=e[3],o}function F8(n,e){return r.jsxs("span",{children:[e>0&&", ",e===0?n.text[0].toUpperCase()+n.text.slice(1):n.text,n.added?r.jsxs("span",{className:"text-success",children:[" +",n.added]}):null,n.removed?r.jsxs("span",{className:"text-destructive",children:[" -",n.removed]}):null]},n.key)}const wp=y.memo(function(e){const t=B.c(35),{toolCalls:s,expandAll:o,expandToolPayloads:i,activeToolCallId:a,isAgentActive:l,activityItems:c,thinkingCount:d,thoughtForMs:u,skillMetadata:f}=e,m=l===void 0?!1:l,p=d===void 0?0:d,h=u===void 0?0:u,[g,x]=y.useState(null),b=y.useRef(null),w=m&&s.some(B8);let v;t[0]!==s?(v=s.some(U8),t[0]=s,t[1]=v):v=t[1];const S=v,j=o||S||(g??w),k=g===null&&w&&!o&&!S,C=y.useRef(null),N=y.useRef(null);let _,P;t[2]!==a||t[3]!==s?(_=()=>{if(!a){C.current=null;return}a!==C.current&&s.some(K=>K.id===a)&&(C.current=a,x(!0),N.current=requestAnimationFrame(()=>{N.current=requestAnimationFrame(()=>{var K;N.current=null,(K=b.current)==null||K.scrollIntoView({behavior:"smooth",block:"nearest"})})}))},P=[a,s],t[2]=a,t[3]=s,t[4]=_,t[5]=P):(_=t[4],P=t[5]),y.useEffect(_,P);let A,T;t[6]===Symbol.for("react.memo_cache_sentinel")?(A=()=>()=>{N.current!==null&&cancelAnimationFrame(N.current)},T=[],t[6]=A,t[7]=T):(A=t[6],T=t[7]),y.useEffect(A,T);let E;if(t[8]!==s){const K=new Map;for(const V of s){const{label:Y,styleName:G}=La(V),J=K.get(Y);J?(J.count=J.count+1,J.hasError=J.hasError||!!V.isError):K.set(Y,{count:1,styleName:G,hasError:!!V.isError})}E=[...K].sort(W8),t[8]=s,t[9]=E}else E=t[9];const R=E;let $;t[10]!==h||t[11]!==s?($=z8(s,{thoughtForMs:h}),t[10]=h,t[11]=s,t[12]=$):$=t[12];const I=$,M=function(V,Y,G){const J=G??[V],Q=m&&Y&&J.some(H8),X=a!==null&&J.some(Z=>Z.id===a);return r.jsx("div",{ref:X?b:void 0,className:q(X&&"rounded-md ring-1 ring-ring"),children:r.jsx(W0,{toolCall:V,groupedBashCalls:G,expandAll:o,expandToolPayloads:i,isAgentActive:Q,skillMetadata:f})},V.id)},D=function(V,Y){const G=[];let J=0;for(;J<V.length;){const Q=V[J];if(Q.name!=="Bash"){G.push(M(Q,Y&&J===V.length-1)),J++;continue}let X=J+1;for(;X<V.length&&V[X].name==="Bash";)X++;const Z=V.slice(J,X);G.push(M(Q,Y&&X===V.length,Z.length>1?Z:void 0)),J=X}return G};if(s.length===1&&p===0&&!c)return r.jsx("div",{className:"flex flex-col gap-2",children:D(s,!0)});if(j){let K;t[13]!==o||t[14]!==S||t[15]!==I||t[16]!==p?(K=!o&&!S&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>x(!1),className:"-ml-2 text-muted-foreground",children:[r.jsx(tt,{"data-icon":"inline-start"}),I.clauses.length>0?r.jsx(yp,{summary:I}):r.jsxs("span",{className:q("font-mono text-xs",vp),children:["Thinking",p>1?` ×${p}`:""]})]}),t[13]=o,t[14]=S,t[15]=I,t[16]=p,t[17]=K):K=t[17];const V=c?(()=>{const G=xp(c,k);return r.jsxs(r.Fragment,{children:[G.hidden>0&&r.jsx(jp,{count:G.hidden,onReveal:()=>x(!0)}),(()=>{const J=[];let Q=0;for(;Q<G.visible.length;){const X=G.visible[Q];if(X.kind==="thinking"){J.push(r.jsx(y8,{blocks:X.blocks,expandAll:!1},`thinking-${Q}`)),Q++;continue}const Z=[...X.toolCalls];let te=Q+1;for(;te<G.visible.length&&G.visible[te].kind==="tool_calls";){const ne=G.visible[te];ne.kind==="tool_calls"&&Z.push(...ne.toolCalls),te++}J.push(...D(Z,te===G.visible.length)),Q=te}return J})()]})})():(()=>{const G=xp(s,k);return r.jsxs(r.Fragment,{children:[G.hidden>0&&r.jsx(jp,{count:G.hidden,onReveal:()=>x(!0)}),D(G.visible,!0)]})})();let Y;return t[18]!==K||t[19]!==V?(Y=r.jsxs("div",{className:"motion-enter flex flex-col gap-2",children:[K,V]}),t[18]=K,t[19]=V,t[20]=Y):Y=t[20],Y}let O;t[21]===Symbol.for("react.memo_cache_sentinel")?(O=()=>x(!0),t[21]=O):O=t[21];let L;t[22]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(Je,{className:"mt-0.5 size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),t[22]=L):L=t[22];let F;t[23]!==I?(F=I.clauses.length>0&&r.jsx(yp,{summary:I}),t[23]=I,t[24]=F):F=t[24];let z;t[25]!==p?(z=p>0&&r.jsxs("span",{className:q("font-mono text-xs",vp),children:["Thinking",p>1?` ×${p}`:""]}),t[25]=p,t[26]=z):z=t[26];let W;t[27]!==R?(W=R.map(K8),t[27]=R,t[28]=W):W=t[28];let U;t[29]!==z||t[30]!==W?(U=r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[z,W]}),t[29]=z,t[30]=W,t[31]=U):U=t[31];let H;return t[32]!==F||t[33]!==U?(H=r.jsxs(ee,{type:"button",variant:"ghost",onClick:O,className:"motion-enter h-auto w-full items-start justify-start gap-2 px-0 py-1 text-left whitespace-normal",children:[L,r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[F,U]})]}),t[32]=F,t[33]=U,t[34]=H):H=t[34],H});function jp(n){const e=B.c(6),{count:t,onReveal:s}=n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(tt,{"data-icon":"inline-start"}),e[0]=o):o=e[0];let i;e[1]!==t?(i=v8(t),e[1]=t,e[2]=i):i=e[2];let a;return e[3]!==s||e[4]!==i?(a=r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:s,className:"-ml-2 text-muted-foreground",children:[o,i]}),e[3]=s,e[4]=i,e[5]=a):a=e[5],a}function B8(n){return n.result===null}function U8(n){return n.name==="AskUserQuestion"}function W8(n,e){return e[1].count-n[1].count}function H8(n){return n.result===null}function K8(n){const[e,t]=n,{count:s,styleName:o,hasError:i}=t;return r.jsxs("span",{className:q("font-mono text-xs",F0(o,i)),children:[e,s>1?` ×${s}`:""]},e)}function q8(n){const e=B.c(15),{label:t,expanded:s,onToggle:o,compact:i}=n,l=(i===void 0?!1:i)&&"min-h-9";let c;e[0]!==l?(c=q("group/fold h-auto min-h-8 w-full cursor-pointer justify-start gap-1.5 px-1 text-left text-xs font-normal text-muted-foreground",l),e[0]=l,e[1]=c):c=e[1];const d=s&&"rotate-90";let u;e[2]!==d?(u=q("size-3 shrink-0 transition-transform duration-150 motion-reduce:transition-none",d),e[2]=d,e[3]=u):u=e[3];let f;e[4]!==u?(f=r.jsx(Je,{"data-icon":"inline-start",className:u}),e[4]=u,e[5]=f):f=e[5];let m;e[6]!==t?(m=r.jsx("span",{className:"tabular-nums",children:t}),e[6]=t,e[7]=m):m=e[7];let p;e[8]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx("span",{"aria-hidden":!0,className:"pointer-events-none ml-1 h-px flex-1 bg-border/40 transition-colors group-hover/fold:bg-border/70"}),e[8]=p):p=e[8];let h;return e[9]!==s||e[10]!==o||e[11]!==c||e[12]!==f||e[13]!==m?(h=r.jsxs(ee,{type:"button",variant:"ghost",onClick:o,"aria-expanded":s,className:c,children:[f,m,p]}),e[9]=s,e[10]=o,e[11]=c,e[12]=f,e[13]=m,e[14]=h):h=e[14],h}const H0="synthesizedFrom",Sp=/[.*+?[\]{}()^$|]/,V8=/[$*?`~]|\\\s/,K0=/<<(-?)\s*(?:'([^']+)'|"([^"]+)")/,G8=new RegExp(K0,"g");function ou(n,e,t,s){return{id:e,name:t,input:{...s,[H0]:n.name},result:null,isError:!1,timestamp:n.timestamp}}function Y8(n){return typeof n.input[H0]=="string"}function X8(n){const e=n[0];return(e==='"'||e==="'")&&n.at(-1)===e?n.slice(1,-1):n}function Np(n){const e=[];for(const t of n.split("/"))!t||t==="."||(t===".."?e.pop():e.push(t));return`/${e.join("/")}`}function za(n,e){const t=X8(n.trim());return!t||V8.test(t)?null:t.startsWith("/")?Np(t):e?Np(`${e}/${t}`):null}function J8(n){const e=[];let t="",s=null;function o(i){t.trim()&&e.push({text:t.trim(),piped:i}),t=""}for(let i=0;i<n.length;i++){const a=n[i];if(s){t+=a,a===s&&(s=null);continue}if(a==='"'||a==="'"){s=a,t+=a;continue}if(a==="|"){o(!0),n[i+1]==="|"&&i++;continue}if(a===";"||a==="&"&&n[i+1]==="&"){o(!1),a==="&"&&i++;continue}t+=a}return o(!1),e}function Q8(n){const e=n.split(`
117
- `),t=[];let s=0;for(;s<e.length;){const o=e[s];s++;const i=new Map;for(const a of o.matchAll(G8)){const[,l,c,d]=a,u=c??d,f=[];for(;s<e.length&&e[s].trim()!==u;)f.push(l?e[s].replace(/^\t+/,""):e[s]),s++;s>=e.length||(s++,i.set(u,f.join(`
118
- `)))}for(const a of J8(o))t.push({text:a.text,bodies:i,piped:a.piped})}return t}function Z8(n,e){const t=n.match(/^cd\s+(?:"([^"]*)"|'([^']*)'|([^\s;&|]+))\s*$/);return t?za(t[1]??t[2]??t[3]??"",e):null}function eE(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 tE(n,e){if(n.piped||n.bodies.size===0)return null;const t=n.text.match(K0);if(!t)return null;const s=n.bodies.get(t[2]??t[3]??"");if(s===void 0)return null;const o=eE(n.text);if(!o)return null;const i=za(o,e);return i?{name:"Write",input:{file_path:i,content:s}}:null}function kp(n,e){const t=e==="replacement";let s="";for(let o=0;o<n.length;o++){const i=n[o];if(i==="\\"){const a=n[o+1];if(a===void 0||a==="|"||!Sp.test(a)&&!"\\/&#".includes(a))return null;s+=a,o++;continue}if(i==="&"&&t||!t&&Sp.test(i))return null;s+=i}return s}const nE=/^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 sE(n,e){var m;const t=(m=n.text.match(nE))==null?void 0:m.groups;if(!t)return null;const{pattern:s,replacement:o,flags:i,dquoted:a,squoted:l,bare:c}=t;if(/[^g]/.test(i))return null;const d=kp(s,"pattern"),u=kp(o,"replacement");if(!d||u===null)return null;const f=za(a??l??c??"",e);return f?{name:"Edit",input:{file_path:f,old_string:d,new_string:u,replace_all:i.includes("g")}}:null}function q0(n,e=null){const t=n.input.command;if(typeof t!="string"||!t)return[];const s=[];let o=e;for(const i of Q8(t)){const a=Z8(i.text,o);if(a){o=a;continue}const l=tE(i,o)??sE(i,o);l&&s.push(ou(n,`${n.id}:bash-${s.length}`,l.name,l.input))}return s}function V0(n,e){const t=n.input.edits,s=n.input.file_path??n.input.path;if(!Array.isArray(t)||typeof s!="string")return[];const o=za(s,e)??s,i=[];for(const[a,l]of t.entries()){if(typeof l!="object"||l===null)continue;const{old_string:c,new_string:d,replace_all:u}=l;typeof c!="string"||typeof d!="string"||i.push(ou(n,`${n.id}:edit-${a}`,"Edit",{file_path:o,old_string:c,new_string:d,replace_all:u===!0}))}return i}function G0(n,e){const t=[n.input.patch,n.input.value,n.input.input].find(s=>typeof s=="string");return t?fx("apply_patch",t,n.id,n.timestamp,e??"").map(s=>ou(n,s.id,s.name,s.input)):[]}function nr(n,e=null){const t=[];for(const s of n)s.isError||(s.name==="Edit"||s.name==="Write"?t.push(s):s.name==="MultiEdit"?t.push(...V0(s,e)):s.name==="Bash"?t.push(...q0(s,e)):s.name==="apply_patch"&&t.push(...G0(s,e)));return t}function Xi(n,e=null){for(const t of n)if(!t.isError&&(t.name==="Edit"||t.name==="Write"||t.name==="MultiEdit"&&V0(t,e).length>0||t.name==="Bash"&&q0(t,e).length>0||t.name==="apply_patch"&&G0(t,e).length>0))return!0;return!1}const oE=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"]),rE={json:Rf,jsonc:Rf,md:Ei,mdx:Ei,txt:Ei,png:Is,jpg:Is,jpeg:Is,gif:Is,webp:Is,svg:Is,ico:Is,sh:li,bash:li,zsh:li,fish:li};function Y0(n){const e=n.split("/").at(-1)??n,t=e.lastIndexOf(".");return t===-1?"":e.slice(t+1).toLowerCase()}function iE(n){const e=Y0(n);return rE[e]??(oE.has(e)?Tr:Gh)}function _c(n){const e=B.c(11),{add:t,del:s,dimmed:o,className:i}=n,a=o&&"opacity-40";let l;e[0]!==i||e[1]!==a?(l=q("flex shrink-0 items-center gap-1 font-mono text-xs tabular-nums",a,i),e[0]=i,e[1]=a,e[2]=l):l=e[2];let c;e[3]!==t?(c=t>0&&r.jsxs("span",{className:"text-success",children:["+",t]}),e[3]=t,e[4]=c):c=e[4];let d;e[5]!==s?(d=s>0&&r.jsxs("span",{className:"text-destructive",children:["-",s]}),e[5]=s,e[6]=d):d=e[6];let u;return e[7]!==l||e[8]!==c||e[9]!==d?(u=r.jsxs("span",{className:l,children:[c,d]}),e[7]=l,e[8]=c,e[9]=d,e[10]=u):u=e[10],u}const Cp=5;function ru(n){const e=B.c(11),{add:t,del:s}=n,o=t+s;if(o===0)return null;let i,a,l;if(e[0]!==t||e[1]!==o){const u=Math.round(t/o*Cp);i=Cp-u,a="flex items-center gap-[1px] shrink-0 ml-1",l=Array.from({length:u},lE),e[0]=t,e[1]=o,e[2]=i,e[3]=a,e[4]=l}else i=e[2],a=e[3],l=e[4];let c;e[5]!==i?(c=Array.from({length:i},aE),e[5]=i,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==l||e[9]!==c?(d=r.jsxs("span",{className:a,children:[l,c]}),e[7]=a,e[8]=l,e[9]=c,e[10]=d):d=e[10],d}function aE(n,e){return r.jsx("span",{className:"inline-block size-1.5 rounded-xs bg-destructive/70"},`d${e}`)}function lE(n,e){return r.jsx("span",{className:"inline-block size-1.5 rounded-xs bg-success/70"},`a${e}`)}const Ji="cogpit:open-subagent";function X0(n){const e=B.c(3),{hasEdit:t,hasWrite:s}=n;if(t&&s){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("span",{className:"shrink-0 text-xs font-bold text-warning",children:"E+W"}),e[0]=i):i=e[0],i}if(s){let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("span",{className:"shrink-0 text-xs font-bold text-success",children:"W"}),e[1]=i):i=e[1],i}let o;return e[2]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx("span",{className:"shrink-0 text-xs font-bold text-warning",children:"E"}),e[2]=o):o=e[2],o}function iu(n){const e=B.c(2),{agentId:t}=n;let s;return e[0]!==t?(s=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",className:"size-5 shrink-0 font-mono text-xs font-bold text-muted-foreground","aria-label":"Open sub-agent view",title:"Open sub-agent view",onClick:o=>{o.stopPropagation(),window.dispatchEvent(new CustomEvent(Ji,{detail:{agentId:t}}))},children:"S"}),e[0]=t,e[1]=s):s=e[1],s}const J0=y.memo(function(e){const t=B.c(96),{file:s,defaultOpen:o,isHighlighted:i,diffMode:a}=e,{ref:l,isNear:c}=i0(),[d,u]=y.useState(o),[f,m]=y.useState(o),p=y.useRef(o);let h;t[0]===Symbol.for("react.memo_cache_sentinel")?(h=Se=>{u(Se),Se?y.startTransition(()=>m(!0)):m(!1)},t[0]=h):h=t[0];const g=h;let x,b;t[1]!==o?(x=()=>{p.current!==o&&(p.current=o,g(o))},b=[o,g],t[1]=o,t[2]=x,t[3]=b):(x=t[2],b=t[3]),y.useEffect(x,b);let w,v;t[4]!==i?(w=()=>{i&&g(!0)},v=[i,g],t[4]=i,t[5]=w,t[6]=v):(w=t[5],v=t[6]),y.useEffect(w,v);let S;t[7]!==s.filePath?(S=Y0(s.filePath),t[7]=s.filePath,t[8]=S):S=t[8];const j=S,k=s.netOriginal,C=s.netCurrent,N=!!(k||C);let _;t[9]!==s.edits?(_=s.edits.some(fE),t[9]=s.edits,t[10]=_):_=t[10];const A=a==="per-edit"?_:N,T=f&&c&&A,[E,R]=y.useState(0);let $;t[11]===Symbol.for("react.memo_cache_sentinel")?($=Se=>{if(!Se)return;const Pe=Se.offsetHeight;R(Re=>Re===Pe?Re:Pe)},t[11]=$):$=t[11];const I=$,M=s.turnRange[0]===s.turnRange[1]?`T${s.turnRange[0]+1}`:`T${s.turnRange[0]+1}–T${s.turnRange[1]+1}`,D=s.filePath,O=i?"border-ring ring-2 ring-ring/20":"border-border";let L;t[12]!==O?(L=q("rounded-lg border bg-card transition-colors",O),t[12]=O,t[13]=L):L=t[13];let F;t[14]!==d?(F=()=>g(!d),t[14]=d,t[15]=F):F=t[15];let z;t[16]!==d?(z=d?r.jsx(tt,{"data-icon":"inline-start",className:"size-3 shrink-0 text-muted-foreground"}):r.jsx(Je,{"data-icon":"inline-start",className:"size-3 shrink-0 text-muted-foreground"}),t[16]=d,t[17]=z):z=t[17];let W;t[18]!==j?(W=r.jsx("span",{className:"shrink-0 font-mono text-xs font-bold text-muted-foreground",children:j}),t[18]=j,t[19]=W):W=t[19];let U;t[20]!==s.opTypes?(U=s.opTypes.includes("Edit"),t[20]=s.opTypes,t[21]=U):U=t[21];let H;t[22]!==s.opTypes?(H=s.opTypes.includes("Write"),t[22]=s.opTypes,t[23]=H):H=t[23];let K;t[24]!==U||t[25]!==H?(K=r.jsx(X0,{hasEdit:U,hasWrite:H}),t[24]=U,t[25]=H,t[26]=K):K=t[26];let V;t[27]!==s.shortPath?(V=r.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",children:s.shortPath}),t[27]=s.shortPath,t[28]=V):V=t[28];let Y;t[29]!==M?(Y=r.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:M}),t[29]=M,t[30]=Y):Y=t[30];let G;t[31]!==s.editCount?(G=s.editCount>1&&r.jsxs(_e,{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]=G):G=t[32];let J;t[33]!==d||t[34]!==F||t[35]!==z||t[36]!==W||t[37]!==K||t[38]!==V||t[39]!==Y||t[40]!==G?(J=r.jsxs(ee,{type:"button",variant:"ghost",onClick:F,className:"h-auto min-w-0 flex-1 justify-start gap-1.5 rounded-r-none px-2 py-1 font-normal","aria-expanded":d,children:[z,W,K,V,Y,G]}),t[33]=d,t[34]=F,t[35]=z,t[36]=W,t[37]=K,t[38]=V,t[39]=Y,t[40]=G,t[41]=J):J=t[41];let Q;t[42]!==s.subAgentId?(Q=s.subAgentId&&r.jsx(iu,{agentId:s.subAgentId}),t[42]=s.subAgentId,t[43]=Q):Q=t[43];let X;t[44]!==s.filePath?(X=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>fr(s.filePath),"aria-label":"Open file in editor"}),t[44]=s.filePath,t[45]=X):X=t[45];let Z;t[46]===Symbol.for("react.memo_cache_sentinel")?(Z=r.jsx(Nr,{"data-icon":"inline-start"}),t[46]=Z):Z=t[46];let te;t[47]!==X?(te=r.jsx(Rt,{render:X,children:Z}),t[47]=X,t[48]=te):te=t[48];let ne;t[49]===Symbol.for("react.memo_cache_sentinel")?(ne=r.jsx(It,{children:"Open in editor"}),t[49]=ne):ne=t[49];let re;t[50]!==te?(re=r.jsxs(At,{children:[te,ne]}),t[50]=te,t[51]=re):re=t[51];let ie;t[52]!==s.filePath?(ie=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>fr(s.filePath,{mode:"diff"}),"aria-label":"View git diff"}),t[52]=s.filePath,t[53]=ie):ie=t[53];let ae;t[54]===Symbol.for("react.memo_cache_sentinel")?(ae=r.jsx(Ky,{"data-icon":"inline-start"}),t[54]=ae):ae=t[54];let se;t[55]!==ie?(se=r.jsx(Rt,{render:ie,children:ae}),t[55]=ie,t[56]=se):se=t[56];let ue;t[57]===Symbol.for("react.memo_cache_sentinel")?(ue=r.jsx(It,{children:"View git diff"}),t[57]=ue):ue=t[57];let le;t[58]!==se?(le=r.jsxs(At,{children:[se,ue]}),t[58]=se,t[59]=le):le=t[59];let de;t[60]!==re||t[61]!==le?(de=r.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[re,le]}),t[60]=re,t[61]=le,t[62]=de):de=t[62];let pe;t[63]!==s.addCount?(pe=s.addCount>0&&r.jsxs("span",{className:"font-mono text-xs tabular-nums text-success",children:["+",s.addCount]}),t[63]=s.addCount,t[64]=pe):pe=t[64];let he;t[65]!==s.delCount?(he=s.delCount>0&&r.jsxs("span",{className:"font-mono text-xs tabular-nums text-destructive",children:["-",s.delCount]}),t[65]=s.delCount,t[66]=he):he=t[66];let ce;t[67]!==s.addCount||t[68]!==s.delCount?(ce=r.jsx(ru,{add:s.addCount,del:s.delCount}),t[67]=s.addCount,t[68]=s.delCount,t[69]=ce):ce=t[69];let ye;t[70]!==Q||t[71]!==de||t[72]!==pe||t[73]!==he||t[74]!==ce?(ye=r.jsxs("div",{className:"flex items-center gap-1.5 pr-2 shrink-0",children:[Q,de,pe,he,ce]}),t[70]=Q,t[71]=de,t[72]=pe,t[73]=he,t[74]=ce,t[75]=ye):ye=t[75];let xe;t[76]!==J||t[77]!==ye?(xe=r.jsxs("div",{className:"group sticky top-0 z-10 flex w-full items-center rounded-t-lg bg-card transition-colors hover:bg-accent",children:[J,ye]}),t[76]=J,t[77]=ye,t[78]=xe):xe=t[78];let me;t[79]!==a||t[80]!==s.edits||t[81]!==s.filePath||t[82]!==s.netStartLine||t[83]!==A||t[84]!==E||t[85]!==C||t[86]!==k||t[87]!==d||t[88]!==T?(me=r.jsx(cE,{showDiff:T,open:d,hasDiff:A,diffRef:I,lastDiffHeight:E,oldString:k,newString:C,filePath:s.filePath,diffMode:a,edits:s.edits,netStartLine:s.netStartLine}),t[79]=a,t[80]=s.edits,t[81]=s.filePath,t[82]=s.netStartLine,t[83]=A,t[84]=E,t[85]=C,t[86]=k,t[87]=d,t[88]=T,t[89]=me):me=t[89];let je;return t[90]!==s.filePath||t[91]!==l||t[92]!==L||t[93]!==xe||t[94]!==me?(je=r.jsxs("div",{ref:l,"data-file-path":D,className:L,children:[xe,me]}),t[90]=s.filePath,t[91]=l,t[92]=L,t[93]=xe,t[94]=me,t[95]=je):je=t[95],je}),cE=y.memo(function(e){const t=B.c(15),{showDiff:s,open:o,hasDiff:i,diffRef:a,lastDiffHeight:l,oldString:c,newString:d,filePath:u,diffMode:f,edits:m,netStartLine:p}=e;if(s){let h;t[0]!==f||t[1]!==m||t[2]!==u||t[3]!==p||t[4]!==d||t[5]!==c?(h=f==="per-edit"?r.jsx(uE,{edits:m,filePath:u}):r.jsx(tu,{oldString:c,newString:d,filePath:u,compact:!1,startLine:p,hideHeader:!0}),t[0]=f,t[1]=m,t[2]=u,t[3]=p,t[4]=d,t[5]=c,t[6]=h):h=t[6];let g;return t[7]!==f||t[8]!==a||t[9]!==h?(g=r.jsx("div",{ref:a,className:"motion-enter overflow-hidden rounded-b",children:h},f),t[7]=f,t[8]=a,t[9]=h,t[10]=g):g=t[10],g}if(o&&l>0){let h;return t[11]!==l?(h=r.jsx("div",{style:{height:l}}),t[11]=l,t[12]=h):h=t[12],h}if(o&&!i){const h=f==="per-edit"?"No edits":"No net changes (all edits cancelled out)";let g;return t[13]!==h?(g=r.jsx("div",{className:"motion-enter px-3 py-2 text-xs italic text-muted-foreground",children:h}),t[13]=h,t[14]=g):g=t[14],g}return null}),_p=3,dE=5,uE=y.memo(function(e){const t=B.c(9),{edits:s,filePath:o}=e,i=s.length,a=s.filter(mE),l=a.length>_p,[c,d]=y.useState(l?_p:a.length);y.useEffect(()=>{if(c>=a.length)return;const x=requestAnimationFrame(()=>{d(b=>Math.min(b+dE,a.length))});return()=>cancelAnimationFrame(x)},[c,a.length]);const u=l?a.slice(0,c):a,f="divide-y divide-border/30";let m;t[0]!==o||t[1]!==i?(m=(x,b)=>r.jsxs("div",{children:[i>1&&r.jsxs("div",{className:"flex items-center gap-2 bg-muted/30 px-2.5 py-1",children:[r.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:[x.toolName," ",b+1,"/",i]}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["T",x.turnIndex+1]}),x.agentId&&r.jsx(iu,{agentId:x.agentId})]}),r.jsx(tu,{oldString:x.oldString,newString:x.newString,filePath:o,compact:!1,startLine:x.startLine,hideHeader:!0})]},x.id),t[0]=o,t[1]=i,t[2]=m):m=t[2];const p=u.map(m);let h;t[3]!==a.length||t[4]!==c?(h=c<a.length&&r.jsxs("div",{className:"py-1.5 text-center text-xs text-muted-foreground",children:["Loading ",a.length-c," more edits…"]}),t[3]=a.length,t[4]=c,t[5]=h):h=t[5];let g;return t[6]!==p||t[7]!==h?(g=r.jsxs("div",{className:f,children:[p,h]}),t[6]=p,t[7]=h,t[8]=g):g=t[8],g});function fE(n){return!!(n.oldString||n.newString)}function mE(n){return!!(n.oldString||n.newString)}const Al=new Map;function pE(n){var S;const e=En("hostFiles"),{sessionSource:t}=it(),s=t==null?void 0:t.dirName,o=Et(s)==="codex",i=n.turns.length,a=((S=n.turns.at(-1))==null?void 0:S.toolCalls.length)??0,l=y.useMemo(()=>{let j=0;for(const k of n.turns){j+=k.toolCalls.length;for(const C of k.subAgentActivity)j+=C.toolCalls.length}return j},[i,a]),c=y.useMemo(()=>{const j=[];for(let k=0;k<n.turns.length;k++)for(const C of n.turns[k].subAgentActivity){const N=o&&(C.status==="completed"||C.status==="failed"||C.status==="interrupted");(C.isBackground||N)&&C.toolCalls.length===0&&j.push({agentId:C.agentId,turnIndex:k})}return j},[n.turns,l,o]),[d,u]=y.useState(new Map),f=y.useRef(new Set);y.useEffect(()=>{if(!s||!n.sessionId||c.length===0)return;const j=[];for(const{agentId:N}of c){const _=Kt(`${s}/${n.sessionId}/${N}`);if(!f.current.has(_)){if(Al.has(_)){u(P=>{const A=new Map(P);return A.set(N,Al.get(_)),A}),f.current.add(_);continue}j.push({agentId:N,cacheKey:_})}}if(j.length===0)return;let k=!1;async function C(){const N=new Map;await Promise.all(j.map(async({agentId:_,cacheKey:P})=>{try{const A=`/api/sessions/${encodeURIComponent(s)}/${encodeURIComponent(n.sessionId)}/subagents/agent-${encodeURIComponent(_)}.jsonl`,T=await ve(A);if(!T.ok)return;const E=await T.text(),$=w0(E,_).flatMap(I=>nr(I.toolCalls,n.cwd));Al.set(P,$),f.current.add(P),N.set(_,$)}catch{}})),!k&&N.size>0&&u(_=>{const P=new Map(_);for(const[A,T]of N)P.set(A,T);return P})}return C(),()=>{k=!0}},[s,n.sessionId,n.cwd,c]);const m=y.useMemo(()=>{const j=[],k=new Set;for(let C=0;C<n.turns.length;C++){const N=n.turns[C];for(const _ of nr(N.toolCalls,n.cwd))j.push({turnIndex:C,toolCall:_});for(const _ of N.subAgentActivity){for(const P of nr(_.toolCalls,n.cwd))j.push({turnIndex:C,toolCall:P,agentId:_.agentId});if((_.isBackground||o)&&_.toolCalls.length===0&&!k.has(_.agentId)){k.add(_.agentId);const P=d.get(_.agentId);if(P)for(const A of P)j.push({turnIndex:C,toolCall:A,agentId:_.agentId})}}}return j},[l,n.turns,d,o]),p=y.useMemo(()=>{const j=new Set;for(const k of m){const C=Q0(k.toolCall);C&&j.add(C)}return[...j]},[m]),[h,g]=y.useState(new Map);y.useEffect(()=>{if(!e||p.length===0){g(new Map);return}let j=!1;return Promise.all(p.map(k=>ve(`/api/file-content?path=${encodeURIComponent(k)}`).then(C=>C.ok?C.text():null).then(C=>C?[k,C]:null).catch(()=>null))).then(k=>{if(j)return;const C=new Map;for(const N of k)N&&C.set(N[0],N[1]);g(C)}),()=>{j=!0}},[e,p]);const x=n.turns.length-1,b=y.useMemo(()=>Qi(m,"all",h),[m,h]),w=y.useMemo(()=>Qi(m,x,h),[m,x,h]),v=y.useMemo(()=>{const j=new Map;for(const k of n.turns)for(const C of k.subAgentActivity)j.has(C.agentId)||j.set(C.agentId,{name:C.agentName,type:C.subagentType});return j},[n.turns]);return{fileChanges:m,fileContents:h,groupedByFile:b,groupedLastTurn:w,lastTurnIndex:x,agentMap:v}}function Tp(n,e){if(!n||!e)return 1;const t=n.indexOf(e);if(t===-1)return 1;let s=1;for(let o=0;o<t;o++)n[o]===`
119
- `&&s++;return s}function Q0(n){return String(n.input.file_path??n.input.path??"")}function hE(n){const e=n.name==="Edit";return{oldString:e?String(n.input.old_string??""):"",newString:String(e?n.input.new_string??"":n.input.content??""),isWrite:!e}}function Qi(n,e,t){const s=new Map;for(const i of n){if(e!=="all"&&i.turnIndex!==e)continue;const a=Q0(i.toolCall);if(!a)continue;let l=s.get(a);l||(l=[],s.set(a,l)),l.push(i)}const o=[];for(const[i,a]of s){const l=[],c=[];let d=1/0,u=-1/0,f=!1,m=!1,p;const h=t==null?void 0:t.get(i);for(let b=0;b<a.length;b++){const w=a[b],v=hE(w.toolCall);l.push(v),w.turnIndex<d&&(d=w.turnIndex),w.turnIndex>u&&(u=w.turnIndex),w.toolCall.name==="Edit"?f=!0:m=!0,w.agentId&&(p=w.agentId),c.push({id:w.toolCall.id,oldString:v.oldString,newString:v.newString,toolName:w.toolCall.name,turnIndex:w.turnIndex,agentId:w.agentId,startLine:w.toolCall.name==="Write"?1:Tp(h,v.newString||v.oldString)})}const g=j8(l),x=[];f&&x.push("Edit"),m&&x.push("Write"),o.push({filePath:i,shortPath:i.split("/").slice(-3).join("/"),editCount:a.length,turnRange:[d,u],opTypes:x,netOriginal:g.originalStr,netCurrent:g.currentStr,addCount:g.addCount,delCount:g.delCount,subAgentId:p??null,edits:c,netStartLine:g.currentStr?Tp(h,g.currentStr):c.length>0?c[0].startLine:1})}return o.sort((i,a)=>i.turnRange[1]-a.turnRange[1]||i.turnRange[0]-a.turnRange[0]||i.filePath.localeCompare(a.filePath)),o}function gE(n,e,t,s){const o=new Map;for(const a of n){if(!a.agentId||e!=="all"&&a.turnIndex!==e)continue;let l=o.get(a.agentId);l||(l=[],o.set(a.agentId,l)),l.push(a)}const i=[];for(const[a,l]of o){const c=Qi(l,"all",s);if(c.length===0)continue;let d=0,u=0;for(const m of c)d+=m.addCount,u+=m.delCount;const f=t.get(a);i.push({agentId:a,agentName:(f==null?void 0:f.name)??null,subagentType:(f==null?void 0:f.type)??null,files:c,totalAdd:d,totalDel:u})}return i.sort((a,l)=>{var u,f;const c=((u=a.files[0])==null?void 0:u.turnRange[0])??0,d=((f=l.files[0])==null?void 0:f.turnRange[0])??0;return c-d}),i}const yr="cogpit:focus-file",xE="cogpit:file-changes-prefs",bE={expanded:!0,diffMode:"net",scope:"last",groupByAgent:!1};function vE(n){const e=B.c(36),{group:t,allExpanded:s,highlightPath:o,diffMode:i}=n;let a;e[0]!==t.agentId||e[1]!==t.agentName?(a=t.agentName||t.agentId.slice(0,8),e[0]=t.agentId,e[1]=t.agentName,e[2]=a):a=e[2];const l=a,c=t.subagentType,d=`Open subagent ${t.agentId}`;let u;e[3]!==t.agentId?(u=()=>{window.dispatchEvent(new CustomEvent(Ji,{detail:{agentId:t.agentId}}))},e[3]=t.agentId,e[4]=u):u=e[4];let f;e[5]!==l||e[6]!==d||e[7]!==u?(f=r.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"h-auto min-w-0 truncate px-1 text-xs font-semibold",title:d,onClick:u,children:l}),e[5]=l,e[6]=d,e[7]=u,e[8]=f):f=e[8];let m;e[9]!==c?(m=c&&r.jsx("span",{className:"truncate text-xs text-muted-foreground",children:c}),e[9]=c,e[10]=m):m=e[10];let p;e[11]!==t.files.length?(p=r.jsx(_e,{variant:"outline",className:"h-5 px-1.5 text-xs text-muted-foreground",children:t.files.length}),e[11]=t.files.length,e[12]=p):p=e[12];let h;e[13]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx("div",{className:"flex-1"}),e[13]=h):h=e[13];let g;e[14]!==t.totalAdd?(g=r.jsxs("span",{className:"font-mono text-xs tabular-nums text-success",children:["+",t.totalAdd]}),e[14]=t.totalAdd,e[15]=g):g=e[15];let x;e[16]!==t.totalDel?(x=r.jsxs("span",{className:"font-mono text-xs tabular-nums text-destructive",children:["-",t.totalDel]}),e[16]=t.totalDel,e[17]=x):x=e[17];let b;e[18]!==f||e[19]!==m||e[20]!==p||e[21]!==g||e[22]!==x?(b=r.jsxs("div",{className:"flex items-center gap-2 px-1.5 pt-1.5 pb-0.5",children:[f,m,p,h,g,x]}),e[18]=f,e[19]=m,e[20]=p,e[21]=g,e[22]=x,e[23]=b):b=e[23];let w;if(e[24]!==s||e[25]!==i||e[26]!==t.files||e[27]!==o){let S;e[29]!==s||e[30]!==i||e[31]!==o?(S=j=>r.jsx(J0,{file:j,defaultOpen:s,isHighlighted:o===j.filePath,diffMode:i},j.filePath),e[29]=s,e[30]=i,e[31]=o,e[32]=S):S=e[32],w=t.files.map(S),e[24]=s,e[25]=i,e[26]=t.files,e[27]=o,e[28]=w}else w=e[28];let v;return e[33]!==b||e[34]!==w?(v=r.jsxs("div",{className:"flex flex-col gap-1",children:[b,w]}),e[33]=b,e[34]=w,e[35]=v):v=e[35],v}const yE=y.memo(function({session:e,sessionChangeKey:t}){const s=y.useRef(null),o=y.useRef(null),i=y.useRef(!0),a=y.useRef(!1),l=y.useRef(0),c=y.useRef(e.turns.length),[d,u]=y.useState(!1),[f,m]=y.useState(!1),[p,h]=Kr(xE,{}),g={...bE,...p},x=g.expanded,b=g.diffMode,w=g.groupByAgent,[v,S]=y.useState(g.scope),j=y.useCallback(G=>{h(J=>({...J,expanded:G}))},[h]),k=y.useCallback(G=>{h(J=>({...J,diffMode:G}))},[h]),C=y.useCallback(G=>{h(J=>({...J,groupByAgent:G}))},[h]);y.useEffect(()=>{typeof v!="number"&&h(G=>({...G,scope:v}))},[v,h]);const[N,_]=y.useState(null),P=y.useRef(null),{fileChanges:A,fileContents:T,groupedByFile:E,groupedLastTurn:R,lastTurnIndex:$,agentMap:I}=pE(e),M=y.useMemo(()=>typeof v!="number"?null:Qi(A,v,T),[A,v,T]);function D(){return typeof v=="number"?M??[]:v==="all"?E:R}const O=D(),L=y.useMemo(()=>w?gE(A,typeof v=="number"?v:v==="all"?"all":$,I,T):[],[w,A,v,$,I,T]);y.useEffect(()=>{const G=J=>{const Q=J.detail;Q!=null&&Q.filePath&&(S(Q.turnIndex),_(Q.filePath),P.current&&clearTimeout(P.current),P.current=setTimeout(()=>_(null),3e3),requestAnimationFrame(()=>{var Z;const X=(Z=s.current)==null?void 0:Z.querySelector(`[data-file-path="${CSS.escape(Q.filePath)}"]`);X==null||X.scrollIntoView({behavior:"smooth",block:"nearest"})}))};return window.addEventListener(yr,G),()=>{window.removeEventListener(yr,G),P.current&&clearTimeout(P.current)}},[]);const F=y.useCallback(()=>{const G=s.current;G&&(u(G.scrollTop>10),m(G.scrollHeight-G.scrollTop-G.clientHeight>10))},[]),z=y.useCallback(()=>{const G=s.current;G&&(i.current=G.scrollHeight-G.scrollTop-G.clientHeight<50,F())},[F]);if(y.useEffect(()=>{F()},[A.length,O.length,F]),y.useEffect(()=>{const G=s.current;G&&(G.scrollTop=G.scrollHeight),i.current=!0,a.current=!1,l.current=A.length,c.current=e.turns.length,S(g.scope),_(null),F()},[t]),y.useEffect(()=>{const G=e.turns.length;G>c.current&&(a.current=!0),c.current=G},[e.turns.length]),y.useEffect(()=>{if(A.length<=l.current){l.current=A.length;return}l.current=A.length,(a.current||i.current)&&(requestAnimationFrame(()=>{var G;(G=o.current)==null||G.scrollIntoView({behavior:"smooth"})}),a.current=!1)},[A.length]),A.length===0)return null;let W=0,U=0,H=0;if(w)for(const G of L)W+=G.totalAdd,U+=G.totalDel,H+=G.files.length;else{for(const G of O)W+=G.addCount,U+=G.delCount;H=O.length}function K(){S(v==="last"?"all":"last")}function V(){return typeof v=="number"?`Turn ${v+1}`:v==="all"?"All turns":`Last turn (T${$+1})`}const Y=V();return r.jsxs("div",{className:"view-transition-file-panel panel-enter-bottom flex h-full min-w-0 flex-col overflow-hidden bg-card",children:[r.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 border-b px-3",children:[r.jsx(Tr,{"data-icon":"inline-start",className:"size-3.5 text-muted-foreground"}),r.jsx("span",{className:"text-xs font-medium text-foreground",children:"File Changes"}),r.jsxs(_e,{variant:"outline",className:"h-5 px-1.5 text-xs text-muted-foreground",children:[H," file",H!==1?"s":""]}),r.jsx("div",{className:"flex-1"}),r.jsxs("span",{className:"font-mono text-xs tabular-nums text-success",children:["+",W]}),r.jsxs("span",{className:"font-mono text-xs tabular-nums text-destructive",children:["-",U]}),r.jsxs(At,{children:[r.jsx(Rt,{render:r.jsx(ee,{variant:w?"secondary":"ghost",size:"icon-xs",onClick:()=>C(!w),"aria-label":w?"Show all changes":"Group by subagent"}),children:r.jsx(ts,{"data-icon":"inline-start"})}),r.jsx(It,{children:w?"Show all changes":"Group by subagent"})]}),r.jsxs(At,{children:[r.jsx(Rt,{render:r.jsx(ee,{variant:v==="all"?"secondary":"ghost",size:"icon-xs",onClick:K,"aria-label":v==="last"?"Show all turns":"Show last turn only"}),children:v==="all"?r.jsx(qy,{"data-icon":"inline-start"}):r.jsx(Fs,{"data-icon":"inline-start"})}),r.jsx(It,{children:v==="last"?"Click for all turns":"Click for last turn only"})]}),r.jsxs(At,{children:[r.jsx(Rt,{render:r.jsx(ee,{variant:b==="per-edit"?"secondary":"ghost",size:"icon-xs",onClick:()=>k(b==="net"?"per-edit":"net"),"aria-label":b==="net"?"Show per-edit diffs":"Show net diff"}),children:b==="net"?r.jsx(Vy,{"data-icon":"inline-start"}):r.jsx(Gy,{"data-icon":"inline-start"})}),r.jsx(It,{children:b==="net"?"Switch to per-edit diffs":"Switch to net diff"})]}),r.jsxs(At,{children:[r.jsx(Rt,{render:r.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:()=>j(!x),"aria-label":x?"Collapse all":"Expand all"}),children:x?r.jsx(ma,{"data-icon":"inline-start"}):r.jsx(fa,{"data-icon":"inline-start"})}),r.jsx(It,{children:x?"Collapse all":"Expand all"})]})]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b bg-muted/30 px-3 py-1",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:"Showing:"}),v!=="all"&&$>0&&r.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:()=>{const G=typeof v=="number"?v:$;G>0&&S(G-1)},disabled:(typeof v=="number"?v:$)<=0,"aria-label":"Previous turn",children:r.jsx(Jc,{"data-icon":"inline-start"})}),r.jsx("span",{className:q("text-xs font-medium",typeof v=="number"?"text-foreground":"text-muted-foreground"),children:Y}),v!=="all"&&$>0&&r.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:()=>{S(G=>typeof G!="number"?G:G+1>=$?"last":G+1)},disabled:v==="last","aria-label":"Next turn",children:r.jsx(Je,{"data-icon":"inline-start"})}),typeof v=="number"&&r.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:()=>S("last"),"aria-label":"Back to last turn",children:r.jsx(rt,{"data-icon":"inline-start"})})]}),r.jsxs("div",{className:"relative flex-1 min-h-0",children:[r.jsx("div",{className:q("pointer-events-none absolute inset-x-0 top-0 z-10 h-6 bg-gradient-to-b from-background to-transparent transition-opacity duration-200",d?"opacity-100":"opacity-0")}),r.jsxs("div",{ref:s,onScroll:z,className:"h-full overflow-y-auto",children:[r.jsx("div",{className:"flex flex-col gap-1 p-1.5",children:w?L.length>0?L.map(G=>r.jsx(vE,{group:G,allExpanded:x,highlightPath:N,diffMode:b},G.agentId)):r.jsxs("div",{className:"py-4 text-center text-xs text-muted-foreground",children:["No subagent changes in ",Y.toLowerCase()]}):O.length>0?O.map(G=>r.jsx(J0,{file:G,defaultOpen:x,isHighlighted:N===G.filePath,diffMode:b},G.filePath)):r.jsxs("div",{className:"py-4 text-center text-xs text-muted-foreground",children:["No file changes in ",Y.toLowerCase()]})}),r.jsx("div",{ref:o})]}),r.jsx("div",{className:q("pointer-events-none absolute inset-x-0 bottom-0 z-10 h-6 bg-gradient-to-t from-background to-transparent transition-opacity duration-200",f?"opacity-100":"opacity-0")})]})]})});function wE(n,e){const t=new Map;function s(o,i){const a=String(o.input.file_path??o.input.path??"");if(!a)return;const l=o.name==="Edit",c=l?String(o.input.old_string??""):"",d=String(l?o.input.new_string??"":o.input.content??""),u=vr(c,d),f=t.get(a)??{add:0,del:0,hasEdit:!1,hasWrite:!1,subAgentId:null};f.add+=u.add,f.del+=u.del,l?f.hasEdit=!0:f.hasWrite=!0,i&&(f.subAgentId=i),t.set(a,f)}return nr(n.toolCalls,e).forEach(o=>s(o)),n.subAgentActivity.forEach(o=>nr(o.toolCalls,e).forEach(i=>s(i,o.agentId))),[...t.entries()].map(([o,{add:i,del:a,hasEdit:l,hasWrite:c,subAgentId:d}])=>({filePath:o,additions:i,deletions:a,hasEdit:l,hasWrite:c,subAgentId:d}))}function Ep(){return{children:new Map,isFile:!1,absPath:"",additions:0,deletions:0,hasEdit:!1,hasWrite:!1,subAgentId:null}}function jE(n,e){if(n.length===0)return[];const t=e.endsWith("/")?e.slice(0,-1):e,s=Ep();for(const i of n){let a=i.filePath;t&&a.startsWith(t+"/")?a=a.slice(t.length+1):a.startsWith("/")&&(a=a.slice(1));const l=a.split("/");let c=s;for(let d=0;d<l.length;d++){let u=c.children.get(l[d]);u||(u=Ep(),c.children.set(l[d],u)),d===l.length-1&&(u.isFile=!0,u.absPath=i.filePath,u.additions+=i.additions,u.deletions+=i.deletions,i.hasEdit&&(u.hasEdit=!0),i.hasWrite&&(u.hasWrite=!0),i.subAgentId&&(u.subAgentId=i.subAgentId)),c=u}}function o(i,a){return[...i.children.entries()].sort(([c,d],[u,f])=>{const m=d.isFile&&d.children.size===0,p=f.isFile&&f.children.size===0;return m!==p?m?1:-1:c.localeCompare(u)}).map(([c,d])=>{const u=a?`${a}/${c}`:c;if(d.isFile&&d.children.size===0)return{name:c,fullPath:u,absPath:d.absPath,isFile:!0,additions:d.additions,deletions:d.deletions,hasEdit:d.hasEdit,hasWrite:d.hasWrite,subAgentId:d.subAgentId,children:[]};let f=d,m=c,p=u;for(;!f.isFile&&f.children.size===1;){const[S,j]=[...f.children.entries()][0];if(j.isFile&&j.children.size===0)break;m+="/"+S,p+="/"+S,f=j}const h=o(f,p);let g=0,x=0,b=f.isFile?f.hasEdit:!1,w=f.isFile?f.hasWrite:!1,v=f.isFile?f.subAgentId:null;for(const S of h)g+=S.additions,x+=S.deletions,S.hasEdit&&(b=!0),S.hasWrite&&(w=!0),S.subAgentId&&(v=S.subAgentId);return f.isFile&&(g+=f.additions,x+=f.deletions),{name:m,fullPath:p,absPath:f.absPath,isFile:!1,additions:g,deletions:x,hasEdit:b,hasWrite:w,subAgentId:v,children:h}})}return o(s,"")}const SE=y.memo(function(e){const t=B.c(45),{turn:s,turnIndex:o,cwd:i}=e,a=En("hostFiles");let l;t[0]!==i||t[1]!==s?(l=wE(s,i),t[0]=i,t[1]=s,t[2]=l):l=t[2];const c=l;let d;t[3]!==i||t[4]!==c?(d=jE(c,i),t[3]=i,t[4]=c,t[5]=d):d=t[5];const u=d,[f,m]=y.useState(!1);let p=0,h=0;if(t[6]!==p||t[7]!==h||t[8]!==c){for(const R of c)p=p+R.additions,h=h+R.deletions;t[6]=p,t[7]=h,t[8]=c,t[9]=p,t[10]=h}else p=t[9],h=t[10];let g;t[11]!==p||t[12]!==h?(g={add:p,del:h},t[11]=p,t[12]=h,t[13]=g):g=t[13];const x=g;if(c.length===0)return null;const b=f&&"rotate-90";let w;t[14]!==b?(w=q("size-3 shrink-0 transition-transform duration-150 motion-reduce:transition-none",b),t[14]=b,t[15]=w):w=t[15];let v;t[16]!==w?(v=r.jsx(Je,{"data-icon":"inline-start",className:w}),t[16]=w,t[17]=v):v=t[17];let S;t[18]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx(Tr,{className:"size-3.5 shrink-0","data-icon":"inline-start"}),t[18]=S):S=t[18];const j=c.length!==1?"s":"";let k;t[19]!==c.length||t[20]!==j?(k=r.jsxs("span",{className:"font-medium tabular-nums",children:[c.length," file",j]}),t[19]=c.length,t[20]=j,t[21]=k):k=t[21];let C,N;t[22]!==x.add||t[23]!==x.del?(C=r.jsx(_c,{add:x.add,del:x.del,className:"opacity-80"}),N=r.jsx(ru,{add:x.add,del:x.del}),t[22]=x.add,t[23]=x.del,t[24]=C,t[25]=N):(C=t[24],N=t[25]);let _;t[26]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx("span",{"aria-hidden":!0,className:"pointer-events-none ml-1 h-px flex-1 bg-border/40 transition-colors group-hover/files:bg-border/70"}),t[26]=_):_=t[26];let P;t[27]!==C||t[28]!==N||t[29]!==v||t[30]!==k?(P=r.jsxs(Mt,{className:"group/files flex min-h-7 w-full cursor-pointer items-center gap-1.5 rounded-md px-1 text-left text-xs text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[v,S,k,C,N,_]}),t[27]=C,t[28]=N,t[29]=v,t[30]=k,t[31]=P):P=t[31];let A;if(t[32]!==a||t[33]!==u||t[34]!==o){let R;t[36]!==a||t[37]!==o?(R=$=>r.jsx(NE,{node:$,depth:0,turnIndex:o,canFocusFiles:a},$.fullPath),t[36]=a,t[37]=o,t[38]=R):R=t[38],A=u.map(R),t[32]=a,t[33]=u,t[34]=o,t[35]=A}else A=t[35];let T;t[39]!==A?(T=r.jsx(dt,{className:"ml-1 border-l border-border/40 pl-3",children:r.jsx("div",{className:"py-0.5",children:A})}),t[39]=A,t[40]=T):T=t[40];let E;return t[41]!==f||t[42]!==P||t[43]!==T?(E=r.jsxs(ct,{open:f,onOpenChange:m,children:[P,T]}),t[41]=f,t[42]=P,t[43]=T,t[44]=E):E=t[44],E}),NE=y.memo(function n({node:e,depth:t,turnIndex:s,canFocusFiles:o}){const[i,a]=y.useState(!0),l=t*16+8;if(e.isFile){const c=iE(e.name),d=()=>{o&&e.absPath&&window.dispatchEvent(new CustomEvent(yr,{detail:{filePath:e.absPath,turnIndex:s}}))};return r.jsxs("div",{className:"flex h-7 w-full items-center gap-1.5 font-mono text-xs",style:{paddingLeft:l},children:[r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",disabled:!o,className:q("h-7 min-w-0 flex-1 justify-start gap-1.5 rounded-sm px-0 font-mono text-xs font-normal disabled:opacity-100",o&&"cursor-pointer"),onClick:d,title:o?"Click to focus in sidebar":void 0,children:[r.jsx(c,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}),r.jsx(X0,{hasEdit:e.hasEdit,hasWrite:e.hasWrite}),r.jsx("span",{className:"truncate text-foreground/75",children:e.name})]}),e.subAgentId&&r.jsx(iu,{agentId:e.subAgentId}),r.jsx(_c,{add:e.additions,del:e.deletions}),r.jsx(ru,{add:e.additions,del:e.deletions})]})}return r.jsxs(r.Fragment,{children:[r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",className:"h-7 w-full justify-start gap-1 rounded-sm font-mono text-xs font-normal",style:{paddingLeft:l},onClick:()=>a(!i),"aria-expanded":i,children:[i?r.jsx(tt,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}):r.jsx(Je,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}),r.jsx(Yy,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}),r.jsx("span",{className:"truncate text-foreground/70",children:e.name}),r.jsx("div",{className:"flex-1 min-w-2"}),!i&&r.jsx(_c,{add:e.additions,del:e.deletions,dimmed:!0})]}),i&&e.children.map(c=>r.jsx(n,{node:c,depth:t+1,turnIndex:s,canFocusFiles:o},c.fullPath))]})});function kE(n){const e=B.c(14),{branchCount:t,onClick:s}=n;if(t===0)return null;let o;e[0]!==s?(o=r.jsx(ee,{variant:"ghost",size:"xs",onClick:f=>{f.stopPropagation(),s()},className:"h-6 text-muted-foreground"}),e[0]=s,e[1]=o):o=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(ed,{"data-icon":"inline-start"}),e[2]=i):i=e[2];let a;e[3]!==t?(a=r.jsx("span",{className:"font-mono text-xs",children:t}),e[3]=t,e[4]=a):a=e[4];let l;e[5]!==o||e[6]!==a?(l=r.jsxs(Rt,{render:o,children:[i,a]}),e[5]=o,e[6]=a,e[7]=l):l=e[7];const c=t!==1?"es":"";let d;e[8]!==t||e[9]!==c?(d=r.jsxs(It,{children:[t," branch",c," from this turn"]}),e[8]=t,e[9]=c,e[10]=d):d=e[10];let u;return e[11]!==l||e[12]!==d?(u=r.jsxs(At,{children:[l,d]}),e[11]=l,e[12]=d,e[13]=u):u=e[13],u}function Fa(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(Jy,{"data-slot":"context-menu",...t}),e[2]=t,e[3]=s):s=e[3],s}function Ba(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("select-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Xy,{"data-slot":"context-menu-trigger",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Ua(n){const e=B.c(18);let t,s,o,i,a,l;e[0]!==n?({className:t,align:o,alignOffset:i,side:a,sideOffset:l,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a,e[6]=l):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5],l=e[6]);const c=o===void 0?"start":o,d=i===void 0?4:i,u=a===void 0?"right":a,f=l===void 0?0:l;let m;e[7]!==t?(m=q("z-50 max-h-(--available-height) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 ease-out outline-none data-[side=bottom]:slide-in-from-top-1 data-[side=inline-end]:slide-in-from-left-1 data-[side=inline-start]:slide-in-from-right-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",t),e[7]=t,e[8]=m):m=e[8];let p;e[9]!==s||e[10]!==m?(p=r.jsx(Dh,{"data-slot":"context-menu-content",className:m,...s}),e[9]=s,e[10]=m,e[11]=p):p=e[11];let h;return e[12]!==c||e[13]!==d||e[14]!==u||e[15]!==f||e[16]!==p?(h=r.jsx(zh,{children:r.jsx(Fh,{className:"isolate z-50 outline-none",align:c,alignOffset:d,side:u,sideOffset:f,children:p})}),e[12]=c,e[13]=d,e[14]=u,e[15]=f,e[16]=p,e[17]=h):h=e[17],h}function vo(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(Lh,{"data-slot":"context-menu-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function KL(n){const e=B.c(10);let t,s,o;e[0]!==n?({className:t,inset:s,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==t?(i=q("px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",t),e[4]=t,e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o||e[8]!==i?(a=r.jsx(Bh,{"data-slot":"context-menu-label","data-inset":s,className:i,...o}),e[6]=s,e[7]=o,e[8]=i,e[9]=a):a=e[9],a}function on(n){const e=B.c(12);let t,s,o,i;e[0]!==n?({className:t,inset:s,variant:i,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);const a=i===void 0?"default":i;let l;e[5]!==t?(l=q("group/context-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none transition-colors duration-75 focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive",t),e[5]=t,e[6]=l):l=e[6];let c;return e[7]!==s||e[8]!==o||e[9]!==l||e[10]!==a?(c=r.jsx(Oh,{"data-slot":"context-menu-item","data-inset":s,"data-variant":a,className:l,...o}),e[7]=s,e[8]=o,e[9]=l,e[10]=a,e[11]=c):c=e[11],c}function wr(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("-mx-1 my-1 h-px bg-border",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Wc,{"data-slot":"context-menu-separator",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function CE(n){const e=B.c(22),{children:t,turnIndex:s,branches:o,onRestoreToHere:i,onOpenBranches:a,onBranchFromHere:l}=n;let c;e[0]!==t?(c=r.jsx(Ba,{className:"select-text",children:t}),e[0]=t,e[1]=c):c=e[1];let d;e[2]!==i||e[3]!==s?(d=()=>i(s),e[2]=i,e[3]=s,e[4]=d):d=e[4];let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Zc,{"data-icon":"inline-start"}),e[5]=u):u=e[5];let f;e[6]!==d?(f=r.jsx(vo,{children:r.jsxs(on,{onClick:d,children:[u,"Restore to this point"]})}),e[6]=d,e[7]=f):f=e[7];let m;e[8]!==o.length||e[9]!==a||e[10]!==s?(m=o.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(wr,{}),r.jsx(vo,{children:r.jsxs(on,{onClick:()=>a(s),children:[r.jsx(ed,{"data-icon":"inline-start"}),"View branches (",o.length,")"]})})]}),e[8]=o.length,e[9]=a,e[10]=s,e[11]=m):m=e[11];let p;e[12]!==l||e[13]!==s?(p=l&&r.jsxs(r.Fragment,{children:[r.jsx(wr,{}),r.jsx(vo,{children:r.jsxs(on,{onClick:()=>l(s),children:[r.jsx(An,{"data-icon":"inline-start"}),"Duplicate from here"]})})]}),e[12]=l,e[13]=s,e[14]=p):p=e[14];let h;e[15]!==f||e[16]!==m||e[17]!==p?(h=r.jsxs(Ua,{className:"min-w-44",children:[f,m,p]}),e[15]=f,e[16]=m,e[17]=p,e[18]=h):h=e[18];let g;return e[19]!==c||e[20]!==h?(g=r.jsxs(Fa,{children:[c,h]}),e[19]=c,e[20]=h,e[21]=g):g=e[21],g}function Z0(n){return Ax(n).status(n)}const _E=new Set(["Agent","TaskOutput","spawn_agent","wait_agent"]);function au(n){switch(n){case"max_turns":return"Stopped — turn limit reached";case"aborted_tools":return"Stopped — tools aborted";case"blocking_limit":return"Stopped — blocked";default:return`Stopped — ${n.replace(/_/g," ")}`}}function Vr(n,e,t,s){switch(n){case"thinking":return"Thinking...";case"tool_use":return e&&_E.has(e)?"Running agents...":e?`Using ${e}`:"Using tool...";case"processing":return"Processing...";case"compacting":return"Compressing context...";case"deferred":return"Awaiting permission review";case"awaiting_agents":return s&&s>0?`Waiting on ${s} agent${s===1?"":"s"}...`:"Waiting on agents...";case"completed":return t?au(t):"Done";default:return null}}function TE(n){const e=B.c(6),{status:t}=n;switch(t){case"thinking":{let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Zy,{className:"size-5 text-warning"}),e[0]=s):s=e[0],s}case"tool_use":{let s;return e[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Gs,{className:"size-5 text-info"}),e[1]=s):s=e[1],s}case"processing":{let s;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Qy,{className:"size-5 text-warning"}),e[2]=s):s=e[2],s}case"compacting":{let s;return e[3]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(ma,{className:"size-5 text-warning"}),e[3]=s):s=e[3],s}case"awaiting_agents":{let s;return e[4]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(yo,{className:"size-5 text-info"}),e[4]=s):s=e[4],s}case"completed":{let s;return e[5]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Bn,{className:"size-5 text-success"}),e[5]=s):s=e[5],s}default:return null}}const Pp=2e3,e2=600;function t2(n){const e=B.c(28),{status:t,label:s,fading:o,startTimestamp:i}=n,a=o===void 0?!1:o,l=t.status==="completed";let c;e[0]!==t.pendingAgentDescriptions?(c=t.pendingAgentDescriptions??[],e[0]=t.pendingAgentDescriptions,e[1]=c):c=e[1];const d=c,u=a?"opacity-0":"opacity-100";let f;e[2]!==u?(f=q("flex items-center gap-2.5 min-w-0 transition-opacity",u),e[2]=u,e[3]=f):f=e[3];let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m={transitionDuration:`${e2}ms`},e[4]=m):m=e[4];let p;e[5]!==t.status?(p=r.jsx(TE,{status:t.status}),e[5]=t.status,e[6]=p):p=e[6];const h=!l&&"text-muted-foreground",g=l&&t.terminalReason&&"text-warning",x=l&&!t.terminalReason&&"text-success";let b;e[7]!==h||e[8]!==g||e[9]!==x?(b=q("text-xs font-medium shrink-0",h,g,x),e[7]=h,e[8]=g,e[9]=x,e[10]=b):b=e[10];let w;e[11]!==s||e[12]!==b?(w=r.jsx("span",{className:b,children:s}),e[11]=s,e[12]=b,e[13]=w):w=e[13];let v;e[14]!==l||e[15]!==i?(v=!l&&i&&r.jsx(lu,{startTimestamp:i}),e[14]=l,e[15]=i,e[16]=v):v=e[16];let S;e[17]!==d?(S=d.length>0&&r.jsx("span",{className:"truncate text-xs text-muted-foreground",title:d.join(`
120
- `),children:d.join(" · ")}),e[17]=d,e[18]=S):S=e[18];let j;e[19]!==t.pendingQueue?(j=(t.pendingQueue??0)>0&&r.jsxs("span",{className:"ml-1 shrink-0 text-xs text-muted-foreground",children:["+",t.pendingQueue," queued"]}),e[19]=t.pendingQueue,e[20]=j):j=e[20];let k;return e[21]!==w||e[22]!==v||e[23]!==S||e[24]!==j||e[25]!==f||e[26]!==p?(k=r.jsxs("div",{className:f,style:m,children:[p,w,v,S,j]}),e[21]=w,e[22]=v,e[23]=S,e[24]=j,e[25]=f,e[26]=p,e[27]=k):k=e[27],k}function EE(n){const e=B.c(28),{status:t,durationLabel:s}=n,[o,i]=y.useState("visible");let a,l;if(e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const h=setTimeout(()=>i("fading"),Pp),g=setTimeout(()=>i("ready"),Pp+e2);return()=>{clearTimeout(h),clearTimeout(g)}},l=[],e[0]=a,e[1]=l):(a=e[0],l=e[1]),y.useEffect(a,l),o==="ready"){let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(Bn,{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=q("text-xs font-medium",g),e[3]=g,e[4]=x):x=e[4];let b;e[5]!==t.terminalReason?(b=t.terminalReason?au(t.terminalReason):"Waiting for your input",e[5]=t.terminalReason,e[6]=b):b=e[6];let w;e[7]!==x||e[8]!==b?(w=r.jsx("span",{className:x,children:b}),e[7]=x,e[8]=b,e[9]=w):w=e[9];let v;e[10]!==s?(v=s&&r.jsx("span",{className:"font-mono text-xs tabular-nums text-muted-foreground",children:s}),e[10]=s,e[11]=v):v=e[11];let S;return e[12]!==w||e[13]!==v?(S=r.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4","data-agent-ready":!0,children:[h,w,v]}),e[12]=w,e[13]=v,e[14]=S):S=e[14],S}let c;e[15]!==t.status||e[16]!==t.terminalReason||e[17]!==t.toolName?(c=Vr(t.status,t.toolName,t.terminalReason)??"Done",e[15]=t.status,e[16]=t.terminalReason,e[17]=t.toolName,e[18]=c):c=e[18];const d=c,u=o==="fading";let f;e[19]!==d||e[20]!==t||e[21]!==u?(f=r.jsx(t2,{status:t,label:d,fading:u}),e[19]=d,e[20]=t,e[21]=u,e[22]=f):f=e[22];let m;e[23]!==s?(m=s&&r.jsxs("span",{className:"font-mono text-xs tabular-nums text-muted-foreground",children:["in ",s]}),e[23]=s,e[24]=m):m=e[24];let p;return e[25]!==f||e[26]!==m?(p=r.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4",children:[f,m]}),e[25]=f,e[26]=m,e[27]=p):p=e[27],p}const PE=y.memo(function(){const e=B.c(25),{session:t,isLive:s,sseState:o,isCompacting:i,pendingInteraction:a}=it(),[l,c]=y.useState(!1),[d,u]=y.useState(!1),f=t==null?void 0:t.sessionId,[m,p]=y.useState(f);f!==m&&(p(f),c(!1),u(!1));let h;e:{if(!t||o!=="connected"){h=null;break e}if(i){let R;e[0]===Symbol.for("react.memo_cache_sentinel")?(R={status:"compacting"},e[0]=R):R=e[0],h=R;break e}const T=t.rawMessages;let E;e[1]!==T?(E=Z0(T),e[1]=T,e[2]=E):E=e[2],h=E}const g=h;let x,b;e[3]!==g||e[4]!==s||e[5]!==d?(x=()=>{if(!(!g||g.status==="compacting"||g.status==="idle")){if(!s){g.status==="completed"&&!d&&c(!0);return}if(g.status==="completed"){u(!0);return}c(!1),u(!1)}},b=[g,s,d],e[3]=g,e[4]=s,e[5]=d,e[6]=x,e[7]=b):(x=e[6],b=e[7]),y.useEffect(x,b);let w;e:{if(!g){w=null;break e}if(g.status==="compacting"){w=g;break e}if(g.status==="completed"){if(l){w=null;break e}if(!s&&!d){w=null;break e}w=g;break e}if(!s||g.status==="idle"){w=null;break e}w=g}const v=w,S=(v==null?void 0:v.status)==="completed",j=(t==null?void 0:t.turns[t.turns.length-1])??null;let k;e:{if(!S||!j){k=null;break e}let T;if(e[8]!==j){const E=ad(j);T=E!==null?Fn(E):null,e[8]=j,e[9]=T}else T=e[9];k=T}const C=k;if(a&&o==="connected"){let T;e[10]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx(Qh,{className:"size-5 shrink-0 text-info"}),e[10]=T):T=e[10];const E=a.type==="plan"?"Waiting for plan approval":"Waiting for your answer";let R;return e[11]!==E?(R=r.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4",children:[T,r.jsx("span",{className:"text-xs font-medium text-info",children:E})]}),e[11]=E,e[12]=R):R=e[12],R}if(!v)return null;if(S){let T;return e[13]!==v||e[14]!==C?(T=r.jsx(EE,{status:v,durationLabel:C}),e[13]=v,e[14]=C,e[15]=T):T=e[15],T}let N;e[16]!==v.pendingAgents||e[17]!==v.status||e[18]!==v.terminalReason||e[19]!==v.toolName?(N=Vr(v.status,v.toolName,v.terminalReason,v.pendingAgents),e[16]=v.pendingAgents,e[17]=v.status,e[18]=v.terminalReason,e[19]=v.toolName,e[20]=N):N=e[20];const _=N;if(!_)return null;const P=j==null?void 0:j.timestamp;let A;return e[21]!==v||e[22]!==_||e[23]!==P?(A=r.jsx("div",{className:"flex items-center gap-2.5 py-3 px-4",children:r.jsx(t2,{status:v,label:_,startTimestamp:P})}),e[21]=v,e[22]=_,e[23]=P,e[24]=A):A=e[24],A});function lu(n){const e=B.c(3),{startTimestamp:t,className:s}=n;let o;return e[0]!==s||e[1]!==t?(o=r.jsx(AE,{startTimestamp:t,className:s},t),e[0]=s,e[1]=t,e[2]=o):o=e[2],o}function AE(n){const e=B.c(12),{startTimestamp:t,className:s}=n;let o;e[0]!==t?(o=new Date(t).getTime(),e[0]=t,e[1]=o):o=e[1];const i=o,a=y.useRef(null);let l,c;e[2]!==i?(l=()=>{const h=setInterval(()=>{const g=a.current;g&&(g.textContent=Fn(Math.max(0,Date.now()-i)))},1e3);return()=>clearInterval(h)},c=[i],e[2]=i,e[3]=l,e[4]=c):(l=e[3],c=e[4]),y.useEffect(l,c);let d;e[5]!==s?(d=q("font-mono text-xs tabular-nums text-muted-foreground",s),e[5]=s,e[6]=d):d=e[6];const u=Math.max(0,Date.now()-i);let f;e[7]!==u?(f=Fn(u),e[7]=u,e[8]=f):f=e[8];let m;return e[9]!==d||e[10]!==f?(m=r.jsx("span",{ref:a,className:d,children:f}),e[9]=d,e[10]=f,e[11]=m):m=e[11],m}function RE(n,e){var s;if(!e)return!0;const t=e.toLowerCase();if(n.userMessage&&(typeof n.userMessage=="string"?n.userMessage:JSON.stringify(n.userMessage)).toLowerCase().includes(t))return!0;for(const o of n.assistantText)if(o.toLowerCase().includes(t))return!0;for(const o of n.contentBlocks)if(o.kind==="queued_prompt"&&o.content.toLowerCase().includes(t)||o.kind==="agent_message"&&(o.sender.toLowerCase().includes(t)||o.body.toLowerCase().includes(t)))return!0;for(const o of n.thinking)if(o.thinking.toLowerCase().includes(t))return!0;for(const o of n.toolCalls)if(o.name.toLowerCase().includes(t)||JSON.stringify(o.input).toLowerCase().includes(t)||(s=o.result)!=null&&s.toLowerCase().includes(t))return!0;return!1}const IE=6e5;function $E(n,e){const t=n[e].timestamp,s=e>0?n[e-1].timestamp:void 0;if(!t||!s)return 0;const o=Date.parse(t)-Date.parse(s);return!Number.isFinite(o)||o<=0?0:Math.min(o,IE)}function Ap(n,e){const t=[],s=[];let o=0,i=0,a=e;for(;a<n.length;){const l=n[a];if(l.kind==="thinking")t.push({kind:"thinking",blocks:l.blocks}),o+=l.blocks.length,i+=$E(n,a),a++;else if(l.kind==="tool_calls")t.push({kind:"tool_calls",toolCalls:l.toolCalls}),s.push(...l.toolCalls),a++;else break}return{items:t,toolCalls:s,thinkingCount:o,thoughtForMs:i,nextIndex:a}}const Tc=new Map,ME=300*1e3;function Rp(n){const e=Tc.get(n);return e?Date.now()>e.expiresAt?(Tc.delete(n),null):e.data:null}function OE(n,e){Tc.set(n,{data:e,expiresAt:Date.now()+ME})}function DE(n){const e=B.c(5);let t;e[0]!==n?(t=()=>n?Rp(Kt(n))??new Map:new Map,e[0]=n,e[1]=t):t=e[1];const[s,o]=y.useState(t),i=y.useRef("");let a,l;return e[2]!==n?(a=()=>{if(!n||Ca(window.location.pathname))return;const c=Kt(n),d=Rp(c);if(d){o(d);return}i.current=n;const u=new AbortController;return ve(`/api/slash-suggestions?cwd=${encodeURIComponent(n)}`,{signal:u.signal}).then(async f=>{if(u.signal.aborted||i.current!==n||!f.ok)return;const m=await f.json();if(u.signal.aborted||i.current!==n)return;const p=new Map;for(const h of m.suggestions??[])h.type==="skill"&&p.set(h.name,{source:h.source,description:h.description,filePath:h.filePath});OE(c,p),o(p)}).catch(LE),()=>u.abort()},l=[n],e[2]=n,e[3]=a,e[4]=l):(a=e[3],l=e[4]),y.useEffect(a,l),s}function LE(){}const zE=new Set(["queued_prompt","agent_message","plan_mode","recap","task_notification"]),FE=new Set(["thinking","tool_calls","sub_agent","background_agent","hook_event"]),BE=new Set(["AskUserQuestion","ExitPlanMode"]),UE=new Set(["text","thinking","tool_calls"]);function WE(n){return n.kind==="tool_calls"&&n.toolCalls.some(e=>BE.has(e.name)&&e.result==null)}function HE(n){for(let e=n.length-1;e>=0;e--){if(WE(n[e]))return e;if(UE.has(n[e].kind))return-1}return-1}const wi={foldedIndices:[],foldAnchorIndex:-1,foldable:!1,hiddenToolCalls:0};function KE(n,e="settled"){if(n.length===0||!n.some(a=>FE.has(a.kind)))return wi;let t=-1;if(e==="settled"){for(let a=n.length-1;a>=0;a--)if(n[a].kind==="text"){t=a;break}if(t===-1)return wi}const s=HE(n),o=[];let i=0;for(let a=0;a<n.length;a++){if(a===t||a===s)continue;const l=n[a];zE.has(l.kind)||(o.push(a),l.kind==="tool_calls"&&(i+=l.toolCalls.length))}return o.length===0?wi:{foldedIndices:o,foldAnchorIndex:o[0],foldable:!0,hiddenToolCalls:i}}function qE(n,e){return n!==null&&n>0?`Worked for ${Fn(n)}`:e>0?`Worked through ${e} step${e===1?"":"s"}`:"Show work"}const n2="border border-border bg-prompt-surface",Ip="border-l border-border/40",$p="border-l border-border";function s2(n){const e=B.c(20),{turn:t,index:s,branchCount:o}=n,i=o===void 0?0:o,{state:a,isMobile:l}=zt(),{activeTurnIndex:c,activeToolCallId:d,expandAll:u,expandToolPayloads:f}=a,{session:m,isLive:p,isSubAgentView:h,undoRedo:g,actions:x}=it(),b=p&&m!==null,w=b&&s===((m==null?void 0:m.turns.length)??0)-1;let v=!w;if(w&&m){let _;if(e[0]!==m.rawMessages){const{status:P}=Z0(m.rawMessages);_=Yd.has(P),e[0]=m.rawMessages,e[1]=_}else _=e[1];v=!_}const S=(m==null?void 0:m.cwd)??"",j=DE(S),k=c===s,C=!g.enabled||h?void 0:g.requestUndo;let N;return e[2]!==x.handleEditCommand||e[3]!==x.handleExpandCommand||e[4]!==x.handleOpenBranches||e[5]!==d||e[6]!==i||e[7]!==S||e[8]!==u||e[9]!==f||e[10]!==s||e[11]!==w||e[12]!==l||e[13]!==b||e[14]!==v||e[15]!==j||e[16]!==k||e[17]!==C||e[18]!==t?(N=r.jsx(YE,{turn:t,index:s,branchCount:i,isActive:k,activeToolCallId:d,expandAll:u,expandToolPayloads:f,isAgentActive:w,isSessionLive:b,isTurnDone:v,isMobile:l,cwd:S,skillMetadata:j,onRestoreToHere:C,onOpenBranches:x.handleOpenBranches,onEditCommand:x.handleEditCommand,onExpandCommand:x.handleExpandCommand}),e[2]=x.handleEditCommand,e[3]=x.handleExpandCommand,e[4]=x.handleOpenBranches,e[5]=d,e[6]=i,e[7]=S,e[8]=u,e[9]=f,e[10]=s,e[11]=w,e[12]=l,e[13]=b,e[14]=v,e[15]=j,e[16]=k,e[17]=C,e[18]=t,e[19]=N):N=e[19],N}function VE(n){const e=B.c(12),{index:t,children:s}=n,{session:o,isSubAgentView:i,undoRedo:a,actions:l}=it(),{requestUndo:c,branchesAtTurn:d}=a,{handleOpenBranches:u,handleBranchFromHere:f}=l,m=t>=((o==null?void 0:o.turns.length)??0);if(!a.enabled||i||m||!c||!u){let g;return e[0]!==s?(g=r.jsx(r.Fragment,{children:s}),e[0]=s,e[1]=g):g=e[1],g}let p;e[2]!==d||e[3]!==t?(p=d(t),e[2]=d,e[3]=t,e[4]=p):p=e[4];let h;return e[5]!==s||e[6]!==f||e[7]!==u||e[8]!==t||e[9]!==c||e[10]!==p?(h=r.jsx(CE,{turnIndex:t,branches:p,onRestoreToHere:c,onOpenBranches:u,onBranchFromHere:f,children:s}),e[5]=s,e[6]=f,e[7]=u,e[8]=t,e[9]=c,e[10]=p,e[11]=h):h=e[11],h}function GE(n){const e=B.c(5),{turn:t,isTurnDone:s,hiddenToolCalls:o}=n;if(s){let a;return e[0]!==o||e[1]!==t?(a=qE(ad(t),o),e[0]=o,e[1]=t,e[2]=a):a=e[2],a}if(!t.timestamp)return"Working";let i;return e[3]!==t.timestamp?(i=r.jsxs("span",{className:"inline-flex items-baseline gap-1",children:["Working for",r.jsx(lu,{startTimestamp:t.timestamp,className:"text-xs text-inherit"})]}),e[3]=t.timestamp,e[4]=i):i=e[4],i}const YE=y.memo(function({turn:e,index:t,branchCount:s,isActive:o,activeToolCallId:i,expandAll:a,expandToolPayloads:l,isAgentActive:c,isSessionLive:d,isTurnDone:u,isMobile:f,cwd:m,skillMetadata:p,onRestoreToHere:h,onOpenBranches:g,onEditCommand:x,onExpandCommand:b}){const{ref:w,isNear:v}=i0(),S=y.useRef(null),j=y.useRef(0);y.useLayoutEffect(()=>{v&&S.current&&(j.current=S.current.offsetHeight)},[v]);const k=Xi(e.toolCalls,m)||e.subAgentActivity.some(R=>Xi(R.toolCalls,m)),C=u?"settled":"working",N=y.useMemo(()=>KE(e.contentBlocks,C),[C,e.contentBlocks]),[_,P]=y.useState(void 0),A=_??(a||!u),{leadingBlocks:T,trailingBlocks:E}=y.useMemo(()=>{if(!N.foldable)return{leadingBlocks:[],trailingBlocks:[]};const R=N.foldAnchorIndex,$=new Set(N.foldedIndices);return{leadingBlocks:e.contentBlocks.slice(0,R),trailingBlocks:e.contentBlocks.slice(R).filter((I,M)=>A||!$.has(R+M))}},[N,e.contentBlocks,A]);return r.jsxs("div",{ref:w,"data-turn-index":t,className:q("group relative",f?"px-1 py-3":"px-4 py-5",o&&"rounded-lg ring-1 ring-ring/40"),children:[r.jsx(JE,{index:t,turn:e,branchCount:s,isTurnDone:u,isMobile:f,onRestoreToHere:h,onOpenBranches:g}),v?r.jsxs("div",{ref:S,className:q("flex flex-col",f?"gap-2":"gap-3"),children:[e.userMessage&&r.jsx(VE,{index:t,children:r.jsx("div",{"data-turn-prompt":!0,className:q(f?"rounded-lg p-2.5":"rounded-lg p-3",n2),children:r.jsx(Kd,{content:e.userMessage,timestamp:e.timestamp,onEditCommand:x,onExpandCommand:b,compact:f})})}),N.foldable?r.jsxs(r.Fragment,{children:[T.length>0&&r.jsx(Rl,{blocks:T,model:e.model,effort:e.effort,expandAll:a,expandToolPayloads:l,activeToolCallId:i,isAgentActive:c,isSessionLive:d,isMobile:f,skillMetadata:p}),r.jsx(q8,{label:r.jsx(GE,{turn:e,isTurnDone:u,hiddenToolCalls:N.hiddenToolCalls}),expanded:A,onToggle:()=>P(!A),compact:f}),E.length>0&&r.jsx(Rl,{blocks:E,model:e.model,effort:e.effort,expandAll:a,expandToolPayloads:l,activeToolCallId:i,isAgentActive:c,isSessionLive:d,isMobile:f,skillMetadata:p})]}):r.jsx(Rl,{blocks:e.contentBlocks,model:e.model,effort:e.effort,expandAll:a,expandToolPayloads:l,activeToolCallId:i,isAgentActive:c,isSessionLive:d,isMobile:f,skillMetadata:p}),u&&k&&r.jsx(SE,{turn:e,turnIndex:t,cwd:m})]}):r.jsx("div",{style:{minHeight:j.current||XE(e)}})]})});function XE(n){return Math.max(60,(n.userMessage?40:0)+n.contentBlocks.length*60)}function JE(n){const e=B.c(26),{index:t,turn:s,branchCount:o,isTurnDone:i,isMobile:a,onRestoreToHere:l,onOpenBranches:c}=n,d=!i&&!!s.timestamp;let u;e[0]!==i||e[1]!==s?(u=i?ad(s):null,e[0]=i,e[1]=s,e[2]=u):u=e[2];const f=u,m=a?"mb-2 gap-1.5":"mb-4 gap-2";let p;e[3]!==m?(p=q("flex items-center",m),e[3]=m,e[4]=p):p=e[4];const h=a?`Turn ${t+1}`:t+1;let g;e[5]!==h?(g=r.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:h}),e[5]=h,e[6]=g):g=e[6];let x;e[7]!==f||e[8]!==d||e[9]!==s.timestamp?(x=r.jsx(QE,{durationMs:f,showLiveTimer:d,timestamp:s.timestamp}),e[7]=f,e[8]=d,e[9]=s.timestamp,e[10]=x):x=e[10];let b;e[11]!==t||e[12]!==a||e[13]!==l?(b=l&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>l(t),className:q("ml-auto text-muted-foreground transition-opacity hover:text-foreground",a?"opacity-70":"opacity-0 group-hover:opacity-100"),title:"Undo this turn and all after it",children:[r.jsx(Zc,{"data-icon":"inline-start"}),r.jsx("span",{className:"hidden sm:inline",children:"Restore"})]}),e[11]=t,e[12]=a,e[13]=l,e[14]=b):b=e[14];let w;e[15]!==o||e[16]!==t||e[17]!==c||e[18]!==l?(w=o>0&&c&&r.jsx("div",{className:q(!l&&"ml-auto"),children:r.jsx(kE,{branchCount:o,onClick:()=>c(t)})}),e[15]=o,e[16]=t,e[17]=c,e[18]=l,e[19]=w):w=e[19];let v;return e[20]!==p||e[21]!==g||e[22]!==x||e[23]!==b||e[24]!==w?(v=r.jsxs("div",{className:p,children:[g,x,b,w]}),e[20]=p,e[21]=g,e[22]=x,e[23]=b,e[24]=w,e[25]=v):v=e[25],v}function QE(n){const e=B.c(8),{durationMs:t,showLiveTimer:s,timestamp:o}=n;if(t!==null){let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Fs,{className:"size-3","data-icon":"inline-start"}),e[0]=i):i=e[0];let a;e[1]!==t?(a=Fn(t),e[1]=t,e[2]=a):a=e[2];let l;return e[3]!==a?(l=r.jsxs("span",{className:"flex items-center gap-1 font-mono text-xs tabular-nums text-muted-foreground",children:[i,a]}),e[3]=a,e[4]=l):l=e[4],l}if(s){let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Fs,{className:"size-3","data-icon":"inline-start"}),e[5]=i):i=e[5];let a;return e[6]!==o?(a=r.jsxs("span",{className:"flex items-center gap-1 font-mono text-xs tabular-nums text-info",children:[i,r.jsx(lu,{startTimestamp:o,className:"tabular-nums"})]}),e[6]=o,e[7]=a):a=e[7],a}return null}function ZE(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 Rl(n){const e=B.c(11),{blocks:t,model:s,effort:o,expandAll:i,expandToolPayloads:a,activeToolCallId:l,isAgentActive:c,isSessionLive:d,isMobile:u,skillMetadata:f}=n;let m;if(e[0]!==l||e[1]!==t||e[2]!==o||e[3]!==i||e[4]!==a||e[5]!==c||e[6]!==u||e[7]!==d||e[8]!==s||e[9]!==f){const p=[],h=u?"ml-0 pl-2":"ml-1 pl-3",g=u?"gap-2":"gap-3",x=new Map,b=(v,S)=>{const j=ZE(v)??`at-${S}`,k=x.get(j)??0;return x.set(j,k+1),k===0?j:`${j}#${k}`};let w=0;for(;w<t.length;){const v=t[w];if(v.kind==="thinking"||v.kind==="tool_calls"){const{items:S,toolCalls:j,thinkingCount:k,thoughtForMs:C,nextIndex:N}=Ap(t,w),_=S.length===1&&S[0].kind==="tool_calls";p.push(r.jsx("div",{className:q(Ip,h),children:r.jsx(wp,{toolCalls:j,expandAll:i,expandToolPayloads:a,activeToolCallId:l,isAgentActive:c,activityItems:_?void 0:S,thinkingCount:k,thoughtForMs:C,skillMetadata:f})},b(v,w))),w=N;continue}if(v.kind==="text"){const{items:S,toolCalls:j,thinkingCount:k,thoughtForMs:C,nextIndex:N}=Ap(t,w+1);p.push(r.jsxs("div",{children:[r.jsx("div",{className:q("flex flex-col",g),children:v.text.map((_,P)=>r.jsx(T_,{text:_,model:s,effort:o,timestamp:v.timestamp,compact:u},P))}),(j.length>0||k>0)&&r.jsx("div",{className:q("mt-1.5",Ip,h),children:r.jsx(wp,{toolCalls:j,expandAll:i,expandToolPayloads:a,activeToolCallId:l,isAgentActive:c,activityItems:k>0?S:void 0,thinkingCount:k,thoughtForMs:C,skillMetadata:f})})]},b(v,w))),w=N;continue}if(v.kind==="queued_prompt"){p.push(r.jsxs("div",{className:q(u?"rounded-lg p-2.5":"rounded-lg p-3",n2),children:[r.jsx(_e,{variant:"outline",className:"mb-2",children:"Queued while working"}),r.jsx(Kd,{content:v.content,timestamp:v.timestamp??"",compact:u})]},b(v,w))),w++;continue}if(v.kind==="agent_message"){p.push(r.jsx(k_,{sender:v.sender,body:v.body,reply:v.reply,timestamp:v.timestamp,isLive:d},b(v,w))),w++;continue}if(v.kind==="sub_agent"){p.push(r.jsx("div",{className:q($p,h),children:r.jsx(V_,{messages:v.messages,expandAll:i})},b(v,w))),w++;continue}if(v.kind==="background_agent"){p.push(r.jsx("div",{className:q($p,h),children:r.jsx(G_,{messages:v.messages,expandAll:i})},b(v,w))),w++;continue}if(v.kind==="hook_event"){p.push(r.jsx(X_,{events:v.events},b(v,w))),w++;continue}if(v.kind==="plan_mode"){p.push(r.jsx(x8,{plan:v.plan,planFilePath:v.planFilePath,status:v.status,toolCalls:v.toolCalls,expandAll:i,expandToolPayloads:a,isAgentActive:c,skillMetadata:f},b(v,w))),w++;continue}if(v.kind==="recap"){p.push(r.jsx(b8,{content:v.content,timestamp:v.timestamp},b(v,w))),w++;continue}if(v.kind==="task_notification"){p.push(r.jsx(w6,{content:v.content},b(v,w))),w++;continue}w++}m=r.jsx(r.Fragment,{children:p}),e[0]=l,e[1]=t,e[2]=o,e[3]=i,e[4]=a,e[5]=c,e[6]=u,e[7]=d,e[8]=s,e[9]=f,e[10]=m}else m=e[10];return m}function e9(n){if(!n)return null;const e=n.trigger==="manual"?"manual":"auto";return n.postTokens!=null?`${e} · ${ut(n.preTokens)} → ${ut(n.postTokens)}`:`${e} · ${ut(n.preTokens)}`}const t9=y.memo(function(e){const t=B.c(30),{summary:s,meta:o}=e,[i,a]=y.useState(!1);let l;t[0]!==o?(l=e9(o),t[0]=o,t[1]=l):l=t[1];const c=l;let d;t[2]!==s?(d=s==null?void 0:s.trim(),t[2]=s,t[3]=d):d=t[3];const u=d;let f;t[4]!==u||t[5]!==i?(f=u&&(i?r.jsx(tt,{className:"size-3","data-icon":"inline-start"}):r.jsx(Je,{className:"size-3","data-icon":"inline-start"})),t[4]=u,t[5]=i,t[6]=f):f=t[6];let m,p;t[7]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(e3,{className:"size-3","data-icon":"inline-start"}),p=r.jsx("span",{className:"font-medium",children:"Compacted"}),t[7]=m,t[8]=p):(m=t[7],p=t[8]);let h;t[9]!==c?(h=c&&r.jsxs(r.Fragment,{children:[r.jsx("span",{children:"·"}),r.jsx("span",{children:c})]}),t[9]=c,t[10]=h):h=t[10];let g;t[11]!==f||t[12]!==h?(g=r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground transition-colors group-hover:text-foreground",children:[f,m,p,h]}),t[11]=f,t[12]=h,t[13]=g):g=t[13];const x=g;if(!u){let N;t[14]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx("div",{className:"h-px flex-1 bg-border"}),t[14]=N):N=t[14];let _;t[15]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx("div",{className:"h-px flex-1 bg-border"}),t[15]=_):_=t[15];let P;return t[16]!==x?(P=r.jsxs("div",{className:"flex items-center gap-3 px-4 py-2",children:[N,x,_]}),t[16]=x,t[17]=P):P=t[17],P}let b,w;t[18]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx(ee,{type:"button",variant:"ghost",className:"group h-auto w-full gap-3 px-0"}),w=r.jsx("div",{className:"h-px flex-1 bg-border"}),t[18]=b,t[19]=w):(b=t[18],w=t[19]);let v;t[20]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx("div",{className:"h-px flex-1 bg-border"}),t[20]=v):v=t[20];let S;t[21]!==x?(S=r.jsxs(Mt,{render:b,children:[w,x,v]}),t[21]=x,t[22]=S):S=t[22];let j;t[23]===Symbol.for("react.memo_cache_sentinel")?(j=[ha],t[23]=j):j=t[23];let k;t[24]!==u?(k=r.jsx(dt,{children:r.jsx("div",{className:"prose prose-sm dark:prose-invert mx-8 mt-2 max-w-none rounded-md border bg-muted/30 px-3 py-2",children:r.jsx(Un,{remarkPlugins:j,components:qn,children:u})})}),t[24]=u,t[25]=k):k=t[25];let C;return t[26]!==i||t[27]!==S||t[28]!==k?(C=r.jsxs(ct,{open:i,onOpenChange:a,className:"px-4 py-2",children:[S,k]}),t[26]=i,t[27]=S,t[28]=k,t[29]=C):C=t[29],C}),n9=1.5;function s9(n,e){return e<=0?!1:n<e*n9}function o9(n,e){return n===0&&!e}function r9(n,e){return!n||!n.firstKey||e.length<=n.length||e[0]===n.firstKey?!1:e.includes(n.firstKey)}function i9(n,e){return e&&e!=="claude"?n.isFragment===!0:n.userMessage===null}const a9=1e3;function l9(n){const e=new Map;return n.map(t=>{if(!t.contentBlocks.some(o=>o.kind==="agent_message"))return t;const s=t.contentBlocks.filter(o=>{if(o.kind!=="agent_message")return!0;const i=Date.parse(o.timestamp??"");if(Number.isNaN(i))return!0;const a=`${o.sender}\0${o.body}`,l=e.get(a);return l!==void 0&&Math.abs(i-l)<=a9?!1:(e.set(a,i),!0)});return s.length===t.contentBlocks.length?t:{...t,contentBlocks:s}})}function o2(n,e,t){const s=new Set(n.map(c=>c.id)),o=e.filter(c=>!s.has(c.id));if(o.length===0)return n;const i=n[0],a=o[o.length-1],l=i&&a&&i9(i,t)?[...o.slice(0,-1),d9(a,i),...n.slice(1)]:[...o,...n];return Md(l9(l))}function c9(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 d9(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:c9(n,e),tokenUsage:e.tokenUsage??n.tokenUsage,model:e.model??n.model,compactionSummary:n.compactionSummary??e.compactionSummary,compactionMeta:n.compactionMeta??e.compactionMeta}}function u9(){const n=B.c(10),{session:e,isSubAgentView:t,undoRedo:s}=it(),{canRedo:o,redoTurnCount:i,redoGhostTurns:a,requestRedoAll:l,requestRedoUpTo:c}=s,d=(e==null?void 0:e.turns.length)??0;if(!s.enabled||t||!o||!l)return null;let u;n[0]!==i||n[1]!==l?(u=r.jsx(t_,{redoTurnCount:i,onRedoAll:l}),n[0]=i,n[1]=l,n[2]=u):u=n[2];let f;n[3]!==a||n[4]!==c||n[5]!==d?(f=a.length>0&&r.jsx("div",{className:"select-none",children:a.map((p,h)=>r.jsxs("div",{className:"group/ghost relative opacity-25 hover:opacity-40 transition-opacity",children:[r.jsx(s2,{turn:p,index:d+h}),c&&r.jsxs(ee,{type:"button",variant:"outline",size:"xs",onClick:()=>c(h),className:"absolute right-4 top-4 text-success opacity-0 transition-opacity group-hover/ghost:opacity-100",children:[r.jsx(t3,{"data-icon":"inline-start"}),"Redo to here"]})]},`ghost-${p.id}`))}),n[3]=a,n[4]=c,n[5]=d,n[6]=f):f=n[6];let m;return n[7]!==u||n[8]!==f?(m=r.jsxs(r.Fragment,{children:[u,f]}),n[7]=u,n[8]=f,n[9]=m):m=n[9],m}function f9(n){const e=B.c(5),{hasMore:t,isLoadingOlder:s}=n;let o;e[0]!==t||e[1]!==s?(o=s?r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx(ot,{className:"size-3 animate-spin","data-icon":"inline-start"}),"Loading older turns…"]}):t?null:r.jsx("span",{children:"Beginning of session"}),e[0]=t,e[1]=s,e[2]=o):o=e[2];let i;return e[3]!==o?(i=r.jsx("div",{className:"flex h-8 select-none items-center justify-center text-xs text-muted-foreground","data-testid":"history-status",children:o}),e[3]=o,e[4]=i):i=e[4],i}function m9(n){return(n.compactionSummary!=null||n.compactionMeta!=null)&&n.userMessage==null&&n.contentBlocks.length===0}function p9({filteredTurns:n,scrollContainerRef:e,hasMore:t=!1,isLoadingOlder:s=!1,pagingEnabled:o=!1,onLoadMore:i}){const{state:{activeTurnIndex:a}}=zt(),{undoRedo:l}=it(),c=y.useRef(null),d=y.useRef(null),[u,f]=y.useState(0),m=y.useMemo(()=>{const v=new Map;return n.map(S=>{const j=v.get(S.turn.id)??0;return v.set(S.turn.id,j+1),{...S,key:j===0?S.turn.id:`${S.turn.id}#${j}`}})},[n]),p=y.useRef(null),h=y.useMemo(()=>r9(p.current,m.map(v=>v.key)),[m]);y.useLayoutEffect(()=>{var v;p.current={firstKey:(v=m[0])==null?void 0:v.key,length:m.length}},[m]);const g=y.useRef(t);y.useEffect(()=>{t&&(g.current=!0)},[t]);const x=t||g.current;y.useLayoutEffect(()=>{const v=e.current,S=d.current;if(!v||!S)return;const j=S.getBoundingClientRect().top-v.getBoundingClientRect().top+v.scrollTop;f(k=>Math.abs(k-j)<1?k:j)},[e,x]),y.useEffect(()=>{if(!t||!i||!o||s)return;const v=e.current;if(!v)return;const S=()=>{s9(v.scrollTop,v.clientHeight)&&i()};return S(),v.addEventListener("scroll",S,{passive:!0}),()=>v.removeEventListener("scroll",S)},[t,s,o,i,m.length,e]);const b=y.useMemo(()=>{const v=new Map;for(let S=0;S<m.length;S++)v.set(m[S].index,S);return v},[m]),w=y.useRef(null);return y.useEffect(()=>{var S;if(a===null){w.current=null;return}if(a===w.current)return;w.current=a;const v=b.get(a);v!==void 0&&((S=c.current)==null||S.scrollToIndex(v,{align:"start",smooth:!0}))},[a,b]),r.jsxs(r.Fragment,{children:[x&&r.jsx(f9,{hasMore:t,isLoadingOlder:s}),r.jsx("div",{ref:d,className:"motion-session-enter",children:r.jsx(e_,{ref:c,scrollRef:e,startMargin:u,shift:h,children:m.map(({turn:v,index:S,key:j})=>r.jsxs("div",{"data-turn-index":S,children:[(v.compactionSummary||v.compactionMeta)&&r.jsx(t9,{summary:v.compactionSummary,meta:v.compactionMeta}),!m9(v)&&r.jsx(s2,{turn:v,index:S,branchCount:l.branchesAtTurn?l.branchesAtTurn(S).length:0})]},j))})}),r.jsx(u9,{})]})}const h9=y.memo(function(e){const t=B.c(19),{chatScrollRef:s,hasMore:o,isLoadingOlder:i,pagingEnabled:a,onLoadMore:l}=e,{state:c}=zt(),{searchQuery:d,sessionChangeKey:u}=c,{session:f}=it(),m=f==null?void 0:f.turns;let p;t[0]!==m?(p=m?m.map(g9):[],t[0]=m,t[1]=p):p=t[1];const h=p;let g;t[2]!==h||t[3]!==d?(g=d?h.filter(S=>{const{turn:j}=S;return RE(j,d)}):h,t[2]=h,t[3]=d,t[4]=g):g=t[4];const x=g;let b;t[5]!==x.length||t[6]!==o||t[7]!==d?(b=d?x.length===0:o9(x.length,o??!1),t[5]=x.length,t[6]=o,t[7]=d,t[8]=b):b=t[8];const w=b;let v;return t[9]!==s||t[10]!==x||t[11]!==o||t[12]!==i||t[13]!==l||t[14]!==a||t[15]!==d||t[16]!==u||t[17]!==w?(v=r.jsx(QC,{children:w?r.jsx(ln,{className:"min-h-64 border-0",children:r.jsxs(cn,{children:[r.jsx(bn,{variant:"icon",children:d?r.jsx(n3,{}):r.jsx(Zh,{})}),r.jsx(dn,{children:d?"No matching turns":"No conversation yet"}),r.jsx(vn,{children:d?"Try a different search term.":"Messages and tool activity will appear here."})]})}):r.jsx(p9,{filteredTurns:x,scrollContainerRef:s,hasMore:o,isLoadingOlder:i,pagingEnabled:a,onLoadMore:l},u)}),t[9]=s,t[10]=x,t[11]=o,t[12]=i,t[13]=l,t[14]=a,t[15]=d,t[16]=u,t[17]=w,t[18]=v):v=t[18],v});function g9(n,e){return{turn:n,index:e}}const x9="[data-turn-index]",r2="[data-turn-prompt]",Mp=1,b9=120,Op=180;function v9(n){if(!n.userMessage)return null;const e=Oa(n.userMessage),{body:t}=hr(e),{remainingText:s}=xr(t),o=Hd(s);if(!o){const a=Bx(e);if(!a)return null;const l=Ux(e);return l?`/${a} ${l}`:`/${a}`}const i=o.split(`
121
- `)[0];return i.length>Op?`${i.slice(0,Op)}...`:i}function y9(n,e){for(let t=e;t>=0;t--){const s=n[t];if(!s)continue;const o=v9(s);if(o)return{index:t,text:o}}return null}function w9(n){const e=n.getBoundingClientRect().top;let t=null,s=0;for(const l of n.querySelectorAll(x9)){const c=l.getBoundingClientRect().top;if(c>e+Mp)break;t=l,s=c}if(!t)return null;const o=Number(t.dataset.turnIndex);if(!Number.isInteger(o))return null;const i=t.querySelector(r2);return(i?i.getBoundingClientRect().bottom>e+Mp:s+b9>e)?null:o}const j9=y.memo(function(e){const t=B.c(22),{session:s,scrollContainerRef:o}=e,[i,a]=y.useState(null);let l,c;t[0]!==o||t[1]!==s.sessionId?(l=()=>{const S=o.current;if(!S)return;let j=null;const k=()=>{j=null;const P=w9(S);a(A=>P===null?null:(A==null?void 0:A.sessionId)===s.sessionId&&A.index===P?A:{sessionId:s.sessionId,index:P})},C=()=>{j===null&&(j=requestAnimationFrame(k))};a(null),S.addEventListener("scroll",C,{passive:!0});const N=new MutationObserver(C);N.observe(S,{childList:!0,subtree:!0});const _=new ResizeObserver(C);return _.observe(S),S.firstElementChild&&_.observe(S.firstElementChild),C(),()=>{S.removeEventListener("scroll",C),N.disconnect(),_.disconnect(),j!==null&&cancelAnimationFrame(j)}},c=[o,s.sessionId],t[0]=o,t[1]=s.sessionId,t[2]=l,t[3]=c):(l=t[2],c=t[3]),y.useEffect(l,c);let d;e:{if(!i||i.sessionId!==s.sessionId){d=null;break e}let S;t[4]!==s.turns||t[5]!==i.index?(S=y9(s.turns,i.index),t[4]=s.turns,t[5]=i.index,t[6]=S):S=t[6],d=S}const u=d;if(!u)return null;let f;t[7]!==u.index||t[8]!==o?(f=()=>{const S=o.current;if(!S)return;const j=S.querySelector(`[data-turn-index="${u.index}"]`),k=(j==null?void 0:j.querySelector(r2))??j;if(!k)return;const C=S.scrollTop+k.getBoundingClientRect().top-S.getBoundingClientRect().top;S.scrollTo({top:Math.max(0,C),behavior:"smooth"})},t[7]=u.index,t[8]=o,t[9]=f):f=t[9];const m=f,p=`Scroll to turn ${u.index+1} prompt`;let h;t[10]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(Zh,{"data-icon":"inline-start"}),t[10]=h):h=t[10];const g=u.index+1;let x;t[11]!==g?(x=r.jsxs("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:["Turn ",g]}),t[11]=g,t[12]=x):x=t[12];let b;t[13]!==u.text?(b=r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-normal text-foreground/80",children:u.text}),t[13]=u.text,t[14]=b):b=t[14];let w;t[15]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(kr,{"data-icon":"inline-end",className:"ml-auto"}),t[15]=w):w=t[15];let v;return t[16]!==u.text||t[17]!==m||t[18]!==p||t[19]!==x||t[20]!==b?(v=r.jsxs(ee,{type:"button",variant:"outline",size:"sm","aria-label":p,title:u.text,className:"motion-slide-down-in absolute left-1/2 top-12 z-20 h-9 max-w-[calc(100%-5rem)] -translate-x-1/2 justify-start gap-2 rounded-full bg-background px-3 text-left shadow-sm",onClick:m,children:[h,x,b,w]}),t[16]=u.text,t[17]=m,t[18]=p,t[19]=x,t[20]=b,t[21]=v):v=t[21],v});function S9(n){const e=B.c(14),{block:t,showCursor:s}=n;if(t.blockType==="tool_use"){const l=t.toolName??"tool";let c;return e[0]!==l?(c=r.jsxs("div",{className:"text-xs text-muted-foreground italic py-1",children:["Preparing ",l,"…"]}),e[0]=l,e[1]=c):c=e[1],c}if(t.blockType==="thinking"){if(!t.text)return null;let l;e[2]!==s?(l=s&&r.jsx(Dp,{}),e[2]=s,e[3]=l):l=e[3];let c;return e[4]!==t.text||e[5]!==l?(c=r.jsxs("div",{className:"my-2 whitespace-pre-wrap break-words border-l pl-3 text-sm italic leading-relaxed text-muted-foreground",children:[t.text,l]}),e[4]=t.text,e[5]=l,e[6]=c):c=e[6],c}if(!t.text)return null;let o;e[7]!==t.text?(o=r.jsx(Qd,{text:t.text}),e[7]=t.text,e[8]=o):o=e[8];let i;e[9]!==s?(i=s&&r.jsx(Dp,{}),e[9]=s,e[10]=i):i=e[10];let a;return e[11]!==o||e[12]!==i?(a=r.jsxs("div",{className:"text-sm leading-relaxed break-words my-2",children:[o,i]}),e[11]=o,e[12]=i,e[13]=a):a=e[13],a}function Dp(){const n=B.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("span",{className:"ml-0.5 inline-block h-[15px] w-[7px] rounded-[1px] bg-foreground/70 align-text-bottom"}),n[0]=e):e=n[0],e}const N9=y.memo(function(){const e=B.c(9),t=Jd();let s,o,i,a;if(e[0]!==t){a=Symbol.for("react.early_return_sentinel");e:{const c=I_(t);if(c.length===0){a=null;break e}const d=new Map;s="px-4",o="streaming-turn-overlay",i=c.map(u=>{const f=d.get(u.messageId)??0;d.set(u.messageId,f+1);const m=u.blocks.reduce(k9,-1);return r.jsx("div",{children:u.blocks.map((p,h)=>r.jsx(S9,{block:p,showCursor:!u.stopped&&h===m},p.index))},`${u.messageId}:${f}`)})}e[0]=t,e[1]=s,e[2]=o,e[3]=i,e[4]=a}else s=e[1],o=e[2],i=e[3],a=e[4];if(a!==Symbol.for("react.early_return_sentinel"))return a;let l;return e[5]!==s||e[6]!==o||e[7]!==i?(l=r.jsx("div",{className:s,"data-testid":o,children:i}),e[5]=s,e[6]=o,e[7]=i,e[8]=l):l=e[8],l});function k9(n,e,t){return e.blockType!=="tool_use"&&e.text?t:n}const C9=3,Zi=["w-6","w-4","w-2.5","w-2"],_9=Zi[Zi.length-1];function T9(n){return n===null||n<0?_9:Zi[Math.min(n,Zi.length-1)]}function E9(n){return n.type==="text"}function Il(n){return n.replace(/\s+/g," ").trim()}function P9(n){const e=typeof n.userMessage=="string"?n.userMessage:Array.isArray(n.userMessage)?n.userMessage.filter(E9).map(l=>l.text).join(" "):"",{text:t}=Kx(e),{remainingText:s}=xr(t),{remainingText:o}=Hx(s),i=Il(Hd(o));if(i)return i;for(const l of n.contentBlocks){if(l.kind!=="task_notification")continue;const c=xr(l.content).notifications.map(d=>d.summary).find(Boolean);if(c)return Il(c)}return n.assistantText.map(Il).find(Boolean)||"Untitled turn"}const A9=y.memo(function(e){const t=B.c(21),{turns:s,scrollContainerRef:o,onJumpToTurn:i}=e,[a,l]=y.useState(null),c=y.useRef(null),d=s.length;let u;if(t[0]!==s){const S=new Map;u=s.map(j=>{const k=S.get(j.id)??0;return S.set(j.id,k+1),k===0?j.id:`${j.id}#${k}`}),t[0]=s,t[1]=u}else u=t[1];const f=u;let m;t[2]!==o?(m=()=>{const S=o.current,j=c.current;if(!S||!j)return;let k=null;const C=()=>{k=null;const _=S.getBoundingClientRect().top+S.clientHeight/2;let P=null;for(const A of S.querySelectorAll("[data-turn-index]")){const T=A.getBoundingClientRect();if(T.top<=_&&T.bottom>=_){P=Number(A.dataset.turnIndex);break}}for(const A of j.querySelectorAll("[data-tick-index]"))A.dataset.current=String(Number(A.dataset.tickIndex)===P)},N=()=>{k===null&&(k=requestAnimationFrame(C))};return C(),S.addEventListener("scroll",N,{passive:!0}),()=>{S.removeEventListener("scroll",N),k!==null&&cancelAnimationFrame(k)}},t[2]=o,t[3]=m):m=t[3];let p;t[4]!==o||t[5]!==d?(p=[o,d],t[4]=o,t[5]=d,t[6]=p):p=t[6],y.useEffect(m,p);let h;t[7]===Symbol.for("react.memo_cache_sentinel")?(h=S=>{const j=S.key==="ArrowDown"?1:S.key==="ArrowUp"?-1:0,k=c.current;if(!k)return;const C=[...k.querySelectorAll("[data-tick-index]")];if(C.length===0)return;let N;if(j!==0){const _=C.indexOf(document.activeElement);N=C[Math.min(Math.max(_+j,0),C.length-1)]}else S.key==="Home"?N=C[0]:S.key==="End"&&(N=C[C.length-1]);N&&(S.preventDefault(),N.focus())},t[7]=h):h=t[7];const g=h;if(d<C9)return null;let x;t[8]===Symbol.for("react.memo_cache_sentinel")?(x=()=>l(null),t[8]=x):x=t[8];let b;t[9]===Symbol.for("react.memo_cache_sentinel")?(b=q("absolute left-0 top-0 hidden h-full max-h-full flex-col items-start gap-1","justify-evenly overflow-y-auto pb-6 pl-2 pt-14","opacity-60 transition-opacity hover:opacity-100 focus-within:opacity-100","[@media(pointer:fine)]:flex"),t[9]=b):b=t[9];let w;if(t[10]!==a||t[11]!==i||t[12]!==f||t[13]!==s){let S;t[15]!==a||t[16]!==i||t[17]!==f?(S=(j,k)=>{const C=P9(j);return r.jsx(ee,{type:"button",variant:"ghost","data-tick-index":k,onMouseEnter:()=>l(k),onFocus:()=>l(k),onClick:()=>i(k),"aria-label":`Turn ${k+1}: ${C}`,className:q("group/tick relative h-1 shrink-0 rounded-full bg-muted-foreground/30 p-0","transition-[width,background-color] duration-150 motion-reduce:transition-none","hover:bg-muted-foreground/80 focus-visible:outline-none focus-visible:bg-muted-foreground/80","data-[current=true]:bg-primary/70",T9(a===null?null:Math.abs(k-a))),children:r.jsxs("span",{className:q("pointer-events-none absolute left-full top-1/2 ml-2 hidden w-64 -translate-y-1/2","rounded-md border bg-popover px-2 py-1.5 text-left","text-xs leading-relaxed text-popover-foreground shadow-sm","group-hover/tick:block group-focus-visible/tick:block"),children:[r.jsx("span",{className:"mr-1 font-mono text-muted-foreground/60",children:k+1}),r.jsx("span",{className:"line-clamp-2 align-middle",children:C})]})},f[k])},t[15]=a,t[16]=i,t[17]=f,t[18]=S):S=t[18],w=s.map(S),t[10]=a,t[11]=i,t[12]=f,t[13]=s,t[14]=w}else w=t[14];let v;return t[19]!==w?(v=r.jsx("nav",{ref:c,"aria-label":"Conversation timeline",onMouseLeave:x,onKeyDown:g,className:b,children:w}),t[19]=w,t[20]=v):v=t[20],v});class R9 extends y.Component{constructor(t){super(t);ai(this,"handleRetry",()=>{this.setState({hasError:!1,error:null})});this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,s){console.error("ErrorBoundary caught:",t,s.componentStack)}render(){return this.state.hasError?r.jsx("div",{className:"flex justify-center p-8",children:r.jsxs(ht,{variant:"destructive",className:"max-w-md has-data-[slot=alert-action]:pr-2.5",children:[r.jsx(xn,{}),r.jsx(Tt,{children:r.jsx("h3",{children:this.props.fallbackMessage||"Something went wrong"})}),this.state.error&&r.jsx(gt,{className:"font-mono text-xs",children:this.state.error.message}),r.jsx(Cs,{className:"static col-start-2 mt-2",children:r.jsxs(ee,{variant:"outline",size:"sm",onClick:this.handleRetry,children:[r.jsx(Ot,{"data-icon":"inline-start"}),"Try again"]})})]})}):this.props.children}}const Lp="find-in-session-highlight",$l="find-in-session-active";function I9(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 $9=y.forwardRef(function(e,t){const s=B.c(63),{scrollContainerRef:o}=e,[i,a]=y.useState(!1),[l,c]=y.useState("");let d;s[0]===Symbol.for("react.memo_cache_sentinel")?(d=[],s[0]=d):d=s[0];const[u,f]=y.useState(d),[m,p]=y.useState(-1),h=y.useRef(null);let g;s[1]!==o?(g=()=>{const ne=o.current;if(!ne)return;ne.querySelectorAll(`mark.${Lp}`).forEach(M9)},s[1]=o,s[2]=g):g=s[2];const x=g;let b;s[3]!==x||s[4]!==o?(b=ne=>{if(x(),!ne||!o.current){f([]),p(-1);return}const re=o.current,ie=I9(re),ae=ne.toLowerCase(),se=[];for(const ue of ie){const le=ue.nodeValue||"",de=le.toLowerCase();let pe=0;const he=[];for(;;){const me=de.indexOf(ae,pe);if(me===-1)break;he.push(me),pe=me+1}if(he.length===0)continue;const ce=ue.parentNode;if(!ce)continue;const ye=document.createDocumentFragment();let xe=0;for(const me of he){me>xe&&ye.appendChild(document.createTextNode(le.slice(xe,me)));const je=document.createElement("mark");je.className=Lp,je.textContent=le.slice(me,me+ne.length),ye.appendChild(je),se.push(je),xe=me+ne.length}xe<le.length&&ye.appendChild(document.createTextNode(le.slice(xe))),ce.replaceChild(ye,ue)}f(se),se.length>0?(p(0),se[0].classList.add($l),se[0].scrollIntoView({block:"center",behavior:"smooth"})):p(-1)},s[3]=x,s[4]=o,s[5]=b):b=s[5];const w=b;let v;s[6]!==m||s[7]!==u?(v=ne=>{if(u.length===0)return;m>=0&&m<u.length&&u[m].classList.remove($l);const re=(ne%u.length+u.length)%u.length;u[re].classList.add($l),u[re].scrollIntoView({block:"center",behavior:"smooth"}),p(re)},s[6]=m,s[7]=u,s[8]=v):v=s[8];const S=v;let j;s[9]!==x?(j=()=>{a(!1),c(""),x(),f([]),p(-1)},s[9]=x,s[10]=j):j=s[10];const k=j;let C,N;s[11]!==k||s[12]!==i?(C=()=>({open:()=>{a(!0),requestAnimationFrame(()=>{var ne;return(ne=h.current)==null?void 0:ne.focus()})},close:k,isOpen:i}),N=[k,i],s[11]=k,s[12]=i,s[13]=C,s[14]=N):(C=s[13],N=s[14]),y.useImperativeHandle(t,C,N);let _,P;s[15]!==w||s[16]!==l?(_=()=>{const ne=setTimeout(()=>w(l),150);return()=>clearTimeout(ne)},P=[l,w],s[15]=w,s[16]=l,s[17]=_,s[18]=P):(_=s[17],P=s[18]),y.useEffect(_,P);let A,T;s[19]!==x?(A=()=>()=>x(),T=[x],s[19]=x,s[20]=A,s[21]=T):(A=s[20],T=s[21]),y.useEffect(A,T);let E;s[22]!==m||s[23]!==S||s[24]!==k?(E=ne=>{ne.key==="Escape"?(ne.preventDefault(),ne.stopPropagation(),k()):ne.key==="Enter"&&(ne.preventDefault(),ne.shiftKey?S(m-1):S(m+1))},s[22]=m,s[23]=S,s[24]=k,s[25]=E):E=s[25];const R=E;if(!i)return null;let $;s[26]===Symbol.for("react.memo_cache_sentinel")?($=ne=>c(ne.target.value),s[26]=$):$=s[26];let I;s[27]!==R||s[28]!==l?(I=r.jsx(ls,{ref:h,value:l,onChange:$,onKeyDown:R,placeholder:"Find in conversation","aria-label":"Find in conversation",autoFocus:!0}),s[27]=R,s[28]=l,s[29]=I):I=s[29];const M=l?u.length>0?`${m+1}/${u.length}`:"0/0":"";let D;s[30]!==M?(D=r.jsx(Pn,{align:"inline-end",children:r.jsx("span",{className:"min-w-12 text-center text-xs tabular-nums",children:M})}),s[30]=M,s[31]=D):D=s[31];let O;s[32]!==I||s[33]!==D?(O=r.jsxs(as,{className:"w-64",children:[I,D]}),s[32]=I,s[33]=D,s[34]=O):O=s[34];let L;s[35]!==m||s[36]!==S?(L=()=>S(m-1),s[35]=m,s[36]=S,s[37]=L):L=s[37];const F=u.length===0,z=u.length>0?"hover:text-foreground":"cursor-default opacity-40";let W;s[38]!==z?(W=q("text-muted-foreground",z),s[38]=z,s[39]=W):W=s[39];let U;s[40]===Symbol.for("react.memo_cache_sentinel")?(U=r.jsx(kr,{"data-icon":"inline-start"}),s[40]=U):U=s[40];let H;s[41]!==L||s[42]!==F||s[43]!==W?(H=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:L,disabled:F,className:W,"aria-label":"Previous match",children:U}),s[41]=L,s[42]=F,s[43]=W,s[44]=H):H=s[44];let K;s[45]!==m||s[46]!==S?(K=()=>S(m+1),s[45]=m,s[46]=S,s[47]=K):K=s[47];const V=u.length===0,Y=u.length>0?"hover:text-foreground":"cursor-default opacity-40";let G;s[48]!==Y?(G=q("text-muted-foreground",Y),s[48]=Y,s[49]=G):G=s[49];let J;s[50]===Symbol.for("react.memo_cache_sentinel")?(J=r.jsx(tt,{"data-icon":"inline-start"}),s[50]=J):J=s[50];let Q;s[51]!==K||s[52]!==V||s[53]!==G?(Q=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:K,disabled:V,className:G,"aria-label":"Next match",children:J}),s[51]=K,s[52]=V,s[53]=G,s[54]=Q):Q=s[54];let X;s[55]===Symbol.for("react.memo_cache_sentinel")?(X=r.jsx(rt,{"data-icon":"inline-start"}),s[55]=X):X=s[55];let Z;s[56]!==k?(Z=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:k,className:"text-muted-foreground hover:text-foreground","aria-label":"Close search",children:X}),s[56]=k,s[57]=Z):Z=s[57];let te;return s[58]!==O||s[59]!==H||s[60]!==Q||s[61]!==Z?(te=r.jsxs("div",{className:"motion-slide-down-in absolute right-4 top-12 z-30 flex items-center gap-1 rounded-lg border bg-popover p-2 text-popover-foreground shadow-sm",children:[O,H,Q,Z]}),s[58]=O,s[59]=H,s[60]=Q,s[61]=Z,s[62]=te):te=s[62],te});function M9(n){const e=n.parentNode;e&&(e.replaceChild(document.createTextNode(n.textContent||""),n),e.normalize())}const qL=["General","View","Tools"],Wa=[{command:"commandPalette",label:"Open command palette",description:"Search actions, projects, and recent sessions",group:"General",defaultShortcut:{key:"k",modKey:!0}},{command:"keyboardShortcuts",label:"Show keyboard shortcuts",description:"Open this reference — only while no text field is focused",group:"General",defaultShortcut:{key:"?",shiftKey:!0}},{command:"newSession",label:"Start a new session",description:"Open the project picker for a new agent session",group:"General",defaultShortcut:{key:"n",platformChord:!0}},{command:"focusComposer",label:"Focus message composer",description:"Jump to the chat composer — only while no text field is focused",group:"General",defaultShortcut:{key:" "}},{command:"prevLiveSession",label:"Focus previous live session",description:"Move focus up the live session list; press Enter to open",group:"General",defaultShortcut:{key:"arrowup",modKey:!0,shiftKey:!0}},{command:"nextLiveSession",label:"Focus next live session",description:"Move focus down the live session list; press Enter to open",group:"General",defaultShortcut:{key:"arrowdown",modKey:!0,shiftKey:!0}},{command:"recentSessionBack",label:"Previous recent session",description:"Step back through recently opened sessions",group:"General",defaultShortcut:{key:"tab",ctrlKey:!0}},{command:"recentSessionForward",label:"Next recent session",description:"Step forward through recently opened sessions",group:"General",defaultShortcut:{key:"tab",ctrlKey:!0,shiftKey:!0}},{command:"toggleSidebar",label:"Toggle session sidebar",description:"Show or hide projects and sessions",group:"View",defaultShortcut:{key:"b",modKey:!0}},{command:"missionControl",label:"Toggle Mission Control",description:"Show every live session at once and answer whatever is blocked",group:"View",defaultShortcut:{doubleTapModifier:"mod"}},{command:"toggleStats",label:"Toggle session analytics",description:"Show or hide the right analytics panel",group:"View",defaultShortcut:{key:"b",modKey:!0,shiftKey:!0}},{command:"expandAll",label:"Expand all groups",description:"Expand conversation and tool groups without opening raw payloads",group:"View",defaultShortcut:{key:"e",modKey:!0}},{command:"expandToolPayloads",label:"Expand all tool payloads",description:"Expand tool inputs, results, and diffs with their containing groups",group:"View",defaultShortcut:{key:"e",modKey:!0,shiftKey:!0}},{command:"findInConversation",label:"Find in conversation",description:"Search the open conversation and step through matches",group:"View",defaultShortcut:{key:"f",modKey:!0}},{command:"integratedTerminal",label:"Toggle integrated terminal",description:"Open or collapse the in-app project terminal",group:"Tools",defaultShortcut:{key:"j",modKey:!0}},{command:"newIntegratedTerminal",label:"New integrated terminal",description:"Create another terminal while the integrated terminal is focused",group:"Tools",defaultShortcut:{key:"n",modKey:!0}},{command:"closeIntegratedTerminal",label:"Close integrated terminal",description:"Close the active terminal while the integrated terminal is focused",group:"Tools",defaultShortcut:{key:"w",modKey:!0}},{command:"preview",label:"Toggle development preview",description:"Show or hide the in-app local server preview",group:"Tools",defaultShortcut:{key:"j",modKey:!0,shiftKey:!0}},{command:"previewRefresh",label:"Refresh development preview",description:"Reload the page while the preview toolbar is focused",group:"Tools",defaultShortcut:{key:"r",modKey:!0}},{command:"previewFocusUrl",label:"Focus preview URL",description:"Select the URL while the preview toolbar is focused",group:"Tools",defaultShortcut:{key:"l",modKey:!0}},{command:"previewZoomIn",label:"Zoom preview in",description:"Increase the preview scale while its toolbar is focused",group:"Tools",defaultShortcut:{key:"=",modKey:!0}},{command:"previewZoomOut",label:"Zoom preview out",description:"Decrease the preview scale while its toolbar is focused",group:"Tools",defaultShortcut:{key:"-",modKey:!0}},{command:"previewResetZoom",label:"Reset preview zoom",description:"Return the preview to 100% while its toolbar is focused",group:"Tools",defaultShortcut:{key:"0",modKey:!0}},{command:"projectFiles",label:"Toggle project files",description:"Browse and edit files in the active project",group:"Tools",defaultShortcut:{key:"f",modKey:!0,shiftKey:!0}},{command:"projectFileSave",label:"Save project file",description:"Save the open file while the project file workspace is focused",group:"Tools",defaultShortcut:{key:"s",modKey:!0}},{command:"systemTerminal",label:"Open system terminal",description:"Open the project in your preferred terminal app",group:"Tools",defaultShortcut:{key:"t",platformChord:!0}},{command:"themeSelector",label:"Change theme",description:"Open the theme selector",group:"Tools",defaultShortcut:{key:"s",platformChord:!0}},{command:"device.switch.1",label:"Switch to device 1",description:"Jump to this machine (the local device)",group:"General",defaultShortcut:{key:"1",platformChord:!0}},{command:"device.switch.2",label:"Switch to device 2",description:"Jump to the 2nd device in the switcher",group:"General",defaultShortcut:{key:"2",platformChord:!0}},{command:"device.switch.3",label:"Switch to device 3",description:"Jump to the 3rd device in the switcher",group:"General",defaultShortcut:{key:"3",platformChord:!0}},{command:"device.switch.4",label:"Switch to device 4",description:"Jump to the 4th device in the switcher",group:"General",defaultShortcut:{key:"4",platformChord:!0}},{command:"device.switch.5",label:"Switch to device 5",description:"Jump to the 5th device in the switcher",group:"General",defaultShortcut:{key:"5",platformChord:!0}},{command:"device.switch.6",label:"Switch to device 6",description:"Jump to the 6th device in the switcher",group:"General",defaultShortcut:{key:"6",platformChord:!0}},{command:"device.switch.7",label:"Switch to device 7",description:"Jump to the 7th device in the switcher",group:"General",defaultShortcut:{key:"7",platformChord:!0}},{command:"device.switch.8",label:"Switch to device 8",description:"Jump to the 8th device in the switcher",group:"General",defaultShortcut:{key:"8",platformChord:!0}},{command:"device.switch.9",label:"Switch to device 9",description:"Jump to the 9th device in the switcher",group:"General",defaultShortcut:{key:"9",platformChord:!0}},{command:"device.cycle",label:"Cycle devices",description:"Switch to the next device in the switcher",group:"General",defaultShortcut:{key:"0",platformChord:!0}}],i2="cogpit-keybindings";let Ms=null;function a2(n=typeof navigator>"u"?"":navigator.platform){return/Mac|iPhone|iPad/i.test(n)}function jr(n){const e=n.toLowerCase();return e==="esc"?"escape":e}function O9(n){if(!n||typeof n!="object")return!1;const e=n;return e.doubleTapModifier==="mod"||typeof e.key=="string"&&e.key.length>0}function cu(){if(Ms)return Ms;try{const n=localStorage.getItem(i2);if(!n)return Ms={};const e=JSON.parse(n);if(!e||typeof e!="object")return Ms={};const t={};for(const s of Wa){const o=e[s.command];O9(o)&&(t[s.command]=o)}return Ms=t}catch{return Ms={}}}function du(n){Ms=n;try{localStorage.setItem(i2,JSON.stringify(n))}catch{}typeof window<"u"&&window.dispatchEvent(new Event("cogpit-keybindings-changed"))}function Gr(n){const e=Wa.find(t=>t.command===n);if(!e)throw new Error(`Unknown keybinding command: ${n}`);return cu()[n]??e.defaultShortcut}function VL(){return Object.fromEntries(Wa.map(n=>[n.command,Gr(n.command)]))}function GL(n,e){const t="doubleTapModifier"in e?{...e}:{...e,key:jr(e.key)};du({...cu(),[n]:t})}function YL(n){const e={...cu()};delete e[n],du(e)}function XL(){du({})}function JL(n){return{key:jr(n.key),metaKey:n.metaKey||void 0,ctrlKey:n.ctrlKey||void 0,shiftKey:n.shiftKey||void 0,altKey:n.altKey||void 0}}function l2(n){const e=n;if(!e)return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||e.isContentEditable===!0}function kt(n,e){const t=Gr(n);return"doubleTapModifier"in t||jr(e.key)!==jr(t.key)?!1:t.modKey?e.metaKey===e.ctrlKey?!1:e.shiftKey===!!t.shiftKey&&e.altKey===!!t.altKey:t.platformChord?e.ctrlKey&&e.metaKey!==e.altKey&&e.shiftKey===!!t.shiftKey:e.metaKey===!!t.metaKey&&e.ctrlKey===!!t.ctrlKey&&e.shiftKey===!!t.shiftKey&&e.altKey===!!t.altKey}function io(n){return n===" "?"Space":n==="escape"?"Esc":n==="tab"?"Tab":n==="arrowup"?"↑":n==="arrowdown"?"↓":n==="arrowleft"?"←":n==="arrowright"?"→":n.length===1?n.toUpperCase():n}function D9(n){const e=a2();return"doubleTapModifier"in n?e?"Double ⌘":"Double Ctrl":n.modKey?e?`${n.shiftKey?"⇧":""}⌘${io(n.key)}`:`Ctrl+${n.shiftKey?"Shift+":""}${io(n.key)}`:n.platformChord?e?`⌃⌘${n.shiftKey?"⇧":""}${io(n.key)}`:`Ctrl+Alt+${n.shiftKey?"Shift+":""}${io(n.key)}`:e?`${n.ctrlKey?"⌃":""}${n.altKey?"⌥":""}${n.shiftKey?"⇧":""}${n.metaKey?"⌘":""}${io(n.key)}`:[n.ctrlKey?"Ctrl":null,n.altKey?"Alt":null,n.shiftKey?"Shift":null,n.metaKey?"Meta":null,io(n.key)].filter(Boolean).join("+")}function Ml(n){return D9(Gr(n))}function zp(n){if("doubleTapModifier"in n)return[`double-tap:${n.doubleTapModifier}`];const e=(t,s,o,i)=>`${jr(n.key)}|${t}|${s}|${o}|${i}`;return n.modKey?[e(!0,!1,!!n.shiftKey,!!n.altKey),e(!1,!0,!!n.shiftKey,!!n.altKey)]:n.platformChord?[e(!0,!0,!!n.shiftKey,!1),e(!1,!0,!!n.shiftKey,!0)]:[e(!!n.metaKey,!!n.ctrlKey,!!n.shiftKey,!!n.altKey)]}function QL(n,e){const t=new Set(zp(n));return Wa.find(s=>s.command!==e&&zp(Gr(s.command)).some(o=>t.has(o)))??null}function Fp(n){return"doubleTapModifier"in Gr(n)?a2()?"Meta":"Control":null}const L9=["device.switch.1","device.switch.2","device.switch.3","device.switch.4","device.switch.5","device.switch.6","device.switch.7","device.switch.8","device.switch.9"],z9="device.cycle";function F9(n){const e=L9.findIndex(t=>kt(t,n));return e===-1?null:e+1}function B9(n){return kt(z9,n)}const Ec="cogpit:find-in-conversation",Ha=y.memo(function(e){const t=B.c(85),{searchInputRef:s,hasTodos:o,hasMore:i,isLoadingOlder:a,onLoadMore:l,mobileSearchOpen:c,onMobileSearchClose:d}=e,u=c===void 0?!1:c,{state:f,dispatch:m,isMobile:p}=zt(),{session:h}=it(),{chat:g,scroll:x}=$r(),{searchQuery:b}=f,{pendingMessages:w}=g,{chatScrollRef:v,scrollEndRef:S,handleScroll:j,canScrollDown:k,scrollToBottomInstant:C,initialScrollDone:N}=x,_=y.useRef(null);let P;t[0]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{var me;return(me=_.current)==null?void 0:me.open()},t[0]=P):P=t[0];const A=P;let T,E;t[1]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{const me=function(Se){kt("findInConversation",Se)&&(Se.preventDefault(),A())};return window.addEventListener("keydown",me),window.addEventListener(Ec,A),()=>{window.removeEventListener("keydown",me),window.removeEventListener(Ec,A)}},E=[A],t[1]=T,t[2]=E):(T=t[1],E=t[2]),y.useEffect(T,E);let R,$;t[3]!==p||t[4]!==u||t[5]!==s?(R=()=>{!p||!u||requestAnimationFrame(()=>{var me;return(me=s.current)==null?void 0:me.focus()})},$=[p,u,s],t[3]=p,t[4]=u,t[5]=s,t[6]=R,t[7]=$):(R=t[6],$=t[7]),y.useEffect(R,$);let I;t[8]!==m?(I=me=>m({type:"JUMP_TO_TURN",index:me}),t[8]=m,t[9]=I):I=t[9];const M=I;let D;t[10]!==m||t[11]!==d?(D=()=>{m({type:"SET_SEARCH_QUERY",value:""}),d==null||d()},t[10]=m,t[11]=d,t[12]=D):D=t[12];const O=D,L=h,F=L.turns.length>0||w.length===0,z=p?"flex min-h-0 flex-1 flex-col":"min-h-0 flex-1";let W;t[13]!==z?(W=q("relative bg-background",z),t[13]=z,t[14]=W):W=t[14];let U;t[15]!==O||t[16]!==m||t[17]!==p||t[18]!==u||t[19]!==s||t[20]!==b?(U=p&&u&&r.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b bg-background px-3 py-2",children:[r.jsxs(as,{className:"h-9 flex-1",children:[r.jsx(ls,{ref:s,value:b,onChange:me=>m({type:"SET_SEARCH_QUERY",value:me.target.value}),placeholder:"Search conversation...","aria-label":"Search conversation"}),r.jsx(Pn,{align:"inline-start",children:r.jsx(gn,{})})]}),r.jsx(ee,{variant:"ghost",size:"icon-sm",onClick:O,"aria-label":"Close conversation search",children:r.jsx(rt,{"data-icon":"inline-start"})})]}),t[15]=O,t[16]=m,t[17]=p,t[18]=u,t[19]=s,t[20]=b,t[21]=U):U=t[21];const H=p?"flex-1 min-h-0":"h-full";let K;t[22]!==H?(K=q("relative",H),t[22]=H,t[23]=K):K=t[23];let V;t[24]!==v?(V=r.jsx($9,{ref:_,scrollContainerRef:v}),t[24]=v,t[25]=V):V=t[25];let Y;t[26]!==v||t[27]!==L.turns||t[28]!==M||t[29]!==p?(Y=!p&&r.jsx(A9,{turns:L.turns,scrollContainerRef:v,onJumpToTurn:M}),t[26]=v,t[27]=L.turns,t[28]=M,t[29]=p,t[30]=Y):Y=t[30];let G;t[31]!==v||t[32]!==L?(G=r.jsx(j9,{session:L,scrollContainerRef:v}),t[31]=v,t[32]=L,t[33]=G):G=t[33];const J=p&&"mobile-scroll";let Q;t[34]!==J?(Q=q("h-full overflow-x-hidden overflow-y-auto bg-background",J),t[34]=J,t[35]=Q):Q=t[35];let X;t[36]!==o||t[37]!==p?(X=p?"px-3 py-3 pb-5":q("mx-auto w-full max-w-[var(--chat-width)] px-6 pt-14",o?"pb-48":"pb-32"),t[36]=o,t[37]=p,t[38]=X):X=t[38];let Z;t[39]!==v||t[40]!==i||t[41]!==N||t[42]!==a||t[43]!==l||t[44]!==F?(Z=F&&r.jsx(h9,{chatScrollRef:v,hasMore:i,isLoadingOlder:a,pagingEnabled:N,onLoadMore:l}),t[39]=v,t[40]=i,t[41]=N,t[42]=a,t[43]=l,t[44]=F,t[45]=Z):Z=t[45];let te;t[46]===Symbol.for("react.memo_cache_sentinel")?(te=r.jsx(N9,{}),t[46]=te):te=t[46];let ne;if(t[47]!==L.turns.length||t[48]!==w){let me;t[50]!==L.turns.length?(me=(je,Se)=>r.jsx(Vx,{message:je,turnNumber:L.turns.length+1+Se},Se),t[50]=L.turns.length,t[51]=me):me=t[51],ne=w.map(me),t[47]=L.turns.length,t[48]=w,t[49]=ne}else ne=t[49];let re;t[52]===Symbol.for("react.memo_cache_sentinel")?(re=r.jsx(PE,{}),t[52]=re):re=t[52];let ie;t[53]!==S?(ie=r.jsx("div",{ref:S}),t[53]=S,t[54]=ie):ie=t[54];let ae;t[55]!==Z||t[56]!==ne||t[57]!==ie?(ae=r.jsxs(R9,{fallbackMessage:"Failed to render conversation timeline",children:[Z,te,ne,re,ie]}),t[55]=Z,t[56]=ne,t[57]=ie,t[58]=ae):ae=t[58];let se;t[59]!==X||t[60]!==ae?(se=r.jsx("div",{className:X,children:ae}),t[59]=X,t[60]=ae,t[61]=se):se=t[61];let ue;t[62]!==v||t[63]!==j||t[64]!==Q||t[65]!==se?(ue=r.jsx("div",{ref:v,onScroll:j,className:Q,children:se}),t[62]=v,t[63]=j,t[64]=Q,t[65]=se,t[66]=ue):ue=t[66];const le=k?"opacity-100 scale-100":"opacity-0 scale-75 pointer-events-none",de=p?"right-3 bottom-3":"right-5 bottom-5";let pe;t[67]!==le||t[68]!==de?(pe=q("absolute rounded-full shadow-sm transition-[opacity,transform] duration-200 ease-out active:scale-95",le,de),t[67]=le,t[68]=de,t[69]=pe):pe=t[69];let he;t[70]===Symbol.for("react.memo_cache_sentinel")?(he=r.jsx(s3,{"data-icon":"inline-start"}),t[70]=he):he=t[70];let ce;t[71]!==C||t[72]!==pe?(ce=r.jsx(ee,{size:"icon",className:pe,onClick:C,"aria-label":"Scroll to bottom",children:he}),t[71]=C,t[72]=pe,t[73]=ce):ce=t[73];let ye;t[74]!==K||t[75]!==V||t[76]!==Y||t[77]!==G||t[78]!==ue||t[79]!==ce?(ye=r.jsxs("div",{className:K,children:[V,Y,G,ue,ce]}),t[74]=K,t[75]=V,t[76]=Y,t[77]=G,t[78]=ue,t[79]=ce,t[80]=ye):ye=t[80];let xe;return t[81]!==W||t[82]!==U||t[83]!==ye?(xe=r.jsxs("div",{className:W,children:[U,ye]}),t[81]=W,t[82]=U,t[83]=ye,t[84]=xe):xe=t[84],xe}),Pc="cogpit-devices-changed",c2="cogpit:devices-changed";function d2(n){typeof n.connectionRevision=="number"&&Uw(n.id,n.connectionRevision)}function u2(n,e,t=!1){window.dispatchEvent(new CustomEvent(Pc,{detail:{deviceId:n,connectionRevision:e,removed:t}}));try{localStorage.setItem(c2,JSON.stringify({deviceId:n,connectionRevision:e,removed:t,nonce:`${Date.now()}:${Math.random()}`}))}catch{}}function Bp(n){d2(n),u2(n.id,n.connectionRevision)}function Ol(n,e=""){return`/api/hub/devices/${encodeURIComponent(n)}${e}`}async function ao(n){try{const e=await n.json();return e&&typeof e=="object"?e:null}catch{return null}}function f2(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.version;if(typeof t=="string")return t}}function U9(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.edition;if(t==="team"||t==="personal")return t}}function Ka(){const[n,e]=y.useState([]),[t,s]=y.useState(!0),[o,i]=y.useState(()=>yt()),a=y.useRef(0),l=y.useCallback(async()=>{const h=++a.current;try{const g=await fs("/api/hub/devices");if(!g.ok)return;const x=await ao(g);if(h!==a.current)return;const b=Array.isArray(x==null?void 0:x.devices)?x.devices:[];for(const w of b)d2(w);e(b)}catch{}finally{h===a.current&&s(!1)}},[]);y.useEffect(()=>{l()},[l]),y.useEffect(()=>{const h=()=>i(yt()),g=()=>void l(),x=v=>{if(v.key===c2){try{const S=JSON.parse(v.newValue??"null");(S==null?void 0:S.removed)===!0&&typeof S.deviceId=="string"&&yt()===S.deviceId&&Ss(Ct)}catch{}l()}},b=()=>{a.current+=1,e([]),s(!0),l()},w=()=>{a.current+=1,e([]),s(!1)};return window.addEventListener("cogpit-device-changed",h),window.addEventListener("popstate",h),window.addEventListener(Pc,g),window.addEventListener("storage",x),window.addEventListener("cogpit-auth-changed",b),window.addEventListener("cogpit-identity-changed",b),window.addEventListener("cogpit-auth-required",w),()=>{window.removeEventListener("cogpit-device-changed",h),window.removeEventListener("popstate",h),window.removeEventListener(Pc,g),window.removeEventListener("storage",x),window.removeEventListener("cogpit-auth-changed",b),window.removeEventListener("cogpit-identity-changed",b),window.removeEventListener("cogpit-auth-required",w)}},[l]);const c=y.useMemo(()=>o===Ct?void 0:n.find(h=>h.id===o),[n,o]),d=y.useCallback(async(h,g,x,b)=>{try{const w=await fs("/api/hub/devices/probe",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:h,port:g,allowLocalTunnel:x,tls:b})}),v=await ao(w);return(v==null?void 0:v.ok)===!0&&v.hello?{ok:!0,hello:v.hello}:{ok:!1,code:(v==null?void 0:v.code)??"UNREACHABLE",error:typeof(v==null?void 0:v.error)=="string"?v.error:void 0}}catch{return{ok:!1,code:"UNREACHABLE",error:"Could not reach the device."}}},[]),u=y.useCallback(async h=>{try{const g=await fs("/api/hub/devices",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(h)}),x=await ao(g);if(g.ok&&(x!=null&&x.device)){const b=x.device;return Bp(b),{ok:!0,device:b}}return{ok:!1,code:(x==null?void 0:x.code)??"ERROR",error:typeof(x==null?void 0:x.error)=="string"?x.error:"Could not add the device."}}catch{return{ok:!1,code:"ERROR",error:"Could not add the device."}}},[]),f=y.useCallback(async(h,g)=>{try{const x=await fs(Ol(h),{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(g)}),b=await ao(x);if(x.ok&&(b!=null&&b.device)){const w=b.device;return Bp(w),{ok:!0,device:w}}return{ok:!1,code:(b==null?void 0:b.code)??"ERROR",error:typeof(b==null?void 0:b.error)=="string"?b.error:"Could not update the device."}}catch{return{ok:!1,code:"ERROR",error:"Could not update the device."}}},[]),m=y.useCallback(async h=>{try{const g=await fs(Ol(h),{method:"DELETE"});if(g.ok)return yt()===h&&Ss(Ct),u2(h,void 0,!0),{ok:!0};const x=await ao(g);return{ok:!1,error:typeof(x==null?void 0:x.error)=="string"?x.error:"Could not remove the device."}}catch{return{ok:!1,error:"Could not remove the device."}}},[]),p=y.useCallback(async h=>{try{const g=await fs(Ol(h,"/test"),{method:"POST"});return await ao(g)??{ok:!1,reachable:!1,code:"UNREACHABLE"}}catch{return{ok:!1,reachable:!1,code:"UNREACHABLE"}}},[]);return{devices:n,activeDeviceId:o,activeDevice:c,loading:t,refresh:l,probe:d,addDevice:u,updateDevice:f,removeDevice:m,testDevice:p}}const W9=/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/;function Up(n,e){if(!W9.test(e))throw new Error(`Invalid Cogpit ${n} id "${e}"`)}function Go(n,e){return`${n}.${e}`}function H9(n){const e=new Set,t=new Set,s=[];for(const o of n){if(Up("plugin",o.id),e.has(o.id))throw new Error(`Duplicate Cogpit plugin id "${o.id}"`);e.add(o.id);for(const i of o.workspacePanels??[]){Up("panel",i.id);const a=Go(o.id,i.id);if(t.has(a))throw new Error(`Duplicate Cogpit workspace panel id "${a}"`);t.add(a),s.push({...i,id:a,pluginId:o.id,localId:i.id})}}return s.sort((o,i)=>(o.order??100)-(i.order??100)||o.title.localeCompare(i.title))}function Ut(n){const e=B.c(13);let t,s,o,i;e[0]!==n?({pressed:o,className:s,children:t,...i}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);const a=o?"border-foreground/20 bg-foreground/[0.06] text-foreground":"border-transparent text-muted-foreground hover:bg-accent hover:text-foreground";let l;e[5]!==s||e[6]!==a?(l=q("inline-flex h-6 shrink-0 items-center gap-1 rounded-full border px-2 text-[11px] leading-none outline-none transition-colors","focus-visible:ring-[3px] focus-visible:ring-ring/20 disabled:opacity-40",a,s),e[5]=s,e[6]=a,e[7]=l):l=e[7];let c;return e[8]!==t||e[9]!==o||e[10]!==i||e[11]!==l?(c=r.jsx("button",{type:"button","aria-pressed":o,className:l,...i,children:t}),e[8]=t,e[9]=o,e[10]=i,e[11]=l,e[12]=c):c=e[12],c}function Wt(n){const e=B.c(2),{children:t}=n;let s;return e[0]!==t?(s=r.jsx("span",{className:"font-mono text-[10px] tabular-nums opacity-70",children:t}),e[0]=t,e[1]=s):s=e[1],s}function ft(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("rounded-md bg-muted motion-safe:animate-in motion-safe:fade-in-0 motion-safe:duration-200 motion-safe:ease-out motion-reduce:animate-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"skeleton",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const Yo="cogpit",Pt={worktrees:Go(Yo,"worktrees"),projectFiles:Go(Yo,"project-files"),fileChanges:Go(Yo,"file-changes"),sessionInfo:Go(Yo,"session-info")},K9=y.lazy(()=>qe(()=>import("./CommandPaletteHost-DU1jhhYG.js"),__vite__mapDeps([25,1,2,3,4])).then(n=>({default:n.CommandPaletteHost}))),q9=y.lazy(()=>qe(()=>import("./index-XlQRZ_Un.js"),__vite__mapDeps([26,1,2,3,4])).then(n=>({default:n.ConfigDialog}))),V9=y.lazy(()=>qe(()=>Promise.resolve().then(()=>uP),void 0).then(n=>({default:n.DevicesDialog}))),G9=y.lazy(()=>qe(()=>import("./KeyboardShortcutsDialog-DtTE4xjZ.js"),__vite__mapDeps([27,1,2,3,4])).then(n=>({default:n.KeyboardShortcutsDialog}))),Y9=y.lazy(()=>qe(()=>import("./ProjectSwitcherModal-UUQMoktd.js"),__vite__mapDeps([28,1,2,3,4])).then(n=>({default:n.ProjectSwitcherModal}))),X9=y.lazy(()=>qe(()=>import("./ThemeSelectorModal-rFVnzZuC.js"),__vite__mapDeps([29,1,2,3,4])).then(n=>({default:n.ThemeSelectorModal})));function J9(n){const e=B.c(116),{navigation:t,project:s,chrome:o}=n,{state:i,config:a,theme:l}=zt(),{session:c,sessionSource:d}=it(),{devices:u,activeDeviceId:f}=Ka(),[m,p]=y.useState(null),[h,g]=y.useState(null);let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=lt("manageDevices"),e[0]=x):x=e[0];const b=x;let w;e[1]!==i.pendingCwd||e[2]!==i.pendingDirName?(w=i.pendingCwd??(i.pendingDirName?_n(i.pendingDirName):null),e[1]=i.pendingCwd,e[2]=i.pendingDirName,e[3]=w):w=e[3];const v=w,S=(d==null?void 0:d.dirName)??i.pendingDirName??i.dashboardProject??null,j=m??h;let k,C;e[4]!==m?(k=()=>{m&&g(m)},C=[m],e[4]=m,e[5]=k,e[6]=C):(k=e[5],C=e[6]),y.useEffect(k,C);const N=o.onKeyboardShortcutsOpenChange;let _,P;e[7]!==N?(_=()=>{const Ee=function(He){kt("keyboardShortcuts",He)&&(l2(document.activeElement)||(He.preventDefault(),N(!0)))};return window.addEventListener("keydown",Ee),()=>window.removeEventListener("keydown",Ee)},P=[N],e[7]=N,e[8]=_,e[9]=P):(_=e[8],P=e[9]),y.useEffect(_,P);const A=f===Ct;let T;e[10]!==A?(T={id:Ct,name:"This machine",isLocal:!0,isActive:A},e[10]=A,e[11]=T):T=e[11];let E;if(e[12]!==f||e[13]!==u||e[14]!==T){let Ee;e[16]!==f?(Ee=$e=>({id:$e.id,name:$e.name,isLocal:!1,isActive:$e.id===f}),e[16]=f,e[17]=Ee):Ee=e[17],E=[T,...u.map(Ee)],e[12]=f,e[13]=u,e[14]=T,e[15]=E}else E=e[15];const R=E;let $;e[18]!==c||e[19]!==(d==null?void 0:d.agentKind)||e[20]!==(d==null?void 0:d.dirName)?($=()=>{if(!c)return;const Ee=(d==null?void 0:d.agentKind)??Et((d==null?void 0:d.dirName)??null);Ar(hg(Ee,c.sessionId,c.cwd))},e[18]=c,e[19]=d==null?void 0:d.agentKind,e[20]=d==null?void 0:d.dirName,e[21]=$):$=e[21];const I=$,M=Q9,D=o.processPanel,O=o.workflowsPanel,L=o.undoDialog,F=o.branchModal,z=a.claudeDir??"";let W;e[22]!==a.handleCloseConfigDialog||e[23]!==a.handleConfigSaved||e[24]!==a.showConfigDialog||e[25]!==z?(W=r.jsx(y.Suspense,{fallback:null,children:r.jsx(q9,{open:a.showConfigDialog,currentPath:z,onClose:a.handleCloseConfigDialog,onSaved:a.handleConfigSaved})}),e[22]=a.handleCloseConfigDialog,e[23]=a.handleConfigSaved,e[24]=a.showConfigDialog,e[25]=z,e[26]=W):W=e[26];const U=(d==null?void 0:d.dirName)??i.pendingDirName??null,H=(c==null?void 0:c.cwd)??i.pendingCwd??null;let K;e[27]!==a.defaultAgentKind||e[28]!==t.onStartNewFolder||e[29]!==t.onStartNewSession||e[30]!==t.panels.handleCloseProjectSwitcher||e[31]!==t.panels.showProjectSwitcher||e[32]!==U||e[33]!==H?(K=r.jsx(y.Suspense,{fallback:null,children:r.jsx(Y9,{open:t.panels.showProjectSwitcher,onClose:t.panels.handleCloseProjectSwitcher,onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:a.defaultAgentKind,currentProjectDirName:U,currentProjectCwd:H})}),e[27]=a.defaultAgentKind,e[28]=t.onStartNewFolder,e[29]=t.onStartNewSession,e[30]=t.panels.handleCloseProjectSwitcher,e[31]=t.panels.showProjectSwitcher,e[32]=U,e[33]=H,e[34]=K):K=e[34];let V;e[35]!==t.panels.handleCloseThemeSelector||e[36]!==t.panels.showThemeSelector||e[37]!==l.setPreview||e[38]!==l.setTheme||e[39]!==l.theme?(V=r.jsx(y.Suspense,{fallback:null,children:r.jsx(X9,{open:t.panels.showThemeSelector,onClose:t.panels.handleCloseThemeSelector,currentTheme:l.theme,onSelectTheme:l.setTheme,onPreviewTheme:l.setPreview})}),e[35]=t.panels.handleCloseThemeSelector,e[36]=t.panels.showThemeSelector,e[37]=l.setPreview,e[38]=l.setTheme,e[39]=l.theme,e[40]=V):V=e[40];const Y=o.commandPaletteOpen,G=o.onCommandPaletteOpenChange,J=t.actions.handleGoHome,Q=t.panels.handleOpenProjectSwitcher,X=t.onOpenPaletteProject,Z=t.actions.handleDashboardSelect,te=t.panels.handleToggleSidebar;let ne,re,ie;e[41]!==t.panels?(ne=()=>t.panels.toggleWorkspacePanel(Pt.sessionInfo),re=()=>t.panels.toggleWorkspacePanel(Pt.fileChanges),ie=()=>t.panels.toggleWorkspacePanel(Pt.worktrees),e[41]=t.panels,e[42]=ne,e[43]=re,e[44]=ie):(ne=e[42],re=e[43],ie=e[44]);const ae=t.panels.handleToggleMission,se=c?t.handlers.handleDuplicateSession:void 0,ue=c?I:void 0,le=c?M:void 0,de=lt("killAny")?o.onKillAll:void 0,pe=lt("configWrite")?t.panels.handleToggleConfig:void 0,he=a.openConfigDialog;let ce;e[45]!==N?(ce=()=>N(!0),e[45]=N,e[46]=ce):ce=e[46];const ye=s.currentCwd?s.onTogglePreview:void 0,xe=lt("hostFiles")&&s.currentCwd?s.onToggleProjectFiles:void 0,me=t.panels.handleToggleThemeSelector,je=s.onOpenTerminal,Se=o.onFocusComposer,Pe=o.onExpandAll,Re=o.onExpandToolPayloads,Ie=o.onCollapseAll,De=!!(c||i.pendingDirName);let Le;e[47]!==v||e[48]!==(c==null?void 0:c.cwd)||e[49]!==(d==null?void 0:d.dirName)||e[50]!==i.dashboardProject||e[51]!==i.pendingDirName?(Le=lt("terminal")&&!!((c==null?void 0:c.cwd)??v??(d==null?void 0:d.dirName)??i.pendingDirName??i.dashboardProject),e[47]=v,e[48]=c==null?void 0:c.cwd,e[49]=d==null?void 0:d.dirName,e[50]=i.dashboardProject,e[51]=i.pendingDirName,e[52]=Le):Le=e[52];const ze=!!c;let Te;e[53]!==s.hasFileChanges?(Te=lt("hostFiles")&&s.hasFileChanges,e[53]=s.hasFileChanges,e[54]=Te):Te=e[54];const Ce=t.panels.activeWorkspacePanel===Pt.sessionInfo,We=t.panels.activeWorkspacePanel===Pt.fileChanges,Fe=t.panels.activeWorkspacePanel===Pt.worktrees,Ne=i.mainView==="config",fe=i.mainView==="mission",Oe=(c==null?void 0:c.cwd)??v??null;let Ae;e[55]!==o.commandPaletteOpen||e[56]!==o.onCollapseAll||e[57]!==o.onCommandPaletteOpenChange||e[58]!==o.onExpandAll||e[59]!==o.onExpandToolPayloads||e[60]!==o.onFocusComposer||e[61]!==a.openConfigDialog||e[62]!==S||e[63]!==t.actions.handleDashboardSelect||e[64]!==t.actions.handleGoHome||e[65]!==t.onOpenPaletteProject||e[66]!==t.panels.handleOpenProjectSwitcher||e[67]!==t.panels.handleToggleMission||e[68]!==t.panels.handleToggleSidebar||e[69]!==t.panels.handleToggleThemeSelector||e[70]!==t.panels.showSidebar||e[71]!==R||e[72]!==s.launchTerminalRequest||e[73]!==s.onOpenTerminal||e[74]!==s.processPanel.addProcess||e[75]!==s.showProjectFiles||e[76]!==s.supportsWorktrees||e[77]!==ne||e[78]!==re||e[79]!==ie||e[80]!==se||e[81]!==ue||e[82]!==le||e[83]!==de||e[84]!==pe||e[85]!==ce||e[86]!==ye||e[87]!==xe||e[88]!==De||e[89]!==Le||e[90]!==ze||e[91]!==Te||e[92]!==Ce||e[93]!==We||e[94]!==Fe||e[95]!==Ne||e[96]!==fe||e[97]!==Oe?(Ae=r.jsx(y.Suspense,{fallback:null,children:r.jsx(K9,{open:Y,onOpenChange:G,onGoHome:J,onNewSession:Q,onOpenProject:X,onOpenSession:Z,onToggleSidebar:te,onToggleStats:ne,onToggleFileChanges:re,onToggleWorktrees:ie,onToggleMissionControl:ae,onDuplicateSession:se,onCopyResumeCommand:ue,onFindInConversation:le,onKillAll:de,onOpenConfig:pe,onOpenSettings:he,onOpenKeyboardShortcuts:ce,onTogglePreview:ye,onToggleProjectFiles:xe,onOpenTheme:me,onOpenTerminal:je,onOpenDevices:b?p:void 0,onSwitchDevice:Ss,devices:R,onFocusComposer:Se,onExpandAll:Pe,onExpandToolPayloads:Re,onCollapseAll:Ie,canFocusComposer:De,canOpenTerminal:Le,hasSession:ze,hasFileChanges:Te,supportsWorktrees:s.supportsWorktrees,showSidebar:t.panels.showSidebar,showStats:Ce,showProjectFiles:s.showProjectFiles,showFileChanges:We,showWorktrees:Fe,showConfig:Ne,showMission:fe,currentProjectDirName:S,projectCwd:Oe,onProcessStarted:s.processPanel.addProcess,launchTerminalRequest:s.launchTerminalRequest})}),e[55]=o.commandPaletteOpen,e[56]=o.onCollapseAll,e[57]=o.onCommandPaletteOpenChange,e[58]=o.onExpandAll,e[59]=o.onExpandToolPayloads,e[60]=o.onFocusComposer,e[61]=a.openConfigDialog,e[62]=S,e[63]=t.actions.handleDashboardSelect,e[64]=t.actions.handleGoHome,e[65]=t.onOpenPaletteProject,e[66]=t.panels.handleOpenProjectSwitcher,e[67]=t.panels.handleToggleMission,e[68]=t.panels.handleToggleSidebar,e[69]=t.panels.handleToggleThemeSelector,e[70]=t.panels.showSidebar,e[71]=R,e[72]=s.launchTerminalRequest,e[73]=s.onOpenTerminal,e[74]=s.processPanel.addProcess,e[75]=s.showProjectFiles,e[76]=s.supportsWorktrees,e[77]=ne,e[78]=re,e[79]=ie,e[80]=se,e[81]=ue,e[82]=le,e[83]=de,e[84]=pe,e[85]=ce,e[86]=ye,e[87]=xe,e[88]=De,e[89]=Le,e[90]=ze,e[91]=Te,e[92]=Ce,e[93]=We,e[94]=Fe,e[95]=Ne,e[96]=fe,e[97]=Oe,e[98]=Ae):Ae=e[98];let Be;e[99]!==o.keyboardShortcutsOpen||e[100]!==N?(Be=r.jsx(y.Suspense,{fallback:null,children:r.jsx(G9,{open:o.keyboardShortcutsOpen,onOpenChange:N})}),e[99]=o.keyboardShortcutsOpen,e[100]=N,e[101]=Be):Be=e[101];let oe;e[102]!==m||e[103]!==j?(oe=b&&j!==null&&r.jsx(y.Suspense,{fallback:null,children:r.jsx(V9,{open:m!==null,initialMode:j,onClose:()=>p(null),onCloseComplete:()=>g(null)})}),e[102]=m,e[103]=j,e[104]=oe):oe=e[104];let ge;return e[105]!==o.branchModal||e[106]!==o.processPanel||e[107]!==o.undoDialog||e[108]!==o.workflowsPanel||e[109]!==W||e[110]!==K||e[111]!==V||e[112]!==Ae||e[113]!==Be||e[114]!==oe?(ge=r.jsxs(r.Fragment,{children:[D,O,L,F,W,K,V,Ae,Be,oe]}),e[105]=o.branchModal,e[106]=o.processPanel,e[107]=o.undoDialog,e[108]=o.workflowsPanel,e[109]=W,e[110]=K,e[111]=V,e[112]=Ae,e[113]=Be,e[114]=oe,e[115]=ge):ge=e[115],ge}function Q9(){window.dispatchEvent(new Event(Ec))}function Dl(n){const e=B.c(10),{reason:t,children:s}=n;if(!t)return s;let o;e[0]!==t?(o=r.jsx("span",{className:"inline-flex",tabIndex:0,"aria-label":t}),e[0]=t,e[1]=o):o=e[1];let i;e[2]!==s||e[3]!==o?(i=r.jsx(Rt,{render:o,children:s}),e[2]=s,e[3]=o,e[4]=i):i=e[4];let a;e[5]!==t?(a=r.jsx(It,{children:t}),e[5]=t,e[6]=a):a=e[6];let l;return e[7]!==i||e[8]!==a?(l=r.jsxs(At,{children:[i,a]}),e[7]=i,e[8]=a,e[9]=l):l=e[9],l}const Z9="2.4.0",m2={version:Z9},eP=m2.version,tP=19384,nP=443,sP=450,oP=typeof navigator<"u"&&/Mac|iPhone|iPad/i.test(navigator.platform||""),rP=`${oP?"⌘⇧":"Ctrl+Shift+"}1–9`,iP=new Set(["BAD_PASSWORD","PASSWORD_REQUIRED","USERNAME_REQUIRES_PASSWORD"]),aP=new Set(["ACCOUNT_DISABLED"]);function Xo(n){const e=n.trim(),t=/^https:\/\//i.test(e),s=e.replace(/^https?:\/\//i,"").replace(/\/.*$/,""),o=/^(.+):(\d+)$/.exec(s),i=o?o[1]:s,a=o?Number(o[2]):void 0;return t?{host:i,port:a,tls:!0}:{host:i,port:a}}function p2(n,e,t){if(n.ok){if(n.hello.edition==="team"&&n.hello.needsBootstrap===!0)return{tone:"info",text:"Reachable team server — create its first admin account before adding it here."};if(n.hello.edition!=="team"&&n.hello.networkAccess===!1)return{tone:"warn",text:"Cogpit is running but network access is disabled — enable it in that device's settings."};if(n.hello.configured===!1)return{tone:"info",text:"Reachable — this device hasn't finished setup yet and will show its setup screen."};const s=n.hello.name?` "${n.hello.name}"`:"",o=n.hello.version?` (v${n.hello.version})`:"";return{tone:"ok",text:`Found Cogpit${s}${o}.`}}switch(n.code){case"UNREACHABLE":return{tone:"error",text:`Can't reach ${e}:${t}. Is Cogpit running with network access enabled?`};case"LEGACY_NO_HELLO":return{tone:"error",text:"That Cogpit is too old for multi-device — update it."};case"NOT_COGPIT":return{tone:"error",text:"Something responded, but it isn't Cogpit."};case"SELF_ADD":return{tone:"error",text:"That's this machine."};default:return{tone:"error",text:n.error??"Could not reach the device."}}}const h2={ok:"text-success",warn:"text-warning",info:"text-info",error:"text-destructive"};function lP(n){const e=B.c(10),{tone:t}=n,s=h2[t];let o;e[0]!==s?(o=q("size-3.5 shrink-0",s),e[0]=s,e[1]=o):o=e[1];const i=o;if(t==="ok"){let l;return e[2]!==i?(l=r.jsx(Bn,{"data-icon":"inline-start",className:i}),e[2]=i,e[3]=l):l=e[3],l}if(t==="warn"){let l;return e[4]!==i?(l=r.jsx(xn,{"data-icon":"inline-start",className:i}),e[4]=i,e[5]=l):l=e[5],l}if(t==="info"){let l;return e[6]!==i?(l=r.jsx(Ot,{"data-icon":"inline-start",className:i}),e[6]=i,e[7]=l):l=e[7],l}let a;return e[8]!==i?(a=r.jsx(Ys,{"data-icon":"inline-start",className:i}),e[8]=i,e[9]=a):a=e[9],a}const cP={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"};function dP({device:n,hubVersion:e,onRename:t,onCredentials:s,onRemove:o,onTest:i}){const[a,l]=y.useState(!1),[c,d]=y.useState(n.name),[u,f]=y.useState(!1),[m,p]=y.useState(n.username??""),[h,g]=y.useState(""),[x,b]=y.useState(null),[w,v]=y.useState(!1),[S,j]=y.useState(null);y.useEffect(()=>{d(n.name)},[n.name]),y.useEffect(()=>{p(n.username??"")},[n.username]);const k=f2(n),C=k!==void 0&&k!==e,N=U9(n)==="team";async function _(){const A=c.trim();if(!A||A===n.name){l(!1),d(n.name);return}j("rename"),await t(n.id,A),j(null),l(!1)}async function P(){const A=m.trim(),T=n.username??"",E=A!==T,R=h.length>0;if(!E&&!R){f(!1),g(""),b(null);return}if(n.auth==="none"&&!R){b("Enter a password when adding an account to an unauthenticated device.");return}const $={};E&&($.username=A||null),R&&($.password=h),j("credentials"),b(null);const I=await s(n.id,$);if(j(null),!I.ok){b(I.error);return}f(!1),g("")}return r.jsxs("div",{className:"rounded-lg border bg-card",children:[r.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2",children:[r.jsx("span",{"aria-label":`Status: ${n.runtime.authState}`,className:q("size-2 shrink-0 rounded-full",cP[n.runtime.authState])}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[a?r.jsx(Ht,{value:c,autoFocus:!0,"aria-label":`Rename ${n.name}`,onChange:A=>d(A.target.value),onKeyDown:A=>{A.key==="Enter"&&_(),A.key==="Escape"&&(l(!1),d(n.name))},onBlur:()=>void _(),className:"h-6 text-sm"}):r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"truncate text-sm text-foreground",children:n.name}),k&&r.jsxs("span",{className:q("shrink-0 font-mono text-xs",C?"text-warning":"text-muted-foreground"),title:C?`Device runs v${k}; hub runs v${e}`:void 0,children:["v",k,C&&" ≠ hub"]}),n.auth==="none"&&r.jsx(_e,{variant:"secondary",children:"Unauthenticated"})]}),r.jsxs("span",{className:"truncate font-mono text-xs text-muted-foreground",children:[n.tls?"https://":"",n.host,":",n.port]}),n.username?r.jsxs("span",{className:"truncate text-xs text-muted-foreground",title:n.username,children:["Team account: ",n.username]}):N?r.jsx("span",{className:"text-xs text-warning",children:"Team account not configured"}):null]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[r.jsx(ee,{variant:"ghost",size:"icon-sm","aria-label":`Re-test ${n.name}`,disabled:S==="test",onClick:async()=>{j("test"),await i(n.id),j(null)},children:r.jsx(Ot,{"data-icon":"inline-start",className:q(S==="test"&&"animate-spin")})}),r.jsx(ee,{variant:"ghost",size:"icon-sm","aria-label":`Edit account for ${n.name}`,onClick:()=>{f(A=>!A),p(n.username??""),g(""),b(null)},children:r.jsx(o3,{"data-icon":"inline-start"})}),r.jsx(ee,{variant:"ghost",size:"icon-sm","aria-label":`Rename ${n.name}`,onClick:()=>l(!0),children:r.jsx(Vs,{"data-icon":"inline-start"})}),r.jsxs(gd,{open:w,onOpenChange:A=>{S!=="remove"&&v(A)},children:[r.jsx(d5,{render:r.jsx(ee,{variant:"ghost",size:"icon-sm","aria-label":`Remove ${n.name}`,className:"text-destructive hover:bg-destructive/10 hover:text-destructive"}),children:r.jsx(ca,{"data-icon":"inline-start"})}),r.jsxs(xd,{size:"sm",children:[r.jsxs(bd,{children:[r.jsxs(yd,{children:["Remove ",n.name,"?"]}),r.jsx(wd,{children:"This device will disappear from Cogpit. You can add it again later."})]}),r.jsxs(vd,{children:[r.jsx(Sd,{disabled:S==="remove",children:"Cancel"}),r.jsxs(jd,{variant:"destructive",disabled:S==="remove",onClick:async()=>{j("remove");try{await o(n.id)}finally{j(null)}},children:[S==="remove"&&r.jsx(ot,{"data-icon":"inline-start",className:"animate-spin"}),"Remove device"]})]})]})]})]})]}),u&&r.jsxs("div",{className:"flex flex-col gap-3 border-t px-3 py-3",children:[r.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[r.jsxs(wt,{children:[r.jsxs(jt,{htmlFor:`device-username-${n.id}`,children:["Username ",r.jsx("span",{className:"text-muted-foreground/60",children:"(team devices)"})]}),r.jsx(Ht,{id:`device-username-${n.id}`,"aria-label":`Username for ${n.name}`,value:m,onChange:A=>p(A.target.value),placeholder:"Leave empty for password-only auth",autoComplete:"off",spellCheck:!1})]}),r.jsxs(wt,{children:[r.jsxs(jt,{htmlFor:`device-password-${n.id}`,children:["New password ",r.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),r.jsx(Ht,{id:`device-password-${n.id}`,"aria-label":`New password for ${n.name}`,type:"password",value:h,onChange:A=>g(A.target.value),placeholder:"Leave blank to keep the stored password",autoComplete:"new-password"})]})]}),n.username&&m.trim()===""&&r.jsx("p",{className:"text-xs text-warning",children:"Clearing the username switches this device back to password-only authentication."}),x&&r.jsx(bs,{children:x}),r.jsxs("div",{className:"flex justify-end gap-1.5",children:[r.jsx(ee,{variant:"outline",size:"sm",onClick:()=>{f(!1),p(n.username??""),g(""),b(null)},children:"Cancel"}),r.jsx(ee,{size:"sm",disabled:S==="credentials",onClick:()=>void P(),children:S==="credentials"?r.jsx(ot,{"data-icon":"inline-start",className:"animate-spin"}):"Save account"})]})]})]})}function g2(n){var nt,Ye;const e=B.c(118),{open:t,initialMode:s,onClose:o,onCloseComplete:i}=n,{devices:a,refresh:l,probe:c,addDevice:d,updateDevice:u,removeDevice:f,testDevice:m}=Ka(),[p,h]=y.useState(""),[g,x]=y.useState(""),[b,w]=y.useState(""),[v,S]=y.useState(""),[j,k]=y.useState(!1),[C,N]=y.useState(!1),[_,P]=y.useState(null),[A,T]=y.useState(!1),[E,R]=y.useState(null),$=y.useRef(null),I=y.useRef(0);let M,D;e[0]!==s||e[1]!==t?(M=()=>{t&&(h(""),x(""),w(""),S(""),k(!1),N(!1),P(null),R(null),s==="add"&&requestAnimationFrame(()=>{var Me;return(Me=$.current)==null?void 0:Me.focus()}))},D=[t,s],e[0]=s,e[1]=t,e[2]=M,e[3]=D):(M=e[2],D=e[3]),y.useEffect(M,D);let O;e[4]!==j||e[5]!==g||e[6]!==c?(O=async()=>{const{host:Me,port:Ue,tls:st}=Xo(g);if(!Me){P(null),N(!1);return}const Vt=I.current=I.current+1;N(!0);const Ft=await c(Me,Ue,j,st);Vt===I.current&&(P({...p2(Ft,Me,Ue??(st?nP:tP)),hello:Ft.ok?Ft.hello:void 0}),N(!1))},e[4]=j,e[5]=g,e[6]=c,e[7]=O):O=e[7];const L=O;let F,z;e[8]!==g||e[9]!==t||e[10]!==L?(F=()=>{if(!t)return;if(!Xo(g).host){P(null),N(!1);return}const Me=window.setTimeout(()=>void L(),sP);return()=>window.clearTimeout(Me)},z=[t,g,L],e[8]=g,e[9]=t,e[10]=L,e[11]=F,e[12]=z):(F=e[11],z=e[12]),y.useEffect(F,z);const W=((nt=_==null?void 0:_.hello)==null?void 0:nt.edition)==="team",U=W&&((Ye=_==null?void 0:_.hello)==null?void 0:Ye.needsBootstrap)===!0,H=W||!j;let K;e:{if(A){K=!1;break e}if(!Xo(g).host){K=!1;break e}if(C||!_){K=!1;break e}if(U){K=!1;break e}if(H&&!v){K=!1;break e}if(W&&!b.trim()){K=!1;break e}if((_==null?void 0:_.tone)==="error"){K=!1;break e}K=!0}const V=K;let Y;e[13]!==d||e[14]!==j||e[15]!==H||e[16]!==g||e[17]!==p||e[18]!==o||e[19]!==v||e[20]!==W||e[21]!==b?(Y=async function(){const{host:Ue,port:st,tls:Vt}=Xo(g);if(!Ue)return;T(!0),R(null);const Ft=await d({name:p.trim()||void 0,host:Ue,port:st,tls:Vt,username:W?b.trim():void 0,password:H&&v||void 0,allowLocalTunnel:j});if(T(!1),Ft.ok){o(),Ss(Ft.device.id);return}R({field:aP.has(Ft.code)?"username":iP.has(Ft.code)?"password":"host",message:Ft.error})},e[13]=d,e[14]=j,e[15]=H,e[16]=g,e[17]=p,e[18]=o,e[19]=v,e[20]=W,e[21]=b,e[22]=Y):Y=e[22];const G=Y;let J;e[23]!==u?(J=async(Me,Ue)=>{await u(Me,{name:Ue})},e[23]=u,e[24]=J):J=e[24];const Q=J;let X;e[25]!==f?(X=async Me=>{await f(Me)},e[25]=f,e[26]=X):X=e[26];const Z=X;let te;e[27]!==l||e[28]!==m?(te=async Me=>{await m(Me),await l()},e[27]=l,e[28]=m,e[29]=te):te=e[29];const ne=te;let re;e[30]!==o?(re=Me=>{Me||o()},e[30]=o,e[31]=re):re=e[31];let ie;e[32]!==i?(ie=Me=>{Me||i==null||i()},e[32]=i,e[33]=ie):ie=e[33];let ae;e[34]===Symbol.for("react.memo_cache_sentinel")?(ae=r.jsxs(Ps,{children:[r.jsx(os,{children:"Devices"}),r.jsxs(rs,{children:["Control another Cogpit device from here. The active device is chosen from the header switcher — ",rP," jumps between devices."]})]}),e[34]=ae):ae=e[34];let se;e[35]!==a||e[36]!==Z||e[37]!==Q||e[38]!==ne||e[39]!==u?(se=a.length>0&&r.jsx("div",{className:"flex flex-col gap-2",children:a.map(Me=>r.jsx(dP,{device:Me,hubVersion:eP,onRename:Q,onCredentials:u,onRemove:Z,onTest:ne},Me.id))}),e[35]=a,e[36]=Z,e[37]=Q,e[38]=ne,e[39]=u,e[40]=se):se=e[40];let ue;e[41]===Symbol.for("react.memo_cache_sentinel")?(ue=r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ln,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),r.jsx("p",{className:"text-sm font-medium text-foreground",children:"Add a device"})]}),e[41]=ue):ue=e[41];const le=(E==null?void 0:E.field)==="host";let de,pe;e[42]===Symbol.for("react.memo_cache_sentinel")?(de=r.jsx(jt,{htmlFor:"device-host",children:"Host"}),pe=r.jsx(No,{children:"Enter a local address or an HTTPS URL."}),e[42]=de,e[43]=pe):(de=e[42],pe=e[43]);let he;e[44]===Symbol.for("react.memo_cache_sentinel")?(he=Me=>{I.current=I.current+1,x(Me.target.value),w(""),P(null),R(null)},e[44]=he):he=e[44];let ce;e[45]!==L?(ce=()=>void L(),e[45]=L,e[46]=ce):ce=e[46];let ye;e[47]!==g||e[48]!==ce?(ye=r.jsx(Ht,{id:"device-host",ref:$,value:g,onChange:he,onBlur:ce,placeholder:"192.168.1.42, my-mac.local:19384 or https://cogpit.example.com",spellCheck:!1,autoComplete:"off"}),e[47]=g,e[48]=ce,e[49]=ye):ye=e[49];let xe;e[50]!==C?(xe=C&&r.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[r.jsx(ot,{"data-icon":"inline-start",className:"size-3.5 animate-spin"})," Checking device…"]}),e[50]=C,e[51]=xe):xe=e[51];let me;e[52]!==_||e[53]!==C?(me=!C&&_&&r.jsxs("p",{role:"status",className:q("flex items-center gap-1.5 text-xs",h2[_.tone]),children:[r.jsx(lP,{tone:_.tone}),_.text]}),e[52]=_,e[53]=C,e[54]=me):me=e[54];let je;e[55]!==E?(je=(E==null?void 0:E.field)==="host"&&r.jsx(bs,{children:E.message}),e[55]=E,e[56]=je):je=e[56];let Se;e[57]!==le||e[58]!==ye||e[59]!==xe||e[60]!==me||e[61]!==je?(Se=r.jsxs(wt,{"data-invalid":le,children:[de,pe,ye,xe,me,je]}),e[57]=le,e[58]=ye,e[59]=xe,e[60]=me,e[61]=je,e[62]=Se):Se=e[62];let Pe;e[63]===Symbol.for("react.memo_cache_sentinel")?(Pe=r.jsxs(jt,{htmlFor:"device-name",children:["Name ",r.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),e[63]=Pe):Pe=e[63];let Re;e[64]===Symbol.for("react.memo_cache_sentinel")?(Re=Me=>h(Me.target.value),e[64]=Re):Re=e[64];let Ie;e[65]!==p?(Ie=r.jsxs(wt,{children:[Pe,r.jsx(Ht,{id:"device-name",value:p,onChange:Re,placeholder:"Defaults to the device's own name"})]}),e[65]=p,e[66]=Ie):Ie=e[66];let De;e[67]!==E||e[68]!==W||e[69]!==b?(De=W&&r.jsxs(wt,{"data-invalid":(E==null?void 0:E.field)==="username",children:[r.jsx(jt,{htmlFor:"device-username",children:"Username"}),r.jsx(Ht,{id:"device-username",value:b,onChange:Me=>w(Me.target.value),placeholder:"Team account username",autoComplete:"username",spellCheck:!1}),r.jsx(No,{children:"Requests through this hub will act as this account on the team server."}),(E==null?void 0:E.field)==="username"&&r.jsx(bs,{children:E.message})]}),e[67]=E,e[68]=W,e[69]=b,e[70]=De):De=e[70];let Le;e[71]!==H||e[72]!==v||e[73]!==E||e[74]!==W?(Le=H&&r.jsxs(wt,{"data-invalid":(E==null?void 0:E.field)==="password",children:[r.jsx(jt,{htmlFor:"device-password",children:"Password"}),r.jsx(Ht,{id:"device-password",type:"password",value:v,onChange:Me=>S(Me.target.value),placeholder:W?"Password for that team account":"Network access password for that device",autoComplete:W?"current-password":"off"}),(E==null?void 0:E.field)==="password"&&r.jsx(bs,{children:E.message})]}),e[71]=H,e[72]=v,e[73]=E,e[74]=W,e[75]=Le):Le=e[75];let ze;e[76]!==Se||e[77]!==Ie||e[78]!==De||e[79]!==Le?(ze=r.jsxs(Ao,{children:[Se,Ie,De,Le]}),e[76]=Se,e[77]=Ie,e[78]=De,e[79]=Le,e[80]=ze):ze=e[80];let Te;e[81]===Symbol.for("react.memo_cache_sentinel")?(Te=Me=>{I.current=I.current+1,k(Me===!0),P(null),R(null)},e[81]=Te):Te=e[81];let Ce;e[82]!==j?(Ce=r.jsx(b1,{id:"device-local-tunnel",name:"device-local-tunnel",checked:j,onCheckedChange:Te}),e[82]=j,e[83]=Ce):Ce=e[83];const We=W?"":" — no password";let Fe;e[84]!==We?(Fe=r.jsxs(jt,{htmlFor:"device-local-tunnel",children:["This is a local tunnel",We]}),e[84]=We,e[85]=Fe):Fe=e[85];let Ne;e[86]!==Ce||e[87]!==Fe?(Ne=r.jsxs(wt,{orientation:"horizontal",children:[Ce,Fe]}),e[86]=Ce,e[87]=Fe,e[88]=Ne):Ne=e[88];let fe;e[89]!==j||e[90]!==W?(fe=j&&r.jsxs(ht,{className:"border-warning/40 bg-warning/10 text-warning",children:[r.jsx(r3,{}),r.jsx(gt,{className:"text-warning",children:W?r.jsx(r.Fragment,{children:"The loopback address is allowed because the tunnel is local; team account authentication still applies."}):r.jsxs(r.Fragment,{children:["Traffic to this device is forwarded ",r.jsx("strong",{children:"unauthenticated"}),". Only use this for an SSH tunnel or another already-secured local channel."]})})]}),e[89]=j,e[90]=W,e[91]=fe):fe=e[91];let Oe;e[92]!==o?(Oe=r.jsx(ee,{variant:"outline",onClick:o,children:"Close"}),e[92]=o,e[93]=Oe):Oe=e[93];const Ae=!V;let Be;e[94]!==G?(Be=()=>void G(),e[94]=G,e[95]=Be):Be=e[95];let oe;e[96]!==A?(oe=A?r.jsxs(r.Fragment,{children:[r.jsx(ot,{"data-icon":"inline-start",className:"size-4 animate-spin"})," Adding…"]}):"Add device",e[96]=A,e[97]=oe):oe=e[97];let ge;e[98]!==Ae||e[99]!==Be||e[100]!==oe?(ge=r.jsx(ee,{disabled:Ae,onClick:Be,children:oe}),e[98]=Ae,e[99]=Be,e[100]=oe,e[101]=ge):ge=e[101];let Ee;e[102]!==Oe||e[103]!==ge?(Ee=r.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[Oe,ge]}),e[102]=Oe,e[103]=ge,e[104]=Ee):Ee=e[104];let $e;e[105]!==ze||e[106]!==Ne||e[107]!==fe||e[108]!==Ee?($e=r.jsxs("div",{className:"flex flex-col gap-4 border-t pt-4",children:[ue,ze,Ne,fe,Ee]}),e[105]=ze,e[106]=Ne,e[107]=fe,e[108]=Ee,e[109]=$e):$e=e[109];let He;e[110]!==se||e[111]!==$e?(He=r.jsxs(ss,{className:"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-xl",children:[ae,se,$e]}),e[110]=se,e[111]=$e,e[112]=He):He=e[112];let Ke;return e[113]!==t||e[114]!==re||e[115]!==ie||e[116]!==He?(Ke=r.jsx(ns,{open:t,onOpenChange:re,onOpenChangeComplete:ie,children:He}),e[113]=t,e[114]=re,e[115]=ie,e[116]=He,e[117]=Ke):Ke=e[117],Ke}const uP=Object.freeze(Object.defineProperty({__proto__:null,DevicesDialog:g2,parseHostPort:Xo,probeMessage:p2},Symbol.toStringTag,{value:"Module"})),Wp=m2.version,fP={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"},Hp={ok:"Reachable",unknown:"Not reachable","bad-password":"Password rejected"};function mP(n){const e=B.c(6),{state:t}=n,s=Hp[t],o=Hp[t],i=fP[t];let a;e[0]!==i?(a=q("size-2 shrink-0 rounded-full",i),e[0]=i,e[1]=a):a=e[1];let l;return e[2]!==s||e[3]!==o||e[4]!==a?(l=r.jsx("span",{"aria-label":s,title:o,className:a}),e[2]=s,e[3]=o,e[4]=a,e[5]=l):l=e[5],l}function uu(n){const e=B.c(50),{compact:t}=n,s=t===void 0?!1:t,{devices:o,activeDeviceId:i,activeDevice:a,refresh:l,testDevice:c}=Ka(),[d,u]=y.useState(null),f=(a==null?void 0:a.name)??"This machine",m=i!==Ct;let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=lt("manageDevices"),e[0]=p):p=e[0];const h=p;let g;e[1]!==o||e[2]!==l||e[3]!==c?(g=F=>{!F||o.length===0||Promise.all(o.map(z=>c(z.id).catch(hP))).then(()=>l())},e[1]=o,e[2]=l,e[3]=c,e[4]=g):g=e[4];const x=g;if(!s&&o.length===0&&!m)return null;const b=s?"sm":"xs",w=s&&"h-10";let v;e[5]!==w?(v=q("max-w-40 justify-start",w),e[5]=w,e[6]=v):v=e[6];let S;e[7]!==b||e[8]!==v?(S=r.jsx(ee,{variant:"ghost",size:b,"aria-label":"Switch device",className:v}),e[7]=b,e[8]=v,e[9]=S):S=e[9];let j;e[10]!==m?(j=m?r.jsx(Yh,{"data-icon":"inline-start"}):r.jsx(If,{"data-icon":"inline-start"}),e[10]=m,e[11]=j):j=e[11];let k;e[12]!==f?(k=r.jsx("span",{className:"truncate",children:f}),e[12]=f,e[13]=k):k=e[13];let C;e[14]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(tt,{"data-icon":"inline-end",className:"opacity-60"}),e[14]=C):C=e[14];let N;e[15]!==S||e[16]!==j||e[17]!==k?(N=r.jsxs(Hn,{render:S,children:[j,k,C]}),e[15]=S,e[16]=j,e[17]=k,e[18]=N):N=e[18];let _;e[19]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(Us,{children:"Devices"}),e[19]=_):_=e[19];let P,A;e[20]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(If,{}),A=r.jsx("span",{className:"flex-1 truncate",children:"This machine"}),e[20]=P,e[21]=A):(P=e[20],A=e[21]);let T;e[22]!==m?(T=!m&&r.jsx(mt,{className:"ml-auto text-success"}),e[22]=m,e[23]=T):T=e[23];let E;e[24]!==T?(E=r.jsxs(_t,{onClick:pP,children:[P,A,T]}),e[24]=T,e[25]=E):E=e[25];let R;if(e[26]!==i||e[27]!==s||e[28]!==o){let F;e[30]!==i||e[31]!==s?(F=z=>{const W=f2(z),U=W!==void 0&&W!==Wp,H=z.id===i;return r.jsxs(_t,{onClick:()=>Ss(z.id),className:q(s&&"min-h-10"),children:[r.jsx(mP,{state:z.runtime.authState}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[r.jsx("span",{className:"truncate",children:z.name}),U&&r.jsxs("span",{className:"shrink-0 font-mono text-xs text-warning",title:`Device runs v${W}; hub runs v${Wp}`,children:["v",W]})]}),r.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:[z.host,":",z.port,z.auth==="none"&&" · unauthenticated"]})]}),H&&r.jsx(mt,{className:"ml-auto text-success"})]},z.id)},e[30]=i,e[31]=s,e[32]=F):F=e[32],R=o.map(F),e[26]=i,e[27]=s,e[28]=o,e[29]=R}else R=e[29];let $;e[33]!==E||e[34]!==R?($=r.jsxs(en,{children:[_,E,R]}),e[33]=E,e[34]=R,e[35]=$):$=e[35];let I;e[36]!==o.length?(I=h&&r.jsxs(r.Fragment,{children:[r.jsx(ur,{}),r.jsxs(en,{children:[r.jsxs(_t,{onClick:()=>u("add"),children:[r.jsx(Ln,{}),r.jsx("span",{children:"Add device…"})]}),o.length>0&&r.jsxs(_t,{onClick:()=>u("manage"),children:[r.jsx(Yc,{}),r.jsx("span",{children:"Manage devices…"})]})]})]}),e[36]=o.length,e[37]=I):I=e[37];let M;e[38]!==$||e[39]!==I?(M=r.jsxs(Kn,{align:"end",sideOffset:6,className:"w-64",children:[$,I]}),e[38]=$,e[39]=I,e[40]=M):M=e[40];let D;e[41]!==x||e[42]!==N||e[43]!==M?(D=r.jsxs(Wn,{onOpenChange:x,children:[N,M]}),e[41]=x,e[42]=N,e[43]=M,e[44]=D):D=e[44];let O;e[45]!==d?(O=h&&r.jsx(g2,{open:d!==null,initialMode:d??"manage",onClose:()=>u(null)}),e[45]=d,e[46]=O):O=e[46];let L;return e[47]!==D||e[48]!==O?(L=r.jsxs(r.Fragment,{children:[D,O]}),e[47]=D,e[48]=O,e[49]=L):L=e[49],L}function pP(){return Ss(Ct)}function hP(){return null}const gP=6e4;function xP(){const[n,e]=y.useState([]),[t,s]=y.useState(!1),o=y.useRef(!1),i=y.useCallback(async()=>{if(!o.current){o.current=!0;try{const l=await ve("/api/system-processes");if(l.ok){const c=await l.json();e((c.processes??[]).filter(d=>d.suspectedLeak))}}catch{}finally{o.current=!1}}},[]),a=y.useCallback(async l=>{if(l.length!==0){s(!0);try{await ve("/api/system-processes/kill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pids:l})}),await new Promise(c=>setTimeout(c,1e3)),await i()}catch{}finally{s(!1)}}},[i]);return y.useEffect(()=>{i();const l=window.setInterval(()=>{document.visibilityState==="visible"&&i()},gP);return()=>window.clearInterval(l)},[i]),{leaks:n,killing:t,killLeaks:a,refresh:i}}const bP=6e4;function vP(){const n=B.c(29),{leaks:e,killing:t,killLeaks:s,refresh:o}=xP(),[i,a]=y.useState(!1),l=e.length>0,c=e.reduce(jP,0);let d,u;if(n[0]!==l?(d=()=>{if(l){a(!0);return}const T=window.setTimeout(()=>a(!1),bP);return()=>window.clearTimeout(T)},u=[l],n[0]=l,n[1]=d,n[2]=u):(d=n[1],u=n[2]),y.useEffect(d,u),!l&&!i)return null;const f=At,m=l?"destructive":"ghost",p=l?`Kill ${e.length} leaked agent ${e.length===1?"process":"processes"}`:"Leak monitor. No leaked agent processes";let h;n[3]!==l||n[4]!==s||n[5]!==e||n[6]!==o?(h=()=>void(l?s(e.map(wP)):o()),n[3]=l,n[4]=s,n[5]=e,n[6]=o,n[7]=h):h=n[7];const g=!l&&"text-muted-foreground";let x;n[8]!==g?(x=q("mr-1 font-mono",g),n[8]=g,n[9]=x):x=n[9];let b;n[10]!==t||n[11]!==m||n[12]!==p||n[13]!==h||n[14]!==x?(b=r.jsx(ee,{variant:m,size:"xs","aria-label":p,onClick:h,disabled:t,className:x}),n[10]=t,n[11]=m,n[12]=p,n[13]=h,n[14]=x,n[15]=b):b=n[15];let w;n[16]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(i3,{"data-icon":"inline-start"}),n[16]=w):w=n[16];const v=t?"…":e.length;let S;n[17]!==v?(S=r.jsx("span",{className:"tabular-nums",children:v}),n[17]=v,n[18]=S):S=n[18];let j;n[19]!==S||n[20]!==b?(j=r.jsxs(Rt,{render:b,children:[w,S]}),n[19]=S,n[20]=b,n[21]=j):j=n[21];const k=It,C="bottom",N="p-3",_=l?r.jsxs("div",{className:"flex min-w-56 flex-col gap-2",children:[r.jsxs("div",{className:"text-xs font-medium",children:["Leaked agent processes · ",c.toFixed(0),"% CPU"]}),e.slice(0,6).map(yP),e.length>6&&r.jsxs("div",{className:"text-xs text-muted-foreground",children:["+",e.length-6," more"]}),r.jsx(St,{}),r.jsxs("div",{className:"text-xs text-muted-foreground",children:["Click to kill ",e.length===1?"it":"all of them"]})]}):r.jsxs("div",{className:"flex min-w-48 flex-col gap-1",children:[r.jsx("div",{className:"text-xs font-medium",children:"Leak monitor"}),r.jsx("div",{className:"text-xs text-muted-foreground",children:"No leaked agent processes. Click to scan again."})]});let P;n[22]!==k||n[23]!==_?(P=r.jsx(k,{side:C,className:N,children:_}),n[22]=k,n[23]=_,n[24]=P):P=n[24];let A;return n[25]!==f||n[26]!==j||n[27]!==P?(A=r.jsxs(f,{children:[j,P]}),n[25]=f,n[26]=j,n[27]=P,n[28]=A):A=n[28],A}function yP(n){return r.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[r.jsxs("span",{className:"truncate text-muted-foreground",children:[n.label," · ",id(n.ageSeconds)]}),r.jsxs("span",{className:"shrink-0 font-semibold text-destructive",children:[n.cpuPercent.toFixed(0),"%"]})]},n.pid)}function wP(n){return n.pid}function jP(n,e){return n+e.cpuPercent}const SP=15e3;function NP(){const n=B.c(12);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],n[0]=e):e=n[0];const[t,s]=y.useState(e);let o;n[1]===Symbol.for("react.memo_cache_sentinel")?(o=async()=>{try{const b=await ve("/api/notifications?limit=100");if(!b.ok)return;const w=await b.json();Array.isArray(w.notifications)&&s(w.notifications)}catch{}},n[1]=o):o=n[1];const i=o;let a,l;n[2]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{i();const b=window.setInterval(()=>void i(),SP);return()=>window.clearInterval(b)},l=[i],n[2]=a,n[3]=l):(a=n[2],l=n[3]),y.useEffect(a,l);let c;n[4]===Symbol.for("react.memo_cache_sentinel")?(c=async(b,w)=>{const v=new Date().toISOString();s(S=>S.map(j=>j.readAt===null&&w(j)?{...j,readAt:v}:j));try{await ve("/api/notifications/read",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)})}catch{}},n[4]=c):c=n[4];const d=c;let u;n[5]===Symbol.for("react.memo_cache_sentinel")?(u=async b=>d({ids:b},w=>b.includes(w.id)),n[5]=u):u=n[5];const f=u;let m;n[6]===Symbol.for("react.memo_cache_sentinel")?(m=async()=>d({all:!0},CP),n[6]=m):m=n[6];const p=m;let h;n[7]!==t?(h=t.filter(kP),n[7]=t,n[8]=h):h=n[8];const g=h.length;let x;return n[9]!==t||n[10]!==g?(x={notifications:t,unreadCount:g,refresh:i,markRead:f,markAllRead:p},n[9]=t,n[10]=g,n[11]=x):x=n[11],x}function kP(n){return n.readAt===null}function CP(){return!0}function x2(n){window.history.pushState({},"",n),window.dispatchEvent(new PopStateEvent("popstate"))}function _P(){const n=B.c(30),{notifications:e,unreadCount:t,refresh:s,markRead:o,markAllRead:i}=NP(),[a,l]=y.useState(!1);let c;n[0]!==o?(c=function(N){if(o([N.id]),!N.dirName||!N.sessionId)return;const _=yt(),P=_===Ct?"":`/d/${_}`;x2(`${P}/${encodeURIComponent(N.dirName)}/${encodeURIComponent(N.sessionId)}`),l(!1)},n[0]=o,n[1]=c):c=n[1];const d=c;let u;n[2]!==s?(u=C=>{l(C),C&&s()},n[2]=s,n[3]=u):u=n[3];const f=a?"secondary":"ghost",m=t>0?`Notifications, ${t} unread`:"Notifications";let p;n[4]!==f||n[5]!==m?(p=r.jsx(ee,{type:"button",variant:f,size:"icon-sm",className:"relative","aria-label":m}),n[4]=f,n[5]=m,n[6]=p):p=n[6];let h;n[7]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx($f,{"data-icon":"inline-start"}),n[7]=h):h=n[7];let g;n[8]!==t?(g=t>0&&r.jsx(_e,{className:"absolute -right-1 -top-1 h-4 min-w-4 px-1 tabular-nums",children:t>99?"99+":t}),n[8]=t,n[9]=g):g=n[9];let x;n[10]!==p||n[11]!==g?(x=r.jsxs(Hn,{render:p,children:[h,g]}),n[10]=p,n[11]=g,n[12]=x):x=n[12];let b;n[13]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx("span",{className:"text-sm font-medium",children:"Notifications"}),n[13]=b):b=n[13];let w;n[14]!==i||n[15]!==t?(w=t>0&&r.jsxs(ee,{variant:"ghost",size:"xs",onClick:()=>void i(),children:[r.jsx(a3,{"data-icon":"inline-start"}),"Mark all read"]}),n[14]=i,n[15]=t,n[16]=w):w=n[16];let v;n[17]!==w?(v=r.jsxs("div",{className:"flex h-11 items-center justify-between border-b px-3",children:[b,w]}),n[17]=w,n[18]=v):v=n[18];let S;n[19]!==e||n[20]!==d?(S=r.jsx("div",{className:"max-h-96 overflow-y-auto",children:e.length===0?r.jsx(ln,{className:"min-h-40 p-6",children:r.jsxs(cn,{children:[r.jsx(bn,{variant:"icon",children:r.jsx($f,{})}),r.jsx(dn,{children:"No notifications"}),r.jsx(vn,{children:"Session updates will appear here."})]})}):r.jsx(en,{children:e.map(C=>r.jsx(TP,{notification:C,onOpen:d},C.id))})}),n[19]=e,n[20]=d,n[21]=S):S=n[21];let j;n[22]!==v||n[23]!==S?(j=r.jsxs(Kn,{align:"end",sideOffset:6,className:"w-80 overflow-hidden p-0",children:[v,S]}),n[22]=v,n[23]=S,n[24]=j):j=n[24];let k;return n[25]!==a||n[26]!==u||n[27]!==j||n[28]!==x?(k=r.jsxs(Wn,{open:a,onOpenChange:u,children:[x,j]}),n[25]=a,n[26]=u,n[27]=j,n[28]=x,n[29]=k):k=n[29],k}function TP(n){const e=B.c(38),{notification:t,onOpen:s}=n,o=t.readAt===null,i=!!(t.dirName&&t.sessionId),a=Date.now();let l;e[0]!==t.at?(l=new Date(t.at).getTime(),e[0]=t.at,e[1]=l):l=e[1];const c=Math.max(0,(a-l)/1e3),d=t.kind==="permission"?tn:pa;let u;e[2]!==t||e[3]!==s?(u=()=>s(t),e[2]=t,e[3]=s,e[4]=u):u=e[4];const f=!i&&"cursor-default",m=o&&"bg-accent/50";let p;e[5]!==f||e[6]!==m?(p=q("rounded-none border-b px-3 py-2.5 last:border-b-0",f,m),e[5]=f,e[6]=m,e[7]=p):p=e[7];const h=t.kind==="permission"?"text-warning":"text-info";let g;e[8]!==h?(g=q("mt-0.5",h),e[8]=h,e[9]=g):g=e[9];let x;e[10]!==d||e[11]!==g?(x=r.jsx(d,{className:g}),e[10]=d,e[11]=g,e[12]=x):x=e[12];const b=o?"font-medium text-foreground":"text-muted-foreground";let w;e[13]!==b?(w=q("truncate text-xs",b),e[13]=b,e[14]=w):w=e[14];let v;e[15]!==t.title||e[16]!==w?(v=r.jsx("span",{className:w,children:t.title}),e[15]=t.title,e[16]=w,e[17]=v):v=e[17];let S;e[18]!==c?(S=id(c),e[18]=c,e[19]=S):S=e[19];let j;e[20]!==S?(j=r.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:S}),e[20]=S,e[21]=j):j=e[21];let k;e[22]!==v||e[23]!==j?(k=r.jsxs("span",{className:"flex items-baseline justify-between gap-2",children:[v,j]}),e[22]=v,e[23]=j,e[24]=k):k=e[24];let C;e[25]!==t.body?(C=r.jsx("span",{className:"mt-0.5 block truncate text-xs text-muted-foreground",children:t.body}),e[25]=t.body,e[26]=C):C=e[26];let N;e[27]!==k||e[28]!==C?(N=r.jsxs("span",{className:"min-w-0 flex-1",children:[k,C]}),e[27]=k,e[28]=C,e[29]=N):N=e[29];let _;e[30]!==o?(_=o&&r.jsx("span",{className:"mt-1.5 size-1.5 shrink-0 rounded-full bg-primary"}),e[30]=o,e[31]=_):_=e[31];let P;return e[32]!==N||e[33]!==_||e[34]!==u||e[35]!==p||e[36]!==x?(P=r.jsxs(_t,{onClick:u,className:p,children:[x,N,_]}),e[32]=N,e[33]=_,e[34]=u,e[35]=p,e[36]=x,e[37]=P):P=e[37],P}const EP=2e3;function To(n){return`${n.toFixed(n<10?1:0)}%`}function ea(n){return`${n.toFixed(0)} MB`}function PP(n){return n>=10?`${n.toFixed(0)}/s`:n>=1?`${n.toFixed(1)}/s`:`${n.toFixed(2)}/s`}function AP(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 RP(n){const e=B.c(44),{metric:t,onKill:s}=n;let o;e[0]!==t.label?(o=r.jsx("span",{className:"truncate text-sm font-medium",children:t.label}),e[0]=t.label,e[1]=o):o=e[1];let i;e[2]!==t.pid?(i=r.jsxs(_e,{variant:"outline",children:["PID ",t.pid]}),e[2]=t.pid,e[3]=i):i=e[3];let a;e[4]!==t.suspectedLeak?(a=t.suspectedLeak&&r.jsx(_e,{variant:"destructive",children:"possible leak"}),e[4]=t.suspectedLeak,e[5]=a):a=e[5];let l;e[6]!==t.orphaned||e[7]!==t.suspectedLeak?(l=t.orphaned&&!t.suspectedLeak&&r.jsx(_e,{variant:"secondary",children:"orphaned"}),e[6]=t.orphaned,e[7]=t.suspectedLeak,e[8]=l):l=e[8];let c;e[9]!==o||e[10]!==i||e[11]!==a||e[12]!==l?(c=r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o,i,a,l]}),e[9]=o,e[10]=i,e[11]=a,e[12]=l,e[13]=c):c=e[13];let d;e[14]!==t.command?(d=r.jsx("p",{className:"mt-1 truncate font-mono text-xs text-muted-foreground",title:t.command,children:t.command}),e[14]=t.command,e[15]=d):d=e[15];let u;e[16]!==c||e[17]!==d?(u=r.jsxs("div",{className:"min-w-0 flex-1",children:[c,d]}),e[16]=c,e[17]=d,e[18]=u):u=e[18];let f;e[19]!==t.pid||e[20]!==t.suspectedLeak||e[21]!==s?(f=t.suspectedLeak&&s&&r.jsx(ee,{variant:"destructive",size:"xs",className:"shrink-0",onClick:()=>s(t.pid),children:"Kill"}),e[19]=t.pid,e[20]=t.suspectedLeak,e[21]=s,e[22]=f):f=e[22];const m=t.cpuPercent>=20&&"text-destructive";let p;e[23]!==m?(p=q("font-mono text-sm font-semibold tabular-nums",m),e[23]=m,e[24]=p):p=e[24];let h;e[25]!==t.cpuPercent?(h=To(t.cpuPercent),e[25]=t.cpuPercent,e[26]=h):h=e[26];let g;e[27]!==p||e[28]!==h?(g=r.jsx("div",{className:p,children:h}),e[27]=p,e[28]=h,e[29]=g):g=e[29];let x;e[30]!==t.memoryMb?(x=ea(t.memoryMb),e[30]=t.memoryMb,e[31]=x):x=e[31];let b;e[32]!==t.ageSeconds?(b=id(t.ageSeconds),e[32]=t.ageSeconds,e[33]=b):b=e[33];let w;e[34]!==x||e[35]!==b?(w=r.jsxs("div",{className:"text-xs text-muted-foreground",children:[x," · ",b]}),e[34]=x,e[35]=b,e[36]=w):w=e[36];let v;e[37]!==g||e[38]!==w?(v=r.jsxs("div",{className:"shrink-0 text-right",children:[g,w]}),e[37]=g,e[38]=w,e[39]=v):v=e[39];let S;return e[40]!==v||e[41]!==u||e[42]!==f?(S=r.jsxs("div",{className:"flex items-start gap-3 py-2.5",children:[u,f,v]}),e[40]=v,e[41]=u,e[42]=f,e[43]=S):S=e[43],S}function IP(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 $P(n,e,t=0){return t>0?t===1?'1 agent process outside Cogpit looks leaked. See "Agent processes" below.':`${t} agent processes outside Cogpit look leaked. See "Agent processes" below.`:n<5?"Cogpit is currently idle. Leave this open while the power spike happens.":e?e.name==="Server"?"The server is doing the most work. Compare the activity and API lists below to find the hot loop.":e.name==="Renderer"?"The renderer is doing the most work, which points to repeated UI rendering, layout, or animation.":e.name==="GPU"?"The GPU process is doing the most work, which points to continuous compositing or visual effects.":`${e.name} is currently the busiest Cogpit process.`:"The server is active. The lists below show its busiest recent work."}function b2(n){const e=B.c(34),{metric:t}=n;let s;e[0]!==t.name?(s=r.jsx("span",{className:"truncate text-sm font-medium",children:t.name}),e[0]=t.name,e[1]=s):s=e[1];let o;e[2]!==t.pid?(o=t.pid>0&&r.jsxs(_e,{variant:"outline",children:["PID ",t.pid]}),e[2]=t.pid,e[3]=o):o=e[3];let i;e[4]!==s||e[5]!==o?(i=r.jsxs("div",{className:"flex items-center gap-2",children:[s,o]}),e[4]=s,e[5]=o,e[6]=i):i=e[6];let a;e[7]!==t?(a=IP(t),e[7]=t,e[8]=a):a=e[8];let l;e[9]!==a?(l=r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:a}),e[9]=a,e[10]=l):l=e[10];let c;e[11]!==i||e[12]!==l?(c=r.jsxs("div",{className:"min-w-0 flex-1",children:[i,l]}),e[11]=i,e[12]=l,e[13]=c):c=e[13];const d=t.cpuPercent>=50&&"text-destructive";let u;e[14]!==d?(u=q("font-mono text-sm font-semibold tabular-nums",d),e[14]=d,e[15]=u):u=e[15];let f;e[16]!==t.cpuPercent?(f=To(t.cpuPercent),e[16]=t.cpuPercent,e[17]=f):f=e[17];let m;e[18]!==u||e[19]!==f?(m=r.jsx("div",{className:u,children:f}),e[18]=u,e[19]=f,e[20]=m):m=e[20];let p;e[21]!==t.memoryMb?(p=ea(t.memoryMb),e[21]=t.memoryMb,e[22]=p):p=e[22];let h;e[23]!==p?(h=r.jsx("div",{className:"text-xs text-muted-foreground",children:p}),e[23]=p,e[24]=h):h=e[24];let g;e[25]!==t.idleWakeupsPerSecond?(g=t.idleWakeupsPerSecond!==void 0&&t.idleWakeupsPerSecond>0&&r.jsxs("div",{className:"text-xs text-muted-foreground",children:[t.idleWakeupsPerSecond.toFixed(0)," wakeups/s"]}),e[25]=t.idleWakeupsPerSecond,e[26]=g):g=e[26];let x;e[27]!==m||e[28]!==h||e[29]!==g?(x=r.jsxs("div",{className:"shrink-0 text-right",children:[m,h,g]}),e[27]=m,e[28]=h,e[29]=g,e[30]=x):x=e[30];let b;return e[31]!==x||e[32]!==c?(b=r.jsxs("div",{className:"flex items-start gap-3 py-2.5",children:[c,x]}),e[31]=x,e[32]=c,e[33]=b):b=e[33],b}function Kp(n){const e=B.c(6),{metrics:t,emptyLabel:s}=n;let o,i;if(e[0]!==s||e[1]!==t){i=Symbol.for("react.early_return_sentinel");e:{const a=t.slice(0,8);if(a.length===0){let l;e[4]!==s?(l=r.jsx("p",{className:"py-3 text-sm text-muted-foreground",children:s}),e[4]=s,e[5]=l):l=e[5],i=l;break e}o=a.map(MP)}e[0]=s,e[1]=t,e[2]=o,e[3]=i}else o=e[2],i=e[3];return i!==Symbol.for("react.early_return_sentinel")?i:o}function MP(n,e){const t=AP(n.bytesPerSecond);return r.jsxs("div",{children:[e>0&&r.jsx(St,{}),r.jsxs("div",{className:"flex items-center gap-3 py-2.5",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"truncate text-sm",children:n.name}),r.jsxs("div",{className:"mt-0.5 flex flex-wrap gap-x-2 text-xs text-muted-foreground",children:[r.jsx("span",{children:PP(n.ratePerSecond)}),t&&r.jsx("span",{children:t}),n.averageDurationMs!==void 0&&r.jsxs("span",{children:[n.averageDurationMs.toFixed(0)," ms avg"]})]})]}),n.active!==void 0&&n.active>0&&r.jsxs(_e,{variant:"secondary",children:[n.active," open"]})]})]},n.name)}function OP(n){const e=B.c(8),{values:t}=n,s=Math.max(100,...t);let o;e[0]!==t?(o=t.map(DP).join(", "),e[0]=t,e[1]=o):o=e[1];const i=`Recent Cogpit CPU: ${o}`;let a;e[2]!==s||e[3]!==t?(a=t.length===0?r.jsx("span",{className:"self-center text-xs text-muted-foreground",children:"Collecting samples…"}):t.map((c,d)=>r.jsx("div",{className:q("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:To(c)},d)),e[2]=s,e[3]=t,e[4]=a):a=e[4];let l;return e[5]!==i||e[6]!==a?(l=r.jsx("div",{className:"flex h-14 items-end gap-1 rounded-md bg-muted/50 p-2",role:"img","aria-label":i,children:a}),e[5]=i,e[6]=a,e[7]=l):l=e[7],l}function DP(n){return To(n)}function LP(n){var pe,he,ce,ye;const e=B.c(135),{open:t,onOpenChange:s}=n,[o,i]=y.useState(null),[a,l]=y.useState(null);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[0]=c):c=e[0];const[d,u]=y.useState(c),[f,m]=y.useState(null),[p,h]=y.useState(!1),g=y.useRef(!1),[x,b]=Hs();let w;e[1]===Symbol.for("react.memo_cache_sentinel")?(w=async()=>{var Ie;if(g.current)return;g.current=!0,h(!0);const xe=ve("/api/performance").then(HP),me=((Ie=window.electronPerformance)==null?void 0:Ie.getSnapshot())??Promise.resolve(null),[je,Se]=await Promise.allSettled([xe,me]),Pe=je.status==="fulfilled"?je.value:null,Re=Se.status==="fulfilled"?Se.value:null;if(Pe&&l(Pe),Re&&i(Re),!Pe&&!Re)m("Performance data is unavailable.");else{m(null);const De=Re&&Re.processes.length>0?Re.processes.reduce(WP,0):(Pe==null?void 0:Pe.cpuPercent)??0;u(Le=>[...Le.slice(-29),De])}g.current=!1,h(!1)},e[1]=w):w=e[1];const v=w;let S,j;e[2]!==t?(S=()=>{if(!t)return;v();const xe=window.setInterval(()=>void v(),EP);return()=>window.clearInterval(xe)},j=[t,v],e[2]=t,e[3]=S,e[4]=j):(S=e[3],j=e[4]),y.useEffect(S,j);let k,C,N,_,P,A,T,E,R,$,I,M,D,O,L,F,z,W,U;if(e[5]!==x||e[6]!==b||e[7]!==o||e[8]!==f||e[9]!==d||e[10]!==s||e[11]!==t||e[12]!==p||e[13]!==a){const xe=[...(o==null?void 0:o.processes)??[]].sort(UP),me=xe.length>0?xe.reduce(BP,0):(a==null?void 0:a.cpuPercent)??0,je=xe[0];let Se;e[33]!==((pe=a==null?void 0:a.system)==null?void 0:pe.processes)?(Se=((he=a==null?void 0:a.system)==null?void 0:he.processes)??[],e[33]=(ce=a==null?void 0:a.system)==null?void 0:ce.processes,e[34]=Se):Se=e[34],T=Se;const Pe=((ye=a==null?void 0:a.system)==null?void 0:ye.suspectedLeakCount)??0,Re=Pe>0||me>=80?"High":me>=15?"Active":"Idle";let Ie;e[35]===Symbol.for("react.memo_cache_sentinel")?(Ie=async st=>{try{await ve("/api/system-processes/kill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pids:[st]})}),await new Promise(FP)}catch{}v()},e[35]=Ie):Ie=e[35],A=Ie;let De;e[36]!==b||e[37]!==o||e[38]!==d||e[39]!==a?(De=()=>{b(JSON.stringify({capturedAt:new Date().toISOString(),electron:o,server:a,cpuHistory:d},null,2))},e[36]=b,e[37]=o,e[38]=d,e[39]=a,e[40]=De):De=e[40];const Le=De;P=ns,D=t,O=s,_=ss,$="h-[min(780px,calc(100vh-2rem))] gap-0 p-0 sm:max-w-3xl";let ze;e[41]===Symbol.for("react.memo_cache_sentinel")?(ze=r.jsx(os,{children:"Power & activity monitor"}),e[41]=ze):ze=e[41];const Te=Re==="High"?"destructive":"secondary";let Ce;e[42]!==Re||e[43]!==Te?(Ce=r.jsxs("div",{className:"flex items-center gap-2",children:[ze,r.jsx(_e,{variant:Te,children:Re})]}),e[42]=Re,e[43]=Te,e[44]=Ce):Ce=e[44];let We;e[45]===Symbol.for("react.memo_cache_sentinel")?(We=r.jsx(rs,{className:"mt-1",children:"Live CPU, memory, and wakeups. Sampling runs only while this window is open."}),e[45]=We):We=e[45];let Fe;e[46]!==Ce?(Fe=r.jsxs("div",{className:"min-w-0 flex-1",children:[Ce,We]}),e[46]=Ce,e[47]=Fe):Fe=e[47];let Ne;e[48]===Symbol.for("react.memo_cache_sentinel")?(Ne=()=>void v(),e[48]=Ne):Ne=e[48];const fe=p&&"animate-spin";let Oe;e[49]!==fe?(Oe=q(fe),e[49]=fe,e[50]=Oe):Oe=e[50];let Ae;e[51]!==Oe?(Ae=r.jsx(Ot,{"data-icon":"inline-start",className:Oe}),e[51]=Oe,e[52]=Ae):Ae=e[52];let Be;e[53]!==p||e[54]!==Ae?(Be=r.jsxs(ee,{variant:"outline",size:"sm",onClick:Ne,disabled:p,children:[Ae,"Refresh"]}),e[53]=p,e[54]=Ae,e[55]=Be):Be=e[55];const oe=!a&&!o;let ge;e[56]!==x?(ge=x?r.jsx(mt,{"data-icon":"inline-start"}):r.jsx(An,{"data-icon":"inline-start"}),e[56]=x,e[57]=ge):ge=e[57];const Ee=x?"Copied":"Copy data";let $e;e[58]!==Le||e[59]!==oe||e[60]!==ge||e[61]!==Ee?($e=r.jsxs(ee,{variant:"outline",size:"sm",onClick:Le,disabled:oe,children:[ge,Ee]}),e[58]=Le,e[59]=oe,e[60]=ge,e[61]=Ee,e[62]=$e):$e=e[62];let He;e[63]!==Be||e[64]!==$e?(He=r.jsxs("div",{className:"flex shrink-0 gap-1",children:[Be,$e]}),e[63]=Be,e[64]=$e,e[65]=He):He=e[65],e[66]!==Fe||e[67]!==He?(I=r.jsx(Ps,{className:"p-5 pb-4",children:r.jsxs("div",{className:"flex items-start gap-3 pr-8",children:[Fe,He]})}),e[66]=Fe,e[67]=He,e[68]=I):I=e[68],e[69]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(St,{}),e[69]=M):M=e[69],N=is,R="min-h-0 min-w-0 flex-1",W="flex flex-col gap-4 p-5",e[70]!==f?(U=f&&r.jsx(ht,{variant:"destructive",children:r.jsx(gt,{children:f})}),e[70]=f,e[71]=U):U=e[71];let Ke;e[72]===Symbol.for("react.memo_cache_sentinel")?(Ke=r.jsx(an,{children:"Current load"}),e[72]=Ke):Ke=e[72];const nt=me>=80&&"text-destructive";let Ye;e[73]!==nt?(Ye=q("font-mono text-lg font-semibold tabular-nums",nt),e[73]=nt,e[74]=Ye):Ye=e[74];const Me=r.jsxs(rn,{children:[Ke,r.jsx(fn,{children:$P(me,je,Pe)}),r.jsx(Nd,{children:r.jsxs("span",{className:Ye,children:[To(me)," CPU"]})})]});let Ue;e[75]!==d?(Ue=r.jsx(Qt,{children:r.jsx(OP,{values:d})}),e[75]=d,e[76]=Ue):Ue=e[76],e[77]!==Me||e[78]!==Ue?(E=r.jsxs(Jt,{size:"sm",children:[Me,Ue]}),e[77]=Me,e[78]=Ue,e[79]=E):E=e[79],C=Jt,F="sm",e[80]===Symbol.for("react.memo_cache_sentinel")?(z=r.jsxs(rn,{children:[r.jsx(an,{children:"Processes"}),r.jsx(fn,{children:"Which part of Cogpit is consuming CPU and memory."})]}),e[80]=z):z=e[80],k=Qt,L=xe.length>0?xe.map(zP):a?r.jsx(b2,{metric:{pid:0,name:"Server",type:"Node",cpuPercent:a.cpuPercent,memoryMb:a.memory.rssMb}}):r.jsx("p",{className:"py-3 text-sm text-muted-foreground",children:"Collecting process data…"}),e[5]=x,e[6]=b,e[7]=o,e[8]=f,e[9]=d,e[10]=s,e[11]=t,e[12]=p,e[13]=a,e[14]=k,e[15]=C,e[16]=N,e[17]=_,e[18]=P,e[19]=A,e[20]=T,e[21]=E,e[22]=R,e[23]=$,e[24]=I,e[25]=M,e[26]=D,e[27]=O,e[28]=L,e[29]=F,e[30]=z,e[31]=W,e[32]=U}else k=e[14],C=e[15],N=e[16],_=e[17],P=e[18],A=e[19],T=e[20],E=e[21],R=e[22],$=e[23],I=e[24],M=e[25],D=e[26],O=e[27],L=e[28],F=e[29],z=e[30],W=e[31],U=e[32];let H;e[81]!==k||e[82]!==L?(H=r.jsx(k,{children:L}),e[81]=k,e[82]=L,e[83]=H):H=e[83];let K;e[84]!==C||e[85]!==H||e[86]!==F||e[87]!==z?(K=r.jsxs(C,{size:F,children:[z,H]}),e[84]=C,e[85]=H,e[86]=F,e[87]=z,e[88]=K):K=e[88];let V;e[89]!==A||e[90]!==T?(V=T.length>0&&r.jsxs(Jt,{size:"sm",children:[r.jsxs(rn,{children:[r.jsx(an,{children:"Agent processes"}),r.jsx(fn,{children:"Claude sessions, browsers, and scripts running outside Cogpit."})]}),r.jsx(Qt,{children:T.map((xe,me)=>r.jsxs("div",{children:[me>0&&r.jsx(St,{}),r.jsx(RP,{metric:xe,onKill:je=>void A(je)})]},xe.pid))})]}),e[89]=A,e[90]=T,e[91]=V):V=e[91];let Y;e[92]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx(an,{children:"Server activity"}),e[92]=Y):Y=e[92];const G=(a==null?void 0:a.sampleWindowSeconds)??10;let J;e[93]!==G?(J=r.jsxs(rn,{children:[Y,r.jsxs(fn,{children:["File checks, streams, and agent work over the last ",G," seconds."]})]}),e[93]=G,e[94]=J):J=e[94];let Q;e[95]!==(a==null?void 0:a.activities)?(Q=(a==null?void 0:a.activities)??[],e[95]=a==null?void 0:a.activities,e[96]=Q):Q=e[96];let X;e[97]!==Q?(X=r.jsx(Qt,{children:r.jsx(Kp,{metrics:Q,emptyLabel:"No watched-file or stream activity in this sample."})}),e[97]=Q,e[98]=X):X=e[98];let Z;e[99]!==J||e[100]!==X?(Z=r.jsxs(Jt,{size:"sm",children:[J,X]}),e[99]=J,e[100]=X,e[101]=Z):Z=e[101];let te;e[102]===Symbol.for("react.memo_cache_sentinel")?(te=r.jsxs(rn,{children:[r.jsx(an,{children:"API activity"}),r.jsx(fn,{children:"Requests ranked by recent frequency and time."})]}),e[102]=te):te=e[102];let ne;e[103]!==(a==null?void 0:a.requests)?(ne=(a==null?void 0:a.requests)??[],e[103]=a==null?void 0:a.requests,e[104]=ne):ne=e[104];let re;e[105]!==ne?(re=r.jsxs(Jt,{size:"sm",children:[te,r.jsx(Qt,{children:r.jsx(Kp,{metrics:ne,emptyLabel:"No API requests in this sample."})})]}),e[105]=ne,e[106]=re):re=e[106];let ie;e[107]!==Z||e[108]!==re?(ie=r.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[Z,re]}),e[107]=Z,e[108]=re,e[109]=ie):ie=e[109];let ae;e[110]!==a?(ae=a&&r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Server event loop ",To(a.eventLoopPercent)," · heap ",ea(a.memory.heapUsedMb)," · RSS ",ea(a.memory.rssMb)]}),e[110]=a,e[111]=ae):ae=e[111];let se;e[112]!==E||e[113]!==K||e[114]!==V||e[115]!==ie||e[116]!==ae||e[117]!==W||e[118]!==U?(se=r.jsxs("div",{className:W,children:[U,E,K,V,ie,ae]}),e[112]=E,e[113]=K,e[114]=V,e[115]=ie,e[116]=ae,e[117]=W,e[118]=U,e[119]=se):se=e[119];let ue;e[120]!==N||e[121]!==R||e[122]!==se?(ue=r.jsx(N,{className:R,children:se}),e[120]=N,e[121]=R,e[122]=se,e[123]=ue):ue=e[123];let le;e[124]!==_||e[125]!==$||e[126]!==I||e[127]!==M||e[128]!==ue?(le=r.jsxs(_,{className:$,children:[I,M,ue]}),e[124]=_,e[125]=$,e[126]=I,e[127]=M,e[128]=ue,e[129]=le):le=e[129];let de;return e[130]!==P||e[131]!==D||e[132]!==O||e[133]!==le?(de=r.jsx(P,{open:D,onOpenChange:O,children:le}),e[130]=P,e[131]=D,e[132]=O,e[133]=le,e[134]=de):de=e[134],de}function zP(n,e){return r.jsxs("div",{children:[e>0&&r.jsx(St,{}),r.jsx(b2,{metric:n})]},n.pid)}function FP(n){return setTimeout(n,1e3)}function BP(n,e){return n+e.cpuPercent}function UP(n,e){return e.cpuPercent-n.cpuPercent}function WP(n,e){return n+e.cpuPercent}async function HP(n){if(!n.ok)throw new Error(`Server monitor returned ${n.status}`);return n.json()}function KP(n){return`${n.title??`Pull request #${n.number}`}
122
- ${n.repo}${n.isDraft?" · draft":""}`}function v2(n){return{href:n.url,target:"_blank",rel:"noreferrer",onClick:e=>e.stopPropagation(),"aria-label":`Pull request #${n.number}`,title:KP(n)}}function qa(n){const e=B.c(17),{pullRequests:t,max:s,compact:o,layout:i}=n,a=s===void 0?3:s,l=i===void 0?"chips":i;if(!(t!=null&&t.length))return null;if(l==="list"){let f;e[0]!==t?(f=t.map(VP),e[0]=t,e[1]=f):f=e[1];let m;return e[2]!==f?(m=r.jsx("div",{className:"flex flex-col gap-0.5",children:f}),e[2]=f,e[3]=m):m=e[3],m}let c,d;if(e[4]!==o||e[5]!==a||e[6]!==t){const f=t.slice(-a);if(e[9]!==a||e[10]!==t){const p=t.slice(0,-a);c=p.length>0&&r.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",title:p.map(qP).join(`
123
- `),children:["+",p.length]}),e[9]=a,e[10]=t,e[11]=c}else c=e[11];let m;e[12]!==o?(m=p=>{const h=p.isDraft?td:Er;return r.jsxs(_e,{variant:p.isDraft?"outline":"secondary",render:r.jsx("a",{...v2(p)}),className:q("shrink-0",o&&"px-1"),children:[r.jsx(h,{"data-icon":"inline-start"}),"#",p.number]},p.url)},e[12]=o,e[13]=m):m=e[13],d=f.map(m),e[4]=o,e[5]=a,e[6]=t,e[7]=c,e[8]=d}else c=e[7],d=e[8];let u;return e[14]!==c||e[15]!==d?(u=r.jsxs(r.Fragment,{children:[c,d]}),e[14]=c,e[15]=d,e[16]=u):u=e[16],u}function qP(n){return`#${n.number} ${n.title??n.repo}`}function VP(n){const e=n.isDraft?td:Er;return r.jsxs("a",{...v2(n),className:"flex items-center gap-1 text-foreground hover:underline",children:[r.jsx(e,{className:"size-2.5 shrink-0"}),r.jsxs("span",{className:"shrink-0",children:["#",n.number]}),n.title&&r.jsx("span",{className:"truncate text-muted-foreground",children:n.title})]},n.url)}const GP=y.memo(function(e){const t=B.c(37),{session:s,sessionSource:o,isLive:i,pullRequests:a,copied:l,creatingSession:c,onCopyResume:d,onNewSession:u,onDuplicateSession:f,onOpenTerminal:m}=e;let p;if(t[0]!==o){const A=o?Ns(o.fileName):null;p=A?eu(A.agentId):null,t[0]=o,t[1]=p}else p=t[1];const h=p;let g;t[2]!==s.turns?(g=s.turns.some(JP),t[2]=s.turns,t[3]=g):g=t[3];const x=g;let b;t[4]!==s.rawMessages||t[5]!==(o==null?void 0:o.dirName)?(b=So(o==null?void 0:o.dirName).contextWindow?s.rawMessages:[],t[4]=s.rawMessages,t[5]=o==null?void 0:o.dirName,t[6]=b):b=t[6];const w=b;let v;t[7]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx("div",{className:q(Mn,"flex h-8 min-w-0 items-center gap-2 pl-1 pr-3")}),t[7]=v):v=t[7];let S;t[8]!==l||t[9]!==c||t[10]!==d||t[11]!==f||t[12]!==u||t[13]!==m||t[14]!==s||t[15]!==o?(S=o?r.jsx(XP,{session:s,sessionSource:o,copied:l,creatingSession:c,onCopyResume:d,onNewSession:u,onDuplicateSession:f,onOpenTerminal:m}):r.jsx("button",{type:"button",onClick:d,className:"truncate rounded-full px-1.5 py-1 text-sm font-medium text-foreground",children:l?"Copied":s.slug||s.sessionId.slice(0,8)}),t[8]=l,t[9]=c,t[10]=d,t[11]=f,t[12]=u,t[13]=m,t[14]=s,t[15]=o,t[16]=S):S=t[16];let j;t[17]!==i?(j=i&&r.jsx(Na,{"aria-label":"Session is live"}),t[17]=i,t[18]=j):j=t[18];let k;t[19]!==s.model?(k=s.model&&r.jsx("span",{className:"shrink-0 font-mono text-[11px] text-foreground/80",children:Js(s.model)}),t[19]=s.model,t[20]=k):k=t[20];let C;t[21]!==w?(C=r.jsx(e1,{rawMessages:w}),t[21]=w,t[22]=C):C=t[22];let N;t[23]!==S||t[24]!==j||t[25]!==k||t[26]!==C?(N=r.jsxs(Rt,{delay:200,render:v,children:[S,j,k,C]}),t[23]=S,t[24]=j,t[25]=k,t[26]=C,t[27]=N):N=t[27];let _;t[28]!==a||t[29]!==w||t[30]!==s||t[31]!==h||t[32]!==x?(_=r.jsx(It,{role:"tooltip",side:"bottom",align:"start",sideOffset:6,className:"p-3",children:r.jsx(YP,{session:s,thinkingEnabled:x,subAgentLabel:h,pullRequests:a,rawMessages:w})}),t[28]=a,t[29]=w,t[30]=s,t[31]=h,t[32]=x,t[33]=_):_=t[33];let P;return t[34]!==_||t[35]!==N?(P=r.jsxs(At,{children:[N,_]}),t[34]=_,t[35]=N,t[36]=P):P=t[36],P});function lo(n){const e=B.c(7),{label:t,children:s}=n;let o;e[0]!==t?(o=r.jsx("span",{className:"w-24 shrink-0 text-muted-foreground",children:t}),e[0]=t,e[1]=o):o=e[1];let i;e[2]!==s?(i=r.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:s}),e[2]=s,e[3]=i):i=e[3];let a;return e[4]!==o||e[5]!==i?(a=r.jsxs("div",{className:"flex gap-3",children:[o,i]}),e[4]=o,e[5]=i,e[6]=a):a=e[6],a}function YP(n){const e=B.c(33),{session:t,thinkingEnabled:s,subAgentLabel:o,pullRequests:i,rawMessages:a}=n;let l,c,d,u,f,m,p;if(e[0]!==i||e[1]!==a||e[2]!==t.branchedFrom||e[3]!==t.gitBranch||e[4]!==t.model||e[5]!==o||e[6]!==s){const g=Rg(a),x=t.branchedFrom;l="flex min-w-64 max-w-96 flex-col gap-1.5 text-xs",e[14]!==t.model||e[15]!==s?(c=t.model&&r.jsxs(lo,{label:"Model",children:[r.jsx("span",{children:Js(t.model)}),s&&r.jsx("span",{className:"text-muted-foreground",children:"· thinking"})]}),e[14]=t.model,e[15]=s,e[16]=c):c=e[16],e[17]!==t.gitBranch?(d=t.gitBranch&&r.jsx(lo,{label:"Branch",children:r.jsx("span",{className:"truncate font-mono",children:t.gitBranch})}),e[17]=t.gitBranch,e[18]=d):d=e[18],e[19]!==i?(u=i.length>0&&r.jsx(lo,{label:"Pull requests",children:r.jsx(qa,{pullRequests:i})}),e[19]=i,e[20]=u):u=e[20],e[21]!==o?(f=o&&r.jsx(lo,{label:"Agent",children:o}),e[21]=o,e[22]=f):f=e[22],e[23]!==x?(m=x&&r.jsxs(lo,{label:"Duplicated from",children:[x.sessionId.slice(0,8),x.turnIndex!=null?` at turn ${x.turnIndex+1}`:""]}),e[23]=x,e[24]=m):m=e[24],p=g&&r.jsxs(lo,{label:"Context",children:[ut(Math.max(0,g.compactAt-g.used))," left before compact ·"," ",ut(g.used)," / ",ut(g.limit)]}),e[0]=i,e[1]=a,e[2]=t.branchedFrom,e[3]=t.gitBranch,e[4]=t.model,e[5]=o,e[6]=s,e[7]=l,e[8]=c,e[9]=d,e[10]=u,e[11]=f,e[12]=m,e[13]=p}else l=e[7],c=e[8],d=e[9],u=e[10],f=e[11],m=e[12],p=e[13];let h;return e[25]!==l||e[26]!==c||e[27]!==d||e[28]!==u||e[29]!==f||e[30]!==m||e[31]!==p?(h=r.jsxs("div",{className:l,children:[c,d,u,f,m,p]}),e[25]=l,e[26]=c,e[27]=d,e[28]=u,e[29]=f,e[30]=m,e[31]=p,e[32]=h):h=e[32],h}function XP(n){const e=B.c(54),{session:t,sessionSource:s,copied:o,creatingSession:i,onCopyResume:a,onNewSession:l,onDuplicateSession:c,onOpenTerminal:d}=n,{dispatch:u}=zt(),f=!!(t.cwd||s.dirName);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=Bs(),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?`${Qn(t.cwd)} / ${g}`:g,e[4]=t.cwd,e[5]=g,e[6]=x):x=e[6];const b=x;let w;e[7]!==t.cwd||e[8]!==s.dirName?(w={path:t.cwd,dirName:s.dirName},e[7]=t.cwd,e[8]=s.dirName,e[9]=w):w=e[9];const v=w;let S;e[10]===Symbol.for("react.memo_cache_sentinel")?(S=!p||_d(),e[10]=S):S=e[10];const j=S;let k;e[11]!==u||e[12]!==s.dirName?(k=function(){y.startTransition(()=>{u({type:"GO_HOME",isMobile:!1}),u({type:"SET_DASHBOARD_PROJECT",dirName:s.dirName})})},e[11]=u,e[12]=s.dirName,e[13]=k):k=e[13];const C=k,N=`Copy resume command for ${b}; open session actions with the context menu`;let _;e[14]!==a||e[15]!==N?(_=r.jsx("button",{type:"button",onClick:a,className:"flex min-w-0 max-w-80 items-center gap-1.5 truncate rounded-full px-1.5 py-1 text-sm font-medium text-foreground transition-colors hover:bg-accent","aria-label":N,"aria-haspopup":"menu",title:"Click to copy resume command. Right-click for session actions."}),e[14]=a,e[15]=N,e[16]=_):_=e[16];let P;e[17]!==o||e[18]!==t.cwd||e[19]!==g?(P=o?r.jsxs("span",{className:"flex items-center gap-1.5 text-success",children:[r.jsx(mt,{className:"size-3"})," Copied"]}):r.jsxs(r.Fragment,{children:[t.cwd&&r.jsx("span",{className:"truncate text-muted-foreground",children:Qn(t.cwd)}),t.cwd&&r.jsx("span",{className:"text-muted-foreground/50",children:"/"}),r.jsx("span",{className:"truncate",children:g})]}),e[17]=o,e[18]=t.cwd,e[19]=g,e[20]=P):P=e[20];let A;e[21]!==_||e[22]!==P?(A=r.jsx(Ba,{render:_,children:P}),e[21]=_,e[22]=P,e[23]=A):A=e[23];let T;e[24]!==l||e[25]!==t.cwd||e[26]!==s.dirName?(T=()=>l(s.dirName,t.cwd),e[24]=l,e[25]=t.cwd,e[26]=s.dirName,e[27]=T):T=e[27];let E;e[28]!==i?(E=i?r.jsx(xt,{className:"size-3.5"}):r.jsx(Ln,{className:"size-3.5"}),e[28]=i,e[29]=E):E=e[29];let R;e[30]!==i||e[31]!==T||e[32]!==E?(R=r.jsxs(on,{disabled:i,onClick:T,children:[E,"New session in this project"]}),e[30]=i,e[31]=T,e[32]=E,e[33]=R):R=e[33];let $;e[34]!==c?($=c&&r.jsxs(on,{onClick:c,children:[r.jsx(An,{className:"size-3.5"}),"Duplicate this session"]}),e[34]=c,e[35]=$):$=e[35];let I;e[36]!==f||e[37]!==v?(I=f&&(j||!p)&&r.jsxs(r.Fragment,{children:[r.jsx(wr,{}),j&&r.jsxs(on,{onClick:()=>k1(v),children:[r.jsx(Nr,{className:"size-3.5"}),"Open project in editor"]}),!p&&r.jsxs(on,{onClick:()=>C1(v),children:[r.jsx(eg,{className:"size-3.5"}),"Reveal in file manager"]})]}),e[36]=f,e[37]=v,e[38]=I):I=e[38];let M;e[39]!==d?(M=d&&!p&&lt("terminal")&&r.jsxs(on,{onClick:d,children:[r.jsx(Gs,{className:"size-3.5"}),"Open terminal in project"]}),e[39]=d,e[40]=M):M=e[40];let D;e[41]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(wr,{}),e[41]=D):D=e[41];let O;e[42]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsx(jo,{className:"size-3.5"}),e[42]=O):O=e[42];let L;e[43]!==C?(L=r.jsxs(on,{onClick:C,children:[O,"View all sessions in this project"]}),e[43]=C,e[44]=L):L=e[44];let F;e[45]!==R||e[46]!==$||e[47]!==I||e[48]!==M||e[49]!==L?(F=r.jsxs(Ua,{className:"min-w-56",children:[R,$,I,M,D,L]}),e[45]=R,e[46]=$,e[47]=I,e[48]=M,e[49]=L,e[50]=F):F=e[50];let z;return e[51]!==A||e[52]!==F?(z=r.jsxs(Fa,{children:[A,F]}),e[51]=A,e[52]=F,e[53]=z):z=e[53],z}function JP(n){return n.thinking.length>0}const Ac="Could not reach the server";async function ji(n,e){try{return await ve(n,e)}catch{return null}}async function Ll(n){const e=await(n==null?void 0:n.json().catch(()=>null)),t=e==null?void 0:e.error;return typeof t=="string"&&t.length>0?t:Ac}function QP(){const n=B.c(15);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],n[0]=e):e=n[0];const[t,s]=y.useState(e),[o,i]=y.useState(null),a=y.useRef(!0);let l,c;n[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>(a.current=!0,()=>{a.current=!1}),c=[],n[1]=l,n[2]=c):(l=n[1],c=n[2]),y.useEffect(l,c);let d;n[3]===Symbol.for("react.memo_cache_sentinel")?(d=async()=>{const k=await ji("/api/shares");if(!(k!=null&&k.ok))return;const C=await k.json().catch(nA);a.current&&Array.isArray(C)&&s(C)},n[3]=d):d=n[3];const u=d;let f,m;n[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{u()},m=[u],n[4]=f,n[5]=m):(f=n[4],m=n[5]),y.useEffect(f,m);let p;n[6]===Symbol.for("react.memo_cache_sentinel")?(p=async k=>{i(null);const C=await ji("/api/shares",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:k})});if(!(C!=null&&C.ok))return a.current&&i(await Ll(C)),null;const N=await C.json().catch(tA);if(!(N!=null&&N.passphrase)||!N.share)return a.current&&i(Ac),null;const _=N.share;return a.current&&s(P=>[...P.filter(A=>A.sessionId!==_.sessionId),_]),N.passphrase},n[6]=p):p=n[6];const h=p;let g;n[7]===Symbol.for("react.memo_cache_sentinel")?(g=async k=>{i(null);const C=await ji(`/api/shares/${encodeURIComponent(k)}/regenerate`,{method:"POST"});if(!(C!=null&&C.ok))return a.current&&i(await Ll(C)),null;const N=await C.json().catch(eA);return N!=null&&N.passphrase?(u(),N.passphrase):(a.current&&i(Ac),null)},n[7]=g):g=n[7];const x=g;let b;n[8]===Symbol.for("react.memo_cache_sentinel")?(b=async k=>{i(null);const C=await ji(`/api/shares/${encodeURIComponent(k)}`,{method:"DELETE"});if(!(C!=null&&C.ok)){a.current&&i(await Ll(C));return}a.current&&s(N=>N.filter(_=>_.sessionId!==k))},n[8]=b):b=n[8];const w=b;let v;n[9]!==t?(v=async()=>{const k=t.map(ZP);for(const C of k)await w(C)},n[9]=t,n[10]=v):v=n[10];const S=v;let j;return n[11]!==o||n[12]!==S||n[13]!==t?(j={shares:t,error:o,refresh:u,create:h,regenerate:x,revoke:w,revokeAll:S},n[11]=o,n[12]=S,n[13]=t,n[14]=j):j=n[14],j}function ZP(n){return n.sessionId}function eA(){return null}function tA(){return null}function nA(){return null}const sA=5e3,oA="••••";function rA(n){return n===0?"No guests connected":n===1?"1 guest connected":`${n} guests connected`}function iA({sessionId:n}){const{config:{networkAccessDisabled:e}}=zt(),{shares:t,error:s,refresh:o,create:i,regenerate:a,revoke:l}=QP(),[c,d]=y.useState(!1),[u,f]=y.useState(null),[m,p]=y.useState(!1),[h,g]=Hs(),[x,b]=Hs(),w=t.find(k=>k.sessionId===n)??null,v=`${window.location.origin}${b4(n)}`;y.useEffect(()=>f(null),[n]),y.useEffect(()=>{if(!c)return;o();const k=setInterval(()=>void o(),sA);return()=>clearInterval(k)},[c,o]);async function S(k){p(!0);try{await k()}finally{p(!1)}}const j=e&&r.jsx("p",{className:"text-xs text-muted-foreground",children:"Network access is off, so this link only works on this machine."});return r.jsxs(Wn,{open:c,onOpenChange:k=>{d(k),k||f(null)},children:[r.jsx(Hn,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm","aria-label":w?"Session is shared":"Share session",className:q(w&&"bg-primary/15 text-primary hover:bg-primary/25")}),children:r.jsx(l3,{"data-icon":"inline-start"})}),r.jsx(Kn,{align:"end",sideOffset:6,className:"w-80 p-3",children:w?r.jsxs("div",{className:"flex flex-col gap-2.5",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("code",{className:"min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 font-mono text-[11px]",children:v}),r.jsx(ee,{variant:"ghost",size:"icon-xs","aria-label":"Copy link",onClick:()=>g(v),children:h?r.jsx(mt,{"data-icon":"inline-start"}):r.jsx(An,{"data-icon":"inline-start"})})]}),r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("code",{className:"min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 font-mono text-[11px]",children:u??oA}),r.jsx(ee,{variant:"ghost",size:"icon-xs","aria-label":"Regenerate passphrase",disabled:m,onClick:()=>S(async()=>{f(await a(n))}),children:r.jsx(Ot,{"data-icon":"inline-start"})})]}),u?r.jsx(ee,{variant:"secondary",size:"xs",onClick:()=>b(`${v}
124
- Passphrase: ${u}`),children:x?"Copied":"Copy link & passphrase"}):r.jsx("p",{className:"text-xs text-muted-foreground",children:"The passphrase is only shown once. Regenerate to get a new one."}),j,s&&r.jsx("p",{className:"text-xs text-destructive",children:s}),r.jsxs("div",{className:"flex items-center justify-between gap-2 border-t pt-2",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:rA(w.guests)}),r.jsx(ee,{variant:"ghost",size:"xs",className:"text-destructive hover:text-destructive",disabled:m,onClick:()=>S(async()=>{await l(n),f(null)}),children:"Stop sharing"})]})]}):r.jsxs("div",{className:"flex flex-col gap-2.5",children:[r.jsx("p",{className:"text-xs text-muted-foreground",children:"Anyone with the link and passphrase can read and join this session."}),j,s&&r.jsx("p",{className:"text-xs text-destructive",children:s}),r.jsx(ee,{size:"xs",disabled:m,onClick:()=>S(async()=>{f(await i(n))}),children:"Enable sharing"})]})})]})}function fu(n,e,t){if(!(n===void 0||!Number.isFinite(n)))return{utilization:Math.min(100,Math.max(0,n)),...e===void 0?{}:{resetsAt:e},...t===void 0?{}:{label:t}}}function at(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)?n:void 0}function Tn(n){return typeof n=="number"&&Number.isFinite(n)?n:void 0}function vs(n){return typeof n=="string"?n:void 0}function xs(n){return n?fu(Tn(n.utilization),vs(n.resets_at)):void 0}function y2(n){if(n)return{isEnabled:!!n.is_enabled,monthlyLimit:Tn(n.monthly_limit),usedCredits:Tn(n.used_credits),utilization:Tn(n.utilization)}}function aA(n){return{fiveHour:xs(at(n.five_hour)),sevenDay:xs(at(n.seven_day)),sevenDayOpus:xs(at(n.seven_day_opus)),sevenDaySonnet:xs(at(n.seven_day_sonnet)),extraUsage:y2(at(n.extra_usage)),subscriptionType:vs(n.subscriptionType)}}function lA(n){if(n.available!==!0)return null;const e=at(n.usage),t=at(e==null?void 0:e.rate_limits),s=at(n.account),o={fiveHour:xs(at(t==null?void 0:t.five_hour)),sevenDay:xs(at(t==null?void 0:t.seven_day)),sevenDayOpus:xs(at(t==null?void 0:t.seven_day_opus)),sevenDaySonnet:xs(at(t==null?void 0:t.seven_day_sonnet)),extraUsage:y2(at(t==null?void 0:t.extra_usage)),subscriptionType:vs(e==null?void 0:e.subscription_type)??vs(s==null?void 0:s.subscriptionType)};return o.fiveHour||o.sevenDay||o.extraUsage||o.subscriptionType?o:null}function cA(n){const e=Tn(n);if(e!==void 0)return new Date(e<1e10?e*1e3:e).toISOString()}function dA(n,e){const t=Tn(n);return t===void 0||t<=0?e:t%1440===0?`${t/1440}-day`:t%60===0?`${t/60}-hour`:`${t}-minute`}function qp(n,e){if(n)return fu(Tn(n.usedPercent),cA(n.resetsAt),dA(n.windowDurationMins,e))}function uA(n){var d,u,f;if(n.available!==!0)return null;const e=at((d=at(n.rateLimits))==null?void 0:d.rateLimits),t=at((u=at(n.account))==null?void 0:u.account),s=at((f=at(n.usage))==null?void 0:f.summary),o=at(e==null?void 0:e.credits),i=qp(at(e==null?void 0:e.primary),"Primary"),a=qp(at(e==null?void 0:e.secondary),"Secondary"),l=s==null?void 0:s.lifetimeTokens,c=Tn(l)??(typeof l=="string"&&Number.isSafeInteger(Number(l))?Number(l):void 0);return!i&&!a&&c===void 0?null:{fiveHour:i,sevenDay:a,subscriptionType:vs(e==null?void 0:e.planType)??vs(t==null?void 0:t.planType),lifetimeTokens:c,creditBalance:vs(o==null?void 0:o.balance),creditsUnlimited:(o==null?void 0:o.unlimited)===!0}}function Vp(n,e){if(!n)return;const t=Tn(n.remainingPercentage),s=Tn(n.usedRequests),o=Tn(n.entitlementRequests);let i;return t!==void 0?i=100-t:n.isUnlimitedEntitlement===!0||o===-1?i=0:s!==void 0&&o!==void 0&&o>0&&(i=s/o*100),fu(i,vs(n.resetDate),e)}function fA(n){var s;if(n.available!==!0)return null;const e=at((s=at(n.quota))==null?void 0:s.quotaSnapshots),t=Vp(at(e==null?void 0:e.chat),"Chat")??Vp(at(e==null?void 0:e.premium_interactions),"Premium interactions");return t?{fiveHour:t}:null}const mA={claude:{endpoint:"/api/claude/runtime",read:lA,legacy:{endpoint:"/api/usage",read:aA}},codex:{endpoint:"/api/codex/runtime",read:uA},copilot:{endpoint:"/api/copilot/runtime",read:fA}};function pA(n){return mA[n]}const hA=300*1e3;function gA(n=Xs){const e=En("viewUsage"),[t,s]=y.useState(null),[o,i]=y.useState(!1),[a,l]=y.useState(!1),c=y.useRef(0),d=y.useRef(null),u=y.useCallback(async()=>{var h;if(!e)return;const f=++c.current;(h=d.current)==null||h.abort();const m=new AbortController;d.current=m;const p=()=>c.current===f&&!m.signal.aborted;i(!0);try{const g=pA(n);let x=await ve(g.endpoint,{signal:m.signal}),b=g.read;if(g.legacy&&!x.ok&&!m.signal.aborted&&(x=await ve(g.legacy.endpoint,{signal:m.signal}),b=g.legacy.read),!p())return;if(x.status===501||x.status===404){l(!1);return}if(!x.ok){l(!0);return}const w=await x.json();if(!p())return;const v=b(w);l(v!==null),s(v?{...v,agentKind:n,fetchedAt:Date.now()}:null)}catch{}finally{p()&&(d.current=null,i(!1))}},[n,e]);return y.useEffect(()=>{var m;if(s(null),l(!1),!e){i(!1),c.current+=1,(m=d.current)==null||m.abort(),d.current=null;return}u();const f=setInterval(u,hA);return()=>{var p;clearInterval(f),c.current+=1,(p=d.current)==null||p.abort(),d.current=null}},[n,e,u]),{usage:e?t:null,loading:e&&o,available:e&&a,refresh:u}}function w2(n){return n>=90?"danger":n>=80?"warning":n>=60?"caution":"nominal"}const j2={nominal:"text-muted-foreground",caution:"text-warning",warning:"text-warning",danger:"text-destructive"};function xA(n){var d;const e=B.c(31),{usage:t}=n;let s,o,i;if(e[0]!==t.agentKind||e[1]!==t.fetchedAt||e[2]!==t.fiveHour||e[3]!==t.sevenDay||e[4]!==t.sevenDayOpus||e[5]!==t.sevenDaySonnet||e[6]!==t.subscriptionType){const u=[];t.fiveHour&&u.push({label:t.fiveHour.label??"5-hour",pct:t.fiveHour.utilization,resetsAt:t.fiveHour.resetsAt}),t.sevenDay&&u.push({label:t.sevenDay.label??"7-day",pct:t.sevenDay.utilization,resetsAt:t.sevenDay.resetsAt}),t.sevenDayOpus&&u.push({label:"Opus",pct:t.sevenDayOpus.utilization,resetsAt:t.sevenDayOpus.resetsAt}),t.sevenDaySonnet&&u.push({label:"Sonnet",pct:t.sevenDaySonnet.utilization,resetsAt:t.sevenDaySonnet.resetsAt}),s="flex min-w-[200px] flex-col gap-2";let f;e[10]!==t.agentKind?(f=t.agentKind?ja(t.agentKind):"Agent",e[10]=t.agentKind,e[11]=f):f=e[11];let m;e[12]!==f?(m=r.jsxs("span",{className:"text-xs font-medium uppercase tracking-wide",children:[f," usage"]}),e[12]=f,e[13]=m):m=e[13];let p;e[14]!==t.subscriptionType?(p=t.subscriptionType&&r.jsx(_e,{variant:"secondary",children:t.subscriptionType}),e[14]=t.subscriptionType,e[15]=p):p=e[15],e[16]!==m||e[17]!==p?(o=r.jsxs("div",{className:"flex items-center justify-between",children:[m,p]}),e[16]=m,e[17]=p,e[18]=o):o=e[18],i=u.map(h=>{const g=h.resetsAt&&t.fetchedAt!=null?new Date(h.resetsAt).getTime()-t.fetchedAt:null,x=g!=null?Math.max(0,Math.round(g/36e5)):null,b=w2(h.pct);return r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs",children:[r.jsx("span",{className:"text-muted-foreground",children:h.label}),r.jsxs("span",{className:q("font-semibold",j2[b]),children:[h.pct.toFixed(1),"%"]})]}),r.jsx(Lr,{value:Math.min(h.pct,100)}),x!=null&&r.jsxs("div",{className:"text-xs text-muted-foreground",children:["Resets in ",x,"h"]})]},h.label)}),e[0]=t.agentKind,e[1]=t.fetchedAt,e[2]=t.fiveHour,e[3]=t.sevenDay,e[4]=t.sevenDayOpus,e[5]=t.sevenDaySonnet,e[6]=t.subscriptionType,e[7]=s,e[8]=o,e[9]=i}else s=e[7],o=e[8],i=e[9];let a;e[19]!==t.extraUsage?(a=((d=t.extraUsage)==null?void 0:d.isEnabled)&&t.extraUsage.usedCredits!=null&&t.extraUsage.monthlyLimit!=null&&r.jsxs("div",{className:"flex flex-col gap-1 pt-1 text-xs text-muted-foreground",children:[r.jsx(St,{}),"Extra: $",t.extraUsage.usedCredits.toFixed(2)," / $",t.extraUsage.monthlyLimit.toFixed(2)]}),e[19]=t.extraUsage,e[20]=a):a=e[20];let l;e[21]!==t.creditBalance||e[22]!==t.creditsUnlimited||e[23]!==t.lifetimeTokens?(l=(t.lifetimeTokens!=null||t.creditBalance||t.creditsUnlimited)&&r.jsxs("div",{className:"flex flex-col gap-1 pt-1 text-xs text-muted-foreground",children:[r.jsx(St,{}),t.lifetimeTokens!=null&&r.jsxs("div",{children:["Lifetime: ",ut(t.lifetimeTokens)," tokens"]}),t.creditsUnlimited?r.jsx("div",{children:"Credits: Unlimited"}):t.creditBalance?r.jsxs("div",{children:["Credits: ",t.creditBalance]}):null]}),e[21]=t.creditBalance,e[22]=t.creditsUnlimited,e[23]=t.lifetimeTokens,e[24]=l):l=e[24];let c;return e[25]!==s||e[26]!==o||e[27]!==i||e[28]!==a||e[29]!==l?(c=r.jsxs("div",{className:s,children:[o,i,a,l]}),e[25]=s,e[26]=o,e[27]=i,e[28]=a,e[29]=l,e[30]=c):c=e[30],c}function bA(n){var S,j;const e=B.c(22),{agentKind:t}=n,s=t===void 0?Xs:t,{usage:o,loading:i,available:a,refresh:l}=gA(s);if(!a||!o)return null;const c=((S=o.fiveHour)==null?void 0:S.utilization)??((j=o.sevenDay)==null?void 0:j.utilization);if(c==null)return null;let d;e[0]!==o.agentKind?(d=o.agentKind?ja(o.agentKind):"agent",e[0]=o.agentKind,e[1]=d):d=e[1];const u=`Refresh ${d} usage`;let f;e[2]!==i||e[3]!==l||e[4]!==u?(f=r.jsx(ee,{type:"button",variant:"ghost",size:"xs","aria-label":u,onClick:l,disabled:i,className:"mr-1 font-mono"}),e[2]=i,e[3]=l,e[4]=u,e[5]=f):f=e[5];const m=j2[w2(c)],p=i&&"opacity-50";let h;e[6]!==m||e[7]!==p?(h=q("tabular-nums",m,p),e[6]=m,e[7]=p,e[8]=h):h=e[8];let g;e[9]!==c?(g=c.toFixed(0),e[9]=c,e[10]=g):g=e[10];let x;e[11]!==h||e[12]!==g?(x=r.jsxs("span",{className:h,children:[g,"%"]}),e[11]=h,e[12]=g,e[13]=x):x=e[13];let b;e[14]!==f||e[15]!==x?(b=r.jsx(Rt,{render:f,children:x}),e[14]=f,e[15]=x,e[16]=b):b=e[16];let w;e[17]!==o?(w=r.jsx(It,{side:"bottom",className:"p-3",children:r.jsx(xA,{usage:o})}),e[17]=o,e[18]=w):w=e[18];let v;return e[19]!==b||e[20]!==w?(v=r.jsxs(At,{children:[b,w]}),e[19]=b,e[20]=w,e[21]=v):v=e[21],v}function vA(n,e){const t=B.c(11);let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s={summary:null,loading:!1,error:null},t[0]=s):s=t[0];const[o,i]=y.useState(s),[a,l]=y.useState(0);let c;t[1]!==n||t[2]!==e?(c=()=>{const p=new AbortController;i(wA);const h=Intl.DateTimeFormat().resolvedOptions().timeZone;return ve(`/api/usage-cost?days=${n}&tz=${encodeURIComponent(h)}`,{signal:p.signal}).then(async g=>{if(!g.ok)throw new Error(`Usage scan failed (${g.status})`);const x=await g.json();i({summary:x,loading:!1,error:null})}).catch(g=>{p.signal.aborted||i(x=>({...x,loading:!1,error:g instanceof Error?g.message:"Usage scan failed"}))}),()=>p.abort()},t[1]=n,t[2]=e,t[3]=c):c=t[3];let d;t[4]!==n||t[5]!==e||t[6]!==a?(d=[n,e,a],t[4]=n,t[5]=e,t[6]=a,t[7]=d):d=t[7],y.useEffect(c,d);let u;t[8]===Symbol.for("react.memo_cache_sentinel")?(u=()=>l(yA),t[8]=u):u=t[8];const f=u;let m;return t[9]!==o?(m={...o,refresh:f},t[9]=o,t[10]=m):m=t[10],m}function yA(n){return n+1}function wA(n){return{...n,loading:!0,error:null}}function jA(n){const e=n.trim().toLowerCase().replace(/\[[^\]]*\]$/,""),t=e.lastIndexOf("/");return t===-1?e:e.slice(t+1)}const SA=new Set(["<synthetic>","synthetic","opus","sonnet","haiku","fable"]);function NA(n,e){const t=jA(e);return t.length===0||SA.has(t)?null:n.get(t)??null}function kA(n,e){const t=n.longContextThresholdTokens,s=e.uncachedInputTokens+e.cachedInputTokens+e.cacheCreationTokens,o=t!==null&&s>t;return function(a,l,c){return a<=0?0:c===null||t===null?a*l:n.longContextPricing==="wholeRequest"?a*(o?c:l):a<=t?a*l:t*l+(a-t)*c}}function CA(n){return n.uncachedInputUsd+n.cachedInputUsd+n.cacheCreationUsd+n.outputUsd}function _A(n,e,t,s=null){const o=NA(n,e);if(o===null)return null;const i=Math.min(t.cacheCreation1hTokens,t.cacheCreationTokens),a=t.cacheCreationTokens-i,l=kA(o,t),c=s==="fast"?o.fastCostMultiplier:1;return{uncachedInputUsd:c*l(t.uncachedInputTokens,o.inputCostPerToken,o.inputCostPerTokenAboveThreshold),cachedInputUsd:c*l(t.cachedInputTokens,o.cacheReadCostPerToken,o.cacheReadCostPerTokenAboveThreshold),cacheCreationUsd:c*(l(a,o.cacheCreationCostPerToken,o.cacheCreationCostPerTokenAboveThreshold)+i*o.cacheCreation1hCostPerToken),outputUsd:c*l(t.outputTokens,o.outputCostPerToken,o.outputCostPerTokenAboveThreshold)}}function TA(n,e,t,s,o=null){const i=_A(n,e,t,o);return i===null?{costUsd:0,costSource:"unpriced"}:{costUsd:CA(i),costSource:"modelPriced"}}function mu(n){return n.uncachedInputTokens+n.cachedInputTokens+n.cacheCreationTokens+n.outputTokens}function EA(n,e,t){if(!e)return 0;const{costUsd:s,costSource:o}=TA(n,e,{uncachedInputTokens:t.input_tokens,cachedInputTokens:t.cache_read_input_tokens??0,cacheCreationTokens:t.cache_creation_input_tokens??0,cacheCreation1hTokens:0,outputTokens:t.output_tokens});return o==="unpriced"?0:s}const PA=[{days:7,label:"7 days"},{days:30,label:"30 days"},{days:90,label:"90 days"}],sr=$g.map(n=>({key:n,label:nn(n).displayName,color:uj(n)}));function AA(n,e){const t=[],o=Date.parse(`${e}T00:00:00Z`);for(let i=Date.parse(`${n}T00:00:00Z`);i<=o;i+=864e5)t.push(new Date(i).toISOString().slice(0,10));return t}function Gp(){return{claude:{costUsd:0,tokens:0},codex:{costUsd:0,tokens:0},copilot:{costUsd:0,tokens:0}}}function RA(n){const e=new Map;for(const o of AA(n.sinceDay,n.untilDay))e.set(o,{day:o,byProvider:Gp(),costUsd:0,tokens:0});const t=new Map,s={costUsd:0,tokens:0,cacheSavingsUsd:0,byProvider:Gp(),days:[],models:[]};for(const o of n.buckets){const i=mu(o.totals);s.costUsd+=o.costUsd,s.tokens+=i,s.cacheSavingsUsd+=o.cacheSavingsUsd,s.byProvider[o.provider].costUsd+=o.costUsd,s.byProvider[o.provider].tokens+=i;const a=e.get(o.day);a&&(a.byProvider[o.provider].costUsd+=o.costUsd,a.byProvider[o.provider].tokens+=i,a.costUsd+=o.costUsd,a.tokens+=i);const l=`${o.provider}:${o.model}`;let c=t.get(l);c||(c={provider:o.provider,model:o.model,costUsd:0,tokens:0,unpriced:!0},t.set(l,c)),c.costUsd+=o.costUsd,c.tokens+=i,o.costSource!=="unpriced"&&(c.unpriced=!1)}return s.days=[...e.values()],s.models=[...t.values()].sort((o,i)=>i.costUsd-o.costUsd||i.tokens-o.tokens),s}function Yp(n){const e=Date.parse(`${n}T00:00:00Z`);return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",timeZone:"UTC"}).format(e)}const zl=720,Fl=180,IA=18;function $A(n){const e=B.c(41),{days:t,metric:s}=n,[o,i]=y.useState(null);let a;e[0]!==s?(a=C=>s==="cost"?C.costUsd:C.tokens,e[0]=s,e[1]=a):a=e[1];const l=a;let c;if(e[2]!==t||e[3]!==l){let C;e[5]!==l?(C=N=>l(N),e[5]=l,e[6]=C):C=e[6],c=Math.max(...t.map(C)),e[2]=t,e[3]=l,e[4]=c}else c=e[4];const d=c;if(d<=0){let C;return e[7]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx("div",{className:"flex h-32 items-center justify-center text-xs text-muted-foreground",children:"No activity in this window."}),e[7]=C):C=e[7],C}const u=Fl-IA,f=zl/t.length,m=Math.max(2,Math.min(28,f-2)),p=o!==null?t[o]:null;let h;e[8]!==p||e[9]!==s||e[10]!==l?(h=p&&r.jsx("div",{className:"pointer-events-none absolute left-0 right-0 top-0 z-10 flex justify-center",children:r.jsxs("div",{className:"rounded-md border bg-popover px-2.5 py-1.5 text-xs text-popover-foreground shadow-xs",children:[r.jsx("span",{className:"font-medium",children:Yp(p.day)}),sr.map(C=>{const{key:N,label:_,color:P}=C,A=p.byProvider[N];return l(A)<=0?null:r.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-muted-foreground",children:[r.jsx("span",{"aria-hidden":!0,className:"size-1.5 rounded-full",style:{backgroundColor:P}}),_,": ",s==="cost"?mn(A.costUsd):ut(A.tokens)]},N)}),r.jsx("span",{className:"ml-2 font-medium",children:s==="cost"?mn(p.costUsd):ut(p.tokens)})]})}),e[8]=p,e[9]=s,e[10]=l,e[11]=h):h=e[11];const g=`Daily ${s==="cost"?"raw API cost":"processed tokens"} by provider`;let x,b;e[12]===Symbol.for("react.memo_cache_sentinel")?(x=()=>i(null),b=r.jsx("line",{x1:0,y1:u,x2:zl,y2:u,stroke:"var(--border)",strokeWidth:1}),e[12]=x,e[13]=b):(x=e[12],b=e[13]);let w;if(e[14]!==m||e[15]!==t||e[16]!==o||e[17]!==d||e[18]!==f||e[19]!==l){let C;e[21]!==m||e[22]!==o||e[23]!==d||e[24]!==f||e[25]!==l?(C=(N,_)=>{const P=_*f+(f-m)/2;let A=u;const T=o===_;return r.jsxs("g",{onMouseEnter:()=>i(_),children:[r.jsx("rect",{x:_*f,y:0,width:f,height:u,fill:"transparent"}),T&&r.jsx("rect",{x:_*f,y:0,width:f,height:u,fill:"var(--foreground)",opacity:.05,rx:2}),sr.map(E=>{const{key:R,color:$}=E,I=l(N.byProvider[R]);if(I<=0)return null;const M=I/d*(u-6);return A=A-M,r.jsx("rect",{x:P,y:A,width:m,height:Math.max(1,M-1.5),rx:1.5,fill:$,opacity:T?1:.85},R)})]},N.day)},e[21]=m,e[22]=o,e[23]=d,e[24]=f,e[25]=l,e[26]=C):C=e[26],w=t.map(C),e[14]=m,e[15]=t,e[16]=o,e[17]=d,e[18]=f,e[19]=l,e[20]=w}else w=e[20];let v;if(e[27]!==t||e[28]!==f){let C;e[30]!==t.length||e[31]!==f?(C=(N,_)=>_===0||_===t.length-1||t.length>10&&_%7===0&&_<t.length-3?r.jsx("text",{x:_*f+f/2,y:Fl-4,textAnchor:"middle",className:"fill-muted-foreground text-[10px]",children:Yp(N.day)},N.day):null,e[30]=t.length,e[31]=f,e[32]=C):C=e[32],v=t.map(C),e[27]=t,e[28]=f,e[29]=v}else v=e[29];let S;e[33]!==g||e[34]!==w||e[35]!==v?(S=r.jsxs("svg",{viewBox:`0 0 ${zl} ${Fl}`,className:"w-full",role:"img","aria-label":g,onMouseLeave:x,children:[b,w,v]}),e[33]=g,e[34]=w,e[35]=v,e[36]=S):S=e[36];let j;e[37]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx("div",{className:"mt-1 flex items-center gap-4",children:sr.map(MA)}),e[37]=j):j=e[37];let k;return e[38]!==h||e[39]!==S?(k=r.jsxs("div",{className:"relative",children:[h,S,j]}),e[38]=h,e[39]=S,e[40]=k):k=e[40],k}function MA(n){const{key:e,label:t,color:s}=n;return r.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[r.jsx("span",{"aria-hidden":!0,className:"size-2 rounded-full",style:{backgroundColor:s}}),t]},e)}function Bl(n){const e=B.c(7),{label:t,value:s}=n;let o;e[0]!==t?(o=r.jsx("span",{className:"text-xs text-muted-foreground",children:t}),e[0]=t,e[1]=o):o=e[1];let i;e[2]!==s?(i=r.jsx("span",{className:"text-sm font-medium text-foreground tabular-nums",children:s}),e[2]=s,e[3]=i):i=e[3];let a;return e[4]!==o||e[5]!==i?(a=r.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[o,i]}),e[4]=o,e[5]=i,e[6]=a):a=e[6],a}function OA(n){const e=B.c(68),{days:t}=n,{summary:s,loading:o,error:i,refresh:a}=vA(t,!0),[l,c]=y.useState("cost");let d;e[0]!==s?(d=s?RA(s):null,e[0]=s,e[1]=d):d=e[1];const u=d;if(i){let F;e[2]!==a?(F=r.jsx(ee,{variant:"outline",size:"sm",onClick:a,children:"Retry"}),e[2]=a,e[3]=F):F=e[3];let z;return e[4]!==i||e[5]!==F?(z=r.jsxs("div",{className:"flex flex-col items-center gap-2 py-10 text-sm text-muted-foreground",children:[i,F]}),e[4]=i,e[5]=F,e[6]=z):z=e[6],z}if(!u||!s){let F;return e[7]===Symbol.for("react.memo_cache_sentinel")?(F=r.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-sm text-muted-foreground",children:[r.jsx(xt,{className:"size-4"})," Scanning transcripts…"]}),e[7]=F):F=e[7],F}const f=o&&"opacity-60";let m;e[8]!==f?(m=q("flex flex-col gap-5",f),e[8]=f,e[9]=m):m=e[9];let p;e[10]!==u.costUsd||e[11]!==u.tokens||e[12]!==l?(p=l==="cost"?mn(u.costUsd):ut(u.tokens),e[10]=u.costUsd,e[11]=u.tokens,e[12]=l,e[13]=p):p=e[13];let h;e[14]!==p?(h=r.jsx("span",{className:"text-3xl font-semibold text-foreground tabular-nums",children:p}),e[14]=p,e[15]=h):h=e[15];const g=l==="cost"?"raw API price":"processed tokens";let x;e[16]!==s.distinctSessions||e[17]!==g?(x=r.jsxs("span",{className:"text-xs text-muted-foreground",children:[s.distinctSessions," sessions · ",g]}),e[16]=s.distinctSessions,e[17]=g,e[18]=x):x=e[18];let b;e[19]!==h||e[20]!==x?(b=r.jsxs("div",{className:"flex flex-col gap-0.5",children:[h,x]}),e[19]=h,e[20]=x,e[21]=b):b=e[21];let w;e[22]===Symbol.for("react.memo_cache_sentinel")?(w=["cost","tokens"],e[22]=w):w=e[22];let v;e[23]!==l?(v=r.jsx("div",{className:"flex rounded-md border p-0.5",children:w.map(F=>r.jsx(ee,{variant:l===F?"secondary":"ghost",size:"xs",onClick:()=>c(F),children:F==="cost"?"Cost":"Tokens"},F))}),e[23]=l,e[24]=v):v=e[24];let S;e[25]!==u.byProvider||e[26]!==l?(S=sr.map(F=>{const{key:z,label:W}=F,U=u.byProvider[z];return U.costUsd===0&&U.tokens===0?null:r.jsxs("span",{className:"text-xs text-muted-foreground tabular-nums",children:[W,": ",l==="cost"?mn(U.costUsd):ut(U.tokens)]},z)}),e[25]=u.byProvider,e[26]=l,e[27]=S):S=e[27];let j;e[28]!==v||e[29]!==S?(j=r.jsxs("div",{className:"flex flex-col items-end gap-1.5",children:[v,S]}),e[28]=v,e[29]=S,e[30]=j):j=e[30];let k;e[31]!==j||e[32]!==b?(k=r.jsxs("div",{className:"flex items-end justify-between gap-4",children:[b,j]}),e[31]=j,e[32]=b,e[33]=k):k=e[33];let C;e[34]!==u.days||e[35]!==l?(C=r.jsx($A,{days:u.days,metric:l}),e[34]=u.days,e[35]=l,e[36]=C):C=e[36];let N;e[37]!==u.tokens?(N=ut(u.tokens),e[37]=u.tokens,e[38]=N):N=e[38];let _;e[39]!==N?(_=r.jsx(Bl,{label:"Processed tokens",value:N}),e[39]=N,e[40]=_):_=e[40];let P;e[41]!==u.cacheSavingsUsd?(P=mn(u.cacheSavingsUsd),e[41]=u.cacheSavingsUsd,e[42]=P):P=e[42];let A;e[43]!==P?(A=r.jsx(Bl,{label:"Cache savings",value:P}),e[43]=P,e[44]=A):A=e[44];const T=String(s.scannedFiles);let E;e[45]!==T?(E=r.jsx(Bl,{label:"Files scanned",value:T}),e[45]=T,e[46]=E):E=e[46];let R;e[47]!==_||e[48]!==A||e[49]!==E?(R=r.jsxs("div",{className:"grid grid-cols-3 gap-x-6 gap-y-3 border-t pt-3",children:[_,A,E]}),e[47]=_,e[48]=A,e[49]=E,e[50]=R):R=e[50];let $;e[51]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx("thead",{children:r.jsxs("tr",{className:"border-b text-left text-xs text-muted-foreground",children:[r.jsx("th",{className:"py-1.5 font-normal",children:"Model"}),r.jsx("th",{className:"py-1.5 text-right font-normal",children:"Cost"}),r.jsx("th",{className:"py-1.5 text-right font-normal",children:"Share"}),r.jsx("th",{className:"py-1.5 text-right font-normal",children:"Tokens"})]})}),e[51]=$):$=e[51];let I;if(e[52]!==u.costUsd||e[53]!==u.models){let F;e[55]!==u.costUsd?(F=z=>{var W;return r.jsxs("tr",{className:"border-b border-border/50",children:[r.jsx("td",{className:"max-w-56 truncate py-1.5 text-foreground",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx("span",{"aria-hidden":!0,className:"size-2 shrink-0 rounded-full",style:{backgroundColor:(W=sr.find(U=>U.key===z.provider))==null?void 0:W.color}}),z.model]})}),r.jsx("td",{className:"py-1.5 text-right text-foreground tabular-nums",children:z.unpriced?"—":mn(z.costUsd)}),r.jsx("td",{className:"py-1.5 text-right text-muted-foreground tabular-nums",children:u.costUsd>0&&!z.unpriced?`${(z.costUsd/u.costUsd*100).toFixed(1)}%`:"—"}),r.jsx("td",{className:"py-1.5 text-right text-muted-foreground tabular-nums",children:ut(z.tokens)})]},`${z.provider}:${z.model}`)},e[55]=u.costUsd,e[56]=F):F=e[56],I=u.models.map(F),e[52]=u.costUsd,e[53]=u.models,e[54]=I}else I=e[54];let M;e[57]!==I?(M=r.jsxs("table",{className:"w-full text-sm",children:[$,r.jsx("tbody",{children:I})]}),e[57]=I,e[58]=M):M=e[58];const D=s.pricing.status==="unavailable"?" (rate table unavailable — costs incomplete)":"";let O;e[59]!==D?(O=r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Raw API-equivalent prices from LiteLLM rates",D," ","— not what a subscription bills."]}),e[59]=D,e[60]=O):O=e[60];let L;return e[61]!==k||e[62]!==C||e[63]!==R||e[64]!==M||e[65]!==O||e[66]!==m?(L=r.jsxs("div",{className:m,children:[k,C,R,M,O]}),e[61]=k,e[62]=C,e[63]=R,e[64]=M,e[65]=O,e[66]=m,e[67]=L):L=e[67],L}function DA(n){const e=B.c(15),{open:t,onOpenChange:s}=n,[o,i]=y.useState(30);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsxs("div",{children:[r.jsx(os,{children:"API usage"}),r.jsx(rs,{children:"What this machine's agent usage would cost at raw API prices."})]}),e[0]=a):a=e[0];let l;e[1]!==o?(l=PA.map(m=>r.jsx(ee,{variant:o===m.days?"secondary":"ghost",size:"xs",onClick:()=>i(m.days),children:m.label},m.days)),e[1]=o,e[2]=l):l=e[2];let c;e[3]!==l?(c=r.jsx(Ps,{children:r.jsxs("div",{className:"flex items-center justify-between gap-4 pr-6",children:[a,r.jsx("div",{className:"flex rounded-md border p-0.5",children:l})]})}),e[3]=l,e[4]=c):c=e[4];let d;e[5]!==o||e[6]!==t?(d=t&&r.jsx(OA,{days:o}),e[5]=o,e[6]=t,e[7]=d):d=e[7];let u;e[8]!==c||e[9]!==d?(u=r.jsxs(ss,{className:"max-h-[85vh] overflow-y-auto sm:max-w-3xl",children:[c,d]}),e[8]=c,e[9]=d,e[10]=u):u=e[10];let f;return e[11]!==s||e[12]!==t||e[13]!==u?(f=r.jsx(ns,{open:t,onOpenChange:s,children:u}),e[11]=s,e[12]=t,e[13]=u,e[14]=f):f=e[14],f}const LA=/https:\/\/github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/,zA=/(?:^|[\n;&|(`])[ \t]*(?:[A-Za-z_]\w*=\S*[ \t]+)*gh[ \t]+pr[ \t]+create\b/,Ul=String.raw`(?:--title|(?:^|\s)-t)(?:=|\s+)`,FA=[new RegExp(`${Ul}"((?:[^"\\\\]|\\\\.)*)"`),new RegExp(`${Ul}'([^']*)'`),new RegExp(`${Ul}(\\S+)`)];function BA(n){const e=n.command??n.cmd;if(typeof e=="string")return[e];if(Array.isArray(e)){const a=e.filter(l=>typeof l=="string");return[a.join(" "),...a]}const t=n.source;if(typeof t!="string")return[];const s=[],o=/(?:["'](?:cmd|command)["']|\b(?:cmd|command))\s*:\s*"((?:\\.|[^"\\])*)"/g;for(const a of t.matchAll(o))try{s.push(JSON.parse(`"${a[1]}"`))}catch{}const i=/(?:["'](?:cmd|command)["']|\b(?:cmd|command))\s*:\s*`([^`]*)`/g;for(const a of t.matchAll(i))s.push(a[1]);return s}function UA(n){return BA(n).find(e=>zA.test(e))??null}function WA(n){for(const e of FA){const t=e.exec(n);if(t)return t[1].replace(/\\(.)/g,"$1")}return null}function HA(){const n=[],e=new Set;function t(s){e.has(s.url)||(e.add(s.url),n.push(s))}return{pullRequests:n,add:t,record(s,o,i,a){const l=LA.exec(s);l&&t({url:l[0],number:Number(l[3]),repo:`${l[1]}/${l[2]}`,title:WA(o),isDraft:/(?:^|\s)--draft(?:\s|$)/.test(o),toolCallId:i,timestamp:a})}}}function KA(n){const e=HA();for(const t of n)for(const s of t.toolCalls){if(s.isError||!s.result)continue;const o=UA(s.input);o&&e.record(s.result,o,s.id,s.timestamp)}return e.pullRequests}function qA(...n){const e=new Map;for(const t of n)for(const s of t??[])e.has(s.url)||e.set(s.url,s);return[...e.values()].sort((t,s)=>t.timestamp.localeCompare(s.timestamp))}const co="flex h-8 items-center px-0.5",VA=y.memo(function(e){var Fe;const t=B.c(98),{showSidebar:s,sidebarRendered:o,sidebarShortcut:i,killing:a,creatingSession:l,onNewSession:c,onDuplicateSession:d,onOpenTerminal:u,onBackToMain:f,onShowWorkflows:m,workflowCount:p,onToggleSidebar:h,onKillAll:g,onOpenSettings:x}=e,b=o===void 0?s:o,{config:w}=zt(),{networkUrl:v,defaultAgentKind:S}=w,{session:j,sessionSource:k,isLive:C}=it(),N=Xd(),_=En("viewUsage"),[P,A]=y.useState(!1),[T,E]=y.useState(!1),[R,$]=Hs(),I=j==null?void 0:j.turns;let M;t[0]!==(N==null?void 0:N.sessions)||t[1]!==(j==null?void 0:j.sessionId)?(M=(Fe=N==null?void 0:N.sessions.find(Ne=>Ne.sessionId===(j==null?void 0:j.sessionId)))==null?void 0:Fe.pullRequests,t[0]=N==null?void 0:N.sessions,t[1]=j==null?void 0:j.sessionId,t[2]=M):M=t[2];const D=M;let O;t[3]!==D||t[4]!==I?(O=qA(KA(I??[]),D),t[3]=D,t[4]=I,t[5]=O):O=t[5];const L=O;let F;t[6]!==S||t[7]!==k?(F=k?k.agentKind??Et(k.dirName):S,t[6]=S,t[7]=k,t[8]=F):F=t[8];const z=F;let W;t[9]!==k?(W=k?Ns(k.fileName)!==null:!1,t[9]=k,t[10]=W):W=t[10];const U=W;let H;t[11]!==$||t[12]!==j||t[13]!==(k==null?void 0:k.agentKind)||t[14]!==(k==null?void 0:k.dirName)?(H=function(){if(!j)return;const fe=(k==null?void 0:k.agentKind)??Et((k==null?void 0:k.dirName)??null);$(hg(fe,j.sessionId,j.cwd))},t[11]=$,t[12]=j,t[13]=k==null?void 0:k.agentKind,t[14]=k==null?void 0:k.dirName,t[15]=H):H=t[15];const K=H;let V;t[16]!==v?(V=function(){v&&Ar(v).then(YA)},t[16]=v,t[17]=V):V=t[17];const Y=V;let G,J;t[18]===Symbol.for("react.memo_cache_sentinel")?(J=r.jsx("div",{"aria-hidden":!0,className:"drag-strip absolute inset-x-0 top-0 z-10 h-10"}),G=r.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-x-0 top-0 z-20 h-16 bg-gradient-to-b from-background from-50% to-transparent"}),t[18]=G,t[19]=J):(G=t[18],J=t[19]);const Q=!b&&"window-inset-start";let X;t[20]!==Q?(X=q("electron-no-drag pointer-events-auto flex min-w-0 items-center gap-1.5",Q),t[20]=Q,t[21]=X):X=t[21];let Z;t[22]!==h||t[23]!==s||t[24]!==i?(Z=!s&&r.jsx(GA,{icon:d3,label:`Show sidebar (${i})`,onClick:h}),t[22]=h,t[23]=s,t[24]=i,t[25]=Z):Z=t[25];let te;t[26]!==U||t[27]!==f||t[28]!==j?(te=j&&U&&f&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:f,className:q(Mn,"h-8 shrink-0 px-2.5 text-xs text-muted-foreground"),children:[r.jsx(Je,{className:"size-3 rotate-180"}),"Main"]}),t[26]=U,t[27]=f,t[28]=j,t[29]=te):te=t[29];let ne;t[30]!==R||t[31]!==l||t[32]!==K||t[33]!==C||t[34]!==d||t[35]!==c||t[36]!==u||t[37]!==L||t[38]!==j||t[39]!==k?(ne=j&&r.jsx(GP,{session:j,sessionSource:k,isLive:C,pullRequests:L,copied:R,creatingSession:l,onCopyResume:K,onNewSession:c,onDuplicateSession:d,onOpenTerminal:u}),t[30]=R,t[31]=l,t[32]=K,t[33]=C,t[34]=d,t[35]=c,t[36]=u,t[37]=L,t[38]=j,t[39]=k,t[40]=ne):ne=t[40];let re;t[41]!==m||t[42]!==j||t[43]!==p?(re=j&&m&&(p??0)>0&&r.jsxs(ee,{variant:"ghost",size:"xs",className:q(Mn,"h-8 shrink-0 gap-1 px-2.5 text-[11px] text-muted-foreground hover:text-foreground"),onClick:m,children:[r.jsx(nd,{className:"size-3"}),"Workflows",r.jsx(_e,{variant:"outline",className:"h-4 min-w-4 justify-center px-1 text-[9px] font-semibold",children:p})]}),t[41]=m,t[42]=j,t[43]=p,t[44]=re):re=t[44];let ie;t[45]!==X||t[46]!==Z||t[47]!==te||t[48]!==ne||t[49]!==re?(ie=r.jsxs("div",{className:X,children:[Z,te,ne,re]}),t[45]=X,t[46]=Z,t[47]=te,t[48]=ne,t[49]=re,t[50]=ie):ie=t[50];let ae,se,ue;t[51]===Symbol.for("react.memo_cache_sentinel")?(ae=r.jsx("div",{className:q(Mn,co,"empty:hidden"),children:r.jsx(vP,{})}),se=r.jsx("div",{className:q(Mn,co,"empty:hidden"),children:r.jsx(_P,{})}),ue=q(Mn,co,"empty:hidden"),t[51]=ae,t[52]=se,t[53]=ue):(ae=t[51],se=t[52],ue=t[53]);let le;t[54]!==z?(le=r.jsx("div",{className:ue,children:r.jsx(bA,{agentKind:z})}),t[54]=z,t[55]=le):le=t[55];let de;t[56]===Symbol.for("react.memo_cache_sentinel")?(de=r.jsx("div",{className:q(Mn,co,"empty:hidden"),children:r.jsx(uu,{})}),t[56]=de):de=t[56];let pe;t[57]!==z||t[58]!==j?(pe=j&&qt(z).sharing&&lt("share")&&r.jsx("div",{className:q(Mn,co),children:r.jsx(iA,{sessionId:j.sessionId})}),t[57]=z,t[58]=j,t[59]=pe):pe=t[59];let he;t[60]===Symbol.for("react.memo_cache_sentinel")?(he=q(Mn,co),t[60]=he):he=t[60];let ce;t[61]===Symbol.for("react.memo_cache_sentinel")?(ce=r.jsx(Hn,{render:r.jsx(ee,{variant:"ghost",size:"icon-sm","aria-label":"More actions"}),children:r.jsx(tg,{"data-icon":"inline-start"})}),t[61]=ce):ce=t[61];let ye;t[62]!==_?(ye=_&&r.jsxs(_t,{onClick:()=>A(!0),children:[r.jsx(ng,{}),"Usage & cost…"]}),t[62]=_,t[63]=ye):ye=t[63];let xe;t[64]===Symbol.for("react.memo_cache_sentinel")?(xe=r.jsxs(_t,{onClick:()=>E(!0),children:[r.jsx(sg,{}),"Server monitor…"]}),t[64]=xe):xe=t[64];let me;t[65]!==Y||t[66]!==v?(me=v&&r.jsxs(_t,{onClick:Y,children:[r.jsx(tc,{className:"text-success"}),"Copy network URL",r.jsx("span",{className:"ml-auto truncate pl-2 font-mono text-[11px] text-muted-foreground",children:v})]}),t[65]=Y,t[66]=v,t[67]=me):me=t[67];let je;t[68]!==ye||t[69]!==me?(je=r.jsxs(en,{children:[ye,xe,me]}),t[68]=ye,t[69]=me,t[70]=je):je=t[70];let Se;t[71]===Symbol.for("react.memo_cache_sentinel")?(Se=r.jsx(ur,{}),t[71]=Se):Se=t[71];let Pe;t[72]===Symbol.for("react.memo_cache_sentinel")?(Pe=r.jsx(u3,{}),t[72]=Pe):Pe=t[72];let Re;t[73]!==x?(Re=r.jsx(en,{children:r.jsxs(_t,{onClick:x,children:[Pe,"Settings"]})}),t[73]=x,t[74]=Re):Re=t[74];let Ie;t[75]!==a||t[76]!==g?(Ie=lt("killAny")&&r.jsxs(r.Fragment,{children:[r.jsx(ur,{}),r.jsx(en,{children:r.jsxs(_t,{variant:"destructive",onClick:g,disabled:a,children:[r.jsx(c3,{}),a?"Stopping processes…":"Stop all agent processes"]})})]}),t[75]=a,t[76]=g,t[77]=Ie):Ie=t[77];let De;t[78]!==je||t[79]!==Re||t[80]!==Ie?(De=r.jsx("div",{className:he,children:r.jsxs(Wn,{children:[ce,r.jsxs(Kn,{align:"end",sideOffset:6,className:"w-64",children:[je,Se,Re,Ie]})]})}),t[78]=je,t[79]=Re,t[80]=Ie,t[81]=De):De=t[81];let Le;t[82]!==le||t[83]!==pe||t[84]!==De?(Le=r.jsxs("div",{className:"electron-no-drag window-inset-end pointer-events-auto flex shrink-0 items-center gap-1.5",children:[ae,se,le,de,pe,De]}),t[82]=le,t[83]=pe,t[84]=De,t[85]=Le):Le=t[85];let ze;t[86]!==ie||t[87]!==Le?(ze=r.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-30 flex items-start justify-between gap-3 px-3 pt-2",children:[ie,Le]}),t[86]=ie,t[87]=Le,t[88]=ze):ze=t[88];let Te;t[89]!==_||t[90]!==P?(Te=_&&r.jsx(DA,{open:P,onOpenChange:A}),t[89]=_,t[90]=P,t[91]=Te):Te=t[91];let Ce;t[92]!==T?(Ce=r.jsx(LP,{open:T,onOpenChange:E}),t[92]=T,t[93]=Ce):Ce=t[93];let We;return t[94]!==ze||t[95]!==Te||t[96]!==Ce?(We=r.jsxs(r.Fragment,{children:[J,G,ze,Te,Ce]}),t[94]=ze,t[95]=Te,t[96]=Ce,t[97]=We):We=t[97],We});function GA(n){const e=B.c(14),{icon:t,label:s,onClick:o}=n;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=q(Mn,"size-8 shrink-0"),e[0]=i):i=e[0];let a;e[1]!==s||e[2]!==o?(a=r.jsx(ee,{variant:"ghost",size:"icon-sm",onClick:o,"aria-label":s,className:i}),e[1]=s,e[2]=o,e[3]=a):a=e[3];let l;e[4]!==t?(l=r.jsx(t,{"data-icon":"inline-start"}),e[4]=t,e[5]=l):l=e[5];let c;e[6]!==a||e[7]!==l?(c=r.jsx(Rt,{render:a,children:l}),e[6]=a,e[7]=l,e[8]=c):c=e[8];let d;e[9]!==s?(d=r.jsx(It,{side:"bottom",children:s}),e[9]=s,e[10]=d):d=e[10];let u;return e[11]!==c||e[12]!==d?(u=r.jsxs(At,{children:[c,d]}),e[11]=c,e[12]=d,e[13]=u):u=e[13],u}function YA(n){n&&$s.success("Copied network URL")}const XA=y.memo(function(e){const t=B.c(13),{onToggleSidebar:s,onGoHome:o,onOpenCommandPalette:i,sidebarShortcut:a,commandPaletteShortcut:l}=e;let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx("div",{className:"flex-1"}),t[0]=c):c=t[0];let d;t[1]!==o?(d=r.jsx(fl,{icon:ys,label:"Home",onClick:o,size:"default"}),t[1]=o,t[2]=d):d=t[2];const u=`Search (${l})`;let f;t[3]!==i||t[4]!==u?(f=r.jsx(fl,{icon:gn,label:u,onClick:i,size:"default"}),t[3]=i,t[4]=u,t[5]=f):f=t[5];const m=`Hide sidebar (${a})`;let p;t[6]!==s||t[7]!==m?(p=r.jsx(fl,{icon:f3,label:m,onClick:s,size:"default"}),t[6]=s,t[7]=m,t[8]=p):p=t[8];let h;return t[9]!==d||t[10]!==f||t[11]!==p?(h=r.jsxs("div",{className:"electron-drag window-inset-start flex h-12 shrink-0 items-center gap-1 px-2",children:[c,d,f,p]}),t[9]=d,t[10]=f,t[11]=p,t[12]=h):h=t[12],h});function JA(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("flex h-full w-full aria-[orientation=vertical]:flex-col",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(h3,{"data-slot":"resizable-panel-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Xp(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(p3,{"data-slot":"resizable-panel",...t}),e[2]=t,e[3]=s):s=e[3],s}function QA(n){const e=B.c(12);let t,s,o;e[0]!==n?({withHandle:o,className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==t?(i=q("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90",t),e[4]=t,e[5]=i):i=e[5];let a;e[6]!==o?(a=o&&r.jsx("div",{className:"z-10 flex h-6 w-1 shrink-0 rounded-lg bg-border"}),e[6]=o,e[7]=a):a=e[7];let l;return e[8]!==s||e[9]!==i||e[10]!==a?(l=r.jsx(m3,{"data-slot":"resizable-handle",className:i,...s,children:a}),e[8]=s,e[9]=i,e[10]=a,e[11]=l):l=e[11],l}const S2=y.createContext(null);function ZA(n){const e=B.c(3),{value:t,children:s}=n;let o;return e[0]!==s||e[1]!==t?(o=r.jsx(S2.Provider,{value:t,children:s}),e[0]=s,e[1]=t,e[2]=o):o=e[2],o}function pu(){const n=y.useContext(S2);if(!n)throw new Error("Built-in workspace panel services are unavailable");return n}function N2(n){const e=B.c(18),{title:t,icon:s,active:o,onClick:i,children:a}=n,l=o&&"bg-sidebar-primary text-sidebar-primary-foreground hover:bg-sidebar-primary/90 hover:text-sidebar-primary-foreground";let c;e[0]!==l?(c=q("relative rounded-md",l),e[0]=l,e[1]=c):c=e[1];let d;e[2]!==o||e[3]!==i||e[4]!==c||e[5]!==t?(d=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm","aria-label":t,"aria-pressed":o,onClick:i,className:c}),e[2]=o,e[3]=i,e[4]=c,e[5]=t,e[6]=d):d=e[6];let u;e[7]!==s?(u=r.jsx(s,{"data-icon":"inline-start"}),e[7]=s,e[8]=u):u=e[8];let f;e[9]!==a||e[10]!==d||e[11]!==u?(f=r.jsxs(Rt,{render:d,children:[u,a]}),e[9]=a,e[10]=d,e[11]=u,e[12]=f):f=e[12];let m;e[13]!==t?(m=r.jsx(It,{side:"left",children:t}),e[13]=t,e[14]=m):m=e[14];let p;return e[15]!==f||e[16]!==m?(p=r.jsxs(At,{children:[f,m]}),e[15]=f,e[16]=m,e[17]=p):p=e[17],p}function k2(n,e){return n.filter(t=>{var s;return((s=t.when)==null?void 0:s.call(t,e))??!0})}function eR(n){const e=B.c(25),{panels:t,context:s,activePanelId:o,onTogglePanel:i,actions:a}=n;let l;e[0]!==a?(l=a===void 0?[]:a,e[0]=a,e[1]=l):l=e[1];const c=l;let d,u,f,m,p,h;if(e[2]!==c||e[3]!==o||e[4]!==s||e[5]!==i||e[6]!==t){h=Symbol.for("react.early_return_sentinel");e:{const x=k2(t,s);if(x.length===0&&c.length===0){h=null;break e}d="Workspace panels",u="electron-no-drag flex w-11 shrink-0 flex-col items-center gap-1 border-l bg-sidebar py-2 text-sidebar-foreground",e[13]!==c?(f=c.map(tR),e[13]=c,e[14]=f):f=e[14],m=c.length>0&&x.length>0&&r.jsx("div",{"aria-hidden":!0,className:"my-1 h-px w-6 bg-sidebar-border"});let b;e[15]!==o||e[16]!==s||e[17]!==i?(b=w=>{var k;const v=w.id===o,S=(k=w.badge)==null?void 0:k.call(w,s),j=w.indicator;return r.jsx(N2,{title:w.title,icon:w.icon,active:v,onClick:()=>i(w.id),children:j?r.jsx(j,{context:s,active:v}):S!=null&&r.jsx(_e,{className:"absolute -right-1 -top-1 min-w-4 px-1 text-[9px]",variant:"secondary",children:S})},w.id)},e[15]=o,e[16]=s,e[17]=i,e[18]=b):b=e[18],p=x.map(b)}e[2]=c,e[3]=o,e[4]=s,e[5]=i,e[6]=t,e[7]=d,e[8]=u,e[9]=f,e[10]=m,e[11]=p,e[12]=h}else d=e[7],u=e[8],f=e[9],m=e[10],p=e[11],h=e[12];if(h!==Symbol.for("react.early_return_sentinel"))return h;let g;return e[19]!==d||e[20]!==u||e[21]!==f||e[22]!==m||e[23]!==p?(g=r.jsxs("aside",{"aria-label":d,className:u,children:[f,m,p]}),e[19]=d,e[20]=u,e[21]=f,e[22]=m,e[23]=p,e[24]=g):g=e[24],g}function tR(n){return r.jsx(N2,{title:n.title,icon:n.icon,active:n.active,onClick:n.onSelect},n.id)}function nR(n){const e=B.c(20),{panels:t,context:s,activePanelId:o,onClosePanel:i,onOpenPanel:a}=n;let l;e[0]!==o?(l=()=>new Set([o]),e[0]=o,e[1]=l):l=e[1];const[c,d]=y.useState(l);let u,f;e[2]!==o?(u=()=>{d(h=>{if(h.has(o))return h;const g=new Set(h);return g.add(o),g})},f=[o],e[2]=o,e[3]=u,e[4]=f):(u=e[3],f=e[4]),y.useEffect(u,f);let m;if(e[5]!==o||e[6]!==s||e[7]!==i||e[8]!==a||e[9]!==t||e[10]!==c){let h;e[12]!==o||e[13]!==s||e[14]!==i||e[15]!==a||e[16]!==c?(h=g=>{const x=g.id===o;if(!x&&(!g.keepAlive||!c.has(g.id)))return null;const b=g.component;return r.jsx("div",{className:q("absolute inset-0 min-h-0",!x&&"hidden"),"aria-hidden":!x,children:r.jsx(b,{context:s,active:x,closePanel:i,openPanel:a})},g.id)},e[12]=o,e[13]=s,e[14]=i,e[15]=a,e[16]=c,e[17]=h):h=e[17],m=t.map(h),e[5]=o,e[6]=s,e[7]=i,e[8]=a,e[9]=t,e[10]=c,e[11]=m}else m=e[11];let p;return e[18]!==m?(p=r.jsx("div",{className:"relative h-full min-h-0 overflow-hidden bg-background",children:m}),e[18]=m,e[19]=p):p=e[19],p}function sR(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 oR(n){const e=B.c(24),{children:t,panels:s,context:o,activePanel:i,services:a,onClosePanel:l,onOpenPanel:c,onTogglePanel:d,actions:u}=n;let f;e[0]!==i?(f=i?sR(i.defaultSize):"100%",e[0]=i,e[1]=f):f=e[1];let m;e[2]!==t||e[3]!==f?(m=r.jsx(Xp,{defaultSize:f,minSize:"320px",children:t}),e[2]=t,e[3]=f,e[4]=m):m=e[4];let p;e[5]!==i||e[6]!==o||e[7]!==l||e[8]!==c||e[9]!==s||e[10]!==a?(p=i&&r.jsxs(r.Fragment,{children:[r.jsx(QA,{withHandle:!0}),r.jsx(Xp,{defaultSize:i.defaultSize??"36%",minSize:i.minSize??"300px",maxSize:i.maxSize??"70%",children:r.jsx(ZA,{value:a,children:r.jsx(nR,{panels:s,context:o,activePanelId:i.id,onClosePanel:l,onOpenPanel:c})})})]}),e[5]=i,e[6]=o,e[7]=l,e[8]=c,e[9]=s,e[10]=a,e[11]=p):p=e[11];let h;e[12]!==m||e[13]!==p?(h=r.jsxs(JA,{orientation:"horizontal",className:"min-h-0 min-w-0 w-auto flex-1",children:[m,p]}),e[12]=m,e[13]=p,e[14]=h):h=e[14];const g=(i==null?void 0:i.id)??null;let x;e[15]!==u||e[16]!==o||e[17]!==d||e[18]!==s||e[19]!==g?(x=r.jsx(eR,{panels:s,context:o,activePanelId:g,onTogglePanel:d,actions:u}),e[15]=u,e[16]=o,e[17]=d,e[18]=s,e[19]=g,e[20]=x):x=e[20];let b;return e[21]!==h||e[22]!==x?(b=r.jsxs(r.Fragment,{children:[h,x]}),e[21]=h,e[22]=x,e[23]=b):b=e[23],b}const hu={data:null,error:null,loading:!1,refreshing:!1},rR=8e3,iR=1500,aR=10,lR=new Set(["gh_missing","gh_auth_required","no_git_repository","no_github_remote"]),cR={endpoint:n=>`/api/github/actions?cwd=${encodeURIComponent(n)}&limit=20`,pollIntervalMs:1e4,fallbackError:"Unable to load GitHub Actions",stores:new Map},dR={endpoint:n=>`/api/github/pulls?cwd=${encodeURIComponent(n)}&limit=30`,pollIntervalMs:3e4,fallbackError:"Unable to load pull requests",stores:new Map},uR={endpoint:n=>`/api/github/issues?cwd=${encodeURIComponent(n)}&limit=30`,pollIntervalMs:6e4,fallbackError:"Unable to load issues",stores:new Map},fR={endpoint:n=>`/api/github/pulls/sessions?cwd=${encodeURIComponent(n)}`,pollIntervalMs:3e4,fallbackError:"Unable to match sessions to pull requests",stores:new Map,settling:n=>n.pending>0};function Rc(n,e){let t=n.stores.get(e);return t||(t={snapshot:hu,listeners:new Set,request:null,fetchedAt:0,settleTimer:null,settleAttempts:0},n.stores.set(e,t)),t}function Wl(n,e){n.snapshot=e;for(const t of n.listeners)t()}async function C2(n){try{const e=await n.json();if(typeof e.error=="string"&&typeof e.code=="string")return e}catch{}return{error:`GitHub request failed (${n.status})`,code:"github_api_failed"}}function _2(n,e){const t=n;return{error:typeof t.error=="string"?t.error:e,code:typeof t.code=="string"?t.code:"github_api_failed"}}async function Mi(n,e,t=!1){const s=Rc(n,e);if(s.request)return s.request;if(!(!t&&s.snapshot.error&&lR.has(s.snapshot.error.code))&&!(!t&&s.fetchedAt>0&&Date.now()-s.fetchedAt<rR))return(t||s.snapshot.data===null)&&Wl(s,{...s.snapshot,error:t?null:s.snapshot.error,loading:s.snapshot.data===null,refreshing:s.snapshot.data!==null}),s.request=ve(n.endpoint(e)).then(async o=>{var a;if(!o.ok)throw await C2(o);const i=await o.json();s.fetchedAt=Date.now(),Wl(s,{data:i,error:null,loading:!1,refreshing:!1}),(a=n.settling)!=null&&a.call(n,i)&&s.settleAttempts<aR?(s.settleAttempts+=1,s.settleTimer=window.setTimeout(()=>{s.settleTimer=null,Mi(n,e,!0)},iR)):s.settleAttempts=0}).catch(o=>{Wl(s,{...s.snapshot,error:_2(o,n.fallbackError),loading:!1,refreshing:!1})}).finally(()=>{s.request=null}),s.request}function Va(n,e,t){const s=B.c(17),o=e??"";let i;s[0]!==o||s[1]!==n?(i=p=>{if(!o)return pR;const h=Rc(n,o);return h.listeners.add(p),()=>h.listeners.delete(p)},s[0]=o,s[1]=n,s[2]=i):i=s[2];let a;s[3]!==o||s[4]!==n?(a=()=>o?Rc(n,o).snapshot:hu,s[3]=o,s[4]=n,s[5]=a):a=s[5];const l=y.useSyncExternalStore(i,a,mR);let c,d;s[6]!==t||s[7]!==o||s[8]!==n?(c=()=>{if(!t||!o)return;Mi(n,o);const p=window.setInterval(()=>{Mi(n,o)},n.pollIntervalMs);return()=>window.clearInterval(p)},d=[n,t,o],s[6]=t,s[7]=o,s[8]=n,s[9]=c,s[10]=d):(c=s[9],d=s[10]),y.useEffect(c,d);let u;s[11]!==o||s[12]!==n?(u=()=>o?Mi(n,o,!0):Promise.resolve(),s[11]=o,s[12]=n,s[13]=u):u=s[13];const f=u;let m;return s[14]!==f||s[15]!==l?(m={...l,refresh:f},s[14]=f,s[15]=l,s[16]=m):m=s[16],m}function mR(){return hu}function pR(){}function T2(n,e){return Va(cR,n,e)}function E2(n,e){return Va(dR,n,e)}function hR(n,e){return Va(uR,n,e)}function gR(n,e){return Va(fR,n,e)}async function P2(n){const e=await ve(n);if(!e.ok)throw await C2(e);return e.json()}function xR(n,e){return P2(`/api/github/actions/jobs?cwd=${encodeURIComponent(n)}&runId=${e}`)}function bR(n,e){return P2(`/api/github/pulls/files?cwd=${encodeURIComponent(n)}&number=${e}`)}function gu(n){const e=B.c(3),{label:t,children:s}=n;let o;return e[0]!==s||e[1]!==t?(o=r.jsx("div",{className:"no-scrollbar flex shrink-0 items-center gap-1 overflow-x-auto border-b px-3 py-1.5",role:"group","aria-label":t,children:s}),e[0]=s,e[1]=t,e[2]=o):o=e[2],o}function xu(n){const e=B.c(10),{icon:t,title:s,description:o}=n;let i;e[0]!==t?(i=r.jsx(bn,{variant:"icon",children:r.jsx(t,{})}),e[0]=t,e[1]=i):i=e[1];let a;e[2]!==s?(a=r.jsx(dn,{children:s}),e[2]=s,e[3]=a):a=e[3];let l;e[4]!==o?(l=r.jsx(vn,{children:o}),e[4]=o,e[5]=l):l=e[5];let c;return e[6]!==i||e[7]!==a||e[8]!==l?(c=r.jsx(ln,{className:"border-0",children:r.jsxs(cn,{children:[i,a,l]})}),e[6]=i,e[7]=a,e[8]=l,e[9]=c):c=e[9],c}function A2(n){const e=B.c(16),{count:t,children:s}=n,[o,i]=y.useState(!1),a=o&&"rotate-90";let l;e[0]!==a?(l=q("size-3 shrink-0 transition-transform",a),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==l?(c=r.jsx(Je,{className:l}),e[2]=l,e[3]=c):c=e[3];let d;e[4]!==t?(d=r.jsx("span",{className:"font-mono text-[10px] tabular-nums opacity-70",children:t}),e[4]=t,e[5]=d):d=e[5];let u;e[6]!==o||e[7]!==c||e[8]!==d?(u=r.jsxs(Mt,{className:"flex h-7 w-full items-center gap-1.5 rounded-sm px-1 text-left text-xs text-muted-foreground outline-none hover:bg-accent/60 hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/20","aria-expanded":o,children:[c,"Closed",d]}),e[6]=o,e[7]=c,e[8]=d,e[9]=u):u=e[9];let f;e[10]!==s?(f=r.jsx(dt,{children:r.jsx("div",{className:"flex flex-col gap-4 pt-2",children:s})}),e[10]=s,e[11]=f):f=e[11];let m;return e[12]!==o||e[13]!==u||e[14]!==f?(m=r.jsxs(ct,{open:o,onOpenChange:i,children:[u,f]}),e[12]=o,e[13]=u,e[14]=f,e[15]=m):m=e[15],m}function R2(n){const e=B.c(4),{count:t}=n;if(t===0)return null;const s=`${t} comment${t===1?"":"s"}`;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(g3,{className:"size-3","aria-hidden":!0}),e[0]=o):o=e[0];let i;return e[1]!==t||e[2]!==s?(i=r.jsxs("span",{className:"flex items-center gap-0.5 font-mono text-[10px] text-muted-foreground tabular-nums","aria-label":s,title:s,children:[o,t]}),e[1]=t,e[2]=s,e[3]=i):i=e[3],i}const Si=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});function bu(n,e){const t=Date.parse(n);if(!Number.isFinite(t))return"Unknown time";const s=Math.round((t-e)/1e3);if(Math.abs(s)<60)return Si.format(s,"second");const o=Math.round(s/60);if(Math.abs(o)<60)return Si.format(o,"minute");const i=Math.round(o/60);return Math.abs(i)<24?Si.format(i,"hour"):Si.format(Math.round(i/24),"day")}function vu(n,e,t){const s=n?Date.parse(n):Number.NaN;if(!Number.isFinite(s))return null;const o=e?Date.parse(e):t,i=Math.max(0,Math.round((o-s)/1e3));if(i<60)return`${i}s`;const a=Math.floor(i/60);return a<60?`${a}m ${i%60}s`:`${Math.floor(a/60)}h ${a%60}m`}function yu(n){const e=B.c(3),[t,s]=y.useState(vR);let o,i;return e[0]!==n?(o=()=>{if(s(Date.now()),!n)return;const a=window.setInterval(()=>s(Date.now()),1e3);return()=>window.clearInterval(a)},i=[n],e[0]=n,e[1]=o,e[2]=i):(o=e[1],i=e[2]),y.useEffect(o,i),t}function vR(){return Date.now()}const yR={data:null,error:null,loading:!1};function I2(n,e,t){const s=B.c(12),o=t===void 0?!1:t,[i,a]=y.useState(!1),[l,c]=y.useState(yR);let d;s[0]!==e||s[1]!==n||s[2]!==l?(d=async function(){if(!l.loading){c(wR);try{c({data:await n(),error:null,loading:!1})}catch(g){c({data:null,error:_2(g,e),loading:!1})}}},s[0]=e,s[1]=n,s[2]=l,s[3]=d):d=s[3];const u=d;let f;s[4]!==u||s[5]!==o||s[6]!==l?(f=function(g){a(g),g&&(!l.data||o)&&u()},s[4]=u,s[5]=o,s[6]=l,s[7]=f):f=s[7];const m=f;let p;return s[8]!==m||s[9]!==i||s[10]!==l?(p={open:i,state:l,onOpenChange:m},s[8]=m,s[9]=i,s[10]=l,s[11]=p):p=s[11],p}function wR(n){return{...n,error:null,loading:!0}}function Yr(n){return n!=="completed"}function $o(n){return n==="action_required"||n==="failure"||n==="startup_failure"||n==="timed_out"}function wu(n,e){return Yr(n)?"live":$o(e)?"fail":e==="success"?"pass":"quiet"}const Jp={live:0,fail:1,quiet:2,pass:3};function jR(n){return n.reduce((e,t)=>Jp[t]<Jp[e]?t:e,"pass")}const SR={live:"bg-info motion-safe:animate-pulse",fail:"bg-destructive",pass:"bg-success",quiet:"bg-border"};function ju(n,e){return n==="in_progress"?"Running":Yr(n)?"Queued":e==="success"?"Passed":e==="cancelled"?"Cancelled":e==="skipped"?"Skipped":e==="timed_out"?"Timed out":e==="action_required"?"Needs action":e==="neutral"||e==="stale"?"Neutral":"Failed"}function Su(n){const e=B.c(14),{status:t,conclusion:s,className:o}=n;let i;e[0]!==s||e[1]!==t?(i=ju(t,s),e[0]=s,e[1]=t,e[2]=i):i=e[2];const a=i;let l,c,d;if(e[3]!==o||e[4]!==s||e[5]!==a||e[6]!==t){d=Symbol.for("react.early_return_sentinel");e:{const f=q("size-3.5 shrink-0",o);if(t==="in_progress"){d=r.jsx(xt,{className:q(f,"text-info"),"aria-label":a});break e}if(Yr(t)){d=r.jsx(Po,{className:q(f,"text-info"),"aria-label":a});break e}if(s==="success"){d=r.jsx(mt,{className:q(f,"text-success"),"aria-label":a});break e}if($o(s)){d=r.jsx(rt,{className:q(f,"text-destructive"),"aria-label":a});break e}if(s==="skipped"||s==="cancelled"){d=r.jsx(x3,{className:q(f,"text-muted-foreground"),"aria-label":a});break e}l=Qc,c=q(f,"text-muted-foreground")}e[3]=o,e[4]=s,e[5]=a,e[6]=t,e[7]=l,e[8]=c,e[9]=d}else l=e[7],c=e[8],d=e[9];if(d!==Symbol.for("react.early_return_sentinel"))return d;let u;return e[10]!==l||e[11]!==a||e[12]!==c?(u=r.jsx(l,{className:c,"aria-label":a}),e[10]=l,e[11]=a,e[12]=c,e[13]=u):u=e[13],u}function NR(n){const e=B.c(19),{step:t,now:s}=n;let o,i,a,l;if(e[0]!==t.conclusion||e[1]!==t.status){const f=$o(t.conclusion);o=t.conclusion==="skipped",a="flex min-w-0 items-center gap-2 py-0.5 text-[11px] leading-5",l=r.jsx(Su,{status:t.status,conclusion:t.conclusion,className:"size-3"}),i=q("min-w-0 flex-1 truncate",f&&"font-medium text-destructive",o&&"text-muted-foreground"),e[0]=t.conclusion,e[1]=t.status,e[2]=o,e[3]=i,e[4]=a,e[5]=l}else o=e[2],i=e[3],a=e[4],l=e[5];let c;e[6]!==t.name||e[7]!==i?(c=r.jsx("span",{className:i,children:t.name}),e[6]=t.name,e[7]=i,e[8]=c):c=e[8];let d;e[9]!==s||e[10]!==o||e[11]!==t.completedAt||e[12]!==t.startedAt?(d=!o&&r.jsx("span",{className:"shrink-0 font-mono text-[10px] text-muted-foreground tabular-nums",children:vu(t.startedAt,t.completedAt,s)}),e[9]=s,e[10]=o,e[11]=t.completedAt,e[12]=t.startedAt,e[13]=d):d=e[13];let u;return e[14]!==a||e[15]!==l||e[16]!==c||e[17]!==d?(u=r.jsxs("li",{className:a,children:[l,c,d]}),e[14]=a,e[15]=l,e[16]=c,e[17]=d,e[18]=u):u=e[18],u}function kR(n){const e=B.c(39),{job:t,now:s}=n;let o;e[0]!==t.conclusion||e[1]!==t.status?(o=wu(t.status,t.conclusion),e[0]=t.conclusion,e[1]=t.status,e[2]=o):o=e[2];const i=o,[a,l]=y.useState(i==="fail"||i==="live");let c;e[3]!==t.completedAt||e[4]!==t.startedAt||e[5]!==s?(c=vu(t.startedAt,t.completedAt,s),e[3]=t.completedAt,e[4]=t.startedAt,e[5]=s,e[6]=c):c=e[6];const d=c,u=t.name;let f;e[7]!==t.conclusion||e[8]!==t.status?(f=ju(t.status,t.conclusion),e[7]=t.conclusion,e[8]=t.status,e[9]=f):f=e[9];const m=`${u}: ${f}`,p=a&&"rotate-90";let h;e[10]!==p?(h=q("size-3 shrink-0 text-muted-foreground transition-transform",p),e[10]=p,e[11]=h):h=e[11];let g;e[12]!==h?(g=r.jsx(Je,{className:h}),e[12]=h,e[13]=g):g=e[13];let x;e[14]!==t.conclusion||e[15]!==t.status?(x=r.jsx(Su,{status:t.status,conclusion:t.conclusion}),e[14]=t.conclusion,e[15]=t.status,e[16]=x):x=e[16];const b=i==="fail"&&"text-destructive";let w;e[17]!==b?(w=q("min-w-0 flex-1 truncate",b),e[17]=b,e[18]=w):w=e[18];let v;e[19]!==t.name||e[20]!==w?(v=r.jsx("span",{className:w,children:t.name}),e[19]=t.name,e[20]=w,e[21]=v):v=e[21];let S;e[22]!==d?(S=d&&r.jsx("span",{className:"shrink-0 font-mono text-[10px] text-muted-foreground tabular-nums",children:d}),e[22]=d,e[23]=S):S=e[23];let j;e[24]!==v||e[25]!==S||e[26]!==m||e[27]!==g||e[28]!==x?(j=r.jsxs(Mt,{className:"flex w-full min-w-0 items-center gap-2 rounded-sm py-1 text-left text-xs outline-none hover:bg-accent/60 focus-visible:ring-[3px] focus-visible:ring-ring/20","aria-label":m,children:[g,x,v,S]}),e[24]=v,e[25]=S,e[26]=m,e[27]=g,e[28]=x,e[29]=j):j=e[29];let k;e[30]!==t.steps||e[31]!==s?(k=t.steps.length>0&&r.jsx("ul",{className:"ml-[5px] border-l border-border pl-4",children:t.steps.map(_=>r.jsx(NR,{step:_,now:s},_.number))}),e[30]=t.steps,e[31]=s,e[32]=k):k=e[32];let C;e[33]!==k?(C=r.jsx(dt,{children:k}),e[33]=k,e[34]=C):C=e[34];let N;return e[35]!==a||e[36]!==j||e[37]!==C?(N=r.jsxs(ct,{open:a,onOpenChange:l,children:[j,C]}),e[35]=a,e[36]=j,e[37]=C,e[38]=N):N=e[38],N}function CR(n){var H,K,V;const e=B.c(73),{run:t,projectPath:s,now:o}=n;let i;e[0]!==t.conclusion||e[1]!==t.status?(i=wu(t.status,t.conclusion),e[0]=t.conclusion,e[1]=t.status,e[2]=i):i=e[2];const a=i,l=a==="live";let c;e[3]!==s||e[4]!==t.id?(c=()=>xR(s,t.id),e[3]=s,e[4]=t.id,e[5]=c):c=e[5];const{open:d,state:u,onOpenChange:f}=I2(c,"Unable to load workflow jobs",l);let m;e[6]!==((H=u.data)==null?void 0:H.jobs)?(m=((K=u.data)==null?void 0:K.jobs)??[],e[6]=(V=u.data)==null?void 0:V.jobs,e[7]=m):m=e[7];const p=m,h=l?null:t.updatedAt;let g;e[8]!==o||e[9]!==t.createdAt||e[10]!==h?(g=vu(t.createdAt,h,o),e[8]=o,e[9]=t.createdAt,e[10]=h,e[11]=g):g=e[11];const x=g,b=t.name,w=t.runNumber;let v;e[12]!==t.conclusion||e[13]!==t.status?(v=ju(t.status,t.conclusion),e[12]=t.conclusion,e[13]=t.status,e[14]=v):v=e[14];const S=`${b} #${w}: ${v}`;let j;e[15]!==t.conclusion||e[16]!==t.status?(j=r.jsx(Su,{status:t.status,conclusion:t.conclusion}),e[15]=t.conclusion,e[16]=t.status,e[17]=j):j=e[17];const k=a==="quiet"&&"text-muted-foreground";let C;e[18]!==k?(C=q("min-w-0 truncate",k),e[18]=k,e[19]=C):C=e[19];let N;e[20]!==t.name||e[21]!==C?(N=r.jsx("span",{className:C,children:t.name}),e[20]=t.name,e[21]=C,e[22]=N):N=e[22];let _;e[23]!==t.runNumber?(_=r.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["#",t.runNumber]}),e[23]=t.runNumber,e[24]=_):_=e[24];let P;e[25]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx("span",{className:"min-w-0 flex-1"}),e[25]=P):P=e[25];let A;e[26]!==t.branch?(A=r.jsx("span",{className:"max-w-24 truncate font-mono text-[10px] text-muted-foreground",children:t.branch}),e[26]=t.branch,e[27]=A):A=e[27];let T;e[28]!==l||e[29]!==x?(T=x&&r.jsx("span",{className:q("w-14 shrink-0 text-right font-mono text-[10px] tabular-nums",l?"text-info":"text-muted-foreground"),children:x}),e[28]=l,e[29]=x,e[30]=T):T=e[30];let E;e[31]!==d||e[32]!==j||e[33]!==N||e[34]!==_||e[35]!==A||e[36]!==T||e[37]!==S?(E=r.jsxs(Mt,{className:"flex h-7 min-w-0 flex-1 items-center gap-2 rounded-sm px-1 text-left text-xs outline-none hover:bg-accent/60 focus-visible:ring-[3px] focus-visible:ring-ring/20","aria-label":S,"aria-expanded":d,children:[j,N,_,P,A,T]}),e[31]=d,e[32]=j,e[33]=N,e[34]=_,e[35]=A,e[36]=T,e[37]=S,e[38]=E):E=e[38];const R=`Open ${t.name} #${t.runNumber} on GitHub`;let $;e[39]!==t.url?($=()=>window.open(t.url,"_blank","noopener,noreferrer"),e[39]=t.url,e[40]=$):$=e[40];let I;e[41]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(zn,{}),e[41]=I):I=e[41];let M;e[42]!==R||e[43]!==$?(M=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",className:"size-6 text-muted-foreground opacity-0 transition-opacity group-hover/run:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100","aria-label":R,onClick:$,children:I}),e[42]=R,e[43]=$,e[44]=M):M=e[44];let D;e[45]!==E||e[46]!==M?(D=r.jsxs("div",{className:"group/run flex items-center gap-1 pr-1",children:[E,M]}),e[45]=E,e[46]=M,e[47]=D):D=e[47];let O;e[48]!==u.data||e[49]!==u.loading?(O=u.loading&&!u.data&&r.jsxs("div",{className:"flex items-center gap-2 py-1 text-[11px] text-muted-foreground",role:"status",children:[r.jsx(xt,{className:"size-3"}),"Loading jobs"]}),e[48]=u.data,e[49]=u.loading,e[50]=O):O=e[50];let L;e[51]!==u.error?(L=u.error&&r.jsx("p",{className:"py-1 text-[11px] text-destructive",children:u.error.error}),e[51]=u.error,e[52]=L):L=e[52];let F;e[53]!==p.length||e[54]!==u.data||e[55]!==u.error||e[56]!==u.loading?(F=!u.loading&&!u.error&&u.data&&p.length===0&&r.jsx("p",{className:"py-1 text-[11px] text-muted-foreground",children:"GitHub reported no jobs for this run."}),e[53]=p.length,e[54]=u.data,e[55]=u.error,e[56]=u.loading,e[57]=F):F=e[57];let z;if(e[58]!==p||e[59]!==o){let Y;e[61]!==o?(Y=G=>r.jsx(kR,{job:G,now:o},G.id),e[61]=o,e[62]=Y):Y=e[62],z=p.map(Y),e[58]=p,e[59]=o,e[60]=z}else z=e[60];let W;e[63]!==O||e[64]!==L||e[65]!==F||e[66]!==z?(W=r.jsx(dt,{children:r.jsxs("div",{className:"ml-[7px] border-l border-border py-1 pl-3 pr-1",children:[O,L,F,z]})}),e[63]=O,e[64]=L,e[65]=F,e[66]=z,e[67]=W):W=e[67];let U;return e[68]!==f||e[69]!==d||e[70]!==D||e[71]!==W?(U=r.jsxs(ct,{open:d,onOpenChange:f,children:[D,W]}),e[68]=f,e[69]=d,e[70]=D,e[71]=W,e[72]=U):U=e[72],U}function _R(n){const e=new Map;for(const s of n){const o=s.commitSha||`run-${s.id}`,i=e.get(o);if(i){i.runs.push(s),s.createdAt>i.createdAt&&(i.createdAt=s.createdAt);continue}e.set(o,{sha:s.commitSha,title:s.displayTitle,actor:s.actor,createdAt:s.createdAt,runs:[s],tone:"pass"})}const t=[...e.values()];for(const s of t)s.tone=jR(s.runs.map(o=>wu(o.status,o.conclusion)));return t.sort((s,o)=>{const i=s.tone==="live"?0:1,a=o.tone==="live"?0:1;return i-a||o.createdAt.localeCompare(s.createdAt)})}function TR(n){const e=B.c(41),{group:t,projectPath:s,now:o}=n,i=t.title,a=SR[t.tone];let l;e[0]!==a?(l=q("absolute inset-y-1 left-0 w-0.5 rounded-full",a),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==l?(c=r.jsx("span",{"aria-hidden":!0,className:l}),e[2]=l,e[3]=c):c=e[3];let d;e[4]!==t.title?(d=r.jsx("h3",{className:"truncate text-[13px] font-medium leading-5",title:t.title,children:t.title}),e[4]=t.title,e[5]=d):d=e[5];let u;e[6]!==t.sha?(u=t.sha&&r.jsx("span",{className:"font-mono",children:t.sha.slice(0,7)}),e[6]=t.sha,e[7]=u):u=e[7];let f;e[8]!==t.actor?(f=t.actor&&r.jsx("span",{className:"truncate",children:t.actor}),e[8]=t.actor,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx("span",{className:"shrink-0",children:"·"}),e[10]=m):m=e[10];const p=t.createdAt;let h;e[11]!==t.createdAt?(h=new Date(t.createdAt).toLocaleString(),e[11]=t.createdAt,e[12]=h):h=e[12];let g;e[13]!==t.createdAt||e[14]!==o?(g=bu(t.createdAt,o),e[13]=t.createdAt,e[14]=o,e[15]=g):g=e[15];let x;e[16]!==t.createdAt||e[17]!==h||e[18]!==g?(x=r.jsx("time",{className:"shrink-0",dateTime:p,title:h,children:g}),e[16]=t.createdAt,e[17]=h,e[18]=g,e[19]=x):x=e[19];let b;e[20]!==x||e[21]!==u||e[22]!==f?(b=r.jsxs("p",{className:"flex min-w-0 items-center gap-1.5 text-[11px] leading-4 text-muted-foreground",children:[u,f,m,x]}),e[20]=x,e[21]=u,e[22]=f,e[23]=b):b=e[23];let w;e[24]!==b||e[25]!==d?(w=r.jsxs("header",{className:"mb-1 min-w-0",children:[d,b]}),e[24]=b,e[25]=d,e[26]=w):w=e[26];let v;if(e[27]!==t.runs||e[28]!==o||e[29]!==s){let k;e[31]!==o||e[32]!==s?(k=C=>r.jsx(CR,{run:C,projectPath:s,now:o},C.id),e[31]=o,e[32]=s,e[33]=k):k=e[33],v=t.runs.map(k),e[27]=t.runs,e[28]=o,e[29]=s,e[30]=v}else v=e[30];let S;e[34]!==v?(S=r.jsx("div",{className:"-ml-1 flex flex-col",children:v}),e[34]=v,e[35]=S):S=e[35];let j;return e[36]!==t.title||e[37]!==w||e[38]!==S||e[39]!==c?(j=r.jsxs("article",{className:"relative pl-3","aria-label":i,children:[c,w,S]}),e[36]=t.title,e[37]=w,e[38]=S,e[39]=c,e[40]=j):j=e[40],j}function ER(n,e){return e==="failed"?n.filter(t=>$o(t.conclusion)):e==="all"?[...n]:n.filter(t=>t.branch===e.branch)}function PR(n,e){return n==="failed"?"Nothing failed in the latest runs.":n==="all"?`No recent runs on ${e}.`:`No recent runs on ${n.branch}.`}function AR(n){const e=B.c(22),{data:t,filter:s,projectPath:o}=n;let i;e[0]!==t.runs||e[1]!==s?(i=ER(t.runs,s),e[0]=t.runs,e[1]=s,e[2]=i):i=e[2];const a=i;let l;e[3]!==a?(l=_R(a),e[3]=a,e[4]=l):l=e[4];const c=l;let d;e[5]!==c?(d=c.some(RR),e[5]=c,e[6]=d):d=e[6];const u=yu(d);if(t.runs.length===0){let p;return e[7]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(xu,{icon:nd,title:"No workflow runs yet",description:"Push a commit that triggers a workflow and it will show up here."}),e[7]=p):p=e[7],p}if(c.length===0){let p;e[8]!==t.branch||e[9]!==s?(p=PR(s,t.branch),e[8]=t.branch,e[9]=s,e[10]=p):p=e[10];let h;return e[11]!==p?(h=r.jsx("p",{className:"px-4 py-6 text-center text-xs text-muted-foreground",children:p}),e[11]=p,e[12]=h):h=e[12],h}let f;if(e[13]!==c||e[14]!==u||e[15]!==o){let p;e[17]!==u||e[18]!==o?(p=h=>r.jsx(TR,{group:h,projectPath:o,now:u},h.sha||h.runs[0].id),e[17]=u,e[18]=o,e[19]=p):p=e[19],f=c.map(p),e[13]=c,e[14]=u,e[15]=o,e[16]=f}else f=e[16];let m;return e[20]!==f?(m=r.jsx(is,{className:"min-h-0 flex-1",children:r.jsx("div",{className:"flex flex-col gap-5 px-3 py-3",children:f})}),e[20]=f,e[21]=m):m=e[21],m}function RR(n){return n.tone==="live"}function IR(n){const e=B.c(23),{data:t,projectPath:s,focus:o}=n,[i,a]=y.useState("all");let l,c;e[0]!==o?(l=()=>{o&&a({branch:o.branch})},c=[o],e[0]=o,e[1]=l,e[2]=c):(l=e[1],c=e[2]),y.useEffect(l,c);const d=t.runs;let u;e[3]!==d?(u=d.filter($R),e[3]=d,e[4]=u):u=e[4];const f=u.length,m=t.branch;let p;e[5]!==m||e[6]!==d?(p=m?d.filter(j=>j.branch===m).length:0,e[5]=m,e[6]=d,e[7]=p):p=e[7];const h=p,g=typeof i=="object"&&i.branch!==m?i.branch:null,x=typeof i=="object"&&!g,b=x&&!m||i==="failed"&&f===0?"all":i;let w;e[8]!==m||e[9]!==h||e[10]!==x||e[11]!==b||e[12]!==f||e[13]!==g||e[14]!==d?(w=d.length>0&&r.jsxs(gu,{label:"Filter runs",children:[r.jsxs(Ut,{pressed:b==="all",onClick:()=>a("all"),children:["All",r.jsx(Wt,{children:d.length})]}),m&&r.jsxs(Ut,{pressed:x&&b!=="all",disabled:h===0,onClick:()=>a({branch:m}),"aria-label":`Only runs on ${m}`,children:[r.jsx(Dn,{className:"size-3"}),r.jsx("span",{className:"max-w-28 truncate",children:m}),r.jsx(Wt,{children:h})]}),g&&r.jsxs(Ut,{pressed:!0,onClick:()=>a("all"),"aria-label":`Only runs on ${g}`,children:[r.jsx(Dn,{className:"size-3"}),r.jsx("span",{className:"max-w-28 truncate",children:g}),r.jsx(Wt,{children:d.filter(j=>j.branch===g).length}),r.jsx(rt,{className:"size-3","aria-hidden":!0})]}),r.jsxs(Ut,{pressed:b==="failed",disabled:f===0,onClick:()=>a("failed"),children:[r.jsx("span",{className:q(f>0&&"text-destructive"),children:"Failed"})," ",r.jsx(Wt,{children:f})]})]}),e[8]=m,e[9]=h,e[10]=x,e[11]=b,e[12]=f,e[13]=g,e[14]=d,e[15]=w):w=e[15];let v;e[16]!==t||e[17]!==b||e[18]!==s?(v=r.jsx(AR,{data:t,filter:b,projectPath:s}),e[16]=t,e[17]=b,e[18]=s,e[19]=v):v=e[19];let S;return e[20]!==w||e[21]!==v?(S=r.jsxs(r.Fragment,{children:[w,v]}),e[20]=w,e[21]=v,e[22]=S):S=e[22],S}function $R(n){return $o(n.conclusion)}const MR=700,OR=12;function $2(n){const e=B.c(15),{body:t}=n,[s,o]=y.useState(!1);let i;e[0]!==t?(i=t.length>MR||t.split(`
125
- `).length>OR,e[0]=t,e[1]=i):i=e[1];const a=i,l=a&&!s&&"max-h-52 overflow-hidden [mask-image:linear-gradient(to_bottom,black_70%,transparent)]";let c;e[2]!==l?(c=q("break-words text-xs leading-5",l),e[2]=l,e[3]=c):c=e[3];let d;e[4]!==t?(d=r.jsx(Qd,{text:t,compactHeadings:!0}),e[4]=t,e[5]=d):d=e[5];let u;e[6]!==c||e[7]!==d?(u=r.jsx("div",{className:c,children:d}),e[6]=c,e[7]=d,e[8]=u):u=e[8];let f;e[9]!==s||e[10]!==a?(f=a&&r.jsx("button",{type:"button",className:"mt-1 text-[11px] text-muted-foreground underline-offset-2 outline-none hover:text-foreground hover:underline focus-visible:underline",onClick:()=>o(DR),"aria-expanded":s,children:s?"Show less":"Show full description"}),e[9]=s,e[10]=a,e[11]=f):f=e[11];let m;return e[12]!==u||e[13]!==f?(m=r.jsxs("div",{className:"max-w-[72ch]",children:[u,f]}),e[12]=u,e[13]=f,e[14]=m):m=e[14],m}function DR(n){return!n}const M2={open:"Open",completed:"Completed",not_planned:"Not planned"},LR={open:"bg-success",completed:"bg-info",not_planned:"bg-border"};function zR(n){const e=B.c(9),{state:t}=n,s=M2[t];if(t==="open"){let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=q("size-3.5 shrink-0","text-success"),e[0]=a):a=e[0];let l;return e[1]!==s?(l=r.jsx(og,{className:a,"aria-label":s}),e[1]=s,e[2]=l):l=e[2],l}if(t==="completed"){let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=q("size-3.5 shrink-0","text-info"),e[3]=a):a=e[3];let l;return e[4]!==s?(l=r.jsx(Bn,{className:a,"aria-label":s}),e[4]=s,e[5]=l):l=e[5],l}let o;e[6]===Symbol.for("react.memo_cache_sentinel")?(o=q("size-3.5 shrink-0","text-muted-foreground"),e[6]=o):o=e[6];let i;return e[7]!==s?(i=r.jsx(v3,{className:o,"aria-label":s}),e[7]=s,e[8]=i):i=e[8],i}function O2(n){const e=B.c(2),{label:t}=n,s=`#${t.color}`;let o;return e[0]!==s?(o=r.jsx("span",{"aria-hidden":!0,className:"inline-block size-2 shrink-0 rounded-full",style:{backgroundColor:s}}),e[0]=s,e[1]=o):o=e[1],o}function FR(n){const e=n.body.trim();return[`Work on GitHub issue #${n.number}: ${n.title}`,n.url,...e?["",e]:[]].join(`
126
- `)}function BR(n){const e=B.c(7),{issue:t,viewer:s}=n;if(s!==null&&t.assignees.includes(s)){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(rg,{className:"size-3 text-info","aria-label":"Assigned to you",role:"img"}),e[0]=d):d=e[0],d}if(t.assignees.length===0)return null;let o;e[1]!==t.assignees?(o=t.assignees.join(", "),e[1]=t.assignees,e[2]=o):o=e[2];const i=`Assigned to ${o}`;let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(sd,{className:"size-3","aria-hidden":!0}),e[3]=a):a=e[3];const l=t.assignees.length>1&&t.assignees.length;let c;return e[4]!==i||e[5]!==l?(c=r.jsxs("span",{className:"flex items-center gap-0.5 text-[10px] text-muted-foreground","aria-label":i,title:i,children:[a,l]}),e[4]=i,e[5]=l,e[6]=c):c=e[6],c}function UR(n){const e=B.c(5),{state:t}=n;if(t==="merged"){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(ig,{className:"size-3 text-info","aria-hidden":!0}),e[0]=a):a=e[0],a}const s=t==="closed"?"text-destructive":"text-success";let o;e[1]!==s?(o=q("size-3",s),e[1]=s,e[2]=o):o=e[2];let i;return e[3]!==o?(i=r.jsx(Er,{className:o,"aria-hidden":!0}),e[3]=o,e[4]=i):i=e[4],i}function WR(n){const e=B.c(12),{issue:t,viewer:s,onShowPull:o}=n,i=t.linkedPulls[0];let a;e[0]!==t||e[1]!==s?(a=r.jsx(BR,{issue:t,viewer:s}),e[0]=t,e[1]=s,e[2]=a):a=e[2];let l;e[3]!==o||e[4]!==i?(l=i&&r.jsxs("button",{type:"button",className:"flex items-center gap-0.5 rounded-sm font-mono text-[10px] text-muted-foreground outline-none hover:bg-accent hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/20","aria-label":`Pull request #${i.number} (${i.state}), show pull requests`,title:`Pull request #${i.number} · ${i.state}`,onClick:o,children:[r.jsx(UR,{state:i.state}),"#",i.number]}),e[3]=o,e[4]=i,e[5]=l):l=e[5];let c;e[6]!==t.comments?(c=r.jsx(R2,{count:t.comments}),e[6]=t.comments,e[7]=c):c=e[7];let d;return e[8]!==a||e[9]!==l||e[10]!==c?(d=r.jsxs("span",{className:"flex h-5 shrink-0 items-center gap-1.5",children:[a,l,c]}),e[8]=a,e[9]=l,e[10]=c,e[11]=d):d=e[11],d}function HR(n){const e=B.c(86),{issue:t,viewer:s,now:o,onPickLabel:i,onShowPull:a,composePrompt:l}=n,[c,d]=y.useState(!1),u=t.state==="open"?t.updatedAt:t.closedAt??t.updatedAt;let f;e[0]!==t.body?(f=t.body.trim(),e[0]=t.body,e[1]=f):f=e[1];const m=f,p=t.title,h=LR[t.state];let g;e[2]!==h?(g=q("absolute inset-y-1 left-0 w-0.5 rounded-full",h),e[2]=h,e[3]=g):g=e[3];let x;e[4]!==g?(x=r.jsx("span",{"aria-hidden":!0,className:g}),e[4]=g,e[5]=x):x=e[5];const b=`${t.title} #${t.number}: ${M2[t.state]}`;let w;e[6]!==t.state?(w=r.jsx(zR,{state:t.state}),e[6]=t.state,e[7]=w):w=e[7];const v=t.state!=="open"&&"text-muted-foreground";let S;e[8]!==v?(S=q("min-w-0 flex-1 truncate text-[13px] font-medium leading-5",v),e[8]=v,e[9]=S):S=e[9];let j;e[10]!==t.title||e[11]!==S?(j=r.jsx("span",{className:S,children:t.title}),e[10]=t.title,e[11]=S,e[12]=j):j=e[12];let k;e[13]!==t.number?(k=r.jsxs("span",{className:"shrink-0 font-mono text-[10px] text-muted-foreground",children:["#",t.number]}),e[13]=t.number,e[14]=k):k=e[14];let C;e[15]!==j||e[16]!==k||e[17]!==w?(C=r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[w,j,k]}),e[15]=j,e[16]=k,e[17]=w,e[18]=C):C=e[18];let N;e[19]!==t.author?(N=t.author&&r.jsx("span",{className:"shrink-0",children:t.author}),e[19]=t.author,e[20]=N):N=e[20];let _;e[21]!==t.labels?(_=t.labels.length>0&&r.jsxs("span",{className:"flex min-w-0 items-center gap-1 truncate",children:[t.labels.slice(0,3).map(KR),t.labels.length>3&&r.jsxs("span",{children:["+",t.labels.length-3]})]}),e[21]=t.labels,e[22]=_):_=e[22];let P;e[23]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx("span",{className:"shrink-0",children:"·"}),e[23]=P):P=e[23];let A;e[24]!==u?(A=new Date(u).toLocaleString(),e[24]=u,e[25]=A):A=e[25];let T;e[26]!==u||e[27]!==o?(T=bu(u,o),e[26]=u,e[27]=o,e[28]=T):T=e[28];let E;e[29]!==u||e[30]!==A||e[31]!==T?(E=r.jsx("time",{className:"shrink-0",dateTime:u,title:A,children:T}),e[29]=u,e[30]=A,e[31]=T,e[32]=E):E=e[32];let R;e[33]!==N||e[34]!==_||e[35]!==E?(R=r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 pl-[22px] text-[11px] leading-4 text-muted-foreground",children:[N,_,P,E]}),e[33]=N,e[34]=_,e[35]=E,e[36]=R):R=e[36];let $;e[37]!==c||e[38]!==C||e[39]!==R||e[40]!==b?($=r.jsxs(Mt,{className:"flex min-w-0 flex-1 flex-col rounded-sm px-1 py-1 text-left outline-none hover:bg-accent/60 focus-visible:ring-[3px] focus-visible:ring-ring/20","aria-label":b,"aria-expanded":c,children:[C,R]}),e[37]=c,e[38]=C,e[39]=R,e[40]=b,e[41]=$):$=e[41];let I;e[42]!==t||e[43]!==a||e[44]!==s?(I=r.jsx(WR,{issue:t,viewer:s,onShowPull:a}),e[42]=t,e[43]=a,e[44]=s,e[45]=I):I=e[45];const M=`Open #${t.number} on GitHub`;let D;e[46]!==t.url?(D=()=>window.open(t.url,"_blank","noopener,noreferrer"),e[46]=t.url,e[47]=D):D=e[47];let O;e[48]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsx(zn,{}),e[48]=O):O=e[48];let L;e[49]!==M||e[50]!==D?(L=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",className:"size-6 text-muted-foreground opacity-0 transition-opacity group-hover/issue:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100","aria-label":M,onClick:D,children:O}),e[49]=M,e[50]=D,e[51]=L):L=e[51];let F;e[52]!==I||e[53]!==L?(F=r.jsxs("div",{className:"mt-1 flex shrink-0 items-center gap-1",children:[I,L]}),e[52]=I,e[53]=L,e[54]=F):F=e[54];let z;e[55]!==$||e[56]!==F?(z=r.jsxs("div",{className:"group/issue flex items-start gap-1 pr-1",children:[$,F]}),e[55]=$,e[56]=F,e[57]=z):z=e[57];let W;e[58]!==m?(W=m?r.jsx($2,{body:m}):r.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"No description."}),e[58]=m,e[59]=W):W=e[59];let U;e[60]!==t.labels||e[61]!==i?(U=t.labels.length>0&&r.jsx("ul",{className:"flex flex-wrap gap-1","aria-label":"Labels",children:t.labels.map(Z=>r.jsx("li",{children:r.jsxs("button",{type:"button",className:"inline-flex h-5 items-center gap-1 rounded-full border px-1.5 text-[10px] leading-none text-muted-foreground outline-none hover:border-foreground/30 hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/20",onClick:()=>i(Z.name),"aria-label":`Only issues labeled ${Z.name}`,children:[r.jsx(O2,{label:Z}),Z.name]})},Z.name))}),e[60]=t.labels,e[61]=i,e[62]=U):U=e[62];let H;e[63]!==l||e[64]!==t?(H=l&&r.jsxs(ee,{type:"button",size:"xs",onClick:()=>l(FR(t)),children:[r.jsx(y3,{"data-icon":"inline-start"}),"Add to prompt"]}),e[63]=l,e[64]=t,e[65]=H):H=e[65];let K;e[66]!==t.url?(K=r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer"}),e[66]=t.url,e[67]=K):K=e[67];let V;e[68]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx(zn,{"data-icon":"inline-end"}),e[68]=V):V=e[68];let Y;e[69]!==K?(Y=r.jsxs(ee,{variant:"outline",size:"xs",render:K,children:["Open issue on GitHub",V]}),e[69]=K,e[70]=Y):Y=e[70];let G;e[71]!==H||e[72]!==Y?(G=r.jsxs("div",{className:"flex flex-wrap gap-2",children:[H,Y]}),e[71]=H,e[72]=Y,e[73]=G):G=e[73];let J;e[74]!==W||e[75]!==U||e[76]!==G?(J=r.jsx(dt,{children:r.jsxs("div",{className:"flex flex-col gap-3 py-2 pl-[22px] pr-1",children:[W,U,G]})}),e[74]=W,e[75]=U,e[76]=G,e[77]=J):J=e[77];let Q;e[78]!==c||e[79]!==z||e[80]!==J?(Q=r.jsxs(ct,{open:c,onOpenChange:d,children:[z,J]}),e[78]=c,e[79]=z,e[80]=J,e[81]=Q):Q=e[81];let X;return e[82]!==t.title||e[83]!==Q||e[84]!==x?(X=r.jsxs("article",{className:"relative pl-3","aria-label":p,children:[x,Q]}),e[82]=t.title,e[83]=Q,e[84]=x,e[85]=X):X=e[85],X}function KR(n){return r.jsxs("span",{className:"flex items-center gap-1 truncate",children:[r.jsx(O2,{label:n}),r.jsx("span",{className:"truncate",children:n.name})]},n.name)}function Qp(n,e,t){return e==="assigned"?t!==null&&n.assignees.includes(t):e==="opened"?t!==null&&n.author===t:e==="unassigned"?n.assignees.length===0:!0}function qR(n){const e=B.c(75),{data:t,composePrompt:s,onShowPulls:o}=n,[i,a]=y.useState("all"),[l,c]=y.useState(null),d=yu(!1),u=t.viewer;let f;e[0]!==t.issues||e[1]!==u?(f=$=>t.issues.filter(I=>Qp(I,$,u)).length,e[0]=t.issues,e[1]=u,e[2]=f):f=e[2];const m=f;let p;e[3]!==m?(p=m("assigned"),e[3]=m,e[4]=p):p=e[4];const h=p;let g;e[5]!==m?(g=m("opened"),e[5]=m,e[6]=g):g=e[6];const x=g;let b;e[7]!==m?(b=m("unassigned"),e[7]=m,e[8]=b):b=e[8];const w=b,v=i==="assigned"&&h===0||i==="opened"&&x===0||i==="unassigned"&&w===0?"all":i,S=t.issues;let j,k,C,N,_,P,A;if(e[9]!==h||e[10]!==s||e[11]!==t.issues||e[12]!==v||e[13]!==l||e[14]!==d||e[15]!==o||e[16]!==x||e[17]!==w||e[18]!==u){C=Symbol.for("react.early_return_sentinel");e:{let $;e[26]!==v||e[27]!==l||e[28]!==u?($=te=>Qp(te,v,u)&&(l===null||te.labels.some(ne=>ne.name===l)),e[26]=v,e[27]=l,e[28]=u,e[29]=$):$=e[29];const I=S.filter($),M=I.filter(GR),D=I.filter(VR);if(t.issues.length===0){let te;e[30]===Symbol.for("react.memo_cache_sentinel")?(te=r.jsx(xu,{icon:og,title:"No issues yet",description:"Issues opened on this repository will show up here."}),e[30]=te):te=e[30],C=te;break e}let O;e[31]!==s||e[32]!==d||e[33]!==o||e[34]!==u?(O=te=>r.jsx(HR,{issue:te,viewer:u,now:d,onPickLabel:c,onShowPull:o,composePrompt:s},te.number),e[31]=s,e[32]=d,e[33]=o,e[34]=u,e[35]=O):O=e[35];const L=O,F=v==="all";let z;e[36]===Symbol.for("react.memo_cache_sentinel")?(z=()=>a("all"),e[36]=z):z=e[36];let W;e[37]!==t.issues.length?(W=r.jsx(Wt,{children:t.issues.length}),e[37]=t.issues.length,e[38]=W):W=e[38];let U;e[39]!==F||e[40]!==W?(U=r.jsxs(Ut,{pressed:F,onClick:z,children:["All",W]}),e[39]=F,e[40]=W,e[41]=U):U=e[41];let H;e[42]!==h||e[43]!==v||e[44]!==u?(H=u&&r.jsxs(Ut,{pressed:v==="assigned",disabled:h===0,onClick:()=>a("assigned"),"aria-label":"Only issues assigned to you",children:[r.jsx(rg,{className:"size-3"}),"Mine",r.jsx(Wt,{children:h})]}),e[42]=h,e[43]=v,e[44]=u,e[45]=H):H=e[45];let K;e[46]!==v||e[47]!==x||e[48]!==u?(K=u&&r.jsxs(Ut,{pressed:v==="opened",disabled:x===0,onClick:()=>a("opened"),"aria-label":"Only issues you opened",children:[r.jsx(sd,{className:"size-3"}),"Opened",r.jsx(Wt,{children:x})]}),e[46]=v,e[47]=x,e[48]=u,e[49]=K):K=e[49];const V=v==="unassigned",Y=w===0;let G;e[50]===Symbol.for("react.memo_cache_sentinel")?(G=()=>a("unassigned"),e[50]=G):G=e[50];let J;e[51]===Symbol.for("react.memo_cache_sentinel")?(J=r.jsx(b3,{className:"size-3"}),e[51]=J):J=e[51];let Q;e[52]!==w?(Q=r.jsx(Wt,{children:w}),e[52]=w,e[53]=Q):Q=e[53];let X;e[54]!==V||e[55]!==Y||e[56]!==Q?(X=r.jsxs(Ut,{pressed:V,disabled:Y,onClick:G,"aria-label":"Only unassigned issues",children:[J,"Unassigned",Q]}),e[54]=V,e[55]=Y,e[56]=Q,e[57]=X):X=e[57];const Z=l&&r.jsxs(Ut,{pressed:!0,onClick:()=>c(null),"aria-label":`Clear label filter ${l}`,children:[r.jsx("span",{className:"max-w-28 truncate",children:l}),r.jsx(Wt,{children:I.length}),r.jsx(rt,{className:"size-3","aria-hidden":!0})]});e[58]!==U||e[59]!==H||e[60]!==K||e[61]!==X||e[62]!==Z?(k=r.jsxs(gu,{label:"Filter issues",children:[U,H,K,X,Z]}),e[58]=U,e[59]=H,e[60]=K,e[61]=X,e[62]=Z,e[63]=k):k=e[63],j=is,A="min-h-0 flex-1",N="flex flex-col gap-4 px-3 py-3",_=M.length===0?r.jsx("p",{className:"px-1 py-3 text-center text-xs text-muted-foreground",children:"Nothing open here."}):M.map(L),P=D.length>0&&r.jsx(A2,{count:D.length,children:D.map(L)})}e[9]=h,e[10]=s,e[11]=t.issues,e[12]=v,e[13]=l,e[14]=d,e[15]=o,e[16]=x,e[17]=w,e[18]=u,e[19]=j,e[20]=k,e[21]=C,e[22]=N,e[23]=_,e[24]=P,e[25]=A}else j=e[19],k=e[20],C=e[21],N=e[22],_=e[23],P=e[24],A=e[25];if(C!==Symbol.for("react.early_return_sentinel"))return C;let T;e[64]!==N||e[65]!==_||e[66]!==P?(T=r.jsxs("div",{className:N,children:[_,P]}),e[64]=N,e[65]=_,e[66]=P,e[67]=T):T=e[67];let E;e[68]!==j||e[69]!==T||e[70]!==A?(E=r.jsx(j,{className:A,children:T}),e[68]=j,e[69]=T,e[70]=A,e[71]=E):E=e[71];let R;return e[72]!==k||e[73]!==E?(R=r.jsxs(r.Fragment,{children:[k,E]}),e[72]=k,e[73]=E,e[74]=R):R=e[74],R}function VR(n){return n.state!=="open"}function GR(n){return n.state==="open"}const D2={open:"Open",draft:"Draft",merged:"Merged",closed:"Closed"},YR={open:"bg-success",draft:"bg-border",merged:"bg-info",closed:"bg-destructive"};function Ks(n){return n.state==="open"||n.state==="draft"}function XR(n){const e=B.c(12),{state:t}=n,s=D2[t];if(t==="open"){let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=q("size-3.5 shrink-0","text-success"),e[0]=a):a=e[0];let l;return e[1]!==s?(l=r.jsx(Er,{className:a,"aria-label":s}),e[1]=s,e[2]=l):l=e[2],l}if(t==="draft"){let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=q("size-3.5 shrink-0","text-muted-foreground"),e[3]=a):a=e[3];let l;return e[4]!==s?(l=r.jsx(td,{className:a,"aria-label":s}),e[4]=s,e[5]=l):l=e[5],l}if(t==="merged"){let a;e[6]===Symbol.for("react.memo_cache_sentinel")?(a=q("size-3.5 shrink-0","text-info"),e[6]=a):a=e[6];let l;return e[7]!==s?(l=r.jsx(ig,{className:a,"aria-label":s}),e[7]=s,e[8]=l):l=e[8],l}let o;e[9]===Symbol.for("react.memo_cache_sentinel")?(o=q("size-3.5 shrink-0","text-destructive"),e[9]=o):o=e[9];let i;return e[10]!==s?(i=r.jsx(w3,{className:o,"aria-label":s}),e[10]=s,e[11]=i):i=e[11],i}function Zp(n){return n==="success"?"Checks passed":n==="failure"?"Checks failed":"Checks running"}function JR(n){const e=B.c(3),{checks:t}=n;if(t==="success"){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(mt,{className:"size-3 text-success"}),e[0]=o):o=e[0],o}if(t==="failure"){let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(rt,{className:"size-3 text-destructive"}),e[1]=o):o=e[1],o}let s;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Po,{className:"size-3 text-info"}),e[2]=s):s=e[2],s}function QR(n){return n.reviewRequested?{icon:r.jsx(ys,{className:"size-3 text-info"}),label:"Your review is requested"}:n.review==="approved"?{icon:r.jsx(Cr,{className:"size-3 text-success"}),label:"Approved"}:n.review==="changes_requested"?{icon:r.jsx(tn,{className:"size-3 text-warning"}),label:"Changes requested"}:n.review==="review_required"&&Ks(n)?{icon:r.jsx(ys,{className:"size-3 text-muted-foreground"}),label:"Review required"}:null}function ZR(n){const e=B.c(17),{pull:t,onShowChecks:s}=n;let o;e[0]!==t?(o=QR(t),e[0]=t,e[1]=o):o=e[1];const i=o;let a;e[2]!==s||e[3]!==t.checks||e[4]!==t.headBranch?(a=t.checks&&r.jsx("button",{type:"button",className:"rounded-sm outline-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/20","aria-label":`${Zp(t.checks)}, show runs`,title:Zp(t.checks),onClick:()=>s(t.headBranch),children:r.jsx(JR,{checks:t.checks})}),e[2]=s,e[3]=t.checks,e[4]=t.headBranch,e[5]=a):a=e[5];let l;e[6]!==i?(l=i&&r.jsx("span",{"aria-label":i.label,title:i.label,role:"img",children:i.icon}),e[6]=i,e[7]=l):l=e[7];let c;e[8]!==t.conflicts?(c=t.conflicts&&r.jsx(xn,{className:"size-3 text-warning","aria-label":"Has merge conflicts",role:"img"}),e[8]=t.conflicts,e[9]=c):c=e[9];let d;e[10]!==t.comments?(d=r.jsx(R2,{count:t.comments}),e[10]=t.comments,e[11]=d):d=e[11];let u;return e[12]!==a||e[13]!==l||e[14]!==c||e[15]!==d?(u=r.jsxs("span",{className:"flex h-5 shrink-0 items-center gap-1.5",children:[a,l,c,d]}),e[12]=a,e[13]=l,e[14]=c,e[15]=d,e[16]=u):u=e[16],u}function eI(n){return n==="added"||n==="copied"?{mark:"A",className:"text-success"}:n==="removed"?{mark:"D",className:"text-destructive"}:n==="renamed"?{mark:"R",className:"text-info"}:{mark:"M",className:"text-warning"}}function tI(n){const e=n.lastIndexOf("/");return e===-1?{directory:"",name:n}:{directory:n.slice(0,e+1),name:n.slice(e+1)}}function nI(n){const e=B.c(38),{file:t}=n;let s,o,i,a,l,c;if(e[0]!==t.path||e[1]!==t.status){const{mark:S,className:j}=eI(t.status);o=S;let k;e[8]!==t.path?(k=tI(t.path),e[8]=t.path,e[9]=k):k=e[9],{directory:s,name:i}=k,l="flex min-w-0 items-center gap-2 py-0.5 font-mono text-[11px] leading-5",c=t.path,a=q("w-3 shrink-0 text-center font-medium",j),e[0]=t.path,e[1]=t.status,e[2]=s,e[3]=o,e[4]=i,e[5]=a,e[6]=l,e[7]=c}else s=e[2],o=e[3],i=e[4],a=e[5],l=e[6],c=e[7];let d;e[10]!==t.status||e[11]!==o||e[12]!==a?(d=r.jsx("span",{className:a,"aria-label":t.status,children:o}),e[10]=t.status,e[11]=o,e[12]=a,e[13]=d):d=e[13];let u;e[14]!==s?(u=r.jsx("span",{className:"text-muted-foreground",children:s}),e[14]=s,e[15]=u):u=e[15];const f=t.status==="removed"&&"line-through text-muted-foreground";let m;e[16]!==f?(m=q(f),e[16]=f,e[17]=m):m=e[17];let p;e[18]!==i||e[19]!==m?(p=r.jsx("span",{className:m,children:i}),e[18]=i,e[19]=m,e[20]=p):p=e[20];let h;e[21]!==u||e[22]!==p?(h=r.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[u,p]}),e[21]=u,e[22]=p,e[23]=h):h=e[23];let g;e[24]!==t.additions?(g=t.additions>0&&r.jsxs("span",{className:"text-success",children:["+",t.additions]}),e[24]=t.additions,e[25]=g):g=e[25];const x=t.additions>0&&t.deletions>0&&" ";let b;e[26]!==t.deletions?(b=t.deletions>0&&r.jsxs("span",{className:"text-destructive",children:["−",t.deletions]}),e[26]=t.deletions,e[27]=b):b=e[27];let w;e[28]!==g||e[29]!==x||e[30]!==b?(w=r.jsxs("span",{className:"shrink-0 text-[10px] tabular-nums",children:[g,x,b]}),e[28]=g,e[29]=x,e[30]=b,e[31]=w):w=e[31];let v;return e[32]!==w||e[33]!==l||e[34]!==c||e[35]!==d||e[36]!==h?(v=r.jsxs("li",{className:l,title:c,children:[d,h,w]}),e[32]=w,e[33]=l,e[34]=c,e[35]=d,e[36]=h,e[37]=v):v=e[37],v}function sI(n){var j,k,C,N,_,P;const e=B.c(40),{pull:t,files:s}=n;let o;e[0]!==t.body?(o=t.body.trim(),e[0]=t.body,e[1]=o):o=e[1];const i=o;let a;e[2]!==((j=s.data)==null?void 0:j.files)?(a=((k=s.data)==null?void 0:k.files)??[],e[2]=(C=s.data)==null?void 0:C.files,e[3]=a):a=e[3];const l=a;let c;e[4]!==i?(c=i?r.jsx($2,{body:i}):r.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"No description."}),e[4]=i,e[5]=c):c=e[5];let d;e[6]!==s.data||e[7]!==l.length?(d=s.data&&r.jsx("span",{className:"font-mono text-[10px] font-normal text-muted-foreground tabular-nums",children:s.data.truncated?`${l.length}+`:l.length}),e[6]=s.data,e[7]=l.length,e[8]=d):d=e[8];let u;e[9]!==d?(u=r.jsxs("h4",{className:"flex items-center gap-1.5 text-[11px] font-medium leading-5",children:["Files changed",d]}),e[9]=d,e[10]=u):u=e[10];let f;e[11]!==s.data||e[12]!==s.loading?(f=s.loading&&!s.data&&r.jsxs("div",{className:"flex items-center gap-2 py-1 text-[11px] text-muted-foreground",role:"status",children:[r.jsx(xt,{className:"size-3"}),"Loading files"]}),e[11]=s.data,e[12]=s.loading,e[13]=f):f=e[13];let m;e[14]!==s.error?(m=s.error&&r.jsx("p",{className:"py-1 text-[11px] text-destructive",children:s.error.error}),e[14]=s.error,e[15]=m):m=e[15];let p;e[16]!==s.data||e[17]!==l.length?(p=s.data&&l.length===0&&r.jsx("p",{className:"py-1 text-[11px] text-muted-foreground",children:"No file changes on this pull request."}),e[16]=s.data,e[17]=l.length,e[18]=p):p=e[18];let h;e[19]!==l?(h=l.length>0&&r.jsx("ul",{className:"border-l border-border pl-2",children:l.map(oI)}),e[19]=l,e[20]=h):h=e[20];let g;e[21]!==((N=s.data)==null?void 0:N.truncated)||e[22]!==l.length?(g=((_=s.data)==null?void 0:_.truncated)&&r.jsxs("p",{className:"py-1 text-[11px] text-muted-foreground",children:["GitHub lists the first ",l.length," files here. The full set is on the pull request."]}),e[21]=(P=s.data)==null?void 0:P.truncated,e[22]=l.length,e[23]=g):g=e[23];let x;e[24]!==g||e[25]!==u||e[26]!==f||e[27]!==m||e[28]!==p||e[29]!==h?(x=r.jsxs("section",{"aria-label":"Files changed",className:"min-w-0",children:[u,f,m,p,h,g]}),e[24]=g,e[25]=u,e[26]=f,e[27]=m,e[28]=p,e[29]=h,e[30]=x):x=e[30];let b;e[31]!==t.url?(b=r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer"}),e[31]=t.url,e[32]=b):b=e[32];let w;e[33]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(zn,{"data-icon":"inline-end"}),e[33]=w):w=e[33];let v;e[34]!==b?(v=r.jsxs(ee,{variant:"outline",size:"xs",className:"self-start",render:b,children:["Open pull request on GitHub",w]}),e[34]=b,e[35]=v):v=e[35];let S;return e[36]!==x||e[37]!==v||e[38]!==c?(S=r.jsxs("div",{className:"flex flex-col gap-3 py-2 pl-[22px] pr-1",children:[c,x,v]}),e[36]=x,e[37]=v,e[38]=c,e[39]=S):S=e[39],S}function oI(n){return r.jsx(nI,{file:n},n.path)}function rI(n){const e=B.c(7),{sessions:t,openSession:s}=n;let o;if(e[0]!==s||e[1]!==t){let a;e[3]!==s?(a=l=>r.jsxs("button",{type:"button",className:"inline-flex h-5 max-w-full items-center gap-1 rounded-full border px-1.5 text-[10px] leading-none text-muted-foreground outline-none hover:border-foreground/30 hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/20 disabled:cursor-default disabled:hover:border-border disabled:hover:text-muted-foreground",onClick:()=>s==null?void 0:s(l.dirName,l.fileName),disabled:!s,"aria-label":`Open session: ${l.title||l.sessionId}`,title:l.title||l.sessionId,children:[r.jsx(oc,{className:"size-3 shrink-0","aria-hidden":!0}),r.jsx("span",{className:"truncate",children:l.title||l.sessionId.slice(0,8)})]},l.sessionId),e[3]=s,e[4]=a):a=e[4],o=t.map(a),e[0]=s,e[1]=t,e[2]=o}else o=e[2];let i;return e[5]!==o?(i=r.jsx("div",{className:"flex flex-wrap gap-1 pl-[26px] pr-1 pb-1","aria-label":"Sessions on this pull request",children:o}),e[5]=o,e[6]=i):i=e[6],i}function iI(n){const e=B.c(88),{pull:t,projectPath:s,currentBranch:o,sessions:i,openSession:a,onShowChecks:l,now:c}=n;let d;e[0]!==s||e[1]!==t.number?(d=()=>bR(s,t.number),e[0]=s,e[1]=t.number,e[2]=d):d=e[2];const{open:u,state:f,onOpenChange:m}=I2(d,"Unable to load changed files"),p=o!==null&&t.headBranch===o,h=Ks(t)?t.updatedAt:t.closedAt??t.updatedAt,g=t.title,x=YR[t.state];let b;e[3]!==x?(b=q("absolute inset-y-1 left-0 w-0.5 rounded-full",x),e[3]=x,e[4]=b):b=e[4];let w;e[5]!==b?(w=r.jsx("span",{"aria-hidden":!0,className:b}),e[5]=b,e[6]=w):w=e[6];const v=`${t.title} #${t.number}: ${D2[t.state]}`;let S;e[7]!==t.state?(S=r.jsx(XR,{state:t.state}),e[7]=t.state,e[8]=S):S=e[8];let j;e[9]!==t?(j=!Ks(t)&&"text-muted-foreground",e[9]=t,e[10]=j):j=e[10];let k;e[11]!==j?(k=q("min-w-0 flex-1 truncate text-[13px] font-medium leading-5",j),e[11]=j,e[12]=k):k=e[12];let C;e[13]!==t.title||e[14]!==k?(C=r.jsx("span",{className:k,children:t.title}),e[13]=t.title,e[14]=k,e[15]=C):C=e[15];let N;e[16]!==t.number?(N=r.jsxs("span",{className:"shrink-0 font-mono text-[10px] text-muted-foreground",children:["#",t.number]}),e[16]=t.number,e[17]=N):N=e[17];let _;e[18]!==C||e[19]!==N||e[20]!==S?(_=r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[S,C,N]}),e[18]=C,e[19]=N,e[20]=S,e[21]=_):_=e[21];let P;e[22]!==t.author?(P=t.author&&r.jsx("span",{className:"shrink-0",children:t.author}),e[22]=t.author,e[23]=P):P=e[23];let A;e[24]!==p?(A=p&&r.jsx(Dn,{className:"size-3 shrink-0 text-foreground","aria-label":"Current branch"}),e[24]=p,e[25]=A):A=e[25];const T=p&&"text-foreground";let E;e[26]!==T?(E=q("truncate",T),e[26]=T,e[27]=E):E=e[27];let R;e[28]!==t.headBranch||e[29]!==E?(R=r.jsx("span",{className:E,children:t.headBranch}),e[28]=t.headBranch,e[29]=E,e[30]=R):R=e[30];let $;e[31]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx(j3,{className:"size-3 shrink-0","aria-hidden":!0}),e[31]=$):$=e[31];let I;e[32]!==t.baseBranch?(I=r.jsx("span",{className:"max-w-24 shrink-0 truncate",children:t.baseBranch}),e[32]=t.baseBranch,e[33]=I):I=e[33];let M;e[34]!==A||e[35]!==R||e[36]!==I?(M=r.jsxs("span",{className:"flex min-w-0 items-center gap-1 font-mono",children:[A,R,$,I]}),e[34]=A,e[35]=R,e[36]=I,e[37]=M):M=e[37];let D;e[38]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx("span",{className:"shrink-0",children:"·"}),e[38]=D):D=e[38];let O;e[39]!==h?(O=new Date(h).toLocaleString(),e[39]=h,e[40]=O):O=e[40];let L;e[41]!==h||e[42]!==c?(L=bu(h,c),e[41]=h,e[42]=c,e[43]=L):L=e[43];let F;e[44]!==h||e[45]!==O||e[46]!==L?(F=r.jsx("time",{className:"shrink-0",dateTime:h,title:O,children:L}),e[44]=h,e[45]=O,e[46]=L,e[47]=F):F=e[47];let z;e[48]!==P||e[49]!==M||e[50]!==F?(z=r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 pl-[22px] text-[11px] leading-4 text-muted-foreground",children:[P,M,D,F]}),e[48]=P,e[49]=M,e[50]=F,e[51]=z):z=e[51];let W;e[52]!==u||e[53]!==_||e[54]!==z||e[55]!==v?(W=r.jsxs(Mt,{className:"flex min-w-0 flex-1 flex-col rounded-sm px-1 py-1 text-left outline-none hover:bg-accent/60 focus-visible:ring-[3px] focus-visible:ring-ring/20","aria-label":v,"aria-expanded":u,children:[_,z]}),e[52]=u,e[53]=_,e[54]=z,e[55]=v,e[56]=W):W=e[56];let U;e[57]!==l||e[58]!==t?(U=r.jsx(ZR,{pull:t,onShowChecks:l}),e[57]=l,e[58]=t,e[59]=U):U=e[59];const H=`Open #${t.number} on GitHub`;let K;e[60]!==t.url?(K=()=>window.open(t.url,"_blank","noopener,noreferrer"),e[60]=t.url,e[61]=K):K=e[61];let V;e[62]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx(zn,{}),e[62]=V):V=e[62];let Y;e[63]!==H||e[64]!==K?(Y=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",className:"size-6 text-muted-foreground opacity-0 transition-opacity group-hover/pull:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100","aria-label":H,onClick:K,children:V}),e[63]=H,e[64]=K,e[65]=Y):Y=e[65];let G;e[66]!==U||e[67]!==Y?(G=r.jsxs("div",{className:"mt-1 flex shrink-0 items-center gap-1",children:[U,Y]}),e[66]=U,e[67]=Y,e[68]=G):G=e[68];let J;e[69]!==W||e[70]!==G?(J=r.jsxs("div",{className:"group/pull flex items-start gap-1 pr-1",children:[W,G]}),e[69]=W,e[70]=G,e[71]=J):J=e[71];let Q;e[72]!==a||e[73]!==i?(Q=i.length>0&&r.jsx(rI,{sessions:i,openSession:a}),e[72]=a,e[73]=i,e[74]=Q):Q=e[74];let X;e[75]!==f||e[76]!==t?(X=r.jsx(dt,{children:r.jsx(sI,{pull:t,files:f})}),e[75]=f,e[76]=t,e[77]=X):X=e[77];let Z;e[78]!==m||e[79]!==u||e[80]!==J||e[81]!==Q||e[82]!==X?(Z=r.jsxs(ct,{open:u,onOpenChange:m,children:[J,Q,X]}),e[78]=m,e[79]=u,e[80]=J,e[81]=Q,e[82]=X,e[83]=Z):Z=e[83];let te;return e[84]!==t.title||e[85]!==Z||e[86]!==w?(te=r.jsxs("article",{className:"relative pl-3","aria-label":g,children:[w,Z]}),e[84]=t.title,e[85]=Z,e[86]=w,e[87]=te):te=e[87],te}function aI(n,e,t){return e==="mine"?n.filter(s=>s.author===t.viewer):e==="branch"?n.filter(s=>s.headBranch===t.branch):[...n]}function lI(n){const e=new Map;for(const t of n)for(const s of t.numbers){const o=e.get(s);o?o.push(t):e.set(s,[t])}return e}function cI(n){const e=B.c(61),{data:t,sessions:s,projectPath:o,openSession:i,onShowChecks:a}=n,[l,c]=y.useState("all"),d=yu(!1);let u;e[0]!==s?(u=lI(s),e[0]=s,e[1]=u):u=e[1];const f=u;let m;e[2]!==t.pulls||e[3]!==t.viewer?(m=t.viewer?t.pulls.filter(A=>A.author===t.viewer).length:0,e[2]=t.pulls,e[3]=t.viewer,e[4]=m):m=e[4];const p=m;let h;e[5]!==t.branch||e[6]!==t.pulls?(h=t.branch?t.pulls.filter(A=>A.headBranch===t.branch).length:0,e[5]=t.branch,e[6]=t.pulls,e[7]=h):h=e[7];const g=h,x=l==="mine"&&p===0||l==="branch"&&g===0?"all":l;let b,w,v,S,j,k,C;if(e[8]!==g||e[9]!==t||e[10]!==x||e[11]!==f||e[12]!==p||e[13]!==d||e[14]!==a||e[15]!==i||e[16]!==o){C=Symbol.for("react.early_return_sentinel");e:{const A=aI(t.pulls,x,t),T=A.filter(Ks),E=A.filter(dI);if(t.pulls.length===0){let z;e[24]===Symbol.for("react.memo_cache_sentinel")?(z=r.jsx(xu,{icon:Er,title:"No pull requests yet",description:"Open one from a branch and it will show up here."}),e[24]=z):z=e[24],C=z;break e}let R;e[25]!==t.branch||e[26]!==f||e[27]!==d||e[28]!==a||e[29]!==i||e[30]!==o?(R=z=>r.jsx(iI,{pull:z,projectPath:o,currentBranch:t.branch,sessions:f.get(z.number)??[],openSession:i,onShowChecks:a,now:d},z.number),e[25]=t.branch,e[26]=f,e[27]=d,e[28]=a,e[29]=i,e[30]=o,e[31]=R):R=e[31];const $=R,I=x==="all";let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=()=>c("all"),e[32]=M):M=e[32];let D;e[33]!==t.pulls.length?(D=r.jsx(Wt,{children:t.pulls.length}),e[33]=t.pulls.length,e[34]=D):D=e[34];let O;e[35]!==I||e[36]!==D?(O=r.jsxs(Ut,{pressed:I,onClick:M,children:["All",D]}),e[35]=I,e[36]=D,e[37]=O):O=e[37];let L;e[38]!==t.viewer||e[39]!==x||e[40]!==p?(L=t.viewer&&r.jsxs(Ut,{pressed:x==="mine",disabled:p===0,onClick:()=>c("mine"),"aria-label":`Only pull requests by ${t.viewer}`,children:[r.jsx(sd,{className:"size-3"}),"Mine",r.jsx(Wt,{children:p})]}),e[38]=t.viewer,e[39]=x,e[40]=p,e[41]=L):L=e[41];let F;e[42]!==g||e[43]!==t.branch||e[44]!==x?(F=t.branch&&r.jsxs(Ut,{pressed:x==="branch",disabled:g===0,onClick:()=>c("branch"),"aria-label":`Only pull requests from ${t.branch}`,children:[r.jsx(Dn,{className:"size-3"}),r.jsx("span",{className:"max-w-28 truncate",children:t.branch}),r.jsx(Wt,{children:g})]}),e[42]=g,e[43]=t.branch,e[44]=x,e[45]=F):F=e[45],e[46]!==O||e[47]!==L||e[48]!==F?(k=r.jsxs(gu,{label:"Filter pull requests",children:[O,L,F]}),e[46]=O,e[47]=L,e[48]=F,e[49]=k):k=e[49],b=is,j="min-h-0 flex-1",w="flex flex-col gap-4 px-3 py-3",v=T.length===0?r.jsx("p",{className:"px-1 py-3 text-center text-xs text-muted-foreground",children:"Nothing open right now."}):T.map($),S=E.length>0&&r.jsx(A2,{count:E.length,children:E.map($)})}e[8]=g,e[9]=t,e[10]=x,e[11]=f,e[12]=p,e[13]=d,e[14]=a,e[15]=i,e[16]=o,e[17]=b,e[18]=w,e[19]=v,e[20]=S,e[21]=j,e[22]=k,e[23]=C}else b=e[17],w=e[18],v=e[19],S=e[20],j=e[21],k=e[22],C=e[23];if(C!==Symbol.for("react.early_return_sentinel"))return C;let N;e[50]!==w||e[51]!==v||e[52]!==S?(N=r.jsxs("div",{className:w,children:[v,S]}),e[50]=w,e[51]=v,e[52]=S,e[53]=N):N=e[53];let _;e[54]!==b||e[55]!==N||e[56]!==j?(_=r.jsx(b,{className:j,children:N}),e[54]=b,e[55]=N,e[56]=j,e[57]=_):_=e[57];let P;return e[58]!==_||e[59]!==k?(P=r.jsxs(r.Fragment,{children:[k,_]}),e[58]=_,e[59]=k,e[60]=P):P=e[60],P}function dI(n){return!Ks(n)}const uI={actions:"Refresh GitHub Actions",pulls:"Refresh pull requests",issues:"Refresh issues"};function fI(n){return n==="actions"||n==="pulls"||n==="issues"}function mI(n){return n.code==="gh_missing"?"Install GitHub CLI, then refresh this panel.":n.code==="gh_auth_required"?"Run `gh auth login` on the Cogpit host, then refresh.":n.code==="no_github_remote"?"Add a GitHub origin remote to this repository.":"Check the repository and your GitHub access, then try again."}function pI(n){const e=B.c(3),{label:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=[0,1,2].map(hI),e[0]=s):s=e[0];let o;return e[1]!==t?(o=r.jsx("div",{className:"flex flex-col gap-5 px-3 py-4","aria-label":t,children:s}),e[1]=t,e[2]=o):o=e[2],o}function hI(n){return r.jsxs("div",{className:"flex flex-col gap-2 border-l-2 border-border pl-3",children:[r.jsx(ft,{className:"h-3.5 w-3/4"}),r.jsx(ft,{className:"h-2.5 w-1/2"}),r.jsx(ft,{className:"h-3 w-full"}),r.jsx(ft,{className:"h-3 w-full"})]},n)}function Hl(n){const e=B.c(23),{state:t,loadingLabel:s,onRetry:o,children:i}=n;if(t.data){let l;e[0]!==i||e[1]!==t.data?(l=i(t.data),e[0]=i,e[1]=t.data,e[2]=l):l=e[2];let c;return e[3]!==l?(c=r.jsx(r.Fragment,{children:l}),e[3]=l,e[4]=c):c=e[4],c}if(t.error){let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(tn,{}),e[5]=l):l=e[5];let c;e[6]!==t.error.error?(c=r.jsx(Tt,{children:t.error.error}),e[6]=t.error.error,e[7]=c):c=e[7];let d;e[8]!==t.error?(d=mI(t.error),e[8]=t.error,e[9]=d):d=e[9];let u;e[10]!==d?(u=r.jsx("span",{children:d}),e[10]=d,e[11]=u):u=e[11];let f;e[12]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(Ot,{"data-icon":"inline-start"}),e[12]=f):f=e[12];let m;e[13]!==o?(m=r.jsxs(ee,{type:"button",variant:"outline",size:"xs",onClick:o,children:[f,"Try again"]}),e[13]=o,e[14]=m):m=e[14];let p;e[15]!==u||e[16]!==m?(p=r.jsxs(gt,{className:"flex flex-col items-start gap-2",children:[u,m]}),e[15]=u,e[16]=m,e[17]=p):p=e[17];let h;return e[18]!==c||e[19]!==p?(h=r.jsx("div",{className:"p-3",children:r.jsxs(ht,{variant:"destructive",children:[l,c,p]})}),e[18]=c,e[19]=p,e[20]=h):h=e[20],h}let a;return e[21]!==s?(a=r.jsx(pI,{label:s}),e[21]=s,e[22]=a):a=e[22],a}function Kl(n){const e=B.c(5),{value:t,attention:s}=n;if(t===null||t===0)return null;const o=s?"text-info":"text-muted-foreground";let i;e[0]!==o?(i=q("font-mono text-[10px] tabular-nums",o),e[0]=o,e[1]=i):i=e[1];let a;return e[2]!==i||e[3]!==t?(a=r.jsx("span",{className:i,children:t}),e[2]=i,e[3]=t,e[4]=a):a=e[4],a}function gI(n){var f,m,p,h;const e=B.c(11),{context:t}=n,s=t.projectPath!==null,{data:o}=T2(t.projectPath,s),i=E2(t.projectPath,s);let a;e[0]!==(o==null?void 0:o.runs)?(a=(o==null?void 0:o.runs.filter(bI).length)??0,e[0]=o==null?void 0:o.runs,e[1]=a):a=e[1];const l=a,c=(f=o==null?void 0:o.runs[0])!=null&&f.conclusion?$o(o.runs[0].conclusion):!1;let d;e[2]!==((m=i.data)==null?void 0:m.pulls)?(d=((p=i.data)==null?void 0:p.pulls.filter(xI).length)??0,e[2]=(h=i.data)==null?void 0:h.pulls,e[3]=d):d=e[3];const u=d;if(l>0){const g=`${l} active GitHub Actions run${l===1?"":"s"}`;let x;return e[4]!==l||e[5]!==g?(x=r.jsx(_e,{className:"absolute -right-1 -top-1 min-w-4 px-1 text-[9px]","aria-label":g,children:l}),e[4]=l,e[5]=g,e[6]=x):x=e[6],x}if(c){let g;return e[7]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx(_e,{variant:"destructive",className:"absolute -right-0.5 -top-0.5 size-3 p-0 text-[8px]","aria-label":"Latest GitHub Actions run failed",children:"!"}),e[7]=g):g=e[7],g}if(u>0){const g=`${u} pull request${u===1?"":"s"} waiting for your review`;let x;return e[8]!==u||e[9]!==g?(x=r.jsx(_e,{variant:"secondary",className:"absolute -right-1 -top-1 min-w-4 px-1 text-[9px]","aria-label":g,children:u}),e[8]=u,e[9]=g,e[10]=x):x=e[10],x}return null}function xI(n){return Ks(n)&&n.reviewRequested}function bI(n){return Yr(n.status)}function vI(n){const e=B.c(78),{context:t,active:s,closePanel:o}=n,[i,a]=y.useState("actions"),[l,c]=y.useState(null),d=t.projectPath,u=T2(d,s),f=E2(d,s),m=gR(d,s&&i==="pulls"),p=hR(d,s&&i==="issues");let h;e[0]!==p||e[1]!==f||e[2]!==u?(h={actions:u,pulls:f,issues:p},e[0]=p,e[1]=f,e[2]=u,e[3]=h):h=e[3];const g=h[i];let x;e[4]===Symbol.for("react.memo_cache_sentinel")?(x=function(re){c({branch:re}),a("actions")},e[4]=x):x=e[4];const b=x,w=u.data??f.data??p.data;let v;e[5]!==u.data?(v=u.data?u.data.runs.filter(wI).length:null,e[5]=u.data,e[6]=v):v=e[6];const S=v;let j;e[7]!==f.data?(j=f.data?f.data.pulls.filter(Ks).length:null,e[7]=f.data,e[8]=j):j=e[8];const k=j;let C;e[9]!==p.data?(C=p.data?p.data.issues.filter(yI).length:null,e[9]=p.data,e[10]=C):C=e[10];const N=C;let _;e[11]===Symbol.for("react.memo_cache_sentinel")?(_=ne=>{fI(ne)&&a(ne)},e[11]=_):_=e[11];let P;e[12]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx("h2",{className:"text-sm font-medium leading-tight",children:"GitHub"}),e[12]=P):P=e[12];let A;e[13]!==w||e[14]!==i?(A=r.jsxs("div",{className:"min-w-0 flex-1",children:[P,w?r.jsxs("a",{href:`${w.repositoryUrl}/${i}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex max-w-full items-center gap-0.5 truncate text-[11px] text-muted-foreground outline-none hover:text-foreground focus-visible:underline",children:[r.jsx("span",{className:"truncate",children:w.repository}),r.jsx(zn,{className:"size-3 shrink-0"})]}):r.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:"Current repository"})]}),e[13]=w,e[14]=i,e[15]=A):A=e[15];let T;e[16]!==g?(T=()=>{g.refresh()},e[16]=g,e[17]=T):T=e[17];const E=g.loading||g.refreshing||!d,R=uI[i];let $;e[18]!==g.refreshing?($=g.refreshing?r.jsx(xt,{}):r.jsx(Ot,{}),e[18]=g.refreshing,e[19]=$):$=e[19];let I;e[20]!==E||e[21]!==R||e[22]!==$||e[23]!==T?(I=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:T,disabled:E,"aria-label":R,children:$}),e[20]=E,e[21]=R,e[22]=$,e[23]=T,e[24]=I):I=e[24];let M;e[25]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(rt,{}),e[25]=M):M=e[25];let D;e[26]!==o?(D=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:o,"aria-label":"Close GitHub",children:M}),e[26]=o,e[27]=D):D=e[27];let O;e[28]!==I||e[29]!==D||e[30]!==A?(O=r.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b pl-4 pr-2",children:[A,I,D]}),e[28]=I,e[29]=D,e[30]=A,e[31]=O):O=e[31];let L;e[32]!==S?(L=r.jsxs(ms,{value:"actions",className:"h-full flex-none rounded-none px-0 text-xs",children:["Actions",r.jsx(Kl,{value:S,attention:!0})]}),e[32]=S,e[33]=L):L=e[33];let F;e[34]!==k?(F=r.jsxs(ms,{value:"pulls",className:"h-full flex-none rounded-none px-0 text-xs",children:["Pull requests",r.jsx(Kl,{value:k})]}),e[34]=k,e[35]=F):F=e[35];let z;e[36]!==N?(z=r.jsxs(ms,{value:"issues",className:"h-full flex-none rounded-none px-0 text-xs",children:["Issues",r.jsx(Kl,{value:N})]}),e[36]=N,e[37]=z):z=e[37];let W;e[38]!==L||e[39]!==F||e[40]!==z?(W=r.jsx("div",{className:"flex h-9 shrink-0 items-end border-b px-3",children:r.jsxs(hd,{variant:"line",className:"h-full gap-3 p-0","aria-label":"GitHub views",children:[L,F,z]})}),e[38]=L,e[39]=F,e[40]=z,e[41]=W):W=e[41];let U;e[42]!==u?(U=()=>{u.refresh()},e[42]=u,e[43]=U):U=e[43];let H;e[44]!==l||e[45]!==d?(H=ne=>d&&r.jsx(IR,{data:ne,projectPath:d,focus:l}),e[44]=l,e[45]=d,e[46]=H):H=e[46];let K;e[47]!==u||e[48]!==U||e[49]!==H?(K=r.jsx(ps,{value:"actions",className:"flex min-h-0 flex-col",children:r.jsx(Hl,{state:u,loadingLabel:"Loading workflow runs",onRetry:U,children:H})}),e[47]=u,e[48]=U,e[49]=H,e[50]=K):K=e[50];let V;e[51]!==f?(V=()=>{f.refresh()},e[51]=f,e[52]=V):V=e[52];let Y;e[53]!==t.openSession||e[54]!==d||e[55]!==m?(Y=ne=>{var re;return d&&r.jsx(cI,{data:ne,sessions:((re=m.data)==null?void 0:re.sessions)??[],projectPath:d,openSession:t.openSession,onShowChecks:b})},e[53]=t.openSession,e[54]=d,e[55]=m,e[56]=Y):Y=e[56];let G;e[57]!==f||e[58]!==V||e[59]!==Y?(G=r.jsx(ps,{value:"pulls",className:"flex min-h-0 flex-col",children:r.jsx(Hl,{state:f,loadingLabel:"Loading pull requests",onRetry:V,children:Y})}),e[57]=f,e[58]=V,e[59]=Y,e[60]=G):G=e[60];let J;e[61]!==p?(J=()=>{p.refresh()},e[61]=p,e[62]=J):J=e[62];let Q;e[63]!==t.composePrompt?(Q=ne=>r.jsx(qR,{data:ne,composePrompt:t.composePrompt,onShowPulls:()=>a("pulls")}),e[63]=t.composePrompt,e[64]=Q):Q=e[64];let X;e[65]!==p||e[66]!==J||e[67]!==Q?(X=r.jsx(ps,{value:"issues",className:"flex min-h-0 flex-col",children:r.jsx(Hl,{state:p,loadingLabel:"Loading issues",onRetry:J,children:Q})}),e[65]=p,e[66]=J,e[67]=Q,e[68]=X):X=e[68];let Z;e[69]!==K||e[70]!==G||e[71]!==X?(Z=r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[K,G,X]}),e[69]=K,e[70]=G,e[71]=X,e[72]=Z):Z=e[72];let te;return e[73]!==O||e[74]!==W||e[75]!==Z||e[76]!==i?(te=r.jsxs(pd,{value:i,onValueChange:_,className:"size-full min-h-0 gap-0","aria-label":"GitHub panel",children:[O,W,Z]}),e[73]=O,e[74]=W,e[75]=Z,e[76]=i,e[77]=te):te=e[77],te}function yI(n){return n.state==="open"}function wI(n){return Yr(n.status)}const jI={id:"github",workspacePanels:[{id:"repository",title:"GitHub",icon:Uh,component:vI,indicator:gI,order:40,defaultSize:"38%",minSize:"360px",maxSize:"62%",when:n=>n.canAccessHostFiles&&n.projectPath!==null}]},Nu={data:null,error:null,loading:!1,refreshing:!1},eh=new Map,SI=8e3,NI=1e4,kI=new Set(["vercel_access_denied","vercel_auth_required","vercel_cli_too_old","vercel_missing","vercel_project_unlinked"]);function ku(n){let e=eh.get(n);return e||(e={snapshot:Nu,listeners:new Set,request:null,fetchedAt:0},eh.set(n,e)),e}function ql(n,e){n.snapshot=e;for(const t of n.listeners)t()}async function L2(n){try{const e=await n.json();if(typeof e.error=="string"&&typeof e.code=="string")return e}catch{}return{error:`Vercel request failed (${n.status})`,code:"vercel_api_failed"}}async function Vl(n,e=!1){const t=ku(n);if(t.request)return t.request;if(!(!e&&t.snapshot.error&&kI.has(t.snapshot.error.code))&&!(!e&&t.fetchedAt>0&&Date.now()-t.fetchedAt<SI))return ql(t,{...t.snapshot,error:null,loading:t.snapshot.data===null,refreshing:t.snapshot.data!==null}),t.request=ve(`/api/vercel-deployments?cwd=${encodeURIComponent(n)}&limit=20`).then(async s=>{if(!s.ok)throw await L2(s);const o=await s.json();t.fetchedAt=Date.now(),ql(t,{data:o,error:null,loading:!1,refreshing:!1})}).catch(s=>{const o=s;ql(t,{...t.snapshot,error:{error:typeof o.error=="string"?o.error:"Unable to load Vercel deployments",code:typeof o.code=="string"?o.code:"vercel_api_failed"},loading:!1,refreshing:!1})}).finally(()=>{t.request=null}),t.request}function CI(n,e){if(!n)return()=>{};const t=ku(n);return t.listeners.add(e),()=>t.listeners.delete(e)}function _I(n){return n?ku(n).snapshot:Nu}function z2(n,e){const t=B.c(13),s=n??"";let o;t[0]!==s?(o=m=>CI(s,m),t[0]=s,t[1]=o):o=t[1];let i;t[2]!==s?(i=()=>_I(s),t[2]=s,t[3]=i):i=t[3];const a=y.useSyncExternalStore(o,i,TI);let l,c;t[4]!==e||t[5]!==s?(l=()=>{if(!e||!s)return;Vl(s);const m=window.setInterval(()=>{Vl(s)},NI);return()=>window.clearInterval(m)},c=[e,s],t[4]=e,t[5]=s,t[6]=l,t[7]=c):(l=t[6],c=t[7]),y.useEffect(l,c);let d;t[8]!==s?(d=()=>s?Vl(s,!0):Promise.resolve(),t[8]=s,t[9]=d):d=t[9];const u=d;let f;return t[10]!==u||t[11]!==a?(f={...a,refresh:u},t[10]=u,t[11]=a,t[12]=f):f=t[12],f}function TI(){return Nu}async function EI(n,e){const t=await ve(`/api/vercel-deployments/build-logs?cwd=${encodeURIComponent(n)}&deploymentId=${encodeURIComponent(e)}&limit=200`);if(!t.ok)throw await L2(t);return t.json()}const PI={live:"bg-info motion-safe:animate-pulse",fail:"bg-destructive",pass:"bg-success"};function Xr(n){return n==="BUILDING"||n==="INITIALIZING"||n==="QUEUED"}function Ga(n){return n==="BLOCKED"||n==="CANCELED"||n==="ERROR"}function Eo(n){return n.target==="production"}function F2(n){return Xr(n)?"live":Ga(n)?"fail":"pass"}function Cu(n){return n==="READY"?"Ready":n==="BUILDING"?"Building":n==="INITIALIZING"?"Initializing":n==="QUEUED"?"Queued":n==="CANCELED"?"Canceled":n==="BLOCKED"?"Blocked":"Failed"}function B2(n,e){const t=Math.floor((e-n)/6e4);if(t<1)return"now";if(t<60)return`${t}m`;const s=Math.floor(t/60);if(s<24)return`${s}h`;const o=Math.floor(s/24);return o<7?`${o}d`:new Date(n).toLocaleDateString()}function AI(n,e){const t=n.buildingAt??n.createdAt,s=n.readyAt??(Xr(n.state)?e:null);if(s===null)return null;const o=Math.max(0,Math.round((s-t)/1e3));if(o<60)return`${o}s`;const i=Math.floor(o/60);return i<60?`${i}m ${o%60}s`:`${Math.floor(i/60)}h ${i%60}m`}function RI(n){const e=B.c(3),[t,s]=y.useState(II);let o,i;return e[0]!==n?(o=()=>{if(s(Date.now()),!n)return;const a=window.setInterval(()=>s(Date.now()),1e3);return()=>window.clearInterval(a)},i=[n],e[0]=n,e[1]=o,e[2]=i):(o=e[1],i=e[2]),y.useEffect(o,i),t}function II(){return Date.now()}function _u(n){if(!n)return null;try{return new URL(n).host}catch{return null}}function Ic(n){return n.commitMessage.split(`
127
- `)[0]||_u(n.url)||`${Cu(n.state)} deployment`}function $I(n){return[n.errorCode,n.errorMessage].filter(Boolean).join(": ")||null}function U2(n){const e=B.c(12),{state:t,className:s}=n;let o;e[0]!==t?(o=Cu(t),e[0]=t,e[1]=o):o=e[1];const i=o;let a,l,c;if(e[2]!==s||e[3]!==i||e[4]!==t){c=Symbol.for("react.early_return_sentinel");e:{const u=q("size-3.5 shrink-0",s);if(t==="BUILDING"){c=r.jsx(xt,{className:q(u,"text-info"),"aria-label":i});break e}if(t==="INITIALIZING"||t==="QUEUED"){c=r.jsx(Po,{className:q(u,"text-info"),"aria-label":i});break e}if(t==="READY"){c=r.jsx(mt,{className:q(u,"text-success"),"aria-label":i});break e}if(t==="BLOCKED"){c=r.jsx(S3,{className:q(u,"text-destructive"),"aria-label":i});break e}a=rt,l=q(u,"text-destructive")}e[2]=s,e[3]=i,e[4]=t,e[5]=a,e[6]=l,e[7]=c}else a=e[5],l=e[6],c=e[7];if(c!==Symbol.for("react.early_return_sentinel"))return c;let d;return e[8]!==a||e[9]!==i||e[10]!==l?(d=r.jsx(a,{className:l,"aria-label":i}),e[8]=a,e[9]=i,e[10]=l,e[11]=d):d=e[11],d}function MI(){const n=B.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("span",{className:"shrink-0 rounded-sm border border-foreground/25 px-1 font-mono text-[9px] uppercase leading-[14px] tracking-wide text-foreground/80",children:"prod"}),n[0]=e):e=n[0],e}function OI(n){return n.code==="vercel_missing"?"Install Vercel CLI on the Cogpit host, then refresh.":n.code==="vercel_cli_too_old"?"Update Vercel CLI to 50.5.1 or newer, then refresh.":n.code==="vercel_auth_required"?"Run `vercel login` on the Cogpit host, then refresh.":n.code==="vercel_project_unlinked"?"Run `vercel link` from this exact project root.":n.code==="vercel_access_denied"?"Sign in to an account with access to the linked Vercel project.":"Check the linked project and your Vercel access, then try again."}function DI(){const n=B.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs("div",{className:"flex flex-col gap-4 px-3 py-4","aria-label":"Loading Vercel deployments",children:[r.jsxs("div",{className:"flex flex-col gap-2 rounded-md border px-3 py-2.5",children:[r.jsx(ft,{className:"h-2.5 w-16"}),r.jsx(ft,{className:"h-3.5 w-3/4"}),r.jsx(ft,{className:"h-2.5 w-1/2"})]}),[0,1,2,3].map(LI)]}),n[0]=e):e=n[0],e}function LI(n){return r.jsxs("div",{className:"flex flex-col gap-2 border-l-2 border-border pl-3",children:[r.jsx(ft,{className:"h-3.5 w-4/5"}),r.jsx(ft,{className:"h-2.5 w-1/2"})]},n)}const zI={data:null,error:null,loading:!1};function FI(n){const e=B.c(5),{logs:t}=n;if(t.events.length===0){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("p",{className:"py-1 text-[11px] text-muted-foreground",children:"Vercel reported no build output."}),e[0]=i):i=e[0],i}let s;e[1]!==t.events?(s=t.events.map(BI),e[1]=t.events,e[2]=s):s=e[2];let o;return e[3]!==s?(o=r.jsx("div",{className:"max-h-64 overflow-auto rounded-md bg-muted/50 px-2 py-1.5 font-mono text-[10px] leading-4",children:s}),e[3]=s,e[4]=o):o=e[4],o}function BI(n){return r.jsxs("div",{className:q("flex gap-2",n.type==="stderr"&&"text-destructive"),children:[r.jsx("time",{className:"shrink-0 text-muted-foreground tabular-nums",dateTime:new Date(n.createdAt).toISOString(),children:new Date(n.createdAt).toLocaleTimeString([],{hour12:!1})}),r.jsx("span",{className:"min-w-0 whitespace-pre-wrap break-words",children:n.text})]},n.id)}function th(n){const e=B.c(6),{href:t,children:s}=n;let o;e[0]!==s?(o=r.jsx("span",{className:"truncate",children:s}),e[0]=s,e[1]=o):o=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(zn,{className:"size-3 shrink-0"}),e[2]=i):i=e[2];let a;return e[3]!==t||e[4]!==o?(a=r.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"inline-flex min-w-0 items-center gap-0.5 text-[11px] text-muted-foreground outline-none hover:text-foreground focus-visible:underline",children:[o,i]}),e[3]=t,e[4]=o,e[5]=a):a=e[5],a}function UI(n){const e=B.c(106),{deployment:t,projectPath:s,now:o}=n,[i,a]=y.useState(!1),[l,c]=y.useState(zI);let d;e[0]!==t.state?(d=F2(t.state),e[0]=t.state,e[1]=d):d=e[1];const u=d;let f;e[2]!==t||e[3]!==o?(f=AI(t,o),e[2]=t,e[3]=o,e[4]=f):f=e[4];const m=f;let p;e[5]!==t?(p=Ic(t),e[5]=t,e[6]=p):p=e[6];const h=p;let g;e[7]!==t?(g=$I(t),e[7]=t,e[8]=g):g=e[8];const x=g;let b;e[9]!==t.url?(b=_u(t.url),e[9]=t.url,e[10]=b):b=e[10];const w=b;let v;e[11]!==t.id||e[12]!==l.loading||e[13]!==s?(v=async function(){if(!l.loading){c(WI);try{const le=await EI(s,t.id);c({data:le,error:null,loading:!1})}catch(le){const pe=le;c({data:null,error:{error:typeof pe.error=="string"?pe.error:"Unable to load build output",code:pe.code??"vercel_api_failed"},loading:!1})}}},e[11]=t.id,e[12]=l.loading,e[13]=s,e[14]=v):v=e[14];const S=v;let j;e[15]!==t.state||e[16]!==S||e[17]!==l.data?(j=function(le){a(le),le&&(!l.data||Xr(t.state))&&S()},e[15]=t.state,e[16]=S,e[17]=l.data,e[18]=j):j=e[18];const k=j,C=PI[u];let N;e[19]!==C?(N=q("absolute inset-y-1 left-0 w-0.5 rounded-full",C),e[19]=C,e[20]=N):N=e[20];let _;e[21]!==N?(_=r.jsx("span",{"aria-hidden":!0,className:N}),e[21]=N,e[22]=_):_=e[22];let P;e[23]!==t.state?(P=Cu(t.state),e[23]=t.state,e[24]=P):P=e[24];const A=`${h}: ${P}`;let T;e[25]!==t.state?(T=r.jsx(U2,{state:t.state}),e[25]=t.state,e[26]=T):T=e[26];const E=u==="fail"&&"text-destructive";let R;e[27]!==E?(R=q("min-w-0 flex-1 truncate text-xs font-medium",E),e[27]=E,e[28]=R):R=e[28];let $;e[29]!==R||e[30]!==h?($=r.jsx("span",{className:R,children:h}),e[29]=R,e[30]=h,e[31]=$):$=e[31];let I;e[32]!==t?(I=Eo(t)&&r.jsx(MI,{}),e[32]=t,e[33]=I):I=e[33];let M;e[34]!==t.createdAt||e[35]!==o?(M=B2(t.createdAt,o),e[34]=t.createdAt,e[35]=o,e[36]=M):M=e[36];let D;e[37]!==M?(D=r.jsx("span",{className:"w-7 shrink-0 text-right font-mono text-[10px] text-muted-foreground tabular-nums",children:M}),e[37]=M,e[38]=D):D=e[38];let O;e[39]!==T||e[40]!==$||e[41]!==I||e[42]!==D?(O=r.jsxs("span",{className:"flex w-full min-w-0 items-center gap-2",children:[T,$,I,D]}),e[39]=T,e[40]=$,e[41]=I,e[42]=D,e[43]=O):O=e[43];let L;e[44]!==t.branch?(L=t.branch&&r.jsx("span",{className:"min-w-0 truncate",children:t.branch}),e[44]=t.branch,e[45]=L):L=e[45];let F;e[46]!==t.commitSha?(F=t.commitSha&&r.jsx("span",{className:"shrink-0",children:t.commitSha.slice(0,7)}),e[46]=t.commitSha,e[47]=F):F=e[47];let z;e[48]!==t.branch||e[49]!==t.commitSha?(z=!t.branch&&!t.commitSha&&r.jsx("span",{className:"min-w-0 truncate",children:"deployed from CLI"}),e[48]=t.branch,e[49]=t.commitSha,e[50]=z):z=e[50];let W;e[51]===Symbol.for("react.memo_cache_sentinel")?(W=r.jsx("span",{className:"min-w-0 flex-1"}),e[51]=W):W=e[51];let U;e[52]!==m||e[53]!==u?(U=m&&r.jsx("span",{className:q("shrink-0 tabular-nums",u==="live"&&"text-info"),children:m}),e[52]=m,e[53]=u,e[54]=U):U=e[54];let H;e[55]!==L||e[56]!==F||e[57]!==z||e[58]!==U?(H=r.jsxs("span",{className:"flex w-full min-w-0 items-center gap-2 pl-[22px] font-mono text-[10px] leading-4 text-muted-foreground",children:[L,F,z,W,U]}),e[55]=L,e[56]=F,e[57]=z,e[58]=U,e[59]=H):H=e[59];let K;e[60]!==x?(K=x&&r.jsx("span",{className:"w-full min-w-0 truncate pl-[22px] text-[11px] leading-4 text-destructive",title:x,children:x}),e[60]=x,e[61]=K):K=e[61];let V;e[62]!==i||e[63]!==A||e[64]!==O||e[65]!==H||e[66]!==K?(V=r.jsxs(Mt,{className:"flex min-w-0 flex-1 flex-col gap-0.5 rounded-sm px-1 py-1 text-left outline-none hover:bg-accent/60 focus-visible:ring-[3px] focus-visible:ring-ring/20","aria-label":A,"aria-expanded":i,children:[O,H,K]}),e[62]=i,e[63]=A,e[64]=O,e[65]=H,e[66]=K,e[67]=V):V=e[67];let Y;e[68]!==t.url||e[69]!==h?(Y=t.url&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",className:"mt-0.5 size-6 text-muted-foreground opacity-0 transition-opacity group-hover/deployment:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100","aria-label":`Open ${h}`,onClick:()=>window.open(t.url??"","_blank","noopener,noreferrer"),children:r.jsx(zn,{})}),e[68]=t.url,e[69]=h,e[70]=Y):Y=e[70];let G;e[71]!==V||e[72]!==Y?(G=r.jsxs("div",{className:"flex items-start gap-1",children:[V,Y]}),e[71]=V,e[72]=Y,e[73]=G):G=e[73];let J;e[74]!==t.url||e[75]!==w?(J=t.url&&w&&r.jsx(th,{href:t.url,children:w}),e[74]=t.url,e[75]=w,e[76]=J):J=e[76];let Q;e[77]!==t.inspectorUrl?(Q=t.inspectorUrl&&r.jsx(th,{href:t.inspectorUrl,children:"Inspect on Vercel"}),e[77]=t.inspectorUrl,e[78]=Q):Q=e[78];let X;e[79]!==t.creator?(X=t.creator&&r.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["by ",t.creator]}),e[79]=t.creator,e[80]=X):X=e[80];let Z;e[81]!==J||e[82]!==Q||e[83]!==X?(Z=r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1",children:[J,Q,X]}),e[81]=J,e[82]=Q,e[83]=X,e[84]=Z):Z=e[84];let te;e[85]!==l.data||e[86]!==l.loading?(te=l.loading&&!l.data&&r.jsxs("div",{className:"flex items-center gap-2 py-1 text-[11px] text-muted-foreground",role:"status",children:[r.jsx(xt,{className:"size-3"}),"Loading build output"]}),e[85]=l.data,e[86]=l.loading,e[87]=te):te=e[87];let ne;e[88]!==l.error?(ne=l.error&&r.jsx("p",{className:"text-[11px] text-destructive",children:l.error.error}),e[88]=l.error,e[89]=ne):ne=e[89];let re;e[90]!==l.data?(re=l.data&&r.jsx(FI,{logs:l.data}),e[90]=l.data,e[91]=re):re=e[91];let ie;e[92]!==Z||e[93]!==te||e[94]!==ne||e[95]!==re?(ie=r.jsx(dt,{children:r.jsxs("div",{className:"ml-[7px] flex flex-col gap-2 border-l border-border py-2 pl-4 pr-1",children:[Z,te,ne,re]})}),e[92]=Z,e[93]=te,e[94]=ne,e[95]=re,e[96]=ie):ie=e[96];let ae;e[97]!==_||e[98]!==G||e[99]!==ie||e[100]!==h?(ae=r.jsxs("article",{className:"group/deployment relative pl-3","aria-label":h,children:[_,G,ie]}),e[97]=_,e[98]=G,e[99]=ie,e[100]=h,e[101]=ae):ae=e[101];let se;return e[102]!==k||e[103]!==i||e[104]!==ae?(se=r.jsx(ct,{open:i,onOpenChange:k,children:ae}),e[102]=k,e[103]=i,e[104]=ae,e[105]=se):se=e[105],se}function WI(n){return{...n,error:null,loading:!0}}function HI(n){const e=n.filter(Eo),t=e.find(i=>i.state==="READY")??null,s=e[0]??null,o=s&&s!==t&&s.state!=="READY"?s:null;return{live:t,pending:o}}function KI(n){const e=B.c(11),{deployments:t,now:s}=n;let o,i;if(e[0]!==t||e[1]!==s){i=Symbol.for("react.early_return_sentinel");e:{const{live:a,pending:l}=HI(t),c=a??l;if(!c){i=null;break e}const d=Ic(c),u=_u(c.url),f=l?F2(l.state):null,m=a?"border-success/30 bg-success/[0.05]":"border-destructive/30 bg-destructive/[0.05]";let p;e[4]!==m?(p=q("mx-3 mt-3 rounded-md border px-3 py-2.5",m),e[4]=m,e[5]=p):p=e[5];const h=a?"bg-success":"bg-destructive";let g;e[6]!==h?(g=q("size-1.5 rounded-full",h),e[6]=h,e[7]=g):g=e[7];let x;e[8]!==g?(x=r.jsx("span",{"aria-hidden":!0,className:g}),e[8]=g,e[9]=x):x=e[9];let b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx("span",{className:"min-w-0 flex-1"}),e[10]=b):b=e[10],o=r.jsxs("section",{"aria-label":"Production",className:p,children:[r.jsxs("p",{className:"mb-1 flex items-center gap-1.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:[x,a?"Live on production":"Production is down",r.jsx("span",{className:"ml-auto font-mono normal-case tracking-normal tabular-nums",children:B2(c.readyAt??c.createdAt,s)})]}),r.jsx("h3",{className:"truncate text-[13px] font-medium leading-5",title:d,children:d}),r.jsxs("p",{className:"mt-0.5 flex min-w-0 items-center gap-2 font-mono text-[10px] text-muted-foreground",children:[c.branch&&r.jsx("span",{className:"truncate",children:c.branch}),c.commitSha&&r.jsx("span",{className:"shrink-0",children:c.commitSha.slice(0,7)}),b,c.url&&u&&r.jsxs("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex min-w-0 max-w-[60%] items-center gap-0.5 font-sans text-[11px] text-foreground/80 outline-none hover:text-foreground focus-visible:underline",children:[r.jsx("span",{className:"truncate",children:u}),r.jsx(zn,{className:"size-3 shrink-0"})]})]}),a&&l&&f&&r.jsxs("p",{className:q("mt-1.5 flex items-center gap-1.5 border-t border-border/60 pt-1.5 text-[11px]",f==="fail"?"text-destructive":"text-info"),children:[r.jsx(U2,{state:l.state,className:"size-3"}),r.jsxs("span",{className:"min-w-0 truncate",children:[f==="fail"?"Newer production deploy failed":"Newer production deploy in progress"," · ",Ic(l)]})]})]})}e[0]=t,e[1]=s,e[2]=o,e[3]=i}else o=e[2],i=e[3];return i!==Symbol.for("react.early_return_sentinel")?i:o}function qI(n,e){return e==="failed"?n.filter(t=>Ga(t.state)):e==="production"?n.filter(Eo):e==="preview"?n.filter(t=>!Eo(t)):[...n]}function VI(n){const e=B.c(17),{data:t,filter:s,projectPath:o}=n;let i;e[0]!==t.deployments||e[1]!==s?(i=qI(t.deployments,s),e[0]=t.deployments,e[1]=s,e[2]=i):i=e[2];const a=i;let l;e[3]!==t.deployments?(l=t.deployments.some(GI),e[3]=t.deployments,e[4]=l):l=e[4];const c=RI(l);if(t.deployments.length===0){let m;return e[5]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(ln,{className:"border-0",children:r.jsxs(cn,{children:[r.jsx(bn,{variant:"icon",children:r.jsx(ag,{})}),r.jsx(dn,{children:"No deployments yet"}),r.jsx(vn,{children:"New Vercel deployments for this linked project will show up here."})]})}),e[5]=m):m=e[5],m}let d;e[6]!==t.deployments||e[7]!==c?(d=r.jsx(KI,{deployments:t.deployments,now:c}),e[6]=t.deployments,e[7]=c,e[8]=d):d=e[8];let u;e[9]!==a||e[10]!==s||e[11]!==c||e[12]!==o?(u=a.length===0?r.jsxs("p",{className:"px-4 py-6 text-center text-xs text-muted-foreground",children:["No recent ",s," deployments."]}):r.jsx("div",{className:"flex flex-col gap-3 px-3 py-3",children:a.map(m=>r.jsx(UI,{deployment:m,projectPath:o,now:c},m.id))}),e[9]=a,e[10]=s,e[11]=c,e[12]=o,e[13]=u):u=e[13];let f;return e[14]!==d||e[15]!==u?(f=r.jsxs(is,{className:"min-h-0 flex-1",children:[d,u]}),e[14]=d,e[15]=u,e[16]=f):f=e[16],f}function GI(n){return Xr(n.state)}function YI(n){const e=B.c(6),{context:t}=n,{data:s}=z2(t.projectPath,t.projectPath!==null);let o;e[0]!==(s==null?void 0:s.deployments)?(o=(s==null?void 0:s.deployments.filter(XI).length)??0,e[0]=s==null?void 0:s.deployments,e[1]=o):o=e[1];const i=o,a=s!=null&&s.deployments[0]?Ga(s.deployments[0].state):!1;if(i>0){const l=`${i} active Vercel deployment${i===1?"":"s"}`;let c;return e[2]!==i||e[3]!==l?(c=r.jsx(_e,{className:"absolute -right-1 -top-1 min-w-4 px-1 text-[9px]","aria-label":l,children:i}),e[2]=i,e[3]=l,e[4]=c):c=e[4],c}if(a){let l;return e[5]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(_e,{variant:"destructive",className:"absolute -right-0.5 -top-0.5 size-3 p-0 text-[8px]","aria-label":"Latest Vercel deployment failed",children:"!"}),e[5]=l):l=e[5],l}return null}function XI(n){return Xr(n.state)}function JI(n){const e=B.c(57),{context:t,active:s,closePanel:o}=n,{data:i,error:a,loading:l,refreshing:c,refresh:d}=z2(t.projectPath,s),[u,f]=y.useState("all"),m=t.projectPath;let p;e[0]!==(i==null?void 0:i.deployments)?(p=(i==null?void 0:i.deployments)??[],e[0]=i==null?void 0:i.deployments,e[1]=p):p=e[1];const h=p,g=h.length;let x;e[2]!==h?(x=h.filter(Eo),e[2]=h,e[3]=x):x=e[3];const b=x.length;let w;e[4]!==h?(w=h.filter(ZI),e[4]=h,e[5]=w):w=e[5];const v=w.length;let S;e[6]!==h?(S=h.filter(QI),e[6]=h,e[7]=S):S=e[7];let j;e[8]!==h.length||e[9]!==x.length||e[10]!==w.length||e[11]!==S.length?(j={all:g,production:b,preview:v,failed:S.length},e[8]=h.length,e[9]=x.length,e[10]=w.length,e[11]=S.length,e[12]=j):j=e[12];const k=j,C=u!=="all"&&k[u]===0?"all":u;let N;e[13]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx("h2",{className:"text-sm font-medium leading-tight",children:"Vercel Deployments"}),e[13]=N):N=e[13];let _;e[14]!==i?(_=r.jsxs("div",{className:"min-w-0 flex-1",children:[N,i!=null&&i.projectUrl?r.jsxs("a",{href:i.projectUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex max-w-full items-center gap-0.5 truncate text-[11px] text-muted-foreground outline-none hover:text-foreground focus-visible:underline",children:[r.jsx("span",{className:"truncate",children:i.projectName}),r.jsx(zn,{className:"size-3 shrink-0"})]}):r.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:"Project linked at the session root"})]}),e[14]=i,e[15]=_):_=e[15];let P;e[16]!==d?(P=()=>{d()},e[16]=d,e[17]=P):P=e[17];const A=l||c||!m;let T;e[18]!==c?(T=c?r.jsx(xt,{}):r.jsx(Ot,{}),e[18]=c,e[19]=T):T=e[19];let E;e[20]!==P||e[21]!==A||e[22]!==T?(E=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:P,disabled:A,"aria-label":"Refresh Vercel deployments",children:T}),e[20]=P,e[21]=A,e[22]=T,e[23]=E):E=e[23];let R;e[24]===Symbol.for("react.memo_cache_sentinel")?(R=r.jsx(rt,{}),e[24]=R):R=e[24];let $;e[25]!==o?($=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:o,"aria-label":"Close Vercel deployments",children:R}),e[25]=o,e[26]=$):$=e[26];let I;e[27]!==_||e[28]!==E||e[29]!==$?(I=r.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b pl-4 pr-2",children:[_,E,$]}),e[27]=_,e[28]=E,e[29]=$,e[30]=I):I=e[30];let M;e[31]!==k||e[32]!==i||e[33]!==C?(M=i&&i.deployments.length>0&&r.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b px-3 py-1.5",role:"group","aria-label":"Filter deployments",children:[r.jsxs(Ut,{pressed:C==="all",onClick:()=>f("all"),children:["All ",r.jsx(Wt,{children:k.all})]}),r.jsxs(Ut,{pressed:C==="production",disabled:k.production===0,onClick:()=>f("production"),children:["Production ",r.jsx(Wt,{children:k.production})]}),r.jsxs(Ut,{pressed:C==="preview",disabled:k.preview===0,onClick:()=>f("preview"),children:["Preview ",r.jsx(Wt,{children:k.preview})]}),r.jsxs(Ut,{pressed:C==="failed",disabled:k.failed===0,onClick:()=>f("failed"),children:[r.jsx("span",{className:q(k.failed>0&&"text-destructive"),children:"Failed"})," ",r.jsx(Wt,{children:k.failed})]})]}),e[31]=k,e[32]=i,e[33]=C,e[34]=M):M=e[34];let D;e[35]!==i||e[36]!==l?(D=l&&!i&&r.jsx(DI,{}),e[35]=i,e[36]=l,e[37]=D):D=e[37];let O;e[38]!==i||e[39]!==a||e[40]!==d?(O=a&&!i&&r.jsx("div",{className:"p-3",children:r.jsxs(ht,{variant:"destructive",children:[r.jsx(tn,{}),r.jsx(Tt,{children:a.error}),r.jsxs(gt,{className:"flex flex-col items-start gap-2",children:[r.jsx("span",{children:OI(a)}),r.jsxs(ee,{type:"button",variant:"outline",size:"xs",onClick:()=>{d()},children:[r.jsx(Ot,{"data-icon":"inline-start"}),"Try again"]})]})]})}),e[38]=i,e[39]=a,e[40]=d,e[41]=O):O=e[41];let L;e[42]!==i||e[43]!==C||e[44]!==m?(L=i&&m&&r.jsx(VI,{data:i,filter:C,projectPath:m}),e[42]=i,e[43]=C,e[44]=m,e[45]=L):L=e[45];let F;e[46]!==i||e[47]!==a||e[48]!==l?(F=!l&&!i&&!a&&r.jsx(ln,{className:"border-0",children:r.jsxs(cn,{children:[r.jsx(bn,{variant:"icon",children:r.jsx(Gs,{})}),r.jsx(dn,{children:"Select a project session"})]})}),e[46]=i,e[47]=a,e[48]=l,e[49]=F):F=e[49];let z;return e[50]!==I||e[51]!==M||e[52]!==D||e[53]!==O||e[54]!==L||e[55]!==F?(z=r.jsxs("section",{className:"flex size-full min-h-0 flex-col","aria-label":"Vercel deployments panel",children:[I,M,D,O,L,F]}),e[50]=I,e[51]=M,e[52]=D,e[53]=O,e[54]=L,e[55]=F,e[56]=z):z=e[56],z}function QI(n){return Ga(n.state)}function ZI(n){return!Eo(n)}const e$={id:"vercel-deployments",workspacePanels:[{id:"deployments",title:"Vercel Deployments",icon:ag,component:JI,indicator:YI,order:45,defaultSize:"42%",minSize:"380px",maxSize:"68%",when:n=>n.canAccessHostFiles&&n.projectPath!==null}]},t$=[jI,e$];function n$(n,e,t){const s=B.c(16);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o={summary:null,loading:!1,error:null},s[0]=o):o=s[0];const[i,a]=y.useState(o),[l,c]=y.useState(0);let d,u;s[1]!==n||s[2]!==e?(d=()=>{a({summary:null,loading:!!(n&&e),error:null})},u=[n,e],s[1]=n,s[2]=e,s[3]=d,s[4]=u):(d=s[3],u=s[4]),y.useEffect(d,u);let f;s[5]!==n||s[6]!==e?(f=()=>{if(!n||!e)return;const x=new AbortController;a(o$);const b=new URLSearchParams({dirName:n,fileName:e});return ve(`/api/usage-cost/session?${b}`,{signal:x.signal}).then(async w=>{if(!w.ok)throw new Error(`Cost scan failed (${w.status})`);const v=await w.json();a({summary:v,loading:!1,error:null})}).catch(w=>{x.signal.aborted||a(v=>({...v,loading:!1,error:w instanceof Error?w.message:"Cost scan failed"}))}),()=>x.abort()},s[5]=n,s[6]=e,s[7]=f):f=s[7];let m;s[8]!==n||s[9]!==e||s[10]!==l||s[11]!==t?(m=[n,e,l,t],s[8]=n,s[9]=e,s[10]=l,s[11]=t,s[12]=m):m=s[12],y.useEffect(f,m);let p;s[13]===Symbol.for("react.memo_cache_sentinel")?(p=()=>c(s$),s[13]=p):p=s[13];const h=p;let g;return s[14]!==i?(g={...i,refresh:h},s[14]=i,s[15]=g):g=s[15],g}function s$(n){return n+1}function o$(n){return{...n,loading:!0,error:null}}function r$(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 i$(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 a$(){const n=B.c(3);let e,t;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx(ft,{className:"h-4 w-24"}),r.jsx(ft,{className:"h-10 w-32"}),r.jsx(ft,{className:"h-3 w-44"})]}),t=r.jsx(ft,{className:"h-20 w-full"}),n[0]=e,n[1]=t):(e=n[0],t=n[1]);let s;return n[2]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsxs("div",{className:"flex flex-col gap-5 pt-2",role:"status","aria-label":"Reading session cost",children:[e,t,r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx(ft,{className:"h-8 w-full"}),r.jsx(ft,{className:"h-8 w-full"}),r.jsx(ft,{className:"h-8 w-full"})]})]}),n[2]=s):s=n[2],s}function l$(n){const e=B.c(10),{message:t,retry:s}=n;let o,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(Uc,{}),i=r.jsx(Tt,{children:"Cost unavailable"}),e[0]=o,e[1]=i):(o=e[0],i=e[1]);let a;e[2]!==t?(a=r.jsx(gt,{children:t}),e[2]=t,e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Ot,{"data-icon":"inline-start"}),e[4]=l):l=e[4];let c;e[5]!==s?(c=r.jsxs(ee,{variant:"outline",size:"xs",onClick:s,className:"mt-2",children:[l,"Retry"]}),e[5]=s,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=r.jsxs(ht,{variant:"destructive",className:"mt-2",children:[o,i,a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d}function Ni(n){const e=B.c(7),{label:t,value:s}=n;let o;e[0]!==t?(o=r.jsx("dt",{className:"text-xs text-muted-foreground",children:t}),e[0]=t,e[1]=o):o=e[1];let i;e[2]!==s?(i=r.jsx("dd",{className:"truncate text-sm font-medium text-foreground tabular-nums",children:s}),e[2]=s,e[3]=i):i=e[3];let a;return e[4]!==o||e[5]!==i?(a=r.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[o,i]}),e[4]=o,e[5]=i,e[6]=a):a=e[6],a}function c$(n){const e=B.c(22),{row:t,totalCost:s}=n,o=s>0?t.costUsd/s*100:0;let i;e[0]!==t.label?(i=r.jsx(o1,{children:t.label}),e[0]=t.label,e[1]=i):i=e[1];let a;e[2]!==t.costUsd?(a=r.jsx(r1,{children:()=>mn(t.costUsd)}),e[2]=t.costUsd,e[3]=a):a=e[3];let l;e[4]!==o||e[5]!==i||e[6]!==a?(l=r.jsxs(Lr,{value:o,children:[i,a]}),e[4]=o,e[5]=i,e[6]=a,e[7]=l):l=e[7];let c;e[8]!==t.tokens?(c=t.tokens>0?ut(t.tokens):"Reported by provider",e[8]=t.tokens,e[9]=c):c=e[9];let d;e[10]!==c?(d=r.jsx("span",{children:c}),e[10]=c,e[11]=d):d=e[11];let u;e[12]!==o?(u=o>0?`${o.toFixed(1)}%`:"—",e[12]=o,e[13]=u):u=e[13];let f;e[14]!==u?(f=r.jsx("span",{children:u}),e[14]=u,e[15]=f):f=e[15];let m;e[16]!==d||e[17]!==f?(m=r.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs text-muted-foreground tabular-nums",children:[d,f]}),e[16]=d,e[17]=f,e[18]=m):m=e[18];let p;return e[19]!==l||e[20]!==m?(p=r.jsxs("div",{className:"flex flex-col gap-1.5",children:[l,m]}),e[19]=l,e[20]=m,e[21]=p):p=e[21],p}function d$(n){const e=B.c(8),{summary:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx("h3",{id:"cost-models-heading",className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"By model"}),e[0]=s):s=e[0];let o;if(e[1]!==t.costUsd||e[2]!==t.models){let a;e[4]!==t.costUsd?(a=l=>{const c=t.costUsd>0?l.costUsd/t.costUsd*100:0;return r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsxs(Lr,{value:c,children:[r.jsx(o1,{title:l.model,children:Js(l.model)}),r.jsx(r1,{children:()=>l.costSource==="unpriced"?"Unpriced":mn(l.costUsd)})]}),r.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs text-muted-foreground tabular-nums",children:[r.jsxs("span",{children:[l.records," ",l.records===1?"call":"calls"]}),r.jsxs("span",{children:[ut(mu(l.totals))," tokens"]})]})]},l.model)},e[4]=t.costUsd,e[5]=a):a=e[5],o=t.models.map(a),e[1]=t.costUsd,e[2]=t.models,e[3]=o}else o=e[3];let i;return e[6]!==o?(i=r.jsxs("section",{"aria-labelledby":"cost-models-heading",className:"flex flex-col gap-3",children:[s,r.jsx("div",{className:"flex flex-col gap-3",children:o})]}),e[6]=o,e[7]=i):i=e[7],i}function u$(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 f$(n){const e=B.c(5),{rows:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx("h3",{id:"cost-calls-heading",className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Most expensive calls"}),e[0]=s):s=e[0];let o;e[1]!==t?(o=t.map(m$),e[1]=t,e[2]=o):o=e[2];let i;return e[3]!==o?(i=r.jsxs("section",{"aria-labelledby":"cost-calls-heading",className:"flex flex-col gap-2",children:[s,r.jsx("ol",{className:"flex flex-col gap-0.5",children:o})]}),e[3]=o,e[4]=i):i=e[4],i}function m$(n){return r.jsxs("li",{className:"flex items-center gap-2 rounded-md px-2 py-1.5 hover:bg-muted/50",children:[r.jsxs("span",{className:"min-w-0 flex-1 truncate text-xs text-foreground",children:["Call ",n.call," · ",Js(n.model)]}),n.isSubagent&&r.jsx(_e,{variant:"outline",children:"Agent"}),r.jsx("span",{className:"shrink-0 font-mono text-xs text-foreground tabular-nums",children:mn(n.costUsd)})]},`${n.timestamp}:${n.call}`)}function p$(n){const e=B.c(74),{summary:t}=n;let s;e[0]!==t.provider?(s=lj(t.provider),e[0]=t.provider,e[1]=s):s=e[1];const o=s;let i,a,l,c,d,u;if(e[2]!==o||e[3]!==t){const g=mu(t.totals),x=i$(t);let b;e[10]!==t.calls?(b=u$(t.calls),e[10]=t.calls,e[11]=b):b=e[11],u=b;const w=t.providerReportedRecords+t.modelPricedRecords>0;i="flex flex-col gap-5 pt-2";let v;e[12]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx("p",{id:"session-cost-heading",className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"API equivalent"}),e[12]=v):v=e[12];let S;e[13]!==o?(S=r.jsx(o,{"aria-hidden":"true"}),e[13]=o,e[14]=S):S=e[14];let j;e[15]!==t.provider?(j=nn(t.provider),e[15]=t.provider,e[16]=j):j=e[16];let k;e[17]!==j.displayName||e[18]!==S?(k=r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[v,r.jsxs(_e,{variant:"outline",children:[S,j.displayName]})]}),e[17]=j.displayName,e[18]=S,e[19]=k):k=e[19];let C;e[20]!==w||e[21]!==t.costUsd?(C=w?mn(t.costUsd):"—",e[20]=w,e[21]=t.costUsd,e[22]=C):C=e[22];let N;e[23]!==C?(N=r.jsx("span",{className:"text-4xl font-semibold tracking-tight text-foreground tabular-nums",children:C}),e[23]=C,e[24]=N):N=e[24];const _=t.unpricedRecords>0?"secondary":"outline";let P;e[25]!==t?(P=r$(t),e[25]=t,e[26]=P):P=e[26];let A;e[27]!==_||e[28]!==P?(A=r.jsx(_e,{variant:_,children:P}),e[27]=_,e[28]=P,e[29]=A):A=e[29];let T;e[30]!==N||e[31]!==A?(T=r.jsxs("div",{className:"flex items-end justify-between gap-3",children:[N,A]}),e[30]=N,e[31]=A,e[32]=T):T=e[32];const E=t.records===1?"model call":"model calls",R=t.includedSubagents>0?` · ${t.includedSubagents} agent ${t.includedSubagents===1?"transcript":"transcripts"}`:"";let $;e[33]!==t.records||e[34]!==E||e[35]!==R?($=r.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.records," ",E,R]}),e[33]=t.records,e[34]=E,e[35]=R,e[36]=$):$=e[36],e[37]!==k||e[38]!==T||e[39]!==$?(a=r.jsxs("section",{"aria-labelledby":"session-cost-heading",className:"flex flex-col gap-2",children:[k,T,$]}),e[37]=k,e[38]=T,e[39]=$,e[40]=a):a=e[40],e[41]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(St,{}),e[41]=l):l=e[41];const I=ut(g);let M;e[42]!==I?(M=r.jsx(Ni,{label:"Processed tokens",value:I}),e[42]=I,e[43]=M):M=e[43];let D;e[44]!==t.cacheSavingsUsd?(D=mn(t.cacheSavingsUsd),e[44]=t.cacheSavingsUsd,e[45]=D):D=e[45];let O;e[46]!==D?(O=r.jsx(Ni,{label:"Cache savings",value:D}),e[46]=D,e[47]=O):O=e[47];let L;e[48]!==t.totals.cachedInputTokens?(L=ut(t.totals.cachedInputTokens),e[48]=t.totals.cachedInputTokens,e[49]=L):L=e[49];let F;e[50]!==L?(F=r.jsx(Ni,{label:"Cached input",value:L}),e[50]=L,e[51]=F):F=e[51];let z;e[52]!==t.totals.reasoningTokens?(z=ut(t.totals.reasoningTokens),e[52]=t.totals.reasoningTokens,e[53]=z):z=e[53];let W;e[54]!==z?(W=r.jsx(Ni,{label:"Reasoning",value:z}),e[54]=z,e[55]=W):W=e[55],e[56]!==M||e[57]!==O||e[58]!==F||e[59]!==W?(c=r.jsxs("dl",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:[M,O,F,W]}),e[56]=M,e[57]=O,e[58]=F,e[59]=W,e[60]=c):c=e[60],d=x.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(St,{}),r.jsxs("section",{"aria-labelledby":"cost-breakdown-heading",className:"flex flex-col gap-3",children:[r.jsx("h3",{id:"cost-breakdown-heading",className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Cost by token type"}),r.jsx("div",{className:"flex flex-col gap-4",children:x.map(U=>r.jsx(c$,{row:U,totalCost:t.costUsd},U.label))})]})]}),e[2]=o,e[3]=t,e[4]=i,e[5]=a,e[6]=l,e[7]=c,e[8]=d,e[9]=u}else i=e[4],a=e[5],l=e[6],c=e[7],d=e[8],u=e[9];let f;e[61]!==t?(f=t.models.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(St,{}),r.jsx(d$,{summary:t})]}),e[61]=t,e[62]=f):f=e[62];let m;e[63]!==u?(m=u.length>=2&&r.jsxs(r.Fragment,{children:[r.jsx(St,{}),r.jsx(f$,{rows:u})]}),e[63]=u,e[64]=m):m=e[64];let p;e[65]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsxs(ht,{children:[r.jsx(Uc,{}),r.jsx(Tt,{children:"How this is calculated"}),r.jsx(gt,{children:"Token counts come from the provider transcript. Costs use provider totals when present, then current LiteLLM API rates, the same pricing source as ccusage. This is not a subscription bill."})]}),e[65]=p):p=e[65];let h;return e[66]!==i||e[67]!==a||e[68]!==l||e[69]!==c||e[70]!==d||e[71]!==f||e[72]!==m?(h=r.jsxs("div",{className:i,children:[a,l,c,d,f,m,p]}),e[66]=i,e[67]=a,e[68]=l,e[69]=c,e[70]=d,e[71]=f,e[72]=m,e[73]=h):h=e[73],h}function h$(n){const e=B.c(7),{dirName:t,fileName:s,revision:o}=n,{summary:i,loading:a,error:l,refresh:c}=n$(t,s,o);if(l){let u;return e[0]!==l||e[1]!==c?(u=r.jsx(l$,{message:l,retry:c}),e[0]=l,e[1]=c,e[2]=u):u=e[2],u}if(!i){if(a){let f;return e[3]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(a$,{}),e[3]=f):f=e[3],f}let u;return e[4]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(ln,{className:"mt-2 min-h-52",children:r.jsxs(cn,{children:[r.jsx(bn,{variant:"icon",children:r.jsx(N3,{})}),r.jsx(dn,{children:"No transcript cost yet"}),r.jsx(vn,{children:"Cost appears after the first model response is written."})]})}),e[4]=u):u=e[4],u}let d;return e[5]!==i?(d=r.jsx(p$,{summary:i}),e[5]=i,e[6]=d):d=e[6],d}function g$(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 x$(n){const e=B.c(14),{turns:t,onJumpToTurn:s}=n;let o;e[0]!==t?(o=g$(t),e[0]=t,e[1]=o):o=e[1];const i=o;if(i.length===0)return null;let a;e[2]!==i.length?(a=r.jsxs(zr,{children:["Errors (",i.length,")"]}),e[2]=i.length,e[3]=a):a=e[3];let l;if(e[4]!==i||e[5]!==s){let u;e[7]!==s?(u=(f,m)=>r.jsxs(ee,{type:"button",variant:"ghost",onClick:()=>s==null?void 0:s(f.turnIndex),className:"h-auto w-full flex-col items-stretch rounded-none border-b border-border px-2 py-2.5 text-left whitespace-normal last:border-b-0 hover:bg-destructive/5",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[r.jsx("span",{className:"font-medium text-destructive",children:f.toolName}),r.jsxs("span",{className:"text-muted-foreground",children:["Turn ",f.turnIndex+1]})]}),r.jsx("div",{className:"mt-0.5 line-clamp-2 text-xs leading-relaxed text-muted-foreground",children:f.message})]},m),e[7]=s,e[8]=u):u=e[8],l=i.map(u),e[4]=i,e[5]=s,e[6]=l}else l=e[6];let c;e[9]!==l?(c=r.jsx("div",{className:"flex max-h-[300px] flex-col overflow-y-auto pr-1",children:l}),e[9]=l,e[10]=c):c=e[10];let d;return e[11]!==a||e[12]!==c?(d=r.jsxs("section",{children:[a,c]}),e[11]=a,e[12]=c,e[13]=d):d=e[13],d}function nh(n){const e=B.c(42),{agentId:t,subagentType:s,agentName:o,preview:i,isViewing:a,isBackground:l,status:c,durationMs:d,toolUseCount:u,disabled:f,onClick:m,onStop:p}=n;let h;e[0]!==t||e[1]!==o||e[2]!==s?(h=o||eu(t,s),e[0]=t,e[1]=o,e[2]=s,e[3]=h):h=e[3];const g=h;let x;e[4]!==d?(x=d==null?null:d<1e3?`${d}ms`:`${(d/1e3).toFixed(d>=1e4?0:1)}s`,e[4]=d,e[5]=x):x=e[5];const b=x;let w;e[6]!==c?(w=c==="running"?r.jsx(ot,{className:"size-3 shrink-0 animate-spin text-success","data-icon":"inline-start"}):c==="done"?r.jsx(Bn,{className:"size-3 shrink-0 text-success","data-icon":"inline-start"}):c==="failed"?r.jsx(Ys,{className:"size-3 shrink-0 text-destructive","data-icon":"inline-start"}):r.jsx(Qc,{className:"size-2.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),e[6]=c,e[7]=w):w=e[7];const v=w,S=a?"bg-accent":"hover:bg-muted/40";let j;e[8]!==S?(j=q("motion-list-item flex w-full items-start border-b border-border text-left transition-colors last:border-b-0",S),e[8]=S,e[9]=j):j=e[9];let k;e[10]!==g?(k=r.jsx(_e,{variant:"outline",children:g}),e[10]=g,e[11]=k):k=e[11];let C;e[12]!==l?(C=l&&r.jsx(_e,{variant:"outline",children:"Background"}),e[12]=l,e[13]=C):C=e[13];let N;e[14]!==a?(N=a&&r.jsx(_e,{children:"Viewing"}),e[14]=a,e[15]=N):N=e[15];const _=c==="running"?"active":c;let P;e[16]!==_?(P=r.jsx("span",{className:"ml-auto text-xs uppercase tracking-wide text-muted-foreground",children:_}),e[16]=_,e[17]=P):P=e[17];let A;e[18]!==v||e[19]!==P||e[20]!==k||e[21]!==C||e[22]!==N?(A=r.jsxs("div",{className:"flex items-center gap-1.5",children:[v,k,C,N,P]}),e[18]=v,e[19]=P,e[20]=k,e[21]=C,e[22]=N,e[23]=A):A=e[23];let T;e[24]!==i?(T=i&&r.jsx("p",{className:"mt-1 line-clamp-2 text-xs leading-relaxed text-muted-foreground",children:i}),e[24]=i,e[25]=T):T=e[25];let E;e[26]!==b||e[27]!==u?(E=(b||u!=null)&&r.jsxs("div",{className:"mt-1.5 flex items-center gap-2 text-xs text-muted-foreground",children:[b&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(Po,{className:"size-2.5","data-icon":"inline-start"}),b]}),u!=null&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(la,{className:"size-2.5","data-icon":"inline-start"}),u," tools"]})]}),e[26]=b,e[27]=u,e[28]=E):E=e[28];let R;e[29]!==f||e[30]!==m||e[31]!==A||e[32]!==T||e[33]!==E?(R=r.jsxs(ee,{type:"button",variant:"ghost",onClick:m,disabled:f,className:"h-auto min-w-0 flex-1 flex-col items-stretch rounded-none px-2.5 py-2 text-left whitespace-normal",children:[A,T,E]}),e[29]=f,e[30]=m,e[31]=A,e[32]=T,e[33]=E,e[34]=R):R=e[34];let $;e[35]!==g||e[36]!==p?($=p&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",className:"m-1",onClick:p,"aria-label":`Stop ${g}`,children:r.jsx(rt,{"data-icon":"inline-start"})}),e[35]=g,e[36]=p,e[37]=$):$=e[37];let I;return e[38]!==R||e[39]!==$||e[40]!==j?(I=r.jsxs("div",{className:j,children:[R,$]}),e[38]=R,e[39]=$,e[40]=j,e[41]=I):I=e[41],I}function b$(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 $c(n){return n.split(`
128
- `).map(e=>e.trim()).find(Boolean)??""}function v$(n){return n.name==="Task"||n.name==="Agent"}function y$(n,e){var i;const t=new Map;for(const a of n.turns)for(const l of a.contentBlocks)if(!(l.kind!=="sub_agent"&&l.kind!=="background_agent"))for(const c of l.messages){const d=t.get(c.agentId),u=b$(c.status);t.set(c.agentId,{agentId:c.agentId,agentName:c.agentName??(d==null?void 0:d.agentName)??null,subagentType:c.subagentType??(d==null?void 0:d.subagentType)??null,preview:$c(((i=c.prompt)==null?void 0:i.trim())||c.text.find(f=>f.trim())||"")||(d==null?void 0:d.preview)||"No task summary recorded",isBackground:c.isBackground||(d==null?void 0:d.isBackground)||!1,status:u==="seen"&&(d!=null&&d.status)?d.status:u,durationMs:c.durationMs??(d==null?void 0:d.durationMs),toolUseCount:c.toolUseCount??(d==null?void 0:d.toolUseCount),parentToolUseId:c.parentToolUseId??(d==null?void 0:d.parentToolUseId)})}const s=new Set;for(const a of t.values())a.parentToolUseId&&s.add(a.parentToolUseId);const o=new Set;for(const a of e)a.parentToolUseId&&o.add(a.parentToolUseId);for(const a of n.turns)for(const l of a.toolCalls){if(!v$(l)||!o.has(l.id)||s.has(l.id))continue;const c=l.input;t.set(`tool:${l.id}`,{agentId:`tool:${l.id}`,agentName:typeof c.name=="string"?c.name:null,subagentType:typeof c.subagent_type=="string"?c.subagent_type:null,preview:$c(typeof c.prompt=="string"?c.prompt:typeof c.description=="string"?c.description:"Agent task in progress"),isBackground:!1,status:"running",parentToolUseId:l.id})}return[...t.values()]}function w$({session:n,sessionSource:e,bgAgents:t,onLoadSession:s}){const o=Jd(),i=y.useMemo(()=>{if(!e)return null;const w=Ns(e.fileName);return w?{...w,dirName:e.dirName}:null},[e]),a=y.useMemo(()=>y$(n,o),[n,o]),l=y.useRef(a);y.useEffect(()=>{!i&&a.length>0&&(l.current=a)},[i,a]);const c=i&&a.length===0?l.current:a,d=y.useMemo(()=>{if(i)return i.parentSessionId;if(e!=null&&e.fileName){const w=e.fileName.match(/^([^/]+)\.jsonl$/);if(w)return w[1]}return null},[i,e]),u=y.useMemo(()=>d?t.filter(w=>w.parentSessionId===d):t,[t,d]),f=y.useMemo(()=>new Map(c.map(w=>[w.agentId,w])),[c]),m=y.useMemo(()=>{const w=new Set(u.map(v=>v.agentId));return c.filter(v=>!w.has(v.agentId))},[u,c]),p=y.useMemo(()=>[...u].sort((w,v)=>v.modifiedAt-w.modifiedAt),[u]),h=y.useMemo(()=>[...m].reverse(),[m]),g=u.length+m.length;if(g===0)return null;const x=w=>{ve(`/api/claude/tasks/${encodeURIComponent(n.sessionId)}/${encodeURIComponent(w)}`,{method:"DELETE"})},b=(i==null?void 0:i.agentId)??null;return r.jsxs("section",{children:[r.jsxs(zr,{children:["Agents (",g,")"]}),i&&s&&r.jsxs(ee,{type:"button",variant:"outline",size:"sm",onClick:()=>s(i.dirName,i.parentFileName),className:"mb-2 w-full justify-start",children:[r.jsx(Je,{"data-icon":"inline-start",className:"rotate-180"}),"Back to Main Agent"]}),r.jsxs("div",{className:"flex max-h-[280px] flex-col gap-1.5 overflow-y-auto pr-0.5",children:[p.map((w,v)=>{const S=$c(w.preview??""),j=f.get(w.agentId);return r.jsx(nh,{agentId:w.agentId,subagentType:(j==null?void 0:j.subagentType)??null,agentName:(j==null?void 0:j.agentName)??null,preview:(j==null?void 0:j.preview)||(S!==w.agentId?S:""),colorIndex:v,isViewing:b===w.agentId,isBackground:!0,status:w.isActive?"running":(j==null?void 0:j.status)==="failed"?"failed":"done",durationMs:j==null?void 0:j.durationMs,toolUseCount:j==null?void 0:j.toolUseCount,disabled:!s,onStop:w.isActive?()=>x(w.agentId):void 0,onClick:()=>s==null?void 0:s(w.dirName,w.fileName)},w.agentId)}),h.map((w,v)=>{const S=!!s&&!!d&&!!e&&!w.agentId.startsWith("tool:");return r.jsx(nh,{agentId:w.agentId,subagentType:w.subagentType,agentName:w.agentName,preview:w.preview,colorIndex:p.length+v,isViewing:b===w.agentId,isBackground:w.isBackground,status:w.status,durationMs:w.durationMs,toolUseCount:w.toolUseCount,disabled:!S,onClick:()=>{S&&s(e.dirName,`${d}/subagents/agent-${w.agentId}.jsonl`)}},w.agentId)})]})]})}function j$(n,e){return`${n.id}-${e}`}function S$(n){const e=B.c(14),{turns:t,onJumpToTurn:s}=n,[o,i]=y.useState(null);if(t.length===0)return null;let a;e[0]!==t.length?(a=r.jsxs(zr,{children:["Turns (",t.length,")"]}),e[0]=t.length,e[1]=a):a=e[1];let l;if(e[2]!==o||e[3]!==s||e[4]!==t){let u;e[6]!==o||e[7]!==s?(u=(f,m)=>{const p=Oa(f.userMessage),h=o===m;return r.jsxs(ee,{type:"button",variant:"ghost",onClick:()=>{i(m),s==null||s(m)},className:q("group h-auto w-full justify-start gap-2 px-2 py-1.5 text-left font-normal",h?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:[r.jsx("span",{className:"mt-0.5 shrink-0 font-mono text-xs text-muted-foreground",children:String(m+1).padStart(2,"0")}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs",children:p?kn(p,50):"(no message)"}),r.jsx("span",{className:"flex shrink-0 items-center gap-1",children:f.toolCalls.length>0&&r.jsx(_e,{variant:"secondary",className:"font-normal",children:f.toolCalls.length})})]},j$(f,m))},e[6]=o,e[7]=s,e[8]=u):u=e[8],l=t.map(u),e[2]=o,e[3]=s,e[4]=t,e[5]=l}else l=e[5];let c;e[9]!==l?(c=r.jsx("div",{className:"max-h-[400px] overflow-y-auto",children:r.jsx("div",{className:"flex flex-col gap-0.5 pr-2",children:l})}),e[9]=l,e[10]=c):c=e[10];let d;return e[11]!==a||e[12]!==c?(d=r.jsxs("section",{children:[a,c]}),e[11]=a,e[12]=c,e[13]=d):d=e[13],d}const Mc=new Map;let Gl=null,Yl=null;async function N$(){try{const n=await ve("/api/usage-cost/rates");if(!n.ok)return Mc;const e=await n.json();return new Map(Object.entries(e.rates??{}))}catch{return Mc}}function k$(){const[n,e]=y.useState(Gl??Mc);return y.useEffect(()=>{if(Gl!==null)return;let t=!0;return Yl??(Yl=N$().then(s=>(s.size>0&&(Gl=s),Yl=null,s))),Yl.then(s=>{t&&e(s)}),()=>{t=!1}},[]),n}function C$(n){const e=n.input;return e.file_path&&typeof e.file_path=="string"?e.file_path.split("/").slice(-2).join("/"):e.command&&typeof e.command=="string"?kn(e.command,40):e.pattern&&typeof e.pattern=="string"?e.pattern:e.query&&typeof e.query=="string"?kn(e.query,40):e.url&&typeof e.url=="string"?kn(e.url,40):kn(K7(n),40)}function _$(n,e){return n.map(t=>{const s=t.tokenUsage;return!s||t.toolCalls.length===0?0:EA(e,t.model,s)/t.toolCalls.length})}function T$(n,e){const t=new Map;for(let s=0;s<n.length;s++)for(const o of n[s].toolCalls){const i=La(o);t.has(i.label)||t.set(i.label,{calls:[],count:0,estimatedCost:0,styleName:i.styleName});const a=t.get(i.label);a.calls.push({tc:o,turnIndex:s}),a.count++,a.estimatedCost+=e[s]}return Array.from(t.entries()).sort((s,o)=>o[1].count-s[1].count)}function E$(n){const e=B.c(14),{turns:t,onJumpToTurn:s}=n,o=k$();let i;e[0]!==o||e[1]!==t?(i=_$(t,o),e[0]=o,e[1]=t,e[2]=i):i=e[2];const a=i;let l;e[3]!==a||e[4]!==t?(l=T$(t,a),e[3]=a,e[4]=t,e[5]=l):l=e[5];const c=l;if(c.length===0)return null;let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(zr,{children:"Tool Calls"}),e[6]=d):d=e[6];let u;if(e[7]!==s||e[8]!==c){let m;e[10]!==s?(m=p=>{const[h,g]=p;return r.jsxs(ct,{children:[r.jsxs(Mt,{className:"group flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-xs transition-colors hover:bg-muted",children:[r.jsx(Je,{className:"size-3 shrink-0 text-muted-foreground transition-transform group-data-panel-open:rotate-90 motion-reduce:transition-none"}),r.jsx("span",{className:"font-medium text-foreground",children:h}),r.jsxs("span",{className:"ml-auto flex items-center gap-1.5",children:[g.estimatedCost>0&&r.jsx("span",{className:"font-mono text-xs text-warning",children:mn(g.estimatedCost)}),r.jsx(_e,{variant:"secondary",className:"font-normal",children:g.count})]})]}),r.jsx(dt,{children:r.jsxs("div",{className:"ml-4 flex flex-col gap-0.5 border-l border-border pl-2 pt-0.5",children:[g.calls.slice(0,50).map((x,b)=>{const{tc:w,turnIndex:v}=x,S=C$(w);return r.jsx("div",{children:r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>s==null?void 0:s(v,w.id),className:q("h-auto w-full justify-start gap-1 px-1.5 py-0.5 text-left font-mono text-xs font-normal",w.isError?"text-destructive hover:bg-destructive/10":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:[w.isError&&r.jsx(xn,{className:"size-2.5 shrink-0 text-destructive","data-icon":"inline-start"}),r.jsx("span",{className:"truncate",children:S||w.id.slice(0,8)})]})},`${w.id}-${b}`)}),g.calls.length>50&&r.jsxs("div",{className:"px-1.5 py-0.5 text-xs text-muted-foreground",children:["+",g.calls.length-50," more"]})]})})]},h)},e[10]=s,e[11]=m):m=e[11],u=c.map(m),e[7]=s,e[8]=c,e[9]=u}else u=e[9];let f;return e[12]!==u?(f=r.jsxs("section",{children:[d,r.jsx("div",{className:"max-h-[320px] overflow-y-auto",children:r.jsx("div",{className:"flex flex-col gap-0.5 pr-2",children:u})})]}),e[12]=u,e[13]=f):f=e[13],f}function P$(n){const e=B.c(19),{searchInputRef:t}=n,{state:s,dispatch:o}=zt(),{searchQuery:i,expandAll:a}=s,{actions:l}=it(),{handleToggleExpandAll:c}=l;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Session details"}),e[0]=d):d=e[0];const u=a?"Collapse all":"Expand all";let f;e[1]!==a?(f=a?r.jsx(ma,{"data-icon":"inline-start"}):r.jsx(fa,{"data-icon":"inline-start"}),e[1]=a,e[2]=f):f=e[2];let m;e[3]!==c||e[4]!==u||e[5]!==f?(m=r.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[d,r.jsx(ee,{variant:"ghost",size:"icon-sm",className:"shrink-0",onClick:c,"aria-label":u,children:f})]}),e[3]=c,e[4]=u,e[5]=f,e[6]=m):m=e[6];const p=i??"";let h;e[7]!==o?(h=v=>o({type:"SET_SEARCH_QUERY",value:v.target.value}),e[7]=o,e[8]=h):h=e[8];let g;e[9]!==t||e[10]!==p||e[11]!==h?(g=r.jsx(ls,{ref:t,type:"text",value:p,onChange:h,placeholder:"Search conversation","aria-label":"Search conversation"}),e[9]=t,e[10]=p,e[11]=h,e[12]=g):g=e[12];let x;e[13]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(Pn,{align:"inline-start",children:r.jsx(gn,{})}),e[13]=x):x=e[13];let b;e[14]!==g?(b=r.jsxs(as,{children:[g,x]}),e[14]=g,e[15]=b):b=e[15];let w;return e[16]!==b||e[17]!==m?(w=r.jsxs("div",{className:"sticky top-0 border-b bg-background px-3 py-3",children:[m,b]}),e[16]=b,e[17]=m,e[18]=w):w=e[18],w}const W2=y.memo(function(e){const t=B.c(48),{embedded:s,onJumpToTurn:o,onToggleServer:i,onServersChanged:a,searchInputRef:l,onLoadSession:c,backgroundAgents:d}=e,u=s===void 0?!1:s,{isMobile:f}=zt(),{session:m,sessionSource:p}=it(),h=m,{turns:g}=h;let x;t[0]!==h.stats.totalCacheCreationTokens||t[1]!==h.stats.totalCacheReadTokens||t[2]!==h.stats.totalInputTokens||t[3]!==h.stats.totalOutputTokens||t[4]!==g.length?(x=[h.stats.totalInputTokens,h.stats.totalOutputTokens,h.stats.totalCacheCreationTokens,h.stats.totalCacheReadTokens,g.length],t[0]=h.stats.totalCacheCreationTokens,t[1]=h.stats.totalCacheReadTokens,t[2]=h.stats.totalInputTokens,t[3]=h.stats.totalOutputTokens,t[4]=g.length,t[5]=x):x=t[5];const b=x.join(":"),w=f?"mobile-scroll w-full flex-1":u?"w-full":"view-transition-right-panel panel-enter-right w-[320px] border-l";let v;t[6]!==w?(v=q("h-full min-h-0 shrink-0 overflow-y-auto bg-background",w),t[6]=w,t[7]=v):v=t[7];let S;t[8]!==l?(S=l&&r.jsx(P$,{searchInputRef:l}),t[8]=l,t[9]=S):S=t[9];const j=f?"p-4":"p-3";let k;t[10]!==j?(k=q(j),t[10]=j,t[11]=k):k=t[11];let C;t[12]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsxs(hd,{variant:"line",className:"grid w-full grid-cols-4",children:[r.jsx(ms,{value:"activity",children:"Activity"}),r.jsx(ms,{value:"agents",children:"Agents"}),r.jsx(ms,{value:"cost",children:"Cost"}),r.jsx(ms,{value:"issues",children:"Issues"})]}),t[12]=C):C=t[12];let N;t[13]!==o||t[14]!==g?(N=r.jsxs(ps,{value:"activity",className:"flex flex-col gap-6 pt-3",children:[r.jsx(S$,{turns:g,onJumpToTurn:o}),r.jsx(E$,{turns:g,onJumpToTurn:o})]}),t[13]=o,t[14]=g,t[15]=N):N=t[15];let _;t[16]!==a||t[17]!==i||t[18]!==h.cwd||t[19]!==g?(_=r.jsx(x1,{cwd:h.cwd,turns:g,onToggleServer:i,onServersChanged:a}),t[16]=a,t[17]=i,t[18]=h.cwd,t[19]=g,t[20]=_):_=t[20];let P;t[21]!==d?(P=d??[],t[21]=d,t[22]=P):P=t[22];let A;t[23]!==c||t[24]!==h||t[25]!==p||t[26]!==P?(A=r.jsx(w$,{session:h,sessionSource:p,bgAgents:P,onLoadSession:c}),t[23]=c,t[24]=h,t[25]=p,t[26]=P,t[27]=A):A=t[27];let T;t[28]!==_||t[29]!==A?(T=r.jsxs(ps,{value:"agents",className:"flex flex-col gap-6 pt-3",children:[_,A]}),t[28]=_,t[29]=A,t[30]=T):T=t[30];const E=(p==null?void 0:p.dirName)??null,R=(p==null?void 0:p.fileName)??null;let $;t[31]!==b||t[32]!==E||t[33]!==R?($=r.jsx(ps,{value:"cost",className:"pt-3",children:r.jsx(h$,{dirName:E,fileName:R,revision:b})}),t[31]=b,t[32]=E,t[33]=R,t[34]=$):$=t[34];let I;t[35]!==o||t[36]!==g?(I=r.jsx(ps,{value:"issues",className:"flex flex-col gap-6 pt-3",children:r.jsx(x$,{turns:g,onJumpToTurn:o})}),t[35]=o,t[36]=g,t[37]=I):I=t[37];let M;t[38]!==T||t[39]!==$||t[40]!==I||t[41]!==k||t[42]!==N?(M=r.jsxs(pd,{defaultValue:"activity",className:k,children:[C,N,T,$,I]}),t[38]=T,t[39]=$,t[40]=I,t[41]=k,t[42]=N,t[43]=M):M=t[43];let D;return t[44]!==M||t[45]!==v||t[46]!==S?(D=r.jsxs("aside",{className:v,children:[S,M]}),t[44]=M,t[45]=v,t[46]=S,t[47]=D):D=t[47],D}),A$=y.lazy(()=>qe(()=>import("./ProjectFilesPanel-CBFFT9qJ.js"),__vite__mapDeps([30,1,31,2,3,4])).then(n=>({default:n.ProjectFilesPanel}))),R$=y.lazy(()=>qe(()=>import("./WorktreePanel-DvZNvNhH.js"),__vite__mapDeps([32,1,2,3,4])).then(n=>({default:n.WorktreePanel})));function H2(){const n=B.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-sm text-muted-foreground",role:"status",children:[r.jsx(xt,{}),"Loading panel…"]}),n[0]=e):e=n[0],e}function I$(n){const e=B.c(6),{context:t,closePanel:s}=n,o=pu(),i=o.projectFilesRoot??t.projectPath;if(!i)return null;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(H2,{}),e[0]=a):a=e[0];let l;return e[1]!==s||e[2]!==i||e[3]!==o.addProjectContext||e[4]!==o.projectFilesRequest?(l=r.jsx(y.Suspense,{fallback:a,children:r.jsx(A$,{cwd:i,onClose:s,onAddToPrompt:o.addProjectContext,openRequest:o.projectFilesRequest,embedded:!0},i)}),e[1]=s,e[2]=i,e[3]=o.addProjectContext,e[4]=o.projectFilesRequest,e[5]=l):l=e[5],l}function $$(n){const e=B.c(3),{context:t}=n;if(!t.session)return null;let s;return e[0]!==t.session||e[1]!==t.sessionChangeKey?(s=r.jsx(yE,{session:t.session,sessionChangeKey:t.sessionChangeKey}),e[0]=t.session,e[1]=t.sessionChangeKey,e[2]=s):s=e[2],s}function M$(){const n=B.c(7),e=pu();let t;return n[0]!==e.backgroundAgents||n[1]!==e.jumpToTurn||n[2]!==e.loadSession||n[3]!==e.searchInputRef||n[4]!==e.serversChanged||n[5]!==e.toggleServer?(t=r.jsx(W2,{embedded:!0,onJumpToTurn:e.jumpToTurn,onToggleServer:e.toggleServer,onServersChanged:e.serversChanged,searchInputRef:e.searchInputRef,onLoadSession:e.loadSession,backgroundAgents:e.backgroundAgents}),n[0]=e.backgroundAgents,n[1]=e.jumpToTurn,n[2]=e.loadSession,n[3]=e.searchInputRef,n[4]=e.serversChanged,n[5]=e.toggleServer,n[6]=t):t=n[6],t}function O$(n){const e=B.c(8),{closePanel:t}=n,s=pu();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(H2,{}),e[0]=o):o=e[0];let i;return e[1]!==t||e[2]!==s.openWorktreeSession||e[3]!==s.worktreeDirName||e[4]!==s.worktrees.loading||e[5]!==s.worktrees.refetch||e[6]!==s.worktrees.worktrees?(i=r.jsx(y.Suspense,{fallback:o,children:r.jsx(R$,{worktrees:s.worktrees.worktrees,loading:s.worktrees.loading,dirName:s.worktreeDirName,onRefetch:s.worktrees.refetch,onOpenSession:s.openWorktreeSession,onClose:t})}),e[1]=t,e[2]=s.openWorktreeSession,e[3]=s.worktreeDirName,e[4]=s.worktrees.loading,e[5]=s.worktrees.refetch,e[6]=s.worktrees.worktrees,e[7]=i):i=e[7],i}const D$={id:Yo,workspacePanels:[{id:"worktrees",title:"Worktrees",icon:Dn,component:O$,order:5,defaultSize:"36%",minSize:"320px",when:n=>n.supportsWorktrees===!0},{id:"project-files",title:"Project files",icon:k3,component:I$,order:10,defaultSize:"55%",minSize:"340px",maxSize:"75%",keepAlive:!0,when:n=>n.canAccessHostFiles&&n.projectPath!==null},{id:"file-changes",title:"File changes",icon:Tr,component:$$,order:20,defaultSize:"36%",minSize:"320px",when:n=>n.canAccessHostFiles&&n.hasFileChanges&&n.session!==null},{id:"session-info",title:"Session details",icon:C3,component:M$,order:30,defaultSize:"36%",minSize:"320px",when:n=>n.session!==null}]},L$=H9([D$,...t$]);function Ya(n){const e=B.c(4),{floating:t,children:s}=n;if(t){let i;return e[0]!==s?(i=r.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 z-20 flex justify-center",children:r.jsx("div",{className:"pointer-events-auto w-full max-w-[var(--chat-width)] border-t bg-background px-3 pt-3",children:s})}),e[0]=s,e[1]=i):i=e[1],i}let o;return e[2]!==s?(o=r.jsx("div",{className:"flex w-full shrink-0 justify-center",children:r.jsx("div",{className:"w-full max-w-[var(--chat-width)] px-3",children:s})}),e[2]=s,e[3]=o):o=e[3],o}function K2(n){const e=B.c(11),{projectPath:t}=n;let s;e[0]!==t?(s=t?Qn(t):null,e[0]=t,e[1]=s):s=e[1];const o=s;let i;e[2]!==o?(i=o?r.jsxs(r.Fragment,{children:["What should we build in"," ",r.jsx("span",{children:o}),"?"]}):"What should we build?",e[2]=o,e[3]=i):i=e[3];let a;e[4]!==i?(a=r.jsx("h1",{className:"text-balance text-2xl font-semibold tracking-tight text-foreground",children:i}),e[4]=i,e[5]=a):a=e[5];let l;e[6]!==t?(l=t&&r.jsx("p",{className:"font-mono text-xs text-muted-foreground",children:ya(t)}),e[6]=t,e[7]=l):l=e[7];let c;return e[8]!==a||e[9]!==l?(c=r.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 text-center",children:[a,l]}),e[8]=a,e[9]=l,e[10]=c):c=e[10],c}function z$(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q(t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function F$(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("flex flex-wrap items-center gap-1.5 text-sm wrap-break-word text-muted-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("ol",{"data-slot":"breadcrumb-list",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function sh(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("inline-flex items-center gap-1",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("li",{"data-slot":"breadcrumb-item",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function B$(n){const e=B.c(10);let t,s,o,i;if(e[0]!==n){const{className:c,render:d,...u}=n;t=d,i=qh,s="a",o=Kh({className:q("transition-colors hover:text-foreground",c)},u),e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i}else t=e[1],s=e[2],o=e[3],i=e[4];let a;e[5]===Symbol.for("react.memo_cache_sentinel")?(a={slot:"breadcrumb-link"},e[5]=a):a=e[5];let l;return e[6]!==t||e[7]!==s||e[8]!==o?(l={defaultTagName:s,props:o,render:t,state:a},e[6]=t,e[7]=s,e[8]=o,e[9]=l):l=e[9],i(l)}function U$(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=q("font-normal text-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("span",{"data-slot":"breadcrumb-page",role:"link","aria-disabled":"true","aria-current":"page",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function W$(n){const e=B.c(12);let t,s,o;e[0]!==n?({children:t,className:s,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==s?(i=q("[&>svg]:size-3.5",s),e[4]=s,e[5]=i):i=e[5];let a;e[6]!==t?(a=t??r.jsx(Je,{}),e[6]=t,e[7]=a):a=e[7];let l;return e[8]!==o||e[9]!==i||e[10]!==a?(l=r.jsx("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:i,...o,children:a}),e[8]=o,e[9]=i,e[10]=a,e[11]=l):l=e[11],l}function q2(n){const e=B.c(51),{children:t,sessionLabel:s,customName:o,onDuplicate:i,onDelete:a,onRename:l}=n,[c,d]=y.useState(!1),[u,f]=y.useState(!1),[m,p]=y.useState(""),h=y.useRef(null);let g;e[0]!==o?(g=function(){p(o||""),f(!0),requestAnimationFrame(()=>{var W;return(W=h.current)==null?void 0:W.select()})},e[0]=o,e[1]=g):g=e[1];const x=g;let b;e[2]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx("div",{className:"w-full"}),e[2]=b):b=e[2];let w;e[3]!==t?(w=r.jsx(Ba,{render:b,children:t}),e[3]=t,e[4]=w):w=e[4];let v;e[5]!==i||e[6]!==l||e[7]!==x?(v=(l||i)&&r.jsxs(vo,{children:[l&&r.jsxs(on,{onClick:x,children:[r.jsx(Vs,{"data-icon":"inline-start"}),"Rename session"]}),i&&r.jsxs(on,{onClick:i,children:[r.jsx(An,{"data-icon":"inline-start"}),"Duplicate session"]})]}),e[5]=i,e[6]=l,e[7]=x,e[8]=v):v=e[8];let S;e[9]!==a||e[10]!==i||e[11]!==l?(S=a&&r.jsxs(r.Fragment,{children:[(i||l)&&r.jsx(wr,{}),r.jsx(vo,{children:r.jsxs(on,{variant:"destructive",onClick:()=>d(!0),children:[r.jsx(ca,{"data-icon":"inline-start"}),"Delete session"]})})]}),e[9]=a,e[10]=i,e[11]=l,e[12]=S):S=e[12];let j;e[13]!==v||e[14]!==S?(j=r.jsxs(Ua,{className:"min-w-44",children:[v,S]}),e[13]=v,e[14]=S,e[15]=j):j=e[15];let k;e[16]!==w||e[17]!==j?(k=r.jsxs(Fa,{children:[w,j]}),e[16]=w,e[17]=j,e[18]=k):k=e[18];let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(yd,{children:"Delete session?"}),e[19]=C):C=e[19];let N;e[20]!==s?(N=r.jsxs(bd,{children:[C,r.jsxs(wd,{children:["This will permanently delete"," ",r.jsx("span",{className:"font-medium text-foreground",children:s}),". This action cannot be undone."]})]}),e[20]=s,e[21]=N):N=e[21];let _;e[22]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(Sd,{size:"sm",children:"Cancel"}),e[22]=_):_=e[22];let P;e[23]!==a?(P=r.jsxs(vd,{children:[_,r.jsx(jd,{variant:"destructive",size:"sm",onClick:()=>{a==null||a(),d(!1)},children:"Delete"})]}),e[23]=a,e[24]=P):P=e[24];let A;e[25]!==P||e[26]!==N?(A=r.jsxs(xd,{children:[N,P]}),e[25]=P,e[26]=N,e[27]=A):A=e[27];let T;e[28]!==c||e[29]!==A?(T=r.jsx(gd,{open:c,onOpenChange:d,children:A}),e[28]=c,e[29]=A,e[30]=T):T=e[30];let E;e[31]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsxs(Ps,{children:[r.jsx(os,{className:"text-foreground",children:"Rename session"}),r.jsx(rs,{className:"text-muted-foreground",children:"Give this session a custom name. Clear to reset to default."})]}),e[31]=E):E=e[31];let R;e[32]!==l||e[33]!==m?(R=z=>{z.preventDefault(),l==null||l(m),f(!1)},e[32]=l,e[33]=m,e[34]=R):R=e[34];let $;e[35]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx(jt,{htmlFor:"session-rename",children:"Session name"}),e[35]=$):$=e[35];let I;e[36]===Symbol.for("react.memo_cache_sentinel")?(I=z=>p(z.target.value),e[36]=I):I=e[36];let M;e[37]!==m||e[38]!==s?(M=r.jsxs(wt,{children:[$,r.jsx(Ht,{id:"session-rename",ref:h,value:m,onChange:I,placeholder:s})]}),e[37]=m,e[38]=s,e[39]=M):M=e[39];let D;e[40]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsxs(Yg,{children:[r.jsx(ee,{type:"button",variant:"ghost",size:"sm",onClick:()=>f(!1),children:"Cancel"}),r.jsx(ee,{type:"submit",size:"sm",children:"Save"})]}),e[40]=D):D=e[40];let O;e[41]!==R||e[42]!==M?(O=r.jsxs(ss,{className:"sm:max-w-md",children:[E,r.jsxs("form",{className:"flex flex-col gap-4",onSubmit:R,children:[M,D]})]}),e[41]=R,e[42]=M,e[43]=O):O=e[43];let L;e[44]!==u||e[45]!==O?(L=r.jsx(ns,{open:u,onOpenChange:f,children:O}),e[44]=u,e[45]=O,e[46]=L):L=e[46];let F;return e[47]!==T||e[48]!==L||e[49]!==k?(F=r.jsxs(r.Fragment,{children:[k,T,L]}),e[47]=T,e[48]=L,e[49]=k,e[50]=F):F=e[50],F}const V2="session-custom-names";function G2(){try{const n=localStorage.getItem(Kt(V2));return n?JSON.parse(n):{}}catch{return{}}}function H$(n){localStorage.setItem(Kt(V2),JSON.stringify(n))}let ta=G2();const na=new Set;if(typeof window<"u"){const n=()=>{ta=G2();for(const e of na)e()};window.addEventListener("cogpit-device-changed",n),window.addEventListener("cogpit-identity-changed",n)}function K$(n){return na.add(n),()=>{na.delete(n)}}function q$(){return ta}function Oc(n,e){const t={...ta},s=e.trim();s?t[n]=s:delete t[n],H$(t),ta=t;for(const o of na)o()}function Y2(){const n=B.c(2),e=y.useSyncExternalStore(K$,q$);let t;return n[0]!==e?(t={names:e,rename:Oc},n[0]=e,n[1]=t):t=n[1],t}function X2(n){const e=B.c(16),{value:t,onChange:s,placeholder:o,loading:i}=n,a=i===void 0?!1:i;let l;e[0]!==a?(l=r.jsx(Pn,{children:a?r.jsx(ot,{className:"animate-spin","aria-label":"Searching session history"}):r.jsx(gn,{"aria-hidden":"true"})}),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==s?(c=m=>s(m.target.value),e[2]=s,e[3]=c):c=e[3];let d;e[4]!==a||e[5]!==o||e[6]!==c||e[7]!==t?(d=r.jsx(ls,{type:"search","aria-busy":a,"aria-label":o,value:t,onChange:c,placeholder:o}),e[4]=a,e[5]=o,e[6]=c,e[7]=t,e[8]=d):d=e[8];let u;e[9]!==s||e[10]!==t?(u=t&&r.jsx(Pn,{align:"inline-end",children:r.jsx(Fr,{"aria-label":"Clear search",onClick:()=>s(""),size:"icon-xs",children:r.jsx(rt,{})})}),e[9]=s,e[10]=t,e[11]=u):u=e[11];let f;return e[12]!==l||e[13]!==d||e[14]!==u?(f=r.jsxs(as,{className:"w-full sm:max-w-sm",children:[l,d,u]}),e[12]=l,e[13]=d,e[14]=u,e[15]=f):f=e[15],f}function J2(n){const e=B.c(10),{message:t,onRetry:s}=n;let o,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(xn,{"aria-hidden":"true"}),i=r.jsx(Tt,{children:"Could not load this data"}),e[0]=o,e[1]=i):(o=e[0],i=e[1]);let a;e[2]!==t?(a=r.jsx(gt,{children:t}),e[2]=t,e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Ot,{"data-icon":"inline-start"}),e[4]=l):l=e[4];let c;e[5]!==s?(c=r.jsx(Cs,{children:r.jsxs(ee,{variant:"ghost",size:"xs",onClick:s,children:[l,"Retry"]})}),e[5]=s,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=r.jsxs(ht,{variant:"destructive",children:[o,i,a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d}function Q2(n){const e=B.c(5),{count:t,includeMessagePlaceholder:s}=n,o=t===void 0?4:t,i=s===void 0?!1:s;let a;if(e[0]!==o||e[1]!==i){let l;e[3]!==i?(l=(c,d)=>r.jsxs("div",{children:[d>0&&r.jsx(St,{}),r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3.5",children:[r.jsx(ft,{className:"size-8 shrink-0 rounded-md"}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[r.jsx(ft,{className:"h-4 w-40 max-w-full"}),i&&r.jsx(ft,{className:"h-3 w-72 max-w-full"}),r.jsx(ft,{className:"h-3 w-52 max-w-full"})]}),r.jsx(ft,{className:"hidden h-5 w-20 sm:block"})]})]},d),e[3]=i,e[4]=l):l=e[4],a=r.jsx("div",{className:"overflow-hidden rounded-lg border","aria-hidden":"true",children:Array.from({length:o},l)}),e[0]=o,e[1]=i,e[2]=a}else a=e[2];return a}function Sr(n){return n==="idle"||n==="completed"}function Tu(n){return Sr(n)?"text-success":n==="thinking"||n==="deferred"?"text-warning":"text-info"}const zs={attention:"bg-warning",working:"bg-success ring-2 ring-success/30",idle:"bg-success/40"},V$=/(?:https?:\/\/)?github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/i,G$=/^([\w.-]+(?:\/[\w.-]+)?)#(\d+)$/,Y$=/(?:^|\s)#(\d+)(?=\s|$)/,X$=/^(?:pr|pull\s+request)\s*#?(\d+)$/i;function ki(n){const e=Number(n);return Number.isSafeInteger(e)&&e>0?e:null}function J$(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 Z2(n){const e=n.trim();if(!e)return null;const t=V$.exec(e);if(t){const l=ki(t[3]);return l===null?null:{number:l,repoHint:`${t[1]}/${t[2]}`.toLowerCase()}}const s=G$.exec(e);if(s){const l=ki(s[2]);return l===null?null:{number:l,repoHint:s[1].toLowerCase()}}const o=Y$.exec(e);if(o){const l=ki(o[1]);if(l===null)return null;const c=`${e.slice(0,o.index)} ${e.slice(o.index+o[0].length)}`;return{number:l,repoHint:J$(c)}}const i=X$.exec(e);if(!i)return null;const a=ki(i[1]);return a===null?null:{number:a,repoHint:null}}function oh(n,e){if(!n)return!1;const t=n.toLowerCase().replace(/\.git$/,"");return t===e||t.endsWith(`/${e}`)||e.endsWith(`/${t}`)}function Q$(n,e){if(!n)return!1;const t=n.toLowerCase().replace(/\.git$/,"").split(/[\\/]/).filter(Boolean).at(-1);if(!t)return!1;const s=t.replace(/[^a-z0-9]/g,"");return e.split("/").some(o=>o.replace(/[^a-z0-9]/g,"")===s)}function Z$(n,e,t=[]){if(n.number!==e.number)return!1;const s=e.repoHint;return s?n.repo&&s.includes("/")?oh(n.repo,s):oh(n.repo,s)?!0:t.some(o=>Q$(o,s)):!0}function eb(n,e,t=[]){var i;const s=Z2(e);if(s){const a=[n.cwd,n.projectShortName,...t];return((i=n.pullRequests)==null?void 0:i.some(l=>Z$(l,s,a)))??!1}const o=e.trim().toLowerCase();return o?[...t,n.aiTitle,n.name,n.slug,n.customTitle,n.firstUserMessage,n.lastUserMessage,n.model,n.gitBranch,n.agentName,n.teamName,n.sessionId,n.cwd,n.projectShortName].some(a=>a==null?void 0:a.toLowerCase().includes(o)):!0}const eM=120*1e3;function tb(n){return n?Date.now()-new Date(n).getTime()<eM:!1}function nb(n,e){const t=n.teamName?n.agentName:"",s=e||n.aiTitle||n.name||t||n.slug||n.firstUserMessage||n.customTitle;return s?kn(s,70):kn(n.sessionId,16)}function rh(n){return n.trim().replace(/\s+/g," ").slice(0,40).toLowerCase()}function tM(n,e){const t=(n.lastUserMessage||n.firstUserMessage||"").trim();return!t||rh(t)===rh(e)?null:kn(t,220)}function nM(n,e){return eb(n,e)}function sM(n,e){if(!n||!e)return null;const t=new Date(e).getTime()-new Date(n).getTime();return t>=6e4?Fn(t):null}function oM(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(`
129
- `)}function rM(n){var t;const e=n.cwd?(t=wa(n.cwd))==null?void 0:t.worktreeName:void 0;return e?{icon:_3,label:e,title:n.cwd}:n.gitBranch?{icon:Dn,label:n.gitBranch}:null}function iM(n,e){return n.agentStatus==="deferred"?"attention":e?Sr(n.agentStatus)?"idle":"working":null}function aM(n){const e=B.c(20),{session:t,live:s}=n;if(t.agentStatus==="deferred"){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(_e,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"Needs review"}),e[0]=o):o=e[0],o}if(s){const o=Sr(t.agentStatus);let i;e[1]!==t.agentPendingAgents||e[2]!==t.agentStatus||e[3]!==t.agentTerminalReason||e[4]!==t.agentToolName?(i=Vr(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??"Active",e[1]=t.agentPendingAgents,e[2]=t.agentStatus,e[3]=t.agentTerminalReason,e[4]=t.agentToolName,e[5]=i):i=e[5];const a=i;let l;e[6]!==t.agentStatus?(l=Tu(t.agentStatus),e[6]=t.agentStatus,e[7]=l):l=e[7];const c=o?"bg-success/60":"bg-current";let d;e[8]!==c?(d=q("size-1.5 rounded-full",c),e[8]=c,e[9]=d):d=e[9];let u;e[10]!==d?(u=r.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:d}),e[10]=d,e[11]=u):u=e[11];let f;return e[12]!==a||e[13]!==l||e[14]!==u?(f=r.jsxs(_e,{variant:"secondary",className:l,children:[u,a]}),e[12]=a,e[13]=l,e[14]=u,e[15]=f):f=e[15],f}if(t.agentTerminalReason){let o;e[16]!==t.agentTerminalReason?(o=au(t.agentTerminalReason),e[16]=t.agentTerminalReason,e[17]=o):o=e[17];let i;return e[18]!==o?(i=r.jsx(_e,{variant:"outline",className:"max-w-44 truncate text-warning",children:o}),e[18]=o,e[19]=i):i=e[19],i}return null}function Xl(n){const e=B.c(9),{icon:t,title:s,className:o,children:i}=n;let a;e[0]!==o?(a=q("flex items-center gap-1",o),e[0]=o,e[1]=a):a=e[1];let l;e[2]!==t?(l=r.jsx(t,{className:"size-3 shrink-0"}),e[2]=t,e[3]=l):l=e[3];let c;return e[4]!==i||e[5]!==a||e[6]!==l||e[7]!==s?(c=r.jsxs("span",{className:a,title:s,children:[l,i]}),e[4]=i,e[5]=a,e[6]=l,e[7]=s,e[8]=c):c=e[8],c}function lM(n){const e=B.c(99),{session:t,customName:s,onSelect:o}=n,i=t.lastActivityAt||t.lastModified;let a,l;e[0]!==i||e[1]!==t?(a=tb(i),l=iM(t,a),e[0]=i,e[1]=t,e[2]=a,e[3]=l):(a=e[2],l=e[3]);const c=l,d=t.teamName?t.agentName:void 0;let u,f,m,p,h,g,x,b,w,v,S,j,k,C;if(e[4]!==s||e[5]!==c||e[6]!==i||e[7]!==a||e[8]!==o||e[9]!==t||e[10]!==d){const M=rM(t);let D;e[25]!==i||e[26]!==t.timestamp?(D=sM(t.timestamp,i),e[25]=i,e[26]=t.timestamp,e[27]=D):D=e[27];const O=D,L=t.turnCount??0;let F,z;e[28]!==s||e[29]!==t?(z=nb(t,s),F=tM(t,z),e[28]=s,e[29]=t,e[30]=F,e[31]=z):(F=e[30],z=e[31]);const W=F;g="motion-list-item group flex w-full items-start gap-3 px-4 py-3 transition-colors hover:bg-muted/50 focus-within:bg-muted",u="button",f=o,e[32]!==t?(m=oM(t),e[32]=t,e[33]=m):m=e[33],p="flex min-w-0 flex-1 items-start gap-3 rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring";let U;e[34]===Symbol.for("react.memo_cache_sentinel")?(U=r.jsx(oc,{className:"size-4"}),e[34]=U):U=e[34];let H;e[35]!==c?(H=c&&r.jsx("span",{"aria-hidden":"true","data-status-dot":c,className:q("absolute -top-1 -right-1 size-2 rounded-full ring-2 ring-card",zs[c])}),e[35]=c,e[36]=H):H=e[36],e[37]!==H?(h=r.jsxs("span",{className:"relative mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-md border bg-muted/40 text-muted-foreground",children:[U,H]}),e[37]=H,e[38]=h):h=e[38],j="flex min-w-0 flex-1 flex-col gap-1";let K;e[39]!==z?(K=r.jsx("span",{className:"truncate text-sm font-medium",children:z}),e[39]=z,e[40]=K):K=e[40];let V;e[41]!==d?(V=d&&r.jsxs(_e,{variant:"outline",className:"shrink-0",children:[r.jsx(yo,{"data-icon":"inline-start"}),kn(d,18)]}),e[41]=d,e[42]=V):V=e[42];let Y;e[43]!==t.branchedFrom?(Y=t.branchedFrom&&r.jsxs(_e,{variant:"outline",className:"shrink-0",title:"Branched from another session",children:[r.jsx(ed,{"data-icon":"inline-start"}),"branch"]}),e[43]=t.branchedFrom,e[44]=Y):Y=e[44];let G;e[45]!==a||e[46]!==t?(G=r.jsx(aM,{session:t,live:a}),e[45]=a,e[46]=t,e[47]=G):G=e[47];let J;e[48]!==i?(J=i&&r.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:Ir(i)}),e[48]=i,e[49]=J):J=e[49];let Q;e[50]!==G||e[51]!==J?(Q=r.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2",children:[G,J]}),e[50]=G,e[51]=J,e[52]=Q):Q=e[52],e[53]!==K||e[54]!==V||e[55]!==Y||e[56]!==Q?(k=r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[K,V,Y,Q]}),e[53]=K,e[54]=V,e[55]=Y,e[56]=Q,e[57]=k):k=e[57],e[58]!==W?(C=W&&r.jsx("span",{className:"line-clamp-1 text-sm text-muted-foreground",children:W}),e[58]=W,e[59]=C):C=e[59],x="flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",e[60]!==t.model?(b=t.model&&r.jsx(_e,{variant:"outline",children:Js(t.model)}),e[60]=t.model,e[61]=b):b=e[61],e[62]!==L?(w=L>0&&r.jsxs(Xl,{icon:oc,children:[L," ",L===1?"turn":"turns"]}),e[62]=L,e[63]=w):w=e[63],e[64]!==O?(v=O&&r.jsx(Xl,{icon:Fs,title:"First prompt to last activity",children:O}),e[64]=O,e[65]=v):v=e[65],S=M&&r.jsx(Xl,{icon:M.icon,className:"max-w-40 truncate",title:M.title,children:kn(M.label,22)}),e[4]=s,e[5]=c,e[6]=i,e[7]=a,e[8]=o,e[9]=t,e[10]=d,e[11]=u,e[12]=f,e[13]=m,e[14]=p,e[15]=h,e[16]=g,e[17]=x,e[18]=b,e[19]=w,e[20]=v,e[21]=S,e[22]=j,e[23]=k,e[24]=C}else u=e[11],f=e[12],m=e[13],p=e[14],h=e[15],g=e[16],x=e[17],b=e[18],w=e[19],v=e[20],S=e[21],j=e[22],k=e[23],C=e[24];let N;e[66]!==t.size?(N=Ag(t.size),e[66]=t.size,e[67]=N):N=e[67];let _;e[68]!==N?(_=r.jsx("span",{children:N}),e[68]=N,e[69]=_):_=e[69];let P;e[70]!==_||e[71]!==x||e[72]!==b||e[73]!==w||e[74]!==v||e[75]!==S?(P=r.jsxs("span",{className:x,children:[b,w,v,S,_]}),e[70]=_,e[71]=x,e[72]=b,e[73]=w,e[74]=v,e[75]=S,e[76]=P):P=e[76];let A;e[77]!==P||e[78]!==j||e[79]!==k||e[80]!==C?(A=r.jsxs("span",{className:j,children:[k,C,P]}),e[77]=P,e[78]=j,e[79]=k,e[80]=C,e[81]=A):A=e[81];let T;e[82]!==u||e[83]!==f||e[84]!==m||e[85]!==p||e[86]!==h||e[87]!==A?(T=r.jsxs("button",{type:u,onClick:f,title:m,className:p,children:[h,A]}),e[82]=u,e[83]=f,e[84]=m,e[85]=p,e[86]=h,e[87]=A,e[88]=T):T=e[88];let E;e[89]!==t.matchedPullRequestNumber||e[90]!==t.pullRequests?(E=t.matchedPullRequestNumber?r.jsxs(_e,{variant:"outline",children:["Matched #",t.matchedPullRequestNumber]}):r.jsx(qa,{pullRequests:t.pullRequests,max:2,compact:!0}),e[89]=t.matchedPullRequestNumber,e[90]=t.pullRequests,e[91]=E):E=e[91];let R;e[92]===Symbol.for("react.memo_cache_sentinel")?(R=r.jsx(Je,{className:"size-4 text-muted-foreground transition-transform group-hover:translate-x-0.5"}),e[92]=R):R=e[92];let $;e[93]!==E?($=r.jsxs("span",{className:"flex shrink-0 items-center gap-2 pt-1.5",children:[E,R]}),e[93]=E,e[94]=$):$=e[94];let I;return e[95]!==g||e[96]!==T||e[97]!==$?(I=r.jsxs("div",{className:g,children:[T,$]}),e[95]=g,e[96]=T,e[97]=$,e[98]=I):I=e[98],I}function cM(n){const e=B.c(61),{selectedProject:t,sessions:s,sessionsTotal:o,sessionsLoading:i,searchLoading:a,searchFilter:l,setSearchFilter:c,filteredSessions:d,fetchError:u,onSelectSession:f,onNewSession:m,creatingSession:p,onDuplicateSession:h,onDeleteSession:g,onBack:x,onRetryFetch:b,loadMoreSessions:w}=n,{names:v,rename:S}=Y2();let j;e[0]!==t.path?(j=Qn(t.path),e[0]=t.path,e[1]=j):j=e[1];const k=j;let C;e[2]!==x?(C=r.jsx(sh,{children:r.jsx(B$,{render:r.jsx("button",{type:"button",onClick:x}),children:"Projects"})}),e[2]=x,e[3]=C):C=e[3];let N;e[4]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(W$,{}),e[4]=N):N=e[4];let _;e[5]!==k?(_=r.jsx(sh,{className:"min-w-0",children:r.jsx(U$,{className:"truncate",children:k})}),e[5]=k,e[6]=_):_=e[6];let P;e[7]!==C||e[8]!==_?(P=r.jsx(z$,{children:r.jsxs(F$,{children:[C,N,_]})}),e[7]=C,e[8]=_,e[9]=P):P=e[9];let A;e[10]!==k?(A=r.jsx("h1",{className:"truncate text-2xl font-semibold tracking-tight",children:k}),e[10]=k,e[11]=A):A=e[11];let T;e[12]!==o?(T=r.jsx(_e,{variant:"secondary",children:o}),e[12]=o,e[13]=T):T=e[13];let E;e[14]!==A||e[15]!==T?(E=r.jsxs("div",{className:"flex items-center gap-2",children:[A,T]}),e[14]=A,e[15]=T,e[16]=E):E=e[16];let R;e[17]!==t.path?(R=ya(t.path),e[17]=t.path,e[18]=R):R=e[18];let $;e[19]!==R?($=r.jsx("p",{className:"truncate text-sm text-muted-foreground",children:R}),e[19]=R,e[20]=$):$=e[20];let I;e[21]!==$||e[22]!==E?(I=r.jsxs("header",{className:"flex min-w-0 flex-col gap-1",children:[E,$]}),e[21]=$,e[22]=E,e[23]=I):I=e[23];let M;e[24]!==l||e[25]!==a||e[26]!==c?(M=r.jsx(X2,{value:l,onChange:c,placeholder:"Search sessions or PRs...",loading:a}),e[24]=l,e[25]=a,e[26]=c,e[27]=M):M=e[27];let D;e[28]!==p||e[29]!==m||e[30]!==t.dirName||e[31]!==t.path?(D=m&&r.jsxs(ee,{size:"sm",disabled:p,onClick:()=>m(t.dirName,t.path),children:[p?r.jsx(xt,{"data-icon":"inline-start"}):r.jsx(Ln,{"data-icon":"inline-start"}),"New Session"]}),e[28]=p,e[29]=m,e[30]=t.dirName,e[31]=t.path,e[32]=D):D=e[32];let O;e[33]!==M||e[34]!==D?(O=r.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[M,D]}),e[33]=M,e[34]=D,e[35]=O):O=e[35];let L;e[36]!==u||e[37]!==b?(L=u&&r.jsx(J2,{message:u,onRetry:b}),e[36]=u,e[37]=b,e[38]=L):L=e[38];let F;e[39]!==d||e[40]!==w||e[41]!==g||e[42]!==h||e[43]!==f||e[44]!==S||e[45]!==l||e[46]!==a||e[47]!==t.dirName||e[48]!==v||e[49]!==s||e[50]!==i||e[51]!==o?(F=(i||a)&&d.length===0?r.jsx(Q2,{includeMessagePlaceholder:!0}):d.length===0?r.jsx(ln,{className:"min-h-72 border",children:r.jsxs(cn,{children:[r.jsx(bn,{variant:"icon",children:r.jsx(pa,{})}),r.jsx(dn,{children:l?"No sessions match your search":"No sessions yet"}),r.jsx(vn,{children:l?"Try #157, honest-cms #157, or paste a PR URL.":"Start a session in this project and it will appear here."})]})}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"overflow-hidden rounded-lg border bg-card",children:d.map((U,H)=>r.jsxs(y.Fragment,{children:[H>0&&r.jsx(St,{}),r.jsx(q2,{sessionLabel:nb(U),customName:v[U.sessionId],onRename:K=>S(U.sessionId,K),onDuplicate:h?()=>h(t.dirName,U.fileName):void 0,onDelete:g?()=>g(t.dirName,U.fileName):void 0,children:r.jsx(lM,{session:U,customName:v[U.sessionId],onSelect:()=>f(t.dirName,U.fileName)})})]},U.fileName))}),s.length<o&&!l&&r.jsx("div",{className:"flex justify-center",children:r.jsxs(ee,{variant:"outline",size:"sm",disabled:i,onClick:w,children:[i&&r.jsx(xt,{"data-icon":"inline-start"}),i?"Loading...":"Load more sessions"]})})]}),e[39]=d,e[40]=w,e[41]=g,e[42]=h,e[43]=f,e[44]=S,e[45]=l,e[46]=a,e[47]=t.dirName,e[48]=v,e[49]=s,e[50]=i,e[51]=o,e[52]=F):F=e[52];let z;e[53]!==O||e[54]!==L||e[55]!==F?(z=r.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Sessions",children:[O,L,F]}),e[53]=O,e[54]=L,e[55]=F,e[56]=z):z=e[56];let W;return e[57]!==I||e[58]!==z||e[59]!==P?(W=r.jsx(is,{className:"h-full",children:r.jsxs("main",{className:"mx-auto flex max-w-6xl flex-col gap-6 px-4 py-6 sm:px-6 sm:pb-10 sm:pt-14",children:[P,I,z]})}),e[57]=I,e[58]=z,e[59]=P,e[60]=W):W=e[60],W}function dM(n){const e=B.c(13),{projectPath:t,fallback:s,className:o}=n,[i,a]=y.useState(null);if(!t||i===t){let m;return e[0]!==s?(m=r.jsx(r.Fragment,{children:s}),e[0]=s,e[1]=m):m=e[1],m}const l=`/api/project-icon?cwd=${encodeURIComponent(t)}`;let c;e[2]!==l?(c=Rr(l),e[2]=l,e[3]=c):c=e[3];let d;e[4]!==t?(d=()=>a(t),e[4]=t,e[5]=d):d=e[5];let u;e[6]!==o?(u=q("size-3.5 shrink-0 rounded-[3px] object-contain",o),e[6]=o,e[7]=u):u=e[7];let f;return e[8]!==t||e[9]!==c||e[10]!==d||e[11]!==u?(f=r.jsx("img",{src:c,alt:"","aria-hidden":!0,loading:"lazy",decoding:"async",onError:d,className:u},t),e[8]=t,e[9]=c,e[10]=d,e[11]=u,e[12]=f):f=e[12],f}function sb(n){const e=B.c(34),{children:t,projectLabel:s,customName:o,className:i,onRename:a}=n,[l,c]=y.useState(!1),[d,u]=y.useState(""),f=y.useRef(null);let m;e[0]!==o?(m=function(){u(o||""),c(!0),requestAnimationFrame(()=>{var R;return(R=f.current)==null?void 0:R.select()})},e[0]=o,e[1]=m):m=e[1];const p=m;let h;e[2]!==i?(h=q("w-full",i),e[2]=i,e[3]=h):h=e[3];let g;e[4]!==h?(g=r.jsx("div",{className:h}),e[4]=h,e[5]=g):g=e[5];let x;e[6]!==t||e[7]!==g?(x=r.jsx(Ba,{render:g,children:t}),e[6]=t,e[7]=g,e[8]=x):x=e[8];let b;e[9]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx(Vs,{"data-icon":"inline-start"}),e[9]=b):b=e[9];let w;e[10]!==p?(w=r.jsx(Ua,{className:"min-w-44",children:r.jsx(vo,{children:r.jsxs(on,{onClick:p,children:[b,"Rename project"]})})}),e[10]=p,e[11]=w):w=e[11];let v;e[12]!==x||e[13]!==w?(v=r.jsxs(Fa,{children:[x,w]}),e[12]=x,e[13]=w,e[14]=v):v=e[14];let S;e[15]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsxs(Ps,{children:[r.jsx(os,{className:"text-foreground",children:"Rename project"}),r.jsx(rs,{className:"text-muted-foreground",children:"Give this project a custom name. Clear to reset to default."})]}),e[15]=S):S=e[15];let j;e[16]!==a||e[17]!==d?(j=E=>{E.preventDefault(),a(d),c(!1)},e[16]=a,e[17]=d,e[18]=j):j=e[18];let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(jt,{htmlFor:"project-rename",children:"Project name"}),e[19]=k):k=e[19];let C;e[20]===Symbol.for("react.memo_cache_sentinel")?(C=E=>u(E.target.value),e[20]=C):C=e[20];let N;e[21]!==s||e[22]!==d?(N=r.jsxs(wt,{children:[k,r.jsx(Ht,{id:"project-rename",ref:f,value:d,onChange:C,placeholder:s})]}),e[21]=s,e[22]=d,e[23]=N):N=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsxs(Yg,{children:[r.jsx(ee,{type:"button",variant:"ghost",size:"sm",onClick:()=>c(!1),children:"Cancel"}),r.jsx(ee,{type:"submit",size:"sm",children:"Save"})]}),e[24]=_):_=e[24];let P;e[25]!==N||e[26]!==j?(P=r.jsxs(ss,{className:"sm:max-w-md",children:[S,r.jsxs("form",{className:"flex flex-col gap-4",onSubmit:j,children:[N,_]})]}),e[25]=N,e[26]=j,e[27]=P):P=e[27];let A;e[28]!==l||e[29]!==P?(A=r.jsx(ns,{open:l,onOpenChange:c,children:P}),e[28]=l,e[29]=P,e[30]=A):A=e[30];let T;return e[31]!==A||e[32]!==v?(T=r.jsxs(r.Fragment,{children:[v,A]}),e[31]=A,e[32]=v,e[33]=T):T=e[33],T}const ob="project-custom-names";function rb(){try{const n=localStorage.getItem(Kt(ob));return n?JSON.parse(n):{}}catch{return{}}}function uM(n){localStorage.setItem(Kt(ob),JSON.stringify(n))}let sa=rb();const oa=new Set;if(typeof window<"u"){const n=()=>{sa=rb();for(const e of oa)e()};window.addEventListener("cogpit-device-changed",n),window.addEventListener("cogpit-identity-changed",n)}function fM(n){return oa.add(n),()=>{oa.delete(n)}}function mM(){return sa}function pM(n,e){const t={...sa},s=e.trim();s?t[n]=s:delete t[n],uM(t),sa=t;for(const o of oa)o()}function ib(){const n=B.c(2),e=y.useSyncExternalStore(fM,mM);let t;return n[0]!==e?(t={names:e,rename:pM},n[0]=e,n[1]=t):t=n[1],t}function hM(n){const e=B.c(45),{projects:t,activeSessions:s,loading:o,refreshing:i,searchFilter:a,setSearchFilter:l,fetchError:c,selectedProjectDirName:d,onSelectProject:u,onRefresh:f}=n;let m;if(e[0]!==s){m={};for(const I of s)tb(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}=ib();let x;e:{if(!a){x=t;break e}let I;if(e[2]!==h||e[3]!==t||e[4]!==a){const M=a.toLowerCase();I=t.filter(D=>{var O;return D.path.toLowerCase().includes(M)||D.shortName.toLowerCase().includes(M)||((O=h[D.dirName])==null?void 0:O.toLowerCase().includes(M))}),e[2]=h,e[3]=t,e[4]=a,e[5]=I}else I=e[5];x=I}const b=x;let w;e[6]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Projects"}),e[6]=w):w=e[6];let v;e[7]!==t.length?(v=r.jsxs("div",{className:"flex items-center gap-2",children:[w,r.jsx(_e,{variant:"secondary",children:t.length})]}),e[7]=t.length,e[8]=v):v=e[8];let S;e[9]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx("p",{className:"text-sm text-muted-foreground",children:"Open a project to browse and resume its sessions."}),e[9]=S):S=e[9];let j;e[10]!==v?(j=r.jsxs("header",{className:"flex flex-col gap-1",children:[v,S]}),e[10]=v,e[11]=j):j=e[11];let k;e[12]!==a||e[13]!==l?(k=r.jsx(X2,{value:a,onChange:l,placeholder:"Filter projects..."}),e[12]=a,e[13]=l,e[14]=k):k=e[14];const C=i&&"animate-spin";let N;e[15]!==C?(N=q(C),e[15]=C,e[16]=N):N=e[16];let _;e[17]!==N?(_=r.jsx(Ot,{"data-icon":"inline-start",className:N}),e[17]=N,e[18]=_):_=e[18];let P;e[19]!==f||e[20]!==i||e[21]!==_?(P=r.jsxs(ee,{variant:"outline",size:"sm",onClick:f,disabled:i,"aria-label":"Refresh projects",children:[_,"Refresh"]}),e[19]=f,e[20]=i,e[21]=_,e[22]=P):P=e[22];let A;e[23]!==P||e[24]!==k?(A=r.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[k,P]}),e[23]=P,e[24]=k,e[25]=A):A=e[25];let T;e[26]!==c||e[27]!==f||e[28]!==d?(T=c&&!d&&r.jsx(J2,{message:c,onRetry:f}),e[26]=c,e[27]=f,e[28]=d,e[29]=T):T=e[29];let E;e[30]!==p||e[31]!==b||e[32]!==o||e[33]!==u||e[34]!==h||e[35]!==g||e[36]!==a?(E=o?r.jsx(Q2,{}):b.length===0?r.jsx(ln,{className:"min-h-72 border",children:r.jsxs(cn,{children:[r.jsx(bn,{variant:"icon",children:r.jsx(jo,{})}),r.jsx(dn,{children:a?"No projects match your search":"No projects yet"}),r.jsx(vn,{children:a?"Try a project name or path.":"Start Claude Code, Codex, or Copilot and its project will appear here."})]})}):r.jsx("div",{className:"overflow-hidden rounded-lg border bg-card",children:b.map((I,M)=>{const D=p[I.dirName]||0,O=h[I.dirName],L=cj(Et(I.dirName));return r.jsxs(y.Fragment,{children:[M>0&&r.jsx(St,{}),r.jsx(sb,{projectLabel:Qn(I.path),customName:O,onRename:F=>g(I.dirName,F),children:r.jsxs("button",{type:"button",onClick:()=>u==null?void 0:u(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:[r.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-3",children:[r.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-md border bg-muted/40",children:r.jsx(dM,{projectPath:I.path,className:"size-4",fallback:r.jsx(jo,{className:"size-4 text-muted-foreground"})})}),r.jsxs("span",{className:"min-w-0",children:[r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"truncate text-sm font-medium",children:O||Qn(I.path)}),L&&r.jsx(_e,{variant:"outline",className:"h-5 shrink-0 px-1.5 text-[10px]",children:L})]}),r.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:ya(I.path)})]})]}),r.jsxs("span",{className:"flex items-center gap-4 pl-11 text-sm text-muted-foreground sm:pl-0",children:[D>0&&r.jsxs(_e,{variant:"secondary",children:[r.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:"size-1.5 rounded-full bg-success"}),D," active"]}),r.jsxs("span",{className:"whitespace-nowrap",children:[I.sessionCount," ",I.sessionCount===1?"session":"sessions"]}),I.lastModified&&r.jsx("span",{className:"hidden w-24 whitespace-nowrap text-right md:inline",children:Ir(I.lastModified)}),r.jsx(Je,{className:"size-4 shrink-0 transition-transform group-hover:translate-x-0.5"})]})]})})]},I.dirName)})}),e[30]=p,e[31]=b,e[32]=o,e[33]=u,e[34]=h,e[35]=g,e[36]=a,e[37]=E):E=e[37];let R;e[38]!==A||e[39]!==T||e[40]!==E?(R=r.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Projects",children:[A,T,E]}),e[38]=A,e[39]=T,e[40]=E,e[41]=R):R=e[41];let $;return e[42]!==R||e[43]!==j?($=r.jsx(is,{className:"h-full",children:r.jsxs("main",{className:"mx-auto flex max-w-6xl flex-col gap-6 px-4 py-6 sm:px-6 sm:pb-10 sm:pt-14",children:[j,R]})}),e[42]=R,e[43]=j,e[44]=$):$=e[44],$}const gM=250,xM=400,ih={results:null,loading:!1,error:null};function ab(n,e){const t=y.useMemo(()=>Z2(n),[n]),[s,o]=y.useState(0),[i,a]=y.useState(ih);y.useEffect(()=>{if(!t){a(ih);return}const c=new AbortController;a({results:null,loading:!0,error:null});let d=null;const u=async()=>{const m=new URLSearchParams({search:n.trim(),limit:"200"});e&&m.set("project",e);try{const p=await ve(`/api/active-sessions?${m}`,{signal:c.signal});if(!p.ok)throw new Error(`Search failed (${p.status})`);const h=await p.json();if(c.signal.aborted)return;const g=Number(p.headers.get("X-Cogpit-PR-Index-Pending")??"0");if(Number.isFinite(g)&&g>0){d=setTimeout(()=>{u()},xM);return}a({results:Array.isArray(h)?h:[],loading:!1,error:null})}catch(p){if(c.signal.aborted)return;a({results:[],loading:!1,error:p instanceof Error?p.message:"Search failed"})}},f=setTimeout(()=>{u()},gM);return()=>{clearTimeout(f),d&&clearTimeout(d),c.abort()}},[e,t,n,s]);const l=y.useCallback(()=>o(c=>c+1),[]);return{...i,active:t!==null,refresh:l}}const bM=y.memo(function({onSelectSession:e,onNewSession:t,creatingSession:s,selectedProjectDirName:o,onSelectProject:i,onDuplicateSession:a,onDeleteSession:l}){const[c]=y.useState(()=>({projects:qi(Jn.projects),activeSessions:qi(Jn.activeSessions)})),[d,u]=y.useState(c.projects??[]),[f,m]=y.useState(c.activeSessions??[]),[p,h]=y.useState(c.projects===void 0),[g,x]=y.useState(!1),[b,w]=y.useState([]),[v,S]=y.useState(0),[j,k]=y.useState(1),[C,N]=y.useState(!1),[_,P]=y.useState(""),[A,T]=y.useState(null),E=y.useRef(0),R=y.useRef(null),$=y.useCallback(async(U=!1)=>{U&&x(!0);try{const[H,K]=await Promise.all([ve("/api/projects"),ve("/api/active-sessions")]);if(!H.ok||!K.ok)throw new Error("Failed to fetch dashboard data");const V=await H.json(),Y=await K.json(),G=Array.isArray(V)?V:[],J=Array.isArray(Y)?Y:[];u(G),m(J),tr(Jn.projects,G),tr(Jn.activeSessions,J),T(null)}catch(H){T(H instanceof Error?H.message:"Failed to load data")}finally{h(!1),x(!1)}},[]);y.useEffect(()=>{$()},[$]);const I=y.useCallback(async(U,H=1,K=!1)=>{var J;const V=++E.current;(J=R.current)==null||J.abort();const Y=new AbortController;R.current=Y;const G=()=>V===E.current;if(N(!0),T(null),!K){const Q=h_(U);Q?(w(Q.sessions),S(Q.total),k(1)):w([])}try{const Q=await ve(`/api/sessions/${encodeURIComponent(U)}?page=${H}&limit=20`,{signal:Y.signal});if(!Q.ok)throw new Error(`Failed to load sessions (${Q.status})`);const X=await Q.json();if(!G())return;const Z=Array.isArray(X.sessions)?X.sessions:[],te=typeof X.total=="number"?X.total:Z.length;w(ne=>K?[...ne,...Z]:Z),S(te),k(H),K||g_(U,{sessions:Z,total:te})}catch(Q){if(!G()||Y.signal.aborted)return;T(Q instanceof Error?Q.message:"Failed to load sessions")}finally{G()&&(R.current=null,N(!1))}},[]);y.useEffect(()=>{var U;if(!o){E.current+=1,(U=R.current)==null||U.abort(),R.current=null,w([]),S(0),k(1),P(""),N(!1);return}P(""),I(o)},[o,I]),y.useEffect(()=>()=>{var U;E.current+=1,(U=R.current)==null||U.abort()},[]);const M=y.useMemo(()=>{if(!o)return null;const U=d.find(K=>K.dirName===o);if(U)return U;const H=_n(o);return{dirName:o,path:H,shortName:Qn(H),sessionCount:v,lastModified:null}},[o,d,v]),D=y.useCallback(()=>{i==null||i(null)},[i]),O=y.useCallback(()=>{o&&I(o,j+1,!0)},[o,j,I]),L=ab(o?_:"",o??void 0),F=y.useMemo(()=>_?b.filter(U=>nM(U,_)):b,[b,_]),z=L.results??F;function W(U,H){l==null||l(U,H),w(K=>K.filter(V=>V.fileName!==H)),S(K=>K-1)}return M?r.jsx(cM,{selectedProject:M,sessions:b,sessionsTotal:v,sessionsLoading:C,searchLoading:L.loading,searchFilter:_,setSearchFilter:P,filteredSessions:z,fetchError:L.error??A,onSelectSession:e,onNewSession:t,creatingSession:s,onDuplicateSession:a,onDeleteSession:W,onBack:D,onRetryFetch:()=>{if(L.error){L.refresh();return}T(null),o&&I(o)},loadMoreSessions:O}):r.jsx(hM,{projects:d,activeSessions:f,loading:p,refreshing:g,searchFilter:_,setSearchFilter:P,fetchError:A,selectedProjectDirName:o??null,onSelectProject:i,onRefresh:()=>$(!0)})});async function lb(n,e,t){return(await ve(`/api/permissions/${encodeURIComponent(n)}/respond`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:e,behavior:t})})).ok}async function vM(n,e){return(await ve(`/api/permissions/${encodeURIComponent(n)}/respond-all`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({behavior:e})})).ok}async function cb(n,e){try{const t=await ve(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return{ok:t.ok,gone:t.status===404}}catch{return{ok:!1,gone:!1}}}function yM(n,e,t){return cb("/api/elicitation-answer",{sessionId:n,requestId:e,...t})}function wM(n,e,t){return cb("/api/user-dialog-answer",{sessionId:n,requestId:e,choice:t})}const jM=3e3,db=y.createContext(null);async function Jl(n,e){try{const t=await ve(n);if(!t.ok)return;const s=await t.text();return s===e.current?void 0:(e.current=s,JSON.parse(s))}catch{return}}function Uo(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 Ci(n,e,t){const s=new Map(n),o=(s.get(e)??[]).filter(i=>!t(i));return o.length>0?s.set(e,o):s.delete(e),s}function SM({children:n}){const[e,t]=y.useState(new Map),[s,o]=y.useState(new Map),[i,a]=y.useState(new Map),[l,c]=y.useState(new Map),[d,u]=y.useState(new Set),[f,m]=y.useState(new Set),p=y.useRef(""),h=y.useRef(""),g=y.useRef(""),x=y.useCallback(async()=>{const[T,E,R]=await Promise.all([Jl("/api/permissions",p),Jl("/api/user-questions",h),Jl("/api/agent-prompts",g)]);T&&(t(Uo(T.bySession)),u(new Set(Uo(T.plansBySession).keys()))),E&&o(Uo(E.bySession)),R&&(a(Uo(R.elicitationsBySession)),c(Uo(R.dialogsBySession)))},[]);y.useEffect(()=>{const T=()=>{document.visibilityState==="visible"&&x()};T();const E=setInterval(T,jM);return document.addEventListener("visibilitychange",T),()=>{clearInterval(E),document.removeEventListener("visibilitychange",T)}},[x]);const b=y.useCallback(async(T,E)=>{m(R=>new Set(R).add(T));try{return await E()}finally{m(R=>{const $=new Set(R);return $.delete(T),$}),x()}},[x]),w=y.useCallback((T,E,R)=>b(E,async()=>{await lb(T,E,R).catch(()=>!1)&&(t(I=>Ci(I,T,M=>M.requestId===E)),p.current="")}),[b]),v=y.useCallback((T,E,R)=>b(E,async()=>{const $=await ud(T,E,R);return $.ok&&(o(I=>Ci(I,T,M=>M.toolUseId===E)),h.current=""),$}),[b]),S=y.useCallback((T,E,R)=>b(E,async()=>{const $=await yM(T,E,R);return $.ok&&(a(I=>Ci(I,T,M=>M.requestId===E)),g.current=""),$}),[b]),j=y.useCallback((T,E,R)=>b(E,async()=>{const $=await wM(T,E,R);return $.ok&&(c(I=>Ci(I,T,M=>M.requestId===E)),g.current=""),$}),[b]),k=y.useMemo(()=>new Set(e.keys()),[e]),C=y.useMemo(()=>new Set(s.keys()),[s]),N=y.useMemo(()=>new Set(i.keys()),[i]),_=y.useMemo(()=>new Set(l.keys()),[l]),P=y.useCallback(()=>{x()},[x]),A=y.useMemo(()=>({permissionsBySession:e,questionsBySession:s,elicitationsBySession:i,dialogsBySession:l,awaitingPermission:k,awaitingQuestion:C,awaitingElicitation:N,awaitingDialog:_,awaitingPlan:d,responding:f,respond:w,answerQuestion:v,answerElicitation:S,answerDialog:j,refresh:P}),[e,s,i,l,k,C,N,_,d,f,w,v,S,j,P]);return r.jsx(db.Provider,{value:A,children:n})}function NM(){const n=y.useContext(db);if(!n)throw new Error("usePendingHumanInput must be used within a PendingHumanInputProvider");return n}const ub=typeof navigator<"u"&&"vibrate"in navigator;function Dc(){ub&&navigator.vibrate(10)}function kM(){ub&&navigator.vibrate(20)}function CM(n){return!!(n.teamName&&n.agentName)}function _M(n,e,t,s,o,i,a){const l=[],c=[];for(const d of Vd(n)){if(s!=null&&s.has(d.sessionId)){l.push({session:d,reason:"permission"});continue}if(o!=null&&o.has(d.sessionId)){l.push({session:d,reason:"question"});continue}if(i!=null&&i.has(d.sessionId)){l.push({session:d,reason:"prompt"});continue}if(a!=null&&a.has(d.sessionId)){l.push({session:d,reason:"plan"});continue}if(d.agentStatus==="deferred"){l.push({session:d,reason:"deferred"});continue}if(CM(d))continue;const u=c0(d,e);if(d.agentStatus==="completed"||!u){t.has(d.sessionId)&&l.push({session:d,reason:"done"});continue}if(d.agentStatus==="idle"){l.push({session:d,reason:"waiting"});continue}(!d.agentStatus||Yd.has(d.agentStatus))&&c.push(d)}return{needsYou:l,working:c}}function TM(n){switch(n.agentStatus){case"tool_use":return n.agentToolName||"Tool";case"thinking":return"Thinking";case"processing":return"Processing";case"compacting":return"Compacting";case"awaiting_agents":return"Agents running";default:return"Running"}}function Eu(n,e){return n?qt(n).externalProcesses&&(e==null?void 0:e.managed)===!1:!1}const fb="aw:turnCounts",EM=200,Xa=new Map;try{const n=localStorage.getItem(fb);if(n){const e=JSON.parse(n);for(const[t,s]of e)Xa.set(t,s)}}catch{}function PM(){try{const n=[...Xa.entries()].slice(-EM);localStorage.setItem(fb,JSON.stringify(n))}catch{}}function AM(n,e){Xa.set(Kt(n),e),PM()}function RM(n,e){const t=Xa.get(Kt(n));return Math.max(t??0,e??0)}function mb(n){const e=B.c(40),{session:t,proc:s,statusLabel:o,customName:i,worktreeName:a}=n,l=i||t.aiTitle,c=t.lastUserMessage||t.firstUserMessage,d=RM(t.sessionId,t.turnCount);let u;e[0]!==l?(u=l&&r.jsx("span",{className:"font-medium leading-snug text-foreground",children:l}),e[0]=l,e[1]=u):u=e[1];let f;e[2]!==t.agentStatus||e[3]!==o?(f=o&&r.jsx("span",{className:q("font-medium",Tu(t.agentStatus)),children:o}),e[2]=t.agentStatus,e[3]=o,e[4]=f):f=e[4];let m;e[5]!==t.agentName||e[6]!==t.teamName?(m=t.teamName&&t.agentName&&r.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[r.jsx(ts,{className:"size-3"}),t.agentName," · ",t.teamName]}),e[5]=t.agentName,e[6]=t.teamName,e[7]=m):m=e[7];let p;e[8]!==c?(p=c&&r.jsx("div",{className:"border-l-2 pl-2 text-muted-foreground",children:r.jsx("span",{className:"line-clamp-3 leading-relaxed",children:c})}),e[8]=c,e[9]=p):p=e[9];let h;e[10]!==t.pullRequests?(h=r.jsx(qa,{pullRequests:t.pullRequests,layout:"list"}),e[10]=t.pullRequests,e[11]=h):h=e[11];let g;e[12]!==t.gitBranch||e[13]!==a?(g=t.gitBranch&&r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx(Dn,{className:"size-2.5"}),a?`${t.gitBranch} · ${a}`:t.gitBranch]}),e[12]=t.gitBranch,e[13]=a,e[14]=g):g=e[14];let x;e[15]!==d?(x=d>0&&r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx(pa,{className:"size-2.5"}),d," ",d===1?"turn":"turns"]}),e[15]=d,e[16]=x):x=e[16];let b;e[17]!==t.size?(b=Ag(t.size),e[17]=t.size,e[18]=b):b=e[18];let w;e[19]!==b?(w=r.jsx("span",{children:b}),e[19]=b,e[20]=w):w=e[20];let v;e[21]!==s?(v=s&&r.jsxs("span",{className:"flex items-center gap-0.5 text-success",children:[r.jsx(T3,{className:"size-2.5"}),s.memMB," MB"]}),e[21]=s,e[22]=v):v=e[22];const S=t.lastActivityAt||t.lastModified;let j;e[23]!==S?(j=Ir(S),e[23]=S,e[24]=j):j=e[24];let k;e[25]!==j?(k=r.jsx("span",{children:j}),e[25]=j,e[26]=k):k=e[26];let C;e[27]!==v||e[28]!==k||e[29]!==g||e[30]!==x||e[31]!==w?(C=r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-muted-foreground",children:[g,x,w,v,k]}),e[27]=v,e[28]=k,e[29]=g,e[30]=x,e[31]=w,e[32]=C):C=e[32];let N;return e[33]!==u||e[34]!==C||e[35]!==f||e[36]!==m||e[37]!==p||e[38]!==h?(N=r.jsxs("div",{className:"flex w-64 flex-col gap-2 text-xs",children:[u,f,m,p,h,C]}),e[33]=u,e[34]=C,e[35]=f,e[36]=m,e[37]=p,e[38]=h,e[39]=N):N=e[39],N}const IM=120;function pb(n){const e=B.c(7),t=y.useRef(null);let s,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>()=>{t.current&&clearTimeout(t.current)},o=[],e[0]=s,e[1]=o):(s=e[0],o=e[1]),y.useEffect(s,o);let i;e[2]!==n?(i=()=>{n&&(t.current&&clearTimeout(t.current),t.current=setTimeout(n,IM))},e[2]=n,e[3]=i):i=e[3];const a=i;let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{t.current&&(clearTimeout(t.current),t.current=null)},e[4]=l):l=e[4];const c=l;let d;return e[5]!==a?(d={onHoverStart:a,onHoverEnd:c},e[5]=a,e[6]=d):d=e[6],d}const $M=6;function MM(n){const e=B.c(7),{iso:t}=n,[,s]=y.useState(0);let o;e[0]!==s?(o=()=>{const c=setInterval(()=>s(OM),15e3);return()=>clearInterval(c)},e[0]=s,e[1]=o):o=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=[],e[2]=i):i=e[2],y.useEffect(o,i);let a;e[3]!==t?(a=Ir(t),e[3]=t,e[4]=a):a=e[4];let l;return e[5]!==a?(l=r.jsx("span",{"data-relative-time":!0,className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:a}),e[5]=a,e[6]=l):l=e[6],l}function OM(n){return n+1}const DM={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"}},LM={permission:zs.attention,deferred:zs.attention,waiting:zs.attention,question:"bg-warning",prompt:"bg-warning",plan:"bg-warning",done:"bg-success"};function ah(n){const e=B.c(76),{session:t,chip:s,dotClassName:o,cardClassName:i,isActiveSession:a,proc:l,killingPids:c,customName:d,projectLabel:u,compact:f,onSelect:m,onKill:p,onResume:h,onPrefetch:g}=n,x=f===void 0?!1:f;let b;e[0]!==l||e[1]!==t.dirName?(b=Eu(Et(t.dirName),l),e[0]=l,e[1]=t.dirName,e[2]=b):b=e[2];const w=b;let v;e[3]!==s||e[4]!==w||e[5]!==t.agentPendingAgents||e[6]!==t.agentStatus||e[7]!==t.agentTerminalReason||e[8]!==t.agentToolName?(v=w?"Read-only":Vr(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??s.label,e[3]=s,e[4]=w,e[5]=t.agentPendingAgents,e[6]=t.agentStatus,e[7]=t.agentTerminalReason,e[8]=t.agentToolName,e[9]=v):v=e[9];const S=v,j=!!h&&!w,{onHoverStart:k,onHoverEnd:C}=pb(g),N=x?"px-2.5 py-2":"border px-2 py-2",_=a&&!x&&"ring-1 ring-ring";let P;e[10]!==i||e[11]!==N||e[12]!==_?(P=q("group relative w-full rounded-md text-left transition-colors",N,i,_),e[10]=i,e[11]=N,e[12]=_,e[13]=P):P=e[13];let A;e[14]!==x||e[15]!==a?(A=x&&a&&r.jsx("span",{className:"absolute inset-y-2 left-0 w-0.5 rounded-full bg-primary","aria-hidden":"true"}),e[14]=x,e[15]=a,e[16]=A):A=e[16];const T=j&&"pr-20";let E;e[17]!==T?(E=q("w-full rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",T),e[17]=T,e[18]=E):E=e[18];let R;e[19]!==C||e[20]!==k||e[21]!==m||e[22]!==E?(R=r.jsx("button",{type:"button","data-attention-session":!0,onClick:m,onMouseEnter:k,onMouseLeave:C,onFocus:k,onBlur:C,className:E}),e[19]=C,e[20]=k,e[21]=m,e[22]=E,e[23]=R):R=e[23];const $=x&&"ring-0";let I;e[24]!==o||e[25]!==$?(I=q("size-1.5 shrink-0 rounded-full",o,$),e[24]=o,e[25]=$,e[26]=I):I=e[26];let M;e[27]!==I?(M=r.jsx("span",{className:I,"aria-hidden":"true"}),e[27]=I,e[28]=M):M=e[28];let D;e[29]!==d||e[30]!==t?(D=a0(t,d),e[29]=d,e[30]=t,e[31]=D):D=e[31];let O;e[32]!==D?(O=r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs leading-tight text-foreground",children:D}),e[32]=D,e[33]=O):O=e[33];const L=x?"text-muted-foreground":s.className;let F;e[34]!==L?(F=q("shrink-0",L),e[34]=L,e[35]=F):F=e[35];const z=w?"Read-only":s.label;let W;e[36]!==F||e[37]!==z?(W=r.jsx(_e,{variant:"outline",className:F,children:z}),e[36]=F,e[37]=z,e[38]=W):W=e[38];let U;e[39]!==x||e[40]!==t.lastActivityAt||e[41]!==t.lastModified?(U=!x&&r.jsx(MM,{iso:t.lastActivityAt||t.lastModified}),e[39]=x,e[40]=t.lastActivityAt,e[41]=t.lastModified,e[42]=U):U=e[42];let H;e[43]!==M||e[44]!==O||e[45]!==W||e[46]!==U?(H=r.jsxs("span",{className:"flex items-center gap-1.5",children:[M,O,W,U]}),e[43]=M,e[44]=O,e[45]=W,e[46]=U,e[47]=H):H=e[47];let K;e[48]!==u?(K=r.jsx("span",{className:"mt-1 block truncate pl-3 text-xs text-muted-foreground",children:u}),e[48]=u,e[49]=K):K=e[49];let V;e[50]!==R||e[51]!==H||e[52]!==K?(V=r.jsxs(Rt,{render:R,children:[H,K]}),e[50]=R,e[51]=H,e[52]=K,e[53]=V):V=e[53];let Y;e[54]!==d||e[55]!==l||e[56]!==t||e[57]!==S?(Y=r.jsx(It,{side:"right",className:"max-w-[280px]",children:r.jsx(mb,{session:t,proc:l,statusLabel:S,customName:d})}),e[54]=d,e[55]=l,e[56]=t,e[57]=S,e[58]=Y):Y=e[58];let G;e[59]!==V||e[60]!==Y?(G=r.jsxs(At,{children:[V,Y]}),e[59]=V,e[60]=Y,e[61]=G):G=e[61];let J;e[62]!==j||e[63]!==h?(J=j&&r.jsxs(ee,{type:"button",variant:"outline",size:"xs",onClick:h,className:"absolute bottom-1 right-1 text-warning","aria-label":"Resume to evaluate",children:[r.jsx(_r,{"data-icon":"inline-start"}),"Resume"]}),e[62]=j,e[63]=h,e[64]=J):J=e[64];let Q;e[65]!==w||e[66]!==c||e[67]!==p||e[68]!==l?(Q=l&&p&&!w&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:Z=>p(l.pid,Z),disabled:c.has(l.pid),className:"absolute right-0 top-0 text-destructive opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",title:`Kill PID ${l.pid}`,"aria-label":`Kill process ${l.pid}`,children:r.jsx(rt,{"data-icon":"inline-start"})}),e[65]=w,e[66]=c,e[67]=p,e[68]=l,e[69]=Q):Q=e[69];let X;return e[70]!==G||e[71]!==J||e[72]!==Q||e[73]!==P||e[74]!==A?(X=r.jsxs("div",{className:P,children:[A,G,J,Q]}),e[70]=G,e[71]=J,e[72]=Q,e[73]=P,e[74]=A,e[75]=X):X=e[75],X}function zM(n){const e=B.c(15),{dotClassName:t,labelClassName:s,label:o,count:i}=n;let a;e[0]!==t?(a=q("size-1.5 rounded-full",t),e[0]=t,e[1]=a):a=e[1];let l;e[2]!==a?(l=r.jsx("span",{className:a,"aria-hidden":"true"}),e[2]=a,e[3]=l):l=e[3];let c;e[4]!==s?(c=q("text-xs font-medium",s),e[4]=s,e[5]=c):c=e[5];let d;e[6]!==o||e[7]!==c?(d=r.jsx("span",{className:c,children:o}),e[6]=o,e[7]=c,e[8]=d):d=e[8];let u;e[9]!==i?(u=r.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:i}),e[9]=i,e[10]=u):u=e[10];let f;return e[11]!==l||e[12]!==d||e[13]!==u?(f=r.jsxs("div",{className:"flex items-center gap-1.5 px-0.5",children:[l,d,u]}),e[11]=l,e[12]=d,e[13]=u,e[14]=f):f=e[14],f}function FM(n){const e=B.c(27),{groups:t,activeSessionKey:s,procBySession:o,killingPids:i,sessionNames:a,projectNames:l,onSelectSession:c,onKill:d,onResumeSession:u,onPrefetchSession:f}=n,[m,p]=y.useState(!1);let h;e[0]!==t.working||e[1]!==m?(h=m?t.working:t.working.slice(0,$M),e[0]=t.working,e[1]=m,e[2]=h):h=e[2];const g=h,x=t.working.length-g.length;let b;e[3]!==l?(b=N=>l[N.dirName]||Gd(N.cwd||_n(N.dirName)),e[3]=l,e[4]=b):b=e[4];const w=b;let v;e[5]!==s||e[6]!==i||e[7]!==f||e[8]!==c||e[9]!==o||e[10]!==w||e[11]!==a?(v=N=>{const _=s===`${N.dirName}/${N.fileName}`;return{session:N,isActiveSession:_,proc:o.get(N.sessionId),killingPids:i,customName:a[N.sessionId],projectLabel:w(N),onSelect:()=>c(N.dirName,N.fileName),onPrefetch:f&&!_?()=>f(N.dirName,N.fileName):void 0}},e[5]=s,e[6]=i,e[7]=f,e[8]=c,e[9]=o,e[10]=w,e[11]=a,e[12]=v):v=e[12];const S=v;let j;e[13]!==t.needsYou||e[14]!==d||e[15]!==u||e[16]!==S?(j=t.needsYou.length>0&&r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx(zM,{dotClassName:zs.attention,labelClassName:"text-warning",label:"Needs you",count:t.needsYou.length}),t.needsYou.map(N=>{const{session:_,reason:P}=N;return r.jsx(ah,{...S(_),chip:DM[P],dotClassName:LM[P],cardClassName:"border-warning/20 bg-warning/5 hover:bg-warning/10",onKill:d,onResume:P==="deferred"&&u?()=>u(_.sessionId,_.cwd,_.dirName):void 0},`${_.dirName}/${_.fileName}`)})]}),e[13]=t.needsYou,e[14]=d,e[15]=u,e[16]=S,e[17]=j):j=e[17];let k;e[18]!==t.working.length||e[19]!==x||e[20]!==d||e[21]!==S||e[22]!==g?(k=t.working.length>0&&r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsxs("div",{className:"flex items-center justify-between px-1",children:[r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Working"}),r.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:t.working.length})]}),r.jsx("div",{"data-working-list":!0,className:"flex flex-col gap-0.5 overflow-hidden rounded-lg border bg-background p-0.5",children:g.map(N=>r.jsx(ah,{...S(N),chip:{label:TM(N),className:""},dotClassName:zs.working,cardClassName:"hover:bg-accent/50",compact:!0,onKill:d},`${N.dirName}/${N.fileName}`))}),x>0&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>p(!0),className:"justify-start",children:[r.jsx(tt,{"data-icon":"inline-start"}),"Show ",x," more"]})]}),e[18]=t.working.length,e[19]=x,e[20]=d,e[21]=S,e[22]=g,e[23]=k):k=e[23];let C;return e[24]!==j||e[25]!==k?(C=r.jsxs("div",{className:"flex flex-col gap-2","data-attention-strip":!0,children:[j,k]}),e[24]=j,e[25]=k,e[26]=C):C=e[26],C}function BM(n){const e=B.c(26),{loading:t,isMobile:s,searchQuery:o,searchLoading:i,onSearchQueryChange:a,onRefresh:l}=n;let c;e[0]!==a?(c=v=>a(v.target.value),e[0]=a,e[1]=c):c=e[1];let d;e[2]!==i||e[3]!==o||e[4]!==c?(d=r.jsx(ls,{type:"search",value:o,onChange:c,placeholder:"Search sessions or PRs","aria-label":"Search sessions by project, branch, title, prompt, PR number, or PR URL","aria-busy":i}),e[2]=i,e[3]=o,e[4]=c,e[5]=d):d=e[5];let u;e[6]!==i?(u=r.jsx(Pn,{align:"inline-start",children:i?r.jsx(ot,{className:"animate-spin"}):r.jsx(gn,{})}),e[6]=i,e[7]=u):u=e[7];let f;e[8]!==a||e[9]!==o?(f=o&&r.jsx(Pn,{align:"inline-end",children:r.jsx(Fr,{size:"icon-xs",onClick:()=>a(""),"aria-label":"Clear session search",children:r.jsx(rt,{"data-icon":"inline-start"})})}),e[8]=a,e[9]=o,e[10]=f):f=e[10];let m;e[11]!==d||e[12]!==u||e[13]!==f?(m=r.jsxs(as,{children:[d,u,f]}),e[11]=d,e[12]=u,e[13]=f,e[14]=m):m=e[14];const p=s?"icon-sm":"icon-xs",h=t&&"animate-spin";let g;e[15]!==h?(g=q(h),e[15]=h,e[16]=g):g=e[16];let x;e[17]!==g?(x=r.jsx(Ot,{"data-icon":"inline-start",className:g}),e[17]=g,e[18]=x):x=e[18];let b;e[19]!==l||e[20]!==p||e[21]!==x?(b=r.jsx(ee,{variant:"ghost",size:p,onClick:l,"aria-label":"Refresh sessions",children:x}),e[19]=l,e[20]=p,e[21]=x,e[22]=b):b=e[22];let w;return e[23]!==b||e[24]!==m?(w=r.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b px-2.5 py-2",children:[m,b]}),e[23]=b,e[24]=m,e[25]=w):w=e[25],w}const UM=["first","second","third","fourth","fifth"];function WM(n){const e=B.c(13),{fetchError:t,showEmpty:s,searching:o,loading:i,sessionCount:a,onRetry:l}=n;let c;e[0]!==t||e[1]!==l?(c=t&&r.jsxs(ht,{variant:"destructive",children:[r.jsx(xn,{}),r.jsx(Tt,{children:"Could not load sessions"}),r.jsx(gt,{className:"truncate",children:t}),r.jsx(Cs,{children:r.jsx(ee,{variant:"outline",size:"xs",onClick:l,children:"Retry"})})]}),e[0]=t,e[1]=l,e[2]=c):c=e[2];let d;e[3]!==o||e[4]!==s?(d=s&&r.jsx(ln,{className:"min-h-56 px-4 py-8",children:r.jsxs(cn,{children:[r.jsx(bn,{variant:"icon",children:o?r.jsx(gn,{}):r.jsx(sg,{})}),r.jsx(dn,{children:o?"No matching sessions":"No sessions yet"}),r.jsx(vn,{children:o?"Try #157, honest-cms #157, or paste a PR URL.":"Start Claude Code, Codex, or Copilot to see recent work here."})]})}),e[3]=o,e[4]=s,e[5]=d):d=e[5];let u;e[6]!==i||e[7]!==a?(u=i&&a===0&&r.jsx("div",{className:"flex flex-col gap-2 px-2 py-4","aria-label":"Loading sessions",children:UM.map(HM)}),e[6]=i,e[7]=a,e[8]=u):u=e[8];let f;return e[9]!==c||e[10]!==d||e[11]!==u?(f=r.jsxs(r.Fragment,{children:[c,d,u]}),e[9]=c,e[10]=d,e[11]=u,e[12]=f):f=e[12],f}function HM(n){return r.jsxs("div",{className:"flex items-center gap-2 py-1",children:[r.jsx(ft,{className:"size-2 shrink-0 rounded-full"}),r.jsx(ft,{className:"h-4 flex-1"}),r.jsx(ft,{className:"h-4 w-10"})]},n)}function KM(n){var ye;const e=B.c(116),{session:t,isActiveSession:s,proc:o,killingPids:i,isNewlyCompleted:a,customName:l,worktreeName:c,teammateCount:d,teammatesCollapsed:u,onToggleTeammates:f,onSelectSession:m,onKill:p,onDuplicateSession:h,onDeleteSession:g,onRenameSession:x,onPrefetchSession:b,onResumeSession:w}=n,v=o!==void 0,S=t.isActive===!0,j=v||S,k=S&&Sr(t.agentStatus),C=t.agentStatus==="deferred";let N;e[0]!==o||e[1]!==t.dirName?(N=Eu(Et(t.dirName),o),e[0]=o,e[1]=t.dirName,e[2]=N):N=e[2];const _=N,[P,A]=y.useState(!1),T=_?"Read-only":j?k?"Running":Vr(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??"Running":null,E=C?"attention":j?Sr(t.agentStatus)?"idle":"working":null,R=!!(t.teamName&&t.agentName);let $;e[3]!==l||e[4]!==t?($=a0(t,l),e[3]=l,e[4]=t,e[5]=$):$=e[5];const I=$;let M;e[6]!==s||e[7]!==b||e[8]!==t.dirName||e[9]!==t.fileName?(M=b&&!s?()=>b(t.dirName,t.fileName):void 0,e[6]=s,e[7]=b,e[8]=t.dirName,e[9]=t.fileName,e[10]=M):M=e[10];const{onHoverStart:D,onHoverEnd:O}=pb(M);let L;e[11]!==w||e[12]!==P||e[13]!==t.cwd||e[14]!==t.dirName||e[15]!==t.sessionId?(L=xe=>{xe.stopPropagation(),!(!w||P)&&(A(!0),w(t.sessionId,t.cwd,t.dirName),setTimeout(()=>A(!1),3e3))},e[11]=w,e[12]=P,e[13]=t.cwd,e[14]=t.dirName,e[15]=t.sessionId,e[16]=L):L=e[16];const F=L;let z;e[17]!==v||e[18]!==s||e[19]!==S||e[20]!==a||e[21]!==t.agentStatus?(z=q("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",qM(s,!S&&v&&t.agentStatus==="completed"&&!!a)),e[17]=v,e[18]=s,e[19]=S,e[20]=a,e[21]=t.agentStatus,e[22]=z):z=e[22];const W=At,U=Rt;let H;e[23]!==m||e[24]!==t.dirName||e[25]!==t.fileName?(H=()=>m(t.dirName,t.fileName),e[23]=m,e[24]=t.dirName,e[25]=t.fileName,e[26]=H):H=e[26];let K;e[27]!==O||e[28]!==D||e[29]!==H?(K=r.jsx("button",{type:"button","data-live-session":!0,onClick:H,onMouseEnter:D,onMouseLeave:O,onFocus:D,onBlur:O,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring"}),e[27]=O,e[28]=D,e[29]=H,e[30]=K):K=e[30];let V;e[31]!==E?(V=E&&r.jsx("span",{"data-status-dot":E,className:q("size-1.5 rounded-full",zs[E])}),e[31]=E,e[32]=V):V=e[32];let Y;e[33]!==V?(Y=r.jsx("span",{className:"flex w-1.5 shrink-0 items-center justify-center","aria-hidden":"true",children:V}),e[33]=V,e[34]=Y):Y=e[34];let G;e[35]!==I?(G=r.jsx("span",{className:"flex-1 truncate text-sm leading-tight text-foreground",children:I}),e[35]=I,e[36]=G):G=e[36];let J;e[37]!==R||e[38]!==t.agentName||e[39]!==I?(J=R&&r.jsxs(_e,{variant:"outline",children:[r.jsx(yo,{"data-icon":"inline-start"}),I!==t.agentName?t.agentName:"Agent"]}),e[37]=R,e[38]=t.agentName,e[39]=I,e[40]=J):J=e[40];const Q=j&&!C&&T&&r.jsx(_e,{variant:"secondary","data-session-live-state":!0,className:q("shrink-0",k&&"text-success",!k&&Tu(t.agentStatus)),children:T});let X;e[41]!==C?(X=C&&r.jsx(_e,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"deferred"}),e[41]=C,e[42]=X):X=e[42];let Z;e[43]!==c?(Z=c&&r.jsxs(_e,{variant:"outline",children:[r.jsx(Dn,{"data-icon":"inline-start"}),c]}),e[43]=c,e[44]=Z):Z=e[44];let te;e[45]!==U||e[46]!==G||e[47]!==J||e[48]!==Q||e[49]!==X||e[50]!==Z||e[51]!==K||e[52]!==Y?(te=r.jsxs(U,{render:K,children:[Y,G,J,Q,X,Z]}),e[45]=U,e[46]=G,e[47]=J,e[48]=Q,e[49]=X,e[50]=Z,e[51]=K,e[52]=Y,e[53]=te):te=e[53];let ne;e[54]!==l||e[55]!==o||e[56]!==t||e[57]!==T||e[58]!==c?(ne=r.jsx(It,{side:"right",className:"max-w-[280px]",children:r.jsx(mb,{session:t,proc:o,statusLabel:T,customName:l,worktreeName:c})}),e[54]=l,e[55]=o,e[56]=t,e[57]=T,e[58]=c,e[59]=ne):ne=e[59];let re;e[60]!==W||e[61]!==te||e[62]!==ne?(re=r.jsxs(W,{children:[te,ne]}),e[60]=W,e[61]=te,e[62]=ne,e[63]=re):re=e[63];let ie;e[64]!==f||e[65]!==d||e[66]!==u?(ie=!!d&&f&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:f,className:"shrink-0",title:u?"Show team agents":"Hide team agents","aria-label":u?`Show ${d} team agents`:`Hide ${d} team agents`,"aria-expanded":!u,children:[r.jsx(ts,{"data-icon":"inline-start"}),d,r.jsx(Je,{"data-icon":"inline-end",className:q("transition-transform duration-150",!u&&"rotate-90")})]}),e[64]=f,e[65]=d,e[66]=u,e[67]=ie):ie=e[67];let ae;e[68]!==F||e[69]!==C||e[70]!==_||e[71]!==w||e[72]!==P?(ae=C&&w&&!_&&r.jsxs(ee,{type:"button",variant:"outline",size:"xs",onClick:F,disabled:P,className:"shrink-0 text-warning",title:"Resume to evaluate deferred permission","aria-label":"Resume to evaluate",children:[r.jsx(_r,{"data-icon":"inline-start"}),"Resume"]}),e[68]=F,e[69]=C,e[70]=_,e[71]=w,e[72]=P,e[73]=ae):ae=e[73];let se;e[74]!==t.matchedPullRequestNumber||e[75]!==t.pullRequests?(se=t.matchedPullRequestNumber?r.jsxs(_e,{variant:"outline",className:"shrink-0 px-1",children:["Matched #",t.matchedPullRequestNumber]}):r.jsx(qa,{pullRequests:t.pullRequests,max:1,compact:!0}),e[74]=t.matchedPullRequestNumber,e[75]=t.pullRequests,e[76]=se):se=e[76];const ue=t.lastActivityAt||t.lastModified;let le;e[77]!==ue?(le=Ir(ue),e[77]=ue,e[78]=le):le=e[78];let de;e[79]!==le?(de=r.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:le}),e[79]=le,e[80]=de):de=e[80];let pe;e[81]!==v||e[82]!==_||e[83]!==i||e[84]!==p||e[85]!==o?(pe=v&&p&&!_&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:xe=>p(o.pid,xe),disabled:i.has(o.pid),className:"absolute right-0 top-0 text-destructive opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",title:`Kill PID ${o.pid}`,"aria-label":`Kill process ${o.pid}`,children:r.jsx(rt,{"data-icon":"inline-start"})}),e[81]=v,e[82]=_,e[83]=i,e[84]=p,e[85]=o,e[86]=pe):pe=e[86];let he;e[87]!==re||e[88]!==ie||e[89]!==ae||e[90]!==se||e[91]!==de||e[92]!==pe||e[93]!==z?(he=r.jsxs("div",{className:z,children:[re,ie,ae,se,de,pe]}),e[87]=re,e[88]=ie,e[89]=ae,e[90]=se,e[91]=de,e[92]=pe,e[93]=z,e[94]=he):he=e[94];const ce=he;if(h||g||x){let xe;e[95]!==t.firstUserMessage||e[96]!==t.sessionId||e[97]!==t.slug?(xe=t.slug||((ye=t.firstUserMessage)==null?void 0:ye.slice(0,30))||t.sessionId.slice(0,12),e[95]=t.firstUserMessage,e[96]=t.sessionId,e[97]=t.slug,e[98]=xe):xe=e[98];let me;e[99]!==h||e[100]!==t.dirName||e[101]!==t.fileName?(me=h?()=>h(t.dirName,t.fileName):void 0,e[99]=h,e[100]=t.dirName,e[101]=t.fileName,e[102]=me):me=e[102];let je;e[103]!==g||e[104]!==t?(je=g?()=>g(t):void 0,e[103]=g,e[104]=t,e[105]=je):je=e[105];let Se;e[106]!==x||e[107]!==t.sessionId?(Se=x?Re=>x(t.sessionId,Re):void 0,e[106]=x,e[107]=t.sessionId,e[108]=Se):Se=e[108];let Pe;return e[109]!==l||e[110]!==ce||e[111]!==xe||e[112]!==me||e[113]!==je||e[114]!==Se?(Pe=r.jsx(q2,{sessionLabel:xe,customName:l,onDuplicate:me,onDelete:je,onRename:Se,children:ce}),e[109]=l,e[110]=ce,e[111]=xe,e[112]=me,e[113]=je,e[114]=Se,e[115]=Pe):Pe=e[115],Pe}return ce}function qM(n,e){return n?"bg-accent":e?"bg-success/10":"hover:bg-accent/60"}function VM(n,e){return n.reduce((t,s)=>s.isActive?t+1:e.has(s.sessionId)?s.agentStatus==="completed"?t:t+1:t,0)}function GM(n){const e=B.c(36),{grouped:t,pendingProjectPath:s,pendingSession:o,collapsedGroups:i,searchQuery:a,activeSessionKey:l,procBySession:c,killingPids:d,newlyCompleted:u,sessionNames:f,projectNames:m,onToggleCollapsed:p,onSelectSession:h,onKill:g,onDuplicateSession:x,onDeleteSession:b,onRenameSession:w,onRenameProject:v,onNewSession:S,creatingSession:j,onPrefetchSession:k,onResumeSession:C}=n;let N;e[0]!==l||e[1]!==j||e[2]!==d||e[3]!==u||e[4]!==b||e[5]!==x||e[6]!==g||e[7]!==S||e[8]!==k||e[9]!==v||e[10]!==w||e[11]!==C||e[12]!==h||e[13]!==p||e[14]!==c||e[15]!==m||e[16]!==f?(N={activeSessionKey:l,procBySession:c,killingPids:d,newlyCompleted:u,sessionNames:f,projectNames:m,onToggleCollapsed:p,onSelectSession:h,onKill:g,onDuplicateSession:x,onDeleteSession:b,onRenameSession:w,onRenameProject:v,onNewSession:S,creatingSession:j,onPrefetchSession:k,onResumeSession:C},e[0]=l,e[1]=j,e[2]=d,e[3]=u,e[4]=b,e[5]=x,e[6]=g,e[7]=S,e[8]=k,e[9]=v,e[10]=w,e[11]=C,e[12]=h,e[13]=p,e[14]=c,e[15]=m,e[16]=f,e[17]=N):N=e[17];const _=N;let P;e[18]!==a?(P=a.trim(),e[18]=a,e[19]=P):P=e[19];const A=!!P;let T;e[20]!==i||e[21]!==A||e[22]!==t||e[23]!==s||e[24]!==o||e[25]!==c||e[26]!==_?(T=[...t.entries()].map(($,I)=>{const[M,D]=$,O=VM(D,c);return y.createElement(lh,{..._,key:M,projectPath:M,sessions:D,liveCount:O,collapsed:i[M]??(I>=3&&O===0),forceExpand:A,pendingSession:s===M?o:void 0})}),e[20]=i,e[21]=A,e[22]=t,e[23]=s,e[24]=o,e[25]=c,e[26]=_,e[27]=T):T=e[27];let E;e[28]!==t||e[29]!==s||e[30]!==o||e[31]!==_?(E=s&&!t.has(s)&&o&&y.createElement(lh,{..._,key:`pending-${s}`,projectPath:s,sessions:[],liveCount:0,collapsed:!1,pendingSession:o}),e[28]=t,e[29]=s,e[30]=o,e[31]=_,e[32]=E):E=e[32];let R;return e[33]!==T||e[34]!==E?(R=r.jsxs(r.Fragment,{children:[T,E]}),e[33]=T,e[34]=E,e[35]=R):R=e[35],R}function lh(n){var We,Fe;const e=B.c(99),{projectPath:t,sessions:s,activeSessionKey:o,procBySession:i,killingPids:a,newlyCompleted:l,sessionNames:c,projectNames:d,liveCount:u,collapsed:f,onToggleCollapsed:m,forceExpand:p,onSelectSession:h,onKill:g,onDuplicateSession:x,onDeleteSession:b,onRenameSession:w,onRenameProject:v,onNewSession:S,creatingSession:j,pendingSession:k,onPrefetchSession:C,onResumeSession:N}=n,_=p===void 0?!1:p,P=y.useId(),A=!!k,T=_||A?!1:f;let E;e[0]!==s?(E=new Set(s.map(XM)),e[0]=s,e[1]=E):E=e[1];const R=E;let $;if(e[2]!==R||e[3]!==s){const Ne=new Map,fe=[];for(const Oe of s){const Ae=Oe.teamLeadSessionId;if(Ae&&Ae!==Oe.sessionId&&R.has(Ae)){const Be=Ne.get(Ae);Be?Be.push(Oe):Ne.set(Ae,[Oe])}else fe.push(Oe)}$={topLevelSessions:fe,teammatesByLead:Ne},e[2]=R,e[3]=s,e[4]=$}else $=e[4];const{topLevelSessions:I,teammatesByLead:M}=$;let D;e[5]===Symbol.for("react.memo_cache_sentinel")?(D=new Set,e[5]=D):D=e[5];const[O,L]=y.useState(D);let F;e[6]===Symbol.for("react.memo_cache_sentinel")?(F=Ne=>{L(fe=>{const Oe=new Set(fe);return Oe.has(Ne)?Oe.delete(Ne):Oe.add(Ne),Oe})},e[6]=F):F=e[6];const z=F,[W,U]=y.useState(!1),H=s.length+(A?1:0);let K,V;e[7]!==_||e[8]!==A||e[9]!==i||e[10]!==W||e[11]!==I?(K=a_(I,i,Math.max(1,5-(A?1:0))),V=_||W?I:I.slice(0,K),e[7]=_,e[8]=A,e[9]=i,e[10]=W,e[11]=I,e[12]=K,e[13]=V):(K=e[12],V=e[13]);const Y=V,G=I.length-Y.length,J=W&&!_&&I.length>K,Q=((We=s.find(YM))==null?void 0:We.dirName)??((Fe=s[0])==null?void 0:Fe.dirName)??(k==null?void 0:k.dirName),X=Q?d[Q]:void 0;let Z;e[14]!==o||e[15]!==a||e[16]!==l||e[17]!==b||e[18]!==x||e[19]!==g||e[20]!==C||e[21]!==w||e[22]!==N||e[23]!==h||e[24]!==i||e[25]!==c?(Z=function(fe,Oe,Ae){return r.jsx(KM,{session:fe,isActiveSession:o===`${fe.dirName}/${fe.fileName}`,proc:i.get(fe.sessionId),killingPids:a,isNewlyCompleted:l.has(fe.sessionId),customName:c[fe.sessionId],worktreeName:Oe,teammateCount:Ae==null?void 0:Ae.count,teammatesCollapsed:Ae==null?void 0:Ae.collapsed,onToggleTeammates:Ae==null?void 0:Ae.onToggle,onSelectSession:h,onKill:g,onDuplicateSession:x,onDeleteSession:b,onRenameSession:w,onPrefetchSession:C,onResumeSession:N},`${fe.dirName}/${fe.fileName}`)},e[14]=o,e[15]=a,e[16]=l,e[17]=b,e[18]=x,e[19]=g,e[20]=C,e[21]=w,e[22]=N,e[23]=h,e[24]=i,e[25]=c,e[26]=Z):Z=e[26];const te=Z,ne=!T;let re;e[27]!==Q||e[28]!==v?(re=Ne=>{Q&&v&&v(Q,Ne)},e[27]=Q,e[28]=v,e[29]=re):re=e[29];let ie;e[30]!==f||e[31]!==m||e[32]!==t?(ie=()=>m(t,!f),e[30]=f,e[31]=m,e[32]=t,e[33]=ie):ie=e[33];const ae=!T,se=_?"Groups stay expanded while searching":void 0,ue=!T&&"rotate-90";let le;e[34]!==ue?(le=q("size-3 shrink-0 text-muted-foreground transition-transform duration-150",ue),e[34]=ue,e[35]=le):le=e[35];let de;e[36]!==le?(de=r.jsx(Je,{className:le}),e[36]=le,e[37]=de):de=e[37];const pe=X||t;let he;e[38]!==pe?(he=r.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:pe}),e[38]=pe,e[39]=he):he=e[39];let ce;e[40]!==X||e[41]!==t?(ce=X&&r.jsx("span",{className:"truncate text-xs text-muted-foreground",children:t}),e[40]=X,e[41]=t,e[42]=ce):ce=e[42];let ye;e[43]!==u?(ye=u>0&&r.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs font-medium text-success","aria-label":`${u} live sessions`,children:[r.jsx(Na,{className:"size-1.5","aria-hidden":"true"}),u]}),e[43]=u,e[44]=ye):ye=e[44];let xe;e[45]!==H?(xe=r.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:H}),e[45]=H,e[46]=xe):xe=e[46];let me;e[47]!==_||e[48]!==P||e[49]!==ie||e[50]!==ae||e[51]!==se||e[52]!==de||e[53]!==he||e[54]!==ce||e[55]!==ye||e[56]!==xe?(me=r.jsxs("button",{type:"button",onClick:ie,disabled:_,"aria-expanded":ae,"aria-controls":P,title:se,className:"flex min-w-0 flex-1 items-center gap-1 rounded-md px-1 py-1 text-left transition-colors hover:bg-accent",children:[de,he,ce,ye,xe]}),e[47]=_,e[48]=P,e[49]=ie,e[50]=ae,e[51]=se,e[52]=de,e[53]=he,e[54]=ce,e[55]=ye,e[56]=xe,e[57]=me):me=e[57];let je;e[58]!==j||e[59]!==S||e[60]!==t||e[61]!==s[0]||e[62]!==s.length?(je=S&&s.length>0&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",className:"shrink-0",disabled:j,onClick:Ne=>{Ne.stopPropagation();const fe=s[0];S(fe.dirName,fe.cwd??void 0)},"aria-label":`New session in ${t}`,children:j?r.jsx(ot,{"data-icon":"inline-start",className:"animate-spin"}):r.jsx(Ln,{"data-icon":"inline-start"})}),e[58]=j,e[59]=S,e[60]=t,e[61]=s[0],e[62]=s.length,e[63]=je):je=e[63];let Se;e[64]!==me||e[65]!==je?(Se=r.jsxs("div",{className:"flex w-full items-center gap-1 px-2 pb-1 pt-3",children:[me,je]}),e[64]=me,e[65]=je,e[66]=Se):Se=e[66];let Pe;e[67]!==X||e[68]!==t||e[69]!==Se||e[70]!==re?(Pe=r.jsx(sb,{projectLabel:t,customName:X,className:"sticky top-0 z-20 bg-background",onRename:re,children:Se}),e[67]=X,e[68]=t,e[69]=Se,e[70]=re,e[71]=Pe):Pe=e[71];let Re;e[72]!==k?(Re=k&&r.jsx(JM,{firstMessage:k.firstMessage}),e[72]=k,e[73]=Re):Re=e[73];let Ie;if(e[74]!==O||e[75]!==te||e[76]!==M||e[77]!==Y){let Ne;e[79]!==O||e[80]!==te||e[81]!==M?(Ne=fe=>{const Oe=fe.cwd??_n(fe.dirName),Ae=wa(Oe),Be=M.get(fe.sessionId);if(!Be)return te(fe,Ae==null?void 0:Ae.worktreeName);const oe=O.has(fe.sessionId);return r.jsxs("div",{className:"flex flex-col gap-px",children:[te(fe,Ae==null?void 0:Ae.worktreeName,{count:Be.length,collapsed:oe,onToggle:()=>z(fe.sessionId)}),!oe&&r.jsx("div",{className:"ml-3 flex flex-col gap-px border-l pl-1",children:Be.map(ge=>te(ge))})]},`${fe.dirName}/${fe.fileName}`)},e[79]=O,e[80]=te,e[81]=M,e[82]=Ne):Ne=e[82],Ie=Y.map(Ne),e[74]=O,e[75]=te,e[76]=M,e[77]=Y,e[78]=Ie}else Ie=e[78];let De;e[83]!==G?(De=G>0&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>U(!0),className:"justify-start",children:[r.jsx(tt,{"data-icon":"inline-start"}),"Show ",G," more"]}),e[83]=G,e[84]=De):De=e[84];let Le;e[85]!==J?(Le=J&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>U(!1),className:"justify-start",children:[r.jsx(kr,{"data-icon":"inline-start"}),"Show less"]}),e[85]=J,e[86]=Le):Le=e[86];let ze;e[87]!==Re||e[88]!==Ie||e[89]!==De||e[90]!==Le?(ze=r.jsxs("div",{className:"flex flex-col gap-px",children:[Re,Ie,De,Le]}),e[87]=Re,e[88]=Ie,e[89]=De,e[90]=Le,e[91]=ze):ze=e[91];let Te;e[92]!==P||e[93]!==ze?(Te=r.jsx(dt,{id:P,className:"ml-3 border-l pl-1",children:ze}),e[92]=P,e[93]=ze,e[94]=Te):Te=e[94];let Ce;return e[95]!==Pe||e[96]!==Te||e[97]!==ne?(Ce=r.jsxs(ct,{open:ne,className:"flex flex-col",children:[Pe,Te]}),e[95]=Pe,e[96]=Te,e[97]=ne,e[98]=Ce):Ce=e[98],Ce}function YM(n){return!wa(n.cwd??_n(n.dirName))}function XM(n){return n.sessionId}function JM(n){const e=B.c(3),{firstMessage:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(ot,{className:"size-3 shrink-0 animate-spin text-info"}),e[0]=s):s=e[0];const o=t||"New session";let i;return e[1]!==o?(i=r.jsxs("div",{className:"motion-enter relative flex w-full items-center gap-1.5 rounded-md bg-accent px-2 py-2 text-left",children:[s,r.jsx("span",{className:"flex-1 truncate text-xs leading-tight text-foreground",children:o})]}),e[1]=o,e[2]=i):i=e[2],i}const QM=y.memo(function(e){const t=B.c(122),{activeSessionKey:s,onSelectSession:o,onDuplicateSession:i,onDeleteSession:a,onNewSession:l,creatingSession:c,pendingSession:d,refreshRef:u,onPrefetchSession:f}=e,{names:m,rename:p}=Y2(),{names:h,rename:g}=ib(),x=md(),b=En("terminal"),w=En("killAny"),{sessions:v,procBySession:S,newlyCompleted:j,loading:k,error:C,refresh:N,removeSession:_,acknowledgeCompleted:P}=g0(),{awaitingPermission:A,awaitingQuestion:T,awaitingElicitation:E,awaitingDialog:R,awaitingPlan:$}=NM();let I;t[0]!==R||t[1]!==E?(I=new Set([...E,...R]),t[0]=R,t[1]=E,t[2]=I):I=t[2];const M=I;let D;t[3]===Symbol.for("react.memo_cache_sentinel")?(D=new Set,t[3]=D):D=t[3];const[O,L]=y.useState(D),[F,z]=y.useState("");let W,U;t[4]===Symbol.for("react.memo_cache_sentinel")?(W=Kt("live-sessions-collapsed-projects"),U={},t[4]=W,t[5]=U):(W=t[4],U=t[5]);const[H,K]=Kr(W,U);let V;t[6]!==K?(V=(Ve,Ze)=>{K(bt=>({...bt,[Ve]:Ze}))},t[6]=K,t[7]=V):V=t[7];const Y=V,G=y.useRef(v);let J;t[8]===Symbol.for("react.memo_cache_sentinel")?(J=new Set,t[8]=J):J=t[8];const Q=y.useRef(J),X=y.useRef(!1);let Z;t[9]===Symbol.for("react.memo_cache_sentinel")?(Z=(Ve,Ze)=>{if(!X.current)return;const bt=setTimeout(()=>{Q.current.delete(bt),X.current&&Ve()},Ze);Q.current.add(bt)},t[9]=Z):Z=t[9];const te=Z;let ne,re;t[10]===Symbol.for("react.memo_cache_sentinel")?(ne=()=>{const Ve=Q.current;return X.current=!0,()=>{X.current=!1;for(const Ze of Ve)clearTimeout(Ze);Ve.clear()}},re=[],t[10]=ne,t[11]=re):(ne=t[10],re=t[11]),y.useEffect(ne,re);let ie,ae;t[12]!==v?(ie=()=>{G.current=v},ae=[v],t[12]=v,t[13]=ie,t[14]=ae):(ie=t[13],ae=t[14]),y.useEffect(ie,ae);let se,ue;t[15]!==N||t[16]!==u?(se=()=>{if(u)return u.current=N,()=>{u.current===N&&(u.current=null)}},ue=[N,u],t[15]=N,t[16]=u,t[17]=se,t[18]=ue):(se=t[17],ue=t[18]),y.useEffect(se,ue);const le=Da(),de=ab(F);let pe;e:{if(!F.trim()){pe=v;break e}let Ve;if(t[19]!==h||t[20]!==F||t[21]!==m||t[22]!==v){let Ze;t[24]!==h||t[25]!==F||t[26]!==m?(Ze=bt=>{const Dt=m[bt.sessionId],Gn=h[bt.dirName];return eb(bt,F,[Dt,Gn])},t[24]=h,t[25]=F,t[26]=m,t[27]=Ze):Ze=t[27],Ve=v.filter(Ze),t[19]=h,t[20]=F,t[21]=m,t[22]=v,t[23]=Ve}else Ve=t[23];pe=Ve}const he=pe,ce=de.results??he;let ye;t[28]!==ce?(ye=i_(ce),t[28]=ce,t[29]=ye):ye=t[29];const xe=ye;let me;t[30]!==A||t[31]!==$||t[32]!==M||t[33]!==T||t[34]!==j||t[35]!==S||t[36]!==v?(me=_M(v,S,j,A,T,M,$),t[30]=A,t[31]=$,t[32]=M,t[33]=T,t[34]=j,t[35]=S,t[36]=v,t[37]=me):me=t[37];const je=me,Se=je.needsYou.length>0||je.working.length>0;let Pe;t[38]!==Se||t[39]!==F?(Pe=!F.trim()&&Se,t[38]=Se,t[39]=F,t[40]=Pe):Pe=t[40];const Re=Pe;let Ie;e:{if(!d){Ie=null;break e}let Ve;t[41]!==d.cwd||t[42]!==d.dirName?(Ve=d.cwd||_n(d.dirName),t[41]=d.cwd,t[42]=d.dirName,t[43]=Ve):Ve=t[43];let Ze;t[44]!==Ve?(Ze=Gd(Ve),t[44]=Ve,t[45]=Ze):Ze=t[45],Ie=Ze}const De=Ie,Le=y.useRef(!1);let ze,Te;t[46]!==f||t[47]!==v?(ze=()=>{if(Le.current||!f||v.length===0)return;Le.current=!0;const Ve=Vd(v).slice(0,3),Ze=globalThis,bt=()=>{for(const Zs of Ve)f(Zs.dirName,Zs.fileName)};let Dt=null,Gn=null;return typeof Ze.requestIdleCallback=="function"?Dt=Ze.requestIdleCallback(bt,{timeout:1500}):Gn=setTimeout(bt,300),()=>{Dt!=null&&typeof Ze.cancelIdleCallback=="function"&&Ze.cancelIdleCallback(Dt),Gn!=null&&clearTimeout(Gn)}},Te=[v,f],t[46]=f,t[47]=v,t[48]=ze,t[49]=Te):(ze=t[48],Te=t[49]),y.useEffect(ze,Te);let Ce;t[50]!==N?(Ce=async(Ve,Ze)=>{Ze.stopPropagation(),L(bt=>new Set(bt).add(Ve));try{await ve("/api/kill-process",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pid:Ve})}),te(N,1500)}catch{}te(()=>{L(bt=>{const Dt=new Set(bt);return Dt.delete(Ve),Dt})},2e3)},t[50]=N,t[51]=Ce):Ce=t[51];const We=Ce;let Fe;t[52]!==P||t[53]!==o?(Fe=(Ve,Ze)=>{const bt=G.current.find(Dt=>Dt.dirName===Ve&&Dt.fileName===Ze);bt&&P(bt.sessionId),o(Ve,Ze)},t[52]=P,t[53]=o,t[54]=Fe):Fe=t[54];const Ne=Fe;let fe;t[55]!==a||t[56]!==_?(fe=Ve=>{a==null||a(Ve.dirName,Ve.fileName),_(Ve.sessionId)},t[55]=a,t[56]=_,t[57]=fe):fe=t[57];const Oe=fe;let Ae;t[58]!==N||t[59]!==x?(Ae=(Ve,Ze,bt)=>{const{command:Dt,args:Gn}=G3(Et(bt),Ve),Zs=`resume_${crypto.randomUUID().slice(0,8)}`;x.send({type:"spawn",id:Zs,name:`Resume ${Ve.slice(0,8)}`,command:Dt,args:Gn,cwd:Ze??void 0,metadata:{type:"terminal"}}),te(N,3e3)},t[58]=N,t[59]=x,t[60]=Ae):Ae=t[60];const Be=Ae;let oe;t[61]!==N?(oe=()=>{kM(),N()},t[61]=N,t[62]=oe):oe=t[62];let ge;t[63]!==le||t[64]!==k||t[65]!==de.loading||t[66]!==F||t[67]!==oe?(ge=r.jsx(BM,{loading:k,isMobile:le,searchQuery:F,searchLoading:de.loading,onSearchQueryChange:z,onRefresh:oe}),t[63]=le,t[64]=k,t[65]=de.loading,t[66]=F,t[67]=oe,t[68]=ge):ge=t[68];const Ee=de.error??C,$e=ce.length===0&&!d&&!k&&!de.loading&&!C&&!de.error;let He;t[69]!==F?(He=F.trim(),t[69]=F,t[70]=He):He=t[70];const Ke=!!He,nt=k||de.loading,Ye=de.active?ce.length:v.length,Me=de.error?de.refresh:N;let Ue;t[71]!==Ee||t[72]!==$e||t[73]!==Ke||t[74]!==nt||t[75]!==Ye||t[76]!==Me?(Ue=r.jsx(WM,{fetchError:Ee,showEmpty:$e,searching:Ke,loading:nt,sessionCount:Ye,onRetry:Me}),t[71]=Ee,t[72]=$e,t[73]=Ke,t[74]=nt,t[75]=Ye,t[76]=Me,t[77]=Ue):Ue=t[77];let st;t[78]!==s||t[79]!==je||t[80]!==w||t[81]!==b||t[82]!==We||t[83]!==Be||t[84]!==Ne||t[85]!==O||t[86]!==f||t[87]!==S||t[88]!==h||t[89]!==m||t[90]!==Re?(st=Re&&r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx(FM,{groups:je,activeSessionKey:s,procBySession:S,killingPids:O,sessionNames:m,projectNames:h,onSelectSession:Ne,onKill:w?We:void 0,onResumeSession:b?Be:void 0,onPrefetchSession:f}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Projects"}),r.jsx(St,{className:"flex-1"})]})]}),t[78]=s,t[79]=je,t[80]=w,t[81]=b,t[82]=We,t[83]=Be,t[84]=Ne,t[85]=O,t[86]=f,t[87]=S,t[88]=h,t[89]=m,t[90]=Re,t[91]=st):st=t[91];const Vt=w?We:void 0,Ft=a?Oe:void 0,Gt=b?Be:void 0;let Vn;t[92]!==s||t[93]!==H||t[94]!==c||t[95]!==xe||t[96]!==Ne||t[97]!==O||t[98]!==j||t[99]!==i||t[100]!==l||t[101]!==f||t[102]!==De||t[103]!==d||t[104]!==S||t[105]!==h||t[106]!==g||t[107]!==p||t[108]!==F||t[109]!==m||t[110]!==Vt||t[111]!==Ft||t[112]!==Gt||t[113]!==Y?(Vn=r.jsx(GM,{grouped:xe,pendingProjectPath:De,pendingSession:d,collapsedGroups:H,searchQuery:F,activeSessionKey:s,procBySession:S,killingPids:O,newlyCompleted:j,sessionNames:m,projectNames:h,onToggleCollapsed:Y,onSelectSession:Ne,onKill:Vt,onDuplicateSession:i,onDeleteSession:Ft,onRenameSession:p,onRenameProject:g,onNewSession:l,creatingSession:c,onPrefetchSession:f,onResumeSession:Gt}),t[92]=s,t[93]=H,t[94]=c,t[95]=xe,t[96]=Ne,t[97]=O,t[98]=j,t[99]=i,t[100]=l,t[101]=f,t[102]=De,t[103]=d,t[104]=S,t[105]=h,t[106]=g,t[107]=p,t[108]=F,t[109]=m,t[110]=Vt,t[111]=Ft,t[112]=Gt,t[113]=Y,t[114]=Vn):Vn=t[114];let Bt;t[115]!==Ue||t[116]!==st||t[117]!==Vn?(Bt=r.jsx(is,{className:"flex-1",children:r.jsxs("div",{className:"flex flex-col gap-4 p-2",children:[Ue,st,Vn]})}),t[115]=Ue,t[116]=st,t[117]=Vn,t[118]=Bt):Bt=t[118];let Rs;return t[119]!==ge||t[120]!==Bt?(Rs=r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[ge,Bt]}),t[119]=ge,t[120]=Bt,t[121]=Rs):Rs=t[121],Rs}),ZM=y.memo(function(e){const t=B.c(16),{activeSessionKey:s,onSelectSession:o,onNewSession:i,creatingSession:a,isMobile:l,onDuplicateSession:c,onDeleteSession:d,pendingSession:u,liveSessionsRefreshRef:f,onPrefetchSession:m,header:p}=e,h=l?"w-full":"w-80";let g;t[0]!==h?(g=q("flex h-full shrink-0 flex-col bg-sidebar",h),t[0]=h,t[1]=g):g=t[1];let x;t[2]!==s||t[3]!==a||t[4]!==f||t[5]!==d||t[6]!==c||t[7]!==i||t[8]!==m||t[9]!==o||t[10]!==u?(x=r.jsx(QM,{activeSessionKey:s,onSelectSession:o,onDuplicateSession:c,onDeleteSession:d,onNewSession:i,creatingSession:a,pendingSession:u,refreshRef:f,onPrefetchSession:m}),t[2]=s,t[3]=a,t[4]=f,t[5]=d,t[6]=c,t[7]=i,t[8]=m,t[9]=o,t[10]=u,t[11]=x):x=t[11];let b;return t[12]!==p||t[13]!==g||t[14]!==x?(b=r.jsxs("aside",{className:g,"aria-label":"Session browser",children:[p,x]}),t[12]=p,t[13]=g,t[14]=x,t[15]=b):b=t[15],b}),eO=y.lazy(()=>qe(()=>import("./index-CpHg1sRc.js"),__vite__mapDeps([33,1,2,3,4])).then(n=>({default:n.MissionControl})));function hb(n){const e=B.c(3),{label:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(xt,{className:"size-4"}),e[0]=s):s=e[0];let o;return e[1]!==t?(o=r.jsxs("div",{className:"motion-enter flex min-h-0 flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",role:"status",children:[s,t]}),e[1]=t,e[2]=o):o=e[2],o}function gb(n){const e=B.c(12),{navigation:t,mobile:s,header:o}=n,i=s===void 0?!1:s,{sessionSource:a}=it(),l=a?`${a.dirName}/${a.fileName}`:null;let c;return e[0]!==l||e[1]!==o||e[2]!==i||e[3]!==t.actions.handleDashboardSelect||e[4]!==t.creatingSession||e[5]!==t.handlers.handleDeleteSession||e[6]!==t.handlers.handleDuplicateSessionByPath||e[7]!==t.liveSessionsRefreshRef||e[8]!==t.onPrefetchSession||e[9]!==t.onStartNewSession||e[10]!==t.pendingSession?(c=r.jsx(ZM,{activeSessionKey:l,onSelectSession:t.actions.handleDashboardSelect,onNewSession:t.onStartNewSession,creatingSession:t.creatingSession,pendingSession:t.pendingSession,onDuplicateSession:t.handlers.handleDuplicateSessionByPath,onDeleteSession:t.handlers.handleDeleteSession,liveSessionsRefreshRef:t.liveSessionsRefreshRef,onPrefetchSession:t.onPrefetchSession,isMobile:i,header:o}),e[0]=l,e[1]=o,e[2]=i,e[3]=t.actions.handleDashboardSelect,e[4]=t.creatingSession,e[5]=t.handlers.handleDeleteSession,e[6]=t.handlers.handleDuplicateSessionByPath,e[7]=t.liveSessionsRefreshRef,e[8]=t.onPrefetchSession,e[9]=t.onStartNewSession,e[10]=t.pendingSession,e[11]=c):c=e[11],c}function xb(n){const e=B.c(8),{navigation:t}=n,{state:s}=zt();let o;return e[0]!==t.actions.handleDashboardSelect||e[1]!==t.creatingSession||e[2]!==t.handlers.handleDeleteSession||e[3]!==t.handlers.handleDuplicateSessionByPath||e[4]!==t.onSelectProject||e[5]!==t.onStartNewSession||e[6]!==s.dashboardProject?(o=r.jsx(bM,{onSelectSession:t.actions.handleDashboardSelect,onNewSession:t.onStartNewSession,creatingSession:t.creatingSession,selectedProjectDirName:s.dashboardProject,onSelectProject:t.onSelectProject,onDuplicateSession:t.handlers.handleDuplicateSessionByPath,onDeleteSession:t.handlers.handleDeleteSession}),e[0]=t.actions.handleDashboardSelect,e[1]=t.creatingSession,e[2]=t.handlers.handleDeleteSession,e[3]=t.handlers.handleDuplicateSessionByPath,e[4]=t.onSelectProject,e[5]=t.onStartNewSession,e[6]=s.dashboardProject,e[7]=o):o=e[7],o}function tO(n){const e=B.c(3),{navigation:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(hb,{label:"Loading Mission Control…"}),e[0]=s):s=e[0];let o;return e[1]!==t.actions.handleDashboardSelect?(o=r.jsx(y.Suspense,{fallback:s,children:r.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 flex-col",children:r.jsx(eO,{onSelectSession:t.actions.handleDashboardSelect})})}),e[1]=t.actions.handleDashboardSelect,e[2]=o):o=e[2],o}function nO({mainView:n,hasSession:e,pendingDirName:t}){return n==="config"?"config":n==="mission"?"mission":e?"session":t?"pending":"dashboard"}function sO({sessionCwd:n,pendingPath:e,sessionDirPath:t,dashboardProjectPath:s}){return n??e??t??s??null}function oO({path:n,text:e,startLine:t,endLine:s,comment:o}){if(!e)return`@${n}`;const i=e.includes("```")?"````":"```",a=t===s?`line ${t}`:`lines ${t}-${s}`;return`${o?`Review request: ${o}
130
- `:""}${n} (${a})
131
- ${i}
132
- ${e}
133
- ${i}`}const rO=y.lazy(()=>qe(()=>import("./ConfigBrowser-CTZR8nw6.js"),__vite__mapDeps([34,1,2,31,3,4])).then(n=>({default:n.ConfigBrowser}))),iO=y.lazy(()=>qe(()=>import("./PreviewPanel-BOL9gNaQ.js"),__vite__mapDeps([35,1,2,3,4])).then(n=>({default:n.PreviewPanel})));function aO(n){const e=B.c(20),{sessionView:t,floatingChrome:s}=n,{session:o}=it();if(!o)return null;let i;e[0]!==t.teamMembersBar?(i=t.teamMembersBar&&r.jsx("div",{className:"pt-10",children:t.teamMembersBar}),e[0]=t.teamMembersBar,e[1]=i):i=e[1];const a=!!t.todoProgress&&t.todosExpanded;let l;e[2]!==t.hasMoreTurns||e[3]!==t.isLoadingOlderTurns||e[4]!==t.onLoadMoreTurns||e[5]!==t.searchInputRef||e[6]!==a?(l=r.jsx(Ha,{searchInputRef:t.searchInputRef,hasTodos:a,hasMore:t.hasMoreTurns,isLoadingOlder:t.isLoadingOlderTurns,onLoadMore:t.onLoadMoreTurns}),e[2]=t.hasMoreTurns,e[3]=t.isLoadingOlderTurns,e[4]=t.onLoadMoreTurns,e[5]=t.searchInputRef,e[6]=a,e[7]=l):l=e[7];let c;e[8]!==t.onTodosExpandedChange||e[9]!==t.todoProgress||e[10]!==t.todosExpanded?(c=t.todoProgress&&r.jsx(Gx,{progress:t.todoProgress,expanded:t.todosExpanded,onExpandedChange:t.onTodosExpandedChange}),e[8]=t.onTodosExpandedChange,e[9]=t.todoProgress,e[10]=t.todosExpanded,e[11]=c):c=e[11];let d;e[12]!==t.activeComposer||e[13]!==c?(d=r.jsxs(Ya,{floating:!0,children:[c,t.activeComposer]}),e[12]=t.activeComposer,e[13]=c,e[14]=d):d=e[14];let u;return e[15]!==s||e[16]!==i||e[17]!==l||e[18]!==d?(u=r.jsx("div",{className:"flex min-h-0 flex-1 bg-background",children:r.jsxs("div",{className:"relative flex h-full min-h-0 flex-1 flex-col",children:[s,i,l,d]})}),e[15]=s,e[16]=i,e[17]=l,e[18]=d,e[19]=u):u=e[19],u}function lO(n){const e=B.c(36),{navigation:t,sessionView:s,project:o,view:i,floatingChrome:a}=n,{state:l}=zt(),{session:c,sessionSource:d}=it();let u,f;if(e[0]!==(c==null?void 0:c.cwd)||e[1]!==d||e[2]!==l.configFilePath||e[3]!==l.dashboardProject||e[4]!==l.pendingCwd||e[5]!==l.pendingDirName||e[6]!==i){f=Symbol.for("react.early_return_sentinel");e:if(u=l.pendingCwd??(l.pendingDirName?_n(l.pendingDirName):null),i==="config"){let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(hb,{label:"Loading configuration…"}),e[9]=p):p=e[9];const h=r.jsx(rO,{projectPath:sO({sessionCwd:c==null?void 0:c.cwd,pendingPath:u,sessionDirPath:d!=null&&d.dirName?_n(d.dirName):null,dashboardProjectPath:l.dashboardProject?_n(l.dashboardProject):null}),initialFilePath:l.configFilePath});let g;e[10]!==h?(g=r.jsx(y.Suspense,{fallback:p,children:r.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 pt-10",children:h})}),e[10]=h,e[11]=g):g=e[11],f=g;break e}e[0]=c==null?void 0:c.cwd,e[1]=d,e[2]=l.configFilePath,e[3]=l.dashboardProject,e[4]=l.pendingCwd,e[5]=l.pendingDirName,e[6]=i,e[7]=u,e[8]=f}else u=e[7],f=e[8];if(f!==Symbol.for("react.early_return_sentinel"))return f;if(i==="mission"){let p;return e[12]!==t?(p=r.jsx("div",{className:"flex min-h-0 flex-1 flex-col pt-10",children:r.jsx(tO,{navigation:t})}),e[12]=t,e[13]=p):p=e[13],p}if(i==="session"){let p;return e[14]!==a||e[15]!==s?(p=r.jsx(aO,{sessionView:s,floatingChrome:a}),e[14]=a,e[15]=s,e[16]=p):p=e[16],p}if(i==="pending"){const p=s.pendingTurns.length>0,h=Bs()?"Only on the machine running this session":void 0;let g;e[17]===Symbol.for("react.memo_cache_sentinel")?(g=_d()?void 0:h,e[17]=g):g=e[17];const x=g,b=!p&&"justify-center gap-4";let w;e[18]!==b?(w=q("flex min-h-0 min-w-0 flex-1 flex-col bg-background",b),e[18]=b,e[19]=w):w=e[19];let v;e[20]!==p||e[21]!==u||e[22]!==s.pendingTurns?(v=p?r.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-14",children:r.jsx("div",{className:"mx-auto w-full max-w-[var(--chat-width)]",children:s.pendingTurns})}):r.jsx(K2,{projectPath:u}),e[20]=p,e[21]=u,e[22]=s.pendingTurns,e[23]=v):v=e[23];let S;e[24]!==s.pendingComposer?(S=r.jsx(Ya,{children:s.pendingComposer}),e[24]=s.pendingComposer,e[25]=S):S=e[25];let j;e[26]!==p||e[27]!==o?(j=!p&&r.jsxs("div",{className:"flex items-center justify-center gap-2",children:[lt("terminal")&&r.jsx(Dl,{reason:h,children:r.jsxs(ee,{variant:"outline",size:"xs",disabled:!!h,onClick:o.onOpenTerminal,children:[r.jsx(Gs,{"data-icon":"inline-start"}),"Terminal"]})}),lt("hostFiles")&&r.jsxs(r.Fragment,{children:[r.jsx(Dl,{reason:x,children:r.jsxs(ee,{variant:"outline",size:"xs",disabled:!!x,onClick:()=>k1(o.pendingProject),children:[r.jsx(Nr,{"data-icon":"inline-start"}),"Open in editor"]})}),r.jsx(Dl,{reason:h,children:r.jsxs(ee,{variant:"outline",size:"xs",disabled:!!h,onClick:()=>C1(o.pendingProject),children:[r.jsx(eg,{"data-icon":"inline-start"}),"Reveal in files"]})})]})]}),e[26]=p,e[27]=o,e[28]=j):j=e[28];let k;return e[29]!==w||e[30]!==v||e[31]!==S||e[32]!==j?(k=r.jsxs("div",{className:w,children:[v,S,j]}),e[29]=w,e[30]=v,e[31]=S,e[32]=j,e[33]=k):k=e[33],k}let m;return e[34]!==t?(m=r.jsx(xb,{navigation:t}),e[34]=t,e[35]=m):m=e[35],m}function cO(n){const e=B.c(104),{navigation:t,sessionView:s,project:o,chrome:i}=n,{state:a,config:l}=zt(),{session:c,sessionSource:d}=it();let u;e[0]!==s.chatInputRef?(u=function(le){var pe,he,ce;const de=((pe=s.chatInputRef.current)==null?void 0:pe.getText().trimEnd())??"";(he=s.chatInputRef.current)==null||he.setText(de?`${de}
134
-
135
- ${le}
136
- `:`${le}
137
- `),(ce=s.chatInputRef.current)==null||ce.focus()},e[0]=s.chatInputRef,e[1]=u):u=e[1];const f=u;let m;e[2]!==f?(m=function(le){const{path:de,text:pe,startLine:he,endLine:ce,comment:ye}=le;f(oO({path:de,text:pe,startLine:he,endLine:ce,comment:ye}))},e[2]=f,e[3]=m):m=e[3];const p=m,h=a.mainView,g=!!c;let x;e[4]!==a.mainView||e[5]!==a.pendingDirName||e[6]!==g?(x=nO({mainView:h,hasSession:g,pendingDirName:a.pendingDirName}),e[4]=a.mainView,e[5]=a.pendingDirName,e[6]=g,e[7]=x):x=e[7];const b=x,w=t.panels.handleToggleSidebar,v=t.actions.handleGoHome,S=i.onOpenCommandPalette;let j,k;e[8]===Symbol.for("react.memo_cache_sentinel")?(k=Ml("toggleSidebar"),j=Ml("commandPalette"),e[8]=j,e[9]=k):(j=e[8],k=e[9]);let C;e[10]!==i.onOpenCommandPalette||e[11]!==t.actions.handleGoHome||e[12]!==t.panels.handleToggleSidebar?(C=r.jsx(XA,{onToggleSidebar:w,onGoHome:v,onOpenCommandPalette:S,sidebarShortcut:k,commandPaletteShortcut:j}),e[10]=i.onOpenCommandPalette,e[11]=t.actions.handleGoHome,e[12]=t.panels.handleToggleSidebar,e[13]=C):C=e[13];const N=C,_=t.panels.showSidebar&&a.mainView!=="config",P=o.currentCwd??null;let A,T,E;e[14]!==f||e[15]!==t.handlers.handleLoadSessionScrollAware||e[16]!==t.panels.activeWorkspacePanel||e[17]!==o.hasFileChanges||e[18]!==o.supportsWorktrees||e[19]!==c||e[20]!==a.mainView||e[21]!==a.sessionChangeKey||e[22]!==P?(A={session:c,sessionChangeKey:a.sessionChangeKey,projectPath:P,hasFileChanges:o.hasFileChanges,canAccessHostFiles:lt("hostFiles"),supportsWorktrees:o.supportsWorktrees,openSession:t.handlers.handleLoadSessionScrollAware,composePrompt:f},E=k2(L$,A),T=a.mainView==="sessions"?E.find(ue=>ue.id===t.panels.activeWorkspacePanel):null,e[14]=f,e[15]=t.handlers.handleLoadSessionScrollAware,e[16]=t.panels.activeWorkspacePanel,e[17]=o.hasFileChanges,e[18]=o.supportsWorktrees,e[19]=c,e[20]=a.mainView,e[21]=a.sessionChangeKey,e[22]=P,e[23]=A,e[24]=T,e[25]=E):(A=e[23],T=e[24],E=e[25]);const R=T,$=(d==null?void 0:d.dirName)??a.pendingDirName??a.dashboardProject??null;let I;e[26]!==t.panels||e[27]!==o?(I=function(le){o.showPreview&&o.onCloseRightWorkspace(),t.panels.toggleWorkspacePanel(le)},e[26]=t.panels,e[27]=o,e[28]=I):I=e[28];const M=I;let D;e[29]!==t.panels||e[30]!==o?(D=function(le){o.showPreview&&o.onCloseRightWorkspace(),t.panels.openWorkspacePanel(le)},e[29]=t.panels,e[30]=o,e[31]=D):D=e[31];const O=D;let L;e[32]!==t.actions||e[33]!==t.panels||e[34]!==$?(L=function(le){$&&(t.actions.handleDashboardSelect($,`${le}.jsonl`),t.panels.closeWorkspacePanel())},e[32]=t.actions,e[33]=t.panels,e[34]=$,e[35]=L):L=e[35];const F=L,z=t.panels.showSidebar;let W;e[36]===Symbol.for("react.memo_cache_sentinel")?(W=Ml("toggleSidebar"),e[36]=W):W=e[36];let U;e[37]!==i.killing||e[38]!==i.onKillAll||e[39]!==l.openConfigDialog||e[40]!==t.creatingSession||e[41]!==t.handlers.handleDuplicateSession||e[42]!==t.onStartNewSession||e[43]!==t.panels.handleToggleSidebar||e[44]!==t.panels.showSidebar||e[45]!==o.onOpenTerminal||e[46]!==s.onBackToMain||e[47]!==s.onShowWorkflows||e[48]!==s.workflowCount||e[49]!==_?(U=r.jsx(VA,{showSidebar:z,sidebarRendered:_,sidebarShortcut:W,killing:i.killing,creatingSession:t.creatingSession,onNewSession:t.onStartNewSession,onDuplicateSession:t.handlers.handleDuplicateSession,onOpenTerminal:o.onOpenTerminal,onBackToMain:s.onBackToMain,onShowWorkflows:s.onShowWorkflows,workflowCount:s.workflowCount,onToggleSidebar:t.panels.handleToggleSidebar,onKillAll:i.onKillAll,onOpenSettings:l.openConfigDialog}),e[37]=i.killing,e[38]=i.onKillAll,e[39]=l.openConfigDialog,e[40]=t.creatingSession,e[41]=t.handlers.handleDuplicateSession,e[42]=t.onStartNewSession,e[43]=t.panels.handleToggleSidebar,e[44]=t.panels.showSidebar,e[45]=o.onOpenTerminal,e[46]=s.onBackToMain,e[47]=s.onShowWorkflows,e[48]=s.workflowCount,e[49]=_,e[50]=U):U=e[50];const H=U;let K;e[51]!==t||e[52]!==N||e[53]!==_?(K=_&&r.jsx("div",{className:"view-transition-sidebar panel-enter w-80 shrink-0 border-r bg-sidebar text-sidebar-foreground",children:r.jsx(gb,{navigation:t,header:N})}),e[51]=t,e[52]=N,e[53]=_,e[54]=K):K=e[54];const V=R??null,Y=o.projectFilesRoot??o.currentCwd??null;let G;e[55]!==p||e[56]!==t.actions.handleJumpToTurn||e[57]!==t.handlers.handleLoadSessionScrollAware||e[58]!==F||e[59]!==o.backgroundAgents||e[60]!==o.processPanel.handleServersChanged||e[61]!==o.processPanel.handleToggleServer||e[62]!==o.projectFilesRequest||e[63]!==o.worktrees||e[64]!==s.searchInputRef||e[65]!==Y||e[66]!==$?(G={projectFilesRoot:Y,projectFilesRequest:o.projectFilesRequest,backgroundAgents:o.backgroundAgents,searchInputRef:s.searchInputRef,addProjectContext:p,jumpToTurn:t.actions.handleJumpToTurn,toggleServer:o.processPanel.handleToggleServer,serversChanged:o.processPanel.handleServersChanged,loadSession:t.handlers.handleLoadSessionScrollAware,worktrees:o.worktrees,worktreeDirName:$,openWorktreeSession:F},e[55]=p,e[56]=t.actions.handleJumpToTurn,e[57]=t.handlers.handleLoadSessionScrollAware,e[58]=F,e[59]=o.backgroundAgents,e[60]=o.processPanel.handleServersChanged,e[61]=o.processPanel.handleToggleServer,e[62]=o.projectFilesRequest,e[63]=o.worktrees,e[64]=s.searchInputRef,e[65]=Y,e[66]=$,e[67]=G):G=e[67];const J=a.mainView==="mission";let Q;e[68]!==t.panels.handleToggleMission||e[69]!==J?(Q={id:"mission-control",title:"Mission Control",icon:E3,active:J,onSelect:t.panels.handleToggleMission},e[68]=t.panels.handleToggleMission,e[69]=J,e[70]=Q):Q=e[70];let X;e[71]!==t.panels.handleToggleConfig||e[72]!==a.mainView?(X=lt("configWrite")?[{id:"config",title:"Config",icon:P3,active:a.mainView==="config",onSelect:t.panels.handleToggleConfig}]:[],e[71]=t.panels.handleToggleConfig,e[72]=a.mainView,e[73]=X):X=e[73];let Z;e[74]!==Q||e[75]!==X?(Z=[Q,...X],e[74]=Q,e[75]=X,e[76]=Z):Z=e[76];const te=b!=="session"&&H;let ne;e[77]!==H||e[78]!==t||e[79]!==o||e[80]!==s||e[81]!==b?(ne=r.jsx(lO,{navigation:t,sessionView:s,project:o,view:b,floatingChrome:H}),e[77]=H,e[78]=t,e[79]=o,e[80]=s,e[81]=b,e[82]=ne):ne=e[82];let re;e[83]!==te||e[84]!==ne?(re=r.jsxs("main",{className:"app-view-transition relative flex size-full min-w-0 flex-col overflow-hidden",children:[te,ne]}),e[83]=te,e[84]=ne,e[85]=re):re=e[85];let ie;e[86]!==t.panels.closeWorkspacePanel||e[87]!==O||e[88]!==A||e[89]!==V||e[90]!==G||e[91]!==Z||e[92]!==re||e[93]!==M||e[94]!==E?(ie=r.jsx(oR,{panels:E,context:A,activePanel:V,services:G,onClosePanel:t.panels.closeWorkspacePanel,onOpenPanel:O,onTogglePanel:M,actions:Z,children:re}),e[86]=t.panels.closeWorkspacePanel,e[87]=O,e[88]=A,e[89]=V,e[90]=G,e[91]=Z,e[92]=re,e[93]=M,e[94]=E,e[95]=ie):ie=e[95];let ae;e[96]!==o.currentCwd||e[97]!==o.onCloseRightWorkspace||e[98]!==o.showPreview?(ae=o.showPreview&&o.currentCwd&&r.jsx(y.Suspense,{fallback:null,children:r.jsx(iO,{cwd:o.currentCwd,onClose:o.onCloseRightWorkspace})}),e[96]=o.currentCwd,e[97]=o.onCloseRightWorkspace,e[98]=o.showPreview,e[99]=ae):ae=e[99];let se;return e[100]!==K||e[101]!==ie||e[102]!==ae?(se=r.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden bg-background",children:[K,ie,ae]}),e[100]=K,e[101]=ie,e[102]=ae,e[103]=se):se=e[103],se}function dO(n){const e=B.c(16),{navigation:t,sessionView:s,project:o,chrome:i}=n,{theme:a}=zt(),l=`${a.themeClasses} flex h-dvh flex-col bg-background text-foreground`;let c,d;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(Jx,{}),d=r.jsx(Xx,{}),e[0]=c,e[1]=d):(c=e[0],d=e[1]);let u;e[2]!==i||e[3]!==t||e[4]!==o||e[5]!==s?(u=r.jsx(cO,{navigation:t,sessionView:s,project:o,chrome:i}),e[2]=i,e[3]=t,e[4]=o,e[5]=s,e[6]=u):u=e[6];let f;e[7]!==i||e[8]!==t||e[9]!==o?(f=r.jsx(J9,{navigation:t,project:o,chrome:i}),e[7]=i,e[8]=t,e[9]=o,e[10]=f):f=e[10];let m;return e[11]!==i.backgroundServers||e[12]!==l||e[13]!==u||e[14]!==f?(m=r.jsxs("div",{className:l,children:[i.backgroundServers,c,d,u,f]}),e[11]=i.backgroundServers,e[12]=l,e[13]=u,e[14]=f,e[15]=m):m=e[15],m}const uO=[{id:"sessions",label:"Sessions",icon:jo},{id:"chat",label:"Chat",icon:pa},{id:"stats",label:"Stats",icon:ng,requiresSession:!0}],fO=y.memo(function(e){const t=B.c(17),{activeTab:s,onTabChange:o}=e,{session:i,isLive:a}=it(),l=i!==null;let c,d,u;if(t[0]!==s||t[1]!==l||t[2]!==a||t[3]!==o){let m;t[7]!==l?(m=g=>!(g.requiresSession&&!l),t[7]=l,t[8]=m):m=t[8];const p=uO.filter(m);c="flex shrink-0 items-stretch border-t bg-background pb-[env(safe-area-inset-bottom)]",d="Navigation";let h;t[9]!==s||t[10]!==a||t[11]!==o?(h=g=>{const x=g.icon,b=s===g.id;return r.jsx("button",{type:"button","aria-current":b?"page":void 0,"aria-label":g.label,title:g.label,onClick:()=>{Dc(),o(g.id)},className:q("flex min-h-14 flex-1 items-center justify-center outline-none transition-[color,transform] duration-150 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset motion-reduce:transition-none",b?"text-foreground":"text-muted-foreground hover:text-foreground"),children:r.jsxs("div",{className:q("relative flex size-9 items-center justify-center rounded-md transition-[background-color,transform,scale] duration-150 ease-out motion-reduce:transition-none",b?"scale-100 bg-accent":"scale-95"),children:[r.jsx(x,{className:q("size-[18px] transition-transform duration-150 ease-out motion-reduce:transition-none",b&&"scale-110"),"aria-hidden":"true"}),g.id==="chat"&&a&&r.jsx(Na,{className:"absolute right-0.5 top-0.5 size-1.5 ring-2 ring-background"})]})},g.id)},t[9]=s,t[10]=a,t[11]=o,t[12]=h):h=t[12],u=p.map(h),t[0]=s,t[1]=l,t[2]=a,t[3]=o,t[4]=c,t[5]=d,t[6]=u}else c=t[4],d=t[5],u=t[6];let f;return t[13]!==c||t[14]!==d||t[15]!==u?(f=r.jsx("nav",{className:c,"aria-label":d,children:u}),t[13]=c,t[14]=d,t[15]=u,t[16]=f):f=t[16],f});function mO(n){const e=B.c(63),{session:t,sessionSource:s,isSubAgentView:o,claudeRawMessages:i,creatingSession:a,onNewSession:l,onDuplicateSession:c,onBackToMain:d,onShowFileChanges:u,hasFileChanges:f,onShowWorkflows:m,workflowCount:p,onSearch:h,expandAll:g,onToggleExpandAll:x}=n;let b;e[0]!==l||e[1]!==t.cwd||e[2]!==s?(b=()=>{s&&l(s.dirName,t.cwd)},e[0]=l,e[1]=t.cwd,e[2]=s,e[3]=b):b=e[3];const w=b;let v;e[4]!==o||e[5]!==d?(v=o&&d&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:d,"aria-label":"Back to main agent",children:r.jsx(Jc,{"data-icon":"inline-start"})}),e[4]=o,e[5]=d,e[6]=v):v=e[6];let S,j;e[7]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx(uu,{compact:!0}),j=r.jsx(St,{orientation:"vertical",className:"h-4"}),e[7]=S,e[8]=j):(S=e[7],j=e[8]);let k;e[9]!==i?(k=r.jsx(e1,{rawMessages:i,warnOnly:!0}),e[9]=i,e[10]=k):k=e[10];let C;e[11]!==t.cwd?(C=t.cwd?Qn(t.cwd):"Session",e[11]=t.cwd,e[12]=C):C=e[12];let N;e[13]!==C?(N=r.jsx("span",{className:"min-w-0 flex-1 truncate text-center text-xs font-medium text-muted-foreground",children:C}),e[13]=C,e[14]=N):N=e[14];let _;e[15]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(Hn,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Session actions"}),children:r.jsx(tg,{"data-icon":"inline-start"})}),e[15]=_):_=e[15];let P;e[16]!==t.cwd?(P=t.cwd?Qn(t.cwd):"Current session",e[16]=t.cwd,e[17]=P):P=e[17];let A;e[18]!==P?(A=r.jsx("span",{className:"truncate text-foreground",children:P}),e[18]=P,e[19]=A):A=e[19];let T;e[20]!==t.gitBranch||e[21]!==t.model?(T=[t.model,t.gitBranch].filter(Boolean).join(" · ")||"Session actions",e[20]=t.gitBranch,e[21]=t.model,e[22]=T):T=e[22];let E;e[23]!==T?(E=r.jsx("span",{className:"truncate font-normal",children:T}),e[23]=T,e[24]=E):E=e[24];let R;e[25]!==A||e[26]!==E?(R=r.jsxs(Us,{className:"flex flex-col gap-0.5",children:[A,E]}),e[25]=A,e[26]=E,e[27]=R):R=e[27];let $;e[28]!==a||e[29]!==w||e[30]!==s?($=s&&r.jsxs(_t,{onClick:w,disabled:a,children:[a?r.jsx(xt,{}):r.jsx(Ln,{}),r.jsx("span",{children:"New session"})]}),e[28]=a,e[29]=w,e[30]=s,e[31]=$):$=e[31];let I;e[32]!==c?(I=c&&r.jsxs(_t,{onClick:c,children:[r.jsx(An,{}),r.jsx("span",{children:"Duplicate session"})]}),e[32]=c,e[33]=I):I=e[33];let M;e[34]!==R||e[35]!==$||e[36]!==I?(M=r.jsxs(en,{children:[R,$,I]}),e[34]=R,e[35]=$,e[36]=I,e[37]=M):M=e[37];let D;e[38]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(ur,{}),e[38]=D):D=e[38];let O;e[39]!==h?(O=h&&r.jsxs(_t,{onClick:h,children:[r.jsx(gn,{}),r.jsx("span",{children:"Search conversation"})]}),e[39]=h,e[40]=O):O=e[40];let L;e[41]!==g||e[42]!==x?(L=x&&r.jsxs(_t,{onClick:x,children:[g?r.jsx(ma,{}):r.jsx(fa,{}),r.jsx("span",{children:g?"Collapse tool calls":"Expand tool calls"})]}),e[41]=g,e[42]=x,e[43]=L):L=e[43];let F;e[44]!==f||e[45]!==u?(F=f&&u&&r.jsxs(_t,{onClick:u,children:[r.jsx(Tr,{}),r.jsx("span",{children:"File changes"})]}),e[44]=f,e[45]=u,e[46]=F):F=e[46];let z;e[47]!==m||e[48]!==p?(z=m&&(p??0)>0&&r.jsxs(_t,{onClick:m,children:[r.jsx(nd,{}),r.jsx("span",{className:"flex-1",children:"Workflows"}),r.jsx(_e,{variant:"secondary",children:p})]}),e[47]=m,e[48]=p,e[49]=z):z=e[49];let W;e[50]!==O||e[51]!==L||e[52]!==F||e[53]!==z?(W=r.jsxs(en,{children:[O,L,F,z]}),e[50]=O,e[51]=L,e[52]=F,e[53]=z,e[54]=W):W=e[54];let U;e[55]!==M||e[56]!==W?(U=r.jsxs(Wn,{children:[_,r.jsxs(Kn,{align:"end",sideOffset:6,className:"w-72",children:[M,D,W]})]}),e[55]=M,e[56]=W,e[57]=U):U=e[57];let H;return e[58]!==v||e[59]!==U||e[60]!==k||e[61]!==N?(H=r.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-1.5 border-b bg-background px-2",children:[v,S,j,k,N,U]}),e[58]=v,e[59]=U,e[60]=k,e[61]=N,e[62]=H):H=e[62],H}const pO=y.memo(function(e){const t=B.c(11),{isMobile:s}=zt(),{session:o,sessionSource:i}=it();if(!s||!o)return null;let a;t[0]!==i?(a=i?Ns(i.fileName):null,t[0]=i,t[1]=a):a=t[1];const l=a;let c;t[2]!==o||t[3]!==(i==null?void 0:i.dirName)?(c=So(i==null?void 0:i.dirName).contextWindow?o.rawMessages:[],t[2]=o,t[3]=i==null?void 0:i.dirName,t[4]=c):c=t[4];const d=c,u=l!==null;let f;return t[5]!==d||t[6]!==e||t[7]!==o||t[8]!==i||t[9]!==u?(f=r.jsx(mO,{...e,onDuplicateSession:e.onDuplicateSession,session:o,sessionSource:i,isSubAgentView:u,claudeRawMessages:d}),t[5]=d,t[6]=e,t[7]=o,t[8]=i,t[9]=u,t[10]=f):f=t[10],f});function hO({onSwipeLeft:n,onSwipeRight:e,threshold:t=50,enabled:s=!0}){const o=y.useRef(null),i=y.useRef(null),a=y.useRef(n),l=y.useRef(e);return a.current=n,l.current=e,y.useEffect(()=>{const c=o.current;if(!c||!s)return;function d(f){const m=f.touches[0];i.current={x:m.clientX,y:m.clientY}}function u(f){var g,x;if(!i.current)return;const m=f.changedTouches[0],p=m.clientX-i.current.x,h=m.clientY-i.current.y;i.current=null,!(Math.abs(p)<t||Math.abs(p)<Math.abs(h))&&(p>0?(g=l.current)==null||g.call(l):(x=a.current)==null||x.call(a))}return c.addEventListener("touchstart",d,{passive:!0}),c.addEventListener("touchend",u,{passive:!0}),()=>{c.removeEventListener("touchstart",d),c.removeEventListener("touchend",u)}},[s,t]),o}const gO=["sessions","chat","stats"];function xO({hasSession:n,hasPendingSession:e}){return gO.filter(t=>!(t==="stats"&&!n&&!e))}function ch(n,e,t){const s=n.indexOf(e);return s===-1?null:n[s+t]??null}const bO=y.lazy(()=>qe(()=>import("./MobileFileChanges-DaJh6sQ7.js"),__vite__mapDeps([36,1,2,3,4])).then(n=>({default:n.MobileFileChanges})));function vO(n){const e=B.c(71),{navigation:t,sessionView:s,project:o,chrome:i}=n,{state:a,theme:l}=zt(),{session:c,isSubAgentView:d}=it(),u=!!c,f=!!a.pendingDirName;let m;e[0]!==u||e[1]!==f?(m=xO({hasSession:u,hasPendingSession:f}),e[0]=u,e[1]=f,e[2]=m):m=e[2];const p=m;let h;e[3]!==t.actions||e[4]!==a.mobileTab||e[5]!==p?(h={enabled:!0,onSwipeLeft:()=>{const F=ch(p,a.mobileTab,1);F&&(Dc(),t.actions.handleMobileTabChange(F))},onSwipeRight:()=>{const F=ch(p,a.mobileTab,-1);F&&(Dc(),t.actions.handleMobileTabChange(F))}},e[3]=t.actions,e[4]=a.mobileTab,e[5]=p,e[6]=h):h=e[6];const g=hO(h);let x;e[7]!==i||e[8]!==t.actions?(x=F=>{i.onSearchOpenChange(!1),t.actions.handleMobileTabChange(F)},e[7]=i,e[8]=t.actions,e[9]=x):x=e[9];const b=x,w=`${l.themeClasses} flex h-dvh flex-col bg-background text-foreground`,v=i.backgroundServers;let S,j;e[10]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx(Jx,{}),j=r.jsx(Xx,{}),e[10]=S,e[11]=j):(S=e[10],j=e[11]);let k;e[12]!==c||e[13]!==a.mobileTab?(k=!(a.mobileTab==="chat"&&c)&&r.jsx("div",{className:"motion-slide-down-in flex h-12 shrink-0 items-center border-b bg-background px-2",children:r.jsx(uu,{compact:!0})}),e[12]=c,e[13]=a.mobileTab,e[14]=k):k=e[14];const C=a.mobileTab,N=!(a.mobileTab==="chat"&&c)&&"motion-session-enter";let _;e[15]!==N?(_=q("flex min-h-0 min-w-0 flex-1",N),e[15]=N,e[16]=_):_=e[16];let P;e[17]!==t||e[18]!==a.mobileTab?(P=a.mobileTab==="sessions"&&r.jsx(gb,{navigation:t,mobile:!0}),e[17]=t,e[18]=a.mobileTab,e[19]=P):P=e[19];let A;e[20]!==i||e[21]!==d||e[22]!==t||e[23]!==o||e[24]!==c||e[25]!==s||e[26]!==a.expandAll||e[27]!==a.mobileTab||e[28]!==a.pendingDirName?(A=a.mobileTab==="chat"&&r.jsx("div",{className:"flex flex-1 min-h-0 flex-col min-w-0",children:c?r.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[s.teamMembersBar,r.jsx(pO,{creatingSession:t.creatingSession,onNewSession:t.onStartNewSession,onDuplicateSession:t.handlers.handleDuplicateSession,onOpenTerminal:o.onOpenTerminal,onBackToMain:d?s.onBackToMain:void 0,onShowFileChanges:()=>i.onFileChangesOpenChange(!0),hasFileChanges:o.hasFileChanges,onShowWorkflows:s.onShowWorkflows,workflowCount:s.workflowCount,onSearch:()=>i.onSearchOpenChange(!0),expandAll:a.expandAll,onToggleExpandAll:s.onToggleExpandAll}),r.jsx(Ha,{searchInputRef:s.searchInputRef,hasMore:s.hasMoreTurns,isLoadingOlder:s.isLoadingOlderTurns,onLoadMore:s.onLoadMoreTurns,mobileSearchOpen:i.searchOpen,onMobileSearchClose:()=>i.onSearchOpenChange(!1)})]}):a.pendingDirName?r.jsx("div",{className:"flex flex-1 min-h-0 flex-col",children:s.pendingTurns.length>0?r.jsx("div",{className:"flex-1 overflow-y-auto px-1 py-3",children:s.pendingTurns}):r.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-4 px-4",children:[r.jsx(K2,{projectPath:s.pendingPath??null}),lt("terminal")&&r.jsxs(ee,{variant:"outline",size:"xs",onClick:o.onOpenTerminal,children:[r.jsx(Gs,{"data-icon":"inline-start"}),"Terminal"]})]})}):r.jsx(xb,{navigation:t})}),e[20]=i,e[21]=d,e[22]=t,e[23]=o,e[24]=c,e[25]=s,e[26]=a.expandAll,e[27]=a.mobileTab,e[28]=a.pendingDirName,e[29]=A):A=e[29];let T;e[30]!==t.handlers||e[31]!==o||e[32]!==c||e[33]!==a.mobileTab?(T=a.mobileTab==="stats"&&c&&r.jsx(W2,{onJumpToTurn:t.handlers.handleMobileJumpToTurn,onToggleServer:o.processPanel.handleToggleServer,onServersChanged:o.processPanel.handleServersChanged,onLoadSession:t.handlers.handleLoadSessionScrollAware,backgroundAgents:o.backgroundAgents}),e[30]=t.handlers,e[31]=o,e[32]=c,e[33]=a.mobileTab,e[34]=T):T=e[34];let E;e[35]!==a.mobileTab||e[36]!==_||e[37]!==P||e[38]!==A||e[39]!==T?(E=r.jsxs("div",{className:_,children:[P,A,T]},C),e[35]=a.mobileTab,e[36]=_,e[37]=P,e[38]=A,e[39]=T,e[40]=E):E=e[40];let R;e[41]!==g||e[42]!==E?(R=r.jsx("main",{ref:g,className:"app-view-transition flex flex-1 min-h-0 overflow-hidden",children:E}),e[41]=g,e[42]=E,e[43]=R):R=e[43];const $=a.mobileTab==="chat"&&i.processPanel;let I;e[44]!==c||e[45]!==s||e[46]!==a.mobileTab||e[47]!==a.pendingDirName?(I=a.mobileTab==="chat"&&(c||a.pendingDirName)&&r.jsxs(r.Fragment,{children:[s.todoProgress,c?s.activeComposer:s.pendingComposer]}),e[44]=c,e[45]=s,e[46]=a.mobileTab,e[47]=a.pendingDirName,e[48]=I):I=e[48];let M;e[49]!==$||e[50]!==I?(M=r.jsxs("div",{className:"shrink-0",children:[$,I]}),e[49]=$,e[50]=I,e[51]=M):M=e[51];let D;e[52]!==b||e[53]!==a.mobileTab?(D=r.jsx(fO,{activeTab:a.mobileTab,onTabChange:b}),e[52]=b,e[53]=a.mobileTab,e[54]=D):D=e[54];let O;e[55]!==i||e[56]!==o||e[57]!==c||e[58]!==a.sessionChangeKey?(O=c&&o.hasFileChanges&&r.jsx(y.Suspense,{fallback:null,children:r.jsx(bO,{open:i.fileChangesOpen,onClose:()=>i.onFileChangesOpenChange(!1),session:c,sessionChangeKey:a.sessionChangeKey})}),e[55]=i,e[56]=o,e[57]=c,e[58]=a.sessionChangeKey,e[59]=O):O=e[59];let L;return e[60]!==i.backgroundServers||e[61]!==i.branchModal||e[62]!==i.undoDialog||e[63]!==i.workflowsPanel||e[64]!==k||e[65]!==R||e[66]!==M||e[67]!==D||e[68]!==O||e[69]!==w?(L=r.jsxs("div",{className:w,children:[v,S,j,k,R,M,i.workflowsPanel,D,i.undoDialog,i.branchModal,O]}),e[60]=i.backgroundServers,e[61]=i.branchModal,e[62]=i.undoDialog,e[63]=i.workflowsPanel,e[64]=k,e[65]=R,e[66]=M,e[67]=D,e[68]=O,e[69]=w,e[70]=L):L=e[70],L}function yO(n){const e=B.c(13),{sessionId:t,loadError:s,searchInputRef:o,activeComposer:i,hasMoreTurns:a,isLoadingOlderTurns:l,onLoadMoreTurns:c}=n,{theme:d,isMobile:u}=zt(),{session:f}=it(),m=`${d.themeClasses} flex h-dvh flex-col overflow-hidden bg-background text-foreground`;let p;e[0]!==i||e[1]!==a||e[2]!==l||e[3]!==u||e[4]!==s||e[5]!==c||e[6]!==o||e[7]!==f||e[8]!==t?(p=f?r.jsxs("main",{className:"relative flex min-h-0 flex-1 flex-col",children:[r.jsx(Ha,{searchInputRef:o,hasMore:a,isLoadingOlder:l,onLoadMore:c}),u?i:r.jsx(Ya,{floating:!0,children:i})]}):r.jsx("main",{className:"flex min-h-0 flex-1 items-center justify-center p-6",children:r.jsx(ln,{className:"max-w-md",children:r.jsxs(cn,{children:[r.jsx(bn,{variant:"icon",children:s?r.jsx(tn,{}):r.jsx(ot,{className:"animate-spin"})}),r.jsx(dn,{children:s?"Unable to open session":"Opening session"}),r.jsx(vn,{children:s??`Looking for ${t} in your local Claude, Codex, and Copilot history.`})]})})}),e[0]=i,e[1]=a,e[2]=l,e[3]=u,e[4]=s,e[5]=c,e[6]=o,e[7]=f,e[8]=t,e[9]=p):p=e[9];let h;return e[10]!==m||e[11]!==p?(h=r.jsx("div",{className:m,children:p}),e[10]=m,e[11]=p,e[12]=h):h=e[12],h}const wO=5;function _i(n,e){const t=Nn(),s=js();return`${s===null?t:`${t}:${s}`}:${n}/${e}`}class jO{constructor(){ai(this,"cache",new Map)}get(e,t){const s=_i(e,t),o=this.cache.get(s);return o&&(o.lastAccessed=Date.now()),o}set(e,t,s,o,i,a,l,c){const d=_i(e,t);!this.cache.has(d)&&this.cache.size>=wO&&this.evictLRU(),this.cache.set(d,{parsed:s,olderTurns:[],source:{dirName:e,fileName:t,rawText:o,agentKind:l,...c!==void 0?{watchOffset:c}:{}},nextByteOffset:i,hasMore:a,lastAccessed:Date.now()})}update(e,t,s){const o=_i(e,t),i=this.cache.get(o);i&&(s.parsed!==void 0&&(i.parsed=s.parsed),s.olderTurns!==void 0&&(i.olderTurns=s.olderTurns),s.nextByteOffset!==void 0&&(i.nextByteOffset=s.nextByteOffset),s.hasMore!==void 0&&(i.hasMore=s.hasMore),s.lastAccessed!==void 0&&(i.lastAccessed=s.lastAccessed),s.source&&(i.source={...i.source,...s.source}))}evict(e,t){e!==void 0&&t!==void 0?this.cache.delete(_i(e,t)):this.evictLRU()}clear(){this.cache.clear()}evictLRU(){let e,t=1/0;for(const[s,o]of this.cache)o.lastAccessed<t&&(t=o.lastAccessed,e=s);e!==void 0&&this.cache.delete(e)}}const Cn=new jO,dh={};function bb(n,e,t,s,o,i){const[a,l]=y.useState(!1),[c,d]=y.useState("disconnected"),[u,f]=y.useState(!1),[m,p]=y.useState(null),[h,g]=y.useState(dh),[x,b]=y.useState(null),[w,v]=y.useState(ho),S=y.useRef(""),j=y.useRef(null),k=y.useRef(ho),C=y.useRef("disconnected"),N=y.useRef(e);N.current=e;const _=y.useRef(o);_.current=o;const P=y.useRef(t);P.current=t;const A=y.useRef(s);A.current=s;const T=y.useRef(i??null);T.current=i??null;const E=y.useRef(!1),R=(n==null?void 0:n.dirName)??null,$=(n==null?void 0:n.fileName)??null,I=(n==null?void 0:n.rawText)??"",M=(n==null?void 0:n.watchOffset)??new TextEncoder().encode(I).byteLength;return y.useEffect(()=>{if(S.current=I,!I){j.current=null,l(!1);return}const D=T.current;if(D){j.current=D;return}P.current(I).then(O=>{j.current=O})},[I]),y.useEffect(()=>{if(b(null),!R||!$){l(!1),d("disconnected");return}d("connecting");const D=`/api/watch/${encodeURIComponent(R)}/${encodeURIComponent($)}?offset=${M}`,O=new EventSource(Rr(D));let L=null;const F=(ae=3e4)=>{L&&clearTimeout(L),L=setTimeout(()=>{l(!1),f(!1)},ae)};let z="",W=M,U=!1,H=!1,K=!1,V=null;const Y=()=>{K=!1,V=null,j.current&&N.current(j.current)},G=()=>{K||(K=!0,V=requestAnimationFrame(Y))};let J=!1,Q=null,X=null;const Z=()=>{J=!1,Q=null,v(k.current)},te=()=>{J||(J=!0,Q=requestAnimationFrame(Z))},ne=ae=>{ae!==k.current&&(k.current=ae,te(),ae.length>0&&!X&&(X=setInterval(()=>{const se=R_(k.current);se!==k.current&&(k.current=se,te()),k.current.length===0&&X&&(clearInterval(X),X=null)},5e3)))},re=()=>{ne(ho),g(dh)},ie=()=>{if(H||U||!z)return;const ae=z;z="",U=!0;const se=j.current;(se?A.current(se,ae):P.current(S.current)).then(le=>{H||(j.current=le,R&&$&&Cn.update(R,$,{parsed:le,source:{rawText:S.current,watchOffset:W}}),G())}).catch(le=>{console.error("[useLiveSession] worker parse failed:",le)}).finally(()=>{U=!1,!H&&z&&ie()})};return O.onopen=()=>{var ae;if(C.current!=="connected"){const se=E.current;E.current=!1,C.current="connected",d("connected"),se&&((ae=_.current)==null||ae.call(_))}},O.onmessage=ae=>{try{C.current!=="connected"&&(C.current="connected",d("connected"));const se=JSON.parse(ae.data);if(se.type==="init")se.recentlyActive?(l(!0),F(5e3)):F();else if(se.type==="compacting_in_progress")l(!0),f(!0),re(),F();else if(se.type==="subagent_activity")l(!0),F();else if(se.type==="runtime_activity")l(!0),F();else if(se.type==="stream_snapshot")l(!0),F(),ne(E_(se.messages??[]));else if(se.type==="stream_delta")l(!0),F(),p(null),b(null),ne(P_(k.current,se.events??[]));else if(se.type==="agent_progress")l(!0),F(),g(ue=>({...ue,[se.toolUseId]:se.summary}));else if(se.type==="prompt_suggestion")b(typeof se.suggestion=="string"?se.suggestion:null);else if(se.type==="turn_error")p(typeof se.message=="string"?se.message:"The turn failed");else if(se.type==="stream_clear")re();else if(se.type==="lines"&&se.lines.length>0){l(!0),f(!1),F(),ne(A_(k.current,se.lines));const ue=se.lines.join(`
138
- `)+`
139
- `;W+=new TextEncoder().encode(ue).byteLength,S.current+=ue,z+=ue,ie()}}catch(se){console.error("[useLiveSession] Error processing SSE message:",se)}},O.onerror=()=>{l(!1),f(!1),E.current=C.current==="connected",C.current="disconnected",d("disconnected"),re()},()=>{H=!0,O.close(),l(!1),C.current="disconnected",d("disconnected"),L&&clearTimeout(L),V!==null&&cancelAnimationFrame(V),Q!==null&&cancelAnimationFrame(Q),X&&clearInterval(X),k.current=ho,v(ho)}},[R,$,I,M]),{isLive:a,sseState:c,isCompacting:u,streamingOverlay:w,turnError:m,agentProgress:h,promptSuggestion:x}}const SO=3e4;function vb(n,e,t){const s=B.c(9),o=SO,[i,a]=y.useState(!1),l=y.useRef(e);let c,d;s[0]!==e?(c=()=>{l.current=e},d=[e],s[0]=e,s[1]=c,s[2]=d):(c=s[1],d=s[2]),y.useEffect(c,d);let u,f;s[3]!==o||s[4]!==n?(u=()=>{if(!n){a(!1);return}let p=!0,h=null;const g=new EventSource(Rr(n));a(!1);const x=()=>{h&&clearTimeout(h),h=setTimeout(()=>{p&&a(!1)},o)};return g.onmessage=b=>{if(p)try{const w=JSON.parse(b.data);w.type==="init"?x():w.type==="update"&&(a(!0),x(),l.current())}catch{}},g.onerror=()=>{p&&a(!1)},()=>{p=!1,g.close(),h&&clearTimeout(h)}},f=[n,o],s[3]=o,s[4]=n,s[5]=u,s[6]=f):(u=s[5],f=s[6]),y.useEffect(u,f);let m;return s[7]!==i?(m={isLive:i},s[7]=i,s[8]=m):m=s[8],m}function NO(n,e){const t=n?`/api/team-watch/${encodeURIComponent(n)}`:null;return vb(t,e)}function kO(n,e){const[t,s]=y.useState(null),o=y.useRef(null),i=(()=>{if(!n)return null;let l,c=null;const d=n.match(/^([^/]+)\/subagents\/(.+)$/);d?(l=d[1],c=d[2]):l=n.replace(".jsonl","");const u=new URLSearchParams({leadSessionId:l});return c&&u.set("subagentFile",c),e&&u.set("dirName",e),u.toString()})();o.current=i;const a=y.useCallback(async()=>{const l=o.current;if(l)try{const c=await ve(`/api/session-team?${l}`);if(!c.ok){s(null);return}const d=await c.json();s(d?{teamName:d.teamName,config:d.config,currentMemberName:d.currentMemberName||null}:null)}catch{s(null)}},[]);return y.useEffect(()=>{if(!n){s(null);return}a()},[n,a]),NO((t==null?void 0:t.teamName)??null,a),t}function CO(n,e,t,s){let o=null;return n&&e&&(o=`/api/workflow-watch/${encodeURIComponent(n)}/${encodeURIComponent(e)}`,t&&(o=o+`/${encodeURIComponent(t)}`)),vb(o,s)}function _O(n,e,t=!0){const[s,o]=y.useState([]),[i,a]=y.useState(!1),l=y.useRef(0),c=!!n&&!!e,d=y.useCallback(async()=>{const m=++l.current;if(!c){o([]);return}try{const p=await ve(`/api/workflows/${encodeURIComponent(n)}/${encodeURIComponent(e)}`);if(!p.ok){m===l.current&&o([]);return}const h=await p.json();m===l.current&&o(Array.isArray(h)?h:[])}catch{m===l.current&&o([])}finally{m===l.current&&a(!1)}},[c,n,e]);y.useEffect(()=>{if(!c){o([]),a(!1);return}a(!0),d()},[c,d]);const u=c&&(t||s.length>0),{isLive:f}=CO(u?n:null,u?e:null,null,d);return{workflows:s,loading:i,isLive:f,refetch:d}}const ra={mode:"bypassPermissions",allowedTools:[],disallowedTools:[]},TO="cogpit:permissions";function EO(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 uh(n,e){const t=await n.json().catch(()=>({error:e}));return typeof t.error=="string"&&t.error?t.error:e}async function yb(n,{model:e,agentKind:t,errorFallback:s,onModelRejected:o}){const i=d=>typeof s=="function"?s(d):s;let l=await n(t==="copilot"?e||"auto":e||void 0),c=l.ok?null:await uh(l,i(l));return!l.ok&&t==="codex"&&e&&EO(c)&&(o==null||o(e),l=await n(void 0),c=l.ok?null:await uh(l,i(l))),{res:l,errorMessage:c}}function PO({sessionSource:n,parsedSessionId:e,cwd:t,permissions:s,onPermissionsApplied:o,model:i,effort:a,fastMode:l,ultracode:c,mcpConfig:d,onModelRejected:u,readOnly:f=!1,onCreateSession:m}){const[p,h]=y.useState("idle"),[g,x]=y.useState(),[b,w]=y.useState([]),v=y.useRef(null),S=y.useRef(null),j=y.useRef(!1),k=n!=null&&n.fileName?ic(n.fileName):null,C=e||k,N=n?Et(n.dirName):null,_=y.useCallback(()=>{var I;(I=v.current)==null||I.abort(),v.current=null,j.current=!1,h("idle"),x(void 0),w([])},[]);y.useEffect(()=>{var I;S.current!==C&&(j.current?(j.current=!1,(I=v.current)==null||I.abort(),v.current=null,h("idle"),x(void 0)):_(),S.current=C)},[C,_]),y.useEffect(()=>()=>{var I;(I=v.current)==null||I.abort()},[]),y.useEffect(()=>{f&&_()},[f,_]);const P=y.useCallback(async(I,M)=>{if(f)return;if(!C&&m){w(L=>[...L,I]),h("connected"),x(void 0),j.current=!0,o==null||o();try{if(!await m(I,M)){j.current=!1,h("idle"),w([]);return}h("idle")}catch(L){j.current=!1,x(L instanceof Error?L.message:"Failed to create session"),h("error"),w([])}return}if(!C)return;w(L=>[...L,I]),h("connected"),x(void 0);const D=s??ra;o==null||o();const O=new AbortController;v.current=O;try{const L={sessionId:C,message:I,images:M||void 0,cwd:t||void 0,permissions:D,effort:a||void 0,fastMode:l?!0:void 0,ultracode:c?!0:void 0,mcpConfig:d||void 0},{res:F,errorMessage:z}=await yb(W=>ve("/api/send-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...L,model:W}),signal:O.signal}),{model:i,agentKind:N,errorFallback:W=>`Request failed (${W.status})`,onModelRejected:u});v.current===O&&(F.ok?h("idle"):(x(z||`Request failed (${F.status})`),h("error"),w(W=>W.slice(0,-1))))}catch(L){if(L instanceof Error&&L.name==="AbortError")return;v.current===O&&(x(L instanceof Error?L.message:"Unknown error"),h("error"),w(F=>F.slice(0,-1)))}},[C,N,t,s,o,i,a,l,c,d,u,f,m]),A=y.useCallback(()=>{_()},[_]),T=y.useCallback(()=>{!C||f||ve("/api/interrupt-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:C})}).catch(()=>{})},[C,f]),E=y.useCallback(()=>{var I;(I=v.current)==null||I.abort(),v.current=null,T(),h("idle"),w([])},[T]),R=E,$=y.useCallback((I=1)=>{w(M=>M.slice(I))},[]);return{status:p,error:g,pendingMessages:b,sendMessage:P,disconnect:A,interrupt:E,stopAgent:R,consumePending:$,isConnected:p==="connected"}}const us={expandAll:!1,expandToolPayloads:!1},AO={session:null,windowTurns:[],olderTurns:[],sessionSource:null,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...us,sessionChangeKey:0,currentMemberName:null,loadingMember:null,mainView:"sessions",configFilePath:null,mobileTab:"sessions",dashboardProject:null};function fh(n,e,t,s){const o=o2(e,t,s);return o===n.turns?n:{...n,turns:o}}function uo(n){return{session:n,windowTurns:(n==null?void 0:n.turns)??[],olderTurns:[]}}function RO(n,e){var t,s;switch(e.type){case"LOAD_SESSION":return{...n,...uo(e.session),sessionSource:e.source,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...us,mainView:"sessions",currentMemberName:null,dashboardProject:null,sessionChangeKey:n.sessionChangeKey+1,mobileTab:e.isMobile?"chat":n.mobileTab};case"GO_HOME":return{...n,...uo(null),sessionSource:null,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...us,mainView:"sessions",currentMemberName:null,dashboardProject:null,mobileTab:e.isMobile?"sessions":n.mobileTab};case"SWITCH_TEAM_MEMBER":return{...n,...uo(e.session),sessionSource:e.source,activeTurnIndex:null,searchQuery:"",...us,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,...us};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,...us}:{...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:fh(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:fh(n.session,n.windowTurns,e.turns,(s=n.sessionSource)==null?void 0:s.agentKind)};case"RELOAD_SESSION_CONTENT":return{...n,...uo(e.session),sessionSource:e.source,sessionChangeKey:n.sessionChangeKey+1};case"SET_CURRENT_MEMBER_NAME":return n.currentMemberName===e.name?n:{...n,currentMemberName:e.name};case"GUARD_MOBILE_TAB":{let o=n.mobileTab;return!e.hasSession&&(o==="stats"||o==="chat")&&(o="sessions"),o!==n.mobileTab?{...n,mobileTab:o}:n}case"SET_LOADING_MEMBER":return n.loadingMember===e.name?n:{...n,loadingMember:e.name};case"SET_DASHBOARD_PROJECT":return n.dashboardProject===e.dirName?n:{...n,dashboardProject:e.dirName};case"INIT_PENDING_SESSION":return{...n,...uo(null),sessionSource:null,pendingDirName:e.dirName,pendingCwd:e.cwd??null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...us,mainView:"sessions",currentMemberName:null,dashboardProject:null,sessionChangeKey:n.sessionChangeKey+1,mobileTab:e.isMobile?"chat":n.mobileTab};case"FINALIZE_SESSION":return{...n,...uo(e.session),sessionSource:e.source,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...us,mainView:"sessions",currentMemberName:null,dashboardProject:null,sessionChangeKey:n.sessionChangeKey+1,mobileTab:e.isMobile?"chat":n.mobileTab};case"OPEN_CONFIG":return{...n,mainView:"config",configFilePath:e.filePath??null};case"CLOSE_CONFIG":return{...n,mainView:"sessions",configFilePath:null};case"OPEN_MISSION":return{...n,mainView:"mission"};case"CLOSE_MISSION":return{...n,mainView:"sessions"};default:return n}}function wb(){return y.useReducer(RO,AO)}function mh(n){n(),requestAnimationFrame(()=>{n(),requestAnimationFrame(n)})}function jb({session:n,isLive:e,pendingMessages:t,consumePending:s,sessionChangeKey:o,partialContentLen:i=0}){const a=y.useRef(null),l=y.useRef(null),c=y.useRef(!0),d=y.useRef(!1),u=y.useRef(0),f=y.useMemo(()=>(n==null?void 0:n.turns.flatMap(O=>O.contentBlocks.flatMap(L=>L.kind==="queued_prompt"?[{id:JSON.stringify([L.timestamp??"",L.content]),content:L.content}]:[])))??[],[n==null?void 0:n.turns]),m=y.useRef(null),p=y.useRef(!1),[h,g]=y.useState(!1),[x,b]=y.useState(!1),[w,v]=y.useState(null),S=y.useCallback(()=>{requestAnimationFrame(()=>{var O;(O=l.current)==null||O.scrollIntoView({behavior:"smooth"})})},[]),j=y.useCallback(()=>{mh(()=>{const O=a.current;O&&(O.scrollTop=O.scrollHeight),c.current=!0,d.current=!1})},[]),k=y.useCallback(()=>{p.current=!0},[]),C=y.useRef(!1),N=y.useRef(!1),_=y.useCallback(()=>{const O=a.current;if(!O)return;const L=O.scrollTop>10,F=O.scrollHeight-O.scrollTop-O.clientHeight>10;L!==C.current&&(C.current=L,g(L)),F!==N.current&&(N.current=F,b(F))},[]),P=y.useCallback(()=>{const O=a.current;O&&(c.current=O.scrollHeight-O.scrollTop-O.clientHeight<150,_())},[_]),A=y.useCallback(O=>{u.current=O},[]),T=y.useRef(o);y.useEffect(()=>{if(o===T.current)return;T.current=o;const O=p.current;p.current=!1;const L=()=>{const z=a.current;z&&(O?(z.scrollTop=0,c.current=!1):(z.scrollTop=z.scrollHeight,c.current=!0),d.current=!1)};mh(L);const F=setTimeout(()=>{L(),v(o)},150);return()=>clearTimeout(F)},[o]);const E=t.length;y.useEffect(()=>{E>0&&(d.current=!0,S())},[E,S]),y.useEffect(()=>{const O=(n==null?void 0:n.sessionId)??null,L=m.current,F=new Set(f.map(U=>U.id));if(!L||L.sessionId!==O){m.current={sessionId:O,ids:F};return}const z=f.filter(U=>!L.ids.has(U.id));if(m.current={sessionId:O,ids:F},z.length===0||E===0)return;let W=0;for(const U of z){const H=t[W];(H===U.content||(H==null?void 0:H.trim())===""&&U.content.length>0)&&W++}W>0&&s(W)},[n==null?void 0:n.sessionId,f,t,E,s]);const R=(n==null?void 0:n.turns.length)??0;y.useEffect(()=>{if(R===0)return;const O=R-u.current;O>0&&(E>0&&s(Math.min(O,E)),(d.current||c.current)&&(S(),d.current=!1)),u.current=R},[R,E,s,S]);const $=n==null?void 0:n.turns.at(-1),I=($==null?void 0:$.toolCalls.length)??0,M=($==null?void 0:$.assistantText.length)??0;y.useEffect(()=>{if(!(!n||!e)){if(c.current){const O=a.current;O&&(O.scrollTop=O.scrollHeight)}requestAnimationFrame(_)}},[R,I,M,i,e,_]);const D=w===o;return y.useMemo(()=>({chatScrollRef:a,scrollEndRef:l,canScrollUp:h,canScrollDown:x,initialScrollDone:D,handleScroll:P,scrollToBottomInstant:j,requestScrollToTop:k,resetTurnCount:A}),[h,x,D,P,j,k,A])}async function Sb(n,e,t,s){const o=await ve(`/api/sessions/${encodeURIComponent(n)}/${encodeURIComponent(e)}?tail=30`);if(!o.ok)throw new Error(`Failed to load ${s} (${o.status})`);const i=await o.json(),a=new Set(i.headerLines),l=i.tailLines.filter(u=>!a.has(u)),c=[...i.headerLines,...l].join(`
140
- `);return{parsed:await t(c),source:{dirName:n,fileName:e,rawText:c,agentKind:Et(n),watchOffset:i.totalSize},byteOffset:i.byteOffset,hasMore:i.hasMore}}async function qs(n,e,t,s){const o=Cn.get(n,e);if(o)return{parsed:o.parsed,source:o.source};const i=Nn(),a=js(),{parsed:l,source:c,byteOffset:d,hasMore:u}=await Sb(n,e,t,s);if(Nn()!==i||js()!==a)return{parsed:l,source:c};const f=Cn.get(n,e);return f?{parsed:f.parsed,source:f.source}:(Cn.set(n,e,l,c.rawText,d,u,c.agentKind,c.watchOffset),{parsed:l,source:c})}async function Nb(n,e,t,s){Cn.evict(n,e);const o=Nn(),i=js(),{parsed:a,source:l,byteOffset:c,hasMore:d}=await Sb(n,e,t,s);return Nn()===o&&js()===i&&Cn.set(n,e,a,l.rawText,c,d,l.agentKind,l.watchOffset),{parsed:a,source:l}}function IO({dispatch:n,isMobile:e,mobileTab:t="sessions",teamContext:s,scrollToBottomInstant:o,resetTurnCount:i,workerParse:a,onBeforeSwitch:l}){const[c,d]=y.useState(null),u=y.useCallback((b,w)=>{d(null),y.startTransition(()=>{n({type:"LOAD_SESSION",session:b,source:w,isMobile:e})}),i(b.turns.length),AM(b.sessionId,b.turns.length),o()},[n,e,i,o]),f=y.useCallback(async(b,w)=>{l==null||l(),d(null);try{const{parsed:v,source:S}=await qs(b,w,a,"session");u(v,S)}catch(v){d(v instanceof Error?v.message:"Failed to load session")}},[u,a,l]),m=y.useCallback(async b=>{if(s){l==null||l(),d(null),n({type:"SET_LOADING_MEMBER",name:b.name});try{const w=await ve(`/api/team-member-session/${encodeURIComponent(s.teamName)}/${encodeURIComponent(b.name)}`);if(!w.ok)throw new Error(`Failed to find session for ${b.name}`);const{dirName:v,fileName:S}=await w.json(),{parsed:j,source:k}=await qs(v,S,a,`session for ${b.name}`);y.startTransition(()=>{n({type:"SWITCH_TEAM_MEMBER",session:j,source:k,memberName:b.name})}),i(j.turns.length),o()}catch(w){d(w instanceof Error?w.message:"Failed to switch team member")}finally{n({type:"SET_LOADING_MEMBER",name:null})}}},[n,s,i,o,a,l]),p=y.useCallback(()=>d(null),[]),h=y.useCallback(()=>{y.startTransition(()=>{n({type:"GO_HOME",isMobile:e})})},[n,e]),g=y.useCallback((b,w)=>{n({type:"JUMP_TO_TURN",index:b,toolCallId:w})},[n]),x=y.useCallback(b=>{b!==t&&y.startTransition(()=>{n({type:"SET_MOBILE_TAB",tab:b})})},[n,t]);return{loadError:c,clearLoadError:p,handleLoadSession:u,handleDashboardSelect:f,handleTeamMemberSwitch:m,handleGoHome:h,handleJumpToTurn:g,handleMobileTabChange:x}}const $O=/^\/preview\/([^/]+)\/?$/;function Pu(n){const e=$O.exec(n);if(!e)return null;try{const t=decodeURIComponent(e[1]);return t.length>0?t:null}catch{return null}}function kb(){const n=yt();return n===Ct?"":`/d/${n}`}function Lc(){const n=kb();return n?`${n}/`:"/"}function Cb(n){const e=/^\/d\/[^/]+(\/.*)?$/.exec(n);return e?e[1]||"/":n}function MO(n,e){return V3(n,e)}function OO(n){const e=kb();if(n.sessionSource){const{dirName:t,fileName:s}=n.sessionSource,o=q3(t,s);return`${e}/${encodeURIComponent(t)}/${encodeURIComponent(o)}`}return n.pendingDirName?`${e}/${encodeURIComponent(n.pendingDirName)}`:n.dashboardProject?`${e}/${encodeURIComponent(n.dashboardProject)}`:Lc()}function ph(n){const e=Cb(n),t=Pu(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 DO({state:n,dispatch:e,isMobile:t,resetTurnCount:s,scrollToBottomInstant:o,workerParse:i}){const[a,l]=y.useState(null),c=y.useRef(0),d=y.useRef(window.location.pathname),u=y.useRef(!1),f=y.useCallback(async m=>{c.current++;try{if(m.type==="preview"&&m.sessionId){l(null);try{const p=await ve(`/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 qs(h.dirName,h.fileName,i,"session preview");e({type:"LOAD_SESSION",session:g.parsed,source:g.source,isMobile:t}),s(g.parsed.turns.length),o()}catch(p){e({type:"GO_HOME",isMobile:t}),l(p instanceof Error?p.message:"Failed to load session preview.")}}else if(m.type==="session"&&m.dirName&&m.sessionId){l(null);const p=MO(m.dirName,m.sessionId);let h;try{h=await qs(m.dirName,p,i,"session")}catch{e({type:"GO_HOME",isMobile:t});const g=Lc();window.history.replaceState(null,"",g),d.current=g,Oo(yt(),g);return}e({type:"LOAD_SESSION",session:h.parsed,source:h.source,isMobile:t}),s(h.parsed.turns.length),o()}else if(m.type==="project"&&m.dirName)l(null),e({type:"SET_DASHBOARD_PROJECT",dirName:m.dirName});else if(l(null),e({type:"GO_HOME",isMobile:t}),m.normalizeHome){const p=Lc();window.history.replaceState(null,"",p),d.current=p,Oo(yt(),p)}}finally{c.current--}},[e,t,s,o,i]);return y.useEffect(()=>{if(u.current)return;u.current=!0,Oo(yt(),window.location.pathname);const m=ph(window.location.pathname);(m.type!=="home"||m.normalizeHome)&&f(m)},[f]),y.useEffect(()=>{if(c.current>0||Pu(Cb(window.location.pathname)))return;const m=OO(n);m!==d.current&&(window.history.pushState(null,"",m),d.current=m,Oo(yt(),m))},[n.sessionSource,n.pendingDirName,n.mainView,n.dashboardProject]),y.useEffect(()=>{const m=()=>{const p=ph(window.location.pathname);d.current=window.location.pathname,Oo(yt(),window.location.pathname),f(p)};return window.addEventListener("popstate",m),()=>window.removeEventListener("popstate",m)},[f]),{previewLoadError:a}}const LO=400;function hh(){return Array.from(document.querySelectorAll("[data-live-session]"))}function zO(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 gh(n){n.focus({preventScroll:!0});const e=zO(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 FO(n){const e=B.c(20),{isMobile:t,searchInputRef:s,chatInputRef:o,dispatch:i,onToggleSidebar:a,onToggleRightSidebar:l,onToggleMissionControl:c,onOpenCommandPalette:d,onOpenProjectSwitcher:u,onOpenThemeSelector:f,onOpenTerminal:m,onToggleIntegratedTerminal:p,onTogglePreview:h,onToggleProjectFiles:g,onHistoryBack:x,onHistoryForward:b,onNavigateToSession:w,onCommitNavigation:v}=n;let S,j;e[0]!==o||e[1]!==i||e[2]!==t||e[3]!==v||e[4]!==x||e[5]!==b||e[6]!==w||e[7]!==d||e[8]!==u||e[9]!==m||e[10]!==f||e[11]!==p||e[12]!==c||e[13]!==h||e[14]!==g||e[15]!==l||e[16]!==a||e[17]!==s?(S=()=>{if(t)return;let k=!1,C=!1,N=null;const _=function(E){var M,D;const R=Fp("missionControl");if(R){if(E.key===R){E.repeat||(k=!0,C=E.shiftKey||E.altKey||(R==="Meta"?E.ctrlKey:E.metaKey));return}k&&(C=!0),N=null}if(kt("commandPalette",E)){E.preventDefault(),d==null||d();return}if(kt("integratedTerminal",E)){if(!lt("terminal"))return;E.preventDefault(),p();return}if(kt("preview",E)){E.preventDefault(),h();return}if(kt("projectFiles",E)){if(!lt("hostFiles"))return;E.preventDefault(),g();return}if(kt("expandAll",E)){E.preventDefault(),i({type:"SET_EXPAND_ALL",value:!0});return}if(kt("expandToolPayloads",E)){E.preventDefault(),i({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0});return}if(kt("toggleSidebar",E)){E.preventDefault(),a();return}if(kt("toggleStats",E)){E.preventDefault(),l();return}if(kt("missionControl",E)){E.preventDefault(),c();return}if(kt("newSession",E)&&(E.preventDefault(),u()),kt("themeSelector",E)&&(E.preventDefault(),f()),kt("systemTerminal",E)){if(!lt("terminal"))return;E.preventDefault(),m()}if(E.key==="Escape"&&(i({type:"SET_SEARCH_QUERY",value:""}),(M=s.current)==null||M.blur()),(E.metaKey||E.ctrlKey)&&E.shiftKey&&E.code.startsWith("Digit")){const O=parseInt(E.code.charAt(5),10);if(O>=1&&O<=9){E.preventDefault();const F=hh()[O-1];F&&(gh(F),F.click())}}const $=kt("recentSessionForward",E);if($||kt("recentSessionBack",E)){E.preventDefault();const O=$?b():x();O&&w(O.dirName,O.fileName)}kt("focusComposer",E)&&!l2(document.activeElement)&&(E.preventDefault(),(D=o.current)==null||D.focus());const I=kt("nextLiveSession",E);if(I||kt("prevLiveSession",E)){E.preventDefault();const O=hh();if(O.length===0)return;const L=O.findIndex(BO);let F;L===-1?F=I?0:O.length-1:F=Math.max(0,Math.min(O.length-1,L+(I?1:-1))),gh(O[F])}},P=function(E){const R=Fp("missionControl");if(R&&E.key===R&&k){const $=!C;if(k=!1,C=!1,$){const I=Date.now();N!==null&&I-N<=LO?(N=null,E.preventDefault(),c()):N=I}else N=null}E.key==="Control"&&(v==null||v())},A=function(){k=!1,C=!1,N=null};return window.addEventListener("keydown",_),window.addEventListener("keyup",P),window.addEventListener("blur",A),()=>{window.removeEventListener("keydown",_),window.removeEventListener("keyup",P),window.removeEventListener("blur",A)}},j=[t,s,o,i,a,l,c,d,u,f,m,p,h,g,x,b,w,v],e[0]=o,e[1]=i,e[2]=t,e[3]=v,e[4]=x,e[5]=b,e[6]=w,e[7]=d,e[8]=u,e[9]=m,e[10]=f,e[11]=p,e[12]=c,e[13]=h,e[14]=g,e[15]=l,e[16]=a,e[17]=s,e[18]=S,e[19]=j):(S=e[18],j=e[19]),y.useEffect(S,j)}function BO(n){return n===document.activeElement}const xh="cogpit-theme",ZL=[{id:"dark",name:"Default Dark",swatches:["oklch(0.105 0 0)","oklch(0.13 0 0)","oklch(0.16 0 0)","oklch(0.2 0 0)","oklch(0.24 0 0)"]},{id:"oled",name:"Deep OLED",swatches:["oklch(0 0 0)","oklch(0.08 0 0)","oklch(0.10 0 0)","oklch(0.10 0 0)","oklch(0.18 0 0)"]},{id:"light",name:"Light",swatches:["oklch(1 0 0)","oklch(1 0 0)","oklch(1 0 0)","oklch(0.96 0 0)","oklch(0.922 0 0)"]}];function UO(n){switch(n){case"dark":return"dark";case"oled":return"dark theme-oled";case"light":return""}}function _b(){const[n,e]=y.useState(()=>{try{const l=localStorage.getItem(xh);if(l==="dark"||l==="oled"||l==="light")return l}catch{}return"dark"}),[t,s]=y.useState(null),o=y.useCallback(l=>{localStorage.setItem(xh,l),e(l),s(null)},[]),i=t??n,a=UO(i);return y.useEffect(()=>{const l=document.documentElement.classList;l.remove("dark","theme-oled"),i==="dark"?l.add("dark"):i==="oled"&&l.add("dark","theme-oled")},[i]),{theme:n,activeTheme:i,themeClasses:a,setTheme:o,setPreview:s}}const WO="cogpit-session-history",zc=50;function Tb(){return Kt(WO)}function HO(){try{const n=localStorage.getItem(Tb());if(!n)return[];const e=JSON.parse(n);if(Array.isArray(e))return e.slice(0,zc)}catch{}return[]}function bh(n){try{localStorage.setItem(Tb(),JSON.stringify(n))}catch{}}function KO(){const n=B.c(6);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=HO(),n[0]=e):e=n[0];const t=y.useRef(e),s=y.useRef(0),o=y.useRef(!1);let i;n[1]===Symbol.for("react.memo_cache_sentinel")?(i=(h,g)=>{if(o.current){o.current=!1;return}const x=`${h}/${g}`;t.current=t.current.filter(b=>`${b.dirName}/${b.fileName}`!==x),t.current.unshift({dirName:h,fileName:g}),t.current.length>zc&&(t.current.length=zc),s.current=0,bh(t.current)},n[1]=i):i=n[1];const a=i;let l;n[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{if(t.current.length<=1)return null;const h=(s.current+1)%t.current.length;return s.current=h,o.current=!0,t.current[h]},n[2]=l):l=n[2];const c=l;let d;n[3]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{if(t.current.length<=1)return null;const h=(s.current-1+t.current.length)%t.current.length;return s.current=h,o.current=!0,t.current[h]},n[3]=d):d=n[3];const u=d;let f;n[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{if(s.current===0){o.current=!1;return}const h=t.current[s.current];h&&(t.current.splice(s.current,1),t.current.unshift(h),bh(t.current)),s.current=0,o.current=!1},n[4]=f):f=n[4];const m=f;let p;return n[5]===Symbol.for("react.memo_cache_sentinel")?(p={push:a,goBack:c,goForward:u,commitNavigation:m},n[5]=p):p=n[5],p}function Eb(){return Kt(TO)}function vh(){try{const n=localStorage.getItem(Eb());if(n){const e=JSON.parse(n);return{mode:e.mode||ra.mode,allowedTools:Array.isArray(e.allowedTools)?e.allowedTools:[],disallowedTools:Array.isArray(e.disallowedTools)?e.disallowedTools:[]}}}catch{}return ra}function qO(n){localStorage.setItem(Eb(),JSON.stringify(n))}function VO(){const n=B.c(21),[e,t]=y.useState(vh),[s,o]=y.useState(vh),i=y.useRef(!0);let a,l;n[0]!==e?(a=()=>{if(i.current){i.current=!1;return}qO(e)},l=[e],n[0]=e,n[1]=a,n[2]=l):(a=n[1],l=n[2]),y.useEffect(a,l);let c;n[3]!==s.allowedTools||n[4]!==s.disallowedTools||n[5]!==s.mode||n[6]!==e.allowedTools||n[7]!==e.disallowedTools||n[8]!==e.mode?(c=e.mode!==s.mode||JSON.stringify(e.allowedTools)!==JSON.stringify(s.allowedTools)||JSON.stringify(e.disallowedTools)!==JSON.stringify(s.disallowedTools),n[3]=s.allowedTools,n[4]=s.disallowedTools,n[5]=s.mode,n[6]=e.allowedTools,n[7]=e.disallowedTools,n[8]=e.mode,n[9]=c):c=n[9];const d=c;let u;n[10]===Symbol.for("react.memo_cache_sentinel")?(u=j=>{t(k=>({...k,mode:j}))},n[10]=u):u=n[10];const f=u;let m;n[11]===Symbol.for("react.memo_cache_sentinel")?(m=j=>{t(k=>{const C=k.allowedTools.includes(j);return{...k,allowedTools:C?k.allowedTools.filter(N=>N!==j):[...k.allowedTools,j]}})},n[11]=m):m=n[11];const p=m;let h;n[12]===Symbol.for("react.memo_cache_sentinel")?(h=j=>{t(k=>{const C=k.disallowedTools.includes(j);return{...k,disallowedTools:C?k.disallowedTools.filter(N=>N!==j):[...k.disallowedTools,j]}})},n[12]=h):h=n[12];const g=h;let x;n[13]!==e?(x=()=>{o(e)},n[13]=e,n[14]=x):x=n[14];const b=x;let w;n[15]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{t(ra)},n[15]=w):w=n[15];const v=w;let S;return n[16]!==s||n[17]!==e||n[18]!==d||n[19]!==b?(S={config:e,appliedConfig:s,hasPendingChanges:d,setMode:f,toggleAllowedTool:p,toggleDisallowedTool:g,markApplied:b,resetToDefault:v},n[16]=s,n[17]=e,n[18]=d,n[19]=b,n[20]=S):S=n[20],S}const GO=2e3;function YO(n,e){return n.length!==e.length?!1:JSON.stringify(n)===JSON.stringify(e)}function XO(n){const[e,t]=y.useState([]),[s,o]=y.useState(null),[i,a]=y.useState(new Set);y.useEffect(()=>{if(!n){t([]),o(null);return}let d=!1;const u=async()=>{if(!d)try{const h=await ve(`/api/permissions/${encodeURIComponent(n)}`);if(d)return;if(h.ok){const g=await h.json();if(d)return;t(b=>YO(b,g.permissions)?b:g.permissions);const x=g.plan?{type:"plan",provider:"copilot",...g.plan}:null;o(b=>JSON.stringify(b)===JSON.stringify(x)?b:x)}}catch{}},f=()=>{(typeof document>"u"||document.visibilityState==="visible")&&u()},m=()=>{document.visibilityState==="visible"&&u()};f();const p=setInterval(f,GO);return document.addEventListener("visibilitychange",m),()=>{d=!0,clearInterval(p),document.removeEventListener("visibilitychange",m)}},[n]);const l=y.useCallback(async(d,u)=>{if(n){a(f=>new Set(f).add(d));try{await lb(n,d,u)&&t(f=>f.filter(m=>m.requestId!==d))}finally{a(f=>{const m=new Set(f);return m.delete(d),m})}}},[n]),c=y.useCallback(async d=>{if(n)try{await vM(n,d)&&t([])}catch{}},[n]);return{requests:e,plan:s,responding:i,respond:l,respondAll:c}}async function JO(n,e){const t=await ve(`/api/copilot-history/${encodeURIComponent(n)}/preview`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({eventId:e})});return t.ok?await t.json():null}async function QO(n,e,t){const s=await ve(`/api/copilot-history/${encodeURIComponent(n)}/rewind`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({eventId:e,mode:t})}),o=await s.json().catch(()=>null);return!s.ok||(o==null?void 0:o.outcome)!=="success"?{ok:!1,error:(o==null?void 0:o.error)||`Copilot rewind failed${o!=null&&o.outcome?`: ${o.outcome}`:""}`}:{ok:!0}}function ZO(n){return n.file_path??n.path??""}function Pb(n){const e=[];for(const t of n.toolCalls){if(t.isError||Y8(t))continue;const s=ZO(t.input);if(s){if(t.name==="Edit"){const o=t.input.old_string,i=t.input.new_string;o!==void 0&&i!==void 0&&e.push({type:"Edit",filePath:s,oldString:o,newString:i,replaceAll:t.input.replace_all??!1})}else if(t.name==="Write"){const o=t.input.content;o!==void 0&&e.push({type:"Write",filePath:s,content:o})}}}return e}function eD(n,e){return{index:e,userMessage:Oa(n.userMessage),toolCalls:Pb(n),thinkingBlocks:n.thinking.map(t=>t.thinking),assistantText:[...n.assistantText],timestamp:n.timestamp,model:n.model}}function ia(n,e,t){const s=[];for(let o=e;o>t;o--){const i=n[o];if(!i)continue;const a=Pb(i);for(let l=a.length-1;l>=0;l--){const c=a[l];c&&(c.type==="Edit"?s.push({type:"reverse-edit",filePath:c.filePath,oldString:c.newString,newString:c.oldString,replaceAll:c.replaceAll,turnIndex:o}):c.type==="Write"&&s.push({type:"delete-write",filePath:c.filePath,content:c.content,turnIndex:o}))}}return s}function tD(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 or(n,e){const t=[],s=e!==void 0?e+1:n.length;for(let o=0;o<s;o++){const i=n[o];i&&t.push(...tD(i.toolCalls,i.index))}return t}function Ab(n,e,t,s){var l;const o=[];for(let c=e+1;c<n.length;c++){const d=n[c];d&&o.push(eD(d,c))}const i=((l=o[0])==null?void 0:l.userMessage)||"Untitled branch",a=i.length>60?i.slice(0,57)+"...":i;return{id:crypto.randomUUID(),createdAt:new Date().toISOString(),branchPointTurnIndex:e,label:a,turns:o,jsonlLines:t,...s&&s.length>0?{childBranches:s}:{}}}function Rb(n,e){const t=[],s=[];for(const o of n)o.branchPointTurnIndex>e?s.push(o):t.push(o);return{retained:t,scooped:s}}function Ib(n,e,t){const s=e+t,o=[],i=[];for(const a of n)a.branchPointTurnIndex<=s?o.push(a):i.push(a);return{restored:o,remaining:i}}function nD(n){const e=new Set,t=new Set;for(const s of n)e.add(s.filePath),t.add(s.turnIndex);return{turnCount:t.size,fileCount:e.size,filePaths:[...e],operationCount:n.length}}function sD(n,e){return{sessionId:n,currentTurnIndex:e-1,totalTurns:e,branches:[],activeBranchId:null}}function Ti(n,e){return n.length>0?nD(n):{turnCount:e,fileCount:0,filePaths:[],operationCount:0}}function $b(n,e,t){return Ix(Ex(Et(t)),n,e)}function Mb(n,e,t,s){const o=Ex(Et(s)),i=e==null?void 0:e.id;if(i){const a=HC(o,n,i);if(a==="keep-all")return n.length;if(a!==null)return a}return Ix(o,n,t)}class Jo extends Error{constructor(){super("abort")}}async function oD(n,e,t,s,o,i,a){var w;const l=n.targetTurnIndex,c=ia(e.turns,e.turns.length-1,l),d=l+1,u=o.split(`
141
- `).filter(Boolean),f=Mb(u,e.turns[l],d,t.dirName),m=u.slice(f);if(m.length===0)throw a("Unable to locate the selected turn in the current session file"),new Jo;const{retained:p,scooped:h}=Rb(s.branches,l),g=Ab(e.turns,l,m,h),x={...s,currentTurnIndex:l,totalTurns:d,branches:[...p,g],activeBranchId:null},b=So(t.dirName).fileCheckpoints?(w=e.turns[l+1])==null?void 0:w.id:void 0;await i({operations:c,sessionSource:t,sessionMutation:{type:"truncate",keepLines:f,expectedLineCount:u.length},state:x,...b?{checkpoint:{sessionId:e.sessionId,userMessageId:b,cwd:e.cwd}}:{}})}async function rD(n,e,t,s,o,i){var b;const a=n.redoUpToArchiveIndex!==void 0&&n.redoUpToArchiveIndex<s.turns.length-1,l=n.redoUpToArchiveIndex??s.turns.length-1,c=l+1,d=or(s.turns,l),u=a?$b(s.jsonlLines,c,e.dirName):s.jsonlLines.length,f=s.jsonlLines.slice(0,u),m=s.jsonlLines.slice(u),p=s.childBranches??[];let h;if(a&&m.length>0){const{restored:w,remaining:v}=Ib(p,s.branchPointTurnIndex,c),S={...s,branchPointTurnIndex:s.branchPointTurnIndex+c,turns:s.turns.slice(c),jsonlLines:m,label:((b=s.turns[c])==null?void 0:b.userMessage)||s.label,childBranches:v.length>0?v:void 0};h=[...t.branches.map(j=>j.id===s.id?S:j),...w]}else h=[...t.branches.filter(w=>w.id!==s.id),...p];const g={...t,currentTurnIndex:t.currentTurnIndex+c,totalTurns:t.totalTurns+c,branches:h,activeBranchId:null},x=o.split(`
142
- `).filter(Boolean);await i({operations:d,sessionSource:e,sessionMutation:{type:"append",lines:f,expectedLineCount:x.length},state:g})}async function iD(n,e,t,s,o,i,a){var S;let l=[...t.branches],c=o.split(`
143
- `).filter(Boolean);const d=[];if(n.turns.length>s.branchPointTurnIndex+1){const j=ia(n.turns,n.turns.length-1,s.branchPointTurnIndex);d.push(...j);const{retained:k,scooped:C}=Rb(l,s.branchPointTurnIndex);l=k;const N=s.branchPointTurnIndex+1,_=Mb(c,n.turns[s.branchPointTurnIndex],N,e.dirName),P=c.slice(_);if(P.length>0){const A=Ab(n.turns,s.branchPointTurnIndex,P,C);l=[...l,A],c=c.slice(0,_)}}const u=i.branchTurnIndex??s.turns.length-1,f=u+1,m=u<s.turns.length-1,p=or(s.turns,u);d.push(...p);const h=m?$b(s.jsonlLines,f,e.dirName):s.jsonlLines.length,g=s.jsonlLines.slice(0,h),x=s.jsonlLines.slice(h),b=s.childBranches??[];let w;if(m&&x.length>0){const{restored:j,remaining:k}=Ib(b,s.branchPointTurnIndex,f);w=[{...s,branchPointTurnIndex:s.branchPointTurnIndex+f,turns:s.turns.slice(f),jsonlLines:x,label:((S=s.turns[f])==null?void 0:S.userMessage)||s.label,childBranches:k.length>0?k:void 0},...j]}else w=b;const v={...t,currentTurnIndex:s.branchPointTurnIndex+f,totalTurns:s.branchPointTurnIndex+1+f,branches:[...l.filter(j=>j.id!==s.id),...w],activeBranchId:null};await a({operations:d,sessionSource:e,sessionMutation:{type:"splice",keepLines:c.length,lines:g,expectedLineCount:o.split(`
144
- `).filter(Boolean).length},state:v})}const aD=[];function Ob(n,e,t,s=!0){const[o,i]=y.useState(null),[a,l]=y.useState(null),[c,d]=y.useState(!1),[u,f]=y.useState(null),m=y.useRef(null),p=y.useRef(0);y.useEffect(()=>{if(p.current+=1,!s||!n){i(null),l(null),f(null),m.current=null;return}if(n.sessionId===m.current)return;if(m.current=n.sessionId,!So(e==null?void 0:e.dirName).redo){i(null);return}const A=n.sessionId,T=new AbortController;return ve(`/api/undo-state/${encodeURIComponent(A)}`,{signal:T.signal}).then(E=>E.ok?E.json():null).then(E=>{m.current===A&&i(E??null)}).catch(E=>{E instanceof Error&&E.name==="AbortError"||m.current===A&&i(null)}),()=>T.abort()},[s,n==null?void 0:n.sessionId]);const h=y.useCallback(async A=>{try{const T=await ve("/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})}),E=await T.json().catch(()=>null);if(!T.ok)throw f((E==null?void 0:E.error)||"Undo transaction failed"),new Jo;i(A.state)}catch(T){throw T instanceof Jo?T:(f(String(T)),new Jo)}},[]),g=(o==null?void 0:o.branches)??aD,{canRedo:x,redoTurnCount:b,redoBranch:w}=y.useMemo(()=>{if(!n||g.length===0)return{canRedo:!1,redoTurnCount:0,redoBranch:null};for(let A=g.length-1;A>=0;A--){const T=g[A];if(T.branchPointTurnIndex+1===n.turns.length)return{canRedo:!0,redoTurnCount:T.turns.length,redoBranch:T}}return{canRedo:!1,redoTurnCount:0,redoBranch:null}},[n,g]),v=y.useMemo(()=>{if(!w||w.jsonlLines.length===0)return[];try{return Ma(w.jsonlLines.join(`
145
- `)).turns}catch{return[]}},[w]),S=y.useCallback(A=>g.filter(T=>T.branchPointTurnIndex===A),[g]),j=y.useCallback(A=>{if(!s||!n)return;const T=A-1;if(T>=n.turns.length-1||T<-1)return;if(So(e==null?void 0:e.dirName).nativeRewind){const R=n.turns[A];if(!R)return;const $=n.sessionId,I=++p.current,M=()=>p.current===I&&m.current===$,D=R.id.includes("@")?R.id.slice(R.id.lastIndexOf("@")+1):R.id,O=n.turns.length-A;JO(n.sessionId,D).then(L=>{var W;if(!M())return;const F=((W=L==null?void 0:L.files)==null?void 0:W.map(({path:U})=>U).filter(U=>typeof U=="string"))??[],z=L!=null&&L.available?L.fileCount??F.length:0;l({type:"undo",summary:{turnCount:O,fileCount:z,filePaths:F,operationCount:z},targetTurnIndex:T,nativeRewind:{eventId:D,mode:"conversation",filesAvailable:!!(L!=null&&L.available&&z>0)}})}).catch(()=>{M()&&l({type:"undo",summary:{turnCount:O,fileCount:0,filePaths:[],operationCount:0},targetTurnIndex:T,nativeRewind:{eventId:D,mode:"conversation"}})});return}const E=ia(n.turns,n.turns.length-1,T);l({type:"undo",summary:Ti(E,n.turns.length-1-T),targetTurnIndex:T})},[s,n,e==null?void 0:e.dirName]),k=y.useCallback(()=>{if(!s||!x||!w||!n)return;const A=or(w.turns);l({type:"redo",summary:Ti(A,w.turns.length),targetTurnIndex:w.branchPointTurnIndex+w.turns.length,branchId:w.id})},[s,x,w,n]),C=y.useCallback(A=>{if(!s||!x||!w||!n)return;const T=A+1,E=or(w.turns,A);l({type:"redo",summary:Ti(E,T),targetTurnIndex:w.branchPointTurnIndex+T,branchId:w.id,redoUpToArchiveIndex:A})},[s,x,w,n]),N=y.useCallback((A,T)=>{if(!s||!n)return;const E=g.find(M=>M.id===A);if(!E)return;const R=T??E.turns.length-1,$=n.turns.length>E.branchPointTurnIndex+1?ia(n.turns,n.turns.length-1,E.branchPointTurnIndex):[],I=or(E.turns,R);l({type:"branch-switch",summary:Ti([...$,...I],R+1),targetTurnIndex:E.branchPointTurnIndex,branchId:A,branchTurnIndex:R})},[s,n,g]),_=y.useCallback(async(A=!1)=>{if(!s||!a||!n||!e){l(null);return}d(!0),f(null);try{if(a.nativeRewind){const $=A&&a.nativeRewind.filesAvailable?"conversation-and-files":"conversation",I=await QO(n.sessionId,a.nativeRewind.eventId,$);if(!I.ok){f(I.error);return}await t(),l(null);return}const T=o??sD(n.sessionId,n.turns.length),E=await ve(`/api/sessions/${encodeURIComponent(e.dirName)}/${encodeURIComponent(e.fileName)}`);if(!E.ok){f("Failed to read session file");return}const R=await E.text();if(a.type==="undo")await oD(a,n,e,T,R,h,f);else if(a.type==="redo"){const $=g.find(I=>I.id===a.branchId);if(!$){l(null);return}await rD(a,e,T,$,R,h)}else if(a.type==="branch-switch"){const $=g.find(I=>I.id===a.branchId);if(!$){l(null);return}await iD(n,e,T,$,R,a,h)}try{await ve("/api/stop-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:n.sessionId})})}catch{}await t(),l(null)}catch(T){if(!(T instanceof Jo))throw T}finally{d(!1)}},[s,a,n,e,o,g,h,t]),P=y.useCallback(()=>{p.current+=1,l(null),f(null)},[]);return{enabled:s,undoState:o,canRedo:x,redoTurnCount:b,redoGhostTurns:v,branches:g,branchesAtTurn:S,requestUndo:j,requestRedoAll:k,requestRedoUpTo:C,requestBranchSwitch:N,confirmState:a,confirmApply:_,confirmCancel:P,isApplying:c,applyError:u}}async function lD(n){try{const t=await(await fs("/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 yh(n){const e=await ve("/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:K3(t==null?void 0:t.mode,Xs),useBuiltInEditor:(t==null?void 0:t.useBuiltInEditor)===!0}}function cD(){const n=B.c(26),[e,t]=y.useState(!0),[s,o]=y.useState(null),[i,a]=y.useState(null),[l,c]=y.useState(Xs),[d,u]=y.useState(!1),[f,m]=y.useState(null),[p,h]=y.useState(!1),[g,x]=y.useState(0),b=y.useRef(null),w=y.useRef(null);let v;n[0]===Symbol.for("react.memo_cache_sentinel")?(v=U=>{a(U.claudeDir),c(U.defaultAgentKind),C5(U.useBuiltInEditor)},n[0]=v):v=n[0];const S=v;let j;n[1]===Symbol.for("react.memo_cache_sentinel")?(j=async()=>{var K;(K=b.current)==null||K.abort();const U=new AbortController;b.current=U;const H=await lD(U.signal);U.signal.aborted||b.current!==U||(m(H.url),h(H.disabled))},n[1]=j):j=n[1];const k=j;let C,N;n[2]===Symbol.for("react.memo_cache_sentinel")?(C=()=>()=>{var U,H;(U=b.current)==null||U.abort(),(H=w.current)==null||H.abort()},N=[],n[2]=C,n[3]=N):(C=n[2],N=n[3]),y.useEffect(C,N);let _;n[4]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{const U=new AbortController;return t(!0),o(null),yh(U.signal).then(S).catch(H=>{H instanceof Error&&H.name==="AbortError"||(a(null),o(H instanceof Error?H.message:"Failed to load configuration"))}).finally(()=>{U.signal.aborted||t(!1)}),()=>U.abort()},n[4]=_):_=n[4];let P;n[5]!==g?(P=[S,g],n[5]=g,n[6]=P):P=n[6],y.useEffect(_,P);let A,T;n[7]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{const U=()=>x(uD);return window.addEventListener("cogpit-auth-changed",U),()=>window.removeEventListener("cogpit-auth-changed",U)},T=[],n[7]=A,n[8]=T):(A=n[7],T=n[8]),y.useEffect(A,T);let E;n[9]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{k()},n[9]=E):E=n[9];let R;n[10]!==i?(R=[i,k],n[10]=i,n[11]=R):R=n[11],y.useEffect(E,R);let $;n[12]===Symbol.for("react.memo_cache_sentinel")?($=()=>u(!1),n[12]=$):$=n[12];const I=$;let M;n[13]!==i?(M=U=>{if(u(!1),U!==i){a(U),window.location.reload();return}x(dD),k()},n[13]=i,n[14]=M):M=n[14];const D=M;let O;n[15]===Symbol.for("react.memo_cache_sentinel")?(O=()=>u(!0),n[15]=O):O=n[15];const L=O;let F;n[16]===Symbol.for("react.memo_cache_sentinel")?(F=()=>{var H;(H=w.current)==null||H.abort();const U=new AbortController;w.current=U,t(!0),o(null),yh(U.signal).then(K=>{U.signal.aborted||w.current!==U||S(K)}).catch(K=>{U.signal.aborted||w.current!==U||(a(null),o(K instanceof Error?K.message:"Failed to load configuration"))}).finally(()=>{U.signal.aborted||w.current!==U||t(!1)})},n[16]=F):F=n[16];const z=F;let W;return n[17]!==i||n[18]!==s||n[19]!==e||n[20]!==l||n[21]!==D||n[22]!==p||n[23]!==f||n[24]!==d?(W={configLoading:e,configError:s,claudeDir:i,defaultAgentKind:l,setClaudeDir:a,showConfigDialog:d,openConfigDialog:L,handleCloseConfigDialog:I,handleConfigSaved:D,retryConfig:z,networkUrl:f,networkAccessDisabled:p},n[17]=i,n[18]=s,n[19]=e,n[20]=l,n[21]=D,n[22]=p,n[23]=f,n[24]=d,n[25]=W):W=n[25],W}function dD(n){return n+1}function uD(n){return n+1}const wh={authenticated:!0,edition:"personal",user:null,capabilities:ka},wn={authenticated:!1,edition:"personal",user:null,capabilities:Or},Db=Object.keys(ka);function jh(n,e){return n!==null&&n.edition===e&&n.authenticated&&(e==="personal"?n.user===null:n.user!==null)&&Db.every(t=>{var s;return typeof((s=n.capabilities)==null?void 0:s[t])=="boolean"})}function fD(n,e){const t={...Or};for(const s of Db)t[s]=n[s]&&e[s];return t}async function Sh(n,e){try{const t=await n("/api/me",{signal:e});return t.ok?await t.json():null}catch{return null}}async function mD(n){try{const e=await ve("/api/hello",{signal:n});return e.ok?(await e.json()).edition==="team"?"team":"personal":null}catch{return null}}function Wo(n){var e;return go(n),kg(((e=n.user)==null?void 0:e.id)??null),n}function pD(n){const e=B.c(8);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={...wn,checked:!1},e[0]=t):t=e[0];const[s,o]=y.useState(t),[i,a]=y.useState(0),l=y.useRef(null),c=y.useRef(!1);let d;e[1]!==n?(d=()=>{var v;if((v=l.current)==null||v.abort(),n===null){c.current=!1,go(wn),o({...wn,checked:!1});return}const p=c.current;c.current=!1,go(wn),o(S=>p?{...S,capabilities:Or,checked:!1}:{...wn,checked:!1});const h=new AbortController;l.current=h;const g=Bs(),x=Sh(fs,h.signal),b=g?mD(h.signal):Promise.resolve(n),w=g?Sh(ve,h.signal):Promise.resolve(null);return Promise.all([x,b,w]).then(S=>{const[j,k,C]=S;if(h.signal.aborted)return;const N=jh(j,n)?j:n==="personal"?wh:null;if(!N||k===null){o({...Wo(wn),checked:!1});return}if(!g){o({...Wo(N),checked:!0});return}const _=jh(C,k)?C:k==="personal"?wh:null;if(!_){o({...Wo(wn),checked:!1});return}o({...Wo({authenticated:N.authenticated,edition:N.edition,user:N.user,capabilities:fD(N.capabilities,_.capabilities)}),checked:!0})}).catch(()=>{h.signal.aborted||o({...Wo(wn),checked:!1})}),()=>{h.abort(),l.current===h&&(l.current=null)}},e[1]=n,e[2]=d):d=e[2];let u;e[3]!==n||e[4]!==i?(u=[n,i],e[3]=n,e[4]=i,e[5]=u):u=e[5],y.useEffect(d,u);let f,m;return e[6]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{const p=()=>{var g;(g=l.current)==null||g.abort(),c.current=!1,go(wn),kg(null),o({...wn,checked:!1}),a(xD)},h=g=>{var w,v;const x=yt();if(x===Ct)return;const b=(w=g.detail)==null?void 0:w.deviceId;b&&b!==x||((v=l.current)==null||v.abort(),c.current=!0,go(wn),o(gD),a(hD))};return window.addEventListener("cogpit-auth-changed",p),window.addEventListener("cogpit-devices-changed",h),()=>{window.removeEventListener("cogpit-auth-changed",p),window.removeEventListener("cogpit-devices-changed",h)}},m=[],e[6]=f,e[7]=m):(f=e[6],m=e[7]),y.useEffect(f,m),s}function hD(n){return n+1}function gD(n){return{...n,capabilities:Or,checked:!1}}function xD(n){return n+1}const bD=3e4;function vD(n){const[e,t]=y.useState(()=>({dirName:n,worktrees:[],loading:n!==null,error:null})),s=y.useRef(0),o=y.useCallback(async()=>{if(!n)return;const a=++s.current;t(l=>l.dirName===n&&l.loading?l:{dirName:n,worktrees:l.dirName===n?l.worktrees:[],loading:!0,error:l.dirName===n?l.error:null});try{const l=await ve(`/api/worktrees/${encodeURIComponent(n)}`);if(a!==s.current)return;if(l.ok){const c=await l.json();if(a!==s.current)return;t({dirName:n,worktrees:c,loading:!1,error:null});return}t(c=>c.dirName===n?{...c,loading:!1,error:"Failed to fetch worktrees"}:c)}catch(l){if(a!==s.current)return;t(c=>c.dirName===n?{...c,loading:!1,error:l instanceof Error?l.message:"Unknown error"}:c)}},[n]);y.useEffect(()=>{if(!n){s.current+=1;return}o();const a=setInterval(()=>void o(),bD);return()=>{clearInterval(a),s.current+=1}},[n,o]);const i=e.dirName===n?e:{worktrees:[],loading:n!==null,error:null};return{worktrees:i.worktrees,loading:i.loading,error:i.error,refetch:o}}function yD(){const n=B.c(3),[e,t]=y.useState(!1);let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=async()=>{t(!0);try{await ve("/api/kill-all",{method:"POST"})}catch{}setTimeout(()=>t(!1),1500)},n[0]=s):s=n[0];const o=s;let i;return n[1]!==e?(i={killing:e,handleKillAll:o},n[1]=e,n[2]=i):i=n[2],i}function wD(n,e){return n?`${n}.jsonl`:e??null}async function Lb(n){try{const e=await ve(`/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 jD=300,Ql=new Map;function Fc(n,e){const t=Kt(n),s=Ql.get(t),o=s?{...s.patch,...e}:e;s&&clearTimeout(s.timer);const i=setTimeout(()=>{Ql.delete(t),Kt(n)===t&&(async()=>{try{await ve(`/api/session-config/${encodeURIComponent(n)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)})}catch{}})()},jD);Ql.set(t,{patch:o,timer:i})}function Bc(n){return new Set(n.filter(e=>e.status==="connected").map(e=>e.name))}async function Nh(n){const e=await Lb(n);return Array.isArray(e==null?void 0:e.mcpServers)?e.mcpServers:null}function kh(n,e){Fc(n,{mcpServers:e})}async function SD(n){if(!n.ok)return null;const e=await n.json();return{servers:e.servers??[],configs:e.configs??{}}}async function Ch(n,e){try{const t=await ve(n,{signal:e});if(e.aborted)return null;const s=await SD(t);return e.aborted?null:s}catch{return null}}async function _h(n,e,t){const s=Bc(t);if(s.size===0)return[];if(n){const o=await Nh(n);if(o)return o.filter(i=>s.has(i))}if(e&&n!==e){const o=await Nh(e);if(o)return o.filter(i=>s.has(i))}return[...s]}function ND(n,e,t,s=!0){const[o,i]=y.useState([]),[a,l]=y.useState({}),[c,d]=y.useState([]),[u,f]=y.useState(!1),[m,p]=y.useState(!1),h=y.useRef(null),g=y.useRef(e);g.current=e;const x=t??e??null,b=y.useRef(x);b.current=x;const w=y.useRef(void 0);y.useEffect(()=>{var C,N;if(!s||!n){(C=h.current)==null||C.abort(),w.current=void 0,i([]),l({}),d([]),f(!1),p(!1);return}const k=new AbortController;return(N=h.current)==null||N.abort(),i([]),l({}),d([]),f(!0),p(!1),w.current=n,Ch(`/api/mcp-servers?cwd=${encodeURIComponent(n)}`,k.signal).then(async _=>{if(k.signal.aborted||w.current!==n||!_)return;i(_.servers),l(_.configs);const P=await _h(b.current,g.current,_.servers);k.signal.aborted||w.current!==n||d(P)}).finally(()=>{k.signal.aborted||w.current!==n||(f(!1),p(!0))}),()=>k.abort()},[n,s]),y.useEffect(()=>()=>{var k;return(k=h.current)==null?void 0:k.abort()},[]),y.useEffect(()=>{if(o.length===0||!x)return;let k=!1;return _h(x,e,o).then(C=>{k||b.current!==x||d(C)}),()=>{k=!0}},[x]);const v=y.useCallback(k=>{d(C=>{const N=C.includes(k)?C.filter(_=>_!==k):[...C,k];return b.current&&kh(b.current,N),N})},[]),S=y.useCallback(()=>{var C;if(!s||!n)return;(C=h.current)==null||C.abort();const k=new AbortController;h.current=k,f(!0),Ch(`/api/mcp-servers?cwd=${encodeURIComponent(n)}&refresh=1`,k.signal).then(N=>{if(k.signal.aborted||w.current!==n||!N)return;i(N.servers),l(N.configs);const _=Bc(N.servers);d(P=>{const A=P.filter(T=>_.has(T));return b.current&&kh(b.current,A),A})}).finally(()=>{k.signal.aborted||h.current!==k||f(!1)})},[n,s]),j=y.useMemo(()=>{if(o.length===0)return null;const k=Bc(o);if(c.length===k.size&&k.size>0&&c.every(_=>k.has(_))||!c.every(_=>a[_]))return null;const N=Object.fromEntries(c.map(_=>[_,a[_]]));return JSON.stringify({mcpServers:N})},[c,a,o]);return{servers:o,selectedServers:c,mcpConfigJson:j,loading:u,loaded:m,toggleServer:v,refresh:S}}function kD(n){var s,o;const e=B.c(12);let t;e:{if(!n){t=null;break e}let i=null,a;if(e[0]!==i||e[1]!==n.turns){const p=new Map;let h=0;for(const g of n.turns)for(const x of g.toolCalls){if(x.name==="TodoWrite"){const b=x.input;Array.isArray(b.todos)&&(i=b.todos);continue}if(x.name==="TaskCreate"){const b=x.input;h=h+1;const v=((o=(s=x.result)==null?void 0:s.match(/(?:Task\s*#?|task[_ ]?id["': ]+)(\d+)/i))==null?void 0:o[1])??String(h);p.set(v,{id:v,content:b.subject||b.description||`Task ${v}`,activeForm:b.activeForm||b.subject||`Working on task ${v}`,status:"pending",owner:b.owner});continue}if(x.name==="TaskUpdate"){const b=x.input,w=String(b.taskId??"");if(!w)continue;if(b.status==="deleted"){p.delete(w);continue}const v=p.get(w)??{id:w,content:b.subject||b.description||`Task ${w}`,activeForm:b.activeForm||b.subject||`Working on task ${w}`,status:"pending"};p.set(w,{...v,content:b.subject||b.description||v.content,activeForm:b.activeForm||v.activeForm,status:b.status||v.status,owner:b.owner??v.owner,blockedBy:b.addBlockedBy?[...new Set([...v.blockedBy??[],...b.addBlockedBy])]:v.blockedBy})}}a=p.size>0?[...p.values()]:i,e[0]=i,e[1]=n.turns,e[2]=a,e[3]=i}else a=e[2],i=e[3];const l=a;if(!l||l.length===0){t=null;break e}let c;e[4]!==l?(c=l.filter(_D),e[4]=l,e[5]=c):c=e[5];const d=c.length;let u;e[6]!==l?(u=l.find(CD)??null,e[6]=l,e[7]=u):u=e[7];const f=u;let m;e[8]!==d||e[9]!==f||e[10]!==l?(m={todos:l,completed:d,total:l.length,inProgress:f},e[8]=d,e[9]=f,e[10]=l,e[11]=m):m=e[11],t=m}return t}function CD(n){return n.status==="in_progress"}function _D(n){return n.status==="completed"}function TD(n){const e=B.c(4);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];const[s,o]=y.useState(t);let i,a;return e[1]!==n?(i=()=>{if(!n){o([]);return}let l=!1;const c=async function(){try{const f=await ve(`/api/background-agents?cwd=${encodeURIComponent(n)}`);if(l)return;if(f.ok){const m=await f.json();o(m)}}catch{}};c();const d=setInterval(c,5e3);return()=>{l=!0,clearInterval(d)}},a=[n],e[1]=n,e[2]=i,e[3]=a):(i=e[2],a=e[3]),y.useEffect(i,a),s}function ED(n,e){const t=B.c(8),s=e===void 0?!0:e;let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],t[0]=o):o=t[0];const[i,a]=y.useState(o),[l,c]=y.useState(!1),d=y.useRef(void 0);let u,f;t[1]!==n||t[2]!==s?(u=()=>{if(!s){d.current=void 0,a([]),c(!1);return}if(d.current===n)return;d.current=n,c(!0);const p=n?`?cwd=${encodeURIComponent(n)}`:"";ve(`/api/slash-suggestions${p}`).then(PD).then(h=>a(h.suggestions||[])).catch(()=>a([])).finally(()=>c(!1))},f=[n,s],t[1]=n,t[2]=s,t[3]=u,t[4]=f):(u=t[3],f=t[4]),y.useEffect(u,f);let m;return t[5]!==l||t[6]!==i?(m={suggestions:i,loading:l},t[5]=l,t[6]=i,t[7]=m):m=t[7],m}function PD(n){return n.json()}function Th(n,e){const t=B.c(6),[s,o]=Kr(n,e),i=typeof s=="boolean"?s:e;let a;t[0]!==e||t[1]!==o?(a=d=>{o(u=>typeof d=="function"?d(typeof u=="boolean"?u:e):d)},t[0]=e,t[1]=o,t[2]=a):a=t[2];const l=a;let c;return t[3]!==l||t[4]!==i?(c=[i,l],t[3]=l,t[4]=i,t[5]=c):c=t[5],c}function Eh(){if(typeof window>"u")return Pt.fileChanges;try{if(JSON.parse(localStorage.getItem("panel-worktrees-visible")??"false")===!0)return Pt.worktrees;if(JSON.parse(localStorage.getItem("panel-stats-visible")??"false")===!0)return Pt.sessionInfo;if(JSON.parse(localStorage.getItem("panel-file-changes-visible")??"true")===!1)return null}catch{}return Pt.fileChanges}function AD(n,e){const t=B.c(46),[s,o]=Th("panel-sidebar-visible",!0),[i,a]=Th("panel-workflows-visible",!1);let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=Eh(),t[0]=l):l=t[0];const[c,d]=Kr("workspace-panel-active",l);let u;t[1]!==c?(u=typeof c=="string"||c===null?c:Eh(),t[1]=c,t[2]=u):u=t[2];const f=u,[m,p]=y.useState(!1),[h,g]=y.useState(!1);let x;t[3]!==o||t[4]!==s?(x=()=>{y.startTransition(()=>o(!s))},t[3]=o,t[4]=s,t[5]=x):x=t[5];const b=x;let w;t[6]!==a?(w=()=>a(ID),t[6]=a,t[7]=w):w=t[7];const v=w;let S;t[8]!==e||t[9]!==d||t[10]!==n.mainView?(S=H=>{y.startTransition(()=>{const K=n.mainView==="config"||n.mainView==="mission";n.mainView==="config"&&e({type:"CLOSE_CONFIG"}),n.mainView==="mission"&&e({type:"CLOSE_MISSION"}),d(V=>K||V!==H?H:null)})},t[8]=e,t[9]=d,t[10]=n.mainView,t[11]=S):S=t[11];const j=S;let k;t[12]!==e||t[13]!==d||t[14]!==n.mainView?(k=H=>{y.startTransition(()=>{n.mainView==="config"&&e({type:"CLOSE_CONFIG"}),n.mainView==="mission"&&e({type:"CLOSE_MISSION"}),d(H)})},t[12]=e,t[13]=d,t[14]=n.mainView,t[15]=k):k=t[15];const C=k;let N;t[16]!==d?(N=()=>{y.startTransition(()=>d(null))},t[16]=d,t[17]=N):N=t[17];const _=N;let P;t[18]!==e||t[19]!==n.mainView?(P=()=>{const H=n.mainView==="config";y.startTransition(()=>{e({type:H?"CLOSE_CONFIG":"OPEN_CONFIG"})})},t[18]=e,t[19]=n.mainView,t[20]=P):P=t[20];const A=P;let T;t[21]!==e||t[22]!==n.mainView?(T=()=>{const H=n.mainView==="mission";y.startTransition(()=>{e({type:H?"CLOSE_MISSION":"OPEN_MISSION"})})},t[21]=e,t[22]=n.mainView,t[23]=T):T=t[23];const E=T;let R;t[24]!==e?(R=H=>{y.startTransition(()=>{e({type:"OPEN_CONFIG",filePath:H})})},t[24]=e,t[25]=R):R=t[25];const $=R;let I;t[26]===Symbol.for("react.memo_cache_sentinel")?(I=()=>p(!0),t[26]=I):I=t[26];const M=I;let D;t[27]===Symbol.for("react.memo_cache_sentinel")?(D=()=>p(!1),t[27]=D):D=t[27];const O=D;let L;t[28]===Symbol.for("react.memo_cache_sentinel")?(L=()=>g(RD),t[28]=L):L=t[28];const F=L;let z;t[29]===Symbol.for("react.memo_cache_sentinel")?(z=()=>g(!1),t[29]=z):z=t[29];const W=z;let U;return t[30]!==f||t[31]!==_||t[32]!==$||t[33]!==A||t[34]!==E||t[35]!==b||t[36]!==v||t[37]!==C||t[38]!==o||t[39]!==a||t[40]!==m||t[41]!==s||t[42]!==h||t[43]!==i||t[44]!==j?(U={showSidebar:s,showWorkflows:i,activeWorkspacePanel:f,showProjectSwitcher:m,showThemeSelector:h,handleToggleSidebar:b,handleToggleWorkflows:v,toggleWorkspacePanel:j,openWorkspacePanel:C,closeWorkspacePanel:_,handleToggleConfig:A,handleToggleMission:E,handleEditConfig:$,handleOpenProjectSwitcher:M,handleCloseProjectSwitcher:O,handleToggleThemeSelector:F,handleCloseThemeSelector:W,setShowSidebar:o,setShowWorkflows:a},t[30]=f,t[31]=_,t[32]=$,t[33]=A,t[34]=E,t[35]=b,t[36]=v,t[37]=C,t[38]=o,t[39]=a,t[40]=m,t[41]=s,t[42]=h,t[43]=i,t[44]=j,t[45]=U):U=t[45],U}function RD(n){return!n}function ID(n){return!n}function $D(n){var K;const{state:e,dispatch:t,isMobile:s,handleJumpToTurn:o,markPermissionsApplied:i,hasPermsPendingChanges:a,permissionsConfig:l,selectedModel:c,selectedEffort:d,fastMode:u,ultracode:f,mcpConfig:m,scrollRequestScrollToTop:p,handleDashboardSelect:h,workerParse:g}=n,x=y.useCallback(async()=>{if(!e.sessionSource)return;const{dirName:V,fileName:Y}=e.sessionSource;try{const{parsed:G,source:J}=await Nb(V,Y,g,"session");t({type:"RELOAD_SESSION_CONTENT",session:G,source:J})}catch{}},[e.sessionSource,t,g]),[b,w]=y.useState(null),v=y.useCallback(V=>w(V),[]),S=y.useCallback(()=>w(null),[]),j=y.useCallback(async(V,Y)=>{try{const G=await ve("/api/branch-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dirName:V,fileName:Y})});if(!G.ok)return;const J=await G.json(),{parsed:Q,source:X}=await qs(J.dirName,J.fileName,g,"session");t({type:"LOAD_SESSION",session:Q,source:X,isMobile:s})}catch{}},[t,s,g]),k=y.useCallback(()=>{e.sessionSource&&j(e.sessionSource.dirName,e.sessionSource.fileName)},[e.sessionSource,j]),C=y.useCallback(async(V,Y)=>{try{await ve("/api/delete-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dirName:V,fileName:Y})})}catch{}},[]),N=y.useCallback(async V=>{var Q,X;if(!e.sessionSource)return;const{dirName:Y,fileName:G}=e.sessionSource,J=(X=(Q=e.session)==null?void 0:Q.turns[V])==null?void 0:X.id;try{const Z=await ve("/api/branch-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dirName:Y,fileName:G,turnIndex:V,turnUuid:J})});if(!Z.ok)return;const te=await Z.json(),{parsed:ne,source:re}=await qs(te.dirName,te.fileName,g,"session");t({type:"LOAD_SESSION",session:ne,source:re,isMobile:s})}catch{}},[e.sessionSource,e.session,t,s,g]),_=y.useCallback((V,Y)=>{o(V,Y),t({type:"SET_MOBILE_TAB",tab:"chat"})},[o,t]),[P,A]=y.useState({}),T=y.useRef(c);T.current=c;const E=y.useRef(d);E.current=d;const R=y.useRef(m);R.current=m;const $=y.useRef(u);$.current=u;const I=y.useRef(f);I.current=f;const M=y.useRef(l);M.current=l;const D=((K=e.session)==null?void 0:K.sessionId)??null,O=y.useRef(null);y.useEffect(()=>{D!==O.current&&(O.current=D,D&&A(V=>D in V?V:{...V,[D]:{model:T.current,effort:E.current,fastMode:$.current,ultracode:I.current,mcpConfig:R.current}}))},[D]);const L=D?P[D]:void 0,F=m!==((L==null?void 0:L.mcpConfig)??null),z=L!=null&&(c!==L.model||d!==L.effort||u!==L.fastMode||f!==L.ultracode||a||F),W=y.useCallback(async()=>{var te,ne;if(!D)return;const V=T.current,Y=E.current,G=$.current,J=I.current,Q=R.current,X=M.current,Z=((te=e.sessionSource)==null?void 0:te.agentKind)??Et(((ne=e.sessionSource)==null?void 0:ne.dirName)??null);qt(Z).settingsApply==="live"&&await ve(`/api/claude/settings/${encodeURIComponent(D)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:V,effort:Y,fastMode:G,ultracode:J,mcpConfig:Q,permissionMode:X.mode,allowedTools:X.allowedTools,disallowedTools:X.disallowedTools})}),A(re=>({...re,[D]:{model:V,effort:Y,fastMode:G,ultracode:J,mcpConfig:Q}})),i()},[D,e.sessionSource,i]),U=y.useCallback(async()=>{if(D)try{await ve("/api/stop-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:D})})}catch{}},[D]),H=y.useCallback((V,Y)=>{Ns(Y)&&p(),h(V,Y)},[p,h]);return{reloadSession:x,branchModalTurn:b,setBranchModalTurn:w,handleOpenBranches:v,handleCloseBranchModal:S,handleDuplicateSessionByPath:j,handleDuplicateSession:k,handleDeleteSession:C,handleBranchFromHere:N,handleMobileJumpToTurn:_,hasSettingsChanges:z,handleApplySettings:W,handleStopSession:U,handleLoadSessionScrollAware:H}}function zb(){const n=B.c(6),e=y.useRef(null);let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t=new Map,n[0]=t):t=n[0];const s=y.useRef(t),o=y.useRef(0);let i,a;n[1]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{const m=s.current,p=new Worker(new URL("/assets/session-parser.worker-QY58jiXs.js",import.meta.url),{type:"module"});return p.onmessage=h=>{const g=h.data,x=m.get(g.id);x&&(m.delete(g.id),g.type==="result"?x.resolve(g.session):x.reject(new Error(g.error)))},p.onerror=h=>{for(const[,g]of m)g.reject(new Error(`Worker error: ${h.message}`));m.clear()},e.current=p,()=>{p.terminate(),e.current=null;for(const[,h]of m)h.reject(new Error("Worker terminated"));m.clear()}},a=[],n[1]=i,n[2]=a):(i=n[1],a=n[2]),y.useEffect(i,a);let l;n[3]===Symbol.for("react.memo_cache_sentinel")?(l=m=>{const p=e.current;return p?new Promise((h,g)=>{o.current=o.current+1;const x=o.current;s.current.set(x,{resolve:h,reject:g}),p.postMessage({type:"parse",id:x,text:m})}):Promise.resolve().then(()=>Ma(m))},n[3]=l):l=n[3];const c=l;let d;n[4]===Symbol.for("react.memo_cache_sentinel")?(d=(m,p)=>{const h=e.current;return h?new Promise((g,x)=>{o.current=o.current+1;const b=o.current;s.current.set(b,{resolve:g,reject:x}),h.postMessage({type:"append",id:b,existing:m,newText:p})}):Promise.resolve().then(()=>GC(m,p))},n[4]=d):d=n[4];const u=d;let f;return n[5]===Symbol.for("react.memo_cache_sentinel")?(f={parse:c,append:u},n[5]=f):f=n[5],f}const MD=30;function Fb({dirName:n,fileName:e,sessionChangeKey:t,workerParse:s,onOlderTurns:o}){const[i,a]=y.useState(!1),[l,c]=y.useState(!1),d=y.useRef(""),u=y.useRef(null),f=`${n??""}::${e??""}::${t}`;return y.useEffect(()=>{d.current=f,u.current=null,c(!1);const p=n&&e?Cn.get(n,e):void 0;a((p==null?void 0:p.hasMore)??!1),p&&p.olderTurns.length>0&&o(p.olderTurns)},[f,n,e,t,o]),{loadMore:y.useCallback(async()=>{if(!n||!e||u.current)return 0;const p=`${n}::${e}::${t}`,h=Cn.get(n,e);if(!(h!=null&&h.hasMore))return d.current===p&&a(!1),0;const g=Symbol("paging-flight");u.current=g,c(!0);try{const x=await ve(`/api/sessions/${encodeURIComponent(n)}/${encodeURIComponent(e)}?before=${h.nextByteOffset}&count=${MD}`);if(!x.ok)return 0;const b=await x.json(),w=b.lines.length>0&&b.hasMore;if(d.current===p&&a(w),b.lines.length===0)return Cn.update(n,e,{hasMore:w,nextByteOffset:b.byteOffset}),0;const v=new Set(b.headerLines),S=b.lines.filter(C=>!v.has(C)),j=await s([...b.headerLines,...S].join(`
146
- `)),k=o2(h.olderTurns,j.turns,h.source.agentKind);return Cn.update(n,e,{hasMore:w,nextByteOffset:b.byteOffset,olderTurns:k}),d.current!==p?0:(o(k),j.turns.length)}finally{u.current===g&&(u.current=null,d.current===p&&c(!1))}},[n,e,t,s,o]),hasMore:i,isLoadingOlder:l}}function OD(n){const e=B.c(50),{agentKind:t,session:s,sessionSource:o,pendingDirName:i,isLive:a}=n,l=t??Xs,c=Pg(l),[d,u]=y.useState(""),[f,m]=y.useState(""),[p,h]=y.useState(!1),[g,x]=y.useState(!1),b=d||(s==null?void 0:s.model);let w;e[0]!==l||e[1]!==b?(w=aw(l,b),e[0]=l,e[1]=b,e[2]=w):w=e[2];const v=w,S=g&&v;let j;e[3]!==l||e[4]!==f||e[5]!==d||e[6]!==S?(j=S?"xhigh":xa(l,f,d),e[3]=l,e[4]=f,e[5]=d,e[6]=S,e[7]=j):j=e[7];const k=j;let C;e[8]!==l||e[9]!==d?(C=yg(l,d),e[8]=l,e[9]=d,e[10]=C):C=e[10];const N=!!C,_=N&&p;let P;e[11]!==l||e[12]!==d?(P=rw(l,d),e[11]=l,e[12]=d,e[13]=P):P=e[13];const A=P,[T,E]=y.useState(null),R=y.useRef(null),$=(o==null?void 0:o.fileName)??null,I=y.useRef($);let M,D;e[14]!==$?(M=()=>{const Z=I.current;I.current=$,!(Z===null||Z===$)&&x(!1)},D=[$],e[14]=$,e[15]=M,e[16]=D):(M=e[15],D=e[16]),y.useEffect(M,D);let O,L;e[17]!==i?(O=()=>{i&&x(!1)},L=[i],e[17]=i,e[18]=O,e[19]=L):(O=e[18],L=e[19]),y.useEffect(O,L);let F;e[20]!==l?(F=Z=>{u(te=>te===Z?"":te),E(`${Z} is unavailable for this account. Cogpit retried the turn with ${nn(l).displayName}'s default model.`)},e[20]=l,e[21]=F):F=e[21];const z=F;let W;e[22]===Symbol.for("react.memo_cache_sentinel")?(W=()=>{E(null)},e[22]=W):W=e[22];const U=W;let H,K;e[23]!==c||e[24]!==i||e[25]!==d||e[26]!==o?(H=()=>{d&&(!o&&!i||c.some(Z=>Z.value===d)||u(""))},K=[c,d,o,i],e[23]=c,e[24]=i,e[25]=d,e[26]=o,e[27]=H,e[28]=K):(H=e[27],K=e[28]),y.useEffect(H,K);let V,Y;e[29]!==T?(V=()=>{if(!T)return;const Z=setTimeout(()=>E(null),12e3);return()=>clearTimeout(Z)},Y=[T],e[29]=T,e[30]=V,e[31]=Y):(V=e[30],Y=e[31]),y.useEffect(V,Y);const G=s==null?void 0:s.rawMessages;let J,Q;e[32]!==l||e[33]!==a||e[34]!==G?(J=()=>{if(!a||!G||!qt(l).modelFallbackNotices)return;let Z;for(let ae=G.length-1;ae>=0;ae=ae-1,ae){const se=G[ae];if(se.type==="system"&&se.subtype==="model_refusal_fallback"){Z=se;break}}if(!Z)return;const te=typeof Z.uuid=="string"?Z.uuid:`${String(Z.original_model)}:${String(Z.fallback_model)}:${String(Z.request_id)}`;if(R.current===te)return;R.current=te;const ne=typeof Z.original_model=="string"?Z.original_model:"Fable",re=typeof Z.fallback_model=="string"?Z.fallback_model:"Opus",ie=typeof Z.api_refusal_explanation=="string"?` ${Z.api_refusal_explanation}`:"";E(`${ne} could not handle this request, so Claude continued with ${re}.${ie}`)},Q=[a,G,l],e[32]=l,e[33]=a,e[34]=G,e[35]=J,e[36]=Q):(J=e[35],Q=e[36]),y.useEffect(J,Q);let X;return e[37]!==k||e[38]!==_||e[39]!==N||e[40]!==p||e[41]!==z||e[42]!==A||e[43]!==T||e[44]!==f||e[45]!==d||e[46]!==S||e[47]!==v||e[48]!==g?(X={selectedModel:d,setSelectedModel:u,selectedEffort:f,setSelectedEffort:m,fastModeEnabled:p,ultracodeEnabled:g,effectiveEffort:k,fastModeAvailable:N,fastModeActive:_,setFastModeEnabled:h,ultracodeAvailable:v,ultracodeActive:S,setUltracodeEnabled:x,imageInputAvailable:A,modelFallbackNotice:T,dismissModelFallbackNotice:U,handleModelRejected:z},e[37]=k,e[38]=_,e[39]=N,e[40]=p,e[41]=z,e[42]=A,e[43]=T,e[44]=f,e[45]=d,e[46]=S,e[47]=v,e[48]=g,e[49]=X):X=e[49],X}const DD=["model","effort","fastMode","ultracode","permissionMode"];function LD({sessionKey:n,values:e,onHydrate:t}){const s=y.useRef(null),o=y.useRef(null),i=y.useRef(t);i.current=t;const a=y.useRef(e);a.current=e,y.useEffect(()=>{if(s.current=null,o.current=null,!n)return;let c=!1;return Lb(n).then(d=>{if(c||d===null)return;if(DD.some(f=>d[f]!==void 0)){i.current(d);const f=a.current,m={model:d.model??f.model,effort:d.effort??f.effort,fastMode:d.fastMode??f.fastMode,ultracode:d.ultracode??f.ultracode,permissionMode:d.permissionMode??f.permissionMode};o.current=JSON.stringify(m)}else Fc(n,a.current),o.current=JSON.stringify(a.current);s.current=n}),()=>{c=!0}},[n]);const l=JSON.stringify(e);y.useEffect(()=>{!n||s.current!==n||l!==o.current&&(o.current=l,Fc(n,a.current))},[l,n])}function zD(n){const[e,t]=y.useState(new Map),[s,o]=y.useState(null),[i,a]=y.useState(!0),l=y.useRef(new Map),c=y.useRef(null);y.useEffect(()=>{const x=n??null,b=c.current;if(b&&b!==x&&l.current.set(b,{activeId:s,collapsed:i}),x!==b){const w=x?l.current.get(x):null;w?(o(w.activeId),a(w.collapsed)):(o(null),a(!0))}c.current=x},[n]);const d=y.useCallback(()=>a(x=>!x),[]),u=y.useCallback(x=>{t(b=>{const w=new Map(b);return w.set(x.id,x),w}),o(x.id),a(!1)},[]),f=y.useCallback(x=>{t(b=>{const w=new Map(b);return w.delete(x),o(v=>{if(v!==x)return v;const S=[...w.keys()];return S.length>0?S[S.length-1]:null}),w})},[]),m=y.useCallback(x=>{o(x),a(!1)},[]),p=y.useCallback((x,b)=>{t(w=>{const v=w.get(x);if(!v||v.status===b)return w;const S=new Map(w);return S.set(x,{...v,status:b}),S})},[]),h=y.useCallback(x=>{t(b=>{let w=!1;const v=new Map(b),S=new Set(x.map(j=>j.id));for(const[j,k]of v)k.type==="task"&&!S.has(j)&&(v.delete(j),w=!0);for(const j of x){const k=v.get(j.id);k?(k.name!==j.title||k.outputPath!==j.outputPath)&&(v.set(j.id,{...k,name:j.title,outputPath:j.outputPath}),w=!0):(v.set(j.id,{id:j.id,name:j.title,type:"task",status:"running",outputPath:j.outputPath}),w=!0)}return w?v:b})},[]),g=y.useCallback((x,b,w)=>{b&&w&&t(v=>{if(v.has(x))return v;const S=new Map(v);return S.set(x,{id:x,name:w,type:"task",status:"running",outputPath:b}),S}),o(v=>v===x?(a(!0),v):(a(!1),x))},[]);return{processes:e,activeProcessId:s,collapsed:i,toggleCollapse:d,addProcess:u,removeProcess:f,setActive:m,updateProcessStatus:p,handleServersChanged:h,handleToggleServer:g}}function FD(n){const e=B.c(54),{sessionId:t,sessionCwd:s,pendingPath:o,sessionDirName:i,pendingDirName:a,dashboardProject:l,supportsFileWorkspace:c,activeWorkspacePanel:d,openWorkspacePanel:u,closeWorkspacePanel:f}=n,m=zD(t),[p,h]=y.useState(null),[g,x]=y.useState(0),b=y.useRef(0),w=s??o??void 0,v=!!(w&&(p==null?void 0:p.kind)==="preview"&&p.cwd===w),S=(p==null?void 0:p.kind)==="project-files"&&p.anchorCwd===(w??null)?p:null;let j;e[0]!==a||e[1]!==o?(j={path:o,dirName:a},e[0]=a,e[1]=o,e[2]=j):j=e[2];const k=j;let C;e[3]!==l||e[4]!==a||e[5]!==o||e[6]!==s||e[7]!==i?(C=()=>{if(Bs()){console.warn("[open-terminal] unavailable for remote devices");return}const G=s??o??void 0,J=i??a??l??void 0;if(!G&&!J){console.warn("[open-terminal] no project path available");return}ve("/api/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:G,dirName:J})}).then(qD).catch(KD)},e[3]=l,e[4]=a,e[5]=o,e[6]=s,e[7]=i,e[8]=C):C=e[8];const N=C;let _;e[9]!==l||e[10]!==a||e[11]!==o||e[12]!==s||e[13]!==i?(_=G=>{if(Bs()){console.warn("[mcp-auth] unavailable for remote devices");return}const J=s??o??void 0,Q=i??a??l??void 0;!J&&!Q||ve("/api/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:J,dirName:Q,command:"claude /mcp"})}).catch(HD)},e[9]=l,e[10]=a,e[11]=o,e[12]=s,e[13]=i,e[14]=_):_=e[14];const P=_;let A;e[15]!==o||e[16]!==m||e[17]!==s?(A=()=>{const J=[...m.processes.values()].filter(WD).at(-1);if(!J){(s??o)&&x(UD);return}m.activeProcessId===J.id&&!m.collapsed?m.toggleCollapse():m.setActive(J.id)},e[15]=o,e[16]=m,e[17]=s,e[18]=A):A=e[18];const T=A;let E;e[19]!==o||e[20]!==s?(E=()=>{(s??o)&&x(BD)},e[19]=o,e[20]=s,e[21]=E):E=e[21];const R=E;let $;e[22]!==f||e[23]!==w||e[24]!==v?($=()=>{w&&y.startTransition(()=>{f(),h(v?null:{kind:"preview",cwd:w})})},e[22]=f,e[23]=w,e[24]=v,e[25]=$):$=e[25];const I=$;let M;e[26]!==d||e[27]!==f||e[28]!==w||e[29]!==u?(M=()=>{if(w){if(d===Pt.projectFiles){f();return}y.startTransition(()=>{h({kind:"project-files",root:w,anchorCwd:w,request:null}),u(Pt.projectFiles)})}},e[26]=d,e[27]=f,e[28]=w,e[29]=u,e[30]=M):M=e[30];const D=M;let O;e[31]!==w||e[32]!==u||e[33]!==c?(O=G=>{if(!c)return!1;const J=T5(G,w);if(!J)return!1;b.current=b.current+1;const Q=b.current;return y.startTransition(()=>h({kind:"project-files",root:J.root,anchorCwd:w??null,request:J.file?{file:J.file,mode:J.mode,line:J.line,token:Q}:null})),u(Pt.projectFiles),!0},e[31]=w,e[32]=u,e[33]=c,e[34]=O):O=e[34];const L=O;let F,z;e[35]!==L?(z=()=>_5(L),F=[L],e[35]=L,e[36]=F,e[37]=z):(F=e[36],z=e[37]),y.useEffect(z,F);let W;e[38]===Symbol.for("react.memo_cache_sentinel")?(W=()=>{y.startTransition(()=>h(null))},e[38]=W):W=e[38];const U=W,H=!!(w&&d===Pt.projectFiles),K=S==null?void 0:S.root,V=(S==null?void 0:S.request)??null;let Y;return e[39]!==w||e[40]!==P||e[41]!==R||e[42]!==N||e[43]!==T||e[44]!==I||e[45]!==D||e[46]!==g||e[47]!==k||e[48]!==m||e[49]!==v||e[50]!==H||e[51]!==K||e[52]!==V?(Y={processPanel:m,currentCwd:w,showPreview:v,showProjectFiles:H,projectFilesRoot:K,projectFilesRequest:V,launchTerminalRequest:g,pendingProject:k,handleOpenTerminal:N,handleMcpAuth:P,handleToggleIntegratedTerminal:T,handleNewIntegratedTerminal:R,handleTogglePreview:I,handleToggleProjectFiles:D,closeRightWorkspace:U},e[39]=w,e[40]=P,e[41]=R,e[42]=N,e[43]=T,e[44]=I,e[45]=D,e[46]=g,e[47]=k,e[48]=m,e[49]=v,e[50]=H,e[51]=K,e[52]=V,e[53]=Y):Y=e[53],Y}function BD(n){return n+1}function UD(n){return n+1}function WD(n){return n.type==="terminal"}function HD(n){return console.error("[mcp-auth] open-terminal failed:",n)}function KD(n){return console.error("[open-terminal] fetch failed:",n)}function qD(n){n.ok||n.json().then(GD).catch(VD)}function VD(){}function GD(n){return console.error("[open-terminal]",n.error)}function YD(n){const e=n.replace(/<[^>]+>[\s\S]*?<\/[^>]+>/g,"").trim();if(!e)return"";const t=e.split(`
147
- `)[0].trim();return t.length<=60?t:t.slice(0,57)+"..."}const XD={totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:0};function Bb(n,e){return{dirName:n.dirName,fileName:n.fileName,rawText:e,agentKind:Et(n.dirName)}}function JD(n){return{sessionId:n.sessionId,version:"",gitBranch:"",cwd:"",slug:"",name:"",model:"",turns:[],stats:{...XD},rawMessages:[],agentKind:Et(n.dirName)}}function Ub(n){if(!(n!=null&&n.trim()))return null;try{return{rawText:n,parsed:Ma(n)}}catch{return null}}async function QD(n,e,t=3,s=100,o=!0){if(o){const i=Ub(n.initialContent);if(i)return i}for(let i=0;i<t;i++){if(e.signal.aborted)throw new DOMException("Aborted","AbortError");const a=await ve(`/api/sessions/${encodeURIComponent(n.dirName)}/${encodeURIComponent(n.fileName)}`,{signal:e.signal});if(a.ok){const l=await a.text();if(l.trim())try{return{rawText:l,parsed:Ma(l)}}catch{}}i<t-1&&await new Promise(l=>setTimeout(l,s))}return null}async function ZD(n,e,t,s){let o=s;for(let i=0;i<30;i++){if(e.signal.aborted)return;const a=await QD(n,e,1,0,!1);if(a&&a.rawText!==o){t({type:"RELOAD_SESSION_CONTENT",session:a.parsed,source:Bb(n,a.rawText)});return}o=(a==null?void 0:a.rawText)??o,await new Promise(l=>setTimeout(l,200))}}async function Ph(n,e,t,s,o){const i=Ub(n.initialContent),a=(i==null?void 0:i.rawText)??"",l=(i==null?void 0:i.parsed)??JD(n),c=Bb(n,a);return t({type:"FINALIZE_SESSION",session:l,source:c,isMobile:s}),o(l,c),ZD(n,e,t,a),n.sessionId}async function eL(n,e,t,s){const o=await ve(`/api/sessions/${encodeURIComponent(n)}?page=1&limit=10`,{signal:s.signal});if(!o.ok)return null;const i=await o.json(),a=t-3e4,l=e.trim(),c=(i.sessions??[]).filter(u=>{const f=u.lastModified?new Date(u.lastModified).getTime():0;return Number.isFinite(f)&&f>=a}),d=c.find(u=>{var f,m;return((f=u.firstUserMessage)==null?void 0:f.trim())===l||((m=u.lastUserMessage)==null?void 0:m.trim())===l})??c[0];return d?{dirName:n,fileName:d.fileName,sessionId:d.sessionId}:null}function tL({permissionsConfig:n,dispatch:e,isMobile:t,onSessionFinalized:s,onCreateStarted:o,onModelRejected:i,model:a,effort:l,fastMode:c,ultracode:d,mcpConfig:u}){const[f,m]=y.useState(!1),[p,h]=y.useState(null),[g,x]=y.useState(!1),[b,w]=y.useState(""),v=y.useRef(null),S=y.useRef(null),j=y.useRef(null),k=y.useCallback((P,A)=>{S.current=P,j.current=A??null,h(null),m(!1),e({type:"INIT_PENDING_SESSION",dirName:P,cwd:A,isMobile:t})},[e,t]),C=y.useCallback(async(P,A)=>{var M;const T=S.current;if(!T)return null;const E=Et(T),R=j.current;(M=v.current)==null||M.abort();const $=new AbortController;v.current=$,m(!0),h(null),o==null||o(P);const I=Date.now();try{const D=YD(P),O=nn(E),{capabilities:L}=O,F={dirName:T,cwd:O.dirName.lossy?R??void 0:void 0,message:P,images:A,permissions:n,effort:l||void 0,fastMode:c?!0:void 0,ultracode:L.ultracode&&d?!0:void 0,name:L.namedSessions&&D||void 0,worktreeName:L.worktrees&&g?b||lw(P):void 0,mcpConfig:L.mcp&&u||void 0},{res:z,errorMessage:W}=await yb(K=>ve("/api/create-and-send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...F,model:K}),signal:$.signal}),{model:a,agentKind:E,errorFallback:"Unknown error",onModelRejected:i});if(!z.ok){if(E==="codex"){const K=await eL(T,P,I,$);if(K){S.current=null,j.current=null;const V=await Ph(K,$,e,t,s);return D&&V&&Oc(V,D),V}}return h(W||`Failed to create session (${z.status})`),null}const U=await z.json();S.current=null,j.current=null;const H=await Ph(U,$,e,t,s);return D&&H&&Oc(H,D),H}catch(D){return $.signal.aborted||h(D instanceof Error?D.message:"Failed to create session"),null}finally{$.signal.aborted||m(!1)}},[n,a,l,c,d,u,g,b,e,t,s,o,i]),N=y.useCallback(()=>h(null),[]),_=y.useCallback(()=>{var P;(P=v.current)==null||P.abort(),v.current=null,S.current=null,j.current=null,m(!1),h(null)},[]);return{creatingSession:f,createError:p,clearCreateError:N,handleNewSession:k,createAndSend:C,cancelCreation:_,pendingDirNameRef:S,worktreeEnabled:g,setWorktreeEnabled:x,worktreeName:b,setWorktreeName:w}}function nL(n){const e=B.c(40),{permissionsConfig:t,dispatch:s,isMobile:o,defaultAgentKind:i,pendingDirName:a,pendingCwd:l,model:c,effort:d,fastMode:u,ultracode:f,mcpConfig:m,onModelRejected:p}=n,h=y.useRef(null),g=y.useRef(null),[x,b]=y.useState(null);let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w=U=>{var H;(H=h.current)==null||H.call(h,U),setTimeout(()=>{var K;return(K=g.current)==null?void 0:K.call(g)},300),setTimeout(()=>{var K;return(K=g.current)==null?void 0:K.call(g)},2e3)},e[0]=w):w=e[0];let v;e[1]!==s||e[2]!==d||e[3]!==u||e[4]!==o||e[5]!==m||e[6]!==c||e[7]!==p||e[8]!==t||e[9]!==f?(v={permissionsConfig:t,dispatch:s,isMobile:o,onSessionFinalized:w,onCreateStarted:b,onModelRejected:p,model:c,effort:d,fastMode:u,ultracode:f,mcpConfig:m},e[1]=s,e[2]=d,e[3]=u,e[4]=o,e[5]=m,e[6]=c,e[7]=p,e[8]=t,e[9]=f,e[10]=v):v=e[10];const S=tL(v),j=S.handleNewSession,[k,C]=y.useState(null);let N;e[11]===Symbol.for("react.memo_cache_sentinel")?(N=new Map,e[11]=N):N=e[11];const _=y.useRef(N);let P;e[12]===Symbol.for("react.memo_cache_sentinel")?(P=async U=>{if(ci===null)return null;const H=_.current;if(H.has(U))return H.get(U)??null;try{const K=await ve("/api/projects");if(!K.ok)return H.set(U,null),null;const V=await K.json(),Y=Y3(V,U,ci);return H.set(U,Y),Y}catch{return H.set(U,null),null}},e[12]=P):P=e[12];const A=P;let T;e[13]!==j?(T=async(U,H)=>{const K=H??null;if(!K){C(null),j(U);return}const V=Et(U)===ci?ci:null,Y=V?al(V,K):await A(K);C(Y?{discoveredDirName:Y,cwd:K}:null),j(V&&Y?Y:U,K)},e[13]=j,e[14]=T):T=e[14];const E=T;let R;e[15]!==i||e[16]!==E?(R=U=>{const H=al(i,U);E(H,U)},e[15]=i,e[16]=E,e[17]=R):R=e[17];const $=R;let I;e[18]!==j||e[19]!==k?(I=U=>{if(!k)return;const H=al(U,k.cwd,k.discoveredDirName);j(H,k.cwd)},e[18]=j,e[19]=k,e[20]=I):I=e[20];const M=I;let D;e:{if(!S.creatingSession||!a){D=null;break e}const U=x??void 0;let H;e[21]!==l||e[22]!==a||e[23]!==U?(H={dirName:a,cwd:l,firstMessage:U},e[21]=l,e[22]=a,e[23]=U,e[24]=H):H=e[24],D=H}const O=D;let L,F;e[25]!==a?(F=()=>{a||(b(null),C(null))},L=[a],e[25]=a,e[26]=L,e[27]=F):(L=e[26],F=e[27]),y.useEffect(F,L);const z=k?M:void 0;let W;return e[28]!==$||e[29]!==E||e[30]!==S.cancelCreation||e[31]!==S.clearCreateError||e[32]!==S.createAndSend||e[33]!==S.createError||e[34]!==S.creatingSession||e[35]!==S.setWorktreeEnabled||e[36]!==S.worktreeEnabled||e[37]!==O||e[38]!==z?(W={creatingSession:S.creatingSession,createError:S.createError,clearCreateError:S.clearCreateError,createAndSend:S.createAndSend,cancelCreation:S.cancelCreation,worktreeEnabled:S.worktreeEnabled,setWorktreeEnabled:S.setWorktreeEnabled,sessionFinalizedRef:h,liveSessionsRefreshRef:g,pendingSessionInfo:O,pendingAgentKindChange:z,handleStartNewSession:E,handleStartNewFolder:$},e[28]=$,e[29]=E,e[30]=S.cancelCreation,e[31]=S.clearCreateError,e[32]=S.createAndSend,e[33]=S.createError,e[34]=S.creatingSession,e[35]=S.setWorktreeEnabled,e[36]=S.worktreeEnabled,e[37]=O,e[38]=z,e[39]=W):W=e[39],W}const Zl=new Set;function sL(n,e){const t=Nn(),s=js();return`${s===null?t:`${t}:${s}`}:${n}/${e}`}async function oL(n,e,t){const s=sL(n,e);if(!Zl.has(s)&&!Cn.get(n,e)){Zl.add(s);try{await qs(n,e,t,"session prefetch")}catch{}finally{Zl.delete(s)}}}function rL({onAuthenticated:n}){const[e,t]=y.useState(null),[s,o]=y.useState(""),[i,a]=y.useState(""),[l,c]=y.useState(!1),[d,u]=y.useState(null),[f,m]=y.useState(!1),p=e==="team";y.useEffect(()=>{let x=!1;return Tg().then(b=>{x||t(b)}),()=>{x=!0}},[]);const h=y.useCallback(async x=>{if(x.preventDefault(),!(!i.trim()||p&&!s.trim())){m(!0),u(null);try{const b=await fetch("/api/auth/verify",p?{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json","X-Cogpit-Client":"1"},body:JSON.stringify({username:s.trim(),password:i})}:{method:"POST",credentials:"same-origin",cache:"no-store",headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json","X-Cogpit-Client":"1"}}),w=await b.json();b.ok&&w.valid?(va(),a(""),o(""),n()):u(w.error||(p?"Invalid credentials":"Invalid password"))}catch{u("Failed to connect to server")}finally{m(!1)}}},[p,n,i,s]),g=f||!i.trim()||p&&!s.trim();return r.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-4 py-8",children:r.jsx("form",{onSubmit:h,className:"w-full max-w-sm",children:r.jsxs(Jt,{children:[r.jsxs(rn,{children:[r.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:r.jsx(A3,{className:"size-4"})}),r.jsx(an,{children:"Sign in to Cogpit"}),r.jsx(fn,{children:p?"Use your team account to continue.":"Enter the server password to continue."})]}),e===null?r.jsx(Qt,{children:r.jsx("div",{className:"flex min-h-24 items-center justify-center",role:"status","aria-label":"Checking server",children:r.jsx(xt,{className:"size-5 text-muted-foreground"})})}):r.jsxs(r.Fragment,{children:[r.jsxs(Qt,{className:"flex flex-col gap-4",children:[r.jsxs(Ao,{children:[p&&r.jsxs(wt,{children:[r.jsx(jt,{htmlFor:"login-username",children:"Username"}),r.jsx(Ht,{id:"login-username",type:"text",value:s,onChange:x=>o(x.target.value),placeholder:"Username",autoComplete:"username",autoFocus:!0})]}),r.jsxs(wt,{children:[r.jsx(jt,{htmlFor:"login-password",children:"Password"}),r.jsxs(as,{children:[r.jsx(ls,{id:"login-password",type:l?"text":"password",value:i,onChange:x=>a(x.target.value),placeholder:"Password",autoComplete:"current-password",autoFocus:!p}),r.jsx(Pn,{align:"inline-end",children:r.jsx(Fr,{size:"icon-xs",onClick:()=>c(x=>!x),"aria-label":l?"Hide password":"Show password",children:l?r.jsx(ua,{}):r.jsx(ys,{})})})]})]})]}),d&&r.jsxs(ht,{variant:"destructive",children:[r.jsx(tn,{"aria-hidden":"true"}),r.jsx(Tt,{children:"Sign in failed"}),r.jsx(gt,{children:d})]})]}),r.jsx(Io,{children:r.jsxs(ee,{type:"submit",className:"w-full",disabled:g,children:[f&&r.jsx(xt,{"data-icon":"inline-start"}),"Connect"]})})]})]})})})}const Ah=16,Oi="__cogpitBootstrapToken";function iL(){const e=new URLSearchParams(window.location.hash.replace(/^#/,"")).get("bootstrap")||"",t=window.history.state||{},s=e||(typeof t[Oi]=="string"?t[Oi]:"");return e&&window.history.replaceState({...t,[Oi]:e},"",`${window.location.pathname}${window.location.search}`),s}function Rh(){const n={...window.history.state||{}};delete n[Oi],window.history.replaceState(n,"",`${window.location.pathname}${window.location.search}`)}function aL({onAuthenticated:n,onBootstrapClosed:e}){const[t]=y.useState(iL),[s,o]=y.useState(""),[i,a]=y.useState(""),[l,c]=y.useState(""),[d,u]=y.useState(""),[f,m]=y.useState(!1),[p,h]=y.useState(null),[g,x]=y.useState(!1),b=d.length>0&&d!==l,w=!t||!s.trim()||l.length<Ah||d!==l,v=y.useCallback(async S=>{if(S.preventDefault(),!w){x(!0),h(null);try{const j=await fetch("/api/team/bootstrap",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json","X-Cogpit-Client":"1","X-Cogpit-Bootstrap-Token":t},body:JSON.stringify({username:s.trim(),password:l,...i.trim()?{displayName:i.trim()}:{}})}),k=await j.json();if(j.ok){Rh(),c(""),u(""),o(""),a(""),await e(),n();return}if(j.status===410){Rh(),await e();return}h(k.error||"Could not create the admin account")}catch{h("Failed to connect to server")}finally{x(!1)}}},[t,i,w,n,e,l,s]);return r.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-4 py-8",children:r.jsx("form",{onSubmit:v,className:"w-full max-w-md",children:r.jsxs(Jt,{children:[r.jsxs(rn,{children:[r.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:r.jsx(R3,{className:"size-4"})}),r.jsx(an,{children:"Create the first admin"}),r.jsx(fn,{children:"Set up the account that will manage this Cogpit team server."})]}),r.jsxs(Qt,{className:"flex flex-col gap-4",children:[!t&&r.jsxs(ht,{children:[r.jsx(xn,{"aria-hidden":"true"}),r.jsx(Tt,{children:"Setup link required"}),r.jsx(gt,{children:"Open the one-time setup URL shown in the Cogpit server log."})]}),r.jsxs(Ao,{children:[r.jsxs(wt,{children:[r.jsx(jt,{htmlFor:"bootstrap-username",children:"Username"}),r.jsx(Ht,{id:"bootstrap-username",type:"text",value:s,onChange:S=>o(S.target.value),placeholder:"Username",autoComplete:"username",autoFocus:!0}),r.jsx(No,{children:"Use 2 to 32 lowercase letters, numbers, dots, underscores, or hyphens."})]}),r.jsxs(wt,{children:[r.jsxs(jt,{htmlFor:"bootstrap-display-name",children:["Display name ",r.jsx("span",{className:"font-normal text-muted-foreground",children:"Optional"})]}),r.jsx(Ht,{id:"bootstrap-display-name",type:"text",value:i,onChange:S=>a(S.target.value),placeholder:"Display name (optional)",autoComplete:"name"})]}),r.jsxs(wt,{children:[r.jsx(jt,{htmlFor:"bootstrap-password",children:"Password"}),r.jsxs(as,{children:[r.jsx(ls,{id:"bootstrap-password",type:f?"text":"password",value:l,onChange:S=>c(S.target.value),placeholder:"Password",autoComplete:"new-password"}),r.jsx(Pn,{align:"inline-end",children:r.jsx(Fr,{size:"icon-xs",onClick:()=>m(S=>!S),"aria-label":f?"Hide password":"Show password",children:f?r.jsx(ua,{}):r.jsx(ys,{})})})]}),r.jsxs(No,{children:["Use at least ",Ah," characters."]})]}),r.jsxs(wt,{"data-invalid":b,children:[r.jsx(jt,{htmlFor:"bootstrap-confirm-password",children:"Confirm password"}),r.jsx(Ht,{id:"bootstrap-confirm-password",type:f?"text":"password",value:d,onChange:S=>u(S.target.value),placeholder:"Confirm password",autoComplete:"new-password","aria-invalid":b}),b&&r.jsx(bs,{children:"Passwords do not match"})]})]}),p&&r.jsxs(ht,{variant:"destructive",children:[r.jsx(tn,{"aria-hidden":"true"}),r.jsx(Tt,{children:"Could not create the account"}),r.jsx(gt,{children:p})]})]}),r.jsx(Io,{children:r.jsxs(ee,{type:"submit",className:"w-full",disabled:g||w,children:[g&&r.jsx(xt,{"data-icon":"inline-start"}),"Create admin account"]})})]})})})}function lL(){const n=B.c(18);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=ba(),n[0]=e):e=n[0];const t=e,[s,o]=y.useState(null),[i,a]=y.useState(!1),[l,c]=y.useState(!1),d=y.useRef(0);let u,f;n[1]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{let T=!1;return _g().then(E=>{T||o(E)}),()=>{T=!0}},f=[],n[1]=u,n[2]=f):(u=n[1],f=n[2]),y.useEffect(u,f);const m=t?!0:s===null?null:s.edition==="team";let p,h;n[3]!==m?(p=()=>{if(m===null)return;if(!m){a(!0),c(!0);return}let T=!1;const E=d.current;return Kw().then(R=>{!T&&d.current===E&&(a(R),c(!0))}),()=>{T=!0}},h=[m],n[3]=m,n[4]=p,n[5]=h):(p=n[4],h=n[5]),y.useEffect(p,h);let g;n[6]!==(s==null?void 0:s.edition)?(g=()=>{let T=!1;const E=()=>{const R=d.current=d.current+1,$=()=>{T||d.current!==R||(a(!1),c(!0))};if(t||(s==null?void 0:s.edition)==="team"){$();return}Wf().then(I=>{T||d.current!==R||(o(I),I.edition==="team"&&$())})};return window.addEventListener("cogpit-auth-required",E),()=>{T=!0,window.removeEventListener("cogpit-auth-required",E)}},n[6]=s==null?void 0:s.edition,n[7]=g):g=n[7];const x=s==null?void 0:s.edition;let b;n[8]!==x?(b=[x,t],n[8]=x,n[9]=b):b=n[9],y.useEffect(g,b);let w;n[10]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{d.current=d.current+1,a(!0),c(!0),window.dispatchEvent(new Event("cogpit-auth-changed"))},n[10]=w):w=n[10];const v=w;let S;n[11]===Symbol.for("react.memo_cache_sentinel")?(S=async()=>{o(await Wf())},n[11]=S):S=n[11];const j=S;let k;n[12]===Symbol.for("react.memo_cache_sentinel")?(k=()=>{d.current=d.current+1,a(!1),c(!0),qw().finally(cL)},n[12]=k):k=n[12];const C=k,N=(s==null?void 0:s.edition)??null,_=l&&s!==null,P=(s==null?void 0:s.needsBootstrap)===!0;let A;return n[13]!==i||n[14]!==N||n[15]!==_||n[16]!==P?(A={isRemote:t,edition:N,authChecked:_,authenticated:i,needsBootstrap:P,handleAuthenticated:v,refreshServerState:j,logout:C},n[13]=i,n[14]=N,n[15]=_,n[16]=P,n[17]=A):A=n[17],A}function cL(){window.dispatchEvent(new Event("cogpit-auth-changed"))}const dL=y.lazy(()=>qe(()=>import("./index-BhjwMUil.js"),__vite__mapDeps([37,1,2,3,4])).then(n=>({default:n.BranchModal}))),uL=y.lazy(()=>qe(()=>import("./WorkflowsPanel-COZwo8h-.js"),__vite__mapDeps([38,1,4,2,3])).then(n=>({default:n.WorkflowsPanel})));function fL(){var cf,df,uf,ff,mf,pf,hf,gf,xf,bf,vf,yf,wf,jf,Sf,Nf,kf,Cf,_f,Tf;const n=Pu(window.location.pathname),e=cD(),t=lL(),s=pD(t.edition),o=s.checked&&(t.edition!=="team"||s.authenticated&&s.edition==="team"&&s.user!==null),i=o&&s.capabilities.configWrite,a=o&&s.capabilities.hostFiles,l=o&&s.capabilities.terminal,c=Da(),d=_b(),[u,f]=wb(),{procBySession:m}=g0(),{parse:p,append:h}=zb(),g=y.useCallback(ke=>{f({type:"SET_OLDER_TURNS",turns:ke})},[f]),x=y.useCallback((ke,Ge)=>{oL(ke,Ge,p)},[p]),b=Fb({dirName:((cf=u.sessionSource)==null?void 0:cf.dirName)??null,fileName:((df=u.sessionSource)==null?void 0:df.fileName)??null,sessionChangeKey:u.sessionChangeKey,workerParse:p,onOlderTurns:g}),{loadMore:w}=b,v=!!u.searchQuery&&b.hasMore,S=((uf=u.session)==null?void 0:uf.turns.length)??0;y.useEffect(()=>{v&&w()},[v,w,S]);const j=AD(u,f),k=y.useRef(null),C=y.useRef(null),[N,_]=y.useState(!1),[P,A]=y.useState(!1),T=y.useCallback(()=>f({type:"TOGGLE_EXPAND_ALL"}),[f]),E=y.useCallback(()=>_(!0),[]),R=y.useCallback(()=>{var ke;return(ke=C.current)==null?void 0:ke.focus()},[]),$=y.useCallback(()=>f({type:"SET_EXPAND_ALL",value:!0}),[f]),I=y.useCallback(()=>f({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0}),[f]),M=y.useCallback(()=>f({type:"SET_EXPAND_ALL",value:!1}),[f]),D=j.toggleWorkspacePanel,O=y.useCallback(()=>D(Pt.sessionInfo),[D]),L=y.useCallback(ke=>{y.startTransition(()=>{f({type:"SET_DASHBOARD_PROJECT",dirName:ke})})},[f]),F=u.pendingCwd??(u.pendingDirName?_n(u.pendingDirName):null),z=((ff=u.sessionSource)==null?void 0:ff.agentKind)??Et(((mf=u.sessionSource)==null?void 0:mf.dirName)??u.pendingDirName??null),W=(pf=u.session)!=null&&pf.sessionId?m.get(u.session.sessionId):void 0,U=qt(z),H=Eu(z,W),K=U.worktrees,V=U.mcp,Y=ED(i?((hf=u.session)==null?void 0:hf.cwd)??F??void 0:void 0,i&&U.slashCommands),G=y.useCallback(ke=>{if(!i)return;const Ge=Y.suggestions.find(Nt=>Nt.name===ke);y.startTransition(()=>{f({type:"OPEN_CONFIG",filePath:Ge==null?void 0:Ge.filePath})})},[i,f,Y.suggestions]),J=y.useCallback(async(ke,Ge)=>{if(!i)return null;const Nt=Y.suggestions.find(yn=>yn.name===ke);if(!(Nt!=null&&Nt.filePath))return null;try{const yn=await ve("/api/expand-command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:Nt.filePath,args:Ge||""})});return yn.ok?(await yn.json()).content??null:null}catch{return null}},[i,Y.suggestions]),{processPanel:Q,currentCwd:X,showPreview:Z,showProjectFiles:te,projectFilesRoot:ne,projectFilesRequest:re,launchTerminalRequest:ie,pendingProject:ae,handleOpenTerminal:se,handleMcpAuth:ue,handleToggleIntegratedTerminal:le,handleNewIntegratedTerminal:de,handleTogglePreview:pe,handleToggleProjectFiles:he,closeRightWorkspace:ce}=FD({sessionId:(gf=u.session)==null?void 0:gf.sessionId,sessionCwd:(xf=u.session)==null?void 0:xf.cwd,pendingPath:F,sessionDirName:(bf=u.sessionSource)==null?void 0:bf.dirName,pendingDirName:u.pendingDirName,dashboardProject:u.dashboardProject,supportsFileWorkspace:!c&&a,activeWorkspacePanel:j.activeWorkspacePanel,openWorkspacePanel:j.openWorkspacePanel,closeWorkspacePanel:j.closeWorkspacePanel}),ye=kD(u.session??null),[xe,me]=y.useState(!1),je=((vf=u.sessionSource)==null?void 0:vf.dirName)??u.pendingDirName??u.dashboardProject??null,{activeWorkspacePanel:Se,closeWorkspacePanel:Pe,showWorkflows:Re}=j,Ie=vD(o&&K&&u.mainView==="sessions"&&Se===Pt.worktrees?je:null),De=y.useMemo(()=>{const ke=u.session;return ke?ke.turns.some(Ge=>Xi(Ge.toolCalls,ke.cwd)||Ge.subAgentActivity.some(Nt=>Xi(Nt.toolCalls,ke.cwd))):!1},[u.session]),Le=y.useMemo(()=>{if(!u.session||!U.workflows)return 0;let ke=0;for(const Ge of u.session.turns)for(const Nt of Ge.toolCalls)Nt.name==="Workflow"&&ke++;return ke},[u.session,U.workflows]),ze=Le>0,Te=y.useMemo(()=>{const ke=u.sessionSource;return!ke||!U.workflows||Ns(ke.fileName)?{dirName:null,sessionId:null}:{dirName:ke.dirName,sessionId:ic(ke.fileName)}},[u.sessionSource,U.workflows]),Ce=_O(Te.dirName,Te.sessionId,ze),We=ze||Ce.workflows.length>0,Fe=Ce.workflows.length||Le,Ne=j.setShowWorkflows,fe=y.useCallback(()=>Ne(!0),[Ne]),[Oe,Ae]=y.useState(!1),[Be,oe]=y.useState(!1),ge=j.openWorkspacePanel;y.useEffect(()=>{if(!a)return;const ke=()=>{c?Ae(!0):ge(Pt.fileChanges)};return window.addEventListener(yr,ke),()=>window.removeEventListener(yr,ke)},[a,ge,c]);const Ee=y.useMemo(()=>u.session?$x(u.session):null,[u.session]),$e=y.useRef(null),{isLive:He,sseState:Ke,isCompacting:nt,streamingOverlay:Ye,turnError:Me,agentProgress:Ue,promptSuggestion:st}=bb(u.sessionSource,ke=>{y.startTransition(()=>{f({type:"UPDATE_SESSION",session:ke})})},p,h,()=>{var ke;return(ke=$e.current)==null?void 0:ke.call($e)},u.session),Vt=y.useMemo(()=>Ye.reduce((ke,Ge)=>ke+Ge.blocks.reduce((Nt,yn)=>Nt+yn.text.length,0),0),[Ye]),Ft=TD(((yf=u.session)==null?void 0:yf.cwd)??null),Gt=VO(),Vn=Gt.setMode,Bt=XO(H?null:((wf=u.session)==null?void 0:wf.sessionId)??null),Rs=H?null:Bt.plan??Ee,{selectedModel:Ve,setSelectedModel:Ze,selectedEffort:bt,setSelectedEffort:Dt,fastModeEnabled:Gn,ultracodeEnabled:Zs,effectiveEffort:Jr,fastModeAvailable:Kb,fastModeActive:Qr,setFastModeEnabled:Ja,ultracodeAvailable:qb,ultracodeActive:Zr,setUltracodeEnabled:Qa,imageInputAvailable:Au,modelFallbackNotice:Vb,dismissModelFallbackNotice:Gb,handleModelRejected:Ru}=OD({agentKind:z,session:u.session,sessionSource:u.sessionSource,pendingDirName:u.pendingDirName,isLive:He}),Iu=wD((jf=u.session)==null?void 0:jf.sessionId,(Sf=u.sessionSource)==null?void 0:Sf.fileName);LD({sessionKey:Iu,values:{model:Ve,effort:bt,fastMode:Gn,ultracode:Zs,permissionMode:Gt.config.mode},onHydrate:y.useCallback(ke=>{ke.model!==void 0&&Ze(ke.model),ke.effort!==void 0&&Dt(ke.effort),ke.fastMode!==void 0&&Ja(ke.fastMode),ke.ultracode!==void 0&&Qa(ke.ultracode),ke.permissionMode&&Vn(ke.permissionMode)},[Ze,Dt,Ja,Qa,Vn])});const un=ND(V&&i?X:void 0,V&&i?je??void 0:void 0,V&&i?Iu??void 0:void 0,i);y.useEffect(()=>{!K&&Se===Pt.worktrees&&Pe()},[K,Se,Pe]),y.useEffect(()=>{Re&&!We&&Ne(!1)},[Re,We,Ne]);const{creatingSession:$u,createError:Mu,clearCreateError:Yb,createAndSend:Xb,cancelCreation:Ou,worktreeEnabled:Jb,setWorktreeEnabled:Qb,sessionFinalizedRef:ei,liveSessionsRefreshRef:Du,pendingSessionInfo:Lu,pendingAgentKindChange:Zb,handleStartNewSession:zu,handleStartNewFolder:ev}=nL({permissionsConfig:Gt.config,dispatch:f,isMobile:c,defaultAgentKind:e.defaultAgentKind,pendingDirName:u.pendingDirName,pendingCwd:u.pendingCwd,onModelRejected:Ru,model:Ve,effort:Jr,fastMode:Qr,ultracode:Zr,mcpConfig:V&&i?un.mcpConfigJson:null}),vt=PO({sessionSource:u.sessionSource,parsedSessionId:((Nf=u.session)==null?void 0:Nf.sessionId)??null,cwd:(kf=u.session)==null?void 0:kf.cwd,permissions:Gt.config,onPermissionsApplied:Gt.markApplied,model:Ve,effort:Jr,fastMode:Qr,ultracode:Zr,mcpConfig:V&&i?un.mcpConfigJson:null,onModelRejected:Ru,readOnly:H,onCreateSession:u.pendingDirName?Xb:void 0}),Lt=kO(U.agentTeams?((Cf=u.sessionSource)==null?void 0:Cf.fileName)??null:null,((_f=u.sessionSource)==null?void 0:_f.dirName)??null);y.useEffect(()=>{Lt!=null&&Lt.currentMemberName?f({type:"SET_CURRENT_MEMBER_NAME",name:Lt.currentMemberName}):Lt||f({type:"SET_CURRENT_MEMBER_NAME",name:null})},[Lt==null?void 0:Lt.currentMemberName,Lt,f]),y.useEffect(()=>{c&&f({type:"GUARD_MOBILE_TAB",hasSession:!!u.session||!!u.pendingDirName})},[u.session,u.pendingDirName,u.mobileTab,c,f]);const Rn=jb({session:u.session,isLive:He,pendingMessages:vt.pendingMessages,consumePending:vt.consumePending,sessionChangeKey:u.sessionChangeKey,partialContentLen:Vt}),Fu=Rn.chatScrollRef,Bu=Rn.resetTurnCount,Uu=Rn.scrollToBottomInstant,tv=y.useCallback(ke=>{me(ke),requestAnimationFrame(()=>{const Ge=Fu.current;Ge&&Ge.scrollTo({top:Ge.scrollTop+(ke?64:-64),behavior:"smooth"})})},[Fu]);y.useLayoutEffect(()=>{const ke=Ge=>{Bu(0),Uu()};return ei.current=ke,()=>{ei.current===ke&&(ei.current=null)}},[Bu,Uu,ei]);const nv=y.useCallback(()=>{vt.disconnect(),Ou()},[vt.disconnect,Ou]),In=IO({dispatch:f,isMobile:c,mobileTab:u.mobileTab,teamContext:Lt,scrollToBottomInstant:Rn.scrollToBottomInstant,resetTurnCount:Rn.resetTurnCount,workerParse:p,onBeforeSwitch:nv}),sv=y.useCallback(ke=>{y.startTransition(()=>{f({type:"GO_HOME",isMobile:c}),f({type:"SET_DASHBOARD_PROJECT",dirName:ke})})},[f,c]),{previewLoadError:ov}=DO({state:u,dispatch:f,isMobile:c,resetTurnCount:Rn.resetTurnCount,scrollToBottomInstant:Rn.scrollToBottomInstant,workerParse:p}),ti=KO(),Wu=ti.push;y.useEffect(()=>{u.sessionSource&&Wu(u.sessionSource.dirName,u.sessionSource.fileName)},[u.sessionSource,Wu]);const pt=$D({state:{session:u.session,sessionSource:u.sessionSource},dispatch:f,isMobile:c,handleJumpToTurn:In.handleJumpToTurn,markPermissionsApplied:Gt.markApplied,hasPermsPendingChanges:Gt.hasPendingChanges,permissionsConfig:Gt.config,selectedModel:Ve,selectedEffort:Jr,fastMode:Qr,ultracode:Zr,mcpConfig:V&&i?un.mcpConfigJson:null,scrollRequestScrollToTop:Rn.requestScrollToTop,handleDashboardSelect:In.handleDashboardSelect,workerParse:p}),{hasSettingsChanges:Hu,handleApplySettings:Ku}=pt,qu=V&&i&&un.mcpConfigJson!==null,Vu=y.useRef(!1);y.useEffect(()=>{var Nt;const ke=un.loaded&&!Vu.current;Vu.current=un.loaded;const Ge=(Nt=u.session)==null?void 0:Nt.sessionId;ke&&Ge&&qu&&Hu&&Ku()},[un.loaded,qu,Hu,Ku,(Tf=u.session)==null?void 0:Tf.sessionId]),y.useLayoutEffect(()=>($e.current=pt.reloadSession,()=>{$e.current===pt.reloadSession&&($e.current=null)}),[pt.reloadSession]);const Yn=Ob(u.session,u.sessionSource,pt.reloadSession,a),ni=Yn.requestBranchSwitch,si=pt.setBranchModalTurn,rv=y.useCallback((ke,Ge)=>{ni(ke,Ge),si(null)},[ni,si]),iv=y.useCallback(ke=>{ni(ke),si(null)},[ni,si]);FO({isMobile:c,searchInputRef:k,chatInputRef:C,dispatch:f,onToggleSidebar:j.handleToggleSidebar,onToggleRightSidebar:O,onToggleMissionControl:j.handleToggleMission,onOpenCommandPalette:E,onOpenProjectSwitcher:j.handleOpenProjectSwitcher,onOpenThemeSelector:j.handleToggleThemeSelector,onOpenTerminal:se,onToggleIntegratedTerminal:le,onTogglePreview:pe,onToggleProjectFiles:he,onHistoryBack:ti.goBack,onHistoryForward:ti.goForward,onNavigateToSession:In.handleDashboardSelect,onCommitNavigation:ti.commitNavigation});const{killing:av,handleKillAll:lv}=yD(),cs=u.sessionSource?Ns(u.sessionSource.fileName):null,cv=cs!==null&&!!(Lt!=null&&Lt.currentMemberName),Za=cs!==null&&!cv,oi=In.handleDashboardSelect,Gu=y.useCallback(()=>{!u.sessionSource||!cs||oi(u.sessionSource.dirName,cs.parentFileName)},[u.sessionSource,cs,oi]);y.useEffect(()=>{const ke=Ge=>{const{agentId:Nt}=Ge.detail??{};if(!Nt||!u.sessionSource||!U.subagentTranscripts)return;const yn=cs?cs.parentSessionId:ic(u.sessionSource.fileName);oi(u.sessionSource.dirName,`${yn}/subagents/agent-${Nt}.jsonl`)};return window.addEventListener(Ji,ke),()=>window.removeEventListener(Ji,ke)},[u.sessionSource,cs,oi,U.subagentTranscripts]);const[dv,Yu]=y.useState(null),uv=pt.branchModalTurn!==null,eo=pt.branchModalTurn??dv;y.useEffect(()=>{pt.branchModalTurn!==null&&Yu(pt.branchModalTurn)},[pt.branchModalTurn]);const Xu=eo!==null?Yn.branchesAtTurn(eo):[],fv=Za?r.jsxs("div",{className:"flex shrink-0 items-center justify-center gap-2 border-t bg-card px-4 py-2.5",children:[r.jsx(yo,{"data-icon":"inline-start",className:"size-3.5 text-muted-foreground"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:"Viewing sub-agent session (read-only)"})]}):null,mv=H?r.jsxs("div",{role:"status",className:"flex shrink-0 items-center justify-center gap-2 border-t bg-card px-4 py-2.5",children:[r.jsx(yo,{"data-icon":"inline-start",className:"size-3.5 text-muted-foreground"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:fj(z)})]}):null,el=fv||mv,pv=In.loadError||Mu||null;let tl;In.loadError?tl=In.clearLoadError:Mu&&(tl=Yb);const hv=!!(u.session&&u.sessionSource&&Ke==="disconnected"),nl=y.useMemo(()=>({state:u,dispatch:f,config:e,theme:d,networkAuth:t,me:s,isMobile:c}),[u.activeTurnIndex,u.activeToolCallId,u.searchQuery,u.expandAll,u.expandToolPayloads,u.mainView,u.mobileTab,u.dashboardProject,u.pendingDirName,u.pendingCwd,u.currentMemberName,u.loadingMember,u.configFilePath,u.sessionChangeKey,f,e,d,t,s,c]),sl=y.useMemo(()=>({session:u.session,sessionSource:u.sessionSource,isLive:He,sseState:Ke,isCompacting:nt,turnError:Me,promptSuggestion:st,undoRedo:Yn,pendingInteraction:Rs,permissionRequests:Bt.requests,permissionResponding:Bt.responding,respondPermission:Bt.respond,respondAllPermissions:Bt.respondAll,isSubAgentView:Za,slashSuggestions:Y.suggestions,slashSuggestionsLoading:Y.loading,actions:{handleStopSession:pt.handleStopSession,handleEditConfig:i?j.handleEditConfig:void 0,handleEditCommand:i?G:void 0,handleExpandCommand:i?J:void 0,handleOpenBranches:pt.handleOpenBranches,handleBranchFromHere:pt.handleBranchFromHere,handleToggleExpandAll:T,handleLoadSession:pt.handleLoadSessionScrollAware}}),[u.session,u.sessionSource,He,Ke,nt,Me,st,Yn,Rs,Za,Bt.requests,Bt.responding,Bt.respond,Bt.respondAll,Y.suggestions,Y.loading,pt.handleStopSession,i,j.handleEditConfig,G,J,pt.handleOpenBranches,pt.handleBranchFromHere,T,pt.handleLoadSessionScrollAware]),ol=y.useMemo(()=>({chat:{status:vt.status,error:vt.error,pendingMessages:vt.pendingMessages,isConnected:vt.isConnected,sendMessage:vt.sendMessage,interrupt:vt.interrupt,stopAgent:vt.stopAgent,consumePending:vt.consumePending},scroll:Rn}),[vt.status,vt.error,vt.pendingMessages,vt.isConnected,vt.sendMessage,vt.interrupt,vt.stopAgent,vt.consumePending,Rn]),Mo=!!u.pendingDirName&&!u.session;if(y.useEffect(()=>{if(!Mo||c)return;const ke=requestAnimationFrame(()=>{var Ge;return(Ge=C.current)==null?void 0:Ge.focus()});return()=>cancelAnimationFrame(ke)},[Mo,c,u.pendingDirName]),!t.authChecked)return r.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-background",role:"status","aria-label":"Checking authentication",children:r.jsx(ot,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(!t.authenticated)return t.needsBootstrap?r.jsx(aL,{onAuthenticated:t.handleAuthenticated,onBootstrapClosed:t.refreshServerState}):r.jsx(rL,{onAuthenticated:t.handleAuthenticated});if(!o)return r.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-background",role:"status","aria-label":"Loading identity",children:r.jsx(ot,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(e.configLoading)return r.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-background",role:"status","aria-label":"Loading",children:r.jsx(ot,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(e.configError)return r.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-background text-foreground",children:r.jsxs(ln,{children:[r.jsxs(cn,{children:[r.jsx(bn,{variant:"icon",children:r.jsx(xn,{className:"text-destructive"})}),r.jsx(dn,{children:"Failed to connect"}),r.jsx(vn,{children:e.configError})]}),r.jsx(wg,{children:r.jsxs(ee,{variant:"outline",size:"sm",onClick:e.retryConfig,children:[r.jsx(Ot,{"data-icon":"inline-start"}),"Retry"]})})]})});if(!e.claudeDir)return i?r.jsx(N5,{onConfigured:e.setClaudeDir}):r.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-background text-sm text-muted-foreground",children:"Cogpit is waiting for an administrator to finish server setup."});const rl=r.jsx(Bw,{activeError:pv,clearActiveError:tl,modelFallbackNotice:Vb,dismissModelFallbackNotice:Gb,connectionLost:hv,theme:d.activeTheme}),Ju=a?r.jsx(g5,{state:Yn.confirmState,isApplying:Yn.isApplying,applyError:Yn.applyError,onConfirm:Yn.confirmApply,onCancel:Yn.confirmCancel}):null,gv=eo!==null&&u.session?u.session.turns.slice(eo):[],Qu=a&&eo!==null&&Xu.length>0&&r.jsx(y.Suspense,{fallback:null,children:r.jsx(dL,{open:uv,branches:Xu,branchPointTurnIndex:eo,currentTurns:gv,onClose:pt.handleCloseBranchModal,onCloseComplete:()=>Yu(null),onRedoToTurn:rv,onRedoEntireBranch:iv})}),Zu=l&&r.jsx(r5,{processes:Q.processes,activeProcessId:Q.activeProcessId,collapsed:Q.collapsed,onSetActive:Q.setActive,onRemove:Q.removeProcess,onToggleCollapse:Q.toggleCollapse,onRequestTerminal:lt("terminal")?de:void 0,onAddTerminalContext:ke=>{var Ef,Pf,Af;const Ge=ke.trim();if(!Ge)return;const Nt=Ge.includes("```")?"````":"```",yn=`${Nt}terminal
148
- ${Ge}
149
- ${Nt}`,il=((Ef=C.current)==null?void 0:Ef.getText().trimEnd())??"";(Pf=C.current)==null||Pf.setText(il?`${il}
150
-
151
- ${yn}
152
- `:`${yn}
153
- `),(Af=C.current)==null||Af.focus()},onUpdateStatus:Q.updateProcessStatus,projectDir:X,onProcessStarted:Q.addProcess,mobile:c}),ef=Lt&&r.jsx(tS,{teamName:Lt.config.name||Lt.teamName,members:Lt.config.members,currentMemberName:u.currentMemberName,loadingMember:u.loadingMember,onMemberClick:In.handleTeamMemberSwitch}),tf=We&&r.jsx(y.Suspense,{fallback:null,children:r.jsx(uL,{open:j.showWorkflows,onOpenChange:j.setShowWorkflows,dirName:Te.dirName,sessionId:Te.sessionId,workflows:Ce.workflows,isLive:Ce.isLive,onRefetchList:Ce.refetch},`${Te.dirName??""}:${Te.sessionId??""}`)}),ri=U.goals?u.session:null,nf=ke=>{var Ge;return r.jsx(Jj,{agentKind:z,onAgentKindChange:Mo?Zb:void 0,selectedModel:Ve,onModelChange:Ze,selectedEffort:Jr,onEffortChange:Dt,fastModeEnabled:Qr,onFastModeEnabledChange:Kb?Ja:void 0,isNewSession:Mo,worktreeEnabled:Jb,onWorktreeEnabledChange:Mo&&K?Qb:void 0,ultracodeEnabled:Zr,onUltracodeEnabledChange:qb?Qa:void 0,onApplySettings:pt.handleApplySettings,activeModelId:(Ge=u.session)==null?void 0:Ge.model,mcpServers:V&&i?un.servers:void 0,selectedMcpServers:V&&i?un.selectedServers:void 0,onToggleMcpServer:V&&i?un.toggleServer:void 0,onRefreshMcpServers:V&&i?un.refresh:void 0,mcpLoading:V&&i?un.loading:void 0,onMcpAuth:V&&i?ue:void 0,permissionMode:Gt.config.mode,onPermissionModeChange:Gt.setMode,mobileExtra:c&&ke&&ri?r.jsx($4,{}):void 0,trailingExtra:!c&&ke&&ri?r.jsx(d1,{}):void 0,mobile:c})},sf=nf(!0),of=nf(!1),rf=r.jsxs("div",{className:"shrink-0 bg-background",children:[!c&&r.jsx(c1,{}),r.jsx(pc,{ref:C,allowImages:Au,agentKind:z,projectCwd:X,compact:c,leadingAccessory:c?sf:void 0}),!c&&sf]}),ii=ri?r.jsx(I4,{agentKind:z,session:ri,onSendCommand:vt.sendMessage,children:rf}):rf,xv=r.jsxs("div",{className:"shrink-0 bg-background",children:[r.jsx(pc,{ref:C,allowImages:Au,agentKind:z,projectCwd:X,compact:c,leadingAccessory:c?of:void 0}),!c&&of]}),af=vt.pendingMessages.map((ke,Ge)=>r.jsx(Vx,{message:ke,turnNumber:Ge+1},Ge)),bv=c?u.mobileTab==="stats":j.activeWorkspacePanel===Pt.sessionInfo,lf=u.session&&!bv&&r.jsx("div",{className:"hidden",children:r.jsx(x1,{cwd:u.session.cwd,turns:u.session.turns,onServersChanged:Q.handleServersChanged})});return n?r.jsxs(Ii,{value:nl,children:[r.jsx(ml,{children:r.jsx(Ai,{value:sl,chatValue:ol,children:r.jsx(kl,{value:Ye,agentProgress:Ue,children:r.jsx(yO,{sessionId:n,loadError:ov,searchInputRef:k,activeComposer:el||xv,hasMoreTurns:b.hasMore,isLoadingOlderTurns:b.isLoadingOlder,onLoadMoreTurns:b.loadMore})})})}),rl]}):c?r.jsxs(Ii,{value:nl,children:[r.jsx(ml,{enabled:l,children:r.jsx(Ai,{value:sl,chatValue:ol,children:r.jsx(kl,{value:Ye,agentProgress:Ue,children:r.jsx(vO,{navigation:{actions:In,handlers:pt,creatingSession:$u,pendingSession:Lu,onStartNewSession:zu,onSelectProject:L,liveSessionsRefreshRef:Du,onPrefetchSession:x},sessionView:{searchInputRef:k,teamMembersBar:ef,activeComposer:el||ii,pendingComposer:ii,pendingTurns:af,todoProgress:ye&&r.jsx(Gx,{progress:ye}),hasMoreTurns:b.hasMore,isLoadingOlderTurns:b.isLoadingOlder,onLoadMoreTurns:b.loadMore,onBackToMain:Gu,onShowWorkflows:fe,onToggleExpandAll:T,workflowCount:Fe,pendingPath:F},project:{processPanel:Q,backgroundAgents:Ft,hasFileChanges:a&&De,onOpenTerminal:se},chrome:{backgroundServers:lf,processPanel:Zu,workflowsPanel:tf,undoDialog:Ju,branchModal:Qu,fileChangesOpen:Oe,onFileChangesOpenChange:Ae,searchOpen:Be,onSearchOpenChange:oe}})})})}),rl]}):r.jsxs(Ii,{value:nl,children:[r.jsx(ml,{enabled:l,children:r.jsx(Ai,{value:sl,chatValue:ol,children:r.jsx(kl,{value:Ye,agentProgress:Ue,children:r.jsx(dO,{navigation:{panels:j,actions:In,handlers:pt,creatingSession:$u,pendingSession:Lu,onStartNewSession:zu,onStartNewFolder:ev,onSelectProject:L,onOpenPaletteProject:sv,liveSessionsRefreshRef:Du,onPrefetchSession:x},sessionView:{searchInputRef:k,chatInputRef:C,teamMembersBar:ef,activeComposer:el||ii,pendingComposer:ii,pendingTurns:af,todoProgress:ye,todosExpanded:xe,onTodosExpandedChange:tv,hasMoreTurns:b.hasMore,isLoadingOlderTurns:b.isLoadingOlder,onLoadMoreTurns:b.loadMore,onBackToMain:Gu,onShowWorkflows:fe,workflowCount:Fe},project:{processPanel:Q,worktrees:Ie,backgroundAgents:Ft,supportsWorktrees:K,hasFileChanges:a&&De,currentCwd:X,showPreview:Z,showProjectFiles:a&&te,projectFilesRoot:ne,projectFilesRequest:re,launchTerminalRequest:ie,pendingProject:ae,onOpenTerminal:se,onTogglePreview:pe,onToggleProjectFiles:he,onCloseRightWorkspace:ce},chrome:{backgroundServers:lf,processPanel:Zu,workflowsPanel:tf,undoDialog:Ju,branchModal:Qu,killing:av,onKillAll:lv,commandPaletteOpen:N,onCommandPaletteOpenChange:_,onOpenCommandPalette:E,onFocusComposer:R,onExpandAll:$,onExpandToolPayloads:I,onCollapseAll:M,keyboardShortcutsOpen:P,onKeyboardShortcutsOpenChange:A}})})})}),rl]})}function mL(){var w;const[n,e]=y.useState(yt),[t,s]=y.useState(()=>Pi(yt())),[o,i]=y.useState(js),[a,l]=y.useState(0),[c,d]=y.useState(!1),[u,f]=y.useState(!1),[m,p]=y.useState(!1),{devices:h,testDevice:g}=Ka();y.useEffect(()=>{const v=()=>{const S=yt();e(j=>j===S?j:S),s(Pi(S))};return window.addEventListener("cogpit-device-changed",v),window.addEventListener("popstate",v),()=>{window.removeEventListener("cogpit-device-changed",v),window.removeEventListener("popstate",v)}},[]),y.useEffect(()=>{const v=S=>{const j=S.detail;(j==null?void 0:j.deviceId)===yt()&&s(Pi(j.deviceId))};return window.addEventListener("cogpit-device-scope-changed",v),()=>window.removeEventListener("cogpit-device-scope-changed",v)},[]),y.useEffect(()=>{const v=()=>i(js());return window.addEventListener("cogpit-identity-changed",v),()=>window.removeEventListener("cogpit-identity-changed",v)},[]),y.useEffect(()=>(window.__cogpitRevealSession=x2,()=>{delete window.__cogpitRevealSession}),[]),y.useEffect(()=>{const v=S=>{const j=[Ct,...h.map(_=>_.id)],k=yt();let C;const N=F9(S);if(N!==null)C=j[N-1];else if(B9(S)){const _=j.indexOf(k);C=j[(_+1)%j.length]}!C||C===k||(S.preventDefault(),Ss(C))};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[h]),y.useEffect(()=>{const v=S=>{const j=S.detail;!(j!=null&&j.deviceId)||j.deviceId!==yt()||(d(!0),j.reason==="DEVICE_AUTH_FAILED"&&f(!0))};return window.addEventListener("cogpit-device-unreachable",v),()=>window.removeEventListener("cogpit-device-unreachable",v)},[]),y.useEffect(()=>{d(!1),f(!1),p(!1)},[n,t]);const x=y.useCallback(async()=>{p(!0);try{const v=await g(n);v.reachable&&v.authState==="bad-password"?f(!0):v.ok&&(d(!1),f(!1),l(S=>S+1))}finally{p(!1)}},[n,g]);y.useEffect(()=>{if(!c||u)return;const v=setInterval(()=>void x(),1e4);return()=>clearInterval(v)},[c,u,x]);const b=((w=h.find(v=>v.id===n))==null?void 0:w.name)??n;return r.jsxs(r.Fragment,{children:[c&&n!==Ct&&r.jsxs(ht,{role:"status",className:"fixed inset-x-3 top-3 z-40 mx-auto max-w-2xl border-warning/40 bg-popover shadow-md",children:[r.jsx(I3,{"data-icon":"inline-start",className:"text-warning"}),r.jsx(Tt,{children:u?"Device credentials need attention":"Remote device unavailable"}),r.jsx(gt,{children:u?`${b} rejected the stored password. Update it in Devices.`:`Can’t reach ${b}. Cogpit will keep retrying.`}),r.jsxs("div",{className:"col-start-2 mt-2 flex flex-wrap gap-2",children:[!u&&r.jsxs(ee,{variant:"outline",size:"xs",onClick:()=>void x(),disabled:m,children:[m&&r.jsx(ot,{"data-icon":"inline-start",className:"animate-spin"}),m?"Retrying":"Retry now"]}),r.jsx(ee,{variant:"outline",size:"xs",onClick:()=>Ss(Ct),children:"Switch to this machine"})]})]}),r.jsx(v_,{children:r.jsx(SM,{children:r.jsx(fL,{})})},`${n}:${t}:${a}:${o??""}`)]})}const Ih="Invalid link or passphrase.";function pL(n,e){return n===401?Ih:n===429?e||"Too many attempts. Try again in a minute.":n===426?"This link needs a secure HTTPS connection. Open the tunnel URL instead of the plain http address.":n===403?"Network access is off on the host, so this session cannot be joined right now.":e||Ih}function hL({sessionId:n,onAuthenticated:e}){const[t,s]=y.useState(""),[o,i]=y.useState(!1),[a,l]=y.useState(null),[c,d]=y.useState(!1),u=y.useCallback(async f=>{if(f.preventDefault(),!!t.trim()){d(!0),l(null);try{const m=await fetch("/api/share/verify",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json","X-Cogpit-Client":"1"},body:JSON.stringify({sessionId:n,passphrase:t})}),p=await m.json();m.ok&&p.valid?(s(""),e()):l(pL(m.status,p.error))}catch{l("Failed to connect to server")}finally{d(!1)}}},[e,t,n]);return r.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-4 py-8",children:r.jsx("form",{onSubmit:u,className:"w-full max-w-sm",children:r.jsxs(Jt,{children:[r.jsxs(rn,{children:[r.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:r.jsx(ts,{className:"size-4"})}),r.jsx(an,{children:"Join this session"}),r.jsx(fn,{children:"Enter the passphrase you were given to join the shared session."})]}),r.jsxs(Qt,{className:"flex flex-col gap-4",children:[r.jsx(Ao,{children:r.jsxs(wt,{children:[r.jsx(jt,{htmlFor:"share-passphrase",children:"Passphrase"}),r.jsxs(as,{children:[r.jsx(ls,{id:"share-passphrase",type:o?"text":"password",value:t,onChange:f=>s(f.target.value),placeholder:"copper-lantern-drift-92",autoComplete:"current-password",autoFocus:!0}),r.jsx(Pn,{align:"inline-end",children:r.jsx(Fr,{size:"icon-xs",onClick:()=>i(f=>!f),"aria-label":o?"Hide passphrase":"Show passphrase",children:o?r.jsx(ua,{}):r.jsx(ys,{})})})]})]})}),a&&r.jsxs(ht,{variant:"destructive",children:[r.jsx(tn,{"aria-hidden":"true"}),r.jsx(Tt,{children:"Could not join"}),r.jsx(gt,{children:a})]})]}),r.jsx(Io,{children:r.jsxs(ee,{type:"submit",className:"w-full",disabled:c||!t.trim(),children:[c&&r.jsx(xt,{"data-icon":"inline-start"}),"Connect"]})})]})})})}function gL(){const n=B.c(9),[e,t]=y.useState("idle"),[s,o]=y.useState();let i;n[0]===Symbol.for("react.memo_cache_sentinel")?(i=[],n[0]=i):i=n[0];const[a,l]=y.useState(i);let c;n[1]===Symbol.for("react.memo_cache_sentinel")?(c=(x,b)=>{l(w=>[...w,x]),t("connected"),o(void 0),u4(x,b).then(w=>{if(w.ok){t("idle");return}o(`Request failed (${w.status})`),t("error"),l(vL)}).catch(w=>{o(w instanceof Error?w.message:"Unknown error"),t("error"),l(bL)})},n[1]=c):c=n[1];const d=c;let u;n[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{f4().catch(xL),t("idle"),l([])},n[2]=u):u=n[2];const f=u;let m;n[3]===Symbol.for("react.memo_cache_sentinel")?(m=x=>{const b=x===void 0?1:x;l(w=>w.slice(b))},n[3]=m):m=n[3];const p=m,h=e==="connected";let g;return n[4]!==s||n[5]!==a||n[6]!==e||n[7]!==h?(g={status:e,error:s,pendingMessages:a,isConnected:h,sendMessage:d,interrupt:f,stopAgent:f,consumePending:p},n[4]=s,n[5]=a,n[6]=e,n[7]=h,n[8]=g):g=n[8],g}function xL(){}function bL(n){return n.slice(0,-1)}function vL(n){return n.slice(0,-1)}const yL=2e3;function wL(n,e){return n.length!==e.length?!1:JSON.stringify(n)===JSON.stringify(e)}function jL(){const n=B.c(11);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],n[0]=e):e=n[0];const[t,s]=y.useState(e);let o;n[1]===Symbol.for("react.memo_cache_sentinel")?(o=new Set,n[1]=o):o=n[1];const[i,a]=y.useState(o);let l,c;n[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{let h=!1;const g=async()=>{const w=await g4();h||w===null||s(v=>wL(v,w)?v:w)},x=()=>{document.visibilityState==="visible"&&g()};x();const b=setInterval(x,yL);return document.addEventListener("visibilitychange",x),()=>{h=!0,clearInterval(b),document.removeEventListener("visibilitychange",x)}},c=[],n[2]=l,n[3]=c):(l=n[2],c=n[3]),y.useEffect(l,c);let d;n[4]===Symbol.for("react.memo_cache_sentinel")?(d=(h,g)=>{a(x=>new Set(x).add(h)),p4(h,g).then(x=>{x&&s(b=>b.filter(w=>w.requestId!==h))}).finally(()=>{a(x=>{const b=new Set(x);return b.delete(h),b})})},n[4]=d):d=n[4];const u=d;let f;n[5]!==t?(f=h=>{for(const g of t)u(g.requestId,h)},n[5]=t,n[6]=f):f=n[6];const m=f;let p;return n[7]!==t||n[8]!==m||n[9]!==i?(p={requests:t,responding:i,respond:u,respondAll:m},n[7]=t,n[8]=m,n[9]=i,n[10]=p):p=n[10],p}const Wb={authenticated:!0,edition:"personal",user:null,capabilities:Or};function SL(n){var de,pe;const e=B.c(78),{info:t,children:s}=n,o=Da(),i=_b(),[a,l]=wb(),{parse:c,append:d}=zb(),[u,f]=y.useState("loading");let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=[],e[0]=m):m=e[0],y.useEffect(TL,m);const p=gL(),h=jL();let g;e[1]!==l||e[2]!==t.dirName||e[3]!==t.fileName||e[4]!==o||e[5]!==c?(g=async()=>{try{const{parsed:he,source:ce}=await Nb(t.dirName,t.fileName,c,"shared session");l({type:"LOAD_SESSION",session:he,source:ce,isMobile:o}),f("ready")}catch{f("failed")}},e[1]=l,e[2]=t.dirName,e[3]=t.fileName,e[4]=o,e[5]=c,e[6]=g):g=e[6];const x=g,b=y.useRef(!1);let w,v;e[7]!==x?(w=()=>{b.current||(b.current=!0,x())},v=[x],e[7]=x,e[8]=w,e[9]=v):(w=e[8],v=e[9]),y.useEffect(w,v);let S;e[10]!==l?(S=he=>{l({type:"UPDATE_SESSION",session:he})},e[10]=l,e[11]=S):S=e[11];const j=S,{isLive:k,sseState:C,isCompacting:N,turnError:_}=bb(a.sessionSource,j,c,d,void 0,a.session);let P;e[12]!==l?(P=he=>{l({type:"SET_OLDER_TURNS",turns:he})},e[12]=l,e[13]=P):P=e[13];const A=P,T=((de=a.sessionSource)==null?void 0:de.dirName)??null,E=((pe=a.sessionSource)==null?void 0:pe.fileName)??null;let R;e[14]!==A||e[15]!==a.sessionChangeKey||e[16]!==T||e[17]!==E||e[18]!==c?(R={dirName:T,fileName:E,sessionChangeKey:a.sessionChangeKey,workerParse:c,onOlderTurns:A},e[14]=A,e[15]=a.sessionChangeKey,e[16]=T,e[17]=E,e[18]=c,e[19]=R):R=e[19];const $=Fb(R);let I;e[20]!==p.consumePending||e[21]!==p.pendingMessages||e[22]!==k||e[23]!==a.session||e[24]!==a.sessionChangeKey?(I={session:a.session,isLive:k,pendingMessages:p.pendingMessages,consumePending:p.consumePending,sessionChangeKey:a.sessionChangeKey},e[20]=p.consumePending,e[21]=p.pendingMessages,e[22]=k,e[23]=a.session,e[24]=a.sessionChangeKey,e[25]=I):I=e[25];const M=jb(I),D=Ob(a.session,a.sessionSource,x,!1);let O;e[26]!==a.session?(O=a.session?$x(a.session):null,e[26]=a.session,e[27]=O):O=e[27];const L=O;let F;e[28]!==l?(F=()=>{l({type:"TOGGLE_EXPAND_ALL"})},e[28]=l,e[29]=F):F=e[29];const z=F,W=CL,U=kL;let H;e[30]!==t.dirName?(H=Et(t.dirName),e[30]=t.dirName,e[31]=H):H=e[31];let K;e[32]!==H?(K={configLoading:!1,configError:null,claudeDir:null,defaultAgentKind:H,setClaudeDir:U,showConfigDialog:!1,openConfigDialog:U,handleCloseConfigDialog:U,handleConfigSaved:U,retryConfig:U,networkUrl:null,networkAccessDisabled:!1},e[32]=H,e[33]=K):K=e[33];let V;e[34]===Symbol.for("react.memo_cache_sentinel")?(V={isRemote:ba(),edition:"personal",authChecked:!0,authenticated:!0,needsBootstrap:!1,handleAuthenticated:U,refreshServerState:NL,logout:U},e[34]=V):V=e[34];let Y;e[35]!==l||e[36]!==o||e[37]!==a||e[38]!==K||e[39]!==i?(Y={state:a,dispatch:l,config:K,theme:i,networkAuth:V,me:Wb,isMobile:o},e[35]=l,e[36]=o,e[37]=a,e[38]=K,e[39]=i,e[40]=Y):Y=e[40];const G=Y;let J;e[41]===Symbol.for("react.memo_cache_sentinel")?(J=[],e[41]=J):J=e[41];let Q;e[42]!==z?(Q={handleStopSession:W,handleOpenBranches:U,handleBranchFromHere:U,handleToggleExpandAll:z,handleLoadSession:U},e[42]=z,e[43]=Q):Q=e[43];let X;e[44]!==N||e[45]!==k||e[46]!==L||e[47]!==h.requests||e[48]!==h.respond||e[49]!==h.respondAll||e[50]!==h.responding||e[51]!==C||e[52]!==a.session||e[53]!==a.sessionSource||e[54]!==Q||e[55]!==_||e[56]!==D?(X={session:a.session,sessionSource:a.sessionSource,isLive:k,sseState:C,isCompacting:N,turnError:_,undoRedo:D,pendingInteraction:L,permissionRequests:h.requests,permissionResponding:h.responding,respondPermission:h.respond,respondAllPermissions:h.respondAll,isSubAgentView:!1,slashSuggestions:J,slashSuggestionsLoading:!1,promptSuggestion:null,actions:Q},e[44]=N,e[45]=k,e[46]=L,e[47]=h.requests,e[48]=h.respond,e[49]=h.respondAll,e[50]=h.responding,e[51]=C,e[52]=a.session,e[53]=a.sessionSource,e[54]=Q,e[55]=_,e[56]=D,e[57]=X):X=e[57];const Z=X;let te;e[58]!==p||e[59]!==M?(te={chat:p,scroll:M},e[58]=p,e[59]=M,e[60]=te):te=e[60];const ne=te;let re;e[61]!==$?(re=()=>{$.loadMore()},e[61]=$,e[62]=re):re=e[62];let ie;e[63]!==u||e[64]!==$.hasMore||e[65]!==$.isLoadingOlder||e[66]!==re?(ie={loadState:u,hasMore:$.hasMore,isLoadingOlder:$.isLoadingOlder,loadMore:re},e[63]=u,e[64]=$.hasMore,e[65]=$.isLoadingOlder,e[66]=re,e[67]=ie):ie=e[67];const ae=ie;let se;e[68]!==s||e[69]!==ae?(se=s(ae),e[68]=s,e[69]=ae,e[70]=se):se=e[70];let ue;e[71]!==ne||e[72]!==Z||e[73]!==se?(ue=r.jsx(Ai,{value:Z,chatValue:ne,children:se}),e[71]=ne,e[72]=Z,e[73]=se,e[74]=ue):ue=e[74];let le;return e[75]!==G||e[76]!==ue?(le=r.jsx(Ii,{value:G,children:ue}),e[75]=G,e[76]=ue,e[77]=le):le=e[77],le}function NL(){return Promise.resolve()}function kL(){}async function CL(){await m4().catch(_L)}function _L(){}function TL(){go(Wb)}function EL(n){const e=B.c(6),{info:t}=n,s=y.useRef(null);let o;e[0]!==t.provider||e[1]!==t.title?(o=a=>r.jsxs("div",{className:"flex h-dvh min-h-0 flex-col bg-background",children:[r.jsxs("header",{className:"flex shrink-0 items-center gap-2 border-b px-4 py-2",children:[r.jsx(ts,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),r.jsx("h1",{className:"truncate text-sm font-medium text-foreground",children:t.title}),r.jsx("span",{className:"ml-auto shrink-0 text-xs text-muted-foreground",children:"Guest view"})]}),a.loadState==="failed"?r.jsx("div",{className:"flex flex-1 items-center justify-center p-6",children:r.jsxs(ht,{variant:"destructive",className:"max-w-sm",children:[r.jsx(tn,{"aria-hidden":"true"}),r.jsx(Tt,{children:"Session unavailable"}),r.jsx(gt,{children:"This conversation could not be loaded. It may have been deleted on the host."})]})}):a.loadState==="loading"?r.jsx("div",{className:"flex flex-1 items-center justify-center",role:"status","aria-label":"Loading shared session",children:r.jsx(xt,{className:"size-5 text-muted-foreground"})}):r.jsxs(r.Fragment,{children:[r.jsx(Ha,{searchInputRef:s,hasMore:a.hasMore,isLoadingOlder:a.isLoadingOlder,onLoadMore:a.loadMore}),r.jsx(Ya,{children:r.jsx(pc,{agentKind:t.provider,projectCwd:null})})]})]}),e[0]=t.provider,e[1]=t.title,e[2]=o):o=e[2];let i;return e[3]!==t||e[4]!==o?(i=r.jsx(SL,{info:t,children:o}),e[3]=t,e[4]=o,e[5]=i):i=e[5],i}function ec(n){const e=B.c(2),{children:t}=n;let s;return e[0]!==t?(s=r.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-4 py-8",children:r.jsx("div",{className:"w-full max-w-sm",children:t})}),e[0]=t,e[1]=s):s=e[1],s}function PL(){const n=B.c(19);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=s1(window.location.pathname),n[0]=e):e=n[0];const t=e;let s;n[1]===Symbol.for("react.memo_cache_sentinel")?(s=t?{kind:"probing"}:{kind:"error",message:"This share link is not valid."},n[1]=s):s=n[1];const[o,i]=y.useState(s);let a;n[2]===Symbol.for("react.memo_cache_sentinel")?(a=async()=>{i({kind:"probing"});const p=await d4();i(p.status==="ok"?{kind:"ready",info:p.info}:p.status==="unauthenticated"?{kind:"login"}:{kind:"error",message:p.message})},n[2]=a):a=n[2];const l=a;let c,d;n[3]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{t&&l()},d=[l,t],n[3]=c,n[4]=d):(c=n[3],d=n[4]),y.useEffect(c,d);let u,f;if(n[5]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{const p=()=>{i(AL)};return window.addEventListener(mc,p),window.addEventListener("cogpit-auth-required",p),()=>{window.removeEventListener(mc,p),window.removeEventListener("cogpit-auth-required",p)}},f=[],n[5]=u,n[6]=f):(u=n[5],f=n[6]),y.useEffect(u,f),o.kind==="ready"){let p;return n[7]!==o.info?(p=r.jsx(EL,{info:o.info}),n[7]=o.info,n[8]=p):p=n[8],p}if(o.kind==="login"&&t){let p;return n[9]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(hL,{sessionId:t,onAuthenticated:()=>void l()}),n[9]=p):p=n[9],p}if(o.kind==="ended"){let p;return n[10]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(ec,{children:r.jsx(Jt,{children:r.jsxs(rn,{children:[r.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:r.jsx($3,{className:"size-4"})}),r.jsx(an,{children:"Sharing has ended"}),r.jsx(fn,{children:"The host stopped sharing this session or changed its passphrase. Ask for a new link to rejoin."})]})})}),n[10]=p):p=n[10],p}if(o.kind==="error"){let p,h;n[11]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(tn,{"aria-hidden":"true"}),h=r.jsx(Tt,{children:"Could not open this session"}),n[11]=p,n[12]=h):(p=n[11],h=n[12]);let g;n[13]!==o.message?(g=r.jsxs(ht,{variant:"destructive",children:[p,h,r.jsx(gt,{children:o.message})]}),n[13]=o.message,n[14]=g):g=n[14];let x;n[15]===Symbol.for("react.memo_cache_sentinel")?(x=t&&r.jsx(ee,{className:"mt-3 w-full",onClick:()=>void l(),children:"Try again"}),n[15]=x):x=n[15];let b;return n[16]!==g?(b=r.jsxs(ec,{children:[g,x]}),n[16]=g,n[17]=b):b=n[17],b}let m;return n[18]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(ec,{children:r.jsx(Jt,{children:r.jsxs(Qt,{className:"flex min-h-24 items-center justify-center gap-2",role:"status","aria-label":"Opening shared session",children:[r.jsx(ts,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),r.jsx(xt,{className:"size-5 text-muted-foreground"})]})})}),n[18]=m):m=n[18],m}function AL(n){return n.kind==="ready"?{kind:"ended"}:n}class RL extends y.Component{constructor(){super(...arguments);ai(this,"state",{error:null})}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,s){console.error("[Cogpit] Unhandled render error",t,s.componentStack)}render(){if(!this.state.error)return this.props.children;const t=this.state.error.message||"An unexpected render error occurred.";return r.jsx("main",{className:"flex h-dvh items-center justify-center bg-background p-6 text-foreground",children:r.jsxs(Jt,{className:"w-full max-w-lg text-center",children:[r.jsxs(rn,{className:"justify-items-center",children:[r.jsx(xn,{"aria-hidden":"true",className:"mb-2 size-8 text-destructive"}),r.jsx(an,{children:r.jsx("h1",{children:"Cogpit hit a render error"})}),r.jsx(fn,{children:"Reload the app to recover. Your sessions and project files are unchanged."})]}),r.jsx(Qt,{children:r.jsx("pre",{className:"max-h-40 w-full overflow-auto rounded-md bg-muted p-3 text-left font-mono text-xs whitespace-pre-wrap",children:t})}),r.jsx(Io,{className:"justify-center",children:r.jsxs(ee,{onClick:()=>window.location.reload(),children:[r.jsx(Ot,{"data-icon":"inline-start"}),"Reload Cogpit"]})})]})})}}const Hb=document.getElementById("root");if(!Hb)throw new Error("Root element not found");Sv.createRoot(Hb).render(r.jsx(y.StrictMode,{children:r.jsx(RL,{children:Ca(window.location.pathname)?r.jsx(PL,{}):r.jsx(mL,{})})}));export{Kt as $,ht as A,ee as B,UL as C,ns as D,ln as E,yE as F,dn as G,vn as H,Pn as I,Zg as J,Wa as K,LL as L,ya as M,Jg as N,Qg as O,Xg as P,kt as Q,Y3 as R,Hj as S,Ka as T,Ao as U,wt as V,Fr as W,bs as X,x7 as Y,b7 as Z,q as _,Kj as a,y5 as a$,a4 as a0,vr as a1,_e as a2,xt as a3,iE as a4,_c as a5,tu as a6,_a as a7,Yg as a8,gd as a9,C1 as aA,Ar as aB,ZL as aC,La as aD,rn as aE,an as aF,Qt as aG,Io as aH,Jt as aI,Ma as aJ,zx as aK,Qs as aL,qn as aM,Hs as aN,Fn as aO,Tt as aP,fn as aQ,Nd as aR,Lr as aS,CO as aT,Na as aU,jt as aV,No as aW,QP as aX,nn as aY,FL as aZ,Ht as a_,xd as aa,bd as ab,yd as ac,wd as ad,vd as ae,Sd as af,jd as ag,Br as ah,A1 as ai,Td as aj,En as ak,Ir as al,ct as am,Mt as an,dt as ao,m5 as ap,$s as aq,Ml as ar,L9 as as,ES as at,BL as au,md as av,Bs as aw,lt as ax,_d as ay,k1 as az,qj as b,ga as b0,b1,zL as b2,At as b3,Rt as b4,It as b5,Fa as b6,Ba as b7,Ua as b8,vo as b9,KL as ba,on as bb,wr as bc,d5 as bd,ft as be,Nj as bf,HL as bg,Vd as bh,c0 as bi,Yd as bj,a0 as bk,Js as bl,g0 as bm,NM as bn,Y2 as bo,Kr as bp,Cs as bq,r_ as br,Wj as c,Lj as d,qL as e,D9 as f,VL as g,ss as h,Ps as i,os as j,rs as k,St as l,as as m,ls as n,XL as o,gt as p,is as q,YL as r,JL as s,QL as t,GL as u,ib as v,ve as w,WL as x,cn as y,bn as z};