usage-board 4.0.1 → 5.0.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.
- package/dist/index.mjs +40 -22
- package/dist/public/_nuxt/3inMrCcs.js +146 -0
- package/dist/public/_nuxt/5M1aAlPv.js +6 -0
- package/dist/public/_nuxt/{C0GhHHgI.js → BHGcQrYH.js} +2 -2
- package/dist/public/_nuxt/{DF2WsXH3.js → BgVTqBr9.js} +1 -1
- package/dist/public/_nuxt/{DXWxIyGU.js → BhTZzeJU.js} +1 -1
- package/dist/public/_nuxt/{D7qEPtpx.js → BlxNEZ3W.js} +1 -1
- package/dist/public/_nuxt/BwYRMC0_.js +1 -0
- package/dist/public/_nuxt/C3BLG0Zo.js +21 -0
- package/dist/public/_nuxt/{De8DvPWL.js → C8lAAJpL.js} +1 -1
- package/dist/public/_nuxt/Cxd8QZxF.js +261 -0
- package/dist/public/_nuxt/DXeNXt_b.js +1 -0
- package/dist/public/_nuxt/DavRiQHq.js +25 -0
- package/dist/public/_nuxt/{Jp5cgQZi.js → DfL4oXhq.js} +3 -3
- package/dist/public/_nuxt/DjKivtvZ.js +1 -0
- package/dist/public/_nuxt/{37OOe3RF.js → OPi16VNs.js} +1 -1
- package/dist/public/_nuxt/builds/latest.json +1 -1
- package/dist/public/_nuxt/builds/meta/eff380a6-8407-4f41-af1f-39f3ae1dface.json +1 -0
- package/dist/public/_nuxt/{entry.DnkKc-6G.css → entry.BYVbC6M5.css} +1 -1
- package/dist/public/_nuxt/error-404.ABvo6GrV.css +1 -0
- package/dist/public/_nuxt/error-500.CaR7LJUF.css +1 -0
- package/dist/public/pricing-data/fast-multiplier-overrides.json +12 -0
- package/dist/public/pricing-data/litellm-pricing.json +43714 -0
- package/dist/public/pricing-data/models-dev-pricing.json +178004 -0
- package/dist/server/chunks/_/analysis-handlers.mjs +54 -0
- package/dist/server/chunks/_/pagination.mjs +16 -0
- package/dist/server/chunks/build/client.precomputed.mjs +1 -1
- package/dist/server/chunks/nitro/nitro.mjs +4976 -5765
- package/dist/server/chunks/routes/api/analysis/agent/session.json.mjs +28 -4
- package/dist/server/chunks/routes/api/analysis/agent/token.json.mjs +14 -4
- package/dist/server/chunks/routes/api/analysis/cache.json.mjs +12 -3
- package/dist/server/chunks/routes/api/analysis/hot-project.json.mjs +15 -5
- package/dist/server/chunks/routes/api/analysis/live-state.json.mjs +32 -0
- package/dist/server/chunks/routes/api/analysis/model.json.mjs +12 -3
- package/dist/server/chunks/routes/api/analysis/overview-cards.json.mjs +12 -3
- package/dist/server/chunks/routes/api/analysis/session.json.mjs +12 -3
- package/dist/server/chunks/routes/api/analysis/token/daily.json.mjs +25 -4
- package/dist/server/chunks/routes/api/analysis/token/today-hourly.json.mjs +12 -3
- package/dist/server/chunks/routes/api/analysis/token.json.mjs +12 -3
- package/dist/server/chunks/routes/api/projects/_project/modules.get.mjs +14 -6
- package/dist/server/chunks/routes/api/projects/catalog.get.mjs +12 -4
- package/dist/server/chunks/routes/renderer.mjs +11 -3
- package/dist/server/chunks/routes/ws.mjs +64 -59
- package/dist/server/index.mjs +11 -3
- package/dist/server/node_modules/@clack/core/dist/index.mjs +17 -0
- package/dist/server/node_modules/@clack/core/package.json +63 -0
- package/dist/server/node_modules/@clack/prompts/dist/index.mjs +145 -0
- package/dist/server/node_modules/@clack/prompts/package.json +68 -0
- package/dist/server/node_modules/dayjs/dayjs.min.js +1 -0
- package/dist/server/node_modules/dayjs/package.json +85 -0
- package/dist/server/node_modules/dayjs/plugin/utc.js +1 -0
- package/dist/server/node_modules/fast-string-truncated-width/dist/index.js +111 -0
- package/dist/server/node_modules/fast-string-truncated-width/dist/utils.js +20 -0
- package/dist/server/node_modules/fast-string-truncated-width/package.json +35 -0
- package/dist/server/node_modules/fast-string-width/dist/index.js +14 -0
- package/dist/server/node_modules/fast-string-width/package.json +34 -0
- package/dist/server/node_modules/fast-wrap-ansi/lib/main.js +218 -0
- package/dist/server/node_modules/fast-wrap-ansi/package.json +51 -0
- package/dist/server/node_modules/sisteransi/package.json +34 -0
- package/dist/server/node_modules/sisteransi/src/index.js +58 -0
- package/dist/server/node_modules/xdg-basedir/index.js +30 -0
- package/dist/server/node_modules/xdg-basedir/package.json +47 -0
- package/dist/server/package.json +10 -2
- package/package.json +11 -9
- package/dist/public/_nuxt/65Ayv2XK.js +0 -146
- package/dist/public/_nuxt/BOWwkrCY.js +0 -25
- package/dist/public/_nuxt/D9-Yw1TR.js +0 -1
- package/dist/public/_nuxt/DKaPq50Z.js +0 -6
- package/dist/public/_nuxt/DgMMKsPE.js +0 -258
- package/dist/public/_nuxt/DxvuOJRP.js +0 -1
- package/dist/public/_nuxt/builds/meta/34b12f78-e5b7-490f-99ba-b4a8ab41b914.json +0 -1
- package/dist/public/_nuxt/error-404.CFBEg71j.css +0 -1
- package/dist/public/_nuxt/error-500.BqCnH31G.css +0 -1
- package/dist/public/_nuxt/qXgLTL_3.js +0 -21
- package/dist/public/_nuxt/y6mAKUDU.js +0 -1
- package/dist/server/chunks/routes/api/payload.json.mjs +0 -26
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,31 @@
|
|
|
1
1
|
import path, { dirname, resolve } from "node:path";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { log } from "@clack/prompts";
|
|
3
4
|
import cac from "cac";
|
|
4
5
|
import { createRuntimeServer } from "nuxt-devkit-server";
|
|
5
|
-
import process from "node:process";
|
|
6
|
+
import process$1 from "node:process";
|
|
6
7
|
import childProcess, { execFile } from "node:child_process";
|
|
7
8
|
import fs, { constants } from "node:fs/promises";
|
|
8
9
|
import { promisify } from "node:util";
|
|
9
10
|
import os from "node:os";
|
|
10
11
|
import fs$1 from "node:fs";
|
|
11
12
|
import { Buffer } from "node:buffer";
|
|
13
|
+
//#region server/runtime/startup-state.ts
|
|
14
|
+
const USAGE_STARTUP_STATE_KEY = Symbol.for("usage-board.startup-state");
|
|
15
|
+
function getUsageStartupState() {
|
|
16
|
+
const globalWithUsageState = globalThis;
|
|
17
|
+
globalWithUsageState[USAGE_STARTUP_STATE_KEY] ??= {};
|
|
18
|
+
return globalWithUsageState[USAGE_STARTUP_STATE_KEY];
|
|
19
|
+
}
|
|
20
|
+
function prepareUsageStartupReady() {
|
|
21
|
+
const state = getUsageStartupState();
|
|
22
|
+
state.ready ??= new Promise((resolve, reject) => {
|
|
23
|
+
state.resolve = resolve;
|
|
24
|
+
state.reject = reject;
|
|
25
|
+
});
|
|
26
|
+
return state.ready;
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
12
29
|
//#region node_modules/.pnpm/is-docker@3.0.0/node_modules/is-docker/index.js
|
|
13
30
|
let isDockerCached;
|
|
14
31
|
function hasDockerEnv() {
|
|
@@ -48,7 +65,7 @@ function isInsideContainer() {
|
|
|
48
65
|
//#endregion
|
|
49
66
|
//#region node_modules/.pnpm/is-wsl@3.1.1/node_modules/is-wsl/index.js
|
|
50
67
|
const isWsl = () => {
|
|
51
|
-
if (process.platform !== "linux") return false;
|
|
68
|
+
if (process$1.platform !== "linux") return false;
|
|
52
69
|
if (os.release().toLowerCase().includes("microsoft")) {
|
|
53
70
|
if (isInsideContainer()) return false;
|
|
54
71
|
return true;
|
|
@@ -59,11 +76,11 @@ const isWsl = () => {
|
|
|
59
76
|
if (fs$1.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop") || fs$1.existsSync("/run/WSL")) return !isInsideContainer();
|
|
60
77
|
return false;
|
|
61
78
|
};
|
|
62
|
-
var is_wsl_default = process.env.__IS_WSL_TEST__ ? isWsl : isWsl();
|
|
79
|
+
var is_wsl_default = process$1.env.__IS_WSL_TEST__ ? isWsl : isWsl();
|
|
63
80
|
//#endregion
|
|
64
81
|
//#region node_modules/.pnpm/powershell-utils@0.1.0/node_modules/powershell-utils/index.js
|
|
65
82
|
const execFile$2 = promisify(childProcess.execFile);
|
|
66
|
-
const powerShellPath$1 = () => `${process.env.SYSTEMROOT || process.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
|
|
83
|
+
const powerShellPath$1 = () => `${process$1.env.SYSTEMROOT || process$1.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
|
|
67
84
|
const executePowerShell = async (command, options = {}) => {
|
|
68
85
|
const { powerShellPath: psPath, ...execFileOptions } = options;
|
|
69
86
|
const encodedCommand = executePowerShell.encodeCommand(command);
|
|
@@ -170,7 +187,7 @@ function defineLazyProperty(object, propertyName, valueGetter) {
|
|
|
170
187
|
//#region node_modules/.pnpm/default-browser-id@5.0.1/node_modules/default-browser-id/index.js
|
|
171
188
|
const execFileAsync$3 = promisify(execFile);
|
|
172
189
|
async function defaultBrowserId() {
|
|
173
|
-
if (process.platform !== "darwin") throw new Error("macOS only");
|
|
190
|
+
if (process$1.platform !== "darwin") throw new Error("macOS only");
|
|
174
191
|
const { stdout } = await execFileAsync$3("defaults", [
|
|
175
192
|
"read",
|
|
176
193
|
"com.apple.LaunchServices/com.apple.launchservices.secure",
|
|
@@ -184,7 +201,7 @@ async function defaultBrowserId() {
|
|
|
184
201
|
//#region node_modules/.pnpm/run-applescript@7.1.0/node_modules/run-applescript/index.js
|
|
185
202
|
const execFileAsync$2 = promisify(execFile);
|
|
186
203
|
async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
|
|
187
|
-
if (process.platform !== "darwin") throw new Error("macOS only");
|
|
204
|
+
if (process$1.platform !== "darwin") throw new Error("macOS only");
|
|
188
205
|
const outputArguments = humanReadableOutput ? [] : ["-ss"];
|
|
189
206
|
const execOptions = {};
|
|
190
207
|
if (signal) execOptions.signal = signal;
|
|
@@ -295,14 +312,14 @@ async function defaultBrowser$1(_execFileAsync = execFileAsync$1) {
|
|
|
295
312
|
const execFileAsync = promisify(execFile);
|
|
296
313
|
const titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
|
|
297
314
|
async function defaultBrowser() {
|
|
298
|
-
if (process.platform === "darwin") {
|
|
315
|
+
if (process$1.platform === "darwin") {
|
|
299
316
|
const id = await defaultBrowserId();
|
|
300
317
|
return {
|
|
301
318
|
name: await bundleName(id),
|
|
302
319
|
id
|
|
303
320
|
};
|
|
304
321
|
}
|
|
305
|
-
if (process.platform === "linux") {
|
|
322
|
+
if (process$1.platform === "linux") {
|
|
306
323
|
const { stdout } = await execFileAsync("xdg-mime", [
|
|
307
324
|
"query",
|
|
308
325
|
"default",
|
|
@@ -314,18 +331,18 @@ async function defaultBrowser() {
|
|
|
314
331
|
id
|
|
315
332
|
};
|
|
316
333
|
}
|
|
317
|
-
if (process.platform === "win32") return defaultBrowser$1();
|
|
334
|
+
if (process$1.platform === "win32") return defaultBrowser$1();
|
|
318
335
|
throw new Error("Only macOS, Linux, and Windows are supported");
|
|
319
336
|
}
|
|
320
337
|
//#endregion
|
|
321
338
|
//#region node_modules/.pnpm/is-in-ssh@1.0.0/node_modules/is-in-ssh/index.js
|
|
322
|
-
const isInSsh = Boolean(process.env.SSH_CONNECTION || process.env.SSH_CLIENT || process.env.SSH_TTY);
|
|
339
|
+
const isInSsh = Boolean(process$1.env.SSH_CONNECTION || process$1.env.SSH_CLIENT || process$1.env.SSH_TTY);
|
|
323
340
|
//#endregion
|
|
324
341
|
//#region node_modules/.pnpm/open@11.0.0/node_modules/open/index.js
|
|
325
342
|
const fallbackAttemptSymbol = Symbol("fallbackAttempt");
|
|
326
343
|
const __dirname = import.meta.url ? path.dirname(fileURLToPath(import.meta.url)) : "";
|
|
327
344
|
const localXdgOpenPath = path.join(__dirname, "xdg-open");
|
|
328
|
-
const { platform, arch } = process;
|
|
345
|
+
const { platform, arch } = process$1;
|
|
329
346
|
const tryEachApp = async (apps, opener) => {
|
|
330
347
|
if (apps.length === 0) return;
|
|
331
348
|
const errors = [];
|
|
@@ -438,7 +455,7 @@ const baseOpen = async (options) => {
|
|
|
438
455
|
await fs.access(localXdgOpenPath, constants.X_OK);
|
|
439
456
|
exeLocalXdgOpen = true;
|
|
440
457
|
} catch {}
|
|
441
|
-
command = process.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen) ? "xdg-open" : localXdgOpenPath;
|
|
458
|
+
command = process$1.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen) ? "xdg-open" : localXdgOpenPath;
|
|
442
459
|
}
|
|
443
460
|
if (appArguments.length > 0) cliArguments.push(...appArguments);
|
|
444
461
|
if (!options.wait) {
|
|
@@ -539,22 +556,23 @@ defineLazyProperty(apps, "safari", () => detectPlatformBinary({ darwin: "Safari"
|
|
|
539
556
|
//#endregion
|
|
540
557
|
//#region package.json
|
|
541
558
|
var name = "usage-board";
|
|
542
|
-
var version = "
|
|
559
|
+
var version = "5.0.0";
|
|
543
560
|
//#endregion
|
|
544
561
|
//#region src/index.ts
|
|
545
562
|
const cli = cac(name);
|
|
546
563
|
cli.command("", "Start tokens usage analysis").option("--host <host>", "Host", { default: "127.0.0.1" }).option("--port <port>", "Port", { default: 7777 }).option("--open", "Open browser", { default: true }).action(async (option) => {
|
|
547
|
-
|
|
548
|
-
|
|
564
|
+
const outputDir = resolve(dirname(fileURLToPath(import.meta.url)), "./");
|
|
565
|
+
process.env.USAGE_BOARD_PRICING_DATA_DIR = resolve(outputDir, "public", "pricing-data");
|
|
566
|
+
const app = await createRuntimeServer({
|
|
567
|
+
path: outputDir,
|
|
549
568
|
host: option.host,
|
|
550
|
-
port: option.port
|
|
551
|
-
onReady: async ({ app }) => {
|
|
552
|
-
if (option.open) {
|
|
553
|
-
console.log(`Usage board is running at ${app.url}`);
|
|
554
|
-
await open(app.url);
|
|
555
|
-
}
|
|
556
|
-
}
|
|
569
|
+
port: option.port
|
|
557
570
|
});
|
|
571
|
+
await prepareUsageStartupReady();
|
|
572
|
+
if (option.open) {
|
|
573
|
+
log.success(`Usage board is running at: ${app.url}`);
|
|
574
|
+
await open(app.url);
|
|
575
|
+
}
|
|
558
576
|
});
|
|
559
577
|
cli.help();
|
|
560
578
|
cli.version(version);
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import{N as kt,O as St,P as De,Q as te,R as At,T as Xe,U as le,V as Q,W as Y,X as Ye,Y as K,Z as ke,$ as he,a0 as Ce,a1 as Ke,a2 as F,a3 as Tt,a4 as qe,a5 as $t,a6 as Dt,a7 as Ct,a8 as ot,a9 as ee,aa as it,ab as wt,ac as Pt,ad as re,ae as we,af as Mt,ag as Ee,ah as Ut,ai as Ze,aj as Ae,ak as Rt,al as Et,am as Lt,an as lt,ao as jt,ap as Ht,aq as Ot,ar as Vt,as as Wt,at as He,au as Oe,av as Gt,aw as Bt,ax as rt,c as Nt,_ as Ve,S as ct,C as zt,a as Te,f as Ft,z as We,A as It,I as ye,u as Xt,e as $e,k as ge,b as ce,d as Je,F as dt,ay as Yt,p as Pe,h as Kt,i as qt,j as fe,D as Qe,az as et,aA as tt,aB as at,G as Zt,H as Jt}from"./Cxd8QZxF.js";import{j as Qt,k as ea,l as st,m as ta,u as aa,e as sa,i as Me,_ as na,a as oa,b as ia}from"./DavRiQHq.js";import{e as se,$ as la,k as ra,N as me,a0 as Ge,o as S,c as H,h as ca,r as Be,Y as Ue,K as da,a8 as Re,X as ut,M as ht,a1 as gt,G as M,B as ua,C as ha,g as N,w as O,i as d,b as D,l as ve,a as P,D as ne,t as B,F as ae,E as be,I as ga,P as nt,q as ma}from"./DfL4oXhq.js";import{u as xe}from"./5M1aAlPv.js";import"./BHGcQrYH.js";const pa=Object.assign(Object.assign({},kt),{tooltip:void 0,annotations:void 0});class fa extends St{constructor(a,e,s){var l;super(a),this._defaultConfig=pa,this.config=this._defaultConfig,e&&(this.updateContainer(e,!0),this.component=e.component),s&&this.setData(s,!0),!((l=this.component)===null||l===void 0)&&l.datamodel.data&&this.render()}setData(a,e){var s;const{config:l}=this;this.component&&this.component.setData(a),e||this.render(),(s=l.tooltip)===null||s===void 0||s.hide()}updateContainer(a,e){super.updateContainer(a),this._removeAllChildren(),this.component=a.component,a.sizing&&(this.component.sizing=a.sizing),this.element.appendChild(this.component.element);const s=a.tooltip;s&&(s.hasContainer()||s.setContainer(this._container),s.setComponents([this.component]));const l=a.annotations;l&&this.element.appendChild(l.element),this.element.appendChild(this._svgDefs.node()),this.element.appendChild(this._svgDefsExternal.node()),e||this.render()}updateComponent(a,e){this.component.setConfig(a),e||this.render()}update(a,e,s){a&&this.updateContainer(a,!0),e&&this.updateComponent(e,!0),s&&this.setData(s,!0),this.render()}getFitWidthScale(){const{config:a,component:e}=this,s=e;if(!s.getWidth)return 1;const l=s.getWidth()+a.margin.left+a.margin.right;return this.width/l}_preRender(){var a,e;super._preRender(),this.component.setSize(this.width,this.height,this.containerWidth,this.containerHeight),this.component.setContainerMargin(this.config.margin),(a=this.config.annotations)===null||a===void 0||a.setSize(this.width,this.height,this.containerWidth,this.containerHeight),(e=this.config.annotations)===null||e===void 0||e.setContainerMargin(this.config.margin)}_render(a){var e,s;const{config:l,component:r}=this;super._render(a),r.g.attr("transform",`translate(${l.margin.left},${l.margin.top})`),r.render(a),(e=l.annotations)===null||e===void 0||e.render(a),l.tooltip&&l.tooltip.update(),(s=l.onRenderComplete)===null||s===void 0||s.call(l,this.svg.node(),l.margin,this.containerWidth,this.containerHeight,this.width,this.height)}render(a=this.config.duration){const{config:e,component:s}=this;if(e.sizing===De.Extend||e.sizing===De.FitWidth){const l=e.sizing===De.FitWidth,r=s,n=r.getWidth()+e.margin.left+e.margin.right,t=r.getHeight()+e.margin.top+e.margin.bottom,u=l?this.getFitWidthScale():1,i=this.svg.attr("width"),o=this.svg.attr("height"),p=n*u,m=t*u,_=i||o;te(this.svg,_?a:0).attr("width",p).attr("height",m).attr("viewBox",`0 0 ${n} ${l?m:t}`).attr("preserveAspectRatio","xMinYMin")}else this.svg.attr("width",this.config.width||this.containerWidth).attr("height",this.config.height||this.containerHeight);this._resizeObserver||this._setUpResizeObserver(),cancelAnimationFrame(this._renderAnimationFrameId),this._renderAnimationFrameId=requestAnimationFrame(()=>{this._preRender(),this._render(a)})}_onResize(){var a;const{config:e}=this;super._onResize(),(a=e.tooltip)===null||a===void 0||a.hide()}destroy(){var a,e;const{component:s,config:l}=this;super.destroy(),s?.destroy(),(a=l.tooltip)===null||a===void 0||a.destroy(),(e=l.annotations)===null||e===void 0||e.destroy()}}function va(g){return g.innerRadius}function ya(g){return g.outerRadius}function ba(g){return g.startAngle}function xa(g){return g.endAngle}function _a(g){return g&&g.padAngle}function ka(g,a,e,s,l,r,n,t){var u=e-g,i=s-a,o=n-l,p=t-r,m=p*u-o*i;if(!(m*m<K))return m=(o*(a-r)-p*(g-l))/m,[g+m*u,a+m*i]}function _e(g,a,e,s,l,r,n){var t=g-e,u=a-s,i=(n?r:-r)/he(t*t+u*u),o=i*u,p=-i*t,m=g+o,_=a+p,v=e+o,k=s+p,c=(m+v)/2,h=(_+k)/2,f=v-m,T=k-_,C=f*f+T*T,A=l-r,x=m*k-v*_,R=(T<0?-1:1)*he(Tt(0,A*A*C-x*x)),z=(x*T-f*R)/C,L=(-x*f-T*R)/C,j=(x*T+f*R)/C,V=(-x*f+T*R)/C,W=z-c,b=L-h,w=j-c,I=V-h;return W*W+b*b>w*w+I*I&&(z=j,L=V),{cx:z,cy:L,x01:-o,y01:-p,x11:z*(l/A-1),y11:L*(l/A-1)}}function Sa(){var g=va,a=ya,e=Y(0),s=null,l=ba,r=xa,n=_a,t=null,u=At(i);function i(){var o,p,m=+g.apply(this,arguments),_=+a.apply(this,arguments),v=l.apply(this,arguments)-Ye,k=r.apply(this,arguments)-Ye,c=Ke(k-v),h=k>v;if(t||(t=o=u()),_<m&&(p=_,_=m,m=p),!(_>K))t.moveTo(0,0);else if(c>ke-K)t.moveTo(_*le(v),_*Q(v)),t.arc(0,0,_,v,k,!h),m>K&&(t.moveTo(m*le(k),m*Q(k)),t.arc(0,0,m,k,v,h));else{var f=v,T=k,C=v,A=k,x=c,R=c,z=n.apply(this,arguments)/2,L=z>K&&(s?+s.apply(this,arguments):he(m*m+_*_)),j=Ce(Ke(_-m)/2,+e.apply(this,arguments)),V=j,W=j,b,w;if(L>K){var I=qe(L/m*Q(z)),J=qe(L/_*Q(z));(x-=I*2)>K?(I*=h?1:-1,C+=I,A-=I):(x=0,C=A=(v+k)/2),(R-=J*2)>K?(J*=h?1:-1,f+=J,T-=J):(R=0,f=T=(v+k)/2)}var y=_*le(f),E=_*Q(f),U=m*le(A),G=m*Q(A);if(j>K){var X=_*le(T),oe=_*Q(T),de=m*le(C),pe=m*Q(C),Z;if(c<Xe)if(Z=ka(y,E,de,pe,X,oe,U,G)){var ue=y-Z[0],$=E-Z[1],q=X-Z[0],ie=oe-Z[1],Fe=1/Q($t((ue*q+$*ie)/(he(ue*ue+$*$)*he(q*q+ie*ie)))/2),Ie=he(Z[0]*Z[0]+Z[1]*Z[1]);V=Ce(j,(m-Ie)/(Fe-1)),W=Ce(j,(_-Ie)/(Fe+1))}else V=W=0}R>K?W>K?(b=_e(de,pe,y,E,_,W,h),w=_e(X,oe,U,G,_,W,h),t.moveTo(b.cx+b.x01,b.cy+b.y01),W<j?t.arc(b.cx,b.cy,W,F(b.y01,b.x01),F(w.y01,w.x01),!h):(t.arc(b.cx,b.cy,W,F(b.y01,b.x01),F(b.y11,b.x11),!h),t.arc(0,0,_,F(b.cy+b.y11,b.cx+b.x11),F(w.cy+w.y11,w.cx+w.x11),!h),t.arc(w.cx,w.cy,W,F(w.y11,w.x11),F(w.y01,w.x01),!h))):(t.moveTo(y,E),t.arc(0,0,_,f,T,!h)):t.moveTo(y,E),!(m>K)||!(x>K)?t.lineTo(U,G):V>K?(b=_e(U,G,X,oe,m,-V,h),w=_e(y,E,de,pe,m,-V,h),t.lineTo(b.cx+b.x01,b.cy+b.y01),V<j?t.arc(b.cx,b.cy,V,F(b.y01,b.x01),F(w.y01,w.x01),!h):(t.arc(b.cx,b.cy,V,F(b.y01,b.x01),F(b.y11,b.x11),!h),t.arc(0,0,m,F(b.cy+b.y11,b.cx+b.x11),F(w.cy+w.y11,w.cx+w.x11),h),t.arc(w.cx,w.cy,V,F(w.y11,w.x11),F(w.y01,w.x01),!h))):t.arc(0,0,m,A,C,h)}if(t.closePath(),o)return t=null,o+""||null}return i.centroid=function(){var o=(+g.apply(this,arguments)+ +a.apply(this,arguments))/2,p=(+l.apply(this,arguments)+ +r.apply(this,arguments))/2-Xe/2;return[le(p)*o,Q(p)*o]},i.innerRadius=function(o){return arguments.length?(g=typeof o=="function"?o:Y(+o),i):g},i.outerRadius=function(o){return arguments.length?(a=typeof o=="function"?o:Y(+o),i):a},i.cornerRadius=function(o){return arguments.length?(e=typeof o=="function"?o:Y(+o),i):e},i.padRadius=function(o){return arguments.length?(s=o==null?null:typeof o=="function"?o:Y(+o),i):s},i.startAngle=function(o){return arguments.length?(l=typeof o=="function"?o:Y(+o),i):l},i.endAngle=function(o){return arguments.length?(r=typeof o=="function"?o:Y(+o),i):r},i.padAngle=function(o){return arguments.length?(n=typeof o=="function"?o:Y(+o),i):n},i.context=function(o){return arguments.length?(t=o??null,i):t},i}function Aa(g,a){return a<g?-1:a>g?1:a>=g?0:NaN}function Ta(g){return g}function $a(){var g=Ta,a=Aa,e=null,s=Y(0),l=Y(ke),r=Y(0);function n(t){var u,i=(t=Dt(t)).length,o,p,m=0,_=new Array(i),v=new Array(i),k=+s.apply(this,arguments),c=Math.min(ke,Math.max(-ke,l.apply(this,arguments)-k)),h,f=Math.min(Math.abs(c)/i,r.apply(this,arguments)),T=f*(c<0?-1:1),C;for(u=0;u<i;++u)(C=v[_[u]=u]=+g(t[u],u,t))>0&&(m+=C);for(a!=null?_.sort(function(A,x){return a(v[A],v[x])}):e!=null&&_.sort(function(A,x){return e(t[A],t[x])}),u=0,p=m?(c-i*T)/m:0;u<i;++u,k=h)o=_[u],C=v[o],h=k+(C>0?C*p:0)+T,v[o]={data:t[o],index:u,value:C,startAngle:k,endAngle:h,padAngle:f};return v}return n.value=function(t){return arguments.length?(g=typeof t=="function"?t:Y(+t),n):g},n.sortValues=function(t){return arguments.length?(a=t,e=null,n):a},n.sort=function(t){return arguments.length?(e=t,a=null,n):e},n.startAngle=function(t){return arguments.length?(s=typeof t=="function"?t:Y(+t),n):s},n.endAngle=function(t){return arguments.length?(l=typeof t=="function"?t:Y(+t),n):l},n.padAngle=function(t){return arguments.length?(r=typeof t=="function"?t:Y(+t),n):r},n}function Da({x:g,y:a,w:e,h:s,tl:l=!1,tr:r=!1,bl:n=!1,br:t=!1,r:u=0}){let i;i=`M${g+u},${a}h${e-2*u}`;let o=r?u:0,p=r?0:u;return i+=`a${o},${o} 0 0 1 ${o},${o}`,i+=`h${p}v${p}`,i+=`v${s-2*u}`,o=t?u:0,p=t?0:u,i+=`a${o},${o} 0 0 1 ${-o},${o}`,i+=`v${p}h${-p}`,i+=`h${2*u-e}`,o=n?u:0,p=n?0:u,i+=`a${o},${o} 0 0 1 ${-o},${-o}`,i+=`h${-p}v${-p}`,i+=`v${2*u-s}`,o=l?u:0,p=l?0:u,i+=`a${o},${o} 0 0 1 ${o},${-o}`,i+=`v${-p}h${p}`,i+="z",i}const Ca=Object.assign(Object.assign({},Ct),{color:void 0,barMaxWidth:void 0,barWidth:void 0,dataStep:void 0,barPadding:0,roundedCorners:2,cursor:null,barMinHeight1Px:!1,barMinHeightZeroValue:null,orientation:ot.Vertical}),mt=ee`
|
|
2
|
+
label: stacked-bar-component;
|
|
3
|
+
`,wa=it`
|
|
4
|
+
:root {
|
|
5
|
+
--vis-stacked-bar-cursor: default;
|
|
6
|
+
--vis-stacked-bar-fill-color: var(--vis-color-main);
|
|
7
|
+
--vis-stacked-bar-stroke-color: none;
|
|
8
|
+
--vis-stacked-bar-stroke-width: 0px;
|
|
9
|
+
--vis-stacked-bar-hover-stroke-width: none;
|
|
10
|
+
--vis-stacked-bar-hover-stroke-color: none;
|
|
11
|
+
|
|
12
|
+
/* Dark Theme */
|
|
13
|
+
--vis-dark-stacked-bar-stroke-color: none;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
body.theme-dark ${`.${mt}`} {
|
|
17
|
+
--vis-stacked-bar-stroke-color: var(--vis-dark-stacked-bar-stroke-color);
|
|
18
|
+
}
|
|
19
|
+
`,Se=ee`
|
|
20
|
+
label: bar;
|
|
21
|
+
fill: var(--vis-stacked-bar-fill-color);
|
|
22
|
+
stroke: var(--vis-stacked-bar-stroke-color);
|
|
23
|
+
stroke-width: var(--vis-stacked-bar-stroke-width);
|
|
24
|
+
cursor: var(--vis-stacked-bar-cursor);
|
|
25
|
+
|
|
26
|
+
&:hover {
|
|
27
|
+
stroke-width: var(--vis-stacked-bar-hover-stroke-width);
|
|
28
|
+
stroke: var(--vis-stacked-bar-hover-stroke-color);
|
|
29
|
+
}
|
|
30
|
+
`,Le=ee`
|
|
31
|
+
label: barGroup;
|
|
32
|
+
`,pt=ee`
|
|
33
|
+
label: barGroupExit;
|
|
34
|
+
`,Pa=Object.freeze(Object.defineProperty({__proto__:null,bar:Se,barGroup:Le,barGroupExit:pt,globalStyles:wa,root:mt},Symbol.toStringTag,{value:"Module"}));class Ne extends wt{constructor(a){super(),this._defaultConfig=Ca,this.config=this._defaultConfig,this.getAccessors=()=>Pt(this.config.y)?this.config.y:[this.config.y],this.stacked=!0,this.events={},this._barData=[],a&&this.setConfig(a)}get bleed(){if(this._barData=this._getVisibleData(),this._barData.length===0)return{top:0,bottom:0,left:0,right:0};const a=!this.isVertical()&&this.dataScale.range()[0]>this.dataScale.range()[1],e=this.dataScale.domain(),s=this._getBarWidth()/2,l=this._barData.map((_,v)=>re(_,this.config.x,v)),r=we(l),n=Mt(l),t=this.dataScale(r),u=this.dataScale(n),i=this.dataScale.invert(t+(a?s:-s)),o=this.dataScale.invert(u+(a?-s:s)),p=i<=e[0]?this.dataScale(e[0])-this.dataScale(i):0,m=o>e[1]?this.dataScale(o)-this.dataScale(e[1]):0;return{top:this.isVertical()?0:a?-m:p,bottom:this.isVertical()?0:a?-p:m,left:this.isVertical()?p:0,right:this.isVertical()?m:0}}get dataScale(){return this.isVertical()?this.xScale:this.yScale}get valueScale(){return this.isVertical()?this.yScale:this.xScale}isVertical(){return this.config.orientation===ot.Vertical}_render(a){const{config:e}=this,s=Ee(a)?a:e.duration,l=this.getAccessors(),r=Ut(this._barData,0,l,this._prevNegative);this._prevNegative=r.map(v=>!!v.isMostlyNegative);const n=this.g.selectAll(`.${Le}`).data(this._barData,(v,k)=>{var c;return`${(c=Ze(v,e.id,k))!==null&&c!==void 0?c:k}`}),t=(v,k)=>{const c=this.dataScale(re(v,e.x,k)),h=this.isVertical()?c:0,f=this.isVertical()?0:c;return`translate(${h},${f})`},i=n.enter().append("g").attr("class",Le).attr("transform",t).style("opacity",1).merge(n);te(i,s).attr("transform",t).style("opacity",1);const o=n.exit().attr("class",pt);te(o,s).style("opacity",0).remove(),te(o.selectAll(`.${Se}`),s).attr("transform",this.isVertical()?`translate(0,${this._height/3})`:`translate(${this._width/6},0)`);const p=i.selectAll(`.${Se}`).data((v,k)=>r.map((c,h)=>({datum:v,index:k,stacked:c[k],stackIndex:h,isEnding:h===r.length-1||h<=r.length-1&&r[h+1][k][0]!==c[k][1]})).filter(c=>c.stacked[0]!==c.stacked[1]),v=>v.stackIndex),_=p.enter().append("path").attr("class",Se).attr("d",v=>this._getBarPath(v,!0)).style("fill",v=>Ae(v.datum,e.color,v.stackIndex)).merge(p);te(_,s).attr("d",v=>this._getBarPath(v)).style("fill",v=>Ae(v.datum,e.color,v.stackIndex)).style("cursor",v=>Ze(v.datum,e.cursor,v.stackIndex)),te(p.exit(),s).style("opacity",0).remove()}_getBarWidth(){const{config:a,datamodel:{data:e}}=this;if(Rt(e))return 0;if(a.barWidth)return we([a.barWidth,a.barMaxWidth]);const s=this.dataScale.bandwidth,l=this.dataScale.domain?this.dataScale.domain():[];let n=1+(s?l.length:l[1]-l[0])/a.dataStep||!s&&e.filter((i,o)=>{const p=re(i,a.x,o);return p>=l[0]&&p<=l[1]}).length||e.length;!s&&n>=2&&(n+=1);const u=(n<2?1:1-a.barPadding)*(this.isVertical()?this._width:this._height)/n;return we([u,a.barMaxWidth])}_getVisibleData(){const{config:a,datamodel:{data:e}}=this,s=this._getBarWidth(),l=e.length<2?0:s/2,r=this.dataScale,n=Math.abs(r.invert(l)-r.invert(0));return e?.filter((u,i)=>{const o=re(u,a.x,i),p=r.domain(),m=+p[0],_=+p[1];return o>=m-n&&o<=_+n})}_getBarPath(a,e=!1){const{config:s}=this,l=this.getAccessors(),r=this._getBarWidth(),n=a.stacked[1]<0,t=a.isEnding,u=re(a.datum,l[a.stackIndex],a.index),i=e?0:Math.abs(this.valueScale(a.stacked[0])-this.valueScale(a.stacked[1])),o=!e&&s.barMinHeight1Px&&i<1&&isFinite(u)&&u!==s.barMinHeightZeroValue?1:i,p=e?this.valueScale(0):this.valueScale(n?a.stacked[0]:a.stacked[1])-(i<1&&s.barMinHeight1Px?1:0),m=-r/2,_=r,v=s.roundedCorners?Ee(s.roundedCorners)?+s.roundedCorners:_/2:0,k=lt(v,0,Math.min(i,_)/2),c=this.yScale.range()[0]>this.yScale.range()[1];return Da({x:this.isVertical()?m:p-o,y:this.isVertical()?p+(c?0:-o):m,w:this.isVertical()?_:o,h:this.isVertical()?o:_,tl:t&&(this.isVertical()?!n&&c||n&&!c:n),tr:t&&(this.isVertical()?!n&&c||n&&!c:!n),br:t&&(this.isVertical()?n&&c||!n&&!c:!n),bl:t&&(this.isVertical()?n&&c||!n&&!c:n),r:k})}getValueScaleExtent(a){const{datamodel:e}=this,s=this.getAccessors(),l=a?this._getVisibleData():e.data;return Et(l,...s)}getDataScaleExtent(){const{config:a,datamodel:e}=this;return Lt(e.data,a.x)}getYDataExtent(a){return this.isVertical()?this.getValueScaleExtent(a):this.getDataScaleExtent()}getXDataExtent(){return this.isVertical()?this.getDataScaleExtent():this.getValueScaleExtent(!1)}}Ne.selectors=Pa;const Ma=Object.assign(Object.assign({},jt),{id:(g,a)=>{var e;return(e=g.id)!==null&&e!==void 0?e:a},value:void 0,angleRange:[0,2*Math.PI],padAngle:0,sortFunction:void 0,cornerRadius:0,color:void 0,radius:void 0,arcWidth:20,centralLabel:void 0,centralSubLabel:void 0,centralSubLabelWrap:!0,showEmptySegments:!1,emptySegmentAngle:.5*Math.PI/180,showBackground:!0,backgroundAngleRange:void 0,centralLabelOffsetX:void 0,centralLabelOffsetY:void 0});function Ua(g,a){g.style("fill",e=>Ae(e.data,a.color,e.index)).style("opacity",0).each((e,s,l)=>{const r=l[s],n=(e.startAngle+e.endAngle)/2,t=(e.endAngle-e.startAngle)/2;r._animState={startAngle:n-t,endAngle:n+t,innerRadius:e.innerRadius,outerRadius:e.outerRadius,padAngle:e.padAngle}})}function Ra(g,a,e,s){g.style("transition",`fill ${s}ms`).style("fill",r=>Ae(r.data,a.color,r.index));const l=r=>a.showEmptySegments||r.value?1:0;s?te(g,s).style("opacity",l).attrTween("d",(n,t,u)=>{const i=u[t],o={startAngle:n.startAngle,endAngle:n.endAngle,innerRadius:n.innerRadius,outerRadius:n.outerRadius,padAngle:n.padAngle},p=Ht(i._animState,o);return m=>(i._animState=p(m),e(i._animState))}):g.attr("d",e).style("opacity",l)}function Ea(g,a){te(g,a).style("opacity",0).remove()}const ft=Array.from({length:4},(g,a)=>{const e=-Math.PI/2+a*Math.PI/2;return[e,e+Math.PI]}),[Ns,zs,Fs,Is]=ft,vt=ee`
|
|
35
|
+
label: donut-component;
|
|
36
|
+
`,La=it`
|
|
37
|
+
:root {
|
|
38
|
+
--vis-donut-central-label-font-size: 16px;
|
|
39
|
+
--vis-donut-central-label-text-color: #5b5f6d;
|
|
40
|
+
// Undefined by default to allow proper fallback to var(--vis-font-family)
|
|
41
|
+
/* --vis-donut-central-label-font-family: */
|
|
42
|
+
--vis-donut-central-label-font-weight: 600;
|
|
43
|
+
|
|
44
|
+
--vis-donut-central-sub-label-font-size: 12px;
|
|
45
|
+
--vis-donut-central-sub-label-text-color: #5b5f6d;
|
|
46
|
+
// Undefined by default to allow proper fallback to var(--vis-font-family)
|
|
47
|
+
/* --vis-donut-central-sub-label-font-family: */
|
|
48
|
+
--vis-donut-central-sub-label-font-weight: 500;
|
|
49
|
+
|
|
50
|
+
--vis-donut-background-color: #E7E9F3;
|
|
51
|
+
--vis-donut-segment-stroke-width: 0;
|
|
52
|
+
// The line segment color variable is not defined by default
|
|
53
|
+
// to allow it to fallback to the donut background color
|
|
54
|
+
/* --vis-donut-segment-stroke-color: none; */
|
|
55
|
+
|
|
56
|
+
--vis-dark-donut-central-label-text-color: #C2BECE;
|
|
57
|
+
--vis-dark-donut-central-sub-label-text-color: #C2BECE;
|
|
58
|
+
--vis-dark-donut-background-color: #18160C;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
body.theme-dark ${`.${vt}`} {
|
|
62
|
+
--vis-donut-central-label-text-color: var(--vis-dark-donut-central-label-text-color);
|
|
63
|
+
--vis-donut-central-sub-label-text-color: var(--vis-dark-donut-central-sub-label-text-color);
|
|
64
|
+
--vis-donut-background-color: var(--vis-dark-donut-background-color);
|
|
65
|
+
}
|
|
66
|
+
`,yt=ee`
|
|
67
|
+
label: background;
|
|
68
|
+
fill: var(--vis-donut-background-color);
|
|
69
|
+
`,je=ee`
|
|
70
|
+
label: segment;
|
|
71
|
+
stroke-width: var(--vis-donut-segment-stroke-width);
|
|
72
|
+
stroke: var(--vis-donut-segment-stroke-color, var(--vis-donut-background-color));
|
|
73
|
+
`,bt=ee`
|
|
74
|
+
label: segment-exit;
|
|
75
|
+
`,xt=ee`
|
|
76
|
+
label: central-label;
|
|
77
|
+
text-anchor: middle;
|
|
78
|
+
dominant-baseline: middle;
|
|
79
|
+
font-size: var(--vis-donut-central-label-font-size);
|
|
80
|
+
font-family: var(--vis-donut-central-label-font-family, var(--vis-font-family));
|
|
81
|
+
font-weight: var(--vis-donut-central-label-font-weight);
|
|
82
|
+
fill: var(--vis-donut-central-label-text-color);
|
|
83
|
+
`,_t=ee`
|
|
84
|
+
label: central-label;
|
|
85
|
+
text-anchor: middle;
|
|
86
|
+
dominant-baseline: middle;
|
|
87
|
+
font-size: var(--vis-donut-central-sub-label-font-size);
|
|
88
|
+
font-family: var(--vis-donut-central-sub-label-font-family, var(--vis-font-family));
|
|
89
|
+
font-weight: var(--vis-donut-central-sub-label-font-weight);
|
|
90
|
+
fill: var(--vis-donut-central-sub-label-text-color);
|
|
91
|
+
`,ja=Object.freeze(Object.defineProperty({__proto__:null,background:yt,centralLabel:xt,centralSubLabel:_t,root:vt,segment:je,segmentExit:bt,variables:La},Symbol.toStringTag,{value:"Module"}));class ze extends Ot{constructor(a){super(),this._defaultConfig=Ma,this.config=this._defaultConfig,this.datamodel=new Vt,this.arcGen=Sa(),this.events={},a&&this.setConfig(a),this.arcBackground=this.g.append("path"),this.arcGroup=this.g.append("g"),this.centralLabel=this.g.append("text").attr("class",xt),this.centralSubLabel=this.g.append("text").attr("class",_t)}get bleed(){return{top:0,bottom:0,left:0,right:0}}_render(a){var e,s,l,r,n,t,u,i,o,p,m,_,v,k;const{config:c,datamodel:h,bleed:f}=this,T=h.data.map(($,q)=>({index:q,datum:$})).filter($=>c.showEmptySegments||re($.datum,c.value,$.index)),C=Ee(a)?a:c.duration,[A,x,R,z]=ft.map($=>c.angleRange&&c.angleRange[0]===$[0]&&c.angleRange[1]===$[1]),L=A||R,j=x||z,V=this._width*(j?2:1),W=this._height*(L?2:1),b=c.radius||Math.min(V-f.left-f.right,W-f.top-f.bottom)/2,w=c.arcWidth===0?0:lt(b-c.arcWidth,0,b-1),I=this._height/2+(A?b/2:R?-b/2:0),J=this._width/2+(z?b/2:x?-b/2:0),y=`translate(${J},${I})`;this.arcGroup.attr("transform",y),this.arcGen.startAngle($=>$.startAngle).endAngle($=>$.endAngle).innerRadius($=>$.innerRadius).outerRadius($=>$.outerRadius).padAngle($=>$.padAngle).cornerRadius(c.cornerRadius);const U=$a().startAngle((s=(e=c.angleRange)===null||e===void 0?void 0:e[0])!==null&&s!==void 0?s:0).endAngle((r=(l=c.angleRange)===null||l===void 0?void 0:l[1])!==null&&r!==void 0?r:2*Math.PI).padAngle(c.padAngle).value($=>re($.datum,c.value,$.index)||0).sort(($,q)=>{var ie;return(ie=c.sortFunction)===null||ie===void 0?void 0:ie.call(c,$.datum,q.datum)})(T).map($=>{const q=Object.assign(Object.assign({},$),{data:$.data.datum,index:$.data.index,innerRadius:w,outerRadius:b});return c.showEmptySegments&&$.endAngle-$.startAngle-$.padAngle<=Number.EPSILON&&(q.endAngle=$.startAngle+Math.max(c.emptySegmentAngle,c.padAngle),q.padAngle=$.padAngle/2),q}),G=this.arcGroup.selectAll(`.${je}`).data(U,$=>c.id($.data,$.index)),X=G.enter().append("path").attr("class",je).call(Ua,c),oe=G.merge(X);oe.call(Ra,c,this.arcGen,C),oe.sort(($,q)=>q.value-$.value),G.exit().attr("class",bt).call(Ea,C);const de=x?"start":z?"end":"middle";this.centralLabel.attr("dy",c.centralSubLabel?"-0.55em":null).style("text-anchor",de).text((n=c.centralLabel)!==null&&n!==void 0?n:null),this.centralSubLabel.attr("dy",c.centralLabel?"0.55em":null).style("text-anchor",de).text((t=c.centralSubLabel)!==null&&t!==void 0?t:null),c.centralSubLabelWrap&&Wt(this.centralSubLabel,w*1.9);const pe=(c.centralLabelOffsetX||0)+J;let Z=(c.centralLabelOffsetY||0)+I;L&&c.centralLabelOffsetX===void 0&&c.centralLabelOffsetY===void 0&&(Z=(A?-this.centralSubLabel.node().getBoundingClientRect().height:R?this.centralLabel.node().getBoundingClientRect().height:0)+I);const ue=`translate(${pe},${Z})`;this.centralLabel.attr("transform",ue),this.centralSubLabel.attr("transform",ue),this.arcBackground.attr("class",yt).attr("visibility",c.showBackground?null:"hidden").attr("transform",y),te(this.arcBackground,C).attr("d",this.arcGen({startAngle:(p=(i=(u=c.backgroundAngleRange)===null||u===void 0?void 0:u[0])!==null&&i!==void 0?i:(o=c.angleRange)===null||o===void 0?void 0:o[0])!==null&&p!==void 0?p:0,endAngle:(k=(_=(m=c.backgroundAngleRange)===null||m===void 0?void 0:m[1])!==null&&_!==void 0?_:(v=c.angleRange)===null||v===void 0?void 0:v[1])!==null&&k!==void 0?k:2*Math.PI,innerRadius:w,outerRadius:b}))}}ze.selectors=ja;const Ha=se({__name:"index",props:{component:{},tooltip:{},annotations:{},duration:{},margin:{},padding:{},sizing:{},width:{},height:{},svgDefs:{},ariaLabel:{},data:{}},setup(g,{expose:a}){const e=g,{data:s}=la(e),l=He(e);let r;const n=da({component:void 0,tooltip:void 0,annotations:void 0}),t=Be(),u=()=>{r||t.value&&n.component&&(r=new fa(t.value,{...Re(n)},s.value))};return ra(()=>{var i;u(),(i=n.component)==null||i.config,r?.updateContainer({...Re(l.value),...Re(n)})}),me(s,()=>{r?r.setData(s.value,!0):u()}),Ge(()=>r?.destroy()),Ue(Oe,{data:s,update:i=>n.component=i,destroy:()=>n.component=void 0}),Ue(Gt,{data:s,update:i=>n.tooltip=i,destroy:()=>{n.tooltip=void 0}}),Ue(Bt,{data:s,update:i=>n.annotations=i,destroy:()=>{n.annotations=void 0}}),a({component:r}),(i,o)=>(S(),H("div",{"data-vis-single-container":"",ref_key:"elRef",ref:t,class:"unovis-single-container"},[ca(i.$slots,"default")],512))}}),Oa={"data-vis-component":""},Va=Ne.selectors,Wa=se({__name:"index",props:{color:{type:[Function,String,Array,null]},barWidth:{},barMaxWidth:{},dataStep:{},barPadding:{},roundedCorners:{type:[Number,Boolean]},cursor:{type:[Function,String,null]},barMinHeight1Px:{type:Boolean},barMinHeightZeroValue:{},orientation:{},x:{type:[Function,Number,null]},y:{type:[Function,Number,null,Array]},id:{type:Function},xScale:{type:[Object,Function]},yScale:{type:[Object,Function]},excludeFromDomainCalculation:{type:Boolean},duration:{},events:{},attributes:{},data:{}},setup(g,{expose:a}){const e=ut(Oe),s=g,l=M(()=>e.data.value??s.data),r=He(s),n=Be();return ht(()=>{gt(()=>{var t;n.value=new Ne(r.value),(t=n.value)==null||t.setData(l.value),e.update(n.value)})}),Ge(()=>{var t;(t=n.value)==null||t.destroy(),e.destroy()}),me(r,(t,u)=>{var i;rt(t,u)||(i=n.value)==null||i.setConfig(r.value)}),me(l,()=>{var t;(t=n.value)==null||t.setData(l.value)}),a({component:n}),(t,u)=>(S(),H("div",Oa))}}),Ga={"data-vis-component":""},Ba=ze.selectors,Na=se({__name:"index",props:{id:{type:Function},value:{type:[Function,Number,null]},angleRange:{},padAngle:{},sortFunction:{type:Function},cornerRadius:{},color:{type:[Function,String,Array,null]},radius:{},arcWidth:{},centralLabel:{},centralSubLabel:{},centralSubLabelWrap:{type:Boolean},showEmptySegments:{type:Boolean},emptySegmentAngle:{},showBackground:{type:Boolean},backgroundAngleRange:{},centralLabelOffsetX:{},centralLabelOffsetY:{},duration:{},events:{},attributes:{},data:{}},setup(g,{expose:a}){const e=ut(Oe),s=g,l=M(()=>e.data.value??s.data),r=He(s),n=Be();return ht(()=>{gt(()=>{var t;n.value=new ze(r.value),(t=n.value)==null||t.setData(l.value),e.update(n.value)})}),Ge(()=>{var t;(t=n.value)==null||t.destroy(),e.destroy()}),me(r,(t,u)=>{var i;rt(t,u)||(i=n.value)==null||i.setConfig(r.value)}),me(l,()=>{var t;(t=n.value)==null||t.setData(l.value)}),a({component:n}),(t,u)=>(S(),H("div",Ga))}}),za={key:0,class:"pointer-events-none absolute inset-0 z-10"},Fa={key:1,class:"flex h-72 items-center justify-center rounded-md border border-dashed text-sm text-muted-foreground"},Ia={class:"mt-4 flex flex-wrap items-center justify-center gap-3 text-xs text-muted-foreground"},Xa={class:"font-medium text-foreground tabular-nums"},Ya=288,Ka=se({__name:"TodayUsageTrendPanel",props:{items:{}},setup(g){const a=g,e={bottom:32,left:56,right:28,top:8},s={left:8,right:18},l=[0,void 0],r=ua("chartRoot"),{width:n}=ha(r),t=M(()=>ga.map(y=>{const E=a.items.reduce((U,G)=>U+(G.agents[y]?.totalTokens??0),0);return{color:y==="codex"?"#94a3b8":nt[y].color,key:y,label:nt[y].label,totalTokens:E}}).filter(y=>y.totalTokens>0).sort((y,E)=>E.totalTokens-y.totalTokens)),u=M(()=>a.items.map(y=>({costUSD:y.costUSD,hour:y.hour,label:y.label,totalTokens:y.totalTokens,values:Object.fromEntries(t.value.map(E=>[E.key,y.agents[E.key]?.totalTokens??0]))}))),i=M(()=>t.value.map(y=>E=>E.values[y.key]??0)),o=M(()=>Object.fromEntries(t.value.map(y=>[y.key,{color:y.color,label:y.label}]))),{getAreaColor:p,getCrosshairColor:m,getGradientId:_,getLineColor:v}=Nt(()=>t.value,{getColor:y=>y.color,getKey:y=>y.key,gradientPrefix:"today-usage-trend"}),k=M(()=>t.value.map(y=>`
|
|
92
|
+
<linearGradient id="${_(y.key)}" x1="0" y1="0" x2="0" y2="1">
|
|
93
|
+
<stop offset="0%" stop-color="${y.color}" stop-opacity="0.42" />
|
|
94
|
+
<stop offset="100%" stop-color="${y.color}" stop-opacity="0.07" />
|
|
95
|
+
</linearGradient>
|
|
96
|
+
`).join("")),c=[0,23],h=[0,4,8,12,16,20,23],f=M(()=>e.left),T=M(()=>e.top),C=M(()=>Math.max(n.value-e.left-e.right,0)),A=M(()=>Math.max(Ya-e.top-e.bottom,0)),x=M(()=>T.value+A.value),R=M(()=>Math.max(C.value-s.left-s.right,0)),z=M(()=>Math.max(...u.value.map(y=>y.totalTokens),0)),{clearHoverGuide:L,handlePointerMove:j,hoverPointerY:V,hoverSelection:W}=Xt({chartRoot:r,isEnabled:()=>a.items.length>0&&R.value>0,resolveBounds:()=>({bottom:x.value,left:f.value,right:f.value+C.value,top:T.value}),resolveSelection(y){const E=f.value+C.value,U=f.value+s.left,G=E-s.right;return Math.round(Je((y-U)/Math.max(G-U,1)*23,0,23))}}),b=M(()=>{if(W.value===null||V.value===null)return null;const y=u.value[W.value];if(!y||C.value<=0||A.value<=0)return null;const E=f.value+s.left+W.value/23*R.value,U=Je(V.value,T.value,x.value),G=A.value<=0?0:1-(U-T.value)/A.value;return{x:E,xLabel:y.label,y:U,yLabel:ce(G*z.value)}});function w(y){return y?.hour??0}function I(y){return y instanceof Date?"":a.items[y]?.label??""}function J(y){if(!y)return"";const E=t.value.map(U=>({color:U.color,costUSD:a.items[y.hour]?.agents[U.key]?.costUSD??0,label:U.label,totalTokens:y.values[U.key]??0})).filter(U=>U.totalTokens>0||U.costUSD>0).sort((U,G)=>G.totalTokens-U.totalTokens);return`
|
|
97
|
+
<div class="grid min-w-56 gap-2 rounded-md border bg-background px-3 py-2 text-xs shadow-lg">
|
|
98
|
+
<div class="flex items-center justify-between gap-4">
|
|
99
|
+
<span class="font-medium text-foreground">${$e(y.label)}</span>
|
|
100
|
+
<span class="font-mono text-muted-foreground">${ge(y.costUSD)}</span>
|
|
101
|
+
</div>
|
|
102
|
+
<div class="flex items-center justify-between gap-4 border-b pb-2 text-muted-foreground">
|
|
103
|
+
<span>Total Tokens</span>
|
|
104
|
+
<span class="font-mono font-semibold text-foreground">${ce(y.totalTokens)}</span>
|
|
105
|
+
</div>
|
|
106
|
+
<div class="grid gap-1 text-muted-foreground">
|
|
107
|
+
${E.map(U=>`
|
|
108
|
+
<div class="flex items-center justify-between gap-4">
|
|
109
|
+
<span class="flex min-w-0 items-center gap-2">
|
|
110
|
+
<span class="size-2 shrink-0 rounded-sm" style="background-color: ${U.color}"></span>
|
|
111
|
+
<span class="truncate">${$e(U.label)}</span>
|
|
112
|
+
</span>
|
|
113
|
+
<span class="font-mono font-medium text-foreground">${ce(U.totalTokens)} / ${ge(U.costUSD)}</span>
|
|
114
|
+
</div>
|
|
115
|
+
`).join("")}
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
`}return(y,E)=>{const U=Ve,G=ye;return S(),N(G,{description:"Hourly token and spend by agent for today",icon:"lucide:chart-area",title:"Today's Token Trend"},{default:O(()=>[d(t).length>0?(S(),H("div",{key:0,ref_key:"chartRoot",ref:r,class:"relative",onPointerleave:E[0]||(E[0]=(...X)=>d(L)&&d(L)(...X)),onPointermove:E[1]||(E[1]=(...X)=>d(j)&&d(j)(...X))},[D(U,{class:"h-72 w-full",config:d(o)},{default:O(()=>[D(d(ct),{"auto-margin":!1,data:d(u),height:288,margin:e,padding:s,"svg-defs":d(k),"x-domain":c,"y-domain":l},{default:O(()=>[D(d(zt),{color:d(p),"curve-type":"monotoneX",line:!0,"line-color":d(v),"line-width":2,opacity:.82,x:w,y:d(i)},null,8,["color","line-color","y"]),D(d(Te),{"grid-line":!1,"tick-format":I,"tick-padding":10,"tick-values":h,type:"x"}),D(d(Te),{"num-ticks":4,"tick-format":d(Ft),type:"y"},null,8,["tick-format"]),d(t).length>0?(S(),N(d(We),{key:0})):ve("",!0),d(t).length>0?(S(),N(d(It),{key:1,color:d(m),template:J,x:w,"y-stacked":d(i)},null,8,["color","y-stacked"])):ve("",!0)]),_:1},8,["data","svg-defs"])]),_:1},8,["config"]),d(b)?(S(),H("div",za,[P("div",{class:"absolute border-l border-dashed border-border/80",style:ne({height:`${d(A)}px`,left:`${d(b).x}px`,top:`${d(T)}px`})},null,4),P("div",{class:"absolute border-t border-dashed border-border/80",style:ne({left:`${d(f)}px`,top:`${d(b).y}px`,width:`${d(C)}px`})},null,4),P("div",{class:"absolute rounded-sm bg-foreground px-2 py-1 text-[11px] font-medium text-background shadow-sm",style:ne({left:`${d(b).x}px`,top:`${d(x)+6}px`,transform:"translateX(-50%)"})},B(d(b).xLabel),5),P("div",{class:"absolute rounded-sm bg-foreground px-2 py-1 text-[11px] font-medium text-background shadow-sm",style:ne({left:`${Math.max(d(f)-8,0)}px`,top:`${d(b).y}px`,transform:"translate(-100%, -50%)"})},B(d(b).yLabel),5)])):ve("",!0)],544)):(S(),H("div",Fa," No usage recorded today. ")),P("div",Ia,[(S(!0),H(ae,null,be(d(t),X=>(S(),H("div",{key:X.key,class:"flex items-center gap-2"},[P("span",{class:"size-2.5 rounded-sm",style:ne({backgroundColor:X.color})},null,4),P("span",null,B(X.label),1),P("span",Xa,B(d(ce)(X.totalTokens)),1)]))),128))])]),_:1})}}}),qa=Object.assign(Ka,{__name:"DashboardTodayUsageTrendPanel"}),Za={key:0,class:"text-xs text-destructive"},Ja={class:"mb-4 grid grid-cols-2 gap-3"},Qa={class:"mb-4 grid grid-cols-2 gap-3"},es={class:"rounded-md border px-3 py-2"},ts={class:"mt-1 text-xl font-semibold tabular-nums"},as={class:"rounded-md border px-3 py-2"},ss={class:"mt-1 text-xl font-semibold tabular-nums"},ns={class:"mt-4 flex flex-wrap justify-center items-center gap-3 text-xs text-muted-foreground"},os=se({name:"StatisticalAnalysisSessionAnalysisPanel",__name:"SessionAnalysisPanel",props:{errorMessage:{},items:{},loading:{type:Boolean},totalSessions:{}},setup(g){const a=g,e=[{color:"#2563eb",key:"tokens",label:"Token Usage"},{color:"#b6d72f",key:"duration",label:"Duration"},{color:"#f97316",key:"cost",label:"Cost"}],s={cost:{color:e[2].color,label:e[2].label},duration:{color:e[1].color,label:e[1].label},tokens:{color:e[0].color,label:e[0].label}},l={bottom:32,left:120,right:12,top:8},r=M(()=>{if(a.items.length===0)return ge(0);const h=a.items.reduce((f,T)=>f+T.costUSD,0)/a.items.length;return ge(h)}),n=M(()=>{const h=new Map;for(const x of a.items){const R=h.get(x.project)??{costUSD:0,durationMinutes:0,sessionCount:0,tokenTotal:0};R.costUSD+=x.costUSD,R.durationMinutes+=o(x.duration),R.sessionCount+=1,R.tokenTotal+=x.tokenTotal,h.set(x.project,R)}const f=Array.from(h.entries()).map(([x,R])=>({project:x,...R})).sort((x,R)=>R.costUSD-x.costUSD),T=Math.max(...f.map(x=>x.tokenTotal),0),C=Math.max(...f.map(x=>x.durationMinutes),0),A=Math.max(...f.map(x=>x.costUSD),0);return f.map((x,R)=>({...x,costLabel:ge(x.costUSD),costScore:A>0?x.costUSD/A*100:0,durationLabel:Yt(x.durationMinutes),durationScore:C>0?x.durationMinutes/C*100:0,index:R,tokenLabel:ce(x.tokenTotal),tokenScore:T>0?x.tokenTotal/T*100:0}))}),t=M(()=>n.value.map(h=>h.index)),u=[h=>h.tokenScore,h=>h.durationScore,h=>h.costScore],i=M(()=>({[Va.bar]:_}));function o(h){const f=h.match(/(\d+)h/)?.[1],T=h.match(/(\d+)m/)?.[1];return Number(f??0)*60+Number(T??0)}function p(h,f){return e[f]?.color??e[0].color}function m(h){return h.index}function _(h){const f=h.datum,T=e[h.stackIndex]??e[0],C=v(f,h.stackIndex);return`
|
|
119
|
+
<div class="grid min-w-44 gap-2 rounded-md border bg-background px-3 py-2 text-xs shadow-lg">
|
|
120
|
+
<div class="font-medium text-foreground">${$e(f.project)}</div>
|
|
121
|
+
<div class="flex items-center justify-between gap-4">
|
|
122
|
+
<span class="flex items-center gap-2 text-muted-foreground">
|
|
123
|
+
<span class="size-2 rounded-sm" style="background-color: ${T.color}"></span>
|
|
124
|
+
${T.label}
|
|
125
|
+
</span>
|
|
126
|
+
<span class="font-mono font-semibold text-foreground">${C}</span>
|
|
127
|
+
</div>
|
|
128
|
+
<div class="grid gap-1 border-t pt-2 text-muted-foreground">
|
|
129
|
+
<div class="flex justify-between gap-4"><span>Tokens</span><span>${f.tokenLabel}</span></div>
|
|
130
|
+
<div class="flex justify-between gap-4"><span>Duration</span><span>${f.durationLabel}</span></div>
|
|
131
|
+
<div class="flex justify-between gap-4"><span>Cost</span><span>${f.costLabel}</span></div>
|
|
132
|
+
<div class="flex justify-between gap-4"><span>Sessions</span><span>${f.sessionCount}</span></div>
|
|
133
|
+
</div>
|
|
134
|
+
</div>
|
|
135
|
+
`}function v(h,f){return f===0?`${h.tokenLabel} tokens`:f===1?h.durationLabel:h.costLabel}function k(h){return h instanceof Date?"":n.value.find(f=>f.index===h)?.project??""}function c(h){return h instanceof Date?"":`${Math.round(h)}%`}return(h,f)=>{const T=dt,C=Ve,A=ye;return S(),N(A,{description:"Token, duration, and cost grouped by project",icon:"lucide:messages-square",title:"Session Analysis"},{default:O(()=>[g.errorMessage?(S(),H("p",Za,B(g.errorMessage),1)):g.loading?(S(),H(ae,{key:1},[P("div",Ja,[D(T,{class:"h-20 w-full rounded-md"}),D(T,{class:"h-20 w-full rounded-md"})]),D(T,{class:"h-80 w-full rounded-md"})],64)):(S(),H(ae,{key:2},[P("div",Qa,[P("div",es,[f[0]||(f[0]=P("p",{class:"text-xs text-muted-foreground"}," Total Sessions ",-1)),P("p",ts,B(g.totalSessions),1)]),P("div",as,[f[1]||(f[1]=P("p",{class:"text-xs text-muted-foreground"}," Top Session Avg ",-1)),P("p",ss,B(r.value),1)])]),D(C,{class:"h-80 w-full",config:s},{default:O(()=>[D(d(ct),{"auto-margin":!1,data:n.value,height:320,margin:l,"y-direction":"south"},{default:O(()=>[D(d(Wa),{"bar-max-width":28,"bar-padding":.28,color:p,cursor:"pointer",orientation:"horizontal","rounded-corners":3,x:m,y:u}),D(d(Te),{"grid-line":!1,"tick-format":k,"tick-text-width":100,"tick-text-fit-mode":"trim","tick-text-trim-type":"end","tick-values":t.value,type:"y"},null,8,["tick-values"]),D(d(Te),{"num-ticks":4,"tick-format":c,type:"x"}),D(d(We),{triggers:i.value},null,8,["triggers"])]),_:1},8,["data"])]),_:1}),P("div",ns,[(S(),H(ae,null,be(e,x=>P("div",{key:x.key,class:"flex items-center gap-2"},[P("span",{class:"size-2.5 rounded-sm",style:ne({backgroundColor:x.color})},null,4),P("span",null,B(x.label),1)])),64))])],64))]),_:1})}}}),is=Object.assign(os,{__name:"StatisticalAnalysisSessionAnalysisPanel"}),ls={class:"space-y-4"},rs={class:"flex items-start justify-between gap-3"},cs={class:"min-w-0"},ds={class:"truncate text-sm font-medium"},us={class:"truncate text-xs text-muted-foreground"},hs={class:"shrink-0 text-sm font-semibold tabular-nums"},gs={class:"h-2 overflow-hidden rounded-full bg-secondary"},ms=se({name:"StatisticalAnalysisUsageBarList",__name:"UsageBarList",props:{items:{}},setup(g){function a(s){switch(s){case"green":return"bg-emerald-500";case"amber":return"bg-amber-500";case"sky":return"bg-sky-500";case"rose":return"bg-rose-500";default:return"bg-primary"}}function e(s){return`${Math.max(s.percent,s.percent>0?3:0)}%`}return(s,l)=>(S(),H("div",ls,[(S(!0),H(ae,null,be(g.items,r=>(S(),H("div",{key:r.label,class:"space-y-2"},[P("div",rs,[P("div",cs,[P("p",ds,B(r.label),1),P("p",us,B(r.detail),1)]),P("span",hs,B(r.value),1)]),P("div",gs,[P("div",{class:ma(["h-full rounded-full transition-[width]",a(r.tone)]),style:ne({width:e(r)})},null,6)])]))),128))]))}}),ps=Object.assign(ms,{__name:"StatisticalAnalysisUsageBarList"}),fs={class:"grid gap-6 lg:grid-cols-[220px_1fr] lg:items-center"},vs={class:"flex items-center justify-center"},ys={class:"space-y-3"},bs={class:"flex min-w-0 items-center gap-2"},xs={class:"truncate text-sm text-muted-foreground"},_s={class:"text-sm font-semibold tabular-nums"},ks={class:"w-12 text-right text-xs text-muted-foreground tabular-nums"},Ss={class:"mt-5 border-t pt-4"},As=se({name:"StatisticalAnalysisEfficiencyCachePanel",__name:"EfficiencyCachePanel",props:{dailyItems:{},items:{}},setup(g){const a=g,e=M(()=>a.dailyItems.reduce((p,m)=>p+m.inputTokens,0)),s=M(()=>a.dailyItems.reduce((p,m)=>p+m.cachedInputTokens,0)),l=M(()=>Math.max(e.value-s.value,0)),r=M(()=>e.value>0?s.value/e.value:0),n=M(()=>Pe(r.value)),t=M(()=>[{color:"#059669",key:"cached",label:"Cached Input",shareLabel:Pe(r.value),value:s.value,valueLabel:ce(s.value)},{color:"#0ea5e9",key:"fresh",label:"Fresh Input",shareLabel:Pe(e.value>0?l.value/e.value:0),value:l.value,valueLabel:ce(l.value)}]),u=M(()=>Object.fromEntries(t.value.map(p=>[p.key,{color:p.color,label:p.label}]))),i=M(()=>({[Ba.segment]:o}));function o(p){const m=p.data;return`
|
|
136
|
+
<div class="grid min-w-40 gap-2 rounded-md border bg-background px-3 py-2 text-xs shadow-lg">
|
|
137
|
+
<div class="flex items-center gap-2 font-medium text-foreground">
|
|
138
|
+
<span class="size-2 rounded-sm" style="background-color: ${m.color}"></span>
|
|
139
|
+
${$e(m.label)}
|
|
140
|
+
</div>
|
|
141
|
+
<div class="grid gap-1 text-muted-foreground">
|
|
142
|
+
<div class="flex justify-between gap-4"><span>Tokens</span><span class="font-mono font-medium text-foreground">${m.valueLabel}</span></div>
|
|
143
|
+
<div class="flex justify-between gap-4"><span>Share</span><span class="font-mono font-medium text-foreground">${m.shareLabel}</span></div>
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
`}return(p,m)=>{const _=Ve,v=ps,k=ye;return S(),N(k,{description:"Cached input ratio across total input tokens",icon:"lucide:gauge",title:"Efficiency / Cache"},{default:O(()=>[P("div",fs,[P("div",vs,[D(_,{class:"h-52 w-full max-w-56",config:d(u)},{default:O(()=>[D(d(Ha),{data:d(t),height:208},{default:O(()=>[D(d(Na),{"arc-width":26,"central-label":d(n),"central-sub-label":"Hit Rate",color:c=>c.color,"corner-radius":4,"pad-angle":.04,value:c=>c.value},null,8,["central-label","color","value"]),D(d(We),{triggers:d(i)},null,8,["triggers"])]),_:1},8,["data"])]),_:1},8,["config"])]),P("div",ys,[(S(!0),H(ae,null,be(d(t),c=>(S(),H("div",{key:c.key,class:"grid grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-3"},[P("div",bs,[P("span",{class:"size-2.5 shrink-0 rounded-full",style:ne({backgroundColor:c.color})},null,4),P("span",xs,B(c.label),1)]),P("span",_s,B(c.valueLabel),1),P("span",ks,B(c.shareLabel),1)]))),128))])]),P("div",Ss,[D(v,{items:g.items},null,8,["items"])])]),_:1})}}}),Ts=Object.assign(As,{__name:"StatisticalAnalysisEfficiencyCachePanel"}),$s={key:0,class:"mb-3 text-xs text-destructive"},Ds=se({name:"StatisticalAnalysisTokensUsagePanel",__name:"TokensUsagePanel",props:{fetchPage:{type:Function},items:{},pagination:{}},setup(g){const a=g,e=M(()=>({items:a.items,pagination:a.pagination??{page:1,pageCount:Math.max(1,Math.ceil(a.items.length/Qe)),pageSize:Qe,total:a.items.length}})),{error:s,pageData:l,setPage:r}=Kt(e,a.fetchPage),n=[{accessorKey:"date",header:"Date",meta:{class:"font-medium"}},{accessorKey:"models",cell:({row:t})=>t.original.models.join(", "),header:"Models"},{accessorKey:"inputTokens",cell:({row:t})=>fe(t.original.inputTokens),header:"Input",meta:{class:"text-right tabular-nums"}},{accessorKey:"outputTokens",cell:({row:t})=>fe(t.original.outputTokens),header:"Output",meta:{class:"text-right tabular-nums"}},{accessorKey:"reasoningOutputTokens",cell:({row:t})=>fe(t.original.reasoningOutputTokens),header:"Reasoning",meta:{class:"text-right tabular-nums"}},{accessorKey:"cachedInputTokens",cell:({row:t})=>fe(t.original.cachedInputTokens),header:"Cache Read",meta:{class:"text-right tabular-nums"}},{accessorKey:"totalTokens",cell:({row:t})=>fe(t.original.totalTokens),header:"Total Tokens",meta:{class:"text-right tabular-nums"}},{accessorKey:"costUSD",cell:({row:t})=>ge(t.original.costUSD),header:"Cost (USD)",meta:{class:"text-right tabular-nums"}}];return(t,u)=>{const i=qt,o=ye;return S(),N(o,{description:"Daily model activity by token type, cache reads, total usage, and cost",icon:"lucide:calendar-days",title:"Daily Token Usage"},{default:O(()=>[d(s)?(S(),H("p",$s,B(d(s).message),1)):ve("",!0),D(i,{columns:n,data:d(l).items,"empty-text":"No daily token usage found.",pagination:d(l).pagination,onPageChange:d(r)},null,8,["data","pagination","onPageChange"])]),_:1})}}}),Cs=Object.assign(Ds,{__name:"StatisticalAnalysisTokensUsagePanel"});function ws(){const g=et(),a=tt(),e=at().sessionAnalysis,{data:s,error:l,refresh:r,status:n}=xe("analysis:home:core",Qt,{default:et}),{clear:t,data:u,error:i,execute:o,refresh:p,status:m}=xe("analysis:home:usage",ea,{default:tt,immediate:!1,server:!1}),{data:_,error:v,execute:k,status:c}=xe("analysis:home:daily-token-page",()=>st(1),{immediate:!1,server:!1}),{clear:h,data:f,error:T,execute:C,refresh:A,status:x}=xe("analysis:home:session",ta,{default:()=>at().sessionAnalysis,immediate:!1,server:!1}),{refresh:R}=aa({clearDeferred:()=>{t(),h()},coreStatus:n,executeDeferred:()=>Promise.all([o(),C()]),refreshCore:r,refreshDeferred:()=>Promise.all([p(),A()])});return sa(()=>R()),me(m,z=>{z==="success"&&c.value==="idle"&&k()},{immediate:!0}),{dailyTokenUsage:M(()=>u.value?.dailyTokenUsage??a.dailyTokenUsage),dailyTokenUsagePage:M(()=>_.value),dailyTokenUsagePageError:v,dailyTokenUsagePageStatus:c,fetchDailyTokenUsagePage:st,efficiencyMetrics:M(()=>u.value?.efficiencyMetrics??a.efficiencyMetrics),error:l,monthlyModelUsage:M(()=>s.value?.modelUsage??g.modelUsage),overviewCards:M(()=>s.value?.overviewCards??g.overviewCards),projectUsage:M(()=>s.value?.hotProjects??g.hotProjects),refresh:R,sessionAnalysisError:T,sessionAnalysisStatus:x,sessionUsage:M(()=>f.value?.items??e.items),status:n,todayHourlyUsage:M(()=>u.value?.todayHourlyUsage??a.todayHourlyUsage),totalSessions:M(()=>f.value?.totalSessions??e.totalSessions),usageError:i,usageStatus:m}}const Ps={class:"bg-background border border-input rounded-xl shadow-xs min-h-0 flex-1 overflow-y-auto"},Ms={class:"grid content-start p-4 space-y-3"},Us={key:0,class:"text-xs text-destructive"},Rs={class:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-4"},Es={key:0,class:"text-xs text-destructive"},Ls={key:0,class:"text-xs text-destructive"},js={key:0,class:"text-xs text-destructive"},Hs={key:0,class:"text-xs text-destructive"},Xs=se({__name:"index",setup(g){const{dailyTokenUsage:a,dailyTokenUsagePage:e,error:s,efficiencyMetrics:l,fetchDailyTokenUsagePage:r,monthlyModelUsage:n,projectUsage:t,sessionAnalysisError:u,sessionAnalysisStatus:i,sessionUsage:o,totalSessions:p,todayHourlyUsage:m,status:_,usageError:v,usageStatus:k,overviewCards:c}=ws(),{errorText:h,showSkeleton:f}=Me(_,s),{errorText:T,showSkeleton:C}=Me(i,u),{errorText:A,showSkeleton:x}=Me(k,v);return(R,z)=>{const L=dt,j=ye,V=Zt,W=Jt,b=na,w=oa,I=qa,J=ia,y=is,E=Ts,U=Cs;return S(),H("div",Ps,[P("div",Ms,[d(h)?(S(),H("p",Us,B(d(h)),1)):ve("",!0),d(f)?(S(),H(ae,{key:1},[P("div",Rs,[(S(),H(ae,null,be(4,G=>D(L,{key:G,class:"h-28 rounded-md"})),64))]),D(V,null,{default:O(()=>[D(j,{class:"md:col-span-8",description:"Monthly token trends by model",icon:"solar:cpu-line-duotone",title:"Model Usage"},{default:O(()=>[D(L,{class:"h-72 w-full rounded-md"})]),_:1}),D(j,{class:"md:col-span-4",description:"Best performers by spend",icon:"lucide:folder-git-2",title:"Top Projects"},{default:O(()=>[D(L,{class:"h-72 w-full rounded-md"})]),_:1}),D(j,{class:"md:col-span-12",description:"Hourly token and spend by agent for today",icon:"lucide:chart-area",title:"Today's Token Trend"},{default:O(()=>[D(L,{class:"h-72 w-full rounded-md"})]),_:1}),D(j,{class:"md:col-span-12",description:"Usage trend over the selected period",icon:"lucide:activity",title:"Usage Trend"},{default:O(()=>[D(L,{class:"h-80 w-full rounded-md"})]),_:1}),D(j,{class:"md:col-span-6",description:"Token, duration, and cost grouped by project",icon:"lucide:messages-square",title:"Session Analysis"},{default:O(()=>[D(L,{class:"h-72 w-full rounded-md"})]),_:1}),D(j,{class:"md:col-span-6",description:"Cached input ratio across total input tokens",icon:"lucide:gauge",title:"Efficiency / Cache"},{default:O(()=>[D(L,{class:"h-72 w-full rounded-md"})]),_:1}),D(j,{class:"md:col-span-12",description:"Daily model activity by token type, cache reads, total usage, and cost",icon:"lucide:calendar-days",title:"Daily Token Usage"},{default:O(()=>[D(L,{class:"h-72 w-full rounded-md"})]),_:1})]),_:1})],64)):(S(),H(ae,{key:2},[D(W,{cards:d(c)},null,8,["cards"]),D(V,null,{default:O(()=>[D(b,{"monthly-items":d(n),class:"md:col-span-8"},null,8,["monthly-items"]),D(w,{items:d(t),class:"md:col-span-4"},null,8,["items"]),d(x)||d(A)?(S(),N(j,{key:0,class:"md:col-span-12",description:"Hourly token and spend by agent for today",icon:"lucide:chart-area",title:"Today's Token Trend"},{default:O(()=>[d(A)?(S(),H("p",Es,B(d(A)),1)):(S(),N(L,{key:1,class:"h-72 w-full rounded-md"}))]),_:1})):(S(),N(I,{key:1,items:d(m),class:"md:col-span-12"},null,8,["items"])),d(x)||d(A)?(S(),N(j,{key:2,class:"md:col-span-12",description:"Usage trend over the selected period",icon:"lucide:activity",title:"Usage Trend"},{default:O(()=>[d(A)?(S(),H("p",Ls,B(d(A)),1)):(S(),N(L,{key:1,class:"h-80 w-full rounded-md"}))]),_:1})):(S(),N(J,{key:3,items:d(a),class:"md:col-span-12",title:"Usage Trend"},null,8,["items"])),D(y,{"error-message":d(T),items:d(o),loading:d(C),"total-sessions":d(p),class:"md:col-span-6"},null,8,["error-message","items","loading","total-sessions"]),d(x)||d(A)?(S(),N(j,{key:4,class:"md:col-span-6",description:"Cached input ratio across total input tokens",icon:"lucide:gauge",title:"Efficiency / Cache"},{default:O(()=>[d(A)?(S(),H("p",js,B(d(A)),1)):(S(),N(L,{key:1,class:"h-72 w-full rounded-md"}))]),_:1})):(S(),N(E,{key:5,"daily-items":d(a),items:d(l),class:"md:col-span-6"},null,8,["daily-items","items"])),d(x)||d(A)?(S(),N(j,{key:6,class:"md:col-span-12",description:"Daily model activity by token type, cache reads, total usage, and cost",icon:"lucide:calendar-days",title:"Daily Token Usage"},{default:O(()=>[d(A)?(S(),H("p",Hs,B(d(A)),1)):(S(),N(L,{key:1,class:"h-72 w-full rounded-md"}))]),_:1})):(S(),N(U,{key:7,"fetch-page":d(r),items:d(e)?.items??[],pagination:d(e)?.pagination,class:"md:col-span-12"},null,8,["fetch-page","items","pagination"]))]),_:1})],64))])])}}});export{Xs as default};
|