claude-session-dashboard 0.4.2 → 0.4.4

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 (29) hide show
  1. package/dist/client/assets/_dashboard-DLFGahko.js +1 -0
  2. package/dist/client/assets/{_sessionId-D4Tpmmb5.js → _sessionId-xiPzwrlf.js} +1 -1
  3. package/dist/client/assets/{createServerFn-BYTDoNe-.js → createServerFn-BLR4iNR3.js} +1 -1
  4. package/dist/client/assets/{index-DnK_zh3s.js → index-D_9sS4oJ.js} +1 -1
  5. package/dist/client/assets/{main-CV28H4XG.js → main-BcKPK-4E.js} +3 -3
  6. package/dist/client/assets/{sessions.queries-tzrs5GhP.js → sessions.queries-CHKiZnLm.js} +1 -1
  7. package/dist/client/assets/{settings-D8yv1q93.js → settings-B2tG1vy0.js} +1 -1
  8. package/dist/client/assets/{settings.types-CMYAW0cQ.js → settings.types-DHC6rkil.js} +1 -1
  9. package/dist/client/assets/{stats-C_6E4jyb.js → stats-BlA0NIHc.js} +1 -1
  10. package/dist/client/assets/{useSessionCost-BBu3AmcX.js → useSessionCost-BikgEmWy.js} +1 -1
  11. package/dist/server/assets/{_dashboard-TUzgwLqB.js → _dashboard-smfIqyQC.js} +56 -30
  12. package/dist/server/assets/{_sessionId-DyFxvcBN.js → _sessionId-DIUMcrWR.js} +1 -1
  13. package/dist/server/assets/_tanstack-start-manifest_v-Dmhlhehg.js +4 -0
  14. package/dist/server/assets/app-info.server-CXcS0a5s.js +40 -0
  15. package/dist/server/assets/{index-Bx7vBs4O.js → index-hFrIPkke.js} +1 -1
  16. package/dist/server/assets/{project-analytics.server-BsmZ4xil.js → project-analytics.server-Bxk8-NnT.js} +2 -3
  17. package/dist/server/assets/{router-Cd4jLk4T.js → router-5hznwWqr.js} +5 -5
  18. package/dist/server/assets/{session-detail.server-BDup9xb0.js → session-detail.server-BIoOQwSE.js} +1 -2
  19. package/dist/server/assets/{session-parser-75iTexM0.js → session-parser-B0pdBvgT.js} +168 -48
  20. package/dist/server/assets/{session-scanner-CPud4KGP.js → session-scanner-CpgOq5m1.js} +4 -5
  21. package/dist/server/assets/{sessions.server-60puUvjv.js → sessions.server-Biq8gbAJ.js} +2 -3
  22. package/dist/server/assets/{settings-KKaz1ty7.js → settings-D0FgLIR5.js} +1 -1
  23. package/dist/server/assets/{stats-Bsrkajci.js → stats-Ae6umrPI.js} +1 -1
  24. package/dist/server/assets/{stats.server-qTOvID9-.js → stats.server-DhzOihwM.js} +86 -83
  25. package/dist/server/server.js +16 -13
  26. package/package.json +1 -1
  27. package/dist/client/assets/_dashboard-t702m22X.js +0 -1
  28. package/dist/server/assets/_tanstack-start-manifest_v-RaGuPsWw.js +0 -4
  29. package/dist/server/assets/claude-path-BdwflgZ1.js +0 -31
