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