@dudousxd/nestjs-agent-dashboard 0.6.0 → 0.8.0

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.
@@ -1 +1 @@
1
- import{g as c,j as e,r as i,L as u,f as m,M as p,e as g,d as h,R as f,c as I,b,P as S,a as w}from"./index-CES4RqI4.js";const T=[{modelId:"gpt-4o",requests:4200,inputTokens:84e5,outputTokens:21e5,costUsd:84.2},{modelId:"claude-3-5-sonnet",requests:2600,inputTokens:52e5,outputTokens:13e5,costUsd:41.6},{modelId:"gpt-4o-mini",requests:9800,inputTokens:12e6,outputTokens:3e6,costUsd:9.4},{modelId:"llama-3-70b",requests:1200,inputTokens:21e5,outputTokens:64e4,costUsd:0}],v=[{actorRef:"tenant:acme",requests:8200,totalTokens:184e5,costUsd:78.1,actorLabel:"Acme Corp"},{actorRef:"user:davi@goflip.ai",requests:3100,totalTokens:69e5,costUsd:34.2,actorLabel:"Davi de Carvalho"},{actorRef:"tenant:globex",requests:4400,totalTokens:92e5,costUsd:21.8,actorLabel:null},{actorRef:"user:ops-bot",requests:2100,totalTokens:394e4,costUsd:1.1,actorLabel:null}],x={"tenant:acme":2e7,"user:davi@goflip.ai":5e6,"tenant:globex":12e6};function D(){const o=[];for(let t=29;t>=0;t-=1){const s=new Date(Date.now()-t*864e5).toISOString().slice(0,10),r=Math.sin(t/3)*.5+1;o.push({day:s,totalTokens:Math.round(7e5*r+t*4e3),costUsd:Number((4.2*r+t*.05).toFixed(2))})}return o}function O(){const o=[];for(let t=29;t>=0;t-=1){const s=new Date(Date.now()-t*864e5).toISOString().slice(0,10),r=Math.sin(t/3)*.5+1,l=Math.round(18*r+t*.3);o.push({day:s,runs:l,failed:Math.max(0,Math.round(l*.06))})}return o}const n={byModel:T,byActor:v,trend:D()},M={metrics:{runs:482,completed:461,failed:21,successRate:461/482,retries:34,durationP50Ms:640,durationP95Ms:2400},byAgent:[{agentName:"analyst",runs:210,failed:8,retries:14},{agentName:"billing-agent",runs:150,failed:9,retries:12},{agentName:"(default)",runs:122,failed:4,retries:8}],errors:[{errorCode:"TIMEOUT",count:9},{errorCode:"TOOL_ERROR",count:6},{errorCode:"RATE_LIMIT",count:4},{errorCode:"UNKNOWN",count:2}],trend:O()},N=[{runId:"r-9f2a",threadId:"th1",actorRef:"tenant:acme",agentName:"analyst",status:"completed",durationMs:820,errorCode:null,errorMessage:null,retries:0,startedAt:new Date(Date.now()-4e4).toISOString(),promptHash:"a1b2c3d4e5f60718293a4b5c6d7e8f9012345678901234567890abcdef01234"},{runId:"r-7c31",threadId:"th2",actorRef:"user:ops-bot",agentName:"billing-agent",status:"failed",durationMs:4200,errorCode:"TIMEOUT",errorMessage:"upstream model request timed out after 3 attempts",retries:2,startedAt:new Date(Date.now()-21e4).toISOString(),promptHash:"ffeeddccbbaa99887766554433221100ffeeddccbbaa99887766554433221"},{runId:"r-a114",threadId:"th3",actorRef:"user:davi@goflip.ai",agentName:null,status:"completed",durationMs:1150,errorCode:null,errorMessage:null,retries:1,startedAt:new Date(Date.now()-54e4).toISOString(),promptHash:null},{runId:"r-b902",threadId:"th1",actorRef:"tenant:acme",agentName:"analyst",status:"failed",durationMs:980,errorCode:"TOOL_ERROR",errorMessage:"search_records returned a 500",retries:0,startedAt:new Date(Date.now()-132e4).toISOString(),promptHash:"a1b2c3d4e5f60718293a4b5c6d7e8f9012345678901234567890abcdef01234"},{runId:"r-c447",threadId:"th2",actorRef:"user:ops-bot",agentName:"billing-agent",status:"running",durationMs:null,errorCode:null,errorMessage:null,retries:0,startedAt:new Date(Date.now()-8e3).toISOString(),promptHash:"ffeeddccbbaa99887766554433221100ffeeddccbbaa99887766554433221"}],y=[{toolCallId:"tc-approve-1",toolName:"delete_asset",input:{assetId:"asset-42",reason:"stale"},threadId:"th2",threadTitle:"Incident triage",actorRef:"user:ops-bot",agentName:"billing-agent",requestedAt:new Date(Date.now()-3e5).toISOString()},{toolCallId:"tc-approve-2",toolName:"send_email",input:{to:"finance@acme.example",subject:"Q3 invoice adjustment"},threadId:"th1",threadTitle:"Q3 procurement review",actorRef:"tenant:acme",agentName:"analyst",requestedAt:new Date(Date.now()-9e5).toISOString()}],C=[{toolName:"search_records",toolType:"read",calls:420,failed:6,rejected:0,p95ExecutionMs:180},{toolName:"delete_asset",toolType:"action",calls:34,failed:1,rejected:4,p95ExecutionMs:620},{toolName:"send_email",toolType:"action",calls:58,failed:2,rejected:2,p95ExecutionMs:410},{toolName:"fetch_pricing",toolType:"read",calls:210,failed:0,rejected:0,p95ExecutionMs:95}],R=x,A=[{toolCallId:"tc1",toolName:"search_records",toolType:"read",status:"ok",threadId:"th1",createdAt:new Date(Date.now()-12e3).toISOString()},{toolCallId:"tc2",toolName:"delete_asset",toolType:"action",status:"forbidden",threadId:"th2",createdAt:new Date(Date.now()-9e4).toISOString()},{toolCallId:"tc3",toolName:"fetch_pricing",toolType:"read",status:"ok",threadId:"th1",createdAt:new Date(Date.now()-24e4).toISOString()},{toolCallId:"tc4",toolName:"send_email",toolType:"action",status:"failed",threadId:"th3",createdAt:new Date(Date.now()-62e4).toISOString()},{toolCallId:"tc5",toolName:"summarize_thread",toolType:"read",status:"ok",threadId:"th2",createdAt:new Date(Date.now()-12e5).toISOString()}],j=[{threadId:"th1",title:"Q3 procurement review",actorRef:"tenant:acme",messageCount:24,totalTokens:184e3,lastActivityAt:new Date(Date.now()-3e4).toISOString(),actorLabel:"Acme Corp"},{threadId:"th2",title:"Incident triage",actorRef:"user:ops-bot",messageCount:11,totalTokens:62e3,lastActivityAt:new Date(Date.now()-4e5).toISOString(),actorLabel:null},{threadId:"th3",title:"Contract summary",actorRef:"user:davi@goflip.ai",messageCount:6,totalTokens:28400,lastActivityAt:new Date(Date.now()-18e5).toISOString(),actorLabel:"Davi de Carvalho"}],k=[{threadId:"th1",title:"Q3 procurement review",actorRef:"tenant:acme",requests:24,totalTokens:184e3,costUsd:18.4,actorLabel:"Acme Corp"},{threadId:"th2",title:"Incident triage",actorRef:"user:ops-bot",requests:11,totalTokens:62e3,costUsd:6.2,actorLabel:null},{threadId:"th3",title:"Contract summary",actorRef:"user:davi@goflip.ai",requests:6,totalTokens:28400,costUsd:2.8,actorLabel:"Davi de Carvalho"}],_=[{modelId:"gpt-4o",inputPricePer1m:2.5,outputPricePer1m:10,cacheReadPricePer1m:1.25,effectiveFrom:new Date(Date.now()-5*864e5).toISOString()},{modelId:"claude-3-5-sonnet",inputPricePer1m:3,outputPricePer1m:15,cacheWritePricePer1m:3.75,cacheReadPricePer1m:.3,effectiveFrom:new Date(Date.now()-12*864e5).toISOString()},{modelId:"gpt-4o-mini",inputPricePer1m:.15,outputPricePer1m:.6,effectiveFrom:new Date(Date.now()-2*864e5).toISOString()}],P=[{id:"e1",event:"run.started",ts:Date.now()-2e3,payload:{runId:"r-9f2",agentName:"analyst"}},{id:"e2",event:"tool-call",ts:Date.now()-5e3,payload:{toolName:"search_records",toolType:"read",status:"ok"}},{id:"e3",event:"quota.exceeded",ts:Date.now()-9e3,payload:{actorId:"tenant:globex",usedTokens:124e5,limitTokens:12e6}},{id:"e4",event:"tool-call",ts:Date.now()-14e3,payload:{toolName:"delete_asset",toolType:"action",status:"forbidden"}},{id:"e5",event:"delegated",ts:Date.now()-2e4,payload:{fromAgent:"router",toAgent:"billing-agent"}},{id:"e6",event:"run.finished",ts:Date.now()-26e3,payload:{runId:"r-8a1",steps:7,inputTokens:4200,outputTokens:1100}}];function L(){return e.jsxs("div",{className:"relative min-h-full",children:[e.jsx("div",{className:"app-bg"}),e.jsxs("div",{className:"relative z-10 mx-auto max-w-[1180px] space-y-6 px-5 py-6",children:[e.jsxs("header",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"grid h-8 w-8 place-items-center rounded-lg border border-[var(--accent)]/40 bg-[var(--accent)]/10",children:e.jsx(u,{className:"h-4 w-4 text-[var(--accent)]"})}),e.jsxs("div",{className:"leading-none",children:[e.jsx("div",{className:"text-sm font-semibold tracking-tight",children:"AI gateway — preview"}),e.jsx("div",{className:"mono text-[10px] uppercase tracking-[0.2em] text-[var(--muted)]",children:"mock data · no backend"})]})]}),e.jsx(a,{label:"Spend & usage",children:e.jsx(m,{overview:n,topThreads:k})}),e.jsx(a,{label:"Models",children:e.jsx(p,{rows:n.byModel})}),e.jsx(a,{label:"Actors & budgets",children:e.jsx(g,{rows:n.byActor,budgets:R})}),e.jsx(a,{label:"Runs & tools",children:e.jsx(h,{toolCalls:A,threads:j})}),e.jsx(a,{label:"Reliability",children:e.jsx(f,{overview:M,runs:N})}),e.jsx(a,{label:"Approvals",children:e.jsx(I,{approvals:y,onDecide:async()=>{}})}),e.jsx(a,{label:"Tools",children:e.jsx(b,{rows:C})}),e.jsx(a,{label:"Pricing",children:e.jsx(S,{prices:_,loading:!1,unavailable:!1,onUpsert:async()=>{},saving:!1})}),e.jsx(a,{label:"Live",children:e.jsx(w,{events:P,connected:!0})})]})]})}function a({label:o,children:t}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"mono text-[11px] uppercase tracking-[0.2em] text-[var(--muted)]",children:o}),t]})}const d=document.getElementById("root");d&&c.createRoot(d).render(e.jsx(i.StrictMode,{children:e.jsx(L,{})}));
1
+ import{g as i,j as e,r as u,L as p,f as m,M as g,e as h,d as f,R as I,c as S,b,P as T,a as w}from"./index-DZVPxvtJ.js";const v=[{modelId:"gpt-4o",requests:4200,inputTokens:84e5,outputTokens:21e5,costUsd:84.2},{modelId:"claude-3-5-sonnet",requests:2600,inputTokens:52e5,outputTokens:13e5,costUsd:41.6},{modelId:"gpt-4o-mini",requests:9800,inputTokens:12e6,outputTokens:3e6,costUsd:9.4},{modelId:"llama-3-70b",requests:1200,inputTokens:21e5,outputTokens:64e4,costUsd:0}],x=[{actorRef:"tenant:acme",requests:8200,totalTokens:184e5,costUsd:78.1,actorLabel:"Acme Corp"},{actorRef:"user:davi@goflip.ai",requests:3100,totalTokens:69e5,costUsd:34.2,actorLabel:"Davi de Carvalho"},{actorRef:"tenant:globex",requests:4400,totalTokens:92e5,costUsd:21.8,actorLabel:null},{actorRef:"user:ops-bot",requests:2100,totalTokens:394e4,costUsd:1.1,actorLabel:null}],C={"tenant:acme":2e7,"user:davi@goflip.ai":5e6,"tenant:globex":12e6};function D(){const o=[];for(let t=29;t>=0;t-=1){const r=new Date(Date.now()-t*864e5).toISOString().slice(0,10),s=Math.sin(t/3)*.5+1;o.push({day:r,totalTokens:Math.round(7e5*s+t*4e3),costUsd:Number((4.2*s+t*.05).toFixed(2))})}return o}function O(){const o=[];for(let t=29;t>=0;t-=1){const r=new Date(Date.now()-t*864e5).toISOString().slice(0,10),s=Math.sin(t/3)*.5+1,l=Math.round(18*s+t*.3);o.push({day:r,runs:l,failed:Math.max(0,Math.round(l*.06))})}return o}const n={byModel:v,byActor:x,trend:D()},M={metrics:{runs:482,completed:461,failed:21,successRate:461/482,retries:34,durationP50Ms:640,durationP95Ms:2400},byAgent:[{agentName:"analyst",runs:210,failed:8,retries:14},{agentName:"billing-agent",runs:150,failed:9,retries:12},{agentName:"(default)",runs:122,failed:4,retries:8}],errors:[{errorCode:"TIMEOUT",count:9},{errorCode:"TOOL_ERROR",count:6},{errorCode:"RATE_LIMIT",count:4},{errorCode:"UNKNOWN",count:2}],trend:O()},N=[{runId:"r-9f2a",threadId:"th1",actorRef:"tenant:acme",agentName:"analyst",status:"completed",durationMs:820,errorCode:null,errorMessage:null,retries:0,startedAt:new Date(Date.now()-4e4).toISOString(),promptHash:"a1b2c3d4e5f60718293a4b5c6d7e8f9012345678901234567890abcdef01234"},{runId:"r-7c31",threadId:"th2",actorRef:"user:ops-bot",agentName:"billing-agent",status:"failed",durationMs:4200,errorCode:"TIMEOUT",errorMessage:"upstream model request timed out after 3 attempts",retries:2,startedAt:new Date(Date.now()-21e4).toISOString(),promptHash:"ffeeddccbbaa99887766554433221100ffeeddccbbaa99887766554433221"},{runId:"r-a114",threadId:"th3",actorRef:"user:davi@goflip.ai",agentName:null,status:"completed",durationMs:1150,errorCode:null,errorMessage:null,retries:1,startedAt:new Date(Date.now()-54e4).toISOString(),promptHash:null},{runId:"r-b902",threadId:"th1",actorRef:"tenant:acme",agentName:"analyst",status:"failed",durationMs:980,errorCode:"TOOL_ERROR",errorMessage:"search_records returned a 500",retries:0,startedAt:new Date(Date.now()-132e4).toISOString(),promptHash:"a1b2c3d4e5f60718293a4b5c6d7e8f9012345678901234567890abcdef01234"},{runId:"r-c447",threadId:"th2",actorRef:"user:ops-bot",agentName:"billing-agent",status:"running",durationMs:null,errorCode:null,errorMessage:null,retries:0,startedAt:new Date(Date.now()-8e3).toISOString(),promptHash:"ffeeddccbbaa99887766554433221100ffeeddccbbaa99887766554433221"}],R=[{toolCallId:"tc-approve-1",toolName:"delete_asset",input:{assetId:"asset-42",reason:"stale"},threadId:"th2",threadTitle:"Incident triage",actorRef:"user:ops-bot",agentName:"billing-agent",requestedAt:new Date(Date.now()-3e5).toISOString()},{toolCallId:"tc-approve-2",toolName:"send_email",input:{to:"finance@acme.example",subject:"Q3 invoice adjustment"},threadId:"th1",threadTitle:"Q3 procurement review",actorRef:"tenant:acme",agentName:"analyst",requestedAt:new Date(Date.now()-9e5).toISOString()}],A=[{toolName:"search_records",toolType:"read",calls:420,failed:6,rejected:0,p95ExecutionMs:180},{toolName:"delete_asset",toolType:"action",calls:34,failed:1,rejected:4,p95ExecutionMs:620},{toolName:"send_email",toolType:"action",calls:58,failed:2,rejected:2,p95ExecutionMs:410},{toolName:"fetch_pricing",toolType:"read",calls:210,failed:0,rejected:0,p95ExecutionMs:95}],y=C,c=[{toolCallId:"tc1",toolName:"search_records",toolType:"read",status:"ok",threadId:"th1",createdAt:new Date(Date.now()-12e3).toISOString()},{toolCallId:"tc2",toolName:"delete_asset",toolType:"action",status:"forbidden",threadId:"th2",createdAt:new Date(Date.now()-9e4).toISOString()},{toolCallId:"tc3",toolName:"fetch_pricing",toolType:"read",status:"ok",threadId:"th1",createdAt:new Date(Date.now()-24e4).toISOString()},{toolCallId:"tc4",toolName:"send_email",toolType:"action",status:"failed",threadId:"th3",createdAt:new Date(Date.now()-62e4).toISOString()},{toolCallId:"tc5",toolName:"summarize_thread",toolType:"read",status:"ok",threadId:"th2",createdAt:new Date(Date.now()-12e5).toISOString()}],_=[{threadId:"th1",title:"Q3 procurement review",actorRef:"tenant:acme",messageCount:24,totalTokens:184e3,lastActivityAt:new Date(Date.now()-3e4).toISOString(),actorLabel:"Acme Corp"},{threadId:"th2",title:"Incident triage",actorRef:"user:ops-bot",messageCount:11,totalTokens:62e3,lastActivityAt:new Date(Date.now()-4e5).toISOString(),actorLabel:null},{threadId:"th3",title:"Contract summary",actorRef:"user:davi@goflip.ai",messageCount:6,totalTokens:28400,lastActivityAt:new Date(Date.now()-18e5).toISOString(),actorLabel:"Davi de Carvalho"}],j=[{threadId:"th1",title:"Q3 procurement review",actorRef:"tenant:acme",requests:24,totalTokens:184e3,costUsd:18.4,actorLabel:"Acme Corp"},{threadId:"th2",title:"Incident triage",actorRef:"user:ops-bot",requests:11,totalTokens:62e3,costUsd:6.2,actorLabel:null},{threadId:"th3",title:"Contract summary",actorRef:"user:davi@goflip.ai",requests:6,totalTokens:28400,costUsd:2.8,actorLabel:"Davi de Carvalho"}],P={rows:c,total:137,page:1,pageSize:25},k={rows:_,total:46,page:1,pageSize:25},E={rows:N,total:482,page:1,pageSize:25},L=[{modelId:"gpt-4o",inputPricePer1m:2.5,outputPricePer1m:10,cacheReadPricePer1m:1.25,effectiveFrom:new Date(Date.now()-5*864e5).toISOString()},{modelId:"claude-3-5-sonnet",inputPricePer1m:3,outputPricePer1m:15,cacheWritePricePer1m:3.75,cacheReadPricePer1m:.3,effectiveFrom:new Date(Date.now()-12*864e5).toISOString()},{modelId:"gpt-4o-mini",inputPricePer1m:.15,outputPricePer1m:.6,effectiveFrom:new Date(Date.now()-2*864e5).toISOString()}],U=[{id:"e1",event:"run.started",ts:Date.now()-2e3,payload:{runId:"r-9f2",agentName:"analyst"}},{id:"e2",event:"tool-call",ts:Date.now()-5e3,payload:{toolName:"search_records",toolType:"read",status:"ok"}},{id:"e3",event:"quota.exceeded",ts:Date.now()-9e3,payload:{actorId:"tenant:globex",usedTokens:124e5,limitTokens:12e6}},{id:"e4",event:"tool-call",ts:Date.now()-14e3,payload:{toolName:"delete_asset",toolType:"action",status:"forbidden"}},{id:"e5",event:"delegated",ts:Date.now()-2e4,payload:{fromAgent:"router",toAgent:"billing-agent"}},{id:"e6",event:"run.finished",ts:Date.now()-26e3,payload:{runId:"r-8a1",steps:7,inputTokens:4200,outputTokens:1100}}];function q(){return e.jsxs("div",{className:"relative min-h-full",children:[e.jsx("div",{className:"app-bg"}),e.jsxs("div",{className:"relative z-10 mx-auto max-w-[1180px] space-y-6 px-5 py-6",children:[e.jsxs("header",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"grid h-8 w-8 place-items-center rounded-lg border border-[var(--accent)]/40 bg-[var(--accent)]/10",children:e.jsx(p,{className:"h-4 w-4 text-[var(--accent)]"})}),e.jsxs("div",{className:"leading-none",children:[e.jsx("div",{className:"text-sm font-semibold tracking-tight",children:"AI gateway — preview"}),e.jsx("div",{className:"mono text-[10px] uppercase tracking-[0.2em] text-[var(--muted)]",children:"mock data · no backend"})]})]}),e.jsx(a,{label:"Spend & usage",children:e.jsx(m,{overview:n,topThreads:j})}),e.jsx(a,{label:"Models",children:e.jsx(g,{rows:n.byModel})}),e.jsx(a,{label:"Actors & budgets",children:e.jsx(h,{rows:n.byActor,budgets:y})}),e.jsx(a,{label:"Runs & tools",children:e.jsx(f,{toolCalls:c,toolCallsPage:P,toolCallsWhere:{},onToolCallsToolNameChange:()=>{},onToolCallsStatusChange:()=>{},onToolCallsPageChange:()=>{},threadsPage:k,threadsWhere:{},onThreadsTitleChange:()=>{},onThreadsPageChange:()=>{}})}),e.jsx(a,{label:"Reliability",children:e.jsx(I,{overview:M,runsPage:E,runsWhere:{},onRunsStatusChange:()=>{},onRunsAgentNameChange:()=>{},onRunsPageChange:()=>{}})}),e.jsx(a,{label:"Approvals",children:e.jsx(S,{approvals:R,onDecide:async()=>{}})}),e.jsx(a,{label:"Tools",children:e.jsx(b,{rows:A})}),e.jsx(a,{label:"Pricing",children:e.jsx(T,{prices:L,loading:!1,unavailable:!1,onUpsert:async()=>{},saving:!1})}),e.jsx(a,{label:"Live",children:e.jsx(w,{events:U,connected:!0})})]})]})}function a({label:o,children:t}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"mono text-[11px] uppercase tracking-[0.2em] text-[var(--muted)]",children:o}),t]})}const d=document.getElementById("root");d&&i.createRoot(d).render(e.jsx(u.StrictMode,{children:e.jsx(q,{})}));
@@ -10,9 +10,9 @@
10
10
  rel="stylesheet"
