stocklift-charts
Version:
StockLift Web Component Charts
11,213 lines • 345 kB
JavaScript
var ar = Object.defineProperty;
var lr = (i, t, e) => t in i ? ar(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
var w = (i, t, e) => lr(i, typeof t != "symbol" ? t + "" : t, e);
import { css as Mt, LitElement as Rt, html as W } from "lit";
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const Ft = (i) => (t, e) => {
e !== void 0 ? e.addInitializer(() => {
customElements.define(i, t);
}) : customElements.define(i, t);
};
/**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const ai = globalThis, fs = ai.ShadowRoot && (ai.ShadyCSS === void 0 || ai.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, ro = Symbol(), Es = /* @__PURE__ */ new WeakMap();
let cr = class {
constructor(t, e, s) {
if (this._$cssResult$ = !0, s !== ro) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
this.cssText = t, this.t = e;
}
get styleSheet() {
let t = this.o;
const e = this.t;
if (fs && t === void 0) {
const s = e !== void 0 && e.length === 1;
s && (t = Es.get(e)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), s && Es.set(e, t));
}
return t;
}
toString() {
return this.cssText;
}
};
const hr = (i) => new cr(typeof i == "string" ? i : i + "", void 0, ro), dr = (i, t) => {
if (fs) i.adoptedStyleSheets = t.map((e) => e instanceof CSSStyleSheet ? e : e.styleSheet);
else for (const e of t) {
const s = document.createElement("style"), n = ai.litNonce;
n !== void 0 && s.setAttribute("nonce", n), s.textContent = e.cssText, i.appendChild(s);
}
}, Ls = fs ? (i) => i : (i) => i instanceof CSSStyleSheet ? ((t) => {
let e = "";
for (const s of t.cssRules) e += s.cssText;
return hr(e);
})(i) : i;
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const { is: fr, defineProperty: ur, getOwnPropertyDescriptor: gr, getOwnPropertyNames: pr, getOwnPropertySymbols: mr, getPrototypeOf: br } = Object, At = globalThis, Rs = At.trustedTypes, xr = Rs ? Rs.emptyScript : "", zi = At.reactiveElementPolyfillSupport, Pe = (i, t) => i, xi = { toAttribute(i, t) {
switch (t) {
case Boolean:
i = i ? xr : null;
break;
case Object:
case Array:
i = i == null ? i : JSON.stringify(i);
}
return i;
}, fromAttribute(i, t) {
let e = i;
switch (t) {
case Boolean:
e = i !== null;
break;
case Number:
e = i === null ? null : Number(i);
break;
case Object:
case Array:
try {
e = JSON.parse(i);
} catch {
e = null;
}
}
return e;
} }, us = (i, t) => !fr(i, t), Fs = { attribute: !0, type: String, converter: xi, reflect: !1, hasChanged: us };
Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), At.litPropertyMetadata ?? (At.litPropertyMetadata = /* @__PURE__ */ new WeakMap());
class ge extends HTMLElement {
static addInitializer(t) {
this._$Ei(), (this.l ?? (this.l = [])).push(t);
}
static get observedAttributes() {
return this.finalize(), this._$Eh && [...this._$Eh.keys()];
}
static createProperty(t, e = Fs) {
if (e.state && (e.attribute = !1), this._$Ei(), this.elementProperties.set(t, e), !e.noAccessor) {
const s = Symbol(), n = this.getPropertyDescriptor(t, s, e);
n !== void 0 && ur(this.prototype, t, n);
}
}
static getPropertyDescriptor(t, e, s) {
const { get: n, set: o } = gr(this.prototype, t) ?? { get() {
return this[e];
}, set(r) {
this[e] = r;
} };
return { get() {
return n == null ? void 0 : n.call(this);
}, set(r) {
const a = n == null ? void 0 : n.call(this);
o.call(this, r), this.requestUpdate(t, a, s);
}, configurable: !0, enumerable: !0 };
}
static getPropertyOptions(t) {
return this.elementProperties.get(t) ?? Fs;
}
static _$Ei() {
if (this.hasOwnProperty(Pe("elementProperties"))) return;
const t = br(this);
t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
}
static finalize() {
if (this.hasOwnProperty(Pe("finalized"))) return;
if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(Pe("properties"))) {
const e = this.properties, s = [...pr(e), ...mr(e)];
for (const n of s) this.createProperty(n, e[n]);
}
const t = this[Symbol.metadata];
if (t !== null) {
const e = litPropertyMetadata.get(t);
if (e !== void 0) for (const [s, n] of e) this.elementProperties.set(s, n);
}
this._$Eh = /* @__PURE__ */ new Map();
for (const [e, s] of this.elementProperties) {
const n = this._$Eu(e, s);
n !== void 0 && this._$Eh.set(n, e);
}
this.elementStyles = this.finalizeStyles(this.styles);
}
static finalizeStyles(t) {
const e = [];
if (Array.isArray(t)) {
const s = new Set(t.flat(1 / 0).reverse());
for (const n of s) e.unshift(Ls(n));
} else t !== void 0 && e.push(Ls(t));
return e;
}
static _$Eu(t, e) {
const s = e.attribute;
return s === !1 ? void 0 : typeof s == "string" ? s : typeof t == "string" ? t.toLowerCase() : void 0;
}
constructor() {
super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev();
}
_$Ev() {
var t;
this._$ES = new Promise((e) => this.enableUpdating = e), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), (t = this.constructor.l) == null || t.forEach((e) => e(this));
}
addController(t) {
var e;
(this._$EO ?? (this._$EO = /* @__PURE__ */ new Set())).add(t), this.renderRoot !== void 0 && this.isConnected && ((e = t.hostConnected) == null || e.call(t));
}
removeController(t) {
var e;
(e = this._$EO) == null || e.delete(t);
}
_$E_() {
const t = /* @__PURE__ */ new Map(), e = this.constructor.elementProperties;
for (const s of e.keys()) this.hasOwnProperty(s) && (t.set(s, this[s]), delete this[s]);
t.size > 0 && (this._$Ep = t);
}
createRenderRoot() {
const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
return dr(t, this.constructor.elementStyles), t;
}
connectedCallback() {
var t;
this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (t = this._$EO) == null || t.forEach((e) => {
var s;
return (s = e.hostConnected) == null ? void 0 : s.call(e);
});
}
enableUpdating(t) {
}
disconnectedCallback() {
var t;
(t = this._$EO) == null || t.forEach((e) => {
var s;
return (s = e.hostDisconnected) == null ? void 0 : s.call(e);
});
}
attributeChangedCallback(t, e, s) {
this._$AK(t, s);
}
_$EC(t, e) {
var o;
const s = this.constructor.elementProperties.get(t), n = this.constructor._$Eu(t, s);
if (n !== void 0 && s.reflect === !0) {
const r = (((o = s.converter) == null ? void 0 : o.toAttribute) !== void 0 ? s.converter : xi).toAttribute(e, s.type);
this._$Em = t, r == null ? this.removeAttribute(n) : this.setAttribute(n, r), this._$Em = null;
}
}
_$AK(t, e) {
var o;
const s = this.constructor, n = s._$Eh.get(t);
if (n !== void 0 && this._$Em !== n) {
const r = s.getPropertyOptions(n), a = typeof r.converter == "function" ? { fromAttribute: r.converter } : ((o = r.converter) == null ? void 0 : o.fromAttribute) !== void 0 ? r.converter : xi;
this._$Em = n, this[n] = a.fromAttribute(e, r.type), this._$Em = null;
}
}
requestUpdate(t, e, s) {
if (t !== void 0) {
if (s ?? (s = this.constructor.getPropertyOptions(t)), !(s.hasChanged ?? us)(this[t], e)) return;
this.P(t, e, s);
}
this.isUpdatePending === !1 && (this._$ES = this._$ET());
}
P(t, e, s) {
this._$AL.has(t) || this._$AL.set(t, e), s.reflect === !0 && this._$Em !== t && (this._$Ej ?? (this._$Ej = /* @__PURE__ */ new Set())).add(t);
}
async _$ET() {
this.isUpdatePending = !0;
try {
await this._$ES;
} catch (e) {
Promise.reject(e);
}
const t = this.scheduleUpdate();
return t != null && await t, !this.isUpdatePending;
}
scheduleUpdate() {
return this.performUpdate();
}
performUpdate() {
var s;
if (!this.isUpdatePending) return;
if (!this.hasUpdated) {
if (this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this._$Ep) {
for (const [o, r] of this._$Ep) this[o] = r;
this._$Ep = void 0;
}
const n = this.constructor.elementProperties;
if (n.size > 0) for (const [o, r] of n) r.wrapped !== !0 || this._$AL.has(o) || this[o] === void 0 || this.P(o, this[o], r);
}
let t = !1;
const e = this._$AL;
try {
t = this.shouldUpdate(e), t ? (this.willUpdate(e), (s = this._$EO) == null || s.forEach((n) => {
var o;
return (o = n.hostUpdate) == null ? void 0 : o.call(n);
}), this.update(e)) : this._$EU();
} catch (n) {
throw t = !1, this._$EU(), n;
}
t && this._$AE(e);
}
willUpdate(t) {
}
_$AE(t) {
var e;
(e = this._$EO) == null || e.forEach((s) => {
var n;
return (n = s.hostUpdated) == null ? void 0 : n.call(s);
}), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(t)), this.updated(t);
}
_$EU() {
this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
}
get updateComplete() {
return this.getUpdateComplete();
}
getUpdateComplete() {
return this._$ES;
}
shouldUpdate(t) {
return !0;
}
update(t) {
this._$Ej && (this._$Ej = this._$Ej.forEach((e) => this._$EC(e, this[e]))), this._$EU();
}
updated(t) {
}
firstUpdated(t) {
}
}
ge.elementStyles = [], ge.shadowRootOptions = { mode: "open" }, ge[Pe("elementProperties")] = /* @__PURE__ */ new Map(), ge[Pe("finalized")] = /* @__PURE__ */ new Map(), zi == null || zi({ ReactiveElement: ge }), (At.reactiveElementVersions ?? (At.reactiveElementVersions = [])).push("2.0.4");
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const _r = { attribute: !0, type: String, converter: xi, reflect: !1, hasChanged: us }, yr = (i = _r, t, e) => {
const { kind: s, metadata: n } = e;
let o = globalThis.litPropertyMetadata.get(n);
if (o === void 0 && globalThis.litPropertyMetadata.set(n, o = /* @__PURE__ */ new Map()), o.set(e.name, i), s === "accessor") {
const { name: r } = e;
return { set(a) {
const l = t.get.call(this);
t.set.call(this, a), this.requestUpdate(r, l, i);
}, init(a) {
return a !== void 0 && this.P(r, void 0, i), a;
} };
}
if (s === "setter") {
const { name: r } = e;
return function(a) {
const l = this[r];
t.call(this, a), this.requestUpdate(r, l, i);
};
}
throw Error("Unsupported decorator location: " + s);
};
function X(i) {
return (t, e) => typeof e == "object" ? yr(i, t, e) : ((s, n, o) => {
const r = n.hasOwnProperty(o);
return n.constructor.createProperty(o, r ? { ...s, wrapped: !0 } : s), r ? Object.getOwnPropertyDescriptor(n, o) : void 0;
})(i, t, e);
}
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
function N(i) {
return X({ ...i, state: !0, attribute: !1 });
}
const Di = Mt`
/* h3 {
text-align: center;
margin: 0;
padding: 1.5rem;
}
h4 {
text-align: center;
margin: 0;
padding: 0;
}
h5 {
text-align: center;
margin: 0;
padding: 0;
font-weight: 300;
} */
button {
font-weight: 400;
font-size: 0.75em;
font-family: inherit;
cursor: pointer;
transition: border-color 0.25s;
/* border-radius: 8px;
padding: 0.6em 1.2em; */
}
button:hover {
border-color: var(--stocklift-button-hover-color, #146ada);
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}
/* APP BUTTON */
.app-button {
cursor: pointer;
font-weight: 400;
font-size: 0.65em;
font-family: inherit;
color: white;
background-color: var(--stocklift-button-color, #4089e9);
transition: background-color 0.25s;
padding: 0.5em 1em;
border: none;
border-radius: 5px;
}
.app-button:hover {
background-color: var(--stocklift-button-hover-color, #146ada);
}
`, se = "https://api.sdk.stocklift.co/sdk/v1", vr = [
"#FF0000",
// Red
"#FF4500",
// Orange-Red
"#FF7F00",
// Orange
"#FFA500",
// Light Orange
"#FFD700",
// Gold
"#FFFF00",
// Yellow
"#ADFF2F",
// Green-Yellow
"#7FFF00",
// Chartreuse
"#00FF00",
// Green
"#32CD32",
// Lime Green
"#00FF7F",
// Spring Green
"#00FFFF",
// Cyan
"#1E90FF",
// Dodger Blue
"#0000FF",
// Blue
"#8A2BE2",
// Blue-Violet
"#9400D3",
// Dark Violet
"#FF00FF",
// Magenta
"#FF1493"
// Deep Pink
], wr = (i, t) => (console.log("totalNetValue", t), (i.institution_value / t * 100).toFixed(2)), kr = (i) => ((i.institution_value / i.cost_basis - 1) * 100).toFixed(2);
var Sr = Object.defineProperty, Mr = Object.getOwnPropertyDescriptor, zt = (i, t, e, s) => {
for (var n = s > 1 ? void 0 : s ? Mr(t, e) : t, o = i.length - 1, r; o >= 0; o--)
(r = i[o]) && (n = (s ? r(t, e, n) : r(n)) || n);
return s && n && Sr(t, e, n), n;
};
let mt = class extends Rt {
constructor() {
super(...arguments), this.netWorth = "", this.returnOnInvestment = "", this.changeFromLastClose = "", this.diversificationScore = 0, this.title = "Portfolio Summary", this.showProgressBar = !1, this.score = 0;
}
firstUpdated() {
this.setData();
}
calculateDiversificationScore() {
this.diversificationScore > 0 && (this.showProgressBar = !0, this.score = 0, setTimeout(() => {
this.score = this.diversificationScore;
}, 1e3), setTimeout(() => {
this.style.setProperty("--show-score", "block");
}, 2e3));
}
updated(i) {
(i.has("returnOnInvestment") || i.has("changeFromLastClose")) && this.setData();
}
setData() {
this.returnOnInvestment[0] === "-" && this.style.setProperty("--return-color", "red"), this.changeFromLastClose[0] === "-" && this.style.setProperty("--change-color", "red");
}
render() {
return W`
<div class="base">
<h6 class="title">${this.title}</h6>
<h3>${this.netWorth}</h3>
<div class="cell-container">
<div class="cell">
<h4 class="md-text cell-content">${this.changeFromLastClose}</h4>
<p class="sm-text changeFromLastClose cell-content">Change from</p>
<p class="sm-text changeFromLastClose cell-content">last close</p>
</div>
<div class="cell">
<h4 class="md-text cell-content">${this.returnOnInvestment}</h4>
<p class="sm-text returnOnInvestment cell-content">Return on</p>
<p class="sm-text returnOnInvestment cell-content">Investment</p>
</div>
</div>
<div class="button-container">
${this.showProgressBar ? W`
<div class="score-container">
<p class="md-text score">${this.diversificationScore}%</p>
<div class="progress-bar-container">
<div
class="progress-bar"
style="width: ${this.score}%"
></div>
</div>
</div>
` : W`
<button
class="app-button"
@click=${this.calculateDiversificationScore}
>
Calculate Diversification Score
</button>
`}
</div>
</div>
`;
}
};
mt.styles = [
Di,
Mt`
:host {
display: block;
box-sizing: border-box;
height: 100%;
position: relative;
}
.base {
text-align: center;
display: flex;
flex-direction: column;
padding: 1rem;
}
.title {
color: var(--stocklift-text-color, #fbfbfb);
font-weight: 400;
text-align: center;
margin: 0;
padding: 0;
position: absolute;
top: 0;
left: 0;
right: 0;
padding: 4px;
margin-bottom: 8px;
}
.cell-container {
display: flex;
justify-content: center;
flex-wrap: wrap; /* Allow cells to wrap to the next line if needed */
}
.cell {
border: 1px solid #e3e1e1;
border-radius: 5px;
margin: 0.2em;
font-size: 14px;
padding: 1em;
display: flex;
flex-direction: column;
text-align: left;
flex: 1 1 calc(33.333% - 0.4em); /* Adjust width dynamically */
box-sizing: border-box; /* Include padding and border in the element's total width and height */
max-width: calc(
33.333% - 0.4em
); /* Ensure cells don't exceed one-third of the container's width */
}
.cell-content {
flex: 1; /* Allow content to grow and shrink */
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%; /* Ensure content takes full width of the cell */
height: 100%; /* Ensure content takes full height of the cell */
box-sizing: border-box; /* Include padding and border in the element's total width and height */
}
.button-container {
display: flex;
flex-direction: column;
padding: 2em 2.5rem;
/* position: absolute; */
/* bottom: 0; */
/* left: 0;
right: 0; */
}
.sm-text {
font-size: 10px;
}
.md-text {
font-size: 12px;
}
.lg-text {
font-size: 14px;
}
.returnOnInvestment {
margin: 0;
padding: 0;
color: var(--return-color, green);
}
.changeFromLastClose {
margin: 0;
padding: 0;
color: var(--change-color, green);
}
.score-container {
display: block;
justify-content: center;
align-items: center;
margin-top: 1rem;
position: relative;
}
.score {
font-weight: 500;
position: absolute;
top: -30px;
right: 0;
display: var(--show-score, none);
}
.progress-bar-container {
width: 100%;
height: 10px;
background-color: #e0e0e0;
border-radius: 10px;
overflow: hidden;
margin-top: 10px;
}
.progress-bar {
height: 100%;
background-color: #007bff;
border-radius: 10px;
transition: width 1s ease-in-out;
}
/* Media Queries for Mobile Optimization */
@media (max-width: 768px) {
.cell {
max-width: calc(100% - 0.4em);
height: 40%;
}
.button-container {
padding: 3em 2.5rem;
}
.title {
font-size: 16px;
}
/* .sm-text {
font-size: 8px;
}
.md-text {
font-size: 10px;
}
.lg-text {
font-size: 12px;
} */
}
`
];
zt([
X({ type: String })
], mt.prototype, "netWorth", 2);
zt([
X({ type: String })
], mt.prototype, "returnOnInvestment", 2);
zt([
X({ type: String })
], mt.prototype, "changeFromLastClose", 2);
zt([
N()
], mt.prototype, "diversificationScore", 2);
zt([
X({ type: String })
], mt.prototype, "title", 2);
zt([
N()
], mt.prototype, "showProgressBar", 2);
zt([
N()
], mt.prototype, "score", 2);
mt = zt([
Ft("sl-summary")
], mt);
function _i(i) {
return String(i).charAt(0).toUpperCase() + String(i).slice(1);
}
function Pr(i) {
const t = _i(i.sector.split("_")[0]), e = _i(i.sector.split("_")[1] || ""), s = e !== void 0 ? `${t} ${e}` : t;
return e === "Services" ? t : s;
}
function Cr(i) {
const t = _i(i.split("_")[0]), e = _i(i.split("_")[1] || ""), s = e !== void 0 ? `${t} ${e}` : t;
return t === "Realestate" ? "Real Estate" : e === "Services" ? t : s;
}
/*!
* @kurkle/color v0.3.4
* https://github.com/kurkle/color#readme
* (c) 2024 Jukka Kurkela
* Released under the MIT License
*/
function We(i) {
return i + 0.5 | 0;
}
const Pt = (i, t, e) => Math.max(Math.min(i, e), t);
function ye(i) {
return Pt(We(i * 2.55), 0, 255);
}
function Tt(i) {
return Pt(We(i * 255), 0, 255);
}
function yt(i) {
return Pt(We(i / 2.55) / 100, 0, 1);
}
function zs(i) {
return Pt(We(i * 100), 0, 100);
}
const at = { 0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, A: 10, B: 11, C: 12, D: 13, E: 14, F: 15, a: 10, b: 11, c: 12, d: 13, e: 14, f: 15 }, Gi = [..."0123456789ABCDEF"], Dr = (i) => Gi[i & 15], Or = (i) => Gi[(i & 240) >> 4] + Gi[i & 15], Xe = (i) => (i & 240) >> 4 === (i & 15), Ar = (i) => Xe(i.r) && Xe(i.g) && Xe(i.b) && Xe(i.a);
function Tr(i) {
var t = i.length, e;
return i[0] === "#" && (t === 4 || t === 5 ? e = {
r: 255 & at[i[1]] * 17,
g: 255 & at[i[2]] * 17,
b: 255 & at[i[3]] * 17,
a: t === 5 ? at[i[4]] * 17 : 255
} : (t === 7 || t === 9) && (e = {
r: at[i[1]] << 4 | at[i[2]],
g: at[i[3]] << 4 | at[i[4]],
b: at[i[5]] << 4 | at[i[6]],
a: t === 9 ? at[i[7]] << 4 | at[i[8]] : 255
})), e;
}
const Er = (i, t) => i < 255 ? t(i) : "";
function Lr(i) {
var t = Ar(i) ? Dr : Or;
return i ? "#" + t(i.r) + t(i.g) + t(i.b) + Er(i.a, t) : void 0;
}
const Rr = /^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;
function ao(i, t, e) {
const s = t * Math.min(e, 1 - e), n = (o, r = (o + i / 30) % 12) => e - s * Math.max(Math.min(r - 3, 9 - r, 1), -1);
return [n(0), n(8), n(4)];
}
function Fr(i, t, e) {
const s = (n, o = (n + i / 60) % 6) => e - e * t * Math.max(Math.min(o, 4 - o, 1), 0);
return [s(5), s(3), s(1)];
}
function zr(i, t, e) {
const s = ao(i, 1, 0.5);
let n;
for (t + e > 1 && (n = 1 / (t + e), t *= n, e *= n), n = 0; n < 3; n++)
s[n] *= 1 - t - e, s[n] += t;
return s;
}
function Ir(i, t, e, s, n) {
return i === n ? (t - e) / s + (t < e ? 6 : 0) : t === n ? (e - i) / s + 2 : (i - t) / s + 4;
}
function gs(i) {
const e = i.r / 255, s = i.g / 255, n = i.b / 255, o = Math.max(e, s, n), r = Math.min(e, s, n), a = (o + r) / 2;
let l, c, h;
return o !== r && (h = o - r, c = a > 0.5 ? h / (2 - o - r) : h / (o + r), l = Ir(e, s, n, h, o), l = l * 60 + 0.5), [l | 0, c || 0, a];
}
function ps(i, t, e, s) {
return (Array.isArray(t) ? i(t[0], t[1], t[2]) : i(t, e, s)).map(Tt);
}
function ms(i, t, e) {
return ps(ao, i, t, e);
}
function Br(i, t, e) {
return ps(zr, i, t, e);
}
function $r(i, t, e) {
return ps(Fr, i, t, e);
}
function lo(i) {
return (i % 360 + 360) % 360;
}
function jr(i) {
const t = Rr.exec(i);
let e = 255, s;
if (!t)
return;
t[5] !== s && (e = t[6] ? ye(+t[5]) : Tt(+t[5]));
const n = lo(+t[2]), o = +t[3] / 100, r = +t[4] / 100;
return t[1] === "hwb" ? s = Br(n, o, r) : t[1] === "hsv" ? s = $r(n, o, r) : s = ms(n, o, r), {
r: s[0],
g: s[1],
b: s[2],
a: e
};
}
function Wr(i, t) {
var e = gs(i);
e[0] = lo(e[0] + t), e = ms(e), i.r = e[0], i.g = e[1], i.b = e[2];
}
function Nr(i) {
if (!i)
return;
const t = gs(i), e = t[0], s = zs(t[1]), n = zs(t[2]);
return i.a < 255 ? `hsla(${e}, ${s}%, ${n}%, ${yt(i.a)})` : `hsl(${e}, ${s}%, ${n}%)`;
}
const Is = {
x: "dark",
Z: "light",
Y: "re",
X: "blu",
W: "gr",
V: "medium",
U: "slate",
A: "ee",
T: "ol",
S: "or",
B: "ra",
C: "lateg",
D: "ights",
R: "in",
Q: "turquois",
E: "hi",
P: "ro",
O: "al",
N: "le",
M: "de",
L: "yello",
F: "en",
K: "ch",
G: "arks",
H: "ea",
I: "ightg",
J: "wh"
}, Bs = {
OiceXe: "f0f8ff",
antiquewEte: "faebd7",
aqua: "ffff",
aquamarRe: "7fffd4",
azuY: "f0ffff",
beige: "f5f5dc",
bisque: "ffe4c4",
black: "0",
blanKedOmond: "ffebcd",
Xe: "ff",
XeviTet: "8a2be2",
bPwn: "a52a2a",
burlywood: "deb887",
caMtXe: "5f9ea0",
KartYuse: "7fff00",
KocTate: "d2691e",
cSO: "ff7f50",
cSnflowerXe: "6495ed",
cSnsilk: "fff8dc",
crimson: "dc143c",
cyan: "ffff",
xXe: "8b",
xcyan: "8b8b",
xgTMnPd: "b8860b",
xWay: "a9a9a9",
xgYF: "6400",
xgYy: "a9a9a9",
xkhaki: "bdb76b",
xmagFta: "8b008b",
xTivegYF: "556b2f",
xSange: "ff8c00",
xScEd: "9932cc",
xYd: "8b0000",
xsOmon: "e9967a",
xsHgYF: "8fbc8f",
xUXe: "483d8b",
xUWay: "2f4f4f",
xUgYy: "2f4f4f",
xQe: "ced1",
xviTet: "9400d3",
dAppRk: "ff1493",
dApskyXe: "bfff",
dimWay: "696969",
dimgYy: "696969",
dodgerXe: "1e90ff",
fiYbrick: "b22222",
flSOwEte: "fffaf0",
foYstWAn: "228b22",
fuKsia: "ff00ff",
gaRsbSo: "dcdcdc",
ghostwEte: "f8f8ff",
gTd: "ffd700",
gTMnPd: "daa520",
Way: "808080",
gYF: "8000",
gYFLw: "adff2f",
gYy: "808080",
honeyMw: "f0fff0",
hotpRk: "ff69b4",
RdianYd: "cd5c5c",
Rdigo: "4b0082",
ivSy: "fffff0",
khaki: "f0e68c",
lavFMr: "e6e6fa",
lavFMrXsh: "fff0f5",
lawngYF: "7cfc00",
NmoncEffon: "fffacd",
ZXe: "add8e6",
ZcSO: "f08080",
Zcyan: "e0ffff",
ZgTMnPdLw: "fafad2",
ZWay: "d3d3d3",
ZgYF: "90ee90",
ZgYy: "d3d3d3",
ZpRk: "ffb6c1",
ZsOmon: "ffa07a",
ZsHgYF: "20b2aa",
ZskyXe: "87cefa",
ZUWay: "778899",
ZUgYy: "778899",
ZstAlXe: "b0c4de",
ZLw: "ffffe0",
lime: "ff00",
limegYF: "32cd32",
lRF: "faf0e6",
magFta: "ff00ff",
maPon: "800000",
VaquamarRe: "66cdaa",
VXe: "cd",
VScEd: "ba55d3",
VpurpN: "9370db",
VsHgYF: "3cb371",
VUXe: "7b68ee",
VsprRggYF: "fa9a",
VQe: "48d1cc",
VviTetYd: "c71585",
midnightXe: "191970",
mRtcYam: "f5fffa",
mistyPse: "ffe4e1",
moccasR: "ffe4b5",
navajowEte: "ffdead",
navy: "80",
Tdlace: "fdf5e6",
Tive: "808000",
TivedBb: "6b8e23",
Sange: "ffa500",
SangeYd: "ff4500",
ScEd: "da70d6",
pOegTMnPd: "eee8aa",
pOegYF: "98fb98",
pOeQe: "afeeee",
pOeviTetYd: "db7093",
papayawEp: "ffefd5",
pHKpuff: "ffdab9",
peru: "cd853f",
pRk: "ffc0cb",
plum: "dda0dd",
powMrXe: "b0e0e6",
purpN: "800080",
YbeccapurpN: "663399",
Yd: "ff0000",
Psybrown: "bc8f8f",
PyOXe: "4169e1",
saddNbPwn: "8b4513",
sOmon: "fa8072",
sandybPwn: "f4a460",
sHgYF: "2e8b57",
sHshell: "fff5ee",
siFna: "a0522d",
silver: "c0c0c0",
skyXe: "87ceeb",
UXe: "6a5acd",
UWay: "708090",
UgYy: "708090",
snow: "fffafa",
sprRggYF: "ff7f",
stAlXe: "4682b4",
tan: "d2b48c",
teO: "8080",
tEstN: "d8bfd8",
tomato: "ff6347",
Qe: "40e0d0",
viTet: "ee82ee",
JHt: "f5deb3",
wEte: "ffffff",
wEtesmoke: "f5f5f5",
Lw: "ffff00",
LwgYF: "9acd32"
};
function Vr() {
const i = {}, t = Object.keys(Bs), e = Object.keys(Is);
let s, n, o, r, a;
for (s = 0; s < t.length; s++) {
for (r = a = t[s], n = 0; n < e.length; n++)
o = e[n], a = a.replace(o, Is[o]);
o = parseInt(Bs[r], 16), i[a] = [o >> 16 & 255, o >> 8 & 255, o & 255];
}
return i;
}
let Ke;
function Hr(i) {
Ke || (Ke = Vr(), Ke.transparent = [0, 0, 0, 0]);
const t = Ke[i.toLowerCase()];
return t && {
r: t[0],
g: t[1],
b: t[2],
a: t.length === 4 ? t[3] : 255
};
}
const Ur = /^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;
function Yr(i) {
const t = Ur.exec(i);
let e = 255, s, n, o;
if (t) {
if (t[7] !== s) {
const r = +t[7];
e = t[8] ? ye(r) : Pt(r * 255, 0, 255);
}
return s = +t[1], n = +t[3], o = +t[5], s = 255 & (t[2] ? ye(s) : Pt(s, 0, 255)), n = 255 & (t[4] ? ye(n) : Pt(n, 0, 255)), o = 255 & (t[6] ? ye(o) : Pt(o, 0, 255)), {
r: s,
g: n,
b: o,
a: e
};
}
}
function Xr(i) {
return i && (i.a < 255 ? `rgba(${i.r}, ${i.g}, ${i.b}, ${yt(i.a)})` : `rgb(${i.r}, ${i.g}, ${i.b})`);
}
const Ii = (i) => i <= 31308e-7 ? i * 12.92 : Math.pow(i, 1 / 2.4) * 1.055 - 0.055, ne = (i) => i <= 0.04045 ? i / 12.92 : Math.pow((i + 0.055) / 1.055, 2.4);
function Kr(i, t, e) {
const s = ne(yt(i.r)), n = ne(yt(i.g)), o = ne(yt(i.b));
return {
r: Tt(Ii(s + e * (ne(yt(t.r)) - s))),
g: Tt(Ii(n + e * (ne(yt(t.g)) - n))),
b: Tt(Ii(o + e * (ne(yt(t.b)) - o))),
a: i.a + e * (t.a - i.a)
};
}
function qe(i, t, e) {
if (i) {
let s = gs(i);
s[t] = Math.max(0, Math.min(s[t] + s[t] * e, t === 0 ? 360 : 1)), s = ms(s), i.r = s[0], i.g = s[1], i.b = s[2];
}
}
function co(i, t) {
return i && Object.assign(t || {}, i);
}
function $s(i) {
var t = { r: 0, g: 0, b: 0, a: 255 };
return Array.isArray(i) ? i.length >= 3 && (t = { r: i[0], g: i[1], b: i[2], a: 255 }, i.length > 3 && (t.a = Tt(i[3]))) : (t = co(i, { r: 0, g: 0, b: 0, a: 1 }), t.a = Tt(t.a)), t;
}
function qr(i) {
return i.charAt(0) === "r" ? Yr(i) : jr(i);
}
class Ee {
constructor(t) {
if (t instanceof Ee)
return t;
const e = typeof t;
let s;
e === "object" ? s = $s(t) : e === "string" && (s = Tr(t) || Hr(t) || qr(t)), this._rgb = s, this._valid = !!s;
}
get valid() {
return this._valid;
}
get rgb() {
var t = co(this._rgb);
return t && (t.a = yt(t.a)), t;
}
set rgb(t) {
this._rgb = $s(t);
}
rgbString() {
return this._valid ? Xr(this._rgb) : void 0;
}
hexString() {
return this._valid ? Lr(this._rgb) : void 0;
}
hslString() {
return this._valid ? Nr(this._rgb) : void 0;
}
mix(t, e) {
if (t) {
const s = this.rgb, n = t.rgb;
let o;
const r = e === o ? 0.5 : e, a = 2 * r - 1, l = s.a - n.a, c = ((a * l === -1 ? a : (a + l) / (1 + a * l)) + 1) / 2;
o = 1 - c, s.r = 255 & c * s.r + o * n.r + 0.5, s.g = 255 & c * s.g + o * n.g + 0.5, s.b = 255 & c * s.b + o * n.b + 0.5, s.a = r * s.a + (1 - r) * n.a, this.rgb = s;
}
return this;
}
interpolate(t, e) {
return t && (this._rgb = Kr(this._rgb, t._rgb, e)), this;
}
clone() {
return new Ee(this.rgb);
}
alpha(t) {
return this._rgb.a = Tt(t), this;
}
clearer(t) {
const e = this._rgb;
return e.a *= 1 - t, this;
}
greyscale() {
const t = this._rgb, e = We(t.r * 0.3 + t.g * 0.59 + t.b * 0.11);
return t.r = t.g = t.b = e, this;
}
opaquer(t) {
const e = this._rgb;
return e.a *= 1 + t, this;
}
negate() {
const t = this._rgb;
return t.r = 255 - t.r, t.g = 255 - t.g, t.b = 255 - t.b, this;
}
lighten(t) {
return qe(this._rgb, 2, t), this;
}
darken(t) {
return qe(this._rgb, 2, -t), this;
}
saturate(t) {
return qe(this._rgb, 1, t), this;
}
desaturate(t) {
return qe(this._rgb, 1, -t), this;
}
rotate(t) {
return Wr(this._rgb, t), this;
}
}
/*!
* Chart.js v4.4.7
* https://www.chartjs.org
* (c) 2024 Chart.js Contributors
* Released under the MIT License
*/
function bt() {
}
const Gr = /* @__PURE__ */ (() => {
let i = 0;
return () => i++;
})();
function E(i) {
return i == null;
}
function $(i) {
if (Array.isArray && Array.isArray(i))
return !0;
const t = Object.prototype.toString.call(i);
return t.slice(0, 7) === "[object" && t.slice(-6) === "Array]";
}
function A(i) {
return i !== null && Object.prototype.toString.call(i) === "[object Object]";
}
function V(i) {
return (typeof i == "number" || i instanceof Number) && isFinite(+i);
}
function nt(i, t) {
return V(i) ? i : t;
}
function C(i, t) {
return typeof i > "u" ? t : i;
}
const Zr = (i, t) => typeof i == "string" && i.endsWith("%") ? parseFloat(i) / 100 : +i / t, ho = (i, t) => typeof i == "string" && i.endsWith("%") ? parseFloat(i) / 100 * t : +i;
function F(i, t, e) {
if (i && typeof i.call == "function")
return i.apply(e, t);
}
function L(i, t, e, s) {
let n, o, r;
if ($(i))
for (o = i.length, n = 0; n < o; n++)
t.call(e, i[n], n);
else if (A(i))
for (r = Object.keys(i), o = r.length, n = 0; n < o; n++)
t.call(e, i[r[n]], r[n]);
}
function yi(i, t) {
let e, s, n, o;
if (!i || !t || i.length !== t.length)
return !1;
for (e = 0, s = i.length; e < s; ++e)
if (n = i[e], o = t[e], n.datasetIndex !== o.datasetIndex || n.index !== o.index)
return !1;
return !0;
}
function vi(i) {
if ($(i))
return i.map(vi);
if (A(i)) {
const t = /* @__PURE__ */ Object.create(null), e = Object.keys(i), s = e.length;
let n = 0;
for (; n < s; ++n)
t[e[n]] = vi(i[e[n]]);
return t;
}
return i;
}
function fo(i) {
return [
"__proto__",
"prototype",
"constructor"
].indexOf(i) === -1;
}
function Qr(i, t, e, s) {
if (!fo(i))
return;
const n = t[i], o = e[i];
A(n) && A(o) ? Le(n, o, s) : t[i] = vi(o);
}
function Le(i, t, e) {
const s = $(t) ? t : [
t
], n = s.length;
if (!A(i))
return i;
e = e || {};
const o = e.merger || Qr;
let r;
for (let a = 0; a < n; ++a) {
if (r = s[a], !A(r))
continue;
const l = Object.keys(r);
for (let c = 0, h = l.length; c < h; ++c)
o(l[c], i, r, e);
}
return i;
}
function Ce(i, t) {
return Le(i, t, {
merger: Jr
});
}
function Jr(i, t, e) {
if (!fo(i))
return;
const s = t[i], n = e[i];
A(s) && A(n) ? Ce(s, n) : Object.prototype.hasOwnProperty.call(t, i) || (t[i] = vi(n));
}
const js = {
// Chart.helpers.core resolveObjectKey should resolve empty key to root object
"": (i) => i,
// default resolvers
x: (i) => i.x,
y: (i) => i.y
};
function ta(i) {
const t = i.split("."), e = [];
let s = "";
for (const n of t)
s += n, s.endsWith("\\") ? s = s.slice(0, -1) + "." : (e.push(s), s = "");
return e;
}
function ea(i) {
const t = ta(i);
return (e) => {
for (const s of t) {
if (s === "")
break;
e = e && e[s];
}
return e;
};
}
function Et(i, t) {
return (js[t] || (js[t] = ea(t)))(i);
}
function bs(i) {
return i.charAt(0).toUpperCase() + i.slice(1);
}
const Re = (i) => typeof i < "u", Lt = (i) => typeof i == "function", Ws = (i, t) => {
if (i.size !== t.size)
return !1;
for (const e of i)
if (!t.has(e))
return !1;
return !0;
};
function ia(i) {
return i.type === "mouseup" || i.type === "click" || i.type === "contextmenu";
}
const I = Math.PI, z = 2 * I, sa = z + I, wi = Number.POSITIVE_INFINITY, na = I / 180, U = I / 2, jt = I / 4, Ns = I * 2 / 3, Ct = Math.log10, pt = Math.sign;
function De(i, t, e) {
return Math.abs(i - t) < e;
}
function Vs(i) {
const t = Math.round(i);
i = De(i, t, i / 1e3) ? t : i;
const e = Math.pow(10, Math.floor(Ct(i))), s = i / e;
return (s <= 1 ? 1 : s <= 2 ? 2 : s <= 5 ? 5 : 10) * e;
}
function oa(i) {
const t = [], e = Math.sqrt(i);
let s;
for (s = 1; s < e; s++)
i % s === 0 && (t.push(s), t.push(i / s));
return e === (e | 0) && t.push(e), t.sort((n, o) => n - o).pop(), t;
}
function ae(i) {
return !isNaN(parseFloat(i)) && isFinite(i);
}
function ra(i, t) {
const e = Math.round(i);
return e - t <= i && e + t >= i;
}
function uo(i, t, e) {
let s, n, o;
for (s = 0, n = i.length; s < n; s++)
o = i[s][e], isNaN(o) || (t.min = Math.min(t.min, o), t.max = Math.max(t.max, o));
}
function ht(i) {
return i * (I / 180);
}
function xs(i) {
return i * (180 / I);
}
function Hs(i) {
if (!V(i))
return;
let t = 1, e = 0;
for (; Math.round(i * t) / t !== i; )
t *= 10, e++;
return e;
}
function go(i, t) {
const e = t.x - i.x, s = t.y - i.y, n = Math.sqrt(e * e + s * s);
let o = Math.atan2(s, e);
return o < -0.5 * I && (o += z), {
angle: o,
distance: n
};
}
function Zi(i, t) {
return Math.sqrt(Math.pow(t.x - i.x, 2) + Math.pow(t.y - i.y, 2));
}
function aa(i, t) {
return (i - t + sa) % z - I;
}
function ot(i) {
return (i % z + z) % z;
}
function Fe(i, t, e, s) {
const n = ot(i), o = ot(t), r = ot(e), a = ot(o - n), l = ot(r - n), c = ot(n - o), h = ot(n - r);
return n === o || n === r || s && o === r || a > l && c < h;
}
function K(i, t, e) {
return Math.max(t, Math.min(e, i));
}
function la(i) {
return K(i, -32768, 32767);
}
function vt(i, t, e, s = 1e-6) {
return i >= Math.min(t, e) - s && i <= Math.max(t, e) + s;
}
function _s(i, t, e) {
e = e || ((r) => i[r] < t);
let s = i.length - 1, n = 0, o;
for (; s - n > 1; )
o = n + s >> 1, e(o) ? n = o : s = o;
return {
lo: n,
hi: s
};
}
const wt = (i, t, e, s) => _s(i, e, s ? (n) => {
const o = i[n][t];
return o < e || o === e && i[n + 1][t] === e;
} : (n) => i[n][t] < e), ca = (i, t, e) => _s(i, e, (s) => i[s][t] >= e);
function ha(i, t, e) {
let s = 0, n = i.length;
for (; s < n && i[s] < t; )
s++;
for (; n > s && i[n - 1] > e; )
n--;
return s > 0 || n < i.length ? i.slice(s, n) : i;
}
const po = [
"push",
"pop",
"shift",
"splice",
"unshift"
];
function da(i, t) {
if (i._chartjs) {
i._chartjs.listeners.push(t);
return;
}
Object.defineProperty(i, "_chartjs", {
configurable: !0,
enumerable: !1,
value: {
listeners: [
t
]
}
}), po.forEach((e) => {
const s = "_onData" + bs(e), n = i[e];
Object.defineProperty(i, e, {
configurable: !0,
enumerable: !1,
value(...o) {
const r = n.apply(this, o);
return i._chartjs.listeners.forEach((a) => {
typeof a[s] == "function" && a[s](...o);
}), r;
}
});
});
}
function Us(i, t) {
const e = i._chartjs;
if (!e)
return;
const s = e.listeners, n = s.indexOf(t);
n !== -1 && s.splice(n, 1), !(s.length > 0) && (po.forEach((o) => {
delete i[o];
}), delete i._chartjs);
}
function mo(i) {
const t = new Set(i);
return t.size === i.length ? i : Array.from(t);
}
const bo = function() {
return typeof window > "u" ? function(i) {
return i();
} : window.requestAnimationFrame;
}();
function xo(i, t) {
let e = [], s = !1;
return function(...n) {
e = n, s || (s = !0, bo.call(window, () => {
s = !1, i.apply(t, e);
}));
};
}
function fa(i, t) {
let e;
return function(...s) {
return t ? (clearTimeout(e), e = setTimeout(i, t, s)) : i.apply(this, s), t;
};
}
const ys = (i) => i === "start" ? "left" : i === "end" ? "right" : "center", Z = (i, t, e) => i === "start" ? t : i === "end" ? e : (t + e) / 2, ua = (i, t, e, s) => i === (s ? "left" : "right") ? e : i === "center" ? (t + e) / 2 : t;
function _o(i, t, e) {
const s = t.length;
let n = 0, o = s;
if (i._sorted) {
const { iScale: r, _parsed: a } = i, l = r.axis, { min: c, max: h, minDefined: d, maxDefined: f } = r.getUserBounds();
d && (n = K(Math.min(
// @ts-expect-error Need to type _parsed
wt(a, l, c).lo,
// @ts-expect-error Need to fix types on _lookupByKey
e ? s : wt(t, l, r.getPixelForValue(c)).lo
), 0, s - 1)), f ? o = K(Math.max(
// @ts-expect-error Need to type _parsed
wt(a, r.axis, h, !0).hi + 1,
// @ts-expect-error Need to fix types on _lookupByKey
e ? 0 : wt(t, l, r.getPixelForValue(h), !0).hi + 1
), n, s) - n : o = s - n;
}
return {
start: n,
count: o
};
}
function yo(i) {
const { xScale: t, yScale: e, _scaleRanges: s } = i, n = {
xmin: t.min,
xmax: t.max,
ymin: e.min,
ymax: e.max
};
if (!s)
return i._scaleRanges = n, !0;
const o = s.xmin !== t.min || s.xmax !== t.max || s.ymin !== e.min || s.ymax !== e.max;
return Object.assign(s, n), o;
}
const Ge = (i) => i === 0 || i === 1, Ys = (i, t, e) => -(Math.pow(2, 10 * (i -= 1)) * Math.sin((i - t) * z / e)), Xs = (i, t, e) => Math.pow(2, -10 * i) * Math.sin((i - t) * z / e) + 1, Oe = {
linear: (i) => i,
easeInQuad: (i) => i * i,
easeOutQuad: (i) => -i * (i - 2),
easeInOutQuad: (i) => (i /= 0.5) < 1 ? 0.5 * i * i : -0.5 * (--i * (i - 2) - 1),
easeInCubic: (i) => i * i * i,
easeOutCubic: (i) => (i -= 1) * i * i + 1,
easeInOutCubic: (i) => (i /= 0.5) < 1 ? 0.5 * i * i * i : 0.5 * ((i -= 2) * i * i + 2),
easeInQuart: (i) => i * i * i * i,
easeOutQuart: (i) => -((i -= 1) * i * i * i - 1),
easeInOutQuart: (i) => (i /= 0.5) < 1 ? 0.5 * i * i * i * i : -0.5 * ((i -= 2) * i * i * i - 2),
easeInQuint: (i) => i * i * i * i * i,
easeOutQuint: (i) => (i -= 1) * i * i * i * i + 1,
easeInOutQuint: (i) => (i /= 0.5) < 1 ? 0.5 * i * i * i * i * i : 0.5 * ((i -= 2) * i * i * i * i + 2),
easeInSine: (i) => -Math.cos(i * U) + 1,
easeOutSine: (i) => Math.sin(i * U),
easeInOutSine: (i) => -0.5 * (Math.cos(I * i) - 1),
easeInExpo: (i) => i === 0 ? 0 : Math.pow(2, 10 * (i - 1)),
easeOutExpo: (i) => i === 1 ? 1 : -Math.pow(2, -10 * i) + 1,
easeInOutExpo: (i) => Ge(i) ? i : i < 0.5 ? 0.5 * Math.pow(2, 10 * (i * 2 - 1)) : 0.5 * (-Math.pow(2, -10 * (i * 2 - 1)) + 2),
easeInCirc: (i) => i >= 1 ? i : -(Math.sqrt(1 - i * i) - 1),
easeOutCirc: (i) => Math.sqrt(1 - (i -= 1) * i),
easeInOutCirc: (i) => (i /= 0.5) < 1 ? -0.5 * (Math.sqrt(1 - i * i) - 1) : 0.5 * (Math.sqrt(1 - (i -= 2) * i) + 1),
easeInElastic: (i) => Ge(i) ? i : Ys(i, 0.075, 0.3),
easeOutElastic: (i) => Ge(i) ? i : Xs(i, 0.075, 0.3),
easeInOutElastic(i) {
return Ge(i) ? i : i < 0.5 ? 0.5 * Ys(i * 2, 0.1125, 0.45) : 0.5 + 0.5 * Xs(i * 2 - 1, 0.1125, 0.45);
},
easeInBack(i) {
return i * i * ((1.70158 + 1) * i - 1.70158);
},
easeOutBack(i) {
return (i -= 1) * i * ((1.70158 + 1) * i + 1.70158) + 1;
},
easeInOutBack(i) {
let t = 1.70158;
return (i /= 0.5) < 1 ? 0.5 * (i * i * (((t *= 1.525) + 1) * i - t)) : 0.5 * ((i -= 2) * i * (((t *= 1.525) + 1) * i + t) + 2);
},
easeInBounce: (i) => 1 - Oe.easeOutBounce(1 - i),
easeOutBounce(i) {
return i < 1 / 2.75 ? 7.5625 * i * i : i < 2 / 2.75 ? 7.5625 * (i -= 1.5 / 2.75) * i + 0.75 : i < 2.5 / 2.75 ? 7.5625 * (i -= 2.25 / 2.75) * i + 0.9375 : 7.5625 * (i -= 2.625 / 2.75) * i + 0.984375;
},
easeInOutBounce: (i) => i < 0.5 ? Oe.easeInBounce(i * 2) * 0.5 : Oe.easeOutBounce(i * 2 - 1) * 0.5 + 0.5
};
function vs(i) {
if (i && typeof i == "object") {
const t = i.toString();
return t === "[object CanvasPattern]" || t === "[object CanvasGradient]";
}
return !1;
}
function Ks(i) {
return vs(i) ? i : new Ee(i);
}
function Bi(i) {
return vs(i) ? i : new Ee(i).saturate(0.5).darken(0.1).hexString();
}
const ga = [
"x",
"y",
"borderWidth",
"radius",
"tension"
], pa = [
"color",
"borderColor",
"backgroundColor"
];
function ma(i) {
i.set("animation", {
delay: void 0,
duration: 1e3,
easing: "easeOutQuart",
fn: void 0,
from: void 0,
loop: void 0,
to: void 0,
type: void 0
}), i.describe("animation", {
_fallback: !1,
_indexable: !1,
_scriptable: (t) => t !== "onProgress" && t !== "onComplete" && t !== "fn"
}), i.set("animations", {
colors: {
type: "color",
properties: pa
},
numbers: {
type: "number",
properties: ga
}
}), i.describe("animations", {
_fallback: "animation"
}), i.set("transitions", {
active: {
animation: {
duration: 400
}
},
resize: {
animation: {
duration: 0
}
},
show: {
animations: {
colors: {
from: "transparent"
},
visible: {
type: "boolean",
duration: 0
}
}
},
hide: {
animations: {
colors: {
to: "transparent"
},
visible: {
type: "boolean",
easing: "linear",
fn: (t) => t | 0
}
}
}
});
}
function ba(i) {
i.set("layout", {
autoPadding: !0,
padding: {
top: 0,
right: 0,
bottom: 0,
left: 0
}
});
}
const qs = /* @__PURE__ */ new Map();
function xa(i, t) {
t = t || {};
const e = i + JSON.stringify(t);
let s = qs.get(e);
return s || (s = new Intl.NumberFormat(i, t), qs.set(e, s)), s;
}
function Ne(i, t, e) {
return xa(t, e).format(i);
}
const vo = {
values(i) {
return $(i) ? i : "" + i;
},
numeric(i, t, e) {
if (i === 0)
return "0";
const s = this.chart.options.locale;
let n, o = i;
if (e.length > 1) {
const c = Math.max(Math.abs(e[0].value), Math.abs(e[e.length - 1].value));
(c < 1e-4 || c > 1e15) && (n = "scientific"), o = _a(i, e);
}
const r = Ct(Math.abs(o)), a = isNaN(r) ? 1 : Math.max(Math.min(-1 * Math.floor(r), 20), 0), l = {
notation: n,
minimumFractionDigits: a,
maximumFractionDigits: a
};
return Object.assign(l, this.options.ticks.format), Ne(i, s, l);
},
logarithmic(i, t, e) {
if (i === 0)
return "0";
const s = e[t].significand || i / Math.pow(10, Math.floor(Ct(i)));
return [
1,
2,
3,
5,
10,
15
].includes(s) || t > 0.8 * e.length ? vo.numeric.call(this, i, t, e) : "";
}
};
function _a(i, t) {
let e = t.length > 3 ? t[2].value - t[1].value : t[1].value - t[0].value;
return Math.abs(e) >= 1 && i !== Math.floor(i) && (e = i - Math.floor(i)), e;
}
var Oi = {
formatters: vo
};
function ya(i) {
i.set("scale", {
display: !0,
offset: !1,
reverse: !1,
beginAtZero: !1,
bounds: "ticks",
clip: !0,
grace: 0,
grid: {
display: !0,
lineWidth: 1,
drawOnChartArea: !0,
drawTicks: !0,
tickLength: 8,
tickWidth: (t, e) => e.lineWidth,
tickColor: (t, e) => e.color,
offset: !1
},
border: {
display: !0,
dash: [],
dashOffset: 0,
width: 1
},
title: {
display: !1,
text: "",
padding: {
top: 4,
bottom: 4
}
},
ticks: {
minRotation: 0,
maxRotation: 50,
mirror: !1,
textStrokeWidth: 0,
textStrokeColor: "",
padding: 3,
display: !0,
autoSkip: !0,
autoSkipPadding: 3,
labelOffset: 0,
callback: Oi.formatters.values,
minor: {},
major: {},
align: "center",
crossAlign: "near",
showLabelBackdrop: !1,
backdropColor: "rgba(255, 255, 255, 0.75)",
backdropPadding: 2
}
}), i.route("scale.ticks", "color", "", "color"), i.route("scale.grid", "color", "", "borderColor"), i.route("scale.border", "color", "", "borderColor"), i.route("scale.title", "color", "", "color"), i.describe("scale", {
_fallback: !1,
_scriptable: (t) => !t.startsWith("before") && !t.startsWith("after") && t !== "callback" && t !== "parser",
_indexable: (t) => t !== "borderDash" && t !== "tickBorderDash" && t !== "dash"
}), i.describe("scales", {
_fallback: "scale"
}), i.describe("scale.ticks", {
_scriptable: (t) => t !== "backdropPadding" && t !== "callback",
_indexable: (t) => t !== "backdropPadding"
});
}
const qt = /* @__PURE__ */ Object.create(null), Qi = /* @__PURE__ */ Object.create(null);
function Ae(i, t) {
if (!t)
return i;
const e = t.split(".");
for (let s = 0, n = e.length; s < n; ++s) {
const o = e[s];
i = i[o] || (i[o] = /* @__PURE__ */ Object.create(null));
}
return i;
}
function $i(i, t, e) {
return typeof t == "string" ? Le(Ae(i, t), e) : Le(Ae(i, ""), t);
}
class va {
constructor(t, e) {
this.animation = void 0, this.backgroundColor = "rgba(0,0,0,0.1)", this.borderColor = "rgba(0,0,0,0.1)", this.color = "#666", this.datasets = {}, this.devicePixelRatio = (s) => s.chart.platform.getDevicePixelRatio(), this.elements = {}, this.events = [
"mousemove",
"mouseout",
"click",
"touchstart",
"touchmove"
], this.font = {
family: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",
size: 12,
style: "normal",
lineHeight: 1.2,
weight: null
}, this.hover = {}, this.hoverBackgroundColor = (s, n) => Bi(n.backgroundColor), this.hoverBorderColor = (s, n) => Bi(n.borderColor), this.hoverColor = (s, n) => Bi(n.color), this.indexAxis = "x", this.interaction = {
mode: "nearest",
intersect: !0,
includeInvisible: !1
}, this.maintainAspectRatio = !0, this.onHover = null, this.onClick = null, this.parsing = !0, this.plugins = {}, this.responsive = !0, this.scale = void 0, this.scales = {}, this.showLine = !0, this.drawActiveElementsOnTop = !0, this.describe(t), this.apply(e);
}
set(t, e) {
return $i(this, t, e);
}
get(t) {
return Ae(this, t);
}
describe(t, e) {
return $i(Qi, t, e);
}
override(t, e) {
return $i(qt, t, e);
}
route(t, e, s, n) {
const o = Ae(this, t), r = Ae(this, s), a = "_" + e;
Object.defineProperties(o, {
[a]: {
value: o[e],
writable: !0
},
[e]: {
enumerable: !0,
get() {
const l = this[a], c = r[n];
return A(l) ? Object.assign({}, c, l) : C(l, c);
},
set(l) {
this[a] = l;
}
}
});
}
apply(t) {
t.forEach((e) => e(this));
}
}
var j = /* @__PURE__ */ new va({
_scriptable: (i) => !i.startsWith("on"),
_indexable: (i) => i !== "events",
hover: {
_fallback: "interaction"
},
interaction: {
_scriptable: !1,
_indexable: !1
}
}, [
ma,
ba,
ya
]);
function wa(i) {
return !i || E(i.size) || E(i.family) ? null : (i.style ? i.style + " " : "") + (i.weight ? i.weight + " " : "") + i.size + "px " + i.family;
}
function ki(i, t, e, s, n) {
let o = t[n];
return o || (o = t[n] = i.measureText(n).width, e.push(n)), o > s && (s = o), s;
}
function ka(i, t, e, s) {
s = s || {};
let n = s.data = s.data || {}, o = s.garbageCollect = s.garbageCollect || [];
s.font !== t && (n = s.data = {}, o = s.garbageCollect = [], s.font = t), i.save(), i.font = t;
let r = 0;
const a = e.length;
let l, c, h, d, f;
for (l = 0; l < a; l++)
if (d = e[l], d != null && !$(d))
r = ki(i, n, o, r, d);
else if ($(d))
for (c = 0, h = d.length; c < h; c++)
f = d[c], f != null && !$(f) && (r = ki(i, n, o, r, f));
i.restore();
const u = o.length / 2;
if (u > e.length) {
for (l = 0; l < u; l++)
delete n[o[l]];
o.splice(0, u);
}
return r;
}
function Wt(i, t, e) {
const s = i.currentDevicePixelRatio, n = e !== 0 ? Math.max(e / 2, 0.5) : 0;
return Math.round((t - n) * s) / s + n;
}
function Gs(i, t) {
!t && !i || (t = t || i.getContext("2d"), t.save(), t.resetTransform(), t.clearRect(0, 0, i.width, i.height), t.restore());
}
function Ji(i, t, e, s) {
wo(i, t, e, s, null);
}
function wo(i, t, e, s, n) {
let o, r, a, l, c, h, d, f;
const u = t.pointStyle, g = t.rotation, p = t.radius;
let m = (g || 0) * na;
if (u && typeof u == "object" && (o = u.toString(), o === "[object HTMLImageElement]" || o === "[object HTMLCanvasElement]")) {
i.save(), i.translate(e, s), i.rotate(m), i.drawImage(u, -u.width / 2, -u.height / 2, u.width, u.height), i.restore();
return;
}
if (!(isNaN(p) || p <= 0)) {
switch (i.beginPath(), u) {
// Default includes circle
default:
n ? i.ellipse(e, s, n / 2, p, 0, 0, z) : i.arc(e, s, p, 0, z), i.closePath();
break;
case "triangle":
h = n ? n / 2 : p, i.moveTo(e + Math.sin(m) * h, s - Math.cos(m) * p), m += Ns, i.lineTo(e + Math.sin(m) * h, s - Math.cos(m) * p), m += Ns, i.lineTo(e + Math.sin(m) * h, s - Math.cos(m) * p), i.closePath();
break;
case "rectRounded":
c = p * 0.516, l = p - c, r = Math.cos(m + jt) * l, d = Math.cos(m + jt) * (n ? n / 2 - c : l), a = Math.sin(m + jt) * l, f = Math.sin(m + jt) * (n ? n / 2 - c : l), i.arc(e - d, s - a, c, m - I, m - U), i.arc(e + f, s - r, c, m - U, m), i.arc(e + d, s + a, c, m, m + U), i.arc(e - f, s + r, c, m + U, m + I), i.closePath();
break;
case "rect":
if (!g) {
l = Math.SQRT1_2 * p, h = n ? n / 2 : l, i.rect(e - h, s - l, 2 * h, 2 * l);
break;
}
m += jt;
/* falls through */
case "rectRot":
d = Math.cos(m) * (n ? n / 2 : p), r = Math.cos(m) * p, a = Math.sin(m) * p, f = Math.sin(m) * (n ? n / 2 : p), i.moveTo(e - d, s - a), i.lineTo(e + f, s - r), i.lineTo(e + d, s + a), i.lineTo(e - f, s + r), i.closePath();
break;
case "crossRot":
m += jt;
/* falls through */
case "cross":
d = Math.cos(m) * (n ? n / 2 : p), r = Math.cos(m) * p, a = Math.sin(m) * p, f = Math.sin(m) * (n ? n / 2 : p), i.moveTo(e - d, s - a), i.lineTo(e + d, s + a), i.moveTo(e + f, s - r), i.lineTo(e - f, s + r);
break;
case "star":
d = Math.cos(m) * (n ? n / 2 : p), r = Math.cos(m) * p, a = Math.sin(m) * p, f = Math.sin(m) * (n ? n / 2 : p), i.moveTo(e - d, s - a), i.lineTo(e + d, s + a), i.moveTo(e + f, s - r), i.lineTo(e - f, s + r), m += jt, d = Math.cos(m) * (n ? n / 2 : p), r = Math.cos(m) * p, a = Math.sin(m) * p, f = Math.sin(m) * (n ? n / 2 : p), i.moveTo(e - d, s - a), i.lineTo(e + d, s + a), i.moveTo(e + f, s - r), i.lineTo(e - f, s + r);
break;
case "line":
r = n ? n / 2 : Math.cos(m) * p, a = Math.sin(m) * p, i.moveTo(e - r, s - a), i.lineTo(e + r, s + a);
break;
case "dash":
i.moveTo(e, s), i.lineTo(e + Math.cos(m) * (n ? n / 2 : p), s + Math.sin(m) * p);
break;
case !1:
i.closePath();
break;
}
i.fill(), t.borderWidth > 0 && i.stroke();
}
}
function kt(i, t, e) {
return e = e || 0.5, !t || i && i.x > t.left - e && i.x < t.right + e && i.y > t.top - e && i.y < t.bottom + e;
}
function Ai(i, t) {
i.save(), i.beginPath(), i.rect(t.left, t.top, t.right - t.left, t.bottom - t.top), i.clip();
}
function Ti(i) {
i.restore();
}
function Sa(i, t, e, s, n) {
if (!t)
return i.lineTo(e.x, e.y);
if (n === "middle") {
const o = (t.x + e.x) / 2;
i.lineTo(o, t.y), i.lineTo(o, e.y);
} else n === "after" != !!s ? i.lineTo(t.x, e.y) : i.lineTo(e.x, t.y);
i.lineTo(e.x, e.y);
}
function Ma(i, t, e, s) {
if (!t)
return i.lineTo(e.x, e.y);
i.bezierCurveTo(s ? t.cp1x : t.cp2x, s ? t.cp1y : t.cp2y, s ? e.cp2x : e.cp1x, s ? e.cp2y : e.cp1y, e.x, e.y);
}
function Pa(i, t) {
t.translation && i.translate(t.translation[0], t.translation[1]), E(t.rotation) || i.rotate(t.rotation), t.color && (i.fillStyle = t.color), t.textAlign && (i.textAlign = t.textAlign), t.textBaseline && (i.textBaseline = t.textBaseline);
}
function Ca(i, t, e, s, n) {
if (n.strikethrough || n.underline) {
const o = i.measureText(s), r = t - o.actualBoundingBoxLeft, a = t + o.actualBoundingBoxRight, l = e - o.actualBoundingBoxAscent, c = e + o.actualBoundingBoxDescent, h = n.strikethrough ? (l + c) / 2 : c;
i.strokeStyle = i.fillStyle, i.beginPath(), i.lineWidth = n.decorationWidth || 2, i.moveTo(r, h), i.lineTo(a, h), i.stroke();
}
}
function Da(i, t) {
const e = i.fillStyle;
i.fillStyle = t.color, i.fillRect(t.left, t.top, t.width, t.height), i.fillStyle = e;
}
function Gt(i, t, e, s, n, o = {}) {
const r = $(t) ? t : [
t
], a = o.strokeWidth > 0 && o.strokeColor !== "";
let l, c;
for (i.save(), i.font = n.string, Pa(i, o), l = 0; l < r.length; ++l)
c = r[l], o.backdrop && Da(i, o.backdrop), a && (o.strokeColor && (i.strokeStyle = o.strokeColor), E(o.strokeWidth) || (i.lineWidth = o.strokeWidth), i.strokeText(c, e, s, o.maxWidth)), i.fillText(c, e, s, o.maxWidth), Ca(i, e, s, c, o), s += Number(n.lineHeight);
i.restore();
}
function ze(i, t) {
const { x: e, y: s, w: n, h: o, radius: r } = t;
i.arc(e + r.topLeft, s + r.topLeft, r.topLeft, 1.5 * I, I, !0), i.lineTo(e, s + o - r.bottomLeft), i.arc(e + r.bottomLeft, s + o - r.bottomLeft, r.bottomLeft, I, U, !0), i.lineTo(e + n - r.bottomRight, s + o), i.arc(e + n - r.bottomRight, s + o - r.bottomRight, r.bottomRight, U, 0, !0), i.lineTo(e + n, s + r.topRight), i.arc(e + n - r.topRight, s + r.topRight, r.topRight, 0, -U, !0), i.lineTo(e + r.topLeft, s);
}
const Oa = /^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/, Aa = /^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;
function Ta(i, t) {
const e = ("" + i).match(Oa);
if (!e || e[1] === "normal")
return t * 1.2;
switch (i = +e[2], e[3]) {
case "px":
return i;
case "%":
i /= 100;
break;
}
return t * i;
}
const Ea = (i) => +i || 0;
function ws(i, t) {
const e = {}, s = A(t), n = s ? Object.keys(t) : t, o = A(i) ? s ? (r) => C(i[r], i[t[r]]) : (r) => i[r] : () => i;
for (const r of n)
e[r] = Ea(o(r));
return e;
}
function ko(i) {
return ws(i, {
top: "y",
right: "x",
bottom: "y",
left: "x"
});
}
function Xt(i) {
return ws(i, [
"topLeft",
"topRight",
"bottomLeft",
"bottomRight"
]);
}
function J(i) {
const t = ko(i);
return t.width = t.left + t.right, t.height = t.top + t.bottom, t;
}
function Y(i, t) {
i = i || {}, t = t || j.font;
let e = C(i.size, t.size);
typeof e == "string" && (e = parseInt(e, 10));
let s = C(i.style, t.style);
s && !("" + s).match(Aa) && (console.warn('Invalid font style specified: "' + s + '"'), s = void 0);
const n = {
family: C(i.family, t.family),
lineHeight: Ta(C(i.lineHeight, t.lineHeight), e),
size: e,
style: s,
weight: C(i.weight, t.weight),
string: ""
};
return n.string = wa(n), n;
}
function ve(i, t, e, s) {
let n, o, r;
for (n = 0, o = i.length; n < o; ++n)
if (r = i[n], r !== void 0 && r !== void 0)
return r;
}
function La(i, t, e) {
const { min: s, max: n } = i, o = ho(t, (n - s) / 2), r = (a, l) => e && a === 0 ? 0 : a + l;
return {
min: r(s, -Math.abs(o)),
max: r(n, o)
};
}
function It(i, t) {
return Object.assign(Object.create(i), t);
}
function ks(i, t = [
""
], e, s, n = () => i[0]) {
const o = e || i;
typeof s > "u" && (s = Co("_fallback", i));
const r = {
[Symbol.toStringTag]: "Object",
_cacheable: !0,
_scopes: i,
_rootScopes: o,
_fallback: s,
_getTarget: n,
override: (a) => ks([
a,
...i
], t, o, s)
};
return new Proxy(r, {
/**
* A trap for the delete operator.
*/
deleteProperty(a, l) {
return delete a[l], delete a._keys, delete i[0][l], !0;
},
/**
* A trap for getting property values.
*/
get(a, l) {
return Mo(a, l, () => Wa(l, t, i, a));
},
/**
* A trap for Object.getOwnPropertyDescriptor.
* Also used by Object.hasOwnProperty.
*/
getOwnPropertyDescriptor(a, l) {
return Reflect.getOwnPropertyDescriptor(a._scopes[0], l);
},
/**
* A trap for Object.getPrototypeOf.
*/
getPrototypeOf() {
return Reflect.getPrototypeOf(i[0]);
},
/**
* A trap for the in operator.
*/
has(a, l) {
return Qs(a).includes(l);
},
/**
* A trap for Object.getOwnPropertyNames and Object.getOwnPropertySymbols.
*/
ownKeys(a) {
return Qs(a);
},
/**
* A trap for setting property values.
*/
set(a, l, c) {
const h = a._storage || (a._storage = n());
return a[l] = h[l] = c, delete a._keys, !0;
}
});
}
function le(i, t, e, s) {
const n = {
_cacheable: !1,
_proxy: i,
_context: t,
_subProxy: e,
_stack: /* @__PURE__ */ new Set(),
_descriptors: So(i, s),
setContext: (o) => le(i, o, e, s),
override: (o) => le(i.override(o), t, e, s)
};
return new Proxy(n, {
/**
* A trap for the delete operator.
*/
deleteProperty(o, r) {
return delete o[r], delete i[r], !0;
},
/**
* A trap for getting property values.
*/
get(o, r, a) {
return Mo(o, r, () => Fa(o, r, a));
},
/**
* A trap for Object.getOwnPropertyDescriptor.
* Also used by Object.hasOwnProperty.
*/
getOwnPropertyDescriptor(o, r) {
return o._descriptors.allKeys ? Reflect.has(i, r) ? {
enumerable: !0,
configurable: !0
} : void 0 : Reflect.getOwnPropertyDescriptor(i, r);
},
/**
* A trap for Object.getPrototypeOf.
*/
getPrototypeOf() {
return Reflect.getPrototypeOf(i);
},
/**
* A trap for the in operator.
*/
has(o, r) {
return Reflect.has(i, r);
},
/**
* A trap for Object.getOwnPropertyNames and Object.getOwnPropertySymbols.
*/
ownKeys() {
return Reflect.ownKeys(i);
},
/**
* A trap for setting property values.
*/
set(o, r, a) {
return i[r] = a, delete o[r], !0;
}
});
}
function So(i, t = {
scriptable: !0,
indexable: !0
}) {
const { _scriptable: e = t.scriptable, _indexable: s = t.indexable, _allKeys: n = t.allKeys } = i;
return {
allKeys: n,
scriptable: e,
indexable: s,
isScriptable: Lt(e) ? e : () => e,
isIndexable: Lt(s) ? s : () => s
};
}
const Ra = (i, t) => i ? i + bs(t) : t, Ss = (i, t) => A(t) && i !== "adapters" && (Object.getPrototypeOf(t) === null || t.constructor === Object);
function Mo(i, t, e) {
if (Object.prototype.hasOwnProperty.call(i, t) || t === "constructor")
return i[t];
const s = e();
return i[t] = s, s;
}
function Fa(i, t, e) {
const { _proxy: s, _context: n, _subProxy: o, _descriptors: r } = i;
let a = s[t];
return Lt(a) && r.isScriptable(t) && (a = za(t, a, i, e)), $(a) && a.length && (a = Ia(t, a, i, r.isIndexable)), Ss(t, a) && (a = le(a, n, o && o[t], r)), a;
}
function za(i, t, e, s) {
const { _proxy: n, _context: o, _subProxy: r, _stack: a } = e;
if (a.has(i))
throw new Error("Recursion detected: " + Array.from(a).join("->") + "->" + i);
a.add(i);
let l = t(o, r || s);
return a.delete(i), Ss(i, l) && (l = Ms(n._scopes, n, i, l)), l;
}
function Ia(i, t, e, s) {
const { _proxy: n, _context: o, _subProxy: r, _descriptors: a } = e;
if (typeof o.index < "u" && s(i))
return t[o.index % t.length];
if (A(t[0])) {
const l = t, c = n._scopes.filter((h) => h !== l);
t = [];
for (const h of l) {
const d = Ms(c, n, i, h);
t.push(le(d, o, r && r[i], a));
}
}
return t;
}
function Po(i, t, e) {
return Lt(i) ? i(t, e) : i;
}
const Ba = (i, t) => i === !0 ? t : typeof i == "string" ? Et(t, i) : void 0;
function $a(i, t, e, s, n) {
for (const o of t) {
const r = Ba(e, o);
if (r) {
i.add(r);
const a = Po(r._fallback, e, n);
if (typeof a < "u" && a !== e && a !== s)
return a;
} else if (r === !1 && typeof s < "u" && e !== s)
return null;
}
return !1;
}
function Ms(i, t, e, s) {
const n = t._rootScopes, o = Po(t._fallback, e, s), r = [
...i,
...n
], a = /* @__PURE__ */ new Set();
a.add(s);
let l = Zs(a, r, e, o || e, s);
return l === null || typeof o < "u" && o !== e && (l = Zs(a, r, o, l, s), l === null) ? !1 : ks(Array.from(a), [
""
], n, o, () => ja(t, e, s));
}
function Zs(i, t, e, s, n) {
for (; e; )
e = $a(i, t, e, s, n);
return e;
}
function ja(i, t, e) {
const s = i._getTarget();
t in s || (s[t] = {});
const n = s[t];
return $(n) && A(e) ? e : n || {};
}
function Wa(i, t, e, s) {
let n;
for (const o of t)
if (n = Co(Ra(o, i), e), typeof n < "u")
return Ss(i, n) ? Ms(e, s, i, n) : n;
}
function Co(i, t) {
for (const e of t) {
if (!e)
continue;
const s = e[i];
if (typeof s < "u")
return s;
}
}
function Qs(i) {
let t = i._keys;
return t || (t = i._keys = Na(i._scopes)), t;
}
function Na(i) {
const t = /* @__PURE__ */ new Set();
for (const e of i)
for (const s of Object.keys(e).filter((n) => !n.startsWith("_")))
t.add(s);
return Array.from(t);
}
function Do(i, t, e, s) {
const { iScale: n } = i, { key: o = "r" } = this._parsing, r = new Array(s);
let a, l, c, h;
for (a = 0, l = s; a < l; ++a)
c = a + e, h = t[c], r[a] = {
r: n.parse(Et(h, o), c)
};
return r;
}
const Va = Number.EPSILON || 1e-14, ce = (i, t) => t < i.length && !i[t].skip && i[t], Oo = (i) => i === "x" ? "y" : "x";
function Ha(i, t, e, s) {
const n = i.skip ? t : i, o = t, r = e.skip ? t : e, a = Zi(o, n), l = Zi(r, o);
let c = a / (a + l), h = l / (a + l);
c = isNaN(c) ? 0 : c, h = isNaN(h) ? 0 : h;
const d = s * c, f = s * h;
return {
previous: {
x: o.x - d * (r.x - n.x),
y: o.y - d * (r.y - n.y)
},
next: {
x: o.x + f * (r.x - n.x),
y: o.y + f * (r.y - n.y)
}
};
}
function Ua(i, t, e) {
const s = i.length;
let n, o, r, a, l, c = ce(i, 0);
for (let h = 0; h < s - 1; ++h)
if (l = c, c = ce(i, h + 1), !(!l || !c)) {
if (De(t[h], 0, Va)) {
e[h] = e[h + 1] = 0;
continue;
}
n = e[h] / t[h], o = e[h + 1] / t[h], a = Math.pow(n, 2) + Math.pow(o, 2), !(a <= 9) && (r = 3 / Math.sqrt(a), e[h] = n * r * t[h], e[h + 1] = o * r * t[h]);
}
}
function Ya(i, t, e = "x") {
const s = Oo(e), n = i.length;
let o, r, a, l = ce(i, 0);
for (let c = 0; c < n; ++c) {
if (r = a, a = l, l = ce(i, c + 1), !a)
continue;
const h = a[e], d = a[s];
r && (o = (h - r[e]) / 3, a[`cp1${e}`] = h - o, a[`cp1${s}`] = d - o * t[c]), l && (o = (l[e] - h) / 3, a[`cp2${e}`] = h + o, a[`cp2${s}`] = d + o * t[c]);
}
}
function Xa(i, t = "x") {
const e = Oo(t), s = i.length, n = Array(s).fill(0), o = Array(s);
let r, a, l, c = ce(i, 0);
for (r = 0; r < s; ++r)
if (a = l, l = c, c = ce(i, r + 1), !!l) {
if (c) {
const h = c[t] - l[t];
n[r] = h !== 0 ? (c[e] - l[e]) / h : 0;
}
o[r] = a ? c ? pt(n[r - 1]) !== pt(n[r]) ? 0 : (n[r - 1] + n[r]) / 2 : n[r - 1] : n[r];
}
Ua(i, n, o), Ya(i, o, t);
}
function Ze(i, t, e) {
return Math.max(Math.min(i, e), t);
}
function Ka(i, t) {
let e, s, n, o, r, a = kt(i[0], t);
for (e = 0, s = i.length; e < s; ++e)
r = o, o = a, a = e < s - 1 && kt(i[e + 1], t), o && (n = i[e], r && (n.cp1x = Ze(n.cp1x, t.left, t.right), n.cp1y = Ze(n.cp1y, t.top, t.bottom)), a && (n.cp2x = Ze(n.cp2x, t.left, t.right), n.cp2y = Ze(n.cp2y, t.top, t.bottom)));
}
function qa(i, t, e, s, n) {
let o, r, a, l;
if (t.spanGaps && (i = i.filter((c) => !c.skip)), t.cubicInterpolationMode === "monotone")
Xa(i, n);
else {
let c = s ? i[i.length - 1] : i[0];
for (o = 0, r = i.length; o < r; ++o)
a = i[o], l = Ha(c, a, i[Math.min(o + 1, r - (s ? 0 : 1)) % r], t.tension), a.cp1x = l.previous.x, a.cp1y = l.previous.y, a.cp2x = l.next.x, a.cp2y = l.next.y, c = a;
}
t.capBezierPoints && Ka(i, e);
}
function Ps() {
return typeof window < "u" && typeof document < "u";
}
function Cs(i) {
let t = i.parentNode;
return t && t.toString() === "[object ShadowRoot]" && (t = t.host), t;
}
function Si(i, t, e) {
let s;
return typeof i == "string" ? (s = parseInt(i, 10), i.indexOf("%") !== -1 && (s = s / 100 * t.parentNode[e])) : s = i, s;
}
const Ei = (i) => i.ownerDocument.defaultView.getComputedStyle(i, null);
function Ga(i, t) {
return Ei(i).getPropertyValue(t);
}
const Za = [
"top",
"right",
"bottom",
"left"
];
function Kt(i, t, e) {
const s = {};
e = e ? "-" + e : "";
for (let n = 0; n < 4; n++) {
const o = Za[n];
s[o] = parseFloat(i[t + "-" + o + e]) || 0;
}
return s.width = s.left + s.right, s.height = s.top + s.bottom, s;
}
const Qa = (i, t, e) => (i > 0 || t > 0) && (!e || !e.shadowRoot);
function Ja(i, t) {
const e = i.touches, s = e && e.length ? e[0] : i, { offsetX: n, offsetY: o } = s;
let r = !1, a, l;
if (Qa(n, o, i.target))
a = n, l = o;
else {
const c = t.getBoundingClientRect();
a = s.clientX - c.left, l = s.clientY - c.top, r = !0;
}
return {
x: a,
y: l,
box: r
};
}
function Ht(i, t) {
if ("native" in i)
return i;
const { canvas: e, currentDevicePixelRatio: s } = t, n = Ei(e), o = n.boxSizing === "border-box", r = Kt(n, "padding"), a = Kt(n, "border", "width"), { x: l, y: c, box: h } = Ja(i, e), d = r.left + (h && a.left), f = r.top + (h && a.top);
let { width: u, height: g } = t;
return o && (u -= r.width + a.width, g -= r.height + a.height), {
x: Math.round((l - d) / u * e.width / s),
y: Math.round((c - f) / g * e.height / s)
};
}
function tl(i, t, e) {
let s, n;
if (t === void 0 || e === void 0) {
const o = i && Cs(i);
if (!o)
t = i.clientWidth, e = i.clientHeight;
else {
const r = o.getBoundingClientRect(), a = Ei(o), l = Kt(a, "border", "width"), c = Kt(a, "padding");
t = r.width - c.width - l.width, e = r.height - c.height - l.height, s = Si(a.maxWidth, o, "clientWidth"), n = Si(a.maxHeight, o, "clientHeight");
}
}
return {
width: t,
height: e,
maxWidth: s || wi,
maxHeight: n || wi
};
}
const Qe = (i) => Math.round(i * 10) / 10;
function el(i, t, e, s) {
const n = Ei(i), o = Kt(n, "margin"), r = Si(n.maxWidth, i, "clientWidth") || wi, a = Si(n.maxHeight, i, "clientHeight") || wi, l = tl(i, t, e);
let { width: c, height: h } = l;
if (n.boxSizing === "content-box") {
const f = Kt(n, "border", "width"), u = Kt(n, "padding");
c -= u.width + f.width, h -= u.height + f.height;
}
return c = Math.max(0, c - o.width), h = Math.max(0, s ? c / s : h - o.height), c = Qe(Math.min(c, r, l.maxWidth)), h = Qe(Math.min(h, a, l.maxHeight)), c && !h && (h = Qe(c / 2)), (t !== void 0 || e !== void 0) && s && l.height && h > l.height && (h = l.height, c = Qe(Math.floor(h * s))), {
width: c,
height: h
};
}
function Js(i, t, e) {
const s = t || 1, n = Math.floor(i.height * s), o = Math.floor(i.width * s);
i.height = Math.floor(i.height), i.width = Math.floor(i.width);
const r = i.canvas;
return r.style && (e || !r.style.height && !r.style.width) && (r.style.height = `${i.height}px`, r.style.width = `${i.width}px`), i.currentDevicePixelRatio !== s || r.height !== n || r.width !== o ? (i.currentDevicePixelRatio = s, r.height = n, r.width = o, i.ctx.setTransform(s, 0, 0, s, 0, 0), !0) : !1;
}
const il = function() {
let i = !1;
try {
const t = {
get passive() {
return i = !0, !1;
}
};
Ps() && (window.addEventListener("test", null, t), window.removeEventListener("test", null, t));
} catch {
}
return i;
}();
function tn(i, t) {
const e = Ga(i, t), s = e && e.match(/^(\d+)(\.\d+)?px$/);
return s ? +s[1] : void 0;
}
function Ut(i, t, e, s) {
return {
x: i.x + e * (t.x - i.x),
y: i.y + e * (t.y - i.y)
};
}
function sl(i, t, e, s) {
return {
x: i.x + e * (t.x - i.x),
y: s === "middle" ? e < 0.5 ? i.y : t.y : s === "after" ? e < 1 ? i.y : t.y : e > 0 ? t.y : i.y
};
}
function nl(i, t, e, s) {
const n = {
x: i.cp2x,
y: i.cp2y
}, o = {
x: t.cp1x,
y: t.cp1y
}, r = Ut(i, n, e), a = Ut(n, o, e), l = Ut(o, t, e), c = Ut(r, a, e), h = Ut(a, l, e);
return Ut(c, h, e);
}
const ol = function(i, t) {
return {
x(e) {
return i + i + t - e;
},
setWidth(e) {
t = e;
},
textAlign(e) {
return e === "center" ? e : e === "right" ? "left" : "right";
},
xPlus(e, s) {
return e - s;
},
leftForLtr(e, s) {
return e - s;
}
};
}, rl = function() {
return {
x(i) {
return i;
},
setWidth(i) {
},
textAlign(i) {
return i;
},
xPlus(i, t) {
return i + t;
},
leftForLtr(i, t) {
return i;
}
};
};
function re(i, t, e) {
return i ? ol(t, e) : rl();
}
function Ao(i, t) {
let e, s;
(t === "ltr" || t === "rtl") && (e = i.canvas.style, s = [
e.getPropertyValue("direction"),
e.getPropertyPriority("direction")
], e.setProperty("direction", t, "important"), i.prevTextDirection = s);
}
function To(i, t) {
t !== void 0 && (delete i.prevTextDirection, i.canvas.style.setProperty("direction", t[0], t[1]));
}
function Eo(i) {
return i === "angle" ? {
between: Fe,
compare: aa,
normalize: ot
} : {
between: vt,
compare: (t, e) => t - e,
normalize: (t) => t
};
}
function en({ start: i, end: t, count: e, loop: s, style: n }) {
return {
start: i % e,
end: t % e,
loop: s && (t - i + 1) % e === 0,
style: n
};
}
function al(i, t, e) {
const { property: s, start: n, end: o } = e, { between: r, normalize: a } = Eo(s), l = t.length;
let { start: c, end: h, loop: d } = i, f, u;
if (d) {
for (c += l, h += l, f = 0, u = l; f < u && r(a(t[c % l][s]), n, o); ++f)
c--, h--;
c %= l, h %= l;
}
return h < c && (h += l), {
start: c,
end: h,
loop: d,
style: i.style
};
}
function Lo(i, t, e) {
if (!e)
return [
i
];
const { property: s, start: n, end: o } = e, r = t.length, { compare: a, between: l, normalize: c } = Eo(s), { start: h, end: d, loop: f, style: u } = al(i, t, e), g = [];
let p = !1, m = null, b, x, v;
const y = () => l(n, v, b) && a(n, v) !== 0, _ = () => a(o, b) === 0 || l(o, v, b), k = () => p || y(), S = () => !p || _();
for (let M = h, P = h; M <= d; ++M)
x = t[M % r], !x.skip && (b = c(x[s]), b !== v && (p = l(b, n, o), m === null && k() && (m = a(b, n) === 0 ? M : P), m !== null && S() && (g.push(en({
start: m,
end: M,
loop: f,
count: r,
style: u
})), m = null), P = M, v = b));
return m !== null && g.push(en({
start: m,
end: d,
loop: f,
count: r,
style: u
})), g;
}
function Ro(i, t) {
const e = [], s = i.segments;
for (let n = 0; n < s.length; n++) {
const o = Lo(s[n], i.points, t);
o.length && e.push(...o);
}
return e;
}
function ll(i, t, e, s) {
let n = 0, o = t - 1;
if (e && !s)
for (; n < t && !i[n].skip; )
n++;
for (; n < t && i[n].skip; )
n++;
for (n %= t, e && (o += n); o > n && i[o % t].skip; )
o--;
return o %= t, {
start: n,
end: o
};
}
function cl(i, t, e, s) {
const n = i.length, o = [];
let r = t, a = i[t], l;
for (l = t + 1; l <= e; ++l) {
const c = i[l % n];
c.skip || c.stop ? a.skip || (s = !1, o.push({
start: t % n,
end: (l - 1) % n,
loop: s
}), t = r = c.stop ? l : null) : (r = l, a.skip && (t = l)), a = c;
}
return r !== null && o.push({
start: t % n,
end: r % n,
loop: s
}), o;
}
function hl(i, t) {
const e = i.points, s = i.options.spanGaps, n = e.length;
if (!n)
return [];
const o = !!i._loop, { start: r, end: a } = ll(e, n, o, s);
if (s === !0)
return sn(i, [
{
start: r,
end: a,
loop: o
}
], e, t);
const l = a < r ? a + n : a, c = !!i._fullLoop && r === 0 && a === n - 1;
return sn(i, cl(e, r, l, c), e, t);
}
function sn(i, t, e, s) {
return !s || !s.setContext || !e ? t : dl(i, t, e, s);
}
function dl(i, t, e, s) {
const n = i._chart.getContext(), o = nn(i.options), { _datasetIndex: r, options: { spanGaps: a } } = i, l = e.length, c = [];
let h = o, d = t[0].start, f = d;
function u(g, p, m, b) {
const x = a ? -1 : 1;
if (g !== p) {
for (g += l; e[g % l].skip; )
g -= x;
for (; e[p % l].skip; )
p += x;
g % l !== p % l && (c.push({
start: g % l,
end: p % l,
loop: m,
style: b
}), h = b, d = p % l);
}
}
for (const g of t) {
d = a ? d : g.start;
let p = e[d % l], m;
for (f = d + 1; f <= g.end; f++) {
const b = e[f % l];
m = nn(s.setContext(It(n, {
type: "segment",
p0: p,
p1: b,
p0DataIndex: (f - 1) % l,
p1DataIndex: f % l,
datasetIndex: r
}))), fl(m, h) && u(d, f - 1, g.loop, h), p = b, h = m;
}
d < f - 1 && u(d, f - 1, g.loop, h);
}
return c;
}
function nn(i) {
return {
backgroundColor: i.backgroundColor,
borderCapStyle: i.borderCapStyle,
borderDash: i.borderDash,
borderDashOffset: i.borderDashOffset,
borderJoinStyle: i.borderJoinStyle,
borderWidth: i.borderWidth,
borderColor: i.borderColor
};
}
function fl(i, t) {
if (!t)
return !1;
const e = [], s = function(n, o) {
return vs(o) ? (e.includes(o) || e.push(o), e.indexOf(o)) : o;
};
return JSON.stringify(i, s) !== JSON.stringify(t, s);
}
/*!
* Chart.js v4.4.7
* https://www.chartjs.org
* (c) 2024 Chart.js Contributors
* Released under the MIT License
*/
class ul {
constructor() {
this._request = null, this._charts = /* @__PURE__ */ new Map(), this._running = !1, this._lastDate = void 0;
}
_notify(t, e, s, n) {
const o = e.listeners[n], r = e.duration;
o.forEach((a) => a({
chart: t,
initial: e.initial,
numSteps: r,
currentStep: Math.min(s - e.start, r)
}));
}
_refresh() {
this._request || (this._running = !0, this._request = bo.call(window, () => {
this._update(), this._request = null, this._running && this._refresh();
}));
}
_update(t = Date.now()) {
let e = 0;
this._charts.forEach((s, n) => {
if (!s.running || !s.items.length)
return;
const o = s.items;
let r = o.length - 1, a = !1, l;
for (; r >= 0; --r)
l = o[r], l._active ? (l._total > s.duration && (s.duration = l._total), l.tick(t), a = !0) : (o[r] = o[o.length - 1], o.pop());
a && (n.draw(), this._notify(n, s, t, "progress")), o.length || (s.running = !1, this._notify(n, s, t, "complete"), s.initial = !1), e += o.length;
}), this._lastDate = t, e === 0 && (this._running = !1);
}
_getAnims(t) {
const e = this._charts;
let s = e.get(t);
return s || (s = {
running: !1,
initial: !0,
items: [],
listeners: {
complete: [],
progress: []
}
}, e.set(t, s)), s;
}
listen(t, e, s) {
this._getAnims(t).listeners[e].push(s);
}
add(t, e) {
!e || !e.length || this._getAnims(t).items.push(...e);
}
has(t) {
return this._getAnims(t).items.length > 0;
}
start(t) {
const e = this._charts.get(t);
e && (e.running = !0, e.start = Date.now(), e.duration = e.items.reduce((s, n) => Math.max(s, n._duration), 0), this._refresh());
}
running(t) {
if (!this._running)
return !1;
const e = this._charts.get(t);
return !(!e || !e.running || !e.items.length);
}
stop(t) {
const e = this._charts.get(t);
if (!e || !e.items.length)
return;
const s = e.items;
let n = s.length - 1;
for (; n >= 0; --n)
s[n].cancel();
e.items = [], this._notify(t, e, Date.now(), "complete");
}
remove(t) {
return this._charts.delete(t);
}
}
var xt = /* @__PURE__ */ new ul();
const on = "transparent", gl = {
boolean(i, t, e) {
return e > 0.5 ? t : i;
},
color(i, t, e) {
const s = Ks(i || on), n = s.valid && Ks(t || on);
return n && n.valid ? n.mix(s, e).hexString() : t;
},
number(i, t, e) {
return i + (t - i) * e;
}
};
class pl {
constructor(t, e, s, n) {
const o = e[s];
n = ve([
t.to,
n,
o,
t.from
]);
const r = ve([
t.from,
o,
n
]);
this._active = !0, this._fn = t.fn || gl[t.type || typeof r], this._easing = Oe[t.easing] || Oe.linear, this._start = Math.floor(Date.now() + (t.delay || 0)), this._duration = this._total = Math.floor(t.duration), this._loop = !!t.loop, this._target = e, this._prop = s, this._from = r, this._to = n, this._promises = void 0;
}
active() {
return this._active;
}
update(t, e, s) {
if (this._active) {
this._notify(!1);
const n = this._target[this._prop], o = s - this._start, r = this._duration - o;
this._start = s, this._duration = Math.floor(Math.max(r, t.duration)), this._total += o, this._loop = !!t.loop, this._to = ve([
t.to,
e,
n,
t.from
]), this._from = ve([
t.from,
n,
e
]);
}
}
cancel() {
this._active && (this.tick(Date.now()), this._active = !1, this._notify(!1));
}
tick(t) {
const e = t - this._start, s = this._duration, n = this._prop, o = this._from, r = this._loop, a = this._to;
let l;
if (this._active = o !== a && (r || e < s), !this._active) {
this._target[n] = a, this._notify(!0);
return;
}
if (e < 0) {
this._target[n] = o;
return;
}
l = e / s % 2, l = r && l > 1 ? 2 - l : l, l = this._easing(Math.min(1, Math.max(0, l))), this._target[n] = this._fn(o, a, l);
}
wait() {
const t = this._promises || (this._promises = []);
return new Promise((e, s) => {
t.push({
res: e,
rej: s
});
});
}
_notify(t) {
const e = t ? "res" : "rej", s = this._promises || [];
for (let n = 0; n < s.length; n++)
s[n][e]();
}
}
class Fo {
constructor(t, e) {
this._chart = t, this._properties = /* @__PURE__ */ new Map(), this.configure(e);
}
configure(t) {
if (!A(t))
return;
const e = Object.keys(j.animation), s = this._properties;
Object.getOwnPropertyNames(t).forEach((n) => {
const o = t[n];
if (!A(o))
return;
const r = {};
for (const a of e)
r[a] = o[a];
($(o.properties) && o.properties || [
n
]).forEach((a) => {
(a === n || !s.has(a)) && s.set(a, r);
});
});
}
_animateOptions(t, e) {
const s = e.options, n = bl(t, s);
if (!n)
return [];
const o = this._createAnimations(n, s);
return s.$shared && ml(t.options.$animations, s).then(() => {
t.options = s;
}, () => {
}), o;
}
_createAnimations(t, e) {
const s = this._properties, n = [], o = t.$animations || (t.$animations = {}), r = Object.keys(e), a = Date.now();
let l;
for (l = r.length - 1; l >= 0; --l) {
const c = r[l];
if (c.charAt(0) === "$")
continue;
if (c === "options") {
n.push(...this._animateOptions(t, e));
continue;
}
const h = e[c];
let d = o[c];
const f = s.get(c);
if (d)
if (f && d.active()) {
d.update(f, h, a);
continue;
} else
d.cancel();
if (!f || !f.duration) {
t[c] = h;
continue;
}
o[c] = d = new pl(f, t, c, h), n.push(d);
}
return n;
}
update(t, e) {
if (this._properties.size === 0) {
Object.assign(t, e);
return;
}
const s = this._createAnimations(t, e);
if (s.length)
return xt.add(this._chart, s), !0;
}
}
function ml(i, t) {
const e = [], s = Object.keys(t);
for (let n = 0; n < s.length; n++) {
const o = i[s[n]];
o && o.active() && e.push(o.wait());
}
return Promise.all(e);
}
function bl(i, t) {
if (!t)
return;
let e = i.options;
if (!e) {
i.options = t;
return;
}
return e.$shared && (i.options = e = Object.assign({}, e, {
$shared: !1,
$animations: {}
})), e;
}
function rn(i, t) {
const e = i && i.options || {}, s = e.reverse, n = e.min === void 0 ? t : 0, o = e.max === void 0 ? t : 0;
return {
start: s ? o : n,
end: s ? n : o
};
}
function xl(i, t, e) {
if (e === !1)
return !1;
const s = rn(i, e), n = rn(t, e);
return {
top: n.end,
right: s.end,
bottom: n.start,
left: s.start
};
}
function _l(i) {
let t, e, s, n;
return A(i) ? (t = i.top, e = i.right, s = i.bottom, n = i.left) : t = e = s = n = i, {
top: t,
right: e,
bottom: s,
left: n,
disabled: i === !1
};
}
function zo(i, t) {
const e = [], s = i._getSortedDatasetMetas(t);
let n, o;
for (n = 0, o = s.length; n < o; ++n)
e.push(s[n].index);
return e;
}
function an(i, t, e, s = {}) {
const n = i.keys, o = s.mode === "single";
let r, a, l, c;
if (t === null)
return;
let h = !1;
for (r = 0, a = n.length; r < a; ++r) {
if (l = +n[r], l === e) {
if (h = !0, s.all)
continue;
break;
}
c = i.values[l], V(c) && (o || t === 0 || pt(t) === pt(c)) && (t += c);
}
return !h && !s.all ? 0 : t;
}
function yl(i, t) {
const { iScale: e, vScale: s } = t, n = e.axis === "x" ? "x" : "y", o = s.axis === "x" ? "x" : "y", r = Object.keys(i), a = new Array(r.length);
let l, c, h;
for (l = 0, c = r.length; l < c; ++l)
h = r[l], a[l] = {
[n]: h,
[o]: i[h]
};
return a;
}
function ji(i, t) {
const e = i && i.options.stacked;
return e || e === void 0 && t.stack !== void 0;
}
function vl(i, t, e) {
return `${i.id}.${t.id}.${e.stack || e.type}`;
}
function wl(i) {
const { min: t, max: e, minDefined: s, maxDefined: n } = i.getUserBounds();
return {
min: s ? t : Number.NEGATIVE_INFINITY,
max: n ? e : Number.POSITIVE_INFINITY
};
}
function kl(i, t, e) {
const s = i[t] || (i[t] = {});
return s[e] || (s[e] = {});
}
function ln(i, t, e, s) {
for (const n of t.getMatchingVisibleMetas(s).reverse()) {
const o = i[n.index];
if (e && o > 0 || !e && o < 0)
return n.index;
}
return null;
}
function cn(i, t) {
const { chart: e, _cachedMeta: s } = i, n = e._stacks || (e._stacks = {}), { iScale: o, vScale: r, index: a } = s, l = o.axis, c = r.axis, h = vl(o, r, s), d = t.length;
let f;
for (let u = 0; u < d; ++u) {
const g = t[u], { [l]: p, [c]: m } = g, b = g._stacks || (g._stacks = {});
f = b[c] = kl(n, h, p), f[a] = m, f._top = ln(f, r, !0, s.type), f._bottom = ln(f, r, !1, s.type);
const x = f._visualValues || (f._visualValues = {});
x[a] = m;
}
}
function Wi(i, t) {
const e = i.scales;
return Object.keys(e).filter((s) => e[s].axis === t).shift();
}
function Sl(i, t) {
return It(i, {
active: !1,
dataset: void 0,
datasetIndex: t,
index: t,
mode: "default",
type: "dataset"
});
}
function Ml(i, t, e) {
return It(i, {
active: !1,
dataIndex: t,
parsed: void 0,
raw: void 0,
element: e,
index: t,
mode: "default",
type: "data"
});
}
function pe(i, t) {
const e = i.controller.index, s = i.vScale && i.vScale.axis;
if (s) {
t = t || i._parsed;
for (const n of t) {
const o = n._stacks;
if (!o || o[s] === void 0 || o[s][e] === void 0)
return;
delete o[s][e], o[s]._visualValues !== void 0 && o[s]._visualValues[e] !== void 0 && delete o[s]._visualValues[e];
}
}
}
const Ni = (i) => i === "reset" || i === "none", hn = (i, t) => t ? i : Object.assign({}, i), Pl = (i, t, e) => i && !t.hidden && t._stacked && {
keys: zo(e, !0),
values: null
};
class dt {
constructor(t, e) {
this.chart = t, this._ctx = t.ctx, this.index = e, this._cachedDataOpts = {}, this._cachedMeta = this.getMeta(), this._type = this._cachedMeta.type, this.options = void 0, this._parsing = !1, this._data = void 0, this._objectData = void 0, this._sharedOptions = void 0, this._drawStart = void 0, this._drawCount = void 0, this.enableOptionSharing = !1, this.supportsDecimation = !1, this.$context = void 0, this._syncList = [], this.datasetElementType = new.target.datasetElementType, this.dataElementType = new.target.dataElementType, this.initialize();
}
initialize() {
const t = this._cachedMeta;
this.configure(), this.linkScales(), t._stacked = ji(t.vScale, t), this.addElements(), this.options.fill && !this.chart.isPluginEnabled("filler") && console.warn("Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options");
}
updateIndex(t) {
this.index !== t && pe(this._cachedMeta), this.index = t;
}
linkScales() {
const t = this.chart, e = this._cachedMeta, s = this.getDataset(), n = (d, f, u, g) => d === "x" ? f : d === "r" ? g : u, o = e.xAxisID = C(s.xAxisID, Wi(t, "x")), r = e.yAxisID = C(s.yAxisID, Wi(t, "y")), a = e.rAxisID = C(s.rAxisID, Wi(t, "r")), l = e.indexAxis, c = e.iAxisID = n(l, o, r, a), h = e.vAxisID = n(l, r, o, a);
e.xScale = this.getScaleForId(o), e.yScale = this.getScaleForId(r), e.rScale = this.getScaleForId(a), e.iScale = this.getScaleForId(c), e.vScale = this.getScaleForId(h);
}
getDataset() {
return this.chart.data.datasets[this.index];
}
getMeta() {
return this.chart.getDatasetMeta(this.index);
}
getScaleForId(t) {
return this.chart.scales[t];
}
_getOtherScale(t) {
const e = this._cachedMeta;
return t === e.iScale ? e.vScale : e.iScale;
}
reset() {
this._update("reset");
}
_destroy() {
const t = this._cachedMeta;
this._data && Us(this._data, this), t._stacked && pe(t);
}
_dataCheck() {
const t = this.getDataset(), e = t.data || (t.data = []), s = this._data;
if (A(e)) {
const n = this._cachedMeta;
this._data = yl(e, n);
} else if (s !== e) {
if (s) {
Us(s, this);
const n = this._cachedMeta;
pe(n), n._parsed = [];
}
e && Object.isExtensible(e) && da(e, this), this._syncList = [], this._data = e;
}
}
addElements() {
const t = this._cachedMeta;
this._dataCheck(), this.datasetElementType && (t.dataset = new this.datasetElementType());
}
buildOrUpdateElements(t) {
const e = this._cachedMeta, s = this.getDataset();
let n = !1;
this._dataCheck();
const o = e._stacked;
e._stacked = ji(e.vScale, e), e.stack !== s.stack && (n = !0, pe(e), e.stack = s.stack), this._resyncElements(t), (n || o !== e._stacked) && (cn(this, e._parsed), e._stacked = ji(e.vScale, e));
}
configure() {
const t = this.chart.config, e = t.datasetScopeKeys(this._type), s = t.getOptionScopes(this.getDataset(), e, !0);
this.options = t.createResolver(s, this.getContext()), this._parsing = this.options.parsing, this._cachedDataOpts = {};
}
parse(t, e) {
const { _cachedMeta: s, _data: n } = this, { iScale: o, _stacked: r } = s, a = o.axis;
let l = t === 0 && e === n.length ? !0 : s._sorted, c = t > 0 && s._parsed[t - 1], h, d, f;
if (this._parsing === !1)
s._parsed = n, s._sorted = !0, f = n;
else {
$(n[t]) ? f = this.parseArrayData(s, n, t, e) : A(n[t]) ? f = this.parseObjectData(s, n, t, e) : f = this.parsePrimitiveData(s, n, t, e);
const u = () => d[a] === null || c && d[a] < c[a];
for (h = 0; h < e; ++h)
s._parsed[h + t] = d = f[h], l && (u() && (l = !1), c = d);
s._sorted = l;
}
r && cn(this, f);
}
parsePrimitiveData(t, e, s, n) {
const { iScale: o, vScale: r } = t, a = o.axis, l = r.axis, c = o.getLabels(), h = o === r, d = new Array(n);
let f, u, g;
for (f = 0, u = n; f < u; ++f)
g = f + s, d[f] = {
[a]: h || o.parse(c[g], g),
[l]: r.parse(e[g], g)
};
return d;
}
parseArrayData(t, e, s, n) {
const { xScale: o, yScale: r } = t, a = new Array(n);
let l, c, h, d;
for (l = 0, c = n; l < c; ++l)
h = l + s, d = e[h], a[l] = {
x: o.parse(d[0], h),
y: r.parse(d[1], h)
};
return a;
}
parseObjectData(t, e, s, n) {
const { xScale: o, yScale: r } = t, { xAxisKey: a = "x", yAxisKey: l = "y" } = this._parsing, c = new Array(n);
let h, d, f, u;
for (h = 0, d = n; h < d; ++h)
f = h + s, u = e[f], c[h] = {
x: o.parse(Et(u, a), f),
y: r.parse(Et(u, l), f)
};
return c;
}
getParsed(t) {
return this._cachedMeta._parsed[t];
}
getDataElement(t) {
return this._cachedMeta.data[t];
}
applyStack(t, e, s) {
const n = this.chart, o = this._cachedMeta, r = e[t.axis], a = {
keys: zo(n, !0),
values: e._stacks[t.axis]._visualValues
};
return an(a, r, o.index, {
mode: s
});
}
updateRangeFromParsed(t, e, s, n) {
const o = s[e.axis];
let r = o === null ? NaN : o;
const a = n && s._stacks[e.axis];
n && a && (n.values = a, r = an(n, o, this._cachedMeta.index)), t.min = Math.min(t.min, r), t.max = Math.max(t.max, r);
}
getMinMax(t, e) {
const s = this._cachedMeta, n = s._parsed, o = s._sorted && t === s.iScale, r = n.length, a = this._getOtherScale(t), l = Pl(e, s, this.chart), c = {
min: Number.POSITIVE_INFINITY,
max: Number.NEGATIVE_INFINITY
}, { min: h, max: d } = wl(a);
let f, u;
function g() {
u = n[f];
const p = u[a.axis];
return !V(u[t.axis]) || h > p || d < p;
}
for (f = 0; f < r && !(!g() && (this.updateRangeFromParsed(c, t, u, l), o)); ++f)
;
if (o) {
for (f = r - 1; f >= 0; --f)
if (!g()) {
this.updateRangeFromParsed(c, t, u, l);
break;
}
}
return c;
}
getAllParsedValues(t) {
const e = this._cachedMeta._parsed, s = [];
let n, o, r;
for (n = 0, o = e.length; n < o; ++n)
r = e[n][t.axis], V(r) && s.push(r);
return s;
}
getMaxOverflow() {
return !1;
}
getLabelAndValue(t) {
const e = this._cachedMeta, s = e.iScale, n = e.vScale, o = this.getParsed(t);
return {
label: s ? "" + s.getLabelForValue(o[s.axis]) : "",
value: n ? "" + n.getLabelForValue(o[n.axis]) : ""
};
}
_update(t) {
const e = this._cachedMeta;
this.update(t || "default"), e._clip = _l(C(this.options.clip, xl(e.xScale, e.yScale, this.getMaxOverflow())));
}
update(t) {
}
draw() {
const t = this._ctx, e = this.chart, s = this._cachedMeta, n = s.data || [], o = e.chartArea, r = [], a = this._drawStart || 0, l = this._drawCount || n.length - a, c = this.options.drawActiveElementsOnTop;
let h;
for (s.dataset && s.dataset.draw(t, o, a, l), h = a; h < a + l; ++h) {
const d = n[h];
d.hidden || (d.active && c ? r.push(d) : d.draw(t, o));
}
for (h = 0; h < r.length; ++h)
r[h].draw(t, o);
}
getStyle(t, e) {
const s = e ? "active" : "default";
return t === void 0 && this._cachedMeta.dataset ? this.resolveDatasetElementOptions(s) : this.resolveDataElementOptions(t || 0, s);
}
getContext(t, e, s) {
const n = this.getDataset();
let o;
if (t >= 0 && t < this._cachedMeta.data.length) {
const r = this._cachedMeta.data[t];
o = r.$context || (r.$context = Ml(this.getContext(), t, r)), o.parsed = this.getParsed(t), o.raw = n.data[t], o.index = o.dataIndex = t;
} else
o = this.$context || (this.$context = Sl(this.chart.getContext(), this.index)), o.dataset = n, o.index = o.datasetIndex = this.index;
return o.active = !!e, o.mode = s, o;
}
resolveDatasetElementOptions(t) {
return this._resolveElementOptions(this.datasetElementType.id, t);
}
resolveDataElementOptions(t, e) {
return this._resolveElementOptions(this.dataElementType.id, e, t);
}
_resolveElementOptions(t, e = "default", s) {
const n = e === "active", o = this._cachedDataOpts, r = t + "-" + e, a = o[r], l = this.enableOptionSharing && Re(s);
if (a)
return hn(a, l);
const c = this.chart.config, h = c.datasetElementScopeKeys(this._type, t), d = n ? [
`${t}Hover`,
"hover",
t,
""
] : [
t,
""
], f = c.getOptionScopes(this.getDataset(), h), u = Object.keys(j.elements[t]), g = () => this.getContext(s, n, e), p = c.resolveNamedOptions(f, u, g, d);
return p.$shared && (p.$shared = l, o[r] = Object.freeze(hn(p, l))), p;
}
_resolveAnimations(t, e, s) {
const n = this.chart, o = this._cachedDataOpts, r = `animation-${e}`, a = o[r];
if (a)
return a;
let l;
if (n.options.animation !== !1) {
const h = this.chart.config, d = h.datasetAnimationScopeKeys(this._type, e), f = h.getOptionScopes(this.getDataset(), d);
l = h.createResolver(f, this.getContext(t, s, e));
}
const c = new Fo(n, l && l.animations);
return l && l._cacheable && (o[r] = Object.freeze(c)), c;
}
getSharedOptions(t) {
if (t.$shared)
return this._sharedOptions || (this._sharedOptions = Object.assign({}, t));
}
includeOptions(t, e) {
return !e || Ni(t) || this.chart._animationsDisabled;
}
_getSharedOptions(t, e) {
const s = this.resolveDataElementOptions(t, e), n = this._sharedOptions, o = this.getSharedOptions(s), r = this.includeOptions(e, o) || o !== n;
return this.updateSharedOptions(o, e, s), {
sharedOptions: o,
includeOptions: r
};
}
updateElement(t, e, s, n) {
Ni(n) ? Object.assign(t, s) : this._resolveAnimations(e, n).update(t, s);
}
updateSharedOptions(t, e, s) {
t && !Ni(e) && this._resolveAnimations(void 0, e).update(t, s);
}
_setStyle(t, e, s, n) {
t.active = n;
const o = this.getStyle(e, n);
this._resolveAnimations(e, s, n).update(t, {
options: !n && this.getSharedOptions(o) || o
});
}
removeHoverStyle(t, e, s) {
this._setStyle(t, s, "active", !1);
}
setHoverStyle(t, e, s) {
this._setStyle(t, s, "active", !0);
}
_removeDatasetHoverStyle() {
const t = this._cachedMeta.dataset;
t && this._setStyle(t, void 0, "active", !1);
}
_setDatasetHoverStyle() {
const t = this._cachedMeta.dataset;
t && this._setStyle(t, void 0, "active", !0);
}
_resyncElements(t) {
const e = this._data, s = this._cachedMeta.data;
for (const [a, l, c] of this._syncList)
this[a](l, c);
this._syncList = [];
const n = s.length, o = e.length, r = Math.min(o, n);
r && this.parse(0, r), o > n ? this._insertElements(n, o - n, t) : o < n && this._removeElements(o, n - o);
}
_insertElements(t, e, s = !0) {
const n = this._cachedMeta, o = n.data, r = t + e;
let a;
const l = (c) => {
for (c.length += e, a = c.length - 1; a >= r; a--)
c[a] = c[a - e];
};
for (l(o), a = t; a < r; ++a)
o[a] = new this.dataElementType();
this._parsing && l(n._parsed), this.parse(t, e), s && this.updateElements(o, t, e, "reset");
}
updateElements(t, e, s, n) {
}
_removeElements(t, e) {
const s = this._cachedMeta;
if (this._parsing) {
const n = s._parsed.splice(t, e);
s._stacked && pe(s, n);
}
s.data.splice(t, e);
}
_sync(t) {
if (this._parsing)
this._syncList.push(t);
else {
const [e, s, n] = t;
this[e](s, n);
}
this.chart._dataChanges.push([
this.index,
...t
]);
}
_onDataPush() {
const t = arguments.length;
this._sync([
"_insertElements",
this.getDataset().data.length - t,
t
]);
}
_onDataPop() {
this._sync([
"_removeElements",
this._cachedMeta.data.length - 1,
1
]);
}
_onDataShift() {
this._sync([
"_removeElements",
0,
1
]);
}
_onDataSplice(t, e) {
e && this._sync([
"_removeElements",
t,
e
]);
const s = arguments.length - 2;
s && this._sync([
"_insertElements",
t,
s
]);
}
_onDataUnshift() {
this._sync([
"_insertElements",
0,
arguments.length
]);
}
}
w(dt, "defaults", {}), w(dt, "datasetElementType", null), w(dt, "dataElementType", null);
function Cl(i, t) {
if (!i._cache.$bar) {
const e = i.getMatchingVisibleMetas(t);
let s = [];
for (let n = 0, o = e.length; n < o; n++)
s = s.concat(e[n].controller.getAllParsedValues(i));
i._cache.$bar = mo(s.sort((n, o) => n - o));
}
return i._cache.$bar;
}
function Dl(i) {
const t = i.iScale, e = Cl(t, i.type);
let s = t._length, n, o, r, a;
const l = () => {
r === 32767 || r === -32768 || (Re(a) && (s = Math.min(s, Math.abs(r - a) || s)), a = r);
};
for (n = 0, o = e.length; n < o; ++n)
r = t.getPixelForValue(e[n]), l();
for (a = void 0, n = 0, o = t.ticks.length; n < o; ++n)
r = t.getPixelForTick(n), l();
return s;
}
function Ol(i, t, e, s) {
const n = e.barThickness;
let o, r;
return E(n) ? (o = t.min * e.categoryPercentage, r = e.barPercentage) : (o = n * s, r = 1), {
chunk: o / s,
ratio: r,
start: t.pixels[i] - o / 2
};
}
function Al(i, t, e, s) {
const n = t.pixels, o = n[i];
let r = i > 0 ? n[i - 1] : null, a = i < n.length - 1 ? n[i + 1] : null;
const l = e.categoryPercentage;
r === null && (r = o - (a === null ? t.end - t.start : a - o)), a === null && (a = o + o - r);
const c = o - (o - Math.min(r, a)) / 2 * l;
return {
chunk: Math.abs(a - r) / 2 * l / s,
ratio: e.barPercentage,
start: c
};
}
function Tl(i, t, e, s) {
const n = e.parse(i[0], s), o = e.parse(i[1], s), r = Math.min(n, o), a = Math.max(n, o);
let l = r, c = a;
Math.abs(r) > Math.abs(a) && (l = a, c = r), t[e.axis] = c, t._custom = {
barStart: l,
barEnd: c,
start: n,
end: o,
min: r,
max: a
};
}
function Io(i, t, e, s) {
return $(i) ? Tl(i, t, e, s) : t[e.axis] = e.parse(i, s), t;
}
function dn(i, t, e, s) {
const n = i.iScale, o = i.vScale, r = n.getLabels(), a = n === o, l = [];
let c, h, d, f;
for (c = e, h = e + s; c < h; ++c)
f = t[c], d = {}, d[n.axis] = a || n.parse(r[c], c), l.push(Io(f, d, o, c));
return l;
}
function Vi(i) {
return i && i.barStart !== void 0 && i.barEnd !== void 0;
}
function El(i, t, e) {
return i !== 0 ? pt(i) : (t.isHorizontal() ? 1 : -1) * (t.min >= e ? 1 : -1);
}
function Ll(i) {
let t, e, s, n, o;
return i.horizontal ? (t = i.base > i.x, e = "left", s = "right") : (t = i.base < i.y, e = "bottom", s = "top"), t ? (n = "end", o = "start") : (n = "start", o = "end"), {
start: e,
end: s,
reverse: t,
top: n,
bottom: o
};
}
function Rl(i, t, e, s) {
let n = t.borderSkipped;
const o = {};
if (!n) {
i.borderSkipped = o;
return;
}
if (n === !0) {
i.borderSkipped = {
top: !0,
right: !0,
bottom: !0,
left: !0
};
return;
}
const { start: r, end: a, reverse: l, top: c, bottom: h } = Ll(i);
n === "middle" && e && (i.enableBorderRadius = !0, (e._top || 0) === s ? n = c : (e._bottom || 0) === s ? n = h : (o[fn(h, r, a, l)] = !0, n = c)), o[fn(n, r, a, l)] = !0, i.borderSkipped = o;
}
function fn(i, t, e, s) {
return s ? (i = Fl(i, t, e), i = un(i, e, t)) : i = un(i, t, e), i;
}
function Fl(i, t, e) {
return i === t ? e : i === e ? t : i;
}
function un(i, t, e) {
return i === "start" ? t : i === "end" ? e : i;
}
function zl(i, { inflateAmount: t }, e) {
i.inflateAmount = t === "auto" ? e === 1 ? 0.33 : 0 : t;
}
class li extends dt {
parsePrimitiveData(t, e, s, n) {
return dn(t, e, s, n);
}
parseArrayData(t, e, s, n) {
return dn(t, e, s, n);
}
parseObjectData(t, e, s, n) {
const { iScale: o, vScale: r } = t, { xAxisKey: a = "x", yAxisKey: l = "y" } = this._parsing, c = o.axis === "x" ? a : l, h = r.axis === "x" ? a : l, d = [];
let f, u, g, p;
for (f = s, u = s + n; f < u; ++f)
p = e[f], g = {}, g[o.axis] = o.parse(Et(p, c), f), d.push(Io(Et(p, h), g, r, f));
return d;
}
updateRangeFromParsed(t, e, s, n) {
super.updateRangeFromParsed(t, e, s, n);
const o = s._custom;
o && e === this._cachedMeta.vScale && (t.min = Math.min(t.min, o.min), t.max = Math.max(t.max, o.max));
}
getMaxOverflow() {
return 0;
}
getLabelAndValue(t) {
const e = this._cachedMeta, { iScale: s, vScale: n } = e, o = this.getParsed(t), r = o._custom, a = Vi(r) ? "[" + r.start + ", " + r.end + "]" : "" + n.getLabelForValue(o[n.axis]);
return {
label: "" + s.getLabelForValue(o[s.axis]),
value: a
};
}
initialize() {
this.enableOptionSharing = !0, super.initialize();
const t = this._cachedMeta;
t.stack = this.getDataset().stack;
}
update(t) {
const e = this._cachedMeta;
this.updateElements(e.data, 0, e.data.length, t);
}
updateElements(t, e, s, n) {
const o = n === "reset", { index: r, _cachedMeta: { vScale: a } } = this, l = a.getBasePixel(), c = a.isHorizontal(), h = this._getRuler(), { sharedOptions: d, includeOptions: f } = this._getSharedOptions(e, n);
for (let u = e; u < e + s; u++) {
const g = this.getParsed(u), p = o || E(g[a.axis]) ? {
base: l,
head: l
} : this._calculateBarValuePixels(u), m = this._calculateBarIndexPixels(u, h), b = (g._stacks || {})[a.axis], x = {
horizontal: c,
base: p.base,
enableBorderRadius: !b || Vi(g._custom) || r === b._top || r === b._bottom,
x: c ? p.head : m.center,
y: c ? m.center : p.head,
height: c ? m.size : Math.abs(p.size),
width: c ? Math.abs(p.size) : m.size
};
f && (x.options = d || this.resolveDataElementOptions(u, t[u].active ? "active" : n));
const v = x.options || t[u].options;
Rl(x, v, b, r), zl(x, v, h.ratio), this.updateElement(t[u], u, x, n);
}
}
_getStacks(t, e) {
const { iScale: s } = this._cachedMeta, n = s.getMatchingVisibleMetas(this._type).filter((h) => h.controller.options.grouped), o = s.options.stacked, r = [], a = this._cachedMeta.controller.getParsed(e), l = a && a[s.axis], c = (h) => {
const d = h._parsed.find((u) => u[s.axis] === l), f = d && d[h.vScale.axis];
if (E(f) || isNaN(f))
return !0;
};
for (const h of n)
if (!(e !== void 0 && c(h)) && ((o === !1 || r.indexOf(h.stack) === -1 || o === void 0 && h.stack === void 0) && r.push(h.stack), h.index === t))
break;
return r.length || r.push(void 0), r;
}
_getStackCount(t) {
return this._getStacks(void 0, t).length;
}
_getStackIndex(t, e, s) {
const n = this._getStacks(t, s), o = e !== void 0 ? n.indexOf(e) : -1;
return o === -1 ? n.length - 1 : o;
}
_getRuler() {
const t = this.options, e = this._cachedMeta, s = e.iScale, n = [];
let o, r;
for (o = 0, r = e.data.length; o < r; ++o)
n.push(s.getPixelForValue(this.getParsed(o)[s.axis], o));
const a = t.barThickness;
return {
min: a || Dl(e),
pixels: n,
start: s._startPixel,
end: s._endPixel,
stackCount: this._getStackCount(),
scale: s,
grouped: t.grouped,
ratio: a ? 1 : t.categoryPercentage * t.barPercentage
};
}
_calculateBarValuePixels(t) {
const { _cachedMeta: { vScale: e, _stacked: s, index: n }, options: { base: o, minBarLength: r } } = this, a = o || 0, l = this.getParsed(t), c = l._custom, h = Vi(c);
let d = l[e.axis], f = 0, u = s ? this.applyStack(e, l, s) : d, g, p;
u !== d && (f = u - d, u = d), h && (d = c.barStart, u = c.barEnd - c.barStart, d !== 0 && pt(d) !== pt(c.barEnd) && (f = 0), f += d);
const m = !E(o) && !h ? o : f;
let b = e.getPixelForValue(m);
if (this.chart.getDataVisibility(t) ? g = e.getPixelForValue(f + u) : g = b, p = g - b, Math.abs(p) < r) {
p = El(p, e, a) * r, d === a && (b -= p / 2);
const x = e.getPixelForDecimal(0), v = e.getPixelForDecimal(1), y = Math.min(x, v), _ = Math.max(x, v);
b = Math.max(Math.min(b, _), y), g = b + p, s && !h && (l._stacks[e.axis]._visualValues[n] = e.getValueForPixel(g) - e.getValueForPixel(b));
}
if (b === e.getPixelForValue(a)) {
const x = pt(p) * e.getLineWidthForValue(a) / 2;
b += x, p -= x;
}
return {
size: p,
base: b,
head: g,
center: g + p / 2
};
}
_calculateBarIndexPixels(t, e) {
const s = e.scale, n = this.options, o = n.skipNull, r = C(n.maxBarThickness, 1 / 0);
let a, l;
if (e.grouped) {
const c = o ? this._getStackCount(t) : e.stackCount, h = n.barThickness === "flex" ? Al(t, e, n, c) : Ol(t, e, n, c), d = this._getStackIndex(this.index, this._cachedMeta.stack, o ? t : void 0);
a = h.start + h.chunk * d + h.chunk / 2, l = Math.min(r, h.chunk * h.ratio);
} else
a = s.getPixelForValue(this.getParsed(t)[s.axis], t), l = Math.min(r, e.min * e.ratio);
return {
base: a - l / 2,
head: a + l / 2,
center: a,
size: l
};
}
draw() {
const t = this._cachedMeta, e = t.vScale, s = t.data, n = s.length;
let o = 0;
for (; o < n; ++o)
this.getParsed(o)[e.axis] !== null && !s[o].hidden && s[o].draw(this._ctx);
}
}
w(li, "id", "bar"), w(li, "defaults", {
datasetElementType: !1,
dataElementType: "bar",
categoryPercentage: 0.8,
barPercentage: 0.9,
grouped: !0,
animations: {
numbers: {
type: "number",
properties: [
"x",
"y",
"base",
"width",
"height"
]
}
}
}), w(li, "overrides", {
scales: {
_index_: {
type: "category",
offset: !0,
grid: {
offset: !0
}
},
_value_: {
type: "linear",
beginAtZero: !0
}
}
});
class ci extends dt {
initialize() {
this.enableOptionSharing = !0, super.initialize();
}
parsePrimitiveData(t, e, s, n) {
const o = super.parsePrimitiveData(t, e, s, n);
for (let r = 0; r < o.length; r++)
o[r]._custom = this.resolveDataElementOptions(r + s).radius;
return o;
}
parseArrayData(t, e, s, n) {
const o = super.parseArrayData(t, e, s, n);
for (let r = 0; r < o.length; r++) {
const a = e[s + r];
o[r]._custom = C(a[2], this.resolveDataElementOptions(r + s).radius);
}
return o;
}
parseObjectData(t, e, s, n) {
const o = super.parseObjectData(t, e, s, n);
for (let r = 0; r < o.length; r++) {
const a = e[s + r];
o[r]._custom = C(a && a.r && +a.r, this.resolveDataElementOptions(r + s).radius);
}
return o;
}
getMaxOverflow() {
const t = this._cachedMeta.data;
let e = 0;
for (let s = t.length - 1; s >= 0; --s)
e = Math.max(e, t[s].size(this.resolveDataElementOptions(s)) / 2);
return e > 0 && e;
}
getLabelAndValue(t) {
const e = this._cachedMeta, s = this.chart.data.labels || [], { xScale: n, yScale: o } = e, r = this.getParsed(t), a = n.getLabelForValue(r.x), l = o.getLabelForValue(r.y), c = r._custom;
return {
label: s[t] || "",
value: "(" + a + ", " + l + (c ? ", " + c : "") + ")"
};
}
update(t) {
const e = this._cachedMeta.data;
this.updateElements(e, 0, e.length, t);
}
updateElements(t, e, s, n) {
const o = n === "reset", { iScale: r, vScale: a } = this._cachedMeta, { sharedOptions: l, includeOptions: c } = this._getSharedOptions(e, n), h = r.axis, d = a.axis;
for (let f = e; f < e + s; f++) {
const u = t[f], g = !o && this.getParsed(f), p = {}, m = p[h] = o ? r.getPixelForDecimal(0.5) : r.getPixelForValue(g[h]), b = p[d] = o ? a.getBasePixel() : a.getPixelForValue(g[d]);
p.skip = isNaN(m) || isNaN(b), c && (p.options = l || this.resolveDataElementOptions(f, u.active ? "active" : n), o && (p.options.radius = 0)), this.updateElement(u, f, p, n);
}
}
resolveDataElementOptions(t, e) {
const s = this.getParsed(t);
let n = super.resolveDataElementOptions(t, e);
n.$shared && (n = Object.assign({}, n, {
$shared: !1
}));
const o = n.radius;
return e !== "active" && (n.radius = 0), n.radius += C(s && s._custom, o), n;
}
}
w(ci, "id", "bubble"), w(ci, "defaults", {
datasetElementType: !1,
dataElementType: "point",
animations: {
numbers: {
type: "number",
properties: [
"x",
"y",
"borderWidth",
"radius"
]
}
}
}), w(ci, "overrides", {
scales: {
x: {
type: "linear"
},
y: {
type: "linear"
}
}
});
function Il(i, t, e) {
let s = 1, n = 1, o = 0, r = 0;
if (t < z) {
const a = i, l = a + t, c = Math.cos(a), h = Math.sin(a), d = Math.cos(l), f = Math.sin(l), u = (v, y, _) => Fe(v, a, l, !0) ? 1 : Math.max(y, y * e, _, _ * e), g = (v, y, _) => Fe(v, a, l, !0) ? -1 : Math.min(y, y * e, _, _ * e), p = u(0, c, d), m = u(U, h, f), b = g(I, c, d), x = g(I + U, h, f);
s = (p - b) / 2, n = (m - x) / 2, o = -(p + b) / 2, r = -(m + x) / 2;
}
return {
ratioX: s,
ratioY: n,
offsetX: o,
offsetY: r
};
}
class Yt extends dt {
constructor(t, e) {
super(t, e), this.enableOptionSharing = !0, this.innerRadius = void 0, this.outerRadius = void 0, this.offsetX = void 0, this.offsetY = void 0;
}
linkScales() {
}
parse(t, e) {
const s = this.getDataset().data, n = this._cachedMeta;
if (this._parsing === !1)
n._parsed = s;
else {
let o = (l) => +s[l];
if (A(s[t])) {
const { key: l = "value" } = this._parsing;
o = (c) => +Et(s[c], l);
}
let r, a;
for (r = t, a = t + e; r < a; ++r)
n._parsed[r] = o(r);
}
}
_getRotation() {
return ht(this.options.rotation - 90);
}
_getCircumference() {
return ht(this.options.circumference);
}
_getRotationExtents() {
let t = z, e = -z;
for (let s = 0; s < this.chart.data.datasets.length; ++s)
if (this.chart.isDatasetVisible(s) && this.chart.getDatasetMeta(s).type === this._type) {
const n = this.chart.getDatasetMeta(s).controller, o = n._getRotation(), r = n._getCircumference();
t = Math.min(t, o), e = Math.max(e, o + r);
}
return {
rotation: t,
circumference: e - t
};
}
update(t) {
const e = this.chart, { chartArea: s } = e, n = this._cachedMeta, o = n.data, r = this.getMaxBorderWidth() + this.getMaxOffset(o) + this.options.spacing, a = Math.max((Math.min(s.width, s.height) - r) / 2, 0), l = Math.min(Zr(this.options.cutout, a), 1), c = this._getRingWeight(this.index), { circumference: h, rotation: d } = this._getRotationExtents(), { ratioX: f, ratioY: u, offsetX: g, offsetY: p } = Il(d, h, l), m = (s.width - r) / f, b = (s.height - r) / u, x = Math.max(Math.min(m, b) / 2, 0), v = ho(this.options.radius, x), y = Math.max(v * l, 0), _ = (v - y) / this._getVisibleDatasetWeightTotal();
this.offsetX = g * v, this.offsetY = p * v, n.total = this.calculateTotal(), this.outerRadius = v - _ * this._getRingWeightOffset(this.index), this.innerRadius = Math.max(this.outerRadius - _ * c, 0), this.updateElements(o, 0, o.length, t);
}
_circumference(t, e) {
const s = this.options, n = this._cachedMeta, o = this._getCircumference();
return e && s.animation.animateRotate || !this.chart.getDataVisibility(t) || n._parsed[t] === null || n.data[t].hidden ? 0 : this.calculateCircumference(n._parsed[t] * o / z);
}
updateElements(t, e, s, n) {
const o = n === "reset", r = this.chart, a = r.chartArea, c = r.options.animation, h = (a.left + a.right) / 2, d = (a.top + a.bottom) / 2, f = o && c.animateScale, u = f ? 0 : this.innerRadius, g = f ? 0 : this.outerRadius, { sharedOptions: p, includeOptions: m } = this._getSharedOptions(e, n);
let b = this._getRotation(), x;
for (x = 0; x < e; ++x)
b += this._circumference(x, o);
for (x = e; x < e + s; ++x) {
const v = this._circumference(x, o), y = t[x], _ = {
x: h + this.offsetX,
y: d + this.offsetY,
startAngle: b,
endAngle: b + v,
circumference: v,
outerRadius: g,
innerRadius: u
};
m && (_.options = p || this.resolveDataElementOptions(x, y.active ? "active" : n)), b += v, this.updateElement(y, x, _, n);
}
}
calculateTotal() {
const t = this._cachedMeta, e = t.data;
let s = 0, n;
for (n = 0; n < e.length; n++) {
const o = t._parsed[n];
o !== null && !isNaN(o) && this.chart.getDataVisibility(n) && !e[n].hidden && (s += Math.abs(o));
}
return s;
}
calculateCircumference(t) {
const e = this._cachedMeta.total;
return e > 0 && !isNaN(t) ? z * (Math.abs(t) / e) : 0;
}
getLabelAndValue(t) {
const e = this._cachedMeta, s = this.chart, n = s.data.labels || [], o = Ne(e._parsed[t], s.options.locale);
return {
label: n[t] || "",
value: o
};
}
getMaxBorderWidth(t) {
let e = 0;
const s = this.chart;
let n, o, r, a, l;
if (!t) {
for (n = 0, o = s.data.datasets.length; n < o; ++n)
if (s.isDatasetVisible(n)) {
r = s.getDatasetMeta(n), t = r.data, a = r.controller;
break;
}
}
if (!t)
return 0;
for (n = 0, o = t.length; n < o; ++n)
l = a.resolveDataElementOptions(n), l.borderAlign !== "inner" && (e = Math.max(e, l.borderWidth || 0, l.hoverBorderWidth || 0));
return e;
}
getMaxOffset(t) {
let e = 0;
for (let s = 0, n = t.length; s < n; ++s) {
const o = this.resolveDataElementOptions(s);
e = Math.max(e, o.offset || 0, o.hoverOffset || 0);
}
return e;
}
_getRingWeightOffset(t) {
let e = 0;
for (let s = 0; s < t; ++s)
this.chart.isDatasetVisible(s) && (e += this._getRingWeight(s));
return e;
}
_getRingWeight(t) {
return Math.max(C(this.chart.data.datasets[t].weight, 1), 0);
}
_getVisibleDatasetWeightTotal() {
return this._getRingWeightOffset(this.chart.data.datasets.length) || 1;
}
}
w(Yt, "id", "doughnut"), w(Yt, "defaults", {
datasetElementType: !1,
dataElementType: "arc",
animation: {
animateRotate: !0,
animateScale: !1
},
animations: {
numbers: {
type: "number",
properties: [
"circumference",
"endAngle",
"innerRadius",
"outerRadius",
"startAngle",
"x",
"y",
"offset",
"borderWidth",
"spacing"
]
}
},
cutout: "50%",
rotation: 0,
circumference: 360,
radius: "100%",
spacing: 0,
indexAxis: "r"
}), w(Yt, "descriptors", {
_scriptable: (t) => t !== "spacing",
_indexable: (t) => t !== "spacing" && !t.startsWith("borderDash") && !t.startsWith("hoverBorderDash")
}), w(Yt, "overrides", {
aspectRatio: 1,
plugins: {
legend: {
labels: {
generateLabels(t) {
const e = t.data;
if (e.labels.length && e.datasets.length) {
const { labels: { pointStyle: s, color: n } } = t.legend.options;
return e.labels.map((o, r) => {
const l = t.getDatasetMeta(0).controller.getStyle(r);
return {
text: o,
fillStyle: l.backgroundColor,
strokeStyle: l.borderColor,
fontColor: n,
lineWidth: l.borderWidth,
pointStyle: s,
hidden: !t.getDataVisibility(r),
index: r
};
});
}
return [];
}
},
onClick(t, e, s) {
s.chart.toggleDataVisibility(e.index), s.chart.update();
}
}
}
});
class hi extends dt {
initialize() {
this.enableOptionSharing = !0, this.supportsDecimation = !0, super.initialize();
}
update(t) {
const e = this._cachedMeta, { dataset: s, data: n = [], _dataset: o } = e, r = this.chart._animationsDisabled;
let { start: a, count: l } = _o(e, n, r);
this._drawStart = a, this._drawCount = l, yo(e) && (a = 0, l = n.length), s._chart = this.chart, s._datasetIndex = this.index, s._decimated = !!o._decimated, s.points = n;
const c = this.resolveDatasetElementOptions(t);
this.options.showLine || (c.borderWidth = 0), c.segment = this.options.segment, this.updateElement(s, void 0, {
animated: !r,
options: c
}, t), this.updateElements(n, a, l, t);
}
updateElements(t, e, s, n) {
const o = n === "reset", { iScale: r, vScale: a, _stacked: l, _dataset: c } = this._cachedMeta, { sharedOptions: h, includeOptions: d } = this._getSharedOptions(e, n), f = r.axis, u = a.axis, { spanGaps: g, segment: p } = this.options, m = ae(g) ? g : Number.POSITIVE_INFINITY, b = this.chart._animationsDisabled || o || n === "none", x = e + s, v = t.length;
let y = e > 0 && this.getParsed(e - 1);
for (let _ = 0; _ < v; ++_) {
const k = t[_], S = b ? k : {};
if (_ < e || _ >= x) {
S.skip = !0;
continue;
}
const M = this.getParsed(_), P = E(M[u]), D = S[f] = r.getPixelForValue(M[f], _), O = S[u] = o || P ? a.getBasePixel() : a.getPixelForValue(l ? this.applyStack(a, M, l) : M[u], _);
S.skip = isNaN(D) || isNaN(O) || P, S.stop = _ > 0 && Math.abs(M[f] - y[f]) > m, p && (S.parsed = M, S.raw = c.data[_]), d && (S.options = h || this.resolveDataElementOptions(_, k.active ? "active" : n)), b || this.updateElement(k, _, S, n), y = M;
}
}
getMaxOverflow() {
const t = this._cachedMeta, e = t.dataset, s = e.options && e.options.borderWidth || 0, n = t.data || [];
if (!n.length)
return s;
const o = n[0].size(this.resolveDataElementOptions(0)), r = n[n.length - 1].size(this.resolveDataElementOptions(n.length - 1));
return Math.max(s, o, r) / 2;
}
draw() {
const t = this._cachedMeta;
t.dataset.updateControlPoints(this.chart.chartArea, t.iScale.axis), super.draw();
}
}
w(hi, "id", "line"), w(hi, "defaults", {
datasetElementType: "line",
dataElementType: "point",
showLine: !0,
spanGaps: !1
}), w(hi, "overrides", {
scales: {
_index_: {
type: "category"
},
_value_: {
type: "linear"
}
}
});
class Te extends dt {
constructor(t, e) {
super(t, e), this.innerRadius = void 0, this.outerRadius = void 0;
}
getLabelAndValue(t) {
const e = this._cachedMeta, s = this.chart, n = s.data.labels || [], o = Ne(e._parsed[t].r, s.options.locale);
return {
label: n[t] || "",
value: o
};
}
parseObjectData(t, e, s, n) {
return Do.bind(this)(t, e, s, n);
}
update(t) {
const e = this._cachedMeta.data;
this._updateRadius(), this.updateElements(e, 0, e.length, t);
}
getMinMax() {
const t = this._cachedMeta, e = {
min: Number.POSITIVE_INFINITY,
max: Number.NEGATIVE_INFINITY
};
return t.data.forEach((s, n) => {
const o = this.getParsed(n).r;
!isNaN(o) && this.chart.getDataVisibility(n) && (o < e.min && (e.min = o), o > e.max && (e.max = o));
}), e;
}
_updateRadius() {
const t = this.chart, e = t.chartArea, s = t.options, n = Math.min(e.right - e.left, e.bottom - e.top), o = Math.max(n / 2, 0), r = Math.max(s.cutoutPercentage ? o / 100 * s.cutoutPercentage : 1, 0), a = (o - r) / t.getVisibleDatasetCount();
this.outerRadius = o - a * this.index, this.innerRadius = this.outerRadius - a;
}
updateElements(t, e, s, n) {
const o = n === "reset", r = this.chart, l = r.options.animation, c = this._cachedMeta.rScale, h = c.xCenter, d = c.yCenter, f = c.getIndexAngle(0) - 0.5 * I;
let u = f, g;
const p = 360 / this.countVisibleElements();
for (g = 0; g < e; ++g)
u += this._computeAngle(g, n, p);
for (g = e; g < e + s; g++) {
const m = t[g];
let b = u, x = u + this._computeAngle(g, n, p), v = r.getDataVisibility(g) ? c.getDistanceFromCenterForValue(this.getParsed(g).r) : 0;
u = x, o && (l.animateScale && (v = 0), l.animateRotate && (b = x = f));
const y = {
x: h,
y: d,
innerRadius: 0,
outerRadius: v,
startAngle: b,
endAngle: x,
options: this.resolveDataElementOptions(g, m.active ? "active" : n)
};
this.updateElement(m, g, y, n);
}
}
countVisibleElements() {
const t = this._cachedMeta;
let e = 0;
return t.data.forEach((s, n) => {
!isNaN(this.getParsed(n).r) && this.chart.getDataVisibility(n) && e++;
}), e;
}
_computeAngle(t, e, s) {
return this.chart.getDataVisibility(t) ? ht(this.resolveDataElementOptions(t, e).angle || s) : 0;
}
}
w(Te, "id", "polarArea"), w(Te, "defaults", {
dataElementType: "arc",
animation: {
animateRotate: !0,
animateScale: !0
},
animations: {
numbers: {
type: "number",
properties: [
"x",
"y",
"startAngle",
"endAngle",
"innerRadius",
"outerRadius"
]
}
},
indexAxis: "r",
startAngle: 0
}), w(Te, "overrides", {
aspectRatio: 1,
plugins: {
legend: {
labels: {
generateLabels(t) {
const e = t.data;
if (e.labels.length && e.datasets.length) {
const { labels: { pointStyle: s, color: n } } = t.legend.options;
return e.labels.map((o, r) => {
const l = t.getDatasetMeta(0).controller.getStyle(r);
return {
text: o,
fillStyle: l.backgroundColor,
strokeStyle: l.borderColor,
fontColor: n,
lineWidth: l.borderWidth,
pointStyle: s,
hidden: !t.getDataVisibility(r),
index: r
};
});
}
return [];
}
},
onClick(t, e, s) {
s.chart.toggleDataVisibility(e.index), s.chart.update();
}
}
},
scales: {
r: {
type: "radialLinear",
angleLines: {
display: !1
},
beginAtZero: !0,
grid: {
circular: !0
},
pointLabels: {
display: !1
},
startAngle: 0
}
}
});
class ts extends Yt {
}
w(ts, "id", "pie"), w(ts, "defaults", {
cutout: 0,
rotation: 0,
circumference: 360,
radius: "100%"
});
class di extends dt {
getLabelAndValue(t) {
const e = this._cachedMeta.vScale, s = this.getParsed(t);
return {
label: e.getLabels()[t],
value: "" + e.getLabelForValue(s[e.axis])
};
}
parseObjectData(t, e, s, n) {
return Do.bind(this)(t, e, s, n);
}
update(t) {
const e = this._cachedMeta, s = e.dataset, n = e.data || [], o = e.iScale.getLabels();
if (s.points = n, t !== "resize") {
const r = this.resolveDatasetElementOptions(t);
this.options.showLine || (r.borderWidth = 0);
const a = {
_loop: !0,
_fullLoop: o.length === n.length,
options: r
};
this.updateElement(s, void 0, a, t);
}
this.updateElements(n, 0, n.length, t);
}
updateElements(t, e, s, n) {
const o = this._cachedMeta.rScale, r = n === "reset";
for (let a = e; a < e + s; a++) {
const l = t[a], c = this.resolveDataElementOptions(a, l.active ? "active" : n), h = o.getPointPositionForValue(a, this.getParsed(a).r), d = r ? o.xCenter : h.x, f = r ? o.yCenter : h.y, u = {
x: d,
y: f,
angle: h.angle,
skip: isNaN(d) || isNaN(f),
options: c
};
this.updateElement(l, a, u, n);
}
}
}
w(di, "id", "radar"), w(di, "defaults", {
datasetElementType: "line",
dataElementType: "point",
indexAxis: "r",
showLine: !0,
elements: {
line: {
fill: "start"
}
}
}), w(di, "overrides", {
aspectRatio: 1,
scales: {
r: {
type: "radialLinear"
}
}
});
class fi extends dt {
getLabelAndValue(t) {
const e = this._cachedMeta, s = this.chart.data.labels || [], { xScale: n, yScale: o } = e, r = this.getParsed(t), a = n.getLabelForValue(r.x), l = o.getLabelForValue(r.y);
return {
label: s[t] || "",
value: "(" + a + ", " + l + ")"
};
}
update(t) {
const e = this._cachedMeta, { data: s = [] } = e, n = this.chart._animationsDisabled;
let { start: o, count: r } = _o(e, s, n);
if (this._drawStart = o, this._drawCount = r, yo(e) && (o = 0, r = s.length), this.options.showLine) {
this.datasetElementType || this.addElements();
const { dataset: a, _dataset: l } = e;
a._chart = this.chart, a._datasetIndex = this.index, a._decimated = !!l._decimated, a.points = s;
const c = this.resolveDatasetElementOptions(t);
c.segment = this.options.segment, this.updateElement(a, void 0, {
animated: !n,
options: c
}, t);
} else this.datasetElementType && (delete e.dataset, this.datasetElementType = !1);
this.updateElements(s, o, r, t);
}
addElements() {
const { showLine: t } = this.options;
!this.datasetElementType && t && (this.datasetElementType = this.chart.registry.getElement("line")), super.addElements();
}
updateElements(t, e, s, n) {
const o = n === "reset", { iScale: r, vScale: a, _stacked: l, _dataset: c } = this._cachedMeta, h = this.resolveDataElementOptions(e, n), d = this.getSharedOptions(h), f = this.includeOptions(n, d), u = r.axis, g = a.axis, { spanGaps: p, segment: m } = this.options, b = ae(p) ? p : Number.POSITIVE_INFINITY, x = this.chart._animationsDisabled || o || n === "none";
let v = e > 0 && this.getParsed(e - 1);
for (let y = e; y < e + s; ++y) {
const _ = t[y], k = this.getParsed(y), S = x ? _ : {}, M = E(k[g]), P = S[u] = r.getPixelForValue(k[u], y), D = S[g] = o || M ? a.getBasePixel() : a.getPixelForValue(l ? this.applyStack(a, k, l) : k[g], y);
S.skip = isNaN(P) || isNaN(D) || M, S.stop = y > 0 && Math.abs(k[u] - v[u]) > b, m && (S.parsed = k, S.raw = c.data[y]), f && (S.options = d || this.resolveDataElementOptions(y, _.active ? "active" : n)), x || this.updateElement(_, y, S, n), v = k;
}
this.updateSharedOptions(d, n, h);
}
getMaxOverflow() {
const t = this._cachedMeta, e = t.data || [];
if (!this.options.showLine) {
let a = 0;
for (let l = e.length - 1; l >= 0; --l)
a = Math.max(a, e[l].size(this.resolveDataElementOptions(l)) / 2);
return a > 0 && a;
}
const s = t.dataset, n = s.options && s.options.borderWidth || 0;
if (!e.length)
return n;
const o = e[0].size(this.resolveDataElementOptions(0)), r = e[e.length - 1].size(this.resolveDataElementOptions(e.length - 1));
return Math.max(n, o, r) / 2;
}
}
w(fi, "id", "scatter"), w(fi, "defaults", {
datasetElementType: !1,
dataElementType: "point",
showLine: !1,
fill: !1
}), w(fi, "overrides", {
interaction: {
mode: "point"
},
scales: {
x: {
type: "linear"
},
y: {
type: "linear"
}
}
});
var Bl = /* @__PURE__ */ Object.freeze({
__proto__: null,
BarController: li,
BubbleController: ci,
DoughnutController: Yt,
LineController: hi,
PieController: ts,
PolarAreaController: Te,
RadarController: di,
ScatterController: fi
});
function Nt() {
throw new Error("This method is not implemented: Check that a complete date adapter is provided.");
}
class Ds {
constructor(t) {
w(this, "options");
this.options = t || {};
}
/**
* Override default date adapter methods.
* Accepts type parameter to define options type.
* @example
* Chart._adapters._date.override<{myAdapterOption: string}>({
* init() {
* console.log(this.options.myAdapterOption);
* }
* })
*/
static override(t) {
Object.assign(Ds.prototype, t);
}
// eslint-disable-next-line @typescript-eslint/no-empty-function
init() {
}
formats() {
return Nt();
}
parse() {
return Nt();
}
format() {
return Nt();
}
add() {
return Nt();
}
diff() {
return Nt();
}
startOf() {
return Nt();
}
endOf() {
return Nt();
}
}
var $l = {
_date: Ds
};
function jl(i, t, e, s) {
const { controller: n, data: o, _sorted: r } = i, a = n._cachedMeta.iScale;
if (a && t === a.axis && t !== "r" && r && o.length) {
const l = a._reversePixels ? ca : wt;
if (s) {
if (n._sharedOptions) {
const c = o[0], h = typeof c.getRange == "function" && c.getRange(t);
if (h) {
const d = l(o, t, e - h), f = l(o, t, e + h);
return {
lo: d.lo,
hi: f.hi
};
}
}
} else return l(o, t, e);
}
return {
lo: 0,
hi: o.length - 1
};
}
function Ve(i, t, e, s, n) {
const o = i.getSortedVisibleDatasetMetas(), r = e[t];
for (let a = 0, l = o.length; a < l; ++a) {
const { index: c, data: h } = o[a], { lo: d, hi: f } = jl(o[a], t, r, n);
for (let u = d; u <= f; ++u) {
const g = h[u];
g.skip || s(g, c, u);
}
}
}
function Wl(i) {
const t = i.indexOf("x") !== -1, e = i.indexOf("y") !== -1;
return function(s, n) {
const o = t ? Math.abs(s.x - n.x) : 0, r = e ? Math.abs(s.y - n.y) : 0;
return Math.sqrt(Math.pow(o, 2) + Math.pow(r, 2));
};
}
function Hi(i, t, e, s, n) {
const o = [];
return !n && !i.isPointInArea(t) || Ve(i, e, t, function(a, l, c) {
!n && !kt(a, i.chartArea, 0) || a.inRange(t.x, t.y, s) && o.push({
element: a,
datasetIndex: l,
index: c
});
}, !0), o;
}
function Nl(i, t, e, s) {
let n = [];
function o(r, a, l) {
const { startAngle: c, endAngle: h } = r.getProps([
"startAngle",
"endAngle"
], s), { angle: d } = go(r, {
x: t.x,
y: t.y
});
Fe(d, c, h) && n.push({
element: r,
datasetIndex: a,
index: l
});
}
return Ve(i, e, t, o), n;
}
function Vl(i, t, e, s, n, o) {
let r = [];
const a = Wl(e);
let l = Number.POSITIVE_INFINITY;
function c(h, d, f) {
const u = h.inRange(t.x, t.y, n);
if (s && !u)
return;
const g = h.getCenterPoint(n);
if (!(!!o || i.isPointInArea(g)) && !u)
return;
const m = a(t, g);
m < l ? (r = [
{
element: h,
datasetIndex: d,
index: f
}
], l = m) : m === l && r.push({
element: h,
datasetIndex: d,
index: f
});
}
return Ve(i, e, t, c), r;
}
function Ui(i, t, e, s, n, o) {
return !o && !i.isPointInArea(t) ? [] : e === "r" && !s ? Nl(i, t, e, n) : Vl(i, t, e, s, n, o);
}
function gn(i, t, e, s, n) {
const o = [], r = e === "x" ? "inXRange" : "inYRange";
let a = !1;
return Ve(i, e, t, (l, c, h) => {
l[r] && l[r](t[e], n) && (o.push({
element: l,
datasetIndex: c,
index: h
}), a = a || l.inRange(t.x, t.y, n));
}), s && !a ? [] : o;
}
var Hl = {
evaluateInteractionItems: Ve,
modes: {
index(i, t, e, s) {
const n = Ht(t, i), o = e.axis || "x", r = e.includeInvisible || !1, a = e.intersect ? Hi(i, n, o, s, r) : Ui(i, n, o, !1, s, r), l = [];
return a.length ? (i.getSortedVisibleDatasetMetas().forEach((c) => {
const h = a[0].index, d = c.data[h];
d && !d.skip && l.push({
element: d,
datasetIndex: c.index,
index: h
});
}), l) : [];
},
dataset(i, t, e, s) {
const n = Ht(t, i), o = e.axis || "xy", r = e.includeInvisible || !1;
let a = e.intersect ? Hi(i, n, o, s, r) : Ui(i, n, o, !1, s, r);
if (a.length > 0) {
const l = a[0].datasetIndex, c = i.getDatasetMeta(l).data;
a = [];
for (let h = 0; h < c.length; ++h)
a.push({
element: c[h],
datasetIndex: l,
index: h
});
}
return a;
},
point(i, t, e, s) {
const n = Ht(t, i), o = e.axis || "xy", r = e.includeInvisible || !1;
return Hi(i, n, o, s, r);
},
nearest(i, t, e, s) {
const n = Ht(t, i), o = e.axis || "xy", r = e.includeInvisible || !1;
return Ui(i, n, o, e.intersect, s, r);
},
x(i, t, e, s) {
const n = Ht(t, i);
return gn(i, n, "x", e.intersect, s);
},
y(i, t, e, s) {
const n = Ht(t, i);
return gn(i, n, "y", e.intersect, s);
}
}
};
const Bo = [
"left",
"top",
"right",
"bottom"
];
function me(i, t) {
return i.filter((e) => e.pos === t);
}
function pn(i, t) {
return i.filter((e) => Bo.indexOf(e.pos) === -1 && e.box.axis === t);
}
function be(i, t) {
return i.sort((e, s) => {
const n = t ? s : e, o = t ? e : s;
return n.weight === o.weight ? n.index - o.index : n.weight - o.weight;
});
}
function Ul(i) {
const t = [];
let e, s, n, o, r, a;
for (e = 0, s = (i || []).length; e < s; ++e)
n = i[e], { position: o, options: { stack: r, stackWeight: a = 1 } } = n, t.push({
index: e,
box: n,
pos: o,
horizontal: n.isHorizontal(),
weight: n.weight,
stack: r && o + r,
stackWeight: a
});
return t;
}
function Yl(i) {
const t = {};
for (const e of i) {
const { stack: s, pos: n, stackWeight: o } = e;
if (!s || !Bo.includes(n))
continue;
const r = t[s] || (t[s] = {
count: 0,
placed: 0,
weight: 0,
size: 0
});
r.count++, r.weight += o;
}
return t;
}
function Xl(i, t) {
const e = Yl(i), { vBoxMaxWidth: s, hBoxMaxHeight: n } = t;
let o, r, a;
for (o = 0, r = i.length; o < r; ++o) {
a = i[o];
const { fullSize: l } = a.box, c = e[a.stack], h = c && a.stackWeight / c.weight;
a.horizontal ? (a.width = h ? h * s : l && t.availableWidth, a.height = n) : (a.width = s, a.height = h ? h * n : l && t.availableHeight);
}
return e;
}
function Kl(i) {
const t = Ul(i), e = be(t.filter((c) => c.box.fullSize), !0), s = be(me(t, "left"), !0), n = be(me(t, "right")), o = be(me(t, "top"), !0), r = be(me(t, "bottom")), a = pn(t, "x"), l = pn(t, "y");
return {
fullSize: e,
leftAndTop: s.concat(o),
rightAndBottom: n.concat(l).concat(r).concat(a),
chartArea: me(t, "chartArea"),
vertical: s.concat(n).concat(l),
horizontal: o.concat(r).concat(a)
};
}
function mn(i, t, e, s) {
return Math.max(i[e], t[e]) + Math.max(i[s], t[s]);
}
function $o(i, t) {
i.top = Math.max(i.top, t.top), i.left = Math.max(i.left, t.left), i.bottom = Math.max(i.bottom, t.bottom), i.right = Math.max(i.right, t.right);
}
function ql(i, t, e, s) {
const { pos: n, box: o } = e, r = i.maxPadding;
if (!A(n)) {
e.size && (i[n] -= e.size);
const d = s[e.stack] || {
size: 0,
count: 1
};
d.size = Math.max(d.size, e.horizontal ? o.height : o.width), e.size = d.size / d.count, i[n] += e.size;
}
o.getPadding && $o(r, o.getPadding());
const a = Math.max(0, t.outerWidth - mn(r, i, "left", "right")), l = Math.max(0, t.outerHeight - mn(r, i, "top", "bottom")), c = a !== i.w, h = l !== i.h;
return i.w = a, i.h = l, e.horizontal ? {
same: c,
other: h
} : {
same: h,
other: c
};
}
function Gl(i) {
const t = i.maxPadding;
function e(s) {
const n = Math.max(t[s] - i[s], 0);
return i[s] += n, n;
}
i.y += e("top"), i.x += e("left"), e("right"), e("bottom");
}
function Zl(i, t) {
const e = t.maxPadding;
function s(n) {
const o = {
left: 0,
top: 0,
right: 0,
bottom: 0
};
return n.forEach((r) => {
o[r] = Math.max(t[r], e[r]);
}), o;
}
return s(i ? [
"left",
"right"
] : [
"top",
"bottom"
]);
}
function we(i, t, e, s) {
const n = [];
let o, r, a, l, c, h;
for (o = 0, r = i.length, c = 0; o < r; ++o) {
a = i[o], l = a.box, l.update(a.width || t.w, a.height || t.h, Zl(a.horizontal, t));
const { same: d, other: f } = ql(t, e, a, s);
c |= d && n.length, h = h || f, l.fullSize || n.push(a);
}
return c && we(n, t, e, s) || h;
}
function Je(i, t, e, s, n) {
i.top = e, i.left = t, i.right = t + s, i.bottom = e + n, i.width = s, i.height = n;
}
function bn(i, t, e, s) {
const n = e.padding;
let { x: o, y: r } = t;
for (const a of i) {
const l = a.box, c = s[a.stack] || {
count: 1,
placed: 0,
weight: 1
}, h = a.stackWeight / c.weight || 1;
if (a.horizontal) {
const d = t.w * h, f = c.size || l.height;
Re(c.start) && (r = c.start), l.fullSize ? Je(l, n.left, r, e.outerWidth - n.right - n.left, f) : Je(l, t.left + c.placed, r, d, f), c.start = r, c.placed += d, r = l.bottom;
} else {
const d = t.h * h, f = c.size || l.width;
Re(c.start) && (o = c.start), l.fullSize ? Je(l, o, n.top, f, e.outerHeight - n.bottom - n.top) : Je(l, o, t.top + c.placed, f, d), c.start = o, c.placed += d, o = l.right;
}
}
t.x = o, t.y = r;
}
var Q = {
addBox(i, t) {
i.boxes || (i.boxes = []), t.fullSize = t.fullSize || !1, t.position = t.position || "top", t.weight = t.weight || 0, t._layers = t._layers || function() {
return [
{
z: 0,
draw(e) {
t.draw(e);
}
}
];
}, i.boxes.push(t);
},
removeBox(i, t) {
const e = i.boxes ? i.boxes.indexOf(t) : -1;
e !== -1 && i.boxes.splice(e, 1);
},
configure(i, t, e) {
t.fullSize = e.fullSize, t.position = e.position, t.weight = e.weight;
},
update(i, t, e, s) {
if (!i)
return;
const n = J(i.options.layout.padding), o = Math.max(t - n.width, 0), r = Math.max(e - n.height, 0), a = Kl(i.boxes), l = a.vertical, c = a.horizontal;
L(i.boxes, (p) => {
typeof p.beforeLayout == "function" && p.beforeLayout();
});
const h = l.reduce((p, m) => m.box.options && m.box.options.display === !1 ? p : p + 1, 0) || 1, d = Object.freeze({
outerWidth: t,
outerHeight: e,
padding: n,
availableWidth: o,
availableHeight: r,
vBoxMaxWidth: o / 2 / h,
hBoxMaxHeight: r / 2
}), f = Object.assign({}, n);
$o(f, J(s));
const u = Object.assign({
maxPadding: f,
w: o,
h: r,
x: n.left,
y: n.top
}, n), g = Xl(l.concat(c), d);
we(a.fullSize, u, d, g), we(l, u, d, g), we(c, u, d, g) && we(l, u, d, g), Gl(u), bn(a.leftAndTop, u, d, g), u.x += u.w, u.y += u.h, bn(a.rightAndBottom, u, d, g), i.chartArea = {
left: u.left,
top: u.top,
right: u.left + u.w,
bottom: u.top + u.h,
height: u.h,
width: u.w
}, L(a.chartArea, (p) => {
const m = p.box;
Object.assign(m, i.chartArea), m.update(u.w, u.h, {
left: 0,
top: 0,
right: 0,
bottom: 0
});
});
}
};
class jo {
acquireContext(t, e) {
}
releaseContext(t) {
return !1;
}
addEventListener(t, e, s) {
}
removeEventListener(t, e, s) {
}
getDevicePixelRatio() {
return 1;
}
getMaximumSize(t, e, s, n) {
return e = Math.max(0, e || t.width), s = s || t.height, {
width: e,
height: Math.max(0, n ? Math.floor(e / n) : s)
};
}
isAttached(t) {
return !0;
}
updateConfig(t) {
}
}
class Ql extends jo {
acquireContext(t) {
return t && t.getContext && t.getContext("2d") || null;
}
updateConfig(t) {
t.options.animation = !1;
}
}
const ui = "$chartjs", Jl = {
touchstart: "mousedown",
touchmove: "mousemove",
touchend: "mouseup",
pointerenter: "mouseenter",
pointerdown: "mousedown",
pointermove: "mousemove",
pointerup: "mouseup",
pointerleave: "mouseout",
pointerout: "mouseout"
}, xn = (i) => i === null || i === "";
function tc(i, t) {
const e = i.style, s = i.getAttribute("height"), n = i.getAttribute("width");
if (i[ui] = {
initial: {
height: s,
width: n,
style: {
display: e.display,
height: e.height,
width: e.width
}
}
}, e.display = e.display || "block", e.boxSizing = e.boxSizing || "border-box", xn(n)) {
const o = tn(i, "width");
o !== void 0 && (i.width = o);
}
if (xn(s))
if (i.style.height === "")
i.height = i.width / (t || 2);
else {
const o = tn(i, "height");
o !== void 0 && (i.height = o);
}
return i;
}
const Wo = il ? {
passive: !0
} : !1;
function ec(i, t, e) {
i && i.addEventListener(t, e, Wo);
}
function ic(i, t, e) {
i && i.canvas && i.canvas.removeEventListener(t, e, Wo);
}
function sc(i, t) {
const e = Jl[i.type] || i.type, { x: s, y: n } = Ht(i, t);
return {
type: e,
chart: t,
native: i,
x: s !== void 0 ? s : null,
y: n !== void 0 ? n : null
};
}
function Mi(i, t) {
for (const e of i)
if (e === t || e.contains(t))
return !0;
}
function nc(i, t, e) {
const s = i.canvas, n = new MutationObserver((o) => {
let r = !1;
for (const a of o)
r = r || Mi(a.addedNodes, s), r = r && !Mi(a.removedNodes, s);
r && e();
});
return n.observe(document, {
childList: !0,
subtree: !0
}), n;
}
function oc(i, t, e) {
const s = i.canvas, n = new MutationObserver((o) => {
let r = !1;
for (const a of o)
r = r || Mi(a.removedNodes, s), r = r && !Mi(a.addedNodes, s);
r && e();
});
return n.observe(document, {
childList: !0,
subtree: !0
}), n;
}
const Ie = /* @__PURE__ */ new Map();
let _n = 0;
function No() {
const i = window.devicePixelRatio;
i !== _n && (_n = i, Ie.forEach((t, e) => {
e.currentDevicePixelRatio !== i && t();
}));
}
function rc(i, t) {
Ie.size || window.addEventListener("resize", No), Ie.set(i, t);
}
function ac(i) {
Ie.delete(i), Ie.size || window.removeEventListener("resize", No);
}
function lc(i, t, e) {
const s = i.canvas, n = s && Cs(s);
if (!n)
return;
const o = xo((a, l) => {
const c = n.clientWidth;
e(a, l), c < n.clientWidth && e();
}, window), r = new ResizeObserver((a) => {
const l = a[0], c = l.contentRect.width, h = l.contentRect.height;
c === 0 && h === 0 || o(c, h);
});
return r.observe(n), rc(i, o), r;
}
function Yi(i, t, e) {
e && e.disconnect(), t === "resize" && ac(i);
}
function cc(i, t, e) {
const s = i.canvas, n = xo((o) => {
i.ctx !== null && e(sc(o, i));
}, i);
return ec(s, t, n), n;
}
class hc extends jo {
acquireContext(t, e) {
const s = t && t.getContext && t.getContext("2d");
return s && s.canvas === t ? (tc(t, e), s) : null;
}
releaseContext(t) {
const e = t.canvas;
if (!e[ui])
return !1;
const s = e[ui].initial;
[
"height",
"width"
].forEach((o) => {
const r = s[o];
E(r) ? e.removeAttribute(o) : e.setAttribute(o, r);
});
const n = s.style || {};
return Object.keys(n).forEach((o) => {
e.style[o] = n[o];
}), e.width = e.width, delete e[ui], !0;
}
addEventListener(t, e, s) {
this.removeEventListener(t, e);
const n = t.$proxies || (t.$proxies = {}), r = {
attach: nc,
detach: oc,
resize: lc
}[e] || cc;
n[e] = r(t, e, s);
}
removeEventListener(t, e) {
const s = t.$proxies || (t.$proxies = {}), n = s[e];
if (!n)
return;
({
attach: Yi,
detach: Yi,
resize: Yi
}[e] || ic)(t, e, n), s[e] = void 0;
}
getDevicePixelRatio() {
return window.devicePixelRatio;
}
getMaximumSize(t, e, s, n) {
return el(t, e, s, n);
}
isAttached(t) {
const e = t && Cs(t);
return !!(e && e.isConnected);
}
}
function dc(i) {
return !Ps() || typeof OffscreenCanvas < "u" && i instanceof OffscreenCanvas ? Ql : hc;
}
class ft {
constructor() {
w(this, "x");
w(this, "y");
w(this, "active", !1);
w(this, "options");
w(this, "$animations");
}
tooltipPosition(t) {
const { x: e, y: s } = this.getProps([
"x",
"y"
], t);
return {
x: e,
y: s
};
}
hasValue() {
return ae(this.x) && ae(this.y);
}
getProps(t, e) {
const s = this.$animations;
if (!e || !s)
return this;
const n = {};
return t.forEach((o) => {
n[o] = s[o] && s[o].active() ? s[o]._to : this[o];
}), n;
}
}
w(ft, "defaults", {}), w(ft, "defaultRoutes");
function fc(i, t) {
const e = i.options.ticks, s = uc(i), n = Math.min(e.maxTicksLimit || s, s), o = e.major.enabled ? pc(t) : [], r = o.length, a = o[0], l = o[r - 1], c = [];
if (r > n)
return mc(t, c, o, r / n), c;
const h = gc(o, t, n);
if (r > 0) {
let d, f;
const u = r > 1 ? Math.round((l - a) / (r - 1)) : null;
for (ti(t, c, h, E(u) ? 0 : a - u, a), d = 0, f = r - 1; d < f; d++)
ti(t, c, h, o[d], o[d + 1]);
return ti(t, c, h, l, E(u) ? t.length : l + u), c;
}
return ti(t, c, h), c;
}
function uc(i) {
const t = i.options.offset, e = i._tickSize(), s = i._length / e + (t ? 0 : 1), n = i._maxLength / e;
return Math.floor(Math.min(s, n));
}
function gc(i, t, e) {
const s = bc(i), n = t.length / e;
if (!s)
return Math.max(n, 1);
const o = oa(s);
for (let r = 0, a = o.length - 1; r < a; r++) {
const l = o[r];
if (l > n)
return l;
}
return Math.max(n, 1);
}
function pc(i) {
const t = [];
let e, s;
for (e = 0, s = i.length; e < s; e++)
i[e].major && t.push(e);
return t;
}
function mc(i, t, e, s) {
let n = 0, o = e[0], r;
for (s = Math.ceil(s), r = 0; r < i.length; r++)
r === o && (t.push(i[r]), n++, o = e[n * s]);
}
function ti(i, t, e, s, n) {
const o = C(s, 0), r = Math.min(C(n, i.length), i.length);
let a = 0, l, c, h;
for (e = Math.ceil(e), n && (l = n - s, e = l / Math.floor(l / e)), h = o; h < 0; )
a++, h = Math.round(o + a * e);
for (c = Math.max(o, 0); c < r; c++)
c === h && (t.push(i[c]), a++, h = Math.round(o + a * e));
}
function bc(i) {
const t = i.length;
let e, s;
if (t < 2)
return !1;
for (s = i[0], e = 1; e < t; ++e)
if (i[e] - i[e - 1] !== s)
return !1;
return s;
}
const xc = (i) => i === "left" ? "right" : i === "right" ? "left" : i, yn = (i, t, e) => t === "top" || t === "left" ? i[t] + e : i[t] - e, vn = (i, t) => Math.min(t || i, i);
function wn(i, t) {
const e = [], s = i.length / t, n = i.length;
let o = 0;
for (; o < n; o += s)
e.push(i[Math.floor(o)]);
return e;
}
function _c(i, t, e) {
const s = i.ticks.length, n = Math.min(t, s - 1), o = i._startPixel, r = i._endPixel, a = 1e-6;
let l = i.getPixelForTick(n), c;
if (!(e && (s === 1 ? c = Math.max(l - o, r - l) : t === 0 ? c = (i.getPixelForTick(1) - l) / 2 : c = (l - i.getPixelForTick(n - 1)) / 2, l += n < t ? c : -c, l < o - a || l > r + a)))
return l;
}
function yc(i, t) {
L(i, (e) => {
const s = e.gc, n = s.length / 2;
let o;
if (n > t) {
for (o = 0; o < n; ++o)
delete e.data[s[o]];
s.splice(0, n);
}
});
}
function xe(i) {
return i.drawTicks ? i.tickLength : 0;
}
function kn(i, t) {
if (!i.display)
return 0;
const e = Y(i.font, t), s = J(i.padding);
return ($(i.text) ? i.text.length : 1) * e.lineHeight + s.height;
}
function vc(i, t) {
return It(i, {
scale: t,
type: "scale"
});
}
function wc(i, t, e) {
return It(i, {
tick: e,
index: t,
type: "tick"
});
}
function kc(i, t, e) {
let s = ys(i);
return (e && t !== "right" || !e && t === "right") && (s = xc(s)), s;
}
function Sc(i, t, e, s) {
const { top: n, left: o, bottom: r, right: a, chart: l } = i, { chartArea: c, scales: h } = l;
let d = 0, f, u, g;
const p = r - n, m = a - o;
if (i.isHorizontal()) {
if (u = Z(s, o, a), A(e)) {
const b = Object.keys(e)[0], x = e[b];
g = h[b].getPixelForValue(x) + p - t;
} else e === "center" ? g = (c.bottom + c.top) / 2 + p - t : g = yn(i, e, t);
f = a - o;
} else {
if (A(e)) {
const b = Object.keys(e)[0], x = e[b];
u = h[b].getPixelForValue(x) - m + t;
} else e === "center" ? u = (c.left + c.right) / 2 - m + t : u = yn(i, e, t);
g = Z(s, r, n), d = e === "left" ? -U : U;
}
return {
titleX: u,
titleY: g,
maxWidth: f,
rotation: d
};
}
class Jt extends ft {
constructor(t) {
super(), this.id = t.id, this.type = t.type, this.options = void 0, this.ctx = t.ctx, this.chart = t.chart, this.top = void 0, this.bottom = void 0, this.left = void 0, this.right = void 0, this.width = void 0, this.height = void 0, this._margins = {
left: 0,
right: 0,
top: 0,
bottom: 0
}, this.maxWidth = void 0, this.maxHeight = void 0, this.paddingTop = void 0, this.paddingBottom = void 0, this.paddingLeft = void 0, this.paddingRight = void 0, this.axis = void 0, this.labelRotation = void 0, this.min = void 0, this.max = void 0, this._range = void 0, this.ticks = [], this._gridLineItems = null, this._labelItems = null, this._labelSizes = null, this._length = 0, this._maxLength = 0, this._longestTextCache = {}, this._startPixel = void 0, this._endPixel = void 0, this._reversePixels = !1, this._userMax = void 0, this._userMin = void 0, this._suggestedMax = void 0, this._suggestedMin = void 0, this._ticksLength = 0, this._borderValue = 0, this._cache = {}, this._dataLimitsCached = !1, this.$context = void 0;
}
init(t) {
this.options = t.setContext(this.getContext()), this.axis = t.axis, this._userMin = this.parse(t.min), this._userMax = this.parse(t.max), this._suggestedMin = this.parse(t.suggestedMin), this._suggestedMax = this.parse(t.suggestedMax);
}
parse(t, e) {
return t;
}
getUserBounds() {
let { _userMin: t, _userMax: e, _suggestedMin: s, _suggestedMax: n } = this;
return t = nt(t, Number.POSITIVE_INFINITY), e = nt(e, Number.NEGATIVE_INFINITY), s = nt(s, Number.POSITIVE_INFINITY), n = nt(n, Number.NEGATIVE_INFINITY), {
min: nt(t, s),
max: nt(e, n),
minDefined: V(t),
maxDefined: V(e)
};
}
getMinMax(t) {
let { min: e, max: s, minDefined: n, maxDefined: o } = this.getUserBounds(), r;
if (n && o)
return {
min: e,
max: s
};
const a = this.getMatchingVisibleMetas();
for (let l = 0, c = a.length; l < c; ++l)
r = a[l].controller.getMinMax(this, t), n || (e = Math.min(e, r.min)), o || (s = Math.max(s, r.max));
return e = o && e > s ? s : e, s = n && e > s ? e : s, {
min: nt(e, nt(s, e)),
max: nt(s, nt(e, s))
};
}
getPadding() {
return {
left: this.paddingLeft || 0,
top: this.paddingTop || 0,
right: this.paddingRight || 0,
bottom: this.paddingBottom || 0
};
}
getTicks() {
return this.ticks;
}
getLabels() {
const t = this.chart.data;
return this.options.labels || (this.isHorizontal() ? t.xLabels : t.yLabels) || t.labels || [];
}
getLabelItems(t = this.chart.chartArea) {
return this._labelItems || (this._labelItems = this._computeLabelItems(t));
}
beforeLayout() {
this._cache = {}, this._dataLimitsCached = !1;
}
beforeUpdate() {
F(this.options.beforeUpdate, [
this
]);
}
update(t, e, s) {
const { beginAtZero: n, grace: o, ticks: r } = this.options, a = r.sampleSize;
this.beforeUpdate(), this.maxWidth = t, this.maxHeight = e, this._margins = s = Object.assign({
left: 0,
right: 0,
top: 0,
bottom: 0
}, s), this.ticks = null, this._labelSizes = null, this._gridLineItems = null, this._labelItems = null, this.beforeSetDimensions(), this.setDimensions(), this.afterSetDimensions(), this._maxLength = this.isHorizontal() ? this.width + s.left + s.right : this.height + s.top + s.bottom, this._dataLimitsCached || (this.beforeDataLimits(), this.determineDataLimits(), this.afterDataLimits(), this._range = La(this, o, n), this._dataLimitsCached = !0), this.beforeBuildTicks(), this.ticks = this.buildTicks() || [], this.afterBuildTicks();
const l = a < this.ticks.length;
this._convertTicksToLabels(l ? wn(this.ticks, a) : this.ticks), this.configure(), this.beforeCalculateLabelRotation(), this.calculateLabelRotation(), this.afterCalculateLabelRotation(), r.display && (r.autoSkip || r.source === "auto") && (this.ticks = fc(this, this.ticks), this._labelSizes = null, this.afterAutoSkip()), l && this._convertTicksToLabels(this.ticks), this.beforeFit(), this.fit(), this.afterFit(), this.afterUpdate();
}
configure() {
let t = this.options.reverse, e, s;
this.isHorizontal() ? (e = this.left, s = this.right) : (e = this.top, s = this.bottom, t = !t), this._startPixel = e, this._endPixel = s, this._reversePixels = t, this._length = s - e, this._alignToPixels = this.options.alignToPixels;
}
afterUpdate() {
F(this.options.afterUpdate, [
this
]);
}
beforeSetDimensions() {
F(this.options.beforeSetDimensions, [
this
]);
}
setDimensions() {
this.isHorizontal() ? (this.width = this.maxWidth, this.left = 0, this.right = this.width) : (this.height = this.maxHeight, this.top = 0, this.bottom = this.height), this.paddingLeft = 0, this.paddingTop = 0, this.paddingRight = 0, this.paddingBottom = 0;
}
afterSetDimensions() {
F(this.options.afterSetDimensions, [
this
]);
}
_callHooks(t) {
this.chart.notifyPlugins(t, this.getContext()), F(this.options[t], [
this
]);
}
beforeDataLimits() {
this._callHooks("beforeDataLimits");
}
determineDataLimits() {
}
afterDataLimits() {
this._callHooks("afterDataLimits");
}
beforeBuildTicks() {
this._callHooks("beforeBuildTicks");
}
buildTicks() {
return [];
}
afterBuildTicks() {
this._callHooks("afterBuildTicks");
}
beforeTickToLabelConversion() {
F(this.options.beforeTickToLabelConversion, [
this
]);
}
generateTickLabels(t) {
const e = this.options.ticks;
let s, n, o;
for (s = 0, n = t.length; s < n; s++)
o = t[s], o.label = F(e.callback, [
o.value,
s,
t
], this);
}
afterTickToLabelConversion() {
F(this.options.afterTickToLabelConversion, [
this
]);
}
beforeCalculateLabelRotation() {
F(this.options.beforeCalculateLabelRotation, [
this
]);
}
calculateLabelRotation() {
const t = this.options, e = t.ticks, s = vn(this.ticks.length, t.ticks.maxTicksLimit), n = e.minRotation || 0, o = e.maxRotation;
let r = n, a, l, c;
if (!this._isVisible() || !e.display || n >= o || s <= 1 || !this.isHorizontal()) {
this.labelRotation = n;
return;
}
const h = this._getLabelSizes(), d = h.widest.width, f = h.highest.height, u = K(this.chart.width - d, 0, this.maxWidth);
a = t.offset ? this.maxWidth / s : u / (s - 1), d + 6 > a && (a = u / (s - (t.offset ? 0.5 : 1)), l = this.maxHeight - xe(t.grid) - e.padding - kn(t.title, this.chart.options.font), c = Math.sqrt(d * d + f * f), r = xs(Math.min(Math.asin(K((h.highest.height + 6) / a, -1, 1)), Math.asin(K(l / c, -1, 1)) - Math.asin(K(f / c, -1, 1)))), r = Math.max(n, Math.min(o, r))), this.labelRotation = r;
}
afterCalculateLabelRotation() {
F(this.options.afterCalculateLabelRotation, [
this
]);
}
afterAutoSkip() {
}
beforeFit() {
F(this.options.beforeFit, [
this
]);
}
fit() {
const t = {
width: 0,
height: 0
}, { chart: e, options: { ticks: s, title: n, grid: o } } = this, r = this._isVisible(), a = this.isHorizontal();
if (r) {
const l = kn(n, e.options.font);
if (a ? (t.width = this.maxWidth, t.height = xe(o) + l) : (t.height = this.maxHeight, t.width = xe(o) + l), s.display && this.ticks.length) {
const { first: c, last: h, widest: d, highest: f } = this._getLabelSizes(), u = s.padding * 2, g = ht(this.labelRotation), p = Math.cos(g), m = Math.sin(g);
if (a) {
const b = s.mirror ? 0 : m * d.width + p * f.height;
t.height = Math.min(this.maxHeight, t.height + b + u);
} else {
const b = s.mirror ? 0 : p * d.width + m * f.height;
t.width = Math.min(this.maxWidth, t.width + b + u);
}
this._calculatePadding(c, h, m, p);
}
}
this._handleMargins(), a ? (this.width = this._length = e.width - this._margins.left - this._margins.right, this.height = t.height) : (this.width = t.width, this.height = this._length = e.height - this._margins.top - this._margins.bottom);
}
_calculatePadding(t, e, s, n) {
const { ticks: { align: o, padding: r }, position: a } = this.options, l = this.labelRotation !== 0, c = a !== "top" && this.axis === "x";
if (this.isHorizontal()) {
const h = this.getPixelForTick(0) - this.left, d = this.right - this.getPixelForTick(this.ticks.length - 1);
let f = 0, u = 0;
l ? c ? (f = n * t.width, u = s * e.height) : (f = s * t.height, u = n * e.width) : o === "start" ? u = e.width : o === "end" ? f = t.width : o !== "inner" && (f = t.width / 2, u = e.width / 2), this.paddingLeft = Math.max((f - h + r) * this.width / (this.width - h), 0), this.paddingRight = Math.max((u - d + r) * this.width / (this.width - d), 0);
} else {
let h = e.height / 2, d = t.height / 2;
o === "start" ? (h = 0, d = t.height) : o === "end" && (h = e.height, d = 0), this.paddingTop = h + r, this.paddingBottom = d + r;
}
}
_handleMargins() {
this._margins && (this._margins.left = Math.max(this.paddingLeft, this._margins.left), this._margins.top = Math.max(this.paddingTop, this._margins.top), this._margins.right = Math.max(this.paddingRight, this._margins.right), this._margins.bottom = Math.max(this.paddingBottom, this._margins.bottom));
}
afterFit() {
F(this.options.afterFit, [
this
]);
}
isHorizontal() {
const { axis: t, position: e } = this.options;
return e === "top" || e === "bottom" || t === "x";
}
isFullSize() {
return this.options.fullSize;
}
_convertTicksToLabels(t) {
this.beforeTickToLabelConversion(), this.generateTickLabels(t);
let e, s;
for (e = 0, s = t.length; e < s; e++)
E(t[e].label) && (t.splice(e, 1), s--, e--);
this.afterTickToLabelConversion();
}
_getLabelSizes() {
let t = this._labelSizes;
if (!t) {
const e = this.options.ticks.sampleSize;
let s = this.ticks;
e < s.length && (s = wn(s, e)), this._labelSizes = t = this._computeLabelSizes(s, s.length, this.options.ticks.maxTicksLimit);
}
return t;
}
_computeLabelSizes(t, e, s) {
const { ctx: n, _longestTextCache: o } = this, r = [], a = [], l = Math.floor(e / vn(e, s));
let c = 0, h = 0, d, f, u, g, p, m, b, x, v, y, _;
for (d = 0; d < e; d += l) {
if (g = t[d].label, p = this._resolveTickFontOptions(d), n.font = m = p.string, b = o[m] = o[m] || {
data: {},
gc: []
}, x = p.lineHeight, v = y = 0, !E(g) && !$(g))
v = ki(n, b.data, b.gc, v, g), y = x;
else if ($(g))
for (f = 0, u = g.length; f < u; ++f)
_ = g[f], !E(_) && !$(_) && (v = ki(n, b.data, b.gc, v, _), y += x);
r.push(v), a.push(y), c = Math.max(v, c), h = Math.max(y, h);
}
yc(o, e);
const k = r.indexOf(c), S = a.indexOf(h), M = (P) => ({
width: r[P] || 0,
height: a[P] || 0
});
return {
first: M(0),
last: M(e - 1),
widest: M(k),
highest: M(S),
widths: r,
heights: a
};
}
getLabelForValue(t) {
return t;
}
getPixelForValue(t, e) {
return NaN;
}
getValueForPixel(t) {
}
getPixelForTick(t) {
const e = this.ticks;
return t < 0 || t > e.length - 1 ? null : this.getPixelForValue(e[t].value);
}
getPixelForDecimal(t) {
this._reversePixels && (t = 1 - t);
const e = this._startPixel + t * this._length;
return la(this._alignToPixels ? Wt(this.chart, e, 0) : e);
}
getDecimalForPixel(t) {
const e = (t - this._startPixel) / this._length;
return this._reversePixels ? 1 - e : e;
}
getBasePixel() {
return this.getPixelForValue(this.getBaseValue());
}
getBaseValue() {
const { min: t, max: e } = this;
return t < 0 && e < 0 ? e : t > 0 && e > 0 ? t : 0;
}
getContext(t) {
const e = this.ticks || [];
if (t >= 0 && t < e.length) {
const s = e[t];
return s.$context || (s.$context = wc(this.getContext(), t, s));
}
return this.$context || (this.$context = vc(this.chart.getContext(), this));
}
_tickSize() {
const t = this.options.ticks, e = ht(this.labelRotation), s = Math.abs(Math.cos(e)), n = Math.abs(Math.sin(e)), o = this._getLabelSizes(), r = t.autoSkipPadding || 0, a = o ? o.widest.width + r : 0, l = o ? o.highest.height + r : 0;
return this.isHorizontal() ? l * s > a * n ? a / s : l / n : l * n < a * s ? l / s : a / n;
}
_isVisible() {
const t = this.options.display;
return t !== "auto" ? !!t : this.getMatchingVisibleMetas().length > 0;
}
_computeGridLineItems(t) {
const e = this.axis, s = this.chart, n = this.options, { grid: o, position: r, border: a } = n, l = o.offset, c = this.isHorizontal(), d = this.ticks.length + (l ? 1 : 0), f = xe(o), u = [], g = a.setContext(this.getContext()), p = g.display ? g.width : 0, m = p / 2, b = function(B) {
return Wt(s, B, p);
};
let x, v, y, _, k, S, M, P, D, O, T, q;
if (r === "top")
x = b(this.bottom), S = this.bottom - f, P = x - m, O = b(t.top) + m, q = t.bottom;
else if (r === "bottom")
x = b(this.top), O = t.top, q = b(t.bottom) - m, S = x + m, P = this.top + f;
else if (r === "left")
x = b(this.right), k = this.right - f, M = x - m, D = b(t.left) + m, T = t.right;
else if (r === "right")
x = b(this.left), D = t.left, T = b(t.right) - m, k = x + m, M = this.left + f;
else if (e === "x") {
if (r === "center")
x = b((t.top + t.bottom) / 2 + 0.5);
else if (A(r)) {
const B = Object.keys(r)[0], H = r[B];
x = b(this.chart.scales[B].getPixelForValue(H));
}
O = t.top, q = t.bottom, S = x + m, P = S + f;
} else if (e === "y") {
if (r === "center")
x = b((t.left + t.right) / 2);
else if (A(r)) {
const B = Object.keys(r)[0], H = r[B];
x = b(this.chart.scales[B].getPixelForValue(H));
}
k = x - m, M = k - f, D = t.left, T = t.right;
}
const st = C(n.ticks.maxTicksLimit, d), R = Math.max(1, Math.ceil(d / st));
for (v = 0; v < d; v += R) {
const B = this.getContext(v), H = o.setContext(B), lt = a.setContext(B), G = H.lineWidth, ee = H.color, Ye = lt.dash || [], ie = lt.dashOffset, fe = H.tickWidth, Bt = H.tickColor, ue = H.tickBorderDash || [], $t = H.tickBorderDashOffset;
y = _c(this, v, l), y !== void 0 && (_ = Wt(s, y, G), c ? k = M = D = T = _ : S = P = O = q = _, u.push({
tx1: k,
ty1: S,
tx2: M,
ty2: P,
x1: D,
y1: O,
x2: T,
y2: q,
width: G,
color: ee,
borderDash: Ye,
borderDashOffset: ie,
tickWidth: fe,
tickColor: Bt,
tickBorderDash: ue,
tickBorderDashOffset: $t
}));
}
return this._ticksLength = d, this._borderValue = x, u;
}
_computeLabelItems(t) {
const e = this.axis, s = this.options, { position: n, ticks: o } = s, r = this.isHorizontal(), a = this.ticks, { align: l, crossAlign: c, padding: h, mirror: d } = o, f = xe(s.grid), u = f + h, g = d ? -h : u, p = -ht(this.labelRotation), m = [];
let b, x, v, y, _, k, S, M, P, D, O, T, q = "middle";
if (n === "top")
k = this.bottom - g, S = this._getXAxisLabelAlignment();
else if (n === "bottom")
k = this.top + g, S = this._getXAxisLabelAlignment();
else if (n === "left") {
const R = this._getYAxisLabelAlignment(f);
S = R.textAlign, _ = R.x;
} else if (n === "right") {
const R = this._getYAxisLabelAlignment(f);
S = R.textAlign, _ = R.x;
} else if (e === "x") {
if (n === "center")
k = (t.top + t.bottom) / 2 + u;
else if (A(n)) {
const R = Object.keys(n)[0], B = n[R];
k = this.chart.scales[R].getPixelForValue(B) + u;
}
S = this._getXAxisLabelAlignment();
} else if (e === "y") {
if (n === "center")
_ = (t.left + t.right) / 2 - u;
else if (A(n)) {
const R = Object.keys(n)[0], B = n[R];
_ = this.chart.scales[R].getPixelForValue(B);
}
S = this._getYAxisLabelAlignment(f).textAlign;
}
e === "y" && (l === "start" ? q = "top" : l === "end" && (q = "bottom"));
const st = this._getLabelSizes();
for (b = 0, x = a.length; b < x; ++b) {
v = a[b], y = v.label;
const R = o.setContext(this.getContext(b));
M = this.getPixelForTick(b) + o.labelOffset, P = this._resolveTickFontOptions(b), D = P.lineHeight, O = $(y) ? y.length : 1;
const B = O / 2, H = R.color, lt = R.textStrokeColor, G = R.textStrokeWidth;
let ee = S;
r ? (_ = M, S === "inner" && (b === x - 1 ? ee = this.options.reverse ? "left" : "right" : b === 0 ? ee = this.options.reverse ? "right" : "left" : ee = "center"), n === "top" ? c === "near" || p !== 0 ? T = -O * D + D / 2 : c === "center" ? T = -st.highest.height / 2 - B * D + D : T = -st.highest.height + D / 2 : c === "near" || p !== 0 ? T = D / 2 : c === "center" ? T = st.highest.height / 2 - B * D : T = st.highest.height - O * D, d && (T *= -1), p !== 0 && !R.showLabelBackdrop && (_ += D / 2 * Math.sin(p))) : (k = M, T = (1 - O) * D / 2);
let Ye;
if (R.showLabelBackdrop) {
const ie = J(R.backdropPadding), fe = st.heights[b], Bt = st.widths[b];
let ue = T - ie.top, $t = 0 - ie.left;
switch (q) {
case "middle":
ue -= fe / 2;
break;
case "bottom":
ue -= fe;
break;
}
switch (S) {
case "center":
$t -= Bt / 2;
break;
case "right":
$t -= Bt;
break;
case "inner":
b === x - 1 ? $t -= Bt : b > 0 && ($t -= Bt / 2);
break;
}
Ye = {
left: $t,
top: ue,
width: Bt + ie.width,
height: fe + ie.height,
color: R.backdropColor
};
}
m.push({
label: y,
font: P,
textOffset: T,
options: {
rotation: p,
color: H,
strokeColor: lt,
strokeWidth: G,
textAlign: ee,
textBaseline: q,
translation: [
_,
k
],
backdrop: Ye
}
});
}
return m;
}
_getXAxisLabelAlignment() {
const { position: t, ticks: e } = this.options;
if (-ht(this.labelRotation))
return t === "top" ? "left" : "right";
let n = "center";
return e.align === "start" ? n = "left" : e.align === "end" ? n = "right" : e.align === "inner" && (n = "inner"), n;
}
_getYAxisLabelAlignment(t) {
const { position: e, ticks: { crossAlign: s, mirror: n, padding: o } } = this.options, r = this._getLabelSizes(), a = t + o, l = r.widest.width;
let c, h;
return e === "left" ? n ? (h = this.right + o, s === "near" ? c = "left" : s === "center" ? (c = "center", h += l / 2) : (c = "right", h += l)) : (h = this.right - a, s === "near" ? c = "right" : s === "center" ? (c = "center", h -= l / 2) : (c = "left", h = this.left)) : e === "right" ? n ? (h = this.left + o, s === "near" ? c = "right" : s === "center" ? (c = "center", h -= l / 2) : (c = "left", h -= l)) : (h = this.left + a, s === "near" ? c = "left" : s === "center" ? (c = "center", h += l / 2) : (c = "right", h = this.right)) : c = "right", {
textAlign: c,
x: h
};
}
_computeLabelArea() {
if (this.options.ticks.mirror)
return;
const t = this.chart, e = this.options.position;
if (e === "left" || e === "right")
return {
top: 0,
left: this.left,
bottom: t.height,
right: this.right
};
if (e === "top" || e === "bottom")
return {
top: this.top,
left: 0,
bottom: this.bottom,
right: t.width
};
}
drawBackground() {
const { ctx: t, options: { backgroundColor: e }, left: s, top: n, width: o, height: r } = this;
e && (t.save(), t.fillStyle = e, t.fillRect(s, n, o, r), t.restore());
}
getLineWidthForValue(t) {
const e = this.options.grid;
if (!this._isVisible() || !e.display)
return 0;
const n = this.ticks.findIndex((o) => o.value === t);
return n >= 0 ? e.setContext(this.getContext(n)).lineWidth : 0;
}
drawGrid(t) {
const e = this.options.grid, s = this.ctx, n = this._gridLineItems || (this._gridLineItems = this._computeGridLineItems(t));
let o, r;
const a = (l, c, h) => {
!h.width || !h.color || (s.save(), s.lineWidth = h.width, s.strokeStyle = h.color, s.setLineDash(h.borderDash || []), s.lineDashOffset = h.borderDashOffset, s.beginPath(), s.moveTo(l.x, l.y), s.lineTo(c.x, c.y), s.stroke(), s.restore());
};
if (e.display)
for (o = 0, r = n.length; o < r; ++o) {
const l = n[o];
e.drawOnChartArea && a({
x: l.x1,
y: l.y1
}, {
x: l.x2,
y: l.y2
}, l), e.drawTicks && a({
x: l.tx1,
y: l.ty1
}, {
x: l.tx2,
y: l.ty2
}, {
color: l.tickColor,
width: l.tickWidth,
borderDash: l.tickBorderDash,
borderDashOffset: l.tickBorderDashOffset
});
}
}
drawBorder() {
const { chart: t, ctx: e, options: { border: s, grid: n } } = this, o = s.setContext(this.getContext()), r = s.display ? o.width : 0;
if (!r)
return;
const a = n.setContext(this.getContext(0)).lineWidth, l = this._borderValue;
let c, h, d, f;
this.isHorizontal() ? (c = Wt(t, this.left, r) - r / 2, h = Wt(t, this.right, a) + a / 2, d = f = l) : (d = Wt(t, this.top, r) - r / 2, f = Wt(t, this.bottom, a) + a / 2, c = h = l), e.save(), e.lineWidth = o.width, e.strokeStyle = o.color, e.beginPath(), e.moveTo(c, d), e.lineTo(h, f), e.stroke(), e.restore();
}
drawLabels(t) {
if (!this.options.ticks.display)
return;
const s = this.ctx, n = this._computeLabelArea();
n && Ai(s, n);
const o = this.getLabelItems(t);
for (const r of o) {
const a = r.options, l = r.font, c = r.label, h = r.textOffset;
Gt(s, c, 0, h, l, a);
}
n && Ti(s);
}
drawTitle() {
const { ctx: t, options: { position: e, title: s, reverse: n } } = this;
if (!s.display)
return;
const o = Y(s.font), r = J(s.padding), a = s.align;
let l = o.lineHeight / 2;
e === "bottom" || e === "center" || A(e) ? (l += r.bottom, $(s.text) && (l += o.lineHeight * (s.text.length - 1))) : l += r.top;
const { titleX: c, titleY: h, maxWidth: d, rotation: f } = Sc(this, l, e, a);
Gt(t, s.text, 0, 0, o, {
color: s.color,
maxWidth: d,
rotation: f,
textAlign: kc(a, e, n),
textBaseline: "middle",
translation: [
c,
h
]
});
}
draw(t) {
this._isVisible() && (this.drawBackground(), this.drawGrid(t), this.drawBorder(), this.drawTitle(), this.drawLabels(t));
}
_layers() {
const t = this.options, e = t.ticks && t.ticks.z || 0, s = C(t.grid && t.grid.z, -1), n = C(t.border && t.border.z, 0);
return !this._isVisible() || this.draw !== Jt.prototype.draw ? [
{
z: e,
draw: (o) => {
this.draw(o);
}
}
] : [
{
z: s,
draw: (o) => {
this.drawBackground(), this.drawGrid(o), this.drawTitle();
}
},
{
z: n,
draw: () => {
this.drawBorder();
}
},
{
z: e,
draw: (o) => {
this.drawLabels(o);
}
}
];
}
getMatchingVisibleMetas(t) {
const e = this.chart.getSortedVisibleDatasetMetas(), s = this.axis + "AxisID", n = [];
let o, r;
for (o = 0, r = e.length; o < r; ++o) {
const a = e[o];
a[s] === this.id && (!t || a.type === t) && n.push(a);
}
return n;
}
_resolveTickFontOptions(t) {
const e = this.options.ticks.setContext(this.getContext(t));
return Y(e.font);
}
_maxDigits() {
const t = this._resolveTickFontOptions(0).lineHeight;
return (this.isHorizontal() ? this.width : this.height) / t;
}
}
class ei {
constructor(t, e, s) {
this.type = t, this.scope = e, this.override = s, this.items = /* @__PURE__ */ Object.create(null);
}
isForType(t) {
return Object.prototype.isPrototypeOf.call(this.type.prototype, t.prototype);
}
register(t) {
const e = Object.getPrototypeOf(t);
let s;
Cc(e) && (s = this.register(e));
const n = this.items, o = t.id, r = this.scope + "." + o;
if (!o)
throw new Error("class does not have id: " + t);
return o in n || (n[o] = t, Mc(t, r, s), this.override && j.override(t.id, t.overrides)), r;
}
get(t) {
return this.items[t];
}
unregister(t) {
const e = this.items, s = t.id, n = this.scope;
s in e && delete e[s], n && s in j[n] && (delete j[n][s], this.override && delete qt[s]);
}
}
function Mc(i, t, e) {
const s = Le(/* @__PURE__ */ Object.create(null), [
e ? j.get(e) : {},
j.get(t),
i.defaults
]);
j.set(t, s), i.defaultRoutes && Pc(t, i.defaultRoutes), i.descriptors && j.describe(t, i.descriptors);
}
function Pc(i, t) {
Object.keys(t).forEach((e) => {
const s = e.split("."), n = s.pop(), o = [
i
].concat(s).join("."), r = t[e].split("."), a = r.pop(), l = r.join(".");
j.route(o, n, l, a);
});
}
function Cc(i) {
return "id" in i && "defaults" in i;
}
class Dc {
constructor() {
this.controllers = new ei(dt, "datasets", !0), this.elements = new ei(ft, "elements"), this.plugins = new ei(Object, "plugins"), this.scales = new ei(Jt, "scales"), this._typedRegistries = [
this.controllers,
this.scales,
this.elements
];
}
add(...t) {
this._each("register", t);
}
remove(...t) {
this._each("unregister", t);
}
addControllers(...t) {
this._each("register", t, this.controllers);
}
addElements(...t) {
this._each("register", t, this.elements);
}
addPlugins(...t) {
this._each("register", t, this.plugins);
}
addScales(...t) {
this._each("register", t, this.scales);
}
getController(t) {
return this._get(t, this.controllers, "controller");
}
getElement(t) {
return this._get(t, this.elements, "element");
}
getPlugin(t) {
return this._get(t, this.plugins, "plugin");
}
getScale(t) {
return this._get(t, this.scales, "scale");
}
removeControllers(...t) {
this._each("unregister", t, this.controllers);
}
removeElements(...t) {
this._each("unregister", t, this.elements);
}
removePlugins(...t) {
this._each("unregister", t, this.plugins);
}
removeScales(...t) {
this._each("unregister", t, this.scales);
}
_each(t, e, s) {
[
...e
].forEach((n) => {
const o = s || this._getRegistryForType(n);
s || o.isForType(n) || o === this.plugins && n.id ? this._exec(t, o, n) : L(n, (r) => {
const a = s || this._getRegistryForType(r);
this._exec(t, a, r);
});
});
}
_exec(t, e, s) {
const n = bs(t);
F(s["before" + n], [], s), e[t](s), F(s["after" + n], [], s);
}
_getRegistryForType(t) {
for (let e = 0; e < this._typedRegistries.length; e++) {
const s = this._typedRegistries[e];
if (s.isForType(t))
return s;
}
return this.plugins;
}
_get(t, e, s) {
const n = e.get(t);
if (n === void 0)
throw new Error('"' + t + '" is not a registered ' + s + ".");
return n;
}
}
var gt = /* @__PURE__ */ new Dc();
class Oc {
constructor() {
this._init = [];
}
notify(t, e, s, n) {
e === "beforeInit" && (this._init = this._createDescriptors(t, !0), this._notify(this._init, t, "install"));
const o = n ? this._descriptors(t).filter(n) : this._descriptors(t), r = this._notify(o, t, e, s);
return e === "afterDestroy" && (this._notify(o, t, "stop"), this._notify(this._init, t, "uninstall")), r;
}
_notify(t, e, s, n) {
n = n || {};
for (const o of t) {
const r = o.plugin, a = r[s], l = [
e,
n,
o.options
];
if (F(a, l, r) === !1 && n.cancelable)
return !1;
}
return !0;
}
invalidate() {
E(this._cache) || (this._oldCache = this._cache, this._cache = void 0);
}
_descriptors(t) {
if (this._cache)
return this._cache;
const e = this._cache = this._createDescriptors(t);
return this._notifyStateChanges(t), e;
}
_createDescriptors(t, e) {
const s = t && t.config, n = C(s.options && s.options.plugins, {}), o = Ac(s);
return n === !1 && !e ? [] : Ec(t, o, n, e);
}
_notifyStateChanges(t) {
const e = this._oldCache || [], s = this._cache, n = (o, r) => o.filter((a) => !r.some((l) => a.plugin.id === l.plugin.id));
this._notify(n(e, s), t, "stop"), this._notify(n(s, e), t, "start");
}
}
function Ac(i) {
const t = {}, e = [], s = Object.keys(gt.plugins.items);
for (let o = 0; o < s.length; o++)
e.push(gt.getPlugin(s[o]));
const n = i.plugins || [];
for (let o = 0; o < n.length; o++) {
const r = n[o];
e.indexOf(r) === -1 && (e.push(r), t[r.id] = !0);
}
return {
plugins: e,
localIds: t
};
}
function Tc(i, t) {
return !t && i === !1 ? null : i === !0 ? {} : i;
}
function Ec(i, { plugins: t, localIds: e }, s, n) {
const o = [], r = i.getContext();
for (const a of t) {
const l = a.id, c = Tc(s[l], n);
c !== null && o.push({
plugin: a,
options: Lc(i.config, {
plugin: a,
local: e[l]
}, c, r)
});
}
return o;
}
function Lc(i, { plugin: t, local: e }, s, n) {
const o = i.pluginScopeKeys(t), r = i.getOptionScopes(s, o);
return e && t.defaults && r.push(t.defaults), i.createResolver(r, n, [
""
], {
scriptable: !1,
indexable: !1,
allKeys: !0
});
}
function es(i, t) {
const e = j.datasets[i] || {};
return ((t.datasets || {})[i] || {}).indexAxis || t.indexAxis || e.indexAxis || "x";
}
function Rc(i, t) {
let e = i;
return i === "_index_" ? e = t : i === "_value_" && (e = t === "x" ? "y" : "x"), e;
}
function Fc(i, t) {
return i === t ? "_index_" : "_value_";
}
function Sn(i) {
if (i === "x" || i === "y" || i === "r")
return i;
}
function zc(i) {
if (i === "top" || i === "bottom")
return "x";
if (i === "left" || i === "right")
return "y";
}
function is(i, ...t) {
if (Sn(i))
return i;
for (const e of t) {
const s = e.axis || zc(e.position) || i.length > 1 && Sn(i[0].toLowerCase());
if (s)
return s;
}
throw new Error(`Cannot determine type of '${i}' axis. Please provide 'axis' or 'position' option.`);
}
function Mn(i, t, e) {
if (e[t + "AxisID"] === i)
return {
axis: t
};
}
function Ic(i, t) {
if (t.data && t.data.datasets) {
const e = t.data.datasets.filter((s) => s.xAxisID === i || s.yAxisID === i);
if (e.length)
return Mn(i, "x", e[0]) || Mn(i, "y", e[0]);
}
return {};
}
function Bc(i, t) {
const e = qt[i.type] || {
scales: {}
}, s = t.scales || {}, n = es(i.type, t), o = /* @__PURE__ */ Object.create(null);
return Object.keys(s).forEach((r) => {
const a = s[r];
if (!A(a))
return console.error(`Invalid scale configuration for scale: ${r}`);
if (a._proxy)
return console.warn(`Ignoring resolver passed as options for scale: ${r}`);
const l = is(r, a, Ic(r, i), j.scales[a.type]), c = Fc(l, n), h = e.scales || {};
o[r] = Ce(/* @__PURE__ */ Object.create(null), [
{
axis: l
},
a,
h[l],
h[c]
]);
}), i.data.datasets.forEach((r) => {
const a = r.type || i.type, l = r.indexAxis || es(a, t), h = (qt[a] || {}).scales || {};
Object.keys(h).forEach((d) => {
const f = Rc(d, l), u = r[f + "AxisID"] || f;
o[u] = o[u] || /* @__PURE__ */ Object.create(null), Ce(o[u], [
{
axis: f
},
s[u],
h[d]
]);
});
}), Object.keys(o).forEach((r) => {
const a = o[r];
Ce(a, [
j.scales[a.type],
j.scale
]);
}), o;
}
function Vo(i) {
const t = i.options || (i.options = {});
t.plugins = C(t.plugins, {}), t.scales = Bc(i, t);
}
function Ho(i) {
return i = i || {}, i.datasets = i.datasets || [], i.labels = i.labels || [], i;
}
function $c(i) {
return i = i || {}, i.data = Ho(i.data), Vo(i), i;
}
const Pn = /* @__PURE__ */ new Map(), Uo = /* @__PURE__ */ new Set();
function ii(i, t) {
let e = Pn.get(i);
return e || (e = t(), Pn.set(i, e), Uo.add(e)), e;
}
const _e = (i, t, e) => {
const s = Et(t, e);
s !== void 0 && i.add(s);
};
class jc {
constructor(t) {
this._config = $c(t), this._scopeCache = /* @__PURE__ */ new Map(), this._resolverCache = /* @__PURE__ */ new Map();
}
get platform() {
return this._config.platform;
}
get type() {
return this._config.type;
}
set type(t) {
this._config.type = t;
}
get data() {
return this._config.data;
}
set data(t) {
this._config.data = Ho(t);
}
get options() {
return this._config.options;
}
set options(t) {
this._config.options = t;
}
get plugins() {
return this._config.plugins;
}
update() {
const t = this._config;
this.clearCache(), Vo(t);
}
clearCache() {
this._scopeCache.clear(), this._resolverCache.clear();
}
datasetScopeKeys(t) {
return ii(t, () => [
[
`datasets.${t}`,
""
]
]);
}
datasetAnimationScopeKeys(t, e) {
return ii(`${t}.transition.${e}`, () => [
[
`datasets.${t}.transitions.${e}`,
`transitions.${e}`
],
[
`datasets.${t}`,
""
]
]);
}
datasetElementScopeKeys(t, e) {
return ii(`${t}-${e}`, () => [
[
`datasets.${t}.elements.${e}`,
`datasets.${t}`,
`elements.${e}`,
""
]
]);
}
pluginScopeKeys(t) {
const e = t.id, s = this.type;
return ii(`${s}-plugin-${e}`, () => [
[
`plugins.${e}`,
...t.additionalOptionScopes || []
]
]);
}
_cachedScopes(t, e) {
const s = this._scopeCache;
let n = s.get(t);
return (!n || e) && (n = /* @__PURE__ */ new Map(), s.set(t, n)), n;
}
getOptionScopes(t, e, s) {
const { options: n, type: o } = this, r = this._cachedScopes(t, s), a = r.get(e);
if (a)
return a;
const l = /* @__PURE__ */ new Set();
e.forEach((h) => {
t && (l.add(t), h.forEach((d) => _e(l, t, d))), h.forEach((d) => _e(l, n, d)), h.forEach((d) => _e(l, qt[o] || {}, d)), h.forEach((d) => _e(l, j, d)), h.forEach((d) => _e(l, Qi, d));
});
const c = Array.from(l);
return c.length === 0 && c.push(/* @__PURE__ */ Object.create(null)), Uo.has(e) && r.set(e, c), c;
}
chartOptionScopes() {
const { options: t, type: e } = this;
return [
t,
qt[e] || {},
j.datasets[e] || {},
{
type: e
},
j,
Qi
];
}
resolveNamedOptions(t, e, s, n = [
""
]) {
const o = {
$shared: !0
}, { resolver: r, subPrefixes: a } = Cn(this._resolverCache, t, n);
let l = r;
if (Nc(r, e)) {
o.$shared = !1, s = Lt(s) ? s() : s;
const c = this.createResolver(t, s, a);
l = le(r, s, c);
}
for (const c of e)
o[c] = l[c];
return o;
}
createResolver(t, e, s = [
""
], n) {
const { resolver: o } = Cn(this._resolverCache, t, s);
return A(e) ? le(o, e, void 0, n) : o;
}
}
function Cn(i, t, e) {
let s = i.get(t);
s || (s = /* @__PURE__ */ new Map(), i.set(t, s));
const n = e.join();
let o = s.get(n);
return o || (o = {
resolver: ks(t, e),
subPrefixes: e.filter((a) => !a.toLowerCase().includes("hover"))
}, s.set(n, o)), o;
}
const Wc = (i) => A(i) && Object.getOwnPropertyNames(i).some((t) => Lt(i[t]));
function Nc(i, t) {
const { isScriptable: e, isIndexable: s } = So(i);
for (const n of t) {
const o = e(n), r = s(n), a = (r || o) && i[n];
if (o && (Lt(a) || Wc(a)) || r && $(a))
return !0;
}
return !1;
}
var Vc = "4.4.7";
const Hc = [
"top",
"bottom",
"left",
"right",
"chartArea"
];
function Dn(i, t) {
return i === "top" || i === "bottom" || Hc.indexOf(i) === -1 && t === "x";
}
function On(i, t) {
return function(e, s) {
return e[i] === s[i] ? e[t] - s[t] : e[i] - s[i];
};
}
function An(i) {
const t = i.chart, e = t.options.animation;
t.notifyPlugins("afterRender"), F(e && e.onComplete, [
i
], t);
}
function Uc(i) {
const t = i.chart, e = t.options.animation;
F(e && e.onProgress, [
i
], t);
}
function Yo(i) {
return Ps() && typeof i == "string" ? i = document.getElementById(i) : i && i.length && (i = i[0]), i && i.canvas && (i = i.canvas), i;
}
const gi = {}, Tn = (i) => {
const t = Yo(i);
return Object.values(gi).filter((e) => e.canvas === t).pop();
};
function Yc(i, t, e) {
const s = Object.keys(i);
for (const n of s) {
const o = +n;
if (o >= t) {
const r = i[n];
delete i[n], (e > 0 || o > t) && (i[o + e] = r);
}
}
}
function Xc(i, t, e, s) {
return !e || i.type === "mouseout" ? null : s ? t : i;
}
function si(i, t, e) {
return i.options.clip ? i[e] : t[e];
}
function Kc(i, t) {
const { xScale: e, yScale: s } = i;
return e && s ? {
left: si(e, t, "left"),
right: si(e, t, "right"),
top: si(s, t, "top"),
bottom: si(s, t, "bottom")
} : t;
}
class ct {
static register(...t) {
gt.add(...t), En();
}
static unregister(...t) {
gt.remove(...t), En();
}
constructor(t, e) {
const s = this.config = new jc(e), n = Yo(t), o = Tn(n);
if (o)
throw new Error("Canvas is already in use. Chart with ID '" + o.id + "' must be destroyed before the canvas with ID '" + o.canvas.id + "' can be reused.");
const r = s.createResolver(s.chartOptionScopes(), this.getContext());
this.platform = new (s.platform || dc(n))(), this.platform.updateConfig(s);
const a = this.platform.acquireContext(n, r.aspectRatio), l = a && a.canvas, c = l && l.height, h = l && l.width;
if (this.id = Gr(), this.ctx = a, this.canvas = l, this.width = h, this.height = c, this._options = r, this._aspectRatio = this.aspectRatio, this._layers = [], this._metasets = [], this._stacks = void 0, this.boxes = [], this.currentDevicePixelRatio = void 0, this.chartArea = void 0, this._active = [], this._lastEvent = void 0, this._listeners = {}, this._responsiveListeners = void 0, this._sortedMetasets = [], this.scales = {}, this._plugins = new Oc(), this.$proxies = {}, this._hiddenIndices = {}, this.attached = !1, this._animationsDisabled = void 0, this.$context = void 0, this._doResize = fa((d) => this.update(d), r.resizeDelay || 0), this._dataChanges = [], gi[this.id] = this, !a || !l) {
console.error("Failed to create chart: can't acquire context from the given item");
return;
}
xt.listen(this, "complete", An), xt.listen(this, "progress", Uc), this._initialize(), this.attached && this.update();
}
get aspectRatio() {
const { options: { aspectRatio: t, maintainAspectRatio: e }, width: s, height: n, _aspectRatio: o } = this;
return E(t) ? e && o ? o : n ? s / n : null : t;
}
get data() {
return this.config.data;
}
set data(t) {
this.config.data = t;
}
get options() {
return this._options;
}
set options(t) {
this.config.options = t;
}
get registry() {
return gt;
}
_initialize() {
return this.notifyPlugins("beforeInit"), this.options.responsive ? this.resize() : Js(this, this.options.devicePixelRatio), this.bindEvents(), this.notifyPlugins("afterInit"), this;
}
clear() {
return Gs(this.canvas, this.ctx), this;
}
stop() {
return xt.stop(this), this;
}
resize(t, e) {
xt.running(this) ? this._resizeBeforeDraw = {
width: t,
height: e
} : this._resize(t, e);
}
_resize(t, e) {
const s = this.options, n = this.canvas, o = s.maintainAspectRatio && this.aspectRatio, r = this.platform.getMaximumSize(n, t, e, o), a = s.devicePixelRatio || this.platform.getDevicePixelRatio(), l = this.width ? "resize" : "attach";
this.width = r.width, this.height = r.height, this._aspectRatio = this.aspectRatio, Js(this, a, !0) && (this.notifyPlugins("resize", {
size: r
}), F(s.onResize, [
this,
r
], this), this.attached && this._doResize(l) && this.render());
}
ensureScalesHaveIDs() {
const e = this.options.scales || {};
L(e, (s, n) => {
s.id = n;
});
}
buildOrUpdateScales() {
const t = this.options, e = t.scales, s = this.scales, n = Object.keys(s).reduce((r, a) => (r[a] = !1, r), {});
let o = [];
e && (o = o.concat(Object.keys(e).map((r) => {
const a = e[r], l = is(r, a), c = l === "r", h = l === "x";
return {
options: a,
dposition: c ? "chartArea" : h ? "bottom" : "left",
dtype: c ? "radialLinear" : h ? "category" : "linear"
};
}))), L(o, (r) => {
const a = r.options, l = a.id, c = is(l, a), h = C(a.type, r.dtype);
(a.position === void 0 || Dn(a.position, c) !== Dn(r.dposition)) && (a.position = r.dposition), n[l] = !0;
let d = null;
if (l in s && s[l].type === h)
d = s[l];
else {
const f = gt.getScale(h);
d = new f({
id: l,
type: h,
ctx: this.ctx,
chart: this
}), s[d.id] = d;
}
d.init(a, t);
}), L(n, (r, a) => {
r || delete s[a];
}), L(s, (r) => {
Q.configure(this, r, r.options), Q.addBox(this, r);
});
}
_updateMetasets() {
const t = this._metasets, e = this.data.datasets.length, s = t.length;
if (t.sort((n, o) => n.index - o.index), s > e) {
for (let n = e; n < s; ++n)
this._destroyDatasetMeta(n);
t.splice(e, s - e);
}
this._sortedMetasets = t.slice(0).sort(On("order", "index"));
}
_removeUnreferencedMetasets() {
const { _metasets: t, data: { datasets: e } } = this;
t.length > e.length && delete this._stacks, t.forEach((s, n) => {
e.filter((o) => o === s._dataset).length === 0 && this._destroyDatasetMeta(n);
});
}
buildOrUpdateControllers() {
const t = [], e = this.data.datasets;
let s, n;
for (this._removeUnreferencedMetasets(), s = 0, n = e.length; s < n; s++) {
const o = e[s];
let r = this.getDatasetMeta(s);
const a = o.type || this.config.type;
if (r.type && r.type !== a && (this._destroyDatasetMeta(s), r = this.getDatasetMeta(s)), r.type = a, r.indexAxis = o.indexAxis || es(a, this.options), r.order = o.order || 0, r.index = s, r.label = "" + o.label, r.visible = this.isDatasetVisible(s), r.controller)
r.controller.updateIndex(s), r.controller.linkScales();
else {
const l = gt.getController(a), { datasetElementType: c, dataElementType: h } = j.datasets[a];
Object.assign(l, {
dataElementType: gt.getElement(h),
datasetElementType: c && gt.getElement(c)
}), r.controller = new l(this, s), t.push(r.controller);
}
}
return this._updateMetasets(), t;
}
_resetElements() {
L(this.data.datasets, (t, e) => {
this.getDatasetMeta(e).controller.reset();
}, this);
}
reset() {
this._resetElements(), this.notifyPlugins("reset");
}
update(t) {
const e = this.config;
e.update();
const s = this._options = e.createResolver(e.chartOptionScopes(), this.getContext()), n = this._animationsDisabled = !s.animation;
if (this._updateScales(), this._checkEventBindings(), this._updateHiddenIndices(), this._plugins.invalidate(), this.notifyPlugins("beforeUpdate", {
mode: t,
cancelable: !0
}) === !1)
return;
const o = this.buildOrUpdateControllers();
this.notifyPlugins("beforeElementsUpdate");
let r = 0;
for (let c = 0, h = this.data.datasets.length; c < h; c++) {
const { controller: d } = this.getDatasetMeta(c), f = !n && o.indexOf(d) === -1;
d.buildOrUpdateElements(f), r = Math.max(+d.getMaxOverflow(), r);
}
r = this._minPadding = s.layout.autoPadding ? r : 0, this._updateLayout(r), n || L(o, (c) => {
c.reset();
}), this._updateDatasets(t), this.notifyPlugins("afterUpdate", {
mode: t
}), this._layers.sort(On("z", "_idx"));
const { _active: a, _lastEvent: l } = this;
l ? this._eventHandler(l, !0) : a.length && this._updateHoverStyles(a, a, !0), this.render();
}
_updateScales() {
L(this.scales, (t) => {
Q.removeBox(this, t);
}), this.ensureScalesHaveIDs(), this.buildOrUpdateScales();
}
_checkEventBindings() {
const t = this.options, e = new Set(Object.keys(this._listeners)), s = new Set(t.events);
(!Ws(e, s) || !!this._responsiveListeners !== t.responsive) && (this.unbindEvents(), this.bindEvents());
}
_updateHiddenIndices() {
const { _hiddenIndices: t } = this, e = this._getUniformDataChanges() || [];
for (const { method: s, start: n, count: o } of e) {
const r = s === "_removeElements" ? -o : o;
Yc(t, n, r);
}
}
_getUniformDataChanges() {
const t = this._dataChanges;
if (!t || !t.length)
return;
this._dataChanges = [];
const e = this.data.datasets.length, s = (o) => new Set(t.filter((r) => r[0] === o).map((r, a) => a + "," + r.splice(1).join(","))), n = s(0);
for (let o = 1; o < e; o++)
if (!Ws(n, s(o)))
return;
return Array.from(n).map((o) => o.split(",")).map((o) => ({
method: o[1],
start: +o[2],
count: +o[3]
}));
}
_updateLayout(t) {
if (this.notifyPlugins("beforeLayout", {
cancelable: !0
}) === !1)
return;
Q.update(this, this.width, this.height, t);
const e = this.chartArea, s = e.width <= 0 || e.height <= 0;
this._layers = [], L(this.boxes, (n) => {
s && n.position === "chartArea" || (n.configure && n.configure(), this._layers.push(...n._layers()));
}, this), this._layers.forEach((n, o) => {
n._idx = o;
}), this.notifyPlugins("afterLayout");
}
_updateDatasets(t) {
if (this.notifyPlugins("beforeDatasetsUpdate", {
mode: t,
cancelable: !0
}) !== !1) {
for (let e = 0, s = this.data.datasets.length; e < s; ++e)
this.getDatasetMeta(e).controller.configure();
for (let e = 0, s = this.data.datasets.length; e < s; ++e)
this._updateDataset(e, Lt(t) ? t({
datasetIndex: e
}) : t);
this.notifyPlugins("afterDatasetsUpdate", {
mode: t
});
}
}
_updateDataset(t, e) {
const s = this.getDatasetMeta(t), n = {
meta: s,
index: t,
mode: e,
cancelable: !0
};
this.notifyPlugins("beforeDatasetUpdate", n) !== !1 && (s.controller._update(e), n.cancelable = !1, this.notifyPlugins("afterDatasetUpdate", n));
}
render() {
this.notifyPlugins("beforeRender", {
cancelable: !0
}) !== !1 && (xt.has(this) ? this.attached && !xt.running(this) && xt.start(this) : (this.draw(), An({
chart: this
})));
}
draw() {
let t;
if (this._resizeBeforeDraw) {
const { width: s, height: n } = this._resizeBeforeDraw;
this._resizeBeforeDraw = null, this._resize(s, n);
}
if (this.clear(), this.width <= 0 || this.height <= 0 || this.notifyPlugins("beforeDraw", {
cancelable: !0
}) === !1)
return;
const e = this._layers;
for (t = 0; t < e.length && e[t].z <= 0; ++t)
e[t].draw(this.chartArea);
for (this._drawDatasets(); t < e.length; ++t)
e[t].draw(this.chartArea);
this.notifyPlugins("afterDraw");
}
_getSortedDatasetMetas(t) {
const e = this._sortedMetasets, s = [];
let n, o;
for (n = 0, o = e.length; n < o; ++n) {
const r = e[n];
(!t || r.visible) && s.push(r);
}
return s;
}
getSortedVisibleDatasetMetas() {
return this._getSortedDatasetMetas(!0);
}
_drawDatasets() {
if (this.notifyPlugins("beforeDatasetsDraw", {
cancelable: !0
}) === !1)
return;
const t = this.getSortedVisibleDatasetMetas();
for (let e = t.length - 1; e >= 0; --e)
this._drawDataset(t[e]);
this.notifyPlugins("afterDatasetsDraw");
}
_drawDataset(t) {
const e = this.ctx, s = t._clip, n = !s.disabled, o = Kc(t, this.chartArea), r = {
meta: t,
index: t.index,
cancelable: !0
};
this.notifyPlugins("beforeDatasetDraw", r) !== !1 && (n && Ai(e, {
left: s.left === !1 ? 0 : o.left - s.left,
right: s.right === !1 ? this.width : o.right + s.right,
top: s.top === !1 ? 0 : o.top - s.top,
bottom: s.bottom === !1 ? this.height : o.bottom + s.bottom
}), t.controller.draw(), n && Ti(e), r.cancelable = !1, this.notifyPlugins("afterDatasetDraw", r));
}
isPointInArea(t) {
return kt(t, this.chartArea, this._minPadding);
}
getElementsAtEventForMode(t, e, s, n) {
const o = Hl.modes[e];
return typeof o == "function" ? o(this, t, s, n) : [];
}
getDatasetMeta(t) {
const e = this.data.datasets[t], s = this._metasets;
let n = s.filter((o) => o && o._dataset === e).pop();
return n || (n = {
type: null,
data: [],
dataset: null,
controller: null,
hidden: null,
xAxisID: null,
yAxisID: null,
order: e && e.order || 0,
index: t,
_dataset: e,
_parsed: [],
_sorted: !1
}, s.push(n)), n;
}
getContext() {
return this.$context || (this.$context = It(null, {
chart: this,
type: "chart"
}));
}
getVisibleDatasetCount() {
return this.getSortedVisibleDatasetMetas().length;
}
isDatasetVisible(t) {
const e = this.data.datasets[t];
if (!e)
return !1;
const s = this.getDatasetMeta(t);
return typeof s.hidden == "boolean" ? !s.hidden : !e.hidden;
}
setDatasetVisibility(t, e) {
const s = this.getDatasetMeta(t);
s.hidden = !e;
}
toggleDataVisibility(t) {
this._hiddenIndices[t] = !this._hiddenIndices[t];
}
getDataVisibility(t) {
return !this._hiddenIndices[t];
}
_updateVisibility(t, e, s) {
const n = s ? "show" : "hide", o = this.getDatasetMeta(t), r = o.controller._resolveAnimations(void 0, n);
Re(e) ? (o.data[e].hidden = !s, this.update()) : (this.setDatasetVisibility(t, s), r.update(o, {
visible: s
}), this.update((a) => a.datasetIndex === t ? n : void 0));
}
hide(t, e) {
this._updateVisibility(t, e, !1);
}
show(t, e) {
this._updateVisibility(t, e, !0);
}
_destroyDatasetMeta(t) {
const e = this._metasets[t];
e && e.controller && e.controller._destroy(), delete this._metasets[t];
}
_stop() {
let t, e;
for (this.stop(), xt.remove(this), t = 0, e = this.data.datasets.length; t < e; ++t)
this._destroyDatasetMeta(t);
}
destroy() {
this.notifyPlugins("beforeDestroy");
const { canvas: t, ctx: e } = this;
this._stop(), this.config.clearCache(), t && (this.unbindEvents(), Gs(t, e), this.platform.releaseContext(e), this.canvas = null, this.ctx = null), delete gi[this.id], this.notifyPlugins("afterDestroy");
}
toBase64Image(...t) {
return this.canvas.toDataURL(...t);
}
bindEvents() {
this.bindUserEvents(), this.options.responsive ? this.bindResponsiveEvents() : this.attached = !0;
}
bindUserEvents() {
const t = this._listeners, e = this.platform, s = (o, r) => {
e.addEventListener(this, o, r), t[o] = r;
}, n = (o, r, a) => {
o.offsetX = r, o.offsetY = a, this._eventHandler(o);
};
L(this.options.events, (o) => s(o, n));
}
bindResponsiveEvents() {
this._responsiveListeners || (this._responsiveListeners = {});
const t = this._responsiveListeners, e = this.platform, s = (l, c) => {
e.addEventListener(this, l, c), t[l] = c;
}, n = (l, c) => {
t[l] && (e.removeEventListener(this, l, c), delete t[l]);
}, o = (l, c) => {
this.canvas && this.resize(l, c);
};
let r;
const a = () => {
n("attach", a), this.attached = !0, this.resize(), s("resize", o), s("detach", r);
};
r = () => {
this.attached = !1, n("resize", o), this._stop(), this._resize(0, 0), s("attach", a);
}, e.isAttached(this.canvas) ? a() : r();
}
unbindEvents() {
L(this._listeners, (t, e) => {
this.platform.removeEventListener(this, e, t);
}), this._listeners = {}, L(this._responsiveListeners, (t, e) => {
this.platform.removeEventListener(this, e, t);
}), this._responsiveListeners = void 0;
}
updateHoverStyle(t, e, s) {
const n = s ? "set" : "remove";
let o, r, a, l;
for (e === "dataset" && (o = this.getDatasetMeta(t[0].datasetIndex), o.controller["_" + n + "DatasetHoverStyle"]()), a = 0, l = t.length; a < l; ++a) {
r = t[a];
const c = r && this.getDatasetMeta(r.datasetIndex).controller;
c && c[n + "HoverStyle"](r.element, r.datasetIndex, r.index);
}
}
getActiveElements() {
return this._active || [];
}
setActiveElements(t) {
const e = this._active || [], s = t.map(({ datasetIndex: o, index: r }) => {
const a = this.getDatasetMeta(o);
if (!a)
throw new Error("No dataset found at index " + o);
return {
datasetIndex: o,
element: a.data[r],
index: r
};
});
!yi(s, e) && (this._active = s, this._lastEvent = null, this._updateHoverStyles(s, e));
}
notifyPlugins(t, e, s) {
return this._plugins.notify(this, t, e, s);
}
isPluginEnabled(t) {
return this._plugins._cache.filter((e) => e.plugin.id === t).length === 1;
}
_updateHoverStyles(t, e, s) {
const n = this.options.hover, o = (l, c) => l.filter((h) => !c.some((d) => h.datasetIndex === d.datasetIndex && h.index === d.index)), r = o(e, t), a = s ? t : o(t, e);
r.length && this.updateHoverStyle(r, n.mode, !1), a.length && n.mode && this.updateHoverStyle(a, n.mode, !0);
}
_eventHandler(t, e) {
const s = {
event: t,
replay: e,
cancelable: !0,
inChartArea: this.isPointInArea(t)
}, n = (r) => (r.options.events || this.options.events).includes(t.native.type);
if (this.notifyPlugins("beforeEvent", s, n) === !1)
return;
const o = this._handleEvent(t, e, s.inChartArea);
return s.cancelable = !1, this.notifyPlugins("afterEvent", s, n), (o || s.changed) && this.render(), this;
}
_handleEvent(t, e, s) {
const { _active: n = [], options: o } = this, r = e, a = this._getActiveElements(t, n, s, r), l = ia(t), c = Xc(t, this._lastEvent, s, l);
s && (this._lastEvent = null, F(o.onHover, [
t,
a,
this
], this), l && F(o.onClick, [
t,
a,
this
], this));
const h = !yi(a, n);
return (h || e) && (this._active = a, this._updateHoverStyles(a, n, e)), this._lastEvent = c, h;
}
_getActiveElements(t, e, s, n) {
if (t.type === "mouseout")
return [];
if (!s)
return e;
const o = this.options.hover;
return this.getElementsAtEventForMode(t, o.mode, o, n);
}
}
w(ct, "defaults", j), w(ct, "instances", gi), w(ct, "overrides", qt), w(ct, "registry", gt), w(ct, "version", Vc), w(ct, "getChart", Tn);
function En() {
return L(ct.instances, (i) => i._plugins.invalidate());
}
function qc(i, t, e) {
const { startAngle: s, pixelMargin: n, x: o, y: r, outerRadius: a, innerRadius: l } = t;
let c = n / a;
i.beginPath(), i.arc(o, r, a, s - c, e + c), l > n ? (c = n / l, i.arc(o, r, l, e + c, s - c, !0)) : i.arc(o, r, n, e + U, s - U), i.closePath(), i.clip();
}
function Gc(i) {
return ws(i, [
"outerStart",
"outerEnd",
"innerStart",
"innerEnd"
]);
}
function Zc(i, t, e, s) {
const n = Gc(i.options.borderRadius), o = (e - t) / 2, r = Math.min(o, s * t / 2), a = (l) => {
const c = (e - Math.min(o, l)) * s / 2;
return K(l, 0, Math.min(o, c));
};
return {
outerStart: a(n.outerStart),
outerEnd: a(n.outerEnd),
innerStart: K(n.innerStart, 0, r),
innerEnd: K(n.innerEnd, 0, r)
};
}
function oe(i, t, e, s) {
return {
x: e + i * Math.cos(t),
y: s + i * Math.sin(t)
};
}
function Pi(i, t, e, s, n, o) {
const { x: r, y: a, startAngle: l, pixelMargin: c, innerRadius: h } = t, d = Math.max(t.outerRadius + s + e - c, 0), f = h > 0 ? h + s + e + c : 0;
let u = 0;
const g = n - l;
if (s) {
const R = h > 0 ? h - s : 0, B = d > 0 ? d - s : 0, H = (R + B) / 2, lt = H !== 0 ? g * H / (H + s) : g;
u = (g - lt) / 2;
}
const p = Math.max(1e-3, g * d - e / I) / d, m = (g - p) / 2, b = l + m + u, x = n - m - u, { outerStart: v, outerEnd: y, innerStart: _, innerEnd: k } = Zc(t, f, d, x - b), S = d - v, M = d - y, P = b + v / S, D = x - y / M, O = f + _, T = f + k, q = b + _ / O, st = x - k / T;
if (i.beginPath(), o) {
const R = (P + D) / 2;
if (i.arc(r, a, d, P, R), i.arc(r, a, d, R, D), y > 0) {
const G = oe(M, D, r, a);
i.arc(G.x, G.y, y, D, x + U);
}
const B = oe(T, x, r, a);
if (i.lineTo(B.x, B.y), k > 0) {
const G = oe(T, st, r, a);
i.arc(G.x, G.y, k, x + U, st + Math.PI);
}
const H = (x - k / f + (b + _ / f)) / 2;
if (i.arc(r, a, f, x - k / f, H, !0), i.arc(r, a, f, H, b + _ / f, !0), _ > 0) {
const G = oe(O, q, r, a);
i.arc(G.x, G.y, _, q + Math.PI, b - U);
}
const lt = oe(S, b, r, a);
if (i.lineTo(lt.x, lt.y), v > 0) {
const G = oe(S, P, r, a);
i.arc(G.x, G.y, v, b - U, P);
}
} else {
i.moveTo(r, a);
const R = Math.cos(P) * d + r, B = Math.sin(P) * d + a;
i.lineTo(R, B);
const H = Math.cos(D) * d + r, lt = Math.sin(D) * d + a;
i.lineTo(H, lt);
}
i.closePath();
}
function Qc(i, t, e, s, n) {
const { fullCircles: o, startAngle: r, circumference: a } = t;
let l = t.endAngle;
if (o) {
Pi(i, t, e, s, l, n);
for (let c = 0; c < o; ++c)
i.fill();
isNaN(a) || (l = r + (a % z || z));
}
return Pi(i, t, e, s, l, n), i.fill(), l;
}
function Jc(i, t, e, s, n) {
const { fullCircles: o, startAngle: r, circumference: a, options: l } = t, { borderWidth: c, borderJoinStyle: h, borderDash: d, borderDashOffset: f } = l, u = l.borderAlign === "inner";
if (!c)
return;
i.setLineDash(d || []), i.lineDashOffset = f, u ? (i.lineWidth = c * 2, i.lineJoin = h || "round") : (i.lineWidth = c, i.lineJoin = h || "bevel");
let g = t.endAngle;
if (o) {
Pi(i, t, e, s, g, n);
for (let p = 0; p < o; ++p)
i.stroke();
isNaN(a) || (g = r + (a % z || z));
}
u && qc(i, t, g), o || (Pi(i, t, e, s, g, n), i.stroke());
}
class ke extends ft {
constructor(e) {
super();
w(this, "circumference");
w(this, "endAngle");
w(this, "fullCircles");
w(this, "innerRadius");
w(this, "outerRadius");
w(this, "pixelMargin");
w(this, "startAngle");
this.options = void 0, this.circumference = void 0, this.startAngle = void 0, this.endAngle = void 0, this.innerRadius = void 0, this.outerRadius = void 0, this.pixelMargin = 0, this.fullCircles = 0, e && Object.assign(this, e);
}
inRange(e, s, n) {
const o = this.getProps([
"x",
"y"
], n), { angle: r, distance: a } = go(o, {
x: e,
y: s
}), { startAngle: l, endAngle: c, innerRadius: h, outerRadius: d, circumference: f } = this.getProps([
"startAngle",
"endAngle",
"innerRadius",
"outerRadius",
"circumference"
], n), u = (this.options.spacing + this.options.borderWidth) / 2, g = C(f, c - l), p = Fe(r, l, c) && l !== c, m = g >= z || p, b = vt(a, h + u, d + u);
return m && b;
}
getCenterPoint(e) {
const { x: s, y: n, startAngle: o, endAngle: r, innerRadius: a, outerRadius: l } = this.getProps([
"x",
"y",
"startAngle",
"endAngle",
"innerRadius",
"outerRadius"
], e), { offset: c, spacing: h } = this.options, d = (o + r) / 2, f = (a + l + h + c) / 2;
return {
x: s + Math.cos(d) * f,
y: n + Math.sin(d) * f
};
}
tooltipPosition(e) {
return this.getCenterPoint(e);
}
draw(e) {
const { options: s, circumference: n } = this, o = (s.offset || 0) / 4, r = (s.spacing || 0) / 2, a = s.circular;
if (this.pixelMargin = s.borderAlign === "inner" ? 0.33 : 0, this.fullCircles = n > z ? Math.floor(n / z) : 0, n === 0 || this.innerRadius < 0 || this.outerRadius < 0)
return;
e.save();
const l = (this.startAngle + this.endAngle) / 2;
e.translate(Math.cos(l) * o, Math.sin(l) * o);
const c = 1 - Math.sin(Math.min(I, n || 0)), h = o * c;
e.fillStyle = s.backgroundColor, e.strokeStyle = s.borderColor, Qc(e, this, h, r, a), Jc(e, this, h, r, a), e.restore();
}
}
w(ke, "id", "arc"), w(ke, "defaults", {
borderAlign: "center",
borderColor: "#fff",
borderDash: [],
borderDashOffset: 0,
borderJoinStyle: void 0,
borderRadius: 0,
borderWidth: 2,
offset: 0,
spacing: 0,
angle: void 0,
circular: !0
}), w(ke, "defaultRoutes", {
backgroundColor: "backgroundColor"
}), w(ke, "descriptors", {
_scriptable: !0,
_indexable: (e) => e !== "borderDash"
});
function Xo(i, t, e = t) {
i.lineCap = C(e.borderCapStyle, t.borderCapStyle), i.setLineDash(C(e.borderDash, t.borderDash)), i.lineDashOffset = C(e.borderDashOffset, t.borderDashOffset), i.lineJoin = C(e.borderJoinStyle, t.borderJoinStyle), i.lineWidth = C(e.borderWidth, t.borderWidth), i.strokeStyle = C(e.borderColor, t.borderColor);
}
function th(i, t, e) {
i.lineTo(e.x, e.y);
}
function eh(i) {
return i.stepped ? Sa : i.tension || i.cubicInterpolationMode === "monotone" ? Ma : th;
}
function Ko(i, t, e = {}) {
const s = i.length, { start: n = 0, end: o = s - 1 } = e, { start: r, end: a } = t, l = Math.max(n, r), c = Math.min(o, a), h = n < r && o < r || n > a && o > a;
return {
count: s,
start: l,
loop: t.loop,
ilen: c < l && !h ? s + c - l : c - l
};
}
function ih(i, t, e, s) {
const { points: n, options: o } = t, { count: r, start: a, loop: l, ilen: c } = Ko(n, e, s), h = eh(o);
let { move: d = !0, reverse: f } = s || {}, u, g, p;
for (u = 0; u <= c; ++u)
g = n[(a + (f ? c - u : u)) % r], !g.skip && (d ? (i.moveTo(g.x, g.y), d = !1) : h(i, p, g, f, o.stepped), p = g);
return l && (g = n[(a + (f ? c : 0)) % r], h(i, p, g, f, o.stepped)), !!l;
}
function sh(i, t, e, s) {
const n = t.points, { count: o, start: r, ilen: a } = Ko(n, e, s), { move: l = !0, reverse: c } = s || {};
let h = 0, d = 0, f, u, g, p, m, b;
const x = (y) => (r + (c ? a - y : y)) % o, v = () => {
p !== m && (i.lineTo(h, m), i.lineTo(h, p), i.lineTo(h, b));
};
for (l && (u = n[x(0)], i.moveTo(u.x, u.y)), f = 0; f <= a; ++f) {
if (u = n[x(f)], u.skip)
continue;
const y = u.x, _ = u.y, k = y | 0;
k === g ? (_ < p ? p = _ : _ > m && (m = _), h = (d * h + y) / ++d) : (v(), i.lineTo(y, _), g = k, d = 0, p = m = _), b = _;
}
v();
}
function ss(i) {
const t = i.options, e = t.borderDash && t.borderDash.length;
return !i._decimated && !i._loop && !t.tension && t.cubicInterpolationMode !== "monotone" && !t.stepped && !e ? sh : ih;
}
function nh(i) {
return i.stepped ? sl : i.tension || i.cubicInterpolationMode === "monotone" ? nl : Ut;
}
function oh(i, t, e, s) {
let n = t._path;
n || (n = t._path = new Path2D(), t.path(n, e, s) && n.closePath()), Xo(i, t.options), i.stroke(n);
}
function rh(i, t, e, s) {
const { segments: n, options: o } = t, r = ss(t);
for (const a of n)
Xo(i, o, a.style), i.beginPath(), r(i, t, a, {
start: e,
end: e + s - 1
}) && i.closePath(), i.stroke();
}
const ah = typeof Path2D == "function";
function lh(i, t, e, s) {
ah && !t.options.segment ? oh(i, t, e, s) : rh(i, t, e, s);
}
class Dt extends ft {
constructor(t) {
super(), this.animated = !0, this.options = void 0, this._chart = void 0, this._loop = void 0, this._fullLoop = void 0, this._path = void 0, this._points = void 0, this._segments = void 0, this._decimated = !1, this._pointsUpdated = !1, this._datasetIndex = void 0, t && Object.assign(this, t);
}
updateControlPoints(t, e) {
const s = this.options;
if ((s.tension || s.cubicInterpolationMode === "monotone") && !s.stepped && !this._pointsUpdated) {
const n = s.spanGaps ? this._loop : this._fullLoop;
qa(this._points, s, t, n, e), this._pointsUpdated = !0;
}
}
set points(t) {
this._points = t, delete this._segments, delete this._path, this._pointsUpdated = !1;
}
get points() {
return this._points;
}
get segments() {
return this._segments || (this._segments = hl(this, this.options.segment));
}
first() {
const t = this.segments, e = this.points;
return t.length && e[t[0].start];
}
last() {
const t = this.segments, e = this.points, s = t.length;
return s && e[t[s - 1].end];
}
interpolate(t, e) {
const s = this.options, n = t[e], o = this.points, r = Ro(this, {
property: e,
start: n,
end: n
});
if (!r.length)
return;
const a = [], l = nh(s);
let c, h;
for (c = 0, h = r.length; c < h; ++c) {
const { start: d, end: f } = r[c], u = o[d], g = o[f];
if (u === g) {
a.push(u);
continue;
}
const p = Math.abs((n - u[e]) / (g[e] - u[e])), m = l(u, g, p, s.stepped);
m[e] = t[e], a.push(m);
}
return a.length === 1 ? a[0] : a;
}
pathSegment(t, e, s) {
return ss(this)(t, this, e, s);
}
path(t, e, s) {
const n = this.segments, o = ss(this);
let r = this._loop;
e = e || 0, s = s || this.points.length - e;
for (const a of n)
r &= o(t, this, a, {
start: e,
end: e + s - 1
});
return !!r;
}
draw(t, e, s, n) {
const o = this.options || {};
(this.points || []).length && o.borderWidth && (t.save(), lh(t, this, s, n), t.restore()), this.animated && (this._pointsUpdated = !1, this._path = void 0);
}
}
w(Dt, "id", "line"), w(Dt, "defaults", {
borderCapStyle: "butt",
borderDash: [],
borderDashOffset: 0,
borderJoinStyle: "miter",
borderWidth: 3,
capBezierPoints: !0,
cubicInterpolationMode: "default",
fill: !1,
spanGaps: !1,
stepped: !1,
tension: 0
}), w(Dt, "defaultRoutes", {
backgroundColor: "backgroundColor",
borderColor: "borderColor"
}), w(Dt, "descriptors", {
_scriptable: !0,
_indexable: (t) => t !== "borderDash" && t !== "fill"
});
function Ln(i, t, e, s) {
const n = i.options, { [e]: o } = i.getProps([
e
], s);
return Math.abs(t - o) < n.radius + n.hitRadius;
}
class pi extends ft {
constructor(e) {
super();
w(this, "parsed");
w(this, "skip");
w(this, "stop");
this.options = void 0, this.parsed = void 0, this.skip = void 0, this.stop = void 0, e && Object.assign(this, e);
}
inRange(e, s, n) {
const o = this.options, { x: r, y: a } = this.getProps([
"x",
"y"
], n);
return Math.pow(e - r, 2) + Math.pow(s - a, 2) < Math.pow(o.hitRadius + o.radius, 2);
}
inXRange(e, s) {
return Ln(this, e, "x", s);
}
inYRange(e, s) {
return Ln(this, e, "y", s);
}
getCenterPoint(e) {
const { x: s, y: n } = this.getProps([
"x",
"y"
], e);
return {
x: s,
y: n
};
}
size(e) {
e = e || this.options || {};
let s = e.radius || 0;
s = Math.max(s, s && e.hoverRadius || 0);
const n = s && e.borderWidth || 0;
return (s + n) * 2;
}
draw(e, s) {
const n = this.options;
this.skip || n.radius < 0.1 || !kt(this, s, this.size(n) / 2) || (e.strokeStyle = n.borderColor, e.lineWidth = n.borderWidth, e.fillStyle = n.backgroundColor, Ji(e, n, this.x, this.y));
}
getRange() {
const e = this.options || {};
return e.radius + e.hitRadius;
}
}
w(pi, "id", "point"), /**
* @type {any}
*/
w(pi, "defaults", {
borderWidth: 1,
hitRadius: 1,
hoverBorderWidth: 1,
hoverRadius: 4,
pointStyle: "circle",
radius: 3,
rotation: 0
}), /**
* @type {any}
*/
w(pi, "defaultRoutes", {
backgroundColor: "backgroundColor",
borderColor: "borderColor"
});
function qo(i, t) {
const { x: e, y: s, base: n, width: o, height: r } = i.getProps([
"x",
"y",
"base",
"width",
"height"
], t);
let a, l, c, h, d;
return i.horizontal ? (d = r / 2, a = Math.min(e, n), l = Math.max(e, n), c = s - d, h = s + d) : (d = o / 2, a = e - d, l = e + d, c = Math.min(s, n), h = Math.max(s, n)), {
left: a,
top: c,
right: l,
bottom: h
};
}
function Ot(i, t, e, s) {
return i ? 0 : K(t, e, s);
}
function ch(i, t, e) {
const s = i.options.borderWidth, n = i.borderSkipped, o = ko(s);
return {
t: Ot(n.top, o.top, 0, e),
r: Ot(n.right, o.right, 0, t),
b: Ot(n.bottom, o.bottom, 0, e),
l: Ot(n.left, o.left, 0, t)
};
}
function hh(i, t, e) {
const { enableBorderRadius: s } = i.getProps([
"enableBorderRadius"
]), n = i.options.borderRadius, o = Xt(n), r = Math.min(t, e), a = i.borderSkipped, l = s || A(n);
return {
topLeft: Ot(!l || a.top || a.left, o.topLeft, 0, r),
topRight: Ot(!l || a.top || a.right, o.topRight, 0, r),
bottomLeft: Ot(!l || a.bottom || a.left, o.bottomLeft, 0, r),
bottomRight: Ot(!l || a.bottom || a.right, o.bottomRight, 0, r)
};
}
function dh(i) {
const t = qo(i), e = t.right - t.left, s = t.bottom - t.top, n = ch(i, e / 2, s / 2), o = hh(i, e / 2, s / 2);
return {
outer: {
x: t.left,
y: t.top,
w: e,
h: s,
radius: o
},
inner: {
x: t.left + n.l,
y: t.top + n.t,
w: e - n.l - n.r,
h: s - n.t - n.b,
radius: {
topLeft: Math.max(0, o.topLeft - Math.max(n.t, n.l)),
topRight: Math.max(0, o.topRight - Math.max(n.t, n.r)),
bottomLeft: Math.max(0, o.bottomLeft - Math.max(n.b, n.l)),
bottomRight: Math.max(0, o.bottomRight - Math.max(n.b, n.r))
}
}
};
}
function Xi(i, t, e, s) {
const n = t === null, o = e === null, a = i && !(n && o) && qo(i, s);
return a && (n || vt(t, a.left, a.right)) && (o || vt(e, a.top, a.bottom));
}
function fh(i) {
return i.topLeft || i.topRight || i.bottomLeft || i.bottomRight;
}
function uh(i, t) {
i.rect(t.x, t.y, t.w, t.h);
}
function Ki(i, t, e = {}) {
const s = i.x !== e.x ? -t : 0, n = i.y !== e.y ? -t : 0, o = (i.x + i.w !== e.x + e.w ? t : 0) - s, r = (i.y + i.h !== e.y + e.h ? t : 0) - n;
return {
x: i.x + s,
y: i.y + n,
w: i.w + o,
h: i.h + r,
radius: i.radius
};
}
class mi extends ft {
constructor(t) {
super(), this.options = void 0, this.horizontal = void 0, this.base = void 0, this.width = void 0, this.height = void 0, this.inflateAmount = void 0, t && Object.assign(this, t);
}
draw(t) {
const { inflateAmount: e, options: { borderColor: s, backgroundColor: n } } = this, { inner: o, outer: r } = dh(this), a = fh(r.radius) ? ze : uh;
t.save(), (r.w !== o.w || r.h !== o.h) && (t.beginPath(), a(t, Ki(r, e, o)), t.clip(), a(t, Ki(o, -e, r)), t.fillStyle = s, t.fill("evenodd")), t.beginPath(), a(t, Ki(o, e)), t.fillStyle = n, t.fill(), t.restore();
}
inRange(t, e, s) {
return Xi(this, t, e, s);
}
inXRange(t, e) {
return Xi(this, t, null, e);
}
inYRange(t, e) {
return Xi(this, null, t, e);
}
getCenterPoint(t) {
const { x: e, y: s, base: n, horizontal: o } = this.getProps([
"x",
"y",
"base",
"horizontal"
], t);
return {
x: o ? (e + n) / 2 : e,
y: o ? s : (s + n) / 2
};
}
getRange(t) {
return t === "x" ? this.width / 2 : this.height / 2;
}
}
w(mi, "id", "bar"), w(mi, "defaults", {
borderSkipped: "start",
borderWidth: 0,
borderRadius: 0,
inflateAmount: "auto",
pointStyle: void 0
}), w(mi, "defaultRoutes", {
backgroundColor: "backgroundColor",
borderColor: "borderColor"
});
var gh = /* @__PURE__ */ Object.freeze({
__proto__: null,
ArcElement: ke,
BarElement: mi,
LineElement: Dt,
PointElement: pi
});
const ns = [
"rgb(54, 162, 235)",
"rgb(255, 99, 132)",
"rgb(255, 159, 64)",
"rgb(255, 205, 86)",
"rgb(75, 192, 192)",
"rgb(153, 102, 255)",
"rgb(201, 203, 207)"
// grey
], Rn = /* @__PURE__ */ ns.map((i) => i.replace("rgb(", "rgba(").replace(")", ", 0.5)"));
function Go(i) {
return ns[i % ns.length];
}
function Zo(i) {
return Rn[i % Rn.length];
}
function ph(i, t) {
return i.borderColor = Go(t), i.backgroundColor = Zo(t), ++t;
}
function mh(i, t) {
return i.backgroundColor = i.data.map(() => Go(t++)), t;
}
function bh(i, t) {
return i.backgroundColor = i.data.map(() => Zo(t++)), t;
}
function xh(i) {
let t = 0;
return (e, s) => {
const n = i.getDatasetMeta(s).controller;
n instanceof Yt ? t = mh(e, t) : n instanceof Te ? t = bh(e, t) : n && (t = ph(e, t));
};
}
function Fn(i) {
let t;
for (t in i)
if (i[t].borderColor || i[t].backgroundColor)
return !0;
return !1;
}
function _h(i) {
return i && (i.borderColor || i.backgroundColor);
}
function yh() {
return j.borderColor !== "rgba(0,0,0,0.1)" || j.backgroundColor !== "rgba(0,0,0,0.1)";
}
var vh = {
id: "colors",
defaults: {
enabled: !0,
forceOverride: !1
},
beforeLayout(i, t, e) {
if (!e.enabled)
return;
const { data: { datasets: s }, options: n } = i.config, { elements: o } = n, r = Fn(s) || _h(n) || o && Fn(o) || yh();
if (!e.forceOverride && r)
return;
const a = xh(i);
s.forEach(a);
}
};
function wh(i, t, e, s, n) {
const o = n.samples || s;
if (o >= e)
return i.slice(t, t + e);
const r = [], a = (e - 2) / (o - 2);
let l = 0;
const c = t + e - 1;
let h = t, d, f, u, g, p;
for (r[l++] = i[h], d = 0; d < o - 2; d++) {
let m = 0, b = 0, x;
const v = Math.floor((d + 1) * a) + 1 + t, y = Math.min(Math.floor((d + 2) * a) + 1, e) + t, _ = y - v;
for (x = v; x < y; x++)
m += i[x].x, b += i[x].y;
m /= _, b /= _;
const k = Math.floor(d * a) + 1 + t, S = Math.min(Math.floor((d + 1) * a) + 1, e) + t, { x: M, y: P } = i[h];
for (u = g = -1, x = k; x < S; x++)
g = 0.5 * Math.abs((M - m) * (i[x].y - P) - (M - i[x].x) * (b - P)), g > u && (u = g, f = i[x], p = x);
r[l++] = f, h = p;
}
return r[l++] = i[c], r;
}
function kh(i, t, e, s) {
let n = 0, o = 0, r, a, l, c, h, d, f, u, g, p;
const m = [], b = t + e - 1, x = i[t].x, y = i[b].x - x;
for (r = t; r < t + e; ++r) {
a = i[r], l = (a.x - x) / y * s, c = a.y;
const _ = l | 0;
if (_ === h)
c < g ? (g = c, d = r) : c > p && (p = c, f = r), n = (o * n + a.x) / ++o;
else {
const k = r - 1;
if (!E(d) && !E(f)) {
const S = Math.min(d, f), M = Math.max(d, f);
S !== u && S !== k && m.push({
...i[S],
x: n
}), M !== u && M !== k && m.push({
...i[M],
x: n
});
}
r > 0 && k !== u && m.push(i[k]), m.push(a), h = _, o = 0, g = p = c, d = f = u = r;
}
}
return m;
}
function Qo(i) {
if (i._decimated) {
const t = i._data;
delete i._decimated, delete i._data, Object.defineProperty(i, "data", {
configurable: !0,
enumerable: !0,
writable: !0,
value: t
});
}
}
function zn(i) {
i.data.datasets.forEach((t) => {
Qo(t);
});
}
function Sh(i, t) {
const e = t.length;
let s = 0, n;
const { iScale: o } = i, { min: r, max: a, minDefined: l, maxDefined: c } = o.getUserBounds();
return l && (s = K(wt(t, o.axis, r).lo, 0, e - 1)), c ? n = K(wt(t, o.axis, a).hi + 1, s, e) - s : n = e - s, {
start: s,
count: n
};
}
var Mh = {
id: "decimation",
defaults: {
algorithm: "min-max",
enabled: !1
},
beforeElementsUpdate: (i, t, e) => {
if (!e.enabled) {
zn(i);
return;
}
const s = i.width;
i.data.datasets.forEach((n, o) => {
const { _data: r, indexAxis: a } = n, l = i.getDatasetMeta(o), c = r || n.data;
if (ve([
a,
i.options.indexAxis
]) === "y" || !l.controller.supportsDecimation)
return;
const h = i.scales[l.xAxisID];
if (h.type !== "linear" && h.type !== "time" || i.options.parsing)
return;
let { start: d, count: f } = Sh(l, c);
const u = e.threshold || 4 * s;
if (f <= u) {
Qo(n);
return;
}
E(r) && (n._data = c, delete n.data, Object.defineProperty(n, "data", {
configurable: !0,
enumerable: !0,
get: function() {
return this._decimated;
},
set: function(p) {
this._data = p;
}
}));
let g;
switch (e.algorithm) {
case "lttb":
g = wh(c, d, f, s, e);
break;
case "min-max":
g = kh(c, d, f, s);
break;
default:
throw new Error(`Unsupported decimation algorithm '${e.algorithm}'`);
}
n._decimated = g;
});
},
destroy(i) {
zn(i);
}
};
function Ph(i, t, e) {
const s = i.segments, n = i.points, o = t.points, r = [];
for (const a of s) {
let { start: l, end: c } = a;
c = Os(l, c, n);
const h = os(e, n[l], n[c], a.loop);
if (!t.segments) {
r.push({
source: a,
target: h,
start: n[l],
end: n[c]
});
continue;
}
const d = Ro(t, h);
for (const f of d) {
const u = os(e, o[f.start], o[f.end], f.loop), g = Lo(a, n, u);
for (const p of g)
r.push({
source: p,
target: f,
start: {
[e]: In(h, u, "start", Math.max)
},
end: {
[e]: In(h, u, "end", Math.min)
}
});
}
}
return r;
}
function os(i, t, e, s) {
if (s)
return;
let n = t[i], o = e[i];
return i === "angle" && (n = ot(n), o = ot(o)), {
property: i,
start: n,
end: o
};
}
function Ch(i, t) {
const { x: e = null, y: s = null } = i || {}, n = t.points, o = [];
return t.segments.forEach(({ start: r, end: a }) => {
a = Os(r, a, n);
const l = n[r], c = n[a];
s !== null ? (o.push({
x: l.x,
y: s
}), o.push({
x: c.x,
y: s
})) : e !== null && (o.push({
x: e,
y: l.y
}), o.push({
x: e,
y: c.y
}));
}), o;
}
function Os(i, t, e) {
for (; t > i; t--) {
const s = e[t];
if (!isNaN(s.x) && !isNaN(s.y))
break;
}
return t;
}
function In(i, t, e, s) {
return i && t ? s(i[e], t[e]) : i ? i[e] : t ? t[e] : 0;
}
function Jo(i, t) {
let e = [], s = !1;
return $(i) ? (s = !0, e = i) : e = Ch(i, t), e.length ? new Dt({
points: e,
options: {
tension: 0
},
_loop: s,
_fullLoop: s
}) : null;
}
function Bn(i) {
return i && i.fill !== !1;
}
function Dh(i, t, e) {
let n = i[t].fill;
const o = [
t
];
let r;
if (!e)
return n;
for (; n !== !1 && o.indexOf(n) === -1; ) {
if (!V(n))
return n;
if (r = i[n], !r)
return !1;
if (r.visible)
return n;
o.push(n), n = r.fill;
}
return !1;
}
function Oh(i, t, e) {
const s = Lh(i);
if (A(s))
return isNaN(s.value) ? !1 : s;
let n = parseFloat(s);
return V(n) && Math.floor(n) === n ? Ah(s[0], t, n, e) : [
"origin",
"start",
"end",
"stack",
"shape"
].indexOf(s) >= 0 && s;
}
function Ah(i, t, e, s) {
return (i === "-" || i === "+") && (e = t + e), e === t || e < 0 || e >= s ? !1 : e;
}
function Th(i, t) {
let e = null;
return i === "start" ? e = t.bottom : i === "end" ? e = t.top : A(i) ? e = t.getPixelForValue(i.value) : t.getBasePixel && (e = t.getBasePixel()), e;
}
function Eh(i, t, e) {
let s;
return i === "start" ? s = e : i === "end" ? s = t.options.reverse ? t.min : t.max : A(i) ? s = i.value : s = t.getBaseValue(), s;
}
function Lh(i) {
const t = i.options, e = t.fill;
let s = C(e && e.target, e);
return s === void 0 && (s = !!t.backgroundColor), s === !1 || s === null ? !1 : s === !0 ? "origin" : s;
}
function Rh(i) {
const { scale: t, index: e, line: s } = i, n = [], o = s.segments, r = s.points, a = Fh(t, e);
a.push(Jo({
x: null,
y: t.bottom
}, s));
for (let l = 0; l < o.length; l++) {
const c = o[l];
for (let h = c.start; h <= c.end; h++)
zh(n, r[h], a);
}
return new Dt({
points: n,
options: {}
});
}
function Fh(i, t) {
const e = [], s = i.getMatchingVisibleMetas("line");
for (let n = 0; n < s.length; n++) {
const o = s[n];
if (o.index === t)
break;
o.hidden || e.unshift(o.dataset);
}
return e;
}
function zh(i, t, e) {
const s = [];
for (let n = 0; n < e.length; n++) {
const o = e[n], { first: r, last: a, point: l } = Ih(o, t, "x");
if (!(!l || r && a)) {
if (r)
s.unshift(l);
else if (i.push(l), !a)
break;
}
}
i.push(...s);
}
function Ih(i, t, e) {
const s = i.interpolate(t, e);
if (!s)
return {};
const n = s[e], o = i.segments, r = i.points;
let a = !1, l = !1;
for (let c = 0; c < o.length; c++) {
const h = o[c], d = r[h.start][e], f = r[h.end][e];
if (vt(n, d, f)) {
a = n === d, l = n === f;
break;
}
}
return {
first: a,
last: l,
point: s
};
}
class tr {
constructor(t) {
this.x = t.x, this.y = t.y, this.radius = t.radius;
}
pathSegment(t, e, s) {
const { x: n, y: o, radius: r } = this;
return e = e || {
start: 0,
end: z
}, t.arc(n, o, r, e.end, e.start, !0), !s.bounds;
}
interpolate(t) {
const { x: e, y: s, radius: n } = this, o = t.angle;
return {
x: e + Math.cos(o) * n,
y: s + Math.sin(o) * n,
angle: o
};
}
}
function Bh(i) {
const { chart: t, fill: e, line: s } = i;
if (V(e))
return $h(t, e);
if (e === "stack")
return Rh(i);
if (e === "shape")
return !0;
const n = jh(i);
return n instanceof tr ? n : Jo(n, s);
}
function $h(i, t) {
const e = i.getDatasetMeta(t);
return e && i.isDatasetVisible(t) ? e.dataset : null;
}
function jh(i) {
return (i.scale || {}).getPointPositionForValue ? Nh(i) : Wh(i);
}
function Wh(i) {
const { scale: t = {}, fill: e } = i, s = Th(e, t);
if (V(s)) {
const n = t.isHorizontal();
return {
x: n ? s : null,
y: n ? null : s
};
}
return null;
}
function Nh(i) {
const { scale: t, fill: e } = i, s = t.options, n = t.getLabels().length, o = s.reverse ? t.max : t.min, r = Eh(e, t, o), a = [];
if (s.grid.circular) {
const l = t.getPointPositionForValue(0, o);
return new tr({
x: l.x,
y: l.y,
radius: t.getDistanceFromCenterForValue(r)
});
}
for (let l = 0; l < n; ++l)
a.push(t.getPointPositionForValue(l, r));
return a;
}
function qi(i, t, e) {
const s = Bh(t), { line: n, scale: o, axis: r } = t, a = n.options, l = a.fill, c = a.backgroundColor, { above: h = c, below: d = c } = l || {};
s && n.points.length && (Ai(i, e), Vh(i, {
line: n,
target: s,
above: h,
below: d,
area: e,
scale: o,
axis: r
}), Ti(i));
}
function Vh(i, t) {
const { line: e, target: s, above: n, below: o, area: r, scale: a } = t, l = e._loop ? "angle" : t.axis;
i.save(), l === "x" && o !== n && ($n(i, s, r.top), jn(i, {
line: e,
target: s,
color: n,
scale: a,
property: l
}), i.restore(), i.save(), $n(i, s, r.bottom)), jn(i, {
line: e,
target: s,
color: o,
scale: a,
property: l
}), i.restore();
}
function $n(i, t, e) {
const { segments: s, points: n } = t;
let o = !0, r = !1;
i.beginPath();
for (const a of s) {
const { start: l, end: c } = a, h = n[l], d = n[Os(l, c, n)];
o ? (i.moveTo(h.x, h.y), o = !1) : (i.lineTo(h.x, e), i.lineTo(h.x, h.y)), r = !!t.pathSegment(i, a, {
move: r
}), r ? i.closePath() : i.lineTo(d.x, e);
}
i.lineTo(t.first().x, e), i.closePath(), i.clip();
}
function jn(i, t) {
const { line: e, target: s, property: n, color: o, scale: r } = t, a = Ph(e, s, n);
for (const { source: l, target: c, start: h, end: d } of a) {
const { style: { backgroundColor: f = o } = {} } = l, u = s !== !0;
i.save(), i.fillStyle = f, Hh(i, r, u && os(n, h, d)), i.beginPath();
const g = !!e.pathSegment(i, l);
let p;
if (u) {
g ? i.closePath() : Wn(i, s, d, n);
const m = !!s.pathSegment(i, c, {
move: g,
reverse: !0
});
p = g && m, p || Wn(i, s, h, n);
}
i.closePath(), i.fill(p ? "evenodd" : "nonzero"), i.restore();
}
}
function Hh(i, t, e) {
const { top: s, bottom: n } = t.chart.chartArea, { property: o, start: r, end: a } = e || {};
o === "x" && (i.beginPath(), i.rect(r, s, a - r, n - s), i.clip());
}
function Wn(i, t, e, s) {
const n = t.interpolate(e, s);
n && i.lineTo(n.x, n.y);
}
var Uh = {
id: "filler",
afterDatasetsUpdate(i, t, e) {
const s = (i.data.datasets || []).length, n = [];
let o, r, a, l;
for (r = 0; r < s; ++r)
o = i.getDatasetMeta(r), a = o.dataset, l = null, a && a.options && a instanceof Dt && (l = {
visible: i.isDatasetVisible(r),
index: r,
fill: Oh(a, r, s),
chart: i,
axis: o.controller.options.indexAxis,
scale: o.vScale,
line: a
}), o.$filler = l, n.push(l);
for (r = 0; r < s; ++r)
l = n[r], !(!l || l.fill === !1) && (l.fill = Dh(n, r, e.propagate));
},
beforeDraw(i, t, e) {
const s = e.drawTime === "beforeDraw", n = i.getSortedVisibleDatasetMetas(), o = i.chartArea;
for (let r = n.length - 1; r >= 0; --r) {
const a = n[r].$filler;
a && (a.line.updateControlPoints(o, a.axis), s && a.fill && qi(i.ctx, a, o));
}
},
beforeDatasetsDraw(i, t, e) {
if (e.drawTime !== "beforeDatasetsDraw")
return;
const s = i.getSortedVisibleDatasetMetas();
for (let n = s.length - 1; n >= 0; --n) {
const o = s[n].$filler;
Bn(o) && qi(i.ctx, o, i.chartArea);
}
},
beforeDatasetDraw(i, t, e) {
const s = t.meta.$filler;
!Bn(s) || e.drawTime !== "beforeDatasetDraw" || qi(i.ctx, s, i.chartArea);
},
defaults: {
propagate: !0,
drawTime: "beforeDatasetDraw"
}
};
const Nn = (i, t) => {
let { boxHeight: e = t, boxWidth: s = t } = i;
return i.usePointStyle && (e = Math.min(e, t), s = i.pointStyleWidth || Math.min(s, t)), {
boxWidth: s,
boxHeight: e,
itemHeight: Math.max(t, e)
};
}, Yh = (i, t) => i !== null && t !== null && i.datasetIndex === t.datasetIndex && i.index === t.index;
class Vn extends ft {
constructor(t) {
super(), this._added = !1, this.legendHitBoxes = [], this._hoveredItem = null, this.doughnutMode = !1, this.chart = t.chart, this.options = t.options, this.ctx = t.ctx, this.legendItems = void 0, this.columnSizes = void 0, this.lineWidths = void 0, this.maxHeight = void 0, this.maxWidth = void 0, this.top = void 0, this.bottom = void 0, this.left = void 0, this.right = void 0, this.height = void 0, this.width = void 0, this._margins = void 0, this.position = void 0, this.weight = void 0, this.fullSize = void 0;
}
update(t, e, s) {
this.maxWidth = t, this.maxHeight = e, this._margins = s, this.setDimensions(), this.buildLabels(), this.fit();
}
setDimensions() {
this.isHorizontal() ? (this.width = this.maxWidth, this.left = this._margins.left, this.right = this.width) : (this.height = this.maxHeight, this.top = this._margins.top, this.bottom = this.height);
}
buildLabels() {
const t = this.options.labels || {};
let e = F(t.generateLabels, [
this.chart
], this) || [];
t.filter && (e = e.filter((s) => t.filter(s, this.chart.data))), t.sort && (e = e.sort((s, n) => t.sort(s, n, this.chart.data))), this.options.reverse && e.reverse(), this.legendItems = e;
}
fit() {
const { options: t, ctx: e } = this;
if (!t.display) {
this.width = this.height = 0;
return;
}
const s = t.labels, n = Y(s.font), o = n.size, r = this._computeTitleHeight(), { boxWidth: a, itemHeight: l } = Nn(s, o);
let c, h;
e.font = n.string, this.isHorizontal() ? (c = this.maxWidth, h = this._fitRows(r, o, a, l) + 10) : (h = this.maxHeight, c = this._fitCols(r, n, a, l) + 10), this.width = Math.min(c, t.maxWidth || this.maxWidth), this.height = Math.min(h, t.maxHeight || this.maxHeight);
}
_fitRows(t, e, s, n) {
const { ctx: o, maxWidth: r, options: { labels: { padding: a } } } = this, l = this.legendHitBoxes = [], c = this.lineWidths = [
0
], h = n + a;
let d = t;
o.textAlign = "left", o.textBaseline = "middle";
let f = -1, u = -h;
return this.legendItems.forEach((g, p) => {
const m = s + e / 2 + o.measureText(g.text).width;
(p === 0 || c[c.length - 1] + m + 2 * a > r) && (d += h, c[c.length - (p > 0 ? 0 : 1)] = 0, u += h, f++), l[p] = {
left: 0,
top: u,
row: f,
width: m,
height: n
}, c[c.length - 1] += m + a;
}), d;
}
_fitCols(t, e, s, n) {
const { ctx: o, maxHeight: r, options: { labels: { padding: a } } } = this, l = this.legendHitBoxes = [], c = this.columnSizes = [], h = r - t;
let d = a, f = 0, u = 0, g = 0, p = 0;
return this.legendItems.forEach((m, b) => {
const { itemWidth: x, itemHeight: v } = Xh(s, e, o, m, n);
b > 0 && u + v + 2 * a > h && (d += f + a, c.push({
width: f,
height: u
}), g += f + a, p++, f = u = 0), l[b] = {
left: g,
top: u,
col: p,
width: x,
height: v
}, f = Math.max(f, x), u += v + a;
}), d += f, c.push({
width: f,
height: u
}), d;
}
adjustHitBoxes() {
if (!this.options.display)
return;
const t = this._computeTitleHeight(), { legendHitBoxes: e, options: { align: s, labels: { padding: n }, rtl: o } } = this, r = re(o, this.left, this.width);
if (this.isHorizontal()) {
let a = 0, l = Z(s, this.left + n, this.right - this.lineWidths[a]);
for (const c of e)
a !== c.row && (a = c.row, l = Z(s, this.left + n, this.right - this.lineWidths[a])), c.top += this.top + t + n, c.left = r.leftForLtr(r.x(l), c.width), l += c.width + n;
} else {
let a = 0, l = Z(s, this.top + t + n, this.bottom - this.columnSizes[a].height);
for (const c of e)
c.col !== a && (a = c.col, l = Z(s, this.top + t + n, this.bottom - this.columnSizes[a].height)), c.top = l, c.left += this.left + n, c.left = r.leftForLtr(r.x(c.left), c.width), l += c.height + n;
}
}
isHorizontal() {
return this.options.position === "top" || this.options.position === "bottom";
}
draw() {
if (this.options.display) {
const t = this.ctx;
Ai(t, this), this._draw(), Ti(t);
}
}
_draw() {
const { options: t, columnSizes: e, lineWidths: s, ctx: n } = this, { align: o, labels: r } = t, a = j.color, l = re(t.rtl, this.left, this.width), c = Y(r.font), { padding: h } = r, d = c.size, f = d / 2;
let u;
this.drawTitle(), n.textAlign = l.textAlign("left"), n.textBaseline = "middle", n.lineWidth = 0.5, n.font = c.string;
const { boxWidth: g, boxHeight: p, itemHeight: m } = Nn(r, d), b = function(k, S, M) {
if (isNaN(g) || g <= 0 || isNaN(p) || p < 0)
return;
n.save();
const P = C(M.lineWidth, 1);
if (n.fillStyle = C(M.fillStyle, a), n.lineCap = C(M.lineCap, "butt"), n.lineDashOffset = C(M.lineDashOffset, 0), n.lineJoin = C(M.lineJoin, "miter"), n.lineWidth = P, n.strokeStyle = C(M.strokeStyle, a), n.setLineDash(C(M.lineDash, [])), r.usePointStyle) {
const D = {
radius: p * Math.SQRT2 / 2,
pointStyle: M.pointStyle,
rotation: M.rotation,
borderWidth: P
}, O = l.xPlus(k, g / 2), T = S + f;
wo(n, D, O, T, r.pointStyleWidth && g);
} else {
const D = S + Math.max((d - p) / 2, 0), O = l.leftForLtr(k, g), T = Xt(M.borderRadius);
n.beginPath(), Object.values(T).some((q) => q !== 0) ? ze(n, {
x: O,
y: D,
w: g,
h: p,
radius: T
}) : n.rect(O, D, g, p), n.fill(), P !== 0 && n.stroke();
}
n.restore();
}, x = function(k, S, M) {
Gt(n, M.text, k, S + m / 2, c, {
strikethrough: M.hidden,
textAlign: l.textAlign(M.textAlign)
});
}, v = this.isHorizontal(), y = this._computeTitleHeight();
v ? u = {
x: Z(o, this.left + h, this.right - s[0]),
y: this.top + h + y,
line: 0
} : u = {
x: this.left + h,
y: Z(o, this.top + y + h, this.bottom - e[0].height),
line: 0
}, Ao(this.ctx, t.textDirection);
const _ = m + h;
this.legendItems.forEach((k, S) => {
n.strokeStyle = k.fontColor, n.fillStyle = k.fontColor;
const M = n.measureText(k.text).width, P = l.textAlign(k.textAlign || (k.textAlign = r.textAlign)), D = g + f + M;
let O = u.x, T = u.y;
l.setWidth(this.width), v ? S > 0 && O + D + h > this.right && (T = u.y += _, u.line++, O = u.x = Z(o, this.left + h, this.right - s[u.line])) : S > 0 && T + _ > this.bottom && (O = u.x = O + e[u.line].width + h, u.line++, T = u.y = Z(o, this.top + y + h, this.bottom - e[u.line].height));
const q = l.x(O);
if (b(q, T, k), O = ua(P, O + g + f, v ? O + D : this.right, t.rtl), x(l.x(O), T, k), v)
u.x += D + h;
else if (typeof k.text != "string") {
const st = c.lineHeight;
u.y += er(k, st) + h;
} else
u.y += _;
}), To(this.ctx, t.textDirection);
}
drawTitle() {
const t = this.options, e = t.title, s = Y(e.font), n = J(e.padding);
if (!e.display)
return;
const o = re(t.rtl, this.left, this.width), r = this.ctx, a = e.position, l = s.size / 2, c = n.top + l;
let h, d = this.left, f = this.width;
if (this.isHorizontal())
f = Math.max(...this.lineWidths), h = this.top + c, d = Z(t.align, d, this.right - f);
else {
const g = this.columnSizes.reduce((p, m) => Math.max(p, m.height), 0);
h = c + Z(t.align, this.top, this.bottom - g - t.labels.padding - this._computeTitleHeight());
}
const u = Z(a, d, d + f);
r.textAlign = o.textAlign(ys(a)), r.textBaseline = "middle", r.strokeStyle = e.color, r.fillStyle = e.color, r.font = s.string, Gt(r, e.text, u, h, s);
}
_computeTitleHeight() {
const t = this.options.title, e = Y(t.font), s = J(t.padding);
return t.display ? e.lineHeight + s.height : 0;
}
_getLegendItemAt(t, e) {
let s, n, o;
if (vt(t, this.left, this.right) && vt(e, this.top, this.bottom)) {
for (o = this.legendHitBoxes, s = 0; s < o.length; ++s)
if (n = o[s], vt(t, n.left, n.left + n.width) && vt(e, n.top, n.top + n.height))
return this.legendItems[s];
}
return null;
}
handleEvent(t) {
const e = this.options;
if (!Gh(t.type, e))
return;
const s = this._getLegendItemAt(t.x, t.y);
if (t.type === "mousemove" || t.type === "mouseout") {
const n = this._hoveredItem, o = Yh(n, s);
n && !o && F(e.onLeave, [
t,
n,
this
], this), this._hoveredItem = s, s && !o && F(e.onHover, [
t,
s,
this
], this);
} else s && F(e.onClick, [
t,
s,
this
], this);
}
}
function Xh(i, t, e, s, n) {
const o = Kh(s, i, t, e), r = qh(n, s, t.lineHeight);
return {
itemWidth: o,
itemHeight: r
};
}
function Kh(i, t, e, s) {
let n = i.text;
return n && typeof n != "string" && (n = n.reduce((o, r) => o.length > r.length ? o : r)), t + e.size / 2 + s.measureText(n).width;
}
function qh(i, t, e) {
let s = i;
return typeof t.text != "string" && (s = er(t, e)), s;
}
function er(i, t) {
const e = i.text ? i.text.length : 0;
return t * e;
}
function Gh(i, t) {
return !!((i === "mousemove" || i === "mouseout") && (t.onHover || t.onLeave) || t.onClick && (i === "click" || i === "mouseup"));
}
var Zh = {
id: "legend",
_element: Vn,
start(i, t, e) {
const s = i.legend = new Vn({
ctx: i.ctx,
options: e,
chart: i
});
Q.configure(i, s, e), Q.addBox(i, s);
},
stop(i) {
Q.removeBox(i, i.legend), delete i.legend;
},
beforeUpdate(i, t, e) {
const s = i.legend;
Q.configure(i, s, e), s.options = e;
},
afterUpdate(i) {
const t = i.legend;
t.buildLabels(), t.adjustHitBoxes();
},
afterEvent(i, t) {
t.replay || i.legend.handleEvent(t.event);
},
defaults: {
display: !0,
position: "top",
align: "center",
fullSize: !0,
reverse: !1,
weight: 1e3,
onClick(i, t, e) {
const s = t.datasetIndex, n = e.chart;
n.isDatasetVisible(s) ? (n.hide(s), t.hidden = !0) : (n.show(s), t.hidden = !1);
},
onHover: null,
onLeave: null,
labels: {
color: (i) => i.chart.options.color,
boxWidth: 40,
padding: 10,
generateLabels(i) {
const t = i.data.datasets, { labels: { usePointStyle: e, pointStyle: s, textAlign: n, color: o, useBorderRadius: r, borderRadius: a } } = i.legend.options;
return i._getSortedDatasetMetas().map((l) => {
const c = l.controller.getStyle(e ? 0 : void 0), h = J(c.borderWidth);
return {
text: t[l.index].label,
fillStyle: c.backgroundColor,
fontColor: o,
hidden: !l.visible,
lineCap: c.borderCapStyle,
lineDash: c.borderDash,
lineDashOffset: c.borderDashOffset,
lineJoin: c.borderJoinStyle,
lineWidth: (h.width + h.height) / 4,
strokeStyle: c.borderColor,
pointStyle: s || c.pointStyle,
rotation: c.rotation,
textAlign: n || c.textAlign,
borderRadius: r && (a || c.borderRadius),
datasetIndex: l.index
};
}, this);
}
},
title: {
color: (i) => i.chart.options.color,
display: !1,
position: "center",
text: ""
}
},
descriptors: {
_scriptable: (i) => !i.startsWith("on"),
labels: {
_scriptable: (i) => ![
"generateLabels",
"filter",
"sort"
].includes(i)
}
}
};
class As extends ft {
constructor(t) {
super(), this.chart = t.chart, this.options = t.options, this.ctx = t.ctx, this._padding = void 0, this.top = void 0, this.bottom = void 0, this.left = void 0, this.right = void 0, this.width = void 0, this.height = void 0, this.position = void 0, this.weight = void 0, this.fullSize = void 0;
}
update(t, e) {
const s = this.options;
if (this.left = 0, this.top = 0, !s.display) {
this.width = this.height = this.right = this.bottom = 0;
return;
}
this.width = this.right = t, this.height = this.bottom = e;
const n = $(s.text) ? s.text.length : 1;
this._padding = J(s.padding);
const o = n * Y(s.font).lineHeight + this._padding.height;
this.isHorizontal() ? this.height = o : this.width = o;
}
isHorizontal() {
const t = this.options.position;
return t === "top" || t === "bottom";
}
_drawArgs(t) {
const { top: e, left: s, bottom: n, right: o, options: r } = this, a = r.align;
let l = 0, c, h, d;
return this.isHorizontal() ? (h = Z(a, s, o), d = e + t, c = o - s) : (r.position === "left" ? (h = s + t, d = Z(a, n, e), l = I * -0.5) : (h = o - t, d = Z(a, e, n), l = I * 0.5), c = n - e), {
titleX: h,
titleY: d,
maxWidth: c,
rotation: l
};
}
draw() {
const t = this.ctx, e = this.options;
if (!e.display)
return;
const s = Y(e.font), o = s.lineHeight / 2 + this._padding.top, { titleX: r, titleY: a, maxWidth: l, rotation: c } = this._drawArgs(o);
Gt(t, e.text, 0, 0, s, {
color: e.color,
maxWidth: l,
rotation: c,
textAlign: ys(e.align),
textBaseline: "middle",
translation: [
r,
a
]
});
}
}
function Qh(i, t) {
const e = new As({
ctx: i.ctx,
options: t,
chart: i
});
Q.configure(i, e, t), Q.addBox(i, e), i.titleBlock = e;
}
var Jh = {
id: "title",
_element: As,
start(i, t, e) {
Qh(i, e);
},
stop(i) {
const t = i.titleBlock;
Q.removeBox(i, t), delete i.titleBlock;
},
beforeUpdate(i, t, e) {
const s = i.titleBlock;
Q.configure(i, s, e), s.options = e;
},
defaults: {
align: "center",
display: !1,
font: {
weight: "bold"
},
fullSize: !0,
padding: 10,
position: "top",
text: "",
weight: 2e3
},
defaultRoutes: {
color: "color"
},
descriptors: {
_scriptable: !0,
_indexable: !1
}
};
const ni = /* @__PURE__ */ new WeakMap();
var td = {
id: "subtitle",
start(i, t, e) {
const s = new As({
ctx: i.ctx,
options: e,
chart: i
});
Q.configure(i, s, e), Q.addBox(i, s), ni.set(i, s);
},
stop(i) {
Q.removeBox(i, ni.get(i)), ni.delete(i);
},
beforeUpdate(i, t, e) {
const s = ni.get(i);
Q.configure(i, s, e), s.options = e;
},
defaults: {
align: "center",
display: !1,
font: {
weight: "normal"
},
fullSize: !0,
padding: 0,
position: "top",
text: "",
weight: 1500
},
defaultRoutes: {
color: "color"
},
descriptors: {
_scriptable: !0,
_indexable: !1
}
};
const Se = {
average(i) {
if (!i.length)
return !1;
let t, e, s = /* @__PURE__ */ new Set(), n = 0, o = 0;
for (t = 0, e = i.length; t < e; ++t) {
const a = i[t].element;
if (a && a.hasValue()) {
const l = a.tooltipPosition();
s.add(l.x), n += l.y, ++o;
}
}
return o === 0 || s.size === 0 ? !1 : {
x: [
...s
].reduce((a, l) => a + l) / s.size,
y: n / o
};
},
nearest(i, t) {
if (!i.length)
return !1;
let e = t.x, s = t.y, n = Number.POSITIVE_INFINITY, o, r, a;
for (o = 0, r = i.length; o < r; ++o) {
const l = i[o].element;
if (l && l.hasValue()) {
const c = l.getCenterPoint(), h = Zi(t, c);
h < n && (n = h, a = l);
}
}
if (a) {
const l = a.tooltipPosition();
e = l.x, s = l.y;
}
return {
x: e,
y: s
};
}
};
function ut(i, t) {
return t && ($(t) ? Array.prototype.push.apply(i, t) : i.push(t)), i;
}
function _t(i) {
return (typeof i == "string" || i instanceof String) && i.indexOf(`
`) > -1 ? i.split(`
`) : i;
}
function ed(i, t) {
const { element: e, datasetIndex: s, index: n } = t, o = i.getDatasetMeta(s).controller, { label: r, value: a } = o.getLabelAndValue(n);
return {
chart: i,
label: r,
parsed: o.getParsed(n),
raw: i.data.datasets[s].data[n],
formattedValue: a,
dataset: o.getDataset(),
dataIndex: n,
datasetIndex: s,
element: e
};
}
function Hn(i, t) {
const e = i.chart.ctx, { body: s, footer: n, title: o } = i, { boxWidth: r, boxHeight: a } = t, l = Y(t.bodyFont), c = Y(t.titleFont), h = Y(t.footerFont), d = o.length, f = n.length, u = s.length, g = J(t.padding);
let p = g.height, m = 0, b = s.reduce((y, _) => y + _.before.length + _.lines.length + _.after.length, 0);
if (b += i.beforeBody.length + i.afterBody.length, d && (p += d * c.lineHeight + (d - 1) * t.titleSpacing + t.titleMarginBottom), b) {
const y = t.displayColors ? Math.max(a, l.lineHeight) : l.lineHeight;
p += u * y + (b - u) * l.lineHeight + (b - 1) * t.bodySpacing;
}
f && (p += t.footerMarginTop + f * h.lineHeight + (f - 1) * t.footerSpacing);
let x = 0;
const v = function(y) {
m = Math.max(m, e.measureText(y).width + x);
};
return e.save(), e.font = c.string, L(i.title, v), e.font = l.string, L(i.beforeBody.concat(i.afterBody), v), x = t.displayColors ? r + 2 + t.boxPadding : 0, L(s, (y) => {
L(y.before, v), L(y.lines, v), L(y.after, v);
}), x = 0, e.font = h.string, L(i.footer, v), e.restore(), m += g.width, {
width: m,
height: p
};
}
function id(i, t) {
const { y: e, height: s } = t;
return e < s / 2 ? "top" : e > i.height - s / 2 ? "bottom" : "center";
}
function sd(i, t, e, s) {
const { x: n, width: o } = s, r = e.caretSize + e.caretPadding;
if (i === "left" && n + o + r > t.width || i === "right" && n - o - r < 0)
return !0;
}
function nd(i, t, e, s) {
const { x: n, width: o } = e, { width: r, chartArea: { left: a, right: l } } = i;
let c = "center";
return s === "center" ? c = n <= (a + l) / 2 ? "left" : "right" : n <= o / 2 ? c = "left" : n >= r - o / 2 && (c = "right"), sd(c, i, t, e) && (c = "center"), c;
}
function Un(i, t, e) {
const s = e.yAlign || t.yAlign || id(i, e);
return {
xAlign: e.xAlign || t.xAlign || nd(i, t, e, s),
yAlign: s
};
}
function od(i, t) {
let { x: e, width: s } = i;
return t === "right" ? e -= s : t === "center" && (e -= s / 2), e;
}
function rd(i, t, e) {
let { y: s, height: n } = i;
return t === "top" ? s += e : t === "bottom" ? s -= n + e : s -= n / 2, s;
}
function Yn(i, t, e, s) {
const { caretSize: n, caretPadding: o, cornerRadius: r } = i, { xAlign: a, yAlign: l } = e, c = n + o, { topLeft: h, topRight: d, bottomLeft: f, bottomRight: u } = Xt(r);
let g = od(t, a);
const p = rd(t, l, c);
return l === "center" ? a === "left" ? g += c : a === "right" && (g -= c) : a === "left" ? g -= Math.max(h, f) + n : a === "right" && (g += Math.max(d, u) + n), {
x: K(g, 0, s.width - t.width),
y: K(p, 0, s.height - t.height)
};
}
function oi(i, t, e) {
const s = J(e.padding);
return t === "center" ? i.x + i.width / 2 : t === "right" ? i.x + i.width - s.right : i.x + s.left;
}
function Xn(i) {
return ut([], _t(i));
}
function ad(i, t, e) {
return It(i, {
tooltip: t,
tooltipItems: e,
type: "tooltip"
});
}
function Kn(i, t) {
const e = t && t.dataset && t.dataset.tooltip && t.dataset.tooltip.callbacks;
return e ? i.override(e) : i;
}
const ir = {
beforeTitle: bt,
title(i) {
if (i.length > 0) {
const t = i[0], e = t.chart.data.labels, s = e ? e.length : 0;
if (this && this.options && this.options.mode === "dataset")
return t.dataset.label || "";
if (t.label)
return t.label;
if (s > 0 && t.dataIndex < s)
return e[t.dataIndex];
}
return "";
},
afterTitle: bt,
beforeBody: bt,
beforeLabel: bt,
label(i) {
if (this && this.options && this.options.mode === "dataset")
return i.label + ": " + i.formattedValue || i.formattedValue;
let t = i.dataset.label || "";
t && (t += ": ");
const e = i.formattedValue;
return E(e) || (t += e), t;
},
labelColor(i) {
const e = i.chart.getDatasetMeta(i.datasetIndex).controller.getStyle(i.dataIndex);
return {
borderColor: e.borderColor,
backgroundColor: e.backgroundColor,
borderWidth: e.borderWidth,
borderDash: e.borderDash,
borderDashOffset: e.borderDashOffset,
borderRadius: 0
};
},
labelTextColor() {
return this.options.bodyColor;
},
labelPointStyle(i) {
const e = i.chart.getDatasetMeta(i.datasetIndex).controller.getStyle(i.dataIndex);
return {
pointStyle: e.pointStyle,
rotation: e.rotation
};
},
afterLabel: bt,
afterBody: bt,
beforeFooter: bt,
footer: bt,
afterFooter: bt
};
function et(i, t, e, s) {
const n = i[t].call(e, s);
return typeof n > "u" ? ir[t].call(e, s) : n;
}
class rs extends ft {
constructor(t) {
super(), this.opacity = 0, this._active = [], this._eventPosition = void 0, this._size = void 0, this._cachedAnimations = void 0, this._tooltipItems = [], this.$animations = void 0, this.$context = void 0, this.chart = t.chart, this.options = t.options, this.dataPoints = void 0, this.title = void 0, this.beforeBody = void 0, this.body = void 0, this.afterBody = void 0, this.footer = void 0, this.xAlign = void 0, this.yAlign = void 0, this.x = void 0, this.y = void 0, this.height = void 0, this.width = void 0, this.caretX = void 0, this.caretY = void 0, this.labelColors = void 0, this.labelPointStyles = void 0, this.labelTextColors = void 0;
}
initialize(t) {
this.options = t, this._cachedAnimations = void 0, this.$context = void 0;
}
_resolveAnimations() {
const t = this._cachedAnimations;
if (t)
return t;
const e = this.chart, s = this.options.setContext(this.getContext()), n = s.enabled && e.options.animation && s.animations, o = new Fo(this.chart, n);
return n._cacheable && (this._cachedAnimations = Object.freeze(o)), o;
}
getContext() {
return this.$context || (this.$context = ad(this.chart.getContext(), this, this._tooltipItems));
}
getTitle(t, e) {
const { callbacks: s } = e, n = et(s, "beforeTitle", this, t), o = et(s, "title", this, t), r = et(s, "afterTitle", this, t);
let a = [];
return a = ut(a, _t(n)), a = ut(a, _t(o)), a = ut(a, _t(r)), a;
}
getBeforeBody(t, e) {
return Xn(et(e.callbacks, "beforeBody", this, t));
}
getBody(t, e) {
const { callbacks: s } = e, n = [];
return L(t, (o) => {
const r = {
before: [],
lines: [],
after: []
}, a = Kn(s, o);
ut(r.before, _t(et(a, "beforeLabel", this, o))), ut(r.lines, et(a, "label", this, o)), ut(r.after, _t(et(a, "afterLabel", this, o))), n.push(r);
}), n;
}
getAfterBody(t, e) {
return Xn(et(e.callbacks, "afterBody", this, t));
}
getFooter(t, e) {
const { callbacks: s } = e, n = et(s, "beforeFooter", this, t), o = et(s, "footer", this, t), r = et(s, "afterFooter", this, t);
let a = [];
return a = ut(a, _t(n)), a = ut(a, _t(o)), a = ut(a, _t(r)), a;
}
_createItems(t) {
const e = this._active, s = this.chart.data, n = [], o = [], r = [];
let a = [], l, c;
for (l = 0, c = e.length; l < c; ++l)
a.push(ed(this.chart, e[l]));
return t.filter && (a = a.filter((h, d, f) => t.filter(h, d, f, s))), t.itemSort && (a = a.sort((h, d) => t.itemSort(h, d, s))), L(a, (h) => {
const d = Kn(t.callbacks, h);
n.push(et(d, "labelColor", this, h)), o.push(et(d, "labelPointStyle", this, h)), r.push(et(d, "labelTextColor", this, h));
}), this.labelColors = n, this.labelPointStyles = o, this.labelTextColors = r, this.dataPoints = a, a;
}
update(t, e) {
const s = this.options.setContext(this.getContext()), n = this._active;
let o, r = [];
if (!n.length)
this.opacity !== 0 && (o = {
opacity: 0
});
else {
const a = Se[s.position].call(this, n, this._eventPosition);
r = this._createItems(s), this.title = this.getTitle(r, s), this.beforeBody = this.getBeforeBody(r, s), this.body = this.getBody(r, s), this.afterBody = this.getAfterBody(r, s), this.footer = this.getFooter(r, s);
const l = this._size = Hn(this, s), c = Object.assign({}, a, l), h = Un(this.chart, s, c), d = Yn(s, c, h, this.chart);
this.xAlign = h.xAlign, this.yAlign = h.yAlign, o = {
opacity: 1,
x: d.x,
y: d.y,
width: l.width,
height: l.height,
caretX: a.x,
caretY: a.y
};
}
this._tooltipItems = r, this.$context = void 0, o && this._resolveAnimations().update(this, o), t && s.external && s.external.call(this, {
chart: this.chart,
tooltip: this,
replay: e
});
}
drawCaret(t, e, s, n) {
const o = this.getCaretPosition(t, s, n);
e.lineTo(o.x1, o.y1), e.lineTo(o.x2, o.y2), e.lineTo(o.x3, o.y3);
}
getCaretPosition(t, e, s) {
const { xAlign: n, yAlign: o } = this, { caretSize: r, cornerRadius: a } = s, { topLeft: l, topRight: c, bottomLeft: h, bottomRight: d } = Xt(a), { x: f, y: u } = t, { width: g, height: p } = e;
let m, b, x, v, y, _;
return o === "center" ? (y = u + p / 2, n === "left" ? (m = f, b = m - r, v = y + r, _ = y - r) : (m = f + g, b = m + r, v = y - r, _ = y + r), x = m) : (n === "left" ? b = f + Math.max(l, h) + r : n === "right" ? b = f + g - Math.max(c, d) - r : b = this.caretX, o === "top" ? (v = u, y = v - r, m = b - r, x = b + r) : (v = u + p, y = v + r, m = b + r, x = b - r), _ = v), {
x1: m,
x2: b,
x3: x,
y1: v,
y2: y,
y3: _
};
}
drawTitle(t, e, s) {
const n = this.title, o = n.length;
let r, a, l;
if (o) {
const c = re(s.rtl, this.x, this.width);
for (t.x = oi(this, s.titleAlign, s), e.textAlign = c.textAlign(s.titleAlign), e.textBaseline = "middle", r = Y(s.titleFont), a = s.titleSpacing, e.fillStyle = s.titleColor, e.font = r.string, l = 0; l < o; ++l)
e.fillText(n[l], c.x(t.x), t.y + r.lineHeight / 2), t.y += r.lineHeight + a, l + 1 === o && (t.y += s.titleMarginBottom - a);
}
}
_drawColorBox(t, e, s, n, o) {
const r = this.labelColors[s], a = this.labelPointStyles[s], { boxHeight: l, boxWidth: c } = o, h = Y(o.bodyFont), d = oi(this, "left", o), f = n.x(d), u = l < h.lineHeight ? (h.lineHeight - l) / 2 : 0, g = e.y + u;
if (o.usePointStyle) {
const p = {
radius: Math.min(c, l) / 2,
pointStyle: a.pointStyle,
rotation: a.rotation,
borderWidth: 1
}, m = n.leftForLtr(f, c) + c / 2, b = g + l / 2;
t.strokeStyle = o.multiKeyBackground, t.fillStyle = o.multiKeyBackground, Ji(t, p, m, b), t.strokeStyle = r.borderColor, t.fillStyle = r.backgroundColor, Ji(t, p, m, b);
} else {
t.lineWidth = A(r.borderWidth) ? Math.max(...Object.values(r.borderWidth)) : r.borderWidth || 1, t.strokeStyle = r.borderColor, t.setLineDash(r.borderDash || []), t.lineDashOffset = r.borderDashOffset || 0;
const p = n.leftForLtr(f, c), m = n.leftForLtr(n.xPlus(f, 1), c - 2), b = Xt(r.borderRadius);
Object.values(b).some((x) => x !== 0) ? (t.beginPath(), t.fillStyle = o.multiKeyBackground, ze(t, {
x: p,
y: g,
w: c,
h: l,
radius: b
}), t.fill(), t.stroke(), t.fillStyle = r.backgroundColor, t.beginPath(), ze(t, {
x: m,
y: g + 1,
w: c - 2,
h: l - 2,
radius: b
}), t.fill()) : (t.fillStyle = o.multiKeyBackground, t.fillRect(p, g, c, l), t.strokeRect(p, g, c, l), t.fillStyle = r.backgroundColor, t.fillRect(m, g + 1, c - 2, l - 2));
}
t.fillStyle = this.labelTextColors[s];
}
drawBody(t, e, s) {
const { body: n } = this, { bodySpacing: o, bodyAlign: r, displayColors: a, boxHeight: l, boxWidth: c, boxPadding: h } = s, d = Y(s.bodyFont);
let f = d.lineHeight, u = 0;
const g = re(s.rtl, this.x, this.width), p = function(M) {
e.fillText(M, g.x(t.x + u), t.y + f / 2), t.y += f + o;
}, m = g.textAlign(r);
let b, x, v, y, _, k, S;
for (e.textAlign = r, e.textBaseline = "middle", e.font = d.string, t.x = oi(this, m, s), e.fillStyle = s.bodyColor, L(this.beforeBody, p), u = a && m !== "right" ? r === "center" ? c / 2 + h : c + 2 + h : 0, y = 0, k = n.length; y < k; ++y) {
for (b = n[y], x = this.labelTextColors[y], e.fillStyle = x, L(b.before, p), v = b.lines, a && v.length && (this._drawColorBox(e, t, y, g, s), f = Math.max(d.lineHeight, l)), _ = 0, S = v.length; _ < S; ++_)
p(v[_]), f = d.lineHeight;
L(b.after, p);
}
u = 0, f = d.lineHeight, L(this.afterBody, p), t.y -= o;
}
drawFooter(t, e, s) {
const n = this.footer, o = n.length;
let r, a;
if (o) {
const l = re(s.rtl, this.x, this.width);
for (t.x = oi(this, s.footerAlign, s), t.y += s.footerMarginTop, e.textAlign = l.textAlign(s.footerAlign), e.textBaseline = "middle", r = Y(s.footerFont), e.fillStyle = s.footerColor, e.font = r.string, a = 0; a < o; ++a)
e.fillText(n[a], l.x(t.x), t.y + r.lineHeight / 2), t.y += r.lineHeight + s.footerSpacing;
}
}
drawBackground(t, e, s, n) {
const { xAlign: o, yAlign: r } = this, { x: a, y: l } = t, { width: c, height: h } = s, { topLeft: d, topRight: f, bottomLeft: u, bottomRight: g } = Xt(n.cornerRadius);
e.fillStyle = n.backgroundColor, e.strokeStyle = n.borderColor, e.lineWidth = n.borderWidth, e.beginPath(), e.moveTo(a + d, l), r === "top" && this.drawCaret(t, e, s, n), e.lineTo(a + c - f, l), e.quadraticCurveTo(a + c, l, a + c, l + f), r === "center" && o === "right" && this.drawCaret(t, e, s, n), e.lineTo(a + c, l + h - g), e.quadraticCurveTo(a + c, l + h, a + c - g, l + h), r === "bottom" && this.drawCaret(t, e, s, n), e.lineTo(a + u, l + h), e.quadraticCurveTo(a, l + h, a, l + h - u), r === "center" && o === "left" && this.drawCaret(t, e, s, n), e.lineTo(a, l + d), e.quadraticCurveTo(a, l, a + d, l), e.closePath(), e.fill(), n.borderWidth > 0 && e.stroke();
}
_updateAnimationTarget(t) {
const e = this.chart, s = this.$animations, n = s && s.x, o = s && s.y;
if (n || o) {
const r = Se[t.position].call(this, this._active, this._eventPosition);
if (!r)
return;
const a = this._size = Hn(this, t), l = Object.assign({}, r, this._size), c = Un(e, t, l), h = Yn(t, l, c, e);
(n._to !== h.x || o._to !== h.y) && (this.xAlign = c.xAlign, this.yAlign = c.yAlign, this.width = a.width, this.height = a.height, this.caretX = r.x, this.caretY = r.y, this._resolveAnimations().update(this, h));
}
}
_willRender() {
return !!this.opacity;
}
draw(t) {
const e = this.options.setContext(this.getContext());
let s = this.opacity;
if (!s)
return;
this._updateAnimationTarget(e);
const n = {
width: this.width,
height: this.height
}, o = {
x: this.x,
y: this.y
};
s = Math.abs(s) < 1e-3 ? 0 : s;
const r = J(e.padding), a = this.title.length || this.beforeBody.length || this.body.length || this.afterBody.length || this.footer.length;
e.enabled && a && (t.save(), t.globalAlpha = s, this.drawBackground(o, t, n, e), Ao(t, e.textDirection), o.y += r.top, this.drawTitle(o, t, e), this.drawBody(o, t, e), this.drawFooter(o, t, e), To(t, e.textDirection), t.restore());
}
getActiveElements() {
return this._active || [];
}
setActiveElements(t, e) {
const s = this._active, n = t.map(({ datasetIndex: a, index: l }) => {
const c = this.chart.getDatasetMeta(a);
if (!c)
throw new Error("Cannot find a dataset at index " + a);
return {
datasetIndex: a,
element: c.data[l],
index: l
};
}), o = !yi(s, n), r = this._positionChanged(n, e);
(o || r) && (this._active = n, this._eventPosition = e, this._ignoreReplayEvents = !0, this.update(!0));
}
handleEvent(t, e, s = !0) {
if (e && this._ignoreReplayEvents)
return !1;
this._ignoreReplayEvents = !1;
const n = this.options, o = this._active || [], r = this._getActiveElements(t, o, e, s), a = this._positionChanged(r, t), l = e || !yi(r, o) || a;
return l && (this._active = r, (n.enabled || n.external) && (this._eventPosition = {
x: t.x,
y: t.y
}, this.update(!0, e))), l;
}
_getActiveElements(t, e, s, n) {
const o = this.options;
if (t.type === "mouseout")
return [];
if (!n)
return e.filter((a) => this.chart.data.datasets[a.datasetIndex] && this.chart.getDatasetMeta(a.datasetIndex).controller.getParsed(a.index) !== void 0);
const r = this.chart.getElementsAtEventForMode(t, o.mode, o, s);
return o.reverse && r.reverse(), r;
}
_positionChanged(t, e) {
const { caretX: s, caretY: n, options: o } = this, r = Se[o.position].call(this, t, e);
return r !== !1 && (s !== r.x || n !== r.y);
}
}
w(rs, "positioners", Se);
var ld = {
id: "tooltip",
_element: rs,
positioners: Se,
afterInit(i, t, e) {
e && (i.tooltip = new rs({
chart: i,
options: e
}));
},
beforeUpdate(i, t, e) {
i.tooltip && i.tooltip.initialize(e);
},
reset(i, t, e) {
i.tooltip && i.tooltip.initialize(e);
},
afterDraw(i) {
const t = i.tooltip;
if (t && t._willRender()) {
const e = {
tooltip: t
};
if (i.notifyPlugins("beforeTooltipDraw", {
...e,
cancelable: !0
}) === !1)
return;
t.draw(i.ctx), i.notifyPlugins("afterTooltipDraw", e);
}
},
afterEvent(i, t) {
if (i.tooltip) {
const e = t.replay;
i.tooltip.handleEvent(t.event, e, t.inChartArea) && (t.changed = !0);
}
},
defaults: {
enabled: !0,
external: null,
position: "average",
backgroundColor: "rgba(0,0,0,0.8)",
titleColor: "#fff",
titleFont: {
weight: "bold"
},
titleSpacing: 2,
titleMarginBottom: 6,
titleAlign: "left",
bodyColor: "#fff",
bodySpacing: 2,
bodyFont: {},
bodyAlign: "left",
footerColor: "#fff",
footerSpacing: 2,
footerMarginTop: 6,
footerFont: {
weight: "bold"
},
footerAlign: "left",
padding: 6,
caretPadding: 2,
caretSize: 5,
cornerRadius: 6,
boxHeight: (i, t) => t.bodyFont.size,
boxWidth: (i, t) => t.bodyFont.size,
multiKeyBackground: "#fff",
displayColors: !0,
boxPadding: 0,
borderColor: "rgba(0,0,0,0)",
borderWidth: 0,
animation: {
duration: 400,
easing: "easeOutQuart"
},
animations: {
numbers: {
type: "number",
properties: [
"x",
"y",
"width",
"height",
"caretX",
"caretY"
]
},
opacity: {
easing: "linear",
duration: 200
}
},
callbacks: ir
},
defaultRoutes: {
bodyFont: "font",
footerFont: "font",
titleFont: "font"
},
descriptors: {
_scriptable: (i) => i !== "filter" && i !== "itemSort" && i !== "external",
_indexable: !1,
callbacks: {
_scriptable: !1,
_indexable: !1
},
animation: {
_fallback: !1
},
animations: {
_fallback: "animation"
}
},
additionalOptionScopes: [
"interaction"
]
}, cd = /* @__PURE__ */ Object.freeze({
__proto__: null,
Colors: vh,
Decimation: Mh,
Filler: Uh,
Legend: Zh,
SubTitle: td,
Title: Jh,
Tooltip: ld
});
const hd = (i, t, e, s) => (typeof t == "string" ? (e = i.push(t) - 1, s.unshift({
index: e,
label: t
})) : isNaN(t) && (e = null), e);
function dd(i, t, e, s) {
const n = i.indexOf(t);
if (n === -1)
return hd(i, t, e, s);
const o = i.lastIndexOf(t);
return n !== o ? e : n;
}
const fd = (i, t) => i === null ? null : K(Math.round(i), 0, t);
function qn(i) {
const t = this.getLabels();
return i >= 0 && i < t.length ? t[i] : i;
}
class as extends Jt {
constructor(t) {
super(t), this._startValue = void 0, this._valueRange = 0, this._addedLabels = [];
}
init(t) {
const e = this._addedLabels;
if (e.length) {
const s = this.getLabels();
for (const { index: n, label: o } of e)
s[n] === o && s.splice(n, 1);
this._addedLabels = [];
}
super.init(t);
}
parse(t, e) {
if (E(t))
return null;
const s = this.getLabels();
return e = isFinite(e) && s[e] === t ? e : dd(s, t, C(e, t), this._addedLabels), fd(e, s.length - 1);
}
determineDataLimits() {
const { minDefined: t, maxDefined: e } = this.getUserBounds();
let { min: s, max: n } = this.getMinMax(!0);
this.options.bounds === "ticks" && (t || (s = 0), e || (n = this.getLabels().length - 1)), this.min = s, this.max = n;
}
buildTicks() {
const t = this.min, e = this.max, s = this.options.offset, n = [];
let o = this.getLabels();
o = t === 0 && e === o.length - 1 ? o : o.slice(t, e + 1), this._valueRange = Math.max(o.length - (s ? 0 : 1), 1), this._startValue = this.min - (s ? 0.5 : 0);
for (let r = t; r <= e; r++)
n.push({
value: r
});
return n;
}
getLabelForValue(t) {
return qn.call(this, t);
}
configure() {
super.configure(), this.isHorizontal() || (this._reversePixels = !this._reversePixels);
}
getPixelForValue(t) {
return typeof t != "number" && (t = this.parse(t)), t === null ? NaN : this.getPixelForDecimal((t - this._startValue) / this._valueRange);
}
getPixelForTick(t) {
const e = this.ticks;
return t < 0 || t > e.length - 1 ? null : this.getPixelForValue(e[t].value);
}
getValueForPixel(t) {
return Math.round(this._startValue + this.getDecimalForPixel(t) * this._valueRange);
}
getBasePixel() {
return this.bottom;
}
}
w(as, "id", "category"), w(as, "defaults", {
ticks: {
callback: qn
}
});
function ud(i, t) {
const e = [], { bounds: n, step: o, min: r, max: a, precision: l, count: c, maxTicks: h, maxDigits: d, includeBounds: f } = i, u = o || 1, g = h - 1, { min: p, max: m } = t, b = !E(r), x = !E(a), v = !E(c), y = (m - p) / (d + 1);
let _ = Vs((m - p) / g / u) * u, k, S, M, P;
if (_ < 1e-14 && !b && !x)
return [
{
value: p
},
{
value: m
}
];
P = Math.ceil(m / _) - Math.floor(p / _), P > g && (_ = Vs(P * _ / g / u) * u), E(l) || (k = Math.pow(10, l), _ = Math.ceil(_ * k) / k), n === "ticks" ? (S = Math.floor(p / _) * _, M = Math.ceil(m / _) * _) : (S = p, M = m), b && x && o && ra((a - r) / o, _ / 1e3) ? (P = Math.round(Math.min((a - r) / _, h)), _ = (a - r) / P, S = r, M = a) : v ? (S = b ? r : S, M = x ? a : M, P = c - 1, _ = (M - S) / P) : (P = (M - S) / _, De(P, Math.round(P), _ / 1e3) ? P = Math.round(P) : P = Math.ceil(P));
const D = Math.max(Hs(_), Hs(S));
k = Math.pow(10, E(l) ? D : l), S = Math.round(S * k) / k, M = Math.round(M * k) / k;
let O = 0;
for (b && (f && S !== r ? (e.push({
value: r
}), S < r && O++, De(Math.round((S + O * _) * k) / k, r, Gn(r, y, i)) && O++) : S < r && O++); O < P; ++O) {
const T = Math.round((S + O * _) * k) / k;
if (x && T > a)
break;
e.push({
value: T
});
}
return x && f && M !== a ? e.length && De(e[e.length - 1].value, a, Gn(a, y, i)) ? e[e.length - 1].value = a : e.push({
value: a
}) : (!x || M === a) && e.push({
value: M
}), e;
}
function Gn(i, t, { horizontal: e, minRotation: s }) {
const n = ht(s), o = (e ? Math.sin(n) : Math.cos(n)) || 1e-3, r = 0.75 * t * ("" + i).length;
return Math.min(t / o, r);
}
class Ci extends Jt {
constructor(t) {
super(t), this.start = void 0, this.end = void 0, this._startValue = void 0, this._endValue = void 0, this._valueRange = 0;
}
parse(t, e) {
return E(t) || (typeof t == "number" || t instanceof Number) && !isFinite(+t) ? null : +t;
}
handleTickRangeOptions() {
const { beginAtZero: t } = this.options, { minDefined: e, maxDefined: s } = this.getUserBounds();
let { min: n, max: o } = this;
const r = (l) => n = e ? n : l, a = (l) => o = s ? o : l;
if (t) {
const l = pt(n), c = pt(o);
l < 0 && c < 0 ? a(0) : l > 0 && c > 0 && r(0);
}
if (n === o) {
let l = o === 0 ? 1 : Math.abs(o * 0.05);
a(o + l), t || r(n - l);
}
this.min = n, this.max = o;
}
getTickLimit() {
const t = this.options.ticks;
let { maxTicksLimit: e, stepSize: s } = t, n;
return s ? (n = Math.ceil(this.max / s) - Math.floor(this.min / s) + 1, n > 1e3 && (console.warn(`scales.${this.id}.ticks.stepSize: ${s} would result generating up to ${n} ticks. Limiting to 1000.`), n = 1e3)) : (n = this.computeTickLimit(), e = e || 11), e && (n = Math.min(e, n)), n;
}
computeTickLimit() {
return Number.POSITIVE_INFINITY;
}
buildTicks() {
const t = this.options, e = t.ticks;
let s = this.getTickLimit();
s = Math.max(2, s);
const n = {
maxTicks: s,
bounds: t.bounds,
min: t.min,
max: t.max,
precision: e.precision,
step: e.stepSize,
count: e.count,
maxDigits: this._maxDigits(),
horizontal: this.isHorizontal(),
minRotation: e.minRotation || 0,
includeBounds: e.includeBounds !== !1
}, o = this._range || this, r = ud(n, o);
return t.bounds === "ticks" && uo(r, this, "value"), t.reverse ? (r.reverse(), this.start = this.max, this.end = this.min) : (this.start = this.min, this.end = this.max), r;
}
configure() {
const t = this.ticks;
let e = this.min, s = this.max;
if (super.configure(), this.options.offset && t.length) {
const n = (s - e) / Math.max(t.length - 1, 1) / 2;
e -= n, s += n;
}
this._startValue = e, this._endValue = s, this._valueRange = s - e;
}
getLabelForValue(t) {
return Ne(t, this.chart.options.locale, this.options.ticks.format);
}
}
class ls extends Ci {
determineDataLimits() {
const { min: t, max: e } = this.getMinMax(!0);
this.min = V(t) ? t : 0, this.max = V(e) ? e : 1, this.handleTickRangeOptions();
}
computeTickLimit() {
const t = this.isHorizontal(), e = t ? this.width : this.height, s = ht(this.options.ticks.minRotation), n = (t ? Math.sin(s) : Math.cos(s)) || 1e-3, o = this._resolveTickFontOptions(0);
return Math.ceil(e / Math.min(40, o.lineHeight / n));
}
getPixelForValue(t) {
return t === null ? NaN : this.getPixelForDecimal((t - this._startValue) / this._valueRange);
}
getValueForPixel(t) {
return this._startValue + this.getDecimalForPixel(t) * this._valueRange;
}
}
w(ls, "id", "linear"), w(ls, "defaults", {
ticks: {
callback: Oi.formatters.numeric
}
});
const Be = (i) => Math.floor(Ct(i)), Vt = (i, t) => Math.pow(10, Be(i) + t);
function Zn(i) {
return i / Math.pow(10, Be(i)) === 1;
}
function Qn(i, t, e) {
const s = Math.pow(10, e), n = Math.floor(i / s);
return Math.ceil(t / s) - n;
}
function gd(i, t) {
const e = t - i;
let s = Be(e);
for (; Qn(i, t, s) > 10; )
s++;
for (; Qn(i, t, s) < 10; )
s--;
return Math.min(s, Be(i));
}
function pd(i, { min: t, max: e }) {
t = nt(i.min, t);
const s = [], n = Be(t);
let o = gd(t, e), r = o < 0 ? Math.pow(10, Math.abs(o)) : 1;
const a = Math.pow(10, o), l = n > o ? Math.pow(10, n) : 0, c = Math.round((t - l) * r) / r, h = Math.floor((t - l) / a / 10) * a * 10;
let d = Math.floor((c - h) / Math.pow(10, o)), f = nt(i.min, Math.round((l + h + d * Math.pow(10, o)) * r) / r);
for (; f < e; )
s.push({
value: f,
major: Zn(f),
significand: d
}), d >= 10 ? d = d < 15 ? 15 : 20 : d++, d >= 20 && (o++, d = 2, r = o >= 0 ? 1 : r), f = Math.round((l + h + d * Math.pow(10, o)) * r) / r;
const u = nt(i.max, f);
return s.push({
value: u,
major: Zn(u),
significand: d
}), s;
}
class cs extends Jt {
constructor(t) {
super(t), this.start = void 0, this.end = void 0, this._startValue = void 0, this._valueRange = 0;
}
parse(t, e) {
const s = Ci.prototype.parse.apply(this, [
t,
e
]);
if (s === 0) {
this._zero = !0;
return;
}
return V(s) && s > 0 ? s : null;
}
determineDataLimits() {
const { min: t, max: e } = this.getMinMax(!0);
this.min = V(t) ? Math.max(0, t) : null, this.max = V(e) ? Math.max(0, e) : null, this.options.beginAtZero && (this._zero = !0), this._zero && this.min !== this._suggestedMin && !V(this._userMin) && (this.min = t === Vt(this.min, 0) ? Vt(this.min, -1) : Vt(this.min, 0)), this.handleTickRangeOptions();
}
handleTickRangeOptions() {
const { minDefined: t, maxDefined: e } = this.getUserBounds();
let s = this.min, n = this.max;
const o = (a) => s = t ? s : a, r = (a) => n = e ? n : a;
s === n && (s <= 0 ? (o(1), r(10)) : (o(Vt(s, -1)), r(Vt(n, 1)))), s <= 0 && o(Vt(n, -1)), n <= 0 && r(Vt(s, 1)), this.min = s, this.max = n;
}
buildTicks() {
const t = this.options, e = {
min: this._userMin,
max: this._userMax
}, s = pd(e, this);
return t.bounds === "ticks" && uo(s, this, "value"), t.reverse ? (s.reverse(), this.start = this.max, this.end = this.min) : (this.start = this.min, this.end = this.max), s;
}
getLabelForValue(t) {
return t === void 0 ? "0" : Ne(t, this.chart.options.locale, this.options.ticks.format);
}
configure() {
const t = this.min;
super.configure(), this._startValue = Ct(t), this._valueRange = Ct(this.max) - Ct(t);
}
getPixelForValue(t) {
return (t === void 0 || t === 0) && (t = this.min), t === null || isNaN(t) ? NaN : this.getPixelForDecimal(t === this.min ? 0 : (Ct(t) - this._startValue) / this._valueRange);
}
getValueForPixel(t) {
const e = this.getDecimalForPixel(t);
return Math.pow(10, this._startValue + e * this._valueRange);
}
}
w(cs, "id", "logarithmic"), w(cs, "defaults", {
ticks: {
callback: Oi.formatters.logarithmic,
major: {
enabled: !0
}
}
});
function hs(i) {
const t = i.ticks;
if (t.display && i.display) {
const e = J(t.backdropPadding);
return C(t.font && t.font.size, j.font.size) + e.height;
}
return 0;
}
function md(i, t, e) {
return e = $(e) ? e : [
e
], {
w: ka(i, t.string, e),
h: e.length * t.lineHeight
};
}
function Jn(i, t, e, s, n) {
return i === s || i === n ? {
start: t - e / 2,
end: t + e / 2
} : i < s || i > n ? {
start: t - e,
end: t
} : {
start: t,
end: t + e
};
}
function bd(i) {
const t = {
l: i.left + i._padding.left,
r: i.right - i._padding.right,
t: i.top + i._padding.top,
b: i.bottom - i._padding.bottom
}, e = Object.assign({}, t), s = [], n = [], o = i._pointLabels.length, r = i.options.pointLabels, a = r.centerPointLabels ? I / o : 0;
for (let l = 0; l < o; l++) {
const c = r.setContext(i.getPointLabelContext(l));
n[l] = c.padding;
const h = i.getPointPosition(l, i.drawingArea + n[l], a), d = Y(c.font), f = md(i.ctx, d, i._pointLabels[l]);
s[l] = f;
const u = ot(i.getIndexAngle(l) + a), g = Math.round(xs(u)), p = Jn(g, h.x, f.w, 0, 180), m = Jn(g, h.y, f.h, 90, 270);
xd(e, t, u, p, m);
}
i.setCenterPoint(t.l - e.l, e.r - t.r, t.t - e.t, e.b - t.b), i._pointLabelItems = vd(i, s, n);
}
function xd(i, t, e, s, n) {
const o = Math.abs(Math.sin(e)), r = Math.abs(Math.cos(e));
let a = 0, l = 0;
s.start < t.l ? (a = (t.l - s.start) / o, i.l = Math.min(i.l, t.l - a)) : s.end > t.r && (a = (s.end - t.r) / o, i.r = Math.max(i.r, t.r + a)), n.start < t.t ? (l = (t.t - n.start) / r, i.t = Math.min(i.t, t.t - l)) : n.end > t.b && (l = (n.end - t.b) / r, i.b = Math.max(i.b, t.b + l));
}
function _d(i, t, e) {
const s = i.drawingArea, { extra: n, additionalAngle: o, padding: r, size: a } = e, l = i.getPointPosition(t, s + n + r, o), c = Math.round(xs(ot(l.angle + U))), h = Sd(l.y, a.h, c), d = wd(c), f = kd(l.x, a.w, d);
return {
visible: !0,
x: l.x,
y: h,
textAlign: d,
left: f,
top: h,
right: f + a.w,
bottom: h + a.h
};
}
function yd(i, t) {
if (!t)
return !0;
const { left: e, top: s, right: n, bottom: o } = i;
return !(kt({
x: e,
y: s
}, t) || kt({
x: e,
y: o
}, t) || kt({
x: n,
y: s
}, t) || kt({
x: n,
y: o
}, t));
}
function vd(i, t, e) {
const s = [], n = i._pointLabels.length, o = i.options, { centerPointLabels: r, display: a } = o.pointLabels, l = {
extra: hs(o) / 2,
additionalAngle: r ? I / n : 0
};
let c;
for (let h = 0; h < n; h++) {
l.padding = e[h], l.size = t[h];
const d = _d(i, h, l);
s.push(d), a === "auto" && (d.visible = yd(d, c), d.visible && (c = d));
}
return s;
}
function wd(i) {
return i === 0 || i === 180 ? "center" : i < 180 ? "left" : "right";
}
function kd(i, t, e) {
return e === "right" ? i -= t : e === "center" && (i -= t / 2), i;
}
function Sd(i, t, e) {
return e === 90 || e === 270 ? i -= t / 2 : (e > 270 || e < 90) && (i -= t), i;
}
function Md(i, t, e) {
const { left: s, top: n, right: o, bottom: r } = e, { backdropColor: a } = t;
if (!E(a)) {
const l = Xt(t.borderRadius), c = J(t.backdropPadding);
i.fillStyle = a;
const h = s - c.left, d = n - c.top, f = o - s + c.width, u = r - n + c.height;
Object.values(l).some((g) => g !== 0) ? (i.beginPath(), ze(i, {
x: h,
y: d,
w: f,
h: u,
radius: l
}), i.fill()) : i.fillRect(h, d, f, u);
}
}
function Pd(i, t) {
const { ctx: e, options: { pointLabels: s } } = i;
for (let n = t - 1; n >= 0; n--) {
const o = i._pointLabelItems[n];
if (!o.visible)
continue;
const r = s.setContext(i.getPointLabelContext(n));
Md(e, r, o);
const a = Y(r.font), { x: l, y: c, textAlign: h } = o;
Gt(e, i._pointLabels[n], l, c + a.lineHeight / 2, a, {
color: r.color,
textAlign: h,
textBaseline: "middle"
});
}
}
function sr(i, t, e, s) {
const { ctx: n } = i;
if (e)
n.arc(i.xCenter, i.yCenter, t, 0, z);
else {
let o = i.getPointPosition(0, t);
n.moveTo(o.x, o.y);
for (let r = 1; r < s; r++)
o = i.getPointPosition(r, t), n.lineTo(o.x, o.y);
}
}
function Cd(i, t, e, s, n) {
const o = i.ctx, r = t.circular, { color: a, lineWidth: l } = t;
!r && !s || !a || !l || e < 0 || (o.save(), o.strokeStyle = a, o.lineWidth = l, o.setLineDash(n.dash || []), o.lineDashOffset = n.dashOffset, o.beginPath(), sr(i, e, r, s), o.closePath(), o.stroke(), o.restore());
}
function Dd(i, t, e) {
return It(i, {
label: e,
index: t,
type: "pointLabel"
});
}
class Me extends Ci {
constructor(t) {
super(t), this.xCenter = void 0, this.yCenter = void 0, this.drawingArea = void 0, this._pointLabels = [], this._pointLabelItems = [];
}
setDimensions() {
const t = this._padding = J(hs(this.options) / 2), e = this.width = this.maxWidth - t.width, s = this.height = this.maxHeight - t.height;
this.xCenter = Math.floor(this.left + e / 2 + t.left), this.yCenter = Math.floor(this.top + s / 2 + t.top), this.drawingArea = Math.floor(Math.min(e, s) / 2);
}
determineDataLimits() {
const { min: t, max: e } = this.getMinMax(!1);
this.min = V(t) && !isNaN(t) ? t : 0, this.max = V(e) && !isNaN(e) ? e : 0, this.handleTickRangeOptions();
}
computeTickLimit() {
return Math.ceil(this.drawingArea / hs(this.options));
}
generateTickLabels(t) {
Ci.prototype.generateTickLabels.call(this, t), this._pointLabels = this.getLabels().map((e, s) => {
const n = F(this.options.pointLabels.callback, [
e,
s
], this);
return n || n === 0 ? n : "";
}).filter((e, s) => this.chart.getDataVisibility(s));
}
fit() {
const t = this.options;
t.display && t.pointLabels.display ? bd(this) : this.setCenterPoint(0, 0, 0, 0);
}
setCenterPoint(t, e, s, n) {
this.xCenter += Math.floor((t - e) / 2), this.yCenter += Math.floor((s - n) / 2), this.drawingArea -= Math.min(this.drawingArea / 2, Math.max(t, e, s, n));
}
getIndexAngle(t) {
const e = z / (this._pointLabels.length || 1), s = this.options.startAngle || 0;
return ot(t * e + ht(s));
}
getDistanceFromCenterForValue(t) {
if (E(t))
return NaN;
const e = this.drawingArea / (this.max - this.min);
return this.options.reverse ? (this.max - t) * e : (t - this.min) * e;
}
getValueForDistanceFromCenter(t) {
if (E(t))
return NaN;
const e = t / (this.drawingArea / (this.max - this.min));
return this.options.reverse ? this.max - e : this.min + e;
}
getPointLabelContext(t) {
const e = this._pointLabels || [];
if (t >= 0 && t < e.length) {
const s = e[t];
return Dd(this.getContext(), t, s);
}
}
getPointPosition(t, e, s = 0) {
const n = this.getIndexAngle(t) - U + s;
return {
x: Math.cos(n) * e + this.xCenter,
y: Math.sin(n) * e + this.yCenter,
angle: n
};
}
getPointPositionForValue(t, e) {
return this.getPointPosition(t, this.getDistanceFromCenterForValue(e));
}
getBasePosition(t) {
return this.getPointPositionForValue(t || 0, this.getBaseValue());
}
getPointLabelPosition(t) {
const { left: e, top: s, right: n, bottom: o } = this._pointLabelItems[t];
return {
left: e,
top: s,
right: n,
bottom: o
};
}
drawBackground() {
const { backgroundColor: t, grid: { circular: e } } = this.options;
if (t) {
const s = this.ctx;
s.save(), s.beginPath(), sr(this, this.getDistanceFromCenterForValue(this._endValue), e, this._pointLabels.length), s.closePath(), s.fillStyle = t, s.fill(), s.restore();
}
}
drawGrid() {
const t = this.ctx, e = this.options, { angleLines: s, grid: n, border: o } = e, r = this._pointLabels.length;
let a, l, c;
if (e.pointLabels.display && Pd(this, r), n.display && this.ticks.forEach((h, d) => {
if (d !== 0 || d === 0 && this.min < 0) {
l = this.getDistanceFromCenterForValue(h.value);
const f = this.getContext(d), u = n.setContext(f), g = o.setContext(f);
Cd(this, u, l, r, g);
}
}), s.display) {
for (t.save(), a = r - 1; a >= 0; a--) {
const h = s.setContext(this.getPointLabelContext(a)), { color: d, lineWidth: f } = h;
!f || !d || (t.lineWidth = f, t.strokeStyle = d, t.setLineDash(h.borderDash), t.lineDashOffset = h.borderDashOffset, l = this.getDistanceFromCenterForValue(e.reverse ? this.min : this.max), c = this.getPointPosition(a, l), t.beginPath(), t.moveTo(this.xCenter, this.yCenter), t.lineTo(c.x, c.y), t.stroke());
}
t.restore();
}
}
drawBorder() {
}
drawLabels() {
const t = this.ctx, e = this.options, s = e.ticks;
if (!s.display)
return;
const n = this.getIndexAngle(0);
let o, r;
t.save(), t.translate(this.xCenter, this.yCenter), t.rotate(n), t.textAlign = "center", t.textBaseline = "middle", this.ticks.forEach((a, l) => {
if (l === 0 && this.min >= 0 && !e.reverse)
return;
const c = s.setContext(this.getContext(l)), h = Y(c.font);
if (o = this.getDistanceFromCenterForValue(this.ticks[l].value), c.showLabelBackdrop) {
t.font = h.string, r = t.measureText(a.label).width, t.fillStyle = c.backdropColor;
const d = J(c.backdropPadding);
t.fillRect(-r / 2 - d.left, -o - h.size / 2 - d.top, r + d.width, h.size + d.height);
}
Gt(t, a.label, 0, -o, h, {
color: c.color,
strokeColor: c.textStrokeColor,
strokeWidth: c.textStrokeWidth
});
}), t.restore();
}
drawTitle() {
}
}
w(Me, "id", "radialLinear"), w(Me, "defaults", {
display: !0,
animate: !0,
position: "chartArea",
angleLines: {
display: !0,
lineWidth: 1,
borderDash: [],
borderDashOffset: 0
},
grid: {
circular: !1
},
startAngle: 0,
ticks: {
showLabelBackdrop: !0,
callback: Oi.formatters.numeric
},
pointLabels: {
backdropColor: void 0,
backdropPadding: 2,
display: !0,
font: {
size: 10
},
callback(t) {
return t;
},
padding: 5,
centerPointLabels: !1
}
}), w(Me, "defaultRoutes", {
"angleLines.color": "borderColor",
"pointLabels.color": "color",
"ticks.color": "color"
}), w(Me, "descriptors", {
angleLines: {
_fallback: "grid"
}
});
const Li = {
millisecond: {
common: !0,
size: 1,
steps: 1e3
},
second: {
common: !0,
size: 1e3,
steps: 60
},
minute: {
common: !0,
size: 6e4,
steps: 60
},
hour: {
common: !0,
size: 36e5,
steps: 24
},
day: {
common: !0,
size: 864e5,
steps: 30
},
week: {
common: !1,
size: 6048e5,
steps: 4
},
month: {
common: !0,
size: 2628e6,
steps: 12
},
quarter: {
common: !1,
size: 7884e6,
steps: 4
},
year: {
common: !0,
size: 3154e7
}
}, it = /* @__PURE__ */ Object.keys(Li);
function to(i, t) {
return i - t;
}
function eo(i, t) {
if (E(t))
return null;
const e = i._adapter, { parser: s, round: n, isoWeekday: o } = i._parseOpts;
let r = t;
return typeof s == "function" && (r = s(r)), V(r) || (r = typeof s == "string" ? e.parse(r, s) : e.parse(r)), r === null ? null : (n && (r = n === "week" && (ae(o) || o === !0) ? e.startOf(r, "isoWeek", o) : e.startOf(r, n)), +r);
}
function io(i, t, e, s) {
const n = it.length;
for (let o = it.indexOf(i); o < n - 1; ++o) {
const r = Li[it[o]], a = r.steps ? r.steps : Number.MAX_SAFE_INTEGER;
if (r.common && Math.ceil((e - t) / (a * r.size)) <= s)
return it[o];
}
return it[n - 1];
}
function Od(i, t, e, s, n) {
for (let o = it.length - 1; o >= it.indexOf(e); o--) {
const r = it[o];
if (Li[r].common && i._adapter.diff(n, s, r) >= t - 1)
return r;
}
return it[e ? it.indexOf(e) : 0];
}
function Ad(i) {
for (let t = it.indexOf(i) + 1, e = it.length; t < e; ++t)
if (Li[it[t]].common)
return it[t];
}
function so(i, t, e) {
if (!e)
i[t] = !0;
else if (e.length) {
const { lo: s, hi: n } = _s(e, t), o = e[s] >= t ? e[s] : e[n];
i[o] = !0;
}
}
function Td(i, t, e, s) {
const n = i._adapter, o = +n.startOf(t[0].value, s), r = t[t.length - 1].value;
let a, l;
for (a = o; a <= r; a = +n.add(a, 1, s))
l = e[a], l >= 0 && (t[l].major = !0);
return t;
}
function no(i, t, e) {
const s = [], n = {}, o = t.length;
let r, a;
for (r = 0; r < o; ++r)
a = t[r], n[a] = r, s.push({
value: a,
major: !1
});
return o === 0 || !e ? s : Td(i, s, n, e);
}
class $e extends Jt {
constructor(t) {
super(t), this._cache = {
data: [],
labels: [],
all: []
}, this._unit = "day", this._majorUnit = void 0, this._offsets = {}, this._normalized = !1, this._parseOpts = void 0;
}
init(t, e = {}) {
const s = t.time || (t.time = {}), n = this._adapter = new $l._date(t.adapters.date);
n.init(e), Ce(s.displayFormats, n.formats()), this._parseOpts = {
parser: s.parser,
round: s.round,
isoWeekday: s.isoWeekday
}, super.init(t), this._normalized = e.normalized;
}
parse(t, e) {
return t === void 0 ? null : eo(this, t);
}
beforeLayout() {
super.beforeLayout(), this._cache = {
data: [],
labels: [],
all: []
};
}
determineDataLimits() {
const t = this.options, e = this._adapter, s = t.time.unit || "day";
let { min: n, max: o, minDefined: r, maxDefined: a } = this.getUserBounds();
function l(c) {
!r && !isNaN(c.min) && (n = Math.min(n, c.min)), !a && !isNaN(c.max) && (o = Math.max(o, c.max));
}
(!r || !a) && (l(this._getLabelBounds()), (t.bounds !== "ticks" || t.ticks.source !== "labels") && l(this.getMinMax(!1))), n = V(n) && !isNaN(n) ? n : +e.startOf(Date.now(), s), o = V(o) && !isNaN(o) ? o : +e.endOf(Date.now(), s) + 1, this.min = Math.min(n, o - 1), this.max = Math.max(n + 1, o);
}
_getLabelBounds() {
const t = this.getLabelTimestamps();
let e = Number.POSITIVE_INFINITY, s = Number.NEGATIVE_INFINITY;
return t.length && (e = t[0], s = t[t.length - 1]), {
min: e,
max: s
};
}
buildTicks() {
const t = this.options, e = t.time, s = t.ticks, n = s.source === "labels" ? this.getLabelTimestamps() : this._generate();
t.bounds === "ticks" && n.length && (this.min = this._userMin || n[0], this.max = this._userMax || n[n.length - 1]);
const o = this.min, r = this.max, a = ha(n, o, r);
return this._unit = e.unit || (s.autoSkip ? io(e.minUnit, this.min, this.max, this._getLabelCapacity(o)) : Od(this, a.length, e.minUnit, this.min, this.max)), this._majorUnit = !s.major.enabled || this._unit === "year" ? void 0 : Ad(this._unit), this.initOffsets(n), t.reverse && a.reverse(), no(this, a, this._majorUnit);
}
afterAutoSkip() {
this.options.offsetAfterAutoskip && this.initOffsets(this.ticks.map((t) => +t.value));
}
initOffsets(t = []) {
let e = 0, s = 0, n, o;
this.options.offset && t.length && (n = this.getDecimalForValue(t[0]), t.length === 1 ? e = 1 - n : e = (this.getDecimalForValue(t[1]) - n) / 2, o = this.getDecimalForValue(t[t.length - 1]), t.length === 1 ? s = o : s = (o - this.getDecimalForValue(t[t.length - 2])) / 2);
const r = t.length < 3 ? 0.5 : 0.25;
e = K(e, 0, r), s = K(s, 0, r), this._offsets = {
start: e,
end: s,
factor: 1 / (e + 1 + s)
};
}
_generate() {
const t = this._adapter, e = this.min, s = this.max, n = this.options, o = n.time, r = o.unit || io(o.minUnit, e, s, this._getLabelCapacity(e)), a = C(n.ticks.stepSize, 1), l = r === "week" ? o.isoWeekday : !1, c = ae(l) || l === !0, h = {};
let d = e, f, u;
if (c && (d = +t.startOf(d, "isoWeek", l)), d = +t.startOf(d, c ? "day" : r), t.diff(s, e, r) > 1e5 * a)
throw new Error(e + " and " + s + " are too far apart with stepSize of " + a + " " + r);
const g = n.ticks.source === "data" && this.getDataTimestamps();
for (f = d, u = 0; f < s; f = +t.add(f, a, r), u++)
so(h, f, g);
return (f === s || n.bounds === "ticks" || u === 1) && so(h, f, g), Object.keys(h).sort(to).map((p) => +p);
}
getLabelForValue(t) {
const e = this._adapter, s = this.options.time;
return s.tooltipFormat ? e.format(t, s.tooltipFormat) : e.format(t, s.displayFormats.datetime);
}
format(t, e) {
const n = this.options.time.displayFormats, o = this._unit, r = e || n[o];
return this._adapter.format(t, r);
}
_tickFormatFunction(t, e, s, n) {
const o = this.options, r = o.ticks.callback;
if (r)
return F(r, [
t,
e,
s
], this);
const a = o.time.displayFormats, l = this._unit, c = this._majorUnit, h = l && a[l], d = c && a[c], f = s[e], u = c && d && f && f.major;
return this._adapter.format(t, n || (u ? d : h));
}
generateTickLabels(t) {
let e, s, n;
for (e = 0, s = t.length; e < s; ++e)
n = t[e], n.label = this._tickFormatFunction(n.value, e, t);
}
getDecimalForValue(t) {
return t === null ? NaN : (t - this.min) / (this.max - this.min);
}
getPixelForValue(t) {
const e = this._offsets, s = this.getDecimalForValue(t);
return this.getPixelForDecimal((e.start + s) * e.factor);
}
getValueForPixel(t) {
const e = this._offsets, s = this.getDecimalForPixel(t) / e.factor - e.end;
return this.min + s * (this.max - this.min);
}
_getLabelSize(t) {
const e = this.options.ticks, s = this.ctx.measureText(t).width, n = ht(this.isHorizontal() ? e.maxRotation : e.minRotation), o = Math.cos(n), r = Math.sin(n), a = this._resolveTickFontOptions(0).size;
return {
w: s * o + a * r,
h: s * r + a * o
};
}
_getLabelCapacity(t) {
const e = this.options.time, s = e.displayFormats, n = s[e.unit] || s.millisecond, o = this._tickFormatFunction(t, 0, no(this, [
t
], this._majorUnit), n), r = this._getLabelSize(o), a = Math.floor(this.isHorizontal() ? this.width / r.w : this.height / r.h) - 1;
return a > 0 ? a : 1;
}
getDataTimestamps() {
let t = this._cache.data || [], e, s;
if (t.length)
return t;
const n = this.getMatchingVisibleMetas();
if (this._normalized && n.length)
return this._cache.data = n[0].controller.getAllParsedValues(this);
for (e = 0, s = n.length; e < s; ++e)
t = t.concat(n[e].controller.getAllParsedValues(this));
return this._cache.data = this.normalize(t);
}
getLabelTimestamps() {
const t = this._cache.labels || [];
let e, s;
if (t.length)
return t;
const n = this.getLabels();
for (e = 0, s = n.length; e < s; ++e)
t.push(eo(this, n[e]));
return this._cache.labels = this._normalized ? t : this.normalize(t);
}
normalize(t) {
return mo(t.sort(to));
}
}
w($e, "id", "time"), w($e, "defaults", {
bounds: "data",
adapters: {},
time: {
parser: !1,
unit: !1,
round: !1,
isoWeekday: !1,
minUnit: "millisecond",
displayFormats: {}
},
ticks: {
source: "auto",
callback: !1,
major: {
enabled: !1
}
}
});
function ri(i, t, e) {
let s = 0, n = i.length - 1, o, r, a, l;
e ? (t >= i[s].pos && t <= i[n].pos && ({ lo: s, hi: n } = wt(i, "pos", t)), { pos: o, time: a } = i[s], { pos: r, time: l } = i[n]) : (t >= i[s].time && t <= i[n].time && ({ lo: s, hi: n } = wt(i, "time", t)), { time: o, pos: a } = i[s], { time: r, pos: l } = i[n]);
const c = r - o;
return c ? a + (l - a) * (t - o) / c : a;
}
class ds extends $e {
constructor(t) {
super(t), this._table = [], this._minPos = void 0, this._tableRange = void 0;
}
initOffsets() {
const t = this._getTimestampsForTable(), e = this._table = this.buildLookupTable(t);
this._minPos = ri(e, this.min), this._tableRange = ri(e, this.max) - this._minPos, super.initOffsets(t);
}
buildLookupTable(t) {
const { min: e, max: s } = this, n = [], o = [];
let r, a, l, c, h;
for (r = 0, a = t.length; r < a; ++r)
c = t[r], c >= e && c <= s && n.push(c);
if (n.length < 2)
return [
{
time: e,
pos: 0
},
{
time: s,
pos: 1
}
];
for (r = 0, a = n.length; r < a; ++r)
h = n[r + 1], l = n[r - 1], c = n[r], Math.round((h + l) / 2) !== c && o.push({
time: c,
pos: r / (a - 1)
});
return o;
}
_generate() {
const t = this.min, e = this.max;
let s = super.getDataTimestamps();
return (!s.includes(t) || !s.length) && s.splice(0, 0, t), (!s.includes(e) || s.length === 1) && s.push(e), s.sort((n, o) => n - o);
}
_getTimestampsForTable() {
let t = this._cache.all || [];
if (t.length)
return t;
const e = this.getDataTimestamps(), s = this.getLabelTimestamps();
return e.length && s.length ? t = this.normalize(e.concat(s)) : t = e.length ? e : s, t = this._cache.all = t, t;
}
getDecimalForValue(t) {
return (ri(this._table, t) - this._minPos) / this._tableRange;
}
getValueForPixel(t) {
const e = this._offsets, s = this.getDecimalForPixel(t) / e.factor - e.end;
return ri(this._table, s * this._tableRange + this._minPos, !0);
}
}
w(ds, "id", "timeseries"), w(ds, "defaults", $e.defaults);
var Ed = /* @__PURE__ */ Object.freeze({
__proto__: null,
CategoryScale: as,
LinearScale: ls,
LogarithmicScale: cs,
RadialLinearScale: Me,
TimeScale: $e,
TimeSeriesScale: ds
});
const Ld = [
Bl,
gh,
cd,
Ed
];
ct.register(...Ld);
var Rd = Object.defineProperty, Fd = Object.getOwnPropertyDescriptor, Ri = (i, t, e, s) => {
for (var n = s > 1 ? void 0 : s ? Fd(t, e) : t, o = i.length - 1, r; o >= 0; o--)
(r = i[o]) && (n = (s ? r(t, e, n) : r(n)) || n);
return s && n && Rd(t, e, n), n;
};
let he = class extends Rt {
constructor() {
super(...arguments), this.assets = [], this.assetImages = {}, this.totalNetWorth = 0;
}
setPercentChangeColor(i) {
return i ? i > 0 ? "green" : i < 0 ? "red" : "yellow" : "yellow";
}
render() {
return W`
<div class="container">
<div class="scroll-view">
${this.assets.map(
(i, t) => {
var e;
return W`
<div class="asset-grid">
<div>
${(e = this.assetImages[i.symbol]) != null && e.url ? W`<img
class="asset-image"
src="${this.assetImages[i.symbol].url}"
alt="${i.symbol}"
/>` : W`<div class="placeholder">
${i.symbol.includes(":") ? i.symbol.split(":")[1] : i.symbol}
</div>`}
</div>
<div class="middle-content">
<div>
${t + 1}. ${i.symbol}
<span class="yellow">${i.weight}</span>
</div>
<div class="sm-font">${i.name}</div>
</div>
<div class="asset-details">
<div class="${this.setPercentChangeColor(
i.percentChange
)}">${i.percentChange}</div>
<div>$${parseFloat(
i.institution_value.toFixed(2)
)}</div>
</div>
</div>
</div>
`;
}
)}
</div>
</div>
`;
}
};
he.styles = Mt`
.container {
/* margin: 0;
padding: 0; */
display: flex;
align-items: center;
padding: 0 12px;
/* DEBUG */
border: 1px solid #7b7979;
border-radius: 10px;
}
.scroll-view {
display: block;
width: 100%;
/* margin: 0;
padding: 0; */
/* flex: 1; */
max-height: var(--stocklift-sector-asset-height, 25vh);
overflow-y: auto;
/* padding-left: 8px 2px; */
/* margin-top: 8px; */
/* Hide scrollbar for WebKit browsers */
::-webkit-scrollbar {
display: none;
}
/* Hide scrollbar for Firefox */
scrollbar-width: none;
}
.asset-grid {
width: 100%;
font-size: 12px;
display: grid;
grid-template-columns: auto 1fr auto;
align-items: center;
/* padding: 8px; */
border-bottom: 1px solid #ccc;
}
.asset-details {
display: block;
justify-content: space-between;
width: 100%;
text-align: right;
}
.middle-content {
/* text-align: left; */
padding: 0 4px;
margin: 0 8px;
}
.yellow {
color: #f5b800;
}
.red {
color: #ff0000;
}
.green {
color: #00ff00;
}
.sm-font {
font-size: 10px;
color: #666;
}
.asset-image {
display: flex;
align-items: center;
justify-content: center;
width: 25px;
height: 25px;
object-fit: fit;
border-radius: 50%;
/* overflow: hidden; */
/* border: 1px solid #b51d1d; */
}
.placeholder {
display: flex;
align-items: center;
justify-content: center;
width: 25px;
height: 25px;
background-color: var(--stocklift-color-primary, #007bff);
color: white;
border-radius: 50%;
font-size: 8px;
text-align: center;
}
`;
Ri([
X({ type: Array })
], he.prototype, "assets", 2);
Ri([
N()
], he.prototype, "assetImages", 2);
Ri([
N()
], he.prototype, "totalNetWorth", 2);
he = Ri([
Ft("assets-view")
], he);
var zd = Object.defineProperty, Id = Object.getOwnPropertyDescriptor, He = (i, t, e, s) => {
for (var n = s > 1 ? void 0 : s ? Id(t, e) : t, o = i.length - 1, r; o >= 0; o--)
(r = i[o]) && (n = (s ? r(t, e, n) : r(n)) || n);
return s && n && zd(t, e, n), n;
};
let Zt = class extends Rt {
constructor() {
super(...arguments), this.assets = [], this.sectorEntries = [], this.sectors = {}, this.expandedSectors = {};
}
updated(i) {
i.has("assets") && (this.groupAssetsBySector(), this.requestUpdate());
}
groupAssetsBySector() {
const i = {};
this.assets.forEach((t) => {
t.sectors.forEach((e) => {
i[e.sector] || (i[e.sector] = []), i[e.sector].push(t);
});
}), this.sectors = i;
}
toggleSector(i) {
this.expandedSectors = {
...this.expandedSectors,
[i]: !this.expandedSectors[i]
};
}
render() {
return W`
<div class="container">
${Object.keys(this.sectors).map(
(i) => W`
<div class="sector" @click=${() => this.toggleSector(i)}>
<div class="sector-header">
<h3>${Cr(i)}</h3>
<span class="selector">${this.expandedSectors[i] ? "▲" : "▼"}</span>
</div>
<div class="sector-details">
<div class="sector-cell">
<div class="icon ${this.getSectorPercentChange(i).isPositive}">
${this.getSectorPercentChange(i).isPositive === "up" ? "▲" : "▼"}
</div>
<div class="sector-inner">
<div class="value">
${this.getSectorPercent(i)}%
</div>
<div class="value ${this.getSectorPercentChange(i).isPositive}">
${this.getSectorPercentChange(i).value}%
</div>
</div>
</div>
<div class="sector-cell">
<div class="icon ${this.getSectorDollarChange(i).isPositive}">
${this.getSectorDollarChange(i).isPositive === "up" ? "▲" : "▼"}
</div>
<div class="sector-inner"></div>
<div class="value">
${this.getSectorDollarAmount(i)}
<div class="value ${this.getSectorDollarChange(i).isPositive}">
${this.getSectorDollarChange(i).value}
</div>
</div>
</div>
</div>
</div>
<div class="sector-content" ?open=${this.expandedSectors[i]}>
<assets-view .assets=${this.sectors[i]}></assets-view>
</div>
</div>
`
)}
</div>
`;
}
getSectorPercent(i) {
const t = this.getSector(i);
return t == null ? void 0 : t.percent.toFixed(2);
}
getSectorPercentChange(i) {
const t = this.getSector(i), e = (t == null ? void 0 : t.percent_change) || "5";
return e.includes("-") ? { value: e.replace("-", ""), isPositive: "down" } : { value: e, isPositive: "up" };
}
getSectorDollarAmount(i) {
const t = this.getSector(i);
return "$" + (t == null ? void 0 : t.amount.toFixed(2));
}
getSectorDollarChange(i) {
const t = this.getSector(i), e = (t == null ? void 0 : t.total_dollar_change.toFixed(2)) || "$50";
return e.includes("-") ? { value: e.replace("-", ""), isPositive: "down" } : { value: e, isPositive: "up" };
}
getSector(i) {
return this.sectorEntries.find(
(e) => e.sector.includes(i.toLowerCase().replace(" ", "_"))
);
}
};
Zt.styles = Mt`
:host {
display: block;
height: 100%;
overflow: hidden;
}
.container {
display: flex;
flex-direction: column;
overflow-y: auto;
height: 100%;
margin-top: 16px;
/* DEBUG */
/* border: 1px solid purple; */
}
.sector {
background-color: var(--stocklift-color-tertiary, #424141);
color: var(--stocklift-text-color);
border-radius: 10px;
margin-bottom: 8px;
padding: 8px;
cursor: pointer;
width: 100%;
box-sizing: border-box;
border: 1px solid #e3e1e1;
}
.sector-header {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 10px;
/* DEBUG */
/* border: 1px solid green; */
}
.sector-content {
display: none;
margin-top: 8px;
margin-bottom: 8px;
width: 100%;
}
.sector-content[open] {
display: block;
width: 100%;
}
.sector-details {
display: flex;
justify-content: space-between;
margin-top: 8px;
/* DEBUG */
/* border: 1px solid red; */
}
.sector-cell {
display: flex;
flex-direction: row;
justify-content: space-around;
align-items: center;
background-color: var(--stocklift-color-tertiary, #424141);
border-radius: 10px;
border: 1px solid var(--stocklift-color-secondary, #acaaaa);
padding: 8px;
width: 48%;
box-sizing: border-box;
text-align: right;
}
.sector-inner {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.sector-cell .icon {
font-size: 14px;
}
.sector-cell .value {
font-size: 12px;
}
.sector-cell .value.up,
.sector-cell .icon.up {
color: #00ff00;
}
.sector-cell .value.down,
.sector-cell .icon.down {
color: #ff0000;
}
.selector {
font-size: 12px; /* Adjust the font size as needed */
}
`;
He([
X({ type: Array })
], Zt.prototype, "assets", 2);
He([
X({ type: Array })
], Zt.prototype, "sectorEntries", 2);
He([
N()
], Zt.prototype, "sectors", 2);
He([
N()
], Zt.prototype, "expandedSectors", 2);
Zt = He([
Ft("sector-breakdown")
], Zt);
var Bd = Object.defineProperty, $d = Object.getOwnPropertyDescriptor, te = (i, t, e, s) => {
for (var n = s > 1 ? void 0 : s ? $d(t, e) : t, o = i.length - 1, r; o >= 0; o--)
(r = i[o]) && (n = (s ? r(t, e, n) : r(n)) || n);
return s && n && Bd(t, e, n), n;
};
let St = class extends Rt {
constructor() {
super(...arguments), this.title = "Sector Diversification", this.sectors = [], this.assets = [], this.assetImages = {}, this.totalNetWorth = 0, this.showBreakdown = !1, this.chart = null;
}
firstUpdated() {
this.updateChartContainerSize(), this.renderChart();
}
updated(i) {
i.has("sectors") && this.renderChart(), this.updateChartContainerSize();
}
updateChartContainerSize() {
this.style.setProperty(
"--stocklift-sector-chart-height",
this.style.height || "25vh",
"!important"
);
}
sortSectors() {
return this.sectors.sort((i, t) => t.percent - i.percent);
}
renderChart() {
requestAnimationFrame(() => {
var t;
const i = (t = this.shadowRoot) == null ? void 0 : t.querySelector(
"#sectorChart"
);
i && (this.chart && this.chart.destroy(), this.chart = new ct(i, {
type: "doughnut",
data: {
datasets: [
{
data: this.sectors.map((e) => Math.round(e.percent)),
backgroundColor: this.sectors.map((e) => e.color)
}
]
},
options: {
responsive: !0,
maintainAspectRatio: !1,
rotation: 0,
circumference: 180,
animation: !1,
animations: {
colors: !1,
x: !1
}
}
}));
});
}
toggleBreakdown() {
this.showBreakdown = !this.showBreakdown, this.showBreakdown || this.renderChart();
}
render() {
return W`
<div class="container">
<h6 class="title">${this.title}</h6>
${this.showBreakdown ? W`
<div class="sector-breakdown-container">
<sector-breakdown
.assets=${this.assets}
.sectorEntries=${this.sectors}
></sector-breakdown>
</div>
` : W`
<div class="content">
<div class="chart-container">
<canvas id="sectorChart"></canvas>
</div>
<div class="scroll-view">
${this.sortSectors().map(
(i) => W`
<div class="sector-item">
<div
class="bullet"
style="background-color: ${i.color};"
></div>
<div class="sector-name">
<div>${parseFloat(i.percent.toFixed(2))}%</div>
<div>${Pr(i)}</div>
</div>
</div>
`
)}
</div>
</div>
`}
<div class="view-breakdown" @click=${this.toggleBreakdown}>
${this.showBreakdown ? "View Chart" : "View Breakdown"}
</div>
</div>
`;
}
};
St.styles = [
// sharedStyles,
Mt`
:host {
display: block;
position: relative;
box-sizing: border-box;
height: 100%;
overflow: hidden;
--stocklift-background-color: #2d2c2c;
--stocklift-button-color: #4089e9;
--stocklift-button-hover-color: #146ada;
--chart-container-height: 30vh;
--asset-container-height: 28vh;
--stocklift-chart-height: 200px;
--stocklift-height: 45vh;
--stocklift-width: 45vh;
height: var(--stocklift-height);
width: var(--stocklift-width);
/* DEBUG */
/* border: 1px solid white; */
}
.container {
display: flex;
flex-direction: column;
align-items: center;
padding: 0 16px;
height: 100%;
overflow: hidden;
/* DEBUG */
/* border: 1px solid red; */
}
.title {
color: var(--stocklift-text-color, #fbfbfb);
font-weight: 400;
text-align: center;
margin: 0;
padding: 0;
position: absolute;
top: 0;
padding: 4px;
margin-bottom: 8px;
}
.sector-breakdown-container {
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
margin-top: 22px;
overflow-y: auto;
overflow-x: hidden;
}
.content {
display: flex;
justify-content: space-between;
height: var(--stocklift-sector-chart-height, 25vh);
width: 100%;
margin-top: 22px;
padding: 16px 0;
}
.chart-container {
flex: 1;
position: relative;
/* height: var(--stocklift-sector-chart-height, 25vh);
width: var(--chart-container-width, 25vh); */
overflow: hidden;
/* Debug */
/* border: 1px solid red; */
}
.scroll-view {
flex: 1;
max-height: 200px;
overflow-y: auto;
padding: 0 16px;
}
.sector-item {
display: flex;
align-items: center;
padding: 4px;
margin-bottom: 8px;
border-radius: 8px;
background-color: #c0b9b9;
cursor: pointer;
font-size: 10px;
}
.sector-item .bullet {
width: 12px;
height: 12px;
border-radius: 50%;
margin-right: 8px;
}
.sector-name {
color: #000;
display: flex;
align-items: center;
justify-content: space-between;
flex: 1;
}
.view-breakdown {
margin-top: 12px;
font-size: 12px;
color: var(--stocklift-text-color, #fbfbfb);
cursor: pointer;
/* position: absolute;
bottom: 0; */
/* DEBUG */
/* border: 1px solid red; */
}
.view-breakdown:hover {
text-decoration: underline;
}
/* Media query for mobile optimization */
@media (max-width: 600px) {
:host {
--stocklift-height: 80vh;
--stocklift-width: 90vw;
height: var(--stocklift-height);
width: var(--stocklift-width);
}
.content {
height: var(--stocklift-sector-chart-height, 24vh);
/* flex-direction: column;
height: auto; */
}
/* .chart-container {
width: 100%;
height: auto;
} */
.sector-item {
font-size: 12px; /* Increase font size for better readability on mobile */
}
.view-breakdown {
font-size: 14px; /* Increase font size for better readability on mobile */
}
}
`
];
te([
X({ type: String })
], St.prototype, "title", 2);
te([
X({ type: Array })
], St.prototype, "sectors", 2);
te([
X({ type: Array })
], St.prototype, "assets", 2);
te([
N()
], St.prototype, "assetImages", 2);
te([
X({ type: Number })
], St.prototype, "totalNetWorth", 2);
te([
N()
], St.prototype, "showBreakdown", 2);
St = te([
Ft("sl-sector-diversification")
], St);
var jd = Object.defineProperty, Wd = Object.getOwnPropertyDescriptor, Ue = (i, t, e, s) => {
for (var n = s > 1 ? void 0 : s ? Wd(t, e) : t, o = i.length - 1, r; o >= 0; o--)
(r = i[o]) && (n = (s ? r(t, e, n) : r(n)) || n);
return s && n && jd(t, e, n), n;
};
let Qt = class extends Rt {
constructor() {
super(...arguments), this.title = "Top Holdings", this.assets = [], this.assetImages = {}, this.sortByWeight = !0;
}
toggleSortByWeight() {
this.sortByWeight = !this.sortByWeight, this.sortAssets();
}
sortAssets() {
this.sortByWeight ? this.assets = [...this.assets].sort(
(i, t) => (t.weight ?? 0) - (i.weight ?? 0)
) : this.assets = [...this.assets].sort(
(i, t) => (t.percentChange ?? 0) - (i.percentChange ?? 0)
);
}
toggleSort() {
this.assets = this.sortByWeight ? this.assets.sort((i, t) => (t.weight ?? 0) - (i.weight ?? 0)) : this.assets.sort(
(i, t) => (t.percentChange ?? 0) - (i.percentChange ?? 0)
), this.sortByWeight = !this.sortByWeight;
}
render() {
return W`
<div class="container">
<h6 class="title">${this.title}</h6>
<button class="app-button" @click=${this.toggleSortByWeight}>
${this.sortByWeight ? "Performance" : "Weight"}
</button>
<assets-view
class="asset-container"
.assets="${this.assets}"
.assetImages="${this.assetImages}"
></assets-view>
</div>
`;
}
};
Qt.styles = [
Di,
Mt`
:host {
display: block;
box-sizing: border-box;
height: 100%;
position: relative;
}
.container {
display: flex;
flex-direction: column;
align-items: center;
width: 100%;
height: 100%;
}
.asset-container {
width: 100%;
height: 100%;
margin-top: 12px;
overflow-y: auto;
}
.title {
color: var(--stocklift-text-color, #fbfbfb);
font-weight: 400;
text-align: center;
margin: 0;
padding: 0;
position: absolute;
top: 0;
left: 0;
right: 0;
padding: 4px;
margin-bottom: 8px;
}
.app-button {
margin-top: 26px;
}
/* Media Queries for Mobile Optimization */
@media (max-width: 768px) {
.title {
font-size: 16px; /* Adjust title font size for small screens */
}
.app-button {
margin-top: 34px; /* Adjust button margin for small screens */
font-size: 14px; /* Adjust button font size for small screens */
padding: 8px 16px; /* Adjust button padding for small screens */
}
}
`
];
Ue([
X({ type: String })
], Qt.prototype, "title", 2);
Ue([
N()
], Qt.prototype, "assets", 2);
Ue([
N()
], Qt.prototype, "assetImages", 2);
Ue([
N()
], Qt.prototype, "sortByWeight", 2);
Qt = Ue([
Ft("sl-top-holdings")
], Qt);
var Nd = Object.defineProperty, Vd = Object.getOwnPropertyDescriptor, Fi = (i, t, e, s) => {
for (var n = s > 1 ? void 0 : s ? Vd(t, e) : t, o = i.length - 1, r; o >= 0; o--)
(r = i[o]) && (n = (s ? r(t, e, n) : r(n)) || n);
return s && n && Nd(t, e, n), n;
};
let de = class extends Rt {
constructor() {
super(...arguments), this.title = "My Portfolio vs. S&P 500", this.portfolioData = [], this.sp500Data = [], this.chart = null;
}
firstUpdated() {
this.renderChart();
}
updated(i) {
(i.has("portfolioData") || i.has("sp500Data")) && this.renderChart();
}
renderChart() {
var t;
const i = (t = this.shadowRoot) == null ? void 0 : t.querySelector(
"#benchmarkChart"
);
i && (this.chart && this.chart.destroy(), this.chart = new ct(i, {
type: "bar",
data: {
labels: this.portfolioData.map((e) => {
const s = new Date(e.date);
return `${s.getMonth() + 1}/${s.getDate()}`;
}),
datasets: [
{
type: "line",
data: this.portfolioData.map((e) => e.total),
borderColor: "#007bff",
backgroundColor: "rgba(0, 123, 255, 0.2)",
fill: !1
},
{
type: "bar",
data: this.sp500Data.map((e) => e.value),
backgroundColor: "#c6ff63",
yAxisID: "xAxis"
}
]
},
options: {
responsive: !0,
maintainAspectRatio: !1,
scales: {
y: {
beginAtZero: !0,
type: "linear",
position: "left",
grid: {
drawOnChartArea: !0
},
ticks: {
display: !1
// Hide the y-axis ticks and labels
}
}
},
plugins: {
legend: {
display: !1
}
}
}
}));
}
render() {
return W`
<div class="container">
<h6 class="title">${this.title}</h6>
<div class="chart-container">
<canvas id="benchmarkChart"></canvas>
</div>
<div class="legend-container">
<div class="legend-item">
<div class="bullet" style="background-color: #007bff;"></div>
<div>My Portfolio</div>
</div>
<div class="legend-item">
<div class="bullet" style="background-color: #eaff63;"></div>
<div>S&P 500</div>
</div>
</div>
</div>
`;
}
};
de.styles = [
Di,
Mt`
:host {
display: block;
box-sizing: border-box;
height: 100%;
position: relative;
}
.container {
display: flex;
flex-direction: column;
align-items: center;
padding: 0 16px;
}
.title {
color: var(--stocklift-text-color, #fbfbfb);
font-weight: 400;
text-align: center;
margin: 0;
padding: 0;
position: absolute;
top: 0;
padding: 4px;
margin-bottom: 8px;
}
.chart-container {
width: 100%;
max-width: 380px;
height: var(--stocklift-chart-height, 200px);
margin-top: 2.5rem;
/* DEBUG */
/* border: 1px solid red; */
}
.legend-container {
display: flex;
justify-content: center;
margin-top: 8px;
}
.legend-item {
display: flex;
align-items: center;
padding: 4px 8px;
margin: 0 8px;
border-radius: 16px;
background-color: var(--stocklift-color-tertiary, #424141);
font-size: 10px;
}
.legend-item .bullet {
width: 12px;
height: 12px;
border-radius: 50%;
margin-right: 8px;
}
/* Media Queries for Mobile Optimization */
@media (max-width: 768px) {
.chart-container {
--stocklift-chart-height: 200px;
}
.title {
font-size: 16px; /* Adjust title font size for small screens */
}
}
`
];
Fi([
X({ type: String })
], de.prototype, "title", 2);
Fi([
X({ type: Array })
], de.prototype, "portfolioData", 2);
Fi([
X({ type: Array })
], de.prototype, "sp500Data", 2);
de = Fi([
Ft("sl-sp500-benchmark")
], de);
var Hd = Object.defineProperty, Ud = Object.getOwnPropertyDescriptor, Ts = (i, t, e, s) => {
for (var n = s > 1 ? void 0 : s ? Ud(t, e) : t, o = i.length - 1, r; o >= 0; o--)
(r = i[o]) && (n = (s ? r(t, e, n) : r(n)) || n);
return s && n && Hd(t, e, n), n;
};
let je = class extends Rt {
constructor() {
super(...arguments), this.title = "Growth Projections", this.growthProjections = [], this.chart = null;
}
firstUpdated() {
this.renderChart();
}
updated(i) {
i.has("growthProjections") && this.renderChart();
}
renderChart() {
var t;
const i = (t = this.shadowRoot) == null ? void 0 : t.querySelector(
"#lineChart"
);
i && (this.chart && this.chart.destroy(), this.chart = new ct(i, {
type: "line",
data: {
labels: this.growthProjections.map((e) => e.year),
datasets: [
{
// label: "Growth Projections",
data: this.growthProjections.map((e) => e.amount),
borderColor: "#007bff",
backgroundColor: "rgba(0, 123, 255, 0.2)",
fill: !0
}
]
},
options: {
responsive: !0,
maintainAspectRatio: !1,
plugins: {
legend: {
display: !1
},
tooltip: {
callbacks: {
label: (e) => {
const s = e.raw;
return console.log("VALUE", s), new Intl.NumberFormat("en-US", {
style: "currency",
currency: "USD"
// You can dynamically set this based on user preference or data
}).format(s);
}
}
}
}
}
}));
}
render() {
return W`
<div class="container">
<h6 class="title">${this.title}</h6>
<div class="chart-container">
<canvas id="lineChart"></canvas>
</div>
</div>
`;
}
};
je.styles = [
Mt`
:host {
display: block;
box-sizing: border-box;
height: 100%;
position: relative;
}
.container {
display: flex;
flex-direction: column;
align-items: center;
padding: 0 16px;
}
.title {
color: var(--stocklift-text-color, #fbfbfb);
font-weight: 400;
text-align: center;
margin: 0;
padding: 0;
position: absolute;
top: 0;
left: 0;
right: 0;
padding: 4px;
margin-bottom: 8px;
}
.chart-container {
width: 100%;
max-width: 380px;
height: var(--stocklift-chart-height, 200px);
margin-top: 3rem;
padding: 1em;
}
/* Media Queries for Mobile Optimization */
@media (max-width: 768px) {
.chart-container {
max-width: 100%; /* Adjust chart container to full width on small screens */
height: var(
--stocklift-chart-height,
250px
); /* Adjust chart height for small screens */
}
.title {
font-size: 16px; /* Adjust title font size for small screens */
}
}
`
];
Ts([
X({ type: String })
], je.prototype, "title", 2);
Ts([
X({ type: Array })
], je.prototype, "growthProjections", 2);
je = Ts([
Ft("sl-projections")
], je);
var Yd = Object.defineProperty, Xd = Object.getOwnPropertyDescriptor, nr = (i) => {
throw TypeError(i);
}, rt = (i, t, e, s) => {
for (var n = s > 1 ? void 0 : s ? Xd(t, e) : t, o = i.length - 1, r; o >= 0; o--)
(r = i[o]) && (n = (s ? r(t, e, n) : r(n)) || n);
return s && n && Yd(t, e, n), n;
}, Kd = (i, t, e) => t.has(i) || nr("Cannot " + e), qd = (i, t, e) => t.has(i) ? nr("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(i) : t.set(i, e), oo = (i, t, e) => (Kd(i, t, "access private method"), e), bi, or, rr;
let tt = class extends Rt {
constructor() {
super(...arguments), qd(this, bi), this.config = null, this.netWorth = "...loading", this.returnOnInvestment = "...loading", this.changeFromLastClose = "...loading", this.diversificationScore = "...loading", this.assetImages = {}, this.totalHoldings = [], this.sectorDiversification = [], this.myChart = [], this.sp500 = [], this.growthProjections = [], this.currentIndex = 0, this.initalized = !1;
}
firstUpdated() {
this.initalized || (this.initalized = !0, this.validateProperties() ? (this.initializePlaid(), this.getPortfolio(), this.getBenchmark()) : console.error("Missing required properties"));
}
validateProperties() {
return this.config && this.config.accessToken && this.config.companyName && this.config.client.uuid;
}
// @ts-ignore
async initializePlaid() {
var e;
if (this.plaidHandler)
return;
const i = await this.getPlaidLinkToken();
if (!i) {
console.error("Error fetching Plaid Link Token");
return;
}
const t = ((e = this.config) == null ? void 0 : e.client) || null;
if (!t || !t.uuid)
throw new Error("Missing client data");
this.plaidHandler = Plaid.create({
token: i,
onSuccess: (s, n) => {
this.plaidExchanageToken(
s,
n.institution.name,
n.institution.institution_id,
n.accounts,
t
);
},
onExit: (s, n) => {
s != null && console.error("Plaid Link error:", s), console.log("Plaid Link exit:", n);
}
});
}
openPlaidLink() {
if (!this.plaidHandler) {
console.error("Plaid handler not initialized");
return;
}
this.plaidHandler.open();
}
/**
*
* * Exchange the Plaid public token for an access token
*
* @param publicToken
* @param institutionName
* @param institutionId
* @param accounts
* @param client
* @returns
*/
async plaidExchanageToken(i, t, e, s, n) {
var l;
if (!((l = this.config) != null && l.accessToken))
throw new Error("Missing access token");
const o = `${se}/plaid/token`, r = await fetch(o, {
method: "POST",
headers: {
Authorization: `Bearer ${this.config.accessToken}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
publicToken: i,
institutionName: t,
institutionId: e,
accounts: s,
client: n
})
});
if (!r.ok)
throw new Error(`HTTP error! status: ${r.status}`);
return await r.json();
}
/**
* * Fetch the Plaid Link token from the StockLift API
* @returns
*
* /plaid/token?companyName=string&clientName=string&clientEmail=string&clientId=string
*/
async getPlaidLinkToken() {
var i;
try {
if (!((i = this.config) != null && i.accessToken))
throw new Error("Missing access token");
const t = new URLSearchParams({
companyName: this.config.companyName
}), e = `${se}/plaid/token?${t.toString()}`, s = await fetch(e, {
headers: {
Authorization: `Bearer ${this.config.accessToken}`
}
});
if (!s.ok)
throw new Error(`HTTP error! status: ${s.status}`);
return (await s.json()).link_token;
} catch (t) {
console.error("Error fetching Plaid Link Token:", t);
}
}
/**
* * Fetch the Geo Diversification data from the StockLift API
* Map Data
*
* /portfolio/geo_diversification/:clientId
*/
async getGeoDiversification() {
var i;
try {
if (!((i = this.config) != null && i.accessToken))
throw new Error("Missing access token");
const t = await fetch(
`${se}/portfolio/geo_diversification/${this.config.client.uuid}`,
{
method: "GET",
headers: {
Authorization: `Bearer ${this.config.accessToken}`,
"Content-Type": "application/json"
}
}
);
if (!t.ok)
throw new Error(`HTTP error! status: ${t.status}`);
const e = await t.json();
console.log("Geo Diversification Data:", e);
} catch (t) {
console.error("Error fetching data:", t);
}
}
/**
* * Fetch the Asset Images data from the StockLift API
*/
async getAssetImages() {
const i = this.totalHoldings.map((t) => t.symbol);
try {
i.forEach(async (t) => {
var n;
if (!((n = this.config) != null && n.accessToken))
throw new Error("Missing access token");
const e = await fetch(
`${se}/portfolio/image/${t}`,
{
method: "GET",
headers: {
Authorization: `Bearer ${this.config.accessToken}`,
"Content-Type": "application/json"
}
}
);
if (!e.ok)
throw new Error(`HTTP error! status: ${e.status}`);
const s = await e.json();
this.assetImages[t] = s;
});
} catch (t) {
console.error("Error fetching data:", t);
}
}
/**
* * Fetch the benchmark data from the StockLift API
*
* /portfolio/benchmark/:clientId
*/
async getBenchmark() {
var i;
try {
if (!((i = this.config) != null && i.accessToken))
throw new Error("Missing access token");
const t = await fetch(
`${se}/portfolio/benchmark/${this.config.client.uuid}`,
{
method: "GET",
headers: {
Authorization: `Bearer ${this.config.accessToken}`,
"Content-Type": "application/json"
}
}
);
if (!t.ok)
throw new Error(`HTTP error! status: ${t.status}`);
const e = await t.json(), s = e.portfolio_change;
this.changeFromLastClose = s ? s + "%" : "$";
const n = e.my_chart, o = e.sp_500;
this.myChart = n || [], this.sp500 = o || [];
} catch (t) {
console.error("Error fetching data:", t);
}
}
/**
* * Fetch the portfolio data from the StockLift API
*
* /portfolio/:clientId
*/
async getPortfolio() {
var i;
try {
if (!((i = this.config) != null && i.accessToken))
throw new Error("Missing access token");
const t = await fetch(
`${se}/portfolio/${this.config.client.uuid}`,
{
method: "GET",
headers: {
Authorization: `Bearer ${this.config.accessToken}`,
"Content-Type": "application/json"
}
}
);
if (!t.ok)
throw new Error(`HTTP error! status: ${t.status}`);
const e = await t.json(), s = e.data.current_net_worth, n = e.data.return_on_investment, o = e.data.diversification_score, r = new Intl.NumberFormat(navigator.language, {
style: "currency",
currency: "USD"
// set dynamically
}).format(s);
this.netWorth = s ? r : "$", this.returnOnInvestment = n ? n + "%" : "$", this.diversificationScore = o || "$";
let a = e.data.sector_totals;
a = a.map((h, d) => ({
...h,
color: vr[d]
})), this.sectorDiversification = a || [];
const l = e.data.total_growth_amount;
this.growthProjections = l || [];
let c = e.data.total_holdings;
c = c.map((h) => ({
...h,
percentChange: kr(h),
weight: wr(h, s)
})), this.totalHoldings = c || [], this.getAssetImages();
} catch (t) {
console.error("Error fetching data:", t);
}
}
get views() {
return [
W`
<sl-summary
.netWorth="${this.netWorth}"
.returnOnInvestment="${this.returnOnInvestment}"
.changeFromLastClose="${this.changeFromLastClose}"
.diversificationScore="${parseFloat(this.diversificationScore)}"
></sl-summary>
`,
W`
<sl-sector-diversification
.sectors="${this.sectorDiversification}"
.assets="${this.totalHoldings}"
.assetImages="${this.assetImages}"
></sl-sector-diversification>
`,
// html`
// <sl-geo-diversification
// .assets="${this.totalHoldings}"
// .assetImages="${this.assetImages}"
// ></sl-geo-diversification>
// `,
W`
<sl-top-holdings
.assets="${this.totalHoldings}"
.assetImages="${this.assetImages}"
></sl-top-holdings>
`,
W`
<sl-sp500-benchmark
.portfolioData="${this.myChart}"
.sp500Data="${this.sp500}"
></sl-sp500-benchmark>
`,
W`
<sl-projections
.growthProjections="${this.growthProjections}"
></sl-projections>
`
];
}
render() {
return this.validateProperties() ? W`
<div class="base">
<!-- CHART VIEWS -->
${this.views[this.currentIndex]}
<!-- FOOTER BUTTONS - (Next, Back & Link Account) -->
<footer class="controls">
<!-- BACK Button -->
<button
class="control-button ${this.currentIndex > 0 ? "visible" : ""}"
@click=${oo(this, bi, rr)}
>
←
</button>
<!-- CONNECT ACCOUNT - Plaid Button -->
<button class="app-button" @click=${this.openPlaidLink}>
Connect Account
</button>
<!-- NEXT Button -->
<button
class="control-button ${this.currentIndex < this.views.length - 1 ? "visible" : ""}"
@click=${oo(this, bi, or)}
>
→
</button>
</footer>
</div>
` : W`
<div>
<p>Missing required properties</p>
</div>
`;
}
};
bi = /* @__PURE__ */ new WeakSet();
or = function() {
this.currentIndex < this.views.length - 1 && this.currentIndex++;
};
rr = function() {
this.currentIndex > 0 && this.currentIndex--;
};
tt.styles = [
Di,
Mt`
:host {
display: block;
position: relative;
box-sizing: border-box;
line-height: 1.5;
/* FONT */
font-family: var(--stocklift-font-family, "Arial", sans-serif);
/* COLORS */
color: var(--stocklift-text-color, #f6f6f6);
background-color: var(--stocklift-background-color, #2d2c2c);
--stocklift-background-color: #2d2c2c;
--stocklift-button-color: #4089e9;
--stocklift-button-hover-color: #146ada;
/* FRAMES */
--chart-container-height: 30vh;
--asset-container-height: 28vh;
--stocklift-chart-height: 200px;
--stocklift-height: 45vh;
--stocklift-width: 45vh;
height: var(--stocklift-height);
width: var(--stocklift-width);
/* BORDER */
--stocklift-border-radius: 22px;
border: var(--stocklift-border, 0.5px solid grey);
border-radius: var(--stocklift-border-radius, 8px);
}
footer {
border-radius: var(--stocklift-border-radius, 8px);
}
.base {
display: flex;
flex-direction: column;
justify-content: center;
height: 80%;
width: 100%;
}
.controls {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.5em 1em 1em;
position: absolute;
bottom: 0;
left: 0;
right: 0;
background-color: var(--stocklift-background-color);
}
.control-button {
background-color: var(--stocklift-button-color);
color: white;
padding: 8px;
cursor: pointer;
border-radius: 50%;
font-size: 10px;
border: none;
visibility: hidden; /* Hide by default */
}
.control-button.visible {
visibility: visible; /* Show when the class is added */
}
.app-button {
margin: 0 auto; /* Center the button */
}
/* Media Queries for Mobile Optimization */
@media (max-width: 768px) {
:host {
--stocklift-height: 40vh;
--stocklift-width: 90vw;
}
.control-button {
font-size: 12px;
padding: 10px;
}
.base {
height: 100%;
}
}
`
];
rt([
X({ type: Object })
], tt.prototype, "config", 2);
rt([
N()
], tt.prototype, "netWorth", 2);
rt([
N()
], tt.prototype, "returnOnInvestment", 2);
rt([
N()
], tt.prototype, "changeFromLastClose", 2);
rt([
N()
], tt.prototype, "diversificationScore", 2);
rt([
N()
], tt.prototype, "assetImages", 2);
rt([
N()
], tt.prototype, "totalHoldings", 2);
rt([
N()
], tt.prototype, "sectorDiversification", 2);
rt([
N()
], tt.prototype, "myChart", 2);
rt([
N()
], tt.prototype, "sp500", 2);
rt([
N()
], tt.prototype, "growthProjections", 2);
rt([
N()
], tt.prototype, "currentIndex", 2);
tt = rt([
Ft("stocklift-charts")
], tt);
export {
tt as StockLiftCharts
};