cogpit 2.6.1 → 2.6.6

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 (32) hide show
  1. package/dist/cli.js +2323 -2393
  2. package/dist/web/assets/{CommandPaletteHost-DLho8Ydr.js → CommandPaletteHost-iiTEkWGR.js} +1 -1
  3. package/dist/web/assets/{ConfigBrowser-DcRITnFh.js → ConfigBrowser-CV_FDTPG.js} +1 -1
  4. package/dist/web/assets/{HighlightedEditor-DIp1oA0P.js → HighlightedEditor-7K1IXoMd.js} +1 -1
  5. package/dist/web/assets/{KeyboardShortcutsDialog-BbU77pdm.js → KeyboardShortcutsDialog-C7QHuM2e.js} +1 -1
  6. package/dist/web/assets/{MobileFileChanges-GkG76Ztq.js → MobileFileChanges-qnY-uxZ_.js} +1 -1
  7. package/dist/web/assets/{PreviewPanel-B8DbD395.js → PreviewPanel-DBIaGXu0.js} +1 -1
  8. package/dist/web/assets/ProjectFilesPanel-DdllBXuv.js +4 -0
  9. package/dist/web/assets/{ProjectSwitcherModal-HW-WAt1o.js → ProjectSwitcherModal-BhevYH6F.js} +1 -1
  10. package/dist/web/assets/{TerminalOutput-Cpqldw8o.js → TerminalOutput-DnTT9ONj.js} +1 -1
  11. package/dist/web/assets/{ThemeSelectorModal-BZ9ceBWr.js → ThemeSelectorModal-GimQk0yY.js} +1 -1
  12. package/dist/web/assets/WorkflowsPanel-BTeZdY1F.js +1 -0
  13. package/dist/web/assets/WorktreePanel-DbSH2Fyv.js +1 -0
  14. package/dist/web/assets/{index-L4keTj_3.js → index-7fgSFumo.js} +1 -1
  15. package/dist/web/assets/{index-De7cnbso.js → index-Bl7YHn3e.js} +1 -1
  16. package/dist/web/assets/index-C640apmk.css +1 -0
  17. package/dist/web/assets/index-CVF75nuK.js +153 -0
  18. package/dist/web/assets/index-CmAiGDkv.js +1 -0
  19. package/dist/web/assets/index-j1RyyaFQ.js +1 -0
  20. package/dist/web/assets/session-parser.worker-DlF00ZHH.js +29 -0
  21. package/dist/web/assets/vendor-ui-C4lFQWec.js +937 -0
  22. package/dist/web/index.html +3 -3
  23. package/package.json +1 -1
  24. package/dist/web/assets/ProjectFilesPanel-nG1bZOL7.js +0 -4
  25. package/dist/web/assets/WorkflowsPanel-DOOg6Hqp.js +0 -1
  26. package/dist/web/assets/WorktreePanel-JHMvhzQu.js +0 -1
  27. package/dist/web/assets/index-9nniVy_T.js +0 -157
  28. package/dist/web/assets/index-BDtY-qce.css +0 -1
  29. package/dist/web/assets/index-BhAAK3QZ.js +0 -1
  30. package/dist/web/assets/index-D2-ty4Xm.js +0 -1
  31. package/dist/web/assets/session-parser.worker-CnmfpqaO.js +0 -29
  32. package/dist/web/assets/vendor-ui-CKSkT7i9.js +0 -912
@@ -0,0 +1,153 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalOutput-DnTT9ONj.js","assets/vendor-react-gGw_S5I_.js","assets/vendor-ui-C4lFQWec.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-iiTEkWGR.js","assets/index-j1RyyaFQ.js","assets/KeyboardShortcutsDialog-C7QHuM2e.js","assets/ProjectSwitcherModal-BhevYH6F.js","assets/ThemeSelectorModal-GimQk0yY.js","assets/ProjectFilesPanel-DdllBXuv.js","assets/HighlightedEditor-7K1IXoMd.js","assets/WorktreePanel-DbSH2Fyv.js","assets/index-CmAiGDkv.js","assets/index-Bl7YHn3e.js","assets/ConfigBrowser-CV_FDTPG.js","assets/PreviewPanel-DBIaGXu0.js","assets/MobileFileChanges-qnY-uxZ_.js","assets/index-7fgSFumo.js","assets/WorkflowsPanel-BTeZdY1F.js"])))=>i.map(i=>d[i]);
2
+ var vy=Object.defineProperty;var yy=(n,e,t)=>e in n?vy(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Ci=(n,e,t)=>yy(n,typeof e!="symbol"?e+"":e,t);import{c as B,j as r,d as ye,e as wy,r as w,a as jy,f as Sy}from"./vendor-react-gGw_S5I_.js";import{aC as Ny,aD as ky,aE as Cy,aF as rs,ae as et,aG as _y,N as mn,aH as bd,at as Hn,aI as Ty,aJ as Ey,aK as Ay,aL as Py,aM as Iy,aN as Ry,a2 as mt,aO as $y,J as at,aP as My,al as A1,b as Pt,aQ as Ly,aR as P1,aS as Oy,aT as Dy,aU as zy,aV as Fy,aW as By,aX as I1,aY as sa,h as jr,aZ as R1,G as fn,a_ as vd,a$ as Uy,b0 as Wy,b1 as Hy,b2 as qy,b3 as Ky,b4 as Vy,b5 as Gy,b6 as Yy,b7 as Xy,b8 as Jy,b9 as Qy,ba as Zy,bb as e3,bc as Ca,bd as t3,be as yd,bf as wd,bg as jd,bh as $1,bi as Sd,bj as Fr,X as tt,bk as Nd,bl as n3,I as kd,af as An,bm as s3,bn as M1,bo as L1,bp as ho,bq as As,br as o3,bs as r3,bt as i3,bu as a3,bv as Sr,S as Yt,z as yo,bw as ts,bx as O1,by as l3,bz as c3,bA as D1,bB as z1,bC as F1,bD as d3,bE as u3,bF as B1,bG as U1,bH as f3,bI as W1,bJ as m3,bK as p3,bL as h3,ah as Br,bM as g3,$ as _a,o as wo,aa as js,bN as Sc,bO as x3,bP as b3,bQ as v3,bR as y3,bS as w3,bT as j3,bU as S3,bV as Cd,bW as N3,bX as Xt,A as pn,bY as k3,bZ as C3,b_ as _3,b$ as T3,c0 as E3,c1 as A3,c2 as jo,c3 as $o,c4 as P3,j as Ta,c5 as I3,c6 as R3,c7 as $3,c8 as M3,c9 as L3,ca as O3,cb as D3,cc as z3,cd as F3,ce as B3,C as Ye,P as Bn,y as Vs,d as H1,cf as U3,cg as W3,ch as H3,ci as q3,F as So,ai as Ps,cj as K3,ck as q1,W as _d,f as Ea,a9 as Aa,cl as V3,cm as Pa,cn as Nc,co as G3,R as Td,cp as Y3,cq as X3,a0 as Us,c as K1,cr as J3,t as Ur,cs as Ed,a1 as fr,ct as Q3,cu as Mo,cv as Ad,l as Lo,cw as Z3,cx as ew,cy as tw,cz as V1,cA as nw,cB as _i,cC as Ms,aj as jm,k as Wr,D as Pd,cD as sw,a5 as oa,cE as ow,au as rw,u as Ia,O as Nr,V as Id,cF as iw,cG as aw,a4 as No,cH as lw,cI as cw,cJ as dw,cK as uw,cL as fw,cM as G1,cN as mw,cO as Rd,ar as pw,cP as hw,n as Sm,cQ as gw,cR as Nm,cS as xw,cT as $d,i as Hr,B as Y1,cU as bw,a6 as Md,s as vw,cV as yw,cW as X1,q as J1,av as kc,w as ww,cX as jw,cY as Sw,cZ as Nw,c_ as kw,c$ as Cw,d0 as nn,Q as Q1,d1 as _w,ao as km,an as Tw,d2 as Ew,d3 as Aw,d4 as Z1,d5 as Ld,d6 as Pw,d7 as Iw,d8 as eg,d9 as Rw,da as Cc,ay as $w,db as Mw,dc as tg,dd as Lw,p as Ow,de as Dw,df as Od,dg as Nn,dh as zw,ad as Fw,L as Bw,x as Uw,ap as Ww,di as Hw,ac as qw,dj as Kw}from"./vendor-ui-C4lFQWec.js";import{c as Vw,a as Gw}from"./vendor-shiki-DOn6sF-i.js";import{r as Yw,M as qn}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 Xw="modulepreload",Jw=function(n){return"/"+n},Cm={},Ve=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=Jw(d),d in Cm)return;Cm[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":Xw,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)})},Ss=["codex","copilot","claude"],_c="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";function Qw(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 Zw(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 ng(n){return{lossy:!1,owns:e=>typeof e=="string"&&e.startsWith(n),encode:e=>Qw(n,e),decode:e=>Zw(n,e)}}function sg(n){const e=new RegExp(`(${_c})\\.jsonl$`,"i").exec(n);return e?e[1]:null}const og={urlId:n=>n.replace(/\.jsonl$/,""),fileNameFromUrlId:n=>n.endsWith(".jsonl")?n:`${n}.jsonl`};function rg(n){return`'${n.replace(/'/g,"'\\''")}'`}function kr(n,e){return e?[n,e]:[]}function ra(n,e){var t;return((t=e.exec(n))==null?void 0:t[1])??null}const ia="[0-9a-f-]{36}",ig="codex__",ag="copilot__",ej=new Set(["default","plan","acceptEdits","dontAsk","auto"]),lg={kind:"claude",displayName:"Claude Code",binName:"claude",dirName:{lossy:!0,owns:n=>typeof n=="string"&&!n.startsWith(ig)&&!n.startsWith(ag),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:sg,...og},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"]:[...ej.has(n.mode)?["--permission-mode",n.mode]:[],...(n.allowedTools??[]).flatMap(e=>["--allowedTools",e]),...(n.disallowedTools??[]).flatMap(e=>["--disallowedTools",e])]:["--permission-mode","default"],model:n=>kr("--model",n),effort:n=>kr("--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=>ra(n,new RegExp(`--resume(?:=|\\s+)(${ia})`))??ra(n,new RegExp(`--session-id(?:=|\\s+)(${ia})`))}},config:{rootDirName:".claude",instructions:[{in:"scope",path:"CLAUDE.md",scopes:["global","project"]},{in:"root",path:"CLAUDE.md",label:".claude/CLAUDE.md",scopes:["project"]}],settings:[{in:"root",path:"settings.json",scopes:["global"]},{in:"root",path:"settings.local.json",scopes:["project"]}],skillsDir:"skills",agentsDir:"agents",commandsDir:"commands",themesDir:"themes",pluginsDir:"plugins",pluginManifestDir:".claude-plugin"},contextWindow:{defaultLimit:1e6,limits:[{match:"claude-haiku-4-5",limit:2e5},{match:"claude-haiku-4-1",limit:2e5},{match:"claude-sonnet-4-5",limit:2e5},{match:"claude-opus-4-5",limit:2e5},{match:"claude-opus-4-1",limit:2e5}],compactBuffer:33e3,extendedContext:{marker:"[1m]",limit:1e6}},capabilities:{worktrees:!0,mcp:!0,slashCommands:!0,workflows:!0,agentTeams:!0,subagentTranscripts:!0,nestedSubagents:!1,sharing:!0,goals:"transcript",undo:!0,redo:!0,nativeRewind:!1,fileCheckpoints:!0,reasoningEffort:!0,fastTier:!0,imageInput:!0,midTurnSteering:!1,stopSession:!0,ultracode:!0,contextWindow:!0,externalProcesses:!1,accountSwitching:!0,modelFallbackNotices:!0,autoPermissionMode:"per-model",settingsApply:"live",turnLiveness:"transcript",tokenStreaming:!0,nativeFork:!1,namedSessions:!0}},_m={appServerValue:"priority",cliConfigValue:"fast"},tj={kind:"codex",displayName:"Codex",binName:"codex",dirName:ng(ig),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:sg,...og},metadataFromHead:!1,resume:{command:(n,e)=>e?`codex -C ${rg(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=>kr("-m",n),effort:n=>n?["-c",`model_reasoning_effort=${JSON.stringify(n)}`]:[],fastTier:n=>n?["-c",`service_tier=${JSON.stringify(_m.cliConfigValue)}`,"--enable","fast_mode"]:[]},serviceTier:_m,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=>ra(n,new RegExp(`codex(?:\\s+\\S+)*\\s+exec\\s+resume\\s+(${ia})`))}},config:{rootDirName:".codex",instructions:[{in:"scope",path:"AGENTS.md",scopes:["global","project"]}],settings:[{in:"root",path:"config.toml",scopes:["global","project"]}],skillsDir:"skills",agentsDir:"agents",commandsDir:"prompts",themesDir:null,pluginsDir:null,pluginManifestDir:null},contextWindow:{defaultLimit:272e3,limits:[],compactBuffer:0,extendedContext:null},capabilities:{worktrees:!1,mcp:!1,slashCommands:!1,workflows:!1,agentTeams:!1,subagentTranscripts:!0,nestedSubagents:!0,sharing:!1,goals:"thread-api",undo:!0,redo:!0,nativeRewind:!1,fileCheckpoints:!1,reasoningEffort:!0,fastTier:!0,imageInput:!0,midTurnSteering:!0,stopSession:!1,ultracode:!1,contextWindow:!1,externalProcesses:!1,accountSwitching:!1,modelFallbackNotices:!1,autoPermissionMode:"never",settingsApply:"next-turn",turnLiveness:"runtime",tokenStreaming:!0,nativeFork:!1,namedSessions:!1}},nj={kind:"copilot",displayName:"GitHub Copilot CLI",binName:"copilot",dirName:ng(ag),sessionFile:{name:n=>`${n}/events.jsonl`,sessionId:n=>{const e=new RegExp(`^(${_c})/events\\.jsonl$`,"i").exec(n);return e?e[1]:null},urlId:n=>{const e=new RegExp(`^(${_c})/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 ${rg(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=>kr("--model",n),effort:n=>kr("--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=>ra(n,new RegExp(`--resume(?:=|\\s+)(${ia})`))}},config:{rootDirName:".copilot",instructions:[{in:"scope",path:"AGENTS.md",scopes:["global","project"]}],settings:[{in:"root",path:"config.json",scopes:["global"]}],skillsDir:"skills",agentsDir:null,commandsDir:null,themesDir:null,pluginsDir:null,pluginManifestDir:null},contextWindow:{defaultLimit:2e5,limits:[],compactBuffer:0,extendedContext:null},capabilities:{worktrees:!1,mcp:!1,slashCommands:!1,workflows:!1,agentTeams:!1,subagentTranscripts:!1,nestedSubagents:!1,sharing:!1,goals:!1,undo:!0,redo:!1,nativeRewind:!0,fileCheckpoints:!1,reasoningEffort:!1,fastTier:!1,imageInput:!1,midTurnSteering:!0,stopSession:!0,ultracode:!1,contextWindow:!1,externalProcesses:!0,accountSwitching:!1,modelFallbackNotices:!1,autoPermissionMode:"always",settingsApply:"next-turn",turnLiveness:"runtime",tokenStreaming:!1,nativeFork:!0,namedSessions:!0}},Cr=Object.freeze({claude:lg,codex:tj,copilot:nj});function an(n){return Cr[n]}function Ra(){return Ss.map(n=>Cr[n])}function sj(n,e){const t=Ra().filter(n);if(t.length!==1)throw new Error(`Expected exactly one agent with ${e}, found ${t.length}`);return t[0]}function Is(n){for(const e of Ss)if(e!=="claude"&&Cr[e].dirName.owns(n))return Cr[e];return lg}function It(n){return Is(n).kind}function Pl(n,e,t){const s=Cr[n].dirName;return t&&s.lossy?t:s.encode(e)}const Gs=Is(null).kind;var T1;const Ti=((T1=Ra().find(n=>n.dirName.lossy))==null?void 0:T1.kind)??null;function ko(n){return Is(n).capabilities}function Ht(n){return an(n).capabilities}function oj(n,e){return Ss.find(t=>t===n)??e}function Tc(n){for(const e of Ra()){const t=e.sessionFile.sessionId(n);if(t)return t}return n.replace(/\.jsonl$/,"")}function rj(n,e){return Is(n).sessionFile.urlId(e)}function ij(n,e){return Is(n).sessionFile.fileNameFromUrlId(e)}function cg(n,e,t){return an(n).resume.command(e,t)}function aj(n,e){const t=an(n);return{command:t.binName,args:[...t.resume.args(e)]}}function Tm(n){return n.replace(/\/+$/,"")||"/"}function lj(n,e,t){var o;const s=Tm(e);return((o=n.find(i=>Is(i.dirName).kind===t&&Tm(i.path)===s))==null?void 0:o.dirName)??null}const cj=[{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"}],Dd=[{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"}],dg=[...Dd,{value:"ultra",label:"Ultra",description:"Maximum reasoning with automatic task delegation"}],Ei=Dd.slice(0,4);var E1;const rr=[{value:((E1=an("codex").serviceTier)==null?void 0:E1.appServerValue)??"priority",label:"Fast",description:"1.5× speed with increased usage"}],Em={isDefault:!0,defaultReasoningEffort:"medium",supportedReasoningEfforts:dg,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:rr},dj=[{value:"",label:"Default",description:"Use Codex's recommended model (GPT-5.6 Sol)",resolvedModel:"gpt-5.6-sol",...Em},{value:"gpt-5.6-sol",label:"GPT-5.6 Sol",description:"Flagship model for the most ambitious work",...Em},{value:"gpt-5.6-terra",label:"GPT-5.6 Terra",description:"Balanced model for everyday work",defaultReasoningEffort:"medium",supportedReasoningEfforts:dg,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:rr},{value:"gpt-5.6-luna",label:"GPT-5.6 Luna",description:"Fastest, most cost-efficient model",defaultReasoningEffort:"medium",supportedReasoningEfforts:Dd,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:rr},{value:"gpt-5.5",label:"GPT-5.5",description:"Frontier model for complex real-world work",defaultReasoningEffort:"medium",supportedReasoningEfforts:Ei,inputModalities:["text","image"],supportsPersonality:!0,serviceTiers:rr},{value:"gpt-5.4",label:"GPT-5.4",description:"Strong model for everyday coding",defaultReasoningEffort:"medium",supportedReasoningEfforts:Ei,inputModalities:["text","image"],supportsPersonality:!0,serviceTiers:rr},{value:"gpt-5.4-mini",label:"GPT-5.4 Mini",description:"Small, fast model for simpler tasks",defaultReasoningEffort:"medium",supportedReasoningEfforts:Ei,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:Ei,inputModalities:["text"],supportsPersonality:!0}],uj=[{value:"",label:"Default",supportsEffort:!1,inputModalities:["text"]},{value:"auto",label:"Auto",description:"Let Copilot choose the best available model",supportsEffort:!1,inputModalities:["text"]}],fj={claude:cj,codex:dj,copilot:uj};function mj(n){return fj[n]}function q(...n){return Ny(ky(n))}const ug=new Map,Ec=new Set;function pj(n,e){!Array.isArray(e)||e.length===0||(ug.set(n,e),Ec.forEach(t=>t()))}function hj(n){return Ec.add(n),()=>Ec.delete(n)}const Am="high",gj=[{value:"low",label:"Light"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"xhigh",label:"Extra High"},{value:"max",label:"Max"}];function xj(n){return ug.get(n)??mj(n)}function qr(n,e){return e?n.find(t=>t.value===e):n.find(t=>t.value!==""&&t.isDefault)??n.find(t=>t.value==="")??n.find(t=>t.value!=="")}function fg(n,e,t){const s=qr(e,t),o=s==null?void 0:s.supportedReasoningEfforts;return o&&o.length>0?o:(s==null?void 0:s.supportsEffort)===!1||!Ht(n).reasoningEffort?[]:gj}function bj(n,e){var t,s;return(s=(t=qr(n,e))==null?void 0:t.serviceTiers)==null?void 0:s.find(o=>o.value==="fast"||o.value==="priority"||o.label.toLowerCase()==="fast")}function vj(n,e,t){var o;const s=(o=qr(e,t))==null?void 0:o.inputModalities;return s?s.includes("image"):Ht(n).imageInput}function yj(n,e,t){var o;const s=Ht(n).autoPermissionMode;return s==="always"?!0:s==="never"?!1:((o=qr(e,t))==null?void 0:o.supportsAutoMode)===!0}function wj(n,e){return Ht(n).ultracode?!(e??"").toLowerCase().startsWith("haiku"):!1}function jj(n,e,t,s){var l;const o=fg(n,e,s);if(o.length===0)return"";const i=c=>!!c&&o.some(d=>d.value===c);if(i(t))return t;const a=(l=qr(e,s))==null?void 0:l.defaultReasoningEffort;return i(a)?a:i(Am)?Am:o[0].value}function Sj(n){return n.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").slice(0,40).replace(/-$/,"")}async function $a(n){try{return await navigator.clipboard.writeText(n),!0}catch{const e=document.activeElement,t=document.createElement("textarea");t.value=n,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();const s=document.execCommand("copy");return document.body.removeChild(t),e instanceof HTMLElement&&e.focus(),s}}const Nj=rs("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(Nj({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(Cy,{"data-slot":"button",className:a,...s}),e[9]=s,e[10]=a,e[11]=l):l=e[11],l}function Kt(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 Vt(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 kj=rs("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 en(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(kj({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 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 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 tn(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 mg(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 Cj(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 _j=n=>{switch(n){case"success":return Aj;case"info":return Ij;case"warning":return Pj;case"error":return Rj;default:return null}},Tj=Array(12).fill(0),Ej=({visible:n,className:e})=>ye.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":n},ye.createElement("div",{className:"sonner-spinner"},Tj.map((t,s)=>ye.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${s}`})))),Aj=ye.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},ye.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),Pj=ye.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},ye.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),Ij=ye.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},ye.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),Rj=ye.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},ye.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),$j=ye.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true"},ye.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ye.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),Mj=()=>{const[n,e]=ye.useState(document.hidden);return ye.useEffect(()=>{const t=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[]),n};let Lj=1;const Oj=100,Pm=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:Lj++};class Dj{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-Oj;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=Pm(e),i=this.pendingDismissals.get(o);i!==void 0&&(cancelAnimationFrame(i),this.pendingDismissals.delete(o),this.dismissedToasts.delete(o));const a=this.dismissedToasts.has(o),l=e.dismissible===void 0?!0:e.dismissible;return a&&(this.dismissedToasts.delete(o),this.toasts=this.toasts.filter(d=>d.id!==o)),(a?void 0:this.toasts.find(d=>d.id===o))?this.toasts=this.toasts.map(d=>d.id===o?(this.publish({...d,...e,id:o,title:t}),{...d,...e,id:o,dismissible:l,title:t}):d):this.addToast({title:t,...s,dismissible:l,id:o}),o},this.dismiss=e=>{if(e==null)return this.getActiveToasts().forEach(s=>{this.dismissedToasts.add(s.id),this.subscribers.forEach(o=>o({id:s.id,dismiss:!0}))}),e;this.dismissedToasts.add(e);const t=this.pendingDismissals.get(e);return t!==void 0&&cancelAnimationFrame(t),this.pendingDismissals.set(e,requestAnimationFrame(()=>{this.pendingDismissals.delete(e),this.subscribers.forEach(s=>s({id:e,dismiss:!0}))})),e},this.message=(e,t)=>this.create({...t,message:e,type:void 0}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let s;t.loading!==void 0&&(s=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));const o=Promise.resolve(e instanceof Function?e():e);let i=s!==void 0,a;const l=o.then(async d=>{if(a=["resolve",d],ye.isValidElement(d))i=!1,this.create({id:s,type:"default",message:d});else if(Fj(d)&&!d.ok){i=!1;const f=typeof t.error=="function"?await t.error(`HTTP error! status: ${d.status}`):t.error,m=typeof t.description=="function"?await t.description(`HTTP error! status: ${d.status}`):t.description,h=typeof f=="object"&&!ye.isValidElement(f)?f:{message:f};this.create({id:s,type:"error",description:m,...h})}else if(d instanceof Error){i=!1;const f=typeof t.error=="function"?await t.error(d):t.error,m=typeof t.description=="function"?await t.description(d):t.description,h=typeof f=="object"&&!ye.isValidElement(f)?f:{message:f};this.create({id:s,type:"error",description:m,...h})}else if(t.success!==void 0){i=!1;const f=typeof t.success=="function"?await t.success(d):t.success,m=typeof t.description=="function"?await t.description(d):t.description,h=typeof f=="object"&&!ye.isValidElement(f)?f:{message:f};this.create({id:s,type:"success",description:m,...h})}}).catch(async d=>{if(a=["reject",d],t.error!==void 0){i=!1;const u=typeof t.error=="function"?await t.error(d):t.error,f=typeof t.description=="function"?await t.description(d):t.description,p=typeof u=="object"&&!ye.isValidElement(u)?u:{message:u};this.create({id:s,type:"error",description:f,...p})}}).finally(()=>{i&&(this.dismiss(s),s=void 0),t.finally==null||t.finally.call(t)}),c=()=>new Promise((d,u)=>l.then(()=>a[0]==="reject"?u(a[1]):d(a[1])).catch(u));return typeof s!="string"&&typeof s!="number"?{unwrap:c}:Object.assign(s,{unwrap:c})},this.custom=(e,t)=>{const s=Pm(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 Qt=new Dj,zj=(n,e)=>Qt.message(n,e),Fj=n=>n&&typeof n=="object"&&"ok"in n&&typeof n.ok=="boolean"&&"status"in n&&typeof n.status=="number",Bj=zj,Uj=()=>Qt.toasts,Wj=()=>Qt.getActiveToasts(),On=Object.assign(Bj,{success:Qt.success,info:Qt.info,warning:Qt.warning,error:Qt.error,custom:Qt.custom,message:Qt.message,promise:Qt.promise,dismiss:Qt.dismiss,loading:Qt.loading},{getHistory:Uj,getToasts:Wj});Cj("[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 Ai(n){return n.label!==void 0}const Hj=3,qj="24px",Kj="16px",Im=4e3,Vj=356,Gj=14,Yj=45,Xj=200;function $n(...n){return n.filter(Boolean).join(" ")}function Jj(n){const[e,t]=n.split("-"),s=[];return e&&s.push(e),t&&s.push(t),s}const Qj=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:v,toasts:y,expanded:b,removeToast:j,defaultRichColors:S,closeButton:k,style:C,cancelButtonStyle:N,actionButtonStyle:E,className:T="",descriptionClassName:P="",duration:_,position:A,gap:I,expandByDefault:$,classNames:R,icons:M,closeButtonAriaLabel:O="Close toast"}=n,[D,z]=ye.useState(null),[F,L]=ye.useState(null),[H,U]=ye.useState(!1),[W,V]=ye.useState(!1),[K,Y]=ye.useState(!1),[X,G]=ye.useState(!1),[J,Z]=ye.useState(!1),[Q,te]=ye.useState(0),[ne,oe]=ye.useState(0),re=ye.useRef(f.duration||_||Im),ie=ye.useRef(null),se=ye.useRef(null),ce=v===0,ae=v+1<=g,ue=f.type,me=ue??"default",de=f.dismissible!==!1,le=f.className||"",xe=f.descriptionClassName||"",pe=ye.useMemo(()=>x.findIndex(Ee=>Ee.toastId===f.id)||0,[x,f.id]),ve=ye.useMemo(()=>{var Ee;return(Ee=f.closeButton)!=null?Ee:k},[f.closeButton,k]),Te=ye.useMemo(()=>f.duration||_||Im,[f.duration,_]),$e=ye.useRef(0),_e=ye.useRef(0),Ce=ye.useRef(0),ke=ye.useRef(null),[Me,Oe]=A.split("-"),Le=ye.useMemo(()=>x.reduce((Ee,ze,fe)=>fe>=pe?Ee:Ee+ze.height,0),[x,pe]),De=Mj(),Ie=ye.useMemo(()=>{var Ee;return(Ee=n.swipeDirections)!=null?Ee:Jj(A)},[n.swipeDirections,A]),he=f.invert||u,ge=ue==="loading";_e.current=ye.useMemo(()=>pe*I+Le,[pe,Le]),ye.useEffect(()=>{re.current=Te},[Te]),ye.useEffect(()=>{U(!0)},[]),ye.useEffect(()=>{const Ee=se.current;if(Ee){const ze=Ee.getBoundingClientRect().height;return oe(ze),h(fe=>[{toastId:f.id,height:ze,position:f.position},...fe]),()=>h(fe=>fe.filter(we=>we.toastId!==f.id))}},[h,f.id]),ye.useLayoutEffect(()=>{if(!H)return;const Ee=se.current,ze=Ee.style.height;Ee.style.height="auto";const fe=Ee.getBoundingClientRect().height;Ee.style.height=ze,oe(fe),h(we=>we.find(Be=>Be.toastId===f.id)?we.map(Be=>Be.toastId===f.id?{...Be,height:fe}:Be):[{toastId:f.id,height:fe,position:f.position},...we])},[H,f.title,f.description,h,f.id,f.jsx,f.action,f.cancel]);const Se=ye.useCallback(()=>{V(!0),te(_e.current),h(Ee=>Ee.filter(ze=>ze.toastId!==f.id)),setTimeout(()=>{j(f)},Xj)},[f,j,h,_e]);ye.useEffect(()=>{if(f.promise&&ue==="loading"||f.duration===1/0||f.type==="loading")return;let Ee;return b||p||De?(()=>{if(Ce.current<$e.current){const we=new Date().getTime()-$e.current;re.current=re.current-we}Ce.current=new Date().getTime()})():(()=>{re.current!==1/0&&($e.current=new Date().getTime(),Ee=setTimeout(()=>{f.onAutoClose==null||f.onAutoClose.call(f,f),Se()},re.current))})(),()=>clearTimeout(Ee)},[b,p,f,ue,De,Se]),ye.useEffect(()=>{f.delete&&(Se(),f.onDismiss==null||f.onDismiss.call(f,f))},[Se,f.delete]);function be(){var Ee;if(M!=null&&M.loading){var ze;return ye.createElement("div",{className:$n(R==null?void 0:R.loader,f==null||(ze=f.classNames)==null?void 0:ze.loader,"sonner-loader"),"data-visible":ue==="loading"},M.loading)}return ye.createElement(Ej,{className:$n(R==null?void 0:R.loader,f==null||(Ee=f.classNames)==null?void 0:Ee.loader),visible:ue==="loading"})}const Fe=f.icon||(M==null?void 0:M[ue])||_j(ue);var He,We;return ye.createElement("li",{tabIndex:0,ref:se,className:$n(T,le,R==null?void 0:R.toast,f==null||(e=f.classNames)==null?void 0:e.toast,R==null?void 0:R[me],f==null||(t=f.classNames)==null?void 0:t[me]),"data-sonner-toast":"","data-rich-colors":(He=f.richColors)!=null?He:S,"data-styled":!(f.jsx||f.unstyled||m),"data-mounted":H,"data-promise":!!f.promise,"data-swiped":J,"data-removed":W,"data-visible":ae,"data-y-position":Me,"data-x-position":Oe,"data-index":v,"data-front":ce,"data-swiping":K,"data-dismissible":de,"data-type":ue,"data-invert":he,"data-swipe-out":X,"data-swipe-direction":F,"data-expanded":!!(b||$&&H),"data-testid":f.testId,style:{"--index":v,"--toasts-before":v,"--z-index":y.length-v,"--offset":`${W?Q:_e.current}px`,"--initial-height":$?"auto":`${ne}px`,...C,...f.style},onDragEnd:()=>{Y(!1),z(null),ke.current=null},onPointerDown:Ee=>{Ee.button!==2&&(ge||!de||(ie.current=new Date,te(_e.current),Ee.target.setPointerCapture(Ee.pointerId),Ee.target.tagName!=="BUTTON"&&(Y(!0),ke.current={x:Ee.clientX,y:Ee.clientY})))},onPointerUp:()=>{var Ee,ze,fe;if(X||!de)return;ke.current=null;const we=Number(((Ee=se.current)==null?void 0:Ee.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Ue=Number(((ze=se.current)==null?void 0:ze.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Be=new Date().getTime()-((fe=ie.current)==null?void 0:fe.getTime()),Ae=D==="x"?we:Ue,qe=Math.abs(Ae)/Be;if((D==="x"?Ie.includes(we>0?"right":"left"):Ie.includes(Ue>0?"bottom":"top"))&&(Math.abs(Ae)>=Yj||qe>.11)){te(_e.current),f.onDismiss==null||f.onDismiss.call(f,f),L(D==="x"?we>0?"right":"left":Ue>0?"down":"up"),Se(),G(!0);return}else{var Je,Ke;(Je=se.current)==null||Je.style.setProperty("--swipe-amount-x","0px"),(Ke=se.current)==null||Ke.style.setProperty("--swipe-amount-y","0px")}Z(!1),Y(!1),z(null)},onPointerMove:Ee=>{var ze,fe,we;if(!ke.current||!de||((ze=window.getSelection())==null?void 0:ze.toString().length)>0)return;const Be=Ee.clientY-ke.current.y,Ae=Ee.clientX-ke.current.x;!D&&(Math.abs(Ae)>1||Math.abs(Be)>1)&&z(Math.abs(Ae)>Math.abs(Be)?"x":"y");let qe={x:0,y:0};const ht=Je=>1/(1.5+Math.abs(Je)/20);if(D==="y"){if(Ie.includes("top")||Ie.includes("bottom"))if(Ie.includes("top")&&Be<0||Ie.includes("bottom")&&Be>0)qe.y=Be;else{const Je=Be*ht(Be);qe.y=Math.abs(Je)<Math.abs(Be)?Je:Be}}else if(D==="x"&&(Ie.includes("left")||Ie.includes("right")))if(Ie.includes("left")&&Ae<0||Ie.includes("right")&&Ae>0)qe.x=Ae;else{const Je=Ae*ht(Ae);qe.x=Math.abs(Je)<Math.abs(Ae)?Je:Ae}(Math.abs(qe.x)>0||Math.abs(qe.y)>0)&&Z(!0),(fe=se.current)==null||fe.style.setProperty("--swipe-amount-x",`${qe.x}px`),(we=se.current)==null||we.style.setProperty("--swipe-amount-y",`${qe.y}px`)}},ve&&!f.jsx&&ue!=="loading"?ye.createElement("button",{"aria-label":O,"data-disabled":ge,"data-close-button":!0,onClick:ge||!de?()=>{}:()=>{Se(),f.onDismiss==null||f.onDismiss.call(f,f)},className:$n(R==null?void 0:R.closeButton,f==null||(s=f.classNames)==null?void 0:s.closeButton)},(We=M==null?void 0:M.close)!=null?We:$j):null,(ue||f.icon||f.promise)&&f.icon!==null&&((M==null?void 0:M[ue])!==null||f.icon)?ye.createElement("div",{"data-icon":"",className:$n(R==null?void 0:R.icon,f==null||(o=f.classNames)==null?void 0:o.icon)},ue==="loading"?f.icon||be():f.promise?be():null,ue!=="loading"?Fe:null):null,ye.createElement("div",{"data-content":"",className:$n(R==null?void 0:R.content,f==null||(i=f.classNames)==null?void 0:i.content)},ye.createElement("div",{"data-title":"",className:$n(R==null?void 0:R.title,f==null||(a=f.classNames)==null?void 0:a.title)},f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title),f.description?ye.createElement("div",{"data-description":"",className:$n(P,xe,R==null?void 0:R.description,f==null||(l=f.classNames)==null?void 0:l.description)},typeof f.description=="function"?f.description():f.description):null),ye.isValidElement(f.cancel)?f.cancel:f.cancel&&Ai(f.cancel)?ye.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||N,onClick:Ee=>{Ai(f.cancel)&&de&&(f.cancel.onClick==null||f.cancel.onClick.call(f.cancel,Ee),Se())},className:$n(R==null?void 0:R.cancelButton,f==null||(c=f.classNames)==null?void 0:c.cancelButton)},f.cancel.label):null,ye.isValidElement(f.action)?f.action:f.action&&Ai(f.action)?ye.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||E,onClick:Ee=>{Ai(f.action)&&(f.action.onClick==null||f.action.onClick.call(f.action,Ee),!Ee.defaultPrevented&&Se())},className:$n(R==null?void 0:R.actionButton,f==null||(d=f.classNames)==null?void 0:d.actionButton)},f.action.label):null)};function Rm(){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 Zj(n,e){const t={};return[n,e].forEach((s,o)=>{const i=o===1,a=i?"--mobile-offset":"--offset",l=i?Kj:qj;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 e4=ye.forwardRef(function(e,t){const{id:s,invert:o,position:i="bottom-right",hotkey:a=["altKey","KeyT"],expand:l,closeButton:c,className:d,offset:u,mobileOffset:f,theme:m="light",richColors:p,duration:h,style:g,visibleToasts:x=Hj,toastOptions:v,dir:y=Rm(),gap:b=Gj,icons:j,customAriaLabel:S,containerAriaLabel:k="Notifications"}=e,[C,N]=ye.useState([]),E=ye.useMemo(()=>s?C.filter(U=>U.toasterId===s):C.filter(U=>!U.toasterId),[C,s]),T=ye.useMemo(()=>Array.from(new Set([i].concat(E.filter(U=>U.position).map(U=>U.position)))),[E,i]),[P,_]=ye.useState([]),[A,I]=ye.useState(!1),[$,R]=ye.useState(!1),[M,O]=ye.useState(m!=="system"?m:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),D=ye.useRef(null),z=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),F=ye.useRef(null),L=ye.useRef(!1),H=ye.useCallback(U=>{N(W=>{var V;return(V=W.find(K=>K.id===U.id))!=null&&V.delete||Qt.dismiss(U.id),W.filter(({id:K})=>K!==U.id)})},[]);return ye.useEffect(()=>Qt.subscribe(U=>{if(U.dismiss){requestAnimationFrame(()=>{N(W=>W.map(V=>V.id===U.id?{...V,delete:!0}:V))});return}setTimeout(()=>{wy.flushSync(()=>{N(W=>{const V=W.findIndex(K=>K.id===U.id);return V!==-1?[...W.slice(0,V),{...W[V],...U},...W.slice(V+1)]:[U,...W]})})})}),[]),ye.useEffect(()=>{if(m!=="system"){O(m);return}if(m==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?O("dark"):O("light")),typeof window>"u")return;const U=window.matchMedia("(prefers-color-scheme: dark)");try{U.addEventListener("change",({matches:W})=>{O(W?"dark":"light")})}catch{U.addListener(({matches:V})=>{try{O(V?"dark":"light")}catch(K){console.error(K)}})}},[m]),ye.useEffect(()=>{C.length<=1&&I(!1)},[C]),ye.useEffect(()=>{const U=W=>{var V;if(a.length>0&&a.every(X=>W[X]||W.code===X)){var Y;I(!0),(Y=D.current)==null||Y.focus()}W.code==="Escape"&&(document.activeElement===D.current||(V=D.current)!=null&&V.contains(document.activeElement))&&I(!1)};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[a]),ye.useEffect(()=>{if(D.current)return()=>{F.current&&(F.current.focus({preventScroll:!0}),F.current=null,L.current=!1)}},[D.current]),ye.createElement("section",{ref:t,"aria-label":S??`${k} ${z}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0,"data-react-aria-top-layer":!0},T.map((U,W)=>{var V;const[K,Y]=U.split("-");return E.length?ye.createElement("ol",{key:U,dir:y==="auto"?Rm():y,tabIndex:-1,ref:D,className:d,"data-sonner-toaster":!0,"data-sonner-theme":M,"data-y-position":K,"data-x-position":Y,style:{"--front-toast-height":`${((V=P[0])==null?void 0:V.height)||0}px`,"--width":`${Vj}px`,"--gap":`${b}px`,...g,...Zj(u,f)},onBlur:X=>{L.current&&!X.currentTarget.contains(X.relatedTarget)&&(L.current=!1,F.current&&(F.current.focus({preventScroll:!0}),F.current=null))},onFocus:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||L.current||(L.current=!0,F.current=X.relatedTarget)},onMouseEnter:()=>I(!0),onMouseMove:()=>I(!0),onMouseLeave:()=>{$||I(!1)},onDragEnd:()=>I(!1),onPointerDown:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||R(!0)},onPointerUp:()=>R(!1)},E.filter(X=>!X.position&&W===0||X.position===U).map((X,G)=>{var J,Z;return ye.createElement(Qj,{key:X.id,icons:j,index:G,toast:X,defaultRichColors:p,duration:(J=v==null?void 0:v.duration)!=null?J:h,className:v==null?void 0:v.className,descriptionClassName:v==null?void 0:v.descriptionClassName,invert:o,visibleToasts:x,closeButton:(Z=v==null?void 0:v.closeButton)!=null?Z:c,interacting:$,position:U,style:v==null?void 0:v.style,unstyled:v==null?void 0:v.unstyled,classNames:v==null?void 0:v.classNames,cancelButtonStyle:v==null?void 0:v.cancelButtonStyle,actionButtonStyle:v==null?void 0:v.actionButtonStyle,closeButtonAriaLabel:v==null?void 0:v.closeButtonAriaLabel,removeToast:H,toasts:E.filter(Q=>Q.position==X.position),heights:P.filter(Q=>Q.position==X.position),setHeights:_,expandByDefault:l,gap:b,expanded:A,swipeDirections:e.swipeDirections})})):null}))}),t4=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(Hn,{className:"size-4"}),info:r.jsx(bd,{className:"size-4"}),warning:r.jsx(mn,{className:"size-4"}),error:r.jsx(_y,{className:"size-4"}),loading:r.jsx(et,{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(e4,{className:"toaster group",icons:s,style:o,...t}),e[4]=t,e[5]=i):i=e[5],i};function n4(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){On.dismiss("app-error");return}On.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]),w.useEffect(c,d);let u,f;e[4]!==i||e[5]!==o?(u=()=>{if(!o){On.dismiss("model-fallback");return}On.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]),w.useEffect(u,f);let m,p;e[8]!==a?(m=()=>{if(!a){On.dismiss("session-connection");return}On.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]),w.useEffect(m,p);const h=l==="light"?"light":"dark";let g;return e[11]!==h?(g=r.jsx(t4,{theme:h,position:"bottom-center",closeButton:!0,visibleToasts:3}),e[11]=h,e[12]=g):g=e[12],g}const Tt="local",pg="cogpit-last-path::",Ac=new Map;function xt(){var t;const n=typeof window<"u"?(t=window.location)==null?void 0:t.pathname:void 0;if(!n)return Tt;const e=/^\/d\/([^/]+)/.exec(n);return e?e[1]:Tt}function Ws(){return xt()!==Tt}function hg(){const n=xt();return n===Tt?"":`/hub/${n}`}function gg(n){const e=hg();return!e||n.startsWith("/api/hub/")||n.startsWith("/api/auth/")?n:n.startsWith("/api")||n.startsWith("/__pty")||n.startsWith("/__browser")?`${e}${n}`:n}let _r=null;function xg(n){n!==_r&&(_r=n,window.dispatchEvent(new Event("cogpit-identity-changed")))}function Ns(){return _r}function Xi(n){return n===Tt?0:Ac.get(n)??0}function s4(n,e){if(n===Tt||!Number.isSafeInteger(e)||e<0)return!1;const t=Ac.get(n);return t!==void 0&&e<=t?!1:(Ac.set(n,e),window.dispatchEvent(new CustomEvent("cogpit-device-scope-changed",{detail:{deviceId:n,connectionRevision:e}})),!0)}function wn(){const n=xt(),e=Xi(n);return e===0?n:`${n}@${e}`}function Jt(n){const e=xt(),t=wn();return _r!==null?`${n}::${t}::${_r}`:e===Tt?n:`${n}::${t}`}function Yo(n,e){sessionStorage.setItem(`${pg}${n}`,e)}function ks(n){const t=sessionStorage.getItem(`${pg}${n}`)??(n===Tt?"/":`/d/${n}/`);window.history.pushState(null,"",t),window.dispatchEvent(new Event("cogpit-device-changed"))}const $m="cogpit-network-token",o4=new Set(["localhost","127.0.0.1","::1","0:0:0:0:0:0:0:1"]);function zd(){const n=window.location.hostname.toLowerCase(),e=n.startsWith("[")&&n.endsWith("]")?n.slice(1,-1):n;return!o4.has(e)}function Ma(){try{localStorage.removeItem($m),sessionStorage.removeItem($m)}catch{}}typeof window<"u"&&Ma();const r4={edition:"personal",needsBootstrap:!1};let Tr=null,go=null;function bg(){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 go=e.edition==="team"?"team":"personal",{edition:go,needsBootstrap:go==="team"&&e.needsBootstrap===!0}}).catch(()=>(Tr=null,r4))}function vg(){return Tr??(Tr=bg()),Tr}function Mm(){return Tr=bg(),Tr}function yg(){return vg().then(n=>n.edition)}async function i4(){if(!zd()&&go!=="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 a4(){try{await fetch("/api/auth/logout",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"X-Cogpit-Client":"1"}})}finally{Ma()}}function Lm(){return Ma(),window.dispatchEvent(new Event("cogpit-auth-required")),Promise.reject(new Error("Authentication required"))}function wg(n,e,t){t&&typeof n=="string"&&n.startsWith("/api")&&(n=gg(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(zd()||go==="team")return Lm();if(go===null)return yg().then(i=>i==="team"?Lm():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 Ne(n,e){return wg(n,e,!0)}function Kn(n,e,t={}){return Ne(n,{method:"POST",...t,headers:{"Content-Type":"application/json",...t.headers},body:JSON.stringify(e)})}function ps(n,e){return wg(n,e,!1)}function Kr(n){return gg(n)}const l4=300*1e3,c4=30*1e3;let Pc=0,Xo=null;function d4(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 u4(){try{const n=await Ne("/api/models");if(!n.ok)throw new Error(`GET /api/models → ${n.status}`);const e=await n.json();for(const t of Ss){const s=e==null?void 0:e[t];d4(s)&&pj(t,s)}Pc=Date.now()+l4}catch{Pc=Date.now()+c4}}function Fd(){return Xo||(Date.now()<Pc?Promise.resolve():(Xo=u4().finally(()=>{Xo=null}),Xo))}function f4(){const n=()=>{document.visibilityState==="visible"&&Fd()};return window.addEventListener("focus",n),document.addEventListener("visibilitychange",n),()=>{window.removeEventListener("focus",n),document.removeEventListener("visibilitychange",n)}}function m4(n){const e=B.c(3);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0],w.useEffect(p4,t);let s;return e[1]!==n?(s=()=>xj(n),e[1]=n,e[2]=s):s=e[2],w.useSyncExternalStore(hj,s)}function p4(){return Fd(),f4()}function jg(n,e){const t=B.c(26),s=m4(n);let o;t[0]!==n||t[1]!==e||t[2]!==s?(o=fg(n,s,e),t[0]=n,t[1]=e,t[2]=s,t[3]=o):o=t[3];let i;t[4]!==e||t[5]!==s?(i=bj(s,e),t[4]=e,t[5]=s,t[6]=i):i=t[6];let a;t[7]!==n||t[8]!==e||t[9]!==s?(a=vj(n,s,e),t[7]=n,t[8]=e,t[9]=s,t[10]=a):a=t[10];let l;t[11]!==n||t[12]!==e||t[13]!==s?(l=yj(n,s,e),t[11]=n,t[12]=e,t[13]=s,t[14]=l):l=t[14];let c;t[15]!==n||t[16]!==e||t[17]!==s?(c=u=>jj(n,s,u,e),t[15]=n,t[16]=e,t[17]=s,t[18]=c):c=t[18];let d;return t[19]!==s||t[20]!==o||t[21]!==i||t[22]!==a||t[23]!==l||t[24]!==c?(d={options:s,effortOptions:o,fastTier:i,imageInput:a,autoPermissionMode:l,normalizeEffort:c},t[19]=s,t[20]=o,t[21]=i,t[22]=a,t[23]=l,t[24]=c,t[25]=d):d=t[25],d}function La(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(Ty,{"data-slot":"popover",...t}),e[2]=t,e[3]=s):s=e[3],s}function Oa(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(Ey,{"data-slot":"popover-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function Sg(n){const e=B.c(22);let t,s,o,i,a,l,c,d;e[0]!==n?({align:i,alignOffset:a,side:l,sideOffset:c,collisionPadding:d,collisionAvoidance:s,className:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a,e[6]=l,e[7]=c,e[8]=d):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5],l=e[6],c=e[7],d=e[8]);const u=i===void 0?"start":i,f=a===void 0?0:a,m=l===void 0?"bottom":l,p=c===void 0?6:c,h=d===void 0?8:d;let g;e[9]!==t?(g=q("z-50 max-h-(--available-height) origin-(--transform-origin) rounded-xl bg-popover text-popover-foreground shadow-lg ring-1 ring-foreground/10 outline-none duration-100 ease-out data-[side=bottom]:slide-in-from-top-1 data-[side=top]:slide-in-from-bottom-1 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",t),e[9]=t,e[10]=g):g=e[10];let x;e[11]!==o||e[12]!==g?(x=r.jsx(Ay,{"data-slot":"popover-content",className:g,...o}),e[11]=o,e[12]=g,e[13]=x):x=e[13];let v;return e[14]!==u||e[15]!==f||e[16]!==s||e[17]!==h||e[18]!==m||e[19]!==p||e[20]!==x?(v=r.jsx(Py,{children:r.jsx(Iy,{className:"isolate z-50 outline-none",align:u,alignOffset:f,side:m,sideOffset:p,collisionPadding:h,collisionAvoidance:s,children:x})}),e[14]=u,e[15]=f,e[16]=s,e[17]=h,e[18]=m,e[19]=p,e[20]=x,e[21]=v):v=e[21],v}const h4=new Set(["mcp","server","servers","api","app","the","and"]),g4=/^([\w-]+\.[a-z]{2,})\s+(.+)$/i;function Ng(n){const e=g4.exec(n.trim());return e?{short:e[2],namespace:e[1]}:{short:n.trim()}}function x4(n){const{short:e}=Ng(n),t=e.split(/[^a-z0-9]+/i).filter(i=>i&&!h4.has(i.toLowerCase())),s=t.length>0?t:[e];return(s.length>=2?s[0][0]+s[1][0]:s[0].slice(0,2)).toUpperCase()}function Bd(n){return n?"bottom":"top"}function Ud(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("max-w-72 data-popup-open:bg-accent data-popup-open:text-accent-foreground",s),e[4]=s,e[5]=i):i=e[5];let a;e[6]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(mt,{"data-icon":"inline-end",className:"opacity-60"}),e[6]=a):a=e[6];let l;return e[7]!==t||e[8]!==o||e[9]!==i?(l=r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",className:i,...o,children:[t,a]}),e[7]=t,e[8]=o,e[9]=i,e[10]=l):l=e[10],l}function Wd(n){const e=B.c(13);let t,s,o,i;e[0]!==n?({side:o,align:i,className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);const a=i===void 0?"start":i;let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l={side:"none",align:"shift",fallbackAxisSide:"none"},e[5]=l):l=e[5];let c;e[6]!==t?(c=q("flex flex-col overflow-hidden p-0",t),e[6]=t,e[7]=c):c=e[7];let d;return e[8]!==a||e[9]!==s||e[10]!==o||e[11]!==c?(d=r.jsx(Sg,{side:o,align:a,collisionAvoidance:l,className:c,...s}),e[8]=a,e[9]=s,e[10]=o,e[11]=c,e[12]=d):d=e[12],d}function xo(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-2 pb-1 pt-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Ic(n){const e=B.c(16);let t,s,o,i,a;e[0]!==n?({value:a,onValueChange:i,className:o,children:s,...t}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5]);let l;e[6]!==i?(l=u=>i(u),e[6]=i,e[7]=l):l=e[7];let c;e[8]!==o?(c=q("flex flex-col gap-px",o),e[8]=o,e[9]=c):c=e[9];let d;return e[10]!==t||e[11]!==s||e[12]!==l||e[13]!==c||e[14]!==a?(d=r.jsx(Ry,{value:a,onValueChange:l,className:c,...t,children:s}),e[10]=t,e[11]=s,e[12]=l,e[13]=c,e[14]=a,e[15]=d):d=e[15],d}const b4="flex w-full cursor-pointer select-none items-center gap-2.5 rounded-lg px-2 py-1.5 text-left text-sm outline-none transition-colors duration-100 hover:bg-accent/70 focus-visible:ring-2 focus-visible:ring-ring/40";function Hd(n){const e=B.c(16),{value:t,title:s,description:o,icon:i,disabled:a}=n;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=q(b4,"group/option data-checked:bg-accent data-checked:text-accent-foreground data-disabled:cursor-not-allowed data-disabled:opacity-40 data-disabled:hover:bg-transparent"),e[0]=l):l=e[0];let c;e[1]!==i?(c=i&&r.jsx(i,{className:"size-4 shrink-0 text-muted-foreground group-data-checked/option:text-foreground"}),e[1]=i,e[2]=c):c=e[2];let d;e[3]!==s?(d=r.jsx("span",{className:"truncate leading-5 group-data-checked/option:font-medium",children:s}),e[3]=s,e[4]=d):d=e[4];let u;e[5]!==o?(u=o&&r.jsx("span",{className:"truncate text-xs leading-4 text-muted-foreground",title:o,children:o}),e[5]=o,e[6]=u):u=e[6];let f;e[7]!==d||e[8]!==u?(f=r.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[d,u]}),e[7]=d,e[8]=u,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx($y,{keepMounted:!0,className:"shrink-0 text-foreground opacity-0 transition-opacity duration-100 data-checked:opacity-100",children:r.jsx(at,{className:"size-4"})}),e[10]=m):m=e[10];let p;return e[11]!==a||e[12]!==c||e[13]!==f||e[14]!==t?(p=r.jsxs(My,{value:t,disabled:a,className:l,children:[c,f,m]}),e[11]=a,e[12]=c,e[13]=f,e[14]=t,e[15]=p):p=e[15],p}const v4=8;function y4(n){const e=B.c(89),{servers:t,selected:s,onToggle:o,onSetSelection:i,onRefresh:a,loading:l,onAuth:c,isNewSession:d}=n,[u,f]=w.useState(""),m=w.useId();let p,h,g,x,v,y,b,j,S,k,C,N,E,T,P,_,A;if(e[0]!==u||e[1]!==d||e[2]!==m||e[3]!==l||e[4]!==c||e[5]!==a||e[6]!==i||e[7]!==o||e[8]!==s||e[9]!==t){const M=t.filter(S4),O=t.filter(j4);let D;e[27]!==s?(D=new Set(s),e[27]=s,e[28]=D):D=e[28];const z=D;let F;e[29]!==z?(F=ae=>z.has(ae.name),e[29]=z,e[30]=F):F=e[30];const L=M.filter(F).length,H=l&&t.length===0,U=H?"MCPs":`MCPs ${L}/${M.length}`,W=u.trim().toLowerCase(),V=ae=>!W||ae.name.toLowerCase().includes(W),K=M.filter(V),Y=O.filter(V);h=La,b=!1,e[31]===Symbol.for("react.memo_cache_sentinel")?(j=ae=>{ae||f("")},e[31]=j):j=e[31];let X;e[32]!==U?(X=r.jsx(Ud,{"aria-label":U}),e[32]=U,e[33]=X):X=e[33];let G;e[34]===Symbol.for("react.memo_cache_sentinel")?(G=r.jsx(A1,{"data-icon":"inline-start"}),e[34]=G):G=e[34];let J;e[35]!==U?(J=r.jsx("span",{className:"truncate",children:U}),e[35]=U,e[36]=J):J=e[36];let Z;e[37]!==H?(Z=H&&r.jsx(Pt,{className:"size-3 animate-spin","aria-hidden":!0}),e[37]=H,e[38]=Z):Z=e[38],e[39]!==X||e[40]!==J||e[41]!==Z?(S=r.jsxs(Oa,{render:X,children:[G,J,Z]}),e[39]=X,e[40]=J,e[41]=Z,e[42]=S):S=e[42],p=Wd,e[43]!==d?(_=Bd(d),e[43]=d,e[44]=_):_=e[44],A="MCP servers",x="w-[23rem]";const Q=M.length>0&&r.jsxs("span",{"aria-hidden":!0,className:"ml-1.5 font-normal normal-case tracking-normal",children:[L," on"]});let te;e[45]!==m||e[46]!==Q?(te=r.jsxs(xo,{id:m,className:"pt-1",children:["MCP servers",Q]}),e[45]=m,e[46]=Q,e[47]=te):te=e[47];const ne=i&&M.length>1&&r.jsxs(r.Fragment,{children:[r.jsx(Om,{label:"Turn every server on",disabled:L===M.length,onClick:()=>i(M.map(w4)),children:"All"}),r.jsx(Om,{label:"Turn every server off",disabled:L===0,onClick:()=>i([]),children:"None"})]}),oe=l&&"animate-spin";let re;e[48]!==oe?(re=q(oe),e[48]=oe,e[49]=re):re=e[49];let ie;e[50]!==re?(ie=r.jsx(Pt,{className:re}),e[50]=re,e[51]=ie):ie=e[51];let se;e[52]!==a||e[53]!==ie?(se=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:a,"aria-label":"Refresh status",title:"Refresh status",className:"text-muted-foreground",children:ie}),e[52]=a,e[53]=ie,e[54]=se):se=e[54];let ce;e[55]!==ne||e[56]!==se?(ce=r.jsxs("div",{className:"flex items-center gap-0.5",children:[ne,se]}),e[55]=ne,e[56]=se,e[57]=ce):ce=e[57],e[58]!==te||e[59]!==ce?(v=r.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 px-1.5 pt-1.5",children:[te,ce]}),e[58]=te,e[59]=ce,e[60]=v):v=e[60],e[61]!==u||e[62]!==t.length?(y=t.length>v4&&r.jsx("div",{className:"shrink-0 px-1.5 pt-1",children:r.jsx("input",{type:"search",value:u,onChange:ae=>f(ae.target.value),placeholder:"Filter servers…","aria-label":"Filter servers",className:"h-7 w-full rounded-md bg-muted/60 px-2 text-xs text-foreground outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring/40 [&::-webkit-search-cancel-button]:hidden"})}),e[61]=u,e[62]=t.length,e[63]=y):y=e[63],g="group",k=m,C="flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto p-1.5",e[64]!==l||e[65]!==t.length?(N=t.length===0&&r.jsx("p",{className:"px-0.5 py-1 text-xs text-muted-foreground",children:l?"Loading…":"No MCP servers configured"}),e[64]=l,e[65]=t.length,e[66]=N):N=e[66],E=t.length>0&&K.length===0&&Y.length===0&&r.jsx("p",{className:"px-0.5 py-1 text-xs text-muted-foreground",children:"No servers match."}),T=K.length>0&&r.jsx("div",{className:"grid grid-cols-2 gap-1",children:K.map(ae=>r.jsx(Dm,{server:ae,on:z.has(ae.name),onClick:()=>o(ae.name)},ae.name))}),P=Y.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(xo,{className:"px-0.5 pt-2 text-warning/80",children:"Needs sign-in"}),r.jsx("div",{className:"grid grid-cols-2 gap-1",children:Y.map(ae=>r.jsx(Dm,{server:ae,onClick:()=>c(ae.name)},ae.name))})]}),e[0]=u,e[1]=d,e[2]=m,e[3]=l,e[4]=c,e[5]=a,e[6]=i,e[7]=o,e[8]=s,e[9]=t,e[10]=p,e[11]=h,e[12]=g,e[13]=x,e[14]=v,e[15]=y,e[16]=b,e[17]=j,e[18]=S,e[19]=k,e[20]=C,e[21]=N,e[22]=E,e[23]=T,e[24]=P,e[25]=_,e[26]=A}else p=e[10],h=e[11],g=e[12],x=e[13],v=e[14],y=e[15],b=e[16],j=e[17],S=e[18],k=e[19],C=e[20],N=e[21],E=e[22],T=e[23],P=e[24],_=e[25],A=e[26];let I;e[67]!==g||e[68]!==k||e[69]!==C||e[70]!==N||e[71]!==E||e[72]!==T||e[73]!==P?(I=r.jsxs("div",{role:g,"aria-labelledby":k,className:C,children:[N,E,T,P]}),e[67]=g,e[68]=k,e[69]=C,e[70]=N,e[71]=E,e[72]=T,e[73]=P,e[74]=I):I=e[74];let $;e[75]!==p||e[76]!==x||e[77]!==v||e[78]!==y||e[79]!==I||e[80]!==_||e[81]!==A?($=r.jsxs(p,{side:_,"aria-label":A,className:x,children:[v,y,I]}),e[75]=p,e[76]=x,e[77]=v,e[78]=y,e[79]=I,e[80]=_,e[81]=A,e[82]=$):$=e[82];let R;return e[83]!==h||e[84]!==b||e[85]!==j||e[86]!==S||e[87]!==$?(R=r.jsxs(h,{modal:b,onOpenChange:j,children:[S,$]}),e[83]=h,e[84]=b,e[85]=j,e[86]=S,e[87]=$,e[88]=R):R=e[88],R}function w4(n){return n.name}function j4(n){return n.status!=="connected"}function S4(n){return n.status==="connected"}function Om(n){const e=B.c(5),{label:t,disabled:s,onClick:o,children:i}=n;let a;return e[0]!==i||e[1]!==s||e[2]!==t||e[3]!==o?(a=r.jsx(ee,{type:"button",variant:"ghost",size:"xs","aria-label":t,title:t,disabled:s,onClick:o,className:"h-6 px-1.5 text-[11px] text-muted-foreground",children:i}),e[0]=i,e[1]=s,e[2]=t,e[3]=o,e[4]=a):a=e[4],a}function Dm(n){const e=B.c(34),{server:t,on:s,onClick:o}=n;let i;e[0]!==t.name?(i=Ng(t.name),e[0]=t.name,e[1]=i):i=e[1];const{short:a,namespace:l}=i,c=s===void 0,d=c?void 0:"checkbox",u=c?void 0:s,f=c?`${t.name}, needs sign-in`:t.name,m=c?`${t.name} · Sign in to connect`:t.name,p=c&&"bg-warning/5 ring-warning/25 hover:bg-warning/10",h=s===!0&&"bg-accent text-accent-foreground ring-foreground/10",g=s===!1&&"text-muted-foreground ring-transparent hover:bg-accent/60 hover:text-foreground";let x;e[2]!==p||e[3]!==h||e[4]!==g?(x=q("flex min-w-0 items-center gap-2 rounded-lg px-2 py-1.5 text-left text-sm outline-none ring-1 ring-inset transition-[background-color,box-shadow,color] duration-100 focus-visible:ring-2 focus-visible:ring-ring/40",p,h,g),e[2]=p,e[3]=h,e[4]=g,e[5]=x):x=e[5];const v=c&&"bg-warning/15 text-warning",y=s===!0&&"bg-primary text-primary-foreground",b=s===!1&&"bg-muted text-muted-foreground";let j;e[6]!==v||e[7]!==y||e[8]!==b?(j=q("flex size-6 shrink-0 items-center justify-center rounded-md text-[10px] font-semibold tracking-wide transition-colors duration-100",v,y,b),e[6]=v,e[7]=y,e[8]=b,e[9]=j):j=e[9];let S;e[10]!==t.name?(S=x4(t.name),e[10]=t.name,e[11]=S):S=e[11];let k;e[12]!==j||e[13]!==S?(k=r.jsx("span",{"aria-hidden":!0,className:j,children:S}),e[12]=j,e[13]=S,e[14]=k):k=e[14];let C;e[15]!==a?(C=r.jsx("span",{className:"truncate leading-4",children:a}),e[15]=a,e[16]=C):C=e[16];let N;e[17]!==l?(N=l&&r.jsx("span",{className:"truncate text-[10px] leading-3 text-muted-foreground",children:l}),e[17]=l,e[18]=N):N=e[18];let E;e[19]!==C||e[20]!==N?(E=r.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[C,N]}),e[19]=C,e[20]=N,e[21]=E):E=e[21];let T;e[22]!==c?(T=c&&r.jsx(Ly,{className:"size-3.5 shrink-0 text-warning","aria-hidden":!0}),e[22]=c,e[23]=T):T=e[23];let P;return e[24]!==o||e[25]!==k||e[26]!==E||e[27]!==T||e[28]!==d||e[29]!==u||e[30]!==f||e[31]!==m||e[32]!==x?(P=r.jsxs("button",{type:"button",role:d,"aria-checked":u,"aria-label":f,title:m,onClick:o,className:x,children:[k,E,T]}),e[24]=o,e[25]=k,e[26]=E,e[27]=T,e[28]=d,e[29]=u,e[30]=f,e[31]=m,e[32]=x,e[33]=P):P=e[33],P}const kg=rs("group/toggle inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap outline-none transition-[color,background-color,border-color,box-shadow,transform,scale] duration-100 ease-out hover:bg-muted hover:text-foreground active:scale-[0.96] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-pressed:bg-muted motion-reduce:transition-none motion-reduce:active:scale-100 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-muted"},size:{default:"h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",sm:"h-7 min-w-7 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2"}},defaultVariants:{variant:"default",size:"default"}});function N4(n){const e=B.c(12);let t,s,o,i;e[0]!==n?({className:t,variant:o,size:i,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);const a=o===void 0?"default":o,l=i===void 0?"default":i;let c;e[5]!==t||e[6]!==l||e[7]!==a?(c=q(kg({variant:a,size:l,className:t})),e[5]=t,e[6]=l,e[7]=a,e[8]=c):c=e[8];let d;return e[9]!==s||e[10]!==c?(d=r.jsx(P1,{"data-slot":"toggle",className:c,...s}),e[9]=s,e[10]=c,e[11]=d):d=e[11],d}function k4(n){const e=B.c(34),{options:t,value:s,onChange:o,disabled:i,labelId:a}=n,l=t.length-1;let c;if(e[0]!==t||e[1]!==s){let b;e[3]!==s?(b=j=>j.value===s,e[3]=s,e[4]=b):b=e[4],c=t.findIndex(b),e[0]=t,e[1]=s,e[2]=c}else c=e[2];const d=Math.max(0,c);let u;e[5]!==o||e[6]!==t||e[7]!==s?(u=b=>{const j=t[b];j&&j.value!==s&&o(j.value)},e[5]=o,e[6]=t,e[7]=s,e[8]=u):u=e[8];const f=i&&"opacity-50";let m;e[9]!==f?(m=q("w-full",f),e[9]=f,e[10]=m):m=e[10];let p;e[11]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(Oy,{className:"rounded-full bg-primary"}),e[11]=p):p=e[11];let h;if(e[12]!==d||e[13]!==l||e[14]!==t){let b;e[16]!==d||e[17]!==l?(b=(j,S)=>r.jsx("span",{"aria-hidden":!0,className:q("pointer-events-none absolute top-1/2 size-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full transition-colors duration-150",S<=d?"bg-primary":"bg-muted-foreground/40"),style:{left:l===0?"50%":`${S/l*100}%`}},j.value),e[16]=d,e[17]=l,e[18]=b):b=e[18],h=t.map(b),e[12]=d,e[13]=l,e[14]=t,e[15]=h}else h=e[15];let g;e[19]!==t?(g=(b,j)=>{var S;return((S=t[j])==null?void 0:S.label)??""},e[19]=t,e[20]=g):g=e[20];let x;e[21]!==a||e[22]!==g?(x=r.jsx(Dy,{"aria-labelledby":a,getAriaValueText:g,className:"size-3.5 rounded-full bg-primary shadow-[0_0_0_3px_var(--popover)] outline-none transition-transform duration-100 has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-ring/50 has-[:focus-visible]:ring-offset-2 has-[:focus-visible]:ring-offset-popover data-dragging:scale-125 motion-reduce:transition-none"}),e[21]=a,e[22]=g,e[23]=x):x=e[23];let v;e[24]!==h||e[25]!==x?(v=r.jsx(zy,{className:"flex h-6 w-full touch-none select-none items-center px-1.5",children:r.jsxs(Fy,{className:"relative h-1 w-full rounded-full bg-muted-foreground/20",children:[p,h,x]})}),e[24]=h,e[25]=x,e[26]=v):v=e[26];let y;return e[27]!==i||e[28]!==d||e[29]!==l||e[30]!==u||e[31]!==m||e[32]!==v?(y=r.jsx(By,{value:d,min:0,max:l,step:1,disabled:i,onValueChange:u,className:m,children:v}),e[27]=i,e[28]=d,e[29]=l,e[30]=u,e[31]=m,e[32]=v,e[33]=y):y=e[33],y}function C4(n,e){var a;const{defaultLimit:t,limits:s,extendedContext:o}=an(e).contextWindow,i=n.trim().toLowerCase();return o&&i.includes(o.marker)?o.limit:((a=s.find(l=>i.includes(l.match)))==null?void 0:a.limit)??t}function _4(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=C4(e,t),c=l-an(t).contextWindow.compactBuffer;return{used:a,limit:l,compactAt:c,percent:Math.min(100,a/c*100),percentAbsolute:Math.min(100,a/l*100)}}const T4=["fable","mythos","opus","sonnet","haiku"];function zm(n){return n.charAt(0).toUpperCase()+n.slice(1)}function Ys(n){if(!n)return"unknown";const e=n.toLowerCase(),t=/\[1m\]$/.test(e)?" 1M":"",s=e.replace(/\[[^\]]*\]$/,"");for(const o of T4){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`${zm(o)}${a}${t}`}if(s.startsWith("gpt-")){const[o,...i]=s.slice(4).split("-"),a=i.map(zm).join(" ");return`GPT-${o}${a?` ${a}`:""}${t}`}return n.length>20?n.slice(0,20)+"...":n}function dn(n){return Number.isFinite(n)?n<.01?`$${n.toFixed(4)}`:n<1?`$${n.toFixed(3)}`:`$${n.toFixed(2)}`:"—"}function lt(n){return n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}k`:String(n)}function Un(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 E4(n){if(n<60)return`${n}s`;const e=Math.floor(n/60),t=n%60;return`${e}m ${t}s`}function Cg(n){return n>=1e6?`${(n/1e6).toFixed(1)}MB`:n>=1e3?`${(n/1e3).toFixed(0)}KB`:`${n}B`}function Oo(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 qd(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 Kd(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 jn(n,e){return n.length<=e?n:n.slice(0,e)+"..."}function kn(n){return Is(n).dirName.decode(n)??n}function Da(n,e=2){const t=n.replace(/\/+$/,"").split("/").filter(Boolean);return t.length<=e?n:t.slice(-e).join("/")}function za(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 ns(n){return n.replace(/\/+$/,"").split("/").at(-1)??n}function Cs(n){const e=n.match(/^([^/]+)\/subagents\/agent-([^.]+)\.jsonl$/);return e?{parentSessionId:e[1],agentId:e[2],parentFileName:`${e[1]}.jsonl`}:null}function _g(n){for(let e=n.length-1;e>=0;e--){const t=n[e];if(t.type==="assistant")return _4(t.message.usage,t.message.model??"","claude")}return null}function Tg(n,e){const t=w.forwardRef(function(o,i){const a=B.c(4);let l;a[0]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx("path",{d:e}),a[0]=l):l=a[0];let c;return a[1]!==o||a[2]!==i?(c=r.jsx("svg",{ref:i,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:24,height:24,fill:"currentColor","aria-hidden":!0,...o,children:l}),a[1]=o,a[2]=i,a[3]=c):c=a[3],c});return t.displayName=n,t}const A4=Tg("AnthropicIcon","M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.1256 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z"),P4=Tg("OpenAIIcon","M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z"),Eg={claude:A4,codex:P4,copilot:I1},Vd={claude:"Claude",codex:"Codex",copilot:"Copilot"},I4={claude:"Claude",codex:"Codex",copilot:"GitHub Copilot"},R4={claude:null,codex:"Codex",copilot:"Copilot"},$4={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"}},M4={claude:"var(--chart-1)",codex:"var(--chart-2)",copilot:"var(--chart-3)"},L4={claude:"Interrupt agent",codex:"Stop active turn",copilot:"Stop Copilot turn"},O4={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 D4(n){return O4[n]}function z4(n){return Eg[n]}function Fa(n){return Vd[n]}function rB(n){return I4[n]}function F4(n){return R4[n]}function iB(n){return $4[n]}function B4(n){return L4[n]}function U4(n){return M4[n]}const Fm=Is(null).kind,Ag=[Fm,...Ss.filter(n=>n!==Fm)];function W4(n){return`This ${Vd[n]} session is controlled by another process. Cogpit can only view it.`}const Rc=Ag.map(n=>({value:n,label:Vd[n],Icon:Eg[n]}));function H4(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 q4(n){var t;const e=(t=n.find(s=>s.value===""))==null?void 0:t.resolvedModel;return e?Gd(e,n):"Default"}function Gd(n,e){var t;return((t=H4(n,e))==null?void 0:t.label)??Ys(n)}function K4(n){var he;const e=B.c(109),{agentKind:t,onAgentKindChange:s,selectedModel:o,resolvedDefaultName:i,modelOptions:a,onModelChange:l,selectedEffort:c,effortOptions:d,onEffortChange:u,fastTier:f,fastModeEnabled:m,onFastModeEnabledChange:p,ultracodeEnabled:h,onUltracodeEnabledChange:g,isNewSession:x}=n,v=m===void 0?!1:m,y=h===void 0?!1:h;let b;e[0]!==t?(b=Ht(t),e[0]=t,e[1]=b):b=e[1];const j=b;let S;e[2]!==t?(S=Rc.find(ge=>ge.value===t),e[2]=t,e[3]=S):S=e[3];const k=S,C=k==null?void 0:k.Icon,N=(k==null?void 0:k.label)??t;let E;e[4]!==a||e[5]!==i||e[6]!==o?(E=((he=a.find(ge=>ge.value===o))==null?void 0:he.label)??i,e[4]=a,e[5]=i,e[6]=o,e[7]=E):E=e[7];const T=E;let P;if(e[8]!==d||e[9]!==c){let ge;e[11]!==c?(ge=Se=>Se.value===c,e[11]=c,e[12]=ge):ge=e[12],P=d.find(ge),e[8]=d,e[9]=c,e[10]=P}else P=e[10];const _=P,A=!s,I=j.reasoningEffort,$=j.fastTier,R=j.ultracode,M=!!f&&!!p,O=!!g,D=v&&M,z=y&&O,F=z?"Pinned by Ultracode":_==null?void 0:_.description,L=_==null?void 0:_.label;let H;e[13]!==T||e[14]!==N||e[15]!==L?(H=[N,T,L].filter(Boolean),e[13]=T,e[14]=N,e[15]=L,e[16]=H):H=e[16];const U=H.join(" · "),W=D?"Fast mode on":null,V=z?"Ultracode on":null;let K;e[17]!==V||e[18]!==W?(K=[W,V].filter(Boolean),e[17]=V,e[18]=W,e[19]=K):K=e[19];const Y=K.join(", "),X=w.useId(),G=w.useId(),J=w.useId(),Z=Y?`${U} (${Y})`:U,Q=Y?`${U} · ${Y}`:void 0;let te;e[20]!==Z||e[21]!==Q?(te=r.jsx(Ud,{"aria-label":Z,title:Q}),e[20]=Z,e[21]=Q,e[22]=te):te=e[22];let ne;e[23]!==C?(ne=C&&r.jsx(C,{"data-icon":"inline-start"}),e[23]=C,e[24]=ne):ne=e[24];let oe;e[25]!==T?(oe=r.jsx("span",{className:"truncate",children:T}),e[25]=T,e[26]=oe):oe=e[26];let re;e[27]!==_?(re=_&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-muted-foreground/60","aria-hidden":!0,children:"·"}),r.jsx("span",{className:"shrink-0 text-muted-foreground",children:_.label})]}),e[27]=_,e[28]=re):re=e[28];let ie;e[29]!==oe||e[30]!==re?(ie=r.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[oe,re]}),e[29]=oe,e[30]=re,e[31]=ie):ie=e[31];let se;e[32]!==D?(se=D&&r.jsx(sa,{className:"size-3 shrink-0 fill-current","aria-hidden":!0}),e[32]=D,e[33]=se):se=e[33];let ce;e[34]!==z?(ce=z&&r.jsx(jr,{className:"size-3 shrink-0 fill-current","aria-hidden":!0}),e[34]=z,e[35]=ce):ce=e[35];let ae;e[36]!==te||e[37]!==ne||e[38]!==ie||e[39]!==se||e[40]!==ce?(ae=r.jsxs(Oa,{render:te,children:[ne,ie,se,ce]}),e[36]=te,e[37]=ne,e[38]=ie,e[39]=se,e[40]=ce,e[41]=ae):ae=e[41];let ue;e[42]!==x?(ue=Bd(x),e[42]=x,e[43]=ue):ue=e[43];let me;e[44]!==X?(me=r.jsx(xo,{id:X,children:"Provider"}),e[44]=X,e[45]=me):me=e[45];let de;e[46]!==s?(de=ge=>s==null?void 0:s(ge),e[46]=s,e[47]=de):de=e[47];let le;e[48]!==t||e[49]!==A?(le=Rc.map(ge=>r.jsx(Hd,{value:ge.value,title:ge.label,icon:ge.Icon,disabled:A&&ge.value!==t},ge.value)),e[48]=t,e[49]=A,e[50]=le):le=e[50];let xe;e[51]!==t||e[52]!==X||e[53]!==de||e[54]!==le?(xe=r.jsx(Ic,{value:t,onValueChange:de,"aria-labelledby":X,children:le}),e[51]=t,e[52]=X,e[53]=de,e[54]=le,e[55]=xe):xe=e[55];let pe;e[56]!==x||e[57]!==A?(pe=A&&!x&&r.jsx("p",{className:"mt-auto px-2 pb-1 pt-3 text-[11px] leading-4 text-muted-foreground",children:"Fixed for this session. Start a new one to switch."}),e[56]=x,e[57]=A,e[58]=pe):pe=e[58];let ve;e[59]!==me||e[60]!==xe||e[61]!==pe?(ve=r.jsxs("div",{className:"flex flex-col border-r bg-muted/30 p-1.5",children:[me,xe,pe]}),e[59]=me,e[60]=xe,e[61]=pe,e[62]=ve):ve=e[62];let Te;e[63]!==G?(Te=r.jsx(xo,{id:G,children:"Model"}),e[63]=G,e[64]=Te):Te=e[64];let $e;e[65]!==M||e[66]!==D||e[67]!==(f==null?void 0:f.description)||e[68]!==T||e[69]!==p||e[70]!==g||e[71]!==$||e[72]!==R||e[73]!==O||e[74]!==z?($e=($||R)&&r.jsxs("div",{className:"flex items-center gap-1",children:[$&&r.jsx(Bm,{label:"Fast mode",pressed:D,onPressedChange:ge=>p==null?void 0:p(ge),disabled:!M,title:M?`Fast mode · ${(f==null?void 0:f.description)??"Lower latency with increased usage"}`:`Fast mode isn't offered for ${T}`,children:r.jsx(sa,{className:q(D&&"fill-current")})}),R&&r.jsxs(Bm,{label:"Ultracode",pressed:z,onPressedChange:ge=>g==null?void 0:g(ge),disabled:!O,title:O?"Ultracode · Extra High effort with standing multi-agent orchestration":`Ultracode isn't available for ${T}`,children:[r.jsx(jr,{className:q(z&&"fill-current")}),"Ultracode"]})]}),e[65]=M,e[66]=D,e[67]=f==null?void 0:f.description,e[68]=T,e[69]=p,e[70]=g,e[71]=$,e[72]=R,e[73]=O,e[74]=z,e[75]=$e):$e=e[75];let _e;e[76]!==Te||e[77]!==$e?(_e=r.jsxs("div",{className:"flex items-center justify-between gap-2 pr-0.5",children:[Te,$e]}),e[76]=Te,e[77]=$e,e[78]=_e):_e=e[78];let Ce;e[79]!==a?(Ce=a.map(V4),e[79]=a,e[80]=Ce):Ce=e[80];let ke;e[81]!==G||e[82]!==l||e[83]!==o||e[84]!==Ce?(ke=r.jsx(Ic,{value:o,onValueChange:l,"aria-labelledby":G,className:"max-h-56 min-h-0 flex-1 overflow-y-auto",children:Ce}),e[81]=G,e[82]=l,e[83]=o,e[84]=Ce,e[85]=ke):ke=e[85];let Me;e[86]!==_e||e[87]!==ke?(Me=r.jsxs("div",{className:"flex min-h-0 flex-col p-1.5",children:[_e,ke]}),e[86]=_e,e[87]=ke,e[88]=Me):Me=e[88];let Oe;e[89]!==ve||e[90]!==Me?(Oe=r.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-[10.5rem_minmax(0,1fr)] overflow-hidden",children:[ve,Me]}),e[89]=ve,e[90]=Me,e[91]=Oe):Oe=e[91];let Le;e[92]!==F||e[93]!==J||e[94]!==d||e[95]!==T||e[96]!==u||e[97]!==c||e[98]!==_||e[99]!==I||e[100]!==z?(Le=I&&r.jsxs("div",{className:"shrink-0 border-t px-2 pb-1.5 pt-2",children:[r.jsxs("div",{className:"flex items-baseline justify-between gap-3 px-1.5",children:[r.jsxs(xo,{id:J,className:"flex items-baseline gap-1.5 p-0",children:["Reasoning",_&&r.jsx("span",{className:"text-xs font-medium normal-case tracking-normal text-foreground motion-safe:animate-in motion-safe:fade-in-0 motion-safe:duration-200",children:_.label},_.value)]}),F&&r.jsx("span",{className:"truncate text-[11px] leading-4 text-muted-foreground",children:F})]}),d.length>0?r.jsx(k4,{options:d,value:c,onChange:u,disabled:z,labelId:J}):r.jsxs("p",{className:"px-1.5 pb-1 text-xs leading-5 text-muted-foreground",children:["Not adjustable for ",T,"."]})]}),e[92]=F,e[93]=J,e[94]=d,e[95]=T,e[96]=u,e[97]=c,e[98]=_,e[99]=I,e[100]=z,e[101]=Le):Le=e[101];let De;e[102]!==ue||e[103]!==Oe||e[104]!==Le?(De=r.jsxs(Wd,{side:ue,align:"end","aria-label":"Model settings",className:"w-[34rem] max-w-[calc(100vw-1.5rem)]",children:[Oe,Le]}),e[102]=ue,e[103]=Oe,e[104]=Le,e[105]=De):De=e[105];let Ie;return e[106]!==ae||e[107]!==De?(Ie=r.jsxs(La,{modal:!1,onOpenChange:G4,children:[ae,De]}),e[106]=ae,e[107]=De,e[108]=Ie):Ie=e[108],Ie}function V4(n){return r.jsx(Hd,{value:n.value,title:n.menuLabel??n.label,description:n.description},n.value)}function G4(n){n&&Fd()}function Bm(n){const e=B.c(7),{label:t,pressed:s,onPressedChange:o,disabled:i,title:a,children:l}=n;let c;return e[0]!==l||e[1]!==i||e[2]!==t||e[3]!==o||e[4]!==s||e[5]!==a?(c=r.jsx(N4,{variant:"outline",size:"sm",pressed:s,onPressedChange:o,disabled:i,"aria-label":t,title:a,className:"h-6 gap-1 px-1.5 text-xs text-muted-foreground data-pressed:bg-primary data-pressed:text-primary-foreground data-pressed:hover:bg-primary/90 [&_svg:not([class*='size-'])]:size-3.5",children:l}),e[0]=l,e[1]=i,e[2]=t,e[3]=o,e[4]=s,e[5]=a,e[6]=c):c=e[6],c}function Pg(n,e){return D4(n).filter(t=>t.value!=="auto"||e)}function Y4(n){const e=B.c(22),{agentKind:t,mode:s,onChange:o,autoAvailable:i,isNewSession:a}=n,l=i===void 0?!1:i,[c,d]=w.useState(!1),u=Pg(t,l),f=u.find(_=>_.value===s)??u[0],m=w.useId(),p=`Permissions: ${f.label}`;let h;e[0]!==p?(h=r.jsx(Ud,{"aria-label":p}),e[0]=p,e[1]=h):h=e[1];let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx(R1,{"data-icon":"inline-start"}),e[2]=g):g=e[2];const x=Wd;let v;e[3]!==a?(v=Bd(a),e[3]=a,e[4]=v):v=e[4];const y="Permissions",b="w-80",j="p-1.5";let S;e[5]!==m?(S=r.jsx(xo,{id:m,children:"Permissions"}),e[5]=m,e[6]=S):S=e[6];const k=Ic;let C;e[7]!==o?(C=_=>{o(_),d(!1)},e[7]=o,e[8]=C):C=e[8];const N=u.map(X4);let E;e[9]!==k||e[10]!==m||e[11]!==s||e[12]!==C||e[13]!==N?(E=r.jsx(k,{value:s,onValueChange:C,"aria-labelledby":m,children:N}),e[9]=k,e[10]=m,e[11]=s,e[12]=C,e[13]=N,e[14]=E):E=e[14];let T;e[15]!==E||e[16]!==S?(T=r.jsxs("div",{className:j,children:[S,E]}),e[15]=E,e[16]=S,e[17]=T):T=e[17];let P;return e[18]!==x||e[19]!==T||e[20]!==v?(P=r.jsx(x,{side:v,"aria-label":y,className:b,children:T}),e[18]=x,e[19]=T,e[20]=v,e[21]=P):P=e[21],r.jsxs(La,{modal:!1,open:c,onOpenChange:d,children:[r.jsxs(Oa,{render:h,children:[g,r.jsx("span",{className:"truncate",children:f.label})]}),P]})}function X4(n){return r.jsx(Hd,{value:n.value,title:n.label,description:n.description},n.value)}function J4(n){const e=B.c(54),{agentKind:t,onAgentKindChange:s,selectedModel:o,resolvedDefaultName:i,modelOptions:a,onModelChange:l,selectedEffort:c,effortOptions:d,onEffortChange:u,fastTier:f,fastModeEnabled:m,onFastModeEnabledChange:p,isNewSession:h,worktreeEnabled:g,onWorktreeEnabledChange:x,ultracodeEnabled:v,onUltracodeEnabledChange:y,autoModeAvailable:b,permissionMode:j,onPermissionModeChange:S,mcpServers:k,selectedMcpServers:C,onToggleMcpServer:N,onSetMcpServers:E,onRefreshMcpServers:T,mcpLoading:P,onMcpAuth:_,changeAndApply:A,trailingExtra:I}=n;let $;e[0]!==t?($=Ht(t),e[0]=t,e[1]=$):$=e[1];const{worktrees:R}=$;let M;e[2]!==t||e[3]!==b||e[4]!==A||e[5]!==h||e[6]!==S||e[7]!==j?(M=S&&j&&r.jsx(Y4,{agentKind:t,mode:j,onChange:W=>A(()=>S(W)),autoAvailable:b,isNewSession:h}),e[2]=t,e[3]=b,e[4]=A,e[5]=h,e[6]=S,e[7]=j,e[8]=M):M=e[8];let O;e[9]!==h||e[10]!==x||e[11]!==R||e[12]!==g?(O=R&&h&&x&&r.jsxs(ee,{type:"button",variant:g?"secondary":"ghost",size:"xs","aria-pressed":!!g,onClick:()=>x(!g),children:[r.jsx(fn,{"data-icon":"inline-start"}),"Worktree"]}),e[9]=h,e[10]=x,e[11]=R,e[12]=g,e[13]=O):O=e[13];let D;e[14]!==A||e[15]!==h||e[16]!==P||e[17]!==k||e[18]!==_||e[19]!==T||e[20]!==E||e[21]!==N||e[22]!==C?(D=N&&T&&_&&(P||k&&k.length>0)&&r.jsx(y4,{servers:k??[],selected:C??[],onToggle:W=>A(()=>N(W)),onSetSelection:E?W=>A(()=>E(W)):void 0,onRefresh:T,loading:P??!1,onAuth:_,isNewSession:h}),e[14]=A,e[15]=h,e[16]=P,e[17]=k,e[18]=_,e[19]=T,e[20]=E,e[21]=N,e[22]=C,e[23]=D):D=e[23];let z;e[24]!==M||e[25]!==O||e[26]!==D||e[27]!==I?(z=r.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:[M,O,D,I]}),e[24]=M,e[25]=O,e[26]=D,e[27]=I,e[28]=z):z=e[28];let F;e[29]!==A||e[30]!==p?(F=p?W=>A(()=>p(W)):void 0,e[29]=A,e[30]=p,e[31]=F):F=e[31];let L;e[32]!==A||e[33]!==y?(L=y?W=>A(()=>y(W)):void 0,e[32]=A,e[33]=y,e[34]=L):L=e[34];let H;e[35]!==t||e[36]!==d||e[37]!==m||e[38]!==f||e[39]!==h||e[40]!==a||e[41]!==s||e[42]!==u||e[43]!==l||e[44]!==i||e[45]!==c||e[46]!==o||e[47]!==F||e[48]!==L||e[49]!==v?(H=r.jsx(K4,{agentKind:t,onAgentKindChange:s,selectedModel:o,resolvedDefaultName:i,modelOptions:a,onModelChange:l,selectedEffort:c,effortOptions:d,onEffortChange:u,fastTier:f,fastModeEnabled:m,onFastModeEnabledChange:F,ultracodeEnabled:v,onUltracodeEnabledChange:L,isNewSession:h}),e[35]=t,e[36]=d,e[37]=m,e[38]=f,e[39]=h,e[40]=a,e[41]=s,e[42]=u,e[43]=l,e[44]=i,e[45]=c,e[46]=o,e[47]=F,e[48]=L,e[49]=v,e[50]=H):H=e[50];let U;return e[51]!==z||e[52]!==H?(U=r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1",role:"group","aria-label":"Session settings",children:[z,H]}),e[51]=z,e[52]=H,e[53]=U):U=e[53],U}function Nt(n){const e=B.c(10);let t,s,o;e[0]!==n?({className:t,orientation:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"horizontal":o;let a;e[4]!==t?(a=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(vd,{"data-slot":"separator",orientation:i,className:a,...s}),e[6]=i,e[7]=s,e[8]=a,e[9]=l):l=e[9],l}function Q4(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=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 Z4(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 e5(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 Do(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 t5=rs("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 yt(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(t5({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 aB(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 wt(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(Q4,{"data-slot":"field-label",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Co(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 vs(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(s5)).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(n5)}),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 n5(n,e){return(n==null?void 0:n.message)&&r.jsx("li",{children:n.message},e)}function s5(n){return[n==null?void 0:n.message,n]}const $c=Wy;function o5(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=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(t3,{"data-slot":"select-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Mc(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(qy,{"data-slot":"select-value",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Lc(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(Vy,{render:r.jsx(mt,{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(Hy,{"data-slot":"select-trigger","data-size":a,className:l,...o,children:[t,c]}),e[8]=t,e[9]=o,e[10]=a,e[11]=l,e[12]=d):d=e[12],d}function Oc(n){const e=B.c(26);let t,s,o,i,a,l,c,d;e[0]!==n?({className:s,children:t,side:i,sideOffset:a,align:l,alignOffset:c,alignItemWithTrigger:d,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a,e[6]=l,e[7]=c,e[8]=d):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5],l=e[6],c=e[7],d=e[8]);const u=i===void 0?"bottom":i,f=a===void 0?4:a,m=l===void 0?"center":l,p=c===void 0?0:c,h=d===void 0?!0:d;let g;e[9]!==s?(g=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(r5,{}),e[11]=x):x=e[11];let v;e[12]!==t?(v=r.jsx(Gy,{children:t}),e[12]=t,e[13]=v):v=e[13];let y;e[14]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(i5,{}),e[14]=y):y=e[14];let b;e[15]!==o||e[16]!==g||e[17]!==v?(b=r.jsxs(Ky,{"data-slot":"select-content",className:g,...o,children:[x,v,y]}),e[15]=o,e[16]=g,e[17]=v,e[18]=b):b=e[18];let j;return e[19]!==m||e[20]!==h||e[21]!==p||e[22]!==u||e[23]!==f||e[24]!==b?(j=r.jsx(Yy,{children:r.jsx(Xy,{side:u,sideOffset:f,align:m,alignOffset:p,alignItemWithTrigger:h,className:"isolate z-50",children:b})}),e[19]=m,e[20]=h,e[21]=p,e[22]=u,e[23]=f,e[24]=b,e[25]=j):j=e[25],j}function Dc(n){const e=B.c(13);let t,s,o;e[0]!==n?({className:s,children:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==s?(i=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(Jy,{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(Qy,{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(at,{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(Uy,{"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 r5(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(Ca,{}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.jsx(Zy,{"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 i5(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(mt,{}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.jsx(e3,{"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 a5(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($1,{"data-slot":"sheet",...t}),e[2]=t,e[3]=s):s=e[3],s}function l5(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(n3,{"data-slot":"sheet-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function c5(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(Fr,{"data-slot":"sheet-close",...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(Sd,{"data-slot":"sheet-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function u5(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(Nd,{"data-slot":"sheet-overlay",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function f5(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(u5,{}),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(Fr,{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(tt,{"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(d5,{children:[d,r.jsxs(jd,{"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 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("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 p5(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(yd,{"data-slot":"sheet-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function h5(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=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(wd,{"data-slot":"sheet-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function mr(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(wt,{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(yt,{className:l,children:[c,d]}),e[6]=l,e[7]=c,e[8]=d,e[9]=u):u=e[9],u}function Pi(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(Mc,{}),e[2]=u):u=e[2];let f;e[3]!==s||e[4]!==c?(f=r.jsx(Lc,{"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(g5),e[6]=i,e[7]=m):m=e[7];let p;e[8]!==m?(p=r.jsx(Oc,{children:r.jsx(o5,{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($c,{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(mr,{label:t,children:h}),e[16]=t,e[17]=h,e[18]=g):g=e[18],g}function g5(n){return r.jsx(Dc,{value:n.value,children:n.menuLabel??n.label},n.value||"default")}function x5(n){const e=B.c(28),{agentKind:t,onAgentKindChange:s,selectedModel:o,onModelChange:i,modelOptions:a,selectedEffort:l,onEffortChange:c,effortOptions:d,ultracodeEnabled:u,fastTier:f,fastModeEnabled:m,onFastModeEnabledChange:p,permissionMode:h,permissionOptions:g,onPermissionModeChange:x,changeAndApply:v}=n;let y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx("h3",{id:"mobile-model-controls",className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Model and behavior"}),e[0]=y):y=e[0];let b;e[1]!==t||e[2]!==s?(b=s&&r.jsx(Pi,{label:"Agent",ariaLabel:"Agent",value:t,options:Rc,onChange:E=>s(E)}),e[1]=t,e[2]=s,e[3]=b):b=e[3];let j;e[4]!==a||e[5]!==i||e[6]!==o?(j=r.jsx(Pi,{label:"Model",ariaLabel:"Model",value:o,options:a,onChange:i}),e[4]=a,e[5]=i,e[6]=o,e[7]=j):j=e[7];let S;e[8]!==d||e[9]!==c||e[10]!==l||e[11]!==u?(S=d.length>0&&r.jsx(Pi,{label:"Reasoning",ariaLabel:"Reasoning effort",value:l,options:d,onChange:c,disabled:u,title:u?"Effort is pinned to XHigh while Ultracode is on":void 0}),e[8]=d,e[9]=c,e[10]=l,e[11]=u,e[12]=S):S=e[12];let k;e[13]!==v||e[14]!==m||e[15]!==f||e[16]!==p?(k=f&&p&&r.jsx(mr,{label:"Speed",children:r.jsxs(ee,{type:"button",variant:m?"secondary":"ghost","aria-pressed":!!m,onClick:()=>v(()=>p(!m)),title:f.description,className:"h-10 justify-start",children:[r.jsx(sa,{"data-icon":"inline-start",className:q(m&&"fill-current")}),m?"Fast":"Standard"]})}),e[13]=v,e[14]=m,e[15]=f,e[16]=p,e[17]=k):k=e[17];let C;e[18]!==x||e[19]!==h||e[20]!==g?(C=x&&h&&r.jsx(Pi,{label:"Access",ariaLabel:"Access policy",value:h,options:g,onChange:E=>x(E)}),e[18]=x,e[19]=h,e[20]=g,e[21]=C):C=e[21];let N;return e[22]!==b||e[23]!==j||e[24]!==S||e[25]!==k||e[26]!==C?(N=r.jsxs("section",{"aria-labelledby":"mobile-model-controls",className:"flex flex-col gap-2",children:[y,r.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[b,j,S,k,C]})]}),e[22]=b,e[23]=j,e[24]=S,e[25]=k,e[26]=C,e[27]=N):N=e[27],N}function b5(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=Ht(t),e[0]=t,e[1]=g):g=e[1];const{worktrees:x,ultracode:v}=g,y=!!(u&&f&&p&&(m||c&&c.length>0)),b=!!(x&&s&&i||v&&l||y);let j;e[2]!==d?(j=d??[],e[2]=d,e[3]=j):j=e[3];let S;e[4]!==j?(S=new Set(j),e[4]=j,e[5]=S):S=e[5];const k=S;if(!b)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(mr,{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(fn,{"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;e[12]!==h||e[13]!==l||e[14]!==v||e[15]!==a?(E=v&&l&&r.jsx(mr,{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(sa,{"data-icon":"inline-start",className:q(a&&"fill-current")}),"Ultracode"]})}),e[12]=h,e[13]=l,e[14]=v,e[15]=a,e[16]=E):E=e[16];let T;e[17]!==h||e[18]!==m||e[19]!==c||e[20]!==p||e[21]!==f||e[22]!==u||e[23]!==k||e[24]!==y?(T=y&&u&&f&&p&&r.jsx(mr,{label:"Connections",wide:!0,children:r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsxs(ee,{type:"button",variant:"ghost",onClick:f,className:"min-h-10 justify-start",children:[r.jsx(Pt,{"data-icon":"inline-start",className:q(m&&"animate-spin")}),"Refresh MCP status"]}),(c??[]).map(_=>{const A=k.has(_.name),I=_.status==="connected";return r.jsxs(ee,{type:"button",variant:"ghost","aria-pressed":I?A:void 0,onClick:()=>I?h(()=>u(_.name)):p(_.name),className:"min-h-10 justify-start text-left",children:[r.jsx("span",{className:q("size-2 shrink-0 rounded-full",I&&A?"bg-success":I?"bg-muted-foreground":"bg-warning")}),r.jsx("span",{className:"min-w-0 flex-1 truncate",children:_.name}),r.jsx("span",{className:"text-xs text-muted-foreground",children:I?A?"On":"Off":"Connect"})]},_.name)})]})}),e[17]=h,e[18]=m,e[19]=c,e[20]=p,e[21]=f,e[22]=u,e[23]=k,e[24]=y,e[25]=T):T=e[25];let P;return e[26]!==N||e[27]!==E||e[28]!==T?(P=r.jsxs("section",{"aria-labelledby":"mobile-advanced-controls",className:"flex flex-col gap-2",children:[C,r.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[N,E,T]})]}),e[26]=N,e[27]=E,e[28]=T,e[29]=P):P=e[29],P}function v5(n){var ie,se;const e=B.c(74),{open:t,onOpenChange:s,agentKind:o,onAgentKindChange:i,selectedModel:a,resolvedDefaultName:l,catalogOptions:c,modelOptions:d,onModelChange:u,selectedEffort:f,effortOptions:m,onEffortChange:p,fastTier:h,fastModeEnabled:g,onFastModeEnabledChange:x,isNewSession:v,worktreeEnabled:y,onWorktreeEnabledChange:b,ultracodeEnabled:j,onUltracodeEnabledChange:S,autoModeAvailable:k,permissionMode:C,onPermissionModeChange:N,mcpServers:E,selectedMcpServers:T,onToggleMcpServer:P,onRefreshMcpServers:_,mcpLoading:A,onMcpAuth:I,mobileExtra:$,changeAndApply:R}=n;let M,O;e[0]!==o||e[1]!==k||e[2]!==C?(M=Pg(o,k),O=(ie=M.find(ce=>ce.value===C))==null?void 0:ie.label,e[0]=o,e[1]=k,e[2]=C,e[3]=M,e[4]=O):(M=e[3],O=e[4]);const D=O;let z;e[5]!==c||e[6]!==l||e[7]!==a?(z=a?Gd(a,c):l,e[5]=c,e[6]=l,e[7]=a,e[8]=z):z=e[8];let F;e[9]!==m||e[10]!==f?(F=(se=m.find(ce=>ce.value===f))==null?void 0:se.label,e[9]=m,e[10]=f,e[11]=F):F=e[11];let L;e[12]!==D||e[13]!==z||e[14]!==F?(L=[z,F,D].filter(Boolean),e[12]=D,e[13]=z,e[14]=F,e[15]=L):L=e[15];const H=L.join(" · ");let U;e[16]!==R||e[17]!==N?(U=ce=>{N&&R(()=>N(ce))},e[16]=R,e[17]=N,e[18]=U):U=e[18];const W=U;let V;e[19]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx(l5,{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(kd,{})}),e[19]=V):V=e[19];let K;e[20]===Symbol.for("react.memo_cache_sentinel")?(K=r.jsx(p5,{children:"Session controls"}),e[20]=K):K=e[20];let Y;e[21]!==H?(Y=r.jsx(h5,{className:"truncate text-xs",children:H}),e[21]=H,e[22]=Y):Y=e[22];let X;e[23]===Symbol.for("react.memo_cache_sentinel")?(X=r.jsx(c5,{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(tt,{})}),e[23]=X):X=e[23];let G;e[24]!==Y?(G=r.jsxs(m5,{className:"gap-1 px-4 pb-3 pt-4",children:[K,Y,X]}),e[24]=Y,e[25]=G):G=e[25];let J;e[26]!==o||e[27]!==R||e[28]!==W||e[29]!==m||e[30]!==g||e[31]!==h||e[32]!==d||e[33]!==i||e[34]!==p||e[35]!==x||e[36]!==u||e[37]!==C||e[38]!==M||e[39]!==f||e[40]!==a||e[41]!==j?(J=r.jsx(x5,{agentKind:o,onAgentKindChange:i,selectedModel:a,onModelChange:u,modelOptions:d,selectedEffort:f,onEffortChange:p,effortOptions:m,ultracodeEnabled:j,fastTier:h,fastModeEnabled:g,onFastModeEnabledChange:x,permissionMode:C,permissionOptions:M,onPermissionModeChange:W,changeAndApply:R}),e[26]=o,e[27]=R,e[28]=W,e[29]=m,e[30]=g,e[31]=h,e[32]=d,e[33]=i,e[34]=p,e[35]=x,e[36]=u,e[37]=C,e[38]=M,e[39]=f,e[40]=a,e[41]=j,e[42]=J):J=e[42];let Z;e[43]!==o||e[44]!==R||e[45]!==v||e[46]!==A||e[47]!==E||e[48]!==I||e[49]!==_||e[50]!==P||e[51]!==S||e[52]!==b||e[53]!==T||e[54]!==j||e[55]!==y?(Z=r.jsx(b5,{agentKind:o,isNewSession:v,worktreeEnabled:y,onWorktreeEnabledChange:b,ultracodeEnabled:j,onUltracodeEnabledChange:S,mcpServers:E,selectedMcpServers:T,onToggleMcpServer:P,onRefreshMcpServers:_,mcpLoading:A,onMcpAuth:I,changeAndApply:R}),e[43]=o,e[44]=R,e[45]=v,e[46]=A,e[47]=E,e[48]=I,e[49]=_,e[50]=P,e[51]=S,e[52]=b,e[53]=T,e[54]=j,e[55]=y,e[56]=Z):Z=e[56];let Q;e[57]!==$?(Q=$&&r.jsxs("section",{"aria-labelledby":"mobile-goal-controls",className:"flex flex-col gap-2 pt-1",children:[r.jsx(Nt,{className:"mb-3"}),r.jsx("h3",{id:"mobile-goal-controls",className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Long-running goal"}),r.jsx("div",{className:"[&>*]:mx-0 [&>*]:mb-0 [&_button]:min-h-10",children:$})]}),e[57]=$,e[58]=Q):Q=e[58];let te;e[59]!==o||e[60]!==v?(te=!v&&r.jsx("p",{className:"text-xs text-muted-foreground",children:Ht(o).settingsApply==="live"?"Changes apply live.":"Changes apply on the next turn."}),e[59]=o,e[60]=v,e[61]=te):te=e[61];let ne;e[62]!==J||e[63]!==Z||e[64]!==Q||e[65]!==te?(ne=r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-4 py-4",children:[J,Z,Q,te]}),e[62]=J,e[63]=Z,e[64]=Q,e[65]=te,e[66]=ne):ne=e[66];let oe;e[67]!==G||e[68]!==ne?(oe=r.jsxs(f5,{side:"bottom",className:"max-h-[82dvh] overflow-hidden rounded-t-2xl pb-[env(safe-area-inset-bottom)]",showCloseButton:!1,children:[G,ne]}),e[67]=G,e[68]=ne,e[69]=oe):oe=e[69];let re;return e[70]!==s||e[71]!==t||e[72]!==oe?(re=r.jsx(r.Fragment,{children:r.jsxs(a5,{open:t,onOpenChange:s,children:[V,oe]})}),e[70]=s,e[71]=t,e[72]=oe,e[73]=re):re=e[73],re}const y5=w.memo(function(e){const t=B.c(53),{agentKind:s,onAgentKindChange:o,selectedModel:i,onModelChange:a,selectedEffort:l,onEffortChange:c,fastModeEnabled:d,onFastModeEnabledChange:u,isNewSession:f,worktreeEnabled:m,onWorktreeEnabledChange:p,ultracodeEnabled:h,onUltracodeEnabledChange:g,onApplySettings:x,activeModelId:v,mcpServers:y,selectedMcpServers:b,onToggleMcpServer:j,onSetMcpServers:S,onRefreshMcpServers:k,mcpLoading:C,onMcpAuth:N,permissionMode:E,onPermissionModeChange:T,mobileExtra:P,trailingExtra:_,mobile:A}=e,I=s===void 0?Gs:s,$=A===void 0?!1:A,[R,M]=w.useState(!1);let O;t[0]!==f||t[1]!==x?(O=se=>{se(),!f&&x&&setTimeout(()=>x(),0)},t[0]=f,t[1]=x,t[2]=O):O=t[2];const D=O;let z;t[3]!==D||t[4]!==a?(z=se=>D(()=>a(se)),t[3]=D,t[4]=a,t[5]=z):z=t[5];const F=z;let L;t[6]!==D||t[7]!==c?(L=se=>D(()=>c(se)),t[6]=D,t[7]=c,t[8]=L):L=t[8];const H=L,{options:U,effortOptions:W,fastTier:V,autoPermissionMode:K,normalizeEffort:Y}=jg(I,i),X=(v==null?void 0:v.toLowerCase().startsWith("gpt-"))??!1,J=v&&(I==="copilot"||X===(I==="codex"))?v:void 0;let Z,Q;t[9]!==U||t[10]!==J?(Z=J?Gd(J,U):q4(U),Q=U.map(se=>{const ce=[se.description,se.availabilityMessage].filter(Boolean).join(" · ")||void 0;return se.value===""?{...se,description:ce,label:Z,menuLabel:se.label}:{...se,description:ce}}),t[9]=U,t[10]=J,t[11]=Z,t[12]=Q):(Z=t[11],Q=t[12]);const te=Q;let ne;t[13]!==Y||t[14]!==l?(ne=Y(l),t[13]=Y,t[14]=l,t[15]=ne):ne=t[15];let oe;t[16]!==I||t[17]!==K||t[18]!==D||t[19]!==W||t[20]!==d||t[21]!==V||t[22]!==H||t[23]!==F||t[24]!==f||t[25]!==C||t[26]!==y||t[27]!==te||t[28]!==o||t[29]!==u||t[30]!==N||t[31]!==T||t[32]!==k||t[33]!==S||t[34]!==j||t[35]!==g||t[36]!==p||t[37]!==E||t[38]!==Z||t[39]!==b||t[40]!==i||t[41]!==ne||t[42]!==h||t[43]!==m?(oe={agentKind:I,onAgentKindChange:o,selectedModel:i,resolvedDefaultName:Z,modelOptions:te,onModelChange:F,selectedEffort:ne,effortOptions:W,onEffortChange:H,fastTier:V,fastModeEnabled:d,onFastModeEnabledChange:u,isNewSession:f,worktreeEnabled:m,onWorktreeEnabledChange:p,ultracodeEnabled:h,onUltracodeEnabledChange:g,autoModeAvailable:K,permissionMode:E,onPermissionModeChange:T,mcpServers:y,selectedMcpServers:b,onToggleMcpServer:j,onSetMcpServers:S,onRefreshMcpServers:k,mcpLoading:C,onMcpAuth:N,changeAndApply:D},t[16]=I,t[17]=K,t[18]=D,t[19]=W,t[20]=d,t[21]=V,t[22]=H,t[23]=F,t[24]=f,t[25]=C,t[26]=y,t[27]=te,t[28]=o,t[29]=u,t[30]=N,t[31]=T,t[32]=k,t[33]=S,t[34]=j,t[35]=g,t[36]=p,t[37]=E,t[38]=Z,t[39]=b,t[40]=i,t[41]=ne,t[42]=h,t[43]=m,t[44]=oe):oe=t[44];const re=oe;if($){let se;return t[45]!==U||t[46]!==re||t[47]!==P||t[48]!==R?(se=r.jsx(v5,{...re,open:R,onOpenChange:M,catalogOptions:U,mobileExtra:P}),t[45]=U,t[46]=re,t[47]=P,t[48]=R,t[49]=se):se=t[49],se}let ie;return t[50]!==re||t[51]!==_?(ie=r.jsx(J4,{...re,trailingExtra:_}),t[50]=re,t[51]=_,t[52]=ie):ie=t[52],ie});function Ig(n){return n.agentType==="team-lead"}function w5(n){return Ig(n)?void 0:n.color}const j5={blue:"bg-blue-500",green:"bg-green-500",yellow:"bg-yellow-500",purple:"bg-purple-500",orange:"bg-orange-500"};function S5(n){return n?j5[n]??"bg-zinc-400":"bg-zinc-400"}const N5=w.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(An,{className:"size-3"}),t[0]=c):c=t[0];let d;t[1]!==s?(d=r.jsxs("div",{className:"flex shrink-0 items-center gap-1.5 text-xs font-medium text-muted-foreground",children:[c,r.jsx("span",{className:"max-w-[120px] truncate",children:s})]}),t[1]=s,t[2]=d):d=t[2];let u;t[3]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Nt,{orientation:"vertical",className:"h-3.5"}),t[3]=u):u=t[3];let f;if(t[4]!==i||t[5]!==a||t[6]!==o||t[7]!==l){let h;t[9]!==i||t[10]!==a||t[11]!==l?(h=g=>{const x=g.name===i,v=g.name===a,y=S5(w5(g));return r.jsxs(ee,{variant:"ghost",size:"xs",onClick:()=>l(g),disabled:v,className:q("whitespace-nowrap",x?"bg-accent text-accent-foreground":"text-muted-foreground"),children:[v?r.jsx(et,{"data-icon":"inline-start",className:"animate-spin"}):r.jsx("span",{className:q("inline-flex size-1.5 shrink-0 rounded-full",y)}),r.jsx("span",{children:g.name}),Ig(g)&&r.jsx(s3,{"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 Rg(n){const e=B.c(3),t=w.useRef(null),[s,o]=w.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]),w.useEffect(i,a),s}const $g=w.createContext(null),Mg=w.createContext(null);function Ji(n){const e=B.c(6),{value:t,chatValue:s,children:o}=n;let i;e[0]!==s||e[1]!==o?(i=r.jsx(Mg.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($g.Provider,{value:t,children:i}),e[3]=i,e[4]=t,e[5]=a):a=e[5],a}function ot(){const n=w.useContext($g);if(!n)throw new Error("useSessionContext must be used within a SessionProvider");return n}function Vr(){const n=w.useContext(Mg);if(!n)throw new Error("useSessionChatContext must be used within a SessionProvider");return n}const k5=rs("group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",destructive:"bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",outline:"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",ghost:"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",link:"text-primary underline-offset-4 hover:underline"}},defaultVariants:{variant:"default"}});function Pe(n){const e=B.c(13);let t,s,o,i,a;if(e[0]!==n){const{className:d,variant:u,render:f,...m}=n;t=f,a=u===void 0?"default":u,i=L1,s="span",o=M1({className:q(k5({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 Um=1,C5=.9,_5=.8,T5=.17,Il=.1,Rl=.999,E5=.9999,A5=.99,P5=/[\\\/_+.#"@\[\(\{&]/,I5=/[\\\/_+.#"@\[\(\{&]/g,R5=/[\s-]/,Lg=/[\s-]/g;function zc(n,e,t,s,o,i,a){if(i===e.length)return o===n.length?Um:A5;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=zc(n,e,t,s,d+1,i+1,a),f>u&&(d===o?f*=Um:P5.test(n.charAt(d-1))?(f*=_5,p=n.slice(o,d-1).match(I5),p&&o>0&&(f*=Math.pow(Rl,p.length))):R5.test(n.charAt(d-1))?(f*=C5,h=n.slice(o,d-1).match(Lg),h&&o>0&&(f*=Math.pow(Rl,h.length))):(f*=T5,o>0&&(f*=Math.pow(Rl,d-o))),n.charAt(d)!==e.charAt(i)&&(f*=E5)),(f<Il&&t.charAt(d-1)===s.charAt(i+1)||s.charAt(i+1)===s.charAt(i)&&t.charAt(d-1)!==s.charAt(i))&&(m=zc(n,e,t,s,d+1,i+2,a),m*Il>f&&(f=m*Il)),f>u&&(u=f),d=t.indexOf(c,d+1);return a[l]=u,u}function Wm(n){return n.toLowerCase().replace(Lg," ")}function $5(n,e,t){return n=t&&t.length>0?`${n+" "+t.join(" ")}`:n,zc(n,e,Wm(n),Wm(e),0,0,{})}var Jo='[cmdk-group=""]',$l='[cmdk-group-items=""]',M5='[cmdk-group-heading=""]',Og='[cmdk-item=""]',Hm=`${Og}:not([aria-disabled="true"])`,Fc="cmdk-item-select",io="data-value",L5=(n,e,t)=>$5(n,e,t),Dg=w.createContext(void 0),Gr=()=>w.useContext(Dg),zg=w.createContext(void 0),Yd=()=>w.useContext(zg),Fg=w.createContext(void 0),Bg=w.forwardRef((n,e)=>{let t=ao(()=>{var L,H;return{search:"",value:(H=(L=n.value)!=null?L:n.defaultValue)!=null?H:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),s=ao(()=>new Set),o=ao(()=>new Map),i=ao(()=>new Map),a=ao(()=>new Set),l=Ug(n),{label:c,children:d,value:u,onValueChange:f,filter:m,shouldFilter:p,loop:h,disablePointerSelection:g=!1,vimBindings:x=!0,...v}=n,y=ho(),b=ho(),j=ho(),S=w.useRef(null),k=V5();Hs(()=>{if(u!==void 0){let L=u.trim();t.current.value=L,C.emit()}},[u]),Hs(()=>{k(6,A)},[]);let C=w.useMemo(()=>({subscribe:L=>(a.current.add(L),()=>a.current.delete(L)),snapshot:()=>t.current,setState:(L,H,U)=>{var W,V,K,Y;if(!Object.is(t.current[L],H)){if(t.current[L]=H,L==="search")_(),T(),k(1,P);else if(L==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let X=document.getElementById(j);X?X.focus():(W=document.getElementById(y))==null||W.focus()}if(k(7,()=>{var X;t.current.selectedItemId=(X=I())==null?void 0:X.id,C.emit()}),U||k(5,A),((V=l.current)==null?void 0:V.value)!==void 0){let X=H??"";(Y=(K=l.current).onValueChange)==null||Y.call(K,X);return}}C.emit()}},emit:()=>{a.current.forEach(L=>L())}}),[]),N=w.useMemo(()=>({value:(L,H,U)=>{var W;H!==((W=i.current.get(L))==null?void 0:W.value)&&(i.current.set(L,{value:H,keywords:U}),t.current.filtered.items.set(L,E(H,U)),k(2,()=>{T(),C.emit()}))},item:(L,H)=>(s.current.add(L),H&&(o.current.has(H)?o.current.get(H).add(L):o.current.set(H,new Set([L]))),k(3,()=>{_(),T(),t.current.value||P(),C.emit()}),()=>{i.current.delete(L),s.current.delete(L),t.current.filtered.items.delete(L);let U=I();k(4,()=>{_(),(U==null?void 0:U.getAttribute("id"))===L&&P(),C.emit()})}),group:L=>(o.current.has(L)||o.current.set(L,new Set),()=>{i.current.delete(L),o.current.delete(L)}),filter:()=>l.current.shouldFilter,label:c||n["aria-label"],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:y,inputId:j,labelId:b,listInnerRef:S}),[]);function E(L,H){var U,W;let V=(W=(U=l.current)==null?void 0:U.filter)!=null?W:L5;return L?V(L,t.current.search,H):0}function T(){if(!t.current.search||l.current.shouldFilter===!1)return;let L=t.current.filtered.items,H=[];t.current.filtered.groups.forEach(W=>{let V=o.current.get(W),K=0;V.forEach(Y=>{let X=L.get(Y);K=Math.max(X,K)}),H.push([W,K])});let U=S.current;$().sort((W,V)=>{var K,Y;let X=W.getAttribute("id"),G=V.getAttribute("id");return((K=L.get(G))!=null?K:0)-((Y=L.get(X))!=null?Y:0)}).forEach(W=>{let V=W.closest($l);V?V.appendChild(W.parentElement===V?W:W.closest(`${$l} > *`)):U.appendChild(W.parentElement===U?W:W.closest(`${$l} > *`))}),H.sort((W,V)=>V[1]-W[1]).forEach(W=>{var V;let K=(V=S.current)==null?void 0:V.querySelector(`${Jo}[${io}="${encodeURIComponent(W[0])}"]`);K==null||K.parentElement.appendChild(K)})}function P(){let L=$().find(U=>U.getAttribute("aria-disabled")!=="true"),H=L==null?void 0:L.getAttribute(io);C.setState("value",H||void 0)}function _(){var L,H,U,W;if(!t.current.search||l.current.shouldFilter===!1){t.current.filtered.count=s.current.size;return}t.current.filtered.groups=new Set;let V=0;for(let K of s.current){let Y=(H=(L=i.current.get(K))==null?void 0:L.value)!=null?H:"",X=(W=(U=i.current.get(K))==null?void 0:U.keywords)!=null?W:[],G=E(Y,X);t.current.filtered.items.set(K,G),G>0&&V++}for(let[K,Y]of o.current)for(let X of Y)if(t.current.filtered.items.get(X)>0){t.current.filtered.groups.add(K);break}t.current.filtered.count=V}function A(){var L,H,U;let W=I();W&&(((L=W.parentElement)==null?void 0:L.firstChild)===W&&((U=(H=W.closest(Jo))==null?void 0:H.querySelector(M5))==null||U.scrollIntoView({block:"nearest"})),W.scrollIntoView({block:"nearest"}))}function I(){var L;return(L=S.current)==null?void 0:L.querySelector(`${Og}[aria-selected="true"]`)}function $(){var L;return Array.from(((L=S.current)==null?void 0:L.querySelectorAll(Hm))||[])}function R(L){let H=$()[L];H&&C.setState("value",H.getAttribute(io))}function M(L){var H;let U=I(),W=$(),V=W.findIndex(Y=>Y===U),K=W[V+L];(H=l.current)!=null&&H.loop&&(K=V+L<0?W[W.length-1]:V+L===W.length?W[0]:W[V+L]),K&&C.setState("value",K.getAttribute(io))}function O(L){let H=I(),U=H==null?void 0:H.closest(Jo),W;for(;U&&!W;)U=L>0?q5(U,Jo):K5(U,Jo),W=U==null?void 0:U.querySelector(Hm);W?C.setState("value",W.getAttribute(io)):M(L)}let D=()=>R($().length-1),z=L=>{L.preventDefault(),L.metaKey?D():L.altKey?O(1):M(1)},F=L=>{L.preventDefault(),L.metaKey?R(0):L.altKey?O(-1):M(-1)};return w.createElement(As.div,{ref:e,tabIndex:-1,...v,"cmdk-root":"",onKeyDown:L=>{var H;(H=v.onKeyDown)==null||H.call(v,L);let U=L.nativeEvent.isComposing||L.keyCode===229;if(!(L.defaultPrevented||U))switch(L.key){case"n":case"j":{x&&L.ctrlKey&&z(L);break}case"ArrowDown":{z(L);break}case"p":case"k":{x&&L.ctrlKey&&F(L);break}case"ArrowUp":{F(L);break}case"Home":{L.preventDefault(),R(0);break}case"End":{L.preventDefault(),D();break}case"Enter":{L.preventDefault();let W=I();if(W){let V=new Event(Fc);W.dispatchEvent(V)}}}}},w.createElement("label",{"cmdk-label":"",htmlFor:N.inputId,id:N.labelId,style:Y5},c),Ba(n,L=>w.createElement(zg.Provider,{value:C},w.createElement(Dg.Provider,{value:N},L))))}),O5=w.forwardRef((n,e)=>{var t,s;let o=ho(),i=w.useRef(null),a=w.useContext(Fg),l=Gr(),c=Ug(n),d=(s=(t=c.current)==null?void 0:t.forceMount)!=null?s:a==null?void 0:a.forceMount;Hs(()=>{if(!d)return l.item(o,a==null?void 0:a.id)},[d]);let u=Wg(o,i,[n.value,n.children,i],n.keywords),f=Yd(),m=_s(k=>k.value&&k.value===u.current),p=_s(k=>d||l.filter()===!1?!0:k.search?k.filtered.items.get(o)>0:!0);w.useEffect(()=>{let k=i.current;if(!(!k||n.disabled))return k.addEventListener(Fc,h),()=>k.removeEventListener(Fc,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:v,onSelect:y,forceMount:b,keywords:j,...S}=n;return w.createElement(As.div,{ref:Sr(i,e),...S,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)}),D5=w.forwardRef((n,e)=>{let{heading:t,children:s,forceMount:o,...i}=n,a=ho(),l=w.useRef(null),c=w.useRef(null),d=ho(),u=Gr(),f=_s(p=>o||u.filter()===!1?!0:p.search?p.filtered.groups.has(a):!0);Hs(()=>u.group(a),[]),Wg(a,l,[n.value,n.heading,c]);let m=w.useMemo(()=>({id:a,forceMount:o}),[o]);return w.createElement(As.div,{ref:Sr(l,e),...i,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},t&&w.createElement("div",{ref:c,"cmdk-group-heading":"","aria-hidden":!0,id:d},t),Ba(n,p=>w.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":t?d:void 0},w.createElement(Fg.Provider,{value:m},p))))}),z5=w.forwardRef((n,e)=>{let{alwaysRender:t,...s}=n,o=w.useRef(null),i=_s(a=>!a.search);return!t&&!i?null:w.createElement(As.div,{ref:Sr(o,e),...s,"cmdk-separator":"",role:"separator"})}),F5=w.forwardRef((n,e)=>{let{onValueChange:t,...s}=n,o=n.value!=null,i=Yd(),a=_s(d=>d.search),l=_s(d=>d.selectedItemId),c=Gr();return w.useEffect(()=>{n.value!=null&&i.setState("search",n.value)},[n.value]),w.createElement(As.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)}})}),B5=w.forwardRef((n,e)=>{let{children:t,label:s="Suggestions",...o}=n,i=w.useRef(null),a=w.useRef(null),l=_s(d=>d.selectedItemId),c=Gr();return w.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)}}},[]),w.createElement(As.div,{ref:Sr(i,e),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":s,id:c.listId},Ba(n,d=>w.createElement("div",{ref:Sr(a,c.listInnerRef),"cmdk-list-sizer":""},d)))}),U5=w.forwardRef((n,e)=>{let{open:t,onOpenChange:s,overlayClassName:o,contentClassName:i,container:a,...l}=n;return w.createElement(o3,{open:t,onOpenChange:s},w.createElement(r3,{container:a},w.createElement(i3,{"cmdk-overlay":"",className:o}),w.createElement(a3,{"aria-label":n.label,"cmdk-dialog":"",className:i},w.createElement(Bg,{ref:e,...l}))))}),W5=w.forwardRef((n,e)=>_s(t=>t.filtered.count===0)?w.createElement(As.div,{ref:e,...n,"cmdk-empty":"",role:"presentation"}):null),H5=w.forwardRef((n,e)=>{let{progress:t,children:s,label:o="Loading...",...i}=n;return w.createElement(As.div,{ref:e,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Ba(n,a=>w.createElement("div",{"aria-hidden":!0},a)))}),zo=Object.assign(Bg,{List:B5,Item:O5,Input:F5,Group:D5,Separator:z5,Dialog:U5,Empty:W5,Loading:H5});function q5(n,e){let t=n.nextElementSibling;for(;t;){if(t.matches(e))return t;t=t.nextElementSibling}}function K5(n,e){let t=n.previousElementSibling;for(;t;){if(t.matches(e))return t;t=t.previousElementSibling}}function Ug(n){let e=w.useRef(n);return Hs(()=>{e.current=n}),e}var Hs=typeof window>"u"?w.useEffect:w.useLayoutEffect;function ao(n){let e=w.useRef();return e.current===void 0&&(e.current=n()),e}function _s(n){let e=Yd(),t=()=>n(e.snapshot());return w.useSyncExternalStore(e.subscribe,t,t)}function Wg(n,e,t,s=[]){let o=w.useRef(),i=Gr();return Hs(()=>{var a;let l=(()=>{var d;for(let u of t){if(typeof u=="string")return u.trim();if(typeof u=="object"&&"current"in u)return u.current?(d=u.current.textContent)==null?void 0:d.trim():o.current}})(),c=s.map(d=>d.trim());i.value(n,l,c),(a=e.current)==null||a.setAttribute(io,l),o.current=l}),o}var V5=()=>{let[n,e]=w.useState(),t=ao(()=>new Map);return Hs(()=>{t.current.forEach(s=>s()),t.current=new Map},[n]),(s,o)=>{t.current.set(s,o),e({})}};function G5(n){let e=n.type;return typeof e=="function"?e(n.props):"render"in e?e.render(n.props):n}function Ba({asChild:n,children:e},t){return n&&w.isValidElement(e)?w.cloneElement(G5(e),{ref:e.ref},t(e.props.children)):t(e)}var Y5={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function is(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($1,{"data-slot":"dialog",...t}),e[2]=t,e[3]=s):s=e[3],s}function X5(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(Sd,{"data-slot":"dialog-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function lB(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(Fr,{"data-slot":"dialog-close",...t}),e[2]=t,e[3]=s):s=e[3],s}function J5(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(Nd,{"data-slot":"dialog-overlay",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function as(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(J5,{}),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(Fr,{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(tt,{"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(X5,{children:[l,r.jsxs(jd,{"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 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("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 Hg(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 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("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(yd,{"data-slot":"dialog-title",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("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(wd,{"data-slot":"dialog-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Xd(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=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(zo,{"data-slot":"command",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function cB(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(ls,{children:c}),e[9]=c,e[10]=m):m=e[10];let p;e[11]!==d?(p=r.jsx(cs,{children:d}),e[11]=d,e[12]=p):p=e[12];let h;e[13]!==m||e[14]!==p?(h=r.jsxs(Rs,{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(as,{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(is,{...o,children:g}),e[21]=o,e[22]=g,e[23]=x):x=e[23],x}function Q5(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(Yt,{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(zo.Input,{"data-slot":"command-input",className:i,...s})]}),e[6]=s,e[7]=i,e[8]=a):a=e[8],a}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("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(zo.List,{"data-slot":"command-list",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Z5(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(zo.Empty,{"data-slot":"command-empty",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function aa(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(zo.Group,{"data-slot":"command-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function la(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(at,{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(zo.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 tS(n){return r.jsx(Pe,{variant:n.source==="built-in"?"secondary":"outline",children:n.source})}const nS=w.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=w.useRef(u);let m,p;if(t[1]!==a?(m=()=>{var P;const T=f.current.get(a);T&&((P=T.scrollIntoView)==null||P.call(T,{block:"nearest"}))},p=[a],t[1]=a,t[2]=m,t[3]=p):(m=t[2],p=t[3]),w.useEffect(m,p),i){let T;return t[4]===Symbol.for("react.memo_cache_sentinel")?(T=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(et,{className:"size-3.5 animate-spin text-muted-foreground"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading suggestions..."})]})}),t[4]=T):T=t[4],T}if(s.length===0){const T=o?`No commands or skills matching "${o}"`:"No commands or skills found";let P;return t[5]!==T?(P=r.jsx("div",{className:"motion-popover-in absolute bottom-full left-0 right-0 z-50 mx-auto mb-2 max-w-[var(--chat-width)]",children:r.jsx("div",{className:"rounded-lg border bg-popover p-3 text-popover-foreground shadow-sm",children:r.jsx("span",{className:"text-xs text-muted-foreground",children:T})})}),t[5]=T,t[6]=P):P=t[6],P}let h,g,x,v,y,b,j,S,k;if(t[7]!==d||t[8]!==c||t[9]!==l||t[10]!==a||t[11]!==s){const T=s.filter(oS),P=[{heading:"Commands",suggestions:T,offset:0},{heading:"Skills",suggestions:s.filter(rS),offset:T.length}];x="motion-popover-in absolute bottom-full left-0 right-0 z-50 mx-auto mb-2 max-w-[var(--chat-width)]",g=Xd,y="slash-suggestions",b=s[a]?`${s[a].type}-${s[a].name}`:void 0,t[21]!==c||t[22]!==s?(j=_=>{const A=s.findIndex(I=>`${I.type}-${I.name}`===_);A>=0&&c(A)},t[21]=c,t[22]=s,t[23]=j):j=t[23],S=!1,k="border shadow-sm",h=Jd,v=P.map(_=>_.suggestions.length>0&&r.jsx(aa,{heading:_.heading,children:_.suggestions.map((A,I)=>{const $=_.offset+I;return r.jsx(sS,{suggestion:A,index:$,isSelected:$===a,onSelect:l,onHover:c,onEdit:d,itemRefs:f},`${A.type}-${A.name}`)})},_.heading)),t[7]=d,t[8]=c,t[9]=l,t[10]=a,t[11]=s,t[12]=h,t[13]=g,t[14]=x,t[15]=v,t[16]=y,t[17]=b,t[18]=j,t[19]=S,t[20]=k}else h=t[12],g=t[13],x=t[14],v=t[15],y=t[16],b=t[17],j=t[18],S=t[19],k=t[20];let C;t[24]!==h||t[25]!==v?(C=r.jsx(h,{children:v}),t[24]=h,t[25]=v,t[26]=C):C=t[26];let N;t[27]!==g||t[28]!==C||t[29]!==y||t[30]!==b||t[31]!==j||t[32]!==S||t[33]!==k?(N=r.jsx(g,{id:y,value:b,onValueChange:j,shouldFilter:S,className:k,children:C}),t[27]=g,t[28]=C,t[29]=y,t[30]=b,t[31]=j,t[32]=S,t[33]=k,t[34]=N):N=t[34];let E;return t[35]!==x||t[36]!==N?(E=r.jsx("div",{className:x,children:N}),t[35]=x,t[36]=N,t[37]=E):E=t[37],E});function sS({suggestion:n,index:e,isSelected:t,onSelect:s,onHover:o,onEdit:i,itemRefs:a}){const l=w.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(la,{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(yo,{className:"size-4 text-muted-foreground"}):r.jsx(jr,{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]}),tS(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(ts,{"data-icon":"inline-start"})})]})}function oS(n){return n.type==="command"}function rS(n){return n.type==="skill"}function iS(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=w.useRef(c);let u,f;e[1]!==i?(u=()=>{var b,j;(j=(b=d.current.get(i))==null?void 0:b.scrollIntoView)==null||j.call(b,{block:"nearest"})},f=[i],e[1]=i,e[2]=u,e[3]=f):(u=e[2],f=e[3]),w.useEffect(u,f);const m=t[i];let p;e[4]!==t||e[5]!==l?(p=b=>{const j=t.indexOf(b);j>=0&&l(j)},e[4]=t,e[5]=l,e[6]=p):p=e[6];let h;e[7]!==o?(h=o&&r.jsx(et,{"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((b,j)=>r.jsxs(la,{ref:S=>{S?(S.id=`file-suggestion-${j}`,d.current.set(j,S)):d.current.delete(j)},value:b,onMouseEnter:()=>l(j),onSelect:()=>a(b),onMouseDown:aS,children:[r.jsx(O1,{"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:b}),j===i&&r.jsx("span",{className:"text-xs text-muted-foreground",children:"↵"})]},b)),e[11]=t,e[12]=o,e[13]=l,e[14]=a,e[15]=s,e[16]=i,e[17]=x):x=e[17];let v;e[18]!==g||e[19]!==x?(v=r.jsx(Jd,{className:"max-h-70",children:r.jsx(aa,{heading:g,children:x})}),e[18]=g,e[19]=x,e[20]=v):v=e[20];let y;return e[21]!==m||e[22]!==p||e[23]!==v?(y=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(Xd,{id:"file-suggestions",value:m,onValueChange:p,shouldFilter:!1,className:"border shadow-sm",children:v})}),e[21]=m,e[22]=p,e[23]=v,e[24]=y):y=e[24],y}function aS(n){return n.preventDefault()}const lS=rs("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 ut(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(lS({variant:o}),t),e[4]=t,e[5]=o,e[6]=i):i=e[6];let a;return e[7]!==s||e[8]!==i?(a=r.jsx("div",{"data-slot":"alert",role:"alert",className:i,...s}),e[7]=s,e[8]=i,e[9]=a):a=e[9],a}function Et(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=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 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("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 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("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 Fo(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(l3,{"data-slot":"dropdown-menu",...t}),e[2]=t,e[3]=s):s=e[3],s}function Bo(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(c3,{"data-slot":"dropdown-menu-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function Uo(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(D1,{"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(B1,{children:r.jsx(U1,{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 es(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(z1,{"data-slot":"dropdown-menu-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function qg(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(W1,{"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 Bt(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(F1,{"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 dB(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(u3,{"data-slot":"dropdown-menu-radio-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function uB(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(f3,{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(at,{})})}),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(d3,{"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 ca(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(vd,{"data-slot":"dropdown-menu-separator",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(p3,{"data-slot":"collapsible",...t}),e[2]=t,e[3]=s):s=e[3],s}function Rt(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(h3,{"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(m3,{"data-slot":"collapsible-content",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const cS={exit_only:"Exit plan mode",interactive:"Implement interactively",autopilot:"Implement with Autopilot",autopilot_fleet:"Implement with Fleet"};function qm(n){return cS[n]??n.replaceAll("_"," ")}function dS(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,v,y,b,j;if(e[0]!==d||e[1]!==a||e[2]!==s||e[3]!==i||e[4]!==l){const P=i===void 0?[]:i;p=l===void 0?!1:l;const _=a??P[0],A=P.filter(R=>R!==_);m=ut,v="mb-3 pr-44",e[15]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(Br,{}),b=r.jsx(Et,{children:"Plan ready for review"}),e[15]=y,e[16]=b):(y=e[15],b=e[16]);const I=s||"Approve the plan or ask the agent to revise it.";e[17]!==I?(j=r.jsx(ft,{children:I}),e[17]=I,e[18]=j):j=e[18],f=Ts,h="flex gap-2";let $;e[19]!==p?($=p&&r.jsx(et,{className:"animate-spin","data-icon":"inline-start"}),e[19]=p,e[20]=$):$=e[20],g=r.jsxs(ee,{size:"sm",disabled:p,onClick:()=>d(_),children:[$,p?"Sending...":_?qm(_):"Approve"]}),x=A.length>0&&r.jsxs(Fo,{children:[r.jsx(Bo,{render:r.jsx(ee,{type:"button",variant:"outline",size:"icon-sm","aria-label":"Other plan actions",disabled:p}),children:r.jsx(mt,{"data-icon":"icon"})}),r.jsx(Uo,{align:"end",children:r.jsx(es,{children:A.map(R=>r.jsx(Bt,{onClick:()=>d(R),children:qm(R)},R))})})]}),e[0]=d,e[1]=a,e[2]=s,e[3]=i,e[4]=l,e[5]=f,e[6]=m,e[7]=p,e[8]=h,e[9]=g,e[10]=x,e[11]=v,e[12]=y,e[13]=b,e[14]=j}else f=e[5],m=e[6],p=e[7],h=e[8],g=e[9],x=e[10],v=e[11],y=e[12],b=e[13],j=e[14];let S;e[21]!==u||e[22]!==p?(S=r.jsx(ee,{variant:"ghost",size:"sm",disabled:p,onClick:u,children:"Reject"}),e[21]=u,e[22]=p,e[23]=S):S=e[23];let k;e[24]!==f||e[25]!==S||e[26]!==h||e[27]!==g||e[28]!==x?(k=r.jsxs(f,{className:h,children:[g,x,S]}),e[24]=f,e[25]=S,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(Rt,{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;e[34]!==t?(E=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(uS)]}),e[34]=t,e[35]=E):E=e[35];let T;return e[36]!==m||e[37]!==k||e[38]!==C||e[39]!==N||e[40]!==E||e[41]!==v||e[42]!==y||e[43]!==b||e[44]!==j?(T=r.jsxs(m,{className:v,children:[y,b,j,k,C,N,E]}),e[36]=m,e[37]=k,e[38]=C,e[39]=N,e[40]=E,e[41]=v,e[42]=y,e[43]=b,e[44]=j,e[45]=T):T=e[45],T}function uS(n,e){return r.jsx(Pe,{variant:"outline",children:n.prompt},e)}const fS=["allow","allow_always","deny"];function Ii(n,e){return(n.availableDecisions??fS).includes(e)}function mS(n){switch(n){case"Bash":return{label:"Run command",icon:yo,tone:"cmd"};case"Edit":return{label:"Edit file",icon:Sc,tone:"write"};case"Write":return{label:"Write file",icon:Sc,tone:"write"};case"Read":return{label:"Read file",icon:js,tone:"read"};case"Glob":return{label:"File search",icon:Yt,tone:"search"};case"Grep":return{label:"Content search",icon:Yt,tone:"search"};case"WebFetch":return{label:"Fetch URL",icon:wo,tone:"net"};case"WebSearch":return{label:"Web search",icon:wo,tone:"net"};default:return{label:n,icon:_a,tone:"other"}}}function pS(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 y;const o=n[0],i=n.length,a=o?Ii(o,"allow"):!1,l=o?Ii(o,"allow_always"):!1,c=o?Ii(o,"deny"):!1,d=i>1&&n.every(b=>Ii(b,"allow")),u=w.useEffectEvent(b=>{if(!o)return;const j=b.target;if(j&&(j.tagName==="INPUT"||j.tagName==="TEXTAREA"||j.isContentEditable)||b.metaKey||b.ctrlKey||b.altKey)return;const S=b.key.toLowerCase();S==="a"&&b.shiftKey&&d?(b.preventDefault(),s("allow")):S==="a"&&a?(b.preventDefault(),t(o.requestId,"allow")):S==="s"&&l?(b.preventDefault(),t(o.requestId,"allow_always")):S==="d"&&c&&(b.preventDefault(),t(o.requestId,"deny"))});w.useEffect(()=>{const b=j=>u(j);return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[]);const f=o?mS(o.toolName):null,m=o?pS(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=(((y=o==null?void 0:o.suggestions)==null?void 0:y.length)??0)>0;if(!o||!f)return null;const g=f.icon,x=e.has(o.requestId),v=i>1;return r.jsx("div",{className:"motion-slide-down-in border-b border-warning/20 bg-warning/5",children:r.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[r.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r.jsx("div",{className:"flex size-7 items-center justify-center rounded-md bg-warning/10 text-warning",children:r.jsx(R1,{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}),v&&r.jsxs(Pe,{variant:"outline",className:"shrink-0 tabular-nums",children:["+",i-1," more"]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[c&&r.jsxs(ee,{variant:"ghost",size:"sm",className:"text-destructive",disabled:x,onClick:()=>t(o.requestId,"deny"),title:"Deny (D)",children:[r.jsx(tt,{"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(g3,{"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(at,{"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 gS=1568,xS=.85,Km=35e5;function bS(n,e){let{width:t,height:s}=n;const o=Math.min(1,gS/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?xS:void 0),u=d.split(",")[1];if(u.length>Km){let f=l?.7:.8;for(;u.length>Km&&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 vS(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]=w.useState(s),[a,l]=w.useState(!1),[c,d]=w.useState(!1),u=w.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]),w.useEffect(f,m);let p;e[4]!==t?(p=R=>{const M=Array.from(R).filter(jS);if(!t){M.length>0&&d(!0);return}d(!1);for(const O of M){const D=new FileReader;D.onload=()=>{if(!u.current){d(!0);return}const z=D.result,F=new Image;F.onload=()=>{if(!u.current){d(!0);return}const L=bS(F,O.type);i(H=>[...H,{id:crypto.randomUUID(),file:O,preview:L.dataUrl,data:L.base64,mediaType:L.mediaType}])},F.src=z},D.onerror=()=>{console.warn(`Failed to read image file: ${O.name}`)},D.readAsDataURL(O)}},e[4]=t,e[5]=p):p=e[5];const h=p;let g;e[6]===Symbol.for("react.memo_cache_sentinel")?(g=R=>{i(M=>M.filter((O,D)=>D!==R)),d(!1)},e[6]=g):g=e[6];const x=g;let v;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{i([]),d(!1)},e[7]=v):v=e[7];const y=v;let b;e[8]===Symbol.for("react.memo_cache_sentinel")?(b=()=>d(!1),e[8]=b):b=e[8];const j=b;let S;e[9]!==t?(S=R=>{R.preventDefault(),t&&l(!0)},e[9]=t,e[10]=S):S=e[10];const k=S;let C;e[11]===Symbol.for("react.memo_cache_sentinel")?(C=R=>{R.preventDefault(),R.currentTarget.contains(R.relatedTarget)||l(!1)},e[11]=C):C=e[11];const N=C;let E;e[12]!==h?(E=R=>{R.preventDefault(),l(!1),R.dataTransfer.files.length>0&&h(R.dataTransfer.files)},e[12]=h,e[13]=E):E=e[13];const T=E;let P;e[14]!==h?(P=R=>{var z;const M=(z=R.clipboardData)==null?void 0:z.items;if(!M)return;const O=Array.from(M).filter(wS);if(O.length===0)return;R.preventDefault();const D=O.map(yS).filter(Boolean);h(D)},e[14]=h,e[15]=P):P=e[15];const _=P,A=!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,I=!t&&o.length>0;let $;return e[16]!==k||e[17]!==T||e[18]!==_||e[19]!==o||e[20]!==a||e[21]!==A||e[22]!==I?($={images:o,isDragOver:a,imageError:A,hasUnsupportedAttachments:I,dismissImageError:j,removeImage:x,clearImages:y,handleDragOver:k,handleDragLeave:N,handleDrop:T,handlePaste:_},e[16]=k,e[17]=T,e[18]=_,e[19]=o,e[20]=a,e[21]=A,e[22]=I,e[23]=$):$=e[23],$}function yS(n){return n.getAsFile()}function wS(n){return n.type.startsWith("image/")}function jS(n){return n.type.startsWith("image/")}function SS(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(y3,{"data-slot":"tooltip-provider",delay:o,...t}),e[3]=o,e[4]=t,e[5]=i):i=e[5],i}function kt(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(SS,{children:r.jsx(v3,{"data-slot":"tooltip",...t})}),e[2]=t,e[3]=s):s=e[3],s}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(x3,{"data-slot":"tooltip-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function _t(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(b3,{"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(w3,{children:r.jsx(j3,{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",Ua=w.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}),Ml=w.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(Ct,{render:m,children:p}),t[9]=m,t[10]=p,t[11]=h):h=t[11];let g;t[12]!==o?(g=r.jsx(_t,{children:o}),t[12]=o,t[13]=g):g=t[13];let x;return t[14]!==h||t[15]!==g?(x=r.jsxs(kt,{children:[h,g]}),t[14]=h,t[15]=g,t[16]=x):x=t[16],x});function NS(n){return n<10?"critical":n<30?"warning":"healthy"}const kS={critical:"border-destructive/30 bg-destructive/10 text-destructive",warning:"border-warning/30 bg-warning/10 text-warning",healthy:"text-muted-foreground"},Kg=w.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,v,y,b,j,S,k;if(t[0]!==s||t[1]!==l||t[2]!==c||t[3]!==d){x=Symbol.for("react.early_return_sentinel");e:{const T=_g(s);if(!T){x=null;break e}const P=Math.max(0,100-T.percent),_=NS(P);if(d&&_==="healthy"){x=null;break e}const A=Math.max(0,T.compactAt-T.used);let I;t[17]!==P||t[18]!==A||t[19]!==l?(I=l?`${P.toFixed(0)}% · ${lt(A)}`:`${P.toFixed(0)}%`,t[17]=P,t[18]=A,t[19]=l,t[20]=I):I=t[20];const $=I,R=kS[_],M=l&&"gap-1";let O;t[21]!==R||t[22]!==M?(O=q("shrink-0 tabular-nums",R,M),t[21]=R,t[22]=M,t[23]=O):O=t[23];let D;t[24]!==$||t[25]!==O?(D=r.jsx(Pe,{variant:"outline",className:O,children:$}),t[24]=$,t[25]=O,t[26]=D):D=t[26];const z=D;if(!c){x=z;break e}f=kt,t[27]!==z?(g=r.jsx(Ct,{render:z}),t[27]=z,t[28]=g):g=t[28],u=_t,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]!==A?(F=lt(A),t[30]=A,t[31]=F):F=t[31];let L;t[32]!==P?(L=P.toFixed(1),t[32]=P,t[33]=L):L=t[33],t[34]!==F||t[35]!==L?(h=r.jsxs("div",{children:[F," remaining (",L,"%)"]}),t[34]=F,t[35]=L,t[36]=h):h=t[36],v="text-muted-foreground",y=lt(T.used),b=" / ",j=lt(T.limit),S=" tokens used (",k=T.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]=v,t[12]=y,t[13]=b,t[14]=j,t[15]=S,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],v=t[11],y=t[12],b=t[13],j=t[14],S=t[15],k=t[16];if(x!==Symbol.for("react.early_return_sentinel"))return x;let C;t[37]!==v||t[38]!==y||t[39]!==b||t[40]!==j||t[41]!==S||t[42]!==k?(C=r.jsxs("div",{className:v,children:[y,b,j,S,k,"%)"]}),t[37]=v,t[38]=y,t[39]=b,t[40]=j,t[41]=S,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 E;return t[50]!==f||t[51]!==g||t[52]!==N?(E=r.jsxs(f,{children:[g,N]}),t[50]=f,t[51]=g,t[52]=N,t[53]=E):E=t[53],E});function CS(n){const e=B.c(7),{isPlanApproval:t,isUserQuestion:s,elapsedSec:o}=n,{isLive:i}=ot(),{chat:a}=Vr(),{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:E4(o)}),r.jsx(Ua,{})]}),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 _S(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}=ot(),{handleStopSession:d}=c,{chat:u}=Vr(),{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)??It((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=B4(g),e[3]=g,e[4]=x):x=e[4];const v=x;let y;e[5]!==v||e[6]!==m||e[7]!==p?(y=p&&r.jsxs(kt,{children:[r.jsx(Ct,{render:r.jsx(ee,{variant:"outline",size:"icon-sm",className:"motion-enter shrink-0 rounded-full text-warning",onClick:m,"aria-label":v,title:v}),children:r.jsx(Cd,{"data-icon":"inline-start",className:"fill-current"})}),r.jsxs(_t,{children:[v," (Esc)"]})]}),e[5]=v,e[6]=m,e[7]=p,e[8]=y):y=e[8];let b;e[9]!==g||e[10]!==d||e[11]!==p?(b=p&&Ht(g).stopSession&&r.jsxs(kt,{children:[r.jsx(Ct,{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(S3,{"data-icon":"inline-start"})}),r.jsx(_t,{children:"Stop session"})]}),e[9]=g,e[10]=d,e[11]=p,e[12]=b):b=e[12];const j=t?"default":"secondary",S=!t&&"text-muted-foreground";let k;e[13]!==S?(k=q("shrink-0 rounded-full",S),e[13]=S,e[14]=k):k=e[14];const C=!t;let N;e[15]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(N3,{"data-icon":"inline-start"}),e[15]=N):N=e[15];let E;e[16]!==s||e[17]!==i||e[18]!==k||e[19]!==C||e[20]!==j?(E=r.jsx(ee,{variant:j,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]=j,e[21]=E):E=e[21];let T;return e[22]!==E||e[23]!==y||e[24]!==b?(T=r.jsxs("div",{className:"flex items-center gap-1",children:[y,b,E]}),e[22]=E,e[23]=y,e[24]=b,e[25]=T):T=e[25],T}function Vm(n){const e=B.c(34),{error:t}=n,[s,o]=w.useState(!1),[i,a]=w.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(Xt,{"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 v;e[13]!==g||e[14]!==x?(v=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]=v):v=e[15];let y;e[16]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsxs(Rs,{children:[r.jsxs(ls,{className:"flex items-center gap-2 text-destructive",children:[r.jsx(Xt,{className:"size-4"}),"Error details"]}),r.jsx(cs,{children:"The full output from the failed request, including the underlying process stderr."})]}),e[16]=y):y=e[16];let b;e[17]!==t?(b=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]=b):b=e[18];let j;e[19]!==i?(j=i?r.jsx(at,{"data-icon":"inline-start"}):r.jsx(pn,{"data-icon":"inline-start"}),e[19]=i,e[20]=j):j=e[20];const S=i?"Copied":"Copy";let k;e[21]!==m||e[22]!==j||e[23]!==S?(k=r.jsx("div",{className:"flex justify-end",children:r.jsxs(ee,{type:"button",variant:"outline",size:"sm",onClick:m,children:[j,S]})}),e[21]=m,e[22]=j,e[23]=S,e[24]=k):k=e[24];let C;e[25]!==b||e[26]!==k?(C=r.jsxs(as,{className:"max-w-2xl",children:[y,b,k]}),e[25]=b,e[26]=k,e[27]=C):C=e[27];let N;e[28]!==s||e[29]!==C?(N=r.jsx(is,{open:s,onOpenChange:o,children:C}),e[28]=s,e[29]=C,e[30]=N):N=e[30];let E;return e[31]!==N||e[32]!==v?(E=r.jsxs(r.Fragment,{children:[v,N]}),e[31]=N,e[32]=v,e[33]=E):E=e[33],E}function TS(n){const e=B.c(17),{suggestion:t,onAccept:s}=n,[o,i]=w.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(jr,{"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(tt,{}),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 ES(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 AS(n,e,t){return`${n.slice(0,e.start)}@${t} `}const Wa={terminal:!0,configWrite:!0,hostFiles:!0,manageUsers:!0,manageWorkspaces:!0,manageDevices:!0,killAny:!0,viewAllSessions:!0,viewUsage:!0,share:!0,runFlows:!0},Yr={terminal:!1,configWrite:!1,hostFiles:!1,manageUsers:!1,manageWorkspaces:!1,manageDevices:!1,killAny:!1,viewAllSessions:!1,viewUsage:!1,share:!1,runFlows:!1};let Vg=Wa;const Bc=new Set;function po(n){Vg=(n==null?void 0:n.capabilities)??Wa;for(const e of Bc)e()}function st(n){return Vg[n]}function PS(n){return Bc.add(n),()=>Bc.delete(n)}function Tn(n){const e=B.c(3);let t,s;return e[0]!==n?(t=()=>st(n),s=()=>st(n),e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]),w.useSyncExternalStore(PS,t,s)}function IS(n){const e=n.files;return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function RS(n,e,t){const s=Tn("hostFiles"),[o,i]=w.useState([]),[a,l]=w.useState(!1);return w.useEffect(()=>{if(!s||!t||!n){i([]),l(!1);return}const c=new AbortController,d=window.setTimeout(async()=>{l(!0);try{const u=await Ne(`/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(IS(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 Uc="cogpit-share-revoked";function $S(){window.dispatchEvent(new Event(Uc))}async function Gg(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&&$S(),s}function Xr(n,e){return Gg(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e??{})})}async function MS(){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 LS(n,e){return Xr("/api/share/send-message",e!=null&&e.length?{message:n,images:e}:{message:n})}function OS(){return Xr("/api/share/interrupt")}function DS(){return Xr("/api/share/stop")}async function zS(n,e){return(await Xr("/api/share/permission",{requestId:n,behavior:e})).ok}async function FS(n,e){try{const t=await Xr("/api/share/answer",{toolUseId:n,answers:e});return{ok:t.ok,gone:t.status===404}}catch{return{ok:!1,gone:!1}}}async function BS(){try{const n=await Gg("/api/share/pending");if(!n.ok)return null;const e=await n.json();return Array.isArray(e.permissions)?e.permissions:[]}catch{return null}}const US=/^\/shared\/([^/]+)\/?$/;function Yg(n){const e=US.exec(n);if(!e)return null;try{return decodeURIComponent(e[1])||null}catch{return null}}function Ha(n){return Yg(n)!==null}function WS(n){return`/shared/${encodeURIComponent(n)}`}function fB(n){return[...n].join(", ")}async function Qd(n,e){try{const t=await Kn(n,e);return{ok:t.ok,gone:t.status===404}}catch{return{ok:!1,gone:!1}}}function Zd(n,e,t){return Ha(window.location.pathname)?FS(e,t):Qd("/api/ask-user-answer",{sessionId:n,toolUseId:e,answers:t})}async function HS(n,e,t){try{return(await Kn(`/api/permissions/${encodeURIComponent(n)}/plan`,{requestId:e,...t})).ok}catch{return!1}}function qa(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 Ri(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 qS(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 KS(n,e,t){return t?"border-warning/40 focus-within:border-warning/60 focus-within:ring-warning/15":n||e?"border-info/40 focus-within:border-info/60 focus-within:ring-info/15":"border-input focus-within:border-ring focus-within:ring-ring/20"}function VS(n,e,t){return n?"px-4 pb-1.5 pt-3.5":e?q("col-span-2 row-start-1",t?"py-2.5 pr-3 pl-2":"py-3 pr-4 pl-4"):q("col-start-2 row-start-1",t?"py-2 pr-1 pl-2":"py-2.5 pr-2 pl-4")}function GS(n,e){return n?"gap-1 px-2 pb-2 pt-0.5":e?"col-start-2 row-start-2 px-1.5 pb-1.5":"col-start-3 row-start-1 pr-1.5 pb-1.5"}const Wc=w.memo(w.forwardRef(function({allowImages:e=!0,agentKind:t,projectCwd:s,leadingAccessory:o,footer:i,compact:a=!1},l){var ze;const c=Tn("hostFiles"),{session:d,isLive:u,actions:{handleEditConfig:f},pendingInteraction:m,permissionRequests:p,permissionResponding:h,respondPermission:g,respondAllPermissions:x,slashSuggestions:v,slashSuggestionsLoading:y,turnError:b,promptSuggestion:j}=ot(),{chat:{status:S,error:k,isConnected:C,sendMessage:N,interrupt:E}}=Vr(),T=C||u,[P,_]=w.useState(""),[A,I]=w.useState(!1),[$,R]=w.useState(!1),[M,O]=w.useState(null),D=w.useRef(null),z=w.useRef(null),F=w.useRef(!1),L=w.useRef(""),H=w.useRef(null);w.useEffect(()=>{L.current=P},[P]);const U=w.useCallback(fe=>{F.current=fe,I(fe)},[]),{images:W,isDragOver:V,imageError:K,hasUnsupportedAttachments:Y,dismissImageError:X,removeImage:G,clearImages:J,handleDragOver:Z,handleDragLeave:Q,handleDrop:te,handlePaste:ne}=vS(e),[oe,re]=w.useState(0),[ie,se]=w.useState(0),[ce,ae]=w.useState(!1),ue=P.startsWith("/")&&!P.includes(" "),me=ue?P.slice(1):"",de=w.useMemo(()=>{if(!ue)return[];const fe=me.toLowerCase(),we=v.filter(Ae=>fe?Ae.name.toLowerCase().includes(fe)||Ae.description.toLowerCase().includes(fe):!0),Ue=we.filter(Ae=>Ae.type==="command"),Be=we.filter(Ae=>Ae.type==="skill");return[...Ue,...Be]},[ue,me,v]),le=w.useMemo(()=>ES(P),[P]),xe=!!(c&&le&&s&&!ce),pe=RS(s,(le==null?void 0:le.query)??"",xe);w.useEffect(()=>{re(0)},[me]),w.useEffect(()=>{se(0)},[le==null?void 0:le.query]);const ve=Rg(C),Te=(m==null?void 0:m.type)==="plan"?m.requestId??null:null;w.useEffect(()=>{z.current=Te,D.current=null,R(!1),O(null)},[Te]);const $e=w.useCallback(async fe=>{const we=m;if(!(d!=null&&d.sessionId)||(we==null?void 0:we.type)!=="question")return;const Ue=we.questions[0];if(!Ue||!fe.trim())return;(await Zd(d.sessionId,we.toolUseId,{[Ue.question]:fe})).ok||N(fe)},[m,d==null?void 0:d.sessionId,N]),_e=w.useCallback(async(fe,we,Ue)=>{const Be=m;if((Be==null?void 0:Be.type)==="plan"&&Be.provider==="copilot"&&Be.requestId&&(d!=null&&d.sessionId)){const Ae=Be.requestId;if(D.current)return!1;D.current=Ae,R(!0),O(null);try{const qe=await HS(d.sessionId,Ae,{approved:fe,...we?{selectedAction:we}:{},...Ue?{feedback:Ue}:{}});return!qe&&z.current===Ae&&O("Couldn't send the plan response. Try again."),qe}finally{D.current===Ae&&(D.current=null,R(!1))}}return N(fe?"yes":Ue||"no"),!0},[m,d==null?void 0:d.sessionId,N]),Ce=w.useCallback(()=>{requestAnimationFrame(()=>{const fe=H.current;fe&&(fe.focus(),fe.selectionStart=fe.selectionEnd=fe.value.length,U(Ri(fe,F.current)))})},[U]),ke=w.useCallback(fe=>{_(`/${fe.name} `),re(0),Ce()},[Ce]),Me=w.useCallback(fe=>{_(fe),Ce()},[Ce]),Oe=w.useCallback(fe=>{if(!le)return;const we=AS(P,le,fe);_(we),ae(!0),se(0),requestAnimationFrame(()=>{const Ue=H.current;Ue&&(Ue.focus(),Ue.selectionStart=Ue.selectionEnd=Ue.value.length,U(Ri(Ue,F.current)))})},[le,P,U]),Le=w.useCallback(async()=>{const fe=P.trim();if(!fe&&W.length===0||!e&&W.length>0)return;if((m==null?void 0:m.type)==="question"){$e(fe),_(""),U(!1),H.current&&(H.current.style.height="auto");return}if((m==null?void 0:m.type)==="plan"&&m.provider==="copilot"){if(!fe||!await _e(!1,void 0,fe))return;_(""),U(!1),H.current&&(H.current.style.height="auto");return}const we=e&&W.length>0?W.map(Ue=>({data:Ue.data,mediaType:Ue.mediaType})):void 0;N(fe,we),_(""),J(),U(!1),H.current&&(H.current.style.height="auto")},[P,W,e,N,J,U,m,$e,_e]),De=w.useCallback(fe=>{if(xe&&fe.key==="Escape"){fe.preventDefault(),ae(!0);return}if(xe&&pe.files.length>0){if(fe.key==="ArrowDown"){fe.preventDefault(),se(we=>we<pe.files.length-1?we+1:0);return}if(fe.key==="ArrowUp"){fe.preventDefault(),se(we=>we>0?we-1:pe.files.length-1);return}if(fe.key==="Tab"||fe.key==="Enter"&&!fe.shiftKey){fe.preventDefault();const we=pe.files[ie];we&&Oe(we);return}}if(ue&&de.length>0){if(fe.key==="ArrowDown"){fe.preventDefault(),re(we=>we<de.length-1?we+1:0);return}if(fe.key==="ArrowUp"){fe.preventDefault(),re(we=>we>0?we-1:de.length-1);return}if(fe.key==="Tab"||fe.key==="Enter"&&!fe.shiftKey){fe.preventDefault();const we=de[oe];we&&ke(we);return}if(fe.key==="Escape"){fe.preventDefault(),_("");return}}if(fe.key==="Escape"&&T&&E){fe.preventDefault(),E();return}fe.key==="Enter"&&!fe.shiftKey&&(fe.preventDefault(),Le())},[Le,T,E,xe,pe.files,ie,Oe,ue,de,oe,ke]),Ie=w.useCallback(fe=>{_(fe.target.value),ae(!1),U(Ri(fe.target,F.current))},[U]);w.useImperativeHandle(l,()=>({focus:()=>{var fe;return(fe=H.current)==null?void 0:fe.focus()},getText:()=>L.current,setText:fe=>{_(fe),ae(!1),requestAnimationFrame(()=>U(Ri(H.current,F.current)))}}),[U]);const he=(m==null?void 0:m.type)==="plan",ge=(m==null?void 0:m.type)==="question",Se=p.length>0,be=!!i,Fe=(P.trim().length>0||W.length>0)&&!Y,He=Ht(t??Gs).midTurnSteering&&T,We=xe?"file-suggestions":ue?"slash-suggestions":void 0,Ee=xe&&pe.files[ie]?`file-suggestion-${ie}`:ue&&de[oe]?`slash-suggestion-${oe}`:void 0;return r.jsxs("div",{className:q("relative pb-0",a?"px-2 pt-2":"px-3 pt-2",V&&"ring-2 ring-info/40 ring-inset"),onDragOver:Z,onDragLeave:Q,onDrop:te,children:[V&&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"})}),ue&&r.jsx(nS,{suggestions:de,filter:me,loading:y,selectedIndex:oe,onSelect:ke,onHover:re,onEdit:f}),xe&&r.jsx(iS,{files:pe.files,query:(le==null?void 0:le.query)??"",loading:pe.loading,selectedIndex:ie,onSelect:Oe,onHover:se}),r.jsxs("div",{children:[he&&r.jsx(dS,{allowedPrompts:m.allowedPrompts,summary:m.summary,planContent:m.planContent,actions:m.actions,recommendedAction:m.recommendedAction,responding:$,responseError:M,onApprove:fe=>{_e(!0,fe)},onReject:()=>{_e(!1)}}),r.jsx(TS,{suggestion:j,onAccept:Me}),W.length>0&&r.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:W.map((fe,we)=>r.jsxs("div",{className:"motion-list-item relative group/thumb",children:[r.jsx("img",{src:fe.preview,alt:`Upload ${we+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(we),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 ${we+1}`,children:r.jsx(tt,{className:"size-3","data-icon":"icon"})})]},fe.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}),!Y&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:X,className:"text-muted-foreground","aria-label":"Dismiss image notice",children:r.jsx(tt,{"data-icon":"icon"})})]}),r.jsxs("div",{className:q("relative overflow-hidden border bg-composer-surface/85 shadow-lg shadow-black/5 backdrop-blur-xl transition-[border-color,box-shadow] duration-150",be?"rounded-3xl":"rounded-xl",KS(he,ge,Se),"focus-within:ring-3"),children:[Se&&r.jsx(hS,{requests:p,responding:h,onRespond:g,onRespondAll:x},(ze=p[0])==null?void 0:ze.requestId),r.jsxs("div",{className:q("min-w-0",be?"flex flex-col":"grid items-end",!be&&(A?"grid-cols-[1fr_auto]":"grid-cols-[auto_minmax(0,1fr)_auto]")),children:[o&&r.jsx("div",{className:q("flex shrink-0 items-center",A?"col-start-1 row-start-2 pl-0.5 pb-0.5":"col-start-1 row-start-1"),children:o}),r.jsx(qa,{ref:H,value:P,onChange:Ie,onKeyDown:De,onPaste:ne,onFocus:()=>{setTimeout(()=>{var fe;return(fe=H.current)==null?void 0:fe.scrollIntoView({behavior:"smooth",block:"center"})},300)},placeholder:qS(he,ge,C,Se,He,a),"aria-label":"Message",role:"combobox","aria-autocomplete":"list","aria-expanded":!!We,"aria-controls":We,"aria-activedescendant":Ee,rows:1,className:q("min-h-0 w-full resize-none rounded-none border-0 bg-transparent text-sm text-foreground shadow-none placeholder:text-muted-foreground focus-visible:border-transparent focus-visible:ring-0 dark:bg-transparent",VS(be,A,a))}),r.jsxs("div",{className:q("flex shrink-0 items-center justify-end",GS(be,A)),children:[i,r.jsx(CS,{isPlanApproval:he,isUserQuestion:ge,elapsedSec:ve}),r.jsx(_S,{hasContent:Fe,onSubmit:Le,submitLabel:He?"Steer active turn":"Send message"})]})]})]}),S==="error"&&k&&r.jsx(Vm,{error:k},k),b&&r.jsx(Vm,{error:b},b)]})]})}));function YS(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function XS(n){return YS(n)?n:null}function JS(n){for(let e=n.length-1;e>=0;e-=1){const t=n[e];if(t.type!=="attachment")continue;const s=XS(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 $i(n){return`/api/codex/goals/${encodeURIComponent(n)}`}function Mt(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=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(k3,{"data-slot":"input",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Jr(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(QS,{children:r.jsx(ZS,{})}),e[7]=l):l=e[7];let c;return e[8]!==t||e[9]!==o||e[10]!==a||e[11]!==i?(c=r.jsxs(C3,{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 QS(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(_3,{className:o,"data-slot":"progress-track",...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function ZS(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(T3,{"data-slot":"progress-indicator",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("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(E3,{className:o,"data-slot":"progress-label",...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}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("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(A3,{className:o,"data-slot":"progress-value",...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const eN={section:null,canCreate:!1,beginEditing:()=>{}},eu=w.createContext(eN);function Qg(){return w.useContext(eu)}const Zg="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-1",ex="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-2";function tN(n){return n==="usageLimited"?"Usage limited":n==="budgetLimited"?"Budget limited":n.charAt(0).toUpperCase()+n.slice(1)}function nN(n){return n==="complete"?"secondary":n==="blocked"||n.endsWith("Limited")?"destructive":n==="paused"?"outline":"default"}function sN({agentKind:n,threadId:e,children:t}){const s=Fa(n),[o,i]=w.useState(null),[a,l]=w.useState(!0),[c,d]=w.useState(!1),[u,f]=w.useState(""),[m,p]=w.useState(""),[h,g]=w.useState(!1),[x,v]=w.useState(null),y=w.useCallback(async T=>{try{const P=await Ne($i(e),{signal:T});if(P.status===404||P.status===501){l(!1);return}if(!P.ok)return;const _=await P.json();i(_.goal),l(!0)}catch{}},[e]);w.useEffect(()=>{const T=new AbortController;y(T.signal);const P=a?setInterval(()=>void y(),1e4):void 0;return()=>{T.abort(),P!==void 0&&clearInterval(P)}},[y,a]);const b=w.useCallback(()=>{var T;f((o==null?void 0:o.objective)??""),p(((T=o==null?void 0:o.tokenBudget)==null?void 0:T.toString())??""),v(null),d(!0)},[o]),j=async()=>{const T=u.trim();if(!T)return;const P=m.trim()?Number(m):null;if(P!==null&&(!Number.isSafeInteger(P)||P<=0)){v("Token budget must be a positive whole number");return}g(!0),v(null);try{const _=await Ne($i(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({objective:T,status:(o==null?void 0:o.status)==="complete"?"active":(o==null?void 0:o.status)??"active",tokenBudget:P})}),A=await _.json();if(!_.ok)throw new Error(A.error||"Could not save goal");i(A.goal),d(!1)}catch(_){v(_ instanceof Error?_.message:"Could not save goal")}finally{g(!1)}},S=async T=>{if(o){g(!0);try{const P=await Ne($i(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:T})});P.ok&&i((await P.json()).goal)}finally{g(!1)}}},k=async()=>{g(!0);try{(await Ne($i(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:ex,onSubmit:T=>{T.preventDefault(),j()},children:[r.jsxs("div",{className:"mb-2 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[r.jsx(jo,{className:"size-3.5","data-icon":"inline-start"}),o?"Edit long-running goal":"Set a long-running goal"]}),r.jsxs(Do,{className:"gap-2",children:[r.jsxs(yt,{children:[r.jsx(wt,{className:"sr-only",htmlFor:"goal-objective",children:"Goal objective"}),r.jsx(qa,{id:"goal-objective",value:u,onChange:T=>f(T.target.value),placeholder:`What should ${s} keep working toward?`,rows:2,autoFocus:!0})]}),r.jsxs(yt,{orientation:"horizontal","data-invalid":!!x,children:[r.jsx(wt,{className:"text-xs text-muted-foreground",htmlFor:"goal-budget",children:"Token budget"}),r.jsx(Mt,{id:"goal-budget",type:"number",min:1,step:1,value:m,onChange:T=>p(T.target.value),placeholder:"Optional",className:"ml-auto h-8 w-28","aria-invalid":!!x})]})]}),r.jsx(vs,{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(tt,{"data-icon":"inline-start"}),"Cancel"]}),r.jsxs(ee,{type:"submit",size:"xs",disabled:h||!u.trim(),children:[r.jsx(at,{"data-icon":"inline-start"}),"Save goal"]})]})]});else if(a&&o){const T=o.status==="paused",P=o.status==="complete";N=r.jsxs("section",{className:Zg,"aria-label":`${s} goal`,children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(jo,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",title:o.objective,children:o.objective}),r.jsx(Pe,{variant:nN(o.status),children:tN(o.status)}),r.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[lt(o.tokensUsed),o.tokenBudget?` / ${lt(o.tokenBudget)}`:""," · ",Math.max(0,Math.round(o.timeUsedSeconds/60)),"m"]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[T&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void S("active"),disabled:h,"aria-label":"Resume goal",children:r.jsx($o,{"data-icon":"icon"})}),!T&&!P&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void S("paused"),disabled:h,"aria-label":"Pause goal",children:r.jsx(P3,{"data-icon":"icon"})}),!P&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void S("complete"),disabled:h,"aria-label":"Mark goal complete",children:r.jsx(at,{"data-icon":"icon"})}),r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:b,"aria-label":"Edit goal",children:r.jsx(ts,{"data-icon":"icon"})}),r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void k(),disabled:h,className:"text-destructive","aria-label":"Clear goal",children:r.jsx(Ta,{"data-icon":"icon"})})]})]}),C!==null&&r.jsx(Jr,{className:"mt-1 mb-0.5",value:C,"aria-label":`${C.toFixed(0)}% of goal token budget used`})]})}const E=w.useMemo(()=>({section:N,canCreate:a&&!o&&!c,beginEditing:b}),[N,a,o,c,b]);return r.jsx(eu.Provider,{value:E,children:t})}function oN(n){switch(n){case"active":return"Goal active";case"achieved":return"Achieved";default:return"Needs attention"}}function rN(n){switch(n){case"failed":return"destructive";case"achieved":return"secondary";default:return"outline"}}function iN(n){const e=B.c(84),{agentKind:t,session:s,onSendCommand:o,children:i}=n;let a;e[0]!==t?(a=Fa(t),e[0]=t,e[1]=a):a=e[1];const l=a;let c;e[2]!==s.rawMessages?(c=JS(s.rawMessages),e[2]=s.rawMessages,e[3]=c):c=e[3];const d=c,[u,f]=w.useState(),[m,p]=w.useState(!1),[h,g]=w.useState(""),[x,v]=w.useState(null),y=d?`${d.status}\0${d.condition}`:"",[b,j]=w.useState(y);b!==y&&(j(y),f(void 0));const S=u!==void 0?u:d;let k;e[4]!==(S==null?void 0:S.condition)?(k=()=>{g((S==null?void 0:S.condition)??""),v(null),p(!0)},e[4]=S==null?void 0:S.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){v("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 E=N;let T;e[9]!==o?(T=()=>{f(null),p(!1),o("/goal clear")},e[9]=o,e[10]=T):T=e[10];const P=T;let _;if(e[11]!==l||e[12]!==C||e[13]!==P||e[14]!==h||e[15]!==m||e[16]!==x||e[17]!==S||e[18]!==E){if(_=null,m){let M;e[20]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(jo,{className:"size-3.5","data-icon":"inline-start"}),e[20]=M):M=e[20];const O=S?"Replace goal":"Set a long-running goal";let D;e[21]!==O?(D=r.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[M,O]}),e[21]=O,e[22]=D):D=e[22];const z=!!x;let F;e[23]===Symbol.for("react.memo_cache_sentinel")?(F=r.jsx(wt,{className:"sr-only",htmlFor:"goal-condition",children:"Goal condition"}),e[23]=F):F=e[23];let L;e[24]===Symbol.for("react.memo_cache_sentinel")?(L=Q=>g(Q.target.value),e[24]=L):L=e[24];const H=`A measurable condition ${l} should keep working toward…`,U=!!x;let W;e[25]!==h||e[26]!==H||e[27]!==U?(W=r.jsx(qa,{id:"goal-condition",value:h,onChange:L,placeholder:H,rows:2,maxLength:4e3,"aria-invalid":U,autoFocus:!0}),e[25]=h,e[26]=H,e[27]=U,e[28]=W):W=e[28];let V;e[29]!==x?(V=r.jsx(vs,{children:x}),e[29]=x,e[30]=V):V=e[30];let K;e[31]!==W||e[32]!==V||e[33]!==z?(K=r.jsxs(yt,{"data-invalid":z,children:[F,W,V]}),e[31]=W,e[32]=V,e[33]=z,e[34]=K):K=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(tt,{"data-icon":"inline-start"}),"Cancel"]}),e[35]=Y):Y=e[35];let X;e[36]!==h?(X=h.trim(),e[36]=h,e[37]=X):X=e[37];const G=!X;let J;e[38]===Symbol.for("react.memo_cache_sentinel")?(J=r.jsx(at,{"data-icon":"inline-start"}),e[38]=J):J=e[38];let Z;e[39]!==E||e[40]!==G?(Z=r.jsxs("div",{className:"mt-2 flex items-center justify-end gap-1",children:[Y,r.jsxs(ee,{type:"button",size:"xs",onClick:E,disabled:G,children:[J,"Start goal"]})]}),e[39]=E,e[40]=G,e[41]=Z):Z=e[41],_=r.jsxs("section",{className:ex,"aria-label":`${l} goal editor`,children:[D,K,Z]})}else if(S){let M;e[42]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(jo,{className:"size-3.5 shrink-0 text-primary","data-icon":"inline-start"}),e[42]=M):M=e[42];let O;e[43]!==S.condition?(O=r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",title:S.condition,children:S.condition}),e[43]=S.condition,e[44]=O):O=e[44];let D;e[45]!==S.status?(D=rN(S.status),e[45]=S.status,e[46]=D):D=e[46];let z;e[47]!==S.status?(z=oN(S.status),e[47]=S.status,e[48]=z):z=e[48];let F;e[49]!==D||e[50]!==z?(F=r.jsx(Pe,{variant:D,children:z}),e[49]=D,e[50]=z,e[51]=F):F=e[51];const L=S.iterations,H=S.iterations===1?"":"s";let U;e[52]!==S.tokens?(U=lt(S.tokens),e[52]=S.tokens,e[53]=U):U=e[53];let W;e[54]!==S.durationMs?(W=Math.round(S.durationMs/6e4),e[54]=S.durationMs,e[55]=W):W=e[55];const V=Math.max(0,W);let K;e[56]!==S.iterations||e[57]!==H||e[58]!==U||e[59]!==V?(K=r.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[L," turn",H," · ",U," · ",V,"m"]}),e[56]=S.iterations,e[57]=H,e[58]=U,e[59]=V,e[60]=K):K=e[60];let Y;e[61]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx(ts,{"data-icon":"icon"}),e[61]=Y):Y=e[61];let X;e[62]!==C?(X=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:C,"aria-label":"Replace goal",children:Y}),e[62]=C,e[63]=X):X=e[63];let G;e[64]===Symbol.for("react.memo_cache_sentinel")?(G=r.jsx(Ta,{"data-icon":"icon"}),e[64]=G):G=e[64];let J;e[65]!==P?(J=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:P,"aria-label":"Clear goal",children:G}),e[65]=P,e[66]=J):J=e[66];let Z;e[67]!==X||e[68]!==J?(Z=r.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[X,J]}),e[67]=X,e[68]=J,e[69]=Z):Z=e[69];let Q;e[70]!==F||e[71]!==K||e[72]!==Z||e[73]!==O?(Q=r.jsxs("div",{className:"flex items-center gap-2",children:[M,O,F,K,Z]}),e[70]=F,e[71]=K,e[72]=Z,e[73]=O,e[74]=Q):Q=e[74];let te;e[75]!==S.reason?(te=S.reason&&r.jsx("p",{className:"line-clamp-2 pb-0.5 pl-5 text-xs text-muted-foreground",children:S.reason}),e[75]=S.reason,e[76]=te):te=e[76],_=r.jsxs("section",{className:Zg,"aria-label":`${l} goal`,children:[Q,te]})}e[11]=l,e[12]=C,e[13]=P,e[14]=h,e[15]=m,e[16]=x,e[17]=S,e[18]=E,e[19]=_}else _=e[19];const A=!S&&!m;let I;e[77]!==C||e[78]!==_||e[79]!==A?(I={section:_,canCreate:A,beginEditing:C},e[77]=C,e[78]=_,e[79]=A,e[80]=I):I=e[80];const $=I;let R;return e[81]!==i||e[82]!==$?(R=r.jsx(eu.Provider,{value:$,children:i}),e[81]=i,e[82]=$,e[83]=R):R=e[83],R}function aN(n){const e=B.c(9),{agentKind:t,session:s,onSendCommand:o,children:i}=n,a=Ht(t).goals;if(a==="thread-api"){let l;return e[0]!==t||e[1]!==i||e[2]!==s.sessionId?(l=r.jsx(sN,{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(iN,{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 tx(){return Qg().section}function nx(){const n=B.c(3),{canCreate:e,beginEditing:t}=Qg();if(!e)return null;let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(jo,{"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 lN(){const n=B.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs(r.Fragment,{children:[r.jsx(tx,{}),r.jsx(nx,{})]}),n[0]=e):e=n[0],e}const cN=/\x1b\].*?(?:\x07|\x1b\\)/g,dN=/\x1b\[[0-9;]*[A-Za-z]/g,uN=/\x1b[()][AB012]/g,fN=/\[2K\[1G/g;function sx(n){return n.replace(cN,"").replace(dN,"").replace(uN,"").replace(fN,`
5
+ `).replace(/\r/g,"")}function Vn(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(R3,{"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(mN,{}),c=r.jsx($3,{}),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(I3,{"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 mN(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(L3,{"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(M3,{"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 ox(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 pN(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 hN(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 gN(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 nt(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=ox,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 xN(n){const e=Tn("hostFiles"),[t,s]=w.useState([]),[o,i]=w.useState(!1),a=w.useCallback(async()=>{if(!e||!n){s([]);return}i(!0);try{const l=await Ne(`/api/scripts?dir=${encodeURIComponent(n)}`);if(l.ok){const c=await l.json();s(c)}}catch{}finally{i(!1)}},[e,n]);return w.useEffect(()=>{a()},[a]),{scripts:t,loading:o,refresh:a}}const Gm=500,bN=5e3;function vN(n){const e=B.c(29),t=n===void 0?!0:n,[s,o]=w.useState("disconnected");let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=[],e[0]=i):i=e[0];const[a,l]=w.useState(i),c=w.useRef(null);let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=new Map,e[1]=d):d=e[1];const u=w.useRef(d),f=w.useRef(Gm),m=w.useRef(null),p=w.useRef(!1),h=w.useRef(yN);let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=z=>{var H;const F=z.type,L=z.id;if(F==="sessions"){l(z.sessions??[]);return}L&&((H=u.current.get(L))==null||H(F,z))},e[2]=g):g=e[2];const x=g;let v,y;e[3]!==t?(v=()=>{if(p.current=!1,!t)return()=>{p.current=!0};const z=function(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}${hg()}/__pty`},F=function(){if(p.current||c.current&&c.current.readyState!==WebSocket.CLOSED)return;o("connecting");const H=new WebSocket(z());c.current=H,H.onopen=()=>{if(p.current){H.close();return}f.current=Gm,o("connected"),H.send(JSON.stringify({type:"list"}))},H.onmessage=U=>{try{const W=JSON.parse(U.data);x(W)}catch{}},H.onclose=()=>{if(p.current)return;o("disconnected"),c.current=null;const U=f.current;f.current=Math.min(U*2,bN),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)}},y=[t,x],e[3]=t,e[4]=v,e[5]=y):(v=e[4],y=e[5]),w.useEffect(v,y);let b;e[6]!==t?(b=z=>{if(!t)return;const F=c.current;F&&F.readyState===WebSocket.OPEN&&F.send(JSON.stringify(z))},e[6]=t,e[7]=b):b=e[7];const j=b;let S;e[8]===Symbol.for("react.memo_cache_sentinel")?(S=(z,F)=>{u.current.set(z,F)},e[8]=S):S=e[8];const k=S;let C;e[9]===Symbol.for("react.memo_cache_sentinel")?(C=z=>{u.current.delete(z)},e[9]=C):C=e[9];const N=C;let E;e[10]!==j?(E=z=>{const F=z===void 0?{}:z,L=`pty_${crypto.randomUUID().slice(0,8)}`;return j({type:"spawn",id:L,name:F.name??"Terminal",cwd:F.cwd,metadata:{type:"terminal"}}),L},e[10]=j,e[11]=E):E=e[11];const T=E;let P;e[12]!==j?(P=z=>{const F=`script_${crypto.randomUUID().slice(0,8)}`;return j({type:"spawn",id:F,name:z.name,cwd:z.cwd,args:["run",z.scriptName],command:"bun",metadata:{type:"script",source:z.source,scriptName:z.scriptName}}),F},e[12]=j,e[13]=P):P=e[13];const _=P;let A;e[14]!==j?(A=z=>{j({type:"kill",id:z})},e[14]=j,e[15]=A):A=e[15];const I=A;let $;e[16]!==j?($=(z,F)=>{j({type:"input",id:z,data:F})},e[16]=j,e[17]=$):$=e[17];const R=$;let M;e[18]!==j?(M=(z,F,L)=>{j({type:"resize",id:z,cols:F,rows:L})},e[18]=j,e[19]=M):M=e[19];const O=M;let D;return e[20]!==I||e[21]!==O||e[22]!==j||e[23]!==a||e[24]!==_||e[25]!==T||e[26]!==s||e[27]!==R?(D={status:s,send:j,subscribe:k,unsubscribe:N,sessions:a,spawnTerminal:T,spawnScript:_,killSession:I,writeInput:R,resize:O},e[20]=I,e[21]=O,e[22]=j,e[23]=a,e[24]=_,e[25]=T,e[26]=s,e[27]=R,e[28]=D):D=e[28],D}function yN(){}const rx=w.createContext(null);function Ll(n){const e=B.c(3),{children:t,enabled:s}=n,i=vN(s===void 0?!0:s);let a;return e[0]!==t||e[1]!==i?(a=r.jsx(rx.Provider,{value:i,children:t}),e[0]=t,e[1]=i,e[2]=a):a=e[2],a}function tu(){const n=w.useContext(rx);if(!n)throw new Error("usePty must be used within a PtyProvider");return n}function wN(n){var u;const e=B.c(11),t=tu();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 jN(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(Cd,{"data-icon":"inline-end",className:"fill-current text-destructive"}):r.jsx($o,{"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 SN=w.memo(function(e){const t=B.c(42),{projectDir:s,onProcessStarted:o}=e,[i,a]=w.useState(!1),[l,c]=w.useState("");let d;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=new Set,t[0]=d):d=t[0];const[u,f]=w.useState(d),{scripts:m,loading:p}=xN(s),{runningProcesses:h,runScript:g,stopScript:x}=wN(o);let v;if(t[1]!==m||t[2]!==l){const F=l.trim().toLowerCase(),L=F?m.filter(H=>H.name.toLowerCase().includes(F)||H.dirLabel.toLowerCase().includes(F)):m;v=new Map;for(const H of L){const U=v.get(H.dirLabel)??[];U.push(H),v.set(H.dirLabel,U)}t[1]=m,t[2]=l,t[3]=v}else v=t[3];const y=v;let b;if(t[4]!==h){b=new Map;for(const[F,L]of h)b.set(`${L.name}:${L.cwd}`,{id:F,status:L.status});t[4]=h,t[5]=b}else b=t[5];const j=b;if(!s||!p&&m.length===0)return null;let S;t[6]===Symbol.for("react.memo_cache_sentinel")?(S=function(L){f(H=>{const U=new Set(H);return U.has(L)?U.delete(L):U.add(L),U})},t[6]=S):S=t[6];const k=S;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(nt,{className:"size-3 text-muted-foreground","aria-label":"Loading scripts"}),t[8]=p,t[9]=N):N=t[9];const E=i?"Close script search":"Search scripts";let T,P;t[10]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{a(NN),c("")},P=r.jsx(Yt,{}),t[10]=T,t[11]=P):(T=t[10],P=t[11]);let _;t[12]!==i||t[13]!==E?(_=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm","aria-label":E,"aria-expanded":i,onClick:T,children:P}),t[12]=i,t[13]=E,t[14]=_):_=t[14];let A;t[15]!==N||t[16]!==_?(A=r.jsxs("div",{className:"flex h-8 shrink-0 items-center gap-2 px-2",children:[C,N,_]}),t[15]=N,t[16]=_,t[17]=A):A=t[17];let I;t[18]!==i||t[19]!==l?(I=i&&r.jsx("div",{className:"motion-slide-down-in px-2 pb-2",children:r.jsx(Mt,{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]=I):I=t[20];let $;t[21]!==u||t[22]!==y||t[23]!==g||t[24]!==j||t[25]!==l||t[26]!==x?($=[...y.entries()].map(F=>{const[L,H]=F,U=u.has(L)||!!l,W=H.filter(kN),V=H.filter(CN),K=U?H:W.length>0?W:H.slice(0,1);return r.jsxs("div",{className:"flex flex-col gap-0.5 pb-1",children:[y.size>1&&r.jsx("div",{className:"truncate px-2 pt-1 text-xs text-muted-foreground",children:L}),K.map(Y=>{const X=j.get(`${Y.name}:${Y.dir}`);return r.jsx(jN,{script:Y,status:(X==null?void 0:X.status)??null,onRun:()=>g(Y.name,Y.dir,Y.dirLabel),onStop:()=>{X&&x(X.id)}},`${L}:${Y.name}`)}),!l&&V.length>0&&r.jsx(ee,{type:"button",variant:"link",size:"sm",className:"h-auto justify-start px-2 py-1",onClick:()=>k(L),children:U?"Show less":`Show ${V.length} more`})]},L)}),t[21]=u,t[22]=y,t[23]=g,t[24]=j,t[25]=l,t[26]=x,t[27]=$):$=t[27];let R;t[28]!==y.size||t[29]!==p||t[30]!==l?(R=!p&&y.size===0&&l&&r.jsx(Kt,{className:"gap-1 p-3",children:r.jsxs(Vt,{className:"gap-1",children:[r.jsx(Gt,{children:"No matching scripts"}),r.jsx(tn,{children:"Try another name."})]})}),t[28]=y.size,t[29]=p,t[30]=l,t[31]=R):R=t[31];let M;t[32]!==$||t[33]!==R?(M=r.jsxs(Vn,{className:"min-h-0 flex-1 px-1 pb-1",children:[$,R]}),t[32]=$,t[33]=R,t[34]=M):M=t[34];let O;t[35]!==I||t[36]!==M||t[37]!==A?(O=r.jsxs("section",{className:"flex w-56 shrink-0 flex-col","aria-label":"Scripts",children:[A,I,M]}),t[35]=I,t[36]=M,t[37]=A,t[38]=O):O=t[38];let D;t[39]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(Nt,{orientation:"vertical"}),t[39]=D):D=t[39];let z;return t[40]!==O?(z=r.jsxs(r.Fragment,{children:[O,D]}),t[40]=O,t[41]=z):z=t[41],z});function NN(n){return!n}function kN(n){return n.isCommon}function CN(n){return!n.isCommon}function Ka(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(z3,{"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 _N=rs("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 Va(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(_N({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(B3,{"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(D3,{"data-slot":"tabs-list","data-variant":a,className:l,...o,children:[t,d]}),e[11]=t,e[12]=o,e[13]=l,e[14]=d,e[15]=a,e[16]=u):u=e[16],u}function Dn(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=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(F3,{"data-slot":"tabs-trigger",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function zn(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(O3,{"data-slot":"tabs-content",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const TN=w.lazy(()=>Ve(()=>import("./TerminalOutput-DnTT9ONj.js"),__vite__mapDeps([0,1,2,3,4,5])).then(n=>({default:n.TerminalOutput})));function EN({process:n}){const[e,t]=w.useState(""),[s,o]=w.useState(!1),i=w.useRef(null);return w.useEffect(()=>{let a;if(n.type==="task"&&n.outputPath)a=Kr(`/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=sx(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]),w.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 AN(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 v;e[11]!==x?(v=q("px-1 py-0 font-normal",x),e[11]=x,e[12]=v):v=e[12];let y;e[13]!==t.type||e[14]!==v?(y=r.jsx(Pe,{variant:"secondary",className:v,children:t.type}),e[13]=t.type,e[14]=v,e[15]=y):y=e[15];let b;e[16]!==t.id||e[17]!==t.name||e[18]!==y||e[19]!==u||e[20]!==m||e[21]!==p||e[22]!==h||e[23]!==g?(b=r.jsxs(Dn,{value:c,"aria-label":d,onClick:u,className:m,children:[p,h,g,y]}),e[16]=t.id,e[17]=t.name,e[18]=y,e[19]=u,e[20]=m,e[21]=p,e[22]=h,e[23]=g,e[24]=b):b=e[24];const j=`Close ${t.name}`,S=`Close ${t.name}`;let k;e[25]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(tt,{"data-icon":"inline-start"}),e[25]=k):k=e[25];let C;e[26]!==i||e[27]!==j||e[28]!==S?(C=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs","aria-label":j,title:S,onClick:i,className:"mr-0.5 text-muted-foreground",children:k}),e[26]=i,e[27]=j,e[28]=S,e[29]=C):C=e[29];let N;return e[30]!==l||e[31]!==b||e[32]!==C?(N=r.jsxs("div",{title:l,className:"inline-flex h-6 shrink-0 items-center",children:[b,C]}),e[30]=l,e[31]=b,e[32]=C,e[33]=N):N=e[33],N}const ix=100,ax=600,PN=200,lx="process-panel-height";function IN(){try{const n=localStorage.getItem(lx);if(n)return Math.min(ax,Math.max(ix,Number(n)))}catch{}return PN}const RN=w.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=tu(),[v,y]=w.useState(IN),b=w.useRef(null);let j,S;t[0]!==f||t[1]!==x.sessions?(j=()=>{for(const le of x.sessions)le.status==="exited"&&(f==null||f(le.id,"stopped"))},S=[x.sessions,f],t[0]=f,t[1]=x.sessions,t[2]=j,t[3]=S):(j=t[2],S=t[3]),w.useEffect(j,S);let k;t[4]!==l||t[5]!==x?(k=le=>{le.type!=="task"&&x.killSession(le.id),l(le.id)},t[4]=l,t[5]=x,t[6]=k):k=t[6];const C=k;let N;t[7]!==v?(N=le=>{le.preventDefault(),b.current={startY:le.clientY,startH:v},le.target.setPointerCapture(le.pointerId)},t[7]=v,t[8]=N):N=t[8];const E=N;let T;t[9]===Symbol.for("react.memo_cache_sentinel")?(T=le=>{if(!b.current)return;const xe=b.current.startY-le.clientY,pe=Math.min(ax,Math.max(ix,b.current.startH+xe));y(pe)},t[9]=T):T=t[9];const P=T;let _;t[10]!==v?(_=()=>{if(b.current){b.current=null;try{localStorage.setItem(lx,String(v))}catch{}}},t[10]=v,t[11]=_):_=t[11];const A=_;let I;t[12]!==o||t[13]!==s?(I=o?s.get(o):null,t[12]=o,t[13]=s,t[14]=I):I=t[14];const $=I;let R;t[15]!==s?(R=[...s.values()],t[15]=s,t[16]=R):R=t[16];const M=R;let O;t[17]!==a?(O=le=>{typeof le=="string"&&a(le)},t[17]=a,t[18]=O):O=t[18];let D;t[19]!==$||t[20]!==i||t[21]!==g||t[22]!==E||t[23]!==A?(D=!g&&!i&&$&&r.jsx("div",{className:"h-1 cursor-row-resize transition-colors hover:bg-accent active:bg-muted-foreground/30",onPointerDown:E,onPointerMove:P,onPointerUp:A,onPointerCancel:A}),t[19]=$,t[20]=i,t[21]=g,t[22]=E,t[23]=A,t[24]=D):D=t[24];const z=g?"h-7 gap-1 px-2":"h-8 gap-2 px-3";let F;t[25]!==z?(F=q("flex shrink-0 items-center border-b bg-card",z),t[25]=z,t[26]=F):F=t[26];const L=i?"Expand terminal panel":"Collapse terminal panel",H=!i;let U;t[27]!==i?(U=i?r.jsx(Ye,{"data-icon":"inline-start"}):r.jsx(mt,{"data-icon":"inline-start"}),t[27]=i,t[28]=U):U=t[28];const W=g&&"sr-only";let V;t[29]!==W?(V=q(W),t[29]=W,t[30]=V):V=t[30];let K;t[31]!==V?(K=r.jsx("span",{className:V,children:"Terminal"}),t[31]=V,t[32]=K):K=t[32];let Y;t[33]!==c||t[34]!==L||t[35]!==H||t[36]!==U||t[37]!==K?(Y=r.jsxs(ee,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2",onClick:c,"aria-label":L,"aria-expanded":H,children:[U,K]}),t[33]=c,t[34]=L,t[35]=H,t[36]=U,t[37]=K,t[38]=Y):Y=t[38];const X=!g&&"ml-2";let G;t[39]!==X?(G=q("min-w-0 flex-1 justify-start overflow-x-auto no-scrollbar",X),t[39]=X,t[40]=G):G=t[40];let J;t[41]!==o||t[42]!==C||t[43]!==g||t[44]!==a||t[45]!==M?(J=M.map(le=>r.jsx(AN,{process:le,isActive:le.id===o,onSelectActive:()=>a(le.id),onClose:()=>C(le),mobile:g},le.id)),t[41]=o,t[42]=C,t[43]=g,t[44]=a,t[45]=M,t[46]=J):J=t[46];let Z;t[47]!==G||t[48]!==J?(Z=r.jsx(Va,{variant:"default","aria-label":"Open processes",className:G,children:J}),t[47]=G,t[48]=J,t[49]=Z):Z=t[49];let Q;t[50]!==d||t[51]!==m?(Q=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(Bn,{})}),t[50]=d,t[51]=m,t[52]=Q):Q=t[52];let te;t[53]!==F||t[54]!==Y||t[55]!==Z||t[56]!==Q?(te=r.jsxs("div",{className:F,children:[Y,Z,Q]}),t[53]=F,t[54]=Y,t[55]=Z,t[56]=Q,t[57]=te):te=t[57];const ne=!i,oe=g?"min(36dvh, 260px)":v;let re;t[58]!==oe?(re={height:oe},t[58]=oe,t[59]=re):re=t[59];let ie;t[60]!==g||t[61]!==p||t[62]!==m?(ie=!g&&r.jsx(SN,{projectDir:m,onProcessStarted:p}),t[60]=g,t[61]=p,t[62]=m,t[63]=ie):ie=t[63];let se;t[64]!==C||t[65]!==u||t[66]!==d||t[67]!==M?(se=M.map(le=>r.jsx(zn,{value:le.id,className:"col-start-1 row-start-1 flex min-h-0 flex-col",children:le.type==="task"?r.jsx(EN,{process:le}):r.jsx(w.Suspense,{fallback:r.jsx("div",{className:"flex size-full items-center justify-center text-xs text-muted-foreground",children:"Loading terminal…"}),children:r.jsx(TN,{processId:le.id,autoFocus:!0,onRequestNew:d,onRequestClose:()=>C(le),onAddContext:u})})},le.id)),t[64]=C,t[65]=u,t[66]=d,t[67]=M,t[68]=se):se=t[68];let ce;t[69]!==$||t[70]!==d||t[71]!==m?(ce=!$&&r.jsxs(Kt,{className:"col-start-1 row-start-1 rounded-none",children:[r.jsxs(Vt,{children:[r.jsx(en,{variant:"icon",children:r.jsx(Vs,{})}),r.jsx(Gt,{children:"No terminal open"}),r.jsx(tn,{children:"Start a terminal here or run a project script from the left."})]}),d&&m&&r.jsx(mg,{children:r.jsxs(ee,{type:"button",size:"sm",onClick:d,children:[r.jsx(Bn,{"data-icon":"inline-start"}),"New terminal"]})})]}),t[69]=$,t[70]=d,t[71]=m,t[72]=ce):ce=t[72];let ae;t[73]!==se||t[74]!==ce?(ae=r.jsxs("div",{className:"grid min-h-0 min-w-0 flex-1 grid-cols-1",children:[se,ce]}),t[73]=se,t[74]=ce,t[75]=ae):ae=t[75];let ue;t[76]!==re||t[77]!==ie||t[78]!==ae?(ue=r.jsx(dt,{children:r.jsxs("div",{className:"flex min-h-0",style:re,children:[ie,ae]})}),t[76]=re,t[77]=ie,t[78]=ae,t[79]=ue):ue=t[79];let me;t[80]!==ne||t[81]!==ue?(me=r.jsx(ct,{open:ne,className:"min-h-0",children:ue}),t[80]=ne,t[81]=ue,t[82]=me):me=t[82];let de;return t[83]!==o||t[84]!==O||t[85]!==D||t[86]!==te||t[87]!==me?(de=r.jsxs(Ka,{value:o,onValueChange:O,className:"shrink-0 gap-0 border-t bg-background",children:[D,te,me]}),t[83]=o,t[84]=O,t[85]=D,t[86]=te,t[87]=me,t[88]=de):de=t[88],de});function Qr(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 $N=/(?::(\d{4,5}))|(?:port\s+(\d{4,5}))|(?:localhost:(\d{4,5}))/gi;function MN(n){const e=new Set;for(const t of n.matchAll($N)){const s=parseInt(t[1]||t[2]||t[3],10);s>0&&s<65536&&e.add(s)}return[...e]}function LN(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=MN(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 Ym(n){var e;return((e=n.preview.split(`
6
+ `).find(t=>t.trim()))==null?void 0:e.trim())||`Task ${n.id}`}function ON(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(Pe,{variant:"secondary",className:"font-mono",children:[a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d}function cx({cwd:n,turns:e,onToggleServer:t,onServersChanged:s}){const[o,i]=w.useState([]),a=LN(e);w.useEffect(()=>{if(!n)return;let c=!1;async function d(){try{const f=await Ne(`/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 Ne(`/api/check-ports?ports=${m.join(",")}`);if(c)return;if(p.ok){const h=await p.json();if(c)return;const g=[],x=new Set;for(const[v,y]of a)!h[v]||x.has(v)||(x.add(v),g.push({id:`port-${v}`,outputPath:y.outputPath,ports:[v],portStatus:{[v]:!0},preview:y.description}));i(g)}}catch{}}d();const u=setInterval(d,1e4);return()=>{c=!0,clearInterval(u)}},[n,a]);const l=w.useCallback(async c=>{try{await Ne("/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 w.useEffect(()=>{if(!s)return;const c=o.filter(d=>d.outputPath).map(d=>({id:d.id,outputPath:d.outputPath,title:Ym(d)}));s(c)},[o,s]),o.length===0?null:r.jsxs("section",{children:[r.jsxs(Qr,{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=Ym(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(H1,{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(ON,{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(Vs,{"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(Cd,{"data-icon":"inline-start",className:"fill-current"}),r.jsx("span",{children:"Stop"})]})]})]},c.id)})})]})}function nu(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(U3,{"data-slot":"alert-dialog",...t}),e[2]=t,e[3]=s):s=e[3],s}function DN(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(W3,{"data-slot":"alert-dialog-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function zN(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(Sd,{"data-slot":"alert-dialog-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}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("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(Nd,{"data-slot":"alert-dialog-overlay",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function su(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(FN,{}),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(zN,{children:[a,r.jsx(jd,{"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 ou(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 ru(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 BN(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 iu(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(yd,{"data-slot":"alert-dialog-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function au(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(wd,{"data-slot":"alert-dialog-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function lu(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 cu(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(Fr,{"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 dx(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(q3,{"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(at,{})}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.jsx(H3,{"data-slot":"checkbox",className:o,...s,children:i}),e[6]=s,e[7]=o,e[8]=a):a=e[8],a}const UN={undo:"Undo turns?",redo:"Redo turns?","branch-switch":"Switch branch?"},WN={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 HN({state:n,isApplying:e,applyError:t,onConfirm:s,onCancel:o}){var f,m;const i=w.useRef(n),[a,l]=w.useState({key:"",selected:!1});w.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(nu,{open:n!==null,onOpenChange:p=>{p||o()},onOpenChangeComplete:p=>{p||(i.current=null,l({key:"",selected:!1}))},children:r.jsxs(su,{children:[r.jsxs(ou,{children:[r.jsx(BN,{children:r.jsx(mn,{className:"text-warning"})}),r.jsx(iu,{children:UN[c.type]}),r.jsx(au,{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.":WN[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(dx,{checked:u,disabled:e,onCheckedChange:p=>l({key:d,selected:p===!0})}),"Restore captured file changes"]})]}),t&&r.jsx(ut,{variant:"destructive",children:r.jsx(ft,{children:t})}),r.jsxs(ru,{children:[r.jsx(cu,{onClick:o,disabled:e,children:"Cancel"}),r.jsx(lu,{onClick:()=>s(u),disabled:e,children:e?r.jsxs(r.Fragment,{children:[r.jsx(et,{"data-icon":"inline-start",className:"animate-spin"}),"Applying..."]}):c.type==="undo"?"Undo":c.type==="redo"?"Redo":"Switch"})]})]})})}function ln(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 xn(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 bn(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 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 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 qN(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 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("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 Zr(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 ds(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 KN=rs("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 En(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(KN({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:VN,...s}),e[7]=i,e[8]=s,e[9]=a,e[10]=l):l=e[10],l}function VN(n){var e,t;n.target.closest("button")||(t=(e=n.currentTarget.parentElement)==null?void 0:e.querySelector("input"))==null||t.focus()}const GN=rs("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 ei(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(GN({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 us(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=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(Mt,{"data-slot":"input-group-control",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function YN(){const[n,e]=w.useState("idle"),[t,s]=w.useState(null),o=w.useRef(void 0),i=w.useCallback(async d=>{if(!d.trim()){e("idle"),s(null);return}e("validating"),s(null);try{const f=await(await Ne(`/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=w.useCallback(d=>{clearTimeout(o.current),o.current=setTimeout(()=>i(d),400)},[i]),l=w.useCallback(()=>{e("idle"),s(null),clearTimeout(o.current)},[]),c=w.useCallback(async(d,u)=>{try{const f=await Ne("/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 w.useEffect(()=>()=>clearTimeout(o.current),[]),{status:n,error:t,debouncedValidate:a,validate:i,reset:l,save:c}}const lo=sj(n=>!n.cli.homeIsDiscoverable,"a home Cogpit has to be told about"),ux=Ra().filter(n=>n.cli.homeIsDiscoverable);function fx(n){return n.flatMap((e,t)=>t===0?[e]:[t===n.length-1?" and ":", ",e])}function mx(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 XN=fx(ux.map(n=>n.displayName)),JN=fx(ux.map(n=>r.jsx(mx,{children:["~",n.cli.homeDirName,n.cli.installMarker].filter(Boolean).join("/")},n.kind))),QN=`~/${lo.cli.homeDirName}`;function ZN(n){const e=B.c(46),{onConfigured:t}=n,[s,o]=w.useState(""),[i,a]=w.useState(!1),{status:l,error:c,debouncedValidate:d,save:u}=YN();let f;e[0]!==d?(f=D=>{const z=D.target.value;o(z),d(z)},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 D=await u(s);D.success&&D.claudeDir&&t(D.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=D=>{D.preventDefault(),l==="valid"&&!i&&h()},e[6]=h,e[7]=i,e[8]=l,e[9]=g):g=e[9];let x,v;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:r.jsx(kd,{className:"size-4"})}),v=r.jsx(bn,{children:"Connect your coding agent"}),e[10]=x,e[11]=v):(x=e[10],v=e[11]);let y;e[12]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsxs(xn,{children:[x,v,r.jsxs(vn,{children:["Cogpit detects ",XN," automatically. Existing histories live in"," ",JN,"."," ","For ",lo.displayName,", enter its data directory, usually"," ",r.jsx(mx,{children:QN}),"."]})]}),e[12]=y):y=e[12];const b=l==="invalid";let j;e[13]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsxs(wt,{htmlFor:"agent-data-directory",children:[lo.displayName," data directory"]}),e[13]=j):j=e[13];let S;e[14]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx(En,{children:r.jsx(So,{"aria-hidden":"true"})}),e[14]=S):S=e[14];const k=l==="invalid";let C;e[15]!==m||e[16]!==s||e[17]!==k?(C=r.jsxs(ds,{children:[S,r.jsx(us,{id:"agent-data-directory",value:s,onChange:m,placeholder:`/Users/you/${lo.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(Co,{className:"flex items-center gap-2",children:[r.jsx(nt,{className:"size-4"}),"Checking path..."]}),e[19]=l,e[20]=N):N=e[20];let E;e[21]!==l?(E=l==="valid"&&r.jsxs(Co,{className:"flex items-center gap-2 text-success",children:[r.jsx(Br,{className:"size-4"}),lo.displayName," history found"]}),e[21]=l,e[22]=E):E=e[22];let T;e[23]!==c||e[24]!==l?(T=l==="invalid"&&c&&r.jsxs(vs,{className:"flex items-center gap-2",children:[r.jsx(Ps,{className:"size-4"}),c]}),e[23]=c,e[24]=l,e[25]=T):T=e[25];let P;e[26]!==N||e[27]!==E||e[28]!==T?(P=r.jsxs("div",{id:"agent-directory-status",className:"min-h-5",role:"status","aria-live":"polite",children:[N,E,T]}),e[26]=N,e[27]=E,e[28]=T,e[29]=P):P=e[29];let _;e[30]!==C||e[31]!==P||e[32]!==b?(_=r.jsx(cn,{children:r.jsx(Do,{children:r.jsxs(yt,{"data-invalid":b,children:[j,C,P]})})}),e[30]=C,e[31]=P,e[32]=b,e[33]=_):_=e[33];const A=l!=="valid"||i;let I;e[34]!==i?(I=i&&r.jsx(nt,{"data-icon":"inline-start"}),e[34]=i,e[35]=I):I=e[35];const $=i?"Saving...":`Connect ${lo.displayName}`;let R;e[36]!==A||e[37]!==I||e[38]!==$?(R=r.jsx(Zr,{children:r.jsxs(ee,{type:"submit",className:"w-full",disabled:A,children:[I,$]})}),e[36]=A,e[37]=I,e[38]=$,e[39]=R):R=e[39];let M;e[40]!==_||e[41]!==R?(M=r.jsxs(ln,{children:[y,_,R]}),e[40]=_,e[41]=R,e[42]=M):M=e[42];let O;return e[43]!==M||e[44]!==g?(O=r.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-4 py-8 text-foreground",children:r.jsx("form",{className:"w-full max-w-lg",onSubmit:g,children:M})}),e[43]=M,e[44]=g,e[45]=O):O=e[45],O}const px=/^[a-z]:[\\/]/i;function du(n){return(px.test(n)?n.replace(/\\/g,"/"):n).replace(/\/+$/,"")||"/"}function Xm(n){const e=du(n);return px.test(n)?e.toLowerCase():e}function ek(n){const e=du(n),t=e.lastIndexOf("/");return t<0?e:t===0?"/":e.slice(0,t)}function Jm(n,e){const t=Xm(n),s=Xm(e);if(t===s)return"";const o=t==="/"?"/":`${t}/`;return s.startsWith(o)?du(e).slice(o.length):null}let uu=!1;function tk(n){uu=n}function fu(){return uu}let pr=null;function nk(n){return pr=n,()=>{pr===n&&(pr=null)}}function sk(n,e){if(!n.path)return null;if(n.kind==="project")return{root:n.path,file:null,mode:"edit"};if(e){const o=Jm(e,n.path);if(o)return{root:e,file:o,mode:Qm(n),line:n.line}}const t=ek(n.path),s=Jm(t,n.path);return s?{root:t,file:s,mode:Qm(n),line:n.line}:null}function Qm(n){return n.mode==="diff"?"diff":"edit"}function hx(n){return uu&&pr!==null&&pr(n)}function gx(n,e){Kn(n,e).catch(()=>{})}function Er(n,e={}){if(st("hostFiles")&&!hx({kind:"file",path:n,...e})){if(Ws()){$a(n);return}gx("/api/open-in-editor",{path:n,mode:e.mode??"file",line:e.line,column:e.column})}}function xx(n){st("hostFiles")&&(n.path&&hx({kind:"project",path:n.path})||vx("/api/open-in-editor",n))}function bx(n){st("hostFiles")&&vx("/api/reveal-in-folder",n)}function vx(n,e){!e.path&&!e.dirName||gx(n,{path:e.path||void 0,dirName:e.dirName||void 0})}const ok=1500;function ss(){const n=B.c(5),[e,t]=w.useState(!1),s=w.useRef(null),o=w.useRef(!0);let i,a;n[0]===Symbol.for("react.memo_cache_sentinel")?(i=()=>(o.current=!0,()=>{o.current=!1,s.current&&clearTimeout(s.current)}),a=[],n[0]=i,n[1]=a):(i=n[0],a=n[1]),w.useEffect(i,a);let l;n[2]===Symbol.for("react.memo_cache_sentinel")?(l=async u=>{!await $a(u)||!o.current||(t(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>t(!1),ok))},n[2]=l):l=n[2];const c=l;let d;return n[3]!==e?(d=[e,c],n[3]=e,n[4]=d):d=n[4],d}function ti(){const n=B.c(2),[e,t]=w.useState(rk);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]),w.useEffect(s,o),e}function rk(){return typeof document<"u"&&document.documentElement.classList.contains("dark")}let Ol=null;const Hc=new Set,Mi=new Map,Zm=["typescript","tsx","javascript","jsx","json","css","html","python","bash","yaml","markdown"],yx={typescript:()=>Ve(()=>import("./typescript-BPQ3VLAy.js"),[]),tsx:()=>Ve(()=>import("./tsx-COt5Ahok.js"),[]),javascript:()=>Ve(()=>import("./javascript-wDzz0qaB.js"),[]),jsx:()=>Ve(()=>import("./jsx-g9-lgVsj.js"),[]),json:()=>Ve(()=>import("./json-Cp-IABpG.js"),[]),css:()=>Ve(()=>import("./css-DPfMkruS.js"),[]),html:()=>Ve(()=>import("./html-GMplVEZG.js"),__vite__mapDeps([6,7,8])),python:()=>Ve(()=>import("./python-B6aJPvgy.js"),[]),bash:()=>Ve(()=>import("./bash-Yzrsuije.js"),[]),yaml:()=>Ve(()=>import("./yaml-Buea-lGh.js"),[]),markdown:()=>Ve(()=>import("./markdown-Cvjx9yec.js"),[]),rust:()=>Ve(()=>import("./rust-B1yitclQ.js"),[]),go:()=>Ve(()=>import("./go-CxLEBnE3.js"),[]),toml:()=>Ve(()=>import("./toml-vGWfd6FD.js"),[]),sql:()=>Ve(()=>import("./sql-BLtJtn59.js"),[]),c:()=>Ve(()=>import("./c-BIGW1oBm.js"),[]),cpp:()=>Ve(()=>import("./cpp-BRuaLJcg.js"),__vite__mapDeps([9,10,11])),java:()=>Ve(()=>import("./java-CylS5w8V.js"),[]),ruby:()=>Ve(()=>import("./ruby-B0Tyh1qT.js"),__vite__mapDeps([12,6,7,8,13,14,11,15,16,17,9,10,18,19])),swift:()=>Ve(()=>import("./swift-D82vCrfD.js"),[]),kotlin:()=>Ve(()=>import("./kotlin-BdnUsdx6.js"),[]),php:()=>Ve(()=>import("./php-aq0itWAE.js"),__vite__mapDeps([20,6,7,8,13,14,11,21])),vue:()=>Ve(()=>import("./vue-DVfSmUF7.js"),__vite__mapDeps([22,8,7,15,21,6])),svelte:()=>Ve(()=>import("./svelte-DZMnMd3x.js"),__vite__mapDeps([23,7,15,8])),scss:()=>Ve(()=>import("./scss-OYdSNvt2.js"),__vite__mapDeps([24,8]))};function wx(){return Ol||(Ol=(async()=>{const[n,e,...t]=await Promise.all([Ve(()=>import("./github-dark-DHJKELXO.js"),[]).then(o=>o.default),Ve(()=>import("./github-light-DAi9KRSo.js"),[]).then(o=>o.default),...Zm.map(o=>yx[o]().then(i=>i.default))]),s=await Vw({themes:[n,e],langs:t,engine:Gw()});for(const o of Zm)Hc.add(o);return s})()),Ol}async function jx(n,e){if(Hc.has(e))return;if(Mi.has(e))return Mi.get(e);const t=yx[e];if(!t)return;const s=t().then(async o=>{await n.loadLanguage(o.default),Hc.add(e)}).finally(()=>Mi.delete(e));Mi.set(e,s),await s}const ik={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 Sx(n){var t;const e=((t=n.split(".").pop())==null?void 0:t.toLowerCase())??"";return ik[e]??null}async function ak(n,e,t){try{const s=await wx();await jx(s,e);const o=t?"github-dark":"github-light";return s.codeToTokens(n,{lang:e,theme:o}).tokens}catch{return null}}const lk="min-w-0 max-h-96 overflow-y-auto whitespace-pre-wrap break-words [overflow-wrap:anywhere] rounded-md border bg-muted/30 p-3 font-mono text-xs leading-relaxed text-foreground/85",mu="min-w-0 max-h-96 overflow-auto whitespace-pre-wrap break-words [overflow-wrap:anywhere] rounded-md bg-muted/40 p-3 font-mono text-xs leading-relaxed text-foreground/85";function Ga(n,e,t){const s=B.c(5),[o,i]=w.useState(null);let a,l;return s[0]!==n||s[1]!==t||s[2]!==e?(a=()=>{if(!e)return;let c=!1;return ak(n,e,t).then(d=>{c||i({code:n,lang:e,isDark:t,tokens:d})}).catch(ck),()=>{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]),w.useEffect(a,l),(o==null?void 0:o.code)===n&&o.lang===e&&o.isDark===t?o.tokens:null}function ck(){}function pu(n){const e=B.c(13),{lines:t,tokens:s,lineNums:o,variant:i,label:a}=n,l=i==="boxed"?lk:mu;let c;if(e[0]!==o||e[1]!==t||e[2]!==s){let f;e[4]!==o||e[5]!==s?(f=(m,p)=>{const h=s==null?void 0:s[p];return r.jsxs("span",{className:"block",children:[(o==null?void 0:o[p])&&r.jsx("span",{className:"inline-block w-10 text-right mr-2 text-muted-foreground select-none",children:o[p]}),h?h.map(dk):m||" "]},p)},e[4]=o,e[5]=s,e[6]=f):f=e[6],c=t.map(f),e[0]=o,e[1]=t,e[2]=s,e[3]=c}else c=e[3];let d;e[7]!==a||e[8]!==c?(d=r.jsx("code",{className:"block","aria-label":a,children:c}),e[7]=a,e[8]=c,e[9]=d):d=e[9];let u;return e[10]!==l||e[11]!==d?(u=r.jsx("pre",{tabIndex:0,className:l,children:d}),e[10]=l,e[11]=d,e[12]=u):u=e[12],u}function dk(n,e){return r.jsx("span",{style:{color:n.color},children:n.content},e)}function Nx(n){const e=B.c(6),{code:t,language:s,label:o}=n,i=ti(),a=Ga(t,s,i);let l;e[0]!==t?(l=Ar(t),e[0]=t,e[1]=l):l=e[1];const c=l;let d;return e[2]!==o||e[3]!==c||e[4]!==a?(d=r.jsx(pu,{lines:c,tokens:a,variant:"unboxed",label:o}),e[2]=o,e[3]=c,e[4]=a,e[5]=d):d=e[5],d}const uk=/^(\s*\d+)→(.*)$/;function Ar(n){return n.split(/\r\n|\r|\n/)}function fk(n){const e=[],t=[];for(const s of Ar(n)){const o=s.match(uk);o?(e.push(o[1]),t.push(o[2])):(e.push(""),t.push(s))}return{lineNums:e,codeLines:t}}function mk(n){const e=B.c(11),{result:t,filePath:s,variant:o}=n,i=o===void 0?"boxed":o,a=ti();let l;e[0]!==s?(l=Sx(s),e[0]=s,e[1]=l):l=e[1];const c=l;let d;e[2]!==t?(d=fk(t),e[2]=t,e[3]=d):d=e[3];const{lineNums:u,codeLines:f}=d;let m;e[4]!==f?(m=f.join(`
7
+ `),e[4]=f,e[5]=m):m=e[5];const h=Ga(m,c,a);let g;return e[6]!==f||e[7]!==u||e[8]!==h||e[9]!==i?(g=r.jsx(pu,{lines:f,tokens:h,lineNums:u,variant:i}),e[6]=f,e[7]=u,e[8]=h,e[9]=i,e[10]=g):g=e[10],g}function kx(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 Cx(n){const e=B.c(9),{result:t,alreadyPretty:s,variant:o}=n,i=o===void 0?"boxed":o,a=ti();let l;e[0]!==s||e[1]!==t?(l=s?t:kx(t)??t,e[0]=s,e[1]=t,e[2]=l):l=e[2];const c=l;let d;e[3]!==c?(d=Ar(c),e[3]=c,e[4]=d):d=e[4];const u=d,f=Ga(c,"json",a);let m;return e[5]!==u||e[6]!==f||e[7]!==i?(m=r.jsx(pu,{lines:u,tokens:f,variant:i}),e[5]=u,e[6]=f,e[7]=i,e[8]=m):m=e[8],m}function pk(n){const e=Ar(n),t=e.slice(0,8).join(`
8
+ `),s=t.slice(0,1e3);return{text:s,hiddenLines:Math.max(0,e.length-Ar(s).length),truncated:e.length>8||t.length>1e3}}function _x(n){const e=B.c(37),{result:t,isError:s,filePath:o,renderResult:i}=n,a=s===void 0?!1:s,[l,c]=w.useState(!1),[d,u]=ss(),f=w.useId();let m;e[0]!==o||e[1]!==a||e[2]!==t?(m=!a&&!o?kx(t):null,e[0]=o,e[1]=a,e[2]=t,e[3]=m):m=e[3];const p=m,h=p??t;let g;e[4]!==h?(g=pk(h),e[4]=h,e[5]=g):g=e[5];const x=g,v=l?h:x.text,y=a&&"text-destructive";let b;e[6]!==y?(b=q("text-xs text-muted-foreground",y),e[6]=y,e[7]=b):b=e[7];const j=a?"Error":"Result";let S;e[8]!==b||e[9]!==j?(S=r.jsx("span",{className:b,children:j}),e[8]=b,e[9]=j,e[10]=S):S=e[10];let k;e[11]!==d||e[12]!==u||e[13]!==t?(k=t.trim()&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>u(t),"aria-label":d?"Result copied":"Copy result",children:d?r.jsx(at,{"data-icon":"icon"}):r.jsx(pn,{"data-icon":"icon"})}),e[11]=d,e[12]=u,e[13]=t,e[14]=k):k=e[14];let C;e[15]!==S||e[16]!==k?(C=r.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[S,k]}),e[15]=S,e[16]=k,e[17]=C):C=e[17];let N;e[18]!==o||e[19]!==a||e[20]!==p||e[21]!==i||e[22]!==t||e[23]!==v?(N=t.trim()?i?i(v):o&&!a?r.jsx(mk,{result:v,filePath:o,variant:"unboxed"}):p!==null?r.jsx(Cx,{result:v,alreadyPretty:!0,variant:"unboxed"}):r.jsx("pre",{tabIndex:0,className:q(mu,a&&"border-destructive/30 text-destructive"),children:v}):r.jsx("p",{className:"text-xs text-muted-foreground",children:"No output"}),e[18]=o,e[19]=a,e[20]=p,e[21]=i,e[22]=t,e[23]=v,e[24]=N):N=e[24];let E;e[25]!==f||e[26]!==N?(E=r.jsx("div",{id:f,children:N}),e[25]=f,e[26]=N,e[27]=E):E=e[27];let T;e[28]!==l||e[29]!==x.hiddenLines||e[30]!==x.truncated||e[31]!==f?(T=x.truncated&&r.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"mt-1",onClick:()=>c(hk),"aria-expanded":l,"aria-controls":f,children:l?"Show less":x.hiddenLines>0?`+${x.hiddenLines} ${x.hiddenLines===1?"line":"lines"}`:"Show more"}),e[28]=l,e[29]=x.hiddenLines,e[30]=x.truncated,e[31]=f,e[32]=T):T=e[32];let P;return e[33]!==E||e[34]!==T||e[35]!==C?(P=r.jsxs("section",{className:"mt-3 min-w-0","aria-label":"Result",children:[C,E,T]}),e[33]=E,e[34]=T,e[35]=C,e[36]=P):P=e[36],P}function hk(n){return!n}const gk={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 xk(n){return gk[n.toLowerCase()]??n}function bk(n){if(!n)return null;const e=n.match(/language-(\S+)/);return(e==null?void 0:e[1])??null}function vk(n){const e=B.c(9),{text:t}=n,[s,o]=ss();let i;e[0]!==o||e[1]!==t?(i=()=>o(t),e[0]=o,e[1]=t,e[2]=i):i=e[2];const a=s?"Copied":"Copy code";let l;e[3]!==s?(l=s?r.jsxs(r.Fragment,{children:[r.jsx(at,{className:"text-success","data-icon":"inline-start"}),r.jsx("span",{className:"text-success",children:"Copied"})]}):r.jsx(pn,{"data-icon":"icon"}),e[3]=s,e[4]=l):l=e[4];let c;return e[5]!==i||e[6]!==a||e[7]!==l?(c=r.jsx(ee,{type:"button",variant:"ghost",size:"xs",onClick:i,className:"text-muted-foreground",title:"Copy code","aria-label":a,children:l}),e[5]=i,e[6]=a,e[7]=l,e[8]=c):c=e[8],c}function yk(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 wk(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(`
9
+ `);let a;e[4]!==s?(a=bk(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(jk,{code:u,lang:l,...o}),e[12]=u,e[13]=l,e[14]=o,e[15]=f):f=e[15],f}function jk(n){const e=B.c(39);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=ti(),a=Ga(t,s,i),[l,c]=w.useState(!1);let d,u,f,m;if(e[4]!==t||e[5]!==l||e[6]!==s||e[7]!==o||e[8]!==a){const g=t.split(`
10
+ `);d=g.length;const x=d>30,v=l?Ye:mt;u="my-3 overflow-hidden rounded-lg border border-border bg-muted/20";let y;e[13]!==v||e[14]!==l||e[15]!==x?(y=x&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>c(!l),className:"text-muted-foreground","aria-label":l?"Expand code":"Collapse code",children:r.jsx(v,{"data-icon":"icon"})}),e[13]=v,e[14]=l,e[15]=x,e[16]=y):y=e[16];let b;e[17]!==s?(b=s&&r.jsx(Pe,{variant:"ghost",className:"px-0 uppercase tracking-wide text-muted-foreground",children:xk(s)}),e[17]=s,e[18]=b):b=e[18];let j;e[19]!==x||e[20]!==d?(j=x&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:[d," lines"]}),e[19]=x,e[20]=d,e[21]=j):j=e[21];let S;e[22]!==y||e[23]!==b||e[24]!==j?(S=r.jsxs("div",{className:"flex items-center gap-2",children:[y,b,j]}),e[22]=y,e[23]=b,e[24]=j,e[25]=S):S=e[25];let k;e[26]!==t?(k=r.jsx(vk,{text:t}),e[26]=t,e[27]=k):k=e[27],e[28]!==S||e[29]!==k?(f=r.jsxs("div",{className:"flex items-center justify-between border-b border-border bg-muted/40 px-3 py-1.5",children:[S,k]}),e[28]=S,e[29]=k,e[30]=f):f=e[30],m=!l&&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",!a&&"text-foreground/90"),...o,children:g.map((C,N)=>{const E=a==null?void 0:a[N];return r.jsxs("span",{className:"block",children:[r.jsx(yk,{num:N+1}),E?E.map(Sk):C||" "]},N)})})})}),e[4]=t,e[5]=l,e[6]=s,e[7]=o,e[8]=a,e[9]=d,e[10]=u,e[11]=f,e[12]=m}else d=e[9],u=e[10],f=e[11],m=e[12];let p;e[31]!==l||e[32]!==d?(p=l&&r.jsxs(ee,{type:"button",variant:"ghost",size:"sm",onClick:()=>c(!1),className:"h-auto w-full justify-start rounded-none px-3 py-2 text-xs text-muted-foreground","aria-label":`Expand ${d} lines of code`,children:["Show ",d," lines..."]}),e[31]=l,e[32]=d,e[33]=p):p=e[33];let h;return e[34]!==u||e[35]!==f||e[36]!==m||e[37]!==p?(h=r.jsxs("div",{className:u,children:[f,m,p]}),e[34]=u,e[35]=f,e[36]=m,e[37]=p,e[38]=h):h=e[38],h}function Sk(n,e){return r.jsx("span",{style:{color:n.color},children:n.content},e)}var zs=function(n,e){return Number(n.toFixed(e))},Nk=function(n,e){return e},Qe=function(n,e,t){t&&typeof t=="function"&&t(n,e)},kk=function(n){return-Math.cos(n*Math.PI)/2+.5},Ck=function(n){return n},_k=function(n){return n*n},Tk=function(n){return n*(2-n)},Ek=function(n){return n<.5?2*n*n:-1+(4-2*n)*n},Ak=function(n){return n*n*n},Pk=function(n){return--n*n*n+1},Ik=function(n){return n<.5?4*n*n*n:(n-1)*(2*n-2)*(2*n-2)+1},Rk=function(n){return n*n*n*n},$k=function(n){return 1- --n*n*n*n},Mk=function(n){return n<.5?8*n*n*n*n:1-8*--n*n*n*n},Lk=function(n){return n*n*n*n*n},Ok=function(n){return 1+--n*n*n*n*n},Dk=function(n){return n<.5?16*n*n*n*n*n:1+16*--n*n*n*n*n},Tx={easeOut:kk,linear:Ck,easeInQuad:_k,easeOutQuad:Tk,easeInOutQuad:Ek,easeInCubic:Ak,easeOutCubic:Pk,easeInOutCubic:Ik,easeInQuart:Rk,easeOutQuart:$k,easeInOutQuart:Mk,easeInQuint:Lk,easeOutQuint:Ok,easeInOutQuint:Dk},Ex=function(n){typeof n=="number"&&cancelAnimationFrame(n)},yn=function(n){n.mounted&&(Ex(n.animation),n.isAnimating=!1,n.animation=null,n.velocity=null)};function Ax(n,e,t,s){if(n.mounted){var o=new Date().getTime(),i=1;yn(n),n.animation=function(){if(!n.mounted)return Ex(n.animation);var a=new Date().getTime()-o,l=a/t,c=Tx[e],d=c(l);a>=t?(s(i),n.animation=null):n.animation&&(s(d),requestAnimationFrame(n.animation))},requestAnimationFrame(n.animation)}}function zk(n){var e=n.scale,t=n.positionX,s=n.positionY;return!(Number.isNaN(e)||Number.isNaN(t)||Number.isNaN(s))}function $s(n,e,t,s){var o=zk(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):Ax(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 Fk(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 Bk=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}},hu=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=Fk(t,s,e),c=l.wrapperWidth,d=l.wrapperHeight,u=l.newContentWidth,f=l.newContentHeight,m=l.newDiffWidth,p=l.newDiffHeight,h=Bk(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,v=x.minPositionX,y=x.maxPositionX,b=x.minPositionY,j=x.maxPositionY;return v!=null&&(h.minPositionX=c*(1-e)+v*e),y!=null&&(h.maxPositionX=y*e),b!=null&&(h.minPositionY=d*(1-e)+b*e),j!=null&&(h.maxPositionY=j*e),h},Pr=function(n,e,t,s){return s?n<e?zs(e,2):n>t?zs(t,2):zs(n,2):zs(n,2)},_o=function(n,e){var t=hu(n,e);return n.bounds=t,t};function ni(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=Pr(n,l-f,d+f,s),h=Pr(e,c-m,u+m,s);return{x:p,y:h}}function Ya(n,e,t,s,o,i){var a=n.state,l=a.scale,c=a.positionX,d=a.positionY,u=s-l;if(!Number.isFinite(e)||!Number.isFinite(t))return console.error("Mouse X and Y position were not provided!"),{x:c,y:d};var f=c-e*u,m=d-t*u,p=ni(f,m,o,i,0,0,null);return p}var ep=1e-7;function si(n,e,t,s,o){var i=o?s:0,a=Math.max(e-i,ep),l=t+i;return!Number.isNaN(t)&&n>=l?l:!Number.isNaN(e)&&n<=a?a:Math.max(n,ep)}var tp=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=oi(i,t);return!(d||i.getAttribute("draggable")==="true"||i.getAttribute("contenteditable")==="true"||i.isContentEditable)},np=function(n){var e=n.isInitialized,t=n.isPanning,s=n.setup,o=s.panning.disabled,i=e&&t&&!o;return!!i},Uk=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}},Wk=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 Hk(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,v=t>f?d.offsetWidth:n.setup.minPositionX||0,y=s>p?d.offsetHeight:n.setup.minPositionY||0,b=Ya(n,v,y,o,n.bounds,l||c),j=b.x,S=b.y;return{scale:o,positionX:g?j:t,positionY:x?S:s}}}function Px(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=ni(e,t,l,i,s,o,a),p=m.x,h=m.y;n.setState(d,p,h)}}var qk=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}},Es=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 Kk=function(n){var e=n.mounted,t=n.wrapperComponent,s=n.contentComponent,o=n.setup,i=o.disabled,a=o.velocityAnimation,l=o.limitToBounds,c=n.state.scale,d=a.disabled;if(d||i||!e||!t||!s)return!1;if(!l)return!0;var u=t.offsetWidth<s.offsetWidth*c||t.offsetHeight<s.offsetHeight*c;return u},Vk=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 Gk(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 sp(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:Pr(n,i,a,o)}function Yk(n){var e=1,t=n.offsetWidth/window.innerWidth;return Number.isNaN(t)?e:Math.min(e,t)}var Dl=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 Xk(n,e,t){var s,o,i=Kk(n);if(i){var a=n.lastMousePosition,l=n.velocityTime,c=n.setup,d=n.wrapperComponent,u=c.velocityAnimation,f=u.maxStrengthMouse,m=u.maxStrengthTouch,p=u.sensitivityTouch,h=u.sensitivityMouse,g=Date.now();if(a&&l&&d){var x=Yk(d),v=(s={},s[hs.TOUCH]=p,s[hs.MOUSE]=h,s)[t],y=(o={},o[hs.TOUCH]=m,o[hs.MOUSE]=f,o)[t],b=e.x-a.x,j=e.y-a.y,S=Dl(b/x,y,v),k=Dl(j/x,y,v),C=g-l,N=b*b+j*j,E=Dl(Math.sqrt(N)/C,y,v);n.velocity={velocityX:S,velocityY:k,total:E}}n.lastMousePosition=e,n.velocityTime=g}}function Jk(n){var e=n.velocity,t=n.bounds,s=n.setup,o=n.wrapperComponent,i=Vk(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,v=x.lockAxisY,y=x.lockAxisX,b=g.animationType,j=h.sizeX,S=h.sizeY,k=h.velocityAlignmentTime,C=k,N=Gk(n,c),E=Math.max(N,C),T=Es(n,j),P=Es(n,S),_=T*o.offsetWidth/100,A=P*o.offsetHeight/100,I=d+_,$=u-_,R=f+A,M=m-A,O=n.state,D=new Date().getTime();Ax(n,b,E,function(z){var F=n.state,L=F.scale,H=F.positionX,U=F.positionY,W=new Date().getTime()-D,V=W/C,K=Tx[h.animationType],Y=1-K(Math.min(1,V)),X=1-z,G=H+a*X,J=U+l*X,Z=sp(G,O.positionX,H,y,p,u,d,$,I,Y),Q=sp(J,O.positionY,U,v,p,m,f,M,R,Y);if(H!==G||U!==J){n.setState(L,Z,Q);var te=n.props.onPanning;te&&te(Xe(n),{})}})}}function op(n,e){var t=n.state,s=t.scale,o=t.positionX,i=t.positionY;n.panStartPosition={x:o,y:i},yn(n),_o(n,s),window.TouchEvent!==void 0&&e instanceof TouchEvent?Wk(n,e):Uk(n,e)}function Ix(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=Hk(n);m&&$s(n,m,d,u)}}function rp(n,e,t,s){var o=n.startCoords,i=n.setup,a=i.autoAlignment,l=a.sizeX,c=a.sizeY;if(o){var d=qk(n,e,t),u=d.x,f=d.y,m=Es(n,l),p=Es(n,c);Xk(n,{x:u,y:f},s),Px(n,u,f,m,p)}}function Qk(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,v=!e&&t&&t.total>.1&&x;v?Jk(n):Ix(n)}}function gu(n,e,t,s){var o=n.setup,i=o.minScale,a=o.maxScale,l=o.limitToBounds,c=si(zs(e,2),i,a,0,!1),d=_o(n,c),u=Ya(n,t,s,c,d,l),f=u.x,m=u.y;return{scale:c,positionX:f,positionY:m}}function xu(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)&&Ix(n),!(h||!o||!n.mounted)){var g=e||o.offsetWidth/2,x=t||o.offsetHeight/2,v=s<a?a:l,y=gu(n,v,g,x);y&&$s(n,y,f,m)}}var un=function(){return un=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},un.apply(this,arguments)};function ip(n,e,t){for(var s=0,o=e.length,i;s<o;s++)(i||!(s in e))&&(i||(i=Array.prototype.slice.call(e,0,s)),i[s]=e[s]);return n.concat(i||Array.prototype.slice.call(e))}var zl={scale:1,positionX:0,positionY:0},Ds={disabled:!1,minPositionX:null,maxPositionX:null,minPositionY:null,maxPositionY:null,minScale:1,maxScale:8,limitToBounds:!0,centerZoomedOut:!1,centerOnInit:!1,disablePadding:!1,smooth:!0,detached:!1,wheel:{step:.015,disabled:!1,wheelDisabled:!1,touchPadDisabled:!1,activationKeys:[],excluded:[]},trackPadPanning:{disabled:!0,velocityDisabled:!1,lockAxisX:!1,lockAxisY:!1,activationKeys:[],excluded:[]},panning:{disabled:!1,velocityDisabled:!1,lockAxisX:!1,lockAxisY:!1,allowLeftClickPan:!0,allowMiddleClickPan:!0,allowRightClickPan:!0,activationKeys:[],excluded:[]},pinch:{step:5,disabled:!1,allowPanning:!0,excluded:[]},doubleClick:{disabled:!1,step:.7,mode:"zoomIn",animationType:"easeOut",animationTime:200,excluded:[]},zoomAnimation:{disabled:!1,size:.4,animationTime:200,animationType:"easeOut"},autoAlignment:{disabled:!1,sizeX:100,sizeY:100,animationTime:200,velocityAlignmentTime:400,animationType:"easeOut"},velocityAnimation:{disabled:!1,sensitivityMouse:1,sensitivityTouch:1.2,maxStrengthMouse:20,maxStrengthTouch:40,inertia:1,animationTime:300,maxAnimationTime:800,animationType:"easeOut"}},qc={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},Rx=function(n){var e,t,s,o,i,a,l,c,d,u=Math.max((e=n.minScale)!==null&&e!==void 0?e:Ds.minScale,1e-7),f=(t=n.maxScale)!==null&&t!==void 0?t:Ds.maxScale,m=(s=n.initialScale)!==null&&s!==void 0?s:zl.scale,p=Math.min(Math.max(m,u),f),h=Pr((o=n.initialPositionX)!==null&&o!==void 0?o:zl.positionX,(i=n.minPositionX)!==null&&i!==void 0?i:-1/0,(a=n.maxPositionX)!==null&&a!==void 0?a:1/0,n.minPositionX!=null||n.maxPositionX!=null),g=Pr((l=n.initialPositionY)!==null&&l!==void 0?l:zl.positionY,(c=n.minPositionY)!==null&&c!==void 0?c:-1/0,(d=n.maxPositionY)!==null&&d!==void 0?d:1/0,n.minPositionY!=null||n.maxPositionY!=null);return{previousScale:p,scale:p,positionX:h,positionY:g}},ap=function(n){var e=un({},Ds);return Object.keys(n).forEach(function(t){var s=t,o=typeof n[s]<"u",i=typeof Ds[s]<"u";if(i&&o){var a=Object.prototype.toString.call(Ds[s]),l=a==="[object Object]",c=a==="[object Array]";l?e[s]=un(un({},Ds[s]),n[s]):c?e[s]=ip(ip([],Ds[s],!0),n[s]):e[s]=n[s]}}),e.minScale<=0&&(e.minScale=1e-7),e},$x=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=si(zs(f,3),l,a,u,!1);return m};function Mx(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,v=(g/2-f)/d,y=$x(n,e,t),b=gu(n,y,x,v);if(!b)return console.error("Error during zoom event. New transformation state was not calculated.");var j=n.props,S=j.onZoomStart,k=j.onZoom,C=j.onZoomStop,N=new MouseEvent("mousemove",{bubbles:!0}),E=Xe(n);Qe(E,N,S),Qe(E,N,k),$s(n,b,p,o);var T=(a=(i=l.ownerDocument)===null||i===void 0?void 0:i.defaultView)!==null&&a!==void 0?a:typeof window<"u"?window:null;T&&T.setTimeout(function(){n.mounted&&Qe(Xe(n),N,C)},p)}function Lx(n,e,t,s){var o,i,a=n.setup,l=n.wrapperComponent,c=n.contentComponent,d=a.limitToBounds,u=a.centerOnInit,f=Rx(n.props),m=n.state,p=m.scale,h=m.positionX,g=m.positionY;if(l){var x=f.positionX,v=f.positionY;if(u&&c){var y=bu(f.scale,l,c);x=y.positionX,v=y.positionY}var b=hu(n,f.scale),j=ni(x,v,b,d,0,0,l),S={scale:f.scale,positionX:j.x,positionY:j.y};if(!(p===f.scale&&h===f.positionX&&g===f.positionY)){s==null||s();var k=n.props,C=k.onZoomStart,N=k.onZoom,E=k.onZoomStop,T=new MouseEvent("mousemove",{bubbles:!0}),P=Xe(n);Qe(P,T,C),Qe(P,T,N),$s(n,S,e,t);var _=(i=(o=l.ownerDocument)===null||o===void 0?void 0:o.defaultView)!==null&&i!==void 0?i:typeof window<"u"?window:null;_&&_.setTimeout(function(){n.mounted&&Qe(Xe(n),T,E)},e)}}}function Zk(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 e6(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=Zk(e,i,a,l),g=h.x,x=h.y,v=p.width/l.scale,y=p.height/l.scale,b=i.offsetWidth/v,j=i.offsetHeight/y,S=si(t||Math.min(b,j),u,f,0,!1),k=(m.width-v*S)/2,C=(m.height-y*S)/2,N=(m.left-g)*S+k+s,E=(m.top-x)*S+C+o,T=hu(n,S),P=ni(N,E,T,d,0,0,i),_=P.x,A=P.y;return{positionX:_,positionY:A,scale:S}}var t6=function(n){return function(e,t,s){e===void 0&&(e=.5),t===void 0&&(t=300),s===void 0&&(s="easeOut"),Mx(n,1,e,t,s)}},n6=function(n){return function(e,t,s){e===void 0&&(e=.5),t===void 0&&(t=300),s===void 0&&(s="easeOut"),Mx(n,-1,e,t,s)}},s6=function(n){return function(e,t,s,o,i){o===void 0&&(o=300),i===void 0&&(i="easeOut");var a=n.state,l=a.positionX,c=a.positionY,d=a.scale,u=n.wrapperComponent,f=n.contentComponent,m=n.setup.disabled;if(!(m||!u||!f)){var p={positionX:Number.isNaN(e)?l:e,positionY:Number.isNaN(t)?c:t,scale:Number.isNaN(s)?d:s};$s(n,p,o,i)}}},o6=function(n){return function(e,t){e===void 0&&(e=200),t===void 0&&(t="easeOut"),Lx(n,e,t)}},r6=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=bu(e||o.scale,i,a);$s(n,l,t,s)}}},i6=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),yn(n);var l=n.wrapperComponent,c=typeof e=="string"?document.getElementById(e):e;if(l&&c&&l.contains(c)){var d=e6(n,c,t,i,a);$s(n,d,s,o)}}},Kc=function(n){return{instance:n,state:n.state,zoomIn:t6(n),zoomOut:n6(n),setTransform:s6(n),resetTransform:o6(n),centerView:r6(n),zoomToElement:i6(n)}},a6=function(n){return{instance:n,state:n.state}},Xe=function(n){var e={};return Object.assign(e,a6(n)),Object.assign(e,Kc(n)),e},Fl=!1;function Bl(){try{var n={get passive(){return Fl=!0,!1}};return n}catch{return Fl=!1,Fl}}var Li=".".concat(qc.wrapperClass),oi=function(n,e){return e.some(function(t){return n.matches("".concat(Li," ").concat(t,", ").concat(Li," .").concat(t,", ").concat(Li," ").concat(t," *, ").concat(Li," .").concat(t," *"))})},Ir=function(n){n&&clearTimeout(n)},l6=function(n){return Number.parseFloat(n.toFixed(8))},Ox=function(n,e,t){var s=l6(t);return"translate(".concat(n,"px, ").concat(e,"px) scale(").concat(s,")")},bu=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 c6(n,e){n!=null&&(typeof n=="function"?n(e):n.current=e)}function d6(n){return function(e){n.forEach(function(t){typeof t=="function"?t(e):t!=null&&(t.current=e)})}}var Dx=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=oi(d,a);if(f)return!1;var m=n.isPressingKeys(n.setup.wheel.activationKeys);return!!m},u6=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=Dx(n,e);if(l)return!1;var c=e.target,d=oi(c,a);if(d)return!1;var u=n.isPressingKeys(i);return!!u},f6=function(n){return n?n.deltaY<0?1:-1:0};function m6(n,e){var t=f6(n),s=Nk(e,t);return s}function zx(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 p6=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=si(h,d,c,m,g&&!f);return x},Fx=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},h6=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=oi(a,o);return!c},g6=function(n){var e=n.setup.pinch.disabled,t=n.isInitialized,s=n.pinchStartDistance,o=t&&!e&&s!==null;return!!o},x6=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}},Bx=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))},b6=5,v6=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/b6),x=t+g,v=x===1/0?0:zs(x,10);return si(v,a,i,u,!f&&!c)},Ux=160,Wx=100,y6=function(n,e){var t=n.props,s=t.onWheelStart,o=t.onZoomStart;n.wheelStopEventTimer||(yn(n),Qe(Xe(n),e,s),Qe(Xe(n),e,o))},w6=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,v=m.step;if(!i)throw new Error("Component not mounted");e.cancelable&&e.preventDefault(),e.stopPropagation();var y=m6(e,null),b=h?v*Math.abs(e.deltaY):v,j=p6(n,y,b,!e.ctrlKey);if(c!==j){var S=_o(n,j),k=zx(e,i,c),C=x||g===0||u||p,N=d&&C,E=Ya(n,k.x,k.y,j,S,N),T=E.x,P=E.y;n.previousWheelEvent=e,n.setState(j,T,P),Qe(Xe(n),e,s),Qe(Xe(n),e,o)}},j6=function(n,e){var t=n.props,s=t.onWheelStop,o=t.onZoomStop;Ir(n.wheelAnimationTimer),n.wheelAnimationTimer=setTimeout(function(){n.mounted&&(xu(n,e.x,e.y),n.wheelAnimationTimer=null)},Wx);var i=Fx(n,e);i&&(Ir(n.wheelStopEventTimer),n.wheelStopEventTimer=setTimeout(function(){n.mounted&&(n.wheelStopEventTimer=null,Qe(Xe(n),e,s),Qe(Xe(n),e,o))},Ux))},S6=function(n,e){var t=n.props,s=t.onWheelStart,o=t.onPanningStart;n.wheelStopEventTimer||(yn(n),Qe(Xe(n),e,s),Qe(Xe(n),e,o))},N6=function(n,e){var t=n.props,s=t.onWheelStop,o=t.onPanningStop;Ir(n.wheelAnimationTimer),n.wheelAnimationTimer=setTimeout(function(){n.mounted&&(xu(n,e.x,e.y),n.wheelAnimationTimer=null)},Wx);var i=Fx(n,e);i&&(Ir(n.wheelStopEventTimer),n.wheelStopEventTimer=setTimeout(function(){n.mounted&&(n.wheelStopEventTimer=null,Qe(Xe(n),e,s),Qe(Xe(n),e,o))},Ux))},Hx=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}},k6=function(n,e){var t=Bx(e);n.pinchStartDistance=t,n.lastDistance=t,n.pinchStartScale=n.state.scale,n.isPanning=!1,n.isPinching=!0,n.pinchPreviousCenter=Hx(e),yn(n)},C6=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 v=x6(e,a,t);if(!(!Number.isFinite(v.x)||!Number.isFinite(v.y))){var y=Bx(e),b=v6(n,y),j=Hx(e),S=a/b,k=(j.x-((i==null?void 0:i.x)||0))*S,C=(j.y-((i==null?void 0:i.y)||0))*S;if(!(b===a&&k===0&&C===0)){n.pinchPreviousCenter=j;var N=_o(n,b),E=h||g===0||d,T=c&&E,P=Ya(n,v.x,v.y,b,N,T),_=P.x,A=P.y;if(n.pinchMidpoint=v,n.lastDistance=y,p.disabled||!x)n.setState(b,_,A);else{var I=f.sizeX,$=f.sizeY,R=Es(n,I,b),M=Es(n,$,b),O=_+k,D=A+C,z=ni(O,D,N,c,R,M,o),F=z.x,L=z.y;n.setState(b,F,L)}}}}},_6=function(n){var e=n.pinchMidpoint;n.velocity=null,n.lastDistance=null,n.pinchMidpoint=null,n.pinchStartScale=null,n.pinchStartDistance=null,n.isPinching=!1,xu(n,e==null?void 0:e.x,e==null?void 0:e.y)},qx=function(n,e){var t=n.props.onZoomStop,s=n.setup.doubleClick.animationTime;Ir(n.doubleClickStopEventTimer),n.doubleClickStopEventTimer=setTimeout(function(){n.doubleClickStopEventTimer=null,Qe(Xe(n),e,t)},s)},T6=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),Lx(n,a,l,function(){return Qe(Xe(n),e,o)}),qx(n,e)};function E6(n,e){return n==="toggle"?e===1?1:-1:n==="zoomOut"?-1:1}function A6(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 T6(n,e);if(!i)return console.error("No ContentComponent found");var x=E6(m,n.state.scale),v=$x(n,x,p);if(a!==v){Qe(Xe(n),e,c);var y=zx(e,i,a),b=gu(n,v,y.x,y.y);if(!b)return console.error("Error during zoom event. New transformation state was not calculated.");Qe(Xe(n),e,d),$s(n,b,h,g),qx(n,e)}}}var P6=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=oi(c,l);return!f},I6=(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&&_o(t,t.state.scale),t.setup=ap(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),yn(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=Dx(t,s);i&&(y6(t,s),w6(t,s),j6(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=u6(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,v=x.sizeX,y=x.sizeY,b=Es(t,v),j=Es(t,y);h===u&&g===f||(S6(t,s),Px(t,h,g,b,j),Qe(Xe(t),s,o),N6(t,s))}},this.onPanningStart=function(s){var o=t.setup.disabled,i=t.props.onPanningStart;if(!o){t.syncModifierKeys(s);var a=tp(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(),yn(t),op(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=np(t);if(a){var l=t.isPressingKeys(t.setup.panning.activationKeys);l&&(s.cancelable&&s.preventDefault(),s.stopPropagation(),rp(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&&(Qk(t,o),Qe(Xe(t),s,i))},this.onPinchStart=function(s){var o=t.setup.disabled,i=t.props.onPinchStart;if(!o){var a=h6(t,s);a&&(k6(t,s),yn(t),Qe(Xe(t),s,i))}},this.onPinch=function(s){var o=t.setup.disabled,i=t.props.onPinch;if(!o){var a=g6(t);a&&(s.cancelable&&s.preventDefault(),s.stopPropagation(),C6(t,s),Qe(Xe(t),s,i))}},this.onPinchStop=function(s){var o=t.props.onPinchStop;t.pinchStartScale&&(_6(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,yn(t);var u=s.touches,f=u.length===1,m=u.length===2,p=tp(t,s);if(f){if(!p)return;yn(t),op(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=np(t);if(!a)return;s.cancelable&&s.preventDefault(),s.stopPropagation();var l=s.touches[0];rp(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=P6(t,s);i&&A6(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=bu(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):Ox(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,_o(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),c6(t.props.ref,i)},this.props=e,this.setup=ap(this.props),this.state=Rx(this.props)}return n})(),Xa=ye.createContext(null),R6=function(n,e){return typeof n=="function"?n(e):n},$6=ye.forwardRef(function(n,e){var t=w.useRef(new I6(n)).current,s=R6(n.children,Kc(t));return w.useImperativeHandle(e,function(){return Kc(t)},[t]),w.useEffect(function(){t.update(n)},[t,n]),r.jsx(Xa.Provider,un({value:t},{children:s}))});ye.forwardRef(function(n,e){var t=w.useRef(null),s=w.useContext(Xa);return w.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",un({},n,{ref:d6([t,e])}))});function M6(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 L6=`.transform-component-module_wrapper__SPB86 {
11
+ position: relative;
12
+ width: -moz-fit-content;
13
+ width: fit-content;
14
+ height: -moz-fit-content;
15
+ height: fit-content;
16
+ overflow: hidden;
17
+ -webkit-touch-callout: none; /* iOS Safari */
18
+ -webkit-user-select: none; /* Safari */
19
+ -khtml-user-select: none; /* Konqueror HTML */
20
+ -moz-user-select: none; /* Firefox */
21
+ -ms-user-select: none; /* Internet Explorer/Edge */
22
+ user-select: none;
23
+ margin: 0;
24
+ padding: 0;
25
+ transform: translate3d(0, 0, 0);
26
+ }
27
+ .transform-component-module_content__FBWxo {
28
+ display: flex;
29
+ flex-wrap: wrap;
30
+ width: -moz-fit-content;
31
+ width: fit-content;
32
+ height: -moz-fit-content;
33
+ height: fit-content;
34
+ margin: 0;
35
+ padding: 0;
36
+ transform-origin: 0% 0%;
37
+ }
38
+ .transform-component-module_content__FBWxo img {
39
+ pointer-events: none;
40
+ }
41
+ .transform-component-module_infiniteGrid__Z-aP3 {
42
+ position: absolute;
43
+ inset: 0;
44
+ pointer-events: none;
45
+ background-image: radial-gradient(
46
+ circle,
47
+ rgba(0, 0, 0, 0.12) 1px,
48
+ transparent 1px
49
+ );
50
+ background-size: 20px 20px;
51
+ background-position: 0 0;
52
+ }
53
+ `,Ul={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo",infiniteGrid:"transform-component-module_infiniteGrid__Z-aP3"};M6(L6);var O6=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=w.useContext(Xa),g=h.init,x=h.cleanupWindowEvents,v=w.useRef(null),y=w.useRef(null),b=w.useRef(null);return w.useEffect(function(){var j=v.current,S=y.current;return j!==null&&S!==null&&g&&(g==null||g(j,S)),function(){x==null||x()}},[]),w.useEffect(function(){if(p){var j=b.current;if(j){var S=function(){var k=h.state,C=k.positionX,N=k.positionY;j.style.backgroundPosition="".concat(C,"px ").concat(N,"px")};return S(),h.onChange(S)}}},[p,h]),r.jsxs("div",un({},d,{ref:v,className:"".concat(qc.wrapperClass," ").concat(Ul.wrapper," ").concat(s),style:a},{children:[p&&r.jsx("div",{ref:b,className:Ul.infiniteGrid,"aria-hidden":!0}),r.jsx("div",un({},f,{ref:y,className:"".concat(qc.contentClass," ").concat(Ul.content," ").concat(i),style:un(un({},l),{transform:Ox(h.state.positionX,h.state.positionY,h.state.scale)})},{children:e}))]}))};function D6(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 z6(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,v=g.y<h.y+h.height&&g.y+g.height>h.y;return x&&v}var y=g.width*g.height;if(y<=0)return!1;var b=D6(h,g);return b/y>=p}ye.forwardRef(function(n,e){var t=n.x,s=n.y,o=n.width,i=n.height,a=n.margin,l=a===void 0?0:a,c=n.threshold,d=c===void 0?0:c,u=n.placeholder,f=u===void 0?null:u,m=n.onShow,p=n.onHide,h=n.children,g=n.className,x=n.style,v=w.useContext(Xa),y=w.useState(!1),b=y[0],j=y[1],S=w.useRef(!1),k=w.useRef(m),C=w.useRef(p);return k.current=m,C.current=p,w.useEffect(function(){var N=function(){var P,_,A=v.wrapperComponent;if(A){var I=z6({elementX:t,elementY:s,elementWidth:o,elementHeight:i,scale:v.state.scale,positionX:v.state.positionX,positionY:v.state.positionY,viewportWidth:A.offsetWidth,viewportHeight:A.offsetHeight,margin:l,threshold:d});I!==S.current&&(S.current=I,j(I),I?(P=k.current)===null||P===void 0||P.call(k):(_=C.current)===null||_===void 0||_.call(C))}};N();var E=v.onChange(N),T;return v.wrapperComponent||(T=v.onInit(function(){return N()})),function(){E(),T==null||T()}},[v,t,s,o,i,l,d]),b?r.jsx("div",un({ref:e,className:g,style:x},{children:h})):f?r.jsx(r.Fragment,{children:f}):null});const lp=8,F6=56;function Qo(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 vu(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]=w.useState(c),[f,m]=w.useState(100),p=w.useRef(null),h=w.useRef(null),g=s[d];let x;e[0]!==s.length?(x=be=>{u(Math.min(Math.max(be,0),s.length-1)),m(100)},e[0]=s.length,e[1]=x):x=e[1];const v=x;let y;e[2]!==v||e[3]!==d?(y=()=>v(d-1),e[2]=v,e[3]=d,e[4]=y):y=e[4];const b=y;let j;e[5]!==v||e[6]!==d?(j=()=>v(d+1),e[5]=v,e[6]=d,e[7]=j):j=e[7];const S=j;if(!g)return null;const k=s.length>1,C=d>0,N=d<s.length-1,E=f>100;let T;e[8]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{var be;return(be=p.current)==null?void 0:be.zoomIn()},e[8]=T):T=e[8];const P=T;let _;e[9]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{var be;return(be=p.current)==null?void 0:be.zoomOut()},e[9]=_):_=e[9];const A=_;let I;e[10]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{var be;return(be=p.current)==null?void 0:be.resetTransform()},e[10]=I):I=e[10];const $=I;let R;e[11]!==N||e[12]!==C||e[13]!==S||e[14]!==b?(R=be=>{be.key==="ArrowLeft"&&C?(be.preventDefault(),b()):be.key==="ArrowRight"&&N?(be.preventDefault(),S()):be.key==="+"||be.key==="="?(be.preventDefault(),P()):be.key==="-"?(be.preventDefault(),A()):be.key==="0"&&(be.preventDefault(),$())},e[11]=N,e[12]=C,e[13]=S,e[14]=b,e[15]=R):R=e[15];const M=R;let O;e[16]===Symbol.for("react.memo_cache_sentinel")?(O=be=>{if(be.pointerType==="mouse"||be.isPrimary===!1){h.current=null;return}h.current={x:be.clientX,y:be.clientY}},e[16]=O):O=e[16];const D=O;let z;e[17]!==N||e[18]!==C||e[19]!==S||e[20]!==b?(z=be=>{var ze;const Fe=h.current;h.current=null;const He=((ze=p.current)==null?void 0:ze.instance.state.scale)??1;if(!Fe||He>1.01)return;const We=be.clientX-Fe.x,Ee=be.clientY-Fe.y;Math.abs(We)<F6||Math.abs(We)<Math.abs(Ee)||(We>0&&C&&b(),We<0&&N&&S())},e[17]=N,e[18]=C,e[19]=S,e[20]=b,e[21]=z):z=e[21];const F=z;let L;e[22]!==i?(L=be=>{be||i()},e[22]=i,e[23]=L):L=e[23];let H;e[24]!==a?(H=be=>{be||a==null||a()},e[24]=a,e[25]=H):H=e[25];let U,W,V;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"),W=r.jsx(ls,{className:"sr-only",children:"Image viewer"}),V=r.jsx(cs,{className:"sr-only",children:"View and navigate images from this session."}),e[26]=U,e[27]=W,e[28]=V):(U=e[26],W=e[27],V=e[28]);let K;e[29]===Symbol.for("react.memo_cache_sentinel")?(K=r.jsx("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-md bg-white/[0.06]",children:r.jsx(K3,{className:"size-3.5 text-white/65","data-icon":"icon"})}),e[29]=K):K=e[29];const Y=g.label||g.alt||"Session image";let X;e[30]!==Y?(X=r.jsx("div",{className:"truncate text-xs font-medium text-white/90",children:Y}),e[30]=Y,e[31]=X):X=e[31];let G;e[32]!==k||e[33]!==s.length||e[34]!==d?(G=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]=G):G=e[35];let J;e[36]!==X||e[37]!==G?(J=r.jsxs("div",{className:"min-w-0 flex-1",children:[X,G]}),e[36]=X,e[37]=G,e[38]=J):J=e[38];const Z=f<=100;let Q;e[39]===Symbol.for("react.memo_cache_sentinel")?(Q=r.jsx(q1,{className:"size-3.5","data-icon":"icon"}),e[39]=Q):Q=e[39];let te;e[40]!==Z?(te=r.jsx(Qo,{label:"Zoom out",disabled:Z,onClick:A,children:Q}),e[40]=Z,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 oe=f>=lp*100;let re;e[44]===Symbol.for("react.memo_cache_sentinel")?(re=r.jsx(Bn,{className:"size-3.5","data-icon":"icon"}),e[44]=re):re=e[44];let ie;e[45]!==oe?(ie=r.jsx(Qo,{label:"Zoom in",disabled:oe,onClick:P,children:re}),e[45]=oe,e[46]=ie):ie=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 ce;e[48]===Symbol.for("react.memo_cache_sentinel")?(ce=r.jsx(tt,{className:"size-4","data-icon":"icon"}),e[48]=ce):ce=e[48];let ae;e[49]!==i?(ae=r.jsx(Qo,{label:"Close image viewer",onClick:i,children:ce}),e[49]=i,e[50]=ae):ae=e[50];let ue;e[51]!==te||e[52]!==ne||e[53]!==ie||e[54]!==ae?(ue=r.jsxs("div",{className:"flex items-center gap-1",children:[te,ne,ie,se,ae]}),e[51]=te,e[52]=ne,e[53]=ie,e[54]=ae,e[55]=ue):ue=e[55];let me;e[56]!==J||e[57]!==ue?(me=r.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b border-white/10 bg-black/20 px-2.5 sm:px-3",children:[K,J,ue]}),e[56]=J,e[57]=ue,e[58]=me):me=e[58];const de=g.id;let le,xe,pe;e[59]===Symbol.for("react.memo_cache_sentinel")?(le={mode:"toggle"},xe={step:.005},pe=(be,Fe)=>m(Math.round(Fe.scale*100)),e[59]=le,e[60]=xe,e[61]=pe):(le=e[59],xe=e[60],pe=e[61]);let ve,Te;e[62]===Symbol.for("react.memo_cache_sentinel")?(ve={width:"100%",height:"100%"},Te={width:"100%",height:"100%"},e[62]=ve,e[63]=Te):(ve=e[62],Te=e[63]);const $e=g.src,_e=g.alt,Ce=E?"cursor-grab active:cursor-grabbing":"cursor-zoom-in";let ke;e[64]!==Ce?(ke=q("max-h-full max-w-full select-none object-contain",Ce),e[64]=Ce,e[65]=ke):ke=e[65];let Me;e[66]!==g.alt||e[67]!==g.src||e[68]!==ke?(Me=r.jsx(O6,{wrapperStyle:ve,contentStyle:Te,contentClass:"flex items-center justify-center p-3 sm:p-6",children:r.jsx("img",{src:$e,alt:_e,draggable:!1,className:ke})}),e[66]=g.alt,e[67]=g.src,e[68]=ke,e[69]=Me):Me=e[69];let Oe;e[70]!==g.id||e[71]!==Me?(Oe=r.jsx($6,{ref:p,minScale:1,maxScale:lp,centerOnInit:!0,centerZoomedOut:!0,doubleClick:le,wheel:xe,onTransform:pe,children:Me},de),e[70]=g.id,e[71]=Me,e[72]=Oe):Oe=e[72];let Le;e[73]!==N||e[74]!==C||e[75]!==S||e[76]!==b||e[77]!==k?(Le=k&&r.jsxs(r.Fragment,{children:[r.jsx(Qo,{label:"Previous image",disabled:!C,onClick:b,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(_d,{className:"size-5","data-icon":"icon"})}),r.jsx(Qo,{label:"Next image",disabled:!N,onClick:S,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(Ye,{className:"size-5","data-icon":"icon"})})]}),e[73]=N,e[74]=C,e[75]=S,e[76]=b,e[77]=k,e[78]=Le):Le=e[78];let De;e[79]!==f?(De=f===100&&r.jsxs("div",{className:"pointer-events-none absolute bottom-2 left-1/2 hidden -translate-x-1/2 items-center gap-1.5 rounded-full bg-black/60 px-2.5 py-1 text-xs text-white/60 sm:flex",children:[r.jsx(Ea,{className:"size-3","data-icon":"inline-start"}),"Scroll or double-click to zoom · drag to pan"]}),e[79]=f,e[80]=De):De=e[80];let Ie;e[81]!==F||e[82]!==Oe||e[83]!==Le||e[84]!==De?(Ie=r.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden bg-black",onPointerDown:D,onPointerUp:F,children:[Oe,Le,De]}),e[81]=F,e[82]=Oe,e[83]=Le,e[84]=De,e[85]=Ie):Ie=e[85];let he;e[86]!==v||e[87]!==k||e[88]!==s||e[89]!==d?(he=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((be,Fe)=>r.jsxs(ee,{type:"button",variant:"ghost",onClick:()=>v(Fe),"aria-label":`View image ${Fe+1}`,"aria-current":Fe===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]",Fe===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:be.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:Fe+1})]},`${be.id}-${Fe}`))})}),e[86]=v,e[87]=k,e[88]=s,e[89]=d,e[90]=he):he=e[90];let ge;e[91]!==M||e[92]!==me||e[93]!==Ie||e[94]!==he?(ge=r.jsxs(as,{showCloseButton:!1,onKeyDown:M,className:U,children:[W,V,me,Ie,he]}),e[91]=M,e[92]=me,e[93]=Ie,e[94]=he,e[95]=ge):ge=e[95];let Se;return e[96]!==l||e[97]!==L||e[98]!==H||e[99]!==ge?(Se=r.jsx(is,{open:l,onOpenChange:L,onOpenChangeComplete:H,children:ge}),e[96]=l,e[97]=L,e[98]=H,e[99]=ge,e[100]=Se):Se=e[100],Se}const cp={0:"\0",b:"\b",f:"\f",n:`
54
+ `,r:"\r",t:" ",v:"\v"};function B6(n){return!!(n&&/[A-Za-z_$]/.test(n))}function da(n){return!!(n&&/[\w$]/.test(n))}function Wn(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 cp){s+=cp[a],o++;continue}if(a===`
55
+ `){o++;continue}if(a==="\r"){o+=n[o+1]===`
56
+ `?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 yu(n,e){if(n[e]!=="/")return null;if(n[e+1]==="/"){const t=n.indexOf(`
57
+ `,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 ri(n,e){const t=Wn(n,e);if(t)return{endIndex:t.endIndex,isString:!0};const s=yu(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=yu(n,t);if(s===null)break;t=s}return t}function Ja(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=ri(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 Kx(n,e){if(!B6(n[e]))return null;let t=e+1;for(;da(n[t]);)t++;return{value:n.slice(e,t),endIndex:t}}function U6(n,e,t){var u;const s=(u=t.trim().match(/^([A-Za-z_$][\w$]*)$/))==null?void 0:u[1];if(!s)return t;const o=n.slice(0,e),i=new RegExp(`\\b(?:const|let|var)\\s+${s.replace(/[$]/g,"\\$")}\\s*=`,"y");let a=null;for(let f=0;f<o.length;f++){const m=ri(o,f);if(m){f=m.endIndex-1;continue}i.lastIndex=f;const p=i.exec(o);p&&(a=p,f+=p[0].length-1)}if(!a||a.index===void 0)return t;const l=Zt(o,a.index+a[0].length),c=o[l];if(c==="{"||c==="["||c==="("){const f=Ja(o,l);if(f!==null)return o.slice(l,f+1).trim()}const d=Wn(o,l);return d?o.slice(l,d.endIndex).trim():t}function Vx(n){const e=[];let t="";for(let s=0;s<n.length;s++){const o=ri(n,s);if(o){o.isString&&(t="literal"),s=o.endIndex-1;continue}const i=t===".";if(/\s/.test(n[s])||(t=n[s]),i||!n.startsWith("tools",s)||da(n[s-1])||da(n[s+5]))continue;let a=Zt(n,s+5),l="";if(n[a]==="."){a=Zt(n,a+1);const u=Kx(n,a);if(!u)continue;l=u.value,a=u.endIndex}else if(n[a]==="["){a=Zt(n,a+1);const u=Wn(n,a);if(!u||(a=Zt(n,u.endIndex),n[a]!=="]"))continue;l=u.value,a++}else continue;if(a=Zt(n,a),n[a]!=="(")continue;const c=Ja(n,a);if(c===null){e.push({name:l,argumentSource:n.slice(a+1).trim(),startIndex:s});break}const d=n.slice(a+1,c).trim();e.push({name:l,argumentSource:U6(n,s,d),startIndex:s})}return e}function Gx(n,e){return Wn(n,e)??Kx(n,e)}function W6(n,e,t){const s=[];for(let o=e;o<t;o++){const i=ri(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 Qa(n,e){let t=Zt(n,0);for(;n[t]==="(";)t=Zt(n,t+1);if(n[t]!=="{")return null;const s=Ja(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=Gx(n,o);if(!i){o++;continue}if(o=Zt(n,i.endIndex),n[o]!==":"){o++;continue}const a=Zt(n,o+1),l=W6(n,a,s);if(i.value===e)return n.slice(a,l).trim();o=l+1}return null}function Yx(n,e,t){const s=[];for(let o=0;o<n.length;o++){const i=yu(n,o);if(i!==null){o=i-1;continue}const a=Gx(n,o);if(a){if(a.value===e&&!da(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 wu(n,e){return Yx(n,e,t=>{var s;return((s=Wn(n,t))==null?void 0:s.value)??null})}function Xx(n,e){return Yx(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 Jx(n){const e=Zt(n,0);if(!n.slice(e).trim())return 0;if(n[e]!=="[")return 1;const t=Ja(n,e);if(t===null)return 1;let s=0,o=!1;const i=[];for(let a=e+1;a<t;a++){const l=ri(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)}const H6=["cmd","command","workdir","description","timeout","yield_time_ms","max_output_tokens","session_id","chars","tty","login","shell","path","file_path","pattern","query","url","prompt","message","target","task_name","agent_id","agent_ids","model","agent_type","fork_turns","reasoning_effort","questions","plan","explanation","search_query","image_query","open","click","find","screenshot","finance","weather","sports","time","response_length","server","uri","cursor","name","code","old_string","new_string","content","replace_all","patch","input"];function dp(n){try{return{value:JSON.parse(n)}}catch{}if(n.startsWith("`")&&n.includes("${"))return null;const e=Wn(n,0);return e&&e.endIndex===n.length?{value:e.value}:null}function ju(n){return typeof n.input.raw=="string"&&/(?:^|__|[.:/])exec$/.test(n.name)}function Qx(n){return typeof n.raw!="string"?[]:Vx(n.raw).map(({name:e,argumentSource:t})=>{const s=t.trim(),o=dp(s);if(o){const a=o.value;return a&&typeof a=="object"&&!Array.isArray(a)?{name:e,input:a}:{name:e,input:typeof a=="string"?{raw:a}:{value:a}}}const i={raw:t};for(const a of H6){const l=Qa(s,a);if(l===null)continue;const c=dp(l);c&&(i[a]=c.value)}return{name:e,input:i}})}function Vc(n){return n.type==="user"}function Su(n){return n.type==="assistant"}function up(n){return n.type==="progress"}function fp(n){return n.type==="system"}function Zx(n){return n.type==="summary"}function q6(n){return n.type==="queue-operation"}function e0(n){return n.type==="attachment"}function K6(n){return n.type==="user"&&n.isCompactSummary===!0}function t0(n){return n.type==="system"&&n.subtype==="compact_boundary"}function mp(n,e){let t=0;for(const s of n)e[s.name]=(e[s.name]??0)+1,s.isError&&t++;return t}function pp(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 Za(n){return{totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:n}}function el(n){const e=Za(n.length);for(const t of n){t.tokenUsage&&pp(e,t.tokenUsage),t.durationMs&&(e.totalDurationMs+=t.durationMs),e.errorCount+=mp(t.toolCalls,e.toolCallCounts);for(const s of t.subAgentActivity)e.errorCount+=mp(s.toolCalls,e.toolCallCounts),s.tokenUsage&&pp(e,s.tokenUsage)}return e}function bo(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 V6=/<(agent-message|teammate-message)([^>]*)>([\s\S]*?)<\/\1>/g,G6=[/\bteammate_id=(?:"([^"]*)"|'([^']*)')/,/\bfrom=(?:"([^"]*)"|'([^']*)')/];function Y6(n){for(const e of G6){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 X6(n){return n.replace(/^\s*<(?:agent-message|teammate-message)\b[^>]*>/,"").replace(/<\/(?:agent-message|teammate-message)>\s*$/,"").trim()}function Rr(n){let e=null,t=!1;const s=n.replace(V6,(o,i,a,l)=>(t=!0,e===null&&(e=Y6(a)),l.trim()));return{sender:e,matched:t,body:t?s.trim():n}}const J6=[/\bblocking question\b/,/\bbefore i touch\b/,/\bshould i\b/,/\btell me one of\b/,/\byour call\b/,/\bwho owns\b/,/\bconfirm whether\b/],Q6=[/(?:^|[,;:.!?—–-]\s*)tell me\b/,/(?:^|[,;:.!?—–-]\s*)say so\b/],Z6=200,eC=/\bhttps?:\/\/\S+/g;function tC(n){const e=n.trim();if(!e)return!1;const t=e.slice(0,Z6).toLowerCase();if(J6.some(i=>i.test(t)))return!0;const o=e.slice(e.lastIndexOf(`
58
+ `)+1).slice(-200).replace(eC,"").toLowerCase();return o.includes("?")||Q6.some(i=>i.test(o))}function tl(n){return typeof n=="string"?n:n.filter(e=>e.type==="text").map(e=>e.text).join(`
59
+ `)}function hp(n){return n?typeof n=="string"?n:n.map(e=>e.type==="text"?e.text:"").filter(Boolean).join(`
60
+ `):""}function n0(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 nC=/<task-notification>[\s\S]*?<\/task-notification>/g,sC=/<[^>]*>/g;function oC(n){var t;if(((t=n.origin)==null?void 0:t.kind)==="task-notification")return!0;const e=tl(n.message.content);return e.includes("<task-notification>")?e.replace(nC,"").replace(sC,"").trim()==="":!1}function rC(n){if(!e0(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:tl(t);if(!n0(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??Rr(s).body}}if((o==null?void 0:o.kind)==="human")return{raw:s,sender:null,body:s};const i=Rr(s);return{raw:s,sender:i.sender,body:i.body}}const iC=[["attributionAgent","agent"],["attributionSkill","skill"],["attributionPlugin","plugin"],["attributionMcpServer","mcpServer"],["attributionMcpTool","mcpTool"]];function aC(n,e){let t=n;for(const[s,o]of iC){const i=e[s];typeof i!="string"||!i||(t={...t,[o]:i})}return t}const lC=/^This session is being continued from a previous conversation[\s\S]*?\n\nSummary:\s*\n/,cC=/\n+(?:If you need specific details from before compaction|(?:Please c|C)ontinue the conversation from where it left off)[\s\S]*$/;function dC(n){return tl(n).trim().replace(lC,"").replace(cC,"").trim()}function uC(n){if(n)return{trigger:n.trigger,preTokens:n.preTokens,postTokens:n.postTokens}}function Oi(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 fC(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 v=n[g];if(v.kind==="tool_calls"){const y=v.toolCalls.findIndex(b=>b.name==="ExitPlanMode");if(y!==-1){d.push(...v.toolCalls.slice(0,y)),m=v.toolCalls[y],p=m.input.path?String(m.input.path):void 0,m.result!==null&&(h=m.isError?"rejected":"approved");const b=v.toolCalls.slice(y+1);e.push({kind:"plan_mode",plan:a,planFilePath:p,status:h,toolCalls:d,timestamp:l}),e.push(...x),b.length>0&&e.push({kind:"tool_calls",toolCalls:b,timestamp:v.timestamp}),t=g+1;break}else d.push(...v.toolCalls),g++}else if(v.kind==="hook_event"||v.kind==="text"||v.kind==="queued_prompt"||v.kind==="agent_message")x.push(v),g++;else break}m||(e.push({kind:"plan_mode",plan:a,planFilePath:void 0,status:"pending",toolCalls:d,timestamp:l}),e.push(...x),t=g);continue}}}e.push(s),t++}return e}function mC(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 Nu(n){var s;const e=n.map(mC),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 pC(n){const e=[];let t=!1;for(let s=0;s<n.length;s++){const o=n[s];if(Zx(o)||t0(o)){t=!1;continue}if(Vc(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}Su(o)&&!t&&(e.push(s),t=!0)}return e}function s0(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 v(N,E){let T=x.get(N);T||(T=new Map,x.set(N,T)),T.set(E,(T.get(E)??0)+1)}function y(N,E){const T=x.get(N),P=T==null?void 0:T.get(E);return!T||!P?!1:(P===1?T.delete(E):T.set(E,P-1),!0)}function b(){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 j(N){if(!i)return;const E=f.get(N);if(!E||E.length===0)return;i.subAgentActivity.push(...E),f.delete(N);const T=p.has(N)?"background_agent":"sub_agent",P=m.get(N);if(P)P.messages.push(...E);else{const _={kind:T,messages:[...E]};i.contentBlocks.push(_),m.set(N,_)}}function S(){if(i){for(const N of i.toolCalls)j(N.id);for(const[N]of f)j(N);for(const N of i.contentBlocks)if(N.kind==="hook_event")for(const E of N.events){if(!(E.eventName==="PostToolUse"||E.eventName.startsWith("PostToolUse:"))||!E.toolUseId)continue;const P=i.toolCalls.find(_=>_.id===E.toolUseId);P&&(E.updatedToolOutput&&(P.outputReplacedByHook=!0),E.durationMs!==void 0&&(P.hookDurationMs=(P.hookDurationMs??0)+E.durationMs))}i.contentBlocks=fC(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(Zx(N)){S(),a={summary:N.summary};continue}if(t0(N)){S(),a={meta:uC(N.compactMetadata)};continue}if(K6(N)){S(),s=o,i=Oi(N,null),i.compactionSummary=dC(N.message.content),i.compactionMeta=a==null?void 0:a.meta,a=null;continue}if(fp(N)&&N.subtype==="away_summary"&&N.content){c={content:N.content,timestamp:N.timestamp};continue}if(q6(N)){if(i&&N.operation==="enqueue"&&n0(N.content)){const E=Rr(N.content);g.push({turn:i,content:N.content,timestamp:N.timestamp,sender:E.sender,body:E.body}),v(i,N.content)}continue}if(e0(N)){const E=rC(N);i&&E!==null&&!y(i,E.raw)&&g.push({turn:i,content:E.raw,timestamp:((k=N.attachment)==null?void 0:k.timestamp)??N.timestamp,sender:E.sender,body:E.body});continue}if(g.length>0){const E=Vc(N)&&!N.isMeta?N.message.content:null;if(typeof E=="string"){const T=g.findIndex(P=>P.content===E);if(T>=0){const[P]=g.splice(T,1);y(P.turn,P.content)}}b()}if(Vc(N)&&!N.isMeta){const E=N.message.content;if(typeof E!="string"&&Array.isArray(E)&&E.some(P=>P.type==="tool_result")&&i){for(const _ of E)if(_.type==="tool_result"){const A=d.get(_.tool_use_id);A&&(A.turn.toolCalls[A.index].result=hp(_.content),A.turn.toolCalls[A.index].isError=_.is_error===!0,d.delete(_.tool_use_id))}const P=N.toolUseResult;if(P!=null&&P.agentId){const _=((C=E.find(O=>O.type==="tool_result"))==null?void 0:C.tool_use_id)??"",A=h.get(_),I=p.has(_),$=[];if(Array.isArray(P.content))for(const O of P.content)O.type==="text"&&$.push(O.text);const R={agentId:P.agentId,parentToolUseId:_||void 0,agentName:(A==null?void 0:A.name)??null,subagentType:(A==null?void 0:A.subagentType)??null,type:"assistant",content:P.content,toolCalls:[],thinking:[],text:$,timestamp:N.timestamp??"",tokenUsage:P.usage?{input_tokens:P.usage.input_tokens??0,output_tokens:P.usage.output_tokens??0,cache_creation_input_tokens:P.usage.cache_creation_input_tokens??0,cache_read_input_tokens:P.usage.cache_read_input_tokens??0}:null,model:null,isBackground:I,prompt:P.prompt,status:P.status,durationMs:P.totalDurationMs,toolUseCount:P.totalToolUseCount};if(!m.get(_)){i.subAgentActivity.push(R);const D={kind:I?"background_agent":"sub_agent",messages:[R]};i.contentBlocks.push(D),m.set(_,D)}}continue}if(oC(N)){const T={kind:"task_notification",content:tl(E),timestamp:N.timestamp};if(i){i.contentBlocks.push(T);continue}s=o,i=Oi(N,null),i.contentBlocks.push(T),l(i);continue}S(),s=o,i=Oi(N,N.message.content),l(i),c&&(i.contentBlocks.push({kind:"recap",content:c.content,timestamp:c.timestamp}),c=null);continue}if(Su(N)){let E=function(){I.length>0&&($.contentBlocks.push({kind:"tool_calls",toolCalls:[...I],timestamp:_}),I.length=0)},T=function(){if(A.length>0){const R=$.contentBlocks[$.contentBlocks.length-1];R&&R.kind==="thinking"?R.blocks.push(...A):$.contentBlocks.push({kind:"thinking",blocks:[...A],timestamp:_}),A.length=0}};i||(s=o,i=Oi(N,null),l(i)),i.model=N.message.model,N.effort&&(i.effort=N.effort),i.attribution=aC(i.attribution,N);const P=N.message.id;u.has(P)||(u.add(P),i.tokenUsage=bo(i.tokenUsage,N.message.usage));const _=N.timestamp??"",A=[],I=[],$=i;for(const R of N.message.content)if(R.type==="thinking"){E();const M=R;if(!M.thinking)continue;i.thinking.push(M),A.push(M)}else if(R.type==="text"){E(),T();const M=/<thinking>([\s\S]*?)<\/thinking>/g;let O=R.text,D;for(;(D=M.exec(R.text))!==null;){const z=D[1].trim();if(z){const F={type:"thinking",thinking:z,signature:""};i.thinking.push(F),i.contentBlocks.push({kind:"thinking",blocks:[F],timestamp:_})}O=O.replace(D[0],"")}if(O=O.trim(),O){i.assistantText.push(O);const z=i.contentBlocks[i.contentBlocks.length-1];z&&z.kind==="text"?z.text.push(O):i.contentBlocks.push({kind:"text",text:[O],timestamp:_})}}else if(R.type==="tool_use"){T();const M={id:R.id,name:R.name,input:R.input,result:null,isError:!1,timestamp:N.timestamp??""},O=i.toolCalls.length;if(i.toolCalls.push(M),I.push(M),d.set(R.id,{turn:i,index:O}),R.name==="Task"||R.name==="Agent"){const D=R.input;D.run_in_background===!0&&p.add(R.id),h.set(R.id,{name:D.name??null,subagentType:D.subagent_type??null})}}T(),E();continue}if(up(N)&&N.data.type==="agent_progress"){const E=N.data,T=N.parentToolUseID??"";let P=null;if(E.message.type==="assistant"){const R=E.message.message,M=R.id,O=R.usage;O&&M&&!u.has(M)&&(u.add(M),P={input_tokens:O.input_tokens??0,output_tokens:O.output_tokens??0,cache_creation_input_tokens:O.cache_creation_input_tokens??0,cache_read_input_tokens:O.cache_read_input_tokens??0})}const _=E.message.type==="assistant"?E.message.message.model??null:null,A=h.get(T),I={agentId:E.agentId,parentToolUseId:T||void 0,agentName:(A==null?void 0:A.name)??null,subagentType:(A==null?void 0:A.subagentType)??null,type:E.message.type,content:E.message.message.content,toolCalls:[],thinking:[],text:[],timestamp:E.message.timestamp??N.timestamp??"",tokenUsage:P,model:_,isBackground:p.has(T)};if(E.message.type==="assistant"){const R=E.message.message.content;if(Array.isArray(R))for(const M of R)M.type==="thinking"?I.thinking.push(M.thinking):M.type==="text"?I.text.push(M.text):M.type==="tool_use"&&I.toolCalls.push({id:M.id,name:M.name,input:M.input,result:null,isError:!1,timestamp:E.message.timestamp??N.timestamp??""})}else if(E.message.type==="user"){const R=E.message.message.content;if(Array.isArray(R)){for(const M of R)if(M.type==="tool_result"){const O=f.get(T);if(O)for(const D of O){const z=D.toolCalls.find(F=>F.id===M.tool_use_id);z&&(z.result=hp(M.content),z.isError=M.is_error===!0)}}}}let $=f.get(T);$||($=[],f.set(T,$)),$.push(I),i&&j(T);continue}if(up(N)&&N.data.type==="hook_progress"){const E=N.data,T=String(E.hook_event_name??E.hookEvent??"unknown"),P=E.hookSpecificOutput,_={eventName:T,source:E.source!==void 0?String(E.source):void 0,toolName:E.tool_name!==void 0?String(E.tool_name):void 0,toolUseId:E.tool_use_id!==void 0?String(E.tool_use_id):void 0,command:E.command!==void 0?String(E.command):void 0,output:E.output!==void 0?String(E.output):void 0,stderr:E.stderr!==void 0?String(E.stderr):void 0,exitCode:E.exit_code!==void 0?Number(E.exit_code):void 0,decision:E.decision!==void 0?String(E.decision):void 0,durationMs:E.duration_ms!==void 0?Number(E.duration_ms):void 0,updatedToolOutput:(P==null?void 0:P.updatedToolOutput)!==void 0?String(P.updatedToolOutput):void 0,sessionTitle:(P==null?void 0:P.sessionTitle)!==void 0?String(P.sessionTitle):void 0,worktreePath:(P==null?void 0:P.worktreePath)!==void 0?String(P.worktreePath):void 0,timestamp:N.timestamp??""};if(i){const A=i.contentBlocks[i.contentBlocks.length-1];A&&A.kind==="hook_event"?A.events.push(_):i.contentBlocks.push({kind:"hook_event",events:[_],timestamp:N.timestamp})}continue}if(fp(N)&&N.subtype==="turn_duration"&&i){N.durationMs!==void 0&&N.durationMs!==null&&(i.durationMs=(i.durationMs??0)+N.durationMs);continue}}return b(),S(),{turns:Nu(e),turnStartIndices:t}}function o0(n){return s0(n).turns}function gp(){return!0}function r0(n){const e=[];for(const t of n){const s=t.trim();if(s)try{e.push(JSON.parse(s))}catch{}}return e}function i0(n){return r0(n.split(`
61
+ `))}function a0(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),Su(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 hC(n){return a0(r0(n))}function gC(n,e){const t=i0(n),s=a0(t),o=o0(t),i=e!=null&&e.skipStats?Za(o.length):el(o);return{...s,turns:o,stats:i,rawMessages:e!=null&&e.skipStats?[]:t,agentKind:"claude"}}function xC(n,e){const t=i0(e);if(t.length===0)return n;const s=n.rawMessages,o=[...s,...t],i=pC(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=o0(o.slice(d)),m=Nu([...u,...f]),p=el(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 l0="<task-notification>",bC=/<task-id>([^<]+)<\/task-id>/g,vC=/<tool-use-id>([^<]+)<\/tool-use-id>/g;function Ln(n){return typeof n=="object"&&n!==null}function yC(n){const e=Ln(n.message)?n.message:null,t=e==null?void 0:e.content;return typeof t=="string"?[t]:Array.isArray(t)?t.filter(s=>Ln(s)&&typeof s.text=="string").map(s=>s.text):[]}function wC(n){const e=[],t=new Set,s=new Set,o=new Set;function i(a,l){if(a.includes(l0)){for(const c of a.matchAll(bC))t.add(c[1]),l==null||l.add(c[1]);for(const c of a.matchAll(vC))t.add(c[1]),l==null||l.add(c[1])}}for(const a of n){if(a.type==="user"){const l=Ln(a.toolUseResult)?a.toolUseResult:null;if((l==null?void 0:l.status)==="async_launched"){const c=Ln(a.message)?a.message:null,u=(Array.isArray(c==null?void 0:c.content)?c.content:[]).filter(p=>Ln(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 yC(a))i(c,o);continue}if(a.type==="assistant"){const l=Ln(a.message)?a.message:null,c=Array.isArray(l==null?void 0:l.content)?l.content:[];for(const d of c){if(!Ln(d)||d.type!=="tool_use"||d.name!=="TaskStop")continue;const u=Ln(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=Ln(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 jC(n,e){return{status:"awaiting_agents",pendingQueue:e,pendingAgents:n.length,pendingAgentDescriptions:n.filter(t=>t.length>0)}}function SC(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=wC(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(l0))continue;const u=d.operation;u==="enqueue"?e++:(u==="dequeue"||u==="remove")&&e--;continue}if(d.type==="attachment"){const u=Ln(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 jC(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 NC(n,e,t){const s=typeof n.sessionId=="string"?n.sessionId:"";return{record:{...n,sessionId:e,branchedFrom:{sessionId:s,turnIndex:t}},originalId:s}}function kC(n){return s0(n).turnStartIndices}function c0(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})}function xp(n){return n.includes("*** Begin Patch")&&n.includes("*** End Patch")}function CC(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=Wn(n,a);if(l){if(xp(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=Wn(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||!xp(d)||s.has(d)||(s.add(d),t.push(d))}return t}function bp(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 vp(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=bp(f.filePath,s),x=bp(h||f.filePath,s),v=p.split(/^@@.*$/m).filter(S=>S.trim()),y=[],b=[];for(const S of v)for(const k of S.split(`
62
+ `))k.startsWith("-")?y.push(k.slice(1)):k.startsWith("+")?b.push(k.slice(1)):k.startsWith(" ")&&(y.push(k.slice(1)),b.push(k.slice(1)));const j=a.length>1?`${e}:file-${u}`:e;f.action==="Add File"?o.push({id:j,name:"Write",input:{file_path:x,content:b.join(`
63
+ `)},result:null,isError:!1,timestamp:t}):f.action==="Delete File"?o.push({id:j,name:"Edit",input:{file_path:x,old_string:y.join(`
64
+ `),new_string:""},result:null,isError:!1,timestamp:t}):o.push({id:j,name:"Edit",input:{file_path:x,...h?{old_path:g}:{},old_string:y.join(`
65
+ `),new_string:b.join(`
66
+ `)},result:null,isError:!1,timestamp:t})}return o}function d0(n,e,t,s,o=""){return n==="apply_patch"?vp(e,t,s,o):CC(e).flatMap((i,a)=>vp(i,`${t}:patch-${a}`,s,o))}function _C(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 Fn(n){return typeof n=="object"&&n!==null}const TC=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"]]),EC=new Set(["exec","exec_command","write_stdin","apply_patch","update_plan","view_image","request_user_input","request_user_input_async","tool_search","list_mcp_resources","list_mcp_resource_templates","read_mcp_resource","request_plugin_install","create_goal","get_goal","update_goal","wait"]);function Cn(n){if(n.startsWith("mcp__"))return n;const e=n.split(/(?:__|[.:/])+/).filter(Boolean).at(-1)??n;return TC.get(e)??(EC.has(e)?e:n)}function AC(n){const e=n==null?void 0:n.match(/Process exited with code (\d+)/);return e?e[1]!=="0":!1}function PC(n){return n==="request_user_input"||n==="request_user_input_async"}function IC(n){const t=(Array.isArray(n.questions)?n.questions:[n]).filter(s=>Fn(s)).map(s=>{const o=typeof s.question=="string"?s.question:typeof s.title=="string"?s.title:"",i=Array.isArray(s.options)?s.options:[];return{question:o,...typeof s.header=="string"&&s.header?{header:s.header}:{},options:i.map(a=>typeof a=="string"?{label:a}:!Fn(a)||typeof a.label!="string"?null:{label:a.label,...typeof a.description=="string"&&a.description?{description:a.description}:{}}).filter(a=>a!==null)}}).filter(s=>s.question);return t.length>0?{...n,questions:t}:n}function RC(n){return{todos:(Array.isArray(n.plan)?n.plan:[]).filter(s=>Fn(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 $C(n){if(n.type!=="image"&&n.type!=="input_image"&&n.type!=="image_url")return null;const e=Fn(n.source)?n.source:n,t=e.media_type??e.mimeType;if(typeof t=="string"&&t.startsWith("image/")&&typeof e.data=="string"&&e.data)return{type:"image",source:{type:"base64",media_type:t,data:e.data}};const s=Fn(n.image_url)?n.image_url.url:n.image_url,o=typeof s=="string"?/^data:(image\/[^;,]+);base64,(.+)$/is.exec(s):null;return o?{type:"image",source:{type:"base64",media_type:o[1].toLowerCase(),data:o[2]}}:null}function yp(n){if(typeof n=="string")return{parts:[n],text:n,images:[]};if(!Array.isArray(n)){const s=n==null?"":JSON.stringify(n);return{parts:[s],text:s,images:[]}}const e=[],t=[];for(const s of n){if(!Fn(s))continue;typeof s.text=="string"&&e.push(s.text);const o=$C(s);o&&t.push(o)}return{parts:e,text:e.join(""),images:t}}const MC=/^Script (?:completed|failed|running)\b/;function u0(n,e){Fn(n)&&(n.status==="rejected"?e.push(1):n.status==="fulfilled"?u0(n.value,e):typeof n.exit_code=="number"&&e.push(n.exit_code))}function LC(n){const e=n[0]??"";if(!MC.test(e))return;if(e.startsWith("Script failed"))return!0;const t=[];for(const s of n.slice(1)){let o;try{o=JSON.parse(s)}catch{continue}for(const i of Array.isArray(o)?o:[o])u0(i,t)}return t.length>0?t.some(s=>s!==0):void 0}function Gc(n){const e=yp(n);let t=Fn(n)&&!Array.isArray(n)?n:null;try{const d=t??JSON.parse(e.text);Fn(d)&&!Array.isArray(d)&&(t=d)}catch{}const s=t&&("output"in t||"content"in t)?yp(t.output??t.content):e,o=s===e?e.images:[...e.images,...s.images],i=Fn(t==null?void 0:t.metadata)?t.metadata:null,a=(i==null?void 0:i.exit_code)??(t==null?void 0:t.exit_code),l=typeof(t==null?void 0:t.isError)=="boolean"?t.isError:typeof(t==null?void 0:t.is_error)=="boolean"?t.is_error:void 0,c=l===!0||(typeof a=="number"?a!==0:l??LC(e.parts)??AC(s.text));return{text:s.text,isError:c,...o.length>0?{images:o}:{}}}const OC=["# AGENTS.md instructions for ","<recommended_plugins>","<environment_context>","<permissions instructions>","<collaboration_mode>","<skills_instructions>"];function DC(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 ku(n){try{return JSON.parse(n)}catch{return null}}function Ze(n){return typeof n=="object"&&n!==null}function To(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 ua(n,e){const t=n==null?void 0:n.content;return Array.isArray(t)?t.filter(s=>Ze(s)&&s.type===e&&typeof s.text=="string").map(s=>s.text).join(`
67
+ `).trim():""}const zC=/^data:(image\/(?:png|jpeg|gif|webp));base64,(.+)$/is,FC=/^data:(audio\/(?:wav|x-wav|mpeg|mp4|webm|ogg));base64,(.+)$/is;function f0(n){if(typeof n!="string")return null;const e=zC.exec(n);return!(e!=null&&e[1])||!e[2]?null:{type:"image",source:{type:"base64",media_type:e[1].toLowerCase(),data:e[2]}}}function m0(n){if(typeof n!="string")return null;const e=FC.exec(n);return!(e!=null&&e[1])||!e[2]?null:{type:"audio",source:{type:"base64",media_type:e[1].toLowerCase(),data:e[2]}}}function BC(n){return Array.isArray(n.images)?n.images.map(f0).filter(e=>e!==null):[]}function UC(n){return Array.isArray(n.audio)?n.audio.map(m0).filter(e=>e!==null):[]}function p0(n){return Array.isArray(n.content)?n.content.filter(e=>Ze(e)&&e.type==="input_image").map(e=>f0(e.image_url)).filter(e=>e!==null):[]}function h0(n){return Array.isArray(n.content)?n.content.filter(e=>Ze(e)&&e.type==="input_audio").map(e=>m0(e.audio_url)).filter(e=>e!==null):[]}function wp(n,e,t=[],s=[],o=[]){const i=[...s.map(l=>`
68
+ ![image](<${l}>)`),...o.map(l=>`
69
+ [audio attachment](<${l}>)`)].join(""),a=n+i;return e.length===0&&t.length===0?a:[...e,...t,...a?[{type:"text",text:a}]:[]]}function WC(n){var a,l;const e=ua(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 HC(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||OC.some(t=>e.startsWith(t))?"":e}function qC(n){if(!Ze(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 KC(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 Zs(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 VC(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 jp(n){if(typeof n!="string"||!n.trim())return{};try{const e=JSON.parse(n);return Ze(e)?e:{value:e}}catch{return{raw:n}}}function er(n){if(typeof n=="string")return n;try{return JSON.stringify(n)}catch{return String(n??"")}}function Sp(...n){return n.find(e=>typeof e=="string")}function GC(n){return n.startsWith("exec-")}function YC(n){var o;if(!Ze(n))return{text:er(n),isError:!1};if("Err"in n)return{text:er(n.Err),isError:!0};const e=Ze(n.Ok)?n.Ok:null;if(!e)return{text:er(n),isError:!1};const t=Gc({...e,content:e.content}),s=t.text||((o=t.images)!=null&&o.length?"":e.structuredContent!==void 0?er(e.structuredContent):er(e));return{...t,text:s,isError:t.isError}}function XC(n,e,t){return{id:n?`${n}@${e}`:DC("codex-turn"),userMessage:null,contentBlocks:[],thinking:[],assistantText:[],toolCalls:[],subAgentActivity:[],timestamp:e,durationMs:null,tokenUsage:null,model:t}}function g0(n){return n.type==="event_msg"&&Ze(n.payload)&&n.payload.type==="user_message"&&typeof n.payload.message=="string"?Yc(n.payload.message):n.type==="response_item"&&Ze(n.payload)&&n.payload.type==="message"&&n.payload.role==="user"?Yc(ua(n.payload,"input_text")):""}function JC(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 g0(n)!==""||p0(e).length>0||h0(e).length>0}return!0}function x0(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(!Ze(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&&Ze(x.payload.branchedFrom)){const j=typeof x.payload.branchedFrom.sessionId=="string"?x.payload.branchedFrom.sessionId:"";j&&(a={sessionId:j,turnIndex:typeof x.payload.branchedFrom.turnIndex=="number"?x.payload.branchedFrom.turnIndex:null})}const y=Ze(x.payload.source)?x.payload.source:null;if(y&&Ze(y.subagent)){m=!0;const j=Ze(y.subagent.thread_spawn)?y.subagent.thread_spawn:null;j&&typeof j.agent_path=="string"&&(h=j.agent_path)}typeof x.payload.forked_from_id=="string"&&x.payload.forked_from_id&&(p=x.payload.forked_from_id);const b=Ze(x.payload.git)?x.payload.git:null;s||(s=b&&typeof b.branch=="string"?b.branch:"")}x.type==="turn_context"&&(i||(i=typeof x.payload.model=="string"?x.payload.model:""),o||(o=typeof x.payload.cwd=="string"?x.payload.cwd:""));const v=g0(x);v&&v!==g&&(l||(l=v),c=v,g=v,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 b0(n){for(const e of n.split(`
70
+ `)){const t=e.trim();if(t)return To(ku(t))}return!1}function QC(n){return To(n[0]??null)}function ZC(n){const e=n.map(ku).filter(To);return x0(e)}function v0(n,e){const t=x0(n.filter(To)),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(T,P,_,A={}){const I=c.get(T);let $=f.get(T);if(!$){const M={agentId:T,parentToolUseId:(I==null?void 0:I.parentToolCallId)||void 0,agentName:(I==null?void 0:I.nickname)??(I!=null&&I.agentPath?Zo(I.agentPath):null),subagentType:(I==null?void 0:I.agentType)??null,type:"assistant",content:null,toolCalls:[],thinking:[],text:[],timestamp:(I==null?void 0:I.timestamp)??_,tokenUsage:null,model:(I==null?void 0:I.model)??null,isBackground:!1,prompt:(I==null?void 0:I.message)||void 0,status:A.status??"running"};P.subAgentActivity.push(M);const O=P.contentBlocks[P.contentBlocks.length-1];(O==null?void 0:O.kind)==="sub_agent"?O.messages.push(M):P.contentBlocks.push({kind:"sub_agent",messages:[M],timestamp:_}),$={message:M,turn:P},f.set(T,$)}const R=$.message;if(I&&(R.parentToolUseId=I.parentToolCallId||R.parentToolUseId,R.agentName=I.nickname??(I.agentPath?Zo(I.agentPath):R.agentName),R.subagentType=I.agentType,R.model=I.model,R.prompt=I.message||R.prompt),A.text&&!R.text.includes(A.text)&&(R.text.push(A.text),R.content=R.text.join(`
71
+
72
+ `)),A.status){const M=new Set(["completed","failed","interrupted"]);if(A.status==="running"&&R.status&&M.has(R.status)||(R.status=A.status),M.has(A.status)&&R.timestamp&&_){const O=new Date(R.timestamp).getTime(),D=new Date(_).getTime();Number.isFinite(O)&&Number.isFinite(D)&&D>=O&&(R.durationMs=D-O)}}return R}let p=null,h=null,g=t.model||null,x="",v=null,y=!1;const b=[];let j=0,S=null,k=null;function C(T){const P=s.length,_=VC(s,T,x);return s.length>P&&k!==null&&b.push(k),k=null,_}function N(T,P,_){const A=XC(T,P,_);return k=S??j,S=null,y||(A.isFragment=!0),v&&(A.compactionSummary=v,v=null),A}function E(T,P,_,A,I){const $=i.get(P);if($){$.input={...$.input,..._},$.result=A,$.isError=A==="failed";return}const R={id:P,name:"WebSearch",input:_,result:A,isError:A==="failed",timestamp:I};i.set(P,R),Zs(T,R,I)}for(let T=0;T<n.length;T++){const P=n[T];if(!To(P))continue;j=T;const _=Ze(P.payload)?P.payload:void 0,A=P.timestamp??"";if(P.type==="compacted"){p=C(p),v="Conversation compacted",x=A;continue}if(P.type!=="world_state"){if(P.type==="turn_context"){p=C(p),S=T,h=typeof(_==null?void 0:_.turn_id)=="string"?_.turn_id:null,g=typeof(_==null?void 0:_.model)=="string"?_.model:g,x=A,y=!0;continue}if(P.type==="event_msg"&&(_==null?void 0:_.type)==="user_message"&&typeof _.message=="string"){p&&(p.assistantText.length>0||p.toolCalls.length>0||p.thinking.length>0)&&(p=C(p)),y=!0,p??(p=N(h,A,g));const I=(Array.isArray(_.local_images)?_.local_images:[]).filter(R=>typeof R=="string"&&R.length>0),$=(Array.isArray(_.local_audio)?_.local_audio:[]).filter(R=>typeof R=="string"&&R.length>0);p.userMessage=wp(_.message,BC(_),UC(_),I,$),p.isFragment=!1,p.timestamp=p.timestamp||A,x=A;continue}if(!(!p&&!JC(P,_))){if(p??(p=N(h,A,g)),!p.model&&g&&(p.model=g),p.timestamp||(p.timestamp=A),A&&(x=A),P.type==="event_msg"&&(_==null?void 0:_.type)==="token_count"){const I=Ze(_.info)?_.info:null,$=I?qC(I.last_token_usage):null;$&&(p.tokenUsage=bo(p.tokenUsage,$));continue}if(P.type==="event_msg"&&(_==null?void 0:_.type)==="web_search_end"&&typeof _.call_id=="string"){const I={};typeof _.query=="string"&&_.query&&(I.query=_.query),Ze(_.action)&&(I.action=_.action),E(p,_.call_id,I,"completed",A);continue}if(P.type==="event_msg"&&(_==null?void 0:_.type)==="mcp_tool_call_end"&&typeof _.call_id=="string"&&Ze(_.invocation)){const I=_.invocation,$=typeof I.server=="string"?I.server:"mcp",R=typeof I.tool=="string"?I.tool:"tool",M=Ze(I.arguments)?I.arguments:{},O=YC(_.result),D=o.get(_.call_id);D?(D.result=O.text,D.isError=O.isError,O.images&&(D.resultImages=O.images),o.delete(_.call_id)):GC(_.call_id)||Zs(p,{id:_.call_id,name:`mcp__${$}__${R}`,input:M,result:O.text,isError:O.isError,...O.images?{resultImages:O.images}:{},timestamp:A},A);continue}if(P.type==="event_msg"&&(_==null?void 0:_.type)==="sub_agent_activity"&&typeof _.agent_thread_id=="string"&&typeof _.agent_path=="string"){const I=_.agent_thread_id,$=typeof _.event_id=="string"?_.event_id:"",R=typeof _.kind=="string"?_.kind:"started",M=$?l.get($):void 0,O=d.get(_.agent_path),D=c.get(I)??(O?c.get(O):void 0);if(R!=="started"&&!D&&!M)continue;if(O&&O!==I&&!f.has(I)){const L=f.get(O);L&&(L.message.agentId=I,f.delete(O),f.set(I,L)),c.delete(O)}const z={agentId:I,nickname:(D==null?void 0:D.nickname)??Zo(_.agent_path)??(M==null?void 0:M.taskName)??null,agentPath:_.agent_path,message:(D==null?void 0:D.message)??(M==null?void 0:M.message)??"",model:(D==null?void 0:D.model)??(M==null?void 0:M.model)??null,agentType:(D==null?void 0:D.agentType)??(M==null?void 0:M.agentType)??null,timestamp:(D==null?void 0:D.timestamp)??(A||(M==null?void 0:M.timestamp)||""),parentToolCallId:(D==null?void 0:D.parentToolCallId)??$};c.set(I,z),d.set(_.agent_path,I),$&&(R==="started"||M)&&u.set($,I),m(I,p,A,{status:R==="interrupted"?"interrupted":"running"});continue}if(!(P.type!=="response_item"||!_)){if(_.type==="reasoning"){const I=Array.isArray(_.summary)?_.summary.filter($=>typeof $=="string").join(`
73
+ `):"";KC(p,I.trim(),A);continue}if(_.type==="message"&&_.role==="assistant"){c0(p,ua(_,"output_text"),A);continue}if(_.type==="message"&&_.role==="user"&&p.userMessage===null){const I=Yc(ua(_,"input_text")),$=p0(_),R=h0(_);(I||$.length>0||R.length>0)&&(p.userMessage=wp(I,$,R),p.isFragment=!1,y=!0);continue}if(_.type==="web_search_call"&&typeof _.id=="string"){const I={};Ze(_.action)&&(I.action=_.action);const $=typeof _.status=="string"?_.status:"completed";E(p,_.id,I,$,A);continue}if(_.type==="tool_search_call"){const I=Sp(_.call_id,_.id)??"";if(I){const $={id:I,name:"ToolSearch",input:Ze(_.arguments)?_.arguments:{},result:null,isError:!1,timestamp:A};o.set(I,$),Zs(p,$,A)}continue}if(_.type==="tool_search_output"&&typeof _.call_id=="string"){const I=o.get(_.call_id);if(I){const $=Array.isArray(_.tools)?_.tools:[],R=$.filter(Ze).map(D=>Sp(D.name)??"").filter(Boolean),M=R.length>0?R.length:$.length,O=`Found ${M} tool${M===1?"":"s"}`;I.result=R.length>0?`${O}: ${R.join(", ")}`:O,I.isError=_.status==="failed",o.delete(_.call_id)}continue}if(_.type==="agent_message"&&typeof _.author=="string"){const I=_.author,$=typeof _.recipient=="string"?_.recipient:null,R=WC(_);if(R.messageType==="NEW_TASK")continue;const M=d.get(I),O=I.startsWith(`${t.agentPath}/`)&&($===null||$===t.agentPath);if(!M&&!O)continue;const D=M??I;M||(c.set(D,{agentId:D,nickname:Zo(I),agentPath:I,message:"",model:null,agentType:null,timestamp:A,parentToolCallId:""}),d.set(I,D));let z;R.messageType==="FINAL_ANSWER"?z="completed":R.messageType==="ERROR"||R.messageType==="FAILED"?z="failed":R.messageType==="INTERRUPTED"?z="interrupted":R.messageType==="MESSAGE"&&(z="running"),m(D,p,A,{status:z,text:R.text||void 0});continue}if(_.type==="function_call"&&typeof _.call_id=="string"){const I=typeof _.name=="string"?_.name:"tool",$=Cn(I),R=jp(_.arguments);let M=$,O=R;$==="exec_command"?M="Bash":$==="update_plan"?(M="TodoWrite",O=RC(R)):PC($)&&(M="AskUserQuestion",O=IC(R)),$==="spawn_agent"&&l.set(_.call_id,{callId:_.call_id,message:HC(R.message),taskName:typeof R.task_name=="string"?R.task_name:null,model:typeof R.model=="string"?R.model:null,agentType:typeof R.agent_type=="string"?R.agent_type:null,timestamp:A});const D={id:_.call_id,name:M,input:O,result:null,isError:!1,timestamp:A,...$==="request_user_input_async"?{asyncQuestion:!0}:{}};o.set(D.id,D),Zs(p,D,A);continue}if(_.type==="function_call_output"&&typeof _.call_id=="string"){const I=o.get(_.call_id);if(!I)continue;const $=Gc(_.output),R=$.text;if(I.result=R,I.isError=$.isError,$.images&&(I.resultImages=$.images),o.delete(_.call_id),I.name==="spawn_agent"&&R)try{const M=JSON.parse(R),O=typeof M.agent_id=="string"?M.agent_id:u.get(I.id)??"",D=typeof M.task_name=="string"?M.task_name:null,z=typeof M.nickname=="string"?M.nickname:D?Zo(D):null;if(O){const F=l.get(I.id),L=c.get(O),H={agentId:O,nickname:z??(L==null?void 0:L.nickname)??(F==null?void 0:F.taskName)??null,agentPath:D??(L==null?void 0:L.agentPath)??null,message:(L==null?void 0:L.message)??(F==null?void 0:F.message)??"",model:(L==null?void 0:L.model)??(F==null?void 0:F.model)??null,agentType:(L==null?void 0:L.agentType)??(F==null?void 0:F.agentType)??null,timestamp:(L==null?void 0:L.timestamp)??(F==null?void 0:F.timestamp)??A,parentToolCallId:(L==null?void 0:L.parentToolCallId)??I.id};c.set(O,H),u.set(I.id,O),H.agentPath&&d.set(H.agentPath,O),m(O,p,A,{status:"running"})}}catch{}if(I.name==="wait_agent"&&R&&p)try{const M=JSON.parse(R),O=Ze(M.status)?M.status:{};for(const[D,z]of Object.entries(O)){const F=Ze(z)?z:{},L=typeof F.completed=="string"?F.completed:"",H=typeof F.failed=="string"?F.failed:typeof F.error=="string"?F.error:"",U=typeof F.interrupted=="string"?F.interrupted:"",W=L?"completed":H?"failed":U?"interrupted":typeof F.status=="string"?F.status:"running";c.has(D)||c.set(D,{agentId:D,nickname:null,agentPath:null,message:"",model:null,agentType:null,timestamp:A,parentToolCallId:""}),m(D,p,A,{status:W,text:L||H||U||void 0})}}catch{}continue}if(_.type==="custom_tool_call"&&typeof _.call_id=="string"){const I=Cn(typeof _.name=="string"?_.name:"tool"),$=typeof _.input=="string"?_.input:"",R=_.call_id,M=$?d0(I,$,R,A,t.cwd):[];if(I!=="apply_patch"){const O={id:R,name:I==="exec_command"?"Bash":I,input:jp($),result:null,isError:!1,timestamp:A};o.set(O.id,O),Zs(p,O,A)}for(const O of M)o.set(O.id,O),Zs(p,O,A);M.length>0&&a.set(R,{calls:M,direct:I==="apply_patch"});continue}if(_.type==="custom_tool_call_output"&&typeof _.call_id=="string"){const I=_.call_id,{text:$,isError:R,images:M}=Gc(_.output),O=a.get(I);if(O){const z=O.direct&&R?new Set(O.calls.map(F=>F.id)):_C($,R,O.calls);for(const F of O.calls){const L=o.get(F.id);L&&(L.result=$,L.isError=z.has(L.id),o.delete(L.id))}a.delete(I)}const D=o.get(I);D&&(D.result=$,D.isError=R,M&&(D.resultImages=M),o.delete(I));continue}}}}}return C(p),{turnStartIndices:b,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?Za(s.length):el(s),rawMessages:e!=null&&e.skipStats?[]:n,branchedFrom:t.branchedFrom,agentKind:"codex"}}function Cu(n,e){const t=n.split(`
74
+ `).map(i=>i.trim()).filter(Boolean).map(ku).filter(To),{turnStartIndices:s,...o}=v0(t,e);return o}function e_(n,e){const t=n.rawMessages.map(s=>JSON.stringify(s)).join(`
75
+ `);return Cu(t?`${t}
76
+ ${e}`:e)}const t_=new Set(["FINAL_ANSWER","ERROR","FAILED","INTERRUPTED"]);function n_(n){const e=n.content;return Array.isArray(e)?e.filter(t=>Ze(t)&&t.type==="input_text"&&typeof t.text=="string").map(t=>t.text).join(`
77
+ `):""}function Di(n){if(typeof n!="string")return null;try{const e=JSON.parse(n);return Ze(e)?e:null}catch{return null}}function s_(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=Ze(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=Cn(typeof f.name=="string"?f.name:"");if(m==="spawn_agent"){const p=Di(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=Di(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=Di(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=Di(f.output),h=Ze(p==null?void 0:p.status)?p.status:{};for(const[g,x]of Object.entries(h)){const v=Ze(x)?x:{},y=typeof v.status=="string"?v.status:"";(typeof v.completed=="string"||typeof v.failed=="string"||typeof v.error=="string"||typeof v.interrupted=="string"||y==="completed"||y==="failed"||y==="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=n_(f).match(/^Message Type:\s*([^\r\n]+)/))==null?void 0:c[1])==null?void 0:d.trim().toUpperCase())??"";if(!t_.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 o_(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=s_(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?Cn(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 r_(n,e,t){const s=Ze(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 i_(n){return v0(n,{skipStats:!0}).turnStartIndices}const a_=/^(?:assistant|auto_mode|auto_mode_switch|background_tasks|canvas|command|custom|elicitation|exit_plan_mode|extensions|external_tool|factory|hook|managed_settings|mcp|model|pending_messages|permission|sampling|session|skill|subagent|system|tool|ui|user_input)\./;function Lt(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function y0(n){return typeof n.agentId!="string"||n.agentId.length===0}function w0(n){return!Lt(n)||typeof n.type!="string"||!Lt(n.data)?!1:n.type==="abort"||n.type==="binary_asset"||n.type==="user.message"||a_.test(n.type)}function j0(n){try{const e=JSON.parse(n);return w0(e)?e:null}catch{return null}}function l_(n){return n.split(`
78
+ `).map(e=>e.trim()).filter(Boolean).map(j0).filter(e=>e!==null)}function je(...n){return n.find(e=>typeof e=="string")??""}function Qn(n){return typeof n=="number"&&Number.isFinite(n)?n:0}function ir(n){return typeof n.timestamp=="string"?n.timestamp:""}function ms(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 Np(n){const e=ms(n,"copilot-turn"),t=je(n.data.turnId);return t?`${t}@${e}`:e}function Wl(n,e){if(!Lt(n))return;const t=je(n.cwd),s=je(n.branch);t&&(e.cwd=t),s&&(e.gitBranch=s)}function S0(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(!y0(t))continue;const{data:s}=t,o=ir(t);if(o&&(e.lastTimestamp=o),t.type==="session.start"){e.sessionId||(e.sessionId=je(s.sessionId)),e.version||(e.version=je(s.copilotVersion)||(typeof s.version=="number"?String(s.version):je(s.version))),Wl(s.context,e),e.model=je(s.selectedModel)||e.model;continue}if(t.type==="session.resume"){Wl(s.context,e),e.model=je(s.selectedModel)||e.model;continue}if(t.type==="session.context_changed"){Wl(s,e);continue}if(t.type==="session.auto_mode_resolved"){e.model=je(s.chosenModel)||e.model;continue}if(t.type==="session.model_change"){e.model=je(s.newModel)||e.model;continue}if(t.type==="session.title_changed"){e.name=je(s.title)||e.name;continue}if(t.type==="session.shutdown"){e.model=je(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=je(s.model)||e.model),t.type!=="user.message")continue;e.turnCount++,e.timestamp||(e.timestamp=o);const i=je(s.content).trim();i&&(e.firstUserMessage||(e.firstUserMessage=i),e.lastUserMessage=i)}return e.lastTimestamp||(e.lastTimestamp=e.timestamp),e}function c_(n){for(const e of n.split(`
79
+ `)){const t=e.trim();if(t)try{const s=JSON.parse(t);if(w0(s))return!0}catch{}}return!1}function d_(n){var e;return N_((e=n[0])==null?void 0:e.type)}function u_(n){const e=n.map(t=>j0(t.trim())).filter(t=>t!==null);return S0(e)}function Hl(n){if(typeof n=="string")return n;if(n===void 0)return"";try{return JSON.stringify(n)}catch{return String(n)}}function kp(n){return typeof n=="string"?n:Array.isArray(n)?n.flatMap(e=>{const t=typeof e=="string"?e:Lt(e)?je(e.text,e.content):"";return t?[t]:[]}).join(`
80
+ `):""}function f_(n){const e=new Map;for(const t of n){if(t.type!=="session.binary_asset"&&t.type!=="binary_asset")continue;const s=je(t.data.assetId),o=je(t.data.data),i=je(t.data.mimeType);s&&o&&i&&e.set(s,{data:o,mimeType:i})}return e}function m_(n,e){if(!Lt(n))return null;const t=e.get(je(n.assetId)),s=je(n.mimeType,t==null?void 0:t.mimeType).toLowerCase(),o=je(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 N0(n,e){if(!Array.isArray(n))return[];const t=[],s=new Set;for(const o of n){const i=m_(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 p_(n,e){const t=je(n.content),s=N0(n.attachments,e);return s.length===0?t:[...s,...t?[{type:"text",text:t}]:[]]}function h_(n,e){return Lt(n.result)?N0([...Array.isArray(n.result.contents)?n.result.contents:[],...Array.isArray(n.result.binaryResultsForLlm)?n.result.binaryResultsForLlm:[]],e):[]}function Xc(n,e=!1){const t=Qn(n.cacheWriteTokens),s=Qn(n.cacheReadTokens),o=Qn(n.inputTokens),i={input_tokens:e?Math.max(0,o-t-s):o,output_tokens:Qn(n.outputTokens),cache_creation_input_tokens:t,cache_read_input_tokens:s},a=Qn(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 g_(n){if(!Lt(n.modelMetrics))return null;let e=null;for(const t of Object.values(n.modelMetrics)){if(!Lt(t)||!Lt(t.usage))continue;const s=Xc(t.usage,!0);s&&(e=bo(e,s))}return e}function x_(n){if(typeof n=="string")return{label:n};if(!Lt(n))return null;const e=je(n.label,n.title,n.value,n.name);if(!e)return null;const t=je(n.description);return t?{label:e,description:t}:{label:e}}function b_(n){return Array.isArray(n)?n.map(x_).filter(e=>e!==null):[]}function v_(n){if(!Lt(n))return null;const e=je(n.question,n.prompt,n.text,n.message);if(!e)return null;const t=je(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:b_(n.options??n.choices),...s===void 0?{}:{multiSelect:s}}}function y_(n){const t=(Array.isArray(n.questions)?n.questions:[n]).map(v_).filter(s=>s!==null);return t.length>0?{...n,questions:t}:n}function ar(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 fa(n,e){const t=Lt(e)?e:e===void 0?{}:{value:e};return n==="AskUserQuestion"?y_(t):n==="Edit"?{...t,file_path:je(t.file_path,t.path),old_string:je(t.old_string,t.old_str),new_string:je(t.new_string,t.new_str)}:n==="Write"?{...t,file_path:je(t.file_path,t.path),content:je(t.content,t.file_text)}:n==="Bash"&&typeof t.command!="string"&&typeof t.cmd=="string"?{...t,command:t.cmd}:t}function w_(n){const e=n.error;if(typeof e=="string")return e;if(Lt(e)){const s=je(e.message,e.code);if(s)return s}const t=n.result;if(typeof t=="string")return t;if(!Lt(t))return t===void 0?"":Hl(t);if(typeof t.detailedContent=="string")return t.detailedContent;if(typeof t.content=="string")return t.content;if(Array.isArray(t.contents)){const s=t.contents.flatMap(o=>{const i=typeof o=="string"?o:Lt(o)?je(o.text,o.content,o.output):"";return i?[i]:[]}).join(`
81
+ `);if(s)return s}return t.structuredContent!==void 0?Hl(t.structuredContent):Hl(t)}function Cp(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 zi(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 lr(n,e,t,s){return{id:n,name:e,input:t,result:null,isError:!1,timestamp:s}}function _p(n,e,t){if(!Array.isArray(n))return[];const s=[];for(const o of n){if(!Lt(o))continue;const i=je(o.toolCallId),a=je(o.name);if(!i||!a||t(i))continue;const l=ar(a);s.push(lr(i,l,fa(l,o.arguments),e))}return s}function Tp(n,e,t,s){n.name=e,n.input=fa(e,t),n.timestamp=s||n.timestamp}function Ep(n,e,t){n.result=w_(e);const s=h_(e,t);s.length>0&&(n.resultImages=s),n.isError=e.success===!1||e.error!==void 0&&e.error!==null}function Ap(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 j_(n){return n.userMessage!==null||n.assistantText.length>0||n.thinking.length>0||n.toolCalls.length>0||n.subAgentActivity.length>0}function k0(n,e){const t=l_(n),s=S0(t),o=f_(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 v(C,N){N&&d.set(C,N)}function y(C){return f||(f=Ap(Np(C),ir(C),null,m,p,!0)),f}function b(){f&&(j_(f)&&i.push(f),f=null)}function j(C){var $;const N=typeof C.agentId=="string"?C.agentId:"";if(!N)return null;const E=l.get(N);if(E)return E.message;const T=C.data,P=je(T.toolCallId),_=P?(($=a.get(P))==null?void 0:$.turn)??f:f;if(!_)return null;const A=je(T.executionMode),I={agentId:N,...P?{parentToolUseId:P}:{},agentName:je(T.agentDisplayName,T.agentName)||null,subagentType:je(T.agentType,T.agentName)||null,type:"assistant",content:null,toolCalls:[],thinking:[],text:[],timestamp:ir(C),tokenUsage:null,model:je(T.model)||null,isBackground:A==="background",...je(T.description)?{prompt:je(T.description)}:{},status:"running"};return _.subAgentActivity.push(I),_.contentBlocks.push({kind:I.isBackground?"background_agent":"sub_agent",messages:[I],timestamp:I.timestamp}),l.set(N,{message:I,turn:_}),I}function S(C){if(y0(C))return!1;const N=j(C);if(!N)return!0;const{data:E}=C,T=ir(C);if(C.type==="subagent.started"||C.type==="subagent.configured")return N.parentToolUseId||(N.parentToolUseId=je(E.toolCallId)||void 0),N.agentName=je(E.agentDisplayName,E.agentName)||N.agentName,N.subagentType=je(E.agentType,E.agentName)||N.subagentType,N.model=je(E.model)||N.model,N.prompt||(N.prompt=je(E.description)||void 0),N.isBackground||(N.isBackground=je(E.executionMode)==="background"),N.status="running",!0;if(C.type==="subagent.completed"||C.type==="subagent.failed"){N.agentName=je(E.agentDisplayName,E.agentName)||N.agentName,N.subagentType=je(E.agentType,E.agentName)||N.subagentType,N.model=je(E.model)||N.model,N.durationMs=Qn(E.durationMs)||N.durationMs,N.toolUseCount=Qn(E.totalToolCalls)||N.toolUseCount,N.status=C.type==="subagent.completed"?"completed":"failed";const P=je(E.error,E.message);return P&&!N.text.includes(P)&&N.text.push(P),!0}if(C.type==="user.message")return N.prompt||(N.prompt=je(E.content)||void 0),!0;if(C.type==="assistant.reasoning"){const P=je(E.content);return P&&!N.thinking.includes(P)&&N.thinking.push(P),!0}if(C.type==="assistant.message"){N.model=je(E.model)||N.model;const P=je(E.reasoningText);P&&!N.thinking.includes(P)&&N.thinking.push(P);const _=kp(E.content);_&&!N.text.includes(_)&&N.text.push(_);for(const A of _p(E.toolRequests,T,I=>c.has(I)))N.toolCalls.push(A),c.set(A.id,{call:A,message:N});return!0}if(C.type==="assistant.usage"){N.model=je(E.model)||N.model;const P=Xc(E);return P&&(N.tokenUsage=bo(N.tokenUsage,P)),!0}if(C.type==="tool.execution_start"){const P=je(E.toolCallId)||ms(C,"copilot-agent-tool"),_=je(E.toolName)||"Tool",A=ar(_),I=c.get(P);if(I)Tp(I.call,A,E.arguments,T);else{const $=lr(P,A,fa(A,E.arguments),T);N.toolCalls.push($),c.set(P,{call:$,message:N})}return!0}if(C.type==="tool.execution_complete"){const P=je(E.toolCallId)||ms(C,"copilot-agent-tool");let _=c.get(P);if(!_){const A=je(E.toolName)||"Tool",I=ar(A),$=lr(P,I,{},T);N.toolCalls.push($),_={call:$,message:N}}return Ep(_.call,E,o),c.delete(P),!0}return!0}for(const C of t){if(S(C))continue;const{data:N}=C,E=ir(C);if(C.type==="session.start"||C.type==="session.resume"){m=je(N.selectedModel)||m,p=je(N.reasoningEffort)||p;continue}if(C.type==="session.auto_mode_resolved"){m=je(N.chosenModel)||m,f&&(f.model=m);continue}if(C.type==="session.model_change"){m=je(N.newModel)||m;const T=N.reasoningEffort;typeof T=="string"&&(p=T),f&&(f.model=m,p&&(f.effort=p));continue}if(C.type==="session.shutdown"){m=je(N.currentModel)||m,f&&!f.model&&(f.model=m),x=g_(N)??x;const T=Qn(N.totalApiDurationMs);f&&!g&&T&&u.set(f,T);continue}if(C.type==="user.message"){b(),f=Ap(Np(C),E,p_(N,o),m,p,!1),v(f,E);continue}if(C.type==="assistant.turn_start"){m=je(N.model)||m;const T=y(C);T.model=m,p&&(T.effort=p),v(T,E);continue}if(C.type==="assistant.reasoning"){const T=y(C);Cp(T,je(N.content),E,je(N.reasoningId)||ms(C,"copilot-thinking")),v(T,E);continue}if(C.type==="assistant.message"){m=je(N.model)||m;const T=y(C);T.model=m,p&&(T.effort=p),Cp(T,je(N.reasoningText),E,ms(C,"copilot-thinking")),c0(T,kp(N.content),E);for(const P of _p(N.toolRequests,E,_=>a.has(_)))zi(T,P,E),a.set(P.id,{call:P,turn:T});v(T,E);continue}if(C.type==="assistant.usage"){m=je(N.model)||m,p=je(N.reasoningEffort)||p;const T=Xc(N),P=Qn(N.duration);T&&(h=!0),P&&(g=!0);const _=y(C);_.model=m,p&&(_.effort=p),T&&(_.tokenUsage=bo(_.tokenUsage,T)),P&&u.set(_,(u.get(_)??0)+P),v(_,E);continue}if(C.type==="tool.execution_start"){m=je(N.model)||m;const T=y(C);T.model=m;const P=je(N.toolCallId)||ms(C,"copilot-tool"),_=je(N.toolName)||"Tool",A=ar(_),I=a.get(P);if(I)Tp(I.call,A,N.arguments,E);else{const $=lr(P,A,fa(A,N.arguments),E);zi(T,$,E),a.set(P,{call:$,turn:T})}v(T,E);continue}if(C.type==="tool.execution_complete"){m=je(N.model)||m;const T=je(N.toolCallId)||ms(C,"copilot-tool");let P=a.get(T);if(!P){const _=y(C),A=je(N.toolName)||"Tool",I=ar(A),$=lr(T,I,{},E);zi(_,$,E),P={call:$,turn:_}}Ep(P.call,N,o),a.delete(T),v(P.turn,E);continue}if(C.type==="session.error"){const T=y(C),_={errorType:je(N.errorType)||"unknown"};typeof N.statusCode=="number"&&(_.statusCode=N.statusCode),typeof N.errorCode=="string"&&(_.errorCode=N.errorCode),zi(T,{id:ms(C,"copilot-error"),name:"Error",input:_,result:je(N.message)||"Copilot session error",isError:!0,timestamp:E},E),v(T,E);continue}(C.type==="assistant.turn_end"||C.type==="assistant.idle"||C.type==="session.idle")&&f&&v(f,E)}if(b(),!h&&x&&i.length===1&&(i[0].tokenUsage=bo(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),E=Date.parse(C.timestamp),T=N?Date.parse(N):Number.NaN;if(Number.isFinite(E)&&Number.isFinite(T)&&T>=E)C.durationMs=T-E;else{const P=u.get(C)??0;P&&(C.durationMs=P)}}const k=e!=null&&e.skipStats?Za(i.length):el(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 S_(n,e){const t=n.rawMessages.map(s=>JSON.stringify(s)).join(`
82
+ `);return k0(t?`${t}
83
+ ${e}`:e)}function N_(n){return typeof n=="string"&&(n==="abort"||n==="binary_asset"||n==="user.message"||n.startsWith("assistant.")||n.startsWith("permission.")||n.startsWith("session.")||n.startsWith("subagent.")||n.startsWith("tool.")||n.startsWith("user_input."))}function k_(n){const e=new Map;for(const o of n){const i=typeof o.agentId=="string"?o.agentId:"";if(!i&&(o.type==="abort"||o.type==="session.shutdown"||o.type==="session.error")){e.clear();continue}if(!i||!o.type.startsWith("subagent."))continue;const a=Lt(o.data)?o.data:{};if(o.type==="subagent.completed"||o.type==="subagent.failed"){e.delete(i);continue}if(o.type==="subagent.started"||o.type==="subagent.configured"){const l=[a.agentDisplayName,a.description,a.agentName].find(c=>typeof c=="string")??"";e.set(i,l||e.get(i)||"")}}if(e.size>0){const o=[...e.values()];return{status:"awaiting_agents",pendingQueue:0,pendingAgents:o.length,pendingAgentDescriptions:o.filter(i=>i.length>0)}}let t=!1;const s=new Set;for(let o=n.length-1;o>=0;o--){const i=n[o];if(typeof i.agentId=="string"&&i.agentId)continue;const a=Lt(i.data)?i.data:{};switch(i.type){case"abort":case"session.shutdown":return{status:"completed"};case"assistant.turn_end":{for(let l=o-1;l>=0;l--){const c=n[l];if(typeof c.agentId=="string"&&c.agentId)continue;if(c.type==="user.message")break;if(c.type==="abort")return{status:"completed"};if(c.type!=="assistant.message")continue;const d=Lt(c.data)?c.data:{};return Array.isArray(d.toolRequests)&&d.toolRequests.length>0?{status:"processing"}:{status:"completed"}}return{status:"processing"}}case"session.error":return{status:"completed",terminalReason:typeof a.message=="string"?a.message:"Copilot session error"};case"assistant.idle":case"session.idle":return{status:t?"completed":"idle"};case"permission.completed":{const l=typeof a.requestId=="string"?a.requestId:"";l&&s.add(l);continue}case"permission.requested":{const l=typeof a.requestId=="string"?a.requestId:"";if(l&&s.has(l))continue;return{status:"deferred"}}case"user_input.requested":return{status:"tool_use",toolName:"AskUserQuestion"};case"tool.execution_start":return s.size>0?{status:"thinking"}:{status:"tool_use",toolName:typeof a.toolName=="string"?Cn(a.toolName):typeof a.name=="string"?Cn(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 C_(){throw new Error("Copilot sessions branch through the CLI's fork API, not by copying the transcript")}function __(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 C0=Ss[Ss.length-1],T_={kind:"codex",descriptor:an("codex"),detectsText:b0,detectsRecords:QC,parse:Cu,append:e_,metadataFromLines:ZC,status:o_,brandBranch:r_,turnBoundaries:i_},E_={kind:"copilot",descriptor:an("copilot"),detectsText:c_,detectsRecords:d_,parse:k0,append:S_,metadataFromLines:u_,status:k_,brandBranch:C_,turnBoundaries:__},A_={kind:"claude",descriptor:an("claude"),detectsText:gp,detectsRecords:gp,parse:gC,append:xC,metadataFromLines:hC,status:SC,brandBranch:NC,turnBoundaries:kC},Qi=Object.freeze({claude:A_,codex:T_,copilot:E_});function _0(n){for(const e of Ss)if(n(Qi[e]))return Qi[e];return Qi[C0]}function T0(n){return Qi[n]}function E0(n){return _0(e=>e.detectsText(n))}function A0(n){return _0(e=>e.detectsRecords(n))}function P0(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 I0(n,e,t){return P0(n,e)[t]??e.length}function P_(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:P0(n,e).find(o=>o>s)??"keep-all"}function I_(n){return ju(n)?Qx(n.input):[n]}function R_(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 $_(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 M_(n,e){const t=n.contentBlocks,s=t.findIndex(o=>o.kind==="tool_calls"&&o.toolCalls.some(i=>i.id===e));return s===-1?!1:t.slice(s+1).some(o=>o.kind==="queued_prompt")}function L_(n){for(let e=n.toolCalls.length-1;e>=0;e--){const t=n.toolCalls[e];if(!t.asyncQuestion||t.isError)continue;if(M_(n,t.id))return null;const s=t.input.questions;if(s&&s.length>0)return{type:"question",toolUseId:t.id,questions:s}}return null}function O_(n,e){const t=e.toolCalls[e.toolCalls.length-1];if(!t||t.asyncQuestion)return null;const{name:s}=t;if(s!=="ExitPlanMode"&&s!=="AskUserQuestion"||t.result!==null&&!t.isError||R_(n,s)||t.isError&&$_(e,t.id))return null;const o=t.input;if(s==="ExitPlanMode")return{type:"plan",allowedPrompts:o.allowedPrompts};const i=o.questions;return i&&i.length>0?{type:"question",toolUseId:t.id,questions:i}:null}function R0(n){const{turns:e}=n;if(e.length===0)return null;const t=e[e.length-1];return!t||t.toolCalls.length===0?null:O_(e,t)??L_(t)}function D_(n){return typeof n=="string"?n:n.filter(e=>e.type==="text").map(e=>e.text).join(`
84
+ `)}function nl(n,e){return E0(n).parse(n,e)}function z_(n,e){const t=A0(n.rawMessages);return(t.kind===C0?E0(e):t).append(n,e)}function sl(n){return n===null?"":typeof n=="string"?n:D_(n)}function $0(n){return n===null||typeof n=="string"?[]:n.filter(e=>e.type==="image")}const M0=w.createContext(null);function F_(n){const e=[];for(let t=0;t<n.length;t+=1){const s=n[t],o=$0(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 B_(n){const e=B.c(10),{images:t,children:s}=n,[o,i]=w.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(vu,{open:o.open,images:o.images,initialIndex:o.index,onClose:()=>i(U_),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(M0.Provider,{value:d,children:[s,u]}),e[6]=s,e[7]=u,e[8]=d,e[9]=f):f=e[9],f}function U_(n){return n?{...n,open:!1}:null}function W_(n){const e=B.c(7),{children:t}=n,{session:s}=ot();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=F_(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(B_,{images:a,children:t}),e[4]=t,e[5]=a,e[6]=l):l=e[6],l}function L0(){return w.useContext(M0)}const O0=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp",".ico",".avif"]);function H_(n){if(!n)return!1;const e=n.lastIndexOf(".");return e===-1?!1:O0.has(n.slice(e).toLowerCase())}function _u(n){return!n||n.startsWith("http://")||n.startsWith("https://")||n.startsWith("data:")||!n.startsWith("/")?!1:H_(n)}function q_(n){return n&&(_u(n)?Kr(`/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=Tn("hostFiles"),[d,u]=w.useState(!1),[f,m]=w.useState(!1),[p,h]=w.useState(),g=L0();let x;e[0]!==c||e[1]!==t?(x=_u(t)&&!c,e[0]=c,e[1]=t,e[2]=x):x=e[2];const v=x;let y;e[3]!==v||e[4]!==t?(y=v?void 0:q_(t),e[3]=v,e[4]=t,e[5]=y):y=e[5];const b=y;let j;e[6]!==s||e[7]!==l||e[8]!==b?(j=b?{id:l,src:b,alt:s??"Rendered image",label:s||"Rendered image"}:null,e[6]=s,e[7]=l,e[8]=b,e[9]=j):j=e[9];const S=j;let k;e[10]!==g||e[11]!==S?(k=()=>{S&&(g?g.openImage(S):(m(!0),u(!0)))},e[10]=g,e[11]=S,e[12]=k):k=e[12];const C=k;if(v){let O;return e[13]!==s?(O=s?r.jsx("span",{className:"text-muted-foreground",children:s}):null,e[13]=s,e[14]=O):O=e[14],O}if(b&&p===b){const O=s?`: ${s}`:"";let D;return e[15]!==O?(D=r.jsxs("span",{role:"status",className:"my-3 block text-xs text-muted-foreground",children:["Image unavailable",O]}),e[15]=O,e[16]=D):D=e[16],D}const N=`Open ${s||"rendered image"}`;let E;e[17]!==i?(E=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):E=e[18];const T=s??"";let P;e[19]!==b?(P=()=>h(b),e[19]=b,e[20]=P):P=e[20];let _;e[21]!==a?(_=q("max-h-96 max-w-full rounded-lg object-contain",a),e[21]=a,e[22]=_):_=e[22];let A;e[23]!==b||e[24]!==_||e[25]!==T||e[26]!==P?(A=r.jsx("img",{src:b,alt:T,loading:"lazy",decoding:"async",onError:P,className:_}),e[23]=b,e[24]=_,e[25]=T,e[26]=P,e[27]=A):A=e[27];let I;e[28]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx("span",{className:"absolute right-2 top-2 flex size-7 items-center justify-center rounded-md border border-white/10 bg-black/45 text-white/70 opacity-80 backdrop-blur transition-[color,background-color,opacity] group-hover/image:bg-black/65 group-hover/image:text-white sm:opacity-0 sm:group-hover/image:opacity-100 sm:group-focus-visible/image:opacity-100",children:r.jsx(Ea,{className:"size-3.5","data-icon":"icon"})}),e[28]=I):I=e[28];let $;e[29]!==C||e[30]!==A||e[31]!==N||e[32]!==E?($=r.jsxs(ee,{type:"button",variant:"ghost",onClick:C,"aria-label":N,className:E,children:[A,I]}),e[29]=C,e[30]=A,e[31]=N,e[32]=E,e[33]=$):$=e[33];let R;e[34]!==d||e[35]!==f||e[36]!==S?(R=f&&S&&r.jsx(vu,{open:d,images:[S],initialIndex:0,onClose:()=>u(!1),onCloseComplete:()=>m(!1)}),e[34]=d,e[35]=f,e[36]=S,e[37]=R):R=e[37];let M;return e[38]!==$||e[39]!==R?(M=r.jsxs(r.Fragment,{children:[$,R]}),e[38]=$,e[39]=R,e[40]=M):M=e[40],M}function K_(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=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 V_(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 G_(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 Y_(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 X_(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 J_(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=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 Q_(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 Z_(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=Tn("hostFiles");let a;e[4]!==s?(a=Q_(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?Er(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 e7=[...O0].map(n=>n.slice(1)).join("|"),t7=new RegExp(`^([ \\t]*)(\\/[^\\s]+\\.(?:${e7}))[ \\t]*$`,"gim");function D0(n){return n.replace(t7,(e,t,s)=>`${t}![${s}](${s})`)}const Gn={code:wk,pre({children:n}){return r.jsx(r.Fragment,{children:n})},a:Z_,h1({children:n}){return r.jsx("h1",{className:"text-xl font-semibold mt-6 mb-3 pb-2 border-b border-border/40 text-foreground first:mt-0",children:n})},h2({children:n}){return r.jsx("h2",{className:"text-lg font-semibold mt-5 mb-2 pb-1.5 border-b border-border/30 text-foreground first:mt-0",children:n})},h3({children:n}){return r.jsx("h3",{className:"text-base font-semibold mt-4 mb-2 text-foreground first:mt-0",children:n})},h4({children:n}){return r.jsx("h4",{className:"text-sm font-semibold mt-3 mb-1.5 text-foreground first:mt-0",children:n})},h5({children:n}){return r.jsx("h5",{className:"text-sm font-medium mt-3 mb-1 text-foreground first:mt-0",children:n})},h6({children:n}){return r.jsx("h6",{className:"text-xs font-medium mt-3 mb-1 text-muted-foreground first:mt-0",children:n})},p({children:n}){return r.jsx("p",{className:"my-1.5 leading-[1.55] text-foreground/90 first:mt-0 last:mb-0 md:my-2 md:leading-relaxed",children:n})},blockquote({children:n}){return r.jsx("blockquote",{className:"my-2 rounded-r-md border-l-2 border-border bg-muted/30 py-1.5 pl-3 pr-2.5 text-foreground/80 [&>p]:my-1 md:my-3 md:py-2 md:pl-4 md:pr-3",children:n})},ul({children:n}){return r.jsx("ul",{className:"my-1.5 flex list-disc flex-col gap-0.5 pl-5 marker:text-muted-foreground/50 [&_ol]:my-1 [&_ul]:my-1 md:my-2 md:gap-1 md:pl-6",children:n})},ol({children:n}){return r.jsx("ol",{className:"my-1.5 flex list-decimal flex-col gap-0.5 pl-5 marker:text-muted-foreground/50 [&_ol]:my-1 [&_ul]:my-1 md:my-2 md:gap-1 md:pl-6",children:n})},li({children:n}){return r.jsx("li",{className:"pl-1 leading-[1.55] text-foreground/90 md:leading-relaxed",children:n})},hr(){return r.jsx(Nt,{className:"my-4"})},table({children:n}){return r.jsx("div",{className:"my-3 overflow-x-auto rounded-lg border border-border/40",children:r.jsx(K_,{className:"border-collapse text-sm",children:n})})},thead({children:n}){return r.jsx(V_,{className:"bg-muted/50",children:n})},tbody({children:n}){return r.jsx(G_,{children:n})},tr({children:n}){return r.jsx(Y_,{className:"even:bg-muted/20",children:n})},th({children:n}){return r.jsx(X_,{className:"h-9 px-3 py-2 text-xs font-medium text-muted-foreground",children:n})},td({children:n}){return r.jsx(J_,{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})}},Yn=[Yw],n7=["system-reminder","local-command-caveat","command-name","command-message","command-args","env","claude_background_info","fast_mode_info","gitStatus","user-prompt-submit-hook"],s7=n7.join("|");function z0(){return new RegExp(`<(${s7})[^>]*>[\\s\\S]*?<\\/\\1>`,"g")}function F0(n){return n.replace(z0(),"").trim()}function o7(n){return z0().test(n)}const r7=/<command-message>([^<]+)<\/command-message>/,i7=/<command-name>([\s\S]*?)<\/command-name>/,a7=/<command-args>([\s\S]*?)<\/command-args>/;function B0(n){const e=n.match(r7);if(e)return e[1];const t=n.match(i7);return t?t[1].trim().replace(/^\//,""):null}function U0(n){const e=n.match(a7);if(!e)return null;const t=e[1].trim();return t.length>0?t:null}const W0={"local-command-stdout":"stdout","local-command-stderr":"stderr","bash-input":"input","bash-stdout":"stdout","bash-stderr":"stderr"},l7=new RegExp(`<(${Object.keys(W0).join("|")})>([\\s\\S]*?)<\\/\\1>`,"g");function c7(n){const e=[],t=n.replace(l7,(s,o,i)=>(e.push({text:sx(i).trim(),stream:W0[o]}),"")).trim();return{outputs:e,remainingText:t}}const d7=/<task-notification>([\s\S]*?)<\/task-notification>/g;function eo(n,e){const t=n.match(new RegExp(`<${e}>([\\s\\S]*?)<\\/${e}>`));return t?t[1].trim():""}function Tu(n){const e=[],t=n.replace(d7,(s,o)=>(e.push({taskId:eo(o,"task-id"),toolUseId:eo(o,"tool-use-id"),outputFile:eo(o,"output-file"),status:eo(o,"status"),summary:eo(o,"summary"),result:eo(o,"result")}),"")).trim();return{notifications:e,remainingText:t}}const u7=/\[Request interrupted by user[^\]]*\]/g;function f7(n){const e=[],t=n.replace(u7,s=>(e.push(s),"")).trim();return{interrupts:e,remainingText:t}}const Pp="[SYSTEM NOTIFICATION - NOT USER INPUT]";function m7(n){const e=n.indexOf(Pp);if(e===-1)return{text:n,isSystemNotification:!1};const t=e+Pp.length,s=n.indexOf(`
85
+
86
+ `,t),o=s===-1?t:s+2;return{text:(n.slice(0,e)+n.slice(o)).trim(),isSystemNotification:!0}}const Ip={Icon:hN,color:"text-destructive",bg:"border-destructive/20 bg-destructive/5",badgeVariant:"destructive"},Rp={completed:{Icon:pN,color:"text-success",bg:"border-success/20 bg-success/5",badgeVariant:"secondary",label:"Completed"},failed:{...Ip,label:"Failed"},error:{...Ip,label:"Error"},running:{Icon:gN,color:"text-warning",bg:"border-warning/20 bg-warning/5",badgeVariant:"outline",label:"Running"}};function H0(n){const e=B.c(32),{notification:t}=n,[s,o]=w.useState(!1),i=Rp[t.status]??Rp.running,{Icon:a}=i,l=t.result.length>0||t.outputFile.length>0,c=s?mt:Ye;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(Pe,{variant:i.badgeVariant,className:i.color,children:i.label}),e[9]=i.badgeVariant,e[10]=i.color,e[11]=i.label,e[12]=p):p=e[12];let h;e[13]!==m||e[14]!==p?(h=r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[m,p]}),e[13]=m,e[14]=p,e[15]=h):h=e[15];let g;e[16]!==c||e[17]!==s||e[18]!==l||e[19]!==t.outputFile||e[20]!==t.result?(g=l&&r.jsxs(r.Fragment,{children:[r.jsxs(Rt,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"mt-1.5 -ml-2 text-muted-foreground"}),children:[r.jsx(c,{"data-icon":"inline-start"}),s?"Hide detail":"Show detail"]}),r.jsx(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(qn,{components:Gn,remarkPlugins:Yn,children:t.result}),t.outputFile&&r.jsxs("div",{className:"mt-2",children:[r.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Output file"}),r.jsx("div",{className:"mt-1 select-all break-all rounded bg-muted px-2 py-1 font-mono text-xs text-muted-foreground",children:t.outputFile})]})]})})]}),e[16]=c,e[17]=s,e[18]=l,e[19]=t.outputFile,e[20]=t.result,e[21]=g):g=e[21];let x;e[22]!==h||e[23]!==g?(x=r.jsxs("div",{className:"min-w-0 flex-1",children:[h,g]}),e[22]=h,e[23]=g,e[24]=x):x=e[24];let v;e[25]!==f||e[26]!==x?(v=r.jsxs("div",{className:"flex items-start gap-2",children:[f,x]}),e[25]=f,e[26]=x,e[27]=v):v=e[27];let y;return e[28]!==s||e[29]!==d||e[30]!==v?(y=r.jsx(ct,{open:s,onOpenChange:o,className:d,children:v}),e[28]=s,e[29]=d,e[30]=v,e[31]=y):y=e[31],y}function p7(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}=Tu(t);if(l.length===0){i=null;break e}s="flex flex-col",o=l.map(h7)}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 h7(n,e){return r.jsx(H0,{notification:n},n.taskId||`notification-${e}`)}function g7(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(Ye,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}):r.jsx(yo,{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 x7(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(ox,{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(qn,{components:Gn,remarkPlugins:Yn,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 Eu=w.memo(function({content:e,timestamp:t,onEditCommand:s,onExpandCommand:o,compact:i=!1}){const a=L0(),[l,c]=w.useState(!1),[d,u]=w.useState(!1),[f,m]=w.useState(!1),[p,h]=w.useState(null),[g,x]=w.useState(!1),[v,y]=w.useState(null),b=w.useMemo(()=>sl(e),[e]),j=w.useMemo(()=>B0(b),[b]),S=w.useMemo(()=>U0(b),[b]),{sender:k,body:C,matched:N}=w.useMemo(()=>Rr(b),[b]),E=w.useMemo(()=>F0(C),[C]),{text:T,isSystemNotification:P}=w.useMemo(()=>m7(E),[E]),{notifications:_,remainingText:A}=w.useMemo(()=>Tu(T),[T]),{outputs:I,remainingText:$}=w.useMemo(()=>c7(A),[A]),{interrupts:R,remainingText:M}=w.useMemo(()=>f7($),[$]),O=w.useCallback(async K=>{if(!K){m(!1);return}if(p!==null){m(!0);return}if(!(!o||!j)){x(!0),m(!0);try{const Y=await o(j,S??void 0);h(Y)}finally{x(!1)}}},[p,o,j,S]),D=w.useMemo(()=>$0(e),[e]),z=w.useMemo(()=>D.map(K=>`data:${K.source.media_type};base64,${K.source.data}`),[D]),F=w.useMemo(()=>z.map((K,Y)=>({id:`message-attachment-${Y}`,src:K,alt:`Attachment ${Y+1}`,label:z.length>1?`Attachment ${Y+1}`:"Attached image"})),[z]),L=w.useMemo(()=>o7(b)||P||N,[b,P,N]),H=d?b:M,W=H.length>500&&!l?H.slice(0,500)+"...":H,V=K=>{const Y=F[K];Y&&(a?a.openImage(Y):y({index:K,open:!0}))};return r.jsxs("div",{className:"group",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"flex items-center gap-2 mb-1",children:L&&r.jsx(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>u(!d),className:"-ml-2 text-muted-foreground",children:d?r.jsxs(r.Fragment,{children:[r.jsx(Aa,{"data-icon":"inline-start"})," Hide raw"]}):r.jsxs(r.Fragment,{children:[r.jsx(js,{"data-icon":"inline-start"})," Show raw"]})})}),!d&&P&&r.jsx("div",{className:"mb-2",children:r.jsxs(Pe,{variant:"outline",className:"text-muted-foreground",children:[r.jsx(yo,{"data-icon":"inline-start"}),"System event"]})}),!d&&N&&r.jsx("div",{className:"mb-2",children:r.jsxs(Pe,{variant:"outline",className:"text-muted-foreground",children:[r.jsx(An,{"data-icon":"inline-start"}),k?`From ${k}`:"Teammate message"]})}),j&&r.jsxs(ct,{open:f,onOpenChange:K=>void O(K),className:"mb-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(Pe,{variant:"outline",className:"font-mono text-foreground",children:[r.jsx(yo,{"data-icon":"inline-start"}),"/",j,S&&r.jsx("span",{className:"text-muted-foreground",children:S})]}),o&&r.jsxs(Rt,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"text-muted-foreground"}),children:[f?r.jsx(mt,{"data-icon":"inline-start"}):r.jsx(Ye,{"data-icon":"inline-start"}),f?"Collapse":"Expand"]}),f&&s&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>s(j),className:"text-muted-foreground",children:[r.jsx(ts,{"data-icon":"inline-start"}),"Edit"]})]}),r.jsx(dt,{children:r.jsx(x7,{loading:g,content:p})})]}),z.length>0&&r.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:z.map((K,Y)=>r.jsxs(ee,{type:"button",variant:"ghost",onClick:()=>V(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:K,alt:`Attachment ${Y+1}`,loading:"lazy",decoding:"async",className:"max-h-64 max-w-full rounded-lg object-contain sm:max-w-md"}),r.jsx("span",{className:"absolute right-2 top-2 flex size-7 items-center justify-center rounded-md border border-white/10 bg-black/45 text-white/70 opacity-80 backdrop-blur transition-[color,background-color,opacity] group-hover/image:bg-black/65 group-hover/image:text-white sm:opacity-0 sm:group-hover/image:opacity-100 sm:group-focus-visible/image:opacity-100",children:r.jsx(Ea,{className:"size-3.5","data-icon":"icon"})}),z.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," / ",z.length]})]},`${D[Y].source.media_type}-${D[Y].source.data.slice(0,24)}-${Y}`))}),!d&&_.length>0&&r.jsx("div",{className:"mb-2 flex flex-col gap-2",children:_.map(K=>r.jsx(H0,{notification:K},K.taskId))}),!d&&I.length>0&&r.jsx("div",{className:"mb-2 flex flex-col gap-1",children:I.map((K,Y)=>r.jsx(g7,{output:K},Y))}),!d&&R.length>0&&r.jsx("div",{className:"mb-2 flex flex-col gap-1",children:R.map((K,Y)=>r.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-destructive",children:[r.jsx(V3,{className:"size-3 shrink-0","data-icon":"inline-start"}),r.jsx("span",{children:K})]},Y))}),W&&r.jsx("div",{className:"max-w-none overflow-hidden break-words text-sm leading-relaxed",children:r.jsx(qn,{components:Gn,remarkPlugins:Yn,children:W})}),H.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(mt,{"data-icon":"inline-start"})," Show less"]}):r.jsxs(r.Fragment,{children:[r.jsx(Ye,{"data-icon":"inline-start"})," Show more"]})}),!i&&t&&r.jsx("div",{className:"flex items-center mt-1.5 ml-auto",children:r.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(t).toLocaleTimeString()})})]}),v!==null&&r.jsx(vu,{open:v.open,images:F,initialIndex:v.index,onClose:()=>y(K=>K?{...K,open:!1}:null),onCloseComplete:()=>y(null)},v.index)]})}),q0=w.memo(function(e){const t=B.c(10),{message:s,turnNumber:o}=e;let i;t[0]!==o?(i=r.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:["Turn ",o]}),t[0]=o,t[1]=i):i=t[1];let a;t[2]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(Pe,{variant:"outline",children:"Queued"}),t[2]=a):a=t[2];let l;t[3]!==i?(l=r.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[i,a]}),t[3]=i,t[4]=l):l=t[4];let c;t[5]!==s?(c=r.jsx("div",{className:"rounded-lg border border-dashed bg-prompt-surface p-3",children:r.jsx(Eu,{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}),K0=w.memo(function(e){const t=B.c(30),{progress:s,expanded:o,onExpandedChange:i}=e,[a,l]=w.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=T=>{i==null||i(T),l(T)},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(mt,{"data-icon":"inline-start"}):r.jsx(Ca,{"data-icon":"inline-start"}),t[3]=c,t[4]=g):g=t[4];let x;t[5]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx("span",{className:"text-sm font-medium",children:"Tasks"}),t[5]=x):x=t[5];let v;t[6]!==u||t[7]!==f?(v=r.jsxs("span",{className:"font-mono text-xs tabular-nums text-muted-foreground",children:[u,"/",f]}),t[6]=u,t[7]=f,t[8]=v):v=t[8];let y;t[9]!==m?(y=m.toFixed(0),t[9]=m,t[10]=y):y=t[10];const b=`${y}% of tasks complete`;let j;t[11]!==m||t[12]!==b?(j=r.jsx(Jr,{value:m,className:"max-w-[200px] flex-1","aria-label":b}),t[11]=m,t[12]=b,t[13]=j):j=t[13];let S;t[14]!==s.inProgress?(S=s.inProgress&&r.jsxs("span",{className:"flex min-w-0 items-center gap-1 truncate text-xs text-info",children:[r.jsx(et,{className:"size-3 shrink-0 animate-spin"}),r.jsx("span",{className:"truncate",children:s.inProgress.activeForm})]}),t[14]=s.inProgress,t[15]=S):S=t[15];let k;t[16]!==g||t[17]!==v||t[18]!==j||t[19]!==S?(k=r.jsxs(Rt,{render:h,children:[g,x,v,j,S]}),t[16]=g,t[17]=v,t[18]=j,t[19]=S,t[20]=k):k=t[20];let C;t[21]!==d?(C=d.map(b7),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 E;return t[25]!==c||t[26]!==p||t[27]!==k||t[28]!==N?(E=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]=E):E=t[29],E});function b7(n,e){return r.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[n.status==="completed"?r.jsx(Hn,{className:"size-3 shrink-0 text-success"}):n.status==="in_progress"?r.jsx(et,{className:"size-3 shrink-0 animate-spin text-info"}):r.jsx(Pa,{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 Wo(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]=w.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 V0(n){return`${n.provider}:${n.latestVersion??"unknown"}`}function v7(n,e){const t=e.split(":")[0];return[...n.filter(s=>s.split(":")[0]!==t),e]}const y7="cogpit:provider-update-dismissals:v1";function w7(n,e){return n.filter(t=>t.status==="behind"&&!e.includes(V0(t)))}async function j7(n){const e=await Ne("/api/provider-updates",{signal:n});if(!e.ok)throw new Error(`Provider update check failed (${e.status})`);return(await e.json()).providers??[]}async function S7(n){const e=await Kn("/api/provider-updates/run",{provider:n}),t=await e.json();if(!t.status)throw new Error(t.error??`Update failed (${e.status})`);return t}const N7=360*60*1e3;function k7(){const[n,e]=w.useState([]),[t,s]=Wo(y7,[]),[o,i]=w.useState(null),[a,l]=w.useState(null);w.useEffect(()=>{const u=new AbortController,f=()=>{j7(u.signal).then(e).catch(()=>{})};f();const m=setInterval(f,N7);return()=>{u.abort(),clearInterval(m)}},[]);const c=w.useCallback(async u=>{i(u),l(null);try{const f=await S7(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=w.useCallback(u=>{s(f=>v7(f,V0(u)))},[s]);return{pending:w7(n,t),updating:o,outcome:a,update:c,dismiss:d,clearOutcome:w.useCallback(()=>l(null),[])}}const C7=5e3,_7={warning:"border-warning/30 bg-warning/10 text-warning",destructive:"border-destructive/30 bg-destructive/10 text-destructive",success:"border-success/30 bg-success/10 text-success"};function ql(n){return`grid-cols-[auto_minmax(0,1fr)_auto] rounded-none border-x-0 border-t-0 px-4 py-2 ${_7[n]}`}function $p(n){const e=n.currentVersion?`v${n.currentVersion}`:"an older build";return`${n.displayName} ${e} → v${n.latestVersion}`}function G0(){const n=B.c(39),{pending:e,updating:t,outcome:s,update:o,dismiss:i,clearOutcome:a}=k7(),l=st("configWrite"),c=(s==null?void 0:s.status)==="succeeded";let d,u;if(n[0]!==a||n[1]!==c?(d=()=>{if(!c)return;const A=setTimeout(a,C7);return()=>clearTimeout(A)},u=[c,a],n[0]=a,n[1]=c,n[2]=d,n[3]=u):(d=n[2],u=n[3]),w.useEffect(d,u),s){let A;return n[4]!==a||n[5]!==s.message||n[6]!==c?(A=c?r.jsxs(ut,{className:ql("success"),children:[r.jsx(Br,{}),r.jsx(Et,{children:s.message}),r.jsx(ft,{className:"text-success/80",children:"New sessions will use the updated CLI."})]}):r.jsxs(ut,{className:ql("destructive"),children:[r.jsx(Ps,{}),r.jsx(Et,{children:"Update did not complete"}),r.jsx(ft,{className:"text-destructive/80",children:s.message}),r.jsx(Ts,{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]=A):A=n[7],A}if(e.length===0)return null;const f=e[0],m=e.filter(A=>A.updateCommand!==null&&l),p=ut;let h;n[8]===Symbol.for("react.memo_cache_sentinel")?(h=ql("warning"),n[8]=h):h=n[8];let g;n[9]!==t?(g=t?r.jsx(et,{className:"animate-spin"}):r.jsx(mn,{}),n[9]=t,n[10]=g):g=n[10];let x;n[11]!==f||n[12]!==e?(x=e.length===1?$p(f):`${e.map(T7).join(" and ")} are out of date`,n[11]=f,n[12]=e,n[13]=x):x=n[13];let v;n[14]!==x?(v=r.jsx(Et,{children:x}),n[14]=x,n[15]=v):v=n[15];const y=e.length>1?e.map($p).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 b;n[16]!==y?(b=r.jsx(ft,{className:"text-warning/80",children:y}),n[16]=y,n[17]=b):b=n[17];const j=Ts,S="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=A=>r.jsxs(ee,{variant:"outline",size:"xs",disabled:t!==null,onClick:()=>void o(A.provider),children:[r.jsx(Nc,{"data-icon":"inline-start"}),t===A.provider?"Updating…":e.length===1?"Update":`Update ${A.displayName}`]},A.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 E;n[22]!==i||n[23]!==e?(E=()=>e.forEach(i),n[22]=i,n[23]=e,n[24]=E):E=n[24];let T;n[25]!==N||n[26]!==E?(T=r.jsx(ee,{variant:"ghost",size:"xs",disabled:N,onClick:E,className:"whitespace-nowrap text-muted-foreground",children:"Don't show again"}),n[25]=N,n[26]=E,n[27]=T):T=n[27];let P;n[28]!==j||n[29]!==C||n[30]!==T?(P=r.jsxs(j,{className:S,children:[C,T]}),n[28]=j,n[29]=C,n[30]=T,n[31]=P):P=n[31];let _;return n[32]!==p||n[33]!==P||n[34]!==h||n[35]!==g||n[36]!==v||n[37]!==b?(_=r.jsxs(p,{className:h,children:[g,v,b,P]}),n[32]=p,n[33]=P,n[34]=h,n[35]=g,n[36]=v,n[37]=b,n[38]=_):_=n[38],_}function T7(n){return n.displayName}function Y0(){const n=B.c(27),[e,t]=w.useState(null),[s,o]=w.useState(null),[i,a]=w.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]),w.useEffect(l,c),s&&!i){let d;n[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Nc,{}),n[2]=d):d=n[2];let u;n[3]!==s.version?(u=r.jsxs(Et,{children:["Cogpit v",s.version," is ready"]}),n[3]=s.version,n[4]=u):u=n[4];let f;n[5]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(ft,{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(Ts,{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(tt,{"data-icon":"inline-start"})})}),n[7]=p):p=n[7];let h;return n[8]!==u?(h=r.jsxs(ut,{className:"grid-cols-[auto_minmax(0,1fr)_auto] rounded-none border-x-0 border-t-0 border-success/30 bg-success/10 px-4 py-2 pr-4 text-success has-data-[slot=alert-action]:pr-4",children:[d,u,f,p]}),n[8]=u,n[9]=h):h=n[9],h}if(e&&!i){let d;n[10]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Nc,{}),n[10]=d):d=n[10];let u;n[11]!==e.version?(u=r.jsxs(Et,{children:["Cogpit v",e.version," is available"]}),n[11]=e.version,n[12]=u):u=n[12];let f;n[13]!==e.platform?(f=e.platform!=="mac"&&r.jsx(ft,{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(G3,{"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(Ts,{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(ut,{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 $r=null,{min:Fs,max:gn,abs:Mp,floor:E7}=Math,X0=(n,e,t)=>Fs(t,gn(e,n)),J0=n=>[...n].sort((e,t)=>e-t),Q0=typeof queueMicrotask=="function"?queueMicrotask:n=>{Promise.resolve().then(n)},Qc=()=>{let n;return[new Promise(e=>{n=e}),n]},Z0=n=>{let e;return()=>(n&&(e=n(),n=void 0),e)},hr=(n,e,t)=>{const s=t?"unshift":"push";for(let o=0;o<e;o++)n[s](-1);return n},e2=(n,e)=>{const t=n.t[e];return t===-1?n.o:t},A7=(n,e,t)=>{const s=n.t[e]===-1;return n.t[e]=t,n.i=Fs(e,n.i),s},Zi=(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+=e2(n,t),n.u[++t]=s;return n.i=e,s},to=(n,e,t=0,s=n.l-1)=>{let o=t;for(;t<=s;){const i=E7((t+s)/2);Zi(n,i)<=e?(o=i,t=i+1):s=i-1}return X0(o,0,n.l-1)},Lp=(n,e,t)=>{const s=e-n.l;return n.i=t?-1:Fs(e-1,n.i),n.l=e,s>0?(hr(n.u,s),hr(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))},P7=typeof window<"u",I7=n=>n.documentElement,R7=n=>n.ownerDocument,$7=n=>n.defaultView,t2=Z0(()=>!!/iP(hone|od|ad)/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>0),M7=Z0(()=>"scrollBehavior"in I7(document).style),L7=n=>gn(n.h(),n.p()),O7=(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=$r,x=[0,i?gn(t-1,0):-1],v=0,y=!1;const b=((A,I,$)=>({o:I,t:$?hr($.slice(0,Fs(A,$.length)),gn(0,A-$.length)):hr([],A),l:A,i:-1,u:hr([],A+1)}))(n,s?s[1]:e,s&&s[0]),j=new Set,S=()=>d-c,k=()=>S()+f+u,C=(A,I)=>(($,R,M,O)=>{if(O=Fs(O,$.l-1),Zi($,O)<=R){const D=to($,M,O);return[to($,R,O,D),D]}{const D=to($,R,void 0,O);return[D,to($,M,D)]}})(b,A,I,x[0]),N=()=>Zi(b,b.l),E=(A,I)=>{const $=Zi(b,A)-f;return I?N()-$-T(A):$},T=A=>e2(b,A),P=(A,I=-1)=>b.t[A]===I,_=A=>{A&&(t2()&&p!==0||g&&h===1?f+=A:u+=A)};return{v:()=>{j.clear()},m:()=>a,_:()=>(A=>[A.t.slice(),A.o])(b),S:(A=200)=>{if(!y||i)return x;let I,$;if(m)[I,$]=x;else{let R=gn(0,k()),M=R+l;o||(A=gn(0,A),p!==1&&(R-=A),p!==2&&(M+=A)),[I,$]=x=C(gn(0,R),gn(0,M)),g&&(I=Fs(I,g[0]),$=gn($,g[1]))}return[gn(I,0),Fs($,b.l-1)]},$:A=>to(b,A-c),I:P,k:E,R:T,T:()=>b.l,C:()=>d,M:()=>p!==0,p:()=>l,O:()=>c,h:N,H:()=>(m=u,u=0,[m,h===2]),W:(A,I)=>{const $=[A,I];return j.add($),()=>{j.delete($)}},B:(A,I)=>{let $,R,M=0;switch(A){case 1:{if(I===d&&h===0)break;const O=m;m=0;const D=I-d,z=Mp(D);O&&z<Mp(O)+1||h!==0||(p=D<0?2:1),i&&(i=!1),d=I,M=4;const F=S();F>=-l&&F<=N()&&(M+=1,R=z>l);break}case 2:M=8,p!==0&&($=!0,M+=1),p=0,h=0,g=$r;break;case 3:{const O=I.filter(([D,z])=>!P(D,z));if(!O.length)break;_(O.reduce((D,[z,F])=>{let L;if(h===2)L=!0;else if(g&&h===1)L=z<g[0];else{const H=S(),U=E(z),W=T(z);L=p!==1&&h===0?U+W<=H:U<H&&U+W<H+l}return L&&(D+=F-T(z)),D},0));for(const[D,z]of O){const F=T(D),L=A7(b,D,z);o&&(v+=L?z:z-F)}o&&l&&v>l&&(_(((D,z)=>{let F=0;const L=[];D.t.forEach((Y,X)=>{Y!==-1&&(L.push(Y),X<z&&F++)}),D.i=-1;const H=J0(L),U=H.length,W=U/2|0,V=U%2==0?(H[W-1]+H[W])/2:H[W],K=D.o;return((D.o=V)-K)*gn(z-F,0)})(b,to(b,k()))),o=!1),M=3,R=!0;break}case 4:l!==I&&(l||(y=R=!0),l=I,M=3);break;case 5:I[1]?(_(Lp(b,I[0],!0)),h=2,M=1):(Lp(b,I[0]),M=1);break;case 6:c=I;break;case 7:h=1;break;case 8:g=C(I,I+l),M=1}M&&(a=1+(2147483647&a),$&&f&&(u+=f,f=0),j.forEach(([O,D])=>{M&O&&D(R)}))}}},Au=setTimeout,Kl=(n,e)=>e?-n:n,D7=(n,e,t,s,o,i)=>{const a=Date.now;let l=0,c=!1,d=!1,u=!1,f=!1;const m=(()=>{let v;const y=()=>{v!=$r&&clearTimeout(v)},b=()=>{y(),v=Au(()=>{v=$r,(()=>{if(c||d)return c=!1,void m();u=!1,n.B(2)})()},150)};return b.J=y,b})(),p=()=>{l=a(),u&&(f=!0),n.B(1,s()),m()},h=v=>{if(c||!n.M()||v.ctrlKey)return;const y=a()-l;150>y&&50<y&&(t?v.deltaX:v.deltaY)&&(c=!0)},g=()=>{d=!0,u=f=!1},x=()=>{d=!1,t2()&&(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[v,y]=n.H();v&&(o(v,y,f),f=!1,y&&n.p()>n.h()&&n.B(1,s()))}}},z7=(n,e,t)=>{let s;return[async(o,i)=>{if(!await e())return;s&&s();const a=()=>{const[l,c]=Qc();return s=()=>{c(!1)},n.p()&&Au(s,150),[l,n.W(2,()=>{c(!0)})]};if(i&&M7())n.B(8,o()),Q0(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()}]},F7=(n,e)=>{let t,s,o=Qc(),i=!1;const a=e?"scrollLeft":"scrollTop",l=e?"overflowX":"overflowY",[c,d]=z7(n,()=>o[0],(u,f)=>{u=Kl(u,i),f?t.scrollTo({[e?"left":"top"]:u,behavior:"smooth"}):t[a]=u});return{N(u,f){t=f,e&&(i=getComputedStyle(f).direction==="rtl"),s=D7(n,f,e,()=>Kl(f[a],i),(m,p,h)=>{if(h){const g=f.style,x=g[l];g[l]="hidden",Au(()=>{g[l]=x})}f[a]=Kl(n.C()+m,i),p&&d()}),o[1](!0)},v(){s&&s.A(),o[1](!1),o=Qc()},P:()=>i,V(u){c(()=>u)},X(u){u+=n.C(),c(()=>u)},Y(u,{align:f,smooth:m,offset:p=0}={}){if(u=X0(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()}}},B7=n=>{let e;return{j(t){(e||(e=new($7(R7(t))).ResizeObserver(n))).observe(t)},D(t){e.unobserve(t)},A(){e&&e.disconnect()}}},U7=(n,e)=>{let t;const s=e?"width":"height",o=new WeakMap,i=B7(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!=$r&&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}},ma=P7?w.useLayoutEffect:w.useEffect,rn="current",n2=(n,e)=>{if(Array.isArray(n))for(const t of n)n2(t,e);else n==null||typeof n=="boolean"||e.push(n)},W7=(n,e)=>{const t=n.key;return t??"_"+e},H7=n=>{const e=w.useRef(null);return e[rn]||(e[rn]=n())},Op=n=>{const e=w.useRef(n);return ma(()=>{e[rn]=n},[n]),e},q7=w.memo(({Z:n,ee:e,te:t,oe:s,ne:o,re:i,se:a,ie:l})=>{const c=w.useRef(null);ma(()=>e(c[rn],t),[t]);const d=w.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})}),K7=(n,e)=>w.useMemo(()=>{if(typeof n=="function")return[s=>n(e[s],s),e.length];const t=(s=>{const o=[];return n2(s,o),o})(n);return[s=>t[s],t.length]},[n,e]),V7=w.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,v]=K7(n,e),y=w.useRef(null),b=w.useRef(!!d),j=Op(p),S=Op(h),[k,C,N,E]=H7(()=>{const M=!!i,O=O7(v,s,d,l,!s);return[O,U7(O,M),F7(O,M),M]});v!==k.T()&&k.B(5,[v,o]),c!==k.O()&&k.B(6,c);const[T,P]=w.useReducer(k.m,void 0,k.m),_=k.M(),A=k.h(),I=N.P(),$=[],R=M=>{const O=x(M);return r.jsx(q7,{ee:C.U,te:M,oe:k.k(M,I),ne:k.I(M),re:f,Z:O,se:E,ie:b[rn]},W7(O,M))};if(ma(()=>{b[rn]=!1,k.W(1,D=>{D?jy.flushSync(P):P()}),k.W(4,()=>{j[rn]&&j[rn](k.C())}),k.W(8,()=>{S[rn]&&S[rn]()});const M=y[rn],O=D=>{C.G(D),N.N(M,D)};return m?Q0(()=>{m[rn]&&O(m[rn])}):O(M.parentElement),()=>{k.v(),C.v(),N.v()}},[]),ma(()=>{N.q()},[T]),w.useImperativeHandle(g,()=>({get cache(){return k._()},get scrollOffset(){return k.C()},get scrollSize(){return L7(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[O,D]=k.S(t);O<=D;O++)M.add(O);J0([...M]).forEach(O=>{$.push(R(O))})}else for(let[M,O]=k.S(t);M<=O;M++)$.push(R(M));return r.jsx(u,{ref:y,style:{contain:"size style",overflowAnchor:"none",flex:"none",position:"relative",width:E?A:"100%",height:E?"100%":A,pointerEvents:_?"none":void 0},children:$})});function G7(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(Td,{className:"size-4","data-icon":"inline-start"}),e[0]=o):o=e[0];let i;e[1]!==t?(i=r.jsx("span",{className:"font-mono",children:t}),e[1]=t,e[2]=i):i=e[2];const a=t!==1?"s":"";let l;e[3]!==a?(l=r.jsxs("span",{children:["turn",a," archived"]}),e[3]=a,e[4]=l):l=e[4];let c;e[5]!==i||e[6]!==l?(c=r.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-muted-foreground",children:[o,i,l]}),e[5]=i,e[6]=l,e[7]=c):c=e[7];let d;e[8]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Nt,{orientation:"vertical",className:"h-4"}),e[8]=d):d=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Y3,{"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 Dp=new Map;function Y7(n){let e=Dp.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},Dp.set(n,e)}return e}function s2(n){const e=B.c(5),t="100%",s=w.useRef(null),[o,i]=w.useState(!0);let a,l;e[0]!==t?(a=()=>{const d=s.current;if(!d)return;const{observer:u,callbacks:f}=Y7(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]),w.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 pa(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 zp(n){const e=pa(n.lastActivityAt);return e!==Number.NEGATIVE_INFINITY?e:pa(n.lastModified)}function Fp(n,e){return n===e?0:e-n}function Bp(n){return[n.dirName??"",n.fileName??"",n.sessionId??""].join("/")}function X7(n,e){const t=Fp(zp(n),zp(e));if(t!==0)return t;const s=Fp(pa(n.lastModified),pa(e.lastModified));return s!==0?s:Bp(n).localeCompare(Bp(e))}function ii(n){return[...n].sort(X7)}function ha(n,e){return e||jn(r2(n),50)}const J7="Untitled session";function o2(n,e){const t=n.teamName&&n.agentName?n.agentName:"";return e||n.aiTitle||t||n.lastUserMessage||n.firstUserMessage||n.slug||void 0}function r2(n,e){return o2(n,e)??J7}function Q7(n,e){return o2(n,e)===void 0}function Z7(n){const e=new Set(n.map(o=>o.sessionId)),t=new Map,s=[];for(const o of n){const i=o.teamLeadSessionId;if(i&&i!==o.sessionId&&e.has(i)){const a=t.get(i);a?a.push(o):t.set(i,[o])}else s.push(o)}return{topLevelSessions:s,teammatesByLead:t}}function e8(n){return n.find(e=>!za(e.cwd??kn(e.dirName)))??n[0]}const t8="Unknown project";function Pu(n){const e=za(n);return Da(e?e.parentPath:n,2)||t8}function Iu(n){return Pu(n.cwd||kn(n.dirName))}function Ru(n){return n==="inactive"?"Archived after two weeks without activity":"Archived"}function n8(n,e){return e?n:n.filter(t=>!t.archived)}function s8(n){const e=ii(n),t=new Map;for(const s of e){const o=Iu(s),i=t.get(o);i?i.push(s):t.set(o,[s])}return t}function i2(n,e){return n.isActive?!0:e.has(n.sessionId)?n.agentStatus!=="completed":!1}const $u=new Set(["thinking","tool_use","processing","compacting","awaiting_agents"]),o8=12e4;function r8(n,e=Date.now()){const t=Date.parse(n.lastActivityAt||n.lastModified);return Number.isFinite(t)&&e-t<o8}function a2(n,e,t=Date.now()){return i2(n,e)?!0:n.agentStatus==="completed"||!n.agentStatus?!1:r8(n,t)}function i8(n,e,t=Date.now()){return n.some(s=>a2(s,e,t))}const a8="cogpit:session-list-cache",l8=10080*60*1e3,c8=24,Zn={projects:"projects",activeSessions:"active-sessions",runningProcesses:"running-processes"},Zc=new Map;function d8(){return{version:1,entries:{}}}function l2(){return Jt(a8)}function c2(){const n=l2(),e=Zc.get(n);if(e)return e;let t=d8();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 Zc.set(n,t),t}function d2(n){const e=c2().entries[n];if(!(!e||Date.now()-e.savedAt>l8))return e.value}function u2(n,e){const t=l2(),o={...c2().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,c8))};Zc.set(t,a);try{localStorage.setItem(t,JSON.stringify(a))}catch{}}function ga(n){const e=d2(n);return Array.isArray(e)?e:void 0}function gr(n,e){u2(n,e)}function f2(n){return`sessions:${n}`}function u8(n){const e=d2(f2(n));if(!e||typeof e!="object")return;const t=e;if(!(!Array.isArray(t.sessions)||typeof t.total!="number"))return t}function f8(n,e){u2(f2(n),e)}const m8=2e4;function p8(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 m2=w.createContext(null);function h8({children:n}){const[e]=w.useState(wn),[t,s]=w.useState(()=>ga(Zn.activeSessions)??[]),[o,i]=w.useState(()=>ga(Zn.runningProcesses)??[]),[a,l]=w.useState(!1),[c,d]=w.useState(null),[u,f]=w.useState(new Set),[m,p]=Wo(Jt("live-sessions-show-archived"),!1),h=m===!0,[g,x]=w.useState(!1),v=h||g,[y,b]=w.useState(0),j=w.useRef(null),S=w.useRef(t),k=w.useRef(null),C=w.useRef(!1);w.useEffect(()=>(C.current=!0,()=>{var M;C.current=!1,(M=k.current)==null||M.abort(),k.current=null}),[]);const N=w.useCallback(async()=>{var D;if(!C.current||wn()!==e)return;(D=k.current)==null||D.abort();const M=new AbortController;k.current=M;const O=()=>C.current&&!M.signal.aborted&&k.current===M&&wn()===e;l(!0);try{const[z,F]=await Promise.all([Ne(v?"/api/active-sessions?archived=include":"/api/active-sessions",{signal:M.signal}),Ne("/api/running-processes",{signal:M.signal})]);if(!O())return;if(!z.ok||!F.ok)throw new Error("Failed to fetch live data");const[L,H]=await Promise.all([z.json(),F.json()]);if(!O())return;const U=Array.isArray(L)?L:[],W=Array.isArray(H)?H:[];S.current=U,s(U),i(W),b(Number(z.headers.get("X-Cogpit-Archived-Count"))||0),gr(Zn.activeSessions,U),gr(Zn.runningProcesses,W),d(null)}catch(z){if(!O())return;d(z instanceof Error?z.message:"Failed to load data")}finally{O()&&l(!1),k.current===M&&(k.current=null)}},[e,v]),E=w.useCallback(()=>{N()},[N]);w.useEffect(()=>{E()},[E]);const T=w.useMemo(()=>p8(o),[o]),P=w.useMemo(()=>i8(t,T),[t,T]);w.useEffect(()=>(window.addEventListener("focus",E),()=>window.removeEventListener("focus",E)),[E]),w.useEffect(()=>{if(!P)return;const M=setInterval(()=>{document.visibilityState==="visible"&&E()},m8);return()=>clearInterval(M)},[P,E]),w.useEffect(()=>{if(t.length===0)return;const M=j.current,O=new Map;for(const D of t)D.agentStatus&&T.has(D.sessionId)&&O.set(D.sessionId,D.agentStatus);M!==null&&f(D=>{let z=null;for(const[F,L]of O)L==="completed"&&M.get(F)!=="completed"&&(z??(z=new Set(D)),z.add(F));for(const F of D)O.get(F)!=="completed"&&(z??(z=new Set(D)),z.delete(F));return z??D}),j.current=O},[t,T]);const _=w.useCallback(M=>{f(O=>{if(!O.has(M))return O;const D=new Set(O);return D.delete(M),D})},[]),A=w.useCallback(M=>{S.current=M,s(M),wn()===e&&gr(Zn.activeSessions,M)},[e]),I=w.useCallback(M=>{A(S.current.filter(O=>O.sessionId!==M))},[A]),$=w.useCallback((M,O)=>{const D=new Set(M),z=S.current,F=new Set(z.filter(H=>D.has(H.sessionId)&&!!H.archived!==O).map(H=>H.sessionId));if(F.size===0)return;A(z.map(H=>{if(!F.has(H.sessionId))return H;if(O)return{...H,archived:!0,archivedReason:"manual"};const{archived:U,archivedReason:W,...V}=H;return V}));const L=O?F.size:-F.size;b(H=>Math.max(0,H+L))},[A]),R=w.useMemo(()=>({sessions:t,processes:o,procBySession:T,newlyCompleted:u,loading:a,error:c,refresh:E,removeSession:I,acknowledgeCompleted:_,showArchived:h,setShowArchived:p,setSearchActive:x,archivedCount:y,setArchived:$}),[t,o,T,u,a,c,E,I,_,h,p,y,$]);return r.jsx(m2.Provider,{value:R,children:n})}function p2(){const n=Mu();if(!n)throw new Error("useSessionInventory must be used within a SessionInventoryProvider");return n}function Mu(){return w.useContext(m2)}const Up=[20,50,80,110,140,170,200,230,260,290,320,350];function g8(n){let e=2166136261;for(let t=0;t<n.length;t++)e^=n.charCodeAt(t),e=Math.imul(e,16777619);return Up[(e>>>0)%Up.length]}function Vl(n){const e=[];let t=!1;for(const s of n.split(`
87
+ `)){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 x8(n){const e=n.split(`
88
+ `);let t=0;for(;t<e.length&&e[t].trim()==="";)t++;const s=Vl(e[t]??"");return s?{subject:s,preview:Vl(e.slice(t+1).join(`
89
+ `))}:{subject:Vl(n),preview:""}}function ed(n){if(!n)return null;const e=new Date(n).getTime();return Number.isNaN(e)?null:e}function b8(n,e){return n===null||e===null||e<n?null:e-n}function v8(n){const e=ed(n);return e===null?null:new Date(e).toLocaleTimeString()}function y8(n){var s;const e=(s=Mu())==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=$u.has(i)?"working":"idle"}return t}const w8=w.memo(function(e){const t=B.c(48),{sender:s,body:o,timestamp:i,reply:a,isLive:l}=e,[c,d]=w.useState(!1);let u;t[0]!==o?(u=X6(o),t[0]=o,t[1]=u):u=t[1];const f=u;let m;t[2]!==f?(m=x8(f),t[2]=f,t[3]=m):m=t[3];const{subject:p,preview:h}=m;let g;t[4]!==i?(g=v8(i),t[4]=i,t[5]=g):g=t[5];const x=g,v=y8(s);let y;t[6]!==f?(y=tC(f),t[6]=f,t[7]=y):y=t[7];const b=y,j=b&&!a,S=ed(i),k=a?b8(S,ed(a.timestamp)):null,C=!a&&l===!0,N=!!a||b;Rg(C&&N);const E=!0;let T;t[8]!==s?(T=g8(s),t[8]=s,t[9]=T):T=t[9];const P=String(T);let _;t[10]!==P?(_={"--agent-hue":P},t[10]=P,t[11]=_):_=t[11];const A=_,I="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(X3,{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 R;t[13]!==s?(R=r.jsx("span",{className:"truncate font-mono text-xs font-medium text-[oklch(0.52_0.16_var(--agent-hue))] dark:text-[oklch(0.74_0.14_var(--agent-hue))]",children:s}),t[13]=s,t[14]=R):R=t[14];let M;t[15]!==v||t[16]!==s?(M=v&&r.jsx("span",{"data-testid":"agent-liveness","data-live":v,title:v==="working"?`${s} is working now`:`${s} is idle`,className:`inline-flex size-1.5 shrink-0 rounded-full ${v==="working"?"animate-pulse bg-warning":"bg-success"}`}),t[15]=v,t[16]=s,t[17]=M):M=t[17];let O;t[18]!==R||t[19]!==M?(O=r.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[$,R,M]}),t[18]=R,t[19]=M,t[20]=O):O=t[20];let D;t[21]!==j?(D=j&&r.jsx(Pe,{variant:"outline",className:"h-4 border-warning/30 bg-warning/10 px-1.5 text-[10px] tracking-wide text-warning uppercase",children:"Needs you"}),t[21]=j,t[22]=D):D=t[22];let z;t[23]!==x?(z=x&&r.jsx("span",{className:"text-xs text-muted-foreground",children:x}),t[23]=x,t[24]=z):z=t[24];let F;t[25]!==D||t[26]!==z?(F=r.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[D,z]}),t[25]=D,t[26]=z,t[27]=F):F=t[27];let L;t[28]!==O||t[29]!==F?(L=r.jsxs("div",{className:"flex items-center gap-2",children:[O,F]}),t[28]=O,t[29]=F,t[30]=L):L=t[30];let H;t[31]!==f||t[32]!==c||t[33]!==h||t[34]!==p?(H=c?r.jsx("div",{"data-testid":"agent-message-body",className:"mt-1.5 max-w-none overflow-hidden break-words text-sm leading-relaxed",children:r.jsx(qn,{components:Gn,remarkPlugins:Yn,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]=H):H=t[35];const U="mt-1.5 flex items-center justify-end gap-2",W=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 ${Un(k)} later`,a.summary&&` · "${a.summary}"`]}):C?S===null?"Awaiting your reply":`Awaiting your reply · ${Un(Math.max(0,Date.now()-S))}`:"Never answered"});let V;t[36]===Symbol.for("react.memo_cache_sentinel")?(V=()=>d(j8),t[36]=V):V=t[36];let K;t[37]!==f||t[38]!==c?(K=r.jsx(ee,{type:"button",variant:"ghost",size:"xs",onClick:V,className:"-mr-2 text-muted-foreground",children:c?r.jsxs(r.Fragment,{children:[r.jsx(mt,{"data-icon":"inline-start"})," Collapse"]}):r.jsxs(r.Fragment,{children:[r.jsx(Ye,{"data-icon":"inline-start"})," Expand ·"," ",f.length.toLocaleString("en-US")," ",f.length===1?"char":"chars"]})}),t[37]=f,t[38]=c,t[39]=K):K=t[39];let Y;t[40]!==W||t[41]!==K?(Y=r.jsxs("div",{className:U,children:[W,K]}),t[40]=W,t[41]=K,t[42]=Y):Y=t[42];let X;return t[43]!==L||t[44]!==H||t[45]!==Y||t[46]!==A?(X=r.jsxs("div",{"data-agent-rail":E,style:A,className:I,children:[L,H,Y]}),t[43]=L,t[44]=H,t[45]=Y,t[46]=A,t[47]=X):X=t[47],X});function j8(n){return!n}const S8=w.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=D0(s),t[0]=s,t[1]=d):d=t[1];const u=d,[f,m]=ss();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:Ys(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(at,{"data-icon":"inline-start"}):r.jsx(pn,{"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(qn,{components:Gn,remarkPlugins:Yn,children:u}),t[12]=u,t[13]=x):x=t[13];let v;t[14]!==g||t[15]!==x?(v=r.jsx("div",{className:g,children:x}),t[14]=g,t[15]=x,t[16]=v):v=t[16];let y;return t[17]!==p||t[18]!==v?(y=r.jsxs("div",{className:"group",children:[p,v]}),t[17]=p,t[18]=v,t[19]=y):y=t[19],y}),co=[];function N8(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 k8(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 Wp=/"id"\s*:\s*"(msg_[A-Za-z0-9]+)"/g;function C8(n,e){if(n.length===0||e.length===0)return n;const t=new Set;for(const o of e){Wp.lastIndex=0;let i;for(;(i=Wp.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 _8(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 T8(n){return n.filter(e=>e.parentToolUseId===null)}function E8(n,e){return n.filter(t=>t.parentToolUseId===e)}const h2={},g2=w.createContext(co),x2=w.createContext(h2);function Gl(n){const e=B.c(6),{value:t,agentProgress:s,children:o}=n,i=s===void 0?h2:s;let a;e[0]!==i||e[1]!==o?(a=r.jsx(x2.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(g2.Provider,{value:t,children:a}),e[3]=a,e[4]=t,e[5]=l):l=e[5],l}function Lu(){return w.useContext(g2)}function A8(n){return w.useContext(x2)[n]??null}function no(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 b2={...Gn,code({className:n,children:e}){return!n&&typeof e=="string"&&!e.includes(`
90
+ `)?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},P8={...b2,h1:no("h1"),h2:no("h2"),h3:no("h3"),h4:no("h4"),h5:no("h5"),h6:no("h6")},Ou=w.memo(function(e){const t=B.c(3),{text:s,compactHeadings:o}=e,a=(o===void 0?!1:o)?P8:b2;let l;return t[0]!==a||t[1]!==s?(l=r.jsx(qn,{components:a,remarkPlugins:Yn,children:s}),t[0]=a,t[1]=s,t[2]=l):l=t[2],l}),Hp=400,I8=24,Du=w.memo(function(e){const t=B.c(24),{toolUseId:s}=e,o=Lu(),i=A8(s),a=w.useRef(null),[l,c]=w.useState(!0);let d,u,f;if(t[0]!==l||t[1]!==o||t[2]!==s){f=E8(o,s).flatMap(R8).filter($8).map(M8).join(`
91
+ `);const k=f.split(`
92
+ `);d=l&&k.length>Hp,u=d?k.slice(-Hp).join(`
93
+ `):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<I8;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],w.useLayoutEffect(g,x),!f&&!i)return null;const v=i?"live-subagent-summary":void 0;let y;t[12]!==i?(y=i??r.jsx("span",{className:"uppercase tracking-wide",children:"Live"}),t[12]=i,t[13]=y):y=t[13];let b;t[14]!==v||t[15]!==y?(b=r.jsx("div",{"data-testid":v,className:"mb-1 text-xs font-medium text-muted-foreground",children:y}),t[14]=v,t[15]=y,t[16]=b):b=t[16];let j;t[17]!==d||t[18]!==m||t[19]!==f?(j=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(Ou,{text:m,compactHeadings:!0})]}),t[17]=d,t[18]=m,t[19]=f,t[20]=j):j=t[20];let S;return t[21]!==b||t[22]!==j?(S=r.jsxs("div",{className:"mt-2 rounded-md border bg-muted/30 px-3 py-2","data-testid":"live-subagent-transcript",children:[b,j]}),t[21]=b,t[22]=j,t[23]=S):S=t[23],S});function R8(n){return n.blocks}function $8(n){return n.blockType!=="tool_use"&&n.text}function M8(n){return n.text}function qp(n){return n.length>8?n.slice(0,8):n}function zu(n,e,t){const s=e??t;return s?`${s} - ${qp(n)}`:qp(n)}function L8(n){const e=new Map;for(const t of n)e.has(t.agentId)||e.set(t.agentId,zu(t.agentId,t.subagentType,t.agentName));return e}function O8(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 D8(n){return n?typeof n=="string"?n:n.map(e=>e.type==="text"?e.text:"").filter(Boolean).join(`
94
+ `):""}function v2(n,e){if(b0(n))return Cu(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(`
95
+
96
+ `),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(`
97
+ `)){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=D8(f.content),m.isError=f.is_error??!1)}}}return t}const Yl=new Map;function z8(n,e){const t=B.c(21),{session:s,sessionSource:o,isLive:i}=ot();let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=new Map,t[0]=a):a=t[0];const[l,c]=w.useState(a),[d,u]=w.useState(!1);let f;t[1]===Symbol.for("react.memo_cache_sentinel")?(f=new Set,t[1]=f):f=t[1];const m=w.useRef(f);let p;if(t[2]!==i||t[3]!==n){let E;t[5]!==i?(E=T=>T.text.length>0||T.thinking.length>0||T.toolCalls.length>0?!1:i?T.durationMs!=null:T.status==="async_launched",t[5]=i,t[6]=E):E=t[6],p=n.filter(E),t[2]=i,t[3]=n,t[4]=p}else p=t[4];const h=p,g=o==null?void 0:o.dirName,x=s==null?void 0:s.sessionId;let v;t[7]===Symbol.for("react.memo_cache_sentinel")?(v=Ha(window.location.pathname),t[7]=v):v=t[7];const y=v;let b,j;t[8]!==h||t[9]!==g||t[10]!==e||t[11]!==x?(b=()=>{if(y||!e||!g||!x||h.length===0)return;const E=[];for(const _ of h){const A=Jt(`${g}/${x}/${_.agentId}`);if(!m.current.has(A)){if(Yl.has(A)){c(I=>{const $=new Map(I);return $.set(_.agentId,Yl.get(A)),$}),m.current.add(A);continue}E.push({agentId:_.agentId,cacheKey:A})}}if(E.length===0)return;let T=!1;return u(!0),async function(){const A=new Map;await Promise.all(E.map(async I=>{const{agentId:$,cacheKey:R}=I;try{const M=`/api/sessions/${encodeURIComponent(g)}/${encodeURIComponent(x)}/subagents/agent-${encodeURIComponent($)}.jsonl`,O=await Ne(M);if(!O.ok)return;const D=await O.text(),z=v2(D,$);Yl.set(R,z),m.current.add(R),A.set($,z)}catch{}})),!T&&A.size>0&&c(I=>{const $=new Map(I);for(const[R,M]of A)$.set(R,M);return $}),T||u(!1)}(),()=>{T=!0}},j=[y,e,g,x,h],t[8]=h,t[9]=g,t[10]=e,t[11]=x,t[12]=b,t[13]=j):(b=t[12],j=t[13]),w.useEffect(b,j);let S;e:{if(l.size===0&&h.length===0){S=n;break e}let E;if(t[14]!==l||t[15]!==n){E=[];for(const T of n){const P=l.get(T.agentId);if(P&&P.length>0&&(T.status==="async_launched"||T.durationMs!=null)){const _={...P[0],durationMs:T.durationMs,toolUseCount:T.toolUseCount,status:T.status,prompt:T.prompt,agentName:T.agentName,subagentType:T.subagentType};E.push(_,...P.slice(1))}else E.push(T)}t[14]=l,t[15]=n,t[16]=E}else E=t[16];S=E}const k=S,C=y&&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 Kp=w.memo(function(e){const t=B.c(74),{messages:s,expandAll:o,label:i,countLabel:a}=e,[l,c]=w.useState(!1),d=o||l,{sessionSource:u,actions:f}=ot(),m=u==null?void 0:u.dirName;let p;t[0]!==m?(p=ko(m),t[0]=m,t[1]=p):p=t[1];const h=p.subagentTranscripts,{enrichedMessages:g,isLoading:x,unavailable:v}=z8(s,d&&h);let y;e:{if(!(u!=null&&u.fileName)){y=null;break e}let G;t[2]!==u.fileName?(G=Cs(u.fileName),t[2]=u.fileName,t[3]=G):G=t[3];const J=G;if(J){y=J.parentSessionId;break e}let Z;if(t[4]!==u.fileName){let te;t[6]===Symbol.for("react.memo_cache_sentinel")?(te=/^([^/]+)\.jsonl$/,t[6]=te):te=t[6],Z=u.fileName.match(te),t[4]=u.fileName,t[5]=Z}else Z=t[5];const Q=Z;y=(Q==null?void 0:Q[1])??null}const b=y;let j;t[7]!==g?(j=new Set(g.map(B8)),t[7]=g,t[8]=j):j=t[8];let S;t[9]!==j?(S=[...j],t[9]=j,t[10]=S):S=t[10];const k=S;let C;t[11]!==g?(C=L8(g),t[11]=g,t[12]=C):C=t[12];const N=C;let E;if(t[13]!==g||t[14]!==s){E=new Map;for(const G of[...s,...g]){const J=E.get(G.agentId)??{};G.durationMs!=null&&(J.durationMs=G.durationMs),G.toolUseCount!=null&&(J.toolUseCount=G.toolUseCount),G.status&&(J.status=G.status),E.set(G.agentId,J)}t[13]=g,t[14]=s,t[15]=E}else E=t[15];const T=E;let P;t[16]!==g||t[17]!==s?(P=O8([...s,...g]),t[16]=g,t[17]=s,t[18]=P):P=t[18];const _=P;let A,I;if(t[19]!==g){I=new Map,A=new Map;for(const G of g)A.set(G.agentId,G),G.text.length>0&&I.set(G.agentId,G);t[19]=g,t[20]=A,t[21]=I}else A=t[20],I=t[21];let $;if(t[22]!==k||t[23]!==A||t[24]!==I){$=new Map;for(const G of k){const J=I.get(G)??A.get(G);J&&$.set(G,J)}t[22]=k,t[23]=A,t[24]=I,t[25]=$}else $=t[25];const R=$;let M;e:{let G=0,J=0,Z=!1,Q=!0;for(const ne of s)ne.durationMs!=null&&(G=G+ne.durationMs,Z=!0),ne.toolUseCount!=null&&(J=J+ne.toolUseCount),ne.status&&ne.status!=="completed"&&(Q=!1);if(!Z){M=null;break e}let te;t[26]!==Q||t[27]!==G||t[28]!==J?(te={totalDuration:G,totalToolUses:J,allCompleted:Q},t[26]=Q,t[27]=G,t[28]=J,t[29]=te):te=t[29],M=te}const O=M;if(s.length===0)return null;let D;t[30]!==l?(D=()=>c(!l),t[30]=l,t[31]=D):D=t[31];let z;t[32]!==d?(z=d?r.jsx(mt,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}):r.jsx(Ye,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),t[32]=d,t[33]=z):z=t[33];let F;t[34]===Symbol.for("react.memo_cache_sentinel")?(F=r.jsx(An,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),t[34]=F):F=t[34];let L;t[35]!==i?(L=r.jsx("span",{className:"text-xs font-medium text-foreground",children:i}),t[35]=i,t[36]=L):L=t[36];let H;t[37]!==k.length||t[38]!==a?(H=k.length>1&&r.jsxs(Pe,{variant:"secondary",children:[k.length," ",a]}),t[37]=k.length,t[38]=a,t[39]=H):H=t[39];let U;t[40]!==k||t[41]!==N?(U=k.map(G=>r.jsx(Pe,{variant:"outline",children:N.get(G)},G)),t[40]=k,t[41]=N,t[42]=U):U=t[42];let W;t[43]!==k.length||t[44]!==O?(W=O?r.jsxs("span",{className:"inline-flex items-center gap-2 text-xs text-muted-foreground",children:[O.allCompleted?r.jsx(Hn,{className:"size-3 text-success","data-icon":"inline-start"}):r.jsx(Ps,{className:"size-3 text-destructive","data-icon":"inline-start"}),r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(Us,{className:"size-3","data-icon":"inline-start"}),Un(O.totalDuration)]}),O.totalToolUses>0&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(_a,{className:"size-3","data-icon":"inline-start"}),O.totalToolUses]})]}):r.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",k.length," agent",k.length!==1?"s":"",")"]}),t[43]=k.length,t[44]=O,t[45]=W):W=t[45];let V;t[46]!==z||t[47]!==L||t[48]!==H||t[49]!==U||t[50]!==W||t[51]!==D?(V=r.jsxs(ee,{type:"button",variant:"ghost",onClick:D,className:"h-auto w-full min-w-0 flex-wrap justify-start gap-2 px-0 py-1 text-left whitespace-normal",children:[z,F,L,H,U,W]}),t[46]=z,t[47]=L,t[48]=H,t[49]=U,t[50]=W,t[51]=D,t[52]=V):V=t[52];let K;t[53]!==k||t[54]!==d||t[55]!==_?(K=!d&&k.map(G=>{const J=_.get(G);return J?r.jsx(Du,{toolUseId:J},G):null}),t[53]=k,t[54]=d,t[55]=_,t[56]=K):K=t[56];let Y;t[57]!==f||t[58]!==k||t[59]!==N||t[60]!==R||t[61]!==h||t[62]!==x||t[63]!==d||t[64]!==b||t[65]!==_||t[66]!==u||t[67]!==T||t[68]!==v?(Y=d&&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."}):x&&r.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground py-1",children:[r.jsx(et,{className:"size-3 animate-spin"}),"Loading agent output..."]}),k.map(G=>{const J=R.get(G),Z=T.get(G),Q=h&&!!u&&!!b&&!v;return r.jsx(F8,{agentLabel:N.get(G)??G,message:J,stats:Z,parentToolUseId:_.get(G),canNavigate:Q,onOpen:()=>{Q&&f.handleLoadSession(u.dirName,`${b}/subagents/agent-${G}.jsonl`)}},G)})]}),t[57]=f,t[58]=k,t[59]=N,t[60]=R,t[61]=h,t[62]=x,t[63]=d,t[64]=b,t[65]=_,t[66]=u,t[67]=T,t[68]=v,t[69]=Y):Y=t[69];let X;return t[70]!==V||t[71]!==K||t[72]!==Y?(X=r.jsxs("div",{children:[V,K,Y]}),t[70]=V,t[71]=K,t[72]=Y,t[73]=X):X=t[73],X});function F8(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=D0((c??[]).join(`
98
+
99
+ `)),e[0]=c,e[1]=d):d=e[1];const u=d,f=((c==null?void 0:c.length)??0)>0,m=(o==null?void 0:o.status)!=null&&o.status!=="completed"&&o.status!=="async_launched",p=(o==null?void 0:o.status)==="completed";let h;e[2]!==t?(h=r.jsx(Pe,{variant:"outline",children:t}),e[2]=t,e[3]=h):h=e[3];let g;e[4]!==p||e[5]!==o?(g=o&&r.jsxs("span",{className:"inline-flex items-center gap-2 text-xs text-muted-foreground",children:[p&&r.jsx(Hn,{className:"size-3 text-success"}),o.durationMs!=null&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(Us,{className:"size-3"}),Un(o.durationMs)]}),o.toolUseCount!=null&&o.toolUseCount>0&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(_a,{className:"size-3"}),o.toolUseCount]})]}),e[4]=p,e[5]=o,e[6]=g):g=e[6];let x;e[7]!==a||e[8]!==l?(x=a&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:l,className:"ml-auto",title:"Open this sub-agent's full chat session",children:[r.jsx(K1,{"data-icon":"inline-start"}),"Open chat"]}),e[7]=a,e[8]=l,e[9]=x):x=e[9];let v;e[10]!==h||e[11]!==g||e[12]!==x?(v=r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[h,g,x]}),e[10]=h,e[11]=g,e[12]=x,e[13]=v):v=e[13];let y;e[14]!==f||e[15]!==m||e[16]!==u||e[17]!==i?(y=f?r.jsx("div",{className:"text-xs break-words overflow-hidden",children:r.jsx(qn,{components:Gn,remarkPlugins:Yn,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(et,{className:"size-3 animate-spin"}),"Working — no return yet"]}):r.jsx(r.Fragment,{children:"No return message from this agent"})}),i&&r.jsx(Du,{toolUseId:i})]}),e[14]=f,e[15]=m,e[16]=u,e[17]=i,e[18]=y):y=e[18];let b;return e[19]!==v||e[20]!==y?(b=r.jsx("div",{className:"border-l pl-3",children:r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[v,y]})}),e[19]=v,e[20]=y,e[21]=b):b=e[21],b}function B8(n){return n.agentId}const U8=new Set(["StopFailure","PermissionDenied","PostToolUseFailure"]),W8=w.memo(function(e){const t=B.c(30),{events:s}=e,[o,i]=w.useState(!1);if(s.length===0)return null;let a;t[0]!==s?(a=s.some(H8),t[0]=s,t[1]=a):a=t[1];const l=a,c=o?mt:Ye,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(Xt,{className:"size-3 text-destructive","data-icon":"inline-start"}):r.jsx(J3,{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(q8).join(", "),t[12]=s,t[13]=x):x=t[13];let v;t[14]!==x?(v=r.jsx("span",{className:"truncate text-muted-foreground/60",children:x}),t[14]=x,t[15]=v):v=t[15];let y;t[16]!==v||t[17]!==m||t[18]!==p||t[19]!==g?(y=r.jsxs(Rt,{render:f,children:[m,p,g,v]}),t[16]=v,t[17]=m,t[18]=p,t[19]=g,t[20]=y):y=t[20];let b;t[21]!==s?(b=s.map(K8),t[21]=s,t[22]=b):b=t[22];let j;t[23]!==b?(j=r.jsx(dt,{children:r.jsx("ul",{className:"ml-5 mt-1 flex flex-col gap-0.5 font-mono",children:b})}),t[23]=b,t[24]=j):j=t[24];let S;return t[25]!==o||t[26]!==y||t[27]!==j||t[28]!==u?(S=r.jsxs(ct,{open:o,onOpenChange:i,className:u,children:[y,j]}),t[25]=o,t[26]=y,t[27]=j,t[28]=u,t[29]=S):S=t[29],S});function H8(n){return U8.has(n.eventName)||n.exitCode!==void 0&&n.exitCode!==0}function q8(n){return n.eventName}function K8(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 V8=24,tr=[];function G8(n,e){for(let s=0;s<tr.length;s++){const o=tr[s];if(o.oldStr===n&&o.newStr===e)return o.result}const t=X8(n,e);return tr.length>=V8&&tr.shift(),tr.push({oldStr:n,newStr:e,result:t}),t}const Y8=25e4;function X8(n,e){const t=n.split(`
100
+ `),s=e.split(`
101
+ `),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>Y8){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 v=t[a+x-1],y=x*f,b=y-f;for(let j=1;j<=d;j++)if(v===s[a+j-1])m[y+j]=m[b+j-1]+1;else{const S=m[b+j],k=m[y+j-1];m[y+j]=S>k?S: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 J8(n,e,t,s){const o=B.c(9),[i,a]=w.useState(null),[l,c]=w.useState(null);let d,u;o[0]!==t||o[1]!==s||o[2]!==e||o[3]!==n?(d=()=>{const m=Sx(t);if(!m){a(null),c(null);return}const p=s?"github-dark":"github-light";let h=!1;const g=requestAnimationFrame(()=>{h||wx().then(async x=>{if(h||(await jx(x,m),h))return;const v=x.codeToTokens(n,{lang:m,theme:p});if(h)return;a(v.tokens);const y=x.codeToTokens(e,{lang:m,theme:p});h||c(y.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]),w.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 Q8={removed:"bg-destructive/10",added:"bg-success/10",unchanged:""},Vp={removed:"border-destructive/20 text-destructive/70",added:"border-success/20 text-success/70",unchanged:"border-border text-muted-foreground"},Z8={removed:"text-destructive",added:"text-success",unchanged:"text-muted-foreground"};function eT(n,e){return n.map((t,s)=>r.jsx("span",{style:{color:t.color},className:q(e&&"opacity-50"),children:t.content},s))}function tT(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 nT(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(q1,{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(Bn,{className:"inline size-3","data-icon":"icon"}),e[1]=s):s=e[1],s}default:{let s;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx("span",{className:"inline-block size-3","aria-hidden":"true"}),e[2]=s):s=e[2],s}}}const Xl=3;function sT(n){if(n.length===0)return[];const e=new Set;for(let i=0;i<n.length;i++)n[i].type!=="unchanged"&&e.add(i);if(e.size===0||n.length<=Xl*2+3)return n.map((i,a)=>({kind:"line",line:i,originalIdx:a}));const t=new Set;for(const i of e)for(let a=Math.max(0,i-Xl);a<=Math.min(n.length-1,i+Xl);a++)t.add(a);const s=[];let o=0;for(;o<n.length;)if(t.has(o))s.push({kind:"line",line:n[o],originalIdx:o}),o++;else{const i=o;let a=0;for(;o<n.length&&!t.has(o);)a++,o++;s.push({kind:"separator",count:a,fromIdx:i,toIdx:o-1})}return s}function oT(n){const e=B.c(7),{count:t,onExpand:s}=n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(Ur,{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 Gp=w.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=tT(s,i,a);const x=Q8[s.type];t[10]!==x?(d=q("flex",x),t[10]=x,t[11]=d):d=t[11];const v=Vp[s.type];let y;t[12]!==v?(y=q("w-8 shrink-0 select-none border-r pr-1 text-right text-xs leading-relaxed tabular-nums",v),t[12]=v,t[13]=y):y=t[13],t[14]!==o||t[15]!==y?(u=r.jsx("span",{className:y,children:o}),t[14]=o,t[15]=y,t[16]=u):u=t[16];const b=Vp[s.type];let j;t[17]!==b?(j=q("select-none shrink-0 w-5 text-right pr-1 border-r",b),t[17]=b,t[18]=j):j=t[18];let S;t[19]!==s.type?(S=r.jsx(nT,{type:s.type}),t[19]=s.type,t[20]=S):S=t[20],t[21]!==j||t[22]!==S?(f=r.jsx("span",{className:j,children:S}),t[21]=j,t[22]=S,t[23]=f):f=t[23],l="pl-2 whitespace-pre",c=m?eT(m,s.type==="unchanged"):r.jsx("span",{className:Z8[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}),Yp=120,Xp=60,rT=120;function Jp(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]=w.useState(c);let f;e[1]!==t?(f=sT(t),e[1]=t,e[2]=f):f=e[2];const m=f,p=m.length>Yp,[h,g]=w.useState(p?Xp:m.length);let x;e[3]!==m.length?(x=()=>{g(m.length>Yp?Xp:m.length)},e[3]=m.length,e[4]=x):x=e[4];let v;e[5]!==m?(v=[m],e[5]=m,e[6]=v):v=e[6],w.useEffect(x,v);let y,b;e[7]!==m.length||e[8]!==h?(y=()=>{if(h>=m.length)return;const _=requestAnimationFrame(()=>{g(A=>Math.min(A+rT,m.length))});return()=>cancelAnimationFrame(_)},b=[h,m.length],e[7]=m.length,e[8]=h,e[9]=y,e[10]=b):(y=e[9],b=e[10]),w.useEffect(y,b);let j;e[11]===Symbol.for("react.memo_cache_sentinel")?(j=_=>{u(A=>new Set(A).add(_))},e[11]=j):j=e[11];const S=j;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;e[16]!==N?(E=q("overflow-x-auto font-mono text-xs leading-relaxed",N),e[16]=N,e[17]=E):E=e[17];let T;if(e[18]!==d||e[19]!==C||e[20]!==t||e[21]!==o||e[22]!==s||e[23]!==l){let _;e[25]!==d||e[26]!==t||e[27]!==o||e[28]!==s||e[29]!==l?(_=(A,I)=>{if(A.kind==="separator")return d.has(A.fromIdx)?t.slice(A.fromIdx,A.toIdx+1).map((M,O)=>{const D=A.fromIdx+O;return r.jsx(Gp,{line:M,lineNum:M.type==="removed"?(M.oldIdx??0)+l:(M.newIdx??0)+l,oldTokens:s,newTokens:o},`exp-${D}`)}):r.jsx(oT,{count:A.count,onExpand:()=>S(A.fromIdx)},`sep-${I}`);const{line:$}=A,R=$.type==="removed"?($.oldIdx??0)+l:($.newIdx??0)+l;return r.jsx(Gp,{line:$,lineNum:R,oldTokens:s,newTokens:o},I)},e[25]=d,e[26]=t,e[27]=o,e[28]=s,e[29]=l,e[30]=_):_=e[30],T=C.map(_),e[18]=d,e[19]=C,e[20]=t,e[21]=o,e[22]=s,e[23]=l,e[24]=T}else T=e[24];let P;return e[31]!==E||e[32]!==T?(P=r.jsx("div",{className:E,children:T}),e[31]=E,e[32]=T,e[33]=P):P=e[33],P}function Qp(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 Fu(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]=w.useState(!1),p=ti();let h;e[0]!==s||e[1]!==t?(h=G8(t,s),e[0]=s,e[1]=t,e[2]=h):h=e[2];const g=h,{oldTokens:x,newTokens:v}=J8(t,s,o,p);let y;e[3]!==o?(y=o.split("/").slice(-3).join("/"),e[3]=o,e[4]=y):y=e[4];const b=y,j=c&&"mt-1.5",S=u&&"border-0 rounded-none";let k;e[5]!==j||e[6]!==S?(k=q("overflow-hidden rounded border border-border bg-muted/20",j,S),e[5]=j,e[6]=S,e[7]=k):k=e[7];let C;e[8]!==u||e[9]!==c||e[10]!==g||e[11]!==b?(C=!u&&r.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2 border-b border-border bg-muted/40 px-2 py-1",children:[r.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",children:b}),r.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r.jsx(Qp,{lines:g}),c&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>m(!0),className:"text-muted-foreground",title:"Expand diff","aria-label":"Expand diff",children:r.jsx(Ea,{"data-icon":"icon"})})]})]}),e[8]=u,e[9]=c,e[10]=g,e[11]=b,e[12]=C):C=e[12];let N;e[13]!==c||e[14]!==g||e[15]!==v||e[16]!==x||e[17]!==d?(N=r.jsx(Jp,{lines:g,oldTokens:x,newTokens:v,compact:c,startLine:d}),e[13]=c,e[14]=g,e[15]=v,e[16]=x,e[17]=d,e[18]=N):N=e[18];let E;e[19]!==N||e[20]!==k||e[21]!==C?(E=r.jsxs("div",{className:k,children:[C,N]}),e[19]=N,e[20]=k,e[21]=C,e[22]=E):E=e[22];let T;e[23]!==o||e[24]!==c||e[25]!==g||e[26]!==f||e[27]!==v||e[28]!==x||e[29]!==d?(T=c&&r.jsx(is,{open:f,onOpenChange:m,children:r.jsxs(as,{className:"flex max-h-[85vh] flex-col border-border bg-background sm:max-w-4xl",children:[r.jsxs(Rs,{children:[r.jsxs(ls,{className:"font-mono text-sm text-foreground flex min-w-0 flex-wrap items-center gap-3 [overflow-wrap:anywhere]",children:[o,r.jsx(Qp,{lines:g})]}),r.jsx(cs,{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(Jp,{lines:g,oldTokens:x,newTokens:v,startLine:d})})]})}),e[23]=o,e[24]=c,e[25]=g,e[26]=f,e[27]=v,e[28]=x,e[29]=d,e[30]=T):T=e[30];let P;return e[31]!==E||e[32]!==T?(P=r.jsxs(r.Fragment,{children:[E,T]}),e[31]=E,e[32]=T,e[33]=P):P=e[33],P}const xa={Read:{label:"Read file",styleName:"Read"},Write:{label:"Write file",styleName:"Write"},Edit:{label:"Edit file",styleName:"Edit"},Bash:{label:"Run command",styleName:"Bash"},Grep:{label:"Search files",styleName:"Grep"},Glob:{label:"Find files",styleName:"Glob"},Task:{label:"Spawn agent",styleName:"Task"},Agent:{label:"Spawn agent",styleName:"Task"},WebFetch:{label:"Open page",styleName:"WebFetch"},TodoWrite:{label:"Update plan",styleName:"TodoWrite"},AskUserQuestion:{label:"Ask question",styleName:"AskUserQuestion"},Skill:{label:"Use skill",styleName:"Skill"},ToolSearch:{label:"Find tools",styleName:"ToolSearch"},SendMessage:{label:"Message agent",styleName:"SendMessage"},ListAgents:{label:"List agents",styleName:"ListAgents"},TaskCreate:{label:"Create task",styleName:"TaskCreate"},TaskUpdate:{label:"Update task",styleName:"TaskUpdate"},TaskList:{label:"List tasks",styleName:"TaskList"},TaskOutput:{label:"Read task output",styleName:"TaskOutput"},TaskStop:{label:"Stop task",styleName:"TaskStop"},NotebookEdit:{label:"Edit notebook",styleName:"Edit"},EnterPlanMode:{label:"Enter plan mode",styleName:"EnterPlanMode"},ExitPlanMode:{label:"Exit plan mode",styleName:"ExitPlanMode"},EnterWorktree:{label:"Enter worktree",styleName:"EnterWorktree"},ExitWorktree:{label:"Exit worktree",styleName:"ExitWorktree"},Workflow:{label:"Run workflow",styleName:"Workflow"},exec_command:{label:"Run command",styleName:"Bash"},write_stdin:{label:"Continue command",styleName:"Bash"},apply_patch:{label:"Apply patch",styleName:"Edit"},update_plan:{label:"Update plan",styleName:"TodoWrite"},request_user_input:{label:"Ask question",styleName:"AskUserQuestion"},request_user_input_async:{label:"Ask question",styleName:"AskUserQuestion"},wait:{label:"Wait for tools",styleName:"Mcp"},spawn_agent:{label:"Spawn agent",styleName:"Task"},wait_agent:{label:"Wait for agents",styleName:"TaskOutput"},send_message:{label:"Message agent",styleName:"SendMessage"},followup_task:{label:"Follow up",styleName:"Task"},list_agents:{label:"List agents",styleName:"ListAgents"},interrupt_agent:{label:"Interrupt agent",styleName:"Task"},tool_search:{label:"Find tools",styleName:"ToolSearch"},list_mcp_resources:{label:"List MCP resources",styleName:"Mcp"},list_mcp_resource_templates:{label:"List MCP templates",styleName:"Mcp"},read_mcp_resource:{label:"Read MCP resource",styleName:"Mcp"},request_plugin_install:{label:"Install plugin",styleName:"Mcp"},create_goal:{label:"Create goal",styleName:"TodoWrite"},get_goal:{label:"Check goal",styleName:"TaskList"},update_goal:{label:"Update goal",styleName:"TodoWrite"},view_image:{label:"View image",styleName:"Read"}},iT=new Set(["Write","Edit","Bash","exec","Task","Agent","Skill","TodoWrite","Image","AskUserQuestion","CronCreate","CronDelete","ScheduleWakeup","RemoteTrigger","PushNotification","EnterWorktree","ExitWorktree","SendMessage","EndConversation","TaskCreate","TaskUpdate","TaskStop","Workflow"]);function aT(n){var t;const e=Cn(n);return iT.has(((t=xa[e])==null?void 0:t.styleName)??e)?"mutating":"readOnly"}function y2(n){return typeof n=="object"&&n!==null}function Ft(...n){return n.find(e=>typeof e=="string")??""}function xs(n){return typeof n!="string"?"":/^gAAAAA[A-Za-z0-9_-]+={0,2}$/.test(n.trim())?"Encrypted message":n}function Xs(n){const e=n.command??n.cmd;return typeof e=="string"?e:!Array.isArray(e)||!e.every(t=>typeof t=="string")?"":e.map(t=>/^[A-Za-z0-9_./:@%+=,-]+$/.test(t)?t:`'${t.replace(/'/g,`'"'"'`)}'`).join(" ")}function os(n,e=140){const t=n.replace(/\s+/g," ").trim();return t.length>e?`${t.slice(0,e-1)}…`:t}function Bu(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 ai(n,e=""){const t=Bu(n);if(t.length===0)return e;const s=os(t[0]);return t.length===1?s:`${s} · +${t.length-1} more`}function ol(n,e){return n===1?`1 ${e}`:`${n} ${e}${/(?:ch|sh|s|x|z)$/.test(e)?"es":"s"}`}const Zp={mcp:"MCP",api:"API",url:"URL",openai:"OpenAI",figma:"Figma",clickup:"ClickUp"};function Mr(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 Zp[i]?Zp[i]:e?i[0].toUpperCase()+i.slice(1):i});if(t.length===0)return"Tool";const s=t.join(" ");return s[0].toUpperCase()+s.slice(1)}function lT(n){if(!n)return null;const e=n.trim(),t=Wn(e,0);return(t==null?void 0:t.endIndex)===e.length?t.value:null}function zt(n,...e){for(const t of e){const s=lT(Qa(n,t));if(s)return s;const o=wu(n,t)[0];if(o)return o}return""}function cT(n,...e){for(const t of e){const s=Xx(n,t)[0];if(s!==void 0)return s}return null}function ba(n){return zt(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 dT=[{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 eh(n,e){return e.flatMap(t=>wu(n,t))}function uT(n,e){const t=e.summaryGroups.map(i=>eh(n,i)),s=e.detail?Xx(n,e.detail.property):[],o=e.countProperties?eh(n,e.countProperties):t[0];return{label:e.label,noun:e.noun,summary:[...t.map(i=>ai(i)),e.detail&&s.length>0?e.detail.format(s[0]):""].filter(Boolean).join(" · "),count:Math.max(Jx(n),Bu(o).length,s.length,1)}}function fT(n){const e=[];for(const t of dT){const s=Qa(n,t.key);s&&e.push(uT(s,t))}return e}function w2(n){const e=fT(n);return e.length===0?{label:"Browse web",summary:ba(n),styleName:"WebSearch"}:e.length===1?{label:e[0].label,summary:e[0].summary,styleName:"WebSearch"}:{label:"Browse web",summary:e.map(t=>ol(t.count,t.noun)).join(" · "),styleName:"WebSearch"}}function j2(n){if(!n.startsWith("mcp__"))return null;const[,e,...t]=n.split("__");return!e||t.length===0?null:{server:Mr(e,!0),action:Mr(t.join(" "))}}function mT(n,e){const t=j2(n);if(!t)return{label:Mr(n),summary:ba(e),styleName:"Mcp"};const s=ba(e);return{label:t.server,summary:[t.action,s].filter(Boolean).join(" · "),styleName:"Mcp"}}function S2(n){const e=Wn(n.trim(),0),t=(e==null?void 0:e.value)??n,s=Bu(Array.from(t.matchAll(/^\*\*\*\s+(?:Update|Add|Delete) File:\s*(.+)$/gm),o=>o[1]));return ai(s,s.length>0?ol(s.length,"file"):"")}function pT(n){const e=n.argumentSource;switch(Cn(n.name)){case"exec_command":return{label:"Run command",summary:zt(e,"cmd","command"),styleName:"Bash"};case"write_stdin":{const t=cT(e,"session_id"),s=zt(e,"chars");return{label:"Continue command",summary:[t!==null?`session ${t}`:"",s?os(s,60):""].filter(Boolean).join(" · "),styleName:"Bash"}}case"apply_patch":return{label:"Apply patch",summary:S2(e),styleName:"Edit"};case"web__run":case"web_search":return w2(e);case"view_image":return{label:"View image",summary:zt(e,"path"),styleName:"Read"};case"update_plan":{const t=Qa(e,"plan"),s=t?Jx(t):0;return{label:"Update plan",summary:s>0?ol(s,"step"):zt(e,"explanation"),styleName:"TodoWrite"}}case"create_goal":return{label:"Create goal",summary:zt(e,"objective"),styleName:"TodoWrite"};case"get_goal":return{label:"Check goal",summary:"",styleName:"TaskList"};case"update_goal":return{label:"Update goal",summary:zt(e,"status"),styleName:"TodoWrite"};case"list_mcp_resources":return{label:"List MCP resources",summary:zt(e,"server"),styleName:"Mcp"};case"list_mcp_resource_templates":return{label:"List MCP templates",summary:zt(e,"server"),styleName:"Mcp"};case"read_mcp_resource":return{label:"Read MCP resource",summary:[zt(e,"server"),zt(e,"uri")].filter(Boolean).join(" · "),styleName:"Mcp"};case"request_plugin_install":return{label:"Install plugin",summary:zt(e,"plugin_id"),styleName:"Mcp"};case"tool_search":return{label:"Find tools",summary:zt(e,"query"),styleName:"ToolSearch"};case"image_gen__imagegen":return{label:"Generate image",summary:zt(e,"prompt"),styleName:"Image"};case"spawn_agent":return{label:"Spawn agent",summary:xs(zt(e,"task_name","message")),styleName:"Task"};case"send_message":case"followup_task":return{...xa[Cn(n.name)],summary:[zt(e,"target"),xs(zt(e,"message"))].filter(Boolean).join(" · ")};default:{const t=Cn(n.name),s=xa[t];return t.startsWith("mcp__")?mT(t,e):{label:(s==null?void 0:s.label)??Mr(t),summary:xs(ba(e)),styleName:(s==null?void 0:s.styleName)??t}}}}function hT(n){const e=Vx(n);if(e.length===0)return{label:"Run tool script",summary:"",styleName:"exec"};const t=e.map(pT),s=t[0];if(t.every(i=>i.label===s.label)){const i=ai(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 gT(n){const e=y2(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:Ft(e==null?void 0:e.url,n.query),styleName:"WebSearch"};if(t==="find_in_page"||t==="findInPage")return{label:"Find on page",summary:[Ft(e==null?void 0:e.pattern),Ft(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=Ft(e==null?void 0:e.query,n.query);return{label:"Search web",summary:ai([o,...s]),styleName:"WebSearch"}}const xT=["summary","headline","verdict","title"];function bT(n){const e=Ft(...xT.map(t=>n[t]));if(e)return os(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 vT(n){const e=Ft(n.description);if(e)return os(e);const t=Ft(n.script);return(t?wu(t,"name")[0]??"":"")||Ft(n.scriptPath)}function th(n){const e=Ft(...["description","summary","query","q","command","cmd","file_path","path","url","uri","pattern","prompt","objective","message","title","name"].map(s=>n[s]));if(e)return os(e);const t=Object.entries(n).find(([s,o])=>s!=="raw"&&s!=="script"&&typeof o=="string");return t?os(t[1]):""}function nh(n){const e=n.input;switch(n.name){case"Read":case"Write":case"Edit":return String(e.file_path??e.path??"");case"Bash":case"exec_command":return Xs(e);case"write_stdin":return[e.session_id!==void 0?`session ${e.session_id}`:"",Ft(e.chars)].filter(Boolean).join(" · ");case"apply_patch":return S2(Ft(e.patch,e.raw,e.input));case"TodoWrite":case"update_plan":{const t=Array.isArray(e.todos)?e.todos:Array.isArray(e.plan)?e.plan:[];return t.length>0?ol(t.length,"step"):Ft(e.explanation)}case"Grep":case"Glob":return String(e.pattern??"");case"Task":case"Agent":return xs(e.description??e.prompt);case"WebFetch":return String(e.url??"");case"NotebookEdit":return String(e.notebook_path??"");case"EnterPlanMode":return"Entered plan mode";case"ExitPlanMode":return"Waiting for plan approval";case"AskUserQuestion":case"request_user_input":case"request_user_input_async":{const t=Array.isArray(e.questions)?e.questions.find(y2):null;return Ft(t==null?void 0:t.question,t==null?void 0:t.title)}case"Monitor":{const t=String(e.bash_id??""),s=e.filter?` · filter=${e.filter}`:"";return`${t}${s}`}case"CronCreate":{const t=String(e.schedule??e.cron??""),s=String(e.prompt??""),o=s.length>60?s.slice(0,60)+"...":s;return t&&o?`${t} → ${o}`:t||o}case"CronList":return"";case"CronDelete":return String(e.id??e.cron_id??"");case"ScheduleWakeup":{const t=Number(e.delaySeconds??0),s=Math.round(t/60),o=t>=3600?`${Math.round(t/3600)}h`:t>=60?`${s}m`:`${t}s`,i=e.reason?` · ${e.reason}`:"";return`in ${o}${i}`}case"RemoteTrigger":{const t=String(e.action??""),s=String(e.id??e.trigger_id??"");return[t,s].filter(Boolean).join(" ")}case"PushNotification":return String(e.title??e.body??"");case"EnterWorktree":{const t=String(e.name??e.branch??""),s=e.path?` (${e.path})`:"";return`${t}${s}`}case"ExitWorktree":return String(e.name??e.branch??"");case"Skill":return String(e.skill??e.name??"");case"ToolSearch":return String(e.query??"");case"SendMessage":{const t=Ft(e.to,e.recipient),s=os(xs(Ft(e.summary,e.message,e.content)));return[t,s].filter(Boolean).join(" · ")}case"ListAgents":case"TaskList":return"";case"TaskCreate":return os(Ft(e.subject,e.description));case"TaskUpdate":{const t=String(e.taskId??""),s=Array.isArray(e.addBlockedBy)?e.addBlockedBy.filter(i=>typeof i=="string"):[],o=Ft(e.status)||(s.length>0?`blocked by ${s.join(", ")}`:"");return o?`${t} → ${o}`:t}case"TaskOutput":case"TaskStop":return String(e.task_id??"");case"Workflow":return vT(e);case"StructuredOutput":case"ReportFindings":case"DesignSync":case"Artifact":case"LSP":return bT(e)||th(e);case"spawn_agent":return xs(e.task_name??e.message);case"wait_agent":{const t=Array.isArray(e.ids)?e.ids.filter(s=>typeof s=="string"):[];return ai(t)}case"send_message":case"followup_task":return[e.target,xs(e.message)].filter(t=>typeof t=="string"&&t.length>0).join(" · ");case"list_agents":return String(e.path_prefix??"");case"interrupt_agent":return String(e.target??"");case"list_mcp_resources":case"list_mcp_resource_templates":return String(e.server??"");case"read_mcp_resource":return[e.server,e.uri].filter(t=>typeof t=="string").join(" · ");case"request_plugin_install":return String(e.plugin_id??"");case"create_goal":return String(e.objective??"");case"update_goal":return String(e.status??"");case"view_image":return String(e.path??"");default:return th(e)}}function Ho(n){if(ju(n))return hT(n.input.raw);const e=Cn(n.name);if(e==="WebSearch"||e==="web_search")return gT(n.input);if(e==="web__run"||e==="web.run")return w2(JSON.stringify(n.input));const t=j2(n.name);if(t)return{label:t.server,summary:[t.action,nh(n)].filter(Boolean).join(" · "),styleName:"Mcp"};const s=xa[e];return{label:(s==null?void 0:s.label)??Mr(e),summary:os(nh({name:e,input:n.input})),styleName:(s==null?void 0:s.styleName)??e}}function yT(n){return Ho(n).summary}const wT={file_path:"File",path:"Path",target:"Recipient",recipient:"Recipient",recipient_agent_id:"Recipient",agent_id:"Agent",agent_type:"Agent type",subagent_type:"Agent type",task_name:"Task",description:"Description",message:"Message",prompt:"Task",content:"Content",query:"Query",pattern:"Pattern",url:"URL",workdir:"Working directory",cwd:"Working directory",max_output_tokens:"Output limit",yield_time_ms:"Yield",timeout_ms:"Timeout"};function jT(n){return wT[n]??n.replace(/_/g," ").replace(/^./,e=>e.toUpperCase())}function ST(n,e){if(typeof e=="number"){if(n==="max_output_tokens")return`${e.toLocaleString()} tokens`;if(n.endsWith("_ms"))return e<1e3?`${e} ms`:`${e/1e3} sec`}return String(e)}function Lr(n){const e=B.c(20),{value:t}=n,[s,o]=w.useState(!1),i=w.useId();let a,l,c,d;if(e[0]!==s||e[1]!==i||e[2]!==t){const p=xs(t);a=p.length>800,l=i;const h=s&&"max-h-96 overflow-auto";e[7]!==h?(c=q("whitespace-pre-wrap break-words [overflow-wrap:anywhere]",h),e[7]=h,e[8]=c):c=e[8],d=a&&!s?`${p.slice(0,800)}…`:p,e[0]=s,e[1]=i,e[2]=t,e[3]=a,e[4]=l,e[5]=c,e[6]=d}else a=e[3],l=e[4],c=e[5],d=e[6];let u;e[9]!==l||e[10]!==c||e[11]!==d?(u=r.jsx("div",{id:l,className:c,children:d}),e[9]=l,e[10]=c,e[11]=d,e[12]=u):u=e[12];let f;e[13]!==s||e[14]!==i||e[15]!==a?(f=a&&r.jsx(ee,{type:"button",variant:"ghost",size:"xs","aria-expanded":s,"aria-controls":i,onClick:()=>o(NT),children:s?"Show less":"Show more"}),e[13]=s,e[14]=i,e[15]=a,e[16]=f):f=e[16];let m;return e[17]!==u||e[18]!==f?(m=r.jsxs(r.Fragment,{children:[u,f]}),e[17]=u,e[18]=f,e[19]=m):m=e[19],m}function NT(n){return!n}function kT(n){const e=n.todos??n.plan;return Array.isArray(e)?e.flatMap(t=>{if(!t||typeof t!="object")return[];const s=t,o=s.content??s.step??s.description;return typeof o=="string"?[{text:o,status:typeof s.status=="string"?s.status:"pending"}]:[]}):[]}function CT(n){const e=B.c(4),{steps:t}=n;let s;e[0]!==t?(s=t.map(_T),e[0]=t,e[1]=s):s=e[1];let o;return e[2]!==s?(o=r.jsx("section",{className:"mt-2 min-w-0","aria-label":"Plan",children:r.jsx("ol",{className:"flex flex-col gap-2",children:s})}),e[2]=s,e[3]=o):o=e[3],o}function _T(n,e){const t=n.status==="completed",s=n.status==="in_progress",o=t?at:s?Ed:Pa,i=t?"Completed":s?"In progress":"Pending";return r.jsxs("li",{className:"flex min-w-0 items-start gap-2 text-xs",children:[r.jsx(o,{role:"img","aria-label":i,className:q("mt-0.5 size-3 shrink-0 text-muted-foreground",s&&"text-info")}),r.jsx("div",{className:"min-w-0 flex-1",children:r.jsx(Lr,{value:n.text})}),r.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:i})]},e)}function TT(n){const e=B.c(4),{questions:t}=n;let s;e[0]!==t?(s=t.map(ET),e[0]=t,e[1]=s):s=e[1];let o;return e[2]!==s?(o=r.jsx("section",{className:"mt-2 flex min-w-0 flex-col gap-3","aria-label":"Questions",children:s}),e[2]=s,e[3]=o):o=e[3],o}function ET(n,e){return r.jsxs("div",{className:"min-w-0 text-xs",children:[r.jsx(Lr,{value:String(n.question??n.title)}),Array.isArray(n.options)&&r.jsx("ul",{className:"mt-2 flex min-w-0 flex-col gap-1.5 border-l border-border pl-3",children:n.options.map(AT)})]},e)}function AT(n,e){const t=typeof n=="string"?{label:n}:n;return!t||typeof t.label!="string"?null:r.jsxs("li",{className:"min-w-0",children:[r.jsx(Lr,{value:t.label}),typeof t.description=="string"&&r.jsx("div",{className:"mt-0.5 text-muted-foreground",children:r.jsx(Lr,{value:t.description})})]},e)}function N2(n){const e=B.c(21),{input:t}=n;let s;e[0]!==t?(s=kT(t),e[0]=t,e[1]=s):s=e[1];const o=s;let i;e[2]!==t.questions?(i=Array.isArray(t.questions)?t.questions.filter(RT):[],e[2]=t.questions,e[3]=i):i=e[3];const a=i;let l,c,d,u,f;if(e[4]!==t||e[5]!==a||e[6]!==o){f=Symbol.for("react.early_return_sentinel");e:{const p=Object.entries(t).filter(IT);if(o.length===0&&p.length===0&&a.length===0){f=null;break e}l="min-w-0",e[12]!==o?(c=o.length>0&&r.jsx(CT,{steps:o}),e[12]=o,e[13]=c):c=e[13],e[14]!==a?(d=a.length>0&&r.jsx(TT,{questions:a}),e[14]=a,e[15]=d):d=e[15],u=p.length>0&&r.jsx("dl",{className:"mt-2 flex min-w-0 flex-col gap-2","aria-label":"Call details",children:p.map(PT)})}e[4]=t,e[5]=a,e[6]=o,e[7]=l,e[8]=c,e[9]=d,e[10]=u,e[11]=f}else l=e[7],c=e[8],d=e[9],u=e[10],f=e[11];if(f!==Symbol.for("react.early_return_sentinel"))return f;let m;return e[16]!==l||e[17]!==c||e[18]!==d||e[19]!==u?(m=r.jsxs("div",{className:l,children:[c,d,u]}),e[16]=l,e[17]=c,e[18]=d,e[19]=u,e[20]=m):m=e[20],m}function PT(n){const[e,t]=n;return r.jsxs("div",{className:"grid min-w-0 grid-cols-[6.5rem_minmax(0,1fr)] items-start gap-x-3 text-xs",children:[r.jsx("dt",{className:"max-w-32 break-words text-muted-foreground",children:jT(e)}),r.jsx("dd",{className:"min-w-0 leading-relaxed",children:r.jsx(Lr,{value:ST(e,t)})})]},e)}function IT(n){const[e,t]=n;return e!=="raw"&&e!=="type"&&(typeof t=="string"?t.length>0:typeof t=="number"||typeof t=="boolean")}function RT(n){return n!==null&&typeof n=="object"&&typeof(n.question??n.title)=="string"}function $T(n){const e=B.c(25),{name:t,input:s}=n;let o;e[0]!==s||e[1]!==t?(o=Ho(typeof s.raw=="string"&&s.raw.startsWith("{")?{name:"exec",input:{raw:`tools.${t}(${s.raw})`}}:{name:t,input:s}),e[0]=s,e[1]=t,e[2]=o):o=e[2];const i=o;let a;e[3]!==s?(a=Xs(s),e[3]=s,e[4]=a):a=e[4];const l=a;let c;e[5]!==l||e[6]!==s?(c=l?Object.fromEntries(Object.entries(s).filter(MT)):s,e[5]=l,e[6]=s,e[7]=c):c=e[7];const d=c;let u;e[8]!==i.label?(u=r.jsx("span",{className:"font-medium",children:i.label}),e[8]=i.label,e[9]=u):u=e[9];let f;e[10]!==l||e[11]!==i.summary?(f=i.summary&&!l&&r.jsx("span",{className:"truncate text-muted-foreground",children:i.summary}),e[10]=l,e[11]=i.summary,e[12]=f):f=e[12];let m;e[13]!==u||e[14]!==f?(m=r.jsxs("div",{className:"mb-1 flex min-w-0 flex-wrap items-center gap-x-2 text-xs",children:[u,f]}),e[13]=u,e[14]=f,e[15]=m):m=e[15];let p;e[16]!==l?(p=l&&r.jsx(Nx,{code:l,language:"bash",label:"Command"}),e[16]=l,e[17]=p):p=e[17];let h;e[18]!==d?(h=r.jsx(N2,{input:d}),e[18]=d,e[19]=h):h=e[19];let g;return e[20]!==i.label||e[21]!==m||e[22]!==p||e[23]!==h?(g=r.jsxs("section",{className:"min-w-0","aria-label":i.label,children:[m,p,h]}),e[20]=i.label,e[21]=m,e[22]=p,e[23]=h,e[24]=g):g=e[24],g}function MT(n){const[e]=n;return e!=="command"&&e!=="cmd"}function LT(n){const e=B.c(32),{input:t}=n,s=String(t.raw??"");let o;e[0]!==t?(o=Qx(t),e[0]=t,e[1]=o):o=e[1];const i=o,[a,l]=w.useState(!1),[c,d]=ss(),u=w.useId(),f=i.length===0||a;let m;e[2]!==i?(m=i.length>0&&r.jsx("div",{className:"flex min-w-0 flex-col gap-3",children:i.map(DT)}),e[2]=i,e[3]=m):m=e[3];let p;e[4]!==i.length||e[5]!==f||e[6]!==u?(p=i.length>0?r.jsxs(ee,{type:"button",variant:"ghost",size:"xs","aria-expanded":f,"aria-controls":u,onClick:()=>l(OT),children:[r.jsx(Ye,{"data-icon":"inline-start",className:q(f&&"rotate-90")}),"Source"]}):r.jsx("span",{className:"text-xs text-muted-foreground",children:"Script"}),e[4]=i.length,e[5]=f,e[6]=u,e[7]=p):p=e[7];let h;e[8]!==d||e[9]!==s?(h=()=>d(s),e[8]=d,e[9]=s,e[10]=h):h=e[10];const g=c?"Tool script copied":"Copy script";let x;e[11]!==c?(x=c?r.jsx(at,{"data-icon":"icon"}):r.jsx(pn,{"data-icon":"icon"}),e[11]=c,e[12]=x):x=e[12];let v;e[13]!==h||e[14]!==g||e[15]!==x?(v=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:h,"aria-label":g,children:x}),e[13]=h,e[14]=g,e[15]=x,e[16]=v):v=e[16];let y;e[17]!==p||e[18]!==v?(y=r.jsxs("div",{className:"mb-1 mt-1 flex items-center justify-between gap-2",children:[p,v]}),e[17]=p,e[18]=v,e[19]=y):y=e[19];let b;e[20]!==s?(b=r.jsx(Nx,{code:s,language:"typescript",label:"Codex exec script"}),e[20]=s,e[21]=b):b=e[21];let j;e[22]!==u||e[23]!==b?(j=r.jsx(dt,{id:u,children:b}),e[22]=u,e[23]=b,e[24]=j):j=e[24];let S;e[25]!==f||e[26]!==j?(S=r.jsx(ct,{open:f,children:j}),e[25]=f,e[26]=j,e[27]=S):S=e[27];let k;return e[28]!==S||e[29]!==m||e[30]!==y?(k=r.jsxs("section",{className:"mt-2 min-w-0","aria-label":"Tool script",children:[m,y,S]}),e[28]=S,e[29]=m,e[30]=y,e[31]=k):k=e[31],k}function OT(n){return!n}function DT(n,e){return r.jsx($T,{...n},e)}const zT=/(?:^|;|&&)\s*echo\s+(["']?)---([\w.-]*)\1\s*(?=;|&&|$)/g;function sh(n){return n.replace(/^\s*(?:;|&&)/,"").trim()}function k2(n,e){const t=[],s=[];let o=0;for(const l of n.matchAll(zT)){const c=sh(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=sh(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:FT(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 FT(n,e){const t=[[]];let s=0;for(const o of n.split(/\r\n|\r|\n/))s<e.length&&o===`---${e[s]}`?(t.push([]),s++):t[t.length-1].push(o);return t.map(o=>o.join(`
102
+ `).trim())}const BT=new Set(["mv","cp","rm","mkdir","touch","tee","ln","chmod","chown","install","rsync"]),UT=/(?:^|[^\d&])>{1,2}(?!\s*&|\s*\/dev\/null)/,WT=/\|\||&&|[|;\n]/,HT=new Set(["echo","printf","true","false",":"]),qT=new Set(["find","grep","rg","ag","ack","locate","which","whereis"]),KT=new Set(["cat","head","tail","less","more","wc","stat","file","strings","jq","awk","cut","sort","uniq","tr","sed","diff","xxd","od"]),VT=new Set(["ls","tree","du"]),GT=new Set(["xargs","sudo","env","time","nohup","command"]);function YT(n){const e=n.split(/\s+/);for(;e.length>1&&(GT.has(e[0])||/^-/.test(e[0]));)e.shift();const[t,...s]=e;return BT.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:UT.test(n)}const C2=/<<-?\s*['"]?\w+['"]?/,XT=/'[^']*'|"(?:[^"\\]|\\.)*"/g;function JT(n){return n.split(C2)[0].replace(XT,'""').split(WT).map(e=>e.trim()).filter(Boolean)}function QT(n){const e=JT(n);if(e.some(YT))return"write";let t=!1,s=!1,o=!1;for(const i of e){const a=i.split(/\s+/)[0];if(!(!a||HT.has(a)))if(qT.has(a))t=!0;else if(KT.has(a))s=!0;else if(VT.has(a))o=!0;else return"run"}return o?"list":t?"search":s?"read":"run"}const ZT=/^["']?((?:~|\.{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 _2(n){const e=new Set;for(const t of n.split(C2)[0].split(/\s+/)){const s=t.match(ZT);if(!s)continue;const o=s[1];o.includes("*")||o.includes("{")||o.startsWith("-")||e.add(o)}return[...e]}const e9=/^(?: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 t9(n){const e=n.trim().match(e9);if(!e)return null;const[,t,s,,o]=e;return _2(o).length?t?{path:o,from:Number(t),to:Number(s)}:{path:o}:null}const n9=/(?: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 s9(n,e){return!e||n==="read"&&e.split(`
103
+ `).length>3?!1:n9.test(e)}function T2(n){const e=QT(n.command);return{kind:e,paths:_2(n.command),readFile:e==="read"?t9(n.command):null,failed:s9(e,n.output)}}function o9(n){var e;return n.label||((e=n.command.match(/^[\w.-]+/))==null?void 0:e[0])||"…"}const r9={read:{icon:fr,label:"Read file"},search:{icon:Yt,label:"Search"},list:{icon:So,label:"List files"},run:{icon:$o,label:"Run command"},write:{icon:Sc,label:"Update files"}},i9=new Set(["command","cmd","description","timeout","run_in_background"]);function E2(n){const e=Xs(n.input);return k2(e,n.result)??[{label:"",command:e,output:n.result}]}function a9(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 l9(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 c9(n){return n.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase())}function d9(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 u9(n){const e=[];n.timeout!==void 0&&e.push(l9(n.timeout)),typeof n.run_in_background=="boolean"&&e.push(n.run_in_background?"Background":"Foreground");for(const[t,s]of Object.entries(n))i9.has(t)||s===void 0||e.push(`${c9(t)} ${d9(s)}`);return e}function f9(n,e){const t=E2(n),s=t.map(T2),o=a9(n,t,s);return{command:Xs(n.input),rows:t.map((i,a)=>({section:i,analysis:s[a],failed:s[a].failed||a===o,pending:e&&n.result===null&&!n.isError})),options:u9(n.input)}}function m9(n){return n?n.split(/\r\n|\r|\n/).length:0}function p9(n){if(n.failed)return"Failed";if(n.pending)return"Output pending";if(n.section.output===null)return"Not run";if(n.section.output==="")return"No output";const e=m9(n.section.output);return e===1?"1 line":`${e} lines`}function h9(n,e){return n.startsWith("/")?n:n.startsWith("~")||!e?null:`${e.replace(/\/$/,"")}/${n.replace(/^\.\//,"")}`}function A2(n){const e=B.c(12),{path:t,line:s,cwd:o,children:i}=n;let a;e[0]!==o||e[1]!==t?(a=h9(t,o),e[0]=o,e[1]=t,e[2]=a):a=e[2];const l=a;if(!l||!st("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(),Er(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 P2(n){const e=B.c(13),{command:t,paths:s,cwd:o}=n;if(s.length===0){let d;return e[0]!==t?(d=r.jsx(r.Fragment,{children:t}),e[0]=t,e[1]=d):d=e[1],d}let i;e[2]!==s?(i=new Set(s),e[2]=s,e[3]=i):i=e[3];const a=i;let l;if(e[4]!==t||e[5]!==o||e[6]!==a){let d;e[8]!==o||e[9]!==a?(d=(u,f)=>{const m=u.replace(/^["']|["']?[,:;]?$/g,"");return a.has(m)?r.jsx(A2,{path:m,cwd:o,children:u},f):u},e[8]=o,e[9]=a,e[10]=d):d=e[10],l=t.split(/(\s+)/).map(d),e[4]=t,e[5]=o,e[6]=a,e[7]=l}else l=e[7];let c;return e[11]!==l?(c=r.jsx(r.Fragment,{children:l}),e[11]=l,e[12]=c):c=e[12],c}const g9=/^([^\s:]+):(\d+)([:-])/;function x9(n){const e=B.c(7),{output:t,cwd:s}=n;let o;if(e[0]!==s||e[1]!==t){let a;e[3]!==s?(a=(l,c)=>{const d=l.match(g9);return r.jsx("span",{className:"block",children:d?r.jsxs(r.Fragment,{children:[r.jsxs(A2,{path:d[1],line:Number(d[2]),cwd:s,children:[d[1],":",d[2]]}),l.slice(d[1].length+d[2].length+1)]}):l||" "},c)},e[3]=s,e[4]=a):a=e[4],o=t.split(/\r\n|\r|\n/).map(a),e[0]=s,e[1]=t,e[2]=o}else o=e[2];let i;return e[5]!==o?(i=r.jsx("pre",{tabIndex:0,className:mu,children:o}),e[5]=o,e[6]=i):i=e[6],i}function I2(n){var l;const e=B.c(14),{row:t,cwd:s}=n;if(t.section.output===null){let c;e[0]!==t.pending?(c=t.pending&&r.jsx(et,{className:"size-3.5 motion-safe:animate-spin","aria-hidden":"true"}),e[0]=t.pending,e[1]=c):c=e[1];const d=t.pending?"Command is running. Waiting for output…":"Output unavailable";let u;return e[2]!==c||e[3]!==d?(u=r.jsxs("p",{className:"flex items-center gap-2 py-2 text-xs text-muted-foreground",role:"status",children:[c,d]}),e[2]=c,e[3]=d,e[4]=u):u=e[4],u}const o=(l=t.analysis.readFile)==null?void 0:l.path;let i;e[5]!==s||e[6]!==t.analysis.kind||e[7]!==t.failed?(i=t.analysis.kind==="search"&&!t.failed?c=>r.jsx(x9,{output:c,cwd:s}):void 0,e[5]=s,e[6]=t.analysis.kind,e[7]=t.failed,e[8]=i):i=e[8];let a;return e[9]!==t.failed||e[10]!==t.section.output||e[11]!==o||e[12]!==i?(a=r.jsx(_x,{result:t.section.output,isError:t.failed,filePath:o,renderResult:i}),e[9]=t.failed,e[10]=t.section.output,e[11]=o,e[12]=i,e[13]=a):a=e[13],a}function b9(n){var M;const e=B.c(52),{row:t,expandAll:s,cwd:o}=n,[i,a]=w.useState(!1),l=s||i,c=t.section.output!==null&&t.section.output!=="";let d;e[0]!==t.section?(d=o9(t.section),e[0]=t.section,e[1]=d):d=e[1];const u=`${d} section: ${t.section.command}`,{icon:f,label:m}=r9[t.analysis.kind];let p;e[2]!==f?(p=r.jsx(f,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[2]=f,e[3]=p):p=e[3];const h=t.section.label||m;let g;e[4]!==h?(g=r.jsx("span",{className:"min-w-0 flex-1 break-words text-[13px] font-medium text-foreground",children:h}),e[4]=h,e[5]=g):g=e[5];const x=t.failed&&"text-destructive";let v;e[6]!==x?(v=q("shrink-0 text-xs tabular-nums text-muted-foreground",x),e[6]=x,e[7]=v):v=e[7];let y;e[8]!==t?(y=p9(t),e[8]=t,e[9]=y):y=e[9];let b;e[10]!==v||e[11]!==y?(b=r.jsx("span",{className:v,children:y}),e[10]=v,e[11]=y,e[12]=b):b=e[12];let j;e[13]!==c||e[14]!==l?(j=c&&r.jsx(Ye,{className:q("size-3.5 shrink-0 text-muted-foreground transition-transform motion-reduce:transition-none",l&&"rotate-90"),"aria-hidden":"true"}),e[13]=c,e[14]=l,e[15]=j):j=e[15];let S;e[16]!==p||e[17]!==g||e[18]!==b||e[19]!==j?(S=r.jsxs(r.Fragment,{children:[p,g,b,j]}),e[16]=p,e[17]=g,e[18]=b,e[19]=j,e[20]=S):S=e[20];const k=S;let C;e[21]!==s?(C=O=>{s||a(O)},e[21]=s,e[22]=C):C=e[22];let N;e[23]!==k||e[24]!==s||e[25]!==c||e[26]!==u?(N=c?r.jsx(Rt,{className:q("flex min-h-9 w-full min-w-0 items-center gap-2 text-left","cursor-pointer rounded-md hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),"aria-label":u,disabled:s,children:k}):r.jsx("div",{className:"flex min-h-9 w-full min-w-0 items-center gap-2 text-left","aria-label":u,children:k}),e[23]=k,e[24]=s,e[25]=c,e[26]=u,e[27]=N):N=e[27];const E=l||!c?"whitespace-pre-wrap break-words [overflow-wrap:anywhere]":"truncate";let T;e[28]!==E?(T=q("min-w-0 flex-1 font-mono text-xs leading-relaxed text-foreground/85",E),e[28]=E,e[29]=T):T=e[29];let P;e[30]!==o||e[31]!==t.analysis.paths||e[32]!==t.section.command?(P=r.jsx(P2,{command:t.section.command,paths:t.analysis.paths,cwd:o}),e[30]=o,e[31]=t.analysis.paths,e[32]=t.section.command,e[33]=P):P=e[33];let _;e[34]!==T||e[35]!==P?(_=r.jsx("code",{className:T,children:P}),e[34]=T,e[35]=P,e[36]=_):_=e[36];let A;e[37]!==t.analysis.readFile?(A=((M=t.analysis.readFile)==null?void 0:M.from)&&r.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:["L",t.analysis.readFile.from,"–",t.analysis.readFile.to]}),e[37]=t.analysis.readFile,e[38]=A):A=e[38];let I;e[39]!==_||e[40]!==A?(I=r.jsxs("div",{className:"flex min-w-0 items-start gap-2 pl-5.5",children:[_,A]}),e[39]=_,e[40]=A,e[41]=I):I=e[41];let $;e[42]!==o||e[43]!==c||e[44]!==t?($=c&&r.jsx(dt,{children:r.jsx("div",{className:"pb-1 pl-5.5",children:r.jsx(I2,{row:t,cwd:o})})}),e[42]=o,e[43]=c,e[44]=t,e[45]=$):$=e[45];let R;return e[46]!==l||e[47]!==C||e[48]!==N||e[49]!==I||e[50]!==$?(R=r.jsxs(ct,{open:l,onOpenChange:C,className:"min-w-0 py-2",children:[N,I,$]}),e[46]=l,e[47]=C,e[48]=N,e[49]=I,e[50]=$,e[51]=R):R=e[51],R}function v9(n){const e=B.c(33),{toolCall:t,cwd:s,expandAll:o,isAgentActive:i}=n,a=o===void 0?!1:o,l=i===void 0?!1:i;let c;e[0]!==l||e[1]!==t?(c=f9(t,l),e[0]=l,e[1]=t,e[2]=c):c=e[2];const d=c,u=d.rows.length,[f,m]=ss(),p=u===1?"Bash command":"Bash commands",h=u===1?"Command":`${u} commands`;let g;e[3]!==h?(g=r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:h}),e[3]=h,e[4]=g):g=e[4];let x;e[5]!==d.command||e[6]!==m?(x=()=>m(d.command),e[5]=d.command,e[6]=m,e[7]=x):x=e[7];const v=f?"Commands copied":u===1?"Copy command":"Copy commands",y=f?"Copied":u===1?"Copy command":"Copy commands";let b;e[8]!==f?(b=f?r.jsx(at,{"data-icon":"inline-start","aria-hidden":"true"}):r.jsx(pn,{"data-icon":"inline-start","aria-hidden":"true"}),e[8]=f,e[9]=b):b=e[9];let j;e[10]!==b||e[11]!==x||e[12]!==v||e[13]!==y?(j=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:x,"aria-label":v,title:y,children:b}),e[10]=b,e[11]=x,e[12]=v,e[13]=y,e[14]=j):j=e[14];let S;e[15]!==j||e[16]!==g?(S=r.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2",children:[g,j]}),e[15]=j,e[16]=g,e[17]=S):S=e[17];let k;e[18]!==d.options?(k=d.options.length>0&&r.jsx("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 py-1 text-xs text-muted-foreground [overflow-wrap:anywhere]",children:d.options.map(y9)}),e[18]=d.options,e[19]=k):k=e[19];let C;e[20]!==d.command||e[21]!==d.rows||e[22]!==u||e[23]!==s||e[24]!==a?(C=u===1?r.jsxs(r.Fragment,{children:[r.jsx("pre",{className:"min-w-0 whitespace-pre-wrap break-words rounded-md bg-muted/40 p-3 font-mono text-xs leading-relaxed text-foreground [overflow-wrap:anywhere]",children:r.jsx(P2,{command:d.command,paths:d.rows[0].analysis.paths,cwd:s})}),r.jsx(I2,{row:d.rows[0],cwd:s})]}):r.jsx("div",{className:"min-w-0",children:d.rows.map((T,P)=>r.jsxs("div",{className:"min-w-0",children:[P>0&&r.jsx(Nt,{}),r.jsx(b9,{row:T,expandAll:a,cwd:s})]},P))}),e[20]=d.command,e[21]=d.rows,e[22]=u,e[23]=s,e[24]=a,e[25]=C):C=e[25];let N;e[26]!==k||e[27]!==C?(N=r.jsxs("div",{className:"flex min-w-0 flex-col gap-2","aria-label":"Command sections",children:[k,C]}),e[26]=k,e[27]=C,e[28]=N):N=e[28];let E;return e[29]!==S||e[30]!==N||e[31]!==p?(E=r.jsxs("section",{className:"min-w-0","aria-label":p,children:[S,N]}),e[29]=S,e[30]=N,e[31]=p,e[32]=E):E=e[32],E}function y9(n){return r.jsx("span",{children:n},n)}const R2=w.createContext({size:"default",variant:"default",spacing:2,orientation:"horizontal"});function w9(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(R2.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(Q3,{"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 j9(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=w.useContext(R2),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",kg({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(P1,{"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 $2(n){const e=B.c(22),{option:t,multiSelect:s,selected:o,showSelectedBadge:i}=n,a=i===void 0?!1:i,l=s?"rounded":"rounded-full",c=o?"border-primary bg-primary text-primary-foreground":"border-muted-foreground/30";let d;e[0]!==l||e[1]!==c?(d=q("mt-0.5 flex size-4 shrink-0 items-center justify-center border",l,c),e[0]=l,e[1]=c,e[2]=d):d=e[2];let u;e[3]!==o?(u=o&&r.jsx(at,{className:"size-3",strokeWidth:3,"data-icon":"icon"}),e[3]=o,e[4]=u):u=e[4];let f;e[5]!==d||e[6]!==u?(f=r.jsx("span",{className:d,"aria-hidden":"true",children:u}),e[5]=d,e[6]=u,e[7]=f):f=e[7];let m;e[8]!==o||e[9]!==a?(m=a&&o&&r.jsx(Pe,{variant:"secondary",className:"ml-2",children:"Selected"}),e[8]=o,e[9]=a,e[10]=m):m=e[10];let p;e[11]!==t.label||e[12]!==m?(p=r.jsxs("span",{className:"block text-xs font-medium",children:[t.label,m]}),e[11]=t.label,e[12]=m,e[13]=p):p=e[13];let h;e[14]!==t.description?(h=t.description&&r.jsx("span",{className:"mt-0.5 block text-xs leading-relaxed text-muted-foreground",children:t.description}),e[14]=t.description,e[15]=h):h=e[15];let g;e[16]!==p||e[17]!==h?(g=r.jsxs("span",{className:"min-w-0 flex-1",children:[p,h]}),e[16]=p,e[17]=h,e[18]=g):g=e[18];let x;return e[19]!==g||e[20]!==f?(x=r.jsxs(r.Fragment,{children:[f,g]}),e[19]=g,e[20]=f,e[21]=x):x=e[21],x}function S9(n){const e=B.c(30),{toolCall:t,sessionId:s}=n;let o;e[0]!==t.input.questions?(o=t.input.questions??[],e[0]=t.input.questions,e[1]=o):o=e[1];const i=o;let a;e[2]!==i?(a=()=>Object.fromEntries(i.map(N9)),e[2]=i,e[3]=a):a=e[3];const[l,c]=w.useState(a),[d,u]=w.useState(!1),[f,m]=w.useState(!1),{chat:p}=Vr(),{sendMessage:h}=p;if(i.length===0)return null;let g;e[4]!==l||e[5]!==i||e[6]!==h?(g=()=>{const E=i.map(T=>{var _;const P=(_=l[T.question])==null?void 0:_.trim();return P?i.length>1?`${T.question}
104
+ ${P}`:P:null}).filter(Boolean).join(`
105
+
106
+ `);E&&h(E),m(!0)},e[4]=l,e[5]=i,e[6]=h,e[7]=g):g=e[7];const x=g;let v;if(e[8]!==l||e[9]!==x||e[10]!==s||e[11]!==t.id){const E=async T=>{T.preventDefault(),u(!0);try{(await Zd(s,t.id,l)).ok?m(!0):x()}catch{x()}u(!1)};v=T=>{E(T)},e[8]=l,e[9]=x,e[10]=s,e[11]=t.id,e[12]=v}else v=e[12];const y=f&&"pointer-events-none opacity-50";let b;e[13]!==y?(b=q("flex flex-col gap-3",y),e[13]=y,e[14]=b):b=e[14];let j;if(e[15]!==l||e[16]!==i||e[17]!==t.id){let E;e[19]!==l||e[20]!==t.id?(E=(T,P)=>{const _=T.options&&T.options.length>0,A=new Set(T.multiSelect?(l[T.question]??"").split(", ").filter(Boolean):[]),I=`ask-user-answer-${t.id}-${P}`;return r.jsxs(Z4,{className:"gap-2 border-b border-border pb-3 last:border-b-0 last:pb-0",children:[(T.header||T.question)&&r.jsxs(e5,{variant:"label",className:"flex flex-col items-start gap-1",children:[T.header&&r.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:T.header}),r.jsx("span",{className:"text-sm leading-relaxed text-foreground",children:T.question})]}),_?r.jsx(w9,{multiple:T.multiSelect,orientation:"vertical",variant:"outline",value:T.multiSelect?Array.from(A):l[T.question]?[l[T.question]]:[],onValueChange:$=>{if(!T.multiSelect&&$.length===0)return;const R=T.multiSelect?$.join(", "):$[0];c({...l,[T.question]:R})},className:"grid w-full gap-1.5",children:T.options.map(($,R)=>{const M=T.multiSelect?A.has($.label):l[T.question]===$.label;return r.jsx(j9,{value:$.label,"aria-label":$.label,className:"h-auto w-full justify-start whitespace-normal px-3 py-2.5 text-left",children:r.jsx($2,{option:$,multiSelect:T.multiSelect,selected:M})},R)})}):r.jsxs(yt,{children:[r.jsx(wt,{htmlFor:I,children:"Answer"}),r.jsx(qa,{id:I,value:l[T.question]??"",onChange:$=>{c({...l,[T.question]:$.target.value})},rows:2,placeholder:"Type your answer..."})]})]},P)},e[19]=l,e[20]=t.id,e[21]=E):E=e[21],j=i.map(E),e[15]=l,e[16]=i,e[17]=t.id,e[18]=j}else j=e[18];const S=d||f,k=f?"Sent":d?"Sending...":"Send answer";let C;e[22]!==k||e[23]!==S?(C=r.jsx(ee,{type:"submit",size:"sm",disabled:S,children:k}),e[22]=k,e[23]=S,e[24]=C):C=e[24];let N;return e[25]!==C||e[26]!==v||e[27]!==b||e[28]!==j?(N=r.jsxs("form",{onSubmit:v,className:b,children:[j,C]}),e[25]=C,e[26]=v,e[27]=b,e[28]=j,e[29]=N):N=e[29],N}function N9(n){return[n.question,""]}function k9(n){return Array.isArray(n.input.questions)?n.input.questions.filter(e=>typeof e=="object"&&e!==null&&typeof e.question=="string"):[]}function oh(n){try{return JSON.parse(`"${n}"`)}catch{return n.replace(/\\"/g,'"').replace(/\\\\/g,"\\")}}function C9(n){const e={},t=/"((?:\\.|[^"\\])*)"\s*=\s*"((?:\\.|[^"\\])*)"/g;let s;for(;(s=t.exec(n))!==null;)e[oh(s[1])]=oh(s[2]);return e}function _9(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function T9(n,e){const t=(n.options??[]).filter(s=>{const o=s.label.trim();return o?new RegExp(`(^|[^\\p{L}\\p{N}])${_9(o)}(?=$|[^\\p{L}\\p{N}])`,"iu").test(e):!1});return t.length===1?t[0].label:void 0}function E9(n,e){if(n.asyncQuestion)return{};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=C9(n.result);for(const o of e)if(s[o.question]===void 0){const i=T9(o,n.result);i!==void 0&&(s[o.question]=i)}return s}function rh(n,e,t){return e===void 0?!1:n.multiSelect?e.split(/,\s*/).includes(t):e===t}function A9(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 b;e[6]!==s||e[7]!==t?(b=j=>rh(t,s,j.label),e[6]=s,e[7]=t,e[8]=b):b=e[8],c=l.filter(b),e[2]=s,e[3]=l,e[4]=t,e[5]=c}else c=e[5];const d=c.length,u=i&&s!==void 0&&d===0,f=o+1;let m;e[9]!==f?(m=r.jsx(Pe,{variant:"outline",className:"size-5 rounded-full p-0 font-mono text-muted-foreground",children:f}),e[9]=f,e[10]=m):m=e[10];let p;e[11]!==t.header?(p=t.header&&r.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:t.header}),e[11]=t.header,e[12]=p):p=e[12];let h;e[13]!==m||e[14]!==p?(h=r.jsxs("div",{className:"mb-1.5 flex items-center gap-2",children:[m,p]}),e[13]=m,e[14]=p,e[15]=h):h=e[15];let g;e[16]!==t.question?(g=r.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:t.question}),e[16]=t.question,e[17]=g):g=e[17];let x;e[18]!==s||e[19]!==l||e[20]!==t?(x=l.length>0&&r.jsx("div",{className:"mt-2 flex flex-col divide-y divide-border",children:l.map((b,j)=>{const S=rh(t,s,b.label);return r.jsx("div",{className:q("flex items-start gap-2.5 py-2",S?"text-foreground":"text-muted-foreground"),children:r.jsx($2,{option:b,multiSelect:t.multiSelect,selected:S,showSelectedBadge:!0})},`${b.label}-${j}`)})}),e[18]=s,e[19]=l,e[20]=t,e[21]=x):x=e[21];let v;e[22]!==s||e[23]!==u?(v=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]=v):v=e[24];let y;return e[25]!==h||e[26]!==g||e[27]!==x||e[28]!==v?(y=r.jsxs("div",{className:"border-b border-border py-3 last:border-b-0",children:[h,g,x,v]}),e[25]=h,e[26]=g,e[27]=x,e[28]=v,e[29]=y):y=e[29],y}function P9(n){const e=B.c(62),{toolCall:t,expandToolPayloads:s,isAwaitingAnswer:o,sessionId:i}=n,[a,l]=w.useState(!1);let c;e[0]!==t?(c=k9(t),e[0]=t,e[1]=c):c=e[1];const d=c;let u;e[2]!==d||e[3]!==t?(u=E9(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&&!t.asyncQuestion,h=!p&&!t.isError&&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,v=t.isError?Xt:p?Hn:Mo,y=t.isError?"Not answered":p?"Answered":h?"Waiting for answer":"No answer recorded",b=t.isError&&"border-destructive/30";let j;e[7]!==b?(j=q("my-1 overflow-hidden rounded-lg border bg-card",b),e[7]=b,e[8]=j):j=e[8];let S;e[9]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx(Ad,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground","data-icon":"inline-start"}),e[9]=S):S=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 E=t.isError?"destructive":p?"secondary":"outline";let T;e[14]!==v?(T=r.jsx(v,{"data-icon":"inline-start"}),e[14]=v,e[15]=T):T=e[15];let P;e[16]!==y||e[17]!==E||e[18]!==T?(P=r.jsxs(Pe,{variant:E,children:[T,y]}),e[16]=y,e[17]=E,e[18]=T,e[19]=P):P=e[19];let _;e[20]!==P||e[21]!==N?(_=r.jsxs("div",{className:"min-w-0 flex-1",children:[N,P]}),e[20]=P,e[21]=N,e[22]=_):_=e[22];let A;e[23]!==t.timestamp?(A=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]=A):A=e[24];let I;e[25]!==_||e[26]!==A?(I=r.jsxs("header",{className:"flex items-start gap-2.5 border-b px-3 py-2.5",children:[S,_,A]}),e[25]=_,e[26]=A,e[27]=I):I=e[27];let $;e[28]!==f||e[29]!==h||e[30]!==d||e[31]!==i||e[32]!==t?($=h&&i?r.jsx(S9,{toolCall:t,sessionId:i}):d.length>0?d.map((U,W)=>r.jsx(A9,{question:U,answer:f[U.question],index:W,completed:t.result!==null&&!t.asyncQuestion},`${U.question}-${W}`)):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 R;e[34]!==x||e[35]!==t.asyncQuestion||e[36]!==t.isError||e[37]!==t.result?(R=t.result!==null&&!t.asyncQuestion&&!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.asyncQuestion,e[36]=t.isError,e[37]=t.result,e[38]=R):R=e[38];let M;e[39]!==$||e[40]!==R?(M=r.jsxs("div",{className:"px-3",children:[$,R]}),e[39]=$,e[40]=R,e[41]=M):M=e[41];let O;e[42]!==s?(O=()=>{s||l(I9)},e[42]=s,e[43]=O):O=e[43];let D;e[44]!==m?(D=m?r.jsx(mt,{"data-icon":"inline-start"}):r.jsx(Ye,{"data-icon":"inline-start"}),e[44]=m,e[45]=D):D=e[45];let z;e[46]!==m||e[47]!==O||e[48]!==D?(z=r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:O,className:"-ml-2 text-muted-foreground","aria-expanded":m,children:[D,"Raw details"]}),e[46]=m,e[47]=O,e[48]=D,e[49]=z):z=e[49];let F;e[50]!==m||e[51]!==t.input||e[52]!==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[50]=m,e[51]=t.input,e[52]=t.result,e[53]=F):F=e[53];let L;e[54]!==z||e[55]!==F?(L=r.jsxs("div",{className:"border-t px-3 py-1.5",children:[z,F]}),e[54]=z,e[55]=F,e[56]=L):L=e[56];let H;return e[57]!==I||e[58]!==M||e[59]!==L||e[60]!==j?(H=r.jsxs("section",{className:j,"aria-label":"Question history",children:[I,M,L]}),e[57]=I,e[58]=M,e[59]=L,e[60]=j,e[61]=H):H=e[61],H}function I9(n){return!n}function R9(n){const e=B.c(4),{styleName:t}=n;let s;e[0]!==t?(s={Read:fr,Write:ts,Edit:ts,Bash:yo,Grep:Yt,Glob:ew,WebFetch:wo,WebSearch:wo,TodoWrite:Z3,Task:An,SendMessage:Lo,AskUserQuestion:Ad,Skill:jr}[t]??A1,e[0]=t,e[1]=s):s=e[1];const o=s;let i;return e[2]!==o?(i=r.jsx(o,{className:"size-4 shrink-0","aria-hidden":"true"}),e[2]=o,e[3]=i):i=e[3],i}function $9({toolCall:n,failed:e=!!n.isError,isAgentActive:t}){const s=n.result===null,o=s&&t&&!e,i=e?Ps:o?et:s?Mo:at,a=e?"Failed":o?"Running":s?"No result":"Completed";return r.jsxs("span",{className:q("flex shrink-0 items-center gap-1.5 text-xs text-muted-foreground",e&&"text-destructive",o&&"text-info"),title:a,children:[r.jsx(i,{role:"img","aria-label":`Tool call ${e?"failed":o?"running":s?"has no result":"completed"}`,className:q("size-3.5",o&&"motion-safe:animate-spin")}),r.jsx("span",{className:q(!e&&!s&&"sr-only"),children:a})]})}const M9={"Read file":["read","reads"],"Write file":["write","writes"],"Edit file":["edit","edits"],"Apply patch":["edit","edits"],"Edit notebook":["edit","edits"],"Run command":["command","commands"],"Continue command":["command","commands"],"Search files":["search","searches"],"Find files":["search","searches"],"Search web":["search","searches"],"Search images":["image search","image searches"],"Open page":["page","pages"],"Open link":["page","pages"],"View image":["image","images"],"Spawn agent":["agent","agents"],"Message agent":["message","messages"],"Ask question":["question","questions"],"Use skill":["skill","skills"],"Update plan":["plan update","plan updates"],"Run tools":["tool batch","tool batches"],"Run tool script":["tool script","tool scripts"]};function Uu(n){var t;if(n.isError)return!0;const e=Xs(n.input);return!e||n.result===null||Ho(n).styleName!=="Bash"?!1:((t=k2(e,n.result))==null?void 0:t.some(s=>T2(s).failed))??!1}function L9(n,e=!1){const t=new Map,s={total:n.length,completed:0,failed:0,running:0,unavailable:0,groups:[],text:""};for(const o of n){Uu(o)?s.failed++:o.result!==null?s.completed++:e?s.running++:s.unavailable++;const{label:i}=Ho(o),a=M9[i],l=(a==null?void 0:a[0])??i,c=t.get(l);c?c.count++:t.set(l,{count:1,nouns:a})}return s.groups=[...t].map(([o,{count:i,nouns:a}])=>({label:o,count:i,text:a?`${i} ${a[i===1?0:1]}`:`${o} ×${i}`})),s.text=s.groups.map(o=>o.text).join(" · "),s}function O9(n,e){return e?e.flatMap(t=>t.kind==="thinking"?t.blocks.map(s=>({kind:"thinking",blocks:[s]})):t.toolCalls.map(s=>({kind:"tool_call",toolCall:s}))):n.map(t=>({kind:"tool_call",toolCall:t}))}const D9=3;function z9(n,e,t=!1){if(!e)return{visible:[...n],hidden:0};const s=n.length-D9,o=n.filter((i,a)=>a>=s||i.kind==="tool_call"&&(Uu(i.toolCall)||t&&i.toolCall.result===null));return{visible:o,hidden:n.length-o.length}}function F9(n,e=!1){return e?"text-destructive":aT(n)==="mutating"?"text-foreground":"text-muted-foreground"}function B9(n){if(n.isError)return null;const e=n.name==="Read"?n.input.file_path:/(?:^|[._])view_image$/.test(n.name)?n.input.path:null;return typeof e=="string"&&_u(e)?e:null}function U9(n){const e=B.c(23),{summary:t,filePath:s,monospace:o}=n;let i;e[0]!==t?(i=t.lastIndexOf("/"),e[0]=t,e[1]=i):i=e[1];let a;e[2]!==t?(a=t.lastIndexOf("\\"),e[2]=t,e[3]=a):a=e[3];const l=Math.max(i,a);if(s&&t.length>30&&l>=0){let f;e[4]!==l||e[5]!==t?(f=t.slice(0,l+1),e[4]=l,e[5]=t,e[6]=f):f=e[6];let m;e[7]!==f?(m=r.jsx("span",{className:"truncate",children:f}),e[7]=f,e[8]=m):m=e[8];let p;e[9]!==l||e[10]!==t?(p=t.slice(l+1),e[9]=l,e[10]=t,e[11]=p):p=e[11];let h;e[12]!==p?(h=r.jsx("span",{className:"max-w-full shrink-0 truncate",children:p}),e[12]=p,e[13]=h):h=e[13];let g;return e[14]!==t||e[15]!==m||e[16]!==h?(g=r.jsxs("span",{className:"flex min-w-0 font-mono text-xs leading-5 text-muted-foreground",title:t,children:[m,h]}),e[14]=t,e[15]=m,e[16]=h,e[17]=g):g=e[17],g}const c=o&&"font-mono";let d;e[18]!==c?(d=q("line-clamp-2 min-w-0 text-xs leading-5 text-muted-foreground [overflow-wrap:anywhere]",c),e[18]=c,e[19]=d):d=e[19];let u;return e[20]!==t||e[21]!==d?(u=r.jsx("span",{className:d,title:t,children:t}),e[20]=t,e[21]=d,e[22]=u):u=e[22],u}function W9(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(Fu,{oldString:s,newString:o,filePath:i}),e[0]=s,e[1]=o,e[2]=i,e[3]=a):a=e[3],a}const M2=w.memo(function(e){var ue,me,de,le;const t=B.c(186),{toolCall:s,expandToolPayloads:o,isAgentActive:i,skillMetadata:a}=e,l=o===void 0?!1:o,{session:c,pendingInteraction:d}=ot(),[u,f]=w.useState(!1),[m,p]=w.useState(!1),h=w.useId(),g=w.useId(),x=w.useId();let v;t[0]!==s?(v=ju(s),t[0]=s,t[1]=v):v=t[1];const y=v;let b;t[2]!==y||t[3]!==s.input||t[4]!==s.name?(b=!y&&(s.name==="Bash"||/(?:^|[._])exec_command$/.test(s.name))&&!!Xs(s.input),t[2]=y,t[3]=s.input,t[4]=s.name,t[5]=b):b=t[5];const j=b;let S;t[6]!==s?(S=Ho(s),t[6]=s,t[7]=S):S=t[7];const k=S;let C;t[8]!==j||t[9]!==s?(C=j?E2(s):null,t[8]=j,t[9]=s,t[10]=C):C=t[10];const N=C;let E;t[11]!==s?(E=Uu(s),t[11]=s,t[12]=E):E=t[12];const T=E,P=k.label,_=k.label===s.name?s.name:`${k.label} (${s.name})`;let A,I,$,R,M,O,D,z,F,L;if(t[13]!==P||t[14]!==l||t[15]!==T||t[16]!==j||t[17]!==i||t[18]!==_||t[19]!==h||t[20]!==u||t[21]!==d||t[22]!==k.styleName||t[23]!==k.summary||t[24]!==N||t[25]!==(c==null?void 0:c.sessionId)||t[26]!==a||t[27]!==x||t[28]!==s){D=Symbol.for("react.early_return_sentinel");e:{const xe=F9(k.styleName,T);let pe;t[39]!==s.timestamp?(pe=s.timestamp?new Date(s.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}):void 0,t[39]=s.timestamp,t[40]=pe):pe=t[40];const ve=pe;let Te;t[41]!==s.timestamp?(Te=s.timestamp?new Date(s.timestamp).toISOString():void 0,t[41]=s.timestamp,t[42]=Te):Te=t[42];const $e=Te;I=l||u;let _e;t[43]!==j||t[44]!==k.summary||t[45]!==N||t[46]!==s.input?(_e=j&&typeof s.input.description=="string"&&s.input.description.trim()?s.input.description:N&&N.length>1?`${N.length} commands · ${N.map(H9).join(", ")}`:k.summary,t[43]=j,t[44]=k.summary,t[45]=N,t[46]=s.input,t[47]=_e):_e=t[47];const Ce=_e;let ke;t[48]!==a||t[49]!==Ce||t[50]!==s.name?(ke=s.name==="Skill"&&a?a.get(Ce)??null:null,t[48]=a,t[49]=Ce,t[50]=s.name,t[51]=ke):ke=t[51],M=ke,R=M==null?void 0:M.filePath,A=s.name==="Edit"&&typeof s.input.old_string=="string"&&typeof s.input.new_string=="string"&&typeof s.input.file_path=="string";const Me=B9(s),Oe=!!((ue=s.resultImages)!=null&&ue.length),Le=Me!==null&&((me=s.result)==null?void 0:me.trim())===""&&!Oe;let De;if(t[52]!==j||t[53]!==A||t[54]!==Le||t[55]!==Oe||t[56]!==s.isError||t[57]!==s.result?(De=s.result!==null&&!Le&&!j&&(!Oe||!!((de=s.result)!=null&&de.trim()))&&(!A||s.isError),t[52]=j,t[53]=A,t[54]=Le,t[55]=Oe,t[56]=s.isError,t[57]=s.result,t[58]=De):De=t[58],$=De,s.name==="AskUserQuestion"){const At=(d==null?void 0:d.type)==="question"&&d.toolUseId===s.id,sn=c==null?void 0:c.sessionId;let Ot;t[59]!==l||t[60]!==At||t[61]!==sn||t[62]!==s?(Ot=r.jsx(P9,{toolCall:s,expandToolPayloads:l,isAwaitingAnswer:At,sessionId:sn}),t[59]=l,t[60]=At,t[61]=sn,t[62]=s,t[63]=Ot):Ot=t[63],D=Ot;break e}const Ie=I&&"bg-muted/25",he=T&&"bg-destructive/5";t[64]!==Ie||t[65]!==he?(z=q("min-w-0 rounded-lg",Ie,he),t[64]=Ie,t[65]=he,t[66]=z):z=t[66],F=s.id;const ge=`Toggle ${P} details${Ce?`: ${Ce}`:""}`;let Se;t[67]!==l?(Se=()=>{l||f(q9)},t[67]=l,t[68]=Se):Se=t[68];const be=T&&"text-destructive";let Fe;t[69]!==be?(Fe=q("flex size-8 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground",be),t[69]=be,t[70]=Fe):Fe=t[70];let He;t[71]!==k.styleName?(He=r.jsx(R9,{styleName:k.styleName}),t[71]=k.styleName,t[72]=He):He=t[72];let We;t[73]!==Fe||t[74]!==He?(We=r.jsx("span",{className:Fe,children:He}),t[73]=Fe,t[74]=He,t[75]=We):We=t[75];const Ee=q("text-[13px] font-medium leading-5",xe);let ze;t[76]!==P||t[77]!==_||t[78]!==Ee?(ze=r.jsx("span",{className:Ee,title:_,children:P}),t[76]=P,t[77]=_,t[78]=Ee,t[79]=ze):ze=t[79];let fe;t[80]!==j||t[81]!==Ce||t[82]!==s.input?(fe=Ce&&r.jsx(U9,{summary:Ce,filePath:[s.input.file_path,s.input.path,s.input.notebook_path].includes(Ce),monospace:!j||!s.input.description}),t[80]=j,t[81]=Ce,t[82]=s.input,t[83]=fe):fe=t[83];let we;t[84]!==ze||t[85]!==fe?(we=r.jsxs("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[ze,fe]}),t[84]=ze,t[85]=fe,t[86]=we):we=t[86];let Ue;t[87]!==T||t[88]!==i||t[89]!==s?(Ue=r.jsx($9,{toolCall:s,failed:T,isAgentActive:i}),t[87]=T,t[88]=i,t[89]=s,t[90]=Ue):Ue=t[90];let Be;t[91]!==s.hookDurationMs?(Be=!!(s.hookDurationMs&&s.hookDurationMs>0)&&r.jsxs("span",{className:"text-xs tabular-nums text-muted-foreground",title:"PostToolUse hook duration",children:[s.hookDurationMs,"ms"]}),t[91]=s.hookDurationMs,t[92]=Be):Be=t[92];let Ae;t[93]!==s.outputReplacedByHook?(Ae=s.outputReplacedByHook&&r.jsx("span",{className:"text-xs text-info",title:"Output replaced by hook",children:"hook"}),t[93]=s.outputReplacedByHook,t[94]=Ae):Ae=t[94];let qe;t[95]!==x||t[96]!==Ue||t[97]!==Be||t[98]!==Ae?(qe=r.jsxs("span",{id:x,className:"flex shrink-0 flex-col items-end gap-1",children:[Ue,Be,Ae]}),t[95]=x,t[96]=Ue,t[97]=Be,t[98]=Ae,t[99]=qe):qe=t[99];const ht=I&&"rotate-90";let Je;t[100]!==ht?(Je=q("size-3.5 shrink-0 text-muted-foreground transition-transform",ht),t[100]=ht,t[101]=Je):Je=t[101];let Ke;t[102]!==Je?(Ke=r.jsx(Ye,{className:Je,"aria-hidden":"true"}),t[102]=Je,t[103]=Ke):Ke=t[103];let Ut;t[104]!==$e||t[105]!==ve?(Ut=ve&&r.jsx("time",{className:"sr-only",dateTime:$e,children:ve}),t[104]=$e,t[105]=ve,t[106]=Ut):Ut=t[106],t[107]!==h||t[108]!==I||t[109]!==x||t[110]!==ge||t[111]!==Se||t[112]!==We||t[113]!==we||t[114]!==qe||t[115]!==Ke||t[116]!==Ut||t[117]!==ve?(L=r.jsxs("button",{type:"button",className:"group/tool flex min-h-14 w-full min-w-0 items-center gap-3 rounded-lg px-3 py-2.5 text-left transition-colors hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",title:ve,"aria-label":ge,"aria-expanded":I,"aria-controls":h,"aria-describedby":x,onClick:Se,children:[We,we,qe,Ke,Ut]}),t[107]=h,t[108]=I,t[109]=x,t[110]=ge,t[111]=Se,t[112]=We,t[113]=we,t[114]=qe,t[115]=Ke,t[116]=Ut,t[117]=ve,t[118]=L):L=t[118],O=Le&&r.jsx(Jc,{src:Me,alt:Me.slice(Me.lastIndexOf("/")+1),id:`tool-image:${s.id}`,className:"my-1.5",thumbnailClassName:"max-h-40"})}t[13]=P,t[14]=l,t[15]=T,t[16]=j,t[17]=i,t[18]=_,t[19]=h,t[20]=u,t[21]=d,t[22]=k.styleName,t[23]=k.summary,t[24]=N,t[25]=c==null?void 0:c.sessionId,t[26]=a,t[27]=x,t[28]=s,t[29]=A,t[30]=I,t[31]=$,t[32]=R,t[33]=M,t[34]=O,t[35]=D,t[36]=z,t[37]=F,t[38]=L}else A=t[29],I=t[30],$=t[31],R=t[32],M=t[33],O=t[34],D=t[35],z=t[36],F=t[37],L=t[38];if(D!==Symbol.for("react.early_return_sentinel"))return D;let H;t[119]!==s.id||t[120]!==s.resultImages?(H=(le=s.resultImages)==null?void 0:le.map((xe,pe)=>r.jsx(Jc,{src:`data:${xe.source.media_type};base64,${xe.source.data}`,alt:`Tool result image ${pe+1}`,id:`tool-result-image:${s.id}:${pe}`,className:"my-1.5",thumbnailClassName:"max-h-40"},`${xe.source.media_type}-${xe.source.data.length}-${xe.source.data.slice(0,32)}-${xe.source.data.slice(-32)}`)),t[119]=s.id,t[120]=s.resultImages,t[121]=H):H=t[121];let U;t[122]!==R||t[123]!==M?(U=M&&r.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-2 font-mono text-xs text-muted-foreground",children:[r.jsxs("span",{children:["source: ",M.source]}),R&&(!Ws()||fu())&&r.jsxs(ee,{type:"button",variant:"link",size:"xs",onClick:()=>Er(R),title:R,children:[r.jsx(K1,{"data-icon":"inline-start"}),"Open SKILL.md"]})]}),t[122]=R,t[123]=M,t[124]=U):U=t[124];let W;t[125]!==A||t[126]!==s?(W=A&&r.jsx(W9,{toolCall:s}),t[125]=A,t[126]=s,t[127]=W):W=t[127];let V;t[128]!==l||t[129]!==j||t[130]!==A||t[131]!==i||t[132]!==y||t[133]!==(c==null?void 0:c.cwd)||t[134]!==s?(V=j?r.jsx(v9,{toolCall:s,cwd:c==null?void 0:c.cwd,expandAll:l,isAgentActive:!!i}):y?r.jsx(LT,{input:s.input}):A?null:r.jsx(N2,{input:s.input}),t[128]=l,t[129]=j,t[130]=A,t[131]=i,t[132]=y,t[133]=c==null?void 0:c.cwd,t[134]=s,t[135]=V):V=t[135];let K;t[136]!==$||t[137]!==s.input||t[138]!==s.isError||t[139]!==s.name||t[140]!==s.result?(K=$&&r.jsx(_x,{result:s.result??"",isError:s.isError,filePath:s.name==="Read"&&typeof s.input.file_path=="string"?s.input.file_path:void 0}),t[136]=$,t[137]=s.input,t[138]=s.isError,t[139]=s.name,t[140]=s.result,t[141]=K):K=t[141];let Y;t[142]===Symbol.for("react.memo_cache_sentinel")?(Y=()=>p(K9),t[142]=Y):Y=t[142];const X=m&&"rotate-90";let G;t[143]!==X?(G=q(X),t[143]=X,t[144]=G):G=t[144];let J;t[145]!==G?(J=r.jsx(Ye,{"data-icon":"inline-start",className:G}),t[145]=G,t[146]=J):J=t[146];let Z;t[147]!==g||t[148]!==m||t[149]!==J?(Z=r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",className:"mt-1","aria-expanded":m,"aria-controls":g,onClick:Y,children:[J,"Raw input"]}),t[147]=g,t[148]=m,t[149]=J,t[150]=Z):Z=t[150];let Q;t[151]!==s.input?(Q=JSON.stringify(s.input),t[151]=s.input,t[152]=Q):Q=t[152];let te;t[153]!==Q?(te=r.jsx(Cx,{result:Q}),t[153]=Q,t[154]=te):te=t[154];let ne;t[155]!==g||t[156]!==te?(ne=r.jsx(dt,{id:g,children:te}),t[155]=g,t[156]=te,t[157]=ne):ne=t[157];let oe;t[158]!==m||t[159]!==Z||t[160]!==ne?(oe=r.jsxs(ct,{open:m,children:[Z,ne]}),t[158]=m,t[159]=Z,t[160]=ne,t[161]=oe):oe=t[161];let re;t[162]!==W||t[163]!==V||t[164]!==K||t[165]!==oe?(re=r.jsxs("div",{className:"min-w-0 px-3 pb-3 pt-1 sm:pl-14",children:[W,V,K,oe]}),t[162]=W,t[163]=V,t[164]=K,t[165]=oe,t[166]=re):re=t[166];let ie;t[167]!==h||t[168]!==re?(ie=r.jsx(dt,{id:h,children:re}),t[167]=h,t[168]=re,t[169]=ie):ie=t[169];let se;t[170]!==I||t[171]!==ie?(se=r.jsx(ct,{open:I,children:ie}),t[170]=I,t[171]=ie,t[172]=se):se=t[172];let ce;t[173]!==s.id||t[174]!==s.name||t[175]!==s.result?(ce=(s.name==="Task"||s.name==="Agent")&&s.result===null&&r.jsx(Du,{toolUseId:s.id}),t[173]=s.id,t[174]=s.name,t[175]=s.result,t[176]=ce):ce=t[176];let ae;return t[177]!==O||t[178]!==H||t[179]!==U||t[180]!==se||t[181]!==ce||t[182]!==z||t[183]!==F||t[184]!==L?(ae=r.jsxs("div",{className:z,"data-tool-call-id":F,children:[L,O,H,U,se,ce]}),t[177]=O,t[178]=H,t[179]=U,t[180]=se,t[181]=ce,t[182]=z,t[183]=F,t[184]=L,t[185]=ae):ae=t[185],ae});function H9(n){return n.label||n.command.split(/\s+/)[0]}function q9(n){return!n}function K9(n){return!n}const V9=w.memo(function({plan:e,planFilePath:t,status:s,toolCalls:o,expandAll:i=!1,expandToolPayloads:a=!1,isAgentActive:l,skillMetadata:c}){const[d,u]=w.useState(!0),f=o.some(j=>j.name==="AskUserQuestion"&&j.result===null),[m,p]=w.useState(null),h=w.useRef(f);w.useEffect(()=>{f&&(h.current=!0)},[f]);const g=i||d,x=i||(m??(f||h.current)),v=s==="approved"?Br:s==="rejected"?Ps:Us,y=g?mt:Ye,b=x?mt:Ye;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(Rt,{render:r.jsx(ee,{type:"button",variant:"ghost",className:"h-auto w-full justify-start rounded-b-none p-2 text-left"}),children:[r.jsx(y,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),r.jsx(tw,{className:"size-4 text-muted-foreground","data-icon":"inline-start"}),r.jsx("span",{className:"text-sm font-medium",children:"Plan Mode"}),r.jsx(v,{className: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(qn,{remarkPlugins:Yn,components:Gn,children:e})}),o.length>0&&r.jsxs(ct,{open:x,onOpenChange:p,className:"mt-2",children:[r.jsxs(Rt,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"-ml-2 text-muted-foreground"}),children:[r.jsx(b,{"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(j=>r.jsx(M2,{toolCall:j,expandToolPayloads:a,isAgentActive:l,skillMetadata:c},j.id))})})]})]})})]})}),G9=w.memo(function(e){const t=B.c(13),{content:s}=e,[o,i]=w.useState(!0),a=o?mt:Ye;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(V1,{className:"size-4 text-muted-foreground","data-icon":"inline-start"}),u=r.jsx("span",{className:"text-sm font-medium",children:"Session recap"}),t[3]=d,t[4]=u):(d=t[3],u=t[4]);let f;t[5]!==c?(f=r.jsxs(Rt,{render:l,children:[c,d,u]}),t[5]=c,t[6]=f):f=t[6];let m;t[7]!==s?(m=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(qn,{remarkPlugins:Yn,components:Gn,children:s})})}),t[7]=s,t[8]=m):m=t[8];let p;return t[9]!==o||t[10]!==f||t[11]!==m?(p=r.jsxs(ct,{open:o,onOpenChange:i,className:"my-2 rounded-lg border bg-card",children:[f,m]}),t[9]=o,t[10]=f,t[11]=m,t[12]=p):p=t[12],p}),Y9=w.memo(function(e){const t=B.c(15),{blocks:s,expandAll:o}=e,[i,a]=w.useState(!1),l=o||i;if(s.length===0)return null;let c;t[0]!==o?(c=p=>{o||a(p)},t[0]=o,t[1]=c):c=t[1];let d;t[2]!==s.length||t[3]!==o||t[4]!==l?(d=!o&&r.jsxs(Rt,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"-ml-2 text-muted-foreground"}),children:[l?r.jsx(mt,{"data-icon":"inline-start"}):r.jsx(Ye,{"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(X9),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 X9(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)}const ih=w.memo(function(e){const t=B.c(111),{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]=w.useState(null),v=w.useRef(null),y=w.useId(),b=w.useId();let j;t[0]!==m||t[1]!==s?(j=L9(s,m),t[0]=m,t[1]=s,t[2]=j):j=t[2];const S=j,k=S.running>0;let C;t[3]!==s?(C=s.some(J9),t[3]=s,t[4]=C):C=t[4];const N=C,E=o||N||(g??k),T=g===null&&k&&!o&&!N;let P;t[5]!==c||t[6]!==s?(P=O9(s,c),t[5]=c,t[6]=s,t[7]=P):P=t[7];const _=P;let A;t[8]!==_||t[9]!==m||t[10]!==T?(A=z9(_,T,m),t[8]=_,t[9]=m,t[10]=T,t[11]=A):A=t[11];const I=A,$=w.useRef(null),R=w.useRef(null);let M,O;t[12]!==a||t[13]!==s?(M=()=>{if(!a){$.current=null;return}a!==$.current&&s.some(oe=>oe.id===a)&&($.current=a,x(!0),R.current=requestAnimationFrame(()=>{R.current=requestAnimationFrame(()=>{var oe;R.current=null,(oe=v.current)==null||oe.scrollIntoView({behavior:"smooth",block:"nearest"})})}))},O=[a,s],t[12]=a,t[13]=s,t[14]=M,t[15]=O):(M=t[14],O=t[15]),w.useEffect(M,O);let D,z;t[16]===Symbol.for("react.memo_cache_sentinel")?(D=()=>()=>{R.current!==null&&cancelAnimationFrame(R.current)},z=[],t[16]=D,t[17]=z):(D=t[16],z=t[17]),w.useEffect(D,z);let F,L,H,U,W,V,K,Y,X,G,J;if(t[18]!==a||t[19]!==c||t[20]!==_||t[21]!==o||t[22]!==i||t[23]!==N||t[24]!==m||t[25]!==E||t[26]!==y||t[27]!==f||t[28]!==b||t[29]!==S.failed||t[30]!==S.running||t[31]!==S.text||t[32]!==S.unavailable||t[33]!==I||t[34]!==p||t[35]!==h||t[36]!==s[0]||t[37]!==s.length){J=Symbol.for("react.early_return_sentinel");e:{const oe=function(De){const Ie=a===De.id;return r.jsx("div",{ref:Ie?v:void 0,className:q("min-w-0",Ie&&"rounded-lg ring-2 ring-ring"),children:r.jsx(M2,{toolCall:De,expandToolPayloads:i,isAgentActive:m&&De.result===null,skillMetadata:f})},De.id)};if(s.length===1&&p===0&&!c){J=oe(s[0]);break e}const re=s.length>0?`${s.length} tool ${s.length===1?"call":"calls"}`:"Thinking";let ie;t[49]!==p||t[50]!==h?(ie=h>0?`Thought for ${Math.max(1,Math.round(h/1e3))}s`:p>0?"Includes thinking":"",t[49]=p,t[50]=h,t[51]=ie):ie=t[51];const se=ie;let ce;t[52]!==S.text||t[53]!==se?(ce=[S.text,se].filter(Boolean),t[52]=S.text,t[53]=se,t[54]=ce):ce=t[54];const ae=ce.join(" · ");Y="min-w-0 rounded-xl border border-border/80 bg-card/50",X="";const ue=`${E?"Collapse":"Expand"} ${re}${ae?`: ${ae}`:""}`,me=o||N||void 0;let de;t[55]!==o||t[56]!==N||t[57]!==E?(de=()=>{!o&&!N&&x(!E)},t[55]=o,t[56]=N,t[57]=E,t[58]=de):de=t[58];let le;t[59]===Symbol.for("react.memo_cache_sentinel")?(le=r.jsx(nw,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),t[59]=le):le=t[59];let xe;t[60]!==re?(xe=r.jsx("span",{className:"text-[13px] font-medium text-foreground",children:re}),t[60]=re,t[61]=xe):xe=t[61];let pe;t[62]!==ae?(pe=ae&&r.jsx("span",{className:"text-xs leading-5 text-muted-foreground [overflow-wrap:anywhere]",children:ae}),t[62]=ae,t[63]=pe):pe=t[63];let ve;t[64]!==xe||t[65]!==pe?(ve=r.jsxs("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[xe,pe]}),t[64]=xe,t[65]=pe,t[66]=ve):ve=t[66];let Te;t[67]!==S.running?(Te=S.running>0&&r.jsxs("span",{className:"flex items-center gap-1.5 text-info",children:[r.jsx(et,{className:"size-3.5 motion-safe:animate-spin","aria-hidden":"true"}),S.running," running"]}),t[67]=S.running,t[68]=Te):Te=t[68];let $e;t[69]!==S.failed?($e=S.failed>0&&r.jsxs("span",{className:"flex items-center gap-1.5 text-destructive",children:[r.jsx(Ps,{className:"size-3.5","aria-hidden":"true"}),S.failed," failed"]}),t[69]=S.failed,t[70]=$e):$e=t[70];let _e;t[71]!==S.unavailable?(_e=S.unavailable>0&&r.jsxs("span",{className:"text-muted-foreground",children:[S.unavailable," no result"]}),t[71]=S.unavailable,t[72]=_e):_e=t[72];let Ce;t[73]!==b||t[74]!==Te||t[75]!==$e||t[76]!==_e?(Ce=r.jsxs("span",{id:b,className:"flex shrink-0 flex-col items-end gap-1 text-xs",children:[Te,$e,_e]}),t[73]=b,t[74]=Te,t[75]=$e,t[76]=_e,t[77]=Ce):Ce=t[77];const ke=E&&"rotate-90";let Me;t[78]!==ke?(Me=q("size-3.5 shrink-0 text-muted-foreground transition-transform",ke),t[78]=ke,t[79]=Me):Me=t[79];let Oe;t[80]!==Me?(Oe=r.jsx(Ye,{className:Me,"aria-hidden":"true"}),t[80]=Me,t[81]=Oe):Oe=t[81],t[82]!==E||t[83]!==y||t[84]!==b||t[85]!==ue||t[86]!==me||t[87]!==de||t[88]!==ve||t[89]!==Ce||t[90]!==Oe?(G=r.jsxs("button",{type:"button",className:"flex min-h-14 w-full min-w-0 items-center gap-3 rounded-xl px-3 py-3 text-left transition-colors hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":ue,"aria-expanded":E,"aria-controls":y,"aria-describedby":b,"aria-disabled":me,onClick:de,children:[le,ve,Ce,Oe]}),t[82]=E,t[83]=y,t[84]=b,t[85]=ue,t[86]=me,t[87]=de,t[88]=ve,t[89]=Ce,t[90]=Oe,t[91]=G):G=t[91],L=ct,K=E,F=dt,V=y,H="min-w-0 border-t border-border/70 px-1 py-1",t[92]!==I.hidden?(U=I.hidden>0&&r.jsxs(ee,{type:"button",variant:"ghost",size:"sm",className:"mb-1 ml-2",onClick:()=>x(!0),children:["Show ",I.hidden," earlier ",I.hidden===1?"step":"steps"]}),t[92]=I.hidden,t[93]=U):U=t[93],W=I.visible.map(Le=>Le.kind==="tool_call"?oe(Le.toolCall):r.jsx("div",{className:"px-3 py-1",children:r.jsx(Y9,{blocks:Le.blocks,expandAll:!1})},`thinking-${_.filter(Q9).indexOf(Le)}`))}t[18]=a,t[19]=c,t[20]=_,t[21]=o,t[22]=i,t[23]=N,t[24]=m,t[25]=E,t[26]=y,t[27]=f,t[28]=b,t[29]=S.failed,t[30]=S.running,t[31]=S.text,t[32]=S.unavailable,t[33]=I,t[34]=p,t[35]=h,t[36]=s[0],t[37]=s.length,t[38]=F,t[39]=L,t[40]=H,t[41]=U,t[42]=W,t[43]=V,t[44]=K,t[45]=Y,t[46]=X,t[47]=G,t[48]=J}else F=t[38],L=t[39],H=t[40],U=t[41],W=t[42],V=t[43],K=t[44],Y=t[45],X=t[46],G=t[47],J=t[48];if(J!==Symbol.for("react.early_return_sentinel"))return J;let Z;t[94]!==H||t[95]!==U||t[96]!==W?(Z=r.jsxs("div",{className:H,children:[U,W]}),t[94]=H,t[95]=U,t[96]=W,t[97]=Z):Z=t[97];let Q;t[98]!==F||t[99]!==V||t[100]!==Z?(Q=r.jsx(F,{id:V,children:Z}),t[98]=F,t[99]=V,t[100]=Z,t[101]=Q):Q=t[101];let te;t[102]!==L||t[103]!==K||t[104]!==Q?(te=r.jsx(L,{open:K,children:Q}),t[102]=L,t[103]=K,t[104]=Q,t[105]=te):te=t[105];let ne;return t[106]!==Y||t[107]!==X||t[108]!==G||t[109]!==te?(ne=r.jsxs("div",{className:Y,"data-tool-activity":X,children:[G,te]}),t[106]=Y,t[107]=X,t[108]=G,t[109]=te,t[110]=ne):ne=t[110],ne});function J9(n){return n.name==="AskUserQuestion"}function Q9(n){return n.kind==="thinking"}function Z9(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(Ye,{"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}function td(n,e){if(!n&&!e)return{add:0,del:0};const t=n?n.split(`
107
+ `):[],s=e?e.split(`
108
+ `):[];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 eE(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(`
109
+ `);if(l){const c=td("",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(`
110
+ `),o=t.map(a=>a.current).join(`
111
+ `),i=td(s,o);return{originalStr:s,currentStr:o,addCount:i.add,delCount:i.del}}const L2="synthesizedFrom",ah=/[.*+?[\]{}()^$|]/,tE=/[$*?`~]|\\\s/,O2=/<<(-?)\s*(?:'([^']+)'|"([^"]+)")/,nE=new RegExp(O2,"g");function Wu(n,e,t,s){return{id:e,name:t,input:{...s,[L2]:n.name},result:null,isError:!1,timestamp:n.timestamp}}function sE(n){return typeof n.input[L2]=="string"}function oE(n){const e=n[0];return(e==='"'||e==="'")&&n.at(-1)===e?n.slice(1,-1):n}function lh(n){const e=[];for(const t of n.split("/"))!t||t==="."||(t===".."?e.pop():e.push(t));return`/${e.join("/")}`}function rl(n,e){const t=oE(n.trim());return!t||tE.test(t)?null:t.startsWith("/")?lh(t):e?lh(`${e}/${t}`):null}function rE(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 iE(n){const e=n.split(`
112
+ `),t=[];let s=0;for(;s<e.length;){const o=e[s];s++;const i=new Map;for(const a of o.matchAll(nE)){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(`
113
+ `)))}for(const a of rE(o))t.push({text:a.text,bodies:i,piped:a.piped})}return t}function aE(n,e){const t=n.match(/^cd\s+(?:"([^"]*)"|'([^']*)'|([^\s;&|]+))\s*$/);return t?rl(t[1]??t[2]??t[3]??"",e):null}function lE(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 cE(n,e){if(n.piped||n.bodies.size===0)return null;const t=n.text.match(O2);if(!t)return null;const s=n.bodies.get(t[2]??t[3]??"");if(s===void 0)return null;const o=lE(n.text);if(!o)return null;const i=rl(o,e);return i?{name:"Write",input:{file_path:i,content:s}}:null}function ch(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==="|"||!ah.test(a)&&!"\\/&#".includes(a))return null;s+=a,o++;continue}if(i==="&"&&t||!t&&ah.test(i))return null;s+=i}return s}const dE=/^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 uE(n,e){var m;const t=(m=n.text.match(dE))==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=ch(s,"pattern"),u=ch(o,"replacement");if(!d||u===null)return null;const f=rl(a??l??c??"",e);return f?{name:"Edit",input:{file_path:f,old_string:d,new_string:u,replace_all:i.includes("g")}}:null}function D2(n,e=null){const t=n.input.command;if(typeof t!="string"||!t)return[];const s=[];let o=e;for(const i of iE(t)){const a=aE(i.text,o);if(a){o=a;continue}const l=cE(i,o)??uE(i,o);l&&s.push(Wu(n,`${n.id}:bash-${s.length}`,l.name,l.input))}return s}function z2(n,e){const t=n.input.edits,s=n.input.file_path??n.input.path;if(!Array.isArray(t)||typeof s!="string")return[];const o=rl(s,e)??s,i=[];for(const[a,l]of t.entries()){if(typeof l!="object"||l===null)continue;const{old_string:c,new_string:d,replace_all:u}=l;typeof c!="string"||typeof d!="string"||i.push(Wu(n,`${n.id}:edit-${a}`,"Edit",{file_path:o,old_string:c,new_string:d,replace_all:u===!0}))}return i}function F2(n,e){const t=[n.input.patch,n.input.value,n.input.input].find(s=>typeof s=="string");return t?d0("apply_patch",t,n.id,n.timestamp,e??"").map(s=>Wu(n,s.id,s.name,s.input)):[]}function xr(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(...z2(s,e)):s.name==="Bash"?t.push(...D2(s,e)):s.name==="apply_patch"&&t.push(...F2(s,e)));return t}function va(n,e=null){for(const t of n)if(!t.isError&&(t.name==="Edit"||t.name==="Write"||t.name==="MultiEdit"&&z2(t,e).length>0||t.name==="Bash"&&D2(t,e).length>0||t.name==="apply_patch"&&F2(t,e).length>0))return!0;return!1}const fE=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"]),mE={json:jm,jsonc:jm,md:fr,mdx:fr,txt:fr,png:Ms,jpg:Ms,jpeg:Ms,gif:Ms,webp:Ms,svg:Ms,ico:Ms,sh:_i,bash:_i,zsh:_i,fish:_i};function B2(n){const e=n.split("/").at(-1)??n,t=e.lastIndexOf(".");return t===-1?"":e.slice(t+1).toLowerCase()}function pE(n){const e=B2(n);return mE[e]??(fE.has(e)?Wr:O1)}function Eo(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 dh=5;function Hu(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*dh);i=dh-u,a="flex items-center gap-[1px] shrink-0 ml-1",l=Array.from({length:u},gE),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},hE),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 hE(n,e){return r.jsx("span",{className:"inline-block size-1.5 rounded-xs bg-destructive/70"},`d${e}`)}function gE(n,e){return r.jsx("span",{className:"inline-block size-1.5 rounded-xs bg-success/70"},`a${e}`)}const ya="cogpit:open-subagent";function U2(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 qu(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(ya,{detail:{agentId:t}}))},children:"S"}),e[0]=t,e[1]=s):s=e[1],s}const W2=w.memo(function(e){const t=B.c(92),{file:s,defaultOpen:o,isHighlighted:i,diffMode:a}=e,{ref:l,isNear:c}=s2(),[d,u]=w.useState(o),[f,m]=w.useState(o),p=w.useRef(o);let h;t[0]===Symbol.for("react.memo_cache_sentinel")?(h=Te=>{u(Te),Te?w.startTransition(()=>m(!0)):m(!1)},t[0]=h):h=t[0];const g=h;let x,v;t[1]!==o?(x=()=>{p.current!==o&&(p.current=o,g(o))},v=[o,g],t[1]=o,t[2]=x,t[3]=v):(x=t[2],v=t[3]),w.useEffect(x,v);let y,b;t[4]!==i?(y=()=>{i&&g(!0)},b=[i,g],t[4]=i,t[5]=y,t[6]=b):(y=t[5],b=t[6]),w.useEffect(y,b);let j;t[7]!==s.filePath?(j=B2(s.filePath),t[7]=s.filePath,t[8]=j):j=t[8];const S=j,k=s.netOriginal,C=s.netCurrent,N=!!(k||C);let E;t[9]!==s.edits?(E=s.edits.some(yE),t[9]=s.edits,t[10]=E):E=t[10];const P=a==="per-edit"?E:N,_=f&&c&&P,[A,I]=w.useState(0);let $;t[11]===Symbol.for("react.memo_cache_sentinel")?($=Te=>{if(!Te)return;const $e=Te.offsetHeight;I(_e=>_e===$e?_e:$e)},t[11]=$):$=t[11];const R=$,M=s.turnRange[0]===s.turnRange[1]?`T${s.turnRange[0]+1}`:`T${s.turnRange[0]+1}–T${s.turnRange[1]+1}`,O=s.filePath,D=i?"border-ring ring-2 ring-ring/20":"border-border";let z;t[12]!==D?(z=q("rounded-lg border bg-card transition-colors",D),t[12]=D,t[13]=z):z=t[13];let F;t[14]!==d?(F=()=>g(!d),t[14]=d,t[15]=F):F=t[15];let L;t[16]!==d?(L=d?r.jsx(mt,{"data-icon":"inline-start",className:"size-3 shrink-0 text-muted-foreground"}):r.jsx(Ye,{"data-icon":"inline-start",className:"size-3 shrink-0 text-muted-foreground"}),t[16]=d,t[17]=L):L=t[17];let H;t[18]!==S?(H=r.jsx("span",{className:"shrink-0 font-mono text-xs font-bold text-muted-foreground",children:S}),t[18]=S,t[19]=H):H=t[19];let U;t[20]!==s.opTypes?(U=s.opTypes.includes("Edit"),t[20]=s.opTypes,t[21]=U):U=t[21];let W;t[22]!==s.opTypes?(W=s.opTypes.includes("Write"),t[22]=s.opTypes,t[23]=W):W=t[23];let V;t[24]!==U||t[25]!==W?(V=r.jsx(U2,{hasEdit:U,hasWrite:W}),t[24]=U,t[25]=W,t[26]=V):V=t[26];let K;t[27]!==s.shortPath?(K=r.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",children:s.shortPath}),t[27]=s.shortPath,t[28]=K):K=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 X;t[31]!==s.editCount?(X=s.editCount>1&&r.jsxs(Pe,{variant:"outline",className:"h-5 shrink-0 px-1 font-mono text-xs text-muted-foreground",children:[s.editCount,"x"]}),t[31]=s.editCount,t[32]=X):X=t[32];let G;t[33]!==d||t[34]!==F||t[35]!==L||t[36]!==H||t[37]!==V||t[38]!==K||t[39]!==Y||t[40]!==X?(G=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:[L,H,V,K,Y,X]}),t[33]=d,t[34]=F,t[35]=L,t[36]=H,t[37]=V,t[38]=K,t[39]=Y,t[40]=X,t[41]=G):G=t[41];let J;t[42]!==s.subAgentId?(J=s.subAgentId&&r.jsx(qu,{agentId:s.subAgentId}),t[42]=s.subAgentId,t[43]=J):J=t[43];let Z;t[44]!==s.filePath?(Z=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>Er(s.filePath),"aria-label":"Open file in editor"}),t[44]=s.filePath,t[45]=Z):Z=t[45];let Q;t[46]===Symbol.for("react.memo_cache_sentinel")?(Q=r.jsx(Pd,{"data-icon":"inline-start"}),t[46]=Q):Q=t[46];let te;t[47]!==Z?(te=r.jsx(Ct,{render:Z,children:Q}),t[47]=Z,t[48]=te):te=t[48];let ne;t[49]===Symbol.for("react.memo_cache_sentinel")?(ne=r.jsx(_t,{children:"Open in editor"}),t[49]=ne):ne=t[49];let oe;t[50]!==te?(oe=r.jsxs(kt,{children:[te,ne]}),t[50]=te,t[51]=oe):oe=t[51];let re;t[52]!==s.filePath?(re=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>Er(s.filePath,{mode:"diff"}),"aria-label":"View git diff"}),t[52]=s.filePath,t[53]=re):re=t[53];let ie;t[54]===Symbol.for("react.memo_cache_sentinel")?(ie=r.jsx(sw,{"data-icon":"inline-start"}),t[54]=ie):ie=t[54];let se;t[55]!==re?(se=r.jsx(Ct,{render:re,children:ie}),t[55]=re,t[56]=se):se=t[56];let ce;t[57]===Symbol.for("react.memo_cache_sentinel")?(ce=r.jsx(_t,{children:"View git diff"}),t[57]=ce):ce=t[57];let ae;t[58]!==se?(ae=r.jsxs(kt,{children:[se,ce]}),t[58]=se,t[59]=ae):ae=t[59];let ue;t[60]!==oe||t[61]!==ae?(ue=r.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[oe,ae]}),t[60]=oe,t[61]=ae,t[62]=ue):ue=t[62];let me,de;t[63]!==s.addCount||t[64]!==s.delCount?(me=r.jsx(Eo,{add:s.addCount,del:s.delCount}),de=r.jsx(Hu,{add:s.addCount,del:s.delCount}),t[63]=s.addCount,t[64]=s.delCount,t[65]=me,t[66]=de):(me=t[65],de=t[66]);let le;t[67]!==J||t[68]!==ue||t[69]!==me||t[70]!==de?(le=r.jsxs("div",{className:"flex items-center gap-1.5 pr-2 shrink-0",children:[J,ue,me,de]}),t[67]=J,t[68]=ue,t[69]=me,t[70]=de,t[71]=le):le=t[71];let xe;t[72]!==G||t[73]!==le?(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:[G,le]}),t[72]=G,t[73]=le,t[74]=xe):xe=t[74];let pe;t[75]!==a||t[76]!==s.edits||t[77]!==s.filePath||t[78]!==s.netStartLine||t[79]!==P||t[80]!==A||t[81]!==C||t[82]!==k||t[83]!==d||t[84]!==_?(pe=r.jsx(xE,{showDiff:_,open:d,hasDiff:P,diffRef:R,lastDiffHeight:A,oldString:k,newString:C,filePath:s.filePath,diffMode:a,edits:s.edits,netStartLine:s.netStartLine}),t[75]=a,t[76]=s.edits,t[77]=s.filePath,t[78]=s.netStartLine,t[79]=P,t[80]=A,t[81]=C,t[82]=k,t[83]=d,t[84]=_,t[85]=pe):pe=t[85];let ve;return t[86]!==s.filePath||t[87]!==l||t[88]!==z||t[89]!==xe||t[90]!==pe?(ve=r.jsxs("div",{ref:l,"data-file-path":O,className:z,children:[xe,pe]}),t[86]=s.filePath,t[87]=l,t[88]=z,t[89]=xe,t[90]=pe,t[91]=ve):ve=t[91],ve}),xE=w.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(vE,{edits:m,filePath:u}):r.jsx(Fu,{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}),uh=3,bE=5,vE=w.memo(function(e){const t=B.c(9),{edits:s,filePath:o}=e,i=s.length,a=s.filter(wE),l=a.length>uh,[c,d]=w.useState(l?uh:a.length);w.useEffect(()=>{if(c>=a.length)return;const x=requestAnimationFrame(()=>{d(v=>Math.min(v+bE,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,v)=>r.jsxs("div",{children:[i>1&&r.jsxs("div",{className:"flex items-center gap-2 bg-muted/30 px-2.5 py-1",children:[r.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:[x.toolName," ",v+1,"/",i]}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["T",x.turnIndex+1]}),x.agentId&&r.jsx(qu,{agentId:x.agentId})]}),r.jsx(Fu,{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 yE(n){return!!(n.oldString||n.newString)}function wE(n){return!!(n.oldString||n.newString)}const Jl=new Map;function jE(n){var y;const e=Tn("hostFiles"),{sessionSource:t}=ot(),s=t==null?void 0:t.dirName,o=It(s)==="codex",i=n.turns.length,a=((y=n.turns.at(-1))==null?void 0:y.toolCalls.length)??0,l=w.useMemo(()=>{let b=0;for(const j of n.turns){b+=j.toolCalls.length;for(const S of j.subAgentActivity)b+=S.toolCalls.length}return b},[i,a]),c=w.useMemo(()=>{const b=[];for(let j=0;j<n.turns.length;j++)for(const S of n.turns[j].subAgentActivity){const k=o&&(S.status==="completed"||S.status==="failed"||S.status==="interrupted");(S.isBackground||k)&&S.toolCalls.length===0&&b.push({agentId:S.agentId,turnIndex:j})}return b},[n.turns,l,o]),[d,u]=w.useState(new Map),f=w.useRef(new Set);w.useEffect(()=>{if(!s||!n.sessionId||c.length===0)return;const b=[];for(const{agentId:k}of c){const C=Jt(`${s}/${n.sessionId}/${k}`);if(!f.current.has(C)){if(Jl.has(C)){u(N=>{const E=new Map(N);return E.set(k,Jl.get(C)),E}),f.current.add(C);continue}b.push({agentId:k,cacheKey:C})}}if(b.length===0)return;let j=!1;async function S(){const k=new Map;await Promise.all(b.map(async({agentId:C,cacheKey:N})=>{try{const E=`/api/sessions/${encodeURIComponent(s)}/${encodeURIComponent(n.sessionId)}/subagents/agent-${encodeURIComponent(C)}.jsonl`,T=await Ne(E);if(!T.ok)return;const P=await T.text(),A=v2(P,C).flatMap(I=>xr(I.toolCalls,n.cwd));Jl.set(N,A),f.current.add(N),k.set(C,A)}catch{}})),!j&&k.size>0&&u(C=>{const N=new Map(C);for(const[E,T]of k)N.set(E,T);return N})}return S(),()=>{j=!0}},[s,n.sessionId,n.cwd,c]);const m=w.useMemo(()=>{const b=[],j=new Set;for(let S=0;S<n.turns.length;S++){const k=n.turns[S];for(const C of xr(k.toolCalls,n.cwd))b.push({turnIndex:S,toolCall:C});for(const C of k.subAgentActivity){for(const N of xr(C.toolCalls,n.cwd))b.push({turnIndex:S,toolCall:N,agentId:C.agentId});if((C.isBackground||o)&&C.toolCalls.length===0&&!j.has(C.agentId)){j.add(C.agentId);const N=d.get(C.agentId);if(N)for(const E of N)b.push({turnIndex:S,toolCall:E,agentId:C.agentId})}}}return b},[l,n.turns,d,o]),p=w.useMemo(()=>{const b=new Set;for(const j of m){const S=H2(j.toolCall);S&&b.add(S)}return[...b]},[m]),[h,g]=w.useState(new Map);w.useEffect(()=>{if(!e||p.length===0){g(new Map);return}let b=!1;return Promise.all(p.map(j=>Ne(`/api/file-content?path=${encodeURIComponent(j)}`).then(S=>S.ok?S.text():null).then(S=>S?[j,S]:null).catch(()=>null))).then(j=>{if(b)return;const S=new Map;for(const k of j)k&&S.set(k[0],k[1]);g(S)}),()=>{b=!0}},[e,p]);const x=n.turns.length-1,v=w.useMemo(()=>{const b=new Map;for(const j of n.turns)for(const S of j.subAgentActivity)b.has(S.agentId)||b.set(S.agentId,{name:S.agentName,type:S.subagentType});return b},[n.turns]);return{fileChanges:m,fileContents:h,lastTurnIndex:x,agentMap:v}}function fh(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]===`
114
+ `&&s++;return s}function H2(n){return String(n.input.file_path??n.input.path??"")}function SE(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 q2(n,e,t){const s=new Map;for(const i of n){if(e!=="all"&&i.turnIndex!==e)continue;const a=H2(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 v=0;v<a.length;v++){const y=a[v],b=SE(y.toolCall);l.push(b),y.turnIndex<d&&(d=y.turnIndex),y.turnIndex>u&&(u=y.turnIndex),y.toolCall.name==="Edit"?f=!0:m=!0,y.agentId&&(p=y.agentId),c.push({id:y.toolCall.id,oldString:b.oldString,newString:b.newString,toolName:y.toolCall.name,turnIndex:y.turnIndex,agentId:y.agentId,startLine:y.toolCall.name==="Write"?1:fh(h,b.newString||b.oldString)})}const g=eE(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?fh(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 NE(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=q2(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 Or="cogpit:focus-file",kE="cogpit:file-changes-prefs",CE={expanded:!0,diffMode:"net",scope:"last",groupByAgent:!1};function _E(n){const e=B.c(34),{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(ya,{detail:{agentId:t.agentId}}))},e[3]=t.agentId,e[4]=u):u=e[4];let f;e[5]!==l||e[6]!==d||e[7]!==u?(f=r.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"h-auto min-w-0 truncate px-1 text-xs font-semibold",title:d,onClick:u,children:l}),e[5]=l,e[6]=d,e[7]=u,e[8]=f):f=e[8];let m;e[9]!==c?(m=c&&r.jsx("span",{className:"truncate text-xs text-muted-foreground",children:c}),e[9]=c,e[10]=m):m=e[10];let p;e[11]!==t.files.length?(p=r.jsx(Pe,{variant:"outline",className:"h-5 px-1.5 text-xs text-muted-foreground",children:t.files.length}),e[11]=t.files.length,e[12]=p):p=e[12];let h;e[13]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx("div",{className:"flex-1"}),e[13]=h):h=e[13];let g;e[14]!==t.totalAdd||e[15]!==t.totalDel?(g=r.jsx(Eo,{add:t.totalAdd,del:t.totalDel}),e[14]=t.totalAdd,e[15]=t.totalDel,e[16]=g):g=e[16];let x;e[17]!==f||e[18]!==m||e[19]!==p||e[20]!==g?(x=r.jsxs("div",{className:"flex items-center gap-2 px-1.5 pt-1.5 pb-0.5",children:[f,m,p,h,g]}),e[17]=f,e[18]=m,e[19]=p,e[20]=g,e[21]=x):x=e[21];let v;if(e[22]!==s||e[23]!==i||e[24]!==t.files||e[25]!==o){let b;e[27]!==s||e[28]!==i||e[29]!==o?(b=j=>r.jsx(W2,{file:j,defaultOpen:s,isHighlighted:o===j.filePath,diffMode:i},j.filePath),e[27]=s,e[28]=i,e[29]=o,e[30]=b):b=e[30],v=t.files.map(b),e[22]=s,e[23]=i,e[24]=t.files,e[25]=o,e[26]=v}else v=e[26];let y;return e[31]!==v||e[32]!==x?(y=r.jsxs("div",{className:"flex flex-col gap-1",children:[x,v]}),e[31]=v,e[32]=x,e[33]=y):y=e[33],y}const TE=w.memo(function({session:e,sessionChangeKey:t}){const s=w.useRef(null),o=w.useRef(null),i=w.useRef(!0),a=w.useRef(!1),l=w.useRef(0),c=w.useRef(e.turns.length),[d,u]=w.useState(!1),[f,m]=w.useState(!1),[p,h]=Wo(kE,{}),g={...CE,...p},x=g.expanded,v=g.diffMode,y=g.groupByAgent,[b,j]=w.useState(g.scope),S=w.useCallback(W=>{h(V=>({...V,expanded:W}))},[h]),k=w.useCallback(W=>{h(V=>({...V,diffMode:W}))},[h]),C=w.useCallback(W=>{h(V=>({...V,groupByAgent:W}))},[h]);w.useEffect(()=>{typeof b!="number"&&h(W=>({...W,scope:b}))},[b,h]);const[N,E]=w.useState(null),T=w.useRef(null),{fileChanges:P,fileContents:_,lastTurnIndex:A,agentMap:I}=jE(e),$=w.useMemo(()=>q2(P,typeof b=="number"?b:b==="all"?"all":A,_),[P,b,A,_]),R=w.useMemo(()=>y?NE(P,typeof b=="number"?b:b==="all"?"all":A,I,_):[],[y,P,b,A,I,_]);w.useEffect(()=>{const W=V=>{const K=V.detail;K!=null&&K.filePath&&(j(K.turnIndex),E(K.filePath),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>E(null),3e3),requestAnimationFrame(()=>{var X;const Y=(X=s.current)==null?void 0:X.querySelector(`[data-file-path="${CSS.escape(K.filePath)}"]`);Y==null||Y.scrollIntoView({behavior:"smooth",block:"nearest"})}))};return window.addEventListener(Or,W),()=>{window.removeEventListener(Or,W),T.current&&clearTimeout(T.current)}},[]);const M=w.useCallback(()=>{const W=s.current;W&&(u(W.scrollTop>10),m(W.scrollHeight-W.scrollTop-W.clientHeight>10))},[]),O=w.useCallback(()=>{const W=s.current;W&&(i.current=W.scrollHeight-W.scrollTop-W.clientHeight<50,M())},[M]);if(w.useEffect(()=>{M()},[P.length,$.length,M]),w.useEffect(()=>{const W=s.current;W&&(W.scrollTop=W.scrollHeight),i.current=!0,a.current=!1,l.current=P.length,c.current=e.turns.length,j(g.scope),E(null),M()},[t]),w.useEffect(()=>{const W=e.turns.length;W>c.current&&(a.current=!0),c.current=W},[e.turns.length]),w.useEffect(()=>{if(P.length<=l.current){l.current=P.length;return}l.current=P.length,(a.current||i.current)&&(requestAnimationFrame(()=>{var W;(W=o.current)==null||W.scrollIntoView({behavior:"smooth"})}),a.current=!1)},[P.length]),P.length===0)return null;let D=0,z=0,F=0;if(y)for(const W of R)D+=W.totalAdd,z+=W.totalDel,F+=W.files.length;else{for(const W of $)D+=W.addCount,z+=W.delCount;F=$.length}function L(){j(b==="last"?"all":"last")}function H(){return typeof b=="number"?`Turn ${b+1}`:b==="all"?"All turns":`Last turn (T${A+1})`}const U=H();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(Wr,{"data-icon":"inline-start",className:"size-3.5 text-muted-foreground"}),r.jsx("span",{className:"text-xs font-medium text-foreground",children:"File Changes"}),r.jsxs(Pe,{variant:"outline",className:"h-5 px-1.5 text-xs text-muted-foreground",children:[F," file",F!==1?"s":""]}),r.jsx("div",{className:"flex-1"}),r.jsx(Eo,{add:D,del:z}),r.jsxs(kt,{children:[r.jsx(Ct,{render:r.jsx(ee,{variant:y?"secondary":"ghost",size:"icon-xs",onClick:()=>C(!y),"aria-label":y?"Show all changes":"Group by subagent"}),children:r.jsx(An,{"data-icon":"inline-start"})}),r.jsx(_t,{children:y?"Show all changes":"Group by subagent"})]}),r.jsxs(kt,{children:[r.jsx(Ct,{render:r.jsx(ee,{variant:b==="all"?"secondary":"ghost",size:"icon-xs",onClick:L,"aria-label":b==="last"?"Show all turns":"Show last turn only"}),children:b==="all"?r.jsx(oa,{"data-icon":"inline-start"}):r.jsx(Us,{"data-icon":"inline-start"})}),r.jsx(_t,{children:b==="last"?"Click for all turns":"Click for last turn only"})]}),r.jsxs(kt,{children:[r.jsx(Ct,{render:r.jsx(ee,{variant:v==="per-edit"?"secondary":"ghost",size:"icon-xs",onClick:()=>k(v==="net"?"per-edit":"net"),"aria-label":v==="net"?"Show per-edit diffs":"Show net diff"}),children:v==="net"?r.jsx(ow,{"data-icon":"inline-start"}):r.jsx(rw,{"data-icon":"inline-start"})}),r.jsx(_t,{children:v==="net"?"Switch to per-edit diffs":"Switch to net diff"})]}),r.jsxs(kt,{children:[r.jsx(Ct,{render:r.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:()=>S(!x),"aria-label":x?"Collapse all":"Expand all"}),children:x?r.jsx(Ia,{"data-icon":"inline-start"}):r.jsx(Ur,{"data-icon":"inline-start"})}),r.jsx(_t,{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:"}),b!=="all"&&A>0&&r.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:()=>{const W=typeof b=="number"?b:A;W>0&&j(W-1)},disabled:(typeof b=="number"?b:A)<=0,"aria-label":"Previous turn",children:r.jsx(_d,{"data-icon":"inline-start"})}),r.jsx("span",{className:q("text-xs font-medium",typeof b=="number"?"text-foreground":"text-muted-foreground"),children:U}),b!=="all"&&A>0&&r.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:()=>{j(W=>typeof W!="number"?W:W+1>=A?"last":W+1)},disabled:b==="last","aria-label":"Next turn",children:r.jsx(Ye,{"data-icon":"inline-start"})}),typeof b=="number"&&r.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:()=>j("last"),"aria-label":"Back to last turn",children:r.jsx(tt,{"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:O,className:"h-full overflow-y-auto",children:[r.jsx("div",{className:"flex flex-col gap-1 p-1.5",children:y?R.length>0?R.map(W=>r.jsx(_E,{group:W,allExpanded:x,highlightPath:N,diffMode:v},W.agentId)):r.jsxs("div",{className:"py-4 text-center text-xs text-muted-foreground",children:["No subagent changes in ",U.toLowerCase()]}):$.length>0?$.map(W=>r.jsx(W2,{file:W,defaultOpen:x,isHighlighted:N===W.filePath,diffMode:v},W.filePath)):r.jsxs("div",{className:"py-4 text-center text-xs text-muted-foreground",children:["No file changes in ",U.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 EE(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=td(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 xr(n.toolCalls,e).forEach(o=>s(o)),n.subAgentActivity.forEach(o=>xr(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 mh(){return{children:new Map,isFile:!1,absPath:"",additions:0,deletions:0,hasEdit:!1,hasWrite:!1,subAgentId:null}}function AE(n,e){if(n.length===0)return[];const t=e.endsWith("/")?e.slice(0,-1):e,s=mh();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=mh(),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[j,S]=[...f.children.entries()][0];if(S.isFile&&S.children.size===0)break;m+="/"+j,p+="/"+j,f=S}const h=o(f,p);let g=0,x=0,v=f.isFile?f.hasEdit:!1,y=f.isFile?f.hasWrite:!1,b=f.isFile?f.subAgentId:null;for(const j of h)g+=j.additions,x+=j.deletions,j.hasEdit&&(v=!0),j.hasWrite&&(y=!0),j.subAgentId&&(b=j.subAgentId);return f.isFile&&(g+=f.additions,x+=f.deletions),{name:m,fullPath:p,absPath:f.absPath,isFile:!1,additions:g,deletions:x,hasEdit:v,hasWrite:y,subAgentId:b,children:h}})}return o(s,"")}const PE=w.memo(function(e){const t=B.c(45),{turn:s,turnIndex:o,cwd:i}=e,a=Tn("hostFiles");let l;t[0]!==i||t[1]!==s?(l=EE(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=AE(c,i),t[3]=i,t[4]=c,t[5]=d):d=t[5];const u=d,[f,m]=w.useState(!1);let p=0,h=0;if(t[6]!==p||t[7]!==h||t[8]!==c){for(const I of c)p=p+I.additions,h=h+I.deletions;t[6]=p,t[7]=h,t[8]=c,t[9]=p,t[10]=h}else p=t[9],h=t[10];let g;t[11]!==p||t[12]!==h?(g={add:p,del:h},t[11]=p,t[12]=h,t[13]=g):g=t[13];const x=g;if(c.length===0)return null;const v=f&&"rotate-90";let y;t[14]!==v?(y=q("size-3 shrink-0 transition-transform duration-150 motion-reduce:transition-none",v),t[14]=v,t[15]=y):y=t[15];let b;t[16]!==y?(b=r.jsx(Ye,{"data-icon":"inline-start",className:y}),t[16]=y,t[17]=b):b=t[17];let j;t[18]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(Wr,{className:"size-3.5 shrink-0","data-icon":"inline-start"}),t[18]=j):j=t[18];const S=c.length!==1?"s":"";let k;t[19]!==c.length||t[20]!==S?(k=r.jsxs("span",{className:"font-medium tabular-nums",children:[c.length," file",S]}),t[19]=c.length,t[20]=S,t[21]=k):k=t[21];let C,N;t[22]!==x.add||t[23]!==x.del?(C=r.jsx(Eo,{add:x.add,del:x.del,className:"opacity-80"}),N=r.jsx(Hu,{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 E;t[26]===Symbol.for("react.memo_cache_sentinel")?(E=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]=E):E=t[26];let T;t[27]!==C||t[28]!==N||t[29]!==b||t[30]!==k?(T=r.jsxs(Rt,{className:"group/files flex min-h-7 w-full cursor-pointer items-center gap-1.5 rounded-md px-1 text-left text-xs text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[b,j,k,C,N,E]}),t[27]=C,t[28]=N,t[29]=b,t[30]=k,t[31]=T):T=t[31];let P;if(t[32]!==a||t[33]!==u||t[34]!==o){let I;t[36]!==a||t[37]!==o?(I=$=>r.jsx(IE,{node:$,depth:0,turnIndex:o,canFocusFiles:a},$.fullPath),t[36]=a,t[37]=o,t[38]=I):I=t[38],P=u.map(I),t[32]=a,t[33]=u,t[34]=o,t[35]=P}else P=t[35];let _;t[39]!==P?(_=r.jsx(dt,{className:"ml-1 border-l border-border/40 pl-3",children:r.jsx("div",{className:"py-0.5",children:P})}),t[39]=P,t[40]=_):_=t[40];let A;return t[41]!==f||t[42]!==T||t[43]!==_?(A=r.jsxs(ct,{open:f,onOpenChange:m,children:[T,_]}),t[41]=f,t[42]=T,t[43]=_,t[44]=A):A=t[44],A}),IE=w.memo(function n({node:e,depth:t,turnIndex:s,canFocusFiles:o}){const[i,a]=w.useState(!0),l=t*16+8;if(e.isFile){const c=pE(e.name),d=()=>{o&&e.absPath&&window.dispatchEvent(new CustomEvent(Or,{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(U2,{hasEdit:e.hasEdit,hasWrite:e.hasWrite}),r.jsx("span",{className:"truncate text-foreground/75",children:e.name})]}),e.subAgentId&&r.jsx(qu,{agentId:e.subAgentId}),r.jsx(Eo,{add:e.additions,del:e.deletions}),r.jsx(Hu,{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(mt,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}):r.jsx(Ye,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}),r.jsx(Nr,{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(Eo,{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 RE(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(Id,{"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(Ct,{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(_t,{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(kt,{children:[l,d]}),e[11]=l,e[12]=d,e[13]=u):u=e[13],u}function il(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(aw,{"data-slot":"context-menu",...t}),e[2]=t,e[3]=s):s=e[3],s}function al(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=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(iw,{"data-slot":"context-menu-trigger",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function ll(n){const e=B.c(18);let t,s,o,i,a,l;e[0]!==n?({className:t,align:o,alignOffset:i,side:a,sideOffset:l,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a,e[6]=l):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5],l=e[6]);const c=o===void 0?"start":o,d=i===void 0?4:i,u=a===void 0?"right":a,f=l===void 0?0:l;let m;e[7]!==t?(m=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(D1,{"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(B1,{children:r.jsx(U1,{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 Bs(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(z1,{"data-slot":"context-menu-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function mB(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(W1,{"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 Wt(n){const e=B.c(12);let t,s,o,i;e[0]!==n?({className:t,inset:s,variant:i,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);const a=i===void 0?"default":i;let l;e[5]!==t?(l=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(F1,{"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 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("-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(vd,{"data-slot":"context-menu-separator",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function $E(n){const e=B.c(22),{children:t,turnIndex:s,branches:o,onRestoreToHere:i,onOpenBranches:a,onBranchFromHere:l}=n;let c;e[0]!==t?(c=r.jsx(al,{className:"select-text",children:t}),e[0]=t,e[1]=c):c=e[1];let d;e[2]!==i||e[3]!==s?(d=()=>i(s),e[2]=i,e[3]=s,e[4]=d):d=e[4];let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Td,{"data-icon":"inline-start"}),e[5]=u):u=e[5];let f;e[6]!==d?(f=r.jsx(Bs,{children:r.jsxs(Wt,{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(Ao,{}),r.jsx(Bs,{children:r.jsxs(Wt,{onClick:()=>a(s),children:[r.jsx(Id,{"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(Ao,{}),r.jsx(Bs,{children:r.jsxs(Wt,{onClick:()=>l(s),children:[r.jsx(pn,{"data-icon":"inline-start"}),"Duplicate from here"]})})]}),e[12]=l,e[13]=s,e[14]=p):p=e[14];let h;e[15]!==f||e[16]!==m||e[17]!==p?(h=r.jsxs(ll,{className:"min-w-44",children:[f,m,p]}),e[15]=f,e[16]=m,e[17]=p,e[18]=h):h=e[18];let g;return e[19]!==c||e[20]!==h?(g=r.jsxs(il,{children:[c,h]}),e[19]=c,e[20]=h,e[21]=g):g=e[21],g}function K2(n){return A0(n).status(n)}const ME=new Set(["Agent","TaskOutput","spawn_agent","wait_agent"]);function Ku(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 li(n,e,t,s){switch(n){case"thinking":return"Thinking...";case"tool_use":return e&&ME.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?Ku(t):"Done";default:return null}}function LE(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(cw,{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(Vs,{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(lw,{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(Ia,{className:"size-5 text-warning"}),e[3]=s):s=e[3],s}case"awaiting_agents":{let s;return e[4]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(No,{className:"size-5 text-info"}),e[4]=s):s=e[4],s}case"completed":{let s;return e[5]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Hn,{className:"size-5 text-success"}),e[5]=s):s=e[5],s}default:return null}}const ph=2e3,V2=600;function G2(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:`${V2}ms`},e[4]=m):m=e[4];let p;e[5]!==t.status?(p=r.jsx(LE,{status:t.status}),e[5]=t.status,e[6]=p):p=e[6];const h=!l&&"text-muted-foreground",g=l&&t.terminalReason&&"text-warning",x=l&&!t.terminalReason&&"text-success";let v;e[7]!==h||e[8]!==g||e[9]!==x?(v=q("text-xs font-medium shrink-0",h,g,x),e[7]=h,e[8]=g,e[9]=x,e[10]=v):v=e[10];let y;e[11]!==s||e[12]!==v?(y=r.jsx("span",{className:v,children:s}),e[11]=s,e[12]=v,e[13]=y):y=e[13];let b;e[14]!==l||e[15]!==i?(b=!l&&i&&r.jsx(Vu,{startTimestamp:i}),e[14]=l,e[15]=i,e[16]=b):b=e[16];let j;e[17]!==d?(j=d.length>0&&r.jsx("span",{className:"truncate text-xs text-muted-foreground",title:d.join(`
115
+ `),children:d.join(" · ")}),e[17]=d,e[18]=j):j=e[18];let S;e[19]!==t.pendingQueue?(S=(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]=S):S=e[20];let k;return e[21]!==y||e[22]!==b||e[23]!==j||e[24]!==S||e[25]!==f||e[26]!==p?(k=r.jsxs("div",{className:f,style:m,children:[p,y,b,j,S]}),e[21]=y,e[22]=b,e[23]=j,e[24]=S,e[25]=f,e[26]=p,e[27]=k):k=e[27],k}function OE(n){const e=B.c(28),{status:t,durationLabel:s}=n,[o,i]=w.useState("visible");let a,l;if(e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const h=setTimeout(()=>i("fading"),ph),g=setTimeout(()=>i("ready"),ph+V2);return()=>{clearTimeout(h),clearTimeout(g)}},l=[],e[0]=a,e[1]=l):(a=e[0],l=e[1]),w.useEffect(a,l),o==="ready"){let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(Hn,{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 v;e[5]!==t.terminalReason?(v=t.terminalReason?Ku(t.terminalReason):"Waiting for your input",e[5]=t.terminalReason,e[6]=v):v=e[6];let y;e[7]!==x||e[8]!==v?(y=r.jsx("span",{className:x,children:v}),e[7]=x,e[8]=v,e[9]=y):y=e[9];let b;e[10]!==s?(b=s&&r.jsx("span",{className:"font-mono text-xs tabular-nums text-muted-foreground",children:s}),e[10]=s,e[11]=b):b=e[11];let j;return e[12]!==y||e[13]!==b?(j=r.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4","data-agent-ready":!0,children:[h,y,b]}),e[12]=y,e[13]=b,e[14]=j):j=e[14],j}let c;e[15]!==t.status||e[16]!==t.terminalReason||e[17]!==t.toolName?(c=li(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(G2,{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 DE=w.memo(function(){const e=B.c(25),{session:t,isLive:s,sseState:o,isCompacting:i,pendingInteraction:a}=ot(),[l,c]=w.useState(!1),[d,u]=w.useState(!1),f=t==null?void 0:t.sessionId,[m,p]=w.useState(f);f!==m&&(p(f),c(!1),u(!1));let h;e:{if(!t||o!=="connected"){h=null;break e}if(i){let I;e[0]===Symbol.for("react.memo_cache_sentinel")?(I={status:"compacting"},e[0]=I):I=e[0],h=I;break e}const _=t.rawMessages;let A;e[1]!==_?(A=K2(_),e[1]=_,e[2]=A):A=e[2],h=A}const g=h;let x,v;e[3]!==g||e[4]!==s||e[5]!==d?(x=()=>{if(!(!g||g.status==="compacting"||g.status==="idle")){if(!s){g.status==="completed"&&!d&&c(!0);return}if(g.status==="completed"){u(!0);return}c(!1),u(!1)}},v=[g,s,d],e[3]=g,e[4]=s,e[5]=d,e[6]=x,e[7]=v):(x=e[6],v=e[7]),w.useEffect(x,v);let y;e:{if(!g){y=null;break e}if(g.status==="compacting"){y=g;break e}if(g.status==="completed"){if(l){y=null;break e}if(!s&&!d){y=null;break e}y=g;break e}if(!s||g.status==="idle"){y=null;break e}y=g}const b=y,j=(b==null?void 0:b.status)==="completed",S=(t==null?void 0:t.turns[t.turns.length-1])??null;let k;e:{if(!j||!S){k=null;break e}let _;if(e[8]!==S){const A=Kd(S);_=A!==null?Un(A):null,e[8]=S,e[9]=_}else _=e[9];k=_}const C=k;if(a&&o==="connected"){let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(Ad,{className:"size-5 shrink-0 text-info"}),e[10]=_):_=e[10];const A=a.type==="plan"?"Waiting for plan approval":"Waiting for your answer";let I;return e[11]!==A?(I=r.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4",children:[_,r.jsx("span",{className:"text-xs font-medium text-info",children:A})]}),e[11]=A,e[12]=I):I=e[12],I}if(!b)return null;if(j){let _;return e[13]!==b||e[14]!==C?(_=r.jsx(OE,{status:b,durationLabel:C}),e[13]=b,e[14]=C,e[15]=_):_=e[15],_}let N;e[16]!==b.pendingAgents||e[17]!==b.status||e[18]!==b.terminalReason||e[19]!==b.toolName?(N=li(b.status,b.toolName,b.terminalReason,b.pendingAgents),e[16]=b.pendingAgents,e[17]=b.status,e[18]=b.terminalReason,e[19]=b.toolName,e[20]=N):N=e[20];const E=N;if(!E)return null;const T=S==null?void 0:S.timestamp;let P;return e[21]!==b||e[22]!==E||e[23]!==T?(P=r.jsx("div",{className:"flex items-center gap-2.5 py-3 px-4",children:r.jsx(G2,{status:b,label:E,startTimestamp:T})}),e[21]=b,e[22]=E,e[23]=T,e[24]=P):P=e[24],P});function Vu(n){const e=B.c(3),{startTimestamp:t,className:s}=n;let o;return e[0]!==s||e[1]!==t?(o=r.jsx(zE,{startTimestamp:t,className:s},t),e[0]=s,e[1]=t,e[2]=o):o=e[2],o}function zE(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=w.useRef(null);let l,c;e[2]!==i?(l=()=>{const h=setInterval(()=>{const g=a.current;g&&(g.textContent=Un(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]),w.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=Un(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 FE(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 BE=6e5;function UE(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,BE)}function hh(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+=UE(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 Y2=w.createContext(null);function ea(n){const e=B.c(3),{value:t,children:s}=n;let o;return e[0]!==s||e[1]!==t?(o=r.jsx(Y2.Provider,{value:t,children:s}),e[0]=s,e[1]=t,e[2]=o):o=e[2],o}function qt(){const n=w.useContext(Y2);if(!n)throw new Error("useAppContext must be used within an AppProvider");return n}const nd=new Map,WE=300*1e3;function gh(n){const e=nd.get(n);return e?Date.now()>e.expiresAt?(nd.delete(n),null):e.data:null}function HE(n,e){nd.set(n,{data:e,expiresAt:Date.now()+WE})}function qE(n){const e=B.c(5);let t;e[0]!==n?(t=()=>n?gh(Jt(n))??new Map:new Map,e[0]=n,e[1]=t):t=e[1];const[s,o]=w.useState(t),i=w.useRef("");let a,l;return e[2]!==n?(a=()=>{if(!n||Ha(window.location.pathname))return;const c=Jt(n),d=gh(c);if(d){o(d);return}i.current=n;const u=new AbortController;return Ne(`/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});HE(c,p),o(p)}).catch(KE),()=>u.abort()},l=[n],e[2]=n,e[3]=a,e[4]=l):(a=e[3],l=e[4]),w.useEffect(a,l),s}function KE(){}const VE=new Set(["queued_prompt","agent_message","plan_mode","recap","task_notification"]),GE=new Set(["thinking","tool_calls","sub_agent","background_agent","hook_event"]),YE=new Set(["AskUserQuestion","ExitPlanMode"]),XE=new Set(["text","thinking","tool_calls"]);function JE(n){return n.kind==="tool_calls"&&n.toolCalls.some(e=>YE.has(e.name)&&e.result==null)}function QE(n,e){for(let t=n.length-1;t>=0;t--){if(JE(n[t]))return t;if(XE.has(n[t].kind))break}return e?n.findIndex(t=>t.kind==="tool_calls"&&t.toolCalls.some(s=>s.id===e&&s.asyncQuestion)):-1}const Fi={foldedIndices:[],foldAnchorIndex:-1,foldable:!1,hiddenToolCalls:0};function ZE(n,e="settled",t){if(n.length===0||!n.some(l=>GE.has(l.kind)))return Fi;let s=-1;if(e==="settled"){for(let l=n.length-1;l>=0;l--)if(n[l].kind==="text"){s=l;break}if(s===-1)return Fi}const o=QE(n,t),i=[];let a=0;for(let l=0;l<n.length;l++){if(l===s||l===o)continue;const c=n[l];VE.has(c.kind)||(i.push(l),c.kind==="tool_calls"&&(a+=c.toolCalls.length))}return i.length===0?Fi:{foldedIndices:i,foldAnchorIndex:i[0],foldable:!0,hiddenToolCalls:a}}function eA(n,e){return n!==null&&n>0?`Worked for ${Un(n)}`:e>0?`Worked through ${e} step${e===1?"":"s"}`:"Show work"}const X2="border border-border bg-prompt-surface",xh="border-l border-border/40",bh="border-l border-border";function J2(n){const e=B.c(21),{turn:t,index:s,branchCount:o}=n,i=o===void 0?0:o,{state:a,isMobile:l}=qt(),{activeTurnIndex:c,activeToolCallId:d,expandAll:u,expandToolPayloads:f}=a,{session:m,isLive:p,isSubAgentView:h,undoRedo:g,actions:x,pendingInteraction:v}=ot(),y=p&&m!==null,b=y&&s===((m==null?void 0:m.turns.length)??0)-1;let j=!b;if(b&&m){let P;if(e[0]!==m.rawMessages){const{status:_}=K2(m.rawMessages);P=$u.has(_),e[0]=m.rawMessages,e[1]=P}else P=e[1];j=!P}const S=(m==null?void 0:m.cwd)??"",k=qE(S),C=(v==null?void 0:v.type)==="question"?v.toolUseId:void 0,N=c===s,E=!g.enabled||h?void 0:g.requestUndo;let T;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]!==b||e[12]!==l||e[13]!==y||e[14]!==j||e[15]!==C||e[16]!==k||e[17]!==N||e[18]!==E||e[19]!==t?(T=r.jsx(sA,{turn:t,openQuestionId:C,index:s,branchCount:i,isActive:N,activeToolCallId:d,expandAll:u,expandToolPayloads:f,isAgentActive:b,isSessionLive:y,isTurnDone:j,isMobile:l,cwd:S,skillMetadata:k,onRestoreToHere:E,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]=b,e[12]=l,e[13]=y,e[14]=j,e[15]=C,e[16]=k,e[17]=N,e[18]=E,e[19]=t,e[20]=T):T=e[20],T}function tA(n){const e=B.c(12),{index:t,children:s}=n,{session:o,isSubAgentView:i,undoRedo:a,actions:l}=ot(),{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($E,{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 nA(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=eA(Kd(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(Vu,{startTimestamp:t.timestamp,className:"text-xs text-inherit"})]}),e[3]=t.timestamp,e[4]=i):i=e[4],i}const sA=w.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:v,openQuestionId:y}){const{ref:b,isNear:j}=s2(),S=w.useRef(null),k=w.useRef(0);w.useLayoutEffect(()=>{j&&S.current&&(k.current=S.current.offsetHeight)},[j]);const C=va(e.toolCalls,m)||e.subAgentActivity.some(R=>va(R.toolCalls,m)),N=u?"settled":"working",E=w.useMemo(()=>ZE(e.contentBlocks,N,y),[N,y,e.contentBlocks]),[T,P]=w.useState(void 0),_=T??(a||!u),{leadingBlocks:A,trailingBlocks:I}=w.useMemo(()=>{if(!E.foldable)return{leadingBlocks:[],trailingBlocks:[]};const R=E.foldAnchorIndex,M=new Set(E.foldedIndices);return{leadingBlocks:e.contentBlocks.slice(0,R),trailingBlocks:e.contentBlocks.slice(R).filter((O,D)=>_||!M.has(R+D))}},[E,e.contentBlocks,_]),$={model:e.model,effort:e.effort,expandAll:a,expandToolPayloads:l,activeToolCallId:i,isAgentActive:c,isSessionLive:d,isMobile:f,skillMetadata:p};return r.jsxs("div",{ref:b,"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(rA,{index:t,turn:e,branchCount:s,isTurnDone:u,isMobile:f,onRestoreToHere:h,onOpenBranches:g}),j?r.jsxs("div",{ref:S,className:q("flex flex-col",f?"gap-2":"gap-3"),children:[e.userMessage&&r.jsx(tA,{index:t,children:r.jsx("div",{"data-turn-prompt":!0,className:q(f?"rounded-lg p-2.5":"rounded-lg p-3",X2),children:r.jsx(Eu,{content:e.userMessage,timestamp:e.timestamp,onEditCommand:x,onExpandCommand:v,compact:f})})}),E.foldable?r.jsxs(r.Fragment,{children:[A.length>0&&r.jsx(Ql,{blocks:A,...$}),r.jsx(Z9,{label:r.jsx(nA,{turn:e,isTurnDone:u,hiddenToolCalls:E.hiddenToolCalls}),expanded:_,onToggle:()=>P(!_),compact:f}),I.length>0&&r.jsx(Ql,{blocks:I,...$})]}):r.jsx(Ql,{blocks:e.contentBlocks,...$}),u&&C&&r.jsx(PE,{turn:e,turnIndex:t,cwd:m})]}):r.jsx("div",{style:{minHeight:k.current||oA(e)}})]})});function oA(n){return Math.max(60,(n.userMessage?40:0)+n.contentBlocks.length*60)}function rA(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?Kd(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(iA,{durationMs:f,showLiveTimer:d,timestamp:s.timestamp}),e[7]=f,e[8]=d,e[9]=s.timestamp,e[10]=x):x=e[10];let v;e[11]!==t||e[12]!==a||e[13]!==l?(v=l&&r.jsxs(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(Td,{"data-icon":"inline-start"}),r.jsx("span",{className:"hidden sm:inline",children:"Restore"})]}),e[11]=t,e[12]=a,e[13]=l,e[14]=v):v=e[14];let y;e[15]!==o||e[16]!==t||e[17]!==c||e[18]!==l?(y=o>0&&c&&r.jsx("div",{className:q(!l&&"ml-auto"),children:r.jsx(RE,{branchCount:o,onClick:()=>c(t)})}),e[15]=o,e[16]=t,e[17]=c,e[18]=l,e[19]=y):y=e[19];let b;return e[20]!==p||e[21]!==g||e[22]!==x||e[23]!==v||e[24]!==y?(b=r.jsxs("div",{className:p,children:[g,x,v,y]}),e[20]=p,e[21]=g,e[22]=x,e[23]=v,e[24]=y,e[25]=b):b=e[25],b}function iA(n){const e=B.c(8),{durationMs:t,showLiveTimer:s,timestamp:o}=n;if(t!==null){let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Us,{className:"size-3","data-icon":"inline-start"}),e[0]=i):i=e[0];let a;e[1]!==t?(a=Un(t),e[1]=t,e[2]=a):a=e[2];let l;return e[3]!==a?(l=r.jsxs("span",{className:"flex items-center gap-1 font-mono text-xs tabular-nums text-muted-foreground",children:[i,a]}),e[3]=a,e[4]=l):l=e[4],l}if(s){let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Us,{className:"size-3","data-icon":"inline-start"}),e[5]=i):i=e[5];let a;return e[6]!==o?(a=r.jsxs("span",{className:"flex items-center gap-1 font-mono text-xs tabular-nums text-info",children:[i,r.jsx(Vu,{startTimestamp:o,className:"tabular-nums"})]}),e[6]=o,e[7]=a):a=e[7],a}return null}function aA(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 Ql(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,v=(b,j)=>{const S=aA(b)??`at-${j}`,k=x.get(S)??0;return x.set(S,k+1),k===0?S:`${S}#${k}`};let y=0;for(;y<t.length;){const b=t[y];if(b.kind==="thinking"||b.kind==="tool_calls"){const{items:j,toolCalls:S,thinkingCount:k,thoughtForMs:C,nextIndex:N}=hh(t,y),E=j.length===1&&j[0].kind==="tool_calls";p.push(r.jsx("div",{className:q(xh,h),children:r.jsx(ih,{toolCalls:S,expandAll:i,expandToolPayloads:a,activeToolCallId:l,isAgentActive:c,activityItems:E?void 0:j,thinkingCount:k,thoughtForMs:C,skillMetadata:f})},v(b,y))),y=N;continue}if(b.kind==="text"){const{items:j,toolCalls:S,thinkingCount:k,thoughtForMs:C,nextIndex:N}=hh(t,y+1);p.push(r.jsxs("div",{children:[r.jsx("div",{className:q("flex flex-col",g),children:b.text.map((E,T)=>r.jsx(S8,{text:E,model:s,effort:o,timestamp:b.timestamp,compact:u},T))}),(S.length>0||k>0)&&r.jsx("div",{className:q("mt-1.5",xh,h),children:r.jsx(ih,{toolCalls:S,expandAll:i,expandToolPayloads:a,activeToolCallId:l,isAgentActive:c,activityItems:k>0?j:void 0,thinkingCount:k,thoughtForMs:C,skillMetadata:f})})]},v(b,y))),y=N;continue}if(b.kind==="queued_prompt"){p.push(r.jsxs("div",{className:q(u?"rounded-lg p-2.5":"rounded-lg p-3",X2),children:[r.jsx(Pe,{variant:"outline",className:"mb-2",children:"Queued while working"}),r.jsx(Eu,{content:b.content,timestamp:b.timestamp??"",compact:u})]},v(b,y))),y++;continue}if(b.kind==="agent_message"){p.push(r.jsx(w8,{sender:b.sender,body:b.body,reply:b.reply,timestamp:b.timestamp,isLive:d},v(b,y))),y++;continue}if(b.kind==="sub_agent"){p.push(r.jsx("div",{className:q(bh,h),children:r.jsx(Kp,{messages:b.messages,expandAll:i,label:"Sub-agent activity",countLabel:"subagents active"})},v(b,y))),y++;continue}if(b.kind==="background_agent"){p.push(r.jsx("div",{className:q(bh,h),children:r.jsx(Kp,{messages:b.messages,expandAll:i,label:"Background agent activity",countLabel:"agents active"})},v(b,y))),y++;continue}if(b.kind==="hook_event"){p.push(r.jsx(W8,{events:b.events},v(b,y))),y++;continue}if(b.kind==="plan_mode"){p.push(r.jsx(V9,{plan:b.plan,planFilePath:b.planFilePath,status:b.status,toolCalls:b.toolCalls,expandAll:i,expandToolPayloads:a,isAgentActive:c,skillMetadata:f},v(b,y))),y++;continue}if(b.kind==="recap"){p.push(r.jsx(G9,{content:b.content},v(b,y))),y++;continue}if(b.kind==="task_notification"){p.push(r.jsx(p7,{content:b.content},v(b,y))),y++;continue}y++}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 lA(n){if(!n)return null;const e=n.trigger==="manual"?"manual":"auto";return n.postTokens!=null?`${e} · ${lt(n.preTokens)} → ${lt(n.postTokens)}`:`${e} · ${lt(n.preTokens)}`}const cA=w.memo(function(e){const t=B.c(29),{summary:s,meta:o}=e,[i,a]=w.useState(!1);let l;t[0]!==o?(l=lA(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(mt,{className:"size-3","data-icon":"inline-start"}):r.jsx(Ye,{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(dw,{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 C;t[14]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx("div",{className:"h-px flex-1 bg-border"}),t[14]=C):C=t[14];let N;t[15]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx("div",{className:"h-px flex-1 bg-border"}),t[15]=N):N=t[15];let E;return t[16]!==x?(E=r.jsxs("div",{className:"flex items-center gap-3 px-4 py-2",children:[C,x,N]}),t[16]=x,t[17]=E):E=t[17],E}let v,y;t[18]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(ee,{type:"button",variant:"ghost",className:"group h-auto w-full gap-3 px-0"}),y=r.jsx("div",{className:"h-px flex-1 bg-border"}),t[18]=v,t[19]=y):(v=t[18],y=t[19]);let b;t[20]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx("div",{className:"h-px flex-1 bg-border"}),t[20]=b):b=t[20];let j;t[21]!==x?(j=r.jsxs(Rt,{render:v,children:[y,x,b]}),t[21]=x,t[22]=j):j=t[22];let S;t[23]!==u?(S=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(qn,{remarkPlugins:Yn,components:Gn,children:u})})}),t[23]=u,t[24]=S):S=t[24];let k;return t[25]!==i||t[26]!==j||t[27]!==S?(k=r.jsxs(ct,{open:i,onOpenChange:a,className:"px-4 py-2",children:[j,S]}),t[25]=i,t[26]=j,t[27]=S,t[28]=k):k=t[28],k}),dA=1.5;function uA(n,e){return e<=0?!1:n<e*dA}function fA(n,e){return n===0&&!e}function mA(n,e){return!n||!n.firstKey||e.length<=n.length||e[0]===n.firstKey?!1:e.includes(n.firstKey)}function pA(n,e){return e&&e!=="claude"?n.isFragment===!0:n.userMessage===null}const hA=1e3;function gA(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)<=hA?!1:(e.set(a,i),!0)});return s.length===t.contentBlocks.length?t:{...t,contentBlocks:s}})}function Q2(n,e,t){const s=new Set(n.map(c=>c.id)),o=e.filter(c=>!s.has(c.id));if(o.length===0)return n;const i=n[0],a=o[o.length-1],l=i&&a&&pA(i,t)?[...o.slice(0,-1),bA(a,i),...n.slice(1)]:[...o,...n];return Nu(gA(l))}function xA(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 bA(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:xA(n,e),tokenUsage:e.tokenUsage??n.tokenUsage,model:e.model??n.model,compactionSummary:n.compactionSummary??e.compactionSummary,compactionMeta:n.compactionMeta??e.compactionMeta}}function vA(){const n=B.c(10),{session:e,isSubAgentView:t,undoRedo:s}=ot(),{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(G7,{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(J2,{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(uw,{"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 yA(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(et,{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 wA(n){return(n.compactionSummary!=null||n.compactionMeta!=null)&&n.userMessage==null&&n.contentBlocks.length===0}function jA({filteredTurns:n,scrollContainerRef:e,hasMore:t=!1,isLoadingOlder:s=!1,pagingEnabled:o=!1,onLoadMore:i}){const{state:{activeTurnIndex:a}}=qt(),{undoRedo:l}=ot(),c=w.useRef(null),d=w.useRef(null),[u,f]=w.useState(0),m=w.useMemo(()=>{const b=new Map;return n.map(j=>{const S=b.get(j.turn.id)??0;return b.set(j.turn.id,S+1),{...j,key:S===0?j.turn.id:`${j.turn.id}#${S}`}})},[n]),p=w.useRef(null),h=w.useMemo(()=>mA(p.current,m.map(b=>b.key)),[m]);w.useLayoutEffect(()=>{var b;p.current={firstKey:(b=m[0])==null?void 0:b.key,length:m.length}},[m]);const g=w.useRef(t);w.useEffect(()=>{t&&(g.current=!0)},[t]);const x=t||g.current;w.useLayoutEffect(()=>{const b=e.current,j=d.current;if(!b||!j)return;const S=j.getBoundingClientRect().top-b.getBoundingClientRect().top+b.scrollTop;f(k=>Math.abs(k-S)<1?k:S)},[e,x]),w.useEffect(()=>{if(!t||!i||!o||s)return;const b=e.current;if(!b)return;const j=()=>{uA(b.scrollTop,b.clientHeight)&&i()};return j(),b.addEventListener("scroll",j,{passive:!0}),()=>b.removeEventListener("scroll",j)},[t,s,o,i,m.length,e]);const v=w.useMemo(()=>{const b=new Map;for(let j=0;j<m.length;j++)b.set(m[j].index,j);return b},[m]),y=w.useRef(null);return w.useEffect(()=>{var j;if(a===null){y.current=null;return}if(a===y.current)return;y.current=a;const b=v.get(a);b!==void 0&&((j=c.current)==null||j.scrollToIndex(b,{align:"start",smooth:!0}))},[a,v]),r.jsxs(r.Fragment,{children:[x&&r.jsx(yA,{hasMore:t,isLoadingOlder:s}),r.jsx("div",{ref:d,className:"motion-session-enter",children:r.jsx(V7,{ref:c,scrollRef:e,startMargin:u,shift:h,children:m.map(({turn:b,index:j,key:S})=>r.jsxs("div",{"data-turn-index":j,children:[(b.compactionSummary||b.compactionMeta)&&r.jsx(cA,{summary:b.compactionSummary,meta:b.compactionMeta}),!wA(b)&&r.jsx(J2,{turn:b,index:j,branchCount:l.branchesAtTurn?l.branchesAtTurn(j).length:0})]},S))})}),r.jsx(vA,{})]})}const SA=w.memo(function(e){const t=B.c(19),{chatScrollRef:s,hasMore:o,isLoadingOlder:i,pagingEnabled:a,onLoadMore:l}=e,{state:c}=qt(),{searchQuery:d,sessionChangeKey:u}=c,{session:f}=ot(),m=f==null?void 0:f.turns;let p;t[0]!==m?(p=m?m.map(NA):[],t[0]=m,t[1]=p):p=t[1];const h=p;let g;t[2]!==h||t[3]!==d?(g=d?h.filter(j=>{const{turn:S}=j;return FE(S,d)}):h,t[2]=h,t[3]=d,t[4]=g):g=t[4];const x=g;let v;t[5]!==x.length||t[6]!==o||t[7]!==d?(v=d?x.length===0:fA(x.length,o??!1),t[5]=x.length,t[6]=o,t[7]=d,t[8]=v):v=t[8];const y=v;let b;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]!==y?(b=r.jsx(W_,{children:y?r.jsx(Kt,{className:"min-h-64 border-0",children:r.jsxs(Vt,{children:[r.jsx(en,{variant:"icon",children:d?r.jsx(fw,{}):r.jsx(G1,{})}),r.jsx(Gt,{children:d?"No matching turns":"No conversation yet"}),r.jsx(tn,{children:d?"Try a different search term.":"Messages and tool activity will appear here."})]})}):r.jsx(jA,{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]=y,t[18]=b):b=t[18],b});function NA(n,e){return{turn:n,index:e}}const kA="[data-turn-index]",Z2="[data-turn-prompt]",vh=1,CA=120,yh=180;function _A(n){if(!n.userMessage)return null;const e=sl(n.userMessage),{body:t}=Rr(e),{remainingText:s}=Tu(t),o=F0(s);if(!o){const a=B0(e);if(!a)return null;const l=U0(e);return l?`/${a} ${l}`:`/${a}`}const i=o.split(`
116
+ `)[0];return i.length>yh?`${i.slice(0,yh)}...`:i}function TA(n,e){for(let t=e;t>=0;t--){const s=n[t];if(!s)continue;const o=_A(s);if(o)return{index:t,text:o}}return null}function EA(n){const e=n.getBoundingClientRect().top;let t=null,s=0;for(const l of n.querySelectorAll(kA)){const c=l.getBoundingClientRect().top;if(c>e+vh)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(Z2);return(i?i.getBoundingClientRect().bottom>e+vh:s+CA>e)?null:o}const AA=w.memo(function(e){const t=B.c(22),{session:s,scrollContainerRef:o}=e,[i,a]=w.useState(null);let l,c;t[0]!==o||t[1]!==s.sessionId?(l=()=>{const j=o.current;if(!j)return;let S=null;const k=()=>{S=null;const T=EA(j);a(P=>T===null?null:(P==null?void 0:P.sessionId)===s.sessionId&&P.index===T?P:{sessionId:s.sessionId,index:T})},C=()=>{S===null&&(S=requestAnimationFrame(k))};a(null),j.addEventListener("scroll",C,{passive:!0});const N=new MutationObserver(C);N.observe(j,{childList:!0,subtree:!0});const E=new ResizeObserver(C);return E.observe(j),j.firstElementChild&&E.observe(j.firstElementChild),C(),()=>{j.removeEventListener("scroll",C),N.disconnect(),E.disconnect(),S!==null&&cancelAnimationFrame(S)}},c=[o,s.sessionId],t[0]=o,t[1]=s.sessionId,t[2]=l,t[3]=c):(l=t[2],c=t[3]),w.useEffect(l,c);let d;e:{if(!i||i.sessionId!==s.sessionId){d=null;break e}let j;t[4]!==s.turns||t[5]!==i.index?(j=TA(s.turns,i.index),t[4]=s.turns,t[5]=i.index,t[6]=j):j=t[6],d=j}const u=d;if(!u)return null;let f;t[7]!==u.index||t[8]!==o?(f=()=>{const j=o.current;if(!j)return;const S=j.querySelector(`[data-turn-index="${u.index}"]`),k=(S==null?void 0:S.querySelector(Z2))??S;if(!k)return;const C=j.scrollTop+k.getBoundingClientRect().top-j.getBoundingClientRect().top;j.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(G1,{"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 v;t[13]!==u.text?(v=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]=v):v=t[14];let y;t[15]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(Ca,{"data-icon":"inline-end",className:"ml-auto"}),t[15]=y):y=t[15];let b;return t[16]!==u.text||t[17]!==m||t[18]!==p||t[19]!==x||t[20]!==v?(b=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,v,y]}),t[16]=u.text,t[17]=m,t[18]=p,t[19]=x,t[20]=v,t[21]=b):b=t[21],b});function PA(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(wh,{}),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(Ou,{text:t.text}),e[7]=t.text,e[8]=o):o=e[8];let i;e[9]!==s?(i=s&&r.jsx(wh,{}),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 wh(){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 IA=w.memo(function(){const e=B.c(9),t=Lu();let s,o,i,a;if(e[0]!==t){a=Symbol.for("react.early_return_sentinel");e:{const c=T8(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(RA,-1);return r.jsx("div",{children:u.blocks.map((p,h)=>r.jsx(PA,{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 RA(n,e,t){return e.blockType!=="tool_use"&&e.text?t:n}class $A extends w.Component{constructor(t){super(t);Ci(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(ut,{variant:"destructive",className:"max-w-md has-data-[slot=alert-action]:pr-2.5",children:[r.jsx(mn,{}),r.jsx(Et,{children:r.jsx("h3",{children:this.props.fallbackMessage||"Something went wrong"})}),this.state.error&&r.jsx(ft,{className:"font-mono text-xs",children:this.state.error.message}),r.jsx(Ts,{className:"static col-start-2 mt-2",children:r.jsxs(ee,{variant:"outline",size:"sm",onClick:this.handleRetry,children:[r.jsx(Pt,{"data-icon":"inline-start"}),"Try again"]})})]})}):this.props.children}}const jh="find-in-session-highlight",Zl="find-in-session-active";function MA(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 LA=w.forwardRef(function(e,t){const s=B.c(63),{scrollContainerRef:o}=e,[i,a]=w.useState(!1),[l,c]=w.useState("");let d;s[0]===Symbol.for("react.memo_cache_sentinel")?(d=[],s[0]=d):d=s[0];const[u,f]=w.useState(d),[m,p]=w.useState(-1),h=w.useRef(null);let g;s[1]!==o?(g=()=>{const ne=o.current;if(!ne)return;ne.querySelectorAll(`mark.${jh}`).forEach(OA)},s[1]=o,s[2]=g):g=s[2];const x=g;let v;s[3]!==x||s[4]!==o?(v=ne=>{if(x(),!ne||!o.current){f([]),p(-1);return}const oe=o.current,re=MA(oe),ie=ne.toLowerCase(),se=[];for(const ce of re){const ae=ce.nodeValue||"",ue=ae.toLowerCase();let me=0;const de=[];for(;;){const ve=ue.indexOf(ie,me);if(ve===-1)break;de.push(ve),me=ve+1}if(de.length===0)continue;const le=ce.parentNode;if(!le)continue;const xe=document.createDocumentFragment();let pe=0;for(const ve of de){ve>pe&&xe.appendChild(document.createTextNode(ae.slice(pe,ve)));const Te=document.createElement("mark");Te.className=jh,Te.textContent=ae.slice(ve,ve+ne.length),xe.appendChild(Te),se.push(Te),pe=ve+ne.length}pe<ae.length&&xe.appendChild(document.createTextNode(ae.slice(pe))),le.replaceChild(xe,ce)}f(se),se.length>0?(p(0),se[0].classList.add(Zl),se[0].scrollIntoView({block:"center",behavior:"smooth"})):p(-1)},s[3]=x,s[4]=o,s[5]=v):v=s[5];const y=v;let b;s[6]!==m||s[7]!==u?(b=ne=>{if(u.length===0)return;m>=0&&m<u.length&&u[m].classList.remove(Zl);const oe=(ne%u.length+u.length)%u.length;u[oe].classList.add(Zl),u[oe].scrollIntoView({block:"center",behavior:"smooth"}),p(oe)},s[6]=m,s[7]=u,s[8]=b):b=s[8];const j=b;let S;s[9]!==x?(S=()=>{a(!1),c(""),x(),f([]),p(-1)},s[9]=x,s[10]=S):S=s[10];const k=S;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]),w.useImperativeHandle(t,C,N);let E,T;s[15]!==y||s[16]!==l?(E=()=>{const ne=setTimeout(()=>y(l),150);return()=>clearTimeout(ne)},T=[l,y],s[15]=y,s[16]=l,s[17]=E,s[18]=T):(E=s[17],T=s[18]),w.useEffect(E,T);let P,_;s[19]!==x?(P=()=>()=>x(),_=[x],s[19]=x,s[20]=P,s[21]=_):(P=s[20],_=s[21]),w.useEffect(P,_);let A;s[22]!==m||s[23]!==j||s[24]!==k?(A=ne=>{ne.key==="Escape"?(ne.preventDefault(),ne.stopPropagation(),k()):ne.key==="Enter"&&(ne.preventDefault(),ne.shiftKey?j(m-1):j(m+1))},s[22]=m,s[23]=j,s[24]=k,s[25]=A):A=s[25];const I=A;if(!i)return null;let $;s[26]===Symbol.for("react.memo_cache_sentinel")?($=ne=>c(ne.target.value),s[26]=$):$=s[26];let R;s[27]!==I||s[28]!==l?(R=r.jsx(us,{ref:h,value:l,onChange:$,onKeyDown:I,placeholder:"Find in conversation","aria-label":"Find in conversation",autoFocus:!0}),s[27]=I,s[28]=l,s[29]=R):R=s[29];const M=l?u.length>0?`${m+1}/${u.length}`:"0/0":"";let O;s[30]!==M?(O=r.jsx(En,{align:"inline-end",children:r.jsx("span",{className:"min-w-12 text-center text-xs tabular-nums",children:M})}),s[30]=M,s[31]=O):O=s[31];let D;s[32]!==R||s[33]!==O?(D=r.jsxs(ds,{className:"w-64",children:[R,O]}),s[32]=R,s[33]=O,s[34]=D):D=s[34];let z;s[35]!==m||s[36]!==j?(z=()=>j(m-1),s[35]=m,s[36]=j,s[37]=z):z=s[37];const F=u.length===0,L=u.length>0?"hover:text-foreground":"cursor-default opacity-40";let H;s[38]!==L?(H=q("text-muted-foreground",L),s[38]=L,s[39]=H):H=s[39];let U;s[40]===Symbol.for("react.memo_cache_sentinel")?(U=r.jsx(Ca,{"data-icon":"inline-start"}),s[40]=U):U=s[40];let W;s[41]!==z||s[42]!==F||s[43]!==H?(W=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:z,disabled:F,className:H,"aria-label":"Previous match",children:U}),s[41]=z,s[42]=F,s[43]=H,s[44]=W):W=s[44];let V;s[45]!==m||s[46]!==j?(V=()=>j(m+1),s[45]=m,s[46]=j,s[47]=V):V=s[47];const K=u.length===0,Y=u.length>0?"hover:text-foreground":"cursor-default opacity-40";let X;s[48]!==Y?(X=q("text-muted-foreground",Y),s[48]=Y,s[49]=X):X=s[49];let G;s[50]===Symbol.for("react.memo_cache_sentinel")?(G=r.jsx(mt,{"data-icon":"inline-start"}),s[50]=G):G=s[50];let J;s[51]!==V||s[52]!==K||s[53]!==X?(J=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:V,disabled:K,className:X,"aria-label":"Next match",children:G}),s[51]=V,s[52]=K,s[53]=X,s[54]=J):J=s[54];let Z;s[55]===Symbol.for("react.memo_cache_sentinel")?(Z=r.jsx(tt,{"data-icon":"inline-start"}),s[55]=Z):Z=s[55];let Q;s[56]!==k?(Q=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:k,className:"text-muted-foreground hover:text-foreground","aria-label":"Close search",children:Z}),s[56]=k,s[57]=Q):Q=s[57];let te;return s[58]!==D||s[59]!==W||s[60]!==J||s[61]!==Q?(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:[D,W,J,Q]}),s[58]=D,s[59]=W,s[60]=J,s[61]=Q,s[62]=te):te=s[62],te});function OA(n){const e=n.parentNode;e&&(e.replaceChild(document.createTextNode(n.textContent||""),n),e.normalize())}const eb=[1,2,3,4,5,6,7,8,9],pB=["General","View","Tools"],cl=[{command:"commandPalette",label:"Open command palette",description:"Search actions, projects, and recent sessions",group:"General",defaultShortcut:{key:"k",modKey:!0}},{command:"keyboardShortcuts",label:"Show keyboard shortcuts",description:"Open this reference — only while no text field is focused",group:"General",defaultShortcut:{key:"?",shiftKey:!0}},{command:"newSession",label:"Start a new session",description:"Open the project picker for a new agent session",group:"General",defaultShortcut:{key:"n",platformChord:!0}},{command:"focusComposer",label:"Focus message composer",description:"Jump to the chat composer — only while no text field is focused",group:"General",defaultShortcut:{key:" "}},{command:"prevLiveSession",label:"Focus previous live session",description:"Move focus up the live session list; press Enter to open",group:"General",defaultShortcut:{key:"arrowup",modKey:!0,shiftKey:!0}},{command:"nextLiveSession",label:"Focus next live session",description:"Move focus down the live session list; press Enter to open",group:"General",defaultShortcut:{key:"arrowdown",modKey:!0,shiftKey:!0}},{command:"recentSessionBack",label:"Previous recent session",description:"Step back through recently opened sessions",group:"General",defaultShortcut:{key:"tab",ctrlKey:!0}},{command:"recentSessionForward",label:"Next recent session",description:"Step forward through recently opened sessions",group:"General",defaultShortcut:{key:"tab",ctrlKey:!0,shiftKey:!0}},{command:"toggleSidebar",label:"Toggle session sidebar",description:"Show or hide projects and sessions",group:"View",defaultShortcut:{key:"b",modKey:!0}},{command:"missionControl",label:"Toggle Mission Control",description:"Show every live session at once and answer whatever is blocked",group:"View",defaultShortcut:{doubleTapModifier:"mod"}},{command:"toggleStats",label:"Toggle session analytics",description:"Show or hide the right analytics panel",group:"View",defaultShortcut:{key:"b",modKey:!0,shiftKey:!0}},{command:"expandAll",label:"Expand all groups",description:"Expand conversation and tool groups without opening raw payloads",group:"View",defaultShortcut:{key:"e",modKey:!0}},{command:"expandToolPayloads",label:"Expand all tool payloads",description:"Expand tool inputs, results, and diffs with their containing groups",group:"View",defaultShortcut:{key:"e",modKey:!0,shiftKey:!0}},{command:"findInConversation",label:"Find in conversation",description:"Search the open conversation and step through matches",group:"View",defaultShortcut:{key:"f",modKey:!0}},{command:"integratedTerminal",label:"Toggle integrated terminal",description:"Open or collapse the in-app project terminal",group:"Tools",defaultShortcut:{key:"j",modKey:!0}},{command:"newIntegratedTerminal",label:"New integrated terminal",description:"Create another terminal while the integrated terminal is focused",group:"Tools",defaultShortcut:{key:"n",modKey:!0}},{command:"closeIntegratedTerminal",label:"Close integrated terminal",description:"Close the active terminal while the integrated terminal is focused",group:"Tools",defaultShortcut:{key:"w",modKey:!0}},{command:"preview",label:"Toggle development preview",description:"Show or hide the in-app local server preview",group:"Tools",defaultShortcut:{key:"j",modKey:!0,shiftKey:!0}},{command:"previewRefresh",label:"Refresh development preview",description:"Reload the page while the preview toolbar is focused",group:"Tools",defaultShortcut:{key:"r",modKey:!0}},{command:"previewFocusUrl",label:"Focus preview URL",description:"Select the URL while the preview toolbar is focused",group:"Tools",defaultShortcut:{key:"l",modKey:!0}},{command:"previewZoomIn",label:"Zoom preview in",description:"Increase the preview scale while its toolbar is focused",group:"Tools",defaultShortcut:{key:"=",modKey:!0}},{command:"previewZoomOut",label:"Zoom preview out",description:"Decrease the preview scale while its toolbar is focused",group:"Tools",defaultShortcut:{key:"-",modKey:!0}},{command:"previewResetZoom",label:"Reset preview zoom",description:"Return the preview to 100% while its toolbar is focused",group:"Tools",defaultShortcut:{key:"0",modKey:!0}},{command:"projectFiles",label:"Toggle project files",description:"Browse and edit files in the active project",group:"Tools",defaultShortcut:{key:"f",modKey:!0,shiftKey:!0}},{command:"projectFileSave",label:"Save project file",description:"Save the open file while the project file workspace is focused",group:"Tools",defaultShortcut:{key:"s",modKey:!0}},{command:"systemTerminal",label:"Open system terminal",description:"Open the project in your preferred terminal app",group:"Tools",defaultShortcut:{key:"t",platformChord:!0}},{command:"themeSelector",label:"Change theme",description:"Open the theme selector",group:"Tools",defaultShortcut:{key:"s",platformChord:!0}},...eb.map(n=>({command:`device.switch.${n}`,label:`Switch to device ${n}`,description:n===1?"Jump to this machine (the local device)":`Jump to the ${n}${n===2?"nd":n===3?"rd":"th"} device in the switcher`,group:"General",defaultShortcut:{key:String(n),platformChord:!0}})),{command:"device.cycle",label:"Cycle devices",description:"Switch to the next device in the switcher",group:"General",defaultShortcut:{key:"0",platformChord:!0}}],tb="cogpit-keybindings";let Ls=null;function nb(n=typeof navigator>"u"?"":navigator.platform){return/Mac|iPhone|iPad/i.test(n)}function Dr(n){const e=n.toLowerCase();return e==="esc"?"escape":e}function DA(n){if(!n||typeof n!="object")return!1;const e=n;return e.doubleTapModifier==="mod"||typeof e.key=="string"&&e.key.length>0}function Gu(){if(Ls)return Ls;try{const n=localStorage.getItem(tb);if(!n)return Ls={};const e=JSON.parse(n);if(!e||typeof e!="object")return Ls={};const t={};for(const s of cl){const o=e[s.command];DA(o)&&(t[s.command]=o)}return Ls=t}catch{return Ls={}}}function Yu(n){Ls=n;try{localStorage.setItem(tb,JSON.stringify(n))}catch{}typeof window<"u"&&window.dispatchEvent(new Event("cogpit-keybindings-changed"))}function ci(n){const e=cl.find(t=>t.command===n);if(!e)throw new Error(`Unknown keybinding command: ${n}`);return Gu()[n]??e.defaultShortcut}function hB(){return Object.fromEntries(cl.map(n=>[n.command,ci(n.command)]))}function gB(n,e){const t="doubleTapModifier"in e?{...e}:{...e,key:Dr(e.key)};Yu({...Gu(),[n]:t})}function xB(n){const e={...Gu()};delete e[n],Yu(e)}function bB(){Yu({})}function vB(n){return{key:Dr(n.key),metaKey:n.metaKey||void 0,ctrlKey:n.ctrlKey||void 0,shiftKey:n.shiftKey||void 0,altKey:n.altKey||void 0}}function sb(n){const e=n;if(!e)return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||e.isContentEditable===!0}function jt(n,e){const t=ci(n);return"doubleTapModifier"in t||Dr(e.key)!==Dr(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 so(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 zA(n){const e=nb();return"doubleTapModifier"in n?e?"Double ⌘":"Double Ctrl":n.modKey?e?`${n.shiftKey?"⇧":""}⌘${so(n.key)}`:`Ctrl+${n.shiftKey?"Shift+":""}${so(n.key)}`:n.platformChord?e?`⌃⌘${n.shiftKey?"⇧":""}${so(n.key)}`:`Ctrl+Alt+${n.shiftKey?"Shift+":""}${so(n.key)}`:e?`${n.ctrlKey?"⌃":""}${n.altKey?"⌥":""}${n.shiftKey?"⇧":""}${n.metaKey?"⌘":""}${so(n.key)}`:[n.ctrlKey?"Ctrl":null,n.altKey?"Alt":null,n.shiftKey?"Shift":null,n.metaKey?"Meta":null,so(n.key)].filter(Boolean).join("+")}function ec(n){return zA(ci(n))}function Sh(n){if("doubleTapModifier"in n)return[`double-tap:${n.doubleTapModifier}`];const e=(t,s,o,i)=>`${Dr(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 yB(n,e){const t=new Set(Sh(n));return cl.find(s=>s.command!==e&&Sh(ci(s.command)).some(o=>t.has(o)))??null}function Nh(n){return"doubleTapModifier"in ci(n)?nb()?"Meta":"Control":null}const FA=eb.map(n=>`device.switch.${n}`),BA="device.cycle";function UA(n){const e=FA.findIndex(t=>jt(t,n));return e===-1?null:e+1}function WA(n){return jt(BA,n)}const sd="cogpit:find-in-conversation",dl=w.memo(function(e){const t=B.c(77),{searchInputRef:s,hasTodos:o,hasMore:i,isLoadingOlder:a,onLoadMore:l,mobileSearchOpen:c,onMobileSearchClose:d}=e,u=c===void 0?!1:c,{state:f,dispatch:m,isMobile:p}=qt(),{session:h}=ot(),{chat:g,scroll:x}=Vr(),{searchQuery:v}=f,{pendingMessages:y}=g,{chatScrollRef:b,scrollEndRef:j,handleScroll:S,canScrollDown:k,scrollToBottomInstant:C,initialScrollDone:N}=x,E=w.useRef(null);let T;t[0]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{var le;return(le=E.current)==null?void 0:le.open()},t[0]=T):T=t[0];const P=T;let _,A;t[1]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{const le=function(pe){jt("findInConversation",pe)&&(pe.preventDefault(),P())};return window.addEventListener("keydown",le),window.addEventListener(sd,P),()=>{window.removeEventListener("keydown",le),window.removeEventListener(sd,P)}},A=[P],t[1]=_,t[2]=A):(_=t[1],A=t[2]),w.useEffect(_,A);let I,$;t[3]!==p||t[4]!==u||t[5]!==s?(I=()=>{!p||!u||requestAnimationFrame(()=>{var le;return(le=s.current)==null?void 0:le.focus()})},$=[p,u,s],t[3]=p,t[4]=u,t[5]=s,t[6]=I,t[7]=$):(I=t[6],$=t[7]),w.useEffect(I,$);let R;t[8]!==m||t[9]!==d?(R=()=>{m({type:"SET_SEARCH_QUERY",value:""}),d==null||d()},t[8]=m,t[9]=d,t[10]=R):R=t[10];const M=R,O=h,D=O.turns.length>0||y.length===0,z=p?"flex min-h-0 flex-1 flex-col":"min-h-0 flex-1";let F;t[11]!==z?(F=q("relative bg-background",z),t[11]=z,t[12]=F):F=t[12];let L;t[13]!==M||t[14]!==m||t[15]!==p||t[16]!==u||t[17]!==s||t[18]!==v?(L=p&&u&&r.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b bg-background px-3 py-2",children:[r.jsxs(ds,{className:"h-9 flex-1",children:[r.jsx(us,{ref:s,value:v,onChange:le=>m({type:"SET_SEARCH_QUERY",value:le.target.value}),placeholder:"Search conversation...","aria-label":"Search conversation"}),r.jsx(En,{align:"inline-start",children:r.jsx(Yt,{})})]}),r.jsx(ee,{variant:"ghost",size:"icon-sm",onClick:M,"aria-label":"Close conversation search",children:r.jsx(tt,{"data-icon":"inline-start"})})]}),t[13]=M,t[14]=m,t[15]=p,t[16]=u,t[17]=s,t[18]=v,t[19]=L):L=t[19];const H=p?"flex-1 min-h-0":"h-full";let U;t[20]!==H?(U=q("relative",H),t[20]=H,t[21]=U):U=t[21];let W;t[22]!==b?(W=r.jsx(LA,{ref:E,scrollContainerRef:b}),t[22]=b,t[23]=W):W=t[23];let V;t[24]!==b||t[25]!==O?(V=r.jsx(AA,{session:O,scrollContainerRef:b}),t[24]=b,t[25]=O,t[26]=V):V=t[26];const K=p&&"mobile-scroll";let Y;t[27]!==K?(Y=q("h-full overflow-x-hidden overflow-y-auto bg-background",K),t[27]=K,t[28]=Y):Y=t[28];let X;t[29]!==o||t[30]!==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[29]=o,t[30]=p,t[31]=X):X=t[31];let G;t[32]!==b||t[33]!==i||t[34]!==N||t[35]!==a||t[36]!==l||t[37]!==D?(G=D&&r.jsx(SA,{chatScrollRef:b,hasMore:i,isLoadingOlder:a,pagingEnabled:N,onLoadMore:l}),t[32]=b,t[33]=i,t[34]=N,t[35]=a,t[36]=l,t[37]=D,t[38]=G):G=t[38];let J;t[39]===Symbol.for("react.memo_cache_sentinel")?(J=r.jsx(IA,{}),t[39]=J):J=t[39];let Z;if(t[40]!==O.turns.length||t[41]!==y){let le;t[43]!==O.turns.length?(le=(xe,pe)=>r.jsx(q0,{message:xe,turnNumber:O.turns.length+1+pe},pe),t[43]=O.turns.length,t[44]=le):le=t[44],Z=y.map(le),t[40]=O.turns.length,t[41]=y,t[42]=Z}else Z=t[42];let Q;t[45]===Symbol.for("react.memo_cache_sentinel")?(Q=r.jsx(DE,{}),t[45]=Q):Q=t[45];let te;t[46]!==j?(te=r.jsx("div",{ref:j}),t[46]=j,t[47]=te):te=t[47];let ne;t[48]!==G||t[49]!==Z||t[50]!==te?(ne=r.jsxs($A,{fallbackMessage:"Failed to render conversation timeline",children:[G,J,Z,Q,te]}),t[48]=G,t[49]=Z,t[50]=te,t[51]=ne):ne=t[51];let oe;t[52]!==X||t[53]!==ne?(oe=r.jsx("div",{className:X,children:ne}),t[52]=X,t[53]=ne,t[54]=oe):oe=t[54];let re;t[55]!==b||t[56]!==S||t[57]!==Y||t[58]!==oe?(re=r.jsx("div",{ref:b,onScroll:S,className:Y,children:oe}),t[55]=b,t[56]=S,t[57]=Y,t[58]=oe,t[59]=re):re=t[59];const ie=k?"opacity-100 scale-100":"opacity-0 scale-75 pointer-events-none",se=p?"right-3 bottom-3":"right-5 bottom-5";let ce;t[60]!==ie||t[61]!==se?(ce=q("absolute rounded-full shadow-sm transition-[opacity,transform] duration-200 ease-out active:scale-95",ie,se),t[60]=ie,t[61]=se,t[62]=ce):ce=t[62];let ae;t[63]===Symbol.for("react.memo_cache_sentinel")?(ae=r.jsx(mw,{"data-icon":"inline-start"}),t[63]=ae):ae=t[63];let ue;t[64]!==C||t[65]!==ce?(ue=r.jsx(ee,{size:"icon",className:ce,onClick:C,"aria-label":"Scroll to bottom",children:ae}),t[64]=C,t[65]=ce,t[66]=ue):ue=t[66];let me;t[67]!==U||t[68]!==W||t[69]!==V||t[70]!==re||t[71]!==ue?(me=r.jsxs("div",{className:U,children:[W,V,re,ue]}),t[67]=U,t[68]=W,t[69]=V,t[70]=re,t[71]=ue,t[72]=me):me=t[72];let de;return t[73]!==L||t[74]!==me||t[75]!==F?(de=r.jsxs("div",{className:F,children:[L,me]}),t[73]=L,t[74]=me,t[75]=F,t[76]=de):de=t[76],de});async function Os(n){try{const e=await(n==null?void 0:n.json());return e&&typeof e=="object"?e:null}catch{return null}}async function tc(n,e){const t=await Os(n);return typeof(t==null?void 0:t.error)=="string"&&t.error?t.error:e}const od="cogpit-devices-changed",ob="cogpit:devices-changed";function rb(n){typeof n.connectionRevision=="number"&&s4(n.id,n.connectionRevision)}function ib(n,e,t=!1){window.dispatchEvent(new CustomEvent(od,{detail:{deviceId:n,connectionRevision:e,removed:t}}));try{localStorage.setItem(ob,JSON.stringify({deviceId:n,connectionRevision:e,removed:t,nonce:`${Date.now()}:${Math.random()}`}))}catch{}}function kh(n){rb(n),ib(n.id,n.connectionRevision)}function nc(n,e=""){return`/api/hub/devices/${encodeURIComponent(n)}${e}`}function ab(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.version;if(typeof t=="string")return t}}function HA(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.edition;if(t==="team"||t==="personal")return t}}function ul(){const[n,e]=w.useState([]),[t,s]=w.useState(!0),[o,i]=w.useState(()=>xt()),a=w.useRef(0),l=w.useCallback(async()=>{const h=++a.current;try{const g=await ps("/api/hub/devices");if(!g.ok)return;const x=await Os(g);if(h!==a.current)return;const v=Array.isArray(x==null?void 0:x.devices)?x.devices:[];for(const y of v)rb(y);e(v)}catch{}finally{h===a.current&&s(!1)}},[]);w.useEffect(()=>{l()},[l]),w.useEffect(()=>{const h=()=>i(xt()),g=()=>void l(),x=b=>{if(b.key===ob){try{const j=JSON.parse(b.newValue??"null");(j==null?void 0:j.removed)===!0&&typeof j.deviceId=="string"&&xt()===j.deviceId&&ks(Tt)}catch{}l()}},v=()=>{a.current+=1,e([]),s(!0),l()},y=()=>{a.current+=1,e([]),s(!1)};return window.addEventListener("cogpit-device-changed",h),window.addEventListener("popstate",h),window.addEventListener(od,g),window.addEventListener("storage",x),window.addEventListener("cogpit-auth-changed",v),window.addEventListener("cogpit-identity-changed",v),window.addEventListener("cogpit-auth-required",y),()=>{window.removeEventListener("cogpit-device-changed",h),window.removeEventListener("popstate",h),window.removeEventListener(od,g),window.removeEventListener("storage",x),window.removeEventListener("cogpit-auth-changed",v),window.removeEventListener("cogpit-identity-changed",v),window.removeEventListener("cogpit-auth-required",y)}},[l]);const c=w.useMemo(()=>o===Tt?void 0:n.find(h=>h.id===o),[n,o]),d=w.useCallback(async(h,g,x,v)=>{try{const y=await ps("/api/hub/devices/probe",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:h,port:g,allowLocalTunnel:x,tls:v})}),b=await Os(y);return(b==null?void 0:b.ok)===!0&&b.hello?{ok:!0,hello:b.hello}:{ok:!1,code:(b==null?void 0:b.code)??"UNREACHABLE",error:typeof(b==null?void 0:b.error)=="string"?b.error:void 0}}catch{return{ok:!1,code:"UNREACHABLE",error:"Could not reach the device."}}},[]),u=w.useCallback(async h=>{try{const g=await ps("/api/hub/devices",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(h)}),x=await Os(g);if(g.ok&&(x!=null&&x.device)){const v=x.device;return kh(v),{ok:!0,device:v}}return{ok:!1,code:(x==null?void 0:x.code)??"ERROR",error:typeof(x==null?void 0:x.error)=="string"?x.error:"Could not add the device."}}catch{return{ok:!1,code:"ERROR",error:"Could not add the device."}}},[]),f=w.useCallback(async(h,g)=>{try{const x=await ps(nc(h),{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(g)}),v=await Os(x);if(x.ok&&(v!=null&&v.device)){const y=v.device;return kh(y),{ok:!0,device:y}}return{ok:!1,code:(v==null?void 0:v.code)??"ERROR",error:typeof(v==null?void 0:v.error)=="string"?v.error:"Could not update the device."}}catch{return{ok:!1,code:"ERROR",error:"Could not update the device."}}},[]),m=w.useCallback(async h=>{try{const g=await ps(nc(h),{method:"DELETE"});if(g.ok)return xt()===h&&ks(Tt),ib(h,void 0,!0),{ok:!0};const x=await Os(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=w.useCallback(async h=>{try{const g=await ps(nc(h,"/test"),{method:"POST"});return await Os(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 qA="2.6.6",lb={version:qA},Ch=lb.version,KA=19384,VA=443,GA=450,YA=typeof navigator<"u"&&/Mac|iPhone|iPad/i.test(navigator.platform||""),XA=`${YA?"⌘⇧":"Ctrl+Shift+"}1–9`,JA=new Set(["BAD_PASSWORD","PASSWORD_REQUIRED","USERNAME_REQUIRES_PASSWORD"]),QA=new Set(["ACCOUNT_DISABLED"]);function Bi(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 ZA(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 cb={ok:"text-success",warn:"text-warning",info:"text-info",error:"text-destructive"};function eP(n){const e=B.c(10),{tone:t}=n,s=cb[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(Hn,{"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(mn,{"data-icon":"inline-start",className:i}),e[4]=i,e[5]=l):l=e[5],l}if(t==="info"){let l;return e[6]!==i?(l=r.jsx(Pt,{"data-icon":"inline-start",className:i}),e[6]=i,e[7]=l):l=e[7],l}let a;return e[8]!==i?(a=r.jsx(Ps,{"data-icon":"inline-start",className:i}),e[8]=i,e[9]=a):a=e[9],a}const tP={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"};function nP({device:n,onRename:e,onCredentials:t,onRemove:s,onTest:o}){const[i,a]=w.useState(!1),[l,c]=w.useState(n.name),[d,u]=w.useState(!1),[f,m]=w.useState(n.username??""),[p,h]=w.useState(""),[g,x]=w.useState(null),[v,y]=w.useState(!1),[b,j]=w.useState(null);w.useEffect(()=>{c(n.name)},[n.name]),w.useEffect(()=>{m(n.username??"")},[n.username]);const S=ab(n),k=S!==void 0&&S!==Ch,C=HA(n)==="team";async function N(){const T=l.trim();if(!T||T===n.name){a(!1),c(n.name);return}j("rename"),await e(n.id,T),j(null),a(!1)}async function E(){const T=f.trim(),P=n.username??"",_=T!==P,A=p.length>0;if(!_&&!A){u(!1),h(""),x(null);return}if(n.auth==="none"&&!A){x("Enter a password when adding an account to an unauthenticated device.");return}const I={};_&&(I.username=T||null),A&&(I.password=p),j("credentials"),x(null);const $=await t(n.id,I);if(j(null),!$.ok){x($.error);return}u(!1),h("")}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",tP[n.runtime.authState])}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[i?r.jsx(Mt,{value:l,autoFocus:!0,"aria-label":`Rename ${n.name}`,onChange:T=>c(T.target.value),onKeyDown:T=>{T.key==="Enter"&&N(),T.key==="Escape"&&(a(!1),c(n.name))},onBlur:()=>void N(),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}),S&&r.jsxs("span",{className:q("shrink-0 font-mono text-xs",k?"text-warning":"text-muted-foreground"),title:k?`Device runs v${S}; hub runs v${Ch}`:void 0,children:["v",S,k&&" ≠ hub"]}),n.auth==="none"&&r.jsx(Pe,{variant:"secondary",children:"Unauthenticated"})]}),r.jsxs("span",{className:"truncate font-mono text-xs text-muted-foreground",children:[n.tls?"https://":"",n.host,":",n.port]}),n.username?r.jsxs("span",{className:"truncate text-xs text-muted-foreground",title:n.username,children:["Team account: ",n.username]}):C?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:b==="test",onClick:async()=>{j("test"),await o(n.id),j(null)},children:r.jsx(Pt,{"data-icon":"inline-start",className:q(b==="test"&&"animate-spin")})}),r.jsx(ee,{variant:"ghost",size:"icon-sm","aria-label":`Edit account for ${n.name}`,onClick:()=>{u(T=>!T),m(n.username??""),h(""),x(null)},children:r.jsx(Rd,{"data-icon":"inline-start"})}),r.jsx(ee,{variant:"ghost",size:"icon-sm","aria-label":`Rename ${n.name}`,onClick:()=>a(!0),children:r.jsx(ts,{"data-icon":"inline-start"})}),r.jsxs(nu,{open:v,onOpenChange:T=>{b!=="remove"&&y(T)},children:[r.jsx(DN,{render:r.jsx(ee,{variant:"ghost",size:"icon-sm","aria-label":`Remove ${n.name}`,className:"text-destructive hover:bg-destructive/10 hover:text-destructive"}),children:r.jsx(Ta,{"data-icon":"inline-start"})}),r.jsxs(su,{size:"sm",children:[r.jsxs(ou,{children:[r.jsxs(iu,{children:["Remove ",n.name,"?"]}),r.jsx(au,{children:"This device will disappear from Cogpit. You can add it again later."})]}),r.jsxs(ru,{children:[r.jsx(cu,{disabled:b==="remove",children:"Cancel"}),r.jsxs(lu,{variant:"destructive",disabled:b==="remove",onClick:async()=>{j("remove");try{await s(n.id)}finally{j(null)}},children:[b==="remove"&&r.jsx(et,{"data-icon":"inline-start",className:"animate-spin"}),"Remove device"]})]})]})]})]})]}),d&&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(yt,{children:[r.jsxs(wt,{htmlFor:`device-username-${n.id}`,children:["Username ",r.jsx("span",{className:"text-muted-foreground/60",children:"(team devices)"})]}),r.jsx(Mt,{id:`device-username-${n.id}`,"aria-label":`Username for ${n.name}`,value:f,onChange:T=>m(T.target.value),placeholder:"Leave empty for password-only auth",autoComplete:"off",spellCheck:!1})]}),r.jsxs(yt,{children:[r.jsxs(wt,{htmlFor:`device-password-${n.id}`,children:["New password ",r.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),r.jsx(Mt,{id:`device-password-${n.id}`,"aria-label":`New password for ${n.name}`,type:"password",value:p,onChange:T=>h(T.target.value),placeholder:"Leave blank to keep the stored password",autoComplete:"new-password"})]})]}),n.username&&f.trim()===""&&r.jsx("p",{className:"text-xs text-warning",children:"Clearing the username switches this device back to password-only authentication."}),g&&r.jsx(vs,{children:g}),r.jsxs("div",{className:"flex justify-end gap-1.5",children:[r.jsx(ee,{variant:"outline",size:"sm",onClick:()=>{u(!1),m(n.username??""),h(""),x(null)},children:"Cancel"}),r.jsx(ee,{size:"sm",disabled:b==="credentials",onClick:()=>void E(),children:b==="credentials"?r.jsx(et,{"data-icon":"inline-start",className:"animate-spin"}):"Save account"})]})]})]})}function db(n){var Ue,Be;const e=B.c(115),{open:t,initialMode:s,onClose:o}=n,{devices:i,refresh:a,probe:l,addDevice:c,updateDevice:d,removeDevice:u,testDevice:f}=ul(),[m,p]=w.useState(""),[h,g]=w.useState(""),[x,v]=w.useState(""),[y,b]=w.useState(""),[j,S]=w.useState(!1),[k,C]=w.useState(!1),[N,E]=w.useState(null),[T,P]=w.useState(!1),[_,A]=w.useState(null),I=w.useRef(null),$=w.useRef(0);let R,M;e[0]!==s||e[1]!==t?(R=()=>{t&&(p(""),g(""),v(""),b(""),S(!1),C(!1),E(null),A(null),s==="add"&&requestAnimationFrame(()=>{var Ae;return(Ae=I.current)==null?void 0:Ae.focus()}))},M=[t,s],e[0]=s,e[1]=t,e[2]=R,e[3]=M):(R=e[2],M=e[3]),w.useEffect(R,M);let O;e[4]!==j||e[5]!==h||e[6]!==l?(O=async()=>{const{host:Ae,port:qe,tls:ht}=Bi(h);if(!Ae){E(null),C(!1);return}const Je=$.current=$.current+1;C(!0);const Ke=await l(Ae,qe,j,ht);Je===$.current&&(E({...ZA(Ke,Ae,qe??(ht?VA:KA)),hello:Ke.ok?Ke.hello:void 0}),C(!1))},e[4]=j,e[5]=h,e[6]=l,e[7]=O):O=e[7];const D=O;let z,F;e[8]!==h||e[9]!==t||e[10]!==D?(z=()=>{if(!t)return;if(!Bi(h).host){E(null),C(!1);return}const Ae=window.setTimeout(()=>void D(),GA);return()=>window.clearTimeout(Ae)},F=[t,h,D],e[8]=h,e[9]=t,e[10]=D,e[11]=z,e[12]=F):(z=e[11],F=e[12]),w.useEffect(z,F);const L=((Ue=N==null?void 0:N.hello)==null?void 0:Ue.edition)==="team",H=L&&((Be=N==null?void 0:N.hello)==null?void 0:Be.needsBootstrap)===!0,U=L||!j;let W;e:{if(T){W=!1;break e}if(!Bi(h).host){W=!1;break e}if(k||!N){W=!1;break e}if(H){W=!1;break e}if(U&&!y){W=!1;break e}if(L&&!x.trim()){W=!1;break e}if((N==null?void 0:N.tone)==="error"){W=!1;break e}W=!0}const V=W;let K;e[13]!==c||e[14]!==j||e[15]!==U||e[16]!==h||e[17]!==m||e[18]!==o||e[19]!==y||e[20]!==L||e[21]!==x?(K=async function(){const{host:qe,port:ht,tls:Je}=Bi(h);if(!qe)return;P(!0),A(null);const Ke=await c({name:m.trim()||void 0,host:qe,port:ht,tls:Je,username:L?x.trim():void 0,password:U&&y||void 0,allowLocalTunnel:j});if(P(!1),Ke.ok){o(),ks(Ke.device.id);return}A({field:QA.has(Ke.code)?"username":JA.has(Ke.code)?"password":"host",message:Ke.error})},e[13]=c,e[14]=j,e[15]=U,e[16]=h,e[17]=m,e[18]=o,e[19]=y,e[20]=L,e[21]=x,e[22]=K):K=e[22];const Y=K;let X;e[23]!==d?(X=async(Ae,qe)=>{await d(Ae,{name:qe})},e[23]=d,e[24]=X):X=e[24];const G=X;let J;e[25]!==u?(J=async Ae=>{await u(Ae)},e[25]=u,e[26]=J):J=e[26];const Z=J;let Q;e[27]!==a||e[28]!==f?(Q=async Ae=>{await f(Ae),await a()},e[27]=a,e[28]=f,e[29]=Q):Q=e[29];const te=Q;let ne;e[30]!==o?(ne=Ae=>{Ae||o()},e[30]=o,e[31]=ne):ne=e[31];let oe;e[32]===Symbol.for("react.memo_cache_sentinel")?(oe=r.jsxs(Rs,{children:[r.jsx(ls,{children:"Devices"}),r.jsxs(cs,{children:["Control another Cogpit device from here. The active device is chosen from the header switcher — ",XA," jumps between devices."]})]}),e[32]=oe):oe=e[32];let re;e[33]!==i||e[34]!==Z||e[35]!==G||e[36]!==te||e[37]!==d?(re=i.length>0&&r.jsx("div",{className:"flex flex-col gap-2",children:i.map(Ae=>r.jsx(nP,{device:Ae,onRename:G,onCredentials:d,onRemove:Z,onTest:te},Ae.id))}),e[33]=i,e[34]=Z,e[35]=G,e[36]=te,e[37]=d,e[38]=re):re=e[38];let ie;e[39]===Symbol.for("react.memo_cache_sentinel")?(ie=r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Bn,{"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[39]=ie):ie=e[39];const se=(_==null?void 0:_.field)==="host";let ce,ae;e[40]===Symbol.for("react.memo_cache_sentinel")?(ce=r.jsx(wt,{htmlFor:"device-host",children:"Host"}),ae=r.jsx(Co,{children:"Enter a local address or an HTTPS URL."}),e[40]=ce,e[41]=ae):(ce=e[40],ae=e[41]);let ue;e[42]===Symbol.for("react.memo_cache_sentinel")?(ue=Ae=>{$.current=$.current+1,g(Ae.target.value),v(""),E(null),A(null)},e[42]=ue):ue=e[42];let me;e[43]!==D?(me=()=>void D(),e[43]=D,e[44]=me):me=e[44];let de;e[45]!==h||e[46]!==me?(de=r.jsx(Mt,{id:"device-host",ref:I,value:h,onChange:ue,onBlur:me,placeholder:"192.168.1.42, my-mac.local:19384 or https://cogpit.example.com",spellCheck:!1,autoComplete:"off"}),e[45]=h,e[46]=me,e[47]=de):de=e[47];let le;e[48]!==k?(le=k&&r.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[r.jsx(et,{"data-icon":"inline-start",className:"size-3.5 animate-spin"})," Checking device…"]}),e[48]=k,e[49]=le):le=e[49];let xe;e[50]!==N||e[51]!==k?(xe=!k&&N&&r.jsxs("p",{role:"status",className:q("flex items-center gap-1.5 text-xs",cb[N.tone]),children:[r.jsx(eP,{tone:N.tone}),N.text]}),e[50]=N,e[51]=k,e[52]=xe):xe=e[52];let pe;e[53]!==_?(pe=(_==null?void 0:_.field)==="host"&&r.jsx(vs,{children:_.message}),e[53]=_,e[54]=pe):pe=e[54];let ve;e[55]!==se||e[56]!==de||e[57]!==le||e[58]!==xe||e[59]!==pe?(ve=r.jsxs(yt,{"data-invalid":se,children:[ce,ae,de,le,xe,pe]}),e[55]=se,e[56]=de,e[57]=le,e[58]=xe,e[59]=pe,e[60]=ve):ve=e[60];let Te;e[61]===Symbol.for("react.memo_cache_sentinel")?(Te=r.jsxs(wt,{htmlFor:"device-name",children:["Name ",r.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),e[61]=Te):Te=e[61];let $e;e[62]===Symbol.for("react.memo_cache_sentinel")?($e=Ae=>p(Ae.target.value),e[62]=$e):$e=e[62];let _e;e[63]!==m?(_e=r.jsxs(yt,{children:[Te,r.jsx(Mt,{id:"device-name",value:m,onChange:$e,placeholder:"Defaults to the device's own name"})]}),e[63]=m,e[64]=_e):_e=e[64];let Ce;e[65]!==_||e[66]!==L||e[67]!==x?(Ce=L&&r.jsxs(yt,{"data-invalid":(_==null?void 0:_.field)==="username",children:[r.jsx(wt,{htmlFor:"device-username",children:"Username"}),r.jsx(Mt,{id:"device-username",value:x,onChange:Ae=>v(Ae.target.value),placeholder:"Team account username",autoComplete:"username",spellCheck:!1}),r.jsx(Co,{children:"Requests through this hub will act as this account on the team server."}),(_==null?void 0:_.field)==="username"&&r.jsx(vs,{children:_.message})]}),e[65]=_,e[66]=L,e[67]=x,e[68]=Ce):Ce=e[68];let ke;e[69]!==U||e[70]!==y||e[71]!==_||e[72]!==L?(ke=U&&r.jsxs(yt,{"data-invalid":(_==null?void 0:_.field)==="password",children:[r.jsx(wt,{htmlFor:"device-password",children:"Password"}),r.jsx(Mt,{id:"device-password",type:"password",value:y,onChange:Ae=>b(Ae.target.value),placeholder:L?"Password for that team account":"Network access password for that device",autoComplete:L?"current-password":"off"}),(_==null?void 0:_.field)==="password"&&r.jsx(vs,{children:_.message})]}),e[69]=U,e[70]=y,e[71]=_,e[72]=L,e[73]=ke):ke=e[73];let Me;e[74]!==ve||e[75]!==_e||e[76]!==Ce||e[77]!==ke?(Me=r.jsxs(Do,{children:[ve,_e,Ce,ke]}),e[74]=ve,e[75]=_e,e[76]=Ce,e[77]=ke,e[78]=Me):Me=e[78];let Oe;e[79]===Symbol.for("react.memo_cache_sentinel")?(Oe=Ae=>{$.current=$.current+1,S(Ae===!0),E(null),A(null)},e[79]=Oe):Oe=e[79];let Le;e[80]!==j?(Le=r.jsx(dx,{id:"device-local-tunnel",name:"device-local-tunnel",checked:j,onCheckedChange:Oe}),e[80]=j,e[81]=Le):Le=e[81];const De=L?"":" — no password";let Ie;e[82]!==De?(Ie=r.jsxs(wt,{htmlFor:"device-local-tunnel",children:["This is a local tunnel",De]}),e[82]=De,e[83]=Ie):Ie=e[83];let he;e[84]!==Le||e[85]!==Ie?(he=r.jsxs(yt,{orientation:"horizontal",children:[Le,Ie]}),e[84]=Le,e[85]=Ie,e[86]=he):he=e[86];let ge;e[87]!==j||e[88]!==L?(ge=j&&r.jsxs(ut,{className:"border-warning/40 bg-warning/10 text-warning",children:[r.jsx(pw,{}),r.jsx(ft,{className:"text-warning",children:L?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[87]=j,e[88]=L,e[89]=ge):ge=e[89];let Se;e[90]!==o?(Se=r.jsx(ee,{variant:"outline",onClick:o,children:"Close"}),e[90]=o,e[91]=Se):Se=e[91];const be=!V;let Fe;e[92]!==Y?(Fe=()=>void Y(),e[92]=Y,e[93]=Fe):Fe=e[93];let He;e[94]!==T?(He=T?r.jsxs(r.Fragment,{children:[r.jsx(et,{"data-icon":"inline-start",className:"size-4 animate-spin"})," Adding…"]}):"Add device",e[94]=T,e[95]=He):He=e[95];let We;e[96]!==be||e[97]!==Fe||e[98]!==He?(We=r.jsx(ee,{disabled:be,onClick:Fe,children:He}),e[96]=be,e[97]=Fe,e[98]=He,e[99]=We):We=e[99];let Ee;e[100]!==Se||e[101]!==We?(Ee=r.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[Se,We]}),e[100]=Se,e[101]=We,e[102]=Ee):Ee=e[102];let ze;e[103]!==Me||e[104]!==he||e[105]!==ge||e[106]!==Ee?(ze=r.jsxs("div",{className:"flex flex-col gap-4 border-t pt-4",children:[ie,Me,he,ge,Ee]}),e[103]=Me,e[104]=he,e[105]=ge,e[106]=Ee,e[107]=ze):ze=e[107];let fe;e[108]!==re||e[109]!==ze?(fe=r.jsxs(as,{className:"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-xl",children:[oe,re,ze]}),e[108]=re,e[109]=ze,e[110]=fe):fe=e[110];let we;return e[111]!==t||e[112]!==ne||e[113]!==fe?(we=r.jsx(is,{open:t,onOpenChange:ne,children:fe}),e[111]=t,e[112]=ne,e[113]=fe,e[114]=we):we=e[114],we}const sP=/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/;function _h(n,e){if(!sP.test(e))throw new Error(`Invalid Cogpit ${n} id "${e}"`)}function uo(n,e){return`${n}.${e}`}function oP(n){const e=new Set,t=new Set,s=[];for(const o of n){if(_h("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??[]){_h("panel",i.id);const a=uo(o.id,i.id);if(t.has(a))throw new Error(`Duplicate Cogpit workspace panel id "${a}"`);t.add(a),s.push({...i,id:a,pluginId:o.id,localId:i.id})}}return s.sort((o,i)=>(o.order??100)-(i.order??100)||o.title.localeCompare(i.title))}const Ui=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});function fl(n,e){const t=Date.parse(n);if(!Number.isFinite(t))return"Unknown time";const s=Math.round((t-e)/1e3);if(Math.abs(s)<60)return Ui.format(s,"second");const o=Math.round(s/60);if(Math.abs(o)<60)return Ui.format(o,"minute");const i=Math.round(o/60);return Math.abs(i)<24?Ui.format(i,"hour"):Ui.format(Math.round(i/24),"day")}function Xu(n,e,t){const s=n?Date.parse(n):Number.NaN;if(!Number.isFinite(s))return null;const o=e?Date.parse(e):t,i=Math.max(0,Math.round((o-s)/1e3));if(i<60)return`${i}s`;const a=Math.floor(i/60);return a<60?`${a}m ${i%60}s`:`${Math.floor(a/60)}h ${a%60}m`}function ml(n){const e=B.c(3),[t,s]=w.useState(rP);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]),w.useEffect(o,i),t}function rP(){return Date.now()}function zr(n){const e=B.c(3),{label:t,children:s}=n;let o;return e[0]!==s||e[1]!==t?(o=r.jsx("div",{className:"no-scrollbar flex shrink-0 items-center gap-1 overflow-x-auto border-b px-3 py-1.5",role:"group","aria-label":t,children:s}),e[0]=s,e[1]=t,e[2]=o):o=e[2],o}function pl(n){const e=B.c(10),{icon:t,title:s,description:o}=n;let i;e[0]!==t?(i=r.jsx(en,{variant:"icon",children:r.jsx(t,{})}),e[0]=t,e[1]=i):i=e[1];let a;e[2]!==s?(a=r.jsx(Gt,{children:s}),e[2]=s,e[3]=a):a=e[3];let l;e[4]!==o?(l=r.jsx(tn,{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(Kt,{className:"border-0",children:r.jsxs(Vt,{children:[i,a,l]})}),e[6]=i,e[7]=a,e[8]=l,e[9]=c):c=e[9],c}function Ju(n){const e=B.c(16),{count:t,children:s}=n,[o,i]=w.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(Ye,{className:l}),e[2]=l,e[3]=c):c=e[3];let d;e[4]!==t?(d=r.jsx("span",{className:"font-mono text-[10px] tabular-nums opacity-70",children:t}),e[4]=t,e[5]=d):d=e[5];let u;e[6]!==o||e[7]!==c||e[8]!==d?(u=r.jsxs(Rt,{className:"flex h-7 w-full items-center gap-1.5 rounded-sm px-1 text-left text-xs text-muted-foreground outline-none hover:bg-accent/60 hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/20","aria-expanded":o,children:[c,"Closed",d]}),e[6]=o,e[7]=c,e[8]=d,e[9]=u):u=e[9];let f;e[10]!==s?(f=r.jsx(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 ub(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(hw,{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 iP=700,aP=12;function Qu(n){const e=B.c(15),{body:t}=n,[s,o]=w.useState(!1);let i;e[0]!==t?(i=t.length>iP||t.split(`
117
+ `).length>aP,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(Ou,{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(lP),"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 lP(n){return!n}function bt(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 vt(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 it(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 fo="cogpit",St={worktrees:uo(fo,"worktrees"),projectFiles:uo(fo,"project-files"),browser:uo(fo,"browser"),fileChanges:uo(fo,"file-changes"),sessionInfo:uo(fo,"session-info")},cP=w.lazy(()=>Ve(()=>import("./CommandPaletteHost-iiTEkWGR.js"),__vite__mapDeps([25,1,2,3,4])).then(n=>({default:n.CommandPaletteHost}))),dP=w.lazy(()=>Ve(()=>import("./index-j1RyyaFQ.js"),__vite__mapDeps([26,1,2,3,4])).then(n=>({default:n.ConfigDialog}))),uP=w.lazy(()=>Ve(()=>import("./KeyboardShortcutsDialog-C7QHuM2e.js"),__vite__mapDeps([27,1,2,3,4])).then(n=>({default:n.KeyboardShortcutsDialog}))),fP=w.lazy(()=>Ve(()=>import("./ProjectSwitcherModal-BhevYH6F.js"),__vite__mapDeps([28,1,2,3,4])).then(n=>({default:n.ProjectSwitcherModal}))),mP=w.lazy(()=>Ve(()=>import("./ThemeSelectorModal-GimQk0yY.js"),__vite__mapDeps([29,1,2,3,4])).then(n=>({default:n.ThemeSelectorModal})));function pP(n){const e=B.c(116),{navigation:t,project:s,chrome:o}=n,{state:i,config:a,theme:l}=qt(),{session:c,sessionSource:d}=ot(),{devices:u,activeDeviceId:f}=ul(),[m,p]=w.useState(null);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=st("manageDevices"),e[0]=h):h=e[0];const g=h;let x;e[1]!==i.pendingCwd||e[2]!==i.pendingDirName?(x=i.pendingCwd??(i.pendingDirName?kn(i.pendingDirName):null),e[1]=i.pendingCwd,e[2]=i.pendingDirName,e[3]=x):x=e[3];const v=x,y=(d==null?void 0:d.dirName)??i.pendingDirName??i.dashboardProject??null,b=o.onKeyboardShortcutsOpenChange;let j,S;e[4]!==b?(j=()=>{const We=function(ze){jt("keyboardShortcuts",ze)&&(sb(document.activeElement)||(ze.preventDefault(),b(!0)))};return window.addEventListener("keydown",We),()=>window.removeEventListener("keydown",We)},S=[b],e[4]=b,e[5]=j,e[6]=S):(j=e[5],S=e[6]),w.useEffect(j,S);const k=f===Tt;let C;e[7]!==k?(C={id:Tt,name:"This machine",isLocal:!0,isActive:k},e[7]=k,e[8]=C):C=e[8];let N;if(e[9]!==f||e[10]!==u||e[11]!==C){let We;e[13]!==f?(We=Ee=>({id:Ee.id,name:Ee.name,isLocal:!1,isActive:Ee.id===f}),e[13]=f,e[14]=We):We=e[14],N=[C,...u.map(We)],e[9]=f,e[10]=u,e[11]=C,e[12]=N}else N=e[12];const E=N;let T;e[15]!==c||e[16]!==(d==null?void 0:d.agentKind)||e[17]!==(d==null?void 0:d.dirName)?(T=()=>{if(!c)return;const We=(d==null?void 0:d.agentKind)??It((d==null?void 0:d.dirName)??null);$a(cg(We,c.sessionId,c.cwd))},e[15]=c,e[16]=d==null?void 0:d.agentKind,e[17]=d==null?void 0:d.dirName,e[18]=T):T=e[18];const P=T,_=hP,A=o.processPanel,I=o.workflowsPanel,$=o.undoDialog,R=o.branchModal,M=a.claudeDir??"";let O;e[19]!==a.handleCloseConfigDialog||e[20]!==a.handleConfigSaved||e[21]!==a.showConfigDialog||e[22]!==M?(O=r.jsx(w.Suspense,{fallback:null,children:r.jsx(dP,{open:a.showConfigDialog,currentPath:M,onClose:a.handleCloseConfigDialog,onSaved:a.handleConfigSaved})}),e[19]=a.handleCloseConfigDialog,e[20]=a.handleConfigSaved,e[21]=a.showConfigDialog,e[22]=M,e[23]=O):O=e[23];const D=(d==null?void 0:d.dirName)??i.pendingDirName??null,z=(c==null?void 0:c.cwd)??i.pendingCwd??null;let F;e[24]!==a.defaultAgentKind||e[25]!==t.onStartNewFolder||e[26]!==t.onStartNewSession||e[27]!==t.panels.handleCloseProjectSwitcher||e[28]!==t.panels.showProjectSwitcher||e[29]!==D||e[30]!==z?(F=r.jsx(w.Suspense,{fallback:null,children:r.jsx(fP,{open:t.panels.showProjectSwitcher,onClose:t.panels.handleCloseProjectSwitcher,onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:a.defaultAgentKind,currentProjectDirName:D,currentProjectCwd:z})}),e[24]=a.defaultAgentKind,e[25]=t.onStartNewFolder,e[26]=t.onStartNewSession,e[27]=t.panels.handleCloseProjectSwitcher,e[28]=t.panels.showProjectSwitcher,e[29]=D,e[30]=z,e[31]=F):F=e[31];let L;e[32]!==t.panels.handleCloseThemeSelector||e[33]!==t.panels.showThemeSelector||e[34]!==l.setPreview||e[35]!==l.setTheme||e[36]!==l.theme?(L=r.jsx(w.Suspense,{fallback:null,children:r.jsx(mP,{open:t.panels.showThemeSelector,onClose:t.panels.handleCloseThemeSelector,currentTheme:l.theme,onSelectTheme:l.setTheme,onPreviewTheme:l.setPreview})}),e[32]=t.panels.handleCloseThemeSelector,e[33]=t.panels.showThemeSelector,e[34]=l.setPreview,e[35]=l.setTheme,e[36]=l.theme,e[37]=L):L=e[37];const H=o.commandPaletteOpen,U=o.onCommandPaletteOpenChange,W=t.actions.handleGoHome,V=t.panels.handleOpenProjectSwitcher,K=t.onOpenPaletteProject,Y=t.actions.handleDashboardSelect,X=t.panels.handleToggleSidebar;let G,J,Z;e[38]!==t.panels?(G=()=>t.panels.toggleWorkspacePanel(St.sessionInfo),J=()=>t.panels.toggleWorkspacePanel(St.fileChanges),Z=()=>t.panels.toggleWorkspacePanel(St.worktrees),e[38]=t.panels,e[39]=G,e[40]=J,e[41]=Z):(G=e[39],J=e[40],Z=e[41]);const Q=t.panels.handleToggleMission,te=c?t.handlers.handleDuplicateSession:void 0,ne=c?P:void 0,oe=c?_:void 0,re=st("killAny")?o.onKillAll:void 0,ie=st("configWrite")?t.panels.handleToggleConfig:void 0,se=a.openConfigDialog;let ce;e[42]!==b?(ce=()=>b(!0),e[42]=b,e[43]=ce):ce=e[43];const ae=s.currentCwd?s.onTogglePreview:void 0,ue=st("hostFiles")&&s.currentCwd?s.onToggleProjectFiles:void 0;let me;e[44]!==t.panels?(me=st("hostFiles")?()=>t.panels.toggleWorkspacePanel(St.browser):void 0,e[44]=t.panels,e[45]=me):me=e[45];const de=t.panels.handleToggleThemeSelector,le=s.onOpenTerminal,xe=o.onFocusComposer,pe=o.onExpandAll,ve=o.onExpandToolPayloads,Te=o.onCollapseAll,$e=!!(c||i.pendingDirName);let _e;e[46]!==v||e[47]!==(c==null?void 0:c.cwd)||e[48]!==(d==null?void 0:d.dirName)||e[49]!==i.dashboardProject||e[50]!==i.pendingDirName?(_e=st("terminal")&&!!((c==null?void 0:c.cwd)??v??(d==null?void 0:d.dirName)??i.pendingDirName??i.dashboardProject),e[46]=v,e[47]=c==null?void 0:c.cwd,e[48]=d==null?void 0:d.dirName,e[49]=i.dashboardProject,e[50]=i.pendingDirName,e[51]=_e):_e=e[51];const Ce=!!c;let ke;e[52]!==s.hasFileChanges?(ke=st("hostFiles")&&s.hasFileChanges,e[52]=s.hasFileChanges,e[53]=ke):ke=e[53];const Me=t.panels.activeWorkspacePanel===St.sessionInfo,Oe=t.panels.activeWorkspacePanel===St.browser,Le=t.panels.activeWorkspacePanel===St.fileChanges,De=t.panels.activeWorkspacePanel===St.worktrees,Ie=i.mainView==="config",he=i.mainView==="mission",ge=(c==null?void 0:c.cwd)??v??null;let Se;e[54]!==o.commandPaletteOpen||e[55]!==o.onCollapseAll||e[56]!==o.onCommandPaletteOpenChange||e[57]!==o.onExpandAll||e[58]!==o.onExpandToolPayloads||e[59]!==o.onFocusComposer||e[60]!==a.openConfigDialog||e[61]!==y||e[62]!==t.actions.handleDashboardSelect||e[63]!==t.actions.handleGoHome||e[64]!==t.onOpenPaletteProject||e[65]!==t.panels.handleOpenProjectSwitcher||e[66]!==t.panels.handleToggleMission||e[67]!==t.panels.handleToggleSidebar||e[68]!==t.panels.handleToggleThemeSelector||e[69]!==t.panels.showSidebar||e[70]!==E||e[71]!==s.launchTerminalRequest||e[72]!==s.onOpenTerminal||e[73]!==s.processPanel.addProcess||e[74]!==s.showProjectFiles||e[75]!==s.supportsWorktrees||e[76]!==G||e[77]!==J||e[78]!==Z||e[79]!==te||e[80]!==ne||e[81]!==oe||e[82]!==re||e[83]!==ie||e[84]!==ce||e[85]!==ae||e[86]!==ue||e[87]!==me||e[88]!==$e||e[89]!==_e||e[90]!==Ce||e[91]!==ke||e[92]!==Me||e[93]!==Oe||e[94]!==Le||e[95]!==De||e[96]!==Ie||e[97]!==he||e[98]!==ge?(Se=r.jsx(w.Suspense,{fallback:null,children:r.jsx(cP,{open:H,onOpenChange:U,onGoHome:W,onNewSession:V,onOpenProject:K,onOpenSession:Y,onToggleSidebar:X,onToggleStats:G,onToggleFileChanges:J,onToggleWorktrees:Z,onToggleMissionControl:Q,onDuplicateSession:te,onCopyResumeCommand:ne,onFindInConversation:oe,onKillAll:re,onOpenConfig:ie,onOpenSettings:se,onOpenKeyboardShortcuts:ce,onTogglePreview:ae,onToggleProjectFiles:ue,onToggleBrowser:me,onOpenTheme:de,onOpenTerminal:le,onOpenDevices:g?p:void 0,onSwitchDevice:ks,devices:E,onFocusComposer:xe,onExpandAll:pe,onExpandToolPayloads:ve,onCollapseAll:Te,canFocusComposer:$e,canOpenTerminal:_e,hasSession:Ce,hasFileChanges:ke,supportsWorktrees:s.supportsWorktrees,showSidebar:t.panels.showSidebar,showStats:Me,showProjectFiles:s.showProjectFiles,showBrowser:Oe,showFileChanges:Le,showWorktrees:De,showConfig:Ie,showMission:he,currentProjectDirName:y,projectCwd:ge,onProcessStarted:s.processPanel.addProcess,launchTerminalRequest:s.launchTerminalRequest})}),e[54]=o.commandPaletteOpen,e[55]=o.onCollapseAll,e[56]=o.onCommandPaletteOpenChange,e[57]=o.onExpandAll,e[58]=o.onExpandToolPayloads,e[59]=o.onFocusComposer,e[60]=a.openConfigDialog,e[61]=y,e[62]=t.actions.handleDashboardSelect,e[63]=t.actions.handleGoHome,e[64]=t.onOpenPaletteProject,e[65]=t.panels.handleOpenProjectSwitcher,e[66]=t.panels.handleToggleMission,e[67]=t.panels.handleToggleSidebar,e[68]=t.panels.handleToggleThemeSelector,e[69]=t.panels.showSidebar,e[70]=E,e[71]=s.launchTerminalRequest,e[72]=s.onOpenTerminal,e[73]=s.processPanel.addProcess,e[74]=s.showProjectFiles,e[75]=s.supportsWorktrees,e[76]=G,e[77]=J,e[78]=Z,e[79]=te,e[80]=ne,e[81]=oe,e[82]=re,e[83]=ie,e[84]=ce,e[85]=ae,e[86]=ue,e[87]=me,e[88]=$e,e[89]=_e,e[90]=Ce,e[91]=ke,e[92]=Me,e[93]=Oe,e[94]=Le,e[95]=De,e[96]=Ie,e[97]=he,e[98]=ge,e[99]=Se):Se=e[99];let be;e[100]!==o.keyboardShortcutsOpen||e[101]!==b?(be=r.jsx(w.Suspense,{fallback:null,children:r.jsx(uP,{open:o.keyboardShortcutsOpen,onOpenChange:b})}),e[100]=o.keyboardShortcutsOpen,e[101]=b,e[102]=be):be=e[102];let Fe;e[103]!==m?(Fe=g&&r.jsx(db,{open:m!==null,initialMode:m??"manage",onClose:()=>p(null)}),e[103]=m,e[104]=Fe):Fe=e[104];let He;return e[105]!==o.branchModal||e[106]!==o.processPanel||e[107]!==o.undoDialog||e[108]!==o.workflowsPanel||e[109]!==O||e[110]!==F||e[111]!==L||e[112]!==Se||e[113]!==be||e[114]!==Fe?(He=r.jsxs(r.Fragment,{children:[A,I,$,R,O,F,L,Se,be,Fe]}),e[105]=o.branchModal,e[106]=o.processPanel,e[107]=o.undoDialog,e[108]=o.workflowsPanel,e[109]=O,e[110]=F,e[111]=L,e[112]=Se,e[113]=be,e[114]=Fe,e[115]=He):He=e[115],He}function hP(){window.dispatchEvent(new Event(sd))}function sc(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(Ct,{render:o,children:s}),e[2]=s,e[3]=o,e[4]=i):i=e[4];let a;e[5]!==t?(a=r.jsx(_t,{children:t}),e[5]=t,e[6]=a):a=e[6];let l;return e[7]!==i||e[8]!==a?(l=r.jsxs(kt,{children:[i,a]}),e[7]=i,e[8]=a,e[9]=l):l=e[9],l}const Th=lb.version,gP={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"},Eh={ok:"Reachable",unknown:"Not reachable","bad-password":"Password rejected"};function xP(n){const e=B.c(6),{state:t}=n,s=Eh[t],o=Eh[t],i=gP[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 Zu(n){const e=B.c(50),{compact:t}=n,s=t===void 0?!1:t,{devices:o,activeDeviceId:i,activeDevice:a,refresh:l,testDevice:c}=ul(),[d,u]=w.useState(null),f=(a==null?void 0:a.name)??"This machine",m=i!==Tt;let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=st("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(L=>c(L.id).catch(vP))).then(()=>l())},e[1]=o,e[2]=l,e[3]=c,e[4]=g):g=e[4];const x=g;if(!s&&o.length===0&&!m)return null;const v=s?"sm":"xs",y=s&&"h-10";let b;e[5]!==y?(b=q("max-w-40 justify-start",y),e[5]=y,e[6]=b):b=e[6];let j;e[7]!==v||e[8]!==b?(j=r.jsx(ee,{variant:"ghost",size:v,"aria-label":"Switch device",className:b}),e[7]=v,e[8]=b,e[9]=j):j=e[9];let S;e[10]!==m?(S=m?r.jsx(H1,{"data-icon":"inline-start"}):r.jsx(Sm,{"data-icon":"inline-start"}),e[10]=m,e[11]=S):S=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(mt,{"data-icon":"inline-end",className:"opacity-60"}),e[14]=C):C=e[14];let N;e[15]!==j||e[16]!==S||e[17]!==k?(N=r.jsxs(Bo,{render:j,children:[S,k,C]}),e[15]=j,e[16]=S,e[17]=k,e[18]=N):N=e[18];let E;e[19]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsx(qg,{children:"Devices"}),e[19]=E):E=e[19];let T,P;e[20]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx(Sm,{}),P=r.jsx("span",{className:"flex-1 truncate",children:"This machine"}),e[20]=T,e[21]=P):(T=e[20],P=e[21]);let _;e[22]!==m?(_=!m&&r.jsx(at,{className:"ml-auto text-success"}),e[22]=m,e[23]=_):_=e[23];let A;e[24]!==_?(A=r.jsxs(Bt,{onClick:bP,children:[T,P,_]}),e[24]=_,e[25]=A):A=e[25];let I;if(e[26]!==i||e[27]!==s||e[28]!==o){let F;e[30]!==i||e[31]!==s?(F=L=>{const H=ab(L),U=H!==void 0&&H!==Th,W=L.id===i;return r.jsxs(Bt,{onClick:()=>ks(L.id),className:q(s&&"min-h-10"),children:[r.jsx(xP,{state:L.runtime.authState}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[r.jsx("span",{className:"truncate",children:L.name}),U&&r.jsxs("span",{className:"shrink-0 font-mono text-xs text-warning",title:`Device runs v${H}; hub runs v${Th}`,children:["v",H]})]}),r.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:[L.host,":",L.port,L.auth==="none"&&" · unauthenticated"]})]}),W&&r.jsx(at,{className:"ml-auto text-success"})]},L.id)},e[30]=i,e[31]=s,e[32]=F):F=e[32],I=o.map(F),e[26]=i,e[27]=s,e[28]=o,e[29]=I}else I=e[29];let $;e[33]!==A||e[34]!==I?($=r.jsxs(es,{children:[E,A,I]}),e[33]=A,e[34]=I,e[35]=$):$=e[35];let R;e[36]!==o.length?(R=h&&r.jsxs(r.Fragment,{children:[r.jsx(ca,{}),r.jsxs(es,{children:[r.jsxs(Bt,{onClick:()=>u("add"),children:[r.jsx(Bn,{}),r.jsx("span",{children:"Add device…"})]}),o.length>0&&r.jsxs(Bt,{onClick:()=>u("manage"),children:[r.jsx(kd,{}),r.jsx("span",{children:"Manage devices…"})]})]})]}),e[36]=o.length,e[37]=R):R=e[37];let M;e[38]!==$||e[39]!==R?(M=r.jsxs(Uo,{align:"end",sideOffset:6,className:"w-64",children:[$,R]}),e[38]=$,e[39]=R,e[40]=M):M=e[40];let O;e[41]!==x||e[42]!==N||e[43]!==M?(O=r.jsxs(Fo,{onOpenChange:x,children:[N,M]}),e[41]=x,e[42]=N,e[43]=M,e[44]=O):O=e[44];let D;e[45]!==d?(D=h&&r.jsx(db,{open:d!==null,initialMode:d??"manage",onClose:()=>u(null)}),e[45]=d,e[46]=D):D=e[46];let z;return e[47]!==O||e[48]!==D?(z=r.jsxs(r.Fragment,{children:[O,D]}),e[47]=O,e[48]=D,e[49]=z):z=e[49],z}function bP(){return ks(Tt)}function vP(){return null}const yP=6e4;function wP(){const[n,e]=w.useState([]),[t,s]=w.useState(!1),o=w.useRef(!1),i=w.useCallback(async()=>{if(!o.current){o.current=!0;try{const l=await Ne("/api/system-processes");if(l.ok){const c=await l.json();e((c.processes??[]).filter(d=>d.suspectedLeak))}}catch{}finally{o.current=!1}}},[]),a=w.useCallback(async l=>{if(l.length!==0){s(!0);try{await Ne("/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 w.useEffect(()=>{i();const l=window.setInterval(()=>{document.visibilityState==="visible"&&i()},yP);return()=>window.clearInterval(l)},[i]),{leaks:n,killing:t,killLeaks:a,refresh:i}}const jP=6e4;function SP(){const n=B.c(29),{leaks:e,killing:t,killLeaks:s,refresh:o}=wP(),[i,a]=w.useState(!1),l=e.length>0,c=e.reduce(CP,0);let d,u;if(n[0]!==l?(d=()=>{if(l){a(!0);return}const _=window.setTimeout(()=>a(!1),jP);return()=>window.clearTimeout(_)},u=[l],n[0]=l,n[1]=d,n[2]=u):(d=n[1],u=n[2]),w.useEffect(d,u),!l&&!i)return null;const f=kt,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(kP)):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 v;n[10]!==t||n[11]!==m||n[12]!==p||n[13]!==h||n[14]!==x?(v=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]=v):v=n[15];let y;n[16]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(gw,{"data-icon":"inline-start"}),n[16]=y):y=n[16];const b=t?"…":e.length;let j;n[17]!==b?(j=r.jsx("span",{className:"tabular-nums",children:b}),n[17]=b,n[18]=j):j=n[18];let S;n[19]!==j||n[20]!==v?(S=r.jsxs(Ct,{render:v,children:[y,j]}),n[19]=j,n[20]=v,n[21]=S):S=n[21];const k=_t,C="bottom",N="p-3",E=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(NP),e.length>6&&r.jsxs("div",{className:"text-xs text-muted-foreground",children:["+",e.length-6," more"]}),r.jsx(Nt,{}),r.jsxs("div",{className:"text-xs text-muted-foreground",children:["Click to kill ",e.length===1?"it":"all of them"]})]}):r.jsxs("div",{className:"flex min-w-48 flex-col gap-1",children:[r.jsx("div",{className:"text-xs font-medium",children:"Leak monitor"}),r.jsx("div",{className:"text-xs text-muted-foreground",children:"No leaked agent processes. Click to scan again."})]});let T;n[22]!==k||n[23]!==E?(T=r.jsx(k,{side:C,className:N,children:E}),n[22]=k,n[23]=E,n[24]=T):T=n[24];let P;return n[25]!==f||n[26]!==S||n[27]!==T?(P=r.jsxs(f,{children:[S,T]}),n[25]=f,n[26]=S,n[27]=T,n[28]=P):P=n[28],P}function NP(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," · ",qd(n.ageSeconds)]}),r.jsxs("span",{className:"shrink-0 font-semibold text-destructive",children:[n.cpuPercent.toFixed(0),"%"]})]},n.pid)}function kP(n){return n.pid}function CP(n,e){return n+e.cpuPercent}const _P=15e3;function TP(){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]=w.useState(e);let o;n[1]===Symbol.for("react.memo_cache_sentinel")?(o=async()=>{try{const v=await Ne("/api/notifications?limit=100");if(!v.ok)return;const y=await v.json();Array.isArray(y.notifications)&&s(y.notifications)}catch{}},n[1]=o):o=n[1];const i=o;let a,l;n[2]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{i();const v=window.setInterval(()=>void i(),_P);return()=>window.clearInterval(v)},l=[i],n[2]=a,n[3]=l):(a=n[2],l=n[3]),w.useEffect(a,l);let c;n[4]===Symbol.for("react.memo_cache_sentinel")?(c=async(v,y)=>{const b=new Date().toISOString();s(j=>j.map(S=>S.readAt===null&&y(S)?{...S,readAt:b}:S));try{await Ne("/api/notifications/read",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(v)})}catch{}},n[4]=c):c=n[4];const d=c;let u;n[5]===Symbol.for("react.memo_cache_sentinel")?(u=async v=>d({ids:v},y=>v.includes(y.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},AP),n[6]=m):m=n[6];const p=m;let h;n[7]!==t?(h=t.filter(EP),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 EP(n){return n.readAt===null}function AP(){return!0}function fb(n){window.history.pushState({},"",n),window.dispatchEvent(new PopStateEvent("popstate"))}function PP(){const n=B.c(30),{notifications:e,unreadCount:t,refresh:s,markRead:o,markAllRead:i}=TP(),[a,l]=w.useState(!1);let c;n[0]!==o?(c=function(N){if(o([N.id]),!N.dirName||!N.sessionId)return;const E=xt(),T=E===Tt?"":`/d/${E}`;fb(`${T}/${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(Nm,{"data-icon":"inline-start"}),n[7]=h):h=n[7];let g;n[8]!==t?(g=t>0&&r.jsx(Pe,{className:"absolute -right-1 -top-1 h-4 min-w-4 px-1 tabular-nums",children:t>99?"99+":t}),n[8]=t,n[9]=g):g=n[9];let x;n[10]!==p||n[11]!==g?(x=r.jsxs(Bo,{render:p,children:[h,g]}),n[10]=p,n[11]=g,n[12]=x):x=n[12];let v;n[13]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx("span",{className:"text-sm font-medium",children:"Notifications"}),n[13]=v):v=n[13];let y;n[14]!==i||n[15]!==t?(y=t>0&&r.jsxs(ee,{variant:"ghost",size:"xs",onClick:()=>void i(),children:[r.jsx(xw,{"data-icon":"inline-start"}),"Mark all read"]}),n[14]=i,n[15]=t,n[16]=y):y=n[16];let b;n[17]!==y?(b=r.jsxs("div",{className:"flex h-11 items-center justify-between border-b px-3",children:[v,y]}),n[17]=y,n[18]=b):b=n[18];let j;n[19]!==e||n[20]!==d?(j=r.jsx("div",{className:"max-h-96 overflow-y-auto",children:e.length===0?r.jsx(Kt,{className:"min-h-40 p-6",children:r.jsxs(Vt,{children:[r.jsx(en,{variant:"icon",children:r.jsx(Nm,{})}),r.jsx(Gt,{children:"No notifications"}),r.jsx(tn,{children:"Session updates will appear here."})]})}):r.jsx(es,{children:e.map(C=>r.jsx(IP,{notification:C,onOpen:d},C.id))})}),n[19]=e,n[20]=d,n[21]=j):j=n[21];let S;n[22]!==b||n[23]!==j?(S=r.jsxs(Uo,{align:"end",sideOffset:6,className:"w-80 overflow-hidden p-0",children:[b,j]}),n[22]=b,n[23]=j,n[24]=S):S=n[24];let k;return n[25]!==a||n[26]!==u||n[27]!==S||n[28]!==x?(k=r.jsxs(Fo,{open:a,onOpenChange:u,children:[x,S]}),n[25]=a,n[26]=u,n[27]=S,n[28]=x,n[29]=k):k=n[29],k}function IP(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"?Xt:Lo;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 v=o?"font-medium text-foreground":"text-muted-foreground";let y;e[13]!==v?(y=q("truncate text-xs",v),e[13]=v,e[14]=y):y=e[14];let b;e[15]!==t.title||e[16]!==y?(b=r.jsx("span",{className:y,children:t.title}),e[15]=t.title,e[16]=y,e[17]=b):b=e[17];let j;e[18]!==c?(j=qd(c),e[18]=c,e[19]=j):j=e[19];let S;e[20]!==j?(S=r.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:j}),e[20]=j,e[21]=S):S=e[21];let k;e[22]!==b||e[23]!==S?(k=r.jsxs("span",{className:"flex items-baseline justify-between gap-2",children:[b,S]}),e[22]=b,e[23]=S,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;e[30]!==o?(E=o&&r.jsx("span",{className:"mt-1.5 size-1.5 shrink-0 rounded-full bg-primary"}),e[30]=o,e[31]=E):E=e[31];let T;return e[32]!==N||e[33]!==E||e[34]!==u||e[35]!==p||e[36]!==x?(T=r.jsxs(Bt,{onClick:u,className:p,children:[x,N,E]}),e[32]=N,e[33]=E,e[34]=u,e[35]=p,e[36]=x,e[37]=T):T=e[37],T}const RP=2e3;function Po(n){return`${n.toFixed(n<10?1:0)}%`}function wa(n){return`${n.toFixed(0)} MB`}function $P(n){return n>=10?`${n.toFixed(0)}/s`:n>=1?`${n.toFixed(1)}/s`:`${n.toFixed(2)}/s`}function MP(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 LP(n){const e=B.c(44),{metric:t,onKill:s}=n;let o;e[0]!==t.label?(o=r.jsx("span",{className:"truncate text-sm font-medium",children:t.label}),e[0]=t.label,e[1]=o):o=e[1];let i;e[2]!==t.pid?(i=r.jsxs(Pe,{variant:"outline",children:["PID ",t.pid]}),e[2]=t.pid,e[3]=i):i=e[3];let a;e[4]!==t.suspectedLeak?(a=t.suspectedLeak&&r.jsx(Pe,{variant:"destructive",children:"possible leak"}),e[4]=t.suspectedLeak,e[5]=a):a=e[5];let l;e[6]!==t.orphaned||e[7]!==t.suspectedLeak?(l=t.orphaned&&!t.suspectedLeak&&r.jsx(Pe,{variant:"secondary",children:"orphaned"}),e[6]=t.orphaned,e[7]=t.suspectedLeak,e[8]=l):l=e[8];let c;e[9]!==o||e[10]!==i||e[11]!==a||e[12]!==l?(c=r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o,i,a,l]}),e[9]=o,e[10]=i,e[11]=a,e[12]=l,e[13]=c):c=e[13];let d;e[14]!==t.command?(d=r.jsx("p",{className:"mt-1 truncate font-mono text-xs text-muted-foreground",title:t.command,children:t.command}),e[14]=t.command,e[15]=d):d=e[15];let u;e[16]!==c||e[17]!==d?(u=r.jsxs("div",{className:"min-w-0 flex-1",children:[c,d]}),e[16]=c,e[17]=d,e[18]=u):u=e[18];let f;e[19]!==t.pid||e[20]!==t.suspectedLeak||e[21]!==s?(f=t.suspectedLeak&&s&&r.jsx(ee,{variant:"destructive",size:"xs",className:"shrink-0",onClick:()=>s(t.pid),children:"Kill"}),e[19]=t.pid,e[20]=t.suspectedLeak,e[21]=s,e[22]=f):f=e[22];const m=t.cpuPercent>=20&&"text-destructive";let p;e[23]!==m?(p=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=Po(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=wa(t.memoryMb),e[30]=t.memoryMb,e[31]=x):x=e[31];let v;e[32]!==t.ageSeconds?(v=qd(t.ageSeconds),e[32]=t.ageSeconds,e[33]=v):v=e[33];let y;e[34]!==x||e[35]!==v?(y=r.jsxs("div",{className:"text-xs text-muted-foreground",children:[x," · ",v]}),e[34]=x,e[35]=v,e[36]=y):y=e[36];let b;e[37]!==g||e[38]!==y?(b=r.jsxs("div",{className:"shrink-0 text-right",children:[g,y]}),e[37]=g,e[38]=y,e[39]=b):b=e[39];let j;return e[40]!==b||e[41]!==u||e[42]!==f?(j=r.jsxs("div",{className:"flex items-start gap-3 py-2.5",children:[u,f,b]}),e[40]=b,e[41]=u,e[42]=f,e[43]=j):j=e[43],j}function OP(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 DP(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 mb(n){const e=B.c(34),{metric:t}=n;let s;e[0]!==t.name?(s=r.jsx("span",{className:"truncate text-sm font-medium",children:t.name}),e[0]=t.name,e[1]=s):s=e[1];let o;e[2]!==t.pid?(o=t.pid>0&&r.jsxs(Pe,{variant:"outline",children:["PID ",t.pid]}),e[2]=t.pid,e[3]=o):o=e[3];let i;e[4]!==s||e[5]!==o?(i=r.jsxs("div",{className:"flex items-center gap-2",children:[s,o]}),e[4]=s,e[5]=o,e[6]=i):i=e[6];let a;e[7]!==t?(a=OP(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=Po(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=wa(t.memoryMb),e[21]=t.memoryMb,e[22]=p):p=e[22];let h;e[23]!==p?(h=r.jsx("div",{className:"text-xs text-muted-foreground",children:p}),e[23]=p,e[24]=h):h=e[24];let g;e[25]!==t.idleWakeupsPerSecond?(g=t.idleWakeupsPerSecond!==void 0&&t.idleWakeupsPerSecond>0&&r.jsxs("div",{className:"text-xs text-muted-foreground",children:[t.idleWakeupsPerSecond.toFixed(0)," wakeups/s"]}),e[25]=t.idleWakeupsPerSecond,e[26]=g):g=e[26];let x;e[27]!==m||e[28]!==h||e[29]!==g?(x=r.jsxs("div",{className:"shrink-0 text-right",children:[m,h,g]}),e[27]=m,e[28]=h,e[29]=g,e[30]=x):x=e[30];let v;return e[31]!==x||e[32]!==c?(v=r.jsxs("div",{className:"flex items-start gap-3 py-2.5",children:[c,x]}),e[31]=x,e[32]=c,e[33]=v):v=e[33],v}function Ah(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(zP)}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 zP(n,e){const t=MP(n.bytesPerSecond);return r.jsxs("div",{children:[e>0&&r.jsx(Nt,{}),r.jsxs("div",{className:"flex items-center gap-3 py-2.5",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"truncate text-sm",children:n.name}),r.jsxs("div",{className:"mt-0.5 flex flex-wrap gap-x-2 text-xs text-muted-foreground",children:[r.jsx("span",{children:$P(n.ratePerSecond)}),t&&r.jsx("span",{children:t}),n.averageDurationMs!==void 0&&r.jsxs("span",{children:[n.averageDurationMs.toFixed(0)," ms avg"]})]})]}),n.active!==void 0&&n.active>0&&r.jsxs(Pe,{variant:"secondary",children:[n.active," open"]})]})]},n.name)}function FP(n){const e=B.c(8),{values:t}=n,s=Math.max(100,...t);let o;e[0]!==t?(o=t.map(BP).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:Po(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 BP(n){return Po(n)}function UP(n){var me,de,le,xe;const e=B.c(135),{open:t,onOpenChange:s}=n,[o,i]=w.useState(null),[a,l]=w.useState(null);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[0]=c):c=e[0];const[d,u]=w.useState(c),[f,m]=w.useState(null),[p,h]=w.useState(!1),g=w.useRef(!1),[x,v]=ss();let y;e[1]===Symbol.for("react.memo_cache_sentinel")?(y=async()=>{var ke;if(g.current)return;g.current=!0,h(!0);const pe=Ne("/api/performance").then(GP),ve=((ke=window.electronPerformance)==null?void 0:ke.getSnapshot())??Promise.resolve(null),[Te,$e]=await Promise.allSettled([pe,ve]),_e=Te.status==="fulfilled"?Te.value:null,Ce=$e.status==="fulfilled"?$e.value:null;if(_e&&l(_e),Ce&&i(Ce),!_e&&!Ce)m("Performance data is unavailable.");else{m(null);const Me=Ce&&Ce.processes.length>0?Ce.processes.reduce(VP,0):(_e==null?void 0:_e.cpuPercent)??0;u(Oe=>[...Oe.slice(-29),Me])}g.current=!1,h(!1)},e[1]=y):y=e[1];const b=y;let j,S;e[2]!==t?(j=()=>{if(!t)return;b();const pe=window.setInterval(()=>void b(),RP);return()=>window.clearInterval(pe)},S=[t,b],e[2]=t,e[3]=j,e[4]=S):(j=e[3],S=e[4]),w.useEffect(j,S);let k,C,N,E,T,P,_,A,I,$,R,M,O,D,z,F,L,H,U;if(e[5]!==x||e[6]!==v||e[7]!==o||e[8]!==f||e[9]!==d||e[10]!==s||e[11]!==t||e[12]!==p||e[13]!==a){const pe=[...(o==null?void 0:o.processes)??[]].sort(KP),ve=pe.length>0?pe.reduce(qP,0):(a==null?void 0:a.cpuPercent)??0,Te=pe[0];let $e;e[33]!==((me=a==null?void 0:a.system)==null?void 0:me.processes)?($e=((de=a==null?void 0:a.system)==null?void 0:de.processes)??[],e[33]=(le=a==null?void 0:a.system)==null?void 0:le.processes,e[34]=$e):$e=e[34],_=$e;const _e=((xe=a==null?void 0:a.system)==null?void 0:xe.suspectedLeakCount)??0,Ce=_e>0||ve>=80?"High":ve>=15?"Active":"Idle";let ke;e[35]===Symbol.for("react.memo_cache_sentinel")?(ke=async Ke=>{try{await Ne("/api/system-processes/kill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pids:[Ke]})}),await new Promise(HP)}catch{}b()},e[35]=ke):ke=e[35],P=ke;let Me;e[36]!==v||e[37]!==o||e[38]!==d||e[39]!==a?(Me=()=>{v(JSON.stringify({capturedAt:new Date().toISOString(),electron:o,server:a,cpuHistory:d},null,2))},e[36]=v,e[37]=o,e[38]=d,e[39]=a,e[40]=Me):Me=e[40];const Oe=Me;T=is,O=t,D=s,E=as,$="h-[min(780px,calc(100vh-2rem))] gap-0 p-0 sm:max-w-3xl";let Le;e[41]===Symbol.for("react.memo_cache_sentinel")?(Le=r.jsx(ls,{children:"Power & activity monitor"}),e[41]=Le):Le=e[41];const De=Ce==="High"?"destructive":"secondary";let Ie;e[42]!==Ce||e[43]!==De?(Ie=r.jsxs("div",{className:"flex items-center gap-2",children:[Le,r.jsx(Pe,{variant:De,children:Ce})]}),e[42]=Ce,e[43]=De,e[44]=Ie):Ie=e[44];let he;e[45]===Symbol.for("react.memo_cache_sentinel")?(he=r.jsx(cs,{className:"mt-1",children:"Live CPU, memory, and wakeups. Sampling runs only while this window is open."}),e[45]=he):he=e[45];let ge;e[46]!==Ie?(ge=r.jsxs("div",{className:"min-w-0 flex-1",children:[Ie,he]}),e[46]=Ie,e[47]=ge):ge=e[47];let Se;e[48]===Symbol.for("react.memo_cache_sentinel")?(Se=()=>void b(),e[48]=Se):Se=e[48];const be=p&&"animate-spin";let Fe;e[49]!==be?(Fe=q(be),e[49]=be,e[50]=Fe):Fe=e[50];let He;e[51]!==Fe?(He=r.jsx(Pt,{"data-icon":"inline-start",className:Fe}),e[51]=Fe,e[52]=He):He=e[52];let We;e[53]!==p||e[54]!==He?(We=r.jsxs(ee,{variant:"outline",size:"sm",onClick:Se,disabled:p,children:[He,"Refresh"]}),e[53]=p,e[54]=He,e[55]=We):We=e[55];const Ee=!a&&!o;let ze;e[56]!==x?(ze=x?r.jsx(at,{"data-icon":"inline-start"}):r.jsx(pn,{"data-icon":"inline-start"}),e[56]=x,e[57]=ze):ze=e[57];const fe=x?"Copied":"Copy data";let we;e[58]!==Oe||e[59]!==Ee||e[60]!==ze||e[61]!==fe?(we=r.jsxs(ee,{variant:"outline",size:"sm",onClick:Oe,disabled:Ee,children:[ze,fe]}),e[58]=Oe,e[59]=Ee,e[60]=ze,e[61]=fe,e[62]=we):we=e[62];let Ue;e[63]!==We||e[64]!==we?(Ue=r.jsxs("div",{className:"flex shrink-0 gap-1",children:[We,we]}),e[63]=We,e[64]=we,e[65]=Ue):Ue=e[65],e[66]!==ge||e[67]!==Ue?(R=r.jsx(Rs,{className:"p-5 pb-4",children:r.jsxs("div",{className:"flex items-start gap-3 pr-8",children:[ge,Ue]})}),e[66]=ge,e[67]=Ue,e[68]=R):R=e[68],e[69]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(Nt,{}),e[69]=M):M=e[69],N=Vn,I="min-h-0 min-w-0 flex-1",H="flex flex-col gap-4 p-5",e[70]!==f?(U=f&&r.jsx(ut,{variant:"destructive",children:r.jsx(ft,{children:f})}),e[70]=f,e[71]=U):U=e[71];let Be;e[72]===Symbol.for("react.memo_cache_sentinel")?(Be=r.jsx(bn,{children:"Current load"}),e[72]=Be):Be=e[72];const Ae=ve>=80&&"text-destructive";let qe;e[73]!==Ae?(qe=q("font-mono text-lg font-semibold tabular-nums",Ae),e[73]=Ae,e[74]=qe):qe=e[74];const ht=r.jsxs(xn,{children:[Be,r.jsx(vn,{children:DP(ve,Te,_e)}),r.jsx(qN,{children:r.jsxs("span",{className:qe,children:[Po(ve)," CPU"]})})]});let Je;e[75]!==d?(Je=r.jsx(cn,{children:r.jsx(FP,{values:d})}),e[75]=d,e[76]=Je):Je=e[76],e[77]!==ht||e[78]!==Je?(A=r.jsxs(ln,{size:"sm",children:[ht,Je]}),e[77]=ht,e[78]=Je,e[79]=A):A=e[79],C=ln,F="sm",e[80]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsxs(xn,{children:[r.jsx(bn,{children:"Processes"}),r.jsx(vn,{children:"Which part of Cogpit is consuming CPU and memory."})]}),e[80]=L):L=e[80],k=cn,z=pe.length>0?pe.map(WP):a?r.jsx(mb,{metric:{pid:0,name:"Server",type:"Node",cpuPercent:a.cpuPercent,memoryMb:a.memory.rssMb}}):r.jsx("p",{className:"py-3 text-sm text-muted-foreground",children:"Collecting process data…"}),e[5]=x,e[6]=v,e[7]=o,e[8]=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,e[18]=T,e[19]=P,e[20]=_,e[21]=A,e[22]=I,e[23]=$,e[24]=R,e[25]=M,e[26]=O,e[27]=D,e[28]=z,e[29]=F,e[30]=L,e[31]=H,e[32]=U}else k=e[14],C=e[15],N=e[16],E=e[17],T=e[18],P=e[19],_=e[20],A=e[21],I=e[22],$=e[23],R=e[24],M=e[25],O=e[26],D=e[27],z=e[28],F=e[29],L=e[30],H=e[31],U=e[32];let W;e[81]!==k||e[82]!==z?(W=r.jsx(k,{children:z}),e[81]=k,e[82]=z,e[83]=W):W=e[83];let V;e[84]!==C||e[85]!==W||e[86]!==F||e[87]!==L?(V=r.jsxs(C,{size:F,children:[L,W]}),e[84]=C,e[85]=W,e[86]=F,e[87]=L,e[88]=V):V=e[88];let K;e[89]!==P||e[90]!==_?(K=_.length>0&&r.jsxs(ln,{size:"sm",children:[r.jsxs(xn,{children:[r.jsx(bn,{children:"Agent processes"}),r.jsx(vn,{children:"Claude sessions, browsers, and scripts running outside Cogpit."})]}),r.jsx(cn,{children:_.map((pe,ve)=>r.jsxs("div",{children:[ve>0&&r.jsx(Nt,{}),r.jsx(LP,{metric:pe,onKill:Te=>void P(Te)})]},pe.pid))})]}),e[89]=P,e[90]=_,e[91]=K):K=e[91];let Y;e[92]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx(bn,{children:"Server activity"}),e[92]=Y):Y=e[92];const X=(a==null?void 0:a.sampleWindowSeconds)??10;let G;e[93]!==X?(G=r.jsxs(xn,{children:[Y,r.jsxs(vn,{children:["File checks, streams, and agent work over the last ",X," seconds."]})]}),e[93]=X,e[94]=G):G=e[94];let J;e[95]!==(a==null?void 0:a.activities)?(J=(a==null?void 0:a.activities)??[],e[95]=a==null?void 0:a.activities,e[96]=J):J=e[96];let Z;e[97]!==J?(Z=r.jsx(cn,{children:r.jsx(Ah,{metrics:J,emptyLabel:"No watched-file or stream activity in this sample."})}),e[97]=J,e[98]=Z):Z=e[98];let Q;e[99]!==G||e[100]!==Z?(Q=r.jsxs(ln,{size:"sm",children:[G,Z]}),e[99]=G,e[100]=Z,e[101]=Q):Q=e[101];let te;e[102]===Symbol.for("react.memo_cache_sentinel")?(te=r.jsxs(xn,{children:[r.jsx(bn,{children:"API activity"}),r.jsx(vn,{children:"Requests ranked by recent frequency and time."})]}),e[102]=te):te=e[102];let ne;e[103]!==(a==null?void 0:a.requests)?(ne=(a==null?void 0:a.requests)??[],e[103]=a==null?void 0:a.requests,e[104]=ne):ne=e[104];let oe;e[105]!==ne?(oe=r.jsxs(ln,{size:"sm",children:[te,r.jsx(cn,{children:r.jsx(Ah,{metrics:ne,emptyLabel:"No API requests in this sample."})})]}),e[105]=ne,e[106]=oe):oe=e[106];let re;e[107]!==Q||e[108]!==oe?(re=r.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[Q,oe]}),e[107]=Q,e[108]=oe,e[109]=re):re=e[109];let ie;e[110]!==a?(ie=a&&r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Server event loop ",Po(a.eventLoopPercent)," · heap ",wa(a.memory.heapUsedMb)," · RSS ",wa(a.memory.rssMb)]}),e[110]=a,e[111]=ie):ie=e[111];let se;e[112]!==A||e[113]!==V||e[114]!==K||e[115]!==re||e[116]!==ie||e[117]!==H||e[118]!==U?(se=r.jsxs("div",{className:H,children:[U,A,V,K,re,ie]}),e[112]=A,e[113]=V,e[114]=K,e[115]=re,e[116]=ie,e[117]=H,e[118]=U,e[119]=se):se=e[119];let ce;e[120]!==N||e[121]!==I||e[122]!==se?(ce=r.jsx(N,{className:I,children:se}),e[120]=N,e[121]=I,e[122]=se,e[123]=ce):ce=e[123];let ae;e[124]!==E||e[125]!==$||e[126]!==R||e[127]!==M||e[128]!==ce?(ae=r.jsxs(E,{className:$,children:[R,M,ce]}),e[124]=E,e[125]=$,e[126]=R,e[127]=M,e[128]=ce,e[129]=ae):ae=e[129];let ue;return e[130]!==T||e[131]!==O||e[132]!==D||e[133]!==ae?(ue=r.jsx(T,{open:O,onOpenChange:D,children:ae}),e[130]=T,e[131]=O,e[132]=D,e[133]=ae,e[134]=ue):ue=e[134],ue}function WP(n,e){return r.jsxs("div",{children:[e>0&&r.jsx(Nt,{}),r.jsx(mb,{metric:n})]},n.pid)}function HP(n){return setTimeout(n,1e3)}function qP(n,e){return n+e.cpuPercent}function KP(n,e){return e.cpuPercent-n.cpuPercent}function VP(n,e){return n+e.cpuPercent}async function GP(n){if(!n.ok)throw new Error(`Server monitor returned ${n.status}`);return n.json()}function YP(n){return`${n.title??`Pull request #${n.number}`}
118
+ ${n.repo}${n.isDraft?" · draft":""}`}function pb(n){return{href:n.url,target:"_blank",rel:"noreferrer",onClick:e=>e.stopPropagation(),"aria-label":`Pull request #${n.number}`,title:YP(n)}}function di(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(JP),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(XP).join(`
119
+ `),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?$d:Hr;return r.jsxs(Pe,{variant:p.isDraft?"outline":"secondary",render:r.jsx("a",{...pb(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 XP(n){return`#${n.number} ${n.title??n.repo}`}function JP(n){const e=n.isDraft?$d:Hr;return r.jsxs("a",{...pb(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 QP=w.memo(function(e){const t=B.c(37),{session:s,sessionSource:o,isLive:i,pullRequests:a,copied:l,creatingSession:c,onCopyResume:d,onNewSession:u,onDuplicateSession:f,onOpenTerminal:m}=e;let p;if(t[0]!==o){const P=o?Cs(o.fileName):null;p=P?zu(P.agentId):null,t[0]=o,t[1]=p}else p=t[1];const h=p;let g;t[2]!==s.turns?(g=s.turns.some(tI),t[2]=s.turns,t[3]=g):g=t[3];const x=g;let v;t[4]!==s.rawMessages||t[5]!==(o==null?void 0:o.dirName)?(v=ko(o==null?void 0:o.dirName).contextWindow?s.rawMessages:[],t[4]=s.rawMessages,t[5]=o==null?void 0:o.dirName,t[6]=v):v=t[6];const y=v;let b;t[7]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx("div",{className:q(Mn,"flex h-8 min-w-0 items-center gap-2 pl-1 pr-3")}),t[7]=b):b=t[7];let j;t[8]!==l||t[9]!==c||t[10]!==d||t[11]!==f||t[12]!==u||t[13]!==m||t[14]!==s||t[15]!==o?(j=o?r.jsx(eI,{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]=j):j=t[16];let S;t[17]!==i?(S=i&&r.jsx(Ua,{"aria-label":"Session is live"}),t[17]=i,t[18]=S):S=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:Ys(s.model)}),t[19]=s.model,t[20]=k):k=t[20];let C;t[21]!==y?(C=r.jsx(Kg,{rawMessages:y}),t[21]=y,t[22]=C):C=t[22];let N;t[23]!==j||t[24]!==S||t[25]!==k||t[26]!==C?(N=r.jsxs(Ct,{delay:200,render:b,children:[j,S,k,C]}),t[23]=j,t[24]=S,t[25]=k,t[26]=C,t[27]=N):N=t[27];let E;t[28]!==a||t[29]!==y||t[30]!==s||t[31]!==h||t[32]!==x?(E=r.jsx(_t,{role:"tooltip",side:"bottom",align:"start",sideOffset:6,className:"p-3",children:r.jsx(ZP,{session:s,thinkingEnabled:x,subAgentLabel:h,pullRequests:a,rawMessages:y})}),t[28]=a,t[29]=y,t[30]=s,t[31]=h,t[32]=x,t[33]=E):E=t[33];let T;return t[34]!==E||t[35]!==N?(T=r.jsxs(kt,{children:[N,E]}),t[34]=E,t[35]=N,t[36]=T):T=t[36],T});function oo(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 ZP(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=_g(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(oo,{label:"Model",children:[r.jsx("span",{children:Ys(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(oo,{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(oo,{label:"Pull requests",children:r.jsx(di,{pullRequests:i})}),e[19]=i,e[20]=u):u=e[20],e[21]!==o?(f=o&&r.jsx(oo,{label:"Agent",children:o}),e[21]=o,e[22]=f):f=e[22],e[23]!==x?(m=x&&r.jsxs(oo,{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(oo,{label:"Context",children:[lt(Math.max(0,g.compactAt-g.used))," left before compact ·"," ",lt(g.used)," / ",lt(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 eI(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}=qt(),f=!!(t.cwd||s.dirName);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=Ws(),e[0]=m):m=e[0];const p=m;let h;e[1]!==t.sessionId||e[2]!==t.slug?(h=t.slug||t.sessionId.slice(0,8),e[1]=t.sessionId,e[2]=t.slug,e[3]=h):h=e[3];const g=h;let x;e[4]!==t.cwd||e[5]!==g?(x=t.cwd?`${ns(t.cwd)} / ${g}`:g,e[4]=t.cwd,e[5]=g,e[6]=x):x=e[6];const v=x;let y;e[7]!==t.cwd||e[8]!==s.dirName?(y={path:t.cwd,dirName:s.dirName},e[7]=t.cwd,e[8]=s.dirName,e[9]=y):y=e[9];const b=y;let j;e[10]===Symbol.for("react.memo_cache_sentinel")?(j=!p||fu(),e[10]=j):j=e[10];const S=j;let k;e[11]!==u||e[12]!==s.dirName?(k=function(){w.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 ${v}; open session actions with the context menu`;let E;e[14]!==a||e[15]!==N?(E=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):E=e[16];let T;e[17]!==o||e[18]!==t.cwd||e[19]!==g?(T=o?r.jsxs("span",{className:"flex items-center gap-1.5 text-success",children:[r.jsx(at,{className:"size-3"})," Copied"]}):r.jsxs(r.Fragment,{children:[t.cwd&&r.jsx("span",{className:"truncate text-muted-foreground",children:ns(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]=T):T=e[20];let P;e[21]!==E||e[22]!==T?(P=r.jsx(al,{render:E,children:T}),e[21]=E,e[22]=T,e[23]=P):P=e[23];let _;e[24]!==l||e[25]!==t.cwd||e[26]!==s.dirName?(_=()=>l(s.dirName,t.cwd),e[24]=l,e[25]=t.cwd,e[26]=s.dirName,e[27]=_):_=e[27];let A;e[28]!==i?(A=i?r.jsx(nt,{className:"size-3.5"}):r.jsx(Bn,{className:"size-3.5"}),e[28]=i,e[29]=A):A=e[29];let I;e[30]!==i||e[31]!==_||e[32]!==A?(I=r.jsxs(Wt,{disabled:i,onClick:_,children:[A,"New session in this project"]}),e[30]=i,e[31]=_,e[32]=A,e[33]=I):I=e[33];let $;e[34]!==c?($=c&&r.jsxs(Wt,{onClick:c,children:[r.jsx(pn,{className:"size-3.5"}),"Duplicate this session"]}),e[34]=c,e[35]=$):$=e[35];let R;e[36]!==f||e[37]!==b?(R=f&&(S||!p)&&r.jsxs(r.Fragment,{children:[r.jsx(Ao,{}),S&&r.jsxs(Wt,{onClick:()=>xx(b),children:[r.jsx(Pd,{className:"size-3.5"}),"Open project in editor"]}),!p&&r.jsxs(Wt,{onClick:()=>bx(b),children:[r.jsx(Y1,{className:"size-3.5"}),"Reveal in file manager"]})]}),e[36]=f,e[37]=b,e[38]=R):R=e[38];let M;e[39]!==d?(M=d&&!p&&st("terminal")&&r.jsxs(Wt,{onClick:d,children:[r.jsx(Vs,{className:"size-3.5"}),"Open terminal in project"]}),e[39]=d,e[40]=M):M=e[40];let O;e[41]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsx(Ao,{}),e[41]=O):O=e[41];let D;e[42]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(So,{className:"size-3.5"}),e[42]=D):D=e[42];let z;e[43]!==C?(z=r.jsxs(Wt,{onClick:C,children:[D,"View all sessions in this project"]}),e[43]=C,e[44]=z):z=e[44];let F;e[45]!==I||e[46]!==$||e[47]!==R||e[48]!==M||e[49]!==z?(F=r.jsxs(ll,{className:"min-w-56",children:[I,$,R,M,O,z]}),e[45]=I,e[46]=$,e[47]=R,e[48]=M,e[49]=z,e[50]=F):F=e[50];let L;return e[51]!==P||e[52]!==F?(L=r.jsxs(il,{children:[P,F]}),e[51]=P,e[52]=F,e[53]=L):L=e[53],L}function tI(n){return n.thinking.length>0}const nr="Could not reach the server";async function Wi(n,e){try{return await Ne(n,e)}catch{return null}}function nI(){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]=w.useState(e),[o,i]=w.useState(null),a=w.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]),w.useEffect(l,c);let d;n[3]===Symbol.for("react.memo_cache_sentinel")?(d=async()=>{const k=await Wi("/api/shares");if(!(k!=null&&k.ok))return;const C=await k.json().catch(iI);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]),w.useEffect(f,m);let p;n[6]===Symbol.for("react.memo_cache_sentinel")?(p=async k=>{i(null);const C=await Wi("/api/shares",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:k})});if(!(C!=null&&C.ok))return a.current&&i(await tc(C,nr)),null;const N=await C.json().catch(rI);if(!(N!=null&&N.passphrase)||!N.share)return a.current&&i(nr),null;const E=N.share;return a.current&&s(T=>[...T.filter(P=>P.sessionId!==E.sessionId),E]),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 Wi(`/api/shares/${encodeURIComponent(k)}/regenerate`,{method:"POST"});if(!(C!=null&&C.ok))return a.current&&i(await tc(C,nr)),null;const N=await C.json().catch(oI);return N!=null&&N.passphrase?(u(),N.passphrase):(a.current&&i(nr),null)},n[7]=g):g=n[7];const x=g;let v;n[8]===Symbol.for("react.memo_cache_sentinel")?(v=async k=>{i(null);const C=await Wi(`/api/shares/${encodeURIComponent(k)}`,{method:"DELETE"});if(!(C!=null&&C.ok)){a.current&&i(await tc(C,nr));return}a.current&&s(N=>N.filter(E=>E.sessionId!==k))},n[8]=v):v=n[8];const y=v;let b;n[9]!==t?(b=async()=>{const k=t.map(sI);for(const C of k)await y(C)},n[9]=t,n[10]=b):b=n[10];const j=b;let S;return n[11]!==o||n[12]!==j||n[13]!==t?(S={shares:t,error:o,refresh:u,create:h,regenerate:x,revoke:y,revokeAll:j},n[11]=o,n[12]=j,n[13]=t,n[14]=S):S=n[14],S}function sI(n){return n.sessionId}function oI(){return null}function rI(){return null}function iI(){return null}const aI=5e3,lI="••••";function cI(n){return n===0?"No guests connected":n===1?"1 guest connected":`${n} guests connected`}function dI({sessionId:n}){const{config:{networkAccessDisabled:e}}=qt(),{shares:t,error:s,refresh:o,create:i,regenerate:a,revoke:l}=nI(),[c,d]=w.useState(!1),[u,f]=w.useState(null),[m,p]=w.useState(!1),[h,g]=ss(),[x,v]=ss(),y=t.find(k=>k.sessionId===n)??null,b=`${window.location.origin}${WS(n)}`;w.useEffect(()=>f(null),[n]),w.useEffect(()=>{if(!c)return;o();const k=setInterval(()=>void o(),aI);return()=>clearInterval(k)},[c,o]);async function j(k){p(!0);try{await k()}finally{p(!1)}}const S=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(Fo,{open:c,onOpenChange:k=>{d(k),k||f(null)},children:[r.jsx(Bo,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm","aria-label":y?"Session is shared":"Share session",className:q(y&&"bg-primary/15 text-primary hover:bg-primary/25")}),children:r.jsx(bw,{"data-icon":"inline-start"})}),r.jsx(Uo,{align:"end",sideOffset:6,className:"w-80 p-3",children:y?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:b}),r.jsx(ee,{variant:"ghost",size:"icon-xs","aria-label":"Copy link",onClick:()=>g(b),children:h?r.jsx(at,{"data-icon":"inline-start"}):r.jsx(pn,{"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??lI}),r.jsx(ee,{variant:"ghost",size:"icon-xs","aria-label":"Regenerate passphrase",disabled:m,onClick:()=>j(async()=>{f(await a(n))}),children:r.jsx(Pt,{"data-icon":"inline-start"})})]}),u?r.jsx(ee,{variant:"secondary",size:"xs",onClick:()=>v(`${b}
120
+ 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."}),S,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:cI(y.guests)}),r.jsx(ee,{variant:"ghost",size:"xs",className:"text-destructive hover:text-destructive",disabled:m,onClick:()=>j(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."}),S,s&&r.jsx("p",{className:"text-xs text-destructive",children:s}),r.jsx(ee,{size:"xs",disabled:m,onClick:()=>j(async()=>{f(await i(n))}),children:"Enable sharing"})]})})]})}function ef(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 rt(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)?n:void 0}function _n(n){return typeof n=="number"&&Number.isFinite(n)?n:void 0}function ys(n){return typeof n=="string"?n:void 0}function bs(n){return n?ef(_n(n.utilization),ys(n.resets_at)):void 0}function hb(n){if(n)return{isEnabled:!!n.is_enabled,monthlyLimit:_n(n.monthly_limit),usedCredits:_n(n.used_credits),utilization:_n(n.utilization)}}function uI(n){return{fiveHour:bs(rt(n.five_hour)),sevenDay:bs(rt(n.seven_day)),sevenDayOpus:bs(rt(n.seven_day_opus)),sevenDaySonnet:bs(rt(n.seven_day_sonnet)),extraUsage:hb(rt(n.extra_usage)),subscriptionType:ys(n.subscriptionType)}}function fI(n){if(n.available!==!0)return null;const e=rt(n.usage),t=rt(e==null?void 0:e.rate_limits),s=rt(n.account),o={fiveHour:bs(rt(t==null?void 0:t.five_hour)),sevenDay:bs(rt(t==null?void 0:t.seven_day)),sevenDayOpus:bs(rt(t==null?void 0:t.seven_day_opus)),sevenDaySonnet:bs(rt(t==null?void 0:t.seven_day_sonnet)),extraUsage:hb(rt(t==null?void 0:t.extra_usage)),subscriptionType:ys(e==null?void 0:e.subscription_type)??ys(s==null?void 0:s.subscriptionType)};return o.fiveHour||o.sevenDay||o.extraUsage||o.subscriptionType?o:null}function mI(n){const e=_n(n);if(e!==void 0)return new Date(e<1e10?e*1e3:e).toISOString()}function pI(n,e){const t=_n(n);return t===void 0||t<=0?e:t%1440===0?`${t/1440}-day`:t%60===0?`${t/60}-hour`:`${t}-minute`}function Ph(n,e){if(n)return ef(_n(n.usedPercent),mI(n.resetsAt),pI(n.windowDurationMins,e))}function hI(n){var d,u,f;if(n.available!==!0)return null;const e=rt((d=rt(n.rateLimits))==null?void 0:d.rateLimits),t=rt((u=rt(n.account))==null?void 0:u.account),s=rt((f=rt(n.usage))==null?void 0:f.summary),o=rt(e==null?void 0:e.credits),i=Ph(rt(e==null?void 0:e.primary),"Primary"),a=Ph(rt(e==null?void 0:e.secondary),"Secondary"),l=s==null?void 0:s.lifetimeTokens,c=_n(l)??(typeof l=="string"&&Number.isSafeInteger(Number(l))?Number(l):void 0);return!i&&!a&&c===void 0?null:{fiveHour:i,sevenDay:a,subscriptionType:ys(e==null?void 0:e.planType)??ys(t==null?void 0:t.planType),lifetimeTokens:c,creditBalance:ys(o==null?void 0:o.balance),creditsUnlimited:(o==null?void 0:o.unlimited)===!0}}function Ih(n,e){if(!n)return;const t=_n(n.remainingPercentage),s=_n(n.usedRequests),o=_n(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),ef(i,ys(n.resetDate),e)}function gI(n){var s;if(n.available!==!0)return null;const e=rt((s=rt(n.quota))==null?void 0:s.quotaSnapshots),t=Ih(rt(e==null?void 0:e.chat),"Chat")??Ih(rt(e==null?void 0:e.premium_interactions),"Premium interactions");return t?{fiveHour:t}:null}const xI={claude:{endpoint:"/api/claude/runtime",read:fI,legacy:{endpoint:"/api/usage",read:uI}},codex:{endpoint:"/api/codex/runtime",read:hI},copilot:{endpoint:"/api/copilot/runtime",read:gI}};function bI(n){return xI[n]}const vI=300*1e3;function yI(n=Gs){const e=Tn("viewUsage"),[t,s]=w.useState(null),[o,i]=w.useState(!1),[a,l]=w.useState(!1),c=w.useRef(0),d=w.useRef(null),u=w.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=bI(n);let x=await Ne(g.endpoint,{signal:m.signal}),v=g.read;if(g.legacy&&!x.ok&&!m.signal.aborted&&(x=await Ne(g.legacy.endpoint,{signal:m.signal}),v=g.legacy.read),!p())return;if(x.status===501||x.status===404){l(!1);return}if(!x.ok){l(!0);return}const y=await x.json();if(!p())return;const b=v(y);l(b!==null),s(b?{...b,agentKind:n,fetchedAt:Date.now()}:null)}catch{}finally{p()&&(d.current=null,i(!1))}},[n,e]);return w.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,vI);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 gb(n){return n>=90?"danger":n>=80?"warning":n>=60?"caution":"nominal"}const xb={nominal:"text-muted-foreground",caution:"text-warning",warning:"text-warning",danger:"text-destructive"};function wI(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?Fa(t.agentKind):"Agent",e[10]=t.agentKind,e[11]=f):f=e[11];let m;e[12]!==f?(m=r.jsxs("span",{className:"text-xs font-medium uppercase tracking-wide",children:[f," usage"]}),e[12]=f,e[13]=m):m=e[13];let p;e[14]!==t.subscriptionType?(p=t.subscriptionType&&r.jsx(Pe,{variant:"secondary",children:t.subscriptionType}),e[14]=t.subscriptionType,e[15]=p):p=e[15],e[16]!==m||e[17]!==p?(o=r.jsxs("div",{className:"flex items-center justify-between",children:[m,p]}),e[16]=m,e[17]=p,e[18]=o):o=e[18],i=u.map(h=>{const g=h.resetsAt&&t.fetchedAt!=null?new Date(h.resetsAt).getTime()-t.fetchedAt:null,x=g!=null?Math.max(0,Math.round(g/36e5)):null,v=gb(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",xb[v]),children:[h.pct.toFixed(1),"%"]})]}),r.jsx(Jr,{value:Math.min(h.pct,100)}),x!=null&&r.jsxs("div",{className:"text-xs text-muted-foreground",children:["Resets in ",x,"h"]})]},h.label)}),e[0]=t.agentKind,e[1]=t.fetchedAt,e[2]=t.fiveHour,e[3]=t.sevenDay,e[4]=t.sevenDayOpus,e[5]=t.sevenDaySonnet,e[6]=t.subscriptionType,e[7]=s,e[8]=o,e[9]=i}else s=e[7],o=e[8],i=e[9];let a;e[19]!==t.extraUsage?(a=((d=t.extraUsage)==null?void 0:d.isEnabled)&&t.extraUsage.usedCredits!=null&&t.extraUsage.monthlyLimit!=null&&r.jsxs("div",{className:"flex flex-col gap-1 pt-1 text-xs text-muted-foreground",children:[r.jsx(Nt,{}),"Extra: $",t.extraUsage.usedCredits.toFixed(2)," / $",t.extraUsage.monthlyLimit.toFixed(2)]}),e[19]=t.extraUsage,e[20]=a):a=e[20];let l;e[21]!==t.creditBalance||e[22]!==t.creditsUnlimited||e[23]!==t.lifetimeTokens?(l=(t.lifetimeTokens!=null||t.creditBalance||t.creditsUnlimited)&&r.jsxs("div",{className:"flex flex-col gap-1 pt-1 text-xs text-muted-foreground",children:[r.jsx(Nt,{}),t.lifetimeTokens!=null&&r.jsxs("div",{children:["Lifetime: ",lt(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 jI(n){var j,S;const e=B.c(22),{agentKind:t}=n,s=t===void 0?Gs:t,{usage:o,loading:i,available:a,refresh:l}=yI(s);if(!a||!o)return null;const c=((j=o.fiveHour)==null?void 0:j.utilization)??((S=o.sevenDay)==null?void 0:S.utilization);if(c==null)return null;let d;e[0]!==o.agentKind?(d=o.agentKind?Fa(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=xb[gb(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 v;e[14]!==f||e[15]!==x?(v=r.jsx(Ct,{render:f,children:x}),e[14]=f,e[15]=x,e[16]=v):v=e[16];let y;e[17]!==o?(y=r.jsx(_t,{side:"bottom",className:"p-3",children:r.jsx(wI,{usage:o})}),e[17]=o,e[18]=y):y=e[18];let b;return e[19]!==v||e[20]!==y?(b=r.jsxs(kt,{children:[v,y]}),e[19]=v,e[20]=y,e[21]=b):b=e[21],b}function SI(n){const e=B.c(9);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={summary:null,loading:!1,error:null},e[0]=t):t=e[0];const[s,o]=w.useState(t),[i,a]=w.useState(0);let l;e[1]!==n?(l=()=>{const m=new AbortController;o(kI);const p=Intl.DateTimeFormat().resolvedOptions().timeZone;return Ne(`/api/usage-cost?days=${n}&tz=${encodeURIComponent(p)}`,{signal:m.signal}).then(async h=>{if(!h.ok)throw new Error(`Usage scan failed (${h.status})`);const g=await h.json();o({summary:g,loading:!1,error:null})}).catch(h=>{m.signal.aborted||o(g=>({...g,loading:!1,error:h instanceof Error?h.message:"Usage scan failed"}))}),()=>m.abort()},e[1]=n,e[2]=l):l=e[2];let c;e[3]!==n||e[4]!==i?(c=[n,i],e[3]=n,e[4]=i,e[5]=c):c=e[5],w.useEffect(l,c);let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=()=>a(NI),e[6]=d):d=e[6];const u=d;let f;return e[7]!==s?(f={...s,refresh:u},e[7]=s,e[8]=f):f=e[8],f}function NI(n){return n+1}function kI(n){return{...n,loading:!0,error:null}}function CI(n){const e=n.trim().toLowerCase().replace(/\[[^\]]*\]$/,""),t=e.lastIndexOf("/");return t===-1?e:e.slice(t+1)}const _I=new Set(["<synthetic>","synthetic","opus","sonnet","haiku","fable"]);function TI(n,e){const t=CI(e);return t.length===0||_I.has(t)?null:n.get(t)??null}function EI(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 AI(n){return n.uncachedInputUsd+n.cachedInputUsd+n.cacheCreationUsd+n.outputUsd}function PI(n,e,t,s=null){const o=TI(n,e);if(o===null)return null;const i=Math.min(t.cacheCreation1hTokens,t.cacheCreationTokens),a=t.cacheCreationTokens-i,l=EI(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 II(n,e,t,s,o=null){const i=PI(n,e,t,o);return i===null?{costUsd:0,costSource:"unpriced"}:{costUsd:AI(i),costSource:"modelPriced"}}function tf(n){return n.uncachedInputTokens+n.cachedInputTokens+n.cacheCreationTokens+n.outputTokens}function RI(n,e,t){if(!e)return 0;const{costUsd:s,costSource:o}=II(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 $I=[{days:7,label:"7 days"},{days:30,label:"30 days"},{days:90,label:"90 days"}],br=Ag.map(n=>({key:n,label:an(n).displayName,color:U4(n)}));function MI(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 Rh(){return{claude:{costUsd:0,tokens:0},codex:{costUsd:0,tokens:0},copilot:{costUsd:0,tokens:0}}}function LI(n){const e=new Map;for(const o of MI(n.sinceDay,n.untilDay))e.set(o,{day:o,byProvider:Rh(),costUsd:0,tokens:0});const t=new Map,s={costUsd:0,tokens:0,cacheSavingsUsd:0,byProvider:Rh(),days:[],models:[]};for(const o of n.buckets){const i=tf(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 $h(n){const e=Date.parse(`${n}T00:00:00Z`);return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",timeZone:"UTC"}).format(e)}const oc=720,rc=180,OI=18;function DI(n){const e=B.c(41),{days:t,metric:s}=n,[o,i]=w.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=rc-OI,f=oc/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:$h(p.day)}),br.map(C=>{const{key:N,label:E,color:T}=C,P=p.byProvider[N];return l(P)<=0?null:r.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-muted-foreground",children:[r.jsx("span",{"aria-hidden":!0,className:"size-1.5 rounded-full",style:{backgroundColor:T}}),E,": ",s==="cost"?dn(P.costUsd):lt(P.tokens)]},N)}),r.jsx("span",{className:"ml-2 font-medium",children:s==="cost"?dn(p.costUsd):lt(p.tokens)})]})}),e[8]=p,e[9]=s,e[10]=l,e[11]=h):h=e[11];const g=`Daily ${s==="cost"?"raw API cost":"processed tokens"} by provider`;let x,v;e[12]===Symbol.for("react.memo_cache_sentinel")?(x=()=>i(null),v=r.jsx("line",{x1:0,y1:u,x2:oc,y2:u,stroke:"var(--border)",strokeWidth:1}),e[12]=x,e[13]=v):(x=e[12],v=e[13]);let y;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,E)=>{const T=E*f+(f-m)/2;let P=u;const _=o===E;return r.jsxs("g",{onMouseEnter:()=>i(E),children:[r.jsx("rect",{x:E*f,y:0,width:f,height:u,fill:"transparent"}),_&&r.jsx("rect",{x:E*f,y:0,width:f,height:u,fill:"var(--foreground)",opacity:.05,rx:2}),br.map(A=>{const{key:I,color:$}=A,R=l(N.byProvider[I]);if(R<=0)return null;const M=R/d*(u-6);return P=P-M,r.jsx("rect",{x:T,y:P,width:m,height:Math.max(1,M-1.5),rx:1.5,fill:$,opacity:_?1:.85},I)})]},N.day)},e[21]=m,e[22]=o,e[23]=d,e[24]=f,e[25]=l,e[26]=C):C=e[26],y=t.map(C),e[14]=m,e[15]=t,e[16]=o,e[17]=d,e[18]=f,e[19]=l,e[20]=y}else y=e[20];let b;if(e[27]!==t||e[28]!==f){let C;e[30]!==t.length||e[31]!==f?(C=(N,E)=>E===0||E===t.length-1||t.length>10&&E%7===0&&E<t.length-3?r.jsx("text",{x:E*f+f/2,y:rc-4,textAnchor:"middle",className:"fill-muted-foreground text-[10px]",children:$h(N.day)},N.day):null,e[30]=t.length,e[31]=f,e[32]=C):C=e[32],b=t.map(C),e[27]=t,e[28]=f,e[29]=b}else b=e[29];let j;e[33]!==g||e[34]!==y||e[35]!==b?(j=r.jsxs("svg",{viewBox:`0 0 ${oc} ${rc}`,className:"w-full",role:"img","aria-label":g,onMouseLeave:x,children:[v,y,b]}),e[33]=g,e[34]=y,e[35]=b,e[36]=j):j=e[36];let S;e[37]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx("div",{className:"mt-1 flex items-center gap-4",children:br.map(zI)}),e[37]=S):S=e[37];let k;return e[38]!==h||e[39]!==j?(k=r.jsxs("div",{className:"relative",children:[h,j,S]}),e[38]=h,e[39]=j,e[40]=k):k=e[40],k}function zI(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 ic(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 FI(n){const e=B.c(68),{days:t}=n,{summary:s,loading:o,error:i,refresh:a}=SI(t),[l,c]=w.useState("cost");let d;e[0]!==s?(d=s?LI(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 L;return e[4]!==i||e[5]!==F?(L=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]=L):L=e[6],L}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(nt,{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"?dn(u.costUsd):lt(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 v;e[19]!==h||e[20]!==x?(v=r.jsxs("div",{className:"flex flex-col gap-0.5",children:[h,x]}),e[19]=h,e[20]=x,e[21]=v):v=e[21];let y;e[22]===Symbol.for("react.memo_cache_sentinel")?(y=["cost","tokens"],e[22]=y):y=e[22];let b;e[23]!==l?(b=r.jsx("div",{className:"flex rounded-md border p-0.5",children:y.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]=b):b=e[24];let j;e[25]!==u.byProvider||e[26]!==l?(j=br.map(F=>{const{key:L,label:H}=F,U=u.byProvider[L];return U.costUsd===0&&U.tokens===0?null:r.jsxs("span",{className:"text-xs text-muted-foreground tabular-nums",children:[H,": ",l==="cost"?dn(U.costUsd):lt(U.tokens)]},L)}),e[25]=u.byProvider,e[26]=l,e[27]=j):j=e[27];let S;e[28]!==b||e[29]!==j?(S=r.jsxs("div",{className:"flex flex-col items-end gap-1.5",children:[b,j]}),e[28]=b,e[29]=j,e[30]=S):S=e[30];let k;e[31]!==S||e[32]!==v?(k=r.jsxs("div",{className:"flex items-end justify-between gap-4",children:[v,S]}),e[31]=S,e[32]=v,e[33]=k):k=e[33];let C;e[34]!==u.days||e[35]!==l?(C=r.jsx(DI,{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=lt(u.tokens),e[37]=u.tokens,e[38]=N):N=e[38];let E;e[39]!==N?(E=r.jsx(ic,{label:"Processed tokens",value:N}),e[39]=N,e[40]=E):E=e[40];let T;e[41]!==u.cacheSavingsUsd?(T=dn(u.cacheSavingsUsd),e[41]=u.cacheSavingsUsd,e[42]=T):T=e[42];let P;e[43]!==T?(P=r.jsx(ic,{label:"Cache savings",value:T}),e[43]=T,e[44]=P):P=e[44];const _=String(s.scannedFiles);let A;e[45]!==_?(A=r.jsx(ic,{label:"Files scanned",value:_}),e[45]=_,e[46]=A):A=e[46];let I;e[47]!==E||e[48]!==P||e[49]!==A?(I=r.jsxs("div",{className:"grid grid-cols-3 gap-x-6 gap-y-3 border-t pt-3",children:[E,P,A]}),e[47]=E,e[48]=P,e[49]=A,e[50]=I):I=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 R;if(e[52]!==u.costUsd||e[53]!==u.models){let F;e[55]!==u.costUsd?(F=L=>{var H;return r.jsxs("tr",{className:"border-b border-border/50",children:[r.jsx("td",{className:"max-w-56 truncate py-1.5 text-foreground",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx("span",{"aria-hidden":!0,className:"size-2 shrink-0 rounded-full",style:{backgroundColor:(H=br.find(U=>U.key===L.provider))==null?void 0:H.color}}),L.model]})}),r.jsx("td",{className:"py-1.5 text-right text-foreground tabular-nums",children:L.unpriced?"—":dn(L.costUsd)}),r.jsx("td",{className:"py-1.5 text-right text-muted-foreground tabular-nums",children:u.costUsd>0&&!L.unpriced?`${(L.costUsd/u.costUsd*100).toFixed(1)}%`:"—"}),r.jsx("td",{className:"py-1.5 text-right text-muted-foreground tabular-nums",children:lt(L.tokens)})]},`${L.provider}:${L.model}`)},e[55]=u.costUsd,e[56]=F):F=e[56],R=u.models.map(F),e[52]=u.costUsd,e[53]=u.models,e[54]=R}else R=e[54];let M;e[57]!==R?(M=r.jsxs("table",{className:"w-full text-sm",children:[$,r.jsx("tbody",{children:R})]}),e[57]=R,e[58]=M):M=e[58];const O=s.pricing.status==="unavailable"?" (rate table unavailable — costs incomplete)":"";let D;e[59]!==O?(D=r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Raw API-equivalent prices from LiteLLM rates",O," ","— not what a subscription bills."]}),e[59]=O,e[60]=D):D=e[60];let z;return e[61]!==k||e[62]!==C||e[63]!==I||e[64]!==M||e[65]!==D||e[66]!==m?(z=r.jsxs("div",{className:m,children:[k,C,I,M,D]}),e[61]=k,e[62]=C,e[63]=I,e[64]=M,e[65]=D,e[66]=m,e[67]=z):z=e[67],z}function BI(n){const e=B.c(15),{open:t,onOpenChange:s}=n,[o,i]=w.useState(30);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsxs("div",{children:[r.jsx(ls,{children:"API usage"}),r.jsx(cs,{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=$I.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(Rs,{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(FI,{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(as,{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(is,{open:t,onOpenChange:s,children:u}),e[11]=s,e[12]=t,e[13]=u,e[14]=f):f=e[14],f}const UI=/https:\/\/github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/,WI=/(?:^|[\n;&|(`])[ \t]*(?:[A-Za-z_]\w*=\S*[ \t]+)*gh[ \t]+pr[ \t]+create\b/,ac=String.raw`(?:--title|(?:^|\s)-t)(?:=|\s+)`,HI=[new RegExp(`${ac}"((?:[^"\\\\]|\\\\.)*)"`),new RegExp(`${ac}'([^']*)'`),new RegExp(`${ac}(\\S+)`)];function qI(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 KI(n){return qI(n).find(e=>WI.test(e))??null}function VI(n){for(const e of HI){const t=e.exec(n);if(t)return t[1].replace(/\\(.)/g,"$1")}return null}function GI(){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=UI.exec(s);l&&t({url:l[0],number:Number(l[3]),repo:`${l[1]}/${l[2]}`,title:VI(o),isDraft:/(?:^|\s)--draft(?:\s|$)/.test(o),toolCallId:i,timestamp:a})}}}function YI(n){const e=GI();for(const t of n)for(const s of t.toolCalls){if(s.isError||!s.result)continue;const o=KI(s.input);o&&e.record(s.result,o,s.id,s.timestamp)}return e.pullRequests}function XI(...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 ro="flex h-8 items-center px-0.5",JI=w.memo(function(e){var ge;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,v=o===void 0?s:o,{config:y}=qt(),{networkUrl:b,defaultAgentKind:j}=y,{session:S,sessionSource:k,isLive:C}=ot(),N=Mu(),E=Tn("viewUsage"),[T,P]=w.useState(!1),[_,A]=w.useState(!1),[I,$]=ss(),R=S==null?void 0:S.turns;let M;t[0]!==(N==null?void 0:N.sessions)||t[1]!==(S==null?void 0:S.sessionId)?(M=(ge=N==null?void 0:N.sessions.find(Se=>Se.sessionId===(S==null?void 0:S.sessionId)))==null?void 0:ge.pullRequests,t[0]=N==null?void 0:N.sessions,t[1]=S==null?void 0:S.sessionId,t[2]=M):M=t[2];const O=M;let D;t[3]!==O||t[4]!==R?(D=XI(YI(R??[]),O),t[3]=O,t[4]=R,t[5]=D):D=t[5];const z=D;let F;t[6]!==j||t[7]!==k?(F=k?k.agentKind??It(k.dirName):j,t[6]=j,t[7]=k,t[8]=F):F=t[8];const L=F;let H;t[9]!==k?(H=k?Cs(k.fileName)!==null:!1,t[9]=k,t[10]=H):H=t[10];const U=H;let W;t[11]!==$||t[12]!==S||t[13]!==(k==null?void 0:k.agentKind)||t[14]!==(k==null?void 0:k.dirName)?(W=function(){if(!S)return;const be=(k==null?void 0:k.agentKind)??It((k==null?void 0:k.dirName)??null);$(cg(be,S.sessionId,S.cwd))},t[11]=$,t[12]=S,t[13]=k==null?void 0:k.agentKind,t[14]=k==null?void 0:k.dirName,t[15]=W):W=t[15];const V=W;let K;t[16]!==b?(K=function(){b&&$a(b).then(ZI)},t[16]=b,t[17]=K):K=t[17];const Y=K;let X,G;t[18]===Symbol.for("react.memo_cache_sentinel")?(G=r.jsx("div",{"aria-hidden":!0,className:"drag-strip absolute inset-x-0 top-0 z-10 h-10"}),X=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]=X,t[19]=G):(X=t[18],G=t[19]);const J=!v&&"window-inset-start";let Z;t[20]!==J?(Z=q("electron-no-drag pointer-events-auto flex min-w-0 items-center gap-1.5",J),t[20]=J,t[21]=Z):Z=t[21];let Q;t[22]!==h||t[23]!==s||t[24]!==i?(Q=!s&&r.jsx(QI,{icon:yw,label:`Show sidebar (${i})`,onClick:h}),t[22]=h,t[23]=s,t[24]=i,t[25]=Q):Q=t[25];let te;t[26]!==U||t[27]!==f||t[28]!==S?(te=S&&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(Ye,{className:"size-3 rotate-180"}),"Main"]}),t[26]=U,t[27]=f,t[28]=S,t[29]=te):te=t[29];let ne;t[30]!==I||t[31]!==l||t[32]!==V||t[33]!==C||t[34]!==d||t[35]!==c||t[36]!==u||t[37]!==z||t[38]!==S||t[39]!==k?(ne=S&&r.jsx(QP,{session:S,sessionSource:k,isLive:C,pullRequests:z,copied:I,creatingSession:l,onCopyResume:V,onNewSession:c,onDuplicateSession:d,onOpenTerminal:u}),t[30]=I,t[31]=l,t[32]=V,t[33]=C,t[34]=d,t[35]=c,t[36]=u,t[37]=z,t[38]=S,t[39]=k,t[40]=ne):ne=t[40];let oe;t[41]!==m||t[42]!==S||t[43]!==p?(oe=S&&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(Md,{className:"size-3"}),"Workflows",r.jsx(Pe,{variant:"outline",className:"h-4 min-w-4 justify-center px-1 text-[9px] font-semibold",children:p})]}),t[41]=m,t[42]=S,t[43]=p,t[44]=oe):oe=t[44];let re;t[45]!==Z||t[46]!==Q||t[47]!==te||t[48]!==ne||t[49]!==oe?(re=r.jsxs("div",{className:Z,children:[Q,te,ne,oe]}),t[45]=Z,t[46]=Q,t[47]=te,t[48]=ne,t[49]=oe,t[50]=re):re=t[50];let ie,se,ce;t[51]===Symbol.for("react.memo_cache_sentinel")?(ie=r.jsx("div",{className:q(Mn,ro,"empty:hidden"),children:r.jsx(SP,{})}),se=r.jsx("div",{className:q(Mn,ro,"empty:hidden"),children:r.jsx(PP,{})}),ce=q(Mn,ro,"empty:hidden"),t[51]=ie,t[52]=se,t[53]=ce):(ie=t[51],se=t[52],ce=t[53]);let ae;t[54]!==L?(ae=r.jsx("div",{className:ce,children:r.jsx(jI,{agentKind:L})}),t[54]=L,t[55]=ae):ae=t[55];let ue;t[56]===Symbol.for("react.memo_cache_sentinel")?(ue=r.jsx("div",{className:q(Mn,ro,"empty:hidden"),children:r.jsx(Zu,{})}),t[56]=ue):ue=t[56];let me;t[57]!==L||t[58]!==S?(me=S&&Ht(L).sharing&&st("share")&&r.jsx("div",{className:q(Mn,ro),children:r.jsx(dI,{sessionId:S.sessionId})}),t[57]=L,t[58]=S,t[59]=me):me=t[59];let de;t[60]===Symbol.for("react.memo_cache_sentinel")?(de=q(Mn,ro),t[60]=de):de=t[60];let le;t[61]===Symbol.for("react.memo_cache_sentinel")?(le=r.jsx(Bo,{render:r.jsx(ee,{variant:"ghost",size:"icon-sm","aria-label":"More actions"}),children:r.jsx(X1,{"data-icon":"inline-start"})}),t[61]=le):le=t[61];let xe;t[62]!==E?(xe=E&&r.jsxs(Bt,{onClick:()=>P(!0),children:[r.jsx(J1,{}),"Usage & cost…"]}),t[62]=E,t[63]=xe):xe=t[63];let pe;t[64]===Symbol.for("react.memo_cache_sentinel")?(pe=r.jsxs(Bt,{onClick:()=>A(!0),children:[r.jsx(kc,{}),"Server monitor…"]}),t[64]=pe):pe=t[64];let ve;t[65]!==Y||t[66]!==b?(ve=b&&r.jsxs(Bt,{onClick:Y,children:[r.jsx(wo,{className:"text-success"}),"Copy network URL",r.jsx("span",{className:"ml-auto truncate pl-2 font-mono text-[11px] text-muted-foreground",children:b})]}),t[65]=Y,t[66]=b,t[67]=ve):ve=t[67];let Te;t[68]!==xe||t[69]!==ve?(Te=r.jsxs(es,{children:[xe,pe,ve]}),t[68]=xe,t[69]=ve,t[70]=Te):Te=t[70];let $e;t[71]===Symbol.for("react.memo_cache_sentinel")?($e=r.jsx(ca,{}),t[71]=$e):$e=t[71];let _e;t[72]===Symbol.for("react.memo_cache_sentinel")?(_e=r.jsx(ww,{}),t[72]=_e):_e=t[72];let Ce;t[73]!==x?(Ce=r.jsx(es,{children:r.jsxs(Bt,{onClick:x,children:[_e,"Settings"]})}),t[73]=x,t[74]=Ce):Ce=t[74];let ke;t[75]!==a||t[76]!==g?(ke=st("killAny")&&r.jsxs(r.Fragment,{children:[r.jsx(ca,{}),r.jsx(es,{children:r.jsxs(Bt,{variant:"destructive",onClick:g,disabled:a,children:[r.jsx(vw,{}),a?"Stopping processes…":"Stop all agent processes"]})})]}),t[75]=a,t[76]=g,t[77]=ke):ke=t[77];let Me;t[78]!==Te||t[79]!==Ce||t[80]!==ke?(Me=r.jsx("div",{className:de,children:r.jsxs(Fo,{children:[le,r.jsxs(Uo,{align:"end",sideOffset:6,className:"w-64",children:[Te,$e,Ce,ke]})]})}),t[78]=Te,t[79]=Ce,t[80]=ke,t[81]=Me):Me=t[81];let Oe;t[82]!==ae||t[83]!==me||t[84]!==Me?(Oe=r.jsxs("div",{className:"electron-no-drag window-inset-end pointer-events-auto flex shrink-0 items-center gap-1.5",children:[ie,se,ae,ue,me,Me]}),t[82]=ae,t[83]=me,t[84]=Me,t[85]=Oe):Oe=t[85];let Le;t[86]!==re||t[87]!==Oe?(Le=r.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-30 flex items-start justify-between gap-3 px-3 pt-2",children:[re,Oe]}),t[86]=re,t[87]=Oe,t[88]=Le):Le=t[88];let De;t[89]!==E||t[90]!==T?(De=E&&r.jsx(BI,{open:T,onOpenChange:P}),t[89]=E,t[90]=T,t[91]=De):De=t[91];let Ie;t[92]!==_?(Ie=r.jsx(UP,{open:_,onOpenChange:A}),t[92]=_,t[93]=Ie):Ie=t[93];let he;return t[94]!==Le||t[95]!==De||t[96]!==Ie?(he=r.jsxs(r.Fragment,{children:[G,X,Le,De,Ie]}),t[94]=Le,t[95]=De,t[96]=Ie,t[97]=he):he=t[97],he});function QI(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(Ct,{render:a,children:l}),e[6]=a,e[7]=l,e[8]=c):c=e[8];let d;e[9]!==s?(d=r.jsx(_t,{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(kt,{children:[c,d]}),e[11]=c,e[12]=d,e[13]=u):u=e[13],u}function ZI(n){n&&On.success("Copied network URL")}const eR=w.memo(function(e){const t=B.c(13),{onToggleSidebar:s,onGoHome:o,onOpenCommandPalette:i,sidebarShortcut:a,commandPaletteShortcut:l}=e;let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx("div",{className:"flex-1"}),t[0]=c):c=t[0];let d;t[1]!==o?(d=r.jsx(Ml,{icon:js,label:"Home",onClick:o,size:"default"}),t[1]=o,t[2]=d):d=t[2];const u=`Search (${l})`;let f;t[3]!==i||t[4]!==u?(f=r.jsx(Ml,{icon:Yt,label:u,onClick:i,size:"default"}),t[3]=i,t[4]=u,t[5]=f):f=t[5];const m=`Hide sidebar (${a})`;let p;t[6]!==s||t[7]!==m?(p=r.jsx(Ml,{icon:jw,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 tR(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(kw,{"data-slot":"resizable-panel-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Mh(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(Nw,{"data-slot":"resizable-panel",...t}),e[2]=t,e[3]=s):s=e[3],s}function nR(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(Sw,{"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 bb=w.createContext(null);function sR(n){const e=B.c(3),{value:t,children:s}=n;let o;return e[0]!==s||e[1]!==t?(o=r.jsx(bb.Provider,{value:t,children:s}),e[0]=s,e[1]=t,e[2]=o):o=e[2],o}function nf(){const n=w.useContext(bb);if(!n)throw new Error("Built-in workspace panel services are unavailable");return n}function vb(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(Ct,{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(_t,{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(kt,{children:[f,m]}),e[15]=f,e[16]=m,e[17]=p):p=e[17],p}function yb(n,e){return n.filter(t=>{var s;return((s=t.when)==null?void 0:s.call(t,e))??!0})}function oR(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=yb(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(rR),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 v;e[15]!==o||e[16]!==s||e[17]!==i?(v=y=>{var k;const b=y.id===o,j=(k=y.badge)==null?void 0:k.call(y,s),S=y.indicator;return r.jsx(vb,{title:y.title,icon:y.icon,active:b,onClick:()=>i(y.id),children:S?r.jsx(S,{context:s,active:b}):j!=null&&r.jsx(Pe,{className:"absolute -right-1 -top-1 min-w-4 px-1 text-[9px]",variant:"secondary",children:j})},y.id)},e[15]=o,e[16]=s,e[17]=i,e[18]=v):v=e[18],p=x.map(v)}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 rR(n){return r.jsx(vb,{title:n.title,icon:n.icon,active:n.active,onClick:n.onSelect},n.id)}function iR(n){const e=B.c(18),{panels:t,context:s,activePanelId:o,onClosePanel:i}=n;let a;e[0]!==o?(a=()=>new Set([o]),e[0]=o,e[1]=a):a=e[1];const[l,c]=w.useState(a);let d,u;e[2]!==o?(d=()=>{c(p=>{if(p.has(o))return p;const h=new Set(p);return h.add(o),h})},u=[o],e[2]=o,e[3]=d,e[4]=u):(d=e[3],u=e[4]),w.useEffect(d,u);let f;if(e[5]!==o||e[6]!==s||e[7]!==i||e[8]!==t||e[9]!==l){let p;e[11]!==o||e[12]!==s||e[13]!==i||e[14]!==l?(p=h=>{const g=h.id===o;if(!g&&(!h.keepAlive||!l.has(h.id)))return null;const x=h.component;return r.jsx("div",{className:q("absolute inset-0 min-h-0",!g&&"hidden"),"aria-hidden":!g,children:r.jsx(x,{context:s,active:g,closePanel:i})},h.id)},e[11]=o,e[12]=s,e[13]=i,e[14]=l,e[15]=p):p=e[15],f=t.map(p),e[5]=o,e[6]=s,e[7]=i,e[8]=t,e[9]=l,e[10]=f}else f=e[10];let m;return e[16]!==f?(m=r.jsx("div",{className:"relative h-full min-h-0 overflow-hidden bg-background",children:f}),e[16]=f,e[17]=m):m=e[17],m}function aR(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 lR(n){const e=B.c(23),{children:t,panels:s,context:o,activePanel:i,services:a,onClosePanel:l,onTogglePanel:c,actions:d}=n;let u;e[0]!==i?(u=i?aR(i.defaultSize):"100%",e[0]=i,e[1]=u):u=e[1];let f;e[2]!==t||e[3]!==u?(f=r.jsx(Mh,{defaultSize:u,minSize:"320px",children:t}),e[2]=t,e[3]=u,e[4]=f):f=e[4];let m;e[5]!==i||e[6]!==o||e[7]!==l||e[8]!==s||e[9]!==a?(m=i&&r.jsxs(r.Fragment,{children:[r.jsx(nR,{withHandle:!0}),r.jsx(Mh,{defaultSize:i.defaultSize??"36%",minSize:i.minSize??"300px",maxSize:i.maxSize??"70%",children:r.jsx(sR,{value:a,children:r.jsx(iR,{panels:s,context:o,activePanelId:i.id,onClosePanel:l})})})]}),e[5]=i,e[6]=o,e[7]=l,e[8]=s,e[9]=a,e[10]=m):m=e[10];let p;e[11]!==f||e[12]!==m?(p=r.jsxs(tR,{orientation:"horizontal",className:"min-h-0 min-w-0 w-auto flex-1",children:[f,m]}),e[11]=f,e[12]=m,e[13]=p):p=e[13];const h=(i==null?void 0:i.id)??null;let g;e[14]!==d||e[15]!==o||e[16]!==c||e[17]!==s||e[18]!==h?(g=r.jsx(oR,{panels:s,context:o,activePanelId:h,onTogglePanel:c,actions:d}),e[14]=d,e[15]=o,e[16]=c,e[17]=s,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==p||e[21]!==g?(x=r.jsxs(r.Fragment,{children:[p,g]}),e[20]=p,e[21]=g,e[22]=x):x=e[22],x}const ui={data:null,error:null,loading:!1,refreshing:!1},cR=8e3,dR=new Set(["clickup_not_configured","clickup_auth_failed","project_unlinked"]),hl="*",sf={endpoint:()=>"/api/clickup/status",pollIntervalMs:5*6e4,fallbackError:"Unable to reach ClickUp",stores:new Map},wb={endpoint:()=>"/api/clickup/tasks/mine",pollIntervalMs:6e4,fallbackError:"Unable to load your ClickUp tasks",stores:new Map},ja={endpoint:n=>`/api/clickup/tasks/list?cwd=${encodeURIComponent(n)}`,pollIntervalMs:6e4,fallbackError:"Unable to load the linked ClickUp list",stores:new Map};function Sa(n,e){let t=n.stores.get(e);return t||(t={snapshot:ui,listeners:new Set,request:null,fetchedAt:0},n.stores.set(e,t)),t}function vr(n,e){n.snapshot=e;for(const t of n.listeners)t()}async function jb(n){try{const e=await n.json();if(typeof e.error=="string"&&typeof e.code=="string")return e}catch{}return{error:`ClickUp request failed (${n.status})`,code:"clickup_api_failed"}}function yr(n,e){const t=n;return{error:typeof t.error=="string"?t.error:e,code:typeof t.code=="string"?t.code:"clickup_api_failed"}}async function vo(n,e,t=!1){const s=Sa(n,e);if(s.request)return s.request;if(!(!t&&s.snapshot.error&&dR.has(s.snapshot.error.code))&&!(!t&&s.fetchedAt>0&&Date.now()-s.fetchedAt<cR))return(t||s.snapshot.data===null)&&vr(s,{...s.snapshot,error:t?null:s.snapshot.error,loading:s.snapshot.data===null,refreshing:s.snapshot.data!==null}),s.request=Ne(n.endpoint(e)).then(async o=>{if(!o.ok)throw await jb(o);const i=await o.json();s.fetchedAt=Date.now(),vr(s,{data:i,error:null,loading:!1,refreshing:!1})}).catch(o=>{vr(s,{...s.snapshot,error:yr(o,n.fallbackError),loading:!1,refreshing:!1})}).finally(()=>{s.request=null}),s.request}function of(n,e,t){const s=B.c(17),o=e??"";let i;s[0]!==n||s[1]!==o?(i=p=>{if(!o)return fR;const h=Sa(n,o);return h.listeners.add(p),()=>h.listeners.delete(p)},s[0]=n,s[1]=o,s[2]=i):i=s[2];let a;s[3]!==n||s[4]!==o?(a=()=>o?Sa(n,o).snapshot:ui,s[3]=n,s[4]=o,s[5]=a):a=s[5];const l=w.useSyncExternalStore(i,a,uR);let c,d;s[6]!==t||s[7]!==n||s[8]!==o?(c=()=>{if(!t||!o)return;vo(n,o);const p=window.setInterval(()=>{vo(n,o)},n.pollIntervalMs);return()=>window.clearInterval(p)},d=[n,t,o],s[6]=t,s[7]=n,s[8]=o,s[9]=c,s[10]=d):(c=s[9],d=s[10]),w.useEffect(c,d);let u;s[11]!==n||s[12]!==o?(u=()=>o?vo(n,o,!0):Promise.resolve(),s[11]=n,s[12]=o,s[13]=u):u=s[13];const f=u;let m;return s[14]!==f||s[15]!==l?(m={...l,refresh:f},s[14]=f,s[15]=l,s[16]=m):m=s[16],m}function uR(){return ui}function fR(){}function Sb(n){return of(sf,hl,n)}function Nb(n){return of(wb,hl,n)}function mR(n,e){return of(ja,n,e)}async function fi(n,e){const t=await Ne(n,e);if(!t.ok)throw await jb(t);return t.json()}function kb(n,e){return{method:n,headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}}function Cb(){for(const n of[wb,ja])for(const e of n.stores.values())e.fetchedAt=0,vr(e,ui)}async function pR(n){await fi("/api/clickup/token",kb("POST",{token:n})),Cb(),await vo(sf,hl,!0)}async function hR(){await fi("/api/clickup/token",{method:"DELETE"}),Cb(),await vo(sf,hl,!0)}async function _b(n,e){await fi("/api/clickup/project-list",kb("PUT",{cwd:n,listId:e}));const t=Sa(ja,n);t.fetchedAt=0,vr(t,ui),e!==null&&await vo(ja,n,!0)}function gR(){return fi("/api/clickup/spaces")}function xR(n){return fi(`/api/clickup/lists?spaceId=${encodeURIComponent(n)}`)}const Lh={status:null,due:"all",priority:null,query:""},Oh={urgent:0,high:1,normal:2,low:3},Dh=1440*60*1e3;function qo(n){return n.status.type==="closed"}function Tb(n){const e=new Date(n);return e.setHours(0,0,0,0),e.getTime()}function Io(n,e){return n.dueAt!==null&&!qo(n)&&n.dueAt<Tb(e)}function Eb(n,e,t){if(e==="all")return!0;if(e==="none")return n.dueAt===null;if(n.dueAt===null)return!1;const s=Tb(t);switch(e){case"overdue":return Io(n,t);case"today":return n.dueAt>=s&&n.dueAt<s+Dh;case"week":return n.dueAt>=s&&n.dueAt<s+7*Dh}}function bR(n,e){const t=e.trim().toLowerCase();return t?[n.name,n.customId??"",n.listName,n.folderName??"",...n.tags.map(s=>s.name)].some(s=>s.toLowerCase().includes(t)):!0}function vR(n,e,t){return n.filter(s=>(e.status===null||s.status.name===e.status)&&(e.priority===null||s.priority===e.priority)&&Eb(s,e.due,t)&&bR(s,e.query))}function yR(n){const e=new Map;for(const t of n)e.has(t.status.name)||e.set(t.status.name,t.status);return[...e.values()].sort((t,s)=>t.order-s.order||t.name.localeCompare(s.name))}function wR(n,e){return[...n].sort((t,s)=>{const o=Number(Io(s,e))-Number(Io(t,e));if(o!==0)return o;if(t.dueAt!==s.dueAt)return t.dueAt===null?1:s.dueAt===null?-1:t.dueAt-s.dueAt;const i=(t.priority?Oh[t.priority]:4)-(s.priority?Oh[s.priority]:4);return i!==0?i:s.updatedAt-t.updatedAt})}function rf(n,e){return n?`${n} › ${e}`:e}function jR(n){const e=n.customId??n.id,t=n.description.trim();return[`Work on ClickUp task ${e}: ${n.name}`,n.url,...t?["",t]:[]].join(`
121
+ `)}function SR(n){const e=n.trim();if(/^\d+$/.test(e))return e;const t=e.match(/\/li\/(\d+)/)??e.match(/\/list\/(\d+)/);return t?t[1]:null}const NR={urgent:"text-destructive",high:"text-warning",normal:"text-info",low:"text-muted-foreground"},kR=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"});function Ab(n){const e=B.c(5),{priority:t}=n;if(!t)return null;const s=NR[t];let o;e[0]!==s?(o=q("size-3 shrink-0",s),e[0]=s,e[1]=o):o=e[1];const i=`${t} priority`;let a;return e[2]!==o||e[3]!==i?(a=r.jsx(jo,{className:o,"aria-label":i,role:"img",fill:"currentColor"}),e[2]=o,e[3]=i,e[4]=a):a=e[4],a}function CR(n){const e=B.c(14),{task:t,now:s}=n;if(t.dueAt===null)return null;const o=Io(t,s);let i;e[0]!==t.dueAt?(i=new Date(t.dueAt).toLocaleDateString(),e[0]=t.dueAt,e[1]=i):i=e[1];const a=`Due ${i}`,l=o?"text-destructive":"text-muted-foreground";let c;e[2]!==l?(c=q("flex shrink-0 items-center gap-0.5 text-[10px] tabular-nums",l),e[2]=l,e[3]=c):c=e[3];let d;e[4]!==t.dueAt?(d=new Date(t.dueAt).toISOString(),e[4]=t.dueAt,e[5]=d):d=e[5];const u=o?`${a} (overdue)`:a;let f;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(_w,{className:"size-3","aria-hidden":!0}),e[6]=f):f=e[6];let m;e[7]!==t.dueAt?(m=kR.format(t.dueAt),e[7]=t.dueAt,e[8]=m):m=e[8];let p;return e[9]!==c||e[10]!==d||e[11]!==u||e[12]!==m?(p=r.jsxs("time",{className:c,dateTime:d,title:u,children:[f,m]}),e[9]=c,e[10]=d,e[11]=u,e[12]=m,e[13]=p):p=e[13],p}function _R(n){const e=B.c(14),{assignees:t,viewer:s}=n;let o,i,a,l,c;if(e[0]!==t||e[1]!==s){c=Symbol.for("react.early_return_sentinel");e:{let u;e[7]!==s?(u=p=>p.id!==s.id,e[7]=s,e[8]=u):u=e[8];const f=t.filter(u);if(f.length===0){c=null;break e}const m=`Also assigned to ${f.map(ER).join(", ")}`;o="flex shrink-0 -space-x-1",i=m,a=m,l=f.slice(0,3).map(TR)}e[0]=t,e[1]=s,e[2]=o,e[3]=i,e[4]=a,e[5]=l,e[6]=c}else o=e[2],i=e[3],a=e[4],l=e[5],c=e[6];if(c!==Symbol.for("react.early_return_sentinel"))return c;let d;return e[9]!==o||e[10]!==i||e[11]!==a||e[12]!==l?(d=r.jsx("span",{className:o,"aria-label":i,title:a,children:l}),e[9]=o,e[10]=i,e[11]=a,e[12]=l,e[13]=d):d=e[13],d}function TR(n){return r.jsx("span",{className:"flex size-4 items-center justify-center rounded-full border border-background text-[8px] font-medium text-white",style:{backgroundColor:n.color??"#6b7280"},"aria-hidden":!0,children:n.initials.slice(0,2)},n.id)}function ER(n){return n.username}function AR(n){const e=B.c(130),{task:t,viewer:s,now:o,onPickStatus:i,composePrompt:a}=n,[l,c]=w.useState(!1);let d,u,f,m,p,h,g,x,v,y,b,j,S,k,C,N;if(e[0]!==l||e[1]!==t){const le=qo(t);let xe;e[18]!==t.description?(xe=t.description.trim(),e[18]=t.description,e[19]=xe):xe=e[19],f=xe;let pe;e[20]!==t.folderName||e[21]!==t.listName?(pe=rf(t.folderName,t.listName),e[20]=t.folderName,e[21]=t.listName,e[22]=pe):pe=e[22],m=pe,h="relative pl-3",g=t.name,e[23]!==t.status.color?(x=r.jsx("span",{"aria-hidden":!0,className:"absolute inset-y-1 left-0 w-0.5 rounded-full",style:{backgroundColor:t.status.color}}),e[23]=t.status.color,e[24]=x):x=e[24],u=ct,C=l,N=c,k="group/task flex items-start gap-1 pr-1",d=Rt,b="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",j=`${t.name}: ${t.status.name}`,S=l,v="flex min-w-0 items-center gap-2",e[25]!==t.priority?(y=r.jsx(Ab,{priority:t.priority}),e[25]=t.priority,e[26]=y):y=e[26],p=q("min-w-0 flex-1 truncate text-[13px] font-medium leading-5",le&&"text-muted-foreground line-through decoration-border"),e[0]=l,e[1]=t,e[2]=d,e[3]=u,e[4]=f,e[5]=m,e[6]=p,e[7]=h,e[8]=g,e[9]=x,e[10]=v,e[11]=y,e[12]=b,e[13]=j,e[14]=S,e[15]=k,e[16]=C,e[17]=N}else d=e[2],u=e[3],f=e[4],m=e[5],p=e[6],h=e[7],g=e[8],x=e[9],v=e[10],y=e[11],b=e[12],j=e[13],S=e[14],k=e[15],C=e[16],N=e[17];let E;e[27]!==p||e[28]!==t.name?(E=r.jsx("span",{className:p,children:t.name}),e[27]=p,e[28]=t.name,e[29]=E):E=e[29];let T;e[30]!==t.customId?(T=t.customId&&r.jsx("span",{className:"shrink-0 font-mono text-[10px] text-muted-foreground",children:t.customId}),e[30]=t.customId,e[31]=T):T=e[31];let P;e[32]!==E||e[33]!==T||e[34]!==v||e[35]!==y?(P=r.jsxs("span",{className:v,children:[y,E,T]}),e[32]=E,e[33]=T,e[34]=v,e[35]=y,e[36]=P):P=e[36];let _;e[37]!==t.status.color?(_={color:t.status.color},e[37]=t.status.color,e[38]=_):_=e[38];let A;e[39]!==_||e[40]!==t.status.name?(A=r.jsx("span",{className:"shrink-0 rounded-sm px-1 text-[10px] uppercase tracking-wide",style:_,children:t.status.name}),e[39]=_,e[40]=t.status.name,e[41]=A):A=e[41];let I;e[42]!==m?(I=r.jsx("span",{className:"truncate",children:m}),e[42]=m,e[43]=I):I=e[43];let $;e[44]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx("span",{className:"shrink-0",children:"·"}),e[44]=$):$=e[44];let R;e[45]!==t.updatedAt?(R=new Date(t.updatedAt).toISOString(),e[45]=t.updatedAt,e[46]=R):R=e[46];let M;e[47]!==t.updatedAt?(M=new Date(t.updatedAt).toLocaleString(),e[47]=t.updatedAt,e[48]=M):M=e[48];let O;e[49]!==o||e[50]!==t.updatedAt?(O=fl(new Date(t.updatedAt).toISOString(),o),e[49]=o,e[50]=t.updatedAt,e[51]=O):O=e[51];let D;e[52]!==R||e[53]!==M||e[54]!==O?(D=r.jsx("time",{className:"shrink-0",dateTime:R,title:M,children:O}),e[52]=R,e[53]=M,e[54]=O,e[55]=D):D=e[55];let z;e[56]!==A||e[57]!==I||e[58]!==D?(z=r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-[11px] leading-4 text-muted-foreground",children:[A,I,$,D]}),e[56]=A,e[57]=I,e[58]=D,e[59]=z):z=e[59];let F;e[60]!==d||e[61]!==P||e[62]!==z||e[63]!==b||e[64]!==j||e[65]!==S?(F=r.jsxs(d,{className:b,"aria-label":j,"aria-expanded":S,children:[P,z]}),e[60]=d,e[61]=P,e[62]=z,e[63]=b,e[64]=j,e[65]=S,e[66]=F):F=e[66];let L;e[67]!==o||e[68]!==t?(L=r.jsx(CR,{task:t,now:o}),e[67]=o,e[68]=t,e[69]=L):L=e[69];let H;e[70]!==t.assignees||e[71]!==s?(H=r.jsx(_R,{assignees:t.assignees,viewer:s}),e[70]=t.assignees,e[71]=s,e[72]=H):H=e[72];const U=`Open ${t.customId??t.name} in ClickUp`;let W;e[73]!==t.url?(W=()=>window.open(t.url,"_blank","noopener,noreferrer"),e[73]=t.url,e[74]=W):W=e[74];let V;e[75]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx(nn,{}),e[75]=V):V=e[75];let K;e[76]!==U||e[77]!==W?(K=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",className:"size-6 text-muted-foreground opacity-0 transition-opacity group-hover/task:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100","aria-label":U,onClick:W,children:V}),e[76]=U,e[77]=W,e[78]=K):K=e[78];let Y;e[79]!==L||e[80]!==H||e[81]!==K?(Y=r.jsxs("div",{className:"mt-1 flex shrink-0 items-center gap-1.5",children:[L,H,K]}),e[79]=L,e[80]=H,e[81]=K,e[82]=Y):Y=e[82];let X;e[83]!==F||e[84]!==Y||e[85]!==k?(X=r.jsxs("div",{className:k,children:[F,Y]}),e[83]=F,e[84]=Y,e[85]=k,e[86]=X):X=e[86];let G;e[87]!==f?(G=f?r.jsx(Qu,{body:f}):r.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"No description."}),e[87]=f,e[88]=G):G=e[88];let J;e[89]!==i||e[90]!==t.status.name?(J=()=>i(t.status.name),e[89]=i,e[90]=t.status.name,e[91]=J):J=e[91];const Z=`Only tasks in ${t.status.name}`;let Q;e[92]!==t.status.color?(Q=r.jsx("span",{"aria-hidden":!0,className:"size-2 rounded-full",style:{backgroundColor:t.status.color}}),e[92]=t.status.color,e[93]=Q):Q=e[93];let te;e[94]!==J||e[95]!==Z||e[96]!==Q||e[97]!==t.status.name?(te=r.jsx("li",{children:r.jsxs("button",{type:"button",className:"inline-flex h-5 items-center gap-1 rounded-full border px-1.5 text-[10px] leading-none text-muted-foreground outline-none hover:border-foreground/30 hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/20",onClick:J,"aria-label":Z,children:[Q,t.status.name]})}),e[94]=J,e[95]=Z,e[96]=Q,e[97]=t.status.name,e[98]=te):te=e[98];let ne;e[99]!==t.tags?(ne=t.tags.map(PR),e[99]=t.tags,e[100]=ne):ne=e[100];let oe;e[101]!==te||e[102]!==ne?(oe=r.jsxs("ul",{className:"flex flex-wrap gap-1","aria-label":"Task details",children:[te,ne]}),e[101]=te,e[102]=ne,e[103]=oe):oe=e[103];let re;e[104]!==a||e[105]!==t?(re=a&&r.jsxs(ee,{type:"button",size:"xs",onClick:()=>a(jR(t)),children:[r.jsx(Q1,{"data-icon":"inline-start"}),"Add to prompt"]}),e[104]=a,e[105]=t,e[106]=re):re=e[106];let ie;e[107]!==t.url?(ie=r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer"}),e[107]=t.url,e[108]=ie):ie=e[108];let se;e[109]===Symbol.for("react.memo_cache_sentinel")?(se=r.jsx(nn,{"data-icon":"inline-end"}),e[109]=se):se=e[109];let ce;e[110]!==ie?(ce=r.jsxs(ee,{variant:"outline",size:"xs",render:ie,children:["Open in ClickUp",se]}),e[110]=ie,e[111]=ce):ce=e[111];let ae;e[112]!==re||e[113]!==ce?(ae=r.jsxs("div",{className:"flex flex-wrap gap-2",children:[re,ce]}),e[112]=re,e[113]=ce,e[114]=ae):ae=e[114];let ue;e[115]!==G||e[116]!==oe||e[117]!==ae?(ue=r.jsx(dt,{children:r.jsxs("div",{className:"flex flex-col gap-3 py-2 pl-1 pr-1",children:[G,oe,ae]})}),e[115]=G,e[116]=oe,e[117]=ae,e[118]=ue):ue=e[118];let me;e[119]!==u||e[120]!==X||e[121]!==ue||e[122]!==C||e[123]!==N?(me=r.jsxs(u,{open:C,onOpenChange:N,children:[X,ue]}),e[119]=u,e[120]=X,e[121]=ue,e[122]=C,e[123]=N,e[124]=me):me=e[124];let de;return e[125]!==h||e[126]!==g||e[127]!==x||e[128]!==me?(de=r.jsxs("article",{className:h,"aria-label":g,children:[x,me]}),e[125]=h,e[126]=g,e[127]=x,e[128]=me,e[129]=de):de=e[129],de}function PR(n){return r.jsx("li",{className:"inline-flex h-5 items-center rounded-full border px-1.5 text-[10px] leading-none text-muted-foreground",children:n.name},n.name)}function Pb(n){const e=B.c(75),{tasks:t,viewer:s,composePrompt:o,emptyTitle:i,emptyDescription:a,truncated:l}=n,[c,d]=w.useState(Lh),u=ml(!1);if(t.length===0){let C;return e[0]!==a||e[1]!==i?(C=r.jsx(pl,{icon:Cw,title:i,description:a}),e[0]=a,e[1]=i,e[2]=C):C=e[2],C}let f,m,p,h,g,x,v,y;if(e[3]!==o||e[4]!==c||e[5]!==u||e[6]!==t||e[7]!==s){const C=t.filter(MR),N=yR(C),E=[...new Set(C.flatMap($R))],T=de=>C.filter(le=>Eb(le,de,u)).length,P=T("overdue"),_=T("today"),A=T("week"),I=vR(t,c,u),$=wR(I.filter(RR),u),R=I.filter(qo).sort(IR);let M;e[16]===Symbol.for("react.memo_cache_sentinel")?(M=de=>d(le=>({...le,...de})),e[16]=M):M=e[16];const O=M;let D;e[17]!==c.due||e[18]!==c.priority||e[19]!==c.query||e[20]!==c.status?(D=c.status!==null||c.due!=="all"||c.priority!==null||c.query.trim()!=="",e[17]=c.due,e[18]=c.priority,e[19]=c.query,e[20]=c.status,e[21]=D):D=e[21];const z=D;let F;e[22]!==o||e[23]!==u||e[24]!==s?(F=de=>r.jsx(AR,{task:de,viewer:s,now:u,onPickStatus:le=>O({status:le}),composePrompt:o},de.id),e[22]=o,e[23]=u,e[24]=s,e[25]=F):F=e[25];const L=F;let H;e[26]===Symbol.for("react.memo_cache_sentinel")?(H=r.jsx(Yt,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}),e[26]=H):H=e[26];let U;e[27]===Symbol.for("react.memo_cache_sentinel")?(U=de=>O({query:de.target.value}),e[27]=U):U=e[27];let W;e[28]!==c.query?(W=r.jsx(Mt,{type:"search",value:c.query,onChange:U,placeholder:"Search tasks","aria-label":"Search tasks",className:"h-7 border-0 bg-transparent px-0 text-xs shadow-none focus-visible:ring-0"}),e[28]=c.query,e[29]=W):W=e[29];let V;e[30]!==z?(V=z&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>d(Lh),"aria-label":"Clear filters",children:[r.jsx(tt,{"data-icon":"inline-start"}),"Clear"]}),e[30]=z,e[31]=V):V=e[31],e[32]!==W||e[33]!==V?(x=r.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b px-3 py-1.5",children:[H,W,V]}),e[32]=W,e[33]=V,e[34]=x):x=e[34];let K;e[35]===Symbol.for("react.memo_cache_sentinel")?(K=()=>O({due:"all"}),e[35]=K):K=e[35];const Y=c.due==="overdue",X=P===0;let G;e[36]===Symbol.for("react.memo_cache_sentinel")?(G=()=>O({due:"overdue"}),e[36]=G):G=e[36];const J=P>0&&c.due!=="overdue"?"text-destructive":void 0;let Z;e[37]!==P?(Z=r.jsx(vt,{children:P}),e[37]=P,e[38]=Z):Z=e[38];let Q;e[39]!==Y||e[40]!==X||e[41]!==J||e[42]!==Z?(Q=r.jsxs(bt,{pressed:Y,disabled:X,onClick:G,className:J,children:["Overdue",Z]}),e[39]=Y,e[40]=X,e[41]=J,e[42]=Z,e[43]=Q):Q=e[43];const te=c.due==="today",ne=_===0;let oe;e[44]===Symbol.for("react.memo_cache_sentinel")?(oe=()=>O({due:"today"}),e[44]=oe):oe=e[44];let re;e[45]!==_?(re=r.jsx(vt,{children:_}),e[45]=_,e[46]=re):re=e[46];let ie;e[47]!==te||e[48]!==ne||e[49]!==re?(ie=r.jsxs(bt,{pressed:te,disabled:ne,onClick:oe,children:["Today",re]}),e[47]=te,e[48]=ne,e[49]=re,e[50]=ie):ie=e[50];const se=c.due==="week",ce=A===0;let ae;e[51]===Symbol.for("react.memo_cache_sentinel")?(ae=()=>O({due:"week"}),e[51]=ae):ae=e[51];let ue;e[52]!==A?(ue=r.jsx(vt,{children:A}),e[52]=A,e[53]=ue):ue=e[53];let me;e[54]!==se||e[55]!==ce||e[56]!==ue?(me=r.jsxs(bt,{pressed:se,disabled:ce,onClick:ae,children:["This week",ue]}),e[54]=se,e[55]=ce,e[56]=ue,e[57]=me):me=e[57],v=r.jsxs(zr,{label:"Filter by due date and priority",children:[r.jsxs(bt,{pressed:c.due==="all",onClick:K,children:["All",r.jsx(vt,{children:C.length})]}),Q,ie,me,E.length>0&&r.jsx("span",{className:"mx-1 h-4 w-px shrink-0 bg-border","aria-hidden":!0}),E.map(de=>r.jsxs(bt,{pressed:c.priority===de,onClick:()=>O({priority:c.priority===de?null:de}),"aria-label":`Only ${de} priority tasks`,children:[r.jsx(Ab,{priority:de}),de,r.jsx(vt,{children:C.filter(le=>le.priority===de).length})]},de))]}),y=N.length>1&&r.jsx(zr,{label:"Filter by status",children:N.map(de=>r.jsxs(bt,{pressed:c.status===de.name,onClick:()=>O({status:c.status===de.name?null:de.name}),"aria-label":`Only tasks in ${de.name}`,children:[r.jsx("span",{"aria-hidden":!0,className:"size-2 rounded-full",style:{backgroundColor:de.color}}),de.name,r.jsx(vt,{children:C.filter(le=>le.status.name===de.name).length})]},de.name))}),f=Vn,g="min-h-0 flex-1",m="flex flex-col gap-4 px-3 py-3",p=$.length===0?r.jsx("p",{className:"px-1 py-3 text-center text-xs text-muted-foreground",children:z?"No tasks match these filters.":"Nothing open here."}):$.map(L),h=R.length>0&&r.jsx(Ju,{count:R.length,children:R.map(L)}),e[3]=o,e[4]=c,e[5]=u,e[6]=t,e[7]=s,e[8]=f,e[9]=m,e[10]=p,e[11]=h,e[12]=g,e[13]=x,e[14]=v,e[15]=y}else f=e[8],m=e[9],p=e[10],h=e[11],g=e[12],x=e[13],v=e[14],y=e[15];let b;e[58]!==t.length||e[59]!==l?(b=l&&r.jsxs("p",{className:"px-1 text-center text-[11px] text-muted-foreground",children:["Showing the first ",t.length," tasks; narrow it down in ClickUp to see the rest."]}),e[58]=t.length,e[59]=l,e[60]=b):b=e[60];let j;e[61]!==m||e[62]!==p||e[63]!==h||e[64]!==b?(j=r.jsxs("div",{className:m,children:[p,h,b]}),e[61]=m,e[62]=p,e[63]=h,e[64]=b,e[65]=j):j=e[65];let S;e[66]!==f||e[67]!==g||e[68]!==j?(S=r.jsx(f,{className:g,children:j}),e[66]=f,e[67]=g,e[68]=j,e[69]=S):S=e[69];let k;return e[70]!==S||e[71]!==x||e[72]!==v||e[73]!==y?(k=r.jsxs(r.Fragment,{children:[x,v,y,S]}),e[70]=S,e[71]=x,e[72]=v,e[73]=y,e[74]=k):k=e[74],k}function IR(n,e){return(e.closedAt??e.updatedAt)-(n.closedAt??n.updatedAt)}function RR(n){return!qo(n)}function $R(n){return n.priority?[n.priority]:[]}function MR(n){return!qo(n)}function LR(n,e){return n?e===null?"Loading lists…":"Choose a list":"Choose a space first"}function OR({projectPath:n,onLinked:e}){const[t,s]=w.useState(""),[o,i]=w.useState(null),[a,l]=w.useState(""),[c,d]=w.useState(null),[u,f]=w.useState(""),[m,p]=w.useState(!1),[h,g]=w.useState(null);w.useEffect(()=>{let y=!1;return gR().then(b=>{y||i(b.spaces)}).catch(b=>{y||g(yr(b,"Unable to load spaces").error)}),()=>{y=!0}},[]),w.useEffect(()=>{if(!a)return;let y=!1;return d(null),f(""),xR(a).then(b=>{y||d(b.lists)}).catch(b=>{y||g(yr(b,"Unable to load lists").error)}),()=>{y=!0}},[a]);async function x(y){if(!y){g("Paste a ClickUp list URL such as https://app.clickup.com/…/v/li/901700000000");return}p(!0),g(null);try{await _b(n,y),e()}catch(b){g(yr(b,"Unable to link that list").error)}finally{p(!1)}}function v(y){y.preventDefault(),x(SR(t))}return r.jsxs("div",{className:"flex flex-col gap-4 p-4","aria-label":"Link a ClickUp list",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm font-medium",children:"Link this project to a ClickUp list"}),r.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:"Tasks from the linked list show up here, next to the code they belong to."})]}),r.jsxs("form",{className:"flex flex-col gap-2",onSubmit:v,children:[r.jsx("label",{className:"text-[11px] font-medium text-muted-foreground",htmlFor:"clickup-list-url",children:"List URL or id"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Mt,{id:"clickup-list-url",value:t,onChange:y=>s(y.target.value),placeholder:"https://app.clickup.com/…/v/li/901700000000",className:"h-8 text-xs",autoComplete:"off",spellCheck:!1}),r.jsxs(ee,{type:"submit",size:"sm",disabled:m||!t.trim(),children:[m?r.jsx(nt,{}):r.jsx(km,{"data-icon":"inline-start"}),"Link"]})]})]}),r.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:[r.jsx("span",{className:"h-px flex-1 bg-border","aria-hidden":!0}),"or browse",r.jsx("span",{className:"h-px flex-1 bg-border","aria-hidden":!0})]}),r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsxs($c,{value:a,onValueChange:y=>l(y??""),children:[r.jsx(Lc,{className:"h-8 text-xs","aria-label":"Space",disabled:o===null,children:r.jsx(Mc,{placeholder:o===null?"Loading spaces…":"Choose a space"})}),r.jsx(Oc,{children:o==null?void 0:o.map(y=>r.jsx(Dc,{value:y.id,children:y.name},y.id))})]}),r.jsxs($c,{value:u,onValueChange:y=>f(y??""),children:[r.jsx(Lc,{className:"h-8 text-xs","aria-label":"List",disabled:!a||c===null,children:r.jsx(Mc,{placeholder:LR(a,c)})}),r.jsxs(Oc,{children:[c==null?void 0:c.map(y=>r.jsx(Dc,{value:y.id,children:rf(y.folderName,y.name)},y.id)),(c==null?void 0:c.length)===0&&r.jsx("p",{className:"px-2 py-1 text-xs text-muted-foreground",children:"This space has no lists."})]})]}),r.jsxs(ee,{type:"button",size:"sm",variant:"outline",disabled:m||!u,onClick:()=>{x(u)},children:[m?r.jsx(nt,{}):r.jsx(km,{"data-icon":"inline-start"}),"Link selected list"]})]}),h&&r.jsx("p",{role:"alert",className:"text-xs text-destructive",children:h})]})}function DR({data:n,projectPath:e,composePrompt:t,onUnlinked:s}){const[o,i]=w.useState(!1),a=rf(n.list.folderName,n.list.name);async function l(){i(!0);try{await _b(e,null),s()}finally{i(!1)}}return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex h-8 shrink-0 items-center gap-2 border-b px-3 text-[11px] text-muted-foreground",children:[r.jsx("a",{href:n.list.url,target:"_blank",rel:"noopener noreferrer",className:"min-w-0 flex-1 truncate outline-none hover:text-foreground focus-visible:underline",title:a,children:a}),r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>{l()},disabled:o,"aria-label":"Unlink this project from ClickUp",children:[o?r.jsx(nt,{}):r.jsx(Tw,{"data-icon":"inline-start"}),"Unlink"]})]}),r.jsx(Pb,{tasks:n.tasks,viewer:n.viewer,composePrompt:t,emptyTitle:"No tasks in this list",emptyDescription:"Tasks added to the linked list will show up here.",truncated:n.truncated})]})}const zR="https://app.clickup.com/settings/apps";function FR(n){return n==="mine"||n==="project"}function BR(n){return n.code==="clickup_auth_failed"?"Generate a new personal token in ClickUp and add it again.":n.code==="clickup_rate_limited"?"ClickUp allows 100 requests a minute per token; the panel retries on its own.":"Check your ClickUp access, then try again."}function Ib(n){const e=B.c(3),{label:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=[0,1,2].map(UR),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 UR(n){return r.jsxs("div",{className:"flex flex-col gap-2 border-l-2 border-border pl-3",children:[r.jsx(it,{className:"h-3.5 w-3/4"}),r.jsx(it,{className:"h-2.5 w-1/2"})]},n)}function zh(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(Xt,{}),e[5]=l):l=e[5];let c;e[6]!==t.error.error?(c=r.jsx(Et,{children:t.error.error}),e[6]=t.error.error,e[7]=c):c=e[7];let d;e[8]!==t.error?(d=BR(t.error),e[8]=t.error,e[9]=d):d=e[9];let u;e[10]!==d?(u=r.jsx("span",{children:d}),e[10]=d,e[11]=u):u=e[11];let f;e[12]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(Pt,{"data-icon":"inline-start"}),e[12]=f):f=e[12];let m;e[13]!==o?(m=r.jsxs(ee,{type:"button",variant:"outline",size:"xs",onClick:o,children:[f,"Try again"]}),e[13]=o,e[14]=m):m=e[14];let p;e[15]!==u||e[16]!==m?(p=r.jsxs(ft,{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(ut,{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(Ib,{label:s}),e[21]=s,e[22]=a):a=e[22],a}function WR({error:n}){const[e,t]=w.useState(""),[s,o]=w.useState(!1),[i,a]=w.useState(null);async function l(c){c.preventDefault(),o(!0),a(null);try{await pR(e.trim()),t("")}catch(d){a(yr(d,"Unable to save the token").error)}finally{o(!1)}}return r.jsxs("form",{className:"flex flex-col gap-4 p-4",onSubmit:c=>{l(c)},"aria-label":"Connect ClickUp",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm font-medium",children:"Connect ClickUp"}),r.jsxs("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:["Paste a personal API token. Cogpit keeps it on this machine, in ",r.jsx("code",{className:"font-mono",children:"~/.cogpit/clickup.json"}),", and never shows it again. A ",r.jsx("code",{className:"font-mono",children:"CLICKUP_API_TOKEN"})," in the server environment works too."]})]}),n&&n.code!=="clickup_not_configured"&&r.jsx("p",{role:"alert",className:"text-xs text-destructive",children:n.error}),r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx("label",{className:"text-[11px] font-medium text-muted-foreground",htmlFor:"clickup-token",children:"Personal API token"}),r.jsx(Mt,{id:"clickup-token",type:"password",value:e,onChange:c=>t(c.target.value),placeholder:"pk_…",className:"h-8 font-mono text-xs",autoComplete:"off",spellCheck:!1})]}),i&&r.jsx("p",{role:"alert",className:"text-xs text-destructive",children:i}),r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsxs(ee,{type:"submit",size:"sm",disabled:s||!e.trim(),children:[s?r.jsx(nt,{}):r.jsx(Rd,{"data-icon":"inline-start"}),"Connect"]}),r.jsxs(ee,{variant:"outline",size:"sm",render:r.jsx("a",{href:zR,target:"_blank",rel:"noopener noreferrer"}),children:["Get a token",r.jsx(nn,{"data-icon":"inline-end"})]})]})]})}function Fh(n){const e=B.c(5),{value:t,attention:s}=n;if(t===null||t===0)return null;const o=s?"text-destructive":"text-muted-foreground";let i;e[0]!==o?(i=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 HR(){var l;const n=B.c(5),e=Sb(!0),{data:t}=Nb(((l=e.data)==null?void 0:l.configured)===!0);let s;if(n[0]!==(t==null?void 0:t.tasks)){const c=Date.now();s=(t==null?void 0:t.tasks.filter(d=>Io(d,c)).length)??0,n[0]=t==null?void 0:t.tasks,n[1]=s}else s=n[1];const o=s;if(o===0)return null;const i=`${o} overdue ClickUp task${o===1?"":"s"}`;let a;return n[2]!==o||n[3]!==i?(a=r.jsx(Pe,{variant:"destructive",className:"absolute -right-1 -top-1 min-w-4 px-1 text-[9px]","aria-label":i,children:o}),n[2]=o,n[3]=i,n[4]=a):a=n[4],a}function qR(n){var $,R,M,O,D,z,F;const e=B.c(69),{context:t,active:s,closePanel:o}=n,[i,a]=w.useState("mine"),l=t.projectPath,c=Sb(s),d=(($=c.data)==null?void 0:$.configured)===!0,u=Nb(s&&d),f=mR(l,s&&d&&i==="project"),m=i==="mine"?u:f;let p;if(e[0]!==u.data){const L=Date.now();p=u.data?u.data.tasks.filter(H=>Io(H,L)).length:null,e[0]=u.data,e[1]=p}else p=e[1];const h=p,g=u.data?u.data.tasks.length:null,x=((R=c.data)==null?void 0:R.workspace)??null;let v;if(c.data===null&&c.error===null){let L;e[2]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(Ib,{label:"Checking ClickUp connection"}),e[2]=L):L=e[2],v=L}else if(d){const L=h||g,H=!!h;let U;e[5]!==L||e[6]!==H?(U=r.jsxs(Dn,{value:"mine",className:"h-full flex-none rounded-none px-0 text-xs",children:["My tasks",r.jsx(Fh,{value:L,attention:H})]}),e[5]=L,e[6]=H,e[7]=U):U=e[7];const W=!l;let V;e[8]!==f.data?(V=f.data?f.data.tasks.filter(VR).length:null,e[8]=f.data,e[9]=V):V=e[9];let K;e[10]!==V?(K=r.jsx(Fh,{value:V}),e[10]=V,e[11]=K):K=e[11];let Y;e[12]!==W||e[13]!==K?(Y=r.jsxs(Dn,{value:"project",className:"h-full flex-none rounded-none px-0 text-xs",disabled:W,children:["This project",K]}),e[12]=W,e[13]=K,e[14]=Y):Y=e[14];let X;e[15]!==U||e[16]!==Y?(X=r.jsx("div",{className:"flex h-9 shrink-0 items-end border-b px-3",children:r.jsxs(Va,{variant:"line",className:"h-full gap-3 p-0","aria-label":"ClickUp views",children:[U,Y]})}),e[15]=U,e[16]=Y,e[17]=X):X=e[17];let G;e[18]!==u?(G=()=>{u.refresh()},e[18]=u,e[19]=G):G=e[19];let J;e[20]!==t.composePrompt?(J=re=>r.jsx(Pb,{tasks:re.tasks,viewer:re.viewer,composePrompt:t.composePrompt,emptyTitle:"Nothing assigned to you",emptyDescription:"Open tasks assigned to you anywhere in the workspace will show up here.",truncated:re.truncated}),e[20]=t.composePrompt,e[21]=J):J=e[21];let Z;e[22]!==u||e[23]!==G||e[24]!==J?(Z=r.jsx(zn,{value:"mine",className:"flex min-h-0 flex-col",children:r.jsx(zh,{state:u,loadingLabel:"Loading your tasks",onRetry:G,children:J})}),e[22]=u,e[23]=G,e[24]=J,e[25]=Z):Z=e[25];let Q;e[26]!==t.composePrompt||e[27]!==f||e[28]!==l?(Q=l&&(((M=f.error)==null?void 0:M.code)==="project_unlinked"?r.jsx(OR,{projectPath:l,onLinked:()=>{f.refresh()}}):r.jsx(zh,{state:f,loadingLabel:"Loading the linked list",onRetry:()=>{f.refresh()},children:re=>r.jsx(DR,{data:re,projectPath:l,composePrompt:t.composePrompt,onUnlinked:()=>{f.refresh()}})})),e[26]=t.composePrompt,e[27]=f,e[28]=l,e[29]=Q):Q=e[29];let te;e[30]!==Q?(te=r.jsx(zn,{value:"project",className:"flex min-h-0 flex-col",children:Q}),e[30]=Q,e[31]=te):te=e[31];let ne;e[32]!==Z||e[33]!==te?(ne=r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[Z,te]}),e[32]=Z,e[33]=te,e[34]=ne):ne=e[34];let oe;e[35]!==ne||e[36]!==X?(oe=r.jsxs(r.Fragment,{children:[X,ne]}),e[35]=ne,e[36]=X,e[37]=oe):oe=e[37],v=oe}else{let L;e[3]!==c.error?(L=r.jsx(WR,{error:c.error}),e[3]=c.error,e[4]=L):L=e[4],v=L}let y;e[38]===Symbol.for("react.memo_cache_sentinel")?(y=L=>{FR(L)&&a(L)},e[38]=y):y=e[38];let b;e[39]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx("h2",{className:"text-sm font-medium leading-tight",children:"ClickUp"}),e[39]=b):b=e[39];let j;e[40]!==c.data||e[41]!==x?(j=r.jsxs("div",{className:"min-w-0 flex-1",children:[b,x?r.jsxs("a",{href:`https://app.clickup.com/${x.id}/home`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex max-w-full items-center gap-0.5 truncate text-[11px] text-muted-foreground outline-none hover:text-foreground focus-visible:underline",children:[r.jsxs("span",{className:"truncate",children:[x.name,(O=c.data)!=null&&O.viewer?` · ${c.data.viewer.username}`:""]}),r.jsx(nn,{className:"size-3 shrink-0"})]}):r.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:"Not connected"})]}),e[40]=c.data,e[41]=x,e[42]=j):j=e[42];let S;e[43]!==d||e[44]!==((D=c.data)==null?void 0:D.tokenFromEnv)?(S=d&&!((z=c.data)!=null&&z.tokenFromEnv)&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:KR,"aria-label":"Disconnect ClickUp",title:"Disconnect ClickUp",children:r.jsx(Rd,{})}),e[43]=d,e[44]=(F=c.data)==null?void 0:F.tokenFromEnv,e[45]=S):S=e[45];let k;e[46]!==d||e[47]!==m||e[48]!==c?(k=()=>{d?m.refresh():c.refresh()},e[46]=d,e[47]=m,e[48]=c,e[49]=k):k=e[49];const C=m.loading||m.refreshing||c.loading,N=i==="mine"?"Refresh my tasks":"Refresh project tasks";let E;e[50]!==m.refreshing?(E=m.refreshing?r.jsx(nt,{}):r.jsx(Pt,{}),e[50]=m.refreshing,e[51]=E):E=e[51];let T;e[52]!==k||e[53]!==C||e[54]!==N||e[55]!==E?(T=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:k,disabled:C,"aria-label":N,children:E}),e[52]=k,e[53]=C,e[54]=N,e[55]=E,e[56]=T):T=e[56];let P;e[57]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(tt,{}),e[57]=P):P=e[57];let _;e[58]!==o?(_=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:o,"aria-label":"Close ClickUp",children:P}),e[58]=o,e[59]=_):_=e[59];let A;e[60]!==T||e[61]!==_||e[62]!==j||e[63]!==S?(A=r.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b pl-4 pr-2",children:[j,S,T,_]}),e[60]=T,e[61]=_,e[62]=j,e[63]=S,e[64]=A):A=e[64];let I;return e[65]!==v||e[66]!==A||e[67]!==i?(I=r.jsxs(Ka,{value:i,onValueChange:y,className:"size-full min-h-0 gap-0","aria-label":"ClickUp panel",children:[A,v]}),e[65]=v,e[66]=A,e[67]=i,e[68]=I):I=e[68],I}function KR(){hR()}function VR(n){return!qo(n)}const GR={id:"clickup",workspacePanels:[{id:"tasks",title:"ClickUp",icon:Ew,component:qR,indicator:HR,order:42,defaultSize:"38%",minSize:"360px",maxSize:"62%",when:n=>n.canAccessHostFiles}]},af={data:null,error:null,loading:!1,refreshing:!1},YR=8e3,XR=1500,JR=10,QR=new Set(["gh_missing","gh_auth_required","no_git_repository","no_github_remote"]),ZR={endpoint:n=>`/api/github/actions?cwd=${encodeURIComponent(n)}&limit=20`,pollIntervalMs:1e4,fallbackError:"Unable to load GitHub Actions",stores:new Map},e$={endpoint:n=>`/api/github/pulls?cwd=${encodeURIComponent(n)}&limit=30`,pollIntervalMs:3e4,fallbackError:"Unable to load pull requests",stores:new Map},t$={endpoint:n=>`/api/github/issues?cwd=${encodeURIComponent(n)}&limit=30`,pollIntervalMs:6e4,fallbackError:"Unable to load issues",stores:new Map},n$={endpoint:n=>`/api/github/pulls/sessions?cwd=${encodeURIComponent(n)}`,pollIntervalMs:3e4,fallbackError:"Unable to match sessions to pull requests",stores:new Map,settling:n=>n.pending>0};function rd(n,e){let t=n.stores.get(e);return t||(t={snapshot:af,listeners:new Set,request:null,fetchedAt:0,settleTimer:null,settleAttempts:0},n.stores.set(e,t)),t}function lc(n,e){n.snapshot=e;for(const t of n.listeners)t()}async function Rb(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 $b(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 ta(n,e,t=!1){const s=rd(n,e);if(s.request)return s.request;if(!(!t&&s.snapshot.error&&QR.has(s.snapshot.error.code))&&!(!t&&s.fetchedAt>0&&Date.now()-s.fetchedAt<YR))return(t||s.snapshot.data===null)&&lc(s,{...s.snapshot,error:t?null:s.snapshot.error,loading:s.snapshot.data===null,refreshing:s.snapshot.data!==null}),s.request=Ne(n.endpoint(e)).then(async o=>{var a;if(!o.ok)throw await Rb(o);const i=await o.json();s.fetchedAt=Date.now(),lc(s,{data:i,error:null,loading:!1,refreshing:!1}),(a=n.settling)!=null&&a.call(n,i)&&s.settleAttempts<JR?(s.settleAttempts+=1,s.settleTimer=window.setTimeout(()=>{s.settleTimer=null,ta(n,e,!0)},XR)):s.settleAttempts=0}).catch(o=>{lc(s,{...s.snapshot,error:$b(o,n.fallbackError),loading:!1,refreshing:!1})}).finally(()=>{s.request=null}),s.request}function gl(n,e,t){const s=B.c(17),o=e??"";let i;s[0]!==o||s[1]!==n?(i=p=>{if(!o)return o$;const h=rd(n,o);return h.listeners.add(p),()=>h.listeners.delete(p)},s[0]=o,s[1]=n,s[2]=i):i=s[2];let a;s[3]!==o||s[4]!==n?(a=()=>o?rd(n,o).snapshot:af,s[3]=o,s[4]=n,s[5]=a):a=s[5];const l=w.useSyncExternalStore(i,a,s$);let c,d;s[6]!==t||s[7]!==o||s[8]!==n?(c=()=>{if(!t||!o)return;ta(n,o);const p=window.setInterval(()=>{ta(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]),w.useEffect(c,d);let u;s[11]!==o||s[12]!==n?(u=()=>o?ta(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 s$(){return af}function o$(){}function Mb(n,e){return gl(ZR,n,e)}function Lb(n,e){return gl(e$,n,e)}function r$(n,e){return gl(t$,n,e)}function i$(n,e){return gl(n$,n,e)}async function Ob(n){const e=await Ne(n);if(!e.ok)throw await Rb(e);return e.json()}function a$(n,e){return Ob(`/api/github/actions/jobs?cwd=${encodeURIComponent(n)}&runId=${e}`)}function l$(n,e){return Ob(`/api/github/pulls/files?cwd=${encodeURIComponent(n)}&number=${e}`)}const c$={data:null,error:null,loading:!1};function Db(n,e,t){const s=B.c(12),o=t===void 0?!1:t,[i,a]=w.useState(!1),[l,c]=w.useState(c$);let d;s[0]!==e||s[1]!==n||s[2]!==l?(d=async function(){if(!l.loading){c(d$);try{c({data:await n(),error:null,loading:!1})}catch(g){c({data:null,error:$b(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 d$(n){return{...n,error:null,loading:!0}}function mi(n){return n!=="completed"}function Ko(n){return n==="action_required"||n==="failure"||n==="startup_failure"||n==="timed_out"}function lf(n,e){return mi(n)?"live":Ko(e)?"fail":e==="success"?"pass":"quiet"}const Bh={live:0,fail:1,quiet:2,pass:3};function u$(n){return n.reduce((e,t)=>Bh[t]<Bh[e]?t:e,"pass")}const f$={live:"bg-info motion-safe:animate-pulse",fail:"bg-destructive",pass:"bg-success",quiet:"bg-border"};function cf(n,e){return n==="in_progress"?"Running":mi(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 df(n){const e=B.c(14),{status:t,conclusion:s,className:o}=n;let i;e[0]!==s||e[1]!==t?(i=cf(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(nt,{className:q(f,"text-info"),"aria-label":a});break e}if(mi(t)){d=r.jsx(Mo,{className:q(f,"text-info"),"aria-label":a});break e}if(s==="success"){d=r.jsx(at,{className:q(f,"text-success"),"aria-label":a});break e}if(Ko(s)){d=r.jsx(tt,{className:q(f,"text-destructive"),"aria-label":a});break e}if(s==="skipped"||s==="cancelled"){d=r.jsx(Aw,{className:q(f,"text-muted-foreground"),"aria-label":a});break e}l=Pa,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 m$(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=Ko(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(df,{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:Xu(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 p$(n){const e=B.c(39),{job:t,now:s}=n;let o;e[0]!==t.conclusion||e[1]!==t.status?(o=lf(t.status,t.conclusion),e[0]=t.conclusion,e[1]=t.status,e[2]=o):o=e[2];const i=o,[a,l]=w.useState(i==="fail"||i==="live");let c;e[3]!==t.completedAt||e[4]!==t.startedAt||e[5]!==s?(c=Xu(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=cf(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(Ye,{className:h}),e[12]=h,e[13]=g):g=e[13];let x;e[14]!==t.conclusion||e[15]!==t.status?(x=r.jsx(df,{status:t.status,conclusion:t.conclusion}),e[14]=t.conclusion,e[15]=t.status,e[16]=x):x=e[16];const v=i==="fail"&&"text-destructive";let y;e[17]!==v?(y=q("min-w-0 flex-1 truncate",v),e[17]=v,e[18]=y):y=e[18];let b;e[19]!==t.name||e[20]!==y?(b=r.jsx("span",{className:y,children:t.name}),e[19]=t.name,e[20]=y,e[21]=b):b=e[21];let j;e[22]!==d?(j=d&&r.jsx("span",{className:"shrink-0 font-mono text-[10px] text-muted-foreground tabular-nums",children:d}),e[22]=d,e[23]=j):j=e[23];let S;e[24]!==b||e[25]!==j||e[26]!==m||e[27]!==g||e[28]!==x?(S=r.jsxs(Rt,{className:"flex w-full min-w-0 items-center gap-2 rounded-sm py-1 text-left text-xs outline-none hover:bg-accent/60 focus-visible:ring-[3px] focus-visible:ring-ring/20","aria-label":m,children:[g,x,b,j]}),e[24]=b,e[25]=j,e[26]=m,e[27]=g,e[28]=x,e[29]=S):S=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(E=>r.jsx(m$,{step:E,now:s},E.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]!==S||e[37]!==C?(N=r.jsxs(ct,{open:a,onOpenChange:l,children:[S,C]}),e[35]=a,e[36]=S,e[37]=C,e[38]=N):N=e[38],N}function h$(n){var W,V,K;const e=B.c(73),{run:t,projectPath:s,now:o}=n;let i;e[0]!==t.conclusion||e[1]!==t.status?(i=lf(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=()=>a$(s,t.id),e[3]=s,e[4]=t.id,e[5]=c):c=e[5];const{open:d,state:u,onOpenChange:f}=Db(c,"Unable to load workflow jobs",l);let m;e[6]!==((W=u.data)==null?void 0:W.jobs)?(m=((V=u.data)==null?void 0:V.jobs)??[],e[6]=(K=u.data)==null?void 0:K.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=Xu(t.createdAt,h,o),e[8]=o,e[9]=t.createdAt,e[10]=h,e[11]=g):g=e[11];const x=g,v=t.name,y=t.runNumber;let b;e[12]!==t.conclusion||e[13]!==t.status?(b=cf(t.status,t.conclusion),e[12]=t.conclusion,e[13]=t.status,e[14]=b):b=e[14];const j=`${v} #${y}: ${b}`;let S;e[15]!==t.conclusion||e[16]!==t.status?(S=r.jsx(df,{status:t.status,conclusion:t.conclusion}),e[15]=t.conclusion,e[16]=t.status,e[17]=S):S=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;e[23]!==t.runNumber?(E=r.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["#",t.runNumber]}),e[23]=t.runNumber,e[24]=E):E=e[24];let T;e[25]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx("span",{className:"min-w-0 flex-1"}),e[25]=T):T=e[25];let P;e[26]!==t.branch?(P=r.jsx("span",{className:"max-w-24 truncate font-mono text-[10px] text-muted-foreground",children:t.branch}),e[26]=t.branch,e[27]=P):P=e[27];let _;e[28]!==l||e[29]!==x?(_=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]=_):_=e[30];let A;e[31]!==d||e[32]!==S||e[33]!==N||e[34]!==E||e[35]!==P||e[36]!==_||e[37]!==j?(A=r.jsxs(Rt,{className:"flex h-7 min-w-0 flex-1 items-center gap-2 rounded-sm px-1 text-left text-xs outline-none hover:bg-accent/60 focus-visible:ring-[3px] focus-visible:ring-ring/20","aria-label":j,"aria-expanded":d,children:[S,N,E,T,P,_]}),e[31]=d,e[32]=S,e[33]=N,e[34]=E,e[35]=P,e[36]=_,e[37]=j,e[38]=A):A=e[38];const I=`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 R;e[41]===Symbol.for("react.memo_cache_sentinel")?(R=r.jsx(nn,{}),e[41]=R):R=e[41];let M;e[42]!==I||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":I,onClick:$,children:R}),e[42]=I,e[43]=$,e[44]=M):M=e[44];let O;e[45]!==A||e[46]!==M?(O=r.jsxs("div",{className:"group/run flex items-center gap-1 pr-1",children:[A,M]}),e[45]=A,e[46]=M,e[47]=O):O=e[47];let D;e[48]!==u.data||e[49]!==u.loading?(D=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(nt,{className:"size-3"}),"Loading jobs"]}),e[48]=u.data,e[49]=u.loading,e[50]=D):D=e[50];let z;e[51]!==u.error?(z=u.error&&r.jsx("p",{className:"py-1 text-[11px] text-destructive",children:u.error.error}),e[51]=u.error,e[52]=z):z=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 L;if(e[58]!==p||e[59]!==o){let Y;e[61]!==o?(Y=X=>r.jsx(p$,{job:X,now:o},X.id),e[61]=o,e[62]=Y):Y=e[62],L=p.map(Y),e[58]=p,e[59]=o,e[60]=L}else L=e[60];let H;e[63]!==D||e[64]!==z||e[65]!==F||e[66]!==L?(H=r.jsx(dt,{children:r.jsxs("div",{className:"ml-[7px] border-l border-border py-1 pl-3 pr-1",children:[D,z,F,L]})}),e[63]=D,e[64]=z,e[65]=F,e[66]=L,e[67]=H):H=e[67];let U;return e[68]!==f||e[69]!==d||e[70]!==O||e[71]!==H?(U=r.jsxs(ct,{open:d,onOpenChange:f,children:[O,H]}),e[68]=f,e[69]=d,e[70]=O,e[71]=H,e[72]=U):U=e[72],U}function g$(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=u$(s.runs.map(o=>lf(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 x$(n){const e=B.c(41),{group:t,projectPath:s,now:o}=n,i=t.title,a=f$[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=fl(t.createdAt,o),e[13]=t.createdAt,e[14]=o,e[15]=g):g=e[15];let x;e[16]!==t.createdAt||e[17]!==h||e[18]!==g?(x=r.jsx("time",{className:"shrink-0",dateTime:p,title:h,children:g}),e[16]=t.createdAt,e[17]=h,e[18]=g,e[19]=x):x=e[19];let v;e[20]!==x||e[21]!==u||e[22]!==f?(v=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]=v):v=e[23];let y;e[24]!==v||e[25]!==d?(y=r.jsxs("header",{className:"mb-1 min-w-0",children:[d,v]}),e[24]=v,e[25]=d,e[26]=y):y=e[26];let b;if(e[27]!==t.runs||e[28]!==o||e[29]!==s){let k;e[31]!==o||e[32]!==s?(k=C=>r.jsx(h$,{run:C,projectPath:s,now:o},C.id),e[31]=o,e[32]=s,e[33]=k):k=e[33],b=t.runs.map(k),e[27]=t.runs,e[28]=o,e[29]=s,e[30]=b}else b=e[30];let j;e[34]!==b?(j=r.jsx("div",{className:"-ml-1 flex flex-col",children:b}),e[34]=b,e[35]=j):j=e[35];let S;return e[36]!==t.title||e[37]!==y||e[38]!==j||e[39]!==c?(S=r.jsxs("article",{className:"relative pl-3","aria-label":i,children:[c,y,j]}),e[36]=t.title,e[37]=y,e[38]=j,e[39]=c,e[40]=S):S=e[40],S}function b$(n,e){return e==="failed"?n.filter(t=>Ko(t.conclusion)):e==="all"?[...n]:n.filter(t=>t.branch===e.branch)}function v$(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 y$(n){const e=B.c(22),{data:t,filter:s,projectPath:o}=n;let i;e[0]!==t.runs||e[1]!==s?(i=b$(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=g$(a),e[3]=a,e[4]=l):l=e[4];const c=l;let d;e[5]!==c?(d=c.some(w$),e[5]=c,e[6]=d):d=e[6];const u=ml(d);if(t.runs.length===0){let p;return e[7]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(pl,{icon:Md,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=v$(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(x$,{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(Vn,{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 w$(n){return n.tone==="live"}function j$(n){const e=B.c(23),{data:t,projectPath:s,focus:o}=n,[i,a]=w.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]),w.useEffect(l,c);const d=t.runs;let u;e[3]!==d?(u=d.filter(S$),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(S=>S.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,v=x&&!m||i==="failed"&&f===0?"all":i;let y;e[8]!==m||e[9]!==h||e[10]!==x||e[11]!==v||e[12]!==f||e[13]!==g||e[14]!==d?(y=d.length>0&&r.jsxs(zr,{label:"Filter runs",children:[r.jsxs(bt,{pressed:v==="all",onClick:()=>a("all"),children:["All",r.jsx(vt,{children:d.length})]}),m&&r.jsxs(bt,{pressed:x&&v!=="all",disabled:h===0,onClick:()=>a({branch:m}),"aria-label":`Only runs on ${m}`,children:[r.jsx(fn,{className:"size-3"}),r.jsx("span",{className:"max-w-28 truncate",children:m}),r.jsx(vt,{children:h})]}),g&&r.jsxs(bt,{pressed:!0,onClick:()=>a("all"),"aria-label":`Only runs on ${g}`,children:[r.jsx(fn,{className:"size-3"}),r.jsx("span",{className:"max-w-28 truncate",children:g}),r.jsx(vt,{children:d.filter(S=>S.branch===g).length}),r.jsx(tt,{className:"size-3","aria-hidden":!0})]}),r.jsxs(bt,{pressed:v==="failed",disabled:f===0,onClick:()=>a("failed"),children:[r.jsx("span",{className:q(f>0&&"text-destructive"),children:"Failed"})," ",r.jsx(vt,{children:f})]})]}),e[8]=m,e[9]=h,e[10]=x,e[11]=v,e[12]=f,e[13]=g,e[14]=d,e[15]=y):y=e[15];let b;e[16]!==t||e[17]!==v||e[18]!==s?(b=r.jsx(y$,{data:t,filter:v,projectPath:s}),e[16]=t,e[17]=v,e[18]=s,e[19]=b):b=e[19];let j;return e[20]!==y||e[21]!==b?(j=r.jsxs(r.Fragment,{children:[y,b]}),e[20]=y,e[21]=b,e[22]=j):j=e[22],j}function S$(n){return Ko(n.conclusion)}const zb={open:"Open",completed:"Completed",not_planned:"Not planned"},N$={open:"bg-success",completed:"bg-info",not_planned:"bg-border"};function k$(n){const e=B.c(9),{state:t}=n,s=zb[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(Ed,{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(Hn,{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(Iw,{className:o,"aria-label":s}),e[7]=s,e[8]=i):i=e[8],i}function Fb(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 C$(n){const e=n.body.trim();return[`Work on GitHub issue #${n.number}: ${n.title}`,n.url,...e?["",e]:[]].join(`
122
+ `)}function _$(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(Z1,{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(Ld,{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 T$(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(eg,{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(Hr,{className:o,"aria-hidden":!0}),e[3]=o,e[4]=i):i=e[4],i}function E$(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(_$,{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(T$,{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(ub,{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 A$(n){const e=B.c(86),{issue:t,viewer:s,now:o,onPickLabel:i,onShowPull:a,composePrompt:l}=n,[c,d]=w.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=N$[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 v=`${t.title} #${t.number}: ${zb[t.state]}`;let y;e[6]!==t.state?(y=r.jsx(k$,{state:t.state}),e[6]=t.state,e[7]=y):y=e[7];const b=t.state!=="open"&&"text-muted-foreground";let j;e[8]!==b?(j=q("min-w-0 flex-1 truncate text-[13px] font-medium leading-5",b),e[8]=b,e[9]=j):j=e[9];let S;e[10]!==t.title||e[11]!==j?(S=r.jsx("span",{className:j,children:t.title}),e[10]=t.title,e[11]=j,e[12]=S):S=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]!==S||e[16]!==k||e[17]!==y?(C=r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[y,S,k]}),e[15]=S,e[16]=k,e[17]=y,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;e[21]!==t.labels?(E=t.labels.length>0&&r.jsxs("span",{className:"flex min-w-0 items-center gap-1 truncate",children:[t.labels.slice(0,3).map(P$),t.labels.length>3&&r.jsxs("span",{children:["+",t.labels.length-3]})]}),e[21]=t.labels,e[22]=E):E=e[22];let T;e[23]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx("span",{className:"shrink-0",children:"·"}),e[23]=T):T=e[23];let P;e[24]!==u?(P=new Date(u).toLocaleString(),e[24]=u,e[25]=P):P=e[25];let _;e[26]!==u||e[27]!==o?(_=fl(u,o),e[26]=u,e[27]=o,e[28]=_):_=e[28];let A;e[29]!==u||e[30]!==P||e[31]!==_?(A=r.jsx("time",{className:"shrink-0",dateTime:u,title:P,children:_}),e[29]=u,e[30]=P,e[31]=_,e[32]=A):A=e[32];let I;e[33]!==N||e[34]!==E||e[35]!==A?(I=r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 pl-[22px] text-[11px] leading-4 text-muted-foreground",children:[N,E,T,A]}),e[33]=N,e[34]=E,e[35]=A,e[36]=I):I=e[36];let $;e[37]!==c||e[38]!==C||e[39]!==I||e[40]!==v?($=r.jsxs(Rt,{className:"flex min-w-0 flex-1 flex-col rounded-sm px-1 py-1 text-left outline-none hover:bg-accent/60 focus-visible:ring-[3px] focus-visible:ring-ring/20","aria-label":v,"aria-expanded":c,children:[C,I]}),e[37]=c,e[38]=C,e[39]=I,e[40]=v,e[41]=$):$=e[41];let R;e[42]!==t||e[43]!==a||e[44]!==s?(R=r.jsx(E$,{issue:t,viewer:s,onShowPull:a}),e[42]=t,e[43]=a,e[44]=s,e[45]=R):R=e[45];const M=`Open #${t.number} on GitHub`;let O;e[46]!==t.url?(O=()=>window.open(t.url,"_blank","noopener,noreferrer"),e[46]=t.url,e[47]=O):O=e[47];let D;e[48]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(nn,{}),e[48]=D):D=e[48];let z;e[49]!==M||e[50]!==O?(z=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:O,children:D}),e[49]=M,e[50]=O,e[51]=z):z=e[51];let F;e[52]!==R||e[53]!==z?(F=r.jsxs("div",{className:"mt-1 flex shrink-0 items-center gap-1",children:[R,z]}),e[52]=R,e[53]=z,e[54]=F):F=e[54];let L;e[55]!==$||e[56]!==F?(L=r.jsxs("div",{className:"group/issue flex items-start gap-1 pr-1",children:[$,F]}),e[55]=$,e[56]=F,e[57]=L):L=e[57];let H;e[58]!==m?(H=m?r.jsx(Qu,{body:m}):r.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"No description."}),e[58]=m,e[59]=H):H=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(Q=>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(Q.name),"aria-label":`Only issues labeled ${Q.name}`,children:[r.jsx(Fb,{label:Q}),Q.name]})},Q.name))}),e[60]=t.labels,e[61]=i,e[62]=U):U=e[62];let W;e[63]!==l||e[64]!==t?(W=l&&r.jsxs(ee,{type:"button",size:"xs",onClick:()=>l(C$(t)),children:[r.jsx(Q1,{"data-icon":"inline-start"}),"Add to prompt"]}),e[63]=l,e[64]=t,e[65]=W):W=e[65];let V;e[66]!==t.url?(V=r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer"}),e[66]=t.url,e[67]=V):V=e[67];let K;e[68]===Symbol.for("react.memo_cache_sentinel")?(K=r.jsx(nn,{"data-icon":"inline-end"}),e[68]=K):K=e[68];let Y;e[69]!==V?(Y=r.jsxs(ee,{variant:"outline",size:"xs",render:V,children:["Open issue on GitHub",K]}),e[69]=V,e[70]=Y):Y=e[70];let X;e[71]!==W||e[72]!==Y?(X=r.jsxs("div",{className:"flex flex-wrap gap-2",children:[W,Y]}),e[71]=W,e[72]=Y,e[73]=X):X=e[73];let G;e[74]!==H||e[75]!==U||e[76]!==X?(G=r.jsx(dt,{children:r.jsxs("div",{className:"flex flex-col gap-3 py-2 pl-[22px] pr-1",children:[H,U,X]})}),e[74]=H,e[75]=U,e[76]=X,e[77]=G):G=e[77];let J;e[78]!==c||e[79]!==L||e[80]!==G?(J=r.jsxs(ct,{open:c,onOpenChange:d,children:[L,G]}),e[78]=c,e[79]=L,e[80]=G,e[81]=J):J=e[81];let Z;return e[82]!==t.title||e[83]!==J||e[84]!==x?(Z=r.jsxs("article",{className:"relative pl-3","aria-label":p,children:[x,J]}),e[82]=t.title,e[83]=J,e[84]=x,e[85]=Z):Z=e[85],Z}function P$(n){return r.jsxs("span",{className:"flex items-center gap-1 truncate",children:[r.jsx(Fb,{label:n}),r.jsx("span",{className:"truncate",children:n.name})]},n.name)}function Uh(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 I$(n){const e=B.c(75),{data:t,composePrompt:s,onShowPulls:o}=n,[i,a]=w.useState("all"),[l,c]=w.useState(null),d=ml(!1),u=t.viewer;let f;e[0]!==t.issues||e[1]!==u?(f=$=>t.issues.filter(R=>Uh(R,$,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 v;e[7]!==m?(v=m("unassigned"),e[7]=m,e[8]=v):v=e[8];const y=v,b=i==="assigned"&&h===0||i==="opened"&&x===0||i==="unassigned"&&y===0?"all":i,j=t.issues;let S,k,C,N,E,T,P;if(e[9]!==h||e[10]!==s||e[11]!==t.issues||e[12]!==b||e[13]!==l||e[14]!==d||e[15]!==o||e[16]!==x||e[17]!==y||e[18]!==u){C=Symbol.for("react.early_return_sentinel");e:{let $;e[26]!==b||e[27]!==l||e[28]!==u?($=te=>Uh(te,b,u)&&(l===null||te.labels.some(ne=>ne.name===l)),e[26]=b,e[27]=l,e[28]=u,e[29]=$):$=e[29];const R=j.filter($),M=R.filter($$),O=R.filter(R$);if(t.issues.length===0){let te;e[30]===Symbol.for("react.memo_cache_sentinel")?(te=r.jsx(pl,{icon:Ed,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 D;e[31]!==s||e[32]!==d||e[33]!==o||e[34]!==u?(D=te=>r.jsx(A$,{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]=D):D=e[35];const z=D,F=b==="all";let L;e[36]===Symbol.for("react.memo_cache_sentinel")?(L=()=>a("all"),e[36]=L):L=e[36];let H;e[37]!==t.issues.length?(H=r.jsx(vt,{children:t.issues.length}),e[37]=t.issues.length,e[38]=H):H=e[38];let U;e[39]!==F||e[40]!==H?(U=r.jsxs(bt,{pressed:F,onClick:L,children:["All",H]}),e[39]=F,e[40]=H,e[41]=U):U=e[41];let W;e[42]!==h||e[43]!==b||e[44]!==u?(W=u&&r.jsxs(bt,{pressed:b==="assigned",disabled:h===0,onClick:()=>a("assigned"),"aria-label":"Only issues assigned to you",children:[r.jsx(Z1,{className:"size-3"}),"Mine",r.jsx(vt,{children:h})]}),e[42]=h,e[43]=b,e[44]=u,e[45]=W):W=e[45];let V;e[46]!==b||e[47]!==x||e[48]!==u?(V=u&&r.jsxs(bt,{pressed:b==="opened",disabled:x===0,onClick:()=>a("opened"),"aria-label":"Only issues you opened",children:[r.jsx(Ld,{className:"size-3"}),"Opened",r.jsx(vt,{children:x})]}),e[46]=b,e[47]=x,e[48]=u,e[49]=V):V=e[49];const K=b==="unassigned",Y=y===0;let X;e[50]===Symbol.for("react.memo_cache_sentinel")?(X=()=>a("unassigned"),e[50]=X):X=e[50];let G;e[51]===Symbol.for("react.memo_cache_sentinel")?(G=r.jsx(Pw,{className:"size-3"}),e[51]=G):G=e[51];let J;e[52]!==y?(J=r.jsx(vt,{children:y}),e[52]=y,e[53]=J):J=e[53];let Z;e[54]!==K||e[55]!==Y||e[56]!==J?(Z=r.jsxs(bt,{pressed:K,disabled:Y,onClick:X,"aria-label":"Only unassigned issues",children:[G,"Unassigned",J]}),e[54]=K,e[55]=Y,e[56]=J,e[57]=Z):Z=e[57];const Q=l&&r.jsxs(bt,{pressed:!0,onClick:()=>c(null),"aria-label":`Clear label filter ${l}`,children:[r.jsx("span",{className:"max-w-28 truncate",children:l}),r.jsx(vt,{children:R.length}),r.jsx(tt,{className:"size-3","aria-hidden":!0})]});e[58]!==U||e[59]!==W||e[60]!==V||e[61]!==Z||e[62]!==Q?(k=r.jsxs(zr,{label:"Filter issues",children:[U,W,V,Z,Q]}),e[58]=U,e[59]=W,e[60]=V,e[61]=Z,e[62]=Q,e[63]=k):k=e[63],S=Vn,P="min-h-0 flex-1",N="flex flex-col gap-4 px-3 py-3",E=M.length===0?r.jsx("p",{className:"px-1 py-3 text-center text-xs text-muted-foreground",children:"Nothing open here."}):M.map(z),T=O.length>0&&r.jsx(Ju,{count:O.length,children:O.map(z)})}e[9]=h,e[10]=s,e[11]=t.issues,e[12]=b,e[13]=l,e[14]=d,e[15]=o,e[16]=x,e[17]=y,e[18]=u,e[19]=S,e[20]=k,e[21]=C,e[22]=N,e[23]=E,e[24]=T,e[25]=P}else S=e[19],k=e[20],C=e[21],N=e[22],E=e[23],T=e[24],P=e[25];if(C!==Symbol.for("react.early_return_sentinel"))return C;let _;e[64]!==N||e[65]!==E||e[66]!==T?(_=r.jsxs("div",{className:N,children:[E,T]}),e[64]=N,e[65]=E,e[66]=T,e[67]=_):_=e[67];let A;e[68]!==S||e[69]!==_||e[70]!==P?(A=r.jsx(S,{className:P,children:_}),e[68]=S,e[69]=_,e[70]=P,e[71]=A):A=e[71];let I;return e[72]!==k||e[73]!==A?(I=r.jsxs(r.Fragment,{children:[k,A]}),e[72]=k,e[73]=A,e[74]=I):I=e[74],I}function R$(n){return n.state!=="open"}function $$(n){return n.state==="open"}const Bb={open:"Open",draft:"Draft",merged:"Merged",closed:"Closed"},M$={open:"bg-success",draft:"bg-border",merged:"bg-info",closed:"bg-destructive"};function qs(n){return n.state==="open"||n.state==="draft"}function L$(n){const e=B.c(12),{state:t}=n,s=Bb[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(Hr,{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($d,{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(eg,{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(Rw,{className:o,"aria-label":s}),e[10]=s,e[11]=i):i=e[11],i}function Wh(n){return n==="success"?"Checks passed":n==="failure"?"Checks failed":"Checks running"}function O$(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(at,{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(tt,{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(Mo,{className:"size-3 text-info"}),e[2]=s):s=e[2],s}function D$(n){return n.reviewRequested?{icon:r.jsx(js,{className:"size-3 text-info"}),label:"Your review is requested"}:n.review==="approved"?{icon:r.jsx(Br,{className:"size-3 text-success"}),label:"Approved"}:n.review==="changes_requested"?{icon:r.jsx(Xt,{className:"size-3 text-warning"}),label:"Changes requested"}:n.review==="review_required"&&qs(n)?{icon:r.jsx(js,{className:"size-3 text-muted-foreground"}),label:"Review required"}:null}function z$(n){const e=B.c(17),{pull:t,onShowChecks:s}=n;let o;e[0]!==t?(o=D$(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":`${Wh(t.checks)}, show runs`,title:Wh(t.checks),onClick:()=>s(t.headBranch),children:r.jsx(O$,{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(mn,{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(ub,{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 F$(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 B$(n){const e=n.lastIndexOf("/");return e===-1?{directory:"",name:n}:{directory:n.slice(0,e+1),name:n.slice(e+1)}}function U$(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:j,className:S}=F$(t.status);o=j;let k;e[8]!==t.path?(k=B$(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",S),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 v;e[26]!==t.deletions?(v=t.deletions>0&&r.jsxs("span",{className:"text-destructive",children:["−",t.deletions]}),e[26]=t.deletions,e[27]=v):v=e[27];let y;e[28]!==g||e[29]!==x||e[30]!==v?(y=r.jsxs("span",{className:"shrink-0 text-[10px] tabular-nums",children:[g,x,v]}),e[28]=g,e[29]=x,e[30]=v,e[31]=y):y=e[31];let b;return e[32]!==y||e[33]!==l||e[34]!==c||e[35]!==d||e[36]!==h?(b=r.jsxs("li",{className:l,title:c,children:[d,h,y]}),e[32]=y,e[33]=l,e[34]=c,e[35]=d,e[36]=h,e[37]=b):b=e[37],b}function W$(n){var S,k,C,N,E,T;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]!==((S=s.data)==null?void 0:S.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(Qu,{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(nt,{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(H$)}),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=((E=s.data)==null?void 0:E.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]=(T=s.data)==null?void 0:T.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 v;e[31]!==t.url?(v=r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer"}),e[31]=t.url,e[32]=v):v=e[32];let y;e[33]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(nn,{"data-icon":"inline-end"}),e[33]=y):y=e[33];let b;e[34]!==v?(b=r.jsxs(ee,{variant:"outline",size:"xs",className:"self-start",render:v,children:["Open pull request on GitHub",y]}),e[34]=v,e[35]=b):b=e[35];let j;return e[36]!==x||e[37]!==b||e[38]!==c?(j=r.jsxs("div",{className:"flex flex-col gap-3 py-2 pl-[22px] pr-1",children:[c,x,b]}),e[36]=x,e[37]=b,e[38]=c,e[39]=j):j=e[39],j}function H$(n){return r.jsx(U$,{file:n},n.path)}function q$(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(Cc,{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 K$(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=()=>l$(s,t.number),e[0]=s,e[1]=t.number,e[2]=d):d=e[2];const{open:u,state:f,onOpenChange:m}=Db(d,"Unable to load changed files"),p=o!==null&&t.headBranch===o,h=qs(t)?t.updatedAt:t.closedAt??t.updatedAt,g=t.title,x=M$[t.state];let v;e[3]!==x?(v=q("absolute inset-y-1 left-0 w-0.5 rounded-full",x),e[3]=x,e[4]=v):v=e[4];let y;e[5]!==v?(y=r.jsx("span",{"aria-hidden":!0,className:v}),e[5]=v,e[6]=y):y=e[6];const b=`${t.title} #${t.number}: ${Bb[t.state]}`;let j;e[7]!==t.state?(j=r.jsx(L$,{state:t.state}),e[7]=t.state,e[8]=j):j=e[8];let S;e[9]!==t?(S=!qs(t)&&"text-muted-foreground",e[9]=t,e[10]=S):S=e[10];let k;e[11]!==S?(k=q("min-w-0 flex-1 truncate text-[13px] font-medium leading-5",S),e[11]=S,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;e[18]!==C||e[19]!==N||e[20]!==j?(E=r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[j,C,N]}),e[18]=C,e[19]=N,e[20]=j,e[21]=E):E=e[21];let T;e[22]!==t.author?(T=t.author&&r.jsx("span",{className:"shrink-0",children:t.author}),e[22]=t.author,e[23]=T):T=e[23];let P;e[24]!==p?(P=p&&r.jsx(fn,{className:"size-3 shrink-0 text-foreground","aria-label":"Current branch"}),e[24]=p,e[25]=P):P=e[25];const _=p&&"text-foreground";let A;e[26]!==_?(A=q("truncate",_),e[26]=_,e[27]=A):A=e[27];let I;e[28]!==t.headBranch||e[29]!==A?(I=r.jsx("span",{className:A,children:t.headBranch}),e[28]=t.headBranch,e[29]=A,e[30]=I):I=e[30];let $;e[31]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx($w,{className:"size-3 shrink-0","aria-hidden":!0}),e[31]=$):$=e[31];let R;e[32]!==t.baseBranch?(R=r.jsx("span",{className:"max-w-24 shrink-0 truncate",children:t.baseBranch}),e[32]=t.baseBranch,e[33]=R):R=e[33];let M;e[34]!==P||e[35]!==I||e[36]!==R?(M=r.jsxs("span",{className:"flex min-w-0 items-center gap-1 font-mono",children:[P,I,$,R]}),e[34]=P,e[35]=I,e[36]=R,e[37]=M):M=e[37];let O;e[38]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsx("span",{className:"shrink-0",children:"·"}),e[38]=O):O=e[38];let D;e[39]!==h?(D=new Date(h).toLocaleString(),e[39]=h,e[40]=D):D=e[40];let z;e[41]!==h||e[42]!==c?(z=fl(h,c),e[41]=h,e[42]=c,e[43]=z):z=e[43];let F;e[44]!==h||e[45]!==D||e[46]!==z?(F=r.jsx("time",{className:"shrink-0",dateTime:h,title:D,children:z}),e[44]=h,e[45]=D,e[46]=z,e[47]=F):F=e[47];let L;e[48]!==T||e[49]!==M||e[50]!==F?(L=r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 pl-[22px] text-[11px] leading-4 text-muted-foreground",children:[T,M,O,F]}),e[48]=T,e[49]=M,e[50]=F,e[51]=L):L=e[51];let H;e[52]!==u||e[53]!==E||e[54]!==L||e[55]!==b?(H=r.jsxs(Rt,{className:"flex min-w-0 flex-1 flex-col rounded-sm px-1 py-1 text-left outline-none hover:bg-accent/60 focus-visible:ring-[3px] focus-visible:ring-ring/20","aria-label":b,"aria-expanded":u,children:[E,L]}),e[52]=u,e[53]=E,e[54]=L,e[55]=b,e[56]=H):H=e[56];let U;e[57]!==l||e[58]!==t?(U=r.jsx(z$,{pull:t,onShowChecks:l}),e[57]=l,e[58]=t,e[59]=U):U=e[59];const W=`Open #${t.number} on GitHub`;let V;e[60]!==t.url?(V=()=>window.open(t.url,"_blank","noopener,noreferrer"),e[60]=t.url,e[61]=V):V=e[61];let K;e[62]===Symbol.for("react.memo_cache_sentinel")?(K=r.jsx(nn,{}),e[62]=K):K=e[62];let Y;e[63]!==W||e[64]!==V?(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":W,onClick:V,children:K}),e[63]=W,e[64]=V,e[65]=Y):Y=e[65];let X;e[66]!==U||e[67]!==Y?(X=r.jsxs("div",{className:"mt-1 flex shrink-0 items-center gap-1",children:[U,Y]}),e[66]=U,e[67]=Y,e[68]=X):X=e[68];let G;e[69]!==H||e[70]!==X?(G=r.jsxs("div",{className:"group/pull flex items-start gap-1 pr-1",children:[H,X]}),e[69]=H,e[70]=X,e[71]=G):G=e[71];let J;e[72]!==a||e[73]!==i?(J=i.length>0&&r.jsx(q$,{sessions:i,openSession:a}),e[72]=a,e[73]=i,e[74]=J):J=e[74];let Z;e[75]!==f||e[76]!==t?(Z=r.jsx(dt,{children:r.jsx(W$,{pull:t,files:f})}),e[75]=f,e[76]=t,e[77]=Z):Z=e[77];let Q;e[78]!==m||e[79]!==u||e[80]!==G||e[81]!==J||e[82]!==Z?(Q=r.jsxs(ct,{open:u,onOpenChange:m,children:[G,J,Z]}),e[78]=m,e[79]=u,e[80]=G,e[81]=J,e[82]=Z,e[83]=Q):Q=e[83];let te;return e[84]!==t.title||e[85]!==Q||e[86]!==y?(te=r.jsxs("article",{className:"relative pl-3","aria-label":g,children:[y,Q]}),e[84]=t.title,e[85]=Q,e[86]=y,e[87]=te):te=e[87],te}function V$(n,e,t){return e==="mine"?n.filter(s=>s.author===t.viewer):e==="branch"?n.filter(s=>s.headBranch===t.branch):[...n]}function G$(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 Y$(n){const e=B.c(61),{data:t,sessions:s,projectPath:o,openSession:i,onShowChecks:a}=n,[l,c]=w.useState("all"),d=ml(!1);let u;e[0]!==s?(u=G$(s),e[0]=s,e[1]=u):u=e[1];const f=u;let m;e[2]!==t.pulls||e[3]!==t.viewer?(m=t.viewer?t.pulls.filter(P=>P.author===t.viewer).length:0,e[2]=t.pulls,e[3]=t.viewer,e[4]=m):m=e[4];const p=m;let h;e[5]!==t.branch||e[6]!==t.pulls?(h=t.branch?t.pulls.filter(P=>P.headBranch===t.branch).length:0,e[5]=t.branch,e[6]=t.pulls,e[7]=h):h=e[7];const g=h,x=l==="mine"&&p===0||l==="branch"&&g===0?"all":l;let v,y,b,j,S,k,C;if(e[8]!==g||e[9]!==t||e[10]!==x||e[11]!==f||e[12]!==p||e[13]!==d||e[14]!==a||e[15]!==i||e[16]!==o){C=Symbol.for("react.early_return_sentinel");e:{const P=V$(t.pulls,x,t),_=P.filter(qs),A=P.filter(X$);if(t.pulls.length===0){let L;e[24]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(pl,{icon:Hr,title:"No pull requests yet",description:"Open one from a branch and it will show up here."}),e[24]=L):L=e[24],C=L;break e}let I;e[25]!==t.branch||e[26]!==f||e[27]!==d||e[28]!==a||e[29]!==i||e[30]!==o?(I=L=>r.jsx(K$,{pull:L,projectPath:o,currentBranch:t.branch,sessions:f.get(L.number)??[],openSession:i,onShowChecks:a,now:d},L.number),e[25]=t.branch,e[26]=f,e[27]=d,e[28]=a,e[29]=i,e[30]=o,e[31]=I):I=e[31];const $=I,R=x==="all";let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=()=>c("all"),e[32]=M):M=e[32];let O;e[33]!==t.pulls.length?(O=r.jsx(vt,{children:t.pulls.length}),e[33]=t.pulls.length,e[34]=O):O=e[34];let D;e[35]!==R||e[36]!==O?(D=r.jsxs(bt,{pressed:R,onClick:M,children:["All",O]}),e[35]=R,e[36]=O,e[37]=D):D=e[37];let z;e[38]!==t.viewer||e[39]!==x||e[40]!==p?(z=t.viewer&&r.jsxs(bt,{pressed:x==="mine",disabled:p===0,onClick:()=>c("mine"),"aria-label":`Only pull requests by ${t.viewer}`,children:[r.jsx(Ld,{className:"size-3"}),"Mine",r.jsx(vt,{children:p})]}),e[38]=t.viewer,e[39]=x,e[40]=p,e[41]=z):z=e[41];let F;e[42]!==g||e[43]!==t.branch||e[44]!==x?(F=t.branch&&r.jsxs(bt,{pressed:x==="branch",disabled:g===0,onClick:()=>c("branch"),"aria-label":`Only pull requests from ${t.branch}`,children:[r.jsx(fn,{className:"size-3"}),r.jsx("span",{className:"max-w-28 truncate",children:t.branch}),r.jsx(vt,{children:g})]}),e[42]=g,e[43]=t.branch,e[44]=x,e[45]=F):F=e[45],e[46]!==D||e[47]!==z||e[48]!==F?(k=r.jsxs(zr,{label:"Filter pull requests",children:[D,z,F]}),e[46]=D,e[47]=z,e[48]=F,e[49]=k):k=e[49],v=Vn,S="min-h-0 flex-1",y="flex flex-col gap-4 px-3 py-3",b=_.length===0?r.jsx("p",{className:"px-1 py-3 text-center text-xs text-muted-foreground",children:"Nothing open right now."}):_.map($),j=A.length>0&&r.jsx(Ju,{count:A.length,children:A.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]=v,e[18]=y,e[19]=b,e[20]=j,e[21]=S,e[22]=k,e[23]=C}else v=e[17],y=e[18],b=e[19],j=e[20],S=e[21],k=e[22],C=e[23];if(C!==Symbol.for("react.early_return_sentinel"))return C;let N;e[50]!==y||e[51]!==b||e[52]!==j?(N=r.jsxs("div",{className:y,children:[b,j]}),e[50]=y,e[51]=b,e[52]=j,e[53]=N):N=e[53];let E;e[54]!==v||e[55]!==N||e[56]!==S?(E=r.jsx(v,{className:S,children:N}),e[54]=v,e[55]=N,e[56]=S,e[57]=E):E=e[57];let T;return e[58]!==E||e[59]!==k?(T=r.jsxs(r.Fragment,{children:[k,E]}),e[58]=E,e[59]=k,e[60]=T):T=e[60],T}function X$(n){return!qs(n)}const J$={actions:"Refresh GitHub Actions",pulls:"Refresh pull requests",issues:"Refresh issues"};function Q$(n){return n==="actions"||n==="pulls"||n==="issues"}function Z$(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 eM(n){const e=B.c(3),{label:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=[0,1,2].map(tM),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 tM(n){return r.jsxs("div",{className:"flex flex-col gap-2 border-l-2 border-border pl-3",children:[r.jsx(it,{className:"h-3.5 w-3/4"}),r.jsx(it,{className:"h-2.5 w-1/2"}),r.jsx(it,{className:"h-3 w-full"}),r.jsx(it,{className:"h-3 w-full"})]},n)}function cc(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(Xt,{}),e[5]=l):l=e[5];let c;e[6]!==t.error.error?(c=r.jsx(Et,{children:t.error.error}),e[6]=t.error.error,e[7]=c):c=e[7];let d;e[8]!==t.error?(d=Z$(t.error),e[8]=t.error,e[9]=d):d=e[9];let u;e[10]!==d?(u=r.jsx("span",{children:d}),e[10]=d,e[11]=u):u=e[11];let f;e[12]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(Pt,{"data-icon":"inline-start"}),e[12]=f):f=e[12];let m;e[13]!==o?(m=r.jsxs(ee,{type:"button",variant:"outline",size:"xs",onClick:o,children:[f,"Try again"]}),e[13]=o,e[14]=m):m=e[14];let p;e[15]!==u||e[16]!==m?(p=r.jsxs(ft,{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(ut,{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(eM,{label:s}),e[21]=s,e[22]=a):a=e[22],a}function dc(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 nM(n){var f,m,p,h;const e=B.c(11),{context:t}=n,s=t.projectPath!==null,{data:o}=Mb(t.projectPath,s),i=Lb(t.projectPath,s);let a;e[0]!==(o==null?void 0:o.runs)?(a=(o==null?void 0:o.runs.filter(oM).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?Ko(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(sM).length)??0,e[2]=(h=i.data)==null?void 0:h.pulls,e[3]=d):d=e[3];const u=d;if(l>0){const g=`${l} active GitHub Actions run${l===1?"":"s"}`;let x;return e[4]!==l||e[5]!==g?(x=r.jsx(Pe,{className:"absolute -right-1 -top-1 min-w-4 px-1 text-[9px]","aria-label":g,children:l}),e[4]=l,e[5]=g,e[6]=x):x=e[6],x}if(c){let g;return e[7]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx(Pe,{variant:"destructive",className:"absolute -right-0.5 -top-0.5 size-3 p-0 text-[8px]","aria-label":"Latest GitHub Actions run failed",children:"!"}),e[7]=g):g=e[7],g}if(u>0){const g=`${u} pull request${u===1?"":"s"} waiting for your review`;let x;return e[8]!==u||e[9]!==g?(x=r.jsx(Pe,{variant:"secondary",className:"absolute -right-1 -top-1 min-w-4 px-1 text-[9px]","aria-label":g,children:u}),e[8]=u,e[9]=g,e[10]=x):x=e[10],x}return null}function sM(n){return qs(n)&&n.reviewRequested}function oM(n){return mi(n.status)}function rM(n){const e=B.c(78),{context:t,active:s,closePanel:o}=n,[i,a]=w.useState("actions"),[l,c]=w.useState(null),d=t.projectPath,u=Mb(d,s),f=Lb(d,s),m=i$(d,s&&i==="pulls"),p=r$(d,s&&i==="issues");let h;e[0]!==p||e[1]!==f||e[2]!==u?(h={actions:u,pulls:f,issues:p},e[0]=p,e[1]=f,e[2]=u,e[3]=h):h=e[3];const g=h[i];let x;e[4]===Symbol.for("react.memo_cache_sentinel")?(x=function(oe){c({branch:oe}),a("actions")},e[4]=x):x=e[4];const v=x,y=u.data??f.data??p.data;let b;e[5]!==u.data?(b=u.data?u.data.runs.filter(aM).length:null,e[5]=u.data,e[6]=b):b=e[6];const j=b;let S;e[7]!==f.data?(S=f.data?f.data.pulls.filter(qs).length:null,e[7]=f.data,e[8]=S):S=e[8];const k=S;let C;e[9]!==p.data?(C=p.data?p.data.issues.filter(iM).length:null,e[9]=p.data,e[10]=C):C=e[10];const N=C;let E;e[11]===Symbol.for("react.memo_cache_sentinel")?(E=ne=>{Q$(ne)&&a(ne)},e[11]=E):E=e[11];let T;e[12]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx("h2",{className:"text-sm font-medium leading-tight",children:"GitHub"}),e[12]=T):T=e[12];let P;e[13]!==y||e[14]!==i?(P=r.jsxs("div",{className:"min-w-0 flex-1",children:[T,y?r.jsxs("a",{href:`${y.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:y.repository}),r.jsx(nn,{className:"size-3 shrink-0"})]}):r.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:"Current repository"})]}),e[13]=y,e[14]=i,e[15]=P):P=e[15];let _;e[16]!==g?(_=()=>{g.refresh()},e[16]=g,e[17]=_):_=e[17];const A=g.loading||g.refreshing||!d,I=J$[i];let $;e[18]!==g.refreshing?($=g.refreshing?r.jsx(nt,{}):r.jsx(Pt,{}),e[18]=g.refreshing,e[19]=$):$=e[19];let R;e[20]!==A||e[21]!==I||e[22]!==$||e[23]!==_?(R=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:_,disabled:A,"aria-label":I,children:$}),e[20]=A,e[21]=I,e[22]=$,e[23]=_,e[24]=R):R=e[24];let M;e[25]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(tt,{}),e[25]=M):M=e[25];let O;e[26]!==o?(O=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:o,"aria-label":"Close GitHub",children:M}),e[26]=o,e[27]=O):O=e[27];let D;e[28]!==R||e[29]!==O||e[30]!==P?(D=r.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b pl-4 pr-2",children:[P,R,O]}),e[28]=R,e[29]=O,e[30]=P,e[31]=D):D=e[31];let z;e[32]!==j?(z=r.jsxs(Dn,{value:"actions",className:"h-full flex-none rounded-none px-0 text-xs",children:["Actions",r.jsx(dc,{value:j,attention:!0})]}),e[32]=j,e[33]=z):z=e[33];let F;e[34]!==k?(F=r.jsxs(Dn,{value:"pulls",className:"h-full flex-none rounded-none px-0 text-xs",children:["Pull requests",r.jsx(dc,{value:k})]}),e[34]=k,e[35]=F):F=e[35];let L;e[36]!==N?(L=r.jsxs(Dn,{value:"issues",className:"h-full flex-none rounded-none px-0 text-xs",children:["Issues",r.jsx(dc,{value:N})]}),e[36]=N,e[37]=L):L=e[37];let H;e[38]!==z||e[39]!==F||e[40]!==L?(H=r.jsx("div",{className:"flex h-9 shrink-0 items-end border-b px-3",children:r.jsxs(Va,{variant:"line",className:"h-full gap-3 p-0","aria-label":"GitHub views",children:[z,F,L]})}),e[38]=z,e[39]=F,e[40]=L,e[41]=H):H=e[41];let U;e[42]!==u?(U=()=>{u.refresh()},e[42]=u,e[43]=U):U=e[43];let W;e[44]!==l||e[45]!==d?(W=ne=>d&&r.jsx(j$,{data:ne,projectPath:d,focus:l}),e[44]=l,e[45]=d,e[46]=W):W=e[46];let V;e[47]!==u||e[48]!==U||e[49]!==W?(V=r.jsx(zn,{value:"actions",className:"flex min-h-0 flex-col",children:r.jsx(cc,{state:u,loadingLabel:"Loading workflow runs",onRetry:U,children:W})}),e[47]=u,e[48]=U,e[49]=W,e[50]=V):V=e[50];let K;e[51]!==f?(K=()=>{f.refresh()},e[51]=f,e[52]=K):K=e[52];let Y;e[53]!==t.openSession||e[54]!==d||e[55]!==m?(Y=ne=>{var oe;return d&&r.jsx(Y$,{data:ne,sessions:((oe=m.data)==null?void 0:oe.sessions)??[],projectPath:d,openSession:t.openSession,onShowChecks:v})},e[53]=t.openSession,e[54]=d,e[55]=m,e[56]=Y):Y=e[56];let X;e[57]!==f||e[58]!==K||e[59]!==Y?(X=r.jsx(zn,{value:"pulls",className:"flex min-h-0 flex-col",children:r.jsx(cc,{state:f,loadingLabel:"Loading pull requests",onRetry:K,children:Y})}),e[57]=f,e[58]=K,e[59]=Y,e[60]=X):X=e[60];let G;e[61]!==p?(G=()=>{p.refresh()},e[61]=p,e[62]=G):G=e[62];let J;e[63]!==t.composePrompt?(J=ne=>r.jsx(I$,{data:ne,composePrompt:t.composePrompt,onShowPulls:()=>a("pulls")}),e[63]=t.composePrompt,e[64]=J):J=e[64];let Z;e[65]!==p||e[66]!==G||e[67]!==J?(Z=r.jsx(zn,{value:"issues",className:"flex min-h-0 flex-col",children:r.jsx(cc,{state:p,loadingLabel:"Loading issues",onRetry:G,children:J})}),e[65]=p,e[66]=G,e[67]=J,e[68]=Z):Z=e[68];let Q;e[69]!==V||e[70]!==X||e[71]!==Z?(Q=r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[V,X,Z]}),e[69]=V,e[70]=X,e[71]=Z,e[72]=Q):Q=e[72];let te;return e[73]!==D||e[74]!==H||e[75]!==Q||e[76]!==i?(te=r.jsxs(Ka,{value:i,onValueChange:E,className:"size-full min-h-0 gap-0","aria-label":"GitHub panel",children:[D,H,Q]}),e[73]=D,e[74]=H,e[75]=Q,e[76]=i,e[77]=te):te=e[77],te}function iM(n){return n.state==="open"}function aM(n){return mi(n.status)}const lM={id:"github",workspacePanels:[{id:"repository",title:"GitHub",icon:I1,component:rM,indicator:nM,order:40,defaultSize:"38%",minSize:"360px",maxSize:"62%",when:n=>n.canAccessHostFiles&&n.projectPath!==null}]},uf={data:null,error:null,loading:!1,refreshing:!1},Hh=new Map,cM=8e3,dM=1e4,uM=new Set(["vercel_access_denied","vercel_auth_required","vercel_cli_too_old","vercel_missing","vercel_project_unlinked"]);function ff(n){let e=Hh.get(n);return e||(e={snapshot:uf,listeners:new Set,request:null,fetchedAt:0},Hh.set(n,e)),e}function uc(n,e){n.snapshot=e;for(const t of n.listeners)t()}async function Ub(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 fc(n,e=!1){const t=ff(n);if(t.request)return t.request;if(!(!e&&t.snapshot.error&&uM.has(t.snapshot.error.code))&&!(!e&&t.fetchedAt>0&&Date.now()-t.fetchedAt<cM))return uc(t,{...t.snapshot,error:null,loading:t.snapshot.data===null,refreshing:t.snapshot.data!==null}),t.request=Ne(`/api/vercel-deployments?cwd=${encodeURIComponent(n)}&limit=20`).then(async s=>{if(!s.ok)throw await Ub(s);const o=await s.json();t.fetchedAt=Date.now(),uc(t,{data:o,error:null,loading:!1,refreshing:!1})}).catch(s=>{const o=s;uc(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 fM(n,e){if(!n)return()=>{};const t=ff(n);return t.listeners.add(e),()=>t.listeners.delete(e)}function mM(n){return n?ff(n).snapshot:uf}function Wb(n,e){const t=B.c(13),s=n??"";let o;t[0]!==s?(o=m=>fM(s,m),t[0]=s,t[1]=o):o=t[1];let i;t[2]!==s?(i=()=>mM(s),t[2]=s,t[3]=i):i=t[3];const a=w.useSyncExternalStore(o,i,pM);let l,c;t[4]!==e||t[5]!==s?(l=()=>{if(!e||!s)return;fc(s);const m=window.setInterval(()=>{fc(s)},dM);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]),w.useEffect(l,c);let d;t[8]!==s?(d=()=>s?fc(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 pM(){return uf}async function hM(n,e){const t=await Ne(`/api/vercel-deployments/build-logs?cwd=${encodeURIComponent(n)}&deploymentId=${encodeURIComponent(e)}&limit=200`);if(!t.ok)throw await Ub(t);return t.json()}const gM={live:"bg-info motion-safe:animate-pulse",fail:"bg-destructive",pass:"bg-success"};function pi(n){return n==="BUILDING"||n==="INITIALIZING"||n==="QUEUED"}function xl(n){return n==="BLOCKED"||n==="CANCELED"||n==="ERROR"}function Ro(n){return n.target==="production"}function Hb(n){return pi(n)?"live":xl(n)?"fail":"pass"}function mf(n){return n==="READY"?"Ready":n==="BUILDING"?"Building":n==="INITIALIZING"?"Initializing":n==="QUEUED"?"Queued":n==="CANCELED"?"Canceled":n==="BLOCKED"?"Blocked":"Failed"}function qb(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 xM(n,e){const t=n.buildingAt??n.createdAt,s=n.readyAt??(pi(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 bM(n){const e=B.c(3),[t,s]=w.useState(vM);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]),w.useEffect(o,i),t}function vM(){return Date.now()}function pf(n){if(!n)return null;try{return new URL(n).host}catch{return null}}function id(n){return n.commitMessage.split(`
123
+ `)[0]||pf(n.url)||`${mf(n.state)} deployment`}function yM(n){return[n.errorCode,n.errorMessage].filter(Boolean).join(": ")||null}function Kb(n){const e=B.c(12),{state:t,className:s}=n;let o;e[0]!==t?(o=mf(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(nt,{className:q(u,"text-info"),"aria-label":i});break e}if(t==="INITIALIZING"||t==="QUEUED"){c=r.jsx(Mo,{className:q(u,"text-info"),"aria-label":i});break e}if(t==="READY"){c=r.jsx(at,{className:q(u,"text-success"),"aria-label":i});break e}if(t==="BLOCKED"){c=r.jsx(Mw,{className:q(u,"text-destructive"),"aria-label":i});break e}a=tt,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 wM(){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 jM(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 SM(){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(it,{className:"h-2.5 w-16"}),r.jsx(it,{className:"h-3.5 w-3/4"}),r.jsx(it,{className:"h-2.5 w-1/2"})]}),[0,1,2,3].map(NM)]}),n[0]=e):e=n[0],e}function NM(n){return r.jsxs("div",{className:"flex flex-col gap-2 border-l-2 border-border pl-3",children:[r.jsx(it,{className:"h-3.5 w-4/5"}),r.jsx(it,{className:"h-2.5 w-1/2"})]},n)}const kM={data:null,error:null,loading:!1};function CM(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(_M),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 _M(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 qh(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(nn,{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 TM(n){const e=B.c(106),{deployment:t,projectPath:s,now:o}=n,[i,a]=w.useState(!1),[l,c]=w.useState(kM);let d;e[0]!==t.state?(d=Hb(t.state),e[0]=t.state,e[1]=d):d=e[1];const u=d;let f;e[2]!==t||e[3]!==o?(f=xM(t,o),e[2]=t,e[3]=o,e[4]=f):f=e[4];const m=f;let p;e[5]!==t?(p=id(t),e[5]=t,e[6]=p):p=e[6];const h=p;let g;e[7]!==t?(g=yM(t),e[7]=t,e[8]=g):g=e[8];const x=g;let v;e[9]!==t.url?(v=pf(t.url),e[9]=t.url,e[10]=v):v=e[10];const y=v;let b;e[11]!==t.id||e[12]!==l.loading||e[13]!==s?(b=async function(){if(!l.loading){c(EM);try{const ae=await hM(s,t.id);c({data:ae,error:null,loading:!1})}catch(ae){const me=ae;c({data:null,error:{error:typeof me.error=="string"?me.error:"Unable to load build output",code:me.code??"vercel_api_failed"},loading:!1})}}},e[11]=t.id,e[12]=l.loading,e[13]=s,e[14]=b):b=e[14];const j=b;let S;e[15]!==t.state||e[16]!==j||e[17]!==l.data?(S=function(ae){a(ae),ae&&(!l.data||pi(t.state))&&j()},e[15]=t.state,e[16]=j,e[17]=l.data,e[18]=S):S=e[18];const k=S,C=gM[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;e[21]!==N?(E=r.jsx("span",{"aria-hidden":!0,className:N}),e[21]=N,e[22]=E):E=e[22];let T;e[23]!==t.state?(T=mf(t.state),e[23]=t.state,e[24]=T):T=e[24];const P=`${h}: ${T}`;let _;e[25]!==t.state?(_=r.jsx(Kb,{state:t.state}),e[25]=t.state,e[26]=_):_=e[26];const A=u==="fail"&&"text-destructive";let I;e[27]!==A?(I=q("min-w-0 flex-1 truncate text-xs font-medium",A),e[27]=A,e[28]=I):I=e[28];let $;e[29]!==I||e[30]!==h?($=r.jsx("span",{className:I,children:h}),e[29]=I,e[30]=h,e[31]=$):$=e[31];let R;e[32]!==t?(R=Ro(t)&&r.jsx(wM,{}),e[32]=t,e[33]=R):R=e[33];let M;e[34]!==t.createdAt||e[35]!==o?(M=qb(t.createdAt,o),e[34]=t.createdAt,e[35]=o,e[36]=M):M=e[36];let O;e[37]!==M?(O=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]=O):O=e[38];let D;e[39]!==_||e[40]!==$||e[41]!==R||e[42]!==O?(D=r.jsxs("span",{className:"flex w-full min-w-0 items-center gap-2",children:[_,$,R,O]}),e[39]=_,e[40]=$,e[41]=R,e[42]=O,e[43]=D):D=e[43];let z;e[44]!==t.branch?(z=t.branch&&r.jsx("span",{className:"min-w-0 truncate",children:t.branch}),e[44]=t.branch,e[45]=z):z=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 L;e[48]!==t.branch||e[49]!==t.commitSha?(L=!t.branch&&!t.commitSha&&r.jsx("span",{className:"min-w-0 truncate",children:"deployed from CLI"}),e[48]=t.branch,e[49]=t.commitSha,e[50]=L):L=e[50];let H;e[51]===Symbol.for("react.memo_cache_sentinel")?(H=r.jsx("span",{className:"min-w-0 flex-1"}),e[51]=H):H=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 W;e[55]!==z||e[56]!==F||e[57]!==L||e[58]!==U?(W=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:[z,F,L,H,U]}),e[55]=z,e[56]=F,e[57]=L,e[58]=U,e[59]=W):W=e[59];let V;e[60]!==x?(V=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]=V):V=e[61];let K;e[62]!==i||e[63]!==P||e[64]!==D||e[65]!==W||e[66]!==V?(K=r.jsxs(Rt,{className:"flex min-w-0 flex-1 flex-col gap-0.5 rounded-sm px-1 py-1 text-left outline-none hover:bg-accent/60 focus-visible:ring-[3px] focus-visible:ring-ring/20","aria-label":P,"aria-expanded":i,children:[D,W,V]}),e[62]=i,e[63]=P,e[64]=D,e[65]=W,e[66]=V,e[67]=K):K=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(nn,{})}),e[68]=t.url,e[69]=h,e[70]=Y):Y=e[70];let X;e[71]!==K||e[72]!==Y?(X=r.jsxs("div",{className:"flex items-start gap-1",children:[K,Y]}),e[71]=K,e[72]=Y,e[73]=X):X=e[73];let G;e[74]!==t.url||e[75]!==y?(G=t.url&&y&&r.jsx(qh,{href:t.url,children:y}),e[74]=t.url,e[75]=y,e[76]=G):G=e[76];let J;e[77]!==t.inspectorUrl?(J=t.inspectorUrl&&r.jsx(qh,{href:t.inspectorUrl,children:"Inspect on Vercel"}),e[77]=t.inspectorUrl,e[78]=J):J=e[78];let Z;e[79]!==t.creator?(Z=t.creator&&r.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["by ",t.creator]}),e[79]=t.creator,e[80]=Z):Z=e[80];let Q;e[81]!==G||e[82]!==J||e[83]!==Z?(Q=r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1",children:[G,J,Z]}),e[81]=G,e[82]=J,e[83]=Z,e[84]=Q):Q=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(nt,{className:"size-3"}),"Loading build output"]}),e[85]=l.data,e[86]=l.loading,e[87]=te):te=e[87];let ne;e[88]!==l.error?(ne=l.error&&r.jsx("p",{className:"text-[11px] text-destructive",children:l.error.error}),e[88]=l.error,e[89]=ne):ne=e[89];let oe;e[90]!==l.data?(oe=l.data&&r.jsx(CM,{logs:l.data}),e[90]=l.data,e[91]=oe):oe=e[91];let re;e[92]!==Q||e[93]!==te||e[94]!==ne||e[95]!==oe?(re=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:[Q,te,ne,oe]})}),e[92]=Q,e[93]=te,e[94]=ne,e[95]=oe,e[96]=re):re=e[96];let ie;e[97]!==E||e[98]!==X||e[99]!==re||e[100]!==h?(ie=r.jsxs("article",{className:"group/deployment relative pl-3","aria-label":h,children:[E,X,re]}),e[97]=E,e[98]=X,e[99]=re,e[100]=h,e[101]=ie):ie=e[101];let se;return e[102]!==k||e[103]!==i||e[104]!==ie?(se=r.jsx(ct,{open:i,onOpenChange:k,children:ie}),e[102]=k,e[103]=i,e[104]=ie,e[105]=se):se=e[105],se}function EM(n){return{...n,error:null,loading:!0}}function AM(n){const e=n.filter(Ro),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 PM(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}=AM(t),c=a??l;if(!c){i=null;break e}const d=id(c),u=pf(c.url),f=l?Hb(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 v;e[10]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx("span",{className:"min-w-0 flex-1"}),e[10]=v):v=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:qb(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)}),v,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(nn,{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(Kb,{state:l.state,className:"size-3"}),r.jsxs("span",{className:"min-w-0 truncate",children:[f==="fail"?"Newer production deploy failed":"Newer production deploy in progress"," · ",id(l)]})]})]})}e[0]=t,e[1]=s,e[2]=o,e[3]=i}else o=e[2],i=e[3];return i!==Symbol.for("react.early_return_sentinel")?i:o}function IM(n,e){return e==="failed"?n.filter(t=>xl(t.state)):e==="production"?n.filter(Ro):e==="preview"?n.filter(t=>!Ro(t)):[...n]}function RM(n){const e=B.c(17),{data:t,filter:s,projectPath:o}=n;let i;e[0]!==t.deployments||e[1]!==s?(i=IM(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($M),e[3]=t.deployments,e[4]=l):l=e[4];const c=bM(l);if(t.deployments.length===0){let m;return e[5]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(Kt,{className:"border-0",children:r.jsxs(Vt,{children:[r.jsx(en,{variant:"icon",children:r.jsx(tg,{})}),r.jsx(Gt,{children:"No deployments yet"}),r.jsx(tn,{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(PM,{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(TM,{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(Vn,{className:"min-h-0 flex-1",children:[d,u]}),e[14]=d,e[15]=u,e[16]=f):f=e[16],f}function $M(n){return pi(n.state)}function MM(n){const e=B.c(6),{context:t}=n,{data:s}=Wb(t.projectPath,t.projectPath!==null);let o;e[0]!==(s==null?void 0:s.deployments)?(o=(s==null?void 0:s.deployments.filter(LM).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]?xl(s.deployments[0].state):!1;if(i>0){const l=`${i} active Vercel deployment${i===1?"":"s"}`;let c;return e[2]!==i||e[3]!==l?(c=r.jsx(Pe,{className:"absolute -right-1 -top-1 min-w-4 px-1 text-[9px]","aria-label":l,children:i}),e[2]=i,e[3]=l,e[4]=c):c=e[4],c}if(a){let l;return e[5]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Pe,{variant:"destructive",className:"absolute -right-0.5 -top-0.5 size-3 p-0 text-[8px]","aria-label":"Latest Vercel deployment failed",children:"!"}),e[5]=l):l=e[5],l}return null}function LM(n){return pi(n.state)}function OM(n){const e=B.c(57),{context:t,active:s,closePanel:o}=n,{data:i,error:a,loading:l,refreshing:c,refresh:d}=Wb(t.projectPath,s),[u,f]=w.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(Ro),e[2]=h,e[3]=x):x=e[3];const v=x.length;let y;e[4]!==h?(y=h.filter(zM),e[4]=h,e[5]=y):y=e[5];const b=y.length;let j;e[6]!==h?(j=h.filter(DM),e[6]=h,e[7]=j):j=e[7];let S;e[8]!==h.length||e[9]!==x.length||e[10]!==y.length||e[11]!==j.length?(S={all:g,production:v,preview:b,failed:j.length},e[8]=h.length,e[9]=x.length,e[10]=y.length,e[11]=j.length,e[12]=S):S=e[12];const k=S,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;e[14]!==i?(E=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(nn,{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):E=e[15];let T;e[16]!==d?(T=()=>{d()},e[16]=d,e[17]=T):T=e[17];const P=l||c||!m;let _;e[18]!==c?(_=c?r.jsx(nt,{}):r.jsx(Pt,{}),e[18]=c,e[19]=_):_=e[19];let A;e[20]!==T||e[21]!==P||e[22]!==_?(A=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:T,disabled:P,"aria-label":"Refresh Vercel deployments",children:_}),e[20]=T,e[21]=P,e[22]=_,e[23]=A):A=e[23];let I;e[24]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(tt,{}),e[24]=I):I=e[24];let $;e[25]!==o?($=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:o,"aria-label":"Close Vercel deployments",children:I}),e[25]=o,e[26]=$):$=e[26];let R;e[27]!==E||e[28]!==A||e[29]!==$?(R=r.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b pl-4 pr-2",children:[E,A,$]}),e[27]=E,e[28]=A,e[29]=$,e[30]=R):R=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(bt,{pressed:C==="all",onClick:()=>f("all"),children:["All ",r.jsx(vt,{children:k.all})]}),r.jsxs(bt,{pressed:C==="production",disabled:k.production===0,onClick:()=>f("production"),children:["Production ",r.jsx(vt,{children:k.production})]}),r.jsxs(bt,{pressed:C==="preview",disabled:k.preview===0,onClick:()=>f("preview"),children:["Preview ",r.jsx(vt,{children:k.preview})]}),r.jsxs(bt,{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(vt,{children:k.failed})]})]}),e[31]=k,e[32]=i,e[33]=C,e[34]=M):M=e[34];let O;e[35]!==i||e[36]!==l?(O=l&&!i&&r.jsx(SM,{}),e[35]=i,e[36]=l,e[37]=O):O=e[37];let D;e[38]!==i||e[39]!==a||e[40]!==d?(D=a&&!i&&r.jsx("div",{className:"p-3",children:r.jsxs(ut,{variant:"destructive",children:[r.jsx(Xt,{}),r.jsx(Et,{children:a.error}),r.jsxs(ft,{className:"flex flex-col items-start gap-2",children:[r.jsx("span",{children:jM(a)}),r.jsxs(ee,{type:"button",variant:"outline",size:"xs",onClick:()=>{d()},children:[r.jsx(Pt,{"data-icon":"inline-start"}),"Try again"]})]})]})}),e[38]=i,e[39]=a,e[40]=d,e[41]=D):D=e[41];let z;e[42]!==i||e[43]!==C||e[44]!==m?(z=i&&m&&r.jsx(RM,{data:i,filter:C,projectPath:m}),e[42]=i,e[43]=C,e[44]=m,e[45]=z):z=e[45];let F;e[46]!==i||e[47]!==a||e[48]!==l?(F=!l&&!i&&!a&&r.jsx(Kt,{className:"border-0",children:r.jsxs(Vt,{children:[r.jsx(en,{variant:"icon",children:r.jsx(Vs,{})}),r.jsx(Gt,{children:"Select a project session"})]})}),e[46]=i,e[47]=a,e[48]=l,e[49]=F):F=e[49];let L;return e[50]!==R||e[51]!==M||e[52]!==O||e[53]!==D||e[54]!==z||e[55]!==F?(L=r.jsxs("section",{className:"flex size-full min-h-0 flex-col","aria-label":"Vercel deployments panel",children:[R,M,O,D,z,F]}),e[50]=R,e[51]=M,e[52]=O,e[53]=D,e[54]=z,e[55]=F,e[56]=L):L=e[56],L}function DM(n){return xl(n.state)}function zM(n){return!Ro(n)}const FM={id:"vercel-deployments",workspacePanels:[{id:"deployments",title:"Vercel Deployments",icon:tg,component:OM,indicator:MM,order:45,defaultSize:"42%",minSize:"380px",maxSize:"68%",when:n=>n.canAccessHostFiles&&n.projectPath!==null}]},BM=[lM,GR,FM];function UM(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]=w.useState(o),[l,c]=w.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]),w.useEffect(d,u);let f;s[5]!==n||s[6]!==e?(f=()=>{if(!n||!e)return;const x=new AbortController;a(HM);const v=new URLSearchParams({dirName:n,fileName:e});return Ne(`/api/usage-cost/session?${v}`,{signal:x.signal}).then(async y=>{if(!y.ok)throw new Error(`Cost scan failed (${y.status})`);const b=await y.json();a({summary:b,loading:!1,error:null})}).catch(y=>{x.signal.aborted||a(b=>({...b,loading:!1,error:y instanceof Error?y.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],w.useEffect(f,m);let p;s[13]===Symbol.for("react.memo_cache_sentinel")?(p=()=>c(WM),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 WM(n){return n+1}function HM(n){return{...n,loading:!0,error:null}}function qM(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 KM(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 VM(){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(it,{className:"h-4 w-24"}),r.jsx(it,{className:"h-10 w-32"}),r.jsx(it,{className:"h-3 w-44"})]}),t=r.jsx(it,{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(it,{className:"h-8 w-full"}),r.jsx(it,{className:"h-8 w-full"}),r.jsx(it,{className:"h-8 w-full"})]})]}),n[2]=s):s=n[2],s}function GM(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(bd,{}),i=r.jsx(Et,{children:"Cost unavailable"}),e[0]=o,e[1]=i):(o=e[0],i=e[1]);let a;e[2]!==t?(a=r.jsx(ft,{children:t}),e[2]=t,e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Pt,{"data-icon":"inline-start"}),e[4]=l):l=e[4];let c;e[5]!==s?(c=r.jsxs(ee,{variant:"outline",size:"xs",onClick:s,className:"mt-2",children:[l,"Retry"]}),e[5]=s,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=r.jsxs(ut,{variant:"destructive",className:"mt-2",children:[o,i,a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d}function Hi(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 YM(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(Xg,{children:t.label}),e[0]=t.label,e[1]=i):i=e[1];let a;e[2]!==t.costUsd?(a=r.jsx(Jg,{children:()=>dn(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(Jr,{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?lt(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 XM(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(Jr,{value:c,children:[r.jsx(Xg,{title:l.model,children:Ys(l.model)}),r.jsx(Jg,{children:()=>l.costSource==="unpriced"?"Unpriced":dn(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:[lt(tf(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 JM(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 QM(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(ZM),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 ZM(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," · ",Ys(n.model)]}),n.isSubagent&&r.jsx(Pe,{variant:"outline",children:"Agent"}),r.jsx("span",{className:"shrink-0 font-mono text-xs text-foreground tabular-nums",children:dn(n.costUsd)})]},`${n.timestamp}:${n.call}`)}function eL(n){const e=B.c(74),{summary:t}=n;let s;e[0]!==t.provider?(s=z4(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=tf(t.totals),x=KM(t);let v;e[10]!==t.calls?(v=JM(t.calls),e[10]=t.calls,e[11]=v):v=e[11],u=v;const y=t.providerReportedRecords+t.modelPricedRecords>0;i="flex flex-col gap-5 pt-2";let b;e[12]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx("p",{id:"session-cost-heading",className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"API equivalent"}),e[12]=b):b=e[12];let j;e[13]!==o?(j=r.jsx(o,{"aria-hidden":"true"}),e[13]=o,e[14]=j):j=e[14];let S;e[15]!==t.provider?(S=an(t.provider),e[15]=t.provider,e[16]=S):S=e[16];let k;e[17]!==S.displayName||e[18]!==j?(k=r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[b,r.jsxs(Pe,{variant:"outline",children:[j,S.displayName]})]}),e[17]=S.displayName,e[18]=j,e[19]=k):k=e[19];let C;e[20]!==y||e[21]!==t.costUsd?(C=y?dn(t.costUsd):"—",e[20]=y,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 E=t.unpricedRecords>0?"secondary":"outline";let T;e[25]!==t?(T=qM(t),e[25]=t,e[26]=T):T=e[26];let P;e[27]!==E||e[28]!==T?(P=r.jsx(Pe,{variant:E,children:T}),e[27]=E,e[28]=T,e[29]=P):P=e[29];let _;e[30]!==N||e[31]!==P?(_=r.jsxs("div",{className:"flex items-end justify-between gap-3",children:[N,P]}),e[30]=N,e[31]=P,e[32]=_):_=e[32];const A=t.records===1?"model call":"model calls",I=t.includedSubagents>0?` · ${t.includedSubagents} agent ${t.includedSubagents===1?"transcript":"transcripts"}`:"";let $;e[33]!==t.records||e[34]!==A||e[35]!==I?($=r.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.records," ",A,I]}),e[33]=t.records,e[34]=A,e[35]=I,e[36]=$):$=e[36],e[37]!==k||e[38]!==_||e[39]!==$?(a=r.jsxs("section",{"aria-labelledby":"session-cost-heading",className:"flex flex-col gap-2",children:[k,_,$]}),e[37]=k,e[38]=_,e[39]=$,e[40]=a):a=e[40],e[41]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Nt,{}),e[41]=l):l=e[41];const R=lt(g);let M;e[42]!==R?(M=r.jsx(Hi,{label:"Processed tokens",value:R}),e[42]=R,e[43]=M):M=e[43];let O;e[44]!==t.cacheSavingsUsd?(O=dn(t.cacheSavingsUsd),e[44]=t.cacheSavingsUsd,e[45]=O):O=e[45];let D;e[46]!==O?(D=r.jsx(Hi,{label:"Cache savings",value:O}),e[46]=O,e[47]=D):D=e[47];let z;e[48]!==t.totals.cachedInputTokens?(z=lt(t.totals.cachedInputTokens),e[48]=t.totals.cachedInputTokens,e[49]=z):z=e[49];let F;e[50]!==z?(F=r.jsx(Hi,{label:"Cached input",value:z}),e[50]=z,e[51]=F):F=e[51];let L;e[52]!==t.totals.reasoningTokens?(L=lt(t.totals.reasoningTokens),e[52]=t.totals.reasoningTokens,e[53]=L):L=e[53];let H;e[54]!==L?(H=r.jsx(Hi,{label:"Reasoning",value:L}),e[54]=L,e[55]=H):H=e[55],e[56]!==M||e[57]!==D||e[58]!==F||e[59]!==H?(c=r.jsxs("dl",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:[M,D,F,H]}),e[56]=M,e[57]=D,e[58]=F,e[59]=H,e[60]=c):c=e[60],d=x.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(Nt,{}),r.jsxs("section",{"aria-labelledby":"cost-breakdown-heading",className:"flex flex-col gap-3",children:[r.jsx("h3",{id:"cost-breakdown-heading",className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Cost by token type"}),r.jsx("div",{className:"flex flex-col gap-4",children:x.map(U=>r.jsx(YM,{row:U,totalCost:t.costUsd},U.label))})]})]}),e[2]=o,e[3]=t,e[4]=i,e[5]=a,e[6]=l,e[7]=c,e[8]=d,e[9]=u}else i=e[4],a=e[5],l=e[6],c=e[7],d=e[8],u=e[9];let f;e[61]!==t?(f=t.models.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(Nt,{}),r.jsx(XM,{summary:t})]}),e[61]=t,e[62]=f):f=e[62];let m;e[63]!==u?(m=u.length>=2&&r.jsxs(r.Fragment,{children:[r.jsx(Nt,{}),r.jsx(QM,{rows:u})]}),e[63]=u,e[64]=m):m=e[64];let p;e[65]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsxs(ut,{children:[r.jsx(bd,{}),r.jsx(Et,{children:"How this is calculated"}),r.jsx(ft,{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 tL(n){const e=B.c(7),{dirName:t,fileName:s,revision:o}=n,{summary:i,loading:a,error:l,refresh:c}=UM(t,s,o);if(l){let u;return e[0]!==l||e[1]!==c?(u=r.jsx(GM,{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(VM,{}),e[3]=f):f=e[3],f}let u;return e[4]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Kt,{className:"mt-2 min-h-52",children:r.jsxs(Vt,{children:[r.jsx(en,{variant:"icon",children:r.jsx(Lw,{})}),r.jsx(Gt,{children:"No transcript cost yet"}),r.jsx(tn,{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(eL,{summary:i}),e[5]=i,e[6]=d):d=e[6],d}function nL(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 sL(n){const e=B.c(14),{turns:t,onJumpToTurn:s}=n;let o;e[0]!==t?(o=nL(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(Qr,{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 Kh(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||zu(t,s),e[0]=t,e[1]=o,e[2]=s,e[3]=h):h=e[3];const g=h;let x;e[4]!==d?(x=d==null?null:d<1e3?`${d}ms`:`${(d/1e3).toFixed(d>=1e4?0:1)}s`,e[4]=d,e[5]=x):x=e[5];const v=x;let y;e[6]!==c?(y=c==="running"?r.jsx(et,{className:"size-3 shrink-0 animate-spin text-success","data-icon":"inline-start"}):c==="done"?r.jsx(Hn,{className:"size-3 shrink-0 text-success","data-icon":"inline-start"}):c==="failed"?r.jsx(Ps,{className:"size-3 shrink-0 text-destructive","data-icon":"inline-start"}):r.jsx(Pa,{className:"size-2.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),e[6]=c,e[7]=y):y=e[7];const b=y,j=a?"bg-accent":"hover:bg-muted/40";let S;e[8]!==j?(S=q("motion-list-item flex w-full items-start border-b border-border text-left transition-colors last:border-b-0",j),e[8]=j,e[9]=S):S=e[9];let k;e[10]!==g?(k=r.jsx(Pe,{variant:"outline",children:g}),e[10]=g,e[11]=k):k=e[11];let C;e[12]!==l?(C=l&&r.jsx(Pe,{variant:"outline",children:"Background"}),e[12]=l,e[13]=C):C=e[13];let N;e[14]!==a?(N=a&&r.jsx(Pe,{children:"Viewing"}),e[14]=a,e[15]=N):N=e[15];const E=c==="running"?"active":c;let T;e[16]!==E?(T=r.jsx("span",{className:"ml-auto text-xs uppercase tracking-wide text-muted-foreground",children:E}),e[16]=E,e[17]=T):T=e[17];let P;e[18]!==b||e[19]!==T||e[20]!==k||e[21]!==C||e[22]!==N?(P=r.jsxs("div",{className:"flex items-center gap-1.5",children:[b,k,C,N,T]}),e[18]=b,e[19]=T,e[20]=k,e[21]=C,e[22]=N,e[23]=P):P=e[23];let _;e[24]!==i?(_=i&&r.jsx("p",{className:"mt-1 line-clamp-2 text-xs leading-relaxed text-muted-foreground",children:i}),e[24]=i,e[25]=_):_=e[25];let A;e[26]!==v||e[27]!==u?(A=(v||u!=null)&&r.jsxs("div",{className:"mt-1.5 flex items-center gap-2 text-xs text-muted-foreground",children:[v&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(Mo,{className:"size-2.5","data-icon":"inline-start"}),v]}),u!=null&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(_a,{className:"size-2.5","data-icon":"inline-start"}),u," tools"]})]}),e[26]=v,e[27]=u,e[28]=A):A=e[28];let I;e[29]!==f||e[30]!==m||e[31]!==P||e[32]!==_||e[33]!==A?(I=r.jsxs(ee,{type:"button",variant:"ghost",onClick:m,disabled:f,className:"h-auto min-w-0 flex-1 flex-col items-stretch rounded-none px-2.5 py-2 text-left whitespace-normal",children:[P,_,A]}),e[29]=f,e[30]=m,e[31]=P,e[32]=_,e[33]=A,e[34]=I):I=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(tt,{"data-icon":"inline-start"})}),e[35]=g,e[36]=p,e[37]=$):$=e[37];let R;return e[38]!==I||e[39]!==$||e[40]!==S?(R=r.jsxs("div",{className:S,children:[I,$]}),e[38]=I,e[39]=$,e[40]=S,e[41]=R):R=e[41],R}function oL(n,e=!1){const t=n==null?void 0:n.toLowerCase();return t==="completed"||t==="success"||t==="done"?"done":t==="failed"||t==="error"||t==="cancelled"?"failed":e||t==="running"||t==="async_launched"?"running":"seen"}function ad(n){return n.split(`
124
+ `).map(e=>e.trim()).find(Boolean)??""}function rL(n){return n.name==="Task"||n.name==="Agent"}function iL(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=oL(c.status);t.set(c.agentId,{agentId:c.agentId,agentName:c.agentName??(d==null?void 0:d.agentName)??null,subagentType:c.subagentType??(d==null?void 0:d.subagentType)??null,preview:ad(((i=c.prompt)==null?void 0:i.trim())||c.text.find(f=>f.trim())||"")||(d==null?void 0:d.preview)||"No task summary recorded",isBackground:c.isBackground||(d==null?void 0:d.isBackground)||!1,status:u==="seen"&&(d!=null&&d.status)?d.status:u,durationMs:c.durationMs??(d==null?void 0:d.durationMs),toolUseCount:c.toolUseCount??(d==null?void 0:d.toolUseCount),parentToolUseId:c.parentToolUseId??(d==null?void 0:d.parentToolUseId)})}const s=new Set;for(const a of t.values())a.parentToolUseId&&s.add(a.parentToolUseId);const o=new Set;for(const a of e)a.parentToolUseId&&o.add(a.parentToolUseId);for(const a of n.turns)for(const l of a.toolCalls){if(!rL(l)||!o.has(l.id)||s.has(l.id))continue;const c=l.input;t.set(`tool:${l.id}`,{agentId:`tool:${l.id}`,agentName:typeof c.name=="string"?c.name:null,subagentType:typeof c.subagent_type=="string"?c.subagent_type:null,preview:ad(typeof c.prompt=="string"?c.prompt:typeof c.description=="string"?c.description:"Agent task in progress"),isBackground:!1,status:"running",parentToolUseId:l.id})}return[...t.values()]}function aL({session:n,sessionSource:e,bgAgents:t,onLoadSession:s}){const o=Lu(),i=w.useMemo(()=>{if(!e)return null;const y=Cs(e.fileName);return y?{...y,dirName:e.dirName}:null},[e]),a=w.useMemo(()=>iL(n,o),[n,o]),l=w.useRef(a);w.useEffect(()=>{!i&&a.length>0&&(l.current=a)},[i,a]);const c=i&&a.length===0?l.current:a,d=w.useMemo(()=>{if(i)return i.parentSessionId;if(e!=null&&e.fileName){const y=e.fileName.match(/^([^/]+)\.jsonl$/);if(y)return y[1]}return null},[i,e]),u=w.useMemo(()=>d?t.filter(y=>y.parentSessionId===d):t,[t,d]),f=w.useMemo(()=>new Map(c.map(y=>[y.agentId,y])),[c]),m=w.useMemo(()=>{const y=new Set(u.map(b=>b.agentId));return c.filter(b=>!y.has(b.agentId))},[u,c]),p=w.useMemo(()=>[...u].sort((y,b)=>b.modifiedAt-y.modifiedAt),[u]),h=w.useMemo(()=>[...m].reverse(),[m]),g=u.length+m.length;if(g===0)return null;const x=y=>{Ne(`/api/claude/tasks/${encodeURIComponent(n.sessionId)}/${encodeURIComponent(y)}`,{method:"DELETE"})},v=(i==null?void 0:i.agentId)??null;return r.jsxs("section",{children:[r.jsxs(Qr,{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(Ye,{"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(y=>{const b=ad(y.preview??""),j=f.get(y.agentId);return r.jsx(Kh,{agentId:y.agentId,subagentType:(j==null?void 0:j.subagentType)??null,agentName:(j==null?void 0:j.agentName)??null,preview:(j==null?void 0:j.preview)||(b!==y.agentId?b:""),isViewing:v===y.agentId,isBackground:!0,status:y.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:y.isActive?()=>x(y.agentId):void 0,onClick:()=>s==null?void 0:s(y.dirName,y.fileName)},y.agentId)}),h.map(y=>{const b=!!s&&!!d&&!!e&&!y.agentId.startsWith("tool:");return r.jsx(Kh,{agentId:y.agentId,subagentType:y.subagentType,agentName:y.agentName,preview:y.preview,isViewing:v===y.agentId,isBackground:y.isBackground,status:y.status,durationMs:y.durationMs,toolUseCount:y.toolUseCount,disabled:!b,onClick:()=>{b&&s(e.dirName,`${d}/subagents/agent-${y.agentId}.jsonl`)}},y.agentId)})]})]})}function lL(n,e){return`${n.id}-${e}`}function cL(n){const e=B.c(14),{turns:t,onJumpToTurn:s}=n,[o,i]=w.useState(null);if(t.length===0)return null;let a;e[0]!==t.length?(a=r.jsxs(Qr,{children:["Turns (",t.length,")"]}),e[0]=t.length,e[1]=a):a=e[1];let l;if(e[2]!==o||e[3]!==s||e[4]!==t){let u;e[6]!==o||e[7]!==s?(u=(f,m)=>{const p=sl(f.userMessage),h=o===m;return r.jsxs(ee,{type:"button",variant:"ghost",onClick:()=>{i(m),s==null||s(m)},className: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?jn(p,50):"(no message)"}),r.jsx("span",{className:"flex shrink-0 items-center gap-1",children:f.toolCalls.length>0&&r.jsx(Pe,{variant:"secondary",className:"font-normal",children:f.toolCalls.length})})]},lL(f,m))},e[6]=o,e[7]=s,e[8]=u):u=e[8],l=t.map(u),e[2]=o,e[3]=s,e[4]=t,e[5]=l}else l=e[5];let c;e[9]!==l?(c=r.jsx("div",{className:"max-h-[400px] overflow-y-auto",children:r.jsx("div",{className:"flex flex-col gap-0.5 pr-2",children:l})}),e[9]=l,e[10]=c):c=e[10];let d;return e[11]!==a||e[12]!==c?(d=r.jsxs("section",{children:[a,c]}),e[11]=a,e[12]=c,e[13]=d):d=e[13],d}const ld=new Map;let mc=null,pc=null;async function dL(){try{const n=await Ne("/api/usage-cost/rates");if(!n.ok)return ld;const e=await n.json();return new Map(Object.entries(e.rates??{}))}catch{return ld}}function uL(){const[n,e]=w.useState(mc??ld);return w.useEffect(()=>{if(mc!==null)return;let t=!0;return pc??(pc=dL().then(s=>(s.size>0&&(mc=s),pc=null,s))),pc.then(s=>{t&&e(s)}),()=>{t=!1}},[]),n}function fL(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"?jn(e.command,40):e.pattern&&typeof e.pattern=="string"?e.pattern:e.query&&typeof e.query=="string"?jn(e.query,40):e.url&&typeof e.url=="string"?jn(e.url,40):jn(yT(n),40)}function mL(n,e){return n.map(t=>{const s=t.tokenUsage;return!s||t.toolCalls.length===0?0:RI(e,t.model,s)/t.toolCalls.length})}function pL(n,e){const t=new Map;for(let s=0;s<n.length;s++)for(const o of n[s].toolCalls){const i=Ho(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 hL(n){const e=B.c(14),{turns:t,onJumpToTurn:s}=n,o=uL();let i;e[0]!==o||e[1]!==t?(i=mL(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=pL(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(Qr,{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(Rt,{className:"group flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-xs transition-colors hover:bg-muted",children:[r.jsx(Ye,{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:dn(g.estimatedCost)}),r.jsx(Pe,{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,v)=>{const{tc:y,turnIndex:b}=x,j=fL(y);return r.jsx("div",{children:r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>s==null?void 0:s(b,y.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",y.isError?"text-destructive hover:bg-destructive/10":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:[y.isError&&r.jsx(mn,{className:"size-2.5 shrink-0 text-destructive","data-icon":"inline-start"}),r.jsx("span",{className:"truncate",children:j||y.id.slice(0,8)})]})},`${y.id}-${v}`)}),g.calls.length>50&&r.jsxs("div",{className:"px-1.5 py-0.5 text-xs text-muted-foreground",children:["+",g.calls.length-50," more"]})]})})]},h)},e[10]=s,e[11]=m):m=e[11],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 gL(n){const e=B.c(19),{searchInputRef:t}=n,{state:s,dispatch:o}=qt(),{searchQuery:i,expandAll:a}=s,{actions:l}=ot(),{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(Ia,{"data-icon":"inline-start"}):r.jsx(Ur,{"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=b=>o({type:"SET_SEARCH_QUERY",value:b.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(us,{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(En,{align:"inline-start",children:r.jsx(Yt,{})}),e[13]=x):x=e[13];let v;e[14]!==g?(v=r.jsxs(ds,{children:[g,x]}),e[14]=g,e[15]=v):v=e[15];let y;return e[16]!==v||e[17]!==m?(y=r.jsxs("div",{className:"sticky top-0 border-b bg-background px-3 py-3",children:[m,v]}),e[16]=v,e[17]=m,e[18]=y):y=e[18],y}const Vb=w.memo(function(e){const t=B.c(48),{onJumpToTurn:s,onToggleServer:o,onServersChanged:i,searchInputRef:a,onLoadSession:l,backgroundAgents:c}=e,{isMobile:d}=qt(),{session:u,sessionSource:f}=ot(),m=u,{turns:p}=m;let h;t[0]!==m.stats.totalCacheCreationTokens||t[1]!==m.stats.totalCacheReadTokens||t[2]!==m.stats.totalInputTokens||t[3]!==m.stats.totalOutputTokens||t[4]!==p.length?(h=[m.stats.totalInputTokens,m.stats.totalOutputTokens,m.stats.totalCacheCreationTokens,m.stats.totalCacheReadTokens,p.length],t[0]=m.stats.totalCacheCreationTokens,t[1]=m.stats.totalCacheReadTokens,t[2]=m.stats.totalInputTokens,t[3]=m.stats.totalOutputTokens,t[4]=p.length,t[5]=h):h=t[5];const g=h.join(":"),x=d?"mobile-scroll w-full flex-1":"w-full";let v;t[6]!==x?(v=q("h-full min-h-0 shrink-0 overflow-y-auto bg-background",x),t[6]=x,t[7]=v):v=t[7];let y;t[8]!==a?(y=a&&r.jsx(gL,{searchInputRef:a}),t[8]=a,t[9]=y):y=t[9];const b=d?"p-4":"p-3";let j;t[10]!==b?(j=q(b),t[10]=b,t[11]=j):j=t[11];let S;t[12]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsxs(Va,{variant:"line",className:"grid w-full grid-cols-4",children:[r.jsx(Dn,{value:"activity",children:"Activity"}),r.jsx(Dn,{value:"agents",children:"Agents"}),r.jsx(Dn,{value:"cost",children:"Cost"}),r.jsx(Dn,{value:"issues",children:"Issues"})]}),t[12]=S):S=t[12];let k;t[13]!==s||t[14]!==p?(k=r.jsxs(zn,{value:"activity",className:"flex flex-col gap-6 pt-3",children:[r.jsx(cL,{turns:p,onJumpToTurn:s}),r.jsx(hL,{turns:p,onJumpToTurn:s})]}),t[13]=s,t[14]=p,t[15]=k):k=t[15];let C;t[16]!==i||t[17]!==o||t[18]!==m.cwd||t[19]!==p?(C=r.jsx(cx,{cwd:m.cwd,turns:p,onToggleServer:o,onServersChanged:i}),t[16]=i,t[17]=o,t[18]=m.cwd,t[19]=p,t[20]=C):C=t[20];let N;t[21]!==c?(N=c??[],t[21]=c,t[22]=N):N=t[22];let E;t[23]!==l||t[24]!==m||t[25]!==f||t[26]!==N?(E=r.jsx(aL,{session:m,sessionSource:f,bgAgents:N,onLoadSession:l}),t[23]=l,t[24]=m,t[25]=f,t[26]=N,t[27]=E):E=t[27];let T;t[28]!==E||t[29]!==C?(T=r.jsxs(zn,{value:"agents",className:"flex flex-col gap-6 pt-3",children:[C,E]}),t[28]=E,t[29]=C,t[30]=T):T=t[30];const P=(f==null?void 0:f.dirName)??null,_=(f==null?void 0:f.fileName)??null;let A;t[31]!==g||t[32]!==P||t[33]!==_?(A=r.jsx(zn,{value:"cost",className:"pt-3",children:r.jsx(tL,{dirName:P,fileName:_,revision:g})}),t[31]=g,t[32]=P,t[33]=_,t[34]=A):A=t[34];let I;t[35]!==s||t[36]!==p?(I=r.jsx(zn,{value:"issues",className:"flex flex-col gap-6 pt-3",children:r.jsx(sL,{turns:p,onJumpToTurn:s})}),t[35]=s,t[36]=p,t[37]=I):I=t[37];let $;t[38]!==T||t[39]!==A||t[40]!==I||t[41]!==j||t[42]!==k?($=r.jsxs(Ka,{defaultValue:"activity",className:j,children:[S,k,T,A,I]}),t[38]=T,t[39]=A,t[40]=I,t[41]=j,t[42]=k,t[43]=$):$=t[43];let R;return t[44]!==$||t[45]!==v||t[46]!==y?(R=r.jsxs("aside",{className:v,children:[y,$]}),t[44]=$,t[45]=v,t[46]=y,t[47]=R):R=t[47],R}),xL="default",bL="tmp-",vL=/^[a-z0-9][a-z0-9_-]{0,39}$/;function yL(n){return vL.test(n)}function wL(n){return n.startsWith(bL)}function Vh(n,e){let t="",s="",o=!0,i=e;for(;i<n.length;i++){const a=n[i],l=n[i+1];if(!s&&/[\s;&|()<>]/.test(a))break;if(a==="\\"&&s!=="'"){if(l===void 0)return null;if(!s||/[$`"\\\n]/.test(l)){l!==`
125
+ `&&(t+=l),i++;continue}}if(a===s){s="";continue}if(!s&&(a==="'"||a==='"')){s=a;continue}if(s!=="'"){if(a==="`"||a==="$"&&/[('"{]/.test(l??""))return null;(a==="$"||!s&&/[*?[{}~]/.test(a))&&(o=!1)}t+=a}return s?null:{value:t,start:e,end:i,literal:o}}function jL(n){const e=[];let t=[],s=0,o=0;const i=()=>({commands:[...e,{words:t,end:n.length,pipeline:s}],complete:!1});for(let a=0;a<n.length;){const l=n[a];if(l==="\\"&&n[a+1]===`
126
+ `){a+=2;continue}if(l==="#"){const u=n.indexOf(`
127
+ `,a);e.push({words:t,end:a,pipeline:s}),t.length>0&&o===0&&s++,t=[],a=u<0?n.length:u;continue}if(/[^\S\n]/.test(l)){a++;continue}if(/[;&|()\n]/.test(l)){const u=n[a+1],f=l==="|"&&u!=="|";if(l==="("&&o++,l===")"&&o--,o<0)return i();e.push({words:t,end:a,pipeline:s}),o===0&&!f&&l!=="("&&l!==")"&&(l!==`
128
+ `||t.length>0)&&s++,t=[],a+=(l==="&"||l==="|")&&(u===l||f&&u==="&")?2:1;continue}if(/^(?:\d+)?<</.test(n.slice(a)))return i();const c=/^(?:\d+)?(?:>>|>\||>&|<&|<>|[<>])/.exec(n.slice(a));if(c){for(a+=c[0].length;/[^\S\n]/.test(n[a]??"");)a++;const u=Vh(n,a);if(!u||u.end===a)return i();a=u.end;continue}const d=Vh(n,a);if(!d||d.end===a)return i();t.push(d),a=d.end}return e.push({words:t,end:n.length,pipeline:s}),{commands:e,complete:o===0}}const cr="agent-browser",SL=new Map([["env",new Set(["-i","--ignore-environment","--"])],["command",new Set(["--"])],["exec",new Set(["--"])],["npx",new Set(["-y","--yes","--"])],["bunx",new Set(["--bun","--"])]]),NL=new Set(["echo","printf","rg","grep","cat","head","tail","wc","ls","stat","file","basename","dirname","cp","mv","rm","mkdir","rmdir","touch"]),kL=new Set(["commit","log","show","diff","status","add","grep","ls-files","rev-parse"]),CL=/^(?:if|then|else|elif|fi|while|until|for|select|case|esac|do|done|function|\{|\}|!)$/,_L=/^[A-Za-z_][A-Za-z_\d]*=/;function Gb(n){return n.slice(n.lastIndexOf("/")+1)}function TL(n,e){var s,o;let t=0;for(;t<n.length;){const i=n[t];if(_L.test(e.slice(i.start,i.end))){t++;continue}if(!i.literal||CL.test(i.value))return null;const a=Gb(i.value);if(a==="command"&&["-v","-V"].includes((s=n[t+1])==null?void 0:s.value))return-1;const l=SL.get(a);if(!l)return t;for(t++;(o=n[t])!=null&&o.value.startsWith("-");){if(!n[t].literal||!l.has(n[t].value))return null;if(n[t++].value==="--")break}}return-1}function EL(n,e,t){const[s,...o]=n;if(o.some(l=>!l.literal))return null;let i=xL,a=null;for(let l=0;l<o.length;l++){const c=o[l];if(c.value!=="--session"&&!c.value.startsWith("--session="))continue;if(a!==null)return null;const d=c.value==="--session"?o[++l]:c;if(i=c.value==="--session"?d==null?void 0:d.value:c.value.slice(10),!i||!yL(i)||d!==c&&!/^(?:\s|\\\n)*$/.test(t.slice(c.end,d.start)))return null;a={start:c.start,end:d.end}}return{text:cr+t.slice(s.end,e).trimEnd(),binaryEnd:s.end,browser:i,sessionFlag:a}}function AL(n){var l;const{commands:e,complete:t}=jL(n),s=[],o=e.some(({words:c})=>c.some(({value:d})=>d.includes(cr)));if(!t)return{invocations:s,ambiguous:o||n.includes(cr)};const i=new Set(e.filter(({words:c})=>c.some(({value:d})=>d.includes(cr))).map(({pipeline:c})=>c));let a=!1;for(const{words:c,end:d,pipeline:u}of e){const f=TL(c,n);if(f===null){a||(a=o);continue}if(f<0)continue;const m=Gb(c[f].value);if(m!==cr){!(NL.has(m)||m==="git"&&kL.has((l=c[f+1])==null?void 0:l.value))&&i.has(u)&&(a=!0);continue}const p=EL(c.slice(f),d,n);p===null?a=!0:s.push(p)}return{invocations:s,ambiguous:a}}function PL(n){return AL(n).invocations}const Gh=120,IL=/(?:^|[._])exec_command$/;function RL(n){return n==="Bash"||IL.test(n)}function $L(n){return I_(n).filter(e=>RL(e.name)).map(e=>Xs(e.input))}function ML(n){for(const e of $L(n)){const[t]=PL(e);if(t===void 0||wL(t.browser))continue;const{text:s}=t;return{session:t.browser,command:s.length>Gh?`${s.slice(0,Gh-1)}…`:s,timestamp:n.timestamp,toolCallId:n.id,done:n.result!==null}}return null}function LL(n){const e=(n==null?void 0:n.turns)??[];for(let t=e.length-1;t>=0;t--){const s=e[t].toolCalls;for(let o=s.length-1;o>=0;o--){const i=ML(s[o]);if(i)return i}}return null}const Yh=1e4,OL=w.lazy(()=>Ve(()=>import("./ProjectFilesPanel-DdllBXuv.js"),__vite__mapDeps([30,1,31,2,4,3])).then(n=>({default:n.ProjectFilesPanel}))),DL=w.lazy(()=>Ve(()=>import("./WorktreePanel-DbSH2Fyv.js"),__vite__mapDeps([32,1,2,3,4])).then(n=>({default:n.WorktreePanel}))),zL=w.lazy(()=>Ve(()=>import("./index-CmAiGDkv.js"),__vite__mapDeps([33,1,2,3,4])).then(n=>({default:n.BrowserPanel})));function hf(){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(nt,{}),"Loading panel…"]}),n[0]=e):e=n[0],e}function FL(n){const e=B.c(6),{context:t,closePanel:s}=n,o=nf(),i=o.projectFilesRoot??t.projectPath;if(!i)return null;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(hf,{}),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(w.Suspense,{fallback:a,children:r.jsx(OL,{cwd:i,onClose:s,onAddToPrompt:o.addProjectContext,openRequest:o.projectFilesRequest},i)}),e[1]=s,e[2]=i,e[3]=o.addProjectContext,e[4]=o.projectFilesRequest,e[5]=l):l=e[5],l}function BL(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(TE,{session:t.session,sessionChangeKey:t.sessionChangeKey}),e[0]=t.session,e[1]=t.sessionChangeKey,e[2]=s):s=e[2],s}function UL(){const n=B.c(7),e=nf();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(Vb,{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 WL(n){const e=B.c(3);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=r.jsx(hf,{}),e[0]=t):t=e[0];let s;return e[1]!==n?(s=r.jsx(w.Suspense,{fallback:t,children:r.jsx(zL,{...n})}),e[1]=n,e[2]=s):s=e[2],s}function HL(n){var d;const e=B.c(8),{context:t}=n,[,s]=w.useState(0);let o;e[0]!==t.session?(o=Date.parse(((d=LL(t.session))==null?void 0:d.timestamp)??""),e[0]=t.session,e[1]=o):o=e[1];const i=o;let a;e[2]!==i||e[3]!==s?(a=()=>{const u=i+Yh-Date.now();if(Number.isNaN(u)||u<=0)return;const f=setTimeout(()=>s(qL),u);return()=>clearTimeout(f)},e[2]=i,e[3]=s,e[4]=a):a=e[4];let l;if(e[5]!==i?(l=[i],e[5]=i,e[6]=l):l=e[6],w.useEffect(a,l),Number.isNaN(i)||Date.now()-i>=Yh)return null;let c;return e[7]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx("span",{role:"status","aria-label":"The agent is using the browser",className:"absolute -right-0.5 -top-0.5 size-2 rounded-full bg-emerald-500 motion-safe:animate-pulse"}),e[7]=c):c=e[7],c}function qL(n){return n+1}function KL(n){const e=B.c(8),{closePanel:t}=n,s=nf();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(hf,{}),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(w.Suspense,{fallback:o,children:r.jsx(DL,{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 VL={id:fo,workspacePanels:[{id:"worktrees",title:"Worktrees",icon:fn,component:KL,order:5,defaultSize:"36%",minSize:"320px",when:n=>n.supportsWorktrees===!0},{id:"project-files",title:"Project files",icon:Ow,component:FL,order:10,defaultSize:"55%",minSize:"340px",maxSize:"75%",keepAlive:!0,when:n=>n.canAccessHostFiles&&n.projectPath!==null},{id:"browser",title:"Browser",icon:wo,component:WL,indicator:HL,order:15,defaultSize:"46%",minSize:"360px",maxSize:"75%",keepAlive:!0,when:n=>n.canAccessHostFiles},{id:"file-changes",title:"File changes",icon:Wr,component:BL,order:20,defaultSize:"36%",minSize:"320px",when:n=>n.canAccessHostFiles&&n.hasFileChanges&&n.session!==null},{id:"session-info",title:"Session details",icon:Dw,component:UL,order:30,defaultSize:"36%",minSize:"320px",when:n=>n.session!==null}]},GL=oP([VL,...BM]);function bl(n){const e=B.c(4),{floating:t,children:s}=n;if(t){let i;return e[0]!==s?(i=r.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 z-20 flex justify-center bg-gradient-to-t from-background via-background/70 to-transparent pt-4",children:r.jsx("div",{className:"pointer-events-auto w-full max-w-[var(--chat-width)] px-3 pb-3",children:s})}),e[0]=s,e[1]=i):i=e[1],i}let o;return e[2]!==s?(o=r.jsx("div",{className:"flex w-full shrink-0 justify-center",children:r.jsx("div",{className:"w-full max-w-[var(--chat-width)] px-3 pb-3",children:s})}),e[2]=s,e[3]=o):o=e[3],o}function Yb(n){const e=B.c(11),{projectPath:t}=n;let s;e[0]!==t?(s=t?ns(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:Da(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 YL(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 XL(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 Xh(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 JL(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=L1,s="a",o=M1({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 QL(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 ZL(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(Ye,{}),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 gf(n){const e=B.c(56),{children:t,sessionLabel:s,customName:o,onDuplicate:i,onDelete:a,onRename:l,onArchive:c,onUnarchive:d,archiveDisabled:u}=n,f=u===void 0?!1:u,[m,p]=w.useState(!1),[h,g]=w.useState(!1),[x,v]=w.useState(""),y=w.useRef(null);let b;e[0]!==o?(b=function(){v(o||""),g(!0),requestAnimationFrame(()=>{var K;return(K=y.current)==null?void 0:K.select()})},e[0]=o,e[1]=b):b=e[1];const j=b;let S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx("div",{className:"w-full"}),e[2]=S):S=e[2];let k;e[3]!==t?(k=r.jsx(al,{render:S,children:t}),e[3]=t,e[4]=k):k=e[4];let C;e[5]!==f||e[6]!==c||e[7]!==i||e[8]!==l||e[9]!==d||e[10]!==j?(C=(l||i||c||d)&&r.jsxs(Bs,{children:[l&&r.jsxs(Wt,{onClick:j,children:[r.jsx(ts,{"data-icon":"inline-start"}),"Rename session"]}),i&&r.jsxs(Wt,{onClick:i,children:[r.jsx(pn,{"data-icon":"inline-start"}),"Duplicate session"]}),d?r.jsxs(Wt,{onClick:d,children:[r.jsx(Od,{"data-icon":"inline-start"}),"Restore from archive"]}):c&&r.jsxs(Wt,{onClick:c,disabled:f,children:[r.jsx(Nn,{"data-icon":"inline-start"}),f?"Archive (stop the session first)":"Archive session"]})]}),e[5]=f,e[6]=c,e[7]=i,e[8]=l,e[9]=d,e[10]=j,e[11]=C):C=e[11];let N;e[12]!==c||e[13]!==a||e[14]!==i||e[15]!==l||e[16]!==d?(N=a&&r.jsxs(r.Fragment,{children:[(i||l||c||d)&&r.jsx(Ao,{}),r.jsx(Bs,{children:r.jsxs(Wt,{variant:"destructive",onClick:()=>p(!0),children:[r.jsx(Ta,{"data-icon":"inline-start"}),"Delete session"]})})]}),e[12]=c,e[13]=a,e[14]=i,e[15]=l,e[16]=d,e[17]=N):N=e[17];let E;e[18]!==C||e[19]!==N?(E=r.jsxs(ll,{className:"min-w-44",children:[C,N]}),e[18]=C,e[19]=N,e[20]=E):E=e[20];let T;e[21]!==k||e[22]!==E?(T=r.jsxs(il,{children:[k,E]}),e[21]=k,e[22]=E,e[23]=T):T=e[23];let P;e[24]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(iu,{children:"Delete session?"}),e[24]=P):P=e[24];let _;e[25]!==s?(_=r.jsxs(ou,{children:[P,r.jsxs(au,{children:["This will permanently delete"," ",r.jsx("span",{className:"font-medium text-foreground",children:s}),". This action cannot be undone."]})]}),e[25]=s,e[26]=_):_=e[26];let A;e[27]===Symbol.for("react.memo_cache_sentinel")?(A=r.jsx(cu,{size:"sm",children:"Cancel"}),e[27]=A):A=e[27];let I;e[28]!==a?(I=r.jsxs(ru,{children:[A,r.jsx(lu,{variant:"destructive",size:"sm",onClick:()=>{a==null||a(),p(!1)},children:"Delete"})]}),e[28]=a,e[29]=I):I=e[29];let $;e[30]!==_||e[31]!==I?($=r.jsxs(su,{children:[_,I]}),e[30]=_,e[31]=I,e[32]=$):$=e[32];let R;e[33]!==m||e[34]!==$?(R=r.jsx(nu,{open:m,onOpenChange:p,children:$}),e[33]=m,e[34]=$,e[35]=R):R=e[35];let M;e[36]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsxs(Rs,{children:[r.jsx(ls,{className:"text-foreground",children:"Rename session"}),r.jsx(cs,{className:"text-muted-foreground",children:"Give this session a custom name. Clear to reset to default."})]}),e[36]=M):M=e[36];let O;e[37]!==l||e[38]!==x?(O=V=>{V.preventDefault(),l==null||l(x),g(!1)},e[37]=l,e[38]=x,e[39]=O):O=e[39];let D;e[40]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(wt,{htmlFor:"session-rename",children:"Session name"}),e[40]=D):D=e[40];let z;e[41]===Symbol.for("react.memo_cache_sentinel")?(z=V=>v(V.target.value),e[41]=z):z=e[41];let F;e[42]!==x||e[43]!==s?(F=r.jsxs(yt,{children:[D,r.jsx(Mt,{id:"session-rename",ref:y,value:x,onChange:z,placeholder:s})]}),e[42]=x,e[43]=s,e[44]=F):F=e[44];let L;e[45]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsxs(Hg,{children:[r.jsx(ee,{type:"button",variant:"ghost",size:"sm",onClick:()=>g(!1),children:"Cancel"}),r.jsx(ee,{type:"submit",size:"sm",children:"Save"})]}),e[45]=L):L=e[45];let H;e[46]!==O||e[47]!==F?(H=r.jsxs(as,{className:"sm:max-w-md",children:[M,r.jsxs("form",{className:"flex flex-col gap-4",onSubmit:O,children:[F,L]})]}),e[46]=O,e[47]=F,e[48]=H):H=e[48];let U;e[49]!==h||e[50]!==H?(U=r.jsx(is,{open:h,onOpenChange:g,children:H}),e[49]=h,e[50]=H,e[51]=U):U=e[51];let W;return e[52]!==R||e[53]!==U||e[54]!==T?(W=r.jsxs(r.Fragment,{children:[T,R,U]}),e[52]=R,e[53]=U,e[54]=T,e[55]=W):W=e[55],W}function Xb(n){function e(){try{const a=localStorage.getItem(Jt(n));return a?JSON.parse(a):{}}catch{return{}}}let t=e();const s=new Set;function o(){for(const a of s)a()}function i(){t=e(),o()}return typeof window<"u"&&(window.addEventListener("cogpit-device-changed",i),window.addEventListener("cogpit-identity-changed",i)),{subscribe:a=>(s.add(a),()=>{s.delete(a)}),getSnapshot:()=>t,rename:(a,l)=>{const c={...t},d=l.trim();d?c[a]=d:delete c[a],localStorage.setItem(Jt(n),JSON.stringify(c)),t=c,o()}}}const cd=Xb("session-custom-names"),dd=cd.rename;function Jb(){const n=B.c(2),e=w.useSyncExternalStore(cd.subscribe,cd.getSnapshot);let t;return n[0]!==e?(t={names:e,rename:dd},n[0]=e,n[1]=t):t=n[1],t}function Qb(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(En,{children:a?r.jsx(et,{className:"animate-spin","aria-label":"Searching session history"}):r.jsx(Yt,{"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(us,{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(En,{align:"inline-end",children:r.jsx(ei,{"aria-label":"Clear search",onClick:()=>s(""),size:"icon-xs",children:r.jsx(tt,{})})}),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(ds,{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 Zb(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(mn,{"aria-hidden":"true"}),i=r.jsx(Et,{children:"Could not load this data"}),e[0]=o,e[1]=i):(o=e[0],i=e[1]);let a;e[2]!==t?(a=r.jsx(ft,{children:t}),e[2]=t,e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Pt,{"data-icon":"inline-start"}),e[4]=l):l=e[4];let c;e[5]!==s?(c=r.jsx(Ts,{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(ut,{variant:"destructive",children:[o,i,a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d}function ev(n){const e=B.c(5),{count:t,includeMessagePlaceholder:s}=n,o=t===void 0?4:t,i=s===void 0?!1:s;let a;if(e[0]!==o||e[1]!==i){let l;e[3]!==i?(l=(c,d)=>r.jsxs("div",{children:[d>0&&r.jsx(Nt,{}),r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3.5",children:[r.jsx(it,{className:"size-8 shrink-0 rounded-md"}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[r.jsx(it,{className:"h-4 w-40 max-w-full"}),i&&r.jsx(it,{className:"h-3 w-72 max-w-full"}),r.jsx(it,{className:"h-3 w-52 max-w-full"})]}),r.jsx(it,{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 hi(n){return n==="idle"||n==="completed"}function vl(n){return hi(n)?"text-success":n==="thinking"||n==="deferred"?"text-warning":"text-info"}const ws={attention:"bg-warning",working:"bg-success ring-2 ring-success/30",idle:"bg-success/40"},eO=/(?:https?:\/\/)?github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/i,tO=/^([\w.-]+(?:\/[\w.-]+)?)#(\d+)$/,nO=/(?:^|\s)#(\d+)(?=\s|$)/,sO=/^(?:pr|pull\s+request)\s*#?(\d+)$/i;function qi(n){const e=Number(n);return Number.isSafeInteger(e)&&e>0?e:null}function oO(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 tv(n){const e=n.trim();if(!e)return null;const t=eO.exec(e);if(t){const l=qi(t[3]);return l===null?null:{number:l,repoHint:`${t[1]}/${t[2]}`.toLowerCase()}}const s=tO.exec(e);if(s){const l=qi(s[2]);return l===null?null:{number:l,repoHint:s[1].toLowerCase()}}const o=nO.exec(e);if(o){const l=qi(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:oO(c)}}const i=sO.exec(e);if(!i)return null;const a=qi(i[1]);return a===null?null:{number:a,repoHint:null}}function Jh(n,e){if(!n)return!1;const t=n.toLowerCase().replace(/\.git$/,"");return t===e||t.endsWith(`/${e}`)||e.endsWith(`/${t}`)}function rO(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 iO(n,e,t=[]){if(n.number!==e.number)return!1;const s=e.repoHint;return s?n.repo&&s.includes("/")?Jh(n.repo,s):Jh(n.repo,s)?!0:t.some(o=>rO(o,s)):!0}function nv(n,e,t=[]){var i;const s=tv(e);if(s){const a=[n.cwd,n.projectShortName,...t];return((i=n.pullRequests)==null?void 0:i.some(l=>iO(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 aO=120*1e3;function sv(n){return n?Date.now()-new Date(n).getTime()<aO:!1}function ov(n,e){const t=n.teamName?n.agentName:"",s=e||n.aiTitle||n.name||t||n.slug||n.firstUserMessage||n.customTitle;return s?jn(s,70):jn(n.sessionId,16)}function Qh(n){return n.trim().replace(/\s+/g," ").slice(0,40).toLowerCase()}function lO(n,e){const t=(n.lastUserMessage||n.firstUserMessage||"").trim();return!t||Qh(t)===Qh(e)?null:jn(t,220)}function cO(n,e){return nv(n,e)}function dO(n,e){if(!n||!e)return null;const t=new Date(e).getTime()-new Date(n).getTime();return t>=6e4?Un(t):null}function uO(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 fO(n){var t;const e=n.cwd?(t=za(n.cwd))==null?void 0:t.worktreeName:void 0;return e?{icon:zw,label:e,title:n.cwd}:n.gitBranch?{icon:fn,label:n.gitBranch}:null}function mO(n,e){return n.agentStatus==="deferred"?"attention":e?hi(n.agentStatus)?"idle":"working":null}function pO(n){const e=B.c(20),{session:t,live:s}=n;if(t.agentStatus==="deferred"){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(Pe,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"Needs review"}),e[0]=o):o=e[0],o}if(s){const o=hi(t.agentStatus);let i;e[1]!==t.agentPendingAgents||e[2]!==t.agentStatus||e[3]!==t.agentTerminalReason||e[4]!==t.agentToolName?(i=li(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=vl(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(Pe,{variant:"secondary",className:l,children:[u,a]}),e[12]=a,e[13]=l,e[14]=u,e[15]=f):f=e[15],f}if(t.agentTerminalReason){let o;e[16]!==t.agentTerminalReason?(o=Ku(t.agentTerminalReason),e[16]=t.agentTerminalReason,e[17]=o):o=e[17];let i;return e[18]!==o?(i=r.jsx(Pe,{variant:"outline",className:"max-w-44 truncate text-warning",children:o}),e[18]=o,e[19]=i):i=e[19],i}return null}function hc(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 hO(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=sv(i),l=mO(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,v,y,b,j,S,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=fO(t);let O;e[25]!==i||e[26]!==t.timestamp?(O=dO(t.timestamp,i),e[25]=i,e[26]=t.timestamp,e[27]=O):O=e[27];const D=O,z=t.turnCount??0;let F,L;e[28]!==s||e[29]!==t?(L=ov(t,s),F=lO(t,L),e[28]=s,e[29]=t,e[30]=F,e[31]=L):(F=e[30],L=e[31]);const H=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=uO(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(Cc,{className:"size-4"}),e[34]=U):U=e[34];let W;e[35]!==c?(W=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",ws[c])}),e[35]=c,e[36]=W):W=e[36],e[37]!==W?(h=r.jsxs("span",{className:"relative mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-md border bg-muted/40 text-muted-foreground",children:[U,W]}),e[37]=W,e[38]=h):h=e[38],S="flex min-w-0 flex-1 flex-col gap-1";let V;e[39]!==L?(V=r.jsx("span",{className:"truncate text-sm font-medium",children:L}),e[39]=L,e[40]=V):V=e[40];let K;e[41]!==d?(K=d&&r.jsxs(Pe,{variant:"outline",className:"shrink-0",children:[r.jsx(No,{"data-icon":"inline-start"}),jn(d,18)]}),e[41]=d,e[42]=K):K=e[42];let Y;e[43]!==t.branchedFrom?(Y=t.branchedFrom&&r.jsxs(Pe,{variant:"outline",className:"shrink-0",title:"Branched from another session",children:[r.jsx(Id,{"data-icon":"inline-start"}),"branch"]}),e[43]=t.branchedFrom,e[44]=Y):Y=e[44];let X;e[45]!==a||e[46]!==t?(X=r.jsx(pO,{session:t,live:a}),e[45]=a,e[46]=t,e[47]=X):X=e[47];let G;e[48]!==i?(G=i&&r.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:Oo(i)}),e[48]=i,e[49]=G):G=e[49];let J;e[50]!==X||e[51]!==G?(J=r.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2",children:[X,G]}),e[50]=X,e[51]=G,e[52]=J):J=e[52],e[53]!==V||e[54]!==K||e[55]!==Y||e[56]!==J?(k=r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[V,K,Y,J]}),e[53]=V,e[54]=K,e[55]=Y,e[56]=J,e[57]=k):k=e[57],e[58]!==H?(C=H&&r.jsx("span",{className:"line-clamp-1 text-sm text-muted-foreground",children:H}),e[58]=H,e[59]=C):C=e[59],x="flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",e[60]!==t.model?(v=t.model&&r.jsx(Pe,{variant:"outline",children:Ys(t.model)}),e[60]=t.model,e[61]=v):v=e[61],e[62]!==z?(y=z>0&&r.jsxs(hc,{icon:Cc,children:[z," ",z===1?"turn":"turns"]}),e[62]=z,e[63]=y):y=e[63],e[64]!==D?(b=D&&r.jsx(hc,{icon:Us,title:"First prompt to last activity",children:D}),e[64]=D,e[65]=b):b=e[65],j=M&&r.jsx(hc,{icon:M.icon,className:"max-w-40 truncate",title:M.title,children:jn(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]=v,e[19]=y,e[20]=b,e[21]=j,e[22]=S,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],v=e[18],y=e[19],b=e[20],j=e[21],S=e[22],k=e[23],C=e[24];let N;e[66]!==t.size?(N=Cg(t.size),e[66]=t.size,e[67]=N):N=e[67];let E;e[68]!==N?(E=r.jsx("span",{children:N}),e[68]=N,e[69]=E):E=e[69];let T;e[70]!==E||e[71]!==x||e[72]!==v||e[73]!==y||e[74]!==b||e[75]!==j?(T=r.jsxs("span",{className:x,children:[v,y,b,j,E]}),e[70]=E,e[71]=x,e[72]=v,e[73]=y,e[74]=b,e[75]=j,e[76]=T):T=e[76];let P;e[77]!==T||e[78]!==S||e[79]!==k||e[80]!==C?(P=r.jsxs("span",{className:S,children:[k,C,T]}),e[77]=T,e[78]=S,e[79]=k,e[80]=C,e[81]=P):P=e[81];let _;e[82]!==u||e[83]!==f||e[84]!==m||e[85]!==p||e[86]!==h||e[87]!==P?(_=r.jsxs("button",{type:u,onClick:f,title:m,className:p,children:[h,P]}),e[82]=u,e[83]=f,e[84]=m,e[85]=p,e[86]=h,e[87]=P,e[88]=_):_=e[88];let A;e[89]!==t.matchedPullRequestNumber||e[90]!==t.pullRequests?(A=t.matchedPullRequestNumber?r.jsxs(Pe,{variant:"outline",children:["Matched #",t.matchedPullRequestNumber]}):r.jsx(di,{pullRequests:t.pullRequests,max:2,compact:!0}),e[89]=t.matchedPullRequestNumber,e[90]=t.pullRequests,e[91]=A):A=e[91];let I;e[92]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(Ye,{className:"size-4 text-muted-foreground transition-transform group-hover:translate-x-0.5"}),e[92]=I):I=e[92];let $;e[93]!==A?($=r.jsxs("span",{className:"flex shrink-0 items-center gap-2 pt-1.5",children:[A,I]}),e[93]=A,e[94]=$):$=e[94];let R;return e[95]!==g||e[96]!==_||e[97]!==$?(R=r.jsxs("div",{className:g,children:[_,$]}),e[95]=g,e[96]=_,e[97]=$,e[98]=R):R=e[98],R}function gO(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:v,loadMoreSessions:y}=n,{names:b,rename:j}=Jb();let S;e[0]!==t.path?(S=ns(t.path),e[0]=t.path,e[1]=S):S=e[1];const k=S;let C;e[2]!==x?(C=r.jsx(Xh,{children:r.jsx(JL,{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(ZL,{}),e[4]=N):N=e[4];let E;e[5]!==k?(E=r.jsx(Xh,{className:"min-w-0",children:r.jsx(QL,{className:"truncate",children:k})}),e[5]=k,e[6]=E):E=e[6];let T;e[7]!==C||e[8]!==E?(T=r.jsx(YL,{children:r.jsxs(XL,{children:[C,N,E]})}),e[7]=C,e[8]=E,e[9]=T):T=e[9];let P;e[10]!==k?(P=r.jsx("h1",{className:"truncate text-2xl font-semibold tracking-tight",children:k}),e[10]=k,e[11]=P):P=e[11];let _;e[12]!==o?(_=r.jsx(Pe,{variant:"secondary",children:o}),e[12]=o,e[13]=_):_=e[13];let A;e[14]!==P||e[15]!==_?(A=r.jsxs("div",{className:"flex items-center gap-2",children:[P,_]}),e[14]=P,e[15]=_,e[16]=A):A=e[16];let I;e[17]!==t.path?(I=Da(t.path),e[17]=t.path,e[18]=I):I=e[18];let $;e[19]!==I?($=r.jsx("p",{className:"truncate text-sm text-muted-foreground",children:I}),e[19]=I,e[20]=$):$=e[20];let R;e[21]!==$||e[22]!==A?(R=r.jsxs("header",{className:"flex min-w-0 flex-col gap-1",children:[A,$]}),e[21]=$,e[22]=A,e[23]=R):R=e[23];let M;e[24]!==l||e[25]!==a||e[26]!==c?(M=r.jsx(Qb,{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 O;e[28]!==p||e[29]!==m||e[30]!==t.dirName||e[31]!==t.path?(O=m&&r.jsxs(ee,{size:"sm",disabled:p,onClick:()=>m(t.dirName,t.path),children:[p?r.jsx(nt,{"data-icon":"inline-start"}):r.jsx(Bn,{"data-icon":"inline-start"}),"New Session"]}),e[28]=p,e[29]=m,e[30]=t.dirName,e[31]=t.path,e[32]=O):O=e[32];let D;e[33]!==M||e[34]!==O?(D=r.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[M,O]}),e[33]=M,e[34]=O,e[35]=D):D=e[35];let z;e[36]!==u||e[37]!==v?(z=u&&r.jsx(Zb,{message:u,onRetry:v}),e[36]=u,e[37]=v,e[38]=z):z=e[38];let F;e[39]!==d||e[40]!==y||e[41]!==g||e[42]!==h||e[43]!==f||e[44]!==j||e[45]!==l||e[46]!==a||e[47]!==t.dirName||e[48]!==b||e[49]!==s||e[50]!==i||e[51]!==o?(F=(i||a)&&d.length===0?r.jsx(ev,{includeMessagePlaceholder:!0}):d.length===0?r.jsx(Kt,{className:"min-h-72 border",children:r.jsxs(Vt,{children:[r.jsx(en,{variant:"icon",children:r.jsx(Lo,{})}),r.jsx(Gt,{children:l?"No sessions match your search":"No sessions yet"}),r.jsx(tn,{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,W)=>r.jsxs(w.Fragment,{children:[W>0&&r.jsx(Nt,{}),r.jsx(gf,{sessionLabel:ov(U),customName:b[U.sessionId],onRename:V=>j(U.sessionId,V),onDuplicate:h?()=>h(t.dirName,U.fileName):void 0,onDelete:g?()=>g(t.dirName,U.fileName):void 0,children:r.jsx(hO,{session:U,customName:b[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:y,children:[i&&r.jsx(nt,{"data-icon":"inline-start"}),i?"Loading...":"Load more sessions"]})})]}),e[39]=d,e[40]=y,e[41]=g,e[42]=h,e[43]=f,e[44]=j,e[45]=l,e[46]=a,e[47]=t.dirName,e[48]=b,e[49]=s,e[50]=i,e[51]=o,e[52]=F):F=e[52];let L;e[53]!==D||e[54]!==z||e[55]!==F?(L=r.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Sessions",children:[D,z,F]}),e[53]=D,e[54]=z,e[55]=F,e[56]=L):L=e[56];let H;return e[57]!==R||e[58]!==L||e[59]!==T?(H=r.jsx(Vn,{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:[T,R,L]})}),e[57]=R,e[58]=L,e[59]=T,e[60]=H):H=e[60],H}function Na(n){const e=B.c(13),{projectPath:t,fallback:s,className:o}=n,[i,a]=w.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=Kr(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 rv(n){const e=B.c(40),{children:t,projectLabel:s,customName:o,className:i,onRename:a,archivableCount:l,onArchiveIdle:c}=n,d=l===void 0?0:l,[u,f]=w.useState(!1),[m,p]=w.useState(""),h=w.useRef(null);let g;e[0]!==o?(g=function(){p(o||""),f(!0),requestAnimationFrame(()=>{var D;return(D=h.current)==null?void 0:D.select()})},e[0]=o,e[1]=g):g=e[1];const x=g;let v;e[2]!==i?(v=q("w-full",i),e[2]=i,e[3]=v):v=e[3];let y;e[4]!==v?(y=r.jsx("div",{className:v}),e[4]=v,e[5]=y):y=e[5];let b;e[6]!==t||e[7]!==y?(b=r.jsx(al,{render:y,children:t}),e[6]=t,e[7]=y,e[8]=b):b=e[8];let j;e[9]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(ts,{"data-icon":"inline-start"}),e[9]=j):j=e[9];let S;e[10]!==x?(S=r.jsx(Bs,{children:r.jsxs(Wt,{onClick:x,children:[j,"Rename project"]})}),e[10]=x,e[11]=S):S=e[11];let k;e[12]!==d||e[13]!==c?(k=c&&r.jsxs(r.Fragment,{children:[r.jsx(Ao,{}),r.jsx(Bs,{children:r.jsxs(Wt,{onClick:c,disabled:d===0,children:[r.jsx(Nn,{"data-icon":"inline-start"}),d>0?`Archive ${d} idle ${d===1?"session":"sessions"}`:"Archive idle sessions"]})})]}),e[12]=d,e[13]=c,e[14]=k):k=e[14];let C;e[15]!==S||e[16]!==k?(C=r.jsxs(ll,{className:"min-w-44",children:[S,k]}),e[15]=S,e[16]=k,e[17]=C):C=e[17];let N;e[18]!==b||e[19]!==C?(N=r.jsxs(il,{children:[b,C]}),e[18]=b,e[19]=C,e[20]=N):N=e[20];let E;e[21]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsxs(Rs,{children:[r.jsx(ls,{className:"text-foreground",children:"Rename project"}),r.jsx(cs,{className:"text-muted-foreground",children:"Give this project a custom name. Clear to reset to default."})]}),e[21]=E):E=e[21];let T;e[22]!==a||e[23]!==m?(T=O=>{O.preventDefault(),a(m),f(!1)},e[22]=a,e[23]=m,e[24]=T):T=e[24];let P;e[25]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(wt,{htmlFor:"project-rename",children:"Project name"}),e[25]=P):P=e[25];let _;e[26]===Symbol.for("react.memo_cache_sentinel")?(_=O=>p(O.target.value),e[26]=_):_=e[26];let A;e[27]!==s||e[28]!==m?(A=r.jsxs(yt,{children:[P,r.jsx(Mt,{id:"project-rename",ref:h,value:m,onChange:_,placeholder:s})]}),e[27]=s,e[28]=m,e[29]=A):A=e[29];let I;e[30]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsxs(Hg,{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[30]=I):I=e[30];let $;e[31]!==T||e[32]!==A?($=r.jsxs(as,{className:"sm:max-w-md",children:[E,r.jsxs("form",{className:"flex flex-col gap-4",onSubmit:T,children:[A,I]})]}),e[31]=T,e[32]=A,e[33]=$):$=e[33];let R;e[34]!==u||e[35]!==$?(R=r.jsx(is,{open:u,onOpenChange:f,children:$}),e[34]=u,e[35]=$,e[36]=R):R=e[36];let M;return e[37]!==N||e[38]!==R?(M=r.jsxs(r.Fragment,{children:[N,R]}),e[37]=N,e[38]=R,e[39]=M):M=e[39],M}const ud=Xb("project-custom-names"),xO=ud.rename;function iv(){const n=B.c(2),e=w.useSyncExternalStore(ud.subscribe,ud.getSnapshot);let t;return n[0]!==e?(t={names:e,rename:xO},n[0]=e,n[1]=t):t=n[1],t}function bO(n){const e=B.c(45),{projects:t,activeSessions:s,loading:o,refreshing:i,searchFilter:a,setSearchFilter:l,fetchError:c,selectedProjectDirName:d,onSelectProject:u,onRefresh:f}=n;let m;if(e[0]!==s){m={};for(const R of s)sv(R.lastModified)&&(m[R.dirName]=(m[R.dirName]||0)+1);e[0]=s,e[1]=m}else m=e[1];const p=m,{names:h,rename:g}=iv();let x;e:{if(!a){x=t;break e}let R;if(e[2]!==h||e[3]!==t||e[4]!==a){const M=a.toLowerCase();R=t.filter(O=>{var D;return O.path.toLowerCase().includes(M)||O.shortName.toLowerCase().includes(M)||((D=h[O.dirName])==null?void 0:D.toLowerCase().includes(M))}),e[2]=h,e[3]=t,e[4]=a,e[5]=R}else R=e[5];x=R}const v=x;let y;e[6]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Projects"}),e[6]=y):y=e[6];let b;e[7]!==t.length?(b=r.jsxs("div",{className:"flex items-center gap-2",children:[y,r.jsx(Pe,{variant:"secondary",children:t.length})]}),e[7]=t.length,e[8]=b):b=e[8];let j;e[9]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx("p",{className:"text-sm text-muted-foreground",children:"Open a project to browse and resume its sessions."}),e[9]=j):j=e[9];let S;e[10]!==b?(S=r.jsxs("header",{className:"flex flex-col gap-1",children:[b,j]}),e[10]=b,e[11]=S):S=e[11];let k;e[12]!==a||e[13]!==l?(k=r.jsx(Qb,{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;e[17]!==N?(E=r.jsx(Pt,{"data-icon":"inline-start",className:N}),e[17]=N,e[18]=E):E=e[18];let T;e[19]!==f||e[20]!==i||e[21]!==E?(T=r.jsxs(ee,{variant:"outline",size:"sm",onClick:f,disabled:i,"aria-label":"Refresh projects",children:[E,"Refresh"]}),e[19]=f,e[20]=i,e[21]=E,e[22]=T):T=e[22];let P;e[23]!==T||e[24]!==k?(P=r.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[k,T]}),e[23]=T,e[24]=k,e[25]=P):P=e[25];let _;e[26]!==c||e[27]!==f||e[28]!==d?(_=c&&!d&&r.jsx(Zb,{message:c,onRetry:f}),e[26]=c,e[27]=f,e[28]=d,e[29]=_):_=e[29];let A;e[30]!==p||e[31]!==v||e[32]!==o||e[33]!==u||e[34]!==h||e[35]!==g||e[36]!==a?(A=o?r.jsx(ev,{}):v.length===0?r.jsx(Kt,{className:"min-h-72 border",children:r.jsxs(Vt,{children:[r.jsx(en,{variant:"icon",children:r.jsx(So,{})}),r.jsx(Gt,{children:a?"No projects match your search":"No projects yet"}),r.jsx(tn,{children:a?"Try a project name or path.":"Start Claude Code, Codex, or Copilot and its project will appear here."})]})}):r.jsx("div",{className:"overflow-hidden rounded-lg border bg-card",children:v.map((R,M)=>{const O=p[R.dirName]||0,D=h[R.dirName],z=F4(It(R.dirName));return r.jsxs(w.Fragment,{children:[M>0&&r.jsx(Nt,{}),r.jsx(rv,{projectLabel:ns(R.path),customName:D,onRename:F=>g(R.dirName,F),children:r.jsxs("button",{type:"button",onClick:()=>u==null?void 0:u(R.dirName),className:"motion-list-item group flex w-full flex-col gap-3 px-4 py-3.5 text-left outline-none transition-colors hover:bg-muted/50 focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset sm:flex-row sm:items-center",children:[r.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-3",children:[r.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-md border bg-muted/40",children:r.jsx(Na,{projectPath:R.path,className:"size-4",fallback:r.jsx(So,{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:D||ns(R.path)}),z&&r.jsx(Pe,{variant:"outline",className:"h-5 shrink-0 px-1.5 text-[10px]",children:z})]}),r.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:Da(R.path)})]})]}),r.jsxs("span",{className:"flex items-center gap-4 pl-11 text-sm text-muted-foreground sm:pl-0",children:[O>0&&r.jsxs(Pe,{variant:"secondary",children:[r.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:"size-1.5 rounded-full bg-success"}),O," active"]}),r.jsxs("span",{className:"whitespace-nowrap",children:[R.sessionCount," ",R.sessionCount===1?"session":"sessions"]}),R.lastModified&&r.jsx("span",{className:"hidden w-24 whitespace-nowrap text-right md:inline",children:Oo(R.lastModified)}),r.jsx(Ye,{className:"size-4 shrink-0 transition-transform group-hover:translate-x-0.5"})]})]})})]},R.dirName)})}),e[30]=p,e[31]=v,e[32]=o,e[33]=u,e[34]=h,e[35]=g,e[36]=a,e[37]=A):A=e[37];let I;e[38]!==P||e[39]!==_||e[40]!==A?(I=r.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Projects",children:[P,_,A]}),e[38]=P,e[39]=_,e[40]=A,e[41]=I):I=e[41];let $;return e[42]!==I||e[43]!==S?($=r.jsx(Vn,{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:[S,I]})}),e[42]=I,e[43]=S,e[44]=$):$=e[44],$}const vO=250,yO=400,Zh={results:null,loading:!1,error:null};function av(n,e){const t=w.useMemo(()=>tv(n),[n]),[s,o]=w.useState(0),[i,a]=w.useState(Zh);w.useEffect(()=>{if(!t){a(Zh);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 Ne(`/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()},yO);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()},vO);return()=>{clearTimeout(f),d&&clearTimeout(d),c.abort()}},[e,t,n,s]);const l=w.useCallback(()=>o(c=>c+1),[]);return{...i,active:t!==null,refresh:l}}const wO=w.memo(function({onSelectSession:e,onNewSession:t,creatingSession:s,selectedProjectDirName:o,onSelectProject:i,onDuplicateSession:a,onDeleteSession:l}){const[c]=w.useState(()=>({projects:ga(Zn.projects),activeSessions:ga(Zn.activeSessions)})),[d,u]=w.useState(c.projects??[]),[f,m]=w.useState(c.activeSessions??[]),[p,h]=w.useState(c.projects===void 0),[g,x]=w.useState(!1),[v,y]=w.useState([]),[b,j]=w.useState(0),[S,k]=w.useState(1),[C,N]=w.useState(!1),[E,T]=w.useState(""),[P,_]=w.useState(null),A=w.useRef(0),I=w.useRef(null),$=w.useCallback(async(U=!1)=>{U&&x(!0);try{const[W,V]=await Promise.all([Ne("/api/projects"),Ne("/api/active-sessions")]);if(!W.ok||!V.ok)throw new Error("Failed to fetch dashboard data");const K=await W.json(),Y=await V.json(),X=Array.isArray(K)?K:[],G=Array.isArray(Y)?Y:[];u(X),m(G),gr(Zn.projects,X),gr(Zn.activeSessions,G),_(null)}catch(W){_(W instanceof Error?W.message:"Failed to load data")}finally{h(!1),x(!1)}},[]);w.useEffect(()=>{$()},[$]);const R=w.useCallback(async(U,W=1,V=!1)=>{var G;const K=++A.current;(G=I.current)==null||G.abort();const Y=new AbortController;I.current=Y;const X=()=>K===A.current;if(N(!0),_(null),!V){const J=u8(U);J?(y(J.sessions),j(J.total),k(1)):y([])}try{const J=await Ne(`/api/sessions/${encodeURIComponent(U)}?page=${W}&limit=20`,{signal:Y.signal});if(!J.ok)throw new Error(`Failed to load sessions (${J.status})`);const Z=await J.json();if(!X())return;const Q=Array.isArray(Z.sessions)?Z.sessions:[],te=typeof Z.total=="number"?Z.total:Q.length;y(ne=>V?[...ne,...Q]:Q),j(te),k(W),V||f8(U,{sessions:Q,total:te})}catch(J){if(!X()||Y.signal.aborted)return;_(J instanceof Error?J.message:"Failed to load sessions")}finally{X()&&(I.current=null,N(!1))}},[]);w.useEffect(()=>{var U;if(!o){A.current+=1,(U=I.current)==null||U.abort(),I.current=null,y([]),j(0),k(1),T(""),N(!1);return}T(""),R(o)},[o,R]),w.useEffect(()=>()=>{var U;A.current+=1,(U=I.current)==null||U.abort()},[]);const M=w.useMemo(()=>{if(!o)return null;const U=d.find(V=>V.dirName===o);if(U)return U;const W=kn(o);return{dirName:o,path:W,shortName:ns(W),sessionCount:b,lastModified:null}},[o,d,b]),O=w.useCallback(()=>{i==null||i(null)},[i]),D=w.useCallback(()=>{o&&R(o,S+1,!0)},[o,S,R]),z=av(o?E:"",o??void 0),F=w.useMemo(()=>E?v.filter(U=>cO(U,E)):v,[v,E]),L=z.results??F;function H(U,W){l==null||l(U,W),y(V=>V.filter(K=>K.fileName!==W)),j(V=>V-1)}return M?r.jsx(gO,{selectedProject:M,sessions:v,sessionsTotal:b,sessionsLoading:C,searchLoading:z.loading,searchFilter:E,setSearchFilter:T,filteredSessions:L,fetchError:z.error??P,onSelectSession:e,onNewSession:t,creatingSession:s,onDuplicateSession:a,onDeleteSession:H,onBack:O,onRetryFetch:()=>{if(z.error){z.refresh();return}_(null),o&&R(o)},loadMoreSessions:D}):r.jsx(bO,{projects:d,activeSessions:f,loading:p,refreshing:g,searchFilter:E,setSearchFilter:T,fetchError:P,selectedProjectDirName:o??null,onSelectProject:i,onRefresh:()=>$(!0)})});async function lv(n,e,t){return(await Kn(`/api/permissions/${encodeURIComponent(n)}/respond`,{requestId:e,behavior:t})).ok}async function jO(n,e){return(await Kn(`/api/permissions/${encodeURIComponent(n)}/respond-all`,{behavior:e})).ok}function SO(n,e,t){return Qd("/api/elicitation-answer",{sessionId:n,requestId:e,...t})}function NO(n,e,t){return Qd("/api/user-dialog-answer",{sessionId:n,requestId:e,choice:t})}const kO=3e3,cv=w.createContext(null);async function gc(n,e){try{const t=await Ne(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 sr(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 Ki(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 CO({children:n}){const[e,t]=w.useState(new Map),[s,o]=w.useState(new Map),[i,a]=w.useState(new Map),[l,c]=w.useState(new Map),[d,u]=w.useState(new Set),[f,m]=w.useState(new Set),p=w.useRef(""),h=w.useRef(""),g=w.useRef(""),x=w.useCallback(async()=>{const[_,A,I]=await Promise.all([gc("/api/permissions",p),gc("/api/user-questions",h),gc("/api/agent-prompts",g)]);_&&(t(sr(_.bySession)),u(new Set(sr(_.plansBySession).keys()))),A&&o(sr(A.bySession)),I&&(a(sr(I.elicitationsBySession)),c(sr(I.dialogsBySession)))},[]);w.useEffect(()=>{const _=()=>{document.visibilityState==="visible"&&x()};_();const A=setInterval(_,kO);return document.addEventListener("visibilitychange",_),()=>{clearInterval(A),document.removeEventListener("visibilitychange",_)}},[x]);const v=w.useCallback(async(_,A)=>{m(I=>new Set(I).add(_));try{return await A()}finally{m(I=>{const $=new Set(I);return $.delete(_),$}),x()}},[x]),y=w.useCallback((_,A,I)=>v(A,async()=>{await lv(_,A,I).catch(()=>!1)&&(t(R=>Ki(R,_,M=>M.requestId===A)),p.current="")}),[v]),b=w.useCallback((_,A,I)=>v(A,async()=>{const $=await Zd(_,A,I);return $.ok&&(o(R=>Ki(R,_,M=>M.toolUseId===A)),h.current=""),$}),[v]),j=w.useCallback((_,A,I)=>v(A,async()=>{const $=await SO(_,A,I);return $.ok&&(a(R=>Ki(R,_,M=>M.requestId===A)),g.current=""),$}),[v]),S=w.useCallback((_,A,I)=>v(A,async()=>{const $=await NO(_,A,I);return $.ok&&(c(R=>Ki(R,_,M=>M.requestId===A)),g.current=""),$}),[v]),k=w.useMemo(()=>new Set(e.keys()),[e]),C=w.useMemo(()=>new Set(s.keys()),[s]),N=w.useMemo(()=>new Set(i.keys()),[i]),E=w.useMemo(()=>new Set(l.keys()),[l]),T=w.useCallback(()=>{x()},[x]),P=w.useMemo(()=>({permissionsBySession:e,questionsBySession:s,elicitationsBySession:i,dialogsBySession:l,awaitingPermission:k,awaitingQuestion:C,awaitingElicitation:N,awaitingDialog:E,awaitingPlan:d,responding:f,respond:y,answerQuestion:b,answerElicitation:j,answerDialog:S,refresh:T}),[e,s,i,l,k,C,N,E,d,f,y,b,j,S,T]);return r.jsx(cv.Provider,{value:P,children:n})}function _O(){const n=w.useContext(cv);if(!n)throw new Error("usePendingHumanInput must be used within a PendingHumanInputProvider");return n}const e1=768;function xf(){const n=B.c(2),[e,t]=w.useState(typeof window<"u"?window.innerWidth<e1:!1);let s,o;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{const i=window.matchMedia(`(max-width: ${e1-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]),w.useEffect(s,o),e}const dv=typeof navigator<"u"&&"vibrate"in navigator;function fd(){dv&&navigator.vibrate(10)}function TO(){dv&&navigator.vibrate(20)}async function EO(n,e){try{return(await Kn("/api/archive-sessions",{sessionIds:n,archived:e})).ok}catch{return!1}}function AO(n){return!!(n.teamName&&n.agentName)}function PO(n,e,t,s,o,i,a){const l=[],c=[];for(const d of ii(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(AO(d))continue;const u=a2(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||$u.has(d.agentStatus))&&c.push(d)}return{needsYou:l,working:c}}function IO(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 bf(n,e){return n?Ht(n).externalProcesses&&(e==null?void 0:e.managed)===!1:!1}const uv="aw:turnCounts",RO=200,yl=new Map;try{const n=localStorage.getItem(uv);if(n){const e=JSON.parse(n);for(const[t,s]of e)yl.set(t,s)}}catch{}function $O(){try{const n=[...yl.entries()].slice(-RO);localStorage.setItem(uv,JSON.stringify(n))}catch{}}function MO(n,e){yl.set(Jt(n),e),$O()}function fv(n,e){const t=yl.get(Jt(n));return Math.max(t??0,e??0)}function vf(n){const e=B.c(51),{session:t,proc:s,statusLabel:o,customName:i,worktreeName:a,projectLabel:l}=n,c=i||t.aiTitle,d=t.firstUserMessage,u=t.lastUserMessage&&t.lastUserMessage!==d?t.lastUserMessage:void 0,f=fv(t.sessionId,t.turnCount);let m;e[0]!==c?(m=c&&r.jsx("span",{className:"font-medium leading-snug text-foreground",children:c}),e[0]=c,e[1]=m):m=e[1];let p;e[2]!==l?(p=l&&r.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[r.jsx(Nr,{className:"size-3 shrink-0"}),r.jsx("span",{className:"truncate",children:l})]}),e[2]=l,e[3]=p):p=e[3];let h;e[4]!==t.agentStatus||e[5]!==o?(h=o&&r.jsx("span",{className:q("font-medium",vl(t.agentStatus)),children:o}),e[4]=t.agentStatus,e[5]=o,e[6]=h):h=e[6];let g;e[7]!==t.agentName||e[8]!==t.teamName?(g=t.teamName&&t.agentName&&r.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[r.jsx(An,{className:"size-3"}),t.agentName," · ",t.teamName]}),e[7]=t.agentName,e[8]=t.teamName,e[9]=g):g=e[9];let x;e[10]!==t.archived||e[11]!==t.archivedReason?(x=t.archived&&r.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[r.jsx(Nn,{className:"size-3"}),Ru(t.archivedReason)]}),e[10]=t.archived,e[11]=t.archivedReason,e[12]=x):x=e[12];let v;e[13]!==d||e[14]!==u?(v=d&&r.jsxs("div",{className:"flex flex-col gap-0.5",children:[u&&r.jsx("span",{className:"text-[10px] text-muted-foreground/70",children:"Started with"}),r.jsx("div",{className:"border-l-2 pl-2 text-muted-foreground",children:r.jsx("span",{"data-first-prompt":!0,className:"line-clamp-8 leading-relaxed",children:d})})]}),e[13]=d,e[14]=u,e[15]=v):v=e[15];let y;e[16]!==u?(y=u&&r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx("span",{className:"text-[10px] text-muted-foreground/70",children:"Latest"}),r.jsx("div",{className:"border-l-2 pl-2 text-muted-foreground",children:r.jsx("span",{"data-last-prompt":!0,className:"line-clamp-4 leading-relaxed",children:u})})]}),e[16]=u,e[17]=y):y=e[17];let b;e[18]!==t.pullRequests?(b=r.jsx(di,{pullRequests:t.pullRequests,layout:"list"}),e[18]=t.pullRequests,e[19]=b):b=e[19];let j;e[20]!==t.gitBranch||e[21]!==a?(j=t.gitBranch&&r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx(fn,{className:"size-2.5"}),a?`${t.gitBranch} · ${a}`:t.gitBranch]}),e[20]=t.gitBranch,e[21]=a,e[22]=j):j=e[22];let S;e[23]!==f?(S=f>0&&r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx(Lo,{className:"size-2.5"}),f," ",f===1?"turn":"turns"]}),e[23]=f,e[24]=S):S=e[24];let k;e[25]!==t.size?(k=Cg(t.size),e[25]=t.size,e[26]=k):k=e[26];let C;e[27]!==k?(C=r.jsx("span",{children:k}),e[27]=k,e[28]=C):C=e[28];let N;e[29]!==s?(N=s&&r.jsxs("span",{className:"flex items-center gap-0.5 text-success",children:[r.jsx(Fw,{className:"size-2.5"}),s.memMB," MB"]}),e[29]=s,e[30]=N):N=e[30];const E=t.lastActivityAt||t.lastModified;let T;e[31]!==E?(T=Oo(E),e[31]=E,e[32]=T):T=e[32];let P;e[33]!==T?(P=r.jsx("span",{children:T}),e[33]=T,e[34]=P):P=e[34];let _;e[35]!==S||e[36]!==C||e[37]!==N||e[38]!==P||e[39]!==j?(_=r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-muted-foreground",children:[j,S,C,N,P]}),e[35]=S,e[36]=C,e[37]=N,e[38]=P,e[39]=j,e[40]=_):_=e[40];let A;return e[41]!==m||e[42]!==_||e[43]!==p||e[44]!==h||e[45]!==g||e[46]!==x||e[47]!==v||e[48]!==y||e[49]!==b?(A=r.jsxs("div",{className:"flex w-72 flex-col gap-2 text-xs",children:[m,p,h,g,x,v,y,b,_]}),e[41]=m,e[42]=_,e[43]=p,e[44]=h,e[45]=g,e[46]=x,e[47]=v,e[48]=y,e[49]=b,e[50]=A):A=e[50],A}const LO=120;function yf(n){const e=B.c(7),t=w.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]),w.useEffect(s,o);let i;e[2]!==n?(i=()=>{n&&(t.current&&clearTimeout(t.current),t.current=setTimeout(n,LO))},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 OO=6;function DO(n){const e=B.c(7),{iso:t}=n,[,s]=w.useState(0);let o;e[0]!==s?(o=()=>{const c=setInterval(()=>s(zO),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],w.useEffect(o,i);let a;e[3]!==t?(a=Oo(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 zO(n){return n+1}const FO={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"}},BO={permission:ws.attention,deferred:ws.attention,waiting:ws.attention,question:"bg-warning",prompt:"bg-warning",plan:"bg-warning",done:"bg-success"};function t1(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 v;e[0]!==l||e[1]!==t.dirName?(v=bf(It(t.dirName),l),e[0]=l,e[1]=t.dirName,e[2]=v):v=e[2];const y=v;let b;e[3]!==s||e[4]!==y||e[5]!==t.agentPendingAgents||e[6]!==t.agentStatus||e[7]!==t.agentTerminalReason||e[8]!==t.agentToolName?(b=y?"Read-only":li(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??s.label,e[3]=s,e[4]=y,e[5]=t.agentPendingAgents,e[6]=t.agentStatus,e[7]=t.agentTerminalReason,e[8]=t.agentToolName,e[9]=b):b=e[9];const j=b,S=!!h&&!y,{onHoverStart:k,onHoverEnd:C}=yf(g),N=x?"px-2.5 py-2":"border px-2 py-2",E=a&&!x&&"ring-1 ring-ring";let T;e[10]!==i||e[11]!==N||e[12]!==E?(T=q("group relative w-full rounded-md text-left transition-colors",N,i,E),e[10]=i,e[11]=N,e[12]=E,e[13]=T):T=e[13];let P;e[14]!==x||e[15]!==a?(P=x&&a&&r.jsx("span",{className:"absolute inset-y-2 left-0 w-0.5 rounded-full bg-primary","aria-hidden":"true"}),e[14]=x,e[15]=a,e[16]=P):P=e[16];const _=S&&"pr-20";let A;e[17]!==_?(A=q("w-full rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",_),e[17]=_,e[18]=A):A=e[18];let I;e[19]!==C||e[20]!==k||e[21]!==m||e[22]!==A?(I=r.jsx("button",{type:"button","data-attention-session":!0,onClick:m,onMouseEnter:k,onMouseLeave:C,onFocus:k,onBlur:C,className:A}),e[19]=C,e[20]=k,e[21]=m,e[22]=A,e[23]=I):I=e[23];const $=x&&"ring-0";let R;e[24]!==o||e[25]!==$?(R=q("size-1.5 shrink-0 rounded-full",o,$),e[24]=o,e[25]=$,e[26]=R):R=e[26];let M;e[27]!==R?(M=r.jsx("span",{className:R,"aria-hidden":"true"}),e[27]=R,e[28]=M):M=e[28];let O;e[29]!==d||e[30]!==t?(O=ha(t,d),e[29]=d,e[30]=t,e[31]=O):O=e[31];let D;e[32]!==O?(D=r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs leading-tight text-foreground",children:O}),e[32]=O,e[33]=D):D=e[33];const z=x?"text-muted-foreground":s.className;let F;e[34]!==z?(F=q("shrink-0",z),e[34]=z,e[35]=F):F=e[35];const L=y?"Read-only":s.label;let H;e[36]!==F||e[37]!==L?(H=r.jsx(Pe,{variant:"outline",className:F,children:L}),e[36]=F,e[37]=L,e[38]=H):H=e[38];let U;e[39]!==x||e[40]!==t.lastActivityAt||e[41]!==t.lastModified?(U=!x&&r.jsx(DO,{iso:t.lastActivityAt||t.lastModified}),e[39]=x,e[40]=t.lastActivityAt,e[41]=t.lastModified,e[42]=U):U=e[42];let W;e[43]!==M||e[44]!==D||e[45]!==H||e[46]!==U?(W=r.jsxs("span",{className:"flex items-center gap-1.5",children:[M,D,H,U]}),e[43]=M,e[44]=D,e[45]=H,e[46]=U,e[47]=W):W=e[47];let V;e[48]!==u?(V=r.jsx("span",{className:"mt-1 block truncate pl-3 text-xs text-muted-foreground",children:u}),e[48]=u,e[49]=V):V=e[49];let K;e[50]!==I||e[51]!==W||e[52]!==V?(K=r.jsxs(Ct,{render:I,children:[W,V]}),e[50]=I,e[51]=W,e[52]=V,e[53]=K):K=e[53];let Y;e[54]!==d||e[55]!==l||e[56]!==t||e[57]!==j?(Y=r.jsx(_t,{side:"right",className:"max-w-[280px]",children:r.jsx(vf,{session:t,proc:l,statusLabel:j,customName:d})}),e[54]=d,e[55]=l,e[56]=t,e[57]=j,e[58]=Y):Y=e[58];let X;e[59]!==K||e[60]!==Y?(X=r.jsxs(kt,{children:[K,Y]}),e[59]=K,e[60]=Y,e[61]=X):X=e[61];let G;e[62]!==S||e[63]!==h?(G=S&&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($o,{"data-icon":"inline-start"}),"Resume"]}),e[62]=S,e[63]=h,e[64]=G):G=e[64];let J;e[65]!==y||e[66]!==c||e[67]!==p||e[68]!==l?(J=l&&p&&!y&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:Q=>p(l.pid,Q),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(tt,{"data-icon":"inline-start"})}),e[65]=y,e[66]=c,e[67]=p,e[68]=l,e[69]=J):J=e[69];let Z;return e[70]!==X||e[71]!==G||e[72]!==J||e[73]!==T||e[74]!==P?(Z=r.jsxs("div",{className:T,children:[P,X,G,J]}),e[70]=X,e[71]=G,e[72]=J,e[73]=T,e[74]=P,e[75]=Z):Z=e[75],Z}function UO(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 WO(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]=w.useState(!1);let h;e[0]!==t.working||e[1]!==m?(h=m?t.working:t.working.slice(0,OO),e[0]=t.working,e[1]=m,e[2]=h):h=e[2];const g=h,x=t.working.length-g.length;let v;e[3]!==l?(v=N=>l[N.dirName]||Pu(N.cwd||kn(N.dirName)),e[3]=l,e[4]=v):v=e[4];const y=v;let b;e[5]!==s||e[6]!==i||e[7]!==f||e[8]!==c||e[9]!==o||e[10]!==y||e[11]!==a?(b=N=>{const E=s===`${N.dirName}/${N.fileName}`;return{session:N,isActiveSession:E,proc:o.get(N.sessionId),killingPids:i,customName:a[N.sessionId],projectLabel:y(N),onSelect:()=>c(N.dirName,N.fileName),onPrefetch:f&&!E?()=>f(N.dirName,N.fileName):void 0}},e[5]=s,e[6]=i,e[7]=f,e[8]=c,e[9]=o,e[10]=y,e[11]=a,e[12]=b):b=e[12];const j=b;let S;e[13]!==t.needsYou||e[14]!==d||e[15]!==u||e[16]!==j?(S=t.needsYou.length>0&&r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx(UO,{dotClassName:ws.attention,labelClassName:"text-warning",label:"Needs you",count:t.needsYou.length}),t.needsYou.map(N=>{const{session:E,reason:T}=N;return r.jsx(t1,{...j(E),chip:FO[T],dotClassName:BO[T],cardClassName:"border-warning/20 bg-warning/5 hover:bg-warning/10",onKill:d,onResume:T==="deferred"&&u?()=>u(E.sessionId,E.cwd,E.dirName):void 0},`${E.dirName}/${E.fileName}`)})]}),e[13]=t.needsYou,e[14]=d,e[15]=u,e[16]=j,e[17]=S):S=e[17];let k;e[18]!==t.working.length||e[19]!==x||e[20]!==d||e[21]!==j||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(t1,{...j(N),chip:{label:IO(N),className:""},dotClassName:ws.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(mt,{"data-icon":"inline-start"}),"Show ",x," more"]})]}),e[18]=t.working.length,e[19]=x,e[20]=d,e[21]=j,e[22]=g,e[23]=k):k=e[23];let C;return e[24]!==S||e[25]!==k?(C=r.jsxs("div",{className:"flex flex-col gap-2","data-attention-strip":!0,children:[S,k]}),e[24]=S,e[25]=k,e[26]=C):C=e[26],C}function HO(n){const e=B.c(44),{loading:t,isMobile:s,searchQuery:o,searchLoading:i,showArchived:a,archivedCount:l,onSearchQueryChange:c,onToggleShowArchived:d,onRefresh:u}=n,f=l===0?"No archived sessions":`${l} archived ${l===1?"session":"sessions"}`;let m;e[0]!==c?(m=M=>c(M.target.value),e[0]=c,e[1]=m):m=e[1];let p;e[2]!==i||e[3]!==o||e[4]!==m?(p=r.jsx(us,{type:"search",value:o,onChange:m,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]=m,e[5]=p):p=e[5];let h;e[6]!==i?(h=r.jsx(En,{align:"inline-start",children:i?r.jsx(et,{className:"animate-spin"}):r.jsx(Yt,{})}),e[6]=i,e[7]=h):h=e[7];let g;e[8]!==c||e[9]!==o?(g=o&&r.jsx(En,{align:"inline-end",children:r.jsx(ei,{size:"icon-xs",onClick:()=>c(""),"aria-label":"Clear session search",children:r.jsx(tt,{"data-icon":"inline-start"})})}),e[8]=c,e[9]=o,e[10]=g):g=e[10];let x;e[11]!==p||e[12]!==h||e[13]!==g?(x=r.jsxs(ds,{children:[p,h,g]}),e[11]=p,e[12]=h,e[13]=g,e[14]=x):x=e[14];const v=s?"icon-sm":"icon-xs",y=a?"Hide archived sessions":"Show archived sessions",b=a&&"bg-accent text-accent-foreground";let j;e[15]!==b?(j=q(b),e[15]=b,e[16]=j):j=e[16];let S;e[17]!==d||e[18]!==a||e[19]!==v||e[20]!==y||e[21]!==j?(S=r.jsx(ee,{variant:"ghost",size:v,onClick:d,"aria-pressed":a,"aria-label":y,className:j}),e[17]=d,e[18]=a,e[19]=v,e[20]=y,e[21]=j,e[22]=S):S=e[22];let k;e[23]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(Nn,{"data-icon":"inline-start"}),e[23]=k):k=e[23];let C;e[24]!==S?(C=r.jsx(Ct,{render:S,children:k}),e[24]=S,e[25]=C):C=e[25];const N=a?"Hide archived":"Show archived";let E;e[26]!==f||e[27]!==N?(E=r.jsxs(_t,{side:"bottom",children:[N," · ",f]}),e[26]=f,e[27]=N,e[28]=E):E=e[28];let T;e[29]!==C||e[30]!==E?(T=r.jsxs(kt,{children:[C,E]}),e[29]=C,e[30]=E,e[31]=T):T=e[31];const P=s?"icon-sm":"icon-xs",_=t&&"animate-spin";let A;e[32]!==_?(A=q(_),e[32]=_,e[33]=A):A=e[33];let I;e[34]!==A?(I=r.jsx(Pt,{"data-icon":"inline-start",className:A}),e[34]=A,e[35]=I):I=e[35];let $;e[36]!==u||e[37]!==P||e[38]!==I?($=r.jsx(ee,{variant:"ghost",size:P,onClick:u,"aria-label":"Refresh sessions",children:I}),e[36]=u,e[37]=P,e[38]=I,e[39]=$):$=e[39];let R;return e[40]!==T||e[41]!==$||e[42]!==x?(R=r.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b px-2.5 py-2",children:[x,T,$]}),e[40]=T,e[41]=$,e[42]=x,e[43]=R):R=e[43],R}const qO=["first","second","third","fourth","fifth"];function KO(n){const e=B.c(31),{fetchError:t,showEmpty:s,searching:o,loading:i,sessionCount:a,hiddenArchivedCount:l,focusedProject:c,onShowAllProjects:d,onShowArchived:u,onRetry:f}=n,m=c===void 0?null:c;let p;e[0]!==m||e[1]!==l||e[2]!==o||e[3]!==s?(p=GO({showEmpty:s,searching:o,focusedProject:m,hiddenArchivedCount:l}),e[0]=m,e[1]=l,e[2]=o,e[3]=s,e[4]=p):p=e[4];const h=p;let g;e[5]!==t||e[6]!==f?(g=t&&r.jsxs(ut,{variant:"destructive",children:[r.jsx(mn,{}),r.jsx(Et,{children:"Could not load sessions"}),r.jsx(ft,{className:"truncate",children:t}),r.jsx(Ts,{children:r.jsx(ee,{variant:"outline",size:"xs",onClick:f,children:"Retry"})})]}),e[5]=t,e[6]=f,e[7]=g):g=e[7];let x;e[8]!==h||e[9]!==l||e[10]!==u?(x=h==="archived"&&r.jsxs(Kt,{className:"min-h-56 px-4 py-8",children:[r.jsxs(Vt,{children:[r.jsx(en,{variant:"icon",children:r.jsx(Nn,{})}),r.jsx(Gt,{children:"Everything is archived"}),r.jsx(tn,{children:l===1?"1 archived session is hidden.":`${l} archived sessions are hidden.`})]}),r.jsxs(ee,{variant:"outline",size:"sm",onClick:u,children:[r.jsx(Nn,{"data-icon":"inline-start"}),"Show archived"]})]}),e[8]=h,e[9]=l,e[10]=u,e[11]=x):x=e[11];let v;e[12]!==h||e[13]!==m||e[14]!==l||e[15]!==d||e[16]!==u||e[17]!==o?(v=h==="focused"&&r.jsxs(Kt,{className:"min-h-56 px-4 py-8",children:[r.jsxs(Vt,{children:[r.jsx(en,{variant:"icon",children:o?r.jsx(Yt,{}):r.jsx(kc,{})}),r.jsx(Gt,{children:o?`No matching sessions in ${m}`:`No sessions in ${m}`}),r.jsx(tn,{children:YO(o,l)})]}),r.jsxs("div",{className:"flex flex-wrap justify-center gap-2",children:[r.jsxs(ee,{variant:"outline",size:"sm",onClick:d,children:[r.jsx(oa,{"data-icon":"inline-start"}),"All projects"]}),!o&&l>0&&r.jsxs(ee,{variant:"ghost",size:"sm",onClick:u,children:[r.jsx(Nn,{"data-icon":"inline-start"}),"Show archived"]})]})]}),e[12]=h,e[13]=m,e[14]=l,e[15]=d,e[16]=u,e[17]=o,e[18]=v):v=e[18];let y;e[19]!==h||e[20]!==o?(y=h==="plain"&&r.jsx(Kt,{className:"min-h-56 px-4 py-8",children:r.jsxs(Vt,{children:[r.jsx(en,{variant:"icon",children:o?r.jsx(Yt,{}):r.jsx(kc,{})}),r.jsx(Gt,{children:o?"No matching sessions":"No sessions yet"}),r.jsx(tn,{children:o?"Try #157, honest-cms #157, or paste a PR URL.":"Start Claude Code, Codex, or Copilot to see recent work here."})]})}),e[19]=h,e[20]=o,e[21]=y):y=e[21];let b;e[22]!==i||e[23]!==a?(b=i&&a===0&&r.jsx("div",{className:"flex flex-col gap-2 px-2 py-4","aria-label":"Loading sessions",children:qO.map(VO)}),e[22]=i,e[23]=a,e[24]=b):b=e[24];let j;return e[25]!==g||e[26]!==x||e[27]!==v||e[28]!==y||e[29]!==b?(j=r.jsxs(r.Fragment,{children:[g,x,v,y,b]}),e[25]=g,e[26]=x,e[27]=v,e[28]=y,e[29]=b,e[30]=j):j=e[30],j}function VO(n){return r.jsxs("div",{className:"flex items-center gap-2 py-1",children:[r.jsx(it,{className:"size-2 shrink-0 rounded-full"}),r.jsx(it,{className:"h-4 flex-1"}),r.jsx(it,{className:"h-4 w-10"})]},n)}function GO({showEmpty:n,searching:e,focusedProject:t,hiddenArchivedCount:s}){return n?t!==null?"focused":!e&&s>0?"archived":"plain":null}function YO(n,e){return n?"Try another search, or look across every project.":e>0?"Its sessions may be archived. Start a new one, or look across every project.":"Start a new session here, or look across every project."}const xc=864e5;function XO(n){const e=new Date(n);return e.setHours(0,0,0,0),e.getTime()}function JO(n,e=Date.now()){const t=Date.parse(n);if(!Number.isFinite(t))return"Older";const s=XO(e);return t>=s?"Today":t>=s-xc?"Yesterday":t>=s-6*xc?"Last 7 days":t>=s-29*xc?"Last 30 days":"Older"}function mv(n,e,t=!1){const s=e!==void 0,o=n.isActive===!0,i=s||o,a=o&&hi(n.agentStatus),l=n.agentStatus==="deferred",c=bf(It(n.dirName),e);return{hasProcess:s,isLive:i,isNativeIdle:a,isDeferred:l,isReadOnly:c,isTeammate:!!(n.teamName&&n.agentName),isArchived:n.archived===!0,statusLabel:QO(n,{isReadOnly:c,isLive:i,isNativeIdle:a}),dotState:ZO(n,{isDeferred:l,isLive:i}),justFinished:!o&&s&&n.agentStatus==="completed"&&t}}function QO(n,{isReadOnly:e,isLive:t,isNativeIdle:s}){return e?"Read-only":t?s?"Running":li(n.agentStatus,n.agentToolName,n.agentTerminalReason,n.agentPendingAgents)??"Running":null}function ZO(n,{isDeferred:e,isLive:t}){return e?"attention":t?hi(n.agentStatus)?"idle":"working":null}function eD(n){var ht,Je;const e=B.c(154),{session:t,projectLabel:s,projectPath:o,showProject:i,isActiveSession:a,proc:l,killingPids:c,isNewlyCompleted:d,customName:u,worktreeName:f,teammateCount:m,teammatesCollapsed:p,onToggleTeammates:h,onSelectSession:g,onKill:x,onDuplicateSession:v,onDeleteSession:y,onArchiveSession:b,onUnarchiveSession:j,onRenameSession:S,onPrefetchSession:k,onResumeSession:C}=n,{isLive:N,isNativeIdle:E,isDeferred:T,isReadOnly:P,isTeammate:_,isArchived:A,statusLabel:I,dotState:$,justFinished:R}=mv(t,l,d),[M,O]=w.useState(!1);let D;e[0]!==u||e[1]!==t?(D=r2(t,u),e[0]=u,e[1]=t,e[2]=D):D=e[2];const z=D,F=Q7(t,u),L=i?s:void 0,H=t.lastUserMessage||t.firstUserMessage,U=!!H&&H!==z,W=fv(t.sessionId,t.turnCount);let V;e[3]!==t.archivedReason?(V=Ru(t.archivedReason),e[3]=t.archivedReason,e[4]=V):V=e[4];const K=V,Y=A?j&&{label:"Restore from archive",icon:Od,run:()=>j(t)}:b&&!N&&{label:"Archive session",icon:Nn,run:()=>b(t)},X=T&&!!C&&!P,G=!!m&&!!h,J=!!t.matchedPullRequestNumber||!!((ht=t.pullRequests)!=null&&ht.length),Z=X||G||J;let Q;e[5]!==a||e[6]!==k||e[7]!==t.dirName||e[8]!==t.fileName?(Q=k&&!a?()=>k(t.dirName,t.fileName):void 0,e[5]=a,e[6]=k,e[7]=t.dirName,e[8]=t.fileName,e[9]=Q):Q=e[9];const{onHoverStart:te,onHoverEnd:ne}=yf(Q);let oe;e[10]!==C||e[11]!==M||e[12]!==t.cwd||e[13]!==t.dirName||e[14]!==t.sessionId?(oe=()=>{!C||M||(O(!0),C(t.sessionId,t.cwd,t.dirName),setTimeout(()=>O(!1),3e3))},e[10]=C,e[11]=M,e[12]=t.cwd,e[13]=t.dirName,e[14]=t.sessionId,e[15]=oe):oe=e[15];const re=oe,ie=!0,se=A||void 0,ce=q("motion-list-item group relative flex flex-col rounded-lg border transition-colors",tD(a,R),A&&"opacity-60 hover:opacity-100 focus-within:opacity-100");let ae;e[16]!==g||e[17]!==t.dirName||e[18]!==t.fileName?(ae=()=>g(t.dirName,t.fileName),e[16]=g,e[17]=t.dirName,e[18]=t.fileName,e[19]=ae):ae=e[19];const ue=a?"true":void 0,me=Z?"pb-1.5":"pb-2.5";let de;e[20]!==me?(de=q("flex w-full flex-col gap-1.5 rounded-lg px-3 pt-2.5 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",me),e[20]=me,e[21]=de):de=e[21];let le;e[22]!==ne||e[23]!==te||e[24]!==de||e[25]!==ae||e[26]!==ue?(le=r.jsx("button",{type:"button","data-live-session":!0,onClick:ae,onMouseEnter:te,onMouseLeave:ne,onFocus:te,onBlur:ne,"aria-current":ue,className:de}),e[22]=ne,e[23]=te,e[24]=de,e[25]=ae,e[26]=ue,e[27]=le):le=e[27];let xe;e[28]!==L||e[29]!==o?(xe=L&&r.jsxs("span",{"data-session-project":!0,className:"flex items-center gap-1.5 pl-3.5 text-[11px] leading-tight text-muted-foreground",children:[r.jsx(Na,{projectPath:o,fallback:r.jsx(Nr,{className:"size-3 shrink-0","aria-hidden":"true"}),className:"size-3"}),r.jsx("span",{className:"truncate",children:L})]}),e[28]=L,e[29]=o,e[30]=xe):xe=e[30];let pe;e[31]!==$?(pe=$&&r.jsx("span",{"data-status-dot":$,className:q("size-1.5 rounded-full",ws[$])}),e[31]=$,e[32]=pe):pe=e[32];let ve;e[33]!==pe?(ve=r.jsx("span",{className:"mt-[7px] flex w-1.5 shrink-0 justify-center","aria-hidden":"true",children:pe}),e[33]=pe,e[34]=ve):ve=e[34];const Te=F?"text-muted-foreground":"font-medium text-foreground";let $e;e[35]!==Te?($e=q("line-clamp-2 flex-1 text-sm leading-snug",Te),e[35]=Te,e[36]=$e):$e=e[36];let _e;e[37]!==z||e[38]!==$e?(_e=r.jsx("span",{className:$e,children:z}),e[37]=z,e[38]=$e,e[39]=_e):_e=e[39];let Ce;e[40]!==ve||e[41]!==_e?(Ce=r.jsxs("span",{className:"flex items-start gap-2",children:[ve,_e]}),e[40]=ve,e[41]=_e,e[42]=Ce):Ce=e[42];let ke;e[43]!==H||e[44]!==U?(ke=U&&r.jsx("span",{className:"line-clamp-2 pl-3.5 text-xs leading-relaxed text-muted-foreground",children:H}),e[43]=H,e[44]=U,e[45]=ke):ke=e[45];let Me;e[46]!==T||e[47]!==N||e[48]!==E||e[49]!==t.agentStatus||e[50]!==I?(Me=N&&!T&&I&&r.jsx(Pe,{variant:"secondary","data-session-live-state":!0,className:q(E?"text-success":vl(t.agentStatus)),children:I}),e[46]=T,e[47]=N,e[48]=E,e[49]=t.agentStatus,e[50]=I,e[51]=Me):Me=e[51];let Oe;e[52]!==T?(Oe=T&&r.jsx(Pe,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"deferred"}),e[52]=T,e[53]=Oe):Oe=e[53];let Le;e[54]!==z||e[55]!==_||e[56]!==t.agentName?(Le=_&&r.jsxs(Pe,{variant:"outline",children:[r.jsx(No,{"data-icon":"inline-start"}),z!==t.agentName?t.agentName:"Agent"]}),e[54]=z,e[55]=_,e[56]=t.agentName,e[57]=Le):Le=e[57];let De;e[58]!==f?(De=f&&r.jsxs(Pe,{variant:"outline",children:[r.jsx(fn,{"data-icon":"inline-start"}),f]}),e[58]=f,e[59]=De):De=e[59];let Ie;e[60]!==t.gitBranch||e[61]!==f?(Ie=t.gitBranch&&!f&&r.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[r.jsx(fn,{className:"size-3 shrink-0","aria-hidden":"true"}),r.jsx("span",{className:"truncate",children:t.gitBranch})]}),e[60]=t.gitBranch,e[61]=f,e[62]=Ie):Ie=e[62];let he;e[63]!==W?(he=W>0&&r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Lo,{className:"size-3 shrink-0","aria-hidden":"true"}),W," ",W===1?"turn":"turns"]}),e[63]=W,e[64]=he):he=e[64];let ge;e[65]!==K||e[66]!==A?(ge=A&&r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Nn,{className:"size-3 shrink-0","aria-label":K,role:"img"}),"Archived"]}),e[65]=K,e[66]=A,e[67]=ge):ge=e[67];const Se=t.lastActivityAt||t.lastModified;let be;e[68]!==Se?(be=Oo(Se),e[68]=Se,e[69]=be):be=e[69];let Fe;e[70]!==be?(Fe=r.jsx("span",{className:"ml-auto tabular-nums",children:be}),e[70]=be,e[71]=Fe):Fe=e[71];let He;e[72]!==Me||e[73]!==Oe||e[74]!==Le||e[75]!==De||e[76]!==Ie||e[77]!==he||e[78]!==ge||e[79]!==Fe?(He=r.jsxs("span",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 pl-3.5 text-[11px] text-muted-foreground",children:[Me,Oe,Le,De,Ie,he,ge,Fe]}),e[72]=Me,e[73]=Oe,e[74]=Le,e[75]=De,e[76]=Ie,e[77]=he,e[78]=ge,e[79]=Fe,e[80]=He):He=e[80];let We;e[81]!==le||e[82]!==xe||e[83]!==Ce||e[84]!==ke||e[85]!==He?(We=r.jsxs(Ct,{render:le,children:[xe,Ce,ke,He]}),e[81]=le,e[82]=xe,e[83]=Ce,e[84]=ke,e[85]=He,e[86]=We):We=e[86];const Ee=L?void 0:s;let ze;e[87]!==u||e[88]!==l||e[89]!==t||e[90]!==I||e[91]!==Ee||e[92]!==f?(ze=r.jsx(_t,{side:"right",className:"max-w-[320px]",children:r.jsx(vf,{session:t,proc:l,statusLabel:I,customName:u,worktreeName:f,projectLabel:Ee})}),e[87]=u,e[88]=l,e[89]=t,e[90]=I,e[91]=Ee,e[92]=f,e[93]=ze):ze=e[93];let fe;e[94]!==We||e[95]!==ze?(fe=r.jsxs(kt,{children:[We,ze]}),e[94]=We,e[95]=ze,e[96]=fe):fe=e[96];let we;e[97]!==X||e[98]!==re||e[99]!==Z||e[100]!==G||e[101]!==h||e[102]!==M||e[103]!==t.matchedPullRequestNumber||e[104]!==t.pullRequests||e[105]!==m||e[106]!==p?(we=Z&&r.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 px-3 pb-2.5 pl-[26px]",children:[t.matchedPullRequestNumber?r.jsxs(Pe,{variant:"outline",className:"px-1",children:["Matched #",t.matchedPullRequestNumber]}):r.jsx(di,{pullRequests:t.pullRequests,max:2,compact:!0}),G&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:h,"aria-expanded":!p,"aria-label":p?`Show ${m} team agents`:`Hide ${m} team agents`,children:[r.jsx(An,{"data-icon":"inline-start"}),m,r.jsx(Ye,{"data-icon":"inline-end",className:q("transition-transform duration-150",!p&&"rotate-90")})]}),X&&r.jsxs(ee,{type:"button",variant:"outline",size:"xs",onClick:re,disabled:M,className:"text-warning",title:"Resume to evaluate deferred permission","aria-label":"Resume to evaluate",children:[r.jsx($o,{"data-icon":"inline-start"}),"Resume"]})]}),e[97]=X,e[98]=re,e[99]=Z,e[100]=G,e[101]=h,e[102]=M,e[103]=t.matchedPullRequestNumber,e[104]=t.pullRequests,e[105]=m,e[106]=p,e[107]=we):we=e[107];let Ue;e[108]!==Y?(Ue=Y&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:Y.run,className:"absolute bottom-1.5 right-1.5 bg-background/80 text-muted-foreground opacity-0 group-focus-within:opacity-100 group-hover:opacity-100 hover:text-foreground",title:Y.label,"aria-label":Y.label,children:r.jsx(Y.icon,{"data-icon":"inline-start"})}),e[108]=Y,e[109]=Ue):Ue=e[109];let Be;e[110]!==P||e[111]!==c||e[112]!==x||e[113]!==l?(Be=l&&x&&!P&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:Ke=>x(l.pid,Ke),disabled:c.has(l.pid),className:"absolute bottom-1.5 right-1.5 bg-background/80 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(tt,{"data-icon":"inline-start"})}),e[110]=P,e[111]=c,e[112]=x,e[113]=l,e[114]=Be):Be=e[114];let Ae;e[115]!==fe||e[116]!==we||e[117]!==Ue||e[118]!==Be||e[119]!==se||e[120]!==ce?(Ae=r.jsxs("div",{"data-session-card":ie,"data-archived":se,className:ce,children:[fe,we,Ue,Be]}),e[115]=fe,e[116]=we,e[117]=Ue,e[118]=Be,e[119]=se,e[120]=ce,e[121]=Ae):Ae=e[121];const qe=Ae;if(v||y||S||b||j){let Ke;e[122]!==t.firstUserMessage||e[123]!==t.sessionId||e[124]!==t.slug?(Ke=t.slug||((Je=t.firstUserMessage)==null?void 0:Je.slice(0,30))||t.sessionId.slice(0,12),e[122]=t.firstUserMessage,e[123]=t.sessionId,e[124]=t.slug,e[125]=Ke):Ke=e[125];let Ut;e[126]!==v||e[127]!==t.dirName||e[128]!==t.fileName?(Ut=v?()=>v(t.dirName,t.fileName):void 0,e[126]=v,e[127]=t.dirName,e[128]=t.fileName,e[129]=Ut):Ut=e[129];let At;e[130]!==y||e[131]!==t?(At=y?()=>y(t):void 0,e[130]=y,e[131]=t,e[132]=At):At=e[132];let sn;e[133]!==S||e[134]!==t.sessionId?(sn=S?Vo=>S(t.sessionId,Vo):void 0,e[133]=S,e[134]=t.sessionId,e[135]=sn):sn=e[135];let Ot;e[136]!==A||e[137]!==b||e[138]!==t?(Ot=b&&!A?()=>b(t):void 0,e[136]=A,e[137]=b,e[138]=t,e[139]=Ot):Ot=e[139];let Pn;e[140]!==A||e[141]!==j||e[142]!==t?(Pn=j&&A?()=>j(t):void 0,e[140]=A,e[141]=j,e[142]=t,e[143]=Pn):Pn=e[143];let Js;return e[144]!==qe||e[145]!==u||e[146]!==N||e[147]!==Ke||e[148]!==Ut||e[149]!==At||e[150]!==sn||e[151]!==Ot||e[152]!==Pn?(Js=r.jsx(gf,{sessionLabel:Ke,customName:u,onDuplicate:Ut,onDelete:At,onRename:sn,onArchive:Ot,onUnarchive:Pn,archiveDisabled:N,children:qe}),e[144]=qe,e[145]=u,e[146]=N,e[147]=Ke,e[148]=Ut,e[149]=At,e[150]=sn,e[151]=Ot,e[152]=Pn,e[153]=Js):Js=e[153],Js}return qe}function tD(n,e){return n?"border-foreground/15 bg-accent":e?"border-success/30 bg-success/10":"border-border/70 hover:border-border hover:bg-accent/50"}function nD(n){var me;const e=B.c(85),{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,onArchiveSession:x,onUnarchiveSession:v,onRenameSession:y,onPrefetchSession:b,onResumeSession:j}=n,{isLive:S,isNativeIdle:k,isDeferred:C,isReadOnly:N,isTeammate:E,isArchived:T,statusLabel:P,dotState:_,justFinished:A}=mv(t,o,a),[I,$]=w.useState(!1);let R;e[0]!==t.archivedReason?(R=Ru(t.archivedReason),e[0]=t.archivedReason,e[1]=R):R=e[1];const M=R;let O;e[2]!==l||e[3]!==t?(O=ha(t,l),e[2]=l,e[3]=t,e[4]=O):O=e[4];const D=O,z=T?v&&{label:"Restore from archive",icon:Od,run:()=>v(t)}:x&&!S&&{label:"Archive session",icon:Nn,run:()=>x(t)};let F;e[5]!==s||e[6]!==b||e[7]!==t.dirName||e[8]!==t.fileName?(F=b&&!s?()=>b(t.dirName,t.fileName):void 0,e[5]=s,e[6]=b,e[7]=t.dirName,e[8]=t.fileName,e[9]=F):F=e[9];const{onHoverStart:L,onHoverEnd:H}=yf(F);let U;e[10]!==j||e[11]!==I||e[12]!==t.cwd||e[13]!==t.dirName||e[14]!==t.sessionId?(U=de=>{de.stopPropagation(),!(!j||I)&&($(!0),j(t.sessionId,t.cwd,t.dirName),setTimeout(()=>$(!1),3e3))},e[10]=j,e[11]=I,e[12]=t.cwd,e[13]=t.dirName,e[14]=t.sessionId,e[15]=U):U=e[15];const W=U,V=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",sD(s,A),T&&"opacity-60 hover:opacity-100 focus-within:opacity-100");let K;e[16]!==m||e[17]!==t.dirName||e[18]!==t.fileName?(K=()=>m(t.dirName,t.fileName),e[16]=m,e[17]=t.dirName,e[18]=t.fileName,e[19]=K):K=e[19];let Y;e[20]!==H||e[21]!==L||e[22]!==K?(Y=r.jsx("button",{type:"button","data-live-session":!0,onClick:K,onMouseEnter:L,onMouseLeave:H,onFocus:L,onBlur:H,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring"}),e[20]=H,e[21]=L,e[22]=K,e[23]=Y):Y=e[23];let X;e[24]!==D?(X=r.jsx("span",{className:"flex-1 truncate text-sm leading-tight text-foreground",children:D}),e[24]=D,e[25]=X):X=e[25];let G;e[26]!==C?(G=C&&r.jsx(Pe,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"deferred"}),e[26]=C,e[27]=G):G=e[27];let J;e[28]!==c?(J=c&&r.jsxs(Pe,{variant:"outline",children:[r.jsx(fn,{"data-icon":"inline-start"}),c]}),e[28]=c,e[29]=J):J=e[29];let Z;e[30]!==l||e[31]!==o||e[32]!==t||e[33]!==P||e[34]!==c?(Z=r.jsx(_t,{side:"right",className:"max-w-[280px]",children:r.jsx(vf,{session:t,proc:o,statusLabel:P,customName:l,worktreeName:c})}),e[30]=l,e[31]=o,e[32]=t,e[33]=P,e[34]=c,e[35]=Z):Z=e[35];let Q;e[36]!==f||e[37]!==d||e[38]!==u?(Q=!!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(An,{"data-icon":"inline-start"}),d,r.jsx(Ye,{"data-icon":"inline-end",className:q("transition-transform duration-150",!u&&"rotate-90")})]}),e[36]=f,e[37]=d,e[38]=u,e[39]=Q):Q=e[39];let te;e[40]!==W||e[41]!==C||e[42]!==N||e[43]!==j||e[44]!==I?(te=C&&j&&!N&&r.jsxs(ee,{type:"button",variant:"outline",size:"xs",onClick:W,disabled:I,className:"shrink-0 text-warning",title:"Resume to evaluate deferred permission","aria-label":"Resume to evaluate",children:[r.jsx($o,{"data-icon":"inline-start"}),"Resume"]}),e[40]=W,e[41]=C,e[42]=N,e[43]=j,e[44]=I,e[45]=te):te=e[45];let ne;e[46]!==t.matchedPullRequestNumber||e[47]!==t.pullRequests?(ne=t.matchedPullRequestNumber?r.jsxs(Pe,{variant:"outline",className:"shrink-0 px-1",children:["Matched #",t.matchedPullRequestNumber]}):r.jsx(di,{pullRequests:t.pullRequests,max:1,compact:!0}),e[46]=t.matchedPullRequestNumber,e[47]=t.pullRequests,e[48]=ne):ne=e[48];let oe;e[49]!==M||e[50]!==T?(oe=T&&r.jsx(Nn,{className:"size-3 shrink-0 text-muted-foreground","aria-label":M,role:"img"}),e[49]=M,e[50]=T,e[51]=oe):oe=e[51];const re=t.lastActivityAt||t.lastModified;let ie;e[52]!==re?(ie=Oo(re),e[52]=re,e[53]=ie):ie=e[53];let se;e[54]!==ie?(se=r.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:ie}),e[54]=ie,e[55]=se):se=e[55];let ce;e[56]!==z?(ce=z&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:de=>{de.stopPropagation(),z.run()},className:"absolute right-0 top-0 bg-background/80 text-muted-foreground opacity-0 group-focus-within:opacity-100 group-hover:opacity-100 hover:text-foreground",title:z.label,"aria-label":z.label,children:r.jsx(z.icon,{"data-icon":"inline-start"})}),e[56]=z,e[57]=ce):ce=e[57];let ae;e[58]!==N||e[59]!==i||e[60]!==p||e[61]!==o?(ae=o&&p&&!N&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:de=>p(o.pid,de),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(tt,{"data-icon":"inline-start"})}),e[58]=N,e[59]=i,e[60]=p,e[61]=o,e[62]=ae):ae=e[62];const ue=r.jsxs("div",{className:V,"data-archived":T||void 0,children:[r.jsxs(kt,{children:[r.jsxs(Ct,{render:Y,children:[r.jsx("span",{className:"flex w-1.5 shrink-0 items-center justify-center","aria-hidden":"true",children:_&&r.jsx("span",{"data-status-dot":_,className:q("size-1.5 rounded-full",ws[_])})}),X,E&&r.jsxs(Pe,{variant:"outline",children:[r.jsx(No,{"data-icon":"inline-start"}),D!==t.agentName?t.agentName:"Agent"]}),S&&!C&&P&&r.jsx(Pe,{variant:"secondary","data-session-live-state":!0,className:q("shrink-0",k&&"text-success",!k&&vl(t.agentStatus)),children:P}),G,J]}),Z]}),Q,te,ne,oe,se,ce,ae]});if(h||g||y||x||v){let de;e[63]!==t.firstUserMessage||e[64]!==t.sessionId||e[65]!==t.slug?(de=t.slug||((me=t.firstUserMessage)==null?void 0:me.slice(0,30))||t.sessionId.slice(0,12),e[63]=t.firstUserMessage,e[64]=t.sessionId,e[65]=t.slug,e[66]=de):de=e[66];let le;e[67]!==h||e[68]!==t.dirName||e[69]!==t.fileName?(le=h?()=>h(t.dirName,t.fileName):void 0,e[67]=h,e[68]=t.dirName,e[69]=t.fileName,e[70]=le):le=e[70];let xe;e[71]!==g||e[72]!==t?(xe=g?()=>g(t):void 0,e[71]=g,e[72]=t,e[73]=xe):xe=e[73];let pe;e[74]!==y||e[75]!==t.sessionId?(pe=y?$e=>y(t.sessionId,$e):void 0,e[74]=y,e[75]=t.sessionId,e[76]=pe):pe=e[76];let ve;e[77]!==T||e[78]!==x||e[79]!==t?(ve=x&&!T?()=>x(t):void 0,e[77]=T,e[78]=x,e[79]=t,e[80]=ve):ve=e[80];let Te;return e[81]!==T||e[82]!==v||e[83]!==t?(Te=v&&T?()=>v(t):void 0,e[81]=T,e[82]=v,e[83]=t,e[84]=Te):Te=e[84],r.jsx(gf,{sessionLabel:de,customName:l,onDuplicate:le,onDelete:xe,onRename:pe,onArchive:ve,onUnarchive:Te,archiveDisabled:S,children:ue})}return ue}function sD(n,e){return n?"bg-accent":e?"bg-success/10":"hover:bg-accent/60"}function oD(n){const e=B.c(50),{sessions:t,pendingSession:s,older:o,showProject:i,activeSessionKey:a,procBySession:l,killingPids:c,newlyCompleted:d,sessionNames:u,projectNames:f,onSelectSession:m,onKill:p,onDuplicateSession:h,onDeleteSession:g,onArchiveSession:x,onUnarchiveSession:v,onRenameSession:y,onPrefetchSession:b,onResumeSession:j}=n;let S,k,C;if(e[0]!==t){S=Z7(t),C=ii(S.topLevelSessions);const U=Date.now(),W=C.map(V=>JO(V.lastActivityAt||V.lastModified,U));k=W.map((V,K)=>V===W[K-1]?null:V),e[0]=t,e[1]=S,e[2]=k,e[3]=C}else S=e[1],k=e[2],C=e[3];const N=k;let E;e[4]!==N||e[5]!==S.teammatesByLead||e[6]!==C?(E={topLevelSessions:C,teammatesByLead:S.teammatesByLead,shelves:N},e[4]=N,e[5]=S.teammatesByLead,e[6]=C,e[7]=E):E=e[7];const{topLevelSessions:T,teammatesByLead:P,shelves:_}=E;let A;e[8]===Symbol.for("react.memo_cache_sentinel")?(A=new Set,e[8]=A):A=e[8];const[I,$]=w.useState(A);let R;e[9]===Symbol.for("react.memo_cache_sentinel")?(R=U=>{$(W=>{const V=new Set(W);return V.has(U)?V.delete(U):V.add(U),V})},e[9]=R):R=e[9];const M=R;let O;e[10]!==a||e[11]!==c||e[12]!==d||e[13]!==x||e[14]!==g||e[15]!==h||e[16]!==p||e[17]!==b||e[18]!==y||e[19]!==j||e[20]!==m||e[21]!==v||e[22]!==l||e[23]!==u?(O=U=>({session:U,isActiveSession:a===bc(U),proc:l.get(U.sessionId),killingPids:c,isNewlyCompleted:d.has(U.sessionId),customName:u[U.sessionId],onSelectSession:m,onKill:p,onDuplicateSession:h,onDeleteSession:g,onArchiveSession:x,onUnarchiveSession:v,onRenameSession:y,onPrefetchSession:b,onResumeSession:j}),e[10]=a,e[11]=c,e[12]=d,e[13]=x,e[14]=g,e[15]=h,e[16]=p,e[17]=b,e[18]=y,e[19]=j,e[20]=m,e[21]=v,e[22]=l,e[23]=u,e[24]=O):O=e[24];const D=O;let z;e[25]!==s?(z=s&&r.jsx(iD,{firstMessage:s.firstMessage}),e[25]=s,e[26]=z):z=e[26];let F;if(e[27]!==I||e[28]!==f||e[29]!==D||e[30]!==_||e[31]!==i||e[32]!==P||e[33]!==T){let U;e[35]!==I||e[36]!==f||e[37]!==D||e[38]!==_||e[39]!==i||e[40]!==P?(U=(W,V)=>{const K=bc(W),Y=W.cwd??kn(W.dirName),X=za(Y),G=f[W.dirName]??Iu(W),J=P.get(W.sessionId),Z=I.has(W.sessionId),Q=_[V],te=r.jsx(eD,{...D(W),worktreeName:X==null?void 0:X.worktreeName,projectLabel:G,projectPath:(X==null?void 0:X.parentPath)??Y,showProject:i,teammateCount:J==null?void 0:J.length,teammatesCollapsed:J?Z:void 0,onToggleTeammates:J?()=>M(W.sessionId):void 0});return r.jsxs(w.Fragment,{children:[Q&&r.jsx(rD,{label:Q}),J&&!Z?r.jsxs("div",{className:"flex flex-col gap-px",children:[te,r.jsx("div",{className:"ml-3 flex flex-col gap-px border-l pl-1",children:J.map(ne=>r.jsx(nD,{...D(ne)},bc(ne)))})]}):te]},K)},e[35]=I,e[36]=f,e[37]=D,e[38]=_,e[39]=i,e[40]=P,e[41]=U):U=e[41],F=T.map(U),e[27]=I,e[28]=f,e[29]=D,e[30]=_,e[31]=i,e[32]=P,e[33]=T,e[34]=F}else F=e[34];let L;e[42]!==o.canLoad||e[43]!==o.load||e[44]!==o.loading?(L=o.canLoad&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:o.load,disabled:o.loading,className:"justify-start text-muted-foreground",children:[o.loading?r.jsx(et,{"data-icon":"inline-start",className:"animate-spin"}):r.jsx(V1,{"data-icon":"inline-start"}),"Load older sessions"]}),e[42]=o.canLoad,e[43]=o.load,e[44]=o.loading,e[45]=L):L=e[45];let H;return e[46]!==z||e[47]!==F||e[48]!==L?(H=r.jsxs("div",{className:"flex flex-col gap-1.5","data-session-card-list":!0,children:[z,F,L]}),e[46]=z,e[47]=F,e[48]=L,e[49]=H):H=e[49],H}function rD(n){const e=B.c(2),{label:t}=n;let s;return e[0]!==t?(s=r.jsx("div",{"data-recency-divider":!0,className:"px-1 pb-0.5 pt-2 text-[11px] font-medium text-muted-foreground/80 first:pt-0",children:t}),e[0]=t,e[1]=s):s=e[1],s}function iD(n){const e=B.c(3),{firstMessage:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(et,{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-lg border border-border/70 bg-accent px-3 py-2.5 text-left",children:[s,r.jsx("span",{className:"flex-1 truncate text-sm leading-tight text-foreground",children:o})]}),e[1]=o,e[2]=i):i=e[2],i}function bc(n){return`${n.dirName}/${n.fileName}`}function dr(n,e){return`${n} ${n===1?e:`${e}s`}`}function aD(n){if(!n)return"No sessions listed";const e=dr(n.total,"session");return n.live>0?`${e}, ${n.live} live`:e}function n1(n){const e=B.c(7),{count:t,label:s,className:o}=n;let i;e[0]!==o?(i=q("flex shrink-0 items-center gap-1 font-medium text-warning",o),e[0]=o,e[1]=i):i=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("span",{className:"size-1.5 rounded-full bg-warning","aria-hidden":"true"}),e[2]=a):a=e[2];let l;return e[3]!==t||e[4]!==s||e[5]!==i?(l=r.jsxs("span",{className:i,"aria-label":s,children:[a,t]}),e[3]=t,e[4]=s,e[5]=i,e[6]=l):l=e[6],l}function lD(n,e){return e===null?0:n.reduce((t,s)=>s.key===e?t:t+s.needsYou,0)}function cD(n){const e=B.c(67),{options:t,value:s,focused:o,totalSessions:i,onChange:a,onNewSession:l,creatingSession:c,onRenameProject:d,archivableCount:u,onArchiveIdle:f}=n,[m,p]=w.useState(!1),h=(o==null?void 0:o.customName)??s;let g;e[0]!==o||e[1]!==t.length||e[2]!==i||e[3]!==s?(g=s===null?`${dr(t.length,"project")}, ${dr(i,"session")}`:aD(o),e[0]=o,e[1]=t.length,e[2]=i,e[3]=s,e[4]=g):g=e[4];const x=g,v=lD(t,s);let y;e[5]!==a?(y=X=>{a(X),p(!1)},e[5]=a,e[6]=y):y=e[6];const b=y,j=s===null?"Choose a project to focus on":`Focused on ${h}. Change project`;let S;e[7]!==(o==null?void 0:o.cwd)||e[8]!==s?(S=s===null?r.jsx(oa,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):r.jsx(Na,{projectPath:(o==null?void 0:o.cwd)??null,fallback:r.jsx(Nr,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),className:"size-5"}),e[7]=o==null?void 0:o.cwd,e[8]=s,e[9]=S):S=e[9];const k=s===null?"All projects":h;let C;e[10]!==k?(C=r.jsx("span",{className:"truncate text-sm font-medium leading-tight text-foreground",children:k}),e[10]=k,e[11]=C):C=e[11];let N;e[12]!==x?(N=r.jsx("span",{className:"truncate text-[11px] leading-tight text-muted-foreground",children:x}),e[12]=x,e[13]=N):N=e[13];let E;e[14]!==C||e[15]!==N?(E=r.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[C,N]}),e[14]=C,e[15]=N,e[16]=E):E=e[16];let T;e[17]!==v?(T=v>0&&r.jsx(n1,{count:v,label:v===1?"1 session in another project is waiting for you":`${v} sessions in other projects are waiting for you`,className:"rounded-full border border-warning/30 bg-warning/10 px-1.5 py-0.5 text-[11px]"}),e[17]=v,e[18]=T):T=e[18];let P;e[19]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(Ur,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[19]=P):P=e[19];let _;e[20]!==j||e[21]!==S||e[22]!==E||e[23]!==T?(_=r.jsxs(Oa,{"aria-label":j,className:"flex h-11 min-w-0 flex-1 items-center gap-2.5 rounded-lg px-2 text-left outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring data-popup-open:bg-accent",children:[S,E,T,P]}),e[20]=j,e[21]=S,e[22]=E,e[23]=T,e[24]=_):_=e[24];const A=_;let I;e[25]!==u||e[26]!==o||e[27]!==f||e[28]!==d||e[29]!==A?(I=o&&d?r.jsx(rv,{projectLabel:o.key,customName:o.customName,className:"flex min-w-0 flex-1",archivableCount:u,onArchiveIdle:f,onRename:X=>d(o.dirName,X),children:A}):A,e[25]=u,e[26]=o,e[27]=f,e[28]=d,e[29]=A,e[30]=I):I=e[30];let $;e[31]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx(Q5,{placeholder:"Find a project",autoFocus:!0}),e[31]=$):$=e[31];let R;e[32]===Symbol.for("react.memo_cache_sentinel")?(R=r.jsx(Z5,{children:"No project matches."}),e[32]=R):R=e[32];const M=s===null;let O;e[33]!==b?(O=()=>b(null),e[33]=b,e[34]=O):O=e[34];let D,z;e[35]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(oa,{className:"text-muted-foreground","aria-hidden":"true"}),z=r.jsx("span",{className:"flex-1 truncate",children:"All projects"}),e[35]=D,e[36]=z):(D=e[35],z=e[36]);let F;e[37]!==i?(F=r.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:i}),e[37]=i,e[38]=F):F=e[38];let L;e[39]!==M||e[40]!==O||e[41]!==F?(L=r.jsx(aa,{children:r.jsxs(la,{value:"all-projects","data-checked":M,onSelect:O,className:"gap-2.5",children:[D,z,F]})}),e[39]=M,e[40]=O,e[41]=F,e[42]=L):L=e[42];let H;if(e[43]!==t||e[44]!==b||e[45]!==s){let X;e[47]!==b||e[48]!==s?(X=G=>r.jsxs(la,{value:G.key,keywords:G.customName?[G.customName]:void 0,"data-checked":s===G.key,onSelect:()=>b(G.key),className:"gap-2.5",children:[r.jsx(Na,{projectPath:G.cwd??null,fallback:r.jsx(Nr,{className:"text-muted-foreground","aria-hidden":"true"}),className:"size-4"}),r.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[r.jsx("span",{className:"truncate",children:G.customName??G.key}),G.customName&&r.jsx("span",{className:"truncate text-[11px] text-muted-foreground",children:G.key})]}),G.needsYou>0&&r.jsx(n1,{count:G.needsYou,label:`${dr(G.needsYou,"session")} waiting for you`,className:"text-xs"}),G.live>0&&r.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs font-medium text-success","aria-label":dr(G.live,"live session"),children:[r.jsx(Ua,{className:"size-1.5","aria-hidden":"true"}),G.live]}),r.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:G.total})]},G.key),e[47]=b,e[48]=s,e[49]=X):X=e[49],H=t.map(X),e[43]=t,e[44]=b,e[45]=s,e[46]=H}else H=e[46];let U;e[50]!==H?(U=r.jsx(aa,{heading:"Projects",children:H}),e[50]=H,e[51]=U):U=e[51];let W;e[52]!==L||e[53]!==U?(W=r.jsx(Sg,{className:"w-(--anchor-width) min-w-72 p-0",children:r.jsxs(Xd,{children:[$,r.jsxs(Jd,{children:[R,L,U]})]})}),e[52]=L,e[53]=U,e[54]=W):W=e[54];let V;e[55]!==m||e[56]!==I||e[57]!==W?(V=r.jsxs(La,{open:m,onOpenChange:p,children:[I,W]}),e[55]=m,e[56]=I,e[57]=W,e[58]=V):V=e[58];let K;e[59]!==c||e[60]!==o||e[61]!==h||e[62]!==l?(K=o&&l&&r.jsx(ee,{type:"button",variant:"outline",size:"icon-sm",className:"shrink-0",disabled:c,onClick:()=>l(o.dirName,o.cwd),"aria-label":`New session in ${h}`,children:c?r.jsx(et,{"data-icon":"inline-start",className:"animate-spin"}):r.jsx(Bn,{"data-icon":"inline-start"})}),e[59]=c,e[60]=o,e[61]=h,e[62]=l,e[63]=K):K=e[63];let Y;return e[64]!==V||e[65]!==K?(Y=r.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b px-2 py-1.5",children:[V,K]}),e[64]=V,e[65]=K,e[66]=Y):Y=e[66],Y}function dD(n,e){return n.reduce((t,s)=>s.isActive?t+1:e.has(s.sessionId)?s.agentStatus==="completed"?t:t+1:t,0)}function uD(n,e,t,s){return[...s8(n).entries()].map(([o,i])=>{const a=e8(i);return{key:o,customName:t[a.dirName],dirName:a.dirName,cwd:a.cwd,dirNames:[...new Set(i.map(l=>l.dirName))],total:i.length,live:dD(i,e),needsYou:i.filter(l=>s.has(l.sessionId)).length}})}function s1(n,e){return e===null?n:n.filter(t=>Iu(t)===e)}function fD(n,e){if(e.length===0)return n;const t=new Set(n.map(o=>o.sessionId)),s=e.filter(o=>!t.has(o.sessionId));return s.length===0?n:ii([...n,...s])}const o1={key:null,sessions:[],loading:!1,loaded:!1};function mD(n,e){const t=n.dirNames?n.dirNames.map(s=>new URLSearchParams({project:s,limit:"200"})):[new URLSearchParams({limit:"200",perProject:"100"})];if(e)for(const s of t)s.set("archived","include");return t}function pD(n,e){const t=B.c(9),s=n?`${e?"a":"l"}:${n.key}`:null,[o,i]=w.useState(o1),a=o.key===s?o:o1;let l;t[0]!==e||t[1]!==s||t[2]!==n?(l=async()=>{if(!(s===null||!n)){i({key:s,sessions:[],loading:!0,loaded:!1});try{const u=await Promise.all(mD(n,e).map(hD));i(f=>f.key===s?{key:s,sessions:u.flat(),loading:!1,loaded:!0}:f)}catch(u){const f=u;i(m=>m.key===s?{...m,loading:!1}:m),On.error(f instanceof Error?f.message:"Could not load older sessions")}}},t[0]=e,t[1]=s,t[2]=n,t[3]=l):l=t[3];const c=l;let d;return t[4]!==a.loaded||t[5]!==a.loading||t[6]!==a.sessions||t[7]!==c?(d={sessions:a.sessions,loading:a.loading,loaded:a.loaded,load:c},t[4]=a.loaded,t[5]=a.loading,t[6]=a.sessions,t[7]=c,t[8]=d):d=t[8],d}async function hD(n){const e=await Ne(`/api/active-sessions?${n}`);if(!e.ok)throw new Error(`Could not load older sessions (${e.status})`);const t=await e.json();return Array.isArray(t)?t:[]}const gD={key:"all"},xD=w.memo(function({activeSessionKey:e,onSelectSession:t,onDuplicateSession:s,onDeleteSession:o,onNewSession:i,creatingSession:a,pendingSession:l,refreshRef:c,onPrefetchSession:d}){const{names:u,rename:f}=Jb(),{names:m,rename:p}=iv(),h=tu(),g=Tn("terminal"),x=Tn("killAny"),{sessions:v,procBySession:y,newlyCompleted:b,loading:j,error:S,refresh:k,removeSession:C,acknowledgeCompleted:N,showArchived:E,setShowArchived:T,setSearchActive:P,archivedCount:_,setArchived:A}=p2(),{awaitingPermission:I,awaitingQuestion:$,awaitingElicitation:R,awaitingDialog:M,awaitingPlan:O}=_O(),D=w.useMemo(()=>new Set([...R,...M]),[R,M]),[z,F]=w.useState(new Set),[L,H]=w.useState(""),[U,W]=Wo(Jt("live-sessions-project-scope"),null),V=!!L.trim(),K=E||V;w.useEffect(()=>(P(V),()=>P(!1)),[V,P]);const Y=w.useRef(v),X=w.useRef(new Set),G=w.useRef(!1),J=w.useCallback((he,ge)=>{if(!G.current)return;const Se=setTimeout(()=>{X.current.delete(Se),G.current&&he()},ge);X.current.add(Se)},[]);w.useEffect(()=>{const he=X.current;return G.current=!0,()=>{G.current=!1;for(const ge of he)clearTimeout(ge);he.clear()}},[]),w.useEffect(()=>{Y.current=v},[v]),w.useEffect(()=>{if(c)return c.current=k,()=>{c.current===k&&(c.current=null)}},[k,c]);const Z=xf(),Q=av(L),te=w.useMemo(()=>n8(v,K),[v,K]),ne=K?0:_,oe=w.useMemo(()=>PO(te,y,b,I,$,D,O),[te,y,b,I,$,D,O]),re=w.useMemo(()=>new Set(oe.needsYou.map(he=>he.session.sessionId)),[oe]),ie=w.useMemo(()=>uD(te,y,m,re),[te,y,m,re]),se=U===null?null:ie.find(he=>he.key===U)??null,ce=(se==null?void 0:se.customName)??U,ae=pD(U===null?gD:se,K),ue=w.useMemo(()=>fD(s1(te,U),ae.sessions),[te,U,ae.sessions]),me=w.useMemo(()=>V?ue.filter(he=>{const ge=u[he.sessionId],Se=m[he.dirName];return nv(he,L,[ge,Se])}):ue,[ue,V,L,u,m]),de=w.useMemo(()=>Q.results?s1(Q.results,U):me,[Q.results,U,me]),le=oe.needsYou.length>0||oe.working.length>0,xe=!V&&le&&U===null,pe=w.useMemo(()=>U===null?[]:ue.filter(he=>!he.archived&&!i2(he,y)),[U,ue,y]),ve=U===null||l!=null&&Pu(l.cwd||kn(l.dirName))===U,Te=w.useRef(!1);w.useEffect(()=>{if(Te.current||!d||v.length===0)return;Te.current=!0;const he=ii(v).slice(0,3),ge=globalThis,Se=()=>{for(const He of he)d(He.dirName,He.fileName)};let be=null,Fe=null;return typeof ge.requestIdleCallback=="function"?be=ge.requestIdleCallback(Se,{timeout:1500}):Fe=setTimeout(Se,300),()=>{be!=null&&typeof ge.cancelIdleCallback=="function"&&ge.cancelIdleCallback(be),Fe!=null&&clearTimeout(Fe)}},[v,d]);const $e=w.useCallback(async(he,ge)=>{ge.stopPropagation(),F(Se=>new Set(Se).add(he));try{await Ne("/api/kill-process",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pid:he})}),J(k,1500)}catch{}J(()=>{F(Se=>{const be=new Set(Se);return be.delete(he),be})},2e3)},[k,J]),_e=w.useCallback((he,ge)=>{const Se=Y.current.find(be=>be.dirName===he&&be.fileName===ge);Se&&N(Se.sessionId),t(he,ge)},[t,N]),Ce=w.useCallback(he=>{o==null||o(he.dirName,he.fileName),C(he.sessionId)},[o,C]),ke=w.useCallback(async(he,ge,Se)=>{if(A(he,ge),!await EO(he,ge)){A(he,!ge),On.error(ge?"Could not archive session":"Could not restore session");return}k(),Se&&On(Se,{action:{label:"Undo",onClick:()=>{ke(he,!ge,null)}}})},[A,k]),Me=w.useCallback(he=>{ke([he.sessionId],!0,`Archived “${ha(he,u[he.sessionId])}”`)},[ke,u]),Oe=w.useCallback(he=>{ke([he.sessionId],!1,`Restored “${ha(he,u[he.sessionId])}”`)},[ke,u]),Le=w.useCallback(he=>{if(he.length===0)return;const ge=he.map(Se=>Se.sessionId);ke(ge,!0,`Archived ${ge.length} ${ge.length===1?"session":"sessions"}`)},[ke]),De=w.useCallback((he,ge,Se)=>{const{command:be,args:Fe}=aj(It(Se),he),He=`resume_${crypto.randomUUID().slice(0,8)}`;h.send({type:"spawn",id:He,name:`Resume ${he.slice(0,8)}`,command:be,args:Fe,cwd:ge??void 0,metadata:{type:"terminal"}}),J(k,3e3)},[h,k,J]),Ie={activeSessionKey:e,procBySession:y,killingPids:z,newlyCompleted:b,sessionNames:u,projectNames:m,onSelectSession:_e,onKill:x?$e:void 0,onDuplicateSession:s,onDeleteSession:o?Ce:void 0,onArchiveSession:Me,onUnarchiveSession:Oe,onRenameSession:f,onPrefetchSession:d,onResumeSession:g?De:void 0};return r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[r.jsx(HO,{loading:j,isMobile:Z,searchQuery:L,searchLoading:Q.loading,showArchived:E,archivedCount:_,onSearchQueryChange:H,onToggleShowArchived:()=>T(!E),onRefresh:()=>{TO(),k()}}),r.jsx(cD,{options:ie,value:U,focused:se,totalSessions:te.length,onChange:W,onNewSession:i,creatingSession:a,onRenameProject:p,archivableCount:pe.length,onArchiveIdle:()=>Le(pe)}),r.jsx(Vn,{className:"flex-1",children:r.jsxs("div",{className:"flex flex-col gap-4 p-2",children:[r.jsx(KO,{fetchError:Q.error??S,showEmpty:de.length===0&&!(l&&ve)&&!j&&!Q.loading&&!S&&!Q.error,searching:V,loading:j||Q.loading,sessionCount:Q.active?de.length:te.length,hiddenArchivedCount:ne,focusedProject:ce,onShowAllProjects:()=>W(null),onShowArchived:()=>T(!0),onRetry:Q.error?Q.refresh:k}),xe&&r.jsx(WO,{groups:oe,activeSessionKey:e,procBySession:y,killingPids:z,sessionNames:u,projectNames:m,onSelectSession:_e,onKill:x?$e:void 0,onResumeSession:g?De:void 0,onPrefetchSession:d}),r.jsx(oD,{...Ie,sessions:de,pendingSession:ve?l:null,showProject:U===null,older:{canLoad:(U===null||!!se)&&!ae.loaded&&!V,loading:ae.loading,load:ae.load}})]})})]})}),bD=w.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(xD,{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 v;return t[12]!==p||t[13]!==g||t[14]!==x?(v=r.jsxs("aside",{className:g,"aria-label":"Session browser",children:[p,x]}),t[12]=p,t[13]=g,t[14]=x,t[15]=v):v=t[15],v}),vD=w.lazy(()=>Ve(()=>import("./index-Bl7YHn3e.js"),__vite__mapDeps([34,1,2,3,4])).then(n=>({default:n.MissionControl})));function pv(n){const e=B.c(3),{label:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(nt,{className:"size-4"}),e[0]=s):s=e[0];let o;return e[1]!==t?(o=r.jsxs("div",{className:"motion-enter flex min-h-0 flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",role:"status",children:[s,t]}),e[1]=t,e[2]=o):o=e[2],o}function hv(n){const e=B.c(12),{navigation:t,mobile:s,header:o}=n,i=s===void 0?!1:s,{sessionSource:a}=ot(),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(bD,{activeSessionKey:l,onSelectSession:t.actions.handleDashboardSelect,onNewSession:t.onStartNewSession,creatingSession:t.creatingSession,pendingSession:t.pendingSession,onDuplicateSession:t.handlers.handleDuplicateSessionByPath,onDeleteSession:t.handlers.handleDeleteSession,liveSessionsRefreshRef:t.liveSessionsRefreshRef,onPrefetchSession:t.onPrefetchSession,isMobile:i,header:o}),e[0]=l,e[1]=o,e[2]=i,e[3]=t.actions.handleDashboardSelect,e[4]=t.creatingSession,e[5]=t.handlers.handleDeleteSession,e[6]=t.handlers.handleDuplicateSessionByPath,e[7]=t.liveSessionsRefreshRef,e[8]=t.onPrefetchSession,e[9]=t.onStartNewSession,e[10]=t.pendingSession,e[11]=c):c=e[11],c}function gv(n){const e=B.c(8),{navigation:t}=n,{state:s}=qt();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(wO,{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 yD(n){const e=B.c(3),{navigation:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(pv,{label:"Loading Mission Control…"}),e[0]=s):s=e[0];let o;return e[1]!==t.actions.handleDashboardSelect?(o=r.jsx(w.Suspense,{fallback:s,children:r.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 flex-col",children:r.jsx(vD,{onSelectSession:t.actions.handleDashboardSelect})})}),e[1]=t.actions.handleDashboardSelect,e[2]=o):o=e[2],o}function wD({mainView:n,hasSession:e,pendingDirName:t}){return n==="config"?"config":n==="mission"?"mission":e?"session":t?"pending":"dashboard"}function jD({sessionCwd:n,pendingPath:e,sessionDirPath:t,dashboardProjectPath:s}){return n??e??t??s??null}function SD({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 ND=w.lazy(()=>Ve(()=>import("./ConfigBrowser-CV_FDTPG.js"),__vite__mapDeps([35,1,2,31,3,4])).then(n=>({default:n.ConfigBrowser}))),kD=w.lazy(()=>Ve(()=>import("./PreviewPanel-DBIaGXu0.js"),__vite__mapDeps([36,1,2,3,4])).then(n=>({default:n.PreviewPanel})));function CD(n){const e=B.c(20),{sessionView:t,floatingChrome:s}=n,{session:o}=ot();if(!o)return null;let i;e[0]!==t.teamMembersBar?(i=t.teamMembersBar&&r.jsx("div",{className:"pt-10",children:t.teamMembersBar}),e[0]=t.teamMembersBar,e[1]=i):i=e[1];const a=!!t.todoProgress&&t.todosExpanded;let l;e[2]!==t.hasMoreTurns||e[3]!==t.isLoadingOlderTurns||e[4]!==t.onLoadMoreTurns||e[5]!==t.searchInputRef||e[6]!==a?(l=r.jsx(dl,{searchInputRef:t.searchInputRef,hasTodos:a,hasMore:t.hasMoreTurns,isLoadingOlder:t.isLoadingOlderTurns,onLoadMore:t.onLoadMoreTurns}),e[2]=t.hasMoreTurns,e[3]=t.isLoadingOlderTurns,e[4]=t.onLoadMoreTurns,e[5]=t.searchInputRef,e[6]=a,e[7]=l):l=e[7];let c;e[8]!==t.onTodosExpandedChange||e[9]!==t.todoProgress||e[10]!==t.todosExpanded?(c=t.todoProgress&&r.jsx(K0,{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(bl,{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 _D(n){const e=B.c(36),{navigation:t,sessionView:s,project:o,view:i,floatingChrome:a}=n,{state:l}=qt(),{session:c,sessionSource:d}=ot();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?kn(l.pendingDirName):null),i==="config"){let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(pv,{label:"Loading configuration…"}),e[9]=p):p=e[9];const h=r.jsx(ND,{projectPath:jD({sessionCwd:c==null?void 0:c.cwd,pendingPath:u,sessionDirPath:d!=null&&d.dirName?kn(d.dirName):null,dashboardProjectPath:l.dashboardProject?kn(l.dashboardProject):null}),initialFilePath:l.configFilePath});let g;e[10]!==h?(g=r.jsx(w.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(yD,{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(CD,{sessionView:s,floatingChrome:a}),e[14]=a,e[15]=s,e[16]=p):p=e[16],p}if(i==="pending"){const p=s.pendingTurns.length>0,h=Ws()?"Only on the machine running this session":void 0;let g;e[17]===Symbol.for("react.memo_cache_sentinel")?(g=fu()?void 0:h,e[17]=g):g=e[17];const x=g,v=!p&&"justify-center gap-4";let y;e[18]!==v?(y=q("flex min-h-0 min-w-0 flex-1 flex-col bg-background",v),e[18]=v,e[19]=y):y=e[19];let b;e[20]!==p||e[21]!==u||e[22]!==s.pendingTurns?(b=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(Yb,{projectPath:u}),e[20]=p,e[21]=u,e[22]=s.pendingTurns,e[23]=b):b=e[23];let j;e[24]!==s.pendingComposer?(j=r.jsx(bl,{children:s.pendingComposer}),e[24]=s.pendingComposer,e[25]=j):j=e[25];let S;e[26]!==p||e[27]!==o?(S=!p&&r.jsxs("div",{className:"flex items-center justify-center gap-2",children:[st("terminal")&&r.jsx(sc,{reason:h,children:r.jsxs(ee,{variant:"outline",size:"xs",disabled:!!h,onClick:o.onOpenTerminal,children:[r.jsx(Vs,{"data-icon":"inline-start"}),"Terminal"]})}),st("hostFiles")&&r.jsxs(r.Fragment,{children:[r.jsx(sc,{reason:x,children:r.jsxs(ee,{variant:"outline",size:"xs",disabled:!!x,onClick:()=>xx(o.pendingProject),children:[r.jsx(Pd,{"data-icon":"inline-start"}),"Open in editor"]})}),r.jsx(sc,{reason:h,children:r.jsxs(ee,{variant:"outline",size:"xs",disabled:!!h,onClick:()=>bx(o.pendingProject),children:[r.jsx(Y1,{"data-icon":"inline-start"}),"Reveal in files"]})})]})]}),e[26]=p,e[27]=o,e[28]=S):S=e[28];let k;return e[29]!==y||e[30]!==b||e[31]!==j||e[32]!==S?(k=r.jsxs("div",{className:y,children:[b,j,S]}),e[29]=y,e[30]=b,e[31]=j,e[32]=S,e[33]=k):k=e[33],k}let m;return e[34]!==t?(m=r.jsx(gv,{navigation:t}),e[34]=t,e[35]=m):m=e[35],m}function TD(n){const e=B.c(100),{navigation:t,sessionView:s,project:o,chrome:i}=n,{state:a,config:l}=qt(),{session:c,sessionSource:d}=ot();let u;e[0]!==s.chatInputRef?(u=function(se){var ae,ue,me;const ce=((ae=s.chatInputRef.current)==null?void 0:ae.getText().trimEnd())??"";(ue=s.chatInputRef.current)==null||ue.setText(ce?`${ce}
134
+
135
+ ${se}
136
+ `:`${se}
137
+ `),(me=s.chatInputRef.current)==null||me.focus()},e[0]=s.chatInputRef,e[1]=u):u=e[1];const f=u;let m;e[2]!==f?(m=function(se){const{path:ce,text:ae,startLine:ue,endLine:me,comment:de}=se;f(SD({path:ce,text:ae,startLine:ue,endLine:me,comment:de}))},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=wD({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 v=x,y=t.panels.handleToggleSidebar,b=t.actions.handleGoHome,j=i.onOpenCommandPalette;let S,k;e[8]===Symbol.for("react.memo_cache_sentinel")?(k=ec("toggleSidebar"),S=ec("commandPalette"),e[8]=S,e[9]=k):(S=e[8],k=e[9]);let C;e[10]!==i.onOpenCommandPalette||e[11]!==t.actions.handleGoHome||e[12]!==t.panels.handleToggleSidebar?(C=r.jsx(eR,{onToggleSidebar:y,onGoHome:b,onOpenCommandPalette:j,sidebarShortcut:k,commandPaletteShortcut:S}),e[10]=i.onOpenCommandPalette,e[11]=t.actions.handleGoHome,e[12]=t.panels.handleToggleSidebar,e[13]=C):C=e[13];const N=C,E=t.panels.showSidebar&&a.mainView!=="config",T=o.currentCwd??null;let P,_,A;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]!==T?(P={session:c,sessionChangeKey:a.sessionChangeKey,projectPath:T,hasFileChanges:o.hasFileChanges,canAccessHostFiles:st("hostFiles"),supportsWorktrees:o.supportsWorktrees,openSession:t.handlers.handleLoadSessionScrollAware,composePrompt:f},A=yb(GL,P),_=a.mainView==="sessions"?A.find(ie=>ie.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]=T,e[23]=P,e[24]=_,e[25]=A):(P=e[23],_=e[24],A=e[25]);const I=_,$=(d==null?void 0:d.dirName)??a.pendingDirName??a.dashboardProject??null;let R;e[26]!==t.panels||e[27]!==o?(R=function(se){o.showPreview&&o.onCloseRightWorkspace(),t.panels.toggleWorkspacePanel(se)},e[26]=t.panels,e[27]=o,e[28]=R):R=e[28];const M=R;let O;e[29]!==t.actions||e[30]!==t.panels||e[31]!==$?(O=function(se){$&&(t.actions.handleDashboardSelect($,`${se}.jsonl`),t.panels.closeWorkspacePanel())},e[29]=t.actions,e[30]=t.panels,e[31]=$,e[32]=O):O=e[32];const D=O,z=t.panels.showSidebar;let F;e[33]===Symbol.for("react.memo_cache_sentinel")?(F=ec("toggleSidebar"),e[33]=F):F=e[33];let L;e[34]!==i.killing||e[35]!==i.onKillAll||e[36]!==l.openConfigDialog||e[37]!==t.creatingSession||e[38]!==t.handlers.handleDuplicateSession||e[39]!==t.onStartNewSession||e[40]!==t.panels.handleToggleSidebar||e[41]!==t.panels.showSidebar||e[42]!==o.onOpenTerminal||e[43]!==s.onBackToMain||e[44]!==s.onShowWorkflows||e[45]!==s.workflowCount||e[46]!==E?(L=r.jsx(JI,{showSidebar:z,sidebarRendered:E,sidebarShortcut:F,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[34]=i.killing,e[35]=i.onKillAll,e[36]=l.openConfigDialog,e[37]=t.creatingSession,e[38]=t.handlers.handleDuplicateSession,e[39]=t.onStartNewSession,e[40]=t.panels.handleToggleSidebar,e[41]=t.panels.showSidebar,e[42]=o.onOpenTerminal,e[43]=s.onBackToMain,e[44]=s.onShowWorkflows,e[45]=s.workflowCount,e[46]=E,e[47]=L):L=e[47];const H=L;let U;e[48]!==t||e[49]!==N||e[50]!==E?(U=E&&r.jsx("div",{className:"view-transition-sidebar panel-enter w-80 shrink-0 border-r bg-sidebar text-sidebar-foreground",children:r.jsx(hv,{navigation:t,header:N})}),e[48]=t,e[49]=N,e[50]=E,e[51]=U):U=e[51];const W=I??null,V=o.projectFilesRoot??o.currentCwd??null;let K;e[52]!==p||e[53]!==t.actions.handleJumpToTurn||e[54]!==t.handlers.handleLoadSessionScrollAware||e[55]!==D||e[56]!==o.backgroundAgents||e[57]!==o.processPanel.handleServersChanged||e[58]!==o.processPanel.handleToggleServer||e[59]!==o.projectFilesRequest||e[60]!==o.worktrees||e[61]!==s.searchInputRef||e[62]!==V||e[63]!==$?(K={projectFilesRoot:V,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:D},e[52]=p,e[53]=t.actions.handleJumpToTurn,e[54]=t.handlers.handleLoadSessionScrollAware,e[55]=D,e[56]=o.backgroundAgents,e[57]=o.processPanel.handleServersChanged,e[58]=o.processPanel.handleToggleServer,e[59]=o.projectFilesRequest,e[60]=o.worktrees,e[61]=s.searchInputRef,e[62]=V,e[63]=$,e[64]=K):K=e[64];const Y=a.mainView==="mission";let X;e[65]!==t.panels.handleToggleMission||e[66]!==Y?(X={id:"mission-control",title:"Mission Control",icon:Bw,active:Y,onSelect:t.panels.handleToggleMission},e[65]=t.panels.handleToggleMission,e[66]=Y,e[67]=X):X=e[67];let G;e[68]!==t.panels.handleToggleConfig||e[69]!==a.mainView?(G=st("configWrite")?[{id:"config",title:"Config",icon:Uw,active:a.mainView==="config",onSelect:t.panels.handleToggleConfig}]:[],e[68]=t.panels.handleToggleConfig,e[69]=a.mainView,e[70]=G):G=e[70];let J;e[71]!==X||e[72]!==G?(J=[X,...G],e[71]=X,e[72]=G,e[73]=J):J=e[73];const Z=v!=="session"&&H;let Q;e[74]!==H||e[75]!==t||e[76]!==o||e[77]!==s||e[78]!==v?(Q=r.jsx(_D,{navigation:t,sessionView:s,project:o,view:v,floatingChrome:H}),e[74]=H,e[75]=t,e[76]=o,e[77]=s,e[78]=v,e[79]=Q):Q=e[79];let te;e[80]!==Z||e[81]!==Q?(te=r.jsxs("main",{className:"app-view-transition relative flex size-full min-w-0 flex-col overflow-hidden",children:[Z,Q]}),e[80]=Z,e[81]=Q,e[82]=te):te=e[82];let ne;e[83]!==t.panels.closeWorkspacePanel||e[84]!==P||e[85]!==W||e[86]!==K||e[87]!==J||e[88]!==te||e[89]!==M||e[90]!==A?(ne=r.jsx(lR,{panels:A,context:P,activePanel:W,services:K,onClosePanel:t.panels.closeWorkspacePanel,onTogglePanel:M,actions:J,children:te}),e[83]=t.panels.closeWorkspacePanel,e[84]=P,e[85]=W,e[86]=K,e[87]=J,e[88]=te,e[89]=M,e[90]=A,e[91]=ne):ne=e[91];let oe;e[92]!==o.currentCwd||e[93]!==o.onCloseRightWorkspace||e[94]!==o.showPreview?(oe=o.showPreview&&o.currentCwd&&r.jsx(w.Suspense,{fallback:null,children:r.jsx(kD,{cwd:o.currentCwd,onClose:o.onCloseRightWorkspace})}),e[92]=o.currentCwd,e[93]=o.onCloseRightWorkspace,e[94]=o.showPreview,e[95]=oe):oe=e[95];let re;return e[96]!==U||e[97]!==ne||e[98]!==oe?(re=r.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden bg-background",children:[U,ne,oe]}),e[96]=U,e[97]=ne,e[98]=oe,e[99]=re):re=e[99],re}function ED(n){const e=B.c(15),{navigation:t,sessionView:s,project:o,chrome:i}=n;let a,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(Y0,{}),l=r.jsx(G0,{}),e[0]=a,e[1]=l):(a=e[0],l=e[1]);let c;e[2]!==i||e[3]!==t||e[4]!==o||e[5]!==s?(c=r.jsx(TD,{navigation:t,sessionView:s,project:o,chrome:i}),e[2]=i,e[3]=t,e[4]=o,e[5]=s,e[6]=c):c=e[6];let d;e[7]!==i||e[8]!==t||e[9]!==o?(d=r.jsx(pP,{navigation:t,project:o,chrome:i}),e[7]=i,e[8]=t,e[9]=o,e[10]=d):d=e[10];let u;return e[11]!==i.backgroundServers||e[12]!==c||e[13]!==d?(u=r.jsxs("div",{className:"flex h-dvh flex-col bg-background text-foreground",children:[i.backgroundServers,a,l,c,d]}),e[11]=i.backgroundServers,e[12]=c,e[13]=d,e[14]=u):u=e[14],u}const AD=[{id:"sessions",label:"Sessions",icon:So},{id:"chat",label:"Chat",icon:Lo},{id:"stats",label:"Stats",icon:J1,requiresSession:!0}],PD=w.memo(function(e){const t=B.c(17),{activeTab:s,onTabChange:o}=e,{session:i,isLive:a}=ot(),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=AD.filter(m);c="flex shrink-0 items-stretch border-t bg-background pb-[env(safe-area-inset-bottom)]",d="Navigation";let h;t[9]!==s||t[10]!==a||t[11]!==o?(h=g=>{const x=g.icon,v=s===g.id;return r.jsx("button",{type:"button","aria-current":v?"page":void 0,"aria-label":g.label,title:g.label,onClick:()=>{fd(),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",v?"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",v?"scale-100 bg-accent":"scale-95"),children:[r.jsx(x,{className:q("size-[18px] transition-transform duration-150 ease-out motion-reduce:transition-none",v&&"scale-110"),"aria-hidden":"true"}),g.id==="chat"&&a&&r.jsx(Ua,{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 ID(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 v;e[0]!==l||e[1]!==t.cwd||e[2]!==s?(v=()=>{s&&l(s.dirName,t.cwd)},e[0]=l,e[1]=t.cwd,e[2]=s,e[3]=v):v=e[3];const y=v;let b;e[4]!==o||e[5]!==d?(b=o&&d&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:d,"aria-label":"Back to main agent",children:r.jsx(_d,{"data-icon":"inline-start"})}),e[4]=o,e[5]=d,e[6]=b):b=e[6];let j,S;e[7]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(Zu,{compact:!0}),S=r.jsx(Nt,{orientation:"vertical",className:"h-4"}),e[7]=j,e[8]=S):(j=e[7],S=e[8]);let k;e[9]!==i?(k=r.jsx(Kg,{rawMessages:i,warnOnly:!0}),e[9]=i,e[10]=k):k=e[10];let C;e[11]!==t.cwd?(C=t.cwd?ns(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;e[15]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsx(Bo,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Session actions"}),children:r.jsx(X1,{"data-icon":"inline-start"})}),e[15]=E):E=e[15];let T;e[16]!==t.cwd?(T=t.cwd?ns(t.cwd):"Current session",e[16]=t.cwd,e[17]=T):T=e[17];let P;e[18]!==T?(P=r.jsx("span",{className:"truncate text-foreground",children:T}),e[18]=T,e[19]=P):P=e[19];let _;e[20]!==t.gitBranch||e[21]!==t.model?(_=[t.model,t.gitBranch].filter(Boolean).join(" · ")||"Session actions",e[20]=t.gitBranch,e[21]=t.model,e[22]=_):_=e[22];let A;e[23]!==_?(A=r.jsx("span",{className:"truncate font-normal",children:_}),e[23]=_,e[24]=A):A=e[24];let I;e[25]!==P||e[26]!==A?(I=r.jsxs(qg,{className:"flex flex-col gap-0.5",children:[P,A]}),e[25]=P,e[26]=A,e[27]=I):I=e[27];let $;e[28]!==a||e[29]!==y||e[30]!==s?($=s&&r.jsxs(Bt,{onClick:y,disabled:a,children:[a?r.jsx(nt,{}):r.jsx(Bn,{}),r.jsx("span",{children:"New session"})]}),e[28]=a,e[29]=y,e[30]=s,e[31]=$):$=e[31];let R;e[32]!==c?(R=c&&r.jsxs(Bt,{onClick:c,children:[r.jsx(pn,{}),r.jsx("span",{children:"Duplicate session"})]}),e[32]=c,e[33]=R):R=e[33];let M;e[34]!==I||e[35]!==$||e[36]!==R?(M=r.jsxs(es,{children:[I,$,R]}),e[34]=I,e[35]=$,e[36]=R,e[37]=M):M=e[37];let O;e[38]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsx(ca,{}),e[38]=O):O=e[38];let D;e[39]!==h?(D=h&&r.jsxs(Bt,{onClick:h,children:[r.jsx(Yt,{}),r.jsx("span",{children:"Search conversation"})]}),e[39]=h,e[40]=D):D=e[40];let z;e[41]!==g||e[42]!==x?(z=x&&r.jsxs(Bt,{onClick:x,children:[g?r.jsx(Ia,{}):r.jsx(Ur,{}),r.jsx("span",{children:g?"Collapse tool calls":"Expand tool calls"})]}),e[41]=g,e[42]=x,e[43]=z):z=e[43];let F;e[44]!==f||e[45]!==u?(F=f&&u&&r.jsxs(Bt,{onClick:u,children:[r.jsx(Wr,{}),r.jsx("span",{children:"File changes"})]}),e[44]=f,e[45]=u,e[46]=F):F=e[46];let L;e[47]!==m||e[48]!==p?(L=m&&(p??0)>0&&r.jsxs(Bt,{onClick:m,children:[r.jsx(Md,{}),r.jsx("span",{className:"flex-1",children:"Workflows"}),r.jsx(Pe,{variant:"secondary",children:p})]}),e[47]=m,e[48]=p,e[49]=L):L=e[49];let H;e[50]!==D||e[51]!==z||e[52]!==F||e[53]!==L?(H=r.jsxs(es,{children:[D,z,F,L]}),e[50]=D,e[51]=z,e[52]=F,e[53]=L,e[54]=H):H=e[54];let U;e[55]!==M||e[56]!==H?(U=r.jsxs(Fo,{children:[E,r.jsxs(Uo,{align:"end",sideOffset:6,className:"w-72",children:[M,O,H]})]}),e[55]=M,e[56]=H,e[57]=U):U=e[57];let W;return e[58]!==b||e[59]!==U||e[60]!==k||e[61]!==N?(W=r.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-1.5 border-b bg-background px-2",children:[b,j,S,k,N,U]}),e[58]=b,e[59]=U,e[60]=k,e[61]=N,e[62]=W):W=e[62],W}const RD=w.memo(function(e){const t=B.c(11),{isMobile:s}=qt(),{session:o,sessionSource:i}=ot();if(!s||!o)return null;let a;t[0]!==i?(a=i?Cs(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=ko(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(ID,{...e,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}),$D=50;function MD({onSwipeLeft:n,onSwipeRight:e}){const t=w.useRef(null),s=w.useRef(null),o=w.useRef(n),i=w.useRef(e);return o.current=n,i.current=e,w.useEffect(()=>{const a=t.current;if(!a)return;function l(d){const u=d.touches[0];s.current={x:u.clientX,y:u.clientY}}function c(d){var p,h;if(!s.current)return;const u=d.changedTouches[0],f=u.clientX-s.current.x,m=u.clientY-s.current.y;s.current=null,!(Math.abs(f)<$D||Math.abs(f)<Math.abs(m))&&(f>0?(p=i.current)==null||p.call(i):(h=o.current)==null||h.call(o))}return a.addEventListener("touchstart",l,{passive:!0}),a.addEventListener("touchend",c,{passive:!0}),()=>{a.removeEventListener("touchstart",l),a.removeEventListener("touchend",c)}},[]),t}const LD=["sessions","chat","stats"];function OD({hasSession:n,hasPendingSession:e}){return LD.filter(t=>!(t==="stats"&&!n&&!e))}function r1(n,e,t){const s=n.indexOf(e);return s===-1?null:n[s+t]??null}const DD=w.lazy(()=>Ve(()=>import("./MobileFileChanges-qnY-uxZ_.js"),__vite__mapDeps([37,1,2,3,4])).then(n=>({default:n.MobileFileChanges})));function zD(n){const e=B.c(70),{navigation:t,sessionView:s,project:o,chrome:i}=n,{state:a}=qt(),{session:l,isSubAgentView:c}=ot(),[d,u]=w.useState(!1),f=!!l,m=!!a.pendingDirName;let p;e[0]!==f||e[1]!==m?(p=OD({hasSession:f,hasPendingSession:m}),e[0]=f,e[1]=m,e[2]=p):p=e[2];const h=p;let g;e[3]!==t.actions||e[4]!==a.mobileTab||e[5]!==h?(g={onSwipeLeft:()=>{const F=r1(h,a.mobileTab,1);F&&(fd(),t.actions.handleMobileTabChange(F))},onSwipeRight:()=>{const F=r1(h,a.mobileTab,-1);F&&(fd(),t.actions.handleMobileTabChange(F))}},e[3]=t.actions,e[4]=a.mobileTab,e[5]=h,e[6]=g):g=e[6];const x=MD(g);let v;e[7]!==t.actions?(v=F=>{u(!1),t.actions.handleMobileTabChange(F)},e[7]=t.actions,e[8]=v):v=e[8];const y=v,b=i.backgroundServers;let j,S;e[9]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(Y0,{}),S=r.jsx(G0,{}),e[9]=j,e[10]=S):(j=e[9],S=e[10]);let k;e[11]!==l||e[12]!==a.mobileTab?(k=!(a.mobileTab==="chat"&&l)&&r.jsx("div",{className:"motion-slide-down-in flex h-12 shrink-0 items-center border-b bg-background px-2",children:r.jsx(Zu,{compact:!0})}),e[11]=l,e[12]=a.mobileTab,e[13]=k):k=e[13];const C=a.mobileTab,N=!(a.mobileTab==="chat"&&l)&&"motion-session-enter";let E;e[14]!==N?(E=q("flex min-h-0 min-w-0 flex-1",N),e[14]=N,e[15]=E):E=e[15];let T;e[16]!==t||e[17]!==a.mobileTab?(T=a.mobileTab==="sessions"&&r.jsx(hv,{navigation:t,mobile:!0}),e[16]=t,e[17]=a.mobileTab,e[18]=T):T=e[18];let P;e[19]!==i||e[20]!==c||e[21]!==t||e[22]!==o||e[23]!==d||e[24]!==l||e[25]!==s||e[26]!==a.expandAll||e[27]!==a.mobileTab||e[28]!==a.pendingDirName?(P=a.mobileTab==="chat"&&r.jsx("div",{className:"flex flex-1 min-h-0 flex-col min-w-0",children:l?r.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[s.teamMembersBar,r.jsx(RD,{creatingSession:t.creatingSession,onNewSession:t.onStartNewSession,onDuplicateSession:t.handlers.handleDuplicateSession,onBackToMain:c?s.onBackToMain:void 0,onShowFileChanges:()=>i.onFileChangesOpenChange(!0),hasFileChanges:o.hasFileChanges,onShowWorkflows:s.onShowWorkflows,workflowCount:s.workflowCount,onSearch:()=>u(!0),expandAll:a.expandAll,onToggleExpandAll:s.onToggleExpandAll}),r.jsx(dl,{searchInputRef:s.searchInputRef,hasMore:s.hasMoreTurns,isLoadingOlder:s.isLoadingOlderTurns,onLoadMore:s.onLoadMoreTurns,mobileSearchOpen:d,onMobileSearchClose:()=>u(!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(Yb,{projectPath:s.pendingPath??null}),st("terminal")&&r.jsxs(ee,{variant:"outline",size:"xs",onClick:o.onOpenTerminal,children:[r.jsx(Vs,{"data-icon":"inline-start"}),"Terminal"]})]})}):r.jsx(gv,{navigation:t})}),e[19]=i,e[20]=c,e[21]=t,e[22]=o,e[23]=d,e[24]=l,e[25]=s,e[26]=a.expandAll,e[27]=a.mobileTab,e[28]=a.pendingDirName,e[29]=P):P=e[29];let _;e[30]!==t.handlers||e[31]!==o||e[32]!==l||e[33]!==a.mobileTab?(_=a.mobileTab==="stats"&&l&&r.jsx(Vb,{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]=l,e[33]=a.mobileTab,e[34]=_):_=e[34];let A;e[35]!==a.mobileTab||e[36]!==E||e[37]!==T||e[38]!==P||e[39]!==_?(A=r.jsxs("div",{className:E,children:[T,P,_]},C),e[35]=a.mobileTab,e[36]=E,e[37]=T,e[38]=P,e[39]=_,e[40]=A):A=e[40];let I;e[41]!==x||e[42]!==A?(I=r.jsx("main",{ref:x,className:"app-view-transition flex flex-1 min-h-0 overflow-hidden",children:A}),e[41]=x,e[42]=A,e[43]=I):I=e[43];const $=a.mobileTab==="chat"&&i.processPanel;let R;e[44]!==l||e[45]!==s||e[46]!==a.mobileTab||e[47]!==a.pendingDirName?(R=a.mobileTab==="chat"&&(l||a.pendingDirName)&&r.jsxs(r.Fragment,{children:[s.todoProgress,l?s.activeComposer:s.pendingComposer]}),e[44]=l,e[45]=s,e[46]=a.mobileTab,e[47]=a.pendingDirName,e[48]=R):R=e[48];let M;e[49]!==$||e[50]!==R?(M=r.jsxs("div",{className:"shrink-0",children:[$,R]}),e[49]=$,e[50]=R,e[51]=M):M=e[51];let O;e[52]!==y||e[53]!==a.mobileTab?(O=r.jsx(PD,{activeTab:a.mobileTab,onTabChange:y}),e[52]=y,e[53]=a.mobileTab,e[54]=O):O=e[54];let D;e[55]!==i||e[56]!==o||e[57]!==l||e[58]!==a.sessionChangeKey?(D=l&&o.hasFileChanges&&r.jsx(w.Suspense,{fallback:null,children:r.jsx(DD,{open:i.fileChangesOpen,onClose:()=>i.onFileChangesOpenChange(!1),session:l,sessionChangeKey:a.sessionChangeKey})}),e[55]=i,e[56]=o,e[57]=l,e[58]=a.sessionChangeKey,e[59]=D):D=e[59];let z;return e[60]!==i.backgroundServers||e[61]!==i.branchModal||e[62]!==i.undoDialog||e[63]!==i.workflowsPanel||e[64]!==I||e[65]!==M||e[66]!==O||e[67]!==D||e[68]!==k?(z=r.jsxs("div",{className:"flex h-dvh flex-col bg-background text-foreground",children:[b,j,S,k,I,M,i.workflowsPanel,O,i.undoDialog,i.branchModal,D]}),e[60]=i.backgroundServers,e[61]=i.branchModal,e[62]=i.undoDialog,e[63]=i.workflowsPanel,e[64]=I,e[65]=M,e[66]=O,e[67]=D,e[68]=k,e[69]=z):z=e[69],z}function FD(n){const e=B.c(10),{sessionId:t,loadError:s,searchInputRef:o,activeComposer:i,hasMoreTurns:a,isLoadingOlderTurns:l,onLoadMoreTurns:c}=n,{isMobile:d}=qt(),{session:u}=ot();let f;return e[0]!==i||e[1]!==a||e[2]!==l||e[3]!==d||e[4]!==s||e[5]!==c||e[6]!==o||e[7]!==u||e[8]!==t?(f=r.jsx("div",{className:"flex h-dvh flex-col overflow-hidden bg-background text-foreground",children:u?r.jsxs("main",{className:"relative flex min-h-0 flex-1 flex-col",children:[r.jsx(dl,{searchInputRef:o,hasMore:a,isLoadingOlder:l,onLoadMore:c}),d?i:r.jsx(bl,{floating:!0,children:i})]}):r.jsx("main",{className:"flex min-h-0 flex-1 items-center justify-center p-6",children:r.jsx(Kt,{className:"max-w-md",children:r.jsxs(Vt,{children:[r.jsx(en,{variant:"icon",children:s?r.jsx(Xt,{}):r.jsx(et,{className:"animate-spin"})}),r.jsx(Gt,{children:s?"Unable to open session":"Opening session"}),r.jsx(tn,{children:s??`Looking for ${t} in your local Claude, Codex, and Copilot history.`})]})})})}),e[0]=i,e[1]=a,e[2]=l,e[3]=d,e[4]=s,e[5]=c,e[6]=o,e[7]=u,e[8]=t,e[9]=f):f=e[9],f}const BD=5;function Vi(n,e){const t=wn(),s=Ns();return`${s===null?t:`${t}:${s}`}:${n}/${e}`}class UD{constructor(){Ci(this,"cache",new Map)}get(e,t){const s=Vi(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=Vi(e,t);!this.cache.has(d)&&this.cache.size>=BD&&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=Vi(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(Vi(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 Sn=new UD,i1={};function xv(n,e,t,s,o,i){const[a,l]=w.useState(!1),[c,d]=w.useState("disconnected"),[u,f]=w.useState(!1),[m,p]=w.useState(null),[h,g]=w.useState(i1),[x,v]=w.useState(null),[y,b]=w.useState(co),j=w.useRef(""),S=w.useRef(null),k=w.useRef(co),C=w.useRef("disconnected"),N=w.useRef(e);N.current=e;const E=w.useRef(o);E.current=o;const T=w.useRef(t);T.current=t;const P=w.useRef(s);P.current=s;const _=w.useRef(i??null);_.current=i??null;const A=w.useRef(!1),I=(n==null?void 0:n.dirName)??null,$=(n==null?void 0:n.fileName)??null,R=(n==null?void 0:n.rawText)??"",M=(n==null?void 0:n.watchOffset)??new TextEncoder().encode(R).byteLength;return w.useEffect(()=>{if(j.current=R,!R){S.current=null,l(!1);return}const O=_.current;if(O){S.current=O;return}T.current(R).then(D=>{S.current=D})},[R]),w.useEffect(()=>{if(v(null),!I||!$){l(!1),d("disconnected");return}d("connecting");const O=`/api/watch/${encodeURIComponent(I)}/${encodeURIComponent($)}?offset=${M}`,D=new EventSource(Kr(O));let z=null;const F=(ie=3e4)=>{z&&clearTimeout(z),z=setTimeout(()=>{l(!1),f(!1)},ie)};let L="",H=M,U=!1,W=!1,V=!1,K=null;const Y=()=>{V=!1,K=null,S.current&&N.current(S.current)},X=()=>{V||(V=!0,K=requestAnimationFrame(Y))};let G=!1,J=null,Z=null;const Q=()=>{G=!1,J=null,b(k.current)},te=()=>{G||(G=!0,J=requestAnimationFrame(Q))},ne=ie=>{ie!==k.current&&(k.current=ie,te(),ie.length>0&&!Z&&(Z=setInterval(()=>{const se=_8(k.current);se!==k.current&&(k.current=se,te()),k.current.length===0&&Z&&(clearInterval(Z),Z=null)},5e3)))},oe=()=>{ne(co),g(i1)},re=()=>{if(W||U||!L)return;const ie=L;L="",U=!0;const se=S.current;(se?P.current(se,ie):T.current(j.current)).then(ae=>{W||(S.current=ae,I&&$&&Sn.update(I,$,{parsed:ae,source:{rawText:j.current,watchOffset:H}}),X())}).catch(ae=>{console.error("[useLiveSession] worker parse failed:",ae)}).finally(()=>{U=!1,!W&&L&&re()})};return D.onopen=()=>{var ie;if(C.current!=="connected"){const se=A.current;A.current=!1,C.current="connected",d("connected"),se&&((ie=E.current)==null||ie.call(E))}},D.onmessage=ie=>{try{C.current!=="connected"&&(C.current="connected",d("connected"));const se=JSON.parse(ie.data);if(se.type==="init")se.recentlyActive?(l(!0),F(5e3)):F();else if(se.type==="compacting")se.active&&(l(!0),oe(),F()),f(se.active===!0);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(N8(se.messages??[]));else if(se.type==="stream_delta")l(!0),F(),p(null),v(null),ne(k8(k.current,se.events??[]));else if(se.type==="agent_progress")l(!0),F(),g(ce=>({...ce,[se.toolUseId]:se.summary}));else if(se.type==="prompt_suggestion")v(typeof se.suggestion=="string"?se.suggestion:null);else if(se.type==="turn_error")p(typeof se.message=="string"?se.message:"The turn failed");else if(se.type==="stream_clear")oe(),f(!1);else if(se.type==="lines"&&se.lines.length>0){l(!0),f(!1),F(),ne(C8(k.current,se.lines));const ce=se.lines.join(`
138
+ `)+`
139
+ `;H+=new TextEncoder().encode(ce).byteLength,j.current+=ce,L+=ce,re()}}catch(se){console.error("[useLiveSession] Error processing SSE message:",se)}},D.onerror=()=>{l(!1),f(!1),A.current=C.current==="connected",C.current="disconnected",d("disconnected"),oe()},()=>{W=!0,D.close(),l(!1),C.current="disconnected",d("disconnected"),z&&clearTimeout(z),K!==null&&cancelAnimationFrame(K),J!==null&&cancelAnimationFrame(J),Z&&clearInterval(Z),k.current=co,b(co)}},[I,$,R,M]),{isLive:a,sseState:c,isCompacting:u,streamingOverlay:y,turnError:m,agentProgress:h,promptSuggestion:x}}const WD=3e4;function bv(n,e,t){const s=B.c(9),o=WD,[i,a]=w.useState(!1),l=w.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]),w.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(Kr(n));a(!1);const x=()=>{h&&clearTimeout(h),h=setTimeout(()=>{p&&a(!1)},o)};return g.onmessage=v=>{if(p)try{const y=JSON.parse(v.data);y.type==="init"?x():y.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]),w.useEffect(u,f);let m;return s[7]!==i?(m={isLive:i},s[7]=i,s[8]=m):m=s[8],m}function HD(n,e){const t=n?`/api/team-watch/${encodeURIComponent(n)}`:null;return bv(t,e)}function qD(n,e){const[t,s]=w.useState(null),o=w.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=w.useCallback(async()=>{const l=o.current;if(l)try{const c=await Ne(`/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 w.useEffect(()=>{if(!n){s(null);return}a()},[n,a]),HD((t==null?void 0:t.teamName)??null,a),t}function KD(n,e,t,s){let o=null;return n&&e&&(o=`/api/workflow-watch/${encodeURIComponent(n)}/${encodeURIComponent(e)}`,t&&(o=o+`/${encodeURIComponent(t)}`)),bv(o,s)}function VD(n,e,t=!0){const[s,o]=w.useState([]),[i,a]=w.useState(!1),l=w.useRef(0),c=!!n&&!!e,d=w.useCallback(async()=>{const m=++l.current;if(!c){o([]);return}try{const p=await Ne(`/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]);w.useEffect(()=>{if(!c){o([]),a(!1);return}a(!0),d()},[c,d]);const u=c&&(t||s.length>0),{isLive:f}=KD(u?n:null,u?e:null,null,d);return{workflows:s,loading:i,isLive:f,refetch:d}}const md={mode:"bypassPermissions",allowedTools:[],disallowedTools:[]},GD="cogpit:permissions";function YD(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 a1(n,e){const t=await n.json().catch(()=>({error:e}));return typeof t.error=="string"&&t.error?t.error:e}async function vv(n,{model:e,agentKind:t,errorFallback:s,onModelRejected:o}){const i=d=>typeof s=="function"?s(d):s;let l=await n(t==="copilot"?e||"auto":e||void 0),c=l.ok?null:await a1(l,i(l));return!l.ok&&t==="codex"&&e&&YD(c)&&(o==null||o(e),l=await n(void 0),c=l.ok?null:await a1(l,i(l))),{res:l,errorMessage:c}}function XD({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]=w.useState("idle"),[g,x]=w.useState(),[v,y]=w.useState([]),b=w.useRef(null),j=w.useRef(null),S=w.useRef(!1),k=n!=null&&n.fileName?Tc(n.fileName):null,C=e||k,N=n?It(n.dirName):null,E=w.useCallback(()=>{var R;(R=b.current)==null||R.abort(),b.current=null,S.current=!1,h("idle"),x(void 0),y([])},[]);w.useEffect(()=>{var R;j.current!==C&&(S.current?(S.current=!1,(R=b.current)==null||R.abort(),b.current=null,h("idle"),x(void 0)):E(),j.current=C)},[C,E]),w.useEffect(()=>()=>{var R;(R=b.current)==null||R.abort()},[]),w.useEffect(()=>{f&&E()},[f,E]);const T=w.useCallback(async(R,M)=>{if(f)return;if(!C&&m){y(z=>[...z,R]),h("connected"),x(void 0),S.current=!0,o==null||o();try{if(!await m(R,M)){S.current=!1,h("idle"),y([]);return}h("idle")}catch(z){S.current=!1,x(z instanceof Error?z.message:"Failed to create session"),h("error"),y([])}return}if(!C)return;y(z=>[...z,R]),h("connected"),x(void 0);const O=s??md;o==null||o();const D=new AbortController;b.current=D;try{const z={sessionId:C,message:R,images:M||void 0,cwd:t||void 0,permissions:O,effort:a||void 0,fastMode:l?!0:void 0,ultracode:c?!0:void 0,mcpConfig:d||void 0},{res:F,errorMessage:L}=await vv(H=>Ne("/api/send-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...z,model:H}),signal:D.signal}),{model:i,agentKind:N,errorFallback:H=>`Request failed (${H.status})`,onModelRejected:u});b.current===D&&(F.ok?h("idle"):(x(L||`Request failed (${F.status})`),h("error"),y(H=>H.slice(0,-1))))}catch(z){if(z instanceof Error&&z.name==="AbortError")return;b.current===D&&(x(z instanceof Error?z.message:"Unknown error"),h("error"),y(F=>F.slice(0,-1)))}},[C,N,t,s,o,i,a,l,c,d,u,f,m]),P=w.useCallback(()=>{E()},[E]),_=w.useCallback(()=>{!C||f||Ne("/api/interrupt-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:C})}).catch(()=>{})},[C,f]),A=w.useCallback(()=>{var R;(R=b.current)==null||R.abort(),b.current=null,_(),h("idle"),y([])},[_]),I=A,$=w.useCallback((R=1)=>{y(M=>M.slice(R))},[]);return{status:p,error:g,pendingMessages:v,sendMessage:T,disconnect:P,interrupt:A,stopAgent:I,consumePending:$,isConnected:p==="connected"}}const mo={expandAll:!1,expandToolPayloads:!1},JD={session:null,windowTurns:[],olderTurns:[],sessionSource:null,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...mo,sessionChangeKey:0,currentMemberName:null,loadingMember:null,mainView:"sessions",configFilePath:null,mobileTab:"sessions",dashboardProject:null};function l1(n,e,t,s){const o=Q2(e,t,s);return o===n.turns?n:{...n,turns:o}}function Gi(n){return{session:n,windowTurns:(n==null?void 0:n.turns)??[],olderTurns:[]}}function QD(n,e){var t,s;switch(e.type){case"LOAD_SESSION":case"FINALIZE_SESSION":case"INIT_PENDING_SESSION":{const o=e.type==="INIT_PENDING_SESSION";return{...n,...Gi(o?null:e.session),sessionSource:o?null:e.source,pendingDirName:o?e.dirName:null,pendingCwd:o?e.cwd??null:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...mo,mainView:"sessions",currentMemberName:null,dashboardProject:null,sessionChangeKey:n.sessionChangeKey+1,mobileTab:e.isMobile?"chat":n.mobileTab}}case"GO_HOME":return{...n,...Gi(null),sessionSource:null,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...mo,mainView:"sessions",currentMemberName:null,dashboardProject:null,mobileTab:e.isMobile?"sessions":n.mobileTab};case"SWITCH_TEAM_MEMBER":return{...n,...Gi(e.session),sessionSource:e.source,activeTurnIndex:null,searchQuery:"",...mo,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,...mo};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,...mo}:{...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:l1(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:l1(n.session,n.windowTurns,e.turns,(s=n.sessionSource)==null?void 0:s.agentKind)};case"RELOAD_SESSION_CONTENT":return{...n,...Gi(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"OPEN_CONFIG":return{...n,mainView:"config",configFilePath:e.filePath??null};case"CLOSE_CONFIG":return{...n,mainView:"sessions",configFilePath:null};case"OPEN_MISSION":return{...n,mainView:"mission"};case"CLOSE_MISSION":return{...n,mainView:"sessions"};default:return n}}function yv(){return w.useReducer(QD,JD)}function c1(n){n(),requestAnimationFrame(()=>{n(),requestAnimationFrame(n)})}function wv({session:n,isLive:e,pendingMessages:t,consumePending:s,sessionChangeKey:o,partialSignal:i}){const a=w.useRef(null),l=w.useRef(null),c=w.useRef(!0),d=w.useRef(!1),u=w.useRef(0),f=w.useMemo(()=>(n==null?void 0:n.turns.flatMap(R=>R.contentBlocks.flatMap(M=>M.kind==="queued_prompt"?[{id:JSON.stringify([M.timestamp??"",M.content]),content:M.content}]:[])))??[],[n==null?void 0:n.turns]),m=w.useRef(null),p=w.useRef(!1),[h,g]=w.useState(!1),[x,v]=w.useState(null),y=w.useCallback(()=>{requestAnimationFrame(()=>{var R;(R=l.current)==null||R.scrollIntoView({behavior:"smooth"})})},[]),b=w.useCallback(()=>{c1(()=>{const R=a.current;R&&(R.scrollTop=R.scrollHeight),c.current=!0,d.current=!1})},[]),j=w.useCallback(()=>{p.current=!0},[]),S=w.useRef(!1),k=w.useCallback(()=>{const R=a.current;if(!R)return;const M=R.scrollHeight-R.scrollTop-R.clientHeight>10;M!==S.current&&(S.current=M,g(M))},[]),C=w.useCallback(()=>{const R=a.current;R&&(c.current=R.scrollHeight-R.scrollTop-R.clientHeight<150,k())},[k]),N=w.useCallback(R=>{u.current=R},[]),E=w.useRef(o);w.useEffect(()=>{if(o===E.current)return;E.current=o;const R=p.current;p.current=!1;const M=()=>{const D=a.current;D&&(R?(D.scrollTop=0,c.current=!1):(D.scrollTop=D.scrollHeight,c.current=!0),d.current=!1)};c1(M);const O=setTimeout(()=>{M(),v(o)},150);return()=>clearTimeout(O)},[o]);const T=t.length;w.useEffect(()=>{T>0&&(d.current=!0,y())},[T,y]),w.useEffect(()=>{const R=(n==null?void 0:n.sessionId)??null,M=m.current,O=new Set(f.map(F=>F.id));if(!M||M.sessionId!==R){m.current={sessionId:R,ids:O};return}const D=f.filter(F=>!M.ids.has(F.id));if(m.current={sessionId:R,ids:O},D.length===0||T===0)return;let z=0;for(const F of D){const L=t[z];(L===F.content||(L==null?void 0:L.trim())===""&&F.content.length>0)&&z++}z>0&&s(z)},[n==null?void 0:n.sessionId,f,t,T,s]);const P=(n==null?void 0:n.turns.length)??0;w.useEffect(()=>{if(P===0)return;const R=P-u.current;R>0&&(T>0&&s(Math.min(R,T)),(d.current||c.current)&&(y(),d.current=!1)),u.current=P},[P,T,s,y]);const _=n==null?void 0:n.turns.at(-1),A=(_==null?void 0:_.toolCalls.length)??0,I=(_==null?void 0:_.assistantText.length)??0;w.useEffect(()=>{if(!(!n||!e)){if(c.current){const R=a.current;R&&(R.scrollTop=R.scrollHeight)}requestAnimationFrame(k)}},[P,A,I,i,e,k]);const $=x===o;return w.useMemo(()=>({chatScrollRef:a,scrollEndRef:l,canScrollDown:h,initialScrollDone:$,handleScroll:C,scrollToBottomInstant:b,requestScrollToTop:j,resetTurnCount:N}),[h,$,C,b,j,N])}async function jv(n,e,t,s){const o=await Ne(`/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:It(n),watchOffset:i.totalSize},byteOffset:i.byteOffset,hasMore:i.hasMore}}async function Ks(n,e,t,s){const o=Sn.get(n,e);if(o)return{parsed:o.parsed,source:o.source};const i=wn(),a=Ns(),{parsed:l,source:c,byteOffset:d,hasMore:u}=await jv(n,e,t,s);if(wn()!==i||Ns()!==a)return{parsed:l,source:c};const f=Sn.get(n,e);return f?{parsed:f.parsed,source:f.source}:(Sn.set(n,e,l,c.rawText,d,u,c.agentKind,c.watchOffset),{parsed:l,source:c})}async function Sv(n,e,t,s){Sn.evict(n,e);const o=wn(),i=Ns(),{parsed:a,source:l,byteOffset:c,hasMore:d}=await jv(n,e,t,s);return wn()===o&&Ns()===i&&Sn.set(n,e,a,l.rawText,c,d,l.agentKind,l.watchOffset),{parsed:a,source:l}}function ZD({dispatch:n,isMobile:e,mobileTab:t="sessions",teamContext:s,scrollToBottomInstant:o,resetTurnCount:i,workerParse:a,onBeforeSwitch:l}){const[c,d]=w.useState(null),u=w.useCallback((v,y)=>{d(null),w.startTransition(()=>{n({type:"LOAD_SESSION",session:v,source:y,isMobile:e})}),i(v.turns.length),MO(v.sessionId,v.turns.length),o()},[n,e,i,o]),f=w.useCallback(async(v,y)=>{l==null||l(),d(null);try{const{parsed:b,source:j}=await Ks(v,y,a,"session");u(b,j)}catch(b){d(b instanceof Error?b.message:"Failed to load session")}},[u,a,l]),m=w.useCallback(async v=>{if(s){l==null||l(),d(null),n({type:"SET_LOADING_MEMBER",name:v.name});try{const y=await Ne(`/api/team-member-session/${encodeURIComponent(s.teamName)}/${encodeURIComponent(v.name)}`);if(!y.ok)throw new Error(`Failed to find session for ${v.name}`);const{dirName:b,fileName:j}=await y.json(),{parsed:S,source:k}=await Ks(b,j,a,`session for ${v.name}`);w.startTransition(()=>{n({type:"SWITCH_TEAM_MEMBER",session:S,source:k,memberName:v.name})}),i(S.turns.length),o()}catch(y){d(y instanceof Error?y.message:"Failed to switch team member")}finally{n({type:"SET_LOADING_MEMBER",name:null})}}},[n,s,i,o,a,l]),p=w.useCallback(()=>d(null),[]),h=w.useCallback(()=>{w.startTransition(()=>{n({type:"GO_HOME",isMobile:e})})},[n,e]),g=w.useCallback((v,y)=>{n({type:"JUMP_TO_TURN",index:v,toolCallId:y})},[n]),x=w.useCallback(v=>{v!==t&&w.startTransition(()=>{n({type:"SET_MOBILE_TAB",tab:v})})},[n,t]);return{loadError:c,clearLoadError:p,handleLoadSession:u,handleDashboardSelect:f,handleTeamMemberSwitch:m,handleGoHome:h,handleJumpToTurn:g,handleMobileTabChange:x}}const ez=/^\/preview\/([^/]+)\/?$/;function wf(n){const e=ez.exec(n);if(!e)return null;try{const t=decodeURIComponent(e[1]);return t.length>0?t:null}catch{return null}}function Nv(){const n=xt();return n===Tt?"":`/d/${n}`}function pd(){const n=Nv();return n?`${n}/`:"/"}function kv(n){const e=/^\/d\/[^/]+(\/.*)?$/.exec(n);return e?e[1]||"/":n}function tz(n,e){return ij(n,e)}function nz(n){const e=Nv();if(n.sessionSource){const{dirName:t,fileName:s}=n.sessionSource,o=rj(t,s);return`${e}/${encodeURIComponent(t)}/${encodeURIComponent(o)}`}return n.pendingDirName?`${e}/${encodeURIComponent(n.pendingDirName)}`:n.dashboardProject?`${e}/${encodeURIComponent(n.dashboardProject)}`:pd()}function d1(n){const e=kv(n),t=wf(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 sz({state:n,dispatch:e,isMobile:t,resetTurnCount:s,scrollToBottomInstant:o,workerParse:i}){const[a,l]=w.useState(null),c=w.useRef(0),d=w.useRef(window.location.pathname),u=w.useRef(!1),f=w.useCallback(async m=>{c.current++;try{if(m.type==="preview"&&m.sessionId){l(null);try{const p=await Ne(`/api/find-session/${encodeURIComponent(m.sessionId)}`);if(!p.ok)throw new Error(p.status===404?`Session ${m.sessionId} was not found.`:`Failed to resolve session (${p.status}).`);const h=await p.json();if(!h.dirName||!h.fileName)throw new Error("Cogpit returned an invalid session location.");const g=await Ks(h.dirName,h.fileName,i,"session preview");e({type:"LOAD_SESSION",session:g.parsed,source:g.source,isMobile:t}),s(g.parsed.turns.length),o()}catch(p){e({type:"GO_HOME",isMobile:t}),l(p instanceof Error?p.message:"Failed to load session preview.")}}else if(m.type==="session"&&m.dirName&&m.sessionId){l(null);const p=tz(m.dirName,m.sessionId);let h;try{h=await Ks(m.dirName,p,i,"session")}catch{e({type:"GO_HOME",isMobile:t});const g=pd();window.history.replaceState(null,"",g),d.current=g,Yo(xt(),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=pd();window.history.replaceState(null,"",p),d.current=p,Yo(xt(),p)}}finally{c.current--}},[e,t,s,o,i]);return w.useEffect(()=>{if(u.current)return;u.current=!0,Yo(xt(),window.location.pathname);const m=d1(window.location.pathname);(m.type!=="home"||m.normalizeHome)&&f(m)},[f]),w.useEffect(()=>{if(c.current>0||wf(kv(window.location.pathname)))return;const m=nz(n);m!==d.current&&(window.history.pushState(null,"",m),d.current=m,Yo(xt(),m))},[n.sessionSource,n.pendingDirName,n.mainView,n.dashboardProject]),w.useEffect(()=>{const m=()=>{const p=d1(window.location.pathname);d.current=window.location.pathname,Yo(xt(),window.location.pathname),f(p)};return window.addEventListener("popstate",m),()=>window.removeEventListener("popstate",m)},[f]),{previewLoadError:a}}const oz=400;function u1(){return Array.from(document.querySelectorAll("[data-live-session]"))}function rz(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 f1(n){n.focus({preventScroll:!0});const e=rz(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 iz(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:v,onNavigateToSession:y,onCommitNavigation:b}=n;let j,S;e[0]!==o||e[1]!==i||e[2]!==t||e[3]!==b||e[4]!==x||e[5]!==v||e[6]!==y||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?(j=()=>{if(t)return;let k=!1,C=!1,N=null;const E=function(A){var M,O;const I=Nh("missionControl");if(I){if(A.key===I){A.repeat||(k=!0,C=A.shiftKey||A.altKey||(I==="Meta"?A.ctrlKey:A.metaKey));return}k&&(C=!0),N=null}if(jt("commandPalette",A)){A.preventDefault(),d==null||d();return}if(jt("integratedTerminal",A)){if(!st("terminal"))return;A.preventDefault(),p();return}if(jt("preview",A)){A.preventDefault(),h();return}if(jt("projectFiles",A)){if(!st("hostFiles"))return;A.preventDefault(),g();return}if(jt("expandAll",A)){A.preventDefault(),i({type:"SET_EXPAND_ALL",value:!0});return}if(jt("expandToolPayloads",A)){A.preventDefault(),i({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0});return}if(jt("toggleSidebar",A)){A.preventDefault(),a();return}if(jt("toggleStats",A)){A.preventDefault(),l();return}if(jt("missionControl",A)){A.preventDefault(),c();return}if(jt("newSession",A)&&(A.preventDefault(),u()),jt("themeSelector",A)&&(A.preventDefault(),f()),jt("systemTerminal",A)){if(!st("terminal"))return;A.preventDefault(),m()}if(A.key==="Escape"&&(i({type:"SET_SEARCH_QUERY",value:""}),(M=s.current)==null||M.blur()),(A.metaKey||A.ctrlKey)&&A.shiftKey&&A.code.startsWith("Digit")){const D=parseInt(A.code.charAt(5),10);if(D>=1&&D<=9){A.preventDefault();const F=u1()[D-1];F&&(f1(F),F.click())}}const $=jt("recentSessionForward",A);if($||jt("recentSessionBack",A)){A.preventDefault();const D=$?v():x();D&&y(D.dirName,D.fileName)}jt("focusComposer",A)&&!sb(document.activeElement)&&(A.preventDefault(),(O=o.current)==null||O.focus());const R=jt("nextLiveSession",A);if(R||jt("prevLiveSession",A)){A.preventDefault();const D=u1();if(D.length===0)return;const z=D.findIndex(az);let F;z===-1?F=R?0:D.length-1:F=Math.max(0,Math.min(D.length-1,z+(R?1:-1))),f1(D[F])}},T=function(A){const I=Nh("missionControl");if(I&&A.key===I&&k){const $=!C;if(k=!1,C=!1,$){const R=Date.now();N!==null&&R-N<=oz?(N=null,A.preventDefault(),c()):N=R}else N=null}A.key==="Control"&&(b==null||b())},P=function(){k=!1,C=!1,N=null};return window.addEventListener("keydown",E),window.addEventListener("keyup",T),window.addEventListener("blur",P),()=>{window.removeEventListener("keydown",E),window.removeEventListener("keyup",T),window.removeEventListener("blur",P)}},S=[t,s,o,i,a,l,c,d,u,f,m,p,h,g,x,v,y,b],e[0]=o,e[1]=i,e[2]=t,e[3]=b,e[4]=x,e[5]=v,e[6]=y,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]=j,e[19]=S):(j=e[18],S=e[19]),w.useEffect(j,S)}function az(n){return n===document.activeElement}const m1="cogpit-theme",wB=[{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 Cv(){const[n,e]=w.useState(()=>{try{const a=localStorage.getItem(m1);if(a==="dark"||a==="oled"||a==="light")return a}catch{}return"dark"}),[t,s]=w.useState(null),o=w.useCallback(a=>{localStorage.setItem(m1,a),e(a),s(null)},[]),i=t??n;return w.useEffect(()=>{const a=document.documentElement.classList;a.remove("dark","theme-oled"),i==="dark"?a.add("dark"):i==="oled"&&a.add("dark","theme-oled")},[i]),{theme:n,activeTheme:i,setTheme:o,setPreview:s}}const lz="cogpit-session-history",hd=50;function _v(){return Jt(lz)}function cz(){try{const n=localStorage.getItem(_v());if(!n)return[];const e=JSON.parse(n);if(Array.isArray(e))return e.slice(0,hd)}catch{}return[]}function p1(n){try{localStorage.setItem(_v(),JSON.stringify(n))}catch{}}function dz(){const n=B.c(6);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=cz(),n[0]=e):e=n[0];const t=w.useRef(e),s=w.useRef(0),o=w.useRef(!1);let i;n[1]===Symbol.for("react.memo_cache_sentinel")?(i=(h,g)=>{if(o.current){o.current=!1;return}const x=`${h}/${g}`;t.current=t.current.filter(v=>`${v.dirName}/${v.fileName}`!==x),t.current.unshift({dirName:h,fileName:g}),t.current.length>hd&&(t.current.length=hd),s.current=0,p1(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),p1(t.current)),s.current=0,o.current=!1},n[4]=f):f=n[4];const m=f;let p;return n[5]===Symbol.for("react.memo_cache_sentinel")?(p={push:a,goBack:c,goForward:u,commitNavigation:m},n[5]=p):p=n[5],p}function Tv(){return Jt(GD)}function h1(){try{const n=localStorage.getItem(Tv());if(n){const e=JSON.parse(n);return{mode:e.mode||md.mode,allowedTools:Array.isArray(e.allowedTools)?e.allowedTools:[],disallowedTools:Array.isArray(e.disallowedTools)?e.disallowedTools:[]}}}catch{}return md}function uz(n){localStorage.setItem(Tv(),JSON.stringify(n))}function fz(){const n=B.c(17),[e,t]=w.useState(h1),[s,o]=w.useState(h1),i=w.useRef(!0);let a,l;n[0]!==e?(a=()=>{if(i.current){i.current=!1;return}uz(e)},l=[e],n[0]=e,n[1]=a,n[2]=l):(a=n[1],l=n[2]),w.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=g=>{t(x=>({...x,mode:g}))},n[10]=u):u=n[10];const f=u;let m;n[11]!==e?(m=()=>{o(e)},n[11]=e,n[12]=m):m=n[12];const p=m;let h;return n[13]!==e||n[14]!==d||n[15]!==p?(h={config:e,hasPendingChanges:d,setMode:f,markApplied:p},n[13]=e,n[14]=d,n[15]=p,n[16]=h):h=n[16],h}const mz=2e3;function pz(n,e){return n.length!==e.length?!1:JSON.stringify(n)===JSON.stringify(e)}function hz(n){const[e,t]=w.useState([]),[s,o]=w.useState(null),[i,a]=w.useState(new Set);w.useEffect(()=>{if(!n){t([]),o(null);return}let d=!1;const u=async()=>{if(!d)try{const h=await Ne(`/api/permissions/${encodeURIComponent(n)}`);if(d)return;if(h.ok){const g=await h.json();if(d)return;t(v=>pz(v,g.permissions)?v:g.permissions);const x=g.plan?{type:"plan",provider:"copilot",...g.plan}:null;o(v=>JSON.stringify(v)===JSON.stringify(x)?v:x)}}catch{}},f=()=>{(typeof document>"u"||document.visibilityState==="visible")&&u()},m=()=>{document.visibilityState==="visible"&&u()};f();const p=setInterval(f,mz);return document.addEventListener("visibilitychange",m),()=>{d=!0,clearInterval(p),document.removeEventListener("visibilitychange",m)}},[n]);const l=w.useCallback(async(d,u)=>{if(n){a(f=>new Set(f).add(d));try{await lv(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=w.useCallback(async d=>{if(n)try{await jO(n,d)&&t([])}catch{}},[n]);return{requests:e,plan:s,responding:i,respond:l,respondAll:c}}async function gz(n,e){const t=await Kn(`/api/copilot-history/${encodeURIComponent(n)}/preview`,{eventId:e});return t.ok?await t.json():null}async function xz(n,e,t){const s=await Kn(`/api/copilot-history/${encodeURIComponent(n)}/rewind`,{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 bz(n){return n.file_path??n.path??""}function Ev(n){const e=[];for(const t of n.toolCalls){if(t.isError||sE(t))continue;const s=bz(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 vz(n,e){return{index:e,userMessage:sl(n.userMessage),toolCalls:Ev(n),thinkingBlocks:n.thinking.map(t=>t.thinking),assistantText:[...n.assistantText],timestamp:n.timestamp,model:n.model}}function ka(n,e,t){const s=[];for(let o=e;o>t;o--){const i=n[o];if(!i)continue;const a=Ev(i);for(let l=a.length-1;l>=0;l--){const c=a[l];c&&(c.type==="Edit"?s.push({type:"reverse-edit",filePath:c.filePath,oldString:c.newString,newString:c.oldString,replaceAll:c.replaceAll,turnIndex:o}):c.type==="Write"&&s.push({type:"delete-write",filePath:c.filePath,content:c.content,turnIndex:o}))}}return s}function yz(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 wr(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(...yz(i.toolCalls,i.index))}return t}function Av(n,e,t,s){var l;const o=[];for(let c=e+1;c<n.length;c++){const d=n[c];d&&o.push(vz(d,c))}const i=((l=o[0])==null?void 0:l.userMessage)||"Untitled branch",a=i.length>60?i.slice(0,57)+"...":i;return{id:crypto.randomUUID(),createdAt:new Date().toISOString(),branchPointTurnIndex:e,label:a,turns:o,jsonlLines:t,...s&&s.length>0?{childBranches:s}:{}}}function Pv(n,e){const t=[],s=[];for(const o of n)o.branchPointTurnIndex>e?s.push(o):t.push(o);return{retained:t,scooped:s}}function Iv(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 wz(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 jz(n,e){return{sessionId:n,currentTurnIndex:e-1,totalTurns:e,branches:[],activeBranchId:null}}function Yi(n,e){return n.length>0?wz(n):{turnCount:e,fileCount:0,filePaths:[],operationCount:0}}function Rv(n,e,t){return I0(T0(It(t)),n,e)}function $v(n,e,t,s){const o=T0(It(s)),i=e==null?void 0:e.id;if(i){const a=P_(o,n,i);if(a==="keep-all")return n.length;if(a!==null)return a}return I0(o,n,t)}class ur extends Error{constructor(){super("abort")}}async function Sz(n,e,t,s,o,i,a){var y;const l=n.targetTurnIndex,c=ka(e.turns,e.turns.length-1,l),d=l+1,u=o.split(`
141
+ `).filter(Boolean),f=$v(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 ur;const{retained:p,scooped:h}=Pv(s.branches,l),g=Av(e.turns,l,m,h),x={...s,currentTurnIndex:l,totalTurns:d,branches:[...p,g],activeBranchId:null},v=ko(t.dirName).fileCheckpoints?(y=e.turns[l+1])==null?void 0:y.id:void 0;await i({operations:c,sessionSource:t,sessionMutation:{type:"truncate",keepLines:f,expectedLineCount:u.length},state:x,...v?{checkpoint:{sessionId:e.sessionId,userMessageId:v,cwd:e.cwd}}:{}})}async function Nz(n,e,t,s,o,i){var v;const a=n.redoUpToArchiveIndex!==void 0&&n.redoUpToArchiveIndex<s.turns.length-1,l=n.redoUpToArchiveIndex??s.turns.length-1,c=l+1,d=wr(s.turns,l),u=a?Rv(s.jsonlLines,c,e.dirName):s.jsonlLines.length,f=s.jsonlLines.slice(0,u),m=s.jsonlLines.slice(u),p=s.childBranches??[];let h;if(a&&m.length>0){const{restored:y,remaining:b}=Iv(p,s.branchPointTurnIndex,c),j={...s,branchPointTurnIndex:s.branchPointTurnIndex+c,turns:s.turns.slice(c),jsonlLines:m,label:((v=s.turns[c])==null?void 0:v.userMessage)||s.label,childBranches:b.length>0?b:void 0};h=[...t.branches.map(S=>S.id===s.id?j:S),...y]}else h=[...t.branches.filter(y=>y.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 kz(n,e,t,s,o,i,a){var j;let l=[...t.branches],c=o.split(`
143
+ `).filter(Boolean);const d=[];if(n.turns.length>s.branchPointTurnIndex+1){const S=ka(n.turns,n.turns.length-1,s.branchPointTurnIndex);d.push(...S);const{retained:k,scooped:C}=Pv(l,s.branchPointTurnIndex);l=k;const N=s.branchPointTurnIndex+1,E=$v(c,n.turns[s.branchPointTurnIndex],N,e.dirName),T=c.slice(E);if(T.length>0){const P=Av(n.turns,s.branchPointTurnIndex,T,C);l=[...l,P],c=c.slice(0,E)}}const u=i.branchTurnIndex??s.turns.length-1,f=u+1,m=u<s.turns.length-1,p=wr(s.turns,u);d.push(...p);const h=m?Rv(s.jsonlLines,f,e.dirName):s.jsonlLines.length,g=s.jsonlLines.slice(0,h),x=s.jsonlLines.slice(h),v=s.childBranches??[];let y;if(m&&x.length>0){const{restored:S,remaining:k}=Iv(v,s.branchPointTurnIndex,f);y=[{...s,branchPointTurnIndex:s.branchPointTurnIndex+f,turns:s.turns.slice(f),jsonlLines:x,label:((j=s.turns[f])==null?void 0:j.userMessage)||s.label,childBranches:k.length>0?k:void 0},...S]}else y=v;const b={...t,currentTurnIndex:s.branchPointTurnIndex+f,totalTurns:s.branchPointTurnIndex+1+f,branches:[...l.filter(S=>S.id!==s.id),...y],activeBranchId:null};await a({operations:d,sessionSource:e,sessionMutation:{type:"splice",keepLines:c.length,lines:g,expectedLineCount:o.split(`
144
+ `).filter(Boolean).length},state:b})}const Cz=[];function Mv(n,e,t,s=!0){const[o,i]=w.useState(null),[a,l]=w.useState(null),[c,d]=w.useState(!1),[u,f]=w.useState(null),m=w.useRef(null),p=w.useRef(0);w.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,!ko(e==null?void 0:e.dirName).redo){i(null);return}const P=n.sessionId,_=new AbortController;return Ne(`/api/undo-state/${encodeURIComponent(P)}`,{signal:_.signal}).then(A=>A.ok?A.json():null).then(A=>{m.current===P&&i(A??null)}).catch(A=>{A instanceof Error&&A.name==="AbortError"||m.current===P&&i(null)}),()=>_.abort()},[s,n==null?void 0:n.sessionId]);const h=w.useCallback(async P=>{try{const _=await Ne("/api/undo/transaction",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({operations:P.operations,session:{dirName:P.sessionSource.dirName,fileName:P.sessionSource.fileName,mutation:P.sessionMutation},state:P.state,checkpoint:P.checkpoint})}),A=await _.json().catch(()=>null);if(!_.ok)throw f((A==null?void 0:A.error)||"Undo transaction failed"),new ur;i(P.state)}catch(_){throw _ instanceof ur?_:(f(String(_)),new ur)}},[]),g=(o==null?void 0:o.branches)??Cz,{canRedo:x,redoTurnCount:v,redoBranch:y}=w.useMemo(()=>{if(!n||g.length===0)return{canRedo:!1,redoTurnCount:0,redoBranch:null};for(let P=g.length-1;P>=0;P--){const _=g[P];if(_.branchPointTurnIndex+1===n.turns.length)return{canRedo:!0,redoTurnCount:_.turns.length,redoBranch:_}}return{canRedo:!1,redoTurnCount:0,redoBranch:null}},[n,g]),b=w.useMemo(()=>{if(!y||y.jsonlLines.length===0)return[];try{return nl(y.jsonlLines.join(`
145
+ `)).turns}catch{return[]}},[y]),j=w.useCallback(P=>g.filter(_=>_.branchPointTurnIndex===P),[g]),S=w.useCallback(P=>{if(!s||!n)return;const _=P-1;if(_>=n.turns.length-1||_<-1)return;if(ko(e==null?void 0:e.dirName).nativeRewind){const I=n.turns[P];if(!I)return;const $=n.sessionId,R=++p.current,M=()=>p.current===R&&m.current===$,O=I.id.includes("@")?I.id.slice(I.id.lastIndexOf("@")+1):I.id,D=n.turns.length-P;gz(n.sessionId,O).then(z=>{var H;if(!M())return;const F=((H=z==null?void 0:z.files)==null?void 0:H.map(({path:U})=>U).filter(U=>typeof U=="string"))??[],L=z!=null&&z.available?z.fileCount??F.length:0;l({type:"undo",summary:{turnCount:D,fileCount:L,filePaths:F,operationCount:L},targetTurnIndex:_,nativeRewind:{eventId:O,mode:"conversation",filesAvailable:!!(z!=null&&z.available&&L>0)}})}).catch(()=>{M()&&l({type:"undo",summary:{turnCount:D,fileCount:0,filePaths:[],operationCount:0},targetTurnIndex:_,nativeRewind:{eventId:O,mode:"conversation"}})});return}const A=ka(n.turns,n.turns.length-1,_);l({type:"undo",summary:Yi(A,n.turns.length-1-_),targetTurnIndex:_})},[s,n,e==null?void 0:e.dirName]),k=w.useCallback(()=>{if(!s||!x||!y||!n)return;const P=wr(y.turns);l({type:"redo",summary:Yi(P,y.turns.length),targetTurnIndex:y.branchPointTurnIndex+y.turns.length,branchId:y.id})},[s,x,y,n]),C=w.useCallback(P=>{if(!s||!x||!y||!n)return;const _=P+1,A=wr(y.turns,P);l({type:"redo",summary:Yi(A,_),targetTurnIndex:y.branchPointTurnIndex+_,branchId:y.id,redoUpToArchiveIndex:P})},[s,x,y,n]),N=w.useCallback((P,_)=>{if(!s||!n)return;const A=g.find(M=>M.id===P);if(!A)return;const I=_??A.turns.length-1,$=n.turns.length>A.branchPointTurnIndex+1?ka(n.turns,n.turns.length-1,A.branchPointTurnIndex):[],R=wr(A.turns,I);l({type:"branch-switch",summary:Yi([...$,...R],I+1),targetTurnIndex:A.branchPointTurnIndex,branchId:P,branchTurnIndex:I})},[s,n,g]),E=w.useCallback(async(P=!1)=>{if(!s||!a||!n||!e){l(null);return}d(!0),f(null);try{if(a.nativeRewind){const $=P&&a.nativeRewind.filesAvailable?"conversation-and-files":"conversation",R=await xz(n.sessionId,a.nativeRewind.eventId,$);if(!R.ok){f(R.error);return}await t(),l(null);return}const _=o??jz(n.sessionId,n.turns.length),A=await Ne(`/api/sessions/${encodeURIComponent(e.dirName)}/${encodeURIComponent(e.fileName)}`);if(!A.ok){f("Failed to read session file");return}const I=await A.text();if(a.type==="undo")await Sz(a,n,e,_,I,h,f);else if(a.type==="redo"){const $=g.find(R=>R.id===a.branchId);if(!$){l(null);return}await Nz(a,e,_,$,I,h)}else if(a.type==="branch-switch"){const $=g.find(R=>R.id===a.branchId);if(!$){l(null);return}await kz(n,e,_,$,I,a,h)}try{await Ne("/api/stop-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:n.sessionId})})}catch{}await t(),l(null)}catch(_){if(!(_ instanceof ur))throw _}finally{d(!1)}},[s,a,n,e,o,g,h,t]),T=w.useCallback(()=>{p.current+=1,l(null),f(null)},[]);return{enabled:s,undoState:o,canRedo:x,redoTurnCount:v,redoGhostTurns:b,branches:g,branchesAtTurn:j,requestUndo:S,requestRedoAll:k,requestRedoUpTo:C,requestBranchSwitch:N,confirmState:a,confirmApply:E,confirmCancel:T,isApplying:c,applyError:u}}async function _z(n){try{const t=await(await ps("/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 Tz(n){const e=await Ne("/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:oj(t==null?void 0:t.mode,Gs),useBuiltInEditor:(t==null?void 0:t.useBuiltInEditor)===!0}}function Ez(){const n=B.c(26),[e,t]=w.useState(!0),[s,o]=w.useState(null),[i,a]=w.useState(null),[l,c]=w.useState(Gs),[d,u]=w.useState(!1),[f,m]=w.useState(null),[p,h]=w.useState(!1),[g,x]=w.useState(0),v=w.useRef(null);let y;n[0]===Symbol.for("react.memo_cache_sentinel")?(y=H=>{a(H.claudeDir),c(H.defaultAgentKind),tk(H.useBuiltInEditor)},n[0]=y):y=n[0];const b=y;let j;n[1]===Symbol.for("react.memo_cache_sentinel")?(j=async()=>{var W;(W=v.current)==null||W.abort();const H=new AbortController;v.current=H;const U=await _z(H.signal);H.signal.aborted||v.current!==H||(m(U.url),h(U.disabled))},n[1]=j):j=n[1];const S=j;let k,C;n[2]===Symbol.for("react.memo_cache_sentinel")?(k=()=>()=>{var H;(H=v.current)==null||H.abort()},C=[],n[2]=k,n[3]=C):(k=n[2],C=n[3]),w.useEffect(k,C);let N;n[4]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{const H=new AbortController;return t(!0),o(null),Tz(H.signal).then(b).catch(U=>{U instanceof Error&&U.name==="AbortError"||(a(null),o(U instanceof Error?U.message:"Failed to load configuration"))}).finally(()=>{H.signal.aborted||t(!1)}),()=>H.abort()},n[4]=N):N=n[4];let E;n[5]!==g?(E=[b,g],n[5]=g,n[6]=E):E=n[6],w.useEffect(N,E);let T,P;n[7]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{const H=()=>x(Iz);return window.addEventListener("cogpit-auth-changed",H),()=>window.removeEventListener("cogpit-auth-changed",H)},P=[],n[7]=T,n[8]=P):(T=n[7],P=n[8]),w.useEffect(T,P);let _;n[9]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{S()},n[9]=_):_=n[9];let A;n[10]!==i?(A=[i,S],n[10]=i,n[11]=A):A=n[11],w.useEffect(_,A);let I;n[12]===Symbol.for("react.memo_cache_sentinel")?(I=()=>u(!1),n[12]=I):I=n[12];const $=I;let R;n[13]!==i?(R=H=>{if(u(!1),H!==i){a(H),window.location.reload();return}x(Pz),S()},n[13]=i,n[14]=R):R=n[14];const M=R;let O;n[15]===Symbol.for("react.memo_cache_sentinel")?(O=()=>u(!0),n[15]=O):O=n[15];const D=O;let z;n[16]===Symbol.for("react.memo_cache_sentinel")?(z=()=>x(Az),n[16]=z):z=n[16];const F=z;let L;return n[17]!==i||n[18]!==s||n[19]!==e||n[20]!==l||n[21]!==M||n[22]!==p||n[23]!==f||n[24]!==d?(L={configLoading:e,configError:s,claudeDir:i,defaultAgentKind:l,setClaudeDir:a,showConfigDialog:d,openConfigDialog:D,handleCloseConfigDialog:$,handleConfigSaved:M,retryConfig:F,networkUrl:f,networkAccessDisabled:p},n[17]=i,n[18]=s,n[19]=e,n[20]=l,n[21]=M,n[22]=p,n[23]=f,n[24]=d,n[25]=L):L=n[25],L}function Az(n){return n+1}function Pz(n){return n+1}function Iz(n){return n+1}const g1={authenticated:!0,edition:"personal",user:null,capabilities:Wa},hn={authenticated:!1,edition:"personal",user:null,capabilities:Yr},Lv=Object.keys(Wa);function x1(n,e){return n!==null&&n.edition===e&&n.authenticated&&(e==="personal"?n.user===null:n.user!==null)&&Lv.every(t=>{var s;return typeof((s=n.capabilities)==null?void 0:s[t])=="boolean"})}function Rz(n,e){const t={...Yr};for(const s of Lv)t[s]=n[s]&&e[s];return t}async function b1(n,e){try{const t=await n("/api/me",{signal:e});return t.ok?await t.json():null}catch{return null}}async function $z(n){try{const e=await Ne("/api/hello",{signal:n});return e.ok?(await e.json()).edition==="team"?"team":"personal":null}catch{return null}}function or(n){var e;return po(n),xg(((e=n.user)==null?void 0:e.id)??null),n}function Mz(n){const e=B.c(8);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={...hn,checked:!1},e[0]=t):t=e[0];const[s,o]=w.useState(t),[i,a]=w.useState(0),l=w.useRef(null),c=w.useRef(!1);let d;e[1]!==n?(d=()=>{var b;if((b=l.current)==null||b.abort(),n===null){c.current=!1,po(hn),o({...hn,checked:!1});return}const p=c.current;c.current=!1,po(hn),o(j=>p?{...j,capabilities:Yr,checked:!1}:{...hn,checked:!1});const h=new AbortController;l.current=h;const g=Ws(),x=b1(ps,h.signal),v=g?$z(h.signal):Promise.resolve(n),y=g?b1(Ne,h.signal):Promise.resolve(null);return Promise.all([x,v,y]).then(j=>{const[S,k,C]=j;if(h.signal.aborted)return;const N=x1(S,n)?S:n==="personal"?g1:null;if(!N||k===null){o({...or(hn),checked:!1});return}if(!g){o({...or(N),checked:!0});return}const E=x1(C,k)?C:k==="personal"?g1:null;if(!E){o({...or(hn),checked:!1});return}o({...or({authenticated:N.authenticated,edition:N.edition,user:N.user,capabilities:Rz(N.capabilities,E.capabilities)}),checked:!0})}).catch(()=>{h.signal.aborted||o({...or(hn),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],w.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,po(hn),xg(null),o({...hn,checked:!1}),a(Dz)},h=g=>{var y,b;const x=xt();if(x===Tt)return;const v=(y=g.detail)==null?void 0:y.deviceId;v&&v!==x||((b=l.current)==null||b.abort(),c.current=!0,po(hn),o(Oz),a(Lz))};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]),w.useEffect(f,m),s}function Lz(n){return n+1}function Oz(n){return{...n,capabilities:Yr,checked:!1}}function Dz(n){return n+1}const zz=3e4;function Fz(n){const[e,t]=w.useState(()=>({dirName:n,worktrees:[],loading:n!==null,error:null})),s=w.useRef(0),o=w.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 Ne(`/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]);w.useEffect(()=>{if(!n){s.current+=1;return}o();const a=setInterval(()=>void o(),zz);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 Bz(){const n=B.c(3),[e,t]=w.useState(!1);let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=async()=>{t(!0);try{await Ne("/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 Uz(n,e){return n?`${n}.jsonl`:e??null}async function Ov(n){try{const e=await Ne(`/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 Wz=300,vc=new Map;function gd(n,e){const t=Jt(n),s=vc.get(t),o=s?{...s.patch,...e}:e;s&&clearTimeout(s.timer);const i=setTimeout(()=>{vc.delete(t),Jt(n)===t&&(async()=>{try{await Kn(`/api/session-config/${encodeURIComponent(n)}`,o,{method:"PUT"})}catch{}})()},Wz);vc.set(t,{patch:o,timer:i})}function xd(n){return new Set(n.filter(e=>e.status==="connected").map(e=>e.name))}async function v1(n){const e=await Ov(n);return Array.isArray(e==null?void 0:e.mcpServers)?e.mcpServers:null}function yc(n,e){gd(n,{mcpServers:e})}async function Hz(n){if(!n.ok)return null;const e=await n.json();return{servers:e.servers??[],configs:e.configs??{}}}async function y1(n,e){try{const t=await Ne(n,{signal:e});if(e.aborted)return null;const s=await Hz(t);return e.aborted?null:s}catch{return null}}async function w1(n,e,t){const s=xd(t);if(s.size===0)return[];if(n){const o=await v1(n);if(o)return o.filter(i=>s.has(i))}if(e&&n!==e){const o=await v1(e);if(o)return o.filter(i=>s.has(i))}return[...s]}function qz(n,e,t,s=!0){const[o,i]=w.useState([]),[a,l]=w.useState({}),[c,d]=w.useState([]),[u,f]=w.useState(!1),[m,p]=w.useState(!1),h=w.useRef(null),g=w.useRef(e);g.current=e;const x=t??e??null,v=w.useRef(x);v.current=x;const y=w.useRef(void 0);w.useEffect(()=>{var N,E;if(!s||!n){(N=h.current)==null||N.abort(),y.current=void 0,i([]),l({}),d([]),f(!1),p(!1);return}const C=new AbortController;return(E=h.current)==null||E.abort(),i([]),l({}),d([]),f(!0),p(!1),y.current=n,y1(`/api/mcp-servers?cwd=${encodeURIComponent(n)}`,C.signal).then(async T=>{if(C.signal.aborted||y.current!==n||!T)return;i(T.servers),l(T.configs);const P=await w1(v.current,g.current,T.servers);C.signal.aborted||y.current!==n||d(P)}).finally(()=>{C.signal.aborted||y.current!==n||(f(!1),p(!0))}),()=>C.abort()},[n,s]),w.useEffect(()=>()=>{var C;return(C=h.current)==null?void 0:C.abort()},[]),w.useEffect(()=>{if(o.length===0||!x)return;let C=!1;return w1(x,e,o).then(N=>{C||v.current!==x||d(N)}),()=>{C=!0}},[x]);const b=w.useCallback(C=>{d(N=>{const E=N.includes(C)?N.filter(T=>T!==C):[...N,C];return v.current&&yc(v.current,E),E})},[]),j=w.useCallback(C=>{d(()=>(v.current&&yc(v.current,C),C))},[]),S=w.useCallback(()=>{var N;if(!s||!n)return;(N=h.current)==null||N.abort();const C=new AbortController;h.current=C,f(!0),y1(`/api/mcp-servers?cwd=${encodeURIComponent(n)}&refresh=1`,C.signal).then(E=>{if(C.signal.aborted||y.current!==n||!E)return;i(E.servers),l(E.configs);const T=xd(E.servers);d(P=>{const _=P.filter(A=>T.has(A));return v.current&&yc(v.current,_),_})}).finally(()=>{C.signal.aborted||h.current!==C||f(!1)})},[n,s]),k=w.useMemo(()=>{if(o.length===0)return null;const C=xd(o);if(c.length===C.size&&C.size>0&&c.every(T=>C.has(T))||!c.every(T=>a[T]))return null;const E=Object.fromEntries(c.map(T=>[T,a[T]]));return JSON.stringify({mcpServers:E})},[c,a,o]);return{servers:o,selectedServers:c,mcpConfigJson:k,loading:u,loaded:m,toggleServer:b,setSelection:j,refresh:S}}function Kz(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 v=x.input;Array.isArray(v.todos)&&(i=v.todos);continue}if(x.name==="TaskCreate"){const v=x.input;h=h+1;const b=((o=(s=x.result)==null?void 0:s.match(/(?:Task\s*#?|task[_ ]?id["': ]+)(\d+)/i))==null?void 0:o[1])??String(h);p.set(b,{id:b,content:v.subject||v.description||`Task ${b}`,activeForm:v.activeForm||v.subject||`Working on task ${b}`,status:"pending",owner:v.owner});continue}if(x.name==="TaskUpdate"){const v=x.input,y=String(v.taskId??"");if(!y)continue;if(v.status==="deleted"){p.delete(y);continue}const b=p.get(y)??{id:y,content:v.subject||v.description||`Task ${y}`,activeForm:v.activeForm||v.subject||`Working on task ${y}`,status:"pending"};p.set(y,{...b,content:v.subject||v.description||b.content,activeForm:v.activeForm||b.activeForm,status:v.status||b.status,owner:v.owner??b.owner,blockedBy:v.addBlockedBy?[...new Set([...b.blockedBy??[],...v.addBlockedBy])]:b.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(Gz),e[4]=l,e[5]=c):c=e[5];const d=c.length;let u;e[6]!==l?(u=l.find(Vz)??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 Vz(n){return n.status==="in_progress"}function Gz(n){return n.status==="completed"}function Yz(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]=w.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 Ne(`/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]),w.useEffect(i,a),s}function Xz(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]=w.useState(o),[l,c]=w.useState(!1),d=w.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)}`:"";Ne(`/api/slash-suggestions${p}`).then(Jz).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]),w.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 Jz(n){return n.json()}function j1(n,e){const t=B.c(6),[s,o]=Wo(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 S1(){if(typeof window>"u")return St.fileChanges;try{if(JSON.parse(localStorage.getItem("panel-worktrees-visible")??"false")===!0)return St.worktrees;if(JSON.parse(localStorage.getItem("panel-stats-visible")??"false")===!0)return St.sessionInfo;if(JSON.parse(localStorage.getItem("panel-file-changes-visible")??"true")===!1)return null}catch{}return St.fileChanges}function Qz(n,e){const t=B.c(42),[s,o]=j1("panel-sidebar-visible",!0),[i,a]=j1("panel-workflows-visible",!1);let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=S1(),t[0]=l):l=t[0];const[c,d]=Wo("workspace-panel-active",l);let u;t[1]!==c?(u=typeof c=="string"||c===null?c:S1(),t[1]=c,t[2]=u):u=t[2];const f=u,[m,p]=w.useState(!1),[h,g]=w.useState(!1);let x;t[3]!==o||t[4]!==s?(x=()=>{w.startTransition(()=>o(!s))},t[3]=o,t[4]=s,t[5]=x):x=t[5];const v=x;let y;t[6]!==e||t[7]!==d||t[8]!==n.mainView?(y=H=>{w.startTransition(()=>{const U=n.mainView==="config"||n.mainView==="mission";n.mainView==="config"&&e({type:"CLOSE_CONFIG"}),n.mainView==="mission"&&e({type:"CLOSE_MISSION"}),d(W=>U||W!==H?H:null)})},t[6]=e,t[7]=d,t[8]=n.mainView,t[9]=y):y=t[9];const b=y;let j;t[10]!==e||t[11]!==d||t[12]!==n.mainView?(j=H=>{w.startTransition(()=>{n.mainView==="config"&&e({type:"CLOSE_CONFIG"}),n.mainView==="mission"&&e({type:"CLOSE_MISSION"}),d(H)})},t[10]=e,t[11]=d,t[12]=n.mainView,t[13]=j):j=t[13];const S=j;let k;t[14]!==d?(k=()=>{w.startTransition(()=>d(null))},t[14]=d,t[15]=k):k=t[15];const C=k;let N;t[16]!==e||t[17]!==n.mainView?(N=()=>{const H=n.mainView==="config";w.startTransition(()=>{e({type:H?"CLOSE_CONFIG":"OPEN_CONFIG"})})},t[16]=e,t[17]=n.mainView,t[18]=N):N=t[18];const E=N;let T;t[19]!==e||t[20]!==n.mainView?(T=()=>{const H=n.mainView==="mission";w.startTransition(()=>{e({type:H?"CLOSE_MISSION":"OPEN_MISSION"})})},t[19]=e,t[20]=n.mainView,t[21]=T):T=t[21];const P=T;let _;t[22]!==e?(_=H=>{w.startTransition(()=>{e({type:"OPEN_CONFIG",filePath:H})})},t[22]=e,t[23]=_):_=t[23];const A=_;let I;t[24]===Symbol.for("react.memo_cache_sentinel")?(I=()=>p(!0),t[24]=I):I=t[24];const $=I;let R;t[25]===Symbol.for("react.memo_cache_sentinel")?(R=()=>p(!1),t[25]=R):R=t[25];const M=R;let O;t[26]===Symbol.for("react.memo_cache_sentinel")?(O=()=>g(Zz),t[26]=O):O=t[26];const D=O;let z;t[27]===Symbol.for("react.memo_cache_sentinel")?(z=()=>g(!1),t[27]=z):z=t[27];const F=z;let L;return t[28]!==f||t[29]!==C||t[30]!==A||t[31]!==E||t[32]!==P||t[33]!==v||t[34]!==S||t[35]!==a||t[36]!==m||t[37]!==s||t[38]!==h||t[39]!==i||t[40]!==b?(L={showSidebar:s,showWorkflows:i,activeWorkspacePanel:f,showProjectSwitcher:m,showThemeSelector:h,handleToggleSidebar:v,toggleWorkspacePanel:b,openWorkspacePanel:S,closeWorkspacePanel:C,handleToggleConfig:E,handleToggleMission:P,handleEditConfig:A,handleOpenProjectSwitcher:$,handleCloseProjectSwitcher:M,handleToggleThemeSelector:D,handleCloseThemeSelector:F,setShowWorkflows:a},t[28]=f,t[29]=C,t[30]=A,t[31]=E,t[32]=P,t[33]=v,t[34]=S,t[35]=a,t[36]=m,t[37]=s,t[38]=h,t[39]=i,t[40]=b,t[41]=L):L=t[41],L}function Zz(n){return!n}function eF(n){var V;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=w.useCallback(async()=>{if(!e.sessionSource)return;const{dirName:K,fileName:Y}=e.sessionSource;try{const{parsed:X,source:G}=await Sv(K,Y,g,"session");t({type:"RELOAD_SESSION_CONTENT",session:X,source:G})}catch{}},[e.sessionSource,t,g]),[v,y]=w.useState(null),b=w.useCallback(K=>y(K),[]),j=w.useCallback(()=>y(null),[]),S=w.useCallback(async(K,Y)=>{try{const X=await Ne("/api/branch-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dirName:K,fileName:Y})});if(!X.ok)return;const G=await X.json(),{parsed:J,source:Z}=await Ks(G.dirName,G.fileName,g,"session");t({type:"LOAD_SESSION",session:J,source:Z,isMobile:s})}catch{}},[t,s,g]),k=w.useCallback(()=>{e.sessionSource&&S(e.sessionSource.dirName,e.sessionSource.fileName)},[e.sessionSource,S]),C=w.useCallback(async(K,Y)=>{try{await Ne("/api/delete-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dirName:K,fileName:Y})})}catch{}},[]),N=w.useCallback(async K=>{var J,Z;if(!e.sessionSource)return;const{dirName:Y,fileName:X}=e.sessionSource,G=(Z=(J=e.session)==null?void 0:J.turns[K])==null?void 0:Z.id;try{const Q=await Ne("/api/branch-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dirName:Y,fileName:X,turnIndex:K,turnUuid:G})});if(!Q.ok)return;const te=await Q.json(),{parsed:ne,source:oe}=await Ks(te.dirName,te.fileName,g,"session");t({type:"LOAD_SESSION",session:ne,source:oe,isMobile:s})}catch{}},[e.sessionSource,e.session,t,s,g]),E=w.useCallback((K,Y)=>{o(K,Y),t({type:"SET_MOBILE_TAB",tab:"chat"})},[o,t]),[T,P]=w.useState({}),_=w.useRef(c);_.current=c;const A=w.useRef(d);A.current=d;const I=w.useRef(m);I.current=m;const $=w.useRef(u);$.current=u;const R=w.useRef(f);R.current=f;const M=w.useRef(l);M.current=l;const O=((V=e.session)==null?void 0:V.sessionId)??null,D=w.useRef(null);w.useEffect(()=>{O!==D.current&&(D.current=O,O&&P(K=>O in K?K:{...K,[O]:{model:_.current,effort:A.current,fastMode:$.current,ultracode:R.current,mcpConfig:I.current}}))},[O]);const z=O?T[O]:void 0,F=m!==((z==null?void 0:z.mcpConfig)??null),L=z!=null&&(c!==z.model||d!==z.effort||u!==z.fastMode||f!==z.ultracode||a||F),H=w.useCallback(async()=>{var te,ne;if(!O)return;const K=_.current,Y=A.current,X=$.current,G=R.current,J=I.current,Z=M.current,Q=((te=e.sessionSource)==null?void 0:te.agentKind)??It(((ne=e.sessionSource)==null?void 0:ne.dirName)??null);Ht(Q).settingsApply==="live"&&await Ne(`/api/claude/settings/${encodeURIComponent(O)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:K,effort:Y,fastMode:X,ultracode:G,mcpConfig:J,permissionMode:Z.mode,allowedTools:Z.allowedTools,disallowedTools:Z.disallowedTools})}),P(oe=>({...oe,[O]:{model:K,effort:Y,fastMode:X,ultracode:G,mcpConfig:J}})),i()},[O,e.sessionSource,i]),U=w.useCallback(async()=>{if(O)try{await Ne("/api/stop-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:O})})}catch{}},[O]),W=w.useCallback((K,Y)=>{Cs(Y)&&p(),h(K,Y)},[p,h]);return{reloadSession:x,branchModalTurn:v,setBranchModalTurn:y,handleOpenBranches:b,handleCloseBranchModal:j,handleDuplicateSessionByPath:S,handleDuplicateSession:k,handleDeleteSession:C,handleBranchFromHere:N,handleMobileJumpToTurn:E,hasSettingsChanges:L,handleApplySettings:H,handleStopSession:U,handleLoadSessionScrollAware:W}}function Dv(){const n=B.c(6),e=w.useRef(null);let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t=new Map,n[0]=t):t=n[0];const s=w.useRef(t),o=w.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-DlF00ZHH.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]),w.useEffect(i,a);let l;n[3]===Symbol.for("react.memo_cache_sentinel")?(l=m=>{const p=e.current;return p?new Promise((h,g)=>{o.current=o.current+1;const x=o.current;s.current.set(x,{resolve:h,reject:g}),p.postMessage({type:"parse",id:x,text:m})}):Promise.resolve().then(()=>nl(m))},n[3]=l):l=n[3];const c=l;let d;n[4]===Symbol.for("react.memo_cache_sentinel")?(d=(m,p)=>{const h=e.current;return h?new Promise((g,x)=>{o.current=o.current+1;const v=o.current;s.current.set(v,{resolve:g,reject:x}),h.postMessage({type:"append",id:v,existing:m,newText:p})}):Promise.resolve().then(()=>z_(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 tF=30;function zv({dirName:n,fileName:e,sessionChangeKey:t,workerParse:s,onOlderTurns:o}){const[i,a]=w.useState(!1),[l,c]=w.useState(!1),d=w.useRef(""),u=w.useRef(null),f=`${n??""}::${e??""}::${t}`;return w.useEffect(()=>{d.current=f,u.current=null,c(!1);const p=n&&e?Sn.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:w.useCallback(async()=>{if(!n||!e||u.current)return 0;const p=`${n}::${e}::${t}`,h=Sn.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 Ne(`/api/sessions/${encodeURIComponent(n)}/${encodeURIComponent(e)}?before=${h.nextByteOffset}&count=${tF}`);if(!x.ok)return 0;const v=await x.json(),y=v.lines.length>0&&v.hasMore;if(d.current===p&&a(y),v.lines.length===0)return Sn.update(n,e,{hasMore:y,nextByteOffset:v.byteOffset}),0;const b=new Set(v.headerLines),j=v.lines.filter(C=>!b.has(C)),S=await s([...v.headerLines,...j].join(`
146
+ `)),k=Q2(h.olderTurns,S.turns,h.source.agentKind);return Sn.update(n,e,{hasMore:y,nextByteOffset:v.byteOffset,olderTurns:k}),d.current!==p?0:(o(k),S.turns.length)}finally{u.current===g&&(u.current=null,d.current===p&&c(!1))}},[n,e,t,s,o]),hasMore:i,isLoadingOlder:l}}function nF(n){const e=B.c(43),{agentKind:t,session:s,sessionSource:o,pendingDirName:i,isLive:a}=n,l=t??Gs,[c,d]=w.useState(""),[u,f]=w.useState(""),[m,p]=w.useState(!1),[h,g]=w.useState(!1),{options:x,fastTier:v,imageInput:y,normalizeEffort:b}=jg(l,c),j=c||(s==null?void 0:s.model);let S;e[0]!==l||e[1]!==j?(S=wj(l,j),e[0]=l,e[1]=j,e[2]=S):S=e[2];const k=S,C=h&&k;let N;e[3]!==b||e[4]!==u||e[5]!==C?(N=C?"xhigh":b(u),e[3]=b,e[4]=u,e[5]=C,e[6]=N):N=e[6];const E=N,T=!!v,P=T&&m,[_,A]=w.useState(null),I=w.useRef(null),$=(o==null?void 0:o.fileName)??null,R=w.useRef($);let M,O;e[7]!==$?(M=()=>{const Q=R.current;R.current=$,!(Q===null||Q===$)&&g(!1)},O=[$],e[7]=$,e[8]=M,e[9]=O):(M=e[8],O=e[9]),w.useEffect(M,O);let D,z;e[10]!==i?(D=()=>{i&&g(!1)},z=[i],e[10]=i,e[11]=D,e[12]=z):(D=e[11],z=e[12]),w.useEffect(D,z);let F;e[13]!==l?(F=Q=>{d(te=>te===Q?"":te),A(`${Q} is unavailable for this account. Cogpit retried the turn with ${an(l).displayName}'s default model.`)},e[13]=l,e[14]=F):F=e[14];const L=F;let H;e[15]===Symbol.for("react.memo_cache_sentinel")?(H=()=>{A(null)},e[15]=H):H=e[15];const U=H;let W,V;e[16]!==x||e[17]!==i||e[18]!==c||e[19]!==o?(W=()=>{c&&(!o&&!i||x.some(Q=>Q.value===c)||d(""))},V=[x,c,o,i],e[16]=x,e[17]=i,e[18]=c,e[19]=o,e[20]=W,e[21]=V):(W=e[20],V=e[21]),w.useEffect(W,V);let K,Y;e[22]!==_?(K=()=>{if(!_)return;const Q=setTimeout(()=>A(null),12e3);return()=>clearTimeout(Q)},Y=[_],e[22]=_,e[23]=K,e[24]=Y):(K=e[23],Y=e[24]),w.useEffect(K,Y);const X=s==null?void 0:s.rawMessages;let G,J;e[25]!==l||e[26]!==a||e[27]!==X?(G=()=>{if(!a||!X||!Ht(l).modelFallbackNotices)return;let Q;for(let ie=X.length-1;ie>=0;ie=ie-1,ie){const se=X[ie];if(se.type==="system"&&se.subtype==="model_refusal_fallback"){Q=se;break}}if(!Q)return;const te=typeof Q.uuid=="string"?Q.uuid:`${String(Q.original_model)}:${String(Q.fallback_model)}:${String(Q.request_id)}`;if(I.current===te)return;I.current=te;const ne=typeof Q.original_model=="string"?Q.original_model:"Fable",oe=typeof Q.fallback_model=="string"?Q.fallback_model:"Opus",re=typeof Q.api_refusal_explanation=="string"?` ${Q.api_refusal_explanation}`:"";A(`${ne} could not handle this request, so Claude continued with ${oe}.${re}`)},J=[a,X,l],e[25]=l,e[26]=a,e[27]=X,e[28]=G,e[29]=J):(G=e[28],J=e[29]),w.useEffect(G,J);let Z;return e[30]!==E||e[31]!==P||e[32]!==T||e[33]!==m||e[34]!==L||e[35]!==y||e[36]!==_||e[37]!==u||e[38]!==c||e[39]!==C||e[40]!==k||e[41]!==h?(Z={selectedModel:c,setSelectedModel:d,selectedEffort:u,setSelectedEffort:f,fastModeEnabled:m,ultracodeEnabled:h,effectiveEffort:E,fastModeAvailable:T,fastModeActive:P,setFastModeEnabled:p,ultracodeAvailable:k,ultracodeActive:C,setUltracodeEnabled:g,imageInputAvailable:y,modelFallbackNotice:_,dismissModelFallbackNotice:U,handleModelRejected:L},e[30]=E,e[31]=P,e[32]=T,e[33]=m,e[34]=L,e[35]=y,e[36]=_,e[37]=u,e[38]=c,e[39]=C,e[40]=k,e[41]=h,e[42]=Z):Z=e[42],Z}const sF=["model","effort","fastMode","ultracode","permissionMode"];function oF({sessionKey:n,values:e,onHydrate:t}){const s=w.useRef(null),o=w.useRef(null),i=w.useRef(t);i.current=t;const a=w.useRef(e);a.current=e,w.useEffect(()=>{if(s.current=null,o.current=null,!n)return;let c=!1;return Ov(n).then(d=>{if(c||d===null)return;if(sF.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 gd(n,a.current),o.current=JSON.stringify(a.current);s.current=n}),()=>{c=!0}},[n]);const l=JSON.stringify(e);w.useEffect(()=>{!n||s.current!==n||l!==o.current&&(o.current=l,gd(n,a.current))},[l,n])}function rF(n){const[e,t]=w.useState(new Map),[s,o]=w.useState(null),[i,a]=w.useState(!0),l=w.useRef(new Map),c=w.useRef(null);w.useEffect(()=>{const x=n??null,v=c.current;if(v&&v!==x&&l.current.set(v,{activeId:s,collapsed:i}),x!==v){const y=x?l.current.get(x):null;y?(o(y.activeId),a(y.collapsed)):(o(null),a(!0))}c.current=x},[n]);const d=w.useCallback(()=>a(x=>!x),[]),u=w.useCallback(x=>{t(v=>{const y=new Map(v);return y.set(x.id,x),y}),o(x.id),a(!1)},[]),f=w.useCallback(x=>{t(v=>{const y=new Map(v);return y.delete(x),o(b=>{if(b!==x)return b;const j=[...y.keys()];return j.length>0?j[j.length-1]:null}),y})},[]),m=w.useCallback(x=>{o(x),a(!1)},[]),p=w.useCallback((x,v)=>{t(y=>{const b=y.get(x);if(!b||b.status===v)return y;const j=new Map(y);return j.set(x,{...b,status:v}),j})},[]),h=w.useCallback(x=>{t(v=>{let y=!1;const b=new Map(v),j=new Set(x.map(S=>S.id));for(const[S,k]of b)k.type==="task"&&!j.has(S)&&(b.delete(S),y=!0);for(const S of x){const k=b.get(S.id);k?(k.name!==S.title||k.outputPath!==S.outputPath)&&(b.set(S.id,{...k,name:S.title,outputPath:S.outputPath}),y=!0):(b.set(S.id,{id:S.id,name:S.title,type:"task",status:"running",outputPath:S.outputPath}),y=!0)}return y?b:v})},[]),g=w.useCallback((x,v,y)=>{v&&y&&t(b=>{if(b.has(x))return b;const j=new Map(b);return j.set(x,{id:x,name:y,type:"task",status:"running",outputPath:v}),j}),o(b=>b===x?(a(!0),b):(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 iF(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=rF(t),[p,h]=w.useState(null),[g,x]=w.useState(0),v=w.useRef(0),y=s??o??void 0,b=!!(y&&(p==null?void 0:p.kind)==="preview"&&p.cwd===y),j=(p==null?void 0:p.kind)==="project-files"&&p.anchorCwd===(y??null)?p:null;let S;e[0]!==a||e[1]!==o?(S={path:o,dirName:a},e[0]=a,e[1]=o,e[2]=S):S=e[2];const k=S;let C;e[3]!==l||e[4]!==a||e[5]!==o||e[6]!==s||e[7]!==i?(C=()=>{if(Ws()){console.warn("[open-terminal] unavailable for remote devices");return}const X=s??o??void 0,G=i??a??l??void 0;if(!X&&!G){console.warn("[open-terminal] no project path available");return}Ne("/api/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:X,dirName:G})}).then(fF).catch(uF)},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;e[9]!==l||e[10]!==a||e[11]!==o||e[12]!==s||e[13]!==i?(E=X=>{if(Ws()){console.warn("[mcp-auth] unavailable for remote devices");return}const G=s??o??void 0,J=i??a??l??void 0;!G&&!J||Ne("/api/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:G,dirName:J,command:"claude /mcp"})}).catch(dF)},e[9]=l,e[10]=a,e[11]=o,e[12]=s,e[13]=i,e[14]=E):E=e[14];const T=E;let P;e[15]!==o||e[16]!==m||e[17]!==s?(P=()=>{const G=[...m.processes.values()].filter(cF).at(-1);if(!G){(s??o)&&x(lF);return}m.activeProcessId===G.id&&!m.collapsed?m.toggleCollapse():m.setActive(G.id)},e[15]=o,e[16]=m,e[17]=s,e[18]=P):P=e[18];const _=P;let A;e[19]!==o||e[20]!==s?(A=()=>{(s??o)&&x(aF)},e[19]=o,e[20]=s,e[21]=A):A=e[21];const I=A;let $;e[22]!==f||e[23]!==y||e[24]!==b?($=()=>{y&&w.startTransition(()=>{f(),h(b?null:{kind:"preview",cwd:y})})},e[22]=f,e[23]=y,e[24]=b,e[25]=$):$=e[25];const R=$;let M;e[26]!==d||e[27]!==f||e[28]!==y||e[29]!==u?(M=()=>{if(y){if(d===St.projectFiles){f();return}w.startTransition(()=>{h({kind:"project-files",root:y,anchorCwd:y,request:null}),u(St.projectFiles)})}},e[26]=d,e[27]=f,e[28]=y,e[29]=u,e[30]=M):M=e[30];const O=M;let D;e[31]!==y||e[32]!==u||e[33]!==c?(D=X=>{if(!c)return!1;const G=sk(X,y);if(!G)return!1;v.current=v.current+1;const J=v.current;return w.startTransition(()=>h({kind:"project-files",root:G.root,anchorCwd:y??null,request:G.file?{file:G.file,mode:G.mode,line:G.line,token:J}:null})),u(St.projectFiles),!0},e[31]=y,e[32]=u,e[33]=c,e[34]=D):D=e[34];const z=D;let F,L;e[35]!==z?(L=()=>nk(z),F=[z],e[35]=z,e[36]=F,e[37]=L):(F=e[36],L=e[37]),w.useEffect(L,F);let H;e[38]===Symbol.for("react.memo_cache_sentinel")?(H=()=>{w.startTransition(()=>h(null))},e[38]=H):H=e[38];const U=H,W=!!(y&&d===St.projectFiles),V=j==null?void 0:j.root,K=(j==null?void 0:j.request)??null;let Y;return e[39]!==y||e[40]!==T||e[41]!==I||e[42]!==N||e[43]!==_||e[44]!==R||e[45]!==O||e[46]!==g||e[47]!==k||e[48]!==m||e[49]!==b||e[50]!==W||e[51]!==V||e[52]!==K?(Y={processPanel:m,currentCwd:y,showPreview:b,showProjectFiles:W,projectFilesRoot:V,projectFilesRequest:K,launchTerminalRequest:g,pendingProject:k,handleOpenTerminal:N,handleMcpAuth:T,handleToggleIntegratedTerminal:_,handleNewIntegratedTerminal:I,handleTogglePreview:R,handleToggleProjectFiles:O,closeRightWorkspace:U},e[39]=y,e[40]=T,e[41]=I,e[42]=N,e[43]=_,e[44]=R,e[45]=O,e[46]=g,e[47]=k,e[48]=m,e[49]=b,e[50]=W,e[51]=V,e[52]=K,e[53]=Y):Y=e[53],Y}function aF(n){return n+1}function lF(n){return n+1}function cF(n){return n.type==="terminal"}function dF(n){return console.error("[mcp-auth] open-terminal failed:",n)}function uF(n){return console.error("[open-terminal] fetch failed:",n)}function fF(n){n.ok||n.json().then(pF).catch(mF)}function mF(){}function pF(n){return console.error("[open-terminal]",n.error)}function hF(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 gF={totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:0};function Fv(n,e){return{dirName:n.dirName,fileName:n.fileName,rawText:e,agentKind:It(n.dirName)}}function xF(n){return{sessionId:n.sessionId,version:"",gitBranch:"",cwd:"",slug:"",name:"",model:"",turns:[],stats:{...gF},rawMessages:[],agentKind:It(n.dirName)}}function Bv(n){if(!(n!=null&&n.trim()))return null;try{return{rawText:n,parsed:nl(n)}}catch{return null}}async function bF(n,e,t=3,s=100,o=!0){if(o){const i=Bv(n.initialContent);if(i)return i}for(let i=0;i<t;i++){if(e.signal.aborted)throw new DOMException("Aborted","AbortError");const a=await Ne(`/api/sessions/${encodeURIComponent(n.dirName)}/${encodeURIComponent(n.fileName)}`,{signal:e.signal});if(a.ok){const l=await a.text();if(l.trim())try{return{rawText:l,parsed:nl(l)}}catch{}}i<t-1&&await new Promise(l=>setTimeout(l,s))}return null}async function vF(n,e,t,s){let o=s;for(let i=0;i<30;i++){if(e.signal.aborted)return;const a=await bF(n,e,1,0,!1);if(a&&a.rawText!==o){t({type:"RELOAD_SESSION_CONTENT",session:a.parsed,source:Fv(n,a.rawText)});return}o=(a==null?void 0:a.rawText)??o,await new Promise(l=>setTimeout(l,200))}}async function N1(n,e,t,s,o){const i=Bv(n.initialContent),a=(i==null?void 0:i.rawText)??"",l=(i==null?void 0:i.parsed)??xF(n),c=Fv(n,a);return t({type:"FINALIZE_SESSION",session:l,source:c,isMobile:s}),o(l,c),vF(n,e,t,a),n.sessionId}async function yF(n,e,t,s){const o=await Ne(`/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 wF({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]=w.useState(!1),[p,h]=w.useState(null),[g,x]=w.useState(!1),v=w.useRef(null),y=w.useRef(null),b=w.useRef(null),j=w.useCallback((N,E)=>{y.current=N,b.current=E??null,h(null),m(!1),e({type:"INIT_PENDING_SESSION",dirName:N,cwd:E,isMobile:t})},[e,t]),S=w.useCallback(async(N,E)=>{var $;const T=y.current;if(!T)return null;const P=It(T),_=b.current;($=v.current)==null||$.abort();const A=new AbortController;v.current=A,m(!0),h(null),o==null||o(N);const I=Date.now();try{const R=hF(N),M=an(P),{capabilities:O}=M,D={dirName:T,cwd:M.dirName.lossy?_??void 0:void 0,message:N,images:E,permissions:n,effort:l||void 0,fastMode:c?!0:void 0,ultracode:O.ultracode&&d?!0:void 0,name:O.namedSessions&&R||void 0,worktreeName:O.worktrees&&g?Sj(N):void 0,mcpConfig:O.mcp&&u||void 0},{res:z,errorMessage:F}=await vv(U=>Ne("/api/create-and-send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...D,model:U}),signal:A.signal}),{model:a,agentKind:P,errorFallback:"Unknown error",onModelRejected:i});if(!z.ok){if(P==="codex"){const U=await yF(T,N,I,A);if(U){y.current=null,b.current=null;const W=await N1(U,A,e,t,s);return R&&W&&dd(W,R),W}}return h(F||`Failed to create session (${z.status})`),null}const L=await z.json();y.current=null,b.current=null;const H=await N1(L,A,e,t,s);return R&&H&&dd(H,R),H}catch(R){return A.signal.aborted||h(R instanceof Error?R.message:"Failed to create session"),null}finally{A.signal.aborted||m(!1)}},[n,a,l,c,d,u,g,e,t,s,o,i]),k=w.useCallback(()=>h(null),[]),C=w.useCallback(()=>{var N;(N=v.current)==null||N.abort(),v.current=null,y.current=null,b.current=null,m(!1),h(null)},[]);return{creatingSession:f,createError:p,clearCreateError:k,handleNewSession:j,createAndSend:S,cancelCreation:C,worktreeEnabled:g,setWorktreeEnabled:x}}function jF(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=w.useRef(null),g=w.useRef(null),[x,v]=w.useState(null);let y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y=W=>{var V;(V=h.current)==null||V.call(h,W),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]=y):y=e[0];let b;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?(b={permissionsConfig:t,dispatch:s,isMobile:o,onSessionFinalized:y,onCreateStarted:v,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]=b):b=e[10];const j=wF(b),S=j.handleNewSession,[k,C]=w.useState(null);let N;e[11]===Symbol.for("react.memo_cache_sentinel")?(N=new Map,e[11]=N):N=e[11];const E=w.useRef(N),T=SF;let P;e[12]===Symbol.for("react.memo_cache_sentinel")?(P=async W=>{if(Ti===null)return null;const V=E.current;if(V.has(W))return V.get(W)??null;const K=lj(await T(),W,Ti);return V.set(W,K),K},e[12]=P):P=e[12];const _=P;let A;e[13]!==S?(A=async(W,V)=>{var G;const K=V??((G=(await T()).find(J=>J.dirName===W))==null?void 0:G.path)??null;if(!K){C(null),S(W);return}const Y=It(W)===Ti?Ti:null,X=Y?Pl(Y,K):await _(K);C(X?{discoveredDirName:X,cwd:K}:null),S(Y&&X?X:W,K)},e[13]=S,e[14]=A):A=e[14];const I=A;let $;e[15]!==i||e[16]!==I?($=W=>{const V=Pl(i,W);I(V,W)},e[15]=i,e[16]=I,e[17]=$):$=e[17];const R=$;let M;e[18]!==S||e[19]!==k?(M=W=>{if(!k)return;const V=Pl(W,k.cwd,k.discoveredDirName);S(V,k.cwd)},e[18]=S,e[19]=k,e[20]=M):M=e[20];const O=M;let D;e:{if(!j.creatingSession||!a){D=null;break e}const W=x??void 0;let V;e[21]!==l||e[22]!==a||e[23]!==W?(V={dirName:a,cwd:l,firstMessage:W},e[21]=l,e[22]=a,e[23]=W,e[24]=V):V=e[24],D=V}const z=D;let F,L;e[25]!==a?(L=()=>{a||(v(null),C(null))},F=[a],e[25]=a,e[26]=F,e[27]=L):(F=e[26],L=e[27]),w.useEffect(L,F);const H=k?O:void 0;let U;return e[28]!==R||e[29]!==I||e[30]!==j.cancelCreation||e[31]!==j.clearCreateError||e[32]!==j.createAndSend||e[33]!==j.createError||e[34]!==j.creatingSession||e[35]!==j.setWorktreeEnabled||e[36]!==j.worktreeEnabled||e[37]!==z||e[38]!==H?(U={creatingSession:j.creatingSession,createError:j.createError,clearCreateError:j.clearCreateError,createAndSend:j.createAndSend,cancelCreation:j.cancelCreation,worktreeEnabled:j.worktreeEnabled,setWorktreeEnabled:j.setWorktreeEnabled,sessionFinalizedRef:h,liveSessionsRefreshRef:g,pendingSessionInfo:z,pendingAgentKindChange:H,handleStartNewSession:I,handleStartNewFolder:R},e[28]=R,e[29]=I,e[30]=j.cancelCreation,e[31]=j.clearCreateError,e[32]=j.createAndSend,e[33]=j.createError,e[34]=j.creatingSession,e[35]=j.setWorktreeEnabled,e[36]=j.worktreeEnabled,e[37]=z,e[38]=H,e[39]=U):U=e[39],U}async function SF(){try{const n=await Ne("/api/projects");return n.ok?await n.json():[]}catch{return[]}}const wc=new Set;function NF(n,e){const t=wn(),s=Ns();return`${s===null?t:`${t}:${s}`}:${n}/${e}`}async function kF(n,e,t){const s=NF(n,e);if(!wc.has(s)&&!Sn.get(n,e)){wc.add(s);try{await Ks(n,e,t,"session prefetch")}catch{}finally{wc.delete(s)}}}function CF({onAuthenticated:n}){const[e,t]=w.useState(null),[s,o]=w.useState(""),[i,a]=w.useState(""),[l,c]=w.useState(!1),[d,u]=w.useState(null),[f,m]=w.useState(!1),p=e==="team";w.useEffect(()=>{let x=!1;return yg().then(v=>{x||t(v)}),()=>{x=!0}},[]);const h=w.useCallback(async x=>{if(x.preventDefault(),!(!i.trim()||p&&!s.trim())){m(!0),u(null);try{const v=await fetch("/api/auth/verify",p?{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json","X-Cogpit-Client":"1"},body:JSON.stringify({username:s.trim(),password:i})}:{method:"POST",credentials:"same-origin",cache:"no-store",headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json","X-Cogpit-Client":"1"}}),y=await v.json();v.ok&&y.valid?(Ma(),a(""),o(""),n()):u(y.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(ln,{children:[r.jsxs(xn,{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(Ww,{className:"size-4"})}),r.jsx(bn,{children:"Sign in to Cogpit"}),r.jsx(vn,{children:p?"Use your team account to continue.":"Enter the server password to continue."})]}),e===null?r.jsx(cn,{children:r.jsx("div",{className:"flex min-h-24 items-center justify-center",role:"status","aria-label":"Checking server",children:r.jsx(nt,{className:"size-5 text-muted-foreground"})})}):r.jsxs(r.Fragment,{children:[r.jsxs(cn,{className:"flex flex-col gap-4",children:[r.jsxs(Do,{children:[p&&r.jsxs(yt,{children:[r.jsx(wt,{htmlFor:"login-username",children:"Username"}),r.jsx(Mt,{id:"login-username",type:"text",value:s,onChange:x=>o(x.target.value),placeholder:"Username",autoComplete:"username",autoFocus:!0})]}),r.jsxs(yt,{children:[r.jsx(wt,{htmlFor:"login-password",children:"Password"}),r.jsxs(ds,{children:[r.jsx(us,{id:"login-password",type:l?"text":"password",value:i,onChange:x=>a(x.target.value),placeholder:"Password",autoComplete:"current-password",autoFocus:!p}),r.jsx(En,{align:"inline-end",children:r.jsx(ei,{size:"icon-xs",onClick:()=>c(x=>!x),"aria-label":l?"Hide password":"Show password",children:l?r.jsx(Aa,{}):r.jsx(js,{})})})]})]})]}),d&&r.jsxs(ut,{variant:"destructive",children:[r.jsx(Xt,{"aria-hidden":"true"}),r.jsx(Et,{children:"Sign in failed"}),r.jsx(ft,{children:d})]})]}),r.jsx(Zr,{children:r.jsxs(ee,{type:"submit",className:"w-full",disabled:g,children:[f&&r.jsx(nt,{"data-icon":"inline-start"}),"Connect"]})})]})]})})})}const k1=16,na="__cogpitBootstrapToken";function _F(){const e=new URLSearchParams(window.location.hash.replace(/^#/,"")).get("bootstrap")||"",t=window.history.state||{},s=e||(typeof t[na]=="string"?t[na]:"");return e&&window.history.replaceState({...t,[na]:e},"",`${window.location.pathname}${window.location.search}`),s}function C1(){const n={...window.history.state||{}};delete n[na],window.history.replaceState(n,"",`${window.location.pathname}${window.location.search}`)}function TF({onAuthenticated:n,onBootstrapClosed:e}){const[t]=w.useState(_F),[s,o]=w.useState(""),[i,a]=w.useState(""),[l,c]=w.useState(""),[d,u]=w.useState(""),[f,m]=w.useState(!1),[p,h]=w.useState(null),[g,x]=w.useState(!1),v=d.length>0&&d!==l,y=!t||!s.trim()||l.length<k1||d!==l,b=w.useCallback(async j=>{if(j.preventDefault(),!y){x(!0),h(null);try{const S=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 S.json();if(S.ok){C1(),c(""),u(""),o(""),a(""),await e(),n();return}if(S.status===410){C1(),await e();return}h(k.error||"Could not create the admin account")}catch{h("Failed to connect to server")}finally{x(!1)}}},[t,i,y,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:b,className:"w-full max-w-md",children:r.jsxs(ln,{children:[r.jsxs(xn,{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(Hw,{className:"size-4"})}),r.jsx(bn,{children:"Create the first admin"}),r.jsx(vn,{children:"Set up the account that will manage this Cogpit team server."})]}),r.jsxs(cn,{className:"flex flex-col gap-4",children:[!t&&r.jsxs(ut,{children:[r.jsx(mn,{"aria-hidden":"true"}),r.jsx(Et,{children:"Setup link required"}),r.jsx(ft,{children:"Open the one-time setup URL shown in the Cogpit server log."})]}),r.jsxs(Do,{children:[r.jsxs(yt,{children:[r.jsx(wt,{htmlFor:"bootstrap-username",children:"Username"}),r.jsx(Mt,{id:"bootstrap-username",type:"text",value:s,onChange:j=>o(j.target.value),placeholder:"Username",autoComplete:"username",autoFocus:!0}),r.jsx(Co,{children:"Use 2 to 32 lowercase letters, numbers, dots, underscores, or hyphens."})]}),r.jsxs(yt,{children:[r.jsxs(wt,{htmlFor:"bootstrap-display-name",children:["Display name ",r.jsx("span",{className:"font-normal text-muted-foreground",children:"Optional"})]}),r.jsx(Mt,{id:"bootstrap-display-name",type:"text",value:i,onChange:j=>a(j.target.value),placeholder:"Display name (optional)",autoComplete:"name"})]}),r.jsxs(yt,{children:[r.jsx(wt,{htmlFor:"bootstrap-password",children:"Password"}),r.jsxs(ds,{children:[r.jsx(us,{id:"bootstrap-password",type:f?"text":"password",value:l,onChange:j=>c(j.target.value),placeholder:"Password",autoComplete:"new-password"}),r.jsx(En,{align:"inline-end",children:r.jsx(ei,{size:"icon-xs",onClick:()=>m(j=>!j),"aria-label":f?"Hide password":"Show password",children:f?r.jsx(Aa,{}):r.jsx(js,{})})})]}),r.jsxs(Co,{children:["Use at least ",k1," characters."]})]}),r.jsxs(yt,{"data-invalid":v,children:[r.jsx(wt,{htmlFor:"bootstrap-confirm-password",children:"Confirm password"}),r.jsx(Mt,{id:"bootstrap-confirm-password",type:f?"text":"password",value:d,onChange:j=>u(j.target.value),placeholder:"Confirm password",autoComplete:"new-password","aria-invalid":v}),v&&r.jsx(vs,{children:"Passwords do not match"})]})]}),p&&r.jsxs(ut,{variant:"destructive",children:[r.jsx(Xt,{"aria-hidden":"true"}),r.jsx(Et,{children:"Could not create the account"}),r.jsx(ft,{children:p})]})]}),r.jsx(Zr,{children:r.jsxs(ee,{type:"submit",className:"w-full",disabled:g||y,children:[g&&r.jsx(nt,{"data-icon":"inline-start"}),"Create admin account"]})})]})})})}function EF(){const n=B.c(18);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=zd(),n[0]=e):e=n[0];const t=e,[s,o]=w.useState(null),[i,a]=w.useState(!1),[l,c]=w.useState(!1),d=w.useRef(0);let u,f;n[1]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{let _=!1;return vg().then(A=>{_||o(A)}),()=>{_=!0}},f=[],n[1]=u,n[2]=f):(u=n[1],f=n[2]),w.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 _=!1;const A=d.current;return i4().then(I=>{!_&&d.current===A&&(a(I),c(!0))}),()=>{_=!0}},h=[m],n[3]=m,n[4]=p,n[5]=h):(p=n[4],h=n[5]),w.useEffect(p,h);let g;n[6]!==(s==null?void 0:s.edition)?(g=()=>{let _=!1;const A=()=>{const I=d.current=d.current+1,$=()=>{_||d.current!==I||(a(!1),c(!0))};if(t||(s==null?void 0:s.edition)==="team"){$();return}Mm().then(R=>{_||d.current!==I||(o(R),R.edition==="team"&&$())})};return window.addEventListener("cogpit-auth-required",A),()=>{_=!0,window.removeEventListener("cogpit-auth-required",A)}},n[6]=s==null?void 0:s.edition,n[7]=g):g=n[7];const x=s==null?void 0:s.edition;let v;n[8]!==x?(v=[x,t],n[8]=x,n[9]=v):v=n[9],w.useEffect(g,v);let y;n[10]===Symbol.for("react.memo_cache_sentinel")?(y=()=>{d.current=d.current+1,a(!0),c(!0),window.dispatchEvent(new Event("cogpit-auth-changed"))},n[10]=y):y=n[10];const b=y;let j;n[11]===Symbol.for("react.memo_cache_sentinel")?(j=async()=>{o(await Mm())},n[11]=j):j=n[11];const S=j;let k;n[12]===Symbol.for("react.memo_cache_sentinel")?(k=()=>{d.current=d.current+1,a(!1),c(!0),a4().finally(AF)},n[12]=k):k=n[12];const C=k,N=(s==null?void 0:s.edition)??null,E=l&&s!==null,T=(s==null?void 0:s.needsBootstrap)===!0;let P;return n[13]!==i||n[14]!==N||n[15]!==E||n[16]!==T?(P={isRemote:t,edition:N,authChecked:E,authenticated:i,needsBootstrap:T,handleAuthenticated:b,refreshServerState:S,logout:C},n[13]=i,n[14]=N,n[15]=E,n[16]=T,n[17]=P):P=n[17],P}function AF(){window.dispatchEvent(new Event("cogpit-auth-changed"))}const PF=w.lazy(()=>Ve(()=>import("./index-7fgSFumo.js"),__vite__mapDeps([38,1,2,3,4])).then(n=>({default:n.BranchModal}))),IF=w.lazy(()=>Ve(()=>import("./WorkflowsPanel-BTeZdY1F.js"),__vite__mapDeps([39,1,4,2,3])).then(n=>({default:n.WorkflowsPanel})));function RF(){var Zf,em,tm,nm,sm,om,rm,im,am,lm,cm,dm,um,fm,mm,pm,hm,gm,xm,bm;const n=wf(window.location.pathname),e=Ez(),t=EF(),s=Mz(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=xf(),d=Cv(),[u,f]=yv(),{procBySession:m}=p2(),{parse:p,append:h}=Dv(),g=w.useCallback(Re=>{f({type:"SET_OLDER_TURNS",turns:Re})},[f]),x=w.useCallback((Re,Ge)=>{kF(Re,Ge,p)},[p]),v=zv({dirName:((Zf=u.sessionSource)==null?void 0:Zf.dirName)??null,fileName:((em=u.sessionSource)==null?void 0:em.fileName)??null,sessionChangeKey:u.sessionChangeKey,workerParse:p,onOlderTurns:g}),{loadMore:y}=v,b=!!u.searchQuery&&v.hasMore,j=((tm=u.session)==null?void 0:tm.turns.length)??0;w.useEffect(()=>{b&&y()},[b,y,j]);const S=Qz(u,f),k=w.useRef(null),C=w.useRef(null),[N,E]=w.useState(!1),[T,P]=w.useState(!1),_=w.useCallback(()=>f({type:"TOGGLE_EXPAND_ALL"}),[f]),A=w.useCallback(()=>E(!0),[]),I=w.useCallback(()=>{var Re;return(Re=C.current)==null?void 0:Re.focus()},[]),$=w.useCallback(()=>f({type:"SET_EXPAND_ALL",value:!0}),[f]),R=w.useCallback(()=>f({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0}),[f]),M=w.useCallback(()=>f({type:"SET_EXPAND_ALL",value:!1}),[f]),O=S.toggleWorkspacePanel,D=w.useCallback(()=>O(St.sessionInfo),[O]),z=w.useCallback(Re=>{w.startTransition(()=>{f({type:"SET_DASHBOARD_PROJECT",dirName:Re})})},[f]),F=u.pendingCwd??(u.pendingDirName?kn(u.pendingDirName):null),L=((nm=u.sessionSource)==null?void 0:nm.agentKind)??It(((sm=u.sessionSource)==null?void 0:sm.dirName)??u.pendingDirName??null),H=(om=u.session)!=null&&om.sessionId?m.get(u.session.sessionId):void 0,U=Ht(L),W=bf(L,H),V=U.worktrees,K=U.mcp,Y=Xz(i?((rm=u.session)==null?void 0:rm.cwd)??F??void 0:void 0,i&&U.slashCommands),X=w.useCallback(Re=>{if(!i)return;const Ge=Y.suggestions.find($t=>$t.name===Re);w.startTransition(()=>{f({type:"OPEN_CONFIG",filePath:Ge==null?void 0:Ge.filePath})})},[i,f,Y.suggestions]),G=w.useCallback(async(Re,Ge)=>{if(!i)return null;const $t=Y.suggestions.find(Jn=>Jn.name===Re);if(!($t!=null&&$t.filePath))return null;try{const Jn=await Ne("/api/expand-command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:$t.filePath,args:Ge||""})});return Jn.ok?(await Jn.json()).content??null:null}catch{return null}},[i,Y.suggestions]),{processPanel:J,currentCwd:Z,showPreview:Q,showProjectFiles:te,projectFilesRoot:ne,projectFilesRequest:oe,launchTerminalRequest:re,pendingProject:ie,handleOpenTerminal:se,handleMcpAuth:ce,handleToggleIntegratedTerminal:ae,handleNewIntegratedTerminal:ue,handleTogglePreview:me,handleToggleProjectFiles:de,closeRightWorkspace:le}=iF({sessionId:(im=u.session)==null?void 0:im.sessionId,sessionCwd:(am=u.session)==null?void 0:am.cwd,pendingPath:F,sessionDirName:(lm=u.sessionSource)==null?void 0:lm.dirName,pendingDirName:u.pendingDirName,dashboardProject:u.dashboardProject,supportsFileWorkspace:!c&&a,activeWorkspacePanel:S.activeWorkspacePanel,openWorkspacePanel:S.openWorkspacePanel,closeWorkspacePanel:S.closeWorkspacePanel}),xe=Kz(u.session??null),[pe,ve]=w.useState(!1),Te=((cm=u.sessionSource)==null?void 0:cm.dirName)??u.pendingDirName??u.dashboardProject??null,{activeWorkspacePanel:$e,closeWorkspacePanel:_e,showWorkflows:Ce}=S,ke=Fz(o&&V&&u.mainView==="sessions"&&$e===St.worktrees?Te:null),Me=w.useMemo(()=>{const Re=u.session;return Re?Re.turns.some(Ge=>va(Ge.toolCalls,Re.cwd)||Ge.subAgentActivity.some($t=>va($t.toolCalls,Re.cwd))):!1},[u.session]),Oe=w.useMemo(()=>{if(!u.session||!U.workflows)return 0;let Re=0;for(const Ge of u.session.turns)for(const $t of Ge.toolCalls)$t.name==="Workflow"&&Re++;return Re},[u.session,U.workflows]),Le=Oe>0,De=w.useMemo(()=>{const Re=u.sessionSource;return!Re||!U.workflows||Cs(Re.fileName)?{dirName:null,sessionId:null}:{dirName:Re.dirName,sessionId:Tc(Re.fileName)}},[u.sessionSource,U.workflows]),Ie=VD(De.dirName,De.sessionId,Le),he=Le||Ie.workflows.length>0,ge=Ie.workflows.length||Oe,Se=S.setShowWorkflows,be=w.useCallback(()=>Se(!0),[Se]),[Fe,He]=w.useState(!1),We=S.openWorkspacePanel;w.useEffect(()=>{if(!a)return;const Re=()=>{c?He(!0):We(St.fileChanges)};return window.addEventListener(Or,Re),()=>window.removeEventListener(Or,Re)},[a,We,c]);const Ee=w.useMemo(()=>u.session?R0(u.session):null,[u.session]),ze=w.useRef(null),{isLive:fe,sseState:we,isCompacting:Ue,streamingOverlay:Be,turnError:Ae,agentProgress:qe,promptSuggestion:ht}=xv(u.sessionSource,Re=>{w.startTransition(()=>{f({type:"UPDATE_SESSION",session:Re})})},p,h,()=>{var Re;return(Re=ze.current)==null?void 0:Re.call(ze)},u.session),Je=Yz(((dm=u.session)==null?void 0:dm.cwd)??null),Ke=fz(),Ut=Ke.setMode,At=hz(W?null:((um=u.session)==null?void 0:um.sessionId)??null),sn=W?null:At.plan??Ee,{selectedModel:Ot,setSelectedModel:Pn,selectedEffort:Js,setSelectedEffort:Vo,fastModeEnabled:Wv,ultracodeEnabled:Hv,effectiveEffort:gi,fastModeAvailable:qv,fastModeActive:xi,setFastModeEnabled:wl,ultracodeAvailable:Kv,ultracodeActive:bi,setUltracodeEnabled:jl,imageInputAvailable:jf,modelFallbackNotice:Vv,dismissModelFallbackNotice:Gv,handleModelRejected:Sf}=nF({agentKind:L,session:u.session,sessionSource:u.sessionSource,pendingDirName:u.pendingDirName,isLive:fe}),Nf=Uz((fm=u.session)==null?void 0:fm.sessionId,(mm=u.sessionSource)==null?void 0:mm.fileName);oF({sessionKey:Nf,values:{model:Ot,effort:Js,fastMode:Wv,ultracode:Hv,permissionMode:Ke.config.mode},onHydrate:w.useCallback(Re=>{Re.model!==void 0&&Pn(Re.model),Re.effort!==void 0&&Vo(Re.effort),Re.fastMode!==void 0&&wl(Re.fastMode),Re.ultracode!==void 0&&jl(Re.ultracode),Re.permissionMode&&Ut(Re.permissionMode)},[Pn,Vo,wl,jl,Ut])});const on=qz(K&&i?Z:void 0,K&&i?Te??void 0:void 0,K&&i?Nf??void 0:void 0,i);w.useEffect(()=>{!V&&$e===St.worktrees&&_e()},[V,$e,_e]),w.useEffect(()=>{Ce&&!he&&Se(!1)},[Ce,he,Se]);const{creatingSession:kf,createError:Cf,clearCreateError:Yv,createAndSend:Xv,cancelCreation:_f,worktreeEnabled:Jv,setWorktreeEnabled:Qv,sessionFinalizedRef:vi,liveSessionsRefreshRef:Tf,pendingSessionInfo:Ef,pendingAgentKindChange:Zv,handleStartNewSession:Af,handleStartNewFolder:ey}=jF({permissionsConfig:Ke.config,dispatch:f,isMobile:c,defaultAgentKind:e.defaultAgentKind,pendingDirName:u.pendingDirName,pendingCwd:u.pendingCwd,onModelRejected:Sf,model:Ot,effort:gi,fastMode:xi,ultracode:bi,mcpConfig:K&&i?on.mcpConfigJson:null}),gt=XD({sessionSource:u.sessionSource,parsedSessionId:((pm=u.session)==null?void 0:pm.sessionId)??null,cwd:(hm=u.session)==null?void 0:hm.cwd,permissions:Ke.config,onPermissionsApplied:Ke.markApplied,model:Ot,effort:gi,fastMode:xi,ultracode:bi,mcpConfig:K&&i?on.mcpConfigJson:null,onModelRejected:Sf,readOnly:W,onCreateSession:u.pendingDirName?Xv:void 0}),Dt=qD(U.agentTeams?((gm=u.sessionSource)==null?void 0:gm.fileName)??null:null,((xm=u.sessionSource)==null?void 0:xm.dirName)??null);w.useEffect(()=>{Dt!=null&&Dt.currentMemberName?f({type:"SET_CURRENT_MEMBER_NAME",name:Dt.currentMemberName}):Dt||f({type:"SET_CURRENT_MEMBER_NAME",name:null})},[Dt==null?void 0:Dt.currentMemberName,Dt,f]),w.useEffect(()=>{c&&f({type:"GUARD_MOBILE_TAB",hasSession:!!u.session||!!u.pendingDirName})},[u.session,u.pendingDirName,u.mobileTab,c,f]);const In=wv({session:u.session,isLive:fe,pendingMessages:gt.pendingMessages,consumePending:gt.consumePending,sessionChangeKey:u.sessionChangeKey,partialSignal:Be}),Pf=In.chatScrollRef,If=In.resetTurnCount,Rf=In.scrollToBottomInstant,ty=w.useCallback(Re=>{ve(Re),requestAnimationFrame(()=>{const Ge=Pf.current;Ge&&Ge.scrollTo({top:Ge.scrollTop+(Re?64:-64),behavior:"smooth"})})},[Pf]);w.useLayoutEffect(()=>{const Re=Ge=>{If(0),Rf()};return vi.current=Re,()=>{vi.current===Re&&(vi.current=null)}},[If,Rf,vi]);const ny=w.useCallback(()=>{gt.disconnect(),_f()},[gt.disconnect,_f]),Rn=ZD({dispatch:f,isMobile:c,mobileTab:u.mobileTab,teamContext:Dt,scrollToBottomInstant:In.scrollToBottomInstant,resetTurnCount:In.resetTurnCount,workerParse:p,onBeforeSwitch:ny}),sy=w.useCallback(Re=>{w.startTransition(()=>{f({type:"GO_HOME",isMobile:c}),f({type:"SET_DASHBOARD_PROJECT",dirName:Re})})},[f,c]),{previewLoadError:oy}=sz({state:u,dispatch:f,isMobile:c,resetTurnCount:In.resetTurnCount,scrollToBottomInstant:In.scrollToBottomInstant,workerParse:p}),yi=dz(),$f=yi.push;w.useEffect(()=>{u.sessionSource&&$f(u.sessionSource.dirName,u.sessionSource.fileName)},[u.sessionSource,$f]);const pt=eF({state:{session:u.session,sessionSource:u.sessionSource},dispatch:f,isMobile:c,handleJumpToTurn:Rn.handleJumpToTurn,markPermissionsApplied:Ke.markApplied,hasPermsPendingChanges:Ke.hasPendingChanges,permissionsConfig:Ke.config,selectedModel:Ot,selectedEffort:gi,fastMode:xi,ultracode:bi,mcpConfig:K&&i?on.mcpConfigJson:null,scrollRequestScrollToTop:In.requestScrollToTop,handleDashboardSelect:Rn.handleDashboardSelect,workerParse:p}),{hasSettingsChanges:Mf,handleApplySettings:Lf}=pt,Of=K&&i&&on.mcpConfigJson!==null,Df=w.useRef(!1);w.useEffect(()=>{var $t;const Re=on.loaded&&!Df.current;Df.current=on.loaded;const Ge=($t=u.session)==null?void 0:$t.sessionId;Re&&Ge&&Of&&Mf&&Lf()},[on.loaded,Of,Mf,Lf,(bm=u.session)==null?void 0:bm.sessionId]),w.useLayoutEffect(()=>(ze.current=pt.reloadSession,()=>{ze.current===pt.reloadSession&&(ze.current=null)}),[pt.reloadSession]);const Xn=Mv(u.session,u.sessionSource,pt.reloadSession,a),wi=Xn.requestBranchSwitch,ji=pt.setBranchModalTurn,ry=w.useCallback((Re,Ge)=>{wi(Re,Ge),ji(null)},[wi,ji]),iy=w.useCallback(Re=>{wi(Re),ji(null)},[wi,ji]);iz({isMobile:c,searchInputRef:k,chatInputRef:C,dispatch:f,onToggleSidebar:S.handleToggleSidebar,onToggleRightSidebar:D,onToggleMissionControl:S.handleToggleMission,onOpenCommandPalette:A,onOpenProjectSwitcher:S.handleOpenProjectSwitcher,onOpenThemeSelector:S.handleToggleThemeSelector,onOpenTerminal:se,onToggleIntegratedTerminal:ae,onTogglePreview:me,onToggleProjectFiles:de,onHistoryBack:yi.goBack,onHistoryForward:yi.goForward,onNavigateToSession:Rn.handleDashboardSelect,onCommitNavigation:yi.commitNavigation});const{killing:ay,handleKillAll:ly}=Bz(),fs=u.sessionSource?Cs(u.sessionSource.fileName):null,cy=fs!==null&&!!(Dt!=null&&Dt.currentMemberName),Sl=fs!==null&&!cy,Si=Rn.handleDashboardSelect,zf=w.useCallback(()=>{!u.sessionSource||!fs||Si(u.sessionSource.dirName,fs.parentFileName)},[u.sessionSource,fs,Si]);w.useEffect(()=>{const Re=Ge=>{const{agentId:$t}=Ge.detail??{};if(!$t||!u.sessionSource||!U.subagentTranscripts)return;const Jn=fs?fs.parentSessionId:Tc(u.sessionSource.fileName);Si(u.sessionSource.dirName,`${Jn}/subagents/agent-${$t}.jsonl`)};return window.addEventListener(ya,Re),()=>window.removeEventListener(ya,Re)},[u.sessionSource,fs,Si,U.subagentTranscripts]);const[dy,Ff]=w.useState(null),uy=pt.branchModalTurn!==null,Qs=pt.branchModalTurn??dy;w.useEffect(()=>{pt.branchModalTurn!==null&&Ff(pt.branchModalTurn)},[pt.branchModalTurn]);const Bf=Qs!==null?Xn.branchesAtTurn(Qs):[],fy=Sl?r.jsxs("div",{className:"flex shrink-0 items-center justify-center gap-2 border-t bg-card px-4 py-2.5",children:[r.jsx(No,{"data-icon":"inline-start",className:"size-3.5 text-muted-foreground"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:"Viewing sub-agent session (read-only)"})]}):null,my=W?r.jsxs("div",{role:"status",className:"flex shrink-0 items-center justify-center gap-2 border-t bg-card px-4 py-2.5",children:[r.jsx(No,{"data-icon":"inline-start",className:"size-3.5 text-muted-foreground"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:W4(L)})]}):null,Nl=fy||my,py=Rn.loadError||Cf||null;let kl;Rn.loadError?kl=Rn.clearLoadError:Cf&&(kl=Yv);const hy=!!(u.session&&u.sessionSource&&we==="disconnected"),Cl=w.useMemo(()=>({state:u,dispatch:f,config:e,theme:d,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,c]),_l=w.useMemo(()=>({session:u.session,sessionSource:u.sessionSource,isLive:fe,sseState:we,isCompacting:Ue,turnError:Ae,promptSuggestion:ht,undoRedo:Xn,pendingInteraction:sn,permissionRequests:At.requests,permissionResponding:At.responding,respondPermission:At.respond,respondAllPermissions:At.respondAll,isSubAgentView:Sl,slashSuggestions:Y.suggestions,slashSuggestionsLoading:Y.loading,actions:{handleStopSession:pt.handleStopSession,handleEditConfig:i?S.handleEditConfig:void 0,handleEditCommand:i?X:void 0,handleExpandCommand:i?G:void 0,handleOpenBranches:pt.handleOpenBranches,handleBranchFromHere:pt.handleBranchFromHere,handleToggleExpandAll:_,handleLoadSession:pt.handleLoadSessionScrollAware}}),[u.session,u.sessionSource,fe,we,Ue,Ae,ht,Xn,sn,Sl,At.requests,At.responding,At.respond,At.respondAll,Y.suggestions,Y.loading,pt.handleStopSession,i,S.handleEditConfig,X,G,pt.handleOpenBranches,pt.handleBranchFromHere,_,pt.handleLoadSessionScrollAware]),Tl=w.useMemo(()=>({chat:{status:gt.status,error:gt.error,pendingMessages:gt.pendingMessages,isConnected:gt.isConnected,sendMessage:gt.sendMessage,interrupt:gt.interrupt,stopAgent:gt.stopAgent,consumePending:gt.consumePending},scroll:In}),[gt.status,gt.error,gt.pendingMessages,gt.isConnected,gt.sendMessage,gt.interrupt,gt.stopAgent,gt.consumePending,In]),Go=!!u.pendingDirName&&!u.session;if(w.useEffect(()=>{if(!Go||c)return;const Re=requestAnimationFrame(()=>{var Ge;return(Ge=C.current)==null?void 0:Ge.focus()});return()=>cancelAnimationFrame(Re)},[Go,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(et,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(!t.authenticated)return t.needsBootstrap?r.jsx(TF,{onAuthenticated:t.handleAuthenticated,onBootstrapClosed:t.refreshServerState}):r.jsx(CF,{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(et,{"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(et,{"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(Kt,{children:[r.jsxs(Vt,{children:[r.jsx(en,{variant:"icon",children:r.jsx(mn,{className:"text-destructive"})}),r.jsx(Gt,{children:"Failed to connect"}),r.jsx(tn,{children:e.configError})]}),r.jsx(mg,{children:r.jsxs(ee,{variant:"outline",size:"sm",onClick:e.retryConfig,children:[r.jsx(Pt,{"data-icon":"inline-start"}),"Retry"]})})]})});if(!e.claudeDir)return i?r.jsx(ZN,{onConfigured:e.setClaudeDir}):r.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-background text-sm text-muted-foreground",children:"Cogpit is waiting for an administrator to finish server setup."});const El=r.jsx(n4,{activeError:py,clearActiveError:kl,modelFallbackNotice:Vv,dismissModelFallbackNotice:Gv,connectionLost:hy,theme:d.activeTheme}),Uf=a?r.jsx(HN,{state:Xn.confirmState,isApplying:Xn.isApplying,applyError:Xn.applyError,onConfirm:Xn.confirmApply,onCancel:Xn.confirmCancel}):null,gy=Qs!==null&&u.session?u.session.turns.slice(Qs):[],Wf=a&&Qs!==null&&Bf.length>0&&r.jsx(w.Suspense,{fallback:null,children:r.jsx(PF,{open:uy,branches:Bf,branchPointTurnIndex:Qs,currentTurns:gy,onClose:pt.handleCloseBranchModal,onCloseComplete:()=>Ff(null),onRedoToTurn:ry,onRedoEntireBranch:iy})}),Hf=l&&r.jsx(RN,{processes:J.processes,activeProcessId:J.activeProcessId,collapsed:J.collapsed,onSetActive:J.setActive,onRemove:J.removeProcess,onToggleCollapse:J.toggleCollapse,onRequestTerminal:st("terminal")?ue:void 0,onAddTerminalContext:Re=>{var vm,ym,wm;const Ge=Re.trim();if(!Ge)return;const $t=Ge.includes("```")?"````":"```",Jn=`${$t}terminal
148
+ ${Ge}
149
+ ${$t}`,Al=((vm=C.current)==null?void 0:vm.getText().trimEnd())??"";(ym=C.current)==null||ym.setText(Al?`${Al}
150
+
151
+ ${Jn}
152
+ `:`${Jn}
153
+ `),(wm=C.current)==null||wm.focus()},onUpdateStatus:J.updateProcessStatus,projectDir:Z,onProcessStarted:J.addProcess,mobile:c}),qf=Dt&&r.jsx(N5,{teamName:Dt.config.name||Dt.teamName,members:Dt.config.members,currentMemberName:u.currentMemberName,loadingMember:u.loadingMember,onMemberClick:Rn.handleTeamMemberSwitch}),Kf=he&&r.jsx(w.Suspense,{fallback:null,children:r.jsx(IF,{open:S.showWorkflows,onOpenChange:S.setShowWorkflows,dirName:De.dirName,sessionId:De.sessionId,workflows:Ie.workflows,isLive:Ie.isLive,onRefetchList:Ie.refetch},`${De.dirName??""}:${De.sessionId??""}`)}),Ni=U.goals?u.session:null,Vf=Re=>{var Ge;return r.jsx(y5,{agentKind:L,onAgentKindChange:Go?Zv:void 0,selectedModel:Ot,onModelChange:Pn,selectedEffort:gi,onEffortChange:Vo,fastModeEnabled:xi,onFastModeEnabledChange:qv?wl:void 0,isNewSession:Go,worktreeEnabled:Jv,onWorktreeEnabledChange:Go&&V?Qv:void 0,ultracodeEnabled:bi,onUltracodeEnabledChange:Kv?jl:void 0,onApplySettings:pt.handleApplySettings,activeModelId:(Ge=u.session)==null?void 0:Ge.model,mcpServers:K&&i?on.servers:void 0,selectedMcpServers:K&&i?on.selectedServers:void 0,onToggleMcpServer:K&&i?on.toggleServer:void 0,onSetMcpServers:K&&i?on.setSelection:void 0,onRefreshMcpServers:K&&i?on.refresh:void 0,mcpLoading:K&&i?on.loading:void 0,onMcpAuth:K&&i?ce:void 0,permissionMode:Ke.config.mode,onPermissionModeChange:Ke.setMode,mobileExtra:c&&Re&&Ni?r.jsx(lN,{}):void 0,trailingExtra:!c&&Re&&Ni?r.jsx(nx,{}):void 0,mobile:c})},Gf=Vf(!0),Yf=Vf(!1),Xf=r.jsxs("div",{className:q("shrink-0",c&&"bg-background"),children:[!c&&r.jsx(tx,{}),r.jsx(Wc,{ref:C,allowImages:jf,agentKind:L,projectCwd:Z,compact:c,leadingAccessory:c?Gf:void 0,footer:c?void 0:Gf})]}),ki=Ni?r.jsx(aN,{agentKind:L,session:Ni,onSendCommand:gt.sendMessage,children:Xf}):Xf,xy=r.jsx("div",{className:q("shrink-0",c&&"bg-background"),children:r.jsx(Wc,{ref:C,allowImages:jf,agentKind:L,projectCwd:Z,compact:c,leadingAccessory:c?Yf:void 0,footer:c?void 0:Yf})}),Jf=gt.pendingMessages.map((Re,Ge)=>r.jsx(q0,{message:Re,turnNumber:Ge+1},Ge)),by=c?u.mobileTab==="stats":S.activeWorkspacePanel===St.sessionInfo,Qf=u.session&&!by&&r.jsx("div",{className:"hidden",children:r.jsx(cx,{cwd:u.session.cwd,turns:u.session.turns,onServersChanged:J.handleServersChanged})});return n?r.jsxs(ea,{value:Cl,children:[r.jsx(Ll,{children:r.jsx(Ji,{value:_l,chatValue:Tl,children:r.jsx(Gl,{value:Be,agentProgress:qe,children:r.jsx(FD,{sessionId:n,loadError:oy,searchInputRef:k,activeComposer:Nl||xy,hasMoreTurns:v.hasMore,isLoadingOlderTurns:v.isLoadingOlder,onLoadMoreTurns:v.loadMore})})})}),El]}):c?r.jsxs(ea,{value:Cl,children:[r.jsx(Ll,{enabled:l,children:r.jsx(Ji,{value:_l,chatValue:Tl,children:r.jsx(Gl,{value:Be,agentProgress:qe,children:r.jsx(zD,{navigation:{actions:Rn,handlers:pt,creatingSession:kf,pendingSession:Ef,onStartNewSession:Af,onSelectProject:z,liveSessionsRefreshRef:Tf,onPrefetchSession:x},sessionView:{searchInputRef:k,teamMembersBar:qf,activeComposer:Nl||ki,pendingComposer:ki,pendingTurns:Jf,todoProgress:xe&&r.jsx(K0,{progress:xe}),hasMoreTurns:v.hasMore,isLoadingOlderTurns:v.isLoadingOlder,onLoadMoreTurns:v.loadMore,onBackToMain:zf,onShowWorkflows:be,onToggleExpandAll:_,workflowCount:ge,pendingPath:F},project:{processPanel:J,backgroundAgents:Je,hasFileChanges:a&&Me,onOpenTerminal:se},chrome:{backgroundServers:Qf,processPanel:Hf,workflowsPanel:Kf,undoDialog:Uf,branchModal:Wf,fileChangesOpen:Fe,onFileChangesOpenChange:He}})})})}),El]}):r.jsxs(ea,{value:Cl,children:[r.jsx(Ll,{enabled:l,children:r.jsx(Ji,{value:_l,chatValue:Tl,children:r.jsx(Gl,{value:Be,agentProgress:qe,children:r.jsx(ED,{navigation:{panels:S,actions:Rn,handlers:pt,creatingSession:kf,pendingSession:Ef,onStartNewSession:Af,onStartNewFolder:ey,onSelectProject:z,onOpenPaletteProject:sy,liveSessionsRefreshRef:Tf,onPrefetchSession:x},sessionView:{searchInputRef:k,chatInputRef:C,teamMembersBar:qf,activeComposer:Nl||ki,pendingComposer:ki,pendingTurns:Jf,todoProgress:xe,todosExpanded:pe,onTodosExpandedChange:ty,hasMoreTurns:v.hasMore,isLoadingOlderTurns:v.isLoadingOlder,onLoadMoreTurns:v.loadMore,onBackToMain:zf,onShowWorkflows:be,workflowCount:ge},project:{processPanel:J,worktrees:ke,backgroundAgents:Je,supportsWorktrees:V,hasFileChanges:a&&Me,currentCwd:Z,showPreview:Q,showProjectFiles:a&&te,projectFilesRoot:ne,projectFilesRequest:oe,launchTerminalRequest:re,pendingProject:ie,onOpenTerminal:se,onTogglePreview:me,onToggleProjectFiles:de,onCloseRightWorkspace:le},chrome:{backgroundServers:Qf,processPanel:Hf,workflowsPanel:Kf,undoDialog:Uf,branchModal:Wf,killing:ay,onKillAll:ly,commandPaletteOpen:N,onCommandPaletteOpenChange:E,onOpenCommandPalette:A,onFocusComposer:I,onExpandAll:$,onExpandToolPayloads:R,onCollapseAll:M,keyboardShortcutsOpen:T,onKeyboardShortcutsOpenChange:P}})})})}),El]})}function $F(){var y;const[n,e]=w.useState(xt),[t,s]=w.useState(()=>Xi(xt())),[o,i]=w.useState(Ns),[a,l]=w.useState(0),[c,d]=w.useState(!1),[u,f]=w.useState(!1),[m,p]=w.useState(!1),{devices:h,testDevice:g}=ul();w.useEffect(()=>{const b=()=>{const j=xt();e(S=>S===j?S:j),s(Xi(j))};return window.addEventListener("cogpit-device-changed",b),window.addEventListener("popstate",b),()=>{window.removeEventListener("cogpit-device-changed",b),window.removeEventListener("popstate",b)}},[]),w.useEffect(()=>{const b=j=>{const S=j.detail;(S==null?void 0:S.deviceId)===xt()&&s(Xi(S.deviceId))};return window.addEventListener("cogpit-device-scope-changed",b),()=>window.removeEventListener("cogpit-device-scope-changed",b)},[]),w.useEffect(()=>{const b=()=>i(Ns());return window.addEventListener("cogpit-identity-changed",b),()=>window.removeEventListener("cogpit-identity-changed",b)},[]),w.useEffect(()=>(window.__cogpitRevealSession=fb,()=>{delete window.__cogpitRevealSession}),[]),w.useEffect(()=>{const b=j=>{const S=[Tt,...h.map(E=>E.id)],k=xt();let C;const N=UA(j);if(N!==null)C=S[N-1];else if(WA(j)){const E=S.indexOf(k);C=S[(E+1)%S.length]}!C||C===k||(j.preventDefault(),ks(C))};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[h]),w.useEffect(()=>{const b=j=>{const S=j.detail;!(S!=null&&S.deviceId)||S.deviceId!==xt()||(d(!0),S.reason==="DEVICE_AUTH_FAILED"&&f(!0))};return window.addEventListener("cogpit-device-unreachable",b),()=>window.removeEventListener("cogpit-device-unreachable",b)},[]),w.useEffect(()=>{d(!1),f(!1),p(!1)},[n,t]);const x=w.useCallback(async()=>{p(!0);try{const b=await g(n);b.reachable&&b.authState==="bad-password"?f(!0):b.ok&&(d(!1),f(!1),l(j=>j+1))}finally{p(!1)}},[n,g]);w.useEffect(()=>{if(!c||u)return;const b=setInterval(()=>void x(),1e4);return()=>clearInterval(b)},[c,u,x]);const v=((y=h.find(b=>b.id===n))==null?void 0:y.name)??n;return r.jsxs(r.Fragment,{children:[c&&n!==Tt&&r.jsxs(ut,{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(qw,{"data-icon":"inline-start",className:"text-warning"}),r.jsx(Et,{children:u?"Device credentials need attention":"Remote device unavailable"}),r.jsx(ft,{children:u?`${v} rejected the stored password. Update it in Devices.`:`Can’t reach ${v}. Cogpit will keep retrying.`}),r.jsxs("div",{className:"col-start-2 mt-2 flex flex-wrap gap-2",children:[!u&&r.jsxs(ee,{variant:"outline",size:"xs",onClick:()=>void x(),disabled:m,children:[m&&r.jsx(et,{"data-icon":"inline-start",className:"animate-spin"}),m?"Retrying":"Retry now"]}),r.jsx(ee,{variant:"outline",size:"xs",onClick:()=>ks(Tt),children:"Switch to this machine"})]})]}),r.jsx(h8,{children:r.jsx(CO,{children:r.jsx(RF,{})})},`${n}:${t}:${a}:${o??""}`)]})}const _1="Invalid link or passphrase.";function MF(n,e){return n===401?_1: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||_1}function LF({sessionId:n,onAuthenticated:e}){const[t,s]=w.useState(""),[o,i]=w.useState(!1),[a,l]=w.useState(null),[c,d]=w.useState(!1),u=w.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(MF(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(ln,{children:[r.jsxs(xn,{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(An,{className:"size-4"})}),r.jsx(bn,{children:"Join this session"}),r.jsx(vn,{children:"Enter the passphrase you were given to join the shared session."})]}),r.jsxs(cn,{className:"flex flex-col gap-4",children:[r.jsx(Do,{children:r.jsxs(yt,{children:[r.jsx(wt,{htmlFor:"share-passphrase",children:"Passphrase"}),r.jsxs(ds,{children:[r.jsx(us,{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(En,{align:"inline-end",children:r.jsx(ei,{size:"icon-xs",onClick:()=>i(f=>!f),"aria-label":o?"Hide passphrase":"Show passphrase",children:o?r.jsx(Aa,{}):r.jsx(js,{})})})]})]})}),a&&r.jsxs(ut,{variant:"destructive",children:[r.jsx(Xt,{"aria-hidden":"true"}),r.jsx(Et,{children:"Could not join"}),r.jsx(ft,{children:a})]})]}),r.jsx(Zr,{children:r.jsxs(ee,{type:"submit",className:"w-full",disabled:c||!t.trim(),children:[c&&r.jsx(nt,{"data-icon":"inline-start"}),"Connect"]})})]})})})}function OF(){const n=B.c(9),[e,t]=w.useState("idle"),[s,o]=w.useState();let i;n[0]===Symbol.for("react.memo_cache_sentinel")?(i=[],n[0]=i):i=n[0];const[a,l]=w.useState(i);let c;n[1]===Symbol.for("react.memo_cache_sentinel")?(c=(x,v)=>{l(y=>[...y,x]),t("connected"),o(void 0),LS(x,v).then(y=>{if(y.ok){t("idle");return}o(`Request failed (${y.status})`),t("error"),l(FF)}).catch(y=>{o(y instanceof Error?y.message:"Unknown error"),t("error"),l(zF)})},n[1]=c):c=n[1];const d=c;let u;n[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{OS().catch(DF),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 v=x===void 0?1:x;l(y=>y.slice(v))},n[3]=m):m=n[3];const p=m,h=e==="connected";let g;return n[4]!==s||n[5]!==a||n[6]!==e||n[7]!==h?(g={status:e,error:s,pendingMessages:a,isConnected:h,sendMessage:d,interrupt: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 DF(){}function zF(n){return n.slice(0,-1)}function FF(n){return n.slice(0,-1)}const BF=2e3;function UF(n,e){return n.length!==e.length?!1:JSON.stringify(n)===JSON.stringify(e)}function WF(){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]=w.useState(e);let o;n[1]===Symbol.for("react.memo_cache_sentinel")?(o=new Set,n[1]=o):o=n[1];const[i,a]=w.useState(o);let l,c;n[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{let h=!1;const g=async()=>{const y=await BS();h||y===null||s(b=>UF(b,y)?b:y)},x=()=>{document.visibilityState==="visible"&&g()};x();const v=setInterval(x,BF);return document.addEventListener("visibilitychange",x),()=>{h=!0,clearInterval(v),document.removeEventListener("visibilitychange",x)}},c=[],n[2]=l,n[3]=c):(l=n[2],c=n[3]),w.useEffect(l,c);let d;n[4]===Symbol.for("react.memo_cache_sentinel")?(d=(h,g)=>{a(x=>new Set(x).add(h)),zS(h,g).then(x=>{x&&s(v=>v.filter(y=>y.requestId!==h))}).finally(()=>{a(x=>{const v=new Set(x);return v.delete(h),v})})},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 HF={capabilities:Yr};function qF(n){var ae,ue;const e=B.c(77),{info:t,children:s}=n,o=xf(),i=Cv(),[a,l]=yv(),{parse:c,append:d}=Dv(),[u,f]=w.useState("loading");let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=[],e[0]=m):m=e[0],w.useEffect(YF,m);const p=OF(),h=WF();let g;e[1]!==l||e[2]!==t.dirName||e[3]!==t.fileName||e[4]!==o||e[5]!==c?(g=async()=>{try{const{parsed:me,source:de}=await Sv(t.dirName,t.fileName,c,"shared session");l({type:"LOAD_SESSION",session:me,source:de,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,v=w.useRef(!1);let y,b;e[7]!==x?(y=()=>{v.current||(v.current=!0,x())},b=[x],e[7]=x,e[8]=y,e[9]=b):(y=e[8],b=e[9]),w.useEffect(y,b);let j;e[10]!==l?(j=me=>{l({type:"UPDATE_SESSION",session:me})},e[10]=l,e[11]=j):j=e[11];const S=j,{isLive:k,sseState:C,isCompacting:N,turnError:E}=xv(a.sessionSource,S,c,d,void 0,a.session);let T;e[12]!==l?(T=me=>{l({type:"SET_OLDER_TURNS",turns:me})},e[12]=l,e[13]=T):T=e[13];const P=T,_=((ae=a.sessionSource)==null?void 0:ae.dirName)??null,A=((ue=a.sessionSource)==null?void 0:ue.fileName)??null;let I;e[14]!==P||e[15]!==a.sessionChangeKey||e[16]!==_||e[17]!==A||e[18]!==c?(I={dirName:_,fileName:A,sessionChangeKey:a.sessionChangeKey,workerParse:c,onOlderTurns:P},e[14]=P,e[15]=a.sessionChangeKey,e[16]=_,e[17]=A,e[18]=c,e[19]=I):I=e[19];const $=zv(I);let R;e[20]!==p.consumePending||e[21]!==p.pendingMessages||e[22]!==k||e[23]!==a.session||e[24]!==a.sessionChangeKey?(R={session:a.session,isLive:k,pendingMessages:p.pendingMessages,consumePending:p.consumePending,sessionChangeKey:a.sessionChangeKey},e[20]=p.consumePending,e[21]=p.pendingMessages,e[22]=k,e[23]=a.session,e[24]=a.sessionChangeKey,e[25]=R):R=e[25];const M=wv(R),O=Mv(a.session,a.sessionSource,x,!1);let D;e[26]!==a.session?(D=a.session?R0(a.session):null,e[26]=a.session,e[27]=D):D=e[27];const z=D;let F;e[28]!==l?(F=()=>{l({type:"TOGGLE_EXPAND_ALL"})},e[28]=l,e[29]=F):F=e[29];const L=F,H=VF,U=KF;let W;e[30]!==t.dirName?(W=It(t.dirName),e[30]=t.dirName,e[31]=W):W=e[31];let V;e[32]!==W?(V={configLoading:!1,configError:null,claudeDir:null,defaultAgentKind:W,setClaudeDir:U,showConfigDialog:!1,openConfigDialog:U,handleCloseConfigDialog:U,handleConfigSaved:U,retryConfig:U,networkUrl:null,networkAccessDisabled:!1},e[32]=W,e[33]=V):V=e[33];let K;e[34]!==l||e[35]!==o||e[36]!==a||e[37]!==V||e[38]!==i?(K={state:a,dispatch:l,config:V,theme:i,isMobile:o},e[34]=l,e[35]=o,e[36]=a,e[37]=V,e[38]=i,e[39]=K):K=e[39];const Y=K;let X;e[40]===Symbol.for("react.memo_cache_sentinel")?(X=[],e[40]=X):X=e[40];let G;e[41]!==L?(G={handleStopSession:H,handleOpenBranches:U,handleBranchFromHere:U,handleToggleExpandAll:L,handleLoadSession:U},e[41]=L,e[42]=G):G=e[42];let J;e[43]!==N||e[44]!==k||e[45]!==z||e[46]!==h.requests||e[47]!==h.respond||e[48]!==h.respondAll||e[49]!==h.responding||e[50]!==C||e[51]!==a.session||e[52]!==a.sessionSource||e[53]!==G||e[54]!==E||e[55]!==O?(J={session:a.session,sessionSource:a.sessionSource,isLive:k,sseState:C,isCompacting:N,turnError:E,undoRedo:O,pendingInteraction:z,permissionRequests:h.requests,permissionResponding:h.responding,respondPermission:h.respond,respondAllPermissions:h.respondAll,isSubAgentView:!1,slashSuggestions:X,slashSuggestionsLoading:!1,promptSuggestion:null,actions:G},e[43]=N,e[44]=k,e[45]=z,e[46]=h.requests,e[47]=h.respond,e[48]=h.respondAll,e[49]=h.responding,e[50]=C,e[51]=a.session,e[52]=a.sessionSource,e[53]=G,e[54]=E,e[55]=O,e[56]=J):J=e[56];const Z=J;let Q;e[57]!==p||e[58]!==M?(Q={chat:p,scroll:M},e[57]=p,e[58]=M,e[59]=Q):Q=e[59];const te=Q;let ne;e[60]!==$?(ne=()=>{$.loadMore()},e[60]=$,e[61]=ne):ne=e[61];let oe;e[62]!==u||e[63]!==$.hasMore||e[64]!==$.isLoadingOlder||e[65]!==ne?(oe={loadState:u,hasMore:$.hasMore,isLoadingOlder:$.isLoadingOlder,loadMore:ne},e[62]=u,e[63]=$.hasMore,e[64]=$.isLoadingOlder,e[65]=ne,e[66]=oe):oe=e[66];const re=oe;let ie;e[67]!==s||e[68]!==re?(ie=s(re),e[67]=s,e[68]=re,e[69]=ie):ie=e[69];let se;e[70]!==te||e[71]!==Z||e[72]!==ie?(se=r.jsx(Ji,{value:Z,chatValue:te,children:ie}),e[70]=te,e[71]=Z,e[72]=ie,e[73]=se):se=e[73];let ce;return e[74]!==Y||e[75]!==se?(ce=r.jsx(ea,{value:Y,children:se}),e[74]=Y,e[75]=se,e[76]=ce):ce=e[76],ce}function KF(){}async function VF(){await DS().catch(GF)}function GF(){}function YF(){po(HF)}function XF(n){const e=B.c(6),{info:t}=n,s=w.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(An,{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(ut,{variant:"destructive",className:"max-w-sm",children:[r.jsx(Xt,{"aria-hidden":"true"}),r.jsx(Et,{children:"Session unavailable"}),r.jsx(ft,{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(nt,{className:"size-5 text-muted-foreground"})}):r.jsxs(r.Fragment,{children:[r.jsx(dl,{searchInputRef:s,hasMore:a.hasMore,isLoadingOlder:a.isLoadingOlder,onLoadMore:a.loadMore}),r.jsx(bl,{children:r.jsx(Wc,{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(qF,{info:t,children:o}),e[3]=t,e[4]=o,e[5]=i):i=e[5],i}function jc(n){const e=B.c(2),{children:t}=n;let s;return e[0]!==t?(s=r.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-4 py-8",children:r.jsx("div",{className:"w-full max-w-sm",children:t})}),e[0]=t,e[1]=s):s=e[1],s}function JF(){const n=B.c(19);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=Yg(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]=w.useState(s);let a;n[2]===Symbol.for("react.memo_cache_sentinel")?(a=async()=>{i({kind:"probing"});const p=await MS();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]),w.useEffect(c,d);let u,f;if(n[5]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{const p=()=>{i(QF)};return window.addEventListener(Uc,p),window.addEventListener("cogpit-auth-required",p),()=>{window.removeEventListener(Uc,p),window.removeEventListener("cogpit-auth-required",p)}},f=[],n[5]=u,n[6]=f):(u=n[5],f=n[6]),w.useEffect(u,f),o.kind==="ready"){let p;return n[7]!==o.info?(p=r.jsx(XF,{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(LF,{sessionId:t,onAuthenticated:()=>void l()}),n[9]=p):p=n[9],p}if(o.kind==="ended"){let p;return n[10]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(jc,{children:r.jsx(ln,{children:r.jsxs(xn,{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(Kw,{className:"size-4"})}),r.jsx(bn,{children:"Sharing has ended"}),r.jsx(vn,{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(Xt,{"aria-hidden":"true"}),h=r.jsx(Et,{children:"Could not open this session"}),n[11]=p,n[12]=h):(p=n[11],h=n[12]);let g;n[13]!==o.message?(g=r.jsxs(ut,{variant:"destructive",children:[p,h,r.jsx(ft,{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 v;return n[16]!==g?(v=r.jsxs(jc,{children:[g,x]}),n[16]=g,n[17]=v):v=n[17],v}let m;return n[18]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(jc,{children:r.jsx(ln,{children:r.jsxs(cn,{className:"flex min-h-24 items-center justify-center gap-2",role:"status","aria-label":"Opening shared session",children:[r.jsx(An,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),r.jsx(nt,{className:"size-5 text-muted-foreground"})]})})}),n[18]=m):m=n[18],m}function QF(n){return n.kind==="ready"?{kind:"ended"}:n}class ZF extends w.Component{constructor(){super(...arguments);Ci(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(ln,{className:"w-full max-w-lg text-center",children:[r.jsxs(xn,{className:"justify-items-center",children:[r.jsx(mn,{"aria-hidden":"true",className:"mb-2 size-8 text-destructive"}),r.jsx(bn,{children:r.jsx("h1",{children:"Cogpit hit a render error"})}),r.jsx(vn,{children:"Reload the app to recover. Your sessions and project files are unchanged."})]}),r.jsx(cn,{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(Zr,{className:"justify-center",children:r.jsxs(ee,{onClick:()=>window.location.reload(),children:[r.jsx(Pt,{"data-icon":"inline-start"}),"Reload Cogpit"]})})]})})}}const Uv=document.getElementById("root");if(!Uv)throw new Error("Root element not found");Sy.createRoot(Uv).render(r.jsx(w.StrictMode,{children:r.jsx(ZF,{children:Ha(window.location.pathname)?r.jsx(JF,{}):r.jsx($F,{})})}));export{Jt as $,ut as A,ee as B,Q5 as C,is as D,Kt as E,TE as F,Gt as G,tn as H,En as I,la as J,cl as K,rB as L,Da as M,Jd as N,aa as O,Xd as P,jt as Q,lj as R,m5 as S,ul as T,Do as U,yt as V,ei as W,vs as X,w9 as Y,j9 as Z,q as _,p5 as a,an as a$,ti as a0,Sx as a1,ak as a2,Tn as a3,Pe as a4,Oo as a5,ct as a6,Rt as a7,Eo as a8,dt as a9,Jc as aA,td as aB,Fu as aC,Yn as aD,qa as aE,Hg as aF,Ho as aG,xn as aH,bn as aI,cn as aJ,Zr as aK,ln as aL,nl as aM,YS as aN,D0 as aO,ss as aP,lt as aQ,Un as aR,Et as aS,vn as aT,qN as aU,Jr as aV,KD as aW,Ua as aX,wt as aY,Co as aZ,nI as a_,nu as aa,su as ab,ou as ac,BN as ad,iu as ae,au as af,ru as ag,cu as ah,lu as ai,On as aj,ec as ak,FA as al,nt as am,eS as an,cB as ao,tu as ap,Ws as aq,st as ar,fu as as,xx as at,bx as au,$a as av,wB as aw,pE as ax,IS as ay,Gn as az,h5 as b,aB as b0,Mt as b1,tc as b2,YN as b3,Ra as b4,dx as b5,iB as b6,kt as b7,Ct as b8,_t as b9,Bt as bA,Bo as bB,uB as bC,dB as bD,ca as bE,Uo as bF,Fo as bG,N4 as bH,lB as bI,LL as bJ,il as ba,al as bb,ll as bc,Bs as bd,mB as be,Wt as bf,Ao as bg,DN as bh,it as bi,Q4 as bj,fB as bk,ii as bl,a2 as bm,$u as bn,ha as bo,Ys as bp,p2 as bq,_O as br,Jb as bs,Wo as bt,Ts as bu,Iu as bv,gg as bw,Os as bx,hg as by,mg as bz,f5 as c,a5 as d,pB as e,zA as f,hB as g,as as h,Rs as i,ls as j,cs as k,Nt as l,ds as m,us as n,bB as o,ft as p,Vn as q,xB as r,vB as s,yB as t,gB as u,iv as v,Ne as w,Z5 as x,Vt as y,en as z};