@kaitranntt/ccs 7.67.0-dev.1 → 7.67.0-dev.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/dist/ui/assets/{accounts-cuFTYYRt.js → accounts-ls0hXYZ9.js} +1 -1
- package/dist/ui/assets/{alert-dialog-SgZxEXpw.js → alert-dialog-DJMw_zyc.js} +1 -1
- package/dist/ui/assets/{api-DQs1Ldow.js → api-Dz2nP1bN.js} +1 -1
- package/dist/ui/assets/{auth-section-C4y85pIC.js → auth-section-BD8XqTiz.js} +1 -1
- package/dist/ui/assets/{backups-section-BERNcZpv.js → backups-section-COOSGu9k.js} +1 -1
- package/dist/ui/assets/{channels-DBLp0DUg.js → channels-AGHzxMPw.js} +1 -1
- package/dist/ui/assets/{checkbox-B-cTEUE0.js → checkbox-pojB3pE7.js} +1 -1
- package/dist/ui/assets/{claude-extension-CiqXZCUX.js → claude-extension-4b8gXOo_.js} +1 -1
- package/dist/ui/assets/{cliproxy-DlQkkQVp.js → cliproxy-BFEBo-pc.js} +1 -1
- package/dist/ui/assets/{cliproxy-ai-providers-wBfCEEze.js → cliproxy-ai-providers-BXE0HGLt.js} +1 -1
- package/dist/ui/assets/{cliproxy-control-panel-Dg15tkqi.js → cliproxy-control-panel-ZnCfRS9l.js} +1 -1
- package/dist/ui/assets/{codex-CbEo9E_j.js → codex-B9uBYmnm.js} +5 -5
- package/dist/ui/assets/{confirm-dialog-DJpEIfS_.js → confirm-dialog-DwPqRjyW.js} +1 -1
- package/dist/ui/assets/{copilot-B8fIS-vF.js → copilot-CSWApqyO.js} +2 -2
- package/dist/ui/assets/{cursor-DCN2ypJD.js → cursor-DYbVB4gp.js} +1 -1
- package/dist/ui/assets/{droid-CKRz_GOK.js → droid-BAovZe7o.js} +1 -1
- package/dist/ui/assets/{globalenv-section-CZCiD-lk.js → globalenv-section-CHHZbjD8.js} +1 -1
- package/dist/ui/assets/{health-CDd5on8I.js → health-Jp7o0exN.js} +1 -1
- package/dist/ui/assets/{icons-C4EMu2PL.js → icons-DfENUzBo.js} +1 -1
- package/dist/ui/assets/{index-BGqBqww_.js → index--j-jJwzV.js} +1 -1
- package/dist/ui/assets/{index-CoUGuS5J.js → index-C5iouJJ2.js} +1 -1
- package/dist/ui/assets/{index-Ywy20w8T.js → index-C5uQdep3.js} +1 -1
- package/dist/ui/assets/{index-8IL3kgiJ.js → index-CpkWv5tW.js} +1 -1
- package/dist/ui/assets/{index-2X6A__Ih.css → index-DFifef9c.css} +1 -1
- package/dist/ui/assets/index-Du97tqVQ.js +69 -0
- package/dist/ui/assets/{index-kTxwXQ5y.js → index-VluKB6dO.js} +1 -1
- package/dist/ui/assets/{logs-ecr4mQMK.js → logs-BDbHSujh.js} +1 -1
- package/dist/ui/assets/{masked-input-bSAouyU5.js → masked-input-BcJDHDE6.js} +1 -1
- package/dist/ui/assets/{proxy-status-widget-BVdcjMn7.js → proxy-status-widget-DQWsa532.js} +1 -1
- package/dist/ui/assets/{raw-json-settings-editor-panel-CJnuNmCM.js → raw-json-settings-editor-panel-Cbn2O4rk.js} +1 -1
- package/dist/ui/assets/{searchable-select-DvFzk1D1.js → searchable-select-fldXYfY4.js} +1 -1
- package/dist/ui/assets/{separator-DgeSGH_l.js → separator-Dd3ktLxa.js} +1 -1
- package/dist/ui/assets/{shared-D5HUP-Vv.js → shared-CdAn8E3x.js} +1 -1
- package/dist/ui/assets/{table-8dkohJBd.js → table-CCf__Q_I.js} +1 -1
- package/dist/ui/assets/{updates-8zMjNZyg.js → updates-DfoGG8Jl.js} +1 -1
- package/dist/ui/index.html +3 -3
- package/package.json +1 -1
- package/dist/ui/assets/index-CUOLpSIB.js +0 -69
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as f,c as pe}from"./react-vendor-CNOkPC89.js";import{u as M,a as ee,C as p,b as g,S as h,c,P as N,B as I,d as H,e as se,f as ge,g as te,h as je,i as ae,j as y,k as D,l as ye,m as Ne,n as we,o as be}from"./index-CUOLpSIB.js";import{a2 as ve,ak as re,al as z,am as ne,a0 as le,a9 as ke,G as Ce,an as Se,R as De,_ as Y,U as Le,Z as ie,v as $e,ac as G,ao as Te,V as Fe,C as Re,ap as Me,aq as Pe}from"./icons-C4EMu2PL.js";import{a as Be,u as P}from"./tanstack-CrmUhA7Z.js";import{K as $,L as V,f as k,H as Ae}from"./utils-CzKF5WmX.js";import{R as oe,A as Ue,C as qe,X as Ie,Y as Q,T as ce,a as Z,P as Oe,b as Ke,c as Ee}from"./charts-BBPXh0Ar.js";import"./notifications-B2HqRBj7.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function Ge({data:s,isLoading:t}){const{privacyMode:r}=M(),{t:n}=ee();if(t)return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:[1,2,3,4,5].map(a=>e.jsx(p,{children:e.jsx(g,{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{className:"h-4 w-[100px]"}),e.jsx(h,{className:"h-8 w-[80px]"})]}),e.jsx(h,{className:"h-8 w-8 rounded-lg"})]})})},a))});const l=(s?.tokenBreakdown?.cacheCreation?.cost??0)+(s?.tokenBreakdown?.cacheRead?.cost??0),i=s?.totalCost?Math.round(l/s.totalCost*100):0,x=[{title:n("analyticsSummary.totalTokens"),value:s?.totalTokens??0,icon:ve,format:a=>R(a),color:"text-blue-600",bgColor:"bg-blue-100 dark:bg-blue-900/20",subtitle:n("analyticsSummary.totalTokensSubtitle",{input:R(s?.totalInputTokens??0),output:R(s?.totalOutputTokens??0)})},{title:n("analyticsSummary.totalCost"),value:s?.totalCost??0,icon:re,format:a=>`$${a.toFixed(2)}`,color:"text-green-600",bgColor:"bg-green-100 dark:bg-green-900/20",subtitle:n("analyticsSummary.totalCostSubtitle",{value:s?.averageCostPerDay?.toFixed(2)??"0.00"})},{title:n("analyticsSummary.cacheTokens"),value:s?.totalCacheTokens??0,icon:z,format:a=>R(a),color:"text-cyan-600",bgColor:"bg-cyan-100 dark:bg-cyan-900/20",subtitle:n("analyticsSummary.cacheTokensSubtitle",{cost:l.toFixed(2),percent:i})},{title:n("analyticsSummary.inputCost"),value:s?.tokenBreakdown?.input?.cost??0,icon:ne,format:a=>`$${a.toFixed(2)}`,color:"text-purple-600",bgColor:"bg-purple-100 dark:bg-purple-900/20",subtitle:n("analyticsSummary.tokensSubtitle",{value:R(s?.tokenBreakdown?.input?.tokens??0)})},{title:n("analyticsSummary.outputCost"),value:s?.tokenBreakdown?.output?.cost??0,icon:le,format:a=>`$${a.toFixed(2)}`,color:"text-orange-600",bgColor:"bg-orange-100 dark:bg-orange-900/20",subtitle:n("analyticsSummary.tokensSubtitle",{value:R(s?.tokenBreakdown?.output?.tokens??0)})}];return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:x.map((a,o)=>{const d=a.icon;return e.jsx(p,{className:"hover:shadow-md transition-shadow",children:e.jsx(g,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between space-x-2",children:[e.jsxs("div",{className:"space-y-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground truncate",children:a.title}),e.jsx("p",{className:c("text-xl font-bold truncate",r&&N),children:a.format(a.value)}),a.subtitle&&e.jsx("p",{className:c("text-[10px] text-muted-foreground truncate",r&&N),children:a.subtitle})]}),e.jsx("div",{className:c("p-2 rounded-lg shrink-0",a.bgColor),children:e.jsx(d,{className:c("h-4 w-4",a.color)})})]})})},o)})})}function R(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function We({model:s}){const{privacyMode:t}=M(),r=He(s.ioRatio);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ke,{className:"h-4 w-4 text-primary shrink-0"}),e.jsx("h4",{className:"font-semibold leading-none truncate",title:s.model,children:s.model})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(I,{variant:"secondary",className:"text-[10px] h-5 px-1.5",children:[s.percentage.toFixed(1),"% usage"]}),e.jsxs(I,{variant:r.variant,className:"text-[10px] h-5 px-1.5",children:[s.ioRatio.toFixed(0),":1 I/O"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("p",{className:c("text-lg font-bold",t&&N),children:["$",s.cost.toFixed(2)]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Total Cost"})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsx("p",{className:c("text-lg font-bold",t&&N),children:ze(s.tokens)}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Total Tokens"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h5",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wider",children:"Token Breakdown"}),e.jsxs("div",{className:c("space-y-1",t&&N),children:[e.jsx(W,{label:"Input",tokens:s.inputTokens,cost:s.costBreakdown.input.cost,color:"#335c67",icon:ne}),e.jsx(W,{label:"Output",tokens:s.outputTokens,cost:s.costBreakdown.output.cost,color:"#fff3b0",icon:le}),e.jsx(W,{label:"Cache Write",tokens:s.cacheCreationTokens,cost:s.costBreakdown.cacheCreation.cost,color:"#e09f3e",icon:z}),e.jsx(W,{label:"Cache Read",tokens:s.cacheReadTokens,cost:s.costBreakdown.cacheRead.cost,color:"#9e2a2b",icon:z})]})]}),e.jsxs("div",{className:"p-2.5 rounded-md border bg-muted/20 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium",children:"Input/Output Ratio"})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground leading-snug",children:r.description})]})]})}function W({label:s,tokens:t,cost:r,color:n,icon:l}){return t===0?null:e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("div",{className:"w-1 h-6 rounded-full shrink-0",style:{backgroundColor:n}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium truncate",children:s}),e.jsxs("span",{className:"font-mono text-muted-foreground",children:["$",r.toFixed(3)]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[e.jsx(l,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:_e(t)})]})]})]})}function He(s){return s>=200?{variant:"destructive",description:"Extended thinking or large context loading. Expected for reasoning models."}:s>=50?{variant:"secondary",description:"More input than output. Typical for analysis tasks."}:s>=5?{variant:"outline",description:"Balanced input/output ratio for typical coding tasks."}:{variant:"default",description:"More output than input. Generation-heavy workload."}}function _e(s){return s.toLocaleString()}function ze(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}const Ve="/api";function b(s){const t=s.getFullYear(),r=String(s.getMonth()+1).padStart(2,"0"),n=String(s.getDate()).padStart(2,"0");return`${t}${r}${n}`}const T={summary:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",b(s.startDate)),s?.endDate&&t.append("until",b(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/summary?${t}`)},trends:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",b(s.startDate)),s?.endDate&&t.append("until",b(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/daily?${t}`)},hourly:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",b(s.startDate)),s?.endDate&&t.append("until",b(s.endDate)),L(`/usage/hourly?${t}`)},models:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",b(s.startDate)),s?.endDate&&t.append("until",b(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/models?${t}`)},sessions:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",b(s.startDate)),s?.endDate&&t.append("until",b(s.endDate)),s?.profile&&t.append("profile",s.profile),s?.limit&&t.append("limit",s.limit.toString()),s?.offset&&t.append("offset",s.offset.toString()),L(`/usage/sessions?${t}`)},monthly:(s,t)=>{const r=new URLSearchParams;return s&&r.append("months",s.toString()),t&&r.append("profile",t),L(`/usage/monthly?${r}`)},refresh:async()=>{if(!(await fetch(`${Ve}/usage/refresh`,{method:"POST",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to refresh usage cache")},status:()=>L("/usage/status"),insights:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",b(s.startDate)),s?.endDate&&t.append("until",b(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/insights?${t}`)}};async function L(s){const r=await fetch(`/api${s}`,{headers:{"Content-Type":"application/json"}});if(!r.ok){const l=await r.json().catch(()=>({error:"Unknown error"}));throw new Error(l.error||r.statusText)}const n=await r.json();return n.data||n}function Ye(s){return P({queryKey:["usage","summary",s],queryFn:()=>T.summary(s),staleTime:60*1e3})}function Qe(s){return P({queryKey:["usage","trends",s],queryFn:()=>T.trends(s),staleTime:60*1e3})}function Ze(s){return P({queryKey:["usage","hourly",s],queryFn:()=>T.hourly(s),staleTime:60*1e3})}function Xe(s){return P({queryKey:["usage","models",s],queryFn:()=>T.models(s),staleTime:60*1e3})}function Je(){const s=Be();return f.useCallback(async()=>{await T.refresh(),await s.invalidateQueries({queryKey:["usage"]})},[s])}function es(){return P({queryKey:["usage","status"],queryFn:()=>T.status(),staleTime:10*1e3,refetchInterval:30*1e3})}function ss(s){return P({queryKey:["usage","sessions",s],queryFn:()=>T.sessions(s),staleTime:60*1e3})}function ts(){const[s,t]=f.useState({from:$(new Date,30),to:new Date}),[r,n]=f.useState(!1),[l,i]=f.useState(null),[x,a]=f.useState(null),[o,d]=f.useState("daily"),u=Je(),m=f.useCallback(async()=>{n(!0);try{await u()}finally{n(!1)}},[u]),j=f.useMemo(()=>({startDate:s?.from,endDate:s?.to}),[s?.from,s?.to]),{data:w,isLoading:v}=Ye(j),{data:C,isLoading:S}=Qe(j),{data:B,isLoading:A}=Ze(j),{data:U,isLoading:q}=Xe(j),{data:_,isLoading:O}=ss({...j,limit:3}),{data:K}=es(),de=f.useCallback(()=>{const F=new Date;t({from:$(F,1),to:F}),d("hourly")},[]),xe=f.useCallback(F=>{t(F),d("daily")},[]),ue=f.useMemo(()=>K?.lastFetch?V(new Date(K.lastFetch),{addSuffix:!0}):null,[K?.lastFetch]),me=f.useCallback((F,fe)=>{const E=fe.currentTarget.getBoundingClientRect();a({x:E.left+E.width/2,y:E.top+E.height/2}),i(F)},[]),he=f.useCallback(()=>{i(null),a(null)},[]);return{dateRange:s,isRefreshing:r,viewMode:o,selectedModel:l,popoverPosition:x,summary:w,trends:C,hourlyData:B,models:U,sessions:_,status:K,isSummaryLoading:v,isTrendsLoading:S,isHourlyLoading:A,isModelsLoading:q,isSessionsLoading:O,isLoading:v||S||q||O,handleRefresh:m,handleTodayClick:de,handleDateRangeChange:xe,handleModelClick:me,handlePopoverClose:he,lastUpdatedText:ue}}function as({value:s,onChange:t,presets:r=[{label:"Last 7 days",range:{from:$(new Date,7),to:new Date}},{label:"Last 30 days",range:{from:$(new Date,30),to:new Date}},{label:"Last 90 days",range:{from:$(new Date,90),to:new Date}}],className:n}){const[l,i]=pe.useState(!1),x=a=>!s||!s.from||!s.to||!a.from||!a.to?!1:k(s.from,"yyyy-MM-dd")===k(a.from,"yyyy-MM-dd")&&k(s.to,"yyyy-MM-dd")===k(a.to,"yyyy-MM-dd");return e.jsxs("div",{className:c("flex flex-wrap items-center gap-2",n),children:[r.map(a=>e.jsx(H,{variant:x(a.range)?"default":"outline",size:"sm",onClick:()=>t(a.range),children:a.label},a.label)),e.jsxs(se,{open:l,onOpenChange:i,children:[e.jsx(ge,{asChild:!0,children:e.jsxs(H,{id:"date",variant:"outline",className:c("w-auto min-w-[200px] sm:min-w-[240px] justify-start text-left font-normal",!s&&"text-muted-foreground"),children:[e.jsx(Se,{className:"mr-2 h-4 w-4"}),s?.from?s.to?e.jsxs(e.Fragment,{children:[k(s.from,"LLL dd, y")," - ",k(s.to,"LLL dd, y")]}):k(s.from,"LLL dd, y"):e.jsx("span",{children:"Pick a date"})]})}),e.jsx(te,{className:"w-auto p-0",align:"end",children:e.jsx(je,{initialFocus:!0,mode:"range",defaultMonth:s?.from,selected:s,onSelect:t,numberOfMonths:2})})]})]})}function rs({dateRange:s,onDateRangeChange:t,onTodayClick:r,onRefresh:n,isRefreshing:l,lastUpdatedText:i,viewMode:x}){const{t:a}=ee();return e.jsxs("div",{className:"flex flex-col gap-3 shrink-0 xl:flex-row xl:items-center xl:justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold",children:a("analytics.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a("analytics.subtitle")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 xl:justify-end",children:[e.jsx(H,{variant:x==="hourly"?"default":"outline",size:"sm",className:"h-8",onClick:r,children:"24H"}),e.jsx(as,{className:"flex-wrap",value:s,onChange:t,presets:[{label:"7D",range:{from:$(new Date,7),to:new Date}},{label:"30D",range:{from:$(new Date,30),to:new Date}},{label:a("analytics.month"),range:{from:Ae(new Date),to:new Date}},{label:a("analytics.allTime"),range:{from:void 0,to:new Date}}]}),i&&e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:a("analytics.updated",{value:i})}),e.jsx(H,{variant:"outline",size:"sm",className:"gap-2 h-8",onClick:n,disabled:l,children:e.jsx(De,{className:`w-3.5 h-3.5 ${l?"animate-spin":""}`})})]})]})}function ns({data:s,isLoading:t,granularity:r="daily",className:n}){const{privacyMode:l}=M(),i=f.useMemo(()=>!s||s.length===0?[]:(r==="hourly"?s:[...s].reverse()).map(o=>{const d="hour"in o?o.hour:o.date;return{...o,dateFormatted:ls(d,r),costRounded:Number(o.cost.toFixed(4))}}),[s,r]);if(t)return e.jsx(h,{className:c("h-full w-full",n)});if(!s||s.length===0)return e.jsx("div",{className:c("h-full flex items-center justify-center",n),children:e.jsx("p",{className:"text-muted-foreground",children:r==="hourly"?"No usage data for today":"No usage data available"})});const x=({x:a,y:o,payload:d,isRight:u})=>{const m=u?`$${d.value}`:X(Number(d.value));return e.jsx("text",{x:a,y:o,dy:4,textAnchor:u?"start":"end",fontSize:12,fill:"currentColor",className:c("fill-muted-foreground",l&&"blur-[4px]"),children:m})};return e.jsx("div",{className:c("w-full h-full",n),children:e.jsx(oe,{width:"100%",height:"100%",children:e.jsxs(Ue,{data:i,margin:{top:5,right:30,left:20,bottom:5},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"tokenGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#0080FF",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#0080FF",stopOpacity:.1})]}),e.jsxs("linearGradient",{id:"costGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#00C49F",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#00C49F",stopOpacity:.1})]})]}),e.jsx(qe,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(Ie,{dataKey:"dateFormatted",tick:{fontSize:12},tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(Q,{yAxisId:"left",orientation:"left",tick:a=>e.jsx(x,{...a,isRight:!1}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(Q,{yAxisId:"right",orientation:"right",tick:a=>e.jsx(x,{...a,isRight:!0}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(ce,{content:({active:a,payload:o,label:d})=>{if(!a||!o||!o.length)return null;const u=o[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-3 shadow-lg",children:[e.jsx("p",{className:"font-medium mb-2",children:d}),o.map((m,j)=>e.jsxs("p",{className:c("text-sm",l&&N),style:{color:m.color},children:[m.name,":"," ",m.name==="Tokens"?X(Number(m.value)||0):`$${m.value}`]},j)),"requests"in u&&e.jsxs("p",{className:c("text-sm text-muted-foreground mt-1",l&&N),children:["Requests: ",u.requests]})]})}}),e.jsx(Z,{yAxisId:"left",type:"monotone",dataKey:"tokens",stroke:"#0080FF",strokeWidth:2,fillOpacity:1,fill:"url(#tokenGradient)",name:"Tokens"}),e.jsx(Z,{yAxisId:"right",type:"monotone",dataKey:"costRounded",stroke:"#00C49F",strokeWidth:2,fillOpacity:1,fill:"url(#costGradient)",name:"Cost"})]})})})}function ls(s,t){if(t==="hourly"){const[n,l]=s.split(" ");if(n&&l){const i=new Date(`${n}T${l}:00Z`);return k(i,"HH:mm")}return s}const r=new Date(s);return t==="monthly"?k(r,"MMM yyyy"):k(r,"MMM dd")}function X(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function is({data:s,isLoading:t,className:r}){const{privacyMode:n}=M(),l=f.useMemo(()=>!s||s.length===0?[]:s.map(a=>({name:a.model,value:a.tokens,cost:a.cost,percentage:a.percentage,fill:ae(a.model)})),[s]);if(t)return e.jsx(h,{className:c("h-full min-h-[100px] w-full",r)});if(!s||s.length===0)return e.jsx("div",{className:c("h-full min-h-[100px] flex items-center justify-center",r),children:e.jsx("p",{className:"text-muted-foreground",children:"No model data available"})});const i=({active:a,payload:o})=>{if(!a||!o)return null;const d=o;if(!d.length)return null;const u=d[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-2 shadow-lg text-xs",children:[e.jsx("p",{className:"font-medium mb-1",children:u.name}),e.jsxs("p",{className:c("text-muted-foreground",n&&N),children:[os(u.value)," (",u.percentage.toFixed(1),"%)"]}),e.jsxs("p",{className:c("text-muted-foreground",n&&N),children:["$",u.cost.toFixed(4)]})]})},x=a=>a.percentage>5?`${a.percentage.toFixed(1)}%`:"";return e.jsx("div",{className:c("w-full h-full min-h-[100px]",r),children:e.jsx(oe,{width:"100%",height:"100%",children:e.jsxs(Oe,{children:[e.jsx(Ke,{data:l,cx:"50%",cy:"50%",labelLine:!1,label:x,innerRadius:50,outerRadius:70,paddingAngle:2,dataKey:"value",children:l.map((a,o)=>e.jsx(Ee,{fill:a.fill,strokeWidth:1},`cell-${o}`))}),e.jsx(ce,{content:i})]})})})}function os(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function cs(s){if(!s)return"";const r=s.replace(/^\/|\/$/g,"").split("/").filter(n=>n.length>0);return r[r.length-1]||""}function ds({data:s,isLoading:t,className:r}){const{privacyMode:n}=M(),l=f.useMemo(()=>{if(!s?.sessions||s.sessions.length===0)return null;const i=s.sessions,x=s.total,a=i.reduce((w,v)=>w+(v.inputTokens+v.outputTokens),0),o=Math.round(a/i.length),u=i.reduce((w,v)=>w+v.cost,0)/i.length,m=i[0],j=m?V(new Date(m.lastActivity),{addSuffix:!0}):"N/A";return{totalSessions:x,avgTokens:o,avgCost:u,lastActive:j,recentSessions:i.slice(0,3)}},[s]);return t?e.jsxs(p,{className:c("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",r),children:[e.jsx(y,{className:"px-3 py-2",children:e.jsx(h,{className:"h-5 w-32"})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx(h,{className:"h-full w-full"})})]}):l?e.jsxs(p,{className:c("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm",r),children:[e.jsx(y,{className:"px-3 py-2",children:e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Y,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsxs(g,{className:"px-3 pb-3 pt-0 flex-1 min-h-0 flex flex-col gap-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-blue-600 dark:text-blue-400",children:[e.jsx(Le,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xl font-bold",children:l.totalSessions})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:"Total Sessions"})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-green-600 dark:text-green-400",children:[e.jsx(ie,{className:"w-4 h-4"}),e.jsxs("span",{className:c("text-xl font-bold",n&&N),children:["$",l.avgCost.toFixed(2)]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:"Avg Cost/Session"})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground font-medium mb-1",children:[e.jsx($e,{className:"w-3 h-3"}),"Recent Activity"]}),e.jsx("div",{className:"space-y-1.5 max-h-full overflow-y-auto pr-1",children:l.recentSessions.map(i=>e.jsxs("div",{className:"flex items-center justify-between text-xs p-1.5 rounded bg-muted/30 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"font-medium truncate",title:i.projectPath,children:cs(i.projectPath)}),(i.target??"claude")!=="claude"&&e.jsx("span",{className:"shrink-0 px-1 py-0 text-[9px] font-medium rounded bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-300 uppercase",children:i.target})]}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:V(new Date(i.lastActivity),{addSuffix:!0})})]}),e.jsxs("div",{className:c("text-right shrink-0 ml-2",n&&N),children:[e.jsxs("div",{className:"font-mono",children:["$",i.cost.toFixed(2)]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[xs(i.inputTokens+i.outputTokens)," toks"]})]})]},i.sessionId))})]})]})]}):e.jsxs(p,{className:c("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",r),children:[e.jsx(y,{className:"px-3 py-2",children:e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Y,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-sm text-muted-foreground text-center",children:"No session data available"})})]})}function xs(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}function us({className:s,isLoading:t}){const{data:r,isLoading:n}=ye(),{data:l,isLoading:i,error:x}=Ne(r?.running);if(t||n||r?.running&&i)return e.jsxs(p,{className:c("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",s),children:[e.jsx(y,{className:"px-3 py-2",children:e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(h,{className:"h-4 w-[100px]"}),e.jsx(h,{className:"h-16 w-full"})]})})]});if(!r?.running)return e.jsxs(p,{className:c("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 border-dashed",s),children:[e.jsx(y,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4 text-muted-foreground"}),"CLIProxy Stats"]}),e.jsx(I,{variant:"secondary",className:"text-[10px] h-5",children:"Offline"})]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Start a CLIProxy session (gemini, codex, agy) to collect stats."})})]});if(x)return e.jsxs(p,{className:c("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 border-destructive/50",s),children:[e.jsx(y,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsx(I,{variant:"destructive",className:"text-[10px] h-5",children:"Error"})]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx("p",{className:"text-xs text-destructive",children:x.message})})]});const o=l?.totalRequests??0,d=l?.quotaExceededCount??0,u=o-d,m=o>0?Math.round(u/o*100):100,j=l?.tokens?.total??0,w=Object.entries(l?.requestsByModel??{}).sort((C,S)=>S[1]-C[1]).slice(0,4),v=w.length>0?w[0][1]:1;return e.jsxs(p,{className:c("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",s),children:[e.jsx(y,{className:"px-3 py-2 border-b bg-muted/5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsxs(I,{variant:"outline",className:"text-[10px] h-5 text-green-600 border-green-200 bg-green-50 dark:bg-green-900/10 dark:border-green-800",children:[e.jsx(ie,{className:"h-3 w-3 mr-0.5"}),"Running"]})]})}),e.jsx(g,{className:"p-0 flex-1 min-h-0",children:e.jsx(we,{className:"h-full",children:e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"relative",children:[e.jsxs("svg",{className:"w-10 h-10 -rotate-90",viewBox:"0 0 36 36",children:[e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"currentColor",strokeWidth:"3",className:"text-muted/30"}),e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeDasharray:`${m*.88} 88`,strokeLinecap:"round",className:m>=90?"text-green-500":"text-amber-500"})]}),e.jsxs("span",{className:"absolute inset-0 flex items-center justify-center text-[8px] font-bold",children:[m,"%"]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:J(o)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:d>0?`${d} failed`:"All success"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/30",children:[e.jsx("div",{className:"p-1.5 rounded-md bg-purple-100 dark:bg-purple-900/20",children:e.jsx(Te,{className:"h-4 w-4 text-purple-600"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:J(j)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:"Total tokens"})]})]})]}),w.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium text-muted-foreground",children:[e.jsx(Fe,{className:"h-3 w-3"}),"Models Used"]}),e.jsx("div",{className:"space-y-1",children:w.map(([C,S])=>{const B=Math.round(S/v*100),A=ms(C);return e.jsxs("div",{className:"group",children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px] mb-0.5",children:[e.jsx("span",{className:"truncate font-medium",title:C,children:A}),e.jsx("span",{className:"text-muted-foreground shrink-0 ml-2",children:S})]}),e.jsx("div",{className:"h-1 bg-muted/50 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-accent/70 rounded-full transition-all",style:{width:`${B}%`}})})]},C)})})]})]})})})]})}function J(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function ms(s){let t=s.replace(/^gemini-claude-/,"").replace(/^gemini-/,"").replace(/^claude-/,"").replace(/^anthropic\./,"").replace(/-thinking$/," Thinking");return t=t.split(/[-_]/).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" "),t.length>20&&(t=t.slice(0,18)+"..."),t}function hs(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(0)}K`:s.toString()}function fs({models:s,isLoading:t,onModelClick:r,privacyMode:n}){return e.jsxs(p,{className:"flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm lg:col-span-4",children:[e.jsx(y,{className:"px-3 py-2",children:e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(re,{className:"w-4 h-4"}),"Cost by Model"]})}),e.jsx(g,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 overflow-y-auto",children:t?e.jsx(h,{className:"h-full w-full"}):e.jsxs("div",{className:"space-y-0.5",children:[[...s||[]].sort((l,i)=>i.cost-l.cost).map(l=>e.jsxs("button",{className:"group flex items-center text-xs w-full hover:bg-muted/50 rounded px-2 py-1.5 transition-colors cursor-pointer gap-3",onClick:i=>r(l,i),title:"Click for details",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 w-[180px] shrink-0",children:[e.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:ae(l.model)}}),e.jsx("span",{className:"font-medium truncate group-hover:underline underline-offset-2",children:l.model})]}),e.jsx(ps,{model:l}),e.jsx("span",{className:c("text-[10px] text-muted-foreground w-14 text-right shrink-0",n&&N),children:hs(l.tokens)}),e.jsxs("span",{className:c("font-mono font-medium w-16 text-right shrink-0",n&&N),children:["$",l.cost.toFixed(2)]}),e.jsx(Re,{className:"w-3 h-3 opacity-0 group-hover:opacity-50 transition-opacity shrink-0"})]},l.model)),e.jsx(gs,{})]})})]})}function ps({model:s}){const t={input:"#335c67",output:"#fff3b0",cacheWrite:"#e09f3e",cacheRead:"#9e2a2b"},r=n=>s.cost>0?n/s.cost*100:0;return e.jsx("div",{className:"flex-1 flex items-center gap-1 min-w-0",children:e.jsxs("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden flex",children:[e.jsx("div",{className:"h-full",style:{backgroundColor:t.input,width:`${r(s.costBreakdown.input.cost)}%`},title:`Input: $${s.costBreakdown.input.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.output,width:`${r(s.costBreakdown.output.cost)}%`},title:`Output: $${s.costBreakdown.output.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.cacheWrite,width:`${r(s.costBreakdown.cacheCreation.cost)}%`},title:`Cache Write: $${s.costBreakdown.cacheCreation.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.cacheRead,width:`${r(s.costBreakdown.cacheRead.cost)}%`},title:`Cache Read: $${s.costBreakdown.cacheRead.cost.toFixed(2)}`})]})})}function gs(){const s=[{color:"#335c67",label:"Input"},{color:"#fff3b0",label:"Output",hasBorder:!0},{color:"#e09f3e",label:"Cache Write"},{color:"#9e2a2b",label:"Cache Read"}];return e.jsx("div",{className:"flex items-center gap-3 pt-2 px-2 text-[10px] text-muted-foreground border-t mt-2",children:s.map(({color:t,label:r,hasBorder:n})=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("div",{className:c("w-2 h-2 rounded-full",n&&"border border-muted-foreground/30"),style:{backgroundColor:t}}),r]},r))})}function js({viewMode:s,trends:t,hourlyData:r,models:n,sessions:l,isTrendsLoading:i,isHourlyLoading:x,isModelsLoading:a,isSessionsLoading:o,isSummaryLoading:d,onModelClick:u}){const{privacyMode:m}=M();return e.jsxs("div",{className:"min-h-0 grid gap-4 lg:grid-rows-[minmax(260px,1.2fr)_minmax(220px,0.9fr)]",children:[e.jsxs(p,{className:"flex flex-col h-full min-h-[220px] lg:min-h-[240px] overflow-hidden gap-0 py-0 shadow-sm",children:[e.jsx(y,{className:"px-3 py-2 shrink-0",children:e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Me,{className:"w-4 h-4"}),s==="hourly"?"Last 24 Hours":"Usage Trends"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 min-h-0",children:e.jsx(ns,{data:s==="hourly"?r||[]:t||[],isLoading:s==="hourly"?x:i,granularity:s==="hourly"?"hourly":"daily"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-10 gap-4 h-auto min-h-[220px] lg:h-full lg:min-h-[220px] lg:grid-rows-[minmax(0,1fr)] lg:[&>*]:min-h-0",children:[e.jsx(fs,{models:n,isLoading:a,onModelClick:u,privacyMode:m}),e.jsxs(p,{className:"flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm lg:col-span-2",children:[e.jsx(y,{className:"px-3 py-2",children:e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Pe,{className:"w-4 h-4"}),"Model Usage"]})}),e.jsx(g,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 flex items-center justify-center",children:e.jsx(is,{data:n||[],isLoading:a,className:"h-full w-full"})})]}),e.jsx(ds,{data:l,isLoading:o,className:"lg:col-span-2"}),e.jsx(us,{isLoading:d,className:"lg:col-span-2"})]})]})}function $s(){return e.jsxs("div",{className:"space-y-4 h-full overflow-hidden",children:[e.jsxs(p,{className:"flex flex-col min-h-[300px]",children:[e.jsx(y,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-32"})}),e.jsx(g,{className:"p-4 pt-0 flex-1",children:e.jsx(h,{className:"h-full w-full"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs(p,{className:"flex flex-col min-h-[250px]",children:[e.jsx(y,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-28"})}),e.jsx(g,{className:"p-4 pt-2",children:e.jsx("div",{className:"space-y-3",children:[1,2,3,4,5].map(s=>e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{className:"w-2.5 h-2.5 rounded-full"}),e.jsx(h,{className:"h-3 w-24"})]}),e.jsx(h,{className:"h-3 w-16"})]},s))})})]}),e.jsxs(p,{className:"flex flex-col min-h-[250px]",children:[e.jsx(y,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-28"})}),e.jsx(g,{className:"p-4 pt-0 flex-1",children:e.jsxs("div",{className:"flex w-full h-full items-center",children:[e.jsx("div",{className:"flex-1 flex justify-center",children:e.jsx(h,{className:"h-[180px] w-[180px] rounded-full"})}),e.jsx("div",{className:"w-[140px] shrink-0 pl-2 space-y-2",children:[1,2,3,4].map(s=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{className:"w-2 h-2 rounded-full"}),e.jsx(h,{className:"h-3 w-20"})]},s))})]})})]})]})]})}function Ts(){const s=f.useRef(null),{dateRange:t,handleDateRangeChange:r,handleTodayClick:n,handleRefresh:l,isRefreshing:i,lastUpdatedText:x,viewMode:a,summary:o,isSummaryLoading:d,trends:u,hourlyData:m,models:j,sessions:w,isTrendsLoading:v,isHourlyLoading:C,isModelsLoading:S,isSessionsLoading:B,handleModelClick:A,selectedModel:U,popoverPosition:q,handlePopoverClose:_}=ts();return e.jsxs("div",{className:"grid h-full min-h-0 grid-rows-[auto_auto_minmax(0,1fr)] gap-4 overflow-y-auto px-4 py-4",children:[e.jsx(rs,{dateRange:t,onDateRangeChange:r,onTodayClick:n,onRefresh:l,isRefreshing:i,lastUpdatedText:x,viewMode:a}),e.jsx(Ge,{data:o,isLoading:d}),e.jsx(js,{viewMode:a,trends:u,hourlyData:m,models:j,sessions:w,isTrendsLoading:v,isHourlyLoading:C,isModelsLoading:S,isSessionsLoading:B,isSummaryLoading:d,onModelClick:A}),e.jsxs(se,{open:!!U,onOpenChange:O=>!O&&_(),children:[e.jsx(be,{asChild:!0,children:e.jsx("div",{ref:s,className:"fixed pointer-events-none",style:{left:q?.x??0,top:q?.y??0,width:1,height:1}})}),e.jsx(te,{className:"w-80 p-3",side:"top",align:"center",children:U&&e.jsx(We,{model:U})})]})]})}export{Ts as AnalyticsPage,$s as AnalyticsSkeleton};
|
|
1
|
+
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as f,c as pe}from"./react-vendor-CNOkPC89.js";import{u as M,a as ee,C as p,b as g,S as h,c,P as N,B as I,d as H,e as se,f as ge,g as te,h as je,i as ae,j as y,k as D,l as ye,m as Ne,n as we,o as be}from"./index-Du97tqVQ.js";import{a3 as ve,al as re,am as z,an as ne,a1 as le,aa as ke,G as Ce,ao as Se,R as De,$ as Q,U as Le,Z as ie,v as $e,ad as G,ap as Te,Y as Fe,C as Re,aq as Me,ar as Pe}from"./icons-DfENUzBo.js";import{a as Be,u as P}from"./tanstack-CrmUhA7Z.js";import{K as $,L as Y,f as k,H as Ae}from"./utils-CzKF5WmX.js";import{R as oe,A as Ue,C as qe,X as Ie,Y as V,T as ce,a as Z,P as Oe,b as Ke,c as Ee}from"./charts-BBPXh0Ar.js";import"./notifications-B2HqRBj7.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function Ge({data:s,isLoading:t}){const{privacyMode:r}=M(),{t:n}=ee();if(t)return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:[1,2,3,4,5].map(a=>e.jsx(p,{children:e.jsx(g,{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{className:"h-4 w-[100px]"}),e.jsx(h,{className:"h-8 w-[80px]"})]}),e.jsx(h,{className:"h-8 w-8 rounded-lg"})]})})},a))});const l=(s?.tokenBreakdown?.cacheCreation?.cost??0)+(s?.tokenBreakdown?.cacheRead?.cost??0),i=s?.totalCost?Math.round(l/s.totalCost*100):0,x=[{title:n("analyticsSummary.totalTokens"),value:s?.totalTokens??0,icon:ve,format:a=>R(a),color:"text-blue-600",bgColor:"bg-blue-100 dark:bg-blue-900/20",subtitle:n("analyticsSummary.totalTokensSubtitle",{input:R(s?.totalInputTokens??0),output:R(s?.totalOutputTokens??0)})},{title:n("analyticsSummary.totalCost"),value:s?.totalCost??0,icon:re,format:a=>`$${a.toFixed(2)}`,color:"text-green-600",bgColor:"bg-green-100 dark:bg-green-900/20",subtitle:n("analyticsSummary.totalCostSubtitle",{value:s?.averageCostPerDay?.toFixed(2)??"0.00"})},{title:n("analyticsSummary.cacheTokens"),value:s?.totalCacheTokens??0,icon:z,format:a=>R(a),color:"text-cyan-600",bgColor:"bg-cyan-100 dark:bg-cyan-900/20",subtitle:n("analyticsSummary.cacheTokensSubtitle",{cost:l.toFixed(2),percent:i})},{title:n("analyticsSummary.inputCost"),value:s?.tokenBreakdown?.input?.cost??0,icon:ne,format:a=>`$${a.toFixed(2)}`,color:"text-purple-600",bgColor:"bg-purple-100 dark:bg-purple-900/20",subtitle:n("analyticsSummary.tokensSubtitle",{value:R(s?.tokenBreakdown?.input?.tokens??0)})},{title:n("analyticsSummary.outputCost"),value:s?.tokenBreakdown?.output?.cost??0,icon:le,format:a=>`$${a.toFixed(2)}`,color:"text-orange-600",bgColor:"bg-orange-100 dark:bg-orange-900/20",subtitle:n("analyticsSummary.tokensSubtitle",{value:R(s?.tokenBreakdown?.output?.tokens??0)})}];return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:x.map((a,o)=>{const d=a.icon;return e.jsx(p,{className:"hover:shadow-md transition-shadow",children:e.jsx(g,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between space-x-2",children:[e.jsxs("div",{className:"space-y-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground truncate",children:a.title}),e.jsx("p",{className:c("text-xl font-bold truncate",r&&N),children:a.format(a.value)}),a.subtitle&&e.jsx("p",{className:c("text-[10px] text-muted-foreground truncate",r&&N),children:a.subtitle})]}),e.jsx("div",{className:c("p-2 rounded-lg shrink-0",a.bgColor),children:e.jsx(d,{className:c("h-4 w-4",a.color)})})]})})},o)})})}function R(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function We({model:s}){const{privacyMode:t}=M(),r=He(s.ioRatio);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ke,{className:"h-4 w-4 text-primary shrink-0"}),e.jsx("h4",{className:"font-semibold leading-none truncate",title:s.model,children:s.model})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(I,{variant:"secondary",className:"text-[10px] h-5 px-1.5",children:[s.percentage.toFixed(1),"% usage"]}),e.jsxs(I,{variant:r.variant,className:"text-[10px] h-5 px-1.5",children:[s.ioRatio.toFixed(0),":1 I/O"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("p",{className:c("text-lg font-bold",t&&N),children:["$",s.cost.toFixed(2)]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Total Cost"})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsx("p",{className:c("text-lg font-bold",t&&N),children:ze(s.tokens)}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Total Tokens"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h5",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wider",children:"Token Breakdown"}),e.jsxs("div",{className:c("space-y-1",t&&N),children:[e.jsx(W,{label:"Input",tokens:s.inputTokens,cost:s.costBreakdown.input.cost,color:"#335c67",icon:ne}),e.jsx(W,{label:"Output",tokens:s.outputTokens,cost:s.costBreakdown.output.cost,color:"#fff3b0",icon:le}),e.jsx(W,{label:"Cache Write",tokens:s.cacheCreationTokens,cost:s.costBreakdown.cacheCreation.cost,color:"#e09f3e",icon:z}),e.jsx(W,{label:"Cache Read",tokens:s.cacheReadTokens,cost:s.costBreakdown.cacheRead.cost,color:"#9e2a2b",icon:z})]})]}),e.jsxs("div",{className:"p-2.5 rounded-md border bg-muted/20 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium",children:"Input/Output Ratio"})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground leading-snug",children:r.description})]})]})}function W({label:s,tokens:t,cost:r,color:n,icon:l}){return t===0?null:e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("div",{className:"w-1 h-6 rounded-full shrink-0",style:{backgroundColor:n}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium truncate",children:s}),e.jsxs("span",{className:"font-mono text-muted-foreground",children:["$",r.toFixed(3)]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[e.jsx(l,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:_e(t)})]})]})]})}function He(s){return s>=200?{variant:"destructive",description:"Extended thinking or large context loading. Expected for reasoning models."}:s>=50?{variant:"secondary",description:"More input than output. Typical for analysis tasks."}:s>=5?{variant:"outline",description:"Balanced input/output ratio for typical coding tasks."}:{variant:"default",description:"More output than input. Generation-heavy workload."}}function _e(s){return s.toLocaleString()}function ze(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}const Ye="/api";function b(s){const t=s.getFullYear(),r=String(s.getMonth()+1).padStart(2,"0"),n=String(s.getDate()).padStart(2,"0");return`${t}${r}${n}`}const T={summary:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",b(s.startDate)),s?.endDate&&t.append("until",b(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/summary?${t}`)},trends:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",b(s.startDate)),s?.endDate&&t.append("until",b(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/daily?${t}`)},hourly:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",b(s.startDate)),s?.endDate&&t.append("until",b(s.endDate)),L(`/usage/hourly?${t}`)},models:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",b(s.startDate)),s?.endDate&&t.append("until",b(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/models?${t}`)},sessions:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",b(s.startDate)),s?.endDate&&t.append("until",b(s.endDate)),s?.profile&&t.append("profile",s.profile),s?.limit&&t.append("limit",s.limit.toString()),s?.offset&&t.append("offset",s.offset.toString()),L(`/usage/sessions?${t}`)},monthly:(s,t)=>{const r=new URLSearchParams;return s&&r.append("months",s.toString()),t&&r.append("profile",t),L(`/usage/monthly?${r}`)},refresh:async()=>{if(!(await fetch(`${Ye}/usage/refresh`,{method:"POST",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to refresh usage cache")},status:()=>L("/usage/status"),insights:s=>{const t=new URLSearchParams;return s?.startDate&&t.append("since",b(s.startDate)),s?.endDate&&t.append("until",b(s.endDate)),s?.profile&&t.append("profile",s.profile),L(`/usage/insights?${t}`)}};async function L(s){const r=await fetch(`/api${s}`,{headers:{"Content-Type":"application/json"}});if(!r.ok){const l=await r.json().catch(()=>({error:"Unknown error"}));throw new Error(l.error||r.statusText)}const n=await r.json();return n.data||n}function Qe(s){return P({queryKey:["usage","summary",s],queryFn:()=>T.summary(s),staleTime:60*1e3})}function Ve(s){return P({queryKey:["usage","trends",s],queryFn:()=>T.trends(s),staleTime:60*1e3})}function Ze(s){return P({queryKey:["usage","hourly",s],queryFn:()=>T.hourly(s),staleTime:60*1e3})}function Xe(s){return P({queryKey:["usage","models",s],queryFn:()=>T.models(s),staleTime:60*1e3})}function Je(){const s=Be();return f.useCallback(async()=>{await T.refresh(),await s.invalidateQueries({queryKey:["usage"]})},[s])}function es(){return P({queryKey:["usage","status"],queryFn:()=>T.status(),staleTime:10*1e3,refetchInterval:30*1e3})}function ss(s){return P({queryKey:["usage","sessions",s],queryFn:()=>T.sessions(s),staleTime:60*1e3})}function ts(){const[s,t]=f.useState({from:$(new Date,30),to:new Date}),[r,n]=f.useState(!1),[l,i]=f.useState(null),[x,a]=f.useState(null),[o,d]=f.useState("daily"),u=Je(),m=f.useCallback(async()=>{n(!0);try{await u()}finally{n(!1)}},[u]),j=f.useMemo(()=>({startDate:s?.from,endDate:s?.to}),[s?.from,s?.to]),{data:w,isLoading:v}=Qe(j),{data:C,isLoading:S}=Ve(j),{data:B,isLoading:A}=Ze(j),{data:U,isLoading:q}=Xe(j),{data:_,isLoading:O}=ss({...j,limit:3}),{data:K}=es(),de=f.useCallback(()=>{const F=new Date;t({from:$(F,1),to:F}),d("hourly")},[]),xe=f.useCallback(F=>{t(F),d("daily")},[]),ue=f.useMemo(()=>K?.lastFetch?Y(new Date(K.lastFetch),{addSuffix:!0}):null,[K?.lastFetch]),me=f.useCallback((F,fe)=>{const E=fe.currentTarget.getBoundingClientRect();a({x:E.left+E.width/2,y:E.top+E.height/2}),i(F)},[]),he=f.useCallback(()=>{i(null),a(null)},[]);return{dateRange:s,isRefreshing:r,viewMode:o,selectedModel:l,popoverPosition:x,summary:w,trends:C,hourlyData:B,models:U,sessions:_,status:K,isSummaryLoading:v,isTrendsLoading:S,isHourlyLoading:A,isModelsLoading:q,isSessionsLoading:O,isLoading:v||S||q||O,handleRefresh:m,handleTodayClick:de,handleDateRangeChange:xe,handleModelClick:me,handlePopoverClose:he,lastUpdatedText:ue}}function as({value:s,onChange:t,presets:r=[{label:"Last 7 days",range:{from:$(new Date,7),to:new Date}},{label:"Last 30 days",range:{from:$(new Date,30),to:new Date}},{label:"Last 90 days",range:{from:$(new Date,90),to:new Date}}],className:n}){const[l,i]=pe.useState(!1),x=a=>!s||!s.from||!s.to||!a.from||!a.to?!1:k(s.from,"yyyy-MM-dd")===k(a.from,"yyyy-MM-dd")&&k(s.to,"yyyy-MM-dd")===k(a.to,"yyyy-MM-dd");return e.jsxs("div",{className:c("flex flex-wrap items-center gap-2",n),children:[r.map(a=>e.jsx(H,{variant:x(a.range)?"default":"outline",size:"sm",onClick:()=>t(a.range),children:a.label},a.label)),e.jsxs(se,{open:l,onOpenChange:i,children:[e.jsx(ge,{asChild:!0,children:e.jsxs(H,{id:"date",variant:"outline",className:c("w-auto min-w-[200px] sm:min-w-[240px] justify-start text-left font-normal",!s&&"text-muted-foreground"),children:[e.jsx(Se,{className:"mr-2 h-4 w-4"}),s?.from?s.to?e.jsxs(e.Fragment,{children:[k(s.from,"LLL dd, y")," - ",k(s.to,"LLL dd, y")]}):k(s.from,"LLL dd, y"):e.jsx("span",{children:"Pick a date"})]})}),e.jsx(te,{className:"w-auto p-0",align:"end",children:e.jsx(je,{initialFocus:!0,mode:"range",defaultMonth:s?.from,selected:s,onSelect:t,numberOfMonths:2})})]})]})}function rs({dateRange:s,onDateRangeChange:t,onTodayClick:r,onRefresh:n,isRefreshing:l,lastUpdatedText:i,viewMode:x}){const{t:a}=ee();return e.jsxs("div",{className:"flex flex-col gap-3 shrink-0 xl:flex-row xl:items-center xl:justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold",children:a("analytics.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a("analytics.subtitle")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 xl:justify-end",children:[e.jsx(H,{variant:x==="hourly"?"default":"outline",size:"sm",className:"h-8",onClick:r,children:"24H"}),e.jsx(as,{className:"flex-wrap",value:s,onChange:t,presets:[{label:"7D",range:{from:$(new Date,7),to:new Date}},{label:"30D",range:{from:$(new Date,30),to:new Date}},{label:a("analytics.month"),range:{from:Ae(new Date),to:new Date}},{label:a("analytics.allTime"),range:{from:void 0,to:new Date}}]}),i&&e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:a("analytics.updated",{value:i})}),e.jsx(H,{variant:"outline",size:"sm",className:"gap-2 h-8",onClick:n,disabled:l,children:e.jsx(De,{className:`w-3.5 h-3.5 ${l?"animate-spin":""}`})})]})]})}function ns({data:s,isLoading:t,granularity:r="daily",className:n}){const{privacyMode:l}=M(),i=f.useMemo(()=>!s||s.length===0?[]:(r==="hourly"?s:[...s].reverse()).map(o=>{const d="hour"in o?o.hour:o.date;return{...o,dateFormatted:ls(d,r),costRounded:Number(o.cost.toFixed(4))}}),[s,r]);if(t)return e.jsx(h,{className:c("h-full w-full",n)});if(!s||s.length===0)return e.jsx("div",{className:c("h-full flex items-center justify-center",n),children:e.jsx("p",{className:"text-muted-foreground",children:r==="hourly"?"No usage data for today":"No usage data available"})});const x=({x:a,y:o,payload:d,isRight:u})=>{const m=u?`$${d.value}`:X(Number(d.value));return e.jsx("text",{x:a,y:o,dy:4,textAnchor:u?"start":"end",fontSize:12,fill:"currentColor",className:c("fill-muted-foreground",l&&"blur-[4px]"),children:m})};return e.jsx("div",{className:c("w-full h-full",n),children:e.jsx(oe,{width:"100%",height:"100%",children:e.jsxs(Ue,{data:i,margin:{top:5,right:30,left:20,bottom:5},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"tokenGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#0080FF",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#0080FF",stopOpacity:.1})]}),e.jsxs("linearGradient",{id:"costGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#00C49F",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#00C49F",stopOpacity:.1})]})]}),e.jsx(qe,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(Ie,{dataKey:"dateFormatted",tick:{fontSize:12},tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(V,{yAxisId:"left",orientation:"left",tick:a=>e.jsx(x,{...a,isRight:!1}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(V,{yAxisId:"right",orientation:"right",tick:a=>e.jsx(x,{...a,isRight:!0}),tickLine:!1,axisLine:{className:"stroke-muted"}}),e.jsx(ce,{content:({active:a,payload:o,label:d})=>{if(!a||!o||!o.length)return null;const u=o[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-3 shadow-lg",children:[e.jsx("p",{className:"font-medium mb-2",children:d}),o.map((m,j)=>e.jsxs("p",{className:c("text-sm",l&&N),style:{color:m.color},children:[m.name,":"," ",m.name==="Tokens"?X(Number(m.value)||0):`$${m.value}`]},j)),"requests"in u&&e.jsxs("p",{className:c("text-sm text-muted-foreground mt-1",l&&N),children:["Requests: ",u.requests]})]})}}),e.jsx(Z,{yAxisId:"left",type:"monotone",dataKey:"tokens",stroke:"#0080FF",strokeWidth:2,fillOpacity:1,fill:"url(#tokenGradient)",name:"Tokens"}),e.jsx(Z,{yAxisId:"right",type:"monotone",dataKey:"costRounded",stroke:"#00C49F",strokeWidth:2,fillOpacity:1,fill:"url(#costGradient)",name:"Cost"})]})})})}function ls(s,t){if(t==="hourly"){const[n,l]=s.split(" ");if(n&&l){const i=new Date(`${n}T${l}:00Z`);return k(i,"HH:mm")}return s}const r=new Date(s);return t==="monthly"?k(r,"MMM yyyy"):k(r,"MMM dd")}function X(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function is({data:s,isLoading:t,className:r}){const{privacyMode:n}=M(),l=f.useMemo(()=>!s||s.length===0?[]:s.map(a=>({name:a.model,value:a.tokens,cost:a.cost,percentage:a.percentage,fill:ae(a.model)})),[s]);if(t)return e.jsx(h,{className:c("h-full min-h-[100px] w-full",r)});if(!s||s.length===0)return e.jsx("div",{className:c("h-full min-h-[100px] flex items-center justify-center",r),children:e.jsx("p",{className:"text-muted-foreground",children:"No model data available"})});const i=({active:a,payload:o})=>{if(!a||!o)return null;const d=o;if(!d.length)return null;const u=d[0].payload;return e.jsxs("div",{className:"rounded-lg border bg-background p-2 shadow-lg text-xs",children:[e.jsx("p",{className:"font-medium mb-1",children:u.name}),e.jsxs("p",{className:c("text-muted-foreground",n&&N),children:[os(u.value)," (",u.percentage.toFixed(1),"%)"]}),e.jsxs("p",{className:c("text-muted-foreground",n&&N),children:["$",u.cost.toFixed(4)]})]})},x=a=>a.percentage>5?`${a.percentage.toFixed(1)}%`:"";return e.jsx("div",{className:c("w-full h-full min-h-[100px]",r),children:e.jsx(oe,{width:"100%",height:"100%",children:e.jsxs(Oe,{children:[e.jsx(Ke,{data:l,cx:"50%",cy:"50%",labelLine:!1,label:x,innerRadius:50,outerRadius:70,paddingAngle:2,dataKey:"value",children:l.map((a,o)=>e.jsx(Ee,{fill:a.fill,strokeWidth:1},`cell-${o}`))}),e.jsx(ce,{content:i})]})})})}function os(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function cs(s){if(!s)return"";const r=s.replace(/^\/|\/$/g,"").split("/").filter(n=>n.length>0);return r[r.length-1]||""}function ds({data:s,isLoading:t,className:r}){const{privacyMode:n}=M(),l=f.useMemo(()=>{if(!s?.sessions||s.sessions.length===0)return null;const i=s.sessions,x=s.total,a=i.reduce((w,v)=>w+(v.inputTokens+v.outputTokens),0),o=Math.round(a/i.length),u=i.reduce((w,v)=>w+v.cost,0)/i.length,m=i[0],j=m?Y(new Date(m.lastActivity),{addSuffix:!0}):"N/A";return{totalSessions:x,avgTokens:o,avgCost:u,lastActive:j,recentSessions:i.slice(0,3)}},[s]);return t?e.jsxs(p,{className:c("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",r),children:[e.jsx(y,{className:"px-3 py-2",children:e.jsx(h,{className:"h-5 w-32"})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx(h,{className:"h-full w-full"})})]}):l?e.jsxs(p,{className:c("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm",r),children:[e.jsx(y,{className:"px-3 py-2",children:e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Q,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsxs(g,{className:"px-3 pb-3 pt-0 flex-1 min-h-0 flex flex-col gap-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-blue-600 dark:text-blue-400",children:[e.jsx(Le,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xl font-bold",children:l.totalSessions})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:"Total Sessions"})]}),e.jsxs("div",{className:"p-2 rounded-md bg-muted/50 border text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-green-600 dark:text-green-400",children:[e.jsx(ie,{className:"w-4 h-4"}),e.jsxs("span",{className:c("text-xl font-bold",n&&N),children:["$",l.avgCost.toFixed(2)]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-0.5",children:"Avg Cost/Session"})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground font-medium mb-1",children:[e.jsx($e,{className:"w-3 h-3"}),"Recent Activity"]}),e.jsx("div",{className:"space-y-1.5 max-h-full overflow-y-auto pr-1",children:l.recentSessions.map(i=>e.jsxs("div",{className:"flex items-center justify-between text-xs p-1.5 rounded bg-muted/30 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"font-medium truncate",title:i.projectPath,children:cs(i.projectPath)}),(i.target??"claude")!=="claude"&&e.jsx("span",{className:"shrink-0 px-1 py-0 text-[9px] font-medium rounded bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-300 uppercase",children:i.target})]}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:Y(new Date(i.lastActivity),{addSuffix:!0})})]}),e.jsxs("div",{className:c("text-right shrink-0 ml-2",n&&N),children:[e.jsxs("div",{className:"font-mono",children:["$",i.cost.toFixed(2)]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[xs(i.inputTokens+i.outputTokens)," toks"]})]})]},i.sessionId))})]})]})]}):e.jsxs(p,{className:c("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",r),children:[e.jsx(y,{className:"px-3 py-2",children:e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Q,{className:"w-4 h-4"}),"Session Stats"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-sm text-muted-foreground text-center",children:"No session data available"})})]})}function xs(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}function us({className:s,isLoading:t}){const{data:r,isLoading:n}=ye(),{data:l,isLoading:i,error:x}=Ne(r?.running);if(t||n||r?.running&&i)return e.jsxs(p,{className:c("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",s),children:[e.jsx(y,{className:"px-3 py-2",children:e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(h,{className:"h-4 w-[100px]"}),e.jsx(h,{className:"h-16 w-full"})]})})]});if(!r?.running)return e.jsxs(p,{className:c("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 border-dashed",s),children:[e.jsx(y,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4 text-muted-foreground"}),"CLIProxy Stats"]}),e.jsx(I,{variant:"secondary",className:"text-[10px] h-5",children:"Offline"})]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Start a CLIProxy session (gemini, codex, agy) to collect stats."})})]});if(x)return e.jsxs(p,{className:c("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 border-destructive/50",s),children:[e.jsx(y,{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsx(I,{variant:"destructive",className:"text-[10px] h-5",children:"Error"})]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1",children:e.jsx("p",{className:"text-xs text-destructive",children:x.message})})]});const o=l?.totalRequests??0,d=l?.quotaExceededCount??0,u=o-d,m=o>0?Math.round(u/o*100):100,j=l?.tokens?.total??0,w=Object.entries(l?.requestsByModel??{}).sort((C,S)=>S[1]-C[1]).slice(0,4),v=w.length>0?w[0][1]:1;return e.jsxs(p,{className:c("flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0",s),children:[e.jsx(y,{className:"px-3 py-2 border-b bg-muted/5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"CLIProxy Stats"]}),e.jsxs(I,{variant:"outline",className:"text-[10px] h-5 text-green-600 border-green-200 bg-green-50 dark:bg-green-900/10 dark:border-green-800",children:[e.jsx(ie,{className:"h-3 w-3 mr-0.5"}),"Running"]})]})}),e.jsx(g,{className:"p-0 flex-1 min-h-0",children:e.jsx(we,{className:"h-full",children:e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"relative",children:[e.jsxs("svg",{className:"w-10 h-10 -rotate-90",viewBox:"0 0 36 36",children:[e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"currentColor",strokeWidth:"3",className:"text-muted/30"}),e.jsx("circle",{cx:"18",cy:"18",r:"14",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeDasharray:`${m*.88} 88`,strokeLinecap:"round",className:m>=90?"text-green-500":"text-amber-500"})]}),e.jsxs("span",{className:"absolute inset-0 flex items-center justify-center text-[8px] font-bold",children:[m,"%"]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:J(o)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:d>0?`${d} failed`:"All success"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/30",children:[e.jsx("div",{className:"p-1.5 rounded-md bg-purple-100 dark:bg-purple-900/20",children:e.jsx(Te,{className:"h-4 w-4 text-purple-600"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-bold leading-none",children:J(j)}),e.jsx("div",{className:"text-[9px] text-muted-foreground mt-0.5",children:"Total tokens"})]})]})]}),w.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium text-muted-foreground",children:[e.jsx(Fe,{className:"h-3 w-3"}),"Models Used"]}),e.jsx("div",{className:"space-y-1",children:w.map(([C,S])=>{const B=Math.round(S/v*100),A=ms(C);return e.jsxs("div",{className:"group",children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px] mb-0.5",children:[e.jsx("span",{className:"truncate font-medium",title:C,children:A}),e.jsx("span",{className:"text-muted-foreground shrink-0 ml-2",children:S})]}),e.jsx("div",{className:"h-1 bg-muted/50 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-accent/70 rounded-full transition-all",style:{width:`${B}%`}})})]},C)})})]})]})})})]})}function J(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function ms(s){let t=s.replace(/^gemini-claude-/,"").replace(/^gemini-/,"").replace(/^claude-/,"").replace(/^anthropic\./,"").replace(/-thinking$/," Thinking");return t=t.split(/[-_]/).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" "),t.length>20&&(t=t.slice(0,18)+"..."),t}function hs(s){return s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(0)}K`:s.toString()}function fs({models:s,isLoading:t,onModelClick:r,privacyMode:n}){return e.jsxs(p,{className:"flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm lg:col-span-4",children:[e.jsx(y,{className:"px-3 py-2",children:e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(re,{className:"w-4 h-4"}),"Cost by Model"]})}),e.jsx(g,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 overflow-y-auto",children:t?e.jsx(h,{className:"h-full w-full"}):e.jsxs("div",{className:"space-y-0.5",children:[[...s||[]].sort((l,i)=>i.cost-l.cost).map(l=>e.jsxs("button",{className:"group flex items-center text-xs w-full hover:bg-muted/50 rounded px-2 py-1.5 transition-colors cursor-pointer gap-3",onClick:i=>r(l,i),title:"Click for details",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 w-[180px] shrink-0",children:[e.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:ae(l.model)}}),e.jsx("span",{className:"font-medium truncate group-hover:underline underline-offset-2",children:l.model})]}),e.jsx(ps,{model:l}),e.jsx("span",{className:c("text-[10px] text-muted-foreground w-14 text-right shrink-0",n&&N),children:hs(l.tokens)}),e.jsxs("span",{className:c("font-mono font-medium w-16 text-right shrink-0",n&&N),children:["$",l.cost.toFixed(2)]}),e.jsx(Re,{className:"w-3 h-3 opacity-0 group-hover:opacity-50 transition-opacity shrink-0"})]},l.model)),e.jsx(gs,{})]})})]})}function ps({model:s}){const t={input:"#335c67",output:"#fff3b0",cacheWrite:"#e09f3e",cacheRead:"#9e2a2b"},r=n=>s.cost>0?n/s.cost*100:0;return e.jsx("div",{className:"flex-1 flex items-center gap-1 min-w-0",children:e.jsxs("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden flex",children:[e.jsx("div",{className:"h-full",style:{backgroundColor:t.input,width:`${r(s.costBreakdown.input.cost)}%`},title:`Input: $${s.costBreakdown.input.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.output,width:`${r(s.costBreakdown.output.cost)}%`},title:`Output: $${s.costBreakdown.output.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.cacheWrite,width:`${r(s.costBreakdown.cacheCreation.cost)}%`},title:`Cache Write: $${s.costBreakdown.cacheCreation.cost.toFixed(2)}`}),e.jsx("div",{className:"h-full",style:{backgroundColor:t.cacheRead,width:`${r(s.costBreakdown.cacheRead.cost)}%`},title:`Cache Read: $${s.costBreakdown.cacheRead.cost.toFixed(2)}`})]})})}function gs(){const s=[{color:"#335c67",label:"Input"},{color:"#fff3b0",label:"Output",hasBorder:!0},{color:"#e09f3e",label:"Cache Write"},{color:"#9e2a2b",label:"Cache Read"}];return e.jsx("div",{className:"flex items-center gap-3 pt-2 px-2 text-[10px] text-muted-foreground border-t mt-2",children:s.map(({color:t,label:r,hasBorder:n})=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("div",{className:c("w-2 h-2 rounded-full",n&&"border border-muted-foreground/30"),style:{backgroundColor:t}}),r]},r))})}function js({viewMode:s,trends:t,hourlyData:r,models:n,sessions:l,isTrendsLoading:i,isHourlyLoading:x,isModelsLoading:a,isSessionsLoading:o,isSummaryLoading:d,onModelClick:u}){const{privacyMode:m}=M();return e.jsxs("div",{className:"min-h-0 grid gap-4 lg:grid-rows-[minmax(260px,1.2fr)_minmax(220px,0.9fr)]",children:[e.jsxs(p,{className:"flex flex-col h-full min-h-[220px] lg:min-h-[240px] overflow-hidden gap-0 py-0 shadow-sm",children:[e.jsx(y,{className:"px-3 py-2 shrink-0",children:e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Me,{className:"w-4 h-4"}),s==="hourly"?"Last 24 Hours":"Usage Trends"]})}),e.jsx(g,{className:"px-3 pb-3 pt-0 flex-1 min-h-0",children:e.jsx(ns,{data:s==="hourly"?r||[]:t||[],isLoading:s==="hourly"?x:i,granularity:s==="hourly"?"hourly":"daily"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-10 gap-4 h-auto min-h-[220px] lg:h-full lg:min-h-[220px] lg:grid-rows-[minmax(0,1fr)] lg:[&>*]:min-h-0",children:[e.jsx(fs,{models:n,isLoading:a,onModelClick:u,privacyMode:m}),e.jsxs(p,{className:"flex flex-col h-full min-h-0 overflow-hidden gap-0 py-0 shadow-sm lg:col-span-2",children:[e.jsx(y,{className:"px-3 py-2",children:e.jsxs(D,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Pe,{className:"w-4 h-4"}),"Model Usage"]})}),e.jsx(g,{className:"px-2 pb-2 pt-0 flex-1 min-h-0 flex items-center justify-center",children:e.jsx(is,{data:n||[],isLoading:a,className:"h-full w-full"})})]}),e.jsx(ds,{data:l,isLoading:o,className:"lg:col-span-2"}),e.jsx(us,{isLoading:d,className:"lg:col-span-2"})]})]})}function $s(){return e.jsxs("div",{className:"space-y-4 h-full overflow-hidden",children:[e.jsxs(p,{className:"flex flex-col min-h-[300px]",children:[e.jsx(y,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-32"})}),e.jsx(g,{className:"p-4 pt-0 flex-1",children:e.jsx(h,{className:"h-full w-full"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs(p,{className:"flex flex-col min-h-[250px]",children:[e.jsx(y,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-28"})}),e.jsx(g,{className:"p-4 pt-2",children:e.jsx("div",{className:"space-y-3",children:[1,2,3,4,5].map(s=>e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{className:"w-2.5 h-2.5 rounded-full"}),e.jsx(h,{className:"h-3 w-24"})]}),e.jsx(h,{className:"h-3 w-16"})]},s))})})]}),e.jsxs(p,{className:"flex flex-col min-h-[250px]",children:[e.jsx(y,{className:"p-4 pb-2",children:e.jsx(h,{className:"h-4 w-28"})}),e.jsx(g,{className:"p-4 pt-0 flex-1",children:e.jsxs("div",{className:"flex w-full h-full items-center",children:[e.jsx("div",{className:"flex-1 flex justify-center",children:e.jsx(h,{className:"h-[180px] w-[180px] rounded-full"})}),e.jsx("div",{className:"w-[140px] shrink-0 pl-2 space-y-2",children:[1,2,3,4].map(s=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{className:"w-2 h-2 rounded-full"}),e.jsx(h,{className:"h-3 w-20"})]},s))})]})})]})]})]})}function Ts(){const s=f.useRef(null),{dateRange:t,handleDateRangeChange:r,handleTodayClick:n,handleRefresh:l,isRefreshing:i,lastUpdatedText:x,viewMode:a,summary:o,isSummaryLoading:d,trends:u,hourlyData:m,models:j,sessions:w,isTrendsLoading:v,isHourlyLoading:C,isModelsLoading:S,isSessionsLoading:B,handleModelClick:A,selectedModel:U,popoverPosition:q,handlePopoverClose:_}=ts();return e.jsxs("div",{className:"grid h-full min-h-0 grid-rows-[auto_auto_minmax(0,1fr)] gap-4 overflow-y-auto px-4 py-4",children:[e.jsx(rs,{dateRange:t,onDateRangeChange:r,onTodayClick:n,onRefresh:l,isRefreshing:i,lastUpdatedText:x,viewMode:a}),e.jsx(Ge,{data:o,isLoading:d}),e.jsx(js,{viewMode:a,trends:u,hourlyData:m,models:j,sessions:w,isTrendsLoading:v,isHourlyLoading:C,isModelsLoading:S,isSessionsLoading:B,isSummaryLoading:d,onModelClick:A}),e.jsxs(se,{open:!!U,onOpenChange:O=>!O&&_(),children:[e.jsx(be,{asChild:!0,children:e.jsx("div",{ref:s,className:"fixed pointer-events-none",style:{left:q?.x??0,top:q?.y??0,width:1,height:1}})}),e.jsx(te,{className:"w-80 p-3",side:"top",align:"center",children:U&&e.jsx(We,{model:U})})]})]})}export{Ts as AnalyticsPage,$s as AnalyticsSkeleton};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as c,L as ne}from"./react-vendor-CNOkPC89.js";import{c as n,L as b,aF as O,r as de,s as oe,t as ce,v as me,w,I as R,d as f,n as C,Q as G,R as J,U as _,V as E,Y as L,C as y,j as k,S as x,b as T,bh as xe}from"./index-CUOLpSIB.js";import{a6 as ue,aC as pe,as as ge,O as he,A as D,_ as z,al as P,Y as be,az as fe,aW as ve,V as je,ag as Ne,L as ye,aX as we,a5 as Z,Z as M,at as ke,aY as Se,i as Le,R as X,d as A,aZ as Ce,af as $,C as ee}from"./icons-C4EMu2PL.js";import{u as F,a as _e,b as Ee,k as Ie}from"./tanstack-CrmUhA7Z.js";import{t as q}from"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function W(r,s){const t=Number.parseInt(r,10);return Number.isNaN(t)?s:Math.max(0,t)}function K({config:r,onSave:s,isPending:t}){const[d,o]=c.useState(r);c.useEffect(()=>{o(r)},[r]);const m=c.useMemo(()=>JSON.stringify(d)!==JSON.stringify(r),[r,d]);return e.jsxs("div",{className:"group relative overflow-hidden rounded-2xl border-2 border-border/60 bg-card/40 p-1 shadow-lg transition-all hover:border-border",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border bg-muted/30 px-5 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-lg bg-primary/5 border border-primary/20",children:e.jsx(ue,{className:"h-3.5 w-3.5 text-primary"})}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("h3",{className:"text-[11px] font-semibold uppercase tracking-[0.14em] text-foreground",children:"Logging Policy"}),e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.1em] text-foreground/45",children:"Retention and privacy"})]})]}),e.jsx("div",{className:n("h-1.5 w-1.5 rounded-full",r.enabled?"bg-emerald-500 shadow-[0_0_8px_rgba(16,185,129,0.5)]":"bg-zinc-500")})]}),e.jsxs("div",{className:"space-y-6 p-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"rounded-xl border border-border/40 bg-background/50 p-3 flex flex-col gap-1",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.12em] text-muted-foreground/70",children:"Active Status"}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:n("text-[11px] font-semibold uppercase tracking-[0.1em]",r.enabled?"text-emerald-500":"text-zinc-500"),children:r.enabled?"Live":"Off"})})]}),e.jsxs("div",{className:"rounded-xl border border-border/40 bg-background/50 p-3 flex flex-col gap-1",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.12em] text-muted-foreground/70",children:"Redaction"}),e.jsx("span",{className:n("text-[11px] font-semibold uppercase tracking-[0.1em]",r.redact?"text-primary":"text-muted-foreground/40"),children:r.redact?"Enforced":"Plain"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-xl border border-border/40 bg-background/20 px-4 py-3 transition-colors hover:bg-background/40",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{htmlFor:"logs-enabled",className:"text-[12px] font-semibold uppercase tracking-[0.12em]",children:"Pipeline"}),e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground/55",children:"Enable structured logging"})]}),e.jsx(O,{id:"logs-enabled",checked:d.enabled,onCheckedChange:a=>o(l=>({...l,enabled:a})),className:"data-[state=checked]:bg-primary"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-xl border border-border/40 bg-background/20 px-4 py-3 transition-colors hover:bg-background/40",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{htmlFor:"logs-redact",className:"text-[12px] font-semibold uppercase tracking-[0.12em]",children:"Masking"}),e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground/55",children:"Sanitize payload data"})]}),e.jsx(O,{id:"logs-redact",checked:d.redact,onCheckedChange:a=>o(l=>({...l,redact:a})),className:"data-[state=checked]:bg-primary"})]})]}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 px-1",children:[e.jsx(pe,{className:"h-3 w-3 text-primary/40"}),e.jsx(b,{htmlFor:"logs-config-level",className:"text-[10px] font-semibold uppercase tracking-[0.12em] text-foreground/70",children:"Minimum Operational Threshold"})]}),e.jsxs(de,{value:d.level,onValueChange:a=>o(l=>({...l,level:a})),children:[e.jsx(oe,{id:"logs-config-level",className:"h-10 rounded-xl border-2 border-border/40 bg-background/50 text-[12px] font-semibold uppercase tracking-[0.1em] focus:ring-0",children:e.jsx(ce,{})}),e.jsxs(me,{className:"border-2 border-border bg-card",children:[e.jsx(w,{value:"error",className:"text-[11px] font-semibold uppercase tracking-[0.1em]",children:"Error Only"}),e.jsx(w,{value:"warn",className:"text-[11px] font-semibold uppercase tracking-[0.1em]",children:"Warn + Above"}),e.jsx(w,{value:"info",className:"text-[11px] font-semibold uppercase tracking-[0.1em]",children:"Info + Above"}),e.jsx(w,{value:"debug",className:"text-[11px] font-semibold uppercase tracking-[0.1em]",children:"Full Debug"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"logs-rotate-mb",className:"px-1 text-[10px] font-semibold uppercase tracking-[0.1em] text-foreground/50",children:"Rotation (MB)"}),e.jsx(R,{id:"logs-rotate-mb",type:"number",min:1,className:"h-10 rounded-xl border-2 border-border/40 bg-background/50 font-mono text-[12px] font-medium focus-visible:ring-0",value:d.rotate_mb,onChange:a=>o(l=>({...l,rotate_mb:W(a.target.value,l.rotate_mb)}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"logs-retain-days",className:"px-1 text-[10px] font-semibold uppercase tracking-[0.1em] text-foreground/50",children:"Retain (Days)"}),e.jsx(R,{id:"logs-retain-days",type:"number",min:1,className:"h-10 rounded-xl border-2 border-border/40 bg-background/50 font-mono text-[12px] font-medium focus-visible:ring-0",value:d.retain_days,onChange:a=>o(l=>({...l,retain_days:W(a.target.value,l.retain_days)}))})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 pt-4 border-t border-border",children:[e.jsxs(f,{onClick:()=>s(d),disabled:!m||t,className:"h-10 w-full gap-2 rounded-xl bg-primary text-[11px] font-semibold uppercase tracking-[0.14em] shadow-lg shadow-primary/20 transition-all hover:scale-[1.02] active:scale-[0.98]",children:[e.jsx(ge,{className:"h-3.5 w-3.5"}),"Commit Changes"]}),e.jsxs(f,{variant:"ghost",onClick:()=>o(r),disabled:!m||t,className:"h-9 gap-2 text-[10px] font-medium uppercase tracking-[0.12em] text-foreground/45 hover:text-foreground",children:[e.jsx(he,{className:"h-3 w-3"}),"Rollback Draft"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between bg-muted/20 px-5 py-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(D,{className:"h-2.5 w-2.5 text-primary/40"}),e.jsx("span",{className:"text-[9px] font-medium uppercase tracking-[0.12em] text-foreground/30",children:"Operational Logic v3.4"})]}),m&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"h-1 w-1 rounded-full bg-amber-500 animate-pulse"}),e.jsx("span",{className:"text-[9px] font-medium uppercase tracking-[0.12em] text-amber-500/70",children:"Pending"})]})]})]})}function Fe(r){if(r==null)return"{}";try{return JSON.stringify(r,null,2)}catch{return String(r)}}function Qe(r){switch(r){case"error":return"Error";case"warn":return"Warn";case"info":return"Info";case"debug":return"Debug"}}const Re={error:"border-red-500/30 bg-red-500/10 text-red-700 dark:text-red-300",warn:"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300",info:"border-sky-500/30 bg-sky-500/10 text-sky-700 dark:text-sky-300",debug:"border-zinc-500/30 bg-zinc-500/10 text-zinc-700 dark:text-zinc-300"};function re({level:r,className:s}){return e.jsx("span",{className:n("inline-flex items-center rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase tracking-[0.12em]",Re[r],s),children:Qe(r)})}function S({label:r,value:s,icon:t}){return e.jsxs("div",{className:"group relative flex flex-col gap-1.5 rounded-xl border border-border/40 bg-background/40 p-3 transition-all hover:bg-background/80 hover:shadow-lg hover:shadow-black/5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[t&&e.jsx(t,{className:"h-3 w-3 text-primary/40 group-hover:text-primary transition-colors"}),e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.12em] text-muted-foreground/70 transition-colors group-hover:text-primary/60",children:r})]}),e.jsx("div",{className:"h-1 w-1 rounded-full bg-border/40 group-hover:bg-primary/40 transition-colors"})]}),e.jsx("p",{className:"truncate font-mono text-[13px] font-medium tracking-tight text-foreground/85 transition-colors group-hover:text-foreground",children:s})]})}function V({entry:r,sourceLabel:s}){return r?e.jsxs("div",{className:"flex h-full flex-col bg-card/30 backdrop-blur-sm animate-in fade-in slide-in-from-right-4 duration-500",children:[e.jsxs("div",{className:"relative shrink-0 border-b border-border bg-card/60 p-6 shadow-sm overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-[0.03] pointer-events-none [background-image:radial-gradient(circle_at_center,var(--primary)_1px,transparent_0)] [background-size:16px_16px]"}),e.jsxs("div",{className:"relative space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(re,{level:r.level,className:"h-5 px-3 shadow-lg shadow-black/5"}),e.jsx("div",{className:"h-4 w-px bg-border/60"}),e.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-border bg-background/50 px-3 py-1 shadow-inner",children:[e.jsx(P,{className:"h-3 w-3 text-primary/60"}),e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-foreground/75",children:s??r.source})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{className:"h-3 w-3 animate-pulse text-emerald-500"}),e.jsx("span",{className:"font-mono text-[11px] font-medium uppercase tracking-[0.12em] text-muted-foreground/45",children:new Date(r.timestamp).toLocaleTimeString(void 0,{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-1 w-4 rounded-full bg-primary/40"}),e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.12em] text-primary/65",children:"Event"})]}),e.jsx("h2",{className:"text-[24px] font-semibold tracking-tight text-foreground leading-tight break-words",children:r.event}),e.jsx("div",{className:"rounded-xl border-l-4 border-primary/20 bg-muted/20 p-4 shadow-inner",children:e.jsx("p",{className:"text-[14px] font-medium leading-relaxed text-foreground/85 selection:bg-primary/20",children:r.message})})]})]})]}),e.jsx(C,{className:"flex-1",children:e.jsx("div",{className:"p-6",children:e.jsxs(G,{defaultValue:"details",className:"space-y-8",children:[e.jsxs(J,{className:"grid h-auto w-full grid-cols-2 gap-1 rounded-xl border border-border/60 bg-muted/40 p-1",children:[e.jsxs(_,{value:"details",className:"min-w-0 gap-2 rounded-lg px-3 py-2 text-[11px] font-semibold uppercase tracking-[0.1em] transition-all data-[state=active]:bg-background data-[state=active]:text-primary data-[state=active]:shadow-sm",children:[e.jsx(be,{className:"h-3.5 w-3.5"}),"Details"]}),e.jsxs(_,{value:"raw",className:"min-w-0 gap-2 rounded-lg px-3 py-2 text-[11px] font-semibold uppercase tracking-[0.1em] transition-all data-[state=active]:bg-background data-[state=active]:text-primary data-[state=active]:shadow-sm",children:[e.jsx(fe,{className:"h-3.5 w-3.5"}),"Raw Context"]})]}),e.jsxs(E,{value:"details",className:"mt-0 space-y-8 animate-in fade-in slide-in-from-bottom-2 duration-500",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[e.jsx(S,{label:"Entry Signature",value:r.id.slice(0,16)+"...",icon:ve}),e.jsx(S,{label:"Telemetry Origin",value:r.source,icon:P}),e.jsx(S,{label:"Process ID",value:r.processId??"NA",icon:je}),e.jsx(S,{label:"Operational Run",value:r.runId?.slice(0,8)??"NA",icon:Ne})]}),e.jsxs("div",{className:"relative overflow-hidden rounded-[2rem] border border-border bg-muted/10 p-1 shadow-inner group",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-transparent via-primary/[0.03] to-transparent h-[200%] -top-full animate-[scan_8s_linear_infinite] pointer-events-none"}),e.jsxs("div",{className:"rounded-[calc(2rem-4px)] border border-dashed border-border/40 bg-background/50 p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-primary/5 border border-primary/20 text-primary shadow-inner",children:e.jsx(z,{className:"h-4 w-4"})}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.12em] text-primary",children:"Automated Summary"}),e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.1em] text-muted-foreground/55",children:"Quick interpretation"})]})]}),e.jsxs("p",{className:"text-[13px] leading-relaxed text-muted-foreground/80 font-medium",children:["This telemetry node was captured from"," ",e.jsx("span",{className:"rounded bg-muted/40 px-1.5 py-0.5 font-semibold text-foreground",children:s??r.source}),"operating at the"," ",e.jsx("span",{className:n("rounded px-1.5 py-0.5 text-[11px] font-semibold uppercase tracking-[0.08em]",r.level==="error"?"bg-red-500/10 text-red-500":r.level==="warn"?"bg-amber-500/10 text-amber-500":r.level==="info"?"bg-sky-500/10 text-sky-500":"bg-zinc-500/10 text-zinc-500"),children:r.level})," ","threshold. The operational payload indicates an event state of"," ",e.jsx("span",{className:"font-semibold text-foreground",children:r.event}),"."]})]})]})]}),e.jsx(E,{value:"raw",className:"mt-0 animate-in fade-in slide-in-from-bottom-2 duration-500",children:e.jsxs("div",{className:"group relative rounded-2xl border-2 border-border bg-zinc-950 p-1 shadow-2xl transition-all hover:border-primary/20",children:[e.jsx("div",{className:"absolute right-4 top-4 z-10 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx("div",{className:"rounded-md border border-white/10 bg-white/5 px-2 py-1 text-[9px] font-medium uppercase tracking-[0.12em] text-white/45 backdrop-blur-md",children:"JSON.RAW.MODE"})}),e.jsx(C,{className:"h-[30rem] w-full rounded-xl p-6",children:e.jsx("pre",{className:"font-mono text-[12px] leading-relaxed tracking-tight text-zinc-400 selection:bg-primary/40 selection:text-primary-foreground",children:Fe({id:r.id,timestamp:r.timestamp,level:r.level,source:r.source,event:r.event,message:r.message,processId:r.processId,runId:r.runId,context:r.context??{}})})})]})})]})})}),e.jsxs("div",{className:"flex shrink-0 items-center justify-between border-t border-border bg-muted/5 px-6 py-3",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500 shadow-[0_0_8px_rgba(16,185,129,0.5)]"}),e.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.12em] text-foreground/35",children:"Node Verified"})]}),e.jsx("div",{className:"h-3 w-px bg-border/40"}),e.jsx("span",{className:"text-[10px] font-medium tabular-nums uppercase tracking-[0.12em] text-foreground/35",children:r.id.slice(0,8)})]}),e.jsx("div",{className:"rounded-full bg-primary/5 px-2 py-0.5 border border-primary/10",children:e.jsx("span",{className:"text-[9px] font-medium uppercase tracking-[0.12em] text-primary/65",children:"CCS-TEC-v3"})})]})]}):e.jsxs("div",{className:"flex h-full flex-col items-center justify-center p-8 text-center animate-in fade-in duration-1000",children:[e.jsxs("div",{className:"relative mb-8",children:[e.jsx("div",{className:"absolute inset-0 animate-ping rounded-full bg-primary/5 p-12"}),e.jsx("div",{className:"relative rounded-full border-2 border-dashed border-border/40 p-10 bg-muted/5",children:e.jsx(z,{className:"h-10 w-10 text-muted-foreground/20"})})]}),e.jsxs("div",{className:"max-w-xs space-y-3",children:[e.jsx("h3",{className:"text-[15px] font-semibold uppercase tracking-[0.14em] text-foreground/65",children:"Inspector Standby"}),e.jsx("p",{className:"text-[13px] leading-relaxed text-muted-foreground/55 font-medium",children:"Select a telemetry node from the active data queue to perform deep analysis of its operational context."})]})]})}function Y({entries:r,selectedEntryId:s,onSelect:t,sourceLabels:d,isLoading:o,isFetching:m}){return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-background/50 backdrop-blur-sm",children:[e.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border bg-card/40 px-6 py-3 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-2 w-2 animate-pulse rounded-full bg-primary shadow-[0_0_12px_rgba(var(--primary),0.6)]"}),e.jsx("h2",{className:"text-[12px] font-semibold uppercase tracking-[0.14em] text-foreground",children:"Live Entry Stream"})]}),e.jsx("div",{className:"h-4 w-px bg-border/60"}),e.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-emerald-500/20 bg-emerald-500/10 px-2 py-0.5",children:[e.jsx(D,{className:"h-3 w-3 text-emerald-500"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.12em] text-emerald-600",children:"Live telemetry"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[m&&e.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-primary/20 bg-primary/10 px-3 py-1",children:[e.jsx(ye,{className:"h-3 w-3 animate-spin text-primary"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.12em] text-primary",children:"Syncing"})]}),e.jsx("span",{className:"font-mono text-[10px] font-medium uppercase tracking-[0.16em] text-foreground/35",children:"NODE.01"})]})]}),e.jsxs("div",{className:"flex items-center gap-0 border-b border-border bg-muted/30 px-0 py-2 text-[10px] font-semibold uppercase tracking-[0.12em] text-foreground/45",children:[e.jsx("div",{className:"w-[6.5rem] shrink-0 px-6",children:"Time"}),e.jsx("div",{className:"w-14 shrink-0 border-l border-border/10 px-2 text-center",children:"Lvl"}),e.jsx("div",{className:"w-[15rem] shrink-0 border-l border-border/10 px-4",children:"Source"}),e.jsx("div",{className:"flex-1 border-l border-border/10 px-4",children:"Message"}),e.jsx("div",{className:"w-[5.5rem] shrink-0 border-l border-border/10 px-2 text-center",children:"Proc"}),e.jsx("div",{className:"w-[5.5rem] shrink-0 border-l border-border/10 px-3 text-center",children:"Run"}),e.jsx("div",{className:"w-11 shrink-0 border-l border-border/10 px-2 text-center",children:"Open"})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:o?e.jsx("div",{className:"space-y-1 p-2",children:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15].map(a=>e.jsx("div",{className:"h-10 w-full animate-pulse rounded-lg border border-border/5 bg-muted/20"},a))}):r.length===0?e.jsxs("div",{className:"flex h-full animate-in fade-in duration-1000 flex-col items-center justify-center gap-6 px-8 text-center",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 animate-ping rounded-full bg-muted/5 p-12"}),e.jsx("div",{className:"relative rounded-full border border-dashed border-border/40 bg-muted/5 p-10",children:e.jsx(we,{className:"h-10 w-10 text-muted-foreground/20"})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[13px] font-semibold uppercase tracking-[0.14em] text-foreground/55",children:"No matching entries"}),e.jsx("p",{className:"max-w-[18rem] text-[12px] font-medium leading-relaxed text-muted-foreground/60",children:"Your current source, level, or search filters are hiding the stream. Adjust them to bring entries back into view."})]})]}):e.jsx(C,{className:"h-full",children:e.jsx("div",{className:"flex flex-col",children:r.map(a=>{const l=a.id===s;return e.jsxs("button",{type:"button",onClick:()=>t(a.id),className:n("group relative flex w-full items-center border-b border-border/5 px-0 py-2.5 text-left transition-all duration-150",l?"z-10 bg-primary/[0.08] shadow-[inset_4px_0_0_rgba(var(--primary),1)]":"bg-transparent hover:bg-muted/30"),children:[e.jsx("div",{className:"absolute inset-y-0 left-0 w-1 origin-center scale-y-0 bg-primary transition-transform duration-300 group-hover:scale-y-100"}),e.jsxs("div",{className:"flex w-full items-center gap-0",children:[e.jsx("div",{className:"flex w-[6.5rem] shrink-0 items-center",children:e.jsx("p",{className:n("px-6 font-mono text-[11px] font-semibold tabular-nums transition-colors",l?"text-primary":"text-foreground/60 group-hover:text-foreground"),children:new Date(a.timestamp).toLocaleTimeString(void 0,{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})})}),e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-0",children:[e.jsx("div",{className:"flex w-14 shrink-0 items-center justify-center opacity-80 transition-opacity group-hover:opacity-100",children:e.jsx(re,{level:a.level,className:"origin-center scale-[0.85]"})}),e.jsxs("div",{className:"flex w-[15rem] shrink-0 flex-col gap-0.5 overflow-hidden px-4",children:[e.jsx("span",{className:n("truncate text-[11px] font-semibold uppercase tracking-[0.12em] transition-colors",l?"text-foreground":"text-foreground/50 group-hover:text-foreground/80"),children:d[a.source]??a.source}),e.jsx("span",{className:"truncate text-[10px] font-medium uppercase tracking-[0.1em] text-muted-foreground/55",children:a.event})]}),e.jsx("div",{className:"min-w-0 flex-1 px-4",children:e.jsx("p",{className:n("truncate text-[13px] font-medium leading-5 transition-colors",l?"text-foreground":"text-foreground/70 group-hover:text-foreground"),children:a.message})}),e.jsx("div",{className:"flex w-[5.5rem] shrink-0 items-center justify-center px-2 font-mono text-[10px] font-semibold tabular-nums tracking-[0.12em] text-foreground/30 transition-colors group-hover:text-primary/45",children:a.processId??"????"}),e.jsx("div",{className:"flex w-[5.5rem] shrink-0 items-center justify-center px-3 font-mono text-[10px] font-semibold tabular-nums tracking-[0.12em] text-foreground/30 transition-colors group-hover:text-primary/45",children:a.runId?.slice(0,4).toUpperCase()??"NONE"}),e.jsx("div",{className:"flex w-11 shrink-0 items-center justify-center px-2",children:e.jsx("div",{className:n("flex h-7 w-7 items-center justify-center rounded-full border transition-all",l?"animate-in zoom-in duration-300 border-primary/20 bg-primary/10 text-primary":"border-transparent text-foreground/20 group-hover:border-border/40 group-hover:bg-background/80 group-hover:text-foreground/55"),children:e.jsx(Z,{className:"h-3.5 w-3.5"})})})]})]})]},a.id)})})})}),e.jsxs("div",{className:"flex shrink-0 items-center justify-between border-t border-border bg-muted/5 px-6 py-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.12em] text-foreground/35",children:"Node: CCS-CORE"}),e.jsx("div",{className:"h-1 w-1 rounded-full bg-border/40"}),e.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.12em] text-foreground/35",children:"Status: Operational"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("span",{className:"text-[10px] font-medium uppercase tracking-[0.12em] text-foreground/35",children:["Entries: ",r.length]})})]})]})}const se=["logs","config"],ae=["logs","sources"],Te=150;function De(){const[r,s]=c.useState("all"),[t,d]=c.useState("all"),[o,m]=c.useState(""),[a,l]=c.useState(Te),[g,u]=c.useState(null),p=c.useDeferredValue(o.trim()),h=F({queryKey:se,queryFn:async()=>(await L.logs.getConfig()).logging,refetchInterval:3e4}),v=F({queryKey:ae,queryFn:async()=>(await L.logs.getSources()).sources,refetchInterval:15e3}),i=F({queryKey:["logs","entries",r,t,p,a],queryFn:async()=>(await L.logs.getEntries({source:r==="all"?void 0:r,level:t==="all"?void 0:t,search:p||void 0,limit:a})).entries,placeholderData:Ie,refetchInterval:1e4}),I=c.useMemo(()=>{const N=i.data??[];return N.length===0?null:g&&N.some(j=>j.id===g)?g:N[0]?.id??null},[i.data,g]),te=c.useMemo(()=>(i.data??[]).find(N=>N.id===I)??null,[I,i.data]),ie=c.useMemo(()=>(v.data??[]).map(j=>j.lastTimestamp).filter(j=>!!j).sort((j,le)=>le.localeCompare(j))[0]??null,[v.data]);return{configQuery:h,sourcesQuery:v,entriesQuery:i,selectedSource:r,setSelectedSource:s,selectedLevel:t,setSelectedLevel:d,search:o,setSearch:m,limit:a,setLimit:l,selectedEntryId:I,setSelectedEntryId:u,selectedEntry:te,latestTimestamp:ie,isInitialLoading:!h.data&&h.isLoading||!v.data&&v.isLoading||!i.data&&i.isLoading}}function Oe(){const r=_e();return Ee({mutationFn:s=>L.logs.updateConfig(s),onSuccess:async()=>{await Promise.all([r.invalidateQueries({queryKey:se}),r.invalidateQueries({queryKey:ae}),r.invalidateQueries({queryKey:["logs","entries"]})]),q.success("Logging configuration saved.")},onError:s=>{q.error(s.message||"Failed to save logging configuration.")}})}function ze(){return[{value:"all",label:"All levels"},{value:"error",label:"Errors"},{value:"warn",label:"Warnings"},{value:"info",label:"Info"},{value:"debug",label:"Debug"}]}function Pe(r){return Object.fromEntries(r.map(s=>[s.source,s.label]))}function H({sources:r,selectedSource:s,onSourceChange:t,selectedLevel:d,onLevelChange:o,search:m,onSearchChange:a,limit:l,onLimitChange:g,onRefresh:u,isRefreshing:p}){const h=ze(),v=[50,100,150,250];return e.jsxs("div",{className:"flex flex-col gap-6 animate-in fade-in slide-in-from-left-2 duration-700",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between px-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-primary shadow-[0_0_8px_rgba(var(--primary),0.5)]"}),e.jsx(b,{htmlFor:"logs-search",className:"text-[11px] font-semibold uppercase tracking-[0.14em] text-foreground/80",children:"Payload Search"})]}),e.jsx(M,{className:"h-3 w-3 text-primary/20"})]}),e.jsxs("div",{className:"group relative",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-3.5 flex items-center transition-all group-focus-within:translate-x-1",children:e.jsx(ke,{className:"h-3.5 w-3.5 text-foreground/20 group-focus-within:text-primary transition-colors"})}),e.jsx(R,{id:"logs-search","aria-label":"Search",value:m,onChange:i=>a(i.target.value),placeholder:"Scan for patterns...",className:"h-11 rounded-xl border-2 border-border/40 bg-background/50 pl-10 text-[13px] font-medium text-foreground placeholder:text-foreground/35 focus-visible:border-primary/40 focus-visible:ring-0 transition-all shadow-inner"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 px-1",children:[e.jsx(Se,{className:"h-3 w-3 text-primary/40"}),e.jsx(b,{className:"text-[11px] font-semibold uppercase tracking-[0.14em] text-foreground/80",children:"Source Matrix"})]}),e.jsxs("div",{className:"flex flex-col gap-1","aria-label":"Source filter",children:[e.jsxs("button",{type:"button",onClick:()=>t("all"),className:n("group relative flex items-center justify-between rounded-lg border px-3 py-2 transition-all active:scale-[0.98]",s==="all"?"border-primary/50 bg-primary/10 text-primary shadow-[0_0_15px_rgba(var(--primary),0.1)]":"border-border/40 bg-muted/20 text-foreground/40 hover:border-border hover:bg-muted/40 hover:text-foreground/80"),children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em]",children:"Global Stream"}),s==="all"&&e.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-primary shadow-[0_0_8px_rgba(var(--primary),0.8)]"})]}),e.jsx("div",{className:"grid grid-cols-2 gap-1 mt-1",children:r.map(i=>e.jsx("button",{type:"button",onClick:()=>t(i.source),className:n("rounded-lg border px-2.5 py-1.5 text-[10px] font-semibold uppercase tracking-[0.1em] transition-all active:scale-[0.97]",s===i.source?"border-primary/50 bg-primary/10 text-primary shadow-sm":"border-border/40 bg-muted/20 text-foreground/40 hover:border-border hover:bg-muted/40 hover:text-foreground/80"),children:i.label},i.source))})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 px-1",children:[e.jsx(Le,{className:"h-3 w-3 text-primary/40"}),e.jsx(b,{className:"text-[11px] font-semibold uppercase tracking-[0.14em] text-foreground/80",children:"Sensitivity"})]}),e.jsx("div",{className:"grid grid-cols-2 gap-1.5","aria-label":"Level filter",children:h.map(i=>e.jsxs("button",{type:"button",onClick:()=>o(i.value),className:n("flex flex-col items-center gap-1 rounded-lg border px-2 py-2 text-[10px] font-semibold uppercase tracking-[0.1em] transition-all active:scale-[0.97]",d===i.value?"border-primary/50 bg-primary/10 text-primary shadow-[0_0_15px_rgba(var(--primary),0.1)]":"border-border/40 bg-muted/20 text-foreground/40 hover:border-border hover:bg-muted/40 hover:text-foreground/80"),children:[e.jsx("span",{children:i.label}),e.jsx("div",{className:n("h-0.5 w-4 rounded-full transition-colors",d===i.value?"bg-primary":"bg-foreground/10")})]},i.value))})]}),e.jsx("div",{className:"mt-4 rounded-2xl border-2 border-border bg-card/40 p-1.5 shadow-xl shadow-black/5",children:e.jsxs("div",{className:"rounded-[calc(1rem-2px)] border border-dashed border-border bg-background/60 p-4 space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.14em] text-primary",children:"Operational Window"}),e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-[0.1em] text-foreground/45",children:"Tail Capacity"})]}),e.jsx("div",{className:"h-8 w-8 rounded-lg bg-primary/5 border border-primary/10 flex items-center justify-center",children:e.jsx(M,{className:"h-4 w-4 text-primary/40"})})]}),e.jsx("div",{className:"grid grid-cols-4 gap-1.5","aria-label":"Visible entries",children:v.map(i=>e.jsx("button",{type:"button",onClick:()=>g(i),className:n("rounded-md border py-1.5 text-[11px] font-semibold tabular-nums transition-all active:scale-[0.95]",l===i?"border-foreground bg-foreground text-background":"border-border/60 bg-muted/40 text-foreground/40 hover:bg-muted hover:text-foreground"),children:i},i))}),e.jsxs(f,{variant:"ghost",size:"sm",className:"group relative h-10 w-full overflow-hidden rounded-xl border-none bg-primary text-[11px] font-semibold uppercase tracking-[0.14em] text-primary-foreground transition-all hover:scale-[1.02] hover:shadow-lg hover:shadow-primary/20 active:scale-[0.98]",onClick:u,children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/10 to-transparent -translate-x-full group-hover:translate-x-full transition-transform duration-1000"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X,{className:n("h-3.5 w-3.5",p&&"animate-spin")}),e.jsx("span",{children:"Refresh Entries"})]})]})]})})]})}function Me(){return e.jsxs("div",{className:"space-y-6","aria-label":"Loading logs workspace",children:[e.jsx(y,{className:"gap-4",children:e.jsxs(k,{className:"space-y-3",children:[e.jsx(x,{className:"h-4 w-28"}),e.jsx(x,{className:"h-8 w-72"}),e.jsx(x,{className:"h-4 w-[30rem]"})]})}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-4",children:[1,2,3,4].map(r=>e.jsx(y,{className:"gap-3",children:e.jsxs(k,{className:"space-y-2",children:[e.jsx(x,{className:"h-4 w-20"}),e.jsx(x,{className:"h-7 w-24"})]})},r))}),e.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,1.45fr)_22rem]",children:[e.jsxs(y,{className:"gap-4",children:[e.jsxs(k,{className:"space-y-3",children:[e.jsx(x,{className:"h-4 w-52"}),e.jsx("div",{className:"grid gap-3 md:grid-cols-4",children:[1,2,3,4].map(r=>e.jsx(x,{className:"h-10 w-full"},r))})]}),e.jsxs(T,{className:"grid gap-4 xl:grid-cols-[22rem_minmax(0,1fr)]",children:[e.jsx(x,{className:"h-[26rem] w-full"}),e.jsx(x,{className:"h-[26rem] w-full"})]})]}),e.jsxs(y,{className:"gap-4",children:[e.jsxs(k,{className:"space-y-3",children:[e.jsx(x,{className:"h-5 w-44"}),e.jsx(x,{className:"h-4 w-full"})]}),e.jsx(T,{className:"space-y-4",children:[1,2,3,4].map(r=>e.jsx(x,{className:"h-10 w-full"},r))})]})]})]})}const Q=1200,Ae=336,qe=368,U=52;function B({side:r,label:s,onExpand:t}){return e.jsxs("div",{className:n("flex h-full w-full flex-col items-center justify-center gap-4 bg-muted/5",r==="left"?"border-r border-border":"border-l border-border"),children:[e.jsx(f,{variant:"ghost",size:"icon",onClick:t,"aria-label":`Show ${s.toLowerCase()}`,className:"h-9 w-9 rounded-xl border border-border/70 bg-background/85 shadow-sm",children:r==="left"?e.jsx(ee,{className:"h-4 w-4"}):e.jsx($,{className:"h-4 w-4"})}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.14em] text-foreground/45",style:{writingMode:"vertical-rl"},children:s})]})}function Ze(){const r=De(),s=Oe(),t=Pe(r.sourcesQuery.data??[]),[d,o]=c.useState(()=>typeof window<"u"?window.innerWidth>=Q:!1),[m,a]=c.useState(!1),[l,g]=c.useState(!1);if(c.useEffect(()=>{const p=window.matchMedia(`(min-width: ${Q}px)`),h=()=>{o(window.innerWidth>=Q)};return h(),p.addEventListener("change",h),()=>p.removeEventListener("change",h)},[]),r.isInitialLoading)return e.jsx(Me,{});const u=r.configQuery.data;return u?e.jsxs("div",{className:"relative flex h-full min-h-full flex-col overflow-hidden border-t border-border/40 bg-background font-sans text-foreground antialiased selection:bg-primary/30 selection:text-primary",children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 z-0 opacity-40 [background-image:radial-gradient(circle_at_1px_1px,rgba(38,38,36,0.08)_1px,transparent_0)] [background-size:14px_14px]"}),e.jsxs("div",{className:"relative z-10 flex shrink-0 items-center justify-between border-b border-border/80 bg-card/95 px-6 py-2 backdrop-blur-xl shadow-md transition-all xl:px-8",children:[e.jsxs("div",{className:"flex items-center gap-10",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"group flex h-9 w-9 items-center justify-center rounded-xl border-2 border-primary/20 bg-primary/5 text-primary shadow-inner transition-all hover:scale-110 active:scale-90",children:e.jsx(A,{className:"h-4.5 w-4.5 transition-transform group-hover:rotate-6"})}),e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"rounded-full bg-primary px-2 py-0.5 text-[10px] font-semibold uppercase tracking-[0.14em] text-primary-foreground shadow-lg shadow-primary/20",children:"Operational"}),e.jsx("h1",{className:"text-[17px] font-semibold tracking-tight text-foreground",children:"Log Operations Center"})]}),e.jsx("p",{className:"font-mono text-[10px] font-medium uppercase tracking-[0.16em] text-foreground/45",children:"CCS.TOC.LOGS.STREAM.v3"})]})]}),e.jsx("div",{className:"hidden h-8 w-px bg-border/80 md:block"}),e.jsxs("div",{className:"hidden items-center gap-10 md:flex",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:n("h-2 w-2 rounded-full ring-4 transition-all duration-700",u.redact?"bg-emerald-500 shadow-[0_0_20px_rgba(16,185,129,0.6)] ring-emerald-500/30":"bg-zinc-600 ring-transparent")}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.14em] text-foreground/90",children:"Redaction"}),e.jsx("span",{className:"text-[11px] font-medium text-foreground/50",children:u.redact?"Enforced":"Standby"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-lg border-2 border-border bg-muted shadow-inner",children:e.jsx(Ce,{className:"h-3.5 w-3.5 text-foreground"})}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.14em] text-foreground/90",children:"Retention"}),e.jsxs("span",{className:"text-[11px] font-medium text-foreground/50",children:[u.retain_days,"D / ",u.rotate_mb,"MB"]})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(f,{variant:"ghost",size:"sm",className:"group h-9 gap-3 rounded-xl border-2 border-border bg-muted px-5 text-[11px] font-semibold uppercase tracking-[0.14em] text-foreground transition-all hover:bg-foreground hover:text-background active:scale-95 shadow-lg shadow-black/5",onClick:()=>void Promise.all([r.sourcesQuery.refetch(),r.entriesQuery.refetch()]),children:[e.jsxs("div",{className:"relative",children:[e.jsx(X,{className:n("h-3.5 w-3.5 transition-transform duration-500",(r.entriesQuery.isFetching||r.sourcesQuery.isFetching)&&"animate-spin")}),!r.entriesQuery.isFetching&&!r.sourcesQuery.isFetching&&e.jsx("div",{className:"absolute -right-1 -top-1 h-1.5 w-1.5 rounded-full border border-muted bg-primary animate-pulse"})]}),r.entriesQuery.isFetching||r.sourcesQuery.isFetching?"Syncing":"Refresh"]}),e.jsx("div",{className:"h-7 w-px bg-border/80"}),e.jsx(f,{asChild:!0,variant:"ghost",size:"sm",className:"h-9 w-9 rounded-xl border-2 border-border bg-muted p-0 text-foreground transition-all hover:bg-foreground hover:text-background active:scale-95 shadow-lg shadow-black/5",children:e.jsx(ne,{to:"/health",children:e.jsx(Z,{className:"h-4 w-4"})})})]})]}),e.jsx("div",{className:"relative z-10 flex min-h-0 flex-1 overflow-hidden",children:e.jsxs(G,{defaultValue:"stream",className:"flex flex-1 flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border/80 bg-card/80 px-6 py-2 backdrop-blur-xl shadow-inner xl:px-8",children:[e.jsxs(J,{className:"h-10 w-auto gap-1.5 rounded-xl border border-border/60 bg-muted/40 p-1",children:[e.jsx(_,{value:"stream",className:"rounded-lg px-5 text-[11px] font-semibold uppercase tracking-[0.12em] text-foreground/60 transition-all data-[state=active]:bg-background data-[state=active]:text-primary data-[state=active]:shadow-md",children:"Telemetry Stream"}),e.jsx(_,{value:"errors",className:"rounded-lg px-5 text-[11px] font-semibold uppercase tracking-[0.12em] text-foreground/60 transition-all data-[state=active]:bg-background data-[state=active]:text-primary data-[state=active]:shadow-md",children:"Legacy Errors"})]}),e.jsxs("div",{className:"hidden items-center gap-3 lg:flex",children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-border bg-muted px-3 py-1 shadow-inner",children:[e.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-emerald-500 shadow-[0_0_8px_rgba(16,185,129,0.6)]"})]}),e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-tight text-foreground/80",children:"Connected"})]}),e.jsxs("span",{className:"pr-4 text-[11px] font-medium tabular-nums text-foreground/45",children:[r.entriesQuery.data?.length??0," captured"]})]})]}),e.jsx(E,{value:"stream",className:"m-0 flex min-h-0 flex-1 overflow-y-auto lg:overflow-hidden focus-visible:outline-none",children:d?e.jsxs("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[e.jsx("div",{"data-logs-pane":"filters",style:{width:m?U:Ae},className:"flex min-h-0 shrink-0 bg-muted/5",children:m?e.jsx(B,{side:"left",label:"Filters",onExpand:()=>a(!1)}):e.jsxs("div",{className:"flex h-full min-h-0 w-full flex-col border-r border-border p-5 2xl:p-6",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.14em] text-foreground/80",children:"Filters"}),e.jsx("p",{className:"text-[11px] text-muted-foreground/70",children:"Search, source, and retention controls"})]}),e.jsx(f,{variant:"ghost",size:"icon",onClick:()=>a(!0),"aria-label":"Hide filters",className:"h-9 w-9 rounded-xl border border-border/70 bg-background/85 shadow-sm",children:e.jsx($,{className:"h-4 w-4"})})]}),e.jsx(C,{className:"min-h-0 flex-1","data-logs-scroll-region":"filters",children:e.jsxs("div",{className:"space-y-5 pr-4",children:[e.jsx(H,{sources:r.sourcesQuery.data??[],selectedSource:r.selectedSource,onSourceChange:r.setSelectedSource,selectedLevel:r.selectedLevel,onLevelChange:r.setSelectedLevel,search:r.search,onSearchChange:r.setSearch,limit:r.limit,onLimitChange:r.setLimit,onRefresh:()=>void Promise.all([r.sourcesQuery.refetch(),r.entriesQuery.refetch()]),isRefreshing:r.entriesQuery.isFetching||r.sourcesQuery.isFetching}),e.jsx("div",{className:"border-t border-border/20 pt-5",children:e.jsx(K,{config:u,onSave:p=>s.mutate(p),isPending:s.isPending})})]})})]})}),e.jsx("div",{"data-logs-pane":"entries",className:"flex min-h-0 min-w-0 flex-1 overflow-hidden border-l border-r border-border bg-background/95",children:e.jsx(Y,{entries:r.entriesQuery.data??[],selectedEntryId:r.selectedEntryId,onSelect:r.setSelectedEntryId,sourceLabels:t,isLoading:r.entriesQuery.isLoading,isFetching:r.entriesQuery.isFetching})}),e.jsx("div",{"data-logs-pane":"details",style:{width:l?U:qe},className:"flex min-h-0 shrink-0 bg-muted/5 shadow-inner",children:l?e.jsx(B,{side:"right",label:"Details",onExpand:()=>g(!1)}):e.jsxs("div",{className:"flex h-full min-h-0 w-full flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border/50 bg-background/60 px-3 py-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.14em] text-foreground/80",children:"Details"}),e.jsx("p",{className:"text-[11px] text-muted-foreground/70",children:"Selected entry context and raw payload"})]}),e.jsx(f,{variant:"ghost",size:"icon",onClick:()=>g(!0),"aria-label":"Hide details",className:"h-9 w-9 rounded-xl border border-border/70 bg-background/85 shadow-sm",children:e.jsx(ee,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(V,{entry:r.selectedEntry,sourceLabel:r.selectedEntry?t[r.selectedEntry.source]:void 0})})]})})]}):e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[e.jsx("div",{className:"border-b border-border bg-muted/5 p-5",children:e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(H,{sources:r.sourcesQuery.data??[],selectedSource:r.selectedSource,onSourceChange:r.setSelectedSource,selectedLevel:r.selectedLevel,onLevelChange:r.setSelectedLevel,search:r.search,onSearchChange:r.setSearch,limit:r.limit,onLimitChange:r.setLimit,onRefresh:()=>void Promise.all([r.sourcesQuery.refetch(),r.entriesQuery.refetch()]),isRefreshing:r.entriesQuery.isFetching||r.sourcesQuery.isFetching}),e.jsx(K,{config:u,onSave:p=>s.mutate(p),isPending:s.isPending})]})}),e.jsx("div",{className:"flex min-h-[32rem] flex-col overflow-hidden border-b border-border bg-background/95",children:e.jsx(Y,{entries:r.entriesQuery.data??[],selectedEntryId:r.selectedEntryId,onSelect:r.setSelectedEntryId,sourceLabels:t,isLoading:r.entriesQuery.isLoading,isFetching:r.entriesQuery.isFetching})}),e.jsx("div",{className:"flex min-h-[30rem] flex-col overflow-hidden bg-muted/5 shadow-inner",children:e.jsx(V,{entry:r.selectedEntry,sourceLabel:r.selectedEntry?t[r.selectedEntry.source]:void 0})})]})}),e.jsx(E,{value:"errors",className:"m-0 flex-1 overflow-y-auto bg-background/20 p-6 focus-visible:outline-none xl:p-8",children:e.jsxs("div",{className:"mx-auto max-w-5xl space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-[2.5rem] border-2 border-border bg-card/40 p-1.5 shadow-2xl shadow-black/10",children:[e.jsx("div",{className:"absolute inset-0 opacity-[0.02] pointer-events-none [background-image:radial-gradient(circle_at_center,var(--primary)_1px,transparent_0)] [background-size:24px_24px]"}),e.jsx(y,{className:"rounded-[calc(2.5rem-0.375rem)] border-none bg-background/60 shadow-none overflow-hidden backdrop-blur-md",children:e.jsxs(T,{className:"flex flex-col gap-6 p-10",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl border-2 border-primary/20 bg-primary/10 text-primary shadow-inner",children:e.jsx(A,{className:"h-5 w-5"})}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.4em] text-primary",children:"Legacy Diagnostic Node"}),e.jsx("p",{className:"text-[9px] font-bold uppercase tracking-widest text-muted-foreground/40",children:"CCS-MATRIX-FAILURE-MONITOR"})]})]}),e.jsx("div",{className:"rounded-full border border-border bg-background/50 px-3 py-1 text-[9px] font-black uppercase tracking-widest text-foreground/40 shadow-inner",children:"Mode: Historical"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h2",{className:"text-3xl font-black uppercase tracking-tighter text-foreground",children:"CLIProxy Failure Analysis"}),e.jsx("p",{className:"max-w-3xl text-[15px] font-medium leading-relaxed text-muted-foreground/60",children:"Maintain oversight of legacy request failures while the unified stream consolidates system-wide telemetry. This view provides direct access to the historical failure matrix for deep-field debugging."})]}),e.jsx("div",{className:"h-px w-full bg-gradient-to-r from-transparent via-border to-transparent opacity-40"})]})})]}),e.jsxs("div",{className:"rounded-[2.5rem] border-2 border-border bg-muted/5 p-8 shadow-inner backdrop-blur-sm",children:[e.jsxs("div",{className:"mb-6 flex items-center gap-3",children:[e.jsx("div",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-primary shadow-[0_0_8px_rgba(var(--primary),0.5)]"}),e.jsx("span",{className:"text-[10px] font-black uppercase tracking-[0.3em] text-foreground/40",children:"Realtime Monitoring Deck"})]}),e.jsx(xe,{})]})]})})]})})]}):null}export{Ze as LogsPage};
|
|
1
|
+
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as c,L as ne}from"./react-vendor-CNOkPC89.js";import{c as n,L as b,aF as O,r as de,s as oe,t as ce,v as me,w,I as R,d as f,n as C,Q as G,R as J,U as _,V as E,Y as L,C as y,j as k,S as x,b as T,bh as xe}from"./index-Du97tqVQ.js";import{a7 as ue,aD as pe,at as ge,Q as he,A as D,$ as z,am as P,_ as be,aA as fe,aW as ve,Y as je,ah as Ne,L as ye,aX as we,a6 as Z,Z as A,au as ke,aY as Se,i as Le,R as $,d as M,aZ as Ce,ag as X,C as ee}from"./icons-DfENUzBo.js";import{u as Q,a as _e,b as Ee,k as Ie}from"./tanstack-CrmUhA7Z.js";import{t as q}from"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function W(r,s){const t=Number.parseInt(r,10);return Number.isNaN(t)?s:Math.max(0,t)}function K({config:r,onSave:s,isPending:t}){const[d,o]=c.useState(r);c.useEffect(()=>{o(r)},[r]);const m=c.useMemo(()=>JSON.stringify(d)!==JSON.stringify(r),[r,d]);return e.jsxs("div",{className:"group relative overflow-hidden rounded-2xl border-2 border-border/60 bg-card/40 p-1 shadow-lg transition-all hover:border-border",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border bg-muted/30 px-5 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-lg bg-primary/5 border border-primary/20",children:e.jsx(ue,{className:"h-3.5 w-3.5 text-primary"})}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("h3",{className:"text-[11px] font-semibold uppercase tracking-[0.14em] text-foreground",children:"Logging Policy"}),e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.1em] text-foreground/45",children:"Retention and privacy"})]})]}),e.jsx("div",{className:n("h-1.5 w-1.5 rounded-full",r.enabled?"bg-emerald-500 shadow-[0_0_8px_rgba(16,185,129,0.5)]":"bg-zinc-500")})]}),e.jsxs("div",{className:"space-y-6 p-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"rounded-xl border border-border/40 bg-background/50 p-3 flex flex-col gap-1",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.12em] text-muted-foreground/70",children:"Active Status"}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:n("text-[11px] font-semibold uppercase tracking-[0.1em]",r.enabled?"text-emerald-500":"text-zinc-500"),children:r.enabled?"Live":"Off"})})]}),e.jsxs("div",{className:"rounded-xl border border-border/40 bg-background/50 p-3 flex flex-col gap-1",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.12em] text-muted-foreground/70",children:"Redaction"}),e.jsx("span",{className:n("text-[11px] font-semibold uppercase tracking-[0.1em]",r.redact?"text-primary":"text-muted-foreground/40"),children:r.redact?"Enforced":"Plain"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-xl border border-border/40 bg-background/20 px-4 py-3 transition-colors hover:bg-background/40",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{htmlFor:"logs-enabled",className:"text-[12px] font-semibold uppercase tracking-[0.12em]",children:"Pipeline"}),e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground/55",children:"Enable structured logging"})]}),e.jsx(O,{id:"logs-enabled",checked:d.enabled,onCheckedChange:a=>o(l=>({...l,enabled:a})),className:"data-[state=checked]:bg-primary"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-xl border border-border/40 bg-background/20 px-4 py-3 transition-colors hover:bg-background/40",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{htmlFor:"logs-redact",className:"text-[12px] font-semibold uppercase tracking-[0.12em]",children:"Masking"}),e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground/55",children:"Sanitize payload data"})]}),e.jsx(O,{id:"logs-redact",checked:d.redact,onCheckedChange:a=>o(l=>({...l,redact:a})),className:"data-[state=checked]:bg-primary"})]})]}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 px-1",children:[e.jsx(pe,{className:"h-3 w-3 text-primary/40"}),e.jsx(b,{htmlFor:"logs-config-level",className:"text-[10px] font-semibold uppercase tracking-[0.12em] text-foreground/70",children:"Minimum Operational Threshold"})]}),e.jsxs(de,{value:d.level,onValueChange:a=>o(l=>({...l,level:a})),children:[e.jsx(oe,{id:"logs-config-level",className:"h-10 rounded-xl border-2 border-border/40 bg-background/50 text-[12px] font-semibold uppercase tracking-[0.1em] focus:ring-0",children:e.jsx(ce,{})}),e.jsxs(me,{className:"border-2 border-border bg-card",children:[e.jsx(w,{value:"error",className:"text-[11px] font-semibold uppercase tracking-[0.1em]",children:"Error Only"}),e.jsx(w,{value:"warn",className:"text-[11px] font-semibold uppercase tracking-[0.1em]",children:"Warn + Above"}),e.jsx(w,{value:"info",className:"text-[11px] font-semibold uppercase tracking-[0.1em]",children:"Info + Above"}),e.jsx(w,{value:"debug",className:"text-[11px] font-semibold uppercase tracking-[0.1em]",children:"Full Debug"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"logs-rotate-mb",className:"px-1 text-[10px] font-semibold uppercase tracking-[0.1em] text-foreground/50",children:"Rotation (MB)"}),e.jsx(R,{id:"logs-rotate-mb",type:"number",min:1,className:"h-10 rounded-xl border-2 border-border/40 bg-background/50 font-mono text-[12px] font-medium focus-visible:ring-0",value:d.rotate_mb,onChange:a=>o(l=>({...l,rotate_mb:W(a.target.value,l.rotate_mb)}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"logs-retain-days",className:"px-1 text-[10px] font-semibold uppercase tracking-[0.1em] text-foreground/50",children:"Retain (Days)"}),e.jsx(R,{id:"logs-retain-days",type:"number",min:1,className:"h-10 rounded-xl border-2 border-border/40 bg-background/50 font-mono text-[12px] font-medium focus-visible:ring-0",value:d.retain_days,onChange:a=>o(l=>({...l,retain_days:W(a.target.value,l.retain_days)}))})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 pt-4 border-t border-border",children:[e.jsxs(f,{onClick:()=>s(d),disabled:!m||t,className:"h-10 w-full gap-2 rounded-xl bg-primary text-[11px] font-semibold uppercase tracking-[0.14em] shadow-lg shadow-primary/20 transition-all hover:scale-[1.02] active:scale-[0.98]",children:[e.jsx(ge,{className:"h-3.5 w-3.5"}),"Commit Changes"]}),e.jsxs(f,{variant:"ghost",onClick:()=>o(r),disabled:!m||t,className:"h-9 gap-2 text-[10px] font-medium uppercase tracking-[0.12em] text-foreground/45 hover:text-foreground",children:[e.jsx(he,{className:"h-3 w-3"}),"Rollback Draft"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between bg-muted/20 px-5 py-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(D,{className:"h-2.5 w-2.5 text-primary/40"}),e.jsx("span",{className:"text-[9px] font-medium uppercase tracking-[0.12em] text-foreground/30",children:"Operational Logic v3.4"})]}),m&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"h-1 w-1 rounded-full bg-amber-500 animate-pulse"}),e.jsx("span",{className:"text-[9px] font-medium uppercase tracking-[0.12em] text-amber-500/70",children:"Pending"})]})]})]})}function Qe(r){if(r==null)return"{}";try{return JSON.stringify(r,null,2)}catch{return String(r)}}function Fe(r){switch(r){case"error":return"Error";case"warn":return"Warn";case"info":return"Info";case"debug":return"Debug"}}const Re={error:"border-red-500/30 bg-red-500/10 text-red-700 dark:text-red-300",warn:"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300",info:"border-sky-500/30 bg-sky-500/10 text-sky-700 dark:text-sky-300",debug:"border-zinc-500/30 bg-zinc-500/10 text-zinc-700 dark:text-zinc-300"};function re({level:r,className:s}){return e.jsx("span",{className:n("inline-flex items-center rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase tracking-[0.12em]",Re[r],s),children:Fe(r)})}function S({label:r,value:s,icon:t}){return e.jsxs("div",{className:"group relative flex flex-col gap-1.5 rounded-xl border border-border/40 bg-background/40 p-3 transition-all hover:bg-background/80 hover:shadow-lg hover:shadow-black/5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[t&&e.jsx(t,{className:"h-3 w-3 text-primary/40 group-hover:text-primary transition-colors"}),e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.12em] text-muted-foreground/70 transition-colors group-hover:text-primary/60",children:r})]}),e.jsx("div",{className:"h-1 w-1 rounded-full bg-border/40 group-hover:bg-primary/40 transition-colors"})]}),e.jsx("p",{className:"truncate font-mono text-[13px] font-medium tracking-tight text-foreground/85 transition-colors group-hover:text-foreground",children:s})]})}function V({entry:r,sourceLabel:s}){return r?e.jsxs("div",{className:"flex h-full flex-col bg-card/30 backdrop-blur-sm animate-in fade-in slide-in-from-right-4 duration-500",children:[e.jsxs("div",{className:"relative shrink-0 border-b border-border bg-card/60 p-6 shadow-sm overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-[0.03] pointer-events-none [background-image:radial-gradient(circle_at_center,var(--primary)_1px,transparent_0)] [background-size:16px_16px]"}),e.jsxs("div",{className:"relative space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(re,{level:r.level,className:"h-5 px-3 shadow-lg shadow-black/5"}),e.jsx("div",{className:"h-4 w-px bg-border/60"}),e.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-border bg-background/50 px-3 py-1 shadow-inner",children:[e.jsx(P,{className:"h-3 w-3 text-primary/60"}),e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-foreground/75",children:s??r.source})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{className:"h-3 w-3 animate-pulse text-emerald-500"}),e.jsx("span",{className:"font-mono text-[11px] font-medium uppercase tracking-[0.12em] text-muted-foreground/45",children:new Date(r.timestamp).toLocaleTimeString(void 0,{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-1 w-4 rounded-full bg-primary/40"}),e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.12em] text-primary/65",children:"Event"})]}),e.jsx("h2",{className:"text-[24px] font-semibold tracking-tight text-foreground leading-tight break-words",children:r.event}),e.jsx("div",{className:"rounded-xl border-l-4 border-primary/20 bg-muted/20 p-4 shadow-inner",children:e.jsx("p",{className:"text-[14px] font-medium leading-relaxed text-foreground/85 selection:bg-primary/20",children:r.message})})]})]})]}),e.jsx(C,{className:"flex-1",children:e.jsx("div",{className:"p-6",children:e.jsxs(G,{defaultValue:"details",className:"space-y-8",children:[e.jsxs(J,{className:"grid h-auto w-full grid-cols-2 gap-1 rounded-xl border border-border/60 bg-muted/40 p-1",children:[e.jsxs(_,{value:"details",className:"min-w-0 gap-2 rounded-lg px-3 py-2 text-[11px] font-semibold uppercase tracking-[0.1em] transition-all data-[state=active]:bg-background data-[state=active]:text-primary data-[state=active]:shadow-sm",children:[e.jsx(be,{className:"h-3.5 w-3.5"}),"Details"]}),e.jsxs(_,{value:"raw",className:"min-w-0 gap-2 rounded-lg px-3 py-2 text-[11px] font-semibold uppercase tracking-[0.1em] transition-all data-[state=active]:bg-background data-[state=active]:text-primary data-[state=active]:shadow-sm",children:[e.jsx(fe,{className:"h-3.5 w-3.5"}),"Raw Context"]})]}),e.jsxs(E,{value:"details",className:"mt-0 space-y-8 animate-in fade-in slide-in-from-bottom-2 duration-500",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[e.jsx(S,{label:"Entry Signature",value:r.id.slice(0,16)+"...",icon:ve}),e.jsx(S,{label:"Telemetry Origin",value:r.source,icon:P}),e.jsx(S,{label:"Process ID",value:r.processId??"NA",icon:je}),e.jsx(S,{label:"Operational Run",value:r.runId?.slice(0,8)??"NA",icon:Ne})]}),e.jsxs("div",{className:"relative overflow-hidden rounded-[2rem] border border-border bg-muted/10 p-1 shadow-inner group",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-transparent via-primary/[0.03] to-transparent h-[200%] -top-full animate-[scan_8s_linear_infinite] pointer-events-none"}),e.jsxs("div",{className:"rounded-[calc(2rem-4px)] border border-dashed border-border/40 bg-background/50 p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-primary/5 border border-primary/20 text-primary shadow-inner",children:e.jsx(z,{className:"h-4 w-4"})}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.12em] text-primary",children:"Automated Summary"}),e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.1em] text-muted-foreground/55",children:"Quick interpretation"})]})]}),e.jsxs("p",{className:"text-[13px] leading-relaxed text-muted-foreground/80 font-medium",children:["This telemetry node was captured from"," ",e.jsx("span",{className:"rounded bg-muted/40 px-1.5 py-0.5 font-semibold text-foreground",children:s??r.source}),"operating at the"," ",e.jsx("span",{className:n("rounded px-1.5 py-0.5 text-[11px] font-semibold uppercase tracking-[0.08em]",r.level==="error"?"bg-red-500/10 text-red-500":r.level==="warn"?"bg-amber-500/10 text-amber-500":r.level==="info"?"bg-sky-500/10 text-sky-500":"bg-zinc-500/10 text-zinc-500"),children:r.level})," ","threshold. The operational payload indicates an event state of"," ",e.jsx("span",{className:"font-semibold text-foreground",children:r.event}),"."]})]})]})]}),e.jsx(E,{value:"raw",className:"mt-0 animate-in fade-in slide-in-from-bottom-2 duration-500",children:e.jsxs("div",{className:"group relative rounded-2xl border-2 border-border bg-zinc-950 p-1 shadow-2xl transition-all hover:border-primary/20",children:[e.jsx("div",{className:"absolute right-4 top-4 z-10 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx("div",{className:"rounded-md border border-white/10 bg-white/5 px-2 py-1 text-[9px] font-medium uppercase tracking-[0.12em] text-white/45 backdrop-blur-md",children:"JSON.RAW.MODE"})}),e.jsx(C,{className:"h-[30rem] w-full rounded-xl p-6",children:e.jsx("pre",{className:"font-mono text-[12px] leading-relaxed tracking-tight text-zinc-400 selection:bg-primary/40 selection:text-primary-foreground",children:Qe({id:r.id,timestamp:r.timestamp,level:r.level,source:r.source,event:r.event,message:r.message,processId:r.processId,runId:r.runId,context:r.context??{}})})})]})})]})})}),e.jsxs("div",{className:"flex shrink-0 items-center justify-between border-t border-border bg-muted/5 px-6 py-3",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500 shadow-[0_0_8px_rgba(16,185,129,0.5)]"}),e.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.12em] text-foreground/35",children:"Node Verified"})]}),e.jsx("div",{className:"h-3 w-px bg-border/40"}),e.jsx("span",{className:"text-[10px] font-medium tabular-nums uppercase tracking-[0.12em] text-foreground/35",children:r.id.slice(0,8)})]}),e.jsx("div",{className:"rounded-full bg-primary/5 px-2 py-0.5 border border-primary/10",children:e.jsx("span",{className:"text-[9px] font-medium uppercase tracking-[0.12em] text-primary/65",children:"CCS-TEC-v3"})})]})]}):e.jsxs("div",{className:"flex h-full flex-col items-center justify-center p-8 text-center animate-in fade-in duration-1000",children:[e.jsxs("div",{className:"relative mb-8",children:[e.jsx("div",{className:"absolute inset-0 animate-ping rounded-full bg-primary/5 p-12"}),e.jsx("div",{className:"relative rounded-full border-2 border-dashed border-border/40 p-10 bg-muted/5",children:e.jsx(z,{className:"h-10 w-10 text-muted-foreground/20"})})]}),e.jsxs("div",{className:"max-w-xs space-y-3",children:[e.jsx("h3",{className:"text-[15px] font-semibold uppercase tracking-[0.14em] text-foreground/65",children:"Inspector Standby"}),e.jsx("p",{className:"text-[13px] leading-relaxed text-muted-foreground/55 font-medium",children:"Select a telemetry node from the active data queue to perform deep analysis of its operational context."})]})]})}function Y({entries:r,selectedEntryId:s,onSelect:t,sourceLabels:d,isLoading:o,isFetching:m}){return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-background/50 backdrop-blur-sm",children:[e.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border bg-card/40 px-6 py-3 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-2 w-2 animate-pulse rounded-full bg-primary shadow-[0_0_12px_rgba(var(--primary),0.6)]"}),e.jsx("h2",{className:"text-[12px] font-semibold uppercase tracking-[0.14em] text-foreground",children:"Live Entry Stream"})]}),e.jsx("div",{className:"h-4 w-px bg-border/60"}),e.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-emerald-500/20 bg-emerald-500/10 px-2 py-0.5",children:[e.jsx(D,{className:"h-3 w-3 text-emerald-500"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.12em] text-emerald-600",children:"Live telemetry"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[m&&e.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-primary/20 bg-primary/10 px-3 py-1",children:[e.jsx(ye,{className:"h-3 w-3 animate-spin text-primary"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.12em] text-primary",children:"Syncing"})]}),e.jsx("span",{className:"font-mono text-[10px] font-medium uppercase tracking-[0.16em] text-foreground/35",children:"NODE.01"})]})]}),e.jsxs("div",{className:"flex items-center gap-0 border-b border-border bg-muted/30 px-0 py-2 text-[10px] font-semibold uppercase tracking-[0.12em] text-foreground/45",children:[e.jsx("div",{className:"w-[6.5rem] shrink-0 px-6",children:"Time"}),e.jsx("div",{className:"w-14 shrink-0 border-l border-border/10 px-2 text-center",children:"Lvl"}),e.jsx("div",{className:"w-[15rem] shrink-0 border-l border-border/10 px-4",children:"Source"}),e.jsx("div",{className:"flex-1 border-l border-border/10 px-4",children:"Message"}),e.jsx("div",{className:"w-[5.5rem] shrink-0 border-l border-border/10 px-2 text-center",children:"Proc"}),e.jsx("div",{className:"w-[5.5rem] shrink-0 border-l border-border/10 px-3 text-center",children:"Run"}),e.jsx("div",{className:"w-11 shrink-0 border-l border-border/10 px-2 text-center",children:"Open"})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:o?e.jsx("div",{className:"space-y-1 p-2",children:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15].map(a=>e.jsx("div",{className:"h-10 w-full animate-pulse rounded-lg border border-border/5 bg-muted/20"},a))}):r.length===0?e.jsxs("div",{className:"flex h-full animate-in fade-in duration-1000 flex-col items-center justify-center gap-6 px-8 text-center",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 animate-ping rounded-full bg-muted/5 p-12"}),e.jsx("div",{className:"relative rounded-full border border-dashed border-border/40 bg-muted/5 p-10",children:e.jsx(we,{className:"h-10 w-10 text-muted-foreground/20"})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[13px] font-semibold uppercase tracking-[0.14em] text-foreground/55",children:"No matching entries"}),e.jsx("p",{className:"max-w-[18rem] text-[12px] font-medium leading-relaxed text-muted-foreground/60",children:"Your current source, level, or search filters are hiding the stream. Adjust them to bring entries back into view."})]})]}):e.jsx(C,{className:"h-full",children:e.jsx("div",{className:"flex flex-col",children:r.map(a=>{const l=a.id===s;return e.jsxs("button",{type:"button",onClick:()=>t(a.id),className:n("group relative flex w-full items-center border-b border-border/5 px-0 py-2.5 text-left transition-all duration-150",l?"z-10 bg-primary/[0.08] shadow-[inset_4px_0_0_rgba(var(--primary),1)]":"bg-transparent hover:bg-muted/30"),children:[e.jsx("div",{className:"absolute inset-y-0 left-0 w-1 origin-center scale-y-0 bg-primary transition-transform duration-300 group-hover:scale-y-100"}),e.jsxs("div",{className:"flex w-full items-center gap-0",children:[e.jsx("div",{className:"flex w-[6.5rem] shrink-0 items-center",children:e.jsx("p",{className:n("px-6 font-mono text-[11px] font-semibold tabular-nums transition-colors",l?"text-primary":"text-foreground/60 group-hover:text-foreground"),children:new Date(a.timestamp).toLocaleTimeString(void 0,{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})})}),e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-0",children:[e.jsx("div",{className:"flex w-14 shrink-0 items-center justify-center opacity-80 transition-opacity group-hover:opacity-100",children:e.jsx(re,{level:a.level,className:"origin-center scale-[0.85]"})}),e.jsxs("div",{className:"flex w-[15rem] shrink-0 flex-col gap-0.5 overflow-hidden px-4",children:[e.jsx("span",{className:n("truncate text-[11px] font-semibold uppercase tracking-[0.12em] transition-colors",l?"text-foreground":"text-foreground/50 group-hover:text-foreground/80"),children:d[a.source]??a.source}),e.jsx("span",{className:"truncate text-[10px] font-medium uppercase tracking-[0.1em] text-muted-foreground/55",children:a.event})]}),e.jsx("div",{className:"min-w-0 flex-1 px-4",children:e.jsx("p",{className:n("truncate text-[13px] font-medium leading-5 transition-colors",l?"text-foreground":"text-foreground/70 group-hover:text-foreground"),children:a.message})}),e.jsx("div",{className:"flex w-[5.5rem] shrink-0 items-center justify-center px-2 font-mono text-[10px] font-semibold tabular-nums tracking-[0.12em] text-foreground/30 transition-colors group-hover:text-primary/45",children:a.processId??"????"}),e.jsx("div",{className:"flex w-[5.5rem] shrink-0 items-center justify-center px-3 font-mono text-[10px] font-semibold tabular-nums tracking-[0.12em] text-foreground/30 transition-colors group-hover:text-primary/45",children:a.runId?.slice(0,4).toUpperCase()??"NONE"}),e.jsx("div",{className:"flex w-11 shrink-0 items-center justify-center px-2",children:e.jsx("div",{className:n("flex h-7 w-7 items-center justify-center rounded-full border transition-all",l?"animate-in zoom-in duration-300 border-primary/20 bg-primary/10 text-primary":"border-transparent text-foreground/20 group-hover:border-border/40 group-hover:bg-background/80 group-hover:text-foreground/55"),children:e.jsx(Z,{className:"h-3.5 w-3.5"})})})]})]})]},a.id)})})})}),e.jsxs("div",{className:"flex shrink-0 items-center justify-between border-t border-border bg-muted/5 px-6 py-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.12em] text-foreground/35",children:"Node: CCS-CORE"}),e.jsx("div",{className:"h-1 w-1 rounded-full bg-border/40"}),e.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.12em] text-foreground/35",children:"Status: Operational"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("span",{className:"text-[10px] font-medium uppercase tracking-[0.12em] text-foreground/35",children:["Entries: ",r.length]})})]})]})}const se=["logs","config"],ae=["logs","sources"],Te=150;function De(){const[r,s]=c.useState("all"),[t,d]=c.useState("all"),[o,m]=c.useState(""),[a,l]=c.useState(Te),[g,u]=c.useState(null),p=c.useDeferredValue(o.trim()),h=Q({queryKey:se,queryFn:async()=>(await L.logs.getConfig()).logging,refetchInterval:3e4}),v=Q({queryKey:ae,queryFn:async()=>(await L.logs.getSources()).sources,refetchInterval:15e3}),i=Q({queryKey:["logs","entries",r,t,p,a],queryFn:async()=>(await L.logs.getEntries({source:r==="all"?void 0:r,level:t==="all"?void 0:t,search:p||void 0,limit:a})).entries,placeholderData:Ie,refetchInterval:1e4}),I=c.useMemo(()=>{const N=i.data??[];return N.length===0?null:g&&N.some(j=>j.id===g)?g:N[0]?.id??null},[i.data,g]),te=c.useMemo(()=>(i.data??[]).find(N=>N.id===I)??null,[I,i.data]),ie=c.useMemo(()=>(v.data??[]).map(j=>j.lastTimestamp).filter(j=>!!j).sort((j,le)=>le.localeCompare(j))[0]??null,[v.data]);return{configQuery:h,sourcesQuery:v,entriesQuery:i,selectedSource:r,setSelectedSource:s,selectedLevel:t,setSelectedLevel:d,search:o,setSearch:m,limit:a,setLimit:l,selectedEntryId:I,setSelectedEntryId:u,selectedEntry:te,latestTimestamp:ie,isInitialLoading:!h.data&&h.isLoading||!v.data&&v.isLoading||!i.data&&i.isLoading}}function Oe(){const r=_e();return Ee({mutationFn:s=>L.logs.updateConfig(s),onSuccess:async()=>{await Promise.all([r.invalidateQueries({queryKey:se}),r.invalidateQueries({queryKey:ae}),r.invalidateQueries({queryKey:["logs","entries"]})]),q.success("Logging configuration saved.")},onError:s=>{q.error(s.message||"Failed to save logging configuration.")}})}function ze(){return[{value:"all",label:"All levels"},{value:"error",label:"Errors"},{value:"warn",label:"Warnings"},{value:"info",label:"Info"},{value:"debug",label:"Debug"}]}function Pe(r){return Object.fromEntries(r.map(s=>[s.source,s.label]))}function H({sources:r,selectedSource:s,onSourceChange:t,selectedLevel:d,onLevelChange:o,search:m,onSearchChange:a,limit:l,onLimitChange:g,onRefresh:u,isRefreshing:p}){const h=ze(),v=[50,100,150,250];return e.jsxs("div",{className:"flex flex-col gap-6 animate-in fade-in slide-in-from-left-2 duration-700",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between px-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-primary shadow-[0_0_8px_rgba(var(--primary),0.5)]"}),e.jsx(b,{htmlFor:"logs-search",className:"text-[11px] font-semibold uppercase tracking-[0.14em] text-foreground/80",children:"Payload Search"})]}),e.jsx(A,{className:"h-3 w-3 text-primary/20"})]}),e.jsxs("div",{className:"group relative",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-3.5 flex items-center transition-all group-focus-within:translate-x-1",children:e.jsx(ke,{className:"h-3.5 w-3.5 text-foreground/20 group-focus-within:text-primary transition-colors"})}),e.jsx(R,{id:"logs-search","aria-label":"Search",value:m,onChange:i=>a(i.target.value),placeholder:"Scan for patterns...",className:"h-11 rounded-xl border-2 border-border/40 bg-background/50 pl-10 text-[13px] font-medium text-foreground placeholder:text-foreground/35 focus-visible:border-primary/40 focus-visible:ring-0 transition-all shadow-inner"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 px-1",children:[e.jsx(Se,{className:"h-3 w-3 text-primary/40"}),e.jsx(b,{className:"text-[11px] font-semibold uppercase tracking-[0.14em] text-foreground/80",children:"Source Matrix"})]}),e.jsxs("div",{className:"flex flex-col gap-1","aria-label":"Source filter",children:[e.jsxs("button",{type:"button",onClick:()=>t("all"),className:n("group relative flex items-center justify-between rounded-lg border px-3 py-2 transition-all active:scale-[0.98]",s==="all"?"border-primary/50 bg-primary/10 text-primary shadow-[0_0_15px_rgba(var(--primary),0.1)]":"border-border/40 bg-muted/20 text-foreground/40 hover:border-border hover:bg-muted/40 hover:text-foreground/80"),children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em]",children:"Global Stream"}),s==="all"&&e.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-primary shadow-[0_0_8px_rgba(var(--primary),0.8)]"})]}),e.jsx("div",{className:"grid grid-cols-2 gap-1 mt-1",children:r.map(i=>e.jsx("button",{type:"button",onClick:()=>t(i.source),className:n("rounded-lg border px-2.5 py-1.5 text-[10px] font-semibold uppercase tracking-[0.1em] transition-all active:scale-[0.97]",s===i.source?"border-primary/50 bg-primary/10 text-primary shadow-sm":"border-border/40 bg-muted/20 text-foreground/40 hover:border-border hover:bg-muted/40 hover:text-foreground/80"),children:i.label},i.source))})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 px-1",children:[e.jsx(Le,{className:"h-3 w-3 text-primary/40"}),e.jsx(b,{className:"text-[11px] font-semibold uppercase tracking-[0.14em] text-foreground/80",children:"Sensitivity"})]}),e.jsx("div",{className:"grid grid-cols-2 gap-1.5","aria-label":"Level filter",children:h.map(i=>e.jsxs("button",{type:"button",onClick:()=>o(i.value),className:n("flex flex-col items-center gap-1 rounded-lg border px-2 py-2 text-[10px] font-semibold uppercase tracking-[0.1em] transition-all active:scale-[0.97]",d===i.value?"border-primary/50 bg-primary/10 text-primary shadow-[0_0_15px_rgba(var(--primary),0.1)]":"border-border/40 bg-muted/20 text-foreground/40 hover:border-border hover:bg-muted/40 hover:text-foreground/80"),children:[e.jsx("span",{children:i.label}),e.jsx("div",{className:n("h-0.5 w-4 rounded-full transition-colors",d===i.value?"bg-primary":"bg-foreground/10")})]},i.value))})]}),e.jsx("div",{className:"mt-4 rounded-2xl border-2 border-border bg-card/40 p-1.5 shadow-xl shadow-black/5",children:e.jsxs("div",{className:"rounded-[calc(1rem-2px)] border border-dashed border-border bg-background/60 p-4 space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.14em] text-primary",children:"Operational Window"}),e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-[0.1em] text-foreground/45",children:"Tail Capacity"})]}),e.jsx("div",{className:"h-8 w-8 rounded-lg bg-primary/5 border border-primary/10 flex items-center justify-center",children:e.jsx(A,{className:"h-4 w-4 text-primary/40"})})]}),e.jsx("div",{className:"grid grid-cols-4 gap-1.5","aria-label":"Visible entries",children:v.map(i=>e.jsx("button",{type:"button",onClick:()=>g(i),className:n("rounded-md border py-1.5 text-[11px] font-semibold tabular-nums transition-all active:scale-[0.95]",l===i?"border-foreground bg-foreground text-background":"border-border/60 bg-muted/40 text-foreground/40 hover:bg-muted hover:text-foreground"),children:i},i))}),e.jsxs(f,{variant:"ghost",size:"sm",className:"group relative h-10 w-full overflow-hidden rounded-xl border-none bg-primary text-[11px] font-semibold uppercase tracking-[0.14em] text-primary-foreground transition-all hover:scale-[1.02] hover:shadow-lg hover:shadow-primary/20 active:scale-[0.98]",onClick:u,children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/10 to-transparent -translate-x-full group-hover:translate-x-full transition-transform duration-1000"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($,{className:n("h-3.5 w-3.5",p&&"animate-spin")}),e.jsx("span",{children:"Refresh Entries"})]})]})]})})]})}function Ae(){return e.jsxs("div",{className:"space-y-6","aria-label":"Loading logs workspace",children:[e.jsx(y,{className:"gap-4",children:e.jsxs(k,{className:"space-y-3",children:[e.jsx(x,{className:"h-4 w-28"}),e.jsx(x,{className:"h-8 w-72"}),e.jsx(x,{className:"h-4 w-[30rem]"})]})}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-4",children:[1,2,3,4].map(r=>e.jsx(y,{className:"gap-3",children:e.jsxs(k,{className:"space-y-2",children:[e.jsx(x,{className:"h-4 w-20"}),e.jsx(x,{className:"h-7 w-24"})]})},r))}),e.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,1.45fr)_22rem]",children:[e.jsxs(y,{className:"gap-4",children:[e.jsxs(k,{className:"space-y-3",children:[e.jsx(x,{className:"h-4 w-52"}),e.jsx("div",{className:"grid gap-3 md:grid-cols-4",children:[1,2,3,4].map(r=>e.jsx(x,{className:"h-10 w-full"},r))})]}),e.jsxs(T,{className:"grid gap-4 xl:grid-cols-[22rem_minmax(0,1fr)]",children:[e.jsx(x,{className:"h-[26rem] w-full"}),e.jsx(x,{className:"h-[26rem] w-full"})]})]}),e.jsxs(y,{className:"gap-4",children:[e.jsxs(k,{className:"space-y-3",children:[e.jsx(x,{className:"h-5 w-44"}),e.jsx(x,{className:"h-4 w-full"})]}),e.jsx(T,{className:"space-y-4",children:[1,2,3,4].map(r=>e.jsx(x,{className:"h-10 w-full"},r))})]})]})]})}const F=1200,Me=336,qe=368,U=52;function B({side:r,label:s,onExpand:t}){return e.jsxs("div",{className:n("flex h-full w-full flex-col items-center justify-center gap-4 bg-muted/5",r==="left"?"border-r border-border":"border-l border-border"),children:[e.jsx(f,{variant:"ghost",size:"icon",onClick:t,"aria-label":`Show ${s.toLowerCase()}`,className:"h-9 w-9 rounded-xl border border-border/70 bg-background/85 shadow-sm",children:r==="left"?e.jsx(ee,{className:"h-4 w-4"}):e.jsx(X,{className:"h-4 w-4"})}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.14em] text-foreground/45",style:{writingMode:"vertical-rl"},children:s})]})}function Ze(){const r=De(),s=Oe(),t=Pe(r.sourcesQuery.data??[]),[d,o]=c.useState(()=>typeof window<"u"?window.innerWidth>=F:!1),[m,a]=c.useState(!1),[l,g]=c.useState(!1);if(c.useEffect(()=>{const p=window.matchMedia(`(min-width: ${F}px)`),h=()=>{o(window.innerWidth>=F)};return h(),p.addEventListener("change",h),()=>p.removeEventListener("change",h)},[]),r.isInitialLoading)return e.jsx(Ae,{});const u=r.configQuery.data;return u?e.jsxs("div",{className:"relative flex h-full min-h-full flex-col overflow-hidden border-t border-border/40 bg-background font-sans text-foreground antialiased selection:bg-primary/30 selection:text-primary",children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 z-0 opacity-40 [background-image:radial-gradient(circle_at_1px_1px,rgba(38,38,36,0.08)_1px,transparent_0)] [background-size:14px_14px]"}),e.jsxs("div",{className:"relative z-10 flex shrink-0 items-center justify-between border-b border-border/80 bg-card/95 px-6 py-2 backdrop-blur-xl shadow-md transition-all xl:px-8",children:[e.jsxs("div",{className:"flex items-center gap-10",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"group flex h-9 w-9 items-center justify-center rounded-xl border-2 border-primary/20 bg-primary/5 text-primary shadow-inner transition-all hover:scale-110 active:scale-90",children:e.jsx(M,{className:"h-4.5 w-4.5 transition-transform group-hover:rotate-6"})}),e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"rounded-full bg-primary px-2 py-0.5 text-[10px] font-semibold uppercase tracking-[0.14em] text-primary-foreground shadow-lg shadow-primary/20",children:"Operational"}),e.jsx("h1",{className:"text-[17px] font-semibold tracking-tight text-foreground",children:"Log Operations Center"})]}),e.jsx("p",{className:"font-mono text-[10px] font-medium uppercase tracking-[0.16em] text-foreground/45",children:"CCS.TOC.LOGS.STREAM.v3"})]})]}),e.jsx("div",{className:"hidden h-8 w-px bg-border/80 md:block"}),e.jsxs("div",{className:"hidden items-center gap-10 md:flex",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:n("h-2 w-2 rounded-full ring-4 transition-all duration-700",u.redact?"bg-emerald-500 shadow-[0_0_20px_rgba(16,185,129,0.6)] ring-emerald-500/30":"bg-zinc-600 ring-transparent")}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.14em] text-foreground/90",children:"Redaction"}),e.jsx("span",{className:"text-[11px] font-medium text-foreground/50",children:u.redact?"Enforced":"Standby"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-lg border-2 border-border bg-muted shadow-inner",children:e.jsx(Ce,{className:"h-3.5 w-3.5 text-foreground"})}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.14em] text-foreground/90",children:"Retention"}),e.jsxs("span",{className:"text-[11px] font-medium text-foreground/50",children:[u.retain_days,"D / ",u.rotate_mb,"MB"]})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(f,{variant:"ghost",size:"sm",className:"group h-9 gap-3 rounded-xl border-2 border-border bg-muted px-5 text-[11px] font-semibold uppercase tracking-[0.14em] text-foreground transition-all hover:bg-foreground hover:text-background active:scale-95 shadow-lg shadow-black/5",onClick:()=>void Promise.all([r.sourcesQuery.refetch(),r.entriesQuery.refetch()]),children:[e.jsxs("div",{className:"relative",children:[e.jsx($,{className:n("h-3.5 w-3.5 transition-transform duration-500",(r.entriesQuery.isFetching||r.sourcesQuery.isFetching)&&"animate-spin")}),!r.entriesQuery.isFetching&&!r.sourcesQuery.isFetching&&e.jsx("div",{className:"absolute -right-1 -top-1 h-1.5 w-1.5 rounded-full border border-muted bg-primary animate-pulse"})]}),r.entriesQuery.isFetching||r.sourcesQuery.isFetching?"Syncing":"Refresh"]}),e.jsx("div",{className:"h-7 w-px bg-border/80"}),e.jsx(f,{asChild:!0,variant:"ghost",size:"sm",className:"h-9 w-9 rounded-xl border-2 border-border bg-muted p-0 text-foreground transition-all hover:bg-foreground hover:text-background active:scale-95 shadow-lg shadow-black/5",children:e.jsx(ne,{to:"/health",children:e.jsx(Z,{className:"h-4 w-4"})})})]})]}),e.jsx("div",{className:"relative z-10 flex min-h-0 flex-1 overflow-hidden",children:e.jsxs(G,{defaultValue:"stream",className:"flex flex-1 flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border/80 bg-card/80 px-6 py-2 backdrop-blur-xl shadow-inner xl:px-8",children:[e.jsxs(J,{className:"h-10 w-auto gap-1.5 rounded-xl border border-border/60 bg-muted/40 p-1",children:[e.jsx(_,{value:"stream",className:"rounded-lg px-5 text-[11px] font-semibold uppercase tracking-[0.12em] text-foreground/60 transition-all data-[state=active]:bg-background data-[state=active]:text-primary data-[state=active]:shadow-md",children:"Telemetry Stream"}),e.jsx(_,{value:"errors",className:"rounded-lg px-5 text-[11px] font-semibold uppercase tracking-[0.12em] text-foreground/60 transition-all data-[state=active]:bg-background data-[state=active]:text-primary data-[state=active]:shadow-md",children:"Legacy Errors"})]}),e.jsxs("div",{className:"hidden items-center gap-3 lg:flex",children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-border bg-muted px-3 py-1 shadow-inner",children:[e.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-emerald-500 shadow-[0_0_8px_rgba(16,185,129,0.6)]"})]}),e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-tight text-foreground/80",children:"Connected"})]}),e.jsxs("span",{className:"pr-4 text-[11px] font-medium tabular-nums text-foreground/45",children:[r.entriesQuery.data?.length??0," captured"]})]})]}),e.jsx(E,{value:"stream",className:"m-0 flex min-h-0 flex-1 overflow-y-auto lg:overflow-hidden focus-visible:outline-none",children:d?e.jsxs("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[e.jsx("div",{"data-logs-pane":"filters",style:{width:m?U:Me},className:"flex min-h-0 shrink-0 bg-muted/5",children:m?e.jsx(B,{side:"left",label:"Filters",onExpand:()=>a(!1)}):e.jsxs("div",{className:"flex h-full min-h-0 w-full flex-col border-r border-border p-5 2xl:p-6",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.14em] text-foreground/80",children:"Filters"}),e.jsx("p",{className:"text-[11px] text-muted-foreground/70",children:"Search, source, and retention controls"})]}),e.jsx(f,{variant:"ghost",size:"icon",onClick:()=>a(!0),"aria-label":"Hide filters",className:"h-9 w-9 rounded-xl border border-border/70 bg-background/85 shadow-sm",children:e.jsx(X,{className:"h-4 w-4"})})]}),e.jsx(C,{className:"min-h-0 flex-1","data-logs-scroll-region":"filters",children:e.jsxs("div",{className:"space-y-5 pr-4",children:[e.jsx(H,{sources:r.sourcesQuery.data??[],selectedSource:r.selectedSource,onSourceChange:r.setSelectedSource,selectedLevel:r.selectedLevel,onLevelChange:r.setSelectedLevel,search:r.search,onSearchChange:r.setSearch,limit:r.limit,onLimitChange:r.setLimit,onRefresh:()=>void Promise.all([r.sourcesQuery.refetch(),r.entriesQuery.refetch()]),isRefreshing:r.entriesQuery.isFetching||r.sourcesQuery.isFetching}),e.jsx("div",{className:"border-t border-border/20 pt-5",children:e.jsx(K,{config:u,onSave:p=>s.mutate(p),isPending:s.isPending})})]})})]})}),e.jsx("div",{"data-logs-pane":"entries",className:"flex min-h-0 min-w-0 flex-1 overflow-hidden border-l border-r border-border bg-background/95",children:e.jsx(Y,{entries:r.entriesQuery.data??[],selectedEntryId:r.selectedEntryId,onSelect:r.setSelectedEntryId,sourceLabels:t,isLoading:r.entriesQuery.isLoading,isFetching:r.entriesQuery.isFetching})}),e.jsx("div",{"data-logs-pane":"details",style:{width:l?U:qe},className:"flex min-h-0 shrink-0 bg-muted/5 shadow-inner",children:l?e.jsx(B,{side:"right",label:"Details",onExpand:()=>g(!1)}):e.jsxs("div",{className:"flex h-full min-h-0 w-full flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border/50 bg-background/60 px-3 py-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.14em] text-foreground/80",children:"Details"}),e.jsx("p",{className:"text-[11px] text-muted-foreground/70",children:"Selected entry context and raw payload"})]}),e.jsx(f,{variant:"ghost",size:"icon",onClick:()=>g(!0),"aria-label":"Hide details",className:"h-9 w-9 rounded-xl border border-border/70 bg-background/85 shadow-sm",children:e.jsx(ee,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(V,{entry:r.selectedEntry,sourceLabel:r.selectedEntry?t[r.selectedEntry.source]:void 0})})]})})]}):e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[e.jsx("div",{className:"border-b border-border bg-muted/5 p-5",children:e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(H,{sources:r.sourcesQuery.data??[],selectedSource:r.selectedSource,onSourceChange:r.setSelectedSource,selectedLevel:r.selectedLevel,onLevelChange:r.setSelectedLevel,search:r.search,onSearchChange:r.setSearch,limit:r.limit,onLimitChange:r.setLimit,onRefresh:()=>void Promise.all([r.sourcesQuery.refetch(),r.entriesQuery.refetch()]),isRefreshing:r.entriesQuery.isFetching||r.sourcesQuery.isFetching}),e.jsx(K,{config:u,onSave:p=>s.mutate(p),isPending:s.isPending})]})}),e.jsx("div",{className:"flex min-h-[32rem] flex-col overflow-hidden border-b border-border bg-background/95",children:e.jsx(Y,{entries:r.entriesQuery.data??[],selectedEntryId:r.selectedEntryId,onSelect:r.setSelectedEntryId,sourceLabels:t,isLoading:r.entriesQuery.isLoading,isFetching:r.entriesQuery.isFetching})}),e.jsx("div",{className:"flex min-h-[30rem] flex-col overflow-hidden bg-muted/5 shadow-inner",children:e.jsx(V,{entry:r.selectedEntry,sourceLabel:r.selectedEntry?t[r.selectedEntry.source]:void 0})})]})}),e.jsx(E,{value:"errors",className:"m-0 flex-1 overflow-y-auto bg-background/20 p-6 focus-visible:outline-none xl:p-8",children:e.jsxs("div",{className:"mx-auto max-w-5xl space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-[2.5rem] border-2 border-border bg-card/40 p-1.5 shadow-2xl shadow-black/10",children:[e.jsx("div",{className:"absolute inset-0 opacity-[0.02] pointer-events-none [background-image:radial-gradient(circle_at_center,var(--primary)_1px,transparent_0)] [background-size:24px_24px]"}),e.jsx(y,{className:"rounded-[calc(2.5rem-0.375rem)] border-none bg-background/60 shadow-none overflow-hidden backdrop-blur-md",children:e.jsxs(T,{className:"flex flex-col gap-6 p-10",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl border-2 border-primary/20 bg-primary/10 text-primary shadow-inner",children:e.jsx(M,{className:"h-5 w-5"})}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.4em] text-primary",children:"Legacy Diagnostic Node"}),e.jsx("p",{className:"text-[9px] font-bold uppercase tracking-widest text-muted-foreground/40",children:"CCS-MATRIX-FAILURE-MONITOR"})]})]}),e.jsx("div",{className:"rounded-full border border-border bg-background/50 px-3 py-1 text-[9px] font-black uppercase tracking-widest text-foreground/40 shadow-inner",children:"Mode: Historical"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h2",{className:"text-3xl font-black uppercase tracking-tighter text-foreground",children:"CLIProxy Failure Analysis"}),e.jsx("p",{className:"max-w-3xl text-[15px] font-medium leading-relaxed text-muted-foreground/60",children:"Maintain oversight of legacy request failures while the unified stream consolidates system-wide telemetry. This view provides direct access to the historical failure matrix for deep-field debugging."})]}),e.jsx("div",{className:"h-px w-full bg-gradient-to-r from-transparent via-border to-transparent opacity-40"})]})})]}),e.jsxs("div",{className:"rounded-[2.5rem] border-2 border-border bg-muted/5 p-8 shadow-inner backdrop-blur-sm",children:[e.jsxs("div",{className:"mb-6 flex items-center gap-3",children:[e.jsx("div",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-primary shadow-[0_0_8px_rgba(var(--primary),0.5)]"}),e.jsx("span",{className:"text-[10px] font-black uppercase tracking-[0.3em] text-foreground/40",children:"Realtime Monitoring Deck"})]}),e.jsx(xe,{})]})]})})]})})]}):null}export{Ze as LogsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s}from"./radix-ui-Zb8sVEtn.js";import{r}from"./react-vendor-CNOkPC89.js";import{I as i,d as m}from"./index-
|
|
1
|
+
import{j as s}from"./radix-ui-Zb8sVEtn.js";import{r}from"./react-vendor-CNOkPC89.js";import{I as i,d as m}from"./index-Du97tqVQ.js";import{E as l,g as n}from"./icons-DfENUzBo.js";function f({label:e,...a}){const[t,o]=r.useState(!1);return s.jsxs("div",{className:"space-y-1",children:[e&&s.jsx("label",{className:"text-sm font-medium",children:e}),s.jsxs("div",{className:"relative",children:[s.jsx(i,{type:t?"text":"password",className:"pr-10 font-mono",...a}),s.jsx(m,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3",onClick:()=>o(!t),tabIndex:-1,children:t?s.jsx(l,{className:"w-4 h-4"}):s.jsx(n,{className:"w-4 h-4"})})]})]})}export{f as M};
|