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
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import os from 'os';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
const homeDirectory = os.homedir();
|
|
5
|
+
const {env} = process;
|
|
6
|
+
|
|
7
|
+
export const xdgData = env.XDG_DATA_HOME ||
|
|
8
|
+
(homeDirectory ? path.join(homeDirectory, '.local', 'share') : undefined);
|
|
9
|
+
|
|
10
|
+
export const xdgConfig = env.XDG_CONFIG_HOME ||
|
|
11
|
+
(homeDirectory ? path.join(homeDirectory, '.config') : undefined);
|
|
12
|
+
|
|
13
|
+
export const xdgState = env.XDG_STATE_HOME ||
|
|
14
|
+
(homeDirectory ? path.join(homeDirectory, '.local', 'state') : undefined);
|
|
15
|
+
|
|
16
|
+
export const xdgCache = env.XDG_CACHE_HOME || (homeDirectory ? path.join(homeDirectory, '.cache') : undefined);
|
|
17
|
+
|
|
18
|
+
export const xdgRuntime = env.XDG_RUNTIME_DIR || undefined;
|
|
19
|
+
|
|
20
|
+
export const xdgDataDirectories = (env.XDG_DATA_DIRS || '/usr/local/share/:/usr/share/').split(':');
|
|
21
|
+
|
|
22
|
+
if (xdgData) {
|
|
23
|
+
xdgDataDirectories.unshift(xdgData);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const xdgConfigDirectories = (env.XDG_CONFIG_DIRS || '/etc/xdg').split(':');
|
|
27
|
+
|
|
28
|
+
if (xdgConfig) {
|
|
29
|
+
xdgConfigDirectories.unshift(xdgConfig);
|
|
30
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "xdg-basedir",
|
|
3
|
+
"version": "5.1.0",
|
|
4
|
+
"description": "Get XDG Base Directory paths",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": "sindresorhus/xdg-basedir",
|
|
7
|
+
"funding": "https://github.com/sponsors/sindresorhus",
|
|
8
|
+
"author": {
|
|
9
|
+
"name": "Sindre Sorhus",
|
|
10
|
+
"email": "sindresorhus@gmail.com",
|
|
11
|
+
"url": "https://sindresorhus.com"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"exports": "./index.js",
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=12"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"test": "xo && ava && tsd"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"index.js",
|
|
23
|
+
"index.d.ts"
|
|
24
|
+
],
|
|
25
|
+
"keywords": [
|
|
26
|
+
"xdg",
|
|
27
|
+
"base",
|
|
28
|
+
"directory",
|
|
29
|
+
"basedir",
|
|
30
|
+
"path",
|
|
31
|
+
"data",
|
|
32
|
+
"config",
|
|
33
|
+
"cache",
|
|
34
|
+
"linux",
|
|
35
|
+
"unix",
|
|
36
|
+
"spec"
|
|
37
|
+
],
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"ava": "^1.4.1",
|
|
40
|
+
"import-fresh": "^3.0.0",
|
|
41
|
+
"tsd": "^0.7.2",
|
|
42
|
+
"xo": "^0.24.0"
|
|
43
|
+
},
|
|
44
|
+
"ava": {
|
|
45
|
+
"serial": true
|
|
46
|
+
}
|
|
47
|
+
}
|
package/dist/server/package.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "usage-board-prod",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": true,
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@babel/parser": "7.29.2",
|
|
8
|
+
"@clack/core": "1.3.1",
|
|
9
|
+
"@clack/prompts": "1.4.0",
|
|
8
10
|
"@iconify/utils": "3.1.0",
|
|
9
11
|
"@lonewolfyx/utils": "0.0.2",
|
|
10
12
|
"@vue/compiler-core": "3.5.32",
|
|
@@ -17,18 +19,24 @@
|
|
|
17
19
|
"@vue/shared": "3.5.32",
|
|
18
20
|
"chokidar": "5.0.0",
|
|
19
21
|
"consola": "3.4.2",
|
|
22
|
+
"dayjs": "1.11.21",
|
|
20
23
|
"devalue": "5.7.1",
|
|
21
24
|
"entities": "7.0.1",
|
|
22
25
|
"estree-walker": "2.0.2",
|
|
26
|
+
"fast-string-truncated-width": "3.0.3",
|
|
27
|
+
"fast-string-width": "3.0.2",
|
|
28
|
+
"fast-wrap-ansi": "0.2.2",
|
|
23
29
|
"glob": "13.0.6",
|
|
24
30
|
"hookable": "6.1.1",
|
|
25
31
|
"md5-typescript": "1.0.5",
|
|
26
32
|
"path-type": "6.0.0",
|
|
27
33
|
"readdirp": "5.0.0",
|
|
34
|
+
"sisteransi": "1.0.5",
|
|
28
35
|
"source-map-js": "1.2.1",
|
|
29
36
|
"ufo": "1.6.3",
|
|
30
37
|
"unhead": "2.1.13",
|
|
31
38
|
"vue": "3.5.32",
|
|
32
|
-
"vue-bundle-renderer": "2.2.0"
|
|
39
|
+
"vue-bundle-renderer": "2.2.0",
|
|
40
|
+
"xdg-basedir": "5.1.0"
|
|
33
41
|
}
|
|
34
42
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "usage-board",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "5.0.0",
|
|
5
5
|
"packageManager": "pnpm@10.33.0",
|
|
6
6
|
"description": "An all-in-one dashboard to quickly analyze token usage from local json files",
|
|
7
7
|
"license": "MIT",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"lint:fix": "nuxt prepare && eslint --fix",
|
|
40
40
|
"dev:cli": "tsdown -w",
|
|
41
41
|
"test": "vitest",
|
|
42
|
-
"prepare": "simple-git-hooks",
|
|
42
|
+
"prepare": "git submodule update --init --recursive && simple-git-hooks",
|
|
43
43
|
"prepublishOnly": "pnpm build"
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|
|
@@ -47,10 +47,13 @@
|
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
+
"@clack/prompts": "^1.4.0",
|
|
50
51
|
"cac": "^7.0.0",
|
|
51
52
|
"crossws": "^0.4.5",
|
|
53
|
+
"dayjs": "^1.11.21",
|
|
52
54
|
"glob": "^13.0.6",
|
|
53
|
-
"nuxt-devkit-server": "^0.0.1"
|
|
55
|
+
"nuxt-devkit-server": "^0.0.1",
|
|
56
|
+
"xdg-basedir": "^5.1.0"
|
|
54
57
|
},
|
|
55
58
|
"devDependencies": {
|
|
56
59
|
"@antfu/eslint-config": "^8.2.0",
|
|
@@ -61,7 +64,6 @@
|
|
|
61
64
|
"@iconify-json/svg-spinners": "^1.2.4",
|
|
62
65
|
"@internationalized/date": "^3.12.1",
|
|
63
66
|
"@lonewolfyx/utils": "^0.0.2",
|
|
64
|
-
"@nuxt/content": "^3.12.0",
|
|
65
67
|
"@nuxt/eslint": "^1.15.2",
|
|
66
68
|
"@nuxt/icon": "^2.2.1",
|
|
67
69
|
"@tailwindcss/vite": "^4.2.2",
|
|
@@ -79,8 +81,8 @@
|
|
|
79
81
|
"embla-carousel-vue": "^8.6.0",
|
|
80
82
|
"eslint": "^10.2.0",
|
|
81
83
|
"get-port-please": "^3.2.0",
|
|
84
|
+
"lint-staged": "^17.0.8",
|
|
82
85
|
"lucide-vue-next": "^0.545.0",
|
|
83
|
-
"nano-staged": "^1.0.2",
|
|
84
86
|
"nuxt": "^4.4.2",
|
|
85
87
|
"open": "^11.0.0",
|
|
86
88
|
"path-type": "^6.0.0",
|
|
@@ -91,7 +93,6 @@
|
|
|
91
93
|
"simple-git-hooks": "^2.13.1",
|
|
92
94
|
"tailwind-merge": "^3.5.0",
|
|
93
95
|
"tailwindcss": "^4.2.2",
|
|
94
|
-
"ts-node": "^10.9.2",
|
|
95
96
|
"tsdown": "^0.21.8",
|
|
96
97
|
"tw-animate-css": "^1.4.0",
|
|
97
98
|
"typescript": "^6.0.2",
|
|
@@ -106,10 +107,11 @@
|
|
|
106
107
|
"zod": "3.25.76"
|
|
107
108
|
},
|
|
108
109
|
"simple-git-hooks": {
|
|
109
|
-
"pre-commit": "npx
|
|
110
|
+
"pre-commit": "npx lint-staged",
|
|
110
111
|
"commit-msg": "node scripts/verify-commit.js"
|
|
111
112
|
},
|
|
112
|
-
"
|
|
113
|
-
"*": "eslint --fix"
|
|
113
|
+
"lint-staged": {
|
|
114
|
+
"*": "eslint --fix",
|
|
115
|
+
"!vendor/**": ""
|
|
114
116
|
}
|
|
115
117
|
}
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import{E as Se,F as Ae,G as Ct,H as st,I as $e,J as qt,K as dt,L as et,M as X,N as Jt,O as J,P as St,Q as gt,R as Dt,T as Zt,U as I,V as Te,W as Kt,X as we,Y as Ce,Z as De,$ as oe,a0 as nt,a1 as le,a2 as Me,a3 as Re,a4 as ut,a5 as Mt,a6 as Le,a7 as jt,a8 as Ee,a9 as Qt,aa as $t,ab as Ue,ac as Pe,ad as je,ae as ie,af as He,ag as Oe,ah as Ve,ai as We,aj as Be,ak as Vt,al as Wt,am as Ge,an as ze,ao as re,_ as Bt,S as ce,C as Ne,a as Tt,z as Gt,A as Fe,B as xt,f as it,e as wt,m as yt,c as te,w as de,q as Rt,i as Ie,b as Ye,d as Xe,g as qe,h as Je,j as Ze,k as Ke,l as vt,x as Qe,y as ta}from"./DgMMKsPE.js";import{j as ea,k as ee,l as aa,m as ae,n as na,o as ne,u as sa,i as Lt,_ as oa,a as la,b as ia}from"./BOWwkrCY.js";import{e as ot,$ as ra,k as ca,I as ft,a0 as zt,o as $,c as j,h as da,r as Nt,Y as Et,H as ue,a7 as Ut,W as he,L as ge,a1 as fe,G as R,B as ua,C as ha,g as W,w as T,i as u,b as x,l as _t,a as D,D as rt,t as H,F as at,E as mt,O as ga,P as se,q as fa,d as Y,x as ma,J as pa}from"./Jp5cgQZi.js";import{u as Pt}from"./DKaPq50Z.js";import"./C0GhHHgI.js";const va=Object.assign(Object.assign({},Se),{tooltip:void 0,annotations:void 0});class ba extends Ae{constructor(e,t,s){var i;super(e),this._defaultConfig=va,this.config=this._defaultConfig,t&&(this.updateContainer(t,!0),this.component=t.component),s&&this.setData(s,!0),!((i=this.component)===null||i===void 0)&&i.datamodel.data&&this.render()}setData(e,t){var s;const{config:i}=this;this.component&&this.component.setData(e),t||this.render(),(s=i.tooltip)===null||s===void 0||s.hide()}updateContainer(e,t){super.updateContainer(e),this._removeAllChildren(),this.component=e.component,e.sizing&&(this.component.sizing=e.sizing),this.element.appendChild(this.component.element);const s=e.tooltip;s&&(s.hasContainer()||s.setContainer(this._container),s.setComponents([this.component]));const i=e.annotations;i&&this.element.appendChild(i.element),this.element.appendChild(this._svgDefs.node()),this.element.appendChild(this._svgDefsExternal.node()),t||this.render()}updateComponent(e,t){this.component.setConfig(e),t||this.render()}update(e,t,s){e&&this.updateContainer(e,!0),t&&this.updateComponent(t,!0),s&&this.setData(s,!0),this.render()}getFitWidthScale(){const{config:e,component:t}=this,s=t;if(!s.getWidth)return 1;const i=s.getWidth()+e.margin.left+e.margin.right;return this.width/i}_preRender(){var e,t;super._preRender(),this.component.setSize(this.width,this.height,this.containerWidth,this.containerHeight),this.component.setContainerMargin(this.config.margin),(e=this.config.annotations)===null||e===void 0||e.setSize(this.width,this.height,this.containerWidth,this.containerHeight),(t=this.config.annotations)===null||t===void 0||t.setContainerMargin(this.config.margin)}_render(e){var t,s;const{config:i,component:c}=this;super._render(e),c.g.attr("transform",`translate(${i.margin.left},${i.margin.top})`),c.render(e),(t=i.annotations)===null||t===void 0||t.render(e),i.tooltip&&i.tooltip.update(),(s=i.onRenderComplete)===null||s===void 0||s.call(i,this.svg.node(),i.margin,this.containerWidth,this.containerHeight,this.width,this.height)}render(e=this.config.duration){const{config:t,component:s}=this;if(t.sizing===Ct.Extend||t.sizing===Ct.FitWidth){const i=t.sizing===Ct.FitWidth,c=s,n=c.getWidth()+t.margin.left+t.margin.right,a=c.getHeight()+t.margin.top+t.margin.bottom,d=i?this.getFitWidthScale():1,l=this.svg.attr("width"),o=this.svg.attr("height"),g=n*d,f=a*d,k=l||o;st(this.svg,k?e:0).attr("width",g).attr("height",f).attr("viewBox",`0 0 ${n} ${i?f:a}`).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(e)})}_onResize(){var e;const{config:t}=this;super._onResize(),(e=t.tooltip)===null||e===void 0||e.hide()}destroy(){var e,t;const{component:s,config:i}=this;super.destroy(),s?.destroy(),(e=i.tooltip)===null||e===void 0||e.destroy(),(t=i.annotations)===null||t===void 0||t.destroy()}}function ya(h){return h.innerRadius}function _a(h){return h.outerRadius}function xa(h){return h.startAngle}function ka(h){return h.endAngle}function Sa(h){return h&&h.padAngle}function Aa(h,e,t,s,i,c,n,a){var d=t-h,l=s-e,o=n-i,g=a-c,f=g*d-o*l;if(!(f*f<J))return f=(o*(e-c)-g*(h-i))/f,[h+f*d,e+f*l]}function kt(h,e,t,s,i,c,n){var a=h-t,d=e-s,l=(n?c:-c)/gt(a*a+d*d),o=l*d,g=-l*a,f=h+o,k=e+g,b=t+o,y=s+g,r=(f+b)/2,m=(k+y)/2,p=b-f,S=y-k,L=p*p+S*S,O=i-c,_=f*y-b*k,C=(S<0?-1:1)*gt(Te(0,O*O*L-_*_)),P=(_*S-p*C)/L,z=(-_*p-S*C)/L,N=(_*S+p*C)/L,B=(-_*p+S*C)/L,G=P-r,A=z-m,M=N-r,F=B-m;return G*G+A*A>M*M+F*F&&(P=N,z=B),{cx:P,cy:z,x01:-o,y01:-g,x11:P*(i/O-1),y11:z*(i/O-1)}}function $a(){var h=ya,e=_a,t=X(0),s=null,i=xa,c=ka,n=Sa,a=null,d=$e(l);function l(){var o,g,f=+h.apply(this,arguments),k=+e.apply(this,arguments),b=i.apply(this,arguments)-Jt,y=c.apply(this,arguments)-Jt,r=Zt(y-b),m=y>b;if(a||(a=o=d()),k<f&&(g=k,k=f,f=g),!(k>J))a.moveTo(0,0);else if(r>St-J)a.moveTo(k*dt(b),k*et(b)),a.arc(0,0,k,b,y,!m),f>J&&(a.moveTo(f*dt(y),f*et(y)),a.arc(0,0,f,y,b,m));else{var p=b,S=y,L=b,O=y,_=r,C=r,P=n.apply(this,arguments)/2,z=P>J&&(s?+s.apply(this,arguments):gt(f*f+k*k)),N=Dt(Zt(k-f)/2,+t.apply(this,arguments)),B=N,G=N,A,M;if(z>J){var F=Kt(z/f*et(P)),K=Kt(z/k*et(P));(_-=F*2)>J?(F*=m?1:-1,L+=F,O-=F):(_=0,L=O=(b+y)/2),(C-=K*2)>J?(K*=m?1:-1,p+=K,S-=K):(C=0,p=S=(b+y)/2)}var v=k*dt(p),E=k*et(p),U=f*dt(O),V=f*et(O);if(N>J){var q=k*dt(S),tt=k*et(S),lt=f*dt(L),pt=f*et(L),Q;if(r<qt)if(Q=Aa(v,E,lt,pt,q,tt,U,V)){var ht=v-Q[0],w=E-Q[1],Z=q-Q[0],ct=tt-Q[1],Yt=1/et(we((ht*Z+w*ct)/(gt(ht*ht+w*w)*gt(Z*Z+ct*ct)))/2),Xt=gt(Q[0]*Q[0]+Q[1]*Q[1]);B=Dt(N,(f-Xt)/(Yt-1)),G=Dt(N,(k-Xt)/(Yt+1))}else B=G=0}C>J?G>J?(A=kt(lt,pt,v,E,k,G,m),M=kt(q,tt,U,V,k,G,m),a.moveTo(A.cx+A.x01,A.cy+A.y01),G<N?a.arc(A.cx,A.cy,G,I(A.y01,A.x01),I(M.y01,M.x01),!m):(a.arc(A.cx,A.cy,G,I(A.y01,A.x01),I(A.y11,A.x11),!m),a.arc(0,0,k,I(A.cy+A.y11,A.cx+A.x11),I(M.cy+M.y11,M.cx+M.x11),!m),a.arc(M.cx,M.cy,G,I(M.y11,M.x11),I(M.y01,M.x01),!m))):(a.moveTo(v,E),a.arc(0,0,k,p,S,!m)):a.moveTo(v,E),!(f>J)||!(_>J)?a.lineTo(U,V):B>J?(A=kt(U,V,q,tt,f,-B,m),M=kt(v,E,lt,pt,f,-B,m),a.lineTo(A.cx+A.x01,A.cy+A.y01),B<N?a.arc(A.cx,A.cy,B,I(A.y01,A.x01),I(M.y01,M.x01),!m):(a.arc(A.cx,A.cy,B,I(A.y01,A.x01),I(A.y11,A.x11),!m),a.arc(0,0,f,I(A.cy+A.y11,A.cx+A.x11),I(M.cy+M.y11,M.cx+M.x11),m),a.arc(M.cx,M.cy,B,I(M.y11,M.x11),I(M.y01,M.x01),!m))):a.arc(0,0,f,O,L,m)}if(a.closePath(),o)return a=null,o+""||null}return l.centroid=function(){var o=(+h.apply(this,arguments)+ +e.apply(this,arguments))/2,g=(+i.apply(this,arguments)+ +c.apply(this,arguments))/2-qt/2;return[dt(g)*o,et(g)*o]},l.innerRadius=function(o){return arguments.length?(h=typeof o=="function"?o:X(+o),l):h},l.outerRadius=function(o){return arguments.length?(e=typeof o=="function"?o:X(+o),l):e},l.cornerRadius=function(o){return arguments.length?(t=typeof o=="function"?o:X(+o),l):t},l.padRadius=function(o){return arguments.length?(s=o==null?null:typeof o=="function"?o:X(+o),l):s},l.startAngle=function(o){return arguments.length?(i=typeof o=="function"?o:X(+o),l):i},l.endAngle=function(o){return arguments.length?(c=typeof o=="function"?o:X(+o),l):c},l.padAngle=function(o){return arguments.length?(n=typeof o=="function"?o:X(+o),l):n},l.context=function(o){return arguments.length?(a=o??null,l):a},l}function Ta(h,e){return e<h?-1:e>h?1:e>=h?0:NaN}function wa(h){return h}function Ca(){var h=wa,e=Ta,t=null,s=X(0),i=X(St),c=X(0);function n(a){var d,l=(a=Ce(a)).length,o,g,f=0,k=new Array(l),b=new Array(l),y=+s.apply(this,arguments),r=Math.min(St,Math.max(-St,i.apply(this,arguments)-y)),m,p=Math.min(Math.abs(r)/l,c.apply(this,arguments)),S=p*(r<0?-1:1),L;for(d=0;d<l;++d)(L=b[k[d]=d]=+h(a[d],d,a))>0&&(f+=L);for(e!=null?k.sort(function(O,_){return e(b[O],b[_])}):t!=null&&k.sort(function(O,_){return t(a[O],a[_])}),d=0,g=f?(r-l*S)/f:0;d<l;++d,y=m)o=k[d],L=b[o],m=y+(L>0?L*g:0)+S,b[o]={data:a[o],index:d,value:L,startAngle:y,endAngle:m,padAngle:p};return b}return n.value=function(a){return arguments.length?(h=typeof a=="function"?a:X(+a),n):h},n.sortValues=function(a){return arguments.length?(e=a,t=null,n):e},n.sort=function(a){return arguments.length?(t=a,e=null,n):t},n.startAngle=function(a){return arguments.length?(s=typeof a=="function"?a:X(+a),n):s},n.endAngle=function(a){return arguments.length?(i=typeof a=="function"?a:X(+a),n):i},n.padAngle=function(a){return arguments.length?(c=typeof a=="function"?a:X(+a),n):c},n}function Da({x:h,y:e,w:t,h:s,tl:i=!1,tr:c=!1,bl:n=!1,br:a=!1,r:d=0}){let l;l=`M${h+d},${e}h${t-2*d}`;let o=c?d:0,g=c?0:d;return l+=`a${o},${o} 0 0 1 ${o},${o}`,l+=`h${g}v${g}`,l+=`v${s-2*d}`,o=a?d:0,g=a?0:d,l+=`a${o},${o} 0 0 1 ${-o},${o}`,l+=`v${g}h${-g}`,l+=`h${2*d-t}`,o=n?d:0,g=n?0:d,l+=`a${o},${o} 0 0 1 ${-o},${-o}`,l+=`h${-g}v${-g}`,l+=`v${2*d-s}`,o=i?d:0,g=i?0:d,l+=`a${o},${o} 0 0 1 ${o},${-o}`,l+=`v${-g}h${g}`,l+="z",l}const Ma=Object.assign(Object.assign({},De),{color:void 0,barMaxWidth:void 0,barWidth:void 0,dataStep:void 0,barPadding:0,roundedCorners:2,cursor:null,barMinHeight1Px:!1,barMinHeightZeroValue:null,orientation:oe.Vertical}),me=nt`
|
|
2
|
-
label: stacked-bar-component;
|
|
3
|
-
`,Ra=le`
|
|
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 ${`.${me}`} {
|
|
17
|
-
--vis-stacked-bar-stroke-color: var(--vis-dark-stacked-bar-stroke-color);
|
|
18
|
-
}
|
|
19
|
-
`,At=nt`
|
|
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
|
-
`,Ht=nt`
|
|
31
|
-
label: barGroup;
|
|
32
|
-
`,pe=nt`
|
|
33
|
-
label: barGroupExit;
|
|
34
|
-
`,La=Object.freeze(Object.defineProperty({__proto__:null,bar:At,barGroup:Ht,barGroupExit:pe,globalStyles:Ra,root:me},Symbol.toStringTag,{value:"Module"}));class Ft extends Me{constructor(e){super(),this._defaultConfig=Ma,this.config=this._defaultConfig,this.getAccessors=()=>Re(this.config.y)?this.config.y:[this.config.y],this.stacked=!0,this.events={},this._barData=[],e&&this.setConfig(e)}get bleed(){if(this._barData=this._getVisibleData(),this._barData.length===0)return{top:0,bottom:0,left:0,right:0};const e=!this.isVertical()&&this.dataScale.range()[0]>this.dataScale.range()[1],t=this.dataScale.domain(),s=this._getBarWidth()/2,i=this._barData.map((k,b)=>ut(k,this.config.x,b)),c=Mt(i),n=Le(i),a=this.dataScale(c),d=this.dataScale(n),l=this.dataScale.invert(a+(e?s:-s)),o=this.dataScale.invert(d+(e?-s:s)),g=l<=t[0]?this.dataScale(t[0])-this.dataScale(l):0,f=o>t[1]?this.dataScale(o)-this.dataScale(t[1]):0;return{top:this.isVertical()?0:e?-f:g,bottom:this.isVertical()?0:e?-g:f,left:this.isVertical()?g:0,right:this.isVertical()?f:0}}get dataScale(){return this.isVertical()?this.xScale:this.yScale}get valueScale(){return this.isVertical()?this.yScale:this.xScale}isVertical(){return this.config.orientation===oe.Vertical}_render(e){const{config:t}=this,s=jt(e)?e:t.duration,i=this.getAccessors(),c=Ee(this._barData,0,i,this._prevNegative);this._prevNegative=c.map(b=>!!b.isMostlyNegative);const n=this.g.selectAll(`.${Ht}`).data(this._barData,(b,y)=>{var r;return`${(r=Qt(b,t.id,y))!==null&&r!==void 0?r:y}`}),a=(b,y)=>{const r=this.dataScale(ut(b,t.x,y)),m=this.isVertical()?r:0,p=this.isVertical()?0:r;return`translate(${m},${p})`},l=n.enter().append("g").attr("class",Ht).attr("transform",a).style("opacity",1).merge(n);st(l,s).attr("transform",a).style("opacity",1);const o=n.exit().attr("class",pe);st(o,s).style("opacity",0).remove(),st(o.selectAll(`.${At}`),s).attr("transform",this.isVertical()?`translate(0,${this._height/3})`:`translate(${this._width/6},0)`);const g=l.selectAll(`.${At}`).data((b,y)=>c.map((r,m)=>({datum:b,index:y,stacked:r[y],stackIndex:m,isEnding:m===c.length-1||m<=c.length-1&&c[m+1][y][0]!==r[y][1]})).filter(r=>r.stacked[0]!==r.stacked[1]),b=>b.stackIndex),k=g.enter().append("path").attr("class",At).attr("d",b=>this._getBarPath(b,!0)).style("fill",b=>$t(b.datum,t.color,b.stackIndex)).merge(g);st(k,s).attr("d",b=>this._getBarPath(b)).style("fill",b=>$t(b.datum,t.color,b.stackIndex)).style("cursor",b=>Qt(b.datum,t.cursor,b.stackIndex)),st(g.exit(),s).style("opacity",0).remove()}_getBarWidth(){const{config:e,datamodel:{data:t}}=this;if(Ue(t))return 0;if(e.barWidth)return Mt([e.barWidth,e.barMaxWidth]);const s=this.dataScale.bandwidth,i=this.dataScale.domain?this.dataScale.domain():[];let n=1+(s?i.length:i[1]-i[0])/e.dataStep||!s&&t.filter((l,o)=>{const g=ut(l,e.x,o);return g>=i[0]&&g<=i[1]}).length||t.length;!s&&n>=2&&(n+=1);const d=(n<2?1:1-e.barPadding)*(this.isVertical()?this._width:this._height)/n;return Mt([d,e.barMaxWidth])}_getVisibleData(){const{config:e,datamodel:{data:t}}=this,s=this._getBarWidth(),i=t.length<2?0:s/2,c=this.dataScale,n=Math.abs(c.invert(i)-c.invert(0));return t?.filter((d,l)=>{const o=ut(d,e.x,l),g=c.domain(),f=+g[0],k=+g[1];return o>=f-n&&o<=k+n})}_getBarPath(e,t=!1){const{config:s}=this,i=this.getAccessors(),c=this._getBarWidth(),n=e.stacked[1]<0,a=e.isEnding,d=ut(e.datum,i[e.stackIndex],e.index),l=t?0:Math.abs(this.valueScale(e.stacked[0])-this.valueScale(e.stacked[1])),o=!t&&s.barMinHeight1Px&&l<1&&isFinite(d)&&d!==s.barMinHeightZeroValue?1:l,g=t?this.valueScale(0):this.valueScale(n?e.stacked[0]:e.stacked[1])-(l<1&&s.barMinHeight1Px?1:0),f=-c/2,k=c,b=s.roundedCorners?jt(s.roundedCorners)?+s.roundedCorners:k/2:0,y=ie(b,0,Math.min(l,k)/2),r=this.yScale.range()[0]>this.yScale.range()[1];return Da({x:this.isVertical()?f:g-o,y:this.isVertical()?g+(r?0:-o):f,w:this.isVertical()?k:o,h:this.isVertical()?o:k,tl:a&&(this.isVertical()?!n&&r||n&&!r:n),tr:a&&(this.isVertical()?!n&&r||n&&!r:!n),br:a&&(this.isVertical()?n&&r||!n&&!r:!n),bl:a&&(this.isVertical()?n&&r||!n&&!r:n),r:y})}getValueScaleExtent(e){const{datamodel:t}=this,s=this.getAccessors(),i=e?this._getVisibleData():t.data;return Pe(i,...s)}getDataScaleExtent(){const{config:e,datamodel:t}=this;return je(t.data,e.x)}getYDataExtent(e){return this.isVertical()?this.getValueScaleExtent(e):this.getDataScaleExtent()}getXDataExtent(){return this.isVertical()?this.getDataScaleExtent():this.getValueScaleExtent(!1)}}Ft.selectors=La;const Ea=Object.assign(Object.assign({},He),{id:(h,e)=>{var t;return(t=h.id)!==null&&t!==void 0?t:e},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(h,e){h.style("fill",t=>$t(t.data,e.color,t.index)).style("opacity",0).each((t,s,i)=>{const c=i[s],n=(t.startAngle+t.endAngle)/2,a=(t.endAngle-t.startAngle)/2;c._animState={startAngle:n-a,endAngle:n+a,innerRadius:t.innerRadius,outerRadius:t.outerRadius,padAngle:t.padAngle}})}function Pa(h,e,t,s){h.style("transition",`fill ${s}ms`).style("fill",c=>$t(c.data,e.color,c.index));const i=c=>e.showEmptySegments||c.value?1:0;s?st(h,s).style("opacity",i).attrTween("d",(n,a,d)=>{const l=d[a],o={startAngle:n.startAngle,endAngle:n.endAngle,innerRadius:n.innerRadius,outerRadius:n.outerRadius,padAngle:n.padAngle},g=Oe(l._animState,o);return f=>(l._animState=g(f),t(l._animState))}):h.attr("d",t).style("opacity",i)}function ja(h,e){st(h,e).style("opacity",0).remove()}const ve=Array.from({length:4},(h,e)=>{const t=-Math.PI/2+e*Math.PI/2;return[t,t+Math.PI]}),[Fn,In,Yn,Xn]=ve,be=nt`
|
|
35
|
-
label: donut-component;
|
|
36
|
-
`,Ha=le`
|
|
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 ${`.${be}`} {
|
|
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
|
-
`,ye=nt`
|
|
67
|
-
label: background;
|
|
68
|
-
fill: var(--vis-donut-background-color);
|
|
69
|
-
`,Ot=nt`
|
|
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
|
-
`,_e=nt`
|
|
74
|
-
label: segment-exit;
|
|
75
|
-
`,xe=nt`
|
|
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
|
-
`,ke=nt`
|
|
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
|
-
`,Oa=Object.freeze(Object.defineProperty({__proto__:null,background:ye,centralLabel:xe,centralSubLabel:ke,root:be,segment:Ot,segmentExit:_e,variables:Ha},Symbol.toStringTag,{value:"Module"}));class It extends Ve{constructor(e){super(),this._defaultConfig=Ea,this.config=this._defaultConfig,this.datamodel=new We,this.arcGen=$a(),this.events={},e&&this.setConfig(e),this.arcBackground=this.g.append("path"),this.arcGroup=this.g.append("g"),this.centralLabel=this.g.append("text").attr("class",xe),this.centralSubLabel=this.g.append("text").attr("class",ke)}get bleed(){return{top:0,bottom:0,left:0,right:0}}_render(e){var t,s,i,c,n,a,d,l,o,g,f,k,b,y;const{config:r,datamodel:m,bleed:p}=this,S=m.data.map((w,Z)=>({index:Z,datum:w})).filter(w=>r.showEmptySegments||ut(w.datum,r.value,w.index)),L=jt(e)?e:r.duration,[O,_,C,P]=ve.map(w=>r.angleRange&&r.angleRange[0]===w[0]&&r.angleRange[1]===w[1]),z=O||C,N=_||P,B=this._width*(N?2:1),G=this._height*(z?2:1),A=r.radius||Math.min(B-p.left-p.right,G-p.top-p.bottom)/2,M=r.arcWidth===0?0:ie(A-r.arcWidth,0,A-1),F=this._height/2+(O?A/2:C?-A/2:0),K=this._width/2+(P?A/2:_?-A/2:0),v=`translate(${K},${F})`;this.arcGroup.attr("transform",v),this.arcGen.startAngle(w=>w.startAngle).endAngle(w=>w.endAngle).innerRadius(w=>w.innerRadius).outerRadius(w=>w.outerRadius).padAngle(w=>w.padAngle).cornerRadius(r.cornerRadius);const U=Ca().startAngle((s=(t=r.angleRange)===null||t===void 0?void 0:t[0])!==null&&s!==void 0?s:0).endAngle((c=(i=r.angleRange)===null||i===void 0?void 0:i[1])!==null&&c!==void 0?c:2*Math.PI).padAngle(r.padAngle).value(w=>ut(w.datum,r.value,w.index)||0).sort((w,Z)=>{var ct;return(ct=r.sortFunction)===null||ct===void 0?void 0:ct.call(r,w.datum,Z.datum)})(S).map(w=>{const Z=Object.assign(Object.assign({},w),{data:w.data.datum,index:w.data.index,innerRadius:M,outerRadius:A});return r.showEmptySegments&&w.endAngle-w.startAngle-w.padAngle<=Number.EPSILON&&(Z.endAngle=w.startAngle+Math.max(r.emptySegmentAngle,r.padAngle),Z.padAngle=w.padAngle/2),Z}),V=this.arcGroup.selectAll(`.${Ot}`).data(U,w=>r.id(w.data,w.index)),q=V.enter().append("path").attr("class",Ot).call(Ua,r),tt=V.merge(q);tt.call(Pa,r,this.arcGen,L),tt.sort((w,Z)=>Z.value-w.value),V.exit().attr("class",_e).call(ja,L);const lt=_?"start":P?"end":"middle";this.centralLabel.attr("dy",r.centralSubLabel?"-0.55em":null).style("text-anchor",lt).text((n=r.centralLabel)!==null&&n!==void 0?n:null),this.centralSubLabel.attr("dy",r.centralLabel?"0.55em":null).style("text-anchor",lt).text((a=r.centralSubLabel)!==null&&a!==void 0?a:null),r.centralSubLabelWrap&&Be(this.centralSubLabel,M*1.9);const pt=(r.centralLabelOffsetX||0)+K;let Q=(r.centralLabelOffsetY||0)+F;z&&r.centralLabelOffsetX===void 0&&r.centralLabelOffsetY===void 0&&(Q=(O?-this.centralSubLabel.node().getBoundingClientRect().height:C?this.centralLabel.node().getBoundingClientRect().height:0)+F);const ht=`translate(${pt},${Q})`;this.centralLabel.attr("transform",ht),this.centralSubLabel.attr("transform",ht),this.arcBackground.attr("class",ye).attr("visibility",r.showBackground?null:"hidden").attr("transform",v),st(this.arcBackground,L).attr("d",this.arcGen({startAngle:(g=(l=(d=r.backgroundAngleRange)===null||d===void 0?void 0:d[0])!==null&&l!==void 0?l:(o=r.angleRange)===null||o===void 0?void 0:o[0])!==null&&g!==void 0?g:0,endAngle:(y=(k=(f=r.backgroundAngleRange)===null||f===void 0?void 0:f[1])!==null&&k!==void 0?k:(b=r.angleRange)===null||b===void 0?void 0:b[1])!==null&&y!==void 0?y:2*Math.PI,innerRadius:M,outerRadius:A}))}}It.selectors=Oa;const Va=ot({__name:"index",props:{component:{},tooltip:{},annotations:{},duration:{},margin:{},padding:{},sizing:{},width:{},height:{},svgDefs:{},ariaLabel:{},data:{}},setup(h,{expose:e}){const t=h,{data:s}=ra(t),i=Vt(t);let c;const n=ue({component:void 0,tooltip:void 0,annotations:void 0}),a=Nt(),d=()=>{c||a.value&&n.component&&(c=new ba(a.value,{...Ut(n)},s.value))};return ca(()=>{var l;d(),(l=n.component)==null||l.config,c?.updateContainer({...Ut(i.value),...Ut(n)})}),ft(s,()=>{c?c.setData(s.value,!0):d()}),zt(()=>c?.destroy()),Et(Wt,{data:s,update:l=>n.component=l,destroy:()=>n.component=void 0}),Et(Ge,{data:s,update:l=>n.tooltip=l,destroy:()=>{n.tooltip=void 0}}),Et(ze,{data:s,update:l=>n.annotations=l,destroy:()=>{n.annotations=void 0}}),e({component:c}),(l,o)=>($(),j("div",{"data-vis-single-container":"",ref_key:"elRef",ref:a,class:"unovis-single-container"},[da(l.$slots,"default")],512))}}),Wa={"data-vis-component":""},Ba=Ft.selectors,Ga=ot({__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(h,{expose:e}){const t=he(Wt),s=h,i=R(()=>t.data.value??s.data),c=Vt(s),n=Nt();return ge(()=>{fe(()=>{var a;n.value=new Ft(c.value),(a=n.value)==null||a.setData(i.value),t.update(n.value)})}),zt(()=>{var a;(a=n.value)==null||a.destroy(),t.destroy()}),ft(c,(a,d)=>{var l;re(a,d)||(l=n.value)==null||l.setConfig(c.value)}),ft(i,()=>{var a;(a=n.value)==null||a.setData(i.value)}),e({component:n}),(a,d)=>($(),j("div",Wa))}}),za={"data-vis-component":""},Na=It.selectors,Fa=ot({__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(h,{expose:e}){const t=he(Wt),s=h,i=R(()=>t.data.value??s.data),c=Vt(s),n=Nt();return ge(()=>{fe(()=>{var a;n.value=new It(c.value),(a=n.value)==null||a.setData(i.value),t.update(n.value)})}),zt(()=>{var a;(a=n.value)==null||a.destroy(),t.destroy()}),ft(c,(a,d)=>{var l;re(a,d)||(l=n.value)==null||l.setConfig(c.value)}),ft(i,()=>{var a;(a=n.value)==null||a.setData(i.value)}),e({component:n}),(a,d)=>($(),j("div",za))}}),Ia={key:0,class:"pointer-events-none absolute inset-0 z-10"},Ya={key:1,class:"flex h-72 items-center justify-center rounded-md border border-dashed text-sm text-muted-foreground"},Xa={class:"mt-4 flex flex-wrap items-center justify-center gap-3 text-xs text-muted-foreground"},qa={class:"font-medium text-foreground tabular-nums"},Ja=288,Za=ot({__name:"TodayUsageTrendPanel",props:{items:{}},setup(h){const e=h,t={bottom:32,left:56,right:28,top:8},s={left:8,right:18},i=[0,void 0],c=ua("chartRoot"),{width:n}=ha(c),a=ue({hour:null,pointerY:null}),d=R(()=>ga.map(v=>{const E=e.items.reduce((U,V)=>U+(V.agents[v]?.totalTokens??0),0);return{color:v==="codex"?"#94a3b8":se[v].color,key:v,label:se[v].label,totalTokens:E}}).filter(v=>v.totalTokens>0).sort((v,E)=>E.totalTokens-v.totalTokens)),l=R(()=>e.items.map(v=>({costUSD:v.costUSD,hour:v.hour,label:v.label,totalTokens:v.totalTokens,values:Object.fromEntries(d.value.map(E=>[E.key,v.agents[E.key]?.totalTokens??0]))}))),o=R(()=>d.value.map(v=>E=>E.values[v.key]??0)),g=R(()=>Object.fromEntries(d.value.map(v=>[v.key,{color:v.color,label:v.label}]))),f=R(()=>d.value.map(v=>`
|
|
92
|
-
<linearGradient id="${K(v.key)}" x1="0" y1="0" x2="0" y2="1">
|
|
93
|
-
<stop offset="0%" stop-color="${v.color}" stop-opacity="0.42" />
|
|
94
|
-
<stop offset="100%" stop-color="${v.color}" stop-opacity="0.07" />
|
|
95
|
-
</linearGradient>
|
|
96
|
-
`).join("")),k=[0,23],b=[0,4,8,12,16,20,23],y=R(()=>t.left),r=R(()=>t.top),m=R(()=>Math.max(n.value-t.left-t.right,0)),p=R(()=>Math.max(Ja-t.top-t.bottom,0)),S=R(()=>r.value+p.value),L=R(()=>Math.max(m.value-s.left-s.right,0)),O=R(()=>Math.max(...l.value.map(v=>v.totalTokens),0)),_=R(()=>{if(a.hour===null||a.pointerY===null)return null;const v=l.value[a.hour];if(!v||m.value<=0||p.value<=0)return null;const E=y.value+s.left+a.hour/23*L.value,U=te(a.pointerY,r.value,S.value),V=p.value<=0?0:1-(U-r.value)/p.value;return{x:E,xLabel:v.label,y:U,yLabel:it(V*O.value)}});function C(v,E){return d.value[E]?`url(#${K(d.value[E].key)})`:"#2563eb"}function P(v){return v?.hour??0}function z(v,E){return d.value[E]?.color??"#2563eb"}function N(v,E){return d.value[E]?.color??"#2563eb"}function B(v){return v instanceof Date?"":e.items[v]?.label??""}function G(v){return v instanceof Date?"":it(v)}function A(v){if(!v)return"";const E=d.value.map(U=>({color:U.color,costUSD:e.items[v.hour]?.agents[U.key]?.costUSD??0,label:U.label,totalTokens:v.values[U.key]??0})).filter(U=>U.totalTokens>0||U.costUSD>0).sort((U,V)=>V.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">${wt(v.label)}</span>
|
|
100
|
-
<span class="font-mono text-muted-foreground">${yt(v.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">${it(v.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">${wt(U.label)}</span>
|
|
112
|
-
</span>
|
|
113
|
-
<span class="font-mono font-medium text-foreground">${it(U.totalTokens)} / ${yt(U.costUSD)}</span>
|
|
114
|
-
</div>
|
|
115
|
-
`).join("")}
|
|
116
|
-
</div>
|
|
117
|
-
</div>
|
|
118
|
-
`}function M(v){const E=c.value?.getBoundingClientRect();if(!E||e.items.length===0)return;const U=v.clientX-E.left,V=v.clientY-E.top,q=y.value+m.value,tt=y.value+s.left,lt=q-s.right;if(U<y.value||U>q||V<r.value||V>S.value||L.value<=0){F();return}a.hour=Math.round(te((U-tt)/Math.max(lt-tt,1)*23,0,23)),a.pointerY=V}function F(){a.hour=null,a.pointerY=null}function K(v){return`today-usage-trend-${v}`}return(v,E)=>{const U=Bt,V=xt;return $(),W(V,{description:"Hourly token and spend by agent for today",icon:"lucide:chart-area",title:"Today's Token Trend"},{default:T(()=>[u(d).length>0?($(),j("div",{key:0,ref_key:"chartRoot",ref:c,class:"relative",onPointerleave:F,onPointermove:M},[x(U,{class:"h-72 w-full",config:u(g)},{default:T(()=>[x(u(ce),{"auto-margin":!1,data:u(l),height:288,margin:t,padding:s,"svg-defs":u(f),"x-domain":k,"y-domain":i},{default:T(()=>[x(u(Ne),{color:C,"curve-type":"monotoneX",line:!0,"line-color":z,"line-width":2,opacity:.82,x:P,y:u(o)},null,8,["y"]),x(u(Tt),{"grid-line":!1,"tick-format":B,"tick-padding":10,"tick-values":b,type:"x"}),x(u(Tt),{"num-ticks":4,"tick-format":G,type:"y"}),u(d).length>0?($(),W(u(Gt),{key:0})):_t("",!0),u(d).length>0?($(),W(u(Fe),{key:1,color:N,template:A,x:P,"y-stacked":u(o)},null,8,["y-stacked"])):_t("",!0)]),_:1},8,["data","svg-defs"])]),_:1},8,["config"]),u(_)?($(),j("div",Ia,[D("div",{class:"absolute border-l border-dashed border-border/80",style:rt({height:`${u(p)}px`,left:`${u(_).x}px`,top:`${u(r)}px`})},null,4),D("div",{class:"absolute border-t border-dashed border-border/80",style:rt({left:`${u(y)}px`,top:`${u(_).y}px`,width:`${u(m)}px`})},null,4),D("div",{class:"absolute rounded-sm bg-foreground px-2 py-1 text-[11px] font-medium text-background shadow-sm",style:rt({left:`${u(_).x}px`,top:`${u(S)+6}px`,transform:"translateX(-50%)"})},H(u(_).xLabel),5),D("div",{class:"absolute rounded-sm bg-foreground px-2 py-1 text-[11px] font-medium text-background shadow-sm",style:rt({left:`${Math.max(u(y)-8,0)}px`,top:`${u(_).y}px`,transform:"translate(-100%, -50%)"})},H(u(_).yLabel),5)])):_t("",!0)],544)):($(),j("div",Ya," No usage recorded today. ")),D("div",Xa,[($(!0),j(at,null,mt(u(d),q=>($(),j("div",{key:q.key,class:"flex items-center gap-2"},[D("span",{class:"size-2.5 rounded-sm",style:rt({backgroundColor:q.color})},null,4),D("span",null,H(q.label),1),D("span",qa,H(u(it)(q.totalTokens)),1)]))),128))])]),_:1})}}}),Ka=Object.assign(Za,{__name:"DashboardTodayUsageTrendPanel"}),Qa={key:0,class:"text-xs text-destructive"},tn={class:"mb-4 grid grid-cols-2 gap-3"},en={class:"mb-4 grid grid-cols-2 gap-3"},an={class:"rounded-md border px-3 py-2"},nn={class:"mt-1 text-xl font-semibold tabular-nums"},sn={class:"rounded-md border px-3 py-2"},on={class:"mt-1 text-xl font-semibold tabular-nums"},ln={class:"mt-4 flex flex-wrap justify-center items-center gap-3 text-xs text-muted-foreground"},rn=ot({name:"StatisticalAnalysisSessionAnalysisPanel",__name:"SessionAnalysisPanel",props:{errorMessage:{},items:{},loading:{type:Boolean},totalSessions:{}},setup(h){const e=h,t=[{color:"#2563eb",key:"tokens",label:"Token Usage"},{color:"#b6d72f",key:"duration",label:"Duration"},{color:"#f97316",key:"cost",label:"Cost"}],s={cost:{color:t[2].color,label:t[2].label},duration:{color:t[1].color,label:t[1].label},tokens:{color:t[0].color,label:t[0].label}},i={bottom:32,left:120,right:12,top:8},c=R(()=>{if(e.items.length===0)return yt(0);const m=e.items.reduce((p,S)=>p+S.costUSD,0)/e.items.length;return yt(m)}),n=R(()=>{const m=new Map;for(const _ of e.items){const C=m.get(_.project)??{costUSD:0,durationMinutes:0,sessionCount:0,tokenTotal:0};C.costUSD+=_.costUSD,C.durationMinutes+=l(_.duration),C.sessionCount+=1,C.tokenTotal+=_.tokenTotal,m.set(_.project,C)}const p=Array.from(m.entries()).map(([_,C])=>({project:_,...C})).sort((_,C)=>C.costUSD-_.costUSD),S=Math.max(...p.map(_=>_.tokenTotal),0),L=Math.max(...p.map(_=>_.durationMinutes),0),O=Math.max(...p.map(_=>_.costUSD),0);return p.map((_,C)=>({..._,costLabel:yt(_.costUSD),costScore:g(_.costUSD,O),durationLabel:o(_.durationMinutes),durationScore:g(_.durationMinutes,L),index:C,tokenLabel:it(_.tokenTotal),tokenScore:g(_.tokenTotal,S)}))}),a=R(()=>n.value.map(m=>m.index)),d=R(()=>({[Ba.bar]:k}));function l(m){const p=m.match(/(\d+)h/)?.[1],S=m.match(/(\d+)m/)?.[1];return Number(p??0)*60+Number(S??0)}function o(m){const p=Math.floor(m/60),S=m%60;return p===0?`${S}m`:S===0?`${p}h`:`${p}h ${S}m`}function g(m,p){return p>0?m/p*100:0}function f(m,p){return t[p]?.color??t[0].color}function k(m){const p=m.datum,S=t[m.stackIndex]??t[0],L=b(p,m.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">${wt(p.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: ${S.color}"></span>
|
|
124
|
-
${S.label}
|
|
125
|
-
</span>
|
|
126
|
-
<span class="font-mono font-semibold text-foreground">${L}</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>${p.tokenLabel}</span></div>
|
|
130
|
-
<div class="flex justify-between gap-4"><span>Duration</span><span>${p.durationLabel}</span></div>
|
|
131
|
-
<div class="flex justify-between gap-4"><span>Cost</span><span>${p.costLabel}</span></div>
|
|
132
|
-
<div class="flex justify-between gap-4"><span>Sessions</span><span>${p.sessionCount}</span></div>
|
|
133
|
-
</div>
|
|
134
|
-
</div>
|
|
135
|
-
`}function b(m,p){return p===0?`${m.tokenLabel} tokens`:p===1?m.durationLabel:m.costLabel}function y(m){return m instanceof Date?"":n.value.find(p=>p.index===m)?.project??""}function r(m){return m instanceof Date?"":`${Math.round(m)}%`}return(m,p)=>{const S=de,L=Bt,O=xt;return $(),W(O,{description:"Token, duration, and cost grouped by project",icon:"lucide:messages-square",title:"Session Analysis"},{default:T(()=>[h.errorMessage?($(),j("p",Qa,H(h.errorMessage),1)):h.loading?($(),j(at,{key:1},[D("div",tn,[x(S,{class:"h-20 w-full rounded-md"}),x(S,{class:"h-20 w-full rounded-md"})]),x(S,{class:"h-80 w-full rounded-md"})],64)):($(),j(at,{key:2},[D("div",en,[D("div",an,[p[0]||(p[0]=D("p",{class:"text-xs text-muted-foreground"}," Total Sessions ",-1)),D("p",nn,H(h.totalSessions),1)]),D("div",sn,[p[1]||(p[1]=D("p",{class:"text-xs text-muted-foreground"}," Top Session Avg ",-1)),D("p",on,H(c.value),1)])]),x(L,{class:"h-80 w-full",config:s},{default:T(()=>[x(u(ce),{"auto-margin":!1,data:n.value,height:320,margin:i,"y-direction":"south"},{default:T(()=>[x(u(Ga),{"bar-max-width":28,"bar-padding":.28,color:f,cursor:"pointer",orientation:"horizontal","rounded-corners":3,x:_=>_.index,y:[_=>_.tokenScore,_=>_.durationScore,_=>_.costScore]},null,8,["x","y"]),x(u(Tt),{"grid-line":!1,"tick-format":y,"tick-text-width":100,"tick-text-fit-mode":"trim","tick-text-trim-type":"end","tick-values":a.value,type:"y"},null,8,["tick-values"]),x(u(Tt),{"num-ticks":4,"tick-format":r,type:"x"}),x(u(Gt),{triggers:d.value},null,8,["triggers"])]),_:1},8,["data"])]),_:1}),D("div",ln,[($(),j(at,null,mt(t,_=>D("div",{key:_.key,class:"flex items-center gap-2"},[D("span",{class:"size-2.5 rounded-sm",style:rt({backgroundColor:_.color})},null,4),D("span",null,H(_.label),1)])),64))])],64))]),_:1})}}}),cn=Object.assign(rn,{__name:"StatisticalAnalysisSessionAnalysisPanel"}),dn={class:"space-y-4"},un={class:"flex items-start justify-between gap-3"},hn={class:"min-w-0"},gn={class:"truncate text-sm font-medium"},fn={class:"truncate text-xs text-muted-foreground"},mn={class:"shrink-0 text-sm font-semibold tabular-nums"},pn={class:"h-2 overflow-hidden rounded-full bg-secondary"},vn=ot({name:"StatisticalAnalysisUsageBarList",__name:"UsageBarList",props:{items:{}},setup(h){function e(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 t(s){return`${Math.max(s.percent,s.percent>0?3:0)}%`}return(s,i)=>($(),j("div",dn,[($(!0),j(at,null,mt(h.items,c=>($(),j("div",{key:c.label,class:"space-y-2"},[D("div",un,[D("div",hn,[D("p",gn,H(c.label),1),D("p",fn,H(c.detail),1)]),D("span",mn,H(c.value),1)]),D("div",pn,[D("div",{class:fa(["h-full rounded-full transition-[width]",e(c.tone)]),style:rt({width:t(c)})},null,6)])]))),128))]))}}),bn=Object.assign(vn,{__name:"StatisticalAnalysisUsageBarList"}),yn={class:"grid gap-6 lg:grid-cols-[220px_1fr] lg:items-center"},_n={class:"flex items-center justify-center"},xn={class:"space-y-3"},kn={class:"flex min-w-0 items-center gap-2"},Sn={class:"truncate text-sm text-muted-foreground"},An={class:"text-sm font-semibold tabular-nums"},$n={class:"w-12 text-right text-xs text-muted-foreground tabular-nums"},Tn={class:"mt-5 border-t pt-4"},wn=ot({name:"StatisticalAnalysisEfficiencyCachePanel",__name:"EfficiencyCachePanel",props:{dailyItems:{},items:{}},setup(h){const e=h,t=R(()=>e.dailyItems.reduce((g,f)=>g+f.inputTokens,0)),s=R(()=>e.dailyItems.reduce((g,f)=>g+f.cachedInputTokens,0)),i=R(()=>Math.max(t.value-s.value,0)),c=R(()=>t.value>0?s.value/t.value:0),n=R(()=>Rt(c.value)),a=R(()=>[{color:"#059669",key:"cached",label:"Cached Input",shareLabel:Rt(c.value),value:s.value,valueLabel:it(s.value)},{color:"#0ea5e9",key:"fresh",label:"Fresh Input",shareLabel:Rt(t.value>0?i.value/t.value:0),value:i.value,valueLabel:it(i.value)}]),d=R(()=>Object.fromEntries(a.value.map(g=>[g.key,{color:g.color,label:g.label}]))),l=R(()=>({[Na.segment]:o}));function o(g){const f=g.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: ${f.color}"></span>
|
|
139
|
-
${wt(f.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">${f.valueLabel}</span></div>
|
|
143
|
-
<div class="flex justify-between gap-4"><span>Share</span><span class="font-mono font-medium text-foreground">${f.shareLabel}</span></div>
|
|
144
|
-
</div>
|
|
145
|
-
</div>
|
|
146
|
-
`}return(g,f)=>{const k=Bt,b=bn,y=xt;return $(),W(y,{description:"Cached input ratio across total input tokens",icon:"lucide:gauge",title:"Efficiency / Cache"},{default:T(()=>[D("div",yn,[D("div",_n,[x(k,{class:"h-52 w-full max-w-56",config:u(d)},{default:T(()=>[x(u(Va),{data:u(a),height:208},{default:T(()=>[x(u(Fa),{"arc-width":26,"central-label":u(n),"central-sub-label":"Hit Rate",color:r=>r.color,"corner-radius":4,"pad-angle":.04,value:r=>r.value},null,8,["central-label","color","value"]),x(u(Gt),{triggers:u(l)},null,8,["triggers"])]),_:1},8,["data"])]),_:1},8,["config"])]),D("div",xn,[($(!0),j(at,null,mt(u(a),r=>($(),j("div",{key:r.key,class:"grid grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-3"},[D("div",kn,[D("span",{class:"size-2.5 shrink-0 rounded-full",style:rt({backgroundColor:r.color})},null,4),D("span",Sn,H(r.label),1)]),D("span",An,H(r.valueLabel),1),D("span",$n,H(r.shareLabel),1)]))),128))])]),D("div",Tn,[x(b,{items:h.items},null,8,["items"])])]),_:1})}}}),Cn=Object.assign(wn,{__name:"StatisticalAnalysisEfficiencyCachePanel"}),bt=10,Dn=ot({name:"StatisticalAnalysisTokensUsagePanel",__name:"TokensUsagePanel",props:{items:{}},setup(h){const e=h,t=pa(1),s=R(()=>Math.max(1,Math.ceil(e.items.length/bt))),i=R(()=>{const n=(Math.min(t.value,s.value)-1)*bt;return e.items.slice(n,n+bt)});return ft(()=>e.items,()=>{t.value=1}),(c,n)=>{const a=qe,d=Xe,l=Ye,o=Ke,g=Je,f=Ie,k=Ze,b=xt;return $(),W(b,{description:"Daily model activity by token type, cache reads, total usage, and cost",icon:"lucide:calendar-days",title:"Daily Token Usage"},{default:T(()=>[x(f,null,{default:T(()=>[x(l,null,{default:T(()=>[x(d,null,{default:T(()=>[x(a,null,{default:T(()=>[...n[1]||(n[1]=[Y("Date",-1)])]),_:1}),x(a,null,{default:T(()=>[...n[2]||(n[2]=[Y("Models",-1)])]),_:1}),x(a,{class:"text-right"},{default:T(()=>[...n[3]||(n[3]=[Y(" Input ",-1)])]),_:1}),x(a,{class:"text-right"},{default:T(()=>[...n[4]||(n[4]=[Y(" Output ",-1)])]),_:1}),x(a,{class:"text-right"},{default:T(()=>[...n[5]||(n[5]=[Y(" Reasoning ",-1)])]),_:1}),x(a,{class:"text-right"},{default:T(()=>[...n[6]||(n[6]=[Y(" Cache Read ",-1)])]),_:1}),x(a,{class:"text-right"},{default:T(()=>[...n[7]||(n[7]=[Y(" Total Tokens ",-1)])]),_:1}),x(a,{class:"text-right"},{default:T(()=>[...n[8]||(n[8]=[Y(" Cost (USD) ",-1)])]),_:1})]),_:1})]),_:1}),x(g,null,{default:T(()=>[($(!0),j(at,null,mt(u(i),y=>($(),W(d,{key:y.date},{default:T(()=>[x(o,{class:"font-medium"},{default:T(()=>[Y(H(y.date),1)]),_:2},1024),x(o,null,{default:T(()=>[Y(H(Object.keys(y.models).join(", ")),1)]),_:2},1024),x(o,{class:"text-right"},{default:T(()=>[Y(H(u(vt)(y.inputTokens)),1)]),_:2},1024),x(o,{class:"text-right"},{default:T(()=>[Y(H(u(vt)(y.outputTokens)),1)]),_:2},1024),x(o,{class:"text-right"},{default:T(()=>[Y(H(u(vt)(y.reasoningOutputTokens)),1)]),_:2},1024),x(o,{class:"text-right"},{default:T(()=>[Y(H(u(vt)(y.cachedInputTokens)),1)]),_:2},1024),x(o,{class:"text-right"},{default:T(()=>[Y(H(u(vt)(y.totalTokens)),1)]),_:2},1024),x(o,{class:"text-right"},{default:T(()=>[Y(H(y.costUSD.toFixed(2)),1)]),_:2},1024)]),_:2},1024))),128))]),_:1})]),_:1}),h.items.length>bt?($(),W(k,{key:0,page:u(t),"onUpdate:page":n[0]||(n[0]=y=>ma(t)?t.value=y:null),"page-count":u(s),"page-size":bt,total:h.items.length},null,8,["page","page-count","total"])):_t("",!0)]),_:1})}}}),Mn=Object.assign(Dn,{__name:"StatisticalAnalysisTokensUsagePanel"});function Rn(){const h=ee(),e=ae(),t=ne().sessionAnalysis,{data:s,error:i,refresh:c,status:n}=Pt("analysis:home:core",ea,{default:ee}),{clear:a,data:d,error:l,execute:o,refresh:g,status:f}=Pt("analysis:home:usage",aa,{default:ae,immediate:!1,server:!1}),{clear:k,data:b,error:y,execute:r,refresh:m,status:p}=Pt("analysis:home:session",na,{default:()=>ne().sessionAnalysis,immediate:!1,server:!1}),{refresh:S}=sa({clearDeferred:()=>{a(),k()},coreStatus:n,executeDeferred:()=>Promise.all([o(),r()]),refreshCore:c,refreshDeferred:()=>Promise.all([g(),m()])});return{dailyTokenUsage:R(()=>d.value?.dailyTokenUsage??e.dailyTokenUsage),efficiencyMetrics:R(()=>d.value?.efficiencyMetrics??e.efficiencyMetrics),error:i,monthlyModelUsage:R(()=>s.value?.modelUsage??h.modelUsage),overviewCards:R(()=>s.value?.overviewCards??h.overviewCards),projectUsage:R(()=>s.value?.hotProjects??h.hotProjects),refresh:S,sessionAnalysisError:y,sessionAnalysisStatus:p,sessionUsage:R(()=>b.value?.items??t.items),status:n,todayHourlyUsage:R(()=>d.value?.todayHourlyUsage??e.todayHourlyUsage),totalSessions:R(()=>b.value?.totalSessions??t.totalSessions),usageError:l,usageStatus:f}}const Ln={class:"bg-background border border-input rounded-xl shadow-xs min-h-0 flex-1 overflow-y-auto"},En={class:"grid content-start p-4 space-y-3"},Un={key:0,class:"text-xs text-destructive"},Pn={class:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-4"},jn={key:0,class:"text-xs text-destructive"},Hn={key:0,class:"text-xs text-destructive"},On={key:0,class:"text-xs text-destructive"},Vn={key:0,class:"text-xs text-destructive"},qn=ot({__name:"index",setup(h){const{dailyTokenUsage:e,error:t,efficiencyMetrics:s,monthlyModelUsage:i,projectUsage:c,sessionAnalysisError:n,sessionAnalysisStatus:a,sessionUsage:d,totalSessions:l,todayHourlyUsage:o,status:g,usageError:f,usageStatus:k,overviewCards:b}=Rn(),{errorText:y,showSkeleton:r}=Lt(g,t),{errorText:m,showSkeleton:p}=Lt(a,n),{errorText:S,showSkeleton:L}=Lt(k,f);return(O,_)=>{const C=de,P=xt,z=Qe,N=ta,B=oa,G=la,A=Ka,M=ia,F=cn,K=Cn,v=Mn;return $(),j("div",Ln,[D("div",En,[u(y)?($(),j("p",Un,H(u(y)),1)):_t("",!0),u(r)?($(),j(at,{key:1},[D("div",Pn,[($(),j(at,null,mt(4,E=>x(C,{key:E,class:"h-28 rounded-md"})),64))]),x(z,null,{default:T(()=>[x(P,{class:"md:col-span-8",description:"Monthly token trends by model",icon:"solar:cpu-line-duotone",title:"Model Usage"},{default:T(()=>[x(C,{class:"h-72 w-full rounded-md"})]),_:1}),x(P,{class:"md:col-span-4",description:"Best performers by spend",icon:"lucide:folder-git-2",title:"Top Projects"},{default:T(()=>[x(C,{class:"h-72 w-full rounded-md"})]),_:1}),x(P,{class:"md:col-span-12",description:"Hourly token and spend by agent for today",icon:"lucide:chart-area",title:"Today's Token Trend"},{default:T(()=>[x(C,{class:"h-72 w-full rounded-md"})]),_:1}),x(P,{class:"md:col-span-12",description:"Usage trend over the selected period",icon:"lucide:activity",title:"Usage Trend"},{default:T(()=>[x(C,{class:"h-80 w-full rounded-md"})]),_:1}),x(P,{class:"md:col-span-6",description:"Token, duration, and cost grouped by project",icon:"lucide:messages-square",title:"Session Analysis"},{default:T(()=>[x(C,{class:"h-72 w-full rounded-md"})]),_:1}),x(P,{class:"md:col-span-6",description:"Cached input ratio across total input tokens",icon:"lucide:gauge",title:"Efficiency / Cache"},{default:T(()=>[x(C,{class:"h-72 w-full rounded-md"})]),_:1}),x(P,{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:T(()=>[x(C,{class:"h-72 w-full rounded-md"})]),_:1})]),_:1})],64)):($(),j(at,{key:2},[x(N,{cards:u(b)},null,8,["cards"]),x(z,null,{default:T(()=>[x(B,{"monthly-items":u(i),class:"md:col-span-8"},null,8,["monthly-items"]),x(G,{items:u(c),class:"md:col-span-4"},null,8,["items"]),u(L)||u(S)?($(),W(P,{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:T(()=>[u(S)?($(),j("p",jn,H(u(S)),1)):($(),W(C,{key:1,class:"h-72 w-full rounded-md"}))]),_:1})):($(),W(A,{key:1,items:u(o),class:"md:col-span-12"},null,8,["items"])),u(L)||u(S)?($(),W(P,{key:2,class:"md:col-span-12",description:"Usage trend over the selected period",icon:"lucide:activity",title:"Usage Trend"},{default:T(()=>[u(S)?($(),j("p",Hn,H(u(S)),1)):($(),W(C,{key:1,class:"h-80 w-full rounded-md"}))]),_:1})):($(),W(M,{key:3,items:u(e),class:"md:col-span-12","heat-metric":"cost",title:"Usage Trend"},null,8,["items"])),x(F,{"error-message":u(m),items:u(d),loading:u(p),"total-sessions":u(l),class:"md:col-span-6"},null,8,["error-message","items","loading","total-sessions"]),u(L)||u(S)?($(),W(P,{key:4,class:"md:col-span-6",description:"Cached input ratio across total input tokens",icon:"lucide:gauge",title:"Efficiency / Cache"},{default:T(()=>[u(S)?($(),j("p",On,H(u(S)),1)):($(),W(C,{key:1,class:"h-72 w-full rounded-md"}))]),_:1})):($(),W(K,{key:5,"daily-items":u(e),items:u(s),class:"md:col-span-6"},null,8,["daily-items","items"])),u(L)||u(S)?($(),W(P,{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:T(()=>[u(S)?($(),j("p",Vn,H(u(S)),1)):($(),W(C,{key:1,class:"h-72 w-full rounded-md"}))]),_:1})):($(),W(v,{key:7,items:u(e),class:"md:col-span-12"},null,8,["items"]))]),_:1})],64))])])}}});export{qn as default};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import{B as ce,_ as ve,S as ke,C as xe,a as pe,z as _e,A as we,e as Te,f as D,c as fe,m as z}from"./DgMMKsPE.js";import{e as ue,B as Ce,C as De,o as d,g as Z,w as ee,a as s,b as q,i,l as I,c as f,D as F,t as m,F as j,E as R,G as l,J as re,q as V,d as ge,P as ye,I as he}from"./Jp5cgQZi.js";import{_ as Me}from"./DKaPq50Z.js";const Se={key:0,class:"pointer-events-none absolute inset-0 z-10"},Ue={class:"mt-4 flex flex-wrap items-center justify-center gap-3 text-xs text-muted-foreground"},$e={class:"font-medium text-foreground tabular-nums"},je=288,Re=ue({name:"StatisticalAnalysisModelUsagePanel",__name:"ModelUsagePanel",props:{monthlyItems:{},year:{}},setup(n){const r=n,h=["#2563eb","#f97316","#0891b2","#8b5cf6","#059669","#f43f5e"],y={bottom:32,left:56,right:12,top:8},C=[0,void 0],U=Ce("chartRoot"),{width:Y}=De(U),L=re(null),b=re(null),A=l(()=>r.year??be(r.monthlyItems)??new Date().getFullYear()),_=l(()=>Array.from({length:12},(t,c)=>{const u=`${c+1}`.padStart(2,"0");return`${A.value}-${u}`})),G=l(()=>[0,Math.max(_.value.length-1,0)]),v=l(()=>_.value.map((t,c)=>c)),W=l(()=>r.monthlyItems.filter(t=>t.month.startsWith(`${A.value}-`))),te=l(()=>Array.from(new Set(W.value.map(t=>t.model)))),O=l(()=>_.value.map((t,c)=>{const u=Object.fromEntries(te.value.map(g=>[g,W.value.find(k=>k.month===t&&k.model===g)?.tokenTotal??0]));return{month:t,monthIndex:c,tokensByModel:u,totalTokens:Object.values(u).reduce((g,k)=>g+k,0)}})),S=l(()=>te.value.map((t,c)=>{const u=ne(c),g=O.value.reduce((k,Q)=>k+(Q.tokensByModel[t]??0),0);return{color:u,model:t,totalLabel:D(g),totalTokens:g}}).sort((t,c)=>c.totalTokens-t.totalTokens)),X=l(()=>S.value.map(t=>c=>c.tokensByModel[t.model]??0)),oe=l(()=>Object.fromEntries(S.value.map(t=>[t.model,{color:t.color,label:t.model}]))),ae=l(()=>S.value.map(t=>`
|
|
2
|
-
<linearGradient id="${me(t.model)}" x1="0" y1="0" x2="0" y2="1">
|
|
3
|
-
<stop offset="0%" stop-color="${t.color}" stop-opacity="0.45" />
|
|
4
|
-
<stop offset="100%" stop-color="${t.color}" stop-opacity="0.08" />
|
|
5
|
-
</linearGradient>
|
|
6
|
-
`).join("")),J=l(()=>O.value.length>0&&S.value.length>0),H=l(()=>y.left),P=l(()=>y.top),B=l(()=>Math.max(Y.value-y.left-y.right,0)),N=l(()=>Math.max(je-y.top-y.bottom,0)),K=l(()=>P.value+N.value),le=l(()=>Math.max(...O.value.map(t=>t.totalTokens),0)),$=l(()=>{if(L.value===null||b.value===null)return null;const t=O.value[L.value];if(!t||B.value<=0||N.value<=0)return null;const c=_.value.length<=1?0:L.value/(_.value.length-1),u=H.value+c*B.value,g=fe(b.value,P.value,K.value),Q=(N.value<=0?0:1-(g-P.value)/N.value)*le.value;return{x:u,xLabel:E(t.month),y:g,yLabel:D(Q)}});function se(t,c){const u=S.value[c];return u?`url(#${me(u.model)})`:ne(0)}function ie(t,c){return S.value[c]?.color??ne(0)}function e(t,c){return S.value[c]?.color??ne(0)}function o(t){const c=S.value.map(u=>({...u,tokenTotal:t.tokensByModel[u.model]??0})).sort((u,g)=>g.tokenTotal-u.tokenTotal);return`
|
|
7
|
-
<div class="grid min-w-48 gap-2 rounded-md border bg-background px-3 py-2 text-xs shadow-lg">
|
|
8
|
-
<div class="font-medium text-foreground">${x(t.month)} ${t.month.slice(0,4)}</div>
|
|
9
|
-
<div class="grid gap-1 text-muted-foreground">
|
|
10
|
-
${c.map(u=>`
|
|
11
|
-
<div class="flex items-center justify-between gap-4">
|
|
12
|
-
<span class="flex items-center gap-2">
|
|
13
|
-
<span class="size-2 rounded-sm" style="background-color: ${u.color}"></span>
|
|
14
|
-
${Te(u.model)}
|
|
15
|
-
</span>
|
|
16
|
-
<span class="font-mono font-medium text-foreground">${D(u.tokenTotal)}</span>
|
|
17
|
-
</div>
|
|
18
|
-
`).join("")}
|
|
19
|
-
</div>
|
|
20
|
-
<div class="flex justify-between gap-4 border-t pt-2 text-muted-foreground">
|
|
21
|
-
<span>Total</span>
|
|
22
|
-
<span class="font-mono font-semibold text-foreground">${D(t.totalTokens)}</span>
|
|
23
|
-
</div>
|
|
24
|
-
</div>
|
|
25
|
-
`}function p(t){if(t instanceof Date)return"";const c=_.value[t];return c?x(c):""}function a(t){return t instanceof Date?"":D(t)}function x(t){const[c,u]=t.split("-"),g=new Date(Number(c),Number(u)-1,1);return new Intl.DateTimeFormat("en-US",{month:"short"}).format(g)}function E(t){return`${x(t)} ${t.slice(0,4)}`}function M(t){const c=U.value?.getBoundingClientRect();if(!c)return;const u=t.clientX-c.left,g=t.clientY-c.top,k=H.value+B.value;if(u<H.value||u>k||g<P.value||g>K.value||B.value<=0||!J.value||_.value.length===0){w();return}const Q=fe((u-H.value)/Math.max(B.value,1),0,1);L.value=_.value.length<=1?0:Math.round(Q*(_.value.length-1)),b.value=g}function w(){L.value=null,b.value=null}function be(t){const u=[...t].sort((g,k)=>k.month.localeCompare(g.month))[0]?.month?.split("-")[0];return u?Number(u):null}function me(t){return`model-usage-${t.replace(/[^a-z0-9]+/gi,"-").toLowerCase()}`}function ne(t){return h[t%h.length]??"#2563eb"}return(t,c)=>{const u=ve,g=ce;return d(),Z(g,{description:"Monthly token trends by model",icon:"solar:cpu-line-duotone",title:"Model Usage"},{default:ee(()=>[s("div",{ref_key:"chartRoot",ref:U,class:"relative",onPointerleave:w,onPointermove:M},[q(u,{class:"h-72 w-full",config:i(oe)},{default:ee(()=>[q(i(ke),{"auto-margin":!1,data:i(O),height:288,margin:y,"svg-defs":i(ae),"x-domain":i(G),"y-domain":C},{default:ee(()=>[q(i(xe),{color:se,line:!0,"line-color":ie,"line-width":2.5,opacity:.82,x:k=>k.monthIndex,y:i(X)},null,8,["x","y"]),q(i(pe),{"grid-line":!1,"tick-format":p,"tick-values":i(v),type:"x"},null,8,["tick-values"]),q(i(pe),{"num-ticks":4,"tick-format":a,type:"y"}),i(J)?(d(),Z(i(_e),{key:0})):I("",!0),i(J)?(d(),Z(i(we),{key:1,color:e,template:o,x:k=>k.monthIndex,"y-stacked":i(X)},null,8,["x","y-stacked"])):I("",!0)]),_:1},8,["data","svg-defs","x-domain"])]),_:1},8,["config"]),i($)?(d(),f("div",Se,[s("div",{class:"absolute border-l border-dashed border-border/80",style:F({height:`${i(N)}px`,left:`${i($).x}px`,top:`${i(P)}px`})},null,4),s("div",{class:"absolute border-t border-dashed border-border/80",style:F({left:`${i(H)}px`,top:`${i($).y}px`,width:`${i(B)}px`})},null,4),s("div",{class:"absolute rounded-sm bg-foreground px-2 py-1 text-[11px] font-medium text-background shadow-sm",style:F({left:`${i($).x}px`,top:`${i(K)+6}px`,transform:"translateX(-50%)"})},m(i($).xLabel),5),s("div",{class:"absolute rounded-sm bg-foreground px-2 py-1 text-[11px] font-medium text-background shadow-sm",style:F({left:`${Math.max(i(H)-8,0)}px`,top:`${i($).y}px`,transform:"translate(-100%, -50%)"})},m(i($).yLabel),5)])):I("",!0)],544),s("div",Ue,[(d(!0),f(j,null,R(i(S),k=>(d(),f("div",{key:k.model,class:"flex items-center gap-2"},[s("span",{class:"size-2.5 rounded-sm",style:F({backgroundColor:k.color})},null,4),s("span",null,m(k.model),1),s("span",$e,m(k.totalLabel),1)]))),128))])]),_:1})}}}),Tt=Object.assign(Re,{__name:"StatisticalAnalysisModelUsagePanel"}),Le={class:"space-y-3"},Ae={class:"flex flex-col flex-1"},Pe={class:"truncate text-sm font-medium tracking-tight"},Be={class:"mt-1 truncate text-xs text-muted-foreground"},Ne={class:"text-right"},Ee={class:"text-xs font-medium tracking-tight tabular-nums"},Ie={class:"mt-1 flex items-center justify-end gap-1"},He=ue({name:"StatisticalAnalysisProjectUsagePanel",__name:"ProjectUsagePanel",props:{items:{}},setup(n){const r=n,h=[{trend:"+12.4%",trendTone:"up"},{trend:"-8.2%",trendTone:"down"},{trend:"+22.1%",trendTone:"up"},{trend:"+15.8%",trendTone:"up"},{trend:"-3.4%",trendTone:"down"},{trend:"+9.6%",trendTone:"up"},{trend:"-5.1%",trendTone:"down"},{trend:"+4.7%",trendTone:"up"}],y=l(()=>r.items.slice(0,6).map((b,A)=>{const _=h[A]??{trend:"+0.0%",trendTone:"up"};return{...b,shortName:L(b.label),trend:_.trend,trendTone:_.trendTone}}));function C(b){return b==="down"?"lucide:trending-down":"lucide:trending-up"}function U(b){return b==="down"?"size-3 text-red-500":"size-3 text-emerald-600 dark:text-emerald-400"}function Y(b){return b==="down"?"text-sm font-medium text-red-500 tabular-nums":"text-sm font-medium text-emerald-600 dark:text-emerald-400 tabular-nums"}function L(b){return b.split(/[-_\s]+/).filter(Boolean).slice(0,2).map(A=>A[0]?.toUpperCase()??"").join("")}return(b,A)=>{const _=Me,G=ce;return d(),Z(G,{description:"Best performers by spend",icon:"lucide:folder-git-2",title:"Top Projects"},{default:ee(()=>[s("div",Le,[(d(!0),f(j,null,R(i(y),v=>(d(),f("div",{key:v.repository,class:"flex justify-between items-center gap-3 rounded-md transition-colors"},[s("div",Ae,[s("p",Pe,m(v.label),1),s("p",Be,m(v.detail),1)]),s("div",Ne,[s("p",Ee,m(v.value),1),s("div",Ie,[q(_,{class:V(U(v.trendTone)),mode:"svg",name:C(v.trendTone)},null,8,["class","name"]),s("span",{class:V(Y(v.trendTone))},m(v.trend),3)])])]))),128))])]),_:1})}}}),Ct=Object.assign(He,{__name:"StatisticalAnalysisProjectUsagePanel"}),ze={class:"mb-4 grid grid-cols-1 gap-3 sm:grid-cols-3"},Fe={class:"text-xs text-muted-foreground"},Ye={class:"mt-1 text-lg font-semibold tabular-nums"},Oe={class:"border-b pb-4"},Ge=["aria-label","tabindex"],qe={class:"sr-only"},Ve={class:"font-medium"},We={key:0,class:"flex items-center justify-between gap-4 text-muted-foreground"},Xe={class:"font-mono font-medium text-foreground"},Je={class:"flex items-center justify-between gap-4 text-muted-foreground"},Ke={class:"font-mono font-medium text-foreground"},Qe={key:1,class:"flex items-center justify-between gap-4 text-muted-foreground"},Ze={class:"font-mono font-medium text-foreground"},et={key:2,class:"mt-1 grid max-h-56 gap-2 overflow-y-auto border-t pt-2 pr-1"},tt={class:"flex items-center justify-between gap-3 text-[11px] font-semibold"},ot={class:"font-mono text-muted-foreground"},at={class:"min-w-0 truncate"},st={key:0},nt={class:"shrink-0 font-mono"},rt={class:"min-w-0 truncate"},lt={key:0},it={class:"shrink-0 font-mono"},ct={class:"mt-4 flex items-center justify-between gap-4"},ut={class:"text-xs text-muted-foreground"},dt={class:"flex items-center gap-1 text-xs text-muted-foreground"},mt={class:"mt-4 grid grid-cols-1 gap-3 sm:grid-cols-3"},pt={class:"text-xs text-muted-foreground"},ft={class:"mt-1 flex items-center justify-between gap-2"},gt={class:"text-sm font-semibold"},yt={class:"text-xs text-muted-foreground"},ht=ue({name:"UsageHeatmapPanel",__name:"UsageHeatmapPanel",props:{heatMetric:{default:"tokens"},items:{},title:{}},setup(n){const r=n,h=["bg-zinc-100 dark:bg-zinc-800/80","bg-emerald-50 dark:bg-emerald-950/70","bg-emerald-100 dark:bg-emerald-900/70","bg-teal-100 dark:bg-teal-900/75","bg-teal-200 dark:bg-teal-800/80","bg-cyan-200 dark:bg-cyan-800/85","bg-cyan-300 dark:bg-cyan-700/90","bg-sky-300 dark:bg-sky-600/90","bg-sky-400 dark:bg-sky-500/95","bg-blue-500 dark:bg-blue-400"],y=[...h],C=[{key:"sun",label:"S",row:"1"},{key:"mon",label:"M",row:"2"},{key:"tue",label:"T",row:"3"},{key:"wed",label:"W",row:"4"},{key:"thu",label:"T",row:"5"},{key:"fri",label:"F",row:"6"},{key:"sat",label:"S",row:"7"}],U=l(()=>P(new Date)),Y=l(()=>{const e=P(U.value);return e.setDate(e.getDate()-364),e}),L=l(()=>`${N(Y.value)} - ${N(U.value)}`),b=l(()=>r.heatMetric==="cost"?"spend":"tokens"),A=l(()=>`${L.value} ${b.value} heatmap. Darker cells mean higher daily ${b.value}.`),_=l(()=>`Colored by daily ${b.value}`),G=l(()=>{const e=new Map(r.items.map(o=>[B(H(o.date)),o]));return Array.from({length:365},(o,p)=>{const a=P(Y.value);return a.setDate(a.getDate()+p),{date:a,usage:e.get(B(a))}})}),v=l(()=>{const e=Math.max(...G.value.map(o=>r.heatMetric==="cost"?o.usage?.costUSD??0:o.usage?.totalTokens??0));return G.value.map(o=>{const p=o.usage?.costUSD??0,a=o.usage?.totalTokens??0,x=r.heatMetric==="cost"?p:a;return{colorClass:h[K(x,e)],costLabel:z(p),costUSD:p,date:N(o.date),hasUsage:!!o.usage,modelRows:$(o.usage?.models??{}),platformSections:le(o.usage?.platforms),tokenLabel:D(a),totalTokens:a}})}),W=l(()=>{const e=Y.value.getDay(),o=(7-(e+v.value.length)%7)%7,p=Math.ceil((e+v.value.length+o)/7),a=Array.from({length:e},(M,w)=>({column:String(Math.floor(w/7)+2),colorClass:"bg-transparent",costLabel:"",date:"",isBlank:!0,key:`blank-${w}`,modelRows:[],platformSections:[],row:String(w%7+1),title:"No date",tooltipArrowClass:"",tooltipClass:"",tokenLabel:""})),x=v.value.map((M,w)=>({...M,column:String(Math.floor((e+w)/7)+2),isBlank:!1,key:M.date,row:String((e+w)%7+1),title:r.heatMetric==="cost"?`${M.date}: ${z(M.costUSD)} / ${D(M.totalTokens)} tokens`:`${M.date}: ${D(M.totalTokens)} tokens / ${z(M.costUSD)}`,...ie(Math.floor((e+w)/7),p)})),E=Array.from({length:o},(M,w)=>({column:String(Math.floor((e+v.value.length+w)/7)+2),colorClass:"bg-transparent",costLabel:"",date:"",isBlank:!0,key:`trailing-blank-${w}`,modelRows:[],platformSections:[],row:String((e+v.value.length+w)%7+1),title:"No date",tooltipArrowClass:"",tooltipClass:"",tokenLabel:""}));return[...a,...x,...E]}),te=l(()=>Math.ceil(W.value.length/7)),O=l(()=>({gridTemplateColumns:`max-content repeat(${te.value}, minmax(0, 1fr))`,gridTemplateRows:"repeat(7, minmax(0, 1fr))"})),S=l(()=>v.value.filter(e=>e.hasUsage).slice(-3)),X=l(()=>v.value.filter(e=>e.hasUsage).length),oe=l(()=>z(v.value.reduce((e,o)=>e+o.costUSD,0))),ae=l(()=>D(v.value.reduce((e,o)=>e+o.totalTokens,0))),J=l(()=>r.heatMetric==="cost"?[{key:"year-cost",label:"Year Spend",value:oe.value},{key:"year-tokens",label:"Year Tokens",value:ae.value},{key:"active-days",label:"Active Days",value:String(X.value)}]:[{key:"year-tokens",label:"Year Tokens",value:ae.value},{key:"year-cost",label:"Year Spend",value:oe.value},{key:"active-days",label:"Active Days",value:String(X.value)}]);function H(e){return new Date(e)}function P(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function B(e){const o=e.getFullYear(),p=`${e.getMonth()+1}`.padStart(2,"0"),a=`${e.getDate()}`.padStart(2,"0");return`${o}-${p}-${a}`}function N(e){return new Intl.DateTimeFormat("en-US",{day:"2-digit",month:"short",year:"numeric"}).format(e)}function K(e,o){return e<=0||o<=0?0:Math.min(9,Math.max(1,Math.ceil(e/o*9)))}function le(e){return Object.entries(e??{}).map(([o,p])=>({costLabel:z(p.costUSD),costUSD:p.costUSD,key:o,label:ye[o]?.label??o,models:$(p.models),totalTokens:p.totalTokens,tokenLabel:D(p.totalTokens)})).sort(se)}function $(e){return Object.entries(e).map(([o,p])=>({costLabel:z(p.costUSD),costUSD:p.costUSD,isFallback:p.isFallback,key:o,label:o,totalTokens:p.totalTokens,tokenLabel:D(p.totalTokens)})).sort(se)}function se(e,o){const p=r.heatMetric==="cost"?o.costUSD-e.costUSD:o.totalTokens-e.totalTokens;return p!==0?p:o.totalTokens!==e.totalTokens?o.totalTokens-e.totalTokens:o.costUSD!==e.costUSD?o.costUSD-e.costUSD:e.label.localeCompare(o.label)}function ie(e,o){return e<=1?{tooltipArrowClass:"left-3.5",tooltipClass:"left-0"}:e>=o-2?{tooltipArrowClass:"right-3.5",tooltipClass:"right-0"}:{tooltipArrowClass:"left-1/2 -translate-x-1/2",tooltipClass:"left-1/2 -translate-x-1/2"}}return(e,o)=>{const p=ce;return d(),Z(p,{description:A.value,icon:"lucide:calendar-days",title:r.title},{default:ee(()=>[s("div",ze,[(d(!0),f(j,null,R(J.value,a=>(d(),f("div",{key:a.key,class:"rounded-md border px-3 py-2"},[s("p",Fe,m(a.label),1),s("p",Ye,m(a.value),1)]))),128))]),s("div",Oe,[s("div",{class:"grid w-full gap-1",style:F(O.value)},[(d(),f(j,null,R(C,a=>s("span",{key:a.key,class:"flex items-center justify-end pr-1 text-[10px] text-muted-foreground",style:F({gridColumn:"1",gridRow:a.row})},m(a.label),5)),64)),(d(!0),f(j,null,R(W.value,a=>(d(),f("div",{key:a.key,class:V(["group relative aspect-square w-full max-w-3 justify-self-center rounded-sm border border-black/5 outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring/50 dark:border-white/10",[a.colorClass,{"border-transparent opacity-0":a.isBlank}]]),"aria-label":a.title,style:F({gridColumn:a.column,gridRow:a.row}),tabindex:a.isBlank?-1:0},[s("span",qe,m(a.title),1),a.isBlank?I("",!0):(d(),f("div",{key:0,class:V(["pointer-events-none absolute bottom-full z-30 mb-2 hidden w-64 max-w-[calc(100vw-2rem)] gap-1 rounded-md border bg-popover px-2.5 py-2 text-xs text-popover-foreground shadow-md group-hover:grid group-focus-visible:grid",a.tooltipClass]),role:"tooltip"},[s("span",Ve,m(a.date),1),r.heatMetric==="tokens"?(d(),f("span",We,[o[0]||(o[0]=s("span",null,"Tokens",-1)),s("span",Xe,m(a.tokenLabel),1)])):I("",!0),s("span",Je,[o[1]||(o[1]=s("span",null,"Cost",-1)),s("span",Ke,m(a.costLabel),1)]),r.heatMetric==="cost"?(d(),f("span",Qe,[o[2]||(o[2]=s("span",null,"Tokens",-1)),s("span",Ze,m(a.tokenLabel),1)])):I("",!0),a.platformSections.length>0||a.modelRows.length>0?(d(),f("div",et,[a.platformSections.length>0?(d(!0),f(j,{key:0},R(a.platformSections,x=>(d(),f("div",{key:x.key,class:"grid gap-1"},[s("div",tt,[s("span",null,m(x.label),1),s("span",ot,m(x.costLabel)+" / "+m(x.tokenLabel),1)]),(d(!0),f(j,null,R(x.models,E=>(d(),f("div",{key:E.key,class:"flex items-center justify-between gap-3 text-[11px] text-muted-foreground"},[s("span",at,[ge(m(E.label),1),E.isFallback?(d(),f("span",st," (fallback)")):I("",!0)]),s("span",nt,m(E.costLabel)+" / "+m(E.tokenLabel),1)]))),128))]))),128)):(d(!0),f(j,{key:1},R(a.modelRows,x=>(d(),f("div",{key:x.key,class:"flex items-center justify-between gap-3 text-[11px] text-muted-foreground"},[s("span",rt,[ge(m(x.label),1),x.isFallback?(d(),f("span",lt," (fallback)")):I("",!0)]),s("span",it,m(x.costLabel)+" / "+m(x.tokenLabel),1)]))),128))])):I("",!0),s("span",{class:V(["absolute top-full size-2 -translate-y-1/2 rotate-45 border-r border-b border-border bg-popover",a.tooltipArrowClass])},null,2)],2))],14,Ge))),128))],4),s("div",ct,[s("p",ut,m(_.value),1),s("div",dt,[o[3]||(o[3]=s("span",null,"Less",-1)),(d(),f(j,null,R(y,a=>s("span",{key:a,class:V(["size-3 rounded-[2px] border border-black/5 dark:border-white/10",a])},null,2)),64)),o[4]||(o[4]=s("span",null,"More",-1))])])]),s("div",mt,[(d(!0),f(j,null,R(S.value,a=>(d(),f("div",{key:a.date,class:"rounded-md border px-3 py-2"},[s("p",pt,m(a.date),1),s("div",ft,[s("span",gt,m(r.heatMetric==="cost"?("formatCurrency"in e?e.formatCurrency:i(z))(a.costUSD):("formatCompactNumber"in e?e.formatCompactNumber:i(D))(a.totalTokens)),1),s("span",yt,m(r.heatMetric==="cost"?("formatCompactNumber"in e?e.formatCompactNumber:i(D))(a.totalTokens):("formatCurrency"in e?e.formatCurrency:i(z))(a.costUSD)),1)])]))),128))])]),_:1},8,["description","title"])}}}),Dt=Object.assign(ht,{__name:"UsageHeatmapPanel"});function de(){return{dailyRows:[],dailyTokenUsage:[],monthlyModelUsage:[],monthlyRows:[],overviewCards:[],projectUsage:[],sessionRows:[],sessionUsage:[],todayTopModel:null,todayTopProject:null,todayTotalCost:0,todayTotalTokens:0,weeklyRows:[]}}function Mt(){return{hotProjects:[],modelUsage:[],overviewCards:[]}}function St(){return{dailyTokenUsage:[],efficiencyMetrics:[],todayHourlyUsage:[]}}function Ut(){return{sessionAnalysis:{items:[],totalSessions:0}}}function $t(){const n=de();return{dailyRows:n.dailyRows,dailyTokenUsage:n.dailyTokenUsage,monthlyModelUsage:n.monthlyModelUsage,overviewCards:n.overviewCards}}function jt(){const n=de();return{monthlyRows:n.monthlyRows,projectUsage:n.projectUsage,sessionRows:n.sessionRows,weeklyRows:n.weeklyRows}}function Rt(){return{sessionUsage:de().sessionUsage}}const bt=["day","week","month","session"],vt={agentSession:"/api/analysis/agent/session.json",agentToken:"/api/analysis/agent/token.json",cache:"/api/analysis/cache.json",dailyTokenUsage:"/api/analysis/token/daily.json",hotProject:"/api/analysis/hot-project.json",model:"/api/analysis/model.json",overviewCards:"/api/analysis/overview-cards.json",session:"/api/analysis/session.json",token:"/api/analysis/token.json",todayHourlyUsage:"/api/analysis/token/today-hourly.json"};async function Lt(){const[n,r,h]=await Promise.all([T("overviewCards"),T("model"),T("hotProject")]);return{hotProjects:h,modelUsage:r,overviewCards:n}}async function At(){const[n,r,h]=await Promise.all([T("cache"),T("dailyTokenUsage"),T("todayHourlyUsage")]);return{dailyTokenUsage:r,efficiencyMetrics:n.items,todayHourlyUsage:h}}function Pt(){return T("session")}async function Bt(n){const[r,h,y,C]=await Promise.all([T("overviewCards",{agent:n}),T("model",{agent:n}),T("token",{agent:n}),T("agentToken",{agent:n,type:"day"})]);return{dailyRows:C,dailyTokenUsage:y,monthlyModelUsage:h,overviewCards:r}}async function Nt(n){const[r,h]=await Promise.all([T("hotProject",{agent:n}),Promise.all(bt.filter(C=>C!=="day").map(async C=>[C,await T("agentToken",{agent:n,type:C})]))]),y=Object.fromEntries(h);return{monthlyRows:y.month,projectUsage:r,sessionRows:y.session,weeklyRows:y.week}}function Et(n){return T("agentSession",{agent:n}).then(r=>({sessionUsage:r}))}function T(n,r={}){return $fetch(vt[n],{query:kt(r)})}function kt(n){const r={};return n.agent&&(r.agent=ye[n.agent].slug),n.type&&(r.type=n.type),Object.keys(r).length>0?r:void 0}function It(n){const r=re(!1);he(n.coreStatus,async y=>{if(y!=="success"){r.value=!1,n.clearDeferred();return}r.value||(r.value=!0,await n.executeDeferred())},{immediate:!0});async function h(){r.value=!1,await n.refreshCore(),n.coreStatus.value==="success"&&(r.value=!0,await n.refreshDeferred())}return{refresh:h}}function Ht(n,r){const h=re(!1);he(n,U=>{U==="success"&&(h.value=!0)},{immediate:!0});const y=l(()=>!h.value&&n.value!=="error");return{errorText:l(()=>n.value!=="error"?"":r.value instanceof Error?r.value.message:typeof r.value=="string"?r.value:"Failed to load dashboard data."),showSkeleton:y}}export{Tt as _,Ct as a,Dt as b,$t as c,Nt as d,jt as e,Bt as f,Et as g,Rt as h,Ht as i,Lt as j,Mt as k,At as l,St as m,Pt as n,Ut as o,It as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as ee,k as te,B as pe,w as me,i as ve,b as ge,g as _e,h as be,l as q,m as ye,j as he}from"./DgMMKsPE.js";import{S as W,P as E,u as ae,a as Te,b as Ie,d as we}from"./C0GhHHgI.js";import{r as A,G as w,V as Ce,W as Se,e as C,k as ke,X as J,I as xe,Y as Me,Z as Ae,$ as H,n as se,o as h,g as T,w as n,b as d,i as t,h as x,j as oe,L as ne,a0 as Be,a1 as Fe,f as j,J as le,a2 as Re,D as $e,l as re,a3 as Ee,a4 as qe,y as V,z as O,s as N,a5 as Pe,a6 as Ve,a as Oe,c as P,t as I,F as U,x as Ne,E as G,d as _,H as Ue}from"./Jp5cgQZi.js";import{i as je,g as X}from"./DF2WsXH3.js";function ue(s){const e=je({dir:A("ltr")});return w(()=>s?.value||e.dir?.value||"ltr")}function Z(){const s=A(),e=w(()=>["#text","#comment"].includes(s.value?.$el.nodeName)?s.value?.$el.nextElementSibling:Ce(s));return{primitiveElement:s,currentElement:e}}const Q="data-reka-collection-item";function ie(s={}){const{key:e="",isProvider:l=!1}=s,o=`${e}CollectionProvider`;let i;if(l){const a=A(new Map);i={collectionRef:A(),itemMap:a},Me(o,i)}else i=Se(o);const b=(a=!1)=>{const u=i.collectionRef.value;if(!u)return[];const m=Array.from(u.querySelectorAll(`[${Q}]`)),g=Array.from(i.itemMap.value.values()).sort((M,B)=>m.indexOf(M.ref)-m.indexOf(B.ref));return a?g:g.filter(M=>M.ref.dataset.disabled!=="")},c=C({name:"CollectionSlot",inheritAttrs:!1,setup(a,{slots:u,attrs:m}){const{primitiveElement:k,currentElement:g}=Z();return xe(g,()=>{i.collectionRef.value=g.value}),()=>J(W,{ref:k,...m},u)}}),f=C({name:"CollectionItem",inheritAttrs:!1,props:{value:{validator:()=>!0}},setup(a,{slots:u,attrs:m}){const{primitiveElement:k,currentElement:g}=Z();return ke(M=>{if(g.value){const B=Ae(g.value);i.itemMap.value.set(B,{ref:g.value,value:a.value}),M(()=>i.itemMap.value.delete(B))}}),()=>J(W,{...m,[Q]:"",ref:k},u)}}),p=w(()=>Array.from(i.itemMap.value.values())),r=w(()=>i.itemMap.value.size);return{getItems:b,reactiveItems:p,itemMapSize:r,CollectionSlot:c,CollectionItem:f}}const De="rovingFocusGroup.onEntryFocus",ze={bubbles:!1,cancelable:!0},Ke={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Le(s,e){return e!=="rtl"?s:s==="ArrowLeft"?"ArrowRight":s==="ArrowRight"?"ArrowLeft":s}function Ge(s,e,l){const o=Le(s.key,l);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(o))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(o)))return Ke[o]}function de(s,e=!1){const l=X();for(const o of s)if(o===l||(o.focus({preventScroll:e}),X()!==l))return}function He(s,e){return s.map((l,o)=>s[(e+o)%s.length])}const[Ye,We]=oe("RovingFocusGroup");var Je=C({__name:"RovingFocusGroup",props:{orientation:{type:String,required:!1,default:void 0},dir:{type:String,required:!1},loop:{type:Boolean,required:!1,default:!1},currentTabStopId:{type:[String,null],required:!1},defaultCurrentTabStopId:{type:String,required:!1},preventScrollOnEntryFocus:{type:Boolean,required:!1,default:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:["entryFocus","update:currentTabStopId"],setup(s,{expose:e,emit:l}){const o=s,i=l,{loop:b,orientation:c,dir:f}=H(o),p=ue(f),r=se(o,"currentTabStopId",i,{defaultValue:o.defaultCurrentTabStopId,passive:o.currentTabStopId===void 0}),a=A(!1),u=A(!1),m=A(0),{getItems:k,CollectionSlot:g}=ie({isProvider:!0});function M(y){const F=!u.value;if(y.currentTarget&&y.target===y.currentTarget&&F&&!a.value){const R=new CustomEvent(De,ze);if(y.currentTarget.dispatchEvent(R),i("entryFocus",R),!R.defaultPrevented){const $=k().map(v=>v.ref).filter(v=>v.dataset.disabled!==""),D=$.find(v=>v.getAttribute("data-active")===""),z=$.find(v=>v.getAttribute("data-highlighted")===""),K=$.find(v=>v.id===r.value),L=[D,z,K,...$].filter(Boolean);de(L,o.preventScrollOnEntryFocus)}}u.value=!1}function B(){setTimeout(()=>{u.value=!1},1)}return e({getItems:k}),We({loop:b,dir:p,orientation:c,currentTabStopId:r,onItemFocus:y=>{r.value=y},onItemShiftTab:()=>{a.value=!0},onFocusableItemAdd:()=>{m.value++},onFocusableItemRemove:()=>{m.value--}}),(y,F)=>(h(),T(t(g),null,{default:n(()=>[d(t(E),{tabindex:a.value||m.value===0?-1:0,"data-orientation":t(c),as:y.as,"as-child":y.asChild,dir:t(p),style:{outline:"none"},onMousedown:F[0]||(F[0]=R=>u.value=!0),onMouseup:B,onFocus:M,onBlur:F[1]||(F[1]=R=>a.value=!1)},{default:n(()=>[x(y.$slots,"default")]),_:3},8,["tabindex","data-orientation","as","as-child","dir"])]),_:3}))}}),Xe=Je,Ze=C({__name:"RovingFocusItem",props:{tabStopId:{type:String,required:!1},focusable:{type:Boolean,required:!1,default:!0},active:{type:Boolean,required:!1},allowShiftKey:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"span"}},setup(s){const e=s,l=Ye(),o=ae(),i=w(()=>e.tabStopId||o),b=w(()=>l.currentTabStopId.value===i.value),{getItems:c,CollectionItem:f}=ie();ne(()=>{e.focusable&&l.onFocusableItemAdd()}),Be(()=>{e.focusable&&l.onFocusableItemRemove()});function p(r){if(r.key==="Tab"&&r.shiftKey){l.onItemShiftTab();return}if(r.target!==r.currentTarget)return;const a=Ge(r,l.orientation.value,l.dir.value);if(a!==void 0){if(r.metaKey||r.ctrlKey||r.altKey||!e.allowShiftKey&&r.shiftKey)return;r.preventDefault();let u=[...c().map(m=>m.ref).filter(m=>m.dataset.disabled!=="")];if(a==="last")u.reverse();else if(a==="prev"||a==="next"){a==="prev"&&u.reverse();const m=u.indexOf(r.currentTarget);u=l.loop.value?He(u,m+1):u.slice(m+1)}Fe(()=>de(u))}}return(r,a)=>(h(),T(t(f),null,{default:n(()=>[d(t(E),{tabindex:b.value?0:-1,"data-orientation":t(l).orientation.value,"data-active":r.active?"":void 0,"data-disabled":r.focusable?void 0:"",as:r.as,"as-child":r.asChild,onMousedown:a[0]||(a[0]=u=>{r.focusable?t(l).onItemFocus(i.value):u.preventDefault()}),onFocus:a[1]||(a[1]=u=>t(l).onItemFocus(i.value)),onKeydown:p},{default:n(()=>[x(r.$slots,"default")]),_:3},8,["tabindex","data-orientation","data-active","data-disabled","as","as-child"])]),_:3}))}}),Qe=Ze;const[Y,et]=oe("TabsRoot");var tt=C({__name:"TabsRoot",props:{defaultValue:{type:null,required:!1},orientation:{type:String,required:!1,default:"horizontal"},dir:{type:String,required:!1},activationMode:{type:String,required:!1,default:"automatic"},modelValue:{type:null,required:!1},unmountOnHide:{type:Boolean,required:!1,default:!0},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:["update:modelValue"],setup(s,{emit:e}){const l=s,o=e,{orientation:i,unmountOnHide:b,dir:c}=H(l),f=ue(c);j();const p=se(l,"modelValue",o,{defaultValue:l.defaultValue,passive:l.modelValue===void 0}),r=A(),a=le(new Set);return et({modelValue:p,changeModelValue:u=>{p.value=u},orientation:i,dir:f,unmountOnHide:b,activationMode:l.activationMode,baseId:ae(void 0,"reka-tabs"),tabsList:r,contentIds:a,registerContent:u=>{a.value=new Set([...a.value,u])},unregisterContent:u=>{const m=new Set(a.value);m.delete(u),a.value=m}}),(u,m)=>(h(),T(t(E),{dir:t(f),"data-orientation":t(i),"as-child":u.asChild,as:u.as},{default:n(()=>[x(u.$slots,"default",{modelValue:t(p)})]),_:3},8,["dir","data-orientation","as-child","as"]))}}),at=tt;function ce(s,e){return`${s}-trigger-${e}`}function fe(s,e){return`${s}-content-${e}`}var st=C({__name:"TabsContent",props:{value:{type:[String,Number],required:!0},forceMount:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(s){const e=s,{forwardRef:l}=j(),o=Y(),i=w(()=>ce(o.baseId,e.value)),b=w(()=>fe(o.baseId,e.value)),c=w(()=>e.value===o.modelValue.value),f=A(c.value);return ne(()=>{o.registerContent(e.value),requestAnimationFrame(()=>{f.value=!1})}),Re(()=>{o.unregisterContent(e.value)}),(p,r)=>(h(),T(t(Te),{present:p.forceMount||c.value,"force-mount":""},{default:n(({present:a})=>[d(t(E),{id:b.value,ref:t(l),"as-child":p.asChild,as:p.as,role:"tabpanel","data-state":c.value?"active":"inactive","data-orientation":t(o).orientation.value,"aria-labelledby":i.value,hidden:!a,tabindex:"0",style:$e({animationDuration:f.value?"0s":void 0})},{default:n(()=>[!t(o).unmountOnHide.value||a?x(p.$slots,"default",{key:0}):re("v-if",!0)]),_:2},1032,["id","as-child","as","data-state","data-orientation","aria-labelledby","hidden","style"])]),_:3},8,["present"]))}}),ot=st,nt=C({__name:"TabsList",props:{loop:{type:Boolean,required:!1,default:!0},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(s){const e=s,{loop:l}=H(e),{forwardRef:o,currentElement:i}=j(),b=Y();return b.tabsList=i,(c,f)=>(h(),T(t(Xe),{"as-child":"",orientation:t(b).orientation.value,dir:t(b).dir.value,loop:t(l)},{default:n(()=>[d(t(E),{ref:t(o),role:"tablist","as-child":c.asChild,as:c.as,"aria-orientation":t(b).orientation.value},{default:n(()=>[x(c.$slots,"default")]),_:3},8,["as-child","as","aria-orientation"])]),_:3},8,["orientation","dir","loop"]))}}),lt=nt,rt=C({__name:"TabsTrigger",props:{value:{type:[String,Number],required:!0},disabled:{type:Boolean,required:!1,default:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"button"}},setup(s){const e=s,{forwardRef:l}=j(),o=Y(),i=w(()=>ce(o.baseId,e.value)),b=w(()=>o.contentIds.value.has(e.value)?fe(o.baseId,e.value):void 0),c=w(()=>e.value===o.modelValue.value);return(f,p)=>(h(),T(t(Qe),{"as-child":"",focusable:!f.disabled,active:c.value},{default:n(()=>[d(t(E),{id:i.value,ref:t(l),role:"tab",type:f.as==="button"?"button":void 0,as:f.as,"as-child":f.asChild,"aria-selected":c.value?"true":"false","aria-controls":b.value,"data-state":c.value?"active":"inactive",disabled:f.disabled,"data-disabled":f.disabled?"":void 0,"data-orientation":t(o).orientation.value,onMousedown:p[0]||(p[0]=qe(r=>{!f.disabled&&r.ctrlKey===!1?t(o).changeModelValue(f.value):r.preventDefault()},["left"])),onKeydown:p[1]||(p[1]=Ee(r=>t(o).changeModelValue(f.value),["enter","space"])),onFocus:p[2]||(p[2]=()=>{const r=t(o).activationMode!=="manual";!c.value&&!f.disabled&&r&&t(o).changeModelValue(f.value)})},{default:n(()=>[x(f.$slots,"default")]),_:3},8,["id","type","as","as-child","aria-selected","aria-controls","data-state","disabled","data-disabled","data-orientation"])]),_:3},8,["focusable","active"]))}}),ut=rt;const it=C({__name:"Tabs",props:{defaultValue:{},orientation:{},dir:{},activationMode:{},modelValue:{},unmountOnHide:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},emits:["update:modelValue"],setup(s,{emit:e}){const l=s,o=e,i=V(l,"class"),b=Ie(i,o);return(c,f)=>(h(),T(t(at),O({"data-slot":"tabs"},t(b),{class:t(N)("flex flex-col gap-2",l.class)}),{default:n(p=>[x(c.$slots,"default",Pe(Ve(p)))]),_:3},16,["class"]))}}),dt=C({__name:"TabsContent",props:{value:{},forceMount:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(s){const e=s,l=V(e,"class");return(o,i)=>(h(),T(t(ot),O({"data-slot":"tabs-content",class:t(N)("flex-1 outline-none",e.class)},t(l)),{default:n(()=>[x(o.$slots,"default")]),_:3},16,["class"]))}}),ct=C({__name:"TabsList",props:{loop:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(s){const e=s,l=V(e,"class");return(o,i)=>(h(),T(t(lt),O({"data-slot":"tabs-list"},t(l),{class:t(N)("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",e.class)}),{default:n(()=>[x(o.$slots,"default")]),_:3},16,["class"]))}}),ft=C({__name:"TabsTrigger",props:{value:{},disabled:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(s){const e=s,l=V(e,"class"),o=we(l);return(i,b)=>(h(),T(t(ut),O({"data-slot":"tabs-trigger",class:t(N)("data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e.class)},t(o)),{default:n(()=>[x(i.$slots,"default")]),_:3},16,["class"]))}}),pt={class:"flex items-center justify-center py-10"},mt=C({__name:"TableEmpty",props:{class:{type:[Boolean,null,String,Object,Array]},colspan:{default:1}},setup(s){const e=s,l=V(e,"class");return(o,i)=>(h(),T(ee,null,{default:n(()=>[d(te,O({class:t(N)("p-4 whitespace-nowrap align-middle text-sm text-foreground",e.class)},t(l)),{default:n(()=>[Oe("div",pt,[x(o.$slots,"default")])]),_:3},16,["class"])]),_:3}))}}),vt={key:0,class:"text-xs text-destructive"},gt=C({name:"UsageAnalyticsTokenUsageTabsPanel",__name:"TokenUsageTabsPanel",props:{dailyItems:{},errorMessage:{},loading:{type:Boolean},weeklyItems:{},monthlyItems:{},sessionItems:{},pageSize:{default:10},productName:{default:"Product"}},setup(s){const e=s,l=le("day"),o=Ue({day:1,month:1,session:1,week:1}),i=[{heading:"Date",label:"Day",value:"day"},{heading:"Week",label:"Week",value:"week"},{heading:"Month",label:"Month",value:"month"},{heading:"Session ID",label:"Session",value:"session"}],b=w(()=>({day:e.dailyItems,month:e.monthlyItems,session:e.sessionItems,week:e.weeklyItems})),c=w(()=>Object.fromEntries(i.map(r=>{const a=b.value[r.value],u=Math.max(1,Math.ceil(a.length/e.pageSize)),m=Math.min(o[r.value],u),k=(m-1)*e.pageSize;return[r.value,{items:a,page:m,pageCount:u,paginatedItems:a.slice(k,k+e.pageSize)}]})));function f(r,a){const u=c.value[r].pageCount;o[r]=Math.min(u,Math.max(1,a))}function p(r){return r.length>0?r.join(", "):"None"}return(r,a)=>{const u=me,m=ft,k=ct,g=_e,M=ee,B=ge,y=te,F=mt,R=be,$=ve,D=he,z=dt,K=it,L=pe;return h(),T(L,{description:`Browse ${s.productName} token consumption by day, week, month, or session.`,icon:"lucide:table-2",title:`${s.productName} Token Usage`},{default:n(()=>[s.errorMessage?(h(),P("p",vt,I(s.errorMessage),1)):s.loading?(h(),P(U,{key:1},[d(u,{class:"h-10 w-64 rounded-md"}),d(u,{class:"mt-4 h-72 w-full rounded-md"})],64)):(h(),T(K,{key:2,modelValue:t(l),"onUpdate:modelValue":a[0]||(a[0]=v=>Ne(l)?l.value=v:null)},{default:n(()=>[d(k,{class:"grid w-full grid-cols-4 sm:w-fit"},{default:n(()=>[(h(),P(U,null,G(i,v=>d(m,{key:v.value,value:v.value},{default:n(()=>[_(I(v.label),1)]),_:2},1032,["value"])),64))]),_:1}),(h(),P(U,null,G(i,v=>d(z,{key:v.value,class:"mt-4",value:v.value},{default:n(()=>[d($,null,{default:n(()=>[d(B,null,{default:n(()=>[d(M,null,{default:n(()=>[d(g,null,{default:n(()=>[_(I(v.heading),1)]),_:2},1024),d(g,null,{default:n(()=>[...a[1]||(a[1]=[_("Models",-1)])]),_:1}),d(g,null,{default:n(()=>[...a[2]||(a[2]=[_("Projects",-1)])]),_:1}),d(g,{class:"text-right"},{default:n(()=>[...a[3]||(a[3]=[_(" Sessions ",-1)])]),_:1}),d(g,{class:"text-right"},{default:n(()=>[...a[4]||(a[4]=[_(" Input ",-1)])]),_:1}),d(g,{class:"text-right"},{default:n(()=>[...a[5]||(a[5]=[_(" Output ",-1)])]),_:1}),d(g,{class:"text-right"},{default:n(()=>[...a[6]||(a[6]=[_(" Reasoning ",-1)])]),_:1}),d(g,{class:"text-right"},{default:n(()=>[...a[7]||(a[7]=[_(" Cache Read ",-1)])]),_:1}),d(g,{class:"text-right"},{default:n(()=>[...a[8]||(a[8]=[_(" Total Tokens ",-1)])]),_:1}),d(g,{class:"text-right"},{default:n(()=>[...a[9]||(a[9]=[_(" Cost ",-1)])]),_:1})]),_:2},1024)]),_:2},1024),d(R,null,{default:n(()=>[(h(!0),P(U,null,G(t(c)[v.value].paginatedItems,S=>(h(),T(M,{key:S.id},{default:n(()=>[d(y,{class:"max-w-72 truncate font-medium"},{default:n(()=>[_(I(S.label),1)]),_:2},1024),d(y,null,{default:n(()=>[_(I(p(S.models)),1)]),_:2},1024),d(y,{class:"max-w-56 truncate"},{default:n(()=>[_(I(p(S.projects)),1)]),_:2},1024),d(y,{class:"text-right tabular-nums"},{default:n(()=>[_(I(S.sessionCount),1)]),_:2},1024),d(y,{class:"text-right tabular-nums"},{default:n(()=>[_(I(t(q)(S.inputTokens)),1)]),_:2},1024),d(y,{class:"text-right tabular-nums"},{default:n(()=>[_(I(t(q)(S.outputTokens)),1)]),_:2},1024),d(y,{class:"text-right tabular-nums"},{default:n(()=>[_(I(t(q)(S.reasoningOutputTokens)),1)]),_:2},1024),d(y,{class:"text-right tabular-nums"},{default:n(()=>[_(I(t(q)(S.cachedInputTokens)),1)]),_:2},1024),d(y,{class:"text-right tabular-nums"},{default:n(()=>[_(I(t(q)(S.totalTokens)),1)]),_:2},1024),d(y,{class:"text-right tabular-nums"},{default:n(()=>[_(I(("formatCurrency"in r?r.formatCurrency:t(ye))(S.costUSD)),1)]),_:2},1024)]),_:2},1024))),128)),t(c)[v.value].items.length===0?(h(),T(F,{key:0,colspan:10},{default:n(()=>[_(" No "+I(s.productName)+" token usage found. ",1)]),_:1})):re("",!0)]),_:2},1024)]),_:2},1024),d(D,{page:t(c)[v.value].page,"page-count":t(c)[v.value].pageCount,"page-size":s.pageSize,total:t(c)[v.value].items.length,"onUpdate:page":S=>f(v.value,S)},null,8,["page","page-count","page-size","total","onUpdate:page"])]),_:2},1032,["value"])),64))]),_:1},8,["modelValue"]))]),_:1},8,["description","title"])}}}),Tt=Object.assign(gt,{__name:"UsageAnalyticsTokenUsageTabsPanel"});export{mt as _,ct as a,ft as b,dt as c,Tt as d,it as e};
|