11
11
  />
12
12
  <title>ai gateway · governance console</title>
13
- <script type="module" crossorigin src="/ai-gateway/assets/index-BjIcXlBO.js"></script>
14
- <link rel="modulepreload" crossorigin href="/ai-gateway/assets/index-CES4RqI4.js">
15
- <link rel="stylesheet" crossorigin href="/ai-gateway/assets/index-CVcgbps5.css">
13
+ <script type="module" crossorigin src="/ai-gateway/assets/index-C42SW8IV.js"></script>
14
+ <link rel="modulepreload" crossorigin href="/ai-gateway/assets/index-DZVPxvtJ.js">
15
+ <link rel="stylesheet" crossorigin href="/ai-gateway/assets/index-DMBWMAsE.css">
16
16
  </head>
17
17
  <body>
18
18
  <div id="root"></div>
@@ -10,9 +10,9 @@
10
10
  rel="stylesheet"
11
11
  />
12
12
  <title>ai gateway · preview</title>
13
- <script type="module" crossorigin src="/ai-gateway/assets/preview-A3jHlGra.js"></script>
14
- <link rel="modulepreload" crossorigin href="/ai-gateway/assets/index-CES4RqI4.js">
15
- <link rel="stylesheet" crossorigin href="/ai-gateway/assets/index-CVcgbps5.css">
13
+ <script type="module" crossorigin src="/ai-gateway/assets/preview-DhDnTjWH.js"></script>
14
+ <link rel="modulepreload" crossorigin href="/ai-gateway/assets/index-DZVPxvtJ.js">
15
+ <link rel="stylesheet" crossorigin href="/ai-gateway/assets/index-DMBWMAsE.css">
16
16
  </head>
