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.
Files changed (42) hide show
  1. package/README.md +2 -1
  2. package/dist/{chunk-JHX5OLL4.js → chunk-PSHZZITB.js} +3280 -805
  3. package/dist/chunk-PSHZZITB.js.map +1 -0
  4. package/dist/chunk-RF3EEWPH.js +17 -0
  5. package/dist/chunk-RF3EEWPH.js.map +1 -0
  6. package/dist/{chunk-OFTTM3UD.js → chunk-WAKW5OPS.js} +2 -2
  7. package/dist/{dist-N2PQATP2.js → dist-RHDY2EZX.js} +18 -20
  8. package/dist/index.js +1291 -672
  9. package/dist/index.js.map +1 -1
  10. package/dist/project-identity-worker.js +27 -0
  11. package/dist/project-identity-worker.js.map +1 -0
  12. package/dist/scan-refresh-worker.js +15 -6
  13. package/dist/scan-refresh-worker.js.map +1 -1
  14. package/dist/search-index-worker.js +16 -6
  15. package/dist/search-index-worker.js.map +1 -1
  16. package/dist/smart-tag-worker.js +2 -2
  17. package/dist/web/assets/{ErrorBoundary-D11tWzfn.js → ErrorBoundary-DIwwrdlw.js} +1 -1
  18. package/dist/web/assets/InteractiveReceipt-DmNBDVms.js +1 -0
  19. package/dist/web/assets/{OverviewScreen-DriPmCam.js → OverviewScreen-B5JekBLC.js} +1 -1
  20. package/dist/web/assets/Projects-Bj6ma2k2.js +1 -0
  21. package/dist/web/assets/{SearchFilterBar-Bx73B5e9.js → SearchFilterBar-B9VrUbym.js} +1 -1
  22. package/dist/web/assets/{SearchResultsPanel-A6_3TPhW.js → SearchResultsPanel-C1cuuOKq.js} +1 -1
  23. package/dist/web/assets/SessionDetail-Dc2CQ3hH.js +54 -0
  24. package/dist/web/assets/contract-DXvltqJG.js +1 -0
  25. package/dist/web/assets/index-3UfOiTBO.css +1 -0
  26. package/dist/web/assets/index-DBMiEd61.js +1410 -0
  27. package/dist/web/assets/panel-CLnL4kMN.js +1 -0
  28. package/dist/web/assets/{session-indexes-0oT5HSS5.js → session-indexes-BPhf1X2P.js} +2 -2
  29. package/dist/web/assets/{utils-DgUgu15E.js → utils-BKqufGdv.js} +1 -1
  30. package/dist/web/icon/agent/dsh.svg +3 -0
  31. package/dist/web/index.html +8 -8
  32. package/package.json +1 -1
  33. package/dist/chunk-JHX5OLL4.js.map +0 -1
  34. package/dist/web/assets/InteractiveReceipt-DYGyHeZd.js +0 -1
  35. package/dist/web/assets/Projects-BPDIcUBK.js +0 -1
  36. package/dist/web/assets/SessionDetail-lQz99ARH.js +0 -54
  37. package/dist/web/assets/contract-V6QuD0UY.js +0 -1
  38. package/dist/web/assets/index-B2RqUgZ5.css +0 -1
  39. package/dist/web/assets/index-BgWoUD_4.js +0 -1410
  40. package/dist/web/assets/panel-C-gc79Gz.js +0 -1
  41. /package/dist/{chunk-OFTTM3UD.js.map → chunk-WAKW5OPS.js.map} +0 -0
  42. /package/dist/{dist-N2PQATP2.js.map → dist-RHDY2EZX.js.map} +0 -0
