@linxiraos/pi-stats 1.2.0 → 1.2.1

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.
@@ -232,5 +232,5 @@ You might need to use a local HTTP server (instead of file://): https://react.de
232
232
  <%s {...props} />
233
233
  React keys must be passed directly to JSX without using spread:
234
234
  let props = %s;
235
- <%s key={someKey} {...props} />`,it,ye,V,ye),xt[ye+it]=!0)}if(ye=null,Ct!==void 0&&(c(Ct),ye=""+Ct),h(ze)&&(c(ze.key),ye=""+ze.key),"key"in ze){Ct={};for(var Re in ze)Re!=="key"&&(Ct[Re]=ze[Re])}else Ct=ze;return ye&&x(Ct,typeof W==="function"?W.displayName||W.name||"Unknown":W),L(W,ye,Ct,p(),ct,Me)}function C(W){w(W)?W._store&&(W._store.validated=1):typeof W==="object"&&W!==null&&W.$$typeof===X&&(W._payload.status==="fulfilled"?w(W._payload.value)&&W._payload.value._store&&(W._payload.value._store.validated=1):W._store&&(W._store.validated=1))}function w(W){return typeof W==="object"&&W!==null&&W.$$typeof===A}var A=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),D=Symbol.for("react.fragment"),M=Symbol.for("react.strict_mode"),B=Symbol.for("react.profiler"),P=Symbol.for("react.consumer"),j=Symbol.for("react.context"),Y=Symbol.for("react.forward_ref"),ce=Symbol.for("react.suspense"),J=Symbol.for("react.suspense_list"),te=Symbol.for("react.memo"),X=Symbol.for("react.lazy"),ae=Symbol.for("react.activity"),H=Symbol.for("react.client.reference"),de=Ys.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,xe=Object.prototype.hasOwnProperty,Ce=Array.isArray,Be=console.createTask?console.createTask:function(){return null};Ys={react_stack_bottom_frame:function(W){return W()}};var ne,me={},ke=Ys.react_stack_bottom_frame.bind(Ys,S)(),$e=Be(f(S)),xt={};rM.Fragment=D,rM.jsxDEV=function(W,ze,Ct,it){var ct=1e4>de.recentlyCreatedOwnerStacks++;return g(W,ze,Ct,it,ct?Error("react-stack-top-frame"):ke,ct?Be(f(W)):$e)}})()});var XT=Z(ak(),1);var Ti=Z(gt(),1);var cm=Z(gt(),1);var ok=(l)=>l?.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();function nk(l,i,c=[]){if(i==null)throw Error("[lucide]: iconNode is required when icon name is used");return{name:ok(l),size:24,node:i,...c.length>0?{aliases:c}:{}}}var rk=(l)=>{let i="",c=!1;for(let f of l){if(f==="-"||f==="_"||f<=" "){c=i.length>0;continue}if(i.length===0)i+=f.toLowerCase();else i+=c?f.toUpperCase():f;c=!1}return i};var lk=(l)=>{let i=rk(l);return i.charAt(0).toUpperCase()+i.slice(1)};var sd=Z(gt(),1);var ld=(...l)=>l.filter((i,c,f)=>Boolean(i)&&i.trim()!==""&&f.indexOf(i)===c).join(" ").trim();var _l={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};function qv(l){return l!==null&&l!==void 0}function sk(l,i={}){let c=i.attributeNames??{},f=(w)=>c[w]??w,p=l.size??l.width??_l.width,S=l.size??l.height??_l.height,h=l.aliases?.filter((w)=>typeof w==="string"&&w.trim()!=="").map((w)=>`lucide-${w}`)??[],x=[...l.name?[`lucide-${l.name}`]:[],...h],b=i.className?.split(" ").filter(Boolean)??[],L=i.includeDefaultClasses===!1?ld(...b):ld("lucide",...x,...b),g=i.absoluteStrokeWidth?Number(i.strokeWidth??_l["stroke-width"])*Number(l.size??l.width??_l.width)/Number(i.size??i.width??_l.width):i.strokeWidth??_l["stroke-width"];return["svg",{...Object.entries(_l).reduce((w,[A,k])=>(w[f(A)]=k,w),{}),..."color"in i&&i.color&&{[f("stroke")]:i.color},..."size"in i&&qv(i.size)&&{[f("width")]:i.size,[f("height")]:i.size},..."width"in i&&qv(i.width)&&{[f("width")]:i.width},..."height"in i&&qv(i.height)&&{[f("height")]:i.height},[f("stroke-width")]:g,...L&&{[f("class")]:L},[f("viewBox")]:`0 0 ${p} ${S}`,...i.hasA11yProp===!1?{[f("aria-hidden")]:"true"}:{},..."attributes"in i&&i.attributes},l.node.map((w)=>{let[A,k,D]=w,M=i.nonScalingStroke?{[f("vector-effect")]:"non-scaling-stroke",...k}:k;return D?[A,M,D]:[A,M]})]}function uk(l,i={}){return sk(l,{...i,attributeNames:{...i.attributeNames,class:"className","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","vector-effect":"vectorEffect"}})}var ik=(l)=>{for(let i in l)if(i.startsWith("aria-")||i==="role"||i==="title")return!0;return!1};var ii=Z(gt(),1),F2=ii.createContext({});var ck=()=>ii.useContext(F2);var dk=sd.forwardRef(({color:l,size:i,width:c,height:f,strokeWidth:p,absoluteStrokeWidth:S,nonScalingStroke:h,className:x="",children:b,iconNode:L=[],icon:g={node:L,aliases:[],size:24},...C},w)=>{let{size:A=24,strokeWidth:k=2,absoluteStrokeWidth:D=!1,nonScalingStroke:M=!1,color:B="currentColor",className:P=""}=ck()??{},j=Boolean(b)||ik(C),[Y,ce,J=[]]=uk(g,{color:l??B,width:c??i??A,height:f??i??A,strokeWidth:p??k,absoluteStrokeWidth:S??D,nonScalingStroke:h??M,className:ld(P,x),hasA11yProp:j,attributes:C});return sd.createElement(Y,{ref:w,...ce},[...J.map(([te,X])=>sd.createElement(te,X)),...Array.isArray(b)?b:[b]])});function Se(l,i=[],c=[]){let f=typeof l==="string"?nk(l,i,c):l,p=cm.forwardRef(({className:S,...h},x)=>cm.createElement(dk,{ref:x,icon:f,className:S,...h}));if(f.name)p.displayName=lk(f.name);return p}var fk={name:"circle-alert",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],aliases:["alert-circle"]};fk.node;var Hl=Se(fk);var pk={name:"face-slightly-frowning",size:24,node:[["path",{d:"M15 10V9",key:"4dkmfx"}],["path",{d:"M9 10V9",key:"1lazqi"}],["path",{d:"M9 16a5 5 0 016 0",key:"34mdxb"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],aliases:["frown"]};pk.node;var Fl=Se(pk);var mk={name:"plug-zap",size:24,node:[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]],aliases:["plug-zap-2"]};mk.node;var Gl=Se(mk);var hk={name:"sparkles",size:24,node:[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],aliases:["stars"]};hk.node;var lr=Se(hk);var gk={name:"square-chart-gantt",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 8h7",key:"kbo1nt"}],["path",{d:"M8 12h6",key:"ikassy"}],["path",{d:"M11 16h5",key:"oq65wt"}]],aliases:["gantt-chart-square","square-gantt-chart"]};gk.node;var Sn=Se(gk);var yk={name:"triangle-alert",size:24,node:[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],aliases:["alert-triangle"]};yk.node;var Vl=Se(yk);var vk={name:"activity",size:24,node:[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]};vk.node;var ud=Se(vk);var bk={name:"arrow-down",size:24,node:[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]};bk.node;var id=Se(bk);var xk={name:"arrow-left",size:24,node:[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]};xk.node;var cd=Se(xk);var Sk={name:"arrow-right",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]};Sk.node;var dd=Se(Sk);var Lk={name:"arrow-up-right",size:24,node:[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]};Lk.node;var fd=Se(Lk);var Ck={name:"arrow-up",size:24,node:[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]};Ck.node;var pd=Se(Ck);var wk={name:"check",size:24,node:[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]};wk.node;var Gs=Se(wk);var kk={name:"chevron-down",size:24,node:[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]};kk.node;var Vs=Se(kk);var Tk={name:"chevron-left",size:24,node:[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]};Tk.node;var md=Se(Tk);var Ik={name:"chevron-right",size:24,node:[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]};Ik.node;var Ln=Se(Ik);var Rk={name:"coins",size:24,node:[["path",{d:"M13.744 17.736a6 6 0 1 1-7.48-7.48",key:"bq4yh3"}],["path",{d:"M15 6h1v4",key:"11y1tn"}],["path",{d:"m6.134 14.768.866-.5 2 3.464",key:"17snzx"}],["circle",{cx:"16",cy:"8",r:"6",key:"14bfc9"}]]};Rk.node;var hd=Se(Rk);var Ak={name:"copy",size:24,node:[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]};Ak.node;var js=Se(Ak);var Mk={name:"cpu",size:24,node:[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]]};Mk.node;var gd=Se(Mk);var Dk={name:"folder-git-2",size:24,node:[["path",{d:"M18 19a5 5 0 0 1-5-5v8",key:"sz5oeg"}],["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]]};Dk.node;var yd=Se(Dk);var Ek={name:"git-branch",size:24,node:[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]]};Ek.node;var vd=Se(Ek);var Ok={name:"inbox",size:24,node:[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]};Ok.node;var bd=Se(Ok);var qk={name:"layout-grid",size:24,node:[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]};qk.node;var xd=Se(qk);var Nk={name:"menu",size:24,node:[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]]};Nk.node;var Sd=Se(Nk);var Bk={name:"monitor",size:24,node:[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]};Bk.node;var Ld=Se(Bk);var zk={name:"moon",size:24,node:[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]};zk.node;var Cd=Se(zk);var Uk={name:"refresh-cw",size:24,node:[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]};Uk.node;var jl=Se(Uk);var Pk={name:"rotate-cw",size:24,node:[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]};Pk.node;var wd=Se(Pk);var _k={name:"search",size:24,node:[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]};_k.node;var kd=Se(_k);var Hk={name:"sun",size:24,node:[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]};Hk.node;var Td=Se(Hk);var Fk={name:"wrench",size:24,node:[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]]};Fk.node;var Id=Se(Fk);var Gk={name:"x",size:24,node:[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]};Gk.node;var nn=Se(Gk);var yi=Z(gt(),1);function Nv(l){let i=l?.trim().toLowerCase()??"";if(i==="zh"||i.startsWith("zh-")||i.startsWith("zh_"))return"zh-CN";return"en"}function Vk(l){for(let i of l??[]){let c=Nv(i);if(c!=="en")return c}return"en"}function G2(l,i={}){return l.replace(/\{([\w.-]+)\}/g,(c,f)=>{let p=i[f];return p===void 0?c:String(p)})}function jk(l,i,c,f={}){let p=c[l]?.[i]??c.en?.[i];if(p===void 0)return console.warn(`[stats.i18n] missing translation: ${i}`),i;return G2(p,f)}var dm={en:{"nav.usage":"Usage","nav.activity":"Activity","nav.insights":"Insights","nav.overview":"Overview","nav.models":"Models","nav.providers":"Providers","nav.costs":"Costs","nav.requests":"Requests","nav.errors":"Errors","nav.traces":"Traces","nav.tools":"Tools","nav.frustration":"Frustration","nav.projects":"Projects","nav.gain":"Gain","nav.dashboard":"zetacode stats","nav.breadcrumb-stats":"stats","nav.pages":"Pages","nav.open-navigation":"Open navigation"},"zh-CN":{"nav.usage":"用量","nav.activity":"活动","nav.insights":"洞察","nav.overview":"总览","nav.models":"模型","nav.providers":"服务商","nav.costs":"费用","nav.requests":"请求","nav.errors":"错误","nav.traces":"调用链","nav.tools":"工具","nav.frustration":"情绪压力","nav.projects":"项目","nav.gain":"收益","nav.dashboard":"zeta 统计","nav.breadcrumb-stats":"统计","nav.pages":"导航","nav.open-navigation":"打开导航"}};var fm={en:{"common.provider":"Provider","common.providers":"Providers","common.model":"Model","common.models":"Models","common.requests":"Requests","common.request":"Request","common.tokens":"Tokens","common.share":"Share","common.cost":"Cost","common.error-rate":"Error rate","common.tokens-per-second":"Tokens/s","common.output-tokens-per-second":"Output tokens/s","common.premium":"Premium","common.premium-requests":"Premium requests","common.duration":"Duration","common.started":"Started","common.request-id":"Request id","common.session-entry":"Session entry","common.entry-id":"Entry id","common.input":"Input","common.output":"Output","common.output-message":"Output message","common.cache-read":"Cache read","common.cache-write":"Cache write","common.project":"Project","common.pages":"Pages","common.filter":"Filter…","common.no-data-in-range":"No data in this range","common.nothing-here-yet":"Nothing here yet","common.show-more":"Show more","common.total":"Total","common.average":"Average","common.unknown":"Unknown","common.root":"(root)","common.other-n":"Other ({count})","common.time-range":"Time range","common.range-1h":"1h","common.range-24h":"24h","common.range-7d":"7d","common.range-30d":"30d","common.range-90d":"90d","common.range-all":"All","common.window-1h":"the last hour","common.window-24h":"the last 24 hours","common.window-7d":"the last 7 days","common.window-30d":"the last 30 days","common.window-90d":"the last 90 days","common.window-all":"all time","common.copy":"Copy","common.copied":"Copied","common.close":"Close","common.cancel":"Cancel","common.aborted":"Aborted","common.failed":"Failed","common.error":"Error","shell.live":"Live","shell.reconnecting":"Reconnecting","shell.syncing":"Syncing","shell.sync-failed":"Sync failed","shell.indexing":"Indexing","shell.lost-connection":"Lost the live connection to the stats server; retrying","shell.ingesting":"Ingesting session files","shell.building-rollups":"Building hourly rollups; older ranges fill in as it goes","shell.sync-now":"Click to sync session files now","shell.just-now":"just now","shell.system-theme":"System theme","shell.dark-theme":"Dark theme","shell.light-theme":"Light theme","shell.range-suffix":"range","shell.jump-hint":"then letter to jump"},"zh-CN":{"common.provider":"服务商","common.providers":"服务商","common.model":"模型","common.models":"模型","common.requests":"请求","common.request":"请求","common.tokens":"Token","common.share":"占比","common.cost":"费用","common.error-rate":"错误率","common.tokens-per-second":"Token/秒","common.output-tokens-per-second":"输出 Token/秒","common.premium":"溢价","common.premium-requests":"溢价请求","common.duration":"耗时","common.started":"开始时间","common.request-id":"请求 ID","common.session-entry":"会话条目","common.entry-id":"条目 ID","common.input":"输入","common.output":"输出","common.output-message":"输出消息","common.cache-read":"缓存读取","common.cache-write":"缓存写入","common.project":"项目","common.pages":"页数","common.filter":"筛选…","common.no-data-in-range":"该时间范围内没有数据","common.nothing-here-yet":"暂无数据","common.show-more":"显示更多","common.total":"合计","common.average":"平均","common.unknown":"未知","common.root":"(根目录)","common.other-n":"其他({count})","common.time-range":"时间范围","common.range-1h":"1 小时","common.range-24h":"24 小时","common.range-7d":"7 天","common.range-30d":"30 天","common.range-90d":"90 天","common.range-all":"全部","common.window-1h":"最近 1 小时","common.window-24h":"最近 24 小时","common.window-7d":"最近 7 天","common.window-30d":"最近 30 天","common.window-90d":"最近 90 天","common.window-all":"全部时间","common.copy":"复制","common.copied":"已复制","common.close":"关闭","common.cancel":"取消","common.aborted":"已中止","common.failed":"失败","common.error":"错误","shell.live":"实时","shell.reconnecting":"重新连接中","shell.syncing":"同步中","shell.sync-failed":"同步失败","shell.indexing":"建立索引","shell.lost-connection":"与统计服务的实时连接已断开,正在重试","shell.ingesting":"正在导入会话文件","shell.building-rollups":"正在构建小时汇总;更早的时间范围会逐步补全","shell.sync-now":"点击立即同步会话文件","shell.just-now":"刚刚","shell.system-theme":"跟随系统","shell.dark-theme":"深色主题","shell.light-theme":"浅色主题","shell.range-suffix":"范围","shell.jump-hint":"再按字母跳转"}};var pm={en:{"overview.title":"Overview","overview.description":"Everything zeta did across your sessions in {window}.","overview.api-equivalent-cost":"API-equivalent cost","overview.api-cost-title":"What this usage would cost at public API rates","overview.unpriced-n":"{count} unpriced","overview.failed-n":"{count} failed","overview.conversation-tokens":"Conversation tokens","overview.tokens-title":"Uncached input + cache reads + cache writes + output","overview.output-n":"{count} output","overview.cache-rate":"Cache rate","overview.cache-rate-title":"Cache reads ÷ (uncached input + cache reads)","overview.cache-saved":"{value} saved","overview.succeeded-n":"{count} succeeded","overview.uncached-input":"Uncached input","overview.avg-latency":"Avg latency","overview.avg-ttft":"Avg TTFT","overview.activity":"Activity","overview.per-5m":"Per 5 minutes","overview.per-hour":"Per hour","overview.per-day":"Per day","overview.succeeded":"Succeeded","overview.api-equivalent":"API-equivalent","overview.token-mix":"Token mix","overview.token-mix-description":"Where conversation tokens went","overview.by-agent":"By agent","overview.requests-short":"{count} req","overview.main-agent":"Main agent","overview.subagents":"Subagents","overview.advisor":"Advisor","overview.latest-requests":"Latest requests","overview.latest-requests-description":"Most recent model calls across every session","overview.all-requests":"All requests","overview.when":"When","overview.status":"Status","overview.ok":"OK"},"zh-CN":{"overview.title":"概览","overview.description":"在{window}内,zeta 在你的所有会话中完成的一切。","overview.api-equivalent-cost":"API 等效费用","overview.api-cost-title":"这些用量按公开 API 费率计算所需的费用","overview.unpriced-n":"{count} 个未定价","overview.failed-n":"{count} 个失败","overview.conversation-tokens":"对话 Token","overview.tokens-title":"未缓存输入 + 缓存读取 + 缓存写入 + 输出","overview.output-n":"{count} 输出","overview.cache-rate":"缓存命中率","overview.cache-rate-title":"缓存读取 ÷(未缓存输入 + 缓存读取)","overview.cache-saved":"节省 {value}","overview.succeeded-n":"{count} 个成功","overview.uncached-input":"未缓存输入","overview.avg-latency":"平均延迟","overview.avg-ttft":"平均 TTFT","overview.activity":"活动","overview.per-5m":"每 5 分钟","overview.per-hour":"每小时","overview.per-day":"每天","overview.succeeded":"成功","overview.api-equivalent":"API 等效","overview.token-mix":"Token 构成","overview.token-mix-description":"对话 Token 的去向","overview.by-agent":"按代理","overview.requests-short":"{count} 次请求","overview.main-agent":"主代理","overview.subagents":"子代理","overview.advisor":"顾问","overview.latest-requests":"最新请求","overview.latest-requests-description":"所有会话中最近的模型调用","overview.all-requests":"全部请求","overview.when":"时间","overview.status":"状态","overview.ok":"正常"}};var mm={en:{"models.subtitle":"Which models did the work in {window}, and how fast they answered.","models.empty-title":"No model usage in this range","models.empty-hint":"Pick a wider range in the top bar.","models.used":"Models used","models.across-providers-one":"across {count} provider","models.across-providers":"across {count} providers","models.most-used":"Most used","models.most-used-hint":"{share} of requests · {provider}","models.failed-n":"{count} failed","models.api-cost":"API-equivalent cost","models.api-cost-title":"What this usage would cost at public API rates","models.unpriced-n":"{count} unpriced","models.request-share":"Request share","models.share-desc":"Each model's share of requests per {bucket}","models.count-desc":"Requests per {bucket}, stacked by model","models.share-mode-aria":"Share chart mode","models.all-models":"All models","models.table-desc":"Click a row for latency and throughput over time","models.cost-title":"API-equivalent estimate at public rates","models.tokens-title":"Uncached input + cache reads + cache writes + output","models.cache-rate":"Cache rate","models.cache-title":"Cache reads ÷ (uncached input + cache reads)","models.errors":"Errors","models.tps-title":"Average output tokens per second","models.ttft":"TTFT","models.ttft-title":"Average time to first token","models.trend":"Trend","models.trend-title":"Requests per {bucket}","models.efficiency":"Efficiency","models.latency":"Latency","models.cache-savings":"Cache savings","models.avg-duration":"Avg duration","models.avg-ttft":"Avg TTFT","models.uncached-input":"Uncached input","models.first-last-seen":"First seen {first} · last seen {last}","models.performance-per-bucket":"Performance per active {bucket}","models.no-samples-title":"No performance samples","models.no-samples-hint":"Timing is recorded for streamed responses.","models.tok-per-second":"{value} tok/s","models.bucket-5m":"5 minutes","models.bucket-hour":"hour","models.bucket-day":"day"},"zh-CN":{"models.subtitle":"在{window}内哪些模型完成了工作,以及它们的响应速度如何。","models.empty-title":"该时间范围内没有模型用量","models.empty-hint":"请在顶部栏选择更宽的时间范围。","models.used":"使用模型数","models.across-providers-one":"覆盖 {count} 个服务商","models.across-providers":"覆盖 {count} 个服务商","models.most-used":"使用最多","models.most-used-hint":"{share} 请求占比 · {provider}","models.failed-n":"{count} 个失败","models.api-cost":"API 等价费用","models.api-cost-title":"按公开 API 价格计算这笔用量的费用","models.unpriced-n":"{count} 个未定价","models.request-share":"请求占比","models.share-desc":"每个{bucket}中各模型的请求占比","models.count-desc":"每个{bucket}的请求数,按模型堆叠","models.share-mode-aria":"占比图表模式","models.all-models":"所有模型","models.table-desc":"点击某行可查看延迟与吞吐随时间的变化","models.cost-title":"按公开价格估算的 API 等价费用","models.tokens-title":"未缓存输入 + 缓存读取 + 缓存写入 + 输出","models.cache-rate":"缓存命中率","models.cache-title":"缓存读取 ÷(未缓存输入 + 缓存读取)","models.errors":"错误","models.tps-title":"平均每秒输出 Token 数","models.ttft":"首 Token 延迟","models.ttft-title":"平均首 Token 延迟","models.trend":"趋势","models.trend-title":"每个{bucket}的请求数","models.efficiency":"效率","models.latency":"延迟","models.cache-savings":"缓存节省","models.avg-duration":"平均耗时","models.avg-ttft":"平均首 Token 延迟","models.uncached-input":"未缓存输入","models.first-last-seen":"首次出现 {first} · 最近出现 {last}","models.performance-per-bucket":"每个活跃{bucket}的性能","models.no-samples-title":"没有性能样本","models.no-samples-hint":"只有流式响应会记录耗时。","models.tok-per-second":"{value} Token/秒","models.bucket-5m":"5 分钟","models.bucket-hour":"小时","models.bucket-day":"天"}};var hm={en:{"providers.description":"Burn, reliability and subscription headroom per provider over {window}.","providers.most-tokens":"Most tokens: {provider}","providers.failed-n":"{count} failed","providers.succeeded-n":"{count} succeeded","providers.tokens-title":"Uncached input + cache reads + cache writes + output","providers.api-equivalent-cost":"API-equivalent cost","providers.api-cost-title":"What this usage would cost at public API rates","providers.unpriced-n":"{count} unpriced","providers.totals":"Provider totals","providers.totals-description":"Cost is an API-equivalent estimate. Select a row for its token mix.","providers.totals-description-unpriced-one":"Cost is an API-equivalent estimate and excludes {count} unpriced subscription request. Select a row for its token mix.","providers.totals-description-unpriced-n":"Cost is an API-equivalent estimate and excludes {count} unpriced subscription requests. Select a row for its token mix.","providers.no-requests-in-range":"No requests in this range","providers.models-title":"Distinct models used through this provider","providers.share-title":"Fraction of all tokens in range","providers.cost-title":"API-equivalent estimate","providers.tps-title":"Average output throughput","providers.premium-title":"Premium requests (subscription multiplier units)","providers.burn":"Burn by provider","providers.burn-estimate-description":"API-equivalent estimate per {bucket}; excludes unpriced subscription requests","providers.burn-description":"Per {bucket}, top {count} providers stacked","providers.bucket-5m":"5 minutes","providers.bucket-hour":"hour","providers.bucket-day":"day","providers.no-provider-activity":"No provider activity in this range","providers.peak-burn-hours":"Peak burn hours","providers.peak-hours-description":"Tokens by local hour of day; peak at {hour}","providers.hours-description":"Tokens by local hour of day","providers.all-providers":"All providers","providers.tokens-peak-hour":"Tokens (peak hour)","providers.no-activity-in-range":"No activity in this range","providers.subscription-windows":"Subscription windows","providers.subscription-windows-description":"What one usage window buys you and how many accounts peak demand needs. Select a row to chart it.","providers.window":"Window","providers.accounts":"Accounts","providers.accounts-title":"Accounts with at least one snapshot for this window in range","providers.resets":"Resets","providers.resets-title":"Window resets observed (drops in used fraction)","providers.windows-burned":"Windows burned","providers.windows-burned-title":"Subscription-window equivalents consumed in range (sum of used-fraction increases across accounts)","providers.tokens-per-window":"Tokens / window","providers.tokens-per-window-title":"Provider tokens burned in range ÷ windows burned — what one full window is worth","providers.too-little-consumed":"Too little of the window was consumed to extrapolate","providers.peak-utilization":"Peak utilization","providers.peak-utilization-title":"Peak of summed used fraction across accounts at any sampled instant; the bar is relative to fleet capacity","providers.accounts-needed":"Accounts needed","providers.accounts-needed-title":"Accounts needed to keep peak demand under 90% of fleet capacity","providers.ideal-accounts":"{ideal} · have {have}","providers.exhaustions":"Exhaustions","providers.exhaustions-title":"Transitions into an exhausted state observed in range","providers.exhausted-n":"{count} exhausted","providers.no-snapshots-in-range":"No usage snapshots in this range","providers.snapshot-hint":"Usage snapshots accumulate whenever usage limits are fetched (TUI footer, /usage, zeta-c usage).","providers.utilization":"Window utilization","providers.utilization-description":"{window} used fraction per account, {from} – {to}","providers.utilization-description-plain":"Recorded limit utilization per account","providers.no-utilization-readings":"No utilization readings for this window","providers.exhausted":"Exhausted","providers.no-reading":"No reading","providers.high":"High","providers.account":"Account","providers.latest-used":"Latest used","providers.status":"Status","providers.peak-in-range":"Peak in range","providers.snapshots":"Snapshots","providers.recorded":"Recorded"},"zh-CN":{"providers.description":"各服务商在{window}内的消耗、可靠性与订阅余量。","providers.most-tokens":"Token 最多:{provider}","providers.failed-n":"{count} 次失败","providers.succeeded-n":"{count} 次成功","providers.tokens-title":"未缓存输入 + 缓存读取 + 缓存写入 + 输出","providers.api-equivalent-cost":"API 等效费用","providers.api-cost-title":"此用量按公开 API 费率计算需要多少费用","providers.unpriced-n":"{count} 个未定价","providers.totals":"服务商汇总","providers.totals-description":"费用为 API 等效估算。选择一行可查看其 Token 构成。","providers.totals-description-unpriced-one":"费用为 API 等效估算,且未包含 {count} 个未定价的订阅请求。选择一行可查看其 Token 构成。","providers.totals-description-unpriced-n":"费用为 API 等效估算,且未包含 {count} 个未定价的订阅请求。选择一行可查看其 Token 构成。","providers.no-requests-in-range":"该时间范围内没有请求","providers.models-title":"通过该服务商使用的不同模型","providers.share-title":"该时间范围内全部 Token 中的占比","providers.cost-title":"API 等效估算","providers.tps-title":"平均输出吞吐量","providers.premium-title":"溢价请求(订阅倍率单位)","providers.burn":"按服务商的消耗","providers.burn-estimate-description":"每{bucket}的 API 等效估算;不含未定价的订阅请求","providers.burn-description":"每{bucket},堆叠显示前 {count} 个服务商","providers.bucket-5m":"5 分钟","providers.bucket-hour":"小时","providers.bucket-day":"天","providers.no-provider-activity":"该时间范围内没有服务商活动","providers.peak-burn-hours":"消耗高峰时段","providers.peak-hours-description":"按本地时段统计的 Token;高峰在 {hour}","providers.hours-description":"按本地时段统计的 Token","providers.all-providers":"全部服务商","providers.tokens-peak-hour":"Token(高峰时段)","providers.no-activity-in-range":"该时间范围内没有活动","providers.subscription-windows":"订阅窗口","providers.subscription-windows-description":"一个用量窗口能带来多少用量,以及峰值需求需要多少个账号。选择一行可将它绘制成图表。","providers.window":"窗口","providers.accounts":"账号","providers.accounts-title":"该时间范围内对此窗口至少有一个快照的账号","providers.resets":"重置次数","providers.resets-title":"观测到的窗口重置次数(已用比例下降)","providers.windows-burned":"消耗的窗口数","providers.windows-burned-title":"该时间范围内消耗的订阅窗口等效量(各账号已用比例增量之和)","providers.tokens-per-window":"Token / 窗口","providers.tokens-per-window-title":"该时间范围内消耗的服务商 Token ÷ 消耗的窗口数 —— 一个完整窗口的价值","providers.too-little-consumed":"该窗口消耗太少,无法外推","providers.peak-utilization":"峰值利用率","providers.peak-utilization-title":"任意采样时刻各账号已用比例之和的峰值;进度条相对于整体容量","providers.accounts-needed":"所需账号数","providers.accounts-needed-title":"将峰值需求控制在整体容量 90% 以下所需的账号数","providers.ideal-accounts":"{ideal} · 现有 {have}","providers.exhaustions":"耗尽次数","providers.exhaustions-title":"该时间范围内观测到的进入耗尽状态的次数","providers.exhausted-n":"{count} 次耗尽","providers.no-snapshots-in-range":"该时间范围内没有用量快照","providers.snapshot-hint":"每当获取用量限额时都会累积用量快照(TUI 底部、/usage、zeta-c usage)。","providers.utilization":"窗口利用率","providers.utilization-description":"{window} 各账号的已用比例,{from} – {to}","providers.utilization-description-plain":"各账号已记录的限额利用率","providers.no-utilization-readings":"该窗口没有利用率记录","providers.exhausted":"已耗尽","providers.no-reading":"无读数","providers.high":"偏高","providers.account":"账号","providers.latest-used":"最新已用","providers.status":"状态","providers.peak-in-range":"范围内峰值","providers.snapshots":"快照数","providers.recorded":"记录时间"}};var gm={en:{"costs.title":"Costs","costs.description":"What {window} of usage would cost at public API rates. Subscription usage without a public price is counted as unpriced, not free.","costs.no-usage-in-range":"No usage in this range","costs.empty-hint":"Pick a wider range in the top bar.","costs.daily-estimate":"Daily estimate","costs.daily-by-model":"Per UTC day, stacked by model","costs.daily-by-component":"Per UTC day, stacked by billing component","costs.split-by":"Split by","costs.by-model":"By model","costs.by-component":"By component","costs.no-priced-usage":"No priced usage in this range","costs.unpriced-requests":"Unpriced requests","costs.where-it-went":"Where it went","costs.estimate-by-component":"Estimate by billing component","costs.unpriced-note-one":"{count} unpriced subscription request is not included.","costs.unpriced-note-n":"{count} unpriced subscription requests are not included.","costs.by-model-description":"Estimate per model with its input, output and cache split","costs.estimate":"Estimate","costs.estimate-title":"API-equivalent estimate at public rates","costs.split":"Split","costs.split-title":"Input · output · cache read · cache write","costs.per-request":"Per request","costs.per-request-title":"Estimate ÷ priced requests","costs.unpriced":"Unpriced","costs.unpriced-column-title":"Requests with no public-equivalent price","costs.api-equivalent-estimate":"API-equivalent estimate","costs.api-estimate-title":"What this usage would cost at public API rates","costs.requests-n":"{count} requests","costs.average-per-day":"Average per day","costs.average-per-day-title":"Estimate ÷ days with any usage","costs.active-days-one":"over {count} active day","costs.active-days-n":"over {count} active days","costs.top-model":"Top model","costs.top-model-hint":"{cost} · {share} of estimate","costs.nothing-priced-yet":"Nothing priced yet","costs.per-priced-request":"Per priced request","costs.per-priced-request-title":"Estimate ÷ requests that have a public price","costs.priced-n":"{count} priced","costs.unpriced-title":"Subscription usage with no public-equivalent price; excluded from the estimate","costs.unpriced-hint":"excluded from the estimate","costs.all-priced":"all usage priced"},"zh-CN":{"costs.title":"费用","costs.description":"按公开 API 费率计算,{window}的用量需要多少费用。没有公开价格的订阅用量计为未定价,而不是免费。","costs.no-usage-in-range":"此时间范围内没有用量","costs.empty-hint":"请在顶栏选择更宽的时间范围。","costs.daily-estimate":"每日估算","costs.daily-by-model":"按 UTC 日统计,按模型堆叠","costs.daily-by-component":"按 UTC 日统计,按计费组件堆叠","costs.split-by":"拆分依据","costs.by-model":"按模型","costs.by-component":"按组件","costs.no-priced-usage":"此时间范围内没有已定价的用量","costs.unpriced-requests":"未定价请求","costs.where-it-went":"费用去向","costs.estimate-by-component":"按计费组件估算","costs.unpriced-note-one":"{count} 个未定价的订阅请求未计入。","costs.unpriced-note-n":"{count} 个未定价的订阅请求未计入。","costs.by-model-description":"按模型估算,并附输入、输出与缓存的拆分","costs.estimate":"估算","costs.estimate-title":"按公开费率计算的 API 等效估算","costs.split":"拆分","costs.split-title":"输入 · 输出 · 缓存读取 · 缓存写入","costs.per-request":"单次请求","costs.per-request-title":"估算值 ÷ 已定价请求数","costs.unpriced":"未定价","costs.unpriced-column-title":"没有公开等效价格的请求","costs.api-equivalent-estimate":"API 等效估算","costs.api-estimate-title":"此用量按公开 API 费率计算需要多少费用","costs.requests-n":"{count} 个请求","costs.average-per-day":"日均","costs.average-per-day-title":"估算值 ÷ 有用量的天数","costs.active-days-one":"共 {count} 个活跃日","costs.active-days-n":"共 {count} 个活跃日","costs.top-model":"费用最高的模型","costs.top-model-hint":"{cost} · 占估算值的 {share}","costs.nothing-priced-yet":"暂无已定价用量","costs.per-priced-request":"单个已定价请求","costs.per-priced-request-title":"估算值 ÷ 有公开价格的请求数","costs.priced-n":"已定价 {count} 个","costs.unpriced-title":"没有公开等效价格的订阅用量;不计入估算","costs.unpriced-hint":"不计入估算","costs.all-priced":"全部用量均已定价"}};var ym={en:{"requests.description":"Every model call zeta made in {window}, newest first. Open a row for its full payload.","requests.loading":"Loading…","requests.load-latest":"Load latest {count}","requests.status":"Status","requests.status-all":"All","requests.none-in-window":"none in {window}","requests.since":"since {time}","requests.failed-hint":"{rate} · {count} aborted","requests.tokens-hint":"Total tokens across these requests","requests.api-equivalent-cost":"API-equivalent cost","requests.cost-hint":"What these requests would cost at public API rates","requests.unpriced-n":"{count} unpriced","requests.median-duration":"Median duration","requests.p95":"p95 {value}","requests.median-ttft":"Median TTFT","requests.ttft":"TTFT","requests.ttft-hint":"Time to first token","requests.log-title":"Request log","requests.log-loading":"Loading the latest requests…","requests.log-count-in-window":"{shown} of {total} requests in {window}","requests.log-count-latest":"{shown} of the latest {total} requests","requests.search-placeholder":"Model, provider or project","requests.footer":"Showing the latest {count} requests, back to {time}. Older requests in {window} are not loaded.","requests.empty-in-window":"No requests in {window}","requests.empty-no-match":"No requests match","requests.empty-no-match-hint":"Clear the search or status filter.","requests.when":"When","requests.uncached-input":"Uncached input tokens","requests.cache-read-title":"Cache read tokens (hover a cell for cache writes)","requests.cache-write":"Cache write: {count}","requests.cost-estimate":"API-equivalent estimate"},"zh-CN":{"requests.description":"zeta 在 {window} 内发出的每一次模型调用,最新在前。打开某一行可查看其完整载荷。","requests.loading":"加载中…","requests.load-latest":"加载最新 {count} 条","requests.status":"状态","requests.status-all":"全部","requests.none-in-window":"{window} 内没有请求","requests.since":"自 {time} 起","requests.failed-hint":"{rate} · {count} 个已中止","requests.tokens-hint":"这些请求的 Token 总量","requests.api-equivalent-cost":"API 等价费用","requests.cost-hint":"这些请求按公开 API 费率计算的费用","requests.unpriced-n":"{count} 个未定价","requests.median-duration":"耗时中位数","requests.p95":"p95 分位 {value}","requests.median-ttft":"首 Token 延迟中位数","requests.ttft":"首 Token 延迟","requests.ttft-hint":"首 Token 延迟","requests.log-title":"请求日志","requests.log-loading":"正在加载最新请求…","requests.log-count-in-window":"{window} 内共 {total} 个请求,显示 {shown} 个","requests.log-count-latest":"最新 {total} 个请求中显示 {shown} 个","requests.search-placeholder":"模型、服务商或项目","requests.footer":"显示最新 {count} 个请求,回溯至 {time}。{window} 内更早的请求未加载。","requests.empty-in-window":"{window} 内没有请求","requests.empty-no-match":"没有匹配的请求","requests.empty-no-match-hint":"清除搜索内容或状态筛选。","requests.when":"时间","requests.uncached-input":"未缓存输入 Token","requests.cache-read-title":"缓存读取 Token(将鼠标悬停在单元格上可查看缓存写入)","requests.cache-write":"缓存写入:{count}","requests.cost-estimate":"API 等价估算"}};var vm={en:{"errors.title":"Errors","errors.description":"Failed model requests in {window}, grouped by error signature. Open a failure for its full payload.","errors.footer":"Showing the latest {count} failures in {window}; older ones are not loaded.","errors.loading":"Loading…","errors.load-latest":"Load latest {count}","errors.failures":"Failures","errors.hint-in-window":"in {window}","errors.hint-latest-loaded":"latest {count} loaded","errors.signatures":"Signatures","errors.signatures-hint":"Distinct error messages after normalizing ids and numbers","errors.signatures-top":"top: {count} failures","errors.affected-models":"Affected models","errors.last-failure":"Last failure","errors.none-in-window":"none in {window}","errors.error-signatures":"Error signatures","errors.signatures-card-description":"Same message with ids and counters normalized. Select one to filter the failures below.","errors.empty-no-failures":"No failures in {window}","errors.empty-all-succeeded":"Every request succeeded or was aborted.","errors.by-model":"By model","errors.by-model-description":"Failures per model. Select one to filter.","errors.empty-no-affected-models":"No affected models","errors.loading-failures":"Loading failures…","errors.filtered-of-total":"{shown} of {total} failures, newest first","errors.search-placeholder":"Message, model or project","errors.no-match":"No failures match","errors.no-match-hint":"Clear the search or the selected filters.","errors.signature":"Signature","errors.more-models":"+{count} more","errors.last-seen":"Last seen","errors.unknown-error":"Unknown error","errors.group-meta":"{count} failures · first {first} · last {last}","errors.open-latest":"Open latest","errors.when":"When","errors.cost-hint":"API-equivalent estimate"},"zh-CN":{"errors.title":"错误","errors.description":"在 {window} 内失败的模型请求,按错误签名分组。打开某条失败可查看完整载荷。","errors.footer":"显示 {window} 内最新的 {count} 个失败;更早的未加载。","errors.loading":"加载中…","errors.load-latest":"加载最新 {count} 条","errors.failures":"失败","errors.hint-in-window":"{window} 内","errors.hint-latest-loaded":"已加载最新 {count} 条","errors.signatures":"签名","errors.signatures-hint":"对 ID 和数字归一化后不同的错误消息","errors.signatures-top":"最多:{count} 个失败","errors.affected-models":"受影响的模型","errors.last-failure":"最近一次失败","errors.none-in-window":"{window} 内没有失败","errors.error-signatures":"错误签名","errors.signatures-card-description":"同一消息在归一化 ID 和计数后归为一组。选择一项可筛选下方的失败。","errors.empty-no-failures":"{window} 内没有失败","errors.empty-all-succeeded":"所有请求均已成功或被中止。","errors.by-model":"按模型","errors.by-model-description":"各模型的失败数。选择一项可筛选。","errors.empty-no-affected-models":"没有受影响的模型","errors.loading-failures":"正在加载失败…","errors.filtered-of-total":"共 {total} 个失败,显示 {shown} 个,最新在前","errors.search-placeholder":"消息、模型或项目","errors.no-match":"没有匹配的失败","errors.no-match-hint":"清除搜索内容或已选筛选条件。","errors.signature":"签名","errors.more-models":"另有 {count} 个","errors.last-seen":"最近出现","errors.unknown-error":"未知错误","errors.group-meta":"{count} 个失败 · 首次 {first} · 最近 {last}","errors.open-latest":"打开最新","errors.when":"时间","errors.cost-hint":"按 API 价格估算"}};var bm={en:{"trace.title":"Traces","trace.description":"Recent sessions with subagent activity folded in. Open one to inspect its timeline.","trace.sessions":"Sessions","trace.session":"Session","trace.most-recent":"{count} most recent","trace.most-recent-filtered":"{shown} of {total} most recent","trace.filter-placeholder":"Filter by title, project, model…","trace.empty-title":"No sessions found","trace.empty-hint":"Run a sync to index recent activity.","trace.no-matching-title":"No matching sessions","trace.no-matching-hint":"Try a different filter.","trace.tool":"Tool","trace.tools":"Tools","trace.agent":"Agent","trace.agents":"Agents","trace.background":"Background","trace.bg":"Bg","trace.refresh":"Refresh trace","trace.timeline":"Timeline","trace.timeline-hint":"W/S zoom · A/D pan · drag pan · wheel zoom · 0 fit · F focus selection · dbl-click focus · Esc deselect","trace.expand-all":"Expand all","trace.collapse-all":"Collapse all","trace.axis-mode":"Axis mode","trace.mode-time-title":"Real wall-clock time","trace.mode-turns-title":"Equal width per user turn","trace.mode-calls-title":"Equal width per model/tool call boundary","trace.turns":"Turns","trace.calls":"Calls","trace.compress-idle":"Compress idle","trace.search-placeholder":"Search spans…","trace.previous-match":"Previous match","trace.next-match":"Next match","trace.transcript":"Transcript","trace.transcript-description":"Every span and marker in order; click to inspect","trace.no-matching-events":"No matching events","trace.canvas-aria":"Trace timeline. W and S zoom, A and D pan, 0 fits all, F focuses the selection.","trace.minimap-aria":"Timeline overview brush","trace.expand-track":"Expand {track}","trace.collapse-track":"Collapse {track}","trace.unterminated":"unterminated","trace.tok":"tok","trace.ttft":"TTFT","trace.wall-time":"Wall time","trace.model-time":"Model time","trace.tool-time":"Tool time","trace.idle":"Idle","trace.tool-calls-n":"{count} tool calls","trace.of-wall":"{percent} of wall","trace.tool-aggregates":"Tool aggregates","trace.tool-aggregates-desc":"{count} tools, by total time","trace.errors":"Errors","trace.failed-n":"{count} failed","trace.avg":"Avg","trace.max":"Max","trace.start":"Start","trace.track":"Track","trace.io-cached":"Input / output / cached","trace.stop-reason":"Stop reason","trace.copy-json":"Copy raw JSON","trace.error-message":"Error message","trace.task":"Task","trace.open-child-track":"Open child track","trace.args":"Args","trace.thinking":"Thinking","trace.text":"Text","trace.raw-entry":"Raw entry","trace.load-failed":"Failed to load entry: {message}"},"zh-CN":{"trace.title":"调用链","trace.description":"最近的会话,已合并子代理活动。打开其中一个即可查看其时间线。","trace.sessions":"会话","trace.session":"会话","trace.most-recent":"最近 {count} 条","trace.most-recent-filtered":"最近 {total} 条中的 {shown} 条","trace.filter-placeholder":"按标题、项目或模型筛选…","trace.empty-title":"未找到会话","trace.empty-hint":"运行一次同步以索引最近的活动。","trace.no-matching-title":"没有匹配的会话","trace.no-matching-hint":"请尝试其他筛选条件。","trace.tool":"工具","trace.tools":"工具","trace.agent":"智能体","trace.agents":"智能体","trace.background":"后台","trace.bg":"背景","trace.refresh":"刷新调用链","trace.timeline":"时间线","trace.timeline-hint":"W/S 缩放 · A/D 平移 · 拖拽平移 · 滚轮缩放 · 0 适应全部 · F 聚焦所选 · 双击聚焦 · Esc 取消选择","trace.expand-all":"全部展开","trace.collapse-all":"全部折叠","trace.axis-mode":"坐标轴模式","trace.mode-time-title":"真实墙钟时间","trace.mode-turns-title":"每个用户轮次等宽","trace.mode-calls-title":"每个模型/工具调用边界等宽","trace.turns":"轮次","trace.calls":"调用次数","trace.compress-idle":"压缩空闲时间","trace.search-placeholder":"搜索跨度…","trace.previous-match":"上一个匹配","trace.next-match":"下一个匹配","trace.transcript":"对话记录","trace.transcript-description":"按顺序列出所有跨度和标记;点击可查看详情","trace.no-matching-events":"没有匹配的事件","trace.canvas-aria":"调用链时间线。W 和 S 缩放,A 和 D 平移,0 适应全部,F 聚焦所选。","trace.minimap-aria":"时间线概览刷选","trace.expand-track":"展开 {track}","trace.collapse-track":"折叠 {track}","trace.unterminated":"未结束","trace.tok":"Token","trace.ttft":"首 Token 延迟","trace.wall-time":"墙钟时间","trace.model-time":"模型耗时","trace.tool-time":"工具耗时","trace.idle":"空闲","trace.tool-calls-n":"{count} 次工具调用","trace.of-wall":"占墙钟时间 {percent}","trace.tool-aggregates":"工具汇总","trace.tool-aggregates-desc":"{count} 个工具,按总耗时排序","trace.errors":"错误","trace.failed-n":"{count} 个失败","trace.avg":"平均","trace.max":"最大","trace.start":"开始","trace.track":"轨道","trace.io-cached":"输入 / 输出 / 缓存读取","trace.stop-reason":"停止原因","trace.copy-json":"复制原始 JSON","trace.error-message":"错误信息","trace.task":"任务","trace.open-child-track":"打开子轨道","trace.args":"参数","trace.thinking":"思考过程","trace.text":"文本","trace.raw-entry":"原始条目","trace.load-failed":"加载条目失败:{message}"}};var xm={en:{"tools.title":"Tools","tools.description":"Which tools zeta called in {window}, how often they failed, and what they cost.","tools.tool-calls":"Tool calls","tools.failed-n":"{count} failed","tools.distinct-tools":"Distinct tools","tools.most-used":"Most used: {tool}","tools.error-rate-title":"Tool results that came back flagged as errors","tools.succeeded-n":"{count} succeeded","tools.attributed-tokens":"Attributed tokens","tools.tokens-output":"{tokens} output","tools.attributed-cost":"Attributed cost","tools.attribution-note":"Tokens and API-equivalent cost of each invoking turn, split evenly across that turn's tool calls","tools.attribution-estimate":"{note}; API-equivalent estimate","tools.unpriced-requests-n":"{count} unpriced requests","tools.api-equivalent":"API-equivalent","tools.result-text":"Result text","tools.result-chars-title":"Characters of tool-result text fed back into context","tools.chars":"{count} chars","tools.call-arguments":"Call arguments","tools.args-chars-title":"Characters of serialized tool-call arguments","tools.avg-result-per-call":"Avg result per call","tools.avg-args-per-call":"Avg arguments per call","tools.calls-over-time":"Calls over time","tools.errors-over-time":"Errors over time","tools.chart-description":"Per {bucket}, top {count} tools stacked","tools.bucket-5m":"5 minutes","tools.bucket-hour":"hour","tools.bucket-day":"day","tools.calls":"Calls","tools.errors":"Errors","tools.no-tool-errors":"No tool errors in this range","tools.by-tool":"By tool","tools.by-tool-description":"{note}. Select a tool to break it down by model.","tools.by-tool-and-model":"By tool and model","tools.by-tool-and-model-description":"Which models call which tools, and how often those calls fail","tools.filter-by-tool":"Filter by tool","tools.all-tools":"All tools","tools.clear-tool-filter":"Clear tool filter","tools.no-tool-calls":"No tool calls in this range","tools.no-calls-to-tool":"No calls to {tool} in this range","tools.tool":"Tool","tools.trend":"Trend","tools.trend-title":"Calls per bucket over the range","tools.share-of-calls":"{percent} of all tool calls","tools.errors-title":"Calls whose result came back flagged as an error","tools.args":"Args","tools.result":"Result","tools.result-per-call":"Result / call","tools.result-per-call-title":"Mean tool-result characters per call","tools.attr-tokens":"Attr. tokens","tools.share-of-tokens":"{percent} of attributed tokens","tools.attr-cost":"Attr. cost","tools.share-of-cost":"{percent} of attributed cost","tools.last-used":"Last used"},"zh-CN":{"tools.title":"工具","tools.description":"zeta 在{window}调用了哪些工具、它们的失败频率如何,以及产生了多少费用。","tools.tool-calls":"工具调用","tools.failed-n":"{count} 个失败","tools.distinct-tools":"不同工具数","tools.most-used":"使用最多:{tool}","tools.error-rate-title":"返回时被标记为错误的工具结果","tools.succeeded-n":"{count} 个成功","tools.attributed-tokens":"归属 Token","tools.tokens-output":"{tokens} 输出","tools.attributed-cost":"归属费用","tools.attribution-note":"每次调用回合的 Token 与 API 等价费用,平均分摊到该回合的各个工具调用","tools.attribution-estimate":"{note};按 API 等价估算","tools.unpriced-requests-n":"{count} 个未定价请求","tools.api-equivalent":"按 API 等价","tools.result-text":"结果文本","tools.result-chars-title":"回填到上下文中的工具结果文本字符数","tools.chars":"{count} 字符","tools.call-arguments":"调用参数","tools.args-chars-title":"序列化后的工具调用参数字符数","tools.avg-result-per-call":"每次调用平均结果","tools.avg-args-per-call":"每次调用平均参数","tools.calls-over-time":"调用次数随时间变化","tools.errors-over-time":"错误数随时间变化","tools.chart-description":"按{bucket}统计,堆叠显示前 {count} 个工具","tools.bucket-5m":"5 分钟","tools.bucket-hour":"小时","tools.bucket-day":"天","tools.calls":"调用次数","tools.errors":"错误数","tools.no-tool-errors":"该时间范围内没有工具错误","tools.by-tool":"按工具","tools.by-tool-description":"{note}。选择某个工具可按模型细分。","tools.by-tool-and-model":"按工具和模型","tools.by-tool-and-model-description":"哪些模型调用了哪些工具,以及这些调用的失败频率","tools.filter-by-tool":"按工具筛选","tools.all-tools":"全部工具","tools.clear-tool-filter":"清除工具筛选","tools.no-tool-calls":"该时间范围内没有工具调用","tools.no-calls-to-tool":"该时间范围内没有对 {tool} 的调用","tools.tool":"工具","tools.trend":"趋势","tools.trend-title":"时间范围内每个分桶的调用次数","tools.share-of-calls":"占全部工具调用的 {percent}","tools.errors-title":"结果返回时被标记为错误的调用","tools.args":"参数","tools.result":"结果","tools.result-per-call":"结果 / 次","tools.result-per-call-title":"每次调用平均工具结果字符数","tools.attr-tokens":"归属 Token","tools.share-of-tokens":"占归属 Token 的 {percent}","tools.attr-cost":"归属费用","tools.share-of-cost":"占归属费用的 {percent}","tools.last-used":"最近使用"}};var Sm={en:{"frustration.estimate-note":"Identical messages share one verdict, and verdicts are cached, so later runs only pay for new messages. Nothing is spent until you proceed.","frustration.column-model-ids":"Model IDs","frustration.column-messages":"Messages","frustration.column-judged":"Judged","frustration.model-versions":"Model versions","frustration.no-model-match":"No model versions match the filters","frustration.small-models-title":"Models with fewer than {count} messages have noisy rates","frustration.hide-regex-title":"Hide models with under {share}% judged messages (rates from regex signals)","frustration.hatch-title":"Under {share}% of these messages are judged; their rates come from regex signals","frustration.regex-badge":"regex","frustration.legend-annoyed-any":"Annoyed, any target","frustration.table-description":"Rates are shares of user messages; rows follow the chart filters.","frustration.running":"Running","frustration.estimating":"Estimating cost…","frustration.failed-n":"{count} failed","frustration.cost-so-far":"cost so far","frustration.elapsed":"elapsed {time}","frustration.in-flight":"{count} in flight","frustration.messages-progress":"{done}/{total} messages","frustration.failed-suffix":", {count} failed","frustration.judge-with":" with {judge}","frustration.in-time":" in {time}","frustration.run-done-line":"Last run judged {progress}{failed}{judge}{elapsed} for {cost}.","frustration.run-cancelled-line":"Last run cancelled after {progress}{failed}; spent {cost}.","frustration.run-failed-line":"Last run failed after {progress}{failed}: {error}. Spent {cost}.","frustration.title":"Frustration","frustration.description":"How often your messages sound annoyed, per model version, in {window}.","frustration.user-messages":"User messages","frustration.user-messages-title":"User messages with prose in range","frustration.judge-coverage":"Judge coverage","frustration.judge-coverage-title":"Messages with a cached judge verdict; the rest use the regex lexicons","frustration.coverage-hint":"{judged} judged · {regex} regex","frustration.coverage-unscored":" · {count} unscored (no lexicon)","frustration.unscored-line":"Messages in a language without a lexicon: {count} — unscored, not calm.","frustration.annoyed":"Annoyed","frustration.annoyed-title":"Messages annoyed at any target","frustration.at-assistant":"At assistant","frustration.at-assistant-title":"Messages annoyed at the assistant","frustration.angry":"Angry","frustration.angry-title":"Messages angry or hostile toward the assistant","frustration.messages-n":"{count} messages","frustration.judge-panel":"Judge classification","frustration.judge-description":"Cached LLM verdicts replace the regex lexicons; unjudged messages fall back to regex signals. Messages in a language no lexicon covers are reported as unscored rather than counted as calm.","frustration.classify":"Classify with judge","frustration.proceed":"Proceed","frustration.starting":"Starting…","frustration.judge-running":"A judge run is in progress","frustration.quote-title":"Quote the cost of judging every unjudged message in range","frustration.estimated-cost":"Estimated cost","frustration.unjudged-messages":"Unjudged unique messages","frustration.prose-chars":"Prose characters","frustration.input-tokens":"Estimated input tokens","frustration.judge-model":"Judge","frustration.all-judged":"Everything in this range is already judged. There is nothing left to classify.","frustration.no-run-yet":"No judge run yet. Classify the unjudged messages to replace regex estimates with verdicts.","frustration.last-run-done":"Last run done","frustration.last-run-cancelled":"Last run cancelled","frustration.last-run-failed":"Last run failed","frustration.not-run-yet":"Not run yet","frustration.regex-only":"Regex only","frustration.cancel-run":"Cancel run","frustration.cancelling":"Cancelling…","frustration.run-judged":"Last run judged {progress}","frustration.run-cancelled-after":"Last run cancelled after {progress}","frustration.run-failed-after":"Last run failed after {progress}","frustration.by-model":"Frustration by model version","frustration.by-model-description":"Share of user messages per model version. Each bar reaches the annoyed rate; the subsets aimed at the assistant stack inside it.","frustration.all-classes":"All","frustration.every-model-class":"Every model class","frustration.model-class":"Model class","frustration.include-small":"Include < {count} messages","frustration.unclassified":"unclassified","frustration.legend-angry":"Angry at assistant","frustration.legend-assistant":"At assistant, not angry","frustration.legend-other":"Annoyed at other targets","frustration.legend-trend":"At assistant trend","frustration.legend-hatched":"Hatched: mostly regex fallback","frustration.legend-hatched-run":"Hatched: mostly regex fallback (run the judge)","frustration.legend-hue":"Hue = model family","frustration.no-messages":"No user messages in this range","frustration.try-longer-range":"Try a longer range.","frustration.mostly-regex":"Mostly regex fallback: run the judge for accurate rates","frustration.row-mostly-regex":" · mostly regex fallback","frustration.stack-relation":"annoyed ⊇ atAssistant ⊇ angry","frustration.unknown-error":"unknown error","frustration.cancelled":"Cancelled","frustration.failed":"Failed","frustration.done":"Done"},"zh-CN":{"frustration.estimate-note":"内容相同的消息共用一份结论,且结论会被缓存,因此后续运行只为新消息付费。在你开始之前不会产生任何费用。","frustration.column-model-ids":"模型 ID","frustration.column-messages":"消息数","frustration.column-judged":"已评判","frustration.model-versions":"模型版本","frustration.no-model-match":"没有符合筛选条件的模型版本","frustration.small-models-title":"消息少于 {count} 条的模型比例噪声较大","frustration.hide-regex-title":"隐藏已评判比例低于 {share}% 的模型(其比例来自正则信号)","frustration.hatch-title":"这些消息中已评判比例低于 {share}%,其比例来自正则信号","frustration.regex-badge":"正则","frustration.legend-annoyed-any":"不耐烦(任意对象)","frustration.table-description":"比例为占用户消息的百分比;行跟随图表筛选。","frustration.running":"运行中","frustration.estimating":"正在估算费用…","frustration.failed-n":"{count} 条失败","frustration.cost-so-far":"当前费用","frustration.elapsed":"已用时 {time}","frustration.in-flight":"并发 {count}","frustration.messages-progress":"{done}/{total} 条消息","frustration.failed-suffix":",{count} 条失败","frustration.judge-with":",评判模型 {judge}","frustration.in-time":",用时 {time}","frustration.run-done-line":"上次运行评判了 {progress}{failed}{judge}{elapsed},花费 {cost}。","frustration.run-cancelled-line":"上次运行在 {progress}{failed} 后取消,花费 {cost}。","frustration.run-failed-line":"上次运行在 {progress}{failed} 后失败:{error}。花费 {cost}。","frustration.title":"情绪压力","frustration.description":"按模型版本统计你的消息有多不耐烦({window})。","frustration.user-messages":"用户消息","frustration.user-messages-title":"该时间范围内的用户消息(含正文)","frustration.judge-coverage":"判据覆盖率","frustration.judge-coverage-title":"已有缓存的评判模型结论的消息;其余使用正则词典","frustration.coverage-hint":"{judged} 条已评判 · {regex} 条正则","frustration.coverage-unscored":" · {count} 条未评分(无词典)","frustration.unscored-line":"缺少对应词典的语言:{count} 条 —— 未评分,不代表平静。","frustration.annoyed":"不耐烦","frustration.annoyed-title":"对任何对象不耐烦的消息","frustration.at-assistant":"针对助手","frustration.at-assistant-title":"对助手不耐烦的消息","frustration.angry":"发怒","frustration.angry-title":"对助手发怒或带有敌意的消息","frustration.messages-n":"{count} 条消息","frustration.judge-panel":"评判模型分类","frustration.judge-description":"缓存的模型结论会取代正则词典;未评判的消息回退到正则信号。缺少词典的语言显示为未评分,而不是判定为平静。","frustration.classify":"用评判模型分类","frustration.proceed":"开始","frustration.starting":"正在开始…","frustration.judge-running":"评判任务正在进行","frustration.quote-title":"估算对该范围内所有未评判消息进行判定的成本","frustration.estimated-cost":"预估费用","frustration.unjudged-messages":"未评判的唯一消息","frustration.prose-chars":"正文字符数","frustration.input-tokens":"预估输入 Token","frustration.judge-model":"评判模型","frustration.all-judged":"该范围内已全部评判,没有需要分类的消息。","frustration.no-run-yet":"尚未运行评判。对未评判的消息分类,即可用结论取代正则估算。","frustration.last-run-done":"上次运行完成","frustration.last-run-cancelled":"上次运行已取消","frustration.last-run-failed":"上次运行失败","frustration.not-run-yet":"尚未运行","frustration.regex-only":"仅正则","frustration.cancel-run":"取消运行","frustration.cancelling":"正在取消…","frustration.run-judged":"上次运行已评判 {progress}","frustration.run-cancelled-after":"上次运行在 {progress} 后取消","frustration.run-failed-after":"上次运行在 {progress} 后失败","frustration.by-model":"按模型版本的情绪压力","frustration.by-model-description":"各模型版本中用户消息的占比。每根柱子到达不耐烦比例,其中针对助手的子集叠在其内部。","frustration.all-classes":"全部","frustration.every-model-class":"所有模型类别","frustration.model-class":"模型类别","frustration.include-small":"包含少于 {count} 条消息","frustration.unclassified":"未分类","frustration.legend-angry":"对助手发怒","frustration.legend-assistant":"针对助手但未发怒","frustration.legend-other":"对其他对象不耐烦","frustration.legend-trend":"针对助手趋势","frustration.legend-hatched":"斜线:多为正则回退","frustration.legend-hatched-run":"斜线:多为正则回退(运行评判)","frustration.legend-hue":"色相 = 模型家族","frustration.no-messages":"该时间范围内没有用户消息","frustration.try-longer-range":"试试更长的时间范围。","frustration.mostly-regex":"多为正则回退:运行评判以获得准确比例","frustration.row-mostly-regex":" · 多为正则回退","frustration.stack-relation":"不耐烦 ⊇ 针对助手 ⊇ 发怒","frustration.unknown-error":"未知错误","frustration.cancelled":"已取消","frustration.failed":"失败","frustration.done":"完成"}};var Lm={en:{"projects.title":"Projects","projects.description":"Usage by session folder in {window}.","projects.folders":"Folders","projects.folder":"Folder","projects.temporary-n":"{count} temporary","projects.failed-n":"{count} failed","projects.api-equivalent-cost":"API-equivalent cost","projects.api-equivalent-cost-hint":"What this usage would cost at public API rates","projects.unpriced-n":"{count} unpriced","projects.conversation-tokens":"Conversation tokens","projects.conversation-tokens-hint":"Uncached input + cache reads + cache writes + output","projects.cache-rate":"Cache rate","projects.cache-rate-hint":"Cache reads ÷ (uncached input + cache reads)","projects.cache-rate-hint-all":"Cache reads ÷ (uncached input + cache reads), across every folder","projects.top-by-cost":"Top by cost","projects.top-by-cost-description":"Share of API-equivalent cost","projects.top-by-requests":"Top by requests","projects.top-by-requests-description":"Share of all requests","projects.folders-n":"{count} folders","projects.folders-of-n":"{count} of {total} folders","projects.hide-temporary":"Hide temporary ({count})","projects.hide-temporary-hint":"Session folders under /tmp or /var/folders","projects.filter-placeholder":"Filter folders…","projects.empty-no-folders":"No project folders in this range","projects.empty-only-temporary":"Only temporary folders in this range","projects.empty-no-match":"No folders match","projects.hint-longer-range":"Try a longer range.","projects.hint-temporary-hidden":"Temporary folders are hidden.","projects.temp":"temp","projects.share-of-requests":"{share} of all requests","projects.share-of-cost":"{share} of all cost","projects.api-equivalent-cost-rates":"API-equivalent cost at public API rates","projects.cache-savings":"Cache savings","projects.cache-savings-hint":"Prompt-input cost saved versus billing the same tokens uncached","projects.errors":"Errors","projects.avg-duration":"Avg duration","projects.last-active":"Last active"},"zh-CN":{"projects.title":"项目","projects.description":"{window}内按会话文件夹统计的用量。","projects.folders":"文件夹","projects.folder":"文件夹","projects.temporary-n":"{count} 个临时","projects.failed-n":"{count} 个失败","projects.api-equivalent-cost":"API 等效费用","projects.api-equivalent-cost-hint":"这些用量按公开 API 费率计算所需的费用","projects.unpriced-n":"{count} 个未计价","projects.conversation-tokens":"对话 Token","projects.conversation-tokens-hint":"未缓存输入 + 缓存读取 + 缓存写入 + 输出","projects.cache-rate":"缓存命中率","projects.cache-rate-hint":"缓存读取 ÷(未缓存输入 + 缓存读取)","projects.cache-rate-hint-all":"缓存读取 ÷(未缓存输入 + 缓存读取),覆盖所有文件夹","projects.top-by-cost":"费用最高","projects.top-by-cost-description":"占 API 等效费用的比例","projects.top-by-requests":"请求最多","projects.top-by-requests-description":"占全部请求的比例","projects.folders-n":"{count} 个文件夹","projects.folders-of-n":"{total} 个文件夹中的 {count} 个","projects.hide-temporary":"隐藏临时文件夹({count})","projects.hide-temporary-hint":"/tmp 或 /var/folders 下的会话文件夹","projects.filter-placeholder":"筛选文件夹…","projects.empty-no-folders":"该时间范围内没有项目文件夹","projects.empty-only-temporary":"该时间范围内只有临时文件夹","projects.empty-no-match":"没有匹配的文件夹","projects.hint-longer-range":"试试更长的时间范围。","projects.hint-temporary-hidden":"临时文件夹已隐藏。","projects.temp":"临时","projects.share-of-requests":"占全部请求的 {share}","projects.share-of-cost":"占全部费用的 {share}","projects.api-equivalent-cost-rates":"按公开 API 费率计算的等效费用","projects.cache-savings":"缓存节省","projects.cache-savings-hint":"同样的 Token 按未缓存计费时,提示输入费用节省的比例","projects.errors":"错误","projects.avg-duration":"平均耗时","projects.last-active":"最近活动"}};var Cm={en:{"gain.title":"Gain","gain.description":"Tokens snapcompact kept out of context in {window}.","gain.description-scoped":"Tokens snapcompact kept out of context for {project} in {window}.","gain.all-projects":"All projects","gain.empty-title":"No savings recorded in {window}","gain.empty-title-scoped":"No savings recorded for {project} in {window}","gain.empty-hint-all":"Savings appear here once snapcompact compacts tool output.","gain.empty-hint-longer-range":"Try a longer range.","gain.saved-tokens":"Saved tokens","gain.saved-bytes":"Saved bytes","gain.reduction":"Reduction","gain.reduction-title":"Saved bytes ÷ original bytes, when the original size is known","gain.reduction-unknown":"original size not recorded","gain.hits":"Hits","gain.saved-per-hit":"Saved per hit","gain.savings-over-time":"Savings over time","gain.savings-over-time-description":"Tokens saved per UTC day, with the running total","gain.saved-per-day":"Saved per day","gain.cumulative":"Cumulative","gain.by-source":"By source","gain.by-source-description":"Savings per subsystem","gain.source":"Source"},"zh-CN":{"gain.title":"收益","gain.description":"在{window}内被 snapcompact 挡在上下文之外的 Token。","gain.description-scoped":"在{window}内被 snapcompact 为 {project} 挡在上下文之外的 Token。","gain.all-projects":"全部项目","gain.empty-title":"在{window}内没有节省记录","gain.empty-title-scoped":"在{window}内没有 {project} 的节省记录","gain.empty-hint-all":"snapcompact 压缩工具输出后,节省量会显示在这里。","gain.empty-hint-longer-range":"请尝试更长的时间范围。","gain.saved-tokens":"节省的 Token","gain.saved-bytes":"节省的字节","gain.reduction":"节省比例","gain.reduction-title":"原始大小已知时,节省字节 ÷ 原始字节","gain.reduction-unknown":"未记录原始大小","gain.hits":"命中次数","gain.saved-per-hit":"每次命中节省","gain.savings-over-time":"节省趋势","gain.savings-over-time-description":"每个 UTC 日节省的 Token,以及累计总量","gain.saved-per-day":"每日节省","gain.cumulative":"累计","gain.by-source":"按来源","gain.by-source-description":"各子系统节省量","gain.source":"来源"}};var wm={en:{"ui.table-shown-of":"{shown} of {total}","ui.show-fewer":"Show fewer","ui.retry":"Retry","ui.delta-new":"new","ui.json":"JSON","ui.trace":"Trace","ui.open-trace":"Open this request's session in the trace view","ui.status-ok":"OK","ui.section-timing":"Timing","ui.time-to-first-token":"Time to first token","ui.uncached-input":"Uncached input","ui.section-cost":"API-equivalent cost","ui.section-identity":"Identity","ui.stop-reason":"Stop reason","ui.api":"API","ui.session-file":"Session file","ui.stats-row":"Stats row"},"zh-CN":{"ui.table-shown-of":"已显示 {shown} / 共 {total}","ui.show-fewer":"收起","ui.retry":"重试","ui.delta-new":"新增","ui.json":"JSON 数据","ui.trace":"调用链","ui.open-trace":"在调用链视图中打开该请求的会话","ui.status-ok":"正常","ui.section-timing":"时间","ui.time-to-first-token":"首 Token 延迟","ui.uncached-input":"未缓存输入","ui.section-cost":"API 等价费用","ui.section-identity":"标识","ui.stop-reason":"停止原因","ui.api":"接口","ui.session-file":"会话文件","ui.stats-row":"统计行"}};var km={en:{},"zh-CN":{}};var V2={...dm.en,...fm.en,...pm.en,...mm.en,...hm.en,...gm.en,...ym.en,...vm.en,...bm.en,...xm.en,...Sm.en,...Lm.en,...Cm.en,...wm.en,...km.en},Xk={id:"en",messages:V2};var j2={...dm["zh-CN"],...fm["zh-CN"],...pm["zh-CN"],...mm["zh-CN"],...hm["zh-CN"],...gm["zh-CN"],...ym["zh-CN"],...vm["zh-CN"],...bm["zh-CN"],...xm["zh-CN"],...Sm["zh-CN"],...Lm["zh-CN"],...Cm["zh-CN"],...wm["zh-CN"],...km["zh-CN"]},Yk={id:"zh-CN",messages:j2};function X2(){return globalThis.__ZETA_STATS_LOCALE__}var Y2={en:Xk.messages,"zh-CN":Yk.messages},Tm="en";$2();function Xs(){return Tm}function $k(l){return Tm=Nv(l),Tm}function $2(){let l=X2();if(l)return $k(l);if(typeof navigator>"u")return"en";return $k(Vk(navigator.languages))}function u(l,i){return jk(Tm,l,Y2,i)}var Kk=60000,Im=60*Kk,sr=24*Im,Bv={"1h":{labelKey:"common.range-1h",windowKey:"common.window-1h",spanMs:Im,bucketMs:5*Kk},"24h":{labelKey:"common.range-24h",windowKey:"common.window-24h",spanMs:sr,bucketMs:Im},"7d":{labelKey:"common.range-7d",windowKey:"common.window-7d",spanMs:7*sr,bucketMs:sr},"30d":{labelKey:"common.range-30d",windowKey:"common.window-30d",spanMs:30*sr,bucketMs:sr},"90d":{labelKey:"common.range-90d",windowKey:"common.window-90d",spanMs:90*sr,bucketMs:sr},all:{labelKey:"common.range-all",windowKey:"common.window-all",spanMs:null,bucketMs:sr}},Q2=1500,ci=["1h","24h","7d","30d","90d","all"];function ia(l){return Bv[l]}var zv={hour:"2-digit",minute:"2-digit",hourCycle:"h23"},Uv={month:"short",day:"numeric"},Qk=new Map;function Rd(l,i){let c=Xs(),f=`${c}:${l}`,p=Qk.get(f);if(!p)p=new Intl.DateTimeFormat(c,i),Qk.set(f,p);return p}function Rm(l,i){if(i<Im)return Rd("hm",zv).format(l);if(i<sr)return Rd("mdhm",{...Uv,...zv}).format(l);return Rd("md",Uv).format(l)}function Am(l,i){return i<sr?Rd("hm",zv).format(l):Rd("md",Uv).format(l)}function _o(l,i,c=Bv[l].bucketMs,f=Date.now()){let p=Math.floor(f/c)*c,S=Bv[l].spanMs,h;if(S!==null)h=Math.floor((f-S)/c)*c;else{h=p;for(let b of i)if(b<h)h=b;h=Math.floor(h/c)*c}h=Math.max(h,p-(Q2-1)*c);let x=[];for(let b=h;b<=p;b+=c)x.push(b);return x}var Ad=Z(gt(),1);class Wk extends Error{status;endpoint;constructor(l,i,c){super(c);this.name="ApiError",this.status=l,this.endpoint=i}}async function K2(l,i){try{let c=await l.json();if(typeof c==="object"&&c!==null&&"error"in c&&typeof c.error==="string")return c.error}catch{}return`HTTP error ${l.status} on ${i}`}var Zk=new WeakMap;async function Oa(l,i,c){let f=typeof c==="object"&&c!==null?Zk.get(c):void 0,p=i;if(f){let b=new Headers(i?.headers);b.set("If-None-Match",f),p={...i,headers:b}}let S=await fetch(l,p);if(S.status===304&&f)return c;if(!S.ok)throw new Wk(S.status,l,await K2(S,l));let h=await S.json(),x=S.headers.get("ETag");if(x&&typeof h==="object"&&h!==null)Zk.set(h,x);return h}var Jk={"X-Zeta-Stats-Action":"1"};async function e1(l="24h",i){return Oa(`/api/stats/overview?range=${encodeURIComponent(l)}`,{signal:i})}async function t1(l="24h",i){return Oa(`/api/stats/model-dashboard?range=${encodeURIComponent(l)}`,{signal:i})}async function a1(l="24h",i){return Oa(`/api/stats/costs?range=${encodeURIComponent(l)}`,{signal:i})}async function Mm(l=50,i){return Oa(`/api/stats/recent?limit=${l}`,{signal:i})}async function o1(l="24h",i=50,c){return Oa(`/api/stats/errors?range=${encodeURIComponent(l)}&limit=${i}`,{signal:c})}async function n1(l,i){return Oa(`/api/request/${l}`,{signal:i})}async function r1(){return Oa("/api/sync",{method:"POST"})}async function l1(l="24h",i){return Oa(`/api/stats/frustration?range=${encodeURIComponent(l)}`,{signal:i})}async function s1(l,i){return Oa(`/api/frustration/estimate?range=${encodeURIComponent(l)}`,{signal:i})}async function u1(l){return Oa(`/api/frustration/judge?range=${encodeURIComponent(l)}`,{method:"POST",headers:Jk})}async function i1(){return Oa("/api/frustration/cancel",{method:"POST",headers:Jk})}async function c1(l="24h",i){return Oa(`/api/stats/folders?range=${encodeURIComponent(l)}`,{signal:i})}async function d1(l="24h",i,c){let f=new URLSearchParams({range:l});if(i)f.set("project",i);return Oa(`/api/stats/gain?${f}`,{signal:c})}async function f1(l="24h",i){return Oa(`/api/stats/tools?range=${encodeURIComponent(l)}`,{signal:i})}async function p1(l="24h",i){return Oa(`/api/stats/providers?range=${encodeURIComponent(l)}`,{signal:i})}async function Pv(l,i,c){let f=new URLSearchParams({range:l});if(i!==null)f.set("provider",i);return Oa(`/api/stats/provider-windows?${f}`,{signal:c})}async function m1(l=100,i,c){let f=new URLSearchParams({limit:String(l)});if(i)f.set("q",i);return Oa(`/api/sessions?${f}`,{signal:c})}async function h1(l,i,c){return Oa(`/api/session/trace?file=${encodeURIComponent(l)}`,{signal:i,cache:"no-store"},c)}async function g1(l,i,c){return Oa(`/api/session/entry?file=${encodeURIComponent(l)}&id=${encodeURIComponent(i)}`,{signal:c})}var W2={phase:"idle",current:0,total:0,processed:0,lastSyncedAt:null,error:null};function J2(){r1().catch(()=>{})}var y1=null,v1=0,Dm=0,Xl={sync:W2,indexingHours:0,connected:!1,requestSync:J2},Hv=new Set;function b1(l){return Hv.add(l),()=>Hv.delete(l)}function x1(){for(let l of Hv)l()}function eM(l,i){return l.phase===i.phase&&l.current===i.current&&l.total===i.total&&l.processed===i.processed&&l.lastSyncedAt===i.lastSyncedAt&&l.error===i.error}function tM(l){if(y1!==l.version)y1=l.version,v1++;let i=Math.max(0,v1-1),c=l.indexingHours!==Xl.indexingHours||!eM(l.sync,Xl.sync);if(!c&&i===Dm)return;if(Dm=i,c)Xl={...Xl,sync:l.sync,indexingHours:l.indexingHours};x1()}function _v(l){if(l===Xl.connected)return;Xl={...Xl,connected:l},x1()}var aM=()=>Xl,oM=()=>Dm,nM=()=>-1;function S1(){return Dm}function L1({children:l}){return Ad.useEffect(()=>{let i=new EventSource("/api/events");return i.onopen=()=>_v(!0),i.onerror=()=>_v(!1),i.onmessage=(c)=>tM(JSON.parse(c.data)),()=>{i.close(),_v(!1)}},[]),l}function Em(){return Ad.useSyncExternalStore(b1,aM)}function C1(l=!0){return Ad.useSyncExternalStore(b1,l?oM:nM)}var Om=Z(ue(),1);function Bt({tone:l="neutral",mono:i,children:c}){return Om.jsxDEV("span",{className:"badge","data-tone":l,"data-mono":i??!1,children:c},void 0,!1,void 0,this)}function ur({tone:l="neutral",pulse:i}){return Om.jsxDEV("span",{className:"dot","data-tone":l,"data-pulse":i??!1},void 0,!1,void 0,this)}function Cn({color:l}){return Om.jsxDEV("span",{className:"swatch",style:{background:l}},void 0,!1,void 0,this)}function ir(l){if(l>=0.05)return"bad";if(l>=0.01)return"warn";return"ok"}var So=Z(ue(),1);function Ye({title:l,description:i,actions:c,flush:f,footer:p,className:S,index:h,stale:x,children:b}){let L=l!==void 0||i!==void 0||c!==void 0;return So.jsxDEV("section",{className:S?`card rise ${S}`:"card rise",style:h!==void 0?{"--i":h}:void 0,children:[L&&So.jsxDEV("header",{className:"card-header",children:[So.jsxDEV("div",{className:"card-titles",children:[l!==void 0&&So.jsxDEV("h2",{className:"card-title",children:l},void 0,!1,void 0,this),i!==void 0&&So.jsxDEV("p",{className:"card-description",children:i},void 0,!1,void 0,this)]},void 0,!0,void 0,this),c!==void 0&&So.jsxDEV("div",{className:"card-actions",children:c},void 0,!1,void 0,this)]},void 0,!0,void 0,this),So.jsxDEV("div",{className:"card-body","data-flush":f??!1,"data-stale":x??!1,children:b},void 0,!1,void 0,this),p!==void 0&&So.jsxDEV("footer",{className:"card-footer",children:p},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function ra({title:l,description:i,actions:c}){return So.jsxDEV("header",{className:"page-header rise",children:[So.jsxDEV("div",{children:[So.jsxDEV("h1",{className:"page-title",children:l},void 0,!1,void 0,this),i!==void 0&&So.jsxDEV("p",{className:"page-description",children:i},void 0,!1,void 0,this)]},void 0,!0,void 0,this),c!==void 0&&So.jsxDEV("div",{className:"page-actions",children:c},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var Md=Z(gt(),1),w1=Z(rd(),1),Qa=Z(ue(),1);function qm({open:l,onClose:i,title:c,subtitle:f,actions:p,width:S,children:h}){let x=Md.useRef(i);x.current=i;let b=Md.useRef(null);if(Md.useEffect(()=>{if(!l)return;let L=document.activeElement instanceof HTMLElement?document.activeElement:null;b.current?.focus();let g=(C)=>{if(C.key==="Escape")C.preventDefault(),x.current()};return window.addEventListener("keydown",g),()=>{window.removeEventListener("keydown",g),L?.focus()}},[l]),!l)return null;return w1.createPortal(Qa.jsxDEV(Qa.Fragment,{children:[Qa.jsxDEV("div",{className:"drawer-scrim",onClick:i,role:"presentation"},void 0,!1,void 0,this),Qa.jsxDEV("div",{ref:b,className:"drawer",role:"dialog","aria-modal":"true",tabIndex:-1,style:S!==void 0?{"--drawer-w":`${S}px`}:void 0,children:[Qa.jsxDEV("header",{className:"drawer-header",children:[Qa.jsxDEV("div",{className:"drawer-titles",children:[Qa.jsxDEV("h2",{className:"drawer-title",children:c},void 0,!1,void 0,this),f!==void 0&&Qa.jsxDEV("div",{className:"drawer-subtitle",children:f},void 0,!1,void 0,this)]},void 0,!0,void 0,this),p,Qa.jsxDEV("button",{type:"button",className:"btn","data-variant":"ghost","data-icon":"true",onClick:i,"aria-label":"Close",children:Qa.jsxDEV(nn,{size:16},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Qa.jsxDEV("div",{className:"drawer-body",children:h},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),document.body)}function Ho({items:l}){return Qa.jsxDEV("dl",{className:"kv",style:{margin:0},children:l.map((i)=>Qa.jsxDEV("div",{className:"kv-item",children:[Qa.jsxDEV("dt",{className:"kv-key",children:i.label},void 0,!1,void 0,this),Qa.jsxDEV("dd",{className:"kv-value",style:{margin:0},children:i.value},void 0,!1,void 0,this)]},i.key,!0,void 0,this))},void 0,!1,void 0,this)}var $s=Z(gt(),1);var wn=Z(ue(),1);function di({data:l,title:i=u("ui.json"),initialCollapsed:c=!1}){let[f,p]=$s.useState(c),[S,h]=$s.useState(!1),x=$s.useRef(0),b=JSON.stringify(l,null,2);return $s.useEffect(()=>()=>window.clearTimeout(x.current),[]),wn.jsxDEV("div",{className:"stack",style:{gap:6},children:[wn.jsxDEV("div",{className:"row",style:{justifyContent:"space-between"},children:[wn.jsxDEV("button",{type:"button",className:"btn","data-variant":"ghost","data-size":"sm",onClick:()=>p((g)=>!g),"aria-expanded":!f,children:[f?wn.jsxDEV(Ln,{size:13},void 0,!1,void 0,this):wn.jsxDEV(Vs,{size:13},void 0,!1,void 0,this),i]},void 0,!0,void 0,this),wn.jsxDEV("button",{type:"button",className:"btn","data-variant":"ghost","data-size":"sm",onClick:async()=>{try{await navigator.clipboard.writeText(b),h(!0),window.clearTimeout(x.current),x.current=window.setTimeout(()=>h(!1),1500)}catch{}},children:[S?wn.jsxDEV(Gs,{size:13},void 0,!1,void 0,this):wn.jsxDEV(js,{size:13},void 0,!1,void 0,this),S?u("common.copied"):u("common.copy")]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),!f&&wn.jsxDEV("pre",{className:"code-block",children:wn.jsxDEV("code",{children:b},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var Qs=Z(gt(),1),k1=Z(rd(),1);var kn=Z(ue(),1);function T1({open:l,title:i,onClose:c,primaryAction:f,cancelLabel:p=u("common.cancel"),children:S}){let h=Qs.useRef(null),x=Qs.useRef(null),b=Qs.useRef(c);b.current=c,Qs.useEffect(()=>{if(!l)return;let w=document.activeElement instanceof HTMLElement?document.activeElement:null,A=(k)=>{if(k.key==="Escape")k.preventDefault(),b.current()};return window.addEventListener("keydown",A),()=>{window.removeEventListener("keydown",A),w?.focus()}},[l]);let L=f!==void 0,g=f?.disabled??!1;if(Qs.useEffect(()=>{if(!l)return;(L&&!g?h.current:x.current)?.focus()},[l,L,g]),!l)return null;return k1.createPortal(kn.jsxDEV("div",{className:"modal-overlay",onClick:(w)=>{if(w.target===w.currentTarget)c()},role:"presentation",children:kn.jsxDEV("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"modal-title",children:[kn.jsxDEV("div",{className:"modal-header",children:[kn.jsxDEV("h2",{id:"modal-title",className:"modal-title",children:i},void 0,!1,void 0,this),kn.jsxDEV("button",{type:"button",className:"btn","data-variant":"ghost","data-icon":"true","data-size":"sm",onClick:c,"aria-label":u("common.close"),children:kn.jsxDEV(nn,{size:15},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),kn.jsxDEV("div",{className:"modal-body",children:S},void 0,!1,void 0,this),kn.jsxDEV("div",{className:"modal-footer",children:[kn.jsxDEV("button",{ref:x,type:"button",className:"btn",onClick:c,children:p},void 0,!1,void 0,this),f&&kn.jsxDEV("button",{ref:h,type:"button",className:"btn","data-variant":"primary",onClick:f.onClick,disabled:f.disabled,children:f.label},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),document.body)}var Nm=Z(ue(),1);function cr({value:l,onChange:i,placeholder:c=u("common.filter"),width:f}){return Nm.jsxDEV("label",{className:"search",children:[Nm.jsxDEV(kd,{size:14},void 0,!1,void 0,this),Nm.jsxDEV("input",{className:"input",type:"search",value:l,placeholder:c,onChange:(p)=>i(p.target.value),style:f!==void 0?{width:f}:void 0},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var fi=Z(gt(),1),Bm=Z(ue(),1);function _a({options:l,value:i,onChange:c,size:f="md","aria-label":p}){let S=fi.useRef(null),[h,x]=fi.useState(null);return fi.useLayoutEffect(()=>{let b=S.current,L=b?.querySelector('[data-active="true"]');if(!b||!L){x(null);return}let g=()=>x({left:L.offsetLeft,width:L.offsetWidth});g();let C=new ResizeObserver(g);return C.observe(b),()=>C.disconnect()},[i,l]),Bm.jsxDEV("div",{ref:S,className:"segmented","data-size":f,role:"radiogroup","aria-label":p,children:[h&&Bm.jsxDEV("span",{className:"segmented-thumb",style:{left:h.left,width:h.width}},void 0,!1,void 0,this),l.map((b)=>Bm.jsxDEV("button",{type:"button",role:"radio","aria-checked":b.value===i,className:"segmented-option","data-active":b.value===i,title:b.title,onClick:()=>c(b.value),children:b.label},b.value,!1,void 0,this))]},void 0,!0,void 0,this)}var hi=Z(gt(),1);var pi=Z(gt(),1);function zm(){let l=pi.useRef(null),[i,c]=pi.useState(0);return pi.useLayoutEffect(()=>{let f=l.current;if(!f)return;c(f.clientWidth);let p=new ResizeObserver((S)=>{let h=Math.round(S[0]?.contentRect.width??0);c((x)=>x===h?x:h)});return p.observe(f),()=>p.disconnect()},[]),[l,i]}var Dd=Z(ue(),1);function mi({values:l,color:i="var(--chart-primary)",height:c=28,width:f,area:p=!0}){let[S,h]=zm(),x=f??h,b=Math.max(0,...l),L=l.length,g="";if(x>0&&L>0){let C=L>1?x/(L-1):0;for(let w=0;w<L;w++){let A=L>1?w*C:x/2,k=b>0?c-2-l[w]/b*(c-4):c-2;g+=`${w===0?"M":"L"}${A.toFixed(1)},${k.toFixed(1)}`}}return Dd.jsxDEV("div",{ref:S,className:"sparkline",style:{width:f??"100%",height:c},children:x>0&&L>0&&Dd.jsxDEV("svg",{width:x,height:c,"aria-hidden":"true",children:[p&&Dd.jsxDEV("path",{className:"area",d:`${g}L${x},${c}L0,${c}Z`,fill:i},void 0,!1,void 0,this),Dd.jsxDEV("path",{className:"chart-line",d:g,stroke:i},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}var rn=Z(ue(),1);function ie({label:l,value:i,hint:c,delta:f,spark:p,sparkColor:S,size:h="md",title:x}){let b=sM(typeof i==="string"||typeof i==="number"?i:null);return rn.jsxDEV("div",{className:"stat","data-size":h,title:x,children:[rn.jsxDEV("div",{className:"stat-label",children:l},void 0,!1,void 0,this),rn.jsxDEV("div",{className:"stat-value","data-flash":b,children:i},void 0,!1,void 0,this),(c!==void 0||f)&&rn.jsxDEV("div",{className:"stat-foot",children:[f&&rn.jsxDEV(lM,{...f},void 0,!1,void 0,this),c!==void 0&&rn.jsxDEV("span",{className:"truncate",children:c},void 0,!1,void 0,this)]},void 0,!0,void 0,this),p&&p.length>1&&rn.jsxDEV("div",{className:"stat-spark",children:rn.jsxDEV(mi,{values:p,color:S},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function la({min:l,children:i}){return rn.jsxDEV("div",{className:"stat-grid rise",style:l!==void 0?{"--stat-min":`${l}px`}:void 0,children:i},void 0,!1,void 0,this)}function lM({change:l,good:i="up"}){if(l===null||!Number.isFinite(l))return rn.jsxDEV("span",{className:"delta",children:"new"},void 0,!1,void 0,this);let c=Math.abs(l)<0.0005?0:l,f=c===0?void 0:c>0===(i==="up")?"good":"bad",p=c>0?"+":c<0?"−":"±",S=Math.abs(c)*100;return rn.jsxDEV("span",{className:"delta","data-tone":f,children:[p,S>=100?S.toFixed(0):S.toFixed(1),"%"]},void 0,!0,void 0,this)}function sM(l){let i=hi.useRef(l),[c,f]=hi.useState(!1);return hi.useEffect(()=>{if(i.current===l)return;let p=i.current!==null;if(i.current=l,!p)return;f(!0);let S=setTimeout(()=>f(!1),900);return()=>clearTimeout(S)},[l]),c}var ga=Z(ue(),1);function wt({title:l=u("common.nothing-here-yet"),hint:i}){return ga.jsxDEV("div",{className:"empty",children:[ga.jsxDEV(bd,{size:20},void 0,!1,void 0,this),ga.jsxDEV("div",{className:"empty-title",children:l},void 0,!1,void 0,this),i!==void 0&&ga.jsxDEV("div",{className:"empty-hint",children:i},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function gi({error:l,onRetry:i}){return ga.jsxDEV("div",{className:"error-state",role:"alert",children:[ga.jsxDEV(Vl,{size:15},void 0,!1,void 0,this),ga.jsxDEV("span",{className:"error-state-message",children:typeof l==="string"?l:l.message},void 0,!1,void 0,this),i&&ga.jsxDEV("button",{type:"button",className:"btn","data-size":"sm","data-variant":"ghost",onClick:i,children:[ga.jsxDEV(wd,{size:13},void 0,!1,void 0,this)," ",u("ui.retry")]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function qa({width:l="100%",height:i=14,style:c}){return ga.jsxDEV("div",{className:"skeleton",style:{width:l,height:i,...c}},void 0,!1,void 0,this)}function zt({height:l=220}){return ga.jsxDEV(qa,{height:l,style:{borderRadius:8}},void 0,!1,void 0,this)}function ca({rows:l=6}){return ga.jsxDEV("div",{style:{display:"flex",flexDirection:"column",gap:10,padding:"8px 16px 16px"},children:Array.from({length:l},(i,c)=>ga.jsxDEV(qa,{height:16,width:`${92-c*13%30}%`},c,!1,void 0,this))},void 0,!1,void 0,this)}function Ge({query:l,skeleton:i,isEmpty:c,empty:f,children:p}){if(l.data===null){if(l.error)return ga.jsxDEV(gi,{error:l.error,onRetry:l.refetch},void 0,!1,void 0,this);return ga.jsxDEV(ga.Fragment,{children:i},void 0,!1,void 0,this)}return ga.jsxDEV(ga.Fragment,{children:[l.error&&ga.jsxDEV(gi,{error:l.error,onRetry:l.refetch},void 0,!1,void 0,this),c?.(l.data)?f??ga.jsxDEV(wt,{},void 0,!1,void 0,this):p(l.data)]},void 0,!0,void 0,this)}var Zs=Z(gt(),1);function Gv(){return Xs()}function z(l){return l.toLocaleString(Gv())}function Ae(l){return l.toLocaleString(Gv(),{notation:"compact"})}function da(l,i){if(l===0)return"$0";let c=i!==void 0?i:l>0&&l<0.01?4:2;return`$${l.toLocaleString(Gv(),{minimumFractionDigits:c,maximumFractionDigits:c})}`}function Ht(l,i,c){return l===0&&i>0?"N/A":da(l,c)}function Vv(l){return l.usage.totalTokens>0&&l.usage.cost.total===0&&(l.provider==="xai-oauth"||l.costUnpriced===!0)}function Yl(l,i){return Ht(l.usage.cost.total,Vv(l)?1:0,i)}function Fe(l,i=1){return`${(l*100).toFixed(i)}%`}function to(l){let i=l*100;if(i>0&&i<0.005)return"<0.01%";return Fe(l,i>0&&i<0.1?2:1)}function At(l,i){if(l===null)return"-";let c=l/1000,f=i!==void 0?i:c<1?2:1;return`${c.toFixed(f)}s`}function Ks(l){if(l<60000)return At(l);let i=Math.floor(l/60000);if(i<60)return`${i}m ${String(Math.floor(l%60000/1000)).padStart(2,"0")}s`;return`${Math.floor(i/60)}h ${String(i%60).padStart(2,"0")}m`}function dr(l){if(l===null)return"-";return l.toFixed(1)}var Fv=[["second",1000],["minute",60000],["hour",3600000],["day",86400000],["month",2629800000],["year",31557600000]],I1=new Map,Um=new Map;function fa(l,i=Date.now()){let c=Xs(),f=I1.get(c);if(!f)f=new Intl.RelativeTimeFormat(c,{numeric:"auto"}),I1.set(c,f);let p=l-i,S=0;for(let b=1;b<Fv.length;b++)if(Math.abs(p)>=Fv[b][1])S=b;let[h,x]=Fv[S];return f.format(Math.round(p/x),h)}function jv(l){let i=Xs(),c=`${i}:mdhm`,f=Um.get(c);if(!f)f=new Intl.DateTimeFormat(i,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}),Um.set(c,f);return f.format(l)}function ln(l){let i=Xs(),c=Um.get(i);if(!c)c=new Intl.DateTimeFormat(i,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",hourCycle:"h23"}),Um.set(i,c);return c.format(l)}function fr(l){return l.replace(/^\/+|\/+$/g,"")||u("common.root")}function Xv(l){if(l>=1e9)return`${(l/1e9).toFixed(1)} GB`;if(l>=1e6)return`${(l/1e6).toFixed(1)} MB`;if(l>=1000)return`${(l/1000).toFixed(1)} KB`;return`${l} B`}var Mt=Z(ue(),1);function Xt({columns:l,rows:i,rowKey:c,onRowClick:f,selectedKey:p,initialSort:S,limit:h,dense:x,empty:b,expanded:L}){let[g,C]=Zs.useState(S??null),[w,A]=Zs.useState(h??Number.POSITIVE_INFINITY),k=Zs.useMemo(()=>{let B=g?l.find((Y)=>Y.key===g.key):void 0;if(!g||!B?.sort)return i;let P=B.sort,j=g.dir==="asc"?1:-1;return[...i].sort((Y,ce)=>{let J=P(Y),te=P(ce);if(typeof J==="number"&&typeof te==="number")return(J-te)*j;return String(J).localeCompare(String(te))*j})},[i,l,g]);if(i.length===0)return Mt.jsxDEV(Mt.Fragment,{children:b??Mt.jsxDEV(wt,{},void 0,!1,void 0,this)},void 0,!1,void 0,this);let D=k.length>w?k.slice(0,w):k,M=(B)=>{if(!B.sort)return;C((P)=>P?.key===B.key?{key:B.key,dir:P.dir==="asc"?"desc":"asc"}:{key:B.key,dir:B.align==="right"?"desc":"asc"})};return Mt.jsxDEV(Mt.Fragment,{children:[Mt.jsxDEV("div",{className:"table-wrap",children:Mt.jsxDEV("table",{className:"table","data-dense":x??!1,children:[Mt.jsxDEV("thead",{children:Mt.jsxDEV("tr",{children:l.map((B)=>{let P=g?.key===B.key?g.dir:void 0;return Mt.jsxDEV("th",{"data-align":B.align??"left","data-sortable":B.sort!==void 0,"data-sorted":P,style:B.width!==void 0?{width:B.width}:void 0,title:B.title,onClick:()=>M(B),"aria-sort":P==="asc"?"ascending":P==="desc"?"descending":void 0,children:[B.header,P&&Mt.jsxDEV("span",{className:"sort-arrow",children:P==="asc"?Mt.jsxDEV(pd,{size:11},void 0,!1,void 0,this):Mt.jsxDEV(id,{size:11},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},B.key,!0,void 0,this)})},void 0,!1,void 0,this)},void 0,!1,void 0,this),Mt.jsxDEV("tbody",{children:D.map((B)=>{let P=c(B),j=L?.(B)??null;return Mt.jsxDEV(Zs.Fragment,{children:[Mt.jsxDEV("tr",{"data-clickable":f!==void 0,"data-selected":p===P,onClick:f?()=>f(B):void 0,onKeyDown:f?(Y)=>{if(Y.key==="Enter"||Y.key===" ")Y.preventDefault(),f(B)}:void 0,tabIndex:f?0:void 0,children:l.map((Y)=>Mt.jsxDEV("td",{"data-align":Y.align??"left","data-wrap":Y.wrap??!1,children:Y.render(B)},Y.key,!1,void 0,this))},void 0,!1,void 0,this),j!==null&&Mt.jsxDEV("tr",{children:Mt.jsxDEV("td",{colSpan:l.length,"data-wrap":"true",style:{padding:0},children:j},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},P,!0,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),h!==void 0&&k.length>h&&Mt.jsxDEV("div",{className:"table-more",children:[Mt.jsxDEV("span",{className:"micro",children:u("ui.table-shown-of",{shown:z(D.length),total:z(k.length)})},void 0,!1,void 0,this),k.length>w&&Mt.jsxDEV("button",{type:"button",className:"btn","data-size":"sm","data-variant":"ghost",onClick:()=>A((B)=>B+h*4),children:u("common.show-more")},void 0,!1,void 0,this),w>h&&Mt.jsxDEV("button",{type:"button",className:"btn","data-size":"sm","data-variant":"ghost",onClick:()=>A(h),children:u("ui.show-fewer")},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function pa({value:l,max:i,display:c,color:f}){let p=i>0?Math.min(100,l/i*100):0;return Mt.jsxDEV("div",{className:"meter-cell",children:[Mt.jsxDEV("span",{className:"num",children:c},void 0,!1,void 0,this),Mt.jsxDEV("div",{className:"meter",children:Mt.jsxDEV("div",{className:"meter-fill",style:{width:`${p}%`,background:f}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Ha({primary:l,secondary:i,lead:c}){return Mt.jsxDEV("div",{className:"row",style:{gap:10},children:[c,Mt.jsxDEV("div",{className:"stack",style:{gap:0},children:[Mt.jsxDEV("span",{className:"cell-primary truncate",children:l},void 0,!1,void 0,this),i!==void 0&&Mt.jsxDEV("span",{className:"cell-secondary truncate",children:i},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var Pm=Z(gt(),1);var Jt=Z(ue(),1);function R1(){let{sync:l,indexingHours:i,connected:c,requestSync:f}=Em(),p=iM(l.phase==="idle"?15000:null),S,h;if(!c)S=Jt.jsxDEV(Jt.Fragment,{children:[Jt.jsxDEV(ur,{tone:"warn"},void 0,!1,void 0,this),Jt.jsxDEV("span",{children:u("shell.reconnecting")},void 0,!1,void 0,this)]},void 0,!0,void 0,this),h=u("shell.lost-connection");else if(l.phase==="syncing")S=Jt.jsxDEV(Jt.Fragment,{children:[Jt.jsxDEV(jl,{size:13,className:"spin"},void 0,!1,void 0,this),Jt.jsxDEV("span",{children:u("shell.syncing")},void 0,!1,void 0,this),l.total>0&&Jt.jsxDEV("span",{className:"live-chip-count",children:[z(l.current),"/",z(l.total)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),h=u("shell.ingesting");else if(l.phase==="error")S=Jt.jsxDEV(Jt.Fragment,{children:[Jt.jsxDEV(ur,{tone:"bad"},void 0,!1,void 0,this),Jt.jsxDEV("span",{children:u("shell.sync-failed")},void 0,!1,void 0,this)]},void 0,!0,void 0,this),h=`${l.error??u("shell.sync-failed")} — click to retry`;else if(i>uM)S=Jt.jsxDEV(Jt.Fragment,{children:[Jt.jsxDEV(jl,{size:13,className:"spin"},void 0,!1,void 0,this),Jt.jsxDEV("span",{children:u("shell.indexing")},void 0,!1,void 0,this),Jt.jsxDEV("span",{className:"live-chip-count",children:[z(i),"h left"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),h=u("shell.building-rollups");else S=Jt.jsxDEV(Jt.Fragment,{children:[Jt.jsxDEV(ur,{tone:"live",pulse:!0},void 0,!1,void 0,this),Jt.jsxDEV("span",{children:u("shell.live")},void 0,!1,void 0,this),l.lastSyncedAt!==null&&Jt.jsxDEV("span",{className:"live-chip-count",children:cM(p-l.lastSyncedAt)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),h=u("shell.sync-now");return Jt.jsxDEV("button",{type:"button",className:"live-chip",onClick:f,disabled:l.phase==="syncing",title:h,children:S},void 0,!1,void 0,this)}var uM=24;function iM(l){let[i,c]=Pm.useState(Date.now);return Pm.useEffect(()=>{if(l===null)return;c(Date.now());let f=setInterval(()=>c(Date.now()),l);return()=>clearInterval(f)},[l]),i}function cM(l){let i=Math.max(0,Math.round(l/1000));if(i<45)return u("shell.just-now");let c=Math.round(i/60);if(c<60)return`${c}m ago`;let f=Math.round(c/60);return f<24?`${f}h ago`:`${Math.round(f/24)}d ago`}var _m=[{headingKey:"nav.usage",items:[{id:"overview",labelKey:"nav.overview",icon:xd,hotkey:"o"},{id:"models",labelKey:"nav.models",icon:gd,hotkey:"m"},{id:"providers",labelKey:"nav.providers",icon:Gl,hotkey:"p"},{id:"costs",labelKey:"nav.costs",icon:hd,hotkey:"c"}]},{headingKey:"nav.activity",items:[{id:"requests",labelKey:"nav.requests",icon:ud,hotkey:"r"},{id:"errors",labelKey:"nav.errors",icon:Hl,hotkey:"e"},{id:"traces",labelKey:"nav.traces",icon:Sn,hotkey:"t"}]},{headingKey:"nav.insights",items:[{id:"tools",labelKey:"nav.tools",icon:Id,hotkey:"l"},{id:"frustration",labelKey:"nav.frustration",icon:Fl,hotkey:"f"},{id:"projects",labelKey:"nav.projects",icon:yd,hotkey:"j"},{id:"gain",labelKey:"nav.gain",icon:lr,hotkey:"g"}]}],dM=_m.flatMap((l)=>l.items),A1=dM.map((l)=>l.id);var Hm=Z(gt(),1),M1="zeta-stats-theme",D1="(prefers-color-scheme: dark)";function fM(){if(typeof localStorage>"u")return"system";let l=localStorage.getItem(M1);return l==="light"||l==="dark"||l==="system"?l:"system"}function E1(){if(typeof window>"u")return"dark";return window.matchMedia(D1).matches?"dark":"light"}var Ws=fM(),Ed=Ws==="system"?E1():Ws,Yv=new Set;function O1(){for(let l of Yv)l()}function $v(){if(Ed=Ws==="system"?E1():Ws,typeof document<"u")document.documentElement.dataset.theme=Ed,document.documentElement.style.colorScheme=Ed}if(typeof window<"u")$v(),window.matchMedia(D1).addEventListener("change",()=>{if(Ws==="system")$v(),O1()});function pM(l){if(Ws=l,typeof localStorage<"u")localStorage.setItem(M1,l);$v(),O1()}function Qv(l){return Yv.add(l),()=>Yv.delete(l)}function q1(){return Hm.useSyncExternalStore(Qv,()=>Ed,()=>"dark")}function N1(){let l=Hm.useSyncExternalStore(Qv,()=>Ws,()=>"system"),i=Hm.useSyncExternalStore(Qv,()=>Ed,()=>"dark");return{preference:l,resolved:i,setPreference:pM}}var Kv=Z(ue(),1),mM={system:"light",light:"dark",dark:"system"},hM={system:Ld,light:Td,dark:Cd},B1={system:u("shell.system-theme"),light:u("shell.light-theme"),dark:u("shell.dark-theme")};function z1(){let{preference:l,setPreference:i}=N1(),c=hM[l];return Kv.jsxDEV("button",{type:"button",className:"btn","data-variant":"ghost","data-icon":"true",onClick:()=>i(mM[l]),"aria-label":`${B1[l]} (click to switch)`,title:`${B1[l]} — click to switch`,children:Kv.jsxDEV(c,{size:15},void 0,!1,void 0,this)},void 0,!1,void 0,this)}var at=Z(ue(),1),gM=ci.map((l,i)=>({value:l,label:u(ia(l).labelKey),title:`${u(ia(l).windowKey)} (${i+1})`}));function U1({section:l,onSectionChange:i,range:c,onRangeChange:f,children:p}){let[S,h]=yi.useState(!1),x=yM(),{sync:b}=Em();vM(i,f);let L=(C)=>{i(C),h(!1),window.scrollTo({top:0})},g=b.phase==="syncing"?b.total>0?b.current/b.total:null:void 0;return at.jsxDEV(at.Fragment,{children:[at.jsxDEV("div",{className:"shell-ambient"},void 0,!1,void 0,this),at.jsxDEV("header",{className:"topbar","data-scrolled":x,children:[at.jsxDEV("button",{type:"button",className:"btn topbar-menu","data-variant":"ghost","data-icon":"true",onClick:()=>h(!0),"aria-label":u("nav.open-navigation"),children:at.jsxDEV(Sd,{size:16},void 0,!1,void 0,this)},void 0,!1,void 0,this),at.jsxDEV("div",{className:"topbar-brand",children:[at.jsxDEV("svg",{className:"topbar-mark",viewBox:"0 0 64 64",width:"22",height:"22","aria-hidden":"true",children:[at.jsxDEV("defs",{children:at.jsxDEV("linearGradient",{id:"zeta-mark-grad",x1:"0",y1:"0",x2:"1",y2:"1",children:[at.jsxDEV("stop",{offset:"0",stopColor:"oklch(0.7 0.24 340)"},void 0,!1,void 0,this),at.jsxDEV("stop",{offset:".5",stopColor:"oklch(0.62 0.21 295)"},void 0,!1,void 0,this),at.jsxDEV("stop",{offset:"1",stopColor:"oklch(0.81 0.14 200)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),at.jsxDEV("text",{x:"32",y:"47",textAnchor:"middle",fontSize:"52",fontWeight:"700",fontFamily:"Georgia, 'Times New Roman', serif",fill:"url(#zeta-mark-grad)",children:"ζ"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),at.jsxDEV("span",{children:"zeta"},void 0,!1,void 0,this),at.jsxDEV("span",{className:"topbar-slash",children:"/"},void 0,!1,void 0,this),at.jsxDEV("span",{className:"topbar-title",children:u("nav.breadcrumb-stats")},void 0,!1,void 0,this)]},void 0,!0,void 0,this),at.jsxDEV("div",{className:"topbar-spacer"},void 0,!1,void 0,this),at.jsxDEV("div",{className:"topbar-actions",children:[at.jsxDEV("span",{className:"topbar-hide-narrow",children:at.jsxDEV(R1,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),at.jsxDEV(_a,{options:gM,value:c,onChange:f,"aria-label":u("common.time-range")},void 0,!1,void 0,this),at.jsxDEV(z1,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this),g!==void 0&&at.jsxDEV("div",{className:"topbar-progress",children:at.jsxDEV("div",{className:"topbar-progress-fill","data-indeterminate":g===null,style:{width:`${(g??0)*100}%`}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),S&&at.jsxDEV("div",{className:"drawer-scrim",onClick:()=>h(!1),role:"presentation"},void 0,!1,void 0,this),at.jsxDEV("nav",{className:"sidebar","data-open":S,"aria-label":u("nav.pages"),children:[_m.map((C)=>at.jsxDEV("div",{className:"nav-group",children:[at.jsxDEV("div",{className:"nav-heading",children:u(C.headingKey)},void 0,!1,void 0,this),C.items.map((w)=>at.jsxDEV("button",{type:"button",className:"nav-row","data-active":w.id===l,"aria-current":w.id===l?"page":void 0,onClick:()=>L(w.id),children:[at.jsxDEV(w.icon,{size:15},void 0,!1,void 0,this),at.jsxDEV("span",{className:"nav-row-label",children:u(w.labelKey)},void 0,!1,void 0,this),at.jsxDEV("kbd",{children:["G ",w.hotkey.toUpperCase()]},void 0,!0,void 0,this)]},w.id,!0,void 0,this))]},C.headingKey,!0,void 0,this)),at.jsxDEV("div",{className:"sidebar-foot micro",children:[at.jsxDEV("span",{children:[at.jsxDEV("span",{className:"kbd",children:"1"},void 0,!1,void 0,this),"–",at.jsxDEV("span",{className:"kbd",children:"6"},void 0,!1,void 0,this)," ",u("shell.range-suffix")]},void 0,!0,void 0,this),at.jsxDEV("span",{children:[at.jsxDEV("span",{className:"kbd",children:"G"},void 0,!1,void 0,this)," ",u("shell.jump-hint")]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),at.jsxDEV("main",{className:"shell-panel",children:at.jsxDEV("div",{className:"shell-content",children:p},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function yM(){let[l,i]=yi.useState(!1);return yi.useEffect(()=>{let c=()=>i(window.scrollY>4);return c(),window.addEventListener("scroll",c,{passive:!0}),()=>window.removeEventListener("scroll",c)},[]),l}function vM(l,i){yi.useEffect(()=>{let c=0,f=(p)=>{if(p.metaKey||p.ctrlKey||p.altKey||p.defaultPrevented)return;let S=p.target;if(S instanceof HTMLElement&&(S.isContentEditable||S.tagName==="INPUT"||S.tagName==="TEXTAREA"||S.tagName==="SELECT"))return;if(document.querySelector('[aria-modal="true"]'))return;let h=p.key.toLowerCase();if(c&&Date.now()-c<1200){c=0;let b=_m.flatMap((L)=>L.items).find((L)=>L.hotkey===h);if(b)p.preventDefault(),l(b.id),window.scrollTo({top:0});return}if(h==="g"){c=Date.now();return}let x=Number(h)-1;if(Number.isInteger(x)&&x>=0&&x<ci.length)p.preventDefault(),i(ci[x])};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[l,i])}var Vr=Z(gt(),1);function Od(l){let[i,c]=l.replace(/^#\/?/,"").split("?"),f=A1.includes(i)?i:"overview",p=new URLSearchParams(c??""),S=p.get("range"),h=ci.includes(S??"")?S:"24h";return{section:f,range:h,session:p.get("s")}}function Fm({section:l,range:i,session:c}){let f=c?`&s=${encodeURIComponent(c)}`:"";return`#/${l}?range=${i}${f}`}function P1(){let[l,i]=Vr.useState(()=>Od(window.location.hash));Vr.useEffect(()=>{let h=()=>i(Od(window.location.hash));window.addEventListener("hashchange",h),window.addEventListener("popstate",h);let x=Fm(Od(window.location.hash));if(window.location.hash!==x)history.replaceState(null,"",x);return()=>{window.removeEventListener("hashchange",h),window.removeEventListener("popstate",h)}},[]);let c=Vr.useCallback((h)=>{i(h);let x=Fm(h);if(window.location.hash!==x)history.pushState(null,"",x)},[]),f=Vr.useCallback((h)=>c({...l,section:h,session:h==="traces"?l.session:null}),[l,c]),p=Vr.useCallback((h)=>c({...l,range:h}),[l,c]),S=Vr.useCallback((h)=>c({...l,session:h}),[l,c]);return{...l,setSection:f,setRange:p,setSession:S}}var zd=Z(gt(),1);var pr=Z(ue(),1);function qd({items:l,max:i,onSelect:c}){let f=i??Math.max(0,...l.map((p)=>p.value));return pr.jsxDEV("div",{className:"bar-list",children:l.map((p)=>{let S=f>0?Math.max(0.5,p.value/f*100):0,h=pr.jsxDEV(pr.Fragment,{children:[pr.jsxDEV("span",{className:"bar-list-fill",style:{width:`${S}%`,background:p.color??"var(--chart-primary)"}},void 0,!1,void 0,this),pr.jsxDEV("span",{className:"bar-list-label",children:p.label},void 0,!1,void 0,this),pr.jsxDEV("span",{className:"bar-list-value",children:p.display??z(p.value)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return c?pr.jsxDEV("button",{type:"button",className:"bar-list-row",onClick:()=>c(p.key),children:h},p.key,!1,void 0,this):pr.jsxDEV("div",{className:"bar-list-row",children:h},p.key,!1,void 0,this)})},void 0,!1,void 0,this)}var jr=Z(gt(),1);var bt=Z(ue(),1),Js=10,bM=24,xM=68,SM=4;function Tn({slots:l,tickLabel:i,tooltipTitle:c,series:f,kind:p="bars",stacked:S=!0,height:h=220,format:x=Ae,formatRight:b,formatTooltip:L,yMax:g,yMaxRight:C,hidden:w,showTotal:A,references:k,onSelect:D,emptyLabel:M="No data in this range",tooltipExtra:B}){let[P,j]=zm(),[Y,ce]=jr.useState(null),J=jr.useId().replace(/:/g,""),te=jr.useMemo(()=>f.filter((V)=>!w?.has(V.key)),[f,w]),X=jr.useMemo(()=>{let V=te.filter((ft)=>ft.axis!=="right"),Re=te.filter((ft)=>ft.axis==="right"),oe=(ft)=>S&&(ft.kind??p)!=="line",ve=new Map,G=Array.from({length:l},()=>0),_e=0;for(let ft of V)if(oe(ft)){let Oe=G.slice();ve.set(ft.key,Oe);for(let un=0;un<l;un++)G[un]+=ft.values[un]??0}else for(let Oe=0;Oe<l;Oe++)_e=Math.max(_e,ft.values[Oe]??0);for(let ft of G)_e=Math.max(_e,ft);let Qe=0;for(let ft of Re)for(let Oe=0;Oe<l;Oe++)Qe=Math.max(Qe,ft.values[Oe]??0);for(let ft of k??[])if(ft.axis==="right")Qe=Math.max(Qe,ft.value);else _e=Math.max(_e,ft.value);let Ue=_1(g??_e),dt=Re.length>0?_1(C??Qe):null,et=te.every((ft)=>ft.values.every((Oe)=>!Oe));return{left:V,right:Re,bases:ve,stackable:oe,leftScale:Ue,rightScale:dt,empty:et}},[te,l,S,p,g,C,k]),ae=X.leftScale.ticks.map((V)=>x(V)),H=X.rightScale?.ticks.map((V)=>(b??x)(V))??[],de=Math.max(28,H1(ae)+12),xe=X.rightScale?Math.max(28,H1(H)+12):8,Ce=Math.max(0,j-de-xe),Be=h-Js-bM,ne=l>0?Ce/l:0,me=(V)=>Js+Be-V/X.leftScale.max*Be,ke=(V)=>Js+Be-V/(X.rightScale?.max??1)*Be,$e=(V)=>de+(V+0.5)*ne,xt=te.filter((V)=>(V.kind??p)==="bars"),W=xt.filter((V)=>!X.stackable(V)||V.axis==="right"),ze=Math.max(1,Math.min(56,ne*(ne>6?0.72:0.9))),Ct=Math.max(1,Math.ceil(l/Math.max(1,Math.floor(Ce/xM)))),it=(V)=>{let Re=V.currentTarget.getBoundingClientRect(),oe=Math.floor((V.clientX-Re.left)/(Re.width/l));ce(oe>=0&&oe<l?oe:null)},ct=Y===null?[]:te.filter((V)=>V.tooltip!==!1).map((V)=>({s:V,v:V.values[Y]})).filter((V)=>V.v!==null&&V.v!==void 0&&(V.v!==0||te.length===1)).sort((V,Re)=>te.length>1?Re.v-V.v:0),Me=ct.filter((V)=>V.s.axis!=="right").reduce((V,Re)=>V+Re.v,0),ye=A??(S&&X.left.length>1);return bt.jsxDEV("div",{className:"chart",ref:P,"data-hovering":Y!==null,style:{height:h},children:[j>0&&bt.jsxDEV("svg",{width:j,height:h,role:"img",children:[bt.jsxDEV("defs",{children:te.filter((V)=>V.pattern==="hatch").map((V)=>bt.jsxDEV("pattern",{id:`${J}-${Zv(V.key)}`,width:"5",height:"5",patternUnits:"userSpaceOnUse",patternTransform:"rotate(45)",children:[bt.jsxDEV("rect",{width:"5",height:"5",fill:V.color,fillOpacity:"0.14"},void 0,!1,void 0,this),bt.jsxDEV("rect",{width:"1.6",height:"5",fill:V.color},void 0,!1,void 0,this)]},V.key,!0,void 0,this))},void 0,!1,void 0,this),bt.jsxDEV("g",{className:"chart-grid",children:X.leftScale.ticks.map((V)=>bt.jsxDEV("line",{x1:de,x2:de+Ce,y1:me(V),y2:me(V)},V,!1,void 0,this))},void 0,!1,void 0,this),bt.jsxDEV("g",{className:"chart-axis",children:[X.leftScale.ticks.map((V,Re)=>bt.jsxDEV("text",{x:de-8,y:me(V),dy:"0.32em",textAnchor:"end",children:ae[Re]},V,!1,void 0,this)),X.rightScale?.ticks.map((V,Re)=>bt.jsxDEV("text",{x:de+Ce+8,y:ke(V),dy:"0.32em",textAnchor:"start",children:H[Re]},V,!1,void 0,this)),Array.from({length:l},(V,Re)=>Re%Ct===0?bt.jsxDEV("text",{x:$e(Re),y:h-6,textAnchor:"middle",children:i(Re)},Re,!1,void 0,this):null)]},void 0,!0,void 0,this),Y!==null&&bt.jsxDEV("rect",{className:"chart-cursor",x:de+Y*ne,y:Js,width:ne,height:Be},void 0,!1,void 0,this),te.filter((V)=>(V.kind??p)==="area").map((V)=>{let Re=V.axis==="right"?ke:me,oe=X.bases.get(V.key),ve=(Ue)=>(oe?.[Ue]??0)+(V.values[Ue]??0),G=F1(l,$e,(Ue)=>Re(ve(Ue))),_e=Array.from({length:l},(Ue,dt)=>l-1-dt).map((Ue)=>`L${$e(Ue).toFixed(1)},${Re(oe?.[Ue]??0).toFixed(1)}`).join(""),Qe=V.pattern==="hatch"?`url(#${J}-${Zv(V.key)})`:V.color;return bt.jsxDEV("g",{children:[bt.jsxDEV("path",{d:`${G}${_e}Z`,fill:Qe,fillOpacity:V.pattern?1:0.2},void 0,!1,void 0,this),bt.jsxDEV("path",{className:"chart-line",d:G,stroke:V.color},void 0,!1,void 0,this)]},V.key,!0,void 0,this)}),xt.map((V)=>{let Re=V.axis==="right"?ke:me,oe=X.bases.get(V.key),ve=W.indexOf(V),G=ve>=0?ze/W.length:ze,_e=V.pattern==="hatch"?`url(#${J}-${Zv(V.key)})`:V.color;return bt.jsxDEV("g",{children:V.values.map((Qe,Ue)=>{if(!Qe)return null;let dt=ve>=0?0:oe?.[Ue]??0,et=Re(dt),ft=Re(dt+Qe),Oe=$e(Ue)-ze/2+(ve>=0?ve*G:0);return bt.jsxDEV("rect",{className:"chart-bar","data-hover":Y===Ue,x:Oe,y:Math.min(et,ft),width:Math.max(1,G-(ve>=0&&W.length>1?1:0)),height:Math.max(Qe>0?1:0,Math.abs(et-ft)),fill:_e},Ue,!1,void 0,this)})},V.key,!1,void 0,this)}),te.filter((V)=>(V.kind??p)==="line").map((V)=>{let Re=V.axis==="right"?ke:me,oe=(ve)=>{let G=V.values[ve];return G===null||G===void 0?null:Re(G)};return bt.jsxDEV("g",{children:[bt.jsxDEV("path",{className:"chart-line",d:F1(l,$e,oe),stroke:V.color,strokeDasharray:V.dashed?"4 3":void 0},void 0,!1,void 0,this),V.values.map((ve,G)=>{let _e=oe(G);if(_e===null||G>0&&oe(G-1)!==null||G<l-1&&oe(G+1)!==null)return null;return bt.jsxDEV("circle",{cx:$e(G),cy:_e,r:2.5,fill:V.color},G,!1,void 0,this)})]},V.key,!0,void 0,this)}),k?.map((V)=>{let Re=V.axis==="right"?ke(V.value):me(V.value);return bt.jsxDEV("g",{className:"chart-axis",children:[bt.jsxDEV("line",{x1:de,x2:de+Ce,y1:Re,y2:Re,stroke:"var(--line-4)",strokeDasharray:"3 3"},void 0,!1,void 0,this),V.label&&bt.jsxDEV("text",{x:de+Ce-4,y:Re-5,textAnchor:"end",children:V.label},void 0,!1,void 0,this)]},`${V.axis??"left"}:${V.value}`,!0,void 0,this)}),bt.jsxDEV("line",{className:"chart-baseline",x1:de,x2:de+Ce,y1:me(0),y2:me(0)},void 0,!1,void 0,this),bt.jsxDEV("rect",{x:de,y:Js,width:Ce,height:Be,fill:"transparent",onPointerMove:it,onPointerLeave:()=>ce(null),onClick:D&&Y!==null?()=>D(Y):void 0,style:{cursor:D?"pointer":"crosshair"}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X.empty&&bt.jsxDEV("div",{className:"chart-empty",children:M},void 0,!1,void 0,this),Y!==null&&!X.empty&&bt.jsxDEV("div",{className:"chart-tooltip",style:$e(Y)>j/2?{right:j-$e(Y)+Math.min(ne/2,24)+8,top:Js}:{left:$e(Y)+Math.min(ne/2,24)+8,top:Js},children:[bt.jsxDEV("div",{className:"chart-tooltip-title",children:(c??i)(Y)},void 0,!1,void 0,this),ct.map(({s:V,v:Re})=>bt.jsxDEV("div",{className:"chart-tooltip-row",children:[bt.jsxDEV("span",{className:"swatch",style:{background:V.color}},void 0,!1,void 0,this),bt.jsxDEV("span",{className:"chart-tooltip-label",children:V.label},void 0,!1,void 0,this),bt.jsxDEV("span",{className:"chart-tooltip-value",children:V.axis==="right"?(b??x)(Re):(L??x)(Re)},void 0,!1,void 0,this)]},V.key,!0,void 0,this)),ye&&ct.length>1&&bt.jsxDEV("div",{className:"chart-tooltip-row chart-tooltip-total",children:[bt.jsxDEV("span",{className:"chart-tooltip-label",children:"Total"},void 0,!1,void 0,this),bt.jsxDEV("span",{className:"chart-tooltip-value",children:(L??x)(Me)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),B&&bt.jsxDEV(jr.Fragment,{children:B(Y)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function _1(l){if(!(l>0))return{max:1,ticks:[0]};let i=l/SM,c=10**Math.floor(Math.log10(i)),f=[1,2,2.5,5,10].map((h)=>h*c).find((h)=>h>=i)??10*c,p=Math.ceil(l/f)*f,S=[];for(let h=0;h<=p+f/2;h+=f)S.push(Number(h.toPrecision(12)));return{max:p,ticks:S}}function H1(l){return l.reduce((i,c)=>Math.max(i,c.length*6.3),0)}function F1(l,i,c){let f="",p=!1;for(let S=0;S<l;S++){let h=c(S);if(h===null){p=!1;continue}f+=`${p?"L":"M"}${i(S).toFixed(1)},${h.toFixed(1)}`,p=!0}return f}function Zv(l){return l.replace(/[^a-zA-Z0-9_-]/g,"_")}var Gm=Z(gt(),1),mr=Z(ue(),1);function Ka({items:l,hidden:i,onToggle:c}){return mr.jsxDEV("div",{className:"legend",children:l.map((f)=>{let p=mr.jsxDEV(mr.Fragment,{children:[mr.jsxDEV("span",{className:"swatch",style:{background:f.color}},void 0,!1,void 0,this),mr.jsxDEV("span",{className:"truncate",children:f.label},void 0,!1,void 0,this),f.value&&mr.jsxDEV("span",{className:"legend-value",children:f.value},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return c?mr.jsxDEV("button",{type:"button",className:"legend-item","data-off":i?.has(f.key)??!1,onClick:()=>c(f.key),title:f.label,children:p},f.key,!1,void 0,this):mr.jsxDEV("span",{className:"legend-item",title:f.label,children:p},f.key,!1,void 0,this)})},void 0,!1,void 0,this)}function sn(){let[l,i]=Gm.useState(()=>new Set),c=Gm.useCallback((f)=>{i((p)=>{let S=new Set(p);if(!S.delete(f))S.add(f);return S})},[]);return[l,c]}var Wv=Z(ue(),1);function $l({segments:l,height:i=8}){let c=l.reduce((f,p)=>f+Math.max(0,p.value),0);return Wv.jsxDEV("div",{className:"share-bar",style:{height:i},role:"img",children:c>0&&l.filter((f)=>f.value>0).map((f)=>Wv.jsxDEV("div",{className:"share-bar-seg",style:{flexGrow:f.value/c,background:f.color},title:`${f.label}: ${(f.value/c*100).toFixed(1)}%`},f.key,!1,void 0,this))},void 0,!1,void 0,this)}var G1=Z(ue(),1);function Xr({buckets:l,bucketMs:i,onSelectBucket:c,...f}){return G1.jsxDEV(Tn,{...f,slots:l.length,tickLabel:(p)=>Am(l[p],i),tooltipTitle:(p)=>Rm(l[p],i),onSelect:c?(p)=>c(l[p]):void 0},void 0,!1,void 0,this)}var Fa=["#5ad8e6","#ed4abf","#9d7bff","#f5b54a","#4ade80","#5b8cff","#ff7a59","#2dd4bf","#c3e94f","#fb7185"],ao="#6c6c74";function ba(l,i){return`${l}::${i}`}function Vm(l){return Nd(l.map((i)=>({key:ba(i.model,i.provider),weight:i.totalRequests})))}function Nd(l){let i=[...l].sort((c,f)=>f.weight-c.weight||c.key.localeCompare(f.key));return new Map(i.map((c,f)=>[c.key,Fa[f%Fa.length]]))}var xa=Z(gt(),1);var LM={entries:new Map,limit:128},CM={entries:new Map,limit:4},wM={entries:new Map,limit:16},eu=new Map;function V1(l){if(l.startsWith('["trace",'))return CM;if(l.startsWith('["request",'))return wM;return LM}function Bd(l){return V1(l).entries.get(l)}function j1(l){return eu.get(l)}function kM(l,i){let{entries:c,limit:f}=V1(l);if(c.delete(l),c.set(l,i),c.size>f){let p=c.keys().next().value;if(p!==void 0)c.delete(p)}}function X1(l,i,c){let f=eu.get(l);if(f)return f.waiters++,f;let p=new AbortController,S=Bd(l)?.data,h={promise:c({signal:p.signal},S).then((x)=>(kM(l,{data:x,updatedAt:Date.now(),version:i}),x)).finally(()=>{if(eu.get(l)===h)eu.delete(l)}),controller:p,waiters:1};return eu.set(l,h),h}function Jv(l,i){if(i.waiters--,i.waiters>0)return;if(eu.get(l)===i)eu.delete(l);i.controller.abort()}var TM=1500;function Ft(l,i,c){let f=JSON.stringify(l),p=c?.enabled??!0,S=c?.pollMs,h=C1(p),[,x]=xa.useReducer((te)=>te+1,0),[b,L]=xa.useState(null),[g,C]=xa.useState(!1),w=xa.useRef(i);w.current=i;let A=xa.useRef(f);A.current=f;let k=xa.useRef(null),D=xa.useRef(0),M=xa.useRef(null),B=xa.useCallback((te)=>{D.current=Date.now();let X=M.current;if(X?.key===te&&j1(te)===X.request)return;let ae=Bd(te)?.data;C(!0);let H=X1(te,S1(),w.current);if(M.current={key:te,request:H},X)Jv(X.key,X.request);H.promise.then((de)=>{if(A.current!==te)return;if(de===ae){L((xe)=>xe===null?xe:null);return}xa.startTransition(()=>{L(null),x()})}).catch((de)=>{if(A.current!==te||H.controller.signal.aborted)return;L({key:te,error:de instanceof Error?de:Error(String(de))})}).finally(()=>{if(M.current?.request===H)M.current=null;if(A.current===te)C(!1)})},[]),P=xa.useCallback(()=>{let te=M.current;if(M.current=null,te)Jv(te.key,te.request)},[]);xa.useEffect(()=>P,[P]),xa.useEffect(()=>{if(!p||M.current&&M.current.key!==f)P();if(!p)return;let te=Bd(f);if(te&&te.version>=h)return;let X=te?D.current+TM-Date.now():0;if(X<=0){B(f);return}let ae=setTimeout(()=>B(f),X);return()=>clearTimeout(ae)},[f,p,h,B,P]),xa.useEffect(()=>{if(!p||!S)return;let te=setInterval(()=>{if(!document.hidden)B(A.current)},S);return()=>clearInterval(te)},[p,S,B]);let j=xa.useCallback(()=>B(A.current),[B]),Y=Bd(f);if(Y)k.current={key:f,data:Y.data,updatedAt:Y.updatedAt};let ce=k.current,J=b?.key===f?b.error:null;return{data:ce?.data??null,error:J,loading:!ce&&!J,stale:!!ce&&ce.key!==f,refreshing:g,updatedAt:ce?.updatedAt??null,refetch:j}}function Sa(l,i,c){let f=Y1(i),p=Array.from({length:i.length},()=>0);for(let S of l){let h=f.get(S.timestamp);if(h!==void 0)p[h]+=c(S)}return p}function hr(l,i){let c=Y1(i.buckets),f=new Map;for(let L of l){let g=c.get(L.timestamp);if(g===void 0)continue;let C=i.key(L),w=f.get(C);if(!w)w=Array.from({length:i.buckets.length},()=>0),f.set(C,w);w[g]+=i.value(L)}let p=[...f.entries()].map(([L,g])=>({key:L,values:g,total:g.reduce((C,w)=>C+w,0)})).filter((L)=>L.total!==0).sort((L,g)=>g.total-L.total||L.key.localeCompare(g.key)),S=i.limit??Number.POSITIVE_INFINITY,h=p.slice(0,S),x=p.slice(S),b=h.map((L,g)=>({key:L.key,label:i.label?i.label(L.key):L.key,color:i.colors?.get(L.key)??Fa[g%Fa.length],values:L.values}));if(x.length>0){let L=Array.from({length:i.buckets.length},()=>0);for(let g of x)for(let C=0;C<L.length;C++)L[C]+=g.values[C];b.push({key:"__other__",label:u("common.other-n",{count:x.length}),color:ao,values:L})}return b}function Y1(l){let i=new Map;for(let c=0;c<l.length;c++)i.set(l[c],c);return i}var IM=["main","subagent","advisor"];function Ql(l){return l.totalInputTokens+l.totalOutputTokens+l.totalCacheReadTokens+l.totalCacheWriteTokens}function K1(l){let i=new Map;for(let h of l)i.set(h.agentType,h);let c=IM.map((h)=>i.get(h)).filter((h)=>h!==void 0),f=c.reduce((h,x)=>h+Ql(x),0),p=c.reduce((h,x)=>h+x.totalCost,0),S=c.map((h)=>{let x=Ql(h);return{agentType:h.agentType,tokens:x,requests:h.totalRequests,cost:h.totalCost,share:f>0?x/f:0}});return{totalTokens:f,totalCost:p,segments:S}}function Z1(l){let i={totalCost:0,requests:0,unpricedRequests:0,activeDays:new Set(l.map((p)=>p.timestamp)).size,avgDailyCost:0,costInput:0,costOutput:0,costCacheRead:0,costCacheWrite:0,models:[],topModel:null},c=new Map;for(let p of l){let S=ba(p.model,p.provider),h=c.get(S);if(!h)h={key:S,model:p.model,provider:p.provider,cost:0,requests:0,unpricedRequests:0,costInput:0,costOutput:0,costCacheRead:0,costCacheWrite:0,share:0},c.set(S,h);$1(h,p),$1(i,p),h.cost+=p.cost,i.totalCost+=p.cost}i.avgDailyCost=i.activeDays>0?i.totalCost/i.activeDays:0,i.models=[...c.values()].sort((p,S)=>S.cost-p.cost||S.requests-p.requests||p.key.localeCompare(S.key));for(let p of i.models)p.share=i.totalCost>0?p.cost/i.totalCost:0;let f=i.models[0];return i.topModel=f!==void 0&&f.cost>0?f:null,i}function $1(l,i){l.costInput+=i.costInput,l.costOutput+=i.costOutput,l.costCacheRead+=i.costCacheRead,l.costCacheWrite+=i.costCacheWrite,l.requests+=i.requests,l.unpricedRequests+=i.unpricedRequests}function W1(l){let i=new Map;for(let c of l){let f=ba(c.model,c.provider),p=i.get(f);if(!p)p=[],i.set(f,p);p.push({timestamp:c.timestamp,avgTtftSeconds:c.avgTtft!==null?c.avgTtft/1000:null,avgTokensPerSecond:c.avgTokensPerSecond,requests:c.requests})}for(let c of i.values())c.sort((f,p)=>f.timestamp-p.timestamp);return i}var RM=/^\/?-?(?:private-)?(?:tmp|var-folders)(?:[-/]|$)/;function J1(l){let i=0,c=0,f=0,p=0,S=0,h=0,x=0,b=0,L=0;for(let w of l){if(i+=w.totalRequests,c+=w.failedRequests,f+=w.totalCost,p+=w.unpricedRequests,S+=w.totalInputTokens+w.totalCacheReadTokens+w.totalCacheWriteTokens+w.totalOutputTokens,h+=w.totalInputTokens,x+=w.totalCacheReadTokens,w.totalRequests>b)b=w.totalRequests;if(w.totalCost>L)L=w.totalCost}let g=0;return{rows:l.map((w)=>{let A=RM.test(w.folder);if(A)g++;return{...w,conversationTokens:w.totalInputTokens+w.totalCacheReadTokens+w.totalCacheWriteTokens+w.totalOutputTokens,requestShare:i>0?w.totalRequests/i:0,costShare:f>0?w.totalCost/f:0,temporary:A}}),totalRequests:i,failedRequests:c,totalCost:f,unpricedRequests:p,conversationTokens:S,cacheRate:h+x>0?x/(h+x):0,maxRequests:b,maxCost:L,temporaryCount:g}}function eT(l){let i=0,c=0,f=0;for(let p of l)i+=p.calls,c+=p.totalTokensShare,f+=p.costShare;return l.map((p)=>({...p,errorRate:p.calls>0?p.errors/p.calls:0,callFraction:i>0?p.calls/i:0,tokenFraction:c>0?p.totalTokensShare/c:0,costFraction:f>0?p.costShare/f:0,avgResultChars:p.calls>0?p.resultChars/p.calls:0}))}function Yr(l){if(l.stopReason==="aborted")return"aborted";if(l.stopReason==="error"||l.errorMessage)return"failed";return"ok"}function eb(l,i){if(l.length===0)return null;return l[Math.min(l.length-1,Math.max(0,Math.ceil(i*l.length)-1))]}function tT(l){let i=0,c=0,f=0,p=0,S=0,h=null,x=null,b=[],L=[];for(let g of l){let C=Yr(g);if(C==="failed")i++;else if(C==="aborted")c++;if(f+=g.usage.totalTokens,p+=g.usage.cost.total,Vv(g))S++;if(g.duration!==null)b.push(g.duration);if(g.ttft!==null)L.push(g.ttft);if(h===null||g.timestamp<h)h=g.timestamp;if(x===null||g.timestamp>x)x=g.timestamp}return b.sort((g,C)=>g-C),L.sort((g,C)=>g-C),{requests:l.length,failed:i,aborted:c,tokens:f,cost:p,unpriced:S,medianDuration:eb(b,0.5),p95Duration:eb(b,0.95),medianTtft:eb(L,0.5),oldest:h,newest:x}}var Q1=180,AM=/\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/gi,MM=/\b(?:req|msg|call|toolu|chatcmpl|resp|run|gen)[-_][A-Za-z0-9_-]{6,}/g,DM=/\b[0-9a-f]{12,}\b/gi,EM=/(?<![\w.-])\d+(?:\.\d+)?/g,OM=/^[1-5]\d\d$/;function tb(l){if(!l?.trim())return"Unknown error";let i=l.replace(/\s+/g," ").trim().replace(AM,"<id>").replace(MM,"<id>").replace(DM,"<hex>").replace(EM,(c)=>OM.test(c)?c:"N");return i.length>Q1?`${i.slice(0,Q1-1)}…`:i}function aT(l){let i=new Map;for(let c of l){let f=tb(c.errorMessage),p=i.get(f);if(!p)p={signature:f,count:0,firstSeen:c.timestamp,lastSeen:c.timestamp,latest:c,models:[],byModel:new Map},i.set(f,p);if(p.count++,c.timestamp<p.firstSeen)p.firstSeen=c.timestamp;if(c.timestamp>p.lastSeen)p.lastSeen=c.timestamp,p.latest=c;let S=ba(c.model,c.provider),h=p.byModel.get(S);if(h)h.count++;else p.byModel.set(S,{model:c.model,provider:c.provider,count:1})}return[...i.values()].map(({byModel:c,...f})=>({...f,models:[...c.values()].sort((p,S)=>S.count-p.count||p.model.localeCompare(S.model))})).sort((c,f)=>f.count-c.count||f.lastSeen-c.lastSeen)}var De=Z(ue(),1),qM=[{value:"model",label:u("costs.by-model")},{value:"component",label:u("costs.by-component")}],NM=6,BM=86400000,Ud=[{key:"costInput",label:u("common.input"),color:"#5b8cff"},{key:"costOutput",label:u("common.output"),color:"var(--chart-secondary)"},{key:"costCacheRead",label:u("common.cache-read"),color:"var(--chart-primary)"},{key:"costCacheWrite",label:u("common.cache-write"),color:"#f5b54a"}],zM=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",timeZone:"UTC"}),UM=new Intl.DateTimeFormat(void 0,{weekday:"short",month:"short",day:"numeric",year:"numeric",timeZone:"UTC"});function oT({active:l,range:i}){let c=Ft(["costs",i],({signal:w})=>a1(i,w),{enabled:l}),f=ia(i),[p,S]=zd.useState("model"),[h,x]=sn(),b=zd.useMemo(()=>c.data?PM(c.data,i):null,[c.data,i]),L=zd.useMemo(()=>b?FM(b):[],[b]),g=(w)=>w.costSeries.length===0,C=De.jsxDEV(wt,{title:u("costs.no-usage-in-range"),hint:u("costs.empty-hint")},void 0,!1,void 0,this);return De.jsxDEV("div",{className:"page",children:[De.jsxDEV(ra,{title:u("costs.title"),description:u("costs.description",{window:u(f.windowKey)})},void 0,!1,void 0,this),De.jsxDEV(Ge,{query:c,skeleton:De.jsxDEV(qa,{height:112,style:{borderRadius:12}},void 0,!1,void 0,this),isEmpty:g,empty:C,children:()=>b&&De.jsxDEV(_M,{view:b,stale:c.stale},void 0,!1,void 0,this)},void 0,!1,void 0,this),De.jsxDEV("div",{className:"grid grid-main-side",children:[De.jsxDEV(Ye,{index:1,title:u("costs.daily-estimate"),description:p==="model"?u("costs.daily-by-model"):u("costs.daily-by-component"),actions:De.jsxDEV(_a,{size:"sm",options:qM,value:p,onChange:S,"aria-label":u("costs.split-by")},void 0,!1,void 0,this),stale:c.stale,children:De.jsxDEV(Ge,{query:c,skeleton:De.jsxDEV(zt,{height:280},void 0,!1,void 0,this),isEmpty:g,empty:C,children:()=>{if(!b)return null;let w=p==="model"?b.modelSeries:b.componentSeries;return De.jsxDEV("div",{className:"stack",style:{gap:12},children:[De.jsxDEV(Tn,{slots:b.buckets.length,tickLabel:(A)=>zM.format(b.buckets[A]),tooltipTitle:(A)=>UM.format(b.buckets[A]),series:w,hidden:h,height:280,format:(A)=>da(A,Number.isInteger(A)?0:2),formatTooltip:(A)=>da(A),emptyLabel:u("costs.no-priced-usage"),tooltipExtra:(A)=>b.unpricedPerDay[A]>0?De.jsxDEV("div",{className:"chart-tooltip-row chart-tooltip-total",children:[De.jsxDEV("span",{className:"chart-tooltip-label",children:u("costs.unpriced-requests")},void 0,!1,void 0,this),De.jsxDEV("span",{className:"chart-tooltip-value",children:z(b.unpricedPerDay[A])},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null},void 0,!1,void 0,this),De.jsxDEV(Ka,{items:w.map((A)=>({key:A.key,label:A.label,color:A.color,value:da(GM(A.values))})),hidden:h,onToggle:x},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}},void 0,!1,void 0,this)},void 0,!1,void 0,this),De.jsxDEV(Ye,{index:2,title:u("costs.where-it-went"),description:u("costs.estimate-by-component"),stale:c.stale,children:De.jsxDEV(Ge,{query:c,skeleton:De.jsxDEV(zt,{height:280},void 0,!1,void 0,this),isEmpty:g,empty:C,children:()=>b&&De.jsxDEV(HM,{summary:b.summary},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),De.jsxDEV(Ye,{index:3,title:u("costs.by-model"),description:u("costs.by-model-description"),stale:c.stale,flush:!0,children:De.jsxDEV(Ge,{query:c,skeleton:De.jsxDEV(ca,{rows:8},void 0,!1,void 0,this),isEmpty:g,empty:C,children:()=>b&&De.jsxDEV(Xt,{rows:b.summary.models,rowKey:(w)=>w.key,columns:L,initialSort:{key:"cost",dir:"desc"},limit:20},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function PM(l,i){let c=l.costSeries,f=Z1(c),p=Vm(f.models.map((L)=>({model:L.model,provider:L.provider,totalRequests:L.requests}))),S=new Map(f.models.map((L)=>[L.key,L])),h=_o(i,c.map((L)=>L.timestamp),BM),x=hr(c,{buckets:h,key:(L)=>ba(L.model,L.provider),label:(L)=>S.get(L)?.model??L,value:(L)=>L.cost,limit:NM,colors:p}).map((L)=>({...L,values:L.values.map((g)=>g||null)})),b=new Set;for(let L of x){if(L.key==="__other__")continue;if(b.has(L.color))L.color=Fa.find((g)=>!b.has(g))??L.color;b.add(L.color)}return{summary:f,swatches:new Map(x.filter((L)=>L.key!=="__other__").map((L)=>[L.key,L.color])),buckets:h,dailyTotals:Sa(c,h,(L)=>L.cost),unpricedPerDay:Sa(c,h,(L)=>L.unpricedRequests),modelSeries:x,componentSeries:Ud.map((L)=>({key:L.key,label:L.label,color:L.color,values:Sa(c,h,(g)=>g[L.key]).map((g)=>g||null)})),maxModelCost:f.models[0]?.cost??0}}function _M({view:l,stale:i}){let{summary:c}=l,f=c.requests-c.unpricedRequests,p=c.topModel;return De.jsxDEV("div",{"data-stale":i,children:De.jsxDEV(la,{min:180,children:[De.jsxDEV(ie,{label:u("costs.api-equivalent-estimate"),title:u("costs.api-estimate-title"),value:Ht(c.totalCost,c.unpricedRequests),hint:u("costs.requests-n",{count:z(c.requests)}),spark:l.dailyTotals,sparkColor:"var(--chart-secondary)"},void 0,!1,void 0,this),De.jsxDEV(ie,{label:u("costs.average-per-day"),title:u("costs.average-per-day-title"),value:Ht(c.avgDailyCost,c.unpricedRequests),hint:u(c.activeDays===1?"costs.active-days-one":"costs.active-days-n",{count:z(c.activeDays)})},void 0,!1,void 0,this),De.jsxDEV(ie,{label:u("costs.top-model"),title:p?`${p.model} (${p.provider})`:void 0,value:p?p.model:"–",hint:p?u("costs.top-model-hint",{cost:da(p.cost),share:Fe(p.share)}):u("costs.nothing-priced-yet")},void 0,!1,void 0,this),De.jsxDEV(ie,{label:u("costs.per-priced-request"),title:u("costs.per-priced-request-title"),value:f>0?nT(c.totalCost/f):"–",hint:u("costs.priced-n",{count:z(f)})},void 0,!1,void 0,this),De.jsxDEV(ie,{label:u("costs.unpriced-requests"),title:u("costs.unpriced-title"),value:z(c.unpricedRequests),hint:c.unpricedRequests>0?u("costs.unpriced-hint"):u("costs.all-priced")},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function HM({summary:l}){return De.jsxDEV("div",{className:"stack",style:{gap:14},children:[De.jsxDEV($l,{height:10,segments:Ud.map((i)=>({key:i.key,label:i.label,value:l[i.key],color:i.color}))},void 0,!1,void 0,this),De.jsxDEV("div",{className:"costs-components",children:[Ud.map((i)=>De.jsxDEV("div",{className:"costs-component-row",children:[De.jsxDEV("span",{className:"row",children:[De.jsxDEV(Cn,{color:i.color},void 0,!1,void 0,this),i.label]},void 0,!0,void 0,this),De.jsxDEV("span",{className:"num",children:da(l[i.key])},void 0,!1,void 0,this),De.jsxDEV("span",{className:"num dim costs-component-share",children:l.totalCost>0?Fe(l[i.key]/l.totalCost):"–"},void 0,!1,void 0,this)]},i.key,!0,void 0,this)),De.jsxDEV("div",{className:"costs-component-row costs-component-total",children:[De.jsxDEV("span",{children:u("common.total")},void 0,!1,void 0,this),De.jsxDEV("span",{className:"num",children:Ht(l.totalCost,l.unpricedRequests)},void 0,!1,void 0,this),De.jsxDEV("span",{className:"costs-component-share"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),l.unpricedRequests>0&&De.jsxDEV("p",{className:"micro dim",children:u(l.unpricedRequests===1?"costs.unpriced-note-one":"costs.unpriced-note-n",{count:z(l.unpricedRequests)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function FM(l){let i=Ud.map((c)=>({key:c.key,header:c.label,align:"right",sort:(f)=>f[c.key],render:(f)=>De.jsxDEV("span",{className:"num",children:da(f[c.key])},void 0,!1,void 0,this)}));return[{key:"model",header:u("common.model"),sort:(c)=>c.model,render:(c)=>De.jsxDEV(Ha,{lead:De.jsxDEV(Cn,{color:l.swatches.get(c.key)??ao},void 0,!1,void 0,this),primary:De.jsxDEV("span",{className:"mono",children:c.model},void 0,!1,void 0,this),secondary:c.provider},void 0,!1,void 0,this)},{key:"requests",header:u("common.requests"),align:"right",sort:(c)=>c.requests,render:(c)=>De.jsxDEV("span",{className:"num",children:z(c.requests)},void 0,!1,void 0,this)},{key:"cost",header:u("costs.estimate"),title:u("costs.estimate-title"),align:"right",sort:(c)=>c.cost,render:(c)=>De.jsxDEV(pa,{value:c.cost,max:l.maxModelCost,display:Ht(c.cost,c.unpricedRequests),color:l.swatches.get(c.key)??ao},void 0,!1,void 0,this)},{key:"share",header:u("common.share"),align:"right",sort:(c)=>c.share,render:(c)=>De.jsxDEV("span",{className:"num muted",children:c.cost>0?Fe(c.share):"–"},void 0,!1,void 0,this)},{key:"split",header:u("costs.split"),title:"Input · output · cache read · cache write",width:150,render:(c)=>c.cost>0?De.jsxDEV($l,{segments:Ud.map((f)=>({key:f.key,label:f.label,value:c[f.key],color:f.color}))},void 0,!1,void 0,this):De.jsxDEV("span",{className:"dim",children:"–"},void 0,!1,void 0,this)},...i,{key:"perRequest",header:u("costs.per-request"),title:"Estimate ÷ priced requests",align:"right",sort:(c)=>c.requests>c.unpricedRequests?c.cost/(c.requests-c.unpricedRequests):-1,render:(c)=>De.jsxDEV("span",{className:"num",children:c.requests>c.unpricedRequests?nT(c.cost/(c.requests-c.unpricedRequests)):"–"},void 0,!1,void 0,this)},{key:"unpriced",header:u("costs.unpriced"),title:"Requests with no public-equivalent price",align:"right",sort:(c)=>c.unpricedRequests,render:(c)=>c.unpricedRequests>0?De.jsxDEV("span",{className:"num tone-warn",children:z(c.unpricedRequests)},void 0,!1,void 0,this):De.jsxDEV("span",{className:"num dim",children:"–"},void 0,!1,void 0,this)}]}function nT(l){return l>0&&l<0.0001?"<$0.0001":da(l)}function GM(l){let i=0;for(let c of l)i+=c??0;return i}var $r=Z(gt(),1);var be=Z(ue(),1),ab=[50,200,1000];function rT({active:l,range:i,onRequestClick:c}){let[f,p]=$r.useState(0),S=ab[f],h=Ft(["errors",i,S],({signal:ae})=>o1(i,S,ae),{enabled:l}),[x,b]=$r.useState(null),[L,g]=$r.useState(null),[C,w]=$r.useState(""),A=ia(i),k=$r.useMemo(()=>{let ae=(h.data??[]).map((Be)=>({row:Be,signature:tb(Be.errorMessage)})),H=aT(h.data??[]),de=new Map;for(let{row:Be}of ae){let ne=ba(Be.model,Be.provider),me=de.get(ne);if(me)me.count++;else de.set(ne,{model:Be.model,provider:Be.provider,count:1})}let xe=[...de.entries()].map(([Be,ne])=>({key:Be,...ne})).sort((Be,ne)=>ne.count-Be.count||Be.model.localeCompare(ne.model)),Ce=ae.reduce((Be,{row:ne})=>!Be||ne.timestamp>Be.timestamp?ne:Be,null);return{rows:ae,groups:H,models:xe,newest:Ce}},[h.data]),D=k.groups.some((ae)=>ae.signature===x)?x:null,M=k.models.some((ae)=>ae.key===L)?L:null,B=$r.useMemo(()=>{let ae=C.trim().toLowerCase();return k.rows.filter((H)=>(D===null||H.signature===D)&&(M===null||ba(H.row.model,H.row.provider)===M)&&(ae===""||H.row.model.toLowerCase().includes(ae)||H.row.provider.toLowerCase().includes(ae)||H.row.folder.toLowerCase().includes(ae)||(H.row.errorMessage??"").toLowerCase().includes(ae))).map((H)=>H.row)},[k.rows,D,M,C]),P=h.data?.length??0,j=!h.stale&&P<S,Y=f+1<ab.length?ab[f+1]:null,ce=h.data!==null&&!j?be.jsxDEV(be.Fragment,{children:[be.jsxDEV("span",{children:u("errors.footer",{count:z(P),window:u(A.windowKey)})},void 0,!1,void 0,this),Y!==null&&be.jsxDEV("button",{type:"button",className:"btn","data-size":"sm",disabled:h.refreshing,onClick:()=>p(f+1),children:h.refreshing&&h.stale?u("errors.loading"):u("errors.load-latest",{count:z(Y)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this):void 0,J=k.groups[0]?.count??0,te=$r.useMemo(()=>VM(J),[J]),X=k.models.find((ae)=>ae.key===M);return be.jsxDEV("div",{className:"page",children:[be.jsxDEV(ra,{title:u("errors.title"),description:u("errors.description",{window:u(A.windowKey)})},void 0,!1,void 0,this),be.jsxDEV(Ge,{query:h,skeleton:be.jsxDEV(qa,{height:96,style:{borderRadius:12}},void 0,!1,void 0,this),children:()=>be.jsxDEV("div",{"data-stale":h.stale,children:be.jsxDEV(la,{min:170,children:[be.jsxDEV(ie,{label:u("errors.failures"),value:z(P),hint:j?u("errors.hint-in-window",{window:u(A.windowKey)}):u("errors.hint-latest-loaded",{count:z(P)})},void 0,!1,void 0,this),be.jsxDEV(ie,{label:u("errors.signatures"),title:u("errors.signatures-hint"),value:z(k.groups.length),hint:k.groups[0]?u("errors.signatures-top",{count:z(k.groups[0].count)}):void 0},void 0,!1,void 0,this),be.jsxDEV(ie,{label:u("errors.affected-models"),value:z(k.models.length),hint:k.models[0]?.model},void 0,!1,void 0,this),be.jsxDEV(ie,{label:u("errors.last-failure"),value:k.newest?fa(k.newest.timestamp):"–",hint:k.newest?ln(k.newest.timestamp):u("errors.none-in-window",{window:u(A.windowKey)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),be.jsxDEV("div",{className:"grid grid-main-side",children:[be.jsxDEV(Ye,{index:1,title:u("errors.error-signatures"),description:u("errors.signatures-card-description"),flush:!0,stale:h.stale,children:be.jsxDEV(Ge,{query:h,skeleton:be.jsxDEV(ca,{rows:8},void 0,!1,void 0,this),isEmpty:(ae)=>ae.length===0,empty:be.jsxDEV(wt,{title:u("errors.empty-no-failures",{window:u(A.windowKey)}),hint:u("errors.empty-all-succeeded")},void 0,!1,void 0,this),children:()=>be.jsxDEV(Xt,{rows:k.groups,rowKey:(ae)=>ae.signature,columns:te,onRowClick:(ae)=>b(D===ae.signature?null:ae.signature),selectedKey:D,expanded:(ae)=>ae.signature===D?be.jsxDEV(jM,{group:ae,onRequestClick:c},void 0,!1,void 0,this):null,limit:12},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),be.jsxDEV(Ye,{index:2,title:u("errors.by-model"),description:u("errors.by-model-description"),stale:h.stale,children:be.jsxDEV(Ge,{query:h,skeleton:be.jsxDEV(qa,{height:180},void 0,!1,void 0,this),isEmpty:(ae)=>ae.length===0,empty:be.jsxDEV(wt,{title:u("errors.empty-no-affected-models")},void 0,!1,void 0,this),children:()=>be.jsxDEV(qd,{items:k.models.slice(0,12).map((ae)=>({key:ae.key,label:be.jsxDEV("span",{className:"row",style:{gap:6,minWidth:0},children:[be.jsxDEV("span",{className:"mono truncate",children:ae.model},void 0,!1,void 0,this),be.jsxDEV("span",{className:"dim truncate",children:ae.provider},void 0,!1,void 0,this)]},void 0,!0,void 0,this),value:ae.count,color:ae.key===M?"var(--bad)":"color-mix(in srgb, var(--bad) 45%, transparent)"})),onSelect:(ae)=>g(M===ae?null:ae)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),be.jsxDEV(Ye,{index:3,title:u("errors.failures"),description:h.data===null?u("errors.loading-failures"):u("errors.filtered-of-total",{shown:z(B.length),total:z(P)}),actions:be.jsxDEV(be.Fragment,{children:[D!==null&&be.jsxDEV("button",{type:"button",className:"btn errors-filter","data-size":"sm",onClick:()=>b(null),title:D,children:[be.jsxDEV("span",{className:"mono truncate",children:D},void 0,!1,void 0,this),be.jsxDEV(nn,{size:12},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X&&be.jsxDEV("button",{type:"button",className:"btn errors-filter","data-size":"sm",onClick:()=>g(null),children:[be.jsxDEV("span",{className:"mono truncate",children:X.model},void 0,!1,void 0,this),be.jsxDEV(nn,{size:12},void 0,!1,void 0,this)]},void 0,!0,void 0,this),be.jsxDEV(cr,{value:C,onChange:w,placeholder:u("errors.search-placeholder")},void 0,!1,void 0,this)]},void 0,!0,void 0,this),flush:!0,stale:h.stale,footer:ce,children:be.jsxDEV(Ge,{query:h,skeleton:be.jsxDEV(ca,{rows:10},void 0,!1,void 0,this),isEmpty:(ae)=>ae.length===0,empty:be.jsxDEV(wt,{title:u("errors.empty-no-failures",{window:u(A.windowKey)})},void 0,!1,void 0,this),children:()=>be.jsxDEV(Xt,{rows:B,rowKey:(ae)=>ae.id??`${ae.sessionFile}:${ae.entryId}`,onRowClick:(ae)=>ae.id!==void 0&&c(ae.id),columns:XM,initialSort:{key:"time",dir:"desc"},limit:50,dense:!0,empty:be.jsxDEV(wt,{title:u("errors.no-match"),hint:u("errors.no-match-hint")},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function VM(l){return[{key:"signature",header:u("errors.signature"),wrap:!0,sort:(i)=>i.signature,render:(i)=>be.jsxDEV("span",{className:"errors-signature",title:i.latest.errorMessage??void 0,children:i.signature},void 0,!1,void 0,this)},{key:"models",header:u("common.models"),sort:(i)=>i.models.length,render:(i)=>be.jsxDEV(Ha,{primary:be.jsxDEV("span",{className:"mono",children:i.models[0]?.model},void 0,!1,void 0,this),secondary:i.models.length>1?u("errors.more-models",{count:z(i.models.length-1)}):i.models[0]?.provider},void 0,!1,void 0,this)},{key:"last",header:u("errors.last-seen"),sort:(i)=>i.lastSeen,render:(i)=>be.jsxDEV("span",{className:"muted",title:ln(i.lastSeen),children:fa(i.lastSeen)},void 0,!1,void 0,this)},{key:"count",header:u("errors.failures"),align:"right",width:120,sort:(i)=>i.count,render:(i)=>be.jsxDEV(pa,{value:i.count,max:l,display:z(i.count),color:"var(--bad)"},void 0,!1,void 0,this)}]}function jM({group:l,onRequestClick:i}){let c=l.latest.id;return be.jsxDEV("div",{className:"errors-detail",children:[be.jsxDEV("pre",{className:"code-block errors-detail-message",children:l.latest.errorMessage??u("errors.unknown-error")},void 0,!1,void 0,this),be.jsxDEV("div",{className:"errors-detail-meta",children:[be.jsxDEV("span",{className:"muted",children:u("errors.group-meta",{count:z(l.count),first:ln(l.firstSeen),last:ln(l.lastSeen)})},void 0,!1,void 0,this),c!==void 0&&be.jsxDEV("button",{type:"button",className:"btn","data-size":"sm",onClick:()=>i(c),children:[u("errors.open-latest")," ",be.jsxDEV(fd,{size:13},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),be.jsxDEV("div",{className:"errors-detail-models",children:l.models.map((f)=>be.jsxDEV("span",{className:"badge","data-mono":"true",children:[f.model," ",be.jsxDEV("span",{className:"dim",children:f.provider},void 0,!1,void 0,this)," ",be.jsxDEV("span",{className:"num",children:Ae(f.count)},void 0,!1,void 0,this)]},ba(f.model,f.provider),!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var XM=[{key:"time",header:u("errors.when"),width:120,sort:(l)=>l.timestamp,render:(l)=>be.jsxDEV("span",{className:"muted",title:ln(l.timestamp),children:fa(l.timestamp)},void 0,!1,void 0,this)},{key:"model",header:u("common.model"),sort:(l)=>l.model,render:(l)=>be.jsxDEV(Ha,{primary:be.jsxDEV("span",{className:"mono",children:l.model},void 0,!1,void 0,this),secondary:l.provider},void 0,!1,void 0,this)},{key:"error",header:u("common.error"),sort:(l)=>l.errorMessage??"",render:(l)=>be.jsxDEV("span",{className:"errors-message",title:l.errorMessage??void 0,children:l.errorMessage??u("errors.unknown-error")},void 0,!1,void 0,this)},{key:"project",header:u("common.project"),sort:(l)=>l.folder,render:(l)=>be.jsxDEV("span",{className:"mono muted",title:l.folder,children:fr(l.folder)},void 0,!1,void 0,this)},{key:"tokens",header:u("common.tokens"),align:"right",sort:(l)=>l.usage.totalTokens,render:(l)=>be.jsxDEV("span",{className:"num",children:z(l.usage.totalTokens)},void 0,!1,void 0,this)},{key:"cost",header:u("common.cost"),title:u("errors.cost-hint"),align:"right",sort:(l)=>l.usage.cost.total,render:(l)=>be.jsxDEV("span",{className:"num",children:Yl(l,4)},void 0,!1,void 0,this)}];var Ut=Z(gt(),1);var Q=Z(ue(),1),YM=1000,jm=50,nb=0.5,Pd="*";function sT({active:l,range:i}){let[c,f]=Ut.useState(!1),p=Ft(["frustration",i],({signal:L})=>l1(i,L),{enabled:l,pollMs:c?YM:void 0}),S=ia(i),h=p.data?.job.state;Ut.useEffect(()=>{if(h!==void 0)f(h==="running")},[h]);let{refetch:x}=p,b=Ut.useCallback(()=>{f(!0),x()},[x]);return Q.jsxDEV("div",{className:"page",children:[Q.jsxDEV(ra,{title:u("frustration.title"),description:u("frustration.description",{window:u(S.windowKey)})},void 0,!1,void 0,this),Q.jsxDEV(Ge,{query:p,skeleton:Q.jsxDEV(zt,{height:96},void 0,!1,void 0,this),children:(L)=>Q.jsxDEV("div",{"data-stale":p.stale,children:Q.jsxDEV($M,{overall:L.overall},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),Q.jsxDEV(Ge,{query:p,skeleton:Q.jsxDEV(zt,{height:120},void 0,!1,void 0,this),children:(L)=>Q.jsxDEV(QM,{active:l,range:i,judgeAvailable:L.judgeAvailable,job:L.job,onRunStarted:b,onRunChanged:x},void 0,!1,void 0,this)},void 0,!1,void 0,this),Q.jsxDEV(Ge,{query:p,skeleton:Q.jsxDEV(Ye,{index:2,title:u("frustration.by-model"),children:[Q.jsxDEV(zt,{height:340},void 0,!1,void 0,this),Q.jsxDEV(ca,{rows:6},void 0,!1,void 0,this)]},void 0,!0,void 0,this),children:(L)=>Q.jsxDEV(rD,{models:L.byModel,stale:p.stale},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function In(l,i){return i>0?Fe(l/i):"–"}function ob(l){return l instanceof Error?l.message:String(l)}function uT(l){let i=Math.max(0,Math.floor(l/1000)),c=Math.floor(i/60),f=i%60;return c>0?`${c}m ${String(f).padStart(2,"0")}s`:`${f}s`}function $M({overall:l}){let i=l.messages-l.judged,c=l.unscored>0?u("frustration.coverage-unscored",{count:z(l.unscored)}):"";return Q.jsxDEV(Q.Fragment,{children:[Q.jsxDEV(la,{min:170,children:[Q.jsxDEV(ie,{label:u("frustration.user-messages"),title:u("frustration.user-messages-title"),value:z(l.messages)},void 0,!1,void 0,this),Q.jsxDEV(ie,{label:u("frustration.judge-coverage"),title:u("frustration.judge-coverage-title"),value:In(l.judged,l.messages),hint:`${u("frustration.coverage-hint",{judged:z(l.judged),regex:z(i)})}${c}`},void 0,!1,void 0,this),Q.jsxDEV(ie,{label:u("frustration.annoyed"),title:u("frustration.annoyed-title"),value:In(l.annoyed,l.messages),hint:u("frustration.messages-n",{count:z(l.annoyed)})},void 0,!1,void 0,this),Q.jsxDEV(ie,{label:u("frustration.at-assistant"),title:u("frustration.at-assistant-title"),value:In(l.atAssistant,l.messages),hint:u("frustration.messages-n",{count:z(l.atAssistant)})},void 0,!1,void 0,this),Q.jsxDEV(ie,{label:u("frustration.angry"),title:u("frustration.angry-title"),value:In(l.angry,l.messages),hint:u("frustration.messages-n",{count:z(l.angry)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this),l.unscored>0&&Q.jsxDEV("p",{className:"micro dim",children:u("frustration.unscored-line",{count:z(l.unscored)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var lT="Judging needs the zeta host process: open the dashboard with zeta-c stats and configure a judge model. Until then messages are classified by regex signals.";function QM({active:l,range:i,judgeAvailable:c,job:f,onRunStarted:p,onRunChanged:S}){let[h,x]=Ut.useState(!1),[b,L]=Ut.useState({status:"loading"}),[g,C]=Ut.useState(!1),[w,A]=Ut.useState(null),[k,D]=Ut.useState(!1),[M,B]=Ut.useState(null),P=Ut.useRef(null),j=f.state==="running",Y=Ut.useCallback(()=>{P.current?.abort(),P.current=null,x(!1)},[]);Ut.useEffect(()=>{if(!l)Y()},[l,Y]),Ut.useEffect(()=>()=>P.current?.abort(),[]);let ce=()=>{P.current?.abort();let H=new AbortController;P.current=H;let de=i;L({status:"loading"}),A(null),B(null),x(!0),s1(de,H.signal).then((xe)=>{if(!H.signal.aborted)L({status:"ready",estimate:xe,range:de})},(xe)=>{if(!H.signal.aborted)L({status:"error",message:ob(xe)})})},J=async()=>{if(b.status!=="ready")return;C(!0),A(null);try{await u1(b.range),Y(),p()}catch(H){A(ob(H))}finally{C(!1)}},te=async()=>{D(!0),B(null);try{await i1(),S()}catch(H){B(ob(H))}finally{D(!1)}},X=b.status==="ready"?b.estimate:null,ae=b.status==="loading"?{label:"Proceed",onClick:J,disabled:!0}:X?.available?{label:g?"Starting…":"Proceed",onClick:J,disabled:g||X.messages===0}:void 0;return Q.jsxDEV(Ye,{index:1,title:Q.jsxDEV(Q.Fragment,{children:[u("frustration.judge-panel")," ",Q.jsxDEV(KM,{job:f,judgeAvailable:c},void 0,!1,void 0,this)]},void 0,!0,void 0,this),description:u("frustration.judge-description"),actions:Q.jsxDEV("button",{type:"button",className:"btn","data-variant":"accent","data-size":"sm",onClick:ce,disabled:!c||j,title:!c?lT:j?u("frustration.judge-running"):u("frustration.quote-title"),children:[Q.jsxDEV(lr,{size:13},void 0,!1,void 0,this)," ",u("frustration.classify")]},void 0,!0,void 0,this),children:[Q.jsxDEV("div",{className:"stack frustration-judge",children:[j?Q.jsxDEV(WM,{job:f,cancelling:k,onCancel:te},void 0,!1,void 0,this):Q.jsxDEV(JM,{job:f},void 0,!1,void 0,this),!c&&Q.jsxDEV("p",{className:"micro dim",children:lT},void 0,!1,void 0,this),M&&Q.jsxDEV("p",{className:"micro tone-bad",role:"alert",children:M},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Q.jsxDEV(T1,{open:h,title:u("frustration.classify"),onClose:Y,primaryAction:ae,children:[Q.jsxDEV(ZM,{estimate:b},void 0,!1,void 0,this),w&&Q.jsxDEV("p",{className:"micro tone-bad",role:"alert",children:w},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function KM({job:l,judgeAvailable:i}){switch(l.state){case"running":return Q.jsxDEV(Bt,{tone:"ok",children:[Q.jsxDEV(ur,{tone:"live",pulse:!0},void 0,!1,void 0,this)," ",u("frustration.running")]},void 0,!0,void 0,this);case"done":return Q.jsxDEV(Bt,{tone:"ok",children:u("frustration.last-run-done")},void 0,!1,void 0,this);case"cancelled":return Q.jsxDEV(Bt,{tone:"warn",children:u("frustration.last-run-cancelled")},void 0,!1,void 0,this);case"failed":return Q.jsxDEV(Bt,{tone:"bad",children:u("frustration.last-run-failed")},void 0,!1,void 0,this);case"idle":return Q.jsxDEV(Bt,{children:i?u("frustration.not-run-yet"):u("frustration.regex-only")},void 0,!1,void 0,this)}}function ZM({estimate:l}){if(l.status==="loading")return Q.jsxDEV("p",{className:"muted",children:u("frustration.estimating")},void 0,!1,void 0,this);if(l.status==="error")return Q.jsxDEV("p",{className:"tone-bad",children:l.message},void 0,!1,void 0,this);let i=l.estimate;if(!i.available)return Q.jsxDEV("p",{children:i.reason},void 0,!1,void 0,this);if(i.messages===0)return Q.jsxDEV("p",{children:u("frustration.all-judged")},void 0,!1,void 0,this);return Q.jsxDEV(Q.Fragment,{children:[Q.jsxDEV("div",{className:"frustration-quote",children:[Q.jsxDEV("span",{className:"dim micro",children:u("frustration.estimated-cost")},void 0,!1,void 0,this),Q.jsxDEV("span",{className:"num frustration-quote-value",children:["≈ ",da(i.cost)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Q.jsxDEV(Ho,{items:[{key:"messages",label:u("frustration.unjudged-messages"),value:z(i.messages)},{key:"chars",label:u("frustration.prose-chars"),value:z(i.chars)},{key:"tokens",label:u("frustration.input-tokens"),value:z(i.inputTokens)},{key:"judge",label:u("frustration.judge-model"),value:i.judge}]},void 0,!1,void 0,this),Q.jsxDEV("p",{className:"micro dim",children:u("frustration.estimate-note")},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function WM({job:l,cancelling:i,onCancel:c}){let f=l.done+l.failed,p=l.total>0?Math.min(1,f/l.total):0;return Q.jsxDEV("div",{className:"stack frustration-progress",children:[Q.jsxDEV("div",{className:"row frustration-progress-head",children:[Q.jsxDEV("span",{className:"num",children:[z(l.done),"/",z(l.total)," judged"]},void 0,!0,void 0,this),Q.jsxDEV("span",{className:"num dim",children:Fe(p)},void 0,!1,void 0,this),Q.jsxDEV("span",{className:"frustration-spacer"},void 0,!1,void 0,this),Q.jsxDEV("button",{type:"button",className:"btn","data-variant":"danger","data-size":"sm",onClick:c,disabled:i,children:i?u("frustration.cancelling"):u("frustration.cancel-run")},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Q.jsxDEV("div",{className:"meter frustration-progress-track",role:"progressbar","aria-valuemin":0,"aria-valuemax":l.total,"aria-valuenow":f,children:Q.jsxDEV("div",{className:"meter-fill frustration-progress-fill",style:{width:`${p*100}%`}},void 0,!1,void 0,this)},void 0,!1,void 0,this),Q.jsxDEV("div",{className:"row micro muted frustration-progress-meta",children:[Q.jsxDEV("span",{className:l.failed>0?"tone-bad":void 0,children:u("frustration.failed-n",{count:z(l.failed)})},void 0,!1,void 0,this),Q.jsxDEV("span",{children:[u("frustration.cost-so-far")," ",Q.jsxDEV("span",{className:"num",children:da(l.cost)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),l.judge&&Q.jsxDEV("span",{className:"mono",children:l.judge},void 0,!1,void 0,this),l.startedAt!==null&&Q.jsxDEV("span",{children:u("frustration.elapsed",{time:uT(Date.now()-l.startedAt)})},void 0,!1,void 0,this),l.startedAt!==null&&l.done>0&&Q.jsxDEV("span",{className:"num",children:[(l.done/Math.max(1,(Date.now()-l.startedAt)/1000)).toFixed(0),"/s"]},void 0,!0,void 0,this),l.concurrency>0&&Q.jsxDEV("span",{className:"num",children:u("frustration.in-flight",{count:z(l.concurrency)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function JM({job:l}){let i=u("frustration.messages-progress",{done:z(l.done),total:z(l.total)}),c=l.failed>0?u("frustration.failed-suffix",{count:z(l.failed)}):"",f=l.judge?u("frustration.judge-with",{judge:l.judge}):"",p=l.startedAt!==null&&l.finishedAt!==null?u("frustration.in-time",{time:uT(l.finishedAt-l.startedAt)}):"";switch(l.state){case"idle":return Q.jsxDEV("p",{className:"muted",children:u("frustration.no-run-yet")},void 0,!1,void 0,this);case"running":return null;case"done":return Q.jsxDEV("p",{className:"muted",children:u("frustration.run-done-line",{progress:i,failed:c,judge:f,elapsed:p,cost:da(l.cost)})},void 0,!1,void 0,this);case"cancelled":return Q.jsxDEV("p",{className:"muted",children:u("frustration.run-cancelled-line",{progress:i,failed:c,cost:da(l.cost)})},void 0,!1,void 0,this);case"failed":return Q.jsxDEV("p",{className:"muted",children:u("frustration.run-failed-line",{progress:i,failed:c,error:l.error??u("frustration.unknown-error"),cost:da(l.cost)})},void 0,!1,void 0,this)}}function Hd(l){return`${l.modelClass}/${l.family??"unclassified"}`}function vi(l){return l.messages>0&&l.judged/l.messages<nb}function eD(l){let i=2166136261;for(let c=0;c<l.length;c++)i^=l.charCodeAt(c),i=Math.imul(i,16777619);return i>>>0}function tD(l){let i=[...new Set(l.map(Hd))].sort(),c=new Set,f=new Map;for(let p of i){let S=eD(p)%Fa.length;for(let h=0;h<Fa.length&&c.has(S);h++)S=(S+1)%Fa.length;c.add(S),f.set(p,Fa[S])}return f}function aD(l,i){if(i==="angry")return`color-mix(in srgb, ${l} 55%, black)`;if(i==="other")return`color-mix(in srgb, ${l} 32%, transparent)`;return l}var oD=[{key:"angry",label:"Angry at assistant"},{key:"assistant",label:"At assistant, not angry"},{key:"other",label:"Annoyed at other targets"}];function nD(l,i){if(i==="angry")return l.angry;if(i==="assistant")return l.atAssistant-l.angry;return l.annoyed-l.atAssistant}function _d(l,i){return i>0?l/i*100:0}function rD({models:l,stale:i}){let[c,f]=Ut.useState(null),[p,S]=sn(),[h,x]=Ut.useState(!1),[b,L]=Ut.useState(!1),g=Ut.useMemo(()=>tD(l),[l]),C=Ut.useMemo(()=>{let J=new Map;for(let te of l)J.set(te.modelClass,(J.get(te.modelClass)??0)+te.messages);return J},[l]),w=Ut.useMemo(()=>{let J=null,te=-1;for(let[X,ae]of C)if(ae>te)J=X,te=ae;return J??Pd},[C]),A=c!==null&&(c===Pd||C.has(c))?c:w,k=Ut.useMemo(()=>[{value:Pd,label:"All",title:"Every model class"},...[...C].map(([J,te])=>({value:J,label:J,title:`${z(te)} messages`}))],[C]),D=Ut.useMemo(()=>A===Pd?l:l.filter((J)=>J.modelClass===A),[l,A]),M=Ut.useMemo(()=>{let J=new Map;for(let te of D){let X=Hd(te),ae=J.get(X);if(ae){ae.messages+=te.messages;continue}let H=te.family??"unclassified";J.set(X,{key:X,label:A===Pd?`${te.modelClass} · ${H}`:H,messages:te.messages})}return[...J.values()]},[D,A]),B=Ut.useMemo(()=>D.filter((J)=>!p.has(Hd(J))),[D,p]),P=B.filter((J)=>J.messages<jm).length,j=B.filter(vi).length,Y=Ut.useMemo(()=>B.filter((J)=>(h||J.messages>=jm)&&!(b&&vi(J))),[B,h,b]);if(l.length===0)return Q.jsxDEV(Ye,{index:2,title:u("frustration.by-model"),stale:i,children:Q.jsxDEV(wt,{title:u("frustration.no-messages"),hint:u("frustration.try-longer-range")},void 0,!1,void 0,this)},void 0,!1,void 0,this);let ce=Y.some(vi);return Q.jsxDEV(Q.Fragment,{children:[Q.jsxDEV(Ye,{index:2,title:u("frustration.by-model"),description:u("frustration.by-model-description"),stale:i,children:Q.jsxDEV("div",{className:"stack frustration-chart-body",children:[Q.jsxDEV("div",{className:"frustration-classes",children:Q.jsxDEV(_a,{size:"sm","aria-label":u("frustration.model-class"),options:k,value:A,onChange:f},void 0,!1,void 0,this)},void 0,!1,void 0,this),Q.jsxDEV("div",{className:"row frustration-filters",children:[Q.jsxDEV(Ka,{items:M.map((J)=>({key:J.key,label:J.label,color:g.get(J.key)??Fa[0],value:z(J.messages)})),hidden:p,onToggle:S},void 0,!1,void 0,this),Q.jsxDEV("span",{className:"frustration-spacer"},void 0,!1,void 0,this),Q.jsxDEV("label",{className:"check",title:u("frustration.small-models-title",{count:jm}),children:[Q.jsxDEV("input",{type:"checkbox",checked:h,onChange:(J)=>x(J.target.checked)},void 0,!1,void 0,this),u("frustration.include-small",{count:jm}),P>0?` (${P})`:""]},void 0,!0,void 0,this),Q.jsxDEV("label",{className:"check",title:u("frustration.hide-regex-title",{share:nb*100}),children:[Q.jsxDEV("input",{type:"checkbox",checked:b,onChange:(J)=>L(J.target.checked)},void 0,!1,void 0,this),"Hide mostly regex",j>0?` (${j})`:""]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Q.jsxDEV(lD,{hasRegexRows:ce},void 0,!1,void 0,this),Q.jsxDEV(sD,{rows:Y,familyColors:g},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),Q.jsxDEV(uD,{rows:Y,familyColors:g,stale:i},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function lD({hasRegexRows:l}){return Q.jsxDEV("div",{className:"legend frustration-key",children:[Q.jsxDEV("span",{className:"legend-item",children:[Q.jsxDEV("span",{className:"swatch frustration-key-swatch","data-variant":"angry"},void 0,!1,void 0,this),"Angry at assistant"]},void 0,!0,void 0,this),Q.jsxDEV("span",{className:"legend-item",children:[Q.jsxDEV("span",{className:"swatch frustration-key-swatch","data-variant":"assistant"},void 0,!1,void 0,this),"At assistant"]},void 0,!0,void 0,this),Q.jsxDEV("span",{className:"legend-item",children:[Q.jsxDEV("span",{className:"swatch frustration-key-swatch","data-variant":"other"},void 0,!1,void 0,this),"Annoyed at other targets"]},void 0,!0,void 0,this),Q.jsxDEV("span",{className:"legend-item",children:[Q.jsxDEV("span",{className:"frustration-key-line"},void 0,!1,void 0,this),u("frustration.legend-trend")]},void 0,!0,void 0,this),Q.jsxDEV("span",{className:"legend-item frustration-key-wide",title:u("frustration.hatch-title",{share:nb*100}),children:[Q.jsxDEV("span",{className:"swatch frustration-key-swatch","data-variant":"hatch"},void 0,!1,void 0,this),l?u("frustration.legend-hatched-run"):u("frustration.legend-hatched")]},void 0,!0,void 0,this),Q.jsxDEV("span",{className:"legend-item dim",children:u("frustration.legend-hue")},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function sD({rows:l,familyColors:i}){let c=Ut.useMemo(()=>{let f=new Map;l.forEach((S,h)=>{let x=Hd(S),b=vi(S),L=`${x}|${b?"regex":"judged"}`,g=f.get(L);if(g)g.slots.push(h);else f.set(L,{family:x,regex:b,slots:[h]})});let p=[];for(let S of oD)for(let[h,x]of f){let b=l.map(()=>null);for(let L of x.slots)b[L]=_d(nD(l[L],S.key),l[L].messages);p.push({key:`${S.key}|${h}`,label:S.label,color:aD(i.get(x.family)??Fa[0],S.key),values:b,pattern:x.regex?"hatch":void 0})}return p.push({key:"trend",label:"At assistant (total)",color:"var(--ink-1)",values:l.map((S)=>_d(S.atAssistant,S.messages)),kind:"line",tooltip:!1}),p},[l,i]);if(l.length===0)return Q.jsxDEV("div",{className:"frustration-chart-empty",children:Q.jsxDEV(wt,{title:u("frustration.no-model-match")},void 0,!1,void 0,this)},void 0,!1,void 0,this);return Q.jsxDEV(Tn,{slots:l.length,tickLabel:(f)=>l[f].label,series:c,height:340,format:(f)=>`${f}%`,formatTooltip:(f)=>`${f.toFixed(1)}%`,showTotal:!1,emptyLabel:"No frustrated messages for these models",tooltipExtra:(f)=>{let p=l[f];return Q.jsxDEV("div",{className:"frustration-tooltip-extra",children:[Q.jsxDEV("div",{className:"chart-tooltip-row chart-tooltip-total",children:[Q.jsxDEV("span",{className:"chart-tooltip-label",children:u("frustration.legend-annoyed-any")},void 0,!1,void 0,this),Q.jsxDEV("span",{className:"chart-tooltip-value",children:In(p.annoyed,p.messages)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Q.jsxDEV("div",{className:"micro dim",children:[z(p.messages)," messages · judged ",z(p.judged)," (",In(p.judged,p.messages),")",vi(p)?u("frustration.row-mostly-regex"):""]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}},void 0,!1,void 0,this)}function uD({rows:l,familyColors:i,stale:c}){let f=Ut.useMemo(()=>[{key:"model",header:u("common.model"),sort:(p)=>p.label,render:(p)=>Q.jsxDEV("span",{className:"row",title:p.key,children:[Q.jsxDEV("span",{className:"swatch",style:{background:i.get(Hd(p))??Fa[0]}},void 0,!1,void 0,this),Q.jsxDEV("span",{className:"cell-primary",children:p.label},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},{key:"ids",header:u("frustration.column-model-ids"),wrap:!0,render:(p)=>Q.jsxDEV("span",{className:"mono micro dim",children:p.models.join(", ")},void 0,!1,void 0,this)},{key:"messages",header:u("frustration.column-messages"),align:"right",sort:(p)=>p.messages,render:(p)=>Q.jsxDEV("span",{className:"num",children:z(p.messages)},void 0,!1,void 0,this)},{key:"judged",header:u("frustration.column-judged"),align:"right",sort:(p)=>p.messages>0?p.judged/p.messages:0,render:(p)=>vi(p)?Q.jsxDEV("span",{className:"row frustration-judged",title:u("frustration.mostly-regex"),children:[Q.jsxDEV(Bt,{tone:"warn",children:u("frustration.regex-badge")},void 0,!1,void 0,this),Q.jsxDEV("span",{className:"num dim",children:In(p.judged,p.messages)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):Q.jsxDEV("span",{className:"num",children:In(p.judged,p.messages)},void 0,!1,void 0,this)},{key:"annoyed",header:u("frustration.annoyed"),align:"right",sort:(p)=>_d(p.annoyed,p.messages),render:(p)=>Q.jsxDEV("span",{className:"num",title:u("frustration.messages-n",{count:z(p.annoyed)}),children:In(p.annoyed,p.messages)},void 0,!1,void 0,this)},{key:"atAssistant",header:u("frustration.at-assistant"),align:"right",sort:(p)=>_d(p.atAssistant,p.messages),render:(p)=>Q.jsxDEV("span",{className:"num",title:u("frustration.messages-n",{count:z(p.atAssistant)}),children:In(p.atAssistant,p.messages)},void 0,!1,void 0,this)},{key:"angry",header:u("frustration.angry"),align:"right",sort:(p)=>_d(p.angry,p.messages),render:(p)=>Q.jsxDEV("span",{className:p.angry>0?"num tone-bad":"num",title:u("frustration.messages-n",{count:z(p.angry)}),children:In(p.angry,p.messages)},void 0,!1,void 0,this)}],[i]);return Q.jsxDEV(Ye,{index:3,title:u("frustration.model-versions"),description:u("frustration.table-description"),flush:!0,stale:c,children:Q.jsxDEV(Xt,{rows:l,rowKey:(p)=>p.key,columns:f,dense:!0,empty:Q.jsxDEV(wt,{title:u("frustration.no-model-match")},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}var Fd=Z(gt(),1);var Et=Z(ue(),1),iD=86400000,cD={snapcompact:"Snapcompact"},dD=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",timeZone:"UTC"});function iT({active:l,range:i}){let[c,f]=Fd.useState(null),p=Ft(["gain",i,c],({signal:w})=>d1(i,c,w),{enabled:l}),S=ia(i),h=p.data,x=Fd.useMemo(()=>{let w=(h?.timeSeries??[]).map((B)=>({...B,timestamp:Date.parse(`${B.date}T00:00:00Z`)})),A=_o(i,w.map((B)=>B.timestamp),iD),k=Sa(w,A,(B)=>B.snapcompact),D=0,M=k.map((B)=>D+=B);return{buckets:A,daily:k,cumulative:M}},[h,i]),b=Fd.useMemo(()=>{if(!h)return[];let w=h.overall.savedTokens;return Object.keys(h.bySource).map((A)=>({...h.bySource[A],source:A,share:w>0?h.bySource[A].savedTokens/w:0}))},[h]),L=h?.projects??[],g=c!==null&&!L.includes(c)?[c,...L]:L,C=[{key:"daily",label:u("gain.saved-per-day"),color:"var(--chart-primary)",values:x.daily},{key:"cumulative",label:u("gain.cumulative"),color:"var(--chart-secondary)",values:x.cumulative,kind:"line",axis:"right"}];return Et.jsxDEV("div",{className:"page",children:[Et.jsxDEV(ra,{title:u("gain.title"),description:c?u("gain.description-scoped",{project:c,window:u(S.windowKey)}):u("gain.description",{window:u(S.windowKey)}),actions:g.length>0&&Et.jsxDEV("select",{className:"input","aria-label":u("common.project"),value:c??"",onChange:(w)=>f(w.target.value||null),style:{maxWidth:320},children:[Et.jsxDEV("option",{value:"",children:u("gain.all-projects")},void 0,!1,void 0,this),g.map((w)=>Et.jsxDEV("option",{value:w,children:w},w,!1,void 0,this))]},void 0,!0,void 0,this)},void 0,!1,void 0,this),Et.jsxDEV(Ge,{query:p,skeleton:Et.jsxDEV(zt,{height:96},void 0,!1,void 0,this),isEmpty:(w)=>w.overall.hits===0&&w.timeSeries.length===0,empty:Et.jsxDEV(Ye,{children:Et.jsxDEV(wt,{title:c?u("gain.empty-title-scoped",{project:c,window:u(S.windowKey)}):u("gain.empty-title",{window:u(S.windowKey)}),hint:i==="all"?u("gain.empty-hint-all"):u("gain.empty-hint-longer-range")},void 0,!1,void 0,this)},void 0,!1,void 0,this),children:({overall:w})=>Et.jsxDEV(Et.Fragment,{children:[Et.jsxDEV("div",{"data-stale":p.stale,children:Et.jsxDEV(la,{min:180,children:[Et.jsxDEV(ie,{label:u("gain.saved-tokens"),value:Ae(w.savedTokens),hint:z(w.savedTokens),spark:x.daily},void 0,!1,void 0,this),Et.jsxDEV(ie,{label:u("gain.saved-bytes"),value:Xv(w.savedBytes)},void 0,!1,void 0,this),Et.jsxDEV(ie,{label:u("gain.reduction"),title:u("gain.reduction-title"),value:w.reductionPercent!==null?Fe(w.reductionPercent):"–",hint:w.reductionPercent===null?u("gain.reduction-unknown"):void 0},void 0,!1,void 0,this),Et.jsxDEV(ie,{label:u("gain.hits"),value:z(w.hits)},void 0,!1,void 0,this),Et.jsxDEV(ie,{label:u("gain.saved-per-hit"),value:w.hits>0?Ae(w.savedTokens/w.hits):"–",hint:u("common.tokens")},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),Et.jsxDEV(Ye,{index:1,title:u("gain.savings-over-time"),description:u("gain.savings-over-time-description"),actions:Et.jsxDEV(Ka,{items:C.map((A)=>({key:A.key,label:A.label,color:A.color}))},void 0,!1,void 0,this),stale:p.stale,children:Et.jsxDEV(Tn,{slots:x.buckets.length,tickLabel:(A)=>dD.format(x.buckets[A]),series:C,height:260,formatTooltip:z,formatRight:Ae},void 0,!1,void 0,this)},void 0,!1,void 0,this),Et.jsxDEV(Ye,{index:2,title:u("gain.by-source"),description:u("gain.by-source-description"),flush:!0,stale:p.stale,children:Et.jsxDEV(Xt,{rows:b,rowKey:(A)=>A.source,columns:fD},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var fD=[{key:"source",header:u("gain.source"),sort:(l)=>l.source,render:(l)=>Et.jsxDEV("span",{className:"cell-primary",children:cD[l.source]},void 0,!1,void 0,this)},{key:"tokens",header:u("gain.saved-tokens"),align:"right",sort:(l)=>l.savedTokens,render:(l)=>Et.jsxDEV("span",{title:z(l.savedTokens),children:Et.jsxDEV(pa,{value:l.share,max:1,display:Ae(l.savedTokens)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},{key:"share",header:u("common.share"),align:"right",sort:(l)=>l.share,render:(l)=>Et.jsxDEV("span",{className:"num muted",children:Fe(l.share)},void 0,!1,void 0,this)},{key:"bytes",header:u("gain.saved-bytes"),align:"right",sort:(l)=>l.savedBytes,render:(l)=>Et.jsxDEV("span",{className:"num",children:Xv(l.savedBytes)},void 0,!1,void 0,this)},{key:"hits",header:u("gain.hits"),align:"right",sort:(l)=>l.hits,render:(l)=>Et.jsxDEV("span",{className:"num",children:z(l.hits)},void 0,!1,void 0,this)},{key:"reduction",header:u("gain.reduction"),align:"right",sort:(l)=>l.reductionPercent??-1,render:(l)=>Et.jsxDEV("span",{className:"num",children:l.reductionPercent!==null?Fe(l.reductionPercent):"–"},void 0,!1,void 0,this)}];var bi=Z(gt(),1);var Le=Z(ue(),1),pD=[{value:"share",label:u("common.share")},{value:"requests",label:u("common.requests")}],mD=6;function dT({active:l,range:i}){let c=Ft(["models",i],({signal:D})=>t1(i,D),{enabled:l}),f=ia(i),[p,S]=bi.useState("share"),[h,x]=sn(),[b,L]=bi.useState(null),g=bi.useMemo(()=>c.data?hD(c.data,i):null,[c.data,i]),C=bD(f.bucketMs),w=bi.useMemo(()=>g?yD(g,b,C):[],[g,b,C]),A=(D)=>D.byModel.length===0,k=Le.jsxDEV(wt,{title:u("models.empty-title"),hint:u("models.empty-hint")},void 0,!1,void 0,this);return Le.jsxDEV("div",{className:"page",children:[Le.jsxDEV(ra,{title:u("common.models"),description:u("models.subtitle",{window:u(f.windowKey)})},void 0,!1,void 0,this),Le.jsxDEV(Ge,{query:c,skeleton:Le.jsxDEV(qa,{height:112,style:{borderRadius:12}},void 0,!1,void 0,this),isEmpty:A,empty:k,children:()=>g&&Le.jsxDEV("div",{"data-stale":c.stale,children:Le.jsxDEV(la,{min:200,children:[Le.jsxDEV(ie,{label:u("models.used"),value:z(g.models.length),hint:g.providerCount===1?u("models.across-providers-one",{count:z(g.providerCount)}):u("models.across-providers",{count:z(g.providerCount)})},void 0,!1,void 0,this),Le.jsxDEV(ie,{label:u("models.most-used"),title:g.top?`${g.top.model} (${g.top.provider})`:void 0,value:g.top?g.top.model:"–",hint:g.top?u("models.most-used-hint",{share:Fe(g.top.totalRequests/Math.max(1,g.totalRequests)),provider:g.top.provider}):void 0},void 0,!1,void 0,this),Le.jsxDEV(ie,{label:u("common.requests"),value:z(g.totalRequests),hint:u("models.failed-n",{count:z(g.failedRequests)}),spark:g.requestTotals},void 0,!1,void 0,this),Le.jsxDEV(ie,{label:u("models.api-cost"),title:u("models.api-cost-title"),value:Ht(g.totalCost,g.unpricedRequests),hint:g.unpricedRequests>0?u("models.unpriced-n",{count:z(g.unpricedRequests)}):void 0},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),Le.jsxDEV(Ye,{index:1,title:u("models.request-share"),description:p==="share"?u("models.share-desc",{bucket:C}):u("models.count-desc",{bucket:C}),actions:Le.jsxDEV(_a,{size:"sm",options:pD,value:p,onChange:S,"aria-label":u("models.share-mode-aria")},void 0,!1,void 0,this),stale:c.stale,children:Le.jsxDEV(Ge,{query:c,skeleton:Le.jsxDEV(zt,{height:260},void 0,!1,void 0,this),isEmpty:A,empty:k,children:()=>g&&Le.jsxDEV("div",{className:"stack",style:{gap:12},children:[Le.jsxDEV(Xr,{buckets:g.buckets,bucketMs:f.bucketMs,series:p==="share"?g.shareSeries:g.countSeries,hidden:h,height:260,yMax:p==="share"?1:void 0,format:p==="share"?(D)=>Fe(D,0):Ae,formatTooltip:p==="share"?(D)=>Fe(D):z,showTotal:p==="requests"},void 0,!1,void 0,this),Le.jsxDEV(Ka,{items:g.countSeries.map((D)=>({key:D.key,label:D.label,color:D.color,value:Fe(cT(D.values)/Math.max(1,cT(g.requestTotals)))})),hidden:h,onToggle:x},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),Le.jsxDEV(Ye,{index:2,title:u("models.all-models"),description:u("models.table-desc"),stale:c.stale,flush:!0,children:Le.jsxDEV(Ge,{query:c,skeleton:Le.jsxDEV(ca,{rows:8},void 0,!1,void 0,this),isEmpty:A,empty:k,children:()=>g&&Le.jsxDEV(Xt,{rows:g.models,rowKey:(D)=>ba(D.model,D.provider),columns:w,initialSort:{key:"requests",dir:"desc"},limit:25,onRowClick:(D)=>{let M=ba(D.model,D.provider);L((B)=>B===M?null:M)},selectedKey:b,expanded:(D)=>{let M=ba(D.model,D.provider);return M===b?Le.jsxDEV(vD,{model:D,color:g.swatches.get(M)??"var(--chart-primary)",points:g.performance.get(M)??[],bucketMs:f.bucketMs,bucketWord:C},void 0,!1,void 0,this):null}},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function hD(l,i){let c=l.byModel,f=Vm(c),p=gD(c),S=_o(i,l.modelSeries.map((M)=>M.timestamp)),h=Sa(l.modelSeries,S,(M)=>M.requests),x={buckets:S,key:(M)=>ba(M.model,M.provider),label:(M)=>p.get(M)??M,value:(M)=>M.requests,colors:f},b=hr(l.modelSeries,{...x,limit:mD}).map((M)=>({...M,values:M.values.map((B)=>B||null)})),L=b.map((M)=>({...M,values:M.values.map((B,P)=>B===null?null:B/h[P])})),g=new Map(hr(l.modelSeries,x).map((M)=>[M.key,M.values])),C,w=0,A=0,k=0,D=0;for(let M of c){if(!C||M.totalRequests>C.totalRequests)C=M;w+=M.totalRequests,A+=M.failedRequests,k+=M.totalCost,D+=M.unpricedRequests}return{models:c,top:C,swatches:new Map(b.filter((M)=>M.key!=="__other__").map((M)=>[M.key,M.color])),labels:p,providerCount:new Set(c.map((M)=>M.provider)).size,totalRequests:w,failedRequests:A,totalCost:k,unpricedRequests:D,maxRequests:C?.totalRequests??0,buckets:S,requestTotals:h,countSeries:b,shareSeries:L,trends:g,performance:W1(l.modelPerformanceSeries)}}function gD(l){let i=new Map;for(let c of l)i.set(c.model,(i.get(c.model)??0)+1);return new Map(l.map((c)=>[ba(c.model,c.provider),(i.get(c.model)??0)>1?`${c.model} · ${c.provider}`:c.model]))}function yD(l,i,c){return[{key:"expand",header:"",width:28,render:(f)=>Le.jsxDEV("span",{className:"models-chevron","data-open":ba(f.model,f.provider)===i,children:Le.jsxDEV(Ln,{size:14},void 0,!1,void 0,this)},void 0,!1,void 0,this)},{key:"model",header:u("common.model"),sort:(f)=>f.model,render:(f)=>Le.jsxDEV(Ha,{lead:Le.jsxDEV(Cn,{color:l.swatches.get(ba(f.model,f.provider))??ao},void 0,!1,void 0,this),primary:Le.jsxDEV("span",{className:"mono",children:f.model},void 0,!1,void 0,this),secondary:f.provider},void 0,!1,void 0,this)},{key:"requests",header:u("common.requests"),align:"right",sort:(f)=>f.totalRequests,render:(f)=>Le.jsxDEV(pa,{value:f.totalRequests,max:l.maxRequests,display:z(f.totalRequests),color:l.swatches.get(ba(f.model,f.provider))??ao},void 0,!1,void 0,this)},{key:"cost",header:u("common.cost"),title:u("models.cost-title"),align:"right",sort:(f)=>f.totalCost,render:(f)=>Le.jsxDEV("span",{className:"num",children:Ht(f.totalCost,f.unpricedRequests)},void 0,!1,void 0,this)},{key:"tokens",header:u("common.tokens"),title:u("models.tokens-title"),align:"right",sort:(f)=>Ql(f),render:(f)=>{let p=Ql(f);return Le.jsxDEV("span",{className:"num",title:z(p),children:Ae(p)},void 0,!1,void 0,this)}},{key:"cache",header:u("models.cache-rate"),title:u("models.cache-title"),align:"right",sort:(f)=>f.cacheRate,render:(f)=>Le.jsxDEV("span",{className:"num",children:Fe(f.cacheRate)},void 0,!1,void 0,this)},{key:"errors",header:u("models.errors"),align:"right",sort:(f)=>f.errorRate,render:(f)=>f.failedRequests===0?Le.jsxDEV("span",{className:"num dim",children:"0%"},void 0,!1,void 0,this):Le.jsxDEV("span",{title:u("models.failed-n",{count:z(f.failedRequests)}),children:Le.jsxDEV(Bt,{tone:ir(f.errorRate),mono:!0,children:to(f.errorRate)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},{key:"tps",header:u("common.tokens-per-second"),title:u("models.tps-title"),align:"right",sort:(f)=>f.avgTokensPerSecond??-1,render:(f)=>Le.jsxDEV("span",{className:"num",children:dr(f.avgTokensPerSecond)},void 0,!1,void 0,this)},{key:"ttft",header:u("models.ttft"),title:u("models.ttft-title"),align:"right",sort:(f)=>f.avgTtft??-1,render:(f)=>Le.jsxDEV("span",{className:"num",children:At(f.avgTtft)},void 0,!1,void 0,this)},{key:"trend",header:u("models.trend"),title:u("models.trend-title",{bucket:c}),width:112,render:(f)=>{let p=ba(f.model,f.provider),S=l.trends.get(p);return S?Le.jsxDEV(mi,{values:S.map((h)=>h??0),color:l.swatches.get(p)??ao,width:96,height:22},void 0,!1,void 0,this):Le.jsxDEV("span",{className:"dim",children:"–"},void 0,!1,void 0,this)}}]}function vD({model:l,color:i,points:c,bucketMs:f,bucketWord:p}){let[S,h]=sn(),x=[{key:"tps",label:u("common.tokens-per-second"),color:i,kind:c.length>1?"line":"bars",values:c.map((b)=>b.avgTokensPerSecond)},{key:"ttft",label:u("models.ttft"),color:ao,kind:c.length>1?"line":"bars",axis:"right",dashed:!0,values:c.map((b)=>b.avgTtftSeconds)}];return Le.jsxDEV("div",{className:"models-detail",children:[Le.jsxDEV("div",{className:"models-detail-facts",children:[Le.jsxDEV("div",{children:[Le.jsxDEV("div",{className:"section-label",children:u("models.efficiency")},void 0,!1,void 0,this),Le.jsxDEV(Ho,{items:[{key:"err",label:u("common.error-rate"),value:Le.jsxDEV("span",{className:`tone-${ir(l.errorRate)}`,children:[to(l.errorRate)," ",Le.jsxDEV("span",{className:"dim",children:["(",u("models.failed-n",{count:z(l.failedRequests)}),")"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},{key:"cache",label:u("models.cache-rate"),value:Fe(l.cacheRate)},{key:"savings",label:u("models.cache-savings"),value:Le.jsxDEV("span",{className:l.cacheSavings<0?"tone-bad":void 0,children:Fe(l.cacheSavings)},void 0,!1,void 0,this)},{key:"premium",label:u("common.premium-requests"),value:z(Math.round(l.totalPremiumRequests*100)/100)}]},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Le.jsxDEV("div",{children:[Le.jsxDEV("div",{className:"section-label",children:u("models.latency")},void 0,!1,void 0,this),Le.jsxDEV(Ho,{items:[{key:"dur",label:u("models.avg-duration"),value:At(l.avgDuration)},{key:"ttft",label:u("models.avg-ttft"),value:At(l.avgTtft)},{key:"tps",label:u("common.tokens-per-second"),value:dr(l.avgTokensPerSecond)}]},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Le.jsxDEV("div",{children:[Le.jsxDEV("div",{className:"section-label",children:u("common.tokens")},void 0,!1,void 0,this),Le.jsxDEV(Ho,{items:[{key:"in",label:u("models.uncached-input"),value:Ae(l.totalInputTokens)},{key:"cr",label:u("common.cache-read"),value:Ae(l.totalCacheReadTokens)},{key:"cw",label:u("common.cache-write"),value:Ae(l.totalCacheWriteTokens)},{key:"out",label:u("common.output"),value:Ae(l.totalOutputTokens)}]},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Le.jsxDEV("div",{className:"micro dim",children:u("models.first-last-seen",{first:fa(l.firstTimestamp),last:fa(l.lastTimestamp)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Le.jsxDEV("div",{className:"models-detail-chart",children:[Le.jsxDEV("div",{className:"row",style:{justifyContent:"space-between"},children:[Le.jsxDEV("div",{className:"section-label",style:{marginBottom:0},children:u("models.performance-per-bucket",{bucket:p})},void 0,!1,void 0,this),Le.jsxDEV(Ka,{items:x.map((b)=>({key:b.key,label:b.label,color:b.color})),hidden:S,onToggle:h},void 0,!1,void 0,this)]},void 0,!0,void 0,this),c.length===0?Le.jsxDEV(wt,{title:u("models.no-samples-title"),hint:u("models.no-samples-hint")},void 0,!1,void 0,this):Le.jsxDEV(Xr,{buckets:c.map((b)=>b.timestamp),bucketMs:f,series:x,hidden:S,stacked:!1,height:240,format:Ae,formatTooltip:(b)=>u("models.tok-per-second",{value:dr(b)}),formatRight:(b)=>`${Number(b.toFixed(2))}s`,tooltipExtra:(b)=>Le.jsxDEV("div",{className:"chart-tooltip-row chart-tooltip-total",children:[Le.jsxDEV("span",{className:"chart-tooltip-label",children:u("common.requests")},void 0,!1,void 0,this),Le.jsxDEV("span",{className:"chart-tooltip-value",children:z(c[b].requests)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function bD(l){if(l<3600000)return u("models.bucket-5m");if(l<86400000)return u("models.bucket-hour");return u("models.bucket-day")}function cT(l){let i=0;for(let c of l)i+=c??0;return i}var Xm=Z(gt(),1);var Ie=Z(ue(),1),xD=[{value:"requests",label:u("common.requests")},{value:"tokens",label:u("common.tokens")},{value:"cost",label:u("common.cost")}],fT={main:u("overview.main-agent"),subagent:u("overview.subagents"),advisor:u("overview.advisor")},pT={main:"var(--chart-primary)",subagent:"var(--chart-secondary)",advisor:"#9d7bff"},mT=[{key:"input",label:u("overview.uncached-input"),color:"#5b8cff"},{key:"cacheRead",label:u("common.cache-read"),color:"var(--chart-primary)"},{key:"cacheWrite",label:u("common.cache-write"),color:"#f5b54a"},{key:"output",label:u("common.output"),color:"var(--chart-secondary)"}];function hT({active:l,range:i,onRequestClick:c}){let f=Ft(["overview",i],({signal:g})=>e1(i,g),{enabled:l}),p=Ft(["recent-requests"],({signal:g})=>Mm(12,g),{enabled:l}),[S,h]=Xm.useState("requests"),x=ia(i),b=Xm.useMemo(()=>{let g=f.data?.timeSeries??[],C=_o(i,g.map((w)=>w.timestamp));return{buckets:C,requests:Sa(g,C,(w)=>w.requests-w.errors),errors:Sa(g,C,(w)=>w.errors),tokens:Sa(g,C,(w)=>w.tokens),cost:Sa(g,C,(w)=>w.cost),all:Sa(g,C,(w)=>w.requests)}},[f.data,i]),L=S==="requests"?[{key:"ok",label:u("overview.succeeded"),color:"var(--chart-primary)",values:b.requests},{key:"err",label:u("common.failed"),color:"var(--bad)",values:b.errors}]:S==="tokens"?[{key:"tokens",label:u("common.tokens"),color:"var(--chart-primary)",values:b.tokens}]:[{key:"cost",label:u("overview.api-equivalent"),color:"var(--chart-secondary)",values:b.cost}];return Ie.jsxDEV("div",{className:"page",children:[Ie.jsxDEV(ra,{title:u("overview.title"),description:u("overview.description",{window:u(x.windowKey)})},void 0,!1,void 0,this),Ie.jsxDEV(Ge,{query:f,skeleton:Ie.jsxDEV(zt,{height:112},void 0,!1,void 0,this),children:({overall:g})=>Ie.jsxDEV("div",{"data-stale":f.stale,className:"stack",style:{gap:16},children:[Ie.jsxDEV(la,{min:190,children:[Ie.jsxDEV(ie,{label:u("overview.api-equivalent-cost"),title:u("overview.api-cost-title"),value:Ht(g.totalCost,g.unpricedRequests),hint:g.unpricedRequests>0?u("overview.unpriced-n",{count:z(g.unpricedRequests)}):void 0,spark:b.cost,sparkColor:"var(--chart-secondary)"},void 0,!1,void 0,this),Ie.jsxDEV(ie,{label:u("common.requests"),value:z(g.totalRequests),hint:u("overview.failed-n",{count:z(g.failedRequests)}),spark:b.all},void 0,!1,void 0,this),Ie.jsxDEV(ie,{label:u("overview.conversation-tokens"),title:u("overview.tokens-title"),value:Ae(Ql(g)),hint:u("overview.output-n",{count:Ae(g.totalOutputTokens)}),spark:b.tokens},void 0,!1,void 0,this),Ie.jsxDEV(ie,{label:u("overview.cache-rate"),title:u("overview.cache-rate-title"),value:Fe(g.cacheRate),hint:u("overview.cache-saved",{value:Fe(g.cacheSavings)})},void 0,!1,void 0,this),Ie.jsxDEV(ie,{label:u("common.error-rate"),value:to(g.errorRate),hint:u("overview.succeeded-n",{count:z(g.successfulRequests)}),spark:b.errors,sparkColor:"var(--bad)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Ie.jsxDEV(la,{min:140,children:[Ie.jsxDEV(ie,{size:"sm",label:u("overview.uncached-input"),value:Ae(g.totalInputTokens)},void 0,!1,void 0,this),Ie.jsxDEV(ie,{size:"sm",label:u("common.cache-read"),value:Ae(g.totalCacheReadTokens)},void 0,!1,void 0,this),Ie.jsxDEV(ie,{size:"sm",label:u("common.cache-write"),value:Ae(g.totalCacheWriteTokens)},void 0,!1,void 0,this),Ie.jsxDEV(ie,{size:"sm",label:u("common.output"),value:Ae(g.totalOutputTokens)},void 0,!1,void 0,this),Ie.jsxDEV(ie,{size:"sm",label:u("common.premium-requests"),value:z(Math.round(g.totalPremiumRequests*100)/100)},void 0,!1,void 0,this),Ie.jsxDEV(ie,{size:"sm",label:u("common.tokens-per-second"),value:dr(g.avgTokensPerSecond)},void 0,!1,void 0,this),Ie.jsxDEV(ie,{size:"sm",label:u("overview.avg-latency"),value:At(g.avgDuration)},void 0,!1,void 0,this),Ie.jsxDEV(ie,{size:"sm",label:u("overview.avg-ttft"),value:At(g.avgTtft)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),Ie.jsxDEV("div",{className:"grid grid-main-side",children:[Ie.jsxDEV(Ye,{index:1,title:u("overview.activity"),description:x.bucketMs<3600000?u("overview.per-5m"):x.bucketMs<86400000?u("overview.per-hour"):u("overview.per-day"),actions:Ie.jsxDEV(_a,{size:"sm",options:xD,value:S,onChange:h},void 0,!1,void 0,this),stale:f.stale,children:Ie.jsxDEV(Ge,{query:f,skeleton:Ie.jsxDEV(zt,{height:260},void 0,!1,void 0,this),children:()=>Ie.jsxDEV(Xr,{buckets:b.buckets,bucketMs:x.bucketMs,series:L,height:260,format:S==="cost"?(g)=>Ht(g,0):Ae},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),Ie.jsxDEV(Ye,{index:2,title:u("overview.token-mix"),description:u("overview.token-mix-description"),stale:f.stale,children:Ie.jsxDEV(Ge,{query:f,skeleton:Ie.jsxDEV(zt,{height:260},void 0,!1,void 0,this),children:({overall:g,byAgentType:C})=>{let w={input:g.totalInputTokens,cacheRead:g.totalCacheReadTokens,cacheWrite:g.totalCacheWriteTokens,output:g.totalOutputTokens},A=Ql(g),k=K1(C);return Ie.jsxDEV("div",{className:"stack",style:{gap:18},children:[Ie.jsxDEV("div",{className:"stack",style:{gap:10},children:[Ie.jsxDEV($l,{segments:mT.map((D)=>({key:D.key,label:D.label,value:w[D.key],color:D.color}))},void 0,!1,void 0,this),Ie.jsxDEV(Ka,{items:mT.map((D)=>({key:D.key,label:D.label,color:D.color,value:A>0?Fe(w[D.key]/A,0):"–"}))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Ie.jsxDEV("div",{className:"stack",style:{gap:10},children:[Ie.jsxDEV("div",{className:"section-label",style:{marginBottom:0},children:u("overview.by-agent")},void 0,!1,void 0,this),Ie.jsxDEV($l,{segments:k.segments.map((D)=>({key:D.agentType,label:fT[D.agentType],value:D.tokens,color:pT[D.agentType]}))},void 0,!1,void 0,this),k.segments.map((D)=>Ie.jsxDEV("div",{className:"row",style:{justifyContent:"space-between"},children:[Ie.jsxDEV("span",{className:"row",children:[Ie.jsxDEV("span",{className:"swatch",style:{background:pT[D.agentType]}},void 0,!1,void 0,this),fT[D.agentType],Ie.jsxDEV("span",{className:"dim num",children:u("overview.requests-short",{count:z(D.requests)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Ie.jsxDEV("span",{className:"row",children:[Ie.jsxDEV("span",{className:"dim num",children:Ae(D.tokens)},void 0,!1,void 0,this),Ie.jsxDEV("span",{className:"num",style:{minWidth:48,textAlign:"right"},children:Fe(D.share)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},D.agentType,!0,void 0,this))]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Ie.jsxDEV(Ye,{index:3,title:Ie.jsxDEV(Ie.Fragment,{children:[Ie.jsxDEV(ur,{tone:"live",pulse:!0},void 0,!1,void 0,this)," ",u("overview.latest-requests")]},void 0,!0,void 0,this),description:u("overview.latest-requests-description"),actions:Ie.jsxDEV("a",{className:"btn","data-size":"sm","data-variant":"ghost",href:`#/requests?range=${i}`,children:[u("overview.all-requests")," ",Ie.jsxDEV(dd,{size:13},void 0,!1,void 0,this)]},void 0,!0,void 0,this),flush:!0,children:Ie.jsxDEV(Ge,{query:p,skeleton:Ie.jsxDEV(ca,{rows:8},void 0,!1,void 0,this),children:(g)=>Ie.jsxDEV(Xt,{rows:g,rowKey:(C)=>C.id??`${C.sessionFile}:${C.entryId}`,onRowClick:(C)=>C.id!==void 0&&c(C.id),columns:SD,dense:!0},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var SD=[{key:"model",header:u("common.model"),render:(l)=>Ie.jsxDEV(Ha,{primary:l.model,secondary:l.provider},void 0,!1,void 0,this)},{key:"time",header:u("overview.when"),render:(l)=>Ie.jsxDEV("span",{className:"muted",children:fa(l.timestamp)},void 0,!1,void 0,this)},{key:"tokens",header:u("common.tokens"),align:"right",render:(l)=>Ie.jsxDEV("span",{className:"num",children:z(l.usage.totalTokens)},void 0,!1,void 0,this)},{key:"cost",header:u("common.cost"),align:"right",render:(l)=>Ie.jsxDEV("span",{className:"num",children:Yl(l,4)},void 0,!1,void 0,this)},{key:"duration",header:u("common.duration"),align:"right",render:(l)=>Ie.jsxDEV("span",{className:"num",children:At(l.duration)},void 0,!1,void 0,this)},{key:"status",header:u("overview.status"),align:"right",render:(l)=>l.errorMessage?Ie.jsxDEV(Bt,{tone:"bad",children:u("common.failed")},void 0,!1,void 0,this):Ie.jsxDEV(Bt,{tone:"ok",children:u("overview.ok")},void 0,!1,void 0,this)}];var Rn=Z(gt(),1);var Ve=Z(ue(),1),LD=100,gT=8;function yT({active:l,range:i}){let c=Ft(["projects",i],({signal:D})=>c1(i,D),{enabled:l}),[f,p]=Rn.useState(""),[S,h]=Rn.useState(!0),x=Rn.useDeferredValue(f.trim().toLowerCase()),b=ia(i),L=Rn.useMemo(()=>J1(c.data??[]),[c.data]),g=Rn.useMemo(()=>S?L.rows.filter((D)=>!D.temporary):L.rows,[L,S]),C=Rn.useMemo(()=>x?g.filter((D)=>D.folder.toLowerCase().includes(x)):g,[g,x]),w=Rn.useMemo(()=>({cost:[...g].sort((D,M)=>M.totalCost-D.totalCost).slice(0,gT),requests:[...g].sort((D,M)=>M.totalRequests-D.totalRequests).slice(0,gT)}),[g]),A=Ve.jsxDEV(wt,{title:u(L.rows.length===0?"projects.empty-no-folders":"projects.empty-only-temporary")},void 0,!1,void 0,this),k=Rn.useMemo(()=>CD(L.maxRequests,L.maxCost),[L]);return Ve.jsxDEV("div",{className:"page",children:[Ve.jsxDEV(ra,{title:u("projects.title"),description:u("projects.description",{window:u(b.windowKey)})},void 0,!1,void 0,this),Ve.jsxDEV(Ge,{query:c,skeleton:Ve.jsxDEV(zt,{height:96},void 0,!1,void 0,this),children:()=>Ve.jsxDEV("div",{"data-stale":c.stale,children:Ve.jsxDEV(la,{min:180,children:[Ve.jsxDEV(ie,{label:u("projects.folders"),value:z(L.rows.length),hint:L.temporaryCount>0?u("projects.temporary-n",{count:z(L.temporaryCount)}):void 0},void 0,!1,void 0,this),Ve.jsxDEV(ie,{label:u("common.requests"),value:z(L.totalRequests),hint:u("projects.failed-n",{count:z(L.failedRequests)})},void 0,!1,void 0,this),Ve.jsxDEV(ie,{label:u("projects.api-equivalent-cost"),title:u("projects.api-equivalent-cost-hint"),value:Ht(L.totalCost,L.unpricedRequests),hint:L.unpricedRequests>0?u("projects.unpriced-n",{count:z(L.unpricedRequests)}):void 0},void 0,!1,void 0,this),Ve.jsxDEV(ie,{label:u("projects.conversation-tokens"),title:u("projects.conversation-tokens-hint"),value:Ae(L.conversationTokens)},void 0,!1,void 0,this),Ve.jsxDEV(ie,{label:u("projects.cache-rate"),title:u("projects.cache-rate-hint-all"),value:Fe(L.cacheRate)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),Ve.jsxDEV("div",{className:"grid grid-2",children:[Ve.jsxDEV(Ye,{index:1,title:u("projects.top-by-cost"),description:u("projects.top-by-cost-description"),stale:c.stale,children:Ve.jsxDEV(Ge,{query:c,skeleton:Ve.jsxDEV(zt,{height:236},void 0,!1,void 0,this),isEmpty:()=>w.cost.length===0,empty:A,children:()=>Ve.jsxDEV(qd,{items:w.cost.map((D)=>({key:D.folder,label:Ve.jsxDEV("span",{className:"mono",children:fr(D.folder)},void 0,!1,void 0,this),value:D.totalCost,display:`${Ht(D.totalCost,D.unpricedRequests)} · ${Fe(D.costShare)}`,color:"var(--chart-secondary)"})),onSelect:p},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),Ve.jsxDEV(Ye,{index:2,title:u("projects.top-by-requests"),description:u("projects.top-by-requests-description"),stale:c.stale,children:Ve.jsxDEV(Ge,{query:c,skeleton:Ve.jsxDEV(zt,{height:236},void 0,!1,void 0,this),isEmpty:()=>w.requests.length===0,empty:A,children:()=>Ve.jsxDEV(qd,{items:w.requests.map((D)=>({key:D.folder,label:Ve.jsxDEV("span",{className:"mono",children:fr(D.folder)},void 0,!1,void 0,this),value:D.totalRequests,display:`${z(D.totalRequests)} · ${Fe(D.requestShare)}`})),onSelect:p},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Ve.jsxDEV(Ye,{index:3,title:u("projects.folders"),description:c.data?C.length===L.rows.length?u("projects.folders-n",{count:z(L.rows.length)}):u("projects.folders-of-n",{count:z(C.length),total:z(L.rows.length)}):void 0,actions:Ve.jsxDEV(Ve.Fragment,{children:[L.temporaryCount>0&&Ve.jsxDEV("label",{className:"check",title:u("projects.hide-temporary-hint"),children:[Ve.jsxDEV("input",{type:"checkbox",checked:S,onChange:(D)=>h(D.target.checked)},void 0,!1,void 0,this),u("projects.hide-temporary",{count:z(L.temporaryCount)})]},void 0,!0,void 0,this),Ve.jsxDEV(cr,{value:f,onChange:p,placeholder:u("projects.filter-placeholder"),width:240},void 0,!1,void 0,this)]},void 0,!0,void 0,this),flush:!0,stale:c.stale,children:Ve.jsxDEV(Ge,{query:c,skeleton:Ve.jsxDEV(ca,{rows:10},void 0,!1,void 0,this),children:()=>Ve.jsxDEV(Xt,{rows:C,rowKey:(D)=>D.folder,columns:k,initialSort:{key:"cost",dir:"desc"},limit:LD,dense:!0,empty:Ve.jsxDEV(wt,{title:u(L.rows.length===0?"projects.empty-no-folders":"projects.empty-no-match"),hint:L.rows.length===0?u("projects.hint-longer-range"):S&&L.temporaryCount>0?u("projects.hint-temporary-hidden"):void 0},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function CD(l,i){return[{key:"folder",header:u("projects.folder"),sort:(c)=>c.folder,render:(c)=>Ve.jsxDEV("span",{className:"row projects-folder",title:c.folder||u("common.root"),children:[Ve.jsxDEV("span",{className:"mono truncate",children:fr(c.folder)},void 0,!1,void 0,this),c.temporary&&Ve.jsxDEV(Bt,{children:u("projects.temp")},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},{key:"requests",header:u("common.requests"),align:"right",sort:(c)=>c.totalRequests,render:(c)=>Ve.jsxDEV("span",{title:u("projects.share-of-requests",{share:Fe(c.requestShare)}),children:Ve.jsxDEV(pa,{value:c.totalRequests,max:l,display:z(c.totalRequests)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},{key:"cost",header:u("common.cost"),title:u("projects.api-equivalent-cost-rates"),align:"right",sort:(c)=>c.totalCost,render:(c)=>Ve.jsxDEV("span",{title:u("projects.share-of-cost",{share:Fe(c.costShare)}),children:Ve.jsxDEV(pa,{value:c.totalCost,max:i,display:Ht(c.totalCost,c.unpricedRequests),color:"var(--chart-secondary)"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},{key:"tokens",header:u("common.tokens"),title:u("projects.conversation-tokens-hint"),align:"right",sort:(c)=>c.conversationTokens,render:(c)=>Ve.jsxDEV("span",{className:"num",title:z(c.conversationTokens),children:Ae(c.conversationTokens)},void 0,!1,void 0,this)},{key:"cacheRate",header:u("projects.cache-rate"),title:u("projects.cache-rate-hint"),align:"right",sort:(c)=>c.cacheRate,render:(c)=>Ve.jsxDEV("span",{className:"num",children:Fe(c.cacheRate)},void 0,!1,void 0,this)},{key:"cacheSavings",header:u("projects.cache-savings"),title:u("projects.cache-savings-hint"),align:"right",sort:(c)=>c.cacheSavings,render:(c)=>Ve.jsxDEV("span",{className:`num ${c.cacheSavings<0?"tone-bad":"muted"}`,children:Fe(c.cacheSavings)},void 0,!1,void 0,this)},{key:"errorRate",header:u("projects.errors"),align:"right",sort:(c)=>c.errorRate,render:(c)=>Ve.jsxDEV("span",{title:u("projects.failed-n",{count:z(c.failedRequests)}),children:Ve.jsxDEV(Bt,{tone:c.failedRequests>0?ir(c.errorRate):"neutral",mono:!0,children:to(c.errorRate)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},{key:"duration",header:u("projects.avg-duration"),align:"right",sort:(c)=>c.avgDuration??-1,render:(c)=>Ve.jsxDEV("span",{className:"num",children:At(c.avgDuration)},void 0,!1,void 0,this)},{key:"last",header:u("projects.last-active"),align:"right",sort:(c)=>c.lastTimestamp,render:(c)=>Ve.jsxDEV("span",{className:"dim",children:fa(c.lastTimestamp)},void 0,!1,void 0,this)}]}var po=Z(gt(),1);var ee=Z(ue(),1),wD=[{value:"tokens",label:u("common.tokens")},{value:"cost",label:u("common.cost"),title:u("providers.cost-title")},{value:"requests",label:u("common.requests")}],vT=6,bT=[{key:"input",label:u("ui.uncached-input"),color:"#5b8cff"},{key:"cacheRead",label:u("common.cache-read"),color:"var(--chart-primary)"},{key:"cacheWrite",label:u("common.cache-write"),color:"#f5b54a"},{key:"output",label:u("common.output"),color:"var(--chart-secondary)"}],xT=u("providers.snapshot-hint");function ST({active:l,range:i}){let c=Ft(["providers",i],({signal:P})=>p1(i,P),{enabled:l}),[f,p]=po.useState("tokens"),[S,h]=sn(),x=ia(i),b=Ft(["provider-windows",i],({signal:P})=>Pv(i,null,P),{enabled:l}),[L,g]=po.useState(null),C=kD(b.data?.windowInsights??[],L),w=C?.provider??null,A=Ft(["provider-windows",i,w],({signal:P})=>Pv(i,w,P),{enabled:l&&w!==null}),k=po.useMemo(()=>{let P=c.data?.providers??[],j=c.data?.series??[],Y=Nd(P.map((X)=>({key:X.provider,weight:X.totalTokens}))),ce=_o(i,j.map((X)=>X.timestamp)),J={requests:0,failed:0,tokens:0,cost:0,unpriced:0};for(let X of P)J.requests+=X.totalRequests,J.failed+=X.failedRequests,J.tokens+=X.totalTokens,J.cost+=X.totalCost,J.unpriced+=X.unpricedRequests;let te=(X)=>hr(j,{buckets:ce,key:(ae)=>ae.provider,value:X,limit:vT,colors:Y}).map((ae)=>({...ae,values:ae.values.map((H)=>H||null)}));return{colors:Y,buckets:ce,totals:J,burn:{tokens:te((X)=>X.totalTokens),cost:te((X)=>X.cost),requests:te((X)=>X.requests)},spark:{tokens:Sa(j,ce,(X)=>X.totalTokens),cost:Sa(j,ce,(X)=>X.cost),requests:Sa(j,ce,(X)=>X.requests)},topProvider:P.reduce((X,ae)=>X===null||ae.totalTokens>X.totalTokens?ae:X,null)}},[c.data,i]),D=k.burn[f],M=f==="cost"?(P)=>da(P):Ae,B=k.totals;return ee.jsxDEV("div",{className:"page",children:[ee.jsxDEV(ra,{title:u("common.providers"),description:u("providers.description",{window:u(x.windowKey)})},void 0,!1,void 0,this),ee.jsxDEV(Ge,{query:c,skeleton:ee.jsxDEV(zt,{height:112},void 0,!1,void 0,this),children:({providers:P})=>ee.jsxDEV("div",{"data-stale":c.stale,children:ee.jsxDEV(la,{min:190,children:[ee.jsxDEV(ie,{label:u("common.providers"),value:z(P.length),hint:k.topProvider?u("providers.most-tokens",{provider:k.topProvider.provider}):void 0},void 0,!1,void 0,this),ee.jsxDEV(ie,{label:u("common.requests"),value:z(B.requests),hint:u("providers.failed-n",{count:z(B.failed)}),spark:k.spark.requests},void 0,!1,void 0,this),ee.jsxDEV(ie,{label:u("common.tokens"),title:u("providers.tokens-title"),value:Ae(B.tokens),spark:k.spark.tokens},void 0,!1,void 0,this),ee.jsxDEV(ie,{label:u("providers.api-equivalent-cost"),title:u("providers.api-cost-title"),value:Ht(B.cost,B.unpriced),hint:B.unpriced>0?u("providers.unpriced-n",{count:z(B.unpriced)}):void 0,spark:k.spark.cost,sparkColor:"var(--chart-secondary)"},void 0,!1,void 0,this),ee.jsxDEV(ie,{label:u("common.error-rate"),value:to(B.requests>0?B.failed/B.requests:0),hint:u("providers.succeeded-n",{count:z(B.requests-B.failed)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),ee.jsxDEV(Ye,{index:1,title:u("providers.totals"),description:B.unpriced>0?u(B.unpriced===1?"providers.totals-description-unpriced-one":"providers.totals-description-unpriced-n",{count:z(B.unpriced)}):u("providers.totals-description"),flush:!0,stale:c.stale,children:ee.jsxDEV(Ge,{query:c,skeleton:ee.jsxDEV(ca,{rows:6},void 0,!1,void 0,this),children:({providers:P})=>ee.jsxDEV(TD,{providers:P,colors:k.colors},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),ee.jsxDEV("div",{className:"grid grid-main-side",children:[ee.jsxDEV(Ye,{index:2,title:u("providers.burn"),description:f==="cost"&&B.unpriced>0?u("providers.burn-estimate-description",{bucket:x.bucketMs<86400000?u("providers.bucket-hour"):u("providers.bucket-day")}):u("providers.burn-description",{bucket:x.bucketMs<3600000?u("providers.bucket-5m"):x.bucketMs<86400000?u("providers.bucket-hour"):u("providers.bucket-day"),count:vT}),actions:ee.jsxDEV(_a,{size:"sm",options:wD,value:f,onChange:p},void 0,!1,void 0,this),stale:c.stale,children:ee.jsxDEV(Ge,{query:c,skeleton:ee.jsxDEV(zt,{height:260},void 0,!1,void 0,this),children:()=>ee.jsxDEV("div",{className:"stack",style:{gap:12},children:[ee.jsxDEV(Xr,{buckets:k.buckets,bucketMs:x.bucketMs,series:D,hidden:S,height:260,format:M,formatTooltip:f==="cost"?(P)=>da(P):z,emptyLabel:u("providers.no-provider-activity")},void 0,!1,void 0,this),ee.jsxDEV(Ka,{items:D.map((P)=>({key:P.key,label:P.label,color:P.color,value:M(P.values.reduce((j,Y)=>j+(Y??0),0))})),hidden:S,onToggle:h},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),ee.jsxDEV(Ge,{query:c,skeleton:ee.jsxDEV(zt,{height:320},void 0,!1,void 0,this),children:({hourly:P,providers:j})=>ee.jsxDEV(RD,{hourly:P,providers:j,stale:c.stale},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ee.jsxDEV(Ye,{index:4,title:u("providers.subscription-windows"),description:u("providers.subscription-windows-description"),flush:!0,stale:b.stale,children:ee.jsxDEV(Ge,{query:b,skeleton:ee.jsxDEV(ca,{rows:6},void 0,!1,void 0,this),children:(P)=>ee.jsxDEV(AD,{insights:P.windowInsights,selected:C,onSelect:g},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),ee.jsxDEV(qD,{insights:b.data?.windowInsights??null,accounts:A,selected:C,onSelect:g},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function kD(l,i){if(i&&l.some((f)=>f.provider===i.provider&&f.windowKey===i.windowKey))return i;let c=i&&l.find((f)=>f.provider===i.provider)||l.reduce((f,p)=>f===void 0||p.fractionConsumed>f.fractionConsumed?p:f,void 0);return c?{provider:c.provider,windowKey:c.windowKey}:null}function TD({providers:l,colors:i}){let[c,f]=po.useState(null),p=po.useMemo(()=>{let S=0,h=0,x=0;for(let b of l)S=Math.max(S,b.totalRequests),h=Math.max(h,b.totalTokens),x+=b.totalTokens;return[{key:"provider",header:u("common.provider"),sort:(b)=>b.provider,render:(b)=>ee.jsxDEV("span",{className:"row",style:{gap:8},children:[ee.jsxDEV(Cn,{color:i.get(b.provider)??ao},void 0,!1,void 0,this),ee.jsxDEV("span",{className:"mono cell-primary",children:b.provider},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},{key:"requests",header:u("common.requests"),align:"right",sort:(b)=>b.totalRequests,render:(b)=>ee.jsxDEV(pa,{value:b.totalRequests,max:S,display:z(b.totalRequests)},void 0,!1,void 0,this)},{key:"errors",header:u("common.error-rate"),align:"right",sort:(b)=>b.totalRequests>0?b.failedRequests/b.totalRequests:0,render:(b)=>{let L=b.totalRequests>0?b.failedRequests/b.totalRequests:0;return ee.jsxDEV("span",{className:"row",style:{gap:8,justifyContent:"flex-end"},children:[ee.jsxDEV("span",{className:"num dim",children:z(b.failedRequests)},void 0,!1,void 0,this),ee.jsxDEV(Bt,{tone:b.failedRequests>0?ir(L):"neutral",mono:!0,children:to(L)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}},{key:"models",header:u("common.models"),title:u("providers.models-title"),align:"right",sort:(b)=>b.models,render:(b)=>ee.jsxDEV("span",{className:"num",children:z(b.models)},void 0,!1,void 0,this)},{key:"tokens",header:u("common.tokens"),title:u("providers.tokens-title"),align:"right",sort:(b)=>b.totalTokens,render:(b)=>ee.jsxDEV(pa,{value:b.totalTokens,max:h,display:Ae(b.totalTokens),color:i.get(b.provider)},void 0,!1,void 0,this)},{key:"share",header:u("common.share"),title:u("providers.share-title"),align:"right",sort:(b)=>b.totalTokens,render:(b)=>ee.jsxDEV("span",{className:"num muted",children:Fe(x>0?b.totalTokens/x:0)},void 0,!1,void 0,this)},{key:"cost",header:u("common.cost"),title:u("providers.cost-title"),align:"right",sort:(b)=>b.totalCost,render:(b)=>ee.jsxDEV("span",{className:"num",title:b.unpricedRequests>0?u("providers.unpriced-n",{count:z(b.unpricedRequests)}):void 0,children:Ht(b.totalCost,b.unpricedRequests)},void 0,!1,void 0,this)},{key:"tps",header:u("common.tokens-per-second"),title:u("providers.tps-title"),align:"right",sort:(b)=>b.avgTokensPerSecond??-1,render:(b)=>ee.jsxDEV("span",{className:"num",children:dr(b.avgTokensPerSecond)},void 0,!1,void 0,this)},{key:"premium",header:u("common.premium"),title:u("providers.premium-title"),align:"right",sort:(b)=>b.totalPremiumRequests,render:(b)=>ee.jsxDEV("span",{className:b.totalPremiumRequests>0?"num":"num dim",children:z(Math.round(b.totalPremiumRequests*100)/100)},void 0,!1,void 0,this)}]},[l,i]);return ee.jsxDEV(Xt,{rows:l,rowKey:(S)=>S.provider,columns:p,initialSort:{key:"tokens",dir:"desc"},limit:12,selectedKey:c,onRowClick:(S)=>f((h)=>h===S.provider?null:S.provider),expanded:(S)=>S.provider===c?ee.jsxDEV(ID,{provider:S},void 0,!1,void 0,this):null,empty:ee.jsxDEV(wt,{title:u("providers.no-requests-in-range")},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function ID({provider:l}){let i={input:l.totalInputTokens,cacheRead:l.totalCacheReadTokens,cacheWrite:l.totalCacheWriteTokens,output:l.totalOutputTokens};return ee.jsxDEV("div",{className:"providers-mix",children:[ee.jsxDEV($l,{segments:bT.map((c)=>({key:c.key,label:c.label,value:i[c.key],color:c.color}))},void 0,!1,void 0,this),ee.jsxDEV(Ka,{items:bT.map((c)=>({key:c.key,label:c.label,color:c.color,value:`${Ae(i[c.key])} · ${l.totalTokens>0?Fe(i[c.key]/l.totalTokens,0):"–"}`}))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var Gd="";function RD({hourly:l,providers:i,stale:c}){let[f,p]=po.useState(Gd),S=f===Gd||i.some((b)=>b.provider===f)?f:Gd,h=po.useMemo(()=>{let b=Array.from({length:24},()=>0),L=Array.from({length:24},()=>0),g=Array.from({length:24},()=>0);for(let k of l){if(S!==Gd&&k.provider!==S)continue;b[k.hour]+=k.totalTokens,L[k.hour]+=k.outputTokens,g[k.hour]+=k.requests}let C=0;for(let k=1;k<24;k++)if(b[k]>b[C])C=k;let w=b[C]>0;return{series:[{key:"tokens",label:u("common.tokens"),color:"var(--chart-primary)",values:b.map((k,D)=>w&&D===C?null:k)},{key:"peak",label:u("providers.tokens-peak-hour"),color:"var(--chart-secondary)",values:b.map((k,D)=>w&&D===C?k:null)}],output:L,requests:g,peak:C,hasData:w}},[l,S]),x=(b)=>`${String(b).padStart(2,"0")}:00`;return ee.jsxDEV(Ye,{index:3,title:u("providers.peak-burn-hours"),description:h.hasData?u("providers.peak-hours-description",{hour:x(h.peak)}):u("providers.hours-description"),actions:ee.jsxDEV("select",{className:"input providers-select",value:S,onChange:(b)=>p(b.target.value),"aria-label":u("common.provider"),children:[ee.jsxDEV("option",{value:Gd,children:u("providers.all-providers")},void 0,!1,void 0,this),i.map((b)=>ee.jsxDEV("option",{value:b.provider,children:b.provider},b.provider,!1,void 0,this))]},void 0,!0,void 0,this),stale:c,children:ee.jsxDEV(Tn,{slots:24,tickLabel:(b)=>String(b).padStart(2,"0"),tooltipTitle:(b)=>`${x(b)}–${x((b+1)%24)}`,series:h.series,height:260,showTotal:!1,formatTooltip:z,emptyLabel:u("providers.no-activity-in-range"),tooltipExtra:(b)=>ee.jsxDEV(ee.Fragment,{children:[ee.jsxDEV("div",{className:"chart-tooltip-row",children:[ee.jsxDEV("span",{className:"chart-tooltip-label",children:u("common.output")},void 0,!1,void 0,this),ee.jsxDEV("span",{className:"chart-tooltip-value",children:z(h.output[b])},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ee.jsxDEV("div",{className:"chart-tooltip-row",children:[ee.jsxDEV("span",{className:"chart-tooltip-label",children:u("common.requests")},void 0,!1,void 0,this),ee.jsxDEV("span",{className:"chart-tooltip-value",children:z(h.requests[b])},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function AD({insights:l,selected:i,onSelect:c}){return ee.jsxDEV(Xt,{rows:l,rowKey:(f)=>`${f.provider}::${f.windowKey}`,columns:MD,initialSort:{key:"consumed",dir:"desc"},limit:12,selectedKey:i?`${i.provider}::${i.windowKey}`:null,onRowClick:(f)=>c({provider:f.provider,windowKey:f.windowKey}),empty:ee.jsxDEV(wt,{title:u("providers.no-snapshots-in-range"),hint:xT},void 0,!1,void 0,this)},void 0,!1,void 0,this)}var MD=[{key:"window",header:u("providers.window"),sort:(l)=>`${l.provider} ${l.windowKey}`,render:(l)=>ee.jsxDEV(Ha,{primary:l.windowKey,secondary:ee.jsxDEV("span",{className:"mono",children:l.provider},void 0,!1,void 0,this)},void 0,!1,void 0,this)},{key:"accounts",header:u("providers.accounts"),title:u("providers.accounts-title"),align:"right",sort:(l)=>l.accounts,render:(l)=>ee.jsxDEV("span",{className:"num",children:z(l.accounts)},void 0,!1,void 0,this)},{key:"cycles",header:u("providers.resets"),title:u("providers.resets-title"),align:"right",sort:(l)=>l.cycles,render:(l)=>ee.jsxDEV("span",{className:"num muted",children:z(l.cycles)},void 0,!1,void 0,this)},{key:"consumed",header:u("providers.windows-burned"),title:u("providers.windows-burned-title"),align:"right",sort:(l)=>l.fractionConsumed,render:(l)=>ee.jsxDEV("span",{className:"num",children:l.fractionConsumed.toFixed(2)},void 0,!1,void 0,this)},{key:"capacity",header:u("providers.tokens-per-window"),title:u("providers.tokens-per-window-title"),align:"right",sort:(l)=>l.estTokensPerWindow??-1,render:(l)=>l.estTokensPerWindow!==null?ee.jsxDEV("span",{className:"num",children:Ae(l.estTokensPerWindow)},void 0,!1,void 0,this):ee.jsxDEV("span",{className:"dim",title:u("providers.too-little-consumed"),children:"–"},void 0,!1,void 0,this)},{key:"peak",header:u("providers.peak-utilization"),title:u("providers.peak-utilization-title"),align:"right",sort:(l)=>l.peakConcurrentFraction,render:(l)=>{let i=l.accounts>0?l.peakConcurrentFraction/l.accounts:0;return ee.jsxDEV(pa,{value:l.peakConcurrentFraction,max:l.accounts,display:Fe(l.peakConcurrentFraction,0),color:i>=0.9?"var(--warn)":void 0},void 0,!1,void 0,this)}},{key:"ideal",header:u("providers.accounts-needed"),title:u("providers.accounts-needed-title"),align:"right",sort:(l)=>l.idealAccounts-l.accounts,render:(l)=>l.idealAccounts>l.accounts?ee.jsxDEV(Bt,{tone:"warn",mono:!0,children:u("providers.ideal-accounts",{ideal:z(l.idealAccounts),have:z(l.accounts)})},void 0,!1,void 0,this):ee.jsxDEV("span",{className:"num",children:z(l.idealAccounts)},void 0,!1,void 0,this)},{key:"exhausted",header:u("providers.exhaustions"),title:u("providers.exhaustions-title"),align:"right",sort:(l)=>l.exhaustedEvents,render:(l)=>l.exhaustedEvents>0?ee.jsxDEV(Bt,{tone:"warn",mono:!0,children:u("providers.exhausted-n",{count:z(l.exhaustedEvents)})},void 0,!1,void 0,this):ee.jsxDEV("span",{className:"num dim",children:"0"},void 0,!1,void 0,this)}],Ym=60000,Qr=60*Ym,$m=24*Qr,DD=[5*Ym,15*Ym,30*Ym,Qr,2*Qr,3*Qr,6*Qr,12*Qr,$m],ED=240,OD=6*Qr;function qD({insights:l,accounts:i,selected:c,onSelect:f}){let[p,S]=sn(),h=po.useMemo(()=>[...new Set((l??[]).map((k)=>k.provider))],[l]),x=po.useMemo(()=>(l??[]).filter((k)=>k.provider===c?.provider).map((k)=>({key:k.windowKey,label:k.windowKey})),[l,c?.provider]),b=po.useMemo(()=>(i.data?.usageSeries??[]).filter((k)=>k.provider===c?.provider),[i.data,c?.provider]),L=b.length===0&&(i.loading||i.stale),g=po.useMemo(()=>{let k=new Map;for(let M of b){let B=k.get(M.accountLabel)??[];if(!B.includes(M.accountKey))B.push(M.accountKey);k.set(M.accountLabel,B)}let D=new Map;for(let[M,B]of k)B.sort(),B.forEach((P,j)=>D.set(P,B.length>1?`${M} #${j+1}`:M));return D},[b]),C=po.useMemo(()=>ND(b.filter((k)=>k.windowKey===c?.windowKey),g),[b,g,c?.windowKey]),w=po.useMemo(()=>{let k=new Map(C.series.map((D)=>[D.key,D.color]));return b.map((D)=>{let M=null,B=null;for(let Y of D.points){if(Y.usedFraction===null)continue;if(B=Math.max(B??0,Y.usedFraction),!M||Y.timestamp>=M.timestamp)M={fraction:Y.usedFraction,exhausted:Y.exhausted,timestamp:Y.timestamp}}let P=D.windowKey===c?.windowKey?k.get(D.accountKey)??null:null,j=g.get(D.accountKey)??D.accountLabel;return{series:D,name:j,color:P,latest:M,peak:B,samples:D.points.length}}).sort((D,M)=>Number(M.color!==null)-Number(D.color!==null)||D.series.windowKey.localeCompare(M.series.windowKey)||(M.latest?.fraction??-1)-(D.latest?.fraction??-1))},[b,g,C.series,c?.windowKey]),A=x.find((k)=>k.key===c?.windowKey)?.label;return ee.jsxDEV(Ye,{index:5,title:u("providers.utilization"),description:C.buckets.length>0?u("providers.utilization-description",{window:A??u("providers.window"),from:jv(C.first),to:jv(C.last)}):u("providers.utilization-description-plain"),actions:c&&ee.jsxDEV("div",{className:"row",style:{gap:6},children:[ee.jsxDEV("select",{className:"input providers-select",value:c.provider,onChange:(k)=>{let D=k.target.value,M=l?.find((B)=>B.provider===D);if(M)f({provider:D,windowKey:M.windowKey})},"aria-label":u("common.provider"),children:h.map((k)=>ee.jsxDEV("option",{value:k,children:k},k,!1,void 0,this))},void 0,!1,void 0,this),ee.jsxDEV("select",{className:"input providers-select",value:c.windowKey,onChange:(k)=>f({provider:c.provider,windowKey:k.target.value}),"aria-label":u("providers.window"),children:x.map((k)=>ee.jsxDEV("option",{value:k.key,children:k.label},k.key,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),stale:i.stale,children:l===null?ee.jsxDEV(zt,{height:260},void 0,!1,void 0,this):c===null?ee.jsxDEV(wt,{title:u("providers.no-snapshots-in-range"),hint:xT},void 0,!1,void 0,this):ee.jsxDEV(Ge,{query:i,skeleton:ee.jsxDEV(zt,{height:260},void 0,!1,void 0,this),children:()=>L?ee.jsxDEV(zt,{height:260},void 0,!1,void 0,this):ee.jsxDEV("div",{className:"stack",style:{gap:16},children:[ee.jsxDEV("div",{className:"stack",style:{gap:12},children:[ee.jsxDEV(Tn,{slots:C.buckets.length,tickLabel:(k)=>Am(C.buckets[k],C.last-C.first>$m?$m:C.bucketMs),tooltipTitle:(k)=>Rm(C.buckets[k],Qr),series:C.series,hidden:p,kind:"line",stacked:!1,height:260,yMax:Math.max(1,C.max),format:(k)=>Fe(k,0),formatTooltip:(k)=>Fe(k,1),references:[{value:1,label:"100%"}],emptyLabel:u("providers.no-utilization-readings"),tooltipExtra:(k)=>{let D=C.exhausted[k];return D.length>0?ee.jsxDEV("div",{className:"chart-tooltip-row",children:[ee.jsxDEV("span",{className:"chart-tooltip-label tone-bad",children:u("providers.exhausted")},void 0,!1,void 0,this),ee.jsxDEV("span",{className:"chart-tooltip-value",children:D.join(", ")},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null}},void 0,!1,void 0,this),C.series.length>1&&ee.jsxDEV(Ka,{items:C.series.map((k)=>({key:k.key,label:k.label,color:k.color})),hidden:p,onToggle:S},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ee.jsxDEV("div",{className:"providers-accounts",children:ee.jsxDEV(Xt,{rows:w,rowKey:(k)=>`${k.series.windowKey}::${k.series.accountKey}`,columns:zD,limit:16,onRowClick:(k)=>f({provider:k.series.provider,windowKey:k.series.windowKey}),dense:!0},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function ND(l,i){let{POSITIVE_INFINITY:c,NEGATIVE_INFINITY:f}=Number;for(let A of l)for(let k of A.points){if(k.timestamp<c)c=k.timestamp;if(k.timestamp>f)f=k.timestamp}if(!(f>=c))return{buckets:[],bucketMs:Qr,first:0,last:0,max:0,series:[],exhausted:[]};let p=f-c,S=DD.find((A)=>p/A<ED)??$m,h=_o("all",[c],S,f),x=(A)=>Math.floor((A-h[0])/S),b=h.map(()=>[]),L=0,g=(A)=>i.get(A.accountKey)??A.accountLabel,w=[...l].sort((A,k)=>g(A).localeCompare(g(k))).map((A,k)=>{let D=h.map(()=>null),M=h.map(()=>0);for(let j of A.points){let Y=x(j.timestamp);if(Y<0||Y>=h.length)continue;if(j.exhausted&&!b[Y].includes(g(A)))b[Y].push(g(A));if(j.usedFraction===null||j.timestamp<M[Y])continue;D[Y]=j.usedFraction,M[Y]=j.timestamp,L=Math.max(L,j.usedFraction)}let B=null,P=0;for(let j=0;j<h.length;j++)if(D[j]!==null)B=D[j],P=M[j];else if(B!==null&&h[j]-P<=OD)D[j]=B;return{key:A.accountKey,label:g(A),color:Fa[k%Fa.length],values:D}});return{buckets:h,bucketMs:S,first:c,last:f,max:L,series:w,exhausted:b}}function BD(l){if(!l)return ee.jsxDEV("span",{className:"dim",children:u("providers.no-reading")},void 0,!1,void 0,this);if(l.exhausted)return ee.jsxDEV(Bt,{tone:"bad",children:u("providers.exhausted")},void 0,!1,void 0,this);if(l.fraction>=0.8)return ee.jsxDEV(Bt,{tone:"warn",children:u("providers.high")},void 0,!1,void 0,this);return ee.jsxDEV(Bt,{tone:"ok",children:u("ui.status-ok")},void 0,!1,void 0,this)}var zD=[{key:"account",header:u("providers.account"),sort:(l)=>l.name,render:(l)=>ee.jsxDEV("span",{className:"row",style:{gap:8},children:[ee.jsxDEV("span",{className:"providers-swatch-slot",children:l.color&&ee.jsxDEV(Cn,{color:l.color},void 0,!1,void 0,this)},void 0,!1,void 0,this),ee.jsxDEV("span",{className:"truncate providers-account",title:l.series.accountKey,children:l.name},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},{key:"window",header:u("providers.window"),sort:(l)=>l.series.windowKey,render:(l)=>ee.jsxDEV("span",{className:l.color?void 0:"muted",children:l.series.windowKey},void 0,!1,void 0,this)},{key:"latest",header:u("providers.latest-used"),align:"right",sort:(l)=>l.latest?.fraction??-1,render:(l)=>l.latest?ee.jsxDEV(pa,{value:l.latest.fraction,max:1,display:Fe(l.latest.fraction,0),color:l.latest.exhausted?"var(--bad)":l.latest.fraction>=0.8?"var(--warn)":"var(--ok)"},void 0,!1,void 0,this):ee.jsxDEV("span",{className:"dim",children:"–"},void 0,!1,void 0,this)},{key:"status",header:u("providers.status"),sort:(l)=>l.latest?.exhausted?2:(l.latest?.fraction??0)>=0.8?1:0,render:(l)=>BD(l.latest)},{key:"peak",header:u("providers.peak-in-range"),align:"right",sort:(l)=>l.peak??-1,render:(l)=>ee.jsxDEV("span",{className:"num",children:l.peak===null?"–":Fe(l.peak,0)},void 0,!1,void 0,this)},{key:"samples",header:u("providers.snapshots"),align:"right",sort:(l)=>l.samples,render:(l)=>ee.jsxDEV("span",{className:"num muted",children:z(l.samples)},void 0,!1,void 0,this)},{key:"recorded",header:u("providers.recorded"),align:"right",sort:(l)=>l.latest?.timestamp??0,render:(l)=>ee.jsxDEV("span",{className:"muted",children:l.latest?fa(l.latest.timestamp):"–"},void 0,!1,void 0,this)}];var tu=Z(gt(),1);var ot=Z(ue(),1),Qm={ok:{label:u("ui.status-ok"),tone:"ok"},aborted:{label:u("common.aborted"),tone:"warn"},failed:{label:u("common.failed"),tone:"bad"}};function LT({id:l,onClose:i}){let c=Ft(["request",l],({signal:S})=>n1(l??0,S),{enabled:l!==null}),f=c.stale?null:c.data,p=f?Qm[Yr(f)]:null;return ot.jsxDEV(qm,{open:l!==null,onClose:i,width:620,title:f?ot.jsxDEV("span",{className:"mono",children:f.model},void 0,!1,void 0,this):u("common.request"),subtitle:f?ot.jsxDEV(ot.Fragment,{children:[f.provider," ·"," ",ot.jsxDEV("span",{title:ln(f.timestamp),children:fa(f.timestamp)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):l!==null?ot.jsxDEV("span",{className:"mono",children:["#",l]},void 0,!0,void 0,this):void 0,actions:f&&p?ot.jsxDEV("div",{className:"row",style:{gap:6},children:[ot.jsxDEV("a",{className:"btn","data-size":"sm","data-variant":"ghost",href:Fm({...Od(window.location.hash),section:"traces",session:f.sessionFile}),onClick:i,title:u("ui.open-trace"),children:[ot.jsxDEV(vd,{size:13},void 0,!1,void 0,this)," Trace"]},void 0,!0,void 0,this),ot.jsxDEV(Bt,{tone:p.tone,children:p.label},void 0,!1,void 0,this)]},void 0,!0,void 0,this):void 0,children:f?ot.jsxDEV(UD,{details:f,aborted:Yr(f)==="aborted"},void 0,!1,void 0,this):c.error?ot.jsxDEV(gi,{error:c.error,onRetry:c.refetch},void 0,!1,void 0,this):ot.jsxDEV("div",{className:"stack",style:{gap:12},children:[ot.jsxDEV(qa,{height:56},void 0,!1,void 0,this),ot.jsxDEV(qa,{height:120},void 0,!1,void 0,this),ot.jsxDEV(qa,{height:120},void 0,!1,void 0,this),ot.jsxDEV(qa,{height:220},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function UD({details:l,aborted:i}){let{usage:c}=l,f=l.duration!==null&&l.duration>0&&c.output>0?c.output*1000/l.duration:null,{messages:p,output:S,...h}=l;return ot.jsxDEV(ot.Fragment,{children:[l.errorMessage&&ot.jsxDEV("section",{className:"request-drawer-error","data-tone":i?"warn":"bad",role:"note",children:[ot.jsxDEV("div",{className:"request-drawer-error-label",children:i?u("common.aborted"):u("common.error")},void 0,!1,void 0,this),ot.jsxDEV("pre",{className:"request-drawer-error-text",children:l.errorMessage},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ot.jsxDEV("section",{children:[ot.jsxDEV("div",{className:"section-label",children:u("ui.section-timing")},void 0,!1,void 0,this),ot.jsxDEV(Ho,{items:[{key:"at",label:u("common.started"),value:ln(l.timestamp)},{key:"duration",label:u("common.duration"),value:At(l.duration)},{key:"ttft",label:u("ui.time-to-first-token"),value:At(l.ttft)},{key:"tps",label:u("common.output-tokens-per-second"),value:dr(f)}]},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ot.jsxDEV("section",{children:[ot.jsxDEV("div",{className:"section-label",children:u("common.tokens")},void 0,!1,void 0,this),ot.jsxDEV(Ho,{items:[{key:"input",label:u("ui.uncached-input"),value:z(c.input)},{key:"cacheRead",label:u("common.cache-read"),value:z(c.cacheRead)},{key:"cacheWrite",label:u("common.cache-write"),value:z(c.cacheWrite)},{key:"output",label:u("common.output"),value:z(c.output)},{key:"total",label:u("common.total"),value:z(c.totalTokens)},{key:"premium",label:u("common.premium-requests"),value:z(Math.round((c.premiumRequests??0)*100)/100)}]},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ot.jsxDEV("section",{children:[ot.jsxDEV("div",{className:"section-label",children:u("ui.section-cost")},void 0,!1,void 0,this),ot.jsxDEV(Ho,{items:[{key:"total",label:"Total",value:Yl(l,4)},{key:"input",label:u("common.input"),value:da(c.cost.input,4)},{key:"cacheRead",label:"Cache read",value:da(c.cost.cacheRead,4)},{key:"cacheWrite",label:"Cache write",value:da(c.cost.cacheWrite,4)},{key:"output",label:"Output",value:da(c.cost.output,4)}]},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ot.jsxDEV("section",{children:[ot.jsxDEV("div",{className:"section-label",children:u("ui.section-identity")},void 0,!1,void 0,this),ot.jsxDEV(Ho,{items:[{key:"id",label:u("common.request-id"),value:l.id??"–"},{key:"entry",label:u("common.entry-id"),value:l.entryId},{key:"stop",label:u("ui.stop-reason"),value:l.stopReason},{key:"api",label:"API",value:l.api},{key:"project",label:u("common.project"),value:ot.jsxDEV("span",{title:l.folder,children:fr(l.folder)},void 0,!1,void 0,this)}]},void 0,!1,void 0,this),ot.jsxDEV("div",{className:"request-drawer-file",children:[ot.jsxDEV("span",{className:"kv-key",children:u("ui.session-file")},void 0,!1,void 0,this),ot.jsxDEV("span",{className:"kv-value",children:l.sessionFile},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),S!=null&&ot.jsxDEV(di,{data:S,title:u("common.output-message")},void 0,!1,void 0,this),ot.jsxDEV(di,{data:p,title:u("common.session-entry"),initialCollapsed:!0},void 0,!1,void 0,this),ot.jsxDEV(di,{data:h,title:u("ui.stats-row"),initialCollapsed:!0},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var We=Z(ue(),1),rb=[500,2000,1e4];function CT({active:l,range:i,onRequestClick:c}){let[f,p]=tu.useState(0),S=rb[f],h=Ft(["requests-log",S],({signal:Y})=>Mm(S,Y),{enabled:l}),[x,b]=tu.useState(""),[L,g]=tu.useState("all"),C=ia(i),w=tu.useMemo(()=>{let Y=h.data??[],ce=C.spanMs===null?null:Date.now()-C.spanMs,J=ce===null?Y:Y.filter((ae)=>ae.timestamp>=ce),te=!h.stale&&(Y.length<S||ce!==null&&J.length<Y.length),X={all:J.length,ok:0,aborted:0,failed:0};for(let ae of J)X[Yr(ae)]++;return{loaded:Y.length,inRange:J,complete:te,counts:X,summary:tT(J)}},[h.data,h.stale,S,C.spanMs]),A=tu.useMemo(()=>{let Y=x.trim().toLowerCase();return w.inRange.filter((ce)=>(L==="all"||Yr(ce)===L)&&(Y===""||ce.model.toLowerCase().includes(Y)||ce.provider.toLowerCase().includes(Y)||ce.folder.toLowerCase().includes(Y)))},[w.inRange,x,L]),{summary:k,counts:D,complete:M}=w,B=f+1<rb.length?rb[f+1]:null,P=B!==null?We.jsxDEV("button",{type:"button",className:"btn","data-size":"sm",disabled:h.refreshing,onClick:()=>p(f+1),children:h.refreshing&&h.stale?u("requests.loading"):u("requests.load-latest",{count:z(B)})},void 0,!1,void 0,this):void 0,j=["all","ok","aborted","failed"].map((Y)=>({value:Y,label:We.jsxDEV(We.Fragment,{children:[Y==="all"?u("requests.status-all"):Qm[Y].label," ",We.jsxDEV("span",{className:"dim num",children:Ae(D[Y])},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}));return We.jsxDEV("div",{className:"page",children:[We.jsxDEV(ra,{title:u("common.requests"),description:u("requests.description",{window:u(C.windowKey)})},void 0,!1,void 0,this),We.jsxDEV(Ge,{query:h,skeleton:We.jsxDEV(qa,{height:96,style:{borderRadius:12}},void 0,!1,void 0,this),children:()=>We.jsxDEV("div",{"data-stale":h.stale,children:We.jsxDEV(la,{min:160,children:[We.jsxDEV(ie,{label:u("common.requests"),value:z(k.requests),hint:k.oldest===null?u("requests.none-in-window",{window:u(C.windowKey)}):u("requests.since",{time:fa(k.oldest)})},void 0,!1,void 0,this),We.jsxDEV(ie,{label:u("common.failed"),value:z(k.failed),hint:u("requests.failed-hint",{rate:k.requests>0?to(k.failed/k.requests):"–",count:z(k.aborted)})},void 0,!1,void 0,this),We.jsxDEV(ie,{label:u("common.tokens"),title:u("requests.tokens-hint"),value:Ae(k.tokens)},void 0,!1,void 0,this),We.jsxDEV(ie,{label:u("requests.api-equivalent-cost"),title:u("requests.cost-hint"),value:Ht(k.cost,k.unpriced),hint:k.unpriced>0?u("requests.unpriced-n",{count:z(k.unpriced)}):void 0},void 0,!1,void 0,this),We.jsxDEV(ie,{label:u("requests.median-duration"),value:At(k.medianDuration),hint:u("requests.p95",{value:At(k.p95Duration)})},void 0,!1,void 0,this),We.jsxDEV(ie,{label:u("requests.median-ttft"),title:u("requests.ttft-hint"),value:At(k.medianTtft)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),We.jsxDEV(Ye,{index:1,title:u("requests.log-title"),description:h.data===null?u("requests.log-loading"):M?u("requests.log-count-in-window",{shown:z(A.length),total:z(k.requests),window:u(C.windowKey)}):u("requests.log-count-latest",{shown:z(A.length),total:z(k.requests)}),actions:We.jsxDEV(We.Fragment,{children:[We.jsxDEV(cr,{value:x,onChange:b,placeholder:u("requests.search-placeholder")},void 0,!1,void 0,this),We.jsxDEV(_a,{size:"sm","aria-label":u("requests.status"),options:j,value:L,onChange:g},void 0,!1,void 0,this)]},void 0,!0,void 0,this),flush:!0,stale:h.stale,footer:h.data!==null&&!M?We.jsxDEV(We.Fragment,{children:[We.jsxDEV("span",{children:u("requests.footer",{count:z(w.loaded),time:k.oldest===null?"–":ln(k.oldest),window:u(C.windowKey)})},void 0,!1,void 0,this),P]},void 0,!0,void 0,this):void 0,children:We.jsxDEV(Ge,{query:h,skeleton:We.jsxDEV(ca,{rows:12},void 0,!1,void 0,this),children:()=>We.jsxDEV(Xt,{rows:A,rowKey:(Y)=>Y.id??`${Y.sessionFile}:${Y.entryId}`,onRowClick:(Y)=>Y.id!==void 0&&c(Y.id),columns:PD,initialSort:{key:"time",dir:"desc"},limit:100,dense:!0,empty:We.jsxDEV(wt,{title:k.requests===0?u("requests.empty-in-window",{window:u(C.windowKey)}):u("requests.empty-no-match"),hint:k.requests===0?void 0:u("requests.empty-no-match-hint")},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var PD=[{key:"model",header:u("common.model"),sort:(l)=>l.model,render:(l)=>We.jsxDEV(Ha,{primary:We.jsxDEV("span",{className:"mono",children:l.model},void 0,!1,void 0,this),secondary:l.provider},void 0,!1,void 0,this)},{key:"time",header:u("requests.when"),sort:(l)=>l.timestamp,render:(l)=>We.jsxDEV("span",{className:"muted",title:ln(l.timestamp),children:fa(l.timestamp)},void 0,!1,void 0,this)},{key:"project",header:u("common.project"),sort:(l)=>l.folder,render:(l)=>We.jsxDEV("span",{className:"mono muted truncate",title:l.folder,style:{display:"block",maxWidth:180},children:fr(l.folder)},void 0,!1,void 0,this)},{key:"input",header:u("common.input"),title:u("requests.uncached-input"),align:"right",sort:(l)=>l.usage.input,render:(l)=>We.jsxDEV("span",{className:"num",children:Ae(l.usage.input)},void 0,!1,void 0,this)},{key:"cache",header:u("common.cache-read"),title:u("requests.cache-read-title"),align:"right",sort:(l)=>l.usage.cacheRead,render:(l)=>We.jsxDEV("span",{className:"num",title:u("requests.cache-write",{count:z(l.usage.cacheWrite)}),children:Ae(l.usage.cacheRead)},void 0,!1,void 0,this)},{key:"output",header:u("common.output"),align:"right",sort:(l)=>l.usage.output,render:(l)=>We.jsxDEV("span",{className:"num",children:Ae(l.usage.output)},void 0,!1,void 0,this)},{key:"cost",header:u("common.cost"),title:u("requests.cost-estimate"),align:"right",sort:(l)=>l.usage.cost.total,render:(l)=>We.jsxDEV("span",{className:"num",children:Yl(l,4)},void 0,!1,void 0,this)},{key:"duration",header:u("common.duration"),align:"right",sort:(l)=>l.duration??-1,render:(l)=>We.jsxDEV("span",{className:"num",children:At(l.duration)},void 0,!1,void 0,this)},{key:"ttft",header:u("requests.ttft"),title:u("requests.ttft-hint"),align:"right",sort:(l)=>l.ttft??-1,render:(l)=>We.jsxDEV("span",{className:"num muted",children:At(l.ttft)},void 0,!1,void 0,this)},{key:"status",header:u("requests.status"),sort:(l)=>Yr(l),render:(l)=>{let i=Qm[Yr(l)];return We.jsxDEV("span",{title:l.errorMessage??void 0,children:We.jsxDEV(Ha,{lead:We.jsxDEV(ur,{tone:i.tone},void 0,!1,void 0,this),primary:i.label,secondary:We.jsxDEV("span",{className:"mono",children:l.stopReason},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}}];var ou=Z(gt(),1);var ge=Z(ue(),1),_D=[{value:"calls",label:u("tools.calls")},{value:"errors",label:u("tools.errors")}],wT=6,au=u("tools.attribution-note");function HD(l){if(l<3600000)return u("tools.bucket-5m");if(l<86400000)return u("tools.bucket-hour");return u("tools.bucket-day")}var lb=ge.jsxDEV(wt,{title:u("tools.no-tool-calls")},void 0,!1,void 0,this);function kT({active:l,range:i}){let c=Ft(["tools",i],({signal:k})=>f1(i,k),{enabled:l}),[f,p]=ou.useState("calls"),[S,h]=sn(),[x,b]=ou.useState(null),L=ia(i),g=ou.useMemo(()=>FD(c.data,i),[c.data,i]),C=x!==null&&g.toolNames.includes(x)?x:null,w=f==="calls"?g.callSeries:g.errorSeries,A=(k)=>k.byTool.length===0;return ge.jsxDEV("div",{className:"page",children:[ge.jsxDEV(ra,{title:u("tools.title"),description:u("tools.description",{window:u(L.windowKey)})},void 0,!1,void 0,this),ge.jsxDEV(Ge,{query:c,skeleton:ge.jsxDEV(zt,{height:112},void 0,!1,void 0,this),children:()=>{let k=g.totals;return ge.jsxDEV("div",{"data-stale":c.stale,className:"stack",style:{gap:16},children:[ge.jsxDEV(la,{min:190,children:[ge.jsxDEV(ie,{label:u("tools.tool-calls"),value:z(k.calls),hint:u("tools.failed-n",{count:z(k.errors)}),spark:g.totalCalls},void 0,!1,void 0,this),ge.jsxDEV(ie,{label:u("tools.distinct-tools"),value:z(k.tools),hint:g.rows[0]?u("tools.most-used",{tool:g.rows[0].tool}):void 0},void 0,!1,void 0,this),ge.jsxDEV(ie,{label:u("common.error-rate"),title:u("tools.error-rate-title"),value:to(k.calls>0?k.errors/k.calls:0),hint:u("tools.succeeded-n",{count:z(k.calls-k.errors)}),spark:g.totalErrors,sparkColor:"var(--bad)"},void 0,!1,void 0,this),ge.jsxDEV(ie,{label:u("tools.attributed-tokens"),title:au,value:Ae(Math.round(k.tokens)),hint:u("tools.tokens-output",{tokens:Ae(Math.round(k.output))})},void 0,!1,void 0,this),ge.jsxDEV(ie,{label:u("tools.attributed-cost"),title:u("tools.attribution-estimate",{note:au}),value:Ht(k.cost,k.unpriced),hint:k.unpriced>0?u("tools.unpriced-requests-n",{count:z(Math.round(k.unpriced))}):u("tools.api-equivalent")},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ge.jsxDEV(la,{min:150,children:[ge.jsxDEV(ie,{size:"sm",label:u("tools.result-text"),title:u("tools.result-chars-title"),value:u("tools.chars",{count:Ae(k.resultChars)})},void 0,!1,void 0,this),ge.jsxDEV(ie,{size:"sm",label:u("tools.call-arguments"),title:u("tools.args-chars-title"),value:u("tools.chars",{count:Ae(k.argsChars)})},void 0,!1,void 0,this),ge.jsxDEV(ie,{size:"sm",label:u("tools.avg-result-per-call"),value:u("tools.chars",{count:Ae(k.calls>0?Math.round(k.resultChars/k.calls):0)})},void 0,!1,void 0,this),ge.jsxDEV(ie,{size:"sm",label:u("tools.avg-args-per-call"),value:u("tools.chars",{count:Ae(k.calls>0?Math.round(k.argsChars/k.calls):0)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}},void 0,!1,void 0,this),ge.jsxDEV(Ye,{index:1,title:f==="calls"?u("tools.calls-over-time"):u("tools.errors-over-time"),description:u("tools.chart-description",{bucket:HD(L.bucketMs),count:wT}),actions:ge.jsxDEV(_a,{size:"sm",options:_D,value:f,onChange:p},void 0,!1,void 0,this),stale:c.stale,children:ge.jsxDEV(Ge,{query:c,skeleton:ge.jsxDEV(zt,{height:260},void 0,!1,void 0,this),isEmpty:A,empty:lb,children:()=>ge.jsxDEV("div",{className:"stack",style:{gap:12},children:[ge.jsxDEV(Xr,{buckets:g.buckets,bucketMs:L.bucketMs,series:w,hidden:S,height:260,formatTooltip:z,emptyLabel:f==="errors"?u("tools.no-tool-errors"):void 0},void 0,!1,void 0,this),ge.jsxDEV(Ka,{items:w.map((k)=>({key:k.key,label:k.label,color:k.color,value:Ae(k.values.reduce((D,M)=>D+(M??0),0))})),hidden:S,onToggle:h},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),ge.jsxDEV(Ye,{index:2,title:u("tools.by-tool"),description:u("tools.by-tool-description",{note:au}),flush:!0,stale:c.stale,children:ge.jsxDEV(Ge,{query:c,skeleton:ge.jsxDEV(ca,{rows:8},void 0,!1,void 0,this),isEmpty:A,empty:lb,children:()=>ge.jsxDEV(Xt,{rows:g.rows,rowKey:(k)=>k.tool,columns:g.toolColumns,initialSort:{key:"calls",dir:"desc"},limit:20,selectedKey:C,onRowClick:(k)=>b((D)=>D===k.tool?null:k.tool),dense:!0},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),ge.jsxDEV(Ye,{index:3,title:u("tools.by-tool-and-model"),description:u("tools.by-tool-and-model-description"),flush:!0,stale:c.stale,actions:ge.jsxDEV("div",{className:"row",style:{gap:6},children:[ge.jsxDEV("select",{className:"input tools-filter",value:C??"",onChange:(k)=>b(k.target.value||null),"aria-label":u("tools.filter-by-tool"),children:[ge.jsxDEV("option",{value:"",children:u("tools.all-tools")},void 0,!1,void 0,this),g.toolNames.map((k)=>ge.jsxDEV("option",{value:k,children:k},k,!1,void 0,this))]},void 0,!0,void 0,this),C!==null&&ge.jsxDEV("button",{type:"button",className:"btn","data-size":"sm","data-variant":"ghost","data-icon":"true",title:u("tools.clear-tool-filter"),"aria-label":u("tools.clear-tool-filter"),onClick:()=>b(null),children:ge.jsxDEV(nn,{size:13},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),children:ge.jsxDEV(Ge,{query:c,skeleton:ge.jsxDEV(ca,{rows:8},void 0,!1,void 0,this),isEmpty:A,empty:lb,children:(k)=>ge.jsxDEV(VD,{rows:k.byToolModel,tool:C,colors:g.colors},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function FD(l,i){let c=l?.byTool??[],f=l?.series??[],p=eT(c).sort((A,k)=>k.calls-A.calls),S=Nd(c.map((A)=>({key:A.tool,weight:A.calls}))),h=_o(i,f.map((A)=>A.timestamp)),x={calls:0,errors:0,tools:c.length,tokens:0,output:0,cost:0,unpriced:0,resultChars:0,argsChars:0};for(let A of c)x.calls+=A.calls,x.errors+=A.errors,x.tokens+=A.totalTokensShare,x.output+=A.outputTokensShare,x.cost+=A.costShare,x.unpriced+=A.unpricedRequestsShare,x.resultChars+=A.resultChars,x.argsChars+=A.argsChars;let[b,L]=[(A)=>A.calls,(A)=>A.errors].map((A)=>hr(f,{buckets:h,key:(k)=>k.tool,value:A,limit:wT,colors:S}).map((k)=>({...k,values:k.values.map((D)=>D||null)}))),g=new Map(hr(f,{buckets:h,key:(A)=>A.tool,value:(A)=>A.calls}).map((A)=>[A.key,A.values])),C=p[0]?.calls??0,w=GD(C,S,g);return{rows:p,colors:S,buckets:h,totals:x,callSeries:b,errorSeries:L,totalCalls:Sa(f,h,(A)=>A.calls),totalErrors:Sa(f,h,(A)=>A.errors),toolNames:p.map((A)=>A.tool).sort((A,k)=>A.localeCompare(k)),toolColumns:w}}function GD(l,i,c){return[{key:"tool",header:u("tools.tool"),sort:(f)=>f.tool,render:(f)=>ge.jsxDEV("span",{className:"row",style:{gap:8},children:[ge.jsxDEV(Cn,{color:i.get(f.tool)??ao},void 0,!1,void 0,this),ge.jsxDEV("span",{className:"mono truncate tools-name",title:f.tool,children:f.tool},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},{key:"trend",header:u("tools.trend"),title:u("tools.trend-title"),render:(f)=>{let p=c.get(f.tool);return p&&p.length>1?ge.jsxDEV(mi,{values:p,width:80,height:20,color:i.get(f.tool)??ao},void 0,!1,void 0,this):ge.jsxDEV("span",{className:"dim",children:"–"},void 0,!1,void 0,this)}},{key:"calls",header:u("tools.calls"),align:"right",sort:(f)=>f.calls,render:(f)=>ge.jsxDEV(pa,{value:f.calls,max:l,display:ge.jsxDEV("span",{title:u("tools.share-of-calls",{percent:Fe(f.callFraction)}),children:[z(f.calls),ge.jsxDEV("span",{className:"dim tools-share",children:Fe(f.callFraction,0)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},{key:"errorRate",header:u("tools.errors"),title:u("tools.errors-title"),align:"right",sort:(f)=>f.errorRate,render:(f)=>ge.jsxDEV("span",{className:"row",style:{gap:8,justifyContent:"flex-end"},children:[ge.jsxDEV("span",{className:"num dim",children:z(f.errors)},void 0,!1,void 0,this),ge.jsxDEV(Bt,{tone:f.errors>0?ir(f.errorRate):"neutral",mono:!0,children:to(f.errorRate)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},{key:"args",header:u("tools.args"),title:u("tools.args-chars-title"),align:"right",sort:(f)=>f.argsChars,render:(f)=>ge.jsxDEV("span",{className:"num",children:Ae(f.argsChars)},void 0,!1,void 0,this)},{key:"result",header:u("tools.result"),title:u("tools.result-chars-title"),align:"right",sort:(f)=>f.resultChars,render:(f)=>ge.jsxDEV("span",{className:"num",children:Ae(f.resultChars)},void 0,!1,void 0,this)},{key:"avgResult",header:u("tools.result-per-call"),title:u("tools.result-per-call-title"),align:"right",sort:(f)=>f.avgResultChars,render:(f)=>ge.jsxDEV("span",{className:"num muted",children:Ae(Math.round(f.avgResultChars))},void 0,!1,void 0,this)},{key:"tokens",header:u("tools.attr-tokens"),title:au,align:"right",sort:(f)=>f.totalTokensShare,render:(f)=>ge.jsxDEV("span",{className:"num",title:u("tools.share-of-tokens",{percent:Fe(f.tokenFraction)}),children:[Ae(Math.round(f.totalTokensShare)),ge.jsxDEV("span",{className:"dim tools-share",children:Fe(f.tokenFraction,0)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},{key:"cost",header:u("tools.attr-cost"),title:u("tools.attribution-estimate",{note:au}),align:"right",sort:(f)=>f.costShare,render:(f)=>ge.jsxDEV("span",{className:"num",title:u("tools.share-of-cost",{percent:Fe(f.costFraction)}),children:[Ht(f.costShare,f.unpricedRequestsShare),ge.jsxDEV("span",{className:"dim tools-share",children:Fe(f.costFraction,0)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},{key:"lastUsed",header:u("tools.last-used"),align:"right",sort:(f)=>f.lastUsed,render:(f)=>ge.jsxDEV("span",{className:"muted",children:fa(f.lastUsed)},void 0,!1,void 0,this)}]}function VD({rows:l,tool:i,colors:c}){let f=ou.useMemo(()=>(i===null?l:l.filter((S)=>S.tool===i)).map((S)=>({...S,errorRate:S.calls>0?S.errors/S.calls:0})),[l,i]),p=ou.useMemo(()=>{let S=f.reduce((h,x)=>Math.max(h,x.calls),0);return[{key:"tool",header:u("tools.tool"),sort:(h)=>h.tool,render:(h)=>ge.jsxDEV("span",{className:"row",style:{gap:8},children:[ge.jsxDEV(Cn,{color:c.get(h.tool)??ao},void 0,!1,void 0,this),ge.jsxDEV("span",{className:"mono truncate tools-name",title:h.tool,children:h.tool},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},{key:"model",header:u("common.model"),sort:(h)=>h.model,render:(h)=>ge.jsxDEV(Ha,{primary:ge.jsxDEV("span",{className:"mono",children:h.model||u("common.unknown")},void 0,!1,void 0,this),secondary:h.provider},void 0,!1,void 0,this)},{key:"calls",header:u("tools.calls"),align:"right",sort:(h)=>h.calls,render:(h)=>ge.jsxDEV(pa,{value:h.calls,max:S,display:z(h.calls)},void 0,!1,void 0,this)},{key:"errorRate",header:u("tools.errors"),align:"right",sort:(h)=>h.errorRate,render:(h)=>ge.jsxDEV("span",{className:"row",style:{gap:8,justifyContent:"flex-end"},children:[ge.jsxDEV("span",{className:"num dim",children:z(h.errors)},void 0,!1,void 0,this),ge.jsxDEV(Bt,{tone:h.errors>0?ir(h.errorRate):"neutral",mono:!0,children:to(h.errorRate)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},{key:"result",header:u("tools.result"),title:u("tools.result-chars-title"),align:"right",sort:(h)=>h.resultChars,render:(h)=>ge.jsxDEV("span",{className:"num",children:Ae(h.resultChars)},void 0,!1,void 0,this)},{key:"tokens",header:u("tools.attr-tokens"),title:au,align:"right",sort:(h)=>h.totalTokensShare,render:(h)=>ge.jsxDEV("span",{className:"num",children:Ae(Math.round(h.totalTokensShare))},void 0,!1,void 0,this)},{key:"cost",header:u("tools.attr-cost"),title:u("tools.attribution-estimate",{note:au}),align:"right",sort:(h)=>h.costShare,render:(h)=>ge.jsxDEV("span",{className:"num",children:Ht(h.costShare,h.unpricedRequestsShare)},void 0,!1,void 0,this)},{key:"lastUsed",header:u("tools.last-used"),align:"right",sort:(h)=>h.lastUsed,render:(h)=>ge.jsxDEV("span",{className:"muted",children:fa(h.lastUsed)},void 0,!1,void 0,this)}]},[f,c]);return ge.jsxDEV(Xt,{rows:f,rowKey:(S)=>`${S.tool}::${S.model}::${S.provider}`,columns:p,initialSort:{key:"calls",dir:"desc"},limit:25,dense:!0,empty:ge.jsxDEV(wt,{title:i?u("tools.no-calls-to-tool",{tool:i}):u("tools.no-tool-calls")},void 0,!1,void 0,this)},void 0,!1,void 0,this)}var ki=Z(gt(),1);var Dt=Z(gt(),1);var gr=Z(ue(),1);function TT({toolStats:l,index:i}){if(l.length===0)return null;let c=Math.max(...l.map((p)=>p.totalMs)),f=[{key:"tool",header:u("trace.tool"),render:(p)=>gr.jsxDEV("span",{className:"mono",children:p.tool},void 0,!1,void 0,this),sort:(p)=>p.tool},{key:"calls",header:u("trace.calls"),align:"right",render:(p)=>gr.jsxDEV("span",{className:"num",children:z(p.calls)},void 0,!1,void 0,this),sort:(p)=>p.calls},{key:"errors",header:u("trace.errors"),align:"right",render:(p)=>p.errors>0?gr.jsxDEV(Bt,{tone:"bad",children:u("trace.failed-n",{count:z(p.errors)})},void 0,!1,void 0,this):gr.jsxDEV("span",{className:"num dim",children:"0"},void 0,!1,void 0,this),sort:(p)=>p.errors},{key:"total",header:u("common.total"),align:"right",width:200,render:(p)=>gr.jsxDEV(pa,{value:p.totalMs,max:c,display:At(p.totalMs),color:"var(--warn)"},void 0,!1,void 0,this),sort:(p)=>p.totalMs},{key:"avg",header:u("trace.avg"),align:"right",render:(p)=>gr.jsxDEV("span",{className:"num",children:At(p.calls>0?p.totalMs/p.calls:0)},void 0,!1,void 0,this),sort:(p)=>p.calls>0?p.totalMs/p.calls:0},{key:"max",header:u("trace.max"),align:"right",render:(p)=>gr.jsxDEV("span",{className:"num",children:At(p.maxMs)},void 0,!1,void 0,this),sort:(p)=>p.maxMs}];return gr.jsxDEV(Ye,{title:u("trace.tool-aggregates"),description:u("trace.tool-aggregates-desc",{count:l.length}),flush:!0,index:i,children:gr.jsxDEV(Xt,{columns:f,rows:l,rowKey:(p)=>p.tool,dense:!0,limit:12},void 0,!1,void 0,this)},void 0,!1,void 0,this)}var Fo=Z(gt(),1);var xi=Z(gt(),1);var nu={turn:"--ink-2",model:"--chart-primary",tool:"--warn",subagent:"--chart-secondary",background:"--ink-4"};function jD(){let l=getComputedStyle(document.documentElement),i=(c,f)=>l.getPropertyValue(c).trim()||f;return{category:{turn:i(nu.turn,"#a0a0a8"),model:i(nu.model,"#5ad8e6"),tool:i(nu.tool,"#f5a524"),subagent:i(nu.subagent,"#ed4abf"),background:i(nu.background,"#46464c")},error:i("--bad","#ff6166"),errorSoft:i("--bad-soft","rgba(255, 97, 102, 0.13)"),marker:i("--ink-1","#ededef"),turnBand:i("--hover","rgba(255, 255, 255, 0.035)"),grid:i("--chart-grid","rgba(255, 255, 255, 0.055)"),tick:i("--chart-axis","#5c5c64"),spanText:i("--ink-inverse","#0a0a0b"),selection:i("--focus","#5ad8e6"),brush:i("--selected","rgba(255, 255, 255, 0.075)"),fontSans:i("--font-sans","system-ui, sans-serif"),fontMono:i("--font-mono","ui-monospace, monospace")}}function Si(){let l=q1(),[i,c]=xi.useState(0);return xi.useEffect(()=>{let f=new MutationObserver(()=>c((p)=>p+1));return f.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>f.disconnect()},[]),xi.useMemo(jD,[l,i])}var AT=Z(ue(),1),Kl=44,Vd=["turn","model","tool","subagent"],IT=6,Li=10;function XD(l,i,c,f){let p=devicePixelRatio,S=Math.floor(c*p),h=Math.floor(Kl*p),x,b;if(typeof OffscreenCanvas>"u"){let k=document.createElement("canvas");k.width=S,k.height=h,x=k,b=k.getContext("2d")}else{let k=new OffscreenCanvas(S,h);x=k,b=k.getContext("2d")}if(!b)return x;b.setTransform(p,0,0,p,0,0);let[L,g]=i.domain,C=Math.max(g-L,0.000000001),w=Vd.map(()=>new Float32Array(c));for(let k of l)for(let D of k.spans){let M=Vd.indexOf(D.kind);if(M===-1)continue;let B=w[M],P=Math.max(0,Math.floor((i.toU(D.start)-L)/C*c)),j=Math.min(c-1,Math.ceil((i.toU(D.end)-L)/C*c));for(let Y=P;Y<=j;Y++)B[Y]=Math.min(1,B[Y]+0.34)}let A=Kl/Vd.length;for(let k=0;k<Vd.length;k++){let D=w[k];b.fillStyle=f.category[Vd[k]];for(let M=0;M<c;M++){if(D[M]<=0)continue;b.globalAlpha=0.25+D[M]*0.75,b.fillRect(M,k*A+1,1,A-2)}b.globalAlpha=1}return x}function RT({tracks:l,scale:i,viewport:c,onViewportChange:f}){let p=Si(),S=Fo.useRef(null),[h,x]=Fo.useState(800),b=Fo.useRef(null);Fo.useEffect(()=>{let P=S.current;if(!P)return;let j=new ResizeObserver((Y)=>{x(Math.max(100,Math.floor(Y[0].contentRect.width)))});return j.observe(P),()=>j.disconnect()},[]);let[L,g]=i.domain,C=Math.max(g-L,0.000000001),w=Fo.useCallback((P)=>(P-L)/C*h,[L,C,h]),A=Fo.useCallback((P)=>L+P/Math.max(h,1)*C,[L,C,h]),k=Fo.useMemo(()=>XD(l,i,h,p),[l,i,h,p]);Fo.useEffect(()=>{let P=S.current;if(!P)return;let j=P.getContext("2d");if(!j)return;let Y=devicePixelRatio;j.setTransform(1,0,0,1,0,0),j.clearRect(0,0,P.width,P.height),j.drawImage(k,0,0),j.setTransform(Y,0,0,Y,0,0);let ce=w(c.u0),J=w(c.u1);j.fillStyle=p.brush,j.fillRect(ce,0,J-ce,Kl),j.strokeStyle=p.selection,j.strokeRect(ce+0.5,0.5,J-ce-1,Kl-1),j.fillStyle=p.selection,j.fillRect(ce,0,2,Kl),j.fillRect(J-2,0,2,Kl)},[k,c,p,w]);let D=(P)=>{let j=P.currentTarget.getBoundingClientRect(),Y=P.clientX-j.left,ce=w(c.u0),J=w(c.u1),te;if(Math.abs(Y-ce)<=IT)te="left";else if(Math.abs(Y-J)<=IT)te="right";else if(Y>ce&&Y<J)te="move";else{te="create";let X=A(Y);f(jd({u0:X,u1:X+Li},L,g))}b.current={mode:te,startX:Y,startViewport:c},P.currentTarget.setPointerCapture(P.pointerId)},M=(P)=>{let j=b.current;if(!j)return;let Y=P.currentTarget.getBoundingClientRect(),ce=P.clientX-Y.left,J=A(ce)-A(j.startX),{u0:te,u1:X}=j.startViewport;if(j.mode==="move")f(jd({u0:te+J,u1:X+J},L,g));else if(j.mode==="left")f(jd({u0:Math.min(te+J,X-Li),u1:X},L,g));else if(j.mode==="right")f(jd({u0:te,u1:Math.max(X+J,te+Li)},L,g));else{let ae=A(j.startX),H=A(ce);f(jd({u0:Math.min(ae,H),u1:Math.max(ae,H,Math.min(ae,H)+Li)},L,g))}},B=()=>{b.current=null};return AT.jsxDEV("canvas",{ref:S,width:Math.floor(h*devicePixelRatio),height:Math.floor(Kl*devicePixelRatio),className:"traces-minimap",style:{height:Kl},role:"slider","aria-label":u("trace.minimap-aria"),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round((c.u0-L)/C*100),tabIndex:-1,onPointerDown:D,onPointerMove:M,onPointerUp:B},void 0,!1,void 0,this)}function jd(l,i,c){let f=Math.max(Li,l.u1-l.u0);f=Math.min(f,c-i||Li);let p=l.u0;if(p<i)p=i;if(p+f>c)p=c-f;return{u0:p,u1:p+f}}var yr=Z(gt(),1);var nt=Z(ue(),1);function YD(l){let i=[];if(typeof l==="string"){if(l.trim())i.push({kind:"text",text:l});return i}if(!Array.isArray(l))return i;for(let c of l){if(!c||typeof c!=="object"||!("type"in c))continue;if((c.type==="text"||c.type==="thinking")&&"text"in c&&typeof c.text==="string")i.push({kind:String(c.type),text:c.text})}return i}function MT({span:l,track:i,onClose:c,onOpenChildTrack:f}){let[p,S]=yr.useState(null),[h,x]=yr.useState(!1),[b,L]=yr.useState(null),[g,C]=yr.useState(!1),w=yr.useRef(0);if(yr.useEffect(()=>{if(S(null),L(null),C(!1),x(!1),!l||!i||!l.entryId)return;x(!0);let P=new AbortController;return g1(i.file,l.entryId,P.signal).then((j)=>{if(!P.signal.aborted)S(j.entry)}).catch((j)=>{if(P.signal.aborted)return;L(j instanceof Error?j:Error(String(j)))}).finally(()=>{if(!P.signal.aborted)x(!1)}),()=>P.abort()},[l,i]),yr.useEffect(()=>()=>window.clearTimeout(w.current),[]),!l)return null;let A=async()=>{try{await navigator.clipboard.writeText(JSON.stringify(p??l,null,2)),C(!0),window.clearTimeout(w.current),w.current=window.setTimeout(()=>C(!1),1500)}catch{}},D=(p&&typeof p==="object"?p:{}).message,M=D?.usage,B=[{key:"duration",label:u("common.duration"),value:nt.jsxDEV("span",{className:"num",children:[At(l.end-l.start),l.unterminated&&nt.jsxDEV("span",{className:"muted",children:[" · ",u("trace.unterminated")]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},{key:"start",label:u("trace.start"),value:nt.jsxDEV("span",{className:"num",children:new Date(l.start).toLocaleTimeString()},void 0,!1,void 0,this)},{key:"track",label:u("trace.track"),value:nt.jsxDEV("span",{className:"mono",children:i?.label??"-"},void 0,!1,void 0,this)}];if(l.kind==="model"){if(B.push({key:"tokens",label:u("common.tokens"),value:nt.jsxDEV("span",{className:"num",children:z(l.tokens??0)},void 0,!1,void 0,this)},{key:"cost",label:u("common.cost"),value:nt.jsxDEV("span",{className:"num",children:["$",(l.cost??0).toFixed(4)]},void 0,!0,void 0,this)},{key:"ttft",label:u("trace.ttft"),value:nt.jsxDEV("span",{className:"num",children:At(l.ttft??null)},void 0,!1,void 0,this)},{key:"model",label:u("common.model"),value:nt.jsxDEV("span",{className:"mono",children:D?.model??l.model??"-"},void 0,!1,void 0,this)}),M)B.push({key:"split",label:u("trace.io-cached"),value:nt.jsxDEV("span",{className:"num",children:[z(M.input??0)," / ",z(M.output??0)," /"," ",z(M.cacheRead??0)]},void 0,!0,void 0,this)});if(D?.provider)B.push({key:"provider",label:u("common.provider"),value:nt.jsxDEV("span",{className:"mono",children:D.provider},void 0,!1,void 0,this)});if(D?.stopReason)B.push({key:"stop",label:u("trace.stop-reason"),value:nt.jsxDEV("span",{className:"mono",children:D.stopReason},void 0,!1,void 0,this)})}return nt.jsxDEV(qm,{open:!0,onClose:c,title:l.label,subtitle:nt.jsxDEV("span",{className:"row",style:{gap:6},children:nt.jsxDEV(Bt,{tone:l.isError?"bad":"neutral",children:l.isError?`${l.kind} · ${u("common.error")}`:l.kind},void 0,!1,void 0,this)},void 0,!1,void 0,this),actions:nt.jsxDEV("button",{type:"button",className:"btn","data-variant":"ghost","data-icon":"true",onClick:A,"aria-label":u("trace.copy-json"),title:u("trace.copy-json"),children:g?nt.jsxDEV(Gs,{size:15},void 0,!1,void 0,this):nt.jsxDEV(js,{size:15},void 0,!1,void 0,this)},void 0,!1,void 0,this),children:nt.jsxDEV("div",{className:"stack traces-drawer",children:[nt.jsxDEV(Ho,{items:B},void 0,!1,void 0,this),D?.errorMessage&&nt.jsxDEV("div",{className:"stack",style:{gap:6},children:[nt.jsxDEV("div",{className:"section-label tone-bad",children:u("trace.error-message")},void 0,!1,void 0,this),nt.jsxDEV("pre",{className:"code-block traces-pre",children:D.errorMessage},void 0,!1,void 0,this)]},void 0,!0,void 0,this),l.kind==="subagent"&&nt.jsxDEV("div",{className:"stack",style:{gap:8},children:[l.detail&&nt.jsxDEV(nt.Fragment,{children:[nt.jsxDEV("div",{className:"section-label",children:u("trace.task")},void 0,!1,void 0,this),nt.jsxDEV("pre",{className:"code-block traces-pre",children:l.detail},void 0,!1,void 0,this)]},void 0,!0,void 0,this),l.childTrackId&&f&&nt.jsxDEV("div",{children:nt.jsxDEV("button",{type:"button",className:"btn","data-size":"sm",onClick:()=>f(l.childTrackId??""),children:[u("trace.open-child-track")," ",nt.jsxDEV("span",{className:"mono",children:l.childTrackId},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),l.kind==="tool"&&l.detail&&nt.jsxDEV("div",{className:"stack",style:{gap:6},children:[nt.jsxDEV("div",{className:"section-label",children:u("trace.args")},void 0,!1,void 0,this),nt.jsxDEV("pre",{className:"code-block traces-pre",children:l.detail},void 0,!1,void 0,this)]},void 0,!0,void 0,this),h&&nt.jsxDEV("div",{className:"stack",children:[nt.jsxDEV(qa,{height:80},void 0,!1,void 0,this),nt.jsxDEV(qa,{height:160},void 0,!1,void 0,this)]},void 0,!0,void 0,this),b&&nt.jsxDEV(gi,{error:u("trace.load-failed",{message:b.message})},void 0,!1,void 0,this),!h&&p!==null&&YD(D?.content).map((P,j)=>nt.jsxDEV("div",{className:"stack",style:{gap:6},children:[nt.jsxDEV("div",{className:"section-label",children:P.kind==="thinking"?u("trace.thinking"):u("trace.text")},void 0,!1,void 0,this),nt.jsxDEV("pre",{className:"code-block traces-pre","data-scroll":"true",children:P.text},void 0,!1,void 0,this)]},`${P.kind}-${j}`,!0,void 0,this)),!h&&p!==null&&nt.jsxDEV(di,{data:p,title:u("trace.raw-entry"),initialCollapsed:!0},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}var An=Z(ue(),1);function DT({summary:l}){let i=(c)=>l.wallMs>0?u("trace.of-wall",{percent:Fe(c/l.wallMs)}):void 0;return An.jsxDEV(la,{min:112,children:[An.jsxDEV(ie,{size:"sm",label:u("trace.wall-time"),value:Ks(l.wallMs)},void 0,!1,void 0,this),An.jsxDEV(ie,{size:"sm",label:u("trace.model-time"),value:Ks(l.modelMs),hint:i(l.modelMs)},void 0,!1,void 0,this),An.jsxDEV(ie,{size:"sm",label:u("trace.tool-time"),value:Ks(l.toolMs),hint:i(l.toolMs)},void 0,!1,void 0,this),An.jsxDEV(ie,{size:"sm",label:u("trace.idle"),value:Ks(l.idleMs),hint:i(l.idleMs)},void 0,!1,void 0,this),An.jsxDEV(ie,{size:"sm",label:u("trace.turns"),value:z(l.turns)},void 0,!1,void 0,this),An.jsxDEV(ie,{size:"sm",label:u("common.requests"),value:z(l.requests),hint:u("trace.tool-calls-n",{count:z(l.toolCalls)})},void 0,!1,void 0,this),An.jsxDEV(ie,{size:"sm",label:u("trace.agents"),value:z(l.subagents)},void 0,!1,void 0,this),An.jsxDEV(ie,{size:"sm",label:u("common.tokens"),value:Ae(l.totalTokens)},void 0,!1,void 0,this),An.jsxDEV(ie,{size:"sm",label:u("common.cost"),value:Ht(l.costTotal,l.unpricedRequests)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var Ot=Z(gt(),1),UT=Z(rd(),1);function Km(l,i){let c=l.length,f=[i[0],i[c-1]],p=(S,h)=>{let x=0,b=c-1;while(x<b){let L=x+b+1>>1;if(S[L]<=h)x=L;else b=L-1}return Math.min(x,c-2)};return{toU(S){if(S<=l[0])return i[0];if(S>=l[c-1])return i[c-1];let h=p(l,S),x=l[h+1]-l[h];if(x<=0)return i[h];return i[h]+(S-l[h])/x*(i[h+1]-i[h])},toT(S){if(S<=i[0])return l[0];if(S>=i[c-1])return l[c-1];let h=p(i,S),x=i[h+1]-i[h];if(x<=0)return l[h];return l[h]+(S-i[h])/x*(l[h+1]-l[h])},domain:f,gaps:[]}}function $D(l){let i=[];for(let c of l)for(let f of c.spans)i.push([f.start,f.end]);return i.sort((c,f)=>c[0]-f[0]),i}function QD(l){let{POSITIVE_INFINITY:i,NEGATIVE_INFINITY:c}=Number;for(let f of l)for(let p of f.spans){if(p.start<i)i=p.start;if(p.end>c)c=p.end}if(!Number.isFinite(i))return[0,1];return[i,Math.max(c,i+1)]}function ET(l,i,c){let f=[...new Set(l.filter((x)=>x>=i&&x<=c))].sort((x,b)=>x-b);if(f[0]!==i)f.unshift(i);if(f[f.length-1]!==c)f.push(c);if(f.length<2)return Km([i,c],[i,c]);let S=(c-i)/(f.length-1),h=f.map((x,b)=>i+b*S);return Km(f,h)}function KD(l,i,c){let f=$D(l),p=[];for(let[g,C]of f){let w=g-2000,A=C+2000,k=p[p.length-1];if(k&&w<=k[1]){if(A>k[1])k[1]=A}else p.push([w,A])}if(p.length===0)p.push([i,c]);p[0][0]=Math.max(p[0][0],i),p[p.length-1][1]=Math.min(Math.max(p[p.length-1][1],p[p.length-1][0]),c);let S=[],h=[],x=[],b=p[0][0];for(let g=0;g<p.length;g++){let[C,w]=p[g];if(g===0)S.push(C),h.push(b);else{let A=p[g-1][1],k=C-A;if(k>30000)b+=8000,x.push({t0:A,t1:C,uMid:b-4000});else b+=k;S.push(C),h.push(b)}b+=Math.max(0,w-C),S.push(w),h.push(b)}return{...Km(S,h),gaps:x}}function OT(l,i,c){let[f,p]=QD(l);if(i==="turns"){let h=(l.find((x)=>x.id==="main")?.spans??[]).filter((x)=>x.kind==="turn").map((x)=>x.start);return ET(h,f,p)}if(i==="calls"){let S=[];for(let h of l)for(let x of h.spans)if(x.kind==="model"||x.kind==="tool"||x.kind==="background")S.push(x.start,x.end);return ET(S,f,p)}if(c)return KD(l,f,p);return Km([f,p],[f,p])}var ZD=90;function WD(l){let i=10**Math.floor(Math.log10(Math.max(l,1)));for(let c of[1,2,5,10])if(i*c>=l)return i*c;return i*10}function JD(l){let i=new Date(l),c=String(i.getHours()).padStart(2,"0"),f=String(i.getMinutes()).padStart(2,"0"),p=String(i.getSeconds()).padStart(2,"0");return`${c}:${f}:${p}`}function Ci(l){let i=l<0?"-":"+",c=Math.abs(l),f=Math.floor(c/3600000),p=Math.floor(c%3600000/60000),S=Math.floor(c%60000/1000),h=Math.floor(c%1000),x=c%1000!==0,b=`${String(p).padStart(2,"0")}:${String(S).padStart(2,"0")}${x?".":""}${x?String(h).padStart(3,"0"):""}`;return f>0?`${i}${f}:${b}`:`${i}${b}`}function qT(l,i,c,f){let p=c-i;if(p<=0||f<=0)return[];let S=[],h=l.domain[0],x=WD(p*ZD/f),b=h+Math.ceil((i-h)/x)*x,L=0;for(let g=b;g<=c&&L<200;g+=x,L++){let C=l.toT(g),w=Math.round((g-h)/x)%5===0;S.push({u:g,label:w?JD(C):Ci(g-h),major:w})}return S}var Rt=Z(ue(),1),Kr=28,cb=22,Lo=18,NT=3,eE=14,BT=200,sb=10,PT=2,tE=4,aE=56,Zm=3,ib=0.3,oE=[{kind:"turn",label:u("common.input")},{kind:"model",label:u("common.model")},{kind:"tool",label:u("trace.tools")},{kind:"subagent",label:u("trace.agents")},{kind:"background",label:u("trace.bg")}];function nE(l,i){let c=new Map(l.map((b)=>[b.id,b])),f=new Set;for(let b of l)if(b.parentId)f.add(b.parentId);let p=(b)=>{let L=b.parentId;while(L){if(i.has(L))return!0;L=c.get(L)?.parentId??null}return!1},S=[],h=[],x=Kr+6;for(let b of l){if(p(b))continue;let L=b.id==="main"?0:b.id.split("/").length,g={turn:[],model:[],tool:[],subagent:[],background:[]};for(let w of b.spans)g[w.kind].push(w);let C={track:b,depth:L,hasChildren:f.has(b.id),headerY:x,lanes:[],turnSpans:g.turn,y0:x,y1:x};x+=cb;for(let{kind:w,label:A}of oE){let k=g[w],D=w==="turn"||w==="model"||w==="tool";if(k.length===0&&!(b.id==="main"&&D))continue;let M={track:b,kind:w,label:A,y:x,spans:k};C.lanes.push(M),h.push(M),x+=Lo+NT}C.y1=x-NT,S.push(C),x+=eE}return{blocks:S,lanes:h,totalHeight:Math.max(x,Kr+48)}}function rE(l,i){return l.lanes.map((c)=>{let f=c.spans.length,p=new Float64Array(f),S=new Float64Array(f),h=new Float64Array(f),x=Number.NEGATIVE_INFINITY;for(let b=0;b<f;b++){let L=c.spans[b];p[b]=i.toU(L.start),S[b]=i.toU(L.end),x=Math.max(x,S[b]),h[b]=x}return{startU:p,endU:S,maxEndU:h}})}function lE(l,i){let c=0,f=l.length;while(c<f){let p=c+f>>>1;if(l[p]<i)c=p+1;else f=p}return c}function sE(l,i){if(l===null||i===null)return l===i;if(l.kind==="span")return i.kind==="span"&&l.span===i.span;return i.kind==="marker"&&l.marker===i.marker}function _T({tracks:l,scale:i,viewport:c,onViewportChange:f,selected:p,onSelect:S,matchIds:h,collapsed:x,onToggleCollapse:b,traceStart:L}){let g=Si(),C=Ot.useRef(null),w=Ot.useRef(null),A=Ot.useRef(null),[k,D]=Ot.useState(800),[M,B]=Ot.useState(null),P=Ot.useRef(null);P.current=M;let j=Ot.useRef({clientX:0,clientY:0}),Y=Ot.useRef([]),ce=Ot.useRef(null),J=Ot.useRef(null),te=Ot.useRef(c);te.current=c;let X=Ot.useMemo(()=>nE(l,x),[l,x]),ae=Ot.useMemo(()=>rE(X,i),[X,i]);Ot.useEffect(()=>{let oe=C.current;if(!oe)return;let ve=new ResizeObserver((G)=>{let _e=Math.max(100,Math.floor(G[0].contentRect.width-BT));D(_e)});return ve.observe(oe),()=>ve.disconnect()},[]);let H=Ot.useCallback((oe,ve)=>{let[G,_e]=i.domain,Qe=Math.max(sb,ve-oe);Qe=Math.min(Qe,_e-G||sb);let Ue=oe;if(Ue<G)Ue=G;if(Ue+Qe>_e)Ue=_e-Qe;return{u0:Ue,u1:Ue+Qe}},[i]),de=Ot.useCallback((oe)=>{te.current=oe,f(oe)},[f]),xe=Ot.useCallback((oe,ve)=>{let G=k,{u0:_e,u1:Qe}=te.current,Ue=Qe-_e,dt=ve===null?0.5:Math.min(1,Math.max(0,ve/G)),et=_e+Ue*dt,ft=Ue*oe;de(H(et-ft*dt,et+ft*(1-dt)))},[k,de,H]),Ce=Ot.useCallback((oe)=>{let{u0:ve,u1:G}=te.current;de(H(ve+oe,G+oe))},[de,H]),Be=Ot.useCallback((oe)=>{let ve=i.toU(oe.start),G=i.toU(oe.end),_e=Math.max((G-ve)*0.1,sb/2);de(H(ve-_e,G+_e))},[i,de,H]);Ot.useEffect(()=>{let oe=w.current;if(!oe)return;let ve=(G)=>{G.preventDefault();let _e=oe.getBoundingClientRect(),Qe=G.clientX-_e.left;J.current=Qe,B(null);let Ue=oe.clientWidth||1,dt=()=>te.current.u1-te.current.u0;if(G.shiftKey){let et=Math.abs(G.deltaY)>=Math.abs(G.deltaX)?G.deltaY:G.deltaX;Ce(et/Ue*dt());return}if(G.deltaX!==0)Ce(G.deltaX/Ue*dt());if(G.deltaY!==0)xe(1.0015**G.deltaY,Qe)};return oe.addEventListener("wheel",ve,{passive:!1}),()=>oe.removeEventListener("wheel",ve)},[xe,Ce]);let ne=Ot.useCallback((oe,ve)=>{let G=w.current;if(!G)return null;let _e=G.getBoundingClientRect(),Qe=oe-_e.left,Ue=ve-_e.top,dt=Y.current;for(let et=dt.length-1;et>=0;et--){let ft=dt[et];if(Qe>=ft.x&&Qe<=ft.x+ft.w&&Ue>=ft.y&&Ue<=ft.y+ft.h)return ft}return null},[]),me=Ot.useCallback(()=>{let oe=A.current;if(!oe)return;let{clientX:ve,clientY:G}=j.current,_e=Math.min(ve+14,window.innerWidth-320),Qe=G+16>window.innerHeight-140?G-120:G+16;oe.style.transform=`translate(${_e}px, ${Qe}px)`},[]),ke=(oe)=>{oe.currentTarget.setPointerCapture(oe.pointerId),ce.current={pointerId:oe.pointerId,lastX:oe.clientX,moved:!1},oe.currentTarget.focus()},$e=(oe)=>{let ve=oe.currentTarget.getBoundingClientRect();J.current=oe.clientX-ve.left;let G=ce.current;if(G&&G.pointerId===oe.pointerId){let Qe=oe.clientX-G.lastX;if(Math.abs(Qe)>0){if(Math.abs(Qe)>2)G.moved=!0;G.lastX=oe.clientX;let Ue=te.current.u1-te.current.u0;Ce(-Qe/(k||1)*Ue)}B(null);return}j.current={clientX:oe.clientX,clientY:oe.clientY};let _e=ne(oe.clientX,oe.clientY);if(sE(_e,P.current))me();else B(_e)},xt=(oe)=>{let ve=ce.current;if(ce.current=null,ve?.moved)return;let G=ne(oe.clientX,oe.clientY);if(G?.kind==="span")S(G.span.id);else S(null)},W=(oe)=>{let ve=ne(oe.clientX,oe.clientY);if(ve?.kind==="span")Be(ve.span)},ze=Ot.useCallback((oe)=>{let ve=p?.span.id;if(!ve)return;for(let G of X.lanes){let _e=G.spans.findIndex((dt)=>dt.id===ve);if(_e===-1)continue;let Qe=G.spans[_e+oe];if(!Qe)return;S(Qe.id);let Ue=i.toU(Qe.start);if(Ue<c.u0||Ue>c.u1){let dt=c.u1-c.u0;f(H(Ue-dt/2,Ue+dt/2))}return}},[p,X,S,i,c,f,H]),Ct=(oe)=>{let ve=c.u1-c.u0;switch(oe.key){case"w":case"W":xe(0.7692307692307692,J.current);break;case"s":case"S":xe(1.3,J.current);break;case"a":case"A":Ce(-ve*0.2);break;case"d":case"D":Ce(ve*0.2);break;case"0":f({u0:i.domain[0],u1:i.domain[1]});break;case"f":case"F":if(p)Be(p.span);break;case"Escape":S(null);break;case",":ze(-1);break;case".":ze(1);break;default:return}oe.preventDefault()};Ot.useEffect(()=>{w.current?.focus({preventScroll:!0})},[]),Ot.useEffect(()=>{let oe=w.current;if(!oe)return;let ve=requestAnimationFrame(()=>{Y.current=uE(oe,X,ae,i,c,g,k,h)});return()=>cancelAnimationFrame(ve)},[X,ae,i,c,g,k,h]);let it=M?.kind==="span"?zT(M,X,i,c,k):null,ct=p?zT(p,X,i,c,k):null;Ot.useLayoutEffect(()=>{if(M)me()},[M,me]);let Me=M?iE(M,L,A):null,ye=Math.floor(k*devicePixelRatio),V=Math.floor(X.totalHeight*devicePixelRatio),Re={width:k,height:X.totalHeight};return Rt.jsxDEV("div",{ref:C,className:"traces-timeline",children:[Rt.jsxDEV("div",{style:{width:BT,flexShrink:0,position:"relative",height:X.totalHeight},children:X.blocks.map((oe)=>Rt.jsxDEV("div",{children:[Rt.jsxDEV("div",{style:{position:"absolute",top:oe.headerY,left:4+oe.depth*14,right:8,height:cb,display:"flex",alignItems:"center",gap:5,minWidth:0},children:[oe.hasChildren?Rt.jsxDEV("button",{type:"button",onClick:()=>b(oe.track.id),"aria-label":x.has(oe.track.id)?u("trace.expand-track",{track:oe.track.label}):u("trace.collapse-track",{track:oe.track.label}),className:"traces-chevron",children:x.has(oe.track.id)?Rt.jsxDEV(Ln,{size:12},void 0,!1,void 0,this):Rt.jsxDEV(Vs,{size:12},void 0,!1,void 0,this)},void 0,!1,void 0,this):Rt.jsxDEV("span",{style:{width:12,flexShrink:0}},void 0,!1,void 0,this),Rt.jsxDEV("span",{className:"traces-gutter-track truncate",style:{minWidth:0},children:oe.track.label},void 0,!1,void 0,this),oe.track.model&&Rt.jsxDEV("span",{className:"traces-gutter-model mono truncate",style:{flexShrink:1,minWidth:0},children:oe.track.model},void 0,!1,void 0,this)]},void 0,!0,void 0,this),oe.lanes.map((ve)=>Rt.jsxDEV("div",{className:"traces-gutter-lane",style:{top:ve.y,left:20+oe.depth*14,lineHeight:`${Lo}px`},children:ve.label},`${ve.track.id}:${ve.kind}`,!1,void 0,this))]},oe.track.id,!0,void 0,this))},void 0,!1,void 0,this),Rt.jsxDEV("div",{className:"traces-canvas-stack",style:Re,children:[Rt.jsxDEV("canvas",{ref:w,className:"traces-canvas",width:ye,height:V,style:Re,tabIndex:0,role:"application","aria-label":u("trace.canvas-aria"),onPointerDown:ke,onPointerMove:$e,onPointerUp:xt,onPointerLeave:()=>{J.current=null,B(null)},onDoubleClick:W,onKeyDown:Ct},void 0,!1,void 0,this),it&&M?.kind==="span"&&Rt.jsxDEV("div",{className:"traces-canvas-hover","aria-hidden":"true",style:{left:it.x,top:it.y,width:it.w,height:Lo,borderRadius:Zm,opacity:h===null||h.has(M.span.id)?1:ib}},void 0,!1,void 0,this),ct&&p&&Rt.jsxDEV("div",{className:"traces-canvas-selection","aria-hidden":"true",style:{left:ct.x-1,top:ct.y-1,width:ct.w+2,height:Lo+2,borderRadius:Zm,borderColor:g.selection,opacity:h===null||h.has(p.span.id)?1:ib}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Me&&UT.createPortal(Me,document.body)]},void 0,!0,void 0,this)}function ub(l,i,c,f,p){if(l.beginPath(),f>=Zm*2+1)l.roundRect(i,c,f,p,Zm);else l.rect(i,c,f,p)}function uE(l,i,c,f,p,S,h,x){let b=[],L=l.getContext("2d");if(!L)return b;let g=i.totalHeight,C=devicePixelRatio;L.setTransform(C,0,0,C,0,0),L.clearRect(0,0,h,g);let{u0:w,u1:A}=p,k=Math.max(A-w,0.000000001),D=(M)=>(M-w)/k*h;for(let M of i.blocks){let B=M.turnSpans;for(let P=0;P<B.length;P++){let j=D(f.toU(B[P].start)),Y=P+1<B.length?D(f.toU(B[P+1].start)):h;if(Y<0||j>h)continue;if(P%2===1)L.fillStyle=S.turnBand,L.fillRect(Math.max(0,j),M.y0,Math.min(h,Y)-Math.max(0,j),M.y1-M.y0);if(j>=0&&j<=h)L.strokeStyle=S.grid,L.beginPath(),L.moveTo(Math.round(j)+0.5,M.y0),L.lineTo(Math.round(j)+0.5,M.y1),L.stroke()}}L.font=`9px ${S.fontMono}`;for(let M of f.gaps){let B=D(M.uMid);if(B<-24||B>h+24)continue;L.save(),L.strokeStyle=S.grid,L.setLineDash([2,4]),L.beginPath(),L.moveTo(B,Kr),L.lineTo(B,g),L.stroke(),L.restore(),L.fillStyle=S.tick,L.textAlign="center",L.fillText(`⋯ ${At(M.t1-M.t0)}`,B,Kr-4),L.textAlign="left"}for(let M of qT(f,w,A,h)){let B=Math.round(D(M.u))+0.5;if(L.strokeStyle=S.grid,L.beginPath(),M.major)L.moveTo(B,4),L.lineTo(B,g);else L.moveTo(B,Kr-8),L.lineTo(B,Kr);if(L.stroke(),L.fillStyle=S.tick,M.major)L.fillText(M.label,B+4,11);else L.globalAlpha=0.75,L.fillText(M.label,B+3,Kr-10),L.globalAlpha=1}L.strokeStyle=S.grid,L.beginPath(),L.moveTo(0,Kr+0.5),L.lineTo(h,Kr+0.5),L.stroke(),L.font=`10px ${S.fontSans}`;for(let M=0;M<i.lanes.length;M++){let B=i.lanes[M],{startU:P,endU:j,maxEndU:Y}=c[M],ce=B.kind==="turn";for(let J=lE(Y,w);J<B.spans.length;J++){let te=P[J];if(te>A)break;let X=j[J];if(X<w)continue;let ae=B.spans[J],H=D(te),de=Math.max(PT,D(X)-H),xe=B.y,Ce=x===null||x.has(ae.id)?1:ib,Be=S.category[ae.kind];if(L.globalAlpha=Ce,ce)L.fillStyle=Be,L.globalAlpha=Ce*0.23,ub(L,H,xe,de,Lo),L.fill(),L.globalAlpha=Ce,L.fillStyle=Be,L.fillRect(H,xe,2,Lo);else L.fillStyle=Be,ub(L,H,xe,de,Lo),L.fill();if(ae.isError)L.fillStyle=S.errorSoft,ub(L,H,xe,de,Lo),L.fill(),L.fillStyle=S.error,L.fillRect(H,xe,2,Lo);if(ae.kind==="model"&&typeof ae.ttft==="number"&&ae.ttft>0&&de>20){let me=D(f.toU(ae.start+ae.ttft));if(me>H+1&&me<H+de-1)L.fillStyle="rgba(0,0,0,0.5)",L.fillRect(me,xe+3,1,Lo-6)}if(ae.unterminated)L.save(),L.strokeStyle=S.tick,L.setLineDash([2,2]),L.beginPath(),L.moveTo(H+de-0.5,xe),L.lineTo(H+de-0.5,xe+Lo),L.stroke(),L.restore();if(de>aE)L.save(),L.beginPath(),L.rect(H+3,xe,de-6,Lo),L.clip(),L.fillStyle=ce?S.tick:S.spanText,L.fillText(ae.label,H+5,xe+Lo-5),L.restore();L.globalAlpha=1;let ne=Math.max(de,tE);b.push({kind:"span",x:H-(ne-de)/2,y:xe,w:ne,h:Lo,span:ae,track:B.track})}}for(let M of i.blocks)for(let B of M.track.markers){let P=D(f.toU(B.time));if(P<-6||P>h+6)continue;let j=M.headerY+cb/2;L.fillStyle=S.marker,L.beginPath(),L.moveTo(P,j-4),L.lineTo(P+4,j),L.lineTo(P,j+4),L.lineTo(P-4,j),L.closePath(),L.fill(),b.push({kind:"marker",x:P-5,y:j-5,w:10,h:10,marker:B,track:M.track})}return b}function zT({span:l,track:i},c,f,p,S){let{u0:h,u1:x}=p,b=f.toU(l.start),L=f.toU(l.end);if(b>x||L<h)return null;let g=c.lanes.find((k)=>k.track===i&&k.kind===l.kind);if(!g)return null;let C=Math.max(x-h,0.000000001),w=(b-h)/C*S,A=(L-h)/C*S;return{x:w,y:g.y,w:Math.max(PT,A-w)}}function iE(l,i,c){let f={left:0,top:0};if(l.kind==="marker"){let{marker:S}=l;return Rt.jsxDEV("div",{ref:c,className:"traces-tooltip",style:f,children:[Rt.jsxDEV("div",{className:"traces-tooltip-title",children:S.label},void 0,!1,void 0,this),Rt.jsxDEV("div",{className:"muted num",children:[new Date(S.time).toLocaleTimeString()," (",Ci(S.time-i),")"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}let{span:p}=l;return Rt.jsxDEV("div",{ref:c,className:"traces-tooltip",style:f,children:[Rt.jsxDEV("div",{className:"traces-tooltip-title truncate",children:p.label},void 0,!1,void 0,this),Rt.jsxDEV("div",{className:"muted num",children:[At(p.end-p.start)," · ",new Date(p.start).toLocaleTimeString()," (",Ci(p.start-i),")",p.unterminated?` · ${u("trace.unterminated")}`:""]},void 0,!0,void 0,this),p.kind==="model"&&Rt.jsxDEV("div",{className:"muted num",children:[p.tokens!==void 0&&Rt.jsxDEV(Rt.Fragment,{children:[z(p.tokens)," ",u("trace.tok")]},void 0,!0,void 0,this),p.cost!==void 0&&Rt.jsxDEV(Rt.Fragment,{children:[" · $",p.cost.toFixed(4)]},void 0,!0,void 0,this),p.ttft!==void 0&&Rt.jsxDEV(Rt.Fragment,{children:[" ","· ",u("trace.ttft")," ",At(p.ttft)]},void 0,!0,void 0,this),p.isError&&Rt.jsxDEV(Rt.Fragment,{children:[" · ",u("common.error")]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),p.kind==="subagent"&&p.model&&Rt.jsxDEV("div",{className:"muted num",children:p.model},void 0,!1,void 0,this),p.detail&&Rt.jsxDEV("div",{className:"traces-tooltip-detail",children:p.detail},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var Mn=Z(gt(),1);var Ga=Z(ue(),1),wi=28,HT=20,cE=340;function dE(l){let i=[];for(let c of l){let f=c.id==="main"?0:c.id.split("/").length;for(let p of c.spans)i.push({key:p.id,time:p.start,span:p,track:c,depth:f});for(let p=0;p<c.markers.length;p++){let S=c.markers[p];i.push({key:`${c.id}:marker:${p}`,time:S.time,marker:S,track:c,depth:f})}}return i.sort((c,f)=>c.time-f.time),i}var FT=Mn.memo(function({tracks:i,selection:c,onSelect:f,search:p,matchIds:S,traceStart:h}){let x=Si(),b=Mn.useRef(null),[L,g]=Mn.useState(0),C=Mn.useMemo(()=>dE(i),[i]),w=Mn.useMemo(()=>{if(!S)return C;let M=p.trim().toLowerCase();return C.filter((B)=>B.span?S.has(B.span.id):(B.marker?.label??"").toLowerCase().includes(M))},[C,p,S]);Mn.useEffect(()=>{if(!c)return;let M=b.current;if(!M)return;let B=w.findIndex((j)=>j.span?.id===c);if(B===-1)return;let P=B*wi;if(P<M.scrollTop||P+wi>M.scrollTop+M.clientHeight)M.scrollTop=Math.max(0,P-M.clientHeight/2)},[c,w]);let A=Math.max(0,Math.floor(L/wi)-HT),k=Math.min(w.length,Math.ceil((L+cE)/wi)+HT),D=w.slice(A,k);return Ga.jsxDEV("div",{ref:b,onScroll:(M)=>g(M.currentTarget.scrollTop),className:"traces-list",children:[Ga.jsxDEV("div",{style:{height:w.length*wi,position:"relative"},children:Ga.jsxDEV("div",{style:{position:"absolute",top:A*wi,left:0,right:0},children:D.map((M)=>{let B=M.span,P=B!==void 0&&B.id===c,j=M.span?x.category[M.span.kind]:x.marker,Y=M.span?.label??M.marker?.label??"",ce=M.span?.detail,J=M.span?At(M.span.end-M.span.start):"",te=M.span?.kind??M.marker?.kind??"",X=Ga.jsxDEV(Ga.Fragment,{children:[Ga.jsxDEV("span",{className:"traces-kind",style:{"--traces-kind-color":j},children:te},void 0,!1,void 0,this),M.depth>0&&Ga.jsxDEV("span",{className:"traces-row-track mono truncate",title:M.track.label,children:M.track.id},void 0,!1,void 0,this),Ga.jsxDEV("span",{className:"traces-row-label truncate",children:Y},void 0,!1,void 0,this),ce&&Ga.jsxDEV("span",{className:"traces-row-detail truncate",children:ce},void 0,!1,void 0,this),Ga.jsxDEV("span",{className:"traces-row-meta num",children:[M.span?.isError&&Ga.jsxDEV("span",{className:"tone-bad",children:u("common.error")},void 0,!1,void 0,this),Ga.jsxDEV("span",{children:J},void 0,!1,void 0,this),Ga.jsxDEV("span",{children:Ci(M.time-h)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),ae={paddingLeft:12+M.depth*12};return B?Ga.jsxDEV("button",{type:"button",onClick:()=>f(B.id),className:"traces-row","data-selected":P?"true":"false",style:ae,children:X},M.key,!1,void 0,this):Ga.jsxDEV("div",{className:"traces-row","data-static":"true",style:ae,children:X},M.key,!1,void 0,this)})},void 0,!1,void 0,this)},void 0,!1,void 0,this),w.length===0&&Ga.jsxDEV(wt,{title:u("trace.no-matching-events")},void 0,!1,void 0,this)]},void 0,!0,void 0,this)});var Je=Z(ue(),1),fE=[{value:"time",label:u("common.duration"),title:u("trace.mode-time-title")},{value:"turns",label:u("trace.turns"),title:u("trace.mode-turns-title")},{value:"calls",label:u("trace.calls"),title:u("trace.mode-calls-title")}],pE=[{kind:"turn",label:u("common.input")},{kind:"model",label:u("common.model")},{kind:"tool",label:u("trace.tool")},{kind:"subagent",label:u("trace.agent")},{kind:"background",label:u("trace.background")}];function GT({file:l,active:i,onBack:c}){let f=Ft(["trace",l],({signal:Me},ye)=>h1(l,Me,ye),{pollMs:15000,enabled:i}),p=f.stale?null:f.data,[S,h]=Dt.useState("time"),[x,b]=Dt.useState(!0),[L,g]=Dt.useState(null),[C,w]=Dt.useState(!1),[A,k]=Dt.useState(""),[D,M]=Dt.useState(0),[B,P]=Dt.useState(new Set),[j,Y]=Dt.useState(null),ce=Dt.useMemo(()=>p?.tracks??[],[p]),J=Dt.useMemo(()=>OT(ce,S,x),[ce,S,x]),te=Dt.useRef(J),X=Dt.useRef(null);Dt.useEffect(()=>{if(!p)return;if(X.current===p.file)return;X.current=p.file,g(null),k(""),Y(null);let Me=new Set;for(let ye of p.tracks)if((ye.id==="main"?0:ye.id.split("/").length)>=1)Me.add(ye.id);P(Me)},[p]),Dt.useEffect(()=>{let Me=te.current;te.current=J,Y((ye)=>{if(!ye)return ye;let V=Me.toT(ye.u0),Re=Me.toT(ye.u1),oe=J.toU(V),ve=J.toU(Re);return ve-oe>0?{u0:oe,u1:ve}:null})},[J]);let ae=Dt.useMemo(()=>j??{u0:J.domain[0],u1:J.domain[1]},[j,J]),H=Dt.useMemo(()=>{let Me=[];for(let ye of ce)for(let V of ye.spans)Me.push({span:V,track:ye});return Me.sort((ye,V)=>ye.span.start-V.span.start),Me},[ce]),de=Dt.useMemo(()=>{let Me=A.trim().toLowerCase();if(!Me)return[];return H.filter(({span:ye})=>`${ye.label} ${ye.detail??""}`.toLowerCase().includes(Me))},[H,A]),xe=Dt.useMemo(()=>A.trim()?new Set(de.map(({span:Me})=>Me.id)):null,[de,A]),Ce=Dt.useCallback((Me)=>{let ye=J.toU(Me.start),V=J.toU(Me.end);Y((Re)=>{let oe=Re??{u0:J.domain[0],u1:J.domain[1]};if(ye>=oe.u0&&V<=oe.u1)return Re;let ve=oe.u1-oe.u0,G=(ye+V)/2,[_e,Qe]=J.domain,Ue=G-ve/2;if(Ue<_e)Ue=_e;if(Ue+ve>Qe)Ue=Math.max(_e,Qe-ve);return{u0:Ue,u1:Ue+ve}})},[J]),Be=Dt.useCallback((Me)=>{g(Me);let ye=H.find(({span:V})=>V.id===Me);if(ye)Ce(ye.span)},[H,Ce]),ne=Dt.useCallback((Me)=>{g(Me),w(Me!==null)},[]),me=Dt.useCallback((Me)=>{if(de.length===0)return;let ye=((D+Me)%de.length+de.length)%de.length;M(ye),Be(de[ye].span.id)},[de,D,Be]),ke=Dt.useCallback((Me)=>{P((ye)=>{let V=new Set(ye);if(V.has(Me))V.delete(Me);else V.add(Me);return V})},[]),$e=Dt.useMemo(()=>{if(!L)return null;return H.find(({span:Me})=>Me.id===L)??null},[L,H]),xt=Dt.useCallback((Me)=>{let ye=ce.find((Re)=>Re.id===Me),V=ye?.spans[0];if(P((Re)=>{let oe=new Set(Re),ve=ye;while(ve?.parentId)oe.delete(ve.parentId),ve=ce.find((G)=>G.id===ve?.parentId);return oe}),V)Be(V.id)},[ce,Be]),W=Dt.useCallback((Me)=>{if(!Me){P(new Set);return}let ye=new Set;for(let V of ce)if(V.id!=="main")ye.add(V.id);P(ye)},[ce]),ze=Dt.useCallback((Me)=>{Be(Me),w(!0)},[Be]),Ct=Dt.useCallback(()=>w(!1),[]),it=p?.startedAt??0,ct={...f,data:p};return Je.jsxDEV("div",{className:"stack traces-view",children:[Je.jsxDEV("div",{children:Je.jsxDEV("button",{type:"button",className:"btn","data-variant":"ghost","data-size":"sm",onClick:c,children:[Je.jsxDEV(cd,{size:14,"aria-hidden":"true"},void 0,!1,void 0,this),u("trace.sessions")]},void 0,!0,void 0,this)},void 0,!1,void 0,this),Je.jsxDEV(ra,{title:Je.jsxDEV("span",{className:"traces-title truncate",children:p?.title??l.split("/").pop()},void 0,!1,void 0,this),description:p?.cwd?Je.jsxDEV("span",{className:"mono",children:p.cwd},void 0,!1,void 0,this):void 0,actions:Je.jsxDEV("button",{type:"button",className:"btn","data-variant":"ghost","data-icon":"true",onClick:f.refetch,"aria-label":u("trace.refresh"),title:u("trace.refresh"),children:Je.jsxDEV(jl,{size:14,className:f.refreshing?"traces-spin":void 0},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),Je.jsxDEV(Ge,{query:ct,skeleton:Je.jsxDEV(zt,{height:420},void 0,!1,void 0,this),children:(Me)=>Je.jsxDEV(Je.Fragment,{children:[Je.jsxDEV(DT,{summary:Me.summary},void 0,!1,void 0,this),Je.jsxDEV(Ye,{index:1,title:u("trace.timeline"),description:u("trace.timeline-hint"),actions:Je.jsxDEV(Je.Fragment,{children:[Je.jsxDEV("button",{type:"button",className:"btn","data-variant":"ghost","data-size":"sm",onClick:()=>W(!1),children:u("trace.expand-all")},void 0,!1,void 0,this),Je.jsxDEV("button",{type:"button",className:"btn","data-variant":"ghost","data-size":"sm",onClick:()=>W(!0),children:u("trace.collapse-all")},void 0,!1,void 0,this)]},void 0,!0,void 0,this),children:Je.jsxDEV("div",{className:"stack",children:[Je.jsxDEV("div",{className:"traces-toolbar",children:[Je.jsxDEV(_a,{options:fE,value:S,onChange:h,size:"sm","aria-label":u("trace.axis-mode")},void 0,!1,void 0,this),S==="time"&&Je.jsxDEV("label",{className:"traces-check",children:[Je.jsxDEV("input",{type:"checkbox",checked:x,onChange:(ye)=>b(ye.target.checked)},void 0,!1,void 0,this),u("trace.compress-idle")]},void 0,!0,void 0,this),Je.jsxDEV("div",{className:"traces-search",children:[Je.jsxDEV(cr,{value:A,onChange:(ye)=>{k(ye),M(0)},placeholder:u("trace.search-placeholder"),width:200},void 0,!1,void 0,this),A.trim()&&Je.jsxDEV(Je.Fragment,{children:[Je.jsxDEV("span",{className:"num muted traces-match-count",children:de.length===0?"0":`${D%Math.max(de.length,1)+1}/${de.length}`},void 0,!1,void 0,this),Je.jsxDEV("button",{type:"button",className:"btn","data-variant":"ghost","data-size":"sm","data-icon":"true",onClick:()=>me(-1),"aria-label":u("trace.previous-match"),disabled:de.length===0,children:Je.jsxDEV(md,{size:14},void 0,!1,void 0,this)},void 0,!1,void 0,this),Je.jsxDEV("button",{type:"button",className:"btn","data-variant":"ghost","data-size":"sm","data-icon":"true",onClick:()=>me(1),"aria-label":u("trace.next-match"),disabled:de.length===0,children:Je.jsxDEV(Ln,{size:14},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Je.jsxDEV("div",{className:"traces-legend",children:pE.map((ye)=>Je.jsxDEV("span",{className:"traces-legend-item",children:[Je.jsxDEV("span",{className:"swatch",style:{background:`var(${nu[ye.kind]})`}},void 0,!1,void 0,this),ye.label]},ye.kind,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Je.jsxDEV(RT,{tracks:ce,scale:J,viewport:ae,onViewportChange:Y},void 0,!1,void 0,this),Je.jsxDEV(_T,{tracks:ce,scale:J,viewport:ae,onViewportChange:Y,selected:$e,onSelect:ne,matchIds:xe,collapsed:B,onToggleCollapse:ke,traceStart:it},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),Je.jsxDEV(Ye,{index:2,title:u("trace.transcript"),description:u("trace.transcript-description"),flush:!0,children:Je.jsxDEV(FT,{tracks:ce,selection:L,onSelect:ze,search:A,matchIds:xe,traceStart:it},void 0,!1,void 0,this)},void 0,!1,void 0,this),Je.jsxDEV(TT,{toolStats:Me.summary.toolStats,index:3},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),Je.jsxDEV(MT,{span:C?$e?.span??null:null,track:$e?.track??null,onClose:Ct,onOpenChildTrack:xt},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var ea=Z(ue(),1),VT=200;function mE({models:l}){if(l.length===0)return ea.jsxDEV("span",{className:"dim",children:"-"},void 0,!1,void 0,this);return ea.jsxDEV("span",{className:"traces-models",title:l.join(`
235
+ <%s key={someKey} {...props} />`,it,ye,V,ye),xt[ye+it]=!0)}if(ye=null,Ct!==void 0&&(c(Ct),ye=""+Ct),h(ze)&&(c(ze.key),ye=""+ze.key),"key"in ze){Ct={};for(var Re in ze)Re!=="key"&&(Ct[Re]=ze[Re])}else Ct=ze;return ye&&x(Ct,typeof W==="function"?W.displayName||W.name||"Unknown":W),L(W,ye,Ct,p(),ct,Me)}function C(W){w(W)?W._store&&(W._store.validated=1):typeof W==="object"&&W!==null&&W.$$typeof===X&&(W._payload.status==="fulfilled"?w(W._payload.value)&&W._payload.value._store&&(W._payload.value._store.validated=1):W._store&&(W._store.validated=1))}function w(W){return typeof W==="object"&&W!==null&&W.$$typeof===A}var A=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),D=Symbol.for("react.fragment"),M=Symbol.for("react.strict_mode"),B=Symbol.for("react.profiler"),P=Symbol.for("react.consumer"),j=Symbol.for("react.context"),Y=Symbol.for("react.forward_ref"),ce=Symbol.for("react.suspense"),J=Symbol.for("react.suspense_list"),te=Symbol.for("react.memo"),X=Symbol.for("react.lazy"),ae=Symbol.for("react.activity"),H=Symbol.for("react.client.reference"),de=Ys.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,xe=Object.prototype.hasOwnProperty,Ce=Array.isArray,Be=console.createTask?console.createTask:function(){return null};Ys={react_stack_bottom_frame:function(W){return W()}};var ne,me={},ke=Ys.react_stack_bottom_frame.bind(Ys,S)(),$e=Be(f(S)),xt={};rM.Fragment=D,rM.jsxDEV=function(W,ze,Ct,it){var ct=1e4>de.recentlyCreatedOwnerStacks++;return g(W,ze,Ct,it,ct?Error("react-stack-top-frame"):ke,ct?Be(f(W)):$e)}})()});var XT=Z(ak(),1);var Ti=Z(gt(),1);var cm=Z(gt(),1);var ok=(l)=>l?.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();function nk(l,i,c=[]){if(i==null)throw Error("[lucide]: iconNode is required when icon name is used");return{name:ok(l),size:24,node:i,...c.length>0?{aliases:c}:{}}}var rk=(l)=>{let i="",c=!1;for(let f of l){if(f==="-"||f==="_"||f<=" "){c=i.length>0;continue}if(i.length===0)i+=f.toLowerCase();else i+=c?f.toUpperCase():f;c=!1}return i};var lk=(l)=>{let i=rk(l);return i.charAt(0).toUpperCase()+i.slice(1)};var sd=Z(gt(),1);var ld=(...l)=>l.filter((i,c,f)=>Boolean(i)&&i.trim()!==""&&f.indexOf(i)===c).join(" ").trim();var _l={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};function qv(l){return l!==null&&l!==void 0}function sk(l,i={}){let c=i.attributeNames??{},f=(w)=>c[w]??w,p=l.size??l.width??_l.width,S=l.size??l.height??_l.height,h=l.aliases?.filter((w)=>typeof w==="string"&&w.trim()!=="").map((w)=>`lucide-${w}`)??[],x=[...l.name?[`lucide-${l.name}`]:[],...h],b=i.className?.split(" ").filter(Boolean)??[],L=i.includeDefaultClasses===!1?ld(...b):ld("lucide",...x,...b),g=i.absoluteStrokeWidth?Number(i.strokeWidth??_l["stroke-width"])*Number(l.size??l.width??_l.width)/Number(i.size??i.width??_l.width):i.strokeWidth??_l["stroke-width"];return["svg",{...Object.entries(_l).reduce((w,[A,k])=>(w[f(A)]=k,w),{}),..."color"in i&&i.color&&{[f("stroke")]:i.color},..."size"in i&&qv(i.size)&&{[f("width")]:i.size,[f("height")]:i.size},..."width"in i&&qv(i.width)&&{[f("width")]:i.width},..."height"in i&&qv(i.height)&&{[f("height")]:i.height},[f("stroke-width")]:g,...L&&{[f("class")]:L},[f("viewBox")]:`0 0 ${p} ${S}`,...i.hasA11yProp===!1?{[f("aria-hidden")]:"true"}:{},..."attributes"in i&&i.attributes},l.node.map((w)=>{let[A,k,D]=w,M=i.nonScalingStroke?{[f("vector-effect")]:"non-scaling-stroke",...k}:k;return D?[A,M,D]:[A,M]})]}function uk(l,i={}){return sk(l,{...i,attributeNames:{...i.attributeNames,class:"className","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","vector-effect":"vectorEffect"}})}var ik=(l)=>{for(let i in l)if(i.startsWith("aria-")||i==="role"||i==="title")return!0;return!1};var ii=Z(gt(),1),F2=ii.createContext({});var ck=()=>ii.useContext(F2);var dk=sd.forwardRef(({color:l,size:i,width:c,height:f,strokeWidth:p,absoluteStrokeWidth:S,nonScalingStroke:h,className:x="",children:b,iconNode:L=[],icon:g={node:L,aliases:[],size:24},...C},w)=>{let{size:A=24,strokeWidth:k=2,absoluteStrokeWidth:D=!1,nonScalingStroke:M=!1,color:B="currentColor",className:P=""}=ck()??{},j=Boolean(b)||ik(C),[Y,ce,J=[]]=uk(g,{color:l??B,width:c??i??A,height:f??i??A,strokeWidth:p??k,absoluteStrokeWidth:S??D,nonScalingStroke:h??M,className:ld(P,x),hasA11yProp:j,attributes:C});return sd.createElement(Y,{ref:w,...ce},[...J.map(([te,X])=>sd.createElement(te,X)),...Array.isArray(b)?b:[b]])});function Se(l,i=[],c=[]){let f=typeof l==="string"?nk(l,i,c):l,p=cm.forwardRef(({className:S,...h},x)=>cm.createElement(dk,{ref:x,icon:f,className:S,...h}));if(f.name)p.displayName=lk(f.name);return p}var fk={name:"circle-alert",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],aliases:["alert-circle"]};fk.node;var Hl=Se(fk);var pk={name:"face-slightly-frowning",size:24,node:[["path",{d:"M15 10V9",key:"4dkmfx"}],["path",{d:"M9 10V9",key:"1lazqi"}],["path",{d:"M9 16a5 5 0 016 0",key:"34mdxb"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],aliases:["frown"]};pk.node;var Fl=Se(pk);var mk={name:"plug-zap",size:24,node:[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]],aliases:["plug-zap-2"]};mk.node;var Gl=Se(mk);var hk={name:"sparkles",size:24,node:[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],aliases:["stars"]};hk.node;var lr=Se(hk);var gk={name:"square-chart-gantt",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 8h7",key:"kbo1nt"}],["path",{d:"M8 12h6",key:"ikassy"}],["path",{d:"M11 16h5",key:"oq65wt"}]],aliases:["gantt-chart-square","square-gantt-chart"]};gk.node;var Sn=Se(gk);var yk={name:"triangle-alert",size:24,node:[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],aliases:["alert-triangle"]};yk.node;var Vl=Se(yk);var vk={name:"activity",size:24,node:[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]};vk.node;var ud=Se(vk);var bk={name:"arrow-down",size:24,node:[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]};bk.node;var id=Se(bk);var xk={name:"arrow-left",size:24,node:[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]};xk.node;var cd=Se(xk);var Sk={name:"arrow-right",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]};Sk.node;var dd=Se(Sk);var Lk={name:"arrow-up-right",size:24,node:[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]};Lk.node;var fd=Se(Lk);var Ck={name:"arrow-up",size:24,node:[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]};Ck.node;var pd=Se(Ck);var wk={name:"check",size:24,node:[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]};wk.node;var Gs=Se(wk);var kk={name:"chevron-down",size:24,node:[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]};kk.node;var Vs=Se(kk);var Tk={name:"chevron-left",size:24,node:[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]};Tk.node;var md=Se(Tk);var Ik={name:"chevron-right",size:24,node:[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]};Ik.node;var Ln=Se(Ik);var Rk={name:"coins",size:24,node:[["path",{d:"M13.744 17.736a6 6 0 1 1-7.48-7.48",key:"bq4yh3"}],["path",{d:"M15 6h1v4",key:"11y1tn"}],["path",{d:"m6.134 14.768.866-.5 2 3.464",key:"17snzx"}],["circle",{cx:"16",cy:"8",r:"6",key:"14bfc9"}]]};Rk.node;var hd=Se(Rk);var Ak={name:"copy",size:24,node:[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]};Ak.node;var js=Se(Ak);var Mk={name:"cpu",size:24,node:[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]]};Mk.node;var gd=Se(Mk);var Dk={name:"folder-git-2",size:24,node:[["path",{d:"M18 19a5 5 0 0 1-5-5v8",key:"sz5oeg"}],["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]]};Dk.node;var yd=Se(Dk);var Ek={name:"git-branch",size:24,node:[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]]};Ek.node;var vd=Se(Ek);var Ok={name:"inbox",size:24,node:[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]};Ok.node;var bd=Se(Ok);var qk={name:"layout-grid",size:24,node:[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]};qk.node;var xd=Se(qk);var Nk={name:"menu",size:24,node:[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]]};Nk.node;var Sd=Se(Nk);var Bk={name:"monitor",size:24,node:[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]};Bk.node;var Ld=Se(Bk);var zk={name:"moon",size:24,node:[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]};zk.node;var Cd=Se(zk);var Uk={name:"refresh-cw",size:24,node:[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]};Uk.node;var jl=Se(Uk);var Pk={name:"rotate-cw",size:24,node:[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]};Pk.node;var wd=Se(Pk);var _k={name:"search",size:24,node:[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]};_k.node;var kd=Se(_k);var Hk={name:"sun",size:24,node:[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]};Hk.node;var Td=Se(Hk);var Fk={name:"wrench",size:24,node:[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]]};Fk.node;var Id=Se(Fk);var Gk={name:"x",size:24,node:[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]};Gk.node;var nn=Se(Gk);var yi=Z(gt(),1);function Nv(l){let i=l?.trim().toLowerCase()??"";if(i==="zh"||i.startsWith("zh-")||i.startsWith("zh_"))return"zh-CN";return"en"}function Vk(l){for(let i of l??[]){let c=Nv(i);if(c!=="en")return c}return"en"}function G2(l,i={}){return l.replace(/\{([\w.-]+)\}/g,(c,f)=>{let p=i[f];return p===void 0?c:String(p)})}function jk(l,i,c,f={}){let p=c[l]?.[i]??c.en?.[i];if(p===void 0)return console.warn(`[stats.i18n] missing translation: ${i}`),i;return G2(p,f)}var dm={en:{"nav.usage":"Usage","nav.activity":"Activity","nav.insights":"Insights","nav.overview":"Overview","nav.models":"Models","nav.providers":"Providers","nav.costs":"Costs","nav.requests":"Requests","nav.errors":"Errors","nav.traces":"Traces","nav.tools":"Tools","nav.frustration":"Frustration","nav.projects":"Projects","nav.gain":"Gain","nav.dashboard":"zetacode stats","nav.breadcrumb-stats":"stats","nav.pages":"Pages","nav.open-navigation":"Open navigation"},"zh-CN":{"nav.usage":"用量","nav.activity":"活动","nav.insights":"洞察","nav.overview":"总览","nav.models":"模型","nav.providers":"服务商","nav.costs":"费用","nav.requests":"请求","nav.errors":"错误","nav.traces":"调用链","nav.tools":"工具","nav.frustration":"情绪压力","nav.projects":"项目","nav.gain":"收益","nav.dashboard":"zeta 统计","nav.breadcrumb-stats":"统计","nav.pages":"导航","nav.open-navigation":"打开导航"}};var fm={en:{"common.provider":"Provider","common.providers":"Providers","common.model":"Model","common.models":"Models","common.requests":"Requests","common.request":"Request","common.tokens":"Tokens","common.share":"Share","common.cost":"Cost","common.error-rate":"Error rate","common.tokens-per-second":"Tokens/s","common.output-tokens-per-second":"Output tokens/s","common.premium":"Premium","common.premium-requests":"Premium requests","common.duration":"Duration","common.started":"Started","common.request-id":"Request id","common.session-entry":"Session entry","common.entry-id":"Entry id","common.input":"Input","common.output":"Output","common.output-message":"Output message","common.cache-read":"Cache read","common.cache-write":"Cache write","common.project":"Project","common.pages":"Pages","common.filter":"Filter…","common.no-data-in-range":"No data in this range","common.nothing-here-yet":"Nothing here yet","common.show-more":"Show more","common.total":"Total","common.average":"Average","common.unknown":"Unknown","common.root":"(root)","common.other-n":"Other ({count})","common.time-range":"Time range","common.range-1h":"1h","common.range-24h":"24h","common.range-7d":"7d","common.range-30d":"30d","common.range-90d":"90d","common.range-all":"All","common.window-1h":"the last hour","common.window-24h":"the last 24 hours","common.window-7d":"the last 7 days","common.window-30d":"the last 30 days","common.window-90d":"the last 90 days","common.window-all":"all time","common.copy":"Copy","common.copied":"Copied","common.close":"Close","common.cancel":"Cancel","common.aborted":"Aborted","common.failed":"Failed","common.error":"Error","shell.live":"Live","shell.reconnecting":"Reconnecting","shell.syncing":"Syncing","shell.sync-failed":"Sync failed","shell.indexing":"Indexing","shell.lost-connection":"Lost the live connection to the stats server; retrying","shell.ingesting":"Ingesting session files","shell.building-rollups":"Building hourly rollups; older ranges fill in as it goes","shell.sync-now":"Click to sync session files now","shell.just-now":"just now","shell.system-theme":"System theme","shell.dark-theme":"Dark theme","shell.light-theme":"Light theme","shell.range-suffix":"range","shell.jump-hint":"then letter to jump"},"zh-CN":{"common.provider":"服务商","common.providers":"服务商","common.model":"模型","common.models":"模型","common.requests":"请求","common.request":"请求","common.tokens":"Token","common.share":"占比","common.cost":"费用","common.error-rate":"错误率","common.tokens-per-second":"Token/秒","common.output-tokens-per-second":"输出 Token/秒","common.premium":"溢价","common.premium-requests":"溢价请求","common.duration":"耗时","common.started":"开始时间","common.request-id":"请求 ID","common.session-entry":"会话条目","common.entry-id":"条目 ID","common.input":"输入","common.output":"输出","common.output-message":"输出消息","common.cache-read":"缓存读取","common.cache-write":"缓存写入","common.project":"项目","common.pages":"页数","common.filter":"筛选…","common.no-data-in-range":"该时间范围内没有数据","common.nothing-here-yet":"暂无数据","common.show-more":"显示更多","common.total":"合计","common.average":"平均","common.unknown":"未知","common.root":"(根目录)","common.other-n":"其他({count})","common.time-range":"时间范围","common.range-1h":"1 小时","common.range-24h":"24 小时","common.range-7d":"7 天","common.range-30d":"30 天","common.range-90d":"90 天","common.range-all":"全部","common.window-1h":"最近 1 小时","common.window-24h":"最近 24 小时","common.window-7d":"最近 7 天","common.window-30d":"最近 30 天","common.window-90d":"最近 90 天","common.window-all":"全部时间","common.copy":"复制","common.copied":"已复制","common.close":"关闭","common.cancel":"取消","common.aborted":"已中止","common.failed":"失败","common.error":"错误","shell.live":"实时","shell.reconnecting":"重新连接中","shell.syncing":"同步中","shell.sync-failed":"同步失败","shell.indexing":"建立索引","shell.lost-connection":"与统计服务的实时连接已断开,正在重试","shell.ingesting":"正在导入会话文件","shell.building-rollups":"正在构建小时汇总;更早的时间范围会逐步补全","shell.sync-now":"点击立即同步会话文件","shell.just-now":"刚刚","shell.system-theme":"跟随系统","shell.dark-theme":"深色主题","shell.light-theme":"浅色主题","shell.range-suffix":"范围","shell.jump-hint":"再按字母跳转"}};var pm={en:{"overview.title":"Overview","overview.description":"Everything zeta did across your sessions in {window}.","overview.api-equivalent-cost":"API-equivalent cost","overview.api-cost-title":"What this usage would cost at public API rates","overview.unpriced-n":"{count} unpriced","overview.failed-n":"{count} failed","overview.conversation-tokens":"Conversation tokens","overview.tokens-title":"Uncached input + cache reads + cache writes + output","overview.output-n":"{count} output","overview.cache-rate":"Cache rate","overview.cache-rate-title":"Cache reads ÷ (uncached input + cache reads)","overview.cache-saved":"{value} saved","overview.succeeded-n":"{count} succeeded","overview.uncached-input":"Uncached input","overview.avg-latency":"Avg latency","overview.avg-ttft":"Avg TTFT","overview.activity":"Activity","overview.per-5m":"Per 5 minutes","overview.per-hour":"Per hour","overview.per-day":"Per day","overview.succeeded":"Succeeded","overview.api-equivalent":"API-equivalent","overview.token-mix":"Token mix","overview.token-mix-description":"Where conversation tokens went","overview.by-agent":"By agent","overview.requests-short":"{count} req","overview.main-agent":"Main agent","overview.subagents":"Subagents","overview.advisor":"Advisor","overview.latest-requests":"Latest requests","overview.latest-requests-description":"Most recent model calls across every session","overview.all-requests":"All requests","overview.when":"When","overview.status":"Status","overview.ok":"OK"},"zh-CN":{"overview.title":"概览","overview.description":"在{window}内,zeta 在你的所有会话中完成的一切。","overview.api-equivalent-cost":"API 等效费用","overview.api-cost-title":"这些用量按公开 API 费率计算所需的费用","overview.unpriced-n":"{count} 个未定价","overview.failed-n":"{count} 个失败","overview.conversation-tokens":"对话 Token","overview.tokens-title":"未缓存输入 + 缓存读取 + 缓存写入 + 输出","overview.output-n":"{count} 输出","overview.cache-rate":"缓存命中率","overview.cache-rate-title":"缓存读取 ÷(未缓存输入 + 缓存读取)","overview.cache-saved":"节省 {value}","overview.succeeded-n":"{count} 个成功","overview.uncached-input":"未缓存输入","overview.avg-latency":"平均延迟","overview.avg-ttft":"平均 TTFT","overview.activity":"活动","overview.per-5m":"每 5 分钟","overview.per-hour":"每小时","overview.per-day":"每天","overview.succeeded":"成功","overview.api-equivalent":"API 等效","overview.token-mix":"Token 构成","overview.token-mix-description":"对话 Token 的去向","overview.by-agent":"按代理","overview.requests-short":"{count} 次请求","overview.main-agent":"主代理","overview.subagents":"子代理","overview.advisor":"顾问","overview.latest-requests":"最新请求","overview.latest-requests-description":"所有会话中最近的模型调用","overview.all-requests":"全部请求","overview.when":"时间","overview.status":"状态","overview.ok":"正常"}};var mm={en:{"models.subtitle":"Which models did the work in {window}, and how fast they answered.","models.empty-title":"No model usage in this range","models.empty-hint":"Pick a wider range in the top bar.","models.used":"Models used","models.across-providers-one":"across {count} provider","models.across-providers":"across {count} providers","models.most-used":"Most used","models.most-used-hint":"{share} of requests · {provider}","models.failed-n":"{count} failed","models.api-cost":"API-equivalent cost","models.api-cost-title":"What this usage would cost at public API rates","models.unpriced-n":"{count} unpriced","models.request-share":"Request share","models.share-desc":"Each model's share of requests per {bucket}","models.count-desc":"Requests per {bucket}, stacked by model","models.share-mode-aria":"Share chart mode","models.all-models":"All models","models.table-desc":"Click a row for latency and throughput over time","models.cost-title":"API-equivalent estimate at public rates","models.tokens-title":"Uncached input + cache reads + cache writes + output","models.cache-rate":"Cache rate","models.cache-title":"Cache reads ÷ (uncached input + cache reads)","models.errors":"Errors","models.tps-title":"Average output tokens per second","models.ttft":"TTFT","models.ttft-title":"Average time to first token","models.trend":"Trend","models.trend-title":"Requests per {bucket}","models.efficiency":"Efficiency","models.latency":"Latency","models.cache-savings":"Cache savings","models.avg-duration":"Avg duration","models.avg-ttft":"Avg TTFT","models.uncached-input":"Uncached input","models.first-last-seen":"First seen {first} · last seen {last}","models.performance-per-bucket":"Performance per active {bucket}","models.no-samples-title":"No performance samples","models.no-samples-hint":"Timing is recorded for streamed responses.","models.tok-per-second":"{value} tok/s","models.bucket-5m":"5 minutes","models.bucket-hour":"hour","models.bucket-day":"day"},"zh-CN":{"models.subtitle":"在{window}内哪些模型完成了工作,以及它们的响应速度如何。","models.empty-title":"该时间范围内没有模型用量","models.empty-hint":"请在顶部栏选择更宽的时间范围。","models.used":"使用模型数","models.across-providers-one":"覆盖 {count} 个服务商","models.across-providers":"覆盖 {count} 个服务商","models.most-used":"使用最多","models.most-used-hint":"{share} 请求占比 · {provider}","models.failed-n":"{count} 个失败","models.api-cost":"API 等价费用","models.api-cost-title":"按公开 API 价格计算这笔用量的费用","models.unpriced-n":"{count} 个未定价","models.request-share":"请求占比","models.share-desc":"每个{bucket}中各模型的请求占比","models.count-desc":"每个{bucket}的请求数,按模型堆叠","models.share-mode-aria":"占比图表模式","models.all-models":"所有模型","models.table-desc":"点击某行可查看延迟与吞吐随时间的变化","models.cost-title":"按公开价格估算的 API 等价费用","models.tokens-title":"未缓存输入 + 缓存读取 + 缓存写入 + 输出","models.cache-rate":"缓存命中率","models.cache-title":"缓存读取 ÷(未缓存输入 + 缓存读取)","models.errors":"错误","models.tps-title":"平均每秒输出 Token 数","models.ttft":"首 Token 延迟","models.ttft-title":"平均首 Token 延迟","models.trend":"趋势","models.trend-title":"每个{bucket}的请求数","models.efficiency":"效率","models.latency":"延迟","models.cache-savings":"缓存节省","models.avg-duration":"平均耗时","models.avg-ttft":"平均首 Token 延迟","models.uncached-input":"未缓存输入","models.first-last-seen":"首次出现 {first} · 最近出现 {last}","models.performance-per-bucket":"每个活跃{bucket}的性能","models.no-samples-title":"没有性能样本","models.no-samples-hint":"只有流式响应会记录耗时。","models.tok-per-second":"{value} Token/秒","models.bucket-5m":"5 分钟","models.bucket-hour":"小时","models.bucket-day":"天"}};var hm={en:{"providers.description":"Burn, reliability and subscription headroom per provider over {window}.","providers.most-tokens":"Most tokens: {provider}","providers.failed-n":"{count} failed","providers.succeeded-n":"{count} succeeded","providers.tokens-title":"Uncached input + cache reads + cache writes + output","providers.api-equivalent-cost":"API-equivalent cost","providers.api-cost-title":"What this usage would cost at public API rates","providers.unpriced-n":"{count} unpriced","providers.totals":"Provider totals","providers.totals-description":"Cost is an API-equivalent estimate. Select a row for its token mix.","providers.totals-description-unpriced-one":"Cost is an API-equivalent estimate and excludes {count} unpriced subscription request. Select a row for its token mix.","providers.totals-description-unpriced-n":"Cost is an API-equivalent estimate and excludes {count} unpriced subscription requests. Select a row for its token mix.","providers.no-requests-in-range":"No requests in this range","providers.models-title":"Distinct models used through this provider","providers.share-title":"Fraction of all tokens in range","providers.cost-title":"API-equivalent estimate","providers.tps-title":"Average output throughput","providers.premium-title":"Premium requests (subscription multiplier units)","providers.burn":"Burn by provider","providers.burn-estimate-description":"API-equivalent estimate per {bucket}; excludes unpriced subscription requests","providers.burn-description":"Per {bucket}, top {count} providers stacked","providers.bucket-5m":"5 minutes","providers.bucket-hour":"hour","providers.bucket-day":"day","providers.no-provider-activity":"No provider activity in this range","providers.peak-burn-hours":"Peak burn hours","providers.peak-hours-description":"Tokens by local hour of day; peak at {hour}","providers.hours-description":"Tokens by local hour of day","providers.all-providers":"All providers","providers.tokens-peak-hour":"Tokens (peak hour)","providers.no-activity-in-range":"No activity in this range","providers.subscription-windows":"Subscription windows","providers.subscription-windows-description":"What one usage window buys you and how many accounts peak demand needs. Select a row to chart it.","providers.window":"Window","providers.accounts":"Accounts","providers.accounts-title":"Accounts with at least one snapshot for this window in range","providers.resets":"Resets","providers.resets-title":"Window resets observed (drops in used fraction)","providers.windows-burned":"Windows burned","providers.windows-burned-title":"Subscription-window equivalents consumed in range (sum of used-fraction increases across accounts)","providers.tokens-per-window":"Tokens / window","providers.tokens-per-window-title":"Provider tokens burned in range ÷ windows burned — what one full window is worth","providers.too-little-consumed":"Too little of the window was consumed to extrapolate","providers.peak-utilization":"Peak utilization","providers.peak-utilization-title":"Peak of summed used fraction across accounts at any sampled instant; the bar is relative to fleet capacity","providers.accounts-needed":"Accounts needed","providers.accounts-needed-title":"Accounts needed to keep peak demand under 90% of fleet capacity","providers.ideal-accounts":"{ideal} · have {have}","providers.exhaustions":"Exhaustions","providers.exhaustions-title":"Transitions into an exhausted state observed in range","providers.exhausted-n":"{count} exhausted","providers.no-snapshots-in-range":"No usage snapshots in this range","providers.snapshot-hint":"Usage snapshots accumulate whenever usage limits are fetched (TUI footer, /usage, zetacode usage).","providers.utilization":"Window utilization","providers.utilization-description":"{window} used fraction per account, {from} – {to}","providers.utilization-description-plain":"Recorded limit utilization per account","providers.no-utilization-readings":"No utilization readings for this window","providers.exhausted":"Exhausted","providers.no-reading":"No reading","providers.high":"High","providers.account":"Account","providers.latest-used":"Latest used","providers.status":"Status","providers.peak-in-range":"Peak in range","providers.snapshots":"Snapshots","providers.recorded":"Recorded"},"zh-CN":{"providers.description":"各服务商在{window}内的消耗、可靠性与订阅余量。","providers.most-tokens":"Token 最多:{provider}","providers.failed-n":"{count} 次失败","providers.succeeded-n":"{count} 次成功","providers.tokens-title":"未缓存输入 + 缓存读取 + 缓存写入 + 输出","providers.api-equivalent-cost":"API 等效费用","providers.api-cost-title":"此用量按公开 API 费率计算需要多少费用","providers.unpriced-n":"{count} 个未定价","providers.totals":"服务商汇总","providers.totals-description":"费用为 API 等效估算。选择一行可查看其 Token 构成。","providers.totals-description-unpriced-one":"费用为 API 等效估算,且未包含 {count} 个未定价的订阅请求。选择一行可查看其 Token 构成。","providers.totals-description-unpriced-n":"费用为 API 等效估算,且未包含 {count} 个未定价的订阅请求。选择一行可查看其 Token 构成。","providers.no-requests-in-range":"该时间范围内没有请求","providers.models-title":"通过该服务商使用的不同模型","providers.share-title":"该时间范围内全部 Token 中的占比","providers.cost-title":"API 等效估算","providers.tps-title":"平均输出吞吐量","providers.premium-title":"溢价请求(订阅倍率单位)","providers.burn":"按服务商的消耗","providers.burn-estimate-description":"每{bucket}的 API 等效估算;不含未定价的订阅请求","providers.burn-description":"每{bucket},堆叠显示前 {count} 个服务商","providers.bucket-5m":"5 分钟","providers.bucket-hour":"小时","providers.bucket-day":"天","providers.no-provider-activity":"该时间范围内没有服务商活动","providers.peak-burn-hours":"消耗高峰时段","providers.peak-hours-description":"按本地时段统计的 Token;高峰在 {hour}","providers.hours-description":"按本地时段统计的 Token","providers.all-providers":"全部服务商","providers.tokens-peak-hour":"Token(高峰时段)","providers.no-activity-in-range":"该时间范围内没有活动","providers.subscription-windows":"订阅窗口","providers.subscription-windows-description":"一个用量窗口能带来多少用量,以及峰值需求需要多少个账号。选择一行可将它绘制成图表。","providers.window":"窗口","providers.accounts":"账号","providers.accounts-title":"该时间范围内对此窗口至少有一个快照的账号","providers.resets":"重置次数","providers.resets-title":"观测到的窗口重置次数(已用比例下降)","providers.windows-burned":"消耗的窗口数","providers.windows-burned-title":"该时间范围内消耗的订阅窗口等效量(各账号已用比例增量之和)","providers.tokens-per-window":"Token / 窗口","providers.tokens-per-window-title":"该时间范围内消耗的服务商 Token ÷ 消耗的窗口数 —— 一个完整窗口的价值","providers.too-little-consumed":"该窗口消耗太少,无法外推","providers.peak-utilization":"峰值利用率","providers.peak-utilization-title":"任意采样时刻各账号已用比例之和的峰值;进度条相对于整体容量","providers.accounts-needed":"所需账号数","providers.accounts-needed-title":"将峰值需求控制在整体容量 90% 以下所需的账号数","providers.ideal-accounts":"{ideal} · 现有 {have}","providers.exhaustions":"耗尽次数","providers.exhaustions-title":"该时间范围内观测到的进入耗尽状态的次数","providers.exhausted-n":"{count} 次耗尽","providers.no-snapshots-in-range":"该时间范围内没有用量快照","providers.snapshot-hint":"每当获取用量限额时都会累积用量快照(TUI 底部、/usage、zetacode usage)。","providers.utilization":"窗口利用率","providers.utilization-description":"{window} 各账号的已用比例,{from} – {to}","providers.utilization-description-plain":"各账号已记录的限额利用率","providers.no-utilization-readings":"该窗口没有利用率记录","providers.exhausted":"已耗尽","providers.no-reading":"无读数","providers.high":"偏高","providers.account":"账号","providers.latest-used":"最新已用","providers.status":"状态","providers.peak-in-range":"范围内峰值","providers.snapshots":"快照数","providers.recorded":"记录时间"}};var gm={en:{"costs.title":"Costs","costs.description":"What {window} of usage would cost at public API rates. Subscription usage without a public price is counted as unpriced, not free.","costs.no-usage-in-range":"No usage in this range","costs.empty-hint":"Pick a wider range in the top bar.","costs.daily-estimate":"Daily estimate","costs.daily-by-model":"Per UTC day, stacked by model","costs.daily-by-component":"Per UTC day, stacked by billing component","costs.split-by":"Split by","costs.by-model":"By model","costs.by-component":"By component","costs.no-priced-usage":"No priced usage in this range","costs.unpriced-requests":"Unpriced requests","costs.where-it-went":"Where it went","costs.estimate-by-component":"Estimate by billing component","costs.unpriced-note-one":"{count} unpriced subscription request is not included.","costs.unpriced-note-n":"{count} unpriced subscription requests are not included.","costs.by-model-description":"Estimate per model with its input, output and cache split","costs.estimate":"Estimate","costs.estimate-title":"API-equivalent estimate at public rates","costs.split":"Split","costs.split-title":"Input · output · cache read · cache write","costs.per-request":"Per request","costs.per-request-title":"Estimate ÷ priced requests","costs.unpriced":"Unpriced","costs.unpriced-column-title":"Requests with no public-equivalent price","costs.api-equivalent-estimate":"API-equivalent estimate","costs.api-estimate-title":"What this usage would cost at public API rates","costs.requests-n":"{count} requests","costs.average-per-day":"Average per day","costs.average-per-day-title":"Estimate ÷ days with any usage","costs.active-days-one":"over {count} active day","costs.active-days-n":"over {count} active days","costs.top-model":"Top model","costs.top-model-hint":"{cost} · {share} of estimate","costs.nothing-priced-yet":"Nothing priced yet","costs.per-priced-request":"Per priced request","costs.per-priced-request-title":"Estimate ÷ requests that have a public price","costs.priced-n":"{count} priced","costs.unpriced-title":"Subscription usage with no public-equivalent price; excluded from the estimate","costs.unpriced-hint":"excluded from the estimate","costs.all-priced":"all usage priced"},"zh-CN":{"costs.title":"费用","costs.description":"按公开 API 费率计算,{window}的用量需要多少费用。没有公开价格的订阅用量计为未定价,而不是免费。","costs.no-usage-in-range":"此时间范围内没有用量","costs.empty-hint":"请在顶栏选择更宽的时间范围。","costs.daily-estimate":"每日估算","costs.daily-by-model":"按 UTC 日统计,按模型堆叠","costs.daily-by-component":"按 UTC 日统计,按计费组件堆叠","costs.split-by":"拆分依据","costs.by-model":"按模型","costs.by-component":"按组件","costs.no-priced-usage":"此时间范围内没有已定价的用量","costs.unpriced-requests":"未定价请求","costs.where-it-went":"费用去向","costs.estimate-by-component":"按计费组件估算","costs.unpriced-note-one":"{count} 个未定价的订阅请求未计入。","costs.unpriced-note-n":"{count} 个未定价的订阅请求未计入。","costs.by-model-description":"按模型估算,并附输入、输出与缓存的拆分","costs.estimate":"估算","costs.estimate-title":"按公开费率计算的 API 等效估算","costs.split":"拆分","costs.split-title":"输入 · 输出 · 缓存读取 · 缓存写入","costs.per-request":"单次请求","costs.per-request-title":"估算值 ÷ 已定价请求数","costs.unpriced":"未定价","costs.unpriced-column-title":"没有公开等效价格的请求","costs.api-equivalent-estimate":"API 等效估算","costs.api-estimate-title":"此用量按公开 API 费率计算需要多少费用","costs.requests-n":"{count} 个请求","costs.average-per-day":"日均","costs.average-per-day-title":"估算值 ÷ 有用量的天数","costs.active-days-one":"共 {count} 个活跃日","costs.active-days-n":"共 {count} 个活跃日","costs.top-model":"费用最高的模型","costs.top-model-hint":"{cost} · 占估算值的 {share}","costs.nothing-priced-yet":"暂无已定价用量","costs.per-priced-request":"单个已定价请求","costs.per-priced-request-title":"估算值 ÷ 有公开价格的请求数","costs.priced-n":"已定价 {count} 个","costs.unpriced-title":"没有公开等效价格的订阅用量;不计入估算","costs.unpriced-hint":"不计入估算","costs.all-priced":"全部用量均已定价"}};var ym={en:{"requests.description":"Every model call zeta made in {window}, newest first. Open a row for its full payload.","requests.loading":"Loading…","requests.load-latest":"Load latest {count}","requests.status":"Status","requests.status-all":"All","requests.none-in-window":"none in {window}","requests.since":"since {time}","requests.failed-hint":"{rate} · {count} aborted","requests.tokens-hint":"Total tokens across these requests","requests.api-equivalent-cost":"API-equivalent cost","requests.cost-hint":"What these requests would cost at public API rates","requests.unpriced-n":"{count} unpriced","requests.median-duration":"Median duration","requests.p95":"p95 {value}","requests.median-ttft":"Median TTFT","requests.ttft":"TTFT","requests.ttft-hint":"Time to first token","requests.log-title":"Request log","requests.log-loading":"Loading the latest requests…","requests.log-count-in-window":"{shown} of {total} requests in {window}","requests.log-count-latest":"{shown} of the latest {total} requests","requests.search-placeholder":"Model, provider or project","requests.footer":"Showing the latest {count} requests, back to {time}. Older requests in {window} are not loaded.","requests.empty-in-window":"No requests in {window}","requests.empty-no-match":"No requests match","requests.empty-no-match-hint":"Clear the search or status filter.","requests.when":"When","requests.uncached-input":"Uncached input tokens","requests.cache-read-title":"Cache read tokens (hover a cell for cache writes)","requests.cache-write":"Cache write: {count}","requests.cost-estimate":"API-equivalent estimate"},"zh-CN":{"requests.description":"zeta 在 {window} 内发出的每一次模型调用,最新在前。打开某一行可查看其完整载荷。","requests.loading":"加载中…","requests.load-latest":"加载最新 {count} 条","requests.status":"状态","requests.status-all":"全部","requests.none-in-window":"{window} 内没有请求","requests.since":"自 {time} 起","requests.failed-hint":"{rate} · {count} 个已中止","requests.tokens-hint":"这些请求的 Token 总量","requests.api-equivalent-cost":"API 等价费用","requests.cost-hint":"这些请求按公开 API 费率计算的费用","requests.unpriced-n":"{count} 个未定价","requests.median-duration":"耗时中位数","requests.p95":"p95 分位 {value}","requests.median-ttft":"首 Token 延迟中位数","requests.ttft":"首 Token 延迟","requests.ttft-hint":"首 Token 延迟","requests.log-title":"请求日志","requests.log-loading":"正在加载最新请求…","requests.log-count-in-window":"{window} 内共 {total} 个请求,显示 {shown} 个","requests.log-count-latest":"最新 {total} 个请求中显示 {shown} 个","requests.search-placeholder":"模型、服务商或项目","requests.footer":"显示最新 {count} 个请求,回溯至 {time}。{window} 内更早的请求未加载。","requests.empty-in-window":"{window} 内没有请求","requests.empty-no-match":"没有匹配的请求","requests.empty-no-match-hint":"清除搜索内容或状态筛选。","requests.when":"时间","requests.uncached-input":"未缓存输入 Token","requests.cache-read-title":"缓存读取 Token(将鼠标悬停在单元格上可查看缓存写入)","requests.cache-write":"缓存写入:{count}","requests.cost-estimate":"API 等价估算"}};var vm={en:{"errors.title":"Errors","errors.description":"Failed model requests in {window}, grouped by error signature. Open a failure for its full payload.","errors.footer":"Showing the latest {count} failures in {window}; older ones are not loaded.","errors.loading":"Loading…","errors.load-latest":"Load latest {count}","errors.failures":"Failures","errors.hint-in-window":"in {window}","errors.hint-latest-loaded":"latest {count} loaded","errors.signatures":"Signatures","errors.signatures-hint":"Distinct error messages after normalizing ids and numbers","errors.signatures-top":"top: {count} failures","errors.affected-models":"Affected models","errors.last-failure":"Last failure","errors.none-in-window":"none in {window}","errors.error-signatures":"Error signatures","errors.signatures-card-description":"Same message with ids and counters normalized. Select one to filter the failures below.","errors.empty-no-failures":"No failures in {window}","errors.empty-all-succeeded":"Every request succeeded or was aborted.","errors.by-model":"By model","errors.by-model-description":"Failures per model. Select one to filter.","errors.empty-no-affected-models":"No affected models","errors.loading-failures":"Loading failures…","errors.filtered-of-total":"{shown} of {total} failures, newest first","errors.search-placeholder":"Message, model or project","errors.no-match":"No failures match","errors.no-match-hint":"Clear the search or the selected filters.","errors.signature":"Signature","errors.more-models":"+{count} more","errors.last-seen":"Last seen","errors.unknown-error":"Unknown error","errors.group-meta":"{count} failures · first {first} · last {last}","errors.open-latest":"Open latest","errors.when":"When","errors.cost-hint":"API-equivalent estimate"},"zh-CN":{"errors.title":"错误","errors.description":"在 {window} 内失败的模型请求,按错误签名分组。打开某条失败可查看完整载荷。","errors.footer":"显示 {window} 内最新的 {count} 个失败;更早的未加载。","errors.loading":"加载中…","errors.load-latest":"加载最新 {count} 条","errors.failures":"失败","errors.hint-in-window":"{window} 内","errors.hint-latest-loaded":"已加载最新 {count} 条","errors.signatures":"签名","errors.signatures-hint":"对 ID 和数字归一化后不同的错误消息","errors.signatures-top":"最多:{count} 个失败","errors.affected-models":"受影响的模型","errors.last-failure":"最近一次失败","errors.none-in-window":"{window} 内没有失败","errors.error-signatures":"错误签名","errors.signatures-card-description":"同一消息在归一化 ID 和计数后归为一组。选择一项可筛选下方的失败。","errors.empty-no-failures":"{window} 内没有失败","errors.empty-all-succeeded":"所有请求均已成功或被中止。","errors.by-model":"按模型","errors.by-model-description":"各模型的失败数。选择一项可筛选。","errors.empty-no-affected-models":"没有受影响的模型","errors.loading-failures":"正在加载失败…","errors.filtered-of-total":"共 {total} 个失败,显示 {shown} 个,最新在前","errors.search-placeholder":"消息、模型或项目","errors.no-match":"没有匹配的失败","errors.no-match-hint":"清除搜索内容或已选筛选条件。","errors.signature":"签名","errors.more-models":"另有 {count} 个","errors.last-seen":"最近出现","errors.unknown-error":"未知错误","errors.group-meta":"{count} 个失败 · 首次 {first} · 最近 {last}","errors.open-latest":"打开最新","errors.when":"时间","errors.cost-hint":"按 API 价格估算"}};var bm={en:{"trace.title":"Traces","trace.description":"Recent sessions with subagent activity folded in. Open one to inspect its timeline.","trace.sessions":"Sessions","trace.session":"Session","trace.most-recent":"{count} most recent","trace.most-recent-filtered":"{shown} of {total} most recent","trace.filter-placeholder":"Filter by title, project, model…","trace.empty-title":"No sessions found","trace.empty-hint":"Run a sync to index recent activity.","trace.no-matching-title":"No matching sessions","trace.no-matching-hint":"Try a different filter.","trace.tool":"Tool","trace.tools":"Tools","trace.agent":"Agent","trace.agents":"Agents","trace.background":"Background","trace.bg":"Bg","trace.refresh":"Refresh trace","trace.timeline":"Timeline","trace.timeline-hint":"W/S zoom · A/D pan · drag pan · wheel zoom · 0 fit · F focus selection · dbl-click focus · Esc deselect","trace.expand-all":"Expand all","trace.collapse-all":"Collapse all","trace.axis-mode":"Axis mode","trace.mode-time-title":"Real wall-clock time","trace.mode-turns-title":"Equal width per user turn","trace.mode-calls-title":"Equal width per model/tool call boundary","trace.turns":"Turns","trace.calls":"Calls","trace.compress-idle":"Compress idle","trace.search-placeholder":"Search spans…","trace.previous-match":"Previous match","trace.next-match":"Next match","trace.transcript":"Transcript","trace.transcript-description":"Every span and marker in order; click to inspect","trace.no-matching-events":"No matching events","trace.canvas-aria":"Trace timeline. W and S zoom, A and D pan, 0 fits all, F focuses the selection.","trace.minimap-aria":"Timeline overview brush","trace.expand-track":"Expand {track}","trace.collapse-track":"Collapse {track}","trace.unterminated":"unterminated","trace.tok":"tok","trace.ttft":"TTFT","trace.wall-time":"Wall time","trace.model-time":"Model time","trace.tool-time":"Tool time","trace.idle":"Idle","trace.tool-calls-n":"{count} tool calls","trace.of-wall":"{percent} of wall","trace.tool-aggregates":"Tool aggregates","trace.tool-aggregates-desc":"{count} tools, by total time","trace.errors":"Errors","trace.failed-n":"{count} failed","trace.avg":"Avg","trace.max":"Max","trace.start":"Start","trace.track":"Track","trace.io-cached":"Input / output / cached","trace.stop-reason":"Stop reason","trace.copy-json":"Copy raw JSON","trace.error-message":"Error message","trace.task":"Task","trace.open-child-track":"Open child track","trace.args":"Args","trace.thinking":"Thinking","trace.text":"Text","trace.raw-entry":"Raw entry","trace.load-failed":"Failed to load entry: {message}"},"zh-CN":{"trace.title":"调用链","trace.description":"最近的会话,已合并子代理活动。打开其中一个即可查看其时间线。","trace.sessions":"会话","trace.session":"会话","trace.most-recent":"最近 {count} 条","trace.most-recent-filtered":"最近 {total} 条中的 {shown} 条","trace.filter-placeholder":"按标题、项目或模型筛选…","trace.empty-title":"未找到会话","trace.empty-hint":"运行一次同步以索引最近的活动。","trace.no-matching-title":"没有匹配的会话","trace.no-matching-hint":"请尝试其他筛选条件。","trace.tool":"工具","trace.tools":"工具","trace.agent":"智能体","trace.agents":"智能体","trace.background":"后台","trace.bg":"背景","trace.refresh":"刷新调用链","trace.timeline":"时间线","trace.timeline-hint":"W/S 缩放 · A/D 平移 · 拖拽平移 · 滚轮缩放 · 0 适应全部 · F 聚焦所选 · 双击聚焦 · Esc 取消选择","trace.expand-all":"全部展开","trace.collapse-all":"全部折叠","trace.axis-mode":"坐标轴模式","trace.mode-time-title":"真实墙钟时间","trace.mode-turns-title":"每个用户轮次等宽","trace.mode-calls-title":"每个模型/工具调用边界等宽","trace.turns":"轮次","trace.calls":"调用次数","trace.compress-idle":"压缩空闲时间","trace.search-placeholder":"搜索跨度…","trace.previous-match":"上一个匹配","trace.next-match":"下一个匹配","trace.transcript":"对话记录","trace.transcript-description":"按顺序列出所有跨度和标记;点击可查看详情","trace.no-matching-events":"没有匹配的事件","trace.canvas-aria":"调用链时间线。W 和 S 缩放,A 和 D 平移,0 适应全部,F 聚焦所选。","trace.minimap-aria":"时间线概览刷选","trace.expand-track":"展开 {track}","trace.collapse-track":"折叠 {track}","trace.unterminated":"未结束","trace.tok":"Token","trace.ttft":"首 Token 延迟","trace.wall-time":"墙钟时间","trace.model-time":"模型耗时","trace.tool-time":"工具耗时","trace.idle":"空闲","trace.tool-calls-n":"{count} 次工具调用","trace.of-wall":"占墙钟时间 {percent}","trace.tool-aggregates":"工具汇总","trace.tool-aggregates-desc":"{count} 个工具,按总耗时排序","trace.errors":"错误","trace.failed-n":"{count} 个失败","trace.avg":"平均","trace.max":"最大","trace.start":"开始","trace.track":"轨道","trace.io-cached":"输入 / 输出 / 缓存读取","trace.stop-reason":"停止原因","trace.copy-json":"复制原始 JSON","trace.error-message":"错误信息","trace.task":"任务","trace.open-child-track":"打开子轨道","trace.args":"参数","trace.thinking":"思考过程","trace.text":"文本","trace.raw-entry":"原始条目","trace.load-failed":"加载条目失败:{message}"}};var xm={en:{"tools.title":"Tools","tools.description":"Which tools zeta called in {window}, how often they failed, and what they cost.","tools.tool-calls":"Tool calls","tools.failed-n":"{count} failed","tools.distinct-tools":"Distinct tools","tools.most-used":"Most used: {tool}","tools.error-rate-title":"Tool results that came back flagged as errors","tools.succeeded-n":"{count} succeeded","tools.attributed-tokens":"Attributed tokens","tools.tokens-output":"{tokens} output","tools.attributed-cost":"Attributed cost","tools.attribution-note":"Tokens and API-equivalent cost of each invoking turn, split evenly across that turn's tool calls","tools.attribution-estimate":"{note}; API-equivalent estimate","tools.unpriced-requests-n":"{count} unpriced requests","tools.api-equivalent":"API-equivalent","tools.result-text":"Result text","tools.result-chars-title":"Characters of tool-result text fed back into context","tools.chars":"{count} chars","tools.call-arguments":"Call arguments","tools.args-chars-title":"Characters of serialized tool-call arguments","tools.avg-result-per-call":"Avg result per call","tools.avg-args-per-call":"Avg arguments per call","tools.calls-over-time":"Calls over time","tools.errors-over-time":"Errors over time","tools.chart-description":"Per {bucket}, top {count} tools stacked","tools.bucket-5m":"5 minutes","tools.bucket-hour":"hour","tools.bucket-day":"day","tools.calls":"Calls","tools.errors":"Errors","tools.no-tool-errors":"No tool errors in this range","tools.by-tool":"By tool","tools.by-tool-description":"{note}. Select a tool to break it down by model.","tools.by-tool-and-model":"By tool and model","tools.by-tool-and-model-description":"Which models call which tools, and how often those calls fail","tools.filter-by-tool":"Filter by tool","tools.all-tools":"All tools","tools.clear-tool-filter":"Clear tool filter","tools.no-tool-calls":"No tool calls in this range","tools.no-calls-to-tool":"No calls to {tool} in this range","tools.tool":"Tool","tools.trend":"Trend","tools.trend-title":"Calls per bucket over the range","tools.share-of-calls":"{percent} of all tool calls","tools.errors-title":"Calls whose result came back flagged as an error","tools.args":"Args","tools.result":"Result","tools.result-per-call":"Result / call","tools.result-per-call-title":"Mean tool-result characters per call","tools.attr-tokens":"Attr. tokens","tools.share-of-tokens":"{percent} of attributed tokens","tools.attr-cost":"Attr. cost","tools.share-of-cost":"{percent} of attributed cost","tools.last-used":"Last used"},"zh-CN":{"tools.title":"工具","tools.description":"zeta 在{window}调用了哪些工具、它们的失败频率如何,以及产生了多少费用。","tools.tool-calls":"工具调用","tools.failed-n":"{count} 个失败","tools.distinct-tools":"不同工具数","tools.most-used":"使用最多:{tool}","tools.error-rate-title":"返回时被标记为错误的工具结果","tools.succeeded-n":"{count} 个成功","tools.attributed-tokens":"归属 Token","tools.tokens-output":"{tokens} 输出","tools.attributed-cost":"归属费用","tools.attribution-note":"每次调用回合的 Token 与 API 等价费用,平均分摊到该回合的各个工具调用","tools.attribution-estimate":"{note};按 API 等价估算","tools.unpriced-requests-n":"{count} 个未定价请求","tools.api-equivalent":"按 API 等价","tools.result-text":"结果文本","tools.result-chars-title":"回填到上下文中的工具结果文本字符数","tools.chars":"{count} 字符","tools.call-arguments":"调用参数","tools.args-chars-title":"序列化后的工具调用参数字符数","tools.avg-result-per-call":"每次调用平均结果","tools.avg-args-per-call":"每次调用平均参数","tools.calls-over-time":"调用次数随时间变化","tools.errors-over-time":"错误数随时间变化","tools.chart-description":"按{bucket}统计,堆叠显示前 {count} 个工具","tools.bucket-5m":"5 分钟","tools.bucket-hour":"小时","tools.bucket-day":"天","tools.calls":"调用次数","tools.errors":"错误数","tools.no-tool-errors":"该时间范围内没有工具错误","tools.by-tool":"按工具","tools.by-tool-description":"{note}。选择某个工具可按模型细分。","tools.by-tool-and-model":"按工具和模型","tools.by-tool-and-model-description":"哪些模型调用了哪些工具,以及这些调用的失败频率","tools.filter-by-tool":"按工具筛选","tools.all-tools":"全部工具","tools.clear-tool-filter":"清除工具筛选","tools.no-tool-calls":"该时间范围内没有工具调用","tools.no-calls-to-tool":"该时间范围内没有对 {tool} 的调用","tools.tool":"工具","tools.trend":"趋势","tools.trend-title":"时间范围内每个分桶的调用次数","tools.share-of-calls":"占全部工具调用的 {percent}","tools.errors-title":"结果返回时被标记为错误的调用","tools.args":"参数","tools.result":"结果","tools.result-per-call":"结果 / 次","tools.result-per-call-title":"每次调用平均工具结果字符数","tools.attr-tokens":"归属 Token","tools.share-of-tokens":"占归属 Token 的 {percent}","tools.attr-cost":"归属费用","tools.share-of-cost":"占归属费用的 {percent}","tools.last-used":"最近使用"}};var Sm={en:{"frustration.estimate-note":"Identical messages share one verdict, and verdicts are cached, so later runs only pay for new messages. Nothing is spent until you proceed.","frustration.column-model-ids":"Model IDs","frustration.column-messages":"Messages","frustration.column-judged":"Judged","frustration.model-versions":"Model versions","frustration.no-model-match":"No model versions match the filters","frustration.small-models-title":"Models with fewer than {count} messages have noisy rates","frustration.hide-regex-title":"Hide models with under {share}% judged messages (rates from regex signals)","frustration.hatch-title":"Under {share}% of these messages are judged; their rates come from regex signals","frustration.regex-badge":"regex","frustration.legend-annoyed-any":"Annoyed, any target","frustration.table-description":"Rates are shares of user messages; rows follow the chart filters.","frustration.running":"Running","frustration.estimating":"Estimating cost…","frustration.failed-n":"{count} failed","frustration.cost-so-far":"cost so far","frustration.elapsed":"elapsed {time}","frustration.in-flight":"{count} in flight","frustration.messages-progress":"{done}/{total} messages","frustration.failed-suffix":", {count} failed","frustration.judge-with":" with {judge}","frustration.in-time":" in {time}","frustration.run-done-line":"Last run judged {progress}{failed}{judge}{elapsed} for {cost}.","frustration.run-cancelled-line":"Last run cancelled after {progress}{failed}; spent {cost}.","frustration.run-failed-line":"Last run failed after {progress}{failed}: {error}. Spent {cost}.","frustration.title":"Frustration","frustration.description":"How often your messages sound annoyed, per model version, in {window}.","frustration.user-messages":"User messages","frustration.user-messages-title":"User messages with prose in range","frustration.judge-coverage":"Judge coverage","frustration.judge-coverage-title":"Messages with a cached judge verdict; the rest use the regex lexicons","frustration.coverage-hint":"{judged} judged · {regex} regex","frustration.coverage-unscored":" · {count} unscored (no lexicon)","frustration.unscored-line":"Messages in a language without a lexicon: {count} — unscored, not calm.","frustration.annoyed":"Annoyed","frustration.annoyed-title":"Messages annoyed at any target","frustration.at-assistant":"At assistant","frustration.at-assistant-title":"Messages annoyed at the assistant","frustration.angry":"Angry","frustration.angry-title":"Messages angry or hostile toward the assistant","frustration.messages-n":"{count} messages","frustration.judge-panel":"Judge classification","frustration.judge-description":"Cached LLM verdicts replace the regex lexicons; unjudged messages fall back to regex signals. Messages in a language no lexicon covers are reported as unscored rather than counted as calm.","frustration.classify":"Classify with judge","frustration.proceed":"Proceed","frustration.starting":"Starting…","frustration.judge-running":"A judge run is in progress","frustration.quote-title":"Quote the cost of judging every unjudged message in range","frustration.estimated-cost":"Estimated cost","frustration.unjudged-messages":"Unjudged unique messages","frustration.prose-chars":"Prose characters","frustration.input-tokens":"Estimated input tokens","frustration.judge-model":"Judge","frustration.all-judged":"Everything in this range is already judged. There is nothing left to classify.","frustration.no-run-yet":"No judge run yet. Classify the unjudged messages to replace regex estimates with verdicts.","frustration.last-run-done":"Last run done","frustration.last-run-cancelled":"Last run cancelled","frustration.last-run-failed":"Last run failed","frustration.not-run-yet":"Not run yet","frustration.regex-only":"Regex only","frustration.cancel-run":"Cancel run","frustration.cancelling":"Cancelling…","frustration.run-judged":"Last run judged {progress}","frustration.run-cancelled-after":"Last run cancelled after {progress}","frustration.run-failed-after":"Last run failed after {progress}","frustration.by-model":"Frustration by model version","frustration.by-model-description":"Share of user messages per model version. Each bar reaches the annoyed rate; the subsets aimed at the assistant stack inside it.","frustration.all-classes":"All","frustration.every-model-class":"Every model class","frustration.model-class":"Model class","frustration.include-small":"Include < {count} messages","frustration.unclassified":"unclassified","frustration.legend-angry":"Angry at assistant","frustration.legend-assistant":"At assistant, not angry","frustration.legend-other":"Annoyed at other targets","frustration.legend-trend":"At assistant trend","frustration.legend-hatched":"Hatched: mostly regex fallback","frustration.legend-hatched-run":"Hatched: mostly regex fallback (run the judge)","frustration.legend-hue":"Hue = model family","frustration.no-messages":"No user messages in this range","frustration.try-longer-range":"Try a longer range.","frustration.mostly-regex":"Mostly regex fallback: run the judge for accurate rates","frustration.row-mostly-regex":" · mostly regex fallback","frustration.stack-relation":"annoyed ⊇ atAssistant ⊇ angry","frustration.unknown-error":"unknown error","frustration.cancelled":"Cancelled","frustration.failed":"Failed","frustration.done":"Done"},"zh-CN":{"frustration.estimate-note":"内容相同的消息共用一份结论,且结论会被缓存,因此后续运行只为新消息付费。在你开始之前不会产生任何费用。","frustration.column-model-ids":"模型 ID","frustration.column-messages":"消息数","frustration.column-judged":"已评判","frustration.model-versions":"模型版本","frustration.no-model-match":"没有符合筛选条件的模型版本","frustration.small-models-title":"消息少于 {count} 条的模型比例噪声较大","frustration.hide-regex-title":"隐藏已评判比例低于 {share}% 的模型(其比例来自正则信号)","frustration.hatch-title":"这些消息中已评判比例低于 {share}%,其比例来自正则信号","frustration.regex-badge":"正则","frustration.legend-annoyed-any":"不耐烦(任意对象)","frustration.table-description":"比例为占用户消息的百分比;行跟随图表筛选。","frustration.running":"运行中","frustration.estimating":"正在估算费用…","frustration.failed-n":"{count} 条失败","frustration.cost-so-far":"当前费用","frustration.elapsed":"已用时 {time}","frustration.in-flight":"并发 {count}","frustration.messages-progress":"{done}/{total} 条消息","frustration.failed-suffix":",{count} 条失败","frustration.judge-with":",评判模型 {judge}","frustration.in-time":",用时 {time}","frustration.run-done-line":"上次运行评判了 {progress}{failed}{judge}{elapsed},花费 {cost}。","frustration.run-cancelled-line":"上次运行在 {progress}{failed} 后取消,花费 {cost}。","frustration.run-failed-line":"上次运行在 {progress}{failed} 后失败:{error}。花费 {cost}。","frustration.title":"情绪压力","frustration.description":"按模型版本统计你的消息有多不耐烦({window})。","frustration.user-messages":"用户消息","frustration.user-messages-title":"该时间范围内的用户消息(含正文)","frustration.judge-coverage":"判据覆盖率","frustration.judge-coverage-title":"已有缓存的评判模型结论的消息;其余使用正则词典","frustration.coverage-hint":"{judged} 条已评判 · {regex} 条正则","frustration.coverage-unscored":" · {count} 条未评分(无词典)","frustration.unscored-line":"缺少对应词典的语言:{count} 条 —— 未评分,不代表平静。","frustration.annoyed":"不耐烦","frustration.annoyed-title":"对任何对象不耐烦的消息","frustration.at-assistant":"针对助手","frustration.at-assistant-title":"对助手不耐烦的消息","frustration.angry":"发怒","frustration.angry-title":"对助手发怒或带有敌意的消息","frustration.messages-n":"{count} 条消息","frustration.judge-panel":"评判模型分类","frustration.judge-description":"缓存的模型结论会取代正则词典;未评判的消息回退到正则信号。缺少词典的语言显示为未评分,而不是判定为平静。","frustration.classify":"用评判模型分类","frustration.proceed":"开始","frustration.starting":"正在开始…","frustration.judge-running":"评判任务正在进行","frustration.quote-title":"估算对该范围内所有未评判消息进行判定的成本","frustration.estimated-cost":"预估费用","frustration.unjudged-messages":"未评判的唯一消息","frustration.prose-chars":"正文字符数","frustration.input-tokens":"预估输入 Token","frustration.judge-model":"评判模型","frustration.all-judged":"该范围内已全部评判,没有需要分类的消息。","frustration.no-run-yet":"尚未运行评判。对未评判的消息分类,即可用结论取代正则估算。","frustration.last-run-done":"上次运行完成","frustration.last-run-cancelled":"上次运行已取消","frustration.last-run-failed":"上次运行失败","frustration.not-run-yet":"尚未运行","frustration.regex-only":"仅正则","frustration.cancel-run":"取消运行","frustration.cancelling":"正在取消…","frustration.run-judged":"上次运行已评判 {progress}","frustration.run-cancelled-after":"上次运行在 {progress} 后取消","frustration.run-failed-after":"上次运行在 {progress} 后失败","frustration.by-model":"按模型版本的情绪压力","frustration.by-model-description":"各模型版本中用户消息的占比。每根柱子到达不耐烦比例,其中针对助手的子集叠在其内部。","frustration.all-classes":"全部","frustration.every-model-class":"所有模型类别","frustration.model-class":"模型类别","frustration.include-small":"包含少于 {count} 条消息","frustration.unclassified":"未分类","frustration.legend-angry":"对助手发怒","frustration.legend-assistant":"针对助手但未发怒","frustration.legend-other":"对其他对象不耐烦","frustration.legend-trend":"针对助手趋势","frustration.legend-hatched":"斜线:多为正则回退","frustration.legend-hatched-run":"斜线:多为正则回退(运行评判)","frustration.legend-hue":"色相 = 模型家族","frustration.no-messages":"该时间范围内没有用户消息","frustration.try-longer-range":"试试更长的时间范围。","frustration.mostly-regex":"多为正则回退:运行评判以获得准确比例","frustration.row-mostly-regex":" · 多为正则回退","frustration.stack-relation":"不耐烦 ⊇ 针对助手 ⊇ 发怒","frustration.unknown-error":"未知错误","frustration.cancelled":"已取消","frustration.failed":"失败","frustration.done":"完成"}};var Lm={en:{"projects.title":"Projects","projects.description":"Usage by session folder in {window}.","projects.folders":"Folders","projects.folder":"Folder","projects.temporary-n":"{count} temporary","projects.failed-n":"{count} failed","projects.api-equivalent-cost":"API-equivalent cost","projects.api-equivalent-cost-hint":"What this usage would cost at public API rates","projects.unpriced-n":"{count} unpriced","projects.conversation-tokens":"Conversation tokens","projects.conversation-tokens-hint":"Uncached input + cache reads + cache writes + output","projects.cache-rate":"Cache rate","projects.cache-rate-hint":"Cache reads ÷ (uncached input + cache reads)","projects.cache-rate-hint-all":"Cache reads ÷ (uncached input + cache reads), across every folder","projects.top-by-cost":"Top by cost","projects.top-by-cost-description":"Share of API-equivalent cost","projects.top-by-requests":"Top by requests","projects.top-by-requests-description":"Share of all requests","projects.folders-n":"{count} folders","projects.folders-of-n":"{count} of {total} folders","projects.hide-temporary":"Hide temporary ({count})","projects.hide-temporary-hint":"Session folders under /tmp or /var/folders","projects.filter-placeholder":"Filter folders…","projects.empty-no-folders":"No project folders in this range","projects.empty-only-temporary":"Only temporary folders in this range","projects.empty-no-match":"No folders match","projects.hint-longer-range":"Try a longer range.","projects.hint-temporary-hidden":"Temporary folders are hidden.","projects.temp":"temp","projects.share-of-requests":"{share} of all requests","projects.share-of-cost":"{share} of all cost","projects.api-equivalent-cost-rates":"API-equivalent cost at public API rates","projects.cache-savings":"Cache savings","projects.cache-savings-hint":"Prompt-input cost saved versus billing the same tokens uncached","projects.errors":"Errors","projects.avg-duration":"Avg duration","projects.last-active":"Last active"},"zh-CN":{"projects.title":"项目","projects.description":"{window}内按会话文件夹统计的用量。","projects.folders":"文件夹","projects.folder":"文件夹","projects.temporary-n":"{count} 个临时","projects.failed-n":"{count} 个失败","projects.api-equivalent-cost":"API 等效费用","projects.api-equivalent-cost-hint":"这些用量按公开 API 费率计算所需的费用","projects.unpriced-n":"{count} 个未计价","projects.conversation-tokens":"对话 Token","projects.conversation-tokens-hint":"未缓存输入 + 缓存读取 + 缓存写入 + 输出","projects.cache-rate":"缓存命中率","projects.cache-rate-hint":"缓存读取 ÷(未缓存输入 + 缓存读取)","projects.cache-rate-hint-all":"缓存读取 ÷(未缓存输入 + 缓存读取),覆盖所有文件夹","projects.top-by-cost":"费用最高","projects.top-by-cost-description":"占 API 等效费用的比例","projects.top-by-requests":"请求最多","projects.top-by-requests-description":"占全部请求的比例","projects.folders-n":"{count} 个文件夹","projects.folders-of-n":"{total} 个文件夹中的 {count} 个","projects.hide-temporary":"隐藏临时文件夹({count})","projects.hide-temporary-hint":"/tmp 或 /var/folders 下的会话文件夹","projects.filter-placeholder":"筛选文件夹…","projects.empty-no-folders":"该时间范围内没有项目文件夹","projects.empty-only-temporary":"该时间范围内只有临时文件夹","projects.empty-no-match":"没有匹配的文件夹","projects.hint-longer-range":"试试更长的时间范围。","projects.hint-temporary-hidden":"临时文件夹已隐藏。","projects.temp":"临时","projects.share-of-requests":"占全部请求的 {share}","projects.share-of-cost":"占全部费用的 {share}","projects.api-equivalent-cost-rates":"按公开 API 费率计算的等效费用","projects.cache-savings":"缓存节省","projects.cache-savings-hint":"同样的 Token 按未缓存计费时,提示输入费用节省的比例","projects.errors":"错误","projects.avg-duration":"平均耗时","projects.last-active":"最近活动"}};var Cm={en:{"gain.title":"Gain","gain.description":"Tokens snapcompact kept out of context in {window}.","gain.description-scoped":"Tokens snapcompact kept out of context for {project} in {window}.","gain.all-projects":"All projects","gain.empty-title":"No savings recorded in {window}","gain.empty-title-scoped":"No savings recorded for {project} in {window}","gain.empty-hint-all":"Savings appear here once snapcompact compacts tool output.","gain.empty-hint-longer-range":"Try a longer range.","gain.saved-tokens":"Saved tokens","gain.saved-bytes":"Saved bytes","gain.reduction":"Reduction","gain.reduction-title":"Saved bytes ÷ original bytes, when the original size is known","gain.reduction-unknown":"original size not recorded","gain.hits":"Hits","gain.saved-per-hit":"Saved per hit","gain.savings-over-time":"Savings over time","gain.savings-over-time-description":"Tokens saved per UTC day, with the running total","gain.saved-per-day":"Saved per day","gain.cumulative":"Cumulative","gain.by-source":"By source","gain.by-source-description":"Savings per subsystem","gain.source":"Source"},"zh-CN":{"gain.title":"收益","gain.description":"在{window}内被 snapcompact 挡在上下文之外的 Token。","gain.description-scoped":"在{window}内被 snapcompact 为 {project} 挡在上下文之外的 Token。","gain.all-projects":"全部项目","gain.empty-title":"在{window}内没有节省记录","gain.empty-title-scoped":"在{window}内没有 {project} 的节省记录","gain.empty-hint-all":"snapcompact 压缩工具输出后,节省量会显示在这里。","gain.empty-hint-longer-range":"请尝试更长的时间范围。","gain.saved-tokens":"节省的 Token","gain.saved-bytes":"节省的字节","gain.reduction":"节省比例","gain.reduction-title":"原始大小已知时,节省字节 ÷ 原始字节","gain.reduction-unknown":"未记录原始大小","gain.hits":"命中次数","gain.saved-per-hit":"每次命中节省","gain.savings-over-time":"节省趋势","gain.savings-over-time-description":"每个 UTC 日节省的 Token,以及累计总量","gain.saved-per-day":"每日节省","gain.cumulative":"累计","gain.by-source":"按来源","gain.by-source-description":"各子系统节省量","gain.source":"来源"}};var wm={en:{"ui.table-shown-of":"{shown} of {total}","ui.show-fewer":"Show fewer","ui.retry":"Retry","ui.delta-new":"new","ui.json":"JSON","ui.trace":"Trace","ui.open-trace":"Open this request's session in the trace view","ui.status-ok":"OK","ui.section-timing":"Timing","ui.time-to-first-token":"Time to first token","ui.uncached-input":"Uncached input","ui.section-cost":"API-equivalent cost","ui.section-identity":"Identity","ui.stop-reason":"Stop reason","ui.api":"API","ui.session-file":"Session file","ui.stats-row":"Stats row"},"zh-CN":{"ui.table-shown-of":"已显示 {shown} / 共 {total}","ui.show-fewer":"收起","ui.retry":"重试","ui.delta-new":"新增","ui.json":"JSON 数据","ui.trace":"调用链","ui.open-trace":"在调用链视图中打开该请求的会话","ui.status-ok":"正常","ui.section-timing":"时间","ui.time-to-first-token":"首 Token 延迟","ui.uncached-input":"未缓存输入","ui.section-cost":"API 等价费用","ui.section-identity":"标识","ui.stop-reason":"停止原因","ui.api":"接口","ui.session-file":"会话文件","ui.stats-row":"统计行"}};var km={en:{},"zh-CN":{}};var V2={...dm.en,...fm.en,...pm.en,...mm.en,...hm.en,...gm.en,...ym.en,...vm.en,...bm.en,...xm.en,...Sm.en,...Lm.en,...Cm.en,...wm.en,...km.en},Xk={id:"en",messages:V2};var j2={...dm["zh-CN"],...fm["zh-CN"],...pm["zh-CN"],...mm["zh-CN"],...hm["zh-CN"],...gm["zh-CN"],...ym["zh-CN"],...vm["zh-CN"],...bm["zh-CN"],...xm["zh-CN"],...Sm["zh-CN"],...Lm["zh-CN"],...Cm["zh-CN"],...wm["zh-CN"],...km["zh-CN"]},Yk={id:"zh-CN",messages:j2};function X2(){return globalThis.__ZETA_STATS_LOCALE__}var Y2={en:Xk.messages,"zh-CN":Yk.messages},Tm="en";$2();function Xs(){return Tm}function $k(l){return Tm=Nv(l),Tm}function $2(){let l=X2();if(l)return $k(l);if(typeof navigator>"u")return"en";return $k(Vk(navigator.languages))}function u(l,i){return jk(Tm,l,Y2,i)}var Kk=60000,Im=60*Kk,sr=24*Im,Bv={"1h":{labelKey:"common.range-1h",windowKey:"common.window-1h",spanMs:Im,bucketMs:5*Kk},"24h":{labelKey:"common.range-24h",windowKey:"common.window-24h",spanMs:sr,bucketMs:Im},"7d":{labelKey:"common.range-7d",windowKey:"common.window-7d",spanMs:7*sr,bucketMs:sr},"30d":{labelKey:"common.range-30d",windowKey:"common.window-30d",spanMs:30*sr,bucketMs:sr},"90d":{labelKey:"common.range-90d",windowKey:"common.window-90d",spanMs:90*sr,bucketMs:sr},all:{labelKey:"common.range-all",windowKey:"common.window-all",spanMs:null,bucketMs:sr}},Q2=1500,ci=["1h","24h","7d","30d","90d","all"];function ia(l){return Bv[l]}var zv={hour:"2-digit",minute:"2-digit",hourCycle:"h23"},Uv={month:"short",day:"numeric"},Qk=new Map;function Rd(l,i){let c=Xs(),f=`${c}:${l}`,p=Qk.get(f);if(!p)p=new Intl.DateTimeFormat(c,i),Qk.set(f,p);return p}function Rm(l,i){if(i<Im)return Rd("hm",zv).format(l);if(i<sr)return Rd("mdhm",{...Uv,...zv}).format(l);return Rd("md",Uv).format(l)}function Am(l,i){return i<sr?Rd("hm",zv).format(l):Rd("md",Uv).format(l)}function _o(l,i,c=Bv[l].bucketMs,f=Date.now()){let p=Math.floor(f/c)*c,S=Bv[l].spanMs,h;if(S!==null)h=Math.floor((f-S)/c)*c;else{h=p;for(let b of i)if(b<h)h=b;h=Math.floor(h/c)*c}h=Math.max(h,p-(Q2-1)*c);let x=[];for(let b=h;b<=p;b+=c)x.push(b);return x}var Ad=Z(gt(),1);class Wk extends Error{status;endpoint;constructor(l,i,c){super(c);this.name="ApiError",this.status=l,this.endpoint=i}}async function K2(l,i){try{let c=await l.json();if(typeof c==="object"&&c!==null&&"error"in c&&typeof c.error==="string")return c.error}catch{}return`HTTP error ${l.status} on ${i}`}var Zk=new WeakMap;async function Oa(l,i,c){let f=typeof c==="object"&&c!==null?Zk.get(c):void 0,p=i;if(f){let b=new Headers(i?.headers);b.set("If-None-Match",f),p={...i,headers:b}}let S=await fetch(l,p);if(S.status===304&&f)return c;if(!S.ok)throw new Wk(S.status,l,await K2(S,l));let h=await S.json(),x=S.headers.get("ETag");if(x&&typeof h==="object"&&h!==null)Zk.set(h,x);return h}var Jk={"X-Zeta-Stats-Action":"1"};async function e1(l="24h",i){return Oa(`/api/stats/overview?range=${encodeURIComponent(l)}`,{signal:i})}async function t1(l="24h",i){return Oa(`/api/stats/model-dashboard?range=${encodeURIComponent(l)}`,{signal:i})}async function a1(l="24h",i){return Oa(`/api/stats/costs?range=${encodeURIComponent(l)}`,{signal:i})}async function Mm(l=50,i){return Oa(`/api/stats/recent?limit=${l}`,{signal:i})}async function o1(l="24h",i=50,c){return Oa(`/api/stats/errors?range=${encodeURIComponent(l)}&limit=${i}`,{signal:c})}async function n1(l,i){return Oa(`/api/request/${l}`,{signal:i})}async function r1(){return Oa("/api/sync",{method:"POST"})}async function l1(l="24h",i){return Oa(`/api/stats/frustration?range=${encodeURIComponent(l)}`,{signal:i})}async function s1(l,i){return Oa(`/api/frustration/estimate?range=${encodeURIComponent(l)}`,{signal:i})}async function u1(l){return Oa(`/api/frustration/judge?range=${encodeURIComponent(l)}`,{method:"POST",headers:Jk})}async function i1(){return Oa("/api/frustration/cancel",{method:"POST",headers:Jk})}async function c1(l="24h",i){return Oa(`/api/stats/folders?range=${encodeURIComponent(l)}`,{signal:i})}async function d1(l="24h",i,c){let f=new URLSearchParams({range:l});if(i)f.set("project",i);return Oa(`/api/stats/gain?${f}`,{signal:c})}async function f1(l="24h",i){return Oa(`/api/stats/tools?range=${encodeURIComponent(l)}`,{signal:i})}async function p1(l="24h",i){return Oa(`/api/stats/providers?range=${encodeURIComponent(l)}`,{signal:i})}async function Pv(l,i,c){let f=new URLSearchParams({range:l});if(i!==null)f.set("provider",i);return Oa(`/api/stats/provider-windows?${f}`,{signal:c})}async function m1(l=100,i,c){let f=new URLSearchParams({limit:String(l)});if(i)f.set("q",i);return Oa(`/api/sessions?${f}`,{signal:c})}async function h1(l,i,c){return Oa(`/api/session/trace?file=${encodeURIComponent(l)}`,{signal:i,cache:"no-store"},c)}async function g1(l,i,c){return Oa(`/api/session/entry?file=${encodeURIComponent(l)}&id=${encodeURIComponent(i)}`,{signal:c})}var W2={phase:"idle",current:0,total:0,processed:0,lastSyncedAt:null,error:null};function J2(){r1().catch(()=>{})}var y1=null,v1=0,Dm=0,Xl={sync:W2,indexingHours:0,connected:!1,requestSync:J2},Hv=new Set;function b1(l){return Hv.add(l),()=>Hv.delete(l)}function x1(){for(let l of Hv)l()}function eM(l,i){return l.phase===i.phase&&l.current===i.current&&l.total===i.total&&l.processed===i.processed&&l.lastSyncedAt===i.lastSyncedAt&&l.error===i.error}function tM(l){if(y1!==l.version)y1=l.version,v1++;let i=Math.max(0,v1-1),c=l.indexingHours!==Xl.indexingHours||!eM(l.sync,Xl.sync);if(!c&&i===Dm)return;if(Dm=i,c)Xl={...Xl,sync:l.sync,indexingHours:l.indexingHours};x1()}function _v(l){if(l===Xl.connected)return;Xl={...Xl,connected:l},x1()}var aM=()=>Xl,oM=()=>Dm,nM=()=>-1;function S1(){return Dm}function L1({children:l}){return Ad.useEffect(()=>{let i=new EventSource("/api/events");return i.onopen=()=>_v(!0),i.onerror=()=>_v(!1),i.onmessage=(c)=>tM(JSON.parse(c.data)),()=>{i.close(),_v(!1)}},[]),l}function Em(){return Ad.useSyncExternalStore(b1,aM)}function C1(l=!0){return Ad.useSyncExternalStore(b1,l?oM:nM)}var Om=Z(ue(),1);function Bt({tone:l="neutral",mono:i,children:c}){return Om.jsxDEV("span",{className:"badge","data-tone":l,"data-mono":i??!1,children:c},void 0,!1,void 0,this)}function ur({tone:l="neutral",pulse:i}){return Om.jsxDEV("span",{className:"dot","data-tone":l,"data-pulse":i??!1},void 0,!1,void 0,this)}function Cn({color:l}){return Om.jsxDEV("span",{className:"swatch",style:{background:l}},void 0,!1,void 0,this)}function ir(l){if(l>=0.05)return"bad";if(l>=0.01)return"warn";return"ok"}var So=Z(ue(),1);function Ye({title:l,description:i,actions:c,flush:f,footer:p,className:S,index:h,stale:x,children:b}){let L=l!==void 0||i!==void 0||c!==void 0;return So.jsxDEV("section",{className:S?`card rise ${S}`:"card rise",style:h!==void 0?{"--i":h}:void 0,children:[L&&So.jsxDEV("header",{className:"card-header",children:[So.jsxDEV("div",{className:"card-titles",children:[l!==void 0&&So.jsxDEV("h2",{className:"card-title",children:l},void 0,!1,void 0,this),i!==void 0&&So.jsxDEV("p",{className:"card-description",children:i},void 0,!1,void 0,this)]},void 0,!0,void 0,this),c!==void 0&&So.jsxDEV("div",{className:"card-actions",children:c},void 0,!1,void 0,this)]},void 0,!0,void 0,this),So.jsxDEV("div",{className:"card-body","data-flush":f??!1,"data-stale":x??!1,children:b},void 0,!1,void 0,this),p!==void 0&&So.jsxDEV("footer",{className:"card-footer",children:p},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function ra({title:l,description:i,actions:c}){return So.jsxDEV("header",{className:"page-header rise",children:[So.jsxDEV("div",{children:[So.jsxDEV("h1",{className:"page-title",children:l},void 0,!1,void 0,this),i!==void 0&&So.jsxDEV("p",{className:"page-description",children:i},void 0,!1,void 0,this)]},void 0,!0,void 0,this),c!==void 0&&So.jsxDEV("div",{className:"page-actions",children:c},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var Md=Z(gt(),1),w1=Z(rd(),1),Qa=Z(ue(),1);function qm({open:l,onClose:i,title:c,subtitle:f,actions:p,width:S,children:h}){let x=Md.useRef(i);x.current=i;let b=Md.useRef(null);if(Md.useEffect(()=>{if(!l)return;let L=document.activeElement instanceof HTMLElement?document.activeElement:null;b.current?.focus();let g=(C)=>{if(C.key==="Escape")C.preventDefault(),x.current()};return window.addEventListener("keydown",g),()=>{window.removeEventListener("keydown",g),L?.focus()}},[l]),!l)return null;return w1.createPortal(Qa.jsxDEV(Qa.Fragment,{children:[Qa.jsxDEV("div",{className:"drawer-scrim",onClick:i,role:"presentation"},void 0,!1,void 0,this),Qa.jsxDEV("div",{ref:b,className:"drawer",role:"dialog","aria-modal":"true",tabIndex:-1,style:S!==void 0?{"--drawer-w":`${S}px`}:void 0,children:[Qa.jsxDEV("header",{className:"drawer-header",children:[Qa.jsxDEV("div",{className:"drawer-titles",children:[Qa.jsxDEV("h2",{className:"drawer-title",children:c},void 0,!1,void 0,this),f!==void 0&&Qa.jsxDEV("div",{className:"drawer-subtitle",children:f},void 0,!1,void 0,this)]},void 0,!0,void 0,this),p,Qa.jsxDEV("button",{type:"button",className:"btn","data-variant":"ghost","data-icon":"true",onClick:i,"aria-label":"Close",children:Qa.jsxDEV(nn,{size:16},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Qa.jsxDEV("div",{className:"drawer-body",children:h},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),document.body)}function Ho({items:l}){return Qa.jsxDEV("dl",{className:"kv",style:{margin:0},children:l.map((i)=>Qa.jsxDEV("div",{className:"kv-item",children:[Qa.jsxDEV("dt",{className:"kv-key",children:i.label},void 0,!1,void 0,this),Qa.jsxDEV("dd",{className:"kv-value",style:{margin:0},children:i.value},void 0,!1,void 0,this)]},i.key,!0,void 0,this))},void 0,!1,void 0,this)}var $s=Z(gt(),1);var wn=Z(ue(),1);function di({data:l,title:i=u("ui.json"),initialCollapsed:c=!1}){let[f,p]=$s.useState(c),[S,h]=$s.useState(!1),x=$s.useRef(0),b=JSON.stringify(l,null,2);return $s.useEffect(()=>()=>window.clearTimeout(x.current),[]),wn.jsxDEV("div",{className:"stack",style:{gap:6},children:[wn.jsxDEV("div",{className:"row",style:{justifyContent:"space-between"},children:[wn.jsxDEV("button",{type:"button",className:"btn","data-variant":"ghost","data-size":"sm",onClick:()=>p((g)=>!g),"aria-expanded":!f,children:[f?wn.jsxDEV(Ln,{size:13},void 0,!1,void 0,this):wn.jsxDEV(Vs,{size:13},void 0,!1,void 0,this),i]},void 0,!0,void 0,this),wn.jsxDEV("button",{type:"button",className:"btn","data-variant":"ghost","data-size":"sm",onClick:async()=>{try{await navigator.clipboard.writeText(b),h(!0),window.clearTimeout(x.current),x.current=window.setTimeout(()=>h(!1),1500)}catch{}},children:[S?wn.jsxDEV(Gs,{size:13},void 0,!1,void 0,this):wn.jsxDEV(js,{size:13},void 0,!1,void 0,this),S?u("common.copied"):u("common.copy")]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),!f&&wn.jsxDEV("pre",{className:"code-block",children:wn.jsxDEV("code",{children:b},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var Qs=Z(gt(),1),k1=Z(rd(),1);var kn=Z(ue(),1);function T1({open:l,title:i,onClose:c,primaryAction:f,cancelLabel:p=u("common.cancel"),children:S}){let h=Qs.useRef(null),x=Qs.useRef(null),b=Qs.useRef(c);b.current=c,Qs.useEffect(()=>{if(!l)return;let w=document.activeElement instanceof HTMLElement?document.activeElement:null,A=(k)=>{if(k.key==="Escape")k.preventDefault(),b.current()};return window.addEventListener("keydown",A),()=>{window.removeEventListener("keydown",A),w?.focus()}},[l]);let L=f!==void 0,g=f?.disabled??!1;if(Qs.useEffect(()=>{if(!l)return;(L&&!g?h.current:x.current)?.focus()},[l,L,g]),!l)return null;return k1.createPortal(kn.jsxDEV("div",{className:"modal-overlay",onClick:(w)=>{if(w.target===w.currentTarget)c()},role:"presentation",children:kn.jsxDEV("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"modal-title",children:[kn.jsxDEV("div",{className:"modal-header",children:[kn.jsxDEV("h2",{id:"modal-title",className:"modal-title",children:i},void 0,!1,void 0,this),kn.jsxDEV("button",{type:"button",className:"btn","data-variant":"ghost","data-icon":"true","data-size":"sm",onClick:c,"aria-label":u("common.close"),children:kn.jsxDEV(nn,{size:15},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),kn.jsxDEV("div",{className:"modal-body",children:S},void 0,!1,void 0,this),kn.jsxDEV("div",{className:"modal-footer",children:[kn.jsxDEV("button",{ref:x,type:"button",className:"btn",onClick:c,children:p},void 0,!1,void 0,this),f&&kn.jsxDEV("button",{ref:h,type:"button",className:"btn","data-variant":"primary",onClick:f.onClick,disabled:f.disabled,children:f.label},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),document.body)}var Nm=Z(ue(),1);function cr({value:l,onChange:i,placeholder:c=u("common.filter"),width:f}){return Nm.jsxDEV("label",{className:"search",children:[Nm.jsxDEV(kd,{size:14},void 0,!1,void 0,this),Nm.jsxDEV("input",{className:"input",type:"search",value:l,placeholder:c,onChange:(p)=>i(p.target.value),style:f!==void 0?{width:f}:void 0},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var fi=Z(gt(),1),Bm=Z(ue(),1);function _a({options:l,value:i,onChange:c,size:f="md","aria-label":p}){let S=fi.useRef(null),[h,x]=fi.useState(null);return fi.useLayoutEffect(()=>{let b=S.current,L=b?.querySelector('[data-active="true"]');if(!b||!L){x(null);return}let g=()=>x({left:L.offsetLeft,width:L.offsetWidth});g();let C=new ResizeObserver(g);return C.observe(b),()=>C.disconnect()},[i,l]),Bm.jsxDEV("div",{ref:S,className:"segmented","data-size":f,role:"radiogroup","aria-label":p,children:[h&&Bm.jsxDEV("span",{className:"segmented-thumb",style:{left:h.left,width:h.width}},void 0,!1,void 0,this),l.map((b)=>Bm.jsxDEV("button",{type:"button",role:"radio","aria-checked":b.value===i,className:"segmented-option","data-active":b.value===i,title:b.title,onClick:()=>c(b.value),children:b.label},b.value,!1,void 0,this))]},void 0,!0,void 0,this)}var hi=Z(gt(),1);var pi=Z(gt(),1);function zm(){let l=pi.useRef(null),[i,c]=pi.useState(0);return pi.useLayoutEffect(()=>{let f=l.current;if(!f)return;c(f.clientWidth);let p=new ResizeObserver((S)=>{let h=Math.round(S[0]?.contentRect.width??0);c((x)=>x===h?x:h)});return p.observe(f),()=>p.disconnect()},[]),[l,i]}var Dd=Z(ue(),1);function mi({values:l,color:i="var(--chart-primary)",height:c=28,width:f,area:p=!0}){let[S,h]=zm(),x=f??h,b=Math.max(0,...l),L=l.length,g="";if(x>0&&L>0){let C=L>1?x/(L-1):0;for(let w=0;w<L;w++){let A=L>1?w*C:x/2,k=b>0?c-2-l[w]/b*(c-4):c-2;g+=`${w===0?"M":"L"}${A.toFixed(1)},${k.toFixed(1)}`}}return Dd.jsxDEV("div",{ref:S,className:"sparkline",style:{width:f??"100%",height:c},children:x>0&&L>0&&Dd.jsxDEV("svg",{width:x,height:c,"aria-hidden":"true",children:[p&&Dd.jsxDEV("path",{className:"area",d:`${g}L${x},${c}L0,${c}Z`,fill:i},void 0,!1,void 0,this),Dd.jsxDEV("path",{className:"chart-line",d:g,stroke:i},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}var rn=Z(ue(),1);function ie({label:l,value:i,hint:c,delta:f,spark:p,sparkColor:S,size:h="md",title:x}){let b=sM(typeof i==="string"||typeof i==="number"?i:null);return rn.jsxDEV("div",{className:"stat","data-size":h,title:x,children:[rn.jsxDEV("div",{className:"stat-label",children:l},void 0,!1,void 0,this),rn.jsxDEV("div",{className:"stat-value","data-flash":b,children:i},void 0,!1,void 0,this),(c!==void 0||f)&&rn.jsxDEV("div",{className:"stat-foot",children:[f&&rn.jsxDEV(lM,{...f},void 0,!1,void 0,this),c!==void 0&&rn.jsxDEV("span",{className:"truncate",children:c},void 0,!1,void 0,this)]},void 0,!0,void 0,this),p&&p.length>1&&rn.jsxDEV("div",{className:"stat-spark",children:rn.jsxDEV(mi,{values:p,color:S},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function la({min:l,children:i}){return rn.jsxDEV("div",{className:"stat-grid rise",style:l!==void 0?{"--stat-min":`${l}px`}:void 0,children:i},void 0,!1,void 0,this)}function lM({change:l,good:i="up"}){if(l===null||!Number.isFinite(l))return rn.jsxDEV("span",{className:"delta",children:"new"},void 0,!1,void 0,this);let c=Math.abs(l)<0.0005?0:l,f=c===0?void 0:c>0===(i==="up")?"good":"bad",p=c>0?"+":c<0?"−":"±",S=Math.abs(c)*100;return rn.jsxDEV("span",{className:"delta","data-tone":f,children:[p,S>=100?S.toFixed(0):S.toFixed(1),"%"]},void 0,!0,void 0,this)}function sM(l){let i=hi.useRef(l),[c,f]=hi.useState(!1);return hi.useEffect(()=>{if(i.current===l)return;let p=i.current!==null;if(i.current=l,!p)return;f(!0);let S=setTimeout(()=>f(!1),900);return()=>clearTimeout(S)},[l]),c}var ga=Z(ue(),1);function wt({title:l=u("common.nothing-here-yet"),hint:i}){return ga.jsxDEV("div",{className:"empty",children:[ga.jsxDEV(bd,{size:20},void 0,!1,void 0,this),ga.jsxDEV("div",{className:"empty-title",children:l},void 0,!1,void 0,this),i!==void 0&&ga.jsxDEV("div",{className:"empty-hint",children:i},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function gi({error:l,onRetry:i}){return ga.jsxDEV("div",{className:"error-state",role:"alert",children:[ga.jsxDEV(Vl,{size:15},void 0,!1,void 0,this),ga.jsxDEV("span",{className:"error-state-message",children:typeof l==="string"?l:l.message},void 0,!1,void 0,this),i&&ga.jsxDEV("button",{type:"button",className:"btn","data-size":"sm","data-variant":"ghost",onClick:i,children:[ga.jsxDEV(wd,{size:13},void 0,!1,void 0,this)," ",u("ui.retry")]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function qa({width:l="100%",height:i=14,style:c}){return ga.jsxDEV("div",{className:"skeleton",style:{width:l,height:i,...c}},void 0,!1,void 0,this)}function zt({height:l=220}){return ga.jsxDEV(qa,{height:l,style:{borderRadius:8}},void 0,!1,void 0,this)}function ca({rows:l=6}){return ga.jsxDEV("div",{style:{display:"flex",flexDirection:"column",gap:10,padding:"8px 16px 16px"},children:Array.from({length:l},(i,c)=>ga.jsxDEV(qa,{height:16,width:`${92-c*13%30}%`},c,!1,void 0,this))},void 0,!1,void 0,this)}function Ge({query:l,skeleton:i,isEmpty:c,empty:f,children:p}){if(l.data===null){if(l.error)return ga.jsxDEV(gi,{error:l.error,onRetry:l.refetch},void 0,!1,void 0,this);return ga.jsxDEV(ga.Fragment,{children:i},void 0,!1,void 0,this)}return ga.jsxDEV(ga.Fragment,{children:[l.error&&ga.jsxDEV(gi,{error:l.error,onRetry:l.refetch},void 0,!1,void 0,this),c?.(l.data)?f??ga.jsxDEV(wt,{},void 0,!1,void 0,this):p(l.data)]},void 0,!0,void 0,this)}var Zs=Z(gt(),1);function Gv(){return Xs()}function z(l){return l.toLocaleString(Gv())}function Ae(l){return l.toLocaleString(Gv(),{notation:"compact"})}function da(l,i){if(l===0)return"$0";let c=i!==void 0?i:l>0&&l<0.01?4:2;return`$${l.toLocaleString(Gv(),{minimumFractionDigits:c,maximumFractionDigits:c})}`}function Ht(l,i,c){return l===0&&i>0?"N/A":da(l,c)}function Vv(l){return l.usage.totalTokens>0&&l.usage.cost.total===0&&(l.provider==="xai-oauth"||l.costUnpriced===!0)}function Yl(l,i){return Ht(l.usage.cost.total,Vv(l)?1:0,i)}function Fe(l,i=1){return`${(l*100).toFixed(i)}%`}function to(l){let i=l*100;if(i>0&&i<0.005)return"<0.01%";return Fe(l,i>0&&i<0.1?2:1)}function At(l,i){if(l===null)return"-";let c=l/1000,f=i!==void 0?i:c<1?2:1;return`${c.toFixed(f)}s`}function Ks(l){if(l<60000)return At(l);let i=Math.floor(l/60000);if(i<60)return`${i}m ${String(Math.floor(l%60000/1000)).padStart(2,"0")}s`;return`${Math.floor(i/60)}h ${String(i%60).padStart(2,"0")}m`}function dr(l){if(l===null)return"-";return l.toFixed(1)}var Fv=[["second",1000],["minute",60000],["hour",3600000],["day",86400000],["month",2629800000],["year",31557600000]],I1=new Map,Um=new Map;function fa(l,i=Date.now()){let c=Xs(),f=I1.get(c);if(!f)f=new Intl.RelativeTimeFormat(c,{numeric:"auto"}),I1.set(c,f);let p=l-i,S=0;for(let b=1;b<Fv.length;b++)if(Math.abs(p)>=Fv[b][1])S=b;let[h,x]=Fv[S];return f.format(Math.round(p/x),h)}function jv(l){let i=Xs(),c=`${i}:mdhm`,f=Um.get(c);if(!f)f=new Intl.DateTimeFormat(i,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}),Um.set(c,f);return f.format(l)}function ln(l){let i=Xs(),c=Um.get(i);if(!c)c=new Intl.DateTimeFormat(i,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",hourCycle:"h23"}),Um.set(i,c);return c.format(l)}function fr(l){return l.replace(/^\/+|\/+$/g,"")||u("common.root")}function Xv(l){if(l>=1e9)return`${(l/1e9).toFixed(1)} GB`;if(l>=1e6)return`${(l/1e6).toFixed(1)} MB`;if(l>=1000)return`${(l/1000).toFixed(1)} KB`;return`${l} B`}var Mt=Z(ue(),1);function Xt({columns:l,rows:i,rowKey:c,onRowClick:f,selectedKey:p,initialSort:S,limit:h,dense:x,empty:b,expanded:L}){let[g,C]=Zs.useState(S??null),[w,A]=Zs.useState(h??Number.POSITIVE_INFINITY),k=Zs.useMemo(()=>{let B=g?l.find((Y)=>Y.key===g.key):void 0;if(!g||!B?.sort)return i;let P=B.sort,j=g.dir==="asc"?1:-1;return[...i].sort((Y,ce)=>{let J=P(Y),te=P(ce);if(typeof J==="number"&&typeof te==="number")return(J-te)*j;return String(J).localeCompare(String(te))*j})},[i,l,g]);if(i.length===0)return Mt.jsxDEV(Mt.Fragment,{children:b??Mt.jsxDEV(wt,{},void 0,!1,void 0,this)},void 0,!1,void 0,this);let D=k.length>w?k.slice(0,w):k,M=(B)=>{if(!B.sort)return;C((P)=>P?.key===B.key?{key:B.key,dir:P.dir==="asc"?"desc":"asc"}:{key:B.key,dir:B.align==="right"?"desc":"asc"})};return Mt.jsxDEV(Mt.Fragment,{children:[Mt.jsxDEV("div",{className:"table-wrap",children:Mt.jsxDEV("table",{className:"table","data-dense":x??!1,children:[Mt.jsxDEV("thead",{children:Mt.jsxDEV("tr",{children:l.map((B)=>{let P=g?.key===B.key?g.dir:void 0;return Mt.jsxDEV("th",{"data-align":B.align??"left","data-sortable":B.sort!==void 0,"data-sorted":P,style:B.width!==void 0?{width:B.width}:void 0,title:B.title,onClick:()=>M(B),"aria-sort":P==="asc"?"ascending":P==="desc"?"descending":void 0,children:[B.header,P&&Mt.jsxDEV("span",{className:"sort-arrow",children:P==="asc"?Mt.jsxDEV(pd,{size:11},void 0,!1,void 0,this):Mt.jsxDEV(id,{size:11},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},B.key,!0,void 0,this)})},void 0,!1,void 0,this)},void 0,!1,void 0,this),Mt.jsxDEV("tbody",{children:D.map((B)=>{let P=c(B),j=L?.(B)??null;return Mt.jsxDEV(Zs.Fragment,{children:[Mt.jsxDEV("tr",{"data-clickable":f!==void 0,"data-selected":p===P,onClick:f?()=>f(B):void 0,onKeyDown:f?(Y)=>{if(Y.key==="Enter"||Y.key===" ")Y.preventDefault(),f(B)}:void 0,tabIndex:f?0:void 0,children:l.map((Y)=>Mt.jsxDEV("td",{"data-align":Y.align??"left","data-wrap":Y.wrap??!1,children:Y.render(B)},Y.key,!1,void 0,this))},void 0,!1,void 0,this),j!==null&&Mt.jsxDEV("tr",{children:Mt.jsxDEV("td",{colSpan:l.length,"data-wrap":"true",style:{padding:0},children:j},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},P,!0,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),h!==void 0&&k.length>h&&Mt.jsxDEV("div",{className:"table-more",children:[Mt.jsxDEV("span",{className:"micro",children:u("ui.table-shown-of",{shown:z(D.length),total:z(k.length)})},void 0,!1,void 0,this),k.length>w&&Mt.jsxDEV("button",{type:"button",className:"btn","data-size":"sm","data-variant":"ghost",onClick:()=>A((B)=>B+h*4),children:u("common.show-more")},void 0,!1,void 0,this),w>h&&Mt.jsxDEV("button",{type:"button",className:"btn","data-size":"sm","data-variant":"ghost",onClick:()=>A(h),children:u("ui.show-fewer")},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function pa({value:l,max:i,display:c,color:f}){let p=i>0?Math.min(100,l/i*100):0;return Mt.jsxDEV("div",{className:"meter-cell",children:[Mt.jsxDEV("span",{className:"num",children:c},void 0,!1,void 0,this),Mt.jsxDEV("div",{className:"meter",children:Mt.jsxDEV("div",{className:"meter-fill",style:{width:`${p}%`,background:f}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Ha({primary:l,secondary:i,lead:c}){return Mt.jsxDEV("div",{className:"row",style:{gap:10},children:[c,Mt.jsxDEV("div",{className:"stack",style:{gap:0},children:[Mt.jsxDEV("span",{className:"cell-primary truncate",children:l},void 0,!1,void 0,this),i!==void 0&&Mt.jsxDEV("span",{className:"cell-secondary truncate",children:i},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var Pm=Z(gt(),1);var Jt=Z(ue(),1);function R1(){let{sync:l,indexingHours:i,connected:c,requestSync:f}=Em(),p=iM(l.phase==="idle"?15000:null),S,h;if(!c)S=Jt.jsxDEV(Jt.Fragment,{children:[Jt.jsxDEV(ur,{tone:"warn"},void 0,!1,void 0,this),Jt.jsxDEV("span",{children:u("shell.reconnecting")},void 0,!1,void 0,this)]},void 0,!0,void 0,this),h=u("shell.lost-connection");else if(l.phase==="syncing")S=Jt.jsxDEV(Jt.Fragment,{children:[Jt.jsxDEV(jl,{size:13,className:"spin"},void 0,!1,void 0,this),Jt.jsxDEV("span",{children:u("shell.syncing")},void 0,!1,void 0,this),l.total>0&&Jt.jsxDEV("span",{className:"live-chip-count",children:[z(l.current),"/",z(l.total)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),h=u("shell.ingesting");else if(l.phase==="error")S=Jt.jsxDEV(Jt.Fragment,{children:[Jt.jsxDEV(ur,{tone:"bad"},void 0,!1,void 0,this),Jt.jsxDEV("span",{children:u("shell.sync-failed")},void 0,!1,void 0,this)]},void 0,!0,void 0,this),h=`${l.error??u("shell.sync-failed")} — click to retry`;else if(i>uM)S=Jt.jsxDEV(Jt.Fragment,{children:[Jt.jsxDEV(jl,{size:13,className:"spin"},void 0,!1,void 0,this),Jt.jsxDEV("span",{children:u("shell.indexing")},void 0,!1,void 0,this),Jt.jsxDEV("span",{className:"live-chip-count",children:[z(i),"h left"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),h=u("shell.building-rollups");else S=Jt.jsxDEV(Jt.Fragment,{children:[Jt.jsxDEV(ur,{tone:"live",pulse:!0},void 0,!1,void 0,this),Jt.jsxDEV("span",{children:u("shell.live")},void 0,!1,void 0,this),l.lastSyncedAt!==null&&Jt.jsxDEV("span",{className:"live-chip-count",children:cM(p-l.lastSyncedAt)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),h=u("shell.sync-now");return Jt.jsxDEV("button",{type:"button",className:"live-chip",onClick:f,disabled:l.phase==="syncing",title:h,children:S},void 0,!1,void 0,this)}var uM=24;function iM(l){let[i,c]=Pm.useState(Date.now);return Pm.useEffect(()=>{if(l===null)return;c(Date.now());let f=setInterval(()=>c(Date.now()),l);return()=>clearInterval(f)},[l]),i}function cM(l){let i=Math.max(0,Math.round(l/1000));if(i<45)return u("shell.just-now");let c=Math.round(i/60);if(c<60)return`${c}m ago`;let f=Math.round(c/60);return f<24?`${f}h ago`:`${Math.round(f/24)}d ago`}var _m=[{headingKey:"nav.usage",items:[{id:"overview",labelKey:"nav.overview",icon:xd,hotkey:"o"},{id:"models",labelKey:"nav.models",icon:gd,hotkey:"m"},{id:"providers",labelKey:"nav.providers",icon:Gl,hotkey:"p"},{id:"costs",labelKey:"nav.costs",icon:hd,hotkey:"c"}]},{headingKey:"nav.activity",items:[{id:"requests",labelKey:"nav.requests",icon:ud,hotkey:"r"},{id:"errors",labelKey:"nav.errors",icon:Hl,hotkey:"e"},{id:"traces",labelKey:"nav.traces",icon:Sn,hotkey:"t"}]},{headingKey:"nav.insights",items:[{id:"tools",labelKey:"nav.tools",icon:Id,hotkey:"l"},{id:"frustration",labelKey:"nav.frustration",icon:Fl,hotkey:"f"},{id:"projects",labelKey:"nav.projects",icon:yd,hotkey:"j"},{id:"gain",labelKey:"nav.gain",icon:lr,hotkey:"g"}]}],dM=_m.flatMap((l)=>l.items),A1=dM.map((l)=>l.id);var Hm=Z(gt(),1),M1="zeta-stats-theme",D1="(prefers-color-scheme: dark)";function fM(){if(typeof localStorage>"u")return"system";let l=localStorage.getItem(M1);return l==="light"||l==="dark"||l==="system"?l:"system"}function E1(){if(typeof window>"u")return"dark";return window.matchMedia(D1).matches?"dark":"light"}var Ws=fM(),Ed=Ws==="system"?E1():Ws,Yv=new Set;function O1(){for(let l of Yv)l()}function $v(){if(Ed=Ws==="system"?E1():Ws,typeof document<"u")document.documentElement.dataset.theme=Ed,document.documentElement.style.colorScheme=Ed}if(typeof window<"u")$v(),window.matchMedia(D1).addEventListener("change",()=>{if(Ws==="system")$v(),O1()});function pM(l){if(Ws=l,typeof localStorage<"u")localStorage.setItem(M1,l);$v(),O1()}function Qv(l){return Yv.add(l),()=>Yv.delete(l)}function q1(){return Hm.useSyncExternalStore(Qv,()=>Ed,()=>"dark")}function N1(){let l=Hm.useSyncExternalStore(Qv,()=>Ws,()=>"system"),i=Hm.useSyncExternalStore(Qv,()=>Ed,()=>"dark");return{preference:l,resolved:i,setPreference:pM}}var Kv=Z(ue(),1),mM={system:"light",light:"dark",dark:"system"},hM={system:Ld,light:Td,dark:Cd},B1={system:u("shell.system-theme"),light:u("shell.light-theme"),dark:u("shell.dark-theme")};function z1(){let{preference:l,setPreference:i}=N1(),c=hM[l];return Kv.jsxDEV("button",{type:"button",className:"btn","data-variant":"ghost","data-icon":"true",onClick:()=>i(mM[l]),"aria-label":`${B1[l]} (click to switch)`,title:`${B1[l]} — click to switch`,children:Kv.jsxDEV(c,{size:15},void 0,!1,void 0,this)},void 0,!1,void 0,this)}var at=Z(ue(),1),gM=ci.map((l,i)=>({value:l,label:u(ia(l).labelKey),title:`${u(ia(l).windowKey)} (${i+1})`}));function U1({section:l,onSectionChange:i,range:c,onRangeChange:f,children:p}){let[S,h]=yi.useState(!1),x=yM(),{sync:b}=Em();vM(i,f);let L=(C)=>{i(C),h(!1),window.scrollTo({top:0})},g=b.phase==="syncing"?b.total>0?b.current/b.total:null:void 0;return at.jsxDEV(at.Fragment,{children:[at.jsxDEV("div",{className:"shell-ambient"},void 0,!1,void 0,this),at.jsxDEV("header",{className:"topbar","data-scrolled":x,children:[at.jsxDEV("button",{type:"button",className:"btn topbar-menu","data-variant":"ghost","data-icon":"true",onClick:()=>h(!0),"aria-label":u("nav.open-navigation"),children:at.jsxDEV(Sd,{size:16},void 0,!1,void 0,this)},void 0,!1,void 0,this),at.jsxDEV("div",{className:"topbar-brand",children:[at.jsxDEV("svg",{className:"topbar-mark",viewBox:"0 0 64 64",width:"22",height:"22","aria-hidden":"true",children:[at.jsxDEV("defs",{children:at.jsxDEV("linearGradient",{id:"zeta-mark-grad",x1:"0",y1:"0",x2:"1",y2:"1",children:[at.jsxDEV("stop",{offset:"0",stopColor:"oklch(0.7 0.24 340)"},void 0,!1,void 0,this),at.jsxDEV("stop",{offset:".5",stopColor:"oklch(0.62 0.21 295)"},void 0,!1,void 0,this),at.jsxDEV("stop",{offset:"1",stopColor:"oklch(0.81 0.14 200)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),at.jsxDEV("text",{x:"32",y:"47",textAnchor:"middle",fontSize:"52",fontWeight:"700",fontFamily:"Georgia, 'Times New Roman', serif",fill:"url(#zeta-mark-grad)",children:"ζ"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),at.jsxDEV("span",{children:"zeta"},void 0,!1,void 0,this),at.jsxDEV("span",{className:"topbar-slash",children:"/"},void 0,!1,void 0,this),at.jsxDEV("span",{className:"topbar-title",children:u("nav.breadcrumb-stats")},void 0,!1,void 0,this)]},void 0,!0,void 0,this),at.jsxDEV("div",{className:"topbar-spacer"},void 0,!1,void 0,this),at.jsxDEV("div",{className:"topbar-actions",children:[at.jsxDEV("span",{className:"topbar-hide-narrow",children:at.jsxDEV(R1,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),at.jsxDEV(_a,{options:gM,value:c,onChange:f,"aria-label":u("common.time-range")},void 0,!1,void 0,this),at.jsxDEV(z1,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this),g!==void 0&&at.jsxDEV("div",{className:"topbar-progress",children:at.jsxDEV("div",{className:"topbar-progress-fill","data-indeterminate":g===null,style:{width:`${(g??0)*100}%`}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),S&&at.jsxDEV("div",{className:"drawer-scrim",onClick:()=>h(!1),role:"presentation"},void 0,!1,void 0,this),at.jsxDEV("nav",{className:"sidebar","data-open":S,"aria-label":u("nav.pages"),children:[_m.map((C)=>at.jsxDEV("div",{className:"nav-group",children:[at.jsxDEV("div",{className:"nav-heading",children:u(C.headingKey)},void 0,!1,void 0,this),C.items.map((w)=>at.jsxDEV("button",{type:"button",className:"nav-row","data-active":w.id===l,"aria-current":w.id===l?"page":void 0,onClick:()=>L(w.id),children:[at.jsxDEV(w.icon,{size:15},void 0,!1,void 0,this),at.jsxDEV("span",{className:"nav-row-label",children:u(w.labelKey)},void 0,!1,void 0,this),at.jsxDEV("kbd",{children:["G ",w.hotkey.toUpperCase()]},void 0,!0,void 0,this)]},w.id,!0,void 0,this))]},C.headingKey,!0,void 0,this)),at.jsxDEV("div",{className:"sidebar-foot micro",children:[at.jsxDEV("span",{children:[at.jsxDEV("span",{className:"kbd",children:"1"},void 0,!1,void 0,this),"–",at.jsxDEV("span",{className:"kbd",children:"6"},void 0,!1,void 0,this)," ",u("shell.range-suffix")]},void 0,!0,void 0,this),at.jsxDEV("span",{children:[at.jsxDEV("span",{className:"kbd",children:"G"},void 0,!1,void 0,this)," ",u("shell.jump-hint")]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),at.jsxDEV("main",{className:"shell-panel",children:at.jsxDEV("div",{className:"shell-content",children:p},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function yM(){let[l,i]=yi.useState(!1);return yi.useEffect(()=>{let c=()=>i(window.scrollY>4);return c(),window.addEventListener("scroll",c,{passive:!0}),()=>window.removeEventListener("scroll",c)},[]),l}function vM(l,i){yi.useEffect(()=>{let c=0,f=(p)=>{if(p.metaKey||p.ctrlKey||p.altKey||p.defaultPrevented)return;let S=p.target;if(S instanceof HTMLElement&&(S.isContentEditable||S.tagName==="INPUT"||S.tagName==="TEXTAREA"||S.tagName==="SELECT"))return;if(document.querySelector('[aria-modal="true"]'))return;let h=p.key.toLowerCase();if(c&&Date.now()-c<1200){c=0;let b=_m.flatMap((L)=>L.items).find((L)=>L.hotkey===h);if(b)p.preventDefault(),l(b.id),window.scrollTo({top:0});return}if(h==="g"){c=Date.now();return}let x=Number(h)-1;if(Number.isInteger(x)&&x>=0&&x<ci.length)p.preventDefault(),i(ci[x])};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[l,i])}var Vr=Z(gt(),1);function Od(l){let[i,c]=l.replace(/^#\/?/,"").split("?"),f=A1.includes(i)?i:"overview",p=new URLSearchParams(c??""),S=p.get("range"),h=ci.includes(S??"")?S:"24h";return{section:f,range:h,session:p.get("s")}}function Fm({section:l,range:i,session:c}){let f=c?`&s=${encodeURIComponent(c)}`:"";return`#/${l}?range=${i}${f}`}function P1(){let[l,i]=Vr.useState(()=>Od(window.location.hash));Vr.useEffect(()=>{let h=()=>i(Od(window.location.hash));window.addEventListener("hashchange",h),window.addEventListener("popstate",h);let x=Fm(Od(window.location.hash));if(window.location.hash!==x)history.replaceState(null,"",x);return()=>{window.removeEventListener("hashchange",h),window.removeEventListener("popstate",h)}},[]);let c=Vr.useCallback((h)=>{i(h);let x=Fm(h);if(window.location.hash!==x)history.pushState(null,"",x)},[]),f=Vr.useCallback((h)=>c({...l,section:h,session:h==="traces"?l.session:null}),[l,c]),p=Vr.useCallback((h)=>c({...l,range:h}),[l,c]),S=Vr.useCallback((h)=>c({...l,session:h}),[l,c]);return{...l,setSection:f,setRange:p,setSession:S}}var zd=Z(gt(),1);var pr=Z(ue(),1);function qd({items:l,max:i,onSelect:c}){let f=i??Math.max(0,...l.map((p)=>p.value));return pr.jsxDEV("div",{className:"bar-list",children:l.map((p)=>{let S=f>0?Math.max(0.5,p.value/f*100):0,h=pr.jsxDEV(pr.Fragment,{children:[pr.jsxDEV("span",{className:"bar-list-fill",style:{width:`${S}%`,background:p.color??"var(--chart-primary)"}},void 0,!1,void 0,this),pr.jsxDEV("span",{className:"bar-list-label",children:p.label},void 0,!1,void 0,this),pr.jsxDEV("span",{className:"bar-list-value",children:p.display??z(p.value)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return c?pr.jsxDEV("button",{type:"button",className:"bar-list-row",onClick:()=>c(p.key),children:h},p.key,!1,void 0,this):pr.jsxDEV("div",{className:"bar-list-row",children:h},p.key,!1,void 0,this)})},void 0,!1,void 0,this)}var jr=Z(gt(),1);var bt=Z(ue(),1),Js=10,bM=24,xM=68,SM=4;function Tn({slots:l,tickLabel:i,tooltipTitle:c,series:f,kind:p="bars",stacked:S=!0,height:h=220,format:x=Ae,formatRight:b,formatTooltip:L,yMax:g,yMaxRight:C,hidden:w,showTotal:A,references:k,onSelect:D,emptyLabel:M="No data in this range",tooltipExtra:B}){let[P,j]=zm(),[Y,ce]=jr.useState(null),J=jr.useId().replace(/:/g,""),te=jr.useMemo(()=>f.filter((V)=>!w?.has(V.key)),[f,w]),X=jr.useMemo(()=>{let V=te.filter((ft)=>ft.axis!=="right"),Re=te.filter((ft)=>ft.axis==="right"),oe=(ft)=>S&&(ft.kind??p)!=="line",ve=new Map,G=Array.from({length:l},()=>0),_e=0;for(let ft of V)if(oe(ft)){let Oe=G.slice();ve.set(ft.key,Oe);for(let un=0;un<l;un++)G[un]+=ft.values[un]??0}else for(let Oe=0;Oe<l;Oe++)_e=Math.max(_e,ft.values[Oe]??0);for(let ft of G)_e=Math.max(_e,ft);let Qe=0;for(let ft of Re)for(let Oe=0;Oe<l;Oe++)Qe=Math.max(Qe,ft.values[Oe]??0);for(let ft of k??[])if(ft.axis==="right")Qe=Math.max(Qe,ft.value);else _e=Math.max(_e,ft.value);let Ue=_1(g??_e),dt=Re.length>0?_1(C??Qe):null,et=te.every((ft)=>ft.values.every((Oe)=>!Oe));return{left:V,right:Re,bases:ve,stackable:oe,leftScale:Ue,rightScale:dt,empty:et}},[te,l,S,p,g,C,k]),ae=X.leftScale.ticks.map((V)=>x(V)),H=X.rightScale?.ticks.map((V)=>(b??x)(V))??[],de=Math.max(28,H1(ae)+12),xe=X.rightScale?Math.max(28,H1(H)+12):8,Ce=Math.max(0,j-de-xe),Be=h-Js-bM,ne=l>0?Ce/l:0,me=(V)=>Js+Be-V/X.leftScale.max*Be,ke=(V)=>Js+Be-V/(X.rightScale?.max??1)*Be,$e=(V)=>de+(V+0.5)*ne,xt=te.filter((V)=>(V.kind??p)==="bars"),W=xt.filter((V)=>!X.stackable(V)||V.axis==="right"),ze=Math.max(1,Math.min(56,ne*(ne>6?0.72:0.9))),Ct=Math.max(1,Math.ceil(l/Math.max(1,Math.floor(Ce/xM)))),it=(V)=>{let Re=V.currentTarget.getBoundingClientRect(),oe=Math.floor((V.clientX-Re.left)/(Re.width/l));ce(oe>=0&&oe<l?oe:null)},ct=Y===null?[]:te.filter((V)=>V.tooltip!==!1).map((V)=>({s:V,v:V.values[Y]})).filter((V)=>V.v!==null&&V.v!==void 0&&(V.v!==0||te.length===1)).sort((V,Re)=>te.length>1?Re.v-V.v:0),Me=ct.filter((V)=>V.s.axis!=="right").reduce((V,Re)=>V+Re.v,0),ye=A??(S&&X.left.length>1);return bt.jsxDEV("div",{className:"chart",ref:P,"data-hovering":Y!==null,style:{height:h},children:[j>0&&bt.jsxDEV("svg",{width:j,height:h,role:"img",children:[bt.jsxDEV("defs",{children:te.filter((V)=>V.pattern==="hatch").map((V)=>bt.jsxDEV("pattern",{id:`${J}-${Zv(V.key)}`,width:"5",height:"5",patternUnits:"userSpaceOnUse",patternTransform:"rotate(45)",children:[bt.jsxDEV("rect",{width:"5",height:"5",fill:V.color,fillOpacity:"0.14"},void 0,!1,void 0,this),bt.jsxDEV("rect",{width:"1.6",height:"5",fill:V.color},void 0,!1,void 0,this)]},V.key,!0,void 0,this))},void 0,!1,void 0,this),bt.jsxDEV("g",{className:"chart-grid",children:X.leftScale.ticks.map((V)=>bt.jsxDEV("line",{x1:de,x2:de+Ce,y1:me(V),y2:me(V)},V,!1,void 0,this))},void 0,!1,void 0,this),bt.jsxDEV("g",{className:"chart-axis",children:[X.leftScale.ticks.map((V,Re)=>bt.jsxDEV("text",{x:de-8,y:me(V),dy:"0.32em",textAnchor:"end",children:ae[Re]},V,!1,void 0,this)),X.rightScale?.ticks.map((V,Re)=>bt.jsxDEV("text",{x:de+Ce+8,y:ke(V),dy:"0.32em",textAnchor:"start",children:H[Re]},V,!1,void 0,this)),Array.from({length:l},(V,Re)=>Re%Ct===0?bt.jsxDEV("text",{x:$e(Re),y:h-6,textAnchor:"middle",children:i(Re)},Re,!1,void 0,this):null)]},void 0,!0,void 0,this),Y!==null&&bt.jsxDEV("rect",{className:"chart-cursor",x:de+Y*ne,y:Js,width:ne,height:Be},void 0,!1,void 0,this),te.filter((V)=>(V.kind??p)==="area").map((V)=>{let Re=V.axis==="right"?ke:me,oe=X.bases.get(V.key),ve=(Ue)=>(oe?.[Ue]??0)+(V.values[Ue]??0),G=F1(l,$e,(Ue)=>Re(ve(Ue))),_e=Array.from({length:l},(Ue,dt)=>l-1-dt).map((Ue)=>`L${$e(Ue).toFixed(1)},${Re(oe?.[Ue]??0).toFixed(1)}`).join(""),Qe=V.pattern==="hatch"?`url(#${J}-${Zv(V.key)})`:V.color;return bt.jsxDEV("g",{children:[bt.jsxDEV("path",{d:`${G}${_e}Z`,fill:Qe,fillOpacity:V.pattern?1:0.2},void 0,!1,void 0,this),bt.jsxDEV("path",{className:"chart-line",d:G,stroke:V.color},void 0,!1,void 0,this)]},V.key,!0,void 0,this)}),xt.map((V)=>{let Re=V.axis==="right"?ke:me,oe=X.bases.get(V.key),ve=W.indexOf(V),G=ve>=0?ze/W.length:ze,_e=V.pattern==="hatch"?`url(#${J}-${Zv(V.key)})`:V.color;return bt.jsxDEV("g",{children:V.values.map((Qe,Ue)=>{if(!Qe)return null;let dt=ve>=0?0:oe?.[Ue]??0,et=Re(dt),ft=Re(dt+Qe),Oe=$e(Ue)-ze/2+(ve>=0?ve*G:0);return bt.jsxDEV("rect",{className:"chart-bar","data-hover":Y===Ue,x:Oe,y:Math.min(et,ft),width:Math.max(1,G-(ve>=0&&W.length>1?1:0)),height:Math.max(Qe>0?1:0,Math.abs(et-ft)),fill:_e},Ue,!1,void 0,this)})},V.key,!1,void 0,this)}),te.filter((V)=>(V.kind??p)==="line").map((V)=>{let Re=V.axis==="right"?ke:me,oe=(ve)=>{let G=V.values[ve];return G===null||G===void 0?null:Re(G)};return bt.jsxDEV("g",{children:[bt.jsxDEV("path",{className:"chart-line",d:F1(l,$e,oe),stroke:V.color,strokeDasharray:V.dashed?"4 3":void 0},void 0,!1,void 0,this),V.values.map((ve,G)=>{let _e=oe(G);if(_e===null||G>0&&oe(G-1)!==null||G<l-1&&oe(G+1)!==null)return null;return bt.jsxDEV("circle",{cx:$e(G),cy:_e,r:2.5,fill:V.color},G,!1,void 0,this)})]},V.key,!0,void 0,this)}),k?.map((V)=>{let Re=V.axis==="right"?ke(V.value):me(V.value);return bt.jsxDEV("g",{className:"chart-axis",children:[bt.jsxDEV("line",{x1:de,x2:de+Ce,y1:Re,y2:Re,stroke:"var(--line-4)",strokeDasharray:"3 3"},void 0,!1,void 0,this),V.label&&bt.jsxDEV("text",{x:de+Ce-4,y:Re-5,textAnchor:"end",children:V.label},void 0,!1,void 0,this)]},`${V.axis??"left"}:${V.value}`,!0,void 0,this)}),bt.jsxDEV("line",{className:"chart-baseline",x1:de,x2:de+Ce,y1:me(0),y2:me(0)},void 0,!1,void 0,this),bt.jsxDEV("rect",{x:de,y:Js,width:Ce,height:Be,fill:"transparent",onPointerMove:it,onPointerLeave:()=>ce(null),onClick:D&&Y!==null?()=>D(Y):void 0,style:{cursor:D?"pointer":"crosshair"}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X.empty&&bt.jsxDEV("div",{className:"chart-empty",children:M},void 0,!1,void 0,this),Y!==null&&!X.empty&&bt.jsxDEV("div",{className:"chart-tooltip",style:$e(Y)>j/2?{right:j-$e(Y)+Math.min(ne/2,24)+8,top:Js}:{left:$e(Y)+Math.min(ne/2,24)+8,top:Js},children:[bt.jsxDEV("div",{className:"chart-tooltip-title",children:(c??i)(Y)},void 0,!1,void 0,this),ct.map(({s:V,v:Re})=>bt.jsxDEV("div",{className:"chart-tooltip-row",children:[bt.jsxDEV("span",{className:"swatch",style:{background:V.color}},void 0,!1,void 0,this),bt.jsxDEV("span",{className:"chart-tooltip-label",children:V.label},void 0,!1,void 0,this),bt.jsxDEV("span",{className:"chart-tooltip-value",children:V.axis==="right"?(b??x)(Re):(L??x)(Re)},void 0,!1,void 0,this)]},V.key,!0,void 0,this)),ye&&ct.length>1&&bt.jsxDEV("div",{className:"chart-tooltip-row chart-tooltip-total",children:[bt.jsxDEV("span",{className:"chart-tooltip-label",children:"Total"},void 0,!1,void 0,this),bt.jsxDEV("span",{className:"chart-tooltip-value",children:(L??x)(Me)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),B&&bt.jsxDEV(jr.Fragment,{children:B(Y)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function _1(l){if(!(l>0))return{max:1,ticks:[0]};let i=l/SM,c=10**Math.floor(Math.log10(i)),f=[1,2,2.5,5,10].map((h)=>h*c).find((h)=>h>=i)??10*c,p=Math.ceil(l/f)*f,S=[];for(let h=0;h<=p+f/2;h+=f)S.push(Number(h.toPrecision(12)));return{max:p,ticks:S}}function H1(l){return l.reduce((i,c)=>Math.max(i,c.length*6.3),0)}function F1(l,i,c){let f="",p=!1;for(let S=0;S<l;S++){let h=c(S);if(h===null){p=!1;continue}f+=`${p?"L":"M"}${i(S).toFixed(1)},${h.toFixed(1)}`,p=!0}return f}function Zv(l){return l.replace(/[^a-zA-Z0-9_-]/g,"_")}var Gm=Z(gt(),1),mr=Z(ue(),1);function Ka({items:l,hidden:i,onToggle:c}){return mr.jsxDEV("div",{className:"legend",children:l.map((f)=>{let p=mr.jsxDEV(mr.Fragment,{children:[mr.jsxDEV("span",{className:"swatch",style:{background:f.color}},void 0,!1,void 0,this),mr.jsxDEV("span",{className:"truncate",children:f.label},void 0,!1,void 0,this),f.value&&mr.jsxDEV("span",{className:"legend-value",children:f.value},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return c?mr.jsxDEV("button",{type:"button",className:"legend-item","data-off":i?.has(f.key)??!1,onClick:()=>c(f.key),title:f.label,children:p},f.key,!1,void 0,this):mr.jsxDEV("span",{className:"legend-item",title:f.label,children:p},f.key,!1,void 0,this)})},void 0,!1,void 0,this)}function sn(){let[l,i]=Gm.useState(()=>new Set),c=Gm.useCallback((f)=>{i((p)=>{let S=new Set(p);if(!S.delete(f))S.add(f);return S})},[]);return[l,c]}var Wv=Z(ue(),1);function $l({segments:l,height:i=8}){let c=l.reduce((f,p)=>f+Math.max(0,p.value),0);return Wv.jsxDEV("div",{className:"share-bar",style:{height:i},role:"img",children:c>0&&l.filter((f)=>f.value>0).map((f)=>Wv.jsxDEV("div",{className:"share-bar-seg",style:{flexGrow:f.value/c,background:f.color},title:`${f.label}: ${(f.value/c*100).toFixed(1)}%`},f.key,!1,void 0,this))},void 0,!1,void 0,this)}var G1=Z(ue(),1);function Xr({buckets:l,bucketMs:i,onSelectBucket:c,...f}){return G1.jsxDEV(Tn,{...f,slots:l.length,tickLabel:(p)=>Am(l[p],i),tooltipTitle:(p)=>Rm(l[p],i),onSelect:c?(p)=>c(l[p]):void 0},void 0,!1,void 0,this)}var Fa=["#5ad8e6","#ed4abf","#9d7bff","#f5b54a","#4ade80","#5b8cff","#ff7a59","#2dd4bf","#c3e94f","#fb7185"],ao="#6c6c74";function ba(l,i){return`${l}::${i}`}function Vm(l){return Nd(l.map((i)=>({key:ba(i.model,i.provider),weight:i.totalRequests})))}function Nd(l){let i=[...l].sort((c,f)=>f.weight-c.weight||c.key.localeCompare(f.key));return new Map(i.map((c,f)=>[c.key,Fa[f%Fa.length]]))}var xa=Z(gt(),1);var LM={entries:new Map,limit:128},CM={entries:new Map,limit:4},wM={entries:new Map,limit:16},eu=new Map;function V1(l){if(l.startsWith('["trace",'))return CM;if(l.startsWith('["request",'))return wM;return LM}function Bd(l){return V1(l).entries.get(l)}function j1(l){return eu.get(l)}function kM(l,i){let{entries:c,limit:f}=V1(l);if(c.delete(l),c.set(l,i),c.size>f){let p=c.keys().next().value;if(p!==void 0)c.delete(p)}}function X1(l,i,c){let f=eu.get(l);if(f)return f.waiters++,f;let p=new AbortController,S=Bd(l)?.data,h={promise:c({signal:p.signal},S).then((x)=>(kM(l,{data:x,updatedAt:Date.now(),version:i}),x)).finally(()=>{if(eu.get(l)===h)eu.delete(l)}),controller:p,waiters:1};return eu.set(l,h),h}function Jv(l,i){if(i.waiters--,i.waiters>0)return;if(eu.get(l)===i)eu.delete(l);i.controller.abort()}var TM=1500;function Ft(l,i,c){let f=JSON.stringify(l),p=c?.enabled??!0,S=c?.pollMs,h=C1(p),[,x]=xa.useReducer((te)=>te+1,0),[b,L]=xa.useState(null),[g,C]=xa.useState(!1),w=xa.useRef(i);w.current=i;let A=xa.useRef(f);A.current=f;let k=xa.useRef(null),D=xa.useRef(0),M=xa.useRef(null),B=xa.useCallback((te)=>{D.current=Date.now();let X=M.current;if(X?.key===te&&j1(te)===X.request)return;let ae=Bd(te)?.data;C(!0);let H=X1(te,S1(),w.current);if(M.current={key:te,request:H},X)Jv(X.key,X.request);H.promise.then((de)=>{if(A.current!==te)return;if(de===ae){L((xe)=>xe===null?xe:null);return}xa.startTransition(()=>{L(null),x()})}).catch((de)=>{if(A.current!==te||H.controller.signal.aborted)return;L({key:te,error:de instanceof Error?de:Error(String(de))})}).finally(()=>{if(M.current?.request===H)M.current=null;if(A.current===te)C(!1)})},[]),P=xa.useCallback(()=>{let te=M.current;if(M.current=null,te)Jv(te.key,te.request)},[]);xa.useEffect(()=>P,[P]),xa.useEffect(()=>{if(!p||M.current&&M.current.key!==f)P();if(!p)return;let te=Bd(f);if(te&&te.version>=h)return;let X=te?D.current+TM-Date.now():0;if(X<=0){B(f);return}let ae=setTimeout(()=>B(f),X);return()=>clearTimeout(ae)},[f,p,h,B,P]),xa.useEffect(()=>{if(!p||!S)return;let te=setInterval(()=>{if(!document.hidden)B(A.current)},S);return()=>clearInterval(te)},[p,S,B]);let j=xa.useCallback(()=>B(A.current),[B]),Y=Bd(f);if(Y)k.current={key:f,data:Y.data,updatedAt:Y.updatedAt};let ce=k.current,J=b?.key===f?b.error:null;return{data:ce?.data??null,error:J,loading:!ce&&!J,stale:!!ce&&ce.key!==f,refreshing:g,updatedAt:ce?.updatedAt??null,refetch:j}}function Sa(l,i,c){let f=Y1(i),p=Array.from({length:i.length},()=>0);for(let S of l){let h=f.get(S.timestamp);if(h!==void 0)p[h]+=c(S)}return p}function hr(l,i){let c=Y1(i.buckets),f=new Map;for(let L of l){let g=c.get(L.timestamp);if(g===void 0)continue;let C=i.key(L),w=f.get(C);if(!w)w=Array.from({length:i.buckets.length},()=>0),f.set(C,w);w[g]+=i.value(L)}let p=[...f.entries()].map(([L,g])=>({key:L,values:g,total:g.reduce((C,w)=>C+w,0)})).filter((L)=>L.total!==0).sort((L,g)=>g.total-L.total||L.key.localeCompare(g.key)),S=i.limit??Number.POSITIVE_INFINITY,h=p.slice(0,S),x=p.slice(S),b=h.map((L,g)=>({key:L.key,label:i.label?i.label(L.key):L.key,color:i.colors?.get(L.key)??Fa[g%Fa.length],values:L.values}));if(x.length>0){let L=Array.from({length:i.buckets.length},()=>0);for(let g of x)for(let C=0;C<L.length;C++)L[C]+=g.values[C];b.push({key:"__other__",label:u("common.other-n",{count:x.length}),color:ao,values:L})}return b}function Y1(l){let i=new Map;for(let c=0;c<l.length;c++)i.set(l[c],c);return i}var IM=["main","subagent","advisor"];function Ql(l){return l.totalInputTokens+l.totalOutputTokens+l.totalCacheReadTokens+l.totalCacheWriteTokens}function K1(l){let i=new Map;for(let h of l)i.set(h.agentType,h);let c=IM.map((h)=>i.get(h)).filter((h)=>h!==void 0),f=c.reduce((h,x)=>h+Ql(x),0),p=c.reduce((h,x)=>h+x.totalCost,0),S=c.map((h)=>{let x=Ql(h);return{agentType:h.agentType,tokens:x,requests:h.totalRequests,cost:h.totalCost,share:f>0?x/f:0}});return{totalTokens:f,totalCost:p,segments:S}}function Z1(l){let i={totalCost:0,requests:0,unpricedRequests:0,activeDays:new Set(l.map((p)=>p.timestamp)).size,avgDailyCost:0,costInput:0,costOutput:0,costCacheRead:0,costCacheWrite:0,models:[],topModel:null},c=new Map;for(let p of l){let S=ba(p.model,p.provider),h=c.get(S);if(!h)h={key:S,model:p.model,provider:p.provider,cost:0,requests:0,unpricedRequests:0,costInput:0,costOutput:0,costCacheRead:0,costCacheWrite:0,share:0},c.set(S,h);$1(h,p),$1(i,p),h.cost+=p.cost,i.totalCost+=p.cost}i.avgDailyCost=i.activeDays>0?i.totalCost/i.activeDays:0,i.models=[...c.values()].sort((p,S)=>S.cost-p.cost||S.requests-p.requests||p.key.localeCompare(S.key));for(let p of i.models)p.share=i.totalCost>0?p.cost/i.totalCost:0;let f=i.models[0];return i.topModel=f!==void 0&&f.cost>0?f:null,i}function $1(l,i){l.costInput+=i.costInput,l.costOutput+=i.costOutput,l.costCacheRead+=i.costCacheRead,l.costCacheWrite+=i.costCacheWrite,l.requests+=i.requests,l.unpricedRequests+=i.unpricedRequests}function W1(l){let i=new Map;for(let c of l){let f=ba(c.model,c.provider),p=i.get(f);if(!p)p=[],i.set(f,p);p.push({timestamp:c.timestamp,avgTtftSeconds:c.avgTtft!==null?c.avgTtft/1000:null,avgTokensPerSecond:c.avgTokensPerSecond,requests:c.requests})}for(let c of i.values())c.sort((f,p)=>f.timestamp-p.timestamp);return i}var RM=/^\/?-?(?:private-)?(?:tmp|var-folders)(?:[-/]|$)/;function J1(l){let i=0,c=0,f=0,p=0,S=0,h=0,x=0,b=0,L=0;for(let w of l){if(i+=w.totalRequests,c+=w.failedRequests,f+=w.totalCost,p+=w.unpricedRequests,S+=w.totalInputTokens+w.totalCacheReadTokens+w.totalCacheWriteTokens+w.totalOutputTokens,h+=w.totalInputTokens,x+=w.totalCacheReadTokens,w.totalRequests>b)b=w.totalRequests;if(w.totalCost>L)L=w.totalCost}let g=0;return{rows:l.map((w)=>{let A=RM.test(w.folder);if(A)g++;return{...w,conversationTokens:w.totalInputTokens+w.totalCacheReadTokens+w.totalCacheWriteTokens+w.totalOutputTokens,requestShare:i>0?w.totalRequests/i:0,costShare:f>0?w.totalCost/f:0,temporary:A}}),totalRequests:i,failedRequests:c,totalCost:f,unpricedRequests:p,conversationTokens:S,cacheRate:h+x>0?x/(h+x):0,maxRequests:b,maxCost:L,temporaryCount:g}}function eT(l){let i=0,c=0,f=0;for(let p of l)i+=p.calls,c+=p.totalTokensShare,f+=p.costShare;return l.map((p)=>({...p,errorRate:p.calls>0?p.errors/p.calls:0,callFraction:i>0?p.calls/i:0,tokenFraction:c>0?p.totalTokensShare/c:0,costFraction:f>0?p.costShare/f:0,avgResultChars:p.calls>0?p.resultChars/p.calls:0}))}function Yr(l){if(l.stopReason==="aborted")return"aborted";if(l.stopReason==="error"||l.errorMessage)return"failed";return"ok"}function eb(l,i){if(l.length===0)return null;return l[Math.min(l.length-1,Math.max(0,Math.ceil(i*l.length)-1))]}function tT(l){let i=0,c=0,f=0,p=0,S=0,h=null,x=null,b=[],L=[];for(let g of l){let C=Yr(g);if(C==="failed")i++;else if(C==="aborted")c++;if(f+=g.usage.totalTokens,p+=g.usage.cost.total,Vv(g))S++;if(g.duration!==null)b.push(g.duration);if(g.ttft!==null)L.push(g.ttft);if(h===null||g.timestamp<h)h=g.timestamp;if(x===null||g.timestamp>x)x=g.timestamp}return b.sort((g,C)=>g-C),L.sort((g,C)=>g-C),{requests:l.length,failed:i,aborted:c,tokens:f,cost:p,unpriced:S,medianDuration:eb(b,0.5),p95Duration:eb(b,0.95),medianTtft:eb(L,0.5),oldest:h,newest:x}}var Q1=180,AM=/\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/gi,MM=/\b(?:req|msg|call|toolu|chatcmpl|resp|run|gen)[-_][A-Za-z0-9_-]{6,}/g,DM=/\b[0-9a-f]{12,}\b/gi,EM=/(?<![\w.-])\d+(?:\.\d+)?/g,OM=/^[1-5]\d\d$/;function tb(l){if(!l?.trim())return"Unknown error";let i=l.replace(/\s+/g," ").trim().replace(AM,"<id>").replace(MM,"<id>").replace(DM,"<hex>").replace(EM,(c)=>OM.test(c)?c:"N");return i.length>Q1?`${i.slice(0,Q1-1)}…`:i}function aT(l){let i=new Map;for(let c of l){let f=tb(c.errorMessage),p=i.get(f);if(!p)p={signature:f,count:0,firstSeen:c.timestamp,lastSeen:c.timestamp,latest:c,models:[],byModel:new Map},i.set(f,p);if(p.count++,c.timestamp<p.firstSeen)p.firstSeen=c.timestamp;if(c.timestamp>p.lastSeen)p.lastSeen=c.timestamp,p.latest=c;let S=ba(c.model,c.provider),h=p.byModel.get(S);if(h)h.count++;else p.byModel.set(S,{model:c.model,provider:c.provider,count:1})}return[...i.values()].map(({byModel:c,...f})=>({...f,models:[...c.values()].sort((p,S)=>S.count-p.count||p.model.localeCompare(S.model))})).sort((c,f)=>f.count-c.count||f.lastSeen-c.lastSeen)}var De=Z(ue(),1),qM=[{value:"model",label:u("costs.by-model")},{value:"component",label:u("costs.by-component")}],NM=6,BM=86400000,Ud=[{key:"costInput",label:u("common.input"),color:"#5b8cff"},{key:"costOutput",label:u("common.output"),color:"var(--chart-secondary)"},{key:"costCacheRead",label:u("common.cache-read"),color:"var(--chart-primary)"},{key:"costCacheWrite",label:u("common.cache-write"),color:"#f5b54a"}],zM=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",timeZone:"UTC"}),UM=new Intl.DateTimeFormat(void 0,{weekday:"short",month:"short",day:"numeric",year:"numeric",timeZone:"UTC"});function oT({active:l,range:i}){let c=Ft(["costs",i],({signal:w})=>a1(i,w),{enabled:l}),f=ia(i),[p,S]=zd.useState("model"),[h,x]=sn(),b=zd.useMemo(()=>c.data?PM(c.data,i):null,[c.data,i]),L=zd.useMemo(()=>b?FM(b):[],[b]),g=(w)=>w.costSeries.length===0,C=De.jsxDEV(wt,{title:u("costs.no-usage-in-range"),hint:u("costs.empty-hint")},void 0,!1,void 0,this);return De.jsxDEV("div",{className:"page",children:[De.jsxDEV(ra,{title:u("costs.title"),description:u("costs.description",{window:u(f.windowKey)})},void 0,!1,void 0,this),De.jsxDEV(Ge,{query:c,skeleton:De.jsxDEV(qa,{height:112,style:{borderRadius:12}},void 0,!1,void 0,this),isEmpty:g,empty:C,children:()=>b&&De.jsxDEV(_M,{view:b,stale:c.stale},void 0,!1,void 0,this)},void 0,!1,void 0,this),De.jsxDEV("div",{className:"grid grid-main-side",children:[De.jsxDEV(Ye,{index:1,title:u("costs.daily-estimate"),description:p==="model"?u("costs.daily-by-model"):u("costs.daily-by-component"),actions:De.jsxDEV(_a,{size:"sm",options:qM,value:p,onChange:S,"aria-label":u("costs.split-by")},void 0,!1,void 0,this),stale:c.stale,children:De.jsxDEV(Ge,{query:c,skeleton:De.jsxDEV(zt,{height:280},void 0,!1,void 0,this),isEmpty:g,empty:C,children:()=>{if(!b)return null;let w=p==="model"?b.modelSeries:b.componentSeries;return De.jsxDEV("div",{className:"stack",style:{gap:12},children:[De.jsxDEV(Tn,{slots:b.buckets.length,tickLabel:(A)=>zM.format(b.buckets[A]),tooltipTitle:(A)=>UM.format(b.buckets[A]),series:w,hidden:h,height:280,format:(A)=>da(A,Number.isInteger(A)?0:2),formatTooltip:(A)=>da(A),emptyLabel:u("costs.no-priced-usage"),tooltipExtra:(A)=>b.unpricedPerDay[A]>0?De.jsxDEV("div",{className:"chart-tooltip-row chart-tooltip-total",children:[De.jsxDEV("span",{className:"chart-tooltip-label",children:u("costs.unpriced-requests")},void 0,!1,void 0,this),De.jsxDEV("span",{className:"chart-tooltip-value",children:z(b.unpricedPerDay[A])},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null},void 0,!1,void 0,this),De.jsxDEV(Ka,{items:w.map((A)=>({key:A.key,label:A.label,color:A.color,value:da(GM(A.values))})),hidden:h,onToggle:x},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}},void 0,!1,void 0,this)},void 0,!1,void 0,this),De.jsxDEV(Ye,{index:2,title:u("costs.where-it-went"),description:u("costs.estimate-by-component"),stale:c.stale,children:De.jsxDEV(Ge,{query:c,skeleton:De.jsxDEV(zt,{height:280},void 0,!1,void 0,this),isEmpty:g,empty:C,children:()=>b&&De.jsxDEV(HM,{summary:b.summary},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),De.jsxDEV(Ye,{index:3,title:u("costs.by-model"),description:u("costs.by-model-description"),stale:c.stale,flush:!0,children:De.jsxDEV(Ge,{query:c,skeleton:De.jsxDEV(ca,{rows:8},void 0,!1,void 0,this),isEmpty:g,empty:C,children:()=>b&&De.jsxDEV(Xt,{rows:b.summary.models,rowKey:(w)=>w.key,columns:L,initialSort:{key:"cost",dir:"desc"},limit:20},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function PM(l,i){let c=l.costSeries,f=Z1(c),p=Vm(f.models.map((L)=>({model:L.model,provider:L.provider,totalRequests:L.requests}))),S=new Map(f.models.map((L)=>[L.key,L])),h=_o(i,c.map((L)=>L.timestamp),BM),x=hr(c,{buckets:h,key:(L)=>ba(L.model,L.provider),label:(L)=>S.get(L)?.model??L,value:(L)=>L.cost,limit:NM,colors:p}).map((L)=>({...L,values:L.values.map((g)=>g||null)})),b=new Set;for(let L of x){if(L.key==="__other__")continue;if(b.has(L.color))L.color=Fa.find((g)=>!b.has(g))??L.color;b.add(L.color)}return{summary:f,swatches:new Map(x.filter((L)=>L.key!=="__other__").map((L)=>[L.key,L.color])),buckets:h,dailyTotals:Sa(c,h,(L)=>L.cost),unpricedPerDay:Sa(c,h,(L)=>L.unpricedRequests),modelSeries:x,componentSeries:Ud.map((L)=>({key:L.key,label:L.label,color:L.color,values:Sa(c,h,(g)=>g[L.key]).map((g)=>g||null)})),maxModelCost:f.models[0]?.cost??0}}function _M({view:l,stale:i}){let{summary:c}=l,f=c.requests-c.unpricedRequests,p=c.topModel;return De.jsxDEV("div",{"data-stale":i,children:De.jsxDEV(la,{min:180,children:[De.jsxDEV(ie,{label:u("costs.api-equivalent-estimate"),title:u("costs.api-estimate-title"),value:Ht(c.totalCost,c.unpricedRequests),hint:u("costs.requests-n",{count:z(c.requests)}),spark:l.dailyTotals,sparkColor:"var(--chart-secondary)"},void 0,!1,void 0,this),De.jsxDEV(ie,{label:u("costs.average-per-day"),title:u("costs.average-per-day-title"),value:Ht(c.avgDailyCost,c.unpricedRequests),hint:u(c.activeDays===1?"costs.active-days-one":"costs.active-days-n",{count:z(c.activeDays)})},void 0,!1,void 0,this),De.jsxDEV(ie,{label:u("costs.top-model"),title:p?`${p.model} (${p.provider})`:void 0,value:p?p.model:"–",hint:p?u("costs.top-model-hint",{cost:da(p.cost),share:Fe(p.share)}):u("costs.nothing-priced-yet")},void 0,!1,void 0,this),De.jsxDEV(ie,{label:u("costs.per-priced-request"),title:u("costs.per-priced-request-title"),value:f>0?nT(c.totalCost/f):"–",hint:u("costs.priced-n",{count:z(f)})},void 0,!1,void 0,this),De.jsxDEV(ie,{label:u("costs.unpriced-requests"),title:u("costs.unpriced-title"),value:z(c.unpricedRequests),hint:c.unpricedRequests>0?u("costs.unpriced-hint"):u("costs.all-priced")},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function HM({summary:l}){return De.jsxDEV("div",{className:"stack",style:{gap:14},children:[De.jsxDEV($l,{height:10,segments:Ud.map((i)=>({key:i.key,label:i.label,value:l[i.key],color:i.color}))},void 0,!1,void 0,this),De.jsxDEV("div",{className:"costs-components",children:[Ud.map((i)=>De.jsxDEV("div",{className:"costs-component-row",children:[De.jsxDEV("span",{className:"row",children:[De.jsxDEV(Cn,{color:i.color},void 0,!1,void 0,this),i.label]},void 0,!0,void 0,this),De.jsxDEV("span",{className:"num",children:da(l[i.key])},void 0,!1,void 0,this),De.jsxDEV("span",{className:"num dim costs-component-share",children:l.totalCost>0?Fe(l[i.key]/l.totalCost):"–"},void 0,!1,void 0,this)]},i.key,!0,void 0,this)),De.jsxDEV("div",{className:"costs-component-row costs-component-total",children:[De.jsxDEV("span",{children:u("common.total")},void 0,!1,void 0,this),De.jsxDEV("span",{className:"num",children:Ht(l.totalCost,l.unpricedRequests)},void 0,!1,void 0,this),De.jsxDEV("span",{className:"costs-component-share"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),l.unpricedRequests>0&&De.jsxDEV("p",{className:"micro dim",children:u(l.unpricedRequests===1?"costs.unpriced-note-one":"costs.unpriced-note-n",{count:z(l.unpricedRequests)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function FM(l){let i=Ud.map((c)=>({key:c.key,header:c.label,align:"right",sort:(f)=>f[c.key],render:(f)=>De.jsxDEV("span",{className:"num",children:da(f[c.key])},void 0,!1,void 0,this)}));return[{key:"model",header:u("common.model"),sort:(c)=>c.model,render:(c)=>De.jsxDEV(Ha,{lead:De.jsxDEV(Cn,{color:l.swatches.get(c.key)??ao},void 0,!1,void 0,this),primary:De.jsxDEV("span",{className:"mono",children:c.model},void 0,!1,void 0,this),secondary:c.provider},void 0,!1,void 0,this)},{key:"requests",header:u("common.requests"),align:"right",sort:(c)=>c.requests,render:(c)=>De.jsxDEV("span",{className:"num",children:z(c.requests)},void 0,!1,void 0,this)},{key:"cost",header:u("costs.estimate"),title:u("costs.estimate-title"),align:"right",sort:(c)=>c.cost,render:(c)=>De.jsxDEV(pa,{value:c.cost,max:l.maxModelCost,display:Ht(c.cost,c.unpricedRequests),color:l.swatches.get(c.key)??ao},void 0,!1,void 0,this)},{key:"share",header:u("common.share"),align:"right",sort:(c)=>c.share,render:(c)=>De.jsxDEV("span",{className:"num muted",children:c.cost>0?Fe(c.share):"–"},void 0,!1,void 0,this)},{key:"split",header:u("costs.split"),title:"Input · output · cache read · cache write",width:150,render:(c)=>c.cost>0?De.jsxDEV($l,{segments:Ud.map((f)=>({key:f.key,label:f.label,value:c[f.key],color:f.color}))},void 0,!1,void 0,this):De.jsxDEV("span",{className:"dim",children:"–"},void 0,!1,void 0,this)},...i,{key:"perRequest",header:u("costs.per-request"),title:"Estimate ÷ priced requests",align:"right",sort:(c)=>c.requests>c.unpricedRequests?c.cost/(c.requests-c.unpricedRequests):-1,render:(c)=>De.jsxDEV("span",{className:"num",children:c.requests>c.unpricedRequests?nT(c.cost/(c.requests-c.unpricedRequests)):"–"},void 0,!1,void 0,this)},{key:"unpriced",header:u("costs.unpriced"),title:"Requests with no public-equivalent price",align:"right",sort:(c)=>c.unpricedRequests,render:(c)=>c.unpricedRequests>0?De.jsxDEV("span",{className:"num tone-warn",children:z(c.unpricedRequests)},void 0,!1,void 0,this):De.jsxDEV("span",{className:"num dim",children:"–"},void 0,!1,void 0,this)}]}function nT(l){return l>0&&l<0.0001?"<$0.0001":da(l)}function GM(l){let i=0;for(let c of l)i+=c??0;return i}var $r=Z(gt(),1);var be=Z(ue(),1),ab=[50,200,1000];function rT({active:l,range:i,onRequestClick:c}){let[f,p]=$r.useState(0),S=ab[f],h=Ft(["errors",i,S],({signal:ae})=>o1(i,S,ae),{enabled:l}),[x,b]=$r.useState(null),[L,g]=$r.useState(null),[C,w]=$r.useState(""),A=ia(i),k=$r.useMemo(()=>{let ae=(h.data??[]).map((Be)=>({row:Be,signature:tb(Be.errorMessage)})),H=aT(h.data??[]),de=new Map;for(let{row:Be}of ae){let ne=ba(Be.model,Be.provider),me=de.get(ne);if(me)me.count++;else de.set(ne,{model:Be.model,provider:Be.provider,count:1})}let xe=[...de.entries()].map(([Be,ne])=>({key:Be,...ne})).sort((Be,ne)=>ne.count-Be.count||Be.model.localeCompare(ne.model)),Ce=ae.reduce((Be,{row:ne})=>!Be||ne.timestamp>Be.timestamp?ne:Be,null);return{rows:ae,groups:H,models:xe,newest:Ce}},[h.data]),D=k.groups.some((ae)=>ae.signature===x)?x:null,M=k.models.some((ae)=>ae.key===L)?L:null,B=$r.useMemo(()=>{let ae=C.trim().toLowerCase();return k.rows.filter((H)=>(D===null||H.signature===D)&&(M===null||ba(H.row.model,H.row.provider)===M)&&(ae===""||H.row.model.toLowerCase().includes(ae)||H.row.provider.toLowerCase().includes(ae)||H.row.folder.toLowerCase().includes(ae)||(H.row.errorMessage??"").toLowerCase().includes(ae))).map((H)=>H.row)},[k.rows,D,M,C]),P=h.data?.length??0,j=!h.stale&&P<S,Y=f+1<ab.length?ab[f+1]:null,ce=h.data!==null&&!j?be.jsxDEV(be.Fragment,{children:[be.jsxDEV("span",{children:u("errors.footer",{count:z(P),window:u(A.windowKey)})},void 0,!1,void 0,this),Y!==null&&be.jsxDEV("button",{type:"button",className:"btn","data-size":"sm",disabled:h.refreshing,onClick:()=>p(f+1),children:h.refreshing&&h.stale?u("errors.loading"):u("errors.load-latest",{count:z(Y)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this):void 0,J=k.groups[0]?.count??0,te=$r.useMemo(()=>VM(J),[J]),X=k.models.find((ae)=>ae.key===M);return be.jsxDEV("div",{className:"page",children:[be.jsxDEV(ra,{title:u("errors.title"),description:u("errors.description",{window:u(A.windowKey)})},void 0,!1,void 0,this),be.jsxDEV(Ge,{query:h,skeleton:be.jsxDEV(qa,{height:96,style:{borderRadius:12}},void 0,!1,void 0,this),children:()=>be.jsxDEV("div",{"data-stale":h.stale,children:be.jsxDEV(la,{min:170,children:[be.jsxDEV(ie,{label:u("errors.failures"),value:z(P),hint:j?u("errors.hint-in-window",{window:u(A.windowKey)}):u("errors.hint-latest-loaded",{count:z(P)})},void 0,!1,void 0,this),be.jsxDEV(ie,{label:u("errors.signatures"),title:u("errors.signatures-hint"),value:z(k.groups.length),hint:k.groups[0]?u("errors.signatures-top",{count:z(k.groups[0].count)}):void 0},void 0,!1,void 0,this),be.jsxDEV(ie,{label:u("errors.affected-models"),value:z(k.models.length),hint:k.models[0]?.model},void 0,!1,void 0,this),be.jsxDEV(ie,{label:u("errors.last-failure"),value:k.newest?fa(k.newest.timestamp):"–",hint:k.newest?ln(k.newest.timestamp):u("errors.none-in-window",{window:u(A.windowKey)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),be.jsxDEV("div",{className:"grid grid-main-side",children:[be.jsxDEV(Ye,{index:1,title:u("errors.error-signatures"),description:u("errors.signatures-card-description"),flush:!0,stale:h.stale,children:be.jsxDEV(Ge,{query:h,skeleton:be.jsxDEV(ca,{rows:8},void 0,!1,void 0,this),isEmpty:(ae)=>ae.length===0,empty:be.jsxDEV(wt,{title:u("errors.empty-no-failures",{window:u(A.windowKey)}),hint:u("errors.empty-all-succeeded")},void 0,!1,void 0,this),children:()=>be.jsxDEV(Xt,{rows:k.groups,rowKey:(ae)=>ae.signature,columns:te,onRowClick:(ae)=>b(D===ae.signature?null:ae.signature),selectedKey:D,expanded:(ae)=>ae.signature===D?be.jsxDEV(jM,{group:ae,onRequestClick:c},void 0,!1,void 0,this):null,limit:12},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),be.jsxDEV(Ye,{index:2,title:u("errors.by-model"),description:u("errors.by-model-description"),stale:h.stale,children:be.jsxDEV(Ge,{query:h,skeleton:be.jsxDEV(qa,{height:180},void 0,!1,void 0,this),isEmpty:(ae)=>ae.length===0,empty:be.jsxDEV(wt,{title:u("errors.empty-no-affected-models")},void 0,!1,void 0,this),children:()=>be.jsxDEV(qd,{items:k.models.slice(0,12).map((ae)=>({key:ae.key,label:be.jsxDEV("span",{className:"row",style:{gap:6,minWidth:0},children:[be.jsxDEV("span",{className:"mono truncate",children:ae.model},void 0,!1,void 0,this),be.jsxDEV("span",{className:"dim truncate",children:ae.provider},void 0,!1,void 0,this)]},void 0,!0,void 0,this),value:ae.count,color:ae.key===M?"var(--bad)":"color-mix(in srgb, var(--bad) 45%, transparent)"})),onSelect:(ae)=>g(M===ae?null:ae)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),be.jsxDEV(Ye,{index:3,title:u("errors.failures"),description:h.data===null?u("errors.loading-failures"):u("errors.filtered-of-total",{shown:z(B.length),total:z(P)}),actions:be.jsxDEV(be.Fragment,{children:[D!==null&&be.jsxDEV("button",{type:"button",className:"btn errors-filter","data-size":"sm",onClick:()=>b(null),title:D,children:[be.jsxDEV("span",{className:"mono truncate",children:D},void 0,!1,void 0,this),be.jsxDEV(nn,{size:12},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X&&be.jsxDEV("button",{type:"button",className:"btn errors-filter","data-size":"sm",onClick:()=>g(null),children:[be.jsxDEV("span",{className:"mono truncate",children:X.model},void 0,!1,void 0,this),be.jsxDEV(nn,{size:12},void 0,!1,void 0,this)]},void 0,!0,void 0,this),be.jsxDEV(cr,{value:C,onChange:w,placeholder:u("errors.search-placeholder")},void 0,!1,void 0,this)]},void 0,!0,void 0,this),flush:!0,stale:h.stale,footer:ce,children:be.jsxDEV(Ge,{query:h,skeleton:be.jsxDEV(ca,{rows:10},void 0,!1,void 0,this),isEmpty:(ae)=>ae.length===0,empty:be.jsxDEV(wt,{title:u("errors.empty-no-failures",{window:u(A.windowKey)})},void 0,!1,void 0,this),children:()=>be.jsxDEV(Xt,{rows:B,rowKey:(ae)=>ae.id??`${ae.sessionFile}:${ae.entryId}`,onRowClick:(ae)=>ae.id!==void 0&&c(ae.id),columns:XM,initialSort:{key:"time",dir:"desc"},limit:50,dense:!0,empty:be.jsxDEV(wt,{title:u("errors.no-match"),hint:u("errors.no-match-hint")},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function VM(l){return[{key:"signature",header:u("errors.signature"),wrap:!0,sort:(i)=>i.signature,render:(i)=>be.jsxDEV("span",{className:"errors-signature",title:i.latest.errorMessage??void 0,children:i.signature},void 0,!1,void 0,this)},{key:"models",header:u("common.models"),sort:(i)=>i.models.length,render:(i)=>be.jsxDEV(Ha,{primary:be.jsxDEV("span",{className:"mono",children:i.models[0]?.model},void 0,!1,void 0,this),secondary:i.models.length>1?u("errors.more-models",{count:z(i.models.length-1)}):i.models[0]?.provider},void 0,!1,void 0,this)},{key:"last",header:u("errors.last-seen"),sort:(i)=>i.lastSeen,render:(i)=>be.jsxDEV("span",{className:"muted",title:ln(i.lastSeen),children:fa(i.lastSeen)},void 0,!1,void 0,this)},{key:"count",header:u("errors.failures"),align:"right",width:120,sort:(i)=>i.count,render:(i)=>be.jsxDEV(pa,{value:i.count,max:l,display:z(i.count),color:"var(--bad)"},void 0,!1,void 0,this)}]}function jM({group:l,onRequestClick:i}){let c=l.latest.id;return be.jsxDEV("div",{className:"errors-detail",children:[be.jsxDEV("pre",{className:"code-block errors-detail-message",children:l.latest.errorMessage??u("errors.unknown-error")},void 0,!1,void 0,this),be.jsxDEV("div",{className:"errors-detail-meta",children:[be.jsxDEV("span",{className:"muted",children:u("errors.group-meta",{count:z(l.count),first:ln(l.firstSeen),last:ln(l.lastSeen)})},void 0,!1,void 0,this),c!==void 0&&be.jsxDEV("button",{type:"button",className:"btn","data-size":"sm",onClick:()=>i(c),children:[u("errors.open-latest")," ",be.jsxDEV(fd,{size:13},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),be.jsxDEV("div",{className:"errors-detail-models",children:l.models.map((f)=>be.jsxDEV("span",{className:"badge","data-mono":"true",children:[f.model," ",be.jsxDEV("span",{className:"dim",children:f.provider},void 0,!1,void 0,this)," ",be.jsxDEV("span",{className:"num",children:Ae(f.count)},void 0,!1,void 0,this)]},ba(f.model,f.provider),!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var XM=[{key:"time",header:u("errors.when"),width:120,sort:(l)=>l.timestamp,render:(l)=>be.jsxDEV("span",{className:"muted",title:ln(l.timestamp),children:fa(l.timestamp)},void 0,!1,void 0,this)},{key:"model",header:u("common.model"),sort:(l)=>l.model,render:(l)=>be.jsxDEV(Ha,{primary:be.jsxDEV("span",{className:"mono",children:l.model},void 0,!1,void 0,this),secondary:l.provider},void 0,!1,void 0,this)},{key:"error",header:u("common.error"),sort:(l)=>l.errorMessage??"",render:(l)=>be.jsxDEV("span",{className:"errors-message",title:l.errorMessage??void 0,children:l.errorMessage??u("errors.unknown-error")},void 0,!1,void 0,this)},{key:"project",header:u("common.project"),sort:(l)=>l.folder,render:(l)=>be.jsxDEV("span",{className:"mono muted",title:l.folder,children:fr(l.folder)},void 0,!1,void 0,this)},{key:"tokens",header:u("common.tokens"),align:"right",sort:(l)=>l.usage.totalTokens,render:(l)=>be.jsxDEV("span",{className:"num",children:z(l.usage.totalTokens)},void 0,!1,void 0,this)},{key:"cost",header:u("common.cost"),title:u("errors.cost-hint"),align:"right",sort:(l)=>l.usage.cost.total,render:(l)=>be.jsxDEV("span",{className:"num",children:Yl(l,4)},void 0,!1,void 0,this)}];var Ut=Z(gt(),1);var Q=Z(ue(),1),YM=1000,jm=50,nb=0.5,Pd="*";function sT({active:l,range:i}){let[c,f]=Ut.useState(!1),p=Ft(["frustration",i],({signal:L})=>l1(i,L),{enabled:l,pollMs:c?YM:void 0}),S=ia(i),h=p.data?.job.state;Ut.useEffect(()=>{if(h!==void 0)f(h==="running")},[h]);let{refetch:x}=p,b=Ut.useCallback(()=>{f(!0),x()},[x]);return Q.jsxDEV("div",{className:"page",children:[Q.jsxDEV(ra,{title:u("frustration.title"),description:u("frustration.description",{window:u(S.windowKey)})},void 0,!1,void 0,this),Q.jsxDEV(Ge,{query:p,skeleton:Q.jsxDEV(zt,{height:96},void 0,!1,void 0,this),children:(L)=>Q.jsxDEV("div",{"data-stale":p.stale,children:Q.jsxDEV($M,{overall:L.overall},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),Q.jsxDEV(Ge,{query:p,skeleton:Q.jsxDEV(zt,{height:120},void 0,!1,void 0,this),children:(L)=>Q.jsxDEV(QM,{active:l,range:i,judgeAvailable:L.judgeAvailable,job:L.job,onRunStarted:b,onRunChanged:x},void 0,!1,void 0,this)},void 0,!1,void 0,this),Q.jsxDEV(Ge,{query:p,skeleton:Q.jsxDEV(Ye,{index:2,title:u("frustration.by-model"),children:[Q.jsxDEV(zt,{height:340},void 0,!1,void 0,this),Q.jsxDEV(ca,{rows:6},void 0,!1,void 0,this)]},void 0,!0,void 0,this),children:(L)=>Q.jsxDEV(rD,{models:L.byModel,stale:p.stale},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function In(l,i){return i>0?Fe(l/i):"–"}function ob(l){return l instanceof Error?l.message:String(l)}function uT(l){let i=Math.max(0,Math.floor(l/1000)),c=Math.floor(i/60),f=i%60;return c>0?`${c}m ${String(f).padStart(2,"0")}s`:`${f}s`}function $M({overall:l}){let i=l.messages-l.judged,c=l.unscored>0?u("frustration.coverage-unscored",{count:z(l.unscored)}):"";return Q.jsxDEV(Q.Fragment,{children:[Q.jsxDEV(la,{min:170,children:[Q.jsxDEV(ie,{label:u("frustration.user-messages"),title:u("frustration.user-messages-title"),value:z(l.messages)},void 0,!1,void 0,this),Q.jsxDEV(ie,{label:u("frustration.judge-coverage"),title:u("frustration.judge-coverage-title"),value:In(l.judged,l.messages),hint:`${u("frustration.coverage-hint",{judged:z(l.judged),regex:z(i)})}${c}`},void 0,!1,void 0,this),Q.jsxDEV(ie,{label:u("frustration.annoyed"),title:u("frustration.annoyed-title"),value:In(l.annoyed,l.messages),hint:u("frustration.messages-n",{count:z(l.annoyed)})},void 0,!1,void 0,this),Q.jsxDEV(ie,{label:u("frustration.at-assistant"),title:u("frustration.at-assistant-title"),value:In(l.atAssistant,l.messages),hint:u("frustration.messages-n",{count:z(l.atAssistant)})},void 0,!1,void 0,this),Q.jsxDEV(ie,{label:u("frustration.angry"),title:u("frustration.angry-title"),value:In(l.angry,l.messages),hint:u("frustration.messages-n",{count:z(l.angry)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this),l.unscored>0&&Q.jsxDEV("p",{className:"micro dim",children:u("frustration.unscored-line",{count:z(l.unscored)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var lT="Judging needs the zeta host process: open the dashboard with zetacode stats and configure a judge model. Until then messages are classified by regex signals.";function QM({active:l,range:i,judgeAvailable:c,job:f,onRunStarted:p,onRunChanged:S}){let[h,x]=Ut.useState(!1),[b,L]=Ut.useState({status:"loading"}),[g,C]=Ut.useState(!1),[w,A]=Ut.useState(null),[k,D]=Ut.useState(!1),[M,B]=Ut.useState(null),P=Ut.useRef(null),j=f.state==="running",Y=Ut.useCallback(()=>{P.current?.abort(),P.current=null,x(!1)},[]);Ut.useEffect(()=>{if(!l)Y()},[l,Y]),Ut.useEffect(()=>()=>P.current?.abort(),[]);let ce=()=>{P.current?.abort();let H=new AbortController;P.current=H;let de=i;L({status:"loading"}),A(null),B(null),x(!0),s1(de,H.signal).then((xe)=>{if(!H.signal.aborted)L({status:"ready",estimate:xe,range:de})},(xe)=>{if(!H.signal.aborted)L({status:"error",message:ob(xe)})})},J=async()=>{if(b.status!=="ready")return;C(!0),A(null);try{await u1(b.range),Y(),p()}catch(H){A(ob(H))}finally{C(!1)}},te=async()=>{D(!0),B(null);try{await i1(),S()}catch(H){B(ob(H))}finally{D(!1)}},X=b.status==="ready"?b.estimate:null,ae=b.status==="loading"?{label:"Proceed",onClick:J,disabled:!0}:X?.available?{label:g?"Starting…":"Proceed",onClick:J,disabled:g||X.messages===0}:void 0;return Q.jsxDEV(Ye,{index:1,title:Q.jsxDEV(Q.Fragment,{children:[u("frustration.judge-panel")," ",Q.jsxDEV(KM,{job:f,judgeAvailable:c},void 0,!1,void 0,this)]},void 0,!0,void 0,this),description:u("frustration.judge-description"),actions:Q.jsxDEV("button",{type:"button",className:"btn","data-variant":"accent","data-size":"sm",onClick:ce,disabled:!c||j,title:!c?lT:j?u("frustration.judge-running"):u("frustration.quote-title"),children:[Q.jsxDEV(lr,{size:13},void 0,!1,void 0,this)," ",u("frustration.classify")]},void 0,!0,void 0,this),children:[Q.jsxDEV("div",{className:"stack frustration-judge",children:[j?Q.jsxDEV(WM,{job:f,cancelling:k,onCancel:te},void 0,!1,void 0,this):Q.jsxDEV(JM,{job:f},void 0,!1,void 0,this),!c&&Q.jsxDEV("p",{className:"micro dim",children:lT},void 0,!1,void 0,this),M&&Q.jsxDEV("p",{className:"micro tone-bad",role:"alert",children:M},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Q.jsxDEV(T1,{open:h,title:u("frustration.classify"),onClose:Y,primaryAction:ae,children:[Q.jsxDEV(ZM,{estimate:b},void 0,!1,void 0,this),w&&Q.jsxDEV("p",{className:"micro tone-bad",role:"alert",children:w},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function KM({job:l,judgeAvailable:i}){switch(l.state){case"running":return Q.jsxDEV(Bt,{tone:"ok",children:[Q.jsxDEV(ur,{tone:"live",pulse:!0},void 0,!1,void 0,this)," ",u("frustration.running")]},void 0,!0,void 0,this);case"done":return Q.jsxDEV(Bt,{tone:"ok",children:u("frustration.last-run-done")},void 0,!1,void 0,this);case"cancelled":return Q.jsxDEV(Bt,{tone:"warn",children:u("frustration.last-run-cancelled")},void 0,!1,void 0,this);case"failed":return Q.jsxDEV(Bt,{tone:"bad",children:u("frustration.last-run-failed")},void 0,!1,void 0,this);case"idle":return Q.jsxDEV(Bt,{children:i?u("frustration.not-run-yet"):u("frustration.regex-only")},void 0,!1,void 0,this)}}function ZM({estimate:l}){if(l.status==="loading")return Q.jsxDEV("p",{className:"muted",children:u("frustration.estimating")},void 0,!1,void 0,this);if(l.status==="error")return Q.jsxDEV("p",{className:"tone-bad",children:l.message},void 0,!1,void 0,this);let i=l.estimate;if(!i.available)return Q.jsxDEV("p",{children:i.reason},void 0,!1,void 0,this);if(i.messages===0)return Q.jsxDEV("p",{children:u("frustration.all-judged")},void 0,!1,void 0,this);return Q.jsxDEV(Q.Fragment,{children:[Q.jsxDEV("div",{className:"frustration-quote",children:[Q.jsxDEV("span",{className:"dim micro",children:u("frustration.estimated-cost")},void 0,!1,void 0,this),Q.jsxDEV("span",{className:"num frustration-quote-value",children:["≈ ",da(i.cost)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Q.jsxDEV(Ho,{items:[{key:"messages",label:u("frustration.unjudged-messages"),value:z(i.messages)},{key:"chars",label:u("frustration.prose-chars"),value:z(i.chars)},{key:"tokens",label:u("frustration.input-tokens"),value:z(i.inputTokens)},{key:"judge",label:u("frustration.judge-model"),value:i.judge}]},void 0,!1,void 0,this),Q.jsxDEV("p",{className:"micro dim",children:u("frustration.estimate-note")},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function WM({job:l,cancelling:i,onCancel:c}){let f=l.done+l.failed,p=l.total>0?Math.min(1,f/l.total):0;return Q.jsxDEV("div",{className:"stack frustration-progress",children:[Q.jsxDEV("div",{className:"row frustration-progress-head",children:[Q.jsxDEV("span",{className:"num",children:[z(l.done),"/",z(l.total)," judged"]},void 0,!0,void 0,this),Q.jsxDEV("span",{className:"num dim",children:Fe(p)},void 0,!1,void 0,this),Q.jsxDEV("span",{className:"frustration-spacer"},void 0,!1,void 0,this),Q.jsxDEV("button",{type:"button",className:"btn","data-variant":"danger","data-size":"sm",onClick:c,disabled:i,children:i?u("frustration.cancelling"):u("frustration.cancel-run")},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Q.jsxDEV("div",{className:"meter frustration-progress-track",role:"progressbar","aria-valuemin":0,"aria-valuemax":l.total,"aria-valuenow":f,children:Q.jsxDEV("div",{className:"meter-fill frustration-progress-fill",style:{width:`${p*100}%`}},void 0,!1,void 0,this)},void 0,!1,void 0,this),Q.jsxDEV("div",{className:"row micro muted frustration-progress-meta",children:[Q.jsxDEV("span",{className:l.failed>0?"tone-bad":void 0,children:u("frustration.failed-n",{count:z(l.failed)})},void 0,!1,void 0,this),Q.jsxDEV("span",{children:[u("frustration.cost-so-far")," ",Q.jsxDEV("span",{className:"num",children:da(l.cost)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),l.judge&&Q.jsxDEV("span",{className:"mono",children:l.judge},void 0,!1,void 0,this),l.startedAt!==null&&Q.jsxDEV("span",{children:u("frustration.elapsed",{time:uT(Date.now()-l.startedAt)})},void 0,!1,void 0,this),l.startedAt!==null&&l.done>0&&Q.jsxDEV("span",{className:"num",children:[(l.done/Math.max(1,(Date.now()-l.startedAt)/1000)).toFixed(0),"/s"]},void 0,!0,void 0,this),l.concurrency>0&&Q.jsxDEV("span",{className:"num",children:u("frustration.in-flight",{count:z(l.concurrency)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function JM({job:l}){let i=u("frustration.messages-progress",{done:z(l.done),total:z(l.total)}),c=l.failed>0?u("frustration.failed-suffix",{count:z(l.failed)}):"",f=l.judge?u("frustration.judge-with",{judge:l.judge}):"",p=l.startedAt!==null&&l.finishedAt!==null?u("frustration.in-time",{time:uT(l.finishedAt-l.startedAt)}):"";switch(l.state){case"idle":return Q.jsxDEV("p",{className:"muted",children:u("frustration.no-run-yet")},void 0,!1,void 0,this);case"running":return null;case"done":return Q.jsxDEV("p",{className:"muted",children:u("frustration.run-done-line",{progress:i,failed:c,judge:f,elapsed:p,cost:da(l.cost)})},void 0,!1,void 0,this);case"cancelled":return Q.jsxDEV("p",{className:"muted",children:u("frustration.run-cancelled-line",{progress:i,failed:c,cost:da(l.cost)})},void 0,!1,void 0,this);case"failed":return Q.jsxDEV("p",{className:"muted",children:u("frustration.run-failed-line",{progress:i,failed:c,error:l.error??u("frustration.unknown-error"),cost:da(l.cost)})},void 0,!1,void 0,this)}}function Hd(l){return`${l.modelClass}/${l.family??"unclassified"}`}function vi(l){return l.messages>0&&l.judged/l.messages<nb}function eD(l){let i=2166136261;for(let c=0;c<l.length;c++)i^=l.charCodeAt(c),i=Math.imul(i,16777619);return i>>>0}function tD(l){let i=[...new Set(l.map(Hd))].sort(),c=new Set,f=new Map;for(let p of i){let S=eD(p)%Fa.length;for(let h=0;h<Fa.length&&c.has(S);h++)S=(S+1)%Fa.length;c.add(S),f.set(p,Fa[S])}return f}function aD(l,i){if(i==="angry")return`color-mix(in srgb, ${l} 55%, black)`;if(i==="other")return`color-mix(in srgb, ${l} 32%, transparent)`;return l}var oD=[{key:"angry",label:"Angry at assistant"},{key:"assistant",label:"At assistant, not angry"},{key:"other",label:"Annoyed at other targets"}];function nD(l,i){if(i==="angry")return l.angry;if(i==="assistant")return l.atAssistant-l.angry;return l.annoyed-l.atAssistant}function _d(l,i){return i>0?l/i*100:0}function rD({models:l,stale:i}){let[c,f]=Ut.useState(null),[p,S]=sn(),[h,x]=Ut.useState(!1),[b,L]=Ut.useState(!1),g=Ut.useMemo(()=>tD(l),[l]),C=Ut.useMemo(()=>{let J=new Map;for(let te of l)J.set(te.modelClass,(J.get(te.modelClass)??0)+te.messages);return J},[l]),w=Ut.useMemo(()=>{let J=null,te=-1;for(let[X,ae]of C)if(ae>te)J=X,te=ae;return J??Pd},[C]),A=c!==null&&(c===Pd||C.has(c))?c:w,k=Ut.useMemo(()=>[{value:Pd,label:"All",title:"Every model class"},...[...C].map(([J,te])=>({value:J,label:J,title:`${z(te)} messages`}))],[C]),D=Ut.useMemo(()=>A===Pd?l:l.filter((J)=>J.modelClass===A),[l,A]),M=Ut.useMemo(()=>{let J=new Map;for(let te of D){let X=Hd(te),ae=J.get(X);if(ae){ae.messages+=te.messages;continue}let H=te.family??"unclassified";J.set(X,{key:X,label:A===Pd?`${te.modelClass} · ${H}`:H,messages:te.messages})}return[...J.values()]},[D,A]),B=Ut.useMemo(()=>D.filter((J)=>!p.has(Hd(J))),[D,p]),P=B.filter((J)=>J.messages<jm).length,j=B.filter(vi).length,Y=Ut.useMemo(()=>B.filter((J)=>(h||J.messages>=jm)&&!(b&&vi(J))),[B,h,b]);if(l.length===0)return Q.jsxDEV(Ye,{index:2,title:u("frustration.by-model"),stale:i,children:Q.jsxDEV(wt,{title:u("frustration.no-messages"),hint:u("frustration.try-longer-range")},void 0,!1,void 0,this)},void 0,!1,void 0,this);let ce=Y.some(vi);return Q.jsxDEV(Q.Fragment,{children:[Q.jsxDEV(Ye,{index:2,title:u("frustration.by-model"),description:u("frustration.by-model-description"),stale:i,children:Q.jsxDEV("div",{className:"stack frustration-chart-body",children:[Q.jsxDEV("div",{className:"frustration-classes",children:Q.jsxDEV(_a,{size:"sm","aria-label":u("frustration.model-class"),options:k,value:A,onChange:f},void 0,!1,void 0,this)},void 0,!1,void 0,this),Q.jsxDEV("div",{className:"row frustration-filters",children:[Q.jsxDEV(Ka,{items:M.map((J)=>({key:J.key,label:J.label,color:g.get(J.key)??Fa[0],value:z(J.messages)})),hidden:p,onToggle:S},void 0,!1,void 0,this),Q.jsxDEV("span",{className:"frustration-spacer"},void 0,!1,void 0,this),Q.jsxDEV("label",{className:"check",title:u("frustration.small-models-title",{count:jm}),children:[Q.jsxDEV("input",{type:"checkbox",checked:h,onChange:(J)=>x(J.target.checked)},void 0,!1,void 0,this),u("frustration.include-small",{count:jm}),P>0?` (${P})`:""]},void 0,!0,void 0,this),Q.jsxDEV("label",{className:"check",title:u("frustration.hide-regex-title",{share:nb*100}),children:[Q.jsxDEV("input",{type:"checkbox",checked:b,onChange:(J)=>L(J.target.checked)},void 0,!1,void 0,this),"Hide mostly regex",j>0?` (${j})`:""]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Q.jsxDEV(lD,{hasRegexRows:ce},void 0,!1,void 0,this),Q.jsxDEV(sD,{rows:Y,familyColors:g},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),Q.jsxDEV(uD,{rows:Y,familyColors:g,stale:i},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function lD({hasRegexRows:l}){return Q.jsxDEV("div",{className:"legend frustration-key",children:[Q.jsxDEV("span",{className:"legend-item",children:[Q.jsxDEV("span",{className:"swatch frustration-key-swatch","data-variant":"angry"},void 0,!1,void 0,this),"Angry at assistant"]},void 0,!0,void 0,this),Q.jsxDEV("span",{className:"legend-item",children:[Q.jsxDEV("span",{className:"swatch frustration-key-swatch","data-variant":"assistant"},void 0,!1,void 0,this),"At assistant"]},void 0,!0,void 0,this),Q.jsxDEV("span",{className:"legend-item",children:[Q.jsxDEV("span",{className:"swatch frustration-key-swatch","data-variant":"other"},void 0,!1,void 0,this),"Annoyed at other targets"]},void 0,!0,void 0,this),Q.jsxDEV("span",{className:"legend-item",children:[Q.jsxDEV("span",{className:"frustration-key-line"},void 0,!1,void 0,this),u("frustration.legend-trend")]},void 0,!0,void 0,this),Q.jsxDEV("span",{className:"legend-item frustration-key-wide",title:u("frustration.hatch-title",{share:nb*100}),children:[Q.jsxDEV("span",{className:"swatch frustration-key-swatch","data-variant":"hatch"},void 0,!1,void 0,this),l?u("frustration.legend-hatched-run"):u("frustration.legend-hatched")]},void 0,!0,void 0,this),Q.jsxDEV("span",{className:"legend-item dim",children:u("frustration.legend-hue")},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function sD({rows:l,familyColors:i}){let c=Ut.useMemo(()=>{let f=new Map;l.forEach((S,h)=>{let x=Hd(S),b=vi(S),L=`${x}|${b?"regex":"judged"}`,g=f.get(L);if(g)g.slots.push(h);else f.set(L,{family:x,regex:b,slots:[h]})});let p=[];for(let S of oD)for(let[h,x]of f){let b=l.map(()=>null);for(let L of x.slots)b[L]=_d(nD(l[L],S.key),l[L].messages);p.push({key:`${S.key}|${h}`,label:S.label,color:aD(i.get(x.family)??Fa[0],S.key),values:b,pattern:x.regex?"hatch":void 0})}return p.push({key:"trend",label:"At assistant (total)",color:"var(--ink-1)",values:l.map((S)=>_d(S.atAssistant,S.messages)),kind:"line",tooltip:!1}),p},[l,i]);if(l.length===0)return Q.jsxDEV("div",{className:"frustration-chart-empty",children:Q.jsxDEV(wt,{title:u("frustration.no-model-match")},void 0,!1,void 0,this)},void 0,!1,void 0,this);return Q.jsxDEV(Tn,{slots:l.length,tickLabel:(f)=>l[f].label,series:c,height:340,format:(f)=>`${f}%`,formatTooltip:(f)=>`${f.toFixed(1)}%`,showTotal:!1,emptyLabel:"No frustrated messages for these models",tooltipExtra:(f)=>{let p=l[f];return Q.jsxDEV("div",{className:"frustration-tooltip-extra",children:[Q.jsxDEV("div",{className:"chart-tooltip-row chart-tooltip-total",children:[Q.jsxDEV("span",{className:"chart-tooltip-label",children:u("frustration.legend-annoyed-any")},void 0,!1,void 0,this),Q.jsxDEV("span",{className:"chart-tooltip-value",children:In(p.annoyed,p.messages)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Q.jsxDEV("div",{className:"micro dim",children:[z(p.messages)," messages · judged ",z(p.judged)," (",In(p.judged,p.messages),")",vi(p)?u("frustration.row-mostly-regex"):""]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}},void 0,!1,void 0,this)}function uD({rows:l,familyColors:i,stale:c}){let f=Ut.useMemo(()=>[{key:"model",header:u("common.model"),sort:(p)=>p.label,render:(p)=>Q.jsxDEV("span",{className:"row",title:p.key,children:[Q.jsxDEV("span",{className:"swatch",style:{background:i.get(Hd(p))??Fa[0]}},void 0,!1,void 0,this),Q.jsxDEV("span",{className:"cell-primary",children:p.label},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},{key:"ids",header:u("frustration.column-model-ids"),wrap:!0,render:(p)=>Q.jsxDEV("span",{className:"mono micro dim",children:p.models.join(", ")},void 0,!1,void 0,this)},{key:"messages",header:u("frustration.column-messages"),align:"right",sort:(p)=>p.messages,render:(p)=>Q.jsxDEV("span",{className:"num",children:z(p.messages)},void 0,!1,void 0,this)},{key:"judged",header:u("frustration.column-judged"),align:"right",sort:(p)=>p.messages>0?p.judged/p.messages:0,render:(p)=>vi(p)?Q.jsxDEV("span",{className:"row frustration-judged",title:u("frustration.mostly-regex"),children:[Q.jsxDEV(Bt,{tone:"warn",children:u("frustration.regex-badge")},void 0,!1,void 0,this),Q.jsxDEV("span",{className:"num dim",children:In(p.judged,p.messages)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):Q.jsxDEV("span",{className:"num",children:In(p.judged,p.messages)},void 0,!1,void 0,this)},{key:"annoyed",header:u("frustration.annoyed"),align:"right",sort:(p)=>_d(p.annoyed,p.messages),render:(p)=>Q.jsxDEV("span",{className:"num",title:u("frustration.messages-n",{count:z(p.annoyed)}),children:In(p.annoyed,p.messages)},void 0,!1,void 0,this)},{key:"atAssistant",header:u("frustration.at-assistant"),align:"right",sort:(p)=>_d(p.atAssistant,p.messages),render:(p)=>Q.jsxDEV("span",{className:"num",title:u("frustration.messages-n",{count:z(p.atAssistant)}),children:In(p.atAssistant,p.messages)},void 0,!1,void 0,this)},{key:"angry",header:u("frustration.angry"),align:"right",sort:(p)=>_d(p.angry,p.messages),render:(p)=>Q.jsxDEV("span",{className:p.angry>0?"num tone-bad":"num",title:u("frustration.messages-n",{count:z(p.angry)}),children:In(p.angry,p.messages)},void 0,!1,void 0,this)}],[i]);return Q.jsxDEV(Ye,{index:3,title:u("frustration.model-versions"),description:u("frustration.table-description"),flush:!0,stale:c,children:Q.jsxDEV(Xt,{rows:l,rowKey:(p)=>p.key,columns:f,dense:!0,empty:Q.jsxDEV(wt,{title:u("frustration.no-model-match")},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}var Fd=Z(gt(),1);var Et=Z(ue(),1),iD=86400000,cD={snapcompact:"Snapcompact"},dD=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",timeZone:"UTC"});function iT({active:l,range:i}){let[c,f]=Fd.useState(null),p=Ft(["gain",i,c],({signal:w})=>d1(i,c,w),{enabled:l}),S=ia(i),h=p.data,x=Fd.useMemo(()=>{let w=(h?.timeSeries??[]).map((B)=>({...B,timestamp:Date.parse(`${B.date}T00:00:00Z`)})),A=_o(i,w.map((B)=>B.timestamp),iD),k=Sa(w,A,(B)=>B.snapcompact),D=0,M=k.map((B)=>D+=B);return{buckets:A,daily:k,cumulative:M}},[h,i]),b=Fd.useMemo(()=>{if(!h)return[];let w=h.overall.savedTokens;return Object.keys(h.bySource).map((A)=>({...h.bySource[A],source:A,share:w>0?h.bySource[A].savedTokens/w:0}))},[h]),L=h?.projects??[],g=c!==null&&!L.includes(c)?[c,...L]:L,C=[{key:"daily",label:u("gain.saved-per-day"),color:"var(--chart-primary)",values:x.daily},{key:"cumulative",label:u("gain.cumulative"),color:"var(--chart-secondary)",values:x.cumulative,kind:"line",axis:"right"}];return Et.jsxDEV("div",{className:"page",children:[Et.jsxDEV(ra,{title:u("gain.title"),description:c?u("gain.description-scoped",{project:c,window:u(S.windowKey)}):u("gain.description",{window:u(S.windowKey)}),actions:g.length>0&&Et.jsxDEV("select",{className:"input","aria-label":u("common.project"),value:c??"",onChange:(w)=>f(w.target.value||null),style:{maxWidth:320},children:[Et.jsxDEV("option",{value:"",children:u("gain.all-projects")},void 0,!1,void 0,this),g.map((w)=>Et.jsxDEV("option",{value:w,children:w},w,!1,void 0,this))]},void 0,!0,void 0,this)},void 0,!1,void 0,this),Et.jsxDEV(Ge,{query:p,skeleton:Et.jsxDEV(zt,{height:96},void 0,!1,void 0,this),isEmpty:(w)=>w.overall.hits===0&&w.timeSeries.length===0,empty:Et.jsxDEV(Ye,{children:Et.jsxDEV(wt,{title:c?u("gain.empty-title-scoped",{project:c,window:u(S.windowKey)}):u("gain.empty-title",{window:u(S.windowKey)}),hint:i==="all"?u("gain.empty-hint-all"):u("gain.empty-hint-longer-range")},void 0,!1,void 0,this)},void 0,!1,void 0,this),children:({overall:w})=>Et.jsxDEV(Et.Fragment,{children:[Et.jsxDEV("div",{"data-stale":p.stale,children:Et.jsxDEV(la,{min:180,children:[Et.jsxDEV(ie,{label:u("gain.saved-tokens"),value:Ae(w.savedTokens),hint:z(w.savedTokens),spark:x.daily},void 0,!1,void 0,this),Et.jsxDEV(ie,{label:u("gain.saved-bytes"),value:Xv(w.savedBytes)},void 0,!1,void 0,this),Et.jsxDEV(ie,{label:u("gain.reduction"),title:u("gain.reduction-title"),value:w.reductionPercent!==null?Fe(w.reductionPercent):"–",hint:w.reductionPercent===null?u("gain.reduction-unknown"):void 0},void 0,!1,void 0,this),Et.jsxDEV(ie,{label:u("gain.hits"),value:z(w.hits)},void 0,!1,void 0,this),Et.jsxDEV(ie,{label:u("gain.saved-per-hit"),value:w.hits>0?Ae(w.savedTokens/w.hits):"–",hint:u("common.tokens")},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),Et.jsxDEV(Ye,{index:1,title:u("gain.savings-over-time"),description:u("gain.savings-over-time-description"),actions:Et.jsxDEV(Ka,{items:C.map((A)=>({key:A.key,label:A.label,color:A.color}))},void 0,!1,void 0,this),stale:p.stale,children:Et.jsxDEV(Tn,{slots:x.buckets.length,tickLabel:(A)=>dD.format(x.buckets[A]),series:C,height:260,formatTooltip:z,formatRight:Ae},void 0,!1,void 0,this)},void 0,!1,void 0,this),Et.jsxDEV(Ye,{index:2,title:u("gain.by-source"),description:u("gain.by-source-description"),flush:!0,stale:p.stale,children:Et.jsxDEV(Xt,{rows:b,rowKey:(A)=>A.source,columns:fD},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var fD=[{key:"source",header:u("gain.source"),sort:(l)=>l.source,render:(l)=>Et.jsxDEV("span",{className:"cell-primary",children:cD[l.source]},void 0,!1,void 0,this)},{key:"tokens",header:u("gain.saved-tokens"),align:"right",sort:(l)=>l.savedTokens,render:(l)=>Et.jsxDEV("span",{title:z(l.savedTokens),children:Et.jsxDEV(pa,{value:l.share,max:1,display:Ae(l.savedTokens)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},{key:"share",header:u("common.share"),align:"right",sort:(l)=>l.share,render:(l)=>Et.jsxDEV("span",{className:"num muted",children:Fe(l.share)},void 0,!1,void 0,this)},{key:"bytes",header:u("gain.saved-bytes"),align:"right",sort:(l)=>l.savedBytes,render:(l)=>Et.jsxDEV("span",{className:"num",children:Xv(l.savedBytes)},void 0,!1,void 0,this)},{key:"hits",header:u("gain.hits"),align:"right",sort:(l)=>l.hits,render:(l)=>Et.jsxDEV("span",{className:"num",children:z(l.hits)},void 0,!1,void 0,this)},{key:"reduction",header:u("gain.reduction"),align:"right",sort:(l)=>l.reductionPercent??-1,render:(l)=>Et.jsxDEV("span",{className:"num",children:l.reductionPercent!==null?Fe(l.reductionPercent):"–"},void 0,!1,void 0,this)}];var bi=Z(gt(),1);var Le=Z(ue(),1),pD=[{value:"share",label:u("common.share")},{value:"requests",label:u("common.requests")}],mD=6;function dT({active:l,range:i}){let c=Ft(["models",i],({signal:D})=>t1(i,D),{enabled:l}),f=ia(i),[p,S]=bi.useState("share"),[h,x]=sn(),[b,L]=bi.useState(null),g=bi.useMemo(()=>c.data?hD(c.data,i):null,[c.data,i]),C=bD(f.bucketMs),w=bi.useMemo(()=>g?yD(g,b,C):[],[g,b,C]),A=(D)=>D.byModel.length===0,k=Le.jsxDEV(wt,{title:u("models.empty-title"),hint:u("models.empty-hint")},void 0,!1,void 0,this);return Le.jsxDEV("div",{className:"page",children:[Le.jsxDEV(ra,{title:u("common.models"),description:u("models.subtitle",{window:u(f.windowKey)})},void 0,!1,void 0,this),Le.jsxDEV(Ge,{query:c,skeleton:Le.jsxDEV(qa,{height:112,style:{borderRadius:12}},void 0,!1,void 0,this),isEmpty:A,empty:k,children:()=>g&&Le.jsxDEV("div",{"data-stale":c.stale,children:Le.jsxDEV(la,{min:200,children:[Le.jsxDEV(ie,{label:u("models.used"),value:z(g.models.length),hint:g.providerCount===1?u("models.across-providers-one",{count:z(g.providerCount)}):u("models.across-providers",{count:z(g.providerCount)})},void 0,!1,void 0,this),Le.jsxDEV(ie,{label:u("models.most-used"),title:g.top?`${g.top.model} (${g.top.provider})`:void 0,value:g.top?g.top.model:"–",hint:g.top?u("models.most-used-hint",{share:Fe(g.top.totalRequests/Math.max(1,g.totalRequests)),provider:g.top.provider}):void 0},void 0,!1,void 0,this),Le.jsxDEV(ie,{label:u("common.requests"),value:z(g.totalRequests),hint:u("models.failed-n",{count:z(g.failedRequests)}),spark:g.requestTotals},void 0,!1,void 0,this),Le.jsxDEV(ie,{label:u("models.api-cost"),title:u("models.api-cost-title"),value:Ht(g.totalCost,g.unpricedRequests),hint:g.unpricedRequests>0?u("models.unpriced-n",{count:z(g.unpricedRequests)}):void 0},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),Le.jsxDEV(Ye,{index:1,title:u("models.request-share"),description:p==="share"?u("models.share-desc",{bucket:C}):u("models.count-desc",{bucket:C}),actions:Le.jsxDEV(_a,{size:"sm",options:pD,value:p,onChange:S,"aria-label":u("models.share-mode-aria")},void 0,!1,void 0,this),stale:c.stale,children:Le.jsxDEV(Ge,{query:c,skeleton:Le.jsxDEV(zt,{height:260},void 0,!1,void 0,this),isEmpty:A,empty:k,children:()=>g&&Le.jsxDEV("div",{className:"stack",style:{gap:12},children:[Le.jsxDEV(Xr,{buckets:g.buckets,bucketMs:f.bucketMs,series:p==="share"?g.shareSeries:g.countSeries,hidden:h,height:260,yMax:p==="share"?1:void 0,format:p==="share"?(D)=>Fe(D,0):Ae,formatTooltip:p==="share"?(D)=>Fe(D):z,showTotal:p==="requests"},void 0,!1,void 0,this),Le.jsxDEV(Ka,{items:g.countSeries.map((D)=>({key:D.key,label:D.label,color:D.color,value:Fe(cT(D.values)/Math.max(1,cT(g.requestTotals)))})),hidden:h,onToggle:x},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),Le.jsxDEV(Ye,{index:2,title:u("models.all-models"),description:u("models.table-desc"),stale:c.stale,flush:!0,children:Le.jsxDEV(Ge,{query:c,skeleton:Le.jsxDEV(ca,{rows:8},void 0,!1,void 0,this),isEmpty:A,empty:k,children:()=>g&&Le.jsxDEV(Xt,{rows:g.models,rowKey:(D)=>ba(D.model,D.provider),columns:w,initialSort:{key:"requests",dir:"desc"},limit:25,onRowClick:(D)=>{let M=ba(D.model,D.provider);L((B)=>B===M?null:M)},selectedKey:b,expanded:(D)=>{let M=ba(D.model,D.provider);return M===b?Le.jsxDEV(vD,{model:D,color:g.swatches.get(M)??"var(--chart-primary)",points:g.performance.get(M)??[],bucketMs:f.bucketMs,bucketWord:C},void 0,!1,void 0,this):null}},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function hD(l,i){let c=l.byModel,f=Vm(c),p=gD(c),S=_o(i,l.modelSeries.map((M)=>M.timestamp)),h=Sa(l.modelSeries,S,(M)=>M.requests),x={buckets:S,key:(M)=>ba(M.model,M.provider),label:(M)=>p.get(M)??M,value:(M)=>M.requests,colors:f},b=hr(l.modelSeries,{...x,limit:mD}).map((M)=>({...M,values:M.values.map((B)=>B||null)})),L=b.map((M)=>({...M,values:M.values.map((B,P)=>B===null?null:B/h[P])})),g=new Map(hr(l.modelSeries,x).map((M)=>[M.key,M.values])),C,w=0,A=0,k=0,D=0;for(let M of c){if(!C||M.totalRequests>C.totalRequests)C=M;w+=M.totalRequests,A+=M.failedRequests,k+=M.totalCost,D+=M.unpricedRequests}return{models:c,top:C,swatches:new Map(b.filter((M)=>M.key!=="__other__").map((M)=>[M.key,M.color])),labels:p,providerCount:new Set(c.map((M)=>M.provider)).size,totalRequests:w,failedRequests:A,totalCost:k,unpricedRequests:D,maxRequests:C?.totalRequests??0,buckets:S,requestTotals:h,countSeries:b,shareSeries:L,trends:g,performance:W1(l.modelPerformanceSeries)}}function gD(l){let i=new Map;for(let c of l)i.set(c.model,(i.get(c.model)??0)+1);return new Map(l.map((c)=>[ba(c.model,c.provider),(i.get(c.model)??0)>1?`${c.model} · ${c.provider}`:c.model]))}function yD(l,i,c){return[{key:"expand",header:"",width:28,render:(f)=>Le.jsxDEV("span",{className:"models-chevron","data-open":ba(f.model,f.provider)===i,children:Le.jsxDEV(Ln,{size:14},void 0,!1,void 0,this)},void 0,!1,void 0,this)},{key:"model",header:u("common.model"),sort:(f)=>f.model,render:(f)=>Le.jsxDEV(Ha,{lead:Le.jsxDEV(Cn,{color:l.swatches.get(ba(f.model,f.provider))??ao},void 0,!1,void 0,this),primary:Le.jsxDEV("span",{className:"mono",children:f.model},void 0,!1,void 0,this),secondary:f.provider},void 0,!1,void 0,this)},{key:"requests",header:u("common.requests"),align:"right",sort:(f)=>f.totalRequests,render:(f)=>Le.jsxDEV(pa,{value:f.totalRequests,max:l.maxRequests,display:z(f.totalRequests),color:l.swatches.get(ba(f.model,f.provider))??ao},void 0,!1,void 0,this)},{key:"cost",header:u("common.cost"),title:u("models.cost-title"),align:"right",sort:(f)=>f.totalCost,render:(f)=>Le.jsxDEV("span",{className:"num",children:Ht(f.totalCost,f.unpricedRequests)},void 0,!1,void 0,this)},{key:"tokens",header:u("common.tokens"),title:u("models.tokens-title"),align:"right",sort:(f)=>Ql(f),render:(f)=>{let p=Ql(f);return Le.jsxDEV("span",{className:"num",title:z(p),children:Ae(p)},void 0,!1,void 0,this)}},{key:"cache",header:u("models.cache-rate"),title:u("models.cache-title"),align:"right",sort:(f)=>f.cacheRate,render:(f)=>Le.jsxDEV("span",{className:"num",children:Fe(f.cacheRate)},void 0,!1,void 0,this)},{key:"errors",header:u("models.errors"),align:"right",sort:(f)=>f.errorRate,render:(f)=>f.failedRequests===0?Le.jsxDEV("span",{className:"num dim",children:"0%"},void 0,!1,void 0,this):Le.jsxDEV("span",{title:u("models.failed-n",{count:z(f.failedRequests)}),children:Le.jsxDEV(Bt,{tone:ir(f.errorRate),mono:!0,children:to(f.errorRate)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},{key:"tps",header:u("common.tokens-per-second"),title:u("models.tps-title"),align:"right",sort:(f)=>f.avgTokensPerSecond??-1,render:(f)=>Le.jsxDEV("span",{className:"num",children:dr(f.avgTokensPerSecond)},void 0,!1,void 0,this)},{key:"ttft",header:u("models.ttft"),title:u("models.ttft-title"),align:"right",sort:(f)=>f.avgTtft??-1,render:(f)=>Le.jsxDEV("span",{className:"num",children:At(f.avgTtft)},void 0,!1,void 0,this)},{key:"trend",header:u("models.trend"),title:u("models.trend-title",{bucket:c}),width:112,render:(f)=>{let p=ba(f.model,f.provider),S=l.trends.get(p);return S?Le.jsxDEV(mi,{values:S.map((h)=>h??0),color:l.swatches.get(p)??ao,width:96,height:22},void 0,!1,void 0,this):Le.jsxDEV("span",{className:"dim",children:"–"},void 0,!1,void 0,this)}}]}function vD({model:l,color:i,points:c,bucketMs:f,bucketWord:p}){let[S,h]=sn(),x=[{key:"tps",label:u("common.tokens-per-second"),color:i,kind:c.length>1?"line":"bars",values:c.map((b)=>b.avgTokensPerSecond)},{key:"ttft",label:u("models.ttft"),color:ao,kind:c.length>1?"line":"bars",axis:"right",dashed:!0,values:c.map((b)=>b.avgTtftSeconds)}];return Le.jsxDEV("div",{className:"models-detail",children:[Le.jsxDEV("div",{className:"models-detail-facts",children:[Le.jsxDEV("div",{children:[Le.jsxDEV("div",{className:"section-label",children:u("models.efficiency")},void 0,!1,void 0,this),Le.jsxDEV(Ho,{items:[{key:"err",label:u("common.error-rate"),value:Le.jsxDEV("span",{className:`tone-${ir(l.errorRate)}`,children:[to(l.errorRate)," ",Le.jsxDEV("span",{className:"dim",children:["(",u("models.failed-n",{count:z(l.failedRequests)}),")"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},{key:"cache",label:u("models.cache-rate"),value:Fe(l.cacheRate)},{key:"savings",label:u("models.cache-savings"),value:Le.jsxDEV("span",{className:l.cacheSavings<0?"tone-bad":void 0,children:Fe(l.cacheSavings)},void 0,!1,void 0,this)},{key:"premium",label:u("common.premium-requests"),value:z(Math.round(l.totalPremiumRequests*100)/100)}]},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Le.jsxDEV("div",{children:[Le.jsxDEV("div",{className:"section-label",children:u("models.latency")},void 0,!1,void 0,this),Le.jsxDEV(Ho,{items:[{key:"dur",label:u("models.avg-duration"),value:At(l.avgDuration)},{key:"ttft",label:u("models.avg-ttft"),value:At(l.avgTtft)},{key:"tps",label:u("common.tokens-per-second"),value:dr(l.avgTokensPerSecond)}]},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Le.jsxDEV("div",{children:[Le.jsxDEV("div",{className:"section-label",children:u("common.tokens")},void 0,!1,void 0,this),Le.jsxDEV(Ho,{items:[{key:"in",label:u("models.uncached-input"),value:Ae(l.totalInputTokens)},{key:"cr",label:u("common.cache-read"),value:Ae(l.totalCacheReadTokens)},{key:"cw",label:u("common.cache-write"),value:Ae(l.totalCacheWriteTokens)},{key:"out",label:u("common.output"),value:Ae(l.totalOutputTokens)}]},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Le.jsxDEV("div",{className:"micro dim",children:u("models.first-last-seen",{first:fa(l.firstTimestamp),last:fa(l.lastTimestamp)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Le.jsxDEV("div",{className:"models-detail-chart",children:[Le.jsxDEV("div",{className:"row",style:{justifyContent:"space-between"},children:[Le.jsxDEV("div",{className:"section-label",style:{marginBottom:0},children:u("models.performance-per-bucket",{bucket:p})},void 0,!1,void 0,this),Le.jsxDEV(Ka,{items:x.map((b)=>({key:b.key,label:b.label,color:b.color})),hidden:S,onToggle:h},void 0,!1,void 0,this)]},void 0,!0,void 0,this),c.length===0?Le.jsxDEV(wt,{title:u("models.no-samples-title"),hint:u("models.no-samples-hint")},void 0,!1,void 0,this):Le.jsxDEV(Xr,{buckets:c.map((b)=>b.timestamp),bucketMs:f,series:x,hidden:S,stacked:!1,height:240,format:Ae,formatTooltip:(b)=>u("models.tok-per-second",{value:dr(b)}),formatRight:(b)=>`${Number(b.toFixed(2))}s`,tooltipExtra:(b)=>Le.jsxDEV("div",{className:"chart-tooltip-row chart-tooltip-total",children:[Le.jsxDEV("span",{className:"chart-tooltip-label",children:u("common.requests")},void 0,!1,void 0,this),Le.jsxDEV("span",{className:"chart-tooltip-value",children:z(c[b].requests)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function bD(l){if(l<3600000)return u("models.bucket-5m");if(l<86400000)return u("models.bucket-hour");return u("models.bucket-day")}function cT(l){let i=0;for(let c of l)i+=c??0;return i}var Xm=Z(gt(),1);var Ie=Z(ue(),1),xD=[{value:"requests",label:u("common.requests")},{value:"tokens",label:u("common.tokens")},{value:"cost",label:u("common.cost")}],fT={main:u("overview.main-agent"),subagent:u("overview.subagents"),advisor:u("overview.advisor")},pT={main:"var(--chart-primary)",subagent:"var(--chart-secondary)",advisor:"#9d7bff"},mT=[{key:"input",label:u("overview.uncached-input"),color:"#5b8cff"},{key:"cacheRead",label:u("common.cache-read"),color:"var(--chart-primary)"},{key:"cacheWrite",label:u("common.cache-write"),color:"#f5b54a"},{key:"output",label:u("common.output"),color:"var(--chart-secondary)"}];function hT({active:l,range:i,onRequestClick:c}){let f=Ft(["overview",i],({signal:g})=>e1(i,g),{enabled:l}),p=Ft(["recent-requests"],({signal:g})=>Mm(12,g),{enabled:l}),[S,h]=Xm.useState("requests"),x=ia(i),b=Xm.useMemo(()=>{let g=f.data?.timeSeries??[],C=_o(i,g.map((w)=>w.timestamp));return{buckets:C,requests:Sa(g,C,(w)=>w.requests-w.errors),errors:Sa(g,C,(w)=>w.errors),tokens:Sa(g,C,(w)=>w.tokens),cost:Sa(g,C,(w)=>w.cost),all:Sa(g,C,(w)=>w.requests)}},[f.data,i]),L=S==="requests"?[{key:"ok",label:u("overview.succeeded"),color:"var(--chart-primary)",values:b.requests},{key:"err",label:u("common.failed"),color:"var(--bad)",values:b.errors}]:S==="tokens"?[{key:"tokens",label:u("common.tokens"),color:"var(--chart-primary)",values:b.tokens}]:[{key:"cost",label:u("overview.api-equivalent"),color:"var(--chart-secondary)",values:b.cost}];return Ie.jsxDEV("div",{className:"page",children:[Ie.jsxDEV(ra,{title:u("overview.title"),description:u("overview.description",{window:u(x.windowKey)})},void 0,!1,void 0,this),Ie.jsxDEV(Ge,{query:f,skeleton:Ie.jsxDEV(zt,{height:112},void 0,!1,void 0,this),children:({overall:g})=>Ie.jsxDEV("div",{"data-stale":f.stale,className:"stack",style:{gap:16},children:[Ie.jsxDEV(la,{min:190,children:[Ie.jsxDEV(ie,{label:u("overview.api-equivalent-cost"),title:u("overview.api-cost-title"),value:Ht(g.totalCost,g.unpricedRequests),hint:g.unpricedRequests>0?u("overview.unpriced-n",{count:z(g.unpricedRequests)}):void 0,spark:b.cost,sparkColor:"var(--chart-secondary)"},void 0,!1,void 0,this),Ie.jsxDEV(ie,{label:u("common.requests"),value:z(g.totalRequests),hint:u("overview.failed-n",{count:z(g.failedRequests)}),spark:b.all},void 0,!1,void 0,this),Ie.jsxDEV(ie,{label:u("overview.conversation-tokens"),title:u("overview.tokens-title"),value:Ae(Ql(g)),hint:u("overview.output-n",{count:Ae(g.totalOutputTokens)}),spark:b.tokens},void 0,!1,void 0,this),Ie.jsxDEV(ie,{label:u("overview.cache-rate"),title:u("overview.cache-rate-title"),value:Fe(g.cacheRate),hint:u("overview.cache-saved",{value:Fe(g.cacheSavings)})},void 0,!1,void 0,this),Ie.jsxDEV(ie,{label:u("common.error-rate"),value:to(g.errorRate),hint:u("overview.succeeded-n",{count:z(g.successfulRequests)}),spark:b.errors,sparkColor:"var(--bad)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Ie.jsxDEV(la,{min:140,children:[Ie.jsxDEV(ie,{size:"sm",label:u("overview.uncached-input"),value:Ae(g.totalInputTokens)},void 0,!1,void 0,this),Ie.jsxDEV(ie,{size:"sm",label:u("common.cache-read"),value:Ae(g.totalCacheReadTokens)},void 0,!1,void 0,this),Ie.jsxDEV(ie,{size:"sm",label:u("common.cache-write"),value:Ae(g.totalCacheWriteTokens)},void 0,!1,void 0,this),Ie.jsxDEV(ie,{size:"sm",label:u("common.output"),value:Ae(g.totalOutputTokens)},void 0,!1,void 0,this),Ie.jsxDEV(ie,{size:"sm",label:u("common.premium-requests"),value:z(Math.round(g.totalPremiumRequests*100)/100)},void 0,!1,void 0,this),Ie.jsxDEV(ie,{size:"sm",label:u("common.tokens-per-second"),value:dr(g.avgTokensPerSecond)},void 0,!1,void 0,this),Ie.jsxDEV(ie,{size:"sm",label:u("overview.avg-latency"),value:At(g.avgDuration)},void 0,!1,void 0,this),Ie.jsxDEV(ie,{size:"sm",label:u("overview.avg-ttft"),value:At(g.avgTtft)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),Ie.jsxDEV("div",{className:"grid grid-main-side",children:[Ie.jsxDEV(Ye,{index:1,title:u("overview.activity"),description:x.bucketMs<3600000?u("overview.per-5m"):x.bucketMs<86400000?u("overview.per-hour"):u("overview.per-day"),actions:Ie.jsxDEV(_a,{size:"sm",options:xD,value:S,onChange:h},void 0,!1,void 0,this),stale:f.stale,children:Ie.jsxDEV(Ge,{query:f,skeleton:Ie.jsxDEV(zt,{height:260},void 0,!1,void 0,this),children:()=>Ie.jsxDEV(Xr,{buckets:b.buckets,bucketMs:x.bucketMs,series:L,height:260,format:S==="cost"?(g)=>Ht(g,0):Ae},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),Ie.jsxDEV(Ye,{index:2,title:u("overview.token-mix"),description:u("overview.token-mix-description"),stale:f.stale,children:Ie.jsxDEV(Ge,{query:f,skeleton:Ie.jsxDEV(zt,{height:260},void 0,!1,void 0,this),children:({overall:g,byAgentType:C})=>{let w={input:g.totalInputTokens,cacheRead:g.totalCacheReadTokens,cacheWrite:g.totalCacheWriteTokens,output:g.totalOutputTokens},A=Ql(g),k=K1(C);return Ie.jsxDEV("div",{className:"stack",style:{gap:18},children:[Ie.jsxDEV("div",{className:"stack",style:{gap:10},children:[Ie.jsxDEV($l,{segments:mT.map((D)=>({key:D.key,label:D.label,value:w[D.key],color:D.color}))},void 0,!1,void 0,this),Ie.jsxDEV(Ka,{items:mT.map((D)=>({key:D.key,label:D.label,color:D.color,value:A>0?Fe(w[D.key]/A,0):"–"}))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Ie.jsxDEV("div",{className:"stack",style:{gap:10},children:[Ie.jsxDEV("div",{className:"section-label",style:{marginBottom:0},children:u("overview.by-agent")},void 0,!1,void 0,this),Ie.jsxDEV($l,{segments:k.segments.map((D)=>({key:D.agentType,label:fT[D.agentType],value:D.tokens,color:pT[D.agentType]}))},void 0,!1,void 0,this),k.segments.map((D)=>Ie.jsxDEV("div",{className:"row",style:{justifyContent:"space-between"},children:[Ie.jsxDEV("span",{className:"row",children:[Ie.jsxDEV("span",{className:"swatch",style:{background:pT[D.agentType]}},void 0,!1,void 0,this),fT[D.agentType],Ie.jsxDEV("span",{className:"dim num",children:u("overview.requests-short",{count:z(D.requests)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Ie.jsxDEV("span",{className:"row",children:[Ie.jsxDEV("span",{className:"dim num",children:Ae(D.tokens)},void 0,!1,void 0,this),Ie.jsxDEV("span",{className:"num",style:{minWidth:48,textAlign:"right"},children:Fe(D.share)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},D.agentType,!0,void 0,this))]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Ie.jsxDEV(Ye,{index:3,title:Ie.jsxDEV(Ie.Fragment,{children:[Ie.jsxDEV(ur,{tone:"live",pulse:!0},void 0,!1,void 0,this)," ",u("overview.latest-requests")]},void 0,!0,void 0,this),description:u("overview.latest-requests-description"),actions:Ie.jsxDEV("a",{className:"btn","data-size":"sm","data-variant":"ghost",href:`#/requests?range=${i}`,children:[u("overview.all-requests")," ",Ie.jsxDEV(dd,{size:13},void 0,!1,void 0,this)]},void 0,!0,void 0,this),flush:!0,children:Ie.jsxDEV(Ge,{query:p,skeleton:Ie.jsxDEV(ca,{rows:8},void 0,!1,void 0,this),children:(g)=>Ie.jsxDEV(Xt,{rows:g,rowKey:(C)=>C.id??`${C.sessionFile}:${C.entryId}`,onRowClick:(C)=>C.id!==void 0&&c(C.id),columns:SD,dense:!0},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var SD=[{key:"model",header:u("common.model"),render:(l)=>Ie.jsxDEV(Ha,{primary:l.model,secondary:l.provider},void 0,!1,void 0,this)},{key:"time",header:u("overview.when"),render:(l)=>Ie.jsxDEV("span",{className:"muted",children:fa(l.timestamp)},void 0,!1,void 0,this)},{key:"tokens",header:u("common.tokens"),align:"right",render:(l)=>Ie.jsxDEV("span",{className:"num",children:z(l.usage.totalTokens)},void 0,!1,void 0,this)},{key:"cost",header:u("common.cost"),align:"right",render:(l)=>Ie.jsxDEV("span",{className:"num",children:Yl(l,4)},void 0,!1,void 0,this)},{key:"duration",header:u("common.duration"),align:"right",render:(l)=>Ie.jsxDEV("span",{className:"num",children:At(l.duration)},void 0,!1,void 0,this)},{key:"status",header:u("overview.status"),align:"right",render:(l)=>l.errorMessage?Ie.jsxDEV(Bt,{tone:"bad",children:u("common.failed")},void 0,!1,void 0,this):Ie.jsxDEV(Bt,{tone:"ok",children:u("overview.ok")},void 0,!1,void 0,this)}];var Rn=Z(gt(),1);var Ve=Z(ue(),1),LD=100,gT=8;function yT({active:l,range:i}){let c=Ft(["projects",i],({signal:D})=>c1(i,D),{enabled:l}),[f,p]=Rn.useState(""),[S,h]=Rn.useState(!0),x=Rn.useDeferredValue(f.trim().toLowerCase()),b=ia(i),L=Rn.useMemo(()=>J1(c.data??[]),[c.data]),g=Rn.useMemo(()=>S?L.rows.filter((D)=>!D.temporary):L.rows,[L,S]),C=Rn.useMemo(()=>x?g.filter((D)=>D.folder.toLowerCase().includes(x)):g,[g,x]),w=Rn.useMemo(()=>({cost:[...g].sort((D,M)=>M.totalCost-D.totalCost).slice(0,gT),requests:[...g].sort((D,M)=>M.totalRequests-D.totalRequests).slice(0,gT)}),[g]),A=Ve.jsxDEV(wt,{title:u(L.rows.length===0?"projects.empty-no-folders":"projects.empty-only-temporary")},void 0,!1,void 0,this),k=Rn.useMemo(()=>CD(L.maxRequests,L.maxCost),[L]);return Ve.jsxDEV("div",{className:"page",children:[Ve.jsxDEV(ra,{title:u("projects.title"),description:u("projects.description",{window:u(b.windowKey)})},void 0,!1,void 0,this),Ve.jsxDEV(Ge,{query:c,skeleton:Ve.jsxDEV(zt,{height:96},void 0,!1,void 0,this),children:()=>Ve.jsxDEV("div",{"data-stale":c.stale,children:Ve.jsxDEV(la,{min:180,children:[Ve.jsxDEV(ie,{label:u("projects.folders"),value:z(L.rows.length),hint:L.temporaryCount>0?u("projects.temporary-n",{count:z(L.temporaryCount)}):void 0},void 0,!1,void 0,this),Ve.jsxDEV(ie,{label:u("common.requests"),value:z(L.totalRequests),hint:u("projects.failed-n",{count:z(L.failedRequests)})},void 0,!1,void 0,this),Ve.jsxDEV(ie,{label:u("projects.api-equivalent-cost"),title:u("projects.api-equivalent-cost-hint"),value:Ht(L.totalCost,L.unpricedRequests),hint:L.unpricedRequests>0?u("projects.unpriced-n",{count:z(L.unpricedRequests)}):void 0},void 0,!1,void 0,this),Ve.jsxDEV(ie,{label:u("projects.conversation-tokens"),title:u("projects.conversation-tokens-hint"),value:Ae(L.conversationTokens)},void 0,!1,void 0,this),Ve.jsxDEV(ie,{label:u("projects.cache-rate"),title:u("projects.cache-rate-hint-all"),value:Fe(L.cacheRate)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),Ve.jsxDEV("div",{className:"grid grid-2",children:[Ve.jsxDEV(Ye,{index:1,title:u("projects.top-by-cost"),description:u("projects.top-by-cost-description"),stale:c.stale,children:Ve.jsxDEV(Ge,{query:c,skeleton:Ve.jsxDEV(zt,{height:236},void 0,!1,void 0,this),isEmpty:()=>w.cost.length===0,empty:A,children:()=>Ve.jsxDEV(qd,{items:w.cost.map((D)=>({key:D.folder,label:Ve.jsxDEV("span",{className:"mono",children:fr(D.folder)},void 0,!1,void 0,this),value:D.totalCost,display:`${Ht(D.totalCost,D.unpricedRequests)} · ${Fe(D.costShare)}`,color:"var(--chart-secondary)"})),onSelect:p},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),Ve.jsxDEV(Ye,{index:2,title:u("projects.top-by-requests"),description:u("projects.top-by-requests-description"),stale:c.stale,children:Ve.jsxDEV(Ge,{query:c,skeleton:Ve.jsxDEV(zt,{height:236},void 0,!1,void 0,this),isEmpty:()=>w.requests.length===0,empty:A,children:()=>Ve.jsxDEV(qd,{items:w.requests.map((D)=>({key:D.folder,label:Ve.jsxDEV("span",{className:"mono",children:fr(D.folder)},void 0,!1,void 0,this),value:D.totalRequests,display:`${z(D.totalRequests)} · ${Fe(D.requestShare)}`})),onSelect:p},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Ve.jsxDEV(Ye,{index:3,title:u("projects.folders"),description:c.data?C.length===L.rows.length?u("projects.folders-n",{count:z(L.rows.length)}):u("projects.folders-of-n",{count:z(C.length),total:z(L.rows.length)}):void 0,actions:Ve.jsxDEV(Ve.Fragment,{children:[L.temporaryCount>0&&Ve.jsxDEV("label",{className:"check",title:u("projects.hide-temporary-hint"),children:[Ve.jsxDEV("input",{type:"checkbox",checked:S,onChange:(D)=>h(D.target.checked)},void 0,!1,void 0,this),u("projects.hide-temporary",{count:z(L.temporaryCount)})]},void 0,!0,void 0,this),Ve.jsxDEV(cr,{value:f,onChange:p,placeholder:u("projects.filter-placeholder"),width:240},void 0,!1,void 0,this)]},void 0,!0,void 0,this),flush:!0,stale:c.stale,children:Ve.jsxDEV(Ge,{query:c,skeleton:Ve.jsxDEV(ca,{rows:10},void 0,!1,void 0,this),children:()=>Ve.jsxDEV(Xt,{rows:C,rowKey:(D)=>D.folder,columns:k,initialSort:{key:"cost",dir:"desc"},limit:LD,dense:!0,empty:Ve.jsxDEV(wt,{title:u(L.rows.length===0?"projects.empty-no-folders":"projects.empty-no-match"),hint:L.rows.length===0?u("projects.hint-longer-range"):S&&L.temporaryCount>0?u("projects.hint-temporary-hidden"):void 0},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function CD(l,i){return[{key:"folder",header:u("projects.folder"),sort:(c)=>c.folder,render:(c)=>Ve.jsxDEV("span",{className:"row projects-folder",title:c.folder||u("common.root"),children:[Ve.jsxDEV("span",{className:"mono truncate",children:fr(c.folder)},void 0,!1,void 0,this),c.temporary&&Ve.jsxDEV(Bt,{children:u("projects.temp")},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},{key:"requests",header:u("common.requests"),align:"right",sort:(c)=>c.totalRequests,render:(c)=>Ve.jsxDEV("span",{title:u("projects.share-of-requests",{share:Fe(c.requestShare)}),children:Ve.jsxDEV(pa,{value:c.totalRequests,max:l,display:z(c.totalRequests)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},{key:"cost",header:u("common.cost"),title:u("projects.api-equivalent-cost-rates"),align:"right",sort:(c)=>c.totalCost,render:(c)=>Ve.jsxDEV("span",{title:u("projects.share-of-cost",{share:Fe(c.costShare)}),children:Ve.jsxDEV(pa,{value:c.totalCost,max:i,display:Ht(c.totalCost,c.unpricedRequests),color:"var(--chart-secondary)"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},{key:"tokens",header:u("common.tokens"),title:u("projects.conversation-tokens-hint"),align:"right",sort:(c)=>c.conversationTokens,render:(c)=>Ve.jsxDEV("span",{className:"num",title:z(c.conversationTokens),children:Ae(c.conversationTokens)},void 0,!1,void 0,this)},{key:"cacheRate",header:u("projects.cache-rate"),title:u("projects.cache-rate-hint"),align:"right",sort:(c)=>c.cacheRate,render:(c)=>Ve.jsxDEV("span",{className:"num",children:Fe(c.cacheRate)},void 0,!1,void 0,this)},{key:"cacheSavings",header:u("projects.cache-savings"),title:u("projects.cache-savings-hint"),align:"right",sort:(c)=>c.cacheSavings,render:(c)=>Ve.jsxDEV("span",{className:`num ${c.cacheSavings<0?"tone-bad":"muted"}`,children:Fe(c.cacheSavings)},void 0,!1,void 0,this)},{key:"errorRate",header:u("projects.errors"),align:"right",sort:(c)=>c.errorRate,render:(c)=>Ve.jsxDEV("span",{title:u("projects.failed-n",{count:z(c.failedRequests)}),children:Ve.jsxDEV(Bt,{tone:c.failedRequests>0?ir(c.errorRate):"neutral",mono:!0,children:to(c.errorRate)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},{key:"duration",header:u("projects.avg-duration"),align:"right",sort:(c)=>c.avgDuration??-1,render:(c)=>Ve.jsxDEV("span",{className:"num",children:At(c.avgDuration)},void 0,!1,void 0,this)},{key:"last",header:u("projects.last-active"),align:"right",sort:(c)=>c.lastTimestamp,render:(c)=>Ve.jsxDEV("span",{className:"dim",children:fa(c.lastTimestamp)},void 0,!1,void 0,this)}]}var po=Z(gt(),1);var ee=Z(ue(),1),wD=[{value:"tokens",label:u("common.tokens")},{value:"cost",label:u("common.cost"),title:u("providers.cost-title")},{value:"requests",label:u("common.requests")}],vT=6,bT=[{key:"input",label:u("ui.uncached-input"),color:"#5b8cff"},{key:"cacheRead",label:u("common.cache-read"),color:"var(--chart-primary)"},{key:"cacheWrite",label:u("common.cache-write"),color:"#f5b54a"},{key:"output",label:u("common.output"),color:"var(--chart-secondary)"}],xT=u("providers.snapshot-hint");function ST({active:l,range:i}){let c=Ft(["providers",i],({signal:P})=>p1(i,P),{enabled:l}),[f,p]=po.useState("tokens"),[S,h]=sn(),x=ia(i),b=Ft(["provider-windows",i],({signal:P})=>Pv(i,null,P),{enabled:l}),[L,g]=po.useState(null),C=kD(b.data?.windowInsights??[],L),w=C?.provider??null,A=Ft(["provider-windows",i,w],({signal:P})=>Pv(i,w,P),{enabled:l&&w!==null}),k=po.useMemo(()=>{let P=c.data?.providers??[],j=c.data?.series??[],Y=Nd(P.map((X)=>({key:X.provider,weight:X.totalTokens}))),ce=_o(i,j.map((X)=>X.timestamp)),J={requests:0,failed:0,tokens:0,cost:0,unpriced:0};for(let X of P)J.requests+=X.totalRequests,J.failed+=X.failedRequests,J.tokens+=X.totalTokens,J.cost+=X.totalCost,J.unpriced+=X.unpricedRequests;let te=(X)=>hr(j,{buckets:ce,key:(ae)=>ae.provider,value:X,limit:vT,colors:Y}).map((ae)=>({...ae,values:ae.values.map((H)=>H||null)}));return{colors:Y,buckets:ce,totals:J,burn:{tokens:te((X)=>X.totalTokens),cost:te((X)=>X.cost),requests:te((X)=>X.requests)},spark:{tokens:Sa(j,ce,(X)=>X.totalTokens),cost:Sa(j,ce,(X)=>X.cost),requests:Sa(j,ce,(X)=>X.requests)},topProvider:P.reduce((X,ae)=>X===null||ae.totalTokens>X.totalTokens?ae:X,null)}},[c.data,i]),D=k.burn[f],M=f==="cost"?(P)=>da(P):Ae,B=k.totals;return ee.jsxDEV("div",{className:"page",children:[ee.jsxDEV(ra,{title:u("common.providers"),description:u("providers.description",{window:u(x.windowKey)})},void 0,!1,void 0,this),ee.jsxDEV(Ge,{query:c,skeleton:ee.jsxDEV(zt,{height:112},void 0,!1,void 0,this),children:({providers:P})=>ee.jsxDEV("div",{"data-stale":c.stale,children:ee.jsxDEV(la,{min:190,children:[ee.jsxDEV(ie,{label:u("common.providers"),value:z(P.length),hint:k.topProvider?u("providers.most-tokens",{provider:k.topProvider.provider}):void 0},void 0,!1,void 0,this),ee.jsxDEV(ie,{label:u("common.requests"),value:z(B.requests),hint:u("providers.failed-n",{count:z(B.failed)}),spark:k.spark.requests},void 0,!1,void 0,this),ee.jsxDEV(ie,{label:u("common.tokens"),title:u("providers.tokens-title"),value:Ae(B.tokens),spark:k.spark.tokens},void 0,!1,void 0,this),ee.jsxDEV(ie,{label:u("providers.api-equivalent-cost"),title:u("providers.api-cost-title"),value:Ht(B.cost,B.unpriced),hint:B.unpriced>0?u("providers.unpriced-n",{count:z(B.unpriced)}):void 0,spark:k.spark.cost,sparkColor:"var(--chart-secondary)"},void 0,!1,void 0,this),ee.jsxDEV(ie,{label:u("common.error-rate"),value:to(B.requests>0?B.failed/B.requests:0),hint:u("providers.succeeded-n",{count:z(B.requests-B.failed)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),ee.jsxDEV(Ye,{index:1,title:u("providers.totals"),description:B.unpriced>0?u(B.unpriced===1?"providers.totals-description-unpriced-one":"providers.totals-description-unpriced-n",{count:z(B.unpriced)}):u("providers.totals-description"),flush:!0,stale:c.stale,children:ee.jsxDEV(Ge,{query:c,skeleton:ee.jsxDEV(ca,{rows:6},void 0,!1,void 0,this),children:({providers:P})=>ee.jsxDEV(TD,{providers:P,colors:k.colors},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),ee.jsxDEV("div",{className:"grid grid-main-side",children:[ee.jsxDEV(Ye,{index:2,title:u("providers.burn"),description:f==="cost"&&B.unpriced>0?u("providers.burn-estimate-description",{bucket:x.bucketMs<86400000?u("providers.bucket-hour"):u("providers.bucket-day")}):u("providers.burn-description",{bucket:x.bucketMs<3600000?u("providers.bucket-5m"):x.bucketMs<86400000?u("providers.bucket-hour"):u("providers.bucket-day"),count:vT}),actions:ee.jsxDEV(_a,{size:"sm",options:wD,value:f,onChange:p},void 0,!1,void 0,this),stale:c.stale,children:ee.jsxDEV(Ge,{query:c,skeleton:ee.jsxDEV(zt,{height:260},void 0,!1,void 0,this),children:()=>ee.jsxDEV("div",{className:"stack",style:{gap:12},children:[ee.jsxDEV(Xr,{buckets:k.buckets,bucketMs:x.bucketMs,series:D,hidden:S,height:260,format:M,formatTooltip:f==="cost"?(P)=>da(P):z,emptyLabel:u("providers.no-provider-activity")},void 0,!1,void 0,this),ee.jsxDEV(Ka,{items:D.map((P)=>({key:P.key,label:P.label,color:P.color,value:M(P.values.reduce((j,Y)=>j+(Y??0),0))})),hidden:S,onToggle:h},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),ee.jsxDEV(Ge,{query:c,skeleton:ee.jsxDEV(zt,{height:320},void 0,!1,void 0,this),children:({hourly:P,providers:j})=>ee.jsxDEV(RD,{hourly:P,providers:j,stale:c.stale},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ee.jsxDEV(Ye,{index:4,title:u("providers.subscription-windows"),description:u("providers.subscription-windows-description"),flush:!0,stale:b.stale,children:ee.jsxDEV(Ge,{query:b,skeleton:ee.jsxDEV(ca,{rows:6},void 0,!1,void 0,this),children:(P)=>ee.jsxDEV(AD,{insights:P.windowInsights,selected:C,onSelect:g},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),ee.jsxDEV(qD,{insights:b.data?.windowInsights??null,accounts:A,selected:C,onSelect:g},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function kD(l,i){if(i&&l.some((f)=>f.provider===i.provider&&f.windowKey===i.windowKey))return i;let c=i&&l.find((f)=>f.provider===i.provider)||l.reduce((f,p)=>f===void 0||p.fractionConsumed>f.fractionConsumed?p:f,void 0);return c?{provider:c.provider,windowKey:c.windowKey}:null}function TD({providers:l,colors:i}){let[c,f]=po.useState(null),p=po.useMemo(()=>{let S=0,h=0,x=0;for(let b of l)S=Math.max(S,b.totalRequests),h=Math.max(h,b.totalTokens),x+=b.totalTokens;return[{key:"provider",header:u("common.provider"),sort:(b)=>b.provider,render:(b)=>ee.jsxDEV("span",{className:"row",style:{gap:8},children:[ee.jsxDEV(Cn,{color:i.get(b.provider)??ao},void 0,!1,void 0,this),ee.jsxDEV("span",{className:"mono cell-primary",children:b.provider},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},{key:"requests",header:u("common.requests"),align:"right",sort:(b)=>b.totalRequests,render:(b)=>ee.jsxDEV(pa,{value:b.totalRequests,max:S,display:z(b.totalRequests)},void 0,!1,void 0,this)},{key:"errors",header:u("common.error-rate"),align:"right",sort:(b)=>b.totalRequests>0?b.failedRequests/b.totalRequests:0,render:(b)=>{let L=b.totalRequests>0?b.failedRequests/b.totalRequests:0;return ee.jsxDEV("span",{className:"row",style:{gap:8,justifyContent:"flex-end"},children:[ee.jsxDEV("span",{className:"num dim",children:z(b.failedRequests)},void 0,!1,void 0,this),ee.jsxDEV(Bt,{tone:b.failedRequests>0?ir(L):"neutral",mono:!0,children:to(L)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}},{key:"models",header:u("common.models"),title:u("providers.models-title"),align:"right",sort:(b)=>b.models,render:(b)=>ee.jsxDEV("span",{className:"num",children:z(b.models)},void 0,!1,void 0,this)},{key:"tokens",header:u("common.tokens"),title:u("providers.tokens-title"),align:"right",sort:(b)=>b.totalTokens,render:(b)=>ee.jsxDEV(pa,{value:b.totalTokens,max:h,display:Ae(b.totalTokens),color:i.get(b.provider)},void 0,!1,void 0,this)},{key:"share",header:u("common.share"),title:u("providers.share-title"),align:"right",sort:(b)=>b.totalTokens,render:(b)=>ee.jsxDEV("span",{className:"num muted",children:Fe(x>0?b.totalTokens/x:0)},void 0,!1,void 0,this)},{key:"cost",header:u("common.cost"),title:u("providers.cost-title"),align:"right",sort:(b)=>b.totalCost,render:(b)=>ee.jsxDEV("span",{className:"num",title:b.unpricedRequests>0?u("providers.unpriced-n",{count:z(b.unpricedRequests)}):void 0,children:Ht(b.totalCost,b.unpricedRequests)},void 0,!1,void 0,this)},{key:"tps",header:u("common.tokens-per-second"),title:u("providers.tps-title"),align:"right",sort:(b)=>b.avgTokensPerSecond??-1,render:(b)=>ee.jsxDEV("span",{className:"num",children:dr(b.avgTokensPerSecond)},void 0,!1,void 0,this)},{key:"premium",header:u("common.premium"),title:u("providers.premium-title"),align:"right",sort:(b)=>b.totalPremiumRequests,render:(b)=>ee.jsxDEV("span",{className:b.totalPremiumRequests>0?"num":"num dim",children:z(Math.round(b.totalPremiumRequests*100)/100)},void 0,!1,void 0,this)}]},[l,i]);return ee.jsxDEV(Xt,{rows:l,rowKey:(S)=>S.provider,columns:p,initialSort:{key:"tokens",dir:"desc"},limit:12,selectedKey:c,onRowClick:(S)=>f((h)=>h===S.provider?null:S.provider),expanded:(S)=>S.provider===c?ee.jsxDEV(ID,{provider:S},void 0,!1,void 0,this):null,empty:ee.jsxDEV(wt,{title:u("providers.no-requests-in-range")},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function ID({provider:l}){let i={input:l.totalInputTokens,cacheRead:l.totalCacheReadTokens,cacheWrite:l.totalCacheWriteTokens,output:l.totalOutputTokens};return ee.jsxDEV("div",{className:"providers-mix",children:[ee.jsxDEV($l,{segments:bT.map((c)=>({key:c.key,label:c.label,value:i[c.key],color:c.color}))},void 0,!1,void 0,this),ee.jsxDEV(Ka,{items:bT.map((c)=>({key:c.key,label:c.label,color:c.color,value:`${Ae(i[c.key])} · ${l.totalTokens>0?Fe(i[c.key]/l.totalTokens,0):"–"}`}))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var Gd="";function RD({hourly:l,providers:i,stale:c}){let[f,p]=po.useState(Gd),S=f===Gd||i.some((b)=>b.provider===f)?f:Gd,h=po.useMemo(()=>{let b=Array.from({length:24},()=>0),L=Array.from({length:24},()=>0),g=Array.from({length:24},()=>0);for(let k of l){if(S!==Gd&&k.provider!==S)continue;b[k.hour]+=k.totalTokens,L[k.hour]+=k.outputTokens,g[k.hour]+=k.requests}let C=0;for(let k=1;k<24;k++)if(b[k]>b[C])C=k;let w=b[C]>0;return{series:[{key:"tokens",label:u("common.tokens"),color:"var(--chart-primary)",values:b.map((k,D)=>w&&D===C?null:k)},{key:"peak",label:u("providers.tokens-peak-hour"),color:"var(--chart-secondary)",values:b.map((k,D)=>w&&D===C?k:null)}],output:L,requests:g,peak:C,hasData:w}},[l,S]),x=(b)=>`${String(b).padStart(2,"0")}:00`;return ee.jsxDEV(Ye,{index:3,title:u("providers.peak-burn-hours"),description:h.hasData?u("providers.peak-hours-description",{hour:x(h.peak)}):u("providers.hours-description"),actions:ee.jsxDEV("select",{className:"input providers-select",value:S,onChange:(b)=>p(b.target.value),"aria-label":u("common.provider"),children:[ee.jsxDEV("option",{value:Gd,children:u("providers.all-providers")},void 0,!1,void 0,this),i.map((b)=>ee.jsxDEV("option",{value:b.provider,children:b.provider},b.provider,!1,void 0,this))]},void 0,!0,void 0,this),stale:c,children:ee.jsxDEV(Tn,{slots:24,tickLabel:(b)=>String(b).padStart(2,"0"),tooltipTitle:(b)=>`${x(b)}–${x((b+1)%24)}`,series:h.series,height:260,showTotal:!1,formatTooltip:z,emptyLabel:u("providers.no-activity-in-range"),tooltipExtra:(b)=>ee.jsxDEV(ee.Fragment,{children:[ee.jsxDEV("div",{className:"chart-tooltip-row",children:[ee.jsxDEV("span",{className:"chart-tooltip-label",children:u("common.output")},void 0,!1,void 0,this),ee.jsxDEV("span",{className:"chart-tooltip-value",children:z(h.output[b])},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ee.jsxDEV("div",{className:"chart-tooltip-row",children:[ee.jsxDEV("span",{className:"chart-tooltip-label",children:u("common.requests")},void 0,!1,void 0,this),ee.jsxDEV("span",{className:"chart-tooltip-value",children:z(h.requests[b])},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function AD({insights:l,selected:i,onSelect:c}){return ee.jsxDEV(Xt,{rows:l,rowKey:(f)=>`${f.provider}::${f.windowKey}`,columns:MD,initialSort:{key:"consumed",dir:"desc"},limit:12,selectedKey:i?`${i.provider}::${i.windowKey}`:null,onRowClick:(f)=>c({provider:f.provider,windowKey:f.windowKey}),empty:ee.jsxDEV(wt,{title:u("providers.no-snapshots-in-range"),hint:xT},void 0,!1,void 0,this)},void 0,!1,void 0,this)}var MD=[{key:"window",header:u("providers.window"),sort:(l)=>`${l.provider} ${l.windowKey}`,render:(l)=>ee.jsxDEV(Ha,{primary:l.windowKey,secondary:ee.jsxDEV("span",{className:"mono",children:l.provider},void 0,!1,void 0,this)},void 0,!1,void 0,this)},{key:"accounts",header:u("providers.accounts"),title:u("providers.accounts-title"),align:"right",sort:(l)=>l.accounts,render:(l)=>ee.jsxDEV("span",{className:"num",children:z(l.accounts)},void 0,!1,void 0,this)},{key:"cycles",header:u("providers.resets"),title:u("providers.resets-title"),align:"right",sort:(l)=>l.cycles,render:(l)=>ee.jsxDEV("span",{className:"num muted",children:z(l.cycles)},void 0,!1,void 0,this)},{key:"consumed",header:u("providers.windows-burned"),title:u("providers.windows-burned-title"),align:"right",sort:(l)=>l.fractionConsumed,render:(l)=>ee.jsxDEV("span",{className:"num",children:l.fractionConsumed.toFixed(2)},void 0,!1,void 0,this)},{key:"capacity",header:u("providers.tokens-per-window"),title:u("providers.tokens-per-window-title"),align:"right",sort:(l)=>l.estTokensPerWindow??-1,render:(l)=>l.estTokensPerWindow!==null?ee.jsxDEV("span",{className:"num",children:Ae(l.estTokensPerWindow)},void 0,!1,void 0,this):ee.jsxDEV("span",{className:"dim",title:u("providers.too-little-consumed"),children:"–"},void 0,!1,void 0,this)},{key:"peak",header:u("providers.peak-utilization"),title:u("providers.peak-utilization-title"),align:"right",sort:(l)=>l.peakConcurrentFraction,render:(l)=>{let i=l.accounts>0?l.peakConcurrentFraction/l.accounts:0;return ee.jsxDEV(pa,{value:l.peakConcurrentFraction,max:l.accounts,display:Fe(l.peakConcurrentFraction,0),color:i>=0.9?"var(--warn)":void 0},void 0,!1,void 0,this)}},{key:"ideal",header:u("providers.accounts-needed"),title:u("providers.accounts-needed-title"),align:"right",sort:(l)=>l.idealAccounts-l.accounts,render:(l)=>l.idealAccounts>l.accounts?ee.jsxDEV(Bt,{tone:"warn",mono:!0,children:u("providers.ideal-accounts",{ideal:z(l.idealAccounts),have:z(l.accounts)})},void 0,!1,void 0,this):ee.jsxDEV("span",{className:"num",children:z(l.idealAccounts)},void 0,!1,void 0,this)},{key:"exhausted",header:u("providers.exhaustions"),title:u("providers.exhaustions-title"),align:"right",sort:(l)=>l.exhaustedEvents,render:(l)=>l.exhaustedEvents>0?ee.jsxDEV(Bt,{tone:"warn",mono:!0,children:u("providers.exhausted-n",{count:z(l.exhaustedEvents)})},void 0,!1,void 0,this):ee.jsxDEV("span",{className:"num dim",children:"0"},void 0,!1,void 0,this)}],Ym=60000,Qr=60*Ym,$m=24*Qr,DD=[5*Ym,15*Ym,30*Ym,Qr,2*Qr,3*Qr,6*Qr,12*Qr,$m],ED=240,OD=6*Qr;function qD({insights:l,accounts:i,selected:c,onSelect:f}){let[p,S]=sn(),h=po.useMemo(()=>[...new Set((l??[]).map((k)=>k.provider))],[l]),x=po.useMemo(()=>(l??[]).filter((k)=>k.provider===c?.provider).map((k)=>({key:k.windowKey,label:k.windowKey})),[l,c?.provider]),b=po.useMemo(()=>(i.data?.usageSeries??[]).filter((k)=>k.provider===c?.provider),[i.data,c?.provider]),L=b.length===0&&(i.loading||i.stale),g=po.useMemo(()=>{let k=new Map;for(let M of b){let B=k.get(M.accountLabel)??[];if(!B.includes(M.accountKey))B.push(M.accountKey);k.set(M.accountLabel,B)}let D=new Map;for(let[M,B]of k)B.sort(),B.forEach((P,j)=>D.set(P,B.length>1?`${M} #${j+1}`:M));return D},[b]),C=po.useMemo(()=>ND(b.filter((k)=>k.windowKey===c?.windowKey),g),[b,g,c?.windowKey]),w=po.useMemo(()=>{let k=new Map(C.series.map((D)=>[D.key,D.color]));return b.map((D)=>{let M=null,B=null;for(let Y of D.points){if(Y.usedFraction===null)continue;if(B=Math.max(B??0,Y.usedFraction),!M||Y.timestamp>=M.timestamp)M={fraction:Y.usedFraction,exhausted:Y.exhausted,timestamp:Y.timestamp}}let P=D.windowKey===c?.windowKey?k.get(D.accountKey)??null:null,j=g.get(D.accountKey)??D.accountLabel;return{series:D,name:j,color:P,latest:M,peak:B,samples:D.points.length}}).sort((D,M)=>Number(M.color!==null)-Number(D.color!==null)||D.series.windowKey.localeCompare(M.series.windowKey)||(M.latest?.fraction??-1)-(D.latest?.fraction??-1))},[b,g,C.series,c?.windowKey]),A=x.find((k)=>k.key===c?.windowKey)?.label;return ee.jsxDEV(Ye,{index:5,title:u("providers.utilization"),description:C.buckets.length>0?u("providers.utilization-description",{window:A??u("providers.window"),from:jv(C.first),to:jv(C.last)}):u("providers.utilization-description-plain"),actions:c&&ee.jsxDEV("div",{className:"row",style:{gap:6},children:[ee.jsxDEV("select",{className:"input providers-select",value:c.provider,onChange:(k)=>{let D=k.target.value,M=l?.find((B)=>B.provider===D);if(M)f({provider:D,windowKey:M.windowKey})},"aria-label":u("common.provider"),children:h.map((k)=>ee.jsxDEV("option",{value:k,children:k},k,!1,void 0,this))},void 0,!1,void 0,this),ee.jsxDEV("select",{className:"input providers-select",value:c.windowKey,onChange:(k)=>f({provider:c.provider,windowKey:k.target.value}),"aria-label":u("providers.window"),children:x.map((k)=>ee.jsxDEV("option",{value:k.key,children:k.label},k.key,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),stale:i.stale,children:l===null?ee.jsxDEV(zt,{height:260},void 0,!1,void 0,this):c===null?ee.jsxDEV(wt,{title:u("providers.no-snapshots-in-range"),hint:xT},void 0,!1,void 0,this):ee.jsxDEV(Ge,{query:i,skeleton:ee.jsxDEV(zt,{height:260},void 0,!1,void 0,this),children:()=>L?ee.jsxDEV(zt,{height:260},void 0,!1,void 0,this):ee.jsxDEV("div",{className:"stack",style:{gap:16},children:[ee.jsxDEV("div",{className:"stack",style:{gap:12},children:[ee.jsxDEV(Tn,{slots:C.buckets.length,tickLabel:(k)=>Am(C.buckets[k],C.last-C.first>$m?$m:C.bucketMs),tooltipTitle:(k)=>Rm(C.buckets[k],Qr),series:C.series,hidden:p,kind:"line",stacked:!1,height:260,yMax:Math.max(1,C.max),format:(k)=>Fe(k,0),formatTooltip:(k)=>Fe(k,1),references:[{value:1,label:"100%"}],emptyLabel:u("providers.no-utilization-readings"),tooltipExtra:(k)=>{let D=C.exhausted[k];return D.length>0?ee.jsxDEV("div",{className:"chart-tooltip-row",children:[ee.jsxDEV("span",{className:"chart-tooltip-label tone-bad",children:u("providers.exhausted")},void 0,!1,void 0,this),ee.jsxDEV("span",{className:"chart-tooltip-value",children:D.join(", ")},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null}},void 0,!1,void 0,this),C.series.length>1&&ee.jsxDEV(Ka,{items:C.series.map((k)=>({key:k.key,label:k.label,color:k.color})),hidden:p,onToggle:S},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ee.jsxDEV("div",{className:"providers-accounts",children:ee.jsxDEV(Xt,{rows:w,rowKey:(k)=>`${k.series.windowKey}::${k.series.accountKey}`,columns:zD,limit:16,onRowClick:(k)=>f({provider:k.series.provider,windowKey:k.series.windowKey}),dense:!0},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function ND(l,i){let{POSITIVE_INFINITY:c,NEGATIVE_INFINITY:f}=Number;for(let A of l)for(let k of A.points){if(k.timestamp<c)c=k.timestamp;if(k.timestamp>f)f=k.timestamp}if(!(f>=c))return{buckets:[],bucketMs:Qr,first:0,last:0,max:0,series:[],exhausted:[]};let p=f-c,S=DD.find((A)=>p/A<ED)??$m,h=_o("all",[c],S,f),x=(A)=>Math.floor((A-h[0])/S),b=h.map(()=>[]),L=0,g=(A)=>i.get(A.accountKey)??A.accountLabel,w=[...l].sort((A,k)=>g(A).localeCompare(g(k))).map((A,k)=>{let D=h.map(()=>null),M=h.map(()=>0);for(let j of A.points){let Y=x(j.timestamp);if(Y<0||Y>=h.length)continue;if(j.exhausted&&!b[Y].includes(g(A)))b[Y].push(g(A));if(j.usedFraction===null||j.timestamp<M[Y])continue;D[Y]=j.usedFraction,M[Y]=j.timestamp,L=Math.max(L,j.usedFraction)}let B=null,P=0;for(let j=0;j<h.length;j++)if(D[j]!==null)B=D[j],P=M[j];else if(B!==null&&h[j]-P<=OD)D[j]=B;return{key:A.accountKey,label:g(A),color:Fa[k%Fa.length],values:D}});return{buckets:h,bucketMs:S,first:c,last:f,max:L,series:w,exhausted:b}}function BD(l){if(!l)return ee.jsxDEV("span",{className:"dim",children:u("providers.no-reading")},void 0,!1,void 0,this);if(l.exhausted)return ee.jsxDEV(Bt,{tone:"bad",children:u("providers.exhausted")},void 0,!1,void 0,this);if(l.fraction>=0.8)return ee.jsxDEV(Bt,{tone:"warn",children:u("providers.high")},void 0,!1,void 0,this);return ee.jsxDEV(Bt,{tone:"ok",children:u("ui.status-ok")},void 0,!1,void 0,this)}var zD=[{key:"account",header:u("providers.account"),sort:(l)=>l.name,render:(l)=>ee.jsxDEV("span",{className:"row",style:{gap:8},children:[ee.jsxDEV("span",{className:"providers-swatch-slot",children:l.color&&ee.jsxDEV(Cn,{color:l.color},void 0,!1,void 0,this)},void 0,!1,void 0,this),ee.jsxDEV("span",{className:"truncate providers-account",title:l.series.accountKey,children:l.name},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},{key:"window",header:u("providers.window"),sort:(l)=>l.series.windowKey,render:(l)=>ee.jsxDEV("span",{className:l.color?void 0:"muted",children:l.series.windowKey},void 0,!1,void 0,this)},{key:"latest",header:u("providers.latest-used"),align:"right",sort:(l)=>l.latest?.fraction??-1,render:(l)=>l.latest?ee.jsxDEV(pa,{value:l.latest.fraction,max:1,display:Fe(l.latest.fraction,0),color:l.latest.exhausted?"var(--bad)":l.latest.fraction>=0.8?"var(--warn)":"var(--ok)"},void 0,!1,void 0,this):ee.jsxDEV("span",{className:"dim",children:"–"},void 0,!1,void 0,this)},{key:"status",header:u("providers.status"),sort:(l)=>l.latest?.exhausted?2:(l.latest?.fraction??0)>=0.8?1:0,render:(l)=>BD(l.latest)},{key:"peak",header:u("providers.peak-in-range"),align:"right",sort:(l)=>l.peak??-1,render:(l)=>ee.jsxDEV("span",{className:"num",children:l.peak===null?"–":Fe(l.peak,0)},void 0,!1,void 0,this)},{key:"samples",header:u("providers.snapshots"),align:"right",sort:(l)=>l.samples,render:(l)=>ee.jsxDEV("span",{className:"num muted",children:z(l.samples)},void 0,!1,void 0,this)},{key:"recorded",header:u("providers.recorded"),align:"right",sort:(l)=>l.latest?.timestamp??0,render:(l)=>ee.jsxDEV("span",{className:"muted",children:l.latest?fa(l.latest.timestamp):"–"},void 0,!1,void 0,this)}];var tu=Z(gt(),1);var ot=Z(ue(),1),Qm={ok:{label:u("ui.status-ok"),tone:"ok"},aborted:{label:u("common.aborted"),tone:"warn"},failed:{label:u("common.failed"),tone:"bad"}};function LT({id:l,onClose:i}){let c=Ft(["request",l],({signal:S})=>n1(l??0,S),{enabled:l!==null}),f=c.stale?null:c.data,p=f?Qm[Yr(f)]:null;return ot.jsxDEV(qm,{open:l!==null,onClose:i,width:620,title:f?ot.jsxDEV("span",{className:"mono",children:f.model},void 0,!1,void 0,this):u("common.request"),subtitle:f?ot.jsxDEV(ot.Fragment,{children:[f.provider," ·"," ",ot.jsxDEV("span",{title:ln(f.timestamp),children:fa(f.timestamp)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):l!==null?ot.jsxDEV("span",{className:"mono",children:["#",l]},void 0,!0,void 0,this):void 0,actions:f&&p?ot.jsxDEV("div",{className:"row",style:{gap:6},children:[ot.jsxDEV("a",{className:"btn","data-size":"sm","data-variant":"ghost",href:Fm({...Od(window.location.hash),section:"traces",session:f.sessionFile}),onClick:i,title:u("ui.open-trace"),children:[ot.jsxDEV(vd,{size:13},void 0,!1,void 0,this)," Trace"]},void 0,!0,void 0,this),ot.jsxDEV(Bt,{tone:p.tone,children:p.label},void 0,!1,void 0,this)]},void 0,!0,void 0,this):void 0,children:f?ot.jsxDEV(UD,{details:f,aborted:Yr(f)==="aborted"},void 0,!1,void 0,this):c.error?ot.jsxDEV(gi,{error:c.error,onRetry:c.refetch},void 0,!1,void 0,this):ot.jsxDEV("div",{className:"stack",style:{gap:12},children:[ot.jsxDEV(qa,{height:56},void 0,!1,void 0,this),ot.jsxDEV(qa,{height:120},void 0,!1,void 0,this),ot.jsxDEV(qa,{height:120},void 0,!1,void 0,this),ot.jsxDEV(qa,{height:220},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function UD({details:l,aborted:i}){let{usage:c}=l,f=l.duration!==null&&l.duration>0&&c.output>0?c.output*1000/l.duration:null,{messages:p,output:S,...h}=l;return ot.jsxDEV(ot.Fragment,{children:[l.errorMessage&&ot.jsxDEV("section",{className:"request-drawer-error","data-tone":i?"warn":"bad",role:"note",children:[ot.jsxDEV("div",{className:"request-drawer-error-label",children:i?u("common.aborted"):u("common.error")},void 0,!1,void 0,this),ot.jsxDEV("pre",{className:"request-drawer-error-text",children:l.errorMessage},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ot.jsxDEV("section",{children:[ot.jsxDEV("div",{className:"section-label",children:u("ui.section-timing")},void 0,!1,void 0,this),ot.jsxDEV(Ho,{items:[{key:"at",label:u("common.started"),value:ln(l.timestamp)},{key:"duration",label:u("common.duration"),value:At(l.duration)},{key:"ttft",label:u("ui.time-to-first-token"),value:At(l.ttft)},{key:"tps",label:u("common.output-tokens-per-second"),value:dr(f)}]},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ot.jsxDEV("section",{children:[ot.jsxDEV("div",{className:"section-label",children:u("common.tokens")},void 0,!1,void 0,this),ot.jsxDEV(Ho,{items:[{key:"input",label:u("ui.uncached-input"),value:z(c.input)},{key:"cacheRead",label:u("common.cache-read"),value:z(c.cacheRead)},{key:"cacheWrite",label:u("common.cache-write"),value:z(c.cacheWrite)},{key:"output",label:u("common.output"),value:z(c.output)},{key:"total",label:u("common.total"),value:z(c.totalTokens)},{key:"premium",label:u("common.premium-requests"),value:z(Math.round((c.premiumRequests??0)*100)/100)}]},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ot.jsxDEV("section",{children:[ot.jsxDEV("div",{className:"section-label",children:u("ui.section-cost")},void 0,!1,void 0,this),ot.jsxDEV(Ho,{items:[{key:"total",label:"Total",value:Yl(l,4)},{key:"input",label:u("common.input"),value:da(c.cost.input,4)},{key:"cacheRead",label:"Cache read",value:da(c.cost.cacheRead,4)},{key:"cacheWrite",label:"Cache write",value:da(c.cost.cacheWrite,4)},{key:"output",label:"Output",value:da(c.cost.output,4)}]},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ot.jsxDEV("section",{children:[ot.jsxDEV("div",{className:"section-label",children:u("ui.section-identity")},void 0,!1,void 0,this),ot.jsxDEV(Ho,{items:[{key:"id",label:u("common.request-id"),value:l.id??"–"},{key:"entry",label:u("common.entry-id"),value:l.entryId},{key:"stop",label:u("ui.stop-reason"),value:l.stopReason},{key:"api",label:"API",value:l.api},{key:"project",label:u("common.project"),value:ot.jsxDEV("span",{title:l.folder,children:fr(l.folder)},void 0,!1,void 0,this)}]},void 0,!1,void 0,this),ot.jsxDEV("div",{className:"request-drawer-file",children:[ot.jsxDEV("span",{className:"kv-key",children:u("ui.session-file")},void 0,!1,void 0,this),ot.jsxDEV("span",{className:"kv-value",children:l.sessionFile},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),S!=null&&ot.jsxDEV(di,{data:S,title:u("common.output-message")},void 0,!1,void 0,this),ot.jsxDEV(di,{data:p,title:u("common.session-entry"),initialCollapsed:!0},void 0,!1,void 0,this),ot.jsxDEV(di,{data:h,title:u("ui.stats-row"),initialCollapsed:!0},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var We=Z(ue(),1),rb=[500,2000,1e4];function CT({active:l,range:i,onRequestClick:c}){let[f,p]=tu.useState(0),S=rb[f],h=Ft(["requests-log",S],({signal:Y})=>Mm(S,Y),{enabled:l}),[x,b]=tu.useState(""),[L,g]=tu.useState("all"),C=ia(i),w=tu.useMemo(()=>{let Y=h.data??[],ce=C.spanMs===null?null:Date.now()-C.spanMs,J=ce===null?Y:Y.filter((ae)=>ae.timestamp>=ce),te=!h.stale&&(Y.length<S||ce!==null&&J.length<Y.length),X={all:J.length,ok:0,aborted:0,failed:0};for(let ae of J)X[Yr(ae)]++;return{loaded:Y.length,inRange:J,complete:te,counts:X,summary:tT(J)}},[h.data,h.stale,S,C.spanMs]),A=tu.useMemo(()=>{let Y=x.trim().toLowerCase();return w.inRange.filter((ce)=>(L==="all"||Yr(ce)===L)&&(Y===""||ce.model.toLowerCase().includes(Y)||ce.provider.toLowerCase().includes(Y)||ce.folder.toLowerCase().includes(Y)))},[w.inRange,x,L]),{summary:k,counts:D,complete:M}=w,B=f+1<rb.length?rb[f+1]:null,P=B!==null?We.jsxDEV("button",{type:"button",className:"btn","data-size":"sm",disabled:h.refreshing,onClick:()=>p(f+1),children:h.refreshing&&h.stale?u("requests.loading"):u("requests.load-latest",{count:z(B)})},void 0,!1,void 0,this):void 0,j=["all","ok","aborted","failed"].map((Y)=>({value:Y,label:We.jsxDEV(We.Fragment,{children:[Y==="all"?u("requests.status-all"):Qm[Y].label," ",We.jsxDEV("span",{className:"dim num",children:Ae(D[Y])},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}));return We.jsxDEV("div",{className:"page",children:[We.jsxDEV(ra,{title:u("common.requests"),description:u("requests.description",{window:u(C.windowKey)})},void 0,!1,void 0,this),We.jsxDEV(Ge,{query:h,skeleton:We.jsxDEV(qa,{height:96,style:{borderRadius:12}},void 0,!1,void 0,this),children:()=>We.jsxDEV("div",{"data-stale":h.stale,children:We.jsxDEV(la,{min:160,children:[We.jsxDEV(ie,{label:u("common.requests"),value:z(k.requests),hint:k.oldest===null?u("requests.none-in-window",{window:u(C.windowKey)}):u("requests.since",{time:fa(k.oldest)})},void 0,!1,void 0,this),We.jsxDEV(ie,{label:u("common.failed"),value:z(k.failed),hint:u("requests.failed-hint",{rate:k.requests>0?to(k.failed/k.requests):"–",count:z(k.aborted)})},void 0,!1,void 0,this),We.jsxDEV(ie,{label:u("common.tokens"),title:u("requests.tokens-hint"),value:Ae(k.tokens)},void 0,!1,void 0,this),We.jsxDEV(ie,{label:u("requests.api-equivalent-cost"),title:u("requests.cost-hint"),value:Ht(k.cost,k.unpriced),hint:k.unpriced>0?u("requests.unpriced-n",{count:z(k.unpriced)}):void 0},void 0,!1,void 0,this),We.jsxDEV(ie,{label:u("requests.median-duration"),value:At(k.medianDuration),hint:u("requests.p95",{value:At(k.p95Duration)})},void 0,!1,void 0,this),We.jsxDEV(ie,{label:u("requests.median-ttft"),title:u("requests.ttft-hint"),value:At(k.medianTtft)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),We.jsxDEV(Ye,{index:1,title:u("requests.log-title"),description:h.data===null?u("requests.log-loading"):M?u("requests.log-count-in-window",{shown:z(A.length),total:z(k.requests),window:u(C.windowKey)}):u("requests.log-count-latest",{shown:z(A.length),total:z(k.requests)}),actions:We.jsxDEV(We.Fragment,{children:[We.jsxDEV(cr,{value:x,onChange:b,placeholder:u("requests.search-placeholder")},void 0,!1,void 0,this),We.jsxDEV(_a,{size:"sm","aria-label":u("requests.status"),options:j,value:L,onChange:g},void 0,!1,void 0,this)]},void 0,!0,void 0,this),flush:!0,stale:h.stale,footer:h.data!==null&&!M?We.jsxDEV(We.Fragment,{children:[We.jsxDEV("span",{children:u("requests.footer",{count:z(w.loaded),time:k.oldest===null?"–":ln(k.oldest),window:u(C.windowKey)})},void 0,!1,void 0,this),P]},void 0,!0,void 0,this):void 0,children:We.jsxDEV(Ge,{query:h,skeleton:We.jsxDEV(ca,{rows:12},void 0,!1,void 0,this),children:()=>We.jsxDEV(Xt,{rows:A,rowKey:(Y)=>Y.id??`${Y.sessionFile}:${Y.entryId}`,onRowClick:(Y)=>Y.id!==void 0&&c(Y.id),columns:PD,initialSort:{key:"time",dir:"desc"},limit:100,dense:!0,empty:We.jsxDEV(wt,{title:k.requests===0?u("requests.empty-in-window",{window:u(C.windowKey)}):u("requests.empty-no-match"),hint:k.requests===0?void 0:u("requests.empty-no-match-hint")},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var PD=[{key:"model",header:u("common.model"),sort:(l)=>l.model,render:(l)=>We.jsxDEV(Ha,{primary:We.jsxDEV("span",{className:"mono",children:l.model},void 0,!1,void 0,this),secondary:l.provider},void 0,!1,void 0,this)},{key:"time",header:u("requests.when"),sort:(l)=>l.timestamp,render:(l)=>We.jsxDEV("span",{className:"muted",title:ln(l.timestamp),children:fa(l.timestamp)},void 0,!1,void 0,this)},{key:"project",header:u("common.project"),sort:(l)=>l.folder,render:(l)=>We.jsxDEV("span",{className:"mono muted truncate",title:l.folder,style:{display:"block",maxWidth:180},children:fr(l.folder)},void 0,!1,void 0,this)},{key:"input",header:u("common.input"),title:u("requests.uncached-input"),align:"right",sort:(l)=>l.usage.input,render:(l)=>We.jsxDEV("span",{className:"num",children:Ae(l.usage.input)},void 0,!1,void 0,this)},{key:"cache",header:u("common.cache-read"),title:u("requests.cache-read-title"),align:"right",sort:(l)=>l.usage.cacheRead,render:(l)=>We.jsxDEV("span",{className:"num",title:u("requests.cache-write",{count:z(l.usage.cacheWrite)}),children:Ae(l.usage.cacheRead)},void 0,!1,void 0,this)},{key:"output",header:u("common.output"),align:"right",sort:(l)=>l.usage.output,render:(l)=>We.jsxDEV("span",{className:"num",children:Ae(l.usage.output)},void 0,!1,void 0,this)},{key:"cost",header:u("common.cost"),title:u("requests.cost-estimate"),align:"right",sort:(l)=>l.usage.cost.total,render:(l)=>We.jsxDEV("span",{className:"num",children:Yl(l,4)},void 0,!1,void 0,this)},{key:"duration",header:u("common.duration"),align:"right",sort:(l)=>l.duration??-1,render:(l)=>We.jsxDEV("span",{className:"num",children:At(l.duration)},void 0,!1,void 0,this)},{key:"ttft",header:u("requests.ttft"),title:u("requests.ttft-hint"),align:"right",sort:(l)=>l.ttft??-1,render:(l)=>We.jsxDEV("span",{className:"num muted",children:At(l.ttft)},void 0,!1,void 0,this)},{key:"status",header:u("requests.status"),sort:(l)=>Yr(l),render:(l)=>{let i=Qm[Yr(l)];return We.jsxDEV("span",{title:l.errorMessage??void 0,children:We.jsxDEV(Ha,{lead:We.jsxDEV(ur,{tone:i.tone},void 0,!1,void 0,this),primary:i.label,secondary:We.jsxDEV("span",{className:"mono",children:l.stopReason},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}}];var ou=Z(gt(),1);var ge=Z(ue(),1),_D=[{value:"calls",label:u("tools.calls")},{value:"errors",label:u("tools.errors")}],wT=6,au=u("tools.attribution-note");function HD(l){if(l<3600000)return u("tools.bucket-5m");if(l<86400000)return u("tools.bucket-hour");return u("tools.bucket-day")}var lb=ge.jsxDEV(wt,{title:u("tools.no-tool-calls")},void 0,!1,void 0,this);function kT({active:l,range:i}){let c=Ft(["tools",i],({signal:k})=>f1(i,k),{enabled:l}),[f,p]=ou.useState("calls"),[S,h]=sn(),[x,b]=ou.useState(null),L=ia(i),g=ou.useMemo(()=>FD(c.data,i),[c.data,i]),C=x!==null&&g.toolNames.includes(x)?x:null,w=f==="calls"?g.callSeries:g.errorSeries,A=(k)=>k.byTool.length===0;return ge.jsxDEV("div",{className:"page",children:[ge.jsxDEV(ra,{title:u("tools.title"),description:u("tools.description",{window:u(L.windowKey)})},void 0,!1,void 0,this),ge.jsxDEV(Ge,{query:c,skeleton:ge.jsxDEV(zt,{height:112},void 0,!1,void 0,this),children:()=>{let k=g.totals;return ge.jsxDEV("div",{"data-stale":c.stale,className:"stack",style:{gap:16},children:[ge.jsxDEV(la,{min:190,children:[ge.jsxDEV(ie,{label:u("tools.tool-calls"),value:z(k.calls),hint:u("tools.failed-n",{count:z(k.errors)}),spark:g.totalCalls},void 0,!1,void 0,this),ge.jsxDEV(ie,{label:u("tools.distinct-tools"),value:z(k.tools),hint:g.rows[0]?u("tools.most-used",{tool:g.rows[0].tool}):void 0},void 0,!1,void 0,this),ge.jsxDEV(ie,{label:u("common.error-rate"),title:u("tools.error-rate-title"),value:to(k.calls>0?k.errors/k.calls:0),hint:u("tools.succeeded-n",{count:z(k.calls-k.errors)}),spark:g.totalErrors,sparkColor:"var(--bad)"},void 0,!1,void 0,this),ge.jsxDEV(ie,{label:u("tools.attributed-tokens"),title:au,value:Ae(Math.round(k.tokens)),hint:u("tools.tokens-output",{tokens:Ae(Math.round(k.output))})},void 0,!1,void 0,this),ge.jsxDEV(ie,{label:u("tools.attributed-cost"),title:u("tools.attribution-estimate",{note:au}),value:Ht(k.cost,k.unpriced),hint:k.unpriced>0?u("tools.unpriced-requests-n",{count:z(Math.round(k.unpriced))}):u("tools.api-equivalent")},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ge.jsxDEV(la,{min:150,children:[ge.jsxDEV(ie,{size:"sm",label:u("tools.result-text"),title:u("tools.result-chars-title"),value:u("tools.chars",{count:Ae(k.resultChars)})},void 0,!1,void 0,this),ge.jsxDEV(ie,{size:"sm",label:u("tools.call-arguments"),title:u("tools.args-chars-title"),value:u("tools.chars",{count:Ae(k.argsChars)})},void 0,!1,void 0,this),ge.jsxDEV(ie,{size:"sm",label:u("tools.avg-result-per-call"),value:u("tools.chars",{count:Ae(k.calls>0?Math.round(k.resultChars/k.calls):0)})},void 0,!1,void 0,this),ge.jsxDEV(ie,{size:"sm",label:u("tools.avg-args-per-call"),value:u("tools.chars",{count:Ae(k.calls>0?Math.round(k.argsChars/k.calls):0)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}},void 0,!1,void 0,this),ge.jsxDEV(Ye,{index:1,title:f==="calls"?u("tools.calls-over-time"):u("tools.errors-over-time"),description:u("tools.chart-description",{bucket:HD(L.bucketMs),count:wT}),actions:ge.jsxDEV(_a,{size:"sm",options:_D,value:f,onChange:p},void 0,!1,void 0,this),stale:c.stale,children:ge.jsxDEV(Ge,{query:c,skeleton:ge.jsxDEV(zt,{height:260},void 0,!1,void 0,this),isEmpty:A,empty:lb,children:()=>ge.jsxDEV("div",{className:"stack",style:{gap:12},children:[ge.jsxDEV(Xr,{buckets:g.buckets,bucketMs:L.bucketMs,series:w,hidden:S,height:260,formatTooltip:z,emptyLabel:f==="errors"?u("tools.no-tool-errors"):void 0},void 0,!1,void 0,this),ge.jsxDEV(Ka,{items:w.map((k)=>({key:k.key,label:k.label,color:k.color,value:Ae(k.values.reduce((D,M)=>D+(M??0),0))})),hidden:S,onToggle:h},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),ge.jsxDEV(Ye,{index:2,title:u("tools.by-tool"),description:u("tools.by-tool-description",{note:au}),flush:!0,stale:c.stale,children:ge.jsxDEV(Ge,{query:c,skeleton:ge.jsxDEV(ca,{rows:8},void 0,!1,void 0,this),isEmpty:A,empty:lb,children:()=>ge.jsxDEV(Xt,{rows:g.rows,rowKey:(k)=>k.tool,columns:g.toolColumns,initialSort:{key:"calls",dir:"desc"},limit:20,selectedKey:C,onRowClick:(k)=>b((D)=>D===k.tool?null:k.tool),dense:!0},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),ge.jsxDEV(Ye,{index:3,title:u("tools.by-tool-and-model"),description:u("tools.by-tool-and-model-description"),flush:!0,stale:c.stale,actions:ge.jsxDEV("div",{className:"row",style:{gap:6},children:[ge.jsxDEV("select",{className:"input tools-filter",value:C??"",onChange:(k)=>b(k.target.value||null),"aria-label":u("tools.filter-by-tool"),children:[ge.jsxDEV("option",{value:"",children:u("tools.all-tools")},void 0,!1,void 0,this),g.toolNames.map((k)=>ge.jsxDEV("option",{value:k,children:k},k,!1,void 0,this))]},void 0,!0,void 0,this),C!==null&&ge.jsxDEV("button",{type:"button",className:"btn","data-size":"sm","data-variant":"ghost","data-icon":"true",title:u("tools.clear-tool-filter"),"aria-label":u("tools.clear-tool-filter"),onClick:()=>b(null),children:ge.jsxDEV(nn,{size:13},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),children:ge.jsxDEV(Ge,{query:c,skeleton:ge.jsxDEV(ca,{rows:8},void 0,!1,void 0,this),isEmpty:A,empty:lb,children:(k)=>ge.jsxDEV(VD,{rows:k.byToolModel,tool:C,colors:g.colors},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function FD(l,i){let c=l?.byTool??[],f=l?.series??[],p=eT(c).sort((A,k)=>k.calls-A.calls),S=Nd(c.map((A)=>({key:A.tool,weight:A.calls}))),h=_o(i,f.map((A)=>A.timestamp)),x={calls:0,errors:0,tools:c.length,tokens:0,output:0,cost:0,unpriced:0,resultChars:0,argsChars:0};for(let A of c)x.calls+=A.calls,x.errors+=A.errors,x.tokens+=A.totalTokensShare,x.output+=A.outputTokensShare,x.cost+=A.costShare,x.unpriced+=A.unpricedRequestsShare,x.resultChars+=A.resultChars,x.argsChars+=A.argsChars;let[b,L]=[(A)=>A.calls,(A)=>A.errors].map((A)=>hr(f,{buckets:h,key:(k)=>k.tool,value:A,limit:wT,colors:S}).map((k)=>({...k,values:k.values.map((D)=>D||null)}))),g=new Map(hr(f,{buckets:h,key:(A)=>A.tool,value:(A)=>A.calls}).map((A)=>[A.key,A.values])),C=p[0]?.calls??0,w=GD(C,S,g);return{rows:p,colors:S,buckets:h,totals:x,callSeries:b,errorSeries:L,totalCalls:Sa(f,h,(A)=>A.calls),totalErrors:Sa(f,h,(A)=>A.errors),toolNames:p.map((A)=>A.tool).sort((A,k)=>A.localeCompare(k)),toolColumns:w}}function GD(l,i,c){return[{key:"tool",header:u("tools.tool"),sort:(f)=>f.tool,render:(f)=>ge.jsxDEV("span",{className:"row",style:{gap:8},children:[ge.jsxDEV(Cn,{color:i.get(f.tool)??ao},void 0,!1,void 0,this),ge.jsxDEV("span",{className:"mono truncate tools-name",title:f.tool,children:f.tool},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},{key:"trend",header:u("tools.trend"),title:u("tools.trend-title"),render:(f)=>{let p=c.get(f.tool);return p&&p.length>1?ge.jsxDEV(mi,{values:p,width:80,height:20,color:i.get(f.tool)??ao},void 0,!1,void 0,this):ge.jsxDEV("span",{className:"dim",children:"–"},void 0,!1,void 0,this)}},{key:"calls",header:u("tools.calls"),align:"right",sort:(f)=>f.calls,render:(f)=>ge.jsxDEV(pa,{value:f.calls,max:l,display:ge.jsxDEV("span",{title:u("tools.share-of-calls",{percent:Fe(f.callFraction)}),children:[z(f.calls),ge.jsxDEV("span",{className:"dim tools-share",children:Fe(f.callFraction,0)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},{key:"errorRate",header:u("tools.errors"),title:u("tools.errors-title"),align:"right",sort:(f)=>f.errorRate,render:(f)=>ge.jsxDEV("span",{className:"row",style:{gap:8,justifyContent:"flex-end"},children:[ge.jsxDEV("span",{className:"num dim",children:z(f.errors)},void 0,!1,void 0,this),ge.jsxDEV(Bt,{tone:f.errors>0?ir(f.errorRate):"neutral",mono:!0,children:to(f.errorRate)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},{key:"args",header:u("tools.args"),title:u("tools.args-chars-title"),align:"right",sort:(f)=>f.argsChars,render:(f)=>ge.jsxDEV("span",{className:"num",children:Ae(f.argsChars)},void 0,!1,void 0,this)},{key:"result",header:u("tools.result"),title:u("tools.result-chars-title"),align:"right",sort:(f)=>f.resultChars,render:(f)=>ge.jsxDEV("span",{className:"num",children:Ae(f.resultChars)},void 0,!1,void 0,this)},{key:"avgResult",header:u("tools.result-per-call"),title:u("tools.result-per-call-title"),align:"right",sort:(f)=>f.avgResultChars,render:(f)=>ge.jsxDEV("span",{className:"num muted",children:Ae(Math.round(f.avgResultChars))},void 0,!1,void 0,this)},{key:"tokens",header:u("tools.attr-tokens"),title:au,align:"right",sort:(f)=>f.totalTokensShare,render:(f)=>ge.jsxDEV("span",{className:"num",title:u("tools.share-of-tokens",{percent:Fe(f.tokenFraction)}),children:[Ae(Math.round(f.totalTokensShare)),ge.jsxDEV("span",{className:"dim tools-share",children:Fe(f.tokenFraction,0)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},{key:"cost",header:u("tools.attr-cost"),title:u("tools.attribution-estimate",{note:au}),align:"right",sort:(f)=>f.costShare,render:(f)=>ge.jsxDEV("span",{className:"num",title:u("tools.share-of-cost",{percent:Fe(f.costFraction)}),children:[Ht(f.costShare,f.unpricedRequestsShare),ge.jsxDEV("span",{className:"dim tools-share",children:Fe(f.costFraction,0)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},{key:"lastUsed",header:u("tools.last-used"),align:"right",sort:(f)=>f.lastUsed,render:(f)=>ge.jsxDEV("span",{className:"muted",children:fa(f.lastUsed)},void 0,!1,void 0,this)}]}function VD({rows:l,tool:i,colors:c}){let f=ou.useMemo(()=>(i===null?l:l.filter((S)=>S.tool===i)).map((S)=>({...S,errorRate:S.calls>0?S.errors/S.calls:0})),[l,i]),p=ou.useMemo(()=>{let S=f.reduce((h,x)=>Math.max(h,x.calls),0);return[{key:"tool",header:u("tools.tool"),sort:(h)=>h.tool,render:(h)=>ge.jsxDEV("span",{className:"row",style:{gap:8},children:[ge.jsxDEV(Cn,{color:c.get(h.tool)??ao},void 0,!1,void 0,this),ge.jsxDEV("span",{className:"mono truncate tools-name",title:h.tool,children:h.tool},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},{key:"model",header:u("common.model"),sort:(h)=>h.model,render:(h)=>ge.jsxDEV(Ha,{primary:ge.jsxDEV("span",{className:"mono",children:h.model||u("common.unknown")},void 0,!1,void 0,this),secondary:h.provider},void 0,!1,void 0,this)},{key:"calls",header:u("tools.calls"),align:"right",sort:(h)=>h.calls,render:(h)=>ge.jsxDEV(pa,{value:h.calls,max:S,display:z(h.calls)},void 0,!1,void 0,this)},{key:"errorRate",header:u("tools.errors"),align:"right",sort:(h)=>h.errorRate,render:(h)=>ge.jsxDEV("span",{className:"row",style:{gap:8,justifyContent:"flex-end"},children:[ge.jsxDEV("span",{className:"num dim",children:z(h.errors)},void 0,!1,void 0,this),ge.jsxDEV(Bt,{tone:h.errors>0?ir(h.errorRate):"neutral",mono:!0,children:to(h.errorRate)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},{key:"result",header:u("tools.result"),title:u("tools.result-chars-title"),align:"right",sort:(h)=>h.resultChars,render:(h)=>ge.jsxDEV("span",{className:"num",children:Ae(h.resultChars)},void 0,!1,void 0,this)},{key:"tokens",header:u("tools.attr-tokens"),title:au,align:"right",sort:(h)=>h.totalTokensShare,render:(h)=>ge.jsxDEV("span",{className:"num",children:Ae(Math.round(h.totalTokensShare))},void 0,!1,void 0,this)},{key:"cost",header:u("tools.attr-cost"),title:u("tools.attribution-estimate",{note:au}),align:"right",sort:(h)=>h.costShare,render:(h)=>ge.jsxDEV("span",{className:"num",children:Ht(h.costShare,h.unpricedRequestsShare)},void 0,!1,void 0,this)},{key:"lastUsed",header:u("tools.last-used"),align:"right",sort:(h)=>h.lastUsed,render:(h)=>ge.jsxDEV("span",{className:"muted",children:fa(h.lastUsed)},void 0,!1,void 0,this)}]},[f,c]);return ge.jsxDEV(Xt,{rows:f,rowKey:(S)=>`${S.tool}::${S.model}::${S.provider}`,columns:p,initialSort:{key:"calls",dir:"desc"},limit:25,dense:!0,empty:ge.jsxDEV(wt,{title:i?u("tools.no-calls-to-tool",{tool:i}):u("tools.no-tool-calls")},void 0,!1,void 0,this)},void 0,!1,void 0,this)}var ki=Z(gt(),1);var Dt=Z(gt(),1);var gr=Z(ue(),1);function TT({toolStats:l,index:i}){if(l.length===0)return null;let c=Math.max(...l.map((p)=>p.totalMs)),f=[{key:"tool",header:u("trace.tool"),render:(p)=>gr.jsxDEV("span",{className:"mono",children:p.tool},void 0,!1,void 0,this),sort:(p)=>p.tool},{key:"calls",header:u("trace.calls"),align:"right",render:(p)=>gr.jsxDEV("span",{className:"num",children:z(p.calls)},void 0,!1,void 0,this),sort:(p)=>p.calls},{key:"errors",header:u("trace.errors"),align:"right",render:(p)=>p.errors>0?gr.jsxDEV(Bt,{tone:"bad",children:u("trace.failed-n",{count:z(p.errors)})},void 0,!1,void 0,this):gr.jsxDEV("span",{className:"num dim",children:"0"},void 0,!1,void 0,this),sort:(p)=>p.errors},{key:"total",header:u("common.total"),align:"right",width:200,render:(p)=>gr.jsxDEV(pa,{value:p.totalMs,max:c,display:At(p.totalMs),color:"var(--warn)"},void 0,!1,void 0,this),sort:(p)=>p.totalMs},{key:"avg",header:u("trace.avg"),align:"right",render:(p)=>gr.jsxDEV("span",{className:"num",children:At(p.calls>0?p.totalMs/p.calls:0)},void 0,!1,void 0,this),sort:(p)=>p.calls>0?p.totalMs/p.calls:0},{key:"max",header:u("trace.max"),align:"right",render:(p)=>gr.jsxDEV("span",{className:"num",children:At(p.maxMs)},void 0,!1,void 0,this),sort:(p)=>p.maxMs}];return gr.jsxDEV(Ye,{title:u("trace.tool-aggregates"),description:u("trace.tool-aggregates-desc",{count:l.length}),flush:!0,index:i,children:gr.jsxDEV(Xt,{columns:f,rows:l,rowKey:(p)=>p.tool,dense:!0,limit:12},void 0,!1,void 0,this)},void 0,!1,void 0,this)}var Fo=Z(gt(),1);var xi=Z(gt(),1);var nu={turn:"--ink-2",model:"--chart-primary",tool:"--warn",subagent:"--chart-secondary",background:"--ink-4"};function jD(){let l=getComputedStyle(document.documentElement),i=(c,f)=>l.getPropertyValue(c).trim()||f;return{category:{turn:i(nu.turn,"#a0a0a8"),model:i(nu.model,"#5ad8e6"),tool:i(nu.tool,"#f5a524"),subagent:i(nu.subagent,"#ed4abf"),background:i(nu.background,"#46464c")},error:i("--bad","#ff6166"),errorSoft:i("--bad-soft","rgba(255, 97, 102, 0.13)"),marker:i("--ink-1","#ededef"),turnBand:i("--hover","rgba(255, 255, 255, 0.035)"),grid:i("--chart-grid","rgba(255, 255, 255, 0.055)"),tick:i("--chart-axis","#5c5c64"),spanText:i("--ink-inverse","#0a0a0b"),selection:i("--focus","#5ad8e6"),brush:i("--selected","rgba(255, 255, 255, 0.075)"),fontSans:i("--font-sans","system-ui, sans-serif"),fontMono:i("--font-mono","ui-monospace, monospace")}}function Si(){let l=q1(),[i,c]=xi.useState(0);return xi.useEffect(()=>{let f=new MutationObserver(()=>c((p)=>p+1));return f.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>f.disconnect()},[]),xi.useMemo(jD,[l,i])}var AT=Z(ue(),1),Kl=44,Vd=["turn","model","tool","subagent"],IT=6,Li=10;function XD(l,i,c,f){let p=devicePixelRatio,S=Math.floor(c*p),h=Math.floor(Kl*p),x,b;if(typeof OffscreenCanvas>"u"){let k=document.createElement("canvas");k.width=S,k.height=h,x=k,b=k.getContext("2d")}else{let k=new OffscreenCanvas(S,h);x=k,b=k.getContext("2d")}if(!b)return x;b.setTransform(p,0,0,p,0,0);let[L,g]=i.domain,C=Math.max(g-L,0.000000001),w=Vd.map(()=>new Float32Array(c));for(let k of l)for(let D of k.spans){let M=Vd.indexOf(D.kind);if(M===-1)continue;let B=w[M],P=Math.max(0,Math.floor((i.toU(D.start)-L)/C*c)),j=Math.min(c-1,Math.ceil((i.toU(D.end)-L)/C*c));for(let Y=P;Y<=j;Y++)B[Y]=Math.min(1,B[Y]+0.34)}let A=Kl/Vd.length;for(let k=0;k<Vd.length;k++){let D=w[k];b.fillStyle=f.category[Vd[k]];for(let M=0;M<c;M++){if(D[M]<=0)continue;b.globalAlpha=0.25+D[M]*0.75,b.fillRect(M,k*A+1,1,A-2)}b.globalAlpha=1}return x}function RT({tracks:l,scale:i,viewport:c,onViewportChange:f}){let p=Si(),S=Fo.useRef(null),[h,x]=Fo.useState(800),b=Fo.useRef(null);Fo.useEffect(()=>{let P=S.current;if(!P)return;let j=new ResizeObserver((Y)=>{x(Math.max(100,Math.floor(Y[0].contentRect.width)))});return j.observe(P),()=>j.disconnect()},[]);let[L,g]=i.domain,C=Math.max(g-L,0.000000001),w=Fo.useCallback((P)=>(P-L)/C*h,[L,C,h]),A=Fo.useCallback((P)=>L+P/Math.max(h,1)*C,[L,C,h]),k=Fo.useMemo(()=>XD(l,i,h,p),[l,i,h,p]);Fo.useEffect(()=>{let P=S.current;if(!P)return;let j=P.getContext("2d");if(!j)return;let Y=devicePixelRatio;j.setTransform(1,0,0,1,0,0),j.clearRect(0,0,P.width,P.height),j.drawImage(k,0,0),j.setTransform(Y,0,0,Y,0,0);let ce=w(c.u0),J=w(c.u1);j.fillStyle=p.brush,j.fillRect(ce,0,J-ce,Kl),j.strokeStyle=p.selection,j.strokeRect(ce+0.5,0.5,J-ce-1,Kl-1),j.fillStyle=p.selection,j.fillRect(ce,0,2,Kl),j.fillRect(J-2,0,2,Kl)},[k,c,p,w]);let D=(P)=>{let j=P.currentTarget.getBoundingClientRect(),Y=P.clientX-j.left,ce=w(c.u0),J=w(c.u1),te;if(Math.abs(Y-ce)<=IT)te="left";else if(Math.abs(Y-J)<=IT)te="right";else if(Y>ce&&Y<J)te="move";else{te="create";let X=A(Y);f(jd({u0:X,u1:X+Li},L,g))}b.current={mode:te,startX:Y,startViewport:c},P.currentTarget.setPointerCapture(P.pointerId)},M=(P)=>{let j=b.current;if(!j)return;let Y=P.currentTarget.getBoundingClientRect(),ce=P.clientX-Y.left,J=A(ce)-A(j.startX),{u0:te,u1:X}=j.startViewport;if(j.mode==="move")f(jd({u0:te+J,u1:X+J},L,g));else if(j.mode==="left")f(jd({u0:Math.min(te+J,X-Li),u1:X},L,g));else if(j.mode==="right")f(jd({u0:te,u1:Math.max(X+J,te+Li)},L,g));else{let ae=A(j.startX),H=A(ce);f(jd({u0:Math.min(ae,H),u1:Math.max(ae,H,Math.min(ae,H)+Li)},L,g))}},B=()=>{b.current=null};return AT.jsxDEV("canvas",{ref:S,width:Math.floor(h*devicePixelRatio),height:Math.floor(Kl*devicePixelRatio),className:"traces-minimap",style:{height:Kl},role:"slider","aria-label":u("trace.minimap-aria"),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round((c.u0-L)/C*100),tabIndex:-1,onPointerDown:D,onPointerMove:M,onPointerUp:B},void 0,!1,void 0,this)}function jd(l,i,c){let f=Math.max(Li,l.u1-l.u0);f=Math.min(f,c-i||Li);let p=l.u0;if(p<i)p=i;if(p+f>c)p=c-f;return{u0:p,u1:p+f}}var yr=Z(gt(),1);var nt=Z(ue(),1);function YD(l){let i=[];if(typeof l==="string"){if(l.trim())i.push({kind:"text",text:l});return i}if(!Array.isArray(l))return i;for(let c of l){if(!c||typeof c!=="object"||!("type"in c))continue;if((c.type==="text"||c.type==="thinking")&&"text"in c&&typeof c.text==="string")i.push({kind:String(c.type),text:c.text})}return i}function MT({span:l,track:i,onClose:c,onOpenChildTrack:f}){let[p,S]=yr.useState(null),[h,x]=yr.useState(!1),[b,L]=yr.useState(null),[g,C]=yr.useState(!1),w=yr.useRef(0);if(yr.useEffect(()=>{if(S(null),L(null),C(!1),x(!1),!l||!i||!l.entryId)return;x(!0);let P=new AbortController;return g1(i.file,l.entryId,P.signal).then((j)=>{if(!P.signal.aborted)S(j.entry)}).catch((j)=>{if(P.signal.aborted)return;L(j instanceof Error?j:Error(String(j)))}).finally(()=>{if(!P.signal.aborted)x(!1)}),()=>P.abort()},[l,i]),yr.useEffect(()=>()=>window.clearTimeout(w.current),[]),!l)return null;let A=async()=>{try{await navigator.clipboard.writeText(JSON.stringify(p??l,null,2)),C(!0),window.clearTimeout(w.current),w.current=window.setTimeout(()=>C(!1),1500)}catch{}},D=(p&&typeof p==="object"?p:{}).message,M=D?.usage,B=[{key:"duration",label:u("common.duration"),value:nt.jsxDEV("span",{className:"num",children:[At(l.end-l.start),l.unterminated&&nt.jsxDEV("span",{className:"muted",children:[" · ",u("trace.unterminated")]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},{key:"start",label:u("trace.start"),value:nt.jsxDEV("span",{className:"num",children:new Date(l.start).toLocaleTimeString()},void 0,!1,void 0,this)},{key:"track",label:u("trace.track"),value:nt.jsxDEV("span",{className:"mono",children:i?.label??"-"},void 0,!1,void 0,this)}];if(l.kind==="model"){if(B.push({key:"tokens",label:u("common.tokens"),value:nt.jsxDEV("span",{className:"num",children:z(l.tokens??0)},void 0,!1,void 0,this)},{key:"cost",label:u("common.cost"),value:nt.jsxDEV("span",{className:"num",children:["$",(l.cost??0).toFixed(4)]},void 0,!0,void 0,this)},{key:"ttft",label:u("trace.ttft"),value:nt.jsxDEV("span",{className:"num",children:At(l.ttft??null)},void 0,!1,void 0,this)},{key:"model",label:u("common.model"),value:nt.jsxDEV("span",{className:"mono",children:D?.model??l.model??"-"},void 0,!1,void 0,this)}),M)B.push({key:"split",label:u("trace.io-cached"),value:nt.jsxDEV("span",{className:"num",children:[z(M.input??0)," / ",z(M.output??0)," /"," ",z(M.cacheRead??0)]},void 0,!0,void 0,this)});if(D?.provider)B.push({key:"provider",label:u("common.provider"),value:nt.jsxDEV("span",{className:"mono",children:D.provider},void 0,!1,void 0,this)});if(D?.stopReason)B.push({key:"stop",label:u("trace.stop-reason"),value:nt.jsxDEV("span",{className:"mono",children:D.stopReason},void 0,!1,void 0,this)})}return nt.jsxDEV(qm,{open:!0,onClose:c,title:l.label,subtitle:nt.jsxDEV("span",{className:"row",style:{gap:6},children:nt.jsxDEV(Bt,{tone:l.isError?"bad":"neutral",children:l.isError?`${l.kind} · ${u("common.error")}`:l.kind},void 0,!1,void 0,this)},void 0,!1,void 0,this),actions:nt.jsxDEV("button",{type:"button",className:"btn","data-variant":"ghost","data-icon":"true",onClick:A,"aria-label":u("trace.copy-json"),title:u("trace.copy-json"),children:g?nt.jsxDEV(Gs,{size:15},void 0,!1,void 0,this):nt.jsxDEV(js,{size:15},void 0,!1,void 0,this)},void 0,!1,void 0,this),children:nt.jsxDEV("div",{className:"stack traces-drawer",children:[nt.jsxDEV(Ho,{items:B},void 0,!1,void 0,this),D?.errorMessage&&nt.jsxDEV("div",{className:"stack",style:{gap:6},children:[nt.jsxDEV("div",{className:"section-label tone-bad",children:u("trace.error-message")},void 0,!1,void 0,this),nt.jsxDEV("pre",{className:"code-block traces-pre",children:D.errorMessage},void 0,!1,void 0,this)]},void 0,!0,void 0,this),l.kind==="subagent"&&nt.jsxDEV("div",{className:"stack",style:{gap:8},children:[l.detail&&nt.jsxDEV(nt.Fragment,{children:[nt.jsxDEV("div",{className:"section-label",children:u("trace.task")},void 0,!1,void 0,this),nt.jsxDEV("pre",{className:"code-block traces-pre",children:l.detail},void 0,!1,void 0,this)]},void 0,!0,void 0,this),l.childTrackId&&f&&nt.jsxDEV("div",{children:nt.jsxDEV("button",{type:"button",className:"btn","data-size":"sm",onClick:()=>f(l.childTrackId??""),children:[u("trace.open-child-track")," ",nt.jsxDEV("span",{className:"mono",children:l.childTrackId},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),l.kind==="tool"&&l.detail&&nt.jsxDEV("div",{className:"stack",style:{gap:6},children:[nt.jsxDEV("div",{className:"section-label",children:u("trace.args")},void 0,!1,void 0,this),nt.jsxDEV("pre",{className:"code-block traces-pre",children:l.detail},void 0,!1,void 0,this)]},void 0,!0,void 0,this),h&&nt.jsxDEV("div",{className:"stack",children:[nt.jsxDEV(qa,{height:80},void 0,!1,void 0,this),nt.jsxDEV(qa,{height:160},void 0,!1,void 0,this)]},void 0,!0,void 0,this),b&&nt.jsxDEV(gi,{error:u("trace.load-failed",{message:b.message})},void 0,!1,void 0,this),!h&&p!==null&&YD(D?.content).map((P,j)=>nt.jsxDEV("div",{className:"stack",style:{gap:6},children:[nt.jsxDEV("div",{className:"section-label",children:P.kind==="thinking"?u("trace.thinking"):u("trace.text")},void 0,!1,void 0,this),nt.jsxDEV("pre",{className:"code-block traces-pre","data-scroll":"true",children:P.text},void 0,!1,void 0,this)]},`${P.kind}-${j}`,!0,void 0,this)),!h&&p!==null&&nt.jsxDEV(di,{data:p,title:u("trace.raw-entry"),initialCollapsed:!0},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}var An=Z(ue(),1);function DT({summary:l}){let i=(c)=>l.wallMs>0?u("trace.of-wall",{percent:Fe(c/l.wallMs)}):void 0;return An.jsxDEV(la,{min:112,children:[An.jsxDEV(ie,{size:"sm",label:u("trace.wall-time"),value:Ks(l.wallMs)},void 0,!1,void 0,this),An.jsxDEV(ie,{size:"sm",label:u("trace.model-time"),value:Ks(l.modelMs),hint:i(l.modelMs)},void 0,!1,void 0,this),An.jsxDEV(ie,{size:"sm",label:u("trace.tool-time"),value:Ks(l.toolMs),hint:i(l.toolMs)},void 0,!1,void 0,this),An.jsxDEV(ie,{size:"sm",label:u("trace.idle"),value:Ks(l.idleMs),hint:i(l.idleMs)},void 0,!1,void 0,this),An.jsxDEV(ie,{size:"sm",label:u("trace.turns"),value:z(l.turns)},void 0,!1,void 0,this),An.jsxDEV(ie,{size:"sm",label:u("common.requests"),value:z(l.requests),hint:u("trace.tool-calls-n",{count:z(l.toolCalls)})},void 0,!1,void 0,this),An.jsxDEV(ie,{size:"sm",label:u("trace.agents"),value:z(l.subagents)},void 0,!1,void 0,this),An.jsxDEV(ie,{size:"sm",label:u("common.tokens"),value:Ae(l.totalTokens)},void 0,!1,void 0,this),An.jsxDEV(ie,{size:"sm",label:u("common.cost"),value:Ht(l.costTotal,l.unpricedRequests)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var Ot=Z(gt(),1),UT=Z(rd(),1);function Km(l,i){let c=l.length,f=[i[0],i[c-1]],p=(S,h)=>{let x=0,b=c-1;while(x<b){let L=x+b+1>>1;if(S[L]<=h)x=L;else b=L-1}return Math.min(x,c-2)};return{toU(S){if(S<=l[0])return i[0];if(S>=l[c-1])return i[c-1];let h=p(l,S),x=l[h+1]-l[h];if(x<=0)return i[h];return i[h]+(S-l[h])/x*(i[h+1]-i[h])},toT(S){if(S<=i[0])return l[0];if(S>=i[c-1])return l[c-1];let h=p(i,S),x=i[h+1]-i[h];if(x<=0)return l[h];return l[h]+(S-i[h])/x*(l[h+1]-l[h])},domain:f,gaps:[]}}function $D(l){let i=[];for(let c of l)for(let f of c.spans)i.push([f.start,f.end]);return i.sort((c,f)=>c[0]-f[0]),i}function QD(l){let{POSITIVE_INFINITY:i,NEGATIVE_INFINITY:c}=Number;for(let f of l)for(let p of f.spans){if(p.start<i)i=p.start;if(p.end>c)c=p.end}if(!Number.isFinite(i))return[0,1];return[i,Math.max(c,i+1)]}function ET(l,i,c){let f=[...new Set(l.filter((x)=>x>=i&&x<=c))].sort((x,b)=>x-b);if(f[0]!==i)f.unshift(i);if(f[f.length-1]!==c)f.push(c);if(f.length<2)return Km([i,c],[i,c]);let S=(c-i)/(f.length-1),h=f.map((x,b)=>i+b*S);return Km(f,h)}function KD(l,i,c){let f=$D(l),p=[];for(let[g,C]of f){let w=g-2000,A=C+2000,k=p[p.length-1];if(k&&w<=k[1]){if(A>k[1])k[1]=A}else p.push([w,A])}if(p.length===0)p.push([i,c]);p[0][0]=Math.max(p[0][0],i),p[p.length-1][1]=Math.min(Math.max(p[p.length-1][1],p[p.length-1][0]),c);let S=[],h=[],x=[],b=p[0][0];for(let g=0;g<p.length;g++){let[C,w]=p[g];if(g===0)S.push(C),h.push(b);else{let A=p[g-1][1],k=C-A;if(k>30000)b+=8000,x.push({t0:A,t1:C,uMid:b-4000});else b+=k;S.push(C),h.push(b)}b+=Math.max(0,w-C),S.push(w),h.push(b)}return{...Km(S,h),gaps:x}}function OT(l,i,c){let[f,p]=QD(l);if(i==="turns"){let h=(l.find((x)=>x.id==="main")?.spans??[]).filter((x)=>x.kind==="turn").map((x)=>x.start);return ET(h,f,p)}if(i==="calls"){let S=[];for(let h of l)for(let x of h.spans)if(x.kind==="model"||x.kind==="tool"||x.kind==="background")S.push(x.start,x.end);return ET(S,f,p)}if(c)return KD(l,f,p);return Km([f,p],[f,p])}var ZD=90;function WD(l){let i=10**Math.floor(Math.log10(Math.max(l,1)));for(let c of[1,2,5,10])if(i*c>=l)return i*c;return i*10}function JD(l){let i=new Date(l),c=String(i.getHours()).padStart(2,"0"),f=String(i.getMinutes()).padStart(2,"0"),p=String(i.getSeconds()).padStart(2,"0");return`${c}:${f}:${p}`}function Ci(l){let i=l<0?"-":"+",c=Math.abs(l),f=Math.floor(c/3600000),p=Math.floor(c%3600000/60000),S=Math.floor(c%60000/1000),h=Math.floor(c%1000),x=c%1000!==0,b=`${String(p).padStart(2,"0")}:${String(S).padStart(2,"0")}${x?".":""}${x?String(h).padStart(3,"0"):""}`;return f>0?`${i}${f}:${b}`:`${i}${b}`}function qT(l,i,c,f){let p=c-i;if(p<=0||f<=0)return[];let S=[],h=l.domain[0],x=WD(p*ZD/f),b=h+Math.ceil((i-h)/x)*x,L=0;for(let g=b;g<=c&&L<200;g+=x,L++){let C=l.toT(g),w=Math.round((g-h)/x)%5===0;S.push({u:g,label:w?JD(C):Ci(g-h),major:w})}return S}var Rt=Z(ue(),1),Kr=28,cb=22,Lo=18,NT=3,eE=14,BT=200,sb=10,PT=2,tE=4,aE=56,Zm=3,ib=0.3,oE=[{kind:"turn",label:u("common.input")},{kind:"model",label:u("common.model")},{kind:"tool",label:u("trace.tools")},{kind:"subagent",label:u("trace.agents")},{kind:"background",label:u("trace.bg")}];function nE(l,i){let c=new Map(l.map((b)=>[b.id,b])),f=new Set;for(let b of l)if(b.parentId)f.add(b.parentId);let p=(b)=>{let L=b.parentId;while(L){if(i.has(L))return!0;L=c.get(L)?.parentId??null}return!1},S=[],h=[],x=Kr+6;for(let b of l){if(p(b))continue;let L=b.id==="main"?0:b.id.split("/").length,g={turn:[],model:[],tool:[],subagent:[],background:[]};for(let w of b.spans)g[w.kind].push(w);let C={track:b,depth:L,hasChildren:f.has(b.id),headerY:x,lanes:[],turnSpans:g.turn,y0:x,y1:x};x+=cb;for(let{kind:w,label:A}of oE){let k=g[w],D=w==="turn"||w==="model"||w==="tool";if(k.length===0&&!(b.id==="main"&&D))continue;let M={track:b,kind:w,label:A,y:x,spans:k};C.lanes.push(M),h.push(M),x+=Lo+NT}C.y1=x-NT,S.push(C),x+=eE}return{blocks:S,lanes:h,totalHeight:Math.max(x,Kr+48)}}function rE(l,i){return l.lanes.map((c)=>{let f=c.spans.length,p=new Float64Array(f),S=new Float64Array(f),h=new Float64Array(f),x=Number.NEGATIVE_INFINITY;for(let b=0;b<f;b++){let L=c.spans[b];p[b]=i.toU(L.start),S[b]=i.toU(L.end),x=Math.max(x,S[b]),h[b]=x}return{startU:p,endU:S,maxEndU:h}})}function lE(l,i){let c=0,f=l.length;while(c<f){let p=c+f>>>1;if(l[p]<i)c=p+1;else f=p}return c}function sE(l,i){if(l===null||i===null)return l===i;if(l.kind==="span")return i.kind==="span"&&l.span===i.span;return i.kind==="marker"&&l.marker===i.marker}function _T({tracks:l,scale:i,viewport:c,onViewportChange:f,selected:p,onSelect:S,matchIds:h,collapsed:x,onToggleCollapse:b,traceStart:L}){let g=Si(),C=Ot.useRef(null),w=Ot.useRef(null),A=Ot.useRef(null),[k,D]=Ot.useState(800),[M,B]=Ot.useState(null),P=Ot.useRef(null);P.current=M;let j=Ot.useRef({clientX:0,clientY:0}),Y=Ot.useRef([]),ce=Ot.useRef(null),J=Ot.useRef(null),te=Ot.useRef(c);te.current=c;let X=Ot.useMemo(()=>nE(l,x),[l,x]),ae=Ot.useMemo(()=>rE(X,i),[X,i]);Ot.useEffect(()=>{let oe=C.current;if(!oe)return;let ve=new ResizeObserver((G)=>{let _e=Math.max(100,Math.floor(G[0].contentRect.width-BT));D(_e)});return ve.observe(oe),()=>ve.disconnect()},[]);let H=Ot.useCallback((oe,ve)=>{let[G,_e]=i.domain,Qe=Math.max(sb,ve-oe);Qe=Math.min(Qe,_e-G||sb);let Ue=oe;if(Ue<G)Ue=G;if(Ue+Qe>_e)Ue=_e-Qe;return{u0:Ue,u1:Ue+Qe}},[i]),de=Ot.useCallback((oe)=>{te.current=oe,f(oe)},[f]),xe=Ot.useCallback((oe,ve)=>{let G=k,{u0:_e,u1:Qe}=te.current,Ue=Qe-_e,dt=ve===null?0.5:Math.min(1,Math.max(0,ve/G)),et=_e+Ue*dt,ft=Ue*oe;de(H(et-ft*dt,et+ft*(1-dt)))},[k,de,H]),Ce=Ot.useCallback((oe)=>{let{u0:ve,u1:G}=te.current;de(H(ve+oe,G+oe))},[de,H]),Be=Ot.useCallback((oe)=>{let ve=i.toU(oe.start),G=i.toU(oe.end),_e=Math.max((G-ve)*0.1,sb/2);de(H(ve-_e,G+_e))},[i,de,H]);Ot.useEffect(()=>{let oe=w.current;if(!oe)return;let ve=(G)=>{G.preventDefault();let _e=oe.getBoundingClientRect(),Qe=G.clientX-_e.left;J.current=Qe,B(null);let Ue=oe.clientWidth||1,dt=()=>te.current.u1-te.current.u0;if(G.shiftKey){let et=Math.abs(G.deltaY)>=Math.abs(G.deltaX)?G.deltaY:G.deltaX;Ce(et/Ue*dt());return}if(G.deltaX!==0)Ce(G.deltaX/Ue*dt());if(G.deltaY!==0)xe(1.0015**G.deltaY,Qe)};return oe.addEventListener("wheel",ve,{passive:!1}),()=>oe.removeEventListener("wheel",ve)},[xe,Ce]);let ne=Ot.useCallback((oe,ve)=>{let G=w.current;if(!G)return null;let _e=G.getBoundingClientRect(),Qe=oe-_e.left,Ue=ve-_e.top,dt=Y.current;for(let et=dt.length-1;et>=0;et--){let ft=dt[et];if(Qe>=ft.x&&Qe<=ft.x+ft.w&&Ue>=ft.y&&Ue<=ft.y+ft.h)return ft}return null},[]),me=Ot.useCallback(()=>{let oe=A.current;if(!oe)return;let{clientX:ve,clientY:G}=j.current,_e=Math.min(ve+14,window.innerWidth-320),Qe=G+16>window.innerHeight-140?G-120:G+16;oe.style.transform=`translate(${_e}px, ${Qe}px)`},[]),ke=(oe)=>{oe.currentTarget.setPointerCapture(oe.pointerId),ce.current={pointerId:oe.pointerId,lastX:oe.clientX,moved:!1},oe.currentTarget.focus()},$e=(oe)=>{let ve=oe.currentTarget.getBoundingClientRect();J.current=oe.clientX-ve.left;let G=ce.current;if(G&&G.pointerId===oe.pointerId){let Qe=oe.clientX-G.lastX;if(Math.abs(Qe)>0){if(Math.abs(Qe)>2)G.moved=!0;G.lastX=oe.clientX;let Ue=te.current.u1-te.current.u0;Ce(-Qe/(k||1)*Ue)}B(null);return}j.current={clientX:oe.clientX,clientY:oe.clientY};let _e=ne(oe.clientX,oe.clientY);if(sE(_e,P.current))me();else B(_e)},xt=(oe)=>{let ve=ce.current;if(ce.current=null,ve?.moved)return;let G=ne(oe.clientX,oe.clientY);if(G?.kind==="span")S(G.span.id);else S(null)},W=(oe)=>{let ve=ne(oe.clientX,oe.clientY);if(ve?.kind==="span")Be(ve.span)},ze=Ot.useCallback((oe)=>{let ve=p?.span.id;if(!ve)return;for(let G of X.lanes){let _e=G.spans.findIndex((dt)=>dt.id===ve);if(_e===-1)continue;let Qe=G.spans[_e+oe];if(!Qe)return;S(Qe.id);let Ue=i.toU(Qe.start);if(Ue<c.u0||Ue>c.u1){let dt=c.u1-c.u0;f(H(Ue-dt/2,Ue+dt/2))}return}},[p,X,S,i,c,f,H]),Ct=(oe)=>{let ve=c.u1-c.u0;switch(oe.key){case"w":case"W":xe(0.7692307692307692,J.current);break;case"s":case"S":xe(1.3,J.current);break;case"a":case"A":Ce(-ve*0.2);break;case"d":case"D":Ce(ve*0.2);break;case"0":f({u0:i.domain[0],u1:i.domain[1]});break;case"f":case"F":if(p)Be(p.span);break;case"Escape":S(null);break;case",":ze(-1);break;case".":ze(1);break;default:return}oe.preventDefault()};Ot.useEffect(()=>{w.current?.focus({preventScroll:!0})},[]),Ot.useEffect(()=>{let oe=w.current;if(!oe)return;let ve=requestAnimationFrame(()=>{Y.current=uE(oe,X,ae,i,c,g,k,h)});return()=>cancelAnimationFrame(ve)},[X,ae,i,c,g,k,h]);let it=M?.kind==="span"?zT(M,X,i,c,k):null,ct=p?zT(p,X,i,c,k):null;Ot.useLayoutEffect(()=>{if(M)me()},[M,me]);let Me=M?iE(M,L,A):null,ye=Math.floor(k*devicePixelRatio),V=Math.floor(X.totalHeight*devicePixelRatio),Re={width:k,height:X.totalHeight};return Rt.jsxDEV("div",{ref:C,className:"traces-timeline",children:[Rt.jsxDEV("div",{style:{width:BT,flexShrink:0,position:"relative",height:X.totalHeight},children:X.blocks.map((oe)=>Rt.jsxDEV("div",{children:[Rt.jsxDEV("div",{style:{position:"absolute",top:oe.headerY,left:4+oe.depth*14,right:8,height:cb,display:"flex",alignItems:"center",gap:5,minWidth:0},children:[oe.hasChildren?Rt.jsxDEV("button",{type:"button",onClick:()=>b(oe.track.id),"aria-label":x.has(oe.track.id)?u("trace.expand-track",{track:oe.track.label}):u("trace.collapse-track",{track:oe.track.label}),className:"traces-chevron",children:x.has(oe.track.id)?Rt.jsxDEV(Ln,{size:12},void 0,!1,void 0,this):Rt.jsxDEV(Vs,{size:12},void 0,!1,void 0,this)},void 0,!1,void 0,this):Rt.jsxDEV("span",{style:{width:12,flexShrink:0}},void 0,!1,void 0,this),Rt.jsxDEV("span",{className:"traces-gutter-track truncate",style:{minWidth:0},children:oe.track.label},void 0,!1,void 0,this),oe.track.model&&Rt.jsxDEV("span",{className:"traces-gutter-model mono truncate",style:{flexShrink:1,minWidth:0},children:oe.track.model},void 0,!1,void 0,this)]},void 0,!0,void 0,this),oe.lanes.map((ve)=>Rt.jsxDEV("div",{className:"traces-gutter-lane",style:{top:ve.y,left:20+oe.depth*14,lineHeight:`${Lo}px`},children:ve.label},`${ve.track.id}:${ve.kind}`,!1,void 0,this))]},oe.track.id,!0,void 0,this))},void 0,!1,void 0,this),Rt.jsxDEV("div",{className:"traces-canvas-stack",style:Re,children:[Rt.jsxDEV("canvas",{ref:w,className:"traces-canvas",width:ye,height:V,style:Re,tabIndex:0,role:"application","aria-label":u("trace.canvas-aria"),onPointerDown:ke,onPointerMove:$e,onPointerUp:xt,onPointerLeave:()=>{J.current=null,B(null)},onDoubleClick:W,onKeyDown:Ct},void 0,!1,void 0,this),it&&M?.kind==="span"&&Rt.jsxDEV("div",{className:"traces-canvas-hover","aria-hidden":"true",style:{left:it.x,top:it.y,width:it.w,height:Lo,borderRadius:Zm,opacity:h===null||h.has(M.span.id)?1:ib}},void 0,!1,void 0,this),ct&&p&&Rt.jsxDEV("div",{className:"traces-canvas-selection","aria-hidden":"true",style:{left:ct.x-1,top:ct.y-1,width:ct.w+2,height:Lo+2,borderRadius:Zm,borderColor:g.selection,opacity:h===null||h.has(p.span.id)?1:ib}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Me&&UT.createPortal(Me,document.body)]},void 0,!0,void 0,this)}function ub(l,i,c,f,p){if(l.beginPath(),f>=Zm*2+1)l.roundRect(i,c,f,p,Zm);else l.rect(i,c,f,p)}function uE(l,i,c,f,p,S,h,x){let b=[],L=l.getContext("2d");if(!L)return b;let g=i.totalHeight,C=devicePixelRatio;L.setTransform(C,0,0,C,0,0),L.clearRect(0,0,h,g);let{u0:w,u1:A}=p,k=Math.max(A-w,0.000000001),D=(M)=>(M-w)/k*h;for(let M of i.blocks){let B=M.turnSpans;for(let P=0;P<B.length;P++){let j=D(f.toU(B[P].start)),Y=P+1<B.length?D(f.toU(B[P+1].start)):h;if(Y<0||j>h)continue;if(P%2===1)L.fillStyle=S.turnBand,L.fillRect(Math.max(0,j),M.y0,Math.min(h,Y)-Math.max(0,j),M.y1-M.y0);if(j>=0&&j<=h)L.strokeStyle=S.grid,L.beginPath(),L.moveTo(Math.round(j)+0.5,M.y0),L.lineTo(Math.round(j)+0.5,M.y1),L.stroke()}}L.font=`9px ${S.fontMono}`;for(let M of f.gaps){let B=D(M.uMid);if(B<-24||B>h+24)continue;L.save(),L.strokeStyle=S.grid,L.setLineDash([2,4]),L.beginPath(),L.moveTo(B,Kr),L.lineTo(B,g),L.stroke(),L.restore(),L.fillStyle=S.tick,L.textAlign="center",L.fillText(`⋯ ${At(M.t1-M.t0)}`,B,Kr-4),L.textAlign="left"}for(let M of qT(f,w,A,h)){let B=Math.round(D(M.u))+0.5;if(L.strokeStyle=S.grid,L.beginPath(),M.major)L.moveTo(B,4),L.lineTo(B,g);else L.moveTo(B,Kr-8),L.lineTo(B,Kr);if(L.stroke(),L.fillStyle=S.tick,M.major)L.fillText(M.label,B+4,11);else L.globalAlpha=0.75,L.fillText(M.label,B+3,Kr-10),L.globalAlpha=1}L.strokeStyle=S.grid,L.beginPath(),L.moveTo(0,Kr+0.5),L.lineTo(h,Kr+0.5),L.stroke(),L.font=`10px ${S.fontSans}`;for(let M=0;M<i.lanes.length;M++){let B=i.lanes[M],{startU:P,endU:j,maxEndU:Y}=c[M],ce=B.kind==="turn";for(let J=lE(Y,w);J<B.spans.length;J++){let te=P[J];if(te>A)break;let X=j[J];if(X<w)continue;let ae=B.spans[J],H=D(te),de=Math.max(PT,D(X)-H),xe=B.y,Ce=x===null||x.has(ae.id)?1:ib,Be=S.category[ae.kind];if(L.globalAlpha=Ce,ce)L.fillStyle=Be,L.globalAlpha=Ce*0.23,ub(L,H,xe,de,Lo),L.fill(),L.globalAlpha=Ce,L.fillStyle=Be,L.fillRect(H,xe,2,Lo);else L.fillStyle=Be,ub(L,H,xe,de,Lo),L.fill();if(ae.isError)L.fillStyle=S.errorSoft,ub(L,H,xe,de,Lo),L.fill(),L.fillStyle=S.error,L.fillRect(H,xe,2,Lo);if(ae.kind==="model"&&typeof ae.ttft==="number"&&ae.ttft>0&&de>20){let me=D(f.toU(ae.start+ae.ttft));if(me>H+1&&me<H+de-1)L.fillStyle="rgba(0,0,0,0.5)",L.fillRect(me,xe+3,1,Lo-6)}if(ae.unterminated)L.save(),L.strokeStyle=S.tick,L.setLineDash([2,2]),L.beginPath(),L.moveTo(H+de-0.5,xe),L.lineTo(H+de-0.5,xe+Lo),L.stroke(),L.restore();if(de>aE)L.save(),L.beginPath(),L.rect(H+3,xe,de-6,Lo),L.clip(),L.fillStyle=ce?S.tick:S.spanText,L.fillText(ae.label,H+5,xe+Lo-5),L.restore();L.globalAlpha=1;let ne=Math.max(de,tE);b.push({kind:"span",x:H-(ne-de)/2,y:xe,w:ne,h:Lo,span:ae,track:B.track})}}for(let M of i.blocks)for(let B of M.track.markers){let P=D(f.toU(B.time));if(P<-6||P>h+6)continue;let j=M.headerY+cb/2;L.fillStyle=S.marker,L.beginPath(),L.moveTo(P,j-4),L.lineTo(P+4,j),L.lineTo(P,j+4),L.lineTo(P-4,j),L.closePath(),L.fill(),b.push({kind:"marker",x:P-5,y:j-5,w:10,h:10,marker:B,track:M.track})}return b}function zT({span:l,track:i},c,f,p,S){let{u0:h,u1:x}=p,b=f.toU(l.start),L=f.toU(l.end);if(b>x||L<h)return null;let g=c.lanes.find((k)=>k.track===i&&k.kind===l.kind);if(!g)return null;let C=Math.max(x-h,0.000000001),w=(b-h)/C*S,A=(L-h)/C*S;return{x:w,y:g.y,w:Math.max(PT,A-w)}}function iE(l,i,c){let f={left:0,top:0};if(l.kind==="marker"){let{marker:S}=l;return Rt.jsxDEV("div",{ref:c,className:"traces-tooltip",style:f,children:[Rt.jsxDEV("div",{className:"traces-tooltip-title",children:S.label},void 0,!1,void 0,this),Rt.jsxDEV("div",{className:"muted num",children:[new Date(S.time).toLocaleTimeString()," (",Ci(S.time-i),")"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}let{span:p}=l;return Rt.jsxDEV("div",{ref:c,className:"traces-tooltip",style:f,children:[Rt.jsxDEV("div",{className:"traces-tooltip-title truncate",children:p.label},void 0,!1,void 0,this),Rt.jsxDEV("div",{className:"muted num",children:[At(p.end-p.start)," · ",new Date(p.start).toLocaleTimeString()," (",Ci(p.start-i),")",p.unterminated?` · ${u("trace.unterminated")}`:""]},void 0,!0,void 0,this),p.kind==="model"&&Rt.jsxDEV("div",{className:"muted num",children:[p.tokens!==void 0&&Rt.jsxDEV(Rt.Fragment,{children:[z(p.tokens)," ",u("trace.tok")]},void 0,!0,void 0,this),p.cost!==void 0&&Rt.jsxDEV(Rt.Fragment,{children:[" · $",p.cost.toFixed(4)]},void 0,!0,void 0,this),p.ttft!==void 0&&Rt.jsxDEV(Rt.Fragment,{children:[" ","· ",u("trace.ttft")," ",At(p.ttft)]},void 0,!0,void 0,this),p.isError&&Rt.jsxDEV(Rt.Fragment,{children:[" · ",u("common.error")]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),p.kind==="subagent"&&p.model&&Rt.jsxDEV("div",{className:"muted num",children:p.model},void 0,!1,void 0,this),p.detail&&Rt.jsxDEV("div",{className:"traces-tooltip-detail",children:p.detail},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var Mn=Z(gt(),1);var Ga=Z(ue(),1),wi=28,HT=20,cE=340;function dE(l){let i=[];for(let c of l){let f=c.id==="main"?0:c.id.split("/").length;for(let p of c.spans)i.push({key:p.id,time:p.start,span:p,track:c,depth:f});for(let p=0;p<c.markers.length;p++){let S=c.markers[p];i.push({key:`${c.id}:marker:${p}`,time:S.time,marker:S,track:c,depth:f})}}return i.sort((c,f)=>c.time-f.time),i}var FT=Mn.memo(function({tracks:i,selection:c,onSelect:f,search:p,matchIds:S,traceStart:h}){let x=Si(),b=Mn.useRef(null),[L,g]=Mn.useState(0),C=Mn.useMemo(()=>dE(i),[i]),w=Mn.useMemo(()=>{if(!S)return C;let M=p.trim().toLowerCase();return C.filter((B)=>B.span?S.has(B.span.id):(B.marker?.label??"").toLowerCase().includes(M))},[C,p,S]);Mn.useEffect(()=>{if(!c)return;let M=b.current;if(!M)return;let B=w.findIndex((j)=>j.span?.id===c);if(B===-1)return;let P=B*wi;if(P<M.scrollTop||P+wi>M.scrollTop+M.clientHeight)M.scrollTop=Math.max(0,P-M.clientHeight/2)},[c,w]);let A=Math.max(0,Math.floor(L/wi)-HT),k=Math.min(w.length,Math.ceil((L+cE)/wi)+HT),D=w.slice(A,k);return Ga.jsxDEV("div",{ref:b,onScroll:(M)=>g(M.currentTarget.scrollTop),className:"traces-list",children:[Ga.jsxDEV("div",{style:{height:w.length*wi,position:"relative"},children:Ga.jsxDEV("div",{style:{position:"absolute",top:A*wi,left:0,right:0},children:D.map((M)=>{let B=M.span,P=B!==void 0&&B.id===c,j=M.span?x.category[M.span.kind]:x.marker,Y=M.span?.label??M.marker?.label??"",ce=M.span?.detail,J=M.span?At(M.span.end-M.span.start):"",te=M.span?.kind??M.marker?.kind??"",X=Ga.jsxDEV(Ga.Fragment,{children:[Ga.jsxDEV("span",{className:"traces-kind",style:{"--traces-kind-color":j},children:te},void 0,!1,void 0,this),M.depth>0&&Ga.jsxDEV("span",{className:"traces-row-track mono truncate",title:M.track.label,children:M.track.id},void 0,!1,void 0,this),Ga.jsxDEV("span",{className:"traces-row-label truncate",children:Y},void 0,!1,void 0,this),ce&&Ga.jsxDEV("span",{className:"traces-row-detail truncate",children:ce},void 0,!1,void 0,this),Ga.jsxDEV("span",{className:"traces-row-meta num",children:[M.span?.isError&&Ga.jsxDEV("span",{className:"tone-bad",children:u("common.error")},void 0,!1,void 0,this),Ga.jsxDEV("span",{children:J},void 0,!1,void 0,this),Ga.jsxDEV("span",{children:Ci(M.time-h)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),ae={paddingLeft:12+M.depth*12};return B?Ga.jsxDEV("button",{type:"button",onClick:()=>f(B.id),className:"traces-row","data-selected":P?"true":"false",style:ae,children:X},M.key,!1,void 0,this):Ga.jsxDEV("div",{className:"traces-row","data-static":"true",style:ae,children:X},M.key,!1,void 0,this)})},void 0,!1,void 0,this)},void 0,!1,void 0,this),w.length===0&&Ga.jsxDEV(wt,{title:u("trace.no-matching-events")},void 0,!1,void 0,this)]},void 0,!0,void 0,this)});var Je=Z(ue(),1),fE=[{value:"time",label:u("common.duration"),title:u("trace.mode-time-title")},{value:"turns",label:u("trace.turns"),title:u("trace.mode-turns-title")},{value:"calls",label:u("trace.calls"),title:u("trace.mode-calls-title")}],pE=[{kind:"turn",label:u("common.input")},{kind:"model",label:u("common.model")},{kind:"tool",label:u("trace.tool")},{kind:"subagent",label:u("trace.agent")},{kind:"background",label:u("trace.background")}];function GT({file:l,active:i,onBack:c}){let f=Ft(["trace",l],({signal:Me},ye)=>h1(l,Me,ye),{pollMs:15000,enabled:i}),p=f.stale?null:f.data,[S,h]=Dt.useState("time"),[x,b]=Dt.useState(!0),[L,g]=Dt.useState(null),[C,w]=Dt.useState(!1),[A,k]=Dt.useState(""),[D,M]=Dt.useState(0),[B,P]=Dt.useState(new Set),[j,Y]=Dt.useState(null),ce=Dt.useMemo(()=>p?.tracks??[],[p]),J=Dt.useMemo(()=>OT(ce,S,x),[ce,S,x]),te=Dt.useRef(J),X=Dt.useRef(null);Dt.useEffect(()=>{if(!p)return;if(X.current===p.file)return;X.current=p.file,g(null),k(""),Y(null);let Me=new Set;for(let ye of p.tracks)if((ye.id==="main"?0:ye.id.split("/").length)>=1)Me.add(ye.id);P(Me)},[p]),Dt.useEffect(()=>{let Me=te.current;te.current=J,Y((ye)=>{if(!ye)return ye;let V=Me.toT(ye.u0),Re=Me.toT(ye.u1),oe=J.toU(V),ve=J.toU(Re);return ve-oe>0?{u0:oe,u1:ve}:null})},[J]);let ae=Dt.useMemo(()=>j??{u0:J.domain[0],u1:J.domain[1]},[j,J]),H=Dt.useMemo(()=>{let Me=[];for(let ye of ce)for(let V of ye.spans)Me.push({span:V,track:ye});return Me.sort((ye,V)=>ye.span.start-V.span.start),Me},[ce]),de=Dt.useMemo(()=>{let Me=A.trim().toLowerCase();if(!Me)return[];return H.filter(({span:ye})=>`${ye.label} ${ye.detail??""}`.toLowerCase().includes(Me))},[H,A]),xe=Dt.useMemo(()=>A.trim()?new Set(de.map(({span:Me})=>Me.id)):null,[de,A]),Ce=Dt.useCallback((Me)=>{let ye=J.toU(Me.start),V=J.toU(Me.end);Y((Re)=>{let oe=Re??{u0:J.domain[0],u1:J.domain[1]};if(ye>=oe.u0&&V<=oe.u1)return Re;let ve=oe.u1-oe.u0,G=(ye+V)/2,[_e,Qe]=J.domain,Ue=G-ve/2;if(Ue<_e)Ue=_e;if(Ue+ve>Qe)Ue=Math.max(_e,Qe-ve);return{u0:Ue,u1:Ue+ve}})},[J]),Be=Dt.useCallback((Me)=>{g(Me);let ye=H.find(({span:V})=>V.id===Me);if(ye)Ce(ye.span)},[H,Ce]),ne=Dt.useCallback((Me)=>{g(Me),w(Me!==null)},[]),me=Dt.useCallback((Me)=>{if(de.length===0)return;let ye=((D+Me)%de.length+de.length)%de.length;M(ye),Be(de[ye].span.id)},[de,D,Be]),ke=Dt.useCallback((Me)=>{P((ye)=>{let V=new Set(ye);if(V.has(Me))V.delete(Me);else V.add(Me);return V})},[]),$e=Dt.useMemo(()=>{if(!L)return null;return H.find(({span:Me})=>Me.id===L)??null},[L,H]),xt=Dt.useCallback((Me)=>{let ye=ce.find((Re)=>Re.id===Me),V=ye?.spans[0];if(P((Re)=>{let oe=new Set(Re),ve=ye;while(ve?.parentId)oe.delete(ve.parentId),ve=ce.find((G)=>G.id===ve?.parentId);return oe}),V)Be(V.id)},[ce,Be]),W=Dt.useCallback((Me)=>{if(!Me){P(new Set);return}let ye=new Set;for(let V of ce)if(V.id!=="main")ye.add(V.id);P(ye)},[ce]),ze=Dt.useCallback((Me)=>{Be(Me),w(!0)},[Be]),Ct=Dt.useCallback(()=>w(!1),[]),it=p?.startedAt??0,ct={...f,data:p};return Je.jsxDEV("div",{className:"stack traces-view",children:[Je.jsxDEV("div",{children:Je.jsxDEV("button",{type:"button",className:"btn","data-variant":"ghost","data-size":"sm",onClick:c,children:[Je.jsxDEV(cd,{size:14,"aria-hidden":"true"},void 0,!1,void 0,this),u("trace.sessions")]},void 0,!0,void 0,this)},void 0,!1,void 0,this),Je.jsxDEV(ra,{title:Je.jsxDEV("span",{className:"traces-title truncate",children:p?.title??l.split("/").pop()},void 0,!1,void 0,this),description:p?.cwd?Je.jsxDEV("span",{className:"mono",children:p.cwd},void 0,!1,void 0,this):void 0,actions:Je.jsxDEV("button",{type:"button",className:"btn","data-variant":"ghost","data-icon":"true",onClick:f.refetch,"aria-label":u("trace.refresh"),title:u("trace.refresh"),children:Je.jsxDEV(jl,{size:14,className:f.refreshing?"traces-spin":void 0},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),Je.jsxDEV(Ge,{query:ct,skeleton:Je.jsxDEV(zt,{height:420},void 0,!1,void 0,this),children:(Me)=>Je.jsxDEV(Je.Fragment,{children:[Je.jsxDEV(DT,{summary:Me.summary},void 0,!1,void 0,this),Je.jsxDEV(Ye,{index:1,title:u("trace.timeline"),description:u("trace.timeline-hint"),actions:Je.jsxDEV(Je.Fragment,{children:[Je.jsxDEV("button",{type:"button",className:"btn","data-variant":"ghost","data-size":"sm",onClick:()=>W(!1),children:u("trace.expand-all")},void 0,!1,void 0,this),Je.jsxDEV("button",{type:"button",className:"btn","data-variant":"ghost","data-size":"sm",onClick:()=>W(!0),children:u("trace.collapse-all")},void 0,!1,void 0,this)]},void 0,!0,void 0,this),children:Je.jsxDEV("div",{className:"stack",children:[Je.jsxDEV("div",{className:"traces-toolbar",children:[Je.jsxDEV(_a,{options:fE,value:S,onChange:h,size:"sm","aria-label":u("trace.axis-mode")},void 0,!1,void 0,this),S==="time"&&Je.jsxDEV("label",{className:"traces-check",children:[Je.jsxDEV("input",{type:"checkbox",checked:x,onChange:(ye)=>b(ye.target.checked)},void 0,!1,void 0,this),u("trace.compress-idle")]},void 0,!0,void 0,this),Je.jsxDEV("div",{className:"traces-search",children:[Je.jsxDEV(cr,{value:A,onChange:(ye)=>{k(ye),M(0)},placeholder:u("trace.search-placeholder"),width:200},void 0,!1,void 0,this),A.trim()&&Je.jsxDEV(Je.Fragment,{children:[Je.jsxDEV("span",{className:"num muted traces-match-count",children:de.length===0?"0":`${D%Math.max(de.length,1)+1}/${de.length}`},void 0,!1,void 0,this),Je.jsxDEV("button",{type:"button",className:"btn","data-variant":"ghost","data-size":"sm","data-icon":"true",onClick:()=>me(-1),"aria-label":u("trace.previous-match"),disabled:de.length===0,children:Je.jsxDEV(md,{size:14},void 0,!1,void 0,this)},void 0,!1,void 0,this),Je.jsxDEV("button",{type:"button",className:"btn","data-variant":"ghost","data-size":"sm","data-icon":"true",onClick:()=>me(1),"aria-label":u("trace.next-match"),disabled:de.length===0,children:Je.jsxDEV(Ln,{size:14},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Je.jsxDEV("div",{className:"traces-legend",children:pE.map((ye)=>Je.jsxDEV("span",{className:"traces-legend-item",children:[Je.jsxDEV("span",{className:"swatch",style:{background:`var(${nu[ye.kind]})`}},void 0,!1,void 0,this),ye.label]},ye.kind,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Je.jsxDEV(RT,{tracks:ce,scale:J,viewport:ae,onViewportChange:Y},void 0,!1,void 0,this),Je.jsxDEV(_T,{tracks:ce,scale:J,viewport:ae,onViewportChange:Y,selected:$e,onSelect:ne,matchIds:xe,collapsed:B,onToggleCollapse:ke,traceStart:it},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),Je.jsxDEV(Ye,{index:2,title:u("trace.transcript"),description:u("trace.transcript-description"),flush:!0,children:Je.jsxDEV(FT,{tracks:ce,selection:L,onSelect:ze,search:A,matchIds:xe,traceStart:it},void 0,!1,void 0,this)},void 0,!1,void 0,this),Je.jsxDEV(TT,{toolStats:Me.summary.toolStats,index:3},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),Je.jsxDEV(MT,{span:C?$e?.span??null:null,track:$e?.track??null,onClose:Ct,onOpenChildTrack:xt},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var ea=Z(ue(),1),VT=200;function mE({models:l}){if(l.length===0)return ea.jsxDEV("span",{className:"dim",children:"-"},void 0,!1,void 0,this);return ea.jsxDEV("span",{className:"traces-models",title:l.join(`
236
236
  `),children:[ea.jsxDEV("span",{className:"mono truncate",children:l[0]},void 0,!1,void 0,this),l.length>1&&ea.jsxDEV("span",{className:"badge",children:["+",l.length-1]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function jT({active:l,session:i,onOpenSession:c}){let[f,p]=ki.useState(""),S=Ft(["sessions",VT],({signal:g})=>m1(VT,void 0,g),{pollMs:30000,enabled:l&&i===null}),h=ki.useMemo(()=>{let g=S.data??[],C=f.trim().toLowerCase();if(!C)return g;return g.filter((w)=>(w.title??"").toLowerCase().includes(C)||w.folder.toLowerCase().includes(C)||w.models.some((A)=>A.toLowerCase().includes(C)))},[S.data,f]),x=ki.useMemo(()=>Math.max(0,...h.map((g)=>g.costTotal)),[h]),b=ki.useMemo(()=>[{key:"title",header:u("trace.session"),width:"32%",render:(g)=>ea.jsxDEV(Ha,{primary:g.title??g.file.split("/").pop(),secondary:ea.jsxDEV("span",{className:"mono",children:g.folder.split("/").slice(-2).join("/")},void 0,!1,void 0,this)},void 0,!1,void 0,this),sort:(g)=>(g.title??g.file).toLowerCase()},{key:"models",header:u("common.models"),render:(g)=>ea.jsxDEV(mE,{models:g.models},void 0,!1,void 0,this)},{key:"started",header:u("common.started"),align:"right",render:(g)=>ea.jsxDEV("span",{className:"muted",title:new Date(g.startedAt).toLocaleString(),children:fa(g.startedAt)},void 0,!1,void 0,this),sort:(g)=>g.startedAt},{key:"duration",header:u("common.duration"),align:"right",render:(g)=>ea.jsxDEV("span",{className:"num",children:Ks(g.endedAt-g.startedAt)},void 0,!1,void 0,this),sort:(g)=>g.endedAt-g.startedAt},{key:"requests",header:u("common.requests"),align:"right",render:(g)=>ea.jsxDEV("span",{className:"num",children:z(g.requests)},void 0,!1,void 0,this),sort:(g)=>g.requests},{key:"toolCalls",header:u("trace.tools"),align:"right",render:(g)=>ea.jsxDEV("span",{className:"num",children:z(g.toolCalls)},void 0,!1,void 0,this),sort:(g)=>g.toolCalls},{key:"subagents",header:u("trace.agents"),align:"right",render:(g)=>g.subagents>0?ea.jsxDEV("span",{className:"num",children:z(g.subagents)},void 0,!1,void 0,this):ea.jsxDEV("span",{className:"num dim",children:"0"},void 0,!1,void 0,this),sort:(g)=>g.subagents},{key:"tokens",header:u("common.tokens"),align:"right",render:(g)=>ea.jsxDEV("span",{className:"num",children:Ae(g.totalTokens)},void 0,!1,void 0,this),sort:(g)=>g.totalTokens},{key:"cost",header:u("common.cost"),align:"right",width:150,render:(g)=>ea.jsxDEV(pa,{value:g.costTotal,max:x,display:Ht(g.costTotal,g.unpricedRequests)},void 0,!1,void 0,this),sort:(g)=>g.costTotal}],[x]);if(i!==null)return ea.jsxDEV(GT,{file:i,active:l,onBack:()=>c(null)},void 0,!1,void 0,this);let L=S.data?.length??0;return ea.jsxDEV("div",{className:"stack traces-page",children:[ea.jsxDEV(ra,{title:u("trace.title"),description:u("trace.description")},void 0,!1,void 0,this),ea.jsxDEV(Ye,{title:u("trace.sessions"),description:S.data?f.trim()?u("trace.most-recent-filtered",{shown:z(h.length),total:z(L)}):u("trace.most-recent",{count:z(L)}):void 0,actions:ea.jsxDEV(cr,{value:f,onChange:p,placeholder:u("trace.filter-placeholder"),width:260},void 0,!1,void 0,this),flush:!0,index:0,stale:S.stale,children:ea.jsxDEV(Ge,{query:S,skeleton:ea.jsxDEV(ca,{rows:10},void 0,!1,void 0,this),isEmpty:(g)=>g.length===0,empty:ea.jsxDEV(wt,{title:u("trace.empty-title"),hint:u("trace.empty-hint")},void 0,!1,void 0,this),children:()=>ea.jsxDEV(Xt,{columns:b,rows:h,rowKey:(g)=>g.file,onRowClick:(g)=>c(g.file),initialSort:{key:"started",dir:"desc"},limit:50,empty:ea.jsxDEV(wt,{title:u("trace.no-matching-title"),hint:u("trace.no-matching-hint")},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var Aa=Z(ue(),1);function db(){return Aa.jsxDEV(L1,{children:Aa.jsxDEV(hE,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function hE(){let{section:l,setSection:i,range:c,setRange:f,session:p,setSession:S}=P1(),[h,x]=Ti.useState(null),b=Ti.useCallback(()=>x(null),[]),L=Ti.useRef(new Set);L.current.add(l);let g=(C)=>{let w=C===l;switch(C){case"overview":return Aa.jsxDEV(hT,{active:w,range:c,onRequestClick:x},void 0,!1,void 0,this);case"requests":return Aa.jsxDEV(CT,{active:w,range:c,onRequestClick:x},void 0,!1,void 0,this);case"errors":return Aa.jsxDEV(rT,{active:w,range:c,onRequestClick:x},void 0,!1,void 0,this);case"traces":return Aa.jsxDEV(jT,{active:w,session:p,onOpenSession:S},void 0,!1,void 0,this);case"models":return Aa.jsxDEV(dT,{active:w,range:c},void 0,!1,void 0,this);case"providers":return Aa.jsxDEV(ST,{active:w,range:c},void 0,!1,void 0,this);case"costs":return Aa.jsxDEV(oT,{active:w,range:c},void 0,!1,void 0,this);case"tools":return Aa.jsxDEV(kT,{active:w,range:c},void 0,!1,void 0,this);case"frustration":return Aa.jsxDEV(sT,{active:w,range:c},void 0,!1,void 0,this);case"projects":return Aa.jsxDEV(yT,{active:w,range:c},void 0,!1,void 0,this);case"gain":return Aa.jsxDEV(iT,{active:w,range:c},void 0,!1,void 0,this)}};return Aa.jsxDEV(Aa.Fragment,{children:[Aa.jsxDEV(U1,{section:l,onSectionChange:i,range:c,onRangeChange:f,children:[...L.current].map((C)=>Aa.jsxDEV("div",{hidden:C!==l,children:g(C)},C,!1,void 0,this))},void 0,!1,void 0,this),Aa.jsxDEV(LT,{id:h,onClose:b},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var $T=Z(ue(),1),YT=document.getElementById("root");if(!YT)throw Error("missing #root");XT.createRoot(YT).render($T.jsxDEV(db,{},void 0,!1,void 0,this));