tokmon 0.22.3 → 0.22.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -129,6 +129,7 @@ The dashboard is a prebuilt static bundle shipped in the package — no build st
129
129
  | scroll / `↑` `↓` / `[` `]` | (Dashboard) move between pages when paginated |
130
130
  | `a` `A` | Cycle account focus forward / back |
131
131
  | `0`–`9` | Jump to an account focus slot |
132
+ | `p` | Toggle privacy mode (configurable in settings) |
132
133
  | `w` `W` | Toggle the web dashboard (opens in your browser) |
133
134
  | `s` | Open settings |
134
135
  | `q` | Quit |
@@ -137,7 +138,7 @@ The dashboard is a prebuilt static bundle shipped in the package — no build st
137
138
 
138
139
  | Key | Action |
139
140
  |-----|--------|
140
- | `p` `P` | Cycle provider forward / back |
141
+ | `P` | Cycle provider back |
141
142
  | `/` | Search (Esc clears) |
142
143
  | `o` | Cycle sort |
143
144
  | `d` `w` `m` | Daily / Weekly / Monthly *(Claude/Codex)* |
@@ -169,6 +170,8 @@ Press `s` to open.
169
170
  - **Refresh interval** — dashboard poll rate (default: 2s)
170
171
  - **Billing poll** — rate-limit / spend API poll rate (default: 5m, min 1m to avoid rate limiting)
171
172
  - **Clear screen** — clears the terminal on launch (like `watch`)
173
+ - **Privacy mode** — hides email addresses by default
174
+ - **Privacy key** — one-key dashboard toggle for privacy mode (default: `p`)
172
175
  - **Timezone** — IANA timezone, or `System`
173
176
  - **Dashboard layout** — `grid` (all providers at once) or `single` (one at a time)
174
177
  - **Default focus** — start on `all`, or remember your `last` focused account
@@ -19,7 +19,7 @@ import {
19
19
  systemTimezone,
20
20
  time,
21
21
  tokens
22
- } from "./chunk-LXHXKELJ.js";
22
+ } from "./chunk-QKF3PKYX.js";
23
23
  import {
24
24
  COLOR_PALETTE,
25
25
  DEFAULTS,
@@ -34,7 +34,7 @@ import {
34
34
  sanitizeTyped,
35
35
  saveConfigSync,
36
36
  snapshotCacheFile
37
- } from "./chunk-OV35PDO6.js";
37
+ } from "./chunk-QTHCHB7S.js";
38
38
  import {
39
39
  glyphs
40
40
  } from "./chunk-RF4GGQGM.js";
@@ -564,7 +564,7 @@ import { Box as Box4, Text as Text4 } from "ink";
564
564
  import { memo as memo3 } from "react";
565
565
  import { Box as Box3, Text as Text3 } from "ink";
566
566
  import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
567
- var GENERAL_ROWS = 7;
567
+ var GENERAL_ROWS = 8;
568
568
  var SETTINGS_TABS = ["general", "providers", "accounts"];