@@ -0,0 +1 @@
1
+ import{j as e,c,u as x,L as l,O as d}from"./main-BcKPK-4E.js";import{u as n,c as h,q as p}from"./createServerFn-BLR4iNR3.js";import{a as m}from"./sessions.queries-CHKiZnLm.js";function u(){const{data:r}=n(m),a=r?.length??0;return a===0?null:e.jsx("span",{className:"ml-auto rounded-full bg-emerald-500/20 px-1.5 py-0.5 text-[10px] font-medium text-emerald-400",children:a})}const f=h({method:"GET"}).handler(c("955327d72ca3168c4751159ca07b8fb0fe0d2381dd0b991f06b941480959fbe8")),g=p({queryKey:["app-info"],queryFn:()=>f(),staleTime:1/0,refetchOnWindowFocus:!1}),j=[{to:"/sessions",label:"Sessions",icon:e.jsxs("svg",{className:"h-4 w-4",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("line",{x1:"2",y1:"4",x2:"14",y2:"4"}),e.jsx("line",{x1:"2",y1:"8",x2:"14",y2:"8"}),e.jsx("line",{x1:"2",y1:"12",x2:"14",y2:"12"})]})},{to:"/stats",label:"Stats",icon:e.jsxs("svg",{className:"h-4 w-4",viewBox:"0 0 16 16",fill:"currentColor",children:[e.jsx("rect",{x:"1",y:"8",width:"3",height:"7",rx:"0.5"}),e.jsx("rect",{x:"6.5",y:"4",width:"3",height:"11",rx:"0.5"}),e.jsx("rect",{x:"12",y:"1",width:"3",height:"14",rx:"0.5"})]})},{to:"/settings",label:"Settings",icon:e.jsxs("svg",{className:"h-4 w-4",viewBox:"0 0 16 16",fill:"currentColor",children:[e.jsx("path",{d:"M8 10a2 2 0 100-4 2 2 0 000 4z"}),e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.5.8a1 1 0 011-.8h1a1 1 0 011 .8l.15.9a5.5 5.5 0 011.1.64l.86-.36a1 1 0 011.17.36l.5.86a1 1 0 01-.18 1.17l-.7.55a5.5 5.5 0 010 1.27l.7.55a1 1 0 01.18 1.17l-.5.86a1 1 0 01-1.17.36l-.86-.36a5.5 5.5 0 01-1.1.64l-.14.9a1 1 0 01-1 .8h-1a1 1 0 01-1-.8l-.14-.9a5.5 5.5 0 01-1.1-.64l-.87.36a1 1 0 01-1.17-.36l-.5-.86a1 1 0 01.18-1.17l.7-.55a5.5 5.5 0 010-1.27l-.7-.55a1 1 0 01-.18-1.17l.5-.86a1 1 0 011.17-.36l.87.36a5.5 5.5 0 011.1-.64L6.5.8zM8 11a3 3 0 100-6 3 3 0 000 6z"})]})}];function y({children:r}){const a=x(),o=a[a.length-1]?.pathname??"",{data:t}=n(g);return e.jsxs("div",{className:"flex min-h-screen",children:[e.jsxs("aside",{className:"flex w-56 shrink-0 flex-col border-r border-gray-800 bg-gray-950",children:[e.jsx("div",{className:"flex h-14 items-center border-b border-gray-800 px-4",children:e.jsxs(l,{to:"/sessions",className:"text-sm font-bold text-white",children:[e.jsx("span",{className:"text-brand-500",children:"Claude"})," Dashboard"]})}),e.jsx("nav",{className:"flex-1 p-3",children:j.map(s=>{const i=o.startsWith(s.to);return e.jsxs(l,{to:s.to,className:`flex items-center gap-2.5 rounded-lg px-3 py-2 text-sm transition-colors ${i?"bg-gray-800 text-white":"text-gray-400 hover:bg-gray-800/50 hover:text-gray-200"}`,children:[e.jsx("span",{className:"text-gray-500",children:s.icon}),s.label,s.to==="/sessions"&&e.jsx(u,{})]},s.to)})}),e.jsxs("div",{className:"border-t border-gray-800 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("a",{href:"https://github.com/dlupiak/claude-session-dashboard",target:"_blank",rel:"noopener noreferrer",className:"text-gray-500 hover:text-gray-300 transition-colors",title:"GitHub Repository",children:e.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"})})}),e.jsx("a",{href:"https://www.npmjs.com/package/claude-session-dashboard",target:"_blank",rel:"noopener noreferrer",className:"text-gray-500 hover:text-gray-300 transition-colors",title:"npm Package",children:e.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M0 0v16h16V0H0zm13 13H8V5H5v8H3V3h10v10z"})})})]}),e.jsx("p",{className:"text-xs text-gray-600",children:"Read-only"})]}),t&&e.jsxs("p",{className:"mt-1.5 truncate text-[10px] text-gray-600",title:`v${t.version} · ${t.appPath}`,children:["v",t.version," · ",t.appPath]})]})]}),e.jsx("main",{className:"flex-1 overflow-auto",children:e.jsx("div",{className:"mx-auto max-w-5xl px-6 py-6",children:r})})]})}function w(){return e.jsx(y,{children:e.jsx(d,{})})}export{w as component};
@@ -1,4 +1,4 @@
1
- import{r as v,c as ae,j as e,L as W,f as G,b as ne}from"./main-CV28H4XG.js";import{c as re,q as le,u as _}from"./createServerFn-BYTDoNe-.js";import{f as C,d as X,b as M,i as V,g as E}from"./format-Bsprb3az.js";import{r as oe,a7 as ie,l as ce,bz as de,bA as xe,aw as me,bB as ue,d as P,bC as pe,bD as he,bE as Y,bF as ge,s as fe,aa as ye,Z as be,a as je,bG as ve,bH as Ne,at as O,bI as q,bJ as ke,bn as we,bq as Te,bo as Me,bp as Se,br as Ce,bK as Ie,bL as De,bs as J,bt as Ae,bu as $e,bM as Oe}from"./useSessionCost-BBu3AmcX.js";import{s as Ee}from"./settings.types-CMYAW0cQ.js";import{a as Pe}from"./sessions.queries-tzrs5GhP.js";class Le{constructor(s){var{x:a,y:n}=s;this.xAxisScale=a,this.yAxisScale=n}map(s,a){var n,r,{position:o}=a;return{x:(n=this.xAxisScale.map(s.x,{position:o}))!==null&&n!==void 0?n:0,y:(r=this.yAxisScale.map(s.y,{position:o}))!==null&&r!==void 0?r:0}}mapWithFallback(s,a){var n,r,{position:o,fallback:l}=a,d,i;return l==="rangeMin"?d=this.yAxisScale.rangeMin():l==="rangeMax"?d=this.yAxisScale.rangeMax():d=0,l==="rangeMin"?i=this.xAxisScale.rangeMin():l==="rangeMax"?i=this.xAxisScale.rangeMax():i=0,{x:(n=this.xAxisScale.map(s.x,{position:o}))!==null&&n!==void 0?n:i,y:(r=this.yAxisScale.map(s.y,{position:o}))!==null&&r!==void 0?r:d}}isInRange(s){var{x:a,y:n}=s,r=a==null||this.xAxisScale.isInRange(a),o=n==null||this.yAxisScale.isInRange(n);return r&&o}}function K(t,s){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),a.push.apply(a,n)}return a}function Z(t){for(var s=1;s<arguments.length;s++){var a=arguments[s]!=null?arguments[s]:{};s%2?K(Object(a),!0).forEach(function(n){Re(t,n,a[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):K(Object(a)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(a,n))})}return t}function Re(t,s,a){return(s=Ue(s))in t?Object.defineProperty(t,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[s]=a,t}function Ue(t){var s=We(t,"string");return typeof s=="symbol"?s:s+""}function We(t,s){if(typeof t!="object"||!t)return t;var a=t[Symbol.toPrimitive];if(a!==void 0){var n=a.call(t,s);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(t)}function R(){return R=Object.assign?Object.assign.bind():function(t){for(var s=1;s<arguments.length;s++){var a=arguments[s];for(var n in a)({}).hasOwnProperty.call(a,n)&&(t[n]=a[n])}return t},R.apply(null,arguments)}var Fe=(t,s)=>{var a;if(v.isValidElement(t))a=v.cloneElement(t,s);else if(typeof t=="function")a=t(s);else{if(!O(s.x1)||!O(s.y1)||!O(s.x2)||!O(s.y2))return null;a=v.createElement("line",R({},s,{className:"recharts-reference-line-line"}))}return a},_e=(t,s,a,n,r,o)=>{var{x:l,width:d}=o,i=r.map(t,{position:a});if(!O(i)||s==="discard"&&!r.isInRange(i))return null;var h=[{x:l+d,y:i},{x:l,y:i}];return n==="left"?h.reverse():h},Xe=(t,s,a,n,r,o)=>{var{y:l,height:d}=o,i=r.map(t,{position:a});if(!O(i)||s==="discard"&&!r.isInRange(i))return null;var h=[{x:i,y:l+d},{x:i,y:l}];return n==="top"?h.reverse():h},Be=(t,s,a,n)=>{var r=[n.mapWithFallback(t[0],{position:a,fallback:"rangeMin"}),n.mapWithFallback(t[1],{position:a,fallback:"rangeMax"})];return s==="discard"&&r.some(o=>!n.isInRange(o))?null:r},ze=(t,s,a,n,r,o,l)=>{var{x:d,y:i,segment:h,ifOverflow:p}=l,f=q(d),g=q(i);return g?_e(i,p,n,o,s,a):f?Xe(d,p,n,r,t,a):h!=null&&h.length===2?Be(h,p,n,new Le({x:t,y:s})):null};function He(t){var s=ce();return v.useEffect(()=>(s(de(t)),()=>{s(xe(t))})),null}function Ge(t){var{xAxisId:s,yAxisId:a,shape:n,className:r,ifOverflow:o}=t,l=me(),d=ue(),i=P(S=>pe(S,s)),h=P(S=>he(S,a)),p=P(S=>Y(S,"xAxis",s,l)),f=P(S=>Y(S,"yAxis",a,l)),g=ge();if(!d||!g||i==null||h==null||p==null||f==null)return null;var N=ze(p,f,g,t.position,i.orientation,h.orientation,t);if(!N)return null;var k=N[0],c=N[1];if(k==null||c==null)return null;var{x:u,y:x}=k,{x:j,y:m}=c,b=o==="hidden"?"url(#".concat(d,")"):void 0,y=Z(Z({clipPath:b},fe(t)),{},{x1:u,y1:x,x2:j,y2:m}),w=ke({x1:u,y1:x,x2:j,y2:m});return v.createElement(ye,{zIndex:t.zIndex},v.createElement(be,{className:je("recharts-reference-line",r)},Fe(n,y),v.createElement(ve,R({},w,{lowerWidth:w.width,upperWidth:w.width}),v.createElement(Ne,{label:t.label}),t.children)))}var Ye={ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",label:!1,stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle",zIndex:ie.line};function F(t){var s=oe(t,Ye);return v.createElement(v.Fragment,null,v.createElement(He,{yAxisId:s.yAxisId,xAxisId:s.xAxisId,ifOverflow:s.ifOverflow,x:s.x,y:s.y,segment:s.segment}),v.createElement(Ge,s))}F.displayName="ReferenceLine";const qe=re({method:"GET"}).handler(ae("ff8a3161afdfa175e9c519e4146a56ab5bce6e80745e99cfc2191ebbb7a859bb"));function Ke(t,s,a){return le({queryKey:["session","detail",t],queryFn:()=>qe({data:{sessionId:t,projectPath:s}}),staleTime:a?2e3:3e4,refetchInterval:a?5e3:void 0})}function Ze(t,s,a,n){const r=[];for(const c of t)if(c.timestamp){const u=new Date(c.timestamp).getTime();isNaN(u)||r.push(u)}for(const c of s)if(c.timestamp){const u=new Date(c.timestamp).getTime();isNaN(u)||r.push(u)}for(const c of a)if(c.timestamp){const u=new Date(c.timestamp).getTime();isNaN(u)||r.push(u)}if(r.length===0)return{startMs:0,endMs:0,durationMs:0,mainLane:[],agentLanes:[],skillMarkers:[],errorMarkers:[]};const o=Math.min(...r),l=Math.max(...r),d=Math.max(l-o,1);function i(c){return(c-o)/d}const h=new Set(s.map(c=>c.toolUseId)),p=new Set(a.map(c=>c.toolUseId)),f=[];for(const c of t){if(c.type!=="assistant"||c.toolCalls.length===0)continue;const u=new Date(c.timestamp).getTime();if(!isNaN(u))for(const x of c.toolCalls)h.has(x.toolUseId)||p.has(x.toolUseId)||f.push({timestampMs:u,toolName:x.toolName,toolUseId:x.toolUseId,relativeX:i(u)})}const g=s.map(c=>{const u=new Date(c.timestamp).getTime(),x=c.durationMs?u+c.durationMs:u+d*.02,j=[];if(c.toolCalls){const m=Object.entries(c.toolCalls).sort(([,w],[,S])=>S-w),b=m.reduce((w,[,S])=>w+S,0);let y=0;for(const[w,S]of m)for(let H=0;H<S;H++){const te=b>1?y/(b-1):.5,se=u+(x-u)*te;j.push({toolName:w,count:1,relativeX:i(se)}),y++}}return{subagentType:c.subagentType,description:c.description,startMs:u,endMs:x,startX:i(u),endX:i(x),durationMs:c.durationMs??null,totalTokens:c.totalTokens??null,totalToolUseCount:c.totalToolUseCount??null,toolDots:j,skills:c.skills?.map(m=>({skill:m.skill,args:m.args}))??[]}}),N=a.map(c=>{const u=new Date(c.timestamp).getTime();return isNaN(u)?null:{skill:c.skill,args:c.args,timestampMs:u,relativeX:i(u)}}).filter(c=>c!==null),k=n.map(c=>{const u=new Date(c.timestamp).getTime();return isNaN(u)?null:{message:c.message,type:c.type,timestampMs:u,relativeX:i(u)}}).filter(c=>c!==null);return{startMs:o,endMs:l,durationMs:d,mainLane:f,agentLanes:g,skillMarkers:N,errorMarkers:k}}function B(t){const s=t.match(/^mcp__[^_]+_[^_]+_[^_]+__(.+)$/);return s?s[1]:t}const Qe={Read:"#e09070",Grep:"#e09070",Glob:"#e09070",Write:"#34d399",Edit:"#34d399",NotebookEdit:"#34d399",Bash:"#fbbf24",Task:"#818cf8",TaskCreate:"#c084fc",TaskUpdate:"#c084fc",TaskList:"#c084fc",TaskGet:"#c084fc",Skill:"#fcd34d",WebSearch:"#22d3ee",WebFetch:"#22d3ee",EnterPlanMode:"#f472b6",ExitPlanMode:"#f472b6",AskUserQuestion:"#a78bfa"},Ve="#9ca3af";function z(t){return Qe[t]??Ve}const I=90,$=16,D=24,T=32,U=8,ee=4;function Je(t,s,a){const n=s-t;if(n<=0)return[];const r=Math.max(3,Math.round(a/120)),o=n/r,l=[5e3,1e4,15e3,3e4,6e4,2*6e4,5*6e4,10*6e4,15*6e4,30*6e4,60*6e4,120*6e4],d=l.find(g=>g>=o)??l[l.length-1],h=n<5*6e4?"HH:mm:ss":"HH:mm",p=Math.ceil(t/d)*d,f=[];for(let g=p;g<=s;g+=d){const N=(g-t)/n;f.push({ms:g,label:C(new Date(g),h),x:I+N*(a-I-$)})}return f}function et({data:t,width:s,onHover:a}){const n=v.useRef(null),r=s,o=r-I-$,l=t.skillMarkers.length>0,d=t.errorMarkers.length>0;let i=D;const h=i;i+=T;const p=[];for(let x=0;x<t.agentLanes.length;x++)i+=U,p.push(i),i+=T;let f=0;l&&(i+=U,f=i,i+=T);let g=0;d&&(i+=U,g=i,i+=T);const N=Math.max(i+8,80);function k(x){return I+x*o}const c=v.useCallback(x=>{if(!n.current)return{x:0,y:0};const j=n.current.getBoundingClientRect();return{x:x.clientX-j.left,y:x.clientY-j.top}},[]),u=Je(t.startMs,t.endMs,r);return e.jsxs("svg",{ref:n,width:r,height:N,className:"select-none",role:"img","aria-label":"Session timeline showing tool calls, agent runs, and skill invocations",onMouseLeave:()=>a(null,{x:0,y:0}),children:[e.jsx("line",{x1:I,y1:D-4,x2:r-$,y2:D-4,stroke:"#374151",strokeWidth:1}),u.map(x=>e.jsxs("g",{children:[e.jsx("line",{x1:x.x,y1:D-8,x2:x.x,y2:D-4,stroke:"#4b5563",strokeWidth:1}),e.jsx("text",{x:x.x,y:D-12,textAnchor:"middle",className:"fill-gray-500 text-[10px]",children:x.label})]},x.ms)),e.jsx("text",{x:4,y:h+T/2+4,className:"fill-gray-500 text-[11px] font-medium",children:"Main"}),e.jsx("line",{x1:I,y1:h+T/2,x2:r-$,y2:h+T/2,stroke:"#1f2937",strokeWidth:1,strokeDasharray:"2,4"}),t.mainLane.map(x=>e.jsx("circle",{cx:k(x.relativeX),cy:h+T/2,r:ee,fill:z(x.toolName),opacity:.85,className:"cursor-pointer transition-transform hover:opacity-100",onMouseEnter:j=>a({kind:"tool",toolName:x.toolName,timestamp:new Date(x.timestampMs).toISOString(),toolUseId:x.toolUseId},c(j)),onMouseLeave:()=>a(null,{x:0,y:0}),children:e.jsx("title",{children:x.toolName})},x.toolUseId)),t.agentLanes.map((x,j)=>e.jsx(tt,{lane:x,y:p[j],toX:k,laneHeight:T,onHover:a,getPosition:c},`${x.subagentType}-${j}`)),l&&e.jsxs(e.Fragment,{children:[e.jsx("text",{x:4,y:f+T/2+4,className:"fill-amber-400/70 text-[11px] font-medium",children:"Skills"}),e.jsx("line",{x1:I,y1:f+T/2,x2:r-$,y2:f+T/2,stroke:"#1f2937",strokeWidth:1,strokeDasharray:"2,4"}),t.skillMarkers.map((x,j)=>{const m=k(x.relativeX),b=f+T/2,y=5;return e.jsx("polygon",{points:`${m},${b-y} ${m+y},${b} ${m},${b+y} ${m-y},${b}`,fill:"#fbbf24",opacity:.85,className:"cursor-pointer hover:opacity-100",onMouseEnter:w=>a({kind:"skill",skill:x.skill,args:x.args,timestamp:new Date(x.timestampMs).toISOString()},c(w)),onMouseLeave:()=>a(null,{x:0,y:0}),children:e.jsxs("title",{children:["/",x.skill]})},`${x.skill}-${j}`)})]}),d&&e.jsxs(e.Fragment,{children:[e.jsx("text",{x:4,y:g+T/2+4,className:"fill-red-400/70 text-[11px] font-medium",children:"Errors"}),e.jsx("line",{x1:I,y1:g+T/2,x2:r-$,y2:g+T/2,stroke:"#1f2937",strokeWidth:1,strokeDasharray:"2,4"}),t.errorMarkers.map((x,j)=>{const m=k(x.relativeX),b=g+T/2,y=5;return e.jsxs("g",{className:"cursor-pointer hover:opacity-100",opacity:.85,onMouseEnter:w=>a({kind:"error",message:x.message,type:x.type,timestamp:new Date(x.timestampMs).toISOString()},c(w)),onMouseLeave:()=>a(null,{x:0,y:0}),children:[e.jsx("line",{x1:m-y,y1:b-y,x2:m+y,y2:b+y,stroke:"#f87171",strokeWidth:2,strokeLinecap:"round"}),e.jsx("line",{x1:m+y,y1:b-y,x2:m-y,y2:b+y,stroke:"#f87171",strokeWidth:2,strokeLinecap:"round"}),e.jsxs("title",{children:[x.type,": ",x.message]})]},`err-${j}`)})]})]})}function tt({lane:t,y:s,toX:a,laneHeight:n,onHover:r,getPosition:o}){const l=a(t.startX),d=Math.max(a(t.endX)-l,8),i=s+n/2,h=t.subagentType.length>10?t.subagentType.slice(0,10)+"...":t.subagentType;return e.jsxs("g",{children:[e.jsx("text",{x:4,y:i+4,className:"fill-indigo-400/70 text-[11px] font-medium",children:h}),e.jsx("rect",{x:l,y:s+2,width:d,height:n-4,rx:6,fill:"rgba(99, 102, 241, 0.08)",stroke:"rgba(99, 102, 241, 0.2)",strokeWidth:1,className:"cursor-pointer hover:fill-indigo-500/15",onMouseEnter:p=>r({kind:"agent",agent:t},o(p)),onMouseLeave:()=>r(null,{x:0,y:0}),children:e.jsxs("title",{children:[t.subagentType,": ",t.description]})}),e.jsx("line",{x1:l+4,y1:i,x2:l+d-4,y2:i,stroke:"rgba(99, 102, 241, 0.15)",strokeWidth:1}),t.toolDots.map((p,f)=>e.jsx("circle",{cx:a(p.relativeX),cy:i,r:ee-.5,fill:z(p.toolName),opacity:.75,className:"cursor-pointer hover:opacity-100",onMouseEnter:g=>r({kind:"tool",toolName:p.toolName,timestamp:new Date(t.startMs+(p.relativeX-t.startX)/(t.endX-t.startX)*(t.endMs-t.startMs)).toISOString(),toolUseId:`${t.subagentType}-${p.toolName}-${f}`},o(g)),onMouseLeave:()=>r(null,{x:0,y:0}),children:e.jsxs("title",{children:[p.toolName," (",t.subagentType,")"]})},`${p.toolName}-${f}`)),t.skills&&t.skills.length>0&&t.skills.map((p,f)=>{const g=t.startX+(t.endX-t.startX)/(t.skills.length+1)*(f+1),N=a(g),k=s+6,c=3;return e.jsx("polygon",{points:`${N},${k-c} ${N+c},${k} ${N},${k+c} ${N-c},${k}`,fill:"#fbbf24",opacity:.85,className:"cursor-pointer hover:opacity-100",onMouseEnter:u=>r({kind:"skill",skill:p.skill,args:p.args,timestamp:new Date(t.startMs).toISOString()},o(u)),onMouseLeave:()=>r(null,{x:0,y:0}),children:e.jsxs("title",{children:["/",p.skill," (",t.subagentType,")"]})},`skill-${p.skill}-${f}`)})]})}function st({item:t,position:s}){return e.jsxs("div",{className:"pointer-events-none absolute z-50 rounded-lg border border-gray-700 bg-gray-900 px-3 py-2 text-xs shadow-xl",style:{left:s.x,top:s.y,transform:"translate(-50%, -100%) translateY(-8px)"},children:[t.kind==="tool"&&e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-gray-100",children:B(t.toolName)}),e.jsx("div",{className:"text-gray-400",children:C(new Date(t.timestamp),"HH:mm:ss")}),e.jsxs("div",{className:"font-mono text-[10px] text-gray-600",children:[t.toolUseId.slice(0,16),"..."]})]}),t.kind==="agent"&&e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-indigo-300",children:t.agent.subagentType}),e.jsx("div",{className:"max-w-48 truncate text-gray-400",children:t.agent.description}),e.jsx("div",{className:"mt-1 flex items-center gap-2 text-gray-500",children:t.agent.durationMs!=null&&e.jsxs("span",{children:[C(new Date(t.agent.startMs),"HH:mm")," -"," ",C(new Date(t.agent.endMs),"HH:mm")," (",X(t.agent.durationMs),")"]})}),e.jsxs("div",{className:"flex items-center gap-2 text-gray-500",children:[t.agent.totalTokens!=null&&e.jsxs("span",{children:[M(t.agent.totalTokens)," tokens"]}),t.agent.totalToolUseCount!=null&&e.jsxs("span",{children:[t.agent.totalToolUseCount," tools"]})]})]}),t.kind==="skill"&&e.jsxs("div",{children:[e.jsxs("div",{className:"font-semibold text-amber-300",children:["/",t.skill]}),t.args&&e.jsx("div",{className:"text-gray-400",children:t.args}),e.jsx("div",{className:"text-gray-500",children:C(new Date(t.timestamp),"HH:mm:ss")})]}),t.kind==="error"&&e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-red-400",children:t.type}),e.jsx("div",{className:"max-w-48 truncate text-gray-400",children:t.message}),e.jsx("div",{className:"text-gray-500",children:C(new Date(t.timestamp),"HH:mm:ss")})]})]})}function at({toolNames:t}){const s=[...new Set(t)].slice(0,12);return s.length===0?null:e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 px-1 text-[10px] text-gray-500",children:[s.map(a=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:z(a)}}),e.jsx("span",{children:B(a)})]},a)),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"inline-block h-2 w-2 rotate-45 bg-amber-400"}),e.jsx("span",{children:"Skill"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-red-400 font-bold leading-none",children:"×"}),e.jsx("span",{children:"Error"})]})]})}function nt({turns:t,agents:s,skills:a,errors:n}){const r=v.useRef(null),[o,l]=v.useState(0),[d,i]=v.useState(1),[h,p]=v.useState(null);v.useEffect(()=>{if(!r.current)return;const m=new ResizeObserver(b=>{const y=b[0];y&&l(y.contentRect.width)});return m.observe(r.current),()=>m.disconnect()},[]);const f=v.useMemo(()=>Ze(t,s,a,n),[t,s,a,n]),g=v.useMemo(()=>{const m=f.mainLane.map(y=>y.toolName);for(const y of f.agentLanes)for(const w of y.toolDots)m.push(w.toolName);const b={};for(const y of m)b[y]=(b[y]??0)+1;return Object.entries(b).sort(([,y],[,w])=>w-y).map(([y])=>y)},[f]),N=(m,b)=>{p(m?{item:m,position:b}:null)};if(t.length===0)return e.jsx("div",{className:"py-8 text-center text-sm text-gray-500",children:"No timeline data available"});const k=new Set(s.map(m=>m.toolUseId)),c=new Set(a.map(m=>m.toolUseId));let u=0,x=0,j=0;for(const m of t)if(m.type==="user"&&m.message?.trim()&&u++,m.type==="assistant"){x++;for(const b of m.toolCalls)!k.has(b.toolUseId)&&!c.has(b.toolUseId)&&j++}return e.jsxs("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4",children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-4",children:[e.jsx(A,{label:"User commands",value:u,color:"blue"}),e.jsx(A,{label:"AI responses",value:x,color:"purple"}),j>0&&e.jsx(A,{label:"Tool calls",value:j,color:"gray"}),s.length>0&&e.jsx(A,{label:"Agents",value:s.length,color:"indigo"}),a.length>0&&e.jsx(A,{label:"Skills",value:a.length,color:"amber"}),n.length>0&&e.jsx(A,{label:"Errors",value:n.length,color:"red"})]}),e.jsxs("div",{className:"mb-3 flex items-start justify-between gap-2",children:[e.jsx("div",{className:"flex-1",children:g.length>0&&e.jsx(at,{toolNames:g})}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsx("button",{type:"button",onClick:()=>i(m=>Math.max(1,m-.5)),disabled:d<=1,className:"rounded bg-gray-800 px-2 py-0.5 text-xs text-gray-300 transition-colors hover:bg-gray-700 disabled:opacity-30",title:"Zoom out",children:"−"}),e.jsx("span",{className:"min-w-[3rem] text-center text-[10px] tabular-nums text-gray-500",children:d===1?"Fit":`${d.toFixed(1)}x`}),e.jsx("button",{type:"button",onClick:()=>i(m=>Math.min(8,m+.5)),disabled:d>=8,className:"rounded bg-gray-800 px-2 py-0.5 text-xs text-gray-300 transition-colors hover:bg-gray-700 disabled:opacity-30",title:"Zoom in",children:"+"}),d>1&&e.jsx("button",{type:"button",onClick:()=>i(1),className:"ml-1 rounded bg-gray-800 px-2 py-0.5 text-[10px] text-gray-400 transition-colors hover:bg-gray-700",title:"Reset zoom",children:"Reset"})]})]}),e.jsx("div",{ref:r,className:"relative overflow-x-auto",children:o>0&&e.jsxs(e.Fragment,{children:[e.jsx(et,{data:f,width:Math.max(o*d,400),onHover:N}),h&&e.jsx(st,{item:h.item,position:h.position})]})})]})}function A({label:t,value:s,color:a}){const n={blue:"bg-brand-500/15 text-brand-400",purple:"bg-purple-500/15 text-purple-400",gray:"bg-gray-800 text-gray-300",indigo:"bg-indigo-500/15 text-indigo-400",amber:"bg-amber-500/15 text-amber-400",red:"bg-red-500/15 text-red-400"};return e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`rounded-md px-2 py-1 text-sm font-bold tabular-nums ${n[a]}`,children:s}),e.jsx("span",{className:"text-[11px] text-gray-500",children:t})]})}function rt({contextWindow:t,tokens:s}){const[a,n]=v.useState(!1);if(!t)return e.jsx(ot,{tokens:s});const{contextLimit:r,modelName:o,systemOverhead:l,currentContextSize:d,messagesEstimate:i,freeSpace:h,autocompactBuffer:p,usagePercent:f,snapshots:g}=t,N=l/r*100,k=i/r*100,c=p/r*100,u=Math.max(0,100-N-k),x=o.replace(/^claude-/,"").split("-202")[0],j=g.map(m=>({turn:m.turnIndex,context:m.contextSize}));return e.jsxs("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-300",children:"Context Window"}),e.jsx("span",{className:"rounded bg-gray-800 px-1.5 py-0.5 text-[10px] font-mono text-gray-400",children:x})]}),e.jsxs("div",{className:"mt-1 flex items-baseline gap-1",children:[e.jsx("span",{className:"text-2xl font-bold text-white",children:M(d)}),e.jsxs("span",{className:"text-sm text-gray-500",children:["/ ",M(r)]}),e.jsxs("span",{className:"text-sm text-gray-400",children:["(",f,"%)"]})]}),e.jsx("p",{className:"text-[10px] text-gray-500",children:"~estimated from token usage"}),e.jsxs("div",{className:"mt-3 flex h-3 overflow-hidden rounded-full bg-gray-800",children:[e.jsx("div",{className:"bg-purple-500",style:{width:`${N}%`},title:`System: ~${M(l)}`}),e.jsx("div",{className:"bg-brand-500",style:{width:`${k}%`},title:`Messages: ~${M(i)}`}),u>0&&e.jsx(e.Fragment,{children:u>c?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bg-gray-700",style:{width:`${u-c}%`}}),e.jsx("div",{className:"autocompact-stripe",style:{width:`${Math.min(c,u)}%`}})]}):e.jsx("div",{className:"autocompact-stripe",style:{width:`${u}%`}})})]}),e.jsxs("div",{className:"mt-1 flex gap-3 text-[10px] text-gray-500",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-purple-500"}),"system"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-brand-500"}),"messages"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-gray-700"}),"free"]})]}),e.jsxs("div",{className:"mt-3 space-y-1.5",children:[e.jsx(L,{label:"System overhead",value:l,total:r,color:"bg-purple-500",prefix:"~"}),e.jsx(L,{label:"Messages",value:i,total:r,color:"bg-brand-500",prefix:"~"}),e.jsx(L,{label:"Autocompact buffer",value:p,total:r,color:"bg-amber-500"}),e.jsx(L,{label:"Free space",value:h,total:r,color:"bg-gray-600"})]}),j.length>1&&e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"mb-1 text-[10px] text-gray-500",children:"Context growth"}),e.jsx(we,{width:"100%",height:96,children:e.jsxs(Te,{data:j,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"contextGrad",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#d97757",stopOpacity:.3}),e.jsx("stop",{offset:"100%",stopColor:"#d97757",stopOpacity:.05})]})}),e.jsx(Me,{domain:[0,r],hide:!0}),e.jsx(Se,{contentStyle:{background:"#1c1c1a",border:"1px solid #3d3b36",borderRadius:"8px",fontSize:"11px"},labelFormatter:m=>`Turn ${m}`,formatter:m=>[M(m),"Context"]}),e.jsx(F,{y:r,stroke:"#ef4444",strokeDasharray:"4 4",strokeOpacity:.5}),e.jsx(F,{y:r-p,stroke:"#f59e0b",strokeDasharray:"2 4",strokeOpacity:.3}),e.jsx(Ce,{type:"stepAfter",dataKey:"context",stroke:"#d97757",fill:"url(#contextGrad)",strokeWidth:1.5,dot:!1})]})})]}),e.jsxs("button",{onClick:()=>n(!a),className:"mt-3 flex w-full items-center gap-1 text-xs text-gray-400 hover:text-gray-300 transition-colors",children:[e.jsx("span",{className:"text-[10px]",children:a?"▾":"▸"}),"Token Details"]}),a&&e.jsx(lt,{tokens:s}),e.jsx("style",{children:`
1
+ import{r as v,c as ae,j as e,L as W,f as G,b as ne}from"./main-BcKPK-4E.js";import{c as re,q as le,u as _}from"./createServerFn-BLR4iNR3.js";import{f as C,d as X,b as M,i as V,g as E}from"./format-Bsprb3az.js";import{r as oe,a7 as ie,l as ce,bz as de,bA as xe,aw as me,bB as ue,d as P,bC as pe,bD as he,bE as Y,bF as ge,s as fe,aa as ye,Z as be,a as je,bG as ve,bH as Ne,at as O,bI as q,bJ as ke,bn as we,bq as Te,bo as Me,bp as Se,br as Ce,bK as Ie,bL as De,bs as J,bt as Ae,bu as $e,bM as Oe}from"./useSessionCost-BikgEmWy.js";import{s as Ee}from"./settings.types-DHC6rkil.js";import{a as Pe}from"./sessions.queries-CHKiZnLm.js";class Le{constructor(s){var{x:a,y:n}=s;this.xAxisScale=a,this.yAxisScale=n}map(s,a){var n,r,{position:o}=a;return{x:(n=this.xAxisScale.map(s.x,{position:o}))!==null&&n!==void 0?n:0,y:(r=this.yAxisScale.map(s.y,{position:o}))!==null&&r!==void 0?r:0}}mapWithFallback(s,a){var n,r,{position:o,fallback:l}=a,d,i;return l==="rangeMin"?d=this.yAxisScale.rangeMin():l==="rangeMax"?d=this.yAxisScale.rangeMax():d=0,l==="rangeMin"?i=this.xAxisScale.rangeMin():l==="rangeMax"?i=this.xAxisScale.rangeMax():i=0,{x:(n=this.xAxisScale.map(s.x,{position:o}))!==null&&n!==void 0?n:i,y:(r=this.yAxisScale.map(s.y,{position:o}))!==null&&r!==void 0?r:d}}isInRange(s){var{x:a,y:n}=s,r=a==null||this.xAxisScale.isInRange(a),o=n==null||this.yAxisScale.isInRange(n);return r&&o}}function K(t,s){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),a.push.apply(a,n)}return a}function Z(t){for(var s=1;s<arguments.length;s++){var a=arguments[s]!=null?arguments[s]:{};s%2?K(Object(a),!0).forEach(function(n){Re(t,n,a[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):K(Object(a)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(a,n))})}return t}function Re(t,s,a){return(s=Ue(s))in t?Object.defineProperty(t,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[s]=a,t}function Ue(t){var s=We(t,"string");return typeof s=="symbol"?s:s+""}function We(t,s){if(typeof t!="object"||!t)return t;var a=t[Symbol.toPrimitive];if(a!==void 0){var n=a.call(t,s);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(t)}function R(){return R=Object.assign?Object.assign.bind():function(t){for(var s=1;s<arguments.length;s++){var a=arguments[s];for(var n in a)({}).hasOwnProperty.call(a,n)&&(t[n]=a[n])}return t},R.apply(null,arguments)}var Fe=(t,s)=>{var a;if(v.isValidElement(t))a=v.cloneElement(t,s);else if(typeof t=="function")a=t(s);else{if(!O(s.x1)||!O(s.y1)||!O(s.x2)||!O(s.y2))return null;a=v.createElement("line",R({},s,{className:"recharts-reference-line-line"}))}return a},_e=(t,s,a,n,r,o)=>{var{x:l,width:d}=o,i=r.map(t,{position:a});if(!O(i)||s==="discard"&&!r.isInRange(i))return null;var h=[{x:l+d,y:i},{x:l,y:i}];return n==="left"?h.reverse():h},Xe=(t,s,a,n,r,o)=>{var{y:l,height:d}=o,i=r.map(t,{position:a});if(!O(i)||s==="discard"&&!r.isInRange(i))return null;var h=[{x:i,y:l+d},{x:i,y:l}];return n==="top"?h.reverse():h},Be=(t,s,a,n)=>{var r=[n.mapWithFallback(t[0],{position:a,fallback:"rangeMin"}),n.mapWithFallback(t[1],{position:a,fallback:"rangeMax"})];return s==="discard"&&r.some(o=>!n.isInRange(o))?null:r},ze=(t,s,a,n,r,o,l)=>{var{x:d,y:i,segment:h,ifOverflow:p}=l,f=q(d),g=q(i);return g?_e(i,p,n,o,s,a):f?Xe(d,p,n,r,t,a):h!=null&&h.length===2?Be(h,p,n,new Le({x:t,y:s})):null};function He(t){var s=ce();return v.useEffect(()=>(s(de(t)),()=>{s(xe(t))})),null}function Ge(t){var{xAxisId:s,yAxisId:a,shape:n,className:r,ifOverflow:o}=t,l=me(),d=ue(),i=P(S=>pe(S,s)),h=P(S=>he(S,a)),p=P(S=>Y(S,"xAxis",s,l)),f=P(S=>Y(S,"yAxis",a,l)),g=ge();if(!d||!g||i==null||h==null||p==null||f==null)return null;var N=ze(p,f,g,t.position,i.orientation,h.orientation,t);if(!N)return null;var k=N[0],c=N[1];if(k==null||c==null)return null;var{x:u,y:x}=k,{x:j,y:m}=c,b=o==="hidden"?"url(#".concat(d,")"):void 0,y=Z(Z({clipPath:b},fe(t)),{},{x1:u,y1:x,x2:j,y2:m}),w=ke({x1:u,y1:x,x2:j,y2:m});return v.createElement(ye,{zIndex:t.zIndex},v.createElement(be,{className:je("recharts-reference-line",r)},Fe(n,y),v.createElement(ve,R({},w,{lowerWidth:w.width,upperWidth:w.width}),v.createElement(Ne,{label:t.label}),t.children)))}var Ye={ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",label:!1,stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle",zIndex:ie.line};function F(t){var s=oe(t,Ye);return v.createElement(v.Fragment,null,v.createElement(He,{yAxisId:s.yAxisId,xAxisId:s.xAxisId,ifOverflow:s.ifOverflow,x:s.x,y:s.y,segment:s.segment}),v.createElement(Ge,s))}F.displayName="ReferenceLine";const qe=re({method:"GET"}).handler(ae("ff8a3161afdfa175e9c519e4146a56ab5bce6e80745e99cfc2191ebbb7a859bb"));function Ke(t,s,a){return le({queryKey:["session","detail",t],queryFn:()=>qe({data:{sessionId:t,projectPath:s}}),staleTime:a?2e3:3e4,refetchInterval:a?5e3:void 0})}function Ze(t,s,a,n){const r=[];for(const c of t)if(c.timestamp){const u=new Date(c.timestamp).getTime();isNaN(u)||r.push(u)}for(const c of s)if(c.timestamp){const u=new Date(c.timestamp).getTime();isNaN(u)||r.push(u)}for(const c of a)if(c.timestamp){const u=new Date(c.timestamp).getTime();isNaN(u)||r.push(u)}if(r.length===0)return{startMs:0,endMs:0,durationMs:0,mainLane:[],agentLanes:[],skillMarkers:[],errorMarkers:[]};const o=Math.min(...r),l=Math.max(...r),d=Math.max(l-o,1);function i(c){return(c-o)/d}const h=new Set(s.map(c=>c.toolUseId)),p=new Set(a.map(c=>c.toolUseId)),f=[];for(const c of t){if(c.type!=="assistant"||c.toolCalls.length===0)continue;const u=new Date(c.timestamp).getTime();if(!isNaN(u))for(const x of c.toolCalls)h.has(x.toolUseId)||p.has(x.toolUseId)||f.push({timestampMs:u,toolName:x.toolName,toolUseId:x.toolUseId,relativeX:i(u)})}const g=s.map(c=>{const u=new Date(c.timestamp).getTime(),x=c.durationMs?u+c.durationMs:u+d*.02,j=[];if(c.toolCalls){const m=Object.entries(c.toolCalls).sort(([,w],[,S])=>S-w),b=m.reduce((w,[,S])=>w+S,0);let y=0;for(const[w,S]of m)for(let H=0;H<S;H++){const te=b>1?y/(b-1):.5,se=u+(x-u)*te;j.push({toolName:w,count:1,relativeX:i(se)}),y++}}return{subagentType:c.subagentType,description:c.description,startMs:u,endMs:x,startX:i(u),endX:i(x),durationMs:c.durationMs??null,totalTokens:c.totalTokens??null,totalToolUseCount:c.totalToolUseCount??null,toolDots:j,skills:c.skills?.map(m=>({skill:m.skill,args:m.args}))??[]}}),N=a.map(c=>{const u=new Date(c.timestamp).getTime();return isNaN(u)?null:{skill:c.skill,args:c.args,timestampMs:u,relativeX:i(u)}}).filter(c=>c!==null),k=n.map(c=>{const u=new Date(c.timestamp).getTime();return isNaN(u)?null:{message:c.message,type:c.type,timestampMs:u,relativeX:i(u)}}).filter(c=>c!==null);return{startMs:o,endMs:l,durationMs:d,mainLane:f,agentLanes:g,skillMarkers:N,errorMarkers:k}}function B(t){const s=t.match(/^mcp__[^_]+_[^_]+_[^_]+__(.+)$/);return s?s[1]:t}const Qe={Read:"#e09070",Grep:"#e09070",Glob:"#e09070",Write:"#34d399",Edit:"#34d399",NotebookEdit:"#34d399",Bash:"#fbbf24",Task:"#818cf8",TaskCreate:"#c084fc",TaskUpdate:"#c084fc",TaskList:"#c084fc",TaskGet:"#c084fc",Skill:"#fcd34d",WebSearch:"#22d3ee",WebFetch:"#22d3ee",EnterPlanMode:"#f472b6",ExitPlanMode:"#f472b6",AskUserQuestion:"#a78bfa"},Ve="#9ca3af";function z(t){return Qe[t]??Ve}const I=90,$=16,D=24,T=32,U=8,ee=4;function Je(t,s,a){const n=s-t;if(n<=0)return[];const r=Math.max(3,Math.round(a/120)),o=n/r,l=[5e3,1e4,15e3,3e4,6e4,2*6e4,5*6e4,10*6e4,15*6e4,30*6e4,60*6e4,120*6e4],d=l.find(g=>g>=o)??l[l.length-1],h=n<5*6e4?"HH:mm:ss":"HH:mm",p=Math.ceil(t/d)*d,f=[];for(let g=p;g<=s;g+=d){const N=(g-t)/n;f.push({ms:g,label:C(new Date(g),h),x:I+N*(a-I-$)})}return f}function et({data:t,width:s,onHover:a}){const n=v.useRef(null),r=s,o=r-I-$,l=t.skillMarkers.length>0,d=t.errorMarkers.length>0;let i=D;const h=i;i+=T;const p=[];for(let x=0;x<t.agentLanes.length;x++)i+=U,p.push(i),i+=T;let f=0;l&&(i+=U,f=i,i+=T);let g=0;d&&(i+=U,g=i,i+=T);const N=Math.max(i+8,80);function k(x){return I+x*o}const c=v.useCallback(x=>{if(!n.current)return{x:0,y:0};const j=n.current.getBoundingClientRect();return{x:x.clientX-j.left,y:x.clientY-j.top}},[]),u=Je(t.startMs,t.endMs,r);return e.jsxs("svg",{ref:n,width:r,height:N,className:"select-none",role:"img","aria-label":"Session timeline showing tool calls, agent runs, and skill invocations",onMouseLeave:()=>a(null,{x:0,y:0}),children:[e.jsx("line",{x1:I,y1:D-4,x2:r-$,y2:D-4,stroke:"#374151",strokeWidth:1}),u.map(x=>e.jsxs("g",{children:[e.jsx("line",{x1:x.x,y1:D-8,x2:x.x,y2:D-4,stroke:"#4b5563",strokeWidth:1}),e.jsx("text",{x:x.x,y:D-12,textAnchor:"middle",className:"fill-gray-500 text-[10px]",children:x.label})]},x.ms)),e.jsx("text",{x:4,y:h+T/2+4,className:"fill-gray-500 text-[11px] font-medium",children:"Main"}),e.jsx("line",{x1:I,y1:h+T/2,x2:r-$,y2:h+T/2,stroke:"#1f2937",strokeWidth:1,strokeDasharray:"2,4"}),t.mainLane.map(x=>e.jsx("circle",{cx:k(x.relativeX),cy:h+T/2,r:ee,fill:z(x.toolName),opacity:.85,className:"cursor-pointer transition-transform hover:opacity-100",onMouseEnter:j=>a({kind:"tool",toolName:x.toolName,timestamp:new Date(x.timestampMs).toISOString(),toolUseId:x.toolUseId},c(j)),onMouseLeave:()=>a(null,{x:0,y:0}),children:e.jsx("title",{children:x.toolName})},x.toolUseId)),t.agentLanes.map((x,j)=>e.jsx(tt,{lane:x,y:p[j],toX:k,laneHeight:T,onHover:a,getPosition:c},`${x.subagentType}-${j}`)),l&&e.jsxs(e.Fragment,{children:[e.jsx("text",{x:4,y:f+T/2+4,className:"fill-amber-400/70 text-[11px] font-medium",children:"Skills"}),e.jsx("line",{x1:I,y1:f+T/2,x2:r-$,y2:f+T/2,stroke:"#1f2937",strokeWidth:1,strokeDasharray:"2,4"}),t.skillMarkers.map((x,j)=>{const m=k(x.relativeX),b=f+T/2,y=5;return e.jsx("polygon",{points:`${m},${b-y} ${m+y},${b} ${m},${b+y} ${m-y},${b}`,fill:"#fbbf24",opacity:.85,className:"cursor-pointer hover:opacity-100",onMouseEnter:w=>a({kind:"skill",skill:x.skill,args:x.args,timestamp:new Date(x.timestampMs).toISOString()},c(w)),onMouseLeave:()=>a(null,{x:0,y:0}),children:e.jsxs("title",{children:["/",x.skill]})},`${x.skill}-${j}`)})]}),d&&e.jsxs(e.Fragment,{children:[e.jsx("text",{x:4,y:g+T/2+4,className:"fill-red-400/70 text-[11px] font-medium",children:"Errors"}),e.jsx("line",{x1:I,y1:g+T/2,x2:r-$,y2:g+T/2,stroke:"#1f2937",strokeWidth:1,strokeDasharray:"2,4"}),t.errorMarkers.map((x,j)=>{const m=k(x.relativeX),b=g+T/2,y=5;return e.jsxs("g",{className:"cursor-pointer hover:opacity-100",opacity:.85,onMouseEnter:w=>a({kind:"error",message:x.message,type:x.type,timestamp:new Date(x.timestampMs).toISOString()},c(w)),onMouseLeave:()=>a(null,{x:0,y:0}),children:[e.jsx("line",{x1:m-y,y1:b-y,x2:m+y,y2:b+y,stroke:"#f87171",strokeWidth:2,strokeLinecap:"round"}),e.jsx("line",{x1:m+y,y1:b-y,x2:m-y,y2:b+y,stroke:"#f87171",strokeWidth:2,strokeLinecap:"round"}),e.jsxs("title",{children:[x.type,": ",x.message]})]},`err-${j}`)})]})]})}function tt({lane:t,y:s,toX:a,laneHeight:n,onHover:r,getPosition:o}){const l=a(t.startX),d=Math.max(a(t.endX)-l,8),i=s+n/2,h=t.subagentType.length>10?t.subagentType.slice(0,10)+"...":t.subagentType;return e.jsxs("g",{children:[e.jsx("text",{x:4,y:i+4,className:"fill-indigo-400/70 text-[11px] font-medium",children:h}),e.jsx("rect",{x:l,y:s+2,width:d,height:n-4,rx:6,fill:"rgba(99, 102, 241, 0.08)",stroke:"rgba(99, 102, 241, 0.2)",strokeWidth:1,className:"cursor-pointer hover:fill-indigo-500/15",onMouseEnter:p=>r({kind:"agent",agent:t},o(p)),onMouseLeave:()=>r(null,{x:0,y:0}),children:e.jsxs("title",{children:[t.subagentType,": ",t.description]})}),e.jsx("line",{x1:l+4,y1:i,x2:l+d-4,y2:i,stroke:"rgba(99, 102, 241, 0.15)",strokeWidth:1}),t.toolDots.map((p,f)=>e.jsx("circle",{cx:a(p.relativeX),cy:i,r:ee-.5,fill:z(p.toolName),opacity:.75,className:"cursor-pointer hover:opacity-100",onMouseEnter:g=>r({kind:"tool",toolName:p.toolName,timestamp:new Date(t.startMs+(p.relativeX-t.startX)/(t.endX-t.startX)*(t.endMs-t.startMs)).toISOString(),toolUseId:`${t.subagentType}-${p.toolName}-${f}`},o(g)),onMouseLeave:()=>r(null,{x:0,y:0}),children:e.jsxs("title",{children:[p.toolName," (",t.subagentType,")"]})},`${p.toolName}-${f}`)),t.skills&&t.skills.length>0&&t.skills.map((p,f)=>{const g=t.startX+(t.endX-t.startX)/(t.skills.length+1)*(f+1),N=a(g),k=s+6,c=3;return e.jsx("polygon",{points:`${N},${k-c} ${N+c},${k} ${N},${k+c} ${N-c},${k}`,fill:"#fbbf24",opacity:.85,className:"cursor-pointer hover:opacity-100",onMouseEnter:u=>r({kind:"skill",skill:p.skill,args:p.args,timestamp:new Date(t.startMs).toISOString()},o(u)),onMouseLeave:()=>r(null,{x:0,y:0}),children:e.jsxs("title",{children:["/",p.skill," (",t.subagentType,")"]})},`skill-${p.skill}-${f}`)})]})}function st({item:t,position:s}){return e.jsxs("div",{className:"pointer-events-none absolute z-50 rounded-lg border border-gray-700 bg-gray-900 px-3 py-2 text-xs shadow-xl",style:{left:s.x,top:s.y,transform:"translate(-50%, -100%) translateY(-8px)"},children:[t.kind==="tool"&&e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-gray-100",children:B(t.toolName)}),e.jsx("div",{className:"text-gray-400",children:C(new Date(t.timestamp),"HH:mm:ss")}),e.jsxs("div",{className:"font-mono text-[10px] text-gray-600",children:[t.toolUseId.slice(0,16),"..."]})]}),t.kind==="agent"&&e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-indigo-300",children:t.agent.subagentType}),e.jsx("div",{className:"max-w-48 truncate text-gray-400",children:t.agent.description}),e.jsx("div",{className:"mt-1 flex items-center gap-2 text-gray-500",children:t.agent.durationMs!=null&&e.jsxs("span",{children:[C(new Date(t.agent.startMs),"HH:mm")," -"," ",C(new Date(t.agent.endMs),"HH:mm")," (",X(t.agent.durationMs),")"]})}),e.jsxs("div",{className:"flex items-center gap-2 text-gray-500",children:[t.agent.totalTokens!=null&&e.jsxs("span",{children:[M(t.agent.totalTokens)," tokens"]}),t.agent.totalToolUseCount!=null&&e.jsxs("span",{children:[t.agent.totalToolUseCount," tools"]})]})]}),t.kind==="skill"&&e.jsxs("div",{children:[e.jsxs("div",{className:"font-semibold text-amber-300",children:["/",t.skill]}),t.args&&e.jsx("div",{className:"text-gray-400",children:t.args}),e.jsx("div",{className:"text-gray-500",children:C(new Date(t.timestamp),"HH:mm:ss")})]}),t.kind==="error"&&e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-red-400",children:t.type}),e.jsx("div",{className:"max-w-48 truncate text-gray-400",children:t.message}),e.jsx("div",{className:"text-gray-500",children:C(new Date(t.timestamp),"HH:mm:ss")})]})]})}function at({toolNames:t}){const s=[...new Set(t)].slice(0,12);return s.length===0?null:e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 px-1 text-[10px] text-gray-500",children:[s.map(a=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:z(a)}}),e.jsx("span",{children:B(a)})]},a)),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"inline-block h-2 w-2 rotate-45 bg-amber-400"}),e.jsx("span",{children:"Skill"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-red-400 font-bold leading-none",children:"×"}),e.jsx("span",{children:"Error"})]})]})}function nt({turns:t,agents:s,skills:a,errors:n}){const r=v.useRef(null),[o,l]=v.useState(0),[d,i]=v.useState(1),[h,p]=v.useState(null);v.useEffect(()=>{if(!r.current)return;const m=new ResizeObserver(b=>{const y=b[0];y&&l(y.contentRect.width)});return m.observe(r.current),()=>m.disconnect()},[]);const f=v.useMemo(()=>Ze(t,s,a,n),[t,s,a,n]),g=v.useMemo(()=>{const m=f.mainLane.map(y=>y.toolName);for(const y of f.agentLanes)for(const w of y.toolDots)m.push(w.toolName);const b={};for(const y of m)b[y]=(b[y]??0)+1;return Object.entries(b).sort(([,y],[,w])=>w-y).map(([y])=>y)},[f]),N=(m,b)=>{p(m?{item:m,position:b}:null)};if(t.length===0)return e.jsx("div",{className:"py-8 text-center text-sm text-gray-500",children:"No timeline data available"});const k=new Set(s.map(m=>m.toolUseId)),c=new Set(a.map(m=>m.toolUseId));let u=0,x=0,j=0;for(const m of t)if(m.type==="user"&&m.message?.trim()&&u++,m.type==="assistant"){x++;for(const b of m.toolCalls)!k.has(b.toolUseId)&&!c.has(b.toolUseId)&&j++}return e.jsxs("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4",children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-4",children:[e.jsx(A,{label:"User commands",value:u,color:"blue"}),e.jsx(A,{label:"AI responses",value:x,color:"purple"}),j>0&&e.jsx(A,{label:"Tool calls",value:j,color:"gray"}),s.length>0&&e.jsx(A,{label:"Agents",value:s.length,color:"indigo"}),a.length>0&&e.jsx(A,{label:"Skills",value:a.length,color:"amber"}),n.length>0&&e.jsx(A,{label:"Errors",value:n.length,color:"red"})]}),e.jsxs("div",{className:"mb-3 flex items-start justify-between gap-2",children:[e.jsx("div",{className:"flex-1",children:g.length>0&&e.jsx(at,{toolNames:g})}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsx("button",{type:"button",onClick:()=>i(m=>Math.max(1,m-.5)),disabled:d<=1,className:"rounded bg-gray-800 px-2 py-0.5 text-xs text-gray-300 transition-colors hover:bg-gray-700 disabled:opacity-30",title:"Zoom out",children:"−"}),e.jsx("span",{className:"min-w-[3rem] text-center text-[10px] tabular-nums text-gray-500",children:d===1?"Fit":`${d.toFixed(1)}x`}),e.jsx("button",{type:"button",onClick:()=>i(m=>Math.min(8,m+.5)),disabled:d>=8,className:"rounded bg-gray-800 px-2 py-0.5 text-xs text-gray-300 transition-colors hover:bg-gray-700 disabled:opacity-30",title:"Zoom in",children:"+"}),d>1&&e.jsx("button",{type:"button",onClick:()=>i(1),className:"ml-1 rounded bg-gray-800 px-2 py-0.5 text-[10px] text-gray-400 transition-colors hover:bg-gray-700",title:"Reset zoom",children:"Reset"})]})]}),e.jsx("div",{ref:r,className:"relative overflow-x-auto",children:o>0&&e.jsxs(e.Fragment,{children:[e.jsx(et,{data:f,width:Math.max(o*d,400),onHover:N}),h&&e.jsx(st,{item:h.item,position:h.position})]})})]})}function A({label:t,value:s,color:a}){const n={blue:"bg-brand-500/15 text-brand-400",purple:"bg-purple-500/15 text-purple-400",gray:"bg-gray-800 text-gray-300",indigo:"bg-indigo-500/15 text-indigo-400",amber:"bg-amber-500/15 text-amber-400",red:"bg-red-500/15 text-red-400"};return e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`rounded-md px-2 py-1 text-sm font-bold tabular-nums ${n[a]}`,children:s}),e.jsx("span",{className:"text-[11px] text-gray-500",children:t})]})}function rt({contextWindow:t,tokens:s}){const[a,n]=v.useState(!1);if(!t)return e.jsx(ot,{tokens:s});const{contextLimit:r,modelName:o,systemOverhead:l,currentContextSize:d,messagesEstimate:i,freeSpace:h,autocompactBuffer:p,usagePercent:f,snapshots:g}=t,N=l/r*100,k=i/r*100,c=p/r*100,u=Math.max(0,100-N-k),x=o.replace(/^claude-/,"").split("-202")[0],j=g.map(m=>({turn:m.turnIndex,context:m.contextSize}));return e.jsxs("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-300",children:"Context Window"}),e.jsx("span",{className:"rounded bg-gray-800 px-1.5 py-0.5 text-[10px] font-mono text-gray-400",children:x})]}),e.jsxs("div",{className:"mt-1 flex items-baseline gap-1",children:[e.jsx("span",{className:"text-2xl font-bold text-white",children:M(d)}),e.jsxs("span",{className:"text-sm text-gray-500",children:["/ ",M(r)]}),e.jsxs("span",{className:"text-sm text-gray-400",children:["(",f,"%)"]})]}),e.jsx("p",{className:"text-[10px] text-gray-500",children:"~estimated from token usage"}),e.jsxs("div",{className:"mt-3 flex h-3 overflow-hidden rounded-full bg-gray-800",children:[e.jsx("div",{className:"bg-purple-500",style:{width:`${N}%`},title:`System: ~${M(l)}`}),e.jsx("div",{className:"bg-brand-500",style:{width:`${k}%`},title:`Messages: ~${M(i)}`}),u>0&&e.jsx(e.Fragment,{children:u>c?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bg-gray-700",style:{width:`${u-c}%`}}),e.jsx("div",{className:"autocompact-stripe",style:{width:`${Math.min(c,u)}%`}})]}):e.jsx("div",{className:"autocompact-stripe",style:{width:`${u}%`}})})]}),e.jsxs("div",{className:"mt-1 flex gap-3 text-[10px] text-gray-500",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-purple-500"}),"system"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-brand-500"}),"messages"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-gray-700"}),"free"]})]}),e.jsxs("div",{className:"mt-3 space-y-1.5",children:[e.jsx(L,{label:"System overhead",value:l,total:r,color:"bg-purple-500",prefix:"~"}),e.jsx(L,{label:"Messages",value:i,total:r,color:"bg-brand-500",prefix:"~"}),e.jsx(L,{label:"Autocompact buffer",value:p,total:r,color:"bg-amber-500"}),e.jsx(L,{label:"Free space",value:h,total:r,color:"bg-gray-600"})]}),j.length>1&&e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"mb-1 text-[10px] text-gray-500",children:"Context growth"}),e.jsx(we,{width:"100%",height:96,children:e.jsxs(Te,{data:j,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"contextGrad",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#d97757",stopOpacity:.3}),e.jsx("stop",{offset:"100%",stopColor:"#d97757",stopOpacity:.05})]})}),e.jsx(Me,{domain:[0,r],hide:!0}),e.jsx(Se,{contentStyle:{background:"#1c1c1a",border:"1px solid #3d3b36",borderRadius:"8px",fontSize:"11px"},labelFormatter:m=>`Turn ${m}`,formatter:m=>[M(m),"Context"]}),e.jsx(F,{y:r,stroke:"#ef4444",strokeDasharray:"4 4",strokeOpacity:.5}),e.jsx(F,{y:r-p,stroke:"#f59e0b",strokeDasharray:"2 4",strokeOpacity:.3}),e.jsx(Ce,{type:"stepAfter",dataKey:"context",stroke:"#d97757",fill:"url(#contextGrad)",strokeWidth:1.5,dot:!1})]})})]}),e.jsxs("button",{onClick:()=>n(!a),className:"mt-3 flex w-full items-center gap-1 text-xs text-gray-400 hover:text-gray-300 transition-colors",children:[e.jsx("span",{className:"text-[10px]",children:a?"▾":"▸"}),"Token Details"]}),a&&e.jsx(lt,{tokens:s}),e.jsx("style",{children:`
2
2
  .autocompact-stripe {
3
3
  background: repeating-linear-gradient(
4
4
  -45deg,
@@ -1 +1 @@
1
- import{S as te,B as L,C as v,s as _,D as m,p as F,E as Q,F as V,G as se,H as E,I as re,J as ne,K as k,n as J,r as w,q as Y,o as ie,M as ae,T as B,N as oe,P as ce}from"./main-CV28H4XG.js";function $(e){if(Array.isArray(e))return e.flatMap(a=>$(a));if(typeof e!="string")return[];const t=[];let s=0,n,i,c,r,o;const d=()=>{for(;s<e.length&&/\s/.test(e.charAt(s));)s+=1;return s<e.length},h=()=>(i=e.charAt(s),i!=="="&&i!==";"&&i!==",");for(;s<e.length;){for(n=s,o=!1;d();)if(i=e.charAt(s),i===","){for(c=s,s+=1,d(),r=s;s<e.length&&h();)s+=1;s<e.length&&e.charAt(s)==="="?(o=!0,s=r,t.push(e.slice(n,c)),n=s):s=c+1}else s+=1;(!o||s>=e.length)&&t.push(e.slice(n))}return t}function he(e){return e instanceof Headers?e:Array.isArray(e)?new Headers(e):typeof e=="object"?new Headers(e):null}function le(...e){return e.reduce((t,s)=>{const n=he(s);if(!n)return t;for(const[i,c]of n.entries())i==="set-cookie"?$(c).forEach(o=>t.append("set-cookie",o)):t.set(i,c);return t},new Headers)}var ue=class extends te{constructor(e,t){super(),this.options=t,this.#s=e,this.#n=null,this.#r=L(),this.bindMethods(),this.setOptions(t)}#s;#e=void 0;#p=void 0;#t=void 0;#a;#l;#r;#n;#v;#u;#d;#o;#c;#i;#f=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),W(this.#e,this.options)?this.#h():this.updateResult(),this.#R())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return P(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return P(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#m(),this.#O(),this.#e.removeObserver(this)}setOptions(e){const t=this.options,s=this.#e;if(this.options=this.#s.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof v(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#g(),this.#e.setOptions(this.options),t._defaulted&&!_(this.options,t)&&this.#s.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const n=this.hasListeners();n&&G(this.#e,s,this.options,t)&&this.#h(),this.updateResult(),n&&(this.#e!==s||v(this.options.enabled,this.#e)!==v(t.enabled,this.#e)||m(this.options.staleTime,this.#e)!==m(t.staleTime,this.#e))&&this.#y();const i=this.#w();n&&(this.#e!==s||v(this.options.enabled,this.#e)!==v(t.enabled,this.#e)||i!==this.#i)&&this.#b(i)}getOptimisticResult(e){const t=this.#s.getQueryCache().build(this.#s,e),s=this.createResult(t,e);return fe(this,s)&&(this.#t=s,this.#l=this.options,this.#a=this.#e.state),s}getCurrentResult(){return this.#t}trackResult(e,t){return new Proxy(e,{get:(s,n)=>(this.trackProp(n),t?.(n),n==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#r.status==="pending"&&this.#r.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(s,n))})}trackProp(e){this.#f.add(e)}getCurrentQuery(){return this.#e}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#s.defaultQueryOptions(e),s=this.#s.getQueryCache().build(this.#s,t);return s.fetch().then(()=>this.createResult(s,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#t))}#h(e){this.#g();let t=this.#e.fetch(this.options,e);return e?.throwOnError||(t=t.catch(F)),t}#y(){this.#m();const e=m(this.options.staleTime,this.#e);if(Q||this.#t.isStale||!V(e))return;const s=se(this.#t.dataUpdatedAt,e)+1;this.#o=E.setTimeout(()=>{this.#t.isStale||this.updateResult()},s)}#w(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#b(e){this.#O(),this.#i=e,!(Q||v(this.options.enabled,this.#e)===!1||!V(this.#i)||this.#i===0)&&(this.#c=E.setInterval(()=>{(this.options.refetchIntervalInBackground||re.isFocused())&&this.#h()},this.#i))}#R(){this.#y(),this.#b(this.#w())}#m(){this.#o&&(E.clearTimeout(this.#o),this.#o=void 0)}#O(){this.#c&&(E.clearInterval(this.#c),this.#c=void 0)}createResult(e,t){const s=this.#e,n=this.options,i=this.#t,c=this.#a,r=this.#l,d=e!==s?e.state:this.#p,{state:h}=e;let a={...h},l=!1,u;if(t._optimisticResults){const f=this.hasListeners(),R=!f&&W(e,t),O=f&&G(e,s,t,n);(R||O)&&(a={...a,...ne(h.data,e.options)}),t._optimisticResults==="isRestoring"&&(a.fetchStatus="idle")}let{error:y,errorUpdatedAt:C,status:p}=a;u=a.data;let N=!1;if(t.placeholderData!==void 0&&u===void 0&&p==="pending"){let f;i?.isPlaceholderData&&t.placeholderData===r?.placeholderData?(f=i.data,N=!0):f=typeof t.placeholderData=="function"?t.placeholderData(this.#d?.state.data,this.#d):t.placeholderData,f!==void 0&&(p="success",u=k(i?.data,f,t),l=!0)}if(t.select&&u!==void 0&&!N)if(i&&u===c?.data&&t.select===this.#v)u=this.#u;else try{this.#v=t.select,u=t.select(u),u=k(i?.data,u,t),this.#u=u,this.#n=null}catch(f){this.#n=f}this.#n&&(y=this.#n,u=this.#u,C=Date.now(),p="error");const M=a.fetchStatus==="fetching",I=p==="pending",x=p==="error",A=I&&M,j=u!==void 0,b={status:p,fetchStatus:a.fetchStatus,isPending:I,isSuccess:p==="success",isError:x,isInitialLoading:A,isLoading:A,data:u,dataUpdatedAt:a.dataUpdatedAt,error:y,errorUpdatedAt:C,failureCount:a.fetchFailureCount,failureReason:a.fetchFailureReason,errorUpdateCount:a.errorUpdateCount,isFetched:a.dataUpdateCount>0||a.errorUpdateCount>0,isFetchedAfterMount:a.dataUpdateCount>d.dataUpdateCount||a.errorUpdateCount>d.errorUpdateCount,isFetching:M,isRefetching:M&&!I,isLoadingError:x&&!j,isPaused:a.fetchStatus==="paused",isPlaceholderData:l,isRefetchError:x&&j,isStale:D(e,t),refetch:this.refetch,promise:this.#r,isEnabled:v(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const f=b.data!==void 0,R=b.status==="error"&&!f,O=S=>{R?S.reject(b.error):f&&S.resolve(b.data)},H=()=>{const S=this.#r=b.promise=L();O(S)},g=this.#r;switch(g.status){case"pending":e.queryHash===s.queryHash&&O(g);break;case"fulfilled":(R||b.data!==g.value)&&H();break;case"rejected":(!R||b.error!==g.reason)&&H();break}}return b}updateResult(){const e=this.#t,t=this.createResult(this.#e,this.options);if(this.#a=this.#e.state,this.#l=this.options,this.#a.data!==void 0&&(this.#d=this.#e),_(t,e))return;this.#t=t;const s=()=>{if(!e)return!0;const{notifyOnChangeProps:n}=this.options,i=typeof n=="function"?n():n;if(i==="all"||!i&&!this.#f.size)return!0;const c=new Set(i??this.#f);return this.options.throwOnError&&c.add("error"),Object.keys(this.#t).some(r=>{const o=r;return this.#t[o]!==e[o]&&c.has(o)})};this.#S({listeners:s()})}#g(){const e=this.#s.getQueryCache().build(this.#s,this.options);if(e===this.#e)return;const t=this.#e;this.#e=e,this.#p=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#R()}#S(e){J.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#t)}),this.#s.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function de(e,t){return v(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function W(e,t){return de(e,t)||e.state.data!==void 0&&P(e,t,t.refetchOnMount)}function P(e,t,s){if(v(t.enabled,e)!==!1&&m(t.staleTime,e)!=="static"){const n=typeof s=="function"?s(e):s;return n==="always"||n!==!1&&D(e,t)}return!1}function G(e,t,s,n){return(e!==t||v(n.enabled,e)===!1)&&(!s.suspense||e.state.status!=="error")&&D(e,s)}function D(e,t){return v(t.enabled,e)!==!1&&e.isStaleByTime(m(t.staleTime,e))}function fe(e,t){return!_(e.getCurrentResult(),t)}var X=w.createContext(!1),pe=()=>w.useContext(X);X.Provider;function ve(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var ye=w.createContext(ve()),we=()=>w.useContext(ye),be=(e,t,s)=>{const n=s?.state.error&&typeof e.throwOnError=="function"?Y(e.throwOnError,[s.state.error,s]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||n)&&(t.isReset()||(e.retryOnMount=!1))},Re=e=>{w.useEffect(()=>{e.clearReset()},[e])},me=({result:e,errorResetBoundary:t,throwOnError:s,query:n,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&n&&(i&&e.data===void 0||Y(s,[e.error,n])),Oe=e=>{if(e.suspense){const s=i=>i==="static"?i:Math.max(i??1e3,1e3),n=e.staleTime;e.staleTime=typeof n=="function"?(...i)=>s(n(...i)):s(n),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},ge=(e,t)=>e.isLoading&&e.isFetching&&!t,Se=(e,t)=>e?.suspense&&t.isPending,z=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});function Ee(e,t,s){const n=pe(),i=we(),c=ie(),r=c.defaultQueryOptions(e);c.getDefaultOptions().queries?._experimental_beforeQuery?.(r);const o=c.getQueryCache().get(r.queryHash);r._optimisticResults=n?"isRestoring":"optimistic",Oe(r),be(r,i,o),Re(i);const d=!c.getQueryCache().get(r.queryHash),[h]=w.useState(()=>new t(c,r)),a=h.getOptimisticResult(r),l=!n&&e.subscribed!==!1;if(w.useSyncExternalStore(w.useCallback(u=>{const y=l?h.subscribe(J.batchCalls(u)):F;return h.updateResult(),y},[h,l]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),w.useEffect(()=>{h.setOptions(r)},[r,h]),Se(r,a))throw z(r,h,i);if(me({result:a,errorResetBoundary:i,throwOnError:r.throwOnError,query:o,suspense:r.suspense}))throw a.error;return c.getDefaultOptions().queries?._experimental_afterQuery?.(r,a),r.experimental_prefetchInRender&&!Q&&ge(a,n)&&(d?z(r,h,i):o?.promise)?.catch(F).finally(()=>{h.updateResult()}),r.notifyOnChangeProps?a:h.trackResult(a)}function _e(e,t){return Ee(e,ue)}function Fe(e){return e}const Z=()=>{throw new Error("createServerOnlyFn() functions can only be called on the server!")};function K(e){return e!=="__proto__"&&e!=="constructor"&&e!=="prototype"}function U(e,t){const s=Object.create(null);if(e)for(const n of Object.keys(e))K(n)&&(s[n]=e[n]);if(t&&typeof t=="object")for(const n of Object.keys(t))K(n)&&(s[n]=t[n]);return s}function ee(e){return Object.create(null)}const T=(e,t)=>{const s=t||e||{};return typeof s.method>"u"&&(s.method="GET"),Object.assign(c=>{const r={...s,...c};return T(void 0,r)},{options:s,middleware:c=>{const r=[...s.middleware||[]];c.map(h=>{B in h?h.options.middleware&&r.push(...h.options.middleware):r.push(h)});const o={...s,middleware:r},d=T(void 0,o);return d[B]=!0,d},inputValidator:c=>{const r={...s,inputValidator:c};return T(void 0,r)},handler:(...c)=>{const[r,o]=c,d={...s,extractedFn:r,serverFn:o},h=[...d.middleware||[],Ie(d)];return Object.assign(async a=>{const l=await q(h,"client",{...r,...d,data:a?.data,headers:a?.headers,signal:a?.signal,fetch:a?.fetch,context:ee()}),u=ae(l.error);if(u)throw u;if(l.error)throw l.error;return l.result},{...r,__executeServer:async a=>{const l=Z(),u=l.contextAfterGlobalMiddlewares,y={...r,...a,serverFnMeta:r.serverFnMeta,context:U(u,a.context),request:l.request};return await q(h,"server",y).then(p=>({result:p.result,error:p.error,context:p.sendContext}))}})}})};async function q(e,t,s){const n=oe()?.functionMiddleware||[];let i=Ce([...n,...e]);if(t==="server"){const r=Z();r?.executedRequestMiddlewares&&(i=i.filter(o=>!r.executedRequestMiddlewares.has(o)))}const c=async r=>{const o=i.shift();if(!o)return r;try{"inputValidator"in o.options&&o.options.inputValidator&&t==="server"&&(r.data=await Me(o.options.inputValidator,r.data));let d;if(t==="client"?"client"in o.options&&(d=o.options.client):"server"in o.options&&(d=o.options.server),d){const a=await d({...r,next:async(l={})=>{const u={...r,...l,context:U(r.context,l.context),sendContext:U(r.sendContext,l.sendContext),headers:le(r.headers,l.headers),_callSiteFetch:r._callSiteFetch,fetch:r._callSiteFetch??l.fetch??r.fetch,result:l.result!==void 0?l.result:l instanceof Response?l:r.result,error:l.error??r.error},y=await c(u);if(y.error)throw y.error;return y}});if(ce(a))return{...r,error:a};if(a instanceof Response)return{...r,result:a};if(!a)throw new Error("User middleware returned undefined. You must call next() or return a result in your middlewares.");return a}return c(r)}catch(d){return{...r,error:d}}};return c({...s,headers:s.headers||{},sendContext:s.sendContext||{},context:s.context||ee(),_callSiteFetch:s.fetch})}function Ce(e,t=100){const s=new Set,n=[],i=(c,r)=>{if(r>t)throw new Error(`Middleware nesting depth exceeded maximum of ${t}. Check for circular references.`);c.forEach(o=>{o.options.middleware&&i(o.options.middleware,r+1),s.has(o)||(s.add(o),n.push(o))})};return i(e,0),n}async function Me(e,t){if(e==null)return{};if("~standard"in e){const s=await e["~standard"].validate(t);if(s.issues)throw new Error(JSON.stringify(s.issues,void 0,2));return s.value}if("parse"in e)return e.parse(t);if(typeof e=="function")return e(t);throw new Error("Invalid validator type!")}function Ie(e){return{"~types":void 0,options:{inputValidator:e.inputValidator,client:async({next:t,sendContext:s,fetch:n,...i})=>{const c={...i,context:s,fetch:n},r=await e.extractedFn?.(c);return t(r)},server:async({next:t,...s})=>{const n=await e.serverFn?.(s);return t({...s,result:n})}}}}export{T as c,Fe as q,_e as u};
1
+ import{S as te,B as L,C as v,s as _,D as m,p as F,E as Q,F as V,G as se,H as E,I as re,J as ne,K as k,n as J,r as w,q as Y,o as ie,M as ae,T as B,N as oe,P as ce}from"./main-BcKPK-4E.js";function $(e){if(Array.isArray(e))return e.flatMap(a=>$(a));if(typeof e!="string")return[];const t=[];let s=0,n,i,c,r,o;const d=()=>{for(;s<e.length&&/\s/.test(e.charAt(s));)s+=1;return s<e.length},h=()=>(i=e.charAt(s),i!=="="&&i!==";"&&i!==",");for(;s<e.length;){for(n=s,o=!1;d();)if(i=e.charAt(s),i===","){for(c=s,s+=1,d(),r=s;s<e.length&&h();)s+=1;s<e.length&&e.charAt(s)==="="?(o=!0,s=r,t.push(e.slice(n,c)),n=s):s=c+1}else s+=1;(!o||s>=e.length)&&t.push(e.slice(n))}return t}function he(e){return e instanceof Headers?e:Array.isArray(e)?new Headers(e):typeof e=="object"?new Headers(e):null}function le(...e){return e.reduce((t,s)=>{const n=he(s);if(!n)return t;for(const[i,c]of n.entries())i==="set-cookie"?$(c).forEach(o=>t.append("set-cookie",o)):t.set(i,c);return t},new Headers)}var ue=class extends te{constructor(e,t){super(),this.options=t,this.#s=e,this.#n=null,this.#r=L(),this.bindMethods(),this.setOptions(t)}#s;#e=void 0;#p=void 0;#t=void 0;#a;#l;#r;#n;#v;#u;#d;#o;#c;#i;#f=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),W(this.#e,this.options)?this.#h():this.updateResult(),this.#R())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return P(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return P(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#m(),this.#O(),this.#e.removeObserver(this)}setOptions(e){const t=this.options,s=this.#e;if(this.options=this.#s.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof v(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#g(),this.#e.setOptions(this.options),t._defaulted&&!_(this.options,t)&&this.#s.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const n=this.hasListeners();n&&G(this.#e,s,this.options,t)&&this.#h(),this.updateResult(),n&&(this.#e!==s||v(this.options.enabled,this.#e)!==v(t.enabled,this.#e)||m(this.options.staleTime,this.#e)!==m(t.staleTime,this.#e))&&this.#y();const i=this.#w();n&&(this.#e!==s||v(this.options.enabled,this.#e)!==v(t.enabled,this.#e)||i!==this.#i)&&this.#b(i)}getOptimisticResult(e){const t=this.#s.getQueryCache().build(this.#s,e),s=this.createResult(t,e);return fe(this,s)&&(this.#t=s,this.#l=this.options,this.#a=this.#e.state),s}getCurrentResult(){return this.#t}trackResult(e,t){return new Proxy(e,{get:(s,n)=>(this.trackProp(n),t?.(n),n==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#r.status==="pending"&&this.#r.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(s,n))})}trackProp(e){this.#f.add(e)}getCurrentQuery(){return this.#e}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#s.defaultQueryOptions(e),s=this.#s.getQueryCache().build(this.#s,t);return s.fetch().then(()=>this.createResult(s,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#t))}#h(e){this.#g();let t=this.#e.fetch(this.options,e);return e?.throwOnError||(t=t.catch(F)),t}#y(){this.#m();const e=m(this.options.staleTime,this.#e);if(Q||this.#t.isStale||!V(e))return;const s=se(this.#t.dataUpdatedAt,e)+1;this.#o=E.setTimeout(()=>{this.#t.isStale||this.updateResult()},s)}#w(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#b(e){this.#O(),this.#i=e,!(Q||v(this.options.enabled,this.#e)===!1||!V(this.#i)||this.#i===0)&&(this.#c=E.setInterval(()=>{(this.options.refetchIntervalInBackground||re.isFocused())&&this.#h()},this.#i))}#R(){this.#y(),this.#b(this.#w())}#m(){this.#o&&(E.clearTimeout(this.#o),this.#o=void 0)}#O(){this.#c&&(E.clearInterval(this.#c),this.#c=void 0)}createResult(e,t){const s=this.#e,n=this.options,i=this.#t,c=this.#a,r=this.#l,d=e!==s?e.state:this.#p,{state:h}=e;let a={...h},l=!1,u;if(t._optimisticResults){const f=this.hasListeners(),R=!f&&W(e,t),O=f&&G(e,s,t,n);(R||O)&&(a={...a,...ne(h.data,e.options)}),t._optimisticResults==="isRestoring"&&(a.fetchStatus="idle")}let{error:y,errorUpdatedAt:C,status:p}=a;u=a.data;let N=!1;if(t.placeholderData!==void 0&&u===void 0&&p==="pending"){let f;i?.isPlaceholderData&&t.placeholderData===r?.placeholderData?(f=i.data,N=!0):f=typeof t.placeholderData=="function"?t.placeholderData(this.#d?.state.data,this.#d):t.placeholderData,f!==void 0&&(p="success",u=k(i?.data,f,t),l=!0)}if(t.select&&u!==void 0&&!N)if(i&&u===c?.data&&t.select===this.#v)u=this.#u;else try{this.#v=t.select,u=t.select(u),u=k(i?.data,u,t),this.#u=u,this.#n=null}catch(f){this.#n=f}this.#n&&(y=this.#n,u=this.#u,C=Date.now(),p="error");const M=a.fetchStatus==="fetching",I=p==="pending",x=p==="error",A=I&&M,j=u!==void 0,b={status:p,fetchStatus:a.fetchStatus,isPending:I,isSuccess:p==="success",isError:x,isInitialLoading:A,isLoading:A,data:u,dataUpdatedAt:a.dataUpdatedAt,error:y,errorUpdatedAt:C,failureCount:a.fetchFailureCount,failureReason:a.fetchFailureReason,errorUpdateCount:a.errorUpdateCount,isFetched:a.dataUpdateCount>0||a.errorUpdateCount>0,isFetchedAfterMount:a.dataUpdateCount>d.dataUpdateCount||a.errorUpdateCount>d.errorUpdateCount,isFetching:M,isRefetching:M&&!I,isLoadingError:x&&!j,isPaused:a.fetchStatus==="paused",isPlaceholderData:l,isRefetchError:x&&j,isStale:D(e,t),refetch:this.refetch,promise:this.#r,isEnabled:v(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const f=b.data!==void 0,R=b.status==="error"&&!f,O=S=>{R?S.reject(b.error):f&&S.resolve(b.data)},H=()=>{const S=this.#r=b.promise=L();O(S)},g=this.#r;switch(g.status){case"pending":e.queryHash===s.queryHash&&O(g);break;case"fulfilled":(R||b.data!==g.value)&&H();break;case"rejected":(!R||b.error!==g.reason)&&H();break}}return b}updateResult(){const e=this.#t,t=this.createResult(this.#e,this.options);if(this.#a=this.#e.state,this.#l=this.options,this.#a.data!==void 0&&(this.#d=this.#e),_(t,e))return;this.#t=t;const s=()=>{if(!e)return!0;const{notifyOnChangeProps:n}=this.options,i=typeof n=="function"?n():n;if(i==="all"||!i&&!this.#f.size)return!0;const c=new Set(i??this.#f);return this.options.throwOnError&&c.add("error"),Object.keys(this.#t).some(r=>{const o=r;return this.#t[o]!==e[o]&&c.has(o)})};this.#S({listeners:s()})}#g(){const e=this.#s.getQueryCache().build(this.#s,this.options);if(e===this.#e)return;const t=this.#e;this.#e=e,this.#p=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#R()}#S(e){J.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#t)}),this.#s.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function de(e,t){return v(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function W(e,t){return de(e,t)||e.state.data!==void 0&&P(e,t,t.refetchOnMount)}function P(e,t,s){if(v(t.enabled,e)!==!1&&m(t.staleTime,e)!=="static"){const n=typeof s=="function"?s(e):s;return n==="always"||n!==!1&&D(e,t)}return!1}function G(e,t,s,n){return(e!==t||v(n.enabled,e)===!1)&&(!s.suspense||e.state.status!=="error")&&D(e,s)}function D(e,t){return v(t.enabled,e)!==!1&&e.isStaleByTime(m(t.staleTime,e))}function fe(e,t){return!_(e.getCurrentResult(),t)}var X=w.createContext(!1),pe=()=>w.useContext(X);X.Provider;function ve(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var ye=w.createContext(ve()),we=()=>w.useContext(ye),be=(e,t,s)=>{const n=s?.state.error&&typeof e.throwOnError=="function"?Y(e.throwOnError,[s.state.error,s]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||n)&&(t.isReset()||(e.retryOnMount=!1))},Re=e=>{w.useEffect(()=>{e.clearReset()},[e])},me=({result:e,errorResetBoundary:t,throwOnError:s,query:n,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&n&&(i&&e.data===void 0||Y(s,[e.error,n])),Oe=e=>{if(e.suspense){const s=i=>i==="static"?i:Math.max(i??1e3,1e3),n=e.staleTime;e.staleTime=typeof n=="function"?(...i)=>s(n(...i)):s(n),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},ge=(e,t)=>e.isLoading&&e.isFetching&&!t,Se=(e,t)=>e?.suspense&&t.isPending,z=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});function Ee(e,t,s){const n=pe(),i=we(),c=ie(),r=c.defaultQueryOptions(e);c.getDefaultOptions().queries?._experimental_beforeQuery?.(r);const o=c.getQueryCache().get(r.queryHash);r._optimisticResults=n?"isRestoring":"optimistic",Oe(r),be(r,i,o),Re(i);const d=!c.getQueryCache().get(r.queryHash),[h]=w.useState(()=>new t(c,r)),a=h.getOptimisticResult(r),l=!n&&e.subscribed!==!1;if(w.useSyncExternalStore(w.useCallback(u=>{const y=l?h.subscribe(J.batchCalls(u)):F;return h.updateResult(),y},[h,l]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),w.useEffect(()=>{h.setOptions(r)},[r,h]),Se(r,a))throw z(r,h,i);if(me({result:a,errorResetBoundary:i,throwOnError:r.throwOnError,query:o,suspense:r.suspense}))throw a.error;return c.getDefaultOptions().queries?._experimental_afterQuery?.(r,a),r.experimental_prefetchInRender&&!Q&&ge(a,n)&&(d?z(r,h,i):o?.promise)?.catch(F).finally(()=>{h.updateResult()}),r.notifyOnChangeProps?a:h.trackResult(a)}function _e(e,t){return Ee(e,ue)}function Fe(e){return e}const Z=()=>{throw new Error("createServerOnlyFn() functions can only be called on the server!")};function K(e){return e!=="__proto__"&&e!=="constructor"&&e!=="prototype"}function U(e,t){const s=Object.create(null);if(e)for(const n of Object.keys(e))K(n)&&(s[n]=e[n]);if(t&&typeof t=="object")for(const n of Object.keys(t))K(n)&&(s[n]=t[n]);return s}function ee(e){return Object.create(null)}const T=(e,t)=>{const s=t||e||{};return typeof s.method>"u"&&(s.method="GET"),Object.assign(c=>{const r={...s,...c};return T(void 0,r)},{options:s,middleware:c=>{const r=[...s.middleware||[]];c.map(h=>{B in h?h.options.middleware&&r.push(...h.options.middleware):r.push(h)});const o={...s,middleware:r},d=T(void 0,o);return d[B]=!0,d},inputValidator:c=>{const r={...s,inputValidator:c};return T(void 0,r)},handler:(...c)=>{const[r,o]=c,d={...s,extractedFn:r,serverFn:o},h=[...d.middleware||[],Ie(d)];return Object.assign(async a=>{const l=await q(h,"client",{...r,...d,data:a?.data,headers:a?.headers,signal:a?.signal,fetch:a?.fetch,context:ee()}),u=ae(l.error);if(u)throw u;if(l.error)throw l.error;return l.result},{...r,__executeServer:async a=>{const l=Z(),u=l.contextAfterGlobalMiddlewares,y={...r,...a,serverFnMeta:r.serverFnMeta,context:U(u,a.context),request:l.request};return await q(h,"server",y).then(p=>({result:p.result,error:p.error,context:p.sendContext}))}})}})};async function q(e,t,s){const n=oe()?.functionMiddleware||[];let i=Ce([...n,...e]);if(t==="server"){const r=Z();r?.executedRequestMiddlewares&&(i=i.filter(o=>!r.executedRequestMiddlewares.has(o)))}const c=async r=>{const o=i.shift();if(!o)return r;try{"inputValidator"in o.options&&o.options.inputValidator&&t==="server"&&(r.data=await Me(o.options.inputValidator,r.data));let d;if(t==="client"?"client"in o.options&&(d=o.options.client):"server"in o.options&&(d=o.options.server),d){const a=await d({...r,next:async(l={})=>{const u={...r,...l,context:U(r.context,l.context),sendContext:U(r.sendContext,l.sendContext),headers:le(r.headers,l.headers),_callSiteFetch:r._callSiteFetch,fetch:r._callSiteFetch??l.fetch??r.fetch,result:l.result!==void 0?l.result:l instanceof Response?l:r.result,error:l.error??r.error},y=await c(u);if(y.error)throw y.error;return y}});if(ce(a))return{...r,error:a};if(a instanceof Response)return{...r,result:a};if(!a)throw new Error("User middleware returned undefined. You must call next() or return a result in your middlewares.");return a}return c(r)}catch(d){return{...r,error:d}}};return c({...s,headers:s.headers||{},sendContext:s.sendContext||{},context:s.context||ee(),_callSiteFetch:s.fetch})}function Ce(e,t=100){const s=new Set,n=[],i=(c,r)=>{if(r>t)throw new Error(`Middleware nesting depth exceeded maximum of ${t}. Check for circular references.`);c.forEach(o=>{o.options.middleware&&i(o.options.middleware,r+1),s.has(o)||(s.add(o),n.push(o))})};return i(e,0),n}async function Me(e,t){if(e==null)return{};if("~standard"in e){const s=await e["~standard"].validate(t);if(s.issues)throw new Error(JSON.stringify(s.issues,void 0,2));return s.value}if("parse"in e)return e.parse(t);if(typeof e=="function")return e(t);throw new Error("Invalid validator type!")}function Ie(e){return{"~types":void 0,options:{inputValidator:e.inputValidator,client:async({next:t,sendContext:s,fetch:n,...i})=>{const c={...i,context:s,fetch:n},r=await e.extractedFn?.(c);return t(r)},server:async({next:t,...s})=>{const n=await e.serverFn?.(s);return t({...s,result:n})}}}}export{T as c,Fe as q,_e as u};
@@ -1 +1 @@
1
- import{j as e,r as g,b as v,L as T,d as N,e as S}from"./main-CV28H4XG.js";import{u as j}from"./createServerFn-BYTDoNe-.js";import{p as k,a as D}from"./sessions.queries-tzrs5GhP.js";import{d as w,e as R,h as L}from"./format-Bsprb3az.js";function M({isActive:t}){return t?e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-emerald-500/15 px-2.5 py-0.5 text-xs font-medium text-emerald-400",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-emerald-500"})]}),"Active"]}):e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-gray-500/15 px-2.5 py-0.5 text-xs font-medium text-gray-400",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-gray-500"}),"Completed"]})}function $({startedAt:t}){const[n,a]=g.useState(()=>Date.now()-new Date(t).getTime());return g.useEffect(()=>{const l=setInterval(()=>{a(Date.now()-new Date(t).getTime())},1e3);return()=>clearInterval(l)},[t]),e.jsx("span",{className:"text-emerald-400",children:w(n)})}function B({session:t}){const{privacyMode:n,anonymizePath:a,anonymizeProjectName:l,anonymizeBranch:i}=v(),r=n?l(t.projectName):t.projectName,c=t.cwd?a(t.cwd,t.projectName):null,m=t.branch?i(t.branch):null;return e.jsxs(T,{to:"/sessions/$sessionId",params:{sessionId:t.sessionId},search:{project:t.projectPath},className:"group block rounded-xl border border-gray-800 bg-gray-900/50 p-4 transition-all hover:border-gray-700 hover:bg-gray-900",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"truncate text-sm font-semibold text-white",children:r}),e.jsx(M,{isActive:t.isActive})]}),m&&e.jsx("p",{className:"mt-1 truncate text-xs text-gray-500",children:e.jsx("span",{className:"font-mono",children:m})})]}),e.jsx("span",{className:"shrink-0 text-xs text-gray-500",children:R(t.lastActiveAt)})]}),e.jsxs("div",{className:"mt-3 flex items-center gap-4 text-xs text-gray-400",children:[e.jsx("span",{title:"Duration",children:t.isActive?e.jsx($,{startedAt:t.startedAt}):w(t.durationMs)}),e.jsxs("span",{title:"Messages",children:[t.messageCount," msgs"]}),t.model&&e.jsx("span",{title:"Model",className:"truncate font-mono text-gray-500",children:t.model.replace(/^claude-/,"").split("-202")[0]}),e.jsx("span",{title:"File size",className:"text-gray-500",children:L(t.fileSizeBytes)})]}),c&&e.jsx("p",{className:"mt-2 truncate text-xs font-mono text-gray-600",children:c})]})}function _({projects:t,activeCount:n}){const a=N(),{search:l,status:i,project:r}=S.useSearch(),{privacyMode:c,anonymizeProjectName:m}=v(),[p,d]=g.useState(l),o=g.useRef(null);g.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]),g.useEffect(()=>{d(l)},[l]);function f(s){d(s),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{a({to:"/sessions",search:h=>({...h,search:s,page:1})})},300)}function y(s){a({to:"/sessions",search:h=>({...h,status:s,page:1})})}function b(s){a({to:"/sessions",search:h=>({...h,project:s,page:1})})}return e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("input",{type:"text",placeholder:"Search sessions...",value:p,onChange:s=>f(s.target.value),className:"rounded-lg border border-gray-700 bg-gray-800/50 px-3 py-1.5 text-sm text-gray-200 placeholder-gray-500 outline-none focus:border-brand-500 focus:ring-1 focus:ring-brand-500"}),e.jsx("div",{className:"flex rounded-lg border border-gray-700 text-xs",children:["all","active","completed"].map(s=>e.jsxs("button",{onClick:()=>y(s),className:`px-3 py-1.5 capitalize transition-colors ${i===s?"bg-gray-700 text-white":"text-gray-400 hover:text-gray-200"} ${s==="all"?"rounded-l-lg":""} ${s==="completed"?"rounded-r-lg":""}`,children:[s,s==="active"&&n>0&&e.jsxs("span",{className:"ml-1 text-emerald-400",children:["(",n,")"]})]},s))}),t.length>1&&e.jsxs("select",{value:r,onChange:s=>b(s.target.value),className:"rounded-lg border border-gray-700 bg-gray-800/50 px-3 py-1.5 text-sm text-gray-200 outline-none focus:border-brand-500",children:[e.jsx("option",{value:"",children:"All projects"}),t.map(s=>e.jsx("option",{value:s,children:c?m(s):s},s))]})]})}const P="claude-dashboard:page-size",C=[5,10,25,50];function A(t){return C.includes(t)}function Q(){if(typeof window>"u")return null;try{const t=localStorage.getItem(P);if(t!==null){const n=Number(t);if(A(n))return n}}catch{}return null}function F(){const[t,n]=g.useState(Q),a=g.useCallback(l=>{if(A(l))try{localStorage.setItem(P,String(l)),n(l)}catch{}},[]);return{storedPageSize:t,setPageSize:a}}function V({page:t,totalPages:n,totalCount:a,pageSize:l,onPageChange:i,onPageSizeChange:r}){if(a===0)return null;const c=(t-1)*l+1,m=Math.min(t*l,a),p=n>1,d=p?G(t,n):[];return e.jsxs("div",{className:"flex flex-col items-center gap-3 sm:flex-row sm:justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("select",{value:l,onChange:o=>r(Number(o.target.value)),className:"rounded-lg border border-gray-700 bg-gray-800/50 px-2 py-1 text-xs text-gray-200 outline-none focus:border-brand-500",children:C.map(o=>e.jsxs("option",{value:o,children:[o," / page"]},o))}),e.jsxs("p",{className:"text-xs text-gray-400",children:["Showing"," ",e.jsxs("span",{className:"font-mono text-gray-300",children:[c,"-",m]})," ","of"," ",e.jsx("span",{className:"font-mono text-gray-300",children:a})," sessions"]})]}),p&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>i(t-1),disabled:t<=1,className:"rounded-lg border border-gray-700 bg-gray-800 px-2.5 py-1.5 text-xs text-gray-400 transition-colors hover:bg-gray-700 hover:text-gray-200 disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-gray-800 disabled:hover:text-gray-400",children:"Previous"}),d.map((o,f)=>o==="ellipsis"?e.jsx("span",{className:"px-1.5 text-xs text-gray-500",children:"..."},`ellipsis-${f}`):e.jsx("button",{onClick:()=>i(o),className:`min-w-[2rem] rounded-lg px-2 py-1.5 text-xs font-mono transition-colors ${o===t?"bg-brand-600 text-white":"border border-gray-700 bg-gray-800 text-gray-400 hover:bg-gray-700 hover:text-gray-200"}`,children:o},o)),e.jsx("button",{onClick:()=>i(t+1),disabled:t>=n,className:"rounded-lg border border-gray-700 bg-gray-800 px-2.5 py-1.5 text-xs text-gray-400 transition-colors hover:bg-gray-700 hover:text-gray-200 disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-gray-800 disabled:hover:text-gray-400",children:"Next"})]})]})}function G(t,n){if(n<=7)return Array.from({length:n},(r,c)=>c+1);const a=new Set;a.add(1),a.add(n);for(let r=t-2;r<=t+2;r++)r>=1&&r<=n&&a.add(r);const l=Array.from(a).sort((r,c)=>r-c),i=[];for(let r=0;r<l.length;r++)r>0&&l[r]-l[r-1]>1&&i.push("ellipsis"),i.push(l[r]);return i}function K(){const t=N(),{page:n,pageSize:a,search:l,status:i,project:r}=S.useSearch(),{storedPageSize:c,setPageSize:m}=F(),p=g.useRef(!1);g.useEffect(()=>{c!==null&&!p.current&&c!==a&&(p.current=!0,t({to:"/sessions",search:u=>({...u,pageSize:c,page:1}),replace:!0}))},[c,a,t]);const{data:d,isLoading:o}=j(k({page:n,pageSize:a,search:l,status:i,project:r})),{data:f=[]}=j(D),y=g.useMemo(()=>{if(!d)return[];const u=new Set(f.map(x=>x.sessionId));return d.sessions.map(x=>({...x,isActive:u.has(x.sessionId)||x.isActive}))},[d,f]);function b(u){t({to:"/sessions",search:x=>({...x,page:u})})}function s(u){m(u),t({to:"/sessions",search:x=>({...x,pageSize:u,page:1})})}if(o)return e.jsx("div",{className:"space-y-3",children:Array.from({length:a}).map((u,x)=>e.jsx("div",{className:"h-28 animate-pulse rounded-xl border border-gray-800 bg-gray-900/50"},x))});const h=d?.totalCount??0,z=d?.totalPages??1,I=d?.projects??[],E=f.length;return e.jsxs("div",{children:[e.jsx(_,{projects:I,activeCount:E}),e.jsx("div",{className:"mt-4 space-y-2",children:y.length===0?e.jsx("div",{className:"py-12 text-center text-sm text-gray-500",children:h===0&&!l&&i==="all"&&!r?"No sessions found in ~/.claude":"No sessions match your filters"}):y.map(u=>e.jsx(B,{session:u},u.sessionId))}),e.jsx("div",{className:"mt-4",children:e.jsx(V,{page:d?.page??n,totalPages:z,totalCount:h,pageSize:a,onPageChange:b,onPageSizeChange:s})})]})}function H(){return e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-white",children:"Sessions"}),e.jsx("p",{className:"mt-1 text-sm text-gray-400",children:"All Claude Code sessions from ~/.claude"}),e.jsx("div",{className:"mt-6",children:e.jsx(K,{})})]})}export{H as component};
1
+ import{j as e,r as g,b as v,L as T,d as N,e as S}from"./main-BcKPK-4E.js";import{u as j}from"./createServerFn-BLR4iNR3.js";import{p as k,a as D}from"./sessions.queries-CHKiZnLm.js";import{d as w,e as R,h as L}from"./format-Bsprb3az.js";function M({isActive:t}){return t?e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-emerald-500/15 px-2.5 py-0.5 text-xs font-medium text-emerald-400",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-emerald-500"})]}),"Active"]}):e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-gray-500/15 px-2.5 py-0.5 text-xs font-medium text-gray-400",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-gray-500"}),"Completed"]})}function $({startedAt:t}){const[n,a]=g.useState(()=>Date.now()-new Date(t).getTime());return g.useEffect(()=>{const l=setInterval(()=>{a(Date.now()-new Date(t).getTime())},1e3);return()=>clearInterval(l)},[t]),e.jsx("span",{className:"text-emerald-400",children:w(n)})}function B({session:t}){const{privacyMode:n,anonymizePath:a,anonymizeProjectName:l,anonymizeBranch:i}=v(),r=n?l(t.projectName):t.projectName,c=t.cwd?a(t.cwd,t.projectName):null,m=t.branch?i(t.branch):null;return e.jsxs(T,{to:"/sessions/$sessionId",params:{sessionId:t.sessionId},search:{project:t.projectPath},className:"group block rounded-xl border border-gray-800 bg-gray-900/50 p-4 transition-all hover:border-gray-700 hover:bg-gray-900",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"truncate text-sm font-semibold text-white",children:r}),e.jsx(M,{isActive:t.isActive})]}),m&&e.jsx("p",{className:"mt-1 truncate text-xs text-gray-500",children:e.jsx("span",{className:"font-mono",children:m})})]}),e.jsx("span",{className:"shrink-0 text-xs text-gray-500",children:R(t.lastActiveAt)})]}),e.jsxs("div",{className:"mt-3 flex items-center gap-4 text-xs text-gray-400",children:[e.jsx("span",{title:"Duration",children:t.isActive?e.jsx($,{startedAt:t.startedAt}):w(t.durationMs)}),e.jsxs("span",{title:"Messages",children:[t.messageCount," msgs"]}),t.model&&e.jsx("span",{title:"Model",className:"truncate font-mono text-gray-500",children:t.model.replace(/^claude-/,"").split("-202")[0]}),e.jsx("span",{title:"File size",className:"text-gray-500",children:L(t.fileSizeBytes)})]}),c&&e.jsx("p",{className:"mt-2 truncate text-xs font-mono text-gray-600",children:c})]})}function _({projects:t,activeCount:n}){const a=N(),{search:l,status:i,project:r}=S.useSearch(),{privacyMode:c,anonymizeProjectName:m}=v(),[p,d]=g.useState(l),o=g.useRef(null);g.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]),g.useEffect(()=>{d(l)},[l]);function f(s){d(s),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{a({to:"/sessions",search:h=>({...h,search:s,page:1})})},300)}function y(s){a({to:"/sessions",search:h=>({...h,status:s,page:1})})}function b(s){a({to:"/sessions",search:h=>({...h,project:s,page:1})})}return e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("input",{type:"text",placeholder:"Search sessions...",value:p,onChange:s=>f(s.target.value),className:"rounded-lg border border-gray-700 bg-gray-800/50 px-3 py-1.5 text-sm text-gray-200 placeholder-gray-500 outline-none focus:border-brand-500 focus:ring-1 focus:ring-brand-500"}),e.jsx("div",{className:"flex rounded-lg border border-gray-700 text-xs",children:["all","active","completed"].map(s=>e.jsxs("button",{onClick:()=>y(s),className:`px-3 py-1.5 capitalize transition-colors ${i===s?"bg-gray-700 text-white":"text-gray-400 hover:text-gray-200"} ${s==="all"?"rounded-l-lg":""} ${s==="completed"?"rounded-r-lg":""}`,children:[s,s==="active"&&n>0&&e.jsxs("span",{className:"ml-1 text-emerald-400",children:["(",n,")"]})]},s))}),t.length>1&&e.jsxs("select",{value:r,onChange:s=>b(s.target.value),className:"rounded-lg border border-gray-700 bg-gray-800/50 px-3 py-1.5 text-sm text-gray-200 outline-none focus:border-brand-500",children:[e.jsx("option",{value:"",children:"All projects"}),t.map(s=>e.jsx("option",{value:s,children:c?m(s):s},s))]})]})}const P="claude-dashboard:page-size",C=[5,10,25,50];function A(t){return C.includes(t)}function Q(){if(typeof window>"u")return null;try{const t=localStorage.getItem(P);if(t!==null){const n=Number(t);if(A(n))return n}}catch{}return null}function F(){const[t,n]=g.useState(Q),a=g.useCallback(l=>{if(A(l))try{localStorage.setItem(P,String(l)),n(l)}catch{}},[]);return{storedPageSize:t,setPageSize:a}}function V({page:t,totalPages:n,totalCount:a,pageSize:l,onPageChange:i,onPageSizeChange:r}){if(a===0)return null;const c=(t-1)*l+1,m=Math.min(t*l,a),p=n>1,d=p?G(t,n):[];return e.jsxs("div",{className:"flex flex-col items-center gap-3 sm:flex-row sm:justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("select",{value:l,onChange:o=>r(Number(o.target.value)),className:"rounded-lg border border-gray-700 bg-gray-800/50 px-2 py-1 text-xs text-gray-200 outline-none focus:border-brand-500",children:C.map(o=>e.jsxs("option",{value:o,children:[o," / page"]},o))}),e.jsxs("p",{className:"text-xs text-gray-400",children:["Showing"," ",e.jsxs("span",{className:"font-mono text-gray-300",children:[c,"-",m]})," ","of"," ",e.jsx("span",{className:"font-mono text-gray-300",children:a})," sessions"]})]}),p&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>i(t-1),disabled:t<=1,className:"rounded-lg border border-gray-700 bg-gray-800 px-2.5 py-1.5 text-xs text-gray-400 transition-colors hover:bg-gray-700 hover:text-gray-200 disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-gray-800 disabled:hover:text-gray-400",children:"Previous"}),d.map((o,f)=>o==="ellipsis"?e.jsx("span",{className:"px-1.5 text-xs text-gray-500",children:"..."},`ellipsis-${f}`):e.jsx("button",{onClick:()=>i(o),className:`min-w-[2rem] rounded-lg px-2 py-1.5 text-xs font-mono transition-colors ${o===t?"bg-brand-600 text-white":"border border-gray-700 bg-gray-800 text-gray-400 hover:bg-gray-700 hover:text-gray-200"}`,children:o},o)),e.jsx("button",{onClick:()=>i(t+1),disabled:t>=n,className:"rounded-lg border border-gray-700 bg-gray-800 px-2.5 py-1.5 text-xs text-gray-400 transition-colors hover:bg-gray-700 hover:text-gray-200 disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-gray-800 disabled:hover:text-gray-400",children:"Next"})]})]})}function G(t,n){if(n<=7)return Array.from({length:n},(r,c)=>c+1);const a=new Set;a.add(1),a.add(n);for(let r=t-2;r<=t+2;r++)r>=1&&r<=n&&a.add(r);const l=Array.from(a).sort((r,c)=>r-c),i=[];for(let r=0;r<l.length;r++)r>0&&l[r]-l[r-1]>1&&i.push("ellipsis"),i.push(l[r]);return i}function K(){const t=N(),{page:n,pageSize:a,search:l,status:i,project:r}=S.useSearch(),{storedPageSize:c,setPageSize:m}=F(),p=g.useRef(!1);g.useEffect(()=>{c!==null&&!p.current&&c!==a&&(p.current=!0,t({to:"/sessions",search:u=>({...u,pageSize:c,page:1}),replace:!0}))},[c,a,t]);const{data:d,isLoading:o}=j(k({page:n,pageSize:a,search:l,status:i,project:r})),{data:f=[]}=j(D),y=g.useMemo(()=>{if(!d)return[];const u=new Set(f.map(x=>x.sessionId));return d.sessions.map(x=>({...x,isActive:u.has(x.sessionId)||x.isActive}))},[d,f]);function b(u){t({to:"/sessions",search:x=>({...x,page:u})})}function s(u){m(u),t({to:"/sessions",search:x=>({...x,pageSize:u,page:1})})}if(o)return e.jsx("div",{className:"space-y-3",children:Array.from({length:a}).map((u,x)=>e.jsx("div",{className:"h-28 animate-pulse rounded-xl border border-gray-800 bg-gray-900/50"},x))});const h=d?.totalCount??0,z=d?.totalPages??1,I=d?.projects??[],E=f.length;return e.jsxs("div",{children:[e.jsx(_,{projects:I,activeCount:E}),e.jsx("div",{className:"mt-4 space-y-2",children:y.length===0?e.jsx("div",{className:"py-12 text-center text-sm text-gray-500",children:h===0&&!l&&i==="all"&&!r?"No sessions found in ~/.claude":"No sessions match your filters"}):y.map(u=>e.jsx(B,{session:u},u.sessionId))}),e.jsx("div",{className:"mt-4",children:e.jsx(V,{page:d?.page??n,totalPages:z,totalCount:h,pageSize:a,onPageChange:b,onPageSizeChange:s})})]})}function H(){return e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-white",children:"Sessions"}),e.jsx("p",{className:"mt-1 text-sm text-gray-400",children:"All Claude Code sessions from ~/.claude"}),e.jsx("div",{className:"mt-6",children:e.jsx(K,{})})]})}export{H as component};