codesesh 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/{chunk-JHX5OLL4.js → chunk-PSHZZITB.js} +3280 -805
- package/dist/chunk-PSHZZITB.js.map +1 -0
- package/dist/chunk-RF3EEWPH.js +17 -0
- package/dist/chunk-RF3EEWPH.js.map +1 -0
- package/dist/{chunk-OFTTM3UD.js → chunk-WAKW5OPS.js} +2 -2
- package/dist/{dist-N2PQATP2.js → dist-RHDY2EZX.js} +18 -20
- package/dist/index.js +1291 -672
- package/dist/index.js.map +1 -1
- package/dist/project-identity-worker.js +27 -0
- package/dist/project-identity-worker.js.map +1 -0
- package/dist/scan-refresh-worker.js +15 -6
- package/dist/scan-refresh-worker.js.map +1 -1
- package/dist/search-index-worker.js +16 -6
- package/dist/search-index-worker.js.map +1 -1
- package/dist/smart-tag-worker.js +2 -2
- package/dist/web/assets/{ErrorBoundary-D11tWzfn.js → ErrorBoundary-DIwwrdlw.js} +1 -1
- package/dist/web/assets/InteractiveReceipt-DmNBDVms.js +1 -0
- package/dist/web/assets/{OverviewScreen-DriPmCam.js → OverviewScreen-B5JekBLC.js} +1 -1
- package/dist/web/assets/Projects-Bj6ma2k2.js +1 -0
- package/dist/web/assets/{SearchFilterBar-Bx73B5e9.js → SearchFilterBar-B9VrUbym.js} +1 -1
- package/dist/web/assets/{SearchResultsPanel-A6_3TPhW.js → SearchResultsPanel-C1cuuOKq.js} +1 -1
- package/dist/web/assets/SessionDetail-Dc2CQ3hH.js +54 -0
- package/dist/web/assets/contract-DXvltqJG.js +1 -0
- package/dist/web/assets/index-3UfOiTBO.css +1 -0
- package/dist/web/assets/index-DBMiEd61.js +1410 -0
- package/dist/web/assets/panel-CLnL4kMN.js +1 -0
- package/dist/web/assets/{session-indexes-0oT5HSS5.js → session-indexes-BPhf1X2P.js} +2 -2
- package/dist/web/assets/{utils-DgUgu15E.js → utils-BKqufGdv.js} +1 -1
- package/dist/web/icon/agent/dsh.svg +3 -0
- package/dist/web/index.html +8 -8
- package/package.json +1 -1
- package/dist/chunk-JHX5OLL4.js.map +0 -1
- package/dist/web/assets/InteractiveReceipt-DYGyHeZd.js +0 -1
- package/dist/web/assets/Projects-BPDIcUBK.js +0 -1
- package/dist/web/assets/SessionDetail-lQz99ARH.js +0 -54
- package/dist/web/assets/contract-V6QuD0UY.js +0 -1
- package/dist/web/assets/index-B2RqUgZ5.css +0 -1
- package/dist/web/assets/index-BgWoUD_4.js +0 -1410
- package/dist/web/assets/panel-C-gc79Gz.js +0 -1
- /package/dist/{chunk-OFTTM3UD.js.map → chunk-WAKW5OPS.js.map} +0 -0
- /package/dist/{dist-N2PQATP2.js.map → dist-RHDY2EZX.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,n as t,t as n}from"./jsx-runtime-B-hcVAMW.js";import{h as r}from"./contract-DXvltqJG.js";import{t as i}from"./SmartTagChips-ux6idUGJ.js";import{t as a}from"./session-title-DdtlxtlR.js";var o=e(t(),1);function s(e,t){return t===0||e-t>=15.666666666666668}function c(e,t,n){return!e&&t<=.12?n+1:0}function l(e,t){return e?0:t+1}function u(){let e=typeof document>`u`?void 0:document.fonts;return e?e.ready.then(()=>void 0):Promise.resolve()}function d(e,t,n){return e>=2&&(t>=8||n>=300)}var f=n();function p(e,t){return!e||Math.abs(e.receiptWidth-t.receiptWidth)>.5||Math.abs(e.receiptHeight-t.receiptHeight)>.5||Math.abs(e.startX-t.startX)>.5||Math.abs(e.startY-t.startY)>.5}var m=18,h=42,g=5,_=270,v=500,y=2,b=.035;function ee(e){let t=window.getComputedStyle(e),n=(e,n)=>t.getPropertyValue(e).trim()||n;return{paperTop:n(`--console-surface`,`white`),paperBottom:n(`--console-surface-sunken`,`whitesmoke`),ink:n(`--console-text`,`black`),inkMuted:n(`--console-text-secondary`,`dimgray`),line:n(`--console-border-strong`,`silver`),shadow:n(`--scrim`,`gray`)}}function te(e){return window.getComputedStyle(e).getPropertyValue(`--font-mono`).trim()||`monospace`}function x(e){return Math.round(e??0).toLocaleString(`en-US`)}function S(e){return`$${(e??0).toFixed(4)}`}function C(e){return new Date(e).toLocaleString(`en-US`,{month:`short`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`})}function w(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 T(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 E(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 D(e){return!e||e.length===0?`SESSION ACTIVITY RECEIPT`:e.map(e=>i[e]).join(` / `)}function O(e,t){let n=r(e);return{id:e.id,title:a(e)||`Untitled session`,agent:n,updatedAt:e.time_updated??e.time_created,tags:e.smart_tags,stats:e.stats,items:E(t)}}function k(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 A(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 j(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(A(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]=A(e,a[a.length-1]??``,n)),a.slice(0,r)}function ne(e,t,n){let r=document.createElement(`canvas`);r.width=_*y,r.height=v*y;let i=r.getContext(`2d`);if(!i)return r;i.scale(y,y);let a=e=>`${e} ${n}`,o=i.createLinearGradient(0,0,_,v);o.addColorStop(0,t.paperTop),o.addColorStop(1,t.paperBottom),i.fillStyle=o,i.fillRect(0,0,_,v);let s=T(w(e.id));i.fillStyle=t.ink;for(let e=0;e<1200;e+=1)i.globalAlpha=b*(.12+s()*.14),i.fillRect(s()*_,s()*v,.7,.7);i.globalAlpha=1,i.fillStyle=t.ink,i.font=a(`700 18px`),i.textAlign=`center`,i.fillText(`CODESESH MART`,_/2,34),i.fillStyle=t.inkMuted,i.font=a(`11px`),i.fillText(A(i,D(e.tags).toUpperCase(),234),_/2,51),i.strokeStyle=t.line,i.lineWidth=1,i.setLineDash([4,4]),i.beginPath(),i.moveTo(18,66),i.lineTo(252,66),i.stroke(),i.setLineDash([]),i.textAlign=`left`,i.fillStyle=t.ink,i.font=a(`11px`),k(i,`Agent`,e.agent,88,_),k(i,`Updated`,C(e.updatedAt),104,_),k(i,`Session`,`#${e.id.slice(0,8)}`,120,_),i.setLineDash([2,3]),i.beginPath(),i.moveTo(18,140),i.lineTo(252,140),i.stroke(),i.setLineDash([]),i.font=a(`700 12px`),i.fillText(`SESSION TOC RECEIPT LIST`,18,163),i.font=a(`11px`);let c=185;for(let t of e.items){let e=x(t.count);i.fillText(A(i,t.label,168),18,c),i.fillText(e,252-i.measureText(e).width,c),c+=17}return i.strokeStyle=t.line,i.lineWidth=1.5,i.beginPath(),i.moveTo(18,c+5),i.lineTo(252,c+5),i.stroke(),c+=26,k(i,`Input tokens`,x(e.stats.total_input_tokens),c,_),c+=16,k(i,`Output tokens`,x(e.stats.total_output_tokens),c,_),c+=16,k(i,`Messages`,x(e.stats.message_count),c,_),c+=22,i.font=a(`700 13px`),k(i,`TOTAL COST`,S(e.stats.total_cost),c,_),i.strokeStyle=t.line,i.setLineDash([4,4]),i.beginPath(),i.moveTo(18,c+18),i.lineTo(252,c+18),i.stroke(),i.setLineDash([]),i.font=a(`10px`),i.textAlign=`center`,i.fillStyle=t.inkMuted,j(i,e.title,234,2).forEach((e,t)=>{i.fillText(e,_/2,c+38+t*13)}),r}function M(e,t){return e*m+t}function N(e){let{receiptWidth:t,receiptHeight:n,startX:r,startY:i}=e,a=t/17,o=n/41,s=[],c=[];for(let e=0;e<h;e+=1)for(let t=0;t<m;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<h;e+=1)for(let t=0;t<m;t+=1){let n=M(e,t);t<17&&l(n,M(e,t+1),.98),e<41&&l(n,M(e+1,t),.92),e<41&&t<17&&(l(n,M(e+1,t+1),.46),l(M(e+1,t),M(e,t+1),.46)),t<16&&l(n,M(e,t+2),.35),e<40&&l(n,M(e+2,t),.28)}return{particles:s,constraints:c,receiptWidth:t,receiptHeight:n}}function re(e,t){let n=t.receiptWidth/17;for(let r=0;r<m;r+=1){let i=e[r];i&&(i.fixedX=t.startX+r*n,i.fixedY=t.startY)}}function P(e){for(let t=0;t<m;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 ie(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 ae(e,t,n,r,i,a){let o=r[M(i,a)],s=r[M(i,a+1)],c=r[M(i+1,a)],l=r[M(i+1,a+1)];if(!o||!s||!c||!l)return;let u=a/17*t.width,d=i/41*t.height,f=t.width/17,p=t.height/41;e.save(),e.beginPath(),e.moveTo(o.x,o.y),e.lineTo(s.x,s.y),e.lineTo(l.x,l.y),e.lineTo(c.x,c.y),e.closePath(),e.clip(),e.transform((s.x-o.x)/f,(s.y-o.y)/f,(c.x-o.x)/p,(c.y-o.y)/p,o.x,o.y),e.drawImage(t,u,d,f+1,p+1,0,0,f+1,p+1),e.restore();let m=Math.atan2(s.y-o.y,s.x-o.x),h=Math.hypot(c.x-o.x,c.y-o.y)/(v/41),g=Math.sin(m)*.08+(h-1)*.16;Math.abs(g)<.01||(e.save(),e.beginPath(),e.moveTo(o.x,o.y),e.lineTo(s.x,s.y),e.lineTo(l.x,l.y),e.lineTo(c.x,c.y),e.closePath(),e.globalAlpha=Math.abs(g),e.fillStyle=g>0?n.paperTop:n.shadow,e.fill(),e.restore())}function oe(e,t,n){let r=null,i=44;for(let a=m;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 se(e){let t=0;for(let n=m;n<e.length;n+=1){let r=e[n];r&&(t=Math.max(t,Math.hypot(r.x-r.oldX,r.y-r.oldY)))}return t}function F({session:e,toc:t,minWidthQuery:n=`(min-width: 1025px)`}){let r=(0,o.useRef)(null),i=(0,o.useRef)(null),a=(0,o.useRef)(null),h=(0,o.useMemo)(()=>O(e,t),[e,t]),y=(0,o.useRef)(h),b=(0,o.useRef)(null);return(0,o.useLayoutEffect)(()=>{let e=r.current,t=i.current,o=a.current;if(!e||!t||!o)return;let f=e.getContext(`2d`,{alpha:!0});if(!f)return;let h={id:null,x:0,y:0,prevX:0,prevY:0,vx:0,vy:0,grabbedIndex:null},x=null,S=!1,C=0,w=0,T=0,E=N({receiptWidth:_,receiptHeight:v,startX:0,startY:32}),D=performance.now(),O=null,k=0,A=0,j=0,M=0,F=!1,I=!1,L=window.matchMedia(n),R=window.matchMedia(`(prefers-reduced-motion: reduce)`),z=()=>x!=null&&L.matches&&document.visibilityState===`visible`,B=()=>{let e=ee(t);x={texture:ne(y.current,e,te(t)),palette:e}},V=()=>{let e=t.getBoundingClientRect(),n=Math.max(280,e.width||320),r=Math.min(_,n-34);return{receiptWidth:r,receiptHeight:Math.min(v,Math.max(320,T-42)),startX:(n-r)/2,startY:32}},H=t=>{F!==t&&(F=t,e.style.visibility=t?`visible`:`hidden`,o.style.visibility=t&&!R.matches?`visible`:`hidden`)},U=()=>{I=!1,C&&=(window.cancelAnimationFrame(C),0),H(!1)},W=(e,t=performance.now())=>{E=N(e),O=e,D=t},G=()=>{let n=window.devicePixelRatio||1,r=t.getBoundingClientRect();w=Math.max(1,r.width),T=Math.max(1,r.height),e.width=Math.floor(w*n),e.height=Math.floor(T*n),f.setTransform(n,0,0,n,0,0),k=0,A=0,j=0,M=0,H(!1),W(V()),z()&&K()},K=()=>{I||!z()||(I=!0,C=window.requestAnimationFrame($))},q=()=>{z()?G():U()},J=e=>{let n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}},Y=e=>{if(e.button!==0||R.matches)return;let t=J(e),n=oe(E.particles,t.x,t.y);n!=null&&(e.preventDefault(),o.setPointerCapture(e.pointerId),h.id=e.pointerId,h.x=t.x,h.y=t.y,h.prevX=t.x,h.prevY=t.y,h.vx=0,h.vy=0,h.grabbedIndex=n,A=0,j=0,K())},X=e=>{if(h.id!==e.pointerId)return;let t=J(e);h.vx=t.x-h.prevX,h.vy=t.y-h.prevY,h.prevX=t.x,h.prevY=t.y,h.x=t.x,h.y=t.y},Z=e=>{if(h.id!==e.pointerId)return;let t=h.grabbedIndex==null?null:E.particles[h.grabbedIndex];t&&(t.oldX=t.x-h.vx*.9,t.oldY=t.y-h.vy*.9),h.id=null,h.grabbedIndex=null},ce=e=>{let t=(e-D)/1e3;for(let e=m;e<E.particles.length;e+=1){let n=E.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=h.grabbedIndex==null?null:E.particles[h.grabbedIndex];n&&(n.x+=(h.x-n.x)*.72,n.y+=(h.y-n.y)*.72)},le=()=>{for(let e=0;e<g;e+=1){P(E.particles);for(let e of E.constraints)ie(E.particles,e)}P(E.particles)},ue=()=>{let e=1/0,t=1/0,n=-1/0,r=-1/0;for(let i of E.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`},de=e=>{let t=E.particles[0],n=E.particles[17],r=E.particles[755],i=E.particles[738];!t||!n||!r||!i||(f.save(),f.shadowColor=e.shadow,f.shadowBlur=24,f.shadowOffsetY=16,f.fillStyle=e.shadow,f.beginPath(),f.moveTo(t.x,t.y),f.lineTo(n.x,n.y),f.lineTo(r.x,r.y),f.lineTo(i.x,i.y),f.closePath(),f.fill(),f.restore())},fe=e=>{let t=E.particles[0],n=E.particles[17];!t||!n||(f.save(),f.strokeStyle=e.ink,f.lineWidth=4,f.lineCap=`round`,f.beginPath(),f.moveTo(t.x-10,t.y-3),f.lineTo(n.x+10,n.y-3),f.stroke(),f.strokeStyle=e.paperTop,f.lineWidth=1,f.beginPath(),f.moveTo(t.x-8,t.y-5),f.lineTo(n.x+8,n.y-5),f.stroke(),f.restore())},Q=()=>{if(x){f.clearRect(0,0,w,T),de(x.palette);for(let e=0;e<41;e+=1)for(let t=0;t<17;t+=1)ae(f,x.texture,x.palette,E.particles,e,t);fe(x.palette),ue()}},$=e=>{if(!I)return;if(!z()){U();return}if(!s(e,M)){C=window.requestAnimationFrame($);return}M=e;let t=V();p(O,t)&&h.id==null?(k=0,H(!1),W(t,e)):(k+=1,O=t),re(E.particles,t),R.matches||(ce(e),le()),Q();let n=h.id!=null;A=c(n,se(E.particles),A),j=l(n,j);let r=R.matches;if((r||k>=2)&&H(!0),r||d(k,A,j)){r||(W(t,e),Q()),I=!1,C=0;return}C=window.requestAnimationFrame($)};H(!1),u().then(()=>{S||(B(),q())});let pe=new ResizeObserver(G);pe.observe(t);let me=new MutationObserver(()=>{B(),Q()});return me.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),L.addEventListener(`change`,q),R.addEventListener(`change`,q),document.addEventListener(`visibilitychange`,q),window.addEventListener(`resize`,q),o.addEventListener(`pointerdown`,Y),o.addEventListener(`pointermove`,X),o.addEventListener(`pointerup`,Z),o.addEventListener(`pointercancel`,Z),b.current=()=>{S||!x||(B(),Q())},()=>{S=!0,b.current=null,U(),pe.disconnect(),me.disconnect(),L.removeEventListener(`change`,q),R.removeEventListener(`change`,q),document.removeEventListener(`visibilitychange`,q),window.removeEventListener(`resize`,q),o.removeEventListener(`pointerdown`,Y),o.removeEventListener(`pointermove`,X),o.removeEventListener(`pointerup`,Z),o.removeEventListener(`pointercancel`,Z)}},[n]),(0,o.useLayoutEffect)(()=>{y.current=h,b.current?.()},[h]),(0,f.jsxs)(`div`,{ref:i,className:`relative h-[calc(100dvh-5.5rem)] min-h-[420px]`,children:[(0,f.jsx)(`canvas`,{ref:r,className:`invisible pointer-events-none absolute inset-0 z-[61] block h-full w-full touch-none`,"aria-hidden":`true`}),(0,f.jsx)(`div`,{ref:a,className:`invisible absolute left-0 top-0 z-[62] cursor-grab touch-none active:cursor-grabbing`,"aria-label":`Interactive thermal receipt with Verlet paper simulation`})]})}export{F as InteractiveReceipt};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,n as t,t as n}from"./jsx-runtime-B-hcVAMW.js";import{Gn as r,_ as i,f as a,g as o,i as s,n as c,o as l,p as u,s as d,t as f,u as p}from"./utils-DgUgu15E.js";import{a as m,l as h,n as g,r as _,t as v,u as y}from"./panel-C-gc79Gz.js";var b=e(t(),1);function x(e,t){let n=e!==null,i=y({queryKey:h.dashboard(e??{},t),enabled:n,queryFn:async({signal:n})=>{if(!e)throw Error(`Dashboard window is required`);try{return await r(e,t,{signal:n})}catch(e){throw n.aborted||console.error(`Failed to load dashboard:`,e),e}}});return{dashboard:n?i.data??null:null,loading:n&&i.isPending,error:n&&i.isError?`Failed to load dashboard`:null}}var S=Math.PI*2;function C(e){return e<0?0:e>1?1:e}function w(e){let t=C(e);return t*t*(3-2*t)}function T(e,t){let n=Math.imul(Math.round(e*16)^2654435769,2246822507);return n=Math.imul(n^n>>>13^Math.round(t*16),3266489909),((n^n>>>16)>>>0)/4294967296}function E(e,t,n){return w((Math.sin(e*.09+n)+Math.sin(t*.075-n*.83)+Math.sin((e+t)*.045+n*1.31)+2)/4)}function ee(e){if(e<=0)return 1;let t=10**Math.floor(Math.log10(e)),n=e/t;return(n<=1?1:n<=2?2:n<=5?5:10)*t}var D=/^var\((--[\w-]+)\)$/;function O(e,t){let n=D.exec(t)?.[1];return n&&e.getPropertyValue(n).trim()||t}function k(e,t){let n=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e)?.[1];if(!n)return e;let r=n.length===3?n.replace(/./g,e=>e+e):n,i=parseInt(r,16);return`rgba(${i>>16&255}, ${i>>8&255}, ${i&255}, ${t})`}var A=50;function j(){let e=!1,t=null,n=0,r=0,i=()=>{n&&cancelAnimationFrame(n),r&&window.clearTimeout(r),n=0,r=0},a=()=>{!e||t===null||n||(r&&=(window.clearTimeout(r),0),n=requestAnimationFrame(s))},o=()=>{!e||t===null||r||n||(r=window.setTimeout(()=>{r=0,a()},A))};function s(r){if(n=0,!e||t===null)return;let i=t(r);i===`active`?a():i===`idle`&&o()}return{api:{requestFrame:a,setFrameHandler:e=>{t=e,e===null?i():a()}},setEnabled:t=>{e!==t&&(e=t,e?a():i())}}}function M(e,t){let n=(0,b.useRef)(null);n.current===null&&(n.current=j());let r=n.current;return(0,b.useEffect)(()=>{let n=e.current;if(!n||t){r.setEnabled(!1);return}let i=!0,a=document.visibilityState===`visible`,o=()=>r.setEnabled(i&&a),s=()=>{a=document.visibilityState===`visible`,o()},c=typeof IntersectionObserver>`u`?null:new IntersectionObserver(([e])=>{i=e?.isIntersecting??!1,o()});return c?.observe(n),document.addEventListener(`visibilitychange`,s),o(),()=>{r.setEnabled(!1),c?.disconnect(),document.removeEventListener(`visibilitychange`,s)}},[r,t,e]),r.api}var N=2,P=5,te=8,ne=7,re=620,ie=.05,ae=.8,oe=.0018,se=.3,ce=.48,le={barRatio:.62,barMax:76,bandGap:4,minBand:6};function ue(e,t,n){let r=Math.max(1,t-1),i=Math.min(ie,ae/r),a=1-(t-1)*i;return 1-(1-C((n-e*i)/a))**3}function de(e,{values:t,axisMax:n,colors:r,highlight:i,hovered:a,layout:o,reducedMotion:s}){let c=(0,b.useContext)(_),l=M(e,s),u=r.join(`\0`),d=(0,b.useRef)({values:t,axisMax:n,hovered:a,layout:o}),f=(0,b.useRef)(new Map),p=(0,b.useRef)(new Map),m=(0,b.useRef)({startedAt:0,running:!1}),h=(0,b.useRef)({w:0,h:0}),g=(0,b.useRef)(()=>{});return(0,b.useEffect)(()=>{d.current={values:t,axisMax:n,hovered:a,layout:o},s?g.current():l.requestFrame()},[n,l,a,o,s,t]),(0,b.useEffect)(()=>{p.current=new Map(f.current),s?(m.current.running=!1,g.current()):(m.current={startedAt:performance.now(),running:!0},l.requestFrame())},[n,l,s,t]),(0,b.useEffect)(()=>{let t=e.current,n=t?.parentElement,r=t?.getContext(`2d`);if(!t||!n||!r)return;let a=getComputedStyle(t),o=(u?u.split(`\0`):[]).map(e=>O(a,e)),c=O(a,i),_=()=>{let e=n.clientWidth,i=n.clientHeight;if(!e||!i)return;let a=Math.min(N,window.devicePixelRatio||1);t.width=Math.round(e*a),t.height=Math.round(i*a),t.style.width=`${e}px`,t.style.height=`${i}px`,r.setTransform(a,0,0,a,0,0),h.current={w:e,h:i}},v=0,y=(e,t,n)=>{if(!m.current.running)return 1;let r=C((n-m.current.startedAt)/re);return r>=1&&(m.current.running=!1),ue(e,t,r)},b=(e,t,n,i,a,o,s,c,l,u,d)=>{let f=[l?te:P,l?te:P,u?ne:P,u?ne:P],p=()=>{r.beginPath(),r.roundRect(e,t,n,i,f)};r.save(),p(),r.clip(),r.globalAlpha=s,r.fillStyle=a;let m=c?.5:.36,h=Math.min(d,i)/2;r.beginPath();for(let a=e+d/2;a<e+n;a+=d)for(let e=t+h;e<t+i;e+=d){let n=w(1-(e-t)/i),o=E(a,e,v),s=d*(m+.34*n+.26*o)*(.8+.4*T(a,e));r.rect(a-s/2,e-s/2,s,s)}r.fill(),r.restore(),c&&(r.save(),p(),r.strokeStyle=o,r.lineWidth=1.75,r.shadowColor=o,r.shadowBlur=10,r.stroke(),r.restore())},x=e=>{v=e*oe;let{w:t,h:n}=h.current;if(!t||!n)return;let i=d.current;if(r.clearRect(0,0,t,n),!i.values.length||i.axisMax<=0){m.current.running=!1;return}let{barRatio:a,barMax:s,bandGap:l,minBand:u}=i.layout,g=i.values.length,_=t/g,x=Math.min(_*a,s),S=Math.max(3,Math.round(t/200)),C=n/i.axisMax,w=i.hovered;i.values.forEach((t,r)=>{let i=y(r,g,e),a=r*_+(_-x)/2,s=n;t.forEach((e,n)=>{let d=`${r}:${n}`,m=e>0?Math.max(u,e*C):0,h=p.current.get(d)??0,g=h+(m-h)*i;f.current.set(d,g);let _=w?.column===r&&w.band===n,v=w==null?1:w.column===r?w.band===null||_?1:ce:se;g>0&&b(a,s-g,x,g,o[n]??o[0]??c,c,v,_,n===t.length-1,n===0,S),s-=g+l})})};g.current=()=>{_(),x(performance.now())},l.setFrameHandler(e=>(x(e),m.current.running?`active`:d.current.hovered===null?`stop`:`idle`)),_();let S=new ResizeObserver(()=>{_(),s?x(performance.now()):l.requestFrame()});return S.observe(n),s&&x(performance.now()),()=>{l.setFrameHandler(null),S.disconnect()}},[e,u,l,i,s,c]),{hitTest:(t,n)=>{let r=e.current,{w:i,h:a}=h.current;if(!r||!i)return null;let o=r.getBoundingClientRect(),s=(t-o.left)/o.width*i,c=(n-o.top)/o.height*a,{values:l,layout:u}=d.current,p=l.length,m=i/p,g=Math.floor(s/m);if(g<0||g>=p)return null;let _=Math.min(m*u.barRatio,u.barMax),v=g*m+(m-_)/2;if(s<v||s>v+_)return{column:g,band:null};let y=a;for(let e=0;e<l[g].length;e++){let t=f.current.get(`${g}:${e}`)??0;if(t>0&&c<=y&&c>=y-t)return{column:g,band:e};y-=t+u.bandGap}return{column:g,band:null}}}}var fe=`(prefers-reduced-motion: reduce)`;function F(){let[e,t]=(0,b.useState)(()=>globalThis.matchMedia?.(fe).matches??!1);return(0,b.useEffect)(()=>{let e=globalThis.matchMedia?.(fe);if(!e)return;let n=()=>t(e.matches);return n(),e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var I=n();function pe(e,t,n){return e===`ArrowLeft`?Math.max(0,t-1):e===`ArrowRight`?Math.min(n,t+1):e===`Home`?0:e===`End`?n:null}function me({label:e,itemLabels:t,activeIndex:n,onActiveIndexChange:r,layout:i}){let a=(0,b.useRef)([]),[o,s]=(0,b.useState)(0),c=t.length-1,l=Math.min(o,Math.max(0,c)),u=(e,t)=>{if(e.key===`Escape`){e.preventDefault(),r(null);return}let n=pe(e.key,t,c);n!==null&&(e.preventDefault(),s(n),a.current[n]?.focus())};return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{role:`listbox`,"aria-label":e,"aria-orientation":`horizontal`,className:f(`pointer-events-none absolute inset-0 z-[1]`,i===`columns`?`flex`:null),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||r(null)},children:t.map((e,t)=>(0,I.jsx)(`div`,{ref:e=>{a.current[t]=e},role:`option`,"aria-label":e,"aria-selected":n===t,tabIndex:t===l?0:-1,className:f(`pointer-events-none focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-[var(--brand)]`,i===`columns`?`h-full min-w-0 flex-1 rounded-sm`:`absolute inset-0 rounded-full`),onFocus:()=>{s(t),r(t)},onKeyDown:e=>u(e,t)},t))}),(0,I.jsx)(`span`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`sr-only`,children:n===null?``:t[n]})]})}var he=[1,.75,.5,.25,0];function ge(e,t){return e===t||e!==null&&t!==null&&e.column===t.column&&e.band===t.band}function L({values:e,axisMax:t,colors:n,highlight:r=`var(--brand)`,hovered:i,onHover:a,layout:o,height:s,formatTick:c,ariaLabel:l,itemLabels:u,className:d}){let p=(0,b.useRef)(null),m=(0,b.useRef)(i),h=F(),{hitTest:g}=de(p,{values:e,axisMax:t,colors:n,highlight:r,hovered:i,layout:{...le,...o},reducedMotion:h});(0,b.useEffect)(()=>{m.current=i},[i]);let _=e=>{ge(m.current,e)||(m.current=e,a(e))};return(0,I.jsxs)(`div`,{className:f(`flex`,d),children:[c?(0,I.jsx)(`div`,{className:`relative shrink-0`,style:{height:s,width:38},"aria-hidden":!0,children:he.map(e=>(0,I.jsx)(`span`,{className:`console-mono absolute right-2 -translate-y-1/2 text-[9.5px] whitespace-nowrap text-[var(--console-muted)]`,style:{top:`${(1-e)*100}%`},children:c(t*e)},e))}):null,(0,I.jsxs)(`div`,{className:`chart-hatch relative min-w-0 flex-1 touch-none`,style:{height:s},onPointerMove:e=>_(g(e.clientX,e.clientY)),onPointerLeave:()=>_(null),children:[he.map(e=>(0,I.jsx)(`span`,{"aria-hidden":!0,className:f(`pointer-events-none absolute inset-x-0`,e===0?`h-px bg-[var(--console-border-strong)]`:`border-t border-dashed border-[var(--console-border)]`),style:{top:`${(1-e)*100}%`}},e)),(0,I.jsx)(`canvas`,{ref:p,"aria-hidden":!0,className:`absolute inset-0 block`}),(0,I.jsx)(me,{label:l,itemLabels:u,activeIndex:i?.column??null,onActiveIndexChange:e=>_(e===null?null:{column:e,band:null}),layout:`columns`})]})]})}var R=6,_e=118,ve={barRatio:.52,barMax:34,bandGap:0,minBand:4},ye=[`var(--brand)`];function be({perAgent:e}){let[t,n]=(0,b.useState)(null),{byCost:r,visible:i,values:a,axisMax:s,itemLabels:l}=(0,b.useMemo)(()=>{let t=e.some(e=>e.cost>0),n=e=>t?e.cost:e.sessions,r=[...e].sort((e,t)=>n(t)-n(e)).slice(0,R),i=r.map(e=>[n(e)]),a=r.map(e=>t?`${e.displayName}: ${o(e.cost)}, ${d(e.sessions)} sessions`:`${e.displayName}: ${d(e.sessions)} sessions`);return{byCost:t,visible:r,values:i,axisMax:Math.max(...i.flat(),0),itemLabels:a}},[e]);return(0,I.jsxs)(v,{role:`region`,"aria-label":`Agents`,className:`p-4`,children:[(0,I.jsx)(g,{title:`Agents`,meta:`${r?`by cost`:`by sessions`} · ${e.length} total`}),i.length===0?(0,I.jsx)(`p`,{className:`console-mono mt-3 text-[11px] text-[var(--console-muted)]`,children:`No data`}):(0,I.jsxs)(`div`,{className:`mt-[14px]`,children:[(0,I.jsx)(L,{values:a,axisMax:s,colors:ye,hovered:t,onHover:n,layout:ve,height:_e,ariaLabel:`Agent distribution chart`,itemLabels:l}),(0,I.jsx)(`div`,{className:`mt-2 grid`,style:{gridTemplateColumns:`repeat(${i.length}, minmax(0, 1fr))`},children:i.map((e,n)=>(0,I.jsxs)(`div`,{"data-testid":`overview-agent-row`,className:`flex min-w-0 flex-col items-center gap-[5px]`,children:[(0,I.jsx)(`span`,{className:`flex size-[18px] items-center justify-center rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)]`,children:(0,I.jsx)(c,{icon:e.icon,iconColored:e.iconColored,alt:e.displayName,className:`size-[10px]`})}),(0,I.jsx)(`span`,{className:f(`console-mono max-w-full truncate text-[9.5px]`,t?.column===n?`text-[var(--console-text)]`:`text-[var(--console-muted)]`),children:e.displayName}),(0,I.jsx)(`span`,{className:`console-mono text-[9.5px] text-[var(--console-text)]`,children:r?o(e.cost):d(e.sessions)}),r?(0,I.jsx)(`span`,{className:`console-mono text-[9.5px] text-[var(--console-muted)]`,children:d(e.sessions)}):null]},e.name))})]}),e.length>R?(0,I.jsxs)(`p`,{className:`console-mono mt-3 text-[10.5px] text-[var(--console-muted)]`,children:[`+ `,e.length-R,` more`]}):null]})}var z=200,B=100,V=100,H=86,U=55,xe=-Math.PI/2,Se=.07,Ce=6,W=4.6,we=2,Te=.0018,Ee=500,G=6,De=.72,Oe=.3,ke=(()=>{let e=[];for(let t=14;t<=186;t+=W)for(let n=14;n<=186;n+=W){let r=t-B,i=n-V,a=Math.hypot(r,i);a<50.4||a>90.6||e.push({x:t,y:n,angle:Math.atan2(i,r),fullness:.62+.38*w((a-U)/31),jitter:T(t,n)})}return e})();function Ae(e,{a0:t,a1:n}){let r=n-t,i=Math.min(Ce,31*.45,U*r*.45),a=i/H,o=i/U,s=(e,t)=>[B+Math.cos(t)*e,V+Math.sin(t)*e],[c,l]=s(H,t+a);e.beginPath(),e.moveTo(c,l),e.arc(B,V,H,t+a,n-a),e.arcTo(...s(H,n),...s(U,n),i),e.arcTo(...s(U,n),...s(U,n-o),i),e.arc(B,V,U,n-o,t+o,!0),e.arcTo(...s(U,t),...s(H,t),i),e.arcTo(...s(H,t),c,l,i),e.closePath()}function je(e){let t=xe;return e.map(e=>{let n=e*S,r={a0:t+Se/2,a1:t+n-Se/2};return t+=n,r})}function Me(e,{shares:t,colors:n,hovered:r,reducedMotion:i}){let a=(0,b.useContext)(_),o=M(e,i),s=n.join(`\0`),c=(0,b.useRef)(r),l=(0,b.useRef)({displayed:t.slice(),from:t.slice(),target:t.slice(),startedAt:0,running:!1}),u=(0,b.useRef)(je(t)),d=(0,b.useRef)(()=>{});return(0,b.useEffect)(()=>{let e=l.current;e.from=e.displayed.slice(),e.target=t.slice(),i?(e.displayed=t.slice(),e.running=!1,d.current()):(e.startedAt=performance.now(),e.running=!0,o.requestFrame())},[o,i,t]),(0,b.useEffect)(()=>{c.current=r,i?d.current():o.requestFrame()},[o,r,i]),(0,b.useEffect)(()=>{let t=e.current,n=t?.parentElement,r=t?.getContext(`2d`);if(!t||!n||!r)return;let a=getComputedStyle(t),f=(s?s.split(`\0`):[]).map(e=>O(a,e)),p=1,m=()=>{let e=n.clientWidth;if(!e)return;let r=Math.min(we,window.devicePixelRatio||1);t.width=Math.ceil(e*r),t.height=Math.ceil(e*r),t.style.width=`${e}px`,t.style.height=`${e}px`,p=e/z*r},h=0,g=e=>{let t=l.current;if(!t.running)return;let n=C((e-t.startedAt)/Ee),r=1-2**(-10*n);t.displayed=t.target.map((e,n)=>{let i=t.from[n]??0;return i+(e-i)*r}),n>=1&&(t.displayed=t.target.slice(),t.running=!1)},_=(e,t,n,i)=>{if(t.a1-t.a0<=.004)return;if(r.save(),n){let n=(t.a0+t.a1)/2;r.translate(Math.cos(n)*G,Math.sin(n)*G),r.shadowColor=k(e,.55),r.shadowBlur=5}Ae(r,t),r.clip(),r.globalAlpha=i?n?1:Oe*De:De,r.fillStyle=e;let a=n?.46:.34,o=t.a0-.06,s=t.a1+.06;r.beginPath();for(let e of ke){let t=e.angle;for(;t<o;)t+=S;for(;t>=o+S;)t-=S;if(t>s)continue;let n=E(e.x,e.y,h),i=W*(a+.36*e.fullness+.26*n)*(.78+.42*e.jitter);r.rect(e.x-i/2,e.y-i/2,i,i)}r.fill(),r.restore()},v=e=>{h=e*Te,r.setTransform(p,0,0,p,0,0),r.clearRect(0,0,z,z);let t=je(l.current.displayed);u.current=t;let n=c.current,i=n!==null;t.forEach((e,t)=>{t!==n&&_(f[t]??f[0]??``,e,!1,i)});let a=n===null?void 0:t[n];a&&_(f[n]??``,a,!0,!0)};d.current=()=>{m(),v(performance.now())},o.setFrameHandler(e=>(g(e),v(e),l.current.running?`active`:c.current===null?`stop`:`idle`)),m();let y=new ResizeObserver(()=>{m(),i?v(performance.now()):o.requestFrame()});return y.observe(n),i&&v(performance.now()),()=>{o.setFrameHandler(null),y.disconnect()}},[e,s,o,i,a]),{hitTest:(t,n)=>{let r=e.current;if(!r)return null;let i=r.getBoundingClientRect();if(!i.width)return null;let a=(t-i.left)/i.width*z-B,o=(n-i.top)/i.height*z-V,s=Math.hypot(a,o);if(s<U||s>H)return null;let c=Math.atan2(o,a);for(let e=0;e<u.current.length;e++){let{a0:t,a1:n}=u.current[e],r=c;for(;r<t;)r+=S;for(;r>=t+S;)r-=S;if(r<=n)return e}return null}}}function Ne({shares:e,colors:t,hovered:n,onHover:r,size:i,ariaLabel:a,itemLabels:o,children:s}){let c=(0,b.useRef)(null),{hitTest:l}=Me(c,{shares:e,colors:t,hovered:n,reducedMotion:F()});return(0,I.jsxs)(`div`,{className:`relative shrink-0 touch-none`,style:{width:i,height:i},onPointerMove:e=>r(l(e.clientX,e.clientY)),onPointerLeave:()=>r(null),children:[(0,I.jsx)(`canvas`,{ref:c,"aria-hidden":!0,className:`block size-full`}),(0,I.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex flex-col items-center justify-center`,children:s}),(0,I.jsx)(me,{label:a,itemLabels:o,activeIndex:n,onActiveIndexChange:r,layout:`surface`})]})}var Pe=5,Fe=142,Ie=.01;function Le(e){return e!==null&&e.some(e=>e.cost>0)}function Re(e,t){let n=[...e].sort((e,t)=>t.cost-e.cost).slice(0,Pe),r=n.map((e,t)=>({key:e.model,label:e.model,value:e.cost,color:`var(--chart-${t+1})`,display:i(e.cost)})),a=t-n.reduce((e,t)=>e+t.cost,0);return t>0&&a>t*Ie&&r.push({key:`__remainder`,label:`Other`,value:a,color:`var(--console-border-strong)`,display:i(a)}),r}function ze(e){return[...e].sort((e,t)=>t.tokens-e.tokens).slice(0,Pe).map((e,t)=>({key:e.model,label:e.model,value:e.tokens,color:`var(--chart-${t+1})`,display:s(e.tokens)}))}function Be({modelCost:e,modelDistribution:t,totals:n}){let[r,c]=(0,b.useState)(null),{byCost:l,entries:u}=(0,b.useMemo)(()=>{let r=Le(e);return{byCost:r,entries:r?Re(e,n.cost):ze(t)}},[e,t,n.cost]),d=u.reduce((e,t)=>e+t.value,0),p=(0,b.useMemo)(()=>u.map(e=>d>0?e.value/d:1/u.length),[u,d]),m=l?`Cost by Model`:`Models`,h=u.map(e=>`${e.label}: ${a(d>0?e.value/d:0)}, ${e.display}`);return(0,I.jsxs)(v,{role:`region`,"aria-label":m,className:`p-4`,children:[(0,I.jsx)(g,{title:m,meta:l?`by cost`:`by tokens`}),u.length===0?(0,I.jsx)(`p`,{className:`console-mono mt-3 text-[11px] text-[var(--console-muted)]`,children:`No model data`}):(0,I.jsxs)(`div`,{className:`mt-[14px] flex items-center gap-[18px]`,children:[(0,I.jsxs)(Ne,{shares:p,colors:u.map(e=>e.color),hovered:r,onHover:c,size:Fe,ariaLabel:`${m} chart`,itemLabels:h,children:[(0,I.jsx)(`span`,{className:`console-mono text-[16px] font-semibold text-[var(--console-text)]`,children:l?i(n.cost):s(n.tokens)}),(0,I.jsx)(`span`,{className:`console-mono mt-0.5 text-[9px] text-[var(--console-muted)]`,children:l?`total cost`:`total tokens`})]}),(0,I.jsx)(`ul`,{className:`flex min-w-0 flex-1 flex-col gap-[7px]`,children:u.map((e,t)=>(0,I.jsxs)(`li`,{className:f(`flex min-w-0 items-center gap-2 transition-opacity`,r!==null&&r!==t?`opacity-45`:null),onPointerEnter:()=>c(t),onPointerLeave:()=>c(null),children:[(0,I.jsx)(`span`,{className:`size-2 shrink-0 rounded-[2px]`,style:{background:e.color},"aria-hidden":!0}),(0,I.jsx)(`span`,{className:`console-mono min-w-0 flex-1 truncate text-[10.5px] text-[var(--console-text)]`,children:e.label}),(0,I.jsx)(`span`,{className:`console-mono w-[34px] shrink-0 text-right text-[10.5px] text-[var(--console-muted)]`,children:a(d>0?e.value/d:0)}),(0,I.jsx)(`span`,{className:`console-mono w-[54px] shrink-0 text-right text-[10.5px] text-[var(--console-text)]`,children:e.display})]},e.key))})]}),(0,I.jsx)(`p`,{className:`console-mono mt-3 border-t border-dashed border-[var(--console-border)] pt-3 text-[10.5px] text-[var(--console-muted)]`,children:l?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`mr-1.5 rounded-sm bg-[var(--brand-soft)] px-1.5 py-0.5 text-[var(--brand)]`,children:`Estimated`}),o(n.costEstimated),` from model unit price,`,` `,o(n.costRecorded),` from agent records`]}):`Per-model cost needs the message cache, which is unavailable here; showing token share instead.`})]})}var Ve=[{value:`7d`,label:`7d`},{value:`30d`,label:`30d`},{value:`90d`,label:`90d`},{value:`all`,label:`All`},{value:`custom`,label:`Custom`}],K=`__all__`;function He({agent:e,onAgentChange:t,agentCatalog:n,scopeCounts:r,window:i,rangePreset:a,onRangeChange:o,onSelectCustom:s}){let[c,l]=(0,b.useState)(!1);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[t?(0,I.jsxs)(`select`,{"aria-label":`Filter by agent`,value:e??K,onChange:e=>t(e.target.value===K?void 0:e.target.value),className:`console-mono max-w-[220px] rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-2 py-1.5 text-xs text-[var(--console-text)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,children:[(0,I.jsx)(`option`,{value:K,children:`All agents`}),n.active.map(e=>(0,I.jsx)(`option`,{value:e.name.toLowerCase(),children:e.displayName},e.name))]}):null,r?(0,I.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[r.projects,` projects · `,r.agents,` agents in scope`]}):null,(0,I.jsx)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:Ve.map(e=>{let t=e.value===a;return(0,I.jsx)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>{e.value===`custom`?l(!0):o(e.value)},className:f(`console-mono motion-hover rounded-full border px-[13px] py-[5px] text-[11px] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,t?`border-[var(--brand)] bg-[var(--brand)] text-[var(--brand-fg)]`:`border-[var(--console-border)] bg-[var(--console-surface)] text-[var(--console-muted)]`),children:e.label},e.value)})})]}),(0,I.jsx)(m,{open:c,onOpenChange:l,window:i,onSelectCustom:s})]})}function Ue(e){return e.toFixed(1)}var We={neutral:`text-[var(--console-muted)]`,warning:`text-[var(--brand)]`,positive:`text-[var(--positive)]`};function q({label:e,value:t,trend:n,trendTone:r=`neutral`,hint:i,emphasis:a=!1}){return(0,I.jsxs)(v,{className:f(`px-4 py-[14px]`,a?`border-[var(--brand-line)]`:null),children:[(0,I.jsx)(`p`,{className:`console-eyebrow`,children:e}),(0,I.jsx)(`p`,{className:f(`console-mono mt-[9px] text-[27px] font-semibold tracking-[-0.02em]`,a?`text-[var(--brand)]`:`text-[var(--console-text)]`),children:t}),(0,I.jsxs)(`div`,{className:`mt-[7px] flex items-center gap-[7px]`,children:[n===void 0?null:(0,I.jsx)(`span`,{"data-testid":`overview-kpi-trend`,className:f(`console-mono text-[10.5px]`,We[r]),children:n}),i===void 0?null:(0,I.jsx)(`span`,{className:`console-mono truncate text-[10.5px] text-[var(--console-muted)]`,children:i})]})]})}function Ge(e){return e.costEstimated===0?`All recorded by agents`:e.costEstimated===e.cost&&e.cost>0?`All estimated from unit price`:`${o(e.costEstimated)} estimated`}function Ke(e){let t=[e.latestActivityProject,e.latestActivityAgent].filter(e=>!!e);return t.length>0?t.join(` · `):void 0}function qe({totals:e,rangeDays:t}){let n=e.previous,r=(e,t)=>t===void 0?null:l(e,t),i=r(e.sessions,n?.sessions),c=r(e.messages,n?.messages),f=r(e.tokens,n?.tokens),p=r(e.cost,n?.cost),m=n?.cost!==void 0&&e.cost>n.cost;return(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-5`,children:[(0,I.jsx)(q,{label:`Sessions`,value:d(e.sessions),trend:i??void 0,hint:t?`${Ue(e.sessions/t)}/day`:void 0}),(0,I.jsx)(q,{label:`Messages`,value:d(e.messages),trend:c??void 0,hint:e.sessions>0?`${Ue(e.messages/e.sessions)}/session`:void 0}),(0,I.jsx)(q,{label:`Tokens`,value:s(e.tokens),trend:f??void 0,hint:`Cache hit ${a(e.cacheReadTokens/e.tokens)}`}),(0,I.jsx)(q,{label:`Cost`,value:o(e.cost),trend:p??void 0,trendTone:m?`warning`:`positive`,hint:Ge(e),emphasis:!0}),(0,I.jsx)(q,{label:`Last activity`,value:e.latestActivity===void 0?`No activity`:u(e.latestActivity),trend:e.latestActivity===void 0?void 0:`●`,trendTone:`positive`,hint:e.latestActivity===void 0?void 0:Ke(e)})]})}var Je=[0,1,2,3,4];function J({className:e}){return(0,I.jsx)(`span`,{className:`skeleton-shimmer block rounded-sm ${e}`})}function Y({bodyClassName:e}){return(0,I.jsxs)(v,{className:`p-4`,children:[(0,I.jsx)(J,{className:`h-[15px] w-28`}),(0,I.jsx)(J,{className:`mt-3 ${e}`})]})}function Ye(){return(0,I.jsxs)(`div`,{className:`space-y-4`,"aria-hidden":!0,"data-testid":`overview-skeleton`,children:[(0,I.jsx)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-5`,children:Je.map(e=>(0,I.jsxs)(v,{className:`px-4 py-[14px]`,children:[(0,I.jsx)(J,{className:`h-[10px] w-16`}),(0,I.jsx)(J,{className:`mt-[9px] h-[27px] w-24`}),(0,I.jsx)(J,{className:`mt-[7px] h-[11px] w-20`})]},e))}),(0,I.jsxs)(v,{className:`p-4`,children:[(0,I.jsx)(J,{className:`h-[15px] w-28`}),(0,I.jsx)(J,{className:`mt-[14px] h-[168px] w-full`})]}),(0,I.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[1.45fr_1fr]`,children:[(0,I.jsx)(Y,{bodyClassName:`h-[248px] w-full`}),(0,I.jsxs)(`div`,{className:`grid content-start gap-4`,children:[(0,I.jsx)(Y,{bodyClassName:`h-[116px] w-full`}),(0,I.jsx)(Y,{bodyClassName:`h-[100px] w-full`})]})]})]})}var Xe=.16;function Ze(e){return e*e*(3-2*e)}function Qe(e,t,n){return e<t?t:e>n?n:e}function X(e,t=new Float32Array(512)){let n=e.length;if(n===0)return t.fill(0),t;for(let r=0;r<512;r++){let i=Qe(r/511*n-.5,0,n-1),a=Math.min(n-2,Math.floor(i));if(a<0){t[r]=e[0];continue}let o=Ze(i-a);t[r]=e[a]*(1-o)+e[a+1]*o}return t}function $e(e,t){let n=Qe(t,0,1)*511,r=Math.min(510,Math.floor(n)),i=n-r;return e[r]*(1-i)+e[r+1]*i}function et(e,t){return 1-(t>0?Math.min(1,e/t):0)*.84}var tt=2,nt=460,rt=180,Z=32,it=.06,at=.24,ot=/oklch\(\s*([\d.]+)\s+([\d.]+)\s+([\d.]+)/;function st(e){let t=Math.imul(e^2654435769,2246822507);return t=Math.imul(t^t>>>13,3266489909),((t^t>>>16)>>>0)/4294967296}function ct(e,t){let n=ot.exec(e),r=ot.exec(t);if(!n||!r)return Array.from({length:33},()=>t);let[i,a,o]=[Number(n[1]),Number(n[2]),Number(n[3])],[s,c,l]=[Number(r[1]),Number(r[2]),Number(r[3])];return Array.from({length:33},(e,t)=>{let n=t/Z,r=i+(s-i)*n,u=a+(c-a)*n,d=o+(l-o)*n;return`oklch(${r.toFixed(3)} ${u.toFixed(3)} ${d.toFixed(1)})`})}function lt(e,{values:t,max:n,reducedMotion:r}){let i=(0,b.useContext)(_),a=M(e,r),o=(0,b.useRef)({from:X(t),to:X(t),current:X(t),fromMax:n,toMax:n,currentMax:n,startedAt:0,duration:0}),s=(0,b.useRef)(null),c=(0,b.useRef)(()=>{}),l=(0,b.useRef)({x:-1e4,y:-1e4,smoothX:-1e4,smoothY:-1e4,speed:0,inside:!1});(0,b.useEffect)(()=>{let e=o.current;e.from.set(e.current),e.fromMax=e.currentMax,X(t,e.to),e.toMax=n,e.startedAt=performance.now(),e.duration=r?0:nt,r?c.current():a.requestFrame()},[a,n,r,t]),(0,b.useEffect)(()=>{let t=e.current,n=t?.parentElement,i=t?.getContext(`2d`);if(!t||!n||!i)return;let u=l.current,d=getComputedStyle(t),f=d.getPropertyValue(`--tile-rest`).trim(),p=ct(d.getPropertyValue(`--tile-wash`).trim(),d.getPropertyValue(`--tile-ink`).trim()),m=()=>{let e=n.clientWidth,r=n.clientHeight;if(!e||!r)return;let a=n.getBoundingClientRect(),o=Math.min(tt,window.devicePixelRatio||1);t.width=Math.round(e*o),t.height=Math.round(r*o),t.style.width=`${e}px`,t.style.height=`${r}px`,i.setTransform(o,0,0,o,0,0),i.imageSmoothingEnabled=!1;let c=Math.max(3,Math.round(e/rt)),l=Math.ceil(e/c),u=Math.ceil(r/c),d=l*u,f=new Uint8Array(d);for(let e=0;e<d;e++)f[e]=+(st(e)<it);s.current={cell:c,cols:l,rows:u,width:e,height:r,left:a.left,top:a.top,step:1/o,glow:new Float32Array(d),spark:f}},h=e=>{let t=o.current,n=t.duration>0?Math.min(1,(e-t.startedAt)/t.duration):1;for(let e=0;e<512;e++)t.current[e]=t.from[e]+(t.to[e]-t.from[e])*n;return t.currentMax=t.fromMax+(t.toMax-t.fromMax)*n,n>=1&&(t.duration=0),n<1},g=e=>{let t=l.current,n=t.smoothX,r=t.smoothY,i=1-.72**e;t.smoothX+=(t.x-n)*i,t.smoothY+=(t.y-r)*i,t.speed=Math.hypot(t.smoothX-n,t.smoothY-r)},_=(e,t=1)=>{let n=s.current;if(!n)return!1;let a=o.current,{cell:c,cols:u,rows:d,width:m,height:h,step:g,glow:_,spark:v}=n,y=e=>Math.round(e/g)*g,b=Math.max(g,y(c*.34)),x=y((c-b)/2);i.clearRect(0,0,m,h),i.fillStyle=f;for(let e=0;e<u;e++){let t=e*c+x;for(let e=0;e<d;e++)i.fillRect(t,e*c+x,b,b)}let S=l.current,C=h*(at+Math.min(1,S.speed/25)*.26),w=!r&&S.inside,T=1-.78**t,E=1-.95**t,ee=e*.0018,D=-1,O=!1;for(let t=0;t<u;t++){let n=u>1?(t+.5)/u:.5,o=et($e(a.current,n),a.currentMax),s=Math.max(.001,1-o),l=t*c,m=l+c/2;for(let n=0;n<d;n++){let a=t*d+n,u=n*c,b=(u+c/2)/h,x=0;b>=o&&(x=1-.55*((b-o)/s));let k=_[a];if(w){let e=Math.hypot(m-S.smoothX,u+c/2-S.smoothY),t=e<C?1-e/C:0;k+=(t-k)*(t>k?T:E),_[a]=k}else k>0&&(k*=1-E,_[a]=k<.002?0:k);_[a]>0&&(O=!0);let A=Math.min(1,x+k*.5);if(A<=.02)continue;let j=A;r||(j*=1+.07*Math.sin(b*Math.PI*3-ee),v[a]&&k>.02&&(j*=1+.25*k*Math.sin(e*.012+a)),j=Math.min(1,j));let M=Math.max(g,y(c*(.28+.42*A))),N=y((c-M)/2),P=Math.round(j*Z);P!==D&&(D=P,i.fillStyle=p[D]??p[Z]??f),i.fillRect(l+N,u+N,M,M)}}return O},v=()=>{m(),h(performance.now()),_(performance.now())};c.current=v;let y=e=>{let t=s.current;if(!t)return;let r=l.current;if(!r.inside){let e=n.getBoundingClientRect();t.left=e.left,t.top=e.top}r.x=e.clientX-t.left,r.y=e.clientY-t.top,r.inside||(r.smoothX=r.x,r.smoothY=r.y),r.inside=!0,a.requestFrame()},b=()=>{l.current.inside=!1,a.requestFrame()},x=0;a.setFrameHandler(e=>{let t=x===0?1:Math.min(3,(e-x)/(1e3/60));x=e;let n=h(e);g(t);let r=_(e,t);return n?`active`:l.current.inside||r?`idle`:(x=0,`stop`)}),m();let S=new ResizeObserver(()=>{m(),r?(h(performance.now()),_(performance.now())):a.requestFrame()});return S.observe(n),r?v():(n.addEventListener(`pointermove`,y,{passive:!0}),n.addEventListener(`pointerleave`,b)),()=>{a.setFrameHandler(null),S.disconnect(),n.removeEventListener(`pointermove`,y),n.removeEventListener(`pointerleave`,b),u.inside=!1}},[e,a,r,i])}var ut=[1,.66,.33,0],dt=e=>`${(1-e*(1-Xe))*100}%`,ft=(e,t)=>(e+.5)/t*100;function pt({values:e,max:t,labels:n,formatValue:r}){let[i,a]=(0,b.useState)(null),o=(0,b.useRef)(null),s=F(),c=t=>{let n=o.current?.getBoundingClientRect();if(!n?.width)return;let r=(t-n.left)/n.width,i=Math.round(r*e.length-.5);a(Math.min(e.length-1,Math.max(0,i)))},l=i!==null,u=i??0,d=e[u]??0,p=s?void 0:`left 260ms ease-out, top 260ms ease-out`;return(0,I.jsxs)(`div`,{ref:o,className:`absolute inset-0 cursor-crosshair touch-none`,onPointerMove:e=>c(e.clientX),onPointerLeave:()=>a(null),children:[(0,I.jsx)(`span`,{className:f(`pointer-events-none absolute inset-y-0 w-px -translate-x-1/2 bg-[var(--brand-line)] transition-opacity duration-150`,l?`opacity-100`:`opacity-0`),style:{left:`${ft(u,e.length)}%`,transition:p}}),(0,I.jsxs)(`div`,{className:f(`pointer-events-none absolute size-0 transition-opacity duration-150`,l?`opacity-100`:`opacity-0`),style:{left:`${ft(u,e.length)}%`,top:`${et(d,t)*100}%`,transition:p},children:[(0,I.jsx)(`span`,{className:`absolute size-[9px] -translate-x-1/2 -translate-y-1/2 rounded-full bg-[var(--brand)] ring-2 ring-[var(--console-surface)]`}),(0,I.jsxs)(`span`,{className:`console-mono absolute bottom-3 flex -translate-x-1/2 items-baseline gap-1.5 rounded-md border border-[var(--console-border)] bg-[var(--console-surface)] px-2 py-1 whitespace-nowrap shadow-[var(--shadow-overlay)]`,children:[(0,I.jsx)(`span`,{className:`text-[10px] text-[var(--console-muted)]`,children:n[u]}),(0,I.jsx)(`span`,{className:`text-[12px] font-semibold text-[var(--console-text)]`,children:r(d)})]})]})]})}function mt({values:e,max:t,labels:n,height:r,formatValue:i,formatTick:a,className:o}){let s=(0,b.useRef)(null);return lt(s,{values:e,max:t,reducedMotion:F()}),(0,I.jsxs)(`div`,{className:f(`flex`,o),"aria-hidden":!0,children:[a?(0,I.jsx)(`div`,{className:`relative shrink-0`,style:{height:r,width:38},children:ut.map(e=>(0,I.jsx)(`span`,{className:`console-mono absolute right-2 -translate-y-1/2 text-[9.5px] whitespace-nowrap text-[var(--console-muted)]`,style:{top:dt(e)},children:a(t*e)},e))}):null,(0,I.jsxs)(`div`,{className:`chart-hatch relative min-w-0 flex-1`,style:{height:r},children:[ut.map(e=>(0,I.jsx)(`span`,{className:f(`pointer-events-none absolute inset-x-0`,e===0?`h-px bg-[var(--console-border-strong)]`:`border-t border-dashed border-[var(--console-border)]`),style:{top:dt(e)}},e)),(0,I.jsx)(`canvas`,{ref:s,className:`absolute inset-0 block`}),e.length>0?(0,I.jsx)(pt,{values:e,max:t,labels:n,formatValue:i}):null]})]})}var ht=168,gt=132,_t=6,vt={barRatio:.86,barMax:46,bandGap:2,minBand:3},Q=[{key:`input`,label:`Input`,color:`var(--token-input)`},{key:`output`,label:`Output`,color:`var(--token-output)`},{key:`cache_read`,label:`Cache read`,color:`var(--token-cache-read)`},{key:`cache_create`,label:`Cache write`,color:`var(--token-cache-write)`}],yt=Q.map(e=>e.color);function bt(e){return e>=1e3?`$${s(e)}`:`$${Math.round(e)}`}function $(e){return e.input+e.output+e.cache_read+e.cache_create}function xt(e){return`${p(e.date)}: ${s($(e))} tokens, ${o(e.cost)}, ${d(e.sessions)} sessions, ${d(e.messages)} messages, input ${s(e.input)}, output ${s(e.output)}, cache read ${s(e.cache_read)}, cache write ${s(e.cache_create)}`}function St({daily:e}){let t=(0,b.useMemo)(()=>e.map(e=>e.cost),[e]),n=(0,b.useMemo)(()=>e.map(e=>p(e.date)),[e]),r=t.reduce((e,t)=>e+t,0),i=t.reduce((e,t)=>Math.max(e,t),0);return i<=0?null:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`mt-[14px] flex items-baseline justify-between border-t border-dashed border-[var(--console-border)] pt-[11px]`,children:[(0,I.jsx)(`span`,{className:`console-mono text-[10.5px] text-[var(--console-text)]`,children:`Daily cost`}),(0,I.jsxs)(`span`,{className:`console-mono text-[10px] text-[var(--console-muted)]`,children:[`Peak `,o(i),` · Avg `,o(r/e.length),` · Total `,o(r)]})]}),(0,I.jsx)(mt,{values:t,max:i,labels:n,height:gt,formatValue:o,formatTick:bt,className:`mt-[7px]`})]})}function Ct({bucket:e,index:t,count:n}){return(0,I.jsxs)(`div`,{className:f(`console-mono pointer-events-none absolute top-2 z-10 rounded-md border border-[var(--console-border)] bg-[var(--console-surface)] px-2.5 py-2 text-[10.5px] whitespace-nowrap text-[var(--console-text)] shadow-[var(--shadow-overlay)]`,t>=n*.75?`-translate-x-full`:`-translate-x-1/2`),style:{left:`${(t+.5)/n*100}%`},children:[(0,I.jsx)(`div`,{children:p(e.date)}),(0,I.jsxs)(`div`,{children:[s($(e)),` tok ·`,` `,(0,I.jsx)(`span`,{className:`text-[var(--brand)]`,children:o(e.cost)})]}),(0,I.jsxs)(`div`,{children:[d(e.sessions),` sessions · `,d(e.messages),` messages`]}),(0,I.jsxs)(`div`,{className:`text-[var(--console-muted)]`,children:[`In `,s(e.input),` · Out `,s(e.output),` · Read`,` `,s(e.cache_read),` · Write `,s(e.cache_create)]})]})}function wt({daily:e}){let[t,n]=(0,b.useState)(null),r=(0,b.useMemo)(()=>e.map(e=>Q.map(t=>e[t.key])),[e]),i=(0,b.useMemo)(()=>e.map(xt),[e]),a=(0,b.useMemo)(()=>ee(e.reduce((e,t)=>Math.max(e,$(t)),0)),[e]),o=t===null?void 0:e[t.column];return(0,I.jsxs)(`div`,{className:`relative mt-[14px]`,children:[(0,I.jsx)(L,{values:r,axisMax:a,colors:yt,hovered:t,onHover:n,layout:vt,height:ht,formatTick:s,ariaLabel:`Daily usage chart`,itemLabels:i}),o&&t?(0,I.jsx)(`div`,{className:`absolute inset-x-0 top-0`,style:{left:38},children:(0,I.jsx)(Ct,{bucket:o,index:t.column,count:e.length})}):null]})}function Tt({daily:e}){let t=e[0],n=e[e.length-1],r=t&&n?` · ${p(t.date)} → ${p(n.date)}`:``,i=Math.max(1,Math.ceil(e.length/_t));return(0,I.jsxs)(v,{role:`region`,"aria-label":`Daily usage`,className:`p-4`,children:[(0,I.jsx)(g,{title:`Daily usage`,action:(0,I.jsx)(`div`,{className:`console-mono flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] text-[var(--console-muted)]`,children:Q.map(e=>(0,I.jsxs)(`span`,{"data-testid":`overview-legend-token`,className:`flex items-center gap-1`,children:[(0,I.jsx)(`span`,{className:`size-2 rounded-[2px]`,style:{background:e.color},"aria-hidden":!0}),e.label]},e.key))})}),(0,I.jsxs)(`p`,{className:`console-mono mt-1 text-[10.5px] text-[var(--console-muted)]`,children:[`Stacked bars = token mix · Area below = daily cost`,r]}),e.length===0?(0,I.jsx)(`p`,{className:`console-mono mt-[14px] text-[11px] text-[var(--console-muted)]`,children:`No usage data`}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(wt,{daily:e}),(0,I.jsx)(St,{daily:e}),(0,I.jsx)(`div`,{style:{paddingLeft:38},children:(0,I.jsx)(`div`,{className:`console-mono mt-2 flex text-[10px] text-[var(--console-muted)]`,children:e.map((t,n)=>(0,I.jsx)(`span`,{className:`flex-1 text-center`,children:n%i===0||n===e.length-1?p(t.date):``},t.date))})})]}),(0,I.jsxs)(`table`,{className:`sr-only`,"aria-label":`Daily usage data`,children:[(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{children:`Date`}),(0,I.jsx)(`th`,{children:`Sessions`}),(0,I.jsx)(`th`,{children:`Messages`}),(0,I.jsx)(`th`,{children:`Tokens`}),(0,I.jsx)(`th`,{children:`Cost`})]})}),(0,I.jsx)(`tbody`,{children:e.map(e=>(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{children:p(e.date)}),(0,I.jsx)(`td`,{children:d(e.sessions)}),(0,I.jsx)(`td`,{children:d(e.messages)}),(0,I.jsx)(`td`,{children:d($(e))}),(0,I.jsx)(`td`,{children:o(e.cost)})]},e.date))})]})]})}function Et({project:e,agent:t,onAgentChange:n,window:r,agentCatalog:i,rangePreset:a,onRangeChange:o,onSelectCustom:s}){let[c,l]=(0,b.useState)(void 0),u=n?t:c,{dashboard:d,error:f}=x(r,{project:e,agent:u});return(0,I.jsxs)(`div`,{"data-testid":`dashboard`,className:`mx-auto max-w-6xl space-y-4`,children:[(0,I.jsx)(He,{agent:u,onAgentChange:n?void 0:l,agentCatalog:i,scopeCounts:d?.scopeCounts,window:r,rangePreset:a,onRangeChange:o,onSelectCustom:s}),f?(0,I.jsx)(`p`,{role:`alert`,className:`rounded-lg border border-[var(--console-error-border)] bg-[var(--console-error-bg)] p-4 text-sm text-[var(--console-error)]`,children:f}):d?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(qe,{totals:d.totals,rangeDays:d.window.days}),(0,I.jsx)(Tt,{daily:d.dailyActivity}),(0,I.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,I.jsx)(be,{perAgent:d.perAgent}),(0,I.jsx)(Be,{modelCost:d.modelCost,modelDistribution:d.modelDistribution,totals:d.totals})]})]}):(0,I.jsx)(Ye,{})]})}export{Et as OverviewScreen};
|
|
1
|
+
import{a as e,n as t,t as n}from"./jsx-runtime-B-hcVAMW.js";import{Kn as r,_ as i,f as a,g as o,i as s,n as c,o as l,p as u,s as d,t as f,u as p}from"./utils-BKqufGdv.js";import{a as m,l as h,n as g,r as _,t as v,u as y}from"./panel-CLnL4kMN.js";var b=e(t(),1);function x(e,t){let n=e!==null,i=y({queryKey:h.dashboard(e??{},t),enabled:n,queryFn:async({signal:n})=>{if(!e)throw Error(`Dashboard window is required`);try{return await r(e,t,{signal:n})}catch(e){throw n.aborted||console.error(`Failed to load dashboard:`,e),e}}});return{dashboard:n?i.data??null:null,loading:n&&i.isPending,error:n&&i.isError?`Failed to load dashboard`:null}}var S=Math.PI*2;function C(e){return e<0?0:e>1?1:e}function w(e){let t=C(e);return t*t*(3-2*t)}function T(e,t){let n=Math.imul(Math.round(e*16)^2654435769,2246822507);return n=Math.imul(n^n>>>13^Math.round(t*16),3266489909),((n^n>>>16)>>>0)/4294967296}function E(e,t,n){return w((Math.sin(e*.09+n)+Math.sin(t*.075-n*.83)+Math.sin((e+t)*.045+n*1.31)+2)/4)}function ee(e){if(e<=0)return 1;let t=10**Math.floor(Math.log10(e)),n=e/t;return(n<=1?1:n<=2?2:n<=5?5:10)*t}var D=/^var\((--[\w-]+)\)$/;function O(e,t){let n=D.exec(t)?.[1];return n&&e.getPropertyValue(n).trim()||t}function k(e,t){let n=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e)?.[1];if(!n)return e;let r=n.length===3?n.replace(/./g,e=>e+e):n,i=parseInt(r,16);return`rgba(${i>>16&255}, ${i>>8&255}, ${i&255}, ${t})`}var A=50;function j(){let e=!1,t=null,n=0,r=0,i=()=>{n&&cancelAnimationFrame(n),r&&window.clearTimeout(r),n=0,r=0},a=()=>{!e||t===null||n||(r&&=(window.clearTimeout(r),0),n=requestAnimationFrame(s))},o=()=>{!e||t===null||r||n||(r=window.setTimeout(()=>{r=0,a()},A))};function s(r){if(n=0,!e||t===null)return;let i=t(r);i===`active`?a():i===`idle`&&o()}return{api:{requestFrame:a,setFrameHandler:e=>{t=e,e===null?i():a()}},setEnabled:t=>{e!==t&&(e=t,e?a():i())}}}function M(e,t){let n=(0,b.useRef)(null);n.current===null&&(n.current=j());let r=n.current;return(0,b.useEffect)(()=>{let n=e.current;if(!n||t){r.setEnabled(!1);return}let i=!0,a=document.visibilityState===`visible`,o=()=>r.setEnabled(i&&a),s=()=>{a=document.visibilityState===`visible`,o()},c=typeof IntersectionObserver>`u`?null:new IntersectionObserver(([e])=>{i=e?.isIntersecting??!1,o()});return c?.observe(n),document.addEventListener(`visibilitychange`,s),o(),()=>{r.setEnabled(!1),c?.disconnect(),document.removeEventListener(`visibilitychange`,s)}},[r,t,e]),r.api}var N=2,P=5,te=8,ne=7,re=620,ie=.05,ae=.8,oe=.0018,se=.3,ce=.48,le={barRatio:.62,barMax:76,bandGap:4,minBand:6};function ue(e,t,n){let r=Math.max(1,t-1),i=Math.min(ie,ae/r),a=1-(t-1)*i;return 1-(1-C((n-e*i)/a))**3}function de(e,{values:t,axisMax:n,colors:r,highlight:i,hovered:a,layout:o,reducedMotion:s}){let c=(0,b.useContext)(_),l=M(e,s),u=r.join(`\0`),d=(0,b.useRef)({values:t,axisMax:n,hovered:a,layout:o}),f=(0,b.useRef)(new Map),p=(0,b.useRef)(new Map),m=(0,b.useRef)({startedAt:0,running:!1}),h=(0,b.useRef)({w:0,h:0}),g=(0,b.useRef)(()=>{});return(0,b.useEffect)(()=>{d.current={values:t,axisMax:n,hovered:a,layout:o},s?g.current():l.requestFrame()},[n,l,a,o,s,t]),(0,b.useEffect)(()=>{p.current=new Map(f.current),s?(m.current.running=!1,g.current()):(m.current={startedAt:performance.now(),running:!0},l.requestFrame())},[n,l,s,t]),(0,b.useEffect)(()=>{let t=e.current,n=t?.parentElement,r=t?.getContext(`2d`);if(!t||!n||!r)return;let a=getComputedStyle(t),o=(u?u.split(`\0`):[]).map(e=>O(a,e)),c=O(a,i),_=()=>{let e=n.clientWidth,i=n.clientHeight;if(!e||!i)return;let a=Math.min(N,window.devicePixelRatio||1);t.width=Math.round(e*a),t.height=Math.round(i*a),t.style.width=`${e}px`,t.style.height=`${i}px`,r.setTransform(a,0,0,a,0,0),h.current={w:e,h:i}},v=0,y=(e,t,n)=>{if(!m.current.running)return 1;let r=C((n-m.current.startedAt)/re);return r>=1&&(m.current.running=!1),ue(e,t,r)},b=(e,t,n,i,a,o,s,c,l,u,d)=>{let f=[l?te:P,l?te:P,u?ne:P,u?ne:P],p=()=>{r.beginPath(),r.roundRect(e,t,n,i,f)};r.save(),p(),r.clip(),r.globalAlpha=s,r.fillStyle=a;let m=c?.5:.36,h=Math.min(d,i)/2;r.beginPath();for(let a=e+d/2;a<e+n;a+=d)for(let e=t+h;e<t+i;e+=d){let n=w(1-(e-t)/i),o=E(a,e,v),s=d*(m+.34*n+.26*o)*(.8+.4*T(a,e));r.rect(a-s/2,e-s/2,s,s)}r.fill(),r.restore(),c&&(r.save(),p(),r.strokeStyle=o,r.lineWidth=1.75,r.shadowColor=o,r.shadowBlur=10,r.stroke(),r.restore())},x=e=>{v=e*oe;let{w:t,h:n}=h.current;if(!t||!n)return;let i=d.current;if(r.clearRect(0,0,t,n),!i.values.length||i.axisMax<=0){m.current.running=!1;return}let{barRatio:a,barMax:s,bandGap:l,minBand:u}=i.layout,g=i.values.length,_=t/g,x=Math.min(_*a,s),S=Math.max(3,Math.round(t/200)),C=n/i.axisMax,w=i.hovered;i.values.forEach((t,r)=>{let i=y(r,g,e),a=r*_+(_-x)/2,s=n;t.forEach((e,n)=>{let d=`${r}:${n}`,m=e>0?Math.max(u,e*C):0,h=p.current.get(d)??0,g=h+(m-h)*i;f.current.set(d,g);let _=w?.column===r&&w.band===n,v=w==null?1:w.column===r?w.band===null||_?1:ce:se;g>0&&b(a,s-g,x,g,o[n]??o[0]??c,c,v,_,n===t.length-1,n===0,S),s-=g+l})})};g.current=()=>{_(),x(performance.now())},l.setFrameHandler(e=>(x(e),m.current.running?`active`:d.current.hovered===null?`stop`:`idle`)),_();let S=new ResizeObserver(()=>{_(),s?x(performance.now()):l.requestFrame()});return S.observe(n),s&&x(performance.now()),()=>{l.setFrameHandler(null),S.disconnect()}},[e,u,l,i,s,c]),{hitTest:(t,n)=>{let r=e.current,{w:i,h:a}=h.current;if(!r||!i)return null;let o=r.getBoundingClientRect(),s=(t-o.left)/o.width*i,c=(n-o.top)/o.height*a,{values:l,layout:u}=d.current,p=l.length,m=i/p,g=Math.floor(s/m);if(g<0||g>=p)return null;let _=Math.min(m*u.barRatio,u.barMax),v=g*m+(m-_)/2;if(s<v||s>v+_)return{column:g,band:null};let y=a;for(let e=0;e<l[g].length;e++){let t=f.current.get(`${g}:${e}`)??0;if(t>0&&c<=y&&c>=y-t)return{column:g,band:e};y-=t+u.bandGap}return{column:g,band:null}}}}var fe=`(prefers-reduced-motion: reduce)`;function F(){let[e,t]=(0,b.useState)(()=>globalThis.matchMedia?.(fe).matches??!1);return(0,b.useEffect)(()=>{let e=globalThis.matchMedia?.(fe);if(!e)return;let n=()=>t(e.matches);return n(),e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var I=n();function pe(e,t,n){return e===`ArrowLeft`?Math.max(0,t-1):e===`ArrowRight`?Math.min(n,t+1):e===`Home`?0:e===`End`?n:null}function me({label:e,itemLabels:t,activeIndex:n,onActiveIndexChange:r,layout:i}){let a=(0,b.useRef)([]),[o,s]=(0,b.useState)(0),c=t.length-1,l=Math.min(o,Math.max(0,c)),u=(e,t)=>{if(e.key===`Escape`){e.preventDefault(),r(null);return}let n=pe(e.key,t,c);n!==null&&(e.preventDefault(),s(n),a.current[n]?.focus())};return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{role:`listbox`,"aria-label":e,"aria-orientation":`horizontal`,className:f(`pointer-events-none absolute inset-0 z-[1]`,i===`columns`?`flex`:null),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||r(null)},children:t.map((e,t)=>(0,I.jsx)(`div`,{ref:e=>{a.current[t]=e},role:`option`,"aria-label":e,"aria-selected":n===t,tabIndex:t===l?0:-1,className:f(`pointer-events-none focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-[var(--brand)]`,i===`columns`?`h-full min-w-0 flex-1 rounded-sm`:`absolute inset-0 rounded-full`),onFocus:()=>{s(t),r(t)},onKeyDown:e=>u(e,t)},t))}),(0,I.jsx)(`span`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`sr-only`,children:n===null?``:t[n]})]})}var he=[1,.75,.5,.25,0];function ge(e,t){return e===t||e!==null&&t!==null&&e.column===t.column&&e.band===t.band}function L({values:e,axisMax:t,colors:n,highlight:r=`var(--brand)`,hovered:i,onHover:a,layout:o,height:s,formatTick:c,ariaLabel:l,itemLabels:u,className:d}){let p=(0,b.useRef)(null),m=(0,b.useRef)(i),h=F(),{hitTest:g}=de(p,{values:e,axisMax:t,colors:n,highlight:r,hovered:i,layout:{...le,...o},reducedMotion:h});(0,b.useEffect)(()=>{m.current=i},[i]);let _=e=>{ge(m.current,e)||(m.current=e,a(e))};return(0,I.jsxs)(`div`,{className:f(`flex`,d),children:[c?(0,I.jsx)(`div`,{className:`relative shrink-0`,style:{height:s,width:38},"aria-hidden":!0,children:he.map(e=>(0,I.jsx)(`span`,{className:`console-mono absolute right-2 -translate-y-1/2 text-[9.5px] whitespace-nowrap text-[var(--console-muted)]`,style:{top:`${(1-e)*100}%`},children:c(t*e)},e))}):null,(0,I.jsxs)(`div`,{className:`chart-hatch relative min-w-0 flex-1 touch-none`,style:{height:s},onPointerMove:e=>_(g(e.clientX,e.clientY)),onPointerLeave:()=>_(null),children:[he.map(e=>(0,I.jsx)(`span`,{"aria-hidden":!0,className:f(`pointer-events-none absolute inset-x-0`,e===0?`h-px bg-[var(--console-border-strong)]`:`border-t border-dashed border-[var(--console-border)]`),style:{top:`${(1-e)*100}%`}},e)),(0,I.jsx)(`canvas`,{ref:p,"aria-hidden":!0,className:`absolute inset-0 block`}),(0,I.jsx)(me,{label:l,itemLabels:u,activeIndex:i?.column??null,onActiveIndexChange:e=>_(e===null?null:{column:e,band:null}),layout:`columns`})]})]})}var R=6,_e=118,ve={barRatio:.52,barMax:34,bandGap:0,minBand:4},ye=[`var(--brand)`];function be({perAgent:e}){let[t,n]=(0,b.useState)(null),{byCost:r,visible:i,values:a,axisMax:s,itemLabels:l}=(0,b.useMemo)(()=>{let t=e.some(e=>e.cost>0),n=e=>t?e.cost:e.sessions,r=[...e].sort((e,t)=>n(t)-n(e)).slice(0,R),i=r.map(e=>[n(e)]),a=r.map(e=>t?`${e.displayName}: ${o(e.cost)}, ${d(e.sessions)} sessions`:`${e.displayName}: ${d(e.sessions)} sessions`);return{byCost:t,visible:r,values:i,axisMax:Math.max(...i.flat(),0),itemLabels:a}},[e]);return(0,I.jsxs)(v,{role:`region`,"aria-label":`Agents`,className:`p-4`,children:[(0,I.jsx)(g,{title:`Agents`,meta:`${r?`by cost`:`by sessions`} · ${e.length} total`}),i.length===0?(0,I.jsx)(`p`,{className:`console-mono mt-3 text-[11px] text-[var(--console-muted)]`,children:`No data`}):(0,I.jsxs)(`div`,{className:`mt-[14px]`,children:[(0,I.jsx)(L,{values:a,axisMax:s,colors:ye,hovered:t,onHover:n,layout:ve,height:_e,ariaLabel:`Agent distribution chart`,itemLabels:l}),(0,I.jsx)(`div`,{className:`mt-2 grid`,style:{gridTemplateColumns:`repeat(${i.length}, minmax(0, 1fr))`},children:i.map((e,n)=>(0,I.jsxs)(`div`,{"data-testid":`overview-agent-row`,className:`flex min-w-0 flex-col items-center gap-[5px]`,children:[(0,I.jsx)(`span`,{className:`flex size-[18px] items-center justify-center rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)]`,children:(0,I.jsx)(c,{icon:e.icon,iconColored:e.iconColored,alt:e.displayName,className:`size-[10px]`})}),(0,I.jsx)(`span`,{className:f(`console-mono max-w-full truncate text-[9.5px]`,t?.column===n?`text-[var(--console-text)]`:`text-[var(--console-muted)]`),children:e.displayName}),(0,I.jsx)(`span`,{className:`console-mono text-[9.5px] text-[var(--console-text)]`,children:r?o(e.cost):d(e.sessions)}),r?(0,I.jsx)(`span`,{className:`console-mono text-[9.5px] text-[var(--console-muted)]`,children:d(e.sessions)}):null]},e.name))})]}),e.length>R?(0,I.jsxs)(`p`,{className:`console-mono mt-3 text-[10.5px] text-[var(--console-muted)]`,children:[`+ `,e.length-R,` more`]}):null]})}var z=200,B=100,V=100,H=86,U=55,xe=-Math.PI/2,Se=.07,Ce=6,W=4.6,we=2,Te=.0018,Ee=500,G=6,De=.72,Oe=.3,ke=(()=>{let e=[];for(let t=14;t<=186;t+=W)for(let n=14;n<=186;n+=W){let r=t-B,i=n-V,a=Math.hypot(r,i);a<50.4||a>90.6||e.push({x:t,y:n,angle:Math.atan2(i,r),fullness:.62+.38*w((a-U)/31),jitter:T(t,n)})}return e})();function Ae(e,{a0:t,a1:n}){let r=n-t,i=Math.min(Ce,31*.45,U*r*.45),a=i/H,o=i/U,s=(e,t)=>[B+Math.cos(t)*e,V+Math.sin(t)*e],[c,l]=s(H,t+a);e.beginPath(),e.moveTo(c,l),e.arc(B,V,H,t+a,n-a),e.arcTo(...s(H,n),...s(U,n),i),e.arcTo(...s(U,n),...s(U,n-o),i),e.arc(B,V,U,n-o,t+o,!0),e.arcTo(...s(U,t),...s(H,t),i),e.arcTo(...s(H,t),c,l,i),e.closePath()}function je(e){let t=xe;return e.map(e=>{let n=e*S,r={a0:t+Se/2,a1:t+n-Se/2};return t+=n,r})}function Me(e,{shares:t,colors:n,hovered:r,reducedMotion:i}){let a=(0,b.useContext)(_),o=M(e,i),s=n.join(`\0`),c=(0,b.useRef)(r),l=(0,b.useRef)({displayed:t.slice(),from:t.slice(),target:t.slice(),startedAt:0,running:!1}),u=(0,b.useRef)(je(t)),d=(0,b.useRef)(()=>{});return(0,b.useEffect)(()=>{let e=l.current;e.from=e.displayed.slice(),e.target=t.slice(),i?(e.displayed=t.slice(),e.running=!1,d.current()):(e.startedAt=performance.now(),e.running=!0,o.requestFrame())},[o,i,t]),(0,b.useEffect)(()=>{c.current=r,i?d.current():o.requestFrame()},[o,r,i]),(0,b.useEffect)(()=>{let t=e.current,n=t?.parentElement,r=t?.getContext(`2d`);if(!t||!n||!r)return;let a=getComputedStyle(t),f=(s?s.split(`\0`):[]).map(e=>O(a,e)),p=1,m=()=>{let e=n.clientWidth;if(!e)return;let r=Math.min(we,window.devicePixelRatio||1);t.width=Math.ceil(e*r),t.height=Math.ceil(e*r),t.style.width=`${e}px`,t.style.height=`${e}px`,p=e/z*r},h=0,g=e=>{let t=l.current;if(!t.running)return;let n=C((e-t.startedAt)/Ee),r=1-2**(-10*n);t.displayed=t.target.map((e,n)=>{let i=t.from[n]??0;return i+(e-i)*r}),n>=1&&(t.displayed=t.target.slice(),t.running=!1)},_=(e,t,n,i)=>{if(t.a1-t.a0<=.004)return;if(r.save(),n){let n=(t.a0+t.a1)/2;r.translate(Math.cos(n)*G,Math.sin(n)*G),r.shadowColor=k(e,.55),r.shadowBlur=5}Ae(r,t),r.clip(),r.globalAlpha=i?n?1:Oe*De:De,r.fillStyle=e;let a=n?.46:.34,o=t.a0-.06,s=t.a1+.06;r.beginPath();for(let e of ke){let t=e.angle;for(;t<o;)t+=S;for(;t>=o+S;)t-=S;if(t>s)continue;let n=E(e.x,e.y,h),i=W*(a+.36*e.fullness+.26*n)*(.78+.42*e.jitter);r.rect(e.x-i/2,e.y-i/2,i,i)}r.fill(),r.restore()},v=e=>{h=e*Te,r.setTransform(p,0,0,p,0,0),r.clearRect(0,0,z,z);let t=je(l.current.displayed);u.current=t;let n=c.current,i=n!==null;t.forEach((e,t)=>{t!==n&&_(f[t]??f[0]??``,e,!1,i)});let a=n===null?void 0:t[n];a&&_(f[n]??``,a,!0,!0)};d.current=()=>{m(),v(performance.now())},o.setFrameHandler(e=>(g(e),v(e),l.current.running?`active`:c.current===null?`stop`:`idle`)),m();let y=new ResizeObserver(()=>{m(),i?v(performance.now()):o.requestFrame()});return y.observe(n),i&&v(performance.now()),()=>{o.setFrameHandler(null),y.disconnect()}},[e,s,o,i,a]),{hitTest:(t,n)=>{let r=e.current;if(!r)return null;let i=r.getBoundingClientRect();if(!i.width)return null;let a=(t-i.left)/i.width*z-B,o=(n-i.top)/i.height*z-V,s=Math.hypot(a,o);if(s<U||s>H)return null;let c=Math.atan2(o,a);for(let e=0;e<u.current.length;e++){let{a0:t,a1:n}=u.current[e],r=c;for(;r<t;)r+=S;for(;r>=t+S;)r-=S;if(r<=n)return e}return null}}}function Ne({shares:e,colors:t,hovered:n,onHover:r,size:i,ariaLabel:a,itemLabels:o,children:s}){let c=(0,b.useRef)(null),{hitTest:l}=Me(c,{shares:e,colors:t,hovered:n,reducedMotion:F()});return(0,I.jsxs)(`div`,{className:`relative shrink-0 touch-none`,style:{width:i,height:i},onPointerMove:e=>r(l(e.clientX,e.clientY)),onPointerLeave:()=>r(null),children:[(0,I.jsx)(`canvas`,{ref:c,"aria-hidden":!0,className:`block size-full`}),(0,I.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex flex-col items-center justify-center`,children:s}),(0,I.jsx)(me,{label:a,itemLabels:o,activeIndex:n,onActiveIndexChange:r,layout:`surface`})]})}var Pe=5,Fe=142,Ie=.01;function Le(e){return e!==null&&e.some(e=>e.cost>0)}function Re(e,t){let n=[...e].sort((e,t)=>t.cost-e.cost).slice(0,Pe),r=n.map((e,t)=>({key:e.model,label:e.model,value:e.cost,color:`var(--chart-${t+1})`,display:i(e.cost)})),a=t-n.reduce((e,t)=>e+t.cost,0);return t>0&&a>t*Ie&&r.push({key:`__remainder`,label:`Other`,value:a,color:`var(--console-border-strong)`,display:i(a)}),r}function ze(e){return[...e].sort((e,t)=>t.tokens-e.tokens).slice(0,Pe).map((e,t)=>({key:e.model,label:e.model,value:e.tokens,color:`var(--chart-${t+1})`,display:s(e.tokens)}))}function Be({modelCost:e,modelDistribution:t,totals:n}){let[r,c]=(0,b.useState)(null),{byCost:l,entries:u}=(0,b.useMemo)(()=>{let r=Le(e);return{byCost:r,entries:r?Re(e,n.cost):ze(t)}},[e,t,n.cost]),d=u.reduce((e,t)=>e+t.value,0),p=(0,b.useMemo)(()=>u.map(e=>d>0?e.value/d:1/u.length),[u,d]),m=l?`Cost by Model`:`Models`,h=u.map(e=>`${e.label}: ${a(d>0?e.value/d:0)}, ${e.display}`);return(0,I.jsxs)(v,{role:`region`,"aria-label":m,className:`p-4`,children:[(0,I.jsx)(g,{title:m,meta:l?`by cost`:`by tokens`}),u.length===0?(0,I.jsx)(`p`,{className:`console-mono mt-3 text-[11px] text-[var(--console-muted)]`,children:`No model data`}):(0,I.jsxs)(`div`,{className:`mt-[14px] flex items-center gap-[18px]`,children:[(0,I.jsxs)(Ne,{shares:p,colors:u.map(e=>e.color),hovered:r,onHover:c,size:Fe,ariaLabel:`${m} chart`,itemLabels:h,children:[(0,I.jsx)(`span`,{className:`console-mono text-[16px] font-semibold text-[var(--console-text)]`,children:l?i(n.cost):s(n.tokens)}),(0,I.jsx)(`span`,{className:`console-mono mt-0.5 text-[9px] text-[var(--console-muted)]`,children:l?`total cost`:`total tokens`})]}),(0,I.jsx)(`ul`,{className:`flex min-w-0 flex-1 flex-col gap-[7px]`,children:u.map((e,t)=>(0,I.jsxs)(`li`,{className:f(`flex min-w-0 items-center gap-2 transition-opacity`,r!==null&&r!==t?`opacity-45`:null),onPointerEnter:()=>c(t),onPointerLeave:()=>c(null),children:[(0,I.jsx)(`span`,{className:`size-2 shrink-0 rounded-[2px]`,style:{background:e.color},"aria-hidden":!0}),(0,I.jsx)(`span`,{className:`console-mono min-w-0 flex-1 truncate text-[10.5px] text-[var(--console-text)]`,children:e.label}),(0,I.jsx)(`span`,{className:`console-mono w-[34px] shrink-0 text-right text-[10.5px] text-[var(--console-muted)]`,children:a(d>0?e.value/d:0)}),(0,I.jsx)(`span`,{className:`console-mono w-[54px] shrink-0 text-right text-[10.5px] text-[var(--console-text)]`,children:e.display})]},e.key))})]}),(0,I.jsx)(`p`,{className:`console-mono mt-3 border-t border-dashed border-[var(--console-border)] pt-3 text-[10.5px] text-[var(--console-muted)]`,children:l?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`mr-1.5 rounded-sm bg-[var(--brand-soft)] px-1.5 py-0.5 text-[var(--brand)]`,children:`Estimated`}),o(n.costEstimated),` from model unit price,`,` `,o(n.costRecorded),` from agent records`]}):`Per-model cost needs the message cache, which is unavailable here; showing token share instead.`})]})}var Ve=[{value:`7d`,label:`7d`},{value:`30d`,label:`30d`},{value:`90d`,label:`90d`},{value:`all`,label:`All`},{value:`custom`,label:`Custom`}],K=`__all__`;function He({agent:e,onAgentChange:t,agentCatalog:n,scopeCounts:r,window:i,rangePreset:a,onRangeChange:o,onSelectCustom:s}){let[c,l]=(0,b.useState)(!1);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[t?(0,I.jsxs)(`select`,{"aria-label":`Filter by agent`,value:e??K,onChange:e=>t(e.target.value===K?void 0:e.target.value),className:`console-mono max-w-[220px] rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-2 py-1.5 text-xs text-[var(--console-text)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,children:[(0,I.jsx)(`option`,{value:K,children:`All agents`}),n.active.map(e=>(0,I.jsx)(`option`,{value:e.name.toLowerCase(),children:e.displayName},e.name))]}):null,r?(0,I.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[r.projects,` projects · `,r.agents,` agents in scope`]}):null,(0,I.jsx)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:Ve.map(e=>{let t=e.value===a;return(0,I.jsx)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>{e.value===`custom`?l(!0):o(e.value)},className:f(`console-mono motion-hover rounded-full border px-[13px] py-[5px] text-[11px] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,t?`border-[var(--brand)] bg-[var(--brand)] text-[var(--brand-fg)]`:`border-[var(--console-border)] bg-[var(--console-surface)] text-[var(--console-muted)]`),children:e.label},e.value)})})]}),(0,I.jsx)(m,{open:c,onOpenChange:l,window:i,onSelectCustom:s})]})}function Ue(e){return e.toFixed(1)}var We={neutral:`text-[var(--console-muted)]`,warning:`text-[var(--brand)]`,positive:`text-[var(--positive)]`};function q({label:e,value:t,trend:n,trendTone:r=`neutral`,hint:i,emphasis:a=!1}){return(0,I.jsxs)(v,{className:f(`px-4 py-[14px]`,a?`border-[var(--brand-line)]`:null),children:[(0,I.jsx)(`p`,{className:`console-eyebrow`,children:e}),(0,I.jsx)(`p`,{className:f(`console-mono mt-[9px] text-[27px] font-semibold tracking-[-0.02em]`,a?`text-[var(--brand)]`:`text-[var(--console-text)]`),children:t}),(0,I.jsxs)(`div`,{className:`mt-[7px] flex items-center gap-[7px]`,children:[n===void 0?null:(0,I.jsx)(`span`,{"data-testid":`overview-kpi-trend`,className:f(`console-mono text-[10.5px]`,We[r]),children:n}),i===void 0?null:(0,I.jsx)(`span`,{className:`console-mono truncate text-[10.5px] text-[var(--console-muted)]`,children:i})]})]})}function Ge(e){return e.costEstimated===0?`All recorded by agents`:e.costEstimated===e.cost&&e.cost>0?`All estimated from unit price`:`${o(e.costEstimated)} estimated`}function Ke(e){let t=[e.latestActivityProject,e.latestActivityAgent].filter(e=>!!e);return t.length>0?t.join(` · `):void 0}function qe({totals:e,rangeDays:t}){let n=e.previous,r=(e,t)=>t===void 0?null:l(e,t),i=r(e.sessions,n?.sessions),c=r(e.messages,n?.messages),f=r(e.tokens,n?.tokens),p=r(e.cost,n?.cost),m=n?.cost!==void 0&&e.cost>n.cost;return(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-5`,children:[(0,I.jsx)(q,{label:`Sessions`,value:d(e.sessions),trend:i??void 0,hint:t?`${Ue(e.sessions/t)}/day`:void 0}),(0,I.jsx)(q,{label:`Messages`,value:d(e.messages),trend:c??void 0,hint:e.sessions>0?`${Ue(e.messages/e.sessions)}/session`:void 0}),(0,I.jsx)(q,{label:`Tokens`,value:s(e.tokens),trend:f??void 0,hint:`Cache hit ${a(e.cacheReadTokens/e.tokens)}`}),(0,I.jsx)(q,{label:`Cost`,value:o(e.cost),trend:p??void 0,trendTone:m?`warning`:`positive`,hint:Ge(e),emphasis:!0}),(0,I.jsx)(q,{label:`Last activity`,value:e.latestActivity===void 0?`No activity`:u(e.latestActivity),trend:e.latestActivity===void 0?void 0:`●`,trendTone:`positive`,hint:e.latestActivity===void 0?void 0:Ke(e)})]})}var Je=[0,1,2,3,4];function J({className:e}){return(0,I.jsx)(`span`,{className:`skeleton-shimmer block rounded-sm ${e}`})}function Y({bodyClassName:e}){return(0,I.jsxs)(v,{className:`p-4`,children:[(0,I.jsx)(J,{className:`h-[15px] w-28`}),(0,I.jsx)(J,{className:`mt-3 ${e}`})]})}function Ye(){return(0,I.jsxs)(`div`,{className:`space-y-4`,"aria-hidden":!0,"data-testid":`overview-skeleton`,children:[(0,I.jsx)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-5`,children:Je.map(e=>(0,I.jsxs)(v,{className:`px-4 py-[14px]`,children:[(0,I.jsx)(J,{className:`h-[10px] w-16`}),(0,I.jsx)(J,{className:`mt-[9px] h-[27px] w-24`}),(0,I.jsx)(J,{className:`mt-[7px] h-[11px] w-20`})]},e))}),(0,I.jsxs)(v,{className:`p-4`,children:[(0,I.jsx)(J,{className:`h-[15px] w-28`}),(0,I.jsx)(J,{className:`mt-[14px] h-[168px] w-full`})]}),(0,I.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[1.45fr_1fr]`,children:[(0,I.jsx)(Y,{bodyClassName:`h-[248px] w-full`}),(0,I.jsxs)(`div`,{className:`grid content-start gap-4`,children:[(0,I.jsx)(Y,{bodyClassName:`h-[116px] w-full`}),(0,I.jsx)(Y,{bodyClassName:`h-[100px] w-full`})]})]})]})}var Xe=.16;function Ze(e){return e*e*(3-2*e)}function Qe(e,t,n){return e<t?t:e>n?n:e}function X(e,t=new Float32Array(512)){let n=e.length;if(n===0)return t.fill(0),t;for(let r=0;r<512;r++){let i=Qe(r/511*n-.5,0,n-1),a=Math.min(n-2,Math.floor(i));if(a<0){t[r]=e[0];continue}let o=Ze(i-a);t[r]=e[a]*(1-o)+e[a+1]*o}return t}function $e(e,t){let n=Qe(t,0,1)*511,r=Math.min(510,Math.floor(n)),i=n-r;return e[r]*(1-i)+e[r+1]*i}function et(e,t){return 1-(t>0?Math.min(1,e/t):0)*.84}var tt=2,nt=460,rt=180,Z=32,it=.06,at=.24,ot=/oklch\(\s*([\d.]+)\s+([\d.]+)\s+([\d.]+)/;function st(e){let t=Math.imul(e^2654435769,2246822507);return t=Math.imul(t^t>>>13,3266489909),((t^t>>>16)>>>0)/4294967296}function ct(e,t){let n=ot.exec(e),r=ot.exec(t);if(!n||!r)return Array.from({length:33},()=>t);let[i,a,o]=[Number(n[1]),Number(n[2]),Number(n[3])],[s,c,l]=[Number(r[1]),Number(r[2]),Number(r[3])];return Array.from({length:33},(e,t)=>{let n=t/Z,r=i+(s-i)*n,u=a+(c-a)*n,d=o+(l-o)*n;return`oklch(${r.toFixed(3)} ${u.toFixed(3)} ${d.toFixed(1)})`})}function lt(e,{values:t,max:n,reducedMotion:r}){let i=(0,b.useContext)(_),a=M(e,r),o=(0,b.useRef)({from:X(t),to:X(t),current:X(t),fromMax:n,toMax:n,currentMax:n,startedAt:0,duration:0}),s=(0,b.useRef)(null),c=(0,b.useRef)(()=>{}),l=(0,b.useRef)({x:-1e4,y:-1e4,smoothX:-1e4,smoothY:-1e4,speed:0,inside:!1});(0,b.useEffect)(()=>{let e=o.current;e.from.set(e.current),e.fromMax=e.currentMax,X(t,e.to),e.toMax=n,e.startedAt=performance.now(),e.duration=r?0:nt,r?c.current():a.requestFrame()},[a,n,r,t]),(0,b.useEffect)(()=>{let t=e.current,n=t?.parentElement,i=t?.getContext(`2d`);if(!t||!n||!i)return;let u=l.current,d=getComputedStyle(t),f=d.getPropertyValue(`--tile-rest`).trim(),p=ct(d.getPropertyValue(`--tile-wash`).trim(),d.getPropertyValue(`--tile-ink`).trim()),m=()=>{let e=n.clientWidth,r=n.clientHeight;if(!e||!r)return;let a=n.getBoundingClientRect(),o=Math.min(tt,window.devicePixelRatio||1);t.width=Math.round(e*o),t.height=Math.round(r*o),t.style.width=`${e}px`,t.style.height=`${r}px`,i.setTransform(o,0,0,o,0,0),i.imageSmoothingEnabled=!1;let c=Math.max(3,Math.round(e/rt)),l=Math.ceil(e/c),u=Math.ceil(r/c),d=l*u,f=new Uint8Array(d);for(let e=0;e<d;e++)f[e]=+(st(e)<it);s.current={cell:c,cols:l,rows:u,width:e,height:r,left:a.left,top:a.top,step:1/o,glow:new Float32Array(d),spark:f}},h=e=>{let t=o.current,n=t.duration>0?Math.min(1,(e-t.startedAt)/t.duration):1;for(let e=0;e<512;e++)t.current[e]=t.from[e]+(t.to[e]-t.from[e])*n;return t.currentMax=t.fromMax+(t.toMax-t.fromMax)*n,n>=1&&(t.duration=0),n<1},g=e=>{let t=l.current,n=t.smoothX,r=t.smoothY,i=1-.72**e;t.smoothX+=(t.x-n)*i,t.smoothY+=(t.y-r)*i,t.speed=Math.hypot(t.smoothX-n,t.smoothY-r)},_=(e,t=1)=>{let n=s.current;if(!n)return!1;let a=o.current,{cell:c,cols:u,rows:d,width:m,height:h,step:g,glow:_,spark:v}=n,y=e=>Math.round(e/g)*g,b=Math.max(g,y(c*.34)),x=y((c-b)/2);i.clearRect(0,0,m,h),i.fillStyle=f;for(let e=0;e<u;e++){let t=e*c+x;for(let e=0;e<d;e++)i.fillRect(t,e*c+x,b,b)}let S=l.current,C=h*(at+Math.min(1,S.speed/25)*.26),w=!r&&S.inside,T=1-.78**t,E=1-.95**t,ee=e*.0018,D=-1,O=!1;for(let t=0;t<u;t++){let n=u>1?(t+.5)/u:.5,o=et($e(a.current,n),a.currentMax),s=Math.max(.001,1-o),l=t*c,m=l+c/2;for(let n=0;n<d;n++){let a=t*d+n,u=n*c,b=(u+c/2)/h,x=0;b>=o&&(x=1-.55*((b-o)/s));let k=_[a];if(w){let e=Math.hypot(m-S.smoothX,u+c/2-S.smoothY),t=e<C?1-e/C:0;k+=(t-k)*(t>k?T:E),_[a]=k}else k>0&&(k*=1-E,_[a]=k<.002?0:k);_[a]>0&&(O=!0);let A=Math.min(1,x+k*.5);if(A<=.02)continue;let j=A;r||(j*=1+.07*Math.sin(b*Math.PI*3-ee),v[a]&&k>.02&&(j*=1+.25*k*Math.sin(e*.012+a)),j=Math.min(1,j));let M=Math.max(g,y(c*(.28+.42*A))),N=y((c-M)/2),P=Math.round(j*Z);P!==D&&(D=P,i.fillStyle=p[D]??p[Z]??f),i.fillRect(l+N,u+N,M,M)}}return O},v=()=>{m(),h(performance.now()),_(performance.now())};c.current=v;let y=e=>{let t=s.current;if(!t)return;let r=l.current;if(!r.inside){let e=n.getBoundingClientRect();t.left=e.left,t.top=e.top}r.x=e.clientX-t.left,r.y=e.clientY-t.top,r.inside||(r.smoothX=r.x,r.smoothY=r.y),r.inside=!0,a.requestFrame()},b=()=>{l.current.inside=!1,a.requestFrame()},x=0;a.setFrameHandler(e=>{let t=x===0?1:Math.min(3,(e-x)/(1e3/60));x=e;let n=h(e);g(t);let r=_(e,t);return n?`active`:l.current.inside||r?`idle`:(x=0,`stop`)}),m();let S=new ResizeObserver(()=>{m(),r?(h(performance.now()),_(performance.now())):a.requestFrame()});return S.observe(n),r?v():(n.addEventListener(`pointermove`,y,{passive:!0}),n.addEventListener(`pointerleave`,b)),()=>{a.setFrameHandler(null),S.disconnect(),n.removeEventListener(`pointermove`,y),n.removeEventListener(`pointerleave`,b),u.inside=!1}},[e,a,r,i])}var ut=[1,.66,.33,0],dt=e=>`${(1-e*(1-Xe))*100}%`,ft=(e,t)=>(e+.5)/t*100;function pt({values:e,max:t,labels:n,formatValue:r}){let[i,a]=(0,b.useState)(null),o=(0,b.useRef)(null),s=F(),c=t=>{let n=o.current?.getBoundingClientRect();if(!n?.width)return;let r=(t-n.left)/n.width,i=Math.round(r*e.length-.5);a(Math.min(e.length-1,Math.max(0,i)))},l=i!==null,u=i??0,d=e[u]??0,p=s?void 0:`left 260ms ease-out, top 260ms ease-out`;return(0,I.jsxs)(`div`,{ref:o,className:`absolute inset-0 cursor-crosshair touch-none`,onPointerMove:e=>c(e.clientX),onPointerLeave:()=>a(null),children:[(0,I.jsx)(`span`,{className:f(`pointer-events-none absolute inset-y-0 w-px -translate-x-1/2 bg-[var(--brand-line)] transition-opacity duration-150`,l?`opacity-100`:`opacity-0`),style:{left:`${ft(u,e.length)}%`,transition:p}}),(0,I.jsxs)(`div`,{className:f(`pointer-events-none absolute size-0 transition-opacity duration-150`,l?`opacity-100`:`opacity-0`),style:{left:`${ft(u,e.length)}%`,top:`${et(d,t)*100}%`,transition:p},children:[(0,I.jsx)(`span`,{className:`absolute size-[9px] -translate-x-1/2 -translate-y-1/2 rounded-full bg-[var(--brand)] ring-2 ring-[var(--console-surface)]`}),(0,I.jsxs)(`span`,{className:`console-mono absolute bottom-3 flex -translate-x-1/2 items-baseline gap-1.5 rounded-md border border-[var(--console-border)] bg-[var(--console-surface)] px-2 py-1 whitespace-nowrap shadow-[var(--shadow-overlay)]`,children:[(0,I.jsx)(`span`,{className:`text-[10px] text-[var(--console-muted)]`,children:n[u]}),(0,I.jsx)(`span`,{className:`text-[12px] font-semibold text-[var(--console-text)]`,children:r(d)})]})]})]})}function mt({values:e,max:t,labels:n,height:r,formatValue:i,formatTick:a,className:o}){let s=(0,b.useRef)(null);return lt(s,{values:e,max:t,reducedMotion:F()}),(0,I.jsxs)(`div`,{className:f(`flex`,o),"aria-hidden":!0,children:[a?(0,I.jsx)(`div`,{className:`relative shrink-0`,style:{height:r,width:38},children:ut.map(e=>(0,I.jsx)(`span`,{className:`console-mono absolute right-2 -translate-y-1/2 text-[9.5px] whitespace-nowrap text-[var(--console-muted)]`,style:{top:dt(e)},children:a(t*e)},e))}):null,(0,I.jsxs)(`div`,{className:`chart-hatch relative min-w-0 flex-1`,style:{height:r},children:[ut.map(e=>(0,I.jsx)(`span`,{className:f(`pointer-events-none absolute inset-x-0`,e===0?`h-px bg-[var(--console-border-strong)]`:`border-t border-dashed border-[var(--console-border)]`),style:{top:dt(e)}},e)),(0,I.jsx)(`canvas`,{ref:s,className:`absolute inset-0 block`}),e.length>0?(0,I.jsx)(pt,{values:e,max:t,labels:n,formatValue:i}):null]})]})}var ht=168,gt=132,_t=6,vt={barRatio:.86,barMax:46,bandGap:2,minBand:3},Q=[{key:`input`,label:`Input`,color:`var(--token-input)`},{key:`output`,label:`Output`,color:`var(--token-output)`},{key:`cache_read`,label:`Cache read`,color:`var(--token-cache-read)`},{key:`cache_create`,label:`Cache write`,color:`var(--token-cache-write)`}],yt=Q.map(e=>e.color);function bt(e){return e>=1e3?`$${s(e)}`:`$${Math.round(e)}`}function $(e){return e.input+e.output+e.cache_read+e.cache_create}function xt(e){return`${p(e.date)}: ${s($(e))} tokens, ${o(e.cost)}, ${d(e.sessions)} sessions, ${d(e.messages)} messages, input ${s(e.input)}, output ${s(e.output)}, cache read ${s(e.cache_read)}, cache write ${s(e.cache_create)}`}function St({daily:e}){let t=(0,b.useMemo)(()=>e.map(e=>e.cost),[e]),n=(0,b.useMemo)(()=>e.map(e=>p(e.date)),[e]),r=t.reduce((e,t)=>e+t,0),i=t.reduce((e,t)=>Math.max(e,t),0);return i<=0?null:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`mt-[14px] flex items-baseline justify-between border-t border-dashed border-[var(--console-border)] pt-[11px]`,children:[(0,I.jsx)(`span`,{className:`console-mono text-[10.5px] text-[var(--console-text)]`,children:`Daily cost`}),(0,I.jsxs)(`span`,{className:`console-mono text-[10px] text-[var(--console-muted)]`,children:[`Peak `,o(i),` · Avg `,o(r/e.length),` · Total `,o(r)]})]}),(0,I.jsx)(mt,{values:t,max:i,labels:n,height:gt,formatValue:o,formatTick:bt,className:`mt-[7px]`})]})}function Ct({bucket:e,index:t,count:n}){return(0,I.jsxs)(`div`,{className:f(`console-mono pointer-events-none absolute top-2 z-10 rounded-md border border-[var(--console-border)] bg-[var(--console-surface)] px-2.5 py-2 text-[10.5px] whitespace-nowrap text-[var(--console-text)] shadow-[var(--shadow-overlay)]`,t>=n*.75?`-translate-x-full`:`-translate-x-1/2`),style:{left:`${(t+.5)/n*100}%`},children:[(0,I.jsx)(`div`,{children:p(e.date)}),(0,I.jsxs)(`div`,{children:[s($(e)),` tok ·`,` `,(0,I.jsx)(`span`,{className:`text-[var(--brand)]`,children:o(e.cost)})]}),(0,I.jsxs)(`div`,{children:[d(e.sessions),` sessions · `,d(e.messages),` messages`]}),(0,I.jsxs)(`div`,{className:`text-[var(--console-muted)]`,children:[`In `,s(e.input),` · Out `,s(e.output),` · Read`,` `,s(e.cache_read),` · Write `,s(e.cache_create)]})]})}function wt({daily:e}){let[t,n]=(0,b.useState)(null),r=(0,b.useMemo)(()=>e.map(e=>Q.map(t=>e[t.key])),[e]),i=(0,b.useMemo)(()=>e.map(xt),[e]),a=(0,b.useMemo)(()=>ee(e.reduce((e,t)=>Math.max(e,$(t)),0)),[e]),o=t===null?void 0:e[t.column];return(0,I.jsxs)(`div`,{className:`relative mt-[14px]`,children:[(0,I.jsx)(L,{values:r,axisMax:a,colors:yt,hovered:t,onHover:n,layout:vt,height:ht,formatTick:s,ariaLabel:`Daily usage chart`,itemLabels:i}),o&&t?(0,I.jsx)(`div`,{className:`absolute inset-x-0 top-0`,style:{left:38},children:(0,I.jsx)(Ct,{bucket:o,index:t.column,count:e.length})}):null]})}function Tt({daily:e}){let t=e[0],n=e[e.length-1],r=t&&n?` · ${p(t.date)} → ${p(n.date)}`:``,i=Math.max(1,Math.ceil(e.length/_t));return(0,I.jsxs)(v,{role:`region`,"aria-label":`Daily usage`,className:`p-4`,children:[(0,I.jsx)(g,{title:`Daily usage`,action:(0,I.jsx)(`div`,{className:`console-mono flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] text-[var(--console-muted)]`,children:Q.map(e=>(0,I.jsxs)(`span`,{"data-testid":`overview-legend-token`,className:`flex items-center gap-1`,children:[(0,I.jsx)(`span`,{className:`size-2 rounded-[2px]`,style:{background:e.color},"aria-hidden":!0}),e.label]},e.key))})}),(0,I.jsxs)(`p`,{className:`console-mono mt-1 text-[10.5px] text-[var(--console-muted)]`,children:[`Stacked bars = token mix · Area below = daily cost`,r]}),e.length===0?(0,I.jsx)(`p`,{className:`console-mono mt-[14px] text-[11px] text-[var(--console-muted)]`,children:`No usage data`}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(wt,{daily:e}),(0,I.jsx)(St,{daily:e}),(0,I.jsx)(`div`,{style:{paddingLeft:38},children:(0,I.jsx)(`div`,{className:`console-mono mt-2 flex text-[10px] text-[var(--console-muted)]`,children:e.map((t,n)=>(0,I.jsx)(`span`,{className:`flex-1 text-center`,children:n%i===0||n===e.length-1?p(t.date):``},t.date))})})]}),(0,I.jsxs)(`table`,{className:`sr-only`,"aria-label":`Daily usage data`,children:[(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{children:`Date`}),(0,I.jsx)(`th`,{children:`Sessions`}),(0,I.jsx)(`th`,{children:`Messages`}),(0,I.jsx)(`th`,{children:`Tokens`}),(0,I.jsx)(`th`,{children:`Cost`})]})}),(0,I.jsx)(`tbody`,{children:e.map(e=>(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{children:p(e.date)}),(0,I.jsx)(`td`,{children:d(e.sessions)}),(0,I.jsx)(`td`,{children:d(e.messages)}),(0,I.jsx)(`td`,{children:d($(e))}),(0,I.jsx)(`td`,{children:o(e.cost)})]},e.date))})]})]})}function Et({project:e,agent:t,onAgentChange:n,window:r,agentCatalog:i,rangePreset:a,onRangeChange:o,onSelectCustom:s}){let[c,l]=(0,b.useState)(void 0),u=n?t:c,{dashboard:d,error:f}=x(r,{project:e,agent:u});return(0,I.jsxs)(`div`,{"data-testid":`dashboard`,className:`mx-auto max-w-6xl space-y-4`,children:[(0,I.jsx)(He,{agent:u,onAgentChange:n?void 0:l,agentCatalog:i,scopeCounts:d?.scopeCounts,window:r,rangePreset:a,onRangeChange:o,onSelectCustom:s}),f?(0,I.jsx)(`p`,{role:`alert`,className:`rounded-lg border border-[var(--console-error-border)] bg-[var(--console-error-bg)] p-4 text-sm text-[var(--console-error)]`,children:f}):d?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(qe,{totals:d.totals,rangeDays:d.window.days}),(0,I.jsx)(Tt,{daily:d.dailyActivity}),(0,I.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,I.jsx)(be,{perAgent:d.perAgent}),(0,I.jsx)(Be,{modelCost:d.modelCost,modelDistribution:d.modelDistribution,totals:d.totals})]})]}):(0,I.jsx)(Ye,{})]})}export{Et as OverviewScreen};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,n as t,t as n}from"./jsx-runtime-B-hcVAMW.js";import{d as r,g as i,i as a,l as o,m as s,n as c,r as l,s as u,t as d,u as f}from"./utils-BKqufGdv.js";import{t as p}from"./panel-CLnL4kMN.js";import{c as m,d as h,h as g,r as _,s as v,t as y,v as b}from"./contract-DXvltqJG.js";import{a as x,o as S,p as C}from"./session-indexes-BPhf1X2P.js";import{n as w}from"./agents-BkRP_ww3.js";import{t as T}from"./session-title-DdtlxtlR.js";import{OverviewScreen as E}from"./OverviewScreen-B5JekBLC.js";var D=e(t(),1);function O(e){return e.time_updated??e.time_created}function k(e){return{agentName:g(e),sessionId:e.id}}function A(e,t){let n=h(t);if(e===n)return`Today`;if(e===y(n,-1))return`Yesterday`;let r=new Date(e);return f(r.getTime())}function j(e){let{session:t}=e,n=k(t);return{routeKey:v(n.agentName,n.sessionId),reference:n,time:O(t),title:T(t),messageCount:t.stats.message_count,cost:t.stats.total_cost??0}}function M(e,t){let n=e.children.toSorted((e,t)=>O(e.session)-O(t.session));for(let e of n)t.push(j(e)),M(e,t)}function N(e,t){let{session:n,inclusiveStats:r}=e,i=k(n),a=[];return M(e,a),{routeKey:v(i.agentName,i.sessionId),reference:i,time:O(n),title:T(n),agentKey:i.agentName,childCount:e.descendantCount,children:a,messageCount:r.messageCount,tokens:r.totalTokens,cost:r.cost,isOrphan:t}}function P(e,t){let n=_(e),r=t?.now??Date.now();return{days:m(n.entries).map(e=>({dayKey:e.dayKey,dayStart:e.dayStart,label:A(e.dayStart,r),mainCount:e.mainCount,subCount:e.subCount,rows:e.nodes.map(e=>N(e,n.mountStateOf(e.session)===`orphan`))})),orphanCount:n.orphans.length,mainCount:n.entries.length,subCount:n.entries.reduce((e,t)=>e+t.descendantCount,0),totalTokens:n.entries.reduce((e,t)=>e+t.inclusiveStats.totalTokens,0)}}function F(e,t,n){return t===`hidden`||e.childCount===0?!1:t===`expanded`||n.has(e.routeKey)}var I=n(),L={sm:`px-2 py-[3px] text-[10.5px]`,md:`px-3 py-[5px] text-xs`};function R({options:e,value:t,onChange:n,size:r=`md`,ariaLabel:i}){let a=(0,D.useRef)([]),o=e.findIndex(e=>e.value===t),s=o<0?0:o,c=(t,r)=>{let i=(t+r+e.length)%e.length;n(e[i].value),a.current[i]?.focus()};return(0,I.jsx)(`div`,{role:`radiogroup`,"aria-label":i,className:`inline-flex rounded-md border border-[var(--console-border)] bg-[var(--console-surface)] p-[3px]`,children:e.map((e,t)=>{let i=t===o;return(0,I.jsx)(`button`,{ref:e=>{a.current[t]=e},type:`button`,role:`radio`,"aria-checked":i,tabIndex:t===s?0:-1,onClick:()=>n(e.value),onKeyDown:e=>{e.key===`ArrowRight`||e.key===`ArrowDown`?(e.preventDefault(),c(t,1)):(e.key===`ArrowLeft`||e.key===`ArrowUp`)&&(e.preventDefault(),c(t,-1))},className:d(`console-mono motion-hover rounded-sm border border-transparent whitespace-nowrap focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,L[r],i?`bg-[var(--brand)] text-[var(--brand-fg)]`:`text-[var(--console-muted)] hover:text-[var(--console-text)]`),children:e.label},e.value)})})}var z=[{value:`collapsed`,label:`Collapsed`},{value:`expanded`,label:`Expand all`},{value:`hidden`,label:`Hidden`}];function B({mode:e,onChange:t}){return(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`console-eyebrow`,children:`Sub-sessions`}),(0,I.jsx)(R,{options:z,value:e,onChange:t,size:`sm`,ariaLabel:`Sub-session display`})]})}function V({id:e,rows:t,onOpen:n}){return(0,I.jsxs)(`div`,{id:e,className:`border-t border-dashed border-[var(--console-border-strong)] bg-[var(--console-surface-muted)] p-[10px_16px_12px_66px]`,children:[(0,I.jsx)(`span`,{className:`console-eyebrow`,children:`Sub-sessions · derived from this session`}),(0,I.jsx)(`div`,{className:`mt-2 flex flex-col gap-1.5 border-l border-dashed border-[var(--console-border-strong)] pl-[14px]`,children:t.map(e=>(0,I.jsxs)(`button`,{type:`button`,onClick:()=>n(e.reference),className:`motion-hover flex items-center gap-[11px] rounded-md border border-[var(--console-border)] bg-[var(--console-surface)] p-[9px_12px] text-left hover:border-[var(--console-border-strong)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,children:[(0,I.jsx)(`span`,{className:`console-mono w-[34px] shrink-0 text-[10px] text-[var(--console-muted)]`,children:l(e.time)}),e.kind==null?null:(0,I.jsx)(`span`,{className:`console-mono shrink-0 rounded-sm border border-[var(--console-border)] px-1.5 text-[9.5px] text-[var(--console-muted)]`,children:e.kind}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[12.5px] text-[var(--console-text)]`,children:e.title}),(0,I.jsxs)(`span`,{className:`console-mono shrink-0 text-[10px] text-[var(--console-muted)]`,children:[u(e.messageCount),` msgs · `,i(e.cost)]})]},e.routeKey))})]})}function H({row:e,mode:t,expanded:n,agentCatalog:r,onToggle:o,onOpen:s}){let d=(0,D.useId)(),f=w(r,e.agentKey),p=f?.displayName??e.agentKey,m=e.childCount>0;return(0,I.jsxs)(`article`,{className:`overflow-hidden rounded-lg border bg-[var(--console-surface)] shadow-[var(--shadow-raised)] ${n?`border-[var(--brand-line)]`:`border-[var(--console-border)]`}`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-[13px] p-[13px_16px]`,children:[(0,I.jsx)(`span`,{className:`console-mono w-[38px] shrink-0 text-[11px] text-[var(--console-muted)]`,children:l(e.time)}),e.isOrphan?(0,I.jsx)(`span`,{className:`console-mono shrink-0 rounded-sm border border-[var(--console-border-strong)] px-1.5 text-[9.5px] text-[var(--console-muted)]`,children:`Unmounted`}):null,(0,I.jsx)(`span`,{className:`inline-flex size-6 shrink-0 items-center justify-center rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)]`,children:f?.icon?(0,I.jsx)(c,{icon:f.icon,iconColored:f.iconColored,alt:p,className:`size-[13px] object-contain`}):null}),(0,I.jsxs)(`button`,{type:`button`,onClick:()=>s(e.reference),className:`min-w-0 flex-1 text-left focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,children:[(0,I.jsx)(`span`,{className:`block truncate text-[13.5px] font-medium text-[var(--console-text)]`,children:e.title}),(0,I.jsxs)(`span`,{className:`console-mono mt-[3px] block truncate text-[10.5px] text-[var(--console-muted)]`,children:[p,` · `,u(e.messageCount),` msgs · `,a(e.tokens),` tok`,m?` · ${e.childCount} sub-sessions`:``]})]}),m&&t!==`hidden`?(0,I.jsxs)(`button`,{type:`button`,"aria-expanded":n,"aria-controls":d,onClick:()=>o(e.routeKey),className:`console-mono motion-hover inline-flex shrink-0 items-center gap-1.5 rounded-full border border-[var(--brand-line)] bg-[var(--brand-soft)] px-2.5 py-[3px] text-[10.5px] text-[var(--brand)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,children:[(0,I.jsx)(`span`,{className:`text-[11px]`,children:`⑂`}),e.childCount,` sub`,(0,I.jsx)(`span`,{className:`opacity-70`,children:n?`▾`:`▸`})]}):null,(0,I.jsxs)(`span`,{className:`console-mono w-[76px] shrink-0 text-right text-[11px] text-[var(--console-muted)]`,children:[i(e.cost),m?` incl. sub`:``]})]}),n?(0,I.jsx)(V,{id:d,rows:e.children,onOpen:s}):null]})}function U({day:e,mode:t,openIds:n,agentCatalog:r,onToggle:i,onOpen:a}){return(0,I.jsxs)(`div`,{className:`flex gap-5`,children:[(0,I.jsxs)(`div`,{className:`w-[84px] shrink-0 pt-[14px] text-right`,children:[(0,I.jsx)(`div`,{className:`console-display text-[15px] font-semibold text-[var(--console-text)]`,children:e.label}),(0,I.jsxs)(`div`,{className:`console-mono mt-0.5 text-[10px] text-[var(--console-muted)]`,children:[e.mainCount,` main · `,e.subCount,` sub`]})]}),(0,I.jsxs)(`div`,{className:`relative flex min-w-0 flex-1 flex-col gap-2.5 border-l border-[var(--console-border)] py-2.5 pr-0 pl-[22px]`,children:[(0,I.jsx)(`span`,{className:`absolute top-[18px] -left-[4px] size-[7px] rounded-full bg-[var(--brand)]`}),e.rows.map(e=>(0,I.jsx)(H,{row:e,mode:t,expanded:F(e,t,n),agentCatalog:r,onToggle:i,onOpen:a},e.routeKey))]})]})}function W({sessions:e,projectName:t,agentCatalog:n,onOpenSession:r}){let[i,o]=(0,D.useState)(`collapsed`),[s,c]=(0,D.useState)(()=>new Set),l=(0,D.useMemo)(()=>P(e),[e]),u=(0,D.useCallback)(e=>{c(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n})},[]);return(0,I.jsxs)(`section`,{"aria-label":`${t} timeline`,className:`flex flex-col gap-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,I.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:`${l.mainCount} sessions · ${l.subCount} sub-sessions · ${a(l.totalTokens)} tokens`}),(0,I.jsx)(`div`,{className:`ml-auto`,children:(0,I.jsx)(B,{mode:i,onChange:o})})]}),(0,I.jsx)(`div`,{className:`flex flex-col gap-3`,children:l.days.map(e=>(0,I.jsx)(U,{day:e,mode:i,openIds:s,agentCatalog:n,onToggle:u,onOpen:r},e.dayKey))}),l.orphanCount>0?(0,I.jsxs)(`p`,{className:`console-mono text-[10.5px] text-[var(--console-muted)]`,children:[l.orphanCount,` unmounted sub-sessions · parent file is gone`]}):null]})}function G({label:e,value:t,hint:n}){return(0,I.jsxs)(p,{className:`p-[14px_16px]`,children:[(0,I.jsx)(`p`,{className:`console-eyebrow`,children:e}),(0,I.jsx)(`p`,{className:`console-mono mt-[9px] text-[27px] font-semibold tracking-[-0.02em] text-[var(--console-text)]`,children:t}),n?(0,I.jsx)(`p`,{className:`console-mono mt-[7px] text-[10.5px] text-[var(--console-muted)]`,children:n}):null]})}function K({agents:e,agentCatalog:t}){return e.length===0?null:(0,I.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:e.slice(0,4).map(e=>{let n=w(t,e.name);return(0,I.jsxs)(`span`,{className:`console-mono inline-flex items-center gap-1 rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-1.5 py-0.5 text-[10px] text-[var(--console-muted)]`,children:[n?.icon?(0,I.jsx)(c,{icon:n.icon,iconColored:n.iconColored,alt:n.displayName,className:`size-3 object-contain`}):null,n?.displayName??e.name,` · `,e.sessions]},e.name)})})}function q({project:e,agentCatalog:t}){return(0,I.jsx)(`li`,{children:(0,I.jsxs)(S,{to:x({kind:e.identityKind,key:e.identityKey}),className:`block rounded-lg border border-[var(--console-border)] bg-[var(--console-surface)] p-4 shadow-[var(--shadow-raised)] motion-hover hover:border-[var(--brand-line)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`h2`,{className:`line-clamp-1 text-[13px] font-medium text-[var(--console-text)]`,children:e.displayName}),(0,I.jsx)(`p`,{className:`console-mono mt-[5px] break-all text-[10.5px] text-[var(--console-muted)]`,children:e.identityKey})]}),(0,I.jsxs)(`div`,{className:`console-mono flex shrink-0 flex-wrap gap-2 text-[11px] text-[var(--console-text-secondary)]`,children:[(0,I.jsxs)(`span`,{children:[r(e.sessionCount),` sessions`]}),(0,I.jsxs)(`span`,{children:[a(e.tokens),` tokens`]}),(0,I.jsx)(`span`,{className:`text-[var(--brand)]`,children:o(e.cost)}),(0,I.jsx)(`span`,{className:`text-[var(--console-muted)]`,children:s(e.lastActivity)})]})]}),(0,I.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2 md:flex-row md:items-center md:justify-between`,children:[(0,I.jsx)(K,{agents:e.agentStats,agentCatalog:t}),(0,I.jsx)(`span`,{className:`console-eyebrow`,children:e.identityKind})]})]})})}function J({projects:e,agentCatalog:t}){let n=e.reduce((e,t)=>e+t.sessionCount,0),i=e.reduce((e,t)=>e+t.tokens,0),c=e.reduce((e,t)=>e+t.cost,0),l=Math.max(0,...e.map(e=>e.lastActivity??0));return e.length===0?(0,I.jsx)(p,{className:`mx-auto max-w-6xl p-6 text-sm text-[var(--console-muted)]`,children:`No projects found`}):(0,I.jsxs)(`div`,{className:`mx-auto max-w-6xl space-y-4`,children:[(0,I.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-4`,children:[(0,I.jsx)(G,{label:`Projects`,value:r(e.length)}),(0,I.jsx)(G,{label:`Sessions`,value:r(n)}),(0,I.jsx)(G,{label:`Tokens`,value:a(i)}),(0,I.jsx)(G,{label:`Total Cost`,value:o(c),hint:l?`Latest ${s(l)}`:void 0})]}),(0,I.jsx)(`ul`,{className:`grid gap-3`,children:e.map(e=>(0,I.jsx)(q,{project:e,agentCatalog:t},`${e.identityKind}:${e.identityKey}`))})]})}function Y({agents:e,agentCatalog:t,activeAgent:n,onChange:r}){let i=e=>`console-mono inline-flex items-center gap-1 rounded-full border px-[13px] py-[5px] text-[11px] motion-hover focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none ${e?`border-[var(--brand)] bg-[var(--brand)] text-[var(--brand-fg)]`:`border-[var(--console-border)] bg-[var(--console-surface)] text-[var(--console-muted)] hover:border-[var(--brand-line)]`}`;return(0,I.jsx)(p,{className:`p-3`,children:(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`console-eyebrow`,children:`Agent`}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>r(void 0),className:i(!n),children:`All Agents`}),e.map(e=>{let a=w(t,e.name),o=n===e.name;return(0,I.jsxs)(`button`,{type:`button`,onClick:()=>r(o?void 0:e.name),className:i(o),children:[a?.icon?(0,I.jsx)(c,{icon:a.icon,iconColored:a.iconColored,alt:a.displayName,className:`size-3 object-contain`}):null,a?.displayName??e.name,` · `,e.sessions]},e.name)})]})})}function X({project:e}){return(0,I.jsxs)(p,{className:`p-4`,children:[(0,I.jsx)(`h2`,{className:`console-display text-[19px] font-semibold text-[var(--console-text)]`,children:e.displayName}),(0,I.jsxs)(`p`,{className:`console-mono mt-1 break-all text-[10.5px] text-[var(--console-muted)]`,children:[e.identityKind,`: `,e.identityKey]})]})}function Z({project:e,agentCatalog:t,projectKey:n,sessions:r,activeAgent:i,onChangeAgent:a,timeWindow:o,rangePreset:s,onRangeChange:c,onSelectCustom:l}){let u=C();if(!e)return(0,I.jsxs)(p,{className:`mx-auto max-w-4xl p-6`,children:[(0,I.jsx)(`h2`,{className:`console-display text-[15px] font-semibold text-[var(--console-text)]`,children:`Project Not Found`}),(0,I.jsx)(`p`,{className:`console-mono mt-2 break-all text-xs text-[var(--console-muted)]`,children:n}),(0,I.jsx)(S,{to:`/projects`,className:`console-mono mt-4 inline-flex rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-xs text-[var(--console-text)] motion-hover hover:bg-[var(--console-surface)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,children:`Back to Projects`})]});let d=i?r.filter(e=>e.agentKey===i):r;return(0,I.jsxs)(`div`,{className:`mx-auto max-w-6xl space-y-4`,children:[(0,I.jsx)(X,{project:e}),(0,I.jsx)(Y,{agents:e.agentStats,agentCatalog:t,activeAgent:i,onChange:a}),(0,I.jsx)(E,{project:{kind:e.identityKind,key:e.identityKey},agent:i,onAgentChange:a,window:o,agentCatalog:t,rangePreset:s,onRangeChange:c,onSelectCustom:l},`${e.identityKind}:${e.identityKey}`),(0,I.jsx)(W,{sessions:d,projectName:e.displayName,agentCatalog:t,onOpenSession:e=>u(b(e))})]})}export{Z as ProjectDashboardView,J as ProjectsOverview};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./jsx-runtime-B-hcVAMW.js";import{
|
|
1
|
+
import{t as e}from"./jsx-runtime-B-hcVAMW.js";import{o as t}from"./contract-DXvltqJG.js";import"./session-indexes-BPhf1X2P.js";import{t as n}from"./SmartTagChips-ux6idUGJ.js";var r=e();function i({active:e,label:t,onClick:n}){return(0,r.jsx)(`button`,{type:`button`,onClick:n,className:`console-mono rounded-full border px-2.5 py-1 text-[10px] motion-hover focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none ${e?`border-[var(--brand)] bg-[var(--brand)] text-[var(--brand-fg)]`:`border-[var(--console-border)] bg-[var(--console-surface-muted)] text-[var(--console-muted)] hover:bg-[var(--console-surface)] hover:text-[var(--console-text)]`}`,children:t})}var a=[`bugfix`,`refactoring`,`feature-dev`,`testing`,`docs`,`git-ops`,`build-deploy`,`exploration`,`planning`],o=[`apply_patch`,`bash`,`read`,`edit`,`grep`],s=[{kind:`read`,label:`Read`},{kind:`edit`,label:`Edit`},{kind:`write`,label:`Write`},{kind:`delete`,label:`Delete`}],c=[{id:`paid`,label:`Cost > $0`,costMin:1e-6},{id:`one_plus`,label:`Cost >= $1`,costMin:1},{id:`ten_plus`,label:`Cost >= $10`,costMin:10}];function l({agents:e,projects:l,filters:u,onChangeFilters:d}){let f=Object.values(u).some(Boolean),p=u.project?t(u.project):void 0,m=(e,t)=>{d(n=>({...n,[e]:n[e]===t?void 0:t}))};return(0,r.jsxs)(`div`,{className:`rounded-lg border border-[var(--console-border)] bg-[var(--console-surface)] p-3 shadow-[var(--shadow-raised)]`,children:[(0,r.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,r.jsx)(`span`,{className:`console-eyebrow`,children:`Scope`}),(0,r.jsx)(i,{active:!u.project,label:`All`,onClick:()=>d(e=>({...e,project:void 0}))}),l.map(e=>(0,r.jsx)(i,{active:p===e.key,label:e.showCount===!1?e.label:`${e.label} · ${e.count}`,onClick:()=>d(t=>({...t,project:p===e.key?void 0:{kind:e.identityKind,key:e.identityKey}}))},e.key))]}),(0,r.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,r.jsx)(`span`,{className:`console-eyebrow`,children:`Agent`}),(0,r.jsx)(i,{active:!u.agent,label:`All Agents`,onClick:()=>d(e=>({...e,agent:void 0}))}),e.map(e=>(0,r.jsx)(i,{active:u.agent===e.name,label:e.displayName,onClick:()=>m(`agent`,e.name)},e.name))]}),(0,r.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,r.jsx)(`span`,{className:`console-eyebrow`,children:`Tag`}),a.map(e=>(0,r.jsx)(i,{active:u.tag===e,label:n[e],onClick:()=>m(`tag`,e)},e))]}),(0,r.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,r.jsx)(`span`,{className:`console-eyebrow`,children:`Signal`}),o.map(e=>(0,r.jsx)(i,{active:u.tool===e,label:`tool:${e}`,onClick:()=>m(`tool`,e)},e))]}),(0,r.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,r.jsx)(`span`,{className:`console-eyebrow`,children:`File Activity`}),s.map(e=>(0,r.jsx)(i,{active:u.fileKind===e.kind,label:e.label,onClick:()=>m(`fileKind`,e.kind)},e.kind))]}),(0,r.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,r.jsx)(`span`,{className:`console-eyebrow`,children:`Cost Range`}),(0,r.jsx)(i,{active:!u.costRange,label:`Any Cost`,onClick:()=>d(e=>({...e,costRange:void 0}))}),c.map(e=>(0,r.jsx)(i,{active:u.costRange===e.id,label:e.label,onClick:()=>m(`costRange`,e.id)},e.id)),f?(0,r.jsx)(`button`,{type:`button`,onClick:()=>d({}),className:`console-mono ml-auto rounded-full border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2.5 py-1 text-[10px] text-[var(--console-muted)] motion-hover hover:bg-[var(--console-surface)] hover:text-[var(--console-text)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,children:`Clear`}):null]})]})}export{l as n,c as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./jsx-runtime-B-hcVAMW.js";import{
|
|
1
|
+
import{t as e}from"./jsx-runtime-B-hcVAMW.js";import{v as t}from"./contract-DXvltqJG.js";import{o as n}from"./session-indexes-BPhf1X2P.js";import{n as r}from"./SmartTagChips-ux6idUGJ.js";import{n as i}from"./SearchFilterBar-B9VrUbym.js";import{t as a}from"./session-title-DdtlxtlR.js";var o=e(),s={recent:`Recent`,title:`Title`,user_message:`User message`,assistant_reply:`Assistant reply`,tool_output:`Tool output`,file_path:`File path`};function c(e,t){let n=[],r=0;for(let{start:i,end:a}of t)i<r||a<=i||a>e.length||(i>r&&n.push(e.slice(r,i)),n.push((0,o.jsx)(`mark`,{children:e.slice(i,a)},`${i}-${a}`)),r=a);return r<e.length&&n.push(e.slice(r)),n}function l({query:e,state:l,agentNameMap:u,agents:d,projects:f,filters:p,onChangeFilters:m,onOpenResult:h,onRetry:g,selectedIndex:_,registerResultRef:v}){let y=l.status===`loaded`?l.results:[],b=(0,o.jsx)(i,{agents:d,projects:f,filters:p,onChangeFilters:m});return l.status===`loading`?(0,o.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[b,(0,o.jsx)(`p`,{className:`sr-only`,"aria-live":`polite`,children:`Searching…`}),(0,o.jsx)(`div`,{className:`grid gap-3`,children:Array.from({length:4}).map((e,t)=>(0,o.jsxs)(`div`,{"data-testid":`search-result-skeleton`,className:`rounded-lg border border-[var(--console-border)] bg-[var(--console-surface)] p-4 shadow-[var(--shadow-raised)]`,children:[(0,o.jsx)(`div`,{className:`skeleton-shimmer h-3 w-32 rounded-sm`}),(0,o.jsx)(`div`,{className:`skeleton-shimmer mt-3 h-4 w-2/3 rounded-sm`}),(0,o.jsx)(`div`,{className:`skeleton-shimmer mt-2 h-3 w-full rounded-sm`}),(0,o.jsx)(`div`,{className:`skeleton-shimmer mt-1 h-3 w-5/6 rounded-sm`})]},t))})]}):l.status===`failed`?(0,o.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[b,(0,o.jsxs)(`div`,{className:`rounded-lg border border-[var(--console-error-border)] bg-[var(--console-error-bg)] p-6`,"aria-live":`polite`,children:[(0,o.jsx)(`h2`,{className:`console-display text-[15px] font-semibold text-[var(--console-error)]`,children:`Search Failed`}),(0,o.jsxs)(`p`,{className:`console-mono mt-2 break-words text-xs text-[var(--console-error)]`,children:[l.error,`. Check the server connection, then try again.`]}),(0,o.jsx)(`button`,{type:`button`,onClick:g,className:`console-mono motion-hover motion-press mt-4 rounded-sm border border-[var(--console-error-border)] bg-[var(--console-surface)] px-3 py-1.5 text-xs font-semibold text-[var(--console-error)] hover:bg-[var(--console-error-bg)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--console-bg)] focus-visible:outline-none`,children:`Retry Search`})]})]}):y.length===0?(0,o.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[b,(0,o.jsxs)(`div`,{className:`rounded-lg border border-[var(--console-border)] bg-[var(--console-surface)] p-6 shadow-[var(--shadow-raised)]`,children:[(0,o.jsx)(`h2`,{className:`console-display text-[15px] font-semibold text-[var(--console-text)]`,children:e?`No matches`:`No recent sessions`}),e?(0,o.jsxs)(`p`,{className:`console-mono mt-2 text-xs text-[var(--console-muted)]`,children:[`Query: `,e]}):null]})]}):(0,o.jsxs)(`div`,{className:`grid gap-3`,children:[b,(0,o.jsx)(`div`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:`Navigate j k · Open Enter · Exit Esc`}),y.map((i,l)=>{let d=i.reference.agentName.toLowerCase(),f=u.get(d)??i.reference.agentName,p=`${i.reference.agentName}/${i.reference.sessionId}`,m=l===_,g=!!i.session.parent_reference&&!i.parent;return(0,o.jsxs)(n,{ref:e=>v(p,e),to:t(i.reference),state:{searchQuery:e},onClick:h,"data-selected":m?`true`:void 0,className:`rounded-lg border bg-[var(--console-surface)] p-4 shadow-[var(--shadow-raised)] motion-hover hover:border-[var(--console-border-strong)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--console-bg)] focus-visible:outline-none ${m?`border-[var(--brand)]`:`border-[var(--console-border)]`}`,children:[(0,o.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,o.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:f}),(0,o.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-1.5 py-0.5 text-[10px] uppercase text-[var(--console-muted)]`,children:s[i.matchType]}),g?(0,o.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border-strong)] px-1.5 py-0.5 text-[10px] text-[var(--console-muted)]`,children:`Unmounted`}):null,(0,o.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:i.session.directory})]}),i.parent?(0,o.jsx)(`p`,{className:`console-mono mt-3 line-clamp-1 text-[11px] text-[var(--console-muted)]`,children:i.parent.title}):null,(0,o.jsxs)(`h2`,{className:`text-[13px] font-semibold text-[var(--console-text)] ${i.parent?`mt-1 flex items-center gap-1.5 pl-3`:`mt-3`}`,children:[i.parent?(0,o.jsx)(`span`,{"aria-hidden":`true`,className:`console-mono text-[var(--brand)]`,children:`›`}):null,a(i.session)]}),(0,o.jsx)(r,{tags:i.session.smart_tags,className:`mt-2`}),(0,o.jsx)(`p`,{className:`mt-2 text-xs leading-6 text-[var(--console-text-secondary)]`,children:c(i.snippet||a(i.session),i.snippet?i.snippetHighlights:[])})]},p)})]})}export{l as SearchResultsPanel};
|