llmtap 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/dashboard/assets/BarChart-C6HDCruv.js +1 -0
  2. package/dist/dashboard/assets/Costs-CbzbCKu_.js +4 -0
  3. package/dist/dashboard/assets/Dashboard-CnMusiwU.js +9 -0
  4. package/dist/dashboard/assets/Models-C1x1xboT.js +1 -0
  5. package/dist/dashboard/assets/{Sessions-IXJPYjKe.js → Sessions-Bh-4XfWy.js} +1 -1
  6. package/dist/dashboard/assets/{Settings-kxBLuIHe.js → Settings-DzwivrGY.js} +2 -2
  7. package/dist/dashboard/assets/StatusDot-CjYDb6xj.js +1 -0
  8. package/dist/dashboard/assets/TraceDetail-C0tQsZ-6.js +17 -0
  9. package/dist/dashboard/assets/Traces-D6m-Ef3q.js +1 -0
  10. package/dist/dashboard/assets/{generateCategoricalChart-CylgFInn.js → chart-styles-BD7W97c9.js} +32 -32
  11. package/dist/dashboard/assets/{clock-CSGov78l.js → clock-BEYeaSdD.js} +1 -1
  12. package/dist/dashboard/assets/{coins-RIVI5-1a.js → coins-BmXTNwva.js} +1 -1
  13. package/dist/dashboard/assets/constants-BzCnW506.js +1 -0
  14. package/dist/dashboard/assets/content-DqloWqre.js +2 -0
  15. package/dist/dashboard/assets/{download-PygxZ--5.js → download-B-39NUBC.js} +1 -1
  16. package/dist/dashboard/assets/format-CNuIwzac.js +1 -0
  17. package/dist/dashboard/assets/{gauge-BBNKtqFH.js → gauge-CfqhcKwk.js} +1 -1
  18. package/dist/dashboard/assets/index-BuSUiwyD.css +1 -0
  19. package/dist/dashboard/assets/index-M3DwcRrc.js +66 -0
  20. package/dist/dashboard/assets/{layers--K2XRXAx.js → layers-BQ0MpYqk.js} +1 -1
  21. package/dist/dashboard/assets/{orbit-2k6lSwt7.js → orbit-eg7lcPsM.js} +1 -1
  22. package/dist/dashboard/assets/provider-colors-DcHYMgVv.js +1 -0
  23. package/dist/dashboard/assets/{zap-Ccrxhk2Q.js → zap-DjNN7wJp.js} +1 -1
  24. package/dist/dashboard/index.html +2 -2
  25. package/dist/index.js +14 -0
  26. package/dist/index.js.map +1 -1
  27. package/package.json +17 -25
  28. package/dist/dashboard/assets/BarChart-N8X7TKRf.js +0 -1
  29. package/dist/dashboard/assets/Costs-BhWdS2kw.js +0 -4
  30. package/dist/dashboard/assets/Dashboard-DnHLwJsN.js +0 -9
  31. package/dist/dashboard/assets/Models-5jWcyfAk.js +0 -1
  32. package/dist/dashboard/assets/TraceDetail-DdKFps7x.js +0 -18
  33. package/dist/dashboard/assets/Traces-Cv9L_xTe.js +0 -2
  34. package/dist/dashboard/assets/chevron-down-B0xosrpl.js +0 -1
  35. package/dist/dashboard/assets/format-BiBDo3KS.js +0 -1
  36. package/dist/dashboard/assets/index-BBr9_AHg.js +0 -22
  37. package/dist/dashboard/assets/index-CIGK6hiV.css +0 -1
  38. package/dist/dashboard/assets/message-square-DdcqfsnD.js +0 -1
  39. package/dist/dashboard/assets/search-BwbP84dP.js +0 -1
