codesesh 0.15.0 → 0.17.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 +1 -0
- package/dist/{chunk-NBCLV4CX.js → chunk-7APNDHQ6.js} +2148 -1298
- package/dist/chunk-7APNDHQ6.js.map +1 -0
- package/dist/chunk-A4U2SMJJ.js +169 -0
- package/dist/chunk-A4U2SMJJ.js.map +1 -0
- package/dist/dist-KEPJFHOC.js +115 -0
- package/dist/index.js +1052 -906
- package/dist/index.js.map +1 -1
- package/dist/scan-refresh-worker.js +70 -63
- package/dist/scan-refresh-worker.js.map +1 -1
- package/dist/search-index-worker.js +11 -7
- package/dist/search-index-worker.js.map +1 -1
- package/dist/smart-tag-worker.js +2 -1
- package/dist/smart-tag-worker.js.map +1 -1
- package/dist/web/assets/index-B076CRkD.js +109 -0
- package/dist/web/assets/index-CWNbVhet.css +2 -0
- package/dist/web/assets/react-D9s532MZ.js +1821 -0
- package/dist/web/assets/{syntax-C_RLNYQn.js → syntax-mZXQuVcd.js} +1 -1
- package/dist/web/assets/vendor-i9U7_fNF.js +41 -0
- package/dist/web/icon/agent/cursor.svg +1 -12
- package/dist/web/icon/agent/pi.svg +2 -2
- package/dist/web/index.html +56 -5
- package/package.json +5 -10
- package/dist/chunk-NBCLV4CX.js.map +0 -1
- package/dist/dist-5356XOFP.js +0 -219
- package/dist/web/assets/index-B6p64k_Q.js +0 -113
- package/dist/web/assets/index-DiFr4_5-.css +0 -2
- package/dist/web/assets/react-3acXkZNw.js +0 -1821
- package/dist/web/assets/vendor-CShgXaOi.js +0 -40
- package/dist/web/icon/agent/antigravity.svg +0 -1
- package/dist/web/icon/agent/kilocode.svg +0 -1
- /package/dist/{dist-5356XOFP.js.map → dist-KEPJFHOC.js.map} +0 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{l as t,t as n,u as r}from"./markdown-dR4kAewZ.js";import{_ as i,a,c as o,d as s,f as c,g as l,h as u,i as d,l as f,m as p,n as m,o as h,r as g,s as _,t as v,u as y,v as b}from"./react-D9s532MZ.js";import{$ as x,A as S,B as C,C as w,D as T,E,F as ee,G as D,H as O,I as te,J as ne,K as k,L as re,M as ie,N as ae,O as A,P as oe,Q as se,R as ce,S as le,T as j,U as ue,V as de,W as fe,X as pe,Y as me,Z as he,_ as ge,a as _e,at as ve,b as ye,c as be,ct as xe,d as Se,dt as Ce,et as M,f as we,ft as Te,g as Ee,h as De,i as Oe,it as ke,j as Ae,k as je,l as Me,lt as Ne,m as Pe,mt as Fe,n as Ie,nt as Le,o as Re,ot as ze,p as Be,pt as Ve,q as He,r as Ue,rt as We,s as Ge,st as Ke,t as qe,tt as Je,u as Ye,ut as Xe,v as Ze,w as Qe,x as $e,y as et,z as tt}from"./vendor-i9U7_fNF.js";import{C as nt,S as rt,_ as it,a as at,b as ot,c as st,d as ct,f as lt,g as ut,h as dt,i as ft,l as pt,m as mt,n as ht,o as gt,p as _t,r as vt,s as yt,t as bt,u as xt,v as St,w as N,x as Ct,y as wt}from"./syntax-mZXQuVcd.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 P=e(r(),1),Tt=e(i(),1),Et=`access_token`,Dt=`codesesh:remote-access-token`,Ot=null;function kt(){if(typeof window>`u`)return;let e=new URL(window.location.href),t=e.searchParams.get(Et);if(t){Ot=t;try{window.sessionStorage.setItem(Dt,t)}catch{}e.searchParams.delete(Et),window.history.replaceState(window.history.state,``,`${e.pathname}${e.search}${e.hash}`);return}try{Ot=window.sessionStorage.getItem(Dt)}catch{Ot=null}}function At(e={}){if(!Ot)return e;let t=new Headers(e.headers);return t.set(`Authorization`,`Bearer ${Ot}`),{...e,headers:t}}function jt(e){if(!Ot)return e;let t=new URL(e,window.location.origin);return t.searchParams.set(Et,Ot),`${t.pathname}${t.search}`}async function F(e,t){let n=await fetch(e,At(t));if(!n.ok){let r=t?.method??`GET`;throw Error(`${r} ${e} failed: ${n.status} ${n.statusText}`)}return n.json()}async function Mt(e){return F(`/api/config`,e)}async function Nt(){return F(`/api/status`)}function Pt(e,t){t?.from!=null&&e.set(`from`,new Date(t.from).toISOString()),t?.to!=null&&e.set(`to`,new Date(t.to).toISOString())}async function Ft(e,t){let n=new URLSearchParams;return Pt(n,e),F(`/api/agents?${n}`,t)}async function It(e,t){let n=new URLSearchParams;return Pt(n,e),F(`/api/projects?${n}`,t)}async function Lt(e={},t){let n=new URLSearchParams;return e.agent&&n.set(`agent`,e.agent),e.projectKind&&n.set(`projectKind`,e.projectKind),e.projectKey&&n.set(`projectKey`,e.projectKey),Pt(n,e),F(`/api/sessions?${n}`,t)}async function Rt(e,t,n){return F(`/api/sessions/${e}/${t}`,n)}async function zt(e,t={},n){let r=new URLSearchParams;e?.days!==0&&Pt(r,e),e?.days!=null&&r.set(`days`,String(e.days)),t.projectKind&&r.set(`projectKind`,t.projectKind),t.projectKey&&r.set(`projectKey`,t.projectKey),t.agent&&r.set(`agent`,t.agent);let i=r.toString();return F(i?`/api/dashboard?${i}`:`/api/dashboard`,n)}async function Bt(e,t={},n){let r=new URLSearchParams;return r.set(`q`,e),t.agent&&r.set(`agent`,t.agent),t.projectKind&&r.set(`projectKind`,t.projectKind),t.projectKey&&r.set(`projectKey`,t.projectKey),t.tag&&r.set(`tag`,t.tag),t.tool&&r.set(`tool`,t.tool),t.fileKind&&r.set(`fileActivity`,t.fileKind),t.costMin!=null&&r.set(`costMin`,String(t.costMin)),t.costMax!=null&&r.set(`costMax`,String(t.costMax)),Pt(r,t),F(`/api/search?${r}`,n)}async function Vt(e){return F(`/api/bookmarks`,e)}async function Ht(e){return F(`/api/bookmarks`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})}async function Ut(e){return F(`/api/bookmarks/import`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})}async function Wt(e){await F(`/api/bookmarks/${encodeURIComponent(e.agentName)}/${encodeURIComponent(e.sessionId)}`,{method:`DELETE`})}async function Gt(e,t,n){await F(`/api/session-aliases/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({alias:n})})}async function Kt(e,t){await F(`/api/session-aliases/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`DELETE`})}function I(e,t={}){let n=JSON.stringify({event:e,data:t});try{if(!Ot&&typeof navigator<`u`&&navigator.sendBeacon){let e=new Blob([n],{type:`application/json`});if(navigator.sendBeacon(`/api/logs`,e))return}}catch{}fetch(`/api/logs`,At({method:`POST`,headers:{"Content-Type":`application/json`},body:n,keepalive:!0})).catch(()=>{})}var qt=1e3,Jt=3e4;function Yt(e){let t=e*.2;return e+(Math.random()*2-1)*t}function Xt(e,t,n,r){let i=!1,a,o=qt,s=!1,c=!1,l,u=()=>{let d=new EventSource(jt(`/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=qt,c=!1,s&&n?.(),s=!0},d.onerror=()=>{if(d.readyState!==EventSource.CLOSED||(d.close(),i))return;c||(c=!0,r?.());let e=Yt(o);o=Math.min(o*2,Jt),a=setTimeout(u,e)}};return u(),()=>{i=!0,a!==void 0&&clearTimeout(a),l?.close()}}var L=t(),Zt=`codeseshProfiler`,Qt=`codeseshProfilerLog`,$t=16,en=500;function tn(){if(typeof window>`u`)return!1;try{return window.localStorage.getItem(Zt)===`1`}catch{return!1}}function nn(){if(typeof window>`u`)return!1;try{return window.localStorage.getItem(Qt)===`1`}catch{return!1}}function rn(e){let t=window.__CODESHESH_RENDER_PROFILE__??[];t.push(e),t.length>en&&t.splice(0,t.length-en),window.__CODESHESH_RENDER_PROFILE__=t}function an(e){if(!tn()||typeof window>`u`)return;let t=performance.now();rn({...e,startTime:on(e.startTime??t),commitTime:on(e.commitTime??t),route:e.route??window.location.pathname})}function on(e){return Math.round(e*100)/100}function sn({id:e,detail:t,children:n}){return tn()?(0,L.jsx)(P.Profiler,{id:e,onRender:(e,n,r,i,a,o)=>{let s={id:e,source:`react-profiler`,phase:n,actualDuration:on(r),baseDuration:on(i),startTime:on(a),commitTime:on(o),route:window.location.pathname,...t?{detail:t}:{}};rn(s),s.actualDuration>=$t&&nn()&&I(`react.profiler.commit`,{...s})},children:(0,L.jsx)(cn,{id:e,detail:t,children:n})}):n}function cn({id:e,detail:t,children:n}){let r=performance.now(),i=(0,P.useRef)(0);return(0,P.useLayoutEffect)(()=>{i.current+=1;let n=performance.now();rn({id:e,source:`commit-latency`,phase:i.current===1?`mount`:`update`,actualDuration:on(n-r),baseDuration:0,startTime:on(r),commitTime:on(n),route:window.location.pathname,...t?{detail:t}:{}})}),n}function ln(){return new Ve({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:!1,staleTime:0},mutations:{retry:!1}}})}var un=ln();function R(e){return function(t){return(0,L.jsx)(l,{icon:e,...t})}}var dn=R(be),fn=R(k),pn=R(Ye),mn=R(Be),hn=R(De),gn=R(Ee),_n=R(ge),vn=R(Ze),yn=R(et),bn=R($e),xn=R(ye),Sn=R(ie),Cn=R(le),wn=R(j),Tn=R(A),En=R(T),Dn=R(je),On=R(E),kn=R(S),An=R(oe),jn=R(ae),Mn=R(Pe),Nn=R(ee),Pn=R(re),Fn=R(te),In=R(ce),Ln=R(w),Rn=R(tt),zn=R(C),Bn=R(de),Vn=R(O),Hn=R(ue),Un=R(Me),Wn=R(fe),Gn=R(D),Kn=R(He),qn=R(Qe),Jn=R(ne),Yn=R(me),Xn=R(Ae),Zn=R(pe),Qn=R(he),$n=R(se),er=R(Se),tr=R(we),nr=class extends P.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,L.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-error-border)] bg-[var(--console-error-bg)] p-6`,children:[(0,L.jsx)(`h3`,{className:`console-mono mb-2 text-sm font-semibold text-[var(--console-error)]`,children:`Something went wrong`}),(0,L.jsx)(`p`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:this.state.error?.message||`Unknown error`})]}):this.props.children}};function rr(e){return`'${e.replace(/'/g,`'\\''`)}'`}function ir({resumeCommandPrefix:e,sessionId:t,directory:n}){if(!e)return null;let r=`${e} ${rr(t)}`,i=n??``;return i.trim()?`cd ${rr(i)} && ${r}`:r}async function ar(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 or({resumeCommandPrefix:e,sessionId:t,directory:n,className:r=``}){let[i,a]=(0,P.useState)(!1),o=ir({resumeCommandPrefix:e,sessionId:t,directory:n});return(0,P.useEffect)(()=>{if(!i)return;let e=window.setTimeout(()=>a(!1),1500);return()=>window.clearTimeout(e)},[i]),o?(0,L.jsxs)(`button`,{type:`button`,onClick:e=>{e.preventDefault(),e.stopPropagation(),ar(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 motion-hover motion-press inline-flex items-center gap-1.5 rounded-sm border px-2 py-1 text-[11px] ${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,L.jsx)(mn,{className:`size-3`,strokeWidth:1.8}):(0,L.jsx)(wn,{className:`size-3`,strokeWidth:1.8}),(0,L.jsx)(`span`,{children:i?`Copied`:`Copy resume`}),(0,L.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:i?`Resume command copied`:``})]}):null}function sr({target:e,onClose:t,onSave:n,onRemove:r}){let[i,a]=(0,P.useState)(``),[o,l]=(0,P.useState)(null),[d,m]=(0,P.useState)(!1);(0,P.useEffect)(()=>{a(e?.displayTitle??e?.title??``),l(null)},[e]);let h=async()=>{let r=i.trim();if(!r||r===e?.title.trim()){await g();return}m(!0),l(null);try{await n(r),t()}catch(e){l(e instanceof Error?e.message:`Could not rename this session.`)}finally{m(!1)}},g=async()=>{m(!0),l(null);try{await r(),t()}catch(e){l(e instanceof Error?e.message:`Could not restore the title.`)}finally{m(!1)}};return(0,L.jsx)(y,{open:e!==null,onOpenChange:e=>e?void 0:t(),children:(0,L.jsxs)(s,{children:[(0,L.jsx)(u,{className:`motion-backdrop fixed inset-0 z-50 bg-black/35`}),(0,L.jsxs)(c,{className:`motion-modal fixed left-1/2 top-1/2 z-50 w-[calc(100%-2rem)] max-w-md -translate-x-1/2 -translate-y-1/2 rounded-sm border border-[var(--console-border-strong)] bg-[var(--console-surface)] p-5 shadow-2xl outline-none`,children:[(0,L.jsx)(f,{className:`console-mono text-sm font-semibold text-[var(--console-text)]`,children:`Rename session`}),(0,L.jsxs)(`label`,{className:`console-mono mt-4 block text-[11px] uppercase tracking-wide text-[var(--console-muted)]`,children:[`Session title`,(0,L.jsx)(`input`,{autoFocus:!0,autoComplete:`off`,name:`session-title`,maxLength:160,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&h()},"aria-invalid":o?!0:void 0,"aria-describedby":o?`session-alias-error`:void 0,className:`mt-1.5 w-full rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-3 py-2 text-sm normal-case tracking-normal text-[var(--console-text)] outline-none focus:border-[var(--console-accent)] focus:ring-2 focus:ring-[var(--console-accent)]/25`})]}),o?(0,L.jsx)(`p`,{id:`session-alias-error`,"aria-live":`polite`,className:`mt-2 text-xs text-[var(--console-error)]`,children:o}):null,(0,L.jsxs)(`div`,{className:`mt-5 flex items-center justify-between gap-3`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>void g(),disabled:d||!e?.displayTitle,className:`text-xs text-[var(--console-muted)] underline decoration-[var(--console-border-strong)] underline-offset-4 hover:text-[var(--console-text)] disabled:cursor-not-allowed disabled:opacity-40`,children:`Remove custom title`}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(p,{className:`rounded-sm border border-[var(--console-border)] px-3 py-1.5 text-xs text-[var(--console-text)] hover:bg-[var(--console-surface-muted)]`,children:`Cancel`}),(0,L.jsx)(`button`,{type:`button`,disabled:d,onClick:()=>void h(),className:`rounded-sm border border-[var(--console-border-strong)] bg-[var(--console-text)] px-3 py-1.5 text-xs text-white hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-60 dark:text-[var(--console-bg)]`,children:d?`Saving…`:`Save title`})]})]})]})]})})}function cr(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function lr(e){if(!e)return null;let{from:t,to:n,days:r}=e.window;if(r===0||t==null)return`All time`;let i=cr(t),a=cr(n??Date.now());return r?`Last ${r}d · ${i} → ${a}`:`${i} → ${a}`}function ur(e,t,n){return t?e?`Searching for "${e}"`:`Loading recent sessions`:e?`${n} matches for "${e}"`:`${n} recent sessions`}function dr(e){if(!e)return null;if(e.backfill?.active){let t=e.backfill.currentAgent,n=e.backfill.pendingAgents.length;return t?`Indexing full history · ${t}${n>0?` · ${n} queued`:``}`:`Indexing full history`}if(e.backfill?.failedAgents.length)return`History indexing failed · ${e.backfill.failedAgents.join(`, `)}`;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 recent sessions${o}. Full history continues in the background.`: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 fr(e,t){let n=e?.agentStatuses[t];return!n||n.status===`complete`?null:n.status===`indexing`?`Indexing`:n.total&&n.processed!=null?`${n.processed}/${n.total}`:n.status===`scanning`?`Scanning`:`Pending`}var pr=[{value:`7d`,label:`Last 7 days`},{value:`14d`,label:`Last 14 days`},{value:`30d`,label:`Last 30 days`},{value:`90d`,label:`Last 90 days`},{value:`all`,label:`All time`}];function mr({window:e,preset:t,customFrom:n,customTo:r,onSelectPreset:i,onSelectCustom:a}){let[o,l]=(0,P.useState)(!1),[d,m]=(0,P.useState)(``),[h,g]=(0,P.useState)(``),_=lr({window:e}),v=()=>{m(n??(e.from==null?``:cr(e.from))),g(r??cr(e.to??Date.now())),l(!0)};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,L.jsxs)(`label`,{className:`relative block`,children:[(0,L.jsx)(`span`,{className:`sr-only`,children:`Session time range`}),(0,L.jsxs)(`select`,{value:t,title:_??`Session time range`,onChange:e=>{let t=e.target.value;t===`custom`?v():i(t)},className:`console-mono w-24 appearance-none rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] py-1 pr-6 pl-2 text-xs text-[var(--console-text)] outline-none hover:border-[var(--console-border-strong)] focus-visible:ring-2 focus-visible:ring-[var(--console-accent)] focus-visible:ring-offset-2 sm:w-auto sm:max-w-44 sm:pr-7`,children:[pr.map(e=>(0,L.jsx)(`option`,{value:e.value,children:e.label},e.value)),(0,L.jsx)(`option`,{value:`custom`,children:`Custom range`})]}),(0,L.jsx)(`span`,{className:`pointer-events-none absolute top-1/2 right-2 -translate-y-1/2 text-[10px] text-[var(--console-muted)]`,children:`▾`})]}),t===`custom`?(0,L.jsx)(`button`,{type:`button`,onClick:v,"aria-label":`Edit custom time range`,className:`console-mono motion-hover motion-press rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-1.5 py-1 text-xs text-[var(--console-muted)] hover:border-[var(--console-border-strong)] hover:text-[var(--console-text)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--console-accent)] focus-visible:ring-offset-2`,children:`Edit`}):null]}),(0,L.jsx)(y,{open:o,onOpenChange:l,children:(0,L.jsxs)(s,{children:[(0,L.jsx)(u,{className:`motion-backdrop fixed inset-0 z-50 bg-black/35`}),(0,L.jsxs)(c,{className:`motion-modal fixed top-1/2 left-1/2 z-50 w-[calc(100%-2rem)] max-w-sm -translate-x-1/2 -translate-y-1/2 rounded-sm border border-[var(--console-border-strong)] bg-[var(--console-surface)] p-5 shadow-2xl outline-none`,children:[(0,L.jsx)(f,{className:`console-mono text-sm font-semibold text-[var(--console-text)]`,children:`Custom time range`}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-[var(--console-muted)]`,children:`Both dates are included.`}),(0,L.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-3`,children:[(0,L.jsxs)(`label`,{className:`console-mono text-[11px] uppercase tracking-wide text-[var(--console-muted)]`,children:[`From`,(0,L.jsx)(`input`,{type:`date`,value:d,max:h||void 0,onChange:e=>m(e.target.value),className:`mt-1.5 w-full rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-2 py-2 text-xs normal-case tracking-normal text-[var(--console-text)] outline-none focus:border-[var(--console-accent)] focus:ring-2 focus:ring-[var(--console-accent)]/25`})]}),(0,L.jsxs)(`label`,{className:`console-mono text-[11px] uppercase tracking-wide text-[var(--console-muted)]`,children:[`To`,(0,L.jsx)(`input`,{type:`date`,value:h,min:d||void 0,onChange:e=>g(e.target.value),className:`mt-1.5 w-full rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-2 py-2 text-xs normal-case tracking-normal text-[var(--console-text)] outline-none focus:border-[var(--console-accent)] focus:ring-2 focus:ring-[var(--console-accent)]/25`})]})]}),(0,L.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,L.jsx)(p,{className:`rounded-sm border border-[var(--console-border)] px-3 py-1.5 text-xs text-[var(--console-text)] hover:bg-[var(--console-surface-muted)]`,children:`Cancel`}),(0,L.jsx)(`button`,{type:`button`,disabled:!d||!h||d>h,onClick:()=>{a(d,h),l(!1)},className:`rounded-sm border border-[var(--console-border-strong)] bg-[var(--console-text)] px-3 py-1.5 text-xs text-white hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-40 dark:text-[var(--console-bg)]`,children:`Apply range`})]})]})]})})]})}var hr={agent:`agent`,notFound:`not-found`,project:`project`,projects:`projects`,root:`root`,session:`session`},gr=[{index:!0,id:hr.root},{path:`projects`,children:[{index:!0,id:hr.projects},{path:`:projectKind/:projectKey`,id:hr.project}]},{path:`:agentKey`,id:hr.agent,children:[{path:`:sessionId`,id:hr.session}]},{path:`*`,id:hr.notFound}];function _r(e){try{decodeURI(new URL(e.url).pathname)}catch{throw new Response(`Malformed URL`,{status:400,statusText:`Bad Request`})}}function vr({request:e}){return _r(e),null}function yr(e){return{kind:e.identityKind,key:e.identityKey}}var br=new Set([`git_remote`,`git_common_dir`,`manifest_path`,`synthetic`,`path`,`loose`]);function xr(e){return br.has(e)}function Sr(e){return`${e.kind}:${e.key}`}function Cr(e){return`/projects/${encodeURIComponent(e.kind)}/${encodeURIComponent(e.key)}`}var wr={mode:`invalidRoute`,activeAgentKey:null,activeSessionId:null};function Tr(e,t){let n=e.at(-1);if(!n)return wr;if(n.id===hr.root)return{mode:`root`,activeAgentKey:null,activeSessionId:null};if(n.id===hr.projects)return{mode:`projects`,activeAgentKey:null,activeSessionId:null};if(n.id===hr.project){let e=n.params.projectKind,t=n.params.projectKey;return!e||!t||!xr(e)?wr:{mode:`project`,activeAgentKey:null,activeSessionId:null,activeProjectKind:e,activeProjectKey:t}}if(n.id===hr.agent||n.id===hr.session){let e=n.params.agentKey?.toLowerCase();if(!e||!t.has(e))return{mode:`missingAgent`,activeAgentKey:null,activeSessionId:null,attemptedKey:e??``};if(n.id===hr.agent)return{mode:`agent`,activeAgentKey:e,activeSessionId:null};let r=n.params.sessionId;return r?{mode:`session`,activeAgentKey:e,activeSessionId:r}:wr}return wr}function Er(){let[e,t]=(0,P.useState)(null),n=(0,P.useCallback)(e=>{t(t=>t&&e.updatedAt<t.updatedAt?t:e)},[]);return(0,P.useEffect)(()=>{let e=!1;return Nt().then(t=>{e||n(t)}).catch(e=>{console.error(`Failed to load scan status:`,e)}),()=>{e=!0}},[n]),{scanStatus:e,setScanStatus:n}}function Dr(e){return{days:e.days,from:e.from,to:e.to}}var z={bookmarks:[`bookmarks`],config:[`config`],dashboards:[`dashboard`],dashboard:(e,t)=>[`dashboard`,Dr(e),t],search:(e,t)=>[`search`,e,t],searches:[`search`],sessionDetails:[`session-detail`],sessionDetail:(e,t)=>[`session-detail`,e,t],sessionSnapshots:[`session-snapshot`],sessionSnapshot:e=>[`session-snapshot`,Dr(e)],sessionSnapshotAggregateQueries:[`session-snapshot-aggregates`],sessionSnapshotAggregates:e=>[`session-snapshot-aggregates`,Dr(e)]},Or=1;function kr(e){return e.mode===`session`?{agent:e.activeAgentKey,sessionId:e.activeSessionId}:null}function Ar(e){let t=kr(e),n=Xe({queryKey:z.sessionDetail(t?.agent??``,t?.sessionId??``),enabled:t!==null,queryFn:async({signal:e})=>{if(!t)throw Error(`Session route is required`);let n=Or++,r=`${t.agent}/${t.sessionId}`,i=performance.now(),a=!1,o=()=>{a||(a=!0,I(`session.open.cancel`,{request_id:n,request_key:r,reason:`route-change`}))};e.addEventListener(`abort`,o,{once:!0}),I(`session.open.start`,{request_id:n,request_key:r,trigger:`route`,agent:t.agent,session:t.sessionId});try{let a=await Rt(t.agent,t.sessionId,{signal:e});if(e.aborted)throw new DOMException(`Aborted`,`AbortError`);return I(`session.open.done`,{request_id:n,request_key:r,trigger:`route`,agent:t.agent,session:t.sessionId,duration_ms:Math.round(performance.now()-i),messages:a.messages.length}),a}catch(a){throw e.aborted?(o(),a):(I(`session.open.error`,{request_id:n,request_key:r,trigger:`route`,agent:t.agent,session:t.sessionId,duration_ms:Math.round(performance.now()-i),error:a instanceof Error?a.message:String(a)}),a)}finally{e.removeEventListener(`abort`,o)}}}),r=(0,P.useCallback)(async()=>{t&&await n.refetch({cancelRefetch:!0})},[n,t]);return{session:t?n.data??null:null,sessionLoading:t!==null&&n.isPending,sessionError:t!==null&&n.isError?`Session not found`:null,refresh:r}}var jr={bugfix:`bugfix`,refactoring:`refactoring`,"feature-dev":`feature-dev`,testing:`testing`,docs:`docs`,"git-ops":`git-ops`,"build-deploy":`build-deploy`,exploration:`exploration`,planning:`planning`},Mr=Object.fromEntries(Object.keys(jr).map(e=>[e,{text:`var(--tag-${e}-text)`,border:`var(--tag-${e}-border)`,background:`var(--tag-${e}-background)`,bar:`var(--tag-${e}-bar)`}]));function Nr(e){return Mr[e]}function Pr(e){let t=Nr(e);return{color:t.text,borderColor:t.border,backgroundColor:t.background}}function Fr({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,L.jsxs)(`div`,{className:`flex flex-wrap gap-1 ${n}`,children:[r.map(e=>(0,L.jsx)(`span`,{className:`console-mono rounded-sm border px-1.5 py-0.5 text-[10px] font-medium`,style:Pr(e),children:jr[e]},e)),i>0?(0,L.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 Ir({active:e,label:t,onClick:n}){return(0,L.jsx)(`button`,{type:`button`,onClick:n,className:`console-mono rounded-sm border px-2 py-1 text-[10px] motion-hover ${e?`border-[var(--console-border-strong)] bg-[var(--console-accent)] text-white dark:text-[var(--console-bg)]`:`border-[var(--console-border)] bg-[var(--console-surface-muted)] text-[var(--console-muted)] hover:bg-[var(--console-surface)]`}`,children:t})}var Lr=[`bugfix`,`refactoring`,`feature-dev`,`testing`,`docs`,`git-ops`,`build-deploy`,`exploration`,`planning`],Rr=[`apply_patch`,`bash`,`read`,`edit`,`grep`],zr=[{kind:`read`,label:`Read`},{kind:`edit`,label:`Edit`},{kind:`write`,label:`Write`},{kind:`delete`,label:`Delete`}],Br=[{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 Vr({agents:e,projects:t,filters:n,onChangeFilters:r}){let i=Object.values(n).some(Boolean),a=n.project?Sr(n.project):void 0,o=(e,t)=>{r(n=>({...n,[e]:n[e]===t?void 0:t}))};return(0,L.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)]/85 p-3`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`Scope`}),(0,L.jsx)(Ir,{active:!n.project,label:`All`,onClick:()=>r(e=>({...e,project:void 0}))}),t.map(e=>(0,L.jsx)(Ir,{active:a===e.key,label:e.showCount===!1?e.label:`${e.label} · ${e.count}`,onClick:()=>r(t=>({...t,project:a===e.key?void 0:{kind:e.identityKind,key:e.identityKey}}))},e.key))]}),(0,L.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`Agent`}),(0,L.jsx)(Ir,{active:!n.agent,label:`All Agents`,onClick:()=>r(e=>({...e,agent:void 0}))}),e.map(e=>(0,L.jsx)(Ir,{active:n.agent===e.name,label:e.displayName,onClick:()=>o(`agent`,e.name)},e.name))]}),(0,L.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`Tag`}),Lr.map(e=>(0,L.jsx)(Ir,{active:n.tag===e,label:jr[e],onClick:()=>o(`tag`,e)},e))]}),(0,L.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`Signal`}),Rr.map(e=>(0,L.jsx)(Ir,{active:n.tool===e,label:`tool:${e}`,onClick:()=>o(`tool`,e)},e))]}),(0,L.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`File Activity`}),zr.map(e=>(0,L.jsx)(Ir,{active:n.fileKind===e.kind,label:e.label,onClick:()=>o(`fileKind`,e.kind)},e.kind))]}),(0,L.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`Cost Range`}),(0,L.jsx)(Ir,{active:!n.costRange,label:`Any Cost`,onClick:()=>r(e=>({...e,costRange:void 0}))}),Br.map(e=>(0,L.jsx)(Ir,{active:n.costRange===e.id,label:e.label,onClick:()=>o(`costRange`,e.id)},e.id)),i?(0,L.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)] motion-hover hover:bg-[var(--console-surface)]`,children:`Clear`}):null]})]})}function Hr(e){return{agentName:e.agentName.trim().toLowerCase(),sessionId:e.sessionId}}function Ur(e){let t=e.indexOf(`/`);if(t<=0||t===e.length-1)return null;let n=e.slice(0,t).trim().toLowerCase();return n?{agentName:n,sessionId:e.slice(t+1)}:null}function Wr(e){let t=Hr(e);return`${t.agentName}/${t.sessionId}`}function Gr(e){return Ur(e.slug)?.agentName??`unknown`}function Kr(e,t){return(t.time_updated??t.time_created)-(e.time_updated??e.time_created)}function qr(e){for(let t=1;t<e.length;t+=1)if(Kr(e[t-1],e[t])>0)return[...e].sort(Kr);return[...e]}function Jr(e,t){return Wr({agentName:e,sessionId:t})}function Yr(e){return`${e.kind}:${e.key}`}function Xr(e,t){return`${e}\0${t.toLowerCase()}`}function Zr(e,t,n){let r=e.get(t);r?r.push(n):e.set(t,[n])}function Qr(e){let t=new Map,n=new Map,r=new Map,i=new Map;for(let n of e){let e=Jr(Gr(n),n.id);t.has(e)||t.set(e,n)}let a=qr(e);for(let e of a){let t=Gr(e);Zr(n,t,e);let a=e.project_identity;if(!a?.key)continue;let o=Yr(a);Zr(r,o,e),Zr(i,Xr(o,t),e)}return{sourceSessions:e,sessionsByActivity:a,byRouteKey:t,byAgent:n,byProjectIdentityKey:r,byProjectAgentKey:i}}function $r(e,t,n){let r=new Map;for(let t of e)r.set(Jr(Gr(t),t.id),t);for(let e of n)r.delete(Jr(e.agentName,e.sessionId));for(let e of t)r.set(Jr(e.reference.agentName,e.reference.sessionId),e.session);return qr([...r.values()])}var ei={id:`session-1`,slug:`claudecode/session-1`,title:`Fix flaky search index test`,directory:`/Users/dev/project`,project_identity:{kind:`git_remote`,key:`github.com/example/project`,displayName:`example/project`},time_created:17e11,time_updated:17000036e5,stats:{message_count:12,total_input_tokens:4200,total_output_tokens:1800,total_cost:.042,cost_source:`recorded`,total_tokens:6e3,total_cache_read_tokens:3e3,total_cache_create_tokens:500},model_usage:{"claude-5-sonnet":6e3},smart_tags:[`bugfix`],smart_tags_source_updated_at:17000036e5};ei.id,ei.id;function B(e){return Jr(Gr(e),e.id)}function ti(e,t,n){let r=e.get(t);if(r){r.push(n);return}e.set(t,[n])}function ni(e,t){let n=Qr(e),r=new Map,i=new Map,a=new Map,o=new Map,s=[],c=new Set(t.map(e=>e.name.toLowerCase()));for(let e of c)r.set(e,[]),i.set(e,[]);for(let t of e){let e=Gr(t),n={...t,agentKey:e,sessionId:t.id,reference:t.slug};s.push(n),c.has(e)&&i.get(e).push(n);let r=t.project_identity;if(!r?.key)continue;let l=Sr(r);ti(a,l,n);let u=o.get(l);u?u.count+=1:o.set(l,{key:l,identityKind:r.kind,identityKey:r.key,label:r.displayName||t.directory,count:1})}for(let e of c)r.set(e,n.byAgent.get(e)??[]);return{byRouteKey:n.byRouteKey,byAgent:r,byProjectIdentityKey:n.byProjectIdentityKey,byProjectAgentKey:n.byProjectAgentKey,byLandingAgent:i,byLandingProjectIdentityKey:a,landingSessions:s,sessionsByActivity:n.sessionsByActivity,projectOptions:[...o.values()].toSorted((e,t)=>t.count-e.count).slice(0,8)}}function ri(e){let t=new Map,n=new Map;for(let r=0;r<e.length;r+=1){let i=e[r],a=B(i);t.has(a)||(t.set(a,i),n.set(a,r))}return{byReference:t,indexByReference:n}}function ii(e,t){return{agent:e.agent,projectKind:e.project?.kind,projectKey:e.project?.key,tag:e.tag,tool:e.tool,fileKind:e.fileKind,costMin:t}}function ai(e,t){return e.trim().length>0||!!(t.tool||t.fileKind)}function oi(e,t,n){let r=t.agent?e.byAgent.get(t.agent)??[]:null,i=t.project?Sr(t.project):void 0,a=i?e.byProjectIdentityKey.get(i)??[]:null,o=r&&a?r.length<=a.length?r:a:r??a??e.sessionsByActivity,s=[];for(let e of o)if(!(t.agent&&Gr(e)!==t.agent)&&!(i&&(!e.project_identity||Sr(e.project_identity)!==i))&&!(t.tag&&!e.smart_tags?.includes(t.tag))&&!(n!==void 0&&e.stats.total_cost<n)&&(s.push({reference:{agentName:Gr(e),sessionId:e.id},session:e,snippet:`Recent session · ${e.directory}`,matchType:`recent`}),s.length>=50))break;return s}function si({usesServerSearch:e,isLoading:t,results:n,selectedProject:r,recentProjectOptions:i}){if(!e)return i;let a=new Map,o=t?[]:n;for(let e of o){let t=e.session.project_identity;if(!t?.key)continue;let n=Sr(t),r=a.get(n);if(r){r.count+=1;continue}a.set(n,{key:n,identityKind:t.kind,identityKey:t.key,label:t.displayName||e.session.directory,count:1,showCount:!1})}let s=r?Sr(r):void 0,c=s?i.find(e=>e.key===s):void 0;return s&&c&&!a.has(s)&&a.set(s,{...c,count:0,showCount:!1}),[...a.values()].toSorted((e,t)=>t.count-e.count).slice(0,8)}var ci=[];function li(e,t=null){let[n,r]=(0,P.useState)(``),[i,a]=(0,P.useState)(``),[o,s]=(0,P.useState)(!1),[c,l]=(0,P.useState)({}),[u,d]=(0,P.useState)(0),f=(0,P.useRef)(null),p=(0,P.useRef)(new Map),m=(0,P.useMemo)(()=>Br.find(e=>e.id===c.costRange)?.costMin,[c.costRange]),h=(0,P.useMemo)(()=>({...ii(c,m),from:t?.from,to:t?.to}),[c,m,t]),g=ai(i,c),_=(0,P.useMemo)(()=>oi(e,c,m),[e,c,m]),v=Xe({queryKey:z.search(i,h),enabled:o&&g,queryFn:async({signal:e})=>{let t=performance.now();I(`search.start`,{query_length:i.length});try{let n=await Bt(i,h,{signal:e});return I(`search.done`,{duration_ms:Math.round(performance.now()-t),results:n.results.length}),n.results}catch(n){throw e.aborted||(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)})),n}}}),y=(0,P.useMemo)(()=>o?g?v.isPending?{status:`loading`}:v.isError?{status:`failed`,error:v.error instanceof Error?v.error.message:`Search request failed`}:{status:`loaded`,results:v.data}:{status:`loaded`,results:_}:{status:`idle`},[_,o,v,g]),b=(0,P.useMemo)(()=>y.status===`loaded`?y.results:ci,[y]),x=y.status===`loading`,S=(0,P.useMemo)(()=>si({usesServerSearch:g,isLoading:x,results:b,selectedProject:c.project,recentProjectOptions:e.projectOptions}),[c.project,x,b,e.projectOptions,g]);(0,P.useEffect)(()=>{o&&d(e=>b.length===0?0:Math.min(e,b.length-1))},[o,b.length]),(0,P.useEffect)(()=>{if(!o)return;let e=b[u];if(!e)return;let t=`${e.reference.agentName}/${e.reference.sessionId}`;p.current.get(t)?.scrollIntoView({block:`nearest`})},[o,b,u]);let C=(0,P.useCallback)(()=>{s(!0),window.setTimeout(()=>{f.current?.focus(),f.current?.select()},0)},[]),w=(0,P.useCallback)(()=>{a(n.trim()),s(!0),d(0)},[n]),T=(0,P.useCallback)(()=>{s(!1),a(``)},[]),E=(0,P.useCallback)(()=>{v.refetch()},[v]);return{draftSearchQuery:n,activeSearchQuery:i,searchMode:o,searchFilters:c,searchState:y,searchResults:b,searchLoading:x,projectOptions:S,usesServerSearch:g,selectedSearchIndex:u,searchInputRef:f,registerResultRef:(0,P.useCallback)((e,t)=>{t?p.current.set(e,t):p.current.delete(e)},[]),setDraftSearchQuery:r,setSearchFilters:l,setSelectedSearchIndex:d,openSearch:C,submitSearch:w,closeSearch:T,retrySearch:E,refresh:(0,P.useCallback)(async()=>{o&&g&&await v.refetch()},[o,v,g])}}var ui=`codesesh:bookmarks:v1`;function di(e){return typeof e==`object`&&!!e}function fi(e){return di(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 pi(e){if(!di(e))return null;if(typeof e.sessionId==`string`&&typeof e.agentKey==`string`&&typeof e.fullPath==`string`&&e.sessionId&&e.agentKey.trim()&&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`)&&fi(e.stats)){let t=Hr({agentName:e.agentKey,sessionId:e.sessionId});return{reference:t,session:{id:t.sessionId,slug:Wr(t),title:e.title,display_title:typeof e.display_title==`string`?e.display_title:void 0,directory:e.directory,time_created:e.time_created,time_updated:typeof e.time_updated==`number`?e.time_updated:void 0,stats:e.stats},bookmarkedAt:typeof e.bookmarked_at==`number`?e.bookmarked_at:Date.now()}}return null}function mi(e){let t=Hr(e);return JSON.stringify([t.agentName,t.sessionId])}function hi(e,t){let n=Hr({agentName:t,sessionId:e.id});return{reference:n,session:{...e,id:n.sessionId,slug:Wr(n)},bookmarkedAt:Date.now()}}function gi(){if(typeof window>`u`)return[];try{let e=window.localStorage.getItem(ui);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.map(pi).filter(e=>e!==null).toSorted(vi):[]}catch{return[]}}function _i(){typeof window>`u`||window.localStorage.removeItem(ui)}function vi(e,t){let n=e.session.time_updated??e.session.time_created;return(t.session.time_updated??t.session.time_created)-n}function yi(e,t){if(e.length===0||t.length===0)return e;let n=new Map(t.map(e=>{let t=hi(e,Gr(e));return[mi(t.reference),t]})),r=!1,i=e.map(e=>{let t=n.get(mi(e.reference));return!t||t.session.slug===e.session.slug&&t.session.title===e.session.title&&t.session.directory===e.session.directory&&t.session.time_created===e.session.time_created&&t.session.time_updated===e.session.time_updated&&t.session.stats.message_count===e.session.stats.message_count&&t.session.stats.total_input_tokens===e.session.stats.total_input_tokens&&t.session.stats.total_output_tokens===e.session.stats.total_output_tokens&&t.session.stats.total_cost===e.session.stats.total_cost&&t.session.stats.total_tokens===e.session.stats.total_tokens?e:(r=!0,{...t,bookmarkedAt:e.bookmarkedAt})});return r?i.toSorted(vi):e}var bi=[];function xi(e){return e.map(({bookmarkedAt:e,...t})=>t)}function Si(e,t,n){let r=mi(t.reference);return n?e.filter(e=>mi(e.reference)!==r):[...e,t].toSorted((e,t)=>{let n=e.session.time_updated??e.session.time_created;return(t.session.time_updated??t.session.time_created)-n})}function Ci(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function wi(e){let t=Te(),n=Xe({queryKey:z.bookmarks,queryFn:async({signal:e})=>{try{return await Vt({signal:e})}catch(t){throw e.aborted||console.error(`Failed to load bookmarks:`,t),t}}}),r=n.data?.bookmarks??bi,i=(0,P.useCallback)(e=>{t.setQueryData(z.bookmarks,{bookmarks:e})},[t]),{mutate:a}=xe({mutationFn:async({snapshot:e,isBookmarked:t})=>{if(t){await Wt(e.reference);return}let{bookmarkedAt:n,...r}=e;await Ht(r)},onMutate:async({snapshot:e,isBookmarked:n})=>{let r=t.cancelQueries({queryKey:z.bookmarks}),a=t.getQueryData(z.bookmarks);return i(Si(a?.bookmarks??[],e,n)),I(n?`bookmark.delete`:`bookmark.add`,{agent:e.reference.agentName,session:e.reference.sessionId}),await r,a},onError:(e,n,r)=>{r&&t.setQueryData(z.bookmarks,r),console.error(`Failed to toggle bookmark:`,e)}}),{mutate:o}=xe({mutationFn:e=>Ut(e)}),{mutate:s}=xe({mutationFn:e=>Ut(e)});(0,P.useEffect)(()=>{let t=yi(r,e);t===r||Ci(t,r)||(i(t),o(xi(t),{onError:e=>console.error(`Failed to sync bookmark snapshots:`,e)}))},[r,e,i,o]),(0,P.useEffect)(()=>{let e=gi();e.length!==0&&(t.cancelQueries({queryKey:z.bookmarks}),s(xi(e),{onSuccess:e=>{i(e.bookmarks),_i()},onError:e=>console.error(`Failed to migrate legacy bookmarks:`,e)}))},[s,t,i]);let c=(0,P.useMemo)(()=>new Set(r.map(e=>mi(e.reference))),[r]),l=(0,P.useCallback)((e,t)=>c.has(mi({agentName:e,sessionId:t})),[c]),u=(0,P.useCallback)(e=>{let t=mi(e.reference);a({snapshot:e,isBookmarked:c.has(t)})},[c,a]),d=(0,P.useCallback)((e,t)=>{u(hi(e,t))},[u]),f=(0,P.useMemo)(()=>r.toSorted((e,t)=>(t.session.time_updated??t.session.time_created)-(e.session.time_updated??e.session.time_created)),[r]),p=n.refetch;return{bookmarkedSessions:f,isSessionBookmarked:l,toggleBookmark:u,toggleSessionBookmark:d,refresh:(0,P.useCallback)(async()=>{await p()},[p])}}function Ti(e,t){let n=t?.projectKind,r=t?.projectKey,i=t?.identityKey,a=t!==void 0,[o,s]=(0,P.useState)(void 0),c=e!==null&&(!a||r!==void 0);(0,P.useEffect)(()=>{i&&s(void 0)},[i]);let l=Xe({queryKey:z.dashboard(e??{},{projectKind:n,projectKey:r,agent:o}),enabled:c,queryFn:async({signal:t})=>{if(!e)throw Error(`Dashboard window is required`);try{return await zt(e,{projectKind:n,projectKey:r,agent:o},{signal:t})}catch(e){throw t.aborted||console.error(`Failed to load dashboard:`,e),e}}});return{dashboard:c?l.data??null:null,loading:c&&l.isPending,error:c&&l.isError?`Failed to load dashboard`:null,selectedAgent:o,setSelectedAgent:s}}function Ei(e){return e.mode===`projects`||e.mode===`project`?`projects`:e.mode===`agent`||e.mode===`missingAgent`?`agents`:null}function Di(e,t){return e.find(e=>t===Sr(yr(e)))??null}function Oi(e,t,n){return t?n?e.byProjectAgentKey.get(Xr(t,n))??[]:e.byProjectIdentityKey.get(t)??[]:[]}function ki({viewState:e,sessionIndexes:t,session:n,agents:r,projects:i,selectedProjectAgent:a,isSessionBookmarked:o}){let s=Ei(e),[c,l]=(0,P.useState)(s??`agents`),u=s??c;return(0,P.useEffect)(()=>{s&&l(s)},[s]),{browseBy:u,selectBrowseBy:(0,P.useCallback)(e=>{l(e)},[]),...(0,P.useMemo)(()=>{let s=e.activeAgentKey,c=r.find(e=>e.name.toLowerCase()===s)??null,l=e.mode===`project`?{kind:e.activeProjectKind,key:e.activeProjectKey}:null,d=l?Sr(l):null,f=l&&d?{identity:l,identityKey:d,project:Di(i,d)}:null,p=d?t.byLandingProjectIdentityKey.get(d)??[]:[],m=e.mode===`session`?t.byRouteKey.get(Jr(e.activeAgentKey,e.activeSessionId))??null:null,h=(e.mode===`session`&&n?.id===e.activeSessionId?n:null)?.project_identity??m?.project_identity??null,g=u===`projects`?e.mode===`project`?l:e.mode===`session`?h:null:null,_=g?Sr(g):null,v=null;g&&_&&(v=f?.identityKey===_?f:{identity:g,identityKey:_,project:Di(i,_)});let y=s?t.byAgent.get(s)??[]:[],b=Oi(t,_,a),x=u===`projects`?b:y,S=ri(x),C=new Set(x.filter(e=>o(Gr(e),e.id)).map(B));return{activeAgentKey:s,activeAgent:c,activeProject:f,activeProjectSessions:p,openedSessionProjectIdentity:h,selectedProjectNavigation:v,sidebarSessions:x,sidebarSessionLookup:S,bookmarkedSidebarSessionReferences:C}},[r,u,o,i,a,n,t,e])}}function Ai(e){let t=new Map,n=new Map;for(let r of e){let e=r.name.toLowerCase();t.set(e,r),n.set(e,r.displayName)}return{active:e.filter(e=>e.count>0),byKey:t,displayNameByKey:n}}function ji(e,t){return e.byKey.get(t.toLowerCase())}async function Mi(e){await Promise.all([e.invalidateQueries({queryKey:z.sessionSnapshotAggregateQueries}),e.invalidateQueries({queryKey:z.sessionDetails}),e.invalidateQueries({queryKey:z.dashboards}),e.invalidateQueries({queryKey:z.searches})])}var Ni={agents:[],sessions:[],projects:[],dashboard:null};async function Pi(e,t){try{return(await It(e,{signal:t})).projects}catch(e){if(t.aborted)throw e;return console.error(`Failed to load projects:`,e),[]}}async function Fi(e,t){let[n,r,i]=await Promise.all([Ft(e,{signal:t}),Pi(e,t),zt(e,{},{signal:t})]);return{agents:n,projects:r,dashboard:i}}function Ii(e){return Ne({queryKey:z.sessionSnapshotAggregates(e),queryFn:({signal:t})=>Fi(e,t),staleTime:100})}function Li(e){return Ne({queryKey:z.sessionSnapshot(e),staleTime:1/0,queryFn:async({signal:t})=>{let[n,r]=await Promise.all([Fi(e,t),Lt({from:e.from,to:e.to},{signal:t})]);return{window:e,...n,sessions:r.sessions}}})}function Ri(){let e=Te(),[t,n]=(0,P.useState)(null),r=(0,P.useRef)(null),i=Xe({queryKey:z.config,queryFn:async({signal:e})=>{try{return await Mt({signal:e})}catch(t){throw e.aborted||console.error(`Failed to load config:`,t),t}}}),a=Xe({...Li(t??{}),enabled:!1}),o=a.data,s=(0,P.useCallback)(async t=>{r.current=t,n(t);try{return await e.cancelQueries({queryKey:z.sessionSnapshots}),await e.invalidateQueries({queryKey:z.sessionSnapshot(t),exact:!0,refetchType:`none`}),await e.fetchQuery(Li(t))}catch(e){if(Fe(e))return null;throw e}},[e]),c=(0,P.useCallback)(async t=>{let n=r.current;if(!n)return null;let i=z.sessionSnapshot(n),a=e.getQueryData(i);if(!a){let t=await s(n);return await Mi(e),t}e.setQueryData(i,{...a,sessions:$r(a.sessions,t.changedSessionHeads,t.removedSessionRefs)}),await Mi(e);let o=await e.fetchQuery(Ii(n));return e.setQueryData(i,e=>e&&{...e,...o})??null},[e,s]),l=(0,P.useCallback)(async()=>{let t=r.current;if(!t)return null;let n=await s(t);return await Mi(e),n},[e,s]),u=o?.agents??Ni.agents,d=(0,P.useMemo)(()=>Ai(u),[u]),f=(0,P.useMemo)(()=>new Set(d.active.map(e=>e.name.toLowerCase())),[d.active]),p=i.error??a.error;return{config:i.data??null,window:o?.window??null,agents:u,sessions:o?.sessions??Ni.sessions,projects:o?.projects??Ni.projects,dashboard:o?.dashboard??Ni.dashboard,loading:i.isPending||!i.isError&&(t===null||a.isPending),error:p?`Failed to load data. Is the CLI server running?`:null,version:a.dataUpdatedAt,activeAgents:d.active,agentCatalog:d,validAgentKeys:f,agentNameMap:d.displayNameByKey,reload:s,applyLiveEvent:c,resyncLiveState:l}}function zi(e){let t=Te(),n=(0,P.useCallback)(async()=>{await Promise.all([e(),Mi(t)])},[t,e]),{mutateAsync:r}=xe({mutationFn:({agentKey:e,sessionId:t,alias:n})=>Gt(e,t,n),onSuccess:n}),{mutateAsync:i}=xe({mutationFn:({agentKey:e,sessionId:t})=>Kt(e,t),onSuccess:n});return{saveAlias:(0,P.useCallback)(async(e,t)=>{await r({...e,alias:t})},[r]),removeAlias:(0,P.useCallback)(async e=>{await i(e)},[i])}}function Bi({window:e,reload:t}){(0,P.useEffect)(()=>{if(!e)return;let n=!0,r=performance.now();return I(`app.load.start`,{path:globalThis.window.location.pathname}),t(e).then(e=>{!n||!e||I(`app.load.done`,{duration_ms:Math.round(performance.now()-r),agents:e.agents.length,sessions:e.sessions.length,projects:e.projects.length})}).catch(e=>{n&&(console.error(`Failed to load data:`,e),I(`app.load.error`,{duration_ms:Math.round(performance.now()-r),error:e instanceof Error?e.message:String(e)}))}),()=>{n=!1}},[t,e])}function Vi({applyLiveEvent:e,resyncLiveState:t,setScanStatus:n}){let[r,i]=(0,P.useState)(null),[a,o]=(0,P.useState)(null),s=(0,P.useEffectEvent)(async t=>{try{await e(t)&&t.newSessions>0&&i(`发现 ${t.newSessions} 个新会话,列表已自动刷新`)}catch(e){console.error(`Failed to sync live session update:`,e)}}),c=(0,P.useEffectEvent)(async()=>{o(null);try{await t()}catch(e){console.error(`Failed to resync live session state:`,e)}});return(0,P.useEffect)(()=>Xt(e=>{s(e)},n,()=>void c(),()=>{o(`实时更新已断开,重连中…`)}),[n]),(0,P.useEffect)(()=>{if(!r)return;let e=window.setTimeout(()=>i(null),3500);return()=>window.clearTimeout(e)},[r]),{liveNotice:a??r}}function Hi(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase();return t===`input`||t===`textarea`||t===`select`||e.isContentEditable}function Ui(e){let{viewState:t,browseBy:n,navigate:r,activeAgentKey:i,sidebarSessions:a,sidebarSessionLookup:o,selectedSidebarSessionReference:s,setSelectedSidebarSessionReference:c,selectedProjectNavigationIdentity:l,shortcutHelpOpen:u,setShortcutHelpOpen:d,dismissShortcutHint:f,isSearchMode:p,activeSearchQuery:m,searchResults:h,selectedSearchIndex:g,setSelectedSearchIndex:_,setDraftSearchQuery:v,openSearch:y,closeSearch:b}=e,x=(0,P.useEffectEvent)(e=>{let x=e.key;if((e.metaKey||e.ctrlKey)&&x.toLowerCase()===`k`){e.preventDefault(),y(),_(0);return}if(e.defaultPrevented||e.metaKey||e.ctrlKey||e.altKey||e.isComposing)return;let S=e.target,C=Hi(S);if(u){x===`Escape`&&(e.preventDefault(),d(!1));return}if(C){x===`Escape`&&(e.preventDefault(),S instanceof HTMLElement&&S.blur());return}if(x===`?`){e.preventDefault(),d(!0),f();return}if(x===`/`){e.preventDefault(),f(),y();return}if(x===`Escape`){if(e.preventDefault(),p){b(),v(``);return}if(t.mode===`session`&&t.activeAgentKey){if(n===`projects`&&l){r(Cr(l));return}r(`/${t.activeAgentKey}`)}return}if(p){if(h.length===0)return;if(x===`j`){e.preventDefault(),f(),_(e=>Math.min(e+1,h.length-1));return}if(x===`k`){e.preventDefault(),f(),_(e=>Math.max(e-1,0));return}if(x===`g`){e.preventDefault(),f(),_(0);return}if(x===`G`){e.preventDefault(),f(),_(h.length-1);return}if(x===`Enter`){let t=h[g];if(!t)return;e.preventDefault(),f(),b(),r(`/${t.reference.agentName.toLowerCase()}/${t.reference.sessionId}`,{state:{searchQuery:m}})}return}if(n===`agents`&&!i||a.length===0)return;let w=e=>{f();let t=s==null?-1:o.indexByReference.get(s)??-1,n=t>=0?t:e>=0?-1:a.length,r=Math.max(0,Math.min(n+e,a.length-1)),i=a[r];c(i?B(i):null)};if(x===`j`){e.preventDefault(),w(1);return}if(x===`k`){e.preventDefault(),w(-1);return}if(x===`g`){e.preventDefault(),f();let t=a[0];c(t?B(t):null);return}if(x===`G`){e.preventDefault(),f();let t=a.at(-1);c(t?B(t):null);return}if(x===`Enter`){let t=s==null?null:o.byReference.get(s);if(!t)return;e.preventDefault(),f(),r(n===`projects`?`/${t.slug}`:`/${i}/${t.id}`)}});(0,P.useEffect)(()=>(window.addEventListener(`keydown`,x),()=>window.removeEventListener(`keydown`,x)),[])}var Wi={"7d":7,"14d":14,"30d":30,"90d":90};function Gi(e){let t=new Date(e);return new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime()}function Ki(e){let t=new Date(Gi(e));return new Date(t.getFullYear(),t.getMonth(),t.getDate()+1).getTime()-1}function qi(e,t){let n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!n)return null;let r=Number(n[1]),i=Number(n[2])-1,a=Number(n[3]),o=t?new Date(r,i,a+1,0,0,0,-1):new Date(r,i,a),s=new Date(r,i,a);return s.getFullYear()!==r||s.getMonth()!==i||s.getDate()!==a?null:o.getTime()}function Ji(e){return e.days===0||e.from==null?`all`:e.days===7||e.days===14||e.days===30||e.days===90?`${e.days}d`:`custom`}function Yi(e,t){let n=Gi(t),r=Ki(t);if(e===`all`)return{from:0,days:0};let i=Wi[e],a=new Date(n);return{from:new Date(a.getFullYear(),a.getMonth(),a.getDate()-i+1).getTime(),to:r,days:i}}function Xi(e,t,n=Date.now()){let r=e.get(`range`);if(r&&r!==`custom`&&r in Wi||r===`all`)return{preset:r,window:Yi(r,n)};if(r===`custom`){let t=e.get(`from`)??``,n=e.get(`to`)??``,i=qi(t,!1),a=qi(n,!0);if(i!=null&&a!=null&&i<=a)return{preset:r,window:{from:i,to:a},customFrom:t,customTo:n}}let i=Ji(t);return i===`custom`?{preset:i,window:t,customFrom:t.from==null?void 0:Zi(t.from),customTo:Zi(t.to??n)}:{preset:i,window:Yi(i,n)}}function Zi(e){let t=new Date(e);return`${String(t.getFullYear()).padStart(4,`0`)}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function Qi(e,t){let n=new URLSearchParams(e);return n.set(`range`,t),n.delete(`from`),n.delete(`to`),n}function $i(e,t,n){let r=new URLSearchParams(e);return r.set(`range`,`custom`),r.set(`from`,t),r.set(`to`,n),r}var ea=[`range`,`from`,`to`];function ta(e){let t=new URLSearchParams;for(let n of ea){let r=e.get(n);r!=null&&t.set(n,r)}return t.toString()}function na(e=Date.now()){let t=new Date(e);return new Date(t.getFullYear(),t.getMonth(),t.getDate()+1).getTime()}function ra(e,t=Date.now()){return(e>t?e:na(t))-1}function ia(e){return e!==null&&e!==`all`&&e!==`custom`}function aa(e){let t=We(),[n,r]=Ke(),i=n.toString(),a=n.has(`range`),o=(0,P.useRef)(t.pathname),s=(0,P.useRef)(null),[c,l]=(0,P.useState)(na);a&&(s.current=ta(n));let u=o.current!==t.pathname,d=(0,P.useMemo)(()=>{if(a||!u||!s.current)return i;let e=new URLSearchParams(i),t=new URLSearchParams(s.current);for(let[n,r]of t)e.set(n,r);return e.toString()},[a,u,i]),f=(0,P.useMemo)(()=>new URLSearchParams(d),[d]),p=ta(f),m=(0,P.useMemo)(()=>new URLSearchParams(p),[p]);(0,P.useEffect)(()=>{if(d!==i){r(f,{replace:!0});return}o.current=t.pathname},[f,d,t.pathname,i,r]);let h=(0,P.useMemo)(()=>e?Xi(m,e,ra(c)):null,[e,c,m]),g=(0,P.useCallback)(e=>Xi(m,e).window,[m]),_=(0,P.useCallback)(()=>e?g(e):null,[e,g]);(0,P.useEffect)(()=>{if(!ia(h?.preset??null))return;let e=Math.max(0,c-Date.now()),t=window.setTimeout(()=>{l(na())},e);return()=>window.clearTimeout(t)},[c,h?.preset]);let v=(0,P.useCallback)(e=>r(Qi(new URLSearchParams(i),e)),[i,r]),y=(0,P.useCallback)((e,t)=>r($i(new URLSearchParams(i),e,t)),[i,r]);return{timeWindow:h?.window??null,preset:h?.preset??null,customFrom:h?.customFrom,customTo:h?.customTo,resolve:g,resolveCurrent:_,selectPreset:v,selectCustom:y}}var oa=[`light`,`dark`,`system`],sa=`codesesh.ui-preferences`,ca=`codesesh.shortcuts-hint-dismissed`,la={shortcutHintDismissed:!1,sidebarCollapsed:!1,theme:`system`};function ua(e){return typeof e==`string`&&oa.includes(e)}function da(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function fa(e){return typeof e==`object`&&!!e}function pa(e){if(!e)return null;try{let t=JSON.parse(e);if(!fa(t)||t.version!==1||!fa(t.state))return null;let{shortcutHintDismissed:n,sidebarCollapsed:r,theme:i}=t.state;return typeof n!=`boolean`||typeof r!=`boolean`||i!==void 0&&!ua(i)?null:{shortcutHintDismissed:n,sidebarCollapsed:r,theme:ua(i)?i:`system`}}catch{return null}}function ma(e=da()){if(!e)return la;try{let t=e.getItem(sa);return t===null?{...la,shortcutHintDismissed:e.getItem(ca)===`1`}:pa(t)??la}catch{return la}}function ha(e,t=da()){if(!t)return;let n={version:1,state:{shortcutHintDismissed:e.shortcutHintDismissed,sidebarCollapsed:e.sidebarCollapsed,theme:e.theme}};try{t.setItem(sa,JSON.stringify(n)),t.removeItem(ca)}catch{return}}function ga(){let[e,t]=(0,P.useState)(ma),n=(0,P.useRef)(e),r=(0,P.useCallback)(e=>{n.current=e,t(e),ha(e)},[]),i=(0,P.useCallback)(()=>{r({...n.current,shortcutHintDismissed:!0})},[r]),a=(0,P.useCallback)(e=>{r({...n.current,sidebarCollapsed:e})},[r]),o=(0,P.useCallback)(e=>{r({...n.current,theme:e})},[r]);return{...e,dismissShortcutHint:i,setSidebarCollapsed:a,setTheme:o}}var _a=(0,P.createContext)(`light`),va=`(prefers-color-scheme: dark)`;function ya(){return typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(va).matches}function ba(e){let[t,n]=(0,P.useState)(ya);(0,P.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(va),t=e=>n(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let r=e===`system`?t?`dark`:`light`:e;return(0,P.useEffect)(()=>{document.documentElement.classList.toggle(`dark`,r===`dark`)},[r]),r}function xa(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 V(e){return e.toLocaleString(`en-US`)}function Sa(e){return e===0?`$0.00`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function Ca(e){if(e===`recorded`)return`recorded`;if(e===`estimated`)return`estimated`}function wa(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function Ta(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})}function H(e){return e.display_title??e.title}function Ea(e){let t=Oa(e);return{contextLabel:Da(e),...t,breadcrumbs:ka(e)}}function Da(e){if(e.isSearchMode)return`Search`;switch(e.viewState.mode){case`session`:return`Session`;case`root`:return`Dashboard`;case`projects`:return`Projects`;case`project`:return`Project`;default:return`Landing`}}function Oa(e){let{viewState:t}=e;if(e.isSearchMode)return{title:`Search`,subtitle:e.searchSubtitle};if(t.mode===`root`)return{title:`Dashboard`,subtitle:e.dashboard?`${e.dashboard.totals.sessions.toLocaleString(`en-US`)} total sessions across ${e.dashboard.perAgent.length} agents`:`Aggregated view across all agents`};if(t.mode===`projects`)return{title:`Projects`,subtitle:`${e.projects.length.toLocaleString(`en-US`)} projects across ${e.sessionCount.toLocaleString(`en-US`)} sessions`};if(t.mode===`project`)return{title:e.activeProject?.displayName??`Project`,subtitle:e.activeProject?`${e.activeProject.sessionCount.toLocaleString(`en-US`)} sessions · ${e.activeProject.agentStats.length} agents`:t.activeProjectKey};if(t.mode===`agent`)return{title:e.activeAgent?.displayName??t.activeAgentKey,subtitle:`${e.sidebarSessionCount} sessions`};if(t.mode===`session`){if(e.sessionError)return{title:`Session Not Found`,subtitle:`Requested /${t.activeAgentKey}/${t.activeSessionId}`};if(e.session){let t=e.session.time_updated??e.session.time_created;return{title:H(e.session)||`Session`,subtitle:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`span`,{children:[`ID: #`,e.session.id.slice(0,8)]}),(0,L.jsx)(`span`,{children:`·`}),(0,L.jsxs)(`span`,{children:[`Updated `,xa(t)]}),(0,L.jsx)(Fr,{tags:e.session.smart_tags,limit:9,className:`inline-flex`})]})}}}return t.mode===`missingAgent`?{title:`Agent Not Found`,subtitle:`Requested /${t.attemptedKey}`}:t.mode===`missingSession`?{title:`Session Not Found`,subtitle:`Session not found in /${t.activeAgentKey}`}:{title:`CodeSesh`,subtitle:`Select an agent to browse sessions`}}function ka(e){let{viewState:t}=e;if(e.isSearchMode)return[{label:`Search`}];let n={label:`Dashboard`,to:e.browseBy===`agents`&&t.mode===`root`||e.browseBy===`projects`&&t.mode===`projects`?void 0:e.browseBy===`projects`?`/projects`:`/`};if(t.mode===`root`)return[{label:`Dashboard`}];if(t.mode===`projects`)return[n,{label:`Projects`}];if(t.mode===`project`)return[n,{label:`Projects`,to:`/projects`},{label:e.activeProject?.displayName??t.activeProjectKey}];if(t.mode===`session`&&e.browseBy===`projects`&&e.selectedProjectIdentity)return[n,{label:`Projects`,to:`/projects`},{label:e.selectedProject?.displayName??e.selectedProjectIdentity.key,to:Cr(e.selectedProjectIdentity)},{label:e.session?H(e.session):t.activeSessionId||`Session`}];if(t.mode===`missingAgent`)return[n,{label:t.attemptedKey}];let r=e.activeAgent?.displayName??t.activeAgentKey??`Unknown Agent`,i={label:r,to:t.mode===`session`?`/${t.activeAgentKey}`:void 0};return t.mode===`agent`?[n,{label:r}]:t.mode===`missingSession`?[n,i,{label:t.attemptedSessionId}]:t.mode===`session`?[n,i,{label:e.session?H(e.session):t.activeSessionId||`Session`}]:[n,{label:`Invalid Route`}]}function U({icon:e,iconColored:t,alt:n,className:r}){if(t)return(0,L.jsx)(`img`,{src:e,alt:n,className:r});let i=`url("${e}") center / contain no-repeat`;return(0,L.jsx)(`span`,{role:`img`,"aria-label":n,className:`inline-block bg-current ${r??``}`,style:{mask:i,WebkitMask:i}})}function Aa({bookmarked:e,onRename:t,onToggleBookmark:n}){let r=(0,P.useRef)(null);return(0,L.jsxs)(d,{modal:!1,children:[(0,L.jsx)(g,{ref:r,"aria-label":`Session options`,onClick:e=>e.stopPropagation(),className:`motion-hover motion-press inline-flex size-6 shrink-0 items-center justify-center rounded-sm border border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)] hover:text-[var(--console-text)] focus-visible:ring-2 focus-visible:ring-[var(--console-accent)] focus-visible:ring-offset-2 focus-visible:outline-none`,children:(0,L.jsx)(zn,{className:`size-3.5`,"aria-hidden":`true`})}),(0,L.jsx)(h,{children:(0,L.jsx)(a,{side:`bottom`,align:`end`,sideOffset:4,className:`z-30`,children:(0,L.jsxs)(_,{finalFocus:r,className:`motion-menu w-36 rounded-sm border border-[var(--console-border-strong)] bg-[var(--console-surface)] p-1 shadow-lg focus-visible:outline-none`,children:[(0,L.jsxs)(o,{onClick:t,className:`motion-hover motion-press flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-xs text-[var(--console-text)] hover:bg-[var(--console-surface-muted)] data-[highlighted]:bg-[var(--console-surface-muted)] focus-visible:outline-none`,children:[(0,L.jsx)(Wn,{className:`size-3`,"aria-hidden":`true`}),`Rename`]}),(0,L.jsxs)(o,{onClick:n,className:`motion-hover motion-press flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-xs text-[var(--console-text)] hover:bg-[var(--console-surface-muted)] data-[highlighted]:bg-[var(--console-surface-muted)] focus-visible:outline-none`,children:[(0,L.jsx)(Jn,{className:`size-3`,fill:e?`currentColor`:`none`,"aria-hidden":`true`}),e?`Remove bookmark`:`Add bookmark`]})]})})})]})}var ja=`
|
|
2
|
+
[data-type='item'][data-item-type='file'] > [data-item-section='icon'] {
|
|
3
|
+
display: none;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
[data-type='item'][data-item-type='file'] > [data-item-section='spacing'] {
|
|
7
|
+
padding-left: 2px;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
[data-type='item'][data-item-type='file'] > [data-item-section='spacing'] > [data-item-section='spacing-item'] {
|
|
11
|
+
margin-right: 4px;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
[data-type='item'][data-item-type='file'] > [data-item-section='content'] {
|
|
15
|
+
flex: 1 1 auto;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
[data-type='item'][data-item-type='file'] > [data-item-section='decoration'] {
|
|
19
|
+
flex: 0 0 auto;
|
|
20
|
+
padding-inline: 6px 2px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
[data-type='item'][data-item-type='file'] > [data-item-section='decoration'] > span {
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
font-size: 18px;
|
|
26
|
+
line-height: 1;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
[data-type='item'][data-item-type='file'] [data-truncate-group-container='middle'] {
|
|
30
|
+
width: 100%;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
[data-type='item'][data-item-type='file']
|
|
34
|
+
[data-truncate-group-container='middle']
|
|
35
|
+
> div[data-truncate-segment-priority='2'] {
|
|
36
|
+
flex: 0 1 auto;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
[data-type='item'][data-item-type='file']
|
|
40
|
+
[data-truncate-group-container='middle']
|
|
41
|
+
> div[data-truncate-segment-priority='1'] {
|
|
42
|
+
flex: 1 999999 auto;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
[data-type='item'][data-item-type='file']
|
|
46
|
+
[data-truncate-group-container='middle']
|
|
47
|
+
[data-truncate-container='fruncate']
|
|
48
|
+
[data-truncate-grid] {
|
|
49
|
+
grid-template-columns: minmax(0, max-content) 0;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
[data-type='item'][data-item-type='file']
|
|
53
|
+
[data-truncate-group-container='middle']
|
|
54
|
+
[data-truncate-container='fruncate']
|
|
55
|
+
[data-truncate-content] {
|
|
56
|
+
direction: ltr;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
[data-type='item'][data-item-type='file']
|
|
60
|
+
[data-truncate-group-container='middle']
|
|
61
|
+
[data-truncate-container='fruncate']
|
|
62
|
+
[data-truncate-marker] {
|
|
63
|
+
right: 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
[data-type='item'][data-item-type='file'] [data-truncate-marker] {
|
|
67
|
+
display: none;
|
|
68
|
+
}
|
|
69
|
+
`;function Ma(e){return e.replaceAll(`/`,`∕`).trim()||`(untitled)`}function Na(e){return e.replace(/\/+$/,``).split(`/`).at(-1)?.trim()||`(unknown)`}function Pa(e){let t=e.project_identity;if(t)return{key:`${t.kind}:${t.key}`,label:t.displayName||Na(e.directory)};let n=Na(e.directory);return{key:n===`(unknown)`?`__unknown__`:`path:${e.directory||n}`,label:n}}function Fa(e){return e.time_updated??e.time_created}function Ia(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 La(e){let t=new Map,n=new Map,r=new Map,i=new Map,a=new Map,o=new Set,s=[],c=new Map;for(let t of e){let{key:e,label:n}=Pa(t),r=Fa(t),i=c.get(e);i?(i.sessions.push(t),r>i.maxTime&&(i.maxTime=r)):c.set(e,{label:n,sessions:[t],maxTime:r})}let l=[...c.entries()].sort(([,e],[,t])=>e.label===`(unknown)`?1:t.label===`(unknown)`?-1:t.maxTime-e.maxTime),u=0,d=new Set;for(let[,e]of l){let c=Ma(e.label),l=`${c}/`,f=2;for(;d.has(l);)l=`${c} (${f})/`,f+=1;d.add(l);let p=l.slice(0,-1),m=new Map;t.set(l,u),t.set(p,u),u+=1,i.set(l,`${e.sessions.length}`),i.set(p,`${e.sessions.length}`);for(let t of e.sessions){let e=H(t);m.set(e,(m.get(e)??0)+1)}for(let i of e.sessions){let e=H(i),c=(m.get(e)??0)>1?`${Ma(e)} #${i.id.slice(0,8)}`:Ma(e),d=`${l}${c}`,f=2;for(;o.has(d);)d=`${l}${c} (${f})`,f+=1;o.add(d),s.push(d),t.set(d,u),u+=1;let p=B(i);n.set(p,d),r.set(p,l),a.set(d,i)}}return{paths:s,sortOrderByPath:t,pathBySessionReference:n,groupPathBySessionReference:r,groupCountByPath:i,sessionByPath:a}}function Ra(e,t){if(!tn())return t();let n=performance.now(),r=t(),i=performance.now();return an({id:e,source:`custom-timing`,phase:`measure`,actualDuration:Math.round((i-n)*100)/100,baseDuration:0,startTime:n,commitTime:i}),r}var za=(0,P.memo)(function({sessions:e,activeSessionReference:t,selectedSessionReference:n,onSelectSession:r,bookmarkedSessionReferences:i,onToggleBookmark:s,onRenameSession:c}){let[l,u]=(0,P.useState)(null),f=(0,P.useRef)(null),p=(0,P.useRef)(null),y=(0,P.useRef)(null),b=(0,P.useMemo)(()=>Ra(`SessionTreeSidebar:buildTreeModel`,()=>La(e)),[e]),x=(0,P.useRef)(b.sortOrderByPath),S=(0,P.useRef)(b.groupCountByPath),C=(0,P.useRef)(b.sessionByPath),w=(0,P.useRef)(i),T=(0,P.useRef)(r),E=(0,P.useRef)(s),ee=(0,P.useRef)(c),D={"--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":`4px`,"--trees-padding-inline-override":`4px`,"--trees-selected-bg-override":`var(--console-surface-muted)`},{model:O}=v({flattenEmptyDirectories:!1,initialExpansion:`closed`,paths:b.paths,sort:(e,t)=>Ia(x.current,e,t),density:`compact`,unsafeCSS:ja,onSelectionChange(e){let t=C.current.get(e[0]??``);t&&T.current(t)},renderRowDecoration({item:e}){return C.current.get(e.path)?{text:`⋯`,title:`Session options`}:S.current.get(e.path)?{text:S.current.get(e.path),title:`Sessions`}:null}});(0,P.useEffect)(()=>{x.current=b.sortOrderByPath,S.current=b.groupCountByPath,C.current=b.sessionByPath,O.resetPaths(b.paths)},[O,b]),(0,P.useEffect)(()=>{T.current=r},[r]),(0,P.useEffect)(()=>{w.current=i},[i]),(0,P.useEffect)(()=>{E.current=s},[s]),(0,P.useEffect)(()=>{ee.current=c},[c]);function te(e,t,n){f.current=t,p.current=n,u(e),y.current?.dispatchEvent(new KeyboardEvent(`keydown`,{key:`ArrowDown`,bubbles:!0,cancelable:!0}))}function ne(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?C.current.get(r.getAttribute(`data-item-path`)??``):null;!n||!r||!i||(e.preventDefault(),e.stopPropagation(),te(i,n,r))}function k(e){if(e.key!==`ContextMenu`&&!(e.shiftKey&&e.key===`F10`))return;let t=e.nativeEvent.composedPath().find(e=>e instanceof HTMLElement&&e.getAttribute(`data-type`)===`item`),n=t?C.current.get(t.getAttribute(`data-item-path`)??``):null;!t||!n||(e.preventDefault(),e.stopPropagation(),te(n,t.querySelector(`[data-item-section='decoration'] > span`)??t,t))}return(0,P.useEffect)(()=>{let e=b.pathBySessionReference.get(t??``),r=b.pathBySessionReference.get(n??``)??e,i=n??t??``,a=b.groupPathBySessionReference.get(i);if(e&&O.getItem(e)?.select(),r&&t){let e=a?O.getItem(a):null;e&&`expand`in e&&e.expand(),O.focusPath(r);return}a&&O.focusPath(a)},[t,O,b,n]),(0,L.jsxs)(`div`,{className:`session-tree h-[min(560px,calc(100vh-410px))] min-h-56 overflow-hidden`,style:D,onClickCapture:ne,onKeyDownCapture:k,children:[(0,L.jsx)(m,{model:O,style:{height:`100%`},"aria-label":`Sessions`}),(0,L.jsxs)(d,{modal:!1,children:[(0,L.jsx)(g,{ref:y,tabIndex:-1,"aria-hidden":`true`,className:`pointer-events-none absolute size-0 opacity-0`}),(0,L.jsx)(h,{children:(0,L.jsx)(a,{anchor:f,side:`bottom`,align:`end`,sideOffset:4,className:`z-40`,children:(0,L.jsx)(_,{finalFocus:p,className:`motion-menu w-36 rounded-sm border border-[var(--console-border-strong)] bg-[var(--console-surface)] p-1 shadow-lg focus-visible:outline-none`,children:l?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(o,{onClick:()=>ee.current(l),className:`motion-hover motion-press block w-full rounded-sm px-2 py-1.5 text-left text-xs text-[var(--console-text)] hover:bg-[var(--console-surface-muted)] data-[highlighted]:bg-[var(--console-surface-muted)] focus-visible:outline-none`,children:`Rename`}),(0,L.jsx)(o,{onClick:()=>E.current(l),className:`motion-hover motion-press block w-full rounded-sm px-2 py-1.5 text-left text-xs text-[var(--console-text)] hover:bg-[var(--console-surface-muted)] data-[highlighted]:bg-[var(--console-surface-muted)] focus-visible:outline-none`,children:w.current.has(B(l))?`Remove bookmark`:`Add bookmark`})]}):null})})})]})]})});function Ba({value:e,onChange:t,projectsDisabled:n=!1}){return(0,L.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,L.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 motion-hover ${a?`cursor-not-allowed border-transparent text-[var(--console-muted)] opacity-45`:i?`border-[var(--console-border-strong)] bg-[var(--console-surface)] 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,L.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,L.jsx)(`span`,{className:`size-1.5 rounded-full bg-[var(--console-accent)]`}):null}),(0,L.jsx)(`span`,{children:r.label})]},r.value)})})}var Va=4,Ha=8,Ua=`h-[min(560px,calc(100vh-410px))] min-h-56`;function Wa({session:e,agentCatalog:t,active:n,selected:r,onSelectSession:i,onToggleBookmark:a,onRenameSession:o,bookmarkedSessionReferences:s}){let c=ji(t,Gr(e));return(0,L.jsxs)(`div`,{className:`flex items-start gap-1 rounded-sm border px-2 py-1.5 motion-hover ${n||r?`border-[var(--console-border-strong)] bg-[var(--console-surface)] text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>i(e),className:`min-w-0 flex-1 text-left`,children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[c?.icon?(0,L.jsx)(U,{icon:c.icon,iconColored:c.iconColored,alt:c.displayName,className:`size-3.5 shrink-0 object-contain`}):null,(0,L.jsx)(`span`,{className:`console-mono line-clamp-1 text-xs text-[var(--console-text)]`,children:H(e)})]}),(0,L.jsx)(`span`,{className:`console-mono mt-0.5 block truncate text-[10px] text-[var(--console-muted)]`,children:xa(e.time_updated??e.time_created)})]}),(0,L.jsx)(Aa,{bookmarked:s.has(B(e)),onRename:()=>o(e),onToggleBookmark:()=>a(e)})]})}function Ga(e){if(e.sessions.length>80)return(0,L.jsx)(Ka,{...e});let{sessions:t,agentCatalog:n,activeSessionReference:r,selectedSessionReference:i,bookmarkedSessionReferences:a,onSelectSession:o,onToggleBookmark:s,onRenameSession:c}=e;return(0,L.jsx)(`div`,{className:`console-scrollbar ${Ua} overflow-y-auto`,children:(0,L.jsx)(`ul`,{className:`space-y-1`,children:t.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsx)(Wa,{session:e,agentCatalog:n,active:r===B(e),selected:i===B(e),bookmarkedSessionReferences:a,onSelectSession:o,onToggleBookmark:s,onRenameSession:c})},e.slug))})})}function Ka({sessions:e,agentCatalog:t,activeSessionReference:n,selectedSessionReference:r,bookmarkedSessionReferences:i,onSelectSession:a,onToggleBookmark:o,onRenameSession:s}){let c=(0,P.useRef)(null),[l,u]=(0,P.useState)({scrollTop:0,height:0}),d=(0,P.useRef)(l),f=(0,P.useCallback)(()=>{let e=c.current;if(!e)return;let t={scrollTop:e.scrollTop,height:e.clientHeight},n=d.current;Math.abs(n.scrollTop-t.scrollTop)<1&&Math.abs(n.height-t.height)<1||(d.current=t,u(t))},[]);(0,P.useEffect)(()=>{let e=c.current;if(!e)return;let t=0,n=()=>{t||=requestAnimationFrame(()=>{t=0,f()})};e.addEventListener(`scroll`,n,{passive:!0});let r=typeof ResizeObserver<`u`?new ResizeObserver(n):null;return r?.observe(e),f(),()=>{t&&cancelAnimationFrame(t),e.removeEventListener(`scroll`,n),r?.disconnect()}},[f]);let p=Math.max(0,Math.floor(l.scrollTop/51)-Ha),m=Math.min(e.length,Math.ceil((l.scrollTop+l.height)/51)+Ha),h=e.slice(p,m),g=Math.max(0,e.length*51-Va);return(0,L.jsx)(`div`,{ref:c,className:`console-scrollbar ${Ua} overflow-y-auto`,children:(0,L.jsx)(`ul`,{className:`relative`,style:{height:g},children:h.map((e,c)=>(0,L.jsx)(`li`,{className:`absolute inset-x-0 top-0`,style:{transform:`translateY(${(p+c)*51}px)`},children:(0,L.jsx)(Wa,{session:e,agentCatalog:t,active:n===B(e),selected:r===B(e),bookmarkedSessionReferences:i,onSelectSession:a,onToggleBookmark:o,onRenameSession:s})},e.slug))})})}function qa(e){return e?.status!==`scanning`||typeof e.total!=`number`||!Number.isFinite(e.total)||e.total<=0||typeof e.processed!=`number`||!Number.isFinite(e.processed)?null:Math.min(100,Math.max(0,Math.round(e.processed/e.total*100)))}function Ja({agents:e,activeAgentKey:t,scanStatus:n,isScanActive:r}){return(0,L.jsx)(L.Fragment,{children:e.map(e=>{let i=e.name.toLowerCase(),a=i===t,o=n?.agentStatuses[e.name],s=fr(n,e.name),c=qa(o),l=r&&s!==null,u=`ml-4 flex items-center gap-2 rounded-sm border px-3 py-1.5 text-left motion-hover ${l?`cursor-not-allowed border-transparent text-[var(--console-muted)] opacity-50`:a?`border-[var(--console-border-strong)] bg-[var(--console-surface)] text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,d=(0,L.jsxs)(L.Fragment,{children:[e.icon&&(0,L.jsx)(U,{icon:e.icon,iconColored:e.iconColored,alt:e.displayName,className:`size-3.5 object-contain`}),(0,L.jsx)(`span`,{className:`console-mono line-clamp-1 flex-1 text-xs`,children:e.displayName}),(0,L.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:s??e.count})]});return(0,L.jsxs)(`li`,{children:[l?(0,L.jsx)(`span`,{className:u,title:`Available after this agent scan completes`,children:d}):(0,L.jsx)(M,{to:`/${i}`,className:u,children:d}),s?(0,L.jsx)(`span`,{className:`ml-4 mt-1 block h-1 overflow-hidden rounded-sm bg-[var(--console-surface-muted)]`,role:`progressbar`,"aria-label":`${e.displayName} ${o?.status===`indexing`?`indexing`:`scan`} progress`,"aria-valuemin":c==null?void 0:0,"aria-valuemax":c==null?void 0:100,"aria-valuenow":c??void 0,"aria-valuetext":c==null?s:void 0,children:(0,L.jsx)(`span`,{className:`block h-full bg-[var(--console-accent)] ${c==null?`scan-progress-indeterminate`:``}`,style:c==null?void 0:{width:`${c}%`}})}):null]},e.name)})})}function Ya({projects:e,selectedProjectNavigationId:t,onSelectProject:n}){return(0,L.jsx)(L.Fragment,{children:e.map(e=>{let r=yr(e),i=t===Sr(r);return(0,L.jsx)(`li`,{children:(0,L.jsxs)(M,{to:Cr(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 motion-hover ${i?`border-[var(--console-border-strong)] bg-[var(--console-surface)] text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,children:[(0,L.jsx)(`span`,{className:`console-mono min-w-0 flex-1 truncate text-xs`,children:e.displayName}),(0,L.jsx)(`span`,{className:`console-mono shrink-0 text-[11px] text-[var(--console-muted)]`,children:e.sessionCount})]})},`${e.identityKind}:${e.identityKey}`)})})}function Xa({model:{sidebarCollapsed:e,browseBy:t,isScanActive:n,viewState:r,agents:i,agentCatalog:a,activeAgentKey:o,scanStatus:s,projects:c,selectedProjectNavigationId:l,loading:u,bookmarkedSessions:d,sidebarSessions:f,selectedSidebarSessionReference:p,bookmarkedSidebarSessionReferences:m},actions:{onChangeBrowseBy:h,onSelectProject:g,onToggleBookmark:_,onSelectFlatSidebarSession:v,onToggleSidebarSessionBookmark:y,onRenameSession:b,onRenameBookmarkedSession:x,onSelectTreeSidebarSession:S}}){let C=r.mode===`session`?Jr(r.activeAgentKey,r.activeSessionId):null;return(0,L.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,L.jsxs)(`div`,{className:`console-scrollbar flex-1 space-y-8 overflow-y-auto px-4 py-6`,children:[(0,L.jsxs)(`section`,{children:[(0,L.jsx)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:`BROWSE BY`}),(0,L.jsx)(Ba,{value:t,onChange:h,projectsDisabled:n})]}),(0,L.jsxs)(`section`,{children:[(0,L.jsx)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:`NAVIGATION`}),(0,L.jsxs)(`ul`,{className:`space-y-1 ${t===`projects`?`console-scrollbar max-h-[min(280px,calc(100vh-440px))] overflow-y-auto pr-1`:``}`,children:[(0,L.jsx)(`li`,{children:(0,L.jsxs)(M,{to:t===`projects`?`/projects`:`/`,className:`flex items-center gap-2 rounded-sm border px-3 py-1.5 text-left motion-hover ${t===`agents`&&r.mode===`root`||t===`projects`&&r.mode===`projects`?`border-[var(--console-border-strong)] bg-[var(--console-surface)] text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,children:[(0,L.jsx)(`img`,{src:`/logo.svg?v=3`,alt:`Dashboard`,className:`size-3.5 rounded-[2px]`}),(0,L.jsx)(`span`,{className:`console-mono line-clamp-1 flex-1 text-xs`,children:`Dashboard`})]})}),t===`agents`?(0,L.jsx)(Ja,{agents:i,activeAgentKey:o,scanStatus:s,isScanActive:n}):(0,L.jsx)(Ya,{projects:c,selectedProjectNavigationId:l,onSelectProject:g}),t===`agents`&&i.length===0&&!u?(0,L.jsx)(`li`,{children:(0,L.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&&!u?(0,L.jsx)(`li`,{children:(0,L.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,L.jsxs)(`section`,{children:[(0,L.jsx)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:`BOOKMARKS`}),d.length===0?(0,L.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:`No bookmarks yet`}):(0,L.jsx)(`ul`,{className:`space-y-1`,children:d.map(e=>{let{reference:t,session:n}=e,i=r.mode===`session`&&r.activeAgentKey===t.agentName&&r.activeSessionId===t.sessionId,o=ji(a,t.agentName);return(0,L.jsx)(`li`,{children:(0,L.jsxs)(`div`,{className:`flex items-start gap-2 rounded-sm border px-2 py-1.5 motion-hover ${i?`border-[var(--console-border-strong)] bg-[var(--console-surface)] text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,children:[(0,L.jsxs)(M,{to:`/${n.slug}`,className:`flex min-w-0 flex-1 items-start gap-2`,children:[o?.icon?(0,L.jsx)(U,{icon:o.icon,iconColored:o.iconColored,alt:o.displayName,className:`mt-0.5 size-3.5 shrink-0 object-contain`}):null,(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`span`,{className:`console-mono line-clamp-1 block text-xs`,children:H(n)}),(0,L.jsx)(`span`,{className:`console-mono mt-0.5 line-clamp-1 block text-[10px] text-[var(--console-muted)]`,children:o?.displayName??t.agentName})]})]}),(0,L.jsx)(Aa,{bookmarked:!0,onRename:()=>x(e),onToggleBookmark:()=>_(e)})]})},mi(t))})})]}),(0,L.jsxs)(`section`,{children:[(0,L.jsxs)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:[`SESSIONS`,f.length>0?(0,L.jsx)(`span`,{className:`ml-2 text-[10px] font-normal text-[var(--console-muted)]`,children:`Navigate j k · Open Enter`}):null]}),t===`agents`&&!o?(0,L.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,L.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:`Select a project`}):f.length===0?(0,L.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,L.jsx)(Ga,{sessions:f,agentCatalog:a,activeSessionReference:C,selectedSessionReference:p,bookmarkedSessionReferences:m,onSelectSession:v,onToggleBookmark:y,onRenameSession:b}):(0,L.jsx)(sn,{id:`SessionTreeSidebar`,detail:{sessions:f.length},children:(0,L.jsx)(za,{sessions:f,activeSessionReference:C,selectedSessionReference:p,onSelectSession:S,bookmarkedSessionReferences:m,onToggleBookmark:y,onRenameSession:b})})]})]})})}var Za=[{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 Qa({open:e,onClose:t}){return(0,L.jsx)(y,{open:e,onOpenChange:e=>e?void 0:t(),children:(0,L.jsxs)(s,{children:[(0,L.jsx)(u,{className:`shortcut-overlay fixed inset-0 z-50 bg-black/35`}),(0,L.jsxs)(c,{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-[var(--console-surface)] p-5 shadow-2xl outline-none`,children:[(0,L.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-[0.16em] text-[var(--console-muted)]`,children:`Keyboard Shortcuts`}),(0,L.jsx)(f,{className:`console-mono mt-2 text-xl font-semibold text-[var(--console-text)]`,children:`Navigate without leaving the keyboard`})]}),(0,L.jsx)(p,{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)] motion-hover hover:bg-[var(--console-surface)]`,children:`Esc`})]}),(0,L.jsx)(`div`,{className:`mt-5 grid gap-4 md:grid-cols-2`,children:Za.map(e=>(0,L.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] p-4`,children:[(0,L.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:e.title}),(0,L.jsx)(`div`,{className:`mt-3 space-y-3`,children:e.items.map(e=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`console-mono text-xs text-[var(--console-text)]`,children:e.keys}),(0,L.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-[var(--console-muted)]`,children:e.description})]},e.keys))})]},e.title))})]})]})})}var $a={light:`dark`,dark:`system`,system:`light`},eo={light:Yn,dark:Rn,system:Ln},to={light:`Light`,dark:`Dark`,system:`System`};function no({theme:e,onChange:t}){let n=eo[e],r=$a[e];return(0,L.jsx)(`button`,{type:`button`,onClick:()=>t(r),"aria-label":`Theme: ${to[e]}. Switch to ${to[r]}.`,title:`Theme: ${to[e]} (click for ${to[r]})`,className:`console-mono motion-hover motion-press rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] p-1.5 text-[var(--console-muted)] hover:bg-[var(--console-surface-muted)] hover:text-[var(--console-text)] focus-visible:ring-2 focus-visible:ring-[var(--console-accent)] focus-visible:ring-offset-2 focus-visible:outline-none`,children:(0,L.jsx)(n,{"aria-hidden":`true`,className:`size-4`})})}function ro({active:e,onToggle:t,className:n=``}){return(0,L.jsx)(`button`,{type:`button`,onClick:e=>{e.preventDefault(),e.stopPropagation(),t()},"aria-label":e?`Remove bookmark`:`Add bookmark`,title:e?`Remove bookmark`:`Add bookmark`,className:`motion-hover motion-press inline-flex size-6 shrink-0 items-center justify-center rounded-sm border ${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,L.jsx)(Jn,{className:`size-3`,strokeWidth:1.8,fill:e?`currentColor`:`none`})})}function io(...e){return Ie(Ge(e))}var ao={light:``,dark:`.dark`},oo={width:320,height:200},so=P.createContext(null);function co(){let e=P.useContext(so);if(!e)throw Error(`useChart must be used within a <ChartContainer />`);return e}function lo({id:e,className:t,children:n,config:r,initialDimension:i=oo,...a}){let o=P.useId(),s=`chart-${e??o.replace(/:/g,``)}`;return(0,L.jsx)(so.Provider,{value:{config:r},children:(0,L.jsxs)(`div`,{"data-slot":`chart`,"data-chart":s,className:io(`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,L.jsx)(uo,{id:s,config:r}),(0,L.jsx)(Re,{initialDimension:i,children:n})]})})}var uo=({id:e,config:t})=>{let n=Object.entries(t).filter(([,e])=>e.theme??e.color);return n.length?(0,L.jsx)(`style`,{dangerouslySetInnerHTML:{__html:Object.entries(ao).map(([t,r])=>`
|
|
70
|
+
${r} [data-chart=${e}] {
|
|
71
|
+
${n.map(([e,n])=>{let r=n.theme?.[t]??n.color;return r?` --color-${e}: ${r};`:null}).join(`
|
|
72
|
+
`)}
|
|
73
|
+
}
|
|
74
|
+
`).join(`
|
|
75
|
+
`)}}):null},fo=_e;function po({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}=co(),m=P.useMemo(()=>{if(i||!t?.length)return null;let[e]=t,n=`${f??e?.dataKey??e?.name??`value`}`,r=mo(p,e,n),a=!f&&typeof o==`string`?p[o]?.label??o:r?.label;return s?(0,L.jsx)(`div`,{className:io(`font-medium`,c),children:s(a,t)}):a?(0,L.jsx)(`div`,{className:io(`font-medium`,c),children:a}):null},[o,s,t,i,c,p,f]);if(!e||!t?.length)return null;let h=t.length===1&&r!==`dot`;return(0,L.jsxs)(`div`,{className:io(`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,L.jsx)(`div`,{className:`grid gap-1.5`,children:t.filter(e=>e.type!==`none`).map((e,t)=>{let n=`${d??e.name??e.dataKey??`value`}`,i=mo(p,e,n),o=u??e.payload?.fill??e.color;return(0,L.jsx)(`div`,{className:io(`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,L.jsxs)(L.Fragment,{children:[i?.icon?(0,L.jsx)(i.icon,{}):!a&&(0,L.jsx)(`div`,{className:io(`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":o,"--color-border":o}}),(0,L.jsxs)(`div`,{className:io(`flex flex-1 justify-between leading-none`,h?`items-end`:`items-center`),children:[(0,L.jsxs)(`div`,{className:`grid gap-1.5`,children:[h?m:null,(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:i?.label??e.name})]}),e.value!=null&&(0,L.jsx)(`span`,{className:`font-mono font-medium text-foreground tabular-nums`,children:typeof e.value==`number`?e.value.toLocaleString():String(e.value)})]})]})},t)})})]})}function mo(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 ho(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:V(e)}function go({label:e,value:t,hint:n}){return(0,L.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] p-4`,children:[(0,L.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-wider text-[var(--console-muted)]`,children:e}),(0,L.jsx)(`p`,{className:`console-mono mt-2 text-xl font-semibold text-[var(--console-text)]`,children:t}),n?(0,L.jsx)(`p`,{className:`mt-1 text-xs text-[var(--console-muted)]`,children:n}):null]})}function _o(e){return e.length>=10?e.slice(5):e}function vo({buckets:e}){let[t,n]=(0,P.useState)(null),r=(0,P.useMemo)(()=>Math.max(1,...e.map(e=>e.sessions)),[e]),i=(0,P.useMemo)(()=>e.reduce((e,t)=>e+t.sessions,0),[e]),a=(0,P.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,L.jsxs)(`section`,{"aria-labelledby":`daily-activity-title`,className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] p-4`,children:[(0,L.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{id:`daily-activity-title`,className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Daily Activity`}),(0,L.jsxs)(`p`,{className:`console-mono mt-1 text-[11px] text-[var(--console-muted)]`,children:[`Session activity · last `,e.length,` days`]})]}),(0,L.jsx)(`span`,{className:`console-mono text-right text-[11px] text-[var(--console-muted)]`,children:t?`${t.date} · ${V(t.sessions)} sessions · ${V(t.messages)} msgs`:`${V(i)} in range`})]}),(0,L.jsx)(`div`,{className:`flex h-32 items-end gap-[2px]`,onPointerLeave:()=>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,L.jsx)(`button`,{type:`button`,"aria-label":a,onPointerEnter:()=>n(e),onClick:()=>n(e),onFocus:()=>n(e),onBlur:()=>n(null),className:`flex-1 cursor-default rounded-t-[1px] border-0 p-0 transition-opacity focus-visible:ring-2 focus-visible:ring-[var(--console-text)] focus-visible:ring-offset-2 focus-visible:outline-none ${e.sessions>0?`bg-[var(--console-accent)]`:`bg-[var(--console-surface-muted)]`} ${o?`opacity-70`:`opacity-100`}`,style:{height:`${i}px`}},e.date)})}),(0,L.jsx)(`div`,{className:`console-mono mt-2 flex text-[10px] text-[var(--console-muted)]`,children:e.map((e,t)=>(0,L.jsx)(`span`,{className:`flex-1 text-center`,children:a.has(t)?_o(e.date):``},e.date))}),(0,L.jsxs)(`table`,{className:`sr-only`,children:[(0,L.jsx)(`caption`,{children:`Daily Activity data`}),(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`th`,{scope:`col`,children:`Date`}),(0,L.jsx)(`th`,{scope:`col`,children:`Sessions`}),(0,L.jsx)(`th`,{scope:`col`,children:`Messages`})]})}),(0,L.jsx)(`tbody`,{children:e.map(e=>(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`th`,{scope:`row`,children:e.date}),(0,L.jsx)(`td`,{children:e.sessions}),(0,L.jsx)(`td`,{children:e.messages})]},e.date))})]})]})}var yo={input:`#4A9EFF`,output:`#7C5CFF`,cache_read:`#3FB68B`,cache_create:`#E8A23B`},bo={input:`Input`,output:`Output`,cache_read:`Cache Read`,cache_create:`Cache Create`};function xo({buckets:e}){let[t,n]=(0,P.useState)(null),r=(0,P.useMemo)(()=>Math.max(1,...e.map(e=>e.input+e.output+e.cache_read+e.cache_create)),[e]),i=(0,P.useMemo)(()=>e.reduce((e,t)=>e+t.input+t.output+t.cache_read+t.cache_create,0),[e]),a=(0,P.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,L.jsxs)(`section`,{"aria-labelledby":`daily-token-activity-title`,className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] p-4`,children:[(0,L.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{id:`daily-token-activity-title`,className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Daily Token Activity`}),(0,L.jsxs)(`p`,{className:`console-mono mt-1 text-[11px] text-[var(--console-muted)]`,children:[`Token breakdown · last `,e.length,` days`]})]}),(0,L.jsx)(`span`,{className:`console-mono text-right text-[11px] text-[var(--console-muted)]`,children:t?`${t.date} · ${ho(t.input+t.output+t.cache_read+t.cache_create)} total`:`${ho(i)} in range`})]}),t?(0,L.jsx)(`div`,{className:`mb-2 flex gap-4`,children:[`input`,`output`,`cache_read`,`cache_create`].map(e=>(0,L.jsxs)(`span`,{className:`console-mono flex items-center gap-1.5 text-[10px] text-[var(--console-muted)]`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`inline-block size-2 rounded-full`,style:{backgroundColor:yo[e]}}),bo[e],`: `,ho(t[e])]},e))}):(0,L.jsx)(`div`,{className:`mb-2 flex gap-4`,children:[`input`,`output`,`cache_read`,`cache_create`].map(e=>(0,L.jsxs)(`span`,{className:`console-mono flex items-center gap-1.5 text-[10px] text-[var(--console-muted)]`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`inline-block size-2 rounded-full`,style:{backgroundColor:yo[e]}}),bo[e]]},e))}),(0,L.jsx)(`div`,{className:`flex h-32 items-end gap-[2px]`,onPointerLeave:()=>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,L.jsx)(`button`,{type:`button`,"aria-label":`${e.date} · ${i} total tokens · ${e.input} input · ${e.output} output · ${e.cache_read} cache read · ${e.cache_create} cache create`,onPointerEnter:()=>n(e),onClick:()=>n(e),onFocus:()=>n(e),onBlur:()=>n(null),className:`flex flex-1 cursor-default flex-col justify-end overflow-hidden rounded-t-[1px] border-0 p-0 transition-opacity focus-visible:ring-2 focus-visible:ring-[var(--console-text)] focus-visible:ring-offset-2 focus-visible:outline-none ${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,L.jsx)(`div`,{style:{height:`${t}px`,backgroundColor:yo[e.key]}},e.key)}):(0,L.jsx)(`div`,{className:`h-full bg-[var(--console-surface-muted)]`})},e.date)})}),(0,L.jsx)(`div`,{className:`console-mono mt-2 flex text-[10px] text-[var(--console-muted)]`,children:e.map((e,t)=>(0,L.jsx)(`span`,{className:`flex-1 text-center`,children:a.has(t)?_o(e.date):``},e.date))}),(0,L.jsxs)(`table`,{className:`sr-only`,children:[(0,L.jsx)(`caption`,{children:`Daily Token Activity data`}),(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`th`,{scope:`col`,children:`Date`}),(0,L.jsx)(`th`,{scope:`col`,children:`Input`}),(0,L.jsx)(`th`,{scope:`col`,children:`Output`}),(0,L.jsx)(`th`,{scope:`col`,children:`Cache Read`}),(0,L.jsx)(`th`,{scope:`col`,children:`Cache Create`})]})}),(0,L.jsx)(`tbody`,{children:e.map(e=>(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`th`,{scope:`row`,children:e.date}),(0,L.jsx)(`td`,{children:e.input}),(0,L.jsx)(`td`,{children:e.output}),(0,L.jsx)(`td`,{children:e.cache_read}),(0,L.jsx)(`td`,{children:e.cache_create})]},e.date))})]})]})}var So=[`#4A9EFF`,`#7C5CFF`,`#3FB68B`,`#E8A23B`,`#E5484D`,`#5BCEDA`,`#F472B6`,`#A78BFA`,`#FB923C`,`#6EE7B7`];function Co({entries:e}){let t=(0,P.useMemo)(()=>e.filter(e=>e.tokens>0),[e]),n=(0,P.useMemo)(()=>t.reduce((e,t)=>e+t.tokens,0),[t]);if(t.length===0||n===0)return(0,L.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] 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:So[t%So.length]})),i=r.reduce((e,t)=>(e[t.chartKey]={label:t.model,color:t.fill},e),{});return(0,L.jsxs)(`section`,{"aria-labelledby":`model-distribution-title`,className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] p-4`,children:[(0,L.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,L.jsx)(`h2`,{id:`model-distribution-title`,className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Model Distribution`}),(0,L.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[t.length,` models`]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-6`,children:[(0,L.jsxs)(`div`,{className:`flex shrink-0 flex-col items-center`,children:[(0,L.jsx)(lo,{config:i,className:`aspect-square size-[160px]`,"aria-hidden":`true`,children:(0,L.jsxs)(Ue,{children:[(0,L.jsx)(fo,{content:(0,L.jsx)(po,{hideLabel:!0,nameKey:`chartKey`,formatter:e=>(0,L.jsxs)(`span`,{className:`font-mono font-medium text-foreground tabular-nums`,children:[V(Number(e)),` tokens`]})})}),(0,L.jsx)(Oe,{data:r,dataKey:`tokens`,nameKey:`chartKey`,outerRadius:70,paddingAngle:1,strokeWidth:0,isAnimationActive:!1})]})}),(0,L.jsxs)(`div`,{className:`console-mono -mt-1 text-center`,children:[(0,L.jsx)(`div`,{className:`text-xs font-semibold text-[var(--console-text)]`,children:ho(n)}),(0,L.jsx)(`div`,{className:`text-[10px] text-[var(--console-muted)]`,children:`tokens`})]})]}),(0,L.jsx)(`ul`,{className:`min-w-0 flex-1 space-y-1.5`,children:r.map(e=>(0,L.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`inline-block size-2.5 shrink-0 rounded-full`,style:{backgroundColor:e.fill}}),(0,L.jsx)(`span`,{className:`console-mono min-w-0 flex-1 truncate text-xs text-[var(--console-text)]`,children:e.model}),(0,L.jsxs)(`span`,{className:`console-mono shrink-0 text-[11px] text-[var(--console-muted)]`,children:[ho(e.tokens),` · `,(e.fraction*100).toFixed(1),`%`]})]},e.model))})]})]})}function wo({perAgent:e}){let t=(0,P.useMemo)(()=>e.reduce((e,t)=>e+t.sessions,0),[e]);return t===0||e.length===0?(0,L.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] p-4 text-sm text-[var(--console-muted)]`,children:`No agent data yet`}):(0,L.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] p-4`,children:[(0,L.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,L.jsx)(`h2`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Agent Distribution`}),(0,L.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` agents`]})]}),(0,L.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>{let n=t>0?e.sessions/t*100:0;return(0,L.jsx)(`li`,{children:(0,L.jsxs)(M,{to:`/${e.name.toLowerCase()}`,className:`block rounded-sm border border-transparent px-2 py-1.5 motion-hover hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon?(0,L.jsx)(U,{icon:e.icon,iconColored:e.iconColored,alt:e.displayName,className:`size-4 object-contain`}):null,(0,L.jsx)(`span`,{className:`console-mono flex-1 text-xs text-[var(--console-text)]`,children:e.displayName}),(0,L.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[V(e.sessions),` · `,n.toFixed(1),`%`]})]}),(0,L.jsx)(`div`,{className:`mt-1.5 h-1.5 overflow-hidden rounded-sm bg-[var(--console-surface-muted)]`,children:(0,L.jsx)(`div`,{className:`h-full bg-[var(--console-accent)]`,style:{width:`${n}%`}})}),(0,L.jsxs)(`div`,{className:`console-mono mt-1 flex gap-3 text-[10px] text-[var(--console-muted)]`,children:[(0,L.jsxs)(`span`,{children:[V(e.messages),` msgs`]}),(0,L.jsxs)(`span`,{children:[ho(e.tokens),` tokens`]})]})]})},e.name)})})]})}function To({projects:e,agentCatalog:t}){return e.length===0?null:(0,L.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] p-4`,children:[(0,L.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,L.jsx)(`h2`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Projects`}),(0,L.jsx)(M,{to:`/projects`,className:`console-mono text-[11px] text-[var(--console-muted)] motion-hover hover:text-[var(--console-text)]`,children:`View all`})]}),(0,L.jsx)(`ul`,{className:`space-y-2`,children:e.slice(0,5).map(e=>{let n=e.agentStats.slice(0,3);return(0,L.jsx)(`li`,{children:(0,L.jsxs)(M,{to:Cr({kind:e.identityKind,key:e.identityKey}),className:`block rounded-sm border border-transparent px-2 py-1.5 motion-hover hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`console-mono min-w-0 flex-1 truncate text-xs text-[var(--console-text)]`,children:e.displayName}),(0,L.jsxs)(`span`,{className:`console-mono shrink-0 text-[11px] text-[var(--console-muted)]`,children:[V(e.sessionCount),` · `,Sa(e.cost)]})]}),(0,L.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5`,children:[n.map(e=>{let n=ji(t,e.name);return(0,L.jsxs)(`span`,{className:`console-mono inline-flex items-center gap-1 rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-1.5 py-0.5 text-[10px] text-[var(--console-muted)]`,children:[n?.icon?(0,L.jsx)(U,{icon:n.icon,iconColored:n.iconColored,alt:n.displayName,className:`size-3 object-contain`}):null,n?.displayName??e.name,` · `,e.sessions]},e.name)}),(0,L.jsxs)(`span`,{className:`console-mono min-w-0 truncate text-[10px] text-[var(--console-muted)]`,children:[ho(e.tokens),` tokens`]})]})]})},`${e.identityKind}:${e.identityKey}`)})})]})}function Eo({sessions:e,agentCatalog:t,onToggleBookmark:n}){return e.length===0?null:(0,L.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] p-4`,children:[(0,L.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,L.jsx)(`h2`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Bookmarked Sessions`}),(0,L.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` items`]})]}),(0,L.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>{let{reference:r,session:i}=e,a=ji(t,r.agentName),o=i.time_updated??i.time_created;return(0,L.jsx)(`li`,{children:(0,L.jsxs)(`div`,{className:`flex items-start gap-2 rounded-sm border border-transparent px-2 py-1.5 motion-hover hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,L.jsxs)(M,{to:`/${i.slug}`,className:`flex min-w-0 flex-1 items-start gap-2`,children:[a?.icon?(0,L.jsx)(U,{icon:a.icon,iconColored:a.iconColored,alt:a.displayName,className:`mt-0.5 size-3.5 shrink-0 object-contain`}):null,(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`p`,{className:`line-clamp-1 text-sm text-[var(--console-text)]`,children:H(i)}),(0,L.jsxs)(`p`,{className:`console-mono mt-0.5 line-clamp-1 text-[11px] text-[var(--console-muted)]`,children:[`/`,i.slug,` · `,xa(o)]})]})]}),(0,L.jsx)(ro,{active:!0,onToggle:()=>n(e)})]})},mi(r))})})]})}function Do({sessions:e,agentCatalog:t,isBookmarked:n,onToggleBookmark:r}){return e.length===0?(0,L.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] p-4 text-sm text-[var(--console-muted)]`,children:`No sessions yet`}):(0,L.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] p-4`,children:[(0,L.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,L.jsx)(`h2`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Recent Activity`}),(0,L.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` items`]})]}),(0,L.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>{let{reference:i,session:a}=e,o=i.agentName.toLowerCase(),s=ji(t,o),c=a.time_updated??a.time_created,l=n(o,i.sessionId);return(0,L.jsx)(`li`,{children:(0,L.jsxs)(`div`,{className:`flex items-start gap-2 rounded-sm border border-transparent px-2 py-1.5 motion-hover hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,L.jsxs)(M,{to:`/${a.slug}`,className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s?.icon?(0,L.jsx)(U,{icon:s.icon,iconColored:s.iconColored,alt:s.displayName,className:`size-3.5 shrink-0 object-contain`}):null,(0,L.jsx)(`p`,{className:`line-clamp-1 flex-1 text-sm text-[var(--console-text)]`,children:H(a)}),(0,L.jsx)(`span`,{className:`console-mono shrink-0 text-[11px] text-[var(--console-muted)]`,children:xa(c)})]}),(0,L.jsxs)(`p`,{className:`console-mono mt-0.5 line-clamp-1 text-[11px] text-[var(--console-muted)]`,children:[`/`,a.slug]}),(0,L.jsx)(Fr,{tags:a.smart_tags,className:`mt-1.5`})]}),(0,L.jsx)(ro,{active:l,onToggle:()=>r(e)})]})},mi(i))})})]})}function Oo({activity:e}){return e.length===0?(0,L.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] p-4 text-sm text-[var(--console-muted)]`,children:`No file activity yet`}):(0,L.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] p-4`,children:[(0,L.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,L.jsx)(`h2`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Recently Touched Files`}),(0,L.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` files`]})]}),(0,L.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>{let t=e.latestTime;return(0,L.jsx)(`li`,{children:(0,L.jsxs)(M,{to:`/${e.session.slug}`,className:`block rounded-sm border border-transparent px-2 py-1.5 motion-hover hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.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,L.jsx)(`span`,{className:`console-mono min-w-0 flex-1 truncate text-xs text-[var(--console-text)]`,children:e.path}),(0,L.jsx)(`span`,{className:`console-mono shrink-0 text-[11px] text-[var(--console-muted)]`,children:xa(t)})]}),(0,L.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,` ·`,` `,H(e.session),` · `,e.count,` events`]})]})},`${e.reference.agentName}/${e.reference.sessionId}/${e.kind}/${e.path}`)})})]})}function ko({data:e,agentCatalog:t,projects:n=[],bookmarkedSessions:r,isBookmarked:i,onToggleBookmark:a}){let{totals:o,perAgent:s,dailyActivity:c,dailyTokenActivity:l,modelDistribution:u,recentSessions:d,recentFileActivities:f=[]}=e;return(0,L.jsxs)(`div`,{"data-testid":`dashboard`,className:`mx-auto max-w-5xl space-y-4`,children:[(0,L.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-5`,children:[(0,L.jsx)(go,{label:`Total Sessions`,value:V(o.sessions)}),(0,L.jsx)(go,{label:`Total Messages`,value:V(o.messages)}),(0,L.jsx)(go,{label:`Total Tokens`,value:ho(o.tokens)}),(0,L.jsx)(go,{label:`Total Cost`,value:Sa(o.cost),hint:Ca(o.cost_source)}),(0,L.jsx)(go,{label:`Latest Activity`,value:xa(o.latestActivity),hint:o.latestActivity?new Date(o.latestActivity).toLocaleString(`zh-CN`):void 0})]}),(0,L.jsx)(vo,{buckets:c}),(0,L.jsx)(xo,{buckets:l}),(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsx)(Co,{entries:u}),(0,L.jsx)(wo,{perAgent:s})]}),(0,L.jsx)(To,{projects:n,agentCatalog:t}),(0,L.jsx)(Do,{sessions:d,agentCatalog:t,isBookmarked:i,onToggleBookmark:a}),(0,L.jsx)(Oo,{activity:f}),(0,L.jsx)(Eo,{sessions:r,agentCatalog:t,onToggleBookmark:e=>a(e)})]})}function Ao(e){return e.total_tokens??e.total_input_tokens+e.total_output_tokens}function jo({label:e,value:t,hint:n}){return(0,L.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] p-4`,children:[(0,L.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-wider text-[var(--console-muted)]`,children:e}),(0,L.jsx)(`p`,{className:`console-mono mt-2 text-xl font-semibold text-[var(--console-text)]`,children:t}),n?(0,L.jsx)(`p`,{className:`mt-1 text-xs text-[var(--console-muted)]`,children:n}):null]})}function Mo({label:e,value:t}){return(0,L.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] p-3`,children:[(0,L.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-wider text-[var(--console-muted)]`,children:e}),(0,L.jsx)(`p`,{className:`console-mono mt-2 break-all text-sm leading-6 text-[var(--console-text)]`,children:t})]})}function No({code:e,title:t,description:n,aside:r,iconSrc:i,iconColored:a,iconAlt:o}){return(0,L.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border-strong)] bg-[var(--console-surface)] p-5 md:p-6`,children:(0,L.jsxs)(`div`,{className:`flex flex-col gap-5 md:flex-row md:items-start md:justify-between`,children:[(0,L.jsxs)(`div`,{className:`max-w-2xl`,children:[(0,L.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,L.jsxs)(`div`,{className:`mt-4 flex items-start gap-3`,children:[i?(0,L.jsx)(U,{icon:i,iconColored:a,alt:o||``,className:`mt-1 size-8 shrink-0 object-contain`}):null,(0,L.jsx)(`h2`,{className:`console-mono text-2xl leading-tight font-semibold tracking-tight text-[var(--console-text)] md:text-[2rem]`,children:t})]}),(0,L.jsx)(`p`,{className:`mt-3 max-w-[42rem] text-sm leading-7 text-[var(--console-muted)]`,children:n})]}),(0,L.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,L.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-[0.16em] text-[var(--console-muted)]`,children:`STATUS NOTE`}),(0,L.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-[var(--console-text)]`,children:r})]})]})})}function Po({agentItems:e}){return(0,L.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] p-4`,children:[(0,L.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,L.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Known Agents`}),(0,L.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` items`]})]}),(0,L.jsx)(`ul`,{className:`grid gap-2 sm:grid-cols-2`,children:e.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsxs)(M,{to:`/${e.key}`,className:`flex min-h-11 items-center gap-2 rounded-sm border border-transparent px-3 py-2 motion-hover 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:[e.icon?(0,L.jsx)(U,{icon:e.icon,iconColored:e.iconColored,alt:e.name,className:`size-4 object-contain`}):null,(0,L.jsx)(`span`,{className:`console-mono flex-1 text-xs text-[var(--console-text)]`,children:e.name}),(0,L.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:e.count})]})},e.key))})]})}function Fo({sessions:e,isBookmarked:t,onToggleBookmark:n}){return e.length===0?(0,L.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] p-4 text-sm text-[var(--console-muted)]`,children:`No sessions yet`}):(0,L.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] p-4`,children:[(0,L.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,L.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Recent Sessions`}),(0,L.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` items`]})]}),(0,L.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>{let r=t(e.agentKey,e.id);return(0,L.jsx)(`li`,{children:(0,L.jsxs)(`div`,{className:`flex items-start gap-2 rounded-sm border border-transparent px-2 py-1.5 motion-hover hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,L.jsxs)(M,{to:`/${e.reference}`,className:`min-w-0 flex-1`,children:[(0,L.jsx)(`p`,{className:`line-clamp-1 text-sm text-[var(--console-text)]`,children:H(e)}),(0,L.jsxs)(`p`,{className:`console-mono mt-0.5 text-[11px] text-[var(--console-muted)]`,children:[`/`,e.reference,` ·`,` `,xa(e.time_updated||e.time_created)]}),(0,L.jsx)(Fr,{tags:e.smart_tags,className:`mt-1.5`})]}),(0,L.jsx)(ro,{active:r,onToggle:()=>n(e)})]})},e.id)})})]})}function Io({type:e,agentCatalog:t,sessions:n,agentItems:r,activeAgentKey:i,attemptedAgentKey:a,attemptedSessionId:o,isBookmarked:s,onToggleBookmark:c}){let l=n.toSorted((e,t)=>(t.time_updated||t.time_created||0)-(e.time_updated||e.time_created||0)),u=l.slice(0,5),d=n.reduce((e,t)=>e+t.stats.message_count,0),f=n.reduce((e,t)=>e+Ao(t.stats),0),p=n.reduce((e,t)=>e+t.stats.total_cost,0),m=p>0?n.some(e=>e.stats.cost_source===`estimated`)?`estimated`:`recorded`:void 0,h=l[0]?.time_updated||l[0]?.time_created;if(e===`missing-agent`){let e=`/${a||`unknown`}${o?`/${o}`:``}`;return(0,L.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,L.jsx)(No,{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,L.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,L.jsx)(Mo,{label:`Requested Agent`,value:a||`unknown`}),(0,L.jsx)(Mo,{label:`Requested Path`,value:e}),o?(0,L.jsx)(Mo,{label:`Requested Session`,value:o}):null]}),(0,L.jsx)(Po,{agentItems:r})]})}if(e===`missing-session`){let e=i?ji(t,i):void 0,n=e?.displayName??i??`Unknown Agent`,r=e?.icon,a=o||`unknown-session`;return(0,L.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,L.jsx)(No,{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 session ID 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:r,iconColored:e?.iconColored,iconAlt:n}),(0,L.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,L.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] p-3`,children:[(0,L.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-wider text-[var(--console-muted)]`,children:`Agent`}),(0,L.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[r?(0,L.jsx)(U,{icon:r,iconColored:e?.iconColored,alt:n,className:`size-4 shrink-0 object-contain`}):null,(0,L.jsx)(`p`,{className:`console-mono break-all text-sm leading-6 text-[var(--console-text)]`,children:n})]})]}),(0,L.jsx)(Mo,{label:`Session`,value:a})]}),(0,L.jsx)(Fo,{sessions:u,isBookmarked:s,onToggleBookmark:c})]})}if(e===`global`)return(0,L.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,L.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,L.jsx)(jo,{label:`Total Sessions`,value:V(n.length)}),(0,L.jsx)(jo,{label:`Total Messages`,value:V(d)}),(0,L.jsx)(jo,{label:`Latest Activity`,value:xa(h),hint:h?new Date(h).toLocaleString(`zh-CN`):void 0})]}),(0,L.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] p-4`,children:[(0,L.jsx)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:`Agents`}),(0,L.jsx)(`ul`,{className:`grid gap-2 sm:grid-cols-2`,children:r.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsxs)(M,{to:`/${e.key}`,className:`flex items-center gap-2 rounded-sm border border-transparent px-2 py-1.5 motion-hover hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[e.icon?(0,L.jsx)(U,{icon:e.icon,iconColored:e.iconColored,alt:e.name,className:`size-4 object-contain`}):null,(0,L.jsx)(`span`,{className:`console-mono flex-1 text-xs text-[var(--console-text)]`,children:e.name}),(0,L.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:e.count})]})},e.key))})]}),(0,L.jsx)(Fo,{sessions:u,isBookmarked:s,onToggleBookmark:c})]});let g=i?ji(t,i):void 0,_=g?.displayName??`Unknown Agent`;return(0,L.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,L.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] p-4`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[g?.icon?(0,L.jsx)(U,{icon:g.icon,iconColored:g.iconColored,alt:_,className:`size-6 object-contain`}):null,(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`console-mono text-sm font-semibold text-[var(--console-text)]`,children:_}),(0,L.jsx)(`p`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:`Select a session from the left to view details`})]})]})}),(0,L.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-4`,children:[(0,L.jsx)(jo,{label:`Sessions`,value:V(n.length)}),(0,L.jsx)(jo,{label:`Messages`,value:V(d)}),(0,L.jsx)(jo,{label:`Tokens`,value:V(f)}),(0,L.jsx)(jo,{label:`Total Cost`,value:Sa(p),hint:Ca(m)})]}),(0,L.jsx)(Fo,{sessions:u,isBookmarked:s,onToggleBookmark:c})]})}function Lo(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:V(e)}function Ro(e){return e.stats.total_tokens??e.stats.total_input_tokens+e.stats.total_output_tokens}function zo({label:e,value:t,hint:n}){return(0,L.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] p-4`,children:[(0,L.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-wider text-[var(--console-muted)]`,children:e}),(0,L.jsx)(`p`,{className:`console-mono mt-2 text-xl font-semibold text-[var(--console-text)]`,children:t}),n?(0,L.jsx)(`p`,{className:`mt-1 text-xs text-[var(--console-muted)]`,children:n}):null]})}function Bo({agents:e,agentCatalog:t}){return e.length===0?null:(0,L.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:e.slice(0,4).map(e=>{let n=ji(t,e.name);return(0,L.jsxs)(`span`,{className:`console-mono inline-flex items-center gap-1 rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-1.5 py-0.5 text-[10px] text-[var(--console-muted)]`,children:[n?.icon?(0,L.jsx)(U,{icon:n.icon,iconColored:n.iconColored,alt:n.displayName,className:`size-3 object-contain`}):null,n?.displayName??e.name,` · `,e.sessions]},e.name)})})}function Vo({project:e,agentCatalog:t}){return(0,L.jsx)(`li`,{children:(0,L.jsxs)(M,{to:Cr({kind:e.identityKind,key:e.identityKey}),className:`block rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)]/85 p-4 motion-hover hover:border-[var(--console-border-strong)] hover:bg-[var(--console-surface)]`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`h2`,{className:`console-mono line-clamp-1 text-sm font-semibold text-[var(--console-text)]`,children:e.displayName}),(0,L.jsx)(`p`,{className:`console-mono mt-1 break-all text-[11px] text-[var(--console-muted)]`,children:e.identityKey})]}),(0,L.jsxs)(`div`,{className:`console-mono flex shrink-0 flex-wrap gap-2 text-[11px] text-[var(--console-muted)]`,children:[(0,L.jsxs)(`span`,{children:[V(e.sessionCount),` sessions`]}),(0,L.jsxs)(`span`,{children:[Lo(e.tokens),` tokens`]}),(0,L.jsx)(`span`,{children:Sa(e.cost)}),(0,L.jsx)(`span`,{children:xa(e.lastActivity)})]})]}),(0,L.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2 md:flex-row md:items-center md:justify-between`,children:[(0,L.jsx)(Bo,{agents:e.agentStats,agentCatalog:t}),(0,L.jsx)(`span`,{className:`console-mono text-[10px] uppercase text-[var(--console-muted)]`,children:e.identityKind})]})]})})}function Ho({projects:e,agentCatalog:t}){let n=e.reduce((e,t)=>e+t.sessionCount,0),r=e.reduce((e,t)=>e+t.tokens,0),i=e.reduce((e,t)=>e+t.cost,0),a=Math.max(0,...e.map(e=>e.lastActivity??0));return e.length===0?(0,L.jsx)(`div`,{className:`mx-auto max-w-5xl rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] p-6 text-sm text-[var(--console-muted)]`,children:`No projects found`}):(0,L.jsxs)(`div`,{className:`mx-auto max-w-5xl space-y-4`,children:[(0,L.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-4`,children:[(0,L.jsx)(zo,{label:`Projects`,value:V(e.length)}),(0,L.jsx)(zo,{label:`Sessions`,value:V(n)}),(0,L.jsx)(zo,{label:`Tokens`,value:Lo(r)}),(0,L.jsx)(zo,{label:`Total Cost`,value:Sa(i),hint:a?`Latest ${xa(a)}`:void 0})]}),(0,L.jsx)(`ul`,{className:`grid gap-3`,children:e.map(e=>(0,L.jsx)(Vo,{project:e,agentCatalog:t},`${e.identityKind}:${e.identityKey}`))})]})}function Uo({agents:e,agentCatalog:t,activeAgent:n,onChange:r}){return(0,L.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] p-3`,children:(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`Agent`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>r(void 0),className:`console-mono rounded-sm border px-2 py-1 text-[10px] motion-hover ${n?`border-[var(--console-border)] bg-[var(--console-surface-muted)] text-[var(--console-muted)] hover:bg-[var(--console-surface)]`:`border-[var(--console-border-strong)] bg-[var(--console-accent)] text-white dark:text-[var(--console-bg)]`}`,children:`All Agents`}),e.map(e=>{let i=ji(t,e.name),a=n===e.name;return(0,L.jsxs)(`button`,{type:`button`,onClick:()=>r(a?void 0:e.name),className:`console-mono inline-flex items-center gap-1 rounded-sm border px-2 py-1 text-[10px] motion-hover ${a?`border-[var(--console-border-strong)] bg-[var(--console-accent)] text-white dark:text-[var(--console-bg)]`:`border-[var(--console-border)] bg-[var(--console-surface-muted)] text-[var(--console-muted)] hover:bg-[var(--console-surface)]`}`,children:[i?.icon?(0,L.jsx)(U,{icon:i.icon,iconColored:i.iconColored,alt:i.displayName,className:`size-3 object-contain`}):null,i?.displayName??e.name,` · `,e.sessions]},e.name)})]})})}function Wo({project:e,agentCatalog:t}){return(0,L.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] p-4`,children:(0,L.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`h2`,{className:`console-mono text-base font-semibold text-[var(--console-text)]`,children:e.displayName}),(0,L.jsxs)(`p`,{className:`console-mono mt-1 break-all text-[11px] text-[var(--console-muted)]`,children:[e.identityKind,`: `,e.identityKey]})]}),(0,L.jsx)(Bo,{agents:e.agentStats,agentCatalog:t})]})})}function Go({sessions:e,agentCatalog:t}){if(e.length===0)return null;let n=e.toSorted((e,t)=>t.stats.total_cost-e.stats.total_cost).slice(0,5);return(0,L.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] p-4`,children:[(0,L.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,L.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Top Cost`}),(0,L.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[n.length,` sessions`]})]}),(0,L.jsx)(`ul`,{className:`space-y-2`,children:n.map(e=>{let n=ji(t,e.agentKey);return(0,L.jsx)(`li`,{children:(0,L.jsxs)(M,{to:`/${e.reference}`,className:`block rounded-sm border border-transparent px-2 py-1.5 motion-hover hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?.icon?(0,L.jsx)(U,{icon:n.icon,iconColored:n.iconColored,alt:n.displayName,className:`size-3.5 object-contain`}):null,(0,L.jsx)(`span`,{className:`line-clamp-1 flex-1 text-sm text-[var(--console-text)]`,children:H(e)}),(0,L.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:Sa(e.stats.total_cost)})]}),(0,L.jsxs)(`p`,{className:`console-mono mt-1 text-[11px] text-[var(--console-muted)]`,children:[`/`,e.reference,` · `,Lo(Ro(e)),` tokens`]})]})},e.reference)})})]})}function Ko({project:e,agentCatalog:t,projectKey:n,dashboard:r,loading:i,error:a,sessions:o,activeAgent:s,onChangeAgent:c,isBookmarked:l,onToggleSessionBookmark:u}){if(!e)return(0,L.jsxs)(`div`,{className:`mx-auto max-w-4xl rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] p-6`,children:[(0,L.jsx)(`h2`,{className:`console-mono text-sm font-semibold text-[var(--console-text)]`,children:`Project Not Found`}),(0,L.jsx)(`p`,{className:`console-mono mt-2 break-all text-xs text-[var(--console-muted)]`,children:n}),(0,L.jsx)(M,{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)] motion-hover hover:bg-[var(--console-surface)]`,children:`Back to Projects`})]});let d=s?o.filter(e=>e.agentKey===s):o;return(0,L.jsxs)(`div`,{className:`mx-auto max-w-5xl space-y-4`,children:[(0,L.jsx)(Wo,{project:e,agentCatalog:t}),(0,L.jsx)(Uo,{agents:e.agentStats,agentCatalog:t,activeAgent:s,onChange:c}),i?(0,L.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] p-6 text-sm text-[var(--console-muted)]`,children:`Loading project dashboard`}):a?(0,L.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:a}):r?(0,L.jsx)(ko,{data:r,agentCatalog:t,projects:[],bookmarkedSessions:[],isBookmarked:l,onToggleBookmark:e=>{`bookmarkedAt`in e||u(e.session,e.reference.agentName)}}):null,(0,L.jsx)(Go,{sessions:d,agentCatalog:t})]})}var qo={a:({children:e})=>(0,L.jsx)(`span`,{className:`console-markdown-link`,children:e})};function Jo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Yo(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(Jo).join(`|`)})`,`gi`)}var Xo=(0,P.memo)(function({text:e,highlightQuery:t}){let r=(0,P.useRef)(null),i=(0,P.useMemo)(()=>Yo(t),[t]);return(0,P.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,L.jsx)(`div`,{ref:r,children:(0,L.jsx)(n,{components:qo,children:e})})});function Zo(e){let t=[];for(let n of e){if(n.type===`image`)continue;if(n.type===`plan`){t.push({type:`plan`,parts:[n]});continue}if(n.type!==`tool`&&!n.text.trim())continue;let e=t.at(-1);if(n.type===`text`){e?.type===`text`?e.parts.push(n):t.push({type:`text`,parts:[n]});continue}if(n.type===`reasoning`){e?.type===`reasoning`?e.parts.push(n):t.push({type:`reasoning`,parts:[n]});continue}e?.type===`tool`?e.parts.push(n):t.push({type:`tool`,parts:[n]})}return t}function Qo(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function $o(e){return typeof e==`string`?e:``}function es(e){return e.replace(/\\n/g,`
|
|
76
|
+
`)}function ts(e){let t=Qo(e),n=$o(t.type);return n?{type:n,path:$o(t.path),oldPath:$o(t.old_path),targetPath:$o(t.targetPath),content:$o(t.content)||$o(Qo(t.input).content)}:null}function ns(e){return(Array.isArray(e)?e:Array.isArray(Qo(e).content)?Qo(e).content:[]).map(e=>ts(e)).filter(e=>e!=null)}function rs(e,t,n){return`${e} ${e===1?t:n}`}function is(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(rs(t,`write`,`writes`)),n>0&&a.push(rs(n,`edit`,`edits`)),r>0&&a.push(rs(r,`delete`,`deletes`)),i>0&&a.push(rs(i,`move`,`moves`)),a.join(` · `)}function as(e){return e.targetPath||e.path||e.oldPath||e.type}function os(e,t,n){return e.reduce((e,r)=>r.type===`write_file`?(e.push({label:n(as(r)),operation:`write`,language:t(r.path),isCode:!0,text:es(r.content)}),e):r.type===`edit_file`?(e.push({label:n(as(r)),operation:`edit`,language:`diff`,isCode:!0,text:es(r.content)}),e):r.type===`delete_file`?(e.push({label:n(as(r)),operation:`edit`,language:`text`,isCode:!1,text:`File deleted.`}),e):(r.type===`move_file`&&e.push({label:n(as(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 ss(e,t,n,r=e=>e){let i=os(e,n,r);return i.length>0?{kind:`file-sections`,sections:i}:{kind:`plain`,text:t,language:`text`,isCode:!1}}function cs(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function ls(e){if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}}function us(e){return typeof e==`string`?e.trim():``}function W(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function G(e){return typeof e==`string`?e.trim():``}function K(e){return typeof e==`string`?e:``}function ds(e){try{return JSON.parse(e)}catch{return null}}function q(e){return e.replaceAll(/\\n/g,`
|
|
77
|
+
`)}function fs(e){let t=G(e.mime_type),n=G(e.data);if(t.startsWith(`image/`)&&n)return`data:${t};base64,${n}`;let r=G(e.url);return/^data:image\//i.test(r)?r:``}function ps(e){return Array.isArray(e)?e.flatMap((e,t)=>{let n=W(e);if(n.type!==`image`)return[];let r=fs(n);return r?[{src:r,alt:`Tool output image ${t+1}`}]:[]}):[]}function ms(e){let t=ps(e);if(t.length>0)return{kind:`media`,items:t,text:vs(e,!1)||void 0};let n=typeof e==`string`&&e.trim()?ls(e.trim()):e;if(n&&typeof n==`object`&&!Array.isArray(n)){let e=Object.entries(n).map(([e,t])=>({label:e,value:t}));return e.length>0?{kind:`property-list`,items:e}:null}return null}function hs(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 gs(e){if(typeof e==`string`)return[e];if(Array.isArray(e))return e.flatMap(e=>gs(e));if(e&&typeof e==`object`){let t=e;if(typeof t.text==`string`)return[t.text];if(t.content!==void 0)return gs(t.content)}return[]}function _s(e){return e.replace(/^<system>/i,``).replace(/<\/system>$/i,``).trim()}function vs(e,t=!0){let n=gs(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)?_s(e):e).join(`
|
|
78
|
+
`)}function ys(e){let t=ls(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 bs(e){let t=e.trim();return t?t.replace(/^tool:\s*/i,``).replace(/^\.+(?=\w)/,``):``}function xs(e){return e.title?.trim()?bs(e.title):e.tool.trim()?bs(e.tool):`tool`}function Ss(e){return xs(e).trim().toLowerCase()}function Cs(e,t=`Tool`){return bs(G(e.title))||G(e.tool)||t}function ws(e){return q(vs(e)||hs(e))||`No output captured.`}function J(e){let t=ws(e.outputValue);if(t!==`No output captured.`)return t;let n=ws(e.errorValue);return n===`No output captured.`?`No output captured.`:n}function Ts(e){let{status:t,input:n,output:r,error:i,metadata:a}=e.state,o=r??``,s=i??``,c=ls(n??{}),l=a??{};return{status:t,command:ys(c),inputValue:c,outputValue:o,errorValue:s,metadataValue:l,inputText:hs(c)}}function Es(e){let t=us(e.nickname);return e.role===`assistant`&&t?`AGENT (${t})`:e.role===`user`?`USER`:e.role===`tool`?`TOOL`:`AGENT`}function Ds(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 Os(e){let t=e.trim();return!t||t.length>300||t.includes(`
|
|
79
|
+
`)||/^[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 ks(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 As(e,t,n,r=0){if(!(e==null||r>4)){if(typeof e==`string`){ks(t)&&Os(e)&&n.add(e.trim());return}if(Array.isArray(e)){for(let i of e)As(i,t,n,r+1);return}if(typeof e==`object`)for(let[t,i]of Object.entries(e))As(i,t,n,r+1)}}function js(e){let t=new Set;return As(e,``,t),[...t]}function Ms(e){return e.state.input??null}function Ns(e){let t=W(e);return G(t.filePath)||G(t.file_path)||G(t.path)||G(t.targetFile)||G(t.effectiveUri)||G(t.relativeWorkspacePath)||``}function Y(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 Ps(e,t){let n=(t??``).replace(/\/+$/,``);return!e||!n?e:e.replace(RegExp(`${cs(n)}(?=$|/|[\\s"'\\)\\]}:;,])`,`g`),`.`)}function Fs(e,t){return e.startsWith(`${t}/`)?e.slice(t.length+1):e}var Is=new Set([`read`,`read_file`,`read_file_v2`,`read_text_file`,`readfile`,`view_image`]),Ls=new Set([`apply_patch`,`edit`,`edit_file`,`edit_file_v2`,`editfile`,`multiedit`,`notebookedit`,`patch`,`search_replace`,`str_replace`]),Rs=new Set([`create_file`,`write`,`write_file`,`writefile`]),zs=new Set([`delete`,`delete_file`]);function Bs(e,t){return`tool-${e}-${t}`}function Vs(e){let t=Ss(e);return Is.has(t)?`read`:Ls.has(t)?`edit`:Rs.has(t)?`write`:zs.has(t)?`delete`:null}function Hs(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 Us(e){let t=new Map,n={read:[],edit:[],write:[],delete:[]};return e.forEach(({msg:e,blocks:r,index:i})=>{let a=0;for(let o of r)if(o.type===`tool`)for(let[r,s]of o.parts.entries()){let c=o.anchorIds?.[r]??Bs(i,a);a+=1,t.set(c,i);let l=Ms(s),u=xs(s),d=s.time_created??e.time_created,f=ns(l);if(f.length>0){for(let e of f){let t=(e.path||e.oldPath).trim();if(!t)continue;let r=e.type===`write_file`?`write`:e.type===`delete_file`?`delete`:`edit`;n[r].push({kind:r,path:t,anchorId:c,time:d,toolLabel:u})}continue}let p=Vs(s);if(!p)continue;let m=js(l);for(let e of m)n[p].push({kind:p,path:e,anchorId:c,time:d,toolLabel:u})}}),{anchorMessageIndexes:t,summary:{read:Hs(n.read),edit:Hs(n.edit),write:Hs(n.write),delete:Hs(n.delete)}}}function Ws(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.latestTime,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}var Gs=48,Ks=1;function qs(e){return`session-message-${e}`}function Js(e,t){return`${qs(e)}-block-${t}`}function Ys(e){let t=e.replace(/<!--[\s\S]*?-->/g,` `).replace(/(^|\s)#{1,6}\s+/g,`$1`).replace(/(\*\*|__)(.*?)\1/g,`$2`).replace(/([*_])(.*?)\1/g,`$2`).replace(/`([^`]+)`/g,`$1`).replace(/\s+/g,` `).trim(),n=Array.from(t);return n.length<=Gs?t:`${n.slice(0,Gs).join(``)}…`}function Xs(e){return Ys(e.map(e=>e.type===`text`||e.type===`reasoning`||e.type===`plan`?e.text:``).filter(Boolean).join(` `))}function Zs(e){let t=Vs(e);return t===`read`?`tool-read`:t?`tool-write`:`tool-execute`}var Qs={"tool-read":`Read`,"tool-write":`Write`,"tool-execute":`Execute`};function $s(e){let t=[];for(let{msg:n,blocks:r,index:i}of e){if(n.role===`user`){let e=qs(i),n=Xs(r.flatMap(e=>e.parts));t.push({id:e,kind:`user`,anchorId:e,messageIndex:i,tooltip:`User · ${n||`Message`}`});continue}r.forEach((e,n)=>{if(e.type===`tool`){e.parts.forEach((n,r)=>{let a=e.anchorIds?.[r];if(!a)return;let o=Zs(n);t.push({id:a,kind:o,anchorId:a,messageIndex:i,tooltip:`${Qs[o]} · ${xs(n)}`})});return}let r=Js(i,n),a=Xs(e.parts);t.push({id:r,kind:`agent`,anchorId:r,messageIndex:i,tooltip:`Agent · ${a||`Response`}`})})}return t}function ec(e,t){if(e.length===0)return null;let n=e.toSorted((e,t)=>e.top-t.top),r=n[0].index;for(let e of n){if(e.top>t)break;r=e.index}return r}function tc(e,t,n,r){return r<=0?null:e<=Ks?0:e>=Math.max(0,n-t)-Ks?r-1:null}function nc(e,t,n,r){if(r<=0||n<=0)return null;let i=Math.min(1,Math.max(0,(e-t)/n));return Math.min(r-1,Math.floor(i*r))}function rc(e){return cc(e)?`Browser`:e.title?.trim()?ac(e.title):e.tool.trim()?ac(e.tool):`tool`}function ic(e){return cc(e)?`browser`:ac(e.tool.trim()?e.tool:rc(e)).toLowerCase()}function ac(e){return e.trim().replace(/^tool:\s*/i,``).replace(/^\.+(?=\w)/,``)}function oc(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function sc(e){return typeof e==`string`?e.trim():``}function cc(e){let t=sc(oc(e.state.metadata).namespace);return ac(sc(e.tool)).toLowerCase()===`js`&&(t===`mcp__node_repl__`||t===`mcp__node_repl__.js`)}function lc(e,t){let n=ic(t),r=`tool:${n}`,i=e.get(n);if(i){i.count+=1;return}e.set(n,{id:r,toolKey:n,label:rc(t),count:1})}function uc(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)lc(r,t),n.add(`tool:${ic(t)}`)}return{filterIds:n,counts:t,tools:[...r.values()].toSorted((e,t)=>e.label.localeCompare(t.label))}}function dc(e,t){return t.has(`tool:${ic(e)}`)}function fc(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=>dc(e,n))}function pc(e,t){let n=e.parts.map((e,n)=>dc(e,t)?n:-1).filter(e=>e>=0),r=n.map(t=>e.parts[t]);return r.length===0?null:{...e,parts:r,anchorIds:e.anchorIds?n.map(t=>e.anchorIds[t]):void 0}}function mc(e,t){return e.map(e=>{let n=e.blocks.filter(n=>fc(n,e.msg,t)).map(e=>e.type===`tool`?pc(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 hc(e,t,n){return!t.trim()&&!n.trim()?[]:[{label:bc(e),lines:vc(qe(q(t),q(n)))}]}function gc(e,t){let n=q(e).split(`
|
|
80
|
+
`),r=q(t).split(`
|
|
81
|
+
`);return[`@@`,...n.map(e=>`- ${e}`),...r.map(e=>`+ ${e}`)].join(`
|
|
82
|
+
`)}function _c(e){let t=q(e),n=t.split(`
|
|
83
|
+
`);return t.endsWith(`
|
|
84
|
+
`)&&n.pop(),n}function vc(e){return e.flatMap(e=>{let t=e.added?`add`:e.removed?`remove`:`context`;return _c(e.value).map(e=>({type:t,text:e}))})}function yc(e){let t=W(e).edit;return Array.isArray(t)?t:t&&typeof t==`object`?[t]:[]}function bc(e){let t=e.trim();if(!t)return`edit`;let n=t.split(`/`).pop()||t;return n===t?n:`${n} · ${t}`}function xc(e,t){let n=yc(e.inputValue),r=bc(t);return n.map(e=>{let t=W(e),n=K(t.old),i=K(t.new);return!n.trim()&&!i.trim()?null:{label:r,lines:vc(qe(q(n),q(i)))}}).filter(e=>e!=null&&e.lines.length>0)}function Sc(e,t){let n=W(e.inputValue),r=Array.isArray(n.edits)?n.edits:[],i=bc(t),a=r.map(e=>{let t=W(e),n=K(t.oldText)||K(t.old),r=K(t.newText)||K(t.new);return!n.trim()&&!r.trim()?null:{label:i,lines:vc(qe(q(n),q(r)))}}).filter(e=>e!=null&&e.lines.length>0);if(a.length>0)return a;let o=W(e.metadataValue),s=K(o.patch)||K(o.diff);return s.trim()?[{label:i,lines:s.split(`
|
|
85
|
+
`).map(e=>({type:e.startsWith(`+`)?`add`:e.startsWith(`-`)?`remove`:`context`,text:e}))}]:[]}function Cc(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 wc(e,t){let n=W(W(e.metadataValue).display),r=Array.isArray(n.structuredPatch)?n.structuredPatch:[],i=K(n.filePath)||t;return r.map(e=>{let t=W(e),n=(Array.isArray(t.lines)?t.lines:[]).map(e=>typeof e==`string`?Cc(e):null).filter(e=>e!=null);return n.length===0?null:{label:bc(i),lines:n}}).filter(e=>e!=null)}function Tc(e){let t=K(W(e.metadataValue).diff);if(t.trim())return q(t);let n=yc(e.inputValue).map(e=>{let t=W(e),n=K(t.old),r=K(t.new);return!n.trim()&&!r.trim()?``:gc(n,r)}).filter(Boolean).join(`
|
|
86
|
+
|
|
87
|
+
`);return n.trim()?n:J(e)}var Ec={".bashrc":`bash`,".zshrc":`bash`,".profile":`bash`,dockerfile:`docker`,".env":`ini`},Dc={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 Oc(e){let t=e.split(`/`).pop()?.toLowerCase()??``;if(!t)return`text`;let n=Ec[t];if(n)return n;if(t.startsWith(`.env.`))return`ini`;let r=t.includes(`.`)?t.split(`.`).pop()??``:``;return r&&Dc[r]||`text`}function kc(e){return e.replace(/\n*<system-reminder>[\s\S]*$/i,``).trimEnd()}function Ac(e){let t=vs(e,!1)||ws(e);return t===`No output captured.`?t:kc(t.replace(/^<file>\s*/i,``).replace(/\s*<\/file>\s*$/i,``)).split(`
|
|
88
|
+
`).filter(e=>!/^\(End of file - total \d+ lines\)$/.test(e.trim())).map(e=>e.replace(/^\d+\|\s?/,``).replace(/^\s*\d+\t/,``)).join(`
|
|
89
|
+
`).trimEnd()||`No output captured.`}function jc(e){let t=W(e.inputValue);if(e.status===`completed`){let e=K(t.content);if(e.trim())return q(e)}return J(e)}function Mc(e){return{...e.defaultStrategy,Icon:e.Icon,title:e.title,secondaryText:e.displayPath||void 0,details:e.details??e.defaultStrategy.details,showInputPreview:!1,outputContent:e.outputContent}}function Nc(e){return Mc({...e,Icon:dn,title:`read`,outputContent:e.outputContent??{kind:`plain`,text:e.text??Ac(e.state.outputValue),language:Oc(e.filePath),isCode:e.isCode??!0}})}function Pc(e){return Mc({...e,Icon:e.Icon??Bn,title:`write`,outputContent:{kind:`plain`,text:jc(e.state),language:Oc(e.filePath),isCode:e.isCode??e.state.status===`completed`}})}function Fc(e){return Mc({...e,Icon:Tn,title:`edit`})}function Ic(e,t,n){let r=Ps(t.command||t.inputText||`{}`,n).replace(/\s+/g,` `).trim(),i=r.length>72?`${r.slice(0,72)}...`:r,a=ms(t.outputValue);return{Icon:qn,title:Cs(e),secondaryText:i?`(${i})`:void 0,details:[],expandable:!0,showInputPreview:!0,outputContent:a??{kind:`plain`,text:J(t),language:`text`,isCode:!1}}}function Lc(e,t,n,r){let i=Ps(G(W(t.inputValue).name),r);return{...n,Icon:$n,title:G(e.tool)||`skill`,secondaryText:i||void 0,expandable:!1,showInputPreview:!1}}function Rc(e){let t=new Map;return{tasks:e.map(e=>{let n=W(e),r=K(n.status),i=r===`completed`||r===`in_progress`||r===`error`?r:`pending`;return t.set(i,(t.get(i)??0)+1),{label:K(n.content)||K(n.subject)||`Untitled task`,status:i,detail:K(n.activeForm)||K(n.description)||void 0}}),summary:[...t.entries()].map(([e,t])=>`${t} ${e}`).join(` · `)}}function zc(e,t){let n=[...t.matchAll(/"([^"]+)"="([^"]+)"/g)],r=new Map(n.map(e=>[e[1],[e[2]]]));return(Array.isArray(e.questions)?e.questions:[]).flatMap(e=>{let t=W(e),n=K(t.question);if(!n)return[];let i=(Array.isArray(t.options)?t.options:[]).flatMap(e=>{let t=W(e),n=K(t.label);if(!n)return[];let r=n.replace(/\s*\(Recommended\)\s*$/i,``);return[{label:r,description:K(t.description)||void 0,recommended:r!==n||void 0}]});return[{header:K(t.header)||void 0,question:n,options:i,answers:r.get(n)??[]}]})}function Bc(e){return e.tool.trim().toLowerCase()}function Vc(e){return typeof e==`string`?e.trim():typeof e==`number`||typeof e==`boolean`?String(e):``}function Hc(e,t){let n=J(t),r=K(W(ls(n)).message)||n;return[{label:`Recipient`,value:K(e.recipient)||K(e.to)},{label:`Summary`,value:K(e.summary)},{label:`Message`,value:K(e.message)||K(e.content)},{label:`Delivery`,value:r}].filter(e=>e.value&&e.value!==`No output captured.`)}function Uc(e,t,n){let r=Ic(e,t,n),i=Bc(e),a=W(t.inputValue),o=Ns(t.inputValue),s=Y(o,n);if(i===`read`)return Nc({defaultStrategy:r,state:t,filePath:o,displayPath:s,outputContent:ms(t.outputValue)});if(i===`edit`){let e=K(a.old_string),n=K(a.new_string),i=hc(s||o,e,n);return Fc({defaultStrategy:r,displayPath:s,outputContent:i.length>0?{kind:`structured-diff`,blocks:i}:{kind:`plain`,text:J(t),language:`text`,isCode:!1}})}if(i===`write`)return Pc({defaultStrategy:r,state:t,filePath:o,displayPath:s,isCode:!0});if(i===`bash`||i===`workflow`){let e=K(a.command)||K(a.script),o=K(a.description),s=Ps(e,n);return{...r,Icon:qn,title:i===`workflow`?`workflow`:`bash`,secondaryText:o||us(s).slice(0,120)||void 0,details:e?[{label:i===`workflow`?`Script`:`Command`,value:s}]:[],showInputPreview:!1,contentLabel:t.status===`error`?`Error`:`Terminal output`,outputContent:{kind:`plain`,text:J(t),language:`text`,isCode:!1}}}if(i===`todowrite`||i===`taskcreate`){let e=Rc(i===`todowrite`?Array.isArray(a.todos)?a.todos:[]:[a]);return{...r,Icon:Mn,title:i===`todowrite`?`tasks`:`create task`,secondaryText:e.summary||void 0,details:[],showInputPreview:!1,contentLabel:`Task state`,outputContent:{kind:`task-list`,items:e.tasks}}}if(i===`taskupdate`||i===`tasklist`){let e=ms(i===`taskupdate`?a:t.outputValue);return{...r,Icon:Mn,title:i===`taskupdate`?`update task`:`list tasks`,secondaryText:K(a.taskId)||K(a.status)||void 0,details:[],showInputPreview:!1,contentLabel:`Task state`,outputContent:e??{kind:`plain`,text:J(t),language:`text`,isCode:!1}}}if(i===`agent`){let e=K(a.subagent_type)||K(a.name),n=K(a.description);return{...r,Icon:fn,title:e?`agent · ${e}`:`agent`,secondaryText:n||void 0,details:[K(a.model)?{label:`Model`,value:K(a.model)}:null,a.run_in_background===!0?{label:`Mode`,value:`Background`}:null].filter(e=>e!=null),showInputPreview:!1,contentLabel:`Agent result`,outputContent:{kind:`plain`,text:J(t),language:`markdown`,isCode:!1}}}if(i===`askuserquestion`){let e=zc(a,J(t));return{...r,Icon:Sn,title:`ask`,secondaryText:e.length?`${e.length} question${e.length===1?``:`s`}`:void 0,details:[],showInputPreview:!1,contentLabel:`Questions`,outputContent:e.length?{kind:`question-list`,questions:e}:{kind:`plain`,text:J(t),language:`text`,isCode:!1}}}if(i===`websearch`||i===`webfetch`){let e=K(a.query),n=K(a.url);return{...r,Icon:Dn,title:i===`websearch`?`web search`:`web fetch`,secondaryText:e||n||void 0,details:[],showInputPreview:!1,contentLabel:`Results`,outputContent:{kind:`plain`,text:J(t),language:`markdown`,isCode:!1}}}if(i===`toolsearch`)return{...r,Icon:Kn,title:`find tools`,secondaryText:K(a.query)||void 0,details:[],showInputPreview:!1,contentLabel:`Matches`};if(i===`skill`)return{...r,Icon:$n,title:`skill`,secondaryText:K(a.skill)||void 0,details:[],showInputPreview:!1,contentLabel:`Result`};if(i===`structuredoutput`||i===`reportfindings`)return{...r,Icon:Mn,title:i===`reportfindings`?`report findings`:`structured output`,secondaryText:`${Object.keys(a).length} fields`,details:[],showInputPreview:!1,contentLabel:`Submitted fields`,outputContent:{kind:`property-list`,items:Object.entries(a).map(([e,t])=>({label:e,value:t}))}};if(i.startsWith(`mcp__claude-in-chrome__`)){let e=i.replace(`mcp__claude-in-chrome__`,``).replaceAll(`_`,` `),t=K(a.url),n=K(a.action)||K(a.query),o=Vc(a.tabId);return{...r,Icon:Un,title:`browser · ${e}`,secondaryText:t||n||void 0,details:o?[{label:`Tab`,value:o}]:[],showInputPreview:!1,contentLabel:`Browser result`}}if(i===`sendmessage`){let e=K(a.recipient)||K(a.to);return{...r,Icon:Fn,title:`send message`,secondaryText:e||void 0,details:[],showInputPreview:!1,contentLabel:`Message details`,outputContent:{kind:`property-list`,items:Hc(a,t)}}}return{...r,title:Cs(e)}}function Wc(e,t,n){let r=Ic(e,t,n),i=e.tool.toLowerCase(),a=W(t.inputValue),o=Ns(t.inputValue),s=Y(o,n);if(i===`glob`){let n=G(a.pattern);return{...r,Icon:Dn,title:e.tool||`glob`,secondaryText:n||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:J(t),language:`text`,isCode:!1}}}if(i===`grep`){let i=G(a.path),o=G(a.pattern),s=[Y(i,n),o].filter(Boolean).join(` · `);return{...r,Icon:Dn,title:e.tool||`grep`,secondaryText:s||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:J(t),language:`text`,isCode:!1}}}if(i===`bash`){let i=G(a.description),o=Ps(G(a.command),n),s=i?`${i}${o?` (${o})`:``}`:o?`(${o})`:void 0;return{...r,Icon:qn,title:e.tool||`bash`,secondaryText:s,showInputPreview:!1,outputContent:{kind:`plain`,text:J(t),language:`text`,isCode:!1}}}return i===`read`?Nc({defaultStrategy:r,state:t,filePath:o,displayPath:s}):i===`edit`?Fc({defaultStrategy:r,displayPath:s,outputContent:{kind:`plain`,text:Tc(t),language:`diff`,isCode:!0}}):i===`write`?Pc({defaultStrategy:r,state:t,filePath:o,displayPath:s}):i===`skill`?Lc(e,t,r,n):r}function Gc(e,t,n){let r=Ic(e,t,n),i=e.tool.toLowerCase(),a=W(t.inputValue),o=Ns(t.inputValue),s=Y(o,n);if(i===`glob`){let n=G(a.pattern);return{...r,Icon:Dn,title:e.title||`glob`,secondaryText:n||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:J(t),language:`text`,isCode:!1}}}if(i===`grep`){let i=G(a.path),o=G(a.pattern),s=[Y(i,n),o].filter(Boolean).join(` · `);return{...r,Icon:Dn,title:e.title||`grep`,secondaryText:s||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:J(t),language:`text`,isCode:!1}}}if(i===`shell`){let i=Ps(G(a.command),n);return{...r,Icon:qn,title:e.title||`bash`,secondaryText:i?`(${i})`:void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:J(t),language:`text`,isCode:!1}}}if(i===`readfile`)return Nc({defaultStrategy:r,state:t,filePath:o,displayPath:s});if(i===`strreplacefile`){let e=xc(t,s||o);return Fc({defaultStrategy:r,displayPath:s,outputContent:e.length>0?{kind:`structured-diff`,blocks:e}:{kind:`plain`,text:Tc(t),language:`diff`,isCode:!0}})}return i===`writefile`?Pc({defaultStrategy:r,state:t,filePath:o,displayPath:s}):r}function X(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Z(e){return typeof e==`string`?e.trim():``}function Kc(e){return typeof e==`string`?e:``}function qc(e){return typeof e==`string`?e.trim():typeof e==`number`||typeof e==`bigint`||typeof e==`boolean`?`${e}`:``}function Jc(e){return e.replace(/\\n/g,`
|
|
90
|
+
`)}function Yc(e){return e.replace(/\s*\(Recommended\)\s*$/i,``).trim()}function Xc(e){let t=e.trim();return{label:Yc(t),recommended:/\(Recommended\)\s*$/i.test(t)}}function Zc(e){return e.replace(/\s+/g,` `).trim()}function Qc(e,t=88){let n=Zc(e);return n?n.length>t?`${n.slice(0,t)}...`:n:``}function $c(e,t){return Qc([`${t} questions`,...e.filter(Boolean).slice(0,2)].join(` · `),96)}function el(e){try{return JSON.parse(e)}catch{return null}}function tl(e){let t=Jc(e).split(`
|
|
91
|
+
`);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(`
|
|
92
|
+
`);return r.trim()?r:e}function nl(e,t,n){n.trim()&&e.push({label:t,value:n})}function rl(e){return e.startsWith(`"`)&&e.endsWith(`"`)||e.startsWith(`'`)&&e.endsWith(`'`)?e.slice(1,-1):e}function il(e){return e.trim()?!/[|&;<>()$`*?{}[\]\\]/.test(e):!1}function al(e){let t=rl(e.trim());return il(t)?t:null}function ol(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 al(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 al(n[1]||``)}return null}function sl(e){let t=e.split(`
|
|
93
|
+
`),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(`
|
|
94
|
+
`)}function cl(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 ll(e){let t=e.trim();return!t||cl(t)?null:(t.startsWith(`{`)||t.startsWith(`[`))&&el(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 ul(e,t,n){let r=tl(t),i=ol(e);if(i){let e=n(i);return{text:sl(r),language:e,isCode:e!==`text`,sourcePath:i,confidence:`path`}}let a=ll(r);return a?{text:r,language:a,isCode:!0,confidence:`content`}:{text:r,language:`text`,isCode:!1,confidence:`plain`}}function dl(e,t,n,r=e=>e,i=e=>e){let a=X(e),o=Z(a.cmd),s=Z(a.workdir),c=Z(a.sandbox_permissions),l=Z(a.justification),u=i(o),d=[];nl(d,`Command`,u),nl(d,`Workdir`,r(s)),nl(d,`Escalation`,c),nl(d,`Justification`,l);let f=Qc(u);return{secondaryText:l?[l,f].filter(Boolean).join(`
|
|
95
|
+
`):f||void 0,details:d,outputAnalysis:ul(o,t,n)}}function fl(e,t,n){let r=X(e),i=qc(r.session_id),a=Kc(r.chars),o=a?`stdin`:`poll`,s=[];return nl(s,`Session`,i),s.push({label:`Chars`,value:a||`(empty)`}),{secondaryText:i?`session #${i} · ${o}`:o,details:s,outputAnalysis:ul(``,t,n)}}function pl(e,t){let n=X(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=X(el(t)?.answers),a=r.map(e=>{let t=X(e),n=Z(t.id),r=X(i[n]),a=(Array.isArray(r.answers)?r.answers:[]).map(e=>typeof e==`string`?Yc(e):``).filter(Boolean),o=Array.isArray(t.options)?t.options.map(e=>{let t=X(e),n=Xc(Z(t.label));return n.label?{label:n.label,description:Z(t.description)||void 0,recommended:n.recommended||void 0}:null}).filter(e=>e!=null):[],s=Z(t.question);return s?{header:Z(t.header)||void 0,question:s,options:o,answers:a}:null}).filter(e=>e!=null);return a.length===0?{secondaryText:void 0,details:[],outputContent:{kind:`plain`,text:t,language:`text`,isCode:!1}}:{secondaryText:$c(a.map(e=>e.header||``),a.length),details:[],outputContent:{kind:`question-list`,questions:a}}}function ml(e){let t=X(e),n=Z(t.explanation),r=Array.isArray(t.plan)?t.plan:[],i=new Map,a=r.map(e=>{let t=X(e),n=Z(t.status)||`pending`,r=Z(t.step)||Z(t.content);return i.set(n,(i.get(n)??0)+1),{label:r||`(empty step)`,status:n===`completed`||n===`in_progress`||n===`error`?n:`pending`}}),o=[...i.entries()].map(([e,t])=>({label:e,value:String(t)}));return{secondaryText:n||[...i.entries()].map(([e,t])=>`${t} ${e}`).join(` · `)||void 0,details:o,items:a}}function hl(e,t){return e.map(e=>Z(X(e)[t])).filter(Boolean).join(` · `)}function gl(e){let t=X(e);return Array.isArray(t.search_query)?{title:`web search`,secondaryText:hl(t.search_query,`q`)||void 0}:Array.isArray(t.open)?{title:`web open`,secondaryText:hl(t.open,`ref_id`)||void 0}:{title:`web ${Object.keys(t)[0]||`run`}`,secondaryText:void 0}}function _l(e,t){let n=X(e),r=Z(n.path),i=Z(n.detail),a=r?t(r):``,o=[];return nl(o,`Image`,a),nl(o,`Detail`,i),{secondaryText:a||void 0,details:o}}function vl(e){return e.replace(/^_+/,``).replaceAll(`_`,` `)}function yl(e){for(let t of[`title`,`summary`,`query`,`q`,`url`,`objective`,`target`,`threadId`]){let n=us(e[t]);if(n)return n.length>120?`${n.slice(0,120)}…`:n}return``}function bl(e){let t=e.indexOf(`Output:
|
|
96
|
+
`);if(t===-1)return e;let n=ds(e.slice(t+8).trim());return Array.isArray(n)&&n.map(e=>G(W(e).text)).filter(Boolean).join(`
|
|
97
|
+
`)||e}function xl(e){let t=W(e.state.input);return[us(t.agent_type),[us(t.model),us(t.reasoning_effort)].filter(Boolean).join(`-`)].filter(Boolean).join(` `)}function Sl(e){return us(W(e.state.metadata).prompt)||us(W(e.state.input).message)||``}function Cl(e,t,n){let r=Ic(e,t,n),i=Ss(e),a=G(W(t.metadataValue).namespace),o=e=>Y(e,n),s=e=>Ps(e,n);if(i===`skill`)return Lc(e,t,r,n);if(i===`js`&&(a===`mcp__node_repl__`||a===`mcp__node_repl__.js`)){let e=G(W(t.inputValue).title);return{...r,Icon:qn,title:`Browser`,secondaryText:e||void 0,details:[],showInputPreview:!1,outputContent:{kind:`plain`,text:bl(J(t)),language:`text`,isCode:!1}}}if(i===`exec_command`||i===`bash`){let e=dl(t.inputValue,J(t),Oc,o,s);return{...r,Icon:qn,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=fl(t.inputValue,J(t),Oc);return{...r,Icon:qn,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=pl(t.inputValue,J(t));return{...r,Icon:Sn,title:`ask`,secondaryText:e.secondaryText,details:e.details,showInputPreview:!1,outputContent:e.outputContent}}if(i===`patch`){let n=ns(t.inputValue),i=is(n);return{...r,Icon:Tn,title:Cs(e,`patch`),secondaryText:i||void 0,details:[],showInputPreview:!1,outputContent:ss(n,J(t),Oc,o)}}if(i===`update_plan`){let e=ml(t.inputValue);return{...r,Icon:Mn,title:`update plan`,secondaryText:e.secondaryText,details:e.details,showInputPreview:!1,contentLabel:`Plan`,outputContent:{kind:`task-list`,items:e.items}}}if(i===`web__run`){let e=gl(t.inputValue);return{...r,Icon:Dn,title:e.title,secondaryText:e.secondaryText,details:[],showInputPreview:!1,outputContent:{kind:`plain`,text:J(t),language:`markdown`,isCode:!1}}}if(i===`view_image`){let e=_l(t.inputValue,o);return{...r,Icon:An,title:`view image`,secondaryText:e.secondaryText,details:e.details,showInputPreview:!1,outputContent:{kind:`plain`,text:J(t),language:`text`,isCode:!1}}}if(i===`subagent`){let n=Sl(e),i=J(t);return{...r,Icon:fn,title:xl(e)||Cs(e,`subagent`),secondaryText:void 0,details:[],showInputPreview:!1,outputContent:{kind:`plain`,text:n||i,language:`markdown`,isCode:!1}}}if(i===`collaboration.send_message`||i===`collaboration.followup_task`){let e=W(t.inputValue),n=G(e.target),a=G(e.message);return{...r,Icon:Fn,title:i.endsWith(`followup_task`)?`follow up with agent`:`message agent`,secondaryText:n||void 0,details:[],showInputPreview:!1,contentLabel:`Message`,outputContent:{kind:`property-list`,items:[n?{label:`Recipient`,value:n}:null,a?{label:`Message`,value:a}:null].filter(e=>e!=null)}}}if(i===`collaboration.wait_agent`||i===`wait`){let e=W(t.inputValue).timeout_ms;return{...r,Icon:Cn,title:`wait for agents`,secondaryText:typeof e==`number`?`${Math.round(e/1e3)}s timeout`:void 0,details:[],showInputPreview:!1,contentLabel:`Agent updates`}}if(i===`collaboration.list_agents`)return{...r,Icon:Qn,title:`list agents`,secondaryText:void 0,details:[],showInputPreview:!1,contentLabel:`Agent tree`};if(i===`collaboration.interrupt_agent`){let e=G(W(t.inputValue).target);return{...r,Icon:Qn,title:`interrupt agent`,secondaryText:e||void 0,details:[],showInputPreview:!1,contentLabel:`Result`}}if(i===`create_goal`||i===`get_goal`||i===`update_goal`){let e=W(t.inputValue);return{...r,Icon:Xn,title:vl(i),secondaryText:G(e.objective)||G(e.status)||void 0,details:[],showInputPreview:!1,contentLabel:`Goal state`}}if(a.startsWith(`mcp__`)||i.includes(`._`)){let e=W(t.inputValue),[n,a=`tool`]=i.split(`.`,2),o=Object.entries(e).map(([e,t])=>({label:e,value:t})),s=ms(t.outputValue);return{...r,Icon:Gn,title:`${vl(n??`integration`)} · ${vl(a)}`,secondaryText:yl(e)||void 0,details:[],showInputPreview:!1,contentLabel:s?`Result`:`Request`,outputContent:s??(o.length>0?{kind:`property-list`,items:o}:r.outputContent)}}return r}function wl(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:typeof e==`string`&&ds(e)||{}}function Tl(e){let t=K(wl(e).contents);return t?q(t):`No output captured.`}function El(e){let t=wl(e),n=Array.isArray(t.directories)?t.directories:[];if(n.length===0)return ws(e);let r=n.flatMap(e=>{let t=W(e);return[G(t.absPath),...(Array.isArray(t.files)?t.files:[]).map(e=>{let t=W(e);return G(t.relPath)||G(t.absPath)}).filter(Boolean).map(e=>` ${e}`)].filter(Boolean)});return r.length>0?r.join(`
|
|
98
|
+
`):`No output captured.`}function Dl(e,t,n){let r=Ic(e,t,n),i=e.tool.toLowerCase(),a=W(t.inputValue),o=Ns(t.inputValue),s=Y(o,n);if(i===`read_file_v2`){let e=Tl(t.outputValue);return Nc({defaultStrategy:r,state:t,filePath:o,displayPath:s,text:e,details:e===`No output captured.`?[{label:`Lines`,value:G(wl(t.outputValue).totalLinesInFile)}]:[],isCode:e!==`No output captured.`})}if(i===`edit_file_v2`){let e=q(K(a.streamingContent));return Fc({defaultStrategy:r,displayPath:s,outputContent:{kind:`plain`,text:e||J(t),language:e?`diff`:`text`,isCode:!!e}})}if(i===`ripgrep_raw_search`){let e=G(a.pattern),i=[Y(G(a.path),n),e].filter(Boolean).join(` · `);return{...r,Icon:Dn,title:`grep`,secondaryText:i||void 0,details:[],showInputPreview:!1,outputContent:{kind:`plain`,text:J(t),language:`text`,isCode:!1}}}if(i===`glob_file_search`){let e=G(a.globPattern),i=[Y(G(a.targetDirectory),n),e].filter(Boolean).join(` · `);return{...r,Icon:Dn,title:`glob`,secondaryText:i||void 0,details:[],showInputPreview:!1,outputContent:{kind:`plain`,text:El(t.outputValue),language:`text`,isCode:!1}}}if(i===`run_terminal_command_v2`){let e=Ps(G(a.command),n),i=G(a.commandDescription),o=i?`${i}${e?` (${e})`:``}`:e?`(${e})`:void 0;return{...r,Icon:qn,title:`bash`,secondaryText:o,details:[],showInputPreview:!1,outputContent:{kind:`plain`,text:J(t),language:`text`,isCode:!1}}}return{...r,title:Cs(e)}}function Ol(e){let t=W(e.inputValue),n=W(e.metadataValue),r=Array.isArray(n.tasks)?n.tasks:[],i=Number(t.id);return W(Number.isFinite(i)&&i>0?r.find(e=>Number(W(e).id)===i):r.at(-1))}function kl(e){let t=J(e).match(/\(([^()]+?)\s*→\s*([^()]+?)\)/);return t?`${t[1]} -> ${t[2]}`:``}function Al(e){let t=(e.split(`
|
|
99
|
+
`)[0]??``).match(/^Agent:\s*(.+)$/i),n=e.split(`
|
|
100
|
+
`).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 jl(e,t,n){let r=Ic(e,t,n),i=e.tool.toLowerCase(),a=W(t.inputValue),o=W(t.metadataValue),s=Ns(t.inputValue),c=Y(s,n);if(i===`todo`){let e=G(a.action)||G(o.action)||`todo`,n=Ol(t),i=Number(n.id)||Number(a.id),s=G(n.subject)||G(a.subject),c=G(n.description)||G(a.description),l=G(n.status)||G(a.status),u=kl(t),d=[i?`#${i}`:``,s,e===`update`&&u?u:l].filter(Boolean);return{...r,Icon:Mn,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||J(t),language:`markdown`,isCode:!1}}}if(i===`read`)return Nc({defaultStrategy:r,state:t,filePath:s,displayPath:c});if(i===`write`)return Pc({defaultStrategy:r,state:t,filePath:s,displayPath:c,Icon:En});if(i===`edit`){let e=Sc(t,c||s),n=typeof o.firstChangedLine==`number`?String(o.firstChangedLine):K(o.firstChangedLine);return Fc({defaultStrategy:r,displayPath:c,details:n?[{label:`Line`,value:n}]:[],outputContent:e.length>0?{kind:`structured-diff`,blocks:e}:{kind:`plain`,text:J(t),language:`text`,isCode:!1}})}if(i===`agent`){let e=G(a.description)||G(o.description),n=G(a.subagent_type)||G(o.subagentType),i=G(o.agentId),s=G(o.status);return{...r,Icon:fn,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:K(a.prompt)||J(t),language:`markdown`,isCode:!1}}}if(i===`get_subagent_result`){let e=G(a.agent_id),n=J(t);return{...r,Icon:fn,title:`subagent result`,secondaryText:e?`#${e}`:void 0,details:Al(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=>K(e)).filter(Boolean):[],i=K(a.question);return{...r,Icon:An,title:`analyze image`,secondaryText:e.map(e=>Y(e,n)).join(`, `),details:[...e.map((e,t)=>({label:t===0?`Image`:`Image ${t+1}`,value:Y(e,n)})),i?{label:`Question`,value:i}:null].filter(e=>e!=null),showInputPreview:!1,outputContent:{kind:`plain`,text:J(t),language:`markdown`,isCode:!1}}}if(i===`bash`||i===`batch`){let e=Ps(G(a.command),n);return{...r,Icon:qn,title:i===`batch`?`batch`:`bash`,secondaryText:e?`(${e})`:void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:J(t),language:`text`,isCode:!1}}}return r}function Ml(e){return e.replace(/\s*[((](?:Recommended|推荐)[))]\s*$/i,``).trim()}function Nl(e){let t=new Map;return{text:e.map(e=>{let n=W(e),r=G(n.status)||`pending`,i=G(n.priority),a=G(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(`
|
|
101
|
+
`)||`No todos captured.`,summary:[...t.entries()].map(([e,t])=>`${t} ${e}`).join(` · `),details:[...t.entries()].map(([e,t])=>({label:e,value:String(t)}))}}function Pl(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,[Ml(r)])}return t}function Fl(e,t){let n=W(e),r=Array.isArray(n.questions)?n.questions:[],i=Pl(t),a=r.map(e=>{let t=W(e),n=G(t.question);if(!n)return null;let r=Array.isArray(t.options)?t.options.map(e=>{let t=W(e),n=G(t.label),r=Ml(n);return r?{label:r,description:G(t.description)||void 0,recommended:r!==n.trim()||void 0}:null}).filter(e=>e!=null):[];return{header:G(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 Il(e,t,n){let r=Ic(e,t,n),i=Ss(e),a=W(t.inputValue),o=W(t.metadataValue),s=Ns(t.inputValue),c=Y(s,n),l=J(t);if(i===`bash`){let e=G(a.description),t=G(a.command),i=Ps(t,n),o=l===`(Bash completed with no output)`?`No output captured.`:l;return{...r,Icon:qn,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 Nc({defaultStrategy:r,state:t,filePath:s,displayPath:c});if(i===`edit`){let e=wc(t,c||s),n=K(a.old_string),i=K(a.new_string),u=hc(c||s,n,i),d=e.length>0?e:u,f=W(o.display);return Fc({defaultStrategy:r,displayPath:c,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),outputContent:d.length>0?{kind:`structured-diff`,blocks:d}:{kind:`plain`,text:l,language:`text`,isCode:!1}})}if(i===`write`)return Pc({defaultStrategy:r,state:t,filePath:s,displayPath:c,Icon:En});if(i===`glob`||i===`grep`){let e=G(a.path),t=G(a.pattern),o=[Y(e,n),t].filter(Boolean).join(` · `);return{...r,Icon:Dn,title:i,secondaryText:o||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:l,language:`text`,isCode:!1}}}if(i===`todowrite`){let e=Nl(Array.isArray(a.todos)?a.todos:[]);return{...r,Icon:Mn,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=G(a.subagent_type),t=G(a.description);return{...r,Icon:fn,title:e?`agent · ${e}`:`agent`,secondaryText:t||void 0,details:e?[{label:`Type`,value:e}]:[],showInputPreview:!1,outputContent:{kind:`plain`,text:l,language:`markdown`,isCode:!1}}}if(i===`askuserquestion`){let e=Fl(t.inputValue,l);return{...r,Icon:Sn,title:`ask`,secondaryText:e.secondaryText,details:[],showInputPreview:!1,outputContent:e.outputContent}}if(i===`enterplanmode`||i===`exitplanmode`){let e=K(a.plan);return{...r,Icon:Mn,title:i===`enterplanmode`?`plan mode`:`plan approved`,secondaryText:e.split(`
|
|
102
|
+
`).find(e=>e.trim())?.replace(/^#+\s*/,``)||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:e||l,language:`markdown`,isCode:!1}}}if(i===`websearch`){let e=G(a.query);return{...r,Icon:Dn,title:`web search`,secondaryText:e||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:l,language:`markdown`,isCode:!1}}}if(i===`skill`){let e=G(a.skill);return{...r,Icon:$n,title:`skill`,secondaryText:e||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:l,language:`markdown`,isCode:!1}}}return r}var Ll={claudecode:Uc,opencode:Wc,kimi:Gc,codex:Cl,cursor:Dl,pi:jl,zcode:Il};function Rl(e,t,n,r){return(Ll[e.toLowerCase()]??Ic)(t,n,r)}function zl(e,t){let n=0;return e.map(e=>{if(e.type!==`tool`)return e;let r=e.parts.map(()=>Bs(t,n++));return{...e,anchorIds:r}})}function Bl(e){let t=[];for(let n of e){let e=Zo(n.parts);if(e.length===0)continue;let r=t.length;t.push({msg:n,blocks:zl(e,r),index:r})}return t}function Vl({messages:e,agentName:t,fileActivity:n}){let r=Bl(Ds(e,t)),i=uc(r),a=Us(r);return{messages:r,toc:i,fileChangeSummary:Ws(n,a.summary),select(e){let t=mc(r,e),n=new Map(t.map((e,t)=>[e.index,t]));return{messages:t,timelineEntries:$s(t),resolveListIndex(e){return n.get(e)}}},resolveMessageIndex(e){return a.anchorMessageIndexes.get(e)}}}function Hl({open:e,children:t,className:n}){return(0,L.jsx)(`div`,{className:io(`motion-collapsible`,n),"data-open":e||void 0,children:(0,L.jsx)(`div`,{className:`motion-collapsible-inner`,children:e?t():null})})}function Ul(e){return e===0?`auto`:`smooth`}function Wl(e,t){return e===`smooth`&&t?`auto`:e}function Gl(e){return e.read.length+e.edit.length+e.write.length+e.delete.length}function Kl({summary:e,baseDirectory:t,onJumpToAnchor:n}){let r=[{key:`read`,label:`Read`,Icon:Dn,items:e.read},{key:`edit`,label:`Edit`,Icon:Tn,items:e.edit},{key:`write`,label:`Write`,Icon:Bn,items:e.write},{key:`delete`,label:`Delete`,Icon:tr,items:e.delete}].filter(e=>e.items.length>0);return r.length===0?null:(0,L.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[var(--console-border)] px-4 py-3`,children:[(0,L.jsx)(On,{className:`size-3.5 text-[var(--console-accent)]`}),(0,L.jsx)(`span`,{className:`console-mono text-xs font-semibold uppercase tracking-[0.16em] text-[var(--console-text)]`,children:`File Tracker`})]}),(0,L.jsx)(`div`,{className:`space-y-3 p-3`,children:r.map(({key:e,label:r,Icon:i,items:a})=>(0,L.jsx)(ql,{label:r,Icon:i,items:a,baseDirectory:t,onJumpToAnchor:n},e))})]})}function ql({label:e,Icon:t,items:n,baseDirectory:r,onJumpToAnchor:i}){let[a,o]=(0,P.useState)(!1);return(0,L.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-sunken)]`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:`motion-hover flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-[var(--console-surface-muted)]`,children:[(0,L.jsx)(t,{className:`size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,L.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,L.jsx)(`span`,{className:`console-mono shrink-0 text-[10px] text-[var(--console-muted)]`,children:n.length}),(0,L.jsx)(gn,{className:`motion-chevron size-3.5 shrink-0 text-[var(--console-muted)]`,"data-open":a||void 0})]}),(0,L.jsx)(Hl,{open:a,children:()=>(0,L.jsx)(`div`,{className:`space-y-1 border-t border-[var(--console-border)] p-2`,children:n.map(e=>(0,L.jsx)(Jl,{item:e,baseDirectory:r,onJumpToAnchor:i},`${e.path}:${e.latestAnchorId||e.latestTime}`))})})]})}function Jl({item:e,baseDirectory:t,onJumpToAnchor:n}){let[r,i]=(0,P.useState)(0);function a(t,r){let a=e.anchors.length;if(a===0)return;let o=(t%a+a)%a;i(o);let s=e.anchors[o];s&&n(s.anchorId,r)}return(0,L.jsxs)(`div`,{className:`flex items-start gap-2 rounded-sm px-2 py-2 motion-hover hover:bg-[var(--console-surface-muted)]`,children:[(0,L.jsx)(`button`,{type:`button`,title:e.path,onClick:e=>a(r,Ul(e.detail)),className:`min-w-0 flex-1 text-left`,children:(0,L.jsx)(`span`,{className:`console-mono block break-all text-xs text-[var(--console-text)]`,children:Fs(e.path,t)})}),e.anchors.length>1?(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,L.jsx)(`button`,{type:`button`,"aria-label":`Previous ${e.path}`,onClick:e=>a(r-1,Ul(e.detail)),className:`rounded-sm border border-[var(--console-border)] p-1 text-[var(--console-muted)] motion-hover hover:bg-[var(--console-surface)]`,children:(0,L.jsx)(yn,{className:`size-3`})}),(0,L.jsxs)(`span`,{className:`console-mono text-[10px] text-[var(--console-muted)]`,children:[r+1,`/`,e.anchors.length]}),(0,L.jsx)(`button`,{type:`button`,"aria-label":`Next ${e.path}`,onClick:e=>a(r+1,Ul(e.detail)),className:`rounded-sm border border-[var(--console-border)] p-1 text-[var(--console-muted)] motion-hover hover:bg-[var(--console-surface)]`,children:(0,L.jsx)(gn,{className:`size-3`})})]}):(0,L.jsx)(`button`,{type:`button`,title:`Jump to tool call`,onClick:e=>a(0,Ul(e.detail)),className:`console-mono shrink-0 text-[10px] text-[var(--console-muted)]`,children:e.count})]})}var Yl=[{id:`user`,label:`User`},{id:`agent_message`,label:`Agent Responses`},{id:`thinking`,label:`Thinking`},{id:`plan`,label:`Plans`},{id:`tools_all`,label:`Tools`}];function Xl(e){return e.tools.map(e=>e.id)}function Zl(e,t,n){let r=new Set(e),i=Xl(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 Ql({checked:e,indeterminate:t=!1,onChange:n}){let r=(0,P.useRef)(null);return(0,P.useLayoutEffect)(()=>{r.current&&(r.current.indeterminate=t)},[t]),(0,L.jsxs)(`span`,{className:`relative mt-0.5 size-3.5 shrink-0`,children:[(0,L.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,L.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 dark:text-[var(--console-bg)]`:`border-[var(--console-border-strong)] bg-[var(--console-surface)] text-transparent`}`,children:t?(0,L.jsx)(In,{className:`size-2.5 stroke-[3]`}):e?(0,L.jsx)(mn,{className:`size-2.5 stroke-[3]`}):null})]})}function $l({toc:e,fileChangeSummary:t,baseDirectory:n,selectedFilters:r,onToggle:i,onJumpToAnchor:a}){return(0,L.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,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsx)(eu,{toc:e,selectedFilters:r,onToggle:i}),(0,L.jsx)(Kl,{summary:t,baseDirectory:n,onJumpToAnchor:a})]})})}function eu({toc:e,selectedFilters:t,onToggle:n}){let r=Xl(e),i=r.filter(e=>t.has(e)).length,a=r.length>0&&i===r.length,o=i>0&&i<r.length;return(0,L.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[var(--console-border)] px-4 py-3`,children:[(0,L.jsx)(kn,{className:`size-3.5 text-[var(--console-accent)]`}),(0,L.jsx)(`span`,{className:`console-mono text-xs font-semibold uppercase tracking-[0.16em] text-[var(--console-text)]`,children:`Session TOC`})]}),(0,L.jsxs)(`div`,{className:`space-y-1 p-3`,children:[Yl.filter(({id:t})=>e.counts[t]>0).map(({id:r,label:i})=>(0,L.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-sm px-2 py-2 motion-hover hover:bg-[var(--console-surface-muted)]`,children:[(0,L.jsx)(Ql,{checked:r===`tools_all`?a:t.has(r),indeterminate:r===`tools_all`&&o,onChange:()=>n(r)}),(0,L.jsx)(`span`,{className:`console-mono min-w-0 flex-1 break-all text-xs leading-relaxed text-[var(--console-text)]`,children:i}),(0,L.jsx)(`span`,{className:`console-mono shrink-0 text-[11px] text-[var(--console-muted)]`,children:e.counts[r]})]},r)),e.tools.length>0?(0,L.jsx)(`div`,{className:`space-y-1 border-t border-[var(--console-border)] pt-2`,children:e.tools.map(e=>(0,L.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-sm px-2 py-2 motion-hover hover:bg-[var(--console-surface-muted)]`,children:[(0,L.jsx)(Ql,{checked:t.has(e.id),onChange:()=>n(e.id)}),(0,L.jsx)(`span`,{className:`console-mono min-w-0 flex-1 break-all text-xs leading-relaxed text-[var(--console-text)]`,children:e.label}),(0,L.jsx)(`span`,{className:`console-mono shrink-0 text-[11px] text-[var(--console-muted)]`,children:e.count})]},e.id))}):null]})]})}N.registerLanguage(`bash`,nt),N.registerLanguage(`c`,rt),N.registerLanguage(`cpp`,Ct),N.registerLanguage(`csharp`,ot),N.registerLanguage(`css`,wt),N.registerLanguage(`docker`,St),N.registerLanguage(`go`,it),N.registerLanguage(`ini`,ut),N.registerLanguage(`java`,dt),N.registerLanguage(`javascript`,mt),N.registerLanguage(`jsx`,_t),N.registerLanguage(`json`,lt),N.registerLanguage(`markdown`,ct),N.registerLanguage(`markup`,xt),N.registerLanguage(`python`,pt),N.registerLanguage(`rust`,st),N.registerLanguage(`sql`,yt),N.registerLanguage(`toml`,gt),N.registerLanguage(`tsx`,at),N.registerLanguage(`typescript`,ft),N.registerLanguage(`yaml`,vt);function tu(e){return e===`html`||e===`xml`?`markup`:e}function nu({language:e,text:t}){let n=(0,P.useContext)(_a);return(0,L.jsx)(N,{language:tu(e),style:n===`dark`?ht:bt,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 ru(e,t){return`${e}:${t}`}function iu(e){return/^(Index:|diff\s|===)/.test(e)?`text-[var(--console-text)] bg-[#f3f4f6] dark:bg-[var(--console-surface-muted)]`:e.startsWith(`@@`)?`text-[#7c3aed] bg-[#f5f3ff] dark:text-[var(--tag-refactoring-text)] dark:bg-[var(--tag-refactoring-background)]`:e.startsWith(`+++ `)||e.startsWith(`--- `)?`text-[#1d4ed8] bg-[#eff6ff] dark:text-[var(--tag-feature-dev-text)] dark:bg-[var(--tag-feature-dev-background)]`:e.startsWith(`+`)?`text-[#15803d] bg-[#f0fdf4] dark:text-[var(--console-success)] dark:bg-[var(--console-success-bg)]`:e.startsWith(`-`)?`text-[#b91c1c] bg-[#fef2f2] dark:text-[var(--console-error)] dark:bg-[var(--console-error-bg)]`:`text-[var(--console-text)]`}function au({text:e}){let t=e.split(`
|
|
103
|
+
`),n=new Map;return(0,L.jsx)(`pre`,{className:`console-mono max-h-[420px] overflow-auto whitespace-pre rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-sunken)] p-3 text-xs leading-relaxed`,children:t.map(e=>{let t=n.get(e)??0;return n.set(e,t+1),(0,L.jsx)(`span`,{className:`block rounded-[2px] px-1 ${iu(e)}`,children:e||` `},ru(e,t))})})}function ou(e){let t=e.text||`No output captured.`;return!e.isCode||e.language===`text`?(0,L.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,L.jsx)(au,{text:t}):(0,L.jsx)(`div`,{className:`max-h-[420px] overflow-auto bg-[var(--console-surface-sunken)]`,children:(0,L.jsx)(nu,{language:e.language,text:t})})}function su({sections:e}){return(0,L.jsx)(`div`,{className:`space-y-3`,children:e.map(e=>(0,L.jsxs)(`div`,{className:`overflow-hidden rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-sunken)]`,children:[(0,L.jsx)(`div`,{className:`border-b border-[var(--console-border)] bg-[var(--console-surface-muted)] px-3 py-1.5`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-[var(--console-muted)]`,children:e.operation}),(0,L.jsx)(`span`,{className:`console-mono text-[11px] font-semibold text-[var(--console-muted)]`,children:e.label})]})}),ou(e)]},`${e.operation}:${e.label}:${e.language}`))})}function cu({items:e,text:t}){return(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsx)(`div`,{className:`grid gap-3 ${e.length>1?`sm:grid-cols-2`:``}`,children:e.map((e,t)=>(0,L.jsxs)(`figure`,{className:`overflow-hidden rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)]`,children:[(0,L.jsx)(`img`,{src:e.src,alt:e.alt,className:`max-h-[520px] w-full object-contain`,loading:`lazy`}),e.caption?(0,L.jsx)(`figcaption`,{className:`console-mono border-t border-[var(--console-border)] px-3 py-2 text-[11px] text-[var(--console-muted)]`,children:e.caption}):null]},`${e.src.slice(0,80)}:${t}`))}),t?(0,L.jsx)(`pre`,{className:`console-mono whitespace-pre-wrap break-words rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-sunken)] p-3 text-xs leading-relaxed text-[var(--console-text)]`,children:t}):null]})}function lu(e){return e==null||e===``?`—`:typeof e==`boolean`?e?`Yes`:`No`:typeof e==`string`||typeof e==`number`||typeof e==`bigint`?String(e):null}function uu({value:e,depth:t=0}){let n=lu(e);return n==null?Array.isArray(e)?t>=2?(0,L.jsxs)(`span`,{children:[e.length,` items`]}):(0,L.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map((e,n)=>(0,L.jsx)(`span`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-1.5 py-0.5`,children:(0,L.jsx)(uu,{value:e,depth:t+1})},n))}):typeof e==`object`?t>=2?(0,L.jsxs)(`span`,{children:[Object.keys(e).length,` fields`]}):(0,L.jsx)(`dl`,{className:`space-y-1.5`,children:Object.entries(e).map(([e,n])=>(0,L.jsxs)(`div`,{className:`grid grid-cols-[minmax(80px,auto)_1fr] gap-2`,children:[(0,L.jsx)(`dt`,{className:`text-[var(--console-muted)]`,children:e}),(0,L.jsx)(`dd`,{className:`min-w-0`,children:(0,L.jsx)(uu,{value:n,depth:t+1})})]},e))}):(0,L.jsx)(`span`,{children:String(e)}):(0,L.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:n})}function du({items:e}){return(0,L.jsx)(`dl`,{className:`overflow-hidden rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-sunken)]`,children:e.map(e=>(0,L.jsxs)(`div`,{className:`grid gap-1 border-b border-[var(--console-border)] px-3 py-2.5 last:border-b-0 sm:grid-cols-[130px_1fr] sm:gap-3`,children:[(0,L.jsx)(`dt`,{className:`console-mono text-[10px] font-semibold uppercase tracking-wide text-[var(--console-muted)]`,children:e.label}),(0,L.jsx)(`dd`,{className:`console-mono min-w-0 text-xs leading-relaxed text-[var(--console-text)]`,children:(0,L.jsx)(uu,{value:e.value})})]},e.label))})}function fu({questions:e}){return(0,L.jsx)(`div`,{className:`space-y-3`,children:e.map(e=>(0,L.jsxs)(`div`,{className:`overflow-hidden rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-sunken)]`,children:[(0,L.jsxs)(`div`,{className:`border-b border-[var(--console-border)] bg-[var(--console-surface-muted)] px-3 py-2`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.header?(0,L.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] 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,L.jsx)(`span`,{className:`console-mono text-[11px] font-semibold text-[var(--console-success)]`,children:`Answered`}):(0,L.jsx)(`span`,{className:`console-mono text-[11px] font-semibold text-[var(--console-muted)]`,children:`Pending`})]}),(0,L.jsx)(`p`,{className:`mt-2 text-sm leading-relaxed text-[var(--console-text)]`,children:e.question})]}),(0,L.jsx)(`div`,{className:`space-y-2 p-3`,children:e.options.map(t=>{let n=e.answers.includes(t.label);return(0,L.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-[var(--console-surface)]`}`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`console-mono text-xs font-semibold ${n?`text-[var(--console-success)]`:`text-[var(--console-text)]`}`,children:t.label}),t.recommended?(0,L.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,L.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-success-border)] bg-[var(--console-surface)] px-1.5 py-0.5 text-[10px] text-[var(--console-success)]`,children:`Selected`}):null]}),t.description?(0,L.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 pu(e){return`${e.label}:${e.lines.map(e=>`${e.type}:${e.text}`).join(`
|
|
104
|
+
`)}`}function mu(e){return e===`add`?`text-[#15803d] bg-[#f0fdf4] dark:text-[var(--console-success)] dark:bg-[var(--console-success-bg)]`:e===`remove`?`text-[#b91c1c] bg-[#fef2f2] dark:text-[var(--console-error)] dark:bg-[var(--console-error-bg)]`:`text-[var(--console-text)]`}function hu({blocks:e}){return(0,L.jsx)(`div`,{className:`space-y-3`,children:e.map(e=>{let t=new Map;return(0,L.jsxs)(`div`,{className:`overflow-hidden rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-sunken)]`,children:[(0,L.jsx)(`div`,{className:`border-b border-[var(--console-border)] bg-[var(--console-surface-muted)] px-3 py-1.5`,children:(0,L.jsx)(`span`,{className:`console-mono text-[11px] font-semibold text-[var(--console-muted)]`,children:e.label})}),(0,L.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,L.jsxs)(`span`,{className:`block rounded-[2px] px-1 ${mu(e.type)}`,children:[e.type===`add`?`+`:e.type===`remove`?`-`:` `,e.text||` `]},`${n}:${r}`)})})]},pu(e))})})}var gu={completed:{Icon:mn,label:`Done`,className:`text-[var(--console-success)]`},error:{Icon:er,label:`Failed`,className:`text-[var(--console-error)]`},in_progress:{Icon:xn,label:`In progress`,className:`text-[var(--console-warning)]`},pending:{Icon:bn,label:`Pending`,className:`text-[var(--console-muted)]`}};function _u({items:e}){return(0,L.jsx)(`ol`,{className:`overflow-hidden rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)]`,children:e.map((e,t)=>{let n=gu[e.status];return(0,L.jsxs)(`li`,{className:`flex gap-3 border-b border-[var(--console-border)] px-3 py-2.5 last:border-b-0`,children:[(0,L.jsx)(n.Icon,{className:`mt-0.5 size-3.5 shrink-0 ${n.className}`}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1`,children:[(0,L.jsx)(`span`,{className:`text-xs font-medium leading-relaxed text-[var(--console-text)]`,children:e.label}),(0,L.jsx)(`span`,{className:`console-mono text-[10px] uppercase tracking-wide ${n.className}`,children:n.label})]}),e.detail?(0,L.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-[var(--console-muted)]`,children:e.detail}):null]})]},`${e.label}:${t}`)})})}function vu({outputContent:e}){if(e.kind===`structured-diff`)return(0,L.jsx)(hu,{blocks:e.blocks});if(e.kind===`file-sections`)return(0,L.jsx)(su,{sections:e.sections});if(e.kind===`question-list`)return(0,L.jsx)(fu,{questions:e.questions});if(e.kind===`task-list`)return(0,L.jsx)(_u,{items:e.items});if(e.kind===`media`)return(0,L.jsx)(cu,{items:e.items,text:e.text});if(e.kind===`property-list`)return(0,L.jsx)(du,{items:e.items});let t=e.text||`No output captured.`;return!e.isCode||e.language===`text`?(0,L.jsx)(`pre`,{className:`console-mono max-h-[420px] overflow-auto whitespace-pre-wrap break-words rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-sunken)] p-3 text-xs leading-relaxed text-[var(--console-text)]`,children:t}):e.language===`diff`?(0,L.jsx)(au,{text:t}):(0,L.jsx)(`div`,{className:`max-h-[420px] overflow-auto rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-sunken)]`,children:(0,L.jsx)(nu,{language:e.language,text:t})})}var yu=`<turn_aborted>
|
|
105
|
+
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.
|
|
106
|
+
</turn_aborted>`;function bu(e){return e.replace(/\r\n/g,`
|
|
107
|
+
`).trim()}function xu(e,t){if(t.toLowerCase()!==`codex`||e.role!==`user`||e.parts.length!==1)return!1;let[n]=e.parts;return!n||n.type!==`text`?!1:bu(n.text)===bu(yu)}function Su(e){let t=e.approval_status===`fail`?`fail`:`success`,n=e.text.trim();return{title:`plan`,secondaryText:void 0,approvalStatus:t,expandable:!!n,contentLabel:t===`fail`?`Rejected`:`Plan`,contentMarkdown:n}}var Cu={completed:{label:`Success`,className:`border-[var(--console-success-border)] bg-[var(--console-success-bg)] text-[var(--console-success)]`,icon:hn},error:{label:`Failed`,className:`border-[var(--console-error-border)] bg-[var(--console-error-bg)] text-[var(--console-error)]`,icon:tr},running:{label:`Running`,className:`border-[var(--console-warning-border)] bg-[var(--console-warning-bg)] text-[var(--console-warning)]`,icon:Nn}};function wu(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(cs).join(`|`)})`,`gi`)}function Tu(e,t){let n=wu(t);return n?e.split(n).map((e,t)=>e.match(n)?(0,L.jsx)(`mark`,{children:e},`${e}-${t}`):(0,L.jsx)(`span`,{children:e},`${e}-${t}`)):e}function Eu({text:e,highlightQuery:t}){return(0,L.jsx)(Xo,{text:e,highlightQuery:t})}var Du=(0,P.memo)(function({messageIndex:e,msg:t,blocks:n,formatTokens:r,sessionAgentKey:i,agent:a,baseDirectory:o,highlightQuery:s}){let c=t.role===`user`,l=xu(t,i),u=()=>{let e=a?.displayName??i,t=a?.icon;return(0,L.jsx)(L.Fragment,{children:t?(0,L.jsx)(U,{icon:t,iconColored:a?.iconColored,alt:e,className:`size-4 rounded-sm object-cover`}):(0,L.jsx)(fn,{className:`size-4 text-[var(--console-muted)]`})})},d=t.mode?t.mode.toUpperCase():null,f=t.model||null,p=Es(t),m=Ta(t.time_created);return(0,L.jsx)(`article`,{id:c?qs(e):void 0,"data-session-timeline-anchor":c?qs(e):void 0,className:`w-full scroll-mt-20 border-l-2 border-[var(--console-thread)] pl-4 pr-3 md:pr-5`,children:(0,L.jsxs)(`div`,{className:`flex gap-4`,children:[(0,L.jsx)(`div`,{className:`shrink-0 pt-1`,children:(0,L.jsx)(`div`,{className:`flex size-8 items-center justify-center rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)]`,children:c?(0,L.jsx)(Zn,{className:`size-4 text-[var(--console-muted)]`}):u()})}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,L.jsx)(`span`,{className:`console-mono text-sm font-bold tracking-wide text-[var(--console-text)]`,children:p}),(0,L.jsx)(`time`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:m}),d&&(0,L.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}),f&&(0,L.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:f})]}),l?(0,L.jsx)(Ou,{}):n.map((t,n)=>{let r=Js(e,n);return t.type===`reasoning`?(0,L.jsx)(ku,{anchorId:r,parts:t.parts,highlightQuery:s},n):t.type===`plan`?(0,L.jsx)(ju,{anchorId:r,parts:t.parts,highlightQuery:s},n):t.type===`tool`?(0,L.jsx)(Au,{parts:t.parts,anchorIds:t.anchorIds,sessionAgentKey:i,baseDirectory:o,highlightQuery:s},n):(0,L.jsx)(`div`,{id:r,"data-session-timeline-anchor":r,className:`scroll-mt-20 rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] p-4 shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:(0,L.jsx)(`div`,{className:`console-markdown text-sm leading-relaxed text-[var(--console-text)]`,children:t.parts.map((e,t)=>(0,L.jsx)(Eu,{text:e.text,highlightQuery:s},t))})},n)}),!c&&(t.tokens||t.cost)&&(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[t.tokens?.input?(0,L.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(t.tokens.input)]}):null,t.tokens?.output?(0,L.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(t.tokens.output)]}):null,t.tokens?.reasoning?(0,L.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(t.tokens.reasoning)]}):null,t.cost?(0,L.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:[t.cost_source===`estimated`?`EST COST`:`COST`,` $`,t.cost.toFixed(4)]}):null]})]})]})})});function Ou(){return(0,L.jsx)(`div`,{className:`space-y-2`,children:(0,L.jsx)(`div`,{className:`flex flex-wrap items-start gap-2`,children:(0,L.jsx)(`div`,{className:`w-full rounded-sm border border-[var(--console-border-strong)] bg-[var(--console-surface)] px-3 py-2 text-left shadow-[2px_2px_0_0_rgba(15,23,42,0.05)] md:w-[560px]`,children:(0,L.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,L.jsx)(Pn,{className:`mt-0.5 size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,L.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:`abort`})})]})})})})}function ku({anchorId:e,parts:t,highlightQuery:n}){let[r,i]=(0,P.useState)(!1),a=t.map(e=>e.text).filter(Boolean).join(`
|
|
108
|
+
|
|
109
|
+
`);return(0,L.jsxs)(`div`,{id:e,"data-session-timeline-anchor":e,className:`scroll-mt-20 overflow-hidden rounded-sm border border-[var(--console-thinking-border)] bg-[var(--console-thinking-bg)]`,children:[(0,L.jsxs)(`div`,{className:`flex cursor-pointer items-center justify-between bg-[var(--console-surface-muted)] px-3 py-2`,onClick:()=>i(!r),children:[(0,L.jsxs)(`span`,{className:`console-mono flex items-center gap-2 text-xs font-medium text-[var(--console-muted)]`,children:[(0,L.jsx)(jn,{className:`size-3.5`}),`Thinking`]}),(0,L.jsx)(`span`,{className:`text-[var(--console-muted)]`,children:(0,L.jsx)(gn,{className:`motion-chevron w-4 h-4`,"data-open":r||void 0})})]}),(0,L.jsx)(Hl,{open:r,children:()=>(0,L.jsx)(`div`,{className:`border-t border-dashed border-[var(--console-thinking-border)] px-4 py-3`,children:(0,L.jsx)(`div`,{className:`console-mono whitespace-pre-wrap text-xs leading-relaxed text-[var(--console-muted)]`,children:Tu(a,n)})})})]})}function Au({parts:e,anchorIds:t,sessionAgentKey:n,baseDirectory:r,highlightQuery:i}){return(0,L.jsx)(`div`,{className:`space-y-2`,children:(0,L.jsx)(`div`,{className:`space-y-2`,children:e.map((e,a)=>(0,L.jsx)(Nu,{tool:e,anchorId:t?.[a],sessionAgentKey:n,baseDirectory:r,highlightQuery:i},a))})})}function ju({anchorId:e,parts:t,highlightQuery:n}){return(0,L.jsx)(`div`,{id:e,"data-session-timeline-anchor":e,className:`scroll-mt-20 space-y-2`,children:t.map((e,t)=>(0,L.jsx)(Mu,{part:e,highlightQuery:n},t))})}function Mu({part:e,highlightQuery:t}){let[n,r]=(0,P.useState)(!1),i=Su(e),a=i.approvalStatus===`fail`?Cu.error:Cu.completed,o=a.icon;return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2`,children:[(0,L.jsx)(`div`,{className:`w-full md:w-[560px] rounded-sm border border-[var(--console-border-strong)] bg-[var(--console-surface)] px-3 py-2 text-left shadow-[2px_2px_0_0_rgba(15,23,42,0.05)] ${i.expandable?`motion-hover hover:bg-[var(--console-surface-muted)]`:``}`,children:i.expandable?(0,L.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-2 text-left`,onClick:()=>r(!n),children:[(0,L.jsx)(pn,{className:`mt-0.5 size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,L.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:i.title})}),(0,L.jsx)(`span`,{className:`mt-0.5 shrink-0 text-[var(--console-muted)]`,children:(0,L.jsx)(gn,{className:`motion-chevron size-3.5`,"data-open":n||void 0})})]}):(0,L.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,L.jsx)(pn,{className:`mt-0.5 size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,L.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:i.title})})]})}),(0,L.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,L.jsx)(o,{className:`size-3`}),a.label]})]}),(0,L.jsx)(Hl,{open:i.expandable&&n,children:()=>(0,L.jsxs)(`div`,{className:`mt-2 overflow-hidden rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:[(0,L.jsx)(`div`,{className:`border-b border-[var(--console-border)] bg-[var(--console-surface-muted)] px-3 py-1.5`,children:(0,L.jsx)(`span`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:i.contentLabel})}),(0,L.jsx)(`div`,{className:`p-4`,children:(0,L.jsx)(`div`,{className:`console-markdown text-sm leading-relaxed text-[var(--console-text)]`,children:(0,L.jsx)(Eu,{text:i.contentMarkdown,highlightQuery:t})})})]})})]})}function Nu({tool:e,anchorId:t,sessionAgentKey:n,baseDirectory:r,highlightQuery:i}){let[a,o]=(0,P.useState)(!1),s=Ts(e),c=Rl(n,e,s,r),l=Ps(s.inputText||`{}`,r),u=Cu[s.status],d=u.icon,f=c.Icon;return(0,L.jsxs)(`div`,{id:t,"data-session-timeline-anchor":t,className:`scroll-mt-20`,children:[(0,L.jsx)(`div`,{className:`flex flex-wrap items-start gap-2`,children:(0,L.jsx)(`div`,{className:`w-full max-w-[720px] rounded-sm border border-[var(--console-border-strong)] bg-[var(--console-surface)] px-3 py-2.5 text-left shadow-[2px_2px_0_0_rgba(15,23,42,0.05)] ${c.expandable?`motion-hover hover:bg-[var(--console-surface-muted)]`:``}`,children:c.expandable?(0,L.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2.5 text-left active:scale-[0.995] motion-reduce:transform-none`,onClick:()=>o(!a),"aria-expanded":a,children:[(0,L.jsx)(f,{className:`size-4 shrink-0 text-[var(--console-accent)]`}),(0,L.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:c.title}),c.secondaryText?(0,L.jsx)(`span`,{className:`console-mono mt-0.5 block whitespace-pre-wrap break-words text-xs leading-relaxed text-[var(--console-muted)]`,children:Tu(c.secondaryText,i)}):null]}),(0,L.jsxs)(`span`,{className:`console-mono inline-flex shrink-0 items-center gap-1 rounded-sm border px-1.5 py-0.5 text-[9px] font-bold uppercase tracking-wider ${u.className}`,children:[(0,L.jsx)(d,{className:`size-2.5 ${s.status===`running`?`animate-spin motion-reduce:animate-none`:``}`}),u.label]}),(0,L.jsx)(`span`,{className:`mt-0.5 shrink-0 text-[var(--console-muted)]`,children:(0,L.jsx)(gn,{className:`motion-chevron size-3.5`,"data-open":a||void 0})})]}):(0,L.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,L.jsx)(f,{className:`size-4 shrink-0 text-[var(--console-accent)]`}),(0,L.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:c.title}),c.secondaryText?(0,L.jsx)(`span`,{className:`console-mono mt-0.5 block whitespace-pre-wrap break-words text-xs leading-relaxed text-[var(--console-muted)]`,children:Tu(c.secondaryText,i)}):null]}),(0,L.jsxs)(`span`,{className:`console-mono inline-flex shrink-0 items-center gap-1 rounded-sm border px-1.5 py-0.5 text-[9px] font-bold uppercase tracking-wider ${u.className}`,children:[(0,L.jsx)(d,{className:`size-2.5`}),u.label]})]})})}),(0,L.jsx)(Hl,{open:c.expandable&&a,children:()=>(0,L.jsxs)(`div`,{className:`mt-2 overflow-hidden rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:[(0,L.jsx)(`div`,{className:`border-b border-[var(--console-border)] bg-[var(--console-surface-muted)] px-3 py-1.5`,children:(0,L.jsx)(`span`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:c.contentLabel??`Output`})}),(0,L.jsxs)(`div`,{className:`space-y-3 p-3`,children:[c.details.length>0?(0,L.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-sunken)] px-3 py-2`,children:(0,L.jsx)(`div`,{className:`space-y-2`,children:c.details.map(e=>(0,L.jsxs)(`div`,{className:`flex flex-col gap-1 md:flex-row md:items-start md:gap-3`,children:[(0,L.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,L.jsx)(`span`,{className:`console-mono whitespace-pre-wrap break-words text-xs leading-relaxed text-[var(--console-text)]`,children:Tu(e.value,i)})]},`${e.label}:${e.value}`))})}):null,(0,L.jsx)(vu,{outputContent:c.outputContent})]}),c.showInputPreview?(0,L.jsxs)(`div`,{className:`border-t border-[var(--console-border)] bg-[var(--console-surface-sunken)] px-3 py-2`,children:[(0,L.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:`Input Preview`}),(0,L.jsx)(`pre`,{className:`console-mono mt-1 max-h-[200px] overflow-x-auto whitespace-pre-wrap break-words text-xs leading-relaxed text-[var(--console-muted)]`,children:Tu(l,i)})]}):null]})})]})}var Pu=32,Fu=280,Iu=6;function Lu(e){return e===window}function Ru(e,t){let n=[],r=0;for(let i=0;i<e;i+=1){let a=t[i]??Fu,o=r,s=o+a;n.push({start:o,end:s}),r=s+(i===e-1?0:Pu)}return{items:n,totalSize:r}}function zu(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 Bu(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 Vu(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 Hu(e){return Lu(e)?window.scrollY:e.scrollTop}function Uu(e){return Lu(e)?window.innerHeight||900:e.clientHeight}function Wu(e,t){if(Lu(t))return e.getBoundingClientRect().top+window.scrollY;let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();return t.scrollTop+r.top-n.top}function Gu(e,t){if(Lu(e)){window.scrollTo({top:t,behavior:`auto`});return}e.scrollTo({top:t,behavior:`auto`})}function Ku({messages:e,sessionAgentKey:t,agent:n,baseDirectory:r,highlightQuery:i,apiRef:a}){let o=e.length>80;return(0,P.useEffect)(()=>{o||(a.current=null)},[a,o]),o?(0,L.jsx)(qu,{messages:e,sessionAgentKey:t,agent:n,baseDirectory:r,highlightQuery:i,apiRef:a}):(0,L.jsx)(`div`,{className:`flex min-w-0 flex-col gap-8`,children:e.map(({msg:e,blocks:a,index:o})=>(0,L.jsx)(Du,{messageIndex:o,msg:e,blocks:a,formatTokens:wa,sessionAgentKey:t,agent:n,baseDirectory:r,highlightQuery:i},`${e.id}:${o}`))})}function qu({messages:e,sessionAgentKey:t,agent:n,baseDirectory:r,highlightQuery:i,apiRef:a}){let o=(0,P.useRef)(null),s=(0,P.useRef)(null),[c,l]=(0,P.useState)([]),[u,d]=(0,P.useState)(null),[f,p]=(0,P.useState)(()=>({scrollTop:0,height:900,listTop:0})),m=(0,P.useRef)(f);(0,P.useEffect)(()=>{m.current=f},[f]);let h=(0,P.useCallback)(()=>{if(typeof window>`u`)return null;let e=o.current,t=e?Vu(e):window;s.current=t;let n=e?Wu(e,t):0,r={scrollTop:Hu(t),height:Uu(t),listTop:n},i=m.current;return Math.abs(i.scrollTop-r.scrollTop)<1&&Math.abs(i.height-r.height)<1&&Math.abs(i.listTop-r.listTop)<1?t:(m.current=r,p(r),t)},[]);(0,P.useEffect)(()=>{let e=0,t=null,n=null,r=e=>{t!==e&&(t&&(t.removeEventListener(`scroll`,a),n&&!Lu(t)&&n.unobserve(t)),t=e,t.addEventListener(`scroll`,a,{passive:!0}),n&&!Lu(t)&&n.observe(t))},i=()=>{let e=h();e&&r(e)},a=()=>{e||=requestAnimationFrame(()=>{e=0,i()})};window.addEventListener(`resize`,a),typeof ResizeObserver<`u`&&(n=new ResizeObserver(a),o.current&&n.observe(o.current),document.body&&n.observe(document.body));let s=new MutationObserver(a),c=o.current?.parentElement;for(;c;)s.observe(c,{attributes:!0,attributeFilter:[`class`,`style`]}),c=c.parentElement;return document.fonts?.addEventListener(`loadingdone`,a),i(),()=>{e&&cancelAnimationFrame(e),n?.disconnect(),s.disconnect(),document.fonts?.removeEventListener(`loadingdone`,a),t?.removeEventListener(`scroll`,a),window.removeEventListener(`resize`,a)}},[h]),(0,P.useEffect)(()=>{l([]),d(null),h()},[e,h]);let g=(0,P.useMemo)(()=>Ru(e.length,c),[c,e.length]),_=(0,P.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,P.useMemo)(()=>{if(e.length===0)return[];let t=Math.max(0,f.scrollTop-f.listTop),n=t+f.height,r=Math.max(0,zu(g.items,t)-Iu),i=Math.min(e.length,Bu(g.items,n)+Iu),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,P.useCallback)(e=>{if(typeof window>`u`)return;let t=g.items[e];if(!t)return;d(e);let n=o.current,r=n?Vu(n):s.current??window;s.current=r;let i=n?Wu(n,r):0,a=Math.max(0,i+t.start-24);Gu(r,a);let c={scrollTop:a,height:Uu(r),listTop:i};m.current=c,p(c)},[g.items]);return(0,P.useEffect)(()=>(a.current={scrollToIndex:y},()=>{a.current?.scrollToIndex===y&&(a.current=null)}),[a,y]),(0,L.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,L.jsx)(Ju,{index:a,top:o,onMeasure:_,children:(0,L.jsx)(Du,{messageIndex:s.index,msg:s.msg,blocks:s.blocks,formatTokens:wa,sessionAgentKey:t,agent:n,baseDirectory:r,highlightQuery:i})},`${s.msg.id}:${s.index}`):null})})}function Ju({index:e,top:t,onMeasure:n,children:r}){let i=(0,P.useRef)(null);return(0,P.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,L.jsx)(`div`,{ref:i,className:`absolute left-0 top-0 w-full`,style:{transform:`translateY(${t}px)`},children:r})}function Yu(e,t){return t===0||e-t>=15.666666666666668}function Xu(e,t,n){return!e&&t<=.12?n+1:0}function Zu(e,t){return e?0:t+1}function Qu(e,t,n){return e>=2&&(t>=8||n>=300)}function $u(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}var Q=18,ed=42,td=5,$=270,nd=500,rd=2;function id(e){return Math.round(e??0).toLocaleString(`en-US`)}function ad(e){return`$${(e??0).toFixed(4)}`}function od(e){return new Date(e).toLocaleString(`en-US`,{month:`short`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`})}function sd(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 cd(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 ld(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 ud(e){return!e||e.length===0?`SESSION ACTIVITY RECEIPT`:e.map(e=>jr[e]).join(` / `)}function dd(e,t){let n=e.slug?.split(`/`)[0]||`codesesh`;return{id:e.id,title:H(e)||`Untitled session`,agent:n,updatedAt:e.time_updated??e.time_created,tags:e.smart_tags,stats:e.stats,items:ld(t)}}function fd(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 pd(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 md(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(pd(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]=pd(e,a[a.length-1]??``,n)),a.slice(0,r)}function hd(e){let t=document.createElement(`canvas`);t.width=$*rd,t.height=nd*rd;let n=t.getContext(`2d`);if(!n)return t;n.scale(rd,rd);let r=n.createLinearGradient(0,0,$,nd);r.addColorStop(0,`#ffffff`),r.addColorStop(.55,`#fafaf6`),r.addColorStop(1,`#f2f2ec`),n.fillStyle=r,n.fillRect(0,0,$,nd);let i=cd(sd(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()*$,i()*nd,.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`,$/2,34),n.font=`11px 'Courier New', monospace`,n.fillText(pd(n,ud(e.tags).toUpperCase(),$-36),$/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($-18,66),n.stroke(),n.setLineDash([]),n.textAlign=`left`,n.fillStyle=`rgba(0, 0, 0, 0.74)`,n.font=`11px 'Courier New', monospace`,fd(n,`Agent`,e.agent,88,$),fd(n,`Updated`,od(e.updatedAt),104,$),fd(n,`Session`,`#${e.id.slice(0,8)}`,120,$),n.setLineDash([2,3]),n.beginPath(),n.moveTo(18,140),n.lineTo($-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=id(t.count);n.fillText(pd(n,t.label,168),18,a),n.fillText(e,$-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($-18,a+5),n.stroke(),a+=26,fd(n,`Input tokens`,id(e.stats.total_input_tokens),a,$),a+=16,fd(n,`Output tokens`,id(e.stats.total_output_tokens),a,$),a+=16,fd(n,`Messages`,id(e.stats.message_count),a,$),a+=22,n.font=`700 13px 'Courier New', monospace`,fd(n,`TOTAL COST`,ad(e.stats.total_cost),a,$),n.strokeStyle=`rgba(0, 0, 0, 0.45)`,n.setLineDash([4,4]),n.beginPath(),n.moveTo(18,a+18),n.lineTo($-18,a+18),n.stroke(),n.setLineDash([]),n.font=`10px 'Courier New', monospace`,n.textAlign=`center`,n.fillStyle=`rgba(0, 0, 0, 0.62)`,md(n,e.title,$-36,2).forEach((e,t)=>{n.fillText(e,$/2,a+38+t*13)}),t}function gd(e,t){return e*Q+t}function _d(e){let{receiptWidth:t,receiptHeight:n,startX:r,startY:i}=e,a=t/(Q-1),o=n/(ed-1),s=[],c=[];for(let e=0;e<ed;e+=1)for(let t=0;t<Q;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<ed;e+=1)for(let t=0;t<Q;t+=1){let n=gd(e,t);t<Q-1&&l(n,gd(e,t+1),.98),e<ed-1&&l(n,gd(e+1,t),.92),e<ed-1&&t<Q-1&&(l(n,gd(e+1,t+1),.46),l(gd(e+1,t),gd(e,t+1),.46)),t<Q-2&&l(n,gd(e,t+2),.35),e<ed-2&&l(n,gd(e+2,t),.28)}return{particles:s,constraints:c,receiptWidth:t,receiptHeight:n}}function vd(e,t){let n=t.receiptWidth/(Q-1);for(let r=0;r<Q;r+=1){let i=e[r];i&&(i.fixedX=t.startX+r*n,i.fixedY=t.startY)}}function yd(e){for(let t=0;t<Q;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 bd(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 xd(e,t,n,r,i){let a=n[gd(r,i)],o=n[gd(r,i+1)],s=n[gd(r+1,i)],c=n[gd(r+1,i+1)];if(!a||!o||!s||!c)return;let l=i/(Q-1)*t.width,u=r/(ed-1)*t.height,d=t.width/(Q-1),f=t.height/(ed-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)/(nd/(ed-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 Sd(e,t,n){let r=null,i=44;for(let a=Q;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 Cd(e){let t=0;for(let n=Q;n<e.length;n+=1){let r=e[n];r&&(t=Math.max(t,Math.hypot(r.x-r.oldX,r.y-r.oldY)))}return t}function wd({session:e,toc:t,minWidthQuery:n=`(min-width: 1025px)`}){let r=(0,P.useRef)(null),i=(0,P.useRef)(null),a=(0,P.useRef)(null),o=(0,P.useMemo)(()=>dd(e,t),[e,t]);return(0,P.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=hd(o),d=0,f=0,p=0,m=_d({receiptWidth:$,receiptHeight:nd,startX:0,startY:32}),h=performance.now(),g=null,_=0,v=0,y=0,b=0,x=!1,S=!1,C=window.matchMedia(n),w=window.matchMedia(`(prefers-reduced-motion: reduce)`),T=()=>C.matches&&document.visibilityState===`visible`,E=()=>{let e=t.getBoundingClientRect(),n=Math.max(280,e.width||320),r=Math.min($,n-34);return{receiptWidth:r,receiptHeight:Math.min(nd,Math.max(320,p-42)),startX:(n-r)/2,startY:32}},ee=t=>{x!==t&&(x=t,e.style.visibility=t?`visible`:`hidden`,s.style.visibility=t&&!w.matches?`visible`:`hidden`)},D=()=>{S=!1,d&&=(window.cancelAnimationFrame(d),0),ee(!1)},O=(e,t=performance.now())=>{m=_d(e),g=e,h=t},te=()=>{let n=window.devicePixelRatio||1,r=t.getBoundingClientRect();f=Math.max(1,r.width),p=Math.max(1,r.height),e.width=Math.floor(f*n),e.height=Math.floor(p*n),c.setTransform(n,0,0,n,0,0),_=0,v=0,y=0,b=0,ee(!1),O(E()),T()&&ne()},ne=()=>{S||!T()||(S=!0,d=window.requestAnimationFrame(de))},k=()=>{T()?te():D()},re=e=>{let n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}},ie=e=>{if(e.button!==0||w.matches)return;let t=re(e),n=Sd(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,y=0,ne())},ae=e=>{if(l.id!==e.pointerId)return;let t=re(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},A=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},oe=e=>{let t=(e-h)/1e3;for(let e=Q;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)},se=()=>{for(let e=0;e<td;e+=1){yd(m.particles);for(let e of m.constraints)bd(m.particles,e)}yd(m.particles)},ce=()=>{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`},le=()=>{let e=m.particles[0],t=m.particles[Q-1],n=m.particles[ed*Q-1],r=m.particles[(ed-1)*Q];!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())},j=()=>{let e=m.particles[0],t=m.particles[Q-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())},ue=()=>{c.clearRect(0,0,f,p),le();for(let e=0;e<ed-1;e+=1)for(let t=0;t<Q-1;t+=1)xd(c,u,m.particles,e,t);j(),ce()},de=e=>{if(!S)return;if(!T()){D();return}if(!Yu(e,b)){d=window.requestAnimationFrame(de);return}b=e;let t=E();$u(g,t)&&l.id==null?(_=0,ee(!1),O(t,e)):(_+=1,g=t),vd(m.particles,t),w.matches||(oe(e),se()),ue();let n=l.id!=null;v=Xu(n,Cd(m.particles),v),y=Zu(n,y);let r=w.matches;if((r||_>=2)&&ee(!0),r||Qu(_,v,y)){r||(O(t,e),ue()),S=!1,d=0;return}d=window.requestAnimationFrame(de)};ee(!1),T()&&te();let fe=new ResizeObserver(te);return fe.observe(t),C.addEventListener(`change`,k),w.addEventListener(`change`,k),document.addEventListener(`visibilitychange`,k),window.addEventListener(`resize`,k),s.addEventListener(`pointerdown`,ie),s.addEventListener(`pointermove`,ae),s.addEventListener(`pointerup`,A),s.addEventListener(`pointercancel`,A),ne(),()=>{D(),fe.disconnect(),C.removeEventListener(`change`,k),w.removeEventListener(`change`,k),document.removeEventListener(`visibilitychange`,k),window.removeEventListener(`resize`,k),s.removeEventListener(`pointerdown`,ie),s.removeEventListener(`pointermove`,ae),s.removeEventListener(`pointerup`,A),s.removeEventListener(`pointercancel`,A)}},[n,o]),(0,L.jsxs)(`div`,{ref:i,className:`relative h-[calc(100dvh-5.5rem)] min-h-[420px]`,children:[(0,L.jsx)(`canvas`,{ref:r,className:`invisible pointer-events-none absolute inset-0 z-[61] block h-full w-full touch-none`,"aria-hidden":`true`}),(0,L.jsx)(`div`,{ref:a,className:`invisible absolute left-0 top-0 z-[62] cursor-grab touch-none active:cursor-grabbing`,"aria-label":`Interactive thermal receipt with Verlet paper simulation`})]})}var Td={desktop:{backdrop:`z-[60] hidden bg-black/20 min-[1025px]:block`,popup:`z-[61] hidden w-[min(92vw,430px)] p-4 min-[1025px]:block`},mobile:{backdrop:`z-50 bg-black/30 min-[1025px]:hidden`,popup:`console-scrollbar z-[51] w-[min(90vw,380px)] overflow-y-auto p-3 min-[1025px]:hidden`}};function Ed({open:e,onOpenChange:t,title:n,variant:r,children:i}){let a=Td[r];return(0,L.jsx)(y,{open:e,onOpenChange:t,children:(0,L.jsxs)(s,{children:[(0,L.jsx)(u,{className:`motion-backdrop fixed inset-0 ${a.backdrop}`}),(0,L.jsxs)(c,{className:`motion-drawer fixed bottom-0 right-0 top-0 overscroll-contain border-l border-[var(--console-border)] bg-[var(--console-bg)] shadow-[-12px_0_32px_rgba(15,23,42,0.18)] outline-none ${a.popup}`,children:[(0,L.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,L.jsx)(f,{className:`console-mono text-xs font-semibold uppercase tracking-[0.16em] text-[var(--console-text)]`,children:n}),(0,L.jsx)(p,{"aria-label":`Close ${n.toLowerCase()}`,className:`motion-hover motion-press rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] p-2 text-[var(--console-muted)] hover:bg-[var(--console-surface-muted)] focus-visible:ring-2 focus-visible:ring-[var(--console-accent)] focus-visible:ring-offset-2 focus-visible:outline-none`,children:(0,L.jsx)(er,{className:`size-4`,"aria-hidden":`true`})})]}),i]})]})})}function Dd({session:e,toc:t}){let[n,r]=(0,P.useState)(!1),[i,a]=(0,P.useState)(!1);return(0,P.useEffect)(()=>{r(!1)},[e.id]),(0,P.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)};return i.addEventListener(`change`,o),o(),()=>{cancelAnimationFrame(t),e&&cancelAnimationFrame(e),i.removeEventListener(`change`,o)}},[n]),(0,L.jsxs)(L.Fragment,{children:[(0,L.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-[var(--console-surface)] text-[10px] font-semibold uppercase tracking-[0.14em] text-[var(--console-text)] shadow-[-2px_4px_14px_rgba(15,23,42,0.14)] motion-hover hover:bg-[var(--console-surface-muted)] min-[1025px]:flex`,children:(0,L.jsx)(`span`,{className:`[writing-mode:vertical-rl]`,children:`Receipt`})}),(0,L.jsx)(Ed,{open:n,onOpenChange:r,title:`Session Receipt`,variant:`desktop`,children:i?(0,L.jsx)(sn,{id:`InteractiveReceipt`,children:(0,L.jsx)(wd,{session:e,toc:t},e.id)}):(0,L.jsx)(`div`,{className:`h-[calc(100dvh-5.5rem)] min-h-[420px] rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)]`})})]})}function Od({toc:e,fileChangeSummary:t,onOpen:n}){let r=Gl(t);return(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-2 min-[1025px]:hidden`,children:[(0,L.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-[var(--console-surface)] px-3 text-xs font-semibold uppercase tracking-[0.12em] text-[var(--console-text)] shadow-[0_1px_2px_rgba(15,23,42,0.04)] motion-hover hover:bg-[var(--console-surface-muted)]`,children:[(0,L.jsx)(kn,{className:`size-3.5 text-[var(--console-accent)]`}),`TOC`,(0,L.jsx)(`span`,{className:`text-[var(--console-muted)]`,children:e.counts.tools_all})]}),r>0?(0,L.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-[var(--console-surface)] px-3 text-xs font-semibold uppercase tracking-[0.12em] text-[var(--console-text)] shadow-[0_1px_2px_rgba(15,23,42,0.04)] motion-hover hover:bg-[var(--console-surface-muted)]`,children:[(0,L.jsx)(On,{className:`size-3.5 text-[var(--console-accent)]`}),`Files`,(0,L.jsx)(`span`,{className:`text-[var(--console-muted)]`,children:r})]}):null]})}function kd({openPanel:e,toc:t,fileChangeSummary:n,baseDirectory:r,selectedFilters:i,onClose:a,onToggle:o,onJumpToAnchor:s}){return(0,P.useEffect)(()=>{if(!e)return;let t=window.matchMedia(`(min-width: 1025px)`),n=()=>{t.matches&&a()};return t.addEventListener(`change`,n),n(),()=>{t.removeEventListener(`change`,n)}},[a,e]),(0,L.jsx)(Ed,{open:e!==null,onOpenChange:e=>{e||a()},title:e===`files`?`File Tracker`:`Session TOC`,variant:`mobile`,children:e?e===`toc`?(0,L.jsx)(eu,{toc:t,selectedFilters:i,onToggle:o}):(0,L.jsx)(Kl,{summary:n,baseDirectory:r,onJumpToAnchor:s}):null})}var Ad=e(b(),1),jd=10,Md=1,Nd=8,Pd=6,Fd={user:`bg-[var(--timeline-user)]`,agent:`bg-[var(--timeline-agent)]`,"tool-read":`bg-[var(--timeline-tool-read)]`,"tool-write":`bg-[var(--timeline-tool-write)]`,"tool-execute":`bg-[var(--timeline-tool-execute)]`},Id={user:`#a85f82`,agent:`#5e86aa`,"tool-read":`#478b7d`,"tool-write":`#bd7336`,"tool-execute":`#786ca3`};function Ld(e){return{start:0,end:Math.min(e,80)}}function Rd(e,t,n,r){if(e<=80)return{start:0,end:e};if(n<=0||r<=0)return Ld(e);if(n>=r)return{start:0,end:e};let i=Math.floor(Math.max(0,t)/r*e),a=Math.ceil(Math.min(r,t+n)/r*e);return{start:Math.max(0,i-Pd),end:Math.min(e,a+Pd)}}function zd(e,t,n){let r=100/t;return{left:`calc(${e*r}% + ${e*n/t}px)`,width:`calc(${r}% - ${(t-1)*n/t}px)`}}var Bd=(0,P.memo)(function({entry:e,index:t,isActive:n,isTooltipVisible:r,virtualized:i,entryCount:a,gapWidth:o,onShowTooltip:s,onHideTooltip:c}){let l=`timeline-tooltip-${e.id}`;return(0,L.jsx)(`span`,{className:`t-tt-wrap session-timeline-item min-w-0 ${i?`absolute inset-y-0`:``}`,style:i?zd(t,a,o):void 0,children:(0,L.jsx)(`button`,{type:`button`,"data-timeline-index":t,"aria-current":n?`location`:void 0,"aria-describedby":r?l:void 0,"aria-label":`Go to ${e.tooltip}`,className:`t-tt-trigger session-timeline-segment h-full w-full rounded-[3px] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--console-text)] ${Fd[e.kind]}`,onPointerEnter:t=>s(e,t.currentTarget,`pointer`),onPointerLeave:()=>c(e.id),onFocus:t=>s(e,t.currentTarget,`focus`),onBlur:()=>c(e.id)})})});function Vd(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 Hd(e){return e===window}function Ud(e){if(Hd(e)){let e=window.innerHeight||900,t=document.scrollingElement??document.documentElement;return{center:e/2,scrollTop:window.scrollY||t.scrollTop,viewportHeight:e,scrollHeight:t.scrollHeight}}return{center:e.getBoundingClientRect().top+e.clientHeight/2,scrollTop:e.scrollTop,viewportHeight:e.clientHeight,scrollHeight:e.scrollHeight}}function Wd(e){let t=e>80?{className:`gap-px`,width:1}:e>40?{className:`gap-0.5`,width:2}:{className:`gap-1`,width:4};return{gapClassName:t.className,gapWidth:t.width,minWidth:e*jd+Math.max(0,e-1)*t.width}}function Gd(e,t,n,r,i){if(r===0||e.clientWidth<=0)return;let a=Math.max(e.scrollWidth,t.scrollWidth,t.getBoundingClientRect().width);if(a<=0)return;let o=Math.max(0,(a-Math.max(0,r-1)*i)/r),s=n*(o+i),c=s+o,l=e.scrollLeft,u=l+e.clientWidth;s<l?e.scrollLeft=s:c>u&&(e.scrollLeft=c-e.clientWidth)}function Kd({entries:e,onNavigate:t}){let n=(0,P.useRef)(null),r=(0,P.useRef)(null),i=(0,P.useRef)(null),a=(0,P.useRef)(null),o=(0,P.useRef)(null),s=(0,P.useRef)({active:!1,moved:!1,startX:0,lastIndex:-1}),c=(0,P.useRef)(!1),l=(0,P.useRef)(null),u=(0,P.useRef)(null),d=(0,P.useRef)(null),[f,p]=(0,P.useState)(0),[m,h]=(0,P.useState)(null),[g,_]=(0,P.useState)({left:!1,right:!1}),[v,y]=(0,P.useState)(null),[b,x]=(0,P.useState)(()=>Ld(e.length)),S=(0,P.useMemo)(()=>new Map(e.map((e,t)=>[e.anchorId,t])),[e]),C=Wd(e.length),w=e.length>80,T=w?Math.min(b.start,e.length):0,E=w?Math.max(T,Math.min(b.end,e.length)):e.length,ee=(0,P.useMemo)(()=>e.slice(T,E).map((e,t)=>({entry:e,index:T+t})),[e,E,T]),D=(0,P.useCallback)(()=>{let t=r.current;if(!t)return;let n=Rd(e.length,t.scrollLeft,t.clientWidth,t.scrollWidth);x(e=>e.start===n.start&&e.end===n.end?e:n);let i=Math.max(0,t.scrollWidth-t.clientWidth),a={left:t.scrollLeft>Md,right:t.scrollLeft<i-Md};if(_(e=>e.left===a.left&&e.right===a.right?e:a),i<=0){y(null);return}let o={start:t.scrollLeft/t.scrollWidth,size:t.clientWidth/t.scrollWidth};y(e=>e?.start===o.start&&e.size===o.size?e:o)},[e.length]);(0,P.useLayoutEffect)(()=>{let e=a.current;if(!e||!m)return;let t=e.offsetWidth/2,n=Math.min(window.innerWidth-Nd-t,Math.max(Nd+t,m.anchorX));e.style.left=`${n}px`},[m]),(0,P.useLayoutEffect)(()=>{D();let e=r.current,t=i.current;if(!e||!t||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(D);return n.observe(e),n.observe(t),()=>n.disconnect()},[e.length,D]),(0,P.useEffect)(()=>{p(0);let t=n.current;if(!t||e.length===0)return;let r=t.closest(`[data-testid="session-detail"]`),i=Vd(t),a=0,o=`[data-session-timeline-anchor]`,s=e=>{let t=e.dataset.sessionTimelineAnchor,n=t?S.get(t):void 0;return n==null?null:{index:n,top:e.getBoundingClientRect().top}},c=()=>Array.from(r?.querySelectorAll(o)??[]).flatMap(e=>s(e)??[]),l=new Map,u=()=>Array.from(l.values()).flatMap(e=>s(e)??[]),d=()=>{let t=Ud(i),n=tc(t.scrollTop,t.viewportHeight,t.scrollHeight,e.length),r=m?u():c(),a=n??ec(r,t.center);a!=null&&p(e=>e===a?e:a)},f=()=>{a||=requestAnimationFrame(()=>{a=0,d()})},m=typeof IntersectionObserver>`u`?null:new IntersectionObserver(e=>{for(let t of e){let e=t.target,n=e.dataset.sessionTimelineAnchor;n&&(t.isIntersecting?l.set(n,e):l.delete(n))}f()},{root:Hd(i)?null:i,threshold:0}),h=e=>m?.observe(e),g=e=>{m?.unobserve(e);let t=e.dataset.sessionTimelineAnchor;t&&l.delete(t)},_=(e,t)=>{e instanceof HTMLElement&&(e.matches(o)&&t(e),e.querySelectorAll(o).forEach(t))};m&&r&&r.querySelectorAll(o).forEach(h),f(),i.addEventListener(`scroll`,f,{passive:!0}),window.addEventListener(`resize`,f);let v=typeof ResizeObserver>`u`?null:new ResizeObserver(f);r&&v?.observe(r);let y=typeof MutationObserver>`u`?null:new MutationObserver(e=>{if(!m){f();return}for(let t of e)t.addedNodes.forEach(e=>_(e,h)),t.removedNodes.forEach(e=>_(e,g));f()});return r&&y?.observe(r,{childList:!0,subtree:!0}),()=>{a&&cancelAnimationFrame(a),m?.disconnect(),v?.disconnect(),y?.disconnect(),i.removeEventListener(`scroll`,f),window.removeEventListener(`resize`,f)}},[e.length,S]),(0,P.useEffect)(()=>{let t=r.current,n=i.current;!t||!n||(Gd(t,n,f,e.length,C.gapWidth),D())},[f,e.length,C.gapWidth,D]),(0,P.useLayoutEffect)(()=>{let e=d.current;if(e==null)return;let t=i.current?.querySelector(`[data-timeline-index="${e}"]`);t&&(d.current=null,t.focus())},[E,T]);let O=v!=null;(0,P.useEffect)(()=>{let t=l.current;if(!t||!O)return;let n=()=>{let n=t.getContext(`2d`),r=t.clientWidth,i=t.clientHeight;if(!n||!r||!i||e.length===0)return;let a=window.devicePixelRatio||1;t.width=Math.round(r*a),t.height=Math.round(i*a),n.scale(a,a),n.clearRect(0,0,r,i);let o=window.getComputedStyle(t),s={user:o.getPropertyValue(`--timeline-user`).trim()||Id.user,agent:o.getPropertyValue(`--timeline-agent`).trim()||Id.agent,"tool-read":o.getPropertyValue(`--timeline-tool-read`).trim()||Id[`tool-read`],"tool-write":o.getPropertyValue(`--timeline-tool-write`).trim()||Id[`tool-write`],"tool-execute":o.getPropertyValue(`--timeline-tool-execute`).trim()||Id[`tool-execute`]};e.forEach((t,a)=>{let o=a/e.length*r,c=(a+1)/e.length*r;n.fillStyle=s[t.kind],n.fillRect(o,0,Math.max(c-o,.5),i)})};n();let r=new MutationObserver(n);if(r.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),typeof ResizeObserver>`u`)return()=>r.disconnect();let i=new ResizeObserver(n);return i.observe(t),()=>{r.disconnect(),i.disconnect()}},[e,O]);let te=(0,P.useCallback)((e,t)=>{let n=r.current;n&&(n.scrollLeft=(e-t)*n.scrollWidth)},[]),ne=(0,P.useCallback)(e=>{let t=r.current;if(!t)return;let n=Math.max(0,t.scrollWidth-t.clientWidth),i=Math.max(40,t.clientWidth*.1),a=Math.max(120,t.clientWidth*.75),o=null;e.key===`ArrowLeft`&&(o=t.scrollLeft-i),e.key===`ArrowRight`&&(o=t.scrollLeft+i),e.key===`PageUp`&&(o=t.scrollLeft-a),e.key===`PageDown`&&(o=t.scrollLeft+a),e.key===`Home`&&(o=0),e.key===`End`&&(o=n),o!=null&&(e.preventDefault(),t.scrollLeft=Math.min(n,Math.max(0,o)))},[]),k=(0,P.useCallback)((e,t,n)=>{let r=t.getBoundingClientRect();o.current=t,h({entryId:e.id,id:`timeline-tooltip-${e.id}`,text:e.tooltip,anchorX:r.left+r.width/2,top:r.bottom+8,source:n})},[]),re=(0,P.useCallback)(e=>{h(t=>t?.entryId===e?(o.current=null,null):t)},[]),ie=(0,P.useCallback)(()=>{D(),h(e=>{let t=o.current;if(!e||e.source!==`focus`||!t||t!==document.activeElement)return o.current=null,null;let n=t.getBoundingClientRect();return{...e,anchorX:n.left+n.width/2,top:n.bottom+8}})},[D]),ae=(0,P.useCallback)(e=>{let t=r.current;t&&(t.scrollLeft+=e*Math.max(120,t.clientWidth*.75))},[]),A=(0,P.useCallback)((n,r)=>{let a=i.current;if(!a)return;let o=a.getBoundingClientRect(),c=nc(n,o.left,o.width,e.length);if(c==null||c===s.current.lastIndex)return;let l=e[c];l&&(s.current.lastIndex=c,t(l,r))},[e,t]),oe=(0,P.useCallback)(t=>{let n=r.current,a=i.current;if(!n||!a)return;let o=a.querySelector(`[data-timeline-index="${t}"]`);if(o){o.focus();return}d.current=t,Gd(n,a,t,e.length,C.gapWidth),D()},[e.length,C.gapWidth,D]),se=(0,P.useCallback)(t=>{let n=t.target.closest(`[data-timeline-index]`)?.dataset.timelineIndex,r=n==null?null:Number(n);if(r==null||!Number.isInteger(r))return;let i=null;t.key===`ArrowLeft`&&(i=Math.max(0,r-1)),t.key===`ArrowRight`&&(i=Math.min(e.length-1,r+1)),t.key===`Home`&&(i=0),t.key===`End`&&(i=e.length-1),!(i==null||i===r)&&(t.preventDefault(),oe(i))},[e.length,oe]);return(0,L.jsx)(`div`,{className:`sticky top-0 z-20 -mx-2 bg-[var(--console-bg)] px-2 py-3`,children:(0,L.jsxs)(`div`,{ref:n,className:`session-message-timeline relative rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-3 py-2.5 shadow-[0_1px_2px_rgba(15,23,42,0.05)]`,children:[(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(`div`,{ref:r,id:`session-timeline-viewport`,role:`navigation`,"aria-label":`Session message timeline`,tabIndex:0,className:`session-timeline-viewport overflow-x-auto overflow-y-hidden overscroll-x-contain py-1`,onScroll:ie,children:(0,L.jsx)(`div`,{ref:i,"data-testid":`session-timeline-track`,className:`${w?`relative`:`grid items-stretch ${C.gapClassName}`} h-5 w-full select-none`,style:w?{minWidth:`${C.minWidth}px`}:{gridTemplateColumns:`repeat(${e.length}, minmax(${jd}px, 1fr))`,minWidth:`${C.minWidth}px`},onKeyDown:se,onPointerDown:e=>{e.button===0&&(s.current={active:!0,moved:!1,startX:e.clientX,lastIndex:-1})},onPointerMove:e=>{let t=s.current;if(t.active){if(!t.moved){if(Math.abs(e.clientX-t.startX)<3)return;t.moved=!0,e.currentTarget.setPointerCapture(e.pointerId)}c.current=!0,A(e.clientX,`auto`)}},onPointerUp:e=>{s.current.active=!1,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),window.setTimeout(()=>{c.current=!1},0)},onPointerCancel:()=>{s.current.active=!1,c.current=!1},onClick:n=>{if(c.current)return;let r=Ul(n.detail),i=n.target.closest(`[data-timeline-index]`)?.dataset.timelineIndex,a=i==null?null:Number(i),o=a==null||!Number.isInteger(a)?void 0:e[a];if(o){t(o,r);return}A(n.clientX,r)},children:ee.map(({entry:t,index:n})=>(0,L.jsx)(Bd,{entry:t,index:n,isActive:n===f,isTooltipVisible:m?.entryId===t.id,virtualized:w,entryCount:e.length,gapWidth:C.gapWidth,onShowTooltip:k,onHideTooltip:re},t.id))})}),g.left&&(0,L.jsx)(`button`,{type:`button`,"aria-label":`Scroll timeline left`,className:`absolute inset-y-0 left-0 z-10 flex w-8 items-center justify-start bg-[linear-gradient(to_right,var(--console-surface)_55%,transparent)] pl-0.5 text-[var(--console-muted)] hover:text-[var(--console-text)] focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-[var(--console-text)]`,onClick:()=>ae(-1),children:(0,L.jsx)(_n,{size:14,"aria-hidden":`true`})}),g.right&&(0,L.jsx)(`button`,{type:`button`,"aria-label":`Scroll timeline right`,className:`absolute inset-y-0 right-0 z-10 flex w-8 items-center justify-end bg-[linear-gradient(to_left,var(--console-surface)_55%,transparent)] pr-0.5 text-[var(--console-muted)] hover:text-[var(--console-text)] focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-[var(--console-text)]`,onClick:()=>ae(1),children:(0,L.jsx)(vn,{size:14,"aria-hidden":`true`})})]}),v&&(0,L.jsx)(`div`,{"data-testid":`session-timeline-minimap`,role:`scrollbar`,"aria-controls":`session-timeline-viewport`,"aria-orientation":`horizontal`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(v.start/(1-v.size)*100),"aria-label":`Timeline scroll position`,tabIndex:0,className:`session-timeline-minimap relative mt-2 h-2.5 cursor-pointer touch-none select-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--console-text)]`,onKeyDown:ne,onPointerDown:e=>{if(e.button!==0)return;let t=e.currentTarget.getBoundingClientRect();if(t.width<=0)return;let n=(e.clientX-t.left)/t.width,r=n>=v.start&&n<=v.start+v.size?n-v.start:v.size/2;u.current={pointerId:e.pointerId,grabOffset:r},e.currentTarget.setPointerCapture(e.pointerId),te(n,r)},onPointerMove:e=>{let t=u.current;if(!t||t.pointerId!==e.pointerId)return;let n=e.currentTarget.getBoundingClientRect();n.width<=0||te((e.clientX-n.left)/n.width,t.grabOffset)},onPointerUp:e=>{u.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)},onPointerCancel:()=>{u.current=null},children:(0,L.jsxs)(`div`,{className:`relative h-full w-full overflow-hidden rounded-[2px]`,children:[(0,L.jsx)(`canvas`,{ref:l,"aria-hidden":`true`,className:`absolute inset-0 h-full w-full`}),(0,L.jsx)(`div`,{"data-testid":`session-timeline-minimap-window`,className:`session-timeline-minimap-window absolute inset-y-0`,style:{left:`${v.start*100}%`,width:`${v.size*100}%`}})]})}),m&&(0,Ad.createPortal)((0,L.jsx)(`span`,{ref:a,id:m.id,role:`tooltip`,className:`t-tt session-timeline-floating-tooltip console-mono text-[11px]`,style:{left:m.anchorX,top:m.top},children:m.text}),document.body)]})})}function qd({anchorId:e,behavior:t,prepareAnchor:n,isCurrent:r}){if(typeof document>`u`)return;let i=Wl(t,window.matchMedia(`(prefers-reduced-motion: reduce)`).matches),a=document.getElementById(e);if(!a&&n){n();let t=0,o=()=>{if(r()){if(a=document.getElementById(e),a){a.scrollIntoView({behavior:i,block:`center`});return}t+=1,t<8&&requestAnimationFrame(o)}};requestAnimationFrame(o);return}a&&a.scrollIntoView({behavior:i,block:`center`})}function Jd(e,t){if(!tn())return t();let n=performance.now(),r=t(),i=performance.now();return an({id:e,source:`custom-timing`,phase:`measure`,actualDuration:Math.round((i-n)*100)/100,baseDuration:0,startTime:n,commitTime:i}),r}function Yd({session:e,agentCatalog:t,highlightQuery:n}){let r=e.reference.agentName,i=ji(t,r),a=(0,P.useMemo)(()=>Jd(`SessionDetail:buildDisplayModel`,()=>Vl({messages:e.messages,agentName:r,fileActivity:e.file_activity})),[e.file_activity,e.messages,r]),{messages:o,toc:s,fileChangeSummary:c}=a,[l,u]=(0,P.useState)(()=>new Set(s.filterIds)),[d,f]=(0,P.useState)(null),p=(0,P.useMemo)(()=>[...s.filterIds].toSorted().join(`|`),[s.filterIds]),m=(0,P.useMemo)(()=>[...l].toSorted().join(`|`),[l]),h=(0,P.useMemo)(()=>Jd(`SessionDetail:selectDisplayModel`,()=>a.select(l)),[a,l]),{messages:g,timelineEntries:_}=h,v=(0,P.useRef)(null),y=(0,P.useRef)(0),b=(0,P.useCallback)((e,t,n)=>{let r=y.current+1;y.current=r;let i=t==null?void 0:h.resolveListIndex(t);qd({anchorId:e,behavior:n,prepareAnchor:i==null?void 0:()=>v.current?.scrollToIndex(i),isCurrent:()=>y.current===r})},[h]),x=(0,P.useCallback)((e,t)=>{b(e,a.resolveMessageIndex(e),t)},[a,b]);return(0,P.useEffect)(()=>{u(new Set(s.filterIds))},[p,s.filterIds]),o.length===0?(0,L.jsx)(`div`,{"data-testid":`session-detail`,className:`mx-auto max-w-4xl rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] p-6 text-sm text-[var(--console-muted)]`,children:`当前会话暂无可展示的消息内容。`}):(0,L.jsxs)(`div`,{"data-testid":`session-detail`,className:`mx-auto w-full max-w-[1440px] space-y-8 px-2 md:px-4`,children:[(0,L.jsx)(Xd,{summary:typeof e.summary_files==`string`?e.summary_files:void 0}),(0,L.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,L.jsx)(Od,{toc:s,fileChangeSummary:c,onOpen:f}),(0,L.jsx)(kd,{openPanel:d,toc:s,fileChangeSummary:c,baseDirectory:e.directory,selectedFilters:l,onClose:()=>f(null),onToggle:e=>u(t=>Zl(t,e,s)),onJumpToAnchor:(e,t)=>{f(null),x(e,t)}}),(0,L.jsx)($l,{toc:s,fileChangeSummary:c,baseDirectory:e.directory,selectedFilters:l,onToggle:e=>u(t=>Zl(t,e,s)),onJumpToAnchor:x}),(0,L.jsx)(`div`,{className:`flex min-w-0 flex-col gap-8`,children:g.length>0?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Kd,{entries:_,onNavigate:(e,t)=>b(e.anchorId,e.messageIndex,t)}),(0,L.jsx)(sn,{id:`MessageList`,detail:{messages:g.length,virtualized:g.length>80},children:(0,L.jsx)(Ku,{messages:g,sessionAgentKey:r,agent:i,baseDirectory:e.directory,highlightQuery:n,apiRef:v},`${e.id}:${m}`)})]}):(0,L.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] p-6 text-sm text-[var(--console-muted)]`,children:`当前筛选条件下暂无可展示的消息内容。`})})]}),(0,L.jsx)(Dd,{session:e,toc:s})]})}function Xd({summary:e,defaultExpanded:t=!1}){let n=typeof e==`string`?e.trim():``,[r,i]=(0,P.useState)(t);return n?(0,L.jsxs)(`section`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:[(0,L.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,L.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,L.jsx)(On,{className:`size-3.5 text-[var(--console-accent)]`}),`Session Summary`]}),r?(0,L.jsx)(yn,{className:`size-3.5 text-[var(--console-muted)]`}):(0,L.jsx)(gn,{className:`size-3.5 text-[var(--console-muted)]`})]}),r?(0,L.jsx)(`div`,{className:`border-t border-[var(--console-border)] px-4 py-4`,children:(0,L.jsx)(`div`,{className:`console-markdown text-sm leading-relaxed text-[var(--console-text)]`,children:(0,L.jsx)(Xo,{text:n})})}):null]}):null}var Zd=[{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 Qd({className:e}){return(0,L.jsx)(`div`,{className:`rounded-sm bg-[var(--console-border)] ${e}`})}function $d(){return(0,L.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,L.jsx)(`div`,{className:`flex flex-1 flex-col gap-8`,children:Zd.map(e=>(0,L.jsx)(`article`,{className:`w-full border-l-2 border-[var(--console-thread)] pl-4 pr-3 md:pr-5`,children:(0,L.jsxs)(`div`,{className:`flex gap-4`,children:[(0,L.jsx)(`div`,{className:`shrink-0 pt-1`,children:(0,L.jsx)(`div`,{className:`flex size-8 items-center justify-center rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)]`,children:(0,L.jsx)(`div`,{className:`size-3.5 rounded-sm bg-[var(--console-border-strong)] animate-pulse motion-reduce:animate-none`})})}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(Qd,{className:`${e.roleWidth} h-3 animate-pulse motion-reduce:animate-none`}),(0,L.jsx)(Qd,{className:`${e.timeWidth} h-2.5 animate-pulse motion-reduce:animate-none`})]}),(0,L.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] p-4 shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:(0,L.jsx)(`div`,{className:`space-y-2`,children:e.bodyWidths.map(t=>(0,L.jsx)(Qd,{className:`${t} h-3 animate-pulse motion-reduce:animate-none`},`${e.id}-${t}`))})})]})]})},e.id))}),(0,L.jsx)(`div`,{className:`min-h-24 flex-1 rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)]/60 animate-pulse motion-reduce:animate-none`})]})}var ef={recent:`Recent`,title:`Title`,user_message:`User message`,assistant_reply:`Assistant reply`,tool_output:`Tool output`,file_path:`File path`};function tf(e){return e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`).replaceAll(`"`,`"`).replaceAll(`'`,`'`).replaceAll(`<mark>`,`<mark>`).replaceAll(`</mark>`,`</mark>`)}function nf({query:e,state:t,agentNameMap:n,agents:r,projects:i,filters:a,onChangeFilters:o,onOpenResult:s,onRetry:c,selectedIndex:l,registerResultRef:u}){let d=t.status===`loaded`?t.results:[],f=(0,L.jsx)(Vr,{agents:r,projects:i,filters:a,onChangeFilters:o});return t.status===`loading`?(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[f,(0,L.jsx)(`p`,{className:`sr-only`,"aria-live":`polite`,children:`Searching…`}),(0,L.jsx)(`div`,{className:`grid gap-3`,children:Array.from({length:4}).map((e,t)=>(0,L.jsxs)(`div`,{className:`animate-pulse rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)]/80 p-4 motion-reduce:animate-none`,children:[(0,L.jsx)(`div`,{className:`h-3 w-32 rounded bg-[var(--console-surface-muted)]`}),(0,L.jsx)(`div`,{className:`mt-3 h-4 w-2/3 rounded bg-[var(--console-surface-muted)]`}),(0,L.jsx)(`div`,{className:`mt-2 h-3 w-full rounded bg-[var(--console-surface-muted)]`}),(0,L.jsx)(`div`,{className:`mt-1 h-3 w-5/6 rounded bg-[var(--console-surface-muted)]`})]},t))})]}):t.status===`failed`?(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[f,(0,L.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-error-border)] bg-[var(--console-error-bg)] p-6`,"aria-live":`polite`,children:[(0,L.jsx)(`h2`,{className:`console-mono text-sm font-semibold text-[var(--console-error)]`,children:`Search Failed`}),(0,L.jsxs)(`p`,{className:`console-mono mt-2 break-words text-xs text-[var(--console-error)]`,children:[t.error,`. Check the server connection, then try again.`]}),(0,L.jsx)(`button`,{type:`button`,onClick:c,className:`console-mono motion-hover motion-press mt-4 rounded-sm border border-[var(--console-error-border)] bg-[var(--console-surface)] px-3 py-1.5 text-xs font-semibold text-[var(--console-error)] hover:bg-[var(--console-error-bg)] focus-visible:ring-2 focus-visible:ring-[var(--console-error)] focus-visible:ring-offset-2 focus-visible:outline-none`,children:`Retry Search`})]})]}):d.length===0?(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[f,(0,L.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)]/80 p-6`,children:[(0,L.jsx)(`h2`,{className:`console-mono text-sm font-semibold text-[var(--console-text)]`,children:e?`No matches`:`No recent sessions`}),e?(0,L.jsxs)(`p`,{className:`console-mono mt-2 text-xs text-[var(--console-muted)]`,children:[`Query: `,e]}):null]})]}):(0,L.jsxs)(`div`,{className:`grid gap-3`,children:[f,(0,L.jsx)(`div`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:`Navigate j k · Open Enter · Exit Esc`}),d.map((t,r)=>{let i=t.reference.agentName.toLowerCase(),a=n.get(i)??t.reference.agentName,o=`${t.reference.agentName}/${t.reference.sessionId}`;return(0,L.jsxs)(M,{ref:e=>u(o,e),to:`/${i}/${t.reference.sessionId}`,state:{searchQuery:e},onClick:s,className:`rounded-sm border bg-[var(--console-surface)]/85 p-4 motion-hover hover:border-[var(--console-border-strong)] hover:bg-[var(--console-surface)] focus-visible:ring-2 focus-visible:ring-[var(--console-accent)] focus-visible:ring-offset-2 focus-visible:outline-none ${r===l?`border-[var(--console-border-strong)]`:`border-[var(--console-border)]`}`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.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,L.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-1.5 py-0.5 text-[10px] uppercase text-[var(--console-muted)]`,children:ef[t.matchType]}),(0,L.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:t.session.directory})]}),(0,L.jsx)(`h2`,{className:`console-mono mt-3 text-sm font-semibold text-[var(--console-text)]`,children:H(t.session)}),(0,L.jsx)(Fr,{tags:t.session.smart_tags,className:`mt-2`}),(0,L.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 dark:[&_mark]:text-[var(--console-bg)]`,dangerouslySetInnerHTML:{__html:tf(t.snippet||H(t.session))}})]},o)})]})}function rf({loading:e,error:t,viewState:n,detailHighlightQuery:r,agents:i,agentCatalog:a,agentNameMap:o,projects:s,landingSessions:c,sessionsByAgent:l,activeProject:u,activeProjectSessions:d,dashboard:f,sessionDetail:p,projectDashboard:m,search:h,bookmarks:g}){let _=(0,P.useMemo)(()=>i.map(e=>({key:e.name.toLowerCase(),name:e.displayName,icon:e.icon,iconColored:e.iconColored,count:e.count})),[i]);return e?(0,L.jsx)($d,{}):h.active?(0,L.jsx)(sn,{id:`SearchResultsPanel`,detail:{results:h.state.status===`loaded`?h.state.results.length:0,loading:h.state.status===`loading`},children:(0,L.jsx)(nf,{query:h.query,state:h.state,agentNameMap:o,agents:i,projects:h.projectOptions,filters:h.filters,onChangeFilters:h.onChangeFilters,onOpenResult:h.onClose,onRetry:h.onRetry,selectedIndex:h.selectedIndex,registerResultRef:h.registerResultRef})}):t?(0,L.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:t}):n.mode===`root`?f?(0,L.jsx)(sn,{id:`Dashboard`,detail:{sessions:f.totals.sessions,projects:s.length},children:(0,L.jsx)(ko,{data:f,agentCatalog:a,projects:s,bookmarkedSessions:g.sessions,isBookmarked:g.isBookmarked,onToggleBookmark:e=>{if(!(`bookmarkedAt`in e)){g.toggleSessionBookmark(e.session,e.reference.agentName);return}g.toggleBookmark(e)}})}):(0,L.jsx)(Io,{type:`global`,agentCatalog:a,sessions:c,agentItems:_,isBookmarked:g.isBookmarked,onToggleBookmark:e=>g.toggleSessionBookmark(e,e.agentKey)}):n.mode===`projects`?(0,L.jsx)(Ho,{projects:s,agentCatalog:a}):n.mode===`project`?(0,L.jsx)(Ko,{project:u,agentCatalog:a,projectKey:n.activeProjectKey,dashboard:m.dashboard,loading:m.loading,error:m.error,sessions:d,activeAgent:m.selectedAgent,onChangeAgent:m.onChangeAgent,isBookmarked:g.isBookmarked,onToggleSessionBookmark:g.toggleSessionBookmark}):n.mode===`agent`?(0,L.jsx)(Io,{type:`agent`,agentCatalog:a,sessions:l.get(n.activeAgentKey)??[],agentItems:_,activeAgentKey:n.activeAgentKey,isBookmarked:g.isBookmarked,onToggleBookmark:e=>g.toggleSessionBookmark(e,e.agentKey)}):n.mode===`session`?p.loading?(0,L.jsx)($d,{}):p.error||!p.session?(0,L.jsx)(Io,{type:`missing-session`,agentCatalog:a,sessions:l.get(n.activeAgentKey)??[],agentItems:_,activeAgentKey:n.activeAgentKey,attemptedSessionId:n.activeSessionId,isBookmarked:g.isBookmarked,onToggleBookmark:e=>g.toggleSessionBookmark(e,e.agentKey)}):(0,L.jsx)(sn,{id:`SessionDetail`,detail:{messages:p.session.messages.length,session:p.session.id},children:(0,L.jsx)(Yd,{session:p.session,agentCatalog:a,highlightQuery:r})}):n.mode===`missingAgent`?(0,L.jsx)(Io,{type:`missing-agent`,agentCatalog:a,sessions:c,agentItems:_,attemptedAgentKey:n.attemptedKey,isBookmarked:g.isBookmarked,onToggleBookmark:e=>g.toggleSessionBookmark(e,e.agentKey)}):(0,L.jsx)(`div`,{className:`text-sm text-[var(--console-muted)]`,children:`Invalid route.`})}function af(){let e=ve(),t=Ri(),n=aa(t.config?.window),{timeWindow:r}=n,{activeAgents:i,agentCatalog:a,sessions:o,projects:s,dashboard:c,window:l,validAgentKeys:u,agentNameMap:d,loading:f,error:p,reload:m,applyLiveEvent:h,resyncLiveState:g}=t;Bi({window:r,reload:m});let[_,v]=(0,P.useState)(null),{scanStatus:y,setScanStatus:b}=Er(),[x,S]=(0,P.useState)(null),[C,w]=(0,P.useState)(!1),{shortcutHintDismissed:T,sidebarCollapsed:E,theme:ee,dismissShortcutHint:D,setSidebarCollapsed:O,setTheme:te}=ga(),ne=ba(ee),[k,re]=(0,P.useState)(null),ie=We(),ae=ke(),A=(0,P.useMemo)(()=>Tr(ae,u),[ae,u]),oe=Ar(A),{session:se,sessionError:ce}=oe;(0,P.useEffect)(()=>{I(`route.change`,{path:ie.pathname,mode:A.mode,agent:A.activeAgentKey,session:A.activeSessionId})},[ie.pathname,A.mode,A.activeAgentKey,A.activeSessionId]),(0,P.useEffect)(()=>{A.mode===`project`&&v({kind:A.activeProjectKind,key:A.activeProjectKey})},[A]);let le=(0,P.useMemo)(()=>ni(o,i),[o,i]),j=li(le,l),{draftSearchQuery:ue,activeSearchQuery:de,searchMode:fe,searchState:pe,searchResults:me,searchLoading:he,selectedSearchIndex:ge,searchInputRef:_e,setDraftSearchQuery:ye,setSelectedSearchIndex:be,openSearch:xe,submitSearch:Se,closeSearch:Ce}=j,we=fe,Te=we?de:typeof ie.state==`object`&&ie.state!==null&&`searchQuery`in ie.state&&typeof ie.state.searchQuery==`string`?ie.state.searchQuery:``,Ee=wi(o),{bookmarkedSessions:De,isSessionBookmarked:Oe,toggleBookmark:Ae,toggleSessionBookmark:je,refresh:Me}=Ee,Ne=A.mode===`project`?A.activeProjectKind:null,Pe=A.mode===`project`?A.activeProjectKey:null,Fe=Ti(l,(0,P.useMemo)(()=>({projectKind:Ne??void 0,projectKey:Pe??void 0,identityKey:Ne&&Pe?Sr({kind:Ne,key:Pe}):void 0}),[Pe,Ne])),{browseBy:Ie,selectBrowseBy:Le,activeAgentKey:Re,activeAgent:ze,activeProject:Be,activeProjectSessions:Ve,openedSessionProjectIdentity:He,selectedProjectNavigation:Ue,sidebarSessions:Ge,sidebarSessionLookup:Ke,bookmarkedSidebarSessionReferences:qe}=ki({viewState:A,sessionIndexes:le,session:se,agents:i,projects:s,selectedProjectAgent:Fe.selectedAgent,isSessionBookmarked:Oe}),Je=Ue?.identity??null,Ye=Ue?.identityKey??null,Xe=(0,P.useCallback)(t=>{S(B(t)),e(`/${t.slug}`)},[e]),Ze=(0,P.useCallback)(e=>{je(e,Gr(e))},[je]),Qe=(0,P.useCallback)(e=>{re({agentKey:Gr(e),sessionId:e.id,title:e.title,displayTitle:e.display_title})},[]),$e=(0,P.useCallback)(e=>{re({agentKey:e.reference.agentName,sessionId:e.reference.sessionId,title:e.session.title,displayTitle:e.session.display_title})},[]),et=(0,P.useCallback)(t=>{S(B(t)),e(`/${t.slug}`)},[e]),tt=dr(y),nt=y?[y.phase,y.scanningAgents[0]??``,y.completedAgents.length,y.totalAgents,y.backfill.active,y.backfill.currentAgent??``,y.backfill.pendingAgents.length,y.backfill.failedAgents.length].join(`|`):null,[rt,it]=(0,P.useState)(nt),[at,ot]=(0,P.useState)(tt);nt!==rt&&(it(nt),ot(tt));let st=y?.active===!0,{liveNotice:ct}=Vi({applyLiveEvent:h,resyncLiveState:g,setScanStatus:b}),{saveAlias:lt,removeAlias:ut}=zi((0,P.useCallback)(async()=>{await Promise.all([r?m(r):void 0,Me()])},[Me,m,r])),dt=(0,P.useCallback)(async e=>{k&&await lt(k,e)},[k,lt]),ft=(0,P.useCallback)(async()=>{k&&await ut(k)},[k,ut]);(0,P.useEffect)(()=>{if(!we){if(A.mode===`session`){S(Jr(A.activeAgentKey,A.activeSessionId));return}if(A.mode===`agent`){S(null);return}S(null)}},[we,A.mode,A.activeAgentKey,A.activeSessionId,Ge]);let pt=Ea({viewState:A,browseBy:Ie,isSearchMode:we,searchSubtitle:pe.status===`failed`?`Search failed for "${de}"`:ur(de,he,me.length),dashboard:c,projects:s,sessionCount:o.length,activeProject:Be?.project??null,activeAgent:ze,sidebarSessionCount:Ge.length,session:se,sessionError:ce,selectedProjectIdentity:Je,selectedProject:Ue?.project??null}),mt=(0,L.jsx)(rf,{loading:f,error:p,viewState:A,detailHighlightQuery:Te,agents:i,agentCatalog:a,agentNameMap:d,projects:s,landingSessions:le.landingSessions,sessionsByAgent:le.byLandingAgent,activeProject:Be?.project??null,activeProjectSessions:Ve,dashboard:c,sessionDetail:{session:oe.session,loading:oe.sessionLoading,error:oe.sessionError},projectDashboard:{dashboard:Fe.dashboard,loading:Fe.loading,error:Fe.error,selectedAgent:Fe.selectedAgent,onChangeAgent:Fe.setSelectedAgent},search:{active:j.searchMode,query:j.activeSearchQuery,state:j.searchState,projectOptions:j.projectOptions,filters:j.searchFilters,onChangeFilters:j.setSearchFilters,onClose:j.closeSearch,onRetry:j.retrySearch,selectedIndex:j.selectedSearchIndex,registerResultRef:j.registerResultRef},bookmarks:{sessions:Ee.bookmarkedSessions,isBookmarked:Ee.isSessionBookmarked,toggleBookmark:Ee.toggleBookmark,toggleSessionBookmark:Ee.toggleSessionBookmark}});function ht(t){if(!(t===`projects`&&st)){if(Le(t),S(null),t===`projects`){let t=He??(A.mode===`session`?null:_);e(t?Cr(t):`/projects`);return}e(`/`)}}return Ui({viewState:A,browseBy:Ie,navigate:e,activeAgentKey:Re,sidebarSessions:Ge,sidebarSessionLookup:Ke,selectedSidebarSessionReference:x,setSelectedSidebarSessionReference:S,selectedProjectNavigationIdentity:Je,shortcutHelpOpen:C,setShortcutHelpOpen:w,dismissShortcutHint:D,isSearchMode:we,activeSearchQuery:de,searchResults:me,selectedSearchIndex:ge,setSelectedSearchIndex:be,setDraftSearchQuery:ye,openSearch:xe,closeSearch:Ce}),(0,L.jsx)(_a.Provider,{value:ne,children:(0,L.jsxs)(`div`,{className:`console-ui flex h-screen flex-col overflow-hidden bg-[var(--console-bg)] text-[var(--console-text)]`,children:[(0,L.jsx)(`a`,{href:`#main`,className:`console-mono sr-only rounded-sm border border-[var(--console-border-strong)] bg-[var(--console-surface)] px-3 py-1.5 text-xs text-[var(--console-text)] focus:not-sr-only focus:fixed focus:top-2 focus:left-2 focus:z-[60] focus-visible:ring-2 focus-visible:ring-[var(--console-accent)] focus-visible:ring-offset-2 focus-visible:outline-none`,children:`Skip to content`}),(0,L.jsx)(`header`,{className:`shrink-0 border-b border-[var(--console-border)] bg-[var(--console-surface)]/85 backdrop-blur-sm`,children:(0,L.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,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,"aria-expanded":!E,"aria-label":E?`Expand sidebar`:`Collapse sidebar`,title:E?`Expand sidebar`:`Collapse sidebar`,onClick:()=>O(!E),className:`hidden rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] p-1.5 text-[var(--console-muted)] motion-hover hover:bg-[var(--console-surface-muted)] hover:text-[var(--console-text)] lg:inline-flex`,children:E?(0,L.jsx)(Hn,{className:`size-4`}):(0,L.jsx)(Vn,{className:`size-4`})}),(0,L.jsxs)(M,{to:`/`,className:`flex items-center gap-2 text-[var(--console-text)]`,children:[(0,L.jsx)(`img`,{src:`/logo.svg?v=3`,alt:`CodeSesh`,className:`h-6 w-6 rounded-sm`}),(0,L.jsx)(`span`,{className:`console-mono text-sm font-semibold uppercase tracking-[0.05em]`,children:`CodeSesh`})]})]}),(0,L.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(),Se()},children:[(0,L.jsxs)(`label`,{className:`flex min-w-0 flex-1 items-center rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-2 py-1 focus-within:border-[var(--console-border-strong)] focus-within:ring-2 focus-within:ring-[var(--console-accent)] focus-within:ring-offset-2`,children:[(0,L.jsx)(`span`,{className:`sr-only`,children:`Search Sessions`}),(0,L.jsx)(`input`,{ref:_e,type:`search`,name:`session-search`,autoComplete:`off`,value:ue,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,L.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)] motion-hover hover:bg-[var(--console-surface)] focus-visible:ring-2 focus-visible:ring-[var(--console-accent)] focus-visible:ring-offset-2 focus-visible:outline-none`,children:`Search`})]}),(0,L.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,L.jsx)(no,{theme:ee,onChange:te}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{w(!0),D()},className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-2 py-1 text-xs text-[var(--console-text)] motion-hover hover:bg-[var(--console-surface-muted)]`,title:`Show keyboard shortcuts`,children:[`?`,(0,L.jsx)(`span`,{className:`hidden sm:inline`,children:` Shortcuts`})]}),r&&n.preset?(0,L.jsx)(mr,{window:r,preset:n.preset,customFrom:n.customFrom,customTo:n.customTo,onSelectPreset:n.selectPreset,onSelectCustom:n.selectCustom}):null,(0,L.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.17.0`]})]})]})}),(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,L.jsx)(Xa,{model:{sidebarCollapsed:E,browseBy:Ie,isScanActive:st,viewState:A,agents:i,agentCatalog:a,activeAgentKey:Re,scanStatus:y,projects:s,selectedProjectNavigationId:Ye,loading:f,bookmarkedSessions:De,sidebarSessions:Ge,selectedSidebarSessionReference:x,bookmarkedSidebarSessionReferences:qe},actions:{onChangeBrowseBy:ht,onSelectProject:v,onToggleBookmark:Ae,onSelectFlatSidebarSession:Xe,onToggleSidebarSessionBookmark:Ze,onRenameSession:Qe,onRenameBookmarkedSession:$e,onSelectTreeSidebarSession:et}}),(0,L.jsxs)(`main`,{id:`main`,tabIndex:-1,className:`flex min-w-0 flex-1 flex-col outline-none`,children:[(0,L.jsx)(`section`,{className:`shrink-0 border-b border-[var(--console-border)] bg-[var(--console-surface)]/70 px-4 py-4 backdrop-blur-sm md:px-8`,children:(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`nav`,{"aria-label":`Breadcrumb`,className:`console-mono mb-2 flex flex-wrap items-center gap-1 text-[11px] text-[var(--console-muted)]`,children:pt.breadcrumbs.map((e,t)=>(0,L.jsxs)(`span`,{className:`flex items-center gap-1`,children:[e.to?(0,L.jsx)(M,{to:e.to,className:`motion-hover hover:text-[var(--console-text)]`,children:e.label}):(0,L.jsx)(`span`,{className:`text-[var(--console-text)]`,children:e.label}),t<pt.breadcrumbs.length-1?(0,L.jsx)(`span`,{children:`/`}):null]},`${e.label}-${t}`))}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.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:pt.contextLabel}),(0,L.jsx)(`h1`,{className:`console-mono text-xl font-semibold tracking-tight text-[var(--console-text)]`,children:pt.title})]}),(0,L.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:pt.subtitle}),(0,L.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[T?null:(0,L.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,L.jsx)(`span`,{children:`Keyboard navigation available`}),(0,L.jsx)(`span`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-1`,children:`?`}),(0,L.jsx)(`button`,{type:`button`,onClick:D,className:`text-[var(--console-muted)] motion-hover hover:text-[var(--console-text)]`,"aria-label":`Dismiss keyboard shortcuts hint`,children:`×`})]}),!we&&A.mode===`session`?(0,L.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,!we&&A.mode===`session`&&se?(0,L.jsx)(or,{resumeCommandPrefix:ji(a,A.activeAgentKey)?.resumeCommandPrefix??null,sessionId:se.id,directory:se.directory}):null]}),(0,L.jsx)(`div`,{"aria-live":`polite`,children:ct?(0,L.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:ct}):null}),(0,L.jsx)(`div`,{children:tt&&A.mode===`root`?(0,L.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:tt}):null}),(0,L.jsx)(`div`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:A.mode===`root`?at:null})]})}),(0,L.jsx)(`section`,{className:`console-scrollbar bg-grid min-h-0 flex-1 overflow-y-auto px-4 py-6 md:px-8`,children:(0,L.jsx)(nr,{children:(0,L.jsx)(sn,{id:`MainContent`,detail:{mode:A.mode,search:we,sessions:o.length},children:mt})})})]})]}),(0,L.jsx)(Qa,{open:C,onClose:()=>w(!1)}),(0,L.jsx)(sr,{target:k,onClose:()=>re(null),onSave:dt,onRemove:ft})]})})}function of(){let e=ze();return(0,L.jsx)(`div`,{role:`alert`,children:Le(e)?`${e.status} ${e.statusText}`:`The application route failed to render.`})}var sf=Je([{id:`app-shell`,path:`/`,Component:af,ErrorBoundary:of,loader:vr,children:gr}]);function cf(){return(0,L.jsx)(x,{router:sf})}kt(),Tt.createRoot(document.getElementById(`root`)).render((0,L.jsx)(P.StrictMode,{children:(0,L.jsx)(Ce,{client:un,children:(0,L.jsx)(sn,{id:`App`,children:(0,L.jsx)(cf,{})})})}));
|