codesesh 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/dist/{chunk-GCOAE7KI.js → chunk-BV65IEWZ.js} +368 -179
- package/dist/chunk-BV65IEWZ.js.map +1 -0
- package/dist/{dist-TZTL6VP4.js → dist-VD54GDPO.js} +10 -2
- package/dist/index.js +949 -510
- package/dist/index.js.map +1 -1
- package/dist/scan-refresh-worker.js +1 -1
- package/dist/search-index-worker.js +1 -1
- package/dist/smart-tag-worker.js +1 -1
- package/dist/web/assets/index-ZikfLnUo.js +113 -0
- package/dist/web/assets/index-y6Zx3LT1.css +2 -0
- package/dist/web/assets/markdown-dR4kAewZ.js +14 -0
- package/dist/web/assets/react-DBHwgW7V.js +1821 -0
- package/dist/web/assets/syntax-C_RLNYQn.js +6 -0
- package/dist/web/assets/vendor-bXsb4Kz4.js +40 -0
- package/dist/web/index.html +6 -6
- package/package.json +9 -8
- package/dist/chunk-GCOAE7KI.js.map +0 -1
- package/dist/web/assets/index-D05hsCzb.css +0 -2
- package/dist/web/assets/index-DOy8q3la.js +0 -113
- package/dist/web/assets/markdown-CGVJZBE7.js +0 -14
- package/dist/web/assets/react-DkEeEGji.js +0 -1821
- package/dist/web/assets/syntax-CFQ-7fm6.js +0 -6
- package/dist/web/assets/vendor-B2nLfkMs.js +0 -80
- /package/dist/{dist-TZTL6VP4.js.map → dist-VD54GDPO.js.map} +0 -0
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{r as t,t as n,u as r}from"./markdown-CGVJZBE7.js";import{n as i,r as a,t as o}from"./react-DkEeEGji.js";import{A as s,B as c,C as l,D as u,E as d,F as f,G as p,H as m,I as h,K as g,L as _,M as v,N as y,O as ee,P as b,R as x,S,T as te,U as ne,V as re,W as C,_ as ie,a as ae,b as oe,c as se,d as w,f as T,g as E,h as ce,i as le,j as ue,k as D,l as de,m as fe,n as pe,o as me,p as O,r as he,s as ge,t as _e,u as ve,v as k,w as ye,x as be,y as xe,z as Se}from"./vendor-B2nLfkMs.js";import{C as A,S as Ce,_ as we,a as Te,b as j,c as Ee,d as De,f as Oe,g as ke,h as Ae,i as M,l as je,m as Me,n as Ne,o as Pe,p as Fe,r as Ie,s as Le,t as Re,u as ze,v as Be,x as Ve,y as He}from"./syntax-CFQ-7fm6.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var N=e(r(),1),Ue=e(a(),1);async function P(e,t){let n=await fetch(e,t);if(!n.ok){let r=t?.method??`GET`;throw Error(`${r} ${e} failed: ${n.status} ${n.statusText}`)}return n.json()}async function We(){return P(`/api/config`)}async function Ge(){return P(`/api/status`)}async function Ke(){return P(`/api/agents`)}async function qe(){return P(`/api/projects`)}async function F(e={}){let t=new URLSearchParams;return e.agent&&t.set(`agent`,e.agent),e.projectKey&&t.set(`projectKey`,e.projectKey),e.from!=null&&t.set(`from`,new Date(e.from).toISOString()),e.to!=null&&t.set(`to`,new Date(e.to).toISOString()),P(`/api/sessions?${t}`)}async function Je(e,t){return P(`/api/sessions/${e}/${t}`)}async function Ye(e,t={}){let n=new URLSearchParams;e?.from!=null&&n.set(`from`,new Date(e.from).toISOString()),e?.to!=null&&n.set(`to`,new Date(e.to).toISOString()),e?.days!=null&&e.days>0&&n.set(`days`,String(e.days)),t.projectKind&&n.set(`projectKind`,t.projectKind),t.projectKey&&n.set(`projectKey`,t.projectKey),t.agent&&n.set(`agent`,t.agent);let r=n.toString();return P(r?`/api/dashboard?${r}`:`/api/dashboard`)}async function Xe(e,t={}){let n=new URLSearchParams;return n.set(`q`,e),t.agent&&n.set(`agent`,t.agent),t.projectKey&&n.set(`projectKey`,t.projectKey),t.tag&&n.set(`tag`,t.tag),t.tool&&n.set(`tool`,t.tool),t.fileKind&&n.set(`fileActivity`,t.fileKind),t.costMin!=null&&n.set(`costMin`,String(t.costMin)),t.costMax!=null&&n.set(`costMax`,String(t.costMax)),P(`/api/search?${n}`)}async function Ze(){return P(`/api/bookmarks`)}async function Qe(e){return P(`/api/bookmarks`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})}async function $e(e){return P(`/api/bookmarks/import`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})}async function et(e,t){await P(`/api/bookmarks/${e}/${t}`,{method:`DELETE`})}function I(e,t={}){let n=JSON.stringify({event:e,data:t});try{if(typeof navigator<`u`&&navigator.sendBeacon){let e=new Blob([n],{type:`application/json`});if(navigator.sendBeacon(`/api/logs`,e))return}}catch{}fetch(`/api/logs`,{method:`POST`,headers:{"Content-Type":`application/json`},body:n,keepalive:!0}).catch(()=>{})}var tt=1e3,nt=3e4;function rt(e){let t=e*.2;return e+(Math.random()*2-1)*t}function it(e,t,n,r){let i=!1,a,o=tt,s=!1,c=!1,l,u=()=>{let d=new EventSource(`/api/events`);l=d,d.addEventListener(`sessions-updated`,t=>{try{e(JSON.parse(t.data))}catch(e){console.error(`Failed to parse session update event:`,e)}}),d.addEventListener(`scan-status`,e=>{if(t)try{t(JSON.parse(e.data))}catch(e){console.error(`Failed to parse scan status event:`,e)}}),d.onopen=()=>{o=tt,c=!1,s&&n?.(),s=!0},d.onerror=()=>{if(d.readyState!==EventSource.CLOSED||(d.close(),i))return;c||(c=!0,r?.());let e=rt(o);o=Math.min(o*2,nt),a=setTimeout(u,e)}};return u(),()=>{i=!0,a!==void 0&&clearTimeout(a),l?.close()}}var L={agents:{opencode:{name:`OpenCode`,icon:`/icon/agent/opencode.svg`},zcode:{name:`ZCode`,icon:`/icon/agent/zcode.svg`},codex:{name:`Codex`,icon:`/icon/agent/codex.svg`},pi:{name:`Pi`,icon:`/icon/agent/pi.svg`},cursor:{name:`Cursor`,icon:`/icon/agent/cursor.svg`},kimi:{name:`Kimi-Cli`,icon:`/icon/agent/kimi.svg`},claudecode:{name:`Claude Code`,icon:`/icon/agent/claudecode.svg`},kilo:{name:`Kilo Code`,icon:`/icon/agent/kilocode.svg`},antigravity:{name:`Antigravity`,icon:`/icon/agent/antigravity.svg`}},getDefaultAgentKey(){let e=Object.keys(this.agents);return e.length>0?e[0]:null},getAgentName(e){let t=this.agents[e];return t||=this.agents[e.toLowerCase()],t?t.name:e}},R=t(),at={a:({children:e})=>(0,R.jsx)(`span`,{className:`console-markdown-link`,children:e})};function ot(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function st(e){let t=e?.trim();if(!t)return null;let n=Array.from(new Set((t.match(/"[^"]+"|\S+/g)??[]).map(e=>e.replace(/^"|"$/g,``).trim()).filter(Boolean).filter(e=>!/^OR$/i.test(e))));return n.length===0?null:RegExp(`(${n.map(ot).join(`|`)})`,`gi`)}function ct({text:e,highlightQuery:t}){let r=(0,N.useRef)(null),i=(0,N.useMemo)(()=>st(t),[t]);return(0,N.useEffect)(()=>{let e=r.current;if(!e||!i)return;let t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=[];for(;t.nextNode();){let e=t.currentNode;if(!(e instanceof Text))continue;let r=e.parentElement;r&&(r.closest(`mark, pre, code`)||e.textContent?.trim()&&n.push(e))}for(let e of n){let t=e.textContent??``;if(i.lastIndex=0,!i.test(t))continue;let n=document.createDocumentFragment(),r=0;i.lastIndex=0;for(let e of t.matchAll(i)){let i=e.index??0,a=e[0]??``;i>r&&n.append(t.slice(r,i));let o=document.createElement(`mark`);o.textContent=a,n.append(o),r=i+a.length}r<t.length&&n.append(t.slice(r)),e.parentNode?.replaceChild(n,e)}},[i,e]),(0,R.jsx)(`div`,{ref:r,children:(0,R.jsx)(n,{components:at,children:e})})}var z=`codeseshProfiler`,B=`codeseshProfilerLog`,lt=16,ut=500;function dt(){if(typeof window>`u`)return!1;try{return window.localStorage.getItem(z)===`1`}catch{return!1}}function ft(){if(typeof window>`u`)return!1;try{return window.localStorage.getItem(B)===`1`}catch{return!1}}function pt(e){let t=window.__CODESHESH_RENDER_PROFILE__??[];t.push(e),t.length>ut&&t.splice(0,t.length-ut),window.__CODESHESH_RENDER_PROFILE__=t}function mt(e){if(!dt()||typeof window>`u`)return;let t=performance.now();pt({...e,startTime:ht(e.startTime??t),commitTime:ht(e.commitTime??t),route:e.route??window.location.pathname})}function ht(e){return Math.round(e*100)/100}function gt({id:e,detail:t,children:n}){return dt()?(0,R.jsx)(N.Profiler,{id:e,onRender:(e,n,r,i,a,o)=>{let s={id:e,source:`react-profiler`,phase:n,actualDuration:ht(r),baseDuration:ht(i),startTime:ht(a),commitTime:ht(o),route:window.location.pathname,...t?{detail:t}:{}};pt(s),s.actualDuration>=lt&&ft()&&I(`react.profiler.commit`,{...s})},children:(0,R.jsx)(_t,{id:e,detail:t,children:n})}):n}function _t({id:e,detail:t,children:n}){let r=performance.now(),i=(0,N.useRef)(0);return(0,N.useLayoutEffect)(()=>{i.current+=1;let n=performance.now();pt({id:e,source:`commit-latency`,phase:i.current===1?`mount`:`update`,actualDuration:ht(n-r),baseDuration:0,startTime:ht(r),commitTime:ht(n),route:window.location.pathname,...t?{detail:t}:{}})}),n}function vt(e){return Ct(e)?`Browser`:typeof e.title==`string`&&e.title.trim()?bt(e.title):typeof e.tool==`string`&&e.tool.trim()?bt(e.tool):`tool`}function yt(e){return Ct(e)?`browser`:bt(typeof e.tool==`string`&&e.tool.trim()?e.tool:vt(e)).toLowerCase()}function bt(e){return e.trim().replace(/^tool:\s*/i,``).replace(/^\.+(?=\w)/,``)}function xt(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function St(e){return typeof e==`string`?e.trim():``}function Ct(e){let t=St(xt(e.state?.metadata).namespace);return bt(St(e.tool)).toLowerCase()===`js`&&(t===`mcp__node_repl__`||t===`mcp__node_repl__.js`)}function wt(e,t){let n=yt(t),r=`tool:${n}`,i=e.get(n);if(i){i.count+=1;return}e.set(n,{id:r,toolKey:n,label:vt(t),count:1})}function Tt(e){let t={user:0,agent_message:0,thinking:0,plan:0,tools_all:0},n=new Set,r=new Map;for(let{msg:i,blocks:a}of e)for(let e of a){if(i.role===`user`){t.user+=1,n.add(`user`);continue}if(e.type===`text`){t.agent_message+=1,n.add(`agent_message`);continue}if(e.type===`reasoning`){t.thinking+=1,n.add(`thinking`);continue}if(e.type===`plan`){t.plan+=1,n.add(`plan`);continue}t.tools_all+=e.parts.length,n.add(`tools_all`);for(let t of e.parts)wt(r,t),n.add(`tool:${yt(t)}`)}return{filterIds:n,counts:t,tools:[...r.values()].toSorted((e,t)=>e.label.localeCompare(t.label))}}function Et(e,t){return t.has(`tool:${yt(e)}`)}function Dt(e,t,n){return t.role===`user`?n.has(`user`):e.type===`text`?n.has(`agent_message`):e.type===`reasoning`?n.has(`thinking`):e.type===`plan`?n.has(`plan`):e.parts.some(e=>Et(e,n))}function Ot(e,t){let n=e.parts.filter(e=>Et(e,t));return n.length===0?null:{...e,parts:n}}function kt(e,t){return e.map(e=>{let n=e.blocks.filter(n=>Dt(n,e.msg,t)).map(e=>e.type===`tool`?Ot(e,t):e).filter(e=>e!=null);return n.length===0?null:{msg:e.msg,blocks:n,index:e.index}}).filter(e=>e!=null)}function At(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(e=>{if(typeof e==`string`)return e;if(e&&typeof e==`object`){let t=e,n=At(t.text);if(n.trim())return n;let r=At(t.content);if(r.trim())return r}return``}).filter(Boolean).join(`
|
|
2
|
-
|
|
3
|
-
`);if(e&&typeof e==`object`){let t=e,n=At(t.text);if(n.trim())return n;let r=At(t.content);if(r.trim())return r}return``}function jt(e){return e.type===`tool`||e.type===`plan`?!0:e.type===`text`||e.type===`reasoning`?!!At(e.text).trim():!1}function Mt(e){return e.reduce((e,t)=>{if(!jt(t))return e;let n=e.at(-1);return t.type!==`plan`&&n?.type===t.type?(n.parts.push(t),e):(e.push({type:t.type,parts:[t]}),e)},[])}function Nt(e){let t=[];for(let n of e){let e=Mt(n.parts);e.length!==0&&t.push({msg:n,blocks:e,index:t.length})}return t}function Pt(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Ft(e){return typeof e==`string`?e:``}function It(e){return e.replace(/\\n/g,`
|
|
4
|
-
`)}function Lt(e){let t=Pt(e),n=Ft(t.type);return n?{type:n,path:Ft(t.path),oldPath:Ft(t.old_path),targetPath:Ft(t.targetPath),content:Ft(t.content)||Ft(Pt(t.input).content)}:null}function Rt(e){return(Array.isArray(e)?e:Array.isArray(Pt(e).content)?Pt(e).content:[]).map(e=>Lt(e)).filter(e=>e!=null)}function zt(e,t,n){return`${e} ${e===1?t:n}`}function Bt(e){let t=e.filter(e=>e.type===`write_file`).length,n=e.filter(e=>e.type===`edit_file`).length,r=e.filter(e=>e.type===`delete_file`).length,i=e.filter(e=>e.type===`move_file`).length,a=[];return t>0&&a.push(zt(t,`write`,`writes`)),n>0&&a.push(zt(n,`edit`,`edits`)),r>0&&a.push(zt(r,`delete`,`deletes`)),i>0&&a.push(zt(i,`move`,`moves`)),a.join(` · `)}function Vt(e){return e.targetPath||e.path||e.oldPath||e.type}function Ht(e,t,n){return e.reduce((e,r)=>r.type===`write_file`?(e.push({label:n(Vt(r)),operation:`write`,language:t(r.path),isCode:!0,text:It(r.content)}),e):r.type===`edit_file`?(e.push({label:n(Vt(r)),operation:`edit`,language:`diff`,isCode:!0,text:It(r.content)}),e):r.type===`delete_file`?(e.push({label:n(Vt(r)),operation:`edit`,language:`text`,isCode:!1,text:`File deleted.`}),e):(r.type===`move_file`&&e.push({label:n(Vt(r)),operation:`edit`,language:`text`,isCode:!1,text:r.targetPath&&r.path?`Moved from ${n(r.path)} to ${n(r.targetPath)}`:r.oldPath?`Moved from ${n(r.oldPath)}`:`File moved.`}),e),[])}function Ut(e,t,n,r=e=>e){let i=Ht(e,n,r);return i.length>0?{kind:`file-sections`,sections:i}:{kind:`plain`,text:t,language:`text`,isCode:!1}}function Wt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Gt(e){if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}}function Kt(e){return typeof e==`string`?e.trim():``}function V(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function H(e){return typeof e==`string`?e.trim():``}function U(e){return typeof e==`string`?e:``}function qt(e){try{return JSON.parse(e)}catch{return null}}function W(e){return e.replaceAll(/\\n/g,`
|
|
5
|
-
`)}function Jt(e){if(e==null)return``;if(typeof e==`string`){let t=e.trim();if(!t)return``;try{let e=JSON.parse(t);return JSON.stringify(e,null,2)}catch{return e}}try{return JSON.stringify(e,null,2)}catch{return typeof e==`number`||typeof e==`bigint`||typeof e==`boolean`?`${e}`:typeof e==`symbol`?e.description?`Symbol(${e.description})`:`Symbol`:typeof e==`function`?`[Function]`:`[Unserializable value]`}}function Yt(e){if(typeof e==`string`)return[e];if(Array.isArray(e))return e.flatMap(e=>Yt(e));if(e&&typeof e==`object`){let t=e;if(typeof t.text==`string`)return[t.text];if(t.content!==void 0)return Yt(t.content)}return[]}function Xt(e){return e.replace(/^<system>/i,``).replace(/<\/system>$/i,``).trim()}function Zt(e,t=!0){let n=Yt(e).map(e=>e.trim()).filter(e=>t?!!e:!!e&&!/^<system>[\s\S]*<\/system>$/i.test(e));return n.length===0?``:n.map(e=>t&&/^<system>[\s\S]*<\/system>$/i.test(e)?Xt(e):e).join(`
|
|
6
|
-
`)}function Qt(e){let t=Gt(e);if(t&&typeof t==`object`){let e=t;if(typeof e.cmd==`string`)return e.cmd;if(typeof e.command==`string`)return e.command}return``}function $t(e){let t=e.trim();return t?t.replace(/^tool:\s*/i,``).replace(/^\.+(?=\w)/,``):``}function en(e){return typeof e.title==`string`&&e.title.trim()?$t(e.title):typeof e.tool==`string`&&e.tool.trim()?$t(e.tool):`tool`}function tn(e){return en(e).trim().toLowerCase()}function nn(e,t=`Tool`){return $t(H(e.title))||H(e.tool)||t}function rn(e){return W(Zt(e)||Jt(e))||`No output captured.`}function G(e){let t=rn(e.outputValue);if(t!==`No output captured.`)return t;let n=rn(e.errorValue);return n===`No output captured.`?`No output captured.`:n}function an(e){let t=e.state||{},n=t.status,r=n===`running`||n===`error`||n===`completed`?n:`completed`,i=t.output??t.result??``,a=t.error??``,o=Gt(t.input??t.arguments??{}),s=t.metadata??{};return{status:r,command:Qt(o),inputValue:o,outputValue:i,errorValue:a,metadataValue:s,inputText:Jt(o)}}function on(e){let t=Kt(e.nickname);return e.role===`assistant`&&t?`AGENT (${t})`:e.role===`user`?`USER`:e.role===`tool`?`TOOL`:`AGENT`}function sn(e,t){if(t.toLowerCase()!==`cursor`)return e;let n=[];for(let t of e){if(t.role!==`tool`){n.push({...t,parts:[...t.parts]});continue}let e=n.at(-1);if(e?.role===`assistant`){e.parts.push(...t.parts);continue}n.push({...t,parts:[...t.parts]})}return n}function cn(e){let t=e.trim();return!t||t.length>300||t.includes(`
|
|
7
|
-
`)||/^[a-z]+:\/\//i.test(t)||/[<>{}]/.test(t)?!1:t.startsWith(`/`)||t.startsWith(`./`)||t.startsWith(`../`)||t.startsWith(`~/`)||t.includes(`/`)||t.includes(`\\`)?!0:/^[A-Za-z0-9_.@-]+\.[A-Za-z0-9_-]+$/.test(t)}function ln(e){let t=e.trim().toLowerCase();return!t||t.includes(`command`)||t.includes(`content`)||t.includes(`text`)||t.includes(`prompt`)||t.includes(`url`)||t.includes(`body`)||t.includes(`title`)||t.includes(`description`)||t===`cwd`||t===`workdir`||t===`directory`?!1:t===`path`||t===`paths`||t.includes(`file`)||t.includes(`path`)}function un(e,t,n,r=0){if(!(e==null||r>4)){if(typeof e==`string`){ln(t)&&cn(e)&&n.add(e.trim());return}if(Array.isArray(e)){for(let i of e)un(i,t,n,r+1);return}if(typeof e==`object`)for(let[t,i]of Object.entries(e))un(i,t,n,r+1)}}function dn(e){let t=new Set;return un(e,``,t),[...t]}function fn(e){return e.state?.arguments??e.state?.input??e.input??null}function K(e){let t=V(e);return H(t.filePath)||H(t.file_path)||H(t.path)||H(t.targetFile)||H(t.effectiveUri)||H(t.relativeWorkspacePath)||``}function q(e,t){let n=e.trim(),r=(t??``).replace(/\/+$/,``);return!n||!r?n:n===r?`.`:n.startsWith(`${r}/`)?n.slice(r.length+1):n}function pn(e,t){let n=(t??``).replace(/\/+$/,``);return!e||!n?e:e.replace(RegExp(`${Wt(n)}(?=$|/|[\\s"'\\)\\]}:;,])`,`g`),`.`)}function mn(e,t){return e.startsWith(`${t}/`)?e.slice(t.length+1):e}function hn(e,t){return`tool-${e}-${t}`}function gn(e){let t=tn(e);return t===`read`?`read`:t===`edit`||t===`multiedit`||t===`apply_patch`||t===`notebookedit`?`edit`:t===`write`||t===`create_file`||t===`write_file`?`write`:t===`delete`||t===`delete_file`?`delete`:null}function _n(e){let t=new Map;for(let n of e){let e=t.get(n.path);if(e){e.count+=1,e.anchors.push({anchorId:n.anchorId,time:n.time,toolLabel:n.toolLabel}),n.time>=e.latestTime&&(e.latestTime=n.time,e.latestAnchorId=n.anchorId,e.toolLabel=n.toolLabel);continue}t.set(n.path,{path:n.path,count:1,latestTime:n.time,latestAnchorId:n.anchorId,toolLabel:n.toolLabel,anchors:[{anchorId:n.anchorId,time:n.time,toolLabel:n.toolLabel}]})}return[...t.values()].map(e=>({...e,anchors:e.anchors.toSorted((e,t)=>e.time-t.time)})).toSorted((e,t)=>t.latestTime===e.latestTime?e.path.localeCompare(t.path):t.latestTime-e.latestTime)}function vn(e){let t=new Map,n=new Map,r={read:[],edit:[],write:[],delete:[]};return e.forEach(({msg:e,blocks:i,index:a})=>{let o=0;for(let s of i)if(s.type===`tool`)for(let i of s.parts){let s=hn(a,o);o+=1,t.set(i,s),n.set(s,a);let c=fn(i),l=en(i),u=i.time_created??e.time_created,d=Rt(c);if(d.length>0){for(let e of d){let t=(e.path||e.oldPath).trim();if(!t)continue;let n=e.type===`write_file`?`write`:e.type===`delete_file`?`delete`:`edit`;r[n].push({kind:n,path:t,anchorId:s,time:u,toolLabel:l})}continue}let f=gn(i);if(!f)continue;let p=dn(c);for(let e of p)r[f].push({kind:f,path:e,anchorId:s,time:u,toolLabel:l})}}),{toolAnchorIds:t,anchorMessageIndexes:n,summary:{read:_n(r.read),edit:_n(r.edit),write:_n(r.write),delete:_n(r.delete)}}}function yn(e,t){if(!e)return t;let n={read:[],edit:[],write:[],delete:[]},r=new Map;for(let e of[`read`,`edit`,`write`,`delete`])for(let n of t[e])r.set(`${e}\0${n.path}`,n);for(let t of e){let e=r.get(`${t.kind}\0${t.path}`);n[t.kind].push({path:t.path,count:t.count,latestTime:t.latest_time,latestAnchorId:e?.latestAnchorId??``,toolLabel:e?.toolLabel??t.kind,anchors:e?.anchors??[]})}for(let e of[`read`,`edit`,`write`,`delete`])n[e].sort((e,t)=>t.latestTime===e.latestTime?e.path.localeCompare(t.path):t.latestTime-e.latestTime);return n}function bn(e){return e.read.length+e.edit.length+e.write.length+e.delete.length}function xn({summary:e,baseDirectory:t,onJumpToAnchor:n}){let r=[{key:`read`,label:`Read`,Icon:s,items:e.read},{key:`edit`,label:`Edit`,Icon:v,items:e.edit},{key:`write`,label:`Write`,Icon:be,items:e.write},{key:`delete`,label:`Delete`,Icon:b,items:e.delete}].filter(e=>e.items.length>0);return r.length===0?null:(0,R.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[var(--console-border)] px-4 py-3`,children:[(0,R.jsx)(D,{className:`size-3.5 text-[var(--console-accent)]`}),(0,R.jsx)(`span`,{className:`console-mono text-xs font-semibold uppercase tracking-[0.16em] text-[var(--console-text)]`,children:`File Tracker`})]}),(0,R.jsx)(`div`,{className:`space-y-3 p-3`,children:r.map(({key:e,label:r,Icon:i,items:a})=>(0,R.jsx)(Sn,{label:r,Icon:i,items:a,baseDirectory:t,onJumpToAnchor:n},e))})]})}function Sn({label:e,Icon:t,items:n,baseDirectory:r,onJumpToAnchor:i}){let[a,o]=(0,N.useState)(!1);return(0,R.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[#fafafa]`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:`flex w-full items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-[var(--console-surface-muted)]`,children:[(0,R.jsx)(t,{className:`size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,R.jsx)(`span`,{className:`console-mono min-w-0 flex-1 text-[11px] font-semibold uppercase tracking-[0.12em] text-[var(--console-muted)]`,children:e}),(0,R.jsx)(`span`,{className:`console-mono shrink-0 text-[10px] text-[var(--console-muted)]`,children:n.length}),a?(0,R.jsx)(_,{className:`size-3.5 shrink-0 text-[var(--console-muted)]`}):(0,R.jsx)(x,{className:`size-3.5 shrink-0 text-[var(--console-muted)]`})]}),a?(0,R.jsx)(`div`,{className:`space-y-1 border-t border-[var(--console-border)] p-2`,children:n.map(e=>(0,R.jsx)(Cn,{item:e,baseDirectory:r,onJumpToAnchor:i},`${e.path}:${e.latestAnchorId||e.latestTime}`))}):null]})}function Cn({item:e,baseDirectory:t,onJumpToAnchor:n}){let[r,i]=(0,N.useState)(0);function a(t){let r=e.anchors.length;if(r===0)return;let a=(t%r+r)%r;i(a);let o=e.anchors[a];o&&n(o.anchorId)}return(0,R.jsxs)(`div`,{className:`flex items-start gap-2 rounded-sm px-2 py-2 transition-colors hover:bg-[var(--console-surface-muted)]`,children:[(0,R.jsx)(`button`,{type:`button`,title:e.path,onClick:()=>a(r),className:`min-w-0 flex-1 text-left`,children:(0,R.jsx)(`span`,{className:`console-mono block break-all text-xs text-[var(--console-text)]`,children:mn(e.path,t)})}),e.anchors.length>1?(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,R.jsx)(`button`,{type:`button`,"aria-label":`Previous ${e.path}`,onClick:()=>a(r-1),className:`rounded-sm border border-[var(--console-border)] p-1 text-[var(--console-muted)] transition-colors hover:bg-white`,children:(0,R.jsx)(_,{className:`size-3`})}),(0,R.jsxs)(`span`,{className:`console-mono text-[10px] text-[var(--console-muted)]`,children:[r+1,`/`,e.anchors.length]}),(0,R.jsx)(`button`,{type:`button`,"aria-label":`Next ${e.path}`,onClick:()=>a(r+1),className:`rounded-sm border border-[var(--console-border)] p-1 text-[var(--console-muted)] transition-colors hover:bg-white`,children:(0,R.jsx)(x,{className:`size-3`})})]}):(0,R.jsx)(`button`,{type:`button`,title:`Jump to tool call`,onClick:()=>a(0),className:`console-mono shrink-0 text-[10px] text-[var(--console-muted)]`,children:e.count})]})}var wn=[{id:`user`,label:`User`},{id:`agent_message`,label:`Agent Responses`},{id:`thinking`,label:`Thinking`},{id:`plan`,label:`Plans`},{id:`tools_all`,label:`Tools`}];function Tn(e){return e.tools.map(e=>e.id)}function En(e,t,n){let r=new Set(e),i=Tn(n);if(t===`tools_all`){if(i.filter(e=>r.has(e)).length<i.length){r.add(`tools_all`);for(let e of i)r.add(e)}else{r.delete(`tools_all`);for(let e of i)r.delete(e)}return r}return t.startsWith(`tool:`)?(r.has(t)?r.delete(t):r.add(t),i.filter(e=>r.has(e)).length===i.length?r.add(`tools_all`):r.delete(`tools_all`),r):(r.has(t)?r.delete(t):r.add(t),r)}function Dn({checked:e,indeterminate:t=!1,onChange:n}){let r=(0,N.useRef)(null);return(0,N.useLayoutEffect)(()=>{r.current&&(r.current.indeterminate=t)},[t]),(0,R.jsxs)(`span`,{className:`relative mt-0.5 size-3.5 shrink-0`,children:[(0,R.jsx)(`input`,{ref:r,type:`checkbox`,checked:e,"aria-checked":t?`mixed`:e,"data-indeterminate":t?`true`:void 0,onChange:n,className:`absolute inset-0 z-10 size-full cursor-pointer opacity-0`}),(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`flex size-3.5 items-center justify-center rounded border ${e||t?`border-[var(--console-accent-strong)] bg-[var(--console-accent-strong)] text-white`:`border-[var(--console-border-strong)] bg-white text-transparent`}`,children:t?(0,R.jsx)(S,{className:`size-2.5 stroke-[3]`}):e?(0,R.jsx)(Se,{className:`size-2.5 stroke-[3]`}):null})]})}function On({toc:e,fileChangeSummary:t,baseDirectory:n,selectedFilters:r,onToggle:i,onJumpToAnchor:a}){return(0,R.jsx)(`aside`,{className:`console-scrollbar hidden min-[1025px]:sticky min-[1025px]:top-4 min-[1025px]:block min-[1025px]:max-h-[calc(100dvh-14rem)] min-[1025px]:overflow-y-auto min-[1025px]:overscroll-contain`,children:(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsx)(kn,{toc:e,selectedFilters:r,onToggle:i}),(0,R.jsx)(xn,{summary:t,baseDirectory:n,onJumpToAnchor:a})]})})}function kn({toc:e,selectedFilters:t,onToggle:n}){let r=Tn(e),i=r.filter(e=>t.has(e)).length,a=r.length>0&&i===r.length,o=i>0&&i<r.length;return(0,R.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[var(--console-border)] px-4 py-3`,children:[(0,R.jsx)(ee,{className:`size-3.5 text-[var(--console-accent)]`}),(0,R.jsx)(`span`,{className:`console-mono text-xs font-semibold uppercase tracking-[0.16em] text-[var(--console-text)]`,children:`Session TOC`})]}),(0,R.jsxs)(`div`,{className:`space-y-1 p-3`,children:[wn.filter(({id:t})=>e.counts[t]>0).map(({id:r,label:i})=>(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-sm px-2 py-2 transition-colors hover:bg-[var(--console-surface-muted)]`,children:[(0,R.jsx)(Dn,{checked:r===`tools_all`?a:t.has(r),indeterminate:r===`tools_all`?o:!1,onChange:()=>n(r)}),(0,R.jsx)(`span`,{className:`console-mono min-w-0 flex-1 break-all text-xs leading-relaxed text-[var(--console-text)]`,children:i}),(0,R.jsx)(`span`,{className:`console-mono shrink-0 text-[11px] text-[var(--console-muted)]`,children:e.counts[r]})]},r)),e.tools.length>0?(0,R.jsx)(`div`,{className:`space-y-1 border-t border-[var(--console-border)] pt-2`,children:e.tools.map(e=>(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-sm px-2 py-2 transition-colors hover:bg-[var(--console-surface-muted)]`,children:[(0,R.jsx)(Dn,{checked:t.has(e.id),onChange:()=>n(e.id)}),(0,R.jsx)(`span`,{className:`console-mono min-w-0 flex-1 break-all text-xs leading-relaxed text-[var(--console-muted)]`,children:e.label}),(0,R.jsx)(`span`,{className:`console-mono shrink-0 text-[11px] text-[var(--console-muted)]`,children:e.count})]},e.id))}):null]})]})}var An={".bashrc":`bash`,".zshrc":`bash`,".profile":`bash`,dockerfile:`docker`,".env":`ini`},jn={ts:`typescript`,tsx:`tsx`,js:`javascript`,jsx:`jsx`,py:`python`,sql:`sql`,rs:`rust`,go:`go`,java:`java`,c:`c`,h:`c`,cc:`cpp`,cpp:`cpp`,cxx:`cpp`,hpp:`cpp`,cs:`csharp`,sh:`bash`,bash:`bash`,zsh:`bash`,html:`html`,css:`css`,yaml:`yaml`,yml:`yaml`,json:`json`,md:`markdown`,toml:`toml`,conf:`ini`,xml:`markup`,svg:`markup`,properties:`ini`,dockerfile:`docker`};function J(e){let t=e.split(`/`).pop()?.toLowerCase()??``;if(!t)return`text`;let n=An[t];if(n)return n;if(t.startsWith(`.env.`))return`ini`;let r=t.includes(`.`)?t.split(`.`).pop()??``:``;return r&&jn[r]||`text`}function Mn(e,t,n){return!t.trim()&&!n.trim()?[]:[{label:Ln(e),lines:Fn(O(W(t),W(n)))}]}function Nn(e,t){let n=W(e).split(`
|
|
8
|
-
`),r=W(t).split(`
|
|
9
|
-
`);return[`@@`,...n.map(e=>`- ${e}`),...r.map(e=>`+ ${e}`)].join(`
|
|
10
|
-
`)}function Pn(e){let t=W(e),n=t.split(`
|
|
11
|
-
`);return t.endsWith(`
|
|
12
|
-
`)&&n.pop(),n}function Fn(e){return e.flatMap(e=>{let t=e.added?`add`:e.removed?`remove`:`context`;return Pn(e.value).map(e=>({type:t,text:e}))})}function In(e){let t=V(e).edit;return Array.isArray(t)?t:t&&typeof t==`object`?[t]:[]}function Ln(e){let t=e.trim();if(!t)return`edit`;let n=t.split(`/`).pop()||t;return n===t?n:`${n} · ${t}`}function Rn(e,t){let n=In(e.inputValue),r=Ln(t);return n.map(e=>{let t=V(e),n=U(t.old),i=U(t.new);return!n.trim()&&!i.trim()?null:{label:r,lines:Fn(O(W(n),W(i)))}}).filter(e=>e!=null&&e.lines.length>0)}function zn(e,t){let n=V(e.inputValue),r=Array.isArray(n.edits)?n.edits:[],i=Ln(t),a=r.map(e=>{let t=V(e),n=U(t.oldText)||U(t.old),r=U(t.newText)||U(t.new);return!n.trim()&&!r.trim()?null:{label:i,lines:Fn(O(W(n),W(r)))}}).filter(e=>e!=null&&e.lines.length>0);if(a.length>0)return a;let o=V(e.metadataValue),s=U(o.patch)||U(o.diff);return s.trim()?[{label:i,lines:s.split(`
|
|
13
|
-
`).map(e=>({type:e.startsWith(`+`)?`add`:e.startsWith(`-`)?`remove`:`context`,text:e}))}]:[]}function Bn(e){return e.startsWith(`@@`)?{type:`context`,text:e}:e.startsWith(`+`)?{type:`add`,text:e.slice(1)}:e.startsWith(`-`)?{type:`remove`,text:e.slice(1)}:e.startsWith(` `)?{type:`context`,text:e.slice(1)}:{type:`context`,text:e}}function Vn(e,t){let n=V(V(e.metadataValue).display),r=Array.isArray(n.structuredPatch)?n.structuredPatch:[],i=U(n.filePath)||t;return r.map(e=>{let t=V(e),n=(Array.isArray(t.lines)?t.lines:[]).map(e=>typeof e==`string`?Bn(e):null).filter(e=>e!=null);return n.length===0?null:{label:Ln(i),lines:n}}).filter(e=>e!=null)}function Hn(e){let t=U(V(e.metadataValue).diff);if(t.trim())return W(t);let n=In(e.inputValue).map(e=>{let t=V(e),n=U(t.old),r=U(t.new);return!n.trim()&&!r.trim()?``:Nn(n,r)}).filter(Boolean).join(`
|
|
14
|
-
|
|
15
|
-
`);return n.trim()?n:G(e)}function Un(e){return e.replace(/\n*<system-reminder>[\s\S]*$/i,``).trimEnd()}function Wn(e){let t=Zt(e,!1)||rn(e);return t===`No output captured.`?t:Un(t.replace(/^<file>\s*/i,``).replace(/\s*<\/file>\s*$/i,``)).split(`
|
|
16
|
-
`).filter(e=>!/^\(End of file - total \d+ lines\)$/.test(e.trim())).map(e=>e.replace(/^\d+\|\s?/,``).replace(/^\s*\d+\t/,``)).join(`
|
|
17
|
-
`).trimEnd()||`No output captured.`}function Gn(e){let t=V(e.inputValue);if(e.status===`completed`){let e=U(t.content);if(e.trim())return W(e)}return G(e)}function Kn(e,t,n){let r=pn(t.command||t.inputText||`{}`,n).replace(/\s+/g,` `).trim(),i=r.length>72?`${r.slice(0,72)}...`:r;return{Icon:k,title:nn(e),secondaryText:i?`(${i})`:void 0,details:[],expandable:!0,showInputPreview:!0,outputContent:{kind:`plain`,text:G(t),language:`text`,isCode:!1}}}function qn(e,t,n,r){let i=pn(H(V(t.inputValue).name),r);return{...n,Icon:ce,title:H(e.tool)||`skill`,secondaryText:i||void 0,expandable:!1,showInputPreview:!1}}function Jn(e,t,n){let r=Kn(e,t,n),i=(e.tool||``).toLowerCase(),a=V(t.inputValue),o=K(t.inputValue),s=q(o,n);if(i===`read`)return{...r,Icon:m,title:`read`,secondaryText:s||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:Wn(t.outputValue),language:J(o),isCode:!0}};if(i===`edit`){let e=U(a.old_string),n=U(a.new_string),i=Mn(s||o,e,n);return{...r,Icon:v,title:`edit`,secondaryText:s||void 0,showInputPreview:!1,outputContent:i.length>0?{kind:`structured-diff`,blocks:i}:{kind:`plain`,text:G(t),language:`text`,isCode:!1}}}return i===`write`?{...r,Icon:be,title:`write`,secondaryText:s||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:Gn(t),language:J(o),isCode:!0}}:{...r,title:nn(e)}}function Yn(e,t,n){let r=Kn(e,t,n),i=(e.tool||``).toLowerCase(),a=V(t.inputValue);if(i===`glob`){let n=H(a.pattern);return{...r,Icon:s,title:e.tool||`glob`,secondaryText:n||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:G(t),language:`text`,isCode:!1}}}if(i===`grep`){let i=H(a.path),o=H(a.pattern),c=[q(i,n),o].filter(Boolean).join(` · `);return{...r,Icon:s,title:e.tool||`grep`,secondaryText:c||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:G(t),language:`text`,isCode:!1}}}if(i===`bash`){let i=H(a.description),o=pn(H(a.command),n),s=i?`${i}${o?` (${o})`:``}`:o?`(${o})`:void 0;return{...r,Icon:k,title:e.tool||`bash`,secondaryText:s,showInputPreview:!1,outputContent:{kind:`plain`,text:G(t),language:`text`,isCode:!1}}}if(i===`read`){let i=K(t.inputValue),a=q(i,n);return{...r,Icon:m,title:e.tool||`read`,secondaryText:a||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:Wn(t.outputValue),language:J(i),isCode:!0}}}if(i===`edit`){let i=q(K(t.inputValue),n);return{...r,Icon:v,title:e.tool||`edit`,secondaryText:i||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:Hn(t),language:`diff`,isCode:!0}}}if(i===`write`){let i=K(t.inputValue),a=q(i,n),o=t.status===`completed`;return{...r,Icon:be,title:e.tool||`write`,secondaryText:a||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:Gn(t),language:J(i),isCode:o}}}return i===`skill`?qn(e,t,r,n):r}function Xn(e,t,n){let r=Kn(e,t,n),i=(e.tool||``).toLowerCase(),a=V(t.inputValue);if(i===`glob`){let n=H(a.pattern);return{...r,Icon:s,title:e.title||`glob`,secondaryText:n||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:G(t),language:`text`,isCode:!1}}}if(i===`grep`){let i=H(a.path),o=H(a.pattern),c=[q(i,n),o].filter(Boolean).join(` · `);return{...r,Icon:s,title:e.title||`grep`,secondaryText:c||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:G(t),language:`text`,isCode:!1}}}if(i===`shell`){let i=pn(H(a.command),n);return{...r,Icon:k,title:e.title||`bash`,secondaryText:i?`(${i})`:void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:G(t),language:`text`,isCode:!1}}}if(i===`readfile`){let i=K(t.inputValue),a=q(i,n);return{...r,Icon:m,title:e.title||`read`,secondaryText:a||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:Wn(t.outputValue),language:J(i),isCode:!0}}}if(i===`strreplacefile`){let i=K(t.inputValue),a=q(i,n),o=Rn(t,a||i);return{...r,Icon:v,title:e.title||`edit`,secondaryText:a||void 0,showInputPreview:!1,outputContent:o.length>0?{kind:`structured-diff`,blocks:o}:{kind:`plain`,text:Hn(t),language:`diff`,isCode:!0}}}if(i===`writefile`){let i=K(t.inputValue),a=q(i,n);return{...r,Icon:be,title:e.title||`write`,secondaryText:a||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:Gn(t),language:J(i),isCode:t.status===`completed`}}}return r}function Zn(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Qn(e){return typeof e==`string`?e.trim():``}function $n(e){return typeof e==`string`?e:``}function er(e){return typeof e==`string`?e.trim():typeof e==`number`||typeof e==`bigint`||typeof e==`boolean`?`${e}`:``}function tr(e){return e.replace(/\\n/g,`
|
|
18
|
-
`)}function nr(e){return e.replace(/\s*\(Recommended\)\s*$/i,``).trim()}function rr(e){let t=e.trim();return{label:nr(t),recommended:/\(Recommended\)\s*$/i.test(t)}}function ir(e){return e.replace(/\s+/g,` `).trim()}function ar(e,t=88){let n=ir(e);return n?n.length>t?`${n.slice(0,t)}...`:n:``}function or(e,t){return ar([`${t} questions`,...e.filter(Boolean).slice(0,2)].join(` · `),96)}function sr(e){try{return JSON.parse(e)}catch{return null}}function cr(e){let t=tr(e).split(`
|
|
19
|
-
`);if(t.length<5||!(/^Chunk ID:\s+\S+/.test(t[0]||``)&&/^Wall time:\s+/.test(t[1]||``)&&/^Process (?:exited with code \d+|running with session ID \d+)/.test(t[2]||``)&&/^Original token count:\s+\d+/.test(t[3]||``)&&/^Output:$/.test(t[4]||``)))return e;let n=5;for(;n<t.length&&t[n]?.trim()===``;)n+=1;let r=t.slice(n).join(`
|
|
20
|
-
`);return r.trim()?r:e}function lr(e,t,n){n.trim()&&e.push({label:t,value:n})}function ur(e){return e.startsWith(`"`)&&e.endsWith(`"`)||e.startsWith(`'`)&&e.endsWith(`'`)?e.slice(1,-1):e}function dr(e){return e.trim()?!/[|&;<>()$`*?{}[\]\\]/.test(e):!1}function fr(e){let t=ur(e.trim());return dr(t)?t:null}function pr(e){let t=e.trim();if(!t)return null;let n=t.match(/^nl\s+-ba\s+([^\s]+)\s*\|\s*sed\s+-n\s+['"][^'"]+['"]$/);if(n)return fr(n[1]||``);for(let e of[/^cat\s+([^\s]+)$/,/^sed\s+-n\s+['"][^'"]+['"]\s+([^\s]+)$/,/^head\s+-n\s+\d+\s+([^\s]+)$/,/^tail\s+-n\s+\d+\s+([^\s]+)$/]){let n=t.match(e);if(n)return fr(n[1]||``)}return null}function mr(e){let t=e.split(`
|
|
21
|
-
`),n=t.filter(e=>e.trim());if(n.length===0)return e;let r=/^\s*\d+(?:\t|\|\s?)/;return n.filter(e=>r.test(e)).length/n.length<.6?e:t.map(e=>e.replace(/^\s*\d+(?:\t|\|\s?)/,``)).join(`
|
|
22
|
-
`)}function hr(e){return/\b(Test Files|Tests|Coverage report|coverage: platform|Ran \d+ tests)\b/.test(e)||/^(PASS|FAIL|stdout\s+\|)/m.test(e)||/\bmodules transformed\b/.test(e)}function gr(e){let t=e.trim();return!t||hr(t)?null:(t.startsWith(`{`)||t.startsWith(`[`))&&sr(t)!=null?`json`:/<(!DOCTYPE html|html\b|body\b|div\b|span\b|main\b|section\b|svg\b|\/[a-z])/i.test(t)?`markup`:[/^#{1,6}\s/m,/^[-*]\s/m,/^\d+\.\s/m,/^```/m].filter(e=>e.test(t)).length>=1&&!/[{};]\s*$/.test(t)?`markdown`:(t.match(/^[A-Za-z0-9_-]+:\s.+$/gm)||[]).length>=2&&!/\b(import|export|const|let|function|class)\b/.test(t)&&!/[{}()[\];]/.test(t)?`yaml`:[/^(from\s+\S+\s+import\s+.+|import\s+\S+)/m,/^def\s+\w+\(/m,/^class\s+\w+[:(]/m].filter(e=>e.test(t)).length>=2||/^(from\s+\S+\s+import\s+.+|import\s+\S+)/m.test(t)&&/^def\s+\w+\(/m.test(t)?`python`:[/\binterface\s+\w+/,/\btype\s+\w+\s*=/,/\bimplements\b/,/\bas const\b/,/:\s*[A-Z][A-Za-z0-9_<>,[\] |&?]+/].filter(e=>e.test(t)).length>=1&&/\b(import|export|const|let|function|class)\b/.test(t)?`typescript`:[/^\s*import\s.+from\s/m,/^\s*export\s/m,/\b(const|let|function|class)\b/].filter(e=>e.test(t)).length>=2?`javascript`:null}function _r(e,t,n){let r=cr(t),i=pr(e);if(i){let e=n(i);return{text:mr(r),language:e,isCode:e!==`text`,sourcePath:i,confidence:`path`}}let a=gr(r);return a?{text:r,language:a,isCode:!0,confidence:`content`}:{text:r,language:`text`,isCode:!1,confidence:`plain`}}function vr(e,t,n,r=e=>e,i=e=>e){let a=Zn(e),o=Qn(a.cmd),s=Qn(a.workdir),c=Qn(a.sandbox_permissions),l=Qn(a.justification),u=i(o),d=[];lr(d,`Command`,u),lr(d,`Workdir`,r(s)),lr(d,`Escalation`,c),lr(d,`Justification`,l);let f=ar(u);return{secondaryText:l?[l,f].filter(Boolean).join(`
|
|
23
|
-
`):f||void 0,details:d,outputAnalysis:_r(o,t,n)}}function yr(e,t,n){let r=Zn(e),i=er(r.session_id),a=$n(r.chars),o=a?`stdin`:`poll`,s=[];return lr(s,`Session`,i),s.push({label:`Chars`,value:a||`(empty)`}),{secondaryText:i?`session #${i} · ${o}`:o,details:s,outputAnalysis:_r(``,t,n)}}function br(e,t){let n=Zn(e),r=Array.isArray(n.questions)?n.questions:null;if(!r||r.length===0)return{secondaryText:void 0,details:[],outputContent:{kind:`plain`,text:t,language:`text`,isCode:!1}};let i=Zn(sr(t)?.answers),a=r.map(e=>{let t=Zn(e),n=Zn(i[Qn(t.id)]),r=(Array.isArray(n.answers)?n.answers:[]).map(e=>typeof e==`string`?nr(e):``).filter(Boolean),a=Array.isArray(t.options)?t.options.map(e=>{let t=Zn(e),n=rr(Qn(t.label));return n.label?{label:n.label,description:Qn(t.description)||void 0,recommended:n.recommended||void 0}:null}).filter(e=>e!=null):[],o=Qn(t.question);return o?{header:Qn(t.header)||void 0,question:o,options:a,answers:r}:null}).filter(e=>e!=null);return a.length===0?{secondaryText:void 0,details:[],outputContent:{kind:`plain`,text:t,language:`text`,isCode:!1}}:{secondaryText:or(a.map(e=>e.header||``),a.length),details:[],outputContent:{kind:`question-list`,questions:a}}}function xr(e){let t=e.indexOf(`Output:
|
|
24
|
-
`);if(t===-1)return e;let n=qt(e.slice(t+8).trim());return Array.isArray(n)&&n.map(e=>H(V(e).text)).filter(Boolean).join(`
|
|
25
|
-
`)||e}function Sr(e){let t=V(V(e.state).arguments),n=Kt(t.agent_type),r=Kt(e.nickname),i=[Kt(t.model),Kt(t.reasoning_effort)].filter(Boolean).join(`-`);return[[n,r].filter(Boolean).join(` - `),i].filter(Boolean).join(` `)}function Cr(e){let t=V(e.state);return Kt(t.prompt)||Kt(V(t.arguments).message)||``}function wr(e,t,n){let r=Kn(e,t,n),i=tn(e),a=H(V(t.metadataValue).namespace),o=e=>q(e,n),s=e=>pn(e,n);if(i===`skill`)return qn(e,t,r,n);if(i===`js`&&(a===`mcp__node_repl__`||a===`mcp__node_repl__.js`)){let e=H(V(t.inputValue).title);return{...r,Icon:k,title:`Browser`,secondaryText:e||void 0,details:[],showInputPreview:!1,outputContent:{kind:`plain`,text:xr(G(t)),language:`text`,isCode:!1}}}if(i===`exec_command`||i===`bash`){let e=vr(t.inputValue,G(t),J,o,s);return{...r,Icon:k,title:`bash`,secondaryText:e.secondaryText,details:e.details,showInputPreview:!1,outputContent:{kind:`plain`,text:e.outputAnalysis.text,language:e.outputAnalysis.language,isCode:e.outputAnalysis.isCode}}}if(i===`write_stdin`){let e=yr(t.inputValue,G(t),J);return{...r,Icon:k,title:`bash`,secondaryText:e.secondaryText,details:e.details,showInputPreview:!1,outputContent:{kind:`plain`,text:e.outputAnalysis.text,language:e.outputAnalysis.language,isCode:e.outputAnalysis.isCode}}}if(i===`request_user_input`){let e=br(t.inputValue,G(t));return{...r,Icon:f,title:`ask`,secondaryText:e.secondaryText,details:e.details,showInputPreview:!1,outputContent:e.outputContent}}if(i===`patch`){let n=Rt(t.inputValue),i=Bt(n);return{...r,Icon:v,title:nn(e,`patch`),secondaryText:i||void 0,details:[],showInputPreview:!1,outputContent:Ut(n,G(t),J,o)}}if(i===`subagent`){let n=Cr(e),i=G(t);return{...r,Icon:re,title:Sr(e)||nn(e,`subagent`),secondaryText:void 0,details:[],showInputPreview:!1,outputContent:{kind:`plain`,text:n||i,language:`markdown`,isCode:!1}}}return r}function Tr(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:typeof e==`string`&&qt(e)||{}}function Er(e){let t=U(Tr(e).contents);return t?W(t):`No output captured.`}function Dr(e){let t=Tr(e),n=Array.isArray(t.directories)?t.directories:[];if(n.length===0)return rn(e);let r=n.flatMap(e=>{let t=V(e);return[H(t.absPath),...(Array.isArray(t.files)?t.files:[]).map(e=>{let t=V(e);return H(t.relPath)||H(t.absPath)}).filter(Boolean).map(e=>` ${e}`)].filter(Boolean)});return r.length>0?r.join(`
|
|
26
|
-
`):`No output captured.`}function Or(e,t,n){let r=Kn(e,t,n),i=(e.tool||``).toLowerCase(),a=V(t.inputValue),o=K(t.inputValue),c=q(o,n);if(i===`read_file_v2`){let e=Er(t.outputValue);return{...r,Icon:m,title:`read`,secondaryText:c||void 0,details:e===`No output captured.`?[{label:`Lines`,value:H(Tr(t.outputValue).totalLinesInFile)}]:[],showInputPreview:!1,outputContent:{kind:`plain`,text:e,language:J(o),isCode:e!==`No output captured.`}}}if(i===`edit_file_v2`){let e=W(U(a.streamingContent));return{...r,Icon:v,title:`edit`,secondaryText:c||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:e||G(t),language:e?`diff`:`text`,isCode:!!e}}}if(i===`ripgrep_raw_search`){let e=H(a.pattern),i=[q(H(a.path),n),e].filter(Boolean).join(` · `);return{...r,Icon:s,title:`grep`,secondaryText:i||void 0,details:[],showInputPreview:!1,outputContent:{kind:`plain`,text:G(t),language:`text`,isCode:!1}}}if(i===`glob_file_search`){let e=H(a.globPattern),i=[q(H(a.targetDirectory),n),e].filter(Boolean).join(` · `);return{...r,Icon:s,title:`glob`,secondaryText:i||void 0,details:[],showInputPreview:!1,outputContent:{kind:`plain`,text:Dr(t.outputValue),language:`text`,isCode:!1}}}if(i===`run_terminal_command_v2`){let e=pn(H(a.command),n),i=H(a.commandDescription),o=i?`${i}${e?` (${e})`:``}`:e?`(${e})`:void 0;return{...r,Icon:k,title:`bash`,secondaryText:o,details:[],showInputPreview:!1,outputContent:{kind:`plain`,text:G(t),language:`text`,isCode:!1}}}return{...r,title:nn(e)}}function kr(e){let t=V(e.inputValue),n=V(e.metadataValue),r=Array.isArray(n.tasks)?n.tasks:[],i=Number(t.id);return V(Number.isFinite(i)&&i>0?r.find(e=>Number(V(e).id)===i):r.at(-1))}function Ar(e){let t=G(e).match(/\(([^()]+?)\s*→\s*([^()]+?)\)/);return t?`${t[1]} -> ${t[2]}`:``}function jr(e){let t=(e.split(`
|
|
27
|
-
`)[0]??``).match(/^Agent:\s*(.+)$/i),n=e.split(`
|
|
28
|
-
`).find(e=>e.includes(`Status:`)),r=[];return t?.[1]&&r.push({label:`Agent`,value:t[1].trim()}),n&&r.push({label:`Summary`,value:n.trim()}),r}function Mr(e,t,n){let r=Kn(e,t,n),i=(e.tool||``).toLowerCase(),a=V(t.inputValue),o=V(t.metadataValue),s=K(t.inputValue),c=q(s,n);if(i===`todo`){let e=H(a.action)||H(o.action)||`todo`,n=kr(t),i=Number(n.id)||Number(a.id),s=H(n.subject)||H(a.subject),c=H(n.description)||H(a.description),l=H(n.status)||H(a.status),u=Ar(t),d=[i?`#${i}`:``,s,e===`update`&&u?u:l].filter(Boolean);return{...r,Icon:te,title:e===`create`?`todo create`:e===`update`?`todo update`:`todo`,secondaryText:d.join(` · `)||void 0,details:[i?{label:`ID`,value:`#${i}`}:null,s?{label:`Subject`,value:s}:null,l?{label:`Status`,value:l}:null,u?{label:`Change`,value:u}:null].filter(e=>e!=null),showInputPreview:!1,outputContent:{kind:`plain`,text:c||G(t),language:`markdown`,isCode:!1}}}if(i===`read`)return{...r,Icon:m,title:`read`,secondaryText:c||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:Wn(t.outputValue),language:J(s),isCode:!0}};if(i===`write`)return{...r,Icon:ue,title:`write`,secondaryText:c||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:Gn(t),language:J(s),isCode:t.status===`completed`}};if(i===`edit`){let e=zn(t,c||s),n=typeof o.firstChangedLine==`number`?String(o.firstChangedLine):U(o.firstChangedLine);return{...r,Icon:v,title:`edit`,secondaryText:c||void 0,details:n?[{label:`Line`,value:n}]:[],showInputPreview:!1,outputContent:e.length>0?{kind:`structured-diff`,blocks:e}:{kind:`plain`,text:G(t),language:`text`,isCode:!1}}}if(i===`agent`){let e=H(a.description)||H(o.description),n=H(a.subagent_type)||H(o.subagentType),i=H(o.agentId),s=H(o.status);return{...r,Icon:re,title:n?`agent · ${n}`:`agent`,secondaryText:[i?`#${i}`:``,e].filter(Boolean).join(` · `),details:[i?{label:`Agent`,value:i}:null,n?{label:`Type`,value:n}:null,s?{label:`Status`,value:s}:null].filter(e=>e!=null),showInputPreview:!1,outputContent:{kind:`plain`,text:U(a.prompt)||G(t),language:`markdown`,isCode:!1}}}if(i===`get_subagent_result`){let e=H(a.agent_id),n=G(t);return{...r,Icon:re,title:`subagent result`,secondaryText:e?`#${e}`:void 0,details:jr(n),showInputPreview:!1,outputContent:{kind:`plain`,text:n,language:`markdown`,isCode:!1}}}if(i===`analyze_image`){let e=Array.isArray(a.images)?a.images.map(e=>U(e)).filter(Boolean):[],i=U(a.question);return{...r,Icon:u,title:`analyze image`,secondaryText:e.map(e=>q(e,n)).join(`, `),details:[...e.map((e,t)=>({label:t===0?`Image`:`Image ${t+1}`,value:q(e,n)})),i?{label:`Question`,value:i}:null].filter(e=>e!=null),showInputPreview:!1,outputContent:{kind:`plain`,text:G(t),language:`markdown`,isCode:!1}}}if(i===`bash`||i===`batch`){let e=pn(H(a.command),n);return{...r,Icon:k,title:i===`batch`?`batch`:`bash`,secondaryText:e?`(${e})`:void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:G(t),language:`text`,isCode:!1}}}return r}function Nr(e){return e.replace(/\s*[((](?:Recommended|推荐)[))]\s*$/i,``).trim()}function Pr(e){let t=new Map;return{text:e.map(e=>{let n=V(e),r=H(n.status)||`pending`,i=H(n.priority),a=H(n.content);t.set(r,(t.get(r)??0)+1);let o=r===`completed`?`x`:r===`in_progress`?`~`:` `,s=i?` _${i}_`:``;return`- [${o}] ${a||`(empty todo)`}${s}`}).join(`
|
|
29
|
-
`)||`No todos captured.`,summary:[...t.entries()].map(([e,t])=>`${t} ${e}`).join(` · `),details:[...t.entries()].map(([e,t])=>({label:e,value:String(t)}))}}function Fr(e){let t=new Map;for(let n of e.matchAll(/"([^"]+)"="([^"]+)"/g)){let e=n[1]?.trim(),r=n[2]?.trim();!e||!r||t.set(e,[Nr(r)])}return t}function Ir(e,t){let n=V(e),r=Array.isArray(n.questions)?n.questions:[],i=Fr(t),a=r.map(e=>{let t=V(e),n=H(t.question);if(!n)return null;let r=Array.isArray(t.options)?t.options.map(e=>{let t=V(e),n=H(t.label),r=Nr(n);return r?{label:r,description:H(t.description)||void 0,recommended:r!==n.trim()||void 0}:null}).filter(e=>e!=null):[];return{header:H(t.header)||void 0,question:n,options:r,answers:i.get(n)??[]}}).filter(e=>e!=null);return a.length===0?{secondaryText:void 0,outputContent:{kind:`plain`,text:t,language:`text`,isCode:!1}}:{secondaryText:`${a.length} question${a.length===1?``:`s`}`,outputContent:{kind:`question-list`,questions:a}}}function Lr(e,t,n){let r=Kn(e,t,n),i=tn(e),a=V(t.inputValue),o=V(t.metadataValue),c=K(t.inputValue),l=q(c,n),u=G(t);if(i===`bash`){let e=H(a.description),t=H(a.command),i=pn(t,n),o=u===`(Bash completed with no output)`?`No output captured.`:u;return{...r,Icon:k,title:`bash`,secondaryText:e?`${e}${i?` (${i})`:``}`:i?`(${i})`:void 0,details:t?[{label:`Command`,value:i||t}]:[],showInputPreview:!1,outputContent:{kind:`plain`,text:o,language:`text`,isCode:!1}}}if(i===`read`)return{...r,Icon:m,title:`read`,secondaryText:l||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:Wn(t.outputValue),language:J(c),isCode:!0}};if(i===`edit`){let e=Vn(t,l||c),n=U(a.old_string),i=U(a.new_string),s=Mn(l||c,n,i),d=e.length>0?e:s,f=V(o.display);return{...r,Icon:v,title:`edit`,secondaryText:l||void 0,details:[typeof f.additions==`number`?{label:`Additions`,value:String(f.additions)}:null,typeof f.deletions==`number`?{label:`Deletions`,value:String(f.deletions)}:null].filter(e=>e!=null),showInputPreview:!1,outputContent:d.length>0?{kind:`structured-diff`,blocks:d}:{kind:`plain`,text:u,language:`text`,isCode:!1}}}if(i===`write`)return{...r,Icon:ue,title:`write`,secondaryText:l||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:Gn(t),language:J(c),isCode:t.status===`completed`}};if(i===`glob`||i===`grep`){let e=H(a.path),t=H(a.pattern),o=[q(e,n),t].filter(Boolean).join(` · `);return{...r,Icon:s,title:i,secondaryText:o||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:u,language:`text`,isCode:!1}}}if(i===`todowrite`){let e=Pr(Array.isArray(a.todos)?a.todos:[]);return{...r,Icon:te,title:`todo`,secondaryText:e.summary||void 0,details:e.details,showInputPreview:!1,outputContent:{kind:`plain`,text:e.text,language:`markdown`,isCode:!1}}}if(i===`agent`){let e=H(a.subagent_type),t=H(a.description);return{...r,Icon:re,title:e?`agent · ${e}`:`agent`,secondaryText:t||void 0,details:e?[{label:`Type`,value:e}]:[],showInputPreview:!1,outputContent:{kind:`plain`,text:u,language:`markdown`,isCode:!1}}}if(i===`askuserquestion`){let e=Ir(t.inputValue,u);return{...r,Icon:f,title:`ask`,secondaryText:e.secondaryText,details:[],showInputPreview:!1,outputContent:e.outputContent}}if(i===`enterplanmode`||i===`exitplanmode`){let e=U(a.plan);return{...r,Icon:te,title:i===`enterplanmode`?`plan mode`:`plan approved`,secondaryText:e.split(`
|
|
30
|
-
`).find(e=>e.trim())?.replace(/^#+\s*/,``)||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:e||u,language:`markdown`,isCode:!1}}}if(i===`websearch`){let e=H(a.query);return{...r,Icon:s,title:`web search`,secondaryText:e||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:u,language:`markdown`,isCode:!1}}}if(i===`skill`){let e=H(a.skill);return{...r,Icon:ce,title:`skill`,secondaryText:e||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:u,language:`markdown`,isCode:!1}}}return r}var Rr={claudecode:Jn,opencode:Yn,kimi:Xn,codex:wr,cursor:Or,pi:Mr,zcode:Lr};function zr(e,t,n,r){return(Rr[e.toLowerCase()]??Kn)(t,n,r)}function Br(e){if(!e)return`unknown`;let t=Date.now()-e;if(Number.isNaN(t)||t<0)return`just now`;let n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function Y(e){return e.toLocaleString(`en-US`)}function Vr(e){return e===0?`$0.00`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function Hr(e){if(e===`recorded`)return`recorded`;if(e===`estimated`)return`estimated`}function Ur(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function Wr(e){if(typeof e==`number`&&e<=0)return`Unknown time`;let t=null;if(typeof e==`number`){let n=e<10**12?e*1e3:e;t=new Date(n)}else if(typeof e==`string`&&e.trim()){let n=Number(e);t=!Number.isNaN(n)&&n>0?new Date(n<10**12?n*1e3:n):new Date(e)}return!t||Number.isNaN(t.getTime())?`Unknown time`:t.toLocaleTimeString(`en-US`,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!0})}A.registerLanguage(`bash`,Ce),A.registerLanguage(`c`,Ve),A.registerLanguage(`cpp`,j),A.registerLanguage(`csharp`,He),A.registerLanguage(`css`,Be),A.registerLanguage(`docker`,we),A.registerLanguage(`go`,ke),A.registerLanguage(`ini`,Ae),A.registerLanguage(`java`,Me),A.registerLanguage(`javascript`,Fe),A.registerLanguage(`jsx`,Oe),A.registerLanguage(`json`,De),A.registerLanguage(`markdown`,ze),A.registerLanguage(`markup`,je),A.registerLanguage(`python`,Ee),A.registerLanguage(`rust`,Le),A.registerLanguage(`sql`,Pe),A.registerLanguage(`toml`,Te),A.registerLanguage(`tsx`,M),A.registerLanguage(`typescript`,Ie),A.registerLanguage(`yaml`,Ne);function Gr(e){return e===`html`||e===`xml`?`markup`:e}function Kr({language:e,text:t}){return(0,R.jsx)(A,{language:Gr(e),style:Re,customStyle:{margin:0,padding:`0.75rem`,borderRadius:0,background:`transparent`,fontSize:`0.75rem`,lineHeight:1.55},codeTagProps:{className:`console-mono`},wrapLongLines:!0,children:t})}function qr(e,t){return`${e}:${t}`}function Jr(e){return/^(Index:|diff\s|===)/.test(e)?`text-[var(--console-text)] bg-[#f3f4f6]`:e.startsWith(`@@`)?`text-[#7c3aed] bg-[#f5f3ff]`:e.startsWith(`+++ `)||e.startsWith(`--- `)?`text-[#1d4ed8] bg-[#eff6ff]`:e.startsWith(`+`)?`text-[#15803d] bg-[#f0fdf4]`:e.startsWith(`-`)?`text-[#b91c1c] bg-[#fef2f2]`:`text-[var(--console-text)]`}function Yr({text:e}){let t=e.split(`
|
|
31
|
-
`),n=new Map;return(0,R.jsx)(`pre`,{className:`console-mono max-h-[420px] overflow-auto whitespace-pre rounded-sm border border-[var(--console-border)] bg-[#fafafa] p-3 text-xs leading-relaxed`,children:t.map(e=>{let t=n.get(e)??0;return n.set(e,t+1),(0,R.jsx)(`span`,{className:`block rounded-[2px] px-1 ${Jr(e)}`,children:e||` `},qr(e,t))})})}function Xr(e){let t=e.text||`No output captured.`;return!e.isCode||e.language===`text`?(0,R.jsx)(`pre`,{className:`console-mono max-h-[420px] overflow-auto whitespace-pre-wrap break-all p-3 text-xs leading-relaxed text-[var(--console-text)]`,children:t}):e.language===`diff`?(0,R.jsx)(Yr,{text:t}):(0,R.jsx)(`div`,{className:`max-h-[420px] overflow-auto bg-[#fafafa]`,children:(0,R.jsx)(Kr,{language:e.language,text:t})})}function Zr({sections:e}){return(0,R.jsx)(`div`,{className:`space-y-3`,children:e.map(e=>(0,R.jsxs)(`div`,{className:`overflow-hidden rounded-sm border border-[var(--console-border)] bg-[#fafafa]`,children:[(0,R.jsx)(`div`,{className:`border-b border-[var(--console-border)] bg-[var(--console-surface-muted)] px-3 py-1.5`,children:(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-white px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-[var(--console-muted)]`,children:e.operation}),(0,R.jsx)(`span`,{className:`console-mono text-[11px] font-semibold text-[var(--console-muted)]`,children:e.label})]})}),Xr(e)]},`${e.operation}:${e.label}:${e.language}`))})}function Qr({questions:e}){return(0,R.jsx)(`div`,{className:`space-y-3`,children:e.map(e=>(0,R.jsxs)(`div`,{className:`overflow-hidden rounded-sm border border-[var(--console-border)] bg-[#fafafa]`,children:[(0,R.jsxs)(`div`,{className:`border-b border-[var(--console-border)] bg-[var(--console-surface-muted)] px-3 py-2`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.header?(0,R.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-white px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-[var(--console-muted)]`,children:e.header}):null,e.answers.length>0?(0,R.jsx)(`span`,{className:`console-mono text-[11px] font-semibold text-[var(--console-success)]`,children:`Answered`}):(0,R.jsx)(`span`,{className:`console-mono text-[11px] font-semibold text-[var(--console-muted)]`,children:`Pending`})]}),(0,R.jsx)(`p`,{className:`mt-2 text-sm leading-relaxed text-[var(--console-text)]`,children:e.question})]}),(0,R.jsx)(`div`,{className:`space-y-2 p-3`,children:e.options.map(t=>{let n=e.answers.includes(t.label);return(0,R.jsxs)(`div`,{className:`rounded-sm border px-3 py-2 ${n?`border-[var(--console-success-border)] bg-[var(--console-success-bg)]`:`border-[var(--console-border)] bg-white`}`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`console-mono text-xs font-semibold ${n?`text-[var(--console-success)]`:`text-[var(--console-text)]`}`,children:t.label}),t.recommended?(0,R.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-1.5 py-0.5 text-[10px] text-[var(--console-muted)]`,children:`Recommended`}):null,n?(0,R.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-success-border)] bg-white px-1.5 py-0.5 text-[10px] text-[var(--console-success)]`,children:`Selected`}):null]}),t.description?(0,R.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-[var(--console-muted)]`,children:t.description}):null]},`${e.question}:${t.label}`)})})]},`${e.header??`question`}:${e.question}`))})}function $r(e){return`${e.label}:${e.lines.map(e=>`${e.type}:${e.text}`).join(`
|
|
32
|
-
`)}`}function ei(e){return e===`add`?`text-[#15803d] bg-[#f0fdf4]`:e===`remove`?`text-[#b91c1c] bg-[#fef2f2]`:`text-[var(--console-text)]`}function ti({blocks:e}){return(0,R.jsx)(`div`,{className:`space-y-3`,children:e.map(e=>{let t=new Map;return(0,R.jsxs)(`div`,{className:`overflow-hidden rounded-sm border border-[var(--console-border)] bg-[#fafafa]`,children:[(0,R.jsx)(`div`,{className:`border-b border-[var(--console-border)] bg-[var(--console-surface-muted)] px-3 py-1.5`,children:(0,R.jsx)(`span`,{className:`console-mono text-[11px] font-semibold text-[var(--console-muted)]`,children:e.label})}),(0,R.jsx)(`pre`,{className:`console-mono max-h-[280px] overflow-auto whitespace-pre p-3 text-xs leading-relaxed`,children:e.lines.map(e=>{let n=`${e.type}:${e.text}`,r=t.get(n)??0;return t.set(n,r+1),(0,R.jsxs)(`span`,{className:`block rounded-[2px] px-1 ${ei(e.type)}`,children:[e.type===`add`?`+`:e.type===`remove`?`-`:` `,e.text||` `]},`${n}:${r}`)})})]},$r(e))})})}function ni({outputContent:e}){if(e.kind===`structured-diff`)return(0,R.jsx)(ti,{blocks:e.blocks});if(e.kind===`file-sections`)return(0,R.jsx)(Zr,{sections:e.sections});if(e.kind===`question-list`)return(0,R.jsx)(Qr,{questions:e.questions});let t=e.text||`No output captured.`;return!e.isCode||e.language===`text`?(0,R.jsx)(`pre`,{className:`console-mono max-h-[420px] overflow-auto whitespace-pre-wrap break-all rounded-sm border border-[var(--console-border)] bg-[#fafafa] p-3 text-xs leading-relaxed text-[var(--console-text)]`,children:t}):e.language===`diff`?(0,R.jsx)(Yr,{text:t}):(0,R.jsx)(`div`,{className:`max-h-[420px] overflow-auto rounded-sm border border-[var(--console-border)] bg-[#fafafa]`,children:(0,R.jsx)(Kr,{language:e.language,text:t})})}var ri=`<turn_aborted>
|
|
33
|
-
The user interrupted the previous turn on purpose. Any running unified exec processes were terminated. If any tools/commands were aborted, they may have partially executed; verify current state before retrying.
|
|
34
|
-
</turn_aborted>`;function ii(e){return e.replace(/\r\n/g,`
|
|
35
|
-
`).trim()}function ai(e,t){if(t.toLowerCase()!==`codex`||e.role!==`user`||e.parts.length!==1)return!1;let[n]=e.parts;return!n||n.type!==`text`||typeof n.text!=`string`?!1:ii(n.text)===ii(ri)}function oi(e){if(typeof e==`string`)return e.trim();if(Array.isArray(e))return e.map(e=>oi(e)).filter(Boolean).join(`
|
|
36
|
-
|
|
37
|
-
`).trim();if(e&&typeof e==`object`){let t=e,n=oi(t.text);if(n)return n;let r=oi(t.content);if(r)return r}return``}function si(e){let t=e.approval_status===`fail`?`fail`:`success`,n=oi(t===`fail`?e.output:e.input);return{title:`plan`,secondaryText:void 0,approvalStatus:t,expandable:!!n,contentLabel:t===`fail`?`Rejected`:`Plan`,contentMarkdown:n}}var ci={completed:{label:`Success`,className:`border-[var(--console-success-border)] bg-[var(--console-success-bg)] text-[var(--console-success)]`,icon:h},error:{label:`Failed`,className:`border-[var(--console-error-border)] bg-[var(--console-error-bg)] text-[var(--console-error)]`,icon:b},running:{label:`Running`,className:`border-[var(--console-warning-border)] bg-[var(--console-warning-bg)] text-[var(--console-warning)]`,icon:ye}};function li(e){let t=e?.trim();if(!t)return null;let n=Array.from(new Set((t.match(/"[^"]+"|\S+/g)??[]).map(e=>e.replace(/^"|"$/g,``).trim()).filter(Boolean).filter(e=>!/^OR$/i.test(e))));return n.length===0?null:RegExp(`(${n.map(Wt).join(`|`)})`,`gi`)}function ui(e,t){let n=li(t);return n?e.split(n).map((e,t)=>e.match(n)?(0,R.jsx)(`mark`,{children:e},`${e}-${t}`):(0,R.jsx)(`span`,{children:e},`${e}-${t}`)):e}function di({text:e,highlightQuery:t}){return(0,R.jsx)(ct,{text:e,highlightQuery:t})}function fi({msg:e,blocks:t,toolAnchorIds:n,formatTokens:r,sessionAgentKey:i,baseDirectory:a,highlightQuery:o}){let s=e.role===`user`,c=ai(e,i),l=()=>{let e=i.toLowerCase(),t=L.getAgentName(e),n=L.agents[e]?.icon;return(0,R.jsx)(R.Fragment,{children:n?(0,R.jsx)(`img`,{src:n,alt:t,className:`size-4 rounded-sm object-cover`}):(0,R.jsx)(re,{className:`size-4 text-[var(--console-muted)]`})})},u=e.mode?e.mode.toUpperCase():null,d=e.model||null,f=on(e),p=Wr(e.time_created);return(0,R.jsx)(`article`,{className:`w-full border-l-2 border-[var(--console-thread)] pl-4 pr-3 md:pr-5`,children:(0,R.jsxs)(`div`,{className:`flex gap-4`,children:[(0,R.jsx)(`div`,{className:`shrink-0 pt-1`,children:(0,R.jsx)(`div`,{className:`flex size-8 items-center justify-center rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)]`,children:s?(0,R.jsx)(E,{className:`size-4 text-[var(--console-muted)]`}):l()})}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,R.jsx)(`span`,{className:`console-mono text-sm font-bold tracking-wide text-[var(--console-text)]`,children:f}),(0,R.jsx)(`time`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:p}),u&&(0,R.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-1.5 py-0.5 text-[10px] text-[var(--console-muted)]`,children:u}),d&&(0,R.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-1.5 py-0.5 text-[10px] text-[var(--console-muted)]`,children:d})]}),c?(0,R.jsx)(pi,{}):t.map((e,t)=>e.type===`reasoning`?(0,R.jsx)(mi,{parts:e.parts,highlightQuery:o},t):e.type===`plan`?(0,R.jsx)(gi,{parts:e.parts,highlightQuery:o},t):e.type===`tool`?(0,R.jsx)(hi,{parts:e.parts,toolAnchorIds:n,sessionAgentKey:i,baseDirectory:a,highlightQuery:o},t):(0,R.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4 shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:(0,R.jsx)(`div`,{className:`console-markdown text-sm leading-relaxed text-[var(--console-text)]`,children:e.parts.map((e,t)=>(0,R.jsx)(di,{text:At(e.text),highlightQuery:o},t))})},t)),!s&&(e.tokens||e.cost)&&(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.tokens?.input?(0,R.jsxs)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] text-[var(--console-muted)]`,children:[`INPUT `,r(e.tokens.input)]}):null,e.tokens?.output?(0,R.jsxs)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] text-[var(--console-muted)]`,children:[`OUTPUT `,r(e.tokens.output)]}):null,e.tokens?.reasoning?(0,R.jsxs)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] text-[var(--console-muted)]`,children:[`REASONING `,r(e.tokens.reasoning)]}):null,e.cost?(0,R.jsxs)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] text-[var(--console-muted)]`,children:[e.cost_source===`estimated`?`EST COST`:`COST`,` $`,e.cost.toFixed(4)]}):null]})]})]})})}function pi(){return(0,R.jsx)(`div`,{className:`space-y-2`,children:(0,R.jsx)(`div`,{className:`flex flex-wrap items-start gap-2`,children:(0,R.jsx)(`div`,{className:`w-full rounded-sm border border-[var(--console-border-strong)] bg-white px-3 py-2 text-left shadow-[2px_2px_0_0_rgba(15,23,42,0.05)] md:w-[560px]`,children:(0,R.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,R.jsx)(l,{className:`mt-0.5 size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,R.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:`abort`})})]})})})})}function mi({parts:e,highlightQuery:t}){let[n,r]=(0,N.useState)(!1),i=e.map(e=>At(e.text)).filter(Boolean).join(`
|
|
38
|
-
|
|
39
|
-
`);return(0,R.jsxs)(`div`,{className:`overflow-hidden rounded-sm border border-[var(--console-thinking-border)] bg-[var(--console-thinking-bg)]`,children:[(0,R.jsxs)(`div`,{className:`flex cursor-pointer items-center justify-between bg-[var(--console-surface-muted)] px-3 py-2`,onClick:()=>r(!n),children:[(0,R.jsxs)(`span`,{className:`console-mono flex items-center gap-2 text-xs font-medium text-[var(--console-muted)]`,children:[(0,R.jsx)(d,{className:`size-3.5`}),`Thinking`]}),(0,R.jsx)(`span`,{className:`text-[var(--console-muted)]`,children:n?(0,R.jsx)(_,{className:`w-4 h-4`}):(0,R.jsx)(x,{className:`w-4 h-4`})})]}),n&&(0,R.jsx)(`div`,{className:`border-t border-dashed border-[var(--console-thinking-border)] px-4 py-3`,children:(0,R.jsx)(`div`,{className:`console-mono whitespace-pre-wrap text-xs leading-relaxed text-[var(--console-muted)]`,children:ui(i,t)})})]})}function hi({parts:e,toolAnchorIds:t,sessionAgentKey:n,baseDirectory:r,highlightQuery:i}){return(0,R.jsx)(`div`,{className:`space-y-2`,children:(0,R.jsx)(`div`,{className:`space-y-2`,children:e.map((e,a)=>(0,R.jsx)(vi,{tool:e,anchorId:t.get(e),sessionAgentKey:n,baseDirectory:r,highlightQuery:i},a))})})}function gi({parts:e,highlightQuery:t}){return(0,R.jsx)(`div`,{className:`space-y-2`,children:e.map((e,n)=>(0,R.jsx)(_i,{part:e,highlightQuery:t},n))})}function _i({part:e,highlightQuery:t}){let[n,r]=(0,N.useState)(!1),i=si(e),a=i.approvalStatus===`fail`?ci.error:ci.completed,o=a.icon;return(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2`,children:[(0,R.jsx)(`div`,{className:`w-full md:w-[560px] rounded-sm border border-[var(--console-border-strong)] bg-white px-3 py-2 text-left shadow-[2px_2px_0_0_rgba(15,23,42,0.05)] ${i.expandable?`transition-colors hover:bg-[var(--console-surface-muted)]`:``}`,children:i.expandable?(0,R.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-2 text-left`,onClick:()=>r(!n),children:[(0,R.jsx)(c,{className:`mt-0.5 size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,R.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:i.title})}),(0,R.jsx)(`span`,{className:`mt-0.5 shrink-0 text-[var(--console-muted)]`,children:n?(0,R.jsx)(_,{className:`size-3.5`}):(0,R.jsx)(x,{className:`size-3.5`})})]}):(0,R.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,R.jsx)(c,{className:`mt-0.5 size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,R.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:i.title})})]})}),(0,R.jsxs)(`span`,{className:`console-mono inline-flex items-center gap-1 rounded-sm border px-2 py-0.5 text-[10px] font-bold uppercase tracking-wider ${a.className}`,children:[(0,R.jsx)(o,{className:`size-3`}),a.label]})]}),i.expandable&&n?(0,R.jsxs)(`div`,{className:`overflow-hidden rounded-sm border border-[var(--console-border)] bg-white shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:[(0,R.jsx)(`div`,{className:`border-b border-[var(--console-border)] bg-[var(--console-surface-muted)] px-3 py-1.5`,children:(0,R.jsx)(`span`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:i.contentLabel})}),(0,R.jsx)(`div`,{className:`p-4`,children:(0,R.jsx)(`div`,{className:`console-markdown text-sm leading-relaxed text-[var(--console-text)]`,children:(0,R.jsx)(di,{text:i.contentMarkdown,highlightQuery:t})})})]}):null]})}function vi({tool:e,anchorId:t,sessionAgentKey:n,baseDirectory:r,highlightQuery:i}){let[a,o]=(0,N.useState)(!1),s=an(e),c=zr(n,e,s,r),l=pn(s.inputText||`{}`,r),u=ci[s.status],d=u.icon,f=c.Icon;return(0,R.jsxs)(`div`,{id:t,className:`scroll-mt-6 space-y-2`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2`,children:[(0,R.jsx)(`div`,{className:`w-full md:w-[560px] rounded-sm border border-[var(--console-border-strong)] bg-white px-3 py-2 text-left shadow-[2px_2px_0_0_rgba(15,23,42,0.05)] ${c.expandable?`transition-colors hover:bg-[var(--console-surface-muted)]`:``}`,children:c.expandable?(0,R.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-2 text-left`,onClick:()=>o(!a),children:[(0,R.jsx)(f,{className:`mt-0.5 size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:c.title}),c.secondaryText?(0,R.jsx)(`span`,{className:`console-mono mt-0.5 block whitespace-pre-wrap break-words text-xs leading-relaxed text-[var(--console-muted)]`,children:ui(c.secondaryText,i)}):null]}),(0,R.jsx)(`span`,{className:`mt-0.5 shrink-0 text-[var(--console-muted)]`,children:a?(0,R.jsx)(_,{className:`size-3.5`}):(0,R.jsx)(x,{className:`size-3.5`})})]}):(0,R.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,R.jsx)(f,{className:`mt-0.5 size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:c.title}),c.secondaryText?(0,R.jsx)(`span`,{className:`console-mono mt-0.5 block whitespace-pre-wrap break-words text-xs leading-relaxed text-[var(--console-muted)]`,children:ui(c.secondaryText,i)}):null]})]})}),(0,R.jsxs)(`span`,{className:`console-mono inline-flex items-center gap-1 rounded-sm border px-2 py-0.5 text-[10px] font-bold uppercase tracking-wider ${u.className}`,children:[(0,R.jsx)(d,{className:`size-3 ${s.status===`running`?`animate-spin`:``}`}),u.label]})]}),c.expandable&&a?(0,R.jsxs)(`div`,{className:`overflow-hidden rounded-sm border border-[var(--console-border)] bg-white shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:[(0,R.jsx)(`div`,{className:`border-b border-[var(--console-border)] bg-[var(--console-surface-muted)] px-3 py-1.5`,children:(0,R.jsx)(`span`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:`Output`})}),(0,R.jsxs)(`div`,{className:`space-y-3 p-3`,children:[c.details.length>0?(0,R.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[#fafafa] px-3 py-2`,children:(0,R.jsx)(`div`,{className:`space-y-2`,children:c.details.map(e=>(0,R.jsxs)(`div`,{className:`flex flex-col gap-1 md:flex-row md:items-start md:gap-3`,children:[(0,R.jsx)(`span`,{className:`console-mono shrink-0 text-[11px] font-semibold uppercase tracking-wide text-[var(--console-muted)] md:w-24`,children:e.label}),(0,R.jsx)(`span`,{className:`console-mono whitespace-pre-wrap break-all text-xs leading-relaxed text-[var(--console-text)]`,children:ui(e.value,i)})]},`${e.label}:${e.value}`))})}):null,(0,R.jsx)(ni,{outputContent:c.outputContent})]}),c.showInputPreview?(0,R.jsxs)(`div`,{className:`border-t border-[var(--console-border)] bg-[#fafafa] px-3 py-2`,children:[(0,R.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:`Input Preview`}),(0,R.jsx)(`pre`,{className:`console-mono mt-1 max-h-[200px] overflow-x-auto whitespace-pre-wrap break-all text-xs leading-relaxed text-[var(--console-muted)]`,children:ui(l,i)})]}):null]}):null]})}var yi=32,bi=280,xi=6;function Si(e){return e===window}function Ci(e,t){let n=[],r=0;for(let i=0;i<e;i+=1){let a=t[i]??bi,o=r,s=o+a;n.push({start:o,end:s}),r=s+(i===e-1?0:yi)}return{items:n,totalSize:r}}function wi(e,t){let n=0,r=e.length;for(;n<r;){let i=Math.floor((n+r)/2),a=e[i];a&&a.end<t?n=i+1:r=i}return n}function Ti(e,t){let n=0,r=e.length;for(;n<r;){let i=Math.floor((n+r)/2),a=e[i];a&&a.start<=t?n=i+1:r=i}return n}function Ei(e){let t=e.parentElement;for(;t;){let{overflowY:e}=window.getComputedStyle(t);if(e===`auto`||e===`scroll`||e===`overlay`)return t;t=t.parentElement}return window}function Di(e){return Si(e)?window.scrollY:e.scrollTop}function Oi(e){return Si(e)?window.innerHeight||900:e.clientHeight}function ki(e,t){if(Si(t))return e.getBoundingClientRect().top+window.scrollY;let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();return t.scrollTop+r.top-n.top}function Ai(e,t){if(Si(e)){window.scrollTo({top:t,behavior:`auto`});return}e.scrollTo({top:t,behavior:`auto`})}function ji({messages:e,toolAnchorIds:t,sessionAgentKey:n,baseDirectory:r,highlightQuery:i,apiRef:a}){let o=e.length>80;return(0,N.useEffect)(()=>{o||(a.current=null)},[a,o]),o?(0,R.jsx)(Mi,{messages:e,toolAnchorIds:t,sessionAgentKey:n,baseDirectory:r,highlightQuery:i,apiRef:a}):(0,R.jsx)(`div`,{className:`flex min-w-0 flex-col gap-8`,children:e.map(({msg:e,blocks:a,index:o})=>(0,R.jsx)(fi,{msg:e,blocks:a,toolAnchorIds:t,formatTokens:Ur,sessionAgentKey:n,baseDirectory:r,highlightQuery:i},`${e.id}:${o}`))})}function Mi({messages:e,toolAnchorIds:t,sessionAgentKey:n,baseDirectory:r,highlightQuery:i,apiRef:a}){let o=(0,N.useRef)(null),s=(0,N.useRef)(null),[c,l]=(0,N.useState)([]),[u,d]=(0,N.useState)(null),[f,p]=(0,N.useState)(()=>({scrollTop:0,height:900,listTop:0})),m=(0,N.useRef)(f);(0,N.useEffect)(()=>{m.current=f},[f]);let h=(0,N.useCallback)(()=>{if(typeof window>`u`)return;let e=o.current,t=e?Ei(e):window;s.current=t;let n=e?ki(e,t):0,r={scrollTop:Di(t),height:Oi(t),listTop:n},i=m.current;Math.abs(i.scrollTop-r.scrollTop)<1&&Math.abs(i.height-r.height)<1&&Math.abs(i.listTop-r.listTop)<1||(m.current=r,p(r))},[]);(0,N.useEffect)(()=>{h();let e=s.current??window,t=0,n=()=>{t||=requestAnimationFrame(()=>{t=0,h()})};e.addEventListener(`scroll`,n,{passive:!0}),window.addEventListener(`resize`,n);let r=window.setInterval(h,100),i=null;return typeof ResizeObserver<`u`&&(i=new ResizeObserver(n),o.current&&i.observe(o.current),Si(e)||i.observe(e),document.body&&i.observe(document.body)),()=>{t&&cancelAnimationFrame(t),i?.disconnect(),window.clearInterval(r),e.removeEventListener(`scroll`,n),window.removeEventListener(`resize`,n)}},[h]),(0,N.useEffect)(()=>{l([]),d(null),h()},[e,h]);let g=(0,N.useMemo)(()=>Ci(e.length,c),[c,e.length]),_=(0,N.useCallback)((e,t)=>{let n=Math.ceil(t);!Number.isFinite(n)||n<=0||l(t=>{let r=t[e];if(r!=null&&Math.abs(r-n)<=1)return t;let i=[...t];return i[e]=n,i})},[]),v=(0,N.useMemo)(()=>{if(e.length===0)return[];let t=Math.max(0,f.scrollTop-f.listTop),n=t+f.height,r=Math.max(0,wi(g.items,t)-xi),i=Math.min(e.length,Ti(g.items,n)+xi),a=[];for(let e=r;e<i;e+=1){let t=g.items[e];t&&a.push({index:e,start:t.start})}if(u!=null&&u>=0&&u<e.length){let e=g.items[u];e&&!a.some(e=>e.index===u)&&(a.push({index:u,start:e.start}),a.sort((e,t)=>e.start-t.start))}return a},[u,g,e.length,f]),y=(0,N.useCallback)(e=>{if(typeof window>`u`)return;let t=g.items[e];if(!t)return;d(e);let n=o.current,r=n?Ei(n):s.current??window;s.current=r;let i=n?ki(n,r):0,a=Math.max(0,i+t.start-24);Ai(r,a);let c={scrollTop:a,height:Oi(r),listTop:i};m.current=c,p(c)},[g.items]);return(0,N.useEffect)(()=>(a.current={scrollToIndex:y},()=>{a.current?.scrollToIndex===y&&(a.current=null)}),[a,y]),(0,R.jsx)(`div`,{ref:o,className:`relative min-w-0`,style:{height:Math.max(1,g.totalSize)},children:v.map(({index:a,start:o})=>{let s=e[a];return s?(0,R.jsx)(Ni,{index:a,top:o,onMeasure:_,children:(0,R.jsx)(fi,{msg:s.msg,blocks:s.blocks,toolAnchorIds:t,formatTokens:Ur,sessionAgentKey:n,baseDirectory:r,highlightQuery:i})},`${s.msg.id}:${s.index}`):null})})}function Ni({index:e,top:t,onMeasure:n,children:r}){let i=(0,N.useRef)(null);return(0,N.useLayoutEffect)(()=>{let t=i.current;if(!t)return;let r=()=>n(e,t.getBoundingClientRect().height);if(r(),typeof ResizeObserver>`u`)return;let a=new ResizeObserver(r);return a.observe(t),()=>a.disconnect()},[e,n]),(0,R.jsx)(`div`,{ref:i,className:`absolute left-0 top-0 w-full`,style:{transform:`translateY(${t}px)`},children:r})}var Pi={bugfix:`bugfix`,refactoring:`refactoring`,"feature-dev":`feature-dev`,testing:`testing`,docs:`docs`,"git-ops":`git-ops`,"build-deploy":`build-deploy`,exploration:`exploration`,planning:`planning`},Fi={bugfix:{text:`#B42318`,border:`#FECDCA`,background:`#FEF3F2`,bar:`#F04438`},refactoring:{text:`#6941C6`,border:`#D9D6FE`,background:`#F4F3FF`,bar:`#7A5AF8`},"feature-dev":{text:`#175CD3`,border:`#B2DDFF`,background:`#EFF8FF`,bar:`#2E90FA`},testing:{text:`#027A48`,border:`#ABEFC6`,background:`#ECFDF3`,bar:`#12B76A`},docs:{text:`#B54708`,border:`#FEDF89`,background:`#FFFAEB`,bar:`#F79009`},"git-ops":{text:`#3538CD`,border:`#C7D7FE`,background:`#EEF4FF`,bar:`#444CE7`},"build-deploy":{text:`#C4320A`,border:`#F9DBAF`,background:`#FEF6EE`,bar:`#EF6820`},exploration:{text:`#0E7090`,border:`#A5F0FC`,background:`#ECFDFF`,bar:`#06AED4`},planning:{text:`#C11574`,border:`#FCCEEE`,background:`#FDF2FA`,bar:`#EE46BC`}};function Ii(e){return Fi[e]}function Li(e){let t=Ii(e);return{color:t.text,borderColor:t.border,backgroundColor:t.background}}function Ri({tags:e,limit:t=4,className:n=``}){if(!e||e.length===0)return null;let r=e.slice(0,t),i=e.length-r.length;return(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-1 ${n}`,children:[r.map(e=>(0,R.jsx)(`span`,{className:`console-mono rounded-sm border px-1.5 py-0.5 text-[10px] font-medium`,style:Li(e),children:Pi[e]},e)),i>0?(0,R.jsxs)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-1.5 py-0.5 text-[10px] text-[var(--console-muted)]`,children:[`+`,i]}):null]})}function zi(e,t){return e?Math.abs(e.receiptWidth-t.receiptWidth)>.5||Math.abs(e.receiptHeight-t.receiptHeight)>.5||Math.abs(e.startX-t.startX)>.5||Math.abs(e.startY-t.startY)>.5:!0}var X=18,Z=42,Bi=5,Q=270,Vi=500,Hi=2;function Ui(e){return Math.round(e??0).toLocaleString(`en-US`)}function Wi(e){return`$${(e??0).toFixed(4)}`}function Gi(e){return new Date(e).toLocaleString(`en-US`,{month:`short`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`})}function Ki(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function qi(e){let t=e||1;return()=>(t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296)}function Ji(e){let t=[{label:`User`,count:e.counts.user},{label:`Agent Responses`,count:e.counts.agent_message},{label:`Thinking`,count:e.counts.thinking},{label:`Plans`,count:e.counts.plan},{label:`Tools`,count:e.counts.tools_all}].filter(e=>e.count>0),n=e.tools.map(e=>({label:e.label,count:e.count})),r=Math.max(0,9-t.length),i=n.length>r?n.slice(0,Math.max(0,r-1)):n,a=n.slice(i.length).reduce((e,t)=>e+t.count,0);return a>0&&i.push({label:`Other tools`,count:a}),[...t,...i].slice(0,9)}function Yi(e){return!e||e.length===0?`SESSION ACTIVITY RECEIPT`:e.map(e=>Pi[e]).join(` / `)}function Xi(e,t){let n=e.slug?.split(`/`)[0]||`codesesh`;return{id:e.id,title:e.title||`Untitled session`,agent:n,updatedAt:e.time_updated??e.time_created,tags:e.smart_tags,stats:e.stats,items:Ji(t)}}function Zi(e,t,n,r,i){let a=t.toUpperCase(),o=n.toUpperCase();e.fillText(a,18,r),e.fillText(o,i-18-e.measureText(o).width,r)}function Qi(e,t,n){if(e.measureText(t).width<=n)return t;let r=t;for(;r.length>1&&e.measureText(`${r}...`).width>n;)r=r.slice(0,-1);return`${r}...`}function $i(e,t,n,r){let i=t.toUpperCase().split(/\s+/).filter(Boolean),a=[],o=``;for(let t of i){let i=o?`${o} ${t}`:t;if(e.measureText(i).width<=n){o=i;continue}if(o?(a.push(o),o=t):(a.push(Qi(e,t,n)),o=``),a.length===r)break}return a.length<r&&o&&a.push(o),a.length>0&&a.length===r&&(a[a.length-1]=Qi(e,a[a.length-1]??``,n)),a.slice(0,r)}function ea(e){let t=document.createElement(`canvas`);t.width=Q*Hi,t.height=Vi*Hi;let n=t.getContext(`2d`);if(!n)return t;n.scale(Hi,Hi);let r=n.createLinearGradient(0,0,Q,Vi);r.addColorStop(0,`#ffffff`),r.addColorStop(.55,`#fafaf6`),r.addColorStop(1,`#f2f2ec`),n.fillStyle=r,n.fillRect(0,0,Q,Vi);let i=qi(Ki(e.id));n.fillStyle=`rgba(0, 0, 0, 0.035)`;for(let e=0;e<1200;e+=1)n.globalAlpha=.12+i()*.14,n.fillRect(i()*Q,i()*Vi,.7,.7);n.globalAlpha=1,n.fillStyle=`rgba(0, 0, 0, 0.78)`,n.font=`700 18px 'Courier New', monospace`,n.textAlign=`center`,n.fillText(`CODESESH MART`,Q/2,34),n.font=`11px 'Courier New', monospace`,n.fillText(Qi(n,Yi(e.tags).toUpperCase(),Q-36),Q/2,51),n.strokeStyle=`rgba(0, 0, 0, 0.5)`,n.lineWidth=1,n.setLineDash([4,4]),n.beginPath(),n.moveTo(18,66),n.lineTo(Q-18,66),n.stroke(),n.setLineDash([]),n.textAlign=`left`,n.fillStyle=`rgba(0, 0, 0, 0.74)`,n.font=`11px 'Courier New', monospace`,Zi(n,`Agent`,e.agent,88,Q),Zi(n,`Updated`,Gi(e.updatedAt),104,Q),Zi(n,`Session`,`#${e.id.slice(0,8)}`,120,Q),n.setLineDash([2,3]),n.beginPath(),n.moveTo(18,140),n.lineTo(Q-18,140),n.stroke(),n.setLineDash([]),n.font=`700 12px 'Courier New', monospace`,n.fillText(`SESSION TOC RECEIPT LIST`,18,163),n.font=`11px 'Courier New', monospace`;let a=185;for(let t of e.items){let e=Ui(t.count);n.fillText(Qi(n,t.label,168),18,a),n.fillText(e,Q-18-n.measureText(e).width,a),a+=17}return n.strokeStyle=`rgba(0, 0, 0, 0.62)`,n.lineWidth=1.5,n.beginPath(),n.moveTo(18,a+5),n.lineTo(Q-18,a+5),n.stroke(),a+=26,Zi(n,`Input tokens`,Ui(e.stats.total_input_tokens),a,Q),a+=16,Zi(n,`Output tokens`,Ui(e.stats.total_output_tokens),a,Q),a+=16,Zi(n,`Messages`,Ui(e.stats.message_count),a,Q),a+=22,n.font=`700 13px 'Courier New', monospace`,Zi(n,`TOTAL COST`,Wi(e.stats.total_cost),a,Q),n.strokeStyle=`rgba(0, 0, 0, 0.45)`,n.setLineDash([4,4]),n.beginPath(),n.moveTo(18,a+18),n.lineTo(Q-18,a+18),n.stroke(),n.setLineDash([]),n.font=`10px 'Courier New', monospace`,n.textAlign=`center`,n.fillStyle=`rgba(0, 0, 0, 0.62)`,$i(n,e.title,Q-36,2).forEach((e,t)=>{n.fillText(e,Q/2,a+38+t*13)}),t}function $(e,t){return e*X+t}function ta(e){let{receiptWidth:t,receiptHeight:n,startX:r,startY:i}=e,a=t/(X-1),o=n/(Z-1),s=[],c=[];for(let e=0;e<Z;e+=1)for(let t=0;t<X;t+=1){let n=r+t*a,c=i+e*o;s.push({x:n,y:c,oldX:n,oldY:c,fixedX:e===0?n:null,fixedY:e===0?c:null})}let l=(e,t,n)=>{let r=s[e],i=s[t];!r||!i||c.push({a:e,b:t,length:Math.hypot(i.x-r.x,i.y-r.y),stiffness:n})};for(let e=0;e<Z;e+=1)for(let t=0;t<X;t+=1){let n=$(e,t);t<X-1&&l(n,$(e,t+1),.98),e<Z-1&&l(n,$(e+1,t),.92),e<Z-1&&t<X-1&&(l(n,$(e+1,t+1),.46),l($(e+1,t),$(e,t+1),.46)),t<X-2&&l(n,$(e,t+2),.35),e<Z-2&&l(n,$(e+2,t),.28)}return{particles:s,constraints:c,receiptWidth:t,receiptHeight:n}}function na(e,t){let n=t.receiptWidth/(X-1);for(let r=0;r<X;r+=1){let i=e[r];i&&(i.fixedX=t.startX+r*n,i.fixedY=t.startY)}}function ra(e){for(let t=0;t<X;t+=1){let n=e[t];!n||n.fixedX==null||n.fixedY==null||(n.x=n.fixedX,n.y=n.fixedY,n.oldX=n.fixedX,n.oldY=n.fixedY)}}function ia(e,t){let n=e[t.a],r=e[t.b];if(!n||!r)return;let i=r.x-n.x,a=r.y-n.y,o=Math.hypot(i,a);if(o<1e-4)return;let s=(o-t.length)/o*t.stiffness,c=n.fixedX!=null&&n.fixedY!=null,l=r.fixedX!=null&&r.fixedY!=null,u=c?0:l?1:.5,d=l?0:c?1:.5,f=i*s,p=a*s;c||(n.x+=f*u,n.y+=p*u),l||(r.x-=f*d,r.y-=p*d)}function aa(e,t,n,r,i){let a=n[$(r,i)],o=n[$(r,i+1)],s=n[$(r+1,i)],c=n[$(r+1,i+1)];if(!a||!o||!s||!c)return;let l=i/(X-1)*t.width,u=r/(Z-1)*t.height,d=t.width/(X-1),f=t.height/(Z-1);e.save(),e.beginPath(),e.moveTo(a.x,a.y),e.lineTo(o.x,o.y),e.lineTo(c.x,c.y),e.lineTo(s.x,s.y),e.closePath(),e.clip(),e.transform((o.x-a.x)/d,(o.y-a.y)/d,(s.x-a.x)/f,(s.y-a.y)/f,a.x,a.y),e.drawImage(t,l,u,d+1,f+1,0,0,d+1,f+1),e.restore();let p=Math.atan2(o.y-a.y,o.x-a.x),m=Math.hypot(s.x-a.x,s.y-a.y)/(Vi/(Z-1)),h=Math.sin(p)*.08+(m-1)*.16;Math.abs(h)<.01||(e.save(),e.beginPath(),e.moveTo(a.x,a.y),e.lineTo(o.x,o.y),e.lineTo(c.x,c.y),e.lineTo(s.x,s.y),e.closePath(),e.fillStyle=h>0?`rgba(255,255,255,${h})`:`rgba(0,0,0,${-h})`,e.fill(),e.restore())}function oa(e,t,n){let r=null,i=44;for(let a=X;a<e.length;a+=1){let o=e[a];if(!o)continue;let s=Math.hypot(o.x-t,o.y-n);s<i&&(i=s,r=a)}return r}function sa({session:e,toc:t,minWidthQuery:n=`(min-width: 1025px)`}){let r=(0,N.useRef)(null),i=(0,N.useRef)(null),a=(0,N.useRef)(null),o=(0,N.useMemo)(()=>Xi(e,t),[e,t]);return(0,N.useLayoutEffect)(()=>{let e=r.current,t=i.current,s=a.current;if(!e||!t||!s)return;let c=e.getContext(`2d`,{alpha:!0});if(!c)return;let l={id:null,x:0,y:0,prevX:0,prevY:0,vx:0,vy:0,grabbedIndex:null},u=ea(o),d=0,f=0,p=0,m=ta({receiptWidth:Q,receiptHeight:Vi,startX:0,startY:32}),h=performance.now(),g=null,_=0,v=0,y=!1,ee=!0,b=!1,x=window.matchMedia(n),S=()=>x.matches&&document.visibilityState===`visible`&&ee,te=()=>{let e=t.getBoundingClientRect(),n=Math.max(280,e.width||320),r=Math.min(Q,n-34);return{receiptWidth:r,receiptHeight:Math.min(Vi,Math.max(320,p-e.top-42)),startX:e.left+(e.width-r)/2,startY:e.top+32}},ne=t=>{y!==t&&(y=t,e.style.visibility=t?`visible`:`hidden`,s.style.visibility=t?`visible`:`hidden`)},re=()=>{b=!1,d&&=(window.cancelAnimationFrame(d),0),ne(!1)},C=(e,t=performance.now())=>{m=ta(e),g=e,h=t},ie=()=>{let t=window.devicePixelRatio||1;f=Math.max(1,window.innerWidth),p=Math.max(1,window.innerHeight),e.width=Math.floor(f*t),e.height=Math.floor(p*t),c.setTransform(t,0,0,t,0,0),_=0,v=0,ne(!1),C(te()),S()&&ae()},ae=()=>{b||!S()||(b=!0,d=window.requestAnimationFrame(pe))},oe=()=>{S()?ie():re()},se=e=>({x:e.clientX,y:e.clientY}),w=e=>{if(e.button!==0)return;let t=se(e),n=oa(m.particles,t.x,t.y);n!=null&&(e.preventDefault(),s.setPointerCapture(e.pointerId),l.id=e.pointerId,l.x=t.x,l.y=t.y,l.prevX=t.x,l.prevY=t.y,l.vx=0,l.vy=0,l.grabbedIndex=n,v=0,ae())},T=e=>{if(l.id!==e.pointerId)return;let t=se(e);l.vx=t.x-l.prevX,l.vy=t.y-l.prevY,l.prevX=t.x,l.prevY=t.y,l.x=t.x,l.y=t.y},E=e=>{if(l.id!==e.pointerId)return;let t=l.grabbedIndex==null?null:m.particles[l.grabbedIndex];t&&(t.oldX=t.x-l.vx*.9,t.oldY=t.y-l.vy*.9),l.id=null,l.grabbedIndex=null},ce=e=>{let t=(e-h)/1e3;for(let e=X;e<m.particles.length;e+=1){let n=m.particles[e];if(!n)continue;let r=(n.x-n.oldX)*.985,i=(n.y-n.oldY)*.985;n.oldX=n.x,n.oldY=n.y,n.x+=r+Math.sin(t*1.7+e*.19)*.018,n.y+=i+.22}let n=l.grabbedIndex==null?null:m.particles[l.grabbedIndex];n&&(n.x+=(l.x-n.x)*.72,n.y+=(l.y-n.y)*.72)},le=()=>{for(let e=0;e<Bi;e+=1){ra(m.particles);for(let e of m.constraints)ia(m.particles,e)}ra(m.particles)},ue=()=>{let e=1/0,t=1/0,n=-1/0,r=-1/0;for(let i of m.particles)e=Math.min(e,i.x),t=Math.min(t,i.y),n=Math.max(n,i.x),r=Math.max(r,i.y);s.style.transform=`translate3d(${e-20}px, ${t-20}px, 0)`,s.style.width=`${n-e+40}px`,s.style.height=`${r-t+40}px`},D=()=>{let e=m.particles[0],t=m.particles[X-1],n=m.particles[Z*X-1],r=m.particles[(Z-1)*X];!e||!t||!n||!r||(c.save(),c.shadowColor=`rgba(0,0,0,0.24)`,c.shadowBlur=24,c.shadowOffsetY=16,c.fillStyle=`rgba(0,0,0,0.14)`,c.beginPath(),c.moveTo(e.x,e.y),c.lineTo(t.x,t.y),c.lineTo(n.x,n.y),c.lineTo(r.x,r.y),c.closePath(),c.fill(),c.restore())},de=()=>{let e=m.particles[0],t=m.particles[X-1];!e||!t||(c.save(),c.strokeStyle=`rgba(0,0,0,0.72)`,c.lineWidth=4,c.lineCap=`round`,c.beginPath(),c.moveTo(e.x-10,e.y-3),c.lineTo(t.x+10,t.y-3),c.stroke(),c.strokeStyle=`rgba(255,255,255,0.55)`,c.lineWidth=1,c.beginPath(),c.moveTo(e.x-8,e.y-5),c.lineTo(t.x+8,t.y-5),c.stroke(),c.restore())},fe=()=>{c.clearRect(0,0,f,p),D();for(let e=0;e<Z-1;e+=1)for(let t=0;t<X-1;t+=1)aa(c,u,m.particles,e,t);de(),ue()},pe=e=>{if(!b)return;if(!S()){re();return}let t=te();if(zi(g,t)&&l.id==null?(_=0,ne(!1),C(t,e)):(_+=1,g=t),na(m.particles,t),ce(e),le(),fe(),v=l.id==null?v+1:0,_>=2&&ne(!0),_>=2&&v>=90){b=!1,d=0;return}d=window.requestAnimationFrame(pe)};ne(!1),S()&&ie();let me=new ResizeObserver(ie);me.observe(t);let O=new IntersectionObserver(([e])=>{ee=!!e?.isIntersecting,oe()});return O.observe(t),x.addEventListener(`change`,oe),document.addEventListener(`visibilitychange`,oe),window.addEventListener(`resize`,oe),s.addEventListener(`pointerdown`,w),s.addEventListener(`pointermove`,T),s.addEventListener(`pointerup`,E),s.addEventListener(`pointercancel`,E),ae(),()=>{re(),me.disconnect(),O.disconnect(),x.removeEventListener(`change`,oe),document.removeEventListener(`visibilitychange`,oe),window.removeEventListener(`resize`,oe),s.removeEventListener(`pointerdown`,w),s.removeEventListener(`pointermove`,T),s.removeEventListener(`pointerup`,E),s.removeEventListener(`pointercancel`,E)}},[n,o]),(0,R.jsxs)(`div`,{ref:i,className:`h-[calc(100dvh-5.5rem)] min-h-[420px]`,children:[(0,R.jsx)(`canvas`,{ref:r,className:`invisible pointer-events-none fixed inset-0 z-[61] block h-screen w-screen touch-none`,"aria-hidden":`true`}),(0,R.jsx)(`div`,{ref:a,className:`invisible fixed left-0 top-0 z-[62] cursor-grab touch-none active:cursor-grabbing`,"aria-label":`Interactive thermal receipt with Verlet paper simulation`})]})}function ca({session:e,toc:t}){let[n,r]=(0,N.useState)(!1),[i,a]=(0,N.useState)(!1);return(0,N.useEffect)(()=>{r(!1)},[e.id]),(0,N.useEffect)(()=>{if(!n){a(!1);return}a(!1);let e=0,t=requestAnimationFrame(()=>{e=requestAnimationFrame(()=>a(!0))}),i=window.matchMedia(`(min-width: 1025px)`),o=()=>{i.matches||r(!1)},s=e=>{e.key===`Escape`&&r(!1)},c=document.body.style.overflow;return document.body.style.overflow=`hidden`,window.addEventListener(`keydown`,s),i.addEventListener(`change`,o),o(),()=>{cancelAnimationFrame(t),e&&cancelAnimationFrame(e),document.body.style.overflow=c,window.removeEventListener(`keydown`,s),i.removeEventListener(`change`,o)}},[n]),(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,"aria-expanded":n,"aria-label":`Open session receipt`,onClick:()=>r(!0),className:`console-mono fixed right-0 top-1/2 z-40 hidden h-32 w-10 -translate-y-1/2 items-center justify-center rounded-l-sm border border-r-0 border-[var(--console-border)] bg-white text-[10px] font-semibold uppercase tracking-[0.14em] text-[var(--console-text)] shadow-[-2px_4px_14px_rgba(15,23,42,0.14)] transition-colors hover:bg-[var(--console-surface-muted)] min-[1025px]:flex`,children:(0,R.jsx)(`span`,{className:`[writing-mode:vertical-rl]`,children:`Receipt`})}),n?(0,R.jsxs)(`div`,{className:`fixed inset-0 z-[60] hidden min-[1025px]:block`,children:[(0,R.jsx)(`button`,{type:`button`,"aria-label":`Close session receipt`,onClick:()=>r(!1),className:`absolute inset-0 bg-black/20`}),(0,R.jsxs)(`aside`,{className:`absolute right-0 top-0 z-10 h-full w-[min(92vw,430px)] border-l border-[var(--console-border)] bg-[var(--console-bg)] p-4 shadow-[-12px_0_32px_rgba(15,23,42,0.18)]`,children:[(0,R.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,R.jsx)(`span`,{className:`console-mono text-xs font-semibold uppercase tracking-[0.16em] text-[var(--console-text)]`,children:`Session Receipt`}),(0,R.jsx)(`button`,{type:`button`,"aria-label":`Close session receipt`,onClick:()=>r(!1),className:`rounded-sm border border-[var(--console-border)] bg-white p-2 text-[var(--console-muted)] transition-colors hover:bg-[var(--console-surface-muted)]`,children:(0,R.jsx)(fe,{className:`size-4`})})]}),i?(0,R.jsx)(gt,{id:`InteractiveReceipt`,children:(0,R.jsx)(sa,{session:e,toc:t},e.id)}):(0,R.jsx)(`div`,{className:`h-[calc(100dvh-5.5rem)] min-h-[420px] rounded-sm border border-[var(--console-border)] bg-white`})]})]}):null]})}function la({toc:e,fileChangeSummary:t,onOpen:n}){let r=bn(t);return(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2 min-[1025px]:hidden`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>n(`toc`),className:`console-mono inline-flex h-9 items-center gap-2 rounded-sm border border-[var(--console-border)] bg-white px-3 text-xs font-semibold uppercase tracking-[0.12em] text-[var(--console-text)] shadow-[0_1px_2px_rgba(15,23,42,0.04)] transition-colors hover:bg-[var(--console-surface-muted)]`,children:[(0,R.jsx)(ee,{className:`size-3.5 text-[var(--console-accent)]`}),`TOC`,(0,R.jsx)(`span`,{className:`text-[var(--console-muted)]`,children:e.counts.tools_all})]}),r>0?(0,R.jsxs)(`button`,{type:`button`,onClick:()=>n(`files`),className:`console-mono inline-flex h-9 items-center gap-2 rounded-sm border border-[var(--console-border)] bg-white px-3 text-xs font-semibold uppercase tracking-[0.12em] text-[var(--console-text)] shadow-[0_1px_2px_rgba(15,23,42,0.04)] transition-colors hover:bg-[var(--console-surface-muted)]`,children:[(0,R.jsx)(D,{className:`size-3.5 text-[var(--console-accent)]`}),`Files`,(0,R.jsx)(`span`,{className:`text-[var(--console-muted)]`,children:r})]}):null]})}function ua({openPanel:e,toc:t,fileChangeSummary:n,baseDirectory:r,selectedFilters:i,onClose:a,onToggle:o,onJumpToAnchor:s}){return(0,N.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&a()},n=document.body.style.overflow,r=window.matchMedia(`(min-width: 1025px)`),i=()=>{r.matches&&a()};return document.body.style.overflow=`hidden`,window.addEventListener(`keydown`,t),r.addEventListener(`change`,i),i(),()=>{document.body.style.overflow=n,window.removeEventListener(`keydown`,t),r.removeEventListener(`change`,i)}},[a,e]),e?(0,R.jsxs)(`div`,{className:`fixed inset-0 z-50 min-[1025px]:hidden`,children:[(0,R.jsx)(`button`,{type:`button`,"aria-label":`Close navigation panel`,onClick:a,className:`absolute inset-0 bg-black/30`}),(0,R.jsxs)(`aside`,{className:`console-scrollbar absolute right-0 top-0 h-full w-[min(90vw,380px)] overflow-y-auto border-l border-[var(--console-border)] bg-[var(--console-bg)] p-3 shadow-[-10px_0_30px_rgba(15,23,42,0.16)]`,children:[(0,R.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,R.jsx)(`span`,{className:`console-mono text-xs font-semibold uppercase tracking-[0.16em] text-[var(--console-text)]`,children:e===`toc`?`Session TOC`:`File Tracker`}),(0,R.jsx)(`button`,{type:`button`,"aria-label":`Close navigation panel`,onClick:a,className:`rounded-sm border border-[var(--console-border)] bg-white p-2 text-[var(--console-muted)] transition-colors hover:bg-[var(--console-surface-muted)]`,children:(0,R.jsx)(fe,{className:`size-4`})})]}),e===`toc`?(0,R.jsx)(kn,{toc:t,selectedFilters:i,onToggle:o}):(0,R.jsx)(xn,{summary:n,baseDirectory:r,onJumpToAnchor:s})]})]}):null}function da(e,t){if(typeof document>`u`)return;let n=document.getElementById(e);if(!n&&t){t();let r=0,i=()=>{if(n=document.getElementById(e),n){n.scrollIntoView({behavior:`smooth`,block:`center`});return}r+=1,r<8&&requestAnimationFrame(i)};requestAnimationFrame(i);return}n&&n.scrollIntoView({behavior:`smooth`,block:`center`})}function fa(e,t){if(!dt())return t();let n=performance.now(),r=t(),i=performance.now();return mt({id:e,source:`custom-timing`,phase:`measure`,actualDuration:Math.round((i-n)*100)/100,baseDuration:0,startTime:n,commitTime:i}),r}function pa({session:e,highlightQuery:t}){let n=(e.slug||``).split(`/`)[0]||L.getDefaultAgentKey()||`claudecode`,r=(0,N.useMemo)(()=>fa(`SessionDetail:normalizeMessages`,()=>sn(e.messages,n)),[e.messages,n]),i=(0,N.useMemo)(()=>fa(`SessionDetail:buildMessageDisplayModels`,()=>Nt(r)),[r]),{toolAnchorIds:a,anchorMessageIndexes:o,summary:s}=(0,N.useMemo)(()=>fa(`SessionDetail:buildFileChangeSummary`,()=>vn(i)),[i]),c=(0,N.useMemo)(()=>fa(`SessionDetail:buildSessionDetailToc`,()=>Tt(i)),[i]),[l,u]=(0,N.useState)(()=>new Set(c.filterIds)),[d,f]=(0,N.useState)(null),p=(0,N.useMemo)(()=>[...c.filterIds].toSorted().join(`|`),[c.filterIds]),m=(0,N.useMemo)(()=>[...l].toSorted().join(`|`),[l]),h=(0,N.useMemo)(()=>fa(`SessionDetail:filterSessionMessages`,()=>kt(i,l)),[i,l]),g=(0,N.useRef)(null),_=(0,N.useMemo)(()=>fa(`SessionDetail:buildAnchorListIndexes`,()=>{let e=new Map;return h.forEach((t,n)=>{e.set(t.index,n)}),e}),[h]),v=(0,N.useMemo)(()=>fa(`SessionDetail:mergeFileActivitySummary`,()=>yn(e.file_activity,s)),[e.file_activity,s]),y=(0,N.useCallback)(e=>{let t=o.get(e),n=t==null?void 0:_.get(t);da(e,()=>{n!=null&&g.current?.scrollToIndex(n)})},[_,o]);return(0,N.useEffect)(()=>{u(new Set(c.filterIds))},[p,c.filterIds]),i.length===0?(0,R.jsx)(`div`,{"data-testid":`session-detail`,className:`mx-auto max-w-4xl rounded-sm border border-[var(--console-border)] bg-white p-6 text-sm text-[var(--console-muted)]`,children:`当前会话暂无可展示的消息内容。`}):(0,R.jsxs)(`div`,{"data-testid":`session-detail`,className:`mx-auto w-full max-w-[1440px] space-y-8 px-2 md:px-4 animate-in fade-in slide-in-from-bottom-2 duration-300`,children:[(0,R.jsx)(ma,{summary:typeof e.summary_files==`string`?e.summary_files:void 0}),(0,R.jsxs)(`div`,{className:`grid gap-6 min-[1025px]:grid-cols-[240px_minmax(0,1fr)] min-[1025px]:items-start min-[1280px]:grid-cols-[220px_minmax(0,1fr)]`,children:[(0,R.jsx)(la,{toc:c,fileChangeSummary:v,onOpen:f}),(0,R.jsx)(ua,{openPanel:d,toc:c,fileChangeSummary:v,baseDirectory:e.directory,selectedFilters:l,onClose:()=>f(null),onToggle:e=>u(t=>En(t,e,c)),onJumpToAnchor:e=>{f(null),y(e)}}),(0,R.jsx)(On,{toc:c,fileChangeSummary:v,baseDirectory:e.directory,selectedFilters:l,onToggle:e=>u(t=>En(t,e,c)),onJumpToAnchor:y}),(0,R.jsx)(`div`,{className:`flex min-w-0 flex-col gap-8`,children:h.length>0?(0,R.jsx)(gt,{id:`MessageList`,detail:{messages:h.length,virtualized:h.length>80},children:(0,R.jsx)(ji,{messages:h,toolAnchorIds:a,sessionAgentKey:n,baseDirectory:e.directory,highlightQuery:t,apiRef:g},`${e.id}:${m}`)}):(0,R.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-6 text-sm text-[var(--console-muted)]`,children:`当前筛选条件下暂无可展示的消息内容。`})})]}),(0,R.jsx)(ca,{session:e,toc:c})]})}function ma({summary:e,defaultExpanded:t=!1}){let n=typeof e==`string`?e.trim():``,[r,i]=(0,N.useState)(t);return n?(0,R.jsxs)(`section`,{className:`rounded-sm border border-[var(--console-border)] bg-white shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:[(0,R.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-4 py-3 text-left`,onClick:()=>i(e=>!e),children:[(0,R.jsxs)(`span`,{className:`console-mono inline-flex items-center gap-2 text-xs font-semibold uppercase tracking-[0.16em] text-[var(--console-text)]`,children:[(0,R.jsx)(D,{className:`size-3.5 text-[var(--console-accent)]`}),`Session Summary`]}),r?(0,R.jsx)(_,{className:`size-3.5 text-[var(--console-muted)]`}):(0,R.jsx)(x,{className:`size-3.5 text-[var(--console-muted)]`})]}),r?(0,R.jsx)(`div`,{className:`border-t border-[var(--console-border)] px-4 py-4`,children:(0,R.jsx)(`div`,{className:`console-markdown text-sm leading-relaxed text-[var(--console-text)]`,children:(0,R.jsx)(ct,{text:n})})}):null]}):null}var ha=[{id:`1`,roleWidth:`w-14`,timeWidth:`w-20`,bodyWidths:[`w-full`,`w-10/12`,`w-7/12`]},{id:`2`,roleWidth:`w-16`,timeWidth:`w-24`,bodyWidths:[`w-9/12`,`w-7/12`]},{id:`3`,roleWidth:`w-14`,timeWidth:`w-16`,bodyWidths:[`w-full`,`w-11/12`,`w-8/12`,`w-5/12`]},{id:`4`,roleWidth:`w-16`,timeWidth:`w-20`,bodyWidths:[`w-10/12`,`w-8/12`]},{id:`5`,roleWidth:`w-14`,timeWidth:`w-24`,bodyWidths:[`w-full`,`w-10/12`,`w-9/12`]}];function ga({className:e}){return(0,R.jsx)(`div`,{className:`rounded-sm bg-[var(--console-border)] ${e}`})}function _a(){return(0,R.jsxs)(`div`,{className:`mx-auto flex min-h-full w-full max-w-5xl flex-col gap-8 px-2 md:px-4`,children:[(0,R.jsx)(`div`,{className:`flex flex-1 flex-col gap-8`,children:ha.map(e=>(0,R.jsx)(`article`,{className:`w-full border-l-2 border-[var(--console-thread)] pl-4 pr-3 md:pr-5`,children:(0,R.jsxs)(`div`,{className:`flex gap-4`,children:[(0,R.jsx)(`div`,{className:`shrink-0 pt-1`,children:(0,R.jsx)(`div`,{className:`flex size-8 items-center justify-center rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)]`,children:(0,R.jsx)(`div`,{className:`size-3.5 rounded-sm bg-[var(--console-border-strong)] animate-pulse`})})}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(ga,{className:`${e.roleWidth} h-3 animate-pulse`}),(0,R.jsx)(ga,{className:`${e.timeWidth} h-2.5 animate-pulse`})]}),(0,R.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4 shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:(0,R.jsx)(`div`,{className:`space-y-2`,children:e.bodyWidths.map(t=>(0,R.jsx)(ga,{className:`${t} h-3 animate-pulse`},`${e.id}-${t}`))})})]})]})},e.id))}),(0,R.jsx)(`div`,{className:`min-h-24 flex-1 rounded-sm border border-[var(--console-border)] bg-white/60 animate-pulse`})]})}function va({active:e,onToggle:t,className:n=``}){return(0,R.jsx)(`button`,{type:`button`,onClick:e=>{e.preventDefault(),e.stopPropagation(),t()},"aria-label":e?`取消收藏会话`:`收藏会话`,title:e?`取消收藏`:`收藏`,className:`inline-flex size-6 shrink-0 items-center justify-center rounded-sm border transition-colors ${n} ${e?`border-[var(--console-border)] bg-[var(--console-surface-muted)] text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] opacity-70 hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)] hover:text-[var(--console-text)] hover:opacity-100`}`,children:(0,R.jsx)(ie,{className:`size-3`,strokeWidth:1.8,fill:e?`currentColor`:`none`})})}function ya(e){return e.total_tokens??e.total_input_tokens+e.total_output_tokens}function ba({label:e,value:t,hint:n}){return(0,R.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,R.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-wider text-[var(--console-muted)]`,children:e}),(0,R.jsx)(`p`,{className:`console-mono mt-2 text-xl font-semibold text-[var(--console-text)]`,children:t}),n?(0,R.jsx)(`p`,{className:`mt-1 text-xs text-[var(--console-muted)]`,children:n}):null]})}function xa({label:e,value:t}){return(0,R.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] p-3`,children:[(0,R.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-wider text-[var(--console-muted)]`,children:e}),(0,R.jsx)(`p`,{className:`console-mono mt-2 break-all text-sm leading-6 text-[var(--console-text)]`,children:t})]})}function Sa({code:e,title:t,description:n,aside:r,iconSrc:i,iconAlt:a}){return(0,R.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border-strong)] bg-white p-5 md:p-6`,children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-5 md:flex-row md:items-start md:justify-between`,children:[(0,R.jsxs)(`div`,{className:`max-w-2xl`,children:[(0,R.jsx)(`span`,{className:`console-mono inline-flex rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] font-semibold uppercase tracking-[0.16em] text-[var(--console-muted)]`,children:e}),(0,R.jsxs)(`div`,{className:`mt-4 flex items-start gap-3`,children:[i?(0,R.jsx)(`img`,{src:i,alt:a||``,className:`mt-1 size-8 shrink-0 object-contain`}):null,(0,R.jsx)(`h2`,{className:`console-mono text-2xl leading-tight font-semibold tracking-tight text-[var(--console-text)] md:text-[2rem]`,children:t})]}),(0,R.jsx)(`p`,{className:`mt-3 max-w-[42rem] text-sm leading-7 text-[var(--console-muted)]`,children:n})]}),(0,R.jsxs)(`div`,{className:`min-w-0 rounded-sm border border-dashed border-[var(--console-border)] bg-[var(--console-surface-muted)] px-4 py-3 md:max-w-xs`,children:[(0,R.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-[0.16em] text-[var(--console-muted)]`,children:`STATUS NOTE`}),(0,R.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-[var(--console-text)]`,children:r})]})]})})}function Ca({agentItems:e}){return(0,R.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,R.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,R.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Known Agents`}),(0,R.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` items`]})]}),(0,R.jsx)(`ul`,{className:`grid gap-2 sm:grid-cols-2`,children:e.map(e=>(0,R.jsx)(`li`,{children:(0,R.jsxs)(C,{to:`/${e.key}`,className:`flex min-h-11 items-center gap-2 rounded-sm border border-transparent px-3 py-2 transition-colors duration-200 hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--console-accent)]`,children:[(0,R.jsx)(`img`,{src:e.icon,alt:e.name,className:`size-4 object-contain`}),(0,R.jsx)(`span`,{className:`console-mono flex-1 text-xs text-[var(--console-text)]`,children:e.name}),(0,R.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:e.count})]})},e.key))})]})}function wa({sessions:e,isBookmarked:t,onToggleBookmark:n}){return e.length===0?(0,R.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4 text-sm text-[var(--console-muted)]`,children:`No sessions yet`}):(0,R.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,R.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,R.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Recent Sessions`}),(0,R.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` items`]})]}),(0,R.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>{let r=t(e.agentKey,e.id);return(0,R.jsx)(`li`,{children:(0,R.jsxs)(`div`,{className:`flex items-start gap-2 rounded-sm border border-transparent px-2 py-1.5 transition-colors hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,R.jsxs)(C,{to:`/${e.fullPath}`,className:`min-w-0 flex-1`,children:[(0,R.jsx)(`p`,{className:`line-clamp-1 text-sm text-[var(--console-text)]`,children:e.title}),(0,R.jsxs)(`p`,{className:`console-mono mt-0.5 text-[11px] text-[var(--console-muted)]`,children:[`/`,e.fullPath,` ·`,` `,Br(e.time_updated||e.time_created)]}),(0,R.jsx)(Ri,{tags:e.smart_tags,className:`mt-1.5`})]}),(0,R.jsx)(va,{active:r,onToggle:()=>n(e)})]})},e.id)})})]})}function Ta({type:e,sessions:t,agentItems:n,activeAgentKey:r,attemptedAgentKey:i,attemptedSessionSlug:a,isBookmarked:o,onToggleBookmark:s}){let c=t.toSorted((e,t)=>(t.time_updated||t.time_created||0)-(e.time_updated||e.time_created||0)),l=c.slice(0,5),u=t.reduce((e,t)=>e+t.stats.message_count,0),d=t.reduce((e,t)=>e+ya(t.stats),0),f=t.reduce((e,t)=>e+t.stats.total_cost,0),p=f>0?t.some(e=>e.stats.cost_source===`estimated`)?`estimated`:`recorded`:void 0,m=c[0]?.time_updated||c[0]?.time_created;if(e===`missing-agent`){let e=`/${i||`unknown`}${a?`/${a}`:``}`;return(0,R.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,R.jsx)(Sa,{code:`404 / AGENT`,title:`This agent isn't on the roster.`,description:`The path you requested is valid in shape, but there is no matching agent in the current registry. It may not be connected yet, or its name may not match what the system recognizes.`,aside:`Choose one of the available agents to continue.`}),(0,R.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,R.jsx)(xa,{label:`Requested Agent`,value:i||`unknown`}),(0,R.jsx)(xa,{label:`Requested Path`,value:e}),a?(0,R.jsx)(xa,{label:`Requested Session`,value:a}):null]}),(0,R.jsx)(Ca,{agentItems:n})]})}if(e===`missing-session`){let e=r||L.getDefaultAgentKey()||`claudecode`,t=L.agents[e],n=t?.name||e,i=t?.icon,c=a||`unknown-session`;return(0,R.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,R.jsx)(Sa,{code:`404 / SESSION`,title:`This session isn't in the index.`,description:`${n} is available, but the session you're looking for does not exist in the current index. The slug may be incorrect, or the record may never have been part of this dataset.`,aside:`We checked the current path, but nothing matched. The session list on the left is still available.`,iconSrc:i,iconAlt:n}),(0,R.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,R.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] p-3`,children:[(0,R.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-wider text-[var(--console-muted)]`,children:`Agent`}),(0,R.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[i?(0,R.jsx)(`img`,{src:i,alt:n,className:`size-4 shrink-0 object-contain`}):null,(0,R.jsx)(`p`,{className:`console-mono break-all text-sm leading-6 text-[var(--console-text)]`,children:n})]})]}),(0,R.jsx)(xa,{label:`Session`,value:c})]}),(0,R.jsx)(wa,{sessions:l,isBookmarked:o,onToggleBookmark:s})]})}if(e===`global`)return(0,R.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,R.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,R.jsx)(ba,{label:`Total Sessions`,value:Y(t.length)}),(0,R.jsx)(ba,{label:`Total Messages`,value:Y(u)}),(0,R.jsx)(ba,{label:`Latest Activity`,value:Br(m),hint:m?new Date(m).toLocaleString(`zh-CN`):void 0})]}),(0,R.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,R.jsx)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:`Agents`}),(0,R.jsx)(`ul`,{className:`grid gap-2 sm:grid-cols-2`,children:n.map(e=>(0,R.jsx)(`li`,{children:(0,R.jsxs)(C,{to:`/${e.key}`,className:`flex items-center gap-2 rounded-sm border border-transparent px-2 py-1.5 transition-colors hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,R.jsx)(`img`,{src:e.icon,alt:e.name,className:`size-4 object-contain`}),(0,R.jsx)(`span`,{className:`console-mono flex-1 text-xs text-[var(--console-text)]`,children:e.name}),(0,R.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:e.count})]})},e.key))})]}),(0,R.jsx)(wa,{sessions:l,isBookmarked:o,onToggleBookmark:s})]});let h=r?L.agents[r]:null,g=h?h.name:`Unknown Agent`;return(0,R.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,R.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[h?(0,R.jsx)(`img`,{src:h.icon,alt:g,className:`size-6 object-contain`}):null,(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`console-mono text-sm font-semibold text-[var(--console-text)]`,children:g}),(0,R.jsx)(`p`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:`Select a session from the left to view details`})]})]})}),(0,R.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-4`,children:[(0,R.jsx)(ba,{label:`Sessions`,value:Y(t.length)}),(0,R.jsx)(ba,{label:`Messages`,value:Y(u)}),(0,R.jsx)(ba,{label:`Tokens`,value:Y(d)}),(0,R.jsx)(ba,{label:`Total Cost`,value:Vr(f),hint:Hr(p)})]}),(0,R.jsx)(wa,{sessions:l,isBookmarked:o,onToggleBookmark:s})]})}var Ea=`codesesh:bookmarks:v1`;function Da(e){return typeof e==`object`&&!!e}function Oa(e){return Da(e)?typeof e.message_count==`number`&&typeof e.total_input_tokens==`number`&&typeof e.total_output_tokens==`number`&&typeof e.total_cost==`number`&&(e.total_tokens==null||typeof e.total_tokens==`number`):!1}function ka(e){return Da(e)?typeof e.sessionId==`string`&&typeof e.agentKey==`string`&&typeof e.fullPath==`string`&&typeof e.title==`string`&&typeof e.directory==`string`&&typeof e.time_created==`number`&&(e.time_updated==null||typeof e.time_updated==`number`)&&(e.bookmarked_at==null||typeof e.bookmarked_at==`number`)&&Oa(e.stats):!1}function Aa(e,t){return`${e}:${t}`}function ja(e,t){return{sessionId:e.id,agentKey:t,fullPath:e.slug,title:e.title,directory:e.directory,time_created:e.time_created,time_updated:e.time_updated,stats:e.stats,bookmarked_at:Date.now()}}function Ma(){if(typeof window>`u`)return[];try{let e=window.localStorage.getItem(Ea);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(ka).toSorted(Pa):[]}catch{return[]}}function Na(){typeof window>`u`||window.localStorage.removeItem(Ea)}function Pa(e,t){let n=e.time_updated??e.time_created;return(t.time_updated??t.time_created)-n}function Fa(e,t){if(e.length===0||t.length===0)return e;let n=new Map(t.map(e=>{let t=ja(e,e.slug.split(`/`)[0]?.toLowerCase()??`unknown`);return[Aa(t.agentKey,t.sessionId),t]})),r=!1,i=e.map(e=>{let t=n.get(Aa(e.agentKey,e.sessionId));return!t||t.fullPath===e.fullPath&&t.title===e.title&&t.directory===e.directory&&t.time_created===e.time_created&&t.time_updated===e.time_updated&&t.stats.message_count===e.stats.message_count&&t.stats.total_input_tokens===e.stats.total_input_tokens&&t.stats.total_output_tokens===e.stats.total_output_tokens&&t.stats.total_cost===e.stats.total_cost&&t.stats.total_tokens===e.stats.total_tokens?e:(r=!0,{...t,bookmarked_at:e.bookmarked_at})});return r?i.toSorted(Pa):e}function Ia(e){return{kind:e.identityKind,key:e.identityKey}}var La=new Set([`git_remote`,`git_common_dir`,`manifest_path`,`synthetic`,`path`,`loose`]);function Ra(e){return La.has(e)}function za(e){return`${e.kind}:${e.key}`}function Ba(e){return decodeURIComponent(e)}function Va(e){return`/projects/${encodeURIComponent(e.kind)}/${encodeURIComponent(e.key)}`}function Ha(...e){return ge(T(e))}var Ua={light:``,dark:`.dark`},Wa={width:320,height:200},Ga=N.createContext(null);function Ka(){let e=N.useContext(Ga);if(!e)throw Error(`useChart must be used within a <ChartContainer />`);return e}function qa({id:e,className:t,children:n,config:r,initialDimension:i=Wa,...a}){let o=N.useId(),s=`chart-${e??o.replace(/:/g,``)}`;return(0,R.jsx)(Ga.Provider,{value:{config:r},children:(0,R.jsxs)(`div`,{"data-slot":`chart`,"data-chart":s,className:Ha(`flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden`,t),...a,children:[(0,R.jsx)(Ja,{id:s,config:r}),(0,R.jsx)(w,{initialDimension:i,children:n})]})})}var Ja=({id:e,config:t})=>{let n=Object.entries(t).filter(([,e])=>e.theme??e.color);return n.length?(0,R.jsx)(`style`,{dangerouslySetInnerHTML:{__html:Object.entries(Ua).map(([t,r])=>`
|
|
40
|
-
${r} [data-chart=${e}] {
|
|
41
|
-
${n.map(([e,n])=>{let r=n.theme?.[t]??n.color;return r?` --color-${e}: ${r};`:null}).join(`
|
|
42
|
-
`)}
|
|
43
|
-
}
|
|
44
|
-
`).join(`
|
|
45
|
-
`)}}):null},Ya=ve;function Xa({active:e,payload:t,className:n,indicator:r=`dot`,hideLabel:i=!1,hideIndicator:a=!1,label:o,labelFormatter:s,labelClassName:c,formatter:l,color:u,nameKey:d,labelKey:f}){let{config:p}=Ka(),m=N.useMemo(()=>{if(i||!t?.length)return null;let[e]=t,n=Za(p,e,`${f??e?.dataKey??e?.name??`value`}`),r=!f&&typeof o==`string`?p[o]?.label??o:n?.label;return s?(0,R.jsx)(`div`,{className:Ha(`font-medium`,c),children:s(r,t)}):r?(0,R.jsx)(`div`,{className:Ha(`font-medium`,c),children:r}):null},[o,s,t,i,c,p,f]);if(!e||!t?.length)return null;let h=t.length===1&&r!==`dot`;return(0,R.jsxs)(`div`,{className:Ha(`grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl`,n),children:[h?null:m,(0,R.jsx)(`div`,{className:`grid gap-1.5`,children:t.filter(e=>e.type!==`none`).map((e,t)=>{let n=Za(p,e,`${d??e.name??e.dataKey??`value`}`),i=u??e.payload?.fill??e.color;return(0,R.jsx)(`div`,{className:Ha(`flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground`,r===`dot`&&`items-center`),children:l&&e?.value!==void 0&&e.name?l(e.value,e.name,e,t,e.payload):(0,R.jsxs)(R.Fragment,{children:[n?.icon?(0,R.jsx)(n.icon,{}):!a&&(0,R.jsx)(`div`,{className:Ha(`shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)`,{"h-2.5 w-2.5":r===`dot`,"w-1":r===`line`,"w-0 border-[1.5px] border-dashed bg-transparent":r===`dashed`,"my-0.5":h&&r===`dashed`}),style:{"--color-bg":i,"--color-border":i}}),(0,R.jsxs)(`div`,{className:Ha(`flex flex-1 justify-between leading-none`,h?`items-end`:`items-center`),children:[(0,R.jsxs)(`div`,{className:`grid gap-1.5`,children:[h?m:null,(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:n?.label??e.name})]}),e.value!=null&&(0,R.jsx)(`span`,{className:`font-mono font-medium text-foreground tabular-nums`,children:typeof e.value==`number`?e.value.toLocaleString():String(e.value)})]})]})},t)})})]})}function Za(e,t,n){if(typeof t!=`object`||!t)return;let r=`payload`in t&&typeof t.payload==`object`&&t.payload!==null?t.payload:void 0,i=n;return n in t&&typeof t[n]==`string`?i=t[n]:r&&n in r&&typeof r[n]==`string`&&(i=r[n]),i in e?e[i]:e[n]}function Qa(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:Y(e)}function $a({label:e,value:t,hint:n}){return(0,R.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,R.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-wider text-[var(--console-muted)]`,children:e}),(0,R.jsx)(`p`,{className:`console-mono mt-2 text-xl font-semibold text-[var(--console-text)]`,children:t}),n?(0,R.jsx)(`p`,{className:`mt-1 text-xs text-[var(--console-muted)]`,children:n}):null]})}function eo(e){return e.length>=10?e.slice(5):e}function to({buckets:e}){let[t,n]=(0,N.useState)(null),r=(0,N.useMemo)(()=>Math.max(1,...e.map(e=>e.sessions)),[e]),i=(0,N.useMemo)(()=>e.reduce((e,t)=>e+t.sessions,0),[e]),a=(0,N.useMemo)(()=>{if(e.length===0)return new Set;let t=Math.min(6,e.length);if(t===1)return new Set([0]);let n=new Set;for(let r=0;r<t;r+=1)n.add(Math.round(r*(e.length-1)/(t-1)));return n},[e.length]);return(0,R.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,R.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Daily Activity`}),(0,R.jsxs)(`p`,{className:`console-mono mt-1 text-[11px] text-[var(--console-muted)]`,children:[`Session activity · last `,e.length,` days`]})]}),(0,R.jsx)(`span`,{className:`console-mono text-right text-[11px] text-[var(--console-muted)]`,children:t?`${t.date} · ${Y(t.sessions)} sessions · ${Y(t.messages)} msgs`:`${Y(i)} in range`})]}),(0,R.jsx)(`div`,{className:`flex h-32 items-end gap-[2px]`,onMouseLeave:()=>n(null),children:e.map(e=>{let i=e.sessions>0?Math.max(Math.round(e.sessions/r*128),4):2,a=`${e.date} · ${e.sessions} sessions · ${e.messages} msgs`,o=t?.date===e.date;return(0,R.jsx)(`div`,{title:a,onMouseEnter:()=>n(e),className:`flex-1 cursor-default rounded-t-[1px] transition-opacity ${e.sessions>0?`bg-[var(--console-accent)]`:`bg-[var(--console-surface-muted)]`} ${o?`opacity-70`:`opacity-100`}`,style:{height:`${i}px`}},e.date)})}),(0,R.jsx)(`div`,{className:`console-mono mt-2 flex text-[10px] text-[var(--console-muted)]`,children:e.map((e,t)=>(0,R.jsx)(`span`,{className:`flex-1 text-center`,children:a.has(t)?eo(e.date):``},e.date))})]})}var no={input:`#4A9EFF`,output:`#7C5CFF`,cache_read:`#3FB68B`,cache_create:`#E8A23B`},ro={input:`Input`,output:`Output`,cache_read:`Cache Read`,cache_create:`Cache Create`};function io({buckets:e}){let[t,n]=(0,N.useState)(null),r=(0,N.useMemo)(()=>Math.max(1,...e.map(e=>e.input+e.output+e.cache_read+e.cache_create)),[e]),i=(0,N.useMemo)(()=>e.reduce((e,t)=>e+t.input+t.output+t.cache_read+t.cache_create,0),[e]),a=(0,N.useMemo)(()=>{if(e.length===0)return new Set;let t=Math.min(6,e.length);if(t===1)return new Set([0]);let n=new Set;for(let r=0;r<t;r+=1)n.add(Math.round(r*(e.length-1)/(t-1)));return n},[e.length]);return i===0?null:(0,R.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,R.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Daily Token Activity`}),(0,R.jsxs)(`p`,{className:`console-mono mt-1 text-[11px] text-[var(--console-muted)]`,children:[`Token breakdown · last `,e.length,` days`]})]}),(0,R.jsx)(`span`,{className:`console-mono text-right text-[11px] text-[var(--console-muted)]`,children:t?`${t.date} · ${Qa(t.input+t.output+t.cache_read+t.cache_create)} total`:`${Qa(i)} in range`})]}),t?(0,R.jsx)(`div`,{className:`mb-2 flex gap-4`,children:[`input`,`output`,`cache_read`,`cache_create`].map(e=>(0,R.jsxs)(`span`,{className:`console-mono flex items-center gap-1.5 text-[10px] text-[var(--console-muted)]`,children:[(0,R.jsx)(`span`,{className:`inline-block size-2 rounded-full`,style:{backgroundColor:no[e]}}),ro[e],`: `,Qa(t[e])]},e))}):(0,R.jsx)(`div`,{className:`mb-2 flex gap-4`,children:[`input`,`output`,`cache_read`,`cache_create`].map(e=>(0,R.jsxs)(`span`,{className:`console-mono flex items-center gap-1.5 text-[10px] text-[var(--console-muted)]`,children:[(0,R.jsx)(`span`,{className:`inline-block size-2 rounded-full`,style:{backgroundColor:no[e]}}),ro[e]]},e))}),(0,R.jsx)(`div`,{className:`flex h-32 items-end gap-[2px]`,onMouseLeave:()=>n(null),children:e.map(e=>{let i=e.input+e.output+e.cache_read+e.cache_create,a=i>0?Math.max(Math.round(i/r*128),4):2,o=t?.date===e.date,s=i>0?[{key:`input`,value:e.input},{key:`output`,value:e.output},{key:`cache_read`,value:e.cache_read},{key:`cache_create`,value:e.cache_create}]:[];return(0,R.jsx)(`div`,{onMouseEnter:()=>n(e),className:`flex flex-1 cursor-default flex-col justify-end overflow-hidden rounded-t-[1px] transition-opacity ${o?`opacity-70`:`opacity-100`}`,style:{height:`${a}px`},children:i>0?s.map(e=>{let t=Math.max(Math.round(e.value/i*a),0);return t===0?null:(0,R.jsx)(`div`,{style:{height:`${t}px`,backgroundColor:no[e.key]}},e.key)}):(0,R.jsx)(`div`,{className:`h-full bg-[var(--console-surface-muted)]`})},e.date)})}),(0,R.jsx)(`div`,{className:`console-mono mt-2 flex text-[10px] text-[var(--console-muted)]`,children:e.map((e,t)=>(0,R.jsx)(`span`,{className:`flex-1 text-center`,children:a.has(t)?eo(e.date):``},e.date))})]})}var ao=[`#4A9EFF`,`#7C5CFF`,`#3FB68B`,`#E8A23B`,`#E5484D`,`#5BCEDA`,`#F472B6`,`#A78BFA`,`#FB923C`,`#6EE7B7`];function oo({entries:e}){let t=(0,N.useMemo)(()=>e.filter(e=>e.tokens>0),[e]),n=(0,N.useMemo)(()=>t.reduce((e,t)=>e+t.tokens,0),[t]);if(t.length===0||n===0)return(0,R.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4 text-sm text-[var(--console-muted)]`,children:`No model data yet`});let r=t.map((e,t)=>({...e,chartKey:`model${t}`,fraction:e.tokens/n,fill:ao[t%ao.length]})),i=r.reduce((e,t)=>(e[t.chartKey]={label:t.model,color:t.fill},e),{});return(0,R.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,R.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,R.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Model Distribution`}),(0,R.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[t.length,` models`]})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-6`,children:[(0,R.jsxs)(`div`,{className:`flex shrink-0 flex-col items-center`,children:[(0,R.jsx)(qa,{config:i,className:`aspect-square size-[160px]`,children:(0,R.jsxs)(se,{children:[(0,R.jsx)(Ya,{content:(0,R.jsx)(Xa,{hideLabel:!0,nameKey:`chartKey`,formatter:e=>(0,R.jsxs)(`span`,{className:`font-mono font-medium text-foreground tabular-nums`,children:[Y(Number(e)),` tokens`]})})}),(0,R.jsx)(de,{data:r,dataKey:`tokens`,nameKey:`chartKey`,outerRadius:70,paddingAngle:1,strokeWidth:0,isAnimationActive:!1})]})}),(0,R.jsxs)(`div`,{className:`console-mono -mt-1 text-center`,children:[(0,R.jsx)(`div`,{className:`text-xs font-semibold text-[var(--console-text)]`,children:Qa(n)}),(0,R.jsx)(`div`,{className:`text-[10px] text-[var(--console-muted)]`,children:`tokens`})]})]}),(0,R.jsx)(`ul`,{className:`min-w-0 flex-1 space-y-1.5`,children:r.map(e=>(0,R.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`inline-block size-2.5 shrink-0 rounded-full`,style:{backgroundColor:e.fill}}),(0,R.jsx)(`span`,{className:`console-mono min-w-0 flex-1 truncate text-xs text-[var(--console-text)]`,children:e.model}),(0,R.jsxs)(`span`,{className:`console-mono shrink-0 text-[11px] text-[var(--console-muted)]`,children:[(e.fraction*100).toFixed(1),`%`]})]},e.model))})]})]})}function so({perAgent:e}){let t=(0,N.useMemo)(()=>e.reduce((e,t)=>e+t.sessions,0),[e]);return t===0||e.length===0?(0,R.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4 text-sm text-[var(--console-muted)]`,children:`No agent data yet`}):(0,R.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,R.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,R.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Agent Distribution`}),(0,R.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` agents`]})]}),(0,R.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>{let n=t>0?e.sessions/t*100:0;return(0,R.jsx)(`li`,{children:(0,R.jsxs)(C,{to:`/${e.name.toLowerCase()}`,className:`block rounded-sm border border-transparent px-2 py-1.5 transition-colors hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon?(0,R.jsx)(`img`,{src:e.icon,alt:e.displayName,className:`size-4 object-contain`}):null,(0,R.jsx)(`span`,{className:`console-mono flex-1 text-xs text-[var(--console-text)]`,children:e.displayName}),(0,R.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[Y(e.sessions),` · `,n.toFixed(1),`%`]})]}),(0,R.jsx)(`div`,{className:`mt-1.5 h-1.5 overflow-hidden rounded-sm bg-[var(--console-surface-muted)]`,children:(0,R.jsx)(`div`,{className:`h-full bg-[var(--console-accent)]`,style:{width:`${n}%`}})}),(0,R.jsxs)(`div`,{className:`console-mono mt-1 flex gap-3 text-[10px] text-[var(--console-muted)]`,children:[(0,R.jsxs)(`span`,{children:[Y(e.messages),` msgs`]}),(0,R.jsxs)(`span`,{children:[Qa(e.tokens),` tokens`]})]})]})},e.name)})})]})}function co({projects:e}){return e.length===0?null:(0,R.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,R.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,R.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Projects`}),(0,R.jsx)(C,{to:`/projects`,className:`console-mono text-[11px] text-[var(--console-muted)] transition-colors hover:text-[var(--console-text)]`,children:`View all`})]}),(0,R.jsx)(`ul`,{className:`space-y-2`,children:e.slice(0,5).map(e=>{let t=e.agentStats.slice(0,3);return(0,R.jsx)(`li`,{children:(0,R.jsxs)(C,{to:Va({kind:e.identityKind,key:e.identityKey}),className:`block rounded-sm border border-transparent px-2 py-1.5 transition-colors hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`console-mono min-w-0 flex-1 truncate text-xs text-[var(--console-text)]`,children:e.displayName}),(0,R.jsxs)(`span`,{className:`console-mono shrink-0 text-[11px] text-[var(--console-muted)]`,children:[Y(e.sessionCount),` · `,Vr(e.cost)]})]}),(0,R.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5`,children:[t.map(e=>{let t=L.agents[e.name];return(0,R.jsxs)(`span`,{className:`console-mono inline-flex items-center gap-1 rounded-sm border border-[var(--console-border)] bg-white px-1.5 py-0.5 text-[10px] text-[var(--console-muted)]`,children:[t?.icon?(0,R.jsx)(`img`,{src:t.icon,alt:t.name,className:`size-3 object-contain`}):null,t?.name??e.name,` · `,e.sessions]},e.name)}),(0,R.jsxs)(`span`,{className:`console-mono min-w-0 truncate text-[10px] text-[var(--console-muted)]`,children:[Qa(e.tokens),` tokens`]})]})]})},`${e.identityKind}:${e.identityKey}`)})})]})}function lo({sessions:e,onToggleBookmark:t}){return e.length===0?null:(0,R.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,R.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,R.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Bookmarked Sessions`}),(0,R.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` items`]})]}),(0,R.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>{let n=L.agents[e.agentKey],r=e.time_updated??e.time_created;return(0,R.jsx)(`li`,{children:(0,R.jsxs)(`div`,{className:`flex items-start gap-2 rounded-sm border border-transparent px-2 py-1.5 transition-colors hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,R.jsxs)(C,{to:`/${e.fullPath}`,className:`flex min-w-0 flex-1 items-start gap-2`,children:[n?.icon?(0,R.jsx)(`img`,{src:n.icon,alt:n.name,className:`mt-0.5 size-3.5 shrink-0 object-contain`}):null,(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`p`,{className:`line-clamp-1 text-sm text-[var(--console-text)]`,children:e.title}),(0,R.jsxs)(`p`,{className:`console-mono mt-0.5 line-clamp-1 text-[11px] text-[var(--console-muted)]`,children:[`/`,e.fullPath,` · `,Br(r)]})]})]}),(0,R.jsx)(va,{active:!0,onToggle:()=>t(e)})]})},Aa(e.agentKey,e.sessionId))})})]})}function uo({sessions:e,isBookmarked:t,onToggleBookmark:n}){return e.length===0?(0,R.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4 text-sm text-[var(--console-muted)]`,children:`No sessions yet`}):(0,R.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,R.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,R.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Recent Activity`}),(0,R.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` items`]})]}),(0,R.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>{let r=e.agentName.toLowerCase(),i=L.agents[r],a=e.time_updated??e.time_created,o=t(r,e.id);return(0,R.jsx)(`li`,{children:(0,R.jsxs)(`div`,{className:`flex items-start gap-2 rounded-sm border border-transparent px-2 py-1.5 transition-colors hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,R.jsxs)(C,{to:`/${e.slug}`,className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[i?.icon?(0,R.jsx)(`img`,{src:i.icon,alt:i.name,className:`size-3.5 shrink-0 object-contain`}):null,(0,R.jsx)(`p`,{className:`line-clamp-1 flex-1 text-sm text-[var(--console-text)]`,children:e.title}),(0,R.jsx)(`span`,{className:`console-mono shrink-0 text-[11px] text-[var(--console-muted)]`,children:Br(a)})]}),(0,R.jsxs)(`p`,{className:`console-mono mt-0.5 line-clamp-1 text-[11px] text-[var(--console-muted)]`,children:[`/`,e.slug]}),(0,R.jsx)(Ri,{tags:e.smart_tags,className:`mt-1.5`})]}),(0,R.jsx)(va,{active:o,onToggle:()=>n(e,r)})]})},e.id)})})]})}function fo({activity:e}){return e.length===0?(0,R.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4 text-sm text-[var(--console-muted)]`,children:`No file activity yet`}):(0,R.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,R.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,R.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Recently Touched Files`}),(0,R.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` files`]})]}),(0,R.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>{let t=e.latest_time;return(0,R.jsx)(`li`,{children:(0,R.jsxs)(C,{to:`/${e.session.slug}`,className:`block rounded-sm border border-transparent px-2 py-1.5 transition-colors hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-1.5 py-0.5 text-[10px] uppercase text-[var(--console-muted)]`,children:e.kind}),(0,R.jsx)(`span`,{className:`console-mono min-w-0 flex-1 truncate text-xs text-[var(--console-text)]`,children:e.path}),(0,R.jsx)(`span`,{className:`console-mono shrink-0 text-[11px] text-[var(--console-muted)]`,children:Br(t)})]}),(0,R.jsxs)(`p`,{className:`console-mono mt-1 line-clamp-1 text-[11px] text-[var(--console-muted)]`,children:[e.session.project_identity?.displayName??e.session.directory,` ·`,` `,e.session.title,` · `,e.count,` events`]})]})},`${e.agent_name}/${e.session_id}/${e.kind}/${e.path}`)})})]})}function po({data:e,projects:t=[],bookmarkedSessions:n,isBookmarked:r,onToggleBookmark:i}){let{totals:a,perAgent:o,dailyActivity:s,dailyTokenActivity:c,modelDistribution:l,recentSessions:u,recentFileActivities:d=[]}=e;return(0,R.jsxs)(`div`,{"data-testid":`dashboard`,className:`mx-auto max-w-5xl space-y-4`,children:[(0,R.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-5`,children:[(0,R.jsx)($a,{label:`Total Sessions`,value:Y(a.sessions)}),(0,R.jsx)($a,{label:`Total Messages`,value:Y(a.messages)}),(0,R.jsx)($a,{label:`Total Tokens`,value:Qa(a.tokens)}),(0,R.jsx)($a,{label:`Total Cost`,value:Vr(a.cost),hint:Hr(a.cost_source)}),(0,R.jsx)($a,{label:`Latest Activity`,value:Br(a.latestActivity),hint:a.latestActivity?new Date(a.latestActivity).toLocaleString(`zh-CN`):void 0})]}),(0,R.jsx)(to,{buckets:s}),(0,R.jsx)(io,{buckets:c}),(0,R.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,R.jsx)(oo,{entries:l}),(0,R.jsx)(so,{perAgent:o})]}),(0,R.jsx)(co,{projects:t}),(0,R.jsx)(uo,{sessions:u,isBookmarked:r,onToggleBookmark:i}),(0,R.jsx)(fo,{activity:d}),(0,R.jsx)(lo,{sessions:n,onToggleBookmark:e=>i(e)})]})}function mo(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:Y(e)}function ho(e){return e.stats.total_tokens??e.stats.total_input_tokens+e.stats.total_output_tokens}function go({label:e,value:t,hint:n}){return(0,R.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,R.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-wider text-[var(--console-muted)]`,children:e}),(0,R.jsx)(`p`,{className:`console-mono mt-2 text-xl font-semibold text-[var(--console-text)]`,children:t}),n?(0,R.jsx)(`p`,{className:`mt-1 text-xs text-[var(--console-muted)]`,children:n}):null]})}function _o({agents:e}){return e.length===0?null:(0,R.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:e.slice(0,4).map(e=>{let t=L.agents[e.name];return(0,R.jsxs)(`span`,{className:`console-mono inline-flex items-center gap-1 rounded-sm border border-[var(--console-border)] bg-white px-1.5 py-0.5 text-[10px] text-[var(--console-muted)]`,children:[t?.icon?(0,R.jsx)(`img`,{src:t.icon,alt:t.name,className:`size-3 object-contain`}):null,t?.name??e.name,` · `,e.sessions]},e.name)})})}function vo({project:e}){return(0,R.jsx)(`li`,{children:(0,R.jsxs)(C,{to:Va({kind:e.identityKind,key:e.identityKey}),className:`block rounded-sm border border-[var(--console-border)] bg-white/85 p-4 transition-colors hover:border-[var(--console-border-strong)] hover:bg-white`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`h2`,{className:`console-mono line-clamp-1 text-sm font-semibold text-[var(--console-text)]`,children:e.displayName}),(0,R.jsx)(`p`,{className:`console-mono mt-1 break-all text-[11px] text-[var(--console-muted)]`,children:e.identityKey})]}),(0,R.jsxs)(`div`,{className:`console-mono flex shrink-0 flex-wrap gap-2 text-[11px] text-[var(--console-muted)]`,children:[(0,R.jsxs)(`span`,{children:[Y(e.sessionCount),` sessions`]}),(0,R.jsxs)(`span`,{children:[mo(e.tokens),` tokens`]}),(0,R.jsx)(`span`,{children:Vr(e.cost)}),(0,R.jsx)(`span`,{children:Br(e.lastActivity)})]})]}),(0,R.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2 md:flex-row md:items-center md:justify-between`,children:[(0,R.jsx)(_o,{agents:e.agentStats}),(0,R.jsx)(`span`,{className:`console-mono text-[10px] uppercase text-[var(--console-muted)]`,children:e.identityKind})]})]})})}function yo({projects:e}){let t=e.reduce((e,t)=>e+t.sessionCount,0),n=e.reduce((e,t)=>e+t.tokens,0),r=e.reduce((e,t)=>e+t.cost,0),i=Math.max(0,...e.map(e=>e.lastActivity??0));return e.length===0?(0,R.jsx)(`div`,{className:`mx-auto max-w-5xl rounded-sm border border-[var(--console-border)] bg-white p-6 text-sm text-[var(--console-muted)]`,children:`No projects found`}):(0,R.jsxs)(`div`,{className:`mx-auto max-w-5xl space-y-4`,children:[(0,R.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-4`,children:[(0,R.jsx)(go,{label:`Projects`,value:Y(e.length)}),(0,R.jsx)(go,{label:`Sessions`,value:Y(t)}),(0,R.jsx)(go,{label:`Tokens`,value:mo(n)}),(0,R.jsx)(go,{label:`Total Cost`,value:Vr(r),hint:i?`Latest ${Br(i)}`:void 0})]}),(0,R.jsx)(`ul`,{className:`grid gap-3`,children:e.map(e=>(0,R.jsx)(vo,{project:e},`${e.identityKind}:${e.identityKey}`))})]})}function bo({agents:e,activeAgent:t,onChange:n}){return(0,R.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-3`,children:(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`Agent`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>n(void 0),className:`console-mono rounded-sm border px-2 py-1 text-[10px] transition-colors ${t?`border-[var(--console-border)] bg-[var(--console-surface-muted)] text-[var(--console-muted)] hover:bg-white`:`border-[var(--console-border-strong)] bg-[var(--console-accent)] text-white`}`,children:`All Agents`}),e.map(e=>{let r=L.agents[e.name],i=t===e.name;return(0,R.jsxs)(`button`,{type:`button`,onClick:()=>n(i?void 0:e.name),className:`console-mono inline-flex items-center gap-1 rounded-sm border px-2 py-1 text-[10px] transition-colors ${i?`border-[var(--console-border-strong)] bg-[var(--console-accent)] text-white`:`border-[var(--console-border)] bg-[var(--console-surface-muted)] text-[var(--console-muted)] hover:bg-white`}`,children:[r?.icon?(0,R.jsx)(`img`,{src:r.icon,alt:r.name,className:`size-3 object-contain`}):null,r?.name??e.name,` · `,e.sessions]},e.name)})]})})}function xo({project:e}){return(0,R.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`h2`,{className:`console-mono text-base font-semibold text-[var(--console-text)]`,children:e.displayName}),(0,R.jsxs)(`p`,{className:`console-mono mt-1 break-all text-[11px] text-[var(--console-muted)]`,children:[e.identityKind,`: `,e.identityKey]})]}),(0,R.jsx)(_o,{agents:e.agentStats})]})})}function So({sessions:e}){if(e.length===0)return null;let t=e.toSorted((e,t)=>t.stats.total_cost-e.stats.total_cost).slice(0,5);return(0,R.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,R.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,R.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Top Cost`}),(0,R.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[t.length,` sessions`]})]}),(0,R.jsx)(`ul`,{className:`space-y-2`,children:t.map(e=>{let t=L.agents[e.agentKey];return(0,R.jsx)(`li`,{children:(0,R.jsxs)(C,{to:`/${e.fullPath}`,className:`block rounded-sm border border-transparent px-2 py-1.5 transition-colors hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t?.icon?(0,R.jsx)(`img`,{src:t.icon,alt:t.name,className:`size-3.5 object-contain`}):null,(0,R.jsx)(`span`,{className:`line-clamp-1 flex-1 text-sm text-[var(--console-text)]`,children:e.title}),(0,R.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:Vr(e.stats.total_cost)})]}),(0,R.jsxs)(`p`,{className:`console-mono mt-1 text-[11px] text-[var(--console-muted)]`,children:[`/`,e.fullPath,` · `,mo(ho(e)),` tokens`]})]})},e.fullPath)})})]})}function Co({project:e,projectKey:t,dashboard:n,loading:r,error:i,sessions:a,activeAgent:o,onChangeAgent:s,isBookmarked:c,onToggleSessionBookmark:l}){if(!e)return(0,R.jsxs)(`div`,{className:`mx-auto max-w-4xl rounded-sm border border-[var(--console-border)] bg-white p-6`,children:[(0,R.jsx)(`h2`,{className:`console-mono text-sm font-semibold text-[var(--console-text)]`,children:`Project Not Found`}),(0,R.jsx)(`p`,{className:`console-mono mt-2 break-all text-xs text-[var(--console-muted)]`,children:t}),(0,R.jsx)(C,{to:`/projects`,className:`console-mono mt-4 inline-flex rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-xs text-[var(--console-text)] transition-colors hover:bg-white`,children:`Back to Projects`})]});let u=o?a.filter(e=>e.agentKey===o):a;return(0,R.jsxs)(`div`,{className:`mx-auto max-w-5xl space-y-4`,children:[(0,R.jsx)(xo,{project:e}),(0,R.jsx)(bo,{agents:e.agentStats,activeAgent:o,onChange:s}),r?(0,R.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-6 text-sm text-[var(--console-muted)]`,children:`Loading project dashboard`}):i?(0,R.jsx)(`div`,{className:`rounded-sm border border-[var(--console-error-border)] bg-[var(--console-error-bg)] p-6 text-sm text-[var(--console-error)]`,children:i}):n?(0,R.jsx)(po,{data:n,projects:[],bookmarkedSessions:[],isBookmarked:c,onToggleBookmark:(e,t)=>{`agentName`in e&&l(e,t??e.agentName.toLowerCase())}}):null,(0,R.jsx)(So,{sessions:u})]})}var wo=class extends N.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`ErrorBoundary caught error:`,e,t)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:(0,R.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-error-border)] bg-[var(--console-error-bg)] p-6`,children:[(0,R.jsx)(`h3`,{className:`console-mono mb-2 text-sm font-semibold text-[var(--console-error)]`,children:`Something went wrong`}),(0,R.jsx)(`p`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:this.state.error?.message||`Unknown error`})]}):this.props.children}};function To(e){return`'${e.replace(/'/g,`'\\''`)}'`}var Eo={claudecode:`claude --resume`,codex:`codex resume`,kimi:`kimi -r`,opencode:`opencode -s`,pi:`pi --session`};function Do(e){let t=e.toLowerCase();return t in Eo?Eo[t]:null}function Oo({agentName:e,sessionId:t,directory:n}){let r=Do(e);if(!r)return null;let i=`${r} ${To(t)}`,a=n??``;return a.trim()?`cd ${To(a)} && ${i}`:i}async function ko(e){if(typeof navigator<`u`&&navigator.clipboard?.writeText)try{return await navigator.clipboard.writeText(e),!0}catch{}if(typeof document>`u`)return!1;let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=!1;try{n=document.execCommand(`copy`)}catch{n=!1}return document.body.removeChild(t),n}function Ao({agentName:e,sessionId:t,directory:n,className:r=``}){let[i,a]=(0,N.useState)(!1),o=Oo({agentName:e,sessionId:t,directory:n});return(0,N.useEffect)(()=>{if(!i)return;let e=window.setTimeout(()=>a(!1),1500);return()=>window.clearTimeout(e)},[i]),o?(0,R.jsxs)(`button`,{type:`button`,onClick:e=>{e.preventDefault(),e.stopPropagation(),ko(o).then(e=>{e&&a(!0)})},"aria-label":i?`Resume command copied: ${o}`:`Copy resume command: ${o}`,title:i?`Copied: ${o}`:`Copy: ${o}`,className:`console-mono inline-flex items-center gap-1.5 rounded-sm border px-2 py-1 text-[11px] transition-colors ${r} ${i?`border-[var(--console-border-strong)] bg-[var(--console-surface-muted)] text-[var(--console-text)]`:`border-[var(--console-border)] bg-[var(--console-surface-muted)] text-[var(--console-muted)] hover:border-[var(--console-border-strong)] hover:text-[var(--console-text)]`}`,children:[i?(0,R.jsx)(Se,{className:`size-3`,strokeWidth:1.8}):(0,R.jsx)(y,{className:`size-3`,strokeWidth:1.8}),(0,R.jsx)(`span`,{children:i?`Copied`:`Copy resume`})]}):null}function jo(e,t){let n=e.replace(/^\/+|\/+$/g,``),r=n?n.split(`/`).map(e=>e.trim()).filter(Boolean):[];if(r.length===0)return{mode:`root`,activeAgentKey:null,activeSessionSlug:null};if(r[0]?.toLowerCase()===`projects`){if(r.length===1)return{mode:`projects`,activeAgentKey:null,activeSessionSlug:null};if(r.length===3)try{let e=decodeURIComponent(r[1]);return Ra(e)?{mode:`project`,activeAgentKey:null,activeSessionSlug:null,activeProjectKind:e,activeProjectKey:Ba(r[2])}:{mode:`invalidRoute`,activeAgentKey:null,activeSessionSlug:null}}catch{return{mode:`invalidRoute`,activeAgentKey:null,activeSessionSlug:null}}return{mode:`invalidRoute`,activeAgentKey:null,activeSessionSlug:null}}if(r.length===1){let e=r[0].toLowerCase();return t.has(e)?{mode:`agent`,activeAgentKey:e,activeSessionSlug:null}:{mode:`missingAgent`,activeAgentKey:null,activeSessionSlug:null,attemptedKey:e}}if(r.length===2){let e=r[0].toLowerCase(),n=r[1];return t.has(e)&&n?{mode:`session`,activeAgentKey:e,activeSessionSlug:n}:t.has(e)?{mode:`missingSession`,activeAgentKey:e,activeSessionSlug:n,attemptedSessionSlug:n}:{mode:`missingAgent`,activeAgentKey:null,activeSessionSlug:null,attemptedKey:e}}return{mode:`invalidRoute`,activeAgentKey:null,activeSessionSlug:null}}function Mo(){let[e,t]=(0,N.useState)(null),n=(0,N.useCallback)(e=>{t(t=>t&&e.updatedAt<t.updatedAt?t:e)},[]);return(0,N.useEffect)(()=>{let e=!1;return Ge().then(t=>{e||n(t)}).catch(e=>{console.error(`Failed to load scan status:`,e)}),()=>{e=!0}},[n]),{scanStatus:e,setScanStatus:n}}function No(e){let[t,n]=(0,N.useState)(null),[r,i]=(0,N.useState)(!1),[a,o]=(0,N.useState)(null);return(0,N.useEffect)(()=>{if(e.mode!==`session`){n(null),o(null);return}let t=new AbortController;i(!0),o(null);let r=performance.now();return I(`session.open.start`,{agent:e.activeAgentKey,session:e.activeSessionSlug}),(async()=>{try{let t=await Je(e.activeAgentKey,e.activeSessionSlug);n(t),I(`session.open.done`,{agent:e.activeAgentKey,session:e.activeSessionSlug,duration_ms:Math.round(performance.now()-r),messages:t.messages.length})}catch(t){I(`session.open.error`,{agent:e.activeAgentKey,session:e.activeSessionSlug,duration_ms:Math.round(performance.now()-r),error:t instanceof Error?t.message:String(t)}),o(`Session not found`),n(null)}finally{i(!1)}})(),()=>t.abort()},[e.mode===`session`?`${e.activeAgentKey}/${e.activeSessionSlug}`:``,e.activeAgentKey,e.activeSessionSlug,e.mode]),{session:t,sessionLoading:r,sessionError:a,refresh:(0,N.useCallback)(async()=>{if(e.mode===`session`)try{n(await Je(e.activeAgentKey,e.activeSessionSlug)),o(null)}catch{n(null),o(`Session not found`)}},[e])}}function Po(e,t){return(t.time_updated??t.time_created)-(e.time_updated??e.time_created)}function Fo(e){return e.slug.split(`/`)[0]?.toLowerCase()||`unknown`}function Io(e,t){return`${e.toLowerCase()}/${t}`}function Lo(e,t){return`${e}\0${t.toLowerCase()}`}function Ro(e,t,n){let r=e.get(t);if(r){r.push(n);return}e.set(t,[n])}function zo(e,t){let n=new Map,r=new Map,i=new Map,a=new Map,o=new Map,s=new Map,c=new Map,l=new Map,u=[],d=new Set(t.map(e=>e.name.toLowerCase()));for(let e of d)r.set(e,[]),s.set(e,[]);for(let t of e){let e=Fo(t),r={...t,agentKey:e,sessionSlug:t.id,fullPath:t.slug};u.push(r);let i=Io(e,t.id);n.has(i)||n.set(i,t),d.has(e)&&s.get(e).push(r);let a=t.project_identity;if(!a?.key)continue;Ro(c,za(a),r);let o=l.get(a.key);o?o.count+=1:l.set(a.key,{key:a.key,label:a.displayName||t.directory,count:1})}let f=e.toSorted(Po);for(let e of f){let t=Fo(e);d.has(t)&&r.get(t).push(e);let n=e.project_identity;if(!n?.key)continue;let s=za(n);Ro(i,s,e),Ro(a,Lo(s,t),e),Ro(o,n.key,e)}return{byRouteKey:n,byAgent:r,byProjectIdentityKey:i,byProjectAgentKey:a,byProjectKey:o,byLandingAgent:s,byLandingProjectIdentityKey:c,landingSessions:u,sessionsByActivity:f,projectOptions:[...l.values()].toSorted((e,t)=>t.count-e.count).slice(0,8)}}function Bo(e){let t=new Map,n=new Map;for(let r=0;r<e.length;r+=1){let i=e[r];t.has(i.id)||(t.set(i.id,i),n.set(i.id,r))}return{byId:t,indexById:n}}function Vo({active:e,label:t,onClick:n}){return(0,R.jsx)(`button`,{type:`button`,onClick:n,className:`console-mono rounded-sm border px-2 py-1 text-[10px] transition-colors ${e?`border-[var(--console-border-strong)] bg-[var(--console-accent)] text-white`:`border-[var(--console-border)] bg-[var(--console-surface-muted)] text-[var(--console-muted)] hover:bg-white`}`,children:t})}var Ho=[`bugfix`,`refactoring`,`feature-dev`,`testing`,`docs`,`git-ops`,`build-deploy`,`exploration`,`planning`],Uo=[`apply_patch`,`bash`,`read`,`edit`,`grep`],Wo=[{kind:`read`,label:`Read`},{kind:`edit`,label:`Edit`},{kind:`write`,label:`Write`},{kind:`delete`,label:`Delete`}],Go=[{id:`paid`,label:`Cost > $0`,costMin:1e-6},{id:`one_plus`,label:`Cost >= $1`,costMin:1},{id:`ten_plus`,label:`Cost >= $10`,costMin:10}];function Ko({agents:e,projects:t,filters:n,onChangeFilters:r}){let i=Object.values(n).some(Boolean),a=(e,t)=>{r(n=>({...n,[e]:n[e]===t?void 0:t}))};return(0,R.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white/85 p-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`Scope`}),(0,R.jsx)(Vo,{active:!n.projectKey,label:`All`,onClick:()=>r(e=>({...e,projectKey:void 0}))}),t.map(e=>(0,R.jsx)(Vo,{active:n.projectKey===e.key,label:e.showCount===!1?e.label:`${e.label} · ${e.count}`,onClick:()=>a(`projectKey`,e.key)},e.key))]}),(0,R.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`Agent`}),(0,R.jsx)(Vo,{active:!n.agent,label:`All Agents`,onClick:()=>r(e=>({...e,agent:void 0}))}),e.map(e=>(0,R.jsx)(Vo,{active:n.agent===e.name,label:e.displayName,onClick:()=>a(`agent`,e.name)},e.name))]}),(0,R.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`Tag`}),Ho.map(e=>(0,R.jsx)(Vo,{active:n.tag===e,label:Pi[e],onClick:()=>a(`tag`,e)},e))]}),(0,R.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`Signal`}),Uo.map(e=>(0,R.jsx)(Vo,{active:n.tool===e,label:`tool:${e}`,onClick:()=>a(`tool`,e)},e))]}),(0,R.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`File Activity`}),Wo.map(e=>(0,R.jsx)(Vo,{active:n.fileKind===e.kind,label:e.label,onClick:()=>a(`fileKind`,e.kind)},e.kind))]}),(0,R.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`Cost Range`}),(0,R.jsx)(Vo,{active:!n.costRange,label:`Any Cost`,onClick:()=>r(e=>({...e,costRange:void 0}))}),Go.map(e=>(0,R.jsx)(Vo,{active:n.costRange===e.id,label:e.label,onClick:()=>a(`costRange`,e.id)},e.id)),i?(0,R.jsx)(`button`,{type:`button`,onClick:()=>r({}),className:`console-mono ml-auto rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[10px] text-[var(--console-muted)] transition-colors hover:bg-white`,children:`Clear`}):null]})]})}function qo(e){let[t,n]=(0,N.useState)(``),[r,i]=(0,N.useState)(``),[a,o]=(0,N.useState)(!1),[s,c]=(0,N.useState)({}),[l,u]=(0,N.useState)([]),[d,f]=(0,N.useState)(!1),[p,m]=(0,N.useState)(0),h=(0,N.useRef)(null),g=(0,N.useRef)(new Map),_=(0,N.useMemo)(()=>{let e=Go.find(e=>e.id===s.costRange);return{agent:s.agent,projectKey:s.projectKey,tag:s.tag,tool:s.tool,fileKind:s.fileKind,costMin:e?.costMin}},[s]),v=r.trim().length>0||!!(s.tool||s.fileKind),y=(0,N.useMemo)(()=>{let t=Go.find(e=>e.id===s.costRange),n=s.agent?e.byAgent.get(s.agent)??[]:null,r=s.projectKey?e.byProjectKey.get(s.projectKey)??[]:null,i=n&&r?n.length<=r.length?n:r:n??r??e.sessionsByActivity,a=[];for(let e of i)if(!(s.agent&&Fo(e)!==s.agent)&&!(s.projectKey&&e.project_identity?.key!==s.projectKey)&&!(s.tag&&!e.smart_tags?.includes(s.tag))&&!(t&&e.stats.total_cost<t.costMin)&&(a.push({agentName:Fo(e),session:e,snippet:`Recent session · ${e.directory}`,matchType:`recent`}),a.length>=50))break;return a},[s,e]);return(0,N.useEffect)(()=>{if(!a){u([]),f(!1);return}if(!v){u(y),f(!1);return}let e=!1;f(!0);let t=performance.now();return I(`search.start`,{query_length:r.length}),Xe(r,_).then(n=>{e||(u(n.results),I(`search.done`,{duration_ms:Math.round(performance.now()-t),results:n.results.length}))}).catch(n=>{e||(console.error(`Failed to load search results:`,n),I(`search.error`,{duration_ms:Math.round(performance.now()-t),error:n instanceof Error?n.message:String(n)}),u([]))}).finally(()=>{e||f(!1)}),()=>{e=!0}},[r,a,y,_,v]),(0,N.useEffect)(()=>{a&&m(e=>l.length===0?0:Math.min(e,l.length-1))},[a,l.length]),(0,N.useEffect)(()=>{if(!a)return;let e=l[p];if(!e)return;let t=`${e.agentName}/${e.session.id}`;g.current.get(t)?.scrollIntoView({block:`nearest`})},[a,l,p]),{draftSearchQuery:t,activeSearchQuery:r,searchMode:a,searchFilters:s,searchResults:l,searchLoading:d,usesServerSearch:v,selectedSearchIndex:p,searchInputRef:h,searchResultRefs:g,setDraftSearchQuery:n,setSearchFilters:c,setSelectedSearchIndex:m,openSearch:(0,N.useCallback)(()=>{o(!0),window.setTimeout(()=>{h.current?.focus(),h.current?.select()},0)},[]),submitSearch:(0,N.useCallback)(()=>{i(t.trim()),o(!0),m(0)},[t]),closeSearch:(0,N.useCallback)(()=>{o(!1),i(``)},[]),refresh:(0,N.useCallback)(async()=>{if(a&&v)try{u((await Xe(r,_)).results)}catch(e){console.error(`Failed to refresh search results:`,e)}},[a,v,r,_])}}function Jo(e){let[t,n]=(0,N.useState)([]);(0,N.useEffect)(()=>{let e=!1;return Ze().then(t=>{e||n(t.bookmarks)}).catch(e=>{console.error(`Failed to load bookmarks:`,e)}),()=>{e=!0}},[]),(0,N.useEffect)(()=>{let t=!1;return n(n=>{let r=Fa(n,e);return r===n?n:($e(r.map(({bookmarked_at:e,...t})=>t)).catch(e=>{t||console.error(`Failed to sync bookmark snapshots:`,e)}),r)}),()=>{t=!0}},[e]),(0,N.useEffect)(()=>{let e=!1;return(async()=>{let t=Ma();if(t.length!==0)try{let r=await $e(t.map(({bookmarked_at:e,...t})=>t));if(e)return;n(r.bookmarks),Na()}catch(t){e||console.error(`Failed to migrate legacy bookmarks:`,t)}})(),()=>{e=!0}},[]);let r=(0,N.useMemo)(()=>new Set(t.map(e=>Aa(e.agentKey,e.sessionId))),[t]),i=(0,N.useCallback)((e,t)=>r.has(Aa(e,t)),[r]),a=(0,N.useCallback)(e=>{let i=Aa(e.agentKey,e.sessionId),a=r.has(i),o=t;n(a?o.filter(e=>Aa(e.agentKey,e.sessionId)!==i):[...o,e].toSorted((e,t)=>{let n=e.time_updated??e.time_created;return(t.time_updated??t.time_created)-n})),I(a?`bookmark.delete`:`bookmark.add`,{agent:e.agentKey,session:e.sessionId}),(a?et(e.agentKey,e.sessionId):Qe({agentKey:e.agentKey,sessionId:e.sessionId,fullPath:e.fullPath,title:e.title,directory:e.directory,time_created:e.time_created,time_updated:e.time_updated,stats:e.stats})).catch(e=>{console.error(`Failed to toggle bookmark:`,e),n(o)})},[r,t]),o=(0,N.useCallback)((e,t)=>{a(ja(e,t))},[a]);return{bookmarkedSessions:(0,N.useMemo)(()=>t.toSorted((e,t)=>(t.time_updated??t.time_created)-(e.time_updated??e.time_created)),[t]),isSessionBookmarked:i,toggleBookmark:a,toggleSessionBookmark:o}}function Yo(e){let[t,n]=(0,N.useState)(null);return(0,N.useEffect)(()=>{if(!e)return;let t=!1;return Ye(e.window).then(e=>{t||n(e)}).catch(e=>{console.error(`Failed to load dashboard:`,e)}),()=>{t=!0}},[e]),{dashboard:t,refresh:(0,N.useCallback)(async()=>{try{n(await Ye(e?.window))}catch(e){console.error(`Failed to refresh dashboard:`,e)}},[e])}}function Xo(e,t,n,r){let[i,a]=(0,N.useState)(null),[o,s]=(0,N.useState)(!1),[c,l]=(0,N.useState)(null),[u,d]=(0,N.useState)(void 0);return(0,N.useEffect)(()=>{r&&d(void 0)},[r]),(0,N.useEffect)(()=>{if(!n||!e){a(null),l(null),s(!1);return}let r=!1;return s(!0),l(null),Ye(e.window,{projectKind:t??void 0,projectKey:n,agent:u}).then(e=>{r||a(e)}).catch(e=>{r||(console.error(`Failed to load project dashboard:`,e),a(null),l(`Failed to load project dashboard`))}).finally(()=>{r||s(!1)}),()=>{r=!0}},[t,n,e,u]),{projectDashboard:i,projectDashboardLoading:o,projectDashboardError:c,selectedProjectAgent:u,setSelectedProjectAgent:d,refresh:(0,N.useCallback)(async()=>{if(!(!n||!e))try{a(await Ye(e.window,{projectKind:t??void 0,projectKey:n,agent:u}))}catch(e){console.error(`Failed to refresh project dashboard:`,e)}},[t,n,e,u])}}function Zo(){let[e,t]=(0,N.useState)(null);return{appConfig:e,refresh:(0,N.useCallback)(async()=>{let e=await We();return t(e),e},[])}}function Qo(){let[e,t]=(0,N.useState)([]);return{agents:e,validAgentKeys:(0,N.useMemo)(()=>new Set(e.map(e=>e.name.toLowerCase())),[e]),agentNameMap:(0,N.useMemo)(()=>new Map(e.map(e=>[e.name.toLowerCase(),e.displayName])),[e]),refresh:(0,N.useCallback)(async()=>{let e=await Ke();return t(e),e},[])}}function $o(e,t){return(t.time_updated??t.time_created)-(e.time_updated??e.time_created)}function es(e,t){if(!t.changedSessionHeads||!t.removedSessionRefs)return null;let n=new Map(e.map(e=>[Io(Fo(e),e.id),e]));for(let{agentName:e,sessionId:r}of t.removedSessionRefs)n.delete(Io(e,r));for(let{agentName:e,session:r}of t.changedSessionHeads)n.set(Io(e,r.id),r);return[...n.values()].sort($o)}function ts(){let[e,t]=(0,N.useState)([]);return{sessions:e,refresh:(0,N.useCallback)(async e=>{let n=await F({from:e.from,to:e.to});return t(n.sessions),n.sessions},[]),applyLiveEvent:(0,N.useCallback)(e=>{t(t=>es(t,e)??t)},[])}}function ns(){let[e,t]=(0,N.useState)([]);return{projects:e,refresh:(0,N.useCallback)(async()=>{try{let e=await qe();return t(e.projects),e.projects}catch(e){return console.error(`Failed to load projects:`,e),t([]),[]}},[])}}function rs({refreshAppConfig:e,refreshAgents:t,refreshSessions:n,refreshProjects:r}){let[i,a]=(0,N.useState)(!0),[o,s]=(0,N.useState)(null);return(0,N.useEffect)(()=>{let i=new AbortController,o=performance.now();return I(`app.load.start`,{path:window.location.pathname}),(async()=>{try{let i=await e(),[a,s,c]=await Promise.all([t(),n(i.window),r()]);I(`app.load.done`,{duration_ms:Math.round(performance.now()-o),agents:a.length,sessions:s.length,projects:c.length})}catch(e){console.error(`Failed to load data:`,e),I(`app.load.error`,{duration_ms:Math.round(performance.now()-o),error:e instanceof Error?e.message:String(e)}),s(`Failed to load data. Is the CLI server running?`)}finally{a(!1)}})(),()=>i.abort()},[e,t,n,r]),{loading:i,error:o}}function is(e){let[t,n]=(0,N.useState)(null),[r,i]=(0,N.useState)(null),{appConfig:a,viewState:o,applySessionsLiveEvent:s,refreshAgents:c,refreshSessions:l,refreshProjects:u,refreshDashboard:d,refreshProjectDashboard:f,refreshSessionDetail:p,refreshSearch:m,setScanStatus:h}=e,g=(0,N.useEffectEvent)(async e=>{try{let t=!!(e.changedSessionHeads&&e.removedSessionRefs);t&&s(e),await Promise.all([c(),t||!a?Promise.resolve():l(a.window),u()]),await d(),await f(),o.mode===`session`&&await p(),await m(),e.newSessions>0&&n(`发现 ${e.newSessions} 个新会话,列表已自动刷新`)}catch(e){console.error(`Failed to sync live session update:`,e)}}),_=(0,N.useEffectEvent)(()=>{i(null),g({type:`sessions-updated`,changedAgents:[],newSessions:0,updatedSessions:0,removedSessions:0,totalSessions:0,timestamp:Date.now()})});return(0,N.useEffect)(()=>it(e=>{g(e)},e=>{h(e)},()=>{_()},()=>{i(`实时更新已断开,重连中…`)}),[h]),(0,N.useEffect)(()=>{if(!t)return;let e=window.setTimeout(()=>{n(null)},3500);return()=>{window.clearTimeout(e)}},[t]),{liveNotice:r??t}}function as(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase();return t===`input`||t===`textarea`||t===`select`||e.isContentEditable}function os(e){let{viewState:t,browseBy:n,navigate:r,activeAgentKey:i,sidebarSessions:a,sidebarSessionLookup:o,selectedSidebarSessionId:s,setSelectedSidebarSessionId:c,selectedProjectNavigationIdentity:l,shortcutHelpOpen:u,setShortcutHelpOpen:d,dismissShortcutHint:f,isSearchMode:p,activeSearchQuery:m,searchResults:h,selectedSearchIndex:g,setSelectedSearchIndex:_,setDraftSearchQuery:v,openSearch:y,closeSearch:ee}=e,b=(0,N.useEffectEvent)(e=>{let b=e.key;if((e.metaKey||e.ctrlKey)&&b.toLowerCase()===`k`){e.preventDefault(),y(),_(0);return}if(e.defaultPrevented||e.metaKey||e.ctrlKey||e.altKey||e.isComposing)return;let x=e.target,S=as(x);if(u){b===`Escape`&&(e.preventDefault(),d(!1));return}if(S){b===`Escape`&&(e.preventDefault(),x instanceof HTMLElement&&x.blur());return}if(b===`?`){e.preventDefault(),d(!0),f();return}if(b===`/`){e.preventDefault(),f(),y();return}if(b===`Escape`){if(e.preventDefault(),p){ee(),v(``);return}if(t.mode===`session`&&t.activeAgentKey){if(n===`projects`&&l){r(Va(l));return}r(`/${t.activeAgentKey}`)}return}if(p){if(h.length===0)return;if(b===`j`){e.preventDefault(),f(),_(e=>Math.min(e+1,h.length-1));return}if(b===`k`){e.preventDefault(),f(),_(e=>Math.max(e-1,0));return}if(b===`g`){e.preventDefault(),f(),_(0);return}if(b===`G`){e.preventDefault(),f(),_(h.length-1);return}if(b===`Enter`){let t=h[g];if(!t)return;e.preventDefault(),f(),ee(),r(`/${t.agentName.toLowerCase()}/${t.session.id}`,{state:{searchQuery:m}})}return}if(n===`agents`&&!i||a.length===0)return;let te=e=>{f();let t=s==null?-1:o.indexById.get(s)??-1,n=t>=0?t:e>=0?-1:a.length;c(a[Math.max(0,Math.min(n+e,a.length-1))]?.id??null)};if(b===`j`){e.preventDefault(),te(1);return}if(b===`k`){e.preventDefault(),te(-1);return}if(b===`g`){e.preventDefault(),f(),c(a[0]?.id??null);return}if(b===`G`){e.preventDefault(),f(),c(a.at(-1)?.id??null);return}if(b===`Enter`){let t=s==null?null:o.byId.get(s);if(!t)return;e.preventDefault(),f(),r(n===`projects`?`/${t.slug}`:`/${i}/${t.id}`)}});(0,N.useEffect)(()=>(window.addEventListener(`keydown`,b),()=>window.removeEventListener(`keydown`,b)),[])}function ss(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function cs(e){if(!e)return null;let{from:t,to:n,days:r}=e.window;if(t==null)return`All time`;let i=ss(t),a=ss(n??Date.now());return r?`Last ${r}d · ${i} → ${a}`:`${i} → ${a}`}function ls(e,t,n){return t?e?`Searching for "${e}"`:`Loading recent sessions`:e?`${n} matches for "${e}"`:`${n} recent sessions`}function us(e){if(!e?.active)return null;let t=e.completedAgents.length,n=e.totalAgents,r=e.scanningAgents[0],i=r?e.agentStatuses[r]:null,a=i?.total&&i.processed!=null?` · ${i.processed}/${i.total}`:``,o=n>0?r?` · ${r}${a} · ${t}/${n} agents ready`:` · ${t}/${n} agents ready`:``;return e.phase===`initializing`?`First-run setup: indexing all local sessions${o}. Your selected time window appears after this finishes.`:e.phase===`indexing`?`Preparing local session index`:n>0?r?`Checking for new or changed sessions · ${r}${a} · ${t}/${n} agents ready`:`Checking for new or changed sessions · ${t}/${n} agents ready`:`Checking for new or changed sessions`}function ds(e,t){let n=e?.agentStatuses[t];return!n||n.status===`complete`?null:n.total&&n.processed!=null?`${n.processed}/${n.total}`:n.status===`scanning`?`Scanning`:`Pending`}function fs(e,t,n){let r=e?.agentStatuses[t];return r?.status===`complete`&&r.sessions!=null?r.sessions:n}var ps=`
|
|
46
|
-
[data-type='item'][data-item-type='file'] > [data-item-section='icon'] {
|
|
47
|
-
display: none;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
[data-type='item'][data-item-type='file'] > [data-item-section='spacing'] {
|
|
51
|
-
padding-left: 2px;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
[data-type='item'][data-item-type='file'] > [data-item-section='spacing'] > [data-item-section='spacing-item'] {
|
|
55
|
-
margin-right: 4px;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
[data-type='item'][data-item-type='file'] > [data-item-section='content'] {
|
|
59
|
-
flex: 1 1 auto;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
[data-type='item'][data-item-type='file'] > [data-item-section='decoration'] {
|
|
63
|
-
flex: 0 0 auto;
|
|
64
|
-
padding-inline: 8px 6px;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
[data-type='item'][data-item-type='file'] > [data-item-section='decoration'] > span {
|
|
68
|
-
cursor: pointer;
|
|
69
|
-
font-size: 18px;
|
|
70
|
-
line-height: 1;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
[data-type='item'][data-item-type='file'] [data-truncate-group-container='middle'] {
|
|
74
|
-
width: 100%;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
[data-type='item'][data-item-type='file']
|
|
78
|
-
[data-truncate-group-container='middle']
|
|
79
|
-
> div[data-truncate-segment-priority='2'] {
|
|
80
|
-
flex: 0 1 auto;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
[data-type='item'][data-item-type='file']
|
|
84
|
-
[data-truncate-group-container='middle']
|
|
85
|
-
> div[data-truncate-segment-priority='1'] {
|
|
86
|
-
flex: 1 999999 auto;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
[data-type='item'][data-item-type='file']
|
|
90
|
-
[data-truncate-group-container='middle']
|
|
91
|
-
[data-truncate-container='fruncate']
|
|
92
|
-
[data-truncate-grid] {
|
|
93
|
-
grid-template-columns: minmax(0, max-content) 0;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
[data-type='item'][data-item-type='file']
|
|
97
|
-
[data-truncate-group-container='middle']
|
|
98
|
-
[data-truncate-container='fruncate']
|
|
99
|
-
[data-truncate-content] {
|
|
100
|
-
direction: ltr;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
[data-type='item'][data-item-type='file']
|
|
104
|
-
[data-truncate-group-container='middle']
|
|
105
|
-
[data-truncate-container='fruncate']
|
|
106
|
-
[data-truncate-marker] {
|
|
107
|
-
right: 0;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
[data-type='item'][data-item-type='file'] [data-truncate-marker] {
|
|
111
|
-
display: none;
|
|
112
|
-
}
|
|
113
|
-
`;function ms(e){return e.replaceAll(`/`,`∕`).trim()||`(untitled)`}function hs(e){return e.replace(/\/+$/,``).split(`/`).at(-1)?.trim()||`(unknown)`}function gs(e){let t=e.project_identity;if(t)return{key:`${t.kind}:${t.key}`,label:t.displayName||hs(e.directory)};let n=hs(e.directory);return{key:n===`(unknown)`?`__unknown__`:`path:${e.directory||n}`,label:n}}function _s(e){return e.time_updated??e.time_created}function vs(e,t,n){let r=e.get(t.path)??2**53-1,i=e.get(n.path)??2**53-1;return r===i?t.path.localeCompare(n.path):r-i}function ys(e){let t=new Map,n=new Map,r=new Map,i=new Map,a=new Map,o=new Map,s=new Set,c=[],l=new Map;for(let t of e){let{key:e,label:n}=gs(t),r=l.get(e);r?r.sessions.push(t):l.set(e,{label:n,sessions:[t]})}let u=[...l.entries()].sort(([,e],[,t])=>{if(e.label===`(unknown)`)return 1;if(t.label===`(unknown)`)return-1;let n=Math.max(...e.sessions.map(_s));return Math.max(...t.sessions.map(_s))-n}),d=0,f=new Set;for(let[,e]of u){let l=ms(e.label),u=`${l}/`,p=2;for(;f.has(u);)u=`${l} (${p})/`,p+=1;f.add(u);let m=u.slice(0,-1),h=new Map;t.set(u,d),t.set(m,d),d+=1,a.set(u,`${e.sessions.length}`),a.set(m,`${e.sessions.length}`);for(let t of e.sessions)h.set(t.title,(h.get(t.title)??0)+1);for(let a of e.sessions){let e=(h.get(a.title)??0)>1?`${ms(a.title)} #${a.id.slice(0,8)}`:ms(a.title),l=`${u}${e}`,f=2;for(;s.has(l);)l=`${u}${e} (${f})`,f+=1;s.add(l),c.push(l),t.set(l,d),d+=1,n.set(a.id,l),r.set(a.id,u),i.set(l,a.id),o.set(l,a)}}return{paths:c,sortOrderByPath:t,pathBySessionId:n,groupPathBySessionId:r,sessionIdByPath:i,groupCountByPath:a,sessionByPath:o}}function bs(e,t){if(!dt())return t();let n=performance.now(),r=t(),i=performance.now();return mt({id:e,source:`custom-timing`,phase:`measure`,actualDuration:Math.round((i-n)*100)/100,baseDuration:0,startTime:n,commitTime:i}),r}var xs=(0,N.memo)(function({sessions:e,activeSessionId:t,selectedSessionId:n,onSelectSession:r,bookmarkedSessionIds:a,onToggleBookmark:s}){let c=(0,N.useMemo)(()=>bs(`SessionTreeSidebar:buildTreeModel`,()=>ys(e)),[e]),l=(0,N.useRef)(c.sortOrderByPath),u=(0,N.useRef)(c.sessionIdByPath),d=(0,N.useRef)(c.groupCountByPath),f=(0,N.useRef)(c.sessionByPath),p=(0,N.useRef)(a),m=(0,N.useRef)(r),h=(0,N.useRef)(s),g={"--trees-bg-override":`transparent`,"--trees-border-color-override":`var(--console-border)`,"--trees-fg-override":`var(--console-text)`,"--trees-fg-muted-override":`var(--console-muted)`,"--trees-font-family-override":`"JetBrains Mono", "IBM Plex Mono", "SFMono-Regular", Menlo, Monaco, Consolas, monospace`,"--trees-font-size-override":`12px`,"--trees-item-margin-x-override":`0px`,"--trees-item-padding-x-override":`8px`,"--trees-selected-bg-override":`var(--console-surface-muted)`},{model:_}=o({flattenEmptyDirectories:!1,initialExpansion:`closed`,paths:c.paths,sort:(e,t)=>vs(l.current,e,t),density:`compact`,unsafeCSS:ps,onSelectionChange(e){let t=u.current.get(e[0]??``);t&&m.current(t)},renderRowDecoration({item:e}){let t=f.current.get(e.path);if(t){let e=p.current.has(t.id);return{text:e?`★`:`☆`,title:e?`Remove bookmark`:`Add bookmark`}}return d.current.get(e.path)?{text:d.current.get(e.path),title:`Sessions`}:null}});(0,N.useEffect)(()=>{l.current=c.sortOrderByPath,u.current=c.sessionIdByPath,d.current=c.groupCountByPath,f.current=c.sessionByPath,_.resetPaths(c.paths)},[_,c]),(0,N.useEffect)(()=>{m.current=r},[r]),(0,N.useEffect)(()=>{p.current=a,_.resetPaths(c.paths)},[a,_,c.paths]),(0,N.useEffect)(()=>{h.current=s},[s]);function v(e){let t=e.nativeEvent.composedPath(),n=t.find(e=>e instanceof HTMLElement&&e.parentElement?.getAttribute(`data-item-section`)===`decoration`),r=t.find(e=>e instanceof HTMLElement&&e.getAttribute(`data-type`)===`item`),i=r?f.current.get(r.getAttribute(`data-item-path`)??``):null;!n||!i||(e.preventDefault(),e.stopPropagation(),h.current(i))}return(0,N.useEffect)(()=>{let e=c.pathBySessionId.get(t??``),r=c.pathBySessionId.get(n??``)??e,i=n??t??``,a=c.groupPathBySessionId.get(i);if(e&&_.getItem(e)?.select(),r&&t){let e=a?_.getItem(a):null;e&&`expand`in e&&e.expand(),_.focusPath(r);return}a&&_.focusPath(a)},[t,_,c,n]),(0,R.jsx)(`div`,{className:`session-tree h-[min(560px,calc(100vh-410px))] min-h-56 overflow-hidden`,style:g,onClickCapture:v,children:(0,R.jsx)(i,{model:_,style:{height:`100%`},"aria-label":`Sessions`})})});function Ss({value:e,onChange:t,projectsDisabled:n=!1}){return(0,R.jsx)(`div`,{role:`radiogroup`,"aria-label":`Browse by`,className:`grid gap-1.5`,children:[{value:`projects`,label:`Projects`},{value:`agents`,label:`Agents`}].map(r=>{let i=e===r.value,a=r.value===`projects`&&n;return(0,R.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":i,disabled:a,onClick:()=>t(r.value),className:`console-mono flex items-center gap-2 rounded-sm border px-3 py-1.5 text-left text-xs transition-colors ${a?`cursor-not-allowed border-transparent text-[var(--console-muted)] opacity-45`:i?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,title:a?`Project grouping is available after the current scan finishes`:void 0,children:[(0,R.jsx)(`span`,{className:`flex size-3 shrink-0 items-center justify-center rounded-full border ${i?`border-[var(--console-accent)]`:`border-[var(--console-border-strong)]`}`,children:i?(0,R.jsx)(`span`,{className:`size-1.5 rounded-full bg-[var(--console-accent)]`}):null}),(0,R.jsx)(`span`,{children:r.label})]},r.value)})})}function Cs({sessions:e,activeSessionId:t,selectedSessionId:n,bookmarkedSessionIds:r,onSelectSession:i,onToggleBookmark:a}){return(0,R.jsx)(`div`,{className:`console-scrollbar h-[min(560px,calc(100vh-410px))] min-h-56 overflow-y-auto`,children:(0,R.jsx)(`ul`,{className:`space-y-1`,children:e.map(e=>{let o=Fo(e),s=L.agents[o],c=t===e.id,l=n===e.id;return(0,R.jsx)(`li`,{children:(0,R.jsxs)(`div`,{className:`flex items-start gap-1 rounded-sm border px-2 py-1.5 transition-colors ${c||l?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>i(e),className:`min-w-0 flex-1 text-left`,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[s?.icon?(0,R.jsx)(`img`,{src:s.icon,alt:s.name,className:`size-3.5 shrink-0 object-contain`}):null,(0,R.jsx)(`span`,{className:`console-mono line-clamp-1 text-xs text-[var(--console-text)]`,children:e.title})]}),(0,R.jsx)(`span`,{className:`console-mono mt-0.5 block truncate text-[10px] text-[var(--console-muted)]`,children:Br(e.time_updated??e.time_created)})]}),(0,R.jsx)(va,{active:r.has(e.id),onToggle:()=>a(e)})]})},e.slug)})})})}function ws({agents:e,activeAgentKey:t,scanStatus:n,isScanActive:r}){return(0,R.jsx)(R.Fragment,{children:e.map(e=>{let i=e.name.toLowerCase(),a=i===t,o=L.agents[i],s=ds(n,e.name),c=r&&s!==null,l=`ml-4 flex items-center gap-2 rounded-sm border px-3 py-1.5 text-left transition-colors ${c?`cursor-not-allowed border-transparent text-[var(--console-muted)] opacity-50`:a?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,u=(0,R.jsxs)(R.Fragment,{children:[o?.icon&&(0,R.jsx)(`img`,{src:o.icon,alt:e.displayName,className:`size-3.5 object-contain`}),(0,R.jsx)(`span`,{className:`console-mono line-clamp-1 flex-1 text-xs`,children:e.displayName}),(0,R.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:s??fs(n,e.name,e.count)})]});return(0,R.jsxs)(`li`,{children:[c?(0,R.jsx)(`span`,{className:l,title:`Available after this agent scan completes`,children:u}):(0,R.jsx)(C,{to:`/${i}`,className:l,children:u}),s?(0,R.jsx)(`span`,{className:`ml-4 mt-1 block h-1 overflow-hidden rounded-sm bg-[var(--console-surface-muted)]`,children:(0,R.jsx)(`span`,{className:`block h-full bg-[var(--console-accent)]`,style:{width:`${n?.agentStatuses[e.name]?.total?Math.round((n.agentStatuses[e.name]?.processed??0)/n.agentStatuses[e.name].total*100):8}%`}})}):null]},e.name)})})}function Ts({projects:e,selectedProjectNavigationId:t,onSelectProject:n}){return(0,R.jsx)(R.Fragment,{children:e.map(e=>{let r=Ia(e),i=t===za(r);return(0,R.jsx)(`li`,{children:(0,R.jsxs)(C,{to:Va(r),onClick:()=>n(r),className:`ml-4 flex min-w-0 items-center gap-2 rounded-sm border px-3 py-1.5 text-left transition-colors ${i?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,children:[(0,R.jsx)(`span`,{className:`console-mono min-w-0 flex-1 truncate text-xs`,children:e.displayName}),(0,R.jsx)(`span`,{className:`console-mono shrink-0 text-[11px] text-[var(--console-muted)]`,children:e.sessionCount})]})},`${e.identityKind}:${e.identityKey}`)})})}function Es({sidebarCollapsed:e,browseBy:t,onChangeBrowseBy:n,isScanActive:r,viewState:i,agents:a,activeAgentKey:o,scanStatus:s,projects:c,selectedProjectNavigationId:l,onSelectProject:u,loading:d,bookmarkedSessions:f,onToggleBookmark:p,sidebarSessions:m,selectedSidebarSessionId:h,bookmarkedSidebarSessionIds:g,onSelectFlatSidebarSession:_,onToggleSidebarSessionBookmark:v,onSelectTreeSidebarSession:y}){return(0,R.jsx)(`aside`,{className:`w-64 shrink-0 flex-col border-r border-[var(--console-border)] bg-[var(--console-sidebar-bg)] ${e?`hidden`:`hidden lg:flex`}`,children:(0,R.jsxs)(`div`,{className:`console-scrollbar flex-1 space-y-8 overflow-y-auto px-4 py-6`,children:[(0,R.jsxs)(`section`,{children:[(0,R.jsx)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:`BROWSE BY`}),(0,R.jsx)(Ss,{value:t,onChange:n,projectsDisabled:r})]}),(0,R.jsxs)(`section`,{children:[(0,R.jsx)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:`NAVIGATION`}),(0,R.jsxs)(`ul`,{className:`space-y-1 ${t===`projects`?`console-scrollbar max-h-[min(280px,calc(100vh-440px))] overflow-y-auto pr-1`:``}`,children:[(0,R.jsx)(`li`,{children:(0,R.jsxs)(C,{to:t===`projects`?`/projects`:`/`,className:`flex items-center gap-2 rounded-sm border px-3 py-1.5 text-left transition-colors ${t===`agents`&&i.mode===`root`||t===`projects`&&i.mode===`projects`?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,children:[(0,R.jsx)(`img`,{src:`/logo.svg?v=3`,alt:`Dashboard`,className:`size-3.5 rounded-[2px]`}),(0,R.jsx)(`span`,{className:`console-mono line-clamp-1 flex-1 text-xs`,children:`Dashboard`})]})}),t===`agents`?(0,R.jsx)(ws,{agents:a,activeAgentKey:o,scanStatus:s,isScanActive:r}):(0,R.jsx)(Ts,{projects:c,selectedProjectNavigationId:l,onSelectProject:u}),t===`agents`&&a.length===0&&!d?(0,R.jsx)(`li`,{children:(0,R.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:s?.active?`Scanning agents...`:`No agents found`})}):null,t===`projects`&&c.length===0&&!d?(0,R.jsx)(`li`,{children:(0,R.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:s?.active?`Scanning projects...`:`No projects found`})}):null]})]}),(0,R.jsxs)(`section`,{children:[(0,R.jsx)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:`BOOKMARKS`}),f.length===0?(0,R.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:`No bookmarks yet`}):(0,R.jsx)(`ul`,{className:`space-y-1`,children:f.map(e=>{let t=i.mode===`session`&&i.activeAgentKey===e.agentKey&&i.activeSessionSlug===e.sessionId,n=L.agents[e.agentKey];return(0,R.jsx)(`li`,{children:(0,R.jsxs)(`div`,{className:`flex items-start gap-2 rounded-sm border px-2 py-1.5 transition-colors ${t?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,children:[(0,R.jsxs)(C,{to:`/${e.fullPath}`,className:`flex min-w-0 flex-1 items-start gap-2`,children:[n?.icon?(0,R.jsx)(`img`,{src:n.icon,alt:n.name,className:`mt-0.5 size-3.5 shrink-0 object-contain`}):null,(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`span`,{className:`console-mono line-clamp-1 block text-xs`,children:e.title}),(0,R.jsx)(`span`,{className:`console-mono mt-0.5 line-clamp-1 block text-[10px] text-[var(--console-muted)]`,children:n?.name??e.agentKey})]})]}),(0,R.jsx)(va,{active:!0,onToggle:()=>p(e)})]})},Aa(e.agentKey,e.sessionId))})})]}),(0,R.jsxs)(`section`,{children:[(0,R.jsxs)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:[`SESSIONS`,m.length>0?(0,R.jsx)(`span`,{className:`ml-2 text-[10px] font-normal text-[var(--console-muted)]`,children:`Navigate j k · Open Enter`}):null]}),t===`agents`&&!o?(0,R.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:`Select an agent`}):t===`projects`&&!l?(0,R.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:`Select a project`}):m.length===0?(0,R.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:s?.active?`Scanning sessions...`:`No sessions yet`}):t===`projects`?(0,R.jsx)(Cs,{sessions:m,activeSessionId:i.mode===`session`?i.activeSessionSlug:null,selectedSessionId:h,bookmarkedSessionIds:g,onSelectSession:_,onToggleBookmark:v}):(0,R.jsx)(gt,{id:`SessionTreeSidebar`,detail:{sessions:m.length},children:(0,R.jsx)(xs,{sessions:m,activeSessionId:i.mode===`session`?i.activeSessionSlug:null,selectedSessionId:h,onSelectSession:y,bookmarkedSessionIds:g,onToggleBookmark:v})})]})]})})}var Ds={recent:`Recent`,title:`Title`,user_message:`User message`,assistant_reply:`Assistant reply`,tool_output:`Tool output`,file_path:`File path`};function Os(e){return e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`).replaceAll(`"`,`"`).replaceAll(`'`,`'`).replaceAll(`<mark>`,`<mark>`).replaceAll(`</mark>`,`</mark>`)}function ks({query:e,loading:t,results:n,agentNameMap:r,agents:i,projects:a,filters:o,onChangeFilters:s,onOpenResult:c,selectedIndex:l,registerResultRef:u}){let d=(0,R.jsx)(Ko,{agents:i,projects:a,filters:o,onChangeFilters:s});return t?(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[d,(0,R.jsx)(`div`,{className:`grid gap-3`,children:Array.from({length:4}).map((e,t)=>(0,R.jsxs)(`div`,{className:`animate-pulse rounded-sm border border-[var(--console-border)] bg-white/80 p-4`,children:[(0,R.jsx)(`div`,{className:`h-3 w-32 rounded bg-[var(--console-surface-muted)]`}),(0,R.jsx)(`div`,{className:`mt-3 h-4 w-2/3 rounded bg-[var(--console-surface-muted)]`}),(0,R.jsx)(`div`,{className:`mt-2 h-3 w-full rounded bg-[var(--console-surface-muted)]`}),(0,R.jsx)(`div`,{className:`mt-1 h-3 w-5/6 rounded bg-[var(--console-surface-muted)]`})]},t))})]}):n.length===0?(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[d,(0,R.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white/80 p-6`,children:[(0,R.jsx)(`h2`,{className:`console-mono text-sm font-semibold text-[var(--console-text)]`,children:e?`No matches`:`No recent sessions`}),e?(0,R.jsxs)(`p`,{className:`console-mono mt-2 text-xs text-[var(--console-muted)]`,children:[`Query: `,e]}):null]})]}):(0,R.jsxs)(`div`,{className:`grid gap-3`,children:[d,(0,R.jsx)(`div`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:`Navigate j k · Open Enter · Exit Esc`}),n.map((t,n)=>{let i=t.agentName.toLowerCase(),a=r.get(i)??t.agentName,o=`${t.agentName}/${t.session.id}`;return(0,R.jsxs)(C,{ref:e=>u(o,e),to:`/${i}/${t.session.id}`,state:{searchQuery:e},onClick:c,className:`rounded-sm border bg-white/85 p-4 transition-colors hover:border-[var(--console-border-strong)] hover:bg-white ${n===l?`border-[var(--console-border-strong)]`:`border-[var(--console-border)]`}`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-1.5 py-0.5 text-[10px] uppercase text-[var(--console-muted)]`,children:a}),(0,R.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-white px-1.5 py-0.5 text-[10px] uppercase text-[var(--console-muted)]`,children:Ds[t.matchType]}),(0,R.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:t.session.directory})]}),(0,R.jsx)(`h2`,{className:`console-mono mt-3 text-sm font-semibold text-[var(--console-text)]`,children:t.session.title}),(0,R.jsx)(Ri,{tags:t.session.smart_tags,className:`mt-2`}),(0,R.jsx)(`p`,{className:`console-mono mt-2 text-xs leading-6 text-[var(--console-muted)] [&_mark]:bg-[var(--console-accent)] [&_mark]:px-0.5 [&_mark]:text-white`,dangerouslySetInnerHTML:{__html:Os(t.snippet||t.session.title)}})]},o)})]})}var As=[{title:`Navigation`,items:[{keys:`j / k`,description:`Move through sessions or search results`},{keys:`Enter`,description:`Open the current selection`},{keys:`g / G`,description:`Jump to the first or last item`}]},{title:`Search & Help`,items:[{keys:`Cmd/Ctrl K`,description:`Open global search`},{keys:`/`,description:`Focus the search box`},{keys:`Esc`,description:`Exit search or close the current detail view`},{keys:`?`,description:`Open this shortcuts panel`}]}];function js({open:e,onClose:t}){return(0,R.jsx)(_e,{open:e,onOpenChange:e=>e?void 0:t(),children:(0,R.jsxs)(ae,{children:[(0,R.jsx)(le,{className:`shortcut-overlay fixed inset-0 z-50 bg-black/35`}),(0,R.jsxs)(he,{"aria-describedby":void 0,className:`shortcut-content fixed left-1/2 top-1/2 z-50 w-[calc(100%-2rem)] max-w-2xl origin-center -translate-x-1/2 -translate-y-1/2 rounded-sm border border-[var(--console-border-strong)] bg-white p-5 shadow-2xl outline-none`,children:[(0,R.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-[0.16em] text-[var(--console-muted)]`,children:`Keyboard Shortcuts`}),(0,R.jsx)(me,{asChild:!0,children:(0,R.jsx)(`h2`,{className:`console-mono mt-2 text-xl font-semibold text-[var(--console-text)]`,children:`Navigate without leaving the keyboard`})})]}),(0,R.jsx)(pe,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-xs text-[var(--console-text)] transition-colors hover:bg-white`,children:`Esc`})})]}),(0,R.jsx)(`div`,{className:`mt-5 grid gap-4 md:grid-cols-2`,children:As.map(e=>(0,R.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] p-4`,children:[(0,R.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:e.title}),(0,R.jsx)(`div`,{className:`mt-3 space-y-3`,children:e.items.map(e=>(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`console-mono text-xs text-[var(--console-text)]`,children:e.keys}),(0,R.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-[var(--console-muted)]`,children:e.description})]},e.keys))})]},e.title))})]})]})})}var Ms=`codesesh.shortcuts-hint-dismissed`;function Ns(){let e=g(),{appConfig:t,refresh:n}=Zo(),{agents:r,validAgentKeys:i,agentNameMap:a,refresh:o}=Qo(),{sessions:s,refresh:c,applyLiveEvent:l}=ts(),{projects:u,refresh:d}=ns(),{loading:f,error:m}=rs({refreshAppConfig:n,refreshAgents:o,refreshSessions:c,refreshProjects:d}),[h,_]=(0,N.useState)(`agents`),[v,y]=(0,N.useState)(null),{scanStatus:ee,setScanStatus:b}=Mo(),[x,S]=(0,N.useState)(null),[te,ne]=(0,N.useState)(!1),[re,ie]=(0,N.useState)(!0),[ae,se]=(0,N.useState)(!1),w=p(),T=(0,N.useMemo)(()=>jo(w.pathname,i),[w.pathname,i]),{session:E,sessionLoading:ce,sessionError:le,refresh:ue}=No(T);(0,N.useEffect)(()=>{I(`route.change`,{path:w.pathname,mode:T.mode,agent:T.activeAgentKey,session:T.activeSessionSlug})},[w.pathname,T.mode,T.activeAgentKey,T.activeSessionSlug]),(0,N.useEffect)(()=>{if(T.mode===`projects`||T.mode===`project`){_(`projects`),T.mode===`project`&&y({kind:T.activeProjectKind,key:T.activeProjectKey});return}(T.mode===`agent`||T.mode===`missingAgent`)&&_(`agents`)},[T]);let D=(0,N.useMemo)(()=>zo(s,r),[s,r]),{draftSearchQuery:de,activeSearchQuery:fe,searchMode:pe,searchFilters:me,searchResults:O,searchLoading:he,usesServerSearch:ge,selectedSearchIndex:_e,searchInputRef:ve,searchResultRefs:k,setDraftSearchQuery:ye,setSearchFilters:be,setSelectedSearchIndex:Se,openSearch:A,submitSearch:Ce,closeSearch:we,refresh:Te}=qo(D),j=pe,Ee=j?fe:typeof w.state==`object`&&w.state!==null&&`searchQuery`in w.state&&typeof w.state.searchQuery==`string`?w.state.searchQuery:``,{bookmarkedSessions:De,isSessionBookmarked:Oe,toggleBookmark:ke,toggleSessionBookmark:Ae}=Jo(s),M=T.activeAgentKey,je=T.mode===`project`?T.activeProjectKind:null,Me=T.mode===`project`?T.activeProjectKey:null,Ne=(0,N.useMemo)(()=>je&&Me?{kind:je,key:Me}:null,[je,Me]),Pe=Ne?za(Ne):null,{dashboard:Fe,refresh:Ie}=Yo(t),{projectDashboard:Le,projectDashboardLoading:Re,projectDashboardError:ze,selectedProjectAgent:Be,setSelectedProjectAgent:Ve,refresh:He}=Xo(t,je,Me,Pe),Ue=(0,N.useMemo)(()=>T.mode===`session`?D.byRouteKey.get(Io(T.activeAgentKey,T.activeSessionSlug))??null:null,[D,T]),P=(T.mode===`session`&&E?.id===T.activeSessionSlug?E:null)?.project_identity??Ue?.project_identity??null,We=h===`projects`?Ne??(T.mode===`session`?P:v):null,Ge=We?za(We):null,Ke=(0,N.useMemo)(()=>M?D.byAgent.get(M)??[]:[],[M,D]),qe=(0,N.useMemo)(()=>Ge?Be?D.byProjectAgentKey.get(Lo(Ge,Be))??[]:D.byProjectIdentityKey.get(Ge)??[]:[],[Be,Ge,D]),F=h===`projects`?qe:Ke,Je=(0,N.useMemo)(()=>Bo(F),[F]),Ye=(0,N.useMemo)(()=>F.length===0?new Set:new Set(F.filter(e=>Oe(Fo(e),e.id)).map(e=>e.id)),[Oe,F]),Xe=(0,N.useCallback)(t=>{S(t.id),e(`/${t.slug}`)},[e]),Ze=(0,N.useCallback)(e=>{Ae(e,Fo(e))},[Ae]),Qe=(0,N.useCallback)(t=>{S(t);let n=Je.byId.get(t);n&&e(`/${n.slug}`)},[e,Je]),$e=us(ee),et=ee?.active===!0,{liveNotice:tt}=is({appConfig:t,viewState:T,applySessionsLiveEvent:l,refreshAgents:o,refreshSessions:c,refreshProjects:d,refreshDashboard:Ie,refreshProjectDashboard:He,refreshSessionDetail:ue,refreshSearch:Te,setScanStatus:b});(0,N.useEffect)(()=>{try{ie(window.localStorage.getItem(Ms)===`1`)}catch{ie(!0)}},[]),(0,N.useEffect)(()=>{if(!j){if(T.mode===`session`){S(T.activeSessionSlug);return}if(T.mode===`agent`){S(null);return}S(null)}},[j,T.mode,T.activeSessionSlug,F]);let nt=D.landingSessions,rt=(0,N.useMemo)(()=>Pe?D.byLandingProjectIdentityKey.get(Pe)??[]:[],[Pe,D]),it=(0,N.useMemo)(()=>r.filter(e=>e.count>0).map(e=>({key:e.name.toLowerCase(),name:e.displayName,icon:e.icon,count:e.count})),[r]),L=(0,N.useMemo)(()=>r.find(e=>e.name.toLowerCase()===M)??null,[M,r]),at=(0,N.useMemo)(()=>u.find(e=>Pe===za(Ia(e)))??null,[Pe,u]),ot=(0,N.useMemo)(()=>u.find(e=>Ge===za(Ia(e)))??null,[u,Ge]),st=D.projectOptions,ct=(0,N.useMemo)(()=>{if(!ge)return st;let e=new Map,t=he?[]:O;for(let n of t){let t=n.session.project_identity;if(!t?.key)continue;let r=e.get(t.key);r?r.count+=1:e.set(t.key,{key:t.key,label:t.displayName||n.session.directory,count:1,showCount:!1})}if(me.projectKey&&!e.has(me.projectKey)){let t=st.find(e=>e.key===me.projectKey);t&&e.set(t.key,{...t,count:0,showCount:!1})}return[...e.values()].toSorted((e,t)=>t.count-e.count).slice(0,8)},[st,me.projectKey,he,O,ge]),z=`CodeSesh`,B=`Select an agent to browse sessions`;if(T.mode===`root`&&(z=j?`Search`:`Dashboard`,B=j?ls(fe,he,O.length):Fe?`${Fe.totals.sessions.toLocaleString(`en-US`)} total sessions across ${Fe.perAgent.length} agents`:`Aggregated view across all agents`),T.mode===`projects`&&(z=`Projects`,B=`${u.length.toLocaleString(`en-US`)} projects across ${s.length.toLocaleString(`en-US`)} sessions`),T.mode===`project`&&(z=at?.displayName??`Project`,B=at?`${at.sessionCount.toLocaleString(`en-US`)} sessions · ${at.agentStats.length} agents`:T.activeProjectKey),T.mode===`agent`&&M&&(z=L?.displayName??M,B=`${F.length} sessions`),T.mode===`session`){if(le)z=`Session Not Found`,B=`Requested /${M}/${T.activeSessionSlug}`;else if(E){z=E.title||`Conversation`;let e=E.time_updated??E.time_created;B=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`span`,{children:[`ID: #`,E.id.slice(0,8)]}),(0,R.jsx)(`span`,{children:`·`}),(0,R.jsxs)(`span`,{children:[`Updated `,Br(e)]}),(0,R.jsx)(Ri,{tags:E.smart_tags,limit:9,className:`inline-flex`})]})}}T.mode===`missingAgent`&&(z=`Agent Not Found`,B=`Requested /${T.attemptedKey}`),T.mode===`missingSession`&&(z=`Session Not Found`,B=`Session not found in /${M}`),j&&(z=`Search`,B=ls(fe,he,O.length));let lt=(0,N.useMemo)(()=>{if(j)return[{label:`Search`}];let e={label:`Dashboard`,to:h===`agents`&&T.mode===`root`||h===`projects`&&T.mode===`projects`?void 0:h===`projects`?`/projects`:`/`};if(T.mode===`root`)return[{label:`Dashboard`}];let t={label:`Projects`,to:T.mode===`project`?`/projects`:void 0};if(T.mode===`projects`)return[e,{label:`Projects`}];if(T.mode===`project`)return[e,t,{label:at?.displayName??T.activeProjectKey}];if(T.mode===`session`&&h===`projects`&&We)return[e,{label:`Projects`,to:`/projects`},{label:ot?.displayName??We.key,to:Va(We)},{label:E?.title||T.activeSessionSlug||`Conversation`}];if(T.mode===`missingAgent`)return[e,{label:T.attemptedKey}];let n=L?.displayName??M??`Unknown Agent`,r={label:n,to:T.mode===`session`?`/${M}`:void 0};return T.mode===`agent`?[e,{label:n}]:T.mode===`missingSession`?[e,r,{label:T.attemptedSessionSlug}]:T.mode===`session`?[e,r,{label:E?.title||T.activeSessionSlug||`Conversation`}]:[e,{label:`Invalid Route`}]},[L,M,at,h,j,ot,We,E?.title,T]),ut;ut=f?(0,R.jsx)(_a,{}):j?(0,R.jsx)(gt,{id:`SearchResultsPanel`,detail:{results:O.length,loading:he},children:(0,R.jsx)(ks,{query:fe,loading:he,results:O,agentNameMap:a,agents:r,projects:ct,filters:me,onChangeFilters:be,onOpenResult:we,selectedIndex:_e,registerResultRef:(e,t)=>{t?k.current.set(e,t):k.current.delete(e)}})}):m?(0,R.jsx)(`div`,{className:`mx-auto max-w-4xl rounded-sm border border-[var(--console-error-border)] bg-[var(--console-error-bg)] p-6 text-sm text-[var(--console-error)]`,children:m}):T.mode===`root`?Fe?(0,R.jsx)(gt,{id:`Dashboard`,detail:{sessions:Fe.totals.sessions,projects:u.length},children:(0,R.jsx)(po,{data:Fe,projects:u,bookmarkedSessions:De,isBookmarked:Oe,onToggleBookmark:(e,t)=>{if(`agentName`in e){Ae(e,t??e.agentName.toLowerCase());return}ke(e)}})}):(0,R.jsx)(Ta,{type:`global`,sessions:nt,agentItems:it,isBookmarked:Oe,onToggleBookmark:e=>Ae(e,e.agentKey)}):T.mode===`projects`?(0,R.jsx)(yo,{projects:u}):T.mode===`project`?(0,R.jsx)(Co,{project:at,projectKey:T.activeProjectKey,dashboard:Le,loading:Re,error:ze,sessions:rt,activeAgent:Be,onChangeAgent:Ve,isBookmarked:Oe,onToggleSessionBookmark:Ae}):T.mode===`agent`&&M?(0,R.jsx)(Ta,{type:`agent`,sessions:D.byLandingAgent.get(M)??[],agentItems:it,activeAgentKey:M,isBookmarked:Oe,onToggleBookmark:e=>Ae(e,e.agentKey)}):T.mode===`session`?ce?(0,R.jsx)(_a,{}):le||!E?(0,R.jsx)(Ta,{type:`missing-session`,sessions:D.byLandingAgent.get(T.activeAgentKey)??[],agentItems:it,activeAgentKey:T.activeAgentKey,attemptedSessionSlug:T.activeSessionSlug,isBookmarked:Oe,onToggleBookmark:e=>Ae(e,e.agentKey)}):(0,R.jsx)(gt,{id:`SessionDetail`,detail:{messages:E.messages.length,session:E.id},children:(0,R.jsx)(pa,{session:E,highlightQuery:Ee})}):T.mode===`missingAgent`?(0,R.jsx)(Ta,{type:`missing-agent`,sessions:nt,agentItems:it,attemptedAgentKey:T.attemptedKey,isBookmarked:Oe,onToggleBookmark:e=>Ae(e,e.agentKey)}):(0,R.jsx)(`div`,{className:`text-sm text-[var(--console-muted)]`,children:`Invalid route.`});function dt(){ie(!0);try{window.localStorage.setItem(Ms,`1`)}catch{}}function ft(t){if(!(t===`projects`&&et)){if(_(t),S(null),t===`projects`){let t=P??(T.mode===`session`?null:v);e(t?Va(t):`/projects`);return}e(`/`)}}return os({viewState:T,browseBy:h,navigate:e,activeAgentKey:M,sidebarSessions:F,sidebarSessionLookup:Je,selectedSidebarSessionId:x,setSelectedSidebarSessionId:S,selectedProjectNavigationIdentity:We,shortcutHelpOpen:te,setShortcutHelpOpen:ne,dismissShortcutHint:dt,isSearchMode:j,activeSearchQuery:fe,searchResults:O,selectedSearchIndex:_e,setSelectedSearchIndex:Se,setDraftSearchQuery:ye,openSearch:A,closeSearch:we}),(0,R.jsxs)(`div`,{className:`console-ui flex h-screen flex-col overflow-hidden bg-[var(--console-bg)] text-[var(--console-text)]`,children:[(0,R.jsx)(`header`,{className:`shrink-0 border-b border-[var(--console-border)] bg-white/85 backdrop-blur-sm`,children:(0,R.jsxs)(`div`,{className:`grid min-h-14 grid-cols-[auto_1fr] items-center gap-3 px-4 py-2 sm:grid-cols-[auto_1fr_auto] sm:py-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,"aria-expanded":!ae,"aria-label":ae?`Expand sidebar`:`Collapse sidebar`,title:ae?`Expand sidebar`:`Collapse sidebar`,onClick:()=>se(e=>!e),className:`hidden rounded-sm border border-[var(--console-border)] bg-white p-1.5 text-[var(--console-muted)] transition-colors hover:bg-[var(--console-surface-muted)] hover:text-[var(--console-text)] lg:inline-flex`,children:ae?(0,R.jsx)(xe,{className:`size-4`}):(0,R.jsx)(oe,{className:`size-4`})}),(0,R.jsxs)(C,{to:`/`,className:`flex items-center gap-2 text-[var(--console-text)]`,children:[(0,R.jsx)(`img`,{src:`/logo.svg?v=3`,alt:`CodeSesh`,className:`h-6 w-6 rounded-sm`}),(0,R.jsx)(`span`,{className:`console-mono text-sm font-semibold uppercase tracking-[0.05em]`,children:`CodeSesh`})]})]}),(0,R.jsxs)(`form`,{className:`order-3 col-span-2 flex w-full items-center justify-center gap-2 sm:order-none sm:col-span-1 sm:mx-auto sm:max-w-[560px]`,onSubmit:e=>{e.preventDefault(),Ce()},children:[(0,R.jsx)(`label`,{className:`flex min-w-0 flex-1 items-center rounded-sm border border-[var(--console-border)] bg-white px-2 py-1`,children:(0,R.jsx)(`input`,{ref:ve,value:de,onChange:e=>ye(e.target.value),placeholder:`Search sessions /`,className:`console-mono w-full min-w-0 bg-transparent text-xs text-[var(--console-text)] outline-none placeholder:text-[var(--console-muted)]`})}),(0,R.jsx)(`button`,{type:`submit`,className:`console-mono rounded-sm border border-[var(--console-border-strong)] bg-[var(--console-surface-muted)] px-3 py-1 text-xs text-[var(--console-text)] transition-colors hover:bg-white`,children:`Search`})]}),(0,R.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>{ne(!0),dt()},className:`console-mono rounded-sm border border-[var(--console-border)] bg-white px-2 py-1 text-xs text-[var(--console-text)] transition-colors hover:bg-[var(--console-surface-muted)]`,title:`Show keyboard shortcuts`,children:[`?`,(0,R.jsx)(`span`,{className:`hidden sm:inline`,children:` Shortcuts`})]}),cs(t)?(0,R.jsx)(`span`,{className:`console-mono hidden rounded-sm border border-[var(--console-border)] bg-white px-2 py-1 text-xs text-[var(--console-text)] md:inline-flex`,title:`Time window applied to agent counts, dashboard, and session list`,children:cs(t)}):null,(0,R.jsxs)(`span`,{className:`console-mono hidden rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-xs text-[var(--console-muted)] sm:inline-flex`,children:[`v`,`0.12.0`]})]})]})}),(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,R.jsx)(Es,{sidebarCollapsed:ae,browseBy:h,onChangeBrowseBy:ft,isScanActive:et,viewState:T,agents:r,activeAgentKey:M,scanStatus:ee,projects:u,selectedProjectNavigationId:Ge,onSelectProject:y,loading:f,bookmarkedSessions:De,onToggleBookmark:ke,sidebarSessions:F,selectedSidebarSessionId:x,bookmarkedSidebarSessionIds:Ye,onSelectFlatSidebarSession:Xe,onToggleSidebarSessionBookmark:Ze,onSelectTreeSidebarSession:Qe}),(0,R.jsxs)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,R.jsx)(`section`,{className:`shrink-0 border-b border-[var(--console-border)] bg-white/70 px-4 py-4 backdrop-blur-sm md:px-8`,children:(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`nav`,{"aria-label":`Breadcrumb`,className:`console-mono mb-2 flex flex-wrap items-center gap-1 text-[11px] text-[var(--console-muted)]`,children:lt.map((e,t)=>(0,R.jsxs)(`span`,{className:`flex items-center gap-1`,children:[e.to?(0,R.jsx)(C,{to:e.to,className:`transition-colors hover:text-[var(--console-text)]`,children:e.label}):(0,R.jsx)(`span`,{className:`text-[var(--console-text)]`,children:e.label}),t<lt.length-1?(0,R.jsx)(`span`,{children:`/`}):null]},`${e.label}-${t}`))}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-1.5 py-0.5 text-[10px] font-bold uppercase text-[var(--console-muted)]`,children:T.mode===`session`?`Session`:T.mode===`root`?`Dashboard`:T.mode===`projects`?`Projects`:T.mode===`project`?`Project`:`Landing`}),(0,R.jsx)(`h1`,{className:`console-mono text-xl font-semibold tracking-tight text-[var(--console-text)]`,children:z})]}),(0,R.jsx)(`div`,{className:`console-mono mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-[var(--console-muted)]`,children:B}),(0,R.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[re?null:(0,R.jsxs)(`div`,{className:`console-mono inline-flex items-center gap-2 rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] text-[var(--console-text)]`,children:[(0,R.jsx)(`span`,{children:`Keyboard navigation available`}),(0,R.jsx)(`span`,{className:`rounded-sm border border-[var(--console-border)] bg-white px-1`,children:`?`}),(0,R.jsx)(`button`,{type:`button`,onClick:dt,className:`text-[var(--console-muted)] transition-colors hover:text-[var(--console-text)]`,"aria-label":`Dismiss keyboard shortcuts hint`,children:`×`})]}),!j&&T.mode===`session`?(0,R.jsx)(`span`,{className:`console-mono inline-flex rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] text-[var(--console-muted)]`,children:`Esc back`}):null,!j&&T.mode===`session`&&E?(0,R.jsx)(Ao,{agentName:T.activeAgentKey,sessionId:E.id,directory:E.directory}):null]}),tt?(0,R.jsx)(`p`,{className:`console-mono mt-2 inline-flex rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] text-[var(--console-text)]`,children:tt}):null,$e&&T.mode===`root`?(0,R.jsx)(`p`,{className:`console-mono mt-2 inline-flex max-w-4xl rounded-sm border border-[var(--console-warning-border)] bg-[var(--console-warning-bg)] px-2 py-1 text-[11px] leading-relaxed text-[var(--console-warning)]`,children:$e}):null]})}),(0,R.jsx)(`section`,{className:`console-scrollbar bg-grid min-h-0 flex-1 overflow-y-auto px-4 py-6 md:px-8`,children:(0,R.jsx)(wo,{children:(0,R.jsx)(gt,{id:`MainContent`,detail:{mode:T.mode,search:j,sessions:s.length},children:ut})})})]})]}),(0,R.jsx)(js,{open:te,onClose:()=>ne(!1)})]})}Ue.createRoot(document.getElementById(`root`)).render((0,R.jsx)(N.StrictMode,{children:(0,R.jsx)(ne,{children:(0,R.jsx)(gt,{id:`App`,children:(0,R.jsx)(Ns,{})})})}));
|