@@ -1,18 +0,0 @@
1
- import{c as f,h as ce,r as h,j as e,L as de,A as Y,m as M,i as pe,b as xe,k as me,g as he}from"./index-BBr9_AHg.js";import{u as ue,P as ge,b as w,c as g}from"./format-BiBDo3KS.js";import{A as be,C as L}from"./chevron-down-B0xosrpl.js";import{C as O,D as fe,a as je}from"./download-PygxZ--5.js";import{L as P}from"./layers--K2XRXAx.js";import{Z as ye}from"./zap-Ccrxhk2Q.js";import{C as Q}from"./coins-RIVI5-1a.js";import{C as E}from"./clock-CSGov78l.js";import{O as Ne}from"./orbit-2k6lSwt7.js";import{C as X,M as W}from"./message-square-DdcqfsnD.js";const ve=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],we=f("chevron-right",ve);const ke=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Ce=f("circle-check",ke);const $e=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],Te=f("code",$e);const Me=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Se=f("file-text",Me);const _e=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],Ie=f("hash",_e);const Re=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],Le=f("image",Re);const Oe=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],G=f("play",Oe);const Pe=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Ee=f("terminal",Pe);const Ae=[["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"}]],De=f("wrench",Ae);function He(t){const a=new Map,n=[];for(const l of t)a.set(l.spanId,{span:l,children:[]});for(const l of t){const i=a.get(l.spanId);i&&(l.parentSpanId&&a.has(l.parentSpanId)?a.get(l.parentSpanId)?.children.push(i):n.push(i))}const d=l=>{l.sort((i,s)=>i.span.startTime-s.span.startTime);for(const i of l)d(i.children)};return d(n),n}function A(t){return t.children.reduce((a,n)=>a+1+A(n),0)}function Fe(){const[t,a]=h.useState(null);function n(d,l){navigator.clipboard.writeText(d),a(l),setTimeout(()=>a(null),2e3)}return{copied:t,copy:n}}function v({text:t,label:a,copied:n,onCopy:d}){return e.jsx("button",{type:"button",onClick:l=>{l.stopPropagation(),d(t,a)},className:"rounded-lg border border-white/8 bg-white/4 p-1.5 text-slate-500 transition-colors hover:text-white",title:"Copy to clipboard",children:n===a?e.jsx(O,{className:"h-3 w-3 text-emerald-300"}):e.jsx(je,{className:"h-3 w-3"})})}function ze({provider:t}){const a={openai:"bg-emerald-400/12 text-emerald-200 border-emerald-400/20",anthropic:"bg-amber-300/12 text-amber-200 border-amber-300/20",google:"bg-sky-400/12 text-sky-200 border-sky-400/20",deepseek:"bg-cyan-400/12 text-cyan-200 border-cyan-400/20",groq:"bg-fuchsia-400/12 text-fuchsia-200 border-fuchsia-400/20"};return e.jsx("span",{className:`rounded-full border px-2.5 py-1 text-[10px] font-bold uppercase tracking-[0.18em] ${a[t]??"border-white/10 bg-white/8 text-slate-300"}`,children:t})}function b({icon:t,label:a,value:n}){return e.jsxs("div",{className:"rounded-2xl border border-white/8 bg-white/4 p-4",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-[0.16em] text-slate-500",children:[e.jsx(t,{className:"h-3 w-3"}),a]}),e.jsx("div",{className:"font-mono text-sm font-semibold text-slate-100",children:n})]})}function Be({role:t,type:a}){const n={system:"bg-purple-400/10 text-purple-200 border-purple-400/16",user:"bg-sky-400/10 text-sky-200 border-sky-400/16",assistant:"bg-emerald-400/10 text-emerald-200 border-emerald-400/16",tool:"bg-amber-300/10 text-amber-200 border-amber-300/16",function:"bg-amber-300/10 text-amber-200 border-amber-300/16"},d=a==="input"?"bg-sky-400/10 text-sky-200 border-sky-400/16":"bg-emerald-400/10 text-emerald-200 border-emerald-400/16";return e.jsx("span",{className:`rounded-full border px-2.5 py-1 text-[10px] font-bold capitalize tracking-[0.16em] ${n[t]??d}`,children:t})}function k(t){return t?typeof t=="string"?t:t.filter(a=>a.type==="text"&&!!a.text).map(a=>a.text).join(`
2
- `):""}function V(t){return!t||typeof t=="string"?!1:t.some(a=>a.type==="image_url"||a.type==="image")}function D(t){return t.map(a=>a.type==="image_url"&&a.image_url?.url?a.image_url.url:a.type==="image"&&a.source?.data?`data:${a.source.media_type||"image/png"};base64,${a.source.data}`:null).filter(a=>{if(!a)return!1;if(a.startsWith("data:image/"))return!0;try{const n=new URL(a);return n.protocol==="http:"||n.protocol==="https:"}catch{return!1}})}function qe(t){const a=k(t);let n=a?Math.ceil(a.length/4):0;if(t&&typeof t!="string"){const d=t.filter(l=>l.type==="image_url"||l.type==="image").length;n+=d*85}return n}function Z({message:t,type:a,copied:n,onCopy:d}){const l=t.content,i=k(l),s=l&&typeof l!="string"?D(l):[],c=a==="input"?"border-white/8":"border-emerald-400/10",o=`msg-${a}-${t.role}-${i.slice(0,20)}`;return e.jsxs("div",{className:`rounded-2xl border ${c} bg-white/4 p-4`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Be,{role:t.role,type:a}),t.name&&e.jsx("span",{className:"font-mono text-[10px] text-slate-500",children:t.name}),s.length>0&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-purple-400/16 bg-purple-400/10 px-2 py-0.5 text-[10px] font-bold uppercase tracking-[0.12em] text-purple-200",children:[e.jsx(Le,{className:"h-2.5 w-2.5"}),s.length," image",s.length>1?"s":""]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-mono text-[10px] text-slate-600",children:["~",qe(l)," tok"]}),i&&e.jsx(v,{text:i,label:o,copied:n,onCopy:d})]})]}),i&&e.jsx("pre",{className:"mt-2.5 whitespace-pre-wrap font-mono text-xs leading-relaxed text-slate-200",children:Ye(i)}),s.length>0&&e.jsx("div",{className:"mt-2.5 flex flex-wrap gap-2",children:s.map((p,j)=>e.jsxs("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"group relative overflow-hidden rounded-lg border border-white/10 bg-slate-950/60 transition-colors hover:border-white/20",children:[e.jsx("img",{src:p,alt:`Image ${j+1}`,className:"max-h-48 max-w-64 object-contain",loading:"lazy"}),e.jsx("span",{className:"absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 transition-opacity group-hover:opacity-100",children:e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-widest text-white",children:"Open"})})]},j))})]})}function Ke({span:t,copied:a,onCopy:n}){const d=t.inputMessages?.length??0,l=t.outputMessages?.length??0,[i,s]=h.useState(d>3),[c,o]=h.useState(l>3);return e.jsx(M.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.2},className:"overflow-hidden",children:e.jsxs("div",{className:"mx-4 mb-4 space-y-5 rounded-[24px] border border-white/8 bg-[linear-gradient(180deg,rgba(8,15,28,0.96),rgba(4,8,18,0.98))] p-5 text-sm",children:[e.jsx("div",{className:"flex items-center justify-between gap-2",children:e.jsxs("div",{className:"grid flex-1 grid-cols-2 gap-3 md:grid-cols-4",children:[e.jsx(b,{icon:Ie,label:"Model",value:t.responseModel??t.requestModel??"-"}),e.jsx(b,{icon:P,label:"Tokens",value:`${t.inputTokens} in / ${t.outputTokens} out`}),e.jsx(b,{icon:Q,label:"Cost",value:w(t.totalCost)}),e.jsx(b,{icon:E,label:"Duration",value:t.duration?g(t.duration):"-"})]})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(v,{text:t.spanId,label:"spanId",copied:a,onCopy:n}),e.jsxs("span",{className:"font-mono text-[10px] text-slate-500",children:["span: ",t.spanId.slice(0,12),"..."]}),t.sessionId&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-slate-600",children:"|"}),e.jsxs("span",{className:"font-mono text-[10px] text-slate-500",children:["session: ",t.sessionId]})]}),t.temperature!==void 0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-slate-600",children:"|"}),e.jsxs("span",{className:"font-mono text-[10px] text-slate-500",children:["temp: ",t.temperature]})]}),t.topP!==void 0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-slate-600",children:"|"}),e.jsxs("span",{className:"font-mono text-[10px] text-slate-500",children:["top_p: ",t.topP]})]}),t.maxTokens!==void 0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-slate-600",children:"|"}),e.jsxs("span",{className:"font-mono text-[10px] text-slate-500",children:["max_tokens: ",t.maxTokens]})]})]}),t.status==="error"&&e.jsxs("div",{className:"rounded-2xl border border-rose-400/18 bg-rose-400/6 p-4",children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-bold uppercase tracking-[0.16em] text-rose-300",children:[e.jsx(X,{className:"h-4 w-4"}),t.errorType??"error"]}),t.errorMessage&&e.jsx(v,{text:t.errorMessage,label:"error",copied:a,onCopy:n})]}),e.jsx("div",{className:"font-mono text-xs leading-relaxed text-rose-200/70",children:t.errorMessage})]}),t.inputMessages&&t.inputMessages.length>0&&e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>s(p=>!p),className:"mb-3 flex w-full items-center gap-1.5 text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500 transition-colors hover:text-slate-300",children:[e.jsx(L,{className:`h-3.5 w-3.5 transition-transform ${i?"-rotate-90":""}`}),e.jsx(W,{className:"h-3.5 w-3.5"}),"Input messages (",t.inputMessages.length,")"]}),!i&&e.jsx("div",{className:"space-y-2",children:t.inputMessages.map((p,j)=>e.jsx(Z,{message:p,type:"input",copied:a,onCopy:n},`in-${p.role}-${j}`))})]}),t.outputMessages&&t.outputMessages.length>0&&e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>o(p=>!p),className:"mb-3 flex w-full items-center gap-1.5 text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500 transition-colors hover:text-slate-300",children:[e.jsx(L,{className:`h-3.5 w-3.5 transition-transform ${c?"-rotate-90":""}`}),e.jsx(W,{className:"h-3.5 w-3.5"}),"Output messages (",t.outputMessages.length,")"]}),!c&&e.jsx("div",{className:"space-y-2",children:t.outputMessages.map((p,j)=>e.jsx(Z,{message:p,type:"output",copied:a,onCopy:n},`out-${p.role}-${j}`))})]}),t.toolCalls&&t.toolCalls.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"mb-3 flex items-center gap-1.5 text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500",children:[e.jsx(De,{className:"h-3.5 w-3.5"}),"Tool calls (",t.toolCalls.length,")"]}),e.jsx("div",{className:"space-y-2",children:t.toolCalls.map(p=>e.jsxs("div",{className:"rounded-2xl border border-amber-300/10 bg-white/4 p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"rounded-full border border-amber-300/16 bg-amber-300/10 px-2.5 py-1 text-[10px] font-bold tracking-[0.16em] text-amber-200",children:p.name}),e.jsx(v,{text:p.arguments,label:`tool-${p.id}`,copied:a,onCopy:n})]}),e.jsx("pre",{className:"mt-2.5 overflow-x-auto font-mono text-xs leading-relaxed text-slate-200",children:ee(p.arguments)}),p.result&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"my-2 border-t border-white/6"}),e.jsx("div",{className:"mb-1 text-[10px] font-bold uppercase tracking-[0.16em] text-slate-600",children:"Result"}),e.jsx("pre",{className:"overflow-x-auto font-mono text-xs leading-relaxed text-slate-300",children:p.result})]})]},p.id))})]})]})})}function ee(t){try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}}function Je(t){const a=t.providerName?.toLowerCase()??"",n=t.requestModel??t.responseModel??"unknown",d=(t.inputMessages??[]).map(s=>({role:s.role,content:typeof s.content=="string"?s.content:s.content??""})),i=JSON.stringify({model:n,messages:d}).replace(/'/g,"'\\''");return a==="openai"?`curl https://api.openai.com/v1/chat/completions \\
3
- -H "Authorization: Bearer $OPENAI_API_KEY" \\
4
- -H "Content-Type: application/json" \\
5
- -d '${i}'`:a==="anthropic"?`curl https://api.anthropic.com/v1/messages \\
6
- -H "x-api-key: $ANTHROPIC_API_KEY" \\
7
- -H "anthropic-version: 2023-06-01" \\
8
- -H "Content-Type: application/json" \\
9
- -d '${JSON.stringify({model:n,max_tokens:t.maxTokens??1024,messages:d.filter(o=>o.role!=="system"),...d.find(o=>o.role==="system")?{system:d.find(o=>o.role==="system").content}:{}}).replace(/'/g,"'\\''")}'`:a==="google"?`curl "https://generativelanguage.googleapis.com/v1beta/models/${n}:generateContent?key=$GOOGLE_API_KEY" \\
10
- -H "Content-Type: application/json" \\
11
- -d '${i}'`:`curl https://api.example.com/v1/chat/completions \\
12
- -H "Authorization: Bearer $API_KEY" \\
13
- -H "Content-Type: application/json" \\
14
- -d '${i}'`}function Ue(t,a,n,d,l,i){const s=[];s.push("# Trace Report"),s.push(""),s.push(`**Trace ID:** \`${t}\``),s.push(`**Status:** ${i?"Error":"Stable"}`),s.push(`**Total Spans:** ${a.length}`),s.push(`**Total Tokens:** ${n.toLocaleString()}`),s.push(`**Total Cost:** ${w(d)}`),s.push(`**Duration:** ${g(l)}`),s.push(""),s.push("---"),s.push("");for(const c of a){if(s.push(`## Span: ${c.name}`),s.push(""),s.push("| Field | Value |"),s.push("|-------|-------|"),s.push(`| Span ID | \`${c.spanId}\` |`),s.push(`| Provider | ${c.providerName} |`),s.push(`| Model | ${c.responseModel??c.requestModel??"-"} |`),s.push(`| Operation | ${c.operationName} |`),s.push(`| Tokens | ${c.inputTokens} in / ${c.outputTokens} out |`),s.push(`| Cost | ${w(c.totalCost)} |`),s.push(`| Duration | ${c.duration?g(c.duration):"-"} |`),s.push(`| Status | ${c.status} |`),s.push(""),c.inputMessages&&c.inputMessages.length>0){s.push("### Input Messages"),s.push("");for(const o of c.inputMessages)s.push(`**[${o.role}]${o.name?` (${o.name})`:""}**`),s.push(""),s.push(k(o.content)||"_empty_"),V(o.content)&&s.push(`
15
- _[${D(o.content).length} image(s) attached]_`),s.push("")}if(c.outputMessages&&c.outputMessages.length>0){s.push("### Output Messages"),s.push("");for(const o of c.outputMessages)s.push(`**[${o.role}]${o.name?` (${o.name})`:""}**`),s.push(""),s.push(k(o.content)||"_empty_"),V(o.content)&&s.push(`
16
- _[${D(o.content).length} image(s) attached]_`),s.push("")}if(c.toolCalls&&c.toolCalls.length>0){s.push("### Tool Calls"),s.push("");for(const o of c.toolCalls)s.push(`**${o.name}** (\`${o.id}\`)`),s.push(""),s.push("```json"),s.push(ee(o.arguments)),s.push("```"),o.result&&(s.push(""),s.push("Result:"),s.push("```"),s.push(o.result),s.push("```")),s.push("")}s.push("---"),s.push("")}return s.join(`
17
- `)}function Ye(t){const a=/```(\w*)\n?([\s\S]*?)```/g,n=[];let d=0,l,i=0;for(;(l=a.exec(t))!==null;){l.index>d&&n.push(e.jsx("span",{children:t.slice(d,l.index)},i++));const s=l[1]||"",c=l[2];n.push(e.jsxs("span",{className:"my-1.5 block rounded-lg border border-white/8 bg-slate-950/80 px-3 py-2",children:[s&&e.jsxs("span",{className:"mb-1 flex items-center gap-1 text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500",children:[e.jsx(Te,{className:"h-3 w-3"}),s]}),e.jsx("span",{className:"block font-mono text-[11px] leading-relaxed text-emerald-200/80",children:c})]},i++)),d=l.index+l[0].length}return d<t.length&&n.push(e.jsx("span",{children:t.slice(d)},i++)),n.length===0?t:n}function nt(){const{traceId:t}=ce(),[a,n]=h.useState(null),[d,l]=h.useState({}),{copied:i,copy:s}=Fe(),[c,o]=h.useState(!1),[p,j]=h.useState(""),[H,F]=h.useState(!1),[y,C]=h.useState(null),[z,$]=h.useState(null),[S,te]=h.useState(null),{data:se,isLoading:ae}=ue({queryKey:["trace",t],queryFn:()=>he(t),enabled:!!t}),x=se?.spans??[],_=h.useMemo(()=>He(x),[x]),I=x.length>0?Math.min(...x.map(r=>r.startTime)):0,N=(x.length>0?Math.max(...x.map(r=>r.endTime??r.startTime)):0)-I||1,B=x.reduce((r,u)=>r+u.totalTokens,0),q=x.reduce((r,u)=>r+u.totalCost,0),R=x.some(r=>r.status==="error");function re(){const r=new Blob([JSON.stringify(x,null,2)],{type:"application/json"}),u=URL.createObjectURL(r),m=document.createElement("a");m.href=u,m.download=`trace-${t?.slice(0,12)}.json`,document.body.appendChild(m),m.click(),document.body.removeChild(m),URL.revokeObjectURL(u)}async function ne(){if(!(!S||!p.trim())){F(!0),$(null),C(null);try{const r=await me(S,p.trim());C(r)}catch(r){$(r instanceof Error?r.message:String(r))}finally{F(!1)}}}function le(r){te(r),o(!0),C(null),$(null)}const K=(r,u=0)=>{const m=r.span.spanId===a,J=r.children.length>0,U=d[r.span.spanId]??!1,oe=(r.span.startTime-I)/N*100,ie=Math.max(((r.span.endTime??r.span.startTime)-r.span.startTime)/N*100,1);return e.jsxs(h.Fragment,{children:[e.jsx("div",{className:"border-t border-white/6 first:border-t-0",children:e.jsxs("div",{className:"flex items-start gap-2 px-4 py-3 sm:px-5",children:[e.jsx("div",{className:"flex items-center",style:{paddingLeft:`${u*22}px`},children:J?e.jsx("button",{type:"button",onClick:()=>l(T=>({...T,[r.span.spanId]:!T[r.span.spanId]})),className:"flex h-8 w-8 items-center justify-center rounded-full border border-white/8 bg-white/4 text-slate-400 transition-colors hover:text-white",children:e.jsx(we,{className:`h-4 w-4 transition-transform ${U?"":"rotate-90"}`})}):e.jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full border border-white/8 bg-white/4 text-slate-500",children:e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-slate-500"})})}),e.jsxs("button",{type:"button",onClick:()=>n(m?null:r.span.spanId),className:`grid min-w-0 flex-1 gap-3 rounded-[22px] px-3 py-3 text-left transition-colors sm:grid-cols-[minmax(0,320px)_minmax(0,1fr)_88px] sm:items-center ${m?"bg-white/8":"hover:bg-white/4"}`,children:[e.jsx("div",{className:"min-w-0",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"relative flex h-3.5 w-3.5 items-center justify-center",children:[e.jsx("span",{className:`absolute inset-0 rounded-full ${r.span.status==="error"?"bg-rose-400/25":"bg-emerald-400/25"}`}),e.jsx("span",{className:`relative h-2 w-2 rounded-full ${r.span.status==="error"?"bg-rose-400":"bg-emerald-300"}`})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium text-white",children:r.span.name}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2.5",children:[e.jsx(ze,{provider:r.span.providerName}),e.jsx("span",{className:"font-mono text-[10px] uppercase tracking-[0.16em] text-slate-500",children:r.span.operationName}),J?e.jsxs("span",{className:"font-mono text-[10px] uppercase tracking-[0.16em] text-slate-500",children:[A(r)," child",A(r)===1?"":"ren"]}):null]})]})]})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between text-[10px] uppercase tracking-[0.16em] text-slate-500",children:[e.jsxs("span",{children:[Math.round(r.span.startTime-I),"ms"]}),e.jsx("span",{children:r.span.duration?g(r.span.duration):"instant"})]}),e.jsx("div",{className:"relative h-8 overflow-hidden rounded-full bg-slate-950/90",children:e.jsx(M.div,{className:`absolute bottom-1 top-1 rounded-full ${r.span.status==="error"?"bg-[linear-gradient(90deg,#fb7185,#f97316)]":"bg-[linear-gradient(90deg,#34d399,#38bdf8)]"}`,style:{left:`${oe}%`,minWidth:"6px"},initial:{width:0},animate:{width:`${ie}%`}})})]}),e.jsxs("div",{className:"text-right font-mono text-[11px] text-slate-400",children:[e.jsx("div",{className:"text-slate-200",children:w(r.span.totalCost)}),e.jsxs("div",{children:[r.span.totalTokens.toLocaleString()," tok"]})]})]})]})}),e.jsx(Y,{children:m?e.jsx(Ke,{span:r.span,copied:i,onCopy:s}):null}),!U&&r.children.map(T=>K(T,u+1))]},r.span.spanId)};return ae?e.jsxs("div",{className:"mx-auto max-w-[1500px] space-y-6",children:[e.jsx("div",{className:"skeleton-panel h-44 rounded-[28px]"}),e.jsx("div",{className:"skeleton-panel h-28 rounded-[24px]"}),e.jsx("div",{className:"skeleton-panel h-72 rounded-[24px]"})]}):e.jsxs(ge,{eyebrow:"Trace Console",title:t?`Trace ${t.slice(0,12)}...`:"Trace detail",description:"Inspect the nested execution tree, timing offsets, token pressure, and payloads for a single trace without losing the operator surface.",aside:e.jsxs("div",{className:"insight-panel",children:[e.jsx(xe,{}),e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsxs("div",{className:"rounded-2xl border border-white/8 bg-white/4 p-4",children:[e.jsx("div",{className:"hud-label",children:"Current status"}),e.jsx("div",{className:"mt-2 flex items-center gap-2 text-base font-medium text-white",children:R?e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"h-4 w-4 text-rose-300"}),"Error state"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ce,{className:"h-4 w-4 text-emerald-300"}),"Stable"]})})]}),e.jsxs("div",{className:"rounded-2xl border border-white/8 bg-white/4 p-4",children:[e.jsx("div",{className:"hud-label",children:"Hierarchy"}),e.jsxs("div",{className:"mt-2 text-base font-medium text-white",children:[_.length," root spans"]}),e.jsxs("div",{className:"mt-1 text-sm text-slate-400",children:[g(N)," elapsed from first to last event"]})]})]})]}),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(de,{to:"/",className:"status-chip transition-colors hover:text-white",children:[e.jsx(be,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Back to overview"})]}),e.jsx("span",{className:"truncate font-mono text-xs text-slate-500",children:t}),e.jsx(v,{text:t??"",label:"traceId",copied:i,onCopy:s})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[x.length>0&&e.jsxs("button",{type:"button",onClick:()=>{const r=x[0];s(Je(r),"curl")},className:"status-chip transition-colors hover:border-white/16 hover:bg-white/8",children:[i==="curl"?e.jsx(O,{className:"h-3.5 w-3.5 text-emerald-300"}):e.jsx(Ee,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:i==="curl"?"Copied!":"Copy as cURL"})]}),x.length>0&&e.jsxs("button",{type:"button",onClick:()=>{s(Ue(t??"",x,B,q,N,R),"markdown")},className:"status-chip transition-colors hover:border-white/16 hover:bg-white/8",children:[i==="markdown"?e.jsx(O,{className:"h-3.5 w-3.5 text-emerald-300"}):e.jsx(Se,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:i==="markdown"?"Copied!":"Copy as Markdown"})]}),e.jsxs("button",{type:"button",onClick:re,className:"status-chip transition-colors hover:border-white/16 hover:bg-white/8",children:[e.jsx(fe,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Export JSON"})]}),x.length>0&&e.jsxs("button",{type:"button",onClick:()=>le(x[0].spanId),className:"status-chip border-emerald-400/20 bg-emerald-400/8 transition-colors hover:border-emerald-400/30 hover:bg-emerald-400/14",children:[e.jsx(G,{className:"h-3.5 w-3.5 text-emerald-300"}),e.jsx("span",{children:"Replay"})]})]})]}),e.jsx("div",{className:"dashboard-shell rounded-[26px] px-5 py-5",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-5",children:[e.jsx(b,{icon:P,label:"Spans",value:String(x.length)}),e.jsx(b,{icon:ye,label:"Tokens",value:B.toLocaleString()}),e.jsx(b,{icon:Q,label:"Cost",value:w(q)}),e.jsx(b,{icon:E,label:"Duration",value:x.length>0?g(N):"-"}),e.jsx(b,{icon:Ne,label:"Status",value:R?"Error":"Stable"})]})}),e.jsxs("div",{className:"dashboard-shell overflow-hidden rounded-[26px]",children:[e.jsxs("div",{className:"flex items-center gap-2.5 border-b border-white/6 px-5 py-4",children:[e.jsx(E,{className:"h-4 w-4 text-sky-300"}),e.jsx("h2",{className:"text-xl font-semibold tracking-[-0.04em] text-white",children:"Trace hierarchy"}),e.jsxs("span",{className:"ml-auto text-xs font-mono tracking-[0.18em] text-slate-500",children:[g(N)," total"]})]}),_.length>0?e.jsx("div",{className:"py-2",children:_.map(r=>K(r))}):e.jsxs("div",{className:"empty-state h-[280px]",children:[e.jsx(P,{className:"h-8 w-8 text-slate-500"}),e.jsx("div",{className:"text-base font-medium text-white",children:"No spans found for this trace"})]})]}),e.jsx(Y,{children:c&&e.jsxs(e.Fragment,{children:[e.jsx(M.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm",onClick:()=>o(!1)}),e.jsxs(M.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},transition:{type:"spring",bounce:.15,duration:.4},className:"fixed left-1/2 top-1/2 z-50 w-full max-w-2xl -translate-x-1/2 -translate-y-1/2 rounded-[24px] border border-white/10 bg-[linear-gradient(180deg,rgba(12,18,32,0.98),rgba(4,8,18,0.99))] p-6 shadow-[0_40px_100px_rgba(0,0,0,0.5)]",children:[e.jsxs("div",{className:"mb-5 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-2xl border border-emerald-400/20 bg-emerald-400/8",children:e.jsx(G,{className:"h-4.5 w-4.5 text-emerald-300"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-white",children:"Trace Replay"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Re-send the same prompts and compare responses"})]})]}),e.jsx("button",{onClick:()=>o(!1),className:"flex h-8 w-8 items-center justify-center rounded-xl border border-white/8 bg-white/5 text-slate-400 transition-colors hover:text-white",children:e.jsx(L,{className:"h-4 w-4"})})]}),!y&&!H&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"rounded-xl border border-amber-400/20 bg-amber-500/8 p-3 text-xs text-amber-200/80",children:"Your API key is sent directly to the provider and is never stored by LLMTap."}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block text-xs font-medium text-slate-400",children:"Provider API Key"}),e.jsx("input",{type:"password",value:p,onChange:r=>j(r.target.value),placeholder:"sk-... or anthropic key",className:"w-full rounded-xl border border-white/10 bg-white/5 px-4 py-3 text-sm text-white placeholder:text-slate-600 focus:border-emerald-400/30 focus:outline-none"})]}),z&&e.jsx("div",{className:"rounded-xl border border-rose-400/20 bg-rose-500/8 p-3 text-sm text-rose-200",children:z}),e.jsx("button",{type:"button",disabled:!p.trim(),onClick:ne,className:"w-full rounded-xl bg-emerald-500 px-4 py-3 text-sm font-semibold text-white transition-colors hover:bg-emerald-400 disabled:cursor-not-allowed disabled:opacity-40",children:"Send Replay Request"})]}),H&&e.jsxs("div",{className:"flex flex-col items-center gap-3 py-12",children:[e.jsx(pe,{className:"h-8 w-8 animate-spin text-emerald-300"}),e.jsxs("p",{className:"text-sm text-slate-400",children:["Replaying against ",x[0]?.providerName," API..."]})]}),y&&(()=>{const r=x.find(m=>m.spanId===S)??x[0],u=r?.outputMessages?.map(m=>k(m.content)).join(`
18
- `)??"";return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[e.jsxs("div",{className:"rounded-xl border border-white/8 bg-white/4 p-3",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-slate-500",children:"Tokens"}),e.jsxs("div",{className:"mt-1 font-mono text-sm text-white",children:[r.totalTokens," ",e.jsx("span",{className:"text-slate-500",children:"vs"})," ",y.totalTokens]})]}),e.jsxs("div",{className:"rounded-xl border border-white/8 bg-white/4 p-3",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-slate-500",children:"Duration"}),e.jsxs("div",{className:"mt-1 font-mono text-sm text-white",children:[g(r.duration??0)," ",e.jsx("span",{className:"text-slate-500",children:"vs"})," ",g(y.duration)]})]}),e.jsxs("div",{className:"rounded-xl border border-white/8 bg-white/4 p-3",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-slate-500",children:"Model"}),e.jsx("div",{className:"mt-1 truncate font-mono text-xs text-white",children:y.responseModel})]})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-xs font-semibold uppercase tracking-[0.16em] text-slate-500",children:"Original Response"}),e.jsx("div",{className:"max-h-[300px] overflow-y-auto rounded-xl border border-white/8 bg-white/4 p-3 text-sm leading-6 text-slate-300",children:u||e.jsx("span",{className:"text-slate-600",children:"No content captured"})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-xs font-semibold uppercase tracking-[0.16em] text-emerald-400/80",children:"Replay Response"}),e.jsx("div",{className:"max-h-[300px] overflow-y-auto rounded-xl border border-emerald-400/12 bg-emerald-400/4 p-3 text-sm leading-6 text-slate-300",children:y.content||e.jsx("span",{className:"text-slate-600",children:"Empty response"})})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{C(null),$(null)},className:"flex-1 rounded-xl border border-white/10 bg-white/5 px-4 py-2.5 text-sm text-slate-300 transition-colors hover:bg-white/10",children:"Replay Again"}),e.jsx("button",{type:"button",onClick:()=>o(!1),className:"flex-1 rounded-xl bg-emerald-500 px-4 py-2.5 text-sm font-semibold text-white transition-colors hover:bg-emerald-400",children:"Done"})]})]})})()]})]})})]})}export{nt as default};
@@ -1,2 +0,0 @@
1
- import{c as Q,u as oe,r as i,j as e,A as O,m as I,X as U,C as de,D as ce,L as xe,g as A,d as me}from"./index-BBr9_AHg.js";import{u as he,P as pe,b as S,d as B,c as C,a as ee}from"./format-BiBDo3KS.js";import{C as ue,M as be}from"./message-square-DdcqfsnD.js";import{Z as je}from"./zap-Ccrxhk2Q.js";import{S as ge,A as G,C as fe,a as Ne,b as se}from"./search-BwbP84dP.js";import{C as ve,A as we}from"./chevron-down-B0xosrpl.js";import{C as ye}from"./clock-CSGov78l.js";import{L as ke}from"./layers--K2XRXAx.js";const Se=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],K=Q("columns-2",Se);const Ce=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],R=Q("square-check-big",Ce);const Te=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],W=Q("square",Te),J=[25,50,100,200],Y=[{value:1,label:"1h"},{value:6,label:"6h"},{value:24,label:"24h"},{value:168,label:"7d"},{value:720,label:"30d"}];function P({status:s}){const a=s==="error";return e.jsxs("span",{className:"relative flex h-3.5 w-3.5 items-center justify-center",children:[e.jsx("span",{className:`absolute inset-0 rounded-full ${a?"bg-rose-400/25":"bg-emerald-400/25"}`}),e.jsx("span",{className:`relative h-2 w-2 rounded-full ${a?"bg-rose-400":"bg-emerald-300"}`})]})}function De({trace:s,onClose:a}){const h=s.totalDuration??(s.endTime?s.endTime-s.startTime:0);return e.jsxs(I.aside,{initial:{x:"100%",opacity:0},animate:{x:0,opacity:1},exit:{x:"100%",opacity:0},transition:{type:"spring",bounce:.12,duration:.45},className:"fixed inset-y-0 right-0 z-50 flex w-full max-w-md flex-col border-l border-white/8 bg-[rgba(6,10,22,0.97)] shadow-[−40px_0_80px_rgba(0,0,0,0.5)] backdrop-blur-xl",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-white/6 px-5 py-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"hud-label",children:"Quick preview"}),e.jsx("h3",{className:"mt-1 truncate text-lg font-semibold tracking-[-0.04em] text-white",children:s.name})]}),e.jsx("button",{type:"button",onClick:a,className:"flex h-9 w-9 items-center justify-center rounded-xl border border-white/8 bg-white/4 text-slate-400 transition-colors hover:bg-white/8 hover:text-white",children:e.jsx(U,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-5",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-2xl border border-white/6 bg-white/4 p-4",children:[e.jsx("div",{className:"hud-label",children:"Trace ID"}),e.jsx("div",{className:"mt-1 break-all font-mono text-sm text-slate-300",children:s.traceId})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"rounded-2xl border border-white/6 bg-white/4 p-4",children:[e.jsx("div",{className:"hud-label",children:"Status"}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx(P,{status:s.status}),e.jsx("span",{className:`text-sm font-medium ${s.status==="error"?"text-rose-300":"text-emerald-300"}`,children:s.status==="error"?"Error":"Healthy"})]})]}),e.jsxs("div",{className:"rounded-2xl border border-white/6 bg-white/4 p-4",children:[e.jsx("div",{className:"hud-label",children:"Duration"}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx(ye,{className:"h-4 w-4 text-sky-300"}),e.jsx("span",{className:"text-sm font-medium text-white",children:h>0?C(h):"N/A"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"rounded-2xl border border-white/6 bg-white/4 p-4 text-center",children:[e.jsx("div",{className:"hud-label",children:"Spans"}),e.jsx("div",{className:"mt-2 text-xl font-semibold text-white",children:s.spanCount}),e.jsx(ke,{className:"mx-auto mt-1 h-4 w-4 text-emerald-300/60"})]}),e.jsxs("div",{className:"rounded-2xl border border-white/6 bg-white/4 p-4 text-center",children:[e.jsx("div",{className:"hud-label",children:"Tokens"}),e.jsx("div",{className:"mt-2 text-xl font-semibold text-white",children:ee(s.totalTokens)}),e.jsx(de,{className:"mx-auto mt-1 h-4 w-4 text-sky-300/60"})]}),e.jsxs("div",{className:"rounded-2xl border border-white/6 bg-white/4 p-4 text-center",children:[e.jsx("div",{className:"hud-label",children:"Cost"}),e.jsx("div",{className:"mt-2 text-xl font-semibold text-white",children:S(s.totalCost)}),e.jsx(ce,{className:"mx-auto mt-1 h-4 w-4 text-amber-300/60"})]})]}),e.jsxs("div",{className:"rounded-2xl border border-white/6 bg-white/4 p-4",children:[e.jsx("div",{className:"hud-label",children:"Started"}),e.jsxs("div",{className:"mt-1 text-sm text-slate-300",children:[new Date(s.startTime).toLocaleString()," (",B(s.startTime),")"]}),s.endTime&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hud-label mt-3",children:"Ended"}),e.jsx("div",{className:"mt-1 text-sm text-slate-300",children:new Date(s.endTime).toLocaleString()})]})]})]}),e.jsxs(xe,{to:`/trace/${s.traceId}`,className:"mt-5 flex w-full items-center justify-center gap-2 rounded-2xl border border-emerald-400/20 bg-[linear-gradient(135deg,rgba(16,185,129,0.12),rgba(14,165,233,0.08))] px-5 py-3 text-sm font-medium text-emerald-300 transition-colors hover:bg-[linear-gradient(135deg,rgba(16,185,129,0.22),rgba(14,165,233,0.14))]",children:["Open full trace detail",e.jsx(se,{className:"h-4 w-4"})]})]})]})}function Ie(s){return s?typeof s=="string"?s:s.filter(a=>a.type==="text"&&a.text).map(a=>a.text).join(`
2
- `):""}function Pe({traceA:s,traceB:a}){const[h,g]=i.useState([]),[f,r]=i.useState([]),[n,N]=i.useState(!0);if(i.useEffect(()=>{let w=!1;return N(!0),Promise.all([A(s.traceId),A(a.traceId)]).then(([c,m])=>{w||(g(c.spans),r(m.spans),N(!1))}),()=>{w=!0}},[s.traceId,a.traceId]),n)return e.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-slate-500",children:"Loading responses..."});const l=w=>w.flatMap(c=>(c.outputMessages??[]).filter(m=>m.role==="assistant").map(m=>({spanName:c.name,model:c.responseModel??c.requestModel,content:Ie(m.content)}))),p=l(h),v=l(f),b=Math.max(p.length,v.length);return b===0?e.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-slate-500",children:"No assistant responses found in either trace."}):e.jsx("div",{className:"space-y-3",children:Array.from({length:b},(w,c)=>{const m=p[c],x=v[c];return e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx("div",{className:"rounded-2xl border border-emerald-400/10 bg-white/3 p-3",children:m?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-1.5 flex items-center gap-2",children:[e.jsx("span",{className:"rounded-full border border-emerald-400/16 bg-emerald-400/10 px-2 py-0.5 text-[10px] font-bold uppercase tracking-[0.12em] text-emerald-200",children:"assistant"}),e.jsx("span",{className:"font-mono text-[10px] text-slate-500",children:m.model})]}),e.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs leading-relaxed text-slate-200",children:m.content||e.jsx("span",{className:"text-slate-600 italic",children:"empty response"})})]}):e.jsx("div",{className:"text-xs italic text-slate-600",children:"No response"})}),e.jsx("div",{className:"rounded-2xl border border-sky-400/10 bg-white/3 p-3",children:x?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-1.5 flex items-center gap-2",children:[e.jsx("span",{className:"rounded-full border border-sky-400/16 bg-sky-400/10 px-2 py-0.5 text-[10px] font-bold uppercase tracking-[0.12em] text-sky-200",children:"assistant"}),e.jsx("span",{className:"font-mono text-[10px] text-slate-500",children:x.model})]}),e.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs leading-relaxed text-slate-200",children:x.content||e.jsx("span",{className:"text-slate-600 italic",children:"empty response"})})]}):e.jsx("div",{className:"text-xs italic text-slate-600",children:"No response"})})]},c)})})}function Me({traceA:s,traceB:a,onClose:h}){const[g,f]=i.useState("metrics"),r=s.totalDuration??(s.endTime?s.endTime-s.startTime:0),n=a.totalDuration??(a.endTime?a.endTime-a.startTime:0),N=[{label:"Status",a:s.status,b:a.status,better:s.status===a.status?"tie":s.status==="ok"?"a":"b"},{label:"Spans",a:String(s.spanCount),b:String(a.spanCount)},{label:"Tokens",a:s.totalTokens.toLocaleString(),b:a.totalTokens.toLocaleString(),diff:s.totalTokens!==a.totalTokens?`${a.totalTokens-s.totalTokens>0?"+":""}${(a.totalTokens-s.totalTokens).toLocaleString()}`:"same",better:s.totalTokens===a.totalTokens?"tie":s.totalTokens<a.totalTokens?"a":"b"},{label:"Cost",a:S(s.totalCost),b:S(a.totalCost),diff:s.totalCost!==a.totalCost?`${a.totalCost-s.totalCost>0?"+":""}${S(Math.abs(a.totalCost-s.totalCost))}`:"same",better:s.totalCost===a.totalCost?"tie":s.totalCost<a.totalCost?"a":"b"},{label:"Duration",a:r>0?C(r):"N/A",b:n>0?C(n):"N/A",diff:r>0&&n>0&&r!==n?`${n-r>0?"+":""}${C(Math.abs(n-r))}`:r===n?"same":void 0,better:r===n?"tie":r>0&&n>0&&r<n?"a":"b"}];return e.jsxs(I.div,{initial:{opacity:0,y:24},animate:{opacity:1,y:0},exit:{opacity:0,y:24},transition:{duration:.3,ease:[.22,1,.36,1]},className:"dashboard-shell rounded-[26px] px-5 py-5 sm:px-6",children:[e.jsxs("div",{className:"mb-5 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"hud-label",children:"Comparison mode"}),e.jsx("h2",{className:"mt-1 text-xl font-semibold tracking-[-0.04em] text-white",children:"Side-by-side analysis"})]}),e.jsxs("button",{type:"button",onClick:h,className:"status-chip transition-colors hover:border-white/16 hover:bg-white/8",children:[e.jsx(U,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Close comparison"})]})]}),e.jsxs("div",{className:"mb-4 flex gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>f("metrics"),className:`inline-flex items-center gap-1.5 rounded-full border px-3.5 py-1.5 text-xs font-semibold transition-colors ${g==="metrics"?"border-emerald-400/20 bg-emerald-400/10 text-emerald-200":"border-white/8 bg-white/4 text-slate-400 hover:text-white"}`,children:[e.jsx(K,{className:"h-3 w-3"}),"Metrics"]}),e.jsxs("button",{type:"button",onClick:()=>f("responses"),className:`inline-flex items-center gap-1.5 rounded-full border px-3.5 py-1.5 text-xs font-semibold transition-colors ${g==="responses"?"border-emerald-400/20 bg-emerald-400/10 text-emerald-200":"border-white/8 bg-white/4 text-slate-400 hover:text-white"}`,children:[e.jsx(be,{className:"h-3 w-3"}),"Response diff"]})]}),g==="metrics"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4 grid grid-cols-[140px_1fr_1fr_120px] gap-3",children:[e.jsx("div",{}),e.jsxs("div",{className:"rounded-2xl border border-emerald-400/15 bg-emerald-400/5 p-3",children:[e.jsx("div",{className:"hud-label",children:"Trace A"}),e.jsx("div",{className:"mt-1 truncate text-sm font-medium text-white",children:s.name}),e.jsx("div",{className:"mt-0.5 font-mono text-[10px] text-slate-500",children:s.traceId.slice(0,16)})]}),e.jsxs("div",{className:"rounded-2xl border border-sky-400/15 bg-sky-400/5 p-3",children:[e.jsx("div",{className:"hud-label",children:"Trace B"}),e.jsx("div",{className:"mt-1 truncate text-sm font-medium text-white",children:a.name}),e.jsx("div",{className:"mt-0.5 font-mono text-[10px] text-slate-500",children:a.traceId.slice(0,16)})]}),e.jsx("div",{className:"flex items-center justify-center text-[11px] uppercase tracking-[0.18em] text-slate-500",children:"Delta"})]}),e.jsx("div",{className:"space-y-2",children:N.map(l=>e.jsxs("div",{className:"grid grid-cols-[140px_1fr_1fr_120px] items-center gap-3 rounded-2xl border border-white/6 bg-white/4 px-4 py-3",children:[e.jsx("div",{className:"text-xs font-medium uppercase tracking-wider text-slate-400",children:l.label}),e.jsx("div",{className:`text-sm font-mono ${l.better==="a"?"text-emerald-300":(l.better==="tie","text-slate-300")}`,children:l.label==="Status"?e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(P,{status:s.status}),l.a]}):l.a}),e.jsx("div",{className:`text-sm font-mono ${l.better==="b"?"text-emerald-300":(l.better==="tie","text-slate-300")}`,children:l.label==="Status"?e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(P,{status:a.status}),l.b]}):l.b}),e.jsx("div",{className:"text-center text-xs font-mono text-slate-500",children:l.diff??"--"})]},l.label))})]}):e.jsx(Pe,{traceA:s,traceB:a})]})}function Oe(){const[s,a]=oe(),h=s.get("q")??"",g=i.useDeferredValue(h),f=s.get("status"),r=f==="ok"||f==="error"?f:"",n=Number(s.get("periodHours")??"24"),N=Number(s.get("pageSize")??"50"),l=J.includes(N)?N:50,p=Math.max(1,Number(s.get("page")??"1")||1),v=(p-1)*l,[b,w]=i.useState(null),[c,m]=i.useState("desc"),[x,M]=i.useState(new Set),[_,$]=i.useState(null),[te,L]=i.useState(!1),T=i.useMemo(()=>({limit:l,offset:v,q:g.trim()||void 0,status:r||void 0,periodHours:Y.some(t=>t.value===n)?n:24}),[g,l,v,n,r]),{data:V,isLoading:ae}=he({queryKey:["traces",T],queryFn:()=>me(T)}),q=V?.traces??[],k=V?.total??0,Z=Math.max(1,Math.ceil(k/l));function le(t){b===t?m(o=>o==="asc"?"desc":"asc"):(w(t),m("desc"))}const u=i.useMemo(()=>b?[...q].sort((t,o)=>{const d=t[b]??0,j=o[b]??0;return c==="asc"?d-j:j-d}):q,[q,b,c]),D=u.length>0&&u.every(t=>x.has(t.traceId)),re=i.useCallback(()=>{M(t=>{const o=new Set(t);if(D)for(const d of u)o.delete(d.traceId);else for(const d of u)o.add(d.traceId);return o})},[D,u]),ie=i.useCallback(t=>{M(o=>{const d=new Set(o);return d.has(t)?d.delete(t):d.add(t),d})},[]),ne=i.useCallback(()=>{M(new Set),L(!1)},[]),E=i.useMemo(()=>u.filter(t=>x.has(t.traceId)),[u,x]),z=x.size===2,F=h.length>0||r.length>0||T.periodHours!==24;function y(t,o=!0){a(d=>{const j=new URLSearchParams(d);for(const[X,H]of Object.entries(t))H===void 0||H===""?j.delete(X):j.set(X,String(H));return o&&j.delete("page"),j},{replace:!0})}return e.jsxs(e.Fragment,{children:[e.jsxs(pe,{eyebrow:"Trace Explorer",title:"Deep-dive into every trace flowing through the system.",description:"Explore, compare, and inspect individual traces with full visibility into span counts, token usage, cost, and execution timing.",aside:e.jsx("div",{className:"insight-panel",children:e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"rounded-2xl border border-white/8 bg-white/4 p-4",children:[e.jsx("div",{className:"hud-label",children:"Total traces"}),e.jsxs("div",{className:"mt-2 flex items-center justify-between",children:[e.jsx("div",{className:"text-lg font-medium text-white",children:ee(k)}),e.jsx(G,{className:"h-4 w-4 text-emerald-300"})]}),e.jsx("div",{className:"mt-1 text-sm text-slate-400",children:"Matching current filters"})]}),x.size>0&&e.jsxs("div",{className:"rounded-2xl border border-sky-400/15 bg-sky-400/5 p-4",children:[e.jsx("div",{className:"hud-label",children:"Selected"}),e.jsxs("div",{className:"mt-2 flex items-center justify-between",children:[e.jsxs("div",{className:"text-lg font-medium text-white",children:[x.size," trace",x.size!==1&&"s"]}),e.jsx(K,{className:"h-4 w-4 text-sky-300"})]}),e.jsx("div",{className:"mt-1 text-sm text-slate-400",children:z?"Ready to compare":"Select exactly 2 to compare"})]})]})}),children:[e.jsx(O,{children:x.size>0&&e.jsx(I.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"overflow-hidden",children:e.jsxs("div",{className:"dashboard-shell flex items-center justify-between gap-4 rounded-[24px] px-5 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"status-chip",children:[e.jsx(R,{className:"h-3.5 w-3.5 text-emerald-300"}),e.jsxs("span",{children:[x.size," selected"]})]}),e.jsxs("button",{type:"button",onClick:ne,className:"status-chip transition-colors hover:border-white/16 hover:bg-white/8",children:[e.jsx(ue,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Clear"})]})]}),e.jsxs("button",{type:"button",disabled:!z,onClick:()=>L(!0),className:`inline-flex items-center gap-2 rounded-2xl border px-4 py-2 text-sm font-medium transition-all ${z?"border-emerald-400/20 bg-[linear-gradient(135deg,rgba(16,185,129,0.14),rgba(14,165,233,0.08))] text-emerald-300 hover:bg-[linear-gradient(135deg,rgba(16,185,129,0.24),rgba(14,165,233,0.14))]":"cursor-not-allowed border-white/6 bg-white/4 text-slate-500"}`,children:[e.jsx(K,{className:"h-4 w-4"}),"Compare traces"]})]})})}),e.jsx(O,{children:te&&E.length===2&&e.jsx(Me,{traceA:E[0],traceB:E[1],onClose:()=>L(!1)})}),e.jsxs("section",{className:"dashboard-shell rounded-[26px] px-4 py-4 sm:px-5 sm:py-5",children:[e.jsxs("div",{className:"mb-4 rounded-[24px] border border-white/8 bg-[linear-gradient(180deg,rgba(7,14,26,0.95),rgba(4,8,18,0.98))] p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"hud-label",children:"Search console"}),e.jsx("h2",{className:"mt-1 text-xl font-semibold tracking-[-0.04em] text-white",children:"Trace explorer"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"status-chip",children:[e.jsx(je,{className:"h-3.5 w-3.5 text-amber-300"}),e.jsxs("span",{children:[k," traces"]})]}),e.jsxs("button",{type:"button",onClick:()=>y({q:void 0,status:void 0,periodHours:void 0}),disabled:!F,className:"status-chip transition-colors hover:border-white/16 hover:bg-white/8 disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(U,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Clear"})]})]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 md:grid-cols-[minmax(0,1.8fr)_minmax(0,0.6fr)_minmax(0,0.6fr)]",children:[e.jsxs("label",{className:"relative block",children:[e.jsx(ge,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-500"}),e.jsx("input",{value:h,onChange:t=>y({q:t.target.value||void 0}),placeholder:"Search by trace name, ID, or keyword...",className:"w-full rounded-2xl border border-white/8 bg-white/4 py-3 pl-10 pr-4 text-sm text-white placeholder:text-slate-500 focus:border-emerald-400/30 focus:bg-white/6 focus:outline-none"})]}),e.jsxs("select",{value:r,onChange:t=>y({status:t.target.value||void 0}),className:"w-full rounded-2xl border border-white/8 bg-white/4 px-4 py-3 text-sm text-white focus:border-emerald-400/30 focus:bg-white/6 focus:outline-none",children:[e.jsx("option",{value:"",children:"All states"}),e.jsx("option",{value:"ok",children:"Healthy only"}),e.jsx("option",{value:"error",children:"Errors only"})]}),e.jsx("select",{value:String(T.periodHours??24),onChange:t=>y({periodHours:Number(t.target.value)===24?void 0:Number(t.target.value)}),className:"w-full rounded-2xl border border-white/8 bg-white/4 px-4 py-3 text-sm text-white focus:border-amber-400/30 focus:bg-white/6 focus:outline-none",children:Y.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))})]})]}),ae?e.jsx("div",{className:"empty-state h-[400px] text-slate-500",children:"Loading traces..."}):u.length===0?e.jsxs("div",{className:"empty-state h-[400px]",children:[e.jsx(G,{className:"h-8 w-8 text-slate-500"}),e.jsx("div",{className:"text-base font-medium text-white",children:F?"No traces match these filters":"No traces recorded yet"}),e.jsx("div",{className:"mt-1 text-sm text-slate-500",children:F?"Try adjusting the search or time window":"Start sending spans to populate the explorer"})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full border-separate border-spacing-y-1.5 text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-[11px] uppercase tracking-[0.18em] text-slate-500",children:[e.jsx("th",{className:"px-3 py-2 text-center",children:e.jsx("button",{type:"button",onClick:re,className:"inline-flex items-center justify-center transition-colors hover:text-slate-300",title:D?"Deselect all":"Select all",children:D?e.jsx(R,{className:"h-4 w-4 text-emerald-300"}):e.jsx(W,{className:"h-4 w-4"})})}),e.jsx("th",{className:"px-3 py-2 w-10",children:"State"}),e.jsx("th",{className:"px-3 py-2",children:"Trace"}),e.jsx("th",{className:"px-3 py-2",children:"ID"}),[["spanCount","Spans"],["totalTokens","Tokens"],["totalCost","Cost"],["startTime","When"]].map(([t,o])=>e.jsx("th",{className:"px-3 py-2 text-right",children:e.jsxs("button",{type:"button",onClick:()=>le(t),className:"inline-flex items-center gap-1 transition-colors hover:text-slate-300",children:[o,b===t?c==="asc"?e.jsx(fe,{className:"h-3 w-3"}):e.jsx(ve,{className:"h-3 w-3"}):e.jsx(Ne,{className:"h-3 w-3 opacity-30"})]})},t)),e.jsx("th",{className:"px-3 py-2 text-right",children:"Duration"})]})}),e.jsx("tbody",{children:u.map(t=>{const o=x.has(t.traceId),d=t.totalDuration??(t.endTime?t.endTime-t.startTime:0);return e.jsxs("tr",{onClick:()=>$(t),className:`cursor-pointer rounded-2xl border transition-colors ${o?"border-emerald-400/20 bg-emerald-400/5":"border-white/6 bg-white/4 hover:bg-white/6"}`,children:[e.jsx("td",{className:"rounded-l-2xl px-3 py-3 text-center",onClick:j=>j.stopPropagation(),children:e.jsx("button",{type:"button",onClick:()=>ie(t.traceId),className:"inline-flex items-center justify-center transition-colors hover:text-emerald-300",children:o?e.jsx(R,{className:"h-4 w-4 text-emerald-300"}):e.jsx(W,{className:"h-4 w-4 text-slate-500"})})}),e.jsx("td",{className:"px-3 py-3",children:e.jsx(P,{status:t.status})}),e.jsx("td",{className:"px-3 py-3",children:e.jsx("span",{className:"inline-flex max-w-[280px] items-center gap-2 text-sm font-medium text-white",children:e.jsx("span",{className:"truncate",children:t.name})})}),e.jsx("td",{className:"px-3 py-3",children:e.jsx("span",{className:"font-mono text-[11px] uppercase tracking-[0.12em] text-slate-500",children:t.traceId.slice(0,12)})}),e.jsx("td",{className:"px-3 py-3 text-right font-mono text-xs text-slate-300",children:t.spanCount}),e.jsx("td",{className:"px-3 py-3 text-right font-mono text-xs text-slate-300",children:t.totalTokens.toLocaleString()}),e.jsx("td",{className:"px-3 py-3 text-right font-mono text-xs text-slate-300",children:S(t.totalCost)}),e.jsx("td",{className:"px-3 py-3 text-right text-xs text-slate-500",children:B(t.startTime)}),e.jsx("td",{className:"rounded-r-2xl px-3 py-3 text-right font-mono text-xs text-slate-400",children:d>0?C(d):"--"})]},t.traceId)})})]})}),e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-3 px-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"text-xs text-slate-500",children:k>0?`Showing ${v+1}-${Math.min(v+u.length,k)} of ${k}`:"Awaiting traces"}),e.jsx("select",{value:String(l),onChange:t=>y({pageSize:Number(t.target.value)===50?void 0:Number(t.target.value)}),className:"rounded-xl border border-white/8 bg-white/4 px-2 py-1.5 text-xs text-slate-300 focus:border-emerald-400/30 focus:outline-none",children:J.map(t=>e.jsxs("option",{value:t,children:[t," / page"]},t))})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>y({page:p>2?p-1:void 0},!1),disabled:p<=1,className:"status-chip transition-colors hover:border-white/16 hover:bg-white/8 disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(we,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Previous"})]}),e.jsxs("span",{className:"text-xs text-slate-500",children:[p," / ",Z]}),e.jsxs("button",{type:"button",onClick:()=>y({page:p+1},!1),disabled:p>=Z,className:"status-chip transition-colors hover:border-white/16 hover:bg-white/8 disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx("span",{children:"Next"}),e.jsx(se,{className:"h-3.5 w-3.5"})]})]})]})]})]})]}),e.jsx(O,{children:_&&e.jsxs(e.Fragment,{children:[e.jsx(I.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>$(null),className:"fixed inset-0 z-40 bg-black/50 backdrop-blur-sm"},"overlay"),e.jsx(De,{trace:_,onClose:()=>$(null)},_.traceId)]})})]})}export{Oe as default};
@@ -1 +0,0 @@
1
- import{c as o}from"./index-BBr9_AHg.js";const e=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],c=o("arrow-left",e);const n=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],r=o("chevron-down",n);export{c as A,r as C};
@@ -1 +0,0 @@
1
- import{z as G,B as L,E as u,F as _,G as x,H as M,I as Q,J as $,K as J,N as C,O as X,P as Y,Q as B,U as V,r as f,V as W,p as Z,j as d}from"./index-BBr9_AHg.js";var q=class extends G{constructor(t,e){super(),this.options=e,this.#s=t,this.#i=null,this.#r=L(),this.bindMethods(),this.setOptions(e)}#s;#t=void 0;#p=void 0;#e=void 0;#n;#l;#r;#i;#m;#u;#d;#o;#h;#a;#f=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),A(this.#t,this.options)?this.#c():this.updateResult(),this.#R())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return F(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return F(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#x(),this.#y(),this.#t.removeObserver(this)}setOptions(t){const e=this.options,s=this.#t;if(this.options=this.#s.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof u(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#S(),this.#t.setOptions(this.options),e._defaulted&&!_(this.options,e)&&this.#s.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const r=this.hasListeners();r&&H(this.#t,s,this.options,e)&&this.#c(),this.updateResult(),r&&(this.#t!==s||u(this.options.enabled,this.#t)!==u(e.enabled,this.#t)||x(this.options.staleTime,this.#t)!==x(e.staleTime,this.#t))&&this.#g();const i=this.#b();r&&(this.#t!==s||u(this.options.enabled,this.#t)!==u(e.enabled,this.#t)||i!==this.#a)&&this.#v(i)}getOptimisticResult(t){const e=this.#s.getQueryCache().build(this.#s,t),s=this.createResult(e,t);return et(this,s)&&(this.#e=s,this.#l=this.options,this.#n=this.#t.state),s}getCurrentResult(){return this.#e}trackResult(t,e){return new Proxy(t,{get:(s,r)=>(this.trackProp(r),e?.(r),r==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#r.status==="pending"&&this.#r.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(s,r))})}trackProp(t){this.#f.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#s.defaultQueryOptions(t),s=this.#s.getQueryCache().build(this.#s,e);return s.fetch().then(()=>this.createResult(s,e))}fetch(t){return this.#c({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#e))}#c(t){this.#S();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(M)),e}#g(){this.#x();const t=x(this.options.staleTime,this.#t);if(Q||this.#e.isStale||!$(t))return;const s=J(this.#e.dataUpdatedAt,t)+1;this.#o=C.setTimeout(()=>{this.#e.isStale||this.updateResult()},s)}#b(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(t){this.#y(),this.#a=t,!(Q||u(this.options.enabled,this.#t)===!1||!$(this.#a)||this.#a===0)&&(this.#h=C.setInterval(()=>{(this.options.refetchIntervalInBackground||X.isFocused())&&this.#c()},this.#a))}#R(){this.#g(),this.#v(this.#b())}#x(){this.#o&&(C.clearTimeout(this.#o),this.#o=void 0)}#y(){this.#h&&(C.clearInterval(this.#h),this.#h=void 0)}createResult(t,e){const s=this.#t,r=this.options,i=this.#e,l=this.#n,n=this.#l,b=t!==s?t.state:this.#p,{state:h}=t;let a={...h},v=!1,o;if(e._optimisticResults){const c=this.hasListeners(),R=!c&&A(t,e),S=c&&H(t,s,e,r);(R||S)&&(a={...a,...Y(h.data,t.options)}),e._optimisticResults==="isRestoring"&&(a.fetchStatus="idle")}let{error:y,errorUpdatedAt:N,status:g}=a;o=a.data;let U=!1;if(e.placeholderData!==void 0&&o===void 0&&g==="pending"){let c;i?.isPlaceholderData&&e.placeholderData===n?.placeholderData?(c=i.data,U=!0):c=typeof e.placeholderData=="function"?e.placeholderData(this.#d?.state.data,this.#d):e.placeholderData,c!==void 0&&(g="success",o=B(i?.data,c,e),v=!0)}if(e.select&&o!==void 0&&!U)if(i&&o===l?.data&&e.select===this.#m)o=this.#u;else try{this.#m=e.select,o=e.select(o),o=B(i?.data,o,e),this.#u=o,this.#i=null}catch(c){this.#i=c}this.#i&&(y=this.#i,o=this.#u,N=Date.now(),g="error");const w=a.fetchStatus==="fetching",I=g==="pending",T=g==="error",D=I&&w,j=o!==void 0,m={status:g,fetchStatus:a.fetchStatus,isPending:I,isSuccess:g==="success",isError:T,isInitialLoading:D,isLoading:D,data:o,dataUpdatedAt:a.dataUpdatedAt,error:y,errorUpdatedAt:N,failureCount:a.fetchFailureCount,failureReason:a.fetchFailureReason,errorUpdateCount:a.errorUpdateCount,isFetched:a.dataUpdateCount>0||a.errorUpdateCount>0,isFetchedAfterMount:a.dataUpdateCount>b.dataUpdateCount||a.errorUpdateCount>b.errorUpdateCount,isFetching:w,isRefetching:w&&!I,isLoadingError:T&&!j,isPaused:a.fetchStatus==="paused",isPlaceholderData:v,isRefetchError:T&&j,isStale:P(t,e),refetch:this.refetch,promise:this.#r,isEnabled:u(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const c=m.data!==void 0,R=m.status==="error"&&!c,S=O=>{R?O.reject(m.error):c&&O.resolve(m.data)},k=()=>{const O=this.#r=m.promise=L();S(O)},E=this.#r;switch(E.status){case"pending":t.queryHash===s.queryHash&&S(E);break;case"fulfilled":(R||m.data!==E.value)&&k();break;case"rejected":(!R||m.error!==E.reason)&&k();break}}return m}updateResult(){const t=this.#e,e=this.createResult(this.#t,this.options);if(this.#n=this.#t.state,this.#l=this.options,this.#n.data!==void 0&&(this.#d=this.#t),_(e,t))return;this.#e=e;const s=()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,i=typeof r=="function"?r():r;if(i==="all"||!i&&!this.#f.size)return!0;const l=new Set(i??this.#f);return this.options.throwOnError&&l.add("error"),Object.keys(this.#e).some(n=>{const p=n;return this.#e[p]!==t[p]&&l.has(p)})};this.#E({listeners:s()})}#S(){const t=this.#s.getQueryCache().build(this.#s,this.options);if(t===this.#t)return;const e=this.#t;this.#t=t,this.#p=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#R()}#E(t){V.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#e)}),this.#s.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function tt(t,e){return u(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function A(t,e){return tt(t,e)||t.state.data!==void 0&&F(t,e,e.refetchOnMount)}function F(t,e,s){if(u(e.enabled,t)!==!1&&x(e.staleTime,t)!=="static"){const r=typeof s=="function"?s(t):s;return r==="always"||r!==!1&&P(t,e)}return!1}function H(t,e,s,r){return(t!==e||u(r.enabled,t)===!1)&&(!s.suspense||t.state.status!=="error")&&P(t,s)}function P(t,e){return u(e.enabled,t)!==!1&&t.isStaleByTime(x(e.staleTime,t))}function et(t,e){return!_(t.getCurrentResult(),e)}var K=f.createContext(!1),st=()=>f.useContext(K);K.Provider;function rt(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var it=f.createContext(rt()),at=()=>f.useContext(it),nt=(t,e,s)=>{const r=s?.state.error&&typeof t.throwOnError=="function"?W(t.throwOnError,[s.state.error,s]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||r)&&(e.isReset()||(t.retryOnMount=!1))},ot=t=>{f.useEffect(()=>{t.clearReset()},[t])},ht=({result:t,errorResetBoundary:e,throwOnError:s,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||W(s,[t.error,r])),ct=t=>{if(t.suspense){const s=i=>i==="static"?i:Math.max(i??1e3,1e3),r=t.staleTime;t.staleTime=typeof r=="function"?(...i)=>s(r(...i)):s(r),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},lt=(t,e)=>t.isLoading&&t.isFetching&&!e,ut=(t,e)=>t?.suspense&&e.isPending,z=(t,e,s)=>e.fetchOptimistic(t).catch(()=>{s.clearReset()});function dt(t,e,s){const r=st(),i=at(),l=Z(),n=l.defaultQueryOptions(t);l.getDefaultOptions().queries?._experimental_beforeQuery?.(n);const p=l.getQueryCache().get(n.queryHash);n._optimisticResults=r?"isRestoring":"optimistic",ct(n),nt(n,i,p),ot(i);const b=!l.getQueryCache().get(n.queryHash),[h]=f.useState(()=>new e(l,n)),a=h.getOptimisticResult(n),v=!r&&t.subscribed!==!1;if(f.useSyncExternalStore(f.useCallback(o=>{const y=v?h.subscribe(V.batchCalls(o)):M;return h.updateResult(),y},[h,v]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),f.useEffect(()=>{h.setOptions(n)},[n,h]),ut(n,a))throw z(n,h,i);if(ht({result:a,errorResetBoundary:i,throwOnError:n.throwOnError,query:p,suspense:n.suspense}))throw a.error;return l.getDefaultOptions().queries?._experimental_afterQuery?.(n,a),n.experimental_prefetchInRender&&!Q&&lt(a,r)&&(b?z(n,h,i):p?.promise)?.catch(M).finally(()=>{h.updateResult()}),n.notifyOnChangeProps?a:h.trackResult(a)}function mt(t,e){return dt(t,q)}function gt({eyebrow:t,title:e,description:s,aside:r,children:i}){return d.jsxs("div",{className:"mx-auto flex w-full max-w-[1500px] flex-col gap-8",children:[d.jsxs("section",{className:"hero-panel overflow-hidden rounded-[28px] border border-white/8 px-5 py-6 sm:px-7 sm:py-8",children:[d.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 w-1/2 bg-[radial-gradient(circle_at_top_right,rgba(14,165,233,0.22),transparent_45%),radial-gradient(circle_at_60%_70%,rgba(34,197,94,0.18),transparent_42%)]"}),d.jsxs("div",{className:"relative grid gap-6 lg:grid-cols-[minmax(0,1fr)_320px]",children:[d.jsxs("div",{className:"space-y-4",children:[d.jsx("div",{className:"hud-label",children:t}),d.jsxs("div",{className:"max-w-3xl space-y-3",children:[d.jsx("h1",{className:"text-3xl font-semibold leading-none tracking-[-0.04em] text-white sm:text-5xl",children:e}),d.jsx("p",{className:"max-w-2xl text-sm leading-6 text-slate-300 sm:text-base",children:s})]})]}),r?d.jsx("div",{className:"relative",children:r}):null]})]}),i]})}function bt(t){const e=Math.abs(t),s=t<0?"-":"";return e<.01?`${s}$${e.toFixed(4)}`:`${s}$${e.toFixed(2)}`}function vt(t){return t<1e3?`${Math.round(t)}ms`:`${(t/1e3).toFixed(1)}s`}function Rt(t){return new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:t>=1e3?1:0}).format(t)}function xt(t){return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function yt(t){const e=Date.now()-t,s=Math.floor(e/6e4);if(s<1)return"just now";if(s<60)return`${s}m ago`;const r=Math.floor(s/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}export{gt as P,Rt as a,bt as b,vt as c,yt as d,xt as f,mt as u};