569
569
  var SETTINGS_TAB_LABELS = {
570
570
  general: "General",
@@ -627,16 +627,17 @@ var SettingsView = memo3(function SettingsView2({
627
627
  ] }),
628
628
  /* @__PURE__ */ jsx3(Row, { cursor, idx: 2, label: "Clear screen", children: /* @__PURE__ */ jsx3(Text3, { bold: true, color: config.clearScreen ? "green" : "red", children: config.clearScreen ? "on" : "off" }) }),
629
629
  /* @__PURE__ */ jsx3(Row, { cursor, idx: 3, label: "Privacy mode", children: /* @__PURE__ */ jsx3(Text3, { bold: true, color: config.privacyMode ? "green" : "red", children: config.privacyMode ? "on" : "off" }) }),
630
- /* @__PURE__ */ jsx3(Row, { cursor, idx: 4, label: "Timezone", children: editingTz ? /* @__PURE__ */ jsxs3(Fragment2, { children: [
630
+ /* @__PURE__ */ jsx3(Row, { cursor, idx: 4, label: "Privacy key", children: /* @__PURE__ */ jsx3(Text3, { bold: true, color: "yellow", children: config.privacyToggleKey === " " ? "space" : config.privacyToggleKey }) }),
631
+ /* @__PURE__ */ jsx3(Row, { cursor, idx: 5, label: "Timezone", children: editingTz ? /* @__PURE__ */ jsxs3(Fragment2, { children: [
631
632
  /* @__PURE__ */ jsx3(Text3, { dimColor: true, children: "[" }),
632
633
  /* @__PURE__ */ jsx3(CaretText, { value: tzEdit ?? "", caret: tzCaret, color: "cyan" }),
633
634
  /* @__PURE__ */ jsx3(Text3, { dimColor: true, children: "]" })
634
635
  ] }) : /* @__PURE__ */ jsx3(Text3, { bold: true, color: "yellow", children: tzDisplay }) }),
635
- cursor === 4 && tzError && /* @__PURE__ */ jsxs3(Text3, { color: "red", children: [
636
+ cursor === 5 && tzError && /* @__PURE__ */ jsxs3(Text3, { color: "red", children: [
636
637
  " ",
637
638
  tzError
638
639
  ] }),
639
- /* @__PURE__ */ jsxs3(Row, { cursor, idx: 5, label: "Dashboard", children: [
640
+ /* @__PURE__ */ jsxs3(Row, { cursor, idx: 6, label: "Dashboard", children: [
640
641
  /* @__PURE__ */ jsxs3(Text3, { dimColor: true, children: [
641
642
  glyphs().caretL,
642
643
  " "
@@ -647,7 +648,7 @@ var SettingsView = memo3(function SettingsView2({
647
648
  glyphs().caretR
648
649
  ] })
649
650
  ] }),
650
- /* @__PURE__ */ jsxs3(Row, { cursor, idx: 6, label: "Default focus", children: [
651
+ /* @__PURE__ */ jsxs3(Row, { cursor, idx: 7, label: "Default focus", children: [
651
652
  /* @__PURE__ */ jsxs3(Text3, { dimColor: true, children: [
652
653
  glyphs().caretL,
653
654
  " "
@@ -2480,6 +2481,14 @@ function handleKey(input, key, ctx) {
2480
2481
  return;
2481
2482
  }
2482
2483
  if (settingsCursor === 4) {
2484
+ if (isPrintable(input, key)) {
2485
+ const clean = sanitizeTyped(input);
2486
+ if (clean.length === 1) updateConfig((c) => ({ ...c, privacyToggleKey: clean }));
2487
+ }
2488
+ if (key.backspace || key.delete) updateConfig((c) => ({ ...c, privacyToggleKey: "p" }));
2489
+ return;
2490
+ }
2491
+ if (settingsCursor === 5) {
2483
2492
  if (key.return) {
2484
2493
  const init = cfg.timezone ?? "";
2485
2494
  setTzEdit(init);
@@ -2489,11 +2498,11 @@ function handleKey(input, key, ctx) {
2489
2498
  if (key.leftArrow || key.rightArrow) updateConfig((c) => ({ ...c, timezone: c.timezone === null ? systemTimezone() : null }));
2490
2499
  return;
2491
2500
  }
2492
- if (settingsCursor === 5 && (key.leftArrow || key.rightArrow || key.return)) {
2501
+ if (settingsCursor === 6 && (key.leftArrow || key.rightArrow || key.return)) {
2493
2502
  updateConfig((c) => ({ ...c, dashboardLayout: c.dashboardLayout === "grid" ? "single" : "grid" }));
2494
2503
  return;
2495
2504
  }
2496
- if (settingsCursor === 6 && (key.leftArrow || key.rightArrow || key.return)) {
2505
+ if (settingsCursor === 7 && (key.leftArrow || key.rightArrow || key.return)) {
2497
2506
  updateConfig((c) => ({ ...c, defaultFocus: c.defaultFocus === "all" ? "last" : "all" }));
2498
2507
  return;
2499
2508
  }
@@ -2531,6 +2540,10 @@ function handleKey(input, key, ctx) {
2531
2540
  }
2532
2541
  return;
2533
2542
  }
2543
+ if (input === cfg.privacyToggleKey) {
2544
+ updateConfig((c) => ({ ...c, privacyMode: !c.privacyMode }));
2545
+ return;
2546
+ }
2534
2547
  if (input === "s") {
2535
2548
  setSettingsTab("general");
2536
2549
  setShowSettings(true);
@@ -3413,7 +3426,7 @@ function App({ interval: cliInterval, initialConfig, baseUrl = null, wsToken = n
3413
3426
  if (webStartingRef.current) return;
3414
3427
  webStartingRef.current = true;
3415
3428
  try {
3416
- const { startWebServer } = await import("./server-RTH46XRR.js");
3429
+ const { startWebServer } = await import("./server-W3JHUDAN.js");
3417
3430
  const ctrl = await startWebServer({ config: cfg, log: false });
3418
3431
  webRef.current = ctrl;
3419
3432
  openUrl(ctrl.url);
@@ -10,7 +10,7 @@ import {
10
10
  fetchPeak,
11
11
  namedHex,
12
12
  resolveTimezone
13
- } from "./chunk-LXHXKELJ.js";
13
+ } from "./chunk-QKF3PKYX.js";
14
14
  import {
15
15
  cacheDir,
16
16
  expandHome,
@@ -18,7 +18,7 @@ import {
18
18
  normalizeConfig,
19
19
  saveConfig,
20
20
  snapshotCacheFile
21
- } from "./chunk-OV35PDO6.js";
21
+ } from "./chunk-QTHCHB7S.js";
22
22
 
23
23
  // src/web/server.ts
24
24
  import { createServer } from "http";
@@ -6,7 +6,7 @@ import {
6
6
  expandHome,
7
7
  isValidTimezone,
8
8
  slugify
9
- } from "./chunk-OV35PDO6.js";
9
+ } from "./chunk-QTHCHB7S.js";
10
10
 
11
11
  // src/providers/usage-core.ts
12
12
  import { readFile, writeFile, rename, mkdir, readdir, unlink } from "fs/promises";
@@ -15,6 +15,7 @@ var DEFAULTS = {
15
15
  billingInterval: 5,
16
16
  clearScreen: true,
17
17
  privacyMode: true,
18
+ privacyToggleKey: "p",
18
19
  timezone: null,
19
20
  accounts: [],
20
21
  activeAccountId: null,
@@ -201,6 +202,7 @@ function repairConfig(input) {
201
202
  billingInterval: clampNum(parsed.billingInterval, DEFAULTS.billingInterval, 1),
202
203
  clearScreen: typeof parsed.clearScreen === "boolean" ? parsed.clearScreen : DEFAULTS.clearScreen,
203
204
  privacyMode: typeof parsed.privacyMode === "boolean" ? parsed.privacyMode : DEFAULTS.privacyMode,
205
+ privacyToggleKey: typeof parsed.privacyToggleKey === "string" && parsed.privacyToggleKey.length === 1 ? parsed.privacyToggleKey : DEFAULTS.privacyToggleKey,
204
206
  timezone,
205
207
  accounts,
206
208
  activeAccountId,
package/dist/cli.js CHANGED
@@ -14,12 +14,12 @@ process.emitWarning = ((warning, ...rest) => {
14
14
  var args = process.argv.slice(2);
15
15
  var subcommand = args[0]?.toLowerCase();
16
16
  if (subcommand === "__daemon") {
17
- const { runDaemon } = await import("./daemon-JQFS7EMA.js");
17
+ const { runDaemon } = await import("./daemon-FHPB5HDQ.js");
18
18
  await runDaemon(args.slice(1), { foreground: false });
19
19
  process.exit(typeof process.exitCode === "number" ? process.exitCode : 0);
20
20
  }
21
21
  if (subcommand === "serve" || subcommand === "web") {
22
- const { runDaemon } = await import("./daemon-JQFS7EMA.js");
22
+ const { runDaemon } = await import("./daemon-FHPB5HDQ.js");
23
23
  await runDaemon(args.slice(1), { foreground: true });
24
24
  process.exit(typeof process.exitCode === "number" ? process.exitCode : 0);
25
25
  }
@@ -54,7 +54,7 @@ for (let i = 0; i < args.length; i++) {
54
54
  process.exit(0);
55
55
  }
56
56
  }
57
- var { loadConfig } = await import("./config-QBY7K5V5.js");
57
+ var { loadConfig } = await import("./config-64N7KBZ7.js");
58
58
  var { resolveGlyphs, setGlyphs } = await import("./glyphs-NKCSZLGO.js");
59
59
  var { attachOrSpawn } = await import("./daemon-handle-HLSKLMWU.js");
60
60
  var config = await loadConfig();
@@ -68,5 +68,5 @@ setGlyphs(resolveGlyphs({
68
68
  }));
69
69
  var daemon = await attachOrSpawn();
70
70
  var mode = daemon.kind === "spawned" ? "connected" : "degraded";
71
- var { bootstrapInk } = await import("./bootstrap-ink-KFQR6QK3.js");
71
+ var { bootstrapInk } = await import("./bootstrap-ink-XN72OM2A.js");
72
72
  await bootstrapInk({ interval, config, daemon, mode });
@@ -24,7 +24,7 @@ import {
24
24
  saveConfigSync,
25
25
  slugify,
26
26
  snapshotCacheFile
27
- } from "./chunk-OV35PDO6.js";
27
+ } from "./chunk-QTHCHB7S.js";
28
28
  export {
29
29
  ACCENT_COLORS,
30
30
  COLOR_PALETTE,
@@ -2,14 +2,14 @@
2
2
  import {
3
3
  appVersion,
4
4
  startWebServer
5
- } from "./chunk-3PT52HWA.js";
5
+ } from "./chunk-LIWHVHDE.js";
6
6
  import {
7
7
  flushDisk
8
- } from "./chunk-LXHXKELJ.js";
8
+ } from "./chunk-QKF3PKYX.js";
9
9
  import {
10
10
  cacheDir,
11
11
  loadConfig
12
- } from "./chunk-OV35PDO6.js";
12
+ } from "./chunk-QTHCHB7S.js";
13
13
 
14
14
  // src/web/open.ts
15
15
  import { spawn } from "child_process";
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ startWebServer
4
+ } from "./chunk-LIWHVHDE.js";
5
+ import "./chunk-QKF3PKYX.js";
6
+ import "./chunk-QTHCHB7S.js";
7
+ export {
8
+ startWebServer
9
+ };
@@ -1,4 +1,4 @@
1
- import{i as I,k as h,l as k,n as Qe,o as xt,p as Ye,q as Je,t as At,v as C,w as Oe,x as S,y as _,z as et,B as Pe,D as tt,r as J,F as kt,H as Ot,I as z,J as F,K as Pt,M as jt,N as _t,O as De,Q as wt,U as M,V as je,W as Tt,Z as St,_ as ae,$ as Et,a0 as _e,a1 as Rt,a2 as re,a3 as Be,g as nt,X as we,Y as Te,a4 as Se,f as It,a5 as Nt,u as Ee,a6 as rt,j as u,P as fe,E as pe,C as Re,R as Ie,a as it,G as at,d as ot,c as se,a7 as ee,T as st,h as G,a8 as W,a9 as ct,aa as Lt,ab as ie,s as Ne}from"./index-DqO2pHzm.js";var $t=["points","className","baseLinePoints","connectNulls"];function V(){return V=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(n[t]=r[t])}return n},V.apply(this,arguments)}function Ct(n,e){if(n==null)return{};var r=Dt(n,e),t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(n);for(i=0;i<a.length;i++)t=a[i],!(e.indexOf(t)>=0)&&Object.prototype.propertyIsEnumerable.call(n,t)&&(r[t]=n[t])}return r}function Dt(n,e){if(n==null)return{};var r={};for(var t in n)if(Object.prototype.hasOwnProperty.call(n,t)){if(e.indexOf(t)>=0)continue;r[t]=n[t]}return r}function Ke(n){return Mt(n)||Ft(n)||Kt(n)||Bt()}function Bt(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
1
+ import{i as I,k as h,l as k,n as Qe,o as xt,p as Ye,q as Je,t as At,v as C,w as Oe,x as S,y as _,z as et,B as Pe,D as tt,r as J,F as kt,H as Ot,I as z,J as F,K as Pt,M as jt,N as _t,O as De,Q as wt,U as M,V as je,W as Tt,Z as St,_ as ae,$ as Et,a0 as _e,a1 as Rt,a2 as re,a3 as Be,g as nt,X as we,Y as Te,a4 as Se,f as It,a5 as Nt,u as Ee,a6 as rt,j as u,P as fe,E as pe,C as Re,R as Ie,a as it,G as at,d as ot,c as se,a7 as ee,T as st,h as G,a8 as W,a9 as ct,aa as Lt,ab as ie,s as Ne}from"./index-sJqh08RC.js";var $t=["points","className","baseLinePoints","connectNulls"];function V(){return V=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(n[t]=r[t])}return n},V.apply(this,arguments)}function Ct(n,e){if(n==null)return{};var r=Dt(n,e),t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(n);for(i=0;i<a.length;i++)t=a[i],!(e.indexOf(t)>=0)&&Object.prototype.propertyIsEnumerable.call(n,t)&&(r[t]=n[t])}return r}function Dt(n,e){if(n==null)return{};var r={};for(var t in n)if(Object.prototype.hasOwnProperty.call(n,t)){if(e.indexOf(t)>=0)continue;r[t]=n[t]}return r}function Ke(n){return Mt(n)||Ft(n)||Kt(n)||Bt()}function Bt(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Kt(n,e){if(n){if(typeof n=="string")return be(n,e);var r=Object.prototype.toString.call(n).slice(8,-1);if(r==="Object"&&n.constructor&&(r=n.constructor.name),r==="Map"||r==="Set")return Array.from(n);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return be(n,e)}}function Ft(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function Mt(n){if(Array.isArray(n))return be(n)}function be(n,e){(e==null||e>n.length)&&(e=n.length);for(var r=0,t=new Array(e);r<e;r++)t[r]=n[r];return t}var Fe=function(e){return e&&e.x===+e.x&&e.y===+e.y},Vt=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],r=[[]];return e.forEach(function(t){Fe(t)?r[r.length-1].push(t):r[r.length-1].length>0&&r.push([])}),Fe(e[0])&&r[r.length-1].push(e[0]),r[r.length-1].length<=0&&(r=r.slice(0,-1)),r},Q=function(e,r){var t=Vt(e);r&&(t=[t.reduce(function(a,o){return[].concat(Ke(a),Ke(o))},[])]);var i=t.map(function(a){return a.reduce(function(o,c,f){return"".concat(o).concat(f===0?"M":"L").concat(c.x,",").concat(c.y)},"")}).join("");return t.length===1?"".concat(i,"Z"):i},qt=function(e,r,t){var i=Q(e,t);return"".concat(i.slice(-1)==="Z"?i.slice(0,-1):i,"L").concat(Q(r.reverse(),t).slice(1))},zt=function(e){var r=e.points,t=e.className,i=e.baseLinePoints,a=e.connectNulls,o=Ct(e,$t);if(!r||!r.length)return null;var c=I("recharts-polygon",t);if(i&&i.length){var f=o.stroke&&o.stroke!=="none",s=qt(r,i,a);return h.createElement("g",{className:c},h.createElement("path",V({},k(o,!0),{fill:s.slice(-1)==="Z"?o.fill:"none",stroke:"none",d:s})),f?h.createElement("path",V({},k(o,!0),{fill:"none",d:Q(r,a)})):null,f?h.createElement("path",V({},k(o,!0),{fill:"none",d:Q(i,a)})):null)}var p=Q(r,a);return h.createElement("path",V({},k(o,!0),{fill:p.slice(-1)==="Z"?o.fill:"none",className:c,d:p}))},ye,Me;function Wt(){if(Me)return ye;Me=1;var n=Qe(),e=xt(),r=Ye();function t(i,a){return i&&i.length?n(i,r(a,2),e):void 0}return ye=t,ye}var Gt=Wt();const Ht=Je(Gt);var ge,Ve;function Zt(){if(Ve)return ge;Ve=1;var n=Qe(),e=Ye(),r=At();function t(i,a){return i&&i.length?n(i,e(a,2),r):void 0}return ge=t,ge}var Ut=Zt();const Xt=Je(Ut);var Qt=["cx","cy","angle","ticks","axisLine"],Yt=["ticks","tick","angle","tickFormatter","stroke"];function H(n){"@babel/helpers - typeof";return H=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},H(n)}function Y(){return Y=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(n[t]=r[t])}return n},Y.apply(this,arguments)}function qe(n,e){var r=Object.keys(n);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(n);e&&(t=t.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),r.push.apply(r,t)}return r}function L(n){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?qe(Object(r),!0).forEach(function(t){de(n,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):qe(Object(r)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(r,t))})}return n}function ze(n,e){if(n==null)return{};var r=Jt(n,e),t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(n);for(i=0;i<a.length;i++)t=a[i],!(e.indexOf(t)>=0)&&Object.prototype.propertyIsEnumerable.call(n,t)&&(r[t]=n[t])}return r}function Jt(n,e){if(n==null)return{};var r={};for(var t in n)if(Object.prototype.hasOwnProperty.call(n,t)){if(e.indexOf(t)>=0)continue;r[t]=n[t]}return r}function en(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function We(n,e){for(var r=0;r<e.length;r++){var t=e[r];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(n,ut(t.key),t)}}function tn(n,e,r){return e&&We(n.prototype,e),r&&We(n,r),Object.defineProperty(n,"prototype",{writable:!1}),n}function nn(n,e,r){return e=ce(e),rn(n,lt()?Reflect.construct(e,r||[],ce(n).constructor):e.apply(n,r))}function rn(n,e){if(e&&(H(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return an(n)}function an(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function lt(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(lt=function(){return!!n})()}function ce(n){return ce=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},ce(n)}function on(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&xe(n,e)}function xe(n,e){return xe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},xe(n,e)}function de(n,e,r){return e=ut(e),e in n?Object.defineProperty(n,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[e]=r,n}function ut(n){var e=sn(n,"string");return H(e)=="symbol"?e:e+""}function sn(n,e){if(H(n)!="object"||!n)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var t=r.call(n,e);if(H(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}var me=(function(n){function e(){return en(this,e),nn(this,e,arguments)}return on(e,n),tn(e,[{key:"getTickValueCoord",value:function(t){var i=t.coordinate,a=this.props,o=a.angle,c=a.cx,f=a.cy;return S(c,f,i,o)}},{key:"getTickTextAnchor",value:function(){var t=this.props.orientation,i;switch(t){case"left":i="end";break;case"right":i="start";break;default:i="middle";break}return i}},{key:"getViewBox",value:function(){var t=this.props,i=t.cx,a=t.cy,o=t.angle,c=t.ticks,f=Ht(c,function(p){return p.coordinate||0}),s=Xt(c,function(p){return p.coordinate||0});return{cx:i,cy:a,startAngle:o,endAngle:o,innerRadius:s.coordinate||0,outerRadius:f.coordinate||0}}},{key:"renderAxisLine",value:function(){var t=this.props,i=t.cx,a=t.cy,o=t.angle,c=t.ticks,f=t.axisLine,s=ze(t,Qt),p=c.reduce(function(m,l){return[Math.min(m[0],l.coordinate),Math.max(m[1],l.coordinate)]},[1/0,-1/0]),d=S(i,a,p[0],o),v=S(i,a,p[1],o),A=L(L(L({},k(s,!1)),{},{fill:"none"},k(f,!1)),{},{x1:d.x,y1:d.y,x2:v.x,y2:v.y});return h.createElement("line",Y({className:"recharts-polar-radius-axis-line"},A))}},{key:"renderTicks",value:function(){var t=this,i=this.props,a=i.ticks,o=i.tick,c=i.angle,f=i.tickFormatter,s=i.stroke,p=ze(i,Yt),d=this.getTickTextAnchor(),v=k(p,!1),A=k(o,!1),m=a.map(function(l,g){var b=t.getTickValueCoord(l),x=L(L(L(L({textAnchor:d,transform:"rotate(".concat(90-c,", ").concat(b.x,", ").concat(b.y,")")},v),{},{stroke:"none",fill:s},A),{},{index:g},b),{},{payload:l});return h.createElement(_,Y({className:I("recharts-polar-radius-axis-tick",et(o)),key:"tick-".concat(l.coordinate)},Pe(t.props,l,g)),e.renderTickItem(o,x,f?f(l.value,g):l.value))});return h.createElement(_,{className:"recharts-polar-radius-axis-ticks"},m)}},{key:"render",value:function(){var t=this.props,i=t.ticks,a=t.axisLine,o=t.tick;return!i||!i.length?null:h.createElement(_,{className:I("recharts-polar-radius-axis",this.props.className)},a&&this.renderAxisLine(),o&&this.renderTicks(),tt.renderCallByParent(this.props,this.getViewBox()))}}],[{key:"renderTickItem",value:function(t,i,a){var o;return h.isValidElement(t)?o=h.cloneElement(t,i):C(t)?o=t(i):o=h.createElement(Oe,Y({},i,{className:"recharts-polar-radius-axis-tick-value"}),a),o}}])})(J.PureComponent);de(me,"displayName","PolarRadiusAxis");de(me,"axisType","radiusAxis");de(me,"defaultProps",{type:"number",radiusAxisId:0,cx:0,cy:0,angle:0,orientation:"right",stroke:"#ccc",axisLine:!0,tick:!0,tickCount:5,allowDataOverflow:!1,scale:"auto",allowDuplicatedCategory:!0});function Z(n){"@babel/helpers - typeof";return Z=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Z(n)}function D(){return D=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(n[t]=r[t])}return n},D.apply(this,arguments)}function Ge(n,e){var r=Object.keys(n);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(n);e&&(t=t.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),r.push.apply(r,t)}return r}function $(n){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Ge(Object(r),!0).forEach(function(t){ve(n,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):Ge(Object(r)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(r,t))})}return n}function cn(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function He(n,e){for(var r=0;r<e.length;r++){var t=e[r];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(n,pt(t.key),t)}}function ln(n,e,r){return e&&He(n.prototype,e),r&&He(n,r),Object.defineProperty(n,"prototype",{writable:!1}),n}function un(n,e,r){return e=le(e),fn(n,ft()?Reflect.construct(e,r||[],le(n).constructor):e.apply(n,r))}function fn(n,e){if(e&&(Z(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return pn(n)}function pn(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function ft(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ft=function(){return!!n})()}function le(n){return le=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},le(n)}function dn(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&Ae(n,e)}function Ae(n,e){return Ae=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},Ae(n,e)}function ve(n,e,r){return e=pt(e),e in n?Object.defineProperty(n,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[e]=r,n}function pt(n){var e=mn(n,"string");return Z(e)=="symbol"?e:e+""}function mn(n,e){if(Z(n)!="object"||!n)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var t=r.call(n,e);if(Z(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}var vn=Math.PI/180,Ze=1e-5,he=(function(n){function e(){return cn(this,e),un(this,e,arguments)}return dn(e,n),ln(e,[{key:"getTickLineCoord",value:function(t){var i=this.props,a=i.cx,o=i.cy,c=i.radius,f=i.orientation,s=i.tickSize,p=s||8,d=S(a,o,c,t.coordinate),v=S(a,o,c+(f==="inner"?-1:1)*p,t.coordinate);return{x1:d.x,y1:d.y,x2:v.x,y2:v.y}}},{key:"getTickTextAnchor",value:function(t){var i=this.props.orientation,a=Math.cos(-t.coordinate*vn),o;return a>Ze?o=i==="outer"?"start":"end":a<-Ze?o=i==="outer"?"end":"start":o="middle",o}},{key:"renderAxisLine",value:function(){var t=this.props,i=t.cx,a=t.cy,o=t.radius,c=t.axisLine,f=t.axisLineType,s=$($({},k(this.props,!1)),{},{fill:"none"},k(c,!1));if(f==="circle")return h.createElement(kt,D({className:"recharts-polar-angle-axis-line"},s,{cx:i,cy:a,r:o}));var p=this.props.ticks,d=p.map(function(v){return S(i,a,o,v.coordinate)});return h.createElement(zt,D({className:"recharts-polar-angle-axis-line"},s,{points:d}))}},{key:"renderTicks",value:function(){var t=this,i=this.props,a=i.ticks,o=i.tick,c=i.tickLine,f=i.tickFormatter,s=i.stroke,p=k(this.props,!1),d=k(o,!1),v=$($({},p),{},{fill:"none"},k(c,!1)),A=a.map(function(m,l){var g=t.getTickLineCoord(m),b=t.getTickTextAnchor(m),x=$($($({textAnchor:b},p),{},{stroke:"none",fill:s},d),{},{index:l,payload:m,x:g.x2,y:g.y2});return h.createElement(_,D({className:I("recharts-polar-angle-axis-tick",et(o)),key:"tick-".concat(m.coordinate)},Pe(t.props,m,l)),c&&h.createElement("line",D({className:"recharts-polar-angle-axis-tick-line"},v,g)),o&&e.renderTickItem(o,x,f?f(m.value,l):m.value))});return h.createElement(_,{className:"recharts-polar-angle-axis-ticks"},A)}},{key:"render",value:function(){var t=this.props,i=t.ticks,a=t.radius,o=t.axisLine;return a<=0||!i||!i.length?null:h.createElement(_,{className:I("recharts-polar-angle-axis",this.props.className)},o&&this.renderAxisLine(),this.renderTicks())}}],[{key:"renderTickItem",value:function(t,i,a){var o;return h.isValidElement(t)?o=h.cloneElement(t,i):C(t)?o=t(i):o=h.createElement(Oe,D({},i,{className:"recharts-polar-angle-axis-tick-value"}),a),o}}])})(J.PureComponent);ve(he,"displayName","PolarAngleAxis");ve(he,"axisType","angleAxis");ve(he,"defaultProps",{type:"category",angleAxisId:0,scale:"auto",cx:0,cy:0,orientation:"outer",axisLine:!0,tickLine:!0,tickSize:8,tick:!0,hide:!1,allowDuplicatedCategory:!0});var oe;function U(n){"@babel/helpers - typeof";return U=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},U(n)}function q(){return q=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(n[t]=r[t])}return n},q.apply(this,arguments)}function Ue(n,e){var r=Object.keys(n);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(n);e&&(t=t.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),r.push.apply(r,t)}return r}function y(n){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Ue(Object(r),!0).forEach(function(t){P(n,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):Ue(Object(r)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(r,t))})}return n}function hn(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function Xe(n,e){for(var r=0;r<e.length;r++){var t=e[r];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(n,mt(t.key),t)}}function yn(n,e,r){return e&&Xe(n.prototype,e),r&&Xe(n,r),Object.defineProperty(n,"prototype",{writable:!1}),n}function gn(n,e,r){return e=ue(e),bn(n,dt()?Reflect.construct(e,r||[],ue(n).constructor):e.apply(n,r))}function bn(n,e){if(e&&(U(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return xn(n)}function xn(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function dt(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(dt=function(){return!!n})()}function ue(n){return ue=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},ue(n)}function An(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&ke(n,e)}function ke(n,e){return ke=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},ke(n,e)}function P(n,e,r){return e=mt(e),e in n?Object.defineProperty(n,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[e]=r,n}function mt(n){var e=kn(n,"string");return U(e)=="symbol"?e:e+""}function kn(n,e){if(U(n)!="object"||!n)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var t=r.call(n,e);if(U(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}var E=(function(n){function e(r){var t;return hn(this,e),t=gn(this,e,[r]),P(t,"pieRef",null),P(t,"sectorRefs",[]),P(t,"id",Tt("recharts-pie-")),P(t,"handleAnimationEnd",function(){var i=t.props.onAnimationEnd;t.setState({isAnimationFinished:!0}),C(i)&&i()}),P(t,"handleAnimationStart",function(){var i=t.props.onAnimationStart;t.setState({isAnimationFinished:!1}),C(i)&&i()}),t.state={isAnimationFinished:!r.isAnimationActive,prevIsAnimationActive:r.isAnimationActive,prevAnimationId:r.animationId,sectorToFocus:0},t}return An(e,n),yn(e,[{key:"isActiveIndex",value:function(t){var i=this.props.activeIndex;return Array.isArray(i)?i.indexOf(t)!==-1:t===i}},{key:"hasActiveIndex",value:function(){var t=this.props.activeIndex;return Array.isArray(t)?t.length!==0:t||t===0}},{key:"renderLabels",value:function(t){var i=this.props.isAnimationActive;if(i&&!this.state.isAnimationFinished)return null;var a=this.props,o=a.label,c=a.labelLine,f=a.dataKey,s=a.valueKey,p=k(this.props,!1),d=k(o,!1),v=k(c,!1),A=o&&o.offsetRadius||20,m=t.map(function(l,g){var b=(l.startAngle+l.endAngle)/2,x=S(l.cx,l.cy,l.outerRadius+A,b),j=y(y(y(y({},p),l),{},{stroke:"none"},d),{},{index:g,textAnchor:e.getTextAnchor(x.x,l.cx)},x),B=y(y(y(y({},p),l),{},{fill:"none",stroke:l.fill},v),{},{index:g,points:[S(l.cx,l.cy,l.outerRadius,b),x]}),w=f;return z(f)&&z(s)?w="value":z(f)&&(w=s),h.createElement(_,{key:"label-".concat(l.startAngle,"-").concat(l.endAngle,"-").concat(l.midAngle,"-").concat(g)},c&&e.renderLabelLineItem(c,B,"line"),e.renderLabelItem(o,j,F(l,w)))});return h.createElement(_,{className:"recharts-pie-labels"},m)}},{key:"renderSectorsStatically",value:function(t){var i=this,a=this.props,o=a.activeShape,c=a.blendStroke,f=a.inactiveShape;return t.map(function(s,p){if((s==null?void 0:s.startAngle)===0&&(s==null?void 0:s.endAngle)===0&&t.length!==1)return null;var d=i.isActiveIndex(p),v=f&&i.hasActiveIndex()?f:null,A=d?o:v,m=y(y({},s),{},{stroke:c?s.fill:s.stroke,tabIndex:-1});return h.createElement(_,q({ref:function(g){g&&!i.sectorRefs.includes(g)&&i.sectorRefs.push(g)},tabIndex:-1,className:"recharts-pie-sector"},Pe(i.props,s,p),{key:"sector-".concat(s==null?void 0:s.startAngle,"-").concat(s==null?void 0:s.endAngle,"-").concat(s.midAngle,"-").concat(p)}),h.createElement(Pt,q({option:A,isActive:d,shapeType:"sector"},m)))})}},{key:"renderSectorsWithAnimation",value:function(){var t=this,i=this.props,a=i.sectors,o=i.isAnimationActive,c=i.animationBegin,f=i.animationDuration,s=i.animationEasing,p=i.animationId,d=this.state,v=d.prevSectors,A=d.prevIsAnimationActive;return h.createElement(jt,{begin:c,duration:f,isActive:o,easing:s,from:{t:0},to:{t:1},key:"pie-".concat(p,"-").concat(A),onAnimationStart:this.handleAnimationStart,onAnimationEnd:this.handleAnimationEnd},function(m){var l=m.t,g=[],b=a&&a[0],x=b.startAngle;return a.forEach(function(j,B){var w=v&&v[B],N=B>0?_t(j,"paddingAngle",0):0;if(w){var X=De(w.endAngle-w.startAngle,j.endAngle-j.startAngle),O=y(y({},j),{},{startAngle:x+N,endAngle:x+X(l)+N});g.push(O),x=O.endAngle}else{var K=j.endAngle,T=j.startAngle,te=De(0,K-T),ne=te(l),R=y(y({},j),{},{startAngle:x+N,endAngle:x+ne+N});g.push(R),x=R.endAngle}}),h.createElement(_,null,t.renderSectorsStatically(g))})}},{key:"attachKeyboardHandlers",value:function(t){var i=this;t.onkeydown=function(a){if(!a.altKey)switch(a.key){case"ArrowLeft":{var o=++i.state.sectorToFocus%i.sectorRefs.length;i.sectorRefs[o].focus(),i.setState({sectorToFocus:o});break}case"ArrowRight":{var c=--i.state.sectorToFocus<0?i.sectorRefs.length-1:i.state.sectorToFocus%i.sectorRefs.length;i.sectorRefs[c].focus(),i.setState({sectorToFocus:c});break}case"Escape":{i.sectorRefs[i.state.sectorToFocus].blur(),i.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var t=this.props,i=t.sectors,a=t.isAnimationActive,o=this.state.prevSectors;return a&&i&&i.length&&(!o||!wt(o,i))?this.renderSectorsWithAnimation():this.renderSectorsStatically(i)}},{key:"componentDidMount",value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:"render",value:function(){var t=this,i=this.props,a=i.hide,o=i.sectors,c=i.className,f=i.label,s=i.cx,p=i.cy,d=i.innerRadius,v=i.outerRadius,A=i.isAnimationActive,m=this.state.isAnimationFinished;if(a||!o||!o.length||!M(s)||!M(p)||!M(d)||!M(v))return null;var l=I("recharts-pie",c);return h.createElement(_,{tabIndex:this.props.rootTabIndex,className:l,ref:function(b){t.pieRef=b}},this.renderSectors(),f&&this.renderLabels(o),tt.renderCallByParent(this.props,null,!1),(!A||m)&&je.renderCallByParent(this.props,o,!1))}}],[{key:"getDerivedStateFromProps",value:function(t,i){return i.prevIsAnimationActive!==t.isAnimationActive?{prevIsAnimationActive:t.isAnimationActive,prevAnimationId:t.animationId,curSectors:t.sectors,prevSectors:[],isAnimationFinished:!0}:t.isAnimationActive&&t.animationId!==i.prevAnimationId?{prevAnimationId:t.animationId,curSectors:t.sectors,prevSectors:i.curSectors,isAnimationFinished:!0}:t.sectors!==i.curSectors?{curSectors:t.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(t,i){return t>i?"start":t<i?"end":"middle"}},{key:"renderLabelLineItem",value:function(t,i,a){if(h.isValidElement(t))return h.cloneElement(t,i);if(C(t))return t(i);var o=I("recharts-pie-label-line",typeof t!="boolean"?t.className:"");return h.createElement(Ot,q({},i,{key:a,type:"linear",className:o}))}},{key:"renderLabelItem",value:function(t,i,a){if(h.isValidElement(t))return h.cloneElement(t,i);var o=a;if(C(t)&&(o=t(i),h.isValidElement(o)))return o;var c=I("recharts-pie-label-text",typeof t!="boolean"&&!C(t)?t.className:"");return h.createElement(Oe,q({},i,{alignmentBaseline:"middle",className:c}),o)}}])})(J.PureComponent);oe=E;P(E,"displayName","Pie");P(E,"defaultProps",{stroke:"#fff",fill:"#808080",legendType:"rect",cx:"50%",cy:"50%",startAngle:0,endAngle:360,innerRadius:0,outerRadius:"80%",paddingAngle:0,labelLine:!0,hide:!1,minAngle:0,isAnimationActive:!St.isSsr,animationBegin:400,animationDuration:1500,animationEasing:"ease",nameKey:"name",blendStroke:!1,rootTabIndex:0});P(E,"parseDeltaAngle",function(n,e){var r=ae(e-n),t=Math.min(Math.abs(e-n),360);return r*t});P(E,"getRealPieData",function(n){var e=n.data,r=n.children,t=k(n,!1),i=Et(r,_e);return e&&e.length?e.map(function(a,o){return y(y(y({payload:a},t),a),i&&i[o]&&i[o].props)}):i&&i.length?i.map(function(a){return y(y({},t),a.props)}):[]});P(E,"parseCoordinateOfPie",function(n,e){var r=e.top,t=e.left,i=e.width,a=e.height,o=Rt(i,a),c=t+re(n.cx,i,i/2),f=r+re(n.cy,a,a/2),s=re(n.innerRadius,o,0),p=re(n.outerRadius,o,o*.8),d=n.maxRadius||Math.sqrt(i*i+a*a)/2;return{cx:c,cy:f,innerRadius:s,outerRadius:p,maxRadius:d}});P(E,"getComposedData",function(n){var e=n.item,r=n.offset,t=e.type.defaultProps!==void 0?y(y({},e.type.defaultProps),e.props):e.props,i=oe.getRealPieData(t);if(!i||!i.length)return null;var a=t.cornerRadius,o=t.startAngle,c=t.endAngle,f=t.paddingAngle,s=t.dataKey,p=t.nameKey,d=t.valueKey,v=t.tooltipType,A=Math.abs(t.minAngle),m=oe.parseCoordinateOfPie(t,r),l=oe.parseDeltaAngle(o,c),g=Math.abs(l),b=s;z(s)&&z(d)?(Be(!1,`Use "dataKey" to specify the value of pie,
3
3
  the props "valueKey" will be deprecated in 1.1.0`),b="value"):z(s)&&(Be(!1,`Use "dataKey" to specify the value of pie,
4
4
  the props "valueKey" will be deprecated in 1.1.0`),b=d);var x=i.filter(function(O){return F(O,b,0)!==0}).length,j=(g>=360?x:x-1)*f,B=g-x*A-j,w=i.reduce(function(O,K){var T=F(K,b,0);return O+(M(T)?T:0)},0),N;if(w>0){var X;N=i.map(function(O,K){var T=F(O,b,0),te=F(O,p,K),ne=(M(T)?T:0)/w,R;K?R=X.endAngle+ae(l)*f*(T!==0?1:0):R=o;var Le=R+ae(l)*((T!==0?A:0)+ne*B),$e=(R+Le)/2,Ce=(m.innerRadius+m.outerRadius)/2,gt=[{name:te,value:T,payload:O,dataKey:b,type:v}],bt=S(m.cx,m.cy,Ce,$e);return X=y(y(y({percent:ne,cornerRadius:a,name:te,tooltipPayload:gt,midAngle:$e,middleRadius:Ce,tooltipPosition:bt},O),m),{},{value:F(O,b),startAngle:R,endAngle:Le,payload:O,paddingAngle:ae(l)*f}),X})}return y(y({},m),{},{sectors:N,data:i})});var vt=nt({chartName:"BarChart",GraphicalChild:Se,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:we},{axisType:"yAxis",AxisComp:Te}],formatAxisMap:It}),On=nt({chartName:"PieChart",GraphicalChild:E,validateTooltipEventTypes:["item"],defaultTooltipEventType:"item",legendContent:"children",axisComponents:[{axisType:"angleAxis",AxisComp:he},{axisType:"radiusAxis",AxisComp:me}],formatAxisMap:Nt,defaultProps:{layout:"centric",startAngle:0,endAngle:360,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"}});const ht={fill:"var(--color-bg-2)"},yt={fill:"var(--color-fg-dim)",fontSize:10,fontFamily:"var(--font-mono)"},Pn=Ne("cost",G,n=>{var e;return(e=n[0])==null?void 0:e.color},{title:n=>ee(n)}),jn=Ne("tokens",W,n=>{var e;return(e=n[0])==null?void 0:e.color},{title:n=>ee(n)}),_n=Ne("saved",G,n=>{var e;return(e=n[0])==null?void 0:e.color},{title:n=>ee(n)});function Tn({derived:n,height:e=280,limit:r=10,metric:t="cost",periodLabel:i}){const a=Ee(),o=rt("(min-width: 768px)"),c=o?124:92,f=o?60:44,s=t==="tokens",p=[...n.byModel].sort((d,v)=>s?v.tokens-d.tokens:v.cost-d.cost).slice(0,r);return u.jsx(fe,{title:s?"tokens by model":"cost by model",titleTag:i,captureName:s?"tokens-by-model":"cost-by-model",children:p.length===0?u.jsx(pe,{children:"no models in period"}):u.jsx(Re,{height:e,children:u.jsx(Ie,{children:u.jsxs(vt,{data:p,layout:"vertical",margin:{top:4,right:f,left:4,bottom:0},children:[u.jsx(it,{...at,horizontal:!1,vertical:!0}),u.jsx(we,{type:"number",...se,tickFormatter:s?W:ot}),u.jsx(Te,{type:"category",dataKey:"model",...se,width:c,tickFormatter:ee}),u.jsx(st,{content:s?jn:Pn,cursor:ht}),u.jsxs(Se,{dataKey:s?"tokens":"cost",radius:[0,3,3,0],isAnimationActive:a,animationDuration:350,children:[p.map(d=>u.jsx(_e,{fill:d.color},d.model)),u.jsx(je,{dataKey:s?"tokens":"cost",position:"right",offset:6,...yt,formatter:d=>s?W(d):G(d)})]})]})})})})}function Sn({derived:n,height:e=240,limit:r=12,periodLabel:t}){const i=Ee(),a=rt("(min-width: 768px)"),o=a?124:92,c=a?60:44,f=[...n.byModel].filter(s=>s.cacheSavings>0).sort((s,p)=>p.cacheSavings-s.cacheSavings).slice(0,r);return u.jsx(fe,{title:"cache savings by model",titleTag:t,captureName:"cache-savings-by-model",children:f.length===0?u.jsx(pe,{children:"no cache savings in period"}):u.jsx(Re,{height:e,children:u.jsx(Ie,{children:u.jsxs(vt,{data:f,layout:"vertical",margin:{top:4,right:c,left:4,bottom:0},children:[u.jsx(it,{...at,horizontal:!1,vertical:!0}),u.jsx(we,{type:"number",...se,tickFormatter:ot}),u.jsx(Te,{type:"category",dataKey:"model",...se,width:o,tickFormatter:ee}),u.jsx(st,{content:_n,cursor:ht}),u.jsx(Se,{dataKey:"cacheSavings",radius:[0,3,3,0],fill:"var(--color-positive)",isAnimationActive:i,animationDuration:350,children:u.jsx(je,{dataKey:"cacheSavings",position:"right",offset:6,...yt,formatter:s=>G(s)})})]})})})})}function En({derived:n,height:e=280,periodLabel:r}){const t=Ee(),i=n.byProvider,a=n.totals.cost,[o,c]=J.useState(null),[f,s]=J.useState(null),p=f?i.findIndex(m=>m.id===f):-1,d=o??(p>=0?p:null),v=d!=null?i[d]:null,A=v&&a>0?v.cost/a:0;return u.jsx(fe,{title:"provider split",titleTag:r,captureName:"provider-split",children:i.length===0?u.jsx(pe,{children:"no spend in period"}):u.jsxs("div",{className:"relative",onMouseLeave:()=>c(null),children:[u.jsx(Re,{height:e,children:u.jsx(Ie,{children:u.jsx(On,{children:u.jsx(E,{data:i,dataKey:"cost",nameKey:"name",innerRadius:"60%",outerRadius:"88%",paddingAngle:i.length>1?2:0,stroke:"var(--color-bg-1)",strokeWidth:2,isAnimationActive:t,animationDuration:350,style:{cursor:"pointer"},onMouseEnter:(m,l)=>c(l),onClick:(m,l)=>s(g=>{var b,x;return g===((b=i[l])==null?void 0:b.id)?null:((x=i[l])==null?void 0:x.id)??null}),children:i.map((m,l)=>u.jsx(_e,{fill:m.color,"aria-label":`${m.name}: ${G(m.cost)}`,fillOpacity:d==null||d===l?1:.32,style:{transition:"fill-opacity 150ms ease"}},m.id))})})})}),u.jsxs("div",{className:"pointer-events-none absolute inset-0 flex flex-col items-center justify-center",children:[u.jsx("div",{className:"tnum text-xl",style:{color:v?v.color:"var(--color-fg-bright)"},children:G(v?v.cost:a)}),u.jsxs("div",{className:"font-display text-[10px] uppercase tracking-wide text-fg-faint",children:[v?`${v.name} · ${ct(A,A>0&&A<.01?1:0)}`:"total",v&&o==null&&p>=0&&u.jsx("span",{className:"text-accent",children:" · pinned"})]})]})]})})}function Rn({derived:n,periodLabel:e}){const r=n.tokenComposition,t=Lt(r),i=[{key:"cacheRead",label:"cache read",value:r.cacheRead,color:ie.cacheRead},{key:"input",label:"input",value:r.input,color:ie.input},{key:"output",label:"output",value:r.output,color:ie.output},{key:"cacheCreate",label:"cache write",value:r.cacheCreate,color:ie.cacheCreate}];return u.jsx(fe,{title:"token composition",titleTag:e,captureName:"token-composition",right:u.jsx("span",{className:"tnum text-xs text-fg-dim",children:W(t)}),children:t===0?u.jsx(pe,{children:"no tokens in period"}):u.jsxs("div",{className:"flex flex-col gap-4 pt-1",children:[u.jsx("div",{className:"flex h-3 w-full overflow-hidden rounded-full bg-bg-3",children:i.map(a=>a.value>0&&u.jsx("div",{style:{width:`${a.value/t*100}%`,minWidth:"2px",background:a.color},title:`${a.label}: ${W(a.value)}`},a.key))}),u.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-2.5",children:i.map(a=>{const o=t>0?a.value/t:0;return u.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs",children:[u.jsxs("span",{className:"flex items-center gap-1.5 text-fg-dim",children:[u.jsx("span",{className:"inline-block size-2 rounded-[2px]",style:{background:a.color}}),a.label]}),u.jsxs("span",{className:"text-fg",children:[u.jsx("span",{className:"tnum text-fg-bright",children:W(a.value)}),u.jsx("span",{className:"ml-1.5 text-fg-faint",children:ct(o,o>0&&o<.01?1:0)})]})]},a.key)})})]})})}export{Sn as CacheByModel,Tn as CostByModel,En as ProviderDonut,Rn as TokenComposition};