17
17
  <body>
18
18
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dudousxd/nestjs-agent-dashboard",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/DavideCarvalho/nestjs-agent.git",
@@ -41,7 +41,7 @@
41
41
  "rxjs": "^7.0.0"
42
42
  },
43
43
  "dependencies": {
44
- "@dudousxd/nestjs-diagnostics": "0.6.1"
44
+ "@dudousxd/nestjs-diagnostics": "0.7.0"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@nestjs/common": "11.1.6",
@@ -62,7 +62,7 @@
62
62
  "typescript": "5.9.3",
63
63
  "vite": "5.4.21",
64
64
  "vitest": "2.1.9",
65
- "@dudousxd/nestjs-agent-core": "0.6.0"
65
+ "@dudousxd/nestjs-agent-core": "0.8.0"
66
66
  },
67
67
  "scripts": {
68
68
  "build": "vite build && tsup && tsc -p tsconfig.client.json",
@@ -1 +0,0 @@
1
- var be=e=>{throw TypeError(e)};var Xt=(e,t,s)=>t.has(e)||be("Cannot "+s);var i=(e,t,s)=>(Xt(e,t,"read from private field"),s?s.call(e):t.get(e)),d=(e,t,s)=>t.has(e)?be("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),u=(e,t,s,r)=>(Xt(e,t,"write to private field"),r?r.call(e,s):t.set(e,s),s),m=(e,t,s)=>(Xt(e,t,"access private method"),s);var Gt=(e,t,s,r)=>({set _(n){u(e,t,n,s)},get _(){return i(e,t,r)}});import{r as O,j as p,p as rs,L as is,D as ns,C as as,U as os,W as ge,S as us,I as cs,T as hs,A as ls,a as ds,P as fs,b as ps,c as ys,R as ms,d as vs,e as bs,M as gs,f as Ss,g as ws}from"./index-CES4RqI4.js";var Ut=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},gt=typeof window>"u"||"Deno"in globalThis;function K(){}function xs(e,t){return typeof e=="function"?e(t):e}function te(e){return typeof e=="number"&&e>=0&&e!==1/0}function $e(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Ct(e,t){return typeof e=="function"?e(t):e}function B(e,t){return typeof e=="function"?e(t):e}function Se(e,t){const{type:s="all",exact:r,fetchStatus:n,predicate:a,queryKey:o,stale:c}=e;if(o){if(r){if(t.queryHash!==pe(o,t.options))return!1}else if(!Lt(t.queryKey,o))return!1}if(s!=="all"){const l=t.isActive();if(s==="active"&&!l||s==="inactive"&&l)return!1}return!(typeof c=="boolean"&&t.isStale()!==c||n&&n!==t.state.fetchStatus||a&&!a(t))}function we(e,t){const{exact:s,status:r,predicate:n,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(s){if(St(t.options.mutationKey)!==St(a))return!1}else if(!Lt(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||n&&!n(t))}function pe(e,t){return((t==null?void 0:t.queryKeyHashFn)||St)(e)}function St(e){return JSON.stringify(e,(t,s)=>ee(s)?Object.keys(s).sort().reduce((r,n)=>(r[n]=s[n],r),{}):s)}function Lt(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(s=>!Lt(e[s],t[s])):!1}function He(e,t){if(e===t)return e;const s=xe(e)&&xe(t);if(s||ee(e)&&ee(t)){const r=s?e:Object.keys(e),n=r.length,a=s?t:Object.keys(t),o=a.length,c=s?[]:{};let l=0;for(let g=0;g<o;g++){const y=s?g:a[g];(!s&&r.includes(y)||s)&&e[y]===void 0&&t[y]===void 0?(c[y]=void 0,l++):(c[y]=He(e[y],t[y]),c[y]===e[y]&&e[y]!==void 0&&l++)}return n===o&&l===n?e:c}return t}function Wt(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const s in e)if(e[s]!==t[s])return!1;return!0}function xe(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function ee(e){if(!Ce(e))return!1;const t=e.constructor;if(t===void 0)return!0;const s=t.prototype;return!(!Ce(s)||!s.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Ce(e){return Object.prototype.toString.call(e)==="[object Object]"}function Cs(e){return new Promise(t=>{setTimeout(t,e)})}function se(e,t,s){return typeof s.structuralSharing=="function"?s.structuralSharing(e,t):s.structuralSharing!==!1?He(e,t):t}function Ps(e,t,s=0){const r=[...e,t];return s&&r.length>s?r.slice(1):r}function Rs(e,t,s=0){const r=[t,...e];return s&&r.length>s?r.slice(0,-1):r}var ye=Symbol();function Ge(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===ye?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var dt,rt,Pt,Me,Os=(Me=class extends Ut{constructor(){super();d(this,dt);d(this,rt);d(this,Pt);u(this,Pt,t=>{if(!gt&&window.addEventListener){const s=()=>t();return window.addEventListener("visibilitychange",s,!1),()=>{window.removeEventListener("visibilitychange",s)}}})}onSubscribe(){i(this,rt)||this.setEventListener(i(this,Pt))}onUnsubscribe(){var t;this.hasListeners()||((t=i(this,rt))==null||t.call(this),u(this,rt,void 0))}setEventListener(t){var s;u(this,Pt,t),(s=i(this,rt))==null||s.call(this),u(this,rt,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){i(this,dt)!==t&&(u(this,dt,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(s=>{s(t)})}isFocused(){var t;return typeof i(this,dt)=="boolean"?i(this,dt):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},dt=new WeakMap,rt=new WeakMap,Pt=new WeakMap,Me),me=new Os,Rt,it,Ot,Ie,Es=(Ie=class extends Ut{constructor(){super();d(this,Rt,!0);d(this,it);d(this,Ot);u(this,Ot,t=>{if(!gt&&window.addEventListener){const s=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",s,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",s),window.removeEventListener("offline",r)}}})}onSubscribe(){i(this,it)||this.setEventListener(i(this,Ot))}onUnsubscribe(){var t;this.hasListeners()||((t=i(this,it))==null||t.call(this),u(this,it,void 0))}setEventListener(t){var s;u(this,Ot,t),(s=i(this,it))==null||s.call(this),u(this,it,t(this.setOnline.bind(this)))}setOnline(t){i(this,Rt)!==t&&(u(this,Rt,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return i(this,Rt)}},Rt=new WeakMap,it=new WeakMap,Ot=new WeakMap,Ie),Vt=new Es;function re(){let e,t;const s=new Promise((n,a)=>{e=n,t=a});s.status="pending",s.catch(()=>{});function r(n){Object.assign(s,n),delete s.resolve,delete s.reject}return s.resolve=n=>{r({status:"fulfilled",value:n}),e(n)},s.reject=n=>{r({status:"rejected",reason:n}),t(n)},s}function Ds(e){return Math.min(1e3*2**e,3e4)}function Be(e){return(e??"online")==="online"?Vt.isOnline():!0}var Ye=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Zt(e){return e instanceof Ye}function ze(e){let t=!1,s=0,r=!1,n;const a=re(),o=f=>{var b;r||(S(new Ye(f)),(b=e.abort)==null||b.call(e))},c=()=>{t=!0},l=()=>{t=!1},g=()=>me.isFocused()&&(e.networkMode==="always"||Vt.isOnline())&&e.canRun(),y=()=>Be(e.networkMode)&&e.canRun(),h=f=>{var b;r||(r=!0,(b=e.onSuccess)==null||b.call(e,f),n==null||n(),a.resolve(f))},S=f=>{var b;r||(r=!0,(b=e.onError)==null||b.call(e,f),n==null||n(),a.reject(f))},v=()=>new Promise(f=>{var b;n=D=>{(r||g())&&f(D)},(b=e.onPause)==null||b.call(e)}).then(()=>{var f;n=void 0,r||(f=e.onContinue)==null||f.call(e)}),R=()=>{if(r)return;let f;const b=s===0?e.initialPromise:void 0;try{f=b??e.fn()}catch(D){f=Promise.reject(D)}Promise.resolve(f).then(h).catch(D=>{var H;if(r)return;const C=e.retry??(gt?0:3),P=e.retryDelay??Ds,j=typeof P=="function"?P(s,D):P,L=C===!0||typeof C=="number"&&s<C||typeof C=="function"&&C(s,D);if(t||!L){S(D);return}s++,(H=e.onFail)==null||H.call(e,s,D),Cs(j).then(()=>g()?void 0:v()).then(()=>{t?S(D):R()})})};return{promise:a,cancel:o,continue:()=>(n==null||n(),a),cancelRetry:c,continueRetry:l,canStart:y,start:()=>(y()?R():v().then(R),a)}}function Fs(){let e=[],t=0,s=c=>{c()},r=c=>{c()},n=c=>setTimeout(c,0);const a=c=>{t?e.push(c):n(()=>{s(c)})},o=()=>{const c=e;e=[],c.length&&n(()=>{r(()=>{c.forEach(l=>{s(l)})})})};return{batch:c=>{let l;t++;try{l=c()}finally{t--,t||o()}return l},batchCalls:c=>(...l)=>{a(()=>{c(...l)})},schedule:a,setNotifyFunction:c=>{s=c},setBatchNotifyFunction:c=>{r=c},setScheduler:c=>{n=c}}}var A=Fs(),ft,Qe,We=(Qe=class{constructor(){d(this,ft)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),te(this.gcTime)&&u(this,ft,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(gt?1/0:5*60*1e3))}clearGcTimeout(){i(this,ft)&&(clearTimeout(i(this,ft)),u(this,ft,void 0))}},ft=new WeakMap,Qe),Et,Dt,N,M,_t,pt,G,X,qe,Ts=(qe=class extends We{constructor(t){super();d(this,G);d(this,Et);d(this,Dt);d(this,N);d(this,M);d(this,_t);d(this,pt);u(this,pt,!1),u(this,_t,t.defaultOptions),this.setOptions(t.options),this.observers=[],u(this,N,t.cache),this.queryKey=t.queryKey,this.queryHash=t.queryHash,u(this,Et,As(this.options)),this.state=t.state??i(this,Et),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=i(this,M))==null?void 0:t.promise}setOptions(t){this.options={...i(this,_t),...t},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&i(this,N).remove(this)}setData(t,s){const r=se(this.state.data,t,this.options);return m(this,G,X).call(this,{data:r,type:"success",dataUpdatedAt:s==null?void 0:s.updatedAt,manual:s==null?void 0:s.manual}),r}setState(t,s){m(this,G,X).call(this,{type:"setState",state:t,setStateOptions:s})}cancel(t){var r,n;const s=(r=i(this,M))==null?void 0:r.promise;return(n=i(this,M))==null||n.cancel(t),s?s.then(K).catch(K):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(i(this,Et))}isActive(){return this.observers.some(t=>B(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===ye||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(t=0){return this.state.isInvalidated||this.state.data===void 0||!$e(this.state.dataUpdatedAt,t)}onFocus(){var s;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(s=i(this,M))==null||s.continue()}onOnline(){var s;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(s=i(this,M))==null||s.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),i(this,N).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(s=>s!==t),this.observers.length||(i(this,M)&&(i(this,pt)?i(this,M).cancel({revert:!0}):i(this,M).cancelRetry()),this.scheduleGc()),i(this,N).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||m(this,G,X).call(this,{type:"invalidate"})}fetch(t,s){var l,g,y;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(s!=null&&s.cancelRefetch))this.cancel({silent:!0});else if(i(this,M))return i(this,M).continueRetry(),i(this,M).promise}if(t&&this.setOptions(t),!this.options.queryFn){const h=this.observers.find(S=>S.options.queryFn);h&&this.setOptions(h.options)}const r=new AbortController,n=h=>{Object.defineProperty(h,"signal",{enumerable:!0,get:()=>(u(this,pt,!0),r.signal)})},a=()=>{const h=Ge(this.options,s),S={queryKey:this.queryKey,meta:this.meta};return n(S),u(this,pt,!1),this.options.persister?this.options.persister(h,S,this):h(S)},o={fetchOptions:s,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:a};n(o),(l=this.options.behavior)==null||l.onFetch(o,this),u(this,Dt,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((g=o.fetchOptions)==null?void 0:g.meta))&&m(this,G,X).call(this,{type:"fetch",meta:(y=o.fetchOptions)==null?void 0:y.meta});const c=h=>{var S,v,R,f;Zt(h)&&h.silent||m(this,G,X).call(this,{type:"error",error:h}),Zt(h)||((v=(S=i(this,N).config).onError)==null||v.call(S,h,this),(f=(R=i(this,N).config).onSettled)==null||f.call(R,this.state.data,h,this)),this.scheduleGc()};return u(this,M,ze({initialPromise:s==null?void 0:s.initialPromise,fn:o.fetchFn,abort:r.abort.bind(r),onSuccess:h=>{var S,v,R,f;if(h===void 0){c(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(h)}catch(b){c(b);return}(v=(S=i(this,N).config).onSuccess)==null||v.call(S,h,this),(f=(R=i(this,N).config).onSettled)==null||f.call(R,h,this.state.error,this),this.scheduleGc()},onError:c,onFail:(h,S)=>{m(this,G,X).call(this,{type:"failed",failureCount:h,error:S})},onPause:()=>{m(this,G,X).call(this,{type:"pause"})},onContinue:()=>{m(this,G,X).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0})),i(this,M).start()}},Et=new WeakMap,Dt=new WeakMap,N=new WeakMap,M=new WeakMap,_t=new WeakMap,pt=new WeakMap,G=new WeakSet,X=function(t){const s=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...Ve(r.data,this.options),fetchMeta:t.meta??null};case"success":return{...r,data:t.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const n=t.error;return Zt(n)&&n.revert&&i(this,Dt)?{...i(this,Dt),fetchStatus:"idle"}:{...r,error:n,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=s(this.state),A.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),i(this,N).notify({query:this,type:"updated",action:t})})},qe);function Ve(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Be(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function As(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,s=t!==void 0,r=s?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:s?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:s?"success":"pending",fetchStatus:"idle"}}var Y,Ue,js=(Ue=class extends Ut{constructor(t={}){super();d(this,Y);this.config=t,u(this,Y,new Map)}build(t,s,r){const n=s.queryKey,a=s.queryHash??pe(n,s);let o=this.get(a);return o||(o=new Ts({cache:this,queryKey:n,queryHash:a,options:t.defaultQueryOptions(s),state:r,defaultOptions:t.getQueryDefaults(n)}),this.add(o)),o}add(t){i(this,Y).has(t.queryHash)||(i(this,Y).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const s=i(this,Y).get(t.queryHash);s&&(t.destroy(),s===t&&i(this,Y).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){A.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return i(this,Y).get(t)}getAll(){return[...i(this,Y).values()]}find(t){const s={exact:!0,...t};return this.getAll().find(r=>Se(s,r))}findAll(t={}){const s=this.getAll();return Object.keys(t).length>0?s.filter(r=>Se(t,r)):s}notify(t){A.batch(()=>{this.listeners.forEach(s=>{s(t)})})}onFocus(){A.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){A.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Y=new WeakMap,Ue),z,Q,yt,W,st,ke,Ms=(ke=class extends We{constructor(t){super();d(this,W);d(this,z);d(this,Q);d(this,yt);this.mutationId=t.mutationId,u(this,Q,t.mutationCache),u(this,z,[]),this.state=t.state||Je(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){i(this,z).includes(t)||(i(this,z).push(t),this.clearGcTimeout(),i(this,Q).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){u(this,z,i(this,z).filter(s=>s!==t)),this.scheduleGc(),i(this,Q).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){i(this,z).length||(this.state.status==="pending"?this.scheduleGc():i(this,Q).remove(this))}continue(){var t;return((t=i(this,yt))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var n,a,o,c,l,g,y,h,S,v,R,f,b,D,C,P,j,L,H,I;u(this,yt,ze({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(T,E)=>{m(this,W,st).call(this,{type:"failed",failureCount:T,error:E})},onPause:()=>{m(this,W,st).call(this,{type:"pause"})},onContinue:()=>{m(this,W,st).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>i(this,Q).canRun(this)}));const s=this.state.status==="pending",r=!i(this,yt).canStart();try{if(!s){m(this,W,st).call(this,{type:"pending",variables:t,isPaused:r}),await((a=(n=i(this,Q).config).onMutate)==null?void 0:a.call(n,t,this));const E=await((c=(o=this.options).onMutate)==null?void 0:c.call(o,t));E!==this.state.context&&m(this,W,st).call(this,{type:"pending",context:E,variables:t,isPaused:r})}const T=await i(this,yt).start();return await((g=(l=i(this,Q).config).onSuccess)==null?void 0:g.call(l,T,t,this.state.context,this)),await((h=(y=this.options).onSuccess)==null?void 0:h.call(y,T,t,this.state.context)),await((v=(S=i(this,Q).config).onSettled)==null?void 0:v.call(S,T,null,this.state.variables,this.state.context,this)),await((f=(R=this.options).onSettled)==null?void 0:f.call(R,T,null,t,this.state.context)),m(this,W,st).call(this,{type:"success",data:T}),T}catch(T){try{throw await((D=(b=i(this,Q).config).onError)==null?void 0:D.call(b,T,t,this.state.context,this)),await((P=(C=this.options).onError)==null?void 0:P.call(C,T,t,this.state.context)),await((L=(j=i(this,Q).config).onSettled)==null?void 0:L.call(j,void 0,T,this.state.variables,this.state.context,this)),await((I=(H=this.options).onSettled)==null?void 0:I.call(H,void 0,T,t,this.state.context)),T}finally{m(this,W,st).call(this,{type:"error",error:T})}}finally{i(this,Q).runNext(this)}}},z=new WeakMap,Q=new WeakMap,yt=new WeakMap,W=new WeakSet,st=function(t){const s=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=s(this.state),A.batch(()=>{i(this,z).forEach(r=>{r.onMutationUpdate(t)}),i(this,Q).notify({mutation:this,type:"updated",action:t})})},ke);function Je(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var _,Nt,Le,Is=(Le=class extends Ut{constructor(t={}){super();d(this,_);d(this,Nt);this.config=t,u(this,_,new Map),u(this,Nt,Date.now())}build(t,s,r){const n=new Ms({mutationCache:this,mutationId:++Gt(this,Nt)._,options:t.defaultMutationOptions(s),state:r});return this.add(n),n}add(t){const s=Bt(t),r=i(this,_).get(s)??[];r.push(t),i(this,_).set(s,r),this.notify({type:"added",mutation:t})}remove(t){var r;const s=Bt(t);if(i(this,_).has(s)){const n=(r=i(this,_).get(s))==null?void 0:r.filter(a=>a!==t);n&&(n.length===0?i(this,_).delete(s):i(this,_).set(s,n))}this.notify({type:"removed",mutation:t})}canRun(t){var r;const s=(r=i(this,_).get(Bt(t)))==null?void 0:r.find(n=>n.state.status==="pending");return!s||s===t}runNext(t){var r;const s=(r=i(this,_).get(Bt(t)))==null?void 0:r.find(n=>n!==t&&n.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}clear(){A.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}getAll(){return[...i(this,_).values()].flat()}find(t){const s={exact:!0,...t};return this.getAll().find(r=>we(s,r))}findAll(t={}){return this.getAll().filter(s=>we(t,s))}notify(t){A.batch(()=>{this.listeners.forEach(s=>{s(t)})})}resumePausedMutations(){const t=this.getAll().filter(s=>s.state.isPaused);return A.batch(()=>Promise.all(t.map(s=>s.continue().catch(K))))}},_=new WeakMap,Nt=new WeakMap,Le);function Bt(e){var t;return((t=e.options.scope)==null?void 0:t.id)??String(e.mutationId)}function Pe(e){return{onFetch:(t,s)=>{var y,h,S,v,R;const r=t.options,n=(S=(h=(y=t.fetchOptions)==null?void 0:y.meta)==null?void 0:h.fetchMore)==null?void 0:S.direction,a=((v=t.state.data)==null?void 0:v.pages)||[],o=((R=t.state.data)==null?void 0:R.pageParams)||[];let c={pages:[],pageParams:[]},l=0;const g=async()=>{let f=!1;const b=P=>{Object.defineProperty(P,"signal",{enumerable:!0,get:()=>(t.signal.aborted?f=!0:t.signal.addEventListener("abort",()=>{f=!0}),t.signal)})},D=Ge(t.options,t.fetchOptions),C=async(P,j,L)=>{if(f)return Promise.reject();if(j==null&&P.pages.length)return Promise.resolve(P);const H={queryKey:t.queryKey,pageParam:j,direction:L?"backward":"forward",meta:t.options.meta};b(H);const I=await D(H),{maxPages:T}=t.options,E=L?Rs:Ps;return{pages:E(P.pages,I,T),pageParams:E(P.pageParams,j,T)}};if(n&&a.length){const P=n==="backward",j=P?Qs:Re,L={pages:a,pageParams:o},H=j(r,L);c=await C(L,H,P)}else{const P=e??a.length;do{const j=l===0?o[0]??r.initialPageParam:Re(r,c);if(l>0&&j==null)break;c=await C(c,j),l++}while(l<P)}return c};t.options.persister?t.fetchFn=()=>{var f,b;return(b=(f=t.options).persister)==null?void 0:b.call(f,g,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},s)}:t.fetchFn=g}}}function Re(e,{pages:t,pageParams:s}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,s[r],s):void 0}function Qs(e,{pages:t,pageParams:s}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,s[0],s):void 0}var F,nt,at,Ft,Tt,ot,At,jt,_e,qs=(_e=class{constructor(e={}){d(this,F);d(this,nt);d(this,at);d(this,Ft);d(this,Tt);d(this,ot);d(this,At);d(this,jt);u(this,F,e.queryCache||new js),u(this,nt,e.mutationCache||new Is),u(this,at,e.defaultOptions||{}),u(this,Ft,new Map),u(this,Tt,new Map),u(this,ot,0)}mount(){Gt(this,ot)._++,i(this,ot)===1&&(u(this,At,me.subscribe(async e=>{e&&(await this.resumePausedMutations(),i(this,F).onFocus())})),u(this,jt,Vt.subscribe(async e=>{e&&(await this.resumePausedMutations(),i(this,F).onOnline())})))}unmount(){var e,t;Gt(this,ot)._--,i(this,ot)===0&&((e=i(this,At))==null||e.call(this),u(this,At,void 0),(t=i(this,jt))==null||t.call(this),u(this,jt,void 0))}isFetching(e){return i(this,F).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return i(this,nt).findAll({...e,status:"pending"}).length}getQueryData(e){var s;const t=this.defaultQueryOptions({queryKey:e});return(s=i(this,F).get(t.queryHash))==null?void 0:s.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),s=i(this,F).build(this,t),r=s.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&s.isStaleByTime(Ct(t.staleTime,s))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return i(this,F).findAll(e).map(({queryKey:t,state:s})=>{const r=s.data;return[t,r]})}setQueryData(e,t,s){const r=this.defaultQueryOptions({queryKey:e}),n=i(this,F).get(r.queryHash),a=n==null?void 0:n.state.data,o=xs(t,a);if(o!==void 0)return i(this,F).build(this,r).setData(o,{...s,manual:!0})}setQueriesData(e,t,s){return A.batch(()=>i(this,F).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,s)]))}getQueryState(e){var s;const t=this.defaultQueryOptions({queryKey:e});return(s=i(this,F).get(t.queryHash))==null?void 0:s.state}removeQueries(e){const t=i(this,F);A.batch(()=>{t.findAll(e).forEach(s=>{t.remove(s)})})}resetQueries(e,t){const s=i(this,F),r={type:"active",...e};return A.batch(()=>(s.findAll(e).forEach(n=>{n.reset()}),this.refetchQueries(r,t)))}cancelQueries(e,t={}){const s={revert:!0,...t},r=A.batch(()=>i(this,F).findAll(e).map(n=>n.cancel(s)));return Promise.all(r).then(K).catch(K)}invalidateQueries(e,t={}){return A.batch(()=>{if(i(this,F).findAll(e).forEach(r=>{r.invalidate()}),(e==null?void 0:e.refetchType)==="none")return Promise.resolve();const s={...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"};return this.refetchQueries(s,t)})}refetchQueries(e,t={}){const s={...t,cancelRefetch:t.cancelRefetch??!0},r=A.batch(()=>i(this,F).findAll(e).filter(n=>!n.isDisabled()).map(n=>{let a=n.fetch(void 0,s);return s.throwOnError||(a=a.catch(K)),n.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(K)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const s=i(this,F).build(this,t);return s.isStaleByTime(Ct(t.staleTime,s))?s.fetch(t):Promise.resolve(s.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(K).catch(K)}fetchInfiniteQuery(e){return e.behavior=Pe(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(K).catch(K)}ensureInfiniteQueryData(e){return e.behavior=Pe(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Vt.isOnline()?i(this,nt).resumePausedMutations():Promise.resolve()}getQueryCache(){return i(this,F)}getMutationCache(){return i(this,nt)}getDefaultOptions(){return i(this,at)}setDefaultOptions(e){u(this,at,e)}setQueryDefaults(e,t){i(this,Ft).set(St(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...i(this,Ft).values()],s={};return t.forEach(r=>{Lt(e,r.queryKey)&&Object.assign(s,r.defaultOptions)}),s}setMutationDefaults(e,t){i(this,Tt).set(St(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...i(this,Tt).values()];let s={};return t.forEach(r=>{Lt(e,r.mutationKey)&&(s={...s,...r.defaultOptions})}),s}defaultQueryOptions(e){if(e._defaulted)return e;const t={...i(this,at).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=pe(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===ye&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...i(this,at).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){i(this,F).clear(),i(this,nt).clear()}},F=new WeakMap,nt=new WeakMap,at=new WeakMap,Ft=new WeakMap,Tt=new WeakMap,ot=new WeakMap,At=new WeakMap,jt=new WeakMap,_e),U,w,Kt,q,mt,Mt,ut,V,$t,It,Qt,vt,bt,ct,qt,x,kt,ie,ne,ae,oe,ue,ce,he,Xe,Ne,Us=(Ne=class extends Ut{constructor(t,s){super();d(this,x);d(this,U);d(this,w);d(this,Kt);d(this,q);d(this,mt);d(this,Mt);d(this,ut);d(this,V);d(this,$t);d(this,It);d(this,Qt);d(this,vt);d(this,bt);d(this,ct);d(this,qt,new Set);this.options=s,u(this,U,t),u(this,V,null),u(this,ut,re()),this.options.experimental_prefetchInRender||i(this,ut).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(s)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(i(this,w).addObserver(this),Oe(i(this,w),this.options)?m(this,x,kt).call(this):this.updateResult(),m(this,x,oe).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return le(i(this,w),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return le(i(this,w),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,m(this,x,ue).call(this),m(this,x,ce).call(this),i(this,w).removeObserver(this)}setOptions(t,s){const r=this.options,n=i(this,w);if(this.options=i(this,U).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof B(this.options.enabled,i(this,w))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");m(this,x,he).call(this),i(this,w).setOptions(this.options),r._defaulted&&!Wt(this.options,r)&&i(this,U).getQueryCache().notify({type:"observerOptionsUpdated",query:i(this,w),observer:this});const a=this.hasListeners();a&&Ee(i(this,w),n,this.options,r)&&m(this,x,kt).call(this),this.updateResult(s),a&&(i(this,w)!==n||B(this.options.enabled,i(this,w))!==B(r.enabled,i(this,w))||Ct(this.options.staleTime,i(this,w))!==Ct(r.staleTime,i(this,w)))&&m(this,x,ie).call(this);const o=m(this,x,ne).call(this);a&&(i(this,w)!==n||B(this.options.enabled,i(this,w))!==B(r.enabled,i(this,w))||o!==i(this,ct))&&m(this,x,ae).call(this,o)}getOptimisticResult(t){const s=i(this,U).getQueryCache().build(i(this,U),t),r=this.createResult(s,t);return Ls(this,r)&&(u(this,q,r),u(this,Mt,this.options),u(this,mt,i(this,w).state)),r}getCurrentResult(){return i(this,q)}trackResult(t,s){const r={};return Object.keys(t).forEach(n=>{Object.defineProperty(r,n,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(n),s==null||s(n),t[n])})}),r}trackProp(t){i(this,qt).add(t)}getCurrentQuery(){return i(this,w)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const s=i(this,U).defaultQueryOptions(t),r=i(this,U).getQueryCache().build(i(this,U),s);return r.fetch().then(()=>this.createResult(r,s))}fetch(t){return m(this,x,kt).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),i(this,q)))}createResult(t,s){var T;const r=i(this,w),n=this.options,a=i(this,q),o=i(this,mt),c=i(this,Mt),g=t!==r?t.state:i(this,Kt),{state:y}=t;let h={...y},S=!1,v;if(s._optimisticResults){const E=this.hasListeners(),wt=!E&&Oe(t,s),xt=E&&Ee(t,r,s,n);(wt||xt)&&(h={...h,...Ve(y.data,t.options)}),s._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:R,errorUpdatedAt:f,status:b}=h;if(s.select&&h.data!==void 0)if(a&&h.data===(o==null?void 0:o.data)&&s.select===i(this,$t))v=i(this,It);else try{u(this,$t,s.select),v=s.select(h.data),v=se(a==null?void 0:a.data,v,s),u(this,It,v),u(this,V,null)}catch(E){u(this,V,E)}else v=h.data;if(s.placeholderData!==void 0&&v===void 0&&b==="pending"){let E;if(a!=null&&a.isPlaceholderData&&s.placeholderData===(c==null?void 0:c.placeholderData))E=a.data;else if(E=typeof s.placeholderData=="function"?s.placeholderData((T=i(this,Qt))==null?void 0:T.state.data,i(this,Qt)):s.placeholderData,s.select&&E!==void 0)try{E=s.select(E),u(this,V,null)}catch(wt){u(this,V,wt)}E!==void 0&&(b="success",v=se(a==null?void 0:a.data,E,s),S=!0)}i(this,V)&&(R=i(this,V),v=i(this,It),f=Date.now(),b="error");const D=h.fetchStatus==="fetching",C=b==="pending",P=b==="error",j=C&&D,L=v!==void 0,I={status:b,fetchStatus:h.fetchStatus,isPending:C,isSuccess:b==="success",isError:P,isInitialLoading:j,isLoading:j,data:v,dataUpdatedAt:h.dataUpdatedAt,error:R,errorUpdatedAt:f,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:h.dataUpdateCount>0||h.errorUpdateCount>0,isFetchedAfterMount:h.dataUpdateCount>g.dataUpdateCount||h.errorUpdateCount>g.errorUpdateCount,isFetching:D,isRefetching:D&&!C,isLoadingError:P&&!L,isPaused:h.fetchStatus==="paused",isPlaceholderData:S,isRefetchError:P&&L,isStale:ve(t,s),refetch:this.refetch,promise:i(this,ut)};if(this.options.experimental_prefetchInRender){const E=Ht=>{I.status==="error"?Ht.reject(I.error):I.data!==void 0&&Ht.resolve(I.data)},wt=()=>{const Ht=u(this,ut,I.promise=re());E(Ht)},xt=i(this,ut);switch(xt.status){case"pending":t.queryHash===r.queryHash&&E(xt);break;case"fulfilled":(I.status==="error"||I.data!==xt.value)&&wt();break;case"rejected":(I.status!=="error"||I.error!==xt.reason)&&wt();break}}return I}updateResult(t){const s=i(this,q),r=this.createResult(i(this,w),this.options);if(u(this,mt,i(this,w).state),u(this,Mt,this.options),i(this,mt).data!==void 0&&u(this,Qt,i(this,w)),Wt(r,s))return;u(this,q,r);const n={},a=()=>{if(!s)return!0;const{notifyOnChangeProps:o}=this.options,c=typeof o=="function"?o():o;if(c==="all"||!c&&!i(this,qt).size)return!0;const l=new Set(c??i(this,qt));return this.options.throwOnError&&l.add("error"),Object.keys(i(this,q)).some(g=>{const y=g;return i(this,q)[y]!==s[y]&&l.has(y)})};(t==null?void 0:t.listeners)!==!1&&a()&&(n.listeners=!0),m(this,x,Xe).call(this,{...n,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&m(this,x,oe).call(this)}},U=new WeakMap,w=new WeakMap,Kt=new WeakMap,q=new WeakMap,mt=new WeakMap,Mt=new WeakMap,ut=new WeakMap,V=new WeakMap,$t=new WeakMap,It=new WeakMap,Qt=new WeakMap,vt=new WeakMap,bt=new WeakMap,ct=new WeakMap,qt=new WeakMap,x=new WeakSet,kt=function(t){m(this,x,he).call(this);let s=i(this,w).fetch(this.options,t);return t!=null&&t.throwOnError||(s=s.catch(K)),s},ie=function(){m(this,x,ue).call(this);const t=Ct(this.options.staleTime,i(this,w));if(gt||i(this,q).isStale||!te(t))return;const r=$e(i(this,q).dataUpdatedAt,t)+1;u(this,vt,setTimeout(()=>{i(this,q).isStale||this.updateResult()},r))},ne=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(i(this,w)):this.options.refetchInterval)??!1},ae=function(t){m(this,x,ce).call(this),u(this,ct,t),!(gt||B(this.options.enabled,i(this,w))===!1||!te(i(this,ct))||i(this,ct)===0)&&u(this,bt,setInterval(()=>{(this.options.refetchIntervalInBackground||me.isFocused())&&m(this,x,kt).call(this)},i(this,ct)))},oe=function(){m(this,x,ie).call(this),m(this,x,ae).call(this,m(this,x,ne).call(this))},ue=function(){i(this,vt)&&(clearTimeout(i(this,vt)),u(this,vt,void 0))},ce=function(){i(this,bt)&&(clearInterval(i(this,bt)),u(this,bt,void 0))},he=function(){const t=i(this,U).getQueryCache().build(i(this,U),this.options);if(t===i(this,w))return;const s=i(this,w);u(this,w,t),u(this,Kt,t.state),this.hasListeners()&&(s==null||s.removeObserver(this),t.addObserver(this))},Xe=function(t){A.batch(()=>{t.listeners&&this.listeners.forEach(s=>{s(i(this,q))}),i(this,U).getQueryCache().notify({query:i(this,w),type:"observerResultsUpdated"})})},Ne);function ks(e,t){return B(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Oe(e,t){return ks(e,t)||e.state.data!==void 0&&le(e,t,t.refetchOnMount)}function le(e,t,s){if(B(t.enabled,e)!==!1){const r=typeof s=="function"?s(e):s;return r==="always"||r!==!1&&ve(e,t)}return!1}function Ee(e,t,s,r){return(e!==t||B(r.enabled,e)===!1)&&(!s.suspense||e.state.status!=="error")&&ve(e,s)}function ve(e,t){return B(t.enabled,e)!==!1&&e.isStaleByTime(Ct(t.staleTime,e))}function Ls(e,t){return!Wt(e.getCurrentResult(),t)}var ht,lt,k,Z,tt,Yt,de,Ke,_s=(Ke=class extends Ut{constructor(t,s){super();d(this,tt);d(this,ht);d(this,lt);d(this,k);d(this,Z);u(this,ht,t),this.setOptions(s),this.bindMethods(),m(this,tt,Yt).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var r;const s=this.options;this.options=i(this,ht).defaultMutationOptions(t),Wt(this.options,s)||i(this,ht).getMutationCache().notify({type:"observerOptionsUpdated",mutation:i(this,k),observer:this}),s!=null&&s.mutationKey&&this.options.mutationKey&&St(s.mutationKey)!==St(this.options.mutationKey)?this.reset():((r=i(this,k))==null?void 0:r.state.status)==="pending"&&i(this,k).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=i(this,k))==null||t.removeObserver(this)}onMutationUpdate(t){m(this,tt,Yt).call(this),m(this,tt,de).call(this,t)}getCurrentResult(){return i(this,lt)}reset(){var t;(t=i(this,k))==null||t.removeObserver(this),u(this,k,void 0),m(this,tt,Yt).call(this),m(this,tt,de).call(this)}mutate(t,s){var r;return u(this,Z,s),(r=i(this,k))==null||r.removeObserver(this),u(this,k,i(this,ht).getMutationCache().build(i(this,ht),this.options)),i(this,k).addObserver(this),i(this,k).execute(t)}},ht=new WeakMap,lt=new WeakMap,k=new WeakMap,Z=new WeakMap,tt=new WeakSet,Yt=function(){var s;const t=((s=i(this,k))==null?void 0:s.state)??Je();u(this,lt,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},de=function(t){A.batch(()=>{var s,r,n,a,o,c,l,g;if(i(this,Z)&&this.hasListeners()){const y=i(this,lt).variables,h=i(this,lt).context;(t==null?void 0:t.type)==="success"?((r=(s=i(this,Z)).onSuccess)==null||r.call(s,t.data,y,h),(a=(n=i(this,Z)).onSettled)==null||a.call(n,t.data,null,y,h)):(t==null?void 0:t.type)==="error"&&((c=(o=i(this,Z)).onError)==null||c.call(o,t.error,y,h),(g=(l=i(this,Z)).onSettled)==null||g.call(l,void 0,t.error,y,h))}this.listeners.forEach(y=>{y(i(this,lt))})})},Ke),Ze=O.createContext(void 0),Jt=e=>{const t=O.useContext(Ze);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Ns=({client:e,children:t})=>(O.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),p.jsx(Ze.Provider,{value:e,children:t})),ts=O.createContext(!1),Ks=()=>O.useContext(ts);ts.Provider;function $s(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Hs=O.createContext($s()),Gs=()=>O.useContext(Hs);function es(e,t){return typeof e=="function"?e(...t):!!e}function fe(){}var Bs=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},Ys=e=>{O.useEffect(()=>{e.clearReset()},[e])},zs=({result:e,errorResetBoundary:t,throwOnError:s,query:r})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&es(s,[e.error,r]),Ws=e=>{e.suspense&&(e.staleTime===void 0&&(e.staleTime=1e3),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3)))},Vs=(e,t)=>e.isLoading&&e.isFetching&&!t,Js=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,De=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});function Xs(e,t,s){var y,h,S,v,R;const r=Jt(),n=Ks(),a=Gs(),o=r.defaultQueryOptions(e);(h=(y=r.getDefaultOptions().queries)==null?void 0:y._experimental_beforeQuery)==null||h.call(y,o),o._optimisticResults=n?"isRestoring":"optimistic",Ws(o),Bs(o,a),Ys(a);const c=!r.getQueryCache().get(o.queryHash),[l]=O.useState(()=>new t(r,o)),g=l.getOptimisticResult(o);if(O.useSyncExternalStore(O.useCallback(f=>{const b=n?fe:l.subscribe(A.batchCalls(f));return l.updateResult(),b},[l,n]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),O.useEffect(()=>{l.setOptions(o,{listeners:!1})},[o,l]),Js(o,g))throw De(o,l,a);if(zs({result:g,errorResetBoundary:a,throwOnError:o.throwOnError,query:r.getQueryCache().get(o.queryHash)}))throw g.error;if((v=(S=r.getDefaultOptions().queries)==null?void 0:S._experimental_afterQuery)==null||v.call(S,o,g),o.experimental_prefetchInRender&&!gt&&Vs(g,n)){const f=c?De(o,l,a):(R=r.getQueryCache().get(o.queryHash))==null?void 0:R.promise;f==null||f.catch(fe).finally(()=>{l.updateResult()})}return o.notifyOnChangeProps?g:l.trackResult(g)}function et(e,t){return Xs(e,Us)}function ss(e,t){const s=Jt(),[r]=O.useState(()=>new _s(s,e));O.useEffect(()=>{r.setOptions(e)},[r,e]);const n=O.useSyncExternalStore(O.useCallback(o=>r.subscribe(A.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=O.useCallback((o,c)=>{r.mutate(o,c).catch(fe)},[r]);if(n.error&&es(r.options.throwOnError,[n.error]))throw n.error;return{...n,mutate:a,mutateAsync:n.mutate}}const Zs=864e5,tr=/^\d{4}-\d{2}-\d{2}$/;function Fe(e,t=Date.now()){return new Date(t-e*Zs).toISOString().slice(0,10)}function er(e=30,t=Date.now()){return{fromDay:Fe(e-1,t),toDay:Fe(0,t)}}function sr(e){return tr.test(e)}function zt(){return typeof window<"u"&&window.__AGENT_API__?window.__AGENT_API__:`${typeof window<"u"&&window.__AGENT_BASE__||"/ai-gateway"}/api`}async function J(e,t){const s=await fetch(zt()+e,t);if(!s.ok)throw new Error(`${s.status} ${s.statusText}`);return await s.json()}const $={spend(e){const t=new URLSearchParams({from:e.fromDay,to:e.toDay});return J(`/spend?${t.toString()}`)},topThreads(e,t=10){const s=new URLSearchParams({from:e.fromDay,to:e.toDay,limit:`${t}`});return J(`/top-threads?${s.toString()}`)},reliability(e){const t=new URLSearchParams({from:e.fromDay,to:e.toDay});return J(`/reliability?${t.toString()}`)},runs(e=50){return J(`/runs?limit=${e}`)},toolCalls(e=50){return J(`/tool-calls?limit=${e}`)},approvals(e=50){return J(`/approvals?limit=${e}`)},async decideApproval(e,t){const s=await fetch(`${zt()}/approvals/${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!s.ok)throw new Error(`${s.status} ${s.statusText}`)},toolStats(e){const t=new URLSearchParams({from:e.fromDay,to:e.toDay});return J(`/tools?${t.toString()}`)},threads(e=50){return J(`/threads?limit=${e}`)},pricing(){return J("/pricing")},async upsertPrice(e){const t=await fetch(`${zt()}/pricing`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error(`${t.status} ${t.statusText}`)},streamEvents(e){const t=new EventSource(`${zt()}/stream`);return t.onmessage=s=>{try{e(JSON.parse(s.data))}catch{}},()=>t.close()}};function rr(e){return et({queryKey:["spend",e.fromDay,e.toDay],queryFn:()=>$.spend(e)})}function ir(e,t=10){return et({queryKey:["top-threads",e.fromDay,e.toDay,t],queryFn:()=>$.topThreads(e,t)})}function nr(e){return et({queryKey:["reliability",e.fromDay,e.toDay],queryFn:()=>$.reliability(e)})}function ar(e=50){return et({queryKey:["runs",e],queryFn:()=>$.runs(e)})}function or(e=50){return et({queryKey:["tool-calls",e],queryFn:()=>$.toolCalls(e)})}function ur(e=50){return et({queryKey:["threads",e],queryFn:()=>$.threads(e)})}function cr(e=50){return et({queryKey:["approvals",e],queryFn:()=>$.approvals(e)})}function hr(){const e=Jt();return ss({mutationFn:({toolCallId:t,input:s})=>$.decideApproval(t,s),onSuccess:()=>{e.invalidateQueries({queryKey:["approvals"]})}})}function lr(e){return et({queryKey:["tool-stats",e.fromDay,e.toDay],queryFn:()=>$.toolStats(e)})}function dr(){return et({queryKey:["pricing"],queryFn:()=>$.pricing()})}function fr(){const e=Jt();return ss({mutationFn:t=>$.upsertPrice(t),onSuccess:()=>{e.invalidateQueries({queryKey:["pricing"]})}})}function pr(e=200){const[t,s]=O.useState([]),[r,n]=O.useState(!1),a=O.useRef(0);return O.useEffect(()=>{n(!0);const o=$.streamEvents(c=>{a.current+=1,s(l=>rs(l,c,a.current,e))});return()=>{n(!1),o()}},[e]),{events:t,connected:r}}const yr=[{key:"spend",label:"Spend & usage",icon:p.jsx(ns,{})},{key:"models",label:"Models",icon:p.jsx(as,{})},{key:"actors",label:"Actors & budgets",icon:p.jsx(os,{})},{key:"runs",label:"Runs & tools",icon:p.jsx(ge,{})},{key:"reliability",label:"Reliability",icon:p.jsx(us,{})},{key:"approvals",label:"Approvals",icon:p.jsx(cs,{})},{key:"tools",label:"Tools",icon:p.jsx(ge,{})},{key:"pricing",label:"Pricing",icon:p.jsx(hs,{})},{key:"live",label:"Live",icon:p.jsx(ls,{})}],mr={byModel:[],byActor:[],trend:[]},vr=[],br=[],gr=[],Sr=[],Te=[],wr=[],xr={metrics:{runs:0,completed:0,failed:0,successRate:0,retries:0,durationP50Ms:null,durationP95Ms:null},byAgent:[],errors:[],trend:[]},Cr=[],Pr="501";function Rr(){const[e,t]=O.useState(er()),[s,r]=O.useState("spend"),n=rr(e),a=ir(e),o=or(),c=ur(),l=nr(e),g=ar(),y=cr(),h=hr(),S=lr(e),v=dr(),R=fr(),f=pr(),b=n.data??mr,D=v.isError&&v.error instanceof Error?v.error.message.startsWith(Pr):!1;return p.jsxs("div",{className:"relative min-h-full",children:[p.jsx("div",{className:"app-bg"}),p.jsxs("div",{className:"relative z-10 mx-auto max-w-[1180px] px-5 py-5",children:[p.jsx(Er,{range:e,onRange:t,connected:f.connected,liveCount:f.events.length}),p.jsx("nav",{className:"mb-5 flex flex-wrap gap-1",children:yr.map(C=>{const P=C.key==="live"?f.events.length:C.key==="approvals"?(y.data??Te).length:0;return p.jsxs("button",{type:"button",onClick:()=>r(C.key),className:`flex items-center gap-2 rounded-lg border px-3 py-1.5 text-xs transition-colors ${s===C.key?"border-[var(--accent)]/50 bg-[var(--accent)]/10 text-[var(--text)]":"border-transparent text-[var(--muted)] hover:text-[var(--text)]"}`,children:[C.icon,C.label,P>0&&p.jsx("span",{className:"mono tnum rounded bg-[var(--accent)]/20 px-1 text-[10px] text-[var(--accent)]",children:P})]},C.key)})}),p.jsx(Or,{section:s,overview:b,topThreads:a.data??gr,loadingSpend:n.isLoading,errorSpend:n.isError,toolCalls:o.data??vr,threads:c.data??br,reliability:l.data??xr,runs:g.data??Cr,approvals:y.data??Te,onDecideApproval:(C,P)=>h.mutateAsync({toolCallId:C,input:P}),toolStats:S.data??wr,liveEvents:f.events,connected:f.connected,prices:v.data??Sr,loadingPrices:v.isLoading,pricingUnavailable:D,onUpsertPrice:C=>R.mutateAsync(C),savingPrice:R.isPending})]})]})}function Or({section:e,overview:t,topThreads:s,loadingSpend:r,errorSpend:n,toolCalls:a,threads:o,reliability:c,runs:l,approvals:g,onDecideApproval:y,toolStats:h,liveEvents:S,connected:v,prices:R,loadingPrices:f,pricingUnavailable:b,onUpsertPrice:D,savingPrice:C}){if(n&&(e==="spend"||e==="models"||e==="actors"))return p.jsx("div",{className:"panel p-6 text-sm text-[var(--bad)]",children:"Failed to load the read-model. Is the governance read-model bound and the API reachable?"});if(r&&(e==="spend"||e==="models"||e==="actors"))return p.jsx("div",{className:"panel animate-pulse p-6 text-sm text-[var(--muted)]",children:"Loading…"});switch(e){case"spend":return p.jsx(Ss,{overview:t,topThreads:s});case"models":return p.jsx(gs,{rows:t.byModel});case"actors":return p.jsx(bs,{rows:t.byActor});case"runs":return p.jsx(vs,{toolCalls:a,threads:o});case"reliability":return p.jsx(ms,{overview:c,runs:l});case"approvals":return p.jsx(ys,{approvals:g,onDecide:y});case"tools":return p.jsx(ps,{rows:h});case"pricing":return p.jsx(fs,{prices:R,loading:f,unavailable:b,onUpsert:D,saving:C});case"live":return p.jsx(ds,{events:S,connected:v});default:return null}}function Er({range:e,onRange:t,connected:s,liveCount:r}){return p.jsxs("header",{className:"mb-5 flex flex-wrap items-center gap-4",children:[p.jsxs("div",{className:"flex items-center gap-2.5",children:[p.jsx("div",{className:"grid h-8 w-8 place-items-center rounded-lg border border-[var(--accent)]/40 bg-[var(--accent)]/10",children:p.jsx(is,{className:"h-4 w-4 text-[var(--accent)]"})}),p.jsxs("div",{className:"leading-none",children:[p.jsx("div",{className:"text-sm font-semibold tracking-tight",children:"AI gateway"}),p.jsx("div",{className:"mono text-[10px] uppercase tracking-[0.2em] text-[var(--muted)]",children:"governance console"})]})]}),p.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[p.jsx(Ae,{label:"From",value:e.fromDay,onChange:n=>t({...e,fromDay:n})}),p.jsx(Ae,{label:"To",value:e.toDay,onChange:n=>t({...e,toDay:n})}),p.jsxs("span",{className:"flex items-center gap-1.5 rounded-lg border border-[var(--line)] px-2.5 py-1.5 text-[11px] text-[var(--muted)]",children:[p.jsx("span",{className:`dot ${s?"s-ok pulse":"s-failed"}`,"aria-hidden":!0}),"live ",r>0?`· ${r}`:""]})]})]})}function Ae({label:e,value:t,onChange:s}){return p.jsxs("label",{className:"flex items-center gap-1.5 rounded-lg border border-[var(--line)] bg-[var(--panel)] px-2.5 py-1 text-[11px] text-[var(--muted)]",children:[p.jsx("span",{className:"uppercase tracking-wider",children:e}),p.jsx("input",{type:"date",value:t,onChange:r=>{const n=r.target.value;sr(n)&&s(n)},className:"mono bg-transparent text-[var(--text)] outline-none"})]})}const Dr=new qs({defaultOptions:{queries:{refetchInterval:5e3,refetchOnWindowFocus:!1,retry:1}}}),je=document.getElementById("root");je&&ws.createRoot(je).render(p.jsx(O.StrictMode,{children:p.jsx(Ns,{client:Dr,children:p.jsx(Rr,{})})}));