codesesh 0.7.1 → 0.8.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.
@@ -0,0 +1,108 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{l as t,t as n,u as r}from"./markdown-Bm__FT1K.js";import{n as i,r as a,t as o}from"./react-CGUTVnhO.js";import{A as s,C as c,D as l,E as u,M as d,N as f,O as p,S as m,T as h,_ as g,a as _,b as v,c as ee,d as y,f as te,g as ne,h as b,i as re,j as x,k as S,l as ie,m as ae,n as oe,o as se,p as ce,r as le,s as ue,t as de,u as C,v as w,w as fe,x as T,y as pe}from"./vendor-DWjfsTQM.js";import{C as E,S as me,_ as D,a as he,b as ge,c as _e,d as O,f as ve,g as k,h as ye,i as be,l as xe,m as A,n as Se,o as Ce,p as j,r as we,s as Te,t as Ee,u as De,v as Oe,x as ke,y as Ae}from"./syntax-Cjw-OADI.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 M=e(r(),1),je=e(a(),1),N={agents:{opencode:{name:`OpenCode`,icon:`/icon/agent/opencode.svg`},codex:{name:`Codex`,icon:`/icon/agent/codex.svg`},cursor:{name:`Cursor`,icon:`/icon/agent/cursor.svg`},kimi:{name:`Kimi-Cli`,icon:`/icon/agent/kimi.svg`},claudecode:{name:`Claude Code`,icon:`/icon/agent/claudecode.svg`},kilo:{name:`Kilo Code`,icon:`/icon/agent/kilocode.svg`},antigravity:{name:`Antigravity`,icon:`/icon/agent/antigravity.svg`}},getDefaultAgentKey(){let e=Object.keys(this.agents);return e.length>0?e[0]:null},getAgentName(e){let t=this.agents[e];return t||=this.agents[e.toLowerCase()],t?t.name:e}};async function Me(){let e=await fetch(`/api/config`);if(!e.ok)throw Error(`Failed to fetch config`);return e.json()}async function Ne(){let e=await fetch(`/api/status`);if(!e.ok)throw Error(`Failed to fetch scan status`);return e.json()}async function Pe(){let e=await fetch(`/api/agents`);if(!e.ok)throw Error(`Failed to fetch agents`);return e.json()}async function Fe(){let e=await fetch(`/api/projects`);if(!e.ok)throw Error(`Failed to fetch projects`);return e.json()}async function Ie(e={}){let t=new URLSearchParams;e.agent&&t.set(`agent`,e.agent),e.projectKey&&t.set(`projectKey`,e.projectKey),e.from!=null&&t.set(`from`,new Date(e.from).toISOString()),e.to!=null&&t.set(`to`,new Date(e.to).toISOString());let n=await fetch(`/api/sessions?${t}`);if(!n.ok)throw Error(`Failed to fetch sessions`);return n.json()}async function Le(e,t){let n=await fetch(`/api/sessions/${e}/${t}`);if(!n.ok)throw Error(`Failed to fetch session data`);return n.json()}async function Re(e,t={}){let n=new URLSearchParams;e?.from!=null&&n.set(`from`,new Date(e.from).toISOString()),e?.to!=null&&n.set(`to`,new Date(e.to).toISOString()),e?.days!=null&&e.days>0&&n.set(`days`,String(e.days)),t.projectKind&&n.set(`projectKind`,t.projectKind),t.projectKey&&n.set(`projectKey`,t.projectKey),t.agent&&n.set(`agent`,t.agent);let r=n.toString(),i=await fetch(r?`/api/dashboard?${r}`:`/api/dashboard`);if(!i.ok)throw Error(`Failed to fetch dashboard`);return i.json()}async function ze(e,t={}){let n=new URLSearchParams;n.set(`q`,e),t.agent&&n.set(`agent`,t.agent),t.projectKey&&n.set(`projectKey`,t.projectKey),t.tag&&n.set(`tag`,t.tag),t.tool&&n.set(`tool`,t.tool),t.fileKind&&n.set(`fileActivity`,t.fileKind),t.costMin!=null&&n.set(`costMin`,String(t.costMin)),t.costMax!=null&&n.set(`costMax`,String(t.costMax));let r=await fetch(`/api/search?${n}`);if(!r.ok)throw Error(`Failed to fetch search results`);return r.json()}async function Be(){let e=await fetch(`/api/bookmarks`);if(!e.ok)throw Error(`Failed to fetch bookmarks`);return e.json()}async function Ve(e){let t=await fetch(`/api/bookmarks`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(`Failed to save bookmark`);return t.json()}async function He(e){let t=await fetch(`/api/bookmarks/import`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(`Failed to import bookmarks`);return t.json()}async function Ue(e,t){if(!(await fetch(`/api/bookmarks/${e}/${t}`,{method:`DELETE`})).ok)throw Error(`Failed to delete bookmark`)}function P(e,t={}){let n=JSON.stringify({event:e,data:t});try{if(typeof navigator<`u`&&navigator.sendBeacon){let e=new Blob([n],{type:`application/json`});if(navigator.sendBeacon(`/api/logs`,e))return}}catch{}fetch(`/api/logs`,{method:`POST`,headers:{"Content-Type":`application/json`},body:n,keepalive:!0}).catch(()=>{})}function We(e,t){let n=new EventSource(`/api/events`);return n.addEventListener(`sessions-updated`,t=>{try{e(JSON.parse(t.data))}catch(e){console.error(`Failed to parse session update event:`,e)}}),n.addEventListener(`scan-status`,e=>{if(t)try{t(JSON.parse(e.data))}catch(e){console.error(`Failed to parse scan status event:`,e)}}),n.onerror=()=>{n.readyState!==EventSource.CLOSED&&console.warn(`Session update stream disconnected`)},()=>{n.close()}}function F(...e){return _(se(e))}var I=t(),Ge={bugfix:`bugfix`,refactoring:`refactoring`,"feature-dev":`feature-dev`,testing:`testing`,docs:`docs`,"git-ops":`git-ops`,"build-deploy":`build-deploy`,exploration:`exploration`,planning:`planning`},Ke={bugfix:{text:`#B42318`,border:`#FECDCA`,background:`#FEF3F2`,bar:`#F04438`},refactoring:{text:`#6941C6`,border:`#D9D6FE`,background:`#F4F3FF`,bar:`#7A5AF8`},"feature-dev":{text:`#175CD3`,border:`#B2DDFF`,background:`#EFF8FF`,bar:`#2E90FA`},testing:{text:`#027A48`,border:`#ABEFC6`,background:`#ECFDF3`,bar:`#12B76A`},docs:{text:`#B54708`,border:`#FEDF89`,background:`#FFFAEB`,bar:`#F79009`},"git-ops":{text:`#3538CD`,border:`#C7D7FE`,background:`#EEF4FF`,bar:`#444CE7`},"build-deploy":{text:`#C4320A`,border:`#F9DBAF`,background:`#FEF6EE`,bar:`#EF6820`},exploration:{text:`#0E7090`,border:`#A5F0FC`,background:`#ECFDFF`,bar:`#06AED4`},planning:{text:`#C11574`,border:`#FCCEEE`,background:`#FDF2FA`,bar:`#EE46BC`}};function L(e){return Ke[e]}function R(e){let t=L(e);return{color:t.text,borderColor:t.border,backgroundColor:t.background}}function qe({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,I.jsxs)(`div`,{className:`flex flex-wrap gap-1 ${n}`,children:[r.map(e=>(0,I.jsx)(`span`,{className:`console-mono rounded-sm border px-1.5 py-0.5 text-[10px] font-medium`,style:R(e),children:Ge[e]},e)),i>0?(0,I.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 Je(e,t){return e?Math.abs(e.receiptWidth-t.receiptWidth)>.5||Math.abs(e.receiptHeight-t.receiptHeight)>.5||Math.abs(e.startX-t.startX)>.5||Math.abs(e.startY-t.startY)>.5:!0}var z=18,B=42,Ye=5,V=270,H=500,U=2;function Xe(e){return Math.round(e??0).toLocaleString(`en-US`)}function Ze(e){return`$${(e??0).toFixed(4)}`}function Qe(e){return new Date(e).toLocaleString(`en-US`,{month:`short`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`})}function $e(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 et(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 tt(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 nt(e){return!e||e.length===0?`SESSION ACTIVITY RECEIPT`:e.map(e=>Ge[e]).join(` / `)}function rt(e,t){let n=e.slug?.split(`/`)[0]||`codesesh`;return{id:e.id,title:e.title||`Untitled session`,agent:n,updatedAt:e.time_updated??e.time_created,tags:e.smart_tags,stats:e.stats,items:tt(t)}}function it(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 at(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 W(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(at(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]=at(e,a[a.length-1]??``,n)),a.slice(0,r)}function ot(e){let t=document.createElement(`canvas`);t.width=V*U,t.height=H*U;let n=t.getContext(`2d`);if(!n)return t;n.scale(U,U);let r=n.createLinearGradient(0,0,V,H);r.addColorStop(0,`#ffffff`),r.addColorStop(.55,`#fafaf6`),r.addColorStop(1,`#f2f2ec`),n.fillStyle=r,n.fillRect(0,0,V,H);let i=et($e(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()*V,i()*H,.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`,V/2,34),n.font=`11px 'Courier New', monospace`,n.fillText(at(n,nt(e.tags).toUpperCase(),V-36),V/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(V-18,66),n.stroke(),n.setLineDash([]),n.textAlign=`left`,n.fillStyle=`rgba(0, 0, 0, 0.74)`,n.font=`11px 'Courier New', monospace`,it(n,`Agent`,e.agent,88,V),it(n,`Updated`,Qe(e.updatedAt),104,V),it(n,`Session`,`#${e.id.slice(0,8)}`,120,V),n.setLineDash([2,3]),n.beginPath(),n.moveTo(18,140),n.lineTo(V-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=Xe(t.count);n.fillText(at(n,t.label,168),18,a),n.fillText(e,V-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(V-18,a+5),n.stroke(),a+=26,it(n,`Input tokens`,Xe(e.stats.total_input_tokens),a,V),a+=16,it(n,`Output tokens`,Xe(e.stats.total_output_tokens),a,V),a+=16,it(n,`Messages`,Xe(e.stats.message_count),a,V),a+=22,n.font=`700 13px 'Courier New', monospace`,it(n,`TOTAL COST`,Ze(e.stats.total_cost),a,V),n.strokeStyle=`rgba(0, 0, 0, 0.45)`,n.setLineDash([4,4]),n.beginPath(),n.moveTo(18,a+18),n.lineTo(V-18,a+18),n.stroke(),n.setLineDash([]),n.font=`10px 'Courier New', monospace`,n.textAlign=`center`,n.fillStyle=`rgba(0, 0, 0, 0.62)`,W(n,e.title,V-36,2).forEach((e,t)=>{n.fillText(e,V/2,a+38+t*13)}),t}function G(e,t){return e*z+t}function st(e){let{receiptWidth:t,receiptHeight:n,startX:r,startY:i}=e,a=t/(z-1),o=n/(B-1),s=[],c=[];for(let e=0;e<B;e+=1)for(let t=0;t<z;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<B;e+=1)for(let t=0;t<z;t+=1){let n=G(e,t);t<z-1&&l(n,G(e,t+1),.98),e<B-1&&l(n,G(e+1,t),.92),e<B-1&&t<z-1&&(l(n,G(e+1,t+1),.46),l(G(e+1,t),G(e,t+1),.46)),t<z-2&&l(n,G(e,t+2),.35),e<B-2&&l(n,G(e+2,t),.28)}return{particles:s,constraints:c,receiptWidth:t,receiptHeight:n}}function ct(e,t){let n=t.receiptWidth/(z-1);for(let r=0;r<z;r+=1){let i=e[r];i&&(i.fixedX=t.startX+r*n,i.fixedY=t.startY)}}function lt(e){for(let t=0;t<z;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 ut(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 dt(e,t,n,r,i){let a=n[G(r,i)],o=n[G(r,i+1)],s=n[G(r+1,i)],c=n[G(r+1,i+1)];if(!a||!o||!s||!c)return;let l=i/(z-1)*t.width,u=r/(B-1)*t.height,d=t.width/(z-1),f=t.height/(B-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)/(H/(B-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 ft(e,t,n){let r=null,i=44;for(let a=z;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 pt({session:e,toc:t}){let n=(0,M.useRef)(null),r=(0,M.useRef)(null),i=(0,M.useRef)(null),a=(0,M.useMemo)(()=>rt(e,t),[e,t]);return(0,M.useLayoutEffect)(()=>{let e=n.current,t=r.current,o=i.current;if(!e||!t||!o)return;let s=e.getContext(`2d`,{alpha:!0});if(!s)return;let c={id:null,x:0,y:0,prevX:0,prevY:0,vx:0,vy:0,grabbedIndex:null},l=ot(a),u=0,d=0,f=0,p=st({receiptWidth:V,receiptHeight:H,startX:0,startY:32}),m=performance.now(),h=null,g=0,_=0,v=!1,ee=!0,y=!1,te=window.matchMedia(`(min-width: 1280px)`),ne=()=>te.matches&&document.visibilityState===`visible`&&ee,b=()=>{let e=t.getBoundingClientRect(),n=Math.max(280,e.width||320),r=Math.min(V,n-34);return{receiptWidth:r,receiptHeight:Math.min(H,Math.max(320,f-e.top-42)),startX:e.left+(e.width-r)/2,startY:e.top+32}},re=t=>{v!==t&&(v=t,e.style.visibility=t?`visible`:`hidden`,o.style.visibility=t?`visible`:`hidden`)},x=()=>{y=!1,u&&=(window.cancelAnimationFrame(u),0),re(!1)},S=(e,t=performance.now())=>{p=st(e),h=e,m=t},ie=()=>{let t=window.devicePixelRatio||1;d=Math.max(1,window.innerWidth),f=Math.max(1,window.innerHeight),e.width=Math.floor(d*t),e.height=Math.floor(f*t),s.setTransform(t,0,0,t,0,0),g=0,_=0,re(!1),S(b()),ne()&&ae()},ae=()=>{y||!ne()||(y=!0,u=window.requestAnimationFrame(E))},oe=()=>{ne()?ie():x()},se=e=>({x:e.clientX,y:e.clientY}),ce=e=>{if(e.button!==0)return;let t=se(e),n=ft(p.particles,t.x,t.y);n!=null&&(e.preventDefault(),o.setPointerCapture(e.pointerId),c.id=e.pointerId,c.x=t.x,c.y=t.y,c.prevX=t.x,c.prevY=t.y,c.vx=0,c.vy=0,c.grabbedIndex=n,_=0,ae())},le=e=>{if(c.id!==e.pointerId)return;let t=se(e);c.vx=t.x-c.prevX,c.vy=t.y-c.prevY,c.prevX=t.x,c.prevY=t.y,c.x=t.x,c.y=t.y},ue=e=>{if(c.id!==e.pointerId)return;let t=c.grabbedIndex==null?null:p.particles[c.grabbedIndex];t&&(t.oldX=t.x-c.vx*.9,t.oldY=t.y-c.vy*.9),c.id=null,c.grabbedIndex=null},de=e=>{let t=(e-m)/1e3;for(let e=z;e<p.particles.length;e+=1){let n=p.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=c.grabbedIndex==null?null:p.particles[c.grabbedIndex];n&&(n.x+=(c.x-n.x)*.72,n.y+=(c.y-n.y)*.72)},C=()=>{for(let e=0;e<Ye;e+=1){lt(p.particles);for(let e of p.constraints)ut(p.particles,e)}lt(p.particles)},w=()=>{let e=1/0,t=1/0,n=-1/0,r=-1/0;for(let i of p.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);o.style.transform=`translate3d(${e-20}px, ${t-20}px, 0)`,o.style.width=`${n-e+40}px`,o.style.height=`${r-t+40}px`},fe=()=>{let e=p.particles[0],t=p.particles[z-1],n=p.particles[B*z-1],r=p.particles[(B-1)*z];!e||!t||!n||!r||(s.save(),s.shadowColor=`rgba(0,0,0,0.24)`,s.shadowBlur=24,s.shadowOffsetY=16,s.fillStyle=`rgba(0,0,0,0.14)`,s.beginPath(),s.moveTo(e.x,e.y),s.lineTo(t.x,t.y),s.lineTo(n.x,n.y),s.lineTo(r.x,r.y),s.closePath(),s.fill(),s.restore())},T=()=>{let e=p.particles[0],t=p.particles[z-1];!e||!t||(s.save(),s.strokeStyle=`rgba(0,0,0,0.72)`,s.lineWidth=4,s.lineCap=`round`,s.beginPath(),s.moveTo(e.x-10,e.y-3),s.lineTo(t.x+10,t.y-3),s.stroke(),s.strokeStyle=`rgba(255,255,255,0.55)`,s.lineWidth=1,s.beginPath(),s.moveTo(e.x-8,e.y-5),s.lineTo(t.x+8,t.y-5),s.stroke(),s.restore())},pe=()=>{s.clearRect(0,0,d,f),fe();for(let e=0;e<B-1;e+=1)for(let t=0;t<z-1;t+=1)dt(s,l,p.particles,e,t);T(),w()},E=e=>{if(!y)return;if(!ne()){x();return}let t=b();if(Je(h,t)&&c.id==null?(g=0,re(!1),S(t,e)):(g+=1,h=t),ct(p.particles,t),de(e),C(),pe(),_=c.id==null?_+1:0,g>=2&&re(!0),g>=2&&_>=90){y=!1,u=0;return}u=window.requestAnimationFrame(E)};re(!1),ne()&&ie();let me=new ResizeObserver(ie);me.observe(t);let D=new IntersectionObserver(([e])=>{ee=!!e?.isIntersecting,oe()});return D.observe(t),te.addEventListener(`change`,oe),document.addEventListener(`visibilitychange`,oe),window.addEventListener(`resize`,oe),o.addEventListener(`pointerdown`,ce),o.addEventListener(`pointermove`,le),o.addEventListener(`pointerup`,ue),o.addEventListener(`pointercancel`,ue),ae(),()=>{x(),me.disconnect(),D.disconnect(),te.removeEventListener(`change`,oe),document.removeEventListener(`visibilitychange`,oe),window.removeEventListener(`resize`,oe),o.removeEventListener(`pointerdown`,ce),o.removeEventListener(`pointermove`,le),o.removeEventListener(`pointerup`,ue),o.removeEventListener(`pointercancel`,ue)}},[a]),(0,I.jsx)(`aside`,{className:`hidden xl:block`,children:(0,I.jsxs)(`div`,{ref:r,className:`sticky top-4 h-[560px]`,children:[(0,I.jsx)(`canvas`,{ref:n,className:`invisible pointer-events-none fixed inset-0 z-40 block h-screen w-screen touch-none`,"aria-hidden":`true`}),(0,I.jsx)(`div`,{ref:i,className:`invisible fixed left-0 top-0 z-40 cursor-grab touch-none active:cursor-grabbing`,"aria-label":`Interactive thermal receipt with Verlet paper simulation`})]})})}var mt={a:({children:e})=>(0,I.jsx)(`span`,{className:`console-markdown-link`,children:e})};function ht(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function gt(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(ht).join(`|`)})`,`gi`)}function _t({text:e,highlightQuery:t}){let r=(0,M.useRef)(null),i=(0,M.useMemo)(()=>gt(t),[t]);return(0,M.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,I.jsx)(`div`,{ref:r,children:(0,I.jsx)(n,{components:mt,children:e})})}var vt=`codeseshProfiler`,yt=`codeseshProfilerLog`,bt=16,xt=500;function K(){if(typeof window>`u`)return!1;try{return window.localStorage.getItem(vt)===`1`}catch{return!1}}function St(){if(typeof window>`u`)return!1;try{return window.localStorage.getItem(yt)===`1`}catch{return!1}}function Ct(e){let t=window.__CODESHESH_RENDER_PROFILE__??[];t.push(e),t.length>xt&&t.splice(0,t.length-xt),window.__CODESHESH_RENDER_PROFILE__=t}function wt(e){if(!K()||typeof window>`u`)return;let t=performance.now();Ct({...e,startTime:q(e.startTime??t),commitTime:q(e.commitTime??t),route:e.route??window.location.pathname})}function q(e){return Math.round(e*100)/100}function Tt({id:e,detail:t,children:n}){return K()?(0,I.jsx)(M.Profiler,{id:e,onRender:(e,n,r,i,a,o)=>{let s={id:e,source:`react-profiler`,phase:n,actualDuration:q(r),baseDuration:q(i),startTime:q(a),commitTime:q(o),route:window.location.pathname,...t?{detail:t}:{}};Ct(s),s.actualDuration>=bt&&St()&&P(`react.profiler.commit`,{...s})},children:(0,I.jsx)(J,{id:e,detail:t,children:n})}):n}function J({id:e,detail:t,children:n}){let r=performance.now(),i=(0,M.useRef)(0);return(0,M.useLayoutEffect)(()=>{i.current+=1;let n=performance.now();Ct({id:e,source:`commit-latency`,phase:i.current===1?`mount`:`update`,actualDuration:q(n-r),baseDuration:0,startTime:q(r),commitTime:q(n),route:window.location.pathname,...t?{detail:t}:{}})}),n}function Et(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(e=>{if(typeof e==`string`)return e;if(e&&typeof e==`object`){let t=e,n=Et(t.text);if(n.trim())return n;let r=Et(t.content);if(r.trim())return r}return``}).filter(Boolean).join(`
2
+
3
+ `);if(e&&typeof e==`object`){let t=e,n=Et(t.text);if(n.trim())return n;let r=Et(t.content);if(r.trim())return r}return``}function Dt(e){return e.type===`tool`||e.type===`plan`?!0:e.type===`text`||e.type===`reasoning`?!!Et(e.text).trim():!1}function Ot(e){return e.reduce((e,t)=>{if(!Dt(t))return e;let n=e.at(-1);return t.type!==`plan`&&n?.type===t.type?(n.parts.push(t),e):(e.push({type:t.type,parts:[t]}),e)},[])}var Y=`<turn_aborted>
4
+ 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.
5
+ </turn_aborted>`;function kt(e){return e.replace(/\r\n/g,`
6
+ `).trim()}function At(e,t){if(t.toLowerCase()!==`codex`||e.role!==`user`||e.parts.length!==1)return!1;let[n]=e.parts;return!n||n.type!==`text`||typeof n.text!=`string`?!1:kt(n.text)===kt(Y)}function jt(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Mt(e){return typeof e==`string`?e:``}function Nt(e){return e.replace(/\\n/g,`
7
+ `)}function Pt(e){let t=jt(e),n=Mt(t.type);return n?{type:n,path:Mt(t.path),oldPath:Mt(t.old_path),targetPath:Mt(t.targetPath),content:Mt(t.content)||Mt(jt(t.input).content)}:null}function Ft(e){return(Array.isArray(e)?e:Array.isArray(jt(e).content)?jt(e).content:[]).map(e=>Pt(e)).filter(e=>e!=null)}function It(e,t,n){return`${e} ${e===1?t:n}`}function Lt(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(It(t,`write`,`writes`)),n>0&&a.push(It(n,`edit`,`edits`)),r>0&&a.push(It(r,`delete`,`deletes`)),i>0&&a.push(It(i,`move`,`moves`)),a.join(` · `)}function Rt(e){return e.targetPath||e.path||e.oldPath||e.type}function zt(e,t){return e.reduce((e,n)=>n.type===`write_file`?(e.push({label:Rt(n),operation:`write`,language:t(n.path),isCode:!0,text:Nt(n.content)}),e):n.type===`edit_file`?(e.push({label:Rt(n),operation:`edit`,language:`diff`,isCode:!0,text:Nt(n.content)}),e):n.type===`delete_file`?(e.push({label:Rt(n),operation:`edit`,language:`text`,isCode:!1,text:`File deleted.`}),e):(n.type===`move_file`&&e.push({label:Rt(n),operation:`edit`,language:`text`,isCode:!1,text:n.targetPath&&n.path?`Moved from ${n.path} to ${n.targetPath}`:n.oldPath?`Moved from ${n.oldPath}`:`File moved.`}),e),[])}function Bt(e,t,n){let r=zt(e,n);return r.length>0?{kind:`file-sections`,sections:r}:{kind:`plain`,text:t,language:`text`,isCode:!1}}function Vt(e){if(typeof e==`string`)return e.trim();if(Array.isArray(e))return e.map(e=>Vt(e)).filter(Boolean).join(`
8
+
9
+ `).trim();if(e&&typeof e==`object`){let t=e,n=Vt(t.text);if(n)return n;let r=Vt(t.content);if(r)return r}return``}function Ht(e){let t=e.approval_status===`fail`?`fail`:`success`,n=Vt(t===`fail`?e.output:e.input);return{title:`plan`,secondaryText:void 0,approvalStatus:t,expandable:!!n,contentLabel:t===`fail`?`Rejected`:`Plan`,contentMarkdown:n}}function Ut(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Wt(e){return typeof e==`string`?e.trim():``}function Gt(e){return typeof e==`string`?e:``}function Kt(e){return typeof e==`string`?e.trim():typeof e==`number`||typeof e==`bigint`||typeof e==`boolean`?`${e}`:``}function qt(e){return e.replace(/\\n/g,`
10
+ `)}function Jt(e){return e.replace(/\s*\(Recommended\)\s*$/i,``).trim()}function Yt(e){let t=e.trim();return{label:Jt(t),recommended:/\(Recommended\)\s*$/i.test(t)}}function Xt(e){return e.replace(/\s+/g,` `).trim()}function Zt(e,t=88){let n=Xt(e);return n?n.length>t?`${n.slice(0,t)}...`:n:``}function Qt(e,t){return Zt([`${t} questions`,...e.filter(Boolean).slice(0,2)].join(` · `),96)}function $t(e){try{return JSON.parse(e)}catch{return null}}function en(e){let t=qt(e).split(`
11
+ `);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(`
12
+ `);return r.trim()?r:e}function tn(e,t,n){n.trim()&&e.push({label:t,value:n})}function nn(e){return e.startsWith(`"`)&&e.endsWith(`"`)||e.startsWith(`'`)&&e.endsWith(`'`)?e.slice(1,-1):e}function rn(e){return e.trim()?!/[|&;<>()$`*?{}[\]\\]/.test(e):!1}function an(e){let t=nn(e.trim());return rn(t)?t:null}function on(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 an(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 an(n[1]||``)}return null}function sn(e){let t=e.split(`
13
+ `),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(`
14
+ `)}function cn(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 ln(e){let t=e.trim();return!t||cn(t)?null:(t.startsWith(`{`)||t.startsWith(`[`))&&$t(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 un(e,t,n){let r=en(t),i=on(e);if(i){let e=n(i);return{text:sn(r),language:e,isCode:e!==`text`,sourcePath:i,confidence:`path`}}let a=ln(r);return a?{text:r,language:a,isCode:!0,confidence:`content`}:{text:r,language:`text`,isCode:!1,confidence:`plain`}}function dn(e,t,n){let r=Ut(e),i=Wt(r.cmd),a=Wt(r.workdir),o=Wt(r.sandbox_permissions),s=Wt(r.justification),c=[];tn(c,`Command`,i),tn(c,`Workdir`,a),tn(c,`Escalation`,o),tn(c,`Justification`,s);let l=Zt(i);return{secondaryText:s?[s,l].filter(Boolean).join(`
15
+ `):l||void 0,details:c,outputAnalysis:un(i,t,n)}}function fn(e,t,n){let r=Ut(e),i=Kt(r.session_id),a=Gt(r.chars),o=a?`stdin`:`poll`,s=[];return tn(s,`Session`,i),s.push({label:`Chars`,value:a||`(empty)`}),{secondaryText:i?`session #${i} · ${o}`:o,details:s,outputAnalysis:un(``,t,n)}}function pn(e,t){let n=Ut(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=Ut($t(t)?.answers),a=r.map(e=>{let t=Ut(e),n=Ut(i[Wt(t.id)]),r=(Array.isArray(n.answers)?n.answers:[]).map(e=>typeof e==`string`?Jt(e):``).filter(Boolean),a=Array.isArray(t.options)?t.options.map(e=>{let t=Ut(e),n=Yt(Wt(t.label));return n.label?{label:n.label,description:Wt(t.description)||void 0,recommended:n.recommended||void 0}:null}).filter(e=>e!=null):[],o=Wt(t.question);return o?{header:Wt(t.header)||void 0,question:o,options:a,answers:r}:null}).filter(e=>e!=null);return a.length===0?{secondaryText:void 0,details:[],outputContent:{kind:`plain`,text:t,language:`text`,isCode:!1}}:{secondaryText:Qt(a.map(e=>e.header||``),a.length),details:[],outputContent:{kind:`question-list`,questions:a}}}function mn(e){return yn(e)?`Browser`:typeof e.title==`string`&&e.title.trim()?gn(e.title):typeof e.tool==`string`&&e.tool.trim()?gn(e.tool):`tool`}function hn(e){return yn(e)?`browser`:gn(typeof e.tool==`string`&&e.tool.trim()?e.tool:mn(e)).toLowerCase()}function gn(e){return e.trim().replace(/^tool:\s*/i,``).replace(/^\.+(?=\w)/,``)}function _n(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function vn(e){return typeof e==`string`?e.trim():``}function yn(e){let t=vn(_n(e.state?.metadata).namespace);return gn(vn(e.tool)).toLowerCase()===`js`&&(t===`mcp__node_repl__`||t===`mcp__node_repl__.js`)}function bn(e,t){let n=hn(t),r=`tool:${n}`,i=e.get(n);if(i){i.count+=1;return}e.set(n,{id:r,toolKey:n,label:mn(t),count:1})}function xn(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)bn(r,t),n.add(`tool:${hn(t)}`)}return{filterIds:n,counts:t,tools:[...r.values()].toSorted((e,t)=>e.label.localeCompare(t.label))}}function Sn(e,t){return t.has(`tools_all`)?t.has(`tool:${hn(e)}`):!1}function Cn(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=>Sn(e,n))}function wn(e,t){let n=e.parts.filter(e=>Sn(e,t));return n.length===0?null:{...e,parts:n}}function Tn(e,t){return e.map(e=>{let n=e.blocks.filter(n=>Cn(n,e.msg,t)).map(e=>e.type===`tool`?wn(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 En(e){let t=[];for(let n of e){let e=Ot(n.parts);e.length!==0&&t.push({msg:n,blocks:e,index:t.length})}return t}var Dn={".bashrc":`bash`,".zshrc":`bash`,".profile":`bash`,dockerfile:`docker`,".env":`ini`},On={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 kn(e){let t=e.split(`/`).pop()?.toLowerCase()??``;if(!t)return`text`;let n=Dn[t];if(n)return n;if(t.startsWith(`.env.`))return`ini`;let r=t.includes(`.`)?t.split(`.`).pop()??``:``;return r&&On[r]||`text`}E.registerLanguage(`bash`,me),E.registerLanguage(`c`,ke),E.registerLanguage(`cpp`,ge),E.registerLanguage(`csharp`,Ae),E.registerLanguage(`css`,Oe),E.registerLanguage(`docker`,D),E.registerLanguage(`go`,k),E.registerLanguage(`ini`,ye),E.registerLanguage(`java`,A),E.registerLanguage(`javascript`,j),E.registerLanguage(`jsx`,ve),E.registerLanguage(`json`,O),E.registerLanguage(`markdown`,De),E.registerLanguage(`markup`,xe),E.registerLanguage(`python`,_e),E.registerLanguage(`rust`,Te),E.registerLanguage(`sql`,Ce),E.registerLanguage(`toml`,he),E.registerLanguage(`tsx`,be),E.registerLanguage(`typescript`,we),E.registerLanguage(`yaml`,Se);function An(e){return e===`html`||e===`xml`?`markup`:e}function jn({language:e,text:t}){return(0,I.jsx)(E,{language:An(e),style:Ee,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 Mn(e,t){return`${e}:${t}`}function Nn(e){return/^(Index:|diff\s|===)/.test(e)?`text-[var(--console-text)] bg-[#f3f4f6]`:e.startsWith(`@@`)?`text-[#7c3aed] bg-[#f5f3ff]`:e.startsWith(`+++ `)||e.startsWith(`--- `)?`text-[#1d4ed8] bg-[#eff6ff]`:e.startsWith(`+`)?`text-[#15803d] bg-[#f0fdf4]`:e.startsWith(`-`)?`text-[#b91c1c] bg-[#fef2f2]`:`text-[var(--console-text)]`}function Pn({text:e}){let t=e.split(`
16
+ `),n=new Map;return(0,I.jsx)(`pre`,{className:`console-mono max-h-[420px] overflow-auto whitespace-pre rounded-sm border border-[var(--console-border)] bg-[#fafafa] p-3 text-xs leading-relaxed`,children:t.map(e=>{let t=n.get(e)??0;return n.set(e,t+1),(0,I.jsx)(`span`,{className:`block rounded-[2px] px-1 ${Nn(e)}`,children:e||` `},Mn(e,t))})})}function Fn(e){let t=e.text||`No output captured.`;return!e.isCode||e.language===`text`?(0,I.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,I.jsx)(Pn,{text:t}):(0,I.jsx)(`div`,{className:`max-h-[420px] overflow-auto bg-[#fafafa]`,children:(0,I.jsx)(jn,{language:e.language,text:t})})}function In({sections:e}){return(0,I.jsx)(`div`,{className:`space-y-3`,children:e.map(e=>(0,I.jsxs)(`div`,{className:`overflow-hidden rounded-sm border border-[var(--console-border)] bg-[#fafafa]`,children:[(0,I.jsx)(`div`,{className:`border-b border-[var(--console-border)] bg-[var(--console-surface-muted)] px-3 py-1.5`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-white px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-[var(--console-muted)]`,children:e.operation}),(0,I.jsx)(`span`,{className:`console-mono text-[11px] font-semibold text-[var(--console-muted)]`,children:e.label})]})}),Fn(e)]},`${e.operation}:${e.label}:${e.language}`))})}function Ln({questions:e}){return(0,I.jsx)(`div`,{className:`space-y-3`,children:e.map(e=>(0,I.jsxs)(`div`,{className:`overflow-hidden rounded-sm border border-[var(--console-border)] bg-[#fafafa]`,children:[(0,I.jsxs)(`div`,{className:`border-b border-[var(--console-border)] bg-[var(--console-surface-muted)] px-3 py-2`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.header?(0,I.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-white px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-[var(--console-muted)]`,children:e.header}):null,e.answers.length>0?(0,I.jsx)(`span`,{className:`console-mono text-[11px] font-semibold text-[var(--console-success)]`,children:`Answered`}):(0,I.jsx)(`span`,{className:`console-mono text-[11px] font-semibold text-[var(--console-muted)]`,children:`Pending`})]}),(0,I.jsx)(`p`,{className:`mt-2 text-sm leading-relaxed text-[var(--console-text)]`,children:e.question})]}),(0,I.jsx)(`div`,{className:`space-y-2 p-3`,children:e.options.map(t=>{let n=e.answers.includes(t.label);return(0,I.jsxs)(`div`,{className:`rounded-sm border px-3 py-2 ${n?`border-[var(--console-success-border)] bg-[var(--console-success-bg)]`:`border-[var(--console-border)] bg-white`}`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`console-mono text-xs font-semibold ${n?`text-[var(--console-success)]`:`text-[var(--console-text)]`}`,children:t.label}),t.recommended?(0,I.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,I.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-success-border)] bg-white px-1.5 py-0.5 text-[10px] text-[var(--console-success)]`,children:`Selected`}):null]}),t.description?(0,I.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 Rn(e){return`${e.label}:${e.lines.map(e=>`${e.type}:${e.text}`).join(`
17
+ `)}`}function zn(e){return e===`add`?`text-[#15803d] bg-[#f0fdf4]`:e===`remove`?`text-[#b91c1c] bg-[#fef2f2]`:`text-[var(--console-text)]`}function Bn({blocks:e}){return(0,I.jsx)(`div`,{className:`space-y-3`,children:e.map(e=>{let t=new Map;return(0,I.jsxs)(`div`,{className:`overflow-hidden rounded-sm border border-[var(--console-border)] bg-[#fafafa]`,children:[(0,I.jsx)(`div`,{className:`border-b border-[var(--console-border)] bg-[var(--console-surface-muted)] px-3 py-1.5`,children:(0,I.jsx)(`span`,{className:`console-mono text-[11px] font-semibold text-[var(--console-muted)]`,children:e.label})}),(0,I.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,I.jsxs)(`span`,{className:`block rounded-[2px] px-1 ${zn(e.type)}`,children:[e.type===`add`?`+`:e.type===`remove`?`-`:` `,e.text||` `]},`${n}:${r}`)})})]},Rn(e))})})}function Vn({outputContent:e}){if(e.kind===`structured-diff`)return(0,I.jsx)(Bn,{blocks:e.blocks});if(e.kind===`file-sections`)return(0,I.jsx)(In,{sections:e.sections});if(e.kind===`question-list`)return(0,I.jsx)(Ln,{questions:e.questions});let t=e.text||`No output captured.`;return!e.isCode||e.language===`text`?(0,I.jsx)(`pre`,{className:`console-mono max-h-[420px] overflow-auto whitespace-pre-wrap break-all rounded-sm border border-[var(--console-border)] bg-[#fafafa] p-3 text-xs leading-relaxed text-[var(--console-text)]`,children:t}):e.language===`diff`?(0,I.jsx)(Pn,{text:t}):(0,I.jsx)(`div`,{className:`max-h-[420px] overflow-auto rounded-sm border border-[var(--console-border)] bg-[#fafafa]`,children:(0,I.jsx)(jn,{language:e.language,text:t})})}var Hn={completed:{label:`Success`,className:`border-[var(--console-success-border)] bg-[var(--console-success-bg)] text-[var(--console-success)]`,icon:m},error:{label:`Failed`,className:`border-[var(--console-error-border)] bg-[var(--console-error-bg)] text-[var(--console-error)]`,icon:v},running:{label:`Running`,className:`border-[var(--console-warning-border)] bg-[var(--console-warning-bg)] text-[var(--console-warning)]`,icon:ce}},Un=32,Wn=80,Gn=280,Kn=6;function qn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Jn(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(qn).join(`|`)})`,`gi`)}function Yn(e,t){let n=Jn(t);return n?e.split(n).map((e,t)=>e.match(n)?(0,I.jsx)(`mark`,{children:e},`${e}-${t}`):(0,I.jsx)(`span`,{children:e},`${e}-${t}`)):e}function Xn({text:e,highlightQuery:t}){return(0,I.jsx)(_t,{text:e,highlightQuery:t})}function Zn(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 Qn(e){if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}}function $n(e){if(typeof e==`string`)return[e];if(Array.isArray(e))return e.flatMap(e=>$n(e));if(e&&typeof e==`object`){let t=e;if(typeof t.text==`string`)return[t.text];if(t.content!==void 0)return $n(t.content)}return[]}function er(e){return e.replace(/^<system>/i,``).replace(/<\/system>$/i,``).trim()}function tr(e,t=!0){let n=$n(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)?er(e):e).join(`
18
+ `)}function nr(e){let t=Qn(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 rr(e){return typeof e==`string`?e.trim():``}function X(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Z(e){return typeof e==`string`?e.trim():``}function ir(e){return typeof e==`string`?e:``}function ar(e){return typeof e.title==`string`&&e.title.trim()?Sr(e.title):typeof e.tool==`string`&&e.tool.trim()?Sr(e.tool):`tool`}function or(e){return ar(e).trim().toLowerCase()}function sr(e,t){return`tool-${e}-${t}`}function cr(e){let t=e.trim();return!t||t.length>300||t.includes(`
19
+ `)||/^[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 lr(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 ur(e,t,n,r=0){if(!(e==null||r>4)){if(typeof e==`string`){lr(t)&&cr(e)&&n.add(e.trim());return}if(Array.isArray(e)){for(let i of e)ur(i,t,n,r+1);return}if(typeof e==`object`)for(let[t,i]of Object.entries(e))ur(i,t,n,r+1)}}function dr(e){let t=new Set;return ur(e,``,t),[...t]}function fr(e){return e.state?.arguments??e.state?.input??e.input??null}function pr(e){let t=or(e);return t===`read`?`read`:t===`edit`||t===`multiedit`||t===`apply_patch`||t===`notebookedit`?`edit`:t===`write`||t===`create_file`||t===`write_file`?`write`:t===`delete`||t===`delete_file`?`delete`:null}function mr(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 hr(e){let t=new Map,n=new Map,r={read:[],edit:[],write:[],delete:[]};return e.forEach(({msg:e,blocks:i,index:a})=>{let o=0;for(let s of i)if(s.type===`tool`)for(let i of s.parts){let s=sr(a,o);o+=1,t.set(i,s),n.set(s,a);let c=fr(i),l=ar(i),u=i.time_created??e.time_created,d=Ft(c);if(d.length>0){for(let e of d){let t=(e.path||e.oldPath).trim();if(!t)continue;let n=e.type===`write_file`?`write`:e.type===`delete_file`?`delete`:`edit`;r[n].push({kind:n,path:t,anchorId:s,time:u,toolLabel:l})}continue}let f=pr(i);if(!f)continue;let p=dr(c);for(let e of p)r[f].push({kind:f,path:e,anchorId:s,time:u,toolLabel:l})}}),{toolAnchorIds:t,anchorMessageIndexes:n,summary:{read:mr(r.read),edit:mr(r.edit),write:mr(r.write),delete:mr(r.delete)}}}function gr(e,t){if(!e)return t;let n={read:[],edit:[],write:[],delete:[]},r=new Map;for(let e of[`read`,`edit`,`write`,`delete`])for(let n of t[e])r.set(`${e}\0${n.path}`,n);for(let t of e){let e=r.get(`${t.kind}\0${t.path}`);n[t.kind].push({path:t.path,count:t.count,latestTime:t.latest_time,latestAnchorId:e?.latestAnchorId??``,toolLabel:e?.toolLabel??t.kind,anchors:e?.anchors??[]})}for(let e of[`read`,`edit`,`write`,`delete`])n[e].sort((e,t)=>t.latestTime===e.latestTime?e.path.localeCompare(t.path):t.latestTime-e.latestTime);return n}function _r(e,t){return e.startsWith(`${t}/`)?e.slice(t.length+1):e}function vr(e,t){if(typeof document>`u`)return;let n=document.getElementById(e);if(!n&&t){t();let r=0,i=()=>{if(n=document.getElementById(e),n){n.scrollIntoView({behavior:`smooth`,block:`center`});return}r+=1,r<8&&requestAnimationFrame(i)};requestAnimationFrame(i);return}n&&n.scrollIntoView({behavior:`smooth`,block:`center`})}function yr(e){try{return JSON.parse(e)}catch{return null}}function br(e,t){if(!K())return t();let n=performance.now(),r=t(),i=performance.now();return wt({id:e,source:`custom-timing`,phase:`measure`,actualDuration:Math.round((i-n)*100)/100,baseDuration:0,startTime:n,commitTime:i}),r}function xr({session:e,toc:t}){let[n,r]=(0,M.useState)(!1);return(0,M.useEffect)(()=>{r(!1);let e=0,t=requestAnimationFrame(()=>{e=requestAnimationFrame(()=>r(!0))});return()=>{cancelAnimationFrame(t),e&&cancelAnimationFrame(e)}},[e.id]),n?(0,I.jsx)(Tt,{id:`InteractiveReceipt`,children:(0,I.jsx)(pt,{session:e,toc:t},e.id)}):(0,I.jsx)(`aside`,{className:`hidden xl:block`,"aria-hidden":`true`})}function Q(e){return e.replace(/\\n/g,`
20
+ `)}function Sr(e){let t=e.trim();return t?t.replace(/^tool:\s*/i,``).replace(/^\.+(?=\w)/,``):``}function Cr(e,t=`Tool`){return Sr(Z(e.title))||Z(e.tool)||t}function wr(e){return Q(tr(e)||Zn(e))||`No output captured.`}function $(e){let t=wr(e.outputValue);if(t!==`No output captured.`)return t;let n=wr(e.errorValue);return n===`No output captured.`?`No output captured.`:n}function Tr(e){let t=e.indexOf(`Output:
21
+ `);if(t===-1)return e;let n=yr(e.slice(t+8).trim());return Array.isArray(n)&&n.map(e=>Z(X(e).text)).filter(Boolean).join(`
22
+ `)||e}function Er(e){let t=X(e);return Z(t.filePath)||Z(t.file_path)||Z(t.path)||Z(t.targetFile)||Z(t.effectiveUri)||Z(t.relativeWorkspacePath)||``}function Dr(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:typeof e==`string`&&yr(e)||{}}function Or(e){return e.replace(/\n*<system-reminder>[\s\S]*$/i,``).trimEnd()}function kr(e){let t=tr(e,!1)||wr(e);return t===`No output captured.`?t:Or(t.replace(/^<file>\s*/i,``).replace(/\s*<\/file>\s*$/i,``)).split(`
23
+ `).filter(e=>!/^\(End of file - total \d+ lines\)$/.test(e.trim())).map(e=>e.replace(/^\d+\|\s?/,``).replace(/^\s*\d+\t/,``)).join(`
24
+ `).trimEnd()||`No output captured.`}function Ar(e){let t=ir(Dr(e).contents);return t?Q(t):`No output captured.`}function jr(e){let t=Dr(e),n=Array.isArray(t.directories)?t.directories:[];if(n.length===0)return wr(e);let r=n.flatMap(e=>{let t=X(e);return[Z(t.absPath),...(Array.isArray(t.files)?t.files:[]).map(e=>{let t=X(e);return Z(t.relPath)||Z(t.absPath)}).filter(Boolean).map(e=>` ${e}`)].filter(Boolean)});return r.length>0?r.join(`
25
+ `):`No output captured.`}function Mr(e,t,n){return!t.trim()&&!n.trim()?[]:[{label:Lr(e),lines:Fr(S(Q(t),Q(n)))}]}function Nr(e,t){let n=Q(e).split(`
26
+ `),r=Q(t).split(`
27
+ `);return[`@@`,...n.map(e=>`- ${e}`),...r.map(e=>`+ ${e}`)].join(`
28
+ `)}function Pr(e){let t=Q(e),n=t.split(`
29
+ `);return t.endsWith(`
30
+ `)&&n.pop(),n}function Fr(e){return e.flatMap(e=>{let t=e.added?`add`:e.removed?`remove`:`context`;return Pr(e.value).map(e=>({type:t,text:e}))})}function Ir(e){let t=X(e).edit;return Array.isArray(t)?t:t&&typeof t==`object`?[t]:[]}function Lr(e){let t=e.trim();if(!t)return`edit`;let n=t.split(`/`).pop()||t;return n===t?n:`${n} · ${t}`}function Rr(e,t){let n=Ir(e.inputValue),r=Lr(t);return n.map(e=>{let t=X(e),n=ir(t.old),i=ir(t.new);return!n.trim()&&!i.trim()?null:{label:r,lines:Fr(S(Q(n),Q(i)))}}).filter(e=>e!=null&&e.lines.length>0)}function zr(e){let t=ir(X(e.metadataValue).diff);if(t.trim())return Q(t);let n=Ir(e.inputValue).map(e=>{let t=X(e),n=ir(t.old),r=ir(t.new);return!n.trim()&&!r.trim()?``:Nr(n,r)}).filter(Boolean).join(`
31
+
32
+ `);return n.trim()?n:$(e)}function Br(e){let t=X(e.inputValue);if(e.status===`completed`){let e=ir(t.content);if(e.trim())return Q(e)}return $(e)}function Vr(e){let t=X(X(e.state).arguments),n=rr(t.agent_type),r=rr(e.nickname),i=[rr(t.model),rr(t.reasoning_effort)].filter(Boolean).join(`-`);return[[n,r].filter(Boolean).join(` - `),i].filter(Boolean).join(` `)}function Hr(e){let t=X(e.state);return rr(t.prompt)||rr(X(t.arguments).message)||``}function Ur(e){let t=rr(e.nickname);return e.role===`assistant`&&t?`AGENT (${t})`:e.role===`user`?`USER`:e.role===`tool`?`TOOL`:`AGENT`}function Wr(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 Gr(e){let t=e.state||{},n=t.status,r=n===`running`||n===`error`||n===`completed`?n:`completed`,i=t.output??t.result??``,a=t.error??``,o=Qn(t.input??t.arguments??{}),s=t.metadata??{};return{status:r,command:nr(o),inputValue:o,outputValue:i,errorValue:a,metadataValue:s,inputText:Zn(o)}}function Kr(e,t){let n=(t.command||t.inputText||`{}`).replace(/\s+/g,` `).trim(),r=n.length>72?`${n.slice(0,72)}...`:n;return{Icon:C,title:Cr(e),secondaryText:r?`(${r})`:void 0,details:[],expandable:!0,showInputPreview:!0,outputContent:{kind:`plain`,text:$(t),language:`text`,isCode:!1}}}function qr(e,t,n){let r=Z(X(t.inputValue).name);return{...n,Icon:ue,title:Z(e.tool)||`skill`,secondaryText:r||void 0,expandable:!1,showInputPreview:!1}}function Jr(e,t){let n=Kr(e,t),r=(e.tool||``).toLowerCase(),i=X(t.inputValue),a=Er(t.inputValue);if(r===`read`)return{...n,Icon:p,title:`read`,secondaryText:a||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:kr(t.outputValue),language:kn(a),isCode:!0}};if(r===`edit`){let e=Mr(a,ir(i.old_string),ir(i.new_string));return{...n,Icon:w,title:`edit`,secondaryText:a||void 0,showInputPreview:!1,outputContent:e.length>0?{kind:`structured-diff`,blocks:e}:{kind:`plain`,text:$(t),language:`text`,isCode:!1}}}return r===`write`?{...n,Icon:y,title:`write`,secondaryText:a||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:Br(t),language:kn(a),isCode:!0}}:{...n,title:Cr(e)}}function Yr(e,t){let n=Kr(e,t),r=(e.tool||``).toLowerCase(),i=X(t.inputValue);if(r===`glob`){let r=Z(i.pattern);return{...n,Icon:g,title:e.tool||`glob`,secondaryText:r||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:$(t),language:`text`,isCode:!1}}}if(r===`grep`){let r=[Z(i.path),Z(i.pattern)].filter(Boolean).join(` · `);return{...n,Icon:g,title:e.tool||`grep`,secondaryText:r||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:$(t),language:`text`,isCode:!1}}}if(r===`bash`){let r=Z(i.description),a=Z(i.command),o=r?`${r}${a?` (${a})`:``}`:a?`(${a})`:void 0;return{...n,Icon:C,title:e.tool||`bash`,secondaryText:o,showInputPreview:!1,outputContent:{kind:`plain`,text:$(t),language:`text`,isCode:!1}}}if(r===`read`){let r=Er(t.inputValue);return{...n,Icon:p,title:e.tool||`read`,secondaryText:r||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:kr(t.outputValue),language:kn(r),isCode:!0}}}if(r===`edit`){let r=Er(t.inputValue);return{...n,Icon:w,title:e.tool||`edit`,secondaryText:r||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:zr(t),language:`diff`,isCode:!0}}}if(r===`write`){let r=Er(t.inputValue),i=t.status===`completed`;return{...n,Icon:y,title:e.tool||`write`,secondaryText:r||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:Br(t),language:kn(r),isCode:i}}}return r===`skill`?qr(e,t,n):n}function Xr(e,t){let n=Kr(e,t),r=(e.tool||``).toLowerCase(),i=X(t.inputValue);if(r===`glob`){let r=Z(i.pattern);return{...n,Icon:g,title:e.title||`glob`,secondaryText:r||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:$(t),language:`text`,isCode:!1}}}if(r===`grep`){let r=[Z(i.path),Z(i.pattern)].filter(Boolean).join(` · `);return{...n,Icon:g,title:e.title||`grep`,secondaryText:r||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:$(t),language:`text`,isCode:!1}}}if(r===`shell`){let r=Z(i.command);return{...n,Icon:C,title:e.title||`bash`,secondaryText:r?`(${r})`:void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:$(t),language:`text`,isCode:!1}}}if(r===`readfile`){let r=Er(t.inputValue);return{...n,Icon:p,title:e.title||`read`,secondaryText:r||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:kr(t.outputValue),language:kn(r),isCode:!0}}}if(r===`strreplacefile`){let r=Er(t.inputValue),i=Rr(t,r);return{...n,Icon:w,title:e.title||`edit`,secondaryText:r||void 0,showInputPreview:!1,outputContent:i.length>0?{kind:`structured-diff`,blocks:i}:{kind:`plain`,text:zr(t),language:`diff`,isCode:!0}}}if(r===`writefile`){let r=Er(t.inputValue);return{...n,Icon:y,title:e.title||`write`,secondaryText:r||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:Br(t),language:kn(r),isCode:t.status===`completed`}}}return n}function Zr(e,t){let n=Kr(e,t),r=or(e),i=Z(X(t.metadataValue).namespace);if(r===`skill`)return qr(e,t,n);if(r===`js`&&(i===`mcp__node_repl__`||i===`mcp__node_repl__.js`)){let e=Z(X(t.inputValue).title);return{...n,Icon:C,title:`Browser`,secondaryText:e||void 0,details:[],showInputPreview:!1,outputContent:{kind:`plain`,text:Tr($(t)),language:`text`,isCode:!1}}}if(r===`exec_command`||r===`bash`){let e=dn(t.inputValue,$(t),kn);return{...n,Icon:C,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(r===`write_stdin`){let e=fn(t.inputValue,$(t),kn);return{...n,Icon:C,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(r===`request_user_input`){let e=pn(t.inputValue,$(t));return{...n,Icon:T,title:`ask`,secondaryText:e.secondaryText,details:e.details,showInputPreview:!1,outputContent:e.outputContent}}if(r===`patch`){let r=Ft(t.inputValue),i=Lt(r);return{...n,Icon:w,title:Cr(e,`patch`),secondaryText:i||void 0,details:[],showInputPreview:!1,outputContent:Bt(r,$(t),kn)}}if(r===`subagent`){let r=Hr(e),i=$(t);return{...n,Icon:l,title:Vr(e)||Cr(e,`subagent`),secondaryText:void 0,details:[],showInputPreview:!1,outputContent:{kind:`plain`,text:r||i,language:`markdown`,isCode:!1}}}return n}function Qr(e,t){let n=Kr(e,t),r=(e.tool||``).toLowerCase(),i=X(t.inputValue),a=Er(t.inputValue);if(r===`read_file_v2`){let e=Ar(t.outputValue);return{...n,Icon:p,title:`read`,secondaryText:a||void 0,details:e===`No output captured.`?[{label:`Lines`,value:Z(Dr(t.outputValue).totalLinesInFile)}]:[],showInputPreview:!1,outputContent:{kind:`plain`,text:e,language:kn(a),isCode:e!==`No output captured.`}}}if(r===`edit_file_v2`){let e=Q(ir(i.streamingContent));return{...n,Icon:w,title:`edit`,secondaryText:a||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:e||$(t),language:e?`diff`:`text`,isCode:!!e}}}if(r===`ripgrep_raw_search`){let e=Z(i.pattern),r=[Z(i.path),e].filter(Boolean).join(` · `);return{...n,Icon:g,title:`grep`,secondaryText:r||void 0,details:[],showInputPreview:!1,outputContent:{kind:`plain`,text:$(t),language:`text`,isCode:!1}}}if(r===`glob_file_search`){let e=Z(i.globPattern),r=[Z(i.targetDirectory),e].filter(Boolean).join(` · `);return{...n,Icon:g,title:`glob`,secondaryText:r||void 0,details:[],showInputPreview:!1,outputContent:{kind:`plain`,text:jr(t.outputValue),language:`text`,isCode:!1}}}if(r===`run_terminal_command_v2`){let e=Z(i.command),r=Z(i.commandDescription),a=r?`${r}${e?` (${e})`:``}`:e?`(${e})`:void 0;return{...n,Icon:C,title:`bash`,secondaryText:a,details:[],showInputPreview:!1,outputContent:{kind:`plain`,text:$(t),language:`text`,isCode:!1}}}return{...n,title:Cr(e)}}function $r(e,t,n){let r=e.toLowerCase();return r===`opencode`?Yr(t,n):r===`codex`?Zr(t,n):r===`kimi`?Xr(t,n):r===`claudecode`?Jr(t,n):r===`cursor`?Qr(t,n):Kr(t,n)}function ei(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function ti(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 ni(e){return e===window}function ri(e,t){let n=[],r=0;for(let i=0;i<e;i+=1){let a=t[i]??Gn,o=r,s=o+a;n.push({start:o,end:s}),r=s+(i===e-1?0:Un)}return{items:n,totalSize:r}}function ii(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 ai(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 oi(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 si(e){return ni(e)?window.scrollY:e.scrollTop}function ci(e){return ni(e)?window.innerHeight||900:e.clientHeight}function li(e,t){if(ni(t))return e.getBoundingClientRect().top+window.scrollY;let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();return t.scrollTop+r.top-n.top}function ui(e,t){if(ni(e)){window.scrollTo({top:t,behavior:`auto`});return}e.scrollTo({top:t,behavior:`auto`})}function di({messages:e,toolAnchorIds:t,sessionAgentKey:n,highlightQuery:r,apiRef:i}){let a=e.length>Wn;return(0,M.useEffect)(()=>{a||(i.current=null)},[i,a]),a?(0,I.jsx)(fi,{messages:e,toolAnchorIds:t,sessionAgentKey:n,highlightQuery:r,apiRef:i}):(0,I.jsx)(`div`,{className:`flex min-w-0 flex-col gap-8`,children:e.map(({msg:e,blocks:i,index:a})=>(0,I.jsx)(xi,{msg:e,blocks:i,toolAnchorIds:t,formatTokens:ei,sessionAgentKey:n,highlightQuery:r},`${e.id}:${a}`))})}function fi({messages:e,toolAnchorIds:t,sessionAgentKey:n,highlightQuery:r,apiRef:i}){let a=(0,M.useRef)(null),o=(0,M.useRef)(null),[s,c]=(0,M.useState)([]),[l,u]=(0,M.useState)(null),[d,f]=(0,M.useState)(()=>({scrollTop:0,height:900,listTop:0})),p=(0,M.useRef)(d);(0,M.useEffect)(()=>{p.current=d},[d]);let m=(0,M.useCallback)(()=>{if(typeof window>`u`)return;let e=a.current,t=e?oi(e):window;o.current=t;let n=e?li(e,t):0,r={scrollTop:si(t),height:ci(t),listTop:n},i=p.current;Math.abs(i.scrollTop-r.scrollTop)<1&&Math.abs(i.height-r.height)<1&&Math.abs(i.listTop-r.listTop)<1||(p.current=r,f(r))},[]);(0,M.useEffect)(()=>{m();let e=o.current??window,t=0,n=()=>{t||=requestAnimationFrame(()=>{t=0,m()})};e.addEventListener(`scroll`,n,{passive:!0}),window.addEventListener(`resize`,n);let r=window.setInterval(m,100),i=null;return typeof ResizeObserver<`u`&&(i=new ResizeObserver(n),a.current&&i.observe(a.current),ni(e)||i.observe(e),document.body&&i.observe(document.body)),()=>{t&&cancelAnimationFrame(t),i?.disconnect(),window.clearInterval(r),e.removeEventListener(`scroll`,n),window.removeEventListener(`resize`,n)}},[m]),(0,M.useEffect)(()=>{c([]),u(null),m()},[e,m]);let h=(0,M.useMemo)(()=>ri(e.length,s),[s,e.length]),g=(0,M.useCallback)((e,t)=>{let n=Math.ceil(t);!Number.isFinite(n)||n<=0||c(t=>{let r=t[e];if(r!=null&&Math.abs(r-n)<=1)return t;let i=[...t];return i[e]=n,i})},[]),_=(0,M.useMemo)(()=>{if(e.length===0)return[];let t=Math.max(0,d.scrollTop-d.listTop),n=t+d.height,r=Math.max(0,ii(h.items,t)-Kn),i=Math.min(e.length,ai(h.items,n)+Kn),a=[];for(let e=r;e<i;e+=1){let t=h.items[e];t&&a.push({index:e,start:t.start})}if(l!=null&&l>=0&&l<e.length){let e=h.items[l];e&&!a.some(e=>e.index===l)&&(a.push({index:l,start:e.start}),a.sort((e,t)=>e.start-t.start))}return a},[l,h,e.length,d]),v=(0,M.useCallback)(e=>{if(typeof window>`u`)return;let t=h.items[e];if(!t)return;u(e);let n=a.current,r=n?oi(n):o.current??window;o.current=r;let i=n?li(n,r):0,s=Math.max(0,i+t.start-24);ui(r,s);let c={scrollTop:s,height:ci(r),listTop:i};p.current=c,f(c)},[h.items]);return(0,M.useEffect)(()=>(i.current={scrollToIndex:v},()=>{i.current?.scrollToIndex===v&&(i.current=null)}),[i,v]),(0,I.jsx)(`div`,{ref:a,className:`relative min-w-0`,style:{height:Math.max(1,h.totalSize)},children:_.map(({index:i,start:a})=>{let o=e[i];return o?(0,I.jsx)(pi,{index:i,top:a,onMeasure:g,children:(0,I.jsx)(xi,{msg:o.msg,blocks:o.blocks,toolAnchorIds:t,formatTokens:ei,sessionAgentKey:n,highlightQuery:r})},`${o.msg.id}:${o.index}`):null})})}function pi({index:e,top:t,onMeasure:n,children:r}){let i=(0,M.useRef)(null);return(0,M.useEffect)(()=>{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,I.jsx)(`div`,{ref:i,className:`absolute left-0 top-0 w-full`,style:{transform:`translateY(${t}px)`},children:r})}function mi({session:e,highlightQuery:t}){let n=(e.slug||``).split(`/`)[0]||N.getDefaultAgentKey()||`claudecode`,r=(0,M.useMemo)(()=>br(`SessionDetail:normalizeMessages`,()=>Wr(e.messages,n)),[e.messages,n]),i=(0,M.useMemo)(()=>br(`SessionDetail:buildMessageDisplayModels`,()=>En(r)),[r]),{toolAnchorIds:a,anchorMessageIndexes:o,summary:s}=(0,M.useMemo)(()=>br(`SessionDetail:buildFileChangeSummary`,()=>hr(i)),[i]),c=(0,M.useMemo)(()=>br(`SessionDetail:buildSessionDetailToc`,()=>xn(i)),[i]),[l,u]=(0,M.useState)(()=>new Set(c.filterIds)),d=(0,M.useMemo)(()=>[...c.filterIds].toSorted().join(`|`),[c.filterIds]),f=(0,M.useMemo)(()=>[...l].toSorted().join(`|`),[l]),p=(0,M.useMemo)(()=>br(`SessionDetail:filterSessionMessages`,()=>Tn(i,l)),[i,l]),m=(0,M.useRef)(null),h=(0,M.useMemo)(()=>br(`SessionDetail:buildAnchorListIndexes`,()=>{let e=new Map;return p.forEach((t,n)=>{e.set(t.index,n)}),e}),[p]),g=(0,M.useMemo)(()=>br(`SessionDetail:mergeFileActivitySummary`,()=>gr(e.file_activity,s)),[e.file_activity,s]),_=(0,M.useCallback)(e=>{let t=o.get(e),n=t==null?void 0:h.get(t);vr(e,()=>{n!=null&&m.current?.scrollToIndex(n)})},[h,o]);return(0,M.useEffect)(()=>{u(new Set(c.filterIds))},[d,c.filterIds]),i.length===0?(0,I.jsx)(`div`,{"data-testid":`session-detail`,className:`mx-auto max-w-4xl rounded-sm border border-[var(--console-border)] bg-white p-6 text-sm text-[var(--console-muted)]`,children:`当前会话暂无可展示的消息内容。`}):(0,I.jsxs)(`div`,{"data-testid":`session-detail`,className:`mx-auto w-full max-w-[1440px] space-y-8 px-2 md:px-4 animate-in fade-in slide-in-from-bottom-2 duration-300`,children:[(0,I.jsx)(bi,{summary:typeof e.summary_files==`string`?e.summary_files:void 0}),(0,I.jsxs)(`div`,{className:`grid gap-6 lg:grid-cols-[240px_minmax(0,1fr)] xl:grid-cols-[220px_minmax(0,1fr)_320px] lg:items-start`,children:[(0,I.jsx)(gi,{toc:c,fileChangeSummary:g,baseDirectory:e.directory,selectedFilters:l,onToggle:e=>u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onJumpToAnchor:_}),(0,I.jsx)(`div`,{className:`flex min-w-0 flex-col gap-8`,children:p.length>0?(0,I.jsx)(Tt,{id:`MessageList`,detail:{messages:p.length,virtualized:p.length>Wn},children:(0,I.jsx)(di,{messages:p,toolAnchorIds:a,sessionAgentKey:n,highlightQuery:t,apiRef:m},`${e.id}:${f}`)}):(0,I.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-6 text-sm text-[var(--console-muted)]`,children:`当前筛选条件下暂无可展示的消息内容。`})}),(0,I.jsx)(xr,{session:e,toc:c})]})]})}var hi=[{id:`user`,label:`User`},{id:`agent_message`,label:`Agent Responses`},{id:`thinking`,label:`Thinking`},{id:`plan`,label:`Plans`},{id:`tools_all`,label:`Tools`}];function gi({toc:e,fileChangeSummary:t,baseDirectory:n,selectedFilters:r,onToggle:i,onJumpToAnchor:a}){let o=r.has(`tools_all`);return(0,I.jsx)(`aside`,{className:`console-scrollbar lg:sticky lg:top-4 lg:max-h-[calc(100dvh-14rem)] lg:overflow-y-auto lg:overscroll-contain`,children:(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[var(--console-border)] px-4 py-3`,children:[(0,I.jsx)(b,{className:`size-3.5 text-[var(--console-accent)]`}),(0,I.jsx)(`span`,{className:`console-mono text-xs font-semibold uppercase tracking-[0.16em] text-[var(--console-text)]`,children:`Session TOC`})]}),(0,I.jsxs)(`div`,{className:`space-y-1 p-3`,children:[hi.filter(({id:t})=>e.counts[t]>0).map(({id:t,label:n})=>(0,I.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-sm px-2 py-2 transition-colors hover:bg-[var(--console-surface-muted)]`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:r.has(t),onChange:()=>i(t),className:`mt-0.5 size-3.5 shrink-0 rounded border-[var(--console-border-strong)] accent-[var(--console-accent-strong)]`}),(0,I.jsx)(`span`,{className:`console-mono min-w-0 flex-1 break-all text-xs leading-relaxed text-[var(--console-text)]`,children:n}),(0,I.jsx)(`span`,{className:`console-mono shrink-0 text-[11px] text-[var(--console-muted)]`,children:e.counts[t]})]},t)),e.tools.length>0?(0,I.jsx)(`div`,{className:`space-y-1 border-t border-[var(--console-border)] pt-2`,children:e.tools.map(e=>(0,I.jsxs)(`label`,{className:F(`flex items-start gap-3 rounded-sm px-2 py-2 transition-colors`,o?`cursor-pointer hover:bg-[var(--console-surface-muted)]`:`cursor-not-allowed opacity-50`),children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:o&&r.has(e.id),disabled:!o,onChange:()=>i(e.id),className:`mt-0.5 size-3.5 shrink-0 rounded border-[var(--console-border-strong)] accent-[var(--console-accent-strong)]`}),(0,I.jsx)(`span`,{className:`console-mono min-w-0 flex-1 break-all text-xs leading-relaxed text-[var(--console-muted)]`,children:e.label}),(0,I.jsx)(`span`,{className:`console-mono shrink-0 text-[11px] text-[var(--console-muted)]`,children:e.count})]},e.id))}):null]})]}),(0,I.jsx)(_i,{summary:t,baseDirectory:n,onJumpToAnchor:a})]})})}function _i({summary:e,baseDirectory:t,onJumpToAnchor:n}){let r=[{key:`read`,label:`Read`,Icon:g,items:e.read},{key:`edit`,label:`Edit`,Icon:w,items:e.edit},{key:`write`,label:`Write`,Icon:y,items:e.write},{key:`delete`,label:`Delete`,Icon:v,items:e.delete}].filter(e=>e.items.length>0);return r.length===0?null:(0,I.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[var(--console-border)] px-4 py-3`,children:[(0,I.jsx)(ne,{className:`size-3.5 text-[var(--console-accent)]`}),(0,I.jsx)(`span`,{className:`console-mono text-xs font-semibold uppercase tracking-[0.16em] text-[var(--console-text)]`,children:`File Tracker`})]}),(0,I.jsx)(`div`,{className:`space-y-3 p-3`,children:r.map(({key:e,label:r,Icon:i,items:a})=>(0,I.jsx)(vi,{label:r,Icon:i,items:a,baseDirectory:t,onJumpToAnchor:n},e))})]})}function vi({label:e,Icon:t,items:n,baseDirectory:r,onJumpToAnchor:i}){let[a,o]=(0,M.useState)(!1);return(0,I.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[#fafafa]`,children:[(0,I.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:`flex w-full items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-[var(--console-surface-muted)]`,children:[(0,I.jsx)(t,{className:`size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,I.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,I.jsx)(`span`,{className:`console-mono shrink-0 text-[10px] text-[var(--console-muted)]`,children:n.length}),a?(0,I.jsx)(c,{className:`size-3.5 shrink-0 text-[var(--console-muted)]`}):(0,I.jsx)(fe,{className:`size-3.5 shrink-0 text-[var(--console-muted)]`})]}),a?(0,I.jsx)(`div`,{className:`space-y-1 border-t border-[var(--console-border)] p-2`,children:n.map(e=>(0,I.jsx)(yi,{item:e,baseDirectory:r,onJumpToAnchor:i},`${e.path}:${e.latestAnchorId||e.latestTime}`))}):null]})}function yi({item:e,baseDirectory:t,onJumpToAnchor:n}){let[r,i]=(0,M.useState)(0);function a(t){let r=e.anchors.length;if(r===0)return;let a=(t%r+r)%r;i(a);let o=e.anchors[a];o&&n(o.anchorId)}return(0,I.jsxs)(`div`,{className:`flex items-start gap-2 rounded-sm px-2 py-2 transition-colors hover:bg-[var(--console-surface-muted)]`,children:[(0,I.jsx)(`button`,{type:`button`,title:e.path,onClick:()=>a(r),className:`min-w-0 flex-1 text-left`,children:(0,I.jsx)(`span`,{className:`console-mono block break-all text-xs text-[var(--console-text)]`,children:_r(e.path,t)})}),e.anchors.length>1?(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,I.jsx)(`button`,{type:`button`,"aria-label":`Previous ${e.path}`,onClick:()=>a(r-1),className:`rounded-sm border border-[var(--console-border)] p-1 text-[var(--console-muted)] transition-colors hover:bg-white`,children:(0,I.jsx)(c,{className:`size-3`})}),(0,I.jsxs)(`span`,{className:`console-mono text-[10px] text-[var(--console-muted)]`,children:[r+1,`/`,e.anchors.length]}),(0,I.jsx)(`button`,{type:`button`,"aria-label":`Next ${e.path}`,onClick:()=>a(r+1),className:`rounded-sm border border-[var(--console-border)] p-1 text-[var(--console-muted)] transition-colors hover:bg-white`,children:(0,I.jsx)(fe,{className:`size-3`})})]}):(0,I.jsx)(`button`,{type:`button`,title:`Jump to tool call`,onClick:()=>a(0),className:`console-mono shrink-0 text-[10px] text-[var(--console-muted)]`,children:e.count})]})}function bi({summary:e,defaultExpanded:t=!1}){let n=typeof e==`string`?e.trim():``,[r,i]=(0,M.useState)(t);return n?(0,I.jsxs)(`section`,{className:`rounded-sm border border-[var(--console-border)] bg-white shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:[(0,I.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,I.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,I.jsx)(ne,{className:`size-3.5 text-[var(--console-accent)]`}),`Session Summary`]}),r?(0,I.jsx)(c,{className:`size-3.5 text-[var(--console-muted)]`}):(0,I.jsx)(fe,{className:`size-3.5 text-[var(--console-muted)]`})]}),r?(0,I.jsx)(`div`,{className:`border-t border-[var(--console-border)] px-4 py-4`,children:(0,I.jsx)(`div`,{className:`console-markdown text-sm leading-relaxed text-[var(--console-text)]`,children:(0,I.jsx)(_t,{text:n})})}):null]}):null}function xi({msg:e,blocks:t,toolAnchorIds:n,formatTokens:r,sessionAgentKey:i,highlightQuery:a}){let o=e.role===`user`,s=At(e,i),c=()=>{let e=i.toLowerCase(),t=N.getAgentName(e),n=N.agents[e]?.icon;return(0,I.jsx)(I.Fragment,{children:n?(0,I.jsx)(`img`,{src:n,alt:t,className:`size-4 rounded-sm object-cover`}):(0,I.jsx)(l,{className:`size-4 text-[var(--console-muted)]`})})},u=e.mode?e.mode.toUpperCase():null,d=e.model||null,f=Ur(e),p=ti(e.time_created);return(0,I.jsx)(`article`,{className:`w-full border-l-2 border-[var(--console-thread)] pl-4 pr-3 md:pr-5`,children:(0,I.jsxs)(`div`,{className:`flex gap-4`,children:[(0,I.jsx)(`div`,{className:`shrink-0 pt-1`,children:(0,I.jsx)(`div`,{className:`flex size-8 items-center justify-center rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)]`,children:o?(0,I.jsx)(ee,{className:`size-4 text-[var(--console-muted)]`}):c()})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,I.jsx)(`span`,{className:`console-mono text-sm font-bold tracking-wide text-[var(--console-text)]`,children:f}),(0,I.jsx)(`time`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:p}),u&&(0,I.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-1.5 py-0.5 text-[10px] text-[var(--console-muted)]`,children:u}),d&&(0,I.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})]}),s?(0,I.jsx)(Si,{}):t.map((e,t)=>e.type===`reasoning`?(0,I.jsx)(Ci,{parts:e.parts,highlightQuery:a},t):e.type===`plan`?(0,I.jsx)(Ti,{parts:e.parts,highlightQuery:a},t):e.type===`tool`?(0,I.jsx)(wi,{parts:e.parts,toolAnchorIds:n,sessionAgentKey:i,highlightQuery:a},t):(0,I.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4 shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:(0,I.jsx)(`div`,{className:`console-markdown text-sm leading-relaxed text-[var(--console-text)]`,children:e.parts.map((e,t)=>(0,I.jsx)(Xn,{text:Et(e.text),highlightQuery:a},t))})},t)),!o&&(e.tokens||e.cost)&&(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.tokens?.input?(0,I.jsxs)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] text-[var(--console-muted)]`,children:[`INPUT `,r(e.tokens.input)]}):null,e.tokens?.output?(0,I.jsxs)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] text-[var(--console-muted)]`,children:[`OUTPUT `,r(e.tokens.output)]}):null,e.tokens?.reasoning?(0,I.jsxs)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] text-[var(--console-muted)]`,children:[`REASONING `,r(e.tokens.reasoning)]}):null,e.cost?(0,I.jsxs)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] text-[var(--console-muted)]`,children:[e.cost_source===`estimated`?`EST COST`:`COST`,` $`,e.cost.toFixed(4)]}):null]})]})]})})}function Si(){return(0,I.jsx)(`div`,{className:`space-y-2`,children:(0,I.jsx)(`div`,{className:`flex flex-wrap items-start gap-2`,children:(0,I.jsx)(`div`,{className:`w-full rounded-sm border border-[var(--console-border-strong)] bg-white px-3 py-2 text-left shadow-[2px_2px_0_0_rgba(15,23,42,0.05)] md:w-[560px]`,children:(0,I.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,I.jsx)(te,{className:`mt-0.5 size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,I.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:`abort`})})]})})})})}function Ci({parts:e,highlightQuery:t}){let[n,r]=(0,M.useState)(!1),i=e.map(e=>Et(e.text)).filter(Boolean).join(`
33
+
34
+ `);return(0,I.jsxs)(`div`,{className:`overflow-hidden rounded-sm border border-[var(--console-thinking-border)] bg-[var(--console-thinking-bg)]`,children:[(0,I.jsxs)(`div`,{className:`flex cursor-pointer items-center justify-between bg-[var(--console-surface-muted)] px-3 py-2`,onClick:()=>r(!n),children:[(0,I.jsxs)(`span`,{className:`console-mono flex items-center gap-2 text-xs font-medium text-[var(--console-muted)]`,children:[(0,I.jsx)(ae,{className:`size-3.5`}),`Thinking`]}),(0,I.jsx)(`span`,{className:`text-[var(--console-muted)]`,children:n?(0,I.jsx)(c,{className:`w-4 h-4`}):(0,I.jsx)(fe,{className:`w-4 h-4`})})]}),n&&(0,I.jsx)(`div`,{className:`border-t border-dashed border-[var(--console-thinking-border)] px-4 py-3`,children:(0,I.jsx)(`div`,{className:`console-mono whitespace-pre-wrap text-xs leading-relaxed text-[var(--console-muted)]`,children:Yn(i,t)})})]})}function wi({parts:e,toolAnchorIds:t,sessionAgentKey:n,highlightQuery:r}){return(0,I.jsx)(`div`,{className:`space-y-2`,children:(0,I.jsx)(`div`,{className:`space-y-2`,children:e.map((e,i)=>(0,I.jsx)(Di,{tool:e,anchorId:t.get(e),sessionAgentKey:n,highlightQuery:r},i))})})}function Ti({parts:e,highlightQuery:t}){return(0,I.jsx)(`div`,{className:`space-y-2`,children:e.map((e,n)=>(0,I.jsx)(Ei,{part:e,highlightQuery:t},n))})}function Ei({part:e,highlightQuery:t}){let[n,r]=(0,M.useState)(!1),i=Ht(e),a=i.approvalStatus===`fail`?Hn.error:Hn.completed,o=a.icon;return(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2`,children:[(0,I.jsx)(`div`,{className:`w-full md:w-[560px] rounded-sm border border-[var(--console-border-strong)] bg-white px-3 py-2 text-left shadow-[2px_2px_0_0_rgba(15,23,42,0.05)] ${i.expandable?`transition-colors hover:bg-[var(--console-surface-muted)]`:``}`,children:i.expandable?(0,I.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-2 text-left`,onClick:()=>r(!n),children:[(0,I.jsx)(u,{className:`mt-0.5 size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,I.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:i.title})}),(0,I.jsx)(`span`,{className:`mt-0.5 shrink-0 text-[var(--console-muted)]`,children:n?(0,I.jsx)(c,{className:`size-3.5`}):(0,I.jsx)(fe,{className:`size-3.5`})})]}):(0,I.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,I.jsx)(u,{className:`mt-0.5 size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,I.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:i.title})})]})}),(0,I.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,I.jsx)(o,{className:`size-3`}),a.label]})]}),i.expandable&&n?(0,I.jsxs)(`div`,{className:`overflow-hidden rounded-sm border border-[var(--console-border)] bg-white shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:[(0,I.jsx)(`div`,{className:`border-b border-[var(--console-border)] bg-[var(--console-surface-muted)] px-3 py-1.5`,children:(0,I.jsx)(`span`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:i.contentLabel})}),(0,I.jsx)(`div`,{className:`p-4`,children:(0,I.jsx)(`div`,{className:`console-markdown text-sm leading-relaxed text-[var(--console-text)]`,children:(0,I.jsx)(Xn,{text:i.contentMarkdown,highlightQuery:t})})})]}):null]})}function Di({tool:e,anchorId:t,sessionAgentKey:n,highlightQuery:r}){let[i,a]=(0,M.useState)(!1),o=Gr(e),s=$r(n,e,o),l=Hn[o.status],u=l.icon,d=s.Icon;return(0,I.jsxs)(`div`,{id:t,className:`scroll-mt-6 space-y-2`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2`,children:[(0,I.jsx)(`div`,{className:`w-full md:w-[560px] rounded-sm border border-[var(--console-border-strong)] bg-white px-3 py-2 text-left shadow-[2px_2px_0_0_rgba(15,23,42,0.05)] ${s.expandable?`transition-colors hover:bg-[var(--console-surface-muted)]`:``}`,children:s.expandable?(0,I.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-2 text-left`,onClick:()=>a(!i),children:[(0,I.jsx)(d,{className:`mt-0.5 size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:s.title}),s.secondaryText?(0,I.jsx)(`span`,{className:`console-mono mt-0.5 block whitespace-pre-wrap break-words text-xs leading-relaxed text-[var(--console-muted)]`,children:Yn(s.secondaryText,r)}):null]}),(0,I.jsx)(`span`,{className:`mt-0.5 shrink-0 text-[var(--console-muted)]`,children:i?(0,I.jsx)(c,{className:`size-3.5`}):(0,I.jsx)(fe,{className:`size-3.5`})})]}):(0,I.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,I.jsx)(d,{className:`mt-0.5 size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:s.title}),s.secondaryText?(0,I.jsx)(`span`,{className:`console-mono mt-0.5 block whitespace-pre-wrap break-words text-xs leading-relaxed text-[var(--console-muted)]`,children:Yn(s.secondaryText,r)}):null]})]})}),(0,I.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 ${l.className}`,children:[(0,I.jsx)(u,{className:`size-3 ${o.status===`running`?`animate-spin`:``}`}),l.label]})]}),s.expandable&&i?(0,I.jsxs)(`div`,{className:`overflow-hidden rounded-sm border border-[var(--console-border)] bg-white shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:[(0,I.jsx)(`div`,{className:`border-b border-[var(--console-border)] bg-[var(--console-surface-muted)] px-3 py-1.5`,children:(0,I.jsx)(`span`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:`Output`})}),(0,I.jsxs)(`div`,{className:`space-y-3 p-3`,children:[s.details.length>0?(0,I.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[#fafafa] px-3 py-2`,children:(0,I.jsx)(`div`,{className:`space-y-2`,children:s.details.map(e=>(0,I.jsxs)(`div`,{className:`flex flex-col gap-1 md:flex-row md:items-start md:gap-3`,children:[(0,I.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,I.jsx)(`span`,{className:`console-mono whitespace-pre-wrap break-all text-xs leading-relaxed text-[var(--console-text)]`,children:Yn(e.value,r)})]},`${e.label}:${e.value}`))})}):null,(0,I.jsx)(Vn,{outputContent:s.outputContent})]}),s.showInputPreview?(0,I.jsxs)(`div`,{className:`border-t border-[var(--console-border)] bg-[#fafafa] px-3 py-2`,children:[(0,I.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:`Input Preview`}),(0,I.jsx)(`pre`,{className:`console-mono mt-1 max-h-[200px] overflow-x-auto whitespace-pre-wrap break-all text-xs leading-relaxed text-[var(--console-muted)]`,children:Yn(o.inputText||`{}`,r)})]}):null]}):null]})}var Oi=[{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 ki({className:e}){return(0,I.jsx)(`div`,{className:`rounded-sm bg-[var(--console-border)] ${e}`})}function Ai(){return(0,I.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,I.jsx)(`div`,{className:`flex flex-1 flex-col gap-8`,children:Oi.map(e=>(0,I.jsx)(`article`,{className:`w-full border-l-2 border-[var(--console-thread)] pl-4 pr-3 md:pr-5`,children:(0,I.jsxs)(`div`,{className:`flex gap-4`,children:[(0,I.jsx)(`div`,{className:`shrink-0 pt-1`,children:(0,I.jsx)(`div`,{className:`flex size-8 items-center justify-center rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)]`,children:(0,I.jsx)(`div`,{className:`size-3.5 rounded-sm bg-[var(--console-border-strong)] animate-pulse`})})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,I.jsx)(ki,{className:`${e.roleWidth} h-3 animate-pulse`}),(0,I.jsx)(ki,{className:`${e.timeWidth} h-2.5 animate-pulse`})]}),(0,I.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4 shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:(0,I.jsx)(`div`,{className:`space-y-2`,children:e.bodyWidths.map(t=>(0,I.jsx)(ki,{className:`${t} h-3 animate-pulse`},`${e.id}-${t}`))})})]})]})},e.id))}),(0,I.jsx)(`div`,{className:`min-h-24 flex-1 rounded-sm border border-[var(--console-border)] bg-white/60 animate-pulse`})]})}function ji({active:e,onToggle:t,className:n=``}){return(0,I.jsx)(`button`,{type:`button`,onClick:e=>{e.preventDefault(),e.stopPropagation(),t()},"aria-label":e?`取消收藏会话`:`收藏会话`,title:e?`取消收藏`:`收藏`,className:`inline-flex size-6 shrink-0 items-center justify-center rounded-sm border transition-colors ${n} ${e?`border-[var(--console-border)] bg-[var(--console-surface-muted)] text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] opacity-70 hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)] hover:text-[var(--console-text)] hover:opacity-100`}`,children:(0,I.jsx)(ie,{className:`size-3`,strokeWidth:1.8,fill:e?`currentColor`:`none`})})}function Mi(e){return e.toLocaleString(`en-US`)}function Ni(e){return e===0?`$0.00`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function Pi(e){if(e===`recorded`)return`recorded`;if(e===`estimated`)return`estimated`}function Fi(e){return e.total_tokens??e.total_input_tokens+e.total_output_tokens}function Ii(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 Li({label:e,value:t,hint:n}){return(0,I.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,I.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-wider text-[var(--console-muted)]`,children:e}),(0,I.jsx)(`p`,{className:`console-mono mt-2 text-xl font-semibold text-[var(--console-text)]`,children:t}),n?(0,I.jsx)(`p`,{className:`mt-1 text-xs text-[var(--console-muted)]`,children:n}):null]})}function Ri({label:e,value:t}){return(0,I.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] p-3`,children:[(0,I.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-wider text-[var(--console-muted)]`,children:e}),(0,I.jsx)(`p`,{className:`console-mono mt-2 break-all text-sm leading-6 text-[var(--console-text)]`,children:t})]})}function zi({code:e,title:t,description:n,aside:r,iconSrc:i,iconAlt:a}){return(0,I.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border-strong)] bg-white p-5 md:p-6`,children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-5 md:flex-row md:items-start md:justify-between`,children:[(0,I.jsxs)(`div`,{className:`max-w-2xl`,children:[(0,I.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,I.jsxs)(`div`,{className:`mt-4 flex items-start gap-3`,children:[i?(0,I.jsx)(`img`,{src:i,alt:a||``,className:`mt-1 size-8 shrink-0 object-contain`}):null,(0,I.jsx)(`h2`,{className:`console-mono text-2xl leading-tight font-semibold tracking-tight text-[var(--console-text)] md:text-[2rem]`,children:t})]}),(0,I.jsx)(`p`,{className:`mt-3 max-w-[42rem] text-sm leading-7 text-[var(--console-muted)]`,children:n})]}),(0,I.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,I.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-[0.16em] text-[var(--console-muted)]`,children:`STATUS NOTE`}),(0,I.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-[var(--console-text)]`,children:r})]})]})})}function Bi({agentItems:e}){return(0,I.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,I.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,I.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Known Agents`}),(0,I.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` items`]})]}),(0,I.jsx)(`ul`,{className:`grid gap-2 sm:grid-cols-2`,children:e.map(e=>(0,I.jsx)(`li`,{children:(0,I.jsxs)(x,{to:`/${e.key}`,className:`flex min-h-11 items-center gap-2 rounded-sm border border-transparent px-3 py-2 transition-colors duration-200 hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--console-accent)]`,children:[(0,I.jsx)(`img`,{src:e.icon,alt:e.name,className:`size-4 object-contain`}),(0,I.jsx)(`span`,{className:`console-mono flex-1 text-xs text-[var(--console-text)]`,children:e.name}),(0,I.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:e.count})]})},e.key))})]})}function Vi({sessions:e,isBookmarked:t,onToggleBookmark:n}){return e.length===0?(0,I.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4 text-sm text-[var(--console-muted)]`,children:`No sessions yet`}):(0,I.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,I.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,I.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Recent Sessions`}),(0,I.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` items`]})]}),(0,I.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>{let r=t(e.agentKey,e.id);return(0,I.jsx)(`li`,{children:(0,I.jsxs)(`div`,{className:`flex items-start gap-2 rounded-sm border border-transparent px-2 py-1.5 transition-colors hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,I.jsxs)(x,{to:`/${e.fullPath}`,className:`min-w-0 flex-1`,children:[(0,I.jsx)(`p`,{className:`line-clamp-1 text-sm text-[var(--console-text)]`,children:e.title}),(0,I.jsxs)(`p`,{className:`console-mono mt-0.5 text-[11px] text-[var(--console-muted)]`,children:[`/`,e.fullPath,` ·`,` `,Ii(e.time_updated||e.time_created)]}),(0,I.jsx)(qe,{tags:e.smart_tags,className:`mt-1.5`})]}),(0,I.jsx)(ji,{active:r,onToggle:()=>n(e)})]})},e.id)})})]})}function Hi({type:e,sessions:t,agentItems:n,activeAgentKey:r,attemptedAgentKey:i,attemptedSessionSlug:a,isBookmarked:o,onToggleBookmark:s}){let c=t.toSorted((e,t)=>(t.time_updated||t.time_created||0)-(e.time_updated||e.time_created||0)),l=c.slice(0,5),u=t.reduce((e,t)=>e+t.stats.message_count,0),d=t.reduce((e,t)=>e+Fi(t.stats),0),f=t.reduce((e,t)=>e+t.stats.total_cost,0),p=f>0?t.some(e=>e.stats.cost_source===`estimated`)?`estimated`:`recorded`:void 0,m=c[0]?.time_updated||c[0]?.time_created;if(e===`missing-agent`){let e=`/${i||`unknown`}${a?`/${a}`:``}`;return(0,I.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,I.jsx)(zi,{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,I.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,I.jsx)(Ri,{label:`Requested Agent`,value:i||`unknown`}),(0,I.jsx)(Ri,{label:`Requested Path`,value:e}),a?(0,I.jsx)(Ri,{label:`Requested Session`,value:a}):null]}),(0,I.jsx)(Bi,{agentItems:n})]})}if(e===`missing-session`){let e=r||N.getDefaultAgentKey()||`claudecode`,t=N.agents[e],n=t?.name||e,i=t?.icon,c=a||`unknown-session`;return(0,I.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,I.jsx)(zi,{code:`404 / SESSION`,title:`This session isn't in the index.`,description:`${n} is available, but the session you're looking for does not exist in the current index. The slug may be incorrect, or the record may never have been part of this dataset.`,aside:`We checked the current path, but nothing matched. The session list on the left is still available.`,iconSrc:i,iconAlt:n}),(0,I.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] p-3`,children:[(0,I.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-wider text-[var(--console-muted)]`,children:`Agent`}),(0,I.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[i?(0,I.jsx)(`img`,{src:i,alt:n,className:`size-4 shrink-0 object-contain`}):null,(0,I.jsx)(`p`,{className:`console-mono break-all text-sm leading-6 text-[var(--console-text)]`,children:n})]})]}),(0,I.jsx)(Ri,{label:`Session`,value:c})]}),(0,I.jsx)(Vi,{sessions:l,isBookmarked:o,onToggleBookmark:s})]})}if(e===`global`)return(0,I.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,I.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,I.jsx)(Li,{label:`Total Sessions`,value:Mi(t.length)}),(0,I.jsx)(Li,{label:`Total Messages`,value:Mi(u)}),(0,I.jsx)(Li,{label:`Latest Activity`,value:Ii(m),hint:m?new Date(m).toLocaleString(`zh-CN`):void 0})]}),(0,I.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,I.jsx)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:`Agents`}),(0,I.jsx)(`ul`,{className:`grid gap-2 sm:grid-cols-2`,children:n.map(e=>(0,I.jsx)(`li`,{children:(0,I.jsxs)(x,{to:`/${e.key}`,className:`flex items-center gap-2 rounded-sm border border-transparent px-2 py-1.5 transition-colors hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,I.jsx)(`img`,{src:e.icon,alt:e.name,className:`size-4 object-contain`}),(0,I.jsx)(`span`,{className:`console-mono flex-1 text-xs text-[var(--console-text)]`,children:e.name}),(0,I.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:e.count})]})},e.key))})]}),(0,I.jsx)(Vi,{sessions:l,isBookmarked:o,onToggleBookmark:s})]});let h=r?N.agents[r]:null,g=h?h.name:`Unknown Agent`;return(0,I.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,I.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[h?(0,I.jsx)(`img`,{src:h.icon,alt:g,className:`size-6 object-contain`}):null,(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`console-mono text-sm font-semibold text-[var(--console-text)]`,children:g}),(0,I.jsx)(`p`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:`Select a session from the left to view details`})]})]})}),(0,I.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-4`,children:[(0,I.jsx)(Li,{label:`Sessions`,value:Mi(t.length)}),(0,I.jsx)(Li,{label:`Messages`,value:Mi(u)}),(0,I.jsx)(Li,{label:`Tokens`,value:Mi(d)}),(0,I.jsx)(Li,{label:`Total Cost`,value:Ni(f),hint:Pi(p)})]}),(0,I.jsx)(Vi,{sessions:l,isBookmarked:o,onToggleBookmark:s})]})}var Ui=`codesesh:bookmarks:v1`;function Wi(e){return typeof e==`object`&&!!e}function Gi(e){return Wi(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 Ki(e){return Wi(e)?typeof e.sessionId==`string`&&typeof e.agentKey==`string`&&typeof e.fullPath==`string`&&typeof e.title==`string`&&typeof e.directory==`string`&&typeof e.time_created==`number`&&(e.time_updated==null||typeof e.time_updated==`number`)&&(e.bookmarked_at==null||typeof e.bookmarked_at==`number`)&&Gi(e.stats):!1}function qi(e,t){return`${e}:${t}`}function Ji(e,t){return{sessionId:e.id,agentKey:t,fullPath:e.slug,title:e.title,directory:e.directory,time_created:e.time_created,time_updated:e.time_updated,stats:e.stats,bookmarked_at:Date.now()}}function Yi(){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.filter(Ki).toSorted(Zi):[]}catch{return[]}}function Xi(){typeof window>`u`||window.localStorage.removeItem(Ui)}function Zi(e,t){let n=e.time_updated??e.time_created;return(t.time_updated??t.time_created)-n}function Qi(e,t){if(e.length===0||t.length===0)return e;let n=new Map(t.map(e=>{let t=Ji(e,e.slug.split(`/`)[0]?.toLowerCase()??`unknown`);return[qi(t.agentKey,t.sessionId),t]})),r=!1,i=e.map(e=>{let t=n.get(qi(e.agentKey,e.sessionId));return!t||t.fullPath===e.fullPath&&t.title===e.title&&t.directory===e.directory&&t.time_created===e.time_created&&t.time_updated===e.time_updated&&t.stats.message_count===e.stats.message_count&&t.stats.total_input_tokens===e.stats.total_input_tokens&&t.stats.total_output_tokens===e.stats.total_output_tokens&&t.stats.total_cost===e.stats.total_cost&&t.stats.total_tokens===e.stats.total_tokens?e:(r=!0,{...t,bookmarked_at:e.bookmarked_at})});return r?i.toSorted(Zi):e}var $i=new Set([`git_remote`,`git_common_dir`,`manifest_path`,`synthetic`,`path`,`loose`]);function ea(e){return $i.has(e)}function ta(e){return`${e.kind}:${e.key}`}function na(e){return decodeURIComponent(e)}function ra(e){return`/projects/${encodeURIComponent(e.kind)}/${encodeURIComponent(e.key)}`}var ia={light:``,dark:`.dark`},aa={width:320,height:200},oa=M.createContext(null);function sa(){let e=M.useContext(oa);if(!e)throw Error(`useChart must be used within a <ChartContainer />`);return e}function ca({id:e,className:t,children:n,config:r,initialDimension:i=aa,...a}){let o=M.useId(),s=`chart-${e??o.replace(/:/g,``)}`;return(0,I.jsx)(oa.Provider,{value:{config:r},children:(0,I.jsxs)(`div`,{"data-slot":`chart`,"data-chart":s,className:F(`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,I.jsx)(la,{id:s,config:r}),(0,I.jsx)(re,{initialDimension:i,children:n})]})})}var la=({id:e,config:t})=>{let n=Object.entries(t).filter(([,e])=>e.theme??e.color);return n.length?(0,I.jsx)(`style`,{dangerouslySetInnerHTML:{__html:Object.entries(ia).map(([t,r])=>`
35
+ ${r} [data-chart=${e}] {
36
+ ${n.map(([e,n])=>{let r=n.theme?.[t]??n.color;return r?` --color-${e}: ${r};`:null}).join(`
37
+ `)}
38
+ }
39
+ `).join(`
40
+ `)}}):null},ua=le;function da({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}=sa(),m=M.useMemo(()=>{if(i||!t?.length)return null;let[e]=t,n=fa(p,e,`${f??e?.dataKey??e?.name??`value`}`),r=!f&&typeof o==`string`?p[o]?.label??o:n?.label;return s?(0,I.jsx)(`div`,{className:F(`font-medium`,c),children:s(r,t)}):r?(0,I.jsx)(`div`,{className:F(`font-medium`,c),children:r}):null},[o,s,t,i,c,p,f]);if(!e||!t?.length)return null;let h=t.length===1&&r!==`dot`;return(0,I.jsxs)(`div`,{className:F(`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,I.jsx)(`div`,{className:`grid gap-1.5`,children:t.filter(e=>e.type!==`none`).map((e,t)=>{let n=fa(p,e,`${d??e.name??e.dataKey??`value`}`),i=u??e.payload?.fill??e.color;return(0,I.jsx)(`div`,{className:F(`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,I.jsxs)(I.Fragment,{children:[n?.icon?(0,I.jsx)(n.icon,{}):!a&&(0,I.jsx)(`div`,{className:F(`shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)`,{"h-2.5 w-2.5":r===`dot`,"w-1":r===`line`,"w-0 border-[1.5px] border-dashed bg-transparent":r===`dashed`,"my-0.5":h&&r===`dashed`}),style:{"--color-bg":i,"--color-border":i}}),(0,I.jsxs)(`div`,{className:F(`flex flex-1 justify-between leading-none`,h?`items-end`:`items-center`),children:[(0,I.jsxs)(`div`,{className:`grid gap-1.5`,children:[h?m:null,(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:n?.label??e.name})]}),e.value!=null&&(0,I.jsx)(`span`,{className:`font-mono font-medium text-foreground tabular-nums`,children:typeof e.value==`number`?e.value.toLocaleString():String(e.value)})]})]})},t)})})]})}function fa(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 pa(e){return e.toLocaleString(`en-US`)}function ma(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:pa(e)}function ha(e){return e===0?`$0.00`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function ga(e){if(e===`recorded`)return`recorded`;if(e===`estimated`)return`estimated`}function _a(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 va({label:e,value:t,hint:n}){return(0,I.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,I.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-wider text-[var(--console-muted)]`,children:e}),(0,I.jsx)(`p`,{className:`console-mono mt-2 text-xl font-semibold text-[var(--console-text)]`,children:t}),n?(0,I.jsx)(`p`,{className:`mt-1 text-xs text-[var(--console-muted)]`,children:n}):null]})}function ya(e){return e.length>=10?e.slice(5):e}function ba({buckets:e}){let[t,n]=(0,M.useState)(null),r=(0,M.useMemo)(()=>Math.max(1,...e.map(e=>e.sessions)),[e]),i=(0,M.useMemo)(()=>e.reduce((e,t)=>e+t.sessions,0),[e]),a=(0,M.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,I.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,I.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Daily Activity`}),(0,I.jsxs)(`p`,{className:`console-mono mt-1 text-[11px] text-[var(--console-muted)]`,children:[`Session activity · last `,e.length,` days`]})]}),(0,I.jsx)(`span`,{className:`console-mono text-right text-[11px] text-[var(--console-muted)]`,children:t?`${t.date} · ${pa(t.sessions)} sessions · ${pa(t.messages)} msgs`:`${pa(i)} in range`})]}),(0,I.jsx)(`div`,{className:`flex h-32 items-end gap-[2px]`,onMouseLeave:()=>n(null),children:e.map(e=>{let i=e.sessions>0?Math.max(Math.round(e.sessions/r*128),4):2,a=`${e.date} · ${e.sessions} sessions · ${e.messages} msgs`,o=t?.date===e.date;return(0,I.jsx)(`div`,{title:a,onMouseEnter:()=>n(e),className:`flex-1 cursor-default rounded-t-[1px] transition-opacity ${e.sessions>0?`bg-[var(--console-accent)]`:`bg-[var(--console-surface-muted)]`} ${o?`opacity-70`:`opacity-100`}`,style:{height:`${i}px`}},e.date)})}),(0,I.jsx)(`div`,{className:`console-mono mt-2 flex text-[10px] text-[var(--console-muted)]`,children:e.map((e,t)=>(0,I.jsx)(`span`,{className:`flex-1 text-center`,children:a.has(t)?ya(e.date):``},e.date))})]})}var xa={input:`#4A9EFF`,output:`#7C5CFF`,cache_read:`#3FB68B`,cache_create:`#E8A23B`},Sa={input:`Input`,output:`Output`,cache_read:`Cache Read`,cache_create:`Cache Create`};function Ca({buckets:e}){let[t,n]=(0,M.useState)(null),r=(0,M.useMemo)(()=>Math.max(1,...e.map(e=>e.input+e.output+e.cache_read+e.cache_create)),[e]),i=(0,M.useMemo)(()=>e.reduce((e,t)=>e+t.input+t.output+t.cache_read+t.cache_create,0),[e]),a=(0,M.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,I.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,I.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Daily Token Activity`}),(0,I.jsxs)(`p`,{className:`console-mono mt-1 text-[11px] text-[var(--console-muted)]`,children:[`Token breakdown · last `,e.length,` days`]})]}),(0,I.jsx)(`span`,{className:`console-mono text-right text-[11px] text-[var(--console-muted)]`,children:t?`${t.date} · ${ma(t.input+t.output+t.cache_read+t.cache_create)} total`:`${ma(i)} in range`})]}),t?(0,I.jsx)(`div`,{className:`mb-2 flex gap-4`,children:[`input`,`output`,`cache_read`,`cache_create`].map(e=>(0,I.jsxs)(`span`,{className:`console-mono flex items-center gap-1.5 text-[10px] text-[var(--console-muted)]`,children:[(0,I.jsx)(`span`,{className:`inline-block size-2 rounded-full`,style:{backgroundColor:xa[e]}}),Sa[e],`: `,ma(t[e])]},e))}):(0,I.jsx)(`div`,{className:`mb-2 flex gap-4`,children:[`input`,`output`,`cache_read`,`cache_create`].map(e=>(0,I.jsxs)(`span`,{className:`console-mono flex items-center gap-1.5 text-[10px] text-[var(--console-muted)]`,children:[(0,I.jsx)(`span`,{className:`inline-block size-2 rounded-full`,style:{backgroundColor:xa[e]}}),Sa[e]]},e))}),(0,I.jsx)(`div`,{className:`flex h-32 items-end gap-[2px]`,onMouseLeave:()=>n(null),children:e.map(e=>{let i=e.input+e.output+e.cache_read+e.cache_create,a=i>0?Math.max(Math.round(i/r*128),4):2,o=t?.date===e.date,s=i>0?[{key:`input`,value:e.input},{key:`output`,value:e.output},{key:`cache_read`,value:e.cache_read},{key:`cache_create`,value:e.cache_create}]:[];return(0,I.jsx)(`div`,{onMouseEnter:()=>n(e),className:`flex flex-1 cursor-default flex-col justify-end overflow-hidden rounded-t-[1px] transition-opacity ${o?`opacity-70`:`opacity-100`}`,style:{height:`${a}px`},children:i>0?s.map(e=>{let t=Math.max(Math.round(e.value/i*a),0);return t===0?null:(0,I.jsx)(`div`,{style:{height:`${t}px`,backgroundColor:xa[e.key]}},e.key)}):(0,I.jsx)(`div`,{className:`h-full bg-[var(--console-surface-muted)]`})},e.date)})}),(0,I.jsx)(`div`,{className:`console-mono mt-2 flex text-[10px] text-[var(--console-muted)]`,children:e.map((e,t)=>(0,I.jsx)(`span`,{className:`flex-1 text-center`,children:a.has(t)?ya(e.date):``},e.date))})]})}var wa=[`#4A9EFF`,`#7C5CFF`,`#3FB68B`,`#E8A23B`,`#E5484D`,`#5BCEDA`,`#F472B6`,`#A78BFA`,`#FB923C`,`#6EE7B7`];function Ta({entries:e}){let t=(0,M.useMemo)(()=>e.filter(e=>e.tokens>0),[e]),n=(0,M.useMemo)(()=>t.reduce((e,t)=>e+t.tokens,0),[t]);if(t.length===0||n===0)return(0,I.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4 text-sm text-[var(--console-muted)]`,children:`No model data yet`});let r=t.map((e,t)=>({...e,chartKey:`model${t}`,fraction:e.tokens/n,fill:wa[t%wa.length]})),i=r.reduce((e,t)=>(e[t.chartKey]={label:t.model,color:t.fill},e),{});return(0,I.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,I.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,I.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Model Distribution`}),(0,I.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[t.length,` models`]})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-6`,children:[(0,I.jsxs)(`div`,{className:`flex shrink-0 flex-col items-center`,children:[(0,I.jsx)(ca,{config:i,className:`aspect-square size-[160px]`,children:(0,I.jsxs)(de,{children:[(0,I.jsx)(ua,{content:(0,I.jsx)(da,{hideLabel:!0,nameKey:`chartKey`,formatter:e=>(0,I.jsxs)(`span`,{className:`font-mono font-medium text-foreground tabular-nums`,children:[pa(Number(e)),` tokens`]})})}),(0,I.jsx)(oe,{data:r,dataKey:`tokens`,nameKey:`chartKey`,outerRadius:70,paddingAngle:1,strokeWidth:0,isAnimationActive:!1})]})}),(0,I.jsxs)(`div`,{className:`console-mono -mt-1 text-center`,children:[(0,I.jsx)(`div`,{className:`text-xs font-semibold text-[var(--console-text)]`,children:ma(n)}),(0,I.jsx)(`div`,{className:`text-[10px] text-[var(--console-muted)]`,children:`tokens`})]})]}),(0,I.jsx)(`ul`,{className:`min-w-0 flex-1 space-y-1.5`,children:r.map(e=>(0,I.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`inline-block size-2.5 shrink-0 rounded-full`,style:{backgroundColor:e.fill}}),(0,I.jsx)(`span`,{className:`console-mono min-w-0 flex-1 truncate text-xs text-[var(--console-text)]`,children:e.model}),(0,I.jsxs)(`span`,{className:`console-mono shrink-0 text-[11px] text-[var(--console-muted)]`,children:[(e.fraction*100).toFixed(1),`%`]})]},e.model))})]})]})}function Ea({perAgent:e}){let t=(0,M.useMemo)(()=>e.reduce((e,t)=>e+t.sessions,0),[e]);return t===0||e.length===0?(0,I.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4 text-sm text-[var(--console-muted)]`,children:`No agent data yet`}):(0,I.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,I.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,I.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Agent Distribution`}),(0,I.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` agents`]})]}),(0,I.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>{let n=t>0?e.sessions/t*100:0;return(0,I.jsx)(`li`,{children:(0,I.jsxs)(x,{to:`/${e.name.toLowerCase()}`,className:`block rounded-sm border border-transparent px-2 py-1.5 transition-colors hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon?(0,I.jsx)(`img`,{src:e.icon,alt:e.displayName,className:`size-4 object-contain`}):null,(0,I.jsx)(`span`,{className:`console-mono flex-1 text-xs text-[var(--console-text)]`,children:e.displayName}),(0,I.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[pa(e.sessions),` · `,n.toFixed(1),`%`]})]}),(0,I.jsx)(`div`,{className:`mt-1.5 h-1.5 overflow-hidden rounded-sm bg-[var(--console-surface-muted)]`,children:(0,I.jsx)(`div`,{className:`h-full bg-[var(--console-accent)]`,style:{width:`${n}%`}})}),(0,I.jsxs)(`div`,{className:`console-mono mt-1 flex gap-3 text-[10px] text-[var(--console-muted)]`,children:[(0,I.jsxs)(`span`,{children:[pa(e.messages),` msgs`]}),(0,I.jsxs)(`span`,{children:[ma(e.tokens),` tokens`]})]})]})},e.name)})})]})}function Da({projects:e}){return e.length===0?null:(0,I.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,I.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,I.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Projects`}),(0,I.jsx)(x,{to:`/projects`,className:`console-mono text-[11px] text-[var(--console-muted)] transition-colors hover:text-[var(--console-text)]`,children:`View all`})]}),(0,I.jsx)(`ul`,{className:`space-y-2`,children:e.slice(0,5).map(e=>{let t=e.agentStats.slice(0,3);return(0,I.jsx)(`li`,{children:(0,I.jsxs)(x,{to:ra({kind:e.identityKind,key:e.identityKey}),className:`block rounded-sm border border-transparent px-2 py-1.5 transition-colors hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`console-mono min-w-0 flex-1 truncate text-xs text-[var(--console-text)]`,children:e.displayName}),(0,I.jsxs)(`span`,{className:`console-mono shrink-0 text-[11px] text-[var(--console-muted)]`,children:[pa(e.sessionCount),` · `,ha(e.cost)]})]}),(0,I.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5`,children:[t.map(e=>{let t=N.agents[e.name];return(0,I.jsxs)(`span`,{className:`console-mono inline-flex items-center gap-1 rounded-sm border border-[var(--console-border)] bg-white px-1.5 py-0.5 text-[10px] text-[var(--console-muted)]`,children:[t?.icon?(0,I.jsx)(`img`,{src:t.icon,alt:t.name,className:`size-3 object-contain`}):null,t?.name??e.name,` · `,e.sessions]},e.name)}),(0,I.jsxs)(`span`,{className:`console-mono min-w-0 truncate text-[10px] text-[var(--console-muted)]`,children:[ma(e.tokens),` tokens`]})]})]})},`${e.identityKind}:${e.identityKey}`)})})]})}function Oa({sessions:e,onToggleBookmark:t}){return e.length===0?null:(0,I.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,I.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,I.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Bookmarked Sessions`}),(0,I.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` items`]})]}),(0,I.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>{let n=N.agents[e.agentKey],r=e.time_updated??e.time_created;return(0,I.jsx)(`li`,{children:(0,I.jsxs)(`div`,{className:`flex items-start gap-2 rounded-sm border border-transparent px-2 py-1.5 transition-colors hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,I.jsxs)(x,{to:`/${e.fullPath}`,className:`flex min-w-0 flex-1 items-start gap-2`,children:[n?.icon?(0,I.jsx)(`img`,{src:n.icon,alt:n.name,className:`mt-0.5 size-3.5 shrink-0 object-contain`}):null,(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`p`,{className:`line-clamp-1 text-sm text-[var(--console-text)]`,children:e.title}),(0,I.jsxs)(`p`,{className:`console-mono mt-0.5 line-clamp-1 text-[11px] text-[var(--console-muted)]`,children:[`/`,e.fullPath,` · `,_a(r)]})]})]}),(0,I.jsx)(ji,{active:!0,onToggle:()=>t(e)})]})},qi(e.agentKey,e.sessionId))})})]})}function ka({sessions:e,isBookmarked:t,onToggleBookmark:n}){return e.length===0?(0,I.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4 text-sm text-[var(--console-muted)]`,children:`No sessions yet`}):(0,I.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,I.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,I.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Recent Activity`}),(0,I.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` items`]})]}),(0,I.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>{let r=e.agentName.toLowerCase(),i=N.agents[r],a=e.time_updated??e.time_created,o=t(r,e.id);return(0,I.jsx)(`li`,{children:(0,I.jsxs)(`div`,{className:`flex items-start gap-2 rounded-sm border border-transparent px-2 py-1.5 transition-colors hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,I.jsxs)(x,{to:`/${e.slug}`,className:`min-w-0 flex-1`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[i?.icon?(0,I.jsx)(`img`,{src:i.icon,alt:i.name,className:`size-3.5 shrink-0 object-contain`}):null,(0,I.jsx)(`p`,{className:`line-clamp-1 flex-1 text-sm text-[var(--console-text)]`,children:e.title}),(0,I.jsx)(`span`,{className:`console-mono shrink-0 text-[11px] text-[var(--console-muted)]`,children:_a(a)})]}),(0,I.jsxs)(`p`,{className:`console-mono mt-0.5 line-clamp-1 text-[11px] text-[var(--console-muted)]`,children:[`/`,e.slug]}),(0,I.jsx)(qe,{tags:e.smart_tags,className:`mt-1.5`})]}),(0,I.jsx)(ji,{active:o,onToggle:()=>n(e,r)})]})},e.id)})})]})}function Aa({activity:e}){return e.length===0?(0,I.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4 text-sm text-[var(--console-muted)]`,children:`No file activity yet`}):(0,I.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,I.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,I.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Recently Touched Files`}),(0,I.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` files`]})]}),(0,I.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>{let t=e.latest_time;return(0,I.jsx)(`li`,{children:(0,I.jsxs)(x,{to:`/${e.session.slug}`,className:`block rounded-sm border border-transparent px-2 py-1.5 transition-colors hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.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,I.jsx)(`span`,{className:`console-mono min-w-0 flex-1 truncate text-xs text-[var(--console-text)]`,children:e.path}),(0,I.jsx)(`span`,{className:`console-mono shrink-0 text-[11px] text-[var(--console-muted)]`,children:_a(t)})]}),(0,I.jsxs)(`p`,{className:`console-mono mt-1 line-clamp-1 text-[11px] text-[var(--console-muted)]`,children:[e.session.project_identity?.displayName??e.session.directory,` ·`,` `,e.session.title,` · `,e.count,` events`]})]})},`${e.agent_name}/${e.session_id}/${e.kind}/${e.path}`)})})]})}function ja({data:e,projects:t=[],bookmarkedSessions:n,isBookmarked:r,onToggleBookmark:i}){let{totals:a,perAgent:o,dailyActivity:s,dailyTokenActivity:c,modelDistribution:l,recentSessions:u,recentFileActivities:d=[]}=e;return(0,I.jsxs)(`div`,{"data-testid":`dashboard`,className:`mx-auto max-w-5xl space-y-4`,children:[(0,I.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-5`,children:[(0,I.jsx)(va,{label:`Total Sessions`,value:pa(a.sessions)}),(0,I.jsx)(va,{label:`Total Messages`,value:pa(a.messages)}),(0,I.jsx)(va,{label:`Total Tokens`,value:ma(a.tokens)}),(0,I.jsx)(va,{label:`Total Cost`,value:ha(a.cost),hint:ga(a.cost_source)}),(0,I.jsx)(va,{label:`Latest Activity`,value:_a(a.latestActivity),hint:a.latestActivity?new Date(a.latestActivity).toLocaleString(`zh-CN`):void 0})]}),(0,I.jsx)(ba,{buckets:s}),(0,I.jsx)(Ca,{buckets:c}),(0,I.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,I.jsx)(Ta,{entries:l}),(0,I.jsx)(Ea,{perAgent:o})]}),(0,I.jsx)(Da,{projects:t}),(0,I.jsx)(ka,{sessions:u,isBookmarked:r,onToggleBookmark:i}),(0,I.jsx)(Aa,{activity:d}),(0,I.jsx)(Oa,{sessions:n,onToggleBookmark:e=>i(e)})]})}function Ma(e){return e.toLocaleString(`en-US`)}function Na(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:Ma(e)}function Pa(e){return e===0?`$0.00`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function Fa(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 Ia(e){return e.stats.total_tokens??e.stats.total_input_tokens+e.stats.total_output_tokens}function La({label:e,value:t,hint:n}){return(0,I.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,I.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-wider text-[var(--console-muted)]`,children:e}),(0,I.jsx)(`p`,{className:`console-mono mt-2 text-xl font-semibold text-[var(--console-text)]`,children:t}),n?(0,I.jsx)(`p`,{className:`mt-1 text-xs text-[var(--console-muted)]`,children:n}):null]})}function Ra({agents:e}){return e.length===0?null:(0,I.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:e.slice(0,4).map(e=>{let t=N.agents[e.name];return(0,I.jsxs)(`span`,{className:`console-mono inline-flex items-center gap-1 rounded-sm border border-[var(--console-border)] bg-white px-1.5 py-0.5 text-[10px] text-[var(--console-muted)]`,children:[t?.icon?(0,I.jsx)(`img`,{src:t.icon,alt:t.name,className:`size-3 object-contain`}):null,t?.name??e.name,` · `,e.sessions]},e.name)})})}function za({project:e}){return(0,I.jsx)(`li`,{children:(0,I.jsxs)(x,{to:ra({kind:e.identityKind,key:e.identityKey}),className:`block rounded-sm border border-[var(--console-border)] bg-white/85 p-4 transition-colors hover:border-[var(--console-border-strong)] hover:bg-white`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`h2`,{className:`console-mono line-clamp-1 text-sm font-semibold text-[var(--console-text)]`,children:e.displayName}),(0,I.jsx)(`p`,{className:`console-mono mt-1 break-all text-[11px] text-[var(--console-muted)]`,children:e.identityKey})]}),(0,I.jsxs)(`div`,{className:`console-mono flex shrink-0 flex-wrap gap-2 text-[11px] text-[var(--console-muted)]`,children:[(0,I.jsxs)(`span`,{children:[Ma(e.sessionCount),` sessions`]}),(0,I.jsxs)(`span`,{children:[Na(e.tokens),` tokens`]}),(0,I.jsx)(`span`,{children:Pa(e.cost)}),(0,I.jsx)(`span`,{children:Fa(e.lastActivity)})]})]}),(0,I.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2 md:flex-row md:items-center md:justify-between`,children:[(0,I.jsx)(Ra,{agents:e.agentStats}),(0,I.jsx)(`span`,{className:`console-mono text-[10px] uppercase text-[var(--console-muted)]`,children:e.identityKind})]})]})})}function Ba({projects:e}){let t=e.reduce((e,t)=>e+t.sessionCount,0),n=e.reduce((e,t)=>e+t.tokens,0),r=e.reduce((e,t)=>e+t.cost,0),i=Math.max(0,...e.map(e=>e.lastActivity??0));return e.length===0?(0,I.jsx)(`div`,{className:`mx-auto max-w-5xl rounded-sm border border-[var(--console-border)] bg-white p-6 text-sm text-[var(--console-muted)]`,children:`No projects found`}):(0,I.jsxs)(`div`,{className:`mx-auto max-w-5xl space-y-4`,children:[(0,I.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-4`,children:[(0,I.jsx)(La,{label:`Projects`,value:Ma(e.length)}),(0,I.jsx)(La,{label:`Sessions`,value:Ma(t)}),(0,I.jsx)(La,{label:`Tokens`,value:Na(n)}),(0,I.jsx)(La,{label:`Total Cost`,value:Pa(r),hint:i?`Latest ${Fa(i)}`:void 0})]}),(0,I.jsx)(`ul`,{className:`grid gap-3`,children:e.map(e=>(0,I.jsx)(za,{project:e},`${e.identityKind}:${e.identityKey}`))})]})}function Va({agents:e,activeAgent:t,onChange:n}){return(0,I.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-3`,children:(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`Agent`}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>n(void 0),className:`console-mono rounded-sm border px-2 py-1 text-[10px] transition-colors ${t?`border-[var(--console-border)] bg-[var(--console-surface-muted)] text-[var(--console-muted)] hover:bg-white`:`border-[var(--console-border-strong)] bg-[var(--console-accent)] text-white`}`,children:`All Agents`}),e.map(e=>{let r=N.agents[e.name],i=t===e.name;return(0,I.jsxs)(`button`,{type:`button`,onClick:()=>n(i?void 0:e.name),className:`console-mono inline-flex items-center gap-1 rounded-sm border px-2 py-1 text-[10px] transition-colors ${i?`border-[var(--console-border-strong)] bg-[var(--console-accent)] text-white`:`border-[var(--console-border)] bg-[var(--console-surface-muted)] text-[var(--console-muted)] hover:bg-white`}`,children:[r?.icon?(0,I.jsx)(`img`,{src:r.icon,alt:r.name,className:`size-3 object-contain`}):null,r?.name??e.name,` · `,e.sessions]},e.name)})]})})}function Ha({project:e}){return(0,I.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`h2`,{className:`console-mono text-base font-semibold text-[var(--console-text)]`,children:e.displayName}),(0,I.jsxs)(`p`,{className:`console-mono mt-1 break-all text-[11px] text-[var(--console-muted)]`,children:[e.identityKind,`: `,e.identityKey]})]}),(0,I.jsx)(Ra,{agents:e.agentStats})]})})}function Ua({sessions:e}){if(e.length===0)return null;let t=e.toSorted((e,t)=>t.stats.total_cost-e.stats.total_cost).slice(0,5);return(0,I.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,I.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,I.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Top Cost`}),(0,I.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[t.length,` sessions`]})]}),(0,I.jsx)(`ul`,{className:`space-y-2`,children:t.map(e=>{let t=N.agents[e.agentKey];return(0,I.jsx)(`li`,{children:(0,I.jsxs)(x,{to:`/${e.fullPath}`,className:`block rounded-sm border border-transparent px-2 py-1.5 transition-colors hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t?.icon?(0,I.jsx)(`img`,{src:t.icon,alt:t.name,className:`size-3.5 object-contain`}):null,(0,I.jsx)(`span`,{className:`line-clamp-1 flex-1 text-sm text-[var(--console-text)]`,children:e.title}),(0,I.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:Pa(e.stats.total_cost)})]}),(0,I.jsxs)(`p`,{className:`console-mono mt-1 text-[11px] text-[var(--console-muted)]`,children:[`/`,e.fullPath,` · `,Na(Ia(e)),` tokens`]})]})},e.fullPath)})})]})}function Wa({project:e,projectKey:t,dashboard:n,loading:r,error:i,sessions:a,activeAgent:o,onChangeAgent:s,isBookmarked:c,onToggleSessionBookmark:l}){if(!e)return(0,I.jsxs)(`div`,{className:`mx-auto max-w-4xl rounded-sm border border-[var(--console-border)] bg-white p-6`,children:[(0,I.jsx)(`h2`,{className:`console-mono text-sm font-semibold text-[var(--console-text)]`,children:`Project Not Found`}),(0,I.jsx)(`p`,{className:`console-mono mt-2 break-all text-xs text-[var(--console-muted)]`,children:t}),(0,I.jsx)(x,{to:`/projects`,className:`console-mono mt-4 inline-flex rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-xs text-[var(--console-text)] transition-colors hover:bg-white`,children:`Back to Projects`})]});let u=o?a.filter(e=>e.agentKey===o):a;return(0,I.jsxs)(`div`,{className:`mx-auto max-w-5xl space-y-4`,children:[(0,I.jsx)(Ha,{project:e}),(0,I.jsx)(Va,{agents:e.agentStats,activeAgent:o,onChange:s}),r?(0,I.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-6 text-sm text-[var(--console-muted)]`,children:`Loading project dashboard`}):i?(0,I.jsx)(`div`,{className:`rounded-sm border border-[var(--console-error-border)] bg-[var(--console-error-bg)] p-6 text-sm text-[var(--console-error)]`,children:i}):n?(0,I.jsx)(ja,{data:n,projects:[],bookmarkedSessions:[],isBookmarked:c,onToggleBookmark:(e,t)=>{`agentName`in e&&l(e,t??e.agentName.toLowerCase())}}):null,(0,I.jsx)(Ua,{sessions:u})]})}var Ga=class extends M.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,I.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-error-border)] bg-[var(--console-error-bg)] p-6`,children:[(0,I.jsx)(`h3`,{className:`console-mono mb-2 text-sm font-semibold text-[var(--console-error)]`,children:`Something went wrong`}),(0,I.jsx)(`p`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:this.state.error?.message||`Unknown error`})]}):this.props.children}};function Ka(e){return`'${e.replace(/'/g,`'\\''`)}'`}var qa={claudecode:`claude --resume`,codex:`codex resume`,kimi:`kimi -r`,opencode:`opencode -s`};function Ja(e){let t=e.toLowerCase();return t in qa?qa[t]:null}function Ya({agentName:e,sessionId:t,directory:n}){let r=Ja(e);if(!r)return null;let i=`${r} ${Ka(t)}`,a=n??``;return a.trim()?`cd ${Ka(a)} && ${i}`:i}async function Xa(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 Za({agentName:e,sessionId:t,directory:n,className:r=``}){let[i,a]=(0,M.useState)(!1),o=Ya({agentName:e,sessionId:t,directory:n});return(0,M.useEffect)(()=>{if(!i)return;let e=window.setTimeout(()=>a(!1),1500);return()=>window.clearTimeout(e)},[i]),o?(0,I.jsxs)(`button`,{type:`button`,onClick:e=>{e.preventDefault(),e.stopPropagation(),Xa(o).then(e=>{e&&a(!0)})},"aria-label":i?`Resume command copied: ${o}`:`Copy resume command: ${o}`,title:i?`Copied: ${o}`:`Copy: ${o}`,className:`console-mono inline-flex items-center gap-1.5 rounded-sm border px-2 py-1 text-[11px] transition-colors ${r} ${i?`border-[var(--console-border-strong)] bg-[var(--console-surface-muted)] text-[var(--console-text)]`:`border-[var(--console-border)] bg-[var(--console-surface-muted)] text-[var(--console-muted)] hover:border-[var(--console-border-strong)] hover:text-[var(--console-text)]`}`,children:[i?(0,I.jsx)(h,{className:`size-3`,strokeWidth:1.8}):(0,I.jsx)(pe,{className:`size-3`,strokeWidth:1.8}),(0,I.jsx)(`span`,{children:i?`Copied`:`Copy resume`})]}):null}var Qa=`
41
+ [data-type='item'][data-item-type='file'] > [data-item-section='icon'] {
42
+ display: none;
43
+ }
44
+
45
+ [data-type='item'][data-item-type='file'] > [data-item-section='spacing'] {
46
+ padding-left: 2px;
47
+ }
48
+
49
+ [data-type='item'][data-item-type='file'] > [data-item-section='spacing'] > [data-item-section='spacing-item'] {
50
+ margin-right: 4px;
51
+ }
52
+
53
+ [data-type='item'][data-item-type='file'] > [data-item-section='content'] {
54
+ flex: 1 1 auto;
55
+ }
56
+
57
+ [data-type='item'][data-item-type='file'] > [data-item-section='decoration'] {
58
+ flex: 0 0 auto;
59
+ padding-inline: 8px 6px;
60
+ }
61
+
62
+ [data-type='item'][data-item-type='file'] > [data-item-section='decoration'] > span {
63
+ cursor: pointer;
64
+ font-size: 18px;
65
+ line-height: 1;
66
+ }
67
+
68
+ [data-type='item'][data-item-type='file'] [data-truncate-group-container='middle'] {
69
+ width: 100%;
70
+ }
71
+
72
+ [data-type='item'][data-item-type='file']
73
+ [data-truncate-group-container='middle']
74
+ > div[data-truncate-segment-priority='2'] {
75
+ flex: 0 1 auto;
76
+ }
77
+
78
+ [data-type='item'][data-item-type='file']
79
+ [data-truncate-group-container='middle']
80
+ > div[data-truncate-segment-priority='1'] {
81
+ flex: 1 999999 auto;
82
+ }
83
+
84
+ [data-type='item'][data-item-type='file']
85
+ [data-truncate-group-container='middle']
86
+ [data-truncate-container='fruncate']
87
+ [data-truncate-grid] {
88
+ grid-template-columns: minmax(0, max-content) 0;
89
+ }
90
+
91
+ [data-type='item'][data-item-type='file']
92
+ [data-truncate-group-container='middle']
93
+ [data-truncate-container='fruncate']
94
+ [data-truncate-content] {
95
+ direction: ltr;
96
+ }
97
+
98
+ [data-type='item'][data-item-type='file']
99
+ [data-truncate-group-container='middle']
100
+ [data-truncate-container='fruncate']
101
+ [data-truncate-marker] {
102
+ right: 0;
103
+ }
104
+
105
+ [data-type='item'][data-item-type='file'] [data-truncate-marker] {
106
+ display: none;
107
+ }
108
+ `;function $a(e){return e.replaceAll(`/`,`∕`).trim()||`(untitled)`}function eo(e){return e.replace(/\/+$/,``).split(`/`).at(-1)?.trim()||`(unknown)`}function to(e){let t=e.project_identity;if(t)return{key:`${t.kind}:${t.key}`,label:t.displayName||eo(e.directory)};let n=eo(e.directory);return{key:n===`(unknown)`?`__unknown__`:`path:${e.directory||n}`,label:n}}function no(e){return e.time_updated??e.time_created}function ro(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 io(e){let t=new Map,n=new Map,r=new Map,i=new Map,a=new Map,o=new Map,s=new Set,c=[],l=new Map;for(let t of e){let{key:e,label:n}=to(t),r=l.get(e);r?r.sessions.push(t):l.set(e,{label:n,sessions:[t]})}let u=[...l.entries()].sort(([,e],[,t])=>{if(e.label===`(unknown)`)return 1;if(t.label===`(unknown)`)return-1;let n=Math.max(...e.sessions.map(no));return Math.max(...t.sessions.map(no))-n}),d=0,f=new Set;for(let[,e]of u){let l=$a(e.label),u=`${l}/`,p=2;for(;f.has(u);)u=`${l} (${p})/`,p+=1;f.add(u);let m=u.slice(0,-1),h=new Map;t.set(u,d),t.set(m,d),d+=1,a.set(u,`${e.sessions.length}`),a.set(m,`${e.sessions.length}`);for(let t of e.sessions)h.set(t.title,(h.get(t.title)??0)+1);for(let a of e.sessions){let e=(h.get(a.title)??0)>1?`${$a(a.title)} #${a.id.slice(0,8)}`:$a(a.title),l=`${u}${e}`,f=2;for(;s.has(l);)l=`${u}${e} (${f})`,f+=1;s.add(l),c.push(l),t.set(l,d),d+=1,n.set(a.id,l),r.set(a.id,u),i.set(l,a.id),o.set(l,a)}}return{paths:c,sortOrderByPath:t,pathBySessionId:n,groupPathBySessionId:r,sessionIdByPath:i,groupCountByPath:a,sessionByPath:o}}function ao(e,t){if(!K())return t();let n=performance.now(),r=t(),i=performance.now();return wt({id:e,source:`custom-timing`,phase:`measure`,actualDuration:Math.round((i-n)*100)/100,baseDuration:0,startTime:n,commitTime:i}),r}var oo=(0,M.memo)(function({sessions:e,activeSessionId:t,selectedSessionId:n,onSelectSession:r,bookmarkedSessionIds:a,onToggleBookmark:s}){let c=(0,M.useMemo)(()=>ao(`SessionTreeSidebar:buildTreeModel`,()=>io(e)),[e]),l=(0,M.useRef)(c.sortOrderByPath),u=(0,M.useRef)(c.sessionIdByPath),d=(0,M.useRef)(c.groupCountByPath),f=(0,M.useRef)(c.sessionByPath),p=(0,M.useRef)(a),m=(0,M.useRef)(r),h=(0,M.useRef)(s),g={"--trees-bg-override":`transparent`,"--trees-border-color-override":`var(--console-border)`,"--trees-fg-override":`var(--console-text)`,"--trees-fg-muted-override":`var(--console-muted)`,"--trees-font-family-override":`"JetBrains Mono", "IBM Plex Mono", "SFMono-Regular", Menlo, Monaco, Consolas, monospace`,"--trees-font-size-override":`12px`,"--trees-item-margin-x-override":`0px`,"--trees-item-padding-x-override":`8px`,"--trees-selected-bg-override":`var(--console-surface-muted)`},{model:_}=o({flattenEmptyDirectories:!1,initialExpansion:`closed`,paths:c.paths,sort:(e,t)=>ro(l.current,e,t),density:`compact`,unsafeCSS:Qa,onSelectionChange(e){let t=u.current.get(e[0]??``);t&&m.current(t)},renderRowDecoration({item:e}){let t=f.current.get(e.path);if(t){let e=p.current.has(t.id);return{text:e?`★`:`☆`,title:e?`Remove bookmark`:`Add bookmark`}}return d.current.get(e.path)?{text:d.current.get(e.path),title:`Sessions`}:null}});(0,M.useEffect)(()=>{l.current=c.sortOrderByPath,u.current=c.sessionIdByPath,d.current=c.groupCountByPath,f.current=c.sessionByPath,_.resetPaths(c.paths)},[_,c]),(0,M.useEffect)(()=>{m.current=r},[r]),(0,M.useEffect)(()=>{p.current=a,_.resetPaths(c.paths)},[a,_,c.paths]),(0,M.useEffect)(()=>{h.current=s},[s]);function v(e){let t=e.nativeEvent.composedPath(),n=t.find(e=>e instanceof HTMLElement&&e.parentElement?.getAttribute(`data-item-section`)===`decoration`),r=t.find(e=>e instanceof HTMLElement&&e.getAttribute(`data-type`)===`item`),i=r?f.current.get(r.getAttribute(`data-item-path`)??``):null;!n||!i||(e.preventDefault(),e.stopPropagation(),h.current(i))}return(0,M.useEffect)(()=>{let e=c.pathBySessionId.get(t??``),r=c.pathBySessionId.get(n??``)??e,i=n??t??``,a=c.groupPathBySessionId.get(i);if(e&&_.getItem(e)?.select(),r&&t){let e=a?_.getItem(a):null;e&&`expand`in e&&e.expand(),_.focusPath(r);return}a&&_.focusPath(a)},[t,_,c,n]),(0,I.jsx)(`div`,{className:`session-tree h-[min(560px,calc(100vh-410px))] min-h-56 overflow-hidden`,style:g,onClickCapture:v,children:(0,I.jsx)(i,{model:_,style:{height:`100%`},"aria-label":`Sessions`})})});function so(e,t){return(t.time_updated??t.time_created)-(e.time_updated??e.time_created)}function co(e){return e.slug.split(`/`)[0]?.toLowerCase()||`unknown`}function lo(e,t){return`${e.toLowerCase()}/${t}`}function uo(e,t){return`${e}\0${t.toLowerCase()}`}function fo(e,t,n){let r=e.get(t);if(r){r.push(n);return}e.set(t,[n])}function po(e,t){let n=new Map,r=new Map,i=new Map,a=new Map,o=new Map,s=new Map,c=new Map,l=new Map,u=[],d=new Set(t.map(e=>e.name.toLowerCase()));for(let e of d)r.set(e,[]),s.set(e,[]);for(let t of e){let e=co(t),r={...t,agentKey:e,sessionSlug:t.id,fullPath:t.slug};u.push(r);let i=lo(e,t.id);n.has(i)||n.set(i,t),d.has(e)&&s.get(e).push(r);let a=t.project_identity;if(!a?.key)continue;fo(c,ta(a),r);let o=l.get(a.key);o?o.count+=1:l.set(a.key,{key:a.key,label:a.displayName||t.directory,count:1})}let f=e.toSorted(so);for(let e of f){let t=co(e);d.has(t)&&r.get(t).push(e);let n=e.project_identity;if(!n?.key)continue;let s=ta(n);fo(i,s,e),fo(a,uo(s,t),e),fo(o,n.key,e)}return{byRouteKey:n,byAgent:r,byProjectIdentityKey:i,byProjectAgentKey:a,byProjectKey:o,byLandingAgent:s,byLandingProjectIdentityKey:c,landingSessions:u,sessionsByActivity:f,projectOptions:[...l.values()].toSorted((e,t)=>t.count-e.count).slice(0,8)}}function mo(e){let t=new Map,n=new Map;for(let r=0;r<e.length;r+=1){let i=e[r];t.has(i.id)||(t.set(i.id,i),n.set(i.id,r))}return{byId:t,indexById:n}}function ho(e,t){let n=e.replace(/^\/+|\/+$/g,``),r=n?n.split(`/`).map(e=>e.trim()).filter(Boolean):[];if(r.length===0)return{mode:`root`,activeAgentKey:null,activeSessionSlug:null};if(r[0]?.toLowerCase()===`projects`){if(r.length===1)return{mode:`projects`,activeAgentKey:null,activeSessionSlug:null};if(r.length===3)try{let e=decodeURIComponent(r[1]);return ea(e)?{mode:`project`,activeAgentKey:null,activeSessionSlug:null,activeProjectKind:e,activeProjectKey:na(r[2])}:{mode:`invalidRoute`,activeAgentKey:null,activeSessionSlug:null}}catch{return{mode:`invalidRoute`,activeAgentKey:null,activeSessionSlug:null}}return{mode:`invalidRoute`,activeAgentKey:null,activeSessionSlug:null}}if(r.length===1){let e=r[0].toLowerCase();return t.has(e)?{mode:`agent`,activeAgentKey:e,activeSessionSlug:null}:{mode:`missingAgent`,activeAgentKey:null,activeSessionSlug:null,attemptedKey:e}}if(r.length===2){let e=r[0].toLowerCase(),n=r[1];return t.has(e)&&n?{mode:`session`,activeAgentKey:e,activeSessionSlug:n}:t.has(e)?{mode:`missingSession`,activeAgentKey:e,activeSessionSlug:n,attemptedSessionSlug:n}:{mode:`missingAgent`,activeAgentKey:null,activeSessionSlug:null,attemptedKey:e}}return{mode:`invalidRoute`,activeAgentKey:null,activeSessionSlug:null}}function go(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function _o(e){if(!e)return null;let{from:t,to:n,days:r}=e.window;if(t==null)return`All time`;let i=go(t),a=go(n??Date.now());return r?`Last ${r}d · ${i} → ${a}`:`${i} → ${a}`}function vo(e,t,n){return t?e?`Searching for "${e}"`:`Loading recent sessions`:e?`${n} matches for "${e}"`:`${n} recent sessions`}function yo(e){if(!e?.active)return null;let t=e.completedAgents.length,n=e.totalAgents,r=e.scanningAgents[0],i=r?e.agentStatuses[r]:null,a=i?.total&&i.processed!=null?` · ${i.processed}/${i.total}`:``,o=n>0?r?` · ${r}${a} · ${t}/${n} agents ready`:` · ${t}/${n} agents ready`:``;return e.phase===`initializing`?`First-run setup: indexing all local sessions${o}. Your selected time window appears after this finishes.`:e.phase===`indexing`?`Preparing local session index`:n>0?r?`Checking for new or changed sessions · ${r}${a} · ${t}/${n} agents ready`:`Checking for new or changed sessions · ${t}/${n} agents ready`:`Checking for new or changed sessions`}function bo(e,t){let n=e?.agentStatuses[t];return!n||n.status===`complete`?null:n.total&&n.processed!=null?`${n.processed}/${n.total}`:n.status===`scanning`?`Scanning`:`Pending`}function xo(e,t,n){let r=e?.agentStatuses[t];return r?.status===`complete`&&r.sessions!=null?r.sessions:n}function So(e){return{kind:e.identityKind,key:e.identityKey}}function Co(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 wo(e,t){return(t.time_updated??t.time_created)-(e.time_updated??e.time_created)}function To(e,t){if(!t.changedSessionHeads||!t.removedSessionRefs)return null;let n=new Map(e.map(e=>[lo(co(e),e.id),e]));for(let{agentName:e,sessionId:r}of t.removedSessionRefs)n.delete(lo(e,r));for(let{agentName:e,session:r}of t.changedSessionHeads)n.set(lo(e,r.id),r);return[...n.values()].sort(wo)}function Eo(e){return e.replaceAll(`&`,`&amp;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`).replaceAll(`"`,`&quot;`).replaceAll(`'`,`&#39;`).replaceAll(`&lt;mark&gt;`,`<mark>`).replaceAll(`&lt;/mark&gt;`,`</mark>`)}var Do=`codesesh.shortcuts-hint-dismissed`,Oo=[`bugfix`,`refactoring`,`feature-dev`,`testing`,`docs`,`git-ops`,`build-deploy`,`exploration`,`planning`],ko=[`apply_patch`,`bash`,`read`,`edit`,`grep`],Ao=[{kind:`read`,label:`Read`},{kind:`edit`,label:`Edit`},{kind:`write`,label:`Write`},{kind:`delete`,label:`Delete`}],jo=[{id:`paid`,label:`Cost > $0`,costMin:1e-6},{id:`one_plus`,label:`Cost >= $1`,costMin:1},{id:`ten_plus`,label:`Cost >= $10`,costMin:10}],Mo={recent:`Recent`,title:`Title`,user_message:`User message`,assistant_reply:`Assistant reply`,tool_output:`Tool output`,file_path:`File path`},No=[{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`,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`}]},{title:`Groups`,items:[{keys:`g / G`,description:`Jump to the first or last session`},{keys:`?`,description:`Open this shortcuts panel`}]}];function Po(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase();return t===`input`||t===`textarea`||t===`select`||e.isContentEditable}function Fo({value:e,onChange:t,projectsDisabled:n=!1}){return(0,I.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,I.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":i,disabled:a,onClick:()=>t(r.value),className:`console-mono flex items-center gap-2 rounded-sm border px-3 py-1.5 text-left text-xs transition-colors ${a?`cursor-not-allowed border-transparent text-[var(--console-muted)] opacity-45`:i?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,title:a?`Project grouping is available after the current scan finishes`:void 0,children:[(0,I.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,I.jsx)(`span`,{className:`size-1.5 rounded-full bg-[var(--console-accent)]`}):null}),(0,I.jsx)(`span`,{children:r.label})]},r.value)})})}function Io({sessions:e,activeSessionId:t,selectedSessionId:n,bookmarkedSessionIds:r,onSelectSession:i,onToggleBookmark:a}){return(0,I.jsx)(`div`,{className:`console-scrollbar h-[min(560px,calc(100vh-410px))] min-h-56 overflow-y-auto`,children:(0,I.jsx)(`ul`,{className:`space-y-1`,children:e.map(e=>{let o=co(e),s=N.agents[o],c=t===e.id,l=n===e.id;return(0,I.jsx)(`li`,{children:(0,I.jsxs)(`div`,{className:`flex items-start gap-1 rounded-sm border px-2 py-1.5 transition-colors ${c||l?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,children:[(0,I.jsxs)(`button`,{type:`button`,onClick:()=>i(e),className:`min-w-0 flex-1 text-left`,children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[s?.icon?(0,I.jsx)(`img`,{src:s.icon,alt:s.name,className:`size-3.5 shrink-0 object-contain`}):null,(0,I.jsx)(`span`,{className:`console-mono line-clamp-1 text-xs text-[var(--console-text)]`,children:e.title})]}),(0,I.jsx)(`span`,{className:`console-mono mt-0.5 block truncate text-[10px] text-[var(--console-muted)]`,children:Co(e.time_updated??e.time_created)})]}),(0,I.jsx)(ji,{active:r.has(e.id),onToggle:()=>a(e)})]})},e.slug)})})})}function Lo(){let e=f(),[t,n]=(0,M.useState)([]),[r,i]=(0,M.useState)([]),[a,o]=(0,M.useState)([]),[s,c]=(0,M.useState)(!0),[l,u]=(0,M.useState)(null),[p,m]=(0,M.useState)(null),[h,g]=(0,M.useState)(!1),[_,v]=(0,M.useState)(null),[ee,y]=(0,M.useState)(null),[te,ne]=(0,M.useState)(null),[b,re]=(0,M.useState)([]),[S,ie]=(0,M.useState)(`agents`),[ae,oe]=(0,M.useState)(null),[se,ce]=(0,M.useState)(null),[le,ue]=(0,M.useState)(!1),[de,C]=(0,M.useState)(null),[w,fe]=(0,M.useState)(void 0),[T,pe]=(0,M.useState)(null),[E,me]=(0,M.useState)(``),[D,he]=(0,M.useState)(``),[ge,_e]=(0,M.useState)(!1),[O,ve]=(0,M.useState)({}),[k,ye]=(0,M.useState)([]),[be,xe]=(0,M.useState)(!1),[A,Se]=(0,M.useState)(null),[Ce,j]=(0,M.useState)(null),[we,Te]=(0,M.useState)(0),[Ee,De]=(0,M.useState)(!1),[Oe,ke]=(0,M.useState)(!0),Ae=(0,M.useRef)(null),je=(0,M.useRef)(new Map);(0,M.useEffect)(()=>{let e=new AbortController,t=performance.now();return P(`app.load.start`,{path:window.location.pathname}),(async()=>{try{let e=await Me();pe(e);let[r,a,s,c,l,u]=await Promise.all([Pe(),Ie({from:e.window.from,to:e.window.to}),Re(e.window).catch(e=>(console.error(`Failed to load dashboard:`,e),null)),Fe().catch(e=>(console.error(`Failed to load projects:`,e),{projects:[]})),Be(),Ne().catch(e=>(console.error(`Failed to load scan status:`,e),null))]);n(r),i(a.sessions),re(c.projects),o(l.bookmarks),u&&Se(u),s&&ne(s),P(`app.load.done`,{duration_ms:Math.round(performance.now()-t),agents:r.length,sessions:a.sessions.length,projects:c.projects.length,dashboard:!!s})}catch(e){console.error(`Failed to load data:`,e),P(`app.load.error`,{duration_ms:Math.round(performance.now()-t),error:e instanceof Error?e.message:String(e)}),u(`Failed to load data. Is the CLI server running?`)}finally{c(!1)}})(),()=>e.abort()},[]);let F=d(),Ge=(0,M.useMemo)(()=>new Set(t.map(e=>e.name.toLowerCase())),[t]),Ke=(0,M.useMemo)(()=>new Map(t.map(e=>[e.name.toLowerCase(),e.displayName])),[t]),L=ge,R=(0,M.useMemo)(()=>ho(F.pathname,Ge),[F.pathname,Ge]);(0,M.useEffect)(()=>{P(`route.change`,{path:F.pathname,mode:R.mode,agent:R.activeAgentKey,session:R.activeSessionSlug})},[F.pathname,R.mode,R.activeAgentKey,R.activeSessionSlug]),(0,M.useEffect)(()=>{if(R.mode===`projects`||R.mode===`project`){ie(`projects`),R.mode===`project`&&oe({kind:R.activeProjectKind,key:R.activeProjectKey});return}(R.mode===`agent`||R.mode===`missingAgent`)&&ie(`agents`)},[R]);let Je=L?D:typeof F.state==`object`&&F.state!==null&&`searchQuery`in F.state&&typeof F.state.searchQuery==`string`?F.state.searchQuery:``,z=(0,M.useMemo)(()=>po(r,t),[r,t]);(0,M.useEffect)(()=>{let e=!1;return o(t=>{let n=Qi(t,r);return n===t?t:(He(n.map(({bookmarked_at:e,...t})=>t)).catch(t=>{e||console.error(`Failed to sync bookmark snapshots:`,t)}),n)}),()=>{e=!0}},[r]),(0,M.useEffect)(()=>{let e=!1;return(async()=>{let t=Yi();if(t.length!==0)try{let n=await He(t.map(({bookmarked_at:e,...t})=>t));if(e)return;o(n.bookmarks),Xi()}catch(t){e||console.error(`Failed to migrate legacy bookmarks:`,t)}})(),()=>{e=!0}},[]);let B=(0,M.useMemo)(()=>new Set(a.map(e=>qi(e.agentKey,e.sessionId))),[a]),Ye=(0,M.useCallback)((e,t)=>B.has(qi(e,t)),[B]),V=(0,M.useCallback)(e=>{let t=qi(e.agentKey,e.sessionId),n=B.has(t),r=a;o(n?r.filter(e=>qi(e.agentKey,e.sessionId)!==t):[...r,e].toSorted((e,t)=>{let n=e.time_updated??e.time_created;return(t.time_updated??t.time_created)-n})),P(n?`bookmark.delete`:`bookmark.add`,{agent:e.agentKey,session:e.sessionId}),(n?Ue(e.agentKey,e.sessionId):Ve({agentKey:e.agentKey,sessionId:e.sessionId,fullPath:e.fullPath,title:e.title,directory:e.directory,time_created:e.time_created,time_updated:e.time_updated,stats:e.stats})).catch(e=>{console.error(`Failed to toggle bookmark:`,e),o(r)})},[B,a]),H=(0,M.useCallback)((e,t)=>{V(Ji(e,t))},[V]),U=R.activeAgentKey,Xe=R.mode===`project`?R.activeProjectKind:null,Ze=R.mode===`project`?R.activeProjectKey:null,Qe=(0,M.useMemo)(()=>Xe&&Ze?{kind:Xe,key:Ze}:null,[Xe,Ze]),$e=Qe?ta(Qe):null,et=(0,M.useMemo)(()=>R.mode===`session`?z.byRouteKey.get(lo(R.activeAgentKey,R.activeSessionSlug))??null:null,[z,R]),tt=(R.mode===`session`&&p?.id===R.activeSessionSlug?p:null)?.project_identity??et?.project_identity??null,nt=S===`projects`?Qe??(R.mode===`session`?tt:ae):null,rt=nt?ta(nt):null,it=(0,M.useMemo)(()=>U?z.byAgent.get(U)??[]:[],[U,z]),at=(0,M.useMemo)(()=>rt?w?z.byProjectAgentKey.get(uo(rt,w))??[]:z.byProjectIdentityKey.get(rt)??[]:[],[w,rt,z]),W=S===`projects`?at:it,ot=(0,M.useMemo)(()=>mo(W),[W]),G=(0,M.useMemo)(()=>W.length===0?new Set:new Set(W.filter(e=>B.has(qi(co(e),e.id))).map(e=>e.id)),[B,W]),st=(0,M.useMemo)(()=>a.toSorted((e,t)=>(t.time_updated??t.time_created)-(e.time_updated??e.time_created)),[a]),ct=(0,M.useCallback)(t=>{j(t.id),e(`/${t.slug}`)},[e]),lt=(0,M.useCallback)(e=>{H(e,co(e))},[H]),ut=(0,M.useCallback)(t=>{j(t);let n=ot.byId.get(t);n&&e(`/${n.slug}`)},[e,ot]),dt=(0,M.useMemo)(()=>{let e=jo.find(e=>e.id===O.costRange);return{agent:O.agent,projectKey:O.projectKey,tag:O.tag,tool:O.tool,fileKind:O.fileKind,costMin:e?.costMin}},[O]),ft=D.trim().length>0||!!(O.tool||O.fileKind),pt=yo(A),mt=A?.active===!0,ht=(0,M.useMemo)(()=>{let e=jo.find(e=>e.id===O.costRange),t=O.agent?z.byAgent.get(O.agent)??[]:null,n=O.projectKey?z.byProjectKey.get(O.projectKey)??[]:null,r=t&&n?t.length<=n.length?t:n:t??n??z.sessionsByActivity,i=[];for(let t of r)if(!(O.agent&&co(t)!==O.agent)&&!(O.projectKey&&t.project_identity?.key!==O.projectKey)&&!(O.tag&&!t.smart_tags?.includes(O.tag))&&!(e&&t.stats.total_cost<e.costMin)&&(i.push({agentName:co(t),session:t,snippet:`Recent session · ${t.directory}`,matchType:`recent`}),i.length>=50))break;return i},[O,z]),gt=R.mode===`session`?`${R.activeAgentKey}/${R.activeSessionSlug}`:``,_t=(0,M.useEffectEvent)(async e=>{try{let t=!!(e.changedSessionHeads&&e.removedSessionRefs);t&&i(t=>To(t,e)??t);let[r,a,o,s,c,l]=await Promise.all([Pe(),t?Promise.resolve(null):Ie({from:T?.window.from,to:T?.window.to}),Re(T?.window).catch(e=>(console.error(`Failed to refresh dashboard:`,e),null)),Fe().catch(e=>(console.error(`Failed to refresh projects:`,e),{projects:[]})),R.mode===`project`?Re(T?.window,{projectKind:R.activeProjectKind,projectKey:R.activeProjectKey,agent:w}).catch(e=>(console.error(`Failed to refresh project dashboard:`,e),null)):Promise.resolve(null),L&&ft?ze(D,dt).catch(e=>(console.error(`Failed to refresh search results:`,e),{results:[]})):Promise.resolve(null)]);if(n(r),a&&i(a.sessions),re(s.projects),o&&ne(o),c&&ce(c),l&&ye(l.results),R.mode===`session`)try{m(await Le(R.activeAgentKey,R.activeSessionSlug)),v(null)}catch{m(null),v(`Session not found`)}e.newSessions>0&&y(`发现 ${e.newSessions} 个新会话,列表已自动刷新`)}catch(e){console.error(`Failed to sync live session update:`,e)}});(0,M.useEffect)(()=>{if(!L){ye([]),xe(!1);return}if(!ft){ye(ht),xe(!1);return}let e=!1;xe(!0);let t=performance.now();return P(`search.start`,{query_length:D.length}),ze(D,dt).then(n=>{e||(ye(n.results),P(`search.done`,{duration_ms:Math.round(performance.now()-t),results:n.results.length}))}).catch(n=>{e||(console.error(`Failed to load search results:`,n),P(`search.error`,{duration_ms:Math.round(performance.now()-t),error:n instanceof Error?n.message:String(n)}),ye([]))}).finally(()=>{e||xe(!1)}),()=>{e=!0}},[D,L,ht,dt,ft]),(0,M.useEffect)(()=>{if(R.mode!==`session`){m(null),v(null);return}let e=new AbortController;g(!0),v(null);let t=performance.now();return P(`session.open.start`,{agent:R.activeAgentKey,session:R.activeSessionSlug}),(async()=>{try{let e=await Le(R.activeAgentKey,R.activeSessionSlug);m(e),P(`session.open.done`,{agent:R.activeAgentKey,session:R.activeSessionSlug,duration_ms:Math.round(performance.now()-t),messages:e.messages.length})}catch(e){P(`session.open.error`,{agent:R.activeAgentKey,session:R.activeSessionSlug,duration_ms:Math.round(performance.now()-t),error:e instanceof Error?e.message:String(e)}),v(`Session not found`),m(null)}finally{g(!1)}})(),()=>e.abort()},[gt,R.activeAgentKey,R.activeSessionSlug,R.mode]),(0,M.useEffect)(()=>{$e&&fe(void 0)},[$e]),(0,M.useEffect)(()=>{if(!Ze||!T){ce(null),C(null),ue(!1);return}let e=!1;return ue(!0),C(null),Re(T.window,{projectKind:Xe??void 0,projectKey:Ze,agent:w}).then(t=>{e||ce(t)}).catch(t=>{e||(console.error(`Failed to load project dashboard:`,t),ce(null),C(`Failed to load project dashboard`))}).finally(()=>{e||ue(!1)}),()=>{e=!0}},[Xe,Ze,T,w]),(0,M.useEffect)(()=>We(e=>{_t(e)},e=>{Se(e)}),[]),(0,M.useEffect)(()=>{if(!ee)return;let e=window.setTimeout(()=>{y(null)},3500);return()=>{window.clearTimeout(e)}},[ee]),(0,M.useEffect)(()=>{try{ke(window.localStorage.getItem(Do)===`1`)}catch{ke(!0)}},[]),(0,M.useEffect)(()=>{if(L){Te(e=>k.length===0?0:Math.min(e,k.length-1));return}if(R.mode===`session`){j(R.activeSessionSlug);return}if(R.mode===`agent`){j(null);return}j(null)},[L,k.length,R.mode,R.activeSessionSlug,W]),(0,M.useEffect)(()=>{if(!L)return;let e=k[we];if(!e)return;let t=`${e.agentName}/${e.session.id}`;je.current.get(t)?.scrollIntoView({block:`nearest`})},[L,k,we]);let vt=z.landingSessions,yt=(0,M.useMemo)(()=>$e?z.byLandingProjectIdentityKey.get($e)??[]:[],[$e,z]),bt=(0,M.useMemo)(()=>t.filter(e=>e.count>0).map(e=>({key:e.name.toLowerCase(),name:e.displayName,icon:e.icon,count:e.count})),[t]),xt=(0,M.useMemo)(()=>t.find(e=>e.name.toLowerCase()===U)??null,[U,t]),K=(0,M.useMemo)(()=>b.find(e=>$e===ta(So(e)))??null,[$e,b]),St=(0,M.useMemo)(()=>b.find(e=>rt===ta(So(e)))??null,[b,rt]),Ct=z.projectOptions,wt=(0,M.useMemo)(()=>{if(!ft)return Ct;let e=new Map,t=be?[]:k;for(let n of t){let t=n.session.project_identity;if(!t?.key)continue;let r=e.get(t.key);r?r.count+=1:e.set(t.key,{key:t.key,label:t.displayName||n.session.directory,count:1,showCount:!1})}if(O.projectKey&&!e.has(O.projectKey)){let t=Ct.find(e=>e.key===O.projectKey);t&&e.set(t.key,{...t,count:0,showCount:!1})}return[...e.values()].toSorted((e,t)=>t.count-e.count).slice(0,8)},[Ct,O.projectKey,be,k,ft]),q=`CodeSesh`,J=`Select an agent to browse sessions`;if(R.mode===`root`&&(q=L?`Search`:`Dashboard`,J=L?vo(D,be,k.length):te?`${te.totals.sessions.toLocaleString(`en-US`)} total sessions across ${te.perAgent.length} agents`:`Aggregated view across all agents`),R.mode===`projects`&&(q=`Projects`,J=`${b.length.toLocaleString(`en-US`)} projects across ${r.length.toLocaleString(`en-US`)} sessions`),R.mode===`project`&&(q=K?.displayName??`Project`,J=K?`${K.sessionCount.toLocaleString(`en-US`)} sessions · ${K.agentStats.length} agents`:R.activeProjectKey),R.mode===`agent`&&U&&(q=xt?.displayName??U,J=`${W.length} sessions`),R.mode===`session`){if(_)q=`Session Not Found`,J=`Requested /${U}/${R.activeSessionSlug}`;else if(p){q=p.title||`Conversation`;let e=p.time_updated??p.time_created;J=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`span`,{children:[`ID: #`,p.id.slice(0,8)]}),(0,I.jsx)(`span`,{children:`·`}),(0,I.jsxs)(`span`,{children:[`Updated `,Co(e)]}),(0,I.jsx)(qe,{tags:p.smart_tags,limit:9,className:`inline-flex`})]})}}R.mode===`missingAgent`&&(q=`Agent Not Found`,J=`Requested /${R.attemptedKey}`),R.mode===`missingSession`&&(q=`Session Not Found`,J=`Session not found in /${U}`),L&&(q=`Search`,J=vo(D,be,k.length));let Et=(0,M.useMemo)(()=>{if(L)return[{label:`Search`}];let e={label:`Dashboard`,to:S===`agents`&&R.mode===`root`||S===`projects`&&R.mode===`projects`?void 0:S===`projects`?`/projects`:`/`};if(R.mode===`root`)return[{label:`Dashboard`}];let t={label:`Projects`,to:R.mode===`project`?`/projects`:void 0};if(R.mode===`projects`)return[e,{label:`Projects`}];if(R.mode===`project`)return[e,t,{label:K?.displayName??R.activeProjectKey}];if(R.mode===`session`&&S===`projects`&&nt)return[e,{label:`Projects`,to:`/projects`},{label:St?.displayName??nt.key,to:ra(nt)},{label:p?.title||R.activeSessionSlug||`Conversation`}];if(R.mode===`missingAgent`)return[e,{label:R.attemptedKey}];let n=xt?.displayName??U??`Unknown Agent`,r={label:n,to:R.mode===`session`?`/${U}`:void 0};return R.mode===`agent`?[e,{label:n}]:R.mode===`missingSession`?[e,r,{label:R.attemptedSessionSlug}]:R.mode===`session`?[e,r,{label:p?.title||R.activeSessionSlug||`Conversation`}]:[e,{label:`Invalid Route`}]},[xt,U,K,S,L,St,nt,p?.title,R]),Dt;Dt=s?(0,I.jsx)(Ai,{}):L?(0,I.jsx)(Tt,{id:`SearchResultsPanel`,detail:{results:k.length,loading:be},children:(0,I.jsx)(Ro,{query:D,loading:be,results:k,agentNameMap:Ke,agents:t,projects:wt,filters:O,onChangeFilters:ve,onOpenResult:()=>{_e(!1),he(``)},selectedIndex:we,registerResultRef:(e,t)=>{t?je.current.set(e,t):je.current.delete(e)}})}):l?(0,I.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:l}):R.mode===`root`?te?(0,I.jsx)(Tt,{id:`Dashboard`,detail:{sessions:te.totals.sessions,projects:b.length},children:(0,I.jsx)(ja,{data:te,projects:b,bookmarkedSessions:st,isBookmarked:Ye,onToggleBookmark:(e,t)=>{if(`agentName`in e){H(e,t??e.agentName.toLowerCase());return}V(e)}})}):(0,I.jsx)(Hi,{type:`global`,sessions:vt,agentItems:bt,isBookmarked:Ye,onToggleBookmark:e=>H(e,e.agentKey)}):R.mode===`projects`?(0,I.jsx)(Ba,{projects:b}):R.mode===`project`?(0,I.jsx)(Wa,{project:K,projectKey:R.activeProjectKey,dashboard:se,loading:le,error:de,sessions:yt,activeAgent:w,onChangeAgent:fe,isBookmarked:Ye,onToggleSessionBookmark:H}):R.mode===`agent`&&U?(0,I.jsx)(Hi,{type:`agent`,sessions:z.byLandingAgent.get(U)??[],agentItems:bt,activeAgentKey:U,isBookmarked:Ye,onToggleBookmark:e=>H(e,e.agentKey)}):R.mode===`session`?h?(0,I.jsx)(Ai,{}):_||!p?(0,I.jsx)(Hi,{type:`missing-session`,sessions:z.byLandingAgent.get(R.activeAgentKey)??[],agentItems:bt,activeAgentKey:R.activeAgentKey,attemptedSessionSlug:R.activeSessionSlug,isBookmarked:Ye,onToggleBookmark:e=>H(e,e.agentKey)}):(0,I.jsx)(Tt,{id:`SessionDetail`,detail:{messages:p.messages.length,session:p.id},children:(0,I.jsx)(mi,{session:p,highlightQuery:Je})}):R.mode===`missingAgent`?(0,I.jsx)(Hi,{type:`missing-agent`,sessions:vt,agentItems:bt,attemptedAgentKey:R.attemptedKey,isBookmarked:Ye,onToggleBookmark:e=>H(e,e.agentKey)}):(0,I.jsx)(`div`,{className:`text-sm text-[var(--console-muted)]`,children:`Invalid route.`});function Ot(){he(E.trim()),_e(!0),Te(0)}function Y(){ke(!0);try{window.localStorage.setItem(Do,`1`)}catch{}}function kt(t){if(!(t===`projects`&&mt)){if(ie(t),j(null),t===`projects`){let t=tt??(R.mode===`session`?null:ae);e(t?ra(t):`/projects`);return}e(`/`)}}let At=(0,M.useEffectEvent)(t=>{let n=t.key;if((t.metaKey||t.ctrlKey)&&n.toLowerCase()===`k`){t.preventDefault(),_e(!0),Te(0),window.setTimeout(()=>{Ae.current?.focus(),Ae.current?.select()},0);return}if(t.defaultPrevented||t.metaKey||t.ctrlKey||t.altKey||t.isComposing)return;let r=t.target,i=Po(r);if(Ee){n===`Escape`&&(t.preventDefault(),De(!1));return}if(i){n===`Escape`&&(t.preventDefault(),r instanceof HTMLElement&&r.blur());return}if(n===`?`){t.preventDefault(),De(!0),Y();return}if(n===`/`){t.preventDefault(),Y(),_e(!0),Ae.current?.focus(),Ae.current?.select();return}if(n===`Escape`){if(t.preventDefault(),L){_e(!1),he(``),me(``);return}if(R.mode===`session`&&R.activeAgentKey){if(S===`projects`&&nt){e(ra(nt));return}e(`/${R.activeAgentKey}`)}return}if(L){if(k.length===0)return;if(n===`j`){t.preventDefault(),Y(),Te(e=>Math.min(e+1,k.length-1));return}if(n===`k`){t.preventDefault(),Y(),Te(e=>Math.max(e-1,0));return}if(n===`g`){t.preventDefault(),Y(),Te(0);return}if(n===`G`){t.preventDefault(),Y(),Te(k.length-1);return}if(n===`Enter`){let n=k[we];if(!n)return;t.preventDefault(),Y(),_e(!1),he(``),e(`/${n.agentName.toLowerCase()}/${n.session.id}`,{state:{searchQuery:D}})}return}if(S===`agents`&&!U||W.length===0)return;let a=e=>{Y();let t=Ce==null?-1:ot.indexById.get(Ce)??-1,n=t>=0?t:e>=0?-1:W.length;j(W[Math.max(0,Math.min(n+e,W.length-1))]?.id??null)};if(n===`j`){t.preventDefault(),a(1);return}if(n===`k`){t.preventDefault(),a(-1);return}if(n===`g`){t.preventDefault(),Y(),j(W[0]?.id??null);return}if(n===`G`){t.preventDefault(),Y(),j(W.at(-1)?.id??null);return}if(n===`Enter`){let n=Ce==null?null:ot.byId.get(Ce);if(!n)return;t.preventDefault(),Y(),e(S===`projects`?`/${n.slug}`:`/${U}/${n.id}`)}});return(0,M.useEffect)(()=>(window.addEventListener(`keydown`,At),()=>window.removeEventListener(`keydown`,At)),[]),(0,I.jsxs)(`div`,{className:`console-ui flex h-screen flex-col overflow-hidden bg-[var(--console-bg)] text-[var(--console-text)]`,children:[(0,I.jsx)(`header`,{className:`shrink-0 border-b border-[var(--console-border)] bg-white/85 backdrop-blur-sm`,children:(0,I.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,I.jsxs)(x,{to:`/`,className:`flex items-center gap-2 text-[var(--console-text)]`,children:[(0,I.jsx)(`img`,{src:`/logo.svg?v=3`,alt:`CodeSesh`,className:`h-6 w-6 rounded-sm`}),(0,I.jsx)(`span`,{className:`console-mono text-sm font-semibold uppercase tracking-[0.05em]`,children:`CodeSesh`})]}),(0,I.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(),Ot()},children:[(0,I.jsx)(`label`,{className:`flex min-w-0 flex-1 items-center rounded-sm border border-[var(--console-border)] bg-white px-2 py-1`,children:(0,I.jsx)(`input`,{ref:Ae,value:E,onChange:e=>me(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,I.jsx)(`button`,{type:`submit`,className:`console-mono rounded-sm border border-[var(--console-border-strong)] bg-[var(--console-surface-muted)] px-3 py-1 text-xs text-[var(--console-text)] transition-colors hover:bg-white`,children:`Search`})]}),(0,I.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,I.jsxs)(`button`,{type:`button`,onClick:()=>{De(!0),Y()},className:`console-mono rounded-sm border border-[var(--console-border)] bg-white px-2 py-1 text-xs text-[var(--console-text)] transition-colors hover:bg-[var(--console-surface-muted)]`,title:`Show keyboard shortcuts`,children:[`?`,(0,I.jsx)(`span`,{className:`hidden sm:inline`,children:` Shortcuts`})]}),_o(T)?(0,I.jsx)(`span`,{className:`console-mono hidden rounded-sm border border-[var(--console-border)] bg-white px-2 py-1 text-xs text-[var(--console-text)] md:inline-flex`,title:`Time window applied to agent counts, dashboard, and session list`,children:_o(T)}):null,(0,I.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.8.0`]})]})]})}),(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,I.jsx)(`aside`,{className:`hidden w-64 shrink-0 flex-col border-r border-[var(--console-border)] bg-[var(--console-sidebar-bg)] lg:flex`,children:(0,I.jsxs)(`div`,{className:`console-scrollbar flex-1 space-y-8 overflow-y-auto px-4 py-6`,children:[(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:`BROWSE BY`}),(0,I.jsx)(Fo,{value:S,onChange:kt,projectsDisabled:mt})]}),(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:`NAVIGATION`}),(0,I.jsxs)(`ul`,{className:`space-y-1 ${S===`projects`?`console-scrollbar max-h-[min(280px,calc(100vh-440px))] overflow-y-auto pr-1`:``}`,children:[(0,I.jsx)(`li`,{children:(0,I.jsxs)(x,{to:S===`projects`?`/projects`:`/`,className:`flex items-center gap-2 rounded-sm border px-3 py-1.5 text-left transition-colors ${S===`agents`&&R.mode===`root`||S===`projects`&&R.mode===`projects`?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,children:[(0,I.jsx)(`img`,{src:`/logo.svg?v=3`,alt:`Dashboard`,className:`size-3.5 rounded-[2px]`}),(0,I.jsx)(`span`,{className:`console-mono line-clamp-1 flex-1 text-xs`,children:`Dashboard`})]})}),S===`agents`?t.map(e=>{let t=e.name.toLowerCase(),n=t===U,r=N.agents[t],i=bo(A,e.name),a=mt&&i!==null,o=`ml-4 flex items-center gap-2 rounded-sm border px-3 py-1.5 text-left transition-colors ${a?`cursor-not-allowed border-transparent text-[var(--console-muted)] opacity-50`:n?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,s=(0,I.jsxs)(I.Fragment,{children:[r?.icon&&(0,I.jsx)(`img`,{src:r.icon,alt:e.displayName,className:`size-3.5 object-contain`}),(0,I.jsx)(`span`,{className:`console-mono line-clamp-1 flex-1 text-xs`,children:e.displayName}),(0,I.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:i??xo(A,e.name,e.count)})]});return(0,I.jsxs)(`li`,{children:[a?(0,I.jsx)(`span`,{className:o,title:`Available after this agent scan completes`,children:s}):(0,I.jsx)(x,{to:`/${t}`,className:o,children:s}),i?(0,I.jsx)(`span`,{className:`ml-4 mt-1 block h-1 overflow-hidden rounded-sm bg-[var(--console-surface-muted)]`,children:(0,I.jsx)(`span`,{className:`block h-full bg-[var(--console-accent)]`,style:{width:`${A?.agentStatuses[e.name]?.total?Math.round((A.agentStatuses[e.name]?.processed??0)/A.agentStatuses[e.name].total*100):8}%`}})}):null]},e.name)}):b.map(e=>{let t=So(e),n=rt===ta(t);return(0,I.jsx)(`li`,{children:(0,I.jsxs)(x,{to:ra(t),onClick:()=>oe(t),className:`ml-4 flex min-w-0 items-center gap-2 rounded-sm border px-3 py-1.5 text-left transition-colors ${n?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,children:[(0,I.jsx)(`span`,{className:`console-mono min-w-0 flex-1 truncate text-xs`,children:e.displayName}),(0,I.jsx)(`span`,{className:`console-mono shrink-0 text-[11px] text-[var(--console-muted)]`,children:e.sessionCount})]})},`${e.identityKind}:${e.identityKey}`)}),S===`agents`&&t.length===0&&!s?(0,I.jsx)(`li`,{children:(0,I.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:A?.active?`Scanning agents...`:`No agents found`})}):null,S===`projects`&&b.length===0&&!s?(0,I.jsx)(`li`,{children:(0,I.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:A?.active?`Scanning projects...`:`No projects found`})}):null]})]}),(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:`BOOKMARKS`}),st.length===0?(0,I.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:`No bookmarks yet`}):(0,I.jsx)(`ul`,{className:`space-y-1`,children:st.map(e=>{let t=R.mode===`session`&&R.activeAgentKey===e.agentKey&&R.activeSessionSlug===e.sessionId,n=N.agents[e.agentKey];return(0,I.jsx)(`li`,{children:(0,I.jsxs)(`div`,{className:`flex items-start gap-2 rounded-sm border px-2 py-1.5 transition-colors ${t?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,children:[(0,I.jsxs)(x,{to:`/${e.fullPath}`,className:`flex min-w-0 flex-1 items-start gap-2`,children:[n?.icon?(0,I.jsx)(`img`,{src:n.icon,alt:n.name,className:`mt-0.5 size-3.5 shrink-0 object-contain`}):null,(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`span`,{className:`console-mono line-clamp-1 block text-xs`,children:e.title}),(0,I.jsx)(`span`,{className:`console-mono mt-0.5 line-clamp-1 block text-[10px] text-[var(--console-muted)]`,children:n?.name??e.agentKey})]})]}),(0,I.jsx)(ji,{active:!0,onToggle:()=>V(e)})]})},qi(e.agentKey,e.sessionId))})})]}),(0,I.jsxs)(`section`,{children:[(0,I.jsxs)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:[`SESSIONS`,W.length>0?(0,I.jsx)(`span`,{className:`ml-2 text-[10px] font-normal text-[var(--console-muted)]`,children:`Navigate j k · Open Enter`}):null]}),S===`agents`&&!U?(0,I.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:`Select an agent`}):S===`projects`&&!rt?(0,I.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:`Select a project`}):W.length===0?(0,I.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:A?.active?`Scanning sessions...`:`No sessions yet`}):S===`projects`?(0,I.jsx)(Io,{sessions:W,activeSessionId:R.mode===`session`?R.activeSessionSlug:null,selectedSessionId:Ce,bookmarkedSessionIds:G,onSelectSession:ct,onToggleBookmark:lt}):(0,I.jsx)(Tt,{id:`SessionTreeSidebar`,detail:{sessions:W.length},children:(0,I.jsx)(oo,{sessions:W,activeSessionId:R.mode===`session`?R.activeSessionSlug:null,selectedSessionId:Ce,onSelectSession:ut,bookmarkedSessionIds:G,onToggleBookmark:lt})})]})]})}),(0,I.jsxs)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,I.jsx)(`section`,{className:`shrink-0 border-b border-[var(--console-border)] bg-white/70 px-4 py-4 backdrop-blur-sm md:px-8`,children:(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`nav`,{"aria-label":`Breadcrumb`,className:`console-mono mb-2 flex flex-wrap items-center gap-1 text-[11px] text-[var(--console-muted)]`,children:Et.map((e,t)=>(0,I.jsxs)(`span`,{className:`flex items-center gap-1`,children:[e.to?(0,I.jsx)(x,{to:e.to,className:`transition-colors hover:text-[var(--console-text)]`,children:e.label}):(0,I.jsx)(`span`,{className:`text-[var(--console-text)]`,children:e.label}),t<Et.length-1?(0,I.jsx)(`span`,{children:`/`}):null]},`${e.label}-${t}`))}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.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:R.mode===`session`?`Session`:R.mode===`root`?`Dashboard`:R.mode===`projects`?`Projects`:R.mode===`project`?`Project`:`Landing`}),(0,I.jsx)(`h1`,{className:`console-mono text-xl font-semibold tracking-tight text-[var(--console-text)]`,children:q})]}),(0,I.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:J}),(0,I.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[Oe?null:(0,I.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,I.jsx)(`span`,{children:`Keyboard navigation available`}),(0,I.jsx)(`span`,{className:`rounded-sm border border-[var(--console-border)] bg-white px-1`,children:`?`}),(0,I.jsx)(`button`,{type:`button`,onClick:Y,className:`text-[var(--console-muted)] transition-colors hover:text-[var(--console-text)]`,"aria-label":`Dismiss keyboard shortcuts hint`,children:`×`})]}),!L&&R.mode===`session`?(0,I.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,!L&&R.mode===`session`&&p?(0,I.jsx)(Za,{agentName:R.activeAgentKey,sessionId:p.id,directory:p.directory}):null]}),ee?(0,I.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:ee}):null,pt&&R.mode===`root`?(0,I.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:pt}):null]})}),(0,I.jsx)(`section`,{className:`console-scrollbar bg-grid min-h-0 flex-1 overflow-y-auto px-4 py-6 md:px-8`,children:(0,I.jsx)(Ga,{children:(0,I.jsx)(Tt,{id:`MainContent`,detail:{mode:R.mode,search:L,sessions:r.length},children:Dt})})})]})]}),Ee?(0,I.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/35 px-4`,onClick:()=>De(!1),children:(0,I.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Keyboard shortcuts`,className:`w-full max-w-2xl rounded-sm border border-[var(--console-border-strong)] bg-white p-5 shadow-2xl`,onClick:e=>e.stopPropagation(),children:[(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-[0.16em] text-[var(--console-muted)]`,children:`Keyboard Shortcuts`}),(0,I.jsx)(`h2`,{className:`console-mono mt-2 text-xl font-semibold text-[var(--console-text)]`,children:`Navigate without leaving the keyboard`})]}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>De(!1),className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-xs text-[var(--console-text)] transition-colors hover:bg-white`,children:`Esc`})]}),(0,I.jsx)(`div`,{className:`mt-5 grid gap-4 md:grid-cols-3`,children:No.map(e=>(0,I.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] p-4`,children:[(0,I.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:e.title}),(0,I.jsx)(`div`,{className:`mt-3 space-y-3`,children:e.items.map(e=>(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`console-mono text-xs text-[var(--console-text)]`,children:e.keys}),(0,I.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-[var(--console-muted)]`,children:e.description})]},e.keys))})]},e.title))})]})}):null]})}function Ro({query:e,loading:t,results:n,agentNameMap:r,agents:i,projects:a,filters:o,onChangeFilters:s,onOpenResult:c,selectedIndex:l,registerResultRef:u}){let d=(0,I.jsx)(zo,{agents:i,projects:a,filters:o,onChangeFilters:s});return t?(0,I.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[d,(0,I.jsx)(`div`,{className:`grid gap-3`,children:Array.from({length:4}).map((e,t)=>(0,I.jsxs)(`div`,{className:`animate-pulse rounded-sm border border-[var(--console-border)] bg-white/80 p-4`,children:[(0,I.jsx)(`div`,{className:`h-3 w-32 rounded bg-[var(--console-surface-muted)]`}),(0,I.jsx)(`div`,{className:`mt-3 h-4 w-2/3 rounded bg-[var(--console-surface-muted)]`}),(0,I.jsx)(`div`,{className:`mt-2 h-3 w-full rounded bg-[var(--console-surface-muted)]`}),(0,I.jsx)(`div`,{className:`mt-1 h-3 w-5/6 rounded bg-[var(--console-surface-muted)]`})]},t))})]}):n.length===0?(0,I.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[d,(0,I.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white/80 p-6`,children:[(0,I.jsx)(`h2`,{className:`console-mono text-sm font-semibold text-[var(--console-text)]`,children:e?`No matches`:`No recent sessions`}),e?(0,I.jsxs)(`p`,{className:`console-mono mt-2 text-xs text-[var(--console-muted)]`,children:[`Query: `,e]}):null]})]}):(0,I.jsxs)(`div`,{className:`grid gap-3`,children:[d,(0,I.jsx)(`div`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:`Navigate j k · Open Enter · Exit Esc`}),n.map((t,n)=>{let i=t.agentName.toLowerCase(),a=r.get(i)??t.agentName,o=`${t.agentName}/${t.session.id}`;return(0,I.jsxs)(x,{ref:e=>u(o,e),to:`/${i}/${t.session.id}`,state:{searchQuery:e},onClick:c,className:`rounded-sm border bg-white/85 p-4 transition-colors hover:border-[var(--console-border-strong)] hover:bg-white ${n===l?`border-[var(--console-border-strong)]`:`border-[var(--console-border)]`}`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.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,I.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-white px-1.5 py-0.5 text-[10px] uppercase text-[var(--console-muted)]`,children:Mo[t.matchType]}),(0,I.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:t.session.directory})]}),(0,I.jsx)(`h2`,{className:`console-mono mt-3 text-sm font-semibold text-[var(--console-text)]`,children:t.session.title}),(0,I.jsx)(qe,{tags:t.session.smart_tags,className:`mt-2`}),(0,I.jsx)(`p`,{className:`console-mono mt-2 text-xs leading-6 text-[var(--console-muted)] [&_mark]:bg-[var(--console-accent)] [&_mark]:px-0.5 [&_mark]:text-white`,dangerouslySetInnerHTML:{__html:Eo(t.snippet||t.session.title)}})]},o)})]})}function zo({agents:e,projects:t,filters:n,onChangeFilters:r}){let i=Object.values(n).some(Boolean),a=(e,t)=>{r(n=>({...n,[e]:n[e]===t?void 0:t}))};return(0,I.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white/85 p-3`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`Scope`}),(0,I.jsx)(Bo,{active:!n.projectKey,label:`All`,onClick:()=>r(e=>({...e,projectKey:void 0}))}),t.map(e=>(0,I.jsx)(Bo,{active:n.projectKey===e.key,label:e.showCount===!1?e.label:`${e.label} · ${e.count}`,onClick:()=>a(`projectKey`,e.key)},e.key))]}),(0,I.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`Agent`}),(0,I.jsx)(Bo,{active:!n.agent,label:`All Agents`,onClick:()=>r(e=>({...e,agent:void 0}))}),e.map(e=>(0,I.jsx)(Bo,{active:n.agent===e.name,label:e.displayName,onClick:()=>a(`agent`,e.name)},e.name))]}),(0,I.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`Tag`}),Oo.map(e=>(0,I.jsx)(Bo,{active:n.tag===e,label:Ge[e],onClick:()=>a(`tag`,e)},e))]}),(0,I.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`Signal`}),ko.map(e=>(0,I.jsx)(Bo,{active:n.tool===e,label:`tool:${e}`,onClick:()=>a(`tool`,e)},e))]}),(0,I.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`File Activity`}),Ao.map(e=>(0,I.jsx)(Bo,{active:n.fileKind===e.kind,label:e.label,onClick:()=>a(`fileKind`,e.kind)},e.kind))]}),(0,I.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`console-mono text-[10px] font-semibold uppercase text-[var(--console-muted)]`,children:`Cost Range`}),(0,I.jsx)(Bo,{active:!n.costRange,label:`Any Cost`,onClick:()=>r(e=>({...e,costRange:void 0}))}),jo.map(e=>(0,I.jsx)(Bo,{active:n.costRange===e.id,label:e.label,onClick:()=>a(`costRange`,e.id)},e.id)),i?(0,I.jsx)(`button`,{type:`button`,onClick:()=>r({}),className:`console-mono ml-auto rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[10px] text-[var(--console-muted)] transition-colors hover:bg-white`,children:`Clear`}):null]})]})}function Bo({active:e,label:t,onClick:n}){return(0,I.jsx)(`button`,{type:`button`,onClick:n,className:`console-mono rounded-sm border px-2 py-1 text-[10px] transition-colors ${e?`border-[var(--console-border-strong)] bg-[var(--console-accent)] text-white`:`border-[var(--console-border)] bg-[var(--console-surface-muted)] text-[var(--console-muted)] hover:bg-white`}`,children:t})}je.createRoot(document.getElementById(`root`)).render((0,I.jsx)(M.StrictMode,{children:(0,I.jsx)(s,{children:(0,I.jsx)(Tt,{id:`App`,children:(0,I.jsx)(Lo,{})})})}));