@@ -1 +0,0 @@
1
- import{a as e,n as t,t as n}from"./jsx-runtime-B-hcVAMW.js";import{t as r}from"./SmartTagChips-ux6idUGJ.js";import{t as i}from"./session-title-DdtlxtlR.js";var a=e(t(),1);function o(e,t){return t===0||e-t>=15.666666666666668}function s(e,t,n){return!e&&t<=.12?n+1:0}function c(e,t){return e?0:t+1}function l(){let e=typeof document>`u`?void 0:document.fonts;return e?e.ready.then(()=>void 0):Promise.resolve()}function u(e,t,n){return e>=2&&(t>=8||n>=300)}var d=n();function f(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 p=18,m=42,h=5,g=270,_=500,v=2,y=.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 b(e){return Math.round(e??0).toLocaleString(`en-US`)}function x(e){return`$${(e??0).toFixed(4)}`}function S(e){return new Date(e).toLocaleString(`en-US`,{month:`short`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`})}function C(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 w(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 T(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 E(e){return!e||e.length===0?`SESSION ACTIVITY RECEIPT`:e.map(e=>r[e]).join(` / `)}function D(e,t){let n=e.slug?.split(`/`)[0]||`codesesh`;return{id:e.id,title:i(e)||`Untitled session`,agent:n,updatedAt:e.time_updated??e.time_created,tags:e.smart_tags,stats:e.stats,items:T(t)}}function O(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 k(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 A(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(k(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]=k(e,a[a.length-1]??``,n)),a.slice(0,r)}function ne(e,t,n){let r=document.createElement(`canvas`);r.width=g*v,r.height=_*v;let i=r.getContext(`2d`);if(!i)return r;i.scale(v,v);let a=e=>`${e} ${n}`,o=i.createLinearGradient(0,0,g,_);o.addColorStop(0,t.paperTop),o.addColorStop(1,t.paperBottom),i.fillStyle=o,i.fillRect(0,0,g,_);let s=w(C(e.id));i.fillStyle=t.ink;for(let e=0;e<1200;e+=1)i.globalAlpha=y*(.12+s()*.14),i.fillRect(s()*g,s()*_,.7,.7);i.globalAlpha=1,i.fillStyle=t.ink,i.font=a(`700 18px`),i.textAlign=`center`,i.fillText(`CODESESH MART`,g/2,34),i.fillStyle=t.inkMuted,i.font=a(`11px`),i.fillText(k(i,E(e.tags).toUpperCase(),234),g/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`),O(i,`Agent`,e.agent,88,g),O(i,`Updated`,S(e.updatedAt),104,g),O(i,`Session`,`#${e.id.slice(0,8)}`,120,g),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=b(t.count);i.fillText(k(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,O(i,`Input tokens`,b(e.stats.total_input_tokens),c,g),c+=16,O(i,`Output tokens`,b(e.stats.total_output_tokens),c,g),c+=16,O(i,`Messages`,b(e.stats.message_count),c,g),c+=22,i.font=a(`700 13px`),O(i,`TOTAL COST`,x(e.stats.total_cost),c,g),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,A(i,e.title,234,2).forEach((e,t)=>{i.fillText(e,g/2,c+38+t*13)}),r}function j(e,t){return e*p+t}function M(e){let{receiptWidth:t,receiptHeight:n,startX:r,startY:i}=e,a=t/17,o=n/41,s=[],c=[];for(let e=0;e<m;e+=1)for(let t=0;t<p;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<m;e+=1)for(let t=0;t<p;t+=1){let n=j(e,t);t<17&&l(n,j(e,t+1),.98),e<41&&l(n,j(e+1,t),.92),e<41&&t<17&&(l(n,j(e+1,t+1),.46),l(j(e+1,t),j(e,t+1),.46)),t<16&&l(n,j(e,t+2),.35),e<40&&l(n,j(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<p;r+=1){let i=e[r];i&&(i.fixedX=t.startX+r*n,i.fixedY=t.startY)}}function N(e){for(let t=0;t<p;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[j(i,a)],s=r[j(i,a+1)],c=r[j(i+1,a)],l=r[j(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)/(_/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=p;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=p;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 P({session:e,toc:t,minWidthQuery:n=`(min-width: 1025px)`}){let r=(0,a.useRef)(null),i=(0,a.useRef)(null),m=(0,a.useRef)(null),v=(0,a.useMemo)(()=>D(e,t),[e,t]);return(0,a.useLayoutEffect)(()=>{let e=r.current,t=i.current,a=m.current;if(!e||!t||!a)return;let d=e.getContext(`2d`,{alpha:!0});if(!d)return;let y={id:null,x:0,y:0,prevX:0,prevY:0,vx:0,vy:0,grabbedIndex:null},b=null,x=!1,S=0,C=0,w=0,T=M({receiptWidth:g,receiptHeight:_,startX:0,startY:32}),E=performance.now(),D=null,O=0,k=0,A=0,j=0,P=!1,F=!1,I=window.matchMedia(n),L=window.matchMedia(`(prefers-reduced-motion: reduce)`),R=()=>b!=null&&I.matches&&document.visibilityState===`visible`,z=()=>{let e=ee(t);b={texture:ne(v,e,te(t)),palette:e}},B=()=>{let e=t.getBoundingClientRect(),n=Math.max(280,e.width||320),r=Math.min(g,n-34);return{receiptWidth:r,receiptHeight:Math.min(_,Math.max(320,w-42)),startX:(n-r)/2,startY:32}},V=t=>{P!==t&&(P=t,e.style.visibility=t?`visible`:`hidden`,a.style.visibility=t&&!L.matches?`visible`:`hidden`)},H=()=>{F=!1,S&&=(window.cancelAnimationFrame(S),0),V(!1)},U=(e,t=performance.now())=>{T=M(e),D=e,E=t},W=()=>{let n=window.devicePixelRatio||1,r=t.getBoundingClientRect();C=Math.max(1,r.width),w=Math.max(1,r.height),e.width=Math.floor(C*n),e.height=Math.floor(w*n),d.setTransform(n,0,0,n,0,0),O=0,k=0,A=0,j=0,V(!1),U(B()),R()&&G()},G=()=>{F||!R()||(F=!0,S=window.requestAnimationFrame(Q))},K=()=>{R()?W():H()},q=e=>{let n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}},J=e=>{if(e.button!==0||L.matches)return;let t=q(e),n=oe(T.particles,t.x,t.y);n!=null&&(e.preventDefault(),a.setPointerCapture(e.pointerId),y.id=e.pointerId,y.x=t.x,y.y=t.y,y.prevX=t.x,y.prevY=t.y,y.vx=0,y.vy=0,y.grabbedIndex=n,k=0,A=0,G())},Y=e=>{if(y.id!==e.pointerId)return;let t=q(e);y.vx=t.x-y.prevX,y.vy=t.y-y.prevY,y.prevX=t.x,y.prevY=t.y,y.x=t.x,y.y=t.y},X=e=>{if(y.id!==e.pointerId)return;let t=y.grabbedIndex==null?null:T.particles[y.grabbedIndex];t&&(t.oldX=t.x-y.vx*.9,t.oldY=t.y-y.vy*.9),y.id=null,y.grabbedIndex=null},ce=e=>{let t=(e-E)/1e3;for(let e=p;e<T.particles.length;e+=1){let n=T.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=y.grabbedIndex==null?null:T.particles[y.grabbedIndex];n&&(n.x+=(y.x-n.x)*.72,n.y+=(y.y-n.y)*.72)},le=()=>{for(let e=0;e<h;e+=1){N(T.particles);for(let e of T.constraints)ie(T.particles,e)}N(T.particles)},ue=()=>{let e=1/0,t=1/0,n=-1/0,r=-1/0;for(let i of T.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);a.style.transform=`translate3d(${e-20}px, ${t-20}px, 0)`,a.style.width=`${n-e+40}px`,a.style.height=`${r-t+40}px`},de=e=>{let t=T.particles[0],n=T.particles[17],r=T.particles[755],i=T.particles[738];!t||!n||!r||!i||(d.save(),d.shadowColor=e.shadow,d.shadowBlur=24,d.shadowOffsetY=16,d.fillStyle=e.shadow,d.beginPath(),d.moveTo(t.x,t.y),d.lineTo(n.x,n.y),d.lineTo(r.x,r.y),d.lineTo(i.x,i.y),d.closePath(),d.fill(),d.restore())},fe=e=>{let t=T.particles[0],n=T.particles[17];!t||!n||(d.save(),d.strokeStyle=e.ink,d.lineWidth=4,d.lineCap=`round`,d.beginPath(),d.moveTo(t.x-10,t.y-3),d.lineTo(n.x+10,n.y-3),d.stroke(),d.strokeStyle=e.paperTop,d.lineWidth=1,d.beginPath(),d.moveTo(t.x-8,t.y-5),d.lineTo(n.x+8,n.y-5),d.stroke(),d.restore())},Z=()=>{if(b){d.clearRect(0,0,C,w),de(b.palette);for(let e=0;e<41;e+=1)for(let t=0;t<17;t+=1)ae(d,b.texture,b.palette,T.particles,e,t);fe(b.palette),ue()}},Q=e=>{if(!F)return;if(!R()){H();return}if(!o(e,j)){S=window.requestAnimationFrame(Q);return}j=e;let t=B();f(D,t)&&y.id==null?(O=0,V(!1),U(t,e)):(O+=1,D=t),re(T.particles,t),L.matches||(ce(e),le()),Z();let n=y.id!=null;k=s(n,se(T.particles),k),A=c(n,A);let r=L.matches;if((r||O>=2)&&V(!0),r||u(O,k,A)){r||(U(t,e),Z()),F=!1,S=0;return}S=window.requestAnimationFrame(Q)};V(!1),l().then(()=>{x||(z(),K())});let $=new ResizeObserver(W);$.observe(t);let pe=new MutationObserver(()=>{z(),Z()});return pe.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),I.addEventListener(`change`,K),L.addEventListener(`change`,K),document.addEventListener(`visibilitychange`,K),window.addEventListener(`resize`,K),a.addEventListener(`pointerdown`,J),a.addEventListener(`pointermove`,Y),a.addEventListener(`pointerup`,X),a.addEventListener(`pointercancel`,X),()=>{x=!0,H(),$.disconnect(),pe.disconnect(),I.removeEventListener(`change`,K),L.removeEventListener(`change`,K),document.removeEventListener(`visibilitychange`,K),window.removeEventListener(`resize`,K),a.removeEventListener(`pointerdown`,J),a.removeEventListener(`pointermove`,Y),a.removeEventListener(`pointerup`,X),a.removeEventListener(`pointercancel`,X)}},[n,v]),(0,d.jsxs)(`div`,{ref:i,className:`relative h-[calc(100dvh-5.5rem)] min-h-[420px]`,children:[(0,d.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,d.jsx)(`div`,{ref:m,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{P as InteractiveReceipt};
@@ -1 +0,0 @@
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-DgUgu15E.js";import{t as p}from"./panel-C-gc79Gz.js";import{_ as m,f as h,g,i as _,l as v,t as y,u as b}from"./contract-V6QuD0UY.js";import{a as x,o as S,p as C}from"./session-indexes-0oT5HSS5.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-DriPmCam.js";var D=e(t(),1);function O(e){return e.time_updated??e.time_created}function k(e){return{agentName:v(e),sessionId:e.id}}function A(e,t){let n=m(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:b(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:b(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:h(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(g(e))})]})}export{Z as ProjectDashboardView,J as ProjectsOverview};