memhouse 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -5
- package/bin/memhouse.js +75 -3
- package/editors/adapter-errors.js +52 -0
- package/editors/antigravity.js +32 -3
- package/editors/cursor.js +67 -7
- package/editors/goose.js +35 -7
- package/editors/index.js +97 -2
- package/editors/opencode.js +71 -13
- package/editors/zed.js +75 -10
- package/mem-house/delivery/AGENT-INSTALL.md +53 -23
- package/mem-house/delivery/kernel-install.md +15 -8
- package/mem-house/shipper/ship.js +63 -4
- package/package.json +5 -2
- package/public/assets/{index-BsgjOSTv.js → index-CCPh7a2Z.js} +2 -2
- package/public/index.html +1 -1
- package/ui/src/pages/SqlViewer.jsx +35 -9
|
@@ -63,11 +63,11 @@ Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}
|
|
|
63
63
|
`).length&&(0,F.jsxs)(`div`,{className:`px-2`,style:{color:`var(--c-text3)`},children:[` ... `,(e.old||``).split(`
|
|
64
64
|
`).length-8,` more lines`]}),e.new&&n.map((e,t)=>(0,F.jsxs)(`div`,{className:`px-2`,style:{background:`rgba(52,211,153,0.07)`,color:`#34d399`},children:[(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`,userSelect:`none`},children:`+ `}),e]},`n`+t)),e.new&&n.length<(e.new||``).split(`
|
|
65
65
|
`).length&&(0,F.jsxs)(`div`,{className:`px-2`,style:{color:`var(--c-text3)`},children:[` ... `,(e.new||``).split(`
|
|
66
|
-
`).length-8,` more lines`]})]})}function mE({call:e,toolName:t,index:n}){let[r,i]=(0,S.useState)(!1),a=dE(t,e.args),o=fE(e.args),s=e.folder?e.folder.split(`/`).pop():null,c=o||e.args&&Object.keys(e.args).length>0;return(0,F.jsxs)(`div`,{className:`px-2 py-1 text-[11px]`,style:{background:n%2==0?`var(--c-code-bg)`:`transparent`},children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-2 cursor-pointer`,onClick:()=>c&&i(!r),children:[(0,F.jsx)(Gh,{source:e.source,size:10}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[a&&(0,F.jsx)(`div`,{className:`font-mono truncate`,style:{color:`var(--c-white)`},title:a,children:a}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(`span`,{children:q(e.source)}),s&&(0,F.jsxs)(`span`,{children:[`· `,s]}),e.timestamp&&(0,F.jsxs)(`span`,{children:[`· `,new Date(e.timestamp).toLocaleDateString()]}),c&&(0,F.jsx)(`span`,{children:r?`▾`:`▸`})]})]})]}),r&&o&&(0,F.jsx)(pE,{diff:o}),r&&!o&&e.args&&Object.keys(e.args).length>0&&(0,F.jsx)(`pre`,{className:`mt-1 px-2 py-1 text-[10px] overflow-x-auto whitespace-pre-wrap break-all`,style:{background:`var(--c-code-bg)`,color:`var(--c-text2)`},children:JSON.stringify(e.args,null,2)})]})}function hE({toolName:e,folder:t,editor:n,dateRange:r,onClose:i}){let[a,o]=(0,S.useState)(null),[s,c]=(0,S.useState)(!0),l=t?t.split(`/`).pop():null;return(0,S.useEffect)(()=>{c(!0),ta(e,{folder:t||void 0,editor:n||void 0,...jh(r)}).then(e=>{o(e),c(!1)})},[e,t,n,r]),(0,F.jsxs)(`div`,{className:`card p-3 fade-in`,style:{borderColor:`rgba(99,102,241,0.3)`},children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(Oi,{size:12,style:{color:`var(--c-accent)`}}),(0,F.jsx)(`span`,{className:`text-xs font-bold`,style:{color:`var(--c-white)`},children:e}),(0,F.jsxs)(`span`,{className:`text-[11px]`,style:{color:`var(--c-text2)`},children:[a?`${a.length} calls`:`...`,a&&l?` in ${l}`:``]})]}),(0,F.jsx)(`button`,{onClick:i,className:`p-0.5`,style:{color:`var(--c-text2)`},children:(0,F.jsx)(ki,{size:12})})]}),s?(0,F.jsx)(`div`,{className:`text-[11px] py-4 text-center`,style:{color:`var(--c-text3)`},children:`loading...`}):a&&a.length>0?(0,F.jsx)(`div`,{className:`max-h-[500px] overflow-y-auto scrollbar-thin space-y-0.5`,children:a.map((t,n)=>(0,F.jsx)(mE,{call:t,toolName:e,index:n},n))}):(0,F.jsx)(`div`,{className:`text-[11px] py-4 text-center`,style:{color:`var(--c-text3)`},children:`no calls found`})]})}function gE({segments:e,height:t=6}){let n=e.reduce((e,t)=>e+t.value,0);return n===0?null:(0,F.jsx)(`div`,{className:`flex w-full rounded-full overflow-hidden`,style:{height:t},children:e.filter(e=>e.value>0).map((e,t)=>(0,F.jsx)(`div`,{title:`${e.label}: ${J(e.value)}`,className:`h-full transition-all`,style:{width:`${(e.value/n*100).toFixed(1)}%`,background:e.color}},t))})}function _E({overview:e}){let[t,n]=(0,S.useState)(``),[r,i]=(0,S.useState)(``),[a,o]=(0,S.useState)(null),[s,c]=(0,S.useState)(null),[l,u]=(0,S.useState)(!1),[d,f]=(0,S.useState)(null),[p,m]=(0,S.useState)(null),h=(0,S.useRef)(null),{dark:g}=tr(),_=g?`#a0a0a0`:`#444`,v=g?`#555`:`#999`,y=g?`rgba(255,255,255,0.03)`:`rgba(0,0,0,0.06)`,b=g?`#9ca3af`:`#555`,x=e?.editors||[],C=e?.topProjects||[];async function w(){u(!0);let e=jh(a),[n,i]=await Promise.all([Wi({editor:t,folder:r||void 0,limit:500,...e}),Ji({editor:t,folder:r||void 0,...e})]);c(n),m(i),u(!1)}(0,S.useEffect)(()=>{w()},[t,r,a]);let T=s?.topTools?.slice(0,15)||[],E=s?.topModels?.slice(0,10)||[],D=(0,S.useMemo)(()=>{if(!s)return null;let e=s.totalInputTokens+s.totalOutputTokens+s.totalCacheRead+s.totalCacheWrite,t=s.analyzedChats>0?(s.totalMessages/s.analyzedChats).toFixed(1):0,n=s.analyzedChats>0?(s.totalToolCalls/s.analyzedChats).toFixed(1):0,r=s.totalMessages>0?Math.round(e/s.totalMessages):0,i=s.totalInputTokens+s.totalCacheRead+s.totalCacheWrite;return{totalTok:e,msgsPerSession:t,toolsPerSession:n,tokPerMsg:r,cacheHitRate:i>0?(s.totalCacheRead/i*100).toFixed(1):0,outputRatio:i>0?(s.totalOutputTokens/i).toFixed(3):0,aiVsHuman:s.totalUserChars>0?(s.totalAssistantChars/s.totalUserChars).toFixed(1):0}},[s]),O=(0,S.useMemo)(()=>T.length>0?uE(T):[],[T]);function k(e,t){if(t.length>0){let e=T[t[0].index]?.name;e&&f(e)}}return(0,F.jsxs)(`div`,{className:`fade-in space-y-3`,children:[(0,F.jsxs)($T,{icon:Ci,title:`Deep Analysis`,children:[(0,F.jsxs)(`select`,{value:t,onChange:e=>n(e.target.value),className:`px-2 py-1 text-[12px] outline-none`,style:{background:`var(--c-bg3)`,color:`var(--c-text)`,border:`1px solid var(--c-border)`},children:[(0,F.jsx)(`option`,{value:``,children:`All Editors`}),x.map(e=>(0,F.jsx)(`option`,{value:e.id,children:q(e.id)},e.id))]}),(0,F.jsxs)(`select`,{value:r,onChange:e=>i(e.target.value),className:`px-2 py-1 text-[12px] outline-none max-w-[200px] truncate`,style:{background:`var(--c-bg3)`,color:`var(--c-text)`,border:`1px solid var(--c-border)`},children:[(0,F.jsx)(`option`,{value:``,children:`All Projects`}),C.map(e=>(0,F.jsx)(`option`,{value:e.fullPath,children:e.name},e.fullPath||e.name))]}),l&&(0,F.jsx)($r,{size:11,className:`animate-spin`,style:{color:`var(--c-text3)`}}),s&&(0,F.jsxs)(`span`,{className:`text-[11px]`,style:{color:`var(--c-text2)`},children:[s.analyzedChats,` sessions analyzed`]}),(0,F.jsx)(`div`,{className:`ml-auto`,children:(0,F.jsx)(Hh,{value:a,onChange:o})})]}),s&&D&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`grid gap-2`,style:{gridTemplateColumns:`repeat(auto-fit, minmax(90px, 1fr))`},children:[(0,F.jsx)(K,{label:`sessions`,value:s.analyzedChats}),(0,F.jsx)(K,{label:`messages`,value:J(s.totalMessages),sub:`${D.msgsPerSession}/session`}),(0,F.jsx)(K,{label:`tool calls`,value:J(s.totalToolCalls),sub:`${D.toolsPerSession}/session`}),(0,F.jsx)(K,{label:`total tokens`,value:J(D.totalTok),sub:`${J(D.tokPerMsg)}/msg`}),(0,F.jsx)(K,{label:`you wrote`,value:J(s.totalUserChars),sub:`AI: ${D.aiVsHuman}\u00d7 more`}),(0,F.jsx)(K,{label:`est. cost`,value:p&&p.totalCost>0?kh(p.totalCost):`—`})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-3`,children:[(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`token flow`}),(0,F.jsxs)(`div`,{className:`space-y-3 mt-2`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[11px] mb-1`,children:[(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`},children:`input tokens`}),(0,F.jsx)(`span`,{className:`font-bold`,style:{color:`var(--c-white)`},children:J(s.totalInputTokens+s.totalCacheRead+s.totalCacheWrite)})]}),(0,F.jsx)(gE,{segments:[{label:`Fresh input`,value:s.totalInputTokens,color:`#6366f1`},{label:`Cache write`,value:s.totalCacheWrite,color:`#fbbf24`},{label:`Cache read`,value:s.totalCacheRead,color:`#34d399`}]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 mt-1 text-[10px]`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`w-2 h-2 rounded-sm`,style:{background:`#6366f1`}}),` fresh `,J(s.totalInputTokens)]}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`w-2 h-2 rounded-sm`,style:{background:`#fbbf24`}}),` cache write `,J(s.totalCacheWrite)]}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`w-2 h-2 rounded-sm`,style:{background:`#34d399`}}),` cache read `,J(s.totalCacheRead)]})]})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[11px] mb-1`,children:[(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`},children:`output tokens`}),(0,F.jsx)(`span`,{className:`font-bold`,style:{color:`var(--c-white)`},children:J(s.totalOutputTokens)})]}),(0,F.jsx)(gE,{segments:[{label:`Output`,value:s.totalOutputTokens,color:`#a78bfa`}]})]}),s.totalCacheWrite>0&&(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[11px] mb-1`,children:[(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`},children:`cache write`}),(0,F.jsx)(`span`,{className:`font-bold`,style:{color:`var(--c-white)`},children:J(s.totalCacheWrite)})]}),(0,F.jsx)(gE,{segments:[{label:`Cache write`,value:s.totalCacheWrite,color:`#fbbf24`}]})]}),(0,F.jsxs)(`div`,{className:`pt-2`,style:{borderTop:`1px solid var(--c-border)`},children:[(0,F.jsx)(`div`,{className:`text-[10px] mb-1`,style:{color:`var(--c-text3)`},children:`overall token distribution`}),(0,F.jsx)(gE,{height:10,segments:[{label:`Input`,value:s.totalInputTokens,color:`#6366f1`},{label:`Output`,value:s.totalOutputTokens,color:`#a78bfa`},{label:`Cache Read`,value:s.totalCacheRead,color:`#34d399`},{label:`Cache Write`,value:s.totalCacheWrite,color:`#fbbf24`}]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 mt-1 text-[10px]`,style:{color:`var(--c-text3)`},children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`w-2 h-2 rounded-sm`,style:{background:`#6366f1`}}),` in`]}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`w-2 h-2 rounded-sm`,style:{background:`#a78bfa`}}),` out`]}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`w-2 h-2 rounded-sm`,style:{background:`#34d399`}}),` cache read`]}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`w-2 h-2 rounded-sm`,style:{background:`#fbbf24`}}),` cache write`]})]})]})]})]}),(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`efficiency insights`}),(0,F.jsxs)(`div`,{className:`space-y-3 mt-2`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`text-[11px] mb-1`,style:{color:`var(--c-text2)`},children:`you vs AI (characters)`}),(0,F.jsx)(gE,{height:8,segments:[{label:`You`,value:s.totalUserChars,color:`#6366f1`},{label:`AI`,value:s.totalAssistantChars,color:`#34d399`}]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between mt-1 text-[10px]`,children:[(0,F.jsxs)(`span`,{style:{color:`#6366f1`},children:[`You: `,J(s.totalUserChars)]}),(0,F.jsxs)(`span`,{style:{color:`#34d399`},children:[`AI: `,J(s.totalAssistantChars)]})]})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,F.jsxs)(`div`,{className:`p-2 rounded-sm`,style:{background:`var(--c-code-bg)`},children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px]`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(Ci,{size:9}),` output/input ratio`]}),(0,F.jsxs)(`div`,{className:`text-sm font-bold mt-0.5`,style:{color:`var(--c-white)`},children:[D.outputRatio,`×`]})]}),(0,F.jsxs)(`div`,{className:`p-2 rounded-sm`,style:{background:`var(--c-code-bg)`},children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px]`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(Ai,{size:9}),` cache hit rate`]}),(0,F.jsxs)(`div`,{className:`text-sm font-bold mt-0.5`,style:{color:parseFloat(D.cacheHitRate)>50?`#34d399`:parseFloat(D.cacheHitRate)>20?`#fbbf24`:`var(--c-white)`},children:[D.cacheHitRate,`%`]})]}),(0,F.jsxs)(`div`,{className:`p-2 rounded-sm`,style:{background:`var(--c-code-bg)`},children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px]`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(ni,{size:9}),` tokens per message`]}),(0,F.jsx)(`div`,{className:`text-sm font-bold mt-0.5`,style:{color:`var(--c-white)`},children:J(D.tokPerMsg)})]}),(0,F.jsxs)(`div`,{className:`p-2 rounded-sm`,style:{background:`var(--c-code-bg)`},children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px]`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(Oi,{size:9}),` tools per session`]}),(0,F.jsx)(`div`,{className:`text-sm font-bold mt-0.5`,style:{color:`var(--c-white)`},children:D.toolsPerSession})]})]}),(0,F.jsxs)(`div`,{className:`p-2 rounded-sm text-center`,style:{background:`var(--c-code-bg)`},children:[(0,F.jsx)(`div`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:`AI amplification factor`}),(0,F.jsxs)(`div`,{className:`text-lg font-bold`,style:{color:`var(--c-accent)`},children:[D.aiVsHuman,`×`]}),(0,F.jsxs)(`div`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:[`AI writes `,D.aiVsHuman,`× more than you type`]})]})]})]})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-3`,children:[(0,F.jsxs)(`div`,{className:`card p-3 lg:col-span-2`,children:[(0,F.jsxs)($,{children:[`most used tools `,(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:`(click to drill down)`})]}),(0,F.jsx)(`div`,{style:{height:Math.max(T.length*20+10,120)},children:T.length>0?(0,F.jsx)(wh,{ref:h,data:{labels:T.map(e=>e.name),datasets:[{data:T.map(e=>e.count),backgroundColor:sE.concat(oE).slice(0,T.length),borderRadius:2}]},options:{indexAxis:`y`,responsive:!0,maintainAspectRatio:!1,onClick:k,scales:{x:{grid:{color:y},ticks:{color:v,font:{size:8,family:cE}}},y:{grid:{display:!1},ticks:{color:_,font:{size:8,family:cE}}}},plugins:{legend:{display:!1},tooltip:{bodyFont:{family:cE,size:10},titleFont:{family:cE,size:10}}}}}):(0,F.jsx)(`div`,{className:`text-[11px] text-center py-8`,style:{color:`var(--c-text3)`},children:`no tool calls found`})})]}),(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`models`}),(0,F.jsx)(`div`,{style:{height:160},children:E.length>0?(0,F.jsx)(Th,{data:{labels:E.map(e=>e.name),datasets:[{data:E.map(e=>e.count),backgroundColor:oE,borderWidth:0}]},options:{responsive:!0,maintainAspectRatio:!1,cutout:`60%`,plugins:{legend:{position:`right`,labels:{color:b,font:{size:8,family:cE},usePointStyle:!0,pointStyle:`circle`,padding:6}},tooltip:{bodyFont:{family:cE,size:10},titleFont:{family:cE,size:10}}}}}):(0,F.jsx)(`div`,{className:`text-[11px] text-center py-8`,style:{color:`var(--c-text3)`},children:`no model data`})}),O.length>0&&(0,F.jsxs)(`div`,{className:`mt-3 pt-3`,style:{borderTop:`1px solid var(--c-border)`},children:[(0,F.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider mb-2`,style:{color:`var(--c-text3)`},children:`tool categories`}),(0,F.jsx)(`div`,{className:`space-y-1.5`,children:O.map(([e,{tools:t,total:n}])=>(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px]`,children:[(0,F.jsx)(`span`,{className:`truncate flex-1`,style:{color:`var(--c-text2)`},children:e}),(0,F.jsx)(`span`,{className:`font-bold`,style:{color:`var(--c-white)`},children:n}),(0,F.jsxs)(`span`,{style:{color:`var(--c-text3)`},children:[`(`,t.length,`)`]})]},e))})]})]})]}),d&&(0,F.jsx)(hE,{toolName:d,folder:r,editor:t,dateRange:a,onClose:()=>f(null)})]})]})}Lf.register(km,Nm,vp,wm,im);var vE=`JetBrains Mono, monospace`;function yE({label:e,a:t,b:n,colorA:r,colorB:i}){let a=parseFloat(t)||0,o=parseFloat(n)||0,s=Math.max(a,o,1);return(0,F.jsxs)(`div`,{className:`grid grid-cols-[1fr_100px_100px] gap-x-3 items-center py-0.5`,style:{borderBottom:`1px solid var(--c-border)`},children:[(0,F.jsx)(`div`,{className:`text-[11px]`,style:{color:`var(--c-text2)`},children:e}),(0,F.jsxs)(`div`,{className:`text-right`,children:[(0,F.jsx)(`span`,{className:`text-[12px] font-mono font-medium`,style:{color:`var(--c-white)`},children:typeof t==`number`?J(t):t}),(0,F.jsx)(`div`,{className:`h-1 rounded-full mt-0.5 ml-auto`,style:{background:r,width:`${(a/s*100).toFixed(0)}%`}})]}),(0,F.jsxs)(`div`,{className:`text-right`,children:[(0,F.jsx)(`span`,{className:`text-[12px] font-mono font-medium`,style:{color:`var(--c-white)`},children:typeof n==`number`?J(n):n}),(0,F.jsx)(`div`,{className:`h-1 rounded-full mt-0.5 ml-auto`,style:{background:i,width:`${(o/s*100).toFixed(0)}%`}})]})]})}function bE({titleA:e,titleB:t,colorA:n,colorB:r,itemsA:i,itemsB:a,limit:o=8}){return(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h4`,{className:`text-[11px] font-medium uppercase tracking-wider mb-1`,style:{color:n},children:e}),(0,F.jsxs)(`div`,{className:`space-y-0.5`,children:[i.slice(0,o).map(e=>(0,F.jsxs)(`div`,{className:`flex justify-between text-[11px] py-0.5`,children:[(0,F.jsx)(`span`,{className:`truncate`,style:{color:`var(--c-text)`},children:e.name}),(0,F.jsx)(`span`,{className:`font-mono ml-2`,style:{color:`var(--c-text3)`},children:e.count})]},e.name)),i.length===0&&(0,F.jsx)(`div`,{className:`text-[11px]`,style:{color:`var(--c-text3)`},children:`none`})]})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h4`,{className:`text-[11px] font-medium uppercase tracking-wider mb-1`,style:{color:r},children:t}),(0,F.jsxs)(`div`,{className:`space-y-0.5`,children:[a.slice(0,o).map(e=>(0,F.jsxs)(`div`,{className:`flex justify-between text-[11px] py-0.5`,children:[(0,F.jsx)(`span`,{className:`truncate`,style:{color:`var(--c-text)`},children:e.name}),(0,F.jsx)(`span`,{className:`font-mono ml-2`,style:{color:`var(--c-text3)`},children:e.count})]},e.name)),a.length===0&&(0,F.jsx)(`div`,{className:`text-[11px]`,style:{color:`var(--c-text3)`},children:`none`})]})]})]})}function xE({overview:e}){let t=e?.editors||[],[n,r]=(0,S.useState)(t[0]?.id||``),[i,a]=(0,S.useState)(t[1]?.id||``),[o,s]=(0,S.useState)(null),[c,l]=(0,S.useState)(!1),{dark:u}=tr(),d=u?`#888`:`#555`;async function f(){if(!n||!i)return;l(!0);let[e,t,r,a]=await Promise.all([Wi({editor:n,limit:500}),Wi({editor:i,limit:500}),Bi({editor:n,limit:1e3}),Bi({editor:i,limit:1e3})]);s({deepA:e,deepB:t,chatsA:r,chatsB:a}),l(!1)}(0,S.useEffect)(()=>{n&&i&&f()},[n,i]);let p=Oh(n),m=Oh(i),h=q(n),g=q(i),_=(e,t)=>t?(e/t).toFixed(1):`0`,v=(e,t)=>t?(e/t*100).toFixed(0)+`%`:`0%`,y=o?[{label:`Sessions`,a:o.chatsA.total,b:o.chatsB.total},{label:`Messages`,a:o.deepA.totalMessages,b:o.deepB.totalMessages},{label:`Tool Calls`,a:o.deepA.totalToolCalls,b:o.deepB.totalToolCalls},{label:`Input Tokens`,a:o.deepA.totalInputTokens,b:o.deepB.totalInputTokens},{label:`Output Tokens`,a:o.deepA.totalOutputTokens,b:o.deepB.totalOutputTokens},{label:`Cache Read`,a:o.deepA.totalCacheRead,b:o.deepB.totalCacheRead}]:[],b=o?[{label:`Avg Msgs / Session`,a:_(o.deepA.totalMessages,o.deepA.analyzedChats),b:_(o.deepB.totalMessages,o.deepB.analyzedChats)},{label:`Avg Tools / Session`,a:_(o.deepA.totalToolCalls,o.deepA.analyzedChats),b:_(o.deepB.totalToolCalls,o.deepB.analyzedChats)},{label:`Avg Tokens / Session`,a:_(o.deepA.totalInputTokens+o.deepA.totalOutputTokens,o.deepA.analyzedChats),b:_(o.deepB.totalInputTokens+o.deepB.totalOutputTokens,o.deepB.analyzedChats)},{label:`Output / Input Ratio`,a:_(o.deepA.totalOutputTokens,o.deepA.totalInputTokens||1),b:_(o.deepB.totalOutputTokens,o.deepB.totalInputTokens||1)},{label:`Tools / Message`,a:_(o.deepA.totalToolCalls,o.deepA.totalMessages||1),b:_(o.deepB.totalToolCalls,o.deepB.totalMessages||1)},{label:`Cache Hit Rate`,a:v(o.deepA.totalCacheRead,o.deepA.totalInputTokens),b:v(o.deepB.totalCacheRead,o.deepB.totalInputTokens)}]:[],x=[`Sessions`,`Messages`,`Tool Calls`],C=o?[o.chatsA.total,o.deepA.totalMessages,o.deepA.totalToolCalls]:[],w=o?[o.chatsB.total,o.deepB.totalMessages,o.deepB.totalToolCalls]:[],T={labels:x,datasets:[{label:h,data:C,backgroundColor:p+`99`,borderRadius:2},{label:g,data:w,backgroundColor:m+`99`,borderRadius:2}]},E=o?{labels:[`Input`,`Output`,`Cache Read`],datasets:[{label:h,data:[o.deepA.totalInputTokens,o.deepA.totalOutputTokens,o.deepA.totalCacheRead],backgroundColor:p+`99`,borderRadius:2},{label:g,data:[o.deepB.totalInputTokens,o.deepB.totalOutputTokens,o.deepB.totalCacheRead],backgroundColor:m+`99`,borderRadius:2}]}:null,D={responsive:!0,maintainAspectRatio:!1,plugins:{legend:{labels:{color:d,font:{size:9,family:vE},usePointStyle:!0,pointStyle:`circle`,padding:8}},tooltip:{bodyFont:{family:vE,size:10},titleFont:{family:vE,size:10}}},scales:{x:{grid:{display:!1},ticks:{color:d,font:{size:9,family:vE}}},y:{grid:{color:u?`rgba(255,255,255,0.03)`:`rgba(0,0,0,0.06)`},ticks:{color:d,font:{size:9,family:vE}}}}};return(0,F.jsxs)(`div`,{className:`fade-in space-y-3`,children:[(0,F.jsxs)($T,{icon:ur,title:`Compare`,children:[(0,F.jsx)(`select`,{value:n,onChange:e=>r(e.target.value),className:`px-2 py-1 text-[12px] outline-none`,style:{background:`var(--c-bg3)`,color:`var(--c-text)`,border:`1px solid var(--c-border)`},children:t.map(e=>(0,F.jsx)(`option`,{value:e.id,children:q(e.id)},e.id))}),(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:`vs`}),(0,F.jsx)(`select`,{value:i,onChange:e=>a(e.target.value),className:`px-2 py-1 text-[12px] outline-none`,style:{background:`var(--c-bg3)`,color:`var(--c-text)`,border:`1px solid var(--c-border)`},children:t.map(e=>(0,F.jsx)(`option`,{value:e.id,children:q(e.id)},e.id))}),c&&(0,F.jsx)($r,{size:11,className:`animate-spin`,style:{color:`var(--c-text3)`}})]}),o&&(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-2`,children:[(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,F.jsx)(`h3`,{className:`text-[11px] font-medium uppercase tracking-wider`,style:{color:`var(--c-text2)`},children:`totals`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px]`,children:[(0,F.jsxs)(`span`,{style:{color:p},children:[`● `,h]}),(0,F.jsxs)(`span`,{style:{color:m},children:[`● `,g]})]})]}),y.map(e=>(0,F.jsx)(yE,{label:e.label,a:e.a,b:e.b,colorA:p,colorB:m},e.label))]}),(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)(`h3`,{className:`text-[11px] font-medium uppercase tracking-wider mb-1.5`,style:{color:`var(--c-text2)`},children:`efficiency`}),b.map(e=>(0,F.jsx)(yE,{label:e.label,a:e.a,b:e.b,colorA:p,colorB:m},e.label))]})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-2`,children:[(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)(`h3`,{className:`text-[11px] font-medium uppercase tracking-wider mb-2`,style:{color:`var(--c-text2)`},children:`usage`}),(0,F.jsx)(`div`,{style:{height:160},children:(0,F.jsx)(wh,{data:T,options:D})})]}),E&&(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)(`h3`,{className:`text-[11px] font-medium uppercase tracking-wider mb-2`,style:{color:`var(--c-text2)`},children:`tokens`}),(0,F.jsx)(`div`,{style:{height:160},children:(0,F.jsx)(wh,{data:E,options:D})})]})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-2`,children:[(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)(`h3`,{className:`text-[11px] font-medium uppercase tracking-wider mb-2`,style:{color:`var(--c-text2)`},children:`top tools`}),(0,F.jsx)(bE,{titleA:h,titleB:g,colorA:p,colorB:m,itemsA:o.deepA.topTools,itemsB:o.deepB.topTools,limit:10})]}),(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)(`h3`,{className:`text-[11px] font-medium uppercase tracking-wider mb-2`,style:{color:`var(--c-text2)`},children:`models`}),(0,F.jsx)(bE,{titleA:h,titleB:g,colorA:p,colorB:m,itemsA:o.deepA.topModels,itemsB:o.deepB.topModels,limit:8})]})]})]})]})}Lf.register(qf,wm,im,km,Nm,vp);var SE=`JetBrains Mono, monospace`,CE=[`#6366f1`,`#a78bfa`,`#818cf8`,`#c084fc`,`#e879f9`,`#f472b6`,`#fb7185`,`#f87171`,`#fbbf24`,`#34d399`];function wE({overview:e}){let{dark:t}=tr(),n=t?`#888`:`#555`,r=t?`#555`:`#999`,i=t?`rgba(255,255,255,0.03)`:`rgba(0,0,0,0.06)`,[a,o]=(0,S.useState)(null),[s,c]=(0,S.useState)(``),[l,u]=(0,S.useState)(``),[d,f]=(0,S.useState)(null),[p,m]=(0,S.useState)(null),h=dt(),g=e?.editors||[];if((0,S.useEffect)(()=>{let e=jh(d);Promise.all([Hi(e),Ji(e)]).then(([e,t])=>{o(e),m(t)})},[d]),!a)return(0,F.jsx)(wa,{label:`Loading projects...`});let _=a.filter(e=>!(l&&!e.editors[l]||s&&!e.folder.toLowerCase().includes(s.toLowerCase())&&!e.name.toLowerCase().includes(s.toLowerCase()))),v=a.reduce((e,t)=>e+t.totalSessions,0),y=a.reduce((e,t)=>e+t.totalMessages,0),b=a.reduce((e,t)=>e+t.totalInputTokens+t.totalOutputTokens,0),x=Math.max(...a.map(e=>e.totalSessions),1),C={},w={};for(let e of a){for(let t of e.topModels)C[t.name]=(C[t.name]||0)+t.count;for(let[t,n]of Object.entries(e.editors))w[t]=(w[t]||0)+n}let T=Object.entries(C).sort((e,t)=>t[1]-e[1]).slice(0,8),E=Object.entries(w).sort((e,t)=>t[1]-e[1]),D=a.slice(0,10);return(0,F.jsxs)(`div`,{className:`fade-in space-y-3`,children:[(0,F.jsx)($T,{icon:Ur,title:`Projects`}),(0,F.jsxs)(`div`,{className:`grid gap-2`,style:{gridTemplateColumns:`repeat(auto-fit, minmax(90px, 1fr))`},children:[(0,F.jsx)(K,{label:`projects`,value:a.length}),(0,F.jsx)(K,{label:`sessions`,value:J(v),onClick:()=>h(`/sessions`)}),(0,F.jsx)(K,{label:`messages`,value:J(y)}),(0,F.jsx)(K,{label:`tokens`,value:J(b)}),(0,F.jsx)(K,{label:`est. cost`,value:p&&p.totalCost>0?kh(p.totalCost):`—`})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-3`,children:[(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsxs)($,{children:[`top projects `,(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:`by sessions`})]}),(0,F.jsx)(`div`,{style:{height:160},children:(0,F.jsx)(wh,{data:{labels:D.map(e=>e.name),datasets:[{data:D.map(e=>e.totalSessions),backgroundColor:`#6366f1`,borderRadius:3}]},options:{responsive:!0,maintainAspectRatio:!1,indexAxis:`y`,scales:{x:{grid:{color:i},ticks:{color:r,font:{size:8,family:SE}}},y:{grid:{display:!1},ticks:{color:n,font:{size:8,family:SE},callback:(e,t)=>D[t]?.name?.length>16?D[t].name.slice(0,15)+`…`:D[t]?.name}}},plugins:{legend:{display:!1},tooltip:{bodyFont:{family:SE,size:10},titleFont:{family:SE,size:10}}}}})})]}),(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`editors`}),(0,F.jsx)(`div`,{style:{height:160},children:(0,F.jsx)(Th,{data:{labels:E.map(e=>q(e[0])),datasets:[{data:E.map(e=>e[1]),backgroundColor:E.map(e=>Oh(e[0])),borderWidth:0}]},options:{responsive:!0,maintainAspectRatio:!1,cutout:`60%`,plugins:{legend:{position:`right`,labels:{color:n,font:{size:9,family:SE},usePointStyle:!0,pointStyle:`circle`,padding:6}},tooltip:{bodyFont:{family:SE,size:10},titleFont:{family:SE,size:10}}}}})})]}),(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`models`}),(0,F.jsx)(`div`,{style:{height:160},children:T.length>0?(0,F.jsx)(Th,{data:{labels:T.map(e=>e[0]),datasets:[{data:T.map(e=>e[1]),backgroundColor:CE,borderWidth:0}]},options:{responsive:!0,maintainAspectRatio:!1,cutout:`60%`,plugins:{legend:{position:`right`,labels:{color:n,font:{size:9,family:SE},usePointStyle:!0,pointStyle:`circle`,padding:6}},tooltip:{bodyFont:{family:SE,size:10},titleFont:{family:SE,size:10}}}}}):(0,F.jsx)(`div`,{className:`text-xs text-center py-12`,style:{color:`var(--c-text3)`},children:`no model data`})})]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsxs)(`select`,{value:l,onChange:e=>u(e.target.value),className:`px-2 py-1 text-[12px] outline-none`,style:{background:`var(--c-bg3)`,color:`var(--c-text)`,border:`1px solid var(--c-border)`},children:[(0,F.jsx)(`option`,{value:``,children:`All Editors`}),g.map(e=>(0,F.jsx)(`option`,{value:e.id,children:q(e.id)},e.id))]}),(0,F.jsxs)(`div`,{className:`relative flex-1 max-w-sm`,children:[(0,F.jsx)(ui,{size:12,className:`absolute left-2.5 top-1/2 -translate-y-1/2`,style:{color:`var(--c-text3)`}}),(0,F.jsx)(`input`,{type:`text`,placeholder:`Search projects...`,value:s,onChange:e=>c(e.target.value),className:`w-full pl-7 pr-3 py-1 text-[12px] outline-none`,style:{background:`var(--c-bg3)`,color:`var(--c-text)`,border:`1px solid var(--c-border)`}})]}),(0,F.jsx)(`div`,{className:`ml-auto`,children:(0,F.jsx)(Hh,{value:d,onChange:f})})]}),(0,F.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3`,children:_.map(e=>{let t=Object.entries(e.editors).sort((e,t)=>t[1]-e[1]),n=e.totalInputTokens+e.totalOutputTokens,r=e.topModels[0];return(0,F.jsxs)(`div`,{className:`card p-3 cursor-pointer transition hover:opacity-90 flex flex-col gap-2.5`,onClick:()=>h(`/projects/detail?folder=${encodeURIComponent(e.folder)}`),children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-2 min-w-0`,children:[(0,F.jsx)(Ur,{size:14,className:`flex-shrink-0 mt-0.5`,style:{color:`var(--c-accent)`}}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,F.jsx)(`div`,{className:`text-[12px] font-bold truncate`,style:{color:`var(--c-white)`},children:e.name}),(0,F.jsx)(`div`,{className:`text-[10px] truncate`,style:{color:`var(--c-text3)`},children:e.folder})]}),(0,F.jsx)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:t.slice(0,4).map(([e])=>(0,F.jsx)(Gh,{source:e,size:12},e))})]}),(0,F.jsx)(`div`,{className:`w-full h-1 rounded-full overflow-hidden`,style:{background:`var(--c-code-bg)`},children:(0,F.jsx)(`div`,{className:`h-full rounded-full`,style:{width:`${(e.totalSessions/x*100).toFixed(1)}%`,background:`var(--c-accent)`}})}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1 text-[11px]`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(ni,{size:9,style:{color:`var(--c-text3)`}}),(0,F.jsxs)(`span`,{style:{color:`var(--c-text2)`},children:[e.totalSessions,` sessions`]}),(0,F.jsxs)(`span`,{className:`ml-auto font-bold`,style:{color:`var(--c-white)`},children:[J(e.totalMessages),` msgs`]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(Oi,{size:9,style:{color:`var(--c-text3)`}}),(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`},children:`tools`}),(0,F.jsx)(`span`,{className:`ml-auto font-bold`,style:{color:`var(--c-white)`},children:J(e.totalToolCalls)})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(Nr,{size:9,style:{color:`var(--c-text3)`}}),(0,F.jsx)(`span`,{className:`truncate`,style:{color:`var(--c-text2)`},children:r?r.name:`—`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:`tok`}),(0,F.jsx)(`span`,{className:`ml-auto font-bold`,style:{color:n>0?`var(--c-white)`:`var(--c-text3)`},children:n>0?J(n):`—`})]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 pt-1 text-[10px]`,style:{borderTop:`1px solid var(--c-border)`},children:[(0,F.jsx)(`div`,{className:`flex items-center gap-1.5 flex-1 min-w-0`,children:t.map(([e,t])=>(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 truncate`,children:[(0,F.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full flex-shrink-0`,style:{background:Oh(e)}}),(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:q(e)}),(0,F.jsx)(`span`,{className:`font-bold`,style:{color:`var(--c-text2)`},children:t})]},e))}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(vr,{size:8}),(0,F.jsx)(`span`,{children:Ah(e.lastSeen)})]})]})]},e.folder)})}),_.length===0&&(0,F.jsx)(`div`,{className:`text-center py-12 text-sm`,style:{color:`var(--c-text3)`},children:`no projects found`})]})}var TE={"A+":`#22c55e`,A:`#22c55e`,"B+":`#4ade80`,B:`#4ade80`,"C+":`#facc15`,C:`#facc15`,"D+":`#f97316`,D:`#f97316`,F:`#ef4444`},EE={"Repo Hygiene":_r,"Grounding Docs":Br,Testing:Hr,"Agent Configs":hr,"AI Context":ei,"Prompts & Skills":si,MCP:oi,"AI Dependencies":ii,"AI Deps":ii};function DE({missing:e}){let[t,n]=(0,S.useState)(!1),r=(0,S.useRef)(null);(0,S.useEffect)(()=>{if(!t)return;let e=e=>{r.current&&!r.current.contains(e.target)&&n(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[t]);let i=e.filter(e=>e.weight>0),a=i.length>0?i:e.slice(0,5);return a.length===0?null:(0,F.jsxs)(`span`,{ref:r,className:`relative flex-shrink-0`,children:[(0,F.jsx)(`button`,{onClick:e=>{e.stopPropagation(),n(!t)},className:`flex items-center justify-center w-4 h-4 rounded-full transition hover:opacity-80`,style:{color:`var(--c-text3)`,background:`var(--c-bg3)`},children:(0,F.jsx)(Jr,{size:10})}),t&&(0,F.jsxs)(`div`,{className:`absolute right-0 top-6 z-50 w-64 p-2.5 rounded shadow-lg`,style:{background:`var(--c-bg)`,border:`1px solid var(--c-border)`,boxShadow:`0 4px 24px rgba(0,0,0,0.3)`},children:[(0,F.jsx)(`div`,{className:`text-[11px] font-medium mb-1.5`,style:{color:`var(--c-white)`},children:`How to improve`}),(0,F.jsx)(`div`,{className:`space-y-1`,children:a.map(e=>(0,F.jsxs)(`div`,{className:`text-[11px]`,style:{color:`var(--c-text2)`},children:[(0,F.jsxs)(`span`,{style:{color:`var(--c-text)`},children:[`+ `,e.label]}),e.weight>0&&(0,F.jsxs)(`span`,{style:{color:`var(--c-text3)`},children:[` (`,e.weight,`pt)`]})]},e.id))})]})]})}function OE({folder:e}){console.log(`AiAuditCard rendering, folder:`,e);let[t,n]=(0,S.useState)(null),[r,i]=(0,S.useState)(!1),[a,o]=(0,S.useState)(null),[s,c]=(0,S.useState)(new Set),l=async()=>{if(e){i(!0),o(null);try{let t=await na(e);if(t.error)throw Error(t.error);n(t)}catch(e){o(e.message)}i(!1)}};if((0,S.useEffect)(()=>{console.log(`AiAuditCard useEffect triggered, folder:`,e),l()},[e]),r)return(0,F.jsx)(`div`,{className:`card p-4`,children:(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)($r,{size:14,className:`animate-spin`,style:{color:`var(--c-accent)`}}),(0,F.jsx)(`span`,{className:`text-[12px]`,style:{color:`var(--c-text2)`},children:`Running AI readiness audit...`})]})});if(a)return(0,F.jsx)(`div`,{className:`card p-4`,children:(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(wi,{size:14,style:{color:`#ef4444`}}),(0,F.jsxs)(`span`,{className:`text-[12px]`,style:{color:`var(--c-text2)`},children:[`Audit failed: `,a]})]}),(0,F.jsxs)(`button`,{onClick:l,className:`flex items-center gap-1.5 px-2.5 py-1 text-[11px] rounded transition hover:opacity-80`,style:{color:`var(--c-text2)`,border:`1px solid var(--c-border)`},children:[(0,F.jsx)(li,{size:10}),`Retry`]})]})});if(!t)return null;let u=TE[t.grade]||`var(--c-text2)`,d=t.sections||{},f=t.findings||[],p={};for(let e of f){let t=e.section||`Other`;p[t]||(p[t]=[]),p[t].push(e)}return(0,F.jsxs)(`div`,{className:`card p-4 space-y-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(hi,{size:16,style:{color:u}}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)($,{children:`ai readiness audit`}),(0,F.jsxs)(`div`,{className:`text-[10px] -mt-1.5`,style:{color:`var(--c-text3)`},children:[`powered by `,(0,F.jsx)(`code`,{style:{fontFamily:`JetBrains Mono, monospace`},children:`npx check-ai`})]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 ml-auto`,children:[(0,F.jsxs)(`span`,{className:`text-[11px]`,style:{color:`var(--c-text3)`},children:[t.checks?.passed||0,`/`,t.checks?.total||0,` checks · `,t.points?.earned||0,`/`,t.points?.max||0,` pts`]}),(0,F.jsx)(`button`,{onClick:l,className:`flex items-center gap-1 px-2 py-1 text-[11px] rounded transition hover:opacity-80`,style:{color:`var(--c-text2)`,border:`1px solid var(--c-border)`},children:(0,F.jsx)(li,{size:10})})]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(`div`,{className:`w-11 h-11 rounded-lg flex items-center justify-center text-base font-black flex-shrink-0`,style:{background:`${u}15`,color:u,border:`1.5px solid ${u}30`},children:t.grade}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,F.jsxs)(`div`,{className:`flex items-baseline gap-1.5`,children:[(0,F.jsx)(`span`,{className:`text-base font-bold`,style:{color:`var(--c-white)`},children:t.score}),(0,F.jsx)(`span`,{className:`text-[11px]`,style:{color:`var(--c-text3)`},children:`/10`}),(0,F.jsx)(`span`,{className:`text-[11px] ml-1`,style:{color:`var(--c-text2)`},children:t.label})]}),(0,F.jsx)(`div`,{className:`w-full h-2 rounded-full overflow-hidden mt-1`,style:{background:`var(--c-code-bg)`},children:(0,F.jsx)(`div`,{className:`h-full rounded-full`,style:{width:`${((t.score||0)/10*100).toFixed(1)}%`,background:u}})})]})]}),(0,F.jsx)(`div`,{children:Object.entries(d).map(([e,t])=>{let n=EE[e]||Br,r=p[e]||[],i=r.filter(e=>e.found),a=r.filter(e=>!e.found),o=t.pct||0,l=o>=70?`#22c55e`:o>=40?`#facc15`:o>0?`#f97316`:`var(--c-text3)`,u=[];for(let e of i)e.detail?u.push(e.detail):e.matchedPath?u.push(e.matchedPath):e.matches&&e.matches.length>0?u.push(e.matches.join(`, `)):u.push(e.label);let d=u.length>0?u.slice(0,3).join(` · `)+(u.length>3?` …`:``):`none detected`,f=s.has(e);return(0,F.jsxs)(`div`,{style:{borderBottom:`1px solid var(--c-border)`},children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2.5 py-2 cursor-pointer transition hover:bg-[var(--c-bg3)]`,onClick:()=>c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),children:[f?(0,F.jsx)(Cr,{size:12,style:{color:`var(--c-text3)`,flexShrink:0}}):(0,F.jsx)(wr,{size:12,style:{color:`var(--c-text3)`,flexShrink:0}}),(0,F.jsx)(n,{size:14,style:{color:`var(--c-text3)`,flexShrink:0}}),(0,F.jsx)(`span`,{className:`text-[12px] font-medium w-32 flex-shrink-0`,style:{color:`var(--c-white)`},children:e}),(0,F.jsx)(`span`,{className:`text-[11px] flex-1 truncate`,style:{color:i.length>0?`var(--c-text2)`:`var(--c-text3)`},children:d}),(0,F.jsxs)(`span`,{className:`text-[11px] flex-shrink-0`,style:{color:`var(--c-text3)`},children:[i.length,`/`,r.length]}),(0,F.jsx)(`div`,{className:`w-20 h-2 rounded-full overflow-hidden flex-shrink-0`,style:{background:`var(--c-code-bg)`},children:(0,F.jsx)(`div`,{className:`h-full rounded-full`,style:{width:`${o}%`,background:l}})}),(0,F.jsxs)(`span`,{className:`text-[11px] w-9 text-right font-bold flex-shrink-0`,style:{color:l},children:[o,`%`]}),a.length>0&&(0,F.jsx)(DE,{missing:a})]}),f&&i.length>0&&(0,F.jsx)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-0.5 pb-2 pl-12`,children:i.map(e=>(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] py-0.5`,children:[(0,F.jsx)(Dr,{size:10,style:{color:`#22c55e`,flexShrink:0}}),(0,F.jsx)(`span`,{style:{color:`var(--c-text)`},children:e.label}),e.matchedPath&&(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:e.matchedPath}),e.detail&&(0,F.jsxs)(`span`,{style:{color:`var(--c-text2)`},children:[`— `,e.detail]})]},e.id))})]},e)})})]})}Lf.register(qf,wm,im,km,Nm,vp);var kE=`JetBrains Mono, monospace`,AE=[`#6366f1`,`#a78bfa`,`#818cf8`,`#c084fc`,`#e879f9`,`#f472b6`,`#fb7185`,`#f87171`,`#fbbf24`,`#34d399`],jE=[`#10b981`,`#34d399`,`#6ee7b7`,`#a7f3d0`,`#d1fae5`,`#ecfdf5`,`#b8f0d8`,`#7ce0b8`,`#4ade80`,`#22c55e`];function ME(){let[e]=zn(),t=dt(),n=e.get(`folder`),{dark:r}=tr(),i=r?`#888`:`#555`,a=r?`#555`:`#999`,o=r?`rgba(255,255,255,0.03)`:`rgba(0,0,0,0.06)`,[s,c]=(0,S.useState)(null),[l,u]=(0,S.useState)([]),[d,f]=(0,S.useState)(!0),[p,m]=(0,S.useState)(``),[h,g]=(0,S.useState)(null),[_,v]=(0,S.useState)(null),[y,b]=(0,S.useState)(null);(0,S.useEffect)(()=>{n&&(f(!0),Promise.all([Hi(),Bi({folder:n,limit:1e3}),Ji({folder:n})]).then(([e,t,r])=>{let i=e.find(e=>e.folder===n);c(i||null),u(t.chats||[]),v(r),i&&b(new Set(Object.keys(i.editors))),f(!1)}))},[n]);let x=(0,S.useMemo)(()=>y?l.filter(e=>y.has(e.source)):l,[l,y]),C=(0,S.useMemo)(()=>{if(!p)return x;let e=p.toLowerCase();return x.filter(t=>t.name&&t.name.toLowerCase().includes(e)||t.topModel&&t.topModel.toLowerCase().includes(e)||t.source&&t.source.toLowerCase().includes(e))},[x,p]),w=e=>{b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};if(!n)return(0,F.jsx)(`div`,{className:`text-sm py-12 text-center`,style:{color:`var(--c-text3)`},children:`no project specified`});if(d)return(0,F.jsx)(wa,{label:`Loading project...`});if(!s)return(0,F.jsx)(`div`,{className:`text-sm py-12 text-center`,style:{color:`var(--c-text3)`},children:`project not found`});let T=Object.entries(s.editors).sort((e,t)=>t[1]-e[1]),E=!y||y.size===T.length,D=x.length,O={},k={};for(let e of x)O[e.source]=(O[e.source]||0)+1,e.topModel&&(k[e.topModel]=(k[e.topModel]||0)+1);let A=Object.entries(k).sort((e,t)=>t[1]-e[1]).slice(0,10),j=Math.max(...Object.values(O),1),ee=s.totalInputTokens+s.totalOutputTokens,te=s.totalInputTokens>0?(s.totalOutputTokens/s.totalInputTokens).toFixed(1):`0`,ne=E?s.totalSessions:D,re=E&&s.totalSessions>0?(s.totalMessages/s.totalSessions).toFixed(1):0;return(0,F.jsxs)(`div`,{className:`fade-in space-y-3`,children:[(0,F.jsxs)(`div`,{className:`card p-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,F.jsx)(`button`,{onClick:()=>t(`/projects`),className:`flex items-center gap-1 text-[12px] transition mt-0.5 flex-shrink-0`,style:{color:`var(--c-text3)`},children:(0,F.jsx)(dr,{size:12})}),(0,F.jsx)(Ur,{size:18,className:`flex-shrink-0 mt-0.5`,style:{color:`var(--c-accent)`}}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,F.jsx)(`h1`,{className:`text-sm font-bold truncate`,style:{color:`var(--c-white)`},children:s.name}),(0,F.jsx)(`div`,{className:`text-[11px] truncate`,style:{color:`var(--c-text3)`},children:s.folder})]}),(0,F.jsx)(`div`,{className:`flex items-center gap-1.5 flex-shrink-0`,children:T.map(([e])=>(0,F.jsx)(Gh,{source:e,size:14},e))})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-4 mt-3 pt-3 text-[11px]`,style:{borderTop:`1px solid var(--c-border)`},children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(vr,{size:9}),(0,F.jsx)(`span`,{children:Ah(s.firstSeen)}),(0,F.jsx)(`span`,{children:`→`}),(0,F.jsx)(`span`,{children:Ah(s.lastSeen)})]}),(0,F.jsx)(`div`,{className:`flex items-center gap-1.5 ml-auto`,children:T.map(([e,t])=>(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,F.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full`,style:{background:Oh(e)}}),(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:q(e)}),(0,F.jsx)(`span`,{className:`font-bold`,style:{color:`var(--c-text2)`},children:t})]},e))})]})]}),(0,F.jsxs)(`div`,{className:`grid gap-2`,style:{gridTemplateColumns:`repeat(auto-fit, minmax(90px, 1fr))`},children:[(0,F.jsx)(K,{label:`sessions`,value:ne,sub:E?``:`filtered`}),(0,F.jsx)(K,{label:`messages`,value:J(s.totalMessages),sub:`${re} avg/session`}),(0,F.jsx)(K,{label:`tool calls`,value:J(s.totalToolCalls),sub:(0,F.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,F.jsx)(Oi,{size:8}),` invocations`]})}),(0,F.jsx)(K,{label:`tokens`,value:J(ee),sub:`${te}\u00d7 out/in`}),s.totalCacheRead>0&&(0,F.jsx)(K,{label:`cache read`,value:J(s.totalCacheRead),sub:`write: ${J(s.totalCacheWrite)}`}),(0,F.jsx)(K,{label:`you wrote`,value:J(s.totalUserChars),sub:`AI: ${J(s.totalAssistantChars)}`}),(0,F.jsx)(K,{label:`est. cost`,value:_&&_.totalCost>0?kh(_.totalCost):`—`,sub:_&&_.byModel.length>0?`${_.byModel.length} model${_.byModel.length===1?``:`s`}`:void 0})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-3`,children:[(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`editors`}),(0,F.jsx)(`div`,{className:`space-y-1.5 mt-1`,children:T.map(([e,t])=>{let n=y?y.has(e):!0,r=O[e]||0;return(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>w(e),className:`accent-[var(--c-accent)] w-3 h-3 flex-shrink-0 cursor-pointer`}),(0,F.jsx)(Gh,{source:e,size:11}),(0,F.jsx)(`span`,{className:`text-[11px] truncate flex-1 cursor-pointer select-none`,onClick:()=>w(e),style:{color:n?`var(--c-text2)`:`var(--c-text3)`,opacity:n?1:.4},children:q(e)}),(0,F.jsx)(`div`,{className:`w-16 h-3 rounded-sm overflow-hidden`,style:{background:`var(--c-code-bg)`},children:(0,F.jsx)(`div`,{className:`h-full rounded-sm transition-all`,style:{width:`${(r/j*100).toFixed(0)}%`,background:n?Oh(e):`var(--c-text3)`,opacity:n?1:.2}})}),(0,F.jsx)(`span`,{className:`text-[11px] w-6 text-right font-bold`,style:{color:n?`var(--c-white)`:`var(--c-text3)`,opacity:n?1:.4},children:r})]},e)})})]}),(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`models`}),A.length>0?(0,F.jsx)(`div`,{style:{height:160},children:(0,F.jsx)(Th,{data:{labels:A.map(e=>e[0]),datasets:[{data:A.map(e=>e[1]),backgroundColor:AE,borderWidth:0}]},options:{responsive:!0,maintainAspectRatio:!1,cutout:`60%`,plugins:{legend:{position:`right`,labels:{color:i,font:{size:8,family:kE},usePointStyle:!0,pointStyle:`circle`,padding:6}},tooltip:{bodyFont:{family:kE,size:10},titleFont:{family:kE,size:10}}}}})}):(0,F.jsx)(`div`,{className:`text-[11px] py-8 text-center`,style:{color:`var(--c-text3)`},children:`no model data`})]}),(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsxs)($,{children:[`top tools `,(0,F.jsxs)(`span`,{style:{color:`var(--c-text3)`},children:[`(`,J(s.totalToolCalls),`)`]})]}),s.topTools.length>0?(0,F.jsx)(`div`,{style:{height:160},children:(0,F.jsx)(wh,{data:{labels:s.topTools.map(e=>e.name),datasets:[{data:s.topTools.map(e=>e.count),backgroundColor:jE.slice(0,s.topTools.length),borderRadius:2}]},options:{responsive:!0,maintainAspectRatio:!1,indexAxis:`y`,scales:{x:{grid:{color:o},ticks:{color:a,font:{size:8,family:kE}}},y:{grid:{display:!1},ticks:{color:i,font:{size:8,family:kE}}}},plugins:{legend:{display:!1},tooltip:{bodyFont:{family:kE,size:10},titleFont:{family:kE,size:10}}}}})}):(0,F.jsx)(`div`,{className:`text-[11px] py-8 text-center`,style:{color:`var(--c-text3)`},children:`no tool data`})]})]}),console.log(`Rendering AiAuditCard, folder:`,n),(0,F.jsx)(OE,{folder:n}),(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3 mb-2`,children:[(0,F.jsxs)($,{children:[`sessions `,(0,F.jsxs)(`span`,{style:{color:`var(--c-text3)`},children:[`(`,C.length,E?``:` of ${l.length}`,`)`]})]}),(0,F.jsxs)(`div`,{className:`relative max-w-xs flex-1`,children:[(0,F.jsx)(ui,{size:11,className:`absolute left-2.5 top-1/2 -translate-y-1/2`,style:{color:`var(--c-text3)`}}),(0,F.jsx)(`input`,{type:`text`,placeholder:`filter sessions...`,value:p,onChange:e=>m(e.target.value),className:`w-full pl-7 pr-3 py-1 text-[12px] outline-none rounded-sm`,style:{background:`var(--c-bg3)`,color:`var(--c-text)`,border:`1px solid var(--c-border)`}})]})]}),(0,F.jsxs)(`div`,{className:`card overflow-hidden`,children:[(0,F.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`text-[10px] uppercase tracking-wider`,style:{borderBottom:`1px solid var(--c-border)`,color:`var(--c-text3)`},children:[(0,F.jsx)(`th`,{className:`text-left py-2 px-3 font-medium`,children:`editor`}),(0,F.jsx)(`th`,{className:`text-left py-2 px-3 font-medium`,children:`name`}),(0,F.jsx)(`th`,{className:`text-left py-2 px-3 font-medium`,children:`mode`}),(0,F.jsx)(`th`,{className:`text-left py-2 px-3 font-medium`,children:`model`}),(0,F.jsx)(`th`,{className:`text-left py-2 px-3 font-medium`,children:`context`}),(0,F.jsx)(`th`,{className:`text-right py-2 px-3 font-medium`,children:`est. cost`}),(0,F.jsx)(`th`,{className:`text-left py-2 px-3 font-medium`,children:`updated`})]})}),(0,F.jsx)(`tbody`,{children:C.map(e=>(0,F.jsxs)(`tr`,{className:`cursor-pointer transition`,style:{borderBottom:`1px solid var(--c-border)`},onMouseEnter:e=>e.currentTarget.style.background=`var(--c-bg3)`,onMouseLeave:e=>e.currentTarget.style.background=`transparent`,onClick:()=>g(e.id),children:[(0,F.jsx)(`td`,{className:`py-2 px-3`,children:(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,F.jsx)(Gh,{source:e.source,size:12}),(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`},children:q(e.source)})]})}),(0,F.jsxs)(`td`,{className:`py-2 px-3 font-medium truncate max-w-[280px]`,style:{color:`var(--c-white)`},children:[e.name||(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:`Untitled`}),e.encrypted&&(0,F.jsx)(`span`,{className:`ml-1.5 text-[10px] text-yellow-500/60`,children:`locked`})]}),(0,F.jsx)(`td`,{className:`py-2 px-3`,style:{color:`var(--c-text2)`},children:e.mode||``}),(0,F.jsx)(`td`,{className:`py-2 px-3 font-mono truncate max-w-[150px]`,style:{color:`var(--c-text2)`},title:e.topModel||``,children:e.topModel||``}),(0,F.jsx)(`td`,{className:`py-2 px-3`,children:e.bubbleCount>=500?(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 font-bold`,style:{color:`#ef4444`},children:[(0,F.jsx)(wi,{size:9}),e.bubbleCount,` msgs`]}):e.bubbleCount>=100?(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 font-bold`,style:{color:`#f59e0b`},children:[(0,F.jsx)(wi,{size:9}),e.bubbleCount,` msgs`]}):(0,F.jsxs)(`span`,{style:{color:`var(--c-text3)`},children:[e.bubbleCount||0,` msgs`]})}),(0,F.jsx)(`td`,{className:`py-2 px-3 font-mono text-right`,style:{color:e.cost>0?`var(--c-text2)`:`var(--c-text3)`},children:e.cost>0?kh(e.cost):``}),(0,F.jsx)(`td`,{className:`py-2 px-3 whitespace-nowrap`,style:{color:`var(--c-text3)`},children:Ah(e.lastUpdatedAt||e.createdAt)})]},e.id))})]}),C.length===0&&(0,F.jsx)(`div`,{className:`text-center py-8 text-sm`,style:{color:`var(--c-text3)`},children:`no sessions found`})]})]}),(0,F.jsx)(XT,{chatId:h,onClose:()=>g(null)})]})}Lf.register(qf,km,Nm,cp,op,vp,wm,im,Yp);var NE=`JetBrains Mono, monospace`,PE=[`#6366f1`,`#a78bfa`,`#818cf8`,`#c084fc`,`#e879f9`,`#f472b6`,`#fb7185`,`#f87171`,`#fbbf24`,`#34d399`,`#2dd4bf`,`#38bdf8`,`#60a5fa`,`#a3e635`];function FE({overview:e}){let{dark:t}=tr(),n=dt(),r=t?`#555`:`#999`,i=t?`#777`:`#555`,a=t?`rgba(255,255,255,0.03)`:`rgba(0,0,0,0.06)`,[o,s]=(0,S.useState)(null),[c,l]=(0,S.useState)(!0),[u,d]=(0,S.useState)(``),[f,p]=(0,S.useState)(null),[m,h]=(0,S.useState)(null),g=e?.editors||[];if((0,S.useEffect)(()=>{l(!0),qi({editor:u,...jh(f)}).then(e=>{s(e),l(!1)}).catch(()=>l(!1))},[u,f]),!o)return(0,F.jsx)(wa,{label:`Loading cost data...`});let{totalCost:_,byModel:v,byEditor:y,byProject:b,monthly:x,topSessions:C,summary:w,unknownModels:T}=o,E=v.length>0?{labels:v.slice(0,10).map(e=>e.model),datasets:[{data:v.slice(0,10).map(e=>Math.round(e.cost*100)/100),backgroundColor:PE,borderWidth:0}]}:null,D=y.length>0?{labels:y.map(e=>q(e.editor)),datasets:[{data:y.map(e=>Math.round(e.cost*100)/100),backgroundColor:y.map(e=>Oh(e.editor)),borderWidth:0}]}:null,O=x.length>1?{labels:x.map(e=>e.month),datasets:[{label:`Cost ($)`,data:x.map(e=>e.cost),borderColor:`#6366f1`,backgroundColor:`rgba(99,102,241,0.1)`,borderWidth:2,tension:.3,pointRadius:3,pointHoverRadius:5,fill:!0}]}:null,k=b.length>0?{labels:b.slice(0,10).map(e=>e.name),datasets:[{data:b.slice(0,10).map(e=>Math.round(e.cost*100)/100),backgroundColor:`#818cf8`,borderRadius:3}]}:null,A={responsive:!0,maintainAspectRatio:!1,cutout:`55%`,plugins:{legend:{position:`right`,labels:{color:i,font:{size:9,family:NE},usePointStyle:!0,pointStyle:`circle`,padding:6}},tooltip:{bodyFont:{family:NE,size:10},titleFont:{family:NE,size:10},callbacks:{label:e=>` ${e.label}: $${e.raw.toFixed(2)}`}}}};return(0,F.jsxs)(`div`,{className:`fade-in space-y-3`,children:[(0,F.jsxs)($T,{icon:Ir,title:`Cost Analysis`,children:[(0,F.jsxs)(`select`,{value:u,onChange:e=>d(e.target.value),className:`px-2 py-1 text-[12px] outline-none`,style:{background:`var(--c-bg3)`,color:`var(--c-text)`,border:`1px solid var(--c-border)`},children:[(0,F.jsx)(`option`,{value:``,children:`All Editors`}),g.map(e=>(0,F.jsxs)(`option`,{value:e.id,children:[q(e.id),` (`,e.count,`)`]},e.id))]}),(0,F.jsx)(`div`,{className:`ml-auto`,children:(0,F.jsx)(Hh,{value:f,onChange:p})})]}),(0,F.jsxs)(`div`,{className:`flex items-start gap-2 px-3 py-2 text-[11px] rounded`,style:{background:`rgba(234,179,8,0.06)`,border:`1px solid rgba(234,179,8,0.15)`,color:`#ca8a04`},children:[(0,F.jsx)(wi,{size:12,className:`mt-0.5 shrink-0`}),(0,F.jsxs)(`span`,{children:[`These are `,(0,F.jsx)(`strong`,{children:`estimates`}),` based on public API list prices. Actual costs may be lower if you use discounted plans, commitments, prompt caching, batching, or provider credits. Token counts for some editors are approximated from character counts (~4 chars/token).`]})]}),(0,F.jsxs)(`div`,{className:`grid gap-2`,style:{gridTemplateColumns:`repeat(auto-fit, minmax(90px, 1fr))`},children:[(0,F.jsx)(K,{label:`total est. cost`,value:kh(_),sub:`all models`}),(0,F.jsx)(K,{label:`avg / session`,value:kh(w.avgPerSession),sub:`${J(w.totalSessions)} sessions`}),(0,F.jsx)(K,{label:`avg / day`,value:kh(w.avgPerDay),sub:`${w.totalDays} days`}),(0,F.jsx)(K,{label:`models`,value:v.length,sub:T.length>0?`${T.length} unknown`:`all priced`}),(0,F.jsx)(K,{label:`top model`,value:v[0]?.model||`—`,sub:v[0]?kh(v[0].cost):``}),(0,F.jsx)(K,{label:`top editor`,value:y[0]?q(y[0].editor):`—`,sub:y[0]?kh(y[0].cost):``})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-3`,children:[(0,F.jsxs)(`div`,{className:`card p-3 lg:col-span-2`,children:[(0,F.jsx)($,{children:`cost by model`}),E?(0,F.jsx)(`div`,{style:{height:220},children:(0,F.jsx)(wh,{data:{labels:v.slice(0,12).map(e=>e.model),datasets:[{data:v.slice(0,12).map(e=>Math.round(e.cost*100)/100),backgroundColor:PE,borderRadius:3}]},options:{responsive:!0,maintainAspectRatio:!1,indexAxis:`y`,scales:{x:{grid:{color:a},ticks:{color:r,font:{size:9,family:NE},callback:e=>`$`+e}},y:{grid:{display:!1},ticks:{color:i,font:{size:9,family:NE}}}},plugins:{legend:{display:!1},tooltip:{bodyFont:{family:NE,size:10},titleFont:{family:NE,size:10},callbacks:{label:e=>` $${e.raw.toFixed(2)}`}}}}})}):(0,F.jsx)(`div`,{className:`text-[11px] py-8 text-center`,style:{color:`var(--c-text3)`},children:`no cost data`})]}),(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`cost by editor`}),D?(0,F.jsx)(`div`,{style:{height:220},children:(0,F.jsx)(Th,{data:D,options:A})}):(0,F.jsx)(`div`,{className:`text-[11px] py-8 text-center`,style:{color:`var(--c-text3)`},children:`no cost data`})]})]}),O&&(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`monthly cost trend`}),(0,F.jsx)(`div`,{style:{height:180},children:(0,F.jsx)(Ch,{data:O,options:{responsive:!0,maintainAspectRatio:!1,interaction:{mode:`index`,intersect:!1},scales:{x:{grid:{display:!1},ticks:{color:r,font:{size:9,family:NE},maxRotation:0,maxTicksLimit:12}},y:{beginAtZero:!0,grid:{color:a},ticks:{color:r,font:{size:9,family:NE},callback:e=>`$`+e}}},plugins:{legend:{display:!1},tooltip:{bodyFont:{family:NE,size:10},titleFont:{family:NE,size:10},callbacks:{label:e=>` $${e.raw.toFixed(2)} (${x[e.dataIndex]?.sessions||0} sessions)`}}}}})})]}),k&&(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`cost by project (top 10)`}),(0,F.jsx)(`div`,{style:{height:220},children:(0,F.jsx)(wh,{data:k,options:{responsive:!0,maintainAspectRatio:!1,indexAxis:`y`,scales:{x:{grid:{color:a},ticks:{color:r,font:{size:9,family:NE},callback:e=>`$`+e}},y:{grid:{display:!1},ticks:{color:i,font:{size:9,family:NE}}}},plugins:{legend:{display:!1},tooltip:{bodyFont:{family:NE,size:10},titleFont:{family:NE,size:10},callbacks:{label:e=>` $${e.raw.toFixed(2)}`}}}}})})]}),(0,F.jsxs)(`div`,{className:`card overflow-hidden`,children:[(0,F.jsx)(`div`,{className:`px-3 py-2`,style:{borderBottom:`1px solid var(--c-border)`},children:(0,F.jsx)($,{children:`model breakdown`})}),(0,F.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`text-[10px] uppercase tracking-wider`,style:{borderBottom:`1px solid var(--c-border)`,color:`var(--c-text3)`},children:[(0,F.jsx)(`th`,{className:`text-left py-2 px-3 font-medium`,children:`model`}),(0,F.jsx)(`th`,{className:`text-right py-2 px-3 font-medium`,children:`input tokens`}),(0,F.jsx)(`th`,{className:`text-right py-2 px-3 font-medium`,children:`output tokens`}),(0,F.jsx)(`th`,{className:`text-right py-2 px-3 font-medium`,children:`cache read`}),(0,F.jsx)(`th`,{className:`text-right py-2 px-3 font-medium`,children:`cache write`}),(0,F.jsx)(`th`,{className:`text-right py-2 px-3 font-medium`,children:`est. cost`}),(0,F.jsx)(`th`,{className:`text-right py-2 px-3 font-medium`,children:`% of total`})]})}),(0,F.jsx)(`tbody`,{children:v.map((e,t)=>(0,F.jsxs)(`tr`,{style:{borderBottom:`1px solid var(--c-border)`},children:[(0,F.jsxs)(`td`,{className:`py-2 px-3 font-mono font-medium`,style:{color:`var(--c-white)`},children:[(0,F.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full mr-1.5`,style:{background:PE[t%PE.length]}}),e.model]}),(0,F.jsx)(`td`,{className:`py-2 px-3 text-right font-mono`,style:{color:`var(--c-text2)`},children:J(e.inputTokens)}),(0,F.jsx)(`td`,{className:`py-2 px-3 text-right font-mono`,style:{color:`var(--c-text2)`},children:J(e.outputTokens)}),(0,F.jsx)(`td`,{className:`py-2 px-3 text-right font-mono`,style:{color:`var(--c-text3)`},children:e.cacheRead>0?J(e.cacheRead):`—`}),(0,F.jsx)(`td`,{className:`py-2 px-3 text-right font-mono`,style:{color:`var(--c-text3)`},children:e.cacheWrite>0?J(e.cacheWrite):`—`}),(0,F.jsx)(`td`,{className:`py-2 px-3 text-right font-mono font-medium`,style:{color:`var(--c-white)`},children:kh(e.cost)}),(0,F.jsx)(`td`,{className:`py-2 px-3 text-right font-mono`,style:{color:`var(--c-text3)`},children:_>0?(e.cost/_*100).toFixed(1)+`%`:`—`})]},e.model))})]}),v.length===0&&(0,F.jsx)(`div`,{className:`text-center py-8 text-sm`,style:{color:`var(--c-text3)`},children:`no model cost data`})]}),C.length>0&&(0,F.jsxs)(`div`,{className:`card overflow-hidden`,children:[(0,F.jsx)(`div`,{className:`px-3 py-2`,style:{borderBottom:`1px solid var(--c-border)`},children:(0,F.jsx)($,{children:`most expensive sessions`})}),(0,F.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`text-[10px] uppercase tracking-wider`,style:{borderBottom:`1px solid var(--c-border)`,color:`var(--c-text3)`},children:[(0,F.jsx)(`th`,{className:`text-left py-2 px-3 font-medium`,children:`editor`}),(0,F.jsx)(`th`,{className:`text-left py-2 px-3 font-medium`,children:`name`}),(0,F.jsx)(`th`,{className:`text-left py-2 px-3 font-medium`,children:`project`}),(0,F.jsx)(`th`,{className:`text-left py-2 px-3 font-medium`,children:`model`}),(0,F.jsx)(`th`,{className:`text-right py-2 px-3 font-medium`,children:`msgs`}),(0,F.jsx)(`th`,{className:`text-right py-2 px-3 font-medium`,children:`est. cost`}),(0,F.jsx)(`th`,{className:`text-left py-2 px-3 font-medium`,children:`date`})]})}),(0,F.jsx)(`tbody`,{children:C.slice(0,30).map(e=>(0,F.jsxs)(`tr`,{className:`cursor-pointer transition`,style:{borderBottom:`1px solid var(--c-border)`},onMouseEnter:e=>e.currentTarget.style.background=`var(--c-bg3)`,onMouseLeave:e=>e.currentTarget.style.background=`transparent`,onClick:()=>h(e.id),children:[(0,F.jsx)(`td`,{className:`py-2 px-3`,children:(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,F.jsx)(Gh,{source:e.source,size:12}),(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`},children:q(e.source)})]})}),(0,F.jsx)(`td`,{className:`py-2 px-3 font-medium truncate max-w-[200px]`,style:{color:`var(--c-white)`},children:e.name||(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:`Untitled`})}),(0,F.jsx)(`td`,{className:`py-2 px-3 truncate max-w-[140px]`,style:{color:`var(--c-text2)`},title:e.folder,children:e.folder?(0,F.jsx)(`span`,{className:`cursor-pointer hover:underline`,style:{color:`var(--c-accent)`},onClick:t=>{t.stopPropagation(),n(`/projects/detail?folder=${encodeURIComponent(e.folder)}`)},children:e.folder.split(`/`).pop()}):``}),(0,F.jsx)(`td`,{className:`py-2 px-3 font-mono truncate max-w-[140px]`,style:{color:`var(--c-text2)`},title:e.model,children:e.model}),(0,F.jsx)(`td`,{className:`py-2 px-3 text-right`,style:{color:`var(--c-text3)`},children:e.messages}),(0,F.jsx)(`td`,{className:`py-2 px-3 text-right font-mono font-medium`,style:{color:`var(--c-white)`},children:kh(e.cost)}),(0,F.jsx)(`td`,{className:`py-2 px-3 whitespace-nowrap`,style:{color:`var(--c-text3)`},children:Ah(e.lastUpdatedAt)})]},e.id))})]})]}),T.length>0&&(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsxs)($,{children:[(0,F.jsx)(wi,{size:11,className:`inline mr-1`,style:{color:`#f59e0b`}}),`unpriced models (`,T.length,`)`]}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-2`,children:T.map(e=>(0,F.jsx)(`span`,{className:`text-[11px] px-2 py-0.5 font-mono`,style:{background:`rgba(245,158,11,0.08)`,color:`#f59e0b`,border:`1px solid rgba(245,158,11,0.2)`},children:e},e))})]}),(0,F.jsx)(XT,{chatId:m,onClose:()=>h(null)})]})}Lf.register(qf,wm,im,km,Nm,vp,cp,op,Yp);var IE=[{label:`Sessions per editor`,sql:`SELECT source, count() AS count FROM sessions_v GROUP BY source ORDER BY count DESC`},{label:`Top 10 projects`,sql:`SELECT project, count() AS sessions, sum(total_msgs) AS messages FROM sessions_v WHERE project != '' GROUP BY project ORDER BY sessions DESC LIMIT 10`},{label:`Messages per day`,sql:`SELECT toDate(ts) AS day, count() AS count FROM messages GROUP BY day ORDER BY day`},{label:`Top models`,sql:`SELECT model, count() AS count FROM messages WHERE model NOT IN ('', '<synthetic>') GROUP BY model ORDER BY count DESC LIMIT 10`},{label:`Top tools`,sql:`SELECT tool_name, count() AS count FROM tool_calls GROUP BY tool_name ORDER BY count DESC LIMIT 15`},{label:`Token usage by editor`,sql:`SELECT source, sum(input_tokens) AS input_tokens, sum(output_tokens) AS output_tokens FROM sessions_v GROUP BY source ORDER BY input_tokens DESC`},{label:`Sessions by mode`,sql:`SELECT mode, count() AS count FROM sessions_v WHERE mode != '' GROUP BY mode ORDER BY count DESC`},{label:`Hourly distribution`,sql:`SELECT toHour(ts) AS hour, count() AS count FROM messages GROUP BY hour ORDER BY hour`},{label:`Full-text search`,sql:`SELECT session_id, any(source) AS source, count() AS hits FROM messages WHERE text_ngram LIKE '%clickhouse%' GROUP BY session_id ORDER BY hits DESC LIMIT 10`}],LE=[{label:`Sessions per editor`,sql:`SELECT source, count() AS count FROM chats GROUP BY source ORDER BY count DESC`},{label:`Top 10 projects`,sql:`SELECT folder, count() AS sessions, sum(bubble_count) AS messages FROM chats WHERE folder IS NOT NULL GROUP BY folder ORDER BY sessions DESC LIMIT 10`},{label:`Messages per day`,sql:`SELECT toDate(toDateTime(intDiv(created_at, 1000))) AS day, count() AS count FROM chats WHERE created_at IS NOT NULL GROUP BY day ORDER BY day`},{label:`Top models`,sql:`SELECT model, count() AS count FROM messages WHERE model IS NOT NULL GROUP BY model ORDER BY count DESC LIMIT 10`},{label:`Top tools`,sql:`SELECT tool_name, count() AS count FROM tool_calls GROUP BY tool_name ORDER BY count DESC LIMIT 15`},{label:`Token usage by editor`,sql:`SELECT c.source AS source, sum(cs.total_input_tokens) AS input_tokens, sum(cs.total_output_tokens) AS output_tokens FROM chat_stats AS cs JOIN chats AS c ON c.id = cs.chat_id GROUP BY c.source ORDER BY input_tokens DESC`},{label:`Sessions by mode`,sql:`SELECT mode, count() AS count FROM chats WHERE mode IS NOT NULL GROUP BY mode ORDER BY count DESC`},{label:`Hourly distribution`,sql:`SELECT toHour(toDateTime(intDiv(created_at, 1000))) AS hour, count() AS count FROM chats WHERE created_at IS NOT NULL GROUP BY hour ORDER BY hour`}];function RE(){let{dark:e}=tr(),[t,n]=(0,S.useState)(IE),[r,i]=(0,S.useState)(IE[0].sql),[a,o]=(0,S.useState)(null),[s,c]=(0,S.useState)(null),[l,u]=(0,S.useState)(!1),[d,f]=(0,S.useState)(null),[p,m]=(0,S.useState)(!1),[h,g]=(0,S.useState)(`bar`),[_,v]=(0,S.useState)(null),y=(0,S.useRef)(null);(0,S.useEffect)(()=>{$i().then(e=>{f(e);let t=e?.tables?.includes(`sessions_v`)?IE:LE;n(t),i(e=>e===IE[0].sql||e===LE[0].sql?t[0].sql:e)}).catch(()=>{})},[]);let b=async()=>{u(!0),c(null),o(null);let e=performance.now();try{let t=await Qi(r.trim());v((performance.now()-e).toFixed(0)),t.error?c(t.error):o(t)}catch(e){c(e.message),v(null)}u(!1)},x=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),b())},C=()=>{if(!a)return;let e=a.columns.join(` `),t=a.rows.map(e=>a.columns.map(t=>e[t]??``).join(` `));navigator.clipboard.writeText([e,...t].join(`
|
|
66
|
+
`).length-8,` more lines`]})]})}function mE({call:e,toolName:t,index:n}){let[r,i]=(0,S.useState)(!1),a=dE(t,e.args),o=fE(e.args),s=e.folder?e.folder.split(`/`).pop():null,c=o||e.args&&Object.keys(e.args).length>0;return(0,F.jsxs)(`div`,{className:`px-2 py-1 text-[11px]`,style:{background:n%2==0?`var(--c-code-bg)`:`transparent`},children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-2 cursor-pointer`,onClick:()=>c&&i(!r),children:[(0,F.jsx)(Gh,{source:e.source,size:10}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[a&&(0,F.jsx)(`div`,{className:`font-mono truncate`,style:{color:`var(--c-white)`},title:a,children:a}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(`span`,{children:q(e.source)}),s&&(0,F.jsxs)(`span`,{children:[`· `,s]}),e.timestamp&&(0,F.jsxs)(`span`,{children:[`· `,new Date(e.timestamp).toLocaleDateString()]}),c&&(0,F.jsx)(`span`,{children:r?`▾`:`▸`})]})]})]}),r&&o&&(0,F.jsx)(pE,{diff:o}),r&&!o&&e.args&&Object.keys(e.args).length>0&&(0,F.jsx)(`pre`,{className:`mt-1 px-2 py-1 text-[10px] overflow-x-auto whitespace-pre-wrap break-all`,style:{background:`var(--c-code-bg)`,color:`var(--c-text2)`},children:JSON.stringify(e.args,null,2)})]})}function hE({toolName:e,folder:t,editor:n,dateRange:r,onClose:i}){let[a,o]=(0,S.useState)(null),[s,c]=(0,S.useState)(!0),l=t?t.split(`/`).pop():null;return(0,S.useEffect)(()=>{c(!0),ta(e,{folder:t||void 0,editor:n||void 0,...jh(r)}).then(e=>{o(e),c(!1)})},[e,t,n,r]),(0,F.jsxs)(`div`,{className:`card p-3 fade-in`,style:{borderColor:`rgba(99,102,241,0.3)`},children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(Oi,{size:12,style:{color:`var(--c-accent)`}}),(0,F.jsx)(`span`,{className:`text-xs font-bold`,style:{color:`var(--c-white)`},children:e}),(0,F.jsxs)(`span`,{className:`text-[11px]`,style:{color:`var(--c-text2)`},children:[a?`${a.length} calls`:`...`,a&&l?` in ${l}`:``]})]}),(0,F.jsx)(`button`,{onClick:i,className:`p-0.5`,style:{color:`var(--c-text2)`},children:(0,F.jsx)(ki,{size:12})})]}),s?(0,F.jsx)(`div`,{className:`text-[11px] py-4 text-center`,style:{color:`var(--c-text3)`},children:`loading...`}):a&&a.length>0?(0,F.jsx)(`div`,{className:`max-h-[500px] overflow-y-auto scrollbar-thin space-y-0.5`,children:a.map((t,n)=>(0,F.jsx)(mE,{call:t,toolName:e,index:n},n))}):(0,F.jsx)(`div`,{className:`text-[11px] py-4 text-center`,style:{color:`var(--c-text3)`},children:`no calls found`})]})}function gE({segments:e,height:t=6}){let n=e.reduce((e,t)=>e+t.value,0);return n===0?null:(0,F.jsx)(`div`,{className:`flex w-full rounded-full overflow-hidden`,style:{height:t},children:e.filter(e=>e.value>0).map((e,t)=>(0,F.jsx)(`div`,{title:`${e.label}: ${J(e.value)}`,className:`h-full transition-all`,style:{width:`${(e.value/n*100).toFixed(1)}%`,background:e.color}},t))})}function _E({overview:e}){let[t,n]=(0,S.useState)(``),[r,i]=(0,S.useState)(``),[a,o]=(0,S.useState)(null),[s,c]=(0,S.useState)(null),[l,u]=(0,S.useState)(!1),[d,f]=(0,S.useState)(null),[p,m]=(0,S.useState)(null),h=(0,S.useRef)(null),{dark:g}=tr(),_=g?`#a0a0a0`:`#444`,v=g?`#555`:`#999`,y=g?`rgba(255,255,255,0.03)`:`rgba(0,0,0,0.06)`,b=g?`#9ca3af`:`#555`,x=e?.editors||[],C=e?.topProjects||[];async function w(){u(!0);let e=jh(a),[n,i]=await Promise.all([Wi({editor:t,folder:r||void 0,limit:500,...e}),Ji({editor:t,folder:r||void 0,...e})]);c(n),m(i),u(!1)}(0,S.useEffect)(()=>{w()},[t,r,a]);let T=s?.topTools?.slice(0,15)||[],E=s?.topModels?.slice(0,10)||[],D=(0,S.useMemo)(()=>{if(!s)return null;let e=s.totalInputTokens+s.totalOutputTokens+s.totalCacheRead+s.totalCacheWrite,t=s.analyzedChats>0?(s.totalMessages/s.analyzedChats).toFixed(1):0,n=s.analyzedChats>0?(s.totalToolCalls/s.analyzedChats).toFixed(1):0,r=s.totalMessages>0?Math.round(e/s.totalMessages):0,i=s.totalInputTokens+s.totalCacheRead+s.totalCacheWrite;return{totalTok:e,msgsPerSession:t,toolsPerSession:n,tokPerMsg:r,cacheHitRate:i>0?(s.totalCacheRead/i*100).toFixed(1):0,outputRatio:i>0?(s.totalOutputTokens/i).toFixed(3):0,aiVsHuman:s.totalUserChars>0?(s.totalAssistantChars/s.totalUserChars).toFixed(1):0}},[s]),O=(0,S.useMemo)(()=>T.length>0?uE(T):[],[T]);function k(e,t){if(t.length>0){let e=T[t[0].index]?.name;e&&f(e)}}return(0,F.jsxs)(`div`,{className:`fade-in space-y-3`,children:[(0,F.jsxs)($T,{icon:Ci,title:`Deep Analysis`,children:[(0,F.jsxs)(`select`,{value:t,onChange:e=>n(e.target.value),className:`px-2 py-1 text-[12px] outline-none`,style:{background:`var(--c-bg3)`,color:`var(--c-text)`,border:`1px solid var(--c-border)`},children:[(0,F.jsx)(`option`,{value:``,children:`All Editors`}),x.map(e=>(0,F.jsx)(`option`,{value:e.id,children:q(e.id)},e.id))]}),(0,F.jsxs)(`select`,{value:r,onChange:e=>i(e.target.value),className:`px-2 py-1 text-[12px] outline-none max-w-[200px] truncate`,style:{background:`var(--c-bg3)`,color:`var(--c-text)`,border:`1px solid var(--c-border)`},children:[(0,F.jsx)(`option`,{value:``,children:`All Projects`}),C.map(e=>(0,F.jsx)(`option`,{value:e.fullPath,children:e.name},e.fullPath||e.name))]}),l&&(0,F.jsx)($r,{size:11,className:`animate-spin`,style:{color:`var(--c-text3)`}}),s&&(0,F.jsxs)(`span`,{className:`text-[11px]`,style:{color:`var(--c-text2)`},children:[s.analyzedChats,` sessions analyzed`]}),(0,F.jsx)(`div`,{className:`ml-auto`,children:(0,F.jsx)(Hh,{value:a,onChange:o})})]}),s&&D&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`grid gap-2`,style:{gridTemplateColumns:`repeat(auto-fit, minmax(90px, 1fr))`},children:[(0,F.jsx)(K,{label:`sessions`,value:s.analyzedChats}),(0,F.jsx)(K,{label:`messages`,value:J(s.totalMessages),sub:`${D.msgsPerSession}/session`}),(0,F.jsx)(K,{label:`tool calls`,value:J(s.totalToolCalls),sub:`${D.toolsPerSession}/session`}),(0,F.jsx)(K,{label:`total tokens`,value:J(D.totalTok),sub:`${J(D.tokPerMsg)}/msg`}),(0,F.jsx)(K,{label:`you wrote`,value:J(s.totalUserChars),sub:`AI: ${D.aiVsHuman}\u00d7 more`}),(0,F.jsx)(K,{label:`est. cost`,value:p&&p.totalCost>0?kh(p.totalCost):`—`})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-3`,children:[(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`token flow`}),(0,F.jsxs)(`div`,{className:`space-y-3 mt-2`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[11px] mb-1`,children:[(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`},children:`input tokens`}),(0,F.jsx)(`span`,{className:`font-bold`,style:{color:`var(--c-white)`},children:J(s.totalInputTokens+s.totalCacheRead+s.totalCacheWrite)})]}),(0,F.jsx)(gE,{segments:[{label:`Fresh input`,value:s.totalInputTokens,color:`#6366f1`},{label:`Cache write`,value:s.totalCacheWrite,color:`#fbbf24`},{label:`Cache read`,value:s.totalCacheRead,color:`#34d399`}]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 mt-1 text-[10px]`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`w-2 h-2 rounded-sm`,style:{background:`#6366f1`}}),` fresh `,J(s.totalInputTokens)]}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`w-2 h-2 rounded-sm`,style:{background:`#fbbf24`}}),` cache write `,J(s.totalCacheWrite)]}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`w-2 h-2 rounded-sm`,style:{background:`#34d399`}}),` cache read `,J(s.totalCacheRead)]})]})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[11px] mb-1`,children:[(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`},children:`output tokens`}),(0,F.jsx)(`span`,{className:`font-bold`,style:{color:`var(--c-white)`},children:J(s.totalOutputTokens)})]}),(0,F.jsx)(gE,{segments:[{label:`Output`,value:s.totalOutputTokens,color:`#a78bfa`}]})]}),s.totalCacheWrite>0&&(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[11px] mb-1`,children:[(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`},children:`cache write`}),(0,F.jsx)(`span`,{className:`font-bold`,style:{color:`var(--c-white)`},children:J(s.totalCacheWrite)})]}),(0,F.jsx)(gE,{segments:[{label:`Cache write`,value:s.totalCacheWrite,color:`#fbbf24`}]})]}),(0,F.jsxs)(`div`,{className:`pt-2`,style:{borderTop:`1px solid var(--c-border)`},children:[(0,F.jsx)(`div`,{className:`text-[10px] mb-1`,style:{color:`var(--c-text3)`},children:`overall token distribution`}),(0,F.jsx)(gE,{height:10,segments:[{label:`Input`,value:s.totalInputTokens,color:`#6366f1`},{label:`Output`,value:s.totalOutputTokens,color:`#a78bfa`},{label:`Cache Read`,value:s.totalCacheRead,color:`#34d399`},{label:`Cache Write`,value:s.totalCacheWrite,color:`#fbbf24`}]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 mt-1 text-[10px]`,style:{color:`var(--c-text3)`},children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`w-2 h-2 rounded-sm`,style:{background:`#6366f1`}}),` in`]}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`w-2 h-2 rounded-sm`,style:{background:`#a78bfa`}}),` out`]}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`w-2 h-2 rounded-sm`,style:{background:`#34d399`}}),` cache read`]}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`w-2 h-2 rounded-sm`,style:{background:`#fbbf24`}}),` cache write`]})]})]})]})]}),(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`efficiency insights`}),(0,F.jsxs)(`div`,{className:`space-y-3 mt-2`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`text-[11px] mb-1`,style:{color:`var(--c-text2)`},children:`you vs AI (characters)`}),(0,F.jsx)(gE,{height:8,segments:[{label:`You`,value:s.totalUserChars,color:`#6366f1`},{label:`AI`,value:s.totalAssistantChars,color:`#34d399`}]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between mt-1 text-[10px]`,children:[(0,F.jsxs)(`span`,{style:{color:`#6366f1`},children:[`You: `,J(s.totalUserChars)]}),(0,F.jsxs)(`span`,{style:{color:`#34d399`},children:[`AI: `,J(s.totalAssistantChars)]})]})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,F.jsxs)(`div`,{className:`p-2 rounded-sm`,style:{background:`var(--c-code-bg)`},children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px]`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(Ci,{size:9}),` output/input ratio`]}),(0,F.jsxs)(`div`,{className:`text-sm font-bold mt-0.5`,style:{color:`var(--c-white)`},children:[D.outputRatio,`×`]})]}),(0,F.jsxs)(`div`,{className:`p-2 rounded-sm`,style:{background:`var(--c-code-bg)`},children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px]`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(Ai,{size:9}),` cache hit rate`]}),(0,F.jsxs)(`div`,{className:`text-sm font-bold mt-0.5`,style:{color:parseFloat(D.cacheHitRate)>50?`#34d399`:parseFloat(D.cacheHitRate)>20?`#fbbf24`:`var(--c-white)`},children:[D.cacheHitRate,`%`]})]}),(0,F.jsxs)(`div`,{className:`p-2 rounded-sm`,style:{background:`var(--c-code-bg)`},children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px]`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(ni,{size:9}),` tokens per message`]}),(0,F.jsx)(`div`,{className:`text-sm font-bold mt-0.5`,style:{color:`var(--c-white)`},children:J(D.tokPerMsg)})]}),(0,F.jsxs)(`div`,{className:`p-2 rounded-sm`,style:{background:`var(--c-code-bg)`},children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px]`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(Oi,{size:9}),` tools per session`]}),(0,F.jsx)(`div`,{className:`text-sm font-bold mt-0.5`,style:{color:`var(--c-white)`},children:D.toolsPerSession})]})]}),(0,F.jsxs)(`div`,{className:`p-2 rounded-sm text-center`,style:{background:`var(--c-code-bg)`},children:[(0,F.jsx)(`div`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:`AI amplification factor`}),(0,F.jsxs)(`div`,{className:`text-lg font-bold`,style:{color:`var(--c-accent)`},children:[D.aiVsHuman,`×`]}),(0,F.jsxs)(`div`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:[`AI writes `,D.aiVsHuman,`× more than you type`]})]})]})]})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-3`,children:[(0,F.jsxs)(`div`,{className:`card p-3 lg:col-span-2`,children:[(0,F.jsxs)($,{children:[`most used tools `,(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:`(click to drill down)`})]}),(0,F.jsx)(`div`,{style:{height:Math.max(T.length*20+10,120)},children:T.length>0?(0,F.jsx)(wh,{ref:h,data:{labels:T.map(e=>e.name),datasets:[{data:T.map(e=>e.count),backgroundColor:sE.concat(oE).slice(0,T.length),borderRadius:2}]},options:{indexAxis:`y`,responsive:!0,maintainAspectRatio:!1,onClick:k,scales:{x:{grid:{color:y},ticks:{color:v,font:{size:8,family:cE}}},y:{grid:{display:!1},ticks:{color:_,font:{size:8,family:cE}}}},plugins:{legend:{display:!1},tooltip:{bodyFont:{family:cE,size:10},titleFont:{family:cE,size:10}}}}}):(0,F.jsx)(`div`,{className:`text-[11px] text-center py-8`,style:{color:`var(--c-text3)`},children:`no tool calls found`})})]}),(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`models`}),(0,F.jsx)(`div`,{style:{height:160},children:E.length>0?(0,F.jsx)(Th,{data:{labels:E.map(e=>e.name),datasets:[{data:E.map(e=>e.count),backgroundColor:oE,borderWidth:0}]},options:{responsive:!0,maintainAspectRatio:!1,cutout:`60%`,plugins:{legend:{position:`right`,labels:{color:b,font:{size:8,family:cE},usePointStyle:!0,pointStyle:`circle`,padding:6}},tooltip:{bodyFont:{family:cE,size:10},titleFont:{family:cE,size:10}}}}}):(0,F.jsx)(`div`,{className:`text-[11px] text-center py-8`,style:{color:`var(--c-text3)`},children:`no model data`})}),O.length>0&&(0,F.jsxs)(`div`,{className:`mt-3 pt-3`,style:{borderTop:`1px solid var(--c-border)`},children:[(0,F.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider mb-2`,style:{color:`var(--c-text3)`},children:`tool categories`}),(0,F.jsx)(`div`,{className:`space-y-1.5`,children:O.map(([e,{tools:t,total:n}])=>(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px]`,children:[(0,F.jsx)(`span`,{className:`truncate flex-1`,style:{color:`var(--c-text2)`},children:e}),(0,F.jsx)(`span`,{className:`font-bold`,style:{color:`var(--c-white)`},children:n}),(0,F.jsxs)(`span`,{style:{color:`var(--c-text3)`},children:[`(`,t.length,`)`]})]},e))})]})]})]}),d&&(0,F.jsx)(hE,{toolName:d,folder:r,editor:t,dateRange:a,onClose:()=>f(null)})]})]})}Lf.register(km,Nm,vp,wm,im);var vE=`JetBrains Mono, monospace`;function yE({label:e,a:t,b:n,colorA:r,colorB:i}){let a=parseFloat(t)||0,o=parseFloat(n)||0,s=Math.max(a,o,1);return(0,F.jsxs)(`div`,{className:`grid grid-cols-[1fr_100px_100px] gap-x-3 items-center py-0.5`,style:{borderBottom:`1px solid var(--c-border)`},children:[(0,F.jsx)(`div`,{className:`text-[11px]`,style:{color:`var(--c-text2)`},children:e}),(0,F.jsxs)(`div`,{className:`text-right`,children:[(0,F.jsx)(`span`,{className:`text-[12px] font-mono font-medium`,style:{color:`var(--c-white)`},children:typeof t==`number`?J(t):t}),(0,F.jsx)(`div`,{className:`h-1 rounded-full mt-0.5 ml-auto`,style:{background:r,width:`${(a/s*100).toFixed(0)}%`}})]}),(0,F.jsxs)(`div`,{className:`text-right`,children:[(0,F.jsx)(`span`,{className:`text-[12px] font-mono font-medium`,style:{color:`var(--c-white)`},children:typeof n==`number`?J(n):n}),(0,F.jsx)(`div`,{className:`h-1 rounded-full mt-0.5 ml-auto`,style:{background:i,width:`${(o/s*100).toFixed(0)}%`}})]})]})}function bE({titleA:e,titleB:t,colorA:n,colorB:r,itemsA:i,itemsB:a,limit:o=8}){return(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h4`,{className:`text-[11px] font-medium uppercase tracking-wider mb-1`,style:{color:n},children:e}),(0,F.jsxs)(`div`,{className:`space-y-0.5`,children:[i.slice(0,o).map(e=>(0,F.jsxs)(`div`,{className:`flex justify-between text-[11px] py-0.5`,children:[(0,F.jsx)(`span`,{className:`truncate`,style:{color:`var(--c-text)`},children:e.name}),(0,F.jsx)(`span`,{className:`font-mono ml-2`,style:{color:`var(--c-text3)`},children:e.count})]},e.name)),i.length===0&&(0,F.jsx)(`div`,{className:`text-[11px]`,style:{color:`var(--c-text3)`},children:`none`})]})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h4`,{className:`text-[11px] font-medium uppercase tracking-wider mb-1`,style:{color:r},children:t}),(0,F.jsxs)(`div`,{className:`space-y-0.5`,children:[a.slice(0,o).map(e=>(0,F.jsxs)(`div`,{className:`flex justify-between text-[11px] py-0.5`,children:[(0,F.jsx)(`span`,{className:`truncate`,style:{color:`var(--c-text)`},children:e.name}),(0,F.jsx)(`span`,{className:`font-mono ml-2`,style:{color:`var(--c-text3)`},children:e.count})]},e.name)),a.length===0&&(0,F.jsx)(`div`,{className:`text-[11px]`,style:{color:`var(--c-text3)`},children:`none`})]})]})]})}function xE({overview:e}){let t=e?.editors||[],[n,r]=(0,S.useState)(t[0]?.id||``),[i,a]=(0,S.useState)(t[1]?.id||``),[o,s]=(0,S.useState)(null),[c,l]=(0,S.useState)(!1),{dark:u}=tr(),d=u?`#888`:`#555`;async function f(){if(!n||!i)return;l(!0);let[e,t,r,a]=await Promise.all([Wi({editor:n,limit:500}),Wi({editor:i,limit:500}),Bi({editor:n,limit:1e3}),Bi({editor:i,limit:1e3})]);s({deepA:e,deepB:t,chatsA:r,chatsB:a}),l(!1)}(0,S.useEffect)(()=>{n&&i&&f()},[n,i]);let p=Oh(n),m=Oh(i),h=q(n),g=q(i),_=(e,t)=>t?(e/t).toFixed(1):`0`,v=(e,t)=>t?(e/t*100).toFixed(0)+`%`:`0%`,y=o?[{label:`Sessions`,a:o.chatsA.total,b:o.chatsB.total},{label:`Messages`,a:o.deepA.totalMessages,b:o.deepB.totalMessages},{label:`Tool Calls`,a:o.deepA.totalToolCalls,b:o.deepB.totalToolCalls},{label:`Input Tokens`,a:o.deepA.totalInputTokens,b:o.deepB.totalInputTokens},{label:`Output Tokens`,a:o.deepA.totalOutputTokens,b:o.deepB.totalOutputTokens},{label:`Cache Read`,a:o.deepA.totalCacheRead,b:o.deepB.totalCacheRead}]:[],b=o?[{label:`Avg Msgs / Session`,a:_(o.deepA.totalMessages,o.deepA.analyzedChats),b:_(o.deepB.totalMessages,o.deepB.analyzedChats)},{label:`Avg Tools / Session`,a:_(o.deepA.totalToolCalls,o.deepA.analyzedChats),b:_(o.deepB.totalToolCalls,o.deepB.analyzedChats)},{label:`Avg Tokens / Session`,a:_(o.deepA.totalInputTokens+o.deepA.totalOutputTokens,o.deepA.analyzedChats),b:_(o.deepB.totalInputTokens+o.deepB.totalOutputTokens,o.deepB.analyzedChats)},{label:`Output / Input Ratio`,a:_(o.deepA.totalOutputTokens,o.deepA.totalInputTokens||1),b:_(o.deepB.totalOutputTokens,o.deepB.totalInputTokens||1)},{label:`Tools / Message`,a:_(o.deepA.totalToolCalls,o.deepA.totalMessages||1),b:_(o.deepB.totalToolCalls,o.deepB.totalMessages||1)},{label:`Cache Hit Rate`,a:v(o.deepA.totalCacheRead,o.deepA.totalInputTokens),b:v(o.deepB.totalCacheRead,o.deepB.totalInputTokens)}]:[],x=[`Sessions`,`Messages`,`Tool Calls`],C=o?[o.chatsA.total,o.deepA.totalMessages,o.deepA.totalToolCalls]:[],w=o?[o.chatsB.total,o.deepB.totalMessages,o.deepB.totalToolCalls]:[],T={labels:x,datasets:[{label:h,data:C,backgroundColor:p+`99`,borderRadius:2},{label:g,data:w,backgroundColor:m+`99`,borderRadius:2}]},E=o?{labels:[`Input`,`Output`,`Cache Read`],datasets:[{label:h,data:[o.deepA.totalInputTokens,o.deepA.totalOutputTokens,o.deepA.totalCacheRead],backgroundColor:p+`99`,borderRadius:2},{label:g,data:[o.deepB.totalInputTokens,o.deepB.totalOutputTokens,o.deepB.totalCacheRead],backgroundColor:m+`99`,borderRadius:2}]}:null,D={responsive:!0,maintainAspectRatio:!1,plugins:{legend:{labels:{color:d,font:{size:9,family:vE},usePointStyle:!0,pointStyle:`circle`,padding:8}},tooltip:{bodyFont:{family:vE,size:10},titleFont:{family:vE,size:10}}},scales:{x:{grid:{display:!1},ticks:{color:d,font:{size:9,family:vE}}},y:{grid:{color:u?`rgba(255,255,255,0.03)`:`rgba(0,0,0,0.06)`},ticks:{color:d,font:{size:9,family:vE}}}}};return(0,F.jsxs)(`div`,{className:`fade-in space-y-3`,children:[(0,F.jsxs)($T,{icon:ur,title:`Compare`,children:[(0,F.jsx)(`select`,{value:n,onChange:e=>r(e.target.value),className:`px-2 py-1 text-[12px] outline-none`,style:{background:`var(--c-bg3)`,color:`var(--c-text)`,border:`1px solid var(--c-border)`},children:t.map(e=>(0,F.jsx)(`option`,{value:e.id,children:q(e.id)},e.id))}),(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:`vs`}),(0,F.jsx)(`select`,{value:i,onChange:e=>a(e.target.value),className:`px-2 py-1 text-[12px] outline-none`,style:{background:`var(--c-bg3)`,color:`var(--c-text)`,border:`1px solid var(--c-border)`},children:t.map(e=>(0,F.jsx)(`option`,{value:e.id,children:q(e.id)},e.id))}),c&&(0,F.jsx)($r,{size:11,className:`animate-spin`,style:{color:`var(--c-text3)`}})]}),o&&(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-2`,children:[(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,F.jsx)(`h3`,{className:`text-[11px] font-medium uppercase tracking-wider`,style:{color:`var(--c-text2)`},children:`totals`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px]`,children:[(0,F.jsxs)(`span`,{style:{color:p},children:[`● `,h]}),(0,F.jsxs)(`span`,{style:{color:m},children:[`● `,g]})]})]}),y.map(e=>(0,F.jsx)(yE,{label:e.label,a:e.a,b:e.b,colorA:p,colorB:m},e.label))]}),(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)(`h3`,{className:`text-[11px] font-medium uppercase tracking-wider mb-1.5`,style:{color:`var(--c-text2)`},children:`efficiency`}),b.map(e=>(0,F.jsx)(yE,{label:e.label,a:e.a,b:e.b,colorA:p,colorB:m},e.label))]})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-2`,children:[(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)(`h3`,{className:`text-[11px] font-medium uppercase tracking-wider mb-2`,style:{color:`var(--c-text2)`},children:`usage`}),(0,F.jsx)(`div`,{style:{height:160},children:(0,F.jsx)(wh,{data:T,options:D})})]}),E&&(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)(`h3`,{className:`text-[11px] font-medium uppercase tracking-wider mb-2`,style:{color:`var(--c-text2)`},children:`tokens`}),(0,F.jsx)(`div`,{style:{height:160},children:(0,F.jsx)(wh,{data:E,options:D})})]})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-2`,children:[(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)(`h3`,{className:`text-[11px] font-medium uppercase tracking-wider mb-2`,style:{color:`var(--c-text2)`},children:`top tools`}),(0,F.jsx)(bE,{titleA:h,titleB:g,colorA:p,colorB:m,itemsA:o.deepA.topTools,itemsB:o.deepB.topTools,limit:10})]}),(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)(`h3`,{className:`text-[11px] font-medium uppercase tracking-wider mb-2`,style:{color:`var(--c-text2)`},children:`models`}),(0,F.jsx)(bE,{titleA:h,titleB:g,colorA:p,colorB:m,itemsA:o.deepA.topModels,itemsB:o.deepB.topModels,limit:8})]})]})]})]})}Lf.register(qf,wm,im,km,Nm,vp);var SE=`JetBrains Mono, monospace`,CE=[`#6366f1`,`#a78bfa`,`#818cf8`,`#c084fc`,`#e879f9`,`#f472b6`,`#fb7185`,`#f87171`,`#fbbf24`,`#34d399`];function wE({overview:e}){let{dark:t}=tr(),n=t?`#888`:`#555`,r=t?`#555`:`#999`,i=t?`rgba(255,255,255,0.03)`:`rgba(0,0,0,0.06)`,[a,o]=(0,S.useState)(null),[s,c]=(0,S.useState)(``),[l,u]=(0,S.useState)(``),[d,f]=(0,S.useState)(null),[p,m]=(0,S.useState)(null),h=dt(),g=e?.editors||[];if((0,S.useEffect)(()=>{let e=jh(d);Promise.all([Hi(e),Ji(e)]).then(([e,t])=>{o(e),m(t)})},[d]),!a)return(0,F.jsx)(wa,{label:`Loading projects...`});let _=a.filter(e=>!(l&&!e.editors[l]||s&&!e.folder.toLowerCase().includes(s.toLowerCase())&&!e.name.toLowerCase().includes(s.toLowerCase()))),v=a.reduce((e,t)=>e+t.totalSessions,0),y=a.reduce((e,t)=>e+t.totalMessages,0),b=a.reduce((e,t)=>e+t.totalInputTokens+t.totalOutputTokens,0),x=Math.max(...a.map(e=>e.totalSessions),1),C={},w={};for(let e of a){for(let t of e.topModels)C[t.name]=(C[t.name]||0)+t.count;for(let[t,n]of Object.entries(e.editors))w[t]=(w[t]||0)+n}let T=Object.entries(C).sort((e,t)=>t[1]-e[1]).slice(0,8),E=Object.entries(w).sort((e,t)=>t[1]-e[1]),D=a.slice(0,10);return(0,F.jsxs)(`div`,{className:`fade-in space-y-3`,children:[(0,F.jsx)($T,{icon:Ur,title:`Projects`}),(0,F.jsxs)(`div`,{className:`grid gap-2`,style:{gridTemplateColumns:`repeat(auto-fit, minmax(90px, 1fr))`},children:[(0,F.jsx)(K,{label:`projects`,value:a.length}),(0,F.jsx)(K,{label:`sessions`,value:J(v),onClick:()=>h(`/sessions`)}),(0,F.jsx)(K,{label:`messages`,value:J(y)}),(0,F.jsx)(K,{label:`tokens`,value:J(b)}),(0,F.jsx)(K,{label:`est. cost`,value:p&&p.totalCost>0?kh(p.totalCost):`—`})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-3`,children:[(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsxs)($,{children:[`top projects `,(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:`by sessions`})]}),(0,F.jsx)(`div`,{style:{height:160},children:(0,F.jsx)(wh,{data:{labels:D.map(e=>e.name),datasets:[{data:D.map(e=>e.totalSessions),backgroundColor:`#6366f1`,borderRadius:3}]},options:{responsive:!0,maintainAspectRatio:!1,indexAxis:`y`,scales:{x:{grid:{color:i},ticks:{color:r,font:{size:8,family:SE}}},y:{grid:{display:!1},ticks:{color:n,font:{size:8,family:SE},callback:(e,t)=>D[t]?.name?.length>16?D[t].name.slice(0,15)+`…`:D[t]?.name}}},plugins:{legend:{display:!1},tooltip:{bodyFont:{family:SE,size:10},titleFont:{family:SE,size:10}}}}})})]}),(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`editors`}),(0,F.jsx)(`div`,{style:{height:160},children:(0,F.jsx)(Th,{data:{labels:E.map(e=>q(e[0])),datasets:[{data:E.map(e=>e[1]),backgroundColor:E.map(e=>Oh(e[0])),borderWidth:0}]},options:{responsive:!0,maintainAspectRatio:!1,cutout:`60%`,plugins:{legend:{position:`right`,labels:{color:n,font:{size:9,family:SE},usePointStyle:!0,pointStyle:`circle`,padding:6}},tooltip:{bodyFont:{family:SE,size:10},titleFont:{family:SE,size:10}}}}})})]}),(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`models`}),(0,F.jsx)(`div`,{style:{height:160},children:T.length>0?(0,F.jsx)(Th,{data:{labels:T.map(e=>e[0]),datasets:[{data:T.map(e=>e[1]),backgroundColor:CE,borderWidth:0}]},options:{responsive:!0,maintainAspectRatio:!1,cutout:`60%`,plugins:{legend:{position:`right`,labels:{color:n,font:{size:9,family:SE},usePointStyle:!0,pointStyle:`circle`,padding:6}},tooltip:{bodyFont:{family:SE,size:10},titleFont:{family:SE,size:10}}}}}):(0,F.jsx)(`div`,{className:`text-xs text-center py-12`,style:{color:`var(--c-text3)`},children:`no model data`})})]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsxs)(`select`,{value:l,onChange:e=>u(e.target.value),className:`px-2 py-1 text-[12px] outline-none`,style:{background:`var(--c-bg3)`,color:`var(--c-text)`,border:`1px solid var(--c-border)`},children:[(0,F.jsx)(`option`,{value:``,children:`All Editors`}),g.map(e=>(0,F.jsx)(`option`,{value:e.id,children:q(e.id)},e.id))]}),(0,F.jsxs)(`div`,{className:`relative flex-1 max-w-sm`,children:[(0,F.jsx)(ui,{size:12,className:`absolute left-2.5 top-1/2 -translate-y-1/2`,style:{color:`var(--c-text3)`}}),(0,F.jsx)(`input`,{type:`text`,placeholder:`Search projects...`,value:s,onChange:e=>c(e.target.value),className:`w-full pl-7 pr-3 py-1 text-[12px] outline-none`,style:{background:`var(--c-bg3)`,color:`var(--c-text)`,border:`1px solid var(--c-border)`}})]}),(0,F.jsx)(`div`,{className:`ml-auto`,children:(0,F.jsx)(Hh,{value:d,onChange:f})})]}),(0,F.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3`,children:_.map(e=>{let t=Object.entries(e.editors).sort((e,t)=>t[1]-e[1]),n=e.totalInputTokens+e.totalOutputTokens,r=e.topModels[0];return(0,F.jsxs)(`div`,{className:`card p-3 cursor-pointer transition hover:opacity-90 flex flex-col gap-2.5`,onClick:()=>h(`/projects/detail?folder=${encodeURIComponent(e.folder)}`),children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-2 min-w-0`,children:[(0,F.jsx)(Ur,{size:14,className:`flex-shrink-0 mt-0.5`,style:{color:`var(--c-accent)`}}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,F.jsx)(`div`,{className:`text-[12px] font-bold truncate`,style:{color:`var(--c-white)`},children:e.name}),(0,F.jsx)(`div`,{className:`text-[10px] truncate`,style:{color:`var(--c-text3)`},children:e.folder})]}),(0,F.jsx)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:t.slice(0,4).map(([e])=>(0,F.jsx)(Gh,{source:e,size:12},e))})]}),(0,F.jsx)(`div`,{className:`w-full h-1 rounded-full overflow-hidden`,style:{background:`var(--c-code-bg)`},children:(0,F.jsx)(`div`,{className:`h-full rounded-full`,style:{width:`${(e.totalSessions/x*100).toFixed(1)}%`,background:`var(--c-accent)`}})}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1 text-[11px]`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(ni,{size:9,style:{color:`var(--c-text3)`}}),(0,F.jsxs)(`span`,{style:{color:`var(--c-text2)`},children:[e.totalSessions,` sessions`]}),(0,F.jsxs)(`span`,{className:`ml-auto font-bold`,style:{color:`var(--c-white)`},children:[J(e.totalMessages),` msgs`]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(Oi,{size:9,style:{color:`var(--c-text3)`}}),(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`},children:`tools`}),(0,F.jsx)(`span`,{className:`ml-auto font-bold`,style:{color:`var(--c-white)`},children:J(e.totalToolCalls)})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(Nr,{size:9,style:{color:`var(--c-text3)`}}),(0,F.jsx)(`span`,{className:`truncate`,style:{color:`var(--c-text2)`},children:r?r.name:`—`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:`tok`}),(0,F.jsx)(`span`,{className:`ml-auto font-bold`,style:{color:n>0?`var(--c-white)`:`var(--c-text3)`},children:n>0?J(n):`—`})]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 pt-1 text-[10px]`,style:{borderTop:`1px solid var(--c-border)`},children:[(0,F.jsx)(`div`,{className:`flex items-center gap-1.5 flex-1 min-w-0`,children:t.map(([e,t])=>(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 truncate`,children:[(0,F.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full flex-shrink-0`,style:{background:Oh(e)}}),(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:q(e)}),(0,F.jsx)(`span`,{className:`font-bold`,style:{color:`var(--c-text2)`},children:t})]},e))}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(vr,{size:8}),(0,F.jsx)(`span`,{children:Ah(e.lastSeen)})]})]})]},e.folder)})}),_.length===0&&(0,F.jsx)(`div`,{className:`text-center py-12 text-sm`,style:{color:`var(--c-text3)`},children:`no projects found`})]})}var TE={"A+":`#22c55e`,A:`#22c55e`,"B+":`#4ade80`,B:`#4ade80`,"C+":`#facc15`,C:`#facc15`,"D+":`#f97316`,D:`#f97316`,F:`#ef4444`},EE={"Repo Hygiene":_r,"Grounding Docs":Br,Testing:Hr,"Agent Configs":hr,"AI Context":ei,"Prompts & Skills":si,MCP:oi,"AI Dependencies":ii,"AI Deps":ii};function DE({missing:e}){let[t,n]=(0,S.useState)(!1),r=(0,S.useRef)(null);(0,S.useEffect)(()=>{if(!t)return;let e=e=>{r.current&&!r.current.contains(e.target)&&n(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[t]);let i=e.filter(e=>e.weight>0),a=i.length>0?i:e.slice(0,5);return a.length===0?null:(0,F.jsxs)(`span`,{ref:r,className:`relative flex-shrink-0`,children:[(0,F.jsx)(`button`,{onClick:e=>{e.stopPropagation(),n(!t)},className:`flex items-center justify-center w-4 h-4 rounded-full transition hover:opacity-80`,style:{color:`var(--c-text3)`,background:`var(--c-bg3)`},children:(0,F.jsx)(Jr,{size:10})}),t&&(0,F.jsxs)(`div`,{className:`absolute right-0 top-6 z-50 w-64 p-2.5 rounded shadow-lg`,style:{background:`var(--c-bg)`,border:`1px solid var(--c-border)`,boxShadow:`0 4px 24px rgba(0,0,0,0.3)`},children:[(0,F.jsx)(`div`,{className:`text-[11px] font-medium mb-1.5`,style:{color:`var(--c-white)`},children:`How to improve`}),(0,F.jsx)(`div`,{className:`space-y-1`,children:a.map(e=>(0,F.jsxs)(`div`,{className:`text-[11px]`,style:{color:`var(--c-text2)`},children:[(0,F.jsxs)(`span`,{style:{color:`var(--c-text)`},children:[`+ `,e.label]}),e.weight>0&&(0,F.jsxs)(`span`,{style:{color:`var(--c-text3)`},children:[` (`,e.weight,`pt)`]})]},e.id))})]})]})}function OE({folder:e}){console.log(`AiAuditCard rendering, folder:`,e);let[t,n]=(0,S.useState)(null),[r,i]=(0,S.useState)(!1),[a,o]=(0,S.useState)(null),[s,c]=(0,S.useState)(new Set),l=async()=>{if(e){i(!0),o(null);try{let t=await na(e);if(t.error)throw Error(t.error);n(t)}catch(e){o(e.message)}i(!1)}};if((0,S.useEffect)(()=>{console.log(`AiAuditCard useEffect triggered, folder:`,e),l()},[e]),r)return(0,F.jsx)(`div`,{className:`card p-4`,children:(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)($r,{size:14,className:`animate-spin`,style:{color:`var(--c-accent)`}}),(0,F.jsx)(`span`,{className:`text-[12px]`,style:{color:`var(--c-text2)`},children:`Running AI readiness audit...`})]})});if(a)return(0,F.jsx)(`div`,{className:`card p-4`,children:(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(wi,{size:14,style:{color:`#ef4444`}}),(0,F.jsxs)(`span`,{className:`text-[12px]`,style:{color:`var(--c-text2)`},children:[`Audit failed: `,a]})]}),(0,F.jsxs)(`button`,{onClick:l,className:`flex items-center gap-1.5 px-2.5 py-1 text-[11px] rounded transition hover:opacity-80`,style:{color:`var(--c-text2)`,border:`1px solid var(--c-border)`},children:[(0,F.jsx)(li,{size:10}),`Retry`]})]})});if(!t)return null;let u=TE[t.grade]||`var(--c-text2)`,d=t.sections||{},f=t.findings||[],p={};for(let e of f){let t=e.section||`Other`;p[t]||(p[t]=[]),p[t].push(e)}return(0,F.jsxs)(`div`,{className:`card p-4 space-y-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(hi,{size:16,style:{color:u}}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)($,{children:`ai readiness audit`}),(0,F.jsxs)(`div`,{className:`text-[10px] -mt-1.5`,style:{color:`var(--c-text3)`},children:[`powered by `,(0,F.jsx)(`code`,{style:{fontFamily:`JetBrains Mono, monospace`},children:`npx check-ai`})]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 ml-auto`,children:[(0,F.jsxs)(`span`,{className:`text-[11px]`,style:{color:`var(--c-text3)`},children:[t.checks?.passed||0,`/`,t.checks?.total||0,` checks · `,t.points?.earned||0,`/`,t.points?.max||0,` pts`]}),(0,F.jsx)(`button`,{onClick:l,className:`flex items-center gap-1 px-2 py-1 text-[11px] rounded transition hover:opacity-80`,style:{color:`var(--c-text2)`,border:`1px solid var(--c-border)`},children:(0,F.jsx)(li,{size:10})})]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(`div`,{className:`w-11 h-11 rounded-lg flex items-center justify-center text-base font-black flex-shrink-0`,style:{background:`${u}15`,color:u,border:`1.5px solid ${u}30`},children:t.grade}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,F.jsxs)(`div`,{className:`flex items-baseline gap-1.5`,children:[(0,F.jsx)(`span`,{className:`text-base font-bold`,style:{color:`var(--c-white)`},children:t.score}),(0,F.jsx)(`span`,{className:`text-[11px]`,style:{color:`var(--c-text3)`},children:`/10`}),(0,F.jsx)(`span`,{className:`text-[11px] ml-1`,style:{color:`var(--c-text2)`},children:t.label})]}),(0,F.jsx)(`div`,{className:`w-full h-2 rounded-full overflow-hidden mt-1`,style:{background:`var(--c-code-bg)`},children:(0,F.jsx)(`div`,{className:`h-full rounded-full`,style:{width:`${((t.score||0)/10*100).toFixed(1)}%`,background:u}})})]})]}),(0,F.jsx)(`div`,{children:Object.entries(d).map(([e,t])=>{let n=EE[e]||Br,r=p[e]||[],i=r.filter(e=>e.found),a=r.filter(e=>!e.found),o=t.pct||0,l=o>=70?`#22c55e`:o>=40?`#facc15`:o>0?`#f97316`:`var(--c-text3)`,u=[];for(let e of i)e.detail?u.push(e.detail):e.matchedPath?u.push(e.matchedPath):e.matches&&e.matches.length>0?u.push(e.matches.join(`, `)):u.push(e.label);let d=u.length>0?u.slice(0,3).join(` · `)+(u.length>3?` …`:``):`none detected`,f=s.has(e);return(0,F.jsxs)(`div`,{style:{borderBottom:`1px solid var(--c-border)`},children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2.5 py-2 cursor-pointer transition hover:bg-[var(--c-bg3)]`,onClick:()=>c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),children:[f?(0,F.jsx)(Cr,{size:12,style:{color:`var(--c-text3)`,flexShrink:0}}):(0,F.jsx)(wr,{size:12,style:{color:`var(--c-text3)`,flexShrink:0}}),(0,F.jsx)(n,{size:14,style:{color:`var(--c-text3)`,flexShrink:0}}),(0,F.jsx)(`span`,{className:`text-[12px] font-medium w-32 flex-shrink-0`,style:{color:`var(--c-white)`},children:e}),(0,F.jsx)(`span`,{className:`text-[11px] flex-1 truncate`,style:{color:i.length>0?`var(--c-text2)`:`var(--c-text3)`},children:d}),(0,F.jsxs)(`span`,{className:`text-[11px] flex-shrink-0`,style:{color:`var(--c-text3)`},children:[i.length,`/`,r.length]}),(0,F.jsx)(`div`,{className:`w-20 h-2 rounded-full overflow-hidden flex-shrink-0`,style:{background:`var(--c-code-bg)`},children:(0,F.jsx)(`div`,{className:`h-full rounded-full`,style:{width:`${o}%`,background:l}})}),(0,F.jsxs)(`span`,{className:`text-[11px] w-9 text-right font-bold flex-shrink-0`,style:{color:l},children:[o,`%`]}),a.length>0&&(0,F.jsx)(DE,{missing:a})]}),f&&i.length>0&&(0,F.jsx)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-0.5 pb-2 pl-12`,children:i.map(e=>(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] py-0.5`,children:[(0,F.jsx)(Dr,{size:10,style:{color:`#22c55e`,flexShrink:0}}),(0,F.jsx)(`span`,{style:{color:`var(--c-text)`},children:e.label}),e.matchedPath&&(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:e.matchedPath}),e.detail&&(0,F.jsxs)(`span`,{style:{color:`var(--c-text2)`},children:[`— `,e.detail]})]},e.id))})]},e)})})]})}Lf.register(qf,wm,im,km,Nm,vp);var kE=`JetBrains Mono, monospace`,AE=[`#6366f1`,`#a78bfa`,`#818cf8`,`#c084fc`,`#e879f9`,`#f472b6`,`#fb7185`,`#f87171`,`#fbbf24`,`#34d399`],jE=[`#10b981`,`#34d399`,`#6ee7b7`,`#a7f3d0`,`#d1fae5`,`#ecfdf5`,`#b8f0d8`,`#7ce0b8`,`#4ade80`,`#22c55e`];function ME(){let[e]=zn(),t=dt(),n=e.get(`folder`),{dark:r}=tr(),i=r?`#888`:`#555`,a=r?`#555`:`#999`,o=r?`rgba(255,255,255,0.03)`:`rgba(0,0,0,0.06)`,[s,c]=(0,S.useState)(null),[l,u]=(0,S.useState)([]),[d,f]=(0,S.useState)(!0),[p,m]=(0,S.useState)(``),[h,g]=(0,S.useState)(null),[_,v]=(0,S.useState)(null),[y,b]=(0,S.useState)(null);(0,S.useEffect)(()=>{n&&(f(!0),Promise.all([Hi(),Bi({folder:n,limit:1e3}),Ji({folder:n})]).then(([e,t,r])=>{let i=e.find(e=>e.folder===n);c(i||null),u(t.chats||[]),v(r),i&&b(new Set(Object.keys(i.editors))),f(!1)}))},[n]);let x=(0,S.useMemo)(()=>y?l.filter(e=>y.has(e.source)):l,[l,y]),C=(0,S.useMemo)(()=>{if(!p)return x;let e=p.toLowerCase();return x.filter(t=>t.name&&t.name.toLowerCase().includes(e)||t.topModel&&t.topModel.toLowerCase().includes(e)||t.source&&t.source.toLowerCase().includes(e))},[x,p]),w=e=>{b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};if(!n)return(0,F.jsx)(`div`,{className:`text-sm py-12 text-center`,style:{color:`var(--c-text3)`},children:`no project specified`});if(d)return(0,F.jsx)(wa,{label:`Loading project...`});if(!s)return(0,F.jsx)(`div`,{className:`text-sm py-12 text-center`,style:{color:`var(--c-text3)`},children:`project not found`});let T=Object.entries(s.editors).sort((e,t)=>t[1]-e[1]),E=!y||y.size===T.length,D=x.length,O={},k={};for(let e of x)O[e.source]=(O[e.source]||0)+1,e.topModel&&(k[e.topModel]=(k[e.topModel]||0)+1);let A=Object.entries(k).sort((e,t)=>t[1]-e[1]).slice(0,10),j=Math.max(...Object.values(O),1),ee=s.totalInputTokens+s.totalOutputTokens,te=s.totalInputTokens>0?(s.totalOutputTokens/s.totalInputTokens).toFixed(1):`0`,ne=E?s.totalSessions:D,re=E&&s.totalSessions>0?(s.totalMessages/s.totalSessions).toFixed(1):0;return(0,F.jsxs)(`div`,{className:`fade-in space-y-3`,children:[(0,F.jsxs)(`div`,{className:`card p-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,F.jsx)(`button`,{onClick:()=>t(`/projects`),className:`flex items-center gap-1 text-[12px] transition mt-0.5 flex-shrink-0`,style:{color:`var(--c-text3)`},children:(0,F.jsx)(dr,{size:12})}),(0,F.jsx)(Ur,{size:18,className:`flex-shrink-0 mt-0.5`,style:{color:`var(--c-accent)`}}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,F.jsx)(`h1`,{className:`text-sm font-bold truncate`,style:{color:`var(--c-white)`},children:s.name}),(0,F.jsx)(`div`,{className:`text-[11px] truncate`,style:{color:`var(--c-text3)`},children:s.folder})]}),(0,F.jsx)(`div`,{className:`flex items-center gap-1.5 flex-shrink-0`,children:T.map(([e])=>(0,F.jsx)(Gh,{source:e,size:14},e))})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-4 mt-3 pt-3 text-[11px]`,style:{borderTop:`1px solid var(--c-border)`},children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(vr,{size:9}),(0,F.jsx)(`span`,{children:Ah(s.firstSeen)}),(0,F.jsx)(`span`,{children:`→`}),(0,F.jsx)(`span`,{children:Ah(s.lastSeen)})]}),(0,F.jsx)(`div`,{className:`flex items-center gap-1.5 ml-auto`,children:T.map(([e,t])=>(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,F.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full`,style:{background:Oh(e)}}),(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:q(e)}),(0,F.jsx)(`span`,{className:`font-bold`,style:{color:`var(--c-text2)`},children:t})]},e))})]})]}),(0,F.jsxs)(`div`,{className:`grid gap-2`,style:{gridTemplateColumns:`repeat(auto-fit, minmax(90px, 1fr))`},children:[(0,F.jsx)(K,{label:`sessions`,value:ne,sub:E?``:`filtered`}),(0,F.jsx)(K,{label:`messages`,value:J(s.totalMessages),sub:`${re} avg/session`}),(0,F.jsx)(K,{label:`tool calls`,value:J(s.totalToolCalls),sub:(0,F.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,F.jsx)(Oi,{size:8}),` invocations`]})}),(0,F.jsx)(K,{label:`tokens`,value:J(ee),sub:`${te}\u00d7 out/in`}),s.totalCacheRead>0&&(0,F.jsx)(K,{label:`cache read`,value:J(s.totalCacheRead),sub:`write: ${J(s.totalCacheWrite)}`}),(0,F.jsx)(K,{label:`you wrote`,value:J(s.totalUserChars),sub:`AI: ${J(s.totalAssistantChars)}`}),(0,F.jsx)(K,{label:`est. cost`,value:_&&_.totalCost>0?kh(_.totalCost):`—`,sub:_&&_.byModel.length>0?`${_.byModel.length} model${_.byModel.length===1?``:`s`}`:void 0})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-3`,children:[(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`editors`}),(0,F.jsx)(`div`,{className:`space-y-1.5 mt-1`,children:T.map(([e,t])=>{let n=y?y.has(e):!0,r=O[e]||0;return(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>w(e),className:`accent-[var(--c-accent)] w-3 h-3 flex-shrink-0 cursor-pointer`}),(0,F.jsx)(Gh,{source:e,size:11}),(0,F.jsx)(`span`,{className:`text-[11px] truncate flex-1 cursor-pointer select-none`,onClick:()=>w(e),style:{color:n?`var(--c-text2)`:`var(--c-text3)`,opacity:n?1:.4},children:q(e)}),(0,F.jsx)(`div`,{className:`w-16 h-3 rounded-sm overflow-hidden`,style:{background:`var(--c-code-bg)`},children:(0,F.jsx)(`div`,{className:`h-full rounded-sm transition-all`,style:{width:`${(r/j*100).toFixed(0)}%`,background:n?Oh(e):`var(--c-text3)`,opacity:n?1:.2}})}),(0,F.jsx)(`span`,{className:`text-[11px] w-6 text-right font-bold`,style:{color:n?`var(--c-white)`:`var(--c-text3)`,opacity:n?1:.4},children:r})]},e)})})]}),(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`models`}),A.length>0?(0,F.jsx)(`div`,{style:{height:160},children:(0,F.jsx)(Th,{data:{labels:A.map(e=>e[0]),datasets:[{data:A.map(e=>e[1]),backgroundColor:AE,borderWidth:0}]},options:{responsive:!0,maintainAspectRatio:!1,cutout:`60%`,plugins:{legend:{position:`right`,labels:{color:i,font:{size:8,family:kE},usePointStyle:!0,pointStyle:`circle`,padding:6}},tooltip:{bodyFont:{family:kE,size:10},titleFont:{family:kE,size:10}}}}})}):(0,F.jsx)(`div`,{className:`text-[11px] py-8 text-center`,style:{color:`var(--c-text3)`},children:`no model data`})]}),(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsxs)($,{children:[`top tools `,(0,F.jsxs)(`span`,{style:{color:`var(--c-text3)`},children:[`(`,J(s.totalToolCalls),`)`]})]}),s.topTools.length>0?(0,F.jsx)(`div`,{style:{height:160},children:(0,F.jsx)(wh,{data:{labels:s.topTools.map(e=>e.name),datasets:[{data:s.topTools.map(e=>e.count),backgroundColor:jE.slice(0,s.topTools.length),borderRadius:2}]},options:{responsive:!0,maintainAspectRatio:!1,indexAxis:`y`,scales:{x:{grid:{color:o},ticks:{color:a,font:{size:8,family:kE}}},y:{grid:{display:!1},ticks:{color:i,font:{size:8,family:kE}}}},plugins:{legend:{display:!1},tooltip:{bodyFont:{family:kE,size:10},titleFont:{family:kE,size:10}}}}})}):(0,F.jsx)(`div`,{className:`text-[11px] py-8 text-center`,style:{color:`var(--c-text3)`},children:`no tool data`})]})]}),console.log(`Rendering AiAuditCard, folder:`,n),(0,F.jsx)(OE,{folder:n}),(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3 mb-2`,children:[(0,F.jsxs)($,{children:[`sessions `,(0,F.jsxs)(`span`,{style:{color:`var(--c-text3)`},children:[`(`,C.length,E?``:` of ${l.length}`,`)`]})]}),(0,F.jsxs)(`div`,{className:`relative max-w-xs flex-1`,children:[(0,F.jsx)(ui,{size:11,className:`absolute left-2.5 top-1/2 -translate-y-1/2`,style:{color:`var(--c-text3)`}}),(0,F.jsx)(`input`,{type:`text`,placeholder:`filter sessions...`,value:p,onChange:e=>m(e.target.value),className:`w-full pl-7 pr-3 py-1 text-[12px] outline-none rounded-sm`,style:{background:`var(--c-bg3)`,color:`var(--c-text)`,border:`1px solid var(--c-border)`}})]})]}),(0,F.jsxs)(`div`,{className:`card overflow-hidden`,children:[(0,F.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`text-[10px] uppercase tracking-wider`,style:{borderBottom:`1px solid var(--c-border)`,color:`var(--c-text3)`},children:[(0,F.jsx)(`th`,{className:`text-left py-2 px-3 font-medium`,children:`editor`}),(0,F.jsx)(`th`,{className:`text-left py-2 px-3 font-medium`,children:`name`}),(0,F.jsx)(`th`,{className:`text-left py-2 px-3 font-medium`,children:`mode`}),(0,F.jsx)(`th`,{className:`text-left py-2 px-3 font-medium`,children:`model`}),(0,F.jsx)(`th`,{className:`text-left py-2 px-3 font-medium`,children:`context`}),(0,F.jsx)(`th`,{className:`text-right py-2 px-3 font-medium`,children:`est. cost`}),(0,F.jsx)(`th`,{className:`text-left py-2 px-3 font-medium`,children:`updated`})]})}),(0,F.jsx)(`tbody`,{children:C.map(e=>(0,F.jsxs)(`tr`,{className:`cursor-pointer transition`,style:{borderBottom:`1px solid var(--c-border)`},onMouseEnter:e=>e.currentTarget.style.background=`var(--c-bg3)`,onMouseLeave:e=>e.currentTarget.style.background=`transparent`,onClick:()=>g(e.id),children:[(0,F.jsx)(`td`,{className:`py-2 px-3`,children:(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,F.jsx)(Gh,{source:e.source,size:12}),(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`},children:q(e.source)})]})}),(0,F.jsxs)(`td`,{className:`py-2 px-3 font-medium truncate max-w-[280px]`,style:{color:`var(--c-white)`},children:[e.name||(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:`Untitled`}),e.encrypted&&(0,F.jsx)(`span`,{className:`ml-1.5 text-[10px] text-yellow-500/60`,children:`locked`})]}),(0,F.jsx)(`td`,{className:`py-2 px-3`,style:{color:`var(--c-text2)`},children:e.mode||``}),(0,F.jsx)(`td`,{className:`py-2 px-3 font-mono truncate max-w-[150px]`,style:{color:`var(--c-text2)`},title:e.topModel||``,children:e.topModel||``}),(0,F.jsx)(`td`,{className:`py-2 px-3`,children:e.bubbleCount>=500?(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 font-bold`,style:{color:`#ef4444`},children:[(0,F.jsx)(wi,{size:9}),e.bubbleCount,` msgs`]}):e.bubbleCount>=100?(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 font-bold`,style:{color:`#f59e0b`},children:[(0,F.jsx)(wi,{size:9}),e.bubbleCount,` msgs`]}):(0,F.jsxs)(`span`,{style:{color:`var(--c-text3)`},children:[e.bubbleCount||0,` msgs`]})}),(0,F.jsx)(`td`,{className:`py-2 px-3 font-mono text-right`,style:{color:e.cost>0?`var(--c-text2)`:`var(--c-text3)`},children:e.cost>0?kh(e.cost):``}),(0,F.jsx)(`td`,{className:`py-2 px-3 whitespace-nowrap`,style:{color:`var(--c-text3)`},children:Ah(e.lastUpdatedAt||e.createdAt)})]},e.id))})]}),C.length===0&&(0,F.jsx)(`div`,{className:`text-center py-8 text-sm`,style:{color:`var(--c-text3)`},children:`no sessions found`})]})]}),(0,F.jsx)(XT,{chatId:h,onClose:()=>g(null)})]})}Lf.register(qf,km,Nm,cp,op,vp,wm,im,Yp);var NE=`JetBrains Mono, monospace`,PE=[`#6366f1`,`#a78bfa`,`#818cf8`,`#c084fc`,`#e879f9`,`#f472b6`,`#fb7185`,`#f87171`,`#fbbf24`,`#34d399`,`#2dd4bf`,`#38bdf8`,`#60a5fa`,`#a3e635`];function FE({overview:e}){let{dark:t}=tr(),n=dt(),r=t?`#555`:`#999`,i=t?`#777`:`#555`,a=t?`rgba(255,255,255,0.03)`:`rgba(0,0,0,0.06)`,[o,s]=(0,S.useState)(null),[c,l]=(0,S.useState)(!0),[u,d]=(0,S.useState)(``),[f,p]=(0,S.useState)(null),[m,h]=(0,S.useState)(null),g=e?.editors||[];if((0,S.useEffect)(()=>{l(!0),qi({editor:u,...jh(f)}).then(e=>{s(e),l(!1)}).catch(()=>l(!1))},[u,f]),!o)return(0,F.jsx)(wa,{label:`Loading cost data...`});let{totalCost:_,byModel:v,byEditor:y,byProject:b,monthly:x,topSessions:C,summary:w,unknownModels:T}=o,E=v.length>0?{labels:v.slice(0,10).map(e=>e.model),datasets:[{data:v.slice(0,10).map(e=>Math.round(e.cost*100)/100),backgroundColor:PE,borderWidth:0}]}:null,D=y.length>0?{labels:y.map(e=>q(e.editor)),datasets:[{data:y.map(e=>Math.round(e.cost*100)/100),backgroundColor:y.map(e=>Oh(e.editor)),borderWidth:0}]}:null,O=x.length>1?{labels:x.map(e=>e.month),datasets:[{label:`Cost ($)`,data:x.map(e=>e.cost),borderColor:`#6366f1`,backgroundColor:`rgba(99,102,241,0.1)`,borderWidth:2,tension:.3,pointRadius:3,pointHoverRadius:5,fill:!0}]}:null,k=b.length>0?{labels:b.slice(0,10).map(e=>e.name),datasets:[{data:b.slice(0,10).map(e=>Math.round(e.cost*100)/100),backgroundColor:`#818cf8`,borderRadius:3}]}:null,A={responsive:!0,maintainAspectRatio:!1,cutout:`55%`,plugins:{legend:{position:`right`,labels:{color:i,font:{size:9,family:NE},usePointStyle:!0,pointStyle:`circle`,padding:6}},tooltip:{bodyFont:{family:NE,size:10},titleFont:{family:NE,size:10},callbacks:{label:e=>` ${e.label}: $${e.raw.toFixed(2)}`}}}};return(0,F.jsxs)(`div`,{className:`fade-in space-y-3`,children:[(0,F.jsxs)($T,{icon:Ir,title:`Cost Analysis`,children:[(0,F.jsxs)(`select`,{value:u,onChange:e=>d(e.target.value),className:`px-2 py-1 text-[12px] outline-none`,style:{background:`var(--c-bg3)`,color:`var(--c-text)`,border:`1px solid var(--c-border)`},children:[(0,F.jsx)(`option`,{value:``,children:`All Editors`}),g.map(e=>(0,F.jsxs)(`option`,{value:e.id,children:[q(e.id),` (`,e.count,`)`]},e.id))]}),(0,F.jsx)(`div`,{className:`ml-auto`,children:(0,F.jsx)(Hh,{value:f,onChange:p})})]}),(0,F.jsxs)(`div`,{className:`flex items-start gap-2 px-3 py-2 text-[11px] rounded`,style:{background:`rgba(234,179,8,0.06)`,border:`1px solid rgba(234,179,8,0.15)`,color:`#ca8a04`},children:[(0,F.jsx)(wi,{size:12,className:`mt-0.5 shrink-0`}),(0,F.jsxs)(`span`,{children:[`These are `,(0,F.jsx)(`strong`,{children:`estimates`}),` based on public API list prices. Actual costs may be lower if you use discounted plans, commitments, prompt caching, batching, or provider credits. Token counts for some editors are approximated from character counts (~4 chars/token).`]})]}),(0,F.jsxs)(`div`,{className:`grid gap-2`,style:{gridTemplateColumns:`repeat(auto-fit, minmax(90px, 1fr))`},children:[(0,F.jsx)(K,{label:`total est. cost`,value:kh(_),sub:`all models`}),(0,F.jsx)(K,{label:`avg / session`,value:kh(w.avgPerSession),sub:`${J(w.totalSessions)} sessions`}),(0,F.jsx)(K,{label:`avg / day`,value:kh(w.avgPerDay),sub:`${w.totalDays} days`}),(0,F.jsx)(K,{label:`models`,value:v.length,sub:T.length>0?`${T.length} unknown`:`all priced`}),(0,F.jsx)(K,{label:`top model`,value:v[0]?.model||`—`,sub:v[0]?kh(v[0].cost):``}),(0,F.jsx)(K,{label:`top editor`,value:y[0]?q(y[0].editor):`—`,sub:y[0]?kh(y[0].cost):``})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-3`,children:[(0,F.jsxs)(`div`,{className:`card p-3 lg:col-span-2`,children:[(0,F.jsx)($,{children:`cost by model`}),E?(0,F.jsx)(`div`,{style:{height:220},children:(0,F.jsx)(wh,{data:{labels:v.slice(0,12).map(e=>e.model),datasets:[{data:v.slice(0,12).map(e=>Math.round(e.cost*100)/100),backgroundColor:PE,borderRadius:3}]},options:{responsive:!0,maintainAspectRatio:!1,indexAxis:`y`,scales:{x:{grid:{color:a},ticks:{color:r,font:{size:9,family:NE},callback:e=>`$`+e}},y:{grid:{display:!1},ticks:{color:i,font:{size:9,family:NE}}}},plugins:{legend:{display:!1},tooltip:{bodyFont:{family:NE,size:10},titleFont:{family:NE,size:10},callbacks:{label:e=>` $${e.raw.toFixed(2)}`}}}}})}):(0,F.jsx)(`div`,{className:`text-[11px] py-8 text-center`,style:{color:`var(--c-text3)`},children:`no cost data`})]}),(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`cost by editor`}),D?(0,F.jsx)(`div`,{style:{height:220},children:(0,F.jsx)(Th,{data:D,options:A})}):(0,F.jsx)(`div`,{className:`text-[11px] py-8 text-center`,style:{color:`var(--c-text3)`},children:`no cost data`})]})]}),O&&(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`monthly cost trend`}),(0,F.jsx)(`div`,{style:{height:180},children:(0,F.jsx)(Ch,{data:O,options:{responsive:!0,maintainAspectRatio:!1,interaction:{mode:`index`,intersect:!1},scales:{x:{grid:{display:!1},ticks:{color:r,font:{size:9,family:NE},maxRotation:0,maxTicksLimit:12}},y:{beginAtZero:!0,grid:{color:a},ticks:{color:r,font:{size:9,family:NE},callback:e=>`$`+e}}},plugins:{legend:{display:!1},tooltip:{bodyFont:{family:NE,size:10},titleFont:{family:NE,size:10},callbacks:{label:e=>` $${e.raw.toFixed(2)} (${x[e.dataIndex]?.sessions||0} sessions)`}}}}})})]}),k&&(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`cost by project (top 10)`}),(0,F.jsx)(`div`,{style:{height:220},children:(0,F.jsx)(wh,{data:k,options:{responsive:!0,maintainAspectRatio:!1,indexAxis:`y`,scales:{x:{grid:{color:a},ticks:{color:r,font:{size:9,family:NE},callback:e=>`$`+e}},y:{grid:{display:!1},ticks:{color:i,font:{size:9,family:NE}}}},plugins:{legend:{display:!1},tooltip:{bodyFont:{family:NE,size:10},titleFont:{family:NE,size:10},callbacks:{label:e=>` $${e.raw.toFixed(2)}`}}}}})})]}),(0,F.jsxs)(`div`,{className:`card overflow-hidden`,children:[(0,F.jsx)(`div`,{className:`px-3 py-2`,style:{borderBottom:`1px solid var(--c-border)`},children:(0,F.jsx)($,{children:`model breakdown`})}),(0,F.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`text-[10px] uppercase tracking-wider`,style:{borderBottom:`1px solid var(--c-border)`,color:`var(--c-text3)`},children:[(0,F.jsx)(`th`,{className:`text-left py-2 px-3 font-medium`,children:`model`}),(0,F.jsx)(`th`,{className:`text-right py-2 px-3 font-medium`,children:`input tokens`}),(0,F.jsx)(`th`,{className:`text-right py-2 px-3 font-medium`,children:`output tokens`}),(0,F.jsx)(`th`,{className:`text-right py-2 px-3 font-medium`,children:`cache read`}),(0,F.jsx)(`th`,{className:`text-right py-2 px-3 font-medium`,children:`cache write`}),(0,F.jsx)(`th`,{className:`text-right py-2 px-3 font-medium`,children:`est. cost`}),(0,F.jsx)(`th`,{className:`text-right py-2 px-3 font-medium`,children:`% of total`})]})}),(0,F.jsx)(`tbody`,{children:v.map((e,t)=>(0,F.jsxs)(`tr`,{style:{borderBottom:`1px solid var(--c-border)`},children:[(0,F.jsxs)(`td`,{className:`py-2 px-3 font-mono font-medium`,style:{color:`var(--c-white)`},children:[(0,F.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full mr-1.5`,style:{background:PE[t%PE.length]}}),e.model]}),(0,F.jsx)(`td`,{className:`py-2 px-3 text-right font-mono`,style:{color:`var(--c-text2)`},children:J(e.inputTokens)}),(0,F.jsx)(`td`,{className:`py-2 px-3 text-right font-mono`,style:{color:`var(--c-text2)`},children:J(e.outputTokens)}),(0,F.jsx)(`td`,{className:`py-2 px-3 text-right font-mono`,style:{color:`var(--c-text3)`},children:e.cacheRead>0?J(e.cacheRead):`—`}),(0,F.jsx)(`td`,{className:`py-2 px-3 text-right font-mono`,style:{color:`var(--c-text3)`},children:e.cacheWrite>0?J(e.cacheWrite):`—`}),(0,F.jsx)(`td`,{className:`py-2 px-3 text-right font-mono font-medium`,style:{color:`var(--c-white)`},children:kh(e.cost)}),(0,F.jsx)(`td`,{className:`py-2 px-3 text-right font-mono`,style:{color:`var(--c-text3)`},children:_>0?(e.cost/_*100).toFixed(1)+`%`:`—`})]},e.model))})]}),v.length===0&&(0,F.jsx)(`div`,{className:`text-center py-8 text-sm`,style:{color:`var(--c-text3)`},children:`no model cost data`})]}),C.length>0&&(0,F.jsxs)(`div`,{className:`card overflow-hidden`,children:[(0,F.jsx)(`div`,{className:`px-3 py-2`,style:{borderBottom:`1px solid var(--c-border)`},children:(0,F.jsx)($,{children:`most expensive sessions`})}),(0,F.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`text-[10px] uppercase tracking-wider`,style:{borderBottom:`1px solid var(--c-border)`,color:`var(--c-text3)`},children:[(0,F.jsx)(`th`,{className:`text-left py-2 px-3 font-medium`,children:`editor`}),(0,F.jsx)(`th`,{className:`text-left py-2 px-3 font-medium`,children:`name`}),(0,F.jsx)(`th`,{className:`text-left py-2 px-3 font-medium`,children:`project`}),(0,F.jsx)(`th`,{className:`text-left py-2 px-3 font-medium`,children:`model`}),(0,F.jsx)(`th`,{className:`text-right py-2 px-3 font-medium`,children:`msgs`}),(0,F.jsx)(`th`,{className:`text-right py-2 px-3 font-medium`,children:`est. cost`}),(0,F.jsx)(`th`,{className:`text-left py-2 px-3 font-medium`,children:`date`})]})}),(0,F.jsx)(`tbody`,{children:C.slice(0,30).map(e=>(0,F.jsxs)(`tr`,{className:`cursor-pointer transition`,style:{borderBottom:`1px solid var(--c-border)`},onMouseEnter:e=>e.currentTarget.style.background=`var(--c-bg3)`,onMouseLeave:e=>e.currentTarget.style.background=`transparent`,onClick:()=>h(e.id),children:[(0,F.jsx)(`td`,{className:`py-2 px-3`,children:(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,F.jsx)(Gh,{source:e.source,size:12}),(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`},children:q(e.source)})]})}),(0,F.jsx)(`td`,{className:`py-2 px-3 font-medium truncate max-w-[200px]`,style:{color:`var(--c-white)`},children:e.name||(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:`Untitled`})}),(0,F.jsx)(`td`,{className:`py-2 px-3 truncate max-w-[140px]`,style:{color:`var(--c-text2)`},title:e.folder,children:e.folder?(0,F.jsx)(`span`,{className:`cursor-pointer hover:underline`,style:{color:`var(--c-accent)`},onClick:t=>{t.stopPropagation(),n(`/projects/detail?folder=${encodeURIComponent(e.folder)}`)},children:e.folder.split(`/`).pop()}):``}),(0,F.jsx)(`td`,{className:`py-2 px-3 font-mono truncate max-w-[140px]`,style:{color:`var(--c-text2)`},title:e.model,children:e.model}),(0,F.jsx)(`td`,{className:`py-2 px-3 text-right`,style:{color:`var(--c-text3)`},children:e.messages}),(0,F.jsx)(`td`,{className:`py-2 px-3 text-right font-mono font-medium`,style:{color:`var(--c-white)`},children:kh(e.cost)}),(0,F.jsx)(`td`,{className:`py-2 px-3 whitespace-nowrap`,style:{color:`var(--c-text3)`},children:Ah(e.lastUpdatedAt)})]},e.id))})]})]}),T.length>0&&(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsxs)($,{children:[(0,F.jsx)(wi,{size:11,className:`inline mr-1`,style:{color:`#f59e0b`}}),`unpriced models (`,T.length,`)`]}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-2`,children:T.map(e=>(0,F.jsx)(`span`,{className:`text-[11px] px-2 py-0.5 font-mono`,style:{background:`rgba(245,158,11,0.08)`,color:`#f59e0b`,border:`1px solid rgba(245,158,11,0.2)`},children:e},e))})]}),(0,F.jsx)(XT,{chatId:m,onClose:()=>h(null)})]})}Lf.register(qf,wm,im,km,Nm,vp,cp,op,Yp);var IE=[{label:`Sessions per editor`,sql:`SELECT source, count() AS count FROM sessions_v GROUP BY source ORDER BY count DESC`},{label:`Top 10 projects`,sql:`SELECT project, count() AS sessions, sum(total_msgs) AS messages FROM sessions_v WHERE project != '' GROUP BY project ORDER BY sessions DESC LIMIT 10`},{label:`Messages per day`,sql:`SELECT toDate(ts) AS day, count() AS count FROM messages GROUP BY day ORDER BY day`},{label:`Top models`,sql:`SELECT model, count() AS count FROM messages WHERE model NOT IN ('', '<synthetic>') GROUP BY model ORDER BY count DESC LIMIT 10`},{label:`Top tools`,sql:`SELECT tool_name, count() AS count FROM tool_calls GROUP BY tool_name ORDER BY count DESC LIMIT 15`},{label:`Token usage by editor`,sql:`SELECT source, sum(input_tokens) AS input_tokens, sum(output_tokens) AS output_tokens FROM sessions_v GROUP BY source ORDER BY input_tokens DESC`},{label:`Sessions by mode`,sql:`SELECT mode, count() AS count FROM sessions_v WHERE mode != '' GROUP BY mode ORDER BY count DESC`},{label:`Hourly distribution`,sql:`SELECT toHour(ts) AS hour, count() AS count FROM messages GROUP BY hour ORDER BY hour`},{label:`Full-text search`,sql:`SELECT session_id, user_id, any(source) AS source, count() AS hits FROM messages WHERE text_ngram LIKE '%clickhouse%' GROUP BY session_id, user_id ORDER BY hits DESC LIMIT 10`}],LE=[{label:`Sessions per editor`,sql:`SELECT source, count() AS count FROM chats GROUP BY source ORDER BY count DESC`},{label:`Top 10 projects`,sql:`SELECT folder, count() AS sessions, sum(bubble_count) AS messages FROM chats WHERE folder IS NOT NULL GROUP BY folder ORDER BY sessions DESC LIMIT 10`},{label:`Messages per day`,sql:`SELECT toDate(toDateTime(intDiv(created_at, 1000))) AS day, count() AS count FROM chats WHERE created_at IS NOT NULL GROUP BY day ORDER BY day`},{label:`Top models`,sql:`SELECT model, count() AS count FROM messages WHERE model IS NOT NULL GROUP BY model ORDER BY count DESC LIMIT 10`},{label:`Top tools`,sql:`SELECT tool_name, count() AS count FROM tool_calls GROUP BY tool_name ORDER BY count DESC LIMIT 15`},{label:`Token usage by editor`,sql:`SELECT c.source AS source, sum(cs.total_input_tokens) AS input_tokens, sum(cs.total_output_tokens) AS output_tokens FROM chat_stats AS cs JOIN chats AS c ON c.id = cs.chat_id GROUP BY c.source ORDER BY input_tokens DESC`},{label:`Sessions by mode`,sql:`SELECT mode, count() AS count FROM chats WHERE mode IS NOT NULL GROUP BY mode ORDER BY count DESC`},{label:`Hourly distribution`,sql:`SELECT toHour(toDateTime(intDiv(created_at, 1000))) AS hour, count() AS count FROM chats WHERE created_at IS NOT NULL GROUP BY hour ORDER BY hour`}];function RE(){let{dark:e}=tr(),[t,n]=(0,S.useState)(`loading`),[r,i]=(0,S.useState)(``),[a,o]=(0,S.useState)(null),[s,c]=(0,S.useState)(null),[l,u]=(0,S.useState)(!1),[d,f]=(0,S.useState)(null),[p,m]=(0,S.useState)(!1),[h,g]=(0,S.useState)(`bar`),[_,v]=(0,S.useState)(null),y=(0,S.useRef)(null);(0,S.useEffect)(()=>{$i().then(e=>{f(e);let t=e?.tables,r=Array.isArray(t)?t.includes(`sessions_v`)?IE:t.includes(`chats`)?LE:null:null;n(r),r&&i(e=>e===``||e===IE[0].sql||e===LE[0].sql?r[0].sql:e)}).catch(()=>n(null))},[]);let b=async()=>{if(!r.trim()||l)return;u(!0),c(null),o(null);let e=performance.now();try{let t=await Qi(r.trim());v((performance.now()-e).toFixed(0)),t.error?c(t.error):o(t)}catch(e){c(e.message),v(null)}u(!1)},x=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),b())},C=()=>{if(!a)return;let e=a.columns.join(` `),t=a.rows.map(e=>a.columns.map(t=>e[t]??``).join(` `));navigator.clipboard.writeText([e,...t].join(`
|
|
67
67
|
`))},w=()=>{if(!a)return;let e=e=>{let t=String(e??``);return t.includes(`,`)||t.includes(`"`)||t.includes(`
|
|
68
68
|
`)?`"${t.replace(/"/g,`""`)}"`:t},t=a.columns.map(e).join(`,`),n=a.rows.map(t=>a.columns.map(n=>e(t[n])).join(`,`)),r=new Blob([t+`
|
|
69
69
|
`+n.join(`
|
|
70
|
-
`)],{type:`text/csv`}),i=URL.createObjectURL(r),o=document.createElement(`a`);o.href=i,o.download=`query-results.csv`,o.click(),URL.revokeObjectURL(i)},T=(0,S.useMemo)(()=>{if(!a||a.columns.length<2||a.rows.length===0)return null;let e=a.columns,t=e.find(e=>a.rows.every(t=>typeof t[e]==`string`||t[e]===null))||e[0],n=e.filter(e=>e!==t&&a.rows.some(t=>typeof t[e]==`number`));if(n.length===0)return null;let r=a.rows.map(e=>String(e[t]??``)),i=[`#6366f1`,`#f59e0b`,`#06b6d4`,`#10b981`,`#f97316`,`#ec4899`,`#8b5cf6`,`#3b82f6`,`#ef4444`,`#14b8a6`];return{labels:r,datasets:n.map((e,t)=>({label:e,data:a.rows.map(t=>t[e]??0),backgroundColor:h===`doughnut`?i.slice(0,r.length):i[t%i.length]+`99`,borderColor:i[t%i.length],borderWidth:h===`line`?2:1,borderRadius:h===`bar`?4:0,tension:.3,fill:h===`line`,pointRadius:h===`line`?3:0}))}},[a,h]),E={responsive:!0,maintainAspectRatio:!1,plugins:{legend:{display:T?.datasets?.length>1||h===`doughnut`,labels:{color:e?`#ccc`:`#555`,font:{size:11}}},tooltip:{backgroundColor:e?`#1e1e2e`:`#fff`,titleColor:e?`#fff`:`#111`,bodyColor:e?`#ccc`:`#555`,borderColor:e?`#333`:`#ddd`,borderWidth:1}},scales:h===`doughnut`?void 0:{x:{ticks:{color:e?`#888`:`#666`,font:{size:10},maxRotation:45},grid:{color:e?`#ffffff08`:`#00000008`}},y:{ticks:{color:e?`#888`:`#666`,font:{size:10}},grid:{color:e?`#ffffff08`:`#00000008`}}}},D={color:`var(--c-text)`},O={color:`var(--c-text2)`},k={background:`var(--c-card)`,border:`1px solid var(--c-border)`};return(0,F.jsxs)(`div`,{className:`fade-in space-y-3`,children:[(0,F.jsxs)($T,{icon:Fr,title:`SQL Viewer`,children:[(0,F.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5`,style:{color:`var(--c-text3)`,background:`var(--c-bg3)`},children:`cache.db`}),(0,F.jsx)(`div`,{className:`ml-auto`,children:(0,F.jsxs)(`button`,{onClick:()=>m(!p),className:`flex items-center gap-1 text-[11px] px-2 py-1 transition hover:bg-[var(--c-card)]`,style:{color:`var(--c-text2)`,border:`1px solid var(--c-border)`},children:[(0,F.jsx)(bi,{size:11}),`Schema`,(0,F.jsx)(Cr,{size:10,className:`transition ${p?`rotate-180`:``}`})]})})]}),p&&d&&(0,F.jsx)(`div`,{className:`rounded-lg p-3 space-y-2 text-[12px]`,style:k,children:(0,F.jsx)(`div`,{className:`flex flex-wrap gap-4`,children:d.tables.map(e=>(0,F.jsxs)(`div`,{className:`min-w-[180px]`,children:[(0,F.jsx)(`div`,{className:`font-semibold mb-1`,style:D,children:e}),(0,F.jsx)(`div`,{className:`space-y-0.5`,children:d.schema[e]?.map(e=>(0,F.jsxs)(`div`,{className:`flex gap-2`,style:O,children:[(0,F.jsx)(`span`,{style:D,children:e.name}),(0,F.jsx)(`span`,{className:`text-[11px] opacity-60`,children:e.type}),e.pk?(0,F.jsx)(`span`,{className:`text-[10px] px-1 rounded`,style:{background:`#6366f133`,color:`#6366f1`},children:`PK`}):null]},e.name))})]},e))})}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.map((e,t)=>(0,F.jsx)(`button`,{onClick:()=>i(e.sql),className:`text-[11px] px-2 py-0.5 rounded transition hover:bg-[var(--c-card)]`,style:{...O,border:`1px solid var(--c-border)`},children:e.label},t))}),(0,F.jsxs)(`div`,{className:`rounded-lg overflow-hidden`,style:k,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5`,style:{borderBottom:`1px solid var(--c-border)`},children:[(0,F.jsx)(`span`,{className:`text-[11px] font-mono`,style:O,children:`SQL`}),(0,F.jsx)(`div`,{className:`flex items-center gap-1`,children:(0,F.jsx)(`span`,{className:`text-[11px]`,style:O,children:`⌘+Enter to run`})})]}),(0,F.jsx)(`textarea`,{ref:y,value:r,onChange:e=>i(e.target.value),onKeyDown:x,spellCheck:!1,className:`w-full p-3 text-[12px] font-mono resize-y outline-none`,style:{background:`transparent`,color:`var(--c-text)`,minHeight:80,maxHeight:300},rows:4}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5`,style:{borderTop:`1px solid var(--c-border)`},children:[(0,F.jsxs)(`button`,{onClick:b,disabled:l||!r.trim(),className:`flex items-center gap-1.5 px-3 py-1 text-[12px] font-medium rounded transition`,style:{background:`#6366f1`,color:`#fff`,opacity:l?.5:1},children:[(0,F.jsx)(ai,{size:11}),l?`Running...`:`Run Query`]}),_&&a&&(0,F.jsxs)(`span`,{className:`text-[11px]`,style:O,children:[a.count,` row`,a.count===1?``:`s`,` in `,_,`ms`]}),a&&(0,F.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,F.jsx)(`button`,{onClick:C,className:`p-1 rounded hover:bg-[var(--c-bg2)] transition`,style:O,title:`Copy to clipboard`,children:(0,F.jsx)(Mr,{size:12})}),(0,F.jsx)(`button`,{onClick:w,className:`p-1 rounded hover:bg-[var(--c-bg2)] transition`,style:O,title:`Download CSV`,children:(0,F.jsx)(Lr,{size:12})})]})]})]}),s&&(0,F.jsx)(`div`,{className:`rounded-lg px-3 py-2 text-[12px]`,style:{background:`#ef444420`,border:`1px solid #ef444440`,color:`#ef4444`},children:s}),a&&a.rows.length>0&&(0,F.jsx)(`div`,{className:`rounded-lg overflow-hidden`,style:k,children:(0,F.jsx)(`div`,{className:`overflow-x-auto`,style:{maxHeight:400},children:(0,F.jsxs)(`table`,{className:`w-full text-[12px]`,style:{borderCollapse:`collapse`},children:[(0,F.jsx)(`thead`,{children:(0,F.jsx)(`tr`,{style:{borderBottom:`1px solid var(--c-border)`},children:a.columns.map(e=>(0,F.jsx)(`th`,{className:`text-left px-3 py-1.5 font-semibold sticky top-0`,style:{...D,background:`var(--c-card)`},children:e},e))})}),(0,F.jsx)(`tbody`,{children:a.rows.map((e,t)=>(0,F.jsx)(`tr`,{className:`hover:bg-[var(--c-bg2)] transition`,style:{borderBottom:`1px solid var(--c-border)`},children:a.columns.map(t=>(0,F.jsx)(`td`,{className:`px-3 py-1 font-mono`,style:O,children:zE(e[t])},t))},t))})]})})}),a&&a.rows.length===0&&(0,F.jsx)(`div`,{className:`rounded-lg px-3 py-6 text-center text-[12px]`,style:{...k,...O},children:`Query returned 0 rows`}),T&&(0,F.jsxs)(`div`,{className:`rounded-lg p-4`,style:k,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,F.jsx)(`span`,{className:`text-[12px] font-semibold`,style:D,children:`Visualization`}),(0,F.jsx)(`div`,{className:`flex gap-0.5 ml-2`,style:{border:`1px solid var(--c-border)`,borderRadius:6},children:[{type:`bar`,icon:yr},{type:`line`,icon:br},{type:`doughnut`,icon:xr}].map(({type:e,icon:t})=>(0,F.jsx)(`button`,{onClick:()=>g(e),className:`p-1.5 transition`,style:{background:h===e?`var(--c-bg2)`:`transparent`,color:h===e?`var(--c-white)`:`var(--c-text3)`,borderRadius:4},children:(0,F.jsx)(t,{size:12})},e))})]}),(0,F.jsxs)(`div`,{style:{height:h===`doughnut`?280:260},children:[h===`bar`&&(0,F.jsx)(wh,{data:T,options:E}),h===`line`&&(0,F.jsx)(Ch,{data:T,options:E}),h===`doughnut`&&(0,F.jsx)(Th,{data:T,options:E})]})]})]})}function zE(e){if(e==null)return(0,F.jsx)(`span`,{className:`opacity-30`,children:`NULL`});if(typeof e==`number`)return e.toLocaleString();let t=String(e);return t.length>120?t.substring(0,120)+`…`:t}var BE=`JetBrains Mono, monospace`;function VE(e){return e<1024?e+` B`:e<1024*1024?(e/1024).toFixed(1)+` KB`:(e/(1024*1024)).toFixed(1)+` MB`}function HE(e){return e?new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`,hour:`2-digit`,minute:`2-digit`}):``}function UE(e){return e?Math.round(e.length/4):0}function WE(e){return e<1e3?String(e):e<1e6?(e/1e3).toFixed(1)+`k`:(e/1e6).toFixed(2)+`M`}function GE(e){let t=e/1e6*3;return t<.001?`<$0.001`:t<.01?`$`+t.toFixed(4):`$`+t.toFixed(3)}function KE(e){if(!e)return`text`;let t=e.toLowerCase();return t.endsWith(`.json`)?`json`:t.endsWith(`.md`)||t.endsWith(`.mdc`)?`markdown`:t.endsWith(`.yaml`)||t.endsWith(`.yml`)?`yaml`:`text`}function qE({content:e}){let t;try{t=JSON.parse(e)}catch{return(0,F.jsx)(`pre`,{className:`text-[12px] whitespace-pre-wrap break-words leading-relaxed`,style:{color:`#ef4444`,fontFamily:BE},children:`Invalid JSON`})}let n=JSON.stringify(t,null,2);return(0,F.jsx)(`pre`,{className:`text-[12px] whitespace-pre-wrap break-words leading-relaxed`,style:{fontFamily:BE},children:n.split(`
|
|
70
|
+
`)],{type:`text/csv`}),i=URL.createObjectURL(r),o=document.createElement(`a`);o.href=i,o.download=`query-results.csv`,o.click(),URL.revokeObjectURL(i)},T=(0,S.useMemo)(()=>{if(!a||a.columns.length<2||a.rows.length===0)return null;let e=a.columns,t=e.find(e=>a.rows.every(t=>typeof t[e]==`string`||t[e]===null))||e[0],n=e.filter(e=>e!==t&&a.rows.some(t=>typeof t[e]==`number`));if(n.length===0)return null;let r=a.rows.map(e=>String(e[t]??``)),i=[`#6366f1`,`#f59e0b`,`#06b6d4`,`#10b981`,`#f97316`,`#ec4899`,`#8b5cf6`,`#3b82f6`,`#ef4444`,`#14b8a6`];return{labels:r,datasets:n.map((e,t)=>({label:e,data:a.rows.map(t=>t[e]??0),backgroundColor:h===`doughnut`?i.slice(0,r.length):i[t%i.length]+`99`,borderColor:i[t%i.length],borderWidth:h===`line`?2:1,borderRadius:h===`bar`?4:0,tension:.3,fill:h===`line`,pointRadius:h===`line`?3:0}))}},[a,h]),E={responsive:!0,maintainAspectRatio:!1,plugins:{legend:{display:T?.datasets?.length>1||h===`doughnut`,labels:{color:e?`#ccc`:`#555`,font:{size:11}}},tooltip:{backgroundColor:e?`#1e1e2e`:`#fff`,titleColor:e?`#fff`:`#111`,bodyColor:e?`#ccc`:`#555`,borderColor:e?`#333`:`#ddd`,borderWidth:1}},scales:h===`doughnut`?void 0:{x:{ticks:{color:e?`#888`:`#666`,font:{size:10},maxRotation:45},grid:{color:e?`#ffffff08`:`#00000008`}},y:{ticks:{color:e?`#888`:`#666`,font:{size:10}},grid:{color:e?`#ffffff08`:`#00000008`}}}},D={color:`var(--c-text)`},O={color:`var(--c-text2)`},k={background:`var(--c-card)`,border:`1px solid var(--c-border)`};return(0,F.jsxs)(`div`,{className:`fade-in space-y-3`,children:[(0,F.jsxs)($T,{icon:Fr,title:`SQL Viewer`,children:[(0,F.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5`,style:{color:`var(--c-text3)`,background:`var(--c-bg3)`},children:`cache.db`}),(0,F.jsx)(`div`,{className:`ml-auto`,children:(0,F.jsxs)(`button`,{onClick:()=>m(!p),className:`flex items-center gap-1 text-[11px] px-2 py-1 transition hover:bg-[var(--c-card)]`,style:{color:`var(--c-text2)`,border:`1px solid var(--c-border)`},children:[(0,F.jsx)(bi,{size:11}),`Schema`,(0,F.jsx)(Cr,{size:10,className:`transition ${p?`rotate-180`:``}`})]})})]}),p&&d&&(0,F.jsx)(`div`,{className:`rounded-lg p-3 space-y-2 text-[12px]`,style:k,children:(0,F.jsx)(`div`,{className:`flex flex-wrap gap-4`,children:d.tables.map(e=>(0,F.jsxs)(`div`,{className:`min-w-[180px]`,children:[(0,F.jsx)(`div`,{className:`font-semibold mb-1`,style:D,children:e}),(0,F.jsx)(`div`,{className:`space-y-0.5`,children:d.schema[e]?.map(e=>(0,F.jsxs)(`div`,{className:`flex gap-2`,style:O,children:[(0,F.jsx)(`span`,{style:D,children:e.name}),(0,F.jsx)(`span`,{className:`text-[11px] opacity-60`,children:e.type}),e.pk?(0,F.jsx)(`span`,{className:`text-[10px] px-1 rounded`,style:{background:`#6366f133`,color:`#6366f1`},children:`PK`}):null]},e.name))})]},e))})}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t===`loading`?(0,F.jsx)(`span`,{className:`text-[11px]`,style:O,children:`loading examples…`}):t===null?(0,F.jsx)(`span`,{className:`text-[11px]`,style:O,children:`examples unavailable — could not determine the schema from /api/schema`}):t.map((e,t)=>(0,F.jsx)(`button`,{onClick:()=>i(e.sql),className:`text-[11px] px-2 py-0.5 rounded transition hover:bg-[var(--c-card)]`,style:{...O,border:`1px solid var(--c-border)`},children:e.label},t))}),(0,F.jsxs)(`div`,{className:`rounded-lg overflow-hidden`,style:k,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5`,style:{borderBottom:`1px solid var(--c-border)`},children:[(0,F.jsx)(`span`,{className:`text-[11px] font-mono`,style:O,children:`SQL`}),(0,F.jsx)(`div`,{className:`flex items-center gap-1`,children:(0,F.jsx)(`span`,{className:`text-[11px]`,style:O,children:`⌘+Enter to run`})})]}),(0,F.jsx)(`textarea`,{ref:y,value:r,onChange:e=>i(e.target.value),onKeyDown:x,spellCheck:!1,className:`w-full p-3 text-[12px] font-mono resize-y outline-none`,style:{background:`transparent`,color:`var(--c-text)`,minHeight:80,maxHeight:300},rows:4}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5`,style:{borderTop:`1px solid var(--c-border)`},children:[(0,F.jsxs)(`button`,{onClick:b,disabled:l||!r.trim(),className:`flex items-center gap-1.5 px-3 py-1 text-[12px] font-medium rounded transition`,style:{background:`#6366f1`,color:`#fff`,opacity:l?.5:1},children:[(0,F.jsx)(ai,{size:11}),l?`Running...`:`Run Query`]}),_&&a&&(0,F.jsxs)(`span`,{className:`text-[11px]`,style:O,children:[a.count,` row`,a.count===1?``:`s`,` in `,_,`ms`]}),a&&(0,F.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,F.jsx)(`button`,{onClick:C,className:`p-1 rounded hover:bg-[var(--c-bg2)] transition`,style:O,title:`Copy to clipboard`,children:(0,F.jsx)(Mr,{size:12})}),(0,F.jsx)(`button`,{onClick:w,className:`p-1 rounded hover:bg-[var(--c-bg2)] transition`,style:O,title:`Download CSV`,children:(0,F.jsx)(Lr,{size:12})})]})]})]}),s&&(0,F.jsx)(`div`,{className:`rounded-lg px-3 py-2 text-[12px]`,style:{background:`#ef444420`,border:`1px solid #ef444440`,color:`#ef4444`},children:s}),a&&a.rows.length>0&&(0,F.jsx)(`div`,{className:`rounded-lg overflow-hidden`,style:k,children:(0,F.jsx)(`div`,{className:`overflow-x-auto`,style:{maxHeight:400},children:(0,F.jsxs)(`table`,{className:`w-full text-[12px]`,style:{borderCollapse:`collapse`},children:[(0,F.jsx)(`thead`,{children:(0,F.jsx)(`tr`,{style:{borderBottom:`1px solid var(--c-border)`},children:a.columns.map(e=>(0,F.jsx)(`th`,{className:`text-left px-3 py-1.5 font-semibold sticky top-0`,style:{...D,background:`var(--c-card)`},children:e},e))})}),(0,F.jsx)(`tbody`,{children:a.rows.map((e,t)=>(0,F.jsx)(`tr`,{className:`hover:bg-[var(--c-bg2)] transition`,style:{borderBottom:`1px solid var(--c-border)`},children:a.columns.map(t=>(0,F.jsx)(`td`,{className:`px-3 py-1 font-mono`,style:O,children:zE(e[t])},t))},t))})]})})}),a&&a.rows.length===0&&(0,F.jsx)(`div`,{className:`rounded-lg px-3 py-6 text-center text-[12px]`,style:{...k,...O},children:`Query returned 0 rows`}),T&&(0,F.jsxs)(`div`,{className:`rounded-lg p-4`,style:k,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,F.jsx)(`span`,{className:`text-[12px] font-semibold`,style:D,children:`Visualization`}),(0,F.jsx)(`div`,{className:`flex gap-0.5 ml-2`,style:{border:`1px solid var(--c-border)`,borderRadius:6},children:[{type:`bar`,icon:yr},{type:`line`,icon:br},{type:`doughnut`,icon:xr}].map(({type:e,icon:t})=>(0,F.jsx)(`button`,{onClick:()=>g(e),className:`p-1.5 transition`,style:{background:h===e?`var(--c-bg2)`:`transparent`,color:h===e?`var(--c-white)`:`var(--c-text3)`,borderRadius:4},children:(0,F.jsx)(t,{size:12})},e))})]}),(0,F.jsxs)(`div`,{style:{height:h===`doughnut`?280:260},children:[h===`bar`&&(0,F.jsx)(wh,{data:T,options:E}),h===`line`&&(0,F.jsx)(Ch,{data:T,options:E}),h===`doughnut`&&(0,F.jsx)(Th,{data:T,options:E})]})]})]})}function zE(e){if(e==null)return(0,F.jsx)(`span`,{className:`opacity-30`,children:`NULL`});if(typeof e==`number`)return e.toLocaleString();let t=String(e);return t.length>120?t.substring(0,120)+`…`:t}var BE=`JetBrains Mono, monospace`;function VE(e){return e<1024?e+` B`:e<1024*1024?(e/1024).toFixed(1)+` KB`:(e/(1024*1024)).toFixed(1)+` MB`}function HE(e){return e?new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`,hour:`2-digit`,minute:`2-digit`}):``}function UE(e){return e?Math.round(e.length/4):0}function WE(e){return e<1e3?String(e):e<1e6?(e/1e3).toFixed(1)+`k`:(e/1e6).toFixed(2)+`M`}function GE(e){let t=e/1e6*3;return t<.001?`<$0.001`:t<.01?`$`+t.toFixed(4):`$`+t.toFixed(3)}function KE(e){if(!e)return`text`;let t=e.toLowerCase();return t.endsWith(`.json`)?`json`:t.endsWith(`.md`)||t.endsWith(`.mdc`)?`markdown`:t.endsWith(`.yaml`)||t.endsWith(`.yml`)?`yaml`:`text`}function qE({content:e}){let t;try{t=JSON.parse(e)}catch{return(0,F.jsx)(`pre`,{className:`text-[12px] whitespace-pre-wrap break-words leading-relaxed`,style:{color:`#ef4444`,fontFamily:BE},children:`Invalid JSON`})}let n=JSON.stringify(t,null,2);return(0,F.jsx)(`pre`,{className:`text-[12px] whitespace-pre-wrap break-words leading-relaxed`,style:{fontFamily:BE},children:n.split(`
|
|
71
71
|
`).map((e,t)=>{let n=[],r=e,i=r.match(/^(\s*)"([^"]+)"(:)/);i&&(n.push((0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:i[1]},`i${t}`)),n.push((0,F.jsxs)(`span`,{style:{color:`#818cf8`},children:[`"`,i[2],`"`]},`k${t}`)),n.push((0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:`:`},`c${t}`)),r=r.slice(i[0].length));let a=r.match(/^(\s*)"([^"]*)"(.*)/);if(a)n.push((0,F.jsx)(`span`,{children:a[1]},`sp${t}`)),n.push((0,F.jsxs)(`span`,{style:{color:`#22c55e`},children:[`"`,a[2],`"`]},`v${t}`)),n.push((0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:a[3]},`r${t}`));else{let e=r.match(/^(\s*)(true|false|null|-?\d+\.?\d*)(.*)?/);e?(n.push((0,F.jsx)(`span`,{children:e[1]},`sp${t}`)),n.push((0,F.jsx)(`span`,{style:{color:e[2]===`null`?`#ef4444`:e[2]===`true`||e[2]===`false`?`#f59e0b`:`#22d3ee`},children:e[2]},`v${t}`)),n.push((0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:e[3]||``},`r${t}`))):n.push((0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:r},`x${t}`))}return(0,F.jsxs)(`span`,{children:[n,`
|
|
72
72
|
`]},t)})})}function JE(e){let t=e.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);if(!t)return{frontmatter:null,body:e};let n=[],r=t[1].split(`
|
|
73
73
|
`);for(let e=0;e<r.length;e++){let t=r[e].match(/^(\w[\w-]*):\s*(.*)/);if(t){let i=t[1],a=t[2].replace(/^["']|["']$/g,``).trim();if(a)n.push([i,a]);else{let t=[];for(;e+1<r.length&&/^\s+-\s/.test(r[e+1]);){e++;let n=r[e].replace(/^\s+-\s*/,``),i=n.match(/^\[([ xX])\]\s*(.*)/);if(i)t.push({type:`checkbox`,checked:i[1]!==` `,text:i[2]});else{let i=n.match(/^(\w[\w-]*):\s*(.*)/);if(i){let n={[i[1]]:i[2].replace(/^["']|["']$/g,``)};for(;e+1<r.length&&/^\s{4,}\w/.test(r[e+1])&&!/^\s+-/.test(r[e+1]);){e++;let t=r[e].trim().match(/^(\w[\w-]*):\s*(.*)/);t&&(n[t[1]]=t[2].replace(/^["']|["']$/g,``))}t.push({type:`object`,data:n})}else t.push({type:`text`,text:n})}}n.push([i,t.length?t:``])}}}return{frontmatter:n.length?n:null,body:t[2]}}var YE={completed:{bg:`rgba(34,197,94,0.12)`,color:`#22c55e`,icon:`✓`},in_progress:{bg:`rgba(99,102,241,0.12)`,color:`#818cf8`,icon:`◐`},pending:{bg:`rgba(250,204,21,0.12)`,color:`#facc15`,icon:`○`},blocked:{bg:`rgba(239,68,68,0.12)`,color:`#ef4444`,icon:`✕`}};function XE({val:e}){return typeof e==`string`?(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`},children:e}):Array.isArray(e)?e.some(e=>e.type===`object`)?(0,F.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:4,width:`100%`},children:e.map((e,t)=>{if(e.type!==`object`)return(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`},children:e.text||``},t);let n=e.data,r=(n.status||``).toLowerCase().replace(/\s+/g,`_`),i=YE[r]||YE.pending,a=r===`completed`;return(0,F.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,padding:`3px 0`},children:[(0,F.jsx)(`span`,{style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:16,height:16,borderRadius:3,flexShrink:0,background:i.bg,color:i.color,fontSize:10,fontWeight:700},children:i.icon}),(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`,opacity:a?.55:1,textDecoration:a?`line-through`:`none`,flex:1},children:n.content||n.title||n.name||n.id||JSON.stringify(n)}),n.status&&(0,F.jsx)(`span`,{style:{fontSize:10,padding:`1px 6px`,borderRadius:3,background:i.bg,color:i.color,flexShrink:0},children:n.status})]},t)})}):(0,F.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:2},children:e.map((e,t)=>(0,F.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:6,color:`var(--c-text2)`,cursor:`default`},children:[e.type===`checkbox`?(0,F.jsx)(`span`,{style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:14,height:14,borderRadius:3,flexShrink:0,border:e.checked?`none`:`1.5px solid var(--c-text3)`,background:e.checked?`#6366f1`:`transparent`,color:`#fff`,fontSize:10,lineHeight:1},children:e.checked?`✓`:``}):(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:`•`}),(0,F.jsx)(`span`,{style:{textDecoration:e.checked?`line-through`:`none`,opacity:e.checked?.5:1},children:e.text})]},t))}):null}function ZE({content:e}){let{frontmatter:t,body:n}=JE(e);return(0,F.jsxs)(`div`,{className:`artifact-markdown`,style:{color:`var(--c-text)`,fontSize:14,lineHeight:1.7,maxWidth:720,margin:`0 auto`},children:[t&&(0,F.jsx)(`div`,{style:{background:`var(--c-bg)`,border:`1px solid var(--c-border)`,borderRadius:6,padding:`10px 14px`,marginBottom:16,fontSize:12,fontFamily:BE},children:t.map(([e,t],n)=>(0,F.jsxs)(`div`,{style:{display:`flex`,gap:8,padding:`3px 0`,alignItems:Array.isArray(t)?`flex-start`:`center`},children:[(0,F.jsx)(`span`,{style:{color:`#818cf8`,minWidth:100,flexShrink:0,paddingTop:Array.isArray(t)?1:0},children:e}),(0,F.jsx)(XE,{val:t})]},n))}),(0,F.jsx)(wS,{remarkPlugins:[OT],components:{h1:({children:e})=>(0,F.jsx)(`h1`,{style:{fontSize:22,fontWeight:700,margin:`0 0 12px 0`,paddingBottom:8,borderBottom:`1px solid var(--c-border)`,color:`var(--c-white)`},children:e}),h2:({children:e})=>(0,F.jsx)(`h2`,{style:{fontSize:18,fontWeight:600,margin:`20px 0 8px 0`,paddingBottom:6,borderBottom:`1px solid var(--c-border)`,color:`var(--c-white)`},children:e}),h3:({children:e})=>(0,F.jsx)(`h3`,{style:{fontSize:15,fontWeight:600,margin:`16px 0 6px 0`,color:`var(--c-white)`},children:e}),h4:({children:e})=>(0,F.jsx)(`h4`,{style:{fontSize:14,fontWeight:600,margin:`12px 0 4px 0`,color:`var(--c-white)`},children:e}),p:({children:e})=>(0,F.jsx)(`p`,{style:{margin:`0 0 10px 0`},children:e}),ul:({children:e})=>(0,F.jsx)(`ul`,{style:{margin:`0 0 10px 0`,paddingLeft:24,listStyleType:`disc`},children:e}),ol:({children:e})=>(0,F.jsx)(`ol`,{style:{margin:`0 0 10px 0`,paddingLeft:24,listStyleType:`decimal`},children:e}),li:({children:e,className:t})=>{let n=t===`task-list-item`;return(0,F.jsx)(`li`,{style:{margin:`2px 0`,listStyleType:n?`none`:void 0,marginLeft:n?-20:0},children:e})},input:({type:e,checked:t})=>e===`checkbox`?(0,F.jsx)(`span`,{style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:15,height:15,borderRadius:3,marginRight:6,verticalAlign:-2,flexShrink:0,border:t?`none`:`1.5px solid var(--c-text3)`,background:t?`#6366f1`:`transparent`,color:`#fff`,fontSize:10},children:t?`✓`:``}):null,pre:({children:e})=>(0,F.jsx)(`pre`,{style:{background:`var(--c-bg)`,border:`1px solid var(--c-border)`,borderRadius:6,padding:12,margin:`8px 0 12px 0`,overflow:`auto`,fontFamily:BE,fontSize:12,color:`var(--c-text)`,lineHeight:1.6},children:e}),code:({node:e,children:t})=>e?.position&&e.position.start.line!==e.position.end.line?(0,F.jsx)(`code`,{children:t}):(0,F.jsx)(`code`,{style:{background:`var(--c-bg3)`,padding:`1px 5px`,borderRadius:4,fontFamily:BE,fontSize:12,color:`#818cf8`},children:t}),blockquote:({children:e})=>(0,F.jsx)(`blockquote`,{style:{borderLeft:`3px solid #6366f1`,paddingLeft:12,margin:`8px 0`,color:`var(--c-text2)`,fontStyle:`italic`},children:e}),table:({children:e})=>(0,F.jsx)(`div`,{style:{overflow:`auto`,margin:`8px 0 12px 0`},children:(0,F.jsx)(`table`,{style:{borderCollapse:`collapse`,width:`100%`,fontSize:13},children:e})}),thead:({children:e})=>(0,F.jsx)(`thead`,{style:{borderBottom:`2px solid var(--c-border)`},children:e}),th:({children:e})=>(0,F.jsx)(`th`,{style:{textAlign:`left`,padding:`6px 12px`,fontWeight:600,color:`var(--c-white)`},children:e}),td:({children:e})=>(0,F.jsx)(`td`,{style:{padding:`5px 12px`,borderBottom:`1px solid var(--c-border)`},children:e}),a:({href:e,children:t})=>(0,F.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,style:{color:`#818cf8`,textDecoration:`underline`,textUnderlineOffset:2},children:t}),hr:()=>(0,F.jsx)(`hr`,{style:{border:`none`,borderTop:`1px solid var(--c-border)`,margin:`16px 0`}}),strong:({children:e})=>(0,F.jsx)(`strong`,{style:{color:`var(--c-white)`,fontWeight:600},children:e}),img:({src:e,alt:t})=>(0,F.jsx)(`img`,{src:e,alt:t,style:{maxWidth:`100%`,borderRadius:6,margin:`8px 0`}})},children:n})]})}function QE({content:e,fileName:t,viewRaw:n}){if(n)return(0,F.jsx)(`pre`,{className:`text-[12px] whitespace-pre-wrap break-words leading-relaxed`,style:{color:`var(--c-text)`,fontFamily:BE},children:e});let r=KE(t);return r===`json`?(0,F.jsx)(qE,{content:e}):r===`markdown`?(0,F.jsx)(ZE,{content:e}):(0,F.jsx)(`pre`,{className:`text-[12px] whitespace-pre-wrap break-words leading-relaxed`,style:{color:`var(--c-text)`,fontFamily:BE},children:e})}function $E(){let[e,t]=(0,S.useState)(null),[n,r]=(0,S.useState)(``),[i,a]=(0,S.useState)(new Set),[o,s]=(0,S.useState)(new Set),[c,l]=(0,S.useState)(null),[u,d]=(0,S.useState)(null),[f,p]=(0,S.useState)(!1),[m,h]=(0,S.useState)(!1);(0,S.useEffect)(()=>{ia().then(e=>{t(e),e&&e.length>0&&(a(new Set([e[0].folder])),e[0].editors.length>0&&s(new Set([e[0].folder+`::`+e[0].editors[0].editor])))})},[]);let g=async e=>{l(e),h(!1),p(!0);try{d(await aa(e.path))}catch{d({error:`Failed to load file content`})}p(!1)},_=e=>{a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},v=e=>{s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};if(!e)return(0,F.jsx)(wa,{label:`Scanning project artifacts...`});let y=e.filter(e=>{if(!n)return!0;let t=n.toLowerCase();return e.name.toLowerCase().includes(t)||e.folder.toLowerCase().includes(t)?!0:e.editors.some(e=>e.label.toLowerCase().includes(t)||e.files.some(e=>e.name.toLowerCase().includes(t)))}),b=e.reduce((e,t)=>e+t.totalArtifacts,0),x=e.length,C=new Set;for(let t of e)for(let e of t.editors)C.add(e.editor);return(0,F.jsxs)(`div`,{className:`h-full`,children:[(0,F.jsx)(`div`,{className:`px-4 py-3`,style:{borderBottom:`1px solid var(--c-border)`},children:(0,F.jsxs)($T,{icon:ii,title:`Artifacts`,children:[(0,F.jsxs)(`span`,{className:`text-[11px]`,style:{color:`var(--c-text3)`},children:[b,` artifacts · `,x,` projects · `,C.size,` editors`]}),(0,F.jsxs)(`div`,{className:`ml-auto relative`,children:[(0,F.jsx)(ui,{size:12,className:`absolute left-2.5 top-1/2 -translate-y-1/2`,style:{color:`var(--c-text3)`}}),(0,F.jsx)(`input`,{type:`text`,placeholder:`Search artifacts...`,value:n,onChange:e=>r(e.target.value),className:`pl-7 pr-3 py-1 text-[12px] outline-none w-[200px]`,style:{background:`var(--c-bg3)`,border:`1px solid var(--c-border)`,color:`var(--c-text)`}})]})]})}),y.length===0?(0,F.jsx)(`div`,{className:`text-sm py-12 text-center`,style:{color:`var(--c-text3)`},children:n?`No artifacts match your search`:`No AI artifacts found in any project folders`}):null,(0,F.jsxs)(`div`,{className:`flex`,style:{height:`calc(100vh - 130px)`},children:[(0,F.jsxs)(`div`,{className:`w-[340px] shrink-0 flex flex-col`,style:{background:`var(--c-card)`,borderRight:`1px solid var(--c-border)`},children:[(0,F.jsx)(`div`,{className:`px-3 py-2 text-[11px] font-semibold uppercase tracking-wider`,style:{color:`var(--c-text3)`,borderBottom:`1px solid var(--c-border)`},children:`Project Tree`}),(0,F.jsx)(`div`,{className:`overflow-y-auto flex-1`,children:y.map(e=>{let t=i.has(e.folder);return(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`button`,{onClick:()=>_(e.folder),className:`w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-[var(--c-bg3)] transition`,style:{borderBottom:`1px solid var(--c-border)`},children:[t?(0,F.jsx)(Cr,{size:12,style:{color:`var(--c-text3)`}}):(0,F.jsx)(wr,{size:12,style:{color:`var(--c-text3)`}}),(0,F.jsx)(Ur,{size:13,style:{color:`#6366f1`}}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`div`,{className:`text-[12px] font-medium truncate`,style:{color:`var(--c-white)`},children:e.name}),(0,F.jsx)(`div`,{className:`text-[10px] truncate`,style:{color:`var(--c-text3)`,fontFamily:BE},children:e.folder})]}),(0,F.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded`,style:{background:`rgba(99,102,241,0.12)`,color:`#818cf8`},children:e.totalArtifacts})]}),t&&e.editors.map(t=>{let n=e.folder+`::`+t.editor,r=o.has(n);return(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`button`,{onClick:()=>v(n),className:`w-full flex items-center gap-2 pl-7 pr-3 py-1.5 text-left hover:bg-[var(--c-bg3)] transition`,children:[r?(0,F.jsx)(Cr,{size:10,style:{color:`var(--c-text3)`}}):(0,F.jsx)(wr,{size:10,style:{color:`var(--c-text3)`}}),t.editor===`_general`?(0,F.jsx)(Br,{size:12,style:{color:`var(--c-text2)`}}):(0,F.jsx)(Gh,{source:t.editor,size:12}),(0,F.jsx)(`span`,{className:`text-[11px] font-medium`,style:{color:t.editor===`_general`?`var(--c-text2)`:Oh(t.editor)},children:t.editor===`_general`?t.label:q(t.editor)}),(0,F.jsx)(`span`,{className:`text-[10px] ml-auto`,style:{color:`var(--c-text3)`},children:t.files.length})]}),r&&t.files.map(e=>(0,F.jsxs)(`button`,{onClick:()=>g(e),className:`w-full flex items-center gap-2 pl-12 pr-3 py-1.5 text-left hover:bg-[var(--c-bg3)] transition`,style:{background:c?.path===e.path?`var(--c-bg3)`:`transparent`,borderLeft:c?.path===e.path?`2px solid #6366f1`:`2px solid transparent`},children:[(0,F.jsx)(Br,{size:11,style:{color:`var(--c-text3)`}}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`div`,{className:`text-[11px] truncate`,style:{color:`var(--c-text)`,fontFamily:BE},children:e.relativePath}),(0,F.jsxs)(`div`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:[VE(e.size),` · `,e.lines,` lines`]})]})]},e.path))]},n)})]},e.folder)})})]}),(0,F.jsx)(`div`,{className:`flex-1 flex flex-col min-w-0 overflow-hidden`,style:{background:`var(--c-card)`},children:c?(0,F.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2.5`,style:{borderBottom:`1px solid var(--c-border)`},children:[(0,F.jsx)(Br,{size:14,style:{color:`#6366f1`}}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,F.jsx)(`div`,{className:`text-[12px] font-medium`,style:{color:`var(--c-white)`,fontFamily:BE},children:c.relativePath}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px]`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(`span`,{children:VE(c.size)}),(0,F.jsxs)(`span`,{children:[c.lines,` lines`]}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(Ar,{size:9}),HE(c.modifiedAt)]})]})]}),u?.content&&(()=>{let e=UE(u.content);return(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] px-2 py-0.5 rounded`,style:{background:`rgba(99,102,241,0.08)`,border:`1px solid rgba(99,102,241,0.15)`,color:`#818cf8`},children:[(0,F.jsx)(Ti,{size:9}),WE(e),` tokens`]}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] px-2 py-0.5 rounded`,style:{background:`rgba(34,197,94,0.08)`,border:`1px solid rgba(34,197,94,0.15)`,color:`#22c55e`},children:[(0,F.jsx)(Ir,{size:9}),GE(e)]})]})})(),(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[10px] px-2 py-0.5 rounded`,style:{background:`${Oh(c.editor)}15`,color:Oh(c.editor)},children:[c.editor!==`_general`&&(0,F.jsx)(Gh,{source:c.editor,size:11}),c.editorLabel]}),(0,F.jsxs)(`button`,{onClick:()=>h(e=>!e),className:`flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-medium transition`,style:{background:m?`rgba(99,102,241,0.15)`:`var(--c-bg3)`,color:m?`#818cf8`:`var(--c-text2)`,border:`1px solid `+(m?`rgba(99,102,241,0.3)`:`var(--c-border)`)},title:m?`Switch to rendered view`:`Switch to raw view`,children:[m?(0,F.jsx)(zr,{size:12}):(0,F.jsx)(jr,{size:12}),m?`Rendered`:`Raw`]}),(0,F.jsx)(`button`,{onClick:()=>{l(null),d(null)},className:`p-1 rounded hover:bg-[var(--c-bg3)] transition`,style:{color:`var(--c-text3)`},children:(0,F.jsx)(ki,{size:14})})]}),(0,F.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:f?(0,F.jsx)(`div`,{className:`text-[12px] py-8 text-center`,style:{color:`var(--c-text3)`},children:`Loading...`}):u?.error?(0,F.jsx)(`div`,{className:`text-[12px] py-8 text-center`,style:{color:`#ef4444`},children:u.error}):u?.content?(0,F.jsx)(QE,{content:u.content,fileName:c.name,viewRaw:m}):null})]}):(0,F.jsx)(`div`,{className:`flex items-center justify-center flex-1 text-[13px]`,style:{color:`var(--c-text3)`},children:(0,F.jsxs)(`div`,{className:`text-center`,children:[(0,F.jsx)(ii,{size:32,className:`mx-auto mb-3 opacity-30`}),(0,F.jsx)(`div`,{children:`Select an artifact to view its contents`}),(0,F.jsx)(`div`,{className:`text-[11px] mt-1 opacity-60`,children:`Click any file in the sidebar tree`})]})})})]})]})}function eD(){let[e,t]=(0,S.useState)(null),[n,r]=(0,S.useState)([]),[i,a]=(0,S.useState)(!0),[o,s]=(0,S.useState)(!1),[c,l]=(0,S.useState)(``),[u,d]=(0,S.useState)(!1);if((0,S.useEffect)(()=>{Promise.all([Yi(),Zi()]).then(([e,n])=>{t(e),r(n),a(!1)}).catch(()=>a(!1))},[]),i||!e)return(0,F.jsx)(wa,{label:`Loading settings...`});let f=e.hiddenProjects||[],p=async e=>{s(!0),t(await Xi({hiddenProjects:f.includes(e)?f.filter(t=>t!==e):[...f,e]})),s(!1)},m=[...n.filter(e=>{if(!c)return!0;let t=c.toLowerCase();return e.folder.toLowerCase().includes(t)||e.name.toLowerCase().includes(t)})].sort((e,t)=>e.name.localeCompare(t.name)),h=!!e.allowSubscriptionAccess;return(0,F.jsxs)(`div`,{className:`fade-in space-y-3`,children:[(0,F.jsx)($T,{icon:pi,title:`Settings`}),(0,F.jsxs)(`div`,{className:`card overflow-hidden`,children:[(0,F.jsxs)(`div`,{className:`px-3 py-2 flex items-center justify-between`,style:{borderBottom:`1px solid var(--c-border)`},children:[(0,F.jsxs)($,{children:[h?(0,F.jsx)(hi,{size:11,className:`inline mr-1`}):(0,F.jsx)(gi,{size:11,className:`inline mr-1`}),`subscription access`]}),(0,F.jsx)(`button`,{onClick:()=>d(!0),disabled:o,className:`text-[11px] px-2 py-0.5 rounded transition`,style:{background:h?`rgba(34,197,94,0.08)`:`rgba(239,68,68,0.08)`,color:h?`#22c55e`:`#ef4444`,border:`1px solid ${h?`rgba(34,197,94,0.15)`:`rgba(239,68,68,0.15)`}`},children:h?`Enabled`:`Disabled`})]}),(0,F.jsxs)(`div`,{className:`text-[11px] px-3 py-2`,style:{color:`var(--c-text3)`},children:[`When enabled, Agentlytics reads locally stored auth tokens (Keychain, SQLite, config files) to show your plan and usage info for each editor. Tokens are kept in-memory only and `,(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`},children:`never sent to any third-party service`}),`.`]})]}),(0,F.jsxs)(`div`,{className:`card overflow-hidden`,children:[(0,F.jsxs)(`div`,{className:`px-3 py-2 flex items-center justify-between`,style:{borderBottom:`1px solid var(--c-border)`},children:[(0,F.jsxs)($,{children:[(0,F.jsx)(Ur,{size:11,className:`inline mr-1`}),`projects (`,n.length,`)`]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[f.length>0&&(0,F.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5`,style:{background:`rgba(239,68,68,0.08)`,color:`#ef4444`,border:`1px solid rgba(239,68,68,0.15)`},children:[f.length,` hidden`]}),(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(ui,{size:11,className:`absolute left-2 top-1/2 -translate-y-1/2`,style:{color:`var(--c-text3)`}}),(0,F.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:`Filter projects...`,className:`pl-6 pr-2 py-1 text-[11px] outline-none w-[180px]`,style:{background:`var(--c-bg3)`,color:`var(--c-text)`,border:`1px solid var(--c-border)`}})]})]})]}),(0,F.jsx)(`div`,{className:`text-[11px] px-3 py-1.5`,style:{color:`var(--c-text3)`,borderBottom:`1px solid var(--c-border)`,background:`var(--c-bg3)`},children:`Hidden projects are excluded from all dashboard stats, sessions, costs, and analytics.`}),m.map(e=>(0,F.jsx)(nD,{project:e,hidden:f.includes(e.folder),onToggle:p,saving:o},e.folder)),m.length===0&&(0,F.jsx)(`div`,{className:`text-center py-6 text-[12px]`,style:{color:`var(--c-text3)`},children:`no projects match filter`})]}),u&&(0,F.jsx)(tD,{enabling:!h,saving:o,onConfirm:async()=>{s(!0),t(await Xi({allowSubscriptionAccess:!h})),s(!1),d(!1)},onCancel:()=>d(!1)})]})}function tD({enabling:e,saving:t,onConfirm:n,onCancel:r}){return(0,F.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,style:{background:`rgba(0,0,0,0.6)`},onClick:r,children:(0,F.jsxs)(`div`,{className:`card w-[420px] mx-4`,onClick:e=>e.stopPropagation(),style:{background:`var(--c-bg2)`,border:`1px solid var(--c-border)`},children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3`,style:{borderBottom:`1px solid var(--c-border)`},children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] font-medium`,style:{color:`var(--c-white)`},children:[(0,F.jsx)(wi,{size:14,style:{color:e?`#fbbf24`:`#ef4444`}}),e?`Enable`:`Disable`,` Subscription Access`]}),(0,F.jsx)(`button`,{onClick:r,className:`p-1 rounded hover:bg-[var(--c-bg3)]`,style:{color:`var(--c-text3)`},children:(0,F.jsx)(ki,{size:14})})]}),(0,F.jsx)(`div`,{className:`px-4 py-3 text-[11px] space-y-2`,style:{color:`var(--c-text2)`},children:e?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`p`,{children:`This will allow Agentlytics to read locally stored auth tokens from:`}),(0,F.jsxs)(`ul`,{className:`space-y-1 pl-3`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(`li`,{children:`Claude Code – macOS Keychain / Linux secret-tool`}),(0,F.jsx)(`li`,{children:`Cursor – local SQLite (state.vscdb)`}),(0,F.jsx)(`li`,{children:`Copilot / VS Code – ~/.config/github-copilot/apps.json`}),(0,F.jsx)(`li`,{children:`Codex – local auth.json (JWT decode only)`}),(0,F.jsx)(`li`,{children:`Devin – local SQLite (state.vscdb)`})]}),(0,F.jsxs)(`p`,{style:{color:`var(--c-text2)`},children:[`Tokens are kept `,(0,F.jsx)(`strong`,{children:`in-memory only`}),` and never sent to any third-party service.`]})]}):(0,F.jsx)(`p`,{children:`This will stop Agentlytics from reading any local auth tokens. Subscription and plan details will no longer be collected.`})}),(0,F.jsxs)(`div`,{className:`flex justify-end gap-2 px-4 py-3`,style:{borderTop:`1px solid var(--c-border)`},children:[(0,F.jsx)(`button`,{onClick:r,className:`text-[11px] px-3 py-1 rounded transition`,style:{color:`var(--c-text3)`,border:`1px solid var(--c-border)`},children:`Cancel`}),(0,F.jsx)(`button`,{onClick:n,disabled:t,className:`text-[11px] px-3 py-1 rounded transition font-medium`,style:{background:e?`rgba(34,197,94,0.12)`:`rgba(239,68,68,0.12)`,color:e?`#22c55e`:`#ef4444`,border:`1px solid ${e?`rgba(34,197,94,0.2)`:`rgba(239,68,68,0.2)`}`},children:t?`Saving...`:e?`Yes, enable`:`Yes, disable`})]})]})})}function nD({project:e,hidden:t,onToggle:n,saving:r}){let i=Object.entries(e.editors||{}).sort((e,t)=>t[1]-e[1]);return(0,F.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2 transition`,style:{borderBottom:`1px solid var(--c-border)`,opacity:t?.5:1},onMouseEnter:e=>e.currentTarget.style.background=`var(--c-bg3)`,onMouseLeave:e=>e.currentTarget.style.background=`transparent`,children:[(0,F.jsx)(`button`,{onClick:()=>n(e.folder),disabled:r,className:`shrink-0 p-1 rounded transition hover:bg-[var(--c-bg)]`,style:{color:t?`#ef4444`:`var(--c-text3)`,border:`1px solid var(--c-border)`},title:t?`Show this project`:`Hide this project`,children:t?(0,F.jsx)(Rr,{size:12}):(0,F.jsx)(zr,{size:12})}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`div`,{className:`text-[12px] font-medium truncate`,style:{color:t?`var(--c-text3)`:`var(--c-white)`},children:e.name}),(0,F.jsx)(`div`,{className:`text-[10px] truncate`,style:{color:`var(--c-text3)`},title:e.folder,children:e.folder})]}),(0,F.jsx)(`div`,{className:`flex items-center gap-2 shrink-0`,children:i.slice(0,3).map(([e,t])=>(0,F.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px]`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(Gh,{source:e,size:10}),t]},e))}),(0,F.jsx)(`div`,{className:`text-[11px] font-mono shrink-0`,style:{color:`var(--c-text2)`},children:J(e.totalSessions)}),(0,F.jsx)(`div`,{className:`text-[10px] shrink-0 w-[80px] text-right`,style:{color:`var(--c-text3)`},children:Ah(e.lastSeen)})]})}function rD({value:e,max:t=100,color:n,label:r}){let i=t>0?Math.min(e/t*100,100):0;return(0,F.jsxs)(`div`,{children:[r&&(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,F.jsx)(`span`,{className:`text-[10px]`,style:{color:`var(--c-text2)`},children:r}),(0,F.jsxs)(`span`,{className:`text-[10px] font-mono`,style:{color:`var(--c-white)`},children:[typeof e==`number`?e.toFixed(1):e,`%`]})]}),(0,F.jsx)(`div`,{className:`h-1.5 w-full`,style:{background:`var(--c-bg3)`},children:(0,F.jsx)(`div`,{className:`h-full transition-all duration-500`,style:{width:`${i}%`,background:n||`#6366f1`}})})]})}function iD({date:e}){if(!e)return null;let t=new Date(e)-new Date;if(t<=0)return(0,F.jsx)(`span`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:`expired`});let n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return n>24?(0,F.jsxs)(`span`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:[`resets in `,Math.floor(n/24),`d `,n%24,`h`]}):(0,F.jsxs)(`span`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:[`resets in `,n,`h `,r,`m`]})}function aD({name:e}){if(!e)return null;let t=(e||``).toLowerCase(),n=`rgba(99,102,241,0.12)`,r=`#818cf8`;return t.includes(`pro`)&&(n=`rgba(168,85,247,0.12)`,r=`#a855f7`),(t.includes(`max`)||t.includes(`ultra`))&&(n=`rgba(234,179,8,0.12)`,r=`#eab308`),t.includes(`plus`)&&(n=`rgba(34,197,94,0.12)`,r=`#22c55e`),t.includes(`free`)&&(n=`rgba(107,114,128,0.12)`,r=`#6b7280`),(0,F.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-wider px-2 py-0.5`,style:{background:n,color:r},children:e})}function oD({label:e,enabled:t}){return(0,F.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5`,style:{background:t?`rgba(34,197,94,0.08)`:`rgba(107,114,128,0.06)`,color:t?`#22c55e`:`var(--c-text3)`,border:`1px solid ${t?`rgba(34,197,94,0.15)`:`var(--c-border)`}`},children:e})}function sD({data:e}){let t=e.usage||{},n=Object.keys(t);return(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,F.jsx)(aD,{name:e.plan?.name}),e.plan?.status&&(0,F.jsxs)(`span`,{className:`text-[10px]`,style:{color:e.plan.status===`active`?`#22c55e`:`var(--c-text3)`},children:[`● `,e.plan.status]}),e.plan?.isYearlyPlan&&(0,F.jsx)(`span`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:`yearly`})]}),e.startOfMonth&&(0,F.jsxs)(`div`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(Ar,{size:9,className:`inline mr-1`}),`billing started `,new Date(e.startOfMonth).toLocaleDateString()]}),n.length>0&&(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(`div`,{className:`text-[10px] font-medium`,style:{color:`var(--c-text2)`},children:`model usage`}),n.map(e=>{let n=t[e];return n.maxRequestUsage&&Math.round(n.numRequests/n.maxRequestUsage*100),(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[11px]`,children:[(0,F.jsx)(`span`,{className:`font-mono`,style:{color:`var(--c-white)`},children:e}),(0,F.jsxs)(`span`,{style:{color:`var(--c-text2)`},children:[n.numRequests,n.maxRequestUsage?` / ${n.maxRequestUsage}`:``,` requests`]})]},e)})]})]})}function cD({data:e}){let t=e.usage||{},n=e.billingCycle||{};return(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,F.jsx)(aD,{name:e.plan?.name}),e.user?.name&&(0,F.jsx)(`span`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:e.user.name})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[t.promptCredits&&(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`flex justify-between text-[10px] mb-0.5`,children:[(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`},children:`prompt credits`}),(0,F.jsxs)(`span`,{className:`font-mono`,style:{color:`var(--c-white)`},children:[t.promptCredits.remaining,` / `,t.promptCredits.allocated]})]}),(0,F.jsx)(rD,{value:t.promptCredits.allocated>0?t.promptCredits.remaining/t.promptCredits.allocated*100:0,color:`#06b6d4`})]}),t.flexCredits&&t.flexCredits.allocated>0&&(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`flex justify-between text-[10px] mb-0.5`,children:[(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`},children:`flex credits`}),(0,F.jsxs)(`span`,{className:`font-mono`,style:{color:`var(--c-white)`},children:[t.flexCredits.remaining,` / `,t.flexCredits.allocated]})]}),(0,F.jsx)(rD,{value:t.flexCredits.allocated>0?t.flexCredits.remaining/t.flexCredits.allocated*100:0,color:`#a78bfa`})]}),t.totalRemainingCredits!=null&&(0,F.jsxs)(`div`,{className:`flex items-center justify-between pt-1`,style:{borderTop:`1px solid var(--c-border)`},children:[(0,F.jsx)(`span`,{className:`text-[10px] font-medium`,style:{color:`var(--c-text2)`},children:`total remaining`}),(0,F.jsx)(`span`,{className:`text-[13px] font-bold font-mono`,style:{color:`var(--c-white)`},children:t.totalRemainingCredits})]})]}),(n.start||n.end)&&(0,F.jsxs)(`div`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(Ar,{size:9,className:`inline mr-1`}),n.start&&new Date(n.start).toLocaleDateString(),` → `,n.end&&new Date(n.end).toLocaleDateString()]}),e.features&&(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Object.entries(e.features).map(([e,t])=>(0,F.jsx)(oD,{label:e.replace(/([A-Z])/g,` $1`).trim(),enabled:t},e))})]})}function lD({data:e}){let t=e.usage||{};return(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)(aD,{name:e.plan?.name}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[t.fiveHour&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)(rD,{value:t.fiveHour.utilization,color:t.fiveHour.utilization>80?`#ef4444`:`#f97316`,label:`5-hour limit`}),(0,F.jsx)(iD,{date:t.fiveHour.resetsAt})]}),t.sevenDay&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)(rD,{value:t.sevenDay.utilization,color:t.sevenDay.utilization>80?`#ef4444`:`#f97316`,label:`7-day limit`}),(0,F.jsx)(iD,{date:t.sevenDay.resetsAt})]}),t.sevenDaySonnet&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)(rD,{value:t.sevenDaySonnet.utilization,color:`#a78bfa`,label:`7-day Sonnet`}),(0,F.jsx)(iD,{date:t.sevenDaySonnet.resetsAt})]}),t.sevenDayOpus&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)(rD,{value:t.sevenDayOpus.utilization,color:`#c084fc`,label:`7-day Opus`}),(0,F.jsx)(iD,{date:t.sevenDayOpus.resetsAt})]})]}),e.extraUsage&&(0,F.jsxs)(`div`,{className:`text-[10px] flex items-center gap-1.5`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(Ai,{size:9}),`extra usage: `,e.extraUsage.isEnabled?(0,F.jsxs)(`span`,{style:{color:`#22c55e`},children:[`enabled`,e.extraUsage.utilization==null?``:` (${e.extraUsage.utilization}% used)`]}):(0,F.jsx)(`span`,{children:`disabled`})]})]})}function uD({data:e}){return(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,F.jsx)(aD,{name:e.plan?.name}),e.plan?.individual&&(0,F.jsx)(`span`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:`individual`})]}),e.user?.login&&(0,F.jsxs)(`div`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:[`@`,e.user.login]}),e.features&&(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Object.entries(e.features).map(([e,t])=>(0,F.jsx)(oD,{label:e.replace(/([A-Z])/g,` $1`).trim(),enabled:t},e))}),e.limits?.quotas&&(0,F.jsxs)(`div`,{className:`text-[10px]`,style:{color:`var(--c-text2)`},children:[(0,F.jsx)(_i,{size:9,className:`inline mr-1`}),`quotas: `,JSON.stringify(e.limits.quotas),e.limits.resetDate&&(0,F.jsxs)(`span`,{children:[` (resets `,new Date(e.limits.resetDate).toLocaleDateString(),`)`]})]})]})}function dD({data:e}){let t=e.plan||{};return(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,F.jsx)(aD,{name:t.name}),e.authMode&&(0,F.jsxs)(`span`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:[`via `,e.authMode]})]}),e.user?.email&&(0,F.jsx)(`div`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:e.user.email}),(t.subscriptionStart||t.subscriptionEnd)&&(0,F.jsxs)(`div`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(Ar,{size:9,className:`inline mr-1`}),t.subscriptionStart&&new Date(t.subscriptionStart).toLocaleDateString(),` → `,t.subscriptionEnd&&new Date(t.subscriptionEnd).toLocaleDateString()]})]})}function fD({data:e}){return(0,F.jsxs)(`div`,{className:`space-y-2`,children:[e.plan?.name&&(0,F.jsx)(aD,{name:e.plan.name}),e.user&&(0,F.jsx)(`div`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:e.user.email||e.user.login||e.user.name||e.user.id||``}),(0,F.jsx)(`pre`,{className:`text-[10px] overflow-auto p-2`,style:{background:`var(--c-bg3)`,color:`var(--c-text2)`,maxHeight:120},children:JSON.stringify(e,null,2)})]})}function pD({data:e}){let[t,n]=(0,S.useState)(!1),r=e.source,i=Oh(r),a=q(r),o=()=>{switch(r){case`cursor`:return(0,F.jsx)(sD,{data:e});case`devin`:case`devin-next`:case`antigravity`:return(0,F.jsx)(cD,{data:e});case`claude-code`:return(0,F.jsx)(lD,{data:e});case`vscode`:case`vscode-insiders`:return(0,F.jsx)(uD,{data:e});case`copilot-cli`:return(0,F.jsx)(uD,{data:e});case`codex`:return(0,F.jsx)(dD,{data:e});default:return(0,F.jsx)(fD,{data:e})}},s=e.models||[];return(0,F.jsxs)(`div`,{className:`card p-4 space-y-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(Gh,{source:r,size:20}),(0,F.jsx)(`span`,{className:`text-[13px] font-bold`,style:{color:`var(--c-white)`},children:a})]}),(0,F.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full`,style:{background:i}})]}),o(),s.length>0&&(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`button`,{onClick:()=>n(!t),className:`flex items-center gap-1 text-[10px] transition hover:opacity-80`,style:{color:`var(--c-text2)`},children:[t?(0,F.jsx)(Tr,{size:10}):(0,F.jsx)(Cr,{size:10}),s.length,` models`]}),t&&(0,F.jsx)(`div`,{className:`mt-2 space-y-1`,children:s.map((e,t)=>(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] py-0.5`,style:{borderBottom:`1px solid var(--c-border)`},children:[(0,F.jsx)(`span`,{style:{color:`var(--c-white)`},children:e.label||e.model}),e.remainingFraction!=null&&(0,F.jsxs)(`span`,{className:`font-mono`,style:{color:e.remainingFraction>.5?`#22c55e`:e.remainingFraction>.2?`#eab308`:`#ef4444`},children:[(e.remainingFraction*100).toFixed(0),`%`]})]},t))})]})]})}function mD(){let[e,t]=(0,S.useState)(null),[n,r]=(0,S.useState)(!0),[i,a]=(0,S.useState)(null),o=()=>{r(!0),a(null),ra().then(e=>{t(e),r(!1)}).catch(e=>{a(e.message),r(!1)})};return(0,S.useEffect)(()=>{o()},[]),(0,F.jsxs)(`div`,{className:`fade-in space-y-3`,children:[(0,F.jsxs)($T,{icon:Pr,title:`Subscriptions`,children:[(0,F.jsxs)(`button`,{onClick:o,disabled:n,className:`flex items-center gap-1 px-2 py-0.5 text-[11px] transition hover:bg-[var(--c-card)]`,style:{color:`var(--c-text2)`,border:`1px solid var(--c-border)`},children:[(0,F.jsx)(li,{size:10,className:n?`animate-spin`:``}),`Refresh`]}),e&&(0,F.jsxs)(`span`,{className:`text-[11px] ml-auto`,style:{color:`var(--c-text3)`},children:[e.length,` subscription`,e.length===1?``:`s`,` detected`]})]}),n&&!e&&(0,F.jsx)(wa,{label:`Loading subscriptions...`}),i&&(0,F.jsx)(`div`,{className:`text-[12px] px-3 py-2`,style:{background:`rgba(239,68,68,0.08)`,border:`1px solid rgba(239,68,68,0.15)`,color:`#ef4444`},children:i}),e&&e.length===0&&(0,F.jsx)(`div`,{className:`text-sm py-12 text-center`,style:{color:`var(--c-text3)`},children:`No subscriptions detected. Make sure your editors are installed and logged in.`}),e&&e.length>0&&(0,F.jsx)(`div`,{className:`grid gap-3`,style:{gridTemplateColumns:`repeat(auto-fill, minmax(340px, 1fr))`},children:e.map((e,t)=>(0,F.jsx)(pD,{data:e},e.source+`-`+t))})]})}Lf.register(qf,wm,im,km,Nm,vp);var hD=`JetBrains Mono, monospace`,gD=[`#6366f1`,`#22c55e`,`#f59e0b`,`#ec4899`,`#3b82f6`,`#a855f7`,`#14b8a6`,`#f43f5e`,`#84cc16`,`#06b6d4`,`#e879f9`,`#fb923c`];function _D({server:e,matchedTools:t}){let[n,r]=(0,S.useState)(!1),i=t||[],a=i.reduce((e,t)=>e+t.count,0),o=e.tools||[],s=o.length>0||i.length>0;return(0,F.jsxs)(`div`,{className:`card overflow-hidden`,children:[(0,F.jsxs)(`button`,{onClick:()=>s&&r(!n),className:`w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-[var(--c-bg3)] transition`,children:[(0,F.jsx)(`div`,{className:`flex items-center justify-center w-6 h-6`,style:{background:`${Oh(e.editor)}15`},children:(0,F.jsx)(fi,{size:11,style:{color:Oh(e.editor)}})}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`text-[12px] font-semibold truncate`,style:{color:`var(--c-white)`},children:e.name}),(0,F.jsx)(`span`,{className:`text-[10px] px-1 py-px`,style:{background:e.scope===`global`?`rgba(99,102,241,0.12)`:`rgba(34,197,94,0.12)`,color:e.scope===`global`?`#818cf8`:`#22c55e`},children:e.scope}),(0,F.jsx)(`span`,{className:`text-[10px] px-1 py-px`,style:{background:e.transport===`stdio`?`rgba(234,179,8,0.12)`:`rgba(59,130,246,0.12)`,color:e.transport===`stdio`?`#eab308`:`#3b82f6`},children:e.transport}),e.disabled&&(0,F.jsx)(`span`,{className:`text-[10px] px-1 py-px`,style:{background:`rgba(239,68,68,0.12)`,color:`#ef4444`},children:`disabled`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 mt-px`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px]`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(Gh,{source:e.editor,size:10}),e.editorLabel]}),e.command&&(0,F.jsxs)(`span`,{className:`text-[10px] truncate`,style:{color:`var(--c-text3)`,fontFamily:hD},children:[e.command,` `,(e.args||[]).slice(0,2).join(` `)]}),e.url&&(0,F.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] truncate`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(Kr,{size:9}),e.url]})]})]}),(0,F.jsxs)(`div`,{className:`text-right shrink-0`,children:[a>0&&(0,F.jsx)(`div`,{className:`text-[12px] font-semibold`,style:{color:`var(--c-white)`},children:J(a)}),(0,F.jsxs)(`div`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:[o.length>0?`${o.length} tools`:`offline`,i.length>0?` · ${i.length} matched`:``]})]}),s?n?(0,F.jsx)(Cr,{size:12,style:{color:`var(--c-text3)`}}):(0,F.jsx)(wr,{size:12,style:{color:`var(--c-text3)`}}):(0,F.jsx)(`div`,{className:`w-3`})]}),n&&s&&(0,F.jsxs)(`div`,{className:`px-3 pb-2 pt-1`,style:{borderTop:`1px solid var(--c-border)`},children:[o.length>0&&(0,F.jsxs)(`div`,{className:`mb-1.5`,children:[(0,F.jsxs)(`div`,{className:`text-[10px] font-medium mb-0.5`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(Oi,{size:9,className:`inline mr-0.5`}),`Available (`,o.length,`)`]}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-0.5`,children:o.map(e=>(0,F.jsx)(`span`,{className:`text-[10px] px-1 py-px`,style:{background:`var(--c-bg3)`,color:`var(--c-text3)`,fontFamily:hD},children:e},e))})]}),i.length>0&&(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`text-[10px] font-medium mb-0.5`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(qr,{size:9,className:`inline mr-0.5`}),`Matched Calls`]}),(0,F.jsx)(`div`,{className:`space-y-0.5`,children:i.map(e=>(0,F.jsxs)(`div`,{className:`flex items-center justify-between py-0.5 px-1.5`,style:{background:`var(--c-bg3)`},children:[(0,F.jsx)(`span`,{className:`text-[10px] truncate`,style:{fontFamily:hD,color:`var(--c-text)`},children:e.name}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 ml-2`,children:[(0,F.jsxs)(`span`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:[e.sessionCount,`s`]}),(0,F.jsx)(`span`,{className:`text-[11px] font-semibold`,style:{color:`var(--c-white)`},children:J(e.count)})]})]},e.name))})]})]})]})}function vD(){let e=dt(),[t,n]=(0,S.useState)(null),[r,i]=(0,S.useState)(!0),[a,o]=(0,S.useState)(``),[s,c]=(0,S.useState)(`servers`),[l,u]=(0,S.useState)(``),[d,f]=(0,S.useState)(``),{dark:p}=tr(),m=p?`#a0a0a0`:`#444`,h=p?`#555`:`#999`,g=p?`rgba(255,255,255,0.03)`:`rgba(0,0,0,0.06)`,_=p?`#9ca3af`:`#555`;(0,S.useEffect)(()=>{oa().then(e=>{n(e),i(!1)}).catch(()=>i(!1))},[]);let v=(0,S.useMemo)(()=>{if(!t)return[];let e=a.toLowerCase();return t.servers.filter(t=>!e||t.name.toLowerCase().includes(e)||t.editor.toLowerCase().includes(e)||(t.command||``).toLowerCase().includes(e))},[t,a]),y=(0,S.useMemo)(()=>{if(!t)return{};let e={};for(let[n,r]of Object.entries(t.matchedTools||{}))for(let t of r)e[t.name]=n;return e},[t]),b=(0,S.useMemo)(()=>{if(!t)return{projects:[],servers:[]};let e=new Set,n=new Set;for(let r of t.toolCalls){for(let t of r.folders||[])e.add(t);let t=y[r.name];t?n.add(t):n.add(`__builtin__`)}return{projects:[...e].sort((e,t)=>e.split(`/`).pop().localeCompare(t.split(`/`).pop())),servers:[...n].filter(e=>e!==`__builtin__`).sort(),hasBuiltIn:n.has(`__builtin__`)}},[t,y]),x=(0,S.useMemo)(()=>{if(!t)return[];let e=a.toLowerCase();return t.toolCalls.filter(t=>!(e&&!t.name.toLowerCase().includes(e)||l&&!(t.folders||[]).includes(l)||d===`__builtin__`&&y[t.name]||d&&d!==`__builtin__`&&y[t.name]!==d))},[t,a,l,d,y]),C=(0,S.useMemo)(()=>{if(!t)return[];let e=a.toLowerCase();return t.topSessions.filter(t=>!e||(t.name||``).toLowerCase().includes(e)||t.source.toLowerCase().includes(e)||(t.folder||``).toLowerCase().includes(e))},[t,a]),w=(0,S.useMemo)(()=>{let e={};for(let t of v)e[t.editor]||(e[t.editor]=[]),e[t.editor].push(t);return e},[v]),T=(0,S.useMemo)(()=>{if(!t)return null;let e={};for(let n of t.servers){let r=(t.matchedTools[n.name]||[]).reduce((e,t)=>e+t.count,0);r!==0&&(e[n.name]||(e[n.name]={}),e[n.name][n.editor]=(e[n.name][n.editor]||0)+r)}let n=Object.entries(e).map(([e,t])=>({name:e,byEditor:t,total:Object.values(t).reduce((e,t)=>e+t,0)})).sort((e,t)=>t.total-e.total).slice(0,10);if(n.length===0)return null;let r=[...new Set(n.flatMap(e=>Object.keys(e.byEditor)))];return{labels:n.map(e=>e.name),datasets:r.map(e=>({label:q(e),data:n.map(t=>t.byEditor[e]||0),backgroundColor:Oh(e)+`CC`,borderRadius:2}))}},[t]),E=(0,S.useMemo)(()=>t?t.servers.filter(e=>(t.matchedTools[e.name]||[]).length===0):[],[t]),D=(0,S.useMemo)(()=>{if(!t)return[];let e=[];for(let[n,r]of Object.entries(t.matchedTools))for(let t of r)e.push({...t,server:n});return e.sort((e,t)=>t.count-e.count).slice(0,12)},[t]),O=(0,S.useMemo)(()=>{if(!t)return[];let e=new Set;for(let n of Object.values(t.matchedTools))for(let t of n)e.add(t.name);let n=[];for(let r of t.servers){let t=r.tools||[];if(t.length!==0)for(let i of t)e.has(i)||n.push({name:i,server:r.name,editor:r.editor})}return n},[t]),k=(0,S.useMemo)(()=>{if(!t)return null;let e={};for(let n of t.servers){let t=q(n.editor);e[t]=(e[t]||0)+1}let n=Object.entries(e).sort((e,t)=>t[1]-e[1]);return n.length===0?null:{labels:n.map(e=>e[0]),colors:n.map(e=>{let n=t.servers.find(t=>q(t.editor)===e[0]);return n?Oh(n.editor):`#666`}),values:n.map(e=>e[1])}},[t]),A=(0,S.useMemo)(()=>{if(!t)return null;let e={};for(let n of t.servers)e[n.transport]=(e[n.transport]||0)+1;let n=Object.entries(e).sort((e,t)=>t[1]-e[1]);if(n.length===0)return null;let r={stdio:`#eab308`,http:`#3b82f6`,sse:`#a855f7`};return{labels:n.map(e=>e[0]),colors:n.map(e=>r[e[0]]||`#666`),values:n.map(e=>e[1])}},[t]);if(r)return(0,F.jsx)(wa,{label:`Loading MCP data...`});if(!t)return(0,F.jsx)(`div`,{className:`text-center py-20 text-[13px]`,style:{color:`var(--c-text3)`},children:`Failed to load MCP data`});let{summary:j,matchedTools:ee}=t,te=[{id:`servers`,label:`Servers`,count:t.servers.length},{id:`tools`,label:`Tools`,count:t.toolCalls.length},{id:`sessions`,label:`Sessions`,count:t.topSessions.length}];return(0,F.jsxs)(`div`,{className:`fade-in space-y-3`,children:[(0,F.jsx)($T,{icon:oi,title:`MCPs`}),(0,F.jsxs)(`div`,{className:`grid gap-2`,style:{gridTemplateColumns:`repeat(auto-fit, minmax(90px, 1fr))`},children:[(0,F.jsx)(K,{label:`servers`,value:j.totalServers,sub:`${j.editorsWithServers.length} editors`}),(0,F.jsx)(K,{label:`unique tools`,value:J(j.uniqueTools)}),(0,F.jsx)(K,{label:`tool calls`,value:J(j.totalToolCalls)}),(0,F.jsx)(K,{label:`sessions`,value:J(j.sessionsWithTools)}),(0,F.jsx)(K,{label:`matched`,value:Object.values(ee).reduce((e,t)=>e+t.length,0),sub:`${Object.keys(ee).length} servers`})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-2`,children:[(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsxs)($,{children:[`most used servers `,(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:`(by editor)`})]}),T?(0,F.jsx)(`div`,{style:{height:Math.max(T.labels.length*22+10,80)},children:(0,F.jsx)(wh,{data:T,options:{indexAxis:`y`,responsive:!0,maintainAspectRatio:!1,scales:{x:{stacked:!0,grid:{color:g},ticks:{color:h,font:{size:9,family:hD}}},y:{stacked:!0,grid:{display:!1},ticks:{color:m,font:{size:9,family:hD}}}},plugins:{legend:{position:`top`,labels:{color:_,font:{size:9,family:hD},usePointStyle:!0,pointStyle:`circle`,padding:6}},tooltip:{mode:`index`,bodyFont:{family:hD,size:10},titleFont:{family:hD,size:10}}}}})}):(0,F.jsx)(`div`,{className:`text-[11px] text-center py-6`,style:{color:`var(--c-text3)`},children:`No MCP server usage`})]}),(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`most used tools`}),D.length>0?(0,F.jsx)(`div`,{style:{height:Math.max(D.length*22+10,80)},children:(0,F.jsx)(wh,{data:{labels:D.map(e=>e.name),datasets:[{data:D.map(e=>e.count),backgroundColor:gD.slice(0,D.length),borderRadius:2}]},options:{indexAxis:`y`,responsive:!0,maintainAspectRatio:!1,scales:{x:{grid:{color:g},ticks:{color:h,font:{size:9,family:hD}}},y:{grid:{display:!1},ticks:{color:m,font:{size:9,family:hD}}}},plugins:{legend:{display:!1},tooltip:{bodyFont:{family:hD,size:10},titleFont:{family:hD,size:10},callbacks:{afterLabel:e=>`Server: ${D[e.dataIndex]?.server||`?`}`}}}}})}):(0,F.jsx)(`div`,{className:`text-[11px] text-center py-6`,style:{color:`var(--c-text3)`},children:`No MCP tool usage`})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`servers by editor`}),k?(0,F.jsx)(`div`,{style:{height:110},children:(0,F.jsx)(Th,{data:{labels:k.labels,datasets:[{data:k.values,backgroundColor:k.colors,borderWidth:0}]},options:{responsive:!0,maintainAspectRatio:!1,cutout:`55%`,plugins:{legend:{position:`right`,labels:{color:_,font:{size:9,family:hD},usePointStyle:!0,pointStyle:`circle`,padding:6}},tooltip:{bodyFont:{family:hD,size:10},titleFont:{family:hD,size:10}}}}})}):(0,F.jsx)(`div`,{className:`text-[11px] text-center py-4`,style:{color:`var(--c-text3)`},children:`no data`})]}),(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`servers by transport`}),A?(0,F.jsx)(`div`,{style:{height:90},children:(0,F.jsx)(Th,{data:{labels:A.labels,datasets:[{data:A.values,backgroundColor:A.colors,borderWidth:0}]},options:{responsive:!0,maintainAspectRatio:!1,cutout:`55%`,plugins:{legend:{position:`right`,labels:{color:_,font:{size:9,family:hD},usePointStyle:!0,pointStyle:`circle`,padding:6}},tooltip:{bodyFont:{family:hD,size:10},titleFont:{family:hD,size:10}}}}})}):(0,F.jsx)(`div`,{className:`text-[11px] text-center py-4`,style:{color:`var(--c-text3)`},children:`no data`})]})]})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-2`,children:[(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsxs)($,{children:[`never used servers `,(0,F.jsxs)(`span`,{style:{color:`var(--c-text3)`},children:[`(`,E.length,`)`]})]}),E.length>0?(0,F.jsx)(`div`,{className:`space-y-0.5 max-h-[160px] overflow-y-auto scrollbar-thin`,children:E.map((e,t)=>(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 py-0.5 px-1.5`,style:{background:`var(--c-bg3)`},children:[(0,F.jsx)(pr,{size:9,style:{color:`#ef4444`,opacity:.5}}),(0,F.jsx)(`span`,{className:`text-[10px] font-medium truncate`,style:{color:`var(--c-text)`},children:e.name}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1 ml-auto shrink-0`,children:[(0,F.jsx)(Gh,{source:e.editor,size:10}),(0,F.jsx)(`span`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:e.editorLabel})]}),e.disabled&&(0,F.jsx)(`span`,{className:`text-[9px] px-0.5`,style:{background:`rgba(239,68,68,0.12)`,color:`#ef4444`},children:`off`})]},`${e.name}-${e.editor}-${t}`))}):(0,F.jsx)(`div`,{className:`text-[11px] text-center py-4`,style:{color:`var(--c-text3)`},children:`All servers have been used`})]}),(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsxs)($,{children:[`never used tools `,(0,F.jsxs)(`span`,{style:{color:`var(--c-text3)`},children:[`(`,O.length,`)`]})]}),O.length>0?(0,F.jsx)(`div`,{className:`space-y-0.5 max-h-[160px] overflow-y-auto scrollbar-thin`,children:O.map((e,t)=>(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 py-0.5 px-1.5`,style:{background:`var(--c-bg3)`},children:[(0,F.jsx)(pr,{size:9,style:{color:`#f59e0b`,opacity:.5}}),(0,F.jsx)(`span`,{className:`text-[10px] truncate`,style:{fontFamily:hD,color:`var(--c-text)`},children:e.name}),(0,F.jsx)(`span`,{className:`ml-auto shrink-0 text-[10px] px-1 py-px`,style:{background:`rgba(99,102,241,0.12)`,color:`#818cf8`},children:e.server})]},`${e.name}-${e.server}-${t}`))}):(0,F.jsx)(`div`,{className:`text-[11px] text-center py-4`,style:{color:`var(--c-text3)`},children:`All queried tools have been used`})]})]}),t.projectMcps&&t.projectMcps.length>0&&(0,F.jsxs)(`div`,{className:`card overflow-hidden`,children:[(0,F.jsx)(`div`,{className:`px-3 py-2`,style:{borderBottom:`1px solid var(--c-border)`},children:(0,F.jsxs)($,{children:[`MCP servers by project `,(0,F.jsxs)(`span`,{style:{color:`var(--c-text3)`},children:[`(`,t.projectMcps.length,`)`]})]})}),(0,F.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`text-[10px] uppercase tracking-wider`,style:{borderBottom:`1px solid var(--c-border)`,color:`var(--c-text3)`},children:[(0,F.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`project`}),(0,F.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`config`}),(0,F.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`servers`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`mcp calls`})]})}),(0,F.jsx)(`tbody`,{children:t.projectMcps.map(t=>t.configs.map((n,r)=>(0,F.jsxs)(`tr`,{className:`transition`,style:{borderBottom:`1px solid var(--c-border)`},onMouseEnter:e=>e.currentTarget.style.background=`var(--c-bg3)`,onMouseLeave:e=>e.currentTarget.style.background=`transparent`,children:[r===0?(0,F.jsx)(`td`,{className:`px-3 py-2`,rowSpan:t.configs.length,children:(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5 cursor-pointer hover:underline`,style:{color:`var(--c-accent)`},onClick:()=>e(`/projects/detail?folder=${encodeURIComponent(t.folder)}`),children:[(0,F.jsx)(Ur,{size:11}),(0,F.jsx)(`span`,{className:`font-medium truncate max-w-[200px]`,children:t.name})]})}):null,(0,F.jsx)(`td`,{className:`px-3 py-2`,children:(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(Gh,{source:n.editor,size:12}),(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`},children:n.file})]})}),(0,F.jsx)(`td`,{className:`px-3 py-2`,children:(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:n.serverNames.map(e=>(0,F.jsxs)(`span`,{className:`text-[11px] px-1.5 py-px`,style:{background:ee[e]?`rgba(99,102,241,0.12)`:`var(--c-bg3)`,color:ee[e]?`#818cf8`:`var(--c-text2)`},children:[(0,F.jsx)(oi,{size:8,className:`inline mr-0.5`}),e,ee[e]&&(0,F.jsx)(`span`,{className:`ml-1 opacity-60`,children:ee[e].reduce((e,t)=>e+t.count,0)})]},e))})}),r===0?(0,F.jsx)(`td`,{className:`px-3 py-2 text-right`,rowSpan:t.configs.length,children:t.mcpToolCalls>0?(0,F.jsx)(`span`,{className:`font-semibold`,style:{color:`var(--c-white)`},children:J(t.mcpToolCalls)}):(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:`—`})}):null]},`${t.folder}-${n.file}`)))})]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(`div`,{className:`flex gap-0.5`,children:te.map(e=>(0,F.jsxs)(`button`,{onClick:()=>c(e.id),className:`px-2.5 py-1 text-[12px] transition`,style:{background:s===e.id?`var(--c-card)`:`transparent`,color:s===e.id?`var(--c-white)`:`var(--c-text3)`,border:s===e.id?`1px solid var(--c-border)`:`1px solid transparent`},children:[e.label,` `,(0,F.jsx)(`span`,{className:`opacity-40 ml-0.5`,children:e.count})]},e.id))}),(0,F.jsx)(`div`,{className:`flex-1`}),s===`tools`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`select`,{value:l,onChange:e=>u(e.target.value),className:`px-2 py-1 text-[12px] outline-none`,style:{background:`var(--c-bg3)`,border:`1px solid var(--c-border)`,color:`var(--c-text)`},children:[(0,F.jsx)(`option`,{value:``,children:`All Projects`}),b.projects.map(e=>(0,F.jsx)(`option`,{value:e,children:e.split(`/`).pop()},e))]}),(0,F.jsxs)(`select`,{value:d,onChange:e=>f(e.target.value),className:`px-2 py-1 text-[12px] outline-none`,style:{background:`var(--c-bg3)`,border:`1px solid var(--c-border)`,color:`var(--c-text)`},children:[(0,F.jsx)(`option`,{value:``,children:`All Servers`}),b.hasBuiltIn&&(0,F.jsx)(`option`,{value:`__builtin__`,children:`built-in`}),b.servers.map(e=>(0,F.jsx)(`option`,{value:e,children:e},e))]})]}),(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(ui,{size:12,className:`absolute left-2.5 top-1/2 -translate-y-1/2`,style:{color:`var(--c-text3)`}}),(0,F.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),placeholder:`Search...`,className:`pl-7 pr-3 py-1 text-[12px] outline-none w-[180px]`,style:{background:`var(--c-bg3)`,border:`1px solid var(--c-border)`,color:`var(--c-text)`}})]})]}),s===`servers`&&(0,F.jsx)(`div`,{children:v.length===0?(0,F.jsxs)(`div`,{className:`text-center py-12 text-[12px]`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(fi,{size:24,className:`mx-auto mb-2 opacity-30`}),(0,F.jsx)(`div`,{children:`No MCP servers detected`}),(0,F.jsx)(`div`,{className:`text-[10px] mt-0.5 opacity-60`,children:`Configure MCP servers in your editors`})]}):Object.entries(w).map(([e,t])=>(0,F.jsxs)(`div`,{className:`mb-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1`,children:[(0,F.jsx)(Gh,{source:e,size:13}),(0,F.jsx)(`span`,{className:`text-[12px] font-semibold`,style:{color:`var(--c-white)`},children:q(e)}),(0,F.jsxs)(`span`,{className:`text-[11px]`,style:{color:`var(--c-text3)`},children:[`(`,t.length,`)`]})]}),(0,F.jsx)(`div`,{className:`space-y-1`,children:t.map(e=>(0,F.jsx)(_D,{server:e,matchedTools:ee[e.name]},`${e.name}-${e.editor}-${e.scope}`))})]},e))}),s===`tools`&&(0,F.jsxs)(`div`,{className:`card overflow-hidden`,children:[(0,F.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`text-[10px] uppercase tracking-wider`,style:{borderBottom:`1px solid var(--c-border)`,color:`var(--c-text3)`},children:[(0,F.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`tool`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`calls`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`sessions`}),(0,F.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`editors`}),(0,F.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`server`})]})}),(0,F.jsx)(`tbody`,{children:x.slice(0,100).map((e,t)=>{let n=y[e.name];return(0,F.jsxs)(`tr`,{className:`transition`,style:{borderBottom:`1px solid var(--c-border)`},onMouseEnter:e=>e.currentTarget.style.background=`var(--c-bg3)`,onMouseLeave:e=>e.currentTarget.style.background=`transparent`,children:[(0,F.jsx)(`td`,{className:`px-3 py-2`,children:(0,F.jsx)(`span`,{style:{fontFamily:hD,color:`var(--c-white)`},children:e.name})}),(0,F.jsx)(`td`,{className:`px-3 py-2 text-right`,children:(0,F.jsx)(`span`,{className:`font-semibold`,style:{color:`var(--c-white)`},children:J(e.count)})}),(0,F.jsx)(`td`,{className:`px-3 py-2 text-right`,style:{color:`var(--c-text2)`},children:e.sessionCount}),(0,F.jsx)(`td`,{className:`px-3 py-2`,children:(0,F.jsx)(`div`,{className:`flex items-center gap-1`,children:e.editors.map(e=>(0,F.jsx)(`span`,{className:`inline-flex items-center gap-0.5`,children:(0,F.jsx)(Gh,{source:e,size:12})},e))})}),(0,F.jsx)(`td`,{className:`px-3 py-2`,children:n?(0,F.jsxs)(`span`,{className:`text-[11px] px-1.5 py-px`,style:{background:`rgba(99,102,241,0.12)`,color:`#818cf8`},children:[(0,F.jsx)(oi,{size:9,className:`inline mr-0.5`}),n]}):(0,F.jsx)(`span`,{className:`text-[11px]`,style:{color:`var(--c-text2)`},children:`built-in`})})]},e.name)})})]}),x.length>100&&(0,F.jsxs)(`div`,{className:`px-3 py-1 text-[10px] text-center`,style:{color:`var(--c-text3)`,background:`var(--c-card)`},children:[`Showing 100 of `,x.length]})]}),s===`sessions`&&(0,F.jsxs)(`div`,{className:`card overflow-hidden`,children:[(0,F.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`text-[10px] uppercase tracking-wider`,style:{borderBottom:`1px solid var(--c-border)`,color:`var(--c-text3)`},children:[(0,F.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`session`}),(0,F.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`editor`}),(0,F.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`project`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`calls`}),(0,F.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`top tools`})]})}),(0,F.jsx)(`tbody`,{children:C.map((t,n)=>{let r=Object.entries(t.tools).sort((e,t)=>t[1]-e[1]).slice(0,3);return(0,F.jsxs)(`tr`,{className:`transition`,style:{borderBottom:`1px solid var(--c-border)`},onMouseEnter:e=>e.currentTarget.style.background=`var(--c-bg3)`,onMouseLeave:e=>e.currentTarget.style.background=`transparent`,children:[(0,F.jsx)(`td`,{className:`px-3 py-2 max-w-[220px] font-medium`,children:(0,F.jsx)(`span`,{className:`truncate block`,style:{color:`var(--c-white)`},children:t.name||(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`,fontStyle:`italic`},children:`Untitled`})})}),(0,F.jsx)(`td`,{className:`px-3 py-2`,children:(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(Gh,{source:t.source,size:12}),(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`},children:q(t.source)})]})}),(0,F.jsx)(`td`,{className:`px-3 py-2 truncate max-w-[160px]`,title:t.folder,children:t.folder?(0,F.jsx)(`span`,{className:`cursor-pointer hover:underline`,style:{color:`var(--c-accent)`},onClick:n=>{n.stopPropagation(),e(`/projects/detail?folder=${encodeURIComponent(t.folder)}`)},children:t.folder.split(/[/\\]/).pop()}):(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:`—`})}),(0,F.jsx)(`td`,{className:`px-3 py-2 text-right`,children:(0,F.jsx)(`span`,{className:`font-semibold`,style:{color:`var(--c-white)`},children:J(t.totalToolCalls)})}),(0,F.jsx)(`td`,{className:`px-3 py-2`,children:(0,F.jsx)(`div`,{className:`flex gap-0.5 flex-wrap`,children:r.map(([e,t])=>(0,F.jsxs)(`span`,{className:`text-[10px] px-1 py-px`,style:{background:`var(--c-bg3)`,color:`var(--c-text2)`,fontFamily:hD},children:[e,` `,(0,F.jsxs)(`span`,{style:{opacity:.5},children:[`×`,t]})]},e))})})]},t.composerId)})})]}),t.topSessions.length===0&&(0,F.jsx)(`div`,{className:`text-center py-8 text-[11px]`,style:{color:`var(--c-text3)`},children:`No sessions with tool calls`})]})]})}function yD({source:e,showLabel:t=!1,size:n=8}){return(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,F.jsx)(Gh,{source:e,size:n}),t&&(0,F.jsx)(`span`,{className:`text-[11px]`,style:{color:`var(--c-text)`},children:q(e)})]})}function bD(e){return e?new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):``}function xD({onSessionClick:e}){let[t,n]=(0,S.useState)([]),r=(0,S.useRef)(null);(0,S.useEffect)(()=>{let e=()=>{va({limit:80}).then(e=>{Array.isArray(e)&&n(e)}).catch(()=>{})};e();let t=setInterval(e,1e4);return()=>clearInterval(t)},[]);let i=Date.now(),a=[],o=null;for(let e of t){let t=i-e.lastUpdatedAt,n;n=t<3e5?`Just now`:t<36e5?`${Math.floor(t/6e4)} min ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:new Date(e.lastUpdatedAt).toLocaleDateString(),(!o||o.label!==n)&&(o={label:n,items:[]},a.push(o)),o.items.push(e)}return(0,F.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2.5 shrink-0`,style:{borderBottom:`1px solid var(--c-border)`},children:[(0,F.jsx)(ci,{size:12,style:{color:`#22c55e`}}),(0,F.jsx)(`span`,{className:`text-[12px] font-medium uppercase tracking-wider`,style:{color:`var(--c-text2)`},children:`Live Feed`}),(0,F.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full pulse-dot ml-auto`,style:{background:`#22c55e`}})]}),(0,F.jsxs)(`div`,{ref:r,className:`flex-1 overflow-y-auto scrollbar-thin`,children:[t.length===0&&(0,F.jsx)(`div`,{className:`text-[12px] py-8 text-center`,style:{color:`var(--c-text3)`},children:`No recent activity`}),a.map((t,n)=>(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`sticky top-0 px-3 py-1.5 text-[10px] font-medium uppercase tracking-wider`,style:{background:`var(--c-bg)`,color:`var(--c-text3)`,borderBottom:`1px solid var(--c-border)`},children:t.label}),t.items.map(t=>(0,F.jsxs)(`div`,{className:`px-3 py-2.5 cursor-pointer transition hover:bg-[var(--c-card)]`,style:{borderBottom:`1px solid var(--c-border)`},onClick:()=>e&&e(t.id,t.username),children:[(0,F.jsx)(`div`,{className:`text-[12px] font-medium truncate mb-1`,style:{color:`var(--c-white)`},children:t.name||`Untitled`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1`,children:[(0,F.jsx)(`span`,{className:`text-[10px] font-medium px-1 py-0.5 shrink-0 truncate max-w-[120px]`,style:{background:`rgba(99,102,241,0.12)`,color:`#818cf8`},title:t.username,children:t.username}),(0,F.jsx)(yD,{source:t.source,size:6}),(0,F.jsx)(`span`,{className:`text-[10px] truncate`,style:{color:`var(--c-text2)`},children:q(t.source)}),(0,F.jsx)(`span`,{className:`text-[10px] ml-auto shrink-0`,style:{color:`var(--c-text3)`},children:bD(t.lastUpdatedAt)})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px]`,style:{color:`var(--c-text3)`},children:[t.totalMessages>0&&(0,F.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,F.jsx)(ni,{size:8}),` `,t.totalMessages]}),t.folder&&(0,F.jsxs)(`span`,{className:`flex items-center gap-0.5 truncate`,children:[(0,F.jsx)(Ur,{size:8}),` `,t.folder.split(`/`).pop()]}),t.mode&&(0,F.jsx)(`span`,{className:`px-1 py-0`,style:{background:`rgba(168,85,247,0.1)`,color:`#a855f7`},children:t.mode}),t.models?.[0]&&(0,F.jsxs)(`span`,{className:`flex items-center gap-0.5 ml-auto truncate`,style:{color:`#818cf8`},children:[(0,F.jsx)(Nr,{size:8}),` `,t.models[0]]})]})]},`${t.id}-${t.username}`))]},n))]})]})}Lf.register(qf,wm,im,km,Nm,vp);var SD=`JetBrains Mono, monospace`,CD=[`#6366f1`,`#a78bfa`,`#818cf8`,`#c084fc`,`#e879f9`,`#f472b6`,`#fb7185`,`#f87171`,`#fbbf24`,`#34d399`],wD=[`#6366f1`,`#8b5cf6`,`#a855f7`,`#c084fc`,`#d8b4fe`,`#e879f9`,`#f472b6`,`#fb7185`];function TD({segments:e,height:t=6}){let n=e.reduce((e,t)=>e+t.value,0);return n===0?null:(0,F.jsx)(`div`,{className:`flex w-full rounded-full overflow-hidden`,style:{height:t},children:e.filter(e=>e.value>0).map((e,t)=>(0,F.jsx)(`div`,{title:`${e.label}: ${J(e.value)}`,className:`h-full transition-all`,style:{width:`${(e.value/n*100).toFixed(1)}%`,background:e.color}},t))})}function ED({userList:e,userColorMap:t,selectedUser:n}){let[r,i]=(0,S.useState)(new Set),a=dt(),{projectGroups:o,ungrouped:s}=(0,S.useMemo)(()=>{let t={},n=new Set;for(let r of e){let e=r.sharedProjects||[];if(e.length===0){n.add(r.username);continue}for(let i of e){let e=typeof i==`string`?i:i.name||i;t[e]||(t[e]=[]),t[e].push(r),n.add(r.username)}}let r=e.filter(e=>!(e.sharedProjects?.length>0));return{projectGroups:Object.entries(t).sort((e,t)=>t[1].length-e[1].length),ungrouped:r}},[e]),c=e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},l=({u:r})=>{e.indexOf(r);let i=t[r.username]||`#6366f1`,o=Object.entries(r.editors||{}).sort((e,t)=>t[1]-e[1]);return(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-1.5 cursor-pointer transition rounded-sm`,style:{background:n===r.username?`rgba(99,102,241,0.12)`:`transparent`},onMouseEnter:e=>{n!==r.username&&(e.currentTarget.style.background=`var(--c-bg3)`)},onMouseLeave:e=>{n!==r.username&&(e.currentTarget.style.background=`transparent`)},onClick:()=>a(`/relay/user/${r.username}`),children:[(0,F.jsx)(`div`,{className:`w-5 h-5 flex items-center justify-center text-[8px] font-bold rounded-sm flex-shrink-0`,style:{background:`${i}20`,color:i},children:r.username.charAt(0).toUpperCase()}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,F.jsx)(`div`,{className:`text-[11px] font-medium truncate`,style:{color:`var(--c-white)`},children:r.username}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1 text-[8px]`,style:{color:`var(--c-text3)`},children:[(0,F.jsxs)(`span`,{children:[r.sessions,`s`]}),(0,F.jsx)(`span`,{children:`·`}),(0,F.jsxs)(`span`,{children:[J(r.totalMessages),`m`]})]}),o.length>0&&(0,F.jsx)(`div`,{className:`flex items-center gap-1 mt-0.5`,children:o.slice(0,4).map(([e])=>(0,F.jsx)(Gh,{source:e,size:9},e))})]})]})};return(0,F.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2.5 shrink-0`,style:{borderBottom:`1px solid var(--c-border)`},children:[(0,F.jsx)(Di,{size:12,style:{color:`var(--c-accent)`}}),(0,F.jsx)(`span`,{className:`text-[12px] font-medium uppercase tracking-wider`,style:{color:`var(--c-text2)`},children:`Team`}),(0,F.jsx)(`span`,{className:`text-[10px] ml-auto`,style:{color:`var(--c-text3)`},children:e.length})]}),(0,F.jsxs)(`div`,{className:`flex-1 overflow-y-auto scrollbar-thin py-1`,children:[o.map(([e,t])=>{let n=r.has(e),i=e.split(`/`).pop();return(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-1.5 cursor-pointer transition`,onMouseEnter:e=>e.currentTarget.style.background=`var(--c-bg3)`,onMouseLeave:e=>e.currentTarget.style.background=`transparent`,onClick:()=>c(e),children:[n?(0,F.jsx)(wr,{size:10,style:{color:`var(--c-text3)`}}):(0,F.jsx)(Cr,{size:10,style:{color:`var(--c-text3)`}}),(0,F.jsx)(Ur,{size:10,style:{color:`#818cf8`}}),(0,F.jsx)(`span`,{className:`text-[11px] font-medium truncate flex-1`,style:{color:`var(--c-text2)`},title:e,children:i}),(0,F.jsx)(`span`,{className:`text-[8px]`,style:{color:`var(--c-text3)`},children:t.length})]}),!n&&(0,F.jsx)(`div`,{className:`pl-3`,children:t.map(t=>(0,F.jsx)(l,{u:t},`${e}-${t.username}`))})]},e)}),s.length>0&&(0,F.jsxs)(`div`,{children:[o.length>0&&(0,F.jsx)(`div`,{className:`px-2 py-1.5 text-[10px] uppercase tracking-wider`,style:{color:`var(--c-text3)`},children:`unassigned`}),(0,F.jsx)(`div`,{className:o.length>0?`pl-1`:``,children:s.map(e=>(0,F.jsx)(l,{u:e},e.username))})]}),e.length===0&&(0,F.jsx)(`div`,{className:`text-[11px] py-6 text-center`,style:{color:`var(--c-text3)`},children:`No team members yet`})]}),e.length>=2&&(0,F.jsx)(DD,{userList:e})]})}function DD({userList:e}){let[t,n]=(0,S.useState)(``),[r,i]=(0,S.useState)(``),[a,o]=(0,S.useState)(!1),[s,c]=(0,S.useState)(null),[l,u]=(0,S.useState)(!1);return(0,F.jsxs)(`div`,{className:`shrink-0 px-2 py-2`,style:{borderTop:`1px solid var(--c-border)`},children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 cursor-pointer text-[10px] uppercase tracking-wider`,style:{color:`var(--c-text3)`},onClick:()=>u(!l),children:[l?(0,F.jsx)(Cr,{size:9}):(0,F.jsx)(wr,{size:9}),(0,F.jsx)(ti,{size:9}),(0,F.jsx)(`span`,{children:`merge users`})]}),l&&(0,F.jsxs)(`div`,{className:`mt-2 space-y-1.5`,children:[(0,F.jsxs)(`select`,{value:t,onChange:e=>n(e.target.value),className:`w-full text-[11px] px-1.5 py-1 outline-none rounded-sm`,style:{background:`var(--c-bg3)`,color:`var(--c-text)`,border:`1px solid var(--c-border)`},children:[(0,F.jsx)(`option`,{value:``,children:`from...`}),e.filter(e=>e.username!==r).map(e=>(0,F.jsx)(`option`,{value:e.username,children:e.username},e.username))]}),(0,F.jsxs)(`select`,{value:r,onChange:e=>i(e.target.value),className:`w-full text-[11px] px-1.5 py-1 outline-none rounded-sm`,style:{background:`var(--c-bg3)`,color:`var(--c-text)`,border:`1px solid var(--c-border)`},children:[(0,F.jsx)(`option`,{value:``,children:`into...`}),e.filter(e=>e.username!==t).map(e=>(0,F.jsx)(`option`,{value:e.username,children:e.username},e.username))]}),(0,F.jsx)(`button`,{disabled:!t||!r||a,onClick:async()=>{if(confirm(`Merge "${t}" → "${r}"? Cannot undo.`)){o(!0),c(null);try{c(await ya(t,r)),n(``),i(``)}catch(e){c({error:e.message})}o(!1)}},className:`w-full text-[11px] px-2 py-1 font-medium transition rounded-sm`,style:{background:t&&r?`rgba(239,68,68,0.15)`:`var(--c-bg3)`,color:t&&r?`#ef4444`:`var(--c-text3)`,border:`1px solid var(--c-border)`,cursor:!t||!r||a?`not-allowed`:`pointer`,opacity:!t||!r||a?.5:1},children:a?`Merging...`:`Merge`}),s&&(0,F.jsx)(`div`,{className:`text-[10px]`,style:{color:s.error?`#ef4444`:`#22c55e`},children:s.error?`Error: ${s.error}`:`Merged!`})]})]})}function OD(){let e=dt(),[t,n]=(0,S.useState)(null),[r,i]=(0,S.useState)(``),[a,o]=(0,S.useState)(null),[s,c]=(0,S.useState)(!1),[l,u]=(0,S.useState)(null),[d,f]=(0,S.useState)(null),{dark:p}=tr(),m=p?`#888`:`#555`,h=p?`rgba(255,255,255,0.04)`:`rgba(0,0,0,0.06)`,g=p?`#555`:`#999`,_=p?`#888`:`#555`;(0,S.useEffect)(()=>{ha().then(n);let e=setInterval(()=>ha().then(n),15e3);return()=>clearInterval(e)},[]);let v=async e=>{if(e.preventDefault(),r.trim()){c(!0);try{o(await _a(r.trim(),{limit:30}))}catch{o([])}c(!1)}},y=t?.users||[],b=(0,S.useMemo)(()=>{let e={};return y.forEach((t,n)=>{e[t.username]=wD[n%wD.length]}),e},[y]);if(!t)return(0,F.jsx)(wa,{label:`Loading relay data...`});let x=t.editors||[],C=t.topModels||[],w=(t.totalInputTokens||0)+(t.totalOutputTokens||0),T=t.totalSessions>0?(t.totalMessages/t.totalSessions).toFixed(1):0,E=t.totalSessions>0?Math.round(w/t.totalSessions):0,D=y.length>0?Math.max(...y.map(e=>e.sessions)):1,O=(e,t)=>{u(e),f(t)},k=`calc(100vh - 42px)`;return(0,F.jsxs)(`div`,{className:`fade-in flex`,style:{height:k},children:[(0,F.jsx)(`div`,{className:`hidden lg:flex flex-col w-[250px] shrink-0 sticky top-[42px] self-start`,style:{height:k,borderRight:`1px solid var(--c-border)`,background:`var(--c-bg)`},children:(0,F.jsx)(ED,{userList:y,userColorMap:b,selectedUser:d,onUserClick:t=>e(`/relay/user/${t}`)})}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0 overflow-y-auto p-4 space-y-3`,children:[(0,F.jsx)($T,{icon:Di,title:`Team Relay`}),(0,F.jsxs)(`div`,{className:`grid gap-2`,style:{gridTemplateColumns:`repeat(auto-fit, minmax(90px, 1fr))`},children:[(0,F.jsx)(K,{label:`team members`,value:t.totalUsers}),(0,F.jsx)(K,{label:`sessions`,value:J(t.totalSessions),sub:`${T} msgs/session`}),(0,F.jsx)(K,{label:`active users`,value:t.activeUsers}),(0,F.jsx)(K,{label:`projects`,value:t.totalProjects}),(0,F.jsx)(K,{label:`messages`,value:J(t.totalMessages)}),(0,F.jsx)(K,{label:`tokens`,value:J(w),sub:`${J(E)}/session`})]}),w>0&&(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,F.jsx)($,{children:`team token usage`}),(0,F.jsxs)(`span`,{className:`text-[11px] font-bold`,style:{color:`var(--c-white)`},children:[J(w),` total`]})]}),(0,F.jsx)(TD,{height:10,segments:[{label:`Input`,value:t.totalInputTokens,color:`#6366f1`},{label:`Output`,value:t.totalOutputTokens,color:`#a78bfa`}]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-4 mt-1.5 text-[10px]`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`w-2 h-2 rounded-sm`,style:{background:`#6366f1`}}),` input `,J(t.totalInputTokens)]}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`w-2 h-2 rounded-sm`,style:{background:`#a78bfa`}}),` output `,J(t.totalOutputTokens)]})]}),y.length>1&&(0,F.jsxs)(`div`,{className:`mt-3 pt-2`,style:{borderTop:`1px solid var(--c-border)`},children:[(0,F.jsx)(`div`,{className:`text-[10px] mb-1.5`,style:{color:`var(--c-text3)`},children:`per-user contribution`}),(0,F.jsx)(TD,{height:8,segments:y.map(e=>({label:e.username,value:e.totalInputTokens+e.totalOutputTokens,color:b[e.username]}))}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-3 mt-1 text-[10px]`,children:y.map(e=>(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(`span`,{className:`w-2 h-2 rounded-sm`,style:{background:b[e.username]}}),e.username]},e.username))})]})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 xl:grid-cols-3 gap-3`,children:[x.length>0&&(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`editors`}),(0,F.jsx)(`div`,{style:{height:160},children:(0,F.jsx)(Th,{data:{labels:x.map(e=>q(e.source)),datasets:[{data:x.map(e=>e.count),backgroundColor:x.map(e=>Oh(e.source)),borderWidth:0}]},options:{responsive:!0,maintainAspectRatio:!1,cutout:`60%`,plugins:{legend:{position:`right`,labels:{color:m,font:{size:9,family:SD},usePointStyle:!0,pointStyle:`circle`,padding:6}},tooltip:{bodyFont:{family:SD,size:10},titleFont:{family:SD,size:10}}}}})})]}),C.length>0&&(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`models`}),(0,F.jsx)(`div`,{style:{height:160},children:(0,F.jsx)(Th,{data:{labels:C.slice(0,10).map(e=>e.name),datasets:[{data:C.slice(0,10).map(e=>e.count),backgroundColor:CD,borderWidth:0}]},options:{responsive:!0,maintainAspectRatio:!1,cutout:`60%`,plugins:{legend:{position:`right`,labels:{color:m,font:{size:8,family:SD},usePointStyle:!0,pointStyle:`circle`,padding:6}},tooltip:{bodyFont:{family:SD,size:10},titleFont:{family:SD,size:10}}}}})})]}),y.length>0&&(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`sessions per user`}),(0,F.jsx)(`div`,{style:{height:Math.max(120,y.length*28)},children:(0,F.jsx)(wh,{data:{labels:y.map(e=>e.username),datasets:[{data:y.map(e=>e.sessions),backgroundColor:y.map(e=>b[e.username]),borderRadius:2}]},options:{responsive:!0,maintainAspectRatio:!1,indexAxis:`y`,plugins:{legend:{display:!1},tooltip:{bodyFont:{family:SD,size:10},titleFont:{family:SD,size:10}}},scales:{x:{grid:{color:h},ticks:{color:g,font:{size:8,family:SD}},beginAtZero:!0},y:{grid:{display:!1},ticks:{color:_,font:{size:9,family:SD}}}}}})})]})]}),(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`search across team`}),(0,F.jsxs)(`form`,{onSubmit:v,className:`flex gap-2 mt-1`,children:[(0,F.jsxs)(`div`,{className:`relative flex-1`,children:[(0,F.jsx)(ui,{size:11,className:`absolute left-2.5 top-1/2 -translate-y-1/2`,style:{color:`var(--c-text3)`}}),(0,F.jsx)(`input`,{type:`text`,value:r,onChange:e=>i(e.target.value),placeholder:`Search messages, files, topics across all users...`,className:`w-full pl-7 pr-3 py-1.5 text-[12px] outline-none rounded-sm`,style:{background:`var(--c-bg3)`,color:`var(--c-white)`,border:`1px solid var(--c-border)`}})]}),(0,F.jsx)(`button`,{type:`submit`,disabled:s,className:`px-3 py-1.5 text-[11px] font-medium transition rounded-sm`,style:{background:`var(--c-card)`,border:`1px solid var(--c-border)`,color:`var(--c-white)`},children:s?`Searching...`:`Search`})]}),a&&(0,F.jsx)(`div`,{className:`mt-3 max-h-[300px] overflow-y-auto scrollbar-thin`,children:a.length===0?(0,F.jsx)(`div`,{className:`text-[12px] py-2`,style:{color:`var(--c-text3)`},children:`No results found`}):(0,F.jsx)(`table`,{className:`w-full text-[12px]`,children:(0,F.jsx)(`tbody`,{children:a.map((e,t)=>(0,F.jsxs)(`tr`,{className:`cursor-pointer transition`,style:{borderBottom:`1px solid var(--c-border)`},onMouseEnter:e=>e.currentTarget.style.background=`var(--c-bg3)`,onMouseLeave:e=>e.currentTarget.style.background=`transparent`,onClick:()=>{u(e.chatId),f(e.username)},children:[(0,F.jsx)(`td`,{className:`py-2 px-2 w-[80px]`,children:(0,F.jsx)(`span`,{className:`text-[10px] font-medium px-1.5 py-0.5`,style:{background:`rgba(99,102,241,0.15)`,color:`#818cf8`},children:e.username})}),(0,F.jsx)(`td`,{className:`py-2 px-2 w-[24px]`,children:(0,F.jsx)(Gh,{source:e.source,size:11})}),(0,F.jsxs)(`td`,{className:`py-2 px-2`,children:[(0,F.jsx)(`div`,{className:`text-[11px] truncate`,style:{color:`var(--c-text3)`},children:e.chatName}),(0,F.jsx)(`div`,{className:`text-[11px] line-clamp-1 mt-0.5`,style:{color:`var(--c-text)`},children:e.content})]}),(0,F.jsx)(`td`,{className:`py-2 px-2 text-[10px] whitespace-nowrap`,style:{color:`var(--c-text3)`},children:e.role})]},t))})})})]}),(0,F.jsx)($,{children:`team overview`}),(0,F.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-3`,children:y.map(t=>{let n=t.totalInputTokens+t.totalOutputTokens,r=b[t.username],i=Object.entries(t.editors||{}).sort((e,t)=>t[1]-e[1]);return(0,F.jsxs)(`div`,{className:`card p-3 cursor-pointer transition hover:opacity-90`,onClick:()=>e(`/relay/user/${t.username}`),children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,F.jsx)(`div`,{className:`w-7 h-7 flex items-center justify-center text-[12px] font-bold rounded-sm flex-shrink-0`,style:{background:`${r}20`,color:r},children:t.username.charAt(0).toUpperCase()}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,F.jsx)(`div`,{className:`text-[12px] font-bold truncate`,style:{color:`var(--c-white)`},children:t.username}),(0,F.jsx)(`div`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:t.lastActive?Ah(t.lastActive):`No activity`})]}),(0,F.jsx)(`div`,{className:`flex items-center gap-0.5 flex-shrink-0`,children:i.slice(0,3).map(([e])=>(0,F.jsx)(Gh,{source:e,size:11},e))})]}),(0,F.jsx)(`div`,{className:`grid grid-cols-4 gap-1 text-center mb-2`,children:[[t.sessions,`sessions`],[J(t.totalMessages),`messages`],[t.projects,`projects`],[J(n),`tokens`]].map(([e,t])=>(0,F.jsxs)(`div`,{className:`p-1 rounded-sm`,style:{background:`var(--c-code-bg)`},children:[(0,F.jsx)(`div`,{className:`text-[11px] font-bold`,style:{color:`var(--c-white)`},children:e}),(0,F.jsx)(`div`,{className:`text-[7px]`,style:{color:`var(--c-text3)`},children:t})]},t))}),(0,F.jsx)(`div`,{className:`h-1.5 rounded-full overflow-hidden`,style:{background:`var(--c-code-bg)`},children:(0,F.jsx)(`div`,{className:`h-full rounded-full`,style:{width:`${(t.sessions/D*100).toFixed(0)}%`,background:r}})}),t.topModels&&t.topModels.length>0&&(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1.5`,children:t.topModels.slice(0,2).map(e=>(0,F.jsx)(`span`,{className:`text-[8px] px-1.5 py-0.5 rounded-sm`,style:{background:`rgba(99,102,241,0.08)`,color:`#818cf8`},children:e.name},e.name))})]},t.username)})}),y.length===0&&(0,F.jsxs)(`div`,{className:`card p-8 text-center`,children:[(0,F.jsx)(Di,{size:32,className:`mx-auto mb-3`,style:{color:`var(--c-text3)`}}),(0,F.jsx)(`div`,{className:`text-[12px] font-medium mb-1`,style:{color:`var(--c-white)`},children:`No team members yet`}),(0,F.jsx)(`div`,{className:`text-[11px]`,style:{color:`var(--c-text3)`},children:`Share the join command with your team to start collecting data`})]})]}),(0,F.jsx)(`div`,{className:`hidden xl:flex flex-col w-[300px] shrink-0 sticky top-[42px] self-start`,style:{height:k,borderLeft:`1px solid var(--c-border)`,background:`var(--c-bg)`},children:(0,F.jsx)(xD,{onSessionClick:O})}),(0,F.jsx)(XT,{chatId:l,onClose:()=>{u(null),f(null)},fetchFn:d?e=>ba(e,d):void 0,username:d,extraHeader:d?(0,F.jsx)(`span`,{className:`text-[11px] font-medium px-1.5 py-0.5 shrink-0`,style:{background:`rgba(99,102,241,0.15)`,color:`#818cf8`},children:d}):null})]})}Lf.register(qf,wm,im,km,Nm,vp);var kD=`JetBrains Mono, monospace`,AD=[`#6366f1`,`#a78bfa`,`#818cf8`,`#c084fc`,`#e879f9`,`#f472b6`,`#fb7185`,`#f87171`,`#fbbf24`,`#34d399`];function jD({segments:e,height:t=6}){let n=e.reduce((e,t)=>e+t.value,0);return n===0?null:(0,F.jsx)(`div`,{className:`flex w-full rounded-full overflow-hidden`,style:{height:t},children:e.filter(e=>e.value>0).map((e,t)=>(0,F.jsx)(`div`,{title:`${e.label}: ${J(e.value)}`,className:`h-full transition-all`,style:{width:`${(e.value/n*100).toFixed(1)}%`,background:e.color}},t))})}function MD({sessions:e,projects:t,selectedChat:n,onSelectChat:r}){let[i,a]=(0,S.useState)(new Set),o=e=>{a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},s=(0,S.useMemo)(()=>{let t={},n=[];for(let r of e)r.folder?(t[r.folder]||(t[r.folder]=[]),t[r.folder].push(r)):n.push(r);return{sorted:Object.entries(t).sort((e,t)=>t[1].length-e[1].length),noProject:n}},[e]),c=({s:e})=>(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-1.5 cursor-pointer transition rounded-sm`,style:{background:n===e.id?`rgba(99,102,241,0.12)`:`transparent`},onMouseEnter:t=>{n!==e.id&&(t.currentTarget.style.background=`var(--c-bg3)`)},onMouseLeave:t=>{n!==e.id&&(t.currentTarget.style.background=`transparent`)},onClick:()=>r(e.id),children:[(0,F.jsx)(Gh,{source:e.source,size:10}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,F.jsx)(`div`,{className:`text-[11px] font-medium truncate`,style:{color:`var(--c-white)`},children:e.name||`Untitled`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1 text-[8px]`,style:{color:`var(--c-text3)`},children:[e.totalMessages>0&&(0,F.jsxs)(`span`,{children:[e.totalMessages,`m`]}),e.totalMessages>0&&e.lastUpdatedAt&&(0,F.jsx)(`span`,{children:`·`}),e.lastUpdatedAt&&(0,F.jsx)(`span`,{children:Ah(e.lastUpdatedAt)})]})]})]});return(0,F.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2.5 shrink-0`,style:{borderBottom:`1px solid var(--c-border)`},children:[(0,F.jsx)(qr,{size:12,style:{color:`var(--c-accent)`}}),(0,F.jsx)(`span`,{className:`text-[12px] font-medium uppercase tracking-wider`,style:{color:`var(--c-text2)`},children:`Sessions`}),(0,F.jsx)(`span`,{className:`text-[10px] ml-auto`,style:{color:`var(--c-text3)`},children:e.length})]}),(0,F.jsxs)(`div`,{className:`flex-1 overflow-y-auto scrollbar-thin py-1`,children:[s.sorted.map(([e,t])=>{let n=i.has(e),r=e.split(`/`).pop();return(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-1.5 cursor-pointer transition`,onMouseEnter:e=>e.currentTarget.style.background=`var(--c-bg3)`,onMouseLeave:e=>e.currentTarget.style.background=`transparent`,onClick:()=>o(e),children:[n?(0,F.jsx)(wr,{size:10,style:{color:`var(--c-text3)`}}):(0,F.jsx)(Cr,{size:10,style:{color:`var(--c-text3)`}}),(0,F.jsx)(Ur,{size:10,style:{color:`#818cf8`}}),(0,F.jsx)(`span`,{className:`text-[11px] font-medium truncate flex-1`,style:{color:`var(--c-text2)`},title:e,children:r}),(0,F.jsx)(`span`,{className:`text-[8px]`,style:{color:`var(--c-text3)`},children:t.length})]}),!n&&(0,F.jsx)(`div`,{className:`pl-3`,children:t.map(e=>(0,F.jsx)(c,{s:e},e.id))})]},e)}),s.noProject.length>0&&(0,F.jsxs)(`div`,{children:[s.sorted.length>0&&(0,F.jsx)(`div`,{className:`px-2 py-1.5 text-[10px] uppercase tracking-wider`,style:{color:`var(--c-text3)`},children:`no project`}),(0,F.jsx)(`div`,{className:s.sorted.length>0?`pl-1`:``,children:s.noProject.map(e=>(0,F.jsx)(c,{s:e},e.id))})]})]})]})}function ND(){let{username:e}=pt(),t=dt(),[n,r]=(0,S.useState)(null),[i,a]=(0,S.useState)(null),{dark:o}=tr(),s=o?`#888`:`#555`,c=o?`rgba(255,255,255,0.04)`:`rgba(0,0,0,0.06)`,l=o?`#555`:`#999`;(0,S.useEffect)(()=>{e&&ga(e,{limit:200}).then(r)},[e]);let u=(0,S.useCallback)(t=>ba(t,e),[e]);if(!n)return(0,F.jsx)(`div`,{className:`text-sm py-12 text-center`,style:{color:`var(--c-text2)`},children:`loading...`});let d=n.length,f=n.reduce((e,t)=>e+(t.totalMessages||0),0),p=n.reduce((e,t)=>e+(t.totalInputTokens||0),0),m=n.reduce((e,t)=>e+(t.totalOutputTokens||0),0),h=p+m,g=d>0?(f/d).toFixed(1):0,_=d>0?Math.round(h/d):0,v={};for(let e of n)e.source&&(v[e.source]=(v[e.source]||0)+1);let y=Object.entries(v).sort((e,t)=>t[1]-e[1]),b={};for(let e of n)e.folder&&(b[e.folder]||(b[e.folder]={count:0,lastActive:0,messages:0,tokens:0}),b[e.folder].count++,b[e.folder].messages+=e.totalMessages||0,b[e.folder].tokens+=(e.totalInputTokens||0)+(e.totalOutputTokens||0),e.lastUpdatedAt>b[e.folder].lastActive&&(b[e.folder].lastActive=e.lastUpdatedAt));let x=Object.entries(b).sort((e,t)=>t[1].count-e[1].count),C=x.length>0?Math.max(...x.map(([,e])=>e.count)):1,w={};for(let e of n)if(e.models)for(let t of e.models)w[t]=(w[t]||0)+1;let T=Object.entries(w).sort((e,t)=>t[1]-e[1]).slice(0,10),E={};for(let e of n)if(e.toolCalls)for(let t of e.toolCalls)E[t]=(E[t]||0)+1;let D=Object.entries(E).sort((e,t)=>t[1]-e[1]).slice(0,15),O={};for(let e of n){let t=new Date(e.lastUpdatedAt||e.createdAt).toISOString().slice(0,10);O[t]=(O[t]||0)+1}let k=Object.entries(O).sort((e,t)=>e[0].localeCompare(t[0])).slice(-14),A=e=>{a(e)},j=`calc(100vh - 42px)`;return(0,F.jsxs)(`div`,{className:`fade-in flex`,style:{height:j},children:[(0,F.jsx)(`div`,{className:`hidden lg:flex flex-col w-[250px] shrink-0 sticky top-[42px] self-start`,style:{height:j,borderRight:`1px solid var(--c-border)`,background:`var(--c-bg)`},children:(0,F.jsx)(MD,{sessions:n,projects:x,selectedChat:i,onSelectChat:a})}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0 overflow-y-auto p-4 space-y-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(`button`,{onClick:()=>t(`/`),className:`p-1.5 transition hover:bg-[var(--c-card)] rounded-sm`,style:{border:`1px solid var(--c-border)`,color:`var(--c-text2)`},children:(0,F.jsx)(dr,{size:14})}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,F.jsx)(`div`,{className:`w-9 h-9 flex items-center justify-center text-[14px] font-bold rounded-sm`,style:{background:`rgba(99,102,241,0.15)`,color:`#818cf8`},children:e.charAt(0).toUpperCase()}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`text-[14px] font-bold`,style:{color:`var(--c-white)`},children:e}),(0,F.jsx)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:y.map(([e])=>(0,F.jsx)(Gh,{source:e,size:11},e))})]})]})]}),(0,F.jsxs)(`div`,{className:`grid gap-2`,style:{gridTemplateColumns:`repeat(auto-fit, minmax(90px, 1fr))`},children:[(0,F.jsx)(K,{label:`sessions`,value:d}),(0,F.jsx)(K,{label:`messages`,value:J(f),sub:`${g}/session`}),(0,F.jsx)(K,{label:`editors`,value:y.length}),(0,F.jsx)(K,{label:`projects`,value:x.length}),(0,F.jsx)(K,{label:`tokens`,value:J(h),sub:`${J(_)}/session`}),(0,F.jsx)(K,{label:`models`,value:T.length})]}),h>0&&(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,F.jsx)($,{children:`token usage`}),(0,F.jsxs)(`span`,{className:`text-[11px] font-bold`,style:{color:`var(--c-white)`},children:[J(h),` total`]})]}),(0,F.jsx)(jD,{height:10,segments:[{label:`Input`,value:p,color:`#6366f1`},{label:`Output`,value:m,color:`#a78bfa`}]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-4 mt-1.5 text-[10px]`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`w-2 h-2 rounded-sm`,style:{background:`#6366f1`}}),` input `,J(p)]}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`w-2 h-2 rounded-sm`,style:{background:`#a78bfa`}}),` output `,J(m)]})]})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 xl:grid-cols-2 gap-3`,children:[y.length>0&&(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`editors`}),(0,F.jsx)(`div`,{style:{height:160},children:(0,F.jsx)(Th,{data:{labels:y.map(([e])=>q(e)),datasets:[{data:y.map(([,e])=>e),backgroundColor:y.map(([e])=>Oh(e)),borderWidth:0}]},options:{responsive:!0,maintainAspectRatio:!1,cutout:`60%`,plugins:{legend:{position:`right`,labels:{color:s,font:{size:9,family:kD},usePointStyle:!0,pointStyle:`circle`,padding:6}},tooltip:{bodyFont:{family:kD,size:10},titleFont:{family:kD,size:10}}}}})})]}),T.length>0&&(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`models`}),(0,F.jsx)(`div`,{style:{height:160},children:(0,F.jsx)(Th,{data:{labels:T.map(([e])=>e),datasets:[{data:T.map(([,e])=>e),backgroundColor:AD,borderWidth:0}]},options:{responsive:!0,maintainAspectRatio:!1,cutout:`60%`,plugins:{legend:{position:`right`,labels:{color:s,font:{size:8,family:kD},usePointStyle:!0,pointStyle:`circle`,padding:6}},tooltip:{bodyFont:{family:kD,size:10},titleFont:{family:kD,size:10}}}}})})]})]}),k.length>1&&(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`daily activity (last 14 days)`}),(0,F.jsx)(`div`,{style:{height:120},children:(0,F.jsx)(wh,{data:{labels:k.map(([e])=>e.slice(5)),datasets:[{data:k.map(([,e])=>e),backgroundColor:`#6366f1`,borderRadius:2}]},options:{responsive:!0,maintainAspectRatio:!1,plugins:{legend:{display:!1},tooltip:{bodyFont:{family:kD,size:10},titleFont:{family:kD,size:10}}},scales:{x:{grid:{display:!1},ticks:{color:l,font:{size:8,family:kD}}},y:{grid:{color:c},ticks:{color:l,font:{size:8,family:kD},stepSize:1},beginAtZero:!0}}}})})]}),x.length>0&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)($,{children:`projects`}),(0,F.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-2 mt-2`,children:x.map(([e,t])=>(0,F.jsxs)(`div`,{className:`card px-3 py-2.5`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,F.jsx)(Ur,{size:11,style:{color:`#818cf8`}}),(0,F.jsx)(`span`,{className:`text-[12px] font-medium truncate`,style:{color:`var(--c-white)`},children:e.split(`/`).pop()})]}),(0,F.jsx)(`div`,{className:`text-[8px] truncate mb-2`,style:{color:`var(--c-text3)`},children:e}),(0,F.jsxs)(`div`,{className:`grid grid-cols-3 gap-1 text-center mb-1.5`,children:[(0,F.jsxs)(`div`,{className:`p-1 rounded-sm`,style:{background:`var(--c-code-bg)`},children:[(0,F.jsx)(`div`,{className:`text-[11px] font-bold`,style:{color:`var(--c-white)`},children:t.count}),(0,F.jsx)(`div`,{className:`text-[7px]`,style:{color:`var(--c-text3)`},children:`sessions`})]}),(0,F.jsxs)(`div`,{className:`p-1 rounded-sm`,style:{background:`var(--c-code-bg)`},children:[(0,F.jsx)(`div`,{className:`text-[11px] font-bold`,style:{color:`var(--c-white)`},children:J(t.messages)}),(0,F.jsx)(`div`,{className:`text-[7px]`,style:{color:`var(--c-text3)`},children:`messages`})]}),(0,F.jsxs)(`div`,{className:`p-1 rounded-sm`,style:{background:`var(--c-code-bg)`},children:[(0,F.jsx)(`div`,{className:`text-[11px] font-bold`,style:{color:`var(--c-white)`},children:J(t.tokens)}),(0,F.jsx)(`div`,{className:`text-[7px]`,style:{color:`var(--c-text3)`},children:`tokens`})]})]}),(0,F.jsx)(`div`,{className:`h-1.5 rounded-full overflow-hidden`,style:{background:`var(--c-code-bg)`},children:(0,F.jsx)(`div`,{className:`h-full rounded-full`,style:{width:`${(t.count/C*100).toFixed(0)}%`,background:`#6366f1`}})}),(0,F.jsx)(`div`,{className:`text-[8px] mt-1`,style:{color:`var(--c-text3)`},children:Ah(t.lastActive)})]},e))})]}),D.length>0&&(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`top tools`}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-1`,children:D.map(([e,t])=>(0,F.jsxs)(`span`,{className:`text-[10px] px-2 py-1 rounded-sm`,style:{background:`var(--c-code-bg)`,color:`var(--c-text2)`},children:[e,` `,(0,F.jsxs)(`span`,{style:{color:`var(--c-text3)`},children:[`×`,t]})]},e))})]}),(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`recent sessions`}),(0,F.jsx)(`div`,{className:`max-h-[400px] overflow-y-auto scrollbar-thin`,children:(0,F.jsx)(`table`,{className:`w-full text-[12px]`,children:(0,F.jsx)(`tbody`,{children:n.slice(0,50).map(e=>(0,F.jsxs)(`tr`,{className:`cursor-pointer transition`,style:{borderBottom:`1px solid var(--c-border)`},onMouseEnter:e=>e.currentTarget.style.background=`var(--c-bg3)`,onMouseLeave:e=>e.currentTarget.style.background=`transparent`,onClick:()=>a(e.id),children:[(0,F.jsx)(`td`,{className:`py-2 px-2 w-[24px]`,children:(0,F.jsx)(Gh,{source:e.source,size:11})}),(0,F.jsxs)(`td`,{className:`py-2 px-2`,children:[(0,F.jsx)(`div`,{className:`text-[11px] font-medium truncate`,style:{color:`var(--c-white)`},children:e.name||`Untitled`}),(0,F.jsx)(`div`,{className:`text-[10px] truncate`,style:{color:`var(--c-text3)`},children:e.folder?e.folder.split(`/`).pop():``})]}),(0,F.jsx)(`td`,{className:`py-2 px-2 text-[10px] whitespace-nowrap`,style:{color:`var(--c-text3)`},children:e.totalMessages>0&&(0,F.jsxs)(`span`,{children:[e.totalMessages,`m`]})}),(0,F.jsx)(`td`,{className:`py-2 px-2`,children:e.mode&&(0,F.jsx)(`span`,{className:`text-[8px] px-1.5 py-0.5 rounded-sm`,style:{background:`rgba(168,85,247,0.1)`,color:`#a855f7`},children:e.mode})}),(0,F.jsx)(`td`,{className:`py-2 px-2 text-[10px] whitespace-nowrap text-right`,style:{color:`var(--c-text3)`},children:Ah(e.lastUpdatedAt)})]},e.id))})})})]})]}),(0,F.jsx)(`div`,{className:`hidden xl:flex flex-col w-[300px] shrink-0 sticky top-[42px] self-start`,style:{height:j,borderLeft:`1px solid var(--c-border)`,background:`var(--c-bg)`},children:(0,F.jsx)(xD,{onSessionClick:A})}),(0,F.jsx)(XT,{chatId:i,onClose:()=>a(null),fetchFn:u,username:e,extraHeader:(0,F.jsx)(`span`,{className:`text-[11px] font-medium px-1.5 py-0.5 shrink-0`,style:{background:`rgba(99,102,241,0.15)`,color:`#818cf8`},children:e})})]})}Lf.register(qf,wm,im,km,Nm,vp);var PD=`JetBrains Mono, monospace`;function FD(e){if(!e)return`—`;let t=Date.now()-e,n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function ID(e){return e===`completed`?`#22c55e`:e===`executing`?`#f59e0b`:`var(--c-text3)`}function LD({value:e,total:t,color:n=`#6366f1`}){return(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`div`,{className:`flex-1 h-1 rounded-full overflow-hidden`,style:{background:`var(--c-bg3)`},children:(0,F.jsx)(`div`,{className:`h-full rounded-full transition-all`,style:{width:`${t>0?Math.round(e/t*100):0}%`,background:n}})}),(0,F.jsxs)(`span`,{className:`text-[10px] tabular-nums`,style:{color:`var(--c-text3)`,fontFamily:PD,minWidth:36},children:[e,`/`,t]})]})}function RD({title:e,subtitle:t,content:n,loading:r,onClose:i}){let a=(0,S.useRef)(null);return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`fixed inset-0 z-40 transition-opacity`,style:{background:`rgba(0,0,0,0.3)`},onClick:i}),(0,F.jsxs)(`div`,{className:`fixed top-0 right-0 bottom-0 z-50 flex flex-col shadow-2xl sidebar-slide-in cursor-default`,style:{width:`min(620px, 92vw)`,background:`var(--c-bg)`,borderLeft:`1px solid var(--c-border)`},children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3 shrink-0`,style:{borderBottom:`1px solid var(--c-border)`},children:[(0,F.jsx)(`button`,{onClick:i,className:`p-1 rounded transition hover:bg-[var(--c-bg3)]`,style:{color:`var(--c-text2)`},children:(0,F.jsx)(ki,{size:14})}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,F.jsx)(`div`,{className:`text-[13px] font-semibold`,style:{color:`var(--c-white)`},children:e}),t&&(0,F.jsx)(`div`,{className:`text-[11px] capitalize`,style:{color:`var(--c-text2)`,fontFamily:PD},children:t})]})]}),(0,F.jsxs)(`div`,{ref:a,className:`flex-1 overflow-y-auto scrollbar-thin px-4 py-3`,children:[r&&(0,F.jsx)(`div`,{className:`text-[12px] py-12 text-center`,style:{color:`var(--c-text3)`},children:`Loading…`}),!r&&n===null&&(0,F.jsx)(`div`,{className:`text-[12px] py-12 text-center`,style:{color:`var(--c-text3)`},children:`File not found.`}),!r&&n!==null&&(0,F.jsx)(`pre`,{className:`text-[11px] leading-relaxed whitespace-pre-wrap break-words`,style:{color:`var(--c-text)`,fontFamily:PD},children:n})]})]})]})}var zD={mode:`Mode`,model_profile:`Model profile`,granularity:`Granularity`,parallelization:`Parallelization`,commit_docs:`Commit docs`},BD={research:`Research`,plan_check:`Plan check`,verifier:`Verifier`,nyquist_validation:`Nyquist`,auto_advance:`Auto advance`,ui_phase:`UI phase`,skip_discuss:`Skip discuss`};function VD({folder:e,anchor:t,onClose:n}){let[r,i]=(0,S.useState)(void 0),a=(0,S.useRef)(null);(0,S.useEffect)(()=>{da(e).then(i).catch(()=>i(null))},[e]),(0,S.useEffect)(()=>{function e(e){a.current&&!a.current.contains(e.target)&&n()}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[n]);let o=t?t.bottom+6:0,s=t?window.innerWidth-t.right:0;function c(e){return e===!0?(0,F.jsx)(`span`,{style:{color:`#22c55e`},children:`on`}):e===!1?(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:`off`}):(0,F.jsx)(`span`,{style:{color:`var(--c-white)`},children:String(e)})}return(0,F.jsxs)(`div`,{ref:a,className:`p-3 shadow-xl text-[11px]`,style:{position:`fixed`,top:o,right:s,zIndex:9999,width:240,background:`var(--c-bg)`,border:`1px solid var(--c-border)`,boxShadow:`0 8px 32px rgba(0,0,0,0.4)`},onClick:e=>e.stopPropagation(),children:[r===void 0&&(0,F.jsx)(`div`,{style:{color:`var(--c-text3)`},children:`Loading…`}),r===null&&(0,F.jsx)(`div`,{style:{color:`var(--c-text3)`},children:`No config.json found.`}),r&&(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(`div`,{className:`space-y-1`,children:Object.entries(zD).map(([e,t])=>e in r?(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`},children:t}),c(r[e])]},e):null)}),r.workflow&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`border-t pt-2`,style:{borderColor:`var(--c-border)`,color:`var(--c-text3)`},children:`workflow`}),(0,F.jsx)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1`,children:Object.entries(BD).map(([e,t])=>e in r.workflow?(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-1`,children:[(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`},children:t}),c(r.workflow[e])]},e):null)})]})]})]})}function HD({phase:e,tokenData:t,onOpenFile:n}){let r=e.total_tasks??0,i=e.completed_tasks??0,a=!!e.has_plan,o=!!e.has_research,s=!!e.has_verification,c=e.status??`planned`;return(0,F.jsxs)(`div`,{className:`flex items-center px-3 py-2 border-b text-[12px] hover:bg-[var(--c-bg3)] transition`,style:{borderColor:`var(--c-border)`,gap:0},children:[(0,F.jsx)(`div`,{style:{width:28,flexShrink:0},children:(0,F.jsx)(c===`completed`?Dr:c===`executing`?$r:kr,{size:12,style:{color:ID(c)},className:c===`executing`?`animate-spin`:``})}),(0,F.jsx)(`div`,{style:{width:32,flexShrink:0},children:(0,F.jsx)(`span`,{className:`text-[10px] font-bold tabular-nums`,style:{color:`var(--c-text3)`,fontFamily:PD},children:e.phase_number??`?`})}),(0,F.jsx)(`div`,{className:`flex-1 min-w-0 pr-3`,children:(0,F.jsx)(`span`,{className:`block truncate capitalize text-[12px]`,style:{color:`var(--c-white)`},children:e.phase_name})}),(0,F.jsx)(`div`,{style:{width:100,flexShrink:0,paddingRight:12},children:r>0?(0,F.jsx)(LD,{value:i,total:r,color:ID(c)}):null}),(0,F.jsxs)(`div`,{style:{width:88,flexShrink:0},className:`flex items-center gap-1`,children:[a&&(0,F.jsxs)(`button`,{onClick:()=>n(e,`plan`),className:`flex items-center gap-1 px-1.5 py-px text-[10px] transition hover:opacity-80 cursor-pointer`,style:{background:`rgba(99,102,241,0.12)`,color:`#818cf8`},title:`View PLAN.md`,children:[(0,F.jsx)(Br,{size:9}),`plan`]}),o&&(0,F.jsx)(`button`,{onClick:()=>n(e,`research`),className:`px-1 py-px transition hover:opacity-80 cursor-pointer`,style:{background:`rgba(245,158,11,0.1)`,color:`#f59e0b`},title:`View RESEARCH.md`,children:(0,F.jsx)(mr,{size:9})}),s&&(0,F.jsx)(`button`,{onClick:()=>n(e,`verification`),className:`px-1 py-px transition hover:opacity-80 cursor-pointer`,style:{background:`rgba(34,197,94,0.1)`,color:`#22c55e`},title:`View VERIFICATION.md`,children:(0,F.jsx)(hi,{size:9})})]}),(0,F.jsx)(`div`,{style:{width:64,flexShrink:0,textAlign:`right`},children:t&&t.cost>0?(0,F.jsx)(`span`,{className:`text-[10px] tabular-nums`,style:{color:`var(--c-text2)`,fontFamily:PD},children:kh(t.cost)}):null}),(0,F.jsx)(`div`,{style:{width:56,flexShrink:0,textAlign:`right`},children:(0,F.jsx)(`span`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:FD(e.last_modified)})})]})}function UD(e){return e.total_phases===0?`var(--c-border)`:e.completed_phases===e.total_phases?`#22c55e`:e.completed_phases>0?`#f59e0b`:`var(--c-border)`}function WD({project:e,isExpanded:t,onToggle:n,onOpenFile:r,onOpenConfig:i,onOpenState:a}){let[o,s]=(0,S.useState)(null),[c,l]=(0,S.useState)(null),u=(0,S.useRef)(null),d=(0,S.useRef)(null),f=e.total_phases>0?Math.round(e.completed_phases/e.total_phases*100):0,p=e.total_phases-e.completed_phases;return(0,S.useEffect)(()=>{t&&o===null&&(ca(e.folder).then(s),fa(e.folder).then(e=>{let t={};for(let n of e)t[n.id]=n;l(t)}).catch(()=>l({})))},[t,o,e.folder]),(0,F.jsxs)(`div`,{className:`card overflow-hidden`,style:{borderLeft:`2px solid ${UD(e)}`},children:[(0,F.jsxs)(`div`,{className:`flex items-center w-full px-3 py-3`,style:{gap:0},children:[(0,F.jsx)(`button`,{onClick:n,className:`flex items-center justify-center hover:bg-[var(--c-bg3)] transition rounded cursor-pointer`,style:{width:24,height:24,flexShrink:0,color:`var(--c-text3)`},children:t?(0,F.jsx)(Cr,{size:13}):(0,F.jsx)(wr,{size:13})}),(0,F.jsxs)(`button`,{onClick:n,className:`flex-1 min-w-0 text-left px-2 cursor-pointer`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`text-[13px] font-semibold truncate`,style:{color:`var(--c-white)`},children:e.name}),e.milestone&&(0,F.jsx)(`span`,{className:`text-[10px] px-1.5 py-px shrink-0`,style:{background:`rgba(99,102,241,0.12)`,color:`#818cf8`},children:e.milestone})]}),(0,F.jsx)(`div`,{className:`text-[10px] truncate mt-0.5`,style:{color:`var(--c-text3)`,fontFamily:PD},children:e.folder})]}),(0,F.jsx)(`div`,{style:{width:36,flexShrink:0,textAlign:`right`},children:(0,F.jsxs)(`span`,{className:`text-[11px] font-bold tabular-nums`,style:{color:f===100?`#22c55e`:f>0?`#f59e0b`:`var(--c-text3)`,fontFamily:PD},children:[f,`%`]})}),(0,F.jsx)(`div`,{style:{width:112,flexShrink:0,padding:`0 10px`},children:(0,F.jsx)(LD,{value:e.completed_phases,total:e.total_phases,color:f===100?`#22c55e`:`#6366f1`})}),(0,F.jsxs)(`div`,{style:{width:80,flexShrink:0},className:`flex items-center gap-1`,children:[e.completed_phases>0&&(0,F.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] px-1.5 py-px`,style:{background:`rgba(34,197,94,0.08)`,color:`#22c55e`},children:[(0,F.jsx)(Dr,{size:9}),` `,e.completed_phases]}),p>0&&(0,F.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] px-1.5 py-px`,style:{background:`rgba(255,255,255,0.04)`,color:`var(--c-text3)`},children:[(0,F.jsx)(kr,{size:9}),` `,p]})]}),(0,F.jsxs)(`div`,{style:{width:52,flexShrink:0},className:`flex items-center gap-2`,children:[e.todos>0&&(0,F.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px]`,style:{color:`var(--c-text3)`},title:`Todos / Seeds`,children:[(0,F.jsx)(Zr,{size:10}),` `,e.todos]}),e.notes>0&&(0,F.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px]`,style:{color:`var(--c-text3)`},title:`Quick tasks`,children:[(0,F.jsx)(vi,{size:10}),` `,e.notes]})]}),(0,F.jsx)(`div`,{style:{width:60,flexShrink:0,textAlign:`right`},children:(0,F.jsx)(`span`,{className:`text-[11px] tabular-nums`,style:{color:e.total_cost>0?`#a78bfa`:`var(--c-text3)`,fontFamily:PD},children:e.total_cost>0?kh(e.total_cost):`—`})}),(0,F.jsx)(`div`,{style:{width:56,flexShrink:0,textAlign:`right`},children:(0,F.jsx)(`span`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:FD(e.last_modified)})}),(0,F.jsxs)(`div`,{style:{width:52,flexShrink:0},className:`flex items-center justify-end gap-0.5`,onClick:e=>e.stopPropagation(),children:[(0,F.jsx)(`button`,{ref:d,onClick:()=>a(e.folder,e.name),className:`p-1 rounded transition hover:bg-[var(--c-bg3)] cursor-pointer`,style:{color:`var(--c-text3)`},title:`View STATE.md`,children:(0,F.jsx)(Yr,{size:13})}),(0,F.jsx)(`button`,{ref:u,onClick:()=>i(e.folder,u.current?.getBoundingClientRect()),className:`p-1 rounded transition hover:bg-[var(--c-bg3)] cursor-pointer`,style:{color:`var(--c-text3)`},title:`GSD config`,children:(0,F.jsx)(Or,{size:13})})]})]}),t&&(0,F.jsxs)(`div`,{className:`border-t`,style:{borderColor:`var(--c-border)`},children:[(0,F.jsxs)(`div`,{className:`flex items-center px-3 py-1 text-[10px]`,style:{background:`var(--c-bg2)`,color:`var(--c-text3)`,gap:0},children:[(0,F.jsx)(`div`,{style:{width:28,flexShrink:0}}),(0,F.jsx)(`div`,{style:{width:32,flexShrink:0},children:`#`}),(0,F.jsx)(`div`,{className:`flex-1 pr-3`,children:`phase`}),(0,F.jsx)(`div`,{style:{width:100,flexShrink:0,paddingRight:12},children:`plans`}),(0,F.jsx)(`div`,{style:{width:88,flexShrink:0},children:`artifacts`}),(0,F.jsx)(`div`,{style:{width:64,flexShrink:0,textAlign:`right`},children:`est. cost`}),(0,F.jsx)(`div`,{style:{width:56,flexShrink:0,textAlign:`right`},children:`updated`})]}),o===null?(0,F.jsx)(`div`,{className:`px-4 py-3 text-[12px]`,style:{color:`var(--c-text3)`},children:`Loading phases…`}):o.length===0?(0,F.jsx)(`div`,{className:`px-4 py-3 text-[12px]`,style:{color:`var(--c-text3)`},children:`No phases found.`}):o.map(t=>(0,F.jsx)(HD,{phase:t,tokenData:c?.[t.id]??null,onOpenFile:(t,n)=>r(t,e.folder,n)},t.id))]})]})}function GD(){let{dark:e}=tr(),[t,n]=(0,S.useState)(null),[r,i]=(0,S.useState)(null),[a,o]=(0,S.useState)(null),[s,c]=(0,S.useState)(null),[l,u]=(0,S.useState)(null),[d,f]=(0,S.useState)(null),[p,m]=(0,S.useState)(!0),h=e?`#888`:`#555`,g=e?`#555`:`#999`,_=e?`rgba(255,255,255,0.03)`:`rgba(0,0,0,0.06)`;(0,S.useEffect)(()=>{Promise.all([sa(),ua()]).then(([e,t])=>{n(e),i(t),m(!1),o({totalCost:(e||[]).reduce((e,t)=>e+(t.total_cost||0),0)})}).catch(()=>m(!1))},[]);function v(e,t){f(n=>n?.folder===e?null:{folder:e,anchor:t})}function y(e,t,n){let r=e.id?.split(`::`)?.[1]||``,i=e.phase_name??e.name??``;u({title:{plan:`PLAN.md`,research:`RESEARCH.md`,verification:`VERIFICATION.md`,summary:`SUMMARY.md`}[n]??n.toUpperCase()+`.md`,subtitle:i,content:null,loading:!0}),n===`plan`?la(t,r).then(e=>u(t=>t?{...t,content:e?.content??null,loading:!1}:null)).catch(()=>u(e=>e?{...e,loading:!1}:null)):pa(t,n,r).then(e=>u(t=>t?{...t,content:e?.content??null,loading:!1}:null)).catch(()=>u(e=>e?{...e,loading:!1}:null))}function b(e,t){u({title:`STATE.md`,subtitle:t,content:null,loading:!0}),pa(e,`state`).then(e=>u(t=>t?{...t,content:e?.content??null,loading:!1}:null)).catch(()=>u(e=>e?{...e,loading:!1}:null))}if(p)return(0,F.jsx)(wa,{label:`Loading GSD projects...`});if(!t||t.length===0)return(0,F.jsxs)(`div`,{className:`fade-in space-y-3`,children:[(0,F.jsx)($T,{icon:xi,title:`GSD Workflow`}),(0,F.jsxs)(`div`,{className:`card p-8 text-center space-y-3`,children:[(0,F.jsx)(xi,{size:32,style:{color:`var(--c-text3)`,margin:`0 auto`}}),(0,F.jsx)(`div`,{className:`text-[14px] font-semibold`,style:{color:`var(--c-white)`},children:`No GSD projects found`}),(0,F.jsxs)(`div`,{className:`text-[12px] max-w-sm mx-auto`,style:{color:`var(--c-text2)`},children:[`GSD (Get Shit Done) is a structured AI workflow system that stores project plans and phases inside a `,(0,F.jsx)(`code`,{style:{fontFamily:PD},children:`.planning/`}),` directory. Run a data scan after initializing a GSD project and it will appear here.`]})]})]});let x=r&&r.totalPhases>0?Math.round(r.completedPhases/r.totalPhases*100):0,C={completed:r?.completedPhases??0,executing:r?.executingPhases??0,planned:r?.plannedPhases??0},w={labels:[`Completed`,`Executing`,`Planned`],datasets:[{data:[C.completed,C.executing,C.planned],backgroundColor:[`#22c55e`,`#f59e0b`,`rgba(255,255,255,0.08)`],borderWidth:0}]},T=[...t].sort((e,t)=>t.total_phases-e.total_phases).slice(0,8),E={labels:T.map(e=>e.name.length>16?e.name.slice(0,15)+`…`:e.name),datasets:[{label:`Completed`,data:T.map(e=>e.completed_phases),backgroundColor:`#22c55e`,borderRadius:2},{label:`Remaining`,data:T.map(e=>e.total_phases-e.completed_phases),backgroundColor:`rgba(99,102,241,0.3)`,borderRadius:2}]},D={responsive:!0,maintainAspectRatio:!1,cutout:`72%`,plugins:{legend:{display:!1},tooltip:{bodyFont:{family:PD,size:10},titleFont:{family:PD,size:10}}}},O={responsive:!0,maintainAspectRatio:!1,indexAxis:`y`,scales:{x:{stacked:!0,grid:{color:_},ticks:{color:g,font:{size:8,family:PD}}},y:{stacked:!0,grid:{display:!1},ticks:{color:h,font:{size:8,family:PD}}}},plugins:{legend:{display:!1},tooltip:{bodyFont:{family:PD,size:10},titleFont:{family:PD,size:10}}}};return(0,F.jsxs)(`div`,{className:`fade-in space-y-3`,children:[(0,F.jsx)($T,{icon:xi,title:`GSD Workflow`}),(0,F.jsxs)(`div`,{className:`grid gap-2`,style:{gridTemplateColumns:`repeat(auto-fit, minmax(90px, 1fr))`},children:[(0,F.jsx)(K,{label:`projects`,value:r?.totalProjects??t.length}),(0,F.jsx)(K,{label:`total phases`,value:r?.totalPhases??`—`}),(0,F.jsx)(K,{label:`completed`,value:r?.completedPhases??`—`}),(0,F.jsx)(K,{label:`completion`,value:r?.totalPhases>0?`${x}%`:`—`}),(0,F.jsx)(K,{label:`total cost`,value:a?kh(a.totalCost):`—`})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-3`,children:[(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`phase status`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,F.jsx)(`div`,{style:{height:110,width:110,flexShrink:0},children:(0,F.jsx)(Th,{data:w,options:D})}),(0,F.jsx)(`div`,{className:`space-y-2 text-[11px]`,children:[{label:`Completed`,count:C.completed,color:`#22c55e`},{label:`Executing`,count:C.executing,color:`#f59e0b`},{label:`Planned`,count:C.planned,color:`var(--c-text3)`}].map(({label:e,count:t,color:n})=>(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0`,style:{background:n}}),(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`},children:e}),(0,F.jsx)(`span`,{className:`ml-auto font-bold tabular-nums`,style:{color:n,fontFamily:PD},children:t})]},e))})]})]}),(0,F.jsxs)(`div`,{className:`card p-3 lg:col-span-2`,children:[(0,F.jsxs)($,{children:[`projects `,(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:`by phases`})]}),(0,F.jsx)(`div`,{style:{height:130},children:(0,F.jsx)(wh,{data:E,options:O})}),(0,F.jsxs)(`div`,{className:`flex items-center gap-4 mt-2 text-[10px]`,style:{color:`var(--c-text3)`},children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-sm`,style:{background:`#22c55e`}}),` Completed`]}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-sm`,style:{background:`rgba(99,102,241,0.3)`}}),` Remaining`]})]})]})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)($,{children:`projects`}),t.map(e=>(0,F.jsx)(WD,{project:e,isExpanded:s===e.folder,onToggle:()=>c(t=>t===e.folder?null:e.folder),onOpenFile:y,onOpenConfig:v,onOpenState:b},e.folder))]}),d&&(0,F.jsx)(VD,{folder:d.folder,anchor:d.anchor,onClose:()=>f(null)}),l&&(0,F.jsx)(RD,{title:l.title,subtitle:l.subtitle,content:l.content,loading:l.loading,onClose:()=>u(null)})]})}function KD({icon:e,label:t,items:n}){let[r,i]=(0,S.useState)(!1),a=ct(),o=n.some(e=>e.to===a.pathname),s=(0,S.useRef)(null);return(0,F.jsxs)(`div`,{className:`relative`,onMouseEnter:()=>{clearTimeout(s.current),i(!0)},onMouseLeave:()=>{s.current=setTimeout(()=>i(!1),150)},children:[(0,F.jsxs)(`button`,{className:`flex items-center gap-1.5 px-2.5 py-1 text-[12px] rounded transition ${o?`bg-[var(--c-card)] text-[var(--c-white)]`:`text-[var(--c-text2)] hover:text-[var(--c-white)]`}`,children:[(0,F.jsx)(e,{size:12}),t,(0,F.jsx)(Cr,{size:10,style:{opacity:.5}})]}),r&&(0,F.jsx)(`div`,{className:`absolute top-full left-0 mt-1 py-1 rounded shadow-lg min-w-[160px] z-[100]`,style:{background:`var(--c-bg)`,border:`1px solid var(--c-border)`},children:n.map(({to:e,icon:t,label:n})=>(0,F.jsxs)(Mn,{to:e,onClick:()=>i(!1),className:({isActive:e})=>`flex items-center gap-2 px-3 py-1.5 text-[12px] transition ${e?`bg-[var(--c-bg3)] text-[var(--c-white)]`:`text-[var(--c-text2)] hover:text-[var(--c-white)] hover:bg-[var(--c-bg3)]`}`,children:[(0,F.jsx)(t,{size:12}),n]},e))})]})}function qD(){let[e,t]=(0,S.useState)(null),[n,r]=(0,S.useState)(null),{live:i,toggle:a}=Sa(),[o,s]=(0,S.useState)(null),[c,l]=(0,S.useState)(!1),[u,d]=(0,S.useState)(!!Mi()),f=(0,S.useRef)(null),{dark:p,toggle:m}=tr(),[h,g]=(0,S.useState)(!1),[_,v]=(0,S.useState)(!1);(0,S.useEffect)(()=>{Fi(()=>d(!1))},[]),(0,S.useEffect)(()=>{ma().then(e=>{s(e.mode||`local`),l(!!e.auth)})},[]);let y=(0,S.useCallback)(()=>{zi().then(t).catch(()=>{})},[]);(0,S.useEffect)(()=>{o===`local`&&y()},[o]);let b=(0,S.useCallback)(async e=>{await Gi(e),t(await zi())},[]);(0,S.useEffect)(()=>(i&&o===`local`?f.current=setInterval(()=>{b().catch(()=>{})},6e4):(f.current&&clearInterval(f.current),f.current=null),()=>{f.current&&clearInterval(f.current)}),[i,o,b]);let x=async()=>{r({scanned:0,total:0});try{await b(e=>r({scanned:e.scanned,total:e.total}))}catch(e){console.error(e)}r(null)},C=o===`relay`,w=C&&c&&!u,T=ct().pathname===`/artifacts`,E=C?[{to:`/`,icon:Di,label:`Team`}]:[{to:`/`,icon:lr,label:`Dashboard`},{to:`/sessions`,icon:ni,label:`Sessions`},{to:`/projects`,icon:Ur,label:`Projects`},{icon:Ir,label:`Costs`,children:[{to:`/costs`,icon:Ir,label:`Cost Analysis`},{to:`/subscriptions`,icon:Pr,label:`Subscriptions`}]},{icon:yr,label:`Insights`,children:[{to:`/analysis`,icon:yr,label:`Deep Analysis`},{to:`/compare`,icon:Wr,label:`Compare`}]},{to:`/artifacts`,icon:ii,label:`Artifacts`},{to:`/gsd`,icon:xi,label:`GSD`},{to:`/mcps`,icon:oi,label:`MCPs`},{to:`/sql`,icon:Fr,label:`SQL`}];return w?(0,F.jsx)(Ta,{onSuccess:()=>d(!0)}):(0,F.jsxs)(`div`,{className:`min-h-screen`,children:[(0,F.jsxs)(`header`,{className:`border-b px-4 py-1.5 flex items-center gap-3 sticky top-0 z-50 backdrop-blur-xl`,style:{borderColor:`var(--c-border)`,background:`var(--c-header)`},children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs font-bold tracking-tight`,style:{color:`var(--c-white)`},children:[(0,F.jsx)(Ca,{size:18}),`Agentlytics`,C&&(0,F.jsx)(`span`,{className:`ml-1.5 text-[10px] font-medium px-1.5 py-0.5`,style:{background:`rgba(99,102,241,0.15)`,color:`#818cf8`},children:`relay`})]}),(0,F.jsx)(`nav`,{className:`flex gap-0.5 ml-2`,children:E.map(e=>e.children?(0,F.jsx)(KD,{icon:e.icon,label:e.label,items:e.children},e.label):(0,F.jsxs)(Mn,{to:e.to,end:e.to===`/`,className:({isActive:e})=>`flex items-center gap-1.5 px-2.5 py-1 text-[12px] rounded transition ${e?`bg-[var(--c-card)] text-[var(--c-white)]`:`text-[var(--c-text2)] hover:text-[var(--c-white)]`}`,children:[(0,F.jsx)(e.icon,{size:12}),e.label]},e.to))}),(0,F.jsxs)(`div`,{className:`ml-auto flex items-center gap-3`,children:[!C&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`button`,{onClick:a,className:`flex items-center gap-1.5 px-2 py-0.5 text-[11px] transition`,style:{color:i?`#22c55e`:`var(--c-text3)`,border:i?`1px solid rgba(34,197,94,0.3)`:`1px solid var(--c-border)`,background:i?`rgba(34,197,94,0.08)`:`transparent`},title:i?`Disable live refresh`:`Enable live refresh (every 60s)`,children:[(0,F.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full ${i?`pulse-dot`:``}`,style:{background:i?`#22c55e`:`var(--c-text3)`}}),`Live`]}),(0,F.jsxs)(`button`,{onClick:x,disabled:!!n,className:`flex items-center gap-1 px-2 py-0.5 text-[11px] rounded transition hover:bg-[var(--c-card)]`,style:{color:`var(--c-text2)`,border:`1px solid var(--c-border)`},title:`Clear cache and rescan all editors`,children:[(0,F.jsx)(li,{size:10,className:n?`animate-spin`:``}),n?`Refetching (${n.scanned}/${n.total})...`:`Refetch`]}),(0,F.jsx)(`span`,{className:`text-[11px]`,style:{color:`var(--c-text2)`},children:e?`${e.totalChats} sessions`:`...`})]}),C&&(0,F.jsxs)(`button`,{onClick:()=>{g(!0),v(!1)},className:`flex items-center gap-1.5 px-2 py-0.5 text-[11px] transition hover:bg-[var(--c-card)]`,style:{color:`#818cf8`,border:`1px solid var(--c-border)`},title:`MCP Connection`,children:[(0,F.jsx)(oi,{size:10}),`Connect`]}),(0,F.jsx)(Mn,{to:`/settings`,className:`p-1 rounded transition hover:bg-[var(--c-card)]`,style:({isActive:e})=>({color:e?`#6366f1`:`var(--c-text2)`}),title:`Settings`,children:(0,F.jsx)(pi,{size:13})}),(0,F.jsx)(`button`,{onClick:m,className:`p-1 rounded transition hover:bg-[var(--c-card)]`,style:{color:`var(--c-text2)`},title:p?`Light mode`:`Dark mode`,children:p?(0,F.jsx)(yi,{size:13}):(0,F.jsx)(ri,{size:13})})]})]}),n&&(0,F.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-1.5 text-[12px]`,style:{background:`rgba(234,179,8,0.08)`,borderBottom:`1px solid rgba(234,179,8,0.15)`,color:`#ca8a04`},children:[(0,F.jsx)(wi,{size:12}),(0,F.jsx)(`span`,{children:`Devin, Devin Next, and Antigravity require their app to be running during refetch — otherwise their sessions won't be detected.`})]}),(0,F.jsx)(`main`,{className:C?`px-0`:T?`p-0 overflow-hidden`:`p-4 max-w-[1400px] mx-auto`,children:o===null?(0,F.jsx)(wa,{label:`Loading...`}):C?(0,F.jsxs)(zt,{children:[(0,F.jsx)(Lt,{path:`/`,element:(0,F.jsx)(OD,{})}),(0,F.jsx)(Lt,{path:`/relay`,element:(0,F.jsx)(OD,{})}),(0,F.jsx)(Lt,{path:`/relay/user/:username`,element:(0,F.jsx)(ND,{})})]}):(0,F.jsxs)(zt,{children:[(0,F.jsx)(Lt,{path:`/`,element:(0,F.jsx)(rE,{overview:e})}),(0,F.jsx)(Lt,{path:`/projects`,element:(0,F.jsx)(wE,{overview:e})}),(0,F.jsx)(Lt,{path:`/projects/detail`,element:(0,F.jsx)(ME,{})}),(0,F.jsx)(Lt,{path:`/sessions`,element:(0,F.jsx)(aE,{overview:e})}),(0,F.jsx)(Lt,{path:`/costs`,element:(0,F.jsx)(FE,{overview:e})}),(0,F.jsx)(Lt,{path:`/analysis`,element:(0,F.jsx)(_E,{overview:e})}),(0,F.jsx)(Lt,{path:`/compare`,element:(0,F.jsx)(xE,{overview:e})}),(0,F.jsx)(Lt,{path:`/subscriptions`,element:(0,F.jsx)(mD,{})}),(0,F.jsx)(Lt,{path:`/artifacts`,element:(0,F.jsx)($E,{})}),(0,F.jsx)(Lt,{path:`/mcps`,element:(0,F.jsx)(vD,{})}),(0,F.jsx)(Lt,{path:`/sql`,element:(0,F.jsx)(RE,{})}),(0,F.jsx)(Lt,{path:`/gsd`,element:(0,F.jsx)(GD,{})}),(0,F.jsx)(Lt,{path:`/settings`,element:(0,F.jsx)(eD,{})})]})}),(0,F.jsxs)(`footer`,{className:`border-t mt-8 px-4 py-3 flex items-center justify-between text-[11px]${T?` hidden`:``}`,style:{borderColor:`var(--c-border)`,color:`var(--c-text3)`},children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsxs)(`a`,{href:`https://github.com/f/agentlytics`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1 hover:text-[var(--c-text)] transition`,children:[(0,F.jsx)(Gr,{size:11}),(0,F.jsx)(`span`,{children:`GitHub`})]}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(Si,{size:11}),(0,F.jsx)(`code`,{style:{fontFamily:`JetBrains Mono, monospace`},children:`npx agentlytics`})]})]}),(0,F.jsxs)(`span`,{children:[`built by `,(0,F.jsx)(`a`,{href:`https://github.com/f`,target:`_blank`,rel:`noopener noreferrer`,className:`hover:text-[var(--c-text)] transition`,style:{color:`var(--c-text2)`},children:`fkadev`})]})]}),h&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`fixed inset-0 z-[60]`,style:{background:`rgba(0,0,0,0.5)`},onClick:()=>g(!1)}),(0,F.jsxs)(`div`,{className:`fixed z-[70] w-[440px] max-w-[90vw] p-5 rounded shadow-2xl`,style:{top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,background:`var(--c-bg)`,border:`1px solid var(--c-border)`},children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,F.jsxs)(`div`,{className:`text-[13px] font-bold`,style:{color:`var(--c-white)`},children:[(0,F.jsx)(oi,{size:13,className:`inline mr-1.5`,style:{color:`#818cf8`}}),`Connection Config`]}),(0,F.jsx)(`button`,{onClick:()=>g(!1),className:`text-[18px] leading-none px-1 hover:opacity-70 transition`,style:{color:`var(--c-text3)`},children:`×`})]}),(0,F.jsx)(`div`,{className:`text-[12px] font-medium mb-1.5`,style:{color:`var(--c-white)`},children:`MCP Config`}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,F.jsx)(`div`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:`Add to your AI client's MCP settings`}),(0,F.jsx)(`button`,{onClick:()=>{let e=localStorage.getItem(`agentlytics_relay_token`),t={url:`${window.location.origin}/mcp`};e&&(t.headers={Authorization:`Bearer ${e}`});let n=JSON.stringify({mcpServers:{agentlytics:t}},null,2);navigator.clipboard.writeText(n),v(!0),setTimeout(()=>v(!1),2e3)},className:`flex items-center gap-1 px-1.5 py-0.5 text-[10px] transition hover:bg-[var(--c-bg3)]`,style:{border:`1px solid var(--c-border)`,color:_?`#22c55e`:`var(--c-text2)`},children:_?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(Sr,{size:9}),` Copied`]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(Mr,{size:9}),` Copy`]})})]}),(0,F.jsx)(`pre`,{className:`text-[11px] px-3 py-2 overflow-x-auto mb-4`,style:{background:`var(--c-bg3)`,border:`1px solid var(--c-border)`,color:`var(--c-text)`,fontFamily:`JetBrains Mono, monospace`,lineHeight:1.6},children:localStorage.getItem(`agentlytics_relay_token`)?`{\n "mcpServers": {\n "agentlytics": {\n "url": "${window.location.origin}/mcp",\n "headers": { "Authorization": "Bearer ${localStorage.getItem(`agentlytics_relay_token`)}" }\n }\n }\n}`:`{\n "mcpServers": {\n "agentlytics": {\n "url": "${window.location.origin}/mcp"\n }\n }\n}`}),(0,F.jsx)(`div`,{className:`text-[12px] font-medium mb-1.5`,style:{color:`var(--c-white)`},children:`Team Sharing`}),(0,F.jsx)(`div`,{className:`text-[10px] mb-1`,style:{color:`var(--c-text3)`},children:`Relay join is not supported in memhouse — team sharing is kernel-based (members + grants + row-level security). See mem-house/delivery/kernel-install.md.`}),(0,F.jsx)(`pre`,{className:`text-[11px] px-3 py-2 overflow-x-auto`,style:{background:`var(--c-bg3)`,border:`1px solid var(--c-border)`,color:`var(--c-text)`,fontFamily:`JetBrains Mono, monospace`,lineHeight:1.6},children:`# each member ships with their own credential:
|