"use strict";
(self.webpackChunk_N_E = self.webpackChunk_N_E || []).push([
[8193], {
60274: function(t, e, i) {
i.d(e, {
FK: function() {
return Animations
},
W_: function() {
return Element
},
ce: function() {
return s.d
},
kL: function() {
return Chart
},
zX: function() {
return R
}
});
var s = i(71041),
a = new
class {
constructor() {
this._request = null, this._charts = new Map, this._running = !1, this._lastDate = void 0
}
_notify(t, e, i, s) {
let a = e.listeners[s],
r = e.duration;
a.forEach(s => s({
chart: t,
initial: e.initial,
numSteps: r,
currentStep: Math.min(i - e.start, r)
}))
}
_refresh() {
this._request || (this._running = !0, this._request = s.r.call(window, () => {
this._update(), this._request = null, this._running && this._refresh()
}))
}
_update(t = Date.now()) {
let e = 0;
this._charts.forEach((i, s) => {
let a;
if (!i.running || !i.items.length) return;
let r = i.items,
n = r.length - 1,
o = !1;
for (; n >= 0; --n)(a = r[n])._active ? (a._total > i.duration && (i.duration = a._total), a.tick(t), o = !0) : (r[n] = r[r.length - 1], r.pop());
o && (s.draw(), this._notify(s, i, t, "progress")), r.length || (i.running = !1, this._notify(s, i, t, "complete"), i.initial = !1), e += r.length
}), this._lastDate = t, 0 === e && (this._running = !1)
}
_getAnims(t) {
let e = this._charts,
i = e.get(t);
return i || (i = {
running: !1,
initial: !0,
items: [],
listeners: {
complete: [],
progress: []
}
}, e.set(t, i)), i
}
listen(t, e, i) {
this._getAnims(t).listeners[e].push(i)
}
add(t, e) {
e && e.length && this._getAnims(t).items.push(...e)
}
has(t) {
return this._getAnims(t).items.length > 0
}
start(t) {
let e = this._charts.get(t);
e && (e.running = !0, e.start = Date.now(), e.duration = e.items.reduce((t, e) => Math.max(t, e._duration), 0), this._refresh())
}
running(t) {
if (!this._running) return !1;
let e = this._charts.get(t);
return !!e && !!e.running && !!e.items.length
}
stop(t) {
let e = this._charts.get(t);
if (!e || !e.items.length) return;
let i = e.items,
s = i.length - 1;
for (; s >= 0; --s) i[s].cancel();
e.items = [], this._notify(t, e, Date.now(), "complete")
}
remove(t) {
return this._charts.delete(t)
}
};
let r = "transparent",
n = {
boolean: (t, e, i) => i > .5 ? e : t,
color(t, e, i) {
let a = (0, s.c)(t || r),
n = a.valid && (0, s.c)(e || r);
return n && n.valid ? n.mix(a, i).hexString() : e
},
number: (t, e, i) => t + (e - t) * i
};
let Animation = class Animation {
constructor(t, e, i, a) {
let r = e[i];
a = (0, s.a)([t.to, a, r, t.from]);
let o = (0, s.a)([t.from, r, a]);
this._active = !0, this._fn = t.fn || n[t.type || typeof o], this._easing = s.e[t.easing] || s.e.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 = i, this._from = o, this._to = a, this._promises = void 0
}
active() {
return this._active
}
update(t, e, i) {
if (this._active) {
this._notify(!1);
let a = this._target[this._prop],
r = i - this._start,
n = this._duration - r;
this._start = i, this._duration = Math.floor(Math.max(n, t.duration)), this._total += r, this._loop = !!t.loop, this._to = (0, s.a)([t.to, e, a, t.from]), this._from = (0, s.a)([t.from, a, e])
}
}
cancel() {
this._active && (this.tick(Date.now()), this._active = !1, this._notify(!1))
}
tick(t) {
let e;
let i = t - this._start,
s = this._duration,
a = this._prop,
r = this._from,
n = this._loop,
o = this._to;
if (this._active = r !== o && (n || i < s), !this._active) {
this._target[a] = o, this._notify(!0);
return
}
if (i < 0) {
this._target[a] = r;
return
}
e = i / s % 2, e = n && e > 1 ? 2 - e : e, e = this._easing(Math.min(1, Math.max(0, e))), this._target[a] = this._fn(r, o, e)
}
wait() {
let t = this._promises || (this._promises = []);
return new Promise((e, i) => {
t.push({
res: e,
rej: i
})
})
}
_notify(t) {
let e = t ? "res" : "rej",
i = this._promises || [];
for (let t = 0; t < i.length; t++) i[t][e]()
}
};
s.d.set("animation", {
delay: void 0,
duration: 1e3,
easing: "easeOutQuart",
fn: void 0,
from: void 0,
loop: void 0,
to: void 0,
type: void 0
});
let o = Object.keys(s.d.animation);
s.d.describe("animation", {
_fallback: !1,
_indexable: !1,
_scriptable: t => "onProgress" !== t && "onComplete" !== t && "fn" !== t
}), s.d.set("animations", {
colors: {
type: "color",
properties: ["color", "borderColor", "backgroundColor"]
},
numbers: {
type: "number",
properties: ["x", "y", "borderWidth", "radius", "tension"]
}
}), s.d.describe("animations", {
_fallback: "animation"
}), s.d.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 => 0 | t
}
}
}
});
let Animations = class Animations {
constructor(t, e) {
this._chart = t, this._properties = new Map, this.configure(e)
}
configure(t) {
if (!(0, s.i)(t)) return;
let e = this._properties;
Object.getOwnPropertyNames(t).forEach(i => {
let a = t[i];
if (!(0, s.i)(a)) return;
let r = {};
for (let t of o) r[t] = a[t];
((0, s.b)(a.properties) && a.properties || [i]).forEach(t => {
t !== i && e.has(t) || e.set(t, r)
})
})
}
_animateOptions(t, e) {
let i = e.options,
s = function(t, e) {
if (!e) return;
let i = t.options;
if (!i) {
t.options = e;
return
}
return i.$shared && (t.options = i = Object.assign({}, i, {
$shared: !1,
$animations: {}
})), i
}(t, i);
if (!s) return [];
let a = this._createAnimations(s, i);
return i.$shared && (function(t, e) {
let i = [],
s = Object.keys(e);
for (let e = 0; e < s.length; e++) {
let a = t[s[e]];
a && a.active() && i.push(a.wait())
}
return Promise.all(i)
})(t.options.$animations, i).then(() => {
t.options = i
}, () => {}), a
}
_createAnimations(t, e) {
let i;
let s = this._properties,
a = [],
r = t.$animations || (t.$animations = {}),
n = Object.keys(e),
o = Date.now();
for (i = n.length - 1; i >= 0; --i) {
let l = n[i];
if ("$" === l.charAt(0)) continue;
if ("options" === l) {
a.push(...this._animateOptions(t, e));
continue
}
let h = e[l],
d = r[l],
c = s.get(l);
if (d) {
if (c && d.active()) {
d.update(c, h, o);
continue
}
d.cancel()
}
if (!c || !c.duration) {
t[l] = h;
continue
}
r[l] = d = new Animation(c, t, l, h), a.push(d)
}
return a
}
update(t, e) {
if (0 === this._properties.size) {
Object.assign(t, e);
return
}
let i = this._createAnimations(t, e);
if (i.length) return a.add(this._chart, i), !0
}
};
function scaleClip(t, e) {
let i = t && t.options || {},
s = i.reverse,
a = void 0 === i.min ? e : 0,
r = void 0 === i.max ? e : 0;
return {
start: s ? r : a,
end: s ? a : r
}
}
function getSortedDatasetIndices(t, e) {
let i, s;
let a = [],
r = t._getSortedDatasetMetas(e);
for (i = 0, s = r.length; i < s; ++i) a.push(r[i].index);
return a
}
function applyStack(t, e, i, a = {}) {
let r, n, o, l;
let h = t.keys,
d = "single" === a.mode;
if (null !== e) {
for (r = 0, n = h.length; r < n; ++r) {
if ((o = +h[r]) === i) {
if (a.all) continue;
break
}
l = t.values[o], (0, s.g)(l) && (d || 0 === e || (0, s.s)(e) === (0, s.s)(l)) && (e += l)
}
return e
}
}
function isStacked(t, e) {
let i = t && t.options.stacked;
return i || void 0 === i && void 0 !== e.stack
}
function getLastIndexInStack(t, e, i, s) {
for (let a of e.getMatchingVisibleMetas(s).reverse()) {
let e = t[a.index];
if (i && e > 0 || !i && e < 0) return a.index
}
return null
}
function updateStacks(t, e) {
let i;
let {
chart: s,
_cachedMeta: a
} = t, r = s._stacks || (s._stacks = {}), {
iScale: n,
vScale: o,
index: l
} = a, h = n.axis, d = o.axis, c = `${n.id}.${o.id}.${a.stack||a.type}`, u = e.length;
for (let t = 0; t < u; ++t) {
let s = e[t],
{
[h]: n,
[d]: u
} = s,
g = s._stacks || (s._stacks = {});
(i = g[d] = function(t, e, i) {
let s = t[e] || (t[e] = {});
return s[i] || (s[i] = {})
}(r, c, n))[l] = u, i._top = getLastIndexInStack(i, o, !0, a.type), i._bottom = getLastIndexInStack(i, o, !1, a.type)
}
}
function getFirstScaleId(t, e) {
let i = t.scales;
return Object.keys(i).filter(t => i[t].axis === e).shift()
}
function clearStacks(t, e) {
let i = t.controller.index,
s = t.vScale && t.vScale.axis;
if (s)
for (let a of e = e || t._parsed) {
let t = a._stacks;
if (!t || void 0 === t[s] || void 0 === t[s][i]) return;
delete t[s][i]
}
}
let isDirectUpdateMode = t => "reset" === t || "none" === t,
cloneIfNotShared = (t, e) => e ? t : Object.assign({}, t),
createStack = (t, e, i) => t && !e.hidden && e._stacked && {
keys: getSortedDatasetIndices(i, !0),
values: null
};
let DatasetController = class DatasetController {
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.$context = void 0, this._syncList = [], this.initialize()
}
initialize() {
let t = this._cachedMeta;
this.configure(), this.linkScales(), t._stacked = isStacked(t.vScale, t), this.addElements()
}
updateIndex(t) {
this.index !== t && clearStacks(this._cachedMeta), this.index = t
}
linkScales() {
let t = this.chart,
e = this._cachedMeta,
i = this.getDataset(),
chooseId = (t, e, i, s) => "x" === t ? e : "r" === t ? s : i,
a = e.xAxisID = (0, s.v)(i.xAxisID, getFirstScaleId(t, "x")),
r = e.yAxisID = (0, s.v)(i.yAxisID, getFirstScaleId(t, "y")),
n = e.rAxisID = (0, s.v)(i.rAxisID, getFirstScaleId(t, "r")),
o = e.indexAxis,
l = e.iAxisID = chooseId(o, a, r, n),
h = e.vAxisID = chooseId(o, r, a, n);
e.xScale = this.getScaleForId(a), e.yScale = this.getScaleForId(r), e.rScale = this.getScaleForId(n), e.iScale = this.getScaleForId(l), 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) {
let e = this._cachedMeta;
return t === e.iScale ? e.vScale : e.iScale
}
reset() {
this._update("reset")
}
_destroy() {
let t = this._cachedMeta;
this._data && (0, s.u)(this._data, this), t._stacked && clearStacks(t)
}
_dataCheck() {
let t = this.getDataset(),
e = t.data || (t.data = []),
i = this._data;
if ((0, s.i)(e)) this._data = function(t) {
let e, i, s;
let a = Object.keys(t),
r = Array(a.length);
for (e = 0, i = a.length; e < i; ++e) s = a[e], r[e] = {
x: s,
y: t[s]
};
return r
}(e);
else if (i !== e) {
if (i) {
(0, s.u)(i, this);
let t = this._cachedMeta;
clearStacks(t), t._parsed = []
}
e && Object.isExtensible(e) && (0, s.l)(e, this), this._syncList = [], this._data = e
}
}
addElements() {
let t = this._cachedMeta;
this._dataCheck(), this.datasetElementType && (t.dataset = new this.datasetElementType)
}
buildOrUpdateElements(t) {
let e = this._cachedMeta,
i = this.getDataset(),
s = !1;
this._dataCheck();
let a = e._stacked;
e._stacked = isStacked(e.vScale, e), e.stack !== i.stack && (s = !0, clearStacks(e), e.stack = i.stack), this._resyncElements(t), (s || a !== e._stacked) && updateStacks(this, e._parsed)
}
configure() {
let t = this.chart.config,
e = t.datasetScopeKeys(this._type),
i = t.getOptionScopes(this.getDataset(), e, !0);
this.options = t.createResolver(i, this.getContext()), this._parsing = this.options.parsing, this._cachedDataOpts = {}
}
parse(t, e) {
let i, a, r;
let {
_cachedMeta: n,
_data: o
} = this, {
iScale: l,
_stacked: h
} = n, d = l.axis, c = 0 === t && e === o.length || n._sorted, u = t > 0 && n._parsed[t - 1];
if (!1 === this._parsing) n._parsed = o, n._sorted = !0, r = o;
else {
r = (0, s.b)(o[t]) ? this.parseArrayData(n, o, t, e) : (0, s.i)(o[t]) ? this.parseObjectData(n, o, t, e) : this.parsePrimitiveData(n, o, t, e);
let isNotInOrderComparedToPrev = () => null === a[d] || u && a[d] < u[d];
for (i = 0; i < e; ++i) n._parsed[i + t] = a = r[i], c && (isNotInOrderComparedToPrev() && (c = !1), u = a);
n._sorted = c
}
h && updateStacks(this, r)
}
parsePrimitiveData(t, e, i, s) {
let a, r;
let {
iScale: n,
vScale: o
} = t, l = n.axis, h = o.axis, d = n.getLabels(), c = n === o, u = Array(s);
for (a = 0; a < s; ++a) r = a + i, u[a] = {
[l]: c || n.parse(d[r], r),
[h]: o.parse(e[r], r)
};
return u
}
parseArrayData(t, e, i, s) {
let a, r, n;
let {
xScale: o,
yScale: l
} = t, h = Array(s);
for (a = 0; a < s; ++a) n = e[r = a + i], h[a] = {
x: o.parse(n[0], r),
y: l.parse(n[1], r)
};
return h
}
parseObjectData(t, e, i, a) {
let r, n, o;
let {
xScale: l,
yScale: h
} = t, {
xAxisKey: d = "x",
yAxisKey: c = "y"
} = this._parsing, u = Array(a);
for (r = 0; r < a; ++r) o = e[n = r + i], u[r] = {
x: l.parse((0, s.f)(o, d), n),
y: h.parse((0, s.f)(o, c), n)
};
return u
}
getParsed(t) {
return this._cachedMeta._parsed[t]
}
getDataElement(t) {
return this._cachedMeta.data[t]
}
applyStack(t, e, i) {
let s = this.chart,
a = this._cachedMeta,
r = e[t.axis],
n = {
keys: getSortedDatasetIndices(s, !0),
values: e._stacks[t.axis]
};
return applyStack(n, r, a.index, {
mode: i
})
}
updateRangeFromParsed(t, e, i, s) {
let a = i[e.axis],
r = null === a ? NaN : a,
n = s && i._stacks[e.axis];
s && n && (s.values = n, r = applyStack(s, a, this._cachedMeta.index)), t.min = Math.min(t.min, r), t.max = Math.max(t.max, r)
}
getMinMax(t, e) {
let i, a;
let r = this._cachedMeta,
n = r._parsed,
o = r._sorted && t === r.iScale,
l = n.length,
h = this._getOtherScale(t),
d = createStack(e, r, this.chart),
c = {
min: Number.POSITIVE_INFINITY,
max: Number.NEGATIVE_INFINITY
},
{
min: u,
max: g
} = function(t) {
let {
min: e,
max: i,
minDefined: s,
maxDefined: a
} = t.getUserBounds();
return {
min: s ? e : Number.NEGATIVE_INFINITY,
max: a ? i : Number.POSITIVE_INFINITY
}
}(h);
function _skip() {
a = n[i];
let e = a[h.axis];
return !(0, s.g)(a[t.axis]) || u > e || g < e
}
for (i = 0; i < l && (_skip() || (this.updateRangeFromParsed(c, t, a, d), !o)); ++i);
if (o) {
for (i = l - 1; i >= 0; --i)
if (!_skip()) {
this.updateRangeFromParsed(c, t, a, d);
break
}
}
return c
}
getAllParsedValues(t) {
let e, i, a;
let r = this._cachedMeta._parsed,
n = [];
for (e = 0, i = r.length; e < i; ++e) a = r[e][t.axis], (0, s.g)(a) && n.push(a);
return n
}
getMaxOverflow() {
return !1
}
getLabelAndValue(t) {
let e = this._cachedMeta,
i = e.iScale,
s = e.vScale,
a = this.getParsed(t);
return {
label: i ? "" + i.getLabelForValue(a[i.axis]) : "",
value: s ? "" + s.getLabelForValue(a[s.axis]) : ""
}
}
_update(t) {
var e;
let i, a, r, n;
let o = this._cachedMeta;
this.update(t || "default"), o._clip = (e = (0, s.v)(this.options.clip, function(t, e, i) {
if (!1 === i) return !1;
let s = scaleClip(t, i),
a = scaleClip(e, i);
return {
top: a.end,
right: s.end,
bottom: a.start,
left: s.start
}
}(o.xScale, o.yScale, this.getMaxOverflow())), (0, s.i)(e) ? (i = e.top, a = e.right, r = e.bottom, n = e.left) : i = a = r = n = e, {
top: i,
right: a,
bottom: r,
left: n,
disabled: !1 === e
})
}
update(t) {}
draw() {
let t;
let e = this._ctx,
i = this.chart,
s = this._cachedMeta,
a = s.data || [],
r = i.chartArea,
n = [],
o = this._drawStart || 0,
l = this._drawCount || a.length - o,
h = this.options.drawActiveElementsOnTop;
for (s.dataset && s.dataset.draw(e, r, o, l), t = o; t < o + l; ++t) {
let i = a[t];
i.hidden || (i.active && h ? n.push(i) : i.draw(e, r))
}
for (t = 0; t < n.length; ++t) n[t].draw(e, r)
}
getStyle(t, e) {
let i = e ? "active" : "default";
return void 0 === t && this._cachedMeta.dataset ? this.resolveDatasetElementOptions(i) : this.resolveDataElementOptions(t || 0, i)
}
getContext(t, e, i) {
var a, r, n;
let o;
let l = this.getDataset();
if (t >= 0 && t < this._cachedMeta.data.length) {
let e = this._cachedMeta.data[t];
(o = e.$context || (e.$context = (a = this.getContext(), (0, s.h)(a, {
active: !1,
dataIndex: t,
parsed: void 0,
raw: void 0,
element: e,
index: t,
mode: "default",
type: "data"
})))).parsed = this.getParsed(t), o.raw = l.data[t], o.index = o.dataIndex = t
} else(o = this.$context || (this.$context = (r = this.chart.getContext(), n = this.index, (0, s.h)(r, {
active: !1,
dataset: void 0,
datasetIndex: n,
index: n,
mode: "default",
type: "dataset"
})))).dataset = l, o.index = o.datasetIndex = this.index;
return o.active = !!e, o.mode = i, 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", i) {
let a = "active" === e,
r = this._cachedDataOpts,
n = t + "-" + e,
o = r[n],
l = this.enableOptionSharing && (0, s.j)(i);
if (o) return cloneIfNotShared(o, l);
let h = this.chart.config,
d = h.datasetElementScopeKeys(this._type, t),
c = a ? [`${t}Hover`, "hover", t, ""] : [t, ""],
u = h.getOptionScopes(this.getDataset(), d),
g = Object.keys(s.d.elements[t]),
p = h.resolveNamedOptions(u, g, () => this.getContext(i, a), c);
return p.$shared && (p.$shared = l, r[n] = Object.freeze(cloneIfNotShared(p, l))), p
}
_resolveAnimations(t, e, i) {
let s;
let a = this.chart,
r = this._cachedDataOpts,
n = `animation-${e}`,
o = r[n];
if (o) return o;
if (!1 !== a.options.animation) {
let a = this.chart.config,
r = a.datasetAnimationScopeKeys(this._type, e),
n = a.getOptionScopes(this.getDataset(), r);
s = a.createResolver(n, this.getContext(t, i, e))
}
let l = new Animations(a, s && s.animations);
return s && s._cacheable && (r[n] = Object.freeze(l)), l
}
getSharedOptions(t) {
if (t.$shared) return this._sharedOptions || (this._sharedOptions = Object.assign({}, t))
}
includeOptions(t, e) {
return !e || isDirectUpdateMode(t) || this.chart._animationsDisabled
}
updateElement(t, e, i, s) {
isDirectUpdateMode(s) ? Object.assign(t, i) : this._resolveAnimations(e, s).update(t, i)
}
updateSharedOptions(t, e, i) {
t && !isDirectUpdateMode(e) && this._resolveAnimations(void 0, e).update(t, i)
}
_setStyle(t, e, i, s) {
t.active = s;
let a = this.getStyle(e, s);
this._resolveAnimations(e, i, s).update(t, {
options: !s && this.getSharedOptions(a) || a
})
}
removeHoverStyle(t, e, i) {
this._setStyle(t, i, "active", !1)
}
setHoverStyle(t, e, i) {
this._setStyle(t, i, "active", !0)
}
_removeDatasetHoverStyle() {
let t = this._cachedMeta.dataset;
t && this._setStyle(t, void 0, "active", !1)
}
_setDatasetHoverStyle() {
let t = this._cachedMeta.dataset;
t && this._setStyle(t, void 0, "active", !0)
}
_resyncElements(t) {
let e = this._data,
i = this._cachedMeta.data;
for (let [t, e, i] of this._syncList) this[t](e, i);
this._syncList = [];
let s = i.length,
a = e.length,
r = Math.min(a, s);
r && this.parse(0, r), a > s ? this._insertElements(s, a - s, t) : a < s && this._removeElements(a, s - a)
}
_insertElements(t, e, i = !0) {
let s;
let a = this._cachedMeta,
r = a.data,
n = t + e,
move = t => {
for (t.length += e, s = t.length - 1; s >= n; s--) t[s] = t[s - e]
};
for (move(r), s = t; s < n; ++s) r[s] = new this.dataElementType;
this._parsing && move(a._parsed), this.parse(t, e), i && this.updateElements(r, t, e, "reset")
}
updateElements(t, e, i, s) {}
_removeElements(t, e) {
let i = this._cachedMeta;
if (this._parsing) {
let s = i._parsed.splice(t, e);
i._stacked && clearStacks(i, s)
}
i.data.splice(t, e)
}
_sync(t) {
if (this._parsing) this._syncList.push(t);
else {
let [e, i, s] = t;
this[e](i, s)
}
this.chart._dataChanges.push([this.index, ...t])
}
_onDataPush() {
let 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]);
let i = arguments.length - 2;
i && this._sync(["_insertElements", t, i])
}
_onDataUnshift() {
this._sync(["_insertElements", 0, arguments.length])
}
};
function parseValue(t, e, i, a) {
return (0, s.b)(t) ? function(t, e, i, s) {
let a = i.parse(t[0], s),
r = i.parse(t[1], s),
n = Math.min(a, r),
o = Math.max(a, r),
l = n,
h = o;
Math.abs(n) > Math.abs(o) && (l = o, h = n), e[i.axis] = h, e._custom = {
barStart: l,
barEnd: h,
start: a,
end: r,
min: n,
max: o
}
}(t, e, i, a) : e[i.axis] = i.parse(t, a), e
}
function parseArrayOrPrimitive(t, e, i, s) {
let a, r, n, o;
let l = t.iScale,
h = t.vScale,
d = l.getLabels(),
c = l === h,
u = [];
for (a = i, r = i + s; a < r; ++a) o = e[a], (n = {})[l.axis] = c || l.parse(d[a], a), u.push(parseValue(o, n, h, a));
return u
}
function isFloatBar(t) {
return t && void 0 !== t.barStart && void 0 !== t.barEnd
}
function parseEdge(t, e, i, s) {
var a;
return t = s ? startEnd(t = (a = t) === e ? i : a === i ? e : a, i, e) : startEnd(t, e, i)
}
function startEnd(t, e, i) {
return "start" === t ? e : "end" === t ? i : t
}
DatasetController.defaults = {}, DatasetController.prototype.datasetElementType = null, DatasetController.prototype.dataElementType = null;
let BarController = class BarController extends DatasetController {
parsePrimitiveData(t, e, i, s) {
return parseArrayOrPrimitive(t, e, i, s)
}
parseArrayData(t, e, i, s) {
return parseArrayOrPrimitive(t, e, i, s)
}
parseObjectData(t, e, i, a) {
let r, n, o, l;
let {
iScale: h,
vScale: d
} = t, {
xAxisKey: c = "x",
yAxisKey: u = "y"
} = this._parsing, g = "x" === h.axis ? c : u, p = "x" === d.axis ? c : u, f = [];
for (r = i, n = i + a; r < n; ++r) l = e[r], (o = {})[h.axis] = h.parse((0, s.f)(l, g), r), f.push(parseValue((0, s.f)(l, p), o, d, r));
return f
}
updateRangeFromParsed(t, e, i, s) {
super.updateRangeFromParsed(t, e, i, s);
let a = i._custom;
a && e === this._cachedMeta.vScale && (t.min = Math.min(t.min, a.min), t.max = Math.max(t.max, a.max))
}
getMaxOverflow() {
return 0
}
getLabelAndValue(t) {
let e = this._cachedMeta,
{
iScale: i,
vScale: s
} = e,
a = this.getParsed(t),
r = a._custom,
n = isFloatBar(r) ? "[" + r.start + ", " + r.end + "]" : "" + s.getLabelForValue(a[s.axis]);
return {
label: "" + i.getLabelForValue(a[i.axis]),
value: n
}
}
initialize() {
this.enableOptionSharing = !0, super.initialize();
let t = this._cachedMeta;
t.stack = this.getDataset().stack
}
update(t) {
let e = this._cachedMeta;
this.updateElements(e.data, 0, e.data.length, t)
}
updateElements(t, e, i, a) {
let r = "reset" === a,
{
index: n,
_cachedMeta: {
vScale: o
}
} = this,
l = o.getBasePixel(),
h = o.isHorizontal(),
d = this._getRuler(),
c = this.resolveDataElementOptions(e, a),
u = this.getSharedOptions(c),
g = this.includeOptions(a, u);
this.updateSharedOptions(u, a, c);
for (let c = e; c < e + i; c++) {
let e = this.getParsed(c),
i = r || (0, s.k)(e[o.axis]) ? {
base: l,
head: l
} : this._calculateBarValuePixels(c),
p = this._calculateBarIndexPixels(c, d),
f = (e._stacks || {})[o.axis],
m = {
horizontal: h,
base: i.base,
enableBorderRadius: !f || isFloatBar(e._custom) || n === f._top || n === f._bottom,
x: h ? i.head : p.center,
y: h ? p.center : i.head,
height: h ? p.size : Math.abs(i.size),
width: h ? Math.abs(i.size) : p.size
};
g && (m.options = u || this.resolveDataElementOptions(c, t[c].active ? "active" : a));
let x = m.options || t[c].options;
! function(t, e, i, s) {
let a, r, n, o, l, h = e.borderSkipped,
d = {};
if (!h) {
t.borderSkipped = d;
return
}
let {
start: c,
end: u,
reverse: g,
top: p,
bottom: f
} = (t.horizontal ? (a = t.base > t.x, r = "left", n = "right") : (a = t.base < t.y, r = "bottom", n = "top"), a ? (o = "end", l = "start") : (o = "start", l = "end"), {
start: r,
end: n,
reverse: a,
top: o,
bottom: l
});
"middle" === h && i && (t.enableBorderRadius = !0, (i._top || 0) === s ? h = p : (i._bottom || 0) === s ? h = f : (d[parseEdge(f, c, u, g)] = !0, h = p)), d[parseEdge(h, c, u, g)] = !0, t.borderSkipped = d
}(m, x, f, n),
function(t, {
inflateAmount: e
}, i) {
t.inflateAmount = "auto" === e ? 1 === i ? .33 : 0 : e
}(m, x, d.ratio), this.updateElement(t[c], c, m, a)
}
}
_getStacks(t, e) {
let i, a;
let r = this._cachedMeta,
n = r.iScale,
o = n.getMatchingVisibleMetas(this._type),
l = n.options.stacked,
h = o.length,
d = [];
for (i = 0; i < h; ++i)
if ((a = o[i]).controller.options.grouped) {
if (void 0 !== e) {
let t = a.controller.getParsed(e)[a.controller._cachedMeta.vScale.axis];
if ((0, s.k)(t) || isNaN(t)) continue
}
if ((!1 === l || -1 === d.indexOf(a.stack) || void 0 === l && void 0 === a.stack) && d.push(a.stack), a.index === t) break
} return d.length || d.push(void 0), d
}
_getStackCount(t) {
return this._getStacks(void 0, t).length
}
_getStackIndex(t, e, i) {
let s = this._getStacks(t, i),
a = void 0 !== e ? s.indexOf(e) : -1;
return -1 === a ? s.length - 1 : a
}
_getRuler() {
let t, e;
let i = this.options,
a = this._cachedMeta,
r = a.iScale,
n = [];
for (t = 0, e = a.data.length; t < e; ++t) n.push(r.getPixelForValue(this.getParsed(t)[r.axis], t));
let o = i.barThickness,
l = o || function(t) {
let e, i, a, r;
let n = t.iScale,
o = function(t, e) {
if (!t._cache.$bar) {
let i = t.getMatchingVisibleMetas(e),
a = [];
for (let e = 0, s = i.length; e < s; e++) a = a.concat(i[e].controller.getAllParsedValues(t));
t._cache.$bar = (0, s._)(a.sort((t, e) => t - e))
}
return t._cache.$bar
}(n, t.type),
l = n._length,
updateMinAndPrev = () => {
32767 !== a && -32768 !== a && ((0, s.j)(r) && (l = Math.min(l, Math.abs(a - r) || l)), r = a)
};
for (e = 0, i = o.length; e < i; ++e) a = n.getPixelForValue(o[e]), updateMinAndPrev();
for (e = 0, r = void 0, i = n.ticks.length; e < i; ++e) a = n.getPixelForTick(e), updateMinAndPrev();
return l
}(a);
return {
min: l,
pixels: n,
start: r._startPixel,
end: r._endPixel,
stackCount: this._getStackCount(),
scale: r,
grouped: i.grouped,
ratio: o ? 1 : i.categoryPercentage * i.barPercentage
}
}
_calculateBarValuePixels(t) {
let e, i;
let {
_cachedMeta: {
vScale: a,
_stacked: r
},
options: {
base: n,
minBarLength: o
}
} = this, l = n || 0, h = this.getParsed(t), d = h._custom, c = isFloatBar(d), u = h[a.axis], g = 0, p = r ? this.applyStack(a, h, r) : u;
p !== u && (g = p - u, p = u), c && (u = d.barStart, p = d.barEnd - d.barStart, 0 !== u && (0, s.s)(u) !== (0, s.s)(d.barEnd) && (g = 0), g += u);
let f = (0, s.k)(n) || c ? g : n,
m = a.getPixelForValue(f);
if (Math.abs(i = (e = this.chart.getDataVisibility(t) ? a.getPixelForValue(g + p) : m) - m) < o) {
var x;
i = (0 !== (x = i) ? (0, s.s)(x) : (a.isHorizontal() ? 1 : -1) * (a.min >= l ? 1 : -1)) * o, u === l && (m -= i / 2), e = m + i
}
if (m === a.getPixelForValue(l)) {
let t = (0, s.s)(i) * a.getLineWidthForValue(l) / 2;
m += t, i -= t
}
return {
size: i,
base: m,
head: e,
center: e + i / 2
}
}
_calculateBarIndexPixels(t, e) {
let i, a;
let r = e.scale,
n = this.options,
o = n.skipNull,
l = (0, s.v)(n.maxBarThickness, 1 / 0);
if (e.grouped) {
let r = o ? this._getStackCount(t) : e.stackCount,
h = "flex" === n.barThickness ? function(t, e, i, s) {
let a = e.pixels,
r = a[t],
n = t > 0 ? a[t - 1] : null,
o = t < a.length - 1 ? a[t + 1] : null,
l = i.categoryPercentage;
null === n && (n = r - (null === o ? e.end - e.start : o - r)), null === o && (o = r + r - n);
let h = r - (r - Math.min(n, o)) / 2 * l,
d = Math.abs(o - n) / 2 * l;
return {
chunk: d / s,
ratio: i.barPercentage,
start: h
}
}(t, e, n, r) : function(t, e, i, a) {
let r, n;
let o = i.barThickness;
return (0, s.k)(o) ? (r = e.min * i.categoryPercentage, n = i.barPercentage) : (r = o * a, n = 1), {
chunk: r / a,
ratio: n,
start: e.pixels[t] - r / 2
}
}(t, e, n, r),
d = this._getStackIndex(this.index, this._cachedMeta.stack, o ? t : void 0);
i = h.start + h.chunk * d + h.chunk / 2, a = Math.min(l, h.chunk * h.ratio)
} else i = r.getPixelForValue(this.getParsed(t)[r.axis], t), a = Math.min(l, e.min * e.ratio);
return {
base: i - a / 2,
head: i + a / 2,
center: i,
size: a
}
}
draw() {
let t = this._cachedMeta,
e = t.vScale,
i = t.data,
s = i.length,
a = 0;
for (; a < s; ++a) null !== this.getParsed(a)[e.axis] && i[a].draw(this._ctx)
}
};
BarController.id = "bar", BarController.defaults = {
datasetElementType: !1,
dataElementType: "bar",
categoryPercentage: .8,
barPercentage: .9,
grouped: !0,
animations: {
numbers: {
type: "number",
properties: ["x", "y", "base", "width", "height"]
}
}
}, BarController.overrides = {
scales: {
_index_: {
type: "category",
offset: !0,
grid: {
offset: !0
}
},
_value_: {
type: "linear",
beginAtZero: !0
}
}
};
let BubbleController = class BubbleController extends DatasetController {
initialize() {
this.enableOptionSharing = !0, super.initialize()
}
parsePrimitiveData(t, e, i, s) {
let a = super.parsePrimitiveData(t, e, i, s);
for (let t = 0; t < a.length; t++) a[t]._custom = this.resolveDataElementOptions(t + i).radius;
return a
}
parseArrayData(t, e, i, a) {
let r = super.parseArrayData(t, e, i, a);
for (let t = 0; t < r.length; t++) {
let a = e[i + t];
r[t]._custom = (0, s.v)(a[2], this.resolveDataElementOptions(t + i).radius)
}
return r
}
parseObjectData(t, e, i, a) {
let r = super.parseObjectData(t, e, i, a);
for (let t = 0; t < r.length; t++) {
let a = e[i + t];
r[t]._custom = (0, s.v)(a && a.r && +a.r, this.resolveDataElementOptions(t + i).radius)
}
return r
}
getMaxOverflow() {
let t = this._cachedMeta.data,
e = 0;
for (let i = t.length - 1; i >= 0; --i) e = Math.max(e, t[i].size(this.resolveDataElementOptions(i)) / 2);
return e > 0 && e
}
getLabelAndValue(t) {
let e = this._cachedMeta,
{
xScale: i,
yScale: s
} = e,
a = this.getParsed(t),
r = i.getLabelForValue(a.x),
n = s.getLabelForValue(a.y),
o = a._custom;
return {
label: e.label,
value: "(" + r + ", " + n + (o ? ", " + o : "") + ")"
}
}
update(t) {
let e = this._cachedMeta.data;
this.updateElements(e, 0, e.length, t)
}
updateElements(t, e, i, s) {
let a = "reset" === s,
{
iScale: r,
vScale: n
} = this._cachedMeta,
o = this.resolveDataElementOptions(e, s),
l = this.getSharedOptions(o),
h = this.includeOptions(s, l),
d = r.axis,
c = n.axis;
for (let o = e; o < e + i; o++) {
let e = t[o],
i = !a && this.getParsed(o),
l = {},
u = l[d] = a ? r.getPixelForDecimal(.5) : r.getPixelForValue(i[d]),
g = l[c] = a ? n.getBasePixel() : n.getPixelForValue(i[c]);
l.skip = isNaN(u) || isNaN(g), h && (l.options = this.resolveDataElementOptions(o, e.active ? "active" : s), a && (l.options.radius = 0)), this.updateElement(e, o, l, s)
}
this.updateSharedOptions(l, s, o)
}
resolveDataElementOptions(t, e) {
let i = this.getParsed(t),
a = super.resolveDataElementOptions(t, e);
a.$shared && (a = Object.assign({}, a, {
$shared: !1
}));
let r = a.radius;
return "active" !== e && (a.radius = 0), a.radius += (0, s.v)(i && i._custom, r), a
}
};
BubbleController.id = "bubble", BubbleController.defaults = {
datasetElementType: !1,
dataElementType: "point",
animations: {
numbers: {
type: "number",
properties: ["x", "y", "borderWidth", "radius"]
}
}
}, BubbleController.overrides = {
scales: {
x: {
type: "linear"
},
y: {
type: "linear"
}
},
plugins: {
tooltip: {
callbacks: {
title: () => ""
}
}
}
};
let DoughnutController = class DoughnutController extends DatasetController {
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) {
let i = this.getDataset().data,
a = this._cachedMeta;
if (!1 === this._parsing) a._parsed = i;
else {
let r, n, getter = t => +i[t];
if ((0, s.i)(i[t])) {
let {
key: t = "value"
} = this._parsing;
getter = e => +(0, s.f)(i[e], t)
}
for (r = t, n = t + e; r < n; ++r) a._parsed[r] = getter(r)
}
}
_getRotation() {
return (0, s.t)(this.options.rotation - 90)
}
_getCircumference() {
return (0, s.t)(this.options.circumference)
}
_getRotationExtents() {
let t = s.T,
e = -s.T;
for (let i = 0; i < this.chart.data.datasets.length; ++i)
if (this.chart.isDatasetVisible(i)) {
let s = this.chart.getDatasetMeta(i).controller,
a = s._getRotation(),
r = s._getCircumference();
t = Math.min(t, a), e = Math.max(e, a + r)
} return {
rotation: t,
circumference: e - t
}
}
update(t) {
let e = this.chart,
{
chartArea: i
} = e,
a = this._cachedMeta,
r = a.data,
n = this.getMaxBorderWidth() + this.getMaxOffset(r) + this.options.spacing,
o = Math.max((Math.min(i.width, i.height) - n) / 2, 0),
l = Math.min((0, s.m)(this.options.cutout, o), 1),
h = this._getRingWeight(this.index),
{
circumference: d,
rotation: c
} = this._getRotationExtents(),
{
ratioX: u,
ratioY: g,
offsetX: p,
offsetY: f
} = function(t, e, i) {
let a = 1,
r = 1,
n = 0,
o = 0;
if (e < s.T) {
let l = t + e,
h = Math.cos(t),
d = Math.sin(t),
c = Math.cos(l),
u = Math.sin(l),
calcMax = (e, a, r) => (0, s.p)(e, t, l, !0) ? 1 : Math.max(a, a * i, r, r * i),
calcMin = (e, a, r) => (0, s.p)(e, t, l, !0) ? -1 : Math.min(a, a * i, r, r * i),
g = calcMax(0, h, c),
p = calcMax(s.H, d, u),
f = calcMin(s.P, h, c),
m = calcMin(s.P + s.H, d, u);
a = (g - f) / 2, r = (p - m) / 2, n = -(g + f) / 2, o = -(p + m) / 2
}
return {
ratioX: a,
ratioY: r,
offsetX: n,
offsetY: o
}
}(c, d, l),
m = (i.width - n) / u,
x = (i.height - n) / g,
b = (0, s.n)(this.options.radius, Math.max(Math.min(m, x) / 2, 0)),
_ = Math.max(b * l, 0),
v = (b - _) / this._getVisibleDatasetWeightTotal();
this.offsetX = p * b, this.offsetY = f * b, a.total = this.calculateTotal(), this.outerRadius = b - v * this._getRingWeightOffset(this.index), this.innerRadius = Math.max(this.outerRadius - v * h, 0), this.updateElements(r, 0, r.length, t)
}
_circumference(t, e) {
let i = this.options,
a = this._cachedMeta,
r = this._getCircumference();
return e && i.animation.animateRotate || !this.chart.getDataVisibility(t) || null === a._parsed[t] || a.data[t].hidden ? 0 : this.calculateCircumference(a._parsed[t] * r / s.T)
}
updateElements(t, e, i, s) {
let a;
let r = "reset" === s,
n = this.chart,
o = n.chartArea,
l = n.options,
h = l.animation,
d = (o.left + o.right) / 2,
c = (o.top + o.bottom) / 2,
u = r && h.animateScale,
g = u ? 0 : this.innerRadius,
p = u ? 0 : this.outerRadius,
f = this.resolveDataElementOptions(e, s),
m = this.getSharedOptions(f),
x = this.includeOptions(s, m),
b = this._getRotation();
for (a = 0; a < e; ++a) b += this._circumference(a, r);
for (a = e; a < e + i; ++a) {
let e = this._circumference(a, r),
i = t[a],
n = {
x: d + this.offsetX,
y: c + this.offsetY,
startAngle: b,
endAngle: b + e,
circumference: e,
outerRadius: p,
innerRadius: g
};
x && (n.options = m || this.resolveDataElementOptions(a, i.active ? "active" : s)), b += e, this.updateElement(i, a, n, s)
}
this.updateSharedOptions(m, s, f)
}
calculateTotal() {
let t;
let e = this._cachedMeta,
i = e.data,
s = 0;
for (t = 0; t < i.length; t++) {
let a = e._parsed[t];
null !== a && !isNaN(a) && this.chart.getDataVisibility(t) && !i[t].hidden && (s += Math.abs(a))
}
return s
}
calculateCircumference(t) {
let e = this._cachedMeta.total;
return e > 0 && !isNaN(t) ? s.T * (Math.abs(t) / e) : 0
}
getLabelAndValue(t) {
let e = this._cachedMeta,
i = this.chart,
a = i.data.labels || [],
r = (0, s.o)(e._parsed[t], i.options.locale);
return {
label: a[t] || "",
value: r
}
}
getMaxBorderWidth(t) {
let e, i, s, a, r, n = 0,
o = this.chart;
if (!t) {
for (e = 0, i = o.data.datasets.length; e < i; ++e)
if (o.isDatasetVisible(e)) {
t = (s = o.getDatasetMeta(e)).data, a = s.controller;
break
}
}
if (!t) return 0;
for (e = 0, i = t.length; e < i; ++e) "inner" !== (r = a.resolveDataElementOptions(e)).borderAlign && (n = Math.max(n, r.borderWidth || 0, r.hoverBorderWidth || 0));
return n
}
getMaxOffset(t) {
let e = 0;
for (let i = 0, s = t.length; i < s; ++i) {
let t = this.resolveDataElementOptions(i);
e = Math.max(e, t.offset || 0, t.hoverOffset || 0)
}
return e
}
_getRingWeightOffset(t) {
let e = 0;
for (let i = 0; i < t; ++i) this.chart.isDatasetVisible(i) && (e += this._getRingWeight(i));
return e
}
_getRingWeight(t) {
return Math.max((0, s.v)(this.chart.data.datasets[t].weight, 1), 0)
}
_getVisibleDatasetWeightTotal() {
return this._getRingWeightOffset(this.chart.data.datasets.length) || 1
}
};
DoughnutController.id = "doughnut", DoughnutController.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"
}, DoughnutController.descriptors = {
_scriptable: t => "spacing" !== t,
_indexable: t => "spacing" !== t
}, DoughnutController.overrides = {
aspectRatio: 1,
plugins: {
legend: {
labels: {
generateLabels(t) {
let e = t.data;
if (e.labels.length && e.datasets.length) {
let {
labels: {
pointStyle: i
}
} = t.legend.options;
return e.labels.map((e, s) => {
let a = t.getDatasetMeta(0),
r = a.controller.getStyle(s);
return {
text: e,
fillStyle: r.backgroundColor,
strokeStyle: r.borderColor,
lineWidth: r.borderWidth,
pointStyle: i,
hidden: !t.getDataVisibility(s),
index: s
}
})
}
return []
}
},
onClick(t, e, i) {
i.chart.toggleDataVisibility(e.index), i.chart.update()
}
},
tooltip: {
callbacks: {
title: () => "",
label(t) {
let e = t.label,
i = ": " + t.formattedValue;
return (0, s.b)(e) ? (e = e.slice(), e[0] += i) : e += i, e
}
}
}
}
};
let LineController = class LineController extends DatasetController {
initialize() {
this.enableOptionSharing = !0, super.initialize()
}
update(t) {
let e = this._cachedMeta,
{
dataset: i,
data: a = [],
_dataset: r
} = e,
n = this.chart._animationsDisabled,
{
start: o,
count: l
} = function(t, e, i) {
let a = e.length,
r = 0,
n = a;
if (t._sorted) {
let {
iScale: o,
_parsed: l
} = t, h = o.axis, {
min: d,
max: c,
minDefined: u,
maxDefined: g
} = o.getUserBounds();
u && (r = (0, s.w)(Math.min((0, s.x)(l, o.axis, d).lo, i ? a : (0, s.x)(e, h, o.getPixelForValue(d)).lo), 0, a - 1)), n = g ? (0, s.w)(Math.max((0, s.x)(l, o.axis, c).hi + 1, i ? 0 : (0, s.x)(e, h, o.getPixelForValue(c)).hi + 1), r, a) - r : a - r
}
return {
start: r,
count: n
}
}(e, a, n);
this._drawStart = o, this._drawCount = l,
function(t) {
let {
xScale: e,
yScale: i,
_scaleRanges: s
} = t, a = {
xmin: e.min,
xmax: e.max,
ymin: i.min,
ymax: i.max
};
if (!s) return t._scaleRanges = a, !0;
let r = s.xmin !== e.min || s.xmax !== e.max || s.ymin !== i.min || s.ymax !== i.max;
return Object.assign(s, a), r
}(e) && (o = 0, l = a.length), i._chart = this.chart, i._datasetIndex = this.index, i._decimated = !!r._decimated, i.points = a;
let h = this.resolveDatasetElementOptions(t);
this.options.showLine || (h.borderWidth = 0), h.segment = this.options.segment, this.updateElement(i, void 0, {
animated: !n,
options: h
}, t), this.updateElements(a, o, l, t)
}
updateElements(t, e, i, a) {
let r = "reset" === a,
{
iScale: n,
vScale: o,
_stacked: l,
_dataset: h
} = this._cachedMeta,
d = this.resolveDataElementOptions(e, a),
c = this.getSharedOptions(d),
u = this.includeOptions(a, c),
g = n.axis,
p = o.axis,
{
spanGaps: f,
segment: m
} = this.options,
x = (0, s.q)(f) ? f : Number.POSITIVE_INFINITY,
b = this.chart._animationsDisabled || r || "none" === a,
_ = e > 0 && this.getParsed(e - 1);
for (let d = e; d < e + i; ++d) {
let e = t[d],
i = this.getParsed(d),
f = b ? e : {},
v = (0, s.k)(i[p]),
y = f[g] = n.getPixelForValue(i[g], d),
k = f[p] = r || v ? o.getBasePixel() : o.getPixelForValue(l ? this.applyStack(o, i, l) : i[p], d);
f.skip = isNaN(y) || isNaN(k) || v, f.stop = d > 0 && i[g] - _[g] > x, m && (f.parsed = i, f.raw = h.data[d]), u && (f.options = c || this.resolveDataElementOptions(d, e.active ? "active" : a)), b || this.updateElement(e, d, f, a), _ = i
}
this.updateSharedOptions(c, a, d)
}
getMaxOverflow() {
let t = this._cachedMeta,
e = t.dataset,
i = e.options && e.options.borderWidth || 0,
s = t.data || [];
if (!s.length) return i;
let a = s[0].size(this.resolveDataElementOptions(0)),
r = s[s.length - 1].size(this.resolveDataElementOptions(s.length - 1));
return Math.max(i, a, r) / 2
}
draw() {
let t = this._cachedMeta;
t.dataset.updateControlPoints(this.chart.chartArea, t.iScale.axis), super.draw()
}
};
LineController.id = "line", LineController.defaults = {
datasetElementType: "line",
dataElementType: "point",
showLine: !0,
spanGaps: !1
}, LineController.overrides = {
scales: {
_index_: {
type: "category"
},
_value_: {
type: "linear"
}
}
};
let PolarAreaController = class PolarAreaController extends DatasetController {
constructor(t, e) {
super(t, e), this.innerRadius = void 0, this.outerRadius = void 0
}
getLabelAndValue(t) {
let e = this._cachedMeta,
i = this.chart,
a = i.data.labels || [],
r = (0, s.o)(e._parsed[t].r, i.options.locale);
return {
label: a[t] || "",
value: r
}
}
update(t) {
let e = this._cachedMeta.data;
this._updateRadius(), this.updateElements(e, 0, e.length, t)
}
_updateRadius() {
let t = this.chart,
e = t.chartArea,
i = t.options,
s = Math.min(e.right - e.left, e.bottom - e.top),
a = Math.max(s / 2, 0),
r = Math.max(i.cutoutPercentage ? a / 100 * i.cutoutPercentage : 1, 0),
n = (a - r) / t.getVisibleDatasetCount();
this.outerRadius = a - n * this.index, this.innerRadius = this.outerRadius - n
}
updateElements(t, e, i, a) {
let r;
let n = "reset" === a,
o = this.chart,
l = this.getDataset(),
h = o.options,
d = h.animation,
c = this._cachedMeta.rScale,
u = c.xCenter,
g = c.yCenter,
p = c.getIndexAngle(0) - .5 * s.P,
f = p,
m = 360 / this.countVisibleElements();
for (r = 0; r < e; ++r) f += this._computeAngle(r, a, m);
for (r = e; r < e + i; r++) {
let e = t[r],
i = f,
s = f + this._computeAngle(r, a, m),
h = o.getDataVisibility(r) ? c.getDistanceFromCenterForValue(l.data[r]) : 0;
f = s, n && (d.animateScale && (h = 0), d.animateRotate && (i = s = p));
let x = {
x: u,
y: g,
innerRadius: 0,
outerRadius: h,
startAngle: i,
endAngle: s,
options: this.resolveDataElementOptions(r, e.active ? "active" : a)
};
this.updateElement(e, r, x, a)
}
}
countVisibleElements() {
let t = this.getDataset(),
e = this._cachedMeta,
i = 0;
return e.data.forEach((e, s) => {
!isNaN(t.data[s]) && this.chart.getDataVisibility(s) && i++
}), i
}
_computeAngle(t, e, i) {
return this.chart.getDataVisibility(t) ? (0, s.t)(this.resolveDataElementOptions(t, e).angle || i) : 0
}
};
PolarAreaController.id = "polarArea", PolarAreaController.defaults = {
dataElementType: "arc",
animation: {
animateRotate: !0,
animateScale: !0
},
animations: {
numbers: {
type: "number",
properties: ["x", "y", "startAngle", "endAngle", "innerRadius", "outerRadius"]
}
},
indexAxis: "r",
startAngle: 0
}, PolarAreaController.overrides = {
aspectRatio: 1,
plugins: {
legend: {
labels: {
generateLabels(t) {
let e = t.data;
if (e.labels.length && e.datasets.length) {
let {
labels: {
pointStyle: i
}
} = t.legend.options;
return e.labels.map((e, s) => {
let a = t.getDatasetMeta(0),
r = a.controller.getStyle(s);
return {
text: e,
fillStyle: r.backgroundColor,
strokeStyle: r.borderColor,
lineWidth: r.borderWidth,
pointStyle: i,
hidden: !t.getDataVisibility(s),
index: s
}
})
}
return []
}
},
onClick(t, e, i) {
i.chart.toggleDataVisibility(e.index), i.chart.update()
}
},
tooltip: {
callbacks: {
title: () => "",
label: t => t.chart.data.labels[t.dataIndex] + ": " + t.formattedValue
}
}
},
scales: {
r: {
type: "radialLinear",
angleLines: {
display: !1
},
beginAtZero: !0,
grid: {
circular: !0
},
pointLabels: {
display: !1
},
startAngle: 0
}
}
};
let PieController = class PieController extends DoughnutController {};
PieController.id = "pie", PieController.defaults = {
cutout: 0,
rotation: 0,
circumference: 360,
radius: "100%"
};
let RadarController = class RadarController extends DatasetController {
getLabelAndValue(t) {
let e = this._cachedMeta.vScale,
i = this.getParsed(t);
return {
label: e.getLabels()[t],
value: "" + e.getLabelForValue(i[e.axis])
}
}
update(t) {
let e = this._cachedMeta,
i = e.dataset,
s = e.data || [],
a = e.iScale.getLabels();
if (i.points = s, "resize" !== t) {
let e = this.resolveDatasetElementOptions(t);
this.options.showLine || (e.borderWidth = 0);
let r = {
_loop: !0,
_fullLoop: a.length === s.length,
options: e
};
this.updateElement(i, void 0, r, t)
}
this.updateElements(s, 0, s.length, t)
}
updateElements(t, e, i, s) {
let a = this.getDataset(),
r = this._cachedMeta.rScale,
n = "reset" === s;
for (let o = e; o < e + i; o++) {
let e = t[o],
i = this.resolveDataElementOptions(o, e.active ? "active" : s),
l = r.getPointPositionForValue(o, a.data[o]),
h = n ? r.xCenter : l.x,
d = n ? r.yCenter : l.y,
c = {
x: h,
y: d,
angle: l.angle,
skip: isNaN(h) || isNaN(d),
options: i
};
this.updateElement(e, o, c, s)
}
}
};
RadarController.id = "radar", RadarController.defaults = {
datasetElementType: "line",
dataElementType: "point",
indexAxis: "r",
showLine: !0,
elements: {
line: {
fill: "start"
}
}
}, RadarController.overrides = {
aspectRatio: 1,
scales: {
r: {
type: "radialLinear"
}
}
};
let ScatterController = class ScatterController extends LineController {};
ScatterController.id = "scatter", ScatterController.defaults = {
showLine: !1,
fill: !1
}, ScatterController.overrides = {
interaction: {
mode: "point"
},
plugins: {
tooltip: {
callbacks: {
title: () => "",
label: t => "(" + t.label + ", " + t.formattedValue + ")"
}
}
},
scales: {
x: {
type: "linear"
},
y: {
type: "linear"
}
}
};
var l = Object.freeze({
__proto__: null,
BarController: BarController,
BubbleController: BubbleController,
DoughnutController: DoughnutController,
LineController: LineController,
PolarAreaController: PolarAreaController,
PieController: PieController,
RadarController: RadarController,
ScatterController: ScatterController
});
function abstract() {
throw Error("This method is not implemented: Check that a complete date adapter is provided.")
}
let DateAdapter = class DateAdapter {
constructor(t) {
this.options = t || {}
}
formats() {
return abstract()
}
parse(t, e) {
return abstract()
}
format(t, e) {
return abstract()
}
add(t, e, i) {
return abstract()
}
diff(t, e, i) {
return abstract()
}
startOf(t, e, i) {
return abstract()
}
endOf(t, e) {
return abstract()
}
};
DateAdapter.override = function(t) {
Object.assign(DateAdapter.prototype, t)
};
var h = {
_date: DateAdapter
};
function getRelativePosition(t, e) {
return "native" in t ? {
x: t.x,
y: t.y
} : (0, s.y)(t, e)
}
function optimizedEvaluateItems(t, e, i, a, r) {
let n = t.getSortedVisibleDatasetMetas(),
o = i[e];
for (let t = 0, i = n.length; t < i; ++t) {
let {
index: i,
data: l
} = n[t], {
lo: h,
hi: d
} = function(t, e, i, a) {
let {
controller: r,
data: n,
_sorted: o
} = t, l = r._cachedMeta.iScale;
if (l && e === l.axis && "r" !== e && o && n.length) {
let t = l._reversePixels ? s.A : s.x;
if (!a) return t(n, e, i);
if (r._sharedOptions) {
let s = n[0],
a = "function" == typeof s.getRange && s.getRange(e);
if (a) {
let s = t(n, e, i - a),
r = t(n, e, i + a);
return {
lo: s.lo,
hi: r.hi
}
}
}
}
return {
lo: 0,
hi: n.length - 1
}
}(n[t], e, o, r);
for (let t = h; t <= d; ++t) {
let e = l[t];
e.skip || a(e, i, t)
}
}
}
function getIntersectItems(t, e, i, a) {
let r = [];
return (0, s.z)(e, t.chartArea, t._minPadding) && optimizedEvaluateItems(t, i, e, function(t, i, s) {
t.inRange(e.x, e.y, a) && r.push({
element: t,
datasetIndex: i,
index: s
})
}, !0), r
}
function getNearestItems(t, e, i, a, r) {
let n;
return (0, s.z)(e, t.chartArea, t._minPadding) ? "r" !== i || a ? function(t, e, i, a, r) {
let n = [],
o = function(t) {
let e = -1 !== t.indexOf("x"),
i = -1 !== t.indexOf("y");
return function(t, s) {
let a = e ? Math.abs(t.x - s.x) : 0,
r = i ? Math.abs(t.y - s.y) : 0;
return Math.sqrt(Math.pow(a, 2) + Math.pow(r, 2))
}
}(i),
l = Number.POSITIVE_INFINITY;
return optimizedEvaluateItems(t, i, e, function(i, h, d) {
let c = i.inRange(e.x, e.y, r);
if (a && !c) return;
let u = i.getCenterPoint(r),
g = (0, s.z)(u, t.chartArea, t._minPadding);
if (!g && !c) return;
let p = o(e, u);
p < l ? (n = [{
element: i,
datasetIndex: h,
index: d
}], l = p) : p === l && n.push({
element: i,
datasetIndex: h,
index: d
})
}), n
}(t, e, i, a, r) : (n = [], optimizedEvaluateItems(t, i, e, function(t, i, a) {
let {
startAngle: o,
endAngle: l
} = t.getProps(["startAngle", "endAngle"], r), {
angle: h
} = (0, s.B)(t, {
x: e.x,
y: e.y
});
(0, s.p)(h, o, l) && n.push({
element: t,
datasetIndex: i,
index: a
})
}), n) : []
}
function getAxisItems(t, e, i, s) {
let a = getRelativePosition(e, t),
r = [],
n = i.axis,
o = "x" === n ? "inXRange" : "inYRange",
l = !1;
return (! function(t, e) {
let i, s, a;
let r = t.getSortedVisibleDatasetMetas();
for (let t = 0, n = r.length; t < n; ++t) {
({
index: i,
data: s
} = r[t]);
for (let t = 0, r = s.length; t < r; ++t)(a = s[t]).skip || e(a, i, t)
}
}(t, (t, e, i) => {
t[o](a[n], s) && r.push({
element: t,
datasetIndex: e,
index: i
}), t.inRange(a.x, a.y, s) && (l = !0)
}), i.intersect && !l) ? [] : r
}
var d = {
modes: {
index(t, e, i, s) {
let a = getRelativePosition(e, t),
r = i.axis || "x",
n = i.intersect ? getIntersectItems(t, a, r, s) : getNearestItems(t, a, r, !1, s),
o = [];
return n.length ? (t.getSortedVisibleDatasetMetas().forEach(t => {
let e = n[0].index,
i = t.data[e];
i && !i.skip && o.push({
element: i,
datasetIndex: t.index,
index: e
})
}), o) : []
},
dataset(t, e, i, s) {
let a = getRelativePosition(e, t),
r = i.axis || "xy",
n = i.intersect ? getIntersectItems(t, a, r, s) : getNearestItems(t, a, r, !1, s);
if (n.length > 0) {
let e = n[0].datasetIndex,
i = t.getDatasetMeta(e).data;
n = [];
for (let t = 0; t < i.length; ++t) n.push({
element: i[t],
datasetIndex: e,
index: t
})
}
return n
},
point(t, e, i, s) {
let a = getRelativePosition(e, t),
r = i.axis || "xy";
return getIntersectItems(t, a, r, s)
},
nearest(t, e, i, s) {
let a = getRelativePosition(e, t),
r = i.axis || "xy";
return getNearestItems(t, a, r, i.intersect, s)
},
x: (t, e, i, s) => getAxisItems(t, e, {
axis: "x",
intersect: i.intersect
}, s),
y: (t, e, i, s) => getAxisItems(t, e, {
axis: "y",
intersect: i.intersect
}, s)
}
};
let c = ["left", "top", "right", "bottom"];
function filterByPosition(t, e) {
return t.filter(t => t.pos === e)
}
function filterDynamicPositionByAxis(t, e) {
return t.filter(t => -1 === c.indexOf(t.pos) && t.box.axis === e)
}
function sortByWeight(t, e) {
return t.sort((t, i) => {
let s = e ? i : t,
a = e ? t : i;
return s.weight === a.weight ? s.index - a.index : s.weight - a.weight
})
}
function getCombinedMax(t, e, i, s) {
return Math.max(t[i], e[i]) + Math.max(t[s], e[s])
}
function updateMaxPadding(t, e) {
t.top = Math.max(t.top, e.top), t.left = Math.max(t.left, e.left), t.bottom = Math.max(t.bottom, e.bottom), t.right = Math.max(t.right, e.right)
}
function fitBoxes(t, e, i, a) {
let r, n, o, l, h, d;
let c = [];
for (r = 0, n = t.length, h = 0; r < n; ++r) {
(l = (o = t[r]).box).update(o.width || e.w, o.height || e.h, function(t, e) {
let i = e.maxPadding;
return function(t) {
let s = {
left: 0,
top: 0,
right: 0,
bottom: 0
};
return t.forEach(t => {
s[t] = Math.max(e[t], i[t])
}), s
}(t ? ["left", "right"] : ["top", "bottom"])
}(o.horizontal, e));
let {
same: n,
other: u
} = function(t, e, i, a) {
let {
pos: r,
box: n
} = i, o = t.maxPadding;
if (!(0, s.i)(r)) {
i.size && (t[r] -= i.size);
let e = a[i.stack] || {
size: 0,
count: 1
};
e.size = Math.max(e.size, i.horizontal ? n.height : n.width), i.size = e.size / e.count, t[r] += i.size
}
n.getPadding && updateMaxPadding(o, n.getPadding());
let l = Math.max(0, e.outerWidth - getCombinedMax(o, t, "left", "right")),
h = Math.max(0, e.outerHeight - getCombinedMax(o, t, "top", "bottom")),
d = l !== t.w,
c = h !== t.h;
return t.w = l, t.h = h, i.horizontal ? {
same: d,
other: c
} : {
same: c,
other: d
}
}(e, i, o, a);
h |= n && c.length, d = d || u, l.fullSize || c.push(o)
}
return h && fitBoxes(c, e, i, a) || d
}
function setBoxDims(t, e, i, s, a) {
t.top = i, t.left = e, t.right = e + s, t.bottom = i + a, t.width = s, t.height = a
}
function placeBoxes(t, e, i, a) {
let r = i.padding,
{
x: n,
y: o
} = e;
for (let l of t) {
let t = l.box,
h = a[l.stack] || {
count: 1,
placed: 0,
weight: 1
},
d = l.stackWeight / h.weight || 1;
if (l.horizontal) {
let a = e.w * d,
n = h.size || t.height;
(0, s.j)(h.start) && (o = h.start), t.fullSize ? setBoxDims(t, r.left, o, i.outerWidth - r.right - r.left, n) : setBoxDims(t, e.left + h.placed, o, a, n), h.start = o, h.placed += a, o = t.bottom
} else {
let a = e.h * d,
o = h.size || t.width;
(0, s.j)(h.start) && (n = h.start), t.fullSize ? setBoxDims(t, n, r.top, o, i.outerHeight - r.bottom - r.top) : setBoxDims(t, n, e.top + h.placed, o, a), h.start = n, h.placed += a, n = t.right
}
}
e.x = n, e.y = o
}
s.d.set("layout", {
autoPadding: !0,
padding: {
top: 0,
right: 0,
bottom: 0,
left: 0
}
});
var u = {
addBox(t, e) {
t.boxes || (t.boxes = []), e.fullSize = e.fullSize || !1, e.position = e.position || "top", e.weight = e.weight || 0, e._layers = e._layers || function() {
return [{
z: 0,
draw(t) {
e.draw(t)
}
}]
}, t.boxes.push(e)
},
removeBox(t, e) {
let i = t.boxes ? t.boxes.indexOf(e) : -1; - 1 !== i && t.boxes.splice(i, 1)
},
configure(t, e, i) {
e.fullSize = i.fullSize, e.position = i.position, e.weight = i.weight
},
update(t, e, i, a) {
if (!t) return;
let r = (0, s.C)(t.options.layout.padding),
n = Math.max(e - r.width, 0),
o = Math.max(i - r.height, 0),
l = function(t) {
let e = function(t) {
let e, i, s, a, r, n;
let o = [];
for (e = 0, i = (t || []).length; e < i; ++e) s = t[e], ({
position: a,
options: {
stack: r,
stackWeight: n = 1
}
} = s), o.push({
index: e,
box: s,
pos: a,
horizontal: s.isHorizontal(),
weight: s.weight,
stack: r && a + r,
stackWeight: n
});
return o
}(t),
i = sortByWeight(e.filter(t => t.box.fullSize), !0),
s = sortByWeight(filterByPosition(e, "left"), !0),
a = sortByWeight(filterByPosition(e, "right")),
r = sortByWeight(filterByPosition(e, "top"), !0),
n = sortByWeight(filterByPosition(e, "bottom")),
o = filterDynamicPositionByAxis(e, "x"),
l = filterDynamicPositionByAxis(e, "y");
return {
fullSize: i,
leftAndTop: s.concat(r),
rightAndBottom: a.concat(l).concat(n).concat(o),
chartArea: filterByPosition(e, "chartArea"),
vertical: s.concat(a).concat(l),
horizontal: r.concat(n).concat(o)
}
}(t.boxes),
h = l.vertical,
d = l.horizontal;
(0, s.D)(t.boxes, t => {
"function" == typeof t.beforeLayout && t.beforeLayout()
});
let u = h.reduce((t, e) => e.box.options && !1 === e.box.options.display ? t : t + 1, 0) || 1,
g = Object.freeze({
outerWidth: e,
outerHeight: i,
padding: r,
availableWidth: n,
availableHeight: o,
vBoxMaxWidth: n / 2 / u,
hBoxMaxHeight: o / 2
}),
p = Object.assign({}, r);
updateMaxPadding(p, (0, s.C)(a));
let f = Object.assign({
maxPadding: p,
w: n,
h: o,
x: r.left,
y: r.top
}, r),
m = function(t, e) {
let i, s, a;
let r = function(t) {
let e = {};
for (let i of t) {
let {
stack: t,
pos: s,
stackWeight: a
} = i;
if (!t || !c.includes(s)) continue;
let r = e[t] || (e[t] = {
count: 0,
placed: 0,
weight: 0,
size: 0
});
r.count++, r.weight += a
}
return e
}(t),
{
vBoxMaxWidth: n,
hBoxMaxHeight: o
} = e;
for (i = 0, s = t.length; i < s; ++i) {
a = t[i];
let {
fullSize: s
} = a.box, l = r[a.stack], h = l && a.stackWeight / l.weight;
a.horizontal ? (a.width = h ? h * n : s && e.availableWidth, a.height = o) : (a.width = n, a.height = h ? h * o : s && e.availableHeight)
}
return r
}(h.concat(d), g);
fitBoxes(l.fullSize, f, g, m), fitBoxes(h, f, g, m), fitBoxes(d, f, g, m) && fitBoxes(h, f, g, m),
function(t) {
let e = t.maxPadding;
function updatePos(i) {
let s = Math.max(e[i] - t[i], 0);
return t[i] += s, s
}
t.y += updatePos("top"), t.x += updatePos("left"), updatePos("right"), updatePos("bottom")
}(f), placeBoxes(l.leftAndTop, f, g, m), f.x += f.w, f.y += f.h, placeBoxes(l.rightAndBottom, f, g, m), t.chartArea = {
left: f.left,
top: f.top,
right: f.left + f.w,
bottom: f.top + f.h,
height: f.h,
width: f.w
}, (0, s.D)(l.chartArea, e => {
let i = e.box;
Object.assign(i, t.chartArea), i.update(f.w, f.h, {
left: 0,
top: 0,
right: 0,
bottom: 0
})
})
}
};
let BasePlatform = class BasePlatform {
acquireContext(t, e) {}
releaseContext(t) {
return !1
}
addEventListener(t, e, i) {}
removeEventListener(t, e, i) {}
getDevicePixelRatio() {
return 1
}
getMaximumSize(t, e, i, s) {
return e = Math.max(0, e || t.width), i = i || t.height, {
width: e,
height: Math.max(0, s ? Math.floor(e / s) : i)
}
}
isAttached(t) {
return !0
}
updateConfig(t) {}
};
let BasicPlatform = class BasicPlatform extends BasePlatform {
acquireContext(t) {
return t && t.getContext && t.getContext("2d") || null
}
updateConfig(t) {
t.options.animation = !1
}
};
let g = "$chartjs",
p = {
touchstart: "mousedown",
touchmove: "mousemove",
touchend: "mouseup",
pointerenter: "mouseenter",
pointerdown: "mousedown",
pointermove: "mousemove",
pointerup: "mouseup",
pointerleave: "mouseout",
pointerout: "mouseout"
},
isNullOrEmpty = t => null === t || "" === t,
f = !!s.J && {
passive: !0
};
function removeListener(t, e, i) {
t.canvas.removeEventListener(e, i, f)
}
function nodeListContains(t, e) {
for (let i of t)
if (i === e || i.contains(e)) return !0
}
function createAttachObserver(t, e, i) {
let s = t.canvas,
a = new MutationObserver(t => {
let e = !1;
for (let i of t) e = (e = e || nodeListContains(i.addedNodes, s)) && !nodeListContains(i.removedNodes, s);
e && i()
});
return a.observe(document, {
childList: !0,
subtree: !0
}), a
}
function createDetachObserver(t, e, i) {
let s = t.canvas,
a = new MutationObserver(t => {
let e = !1;
for (let i of t) e = (e = e || nodeListContains(i.removedNodes, s)) && !nodeListContains(i.addedNodes, s);
e && i()
});
return a.observe(document, {
childList: !0,
subtree: !0
}), a
}
let m = new Map,
x = 0;
function onWindowResize() {
let t = window.devicePixelRatio;
t !== x && (x = t, m.forEach((e, i) => {
i.currentDevicePixelRatio !== t && e()
}))
}
function createResizeObserver(t, e, i) {
let a = t.canvas,
r = a && (0, s.F)(a);
if (!r) return;
let n = (0, s.I)((t, e) => {
let s = r.clientWidth;
i(t, e), s < r.clientWidth && i()
}, window),
o = new ResizeObserver(t => {
let e = t[0],
i = e.contentRect.width,
s = e.contentRect.height;
(0 !== i || 0 !== s) && n(i, s)
});
return o.observe(r), m.size || window.addEventListener("resize", onWindowResize), m.set(t, n), o
}
function releaseObserver(t, e, i) {
i && i.disconnect(), "resize" === e && (m.delete(t), m.size || window.removeEventListener("resize", onWindowResize))
}
function createProxyAndListen(t, e, i) {
let a = t.canvas,
r = (0, s.I)(e => {
null !== t.ctx && i(function(t, e) {
let i = p[t.type] || t.type,
{
x: a,
y: r
} = (0, s.y)(t, e);
return {
type: i,
chart: e,
native: t,
x: void 0 !== a ? a : null,
y: void 0 !== r ? r : null
}
}(e, t))
}, t, t => {
let e = t[0];
return [e, e.offsetX, e.offsetY]
});
return ! function(t, e, i) {
t.addEventListener(e, i, f)
}(a, e, r), r
}
let DomPlatform = class DomPlatform extends BasePlatform {
acquireContext(t, e) {
let i = t && t.getContext && t.getContext("2d");
return i && i.canvas === t ? (! function(t, e) {
let i = t.style,
a = t.getAttribute("height"),
r = t.getAttribute("width");
if (t[g] = {
initial: {
height: a,
width: r,
style: {
display: i.display,
height: i.height,
width: i.width
}
}
}, i.display = i.display || "block", i.boxSizing = i.boxSizing || "border-box", isNullOrEmpty(r)) {
let e = (0, s.G)(t, "width");
void 0 !== e && (t.width = e)
}
if (isNullOrEmpty(a)) {
if ("" === t.style.height) t.height = t.width / (e || 2);
else {
let e = (0, s.G)(t, "height");
void 0 !== e && (t.height = e)
}
}
}(t, e), i) : null
}
releaseContext(t) {
let e = t.canvas;
if (!e[g]) return !1;
let i = e[g].initial;
["height", "width"].forEach(t => {
let a = i[t];
(0, s.k)(a) ? e.removeAttribute(t): e.setAttribute(t, a)
});
let a = i.style || {};
return Object.keys(a).forEach(t => {
e.style[t] = a[t]
}), e.width = e.width, delete e[g], !0
}
addEventListener(t, e, i) {
this.removeEventListener(t, e);
let s = t.$proxies || (t.$proxies = {}),
a = {
attach: createAttachObserver,
detach: createDetachObserver,
resize: createResizeObserver
} [e] || createProxyAndListen;
s[e] = a(t, e, i)
}
removeEventListener(t, e) {
let i = t.$proxies || (t.$proxies = {}),
s = i[e];
if (!s) return;
let a = {
attach: releaseObserver,
detach: releaseObserver,
resize: releaseObserver
} [e] || removeListener;
a(t, e, s), i[e] = void 0
}
getDevicePixelRatio() {
return window.devicePixelRatio
}
getMaximumSize(t, e, i, a) {
return (0, s.E)(t, e, i, a)
}
isAttached(t) {
let e = (0, s.F)(t);
return !!(e && e.isConnected)
}
};
let Element = class Element {
constructor() {
this.x = void 0, this.y = void 0, this.active = !1, this.options = void 0, this.$animations = void 0
}
tooltipPosition(t) {
let {
x: e,
y: i
} = this.getProps(["x", "y"], t);
return {
x: e,
y: i
}
}
hasValue() {
return (0, s.q)(this.x) && (0, s.q)(this.y)
}
getProps(t, e) {
let i = this.$animations;
if (!e || !i) return this;
let s = {};
return t.forEach(t => {
s[t] = i[t] && i[t].active() ? i[t]._to : this[t]
}), s
}
};
Element.defaults = {}, Element.defaultRoutes = void 0;
let b = {
values: t => (0, s.b)(t) ? t : "" + t,
numeric(t, e, i) {
let a;
if (0 === t) return "0";
let r = this.chart.options.locale,
n = t;
if (i.length > 1) {
let e;
let s = Math.max(Math.abs(i[0].value), Math.abs(i[i.length - 1].value));
(s < 1e-4 || s > 1e15) && (a = "scientific"), Math.abs(e = i.length > 3 ? i[2].value - i[1].value : i[1].value - i[0].value) >= 1 && t !== Math.floor(t) && (e = t - Math.floor(t)), n = e
}
let o = (0, s.L)(Math.abs(n)),
l = Math.max(Math.min(-1 * Math.floor(o), 20), 0),
h = {
notation: a,
minimumFractionDigits: l,
maximumFractionDigits: l
};
return Object.assign(h, this.options.ticks.format), (0, s.o)(t, r, h)
},
logarithmic(t, e, i) {
if (0 === t) return "0";
let a = t / Math.pow(10, Math.floor((0, s.L)(t)));
return 1 === a || 2 === a || 5 === a ? b.numeric.call(this, t, e, i) : ""
}
};
var _ = {
formatters: b
};
function skip(t, e, i, a, r) {
let n, o, l;
let h = (0, s.v)(a, 0),
d = Math.min((0, s.v)(r, t.length), t.length),
c = 0;
for (i = Math.ceil(i), r && (i = (n = r - a) / Math.floor(n / i)), l = h; l < 0;) l = Math.round(h + ++c * i);
for (o = Math.max(h, 0); o < d; o++) o === l && (e.push(t[o]), l = Math.round(h + ++c * i))
}
s.d.set("scale", {
display: !0,
offset: !1,
reverse: !1,
beginAtZero: !1,
bounds: "ticks",
grace: 0,
grid: {
display: !0,
lineWidth: 1,
drawBorder: !0,
drawOnChartArea: !0,
drawTicks: !0,
tickLength: 8,
tickWidth: (t, e) => e.lineWidth,
tickColor: (t, e) => e.color,
offset: !1,
borderDash: [],
borderDashOffset: 0,
borderWidth: 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: _.formatters.values,
minor: {},
major: {},
align: "center",
crossAlign: "near",
showLabelBackdrop: !1,
backdropColor: "rgba(255, 255, 255, 0.75)",
backdropPadding: 2
}
}), s.d.route("scale.ticks", "color", "", "color"), s.d.route("scale.grid", "color", "", "borderColor"), s.d.route("scale.grid", "borderColor", "", "borderColor"), s.d.route("scale.title", "color", "", "color"), s.d.describe("scale", {
_fallback: !1,
_scriptable: t => !t.startsWith("before") && !t.startsWith("after") && "callback" !== t && "parser" !== t,
_indexable: t => "borderDash" !== t && "tickBorderDash" !== t
}), s.d.describe("scales", {
_fallback: "scale"
}), s.d.describe("scale.ticks", {
_scriptable: t => "backdropPadding" !== t && "callback" !== t,
_indexable: t => "backdropPadding" !== t
});
let reverseAlign = t => "left" === t ? "right" : "right" === t ? "left" : t,
offsetFromEdge = (t, e, i) => "top" === e || "left" === e ? t[e] + i : t[e] - i;
function sample(t, e) {
let i = [],
s = t.length / e,
a = t.length,
r = 0;
for (; r < a; r += s) i.push(t[Math.floor(r)]);
return i
}
function getTickMarkLength(t) {
return t.drawTicks ? t.tickLength : 0
}
function getTitleHeight(t, e) {
if (!t.display) return 0;
let i = (0, s.Z)(t.font, e),
a = (0, s.C)(t.padding),
r = (0, s.b)(t.text) ? t.text.length : 1;
return r * i.lineHeight + a.height
}
let Scale = class Scale extends Element {
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: i,
_suggestedMax: a
} = this;
return t = (0, s.N)(t, Number.POSITIVE_INFINITY), e = (0, s.N)(e, Number.NEGATIVE_INFINITY), i = (0, s.N)(i, Number.POSITIVE_INFINITY), a = (0, s.N)(a, Number.NEGATIVE_INFINITY), {
min: (0, s.N)(t, i),
max: (0, s.N)(e, a),
minDefined: (0, s.g)(t),
maxDefined: (0, s.g)(e)
}
}
getMinMax(t) {
let e, {
min: i,
max: a,
minDefined: r,
maxDefined: n
} = this.getUserBounds();
if (r && n) return {
min: i,
max: a
};
let o = this.getMatchingVisibleMetas();
for (let s = 0, l = o.length; s < l; ++s) e = o[s].controller.getMinMax(this, t), r || (i = Math.min(i, e.min)), n || (a = Math.max(a, e.max));
return i = n && i > a ? a : i, a = r && i > a ? i : a, {
min: (0, s.N)(i, (0, s.N)(a, i)),
max: (0, s.N)(a, (0, s.N)(i, a))
}
}
getPadding() {
return {
left: this.paddingLeft || 0,
top: this.paddingTop || 0,
right: this.paddingRight || 0,
bottom: this.paddingBottom || 0
}
}
getTicks() {
return this.ticks
}
getLabels() {
let t = this.chart.data;
return this.options.labels || (this.isHorizontal() ? t.xLabels : t.yLabels) || t.labels || []
}
beforeLayout() {
this._cache = {}, this._dataLimitsCached = !1
}
beforeUpdate() {
(0, s.O)(this.options.beforeUpdate, [this])
}
update(t, e, i) {
let {
beginAtZero: a,
grace: r,
ticks: n
} = this.options, o = n.sampleSize;
this.beforeUpdate(), this.maxWidth = t, this.maxHeight = e, this._margins = i = Object.assign({
left: 0,
right: 0,
top: 0,
bottom: 0
}, i), this.ticks = null, this._labelSizes = null, this._gridLineItems = null, this._labelItems = null, this.beforeSetDimensions(), this.setDimensions(), this.afterSetDimensions(), this._maxLength = this.isHorizontal() ? this.width + i.left + i.right : this.height + i.top + i.bottom, this._dataLimitsCached || (this.beforeDataLimits(), this.determineDataLimits(), this.afterDataLimits(), this._range = (0, s.Q)(this, r, a), this._dataLimitsCached = !0), this.beforeBuildTicks(), this.ticks = this.buildTicks() || [], this.afterBuildTicks();
let l = o < this.ticks.length;
this._convertTicksToLabels(l ? sample(this.ticks, o) : this.ticks), this.configure(), this.beforeCalculateLabelRotation(), this.calculateLabelRotation(), this.afterCalculateLabelRotation(), n.display && (n.autoSkip || "auto" === n.source) && (this.ticks = function(t, e) {
let i = t.options.ticks,
a = i.maxTicksLimit || function(t) {
let e = t.options.offset,
i = t._tickSize(),
s = t._length / i + (e ? 0 : 1),
a = t._maxLength / i;
return Math.floor(Math.min(s, a))
}(t),
r = i.major.enabled ? function(t) {
let e, i;
let s = [];
for (e = 0, i = t.length; e < i; e++) t[e].major && s.push(e);
return s
}(e) : [],
n = r.length,
o = r[0],
l = r[n - 1],
h = [];
if (n > a) return function(t, e, i, s) {
let a, r = 0,
n = i[0];
for (a = 0, s = Math.ceil(s); a < t.length; a++) a === n && (e.push(t[a]), n = i[++r * s])
}(e, h, r, n / a), h;
let d = function(t, e, i) {
let a = function(t) {
let e, i;
let s = t.length;
if (s < 2) return !1;
for (i = t[0], e = 1; e < s; ++e)
if (t[e] - t[e - 1] !== i) return !1;
return i
}(t),
r = e.length / i;
if (!a) return Math.max(r, 1);
let n = (0, s.M)(a);
for (let t = 0, e = n.length - 1; t < e; t++) {
let e = n[t];
if (e > r) return e
}
return Math.max(r, 1)
}(r, e, a);
if (n > 0) {
let t, i;
let a = n > 1 ? Math.round((l - o) / (n - 1)) : null;
for (skip(e, h, d, (0, s.k)(a) ? 0 : o - a, o), t = 0, i = n - 1; t < i; t++) skip(e, h, d, r[t], r[t + 1]);
return skip(e, h, d, l, (0, s.k)(a) ? e.length : l + a), h
}
return skip(e, h, d), h
}(this, this.ticks), this._labelSizes = null), l && this._convertTicksToLabels(this.ticks), this.beforeFit(), this.fit(), this.afterFit(), this.afterUpdate()
}
configure() {
let t, e, i = this.options.reverse;
this.isHorizontal() ? (t = this.left, e = this.right) : (t = this.top, e = this.bottom, i = !i), this._startPixel = t, this._endPixel = e, this._reversePixels = i, this._length = e - t, this._alignToPixels = this.options.alignToPixels
}
afterUpdate() {
(0, s.O)(this.options.afterUpdate, [this])
}
beforeSetDimensions() {
(0, s.O)(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() {
(0, s.O)(this.options.afterSetDimensions, [this])
}
_callHooks(t) {
this.chart.notifyPlugins(t, this.getContext()), (0, s.O)(this.options[t], [this])
}
beforeDataLimits() {
this._callHooks("beforeDataLimits")
}
determineDataLimits() {}
afterDataLimits() {
this._callHooks("afterDataLimits")
}
beforeBuildTicks() {
this._callHooks("beforeBuildTicks")
}
buildTicks() {
return []
}
afterBuildTicks() {
this._callHooks("afterBuildTicks")
}
beforeTickToLabelConversion() {
(0, s.O)(this.options.beforeTickToLabelConversion, [this])
}
generateTickLabels(t) {
let e, i, a;
let r = this.options.ticks;
for (e = 0, i = t.length; e < i; e++)(a = t[e]).label = (0, s.O)(r.callback, [a.value, e, t], this)
}
afterTickToLabelConversion() {
(0, s.O)(this.options.afterTickToLabelConversion, [this])
}
beforeCalculateLabelRotation() {
(0, s.O)(this.options.beforeCalculateLabelRotation, [this])
}
calculateLabelRotation() {
let t, e, i;
let a = this.options,
r = a.ticks,
n = this.ticks.length,
o = r.minRotation || 0,
l = r.maxRotation,
h = o;
if (!this._isVisible() || !r.display || o >= l || n <= 1 || !this.isHorizontal()) {
this.labelRotation = o;
return
}
let d = this._getLabelSizes(),
c = d.widest.width,
u = d.highest.height,
g = (0, s.w)(this.chart.width - c, 0, this.maxWidth);
c + 6 > (t = a.offset ? this.maxWidth / n : g / (n - 1)) && (t = g / (n - (a.offset ? .5 : 1)), e = this.maxHeight - getTickMarkLength(a.grid) - r.padding - getTitleHeight(a.title, this.chart.options.font), i = Math.sqrt(c * c + u * u), h = Math.max(o, Math.min(l, h = (0, s.R)(Math.min(Math.asin((0, s.w)((d.highest.height + 6) / t, -1, 1)), Math.asin((0, s.w)(e / i, -1, 1)) - Math.asin((0, s.w)(u / i, -1, 1))))))), this.labelRotation = h
}
afterCalculateLabelRotation() {
(0, s.O)(this.options.afterCalculateLabelRotation, [this])
}
beforeFit() {
(0, s.O)(this.options.beforeFit, [this])
}
fit() {
let t = {
width: 0,
height: 0
},
{
chart: e,
options: {
ticks: i,
title: a,
grid: r
}
} = this,
n = this._isVisible(),
o = this.isHorizontal();
if (n) {
let n = getTitleHeight(a, e.options.font);
if (o ? (t.width = this.maxWidth, t.height = getTickMarkLength(r) + n) : (t.height = this.maxHeight, t.width = getTickMarkLength(r) + n), i.display && this.ticks.length) {
let {
first: e,
last: a,
widest: r,
highest: n
} = this._getLabelSizes(), l = 2 * i.padding, h = (0, s.t)(this.labelRotation), d = Math.cos(h), c = Math.sin(h);
if (o) {
let e = i.mirror ? 0 : c * r.width + d * n.height;
t.height = Math.min(this.maxHeight, t.height + e + l)
} else {
let e = i.mirror ? 0 : d * r.width + c * n.height;
t.width = Math.min(this.maxWidth, t.width + e + l)
}
this._calculatePadding(e, a, c, d)
}
}
this._handleMargins(), o ? (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, i, s) {
let {
ticks: {
align: a,
padding: r
},
position: n
} = this.options, o = 0 !== this.labelRotation, l = "top" !== n && "x" === this.axis;
if (this.isHorizontal()) {
let n = this.getPixelForTick(0) - this.left,
h = this.right - this.getPixelForTick(this.ticks.length - 1),
d = 0,
c = 0;
o ? l ? (d = s * t.width, c = i * e.height) : (d = i * t.height, c = s * e.width) : "start" === a ? c = e.width : "end" === a ? d = t.width : (d = t.width / 2, c = e.width / 2), this.paddingLeft = Math.max((d - n + r) * this.width / (this.width - n), 0), this.paddingRight = Math.max((c - h + r) * this.width / (this.width - h), 0)
} else {
let i = e.height / 2,
s = t.height / 2;
"start" === a ? (i = 0, s = t.height) : "end" === a && (i = e.height, s = 0), this.paddingTop = i + r, this.paddingBottom = s + 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() {
(0, s.O)(this.options.afterFit, [this])
}
isHorizontal() {
let {
axis: t,
position: e
} = this.options;
return "top" === e || "bottom" === e || "x" === t
}
isFullSize() {
return this.options.fullSize
}
_convertTicksToLabels(t) {
let e, i;
for (this.beforeTickToLabelConversion(), this.generateTickLabels(t), e = 0, i = t.length; e < i; e++)(0, s.k)(t[e].label) && (t.splice(e, 1), i--, e--);
this.afterTickToLabelConversion()
}
_getLabelSizes() {
let t = this._labelSizes;
if (!t) {
let e = this.options.ticks.sampleSize,
i = this.ticks;
e < i.length && (i = sample(i, e)), this._labelSizes = t = this._computeLabelSizes(i, i.length)
}
return t
}
_computeLabelSizes(t, e) {
let i, a, r, n, o, l, h, d, c, u, g;
let {
ctx: p,
_longestTextCache: f
} = this, m = [], x = [], b = 0, _ = 0;
for (i = 0; i < e; ++i) {
if (n = t[i].label, o = this._resolveTickFontOptions(i), p.font = l = o.string, h = f[l] = f[l] || {
data: {},
gc: []
}, d = o.lineHeight, c = u = 0, (0, s.k)(n) || (0, s.b)(n)) {
if ((0, s.b)(n))
for (a = 0, r = n.length; a < r; ++a) g = n[a], (0, s.k)(g) || (0, s.b)(g) || (c = (0, s.S)(p, h.data, h.gc, c, g), u += d)
} else c = (0, s.S)(p, h.data, h.gc, c, n), u = d;
m.push(c), x.push(u), b = Math.max(c, b), _ = Math.max(u, _)
}(0, s.D)(f, t => {
let i;
let s = t.gc,
a = s.length / 2;
if (a > e) {
for (i = 0; i < a; ++i) delete t.data[s[i]];
s.splice(0, a)
}
});
let v = m.indexOf(b),
y = x.indexOf(_),
valueAt = t => ({
width: m[t] || 0,
height: x[t] || 0
});
return {
first: valueAt(0),
last: valueAt(e - 1),
widest: valueAt(v),
highest: valueAt(y),
widths: m,
heights: x
}
}
getLabelForValue(t) {
return t
}
getPixelForValue(t, e) {
return NaN
}
getValueForPixel(t) {}
getPixelForTick(t) {
let e = this.ticks;
return t < 0 || t > e.length - 1 ? null : this.getPixelForValue(e[t].value)
}
getPixelForDecimal(t) {
this._reversePixels && (t = 1 - t);
let e = this._startPixel + t * this._length;
return (0, s.U)(this._alignToPixels ? (0, s.V)(this.chart, e, 0) : e)
}
getDecimalForPixel(t) {
let e = (t - this._startPixel) / this._length;
return this._reversePixels ? 1 - e : e
}
getBasePixel() {
return this.getPixelForValue(this.getBaseValue())
}
getBaseValue() {
let {
min: t,
max: e
} = this;
return t < 0 && e < 0 ? e : t > 0 && e > 0 ? t : 0
}
getContext(t) {
var e, i;
let a = this.ticks || [];
if (t >= 0 && t < a.length) {
let i = a[t];
return i.$context || (i.$context = (e = this.getContext(), (0, s.h)(e, {
tick: i,
index: t,
type: "tick"
})))
}
return this.$context || (this.$context = (i = this.chart.getContext(), (0, s.h)(i, {
scale: this,
type: "scale"
})))
}
_tickSize() {
let t = this.options.ticks,
e = (0, s.t)(this.labelRotation),
i = Math.abs(Math.cos(e)),
a = Math.abs(Math.sin(e)),
r = this._getLabelSizes(),
n = t.autoSkipPadding || 0,
o = r ? r.widest.width + n : 0,
l = r ? r.highest.height + n : 0;
return this.isHorizontal() ? l * i > o * a ? o / i : l / a : l * a < o * i ? l / i : o / a
}
_isVisible() {
let t = this.options.display;
return "auto" !== t ? !!t : this.getMatchingVisibleMetas().length > 0
}
_computeGridLineItems(t) {
let e, i, a, r, n, o, l, h, d, c, u, g;
let p = this.axis,
f = this.chart,
m = this.options,
{
grid: x,
position: b
} = m,
_ = x.offset,
v = this.isHorizontal(),
y = this.ticks,
k = y.length + (_ ? 1 : 0),
M = getTickMarkLength(x),
w = [],
S = x.setContext(this.getContext()),
D = S.drawBorder ? S.borderWidth : 0,
C = D / 2,
alignBorderValue = function(t) {
return (0, s.V)(f, t, D)
};
if ("top" === b) e = alignBorderValue(this.bottom), o = this.bottom - M, h = e - C, c = alignBorderValue(t.top) + C, g = t.bottom;
else if ("bottom" === b) e = alignBorderValue(this.top), c = t.top, g = alignBorderValue(t.bottom) - C, o = e + C, h = this.top + M;
else if ("left" === b) e = alignBorderValue(this.right), n = this.right - M, l = e - C, d = alignBorderValue(t.left) + C, u = t.right;
else if ("right" === b) e = alignBorderValue(this.left), d = t.left, u = alignBorderValue(t.right) - C, n = e + C, l = this.left + M;
else if ("x" === p) {
if ("center" === b) e = alignBorderValue((t.top + t.bottom) / 2 + .5);
else if ((0, s.i)(b)) {
let t = Object.keys(b)[0],
i = b[t];
e = alignBorderValue(this.chart.scales[t].getPixelForValue(i))
}
c = t.top, g = t.bottom, h = (o = e + C) + M
} else if ("y" === p) {
if ("center" === b) e = alignBorderValue((t.left + t.right) / 2);
else if ((0, s.i)(b)) {
let t = Object.keys(b)[0],
i = b[t];
e = alignBorderValue(this.chart.scales[t].getPixelForValue(i))
}
l = (n = e - C) - M, d = t.left, u = t.right
}
let P = (0, s.v)(m.ticks.maxTicksLimit, k),
L = Math.max(1, Math.ceil(k / P));
for (i = 0; i < k; i += L) {
let t = x.setContext(this.getContext(i)),
e = t.lineWidth,
p = t.color,
m = x.borderDash || [],
b = t.borderDashOffset,
y = t.tickWidth,
k = t.tickColor,
M = t.tickBorderDash || [],
S = t.tickBorderDashOffset;
void 0 !== (a = function(t, e, i) {
let s;
let a = t.ticks.length,
r = Math.min(e, a - 1),
n = t._startPixel,
o = t._endPixel,
l = t.getPixelForTick(r);
if (!i || (s = 1 === a ? Math.max(l - n, o - l) : 0 === e ? (t.getPixelForTick(1) - l) / 2 : (l - t.getPixelForTick(r - 1)) / 2, !((l += r < e ? s : -s) < n - 1e-6) && !(l > o + 1e-6))) return l
}(this, i, _)) && (r = (0, s.V)(f, a, e), v ? n = l = d = u = r : o = h = c = g = r, w.push({
tx1: n,
ty1: o,
tx2: l,
ty2: h,
x1: d,
y1: c,
x2: u,
y2: g,
width: e,
color: p,
borderDash: m,
borderDashOffset: b,
tickWidth: y,
tickColor: k,
tickBorderDash: M,
tickBorderDashOffset: S
}))
}
return this._ticksLength = k, this._borderValue = e, w
}
_computeLabelItems(t) {
let e, i, a, r, n, o, l, h, d, c, u;
let g = this.axis,
p = this.options,
{
position: f,
ticks: m
} = p,
x = this.isHorizontal(),
b = this.ticks,
{
align: _,
crossAlign: v,
padding: y,
mirror: k
} = m,
M = getTickMarkLength(p.grid),
w = M + y,
S = k ? -y : w,
D = -(0, s.t)(this.labelRotation),
C = [],
P = "middle";
if ("top" === f) n = this.bottom - S, o = this._getXAxisLabelAlignment();
else if ("bottom" === f) n = this.top + S, o = this._getXAxisLabelAlignment();
else if ("left" === f) {
let t = this._getYAxisLabelAlignment(M);
o = t.textAlign, r = t.x
} else if ("right" === f) {
let t = this._getYAxisLabelAlignment(M);
o = t.textAlign, r = t.x
} else if ("x" === g) {
if ("center" === f) n = (t.top + t.bottom) / 2 + w;
else if ((0, s.i)(f)) {
let t = Object.keys(f)[0],
e = f[t];
n = this.chart.scales[t].getPixelForValue(e) + w
}
o = this._getXAxisLabelAlignment()
} else if ("y" === g) {
if ("center" === f) r = (t.left + t.right) / 2 - w;
else if ((0, s.i)(f)) {
let t = Object.keys(f)[0],
e = f[t];
r = this.chart.scales[t].getPixelForValue(e)
}
o = this._getYAxisLabelAlignment(M).textAlign
}
"y" === g && ("start" === _ ? P = "top" : "end" === _ && (P = "bottom"));
let L = this._getLabelSizes();
for (e = 0, i = b.length; e < i; ++e) {
let t;
a = b[e].label;
let i = m.setContext(this.getContext(e));
l = this.getPixelForTick(e) + m.labelOffset, d = (h = this._resolveTickFontOptions(e)).lineHeight, c = (0, s.b)(a) ? a.length : 1;
let g = c / 2,
p = i.color,
_ = i.textStrokeColor,
y = i.textStrokeWidth;
if (x ? (r = l, u = "top" === f ? "near" === v || 0 !== D ? -c * d + d / 2 : "center" === v ? -L.highest.height / 2 - g * d + d : -L.highest.height + d / 2 : "near" === v || 0 !== D ? d / 2 : "center" === v ? L.highest.height / 2 - g * d : L.highest.height - c * d, k && (u *= -1)) : (n = l, u = (1 - c) * d / 2), i.showLabelBackdrop) {
let a = (0, s.C)(i.backdropPadding),
l = L.heights[e],
h = L.widths[e],
d = n + u - a.top,
c = r - a.left;
switch (P) {
case "middle":
d -= l / 2;
break;
case "bottom":
d -= l
}
switch (o) {
case "center":
c -= h / 2;
break;
case "right":
c -= h
}
t = {
left: c,
top: d,
width: h + a.width,
height: l + a.height,
color: i.backdropColor
}
}
C.push({
rotation: D,
label: a,
font: h,
color: p,
strokeColor: _,
strokeWidth: y,
textOffset: u,
textAlign: o,
textBaseline: P,
translation: [r, n],
backdrop: t
})
}
return C
}
_getXAxisLabelAlignment() {
let {
position: t,
ticks: e
} = this.options, i = -(0, s.t)(this.labelRotation);
if (i) return "top" === t ? "left" : "right";
let a = "center";
return "start" === e.align ? a = "left" : "end" === e.align && (a = "right"), a
}
_getYAxisLabelAlignment(t) {
let e, i;
let {
position: s,
ticks: {
crossAlign: a,
mirror: r,
padding: n
}
} = this.options, o = this._getLabelSizes(), l = t + n, h = o.widest.width;
return "left" === s ? r ? (i = this.right + n, "near" === a ? e = "left" : "center" === a ? (e = "center", i += h / 2) : (e = "right", i += h)) : (i = this.right - l, "near" === a ? e = "right" : "center" === a ? (e = "center", i -= h / 2) : (e = "left", i = this.left)) : "right" === s ? r ? (i = this.left + n, "near" === a ? e = "right" : "center" === a ? (e = "center", i -= h / 2) : (e = "left", i -= h)) : (i = this.left + l, "near" === a ? e = "left" : "center" === a ? (e = "center", i += h / 2) : (e = "right", i = this.right)) : e = "right", {
textAlign: e,
x: i
}
}
_computeLabelArea() {
if (this.options.ticks.mirror) return;
let t = this.chart,
e = this.options.position;
return "left" === e || "right" === e ? {
top: 0,
left: this.left,
bottom: t.height,
right: this.right
} : "top" === e || "bottom" === e ? {
top: this.top,
left: 0,
bottom: this.bottom,
right: t.width
} : void 0
}
drawBackground() {
let {
ctx: t,
options: {
backgroundColor: e
},
left: i,
top: s,
width: a,
height: r
} = this;
e && (t.save(), t.fillStyle = e, t.fillRect(i, s, a, r), t.restore())
}
getLineWidthForValue(t) {
let e = this.options.grid;
if (!this._isVisible() || !e.display) return 0;
let i = this.ticks,
s = i.findIndex(e => e.value === t);
if (s >= 0) {
let t = e.setContext(this.getContext(s));
return t.lineWidth
}
return 0
}
drawGrid(t) {
let e, i;
let s = this.options.grid,
a = this.ctx,
r = this._gridLineItems || (this._gridLineItems = this._computeGridLineItems(t)),
drawLine = (t, e, i) => {
i.width && i.color && (a.save(), a.lineWidth = i.width, a.strokeStyle = i.color, a.setLineDash(i.borderDash || []), a.lineDashOffset = i.borderDashOffset, a.beginPath(), a.moveTo(t.x, t.y), a.lineTo(e.x, e.y), a.stroke(), a.restore())
};
if (s.display)
for (e = 0, i = r.length; e < i; ++e) {
let t = r[e];
s.drawOnChartArea && drawLine({
x: t.x1,
y: t.y1
}, {
x: t.x2,
y: t.y2
}, t), s.drawTicks && drawLine({
x: t.tx1,
y: t.ty1
}, {
x: t.tx2,
y: t.ty2
}, {
color: t.tickColor,
width: t.tickWidth,
borderDash: t.tickBorderDash,
borderDashOffset: t.tickBorderDashOffset
})
}
}
drawBorder() {
let t, e, i, a;
let {
chart: r,
ctx: n,
options: {
grid: o
}
} = this, l = o.setContext(this.getContext()), h = o.drawBorder ? l.borderWidth : 0;
if (!h) return;
let d = o.setContext(this.getContext(0)).lineWidth,
c = this._borderValue;
this.isHorizontal() ? (t = (0, s.V)(r, this.left, h) - h / 2, e = (0, s.V)(r, this.right, d) + d / 2, i = a = c) : (i = (0, s.V)(r, this.top, h) - h / 2, a = (0, s.V)(r, this.bottom, d) + d / 2, t = e = c), n.save(), n.lineWidth = l.borderWidth, n.strokeStyle = l.borderColor, n.beginPath(), n.moveTo(t, i), n.lineTo(e, a), n.stroke(), n.restore()
}
drawLabels(t) {
let e, i;
let a = this.options.ticks;
if (!a.display) return;
let r = this.ctx,
n = this._computeLabelArea();
n && (0, s.W)(r, n);
let o = this._labelItems || (this._labelItems = this._computeLabelItems(t));
for (e = 0, i = o.length; e < i; ++e) {
let t = o[e],
i = t.font,
a = t.label;
t.backdrop && (r.fillStyle = t.backdrop.color, r.fillRect(t.backdrop.left, t.backdrop.top, t.backdrop.width, t.backdrop.height));
let n = t.textOffset;
(0, s.X)(r, a, 0, n, i, t)
}
n && (0, s.Y)(r)
}
drawTitle() {
let t;
let {
ctx: e,
options: {
position: i,
title: a,
reverse: r
}
} = this;
if (!a.display) return;
let n = (0, s.Z)(a.font),
o = (0, s.C)(a.padding),
l = a.align,
h = n.lineHeight / 2;
"bottom" === i || "center" === i || (0, s.i)(i) ? (h += o.bottom, (0, s.b)(a.text) && (h += n.lineHeight * (a.text.length - 1))) : h += o.top;
let {
titleX: d,
titleY: c,
maxWidth: u,
rotation: g
} = function(t, e, i, a) {
let r, n, o;
let {
top: l,
left: h,
bottom: d,
right: c,
chart: u
} = t, {
chartArea: g,
scales: p
} = u, f = 0, m = d - l, x = c - h;
if (t.isHorizontal()) {
if (n = (0, s.a0)(a, h, c), (0, s.i)(i)) {
let t = Object.keys(i)[0],
s = i[t];
o = p[t].getPixelForValue(s) + m - e
} else o = "center" === i ? (g.bottom + g.top) / 2 + m - e : offsetFromEdge(t, i, e);
r = c - h
} else {
if ((0, s.i)(i)) {
let t = Object.keys(i)[0],
s = i[t];
n = p[t].getPixelForValue(s) - x + e
} else n = "center" === i ? (g.left + g.right) / 2 - x + e : offsetFromEdge(t, i, e);
o = (0, s.a0)(a, d, l), f = "left" === i ? -s.H : s.H
}
return {
titleX: n,
titleY: o,
maxWidth: r,
rotation: f
}
}(this, h, i, l);
(0, s.X)(e, a.text, 0, 0, n, {
color: a.color,
maxWidth: u,
rotation: g,
textAlign: (t = (0, s.$)(l), (r && "right" !== i || !r && "right" === i) && (t = reverseAlign(t)), t),
textBaseline: "middle",
translation: [d, c]
})
}
draw(t) {
this._isVisible() && (this.drawBackground(), this.drawGrid(t), this.drawBorder(), this.drawTitle(), this.drawLabels(t))
}
_layers() {
let t = this.options,
e = t.ticks && t.ticks.z || 0,
i = (0, s.v)(t.grid && t.grid.z, -1);
return this._isVisible() && this.draw === Scale.prototype.draw ? [{
z: i,
draw: t => {
this.drawBackground(), this.drawGrid(t), this.drawTitle()
}
}, {
z: i + 1,
draw: () => {
this.drawBorder()
}
}, {
z: e,
draw: t => {
this.drawLabels(t)
}
}] : [{
z: e,
draw: t => {
this.draw(t)
}
}]
}
getMatchingVisibleMetas(t) {
let e, i;
let s = this.chart.getSortedVisibleDatasetMetas(),
a = this.axis + "AxisID",
r = [];
for (e = 0, i = s.length; e < i; ++e) {
let i = s[e];
i[a] !== this.id || t && i.type !== t || r.push(i)
}
return r
}
_resolveTickFontOptions(t) {
let e = this.options.ticks.setContext(this.getContext(t));
return (0, s.Z)(e.font)
}
_maxDigits() {
let t = this._resolveTickFontOptions(0).lineHeight;
return (this.isHorizontal() ? this.width : this.height) / t
}
};
let TypedRegistry = class TypedRegistry {
constructor(t, e, i) {
this.type = t, this.scope = e, this.override = i, this.items = Object.create(null)
}
isForType(t) {
return Object.prototype.isPrototypeOf.call(this.type.prototype, t.prototype)
}
register(t) {
let e;
let i = Object.getPrototypeOf(t);
"id" in i && "defaults" in i && (e = this.register(i));
let a = this.items,
r = t.id,
n = this.scope + "." + r;
if (!r) throw Error("class does not have id: " + t);
return r in a || (a[r] = t, function(t, e, i) {
let a = (0, s.a2)(Object.create(null), [i ? s.d.get(i) : {}, s.d.get(e), t.defaults]);
s.d.set(e, a), t.defaultRoutes && function(t, e) {
Object.keys(e).forEach(i => {
let a = i.split("."),
r = a.pop(),
n = [t].concat(a).join("."),
o = e[i].split("."),
l = o.pop(),
h = o.join(".");
s.d.route(n, r, h, l)
})
}(e, t.defaultRoutes), t.descriptors && s.d.describe(e, t.descriptors)
}(t, n, e), this.override && s.d.override(t.id, t.overrides)), n
}
get(t) {
return this.items[t]
}
unregister(t) {
let e = this.items,
i = t.id,
a = this.scope;
i in e && delete e[i], a && i in s.d[a] && (delete s.d[a][i], this.override && delete s.a1[i])
}
};
var v = new class {
constructor() {
this.controllers = new TypedRegistry(DatasetController, "datasets", !0), this.elements = new TypedRegistry(Element, "elements"), this.plugins = new TypedRegistry(Object, "plugins"), this.scales = new TypedRegistry(Scale, "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, i) {
[...e].forEach(e => {
let a = i || this._getRegistryForType(e);
i || a.isForType(e) || a === this.plugins && e.id ? this._exec(t, a, e) : (0, s.D)(e, e => {
let s = i || this._getRegistryForType(e);
this._exec(t, s, e)
})
})
}
_exec(t, e, i) {
let a = (0, s.a3)(t);
(0, s.O)(i["before" + a], [], i), e[t](i), (0, s.O)(i["after" + a], [], i)
}
_getRegistryForType(t) {
for (let e = 0; e < this._typedRegistries.length; e++) {
let i = this._typedRegistries[e];
if (i.isForType(t)) return i
}
return this.plugins
}
_get(t, e, i) {
let s = e.get(t);
if (void 0 === s) throw Error('"' + t + '" is not a registered ' + i + ".");
return s
}
};
let PluginService = class PluginService {
constructor() {
this._init = []
}
notify(t, e, i, s) {
"beforeInit" === e && (this._init = this._createDescriptors(t, !0), this._notify(this._init, t, "install"));
let a = s ? this._descriptors(t).filter(s) : this._descriptors(t),
r = this._notify(a, t, e, i);
return "afterDestroy" === e && (this._notify(a, t, "stop"), this._notify(this._init, t, "uninstall")), r
}
_notify(t, e, i, a) {
for (let r of (a = a || {}, t)) {
let t = r.plugin,
n = t[i],
o = [e, a, r.options];
if (!1 === (0, s.O)(n, o, t) && a.cancelable) return !1
}
return !0
}
invalidate() {
(0, s.k)(this._cache) || (this._oldCache = this._cache, this._cache = void 0)
}
_descriptors(t) {
if (this._cache) return this._cache;
let e = this._cache = this._createDescriptors(t);
return this._notifyStateChanges(t), e
}
_createDescriptors(t, e) {
let i = t && t.config,
a = (0, s.v)(i.options && i.options.plugins, {}),
r = function(t) {
let e = [],
i = Object.keys(v.plugins.items);
for (let t = 0; t < i.length; t++) e.push(v.getPlugin(i[t]));
let s = t.plugins || [];
for (let t = 0; t < s.length; t++) {
let i = s[t]; - 1 === e.indexOf(i) && e.push(i)
}
return e
}(i);
return !1 !== a || e ? function(t, e, i, s) {
let a = [],
r = t.getContext();
for (let o = 0; o < e.length; o++) {
var n;
let l = e[o],
h = l.id,
d = (n = i[h], s || !1 !== n ? !0 === n ? {} : n : null);
null !== d && a.push({
plugin: l,
options: function(t, e, i, s) {
let a = t.pluginScopeKeys(e),
r = t.getOptionScopes(i, a);
return t.createResolver(r, s, [""], {
scriptable: !1,
indexable: !1,
allKeys: !0
})
}(t.config, l, d, r)
})
}
return a
}(t, r, a, e) : []
}
_notifyStateChanges(t) {
let e = this._oldCache || [],
i = this._cache,
diff = (t, e) => t.filter(t => !e.some(e => t.plugin.id === e.plugin.id));
this._notify(diff(e, i), t, "stop"), this._notify(diff(i, e), t, "start")
}
};
function getIndexAxis(t, e) {
let i = s.d.datasets[t] || {},
a = (e.datasets || {})[t] || {};
return a.indexAxis || e.indexAxis || i.indexAxis || "x"
}
function determineAxis(t, e) {
var i;
return "x" === t || "y" === t ? t : e.axis || ("top" === (i = e.position) || "bottom" === i ? "x" : "left" === i || "right" === i ? "y" : void 0) || t.charAt(0).toLowerCase()
}
function initOptions(t) {
let e = t.options || (t.options = {});
e.plugins = (0, s.v)(e.plugins, {}), e.scales = function(t, e) {
let i = s.a1[t.type] || {
scales: {}
},
a = e.scales || {},
r = getIndexAxis(t.type, e),
n = Object.create(null),
o = Object.create(null);
return Object.keys(a).forEach(t => {
let e = a[t];
if (!(0, s.i)(e)) return console.error(`Invalid scale configuration for scale: ${t}`);
if (e._proxy) return console.warn(`Ignoring resolver passed as options for scale: ${t}`);
let l = determineAxis(t, e),
h = l === r ? "_index_" : "_value_",
d = i.scales || {};
n[l] = n[l] || t, o[t] = (0, s.a9)(Object.create(null), [{
axis: l
}, e, d[l], d[h]])
}), t.data.datasets.forEach(i => {
let r = i.type || t.type,
l = i.indexAxis || getIndexAxis(r, e),
h = s.a1[r] || {},
d = h.scales || {};
Object.keys(d).forEach(t => {
let e;
let r = (e = t, "_index_" === t ? e = l : "_value_" === t && (e = "x" === l ? "y" : "x"), e),
h = i[r + "AxisID"] || n[r] || r;
o[h] = o[h] || Object.create(null), (0, s.a9)(o[h], [{
axis: r
}, a[h], d[t]])
})
}), Object.keys(o).forEach(t => {
let e = o[t];
(0, s.a9)(e, [s.d.scales[e.type], s.d.scale])
}), o
}(t, e)
}
function initData(t) {
return (t = t || {}).datasets = t.datasets || [], t.labels = t.labels || [], t
}
let y = new Map,
k = new Set;
function cachedKeys(t, e) {
let i = y.get(t);
return i || (i = e(), y.set(t, i), k.add(i)), i
}
let addIfFound = (t, e, i) => {
let a = (0, s.f)(e, i);
void 0 !== a && t.add(a)
};
let Config = class Config {
constructor(t) {
var e;
this._config = ((e = (e = t) || {}).data = initData(e.data), initOptions(e), e), this._scopeCache = new Map, this._resolverCache = 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 = initData(t)
}
get options() {
return this._config.options
}
set options(t) {
this._config.options = t
}
get plugins() {
return this._config.plugins
}
update() {
let t = this._config;
this.clearCache(), initOptions(t)
}
clearCache() {
this._scopeCache.clear(), this._resolverCache.clear()
}
datasetScopeKeys(t) {
return cachedKeys(t, () => [
[`datasets.${t}`, ""]
])
}
datasetAnimationScopeKeys(t, e) {
return cachedKeys(`${t}.transition.${e}`, () => [
[`datasets.${t}.transitions.${e}`, `transitions.${e}`],
[`datasets.${t}`, ""]
])
}
datasetElementScopeKeys(t, e) {
return cachedKeys(`${t}-${e}`, () => [
[`datasets.${t}.elements.${e}`, `datasets.${t}`, `elements.${e}`, ""]
])
}
pluginScopeKeys(t) {
let e = t.id,
i = this.type;
return cachedKeys(`${i}-plugin-${e}`, () => [
[`plugins.${e}`, ...t.additionalOptionScopes || []]
])
}
_cachedScopes(t, e) {
let i = this._scopeCache,
s = i.get(t);
return (!s || e) && (s = new Map, i.set(t, s)), s
}
getOptionScopes(t, e, i) {
let {
options: a,
type: r
} = this, n = this._cachedScopes(t, i), o = n.get(e);
if (o) return o;
let l = new Set;
e.forEach(e => {
t && (l.add(t), e.forEach(e => addIfFound(l, t, e))), e.forEach(t => addIfFound(l, a, t)), e.forEach(t => addIfFound(l, s.a1[r] || {}, t)), e.forEach(t => addIfFound(l, s.d, t)), e.forEach(t => addIfFound(l, s.a4, t))
});
let h = Array.from(l);
return 0 === h.length && h.push(Object.create(null)), k.has(e) && n.set(e, h), h
}
chartOptionScopes() {
let {
options: t,
type: e
} = this;
return [t, s.a1[e] || {}, s.d.datasets[e] || {}, {
type: e
}, s.d, s.a4]
}
resolveNamedOptions(t, e, i, a = [""]) {
let r = {
$shared: !0
},
{
resolver: n,
subPrefixes: o
} = getResolver(this._resolverCache, t, a),
l = n;
if (function(t, e) {
let {
isScriptable: i,
isIndexable: a
} = (0, s.a8)(t);
for (let r of e) {
let e = i(r),
n = a(r),
o = (n || e) && t[r];
if (e && ((0, s.a5)(o) || hasFunction(o)) || n && (0, s.b)(o)) return !0
}
return !1
}(n, e)) {
r.$shared = !1, i = (0, s.a5)(i) ? i() : i;
let e = this.createResolver(t, i, o);
l = (0, s.a6)(n, i, e)
}
for (let t of e) r[t] = l[t];
return r
}
createResolver(t, e, i = [""], a) {
let {
resolver: r
} = getResolver(this._resolverCache, t, i);
return (0, s.i)(e) ? (0, s.a6)(r, e, void 0, a) : r
}
};
function getResolver(t, e, i) {
let a = t.get(e);
a || (a = new Map, t.set(e, a));
let r = i.join(),
n = a.get(r);
if (!n) {
let t = (0, s.a7)(e, i);
n = {
resolver: t,
subPrefixes: i.filter(t => !t.toLowerCase().includes("hover"))
}, a.set(r, n)
}
return n
}
let hasFunction = t => (0, s.i)(t) && Object.getOwnPropertyNames(t).reduce((e, i) => e || (0, s.a5)(t[i]), !1),
M = ["top", "bottom", "left", "right", "chartArea"];
function positionIsHorizontal(t, e) {
return "top" === t || "bottom" === t || -1 === M.indexOf(t) && "x" === e
}
function compare2Level(t, e) {
return function(i, s) {
return i[t] === s[t] ? i[e] - s[e] : i[t] - s[t]
}
}
function onAnimationsComplete(t) {
let e = t.chart,
i = e.options.animation;
e.notifyPlugins("afterRender"), (0, s.O)(i && i.onComplete, [t], e)
}
function onAnimationProgress(t) {
let e = t.chart,
i = e.options.animation;
(0, s.O)(i && i.onProgress, [t], e)
}
function getCanvas(t) {
return (0, s.K)() && "string" == typeof t ? t = document.getElementById(t) : t && t.length && (t = t[0]), t && t.canvas && (t = t.canvas), t
}
let w = {},
getChart = t => {
let e = getCanvas(t);
return Object.values(w).filter(t => t.canvas === e).pop()
};
let Chart = class Chart {
constructor(t, e) {
let i = this.config = new Config(e),
r = getCanvas(t),
n = getChart(r);
if (n) throw Error("Canvas is already in use. Chart with ID '" + n.id + "' must be destroyed before the canvas can be reused.");
let o = i.createResolver(i.chartOptionScopes(), this.getContext());
this.platform = new(i.platform || (!(0, s.K)() || "undefined" != typeof OffscreenCanvas && r instanceof OffscreenCanvas ? BasicPlatform : DomPlatform)), this.platform.updateConfig(i);
let l = this.platform.acquireContext(r, o.aspectRatio),
h = l && l.canvas,
d = h && h.height,
c = h && h.width;
if (this.id = (0, s.aa)(), this.ctx = l, this.canvas = h, this.width = c, this.height = d, this._options = o, 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 PluginService, this.$proxies = {}, this._hiddenIndices = {}, this.attached = !1, this._animationsDisabled = void 0, this.$context = void 0, this._doResize = (0, s.ab)(t => this.update(t), o.resizeDelay || 0), this._dataChanges = [], w[this.id] = this, !l || !h) {
console.error("Failed to create chart: can't acquire context from the given item");
return
}
a.listen(this, "complete", onAnimationsComplete), a.listen(this, "progress", onAnimationProgress), this._initialize(), this.attached && this.update()
}
get aspectRatio() {
let {
options: {
aspectRatio: t,
maintainAspectRatio: e
},
width: i,
height: a,
_aspectRatio: r
} = this;
return (0, s.k)(t) ? e && r ? r : a ? i / a : 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
}
_initialize() {
return this.notifyPlugins("beforeInit"), this.options.responsive ? this.resize() : (0, s.ac)(this, this.options.devicePixelRatio), this.bindEvents(), this.notifyPlugins("afterInit"), this
}
clear() {
return (0, s.ad)(this.canvas, this.ctx), this
}
stop() {
return a.stop(this), this
}
resize(t, e) {
a.running(this) ? this._resizeBeforeDraw = {
width: t,
height: e
} : this._resize(t, e)
}
_resize(t, e) {
let i = this.options,
a = this.canvas,
r = i.maintainAspectRatio && this.aspectRatio,
n = this.platform.getMaximumSize(a, t, e, r),
o = i.devicePixelRatio || this.platform.getDevicePixelRatio(),
l = this.width ? "resize" : "attach";
this.width = n.width, this.height = n.height, this._aspectRatio = this.aspectRatio, (0, s.ac)(this, o, !0) && (this.notifyPlugins("resize", {
size: n
}), (0, s.O)(i.onResize, [this, n], this), this.attached && this._doResize(l) && this.render())
}
ensureScalesHaveIDs() {
let t = this.options,
e = t.scales || {};
(0, s.D)(e, (t, e) => {
t.id = e
})
}
buildOrUpdateScales() {
let t = this.options,
e = t.scales,
i = this.scales,
a = Object.keys(i).reduce((t, e) => (t[e] = !1, t), {}),
r = [];
e && (r = r.concat(Object.keys(e).map(t => {
let i = e[t],
s = determineAxis(t, i),
a = "r" === s,
r = "x" === s;
return {
options: i,
dposition: a ? "chartArea" : r ? "bottom" : "left",
dtype: a ? "radialLinear" : r ? "category" : "linear"
}
}))), (0, s.D)(r, e => {
let r = e.options,
n = r.id,
o = determineAxis(n, r),
l = (0, s.v)(r.type, e.dtype);
(void 0 === r.position || positionIsHorizontal(r.position, o) !== positionIsHorizontal(e.dposition)) && (r.position = e.dposition), a[n] = !0;
let h = null;
if (n in i && i[n].type === l) h = i[n];
else {
let t = v.getScale(l);
i[(h = new t({
id: n,
type: l,
ctx: this.ctx,
chart: this
})).id] = h
}
h.init(r, t)
}), (0, s.D)(a, (t, e) => {
t || delete i[e]
}), (0, s.D)(i, t => {
u.configure(this, t, t.options), u.addBox(this, t)
})
}
_updateMetasets() {
let t = this._metasets,
e = this.data.datasets.length,
i = t.length;
if (t.sort((t, e) => t.index - e.index), i > e) {
for (let t = e; t < i; ++t) this._destroyDatasetMeta(t);
t.splice(e, i - e)
}
this._sortedMetasets = t.slice(0).sort(compare2Level("order", "index"))
}
_removeUnreferencedMetasets() {
let {
_metasets: t,
data: {
datasets: e
}
} = this;
t.length > e.length && delete this._stacks, t.forEach((t, i) => {
0 === e.filter(e => e === t._dataset).length && this._destroyDatasetMeta(i)
})
}
buildOrUpdateControllers() {
let t, e;
let i = [],
a = this.data.datasets;
for (this._removeUnreferencedMetasets(), t = 0, e = a.length; t < e; t++) {
let e = a[t],
r = this.getDatasetMeta(t),
n = e.type || this.config.type;
if (r.type && r.type !== n && (this._destroyDatasetMeta(t), r = this.getDatasetMeta(t)), r.type = n, r.indexAxis = e.indexAxis || getIndexAxis(n, this.options), r.order = e.order || 0, r.index = t, r.label = "" + e.label, r.visible = this.isDatasetVisible(t), r.controller) r.controller.updateIndex(t), r.controller.linkScales();
else {
let e = v.getController(n),
{
datasetElementType: a,
dataElementType: o
} = s.d.datasets[n];
Object.assign(e.prototype, {
dataElementType: v.getElement(o),
datasetElementType: a && v.getElement(a)
}), r.controller = new e(this, t), i.push(r.controller)
}
}
return this._updateMetasets(), i
}
_resetElements() {
(0, s.D)(this.data.datasets, (t, e) => {
this.getDatasetMeta(e).controller.reset()
}, this)
}
reset() {
this._resetElements(), this.notifyPlugins("reset")
}
update(t) {
let e = this.config;
e.update();
let i = this._options = e.createResolver(e.chartOptionScopes(), this.getContext()),
a = this._animationsDisabled = !i.animation;
if (this._updateScales(), this._checkEventBindings(), this._updateHiddenIndices(), this._plugins.invalidate(), !1 === this.notifyPlugins("beforeUpdate", {
mode: t,
cancelable: !0
})) return;
let r = this.buildOrUpdateControllers();
this.notifyPlugins("beforeElementsUpdate");
let n = 0;
for (let t = 0, e = this.data.datasets.length; t < e; t++) {
let {
controller: e
} = this.getDatasetMeta(t), i = !a && -1 === r.indexOf(e);
e.buildOrUpdateElements(i), n = Math.max(+e.getMaxOverflow(), n)
}
n = this._minPadding = i.layout.autoPadding ? n : 0, this._updateLayout(n), a || (0, s.D)(r, t => {
t.reset()
}), this._updateDatasets(t), this.notifyPlugins("afterUpdate", {
mode: t
}), this._layers.sort(compare2Level("z", "_idx"));
let {
_active: o,
_lastEvent: l
} = this;
l ? this._eventHandler(l, !0) : o.length && this._updateHoverStyles(o, o, !0), this.render()
}
_updateScales() {
(0, s.D)(this.scales, t => {
u.removeBox(this, t)
}), this.ensureScalesHaveIDs(), this.buildOrUpdateScales()
}
_checkEventBindings() {
let t = this.options,
e = new Set(Object.keys(this._listeners)),
i = new Set(t.events);
(0, s.ae)(e, i) && !!this._responsiveListeners === t.responsive || (this.unbindEvents(), this.bindEvents())
}
_updateHiddenIndices() {
let {
_hiddenIndices: t
} = this, e = this._getUniformDataChanges() || [];
for (let {
method: i,
start: s,
count: a
}
of e) {
let e = "_removeElements" === i ? -a : a;
! function(t, e, i) {
let s = Object.keys(t);
for (let a of s) {
let s = +a;
if (s >= e) {
let r = t[a];
delete t[a], (i > 0 || s > e) && (t[s + i] = r)
}
}
}(t, s, e)
}
}
_getUniformDataChanges() {
let t = this._dataChanges;
if (!t || !t.length) return;
this._dataChanges = [];
let e = this.data.datasets.length,
makeSet = e => new Set(t.filter(t => t[0] === e).map((t, e) => e + "," + t.splice(1).join(","))),
i = makeSet(0);
for (let t = 1; t < e; t++)
if (!(0, s.ae)(i, makeSet(t))) return;
return Array.from(i).map(t => t.split(",")).map(t => ({
method: t[1],
start: +t[2],
count: +t[3]
}))
}
_updateLayout(t) {
if (!1 === this.notifyPlugins("beforeLayout", {
cancelable: !0
})) return;
u.update(this, this.width, this.height, t);
let e = this.chartArea,
i = e.width <= 0 || e.height <= 0;
this._layers = [], (0, s.D)(this.boxes, t => {
i && "chartArea" === t.position || (t.configure && t.configure(), this._layers.push(...t._layers()))
}, this), this._layers.forEach((t, e) => {
t._idx = e
}), this.notifyPlugins("afterLayout")
}
_updateDatasets(t) {
if (!1 !== this.notifyPlugins("beforeDatasetsUpdate", {
mode: t,
cancelable: !0
})) {
for (let t = 0, e = this.data.datasets.length; t < e; ++t) this.getDatasetMeta(t).controller.configure();
for (let e = 0, i = this.data.datasets.length; e < i; ++e) this._updateDataset(e, (0, s.a5)(t) ? t({
datasetIndex: e
}) : t);
this.notifyPlugins("afterDatasetsUpdate", {
mode: t
})
}
}
_updateDataset(t, e) {
let i = this.getDatasetMeta(t),
s = {
meta: i,
index: t,
mode: e,
cancelable: !0
};
!1 !== this.notifyPlugins("beforeDatasetUpdate", s) && (i.controller._update(e), s.cancelable = !1, this.notifyPlugins("afterDatasetUpdate", s))
}
render() {
!1 !== this.notifyPlugins("beforeRender", {
cancelable: !0
}) && (a.has(this) ? this.attached && !a.running(this) && a.start(this) : (this.draw(), onAnimationsComplete({
chart: this
})))
}
draw() {
let t;
if (this._resizeBeforeDraw) {
let {
width: t,
height: e
} = this._resizeBeforeDraw;
this._resize(t, e), this._resizeBeforeDraw = null
}
if (this.clear(), this.width <= 0 || this.height <= 0 || !1 === this.notifyPlugins("beforeDraw", {
cancelable: !0
})) return;
let 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) {
let e, i;
let s = this._sortedMetasets,
a = [];
for (e = 0, i = s.length; e < i; ++e) {
let i = s[e];
(!t || i.visible) && a.push(i)
}
return a
}
getSortedVisibleDatasetMetas() {
return this._getSortedDatasetMetas(!0)
}
_drawDatasets() {
if (!1 === this.notifyPlugins("beforeDatasetsDraw", {
cancelable: !0
})) return;
let t = this.getSortedVisibleDatasetMetas();
for (let e = t.length - 1; e >= 0; --e) this._drawDataset(t[e]);
this.notifyPlugins("afterDatasetsDraw")
}
_drawDataset(t) {
let e = this.ctx,
i = t._clip,
a = !i.disabled,
r = this.chartArea,
n = {
meta: t,
index: t.index,
cancelable: !0
};
!1 !== this.notifyPlugins("beforeDatasetDraw", n) && (a && (0, s.W)(e, {
left: !1 === i.left ? 0 : r.left - i.left,
right: !1 === i.right ? this.width : r.right + i.right,
top: !1 === i.top ? 0 : r.top - i.top,
bottom: !1 === i.bottom ? this.height : r.bottom + i.bottom
}), t.controller.draw(), a && (0, s.Y)(e), n.cancelable = !1, this.notifyPlugins("afterDatasetDraw", n))
}
getElementsAtEventForMode(t, e, i, s) {
let a = d.modes[e];
return "function" == typeof a ? a(this, t, i, s) : []
}
getDatasetMeta(t) {
let e = this.data.datasets[t],
i = this._metasets,
s = i.filter(t => t && t._dataset === e).pop();
return s || (s = {
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
}, i.push(s)), s
}
getContext() {
return this.$context || (this.$context = (0, s.h)(null, {
chart: this,
type: "chart"
}))
}
getVisibleDatasetCount() {
return this.getSortedVisibleDatasetMetas().length
}
isDatasetVisible(t) {
let e = this.data.datasets[t];
if (!e) return !1;
let i = this.getDatasetMeta(t);
return "boolean" == typeof i.hidden ? !i.hidden : !e.hidden
}
setDatasetVisibility(t, e) {
let i = this.getDatasetMeta(t);
i.hidden = !e
}
toggleDataVisibility(t) {
this._hiddenIndices[t] = !this._hiddenIndices[t]
}
getDataVisibility(t) {
return !this._hiddenIndices[t]
}
_updateVisibility(t, e, i) {
let a = i ? "show" : "hide",
r = this.getDatasetMeta(t),
n = r.controller._resolveAnimations(void 0, a);
(0, s.j)(e) ? (r.data[e].hidden = !i, this.update()) : (this.setDatasetVisibility(t, i), n.update(r, {
visible: i
}), this.update(e => e.datasetIndex === t ? a : void 0))
}
hide(t, e) {
this._updateVisibility(t, e, !1)
}
show(t, e) {
this._updateVisibility(t, e, !0)
}
_destroyDatasetMeta(t) {
let e = this._metasets[t];
e && e.controller && e.controller._destroy(), delete this._metasets[t]
}
_stop() {
let t, e;
for (this.stop(), a.remove(this), t = 0, e = this.data.datasets.length; t < e; ++t) this._destroyDatasetMeta(t)
}
destroy() {
this.notifyPlugins("beforeDestroy");
let {
canvas: t,
ctx: e
} = this;
this._stop(), this.config.clearCache(), t && (this.unbindEvents(), (0, s.ad)(t, e), this.platform.releaseContext(e), this.canvas = null, this.ctx = null), this.notifyPlugins("destroy"), delete w[this.id], this.notifyPlugins("afterDestroy")
}
toBase64Image(...t) {
return this.canvas.toDataURL(...t)
}
bindEvents() {
this.bindUserEvents(), this.options.responsive ? this.bindResponsiveEvents() : this.attached = !0
}
bindUserEvents() {
let t = this._listeners,
e = this.platform,
_add = (i, s) => {
e.addEventListener(this, i, s), t[i] = s
},
listener = (t, e, i) => {
t.offsetX = e, t.offsetY = i, this._eventHandler(t)
};
(0, s.D)(this.options.events, t => _add(t, listener))
}
bindResponsiveEvents() {
let t;
this._responsiveListeners || (this._responsiveListeners = {});
let e = this._responsiveListeners,
i = this.platform,
_add = (t, s) => {
i.addEventListener(this, t, s), e[t] = s
},
_remove = (t, s) => {
e[t] && (i.removeEventListener(this, t, s), delete e[t])
},
listener = (t, e) => {
this.canvas && this.resize(t, e)
},
attached = () => {
_remove("attach", attached), this.attached = !0, this.resize(), _add("resize", listener), _add("detach", t)
};
t = () => {
this.attached = !1, _remove("resize", listener), this._stop(), this._resize(0, 0), _add("attach", attached)
}, i.isAttached(this.canvas) ? attached() : t()
}
unbindEvents() {
(0, s.D)(this._listeners, (t, e) => {
this.platform.removeEventListener(this, e, t)
}), this._listeners = {}, (0, s.D)(this._responsiveListeners, (t, e) => {
this.platform.removeEventListener(this, e, t)
}), this._responsiveListeners = void 0
}
updateHoverStyle(t, e, i) {
let s, a, r;
let n = i ? "set" : "remove";
for ("dataset" === e && this.getDatasetMeta(t[0].datasetIndex).controller["_" + n + "DatasetHoverStyle"](), a = 0, r = t.length; a < r; ++a) {
s = t[a];
let e = s && this.getDatasetMeta(s.datasetIndex).controller;
e && e[n + "HoverStyle"](s.element, s.datasetIndex, s.index)
}
}
getActiveElements() {
return this._active || []
}
setActiveElements(t) {
let e = this._active || [],
i = t.map(({
datasetIndex: t,
index: e
}) => {
let i = this.getDatasetMeta(t);
if (!i) throw Error("No dataset found at index " + t);
return {
datasetIndex: t,
element: i.data[e],
index: e
}
}),
a = !(0, s.af)(i, e);
a && (this._active = i, this._lastEvent = null, this._updateHoverStyles(i, e))
}
notifyPlugins(t, e, i) {
return this._plugins.notify(this, t, e, i)
}
_updateHoverStyles(t, e, i) {
let s = this.options.hover,
diff = (t, e) => t.filter(t => !e.some(e => t.datasetIndex === e.datasetIndex && t.index === e.index)),
a = diff(e, t),
r = i ? t : diff(t, e);
a.length && this.updateHoverStyle(a, s.mode, !1), r.length && s.mode && this.updateHoverStyle(r, s.mode, !0)
}
_eventHandler(t, e) {
let i = {
event: t,
replay: e,
cancelable: !0,
inChartArea: (0, s.z)(t, this.chartArea, this._minPadding)
},
eventFilter = e => (e.options.events || this.options.events).includes(t.native.type);
if (!1 === this.notifyPlugins("beforeEvent", i, eventFilter)) return;
let a = this._handleEvent(t, e, i.inChartArea);
return i.cancelable = !1, this.notifyPlugins("afterEvent", i, eventFilter), (a || i.changed) && this.render(), this
}
_handleEvent(t, e, i) {
var a;
let {
_active: r = [],
options: n
} = this, o = this._getActiveElements(t, r, i, e), l = (0, s.ag)(t), h = (a = this._lastEvent, i && "mouseout" !== t.type ? l ? a : t : null);
i && (this._lastEvent = null, (0, s.O)(n.onHover, [t, o, this], this), l && (0, s.O)(n.onClick, [t, o, this], this));
let d = !(0, s.af)(o, r);
return (d || e) && (this._active = o, this._updateHoverStyles(o, r, e)), this._lastEvent = h, d
}
_getActiveElements(t, e, i, s) {
if ("mouseout" === t.type) return [];
if (!i) return e;
let a = this.options.hover;
return this.getElementsAtEventForMode(t, a.mode, a, s)
}
};
let invalidatePlugins = () => (0, s.D)(Chart.instances, t => t._plugins.invalidate());
function clipArc(t, e, i) {
let {
startAngle: a,
pixelMargin: r,
x: n,
y: o,
outerRadius: l,
innerRadius: h
} = e, d = r / l;
t.beginPath(), t.arc(n, o, l, a - d, i + d), h > r ? (d = r / h, t.arc(n, o, h, i + d, a - d, !0)) : t.arc(n, o, r, i + s.H, a - s.H), t.closePath(), t.clip()
}
function rThetaToXY(t, e, i, s) {
return {
x: i + t * Math.cos(e),
y: s + t * Math.sin(e)
}
}
function pathArc(t, e, i, a, r) {
let {
x: n,
y: o,
startAngle: l,
pixelMargin: h,
innerRadius: d
} = e, c = Math.max(e.outerRadius + a + i - h, 0), u = d > 0 ? d + a + i + h : 0, g = 0, p = r - l;
if (a) {
let t = c > 0 ? c - a : 0,
e = ((d > 0 ? d - a : 0) + t) / 2;
g = (p - (0 !== e ? p * e / (e + a) : p)) / 2
}
let f = Math.max(.001, p * c - i / s.P) / c,
m = (p - f) / 2,
x = l + m + g,
b = r - m - g,
{
outerStart: _,
outerEnd: v,
innerStart: y,
innerEnd: k
} = function(t, e, i, a) {
var r;
let n = (r = t.options.borderRadius, (0, s.ai)(r, ["outerStart", "outerEnd", "innerStart", "innerEnd"])),
o = (i - e) / 2,
l = Math.min(o, a * e / 2),
computeOuterLimit = t => {
let e = (i - Math.min(o, t)) * a / 2;
return (0, s.w)(t, 0, Math.min(o, e))
};
return {
outerStart: computeOuterLimit(n.outerStart),
outerEnd: computeOuterLimit(n.outerEnd),
innerStart: (0, s.w)(n.innerStart, 0, l),
innerEnd: (0, s.w)(n.innerEnd, 0, l)
}
}(e, u, c, b - x),
M = c - _,
w = c - v,
S = x + _ / M,
D = b - v / w,
C = u + y,
P = u + k,
L = x + y / C,
A = b - k / P;
if (t.beginPath(), t.arc(n, o, c, S, D), v > 0) {
let e = rThetaToXY(w, D, n, o);
t.arc(e.x, e.y, v, D, b + s.H)
}
let O = rThetaToXY(P, b, n, o);
if (t.lineTo(O.x, O.y), k > 0) {
let e = rThetaToXY(P, A, n, o);
t.arc(e.x, e.y, k, b + s.H, A + Math.PI)
}
if (t.arc(n, o, u, b - k / u, x + y / u, !0), y > 0) {
let e = rThetaToXY(C, L, n, o);
t.arc(e.x, e.y, y, L + Math.PI, x - s.H)
}
let T = rThetaToXY(M, x, n, o);
if (t.lineTo(T.x, T.y), _ > 0) {
let e = rThetaToXY(M, S, n, o);
t.arc(e.x, e.y, _, x - s.H, S)
}
t.closePath()
}
Object.defineProperties(Chart, {
defaults: {
enumerable: !0,
value: s.d
},
instances: {
enumerable: !0,
value: w
},
overrides: {
enumerable: !0,
value: s.a1
},
registry: {
enumerable: !0,
value: v
},
version: {
enumerable: !0,
value: "3.7.1"
},
getChart: {
enumerable: !0,
value: getChart
},
register: {
enumerable: !0,
value: (...t) => {
v.add(...t), invalidatePlugins()
}
},
unregister: {
enumerable: !0,
value: (...t) => {
v.remove(...t), invalidatePlugins()
}
}
});
let ArcElement = class ArcElement extends Element {
constructor(t) {
super(), 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, t && Object.assign(this, t)
}
inRange(t, e, i) {
let a = this.getProps(["x", "y"], i),
{
angle: r,
distance: n
} = (0, s.B)(a, {
x: t,
y: e
}),
{
startAngle: o,
endAngle: l,
innerRadius: h,
outerRadius: d,
circumference: c
} = this.getProps(["startAngle", "endAngle", "innerRadius", "outerRadius", "circumference"], i),
u = this.options.spacing / 2,
g = (0, s.v)(c, l - o),
p = g >= s.T || (0, s.p)(r, o, l),
f = (0, s.ah)(n, h + u, d + u);
return p && f
}
getCenterPoint(t) {
let {
x: e,
y: i,
startAngle: s,
endAngle: a,
innerRadius: r,
outerRadius: n
} = this.getProps(["x", "y", "startAngle", "endAngle", "innerRadius", "outerRadius", "circumference"], t), {
offset: o,
spacing: l
} = this.options, h = (s + a) / 2, d = (r + n + l + o) / 2;
return {
x: e + Math.cos(h) * d,
y: i + Math.sin(h) * d
}
}
tooltipPosition(t) {
return this.getCenterPoint(t)
}
draw(t) {
let {
options: e,
circumference: i
} = this, a = (e.offset || 0) / 2, r = (e.spacing || 0) / 2;
if (this.pixelMargin = "inner" === e.borderAlign ? .33 : 0, this.fullCircles = i > s.T ? Math.floor(i / s.T) : 0, 0 === i || this.innerRadius < 0 || this.outerRadius < 0) return;
t.save();
let n = 0;
if (a) {
n = a / 2;
let e = (this.startAngle + this.endAngle) / 2;
t.translate(Math.cos(e) * n, Math.sin(e) * n), this.circumference >= s.P && (n = a)
}
t.fillStyle = e.backgroundColor, t.strokeStyle = e.borderColor;
let o = function(t, e, i, a) {
let {
fullCircles: r,
startAngle: n,
circumference: o
} = e, l = e.endAngle;
if (r) {
pathArc(t, e, i, a, n + s.T);
for (let e = 0; e < r; ++e) t.fill();
isNaN(o) || (l = n + o % s.T, o % s.T != 0 || (l += s.T))
}
return pathArc(t, e, i, a, l), t.fill(), l
}(t, this, n, r);
! function(t, e, i, a, r) {
let {
options: n
} = e, {
borderWidth: o,
borderJoinStyle: l
} = n, h = "inner" === n.borderAlign;
o && (h ? (t.lineWidth = 2 * o, t.lineJoin = l || "round") : (t.lineWidth = o, t.lineJoin = l || "bevel"), e.fullCircles && function(t, e, i) {
let a;
let {
x: r,
y: n,
startAngle: o,
pixelMargin: l,
fullCircles: h
} = e, d = Math.max(e.outerRadius - l, 0), c = e.innerRadius + l;
for (i && clipArc(t, e, o + s.T), t.beginPath(), t.arc(r, n, c, o + s.T, o, !0), a = 0; a < h; ++a) t.stroke();
for (t.beginPath(), t.arc(r, n, d, o, o + s.T), a = 0; a < h; ++a) t.stroke()
}(t, e, h), h && clipArc(t, e, r), pathArc(t, e, i, a, r), t.stroke())
}(t, this, n, r, o), t.restore()
}
};
function setStyle(t, e, i = e) {
t.lineCap = (0, s.v)(i.borderCapStyle, e.borderCapStyle), t.setLineDash((0, s.v)(i.borderDash, e.borderDash)), t.lineDashOffset = (0, s.v)(i.borderDashOffset, e.borderDashOffset), t.lineJoin = (0, s.v)(i.borderJoinStyle, e.borderJoinStyle), t.lineWidth = (0, s.v)(i.borderWidth, e.borderWidth), t.strokeStyle = (0, s.v)(i.borderColor, e.borderColor)
}
function lineTo(t, e, i) {
t.lineTo(i.x, i.y)
}
function pathVars(t, e, i = {}) {
let s = t.length,
{
start: a = 0,
end: r = s - 1
} = i,
{
start: n,
end: o
} = e,
l = Math.max(a, n),
h = Math.min(r, o);
return {
count: s,
start: l,
loop: e.loop,
ilen: h < l && !(a < n && r < n || a > o && r > o) ? s + h - l : h - l
}
}
function pathSegment(t, e, i, a) {
let r, n, o;
let {
points: l,
options: h
} = e, {
count: d,
start: c,
loop: u,
ilen: g
} = pathVars(l, i, a), p = h.stepped ? s.ap : h.tension || "monotone" === h.cubicInterpolationMode ? s.aq : lineTo, {
move: f = !0,
reverse: m
} = a || {};
for (r = 0; r <= g; ++r)(n = l[(c + (m ? g - r : r)) % d]).skip || (f ? (t.moveTo(n.x, n.y), f = !1) : p(t, o, n, m, h.stepped), o = n);
return u && p(t, o, n = l[(c + (m ? g : 0)) % d], m, h.stepped), !!u
}
function fastPathSegment(t, e, i, s) {
let a, r, n, o, l, h;
let d = e.points,
{
count: c,
start: u,
ilen: g
} = pathVars(d, i, s),
{
move: p = !0,
reverse: f
} = s || {},
m = 0,
x = 0,
pointIndex = t => (u + (f ? g - t : t)) % c,
drawX = () => {
o !== l && (t.lineTo(m, l), t.lineTo(m, o), t.lineTo(m, h))
};
for (p && (r = d[pointIndex(0)], t.moveTo(r.x, r.y)), a = 0; a <= g; ++a) {
if ((r = d[pointIndex(a)]).skip) continue;
let e = r.x,
i = r.y,
s = 0 | e;
s === n ? (i < o ? o = i : i > l && (l = i), m = (x * m + e) / ++x) : (drawX(), t.lineTo(e, i), n = s, x = 0, o = l = i), h = i
}
drawX()
}
function _getSegmentMethod(t) {
let e = t.options,
i = e.borderDash && e.borderDash.length,
s = !t._decimated && !t._loop && !e.tension && "monotone" !== e.cubicInterpolationMode && !e.stepped && !i;
return s ? fastPathSegment : pathSegment
}
ArcElement.id = "arc", ArcElement.defaults = {
borderAlign: "center",
borderColor: "#fff",
borderJoinStyle: void 0,
borderRadius: 0,
borderWidth: 2,
offset: 0,
spacing: 0,
angle: void 0
}, ArcElement.defaultRoutes = {
backgroundColor: "backgroundColor"
};
let S = "function" == typeof Path2D;
let LineElement = class LineElement extends Element {
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) {
let i = this.options;
if ((i.tension || "monotone" === i.cubicInterpolationMode) && !i.stepped && !this._pointsUpdated) {
let a = i.spanGaps ? this._loop : this._fullLoop;
(0, s.aj)(this._points, i, t, a, 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 = (0, s.ak)(this, this.options.segment))
}
first() {
let t = this.segments,
e = this.points;
return t.length && e[t[0].start]
}
last() {
let t = this.segments,
e = this.points,
i = t.length;
return i && e[t[i - 1].end]
}
interpolate(t, e) {
let i, a;
let r = this.options,
n = t[e],
o = this.points,
l = (0, s.al)(this, {
property: e,
start: n,
end: n
});
if (!l.length) return;
let h = [],
d = r.stepped ? s.am : r.tension || "monotone" === r.cubicInterpolationMode ? s.an : s.ao;
for (i = 0, a = l.length; i < a; ++i) {
let {
start: s,
end: a
} = l[i], c = o[s], u = o[a];
if (c === u) {
h.push(c);
continue
}
let g = Math.abs((n - c[e]) / (u[e] - c[e])),
p = d(c, u, g, r.stepped);
p[e] = t[e], h.push(p)
}
return 1 === h.length ? h[0] : h
}
pathSegment(t, e, i) {
let s = _getSegmentMethod(this);
return s(t, this, e, i)
}
path(t, e, i) {
let s = this.segments,
a = _getSegmentMethod(this),
r = this._loop;
for (let n of (e = e || 0, i = i || this.points.length - e, s)) r &= a(t, this, n, {
start: e,
end: e + i - 1
});
return !!r
}
draw(t, e, i, s) {
let a = this.options || {},
r = this.points || [];
r.length && a.borderWidth && (t.save(), function(t, e, i, s) {
if (S && !e.options.segment) {
let a;
(a = e._path) || (a = e._path = new Path2D, e.path(a, i, s) && a.closePath()), setStyle(t, e.options), t.stroke(a)
} else ! function(t, e, i, s) {
let {
segments: a,
options: r
} = e, n = _getSegmentMethod(e);
for (let o of a) setStyle(t, r, o.style), t.beginPath(), n(t, e, o, {
start: i,
end: i + s - 1
}) && t.closePath(), t.stroke()
}(t, e, i, s)
}(t, this, i, s), t.restore()), this.animated && (this._pointsUpdated = !1, this._path = void 0)
}
};
function inRange$1(t, e, i, s) {
let a = t.options,
{
[i]: r
} = t.getProps([i], s);
return Math.abs(e - r) < a.radius + a.hitRadius
}
LineElement.id = "line", LineElement.defaults = {
borderCapStyle: "butt",
borderDash: [],
borderDashOffset: 0,
borderJoinStyle: "miter",
borderWidth: 3,
capBezierPoints: !0,
cubicInterpolationMode: "default",
fill: !1,
spanGaps: !1,
stepped: !1,
tension: 0
}, LineElement.defaultRoutes = {
backgroundColor: "backgroundColor",
borderColor: "borderColor"
}, LineElement.descriptors = {
_scriptable: !0,
_indexable: t => "borderDash" !== t && "fill" !== t
};
let PointElement = class PointElement extends Element {
constructor(t) {
super(), this.options = void 0, this.parsed = void 0, this.skip = void 0, this.stop = void 0, t && Object.assign(this, t)
}
inRange(t, e, i) {
let s = this.options,
{
x: a,
y: r
} = this.getProps(["x", "y"], i);
return Math.pow(t - a, 2) + Math.pow(e - r, 2) < Math.pow(s.hitRadius + s.radius, 2)
}
inXRange(t, e) {
return inRange$1(this, t, "x", e)
}
inYRange(t, e) {
return inRange$1(this, t, "y", e)
}
getCenterPoint(t) {
let {
x: e,
y: i
} = this.getProps(["x", "y"], t);
return {
x: e,
y: i
}
}
size(t) {
let e = (t = t || this.options || {}).radius || 0;
e = Math.max(e, e && t.hoverRadius || 0);
let i = e && t.borderWidth || 0;
return (e + i) * 2
}
draw(t, e) {
let i = this.options;
!this.skip && !(i.radius < .1) && (0, s.z)(this, e, this.size(i) / 2) && (t.strokeStyle = i.borderColor, t.lineWidth = i.borderWidth, t.fillStyle = i.backgroundColor, (0, s.ar)(t, i, this.x, this.y))
}
getRange() {
let t = this.options || {};
return t.radius + t.hitRadius
}
};
function getBarBounds(t, e) {
let i, s, a, r, n;
let {
x: o,
y: l,
base: h,
width: d,
height: c
} = t.getProps(["x", "y", "base", "width", "height"], e);
return t.horizontal ? (n = c / 2, i = Math.min(o, h), s = Math.max(o, h), a = l - n, r = l + n) : (i = o - (n = d / 2), s = o + n, a = Math.min(l, h), r = Math.max(l, h)), {
left: i,
top: a,
right: s,
bottom: r
}
}
function skipOrLimit(t, e, i, a) {
return t ? 0 : (0, s.w)(e, i, a)
}
function inRange(t, e, i, a) {
let r = null === e,
n = null === i,
o = t && !(r && n) && getBarBounds(t, a);
return o && (r || (0, s.ah)(e, o.left, o.right)) && (n || (0, s.ah)(i, o.top, o.bottom))
}
function addNormalRectPath(t, e) {
t.rect(e.x, e.y, e.w, e.h)
}
function inflateRect(t, e, i = {}) {
let s = t.x !== i.x ? -e : 0,
a = t.y !== i.y ? -e : 0,
r = (t.x + t.w !== i.x + i.w ? e : 0) - s,
n = (t.y + t.h !== i.y + i.h ? e : 0) - a;
return {
x: t.x + s,
y: t.y + a,
w: t.w + r,
h: t.h + n,
radius: t.radius
}
}
PointElement.id = "point", PointElement.defaults = {
borderWidth: 1,
hitRadius: 1,
hoverBorderWidth: 1,
hoverRadius: 4,
pointStyle: "circle",
radius: 3,
rotation: 0
}, PointElement.defaultRoutes = {
backgroundColor: "backgroundColor",
borderColor: "borderColor"
};
let BarElement = class BarElement extends Element {
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) {
var e;
let {
inflateAmount: i,
options: {
borderColor: a,
backgroundColor: r
}
} = this, {
inner: n,
outer: o
} = function(t) {
let e = getBarBounds(t),
i = e.right - e.left,
a = e.bottom - e.top,
r = function(t, e, i) {
let a = t.options.borderWidth,
r = t.borderSkipped,
n = (0, s.at)(a);
return {
t: skipOrLimit(r.top, n.top, 0, i),
r: skipOrLimit(r.right, n.right, 0, e),
b: skipOrLimit(r.bottom, n.bottom, 0, i),
l: skipOrLimit(r.left, n.left, 0, e)
}
}(t, i / 2, a / 2),
n = function(t, e, i) {
let {
enableBorderRadius: a
} = t.getProps(["enableBorderRadius"]), r = t.options.borderRadius, n = (0, s.au)(r), o = Math.min(e, i), l = t.borderSkipped, h = a || (0, s.i)(r);
return {
topLeft: skipOrLimit(!h || l.top || l.left, n.topLeft, 0, o),
topRight: skipOrLimit(!h || l.top || l.right, n.topRight, 0, o),
bottomLeft: skipOrLimit(!h || l.bottom || l.left, n.bottomLeft, 0, o),
bottomRight: skipOrLimit(!h || l.bottom || l.right, n.bottomRight, 0, o)
}
}(t, i / 2, a / 2);
return {
outer: {
x: e.left,
y: e.top,
w: i,
h: a,
radius: n
},
inner: {
x: e.left + r.l,
y: e.top + r.t,
w: i - r.l - r.r,
h: a - r.t - r.b,
radius: {
topLeft: Math.max(0, n.topLeft - Math.max(r.t, r.l)),
topRight: Math.max(0, n.topRight - Math.max(r.t, r.r)),
bottomLeft: Math.max(0, n.bottomLeft - Math.max(r.b, r.l)),
bottomRight: Math.max(0, n.bottomRight - Math.max(r.b, r.r))
}
}
}
}(this), l = (e = o.radius).topLeft || e.topRight || e.bottomLeft || e.bottomRight ? s.as : addNormalRectPath;
t.save(), (o.w !== n.w || o.h !== n.h) && (t.beginPath(), l(t, inflateRect(o, i, n)), t.clip(), l(t, inflateRect(n, -i, o)), t.fillStyle = a, t.fill("evenodd")), t.beginPath(), l(t, inflateRect(n, i)), t.fillStyle = r, t.fill(), t.restore()
}
inRange(t, e, i) {
return inRange(this, t, e, i)
}
inXRange(t, e) {
return inRange(this, t, null, e)
}
inYRange(t, e) {
return inRange(this, null, t, e)
}
getCenterPoint(t) {
let {
x: e,
y: i,
base: s,
horizontal: a
} = this.getProps(["x", "y", "base", "horizontal"], t);
return {
x: a ? (e + s) / 2 : e,
y: a ? i : (i + s) / 2
}
}
getRange(t) {
return "x" === t ? this.width / 2 : this.height / 2
}
};
BarElement.id = "bar", BarElement.defaults = {
borderSkipped: "start",
borderWidth: 0,
borderRadius: 0,
inflateAmount: "auto",
pointStyle: void 0
}, BarElement.defaultRoutes = {
backgroundColor: "backgroundColor",
borderColor: "borderColor"
};
var D = Object.freeze({
__proto__: null,
ArcElement: ArcElement,
LineElement: LineElement,
PointElement: PointElement,
BarElement: BarElement
});
function cleanDecimatedDataset(t) {
if (t._decimated) {
let e = t._data;
delete t._decimated, delete t._data, Object.defineProperty(t, "data", {
value: e
})
}
}
function cleanDecimatedData(t) {
t.data.datasets.forEach(t => {
cleanDecimatedDataset(t)
})
}
let simpleArc = class simpleArc {
constructor(t) {
this.x = t.x, this.y = t.y, this.radius = t.radius
}
pathSegment(t, e, i) {
let {
x: a,
y: r,
radius: n
} = this;
return e = e || {
start: 0,
end: s.T
}, t.arc(a, r, n, e.end, e.start, !0), !i.bounds
}
interpolate(t) {
let {
x: e,
y: i,
radius: s
} = this, a = t.angle;
return {
x: e + Math.cos(a) * s,
y: i + Math.sin(a) * s,
angle: a
}
}
};
function findSegmentEnd(t, e, i) {
for (; e > t; e--) {
let t = i[e];
if (!isNaN(t.x) && !isNaN(t.y)) break
}
return e
}
function createBoundaryLine(t, e) {
let i = [],
a = !1;
return (0, s.b)(t) ? (a = !0, i = t) : i = function(t, e) {
let {
x: i = null,
y: s = null
} = t || {}, a = e.points, r = [];
return e.segments.forEach(({
start: t,
end: e
}) => {
e = findSegmentEnd(t, e, a);
let n = a[t],
o = a[e];
null !== s ? (r.push({
x: n.x,
y: s
}), r.push({
x: o.x,
y: s
})) : null !== i && (r.push({
x: i,
y: n.y
}), r.push({
x: i,
y: o.y
}))
}), r
}(t, e), i.length ? new LineElement({
points: i,
options: {
tension: 0
},
_loop: a,
_fullLoop: a
}) : null
}
function _clip(t, e, i) {
let {
segments: s,
points: a
} = e, r = !0, n = !1;
for (let o of (t.beginPath(), s)) {
let {
start: s,
end: l
} = o, h = a[s], d = a[findSegmentEnd(s, l, a)];
r ? (t.moveTo(h.x, h.y), r = !1) : (t.lineTo(h.x, i), t.lineTo(h.x, h.y)), (n = !!e.pathSegment(t, o, {
move: n
})) ? t.closePath() : t.lineTo(d.x, i)
}
t.lineTo(e.first().x, i), t.closePath(), t.clip()
}
function getBounds(t, e, i, a) {
if (a) return;
let r = e[t],
n = i[t];
return "angle" === t && (r = (0, s.aw)(r), n = (0, s.aw)(n)), {
property: t,
start: r,
end: n
}
}
function _getEdge(t, e, i, s) {
return t && e ? s(t[i], e[i]) : t ? t[i] : e ? e[i] : 0
}
function interpolatedLineTo(t, e, i, s) {
let a = e.interpolate(i, s);
a && t.lineTo(a.x, a.y)
}
function _fill(t, e) {
let {
line: i,
target: a,
property: r,
color: n,
scale: o
} = e, l = function(t, e, i) {
let a = t.segments,
r = t.points,
n = e.points,
o = [];
for (let t of a) {
let {
start: a,
end: l
} = t;
l = findSegmentEnd(a, l, r);
let h = getBounds(i, r[a], r[l], t.loop);
if (!e.segments) {
o.push({
source: t,
target: h,
start: r[a],
end: r[l]
});
continue
}
let d = (0, s.al)(e, h);
for (let e of d) {
let a = getBounds(i, n[e.start], n[e.end], e.loop),
l = (0, s.av)(t, r, a);
for (let t of l) o.push({
source: t,
target: e,
start: {
[i]: _getEdge(h, a, "start", Math.max)
},
end: {
[i]: _getEdge(h, a, "end", Math.min)
}
})
}
}
return o
}(i, a, r);
for (let {
source: e,
target: s,
start: h,
end: d
}
of l) {
let l;
let {
style: {
backgroundColor: c = n
} = {}
} = e, u = !0 !== a;
t.save(), t.fillStyle = c,
function(t, e, i) {
let {
top: s,
bottom: a
} = e.chart.chartArea, {
property: r,
start: n,
end: o
} = i || {};
"x" === r && (t.beginPath(), t.rect(n, s, o - n, a - s), t.clip())
}(t, o, u && getBounds(r, h, d)), t.beginPath();
let g = !!i.pathSegment(t, e);
if (u) {
g ? t.closePath() : interpolatedLineTo(t, a, d, r);
let e = !!a.pathSegment(t, s, {
move: g,
reverse: !0
});
(l = g && e) || interpolatedLineTo(t, a, h, r)
}
t.closePath(), t.fill(l ? "evenodd" : "nonzero"), t.restore()
}
}
function drawfill(t, e, i) {
let a = function(t) {
let {
chart: e,
fill: i,
line: a
} = t;
if ((0, s.g)(i)) return function(t, e) {
let i = t.getDatasetMeta(e),
s = i && t.isDatasetVisible(e);
return s ? i.dataset : null
}(e, i);
if ("stack" === i) return function(t) {
let {
scale: e,
index: i,
line: a
} = t, r = [], n = a.segments, o = a.points, l = function(t, e) {
let i = [],
s = t.getMatchingVisibleMetas("line");
for (let t = 0; t < s.length; t++) {
let a = s[t];
if (a.index === e) break;
a.hidden || i.unshift(a.dataset)
}
return i
}(e, i);
l.push(createBoundaryLine({
x: null,
y: e.bottom
}, a));
for (let t = 0; t < n.length; t++) {
let e = n[t];
for (let t = e.start; t <= e.end; t++) ! function(t, e, i) {
let a = [];
for (let r = 0; r < i.length; r++) {
let n = i[r],
{
first: o,
last: l,
point: h
} = function(t, e, i) {
let a = t.interpolate(e, i);
if (!a) return {};
let r = a[i],
n = t.segments,
o = t.points,
l = !1,
h = !1;
for (let t = 0; t < n.length; t++) {
let e = n[t],
a = o[e.start][i],
d = o[e.end][i];
if ((0, s.ah)(r, a, d)) {
l = r === a, h = r === d;
break
}
}
return {
first: l,
last: h,
point: a
}
}(n, e, "x");
if (h && (!o || !l)) {
if (o) a.unshift(h);
else if (t.push(h), !l) break
}
}
t.push(...a)
}(r, o[t], l)
}
return new LineElement({
points: r,
options: {}
})
}(t);
if ("shape" === i) return !0;
let r = function(t) {
let e = t.scale || {};
return e.getPointPositionForValue ? function(t) {
let e, i, a;
let {
scale: r,
fill: n
} = t, o = r.options, l = r.getLabels().length, h = [], d = o.reverse ? r.max : r.min, c = o.reverse ? r.min : r.max;
if (a = "start" === n ? d : "end" === n ? c : (0, s.i)(n) ? n.value : r.getBaseValue(), o.grid.circular) return i = r.getPointPositionForValue(0, d), new simpleArc({
x: i.x,
y: i.y,
radius: r.getDistanceFromCenterForValue(a)
});
for (e = 0; e < l; ++e) h.push(r.getPointPositionForValue(e, a));
return h
}(t) : function(t) {
let e;
let {
scale: i = {},
fill: a
} = t, r = null;
return ("start" === a ? r = i.bottom : "end" === a ? r = i.top : (0, s.i)(a) ? r = i.getPixelForValue(a.value) : i.getBasePixel && (r = i.getBasePixel()), (0, s.g)(r)) ? {
x: (e = i.isHorizontal()) ? r : null,
y: e ? null : r
} : null
}(t)
}(t);
return r instanceof simpleArc ? r : createBoundaryLine(r, a)
}(e),
{
line: r,
scale: n,
axis: o
} = e,
l = r.options,
h = l.fill,
d = l.backgroundColor,
{
above: c = d,
below: u = d
} = h || {};
a && r.points.length && ((0, s.W)(t, i), function(t, e) {
let {
line: i,
target: s,
above: a,
below: r,
area: n,
scale: o
} = e, l = i._loop ? "angle" : e.axis;
t.save(), "x" === l && r !== a && (_clip(t, s, n.top), _fill(t, {
line: i,
target: s,
color: a,
scale: o,
property: l
}), t.restore(), t.save(), _clip(t, s, n.bottom)), _fill(t, {
line: i,
target: s,
color: r,
scale: o,
property: l
}), t.restore()
}(t, {
line: r,
target: a,
above: c,
below: u,
area: i,
scale: n,
axis: o
}), (0, s.Y)(t))
}
let getBoxSize = (t, e) => {
let {
boxHeight: i = e,
boxWidth: s = e
} = t;
return t.usePointStyle && (i = Math.min(i, e), s = Math.min(s, e)), {
boxWidth: s,
boxHeight: i,
itemHeight: Math.max(e, i)
}
},
itemsEqual = (t, e) => null !== t && null !== e && t.datasetIndex === e.datasetIndex && t.index === e.index;
let Legend = class Legend extends Element {
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, i) {
this.maxWidth = t, this.maxHeight = e, this._margins = i, 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() {
let t = this.options.labels || {},
e = (0, s.O)(t.generateLabels, [this.chart], this) || [];
t.filter && (e = e.filter(e => t.filter(e, this.chart.data))), t.sort && (e = e.sort((e, i) => t.sort(e, i, this.chart.data))), this.options.reverse && e.reverse(), this.legendItems = e
}
fit() {
let t, e;
let {
options: i,
ctx: a
} = this;
if (!i.display) {
this.width = this.height = 0;
return
}
let r = i.labels,
n = (0, s.Z)(r.font),
o = n.size,
l = this._computeTitleHeight(),
{
boxWidth: h,
itemHeight: d
} = getBoxSize(r, o);
a.font = n.string, this.isHorizontal() ? (t = this.maxWidth, e = this._fitRows(l, o, h, d) + 10) : (e = this.maxHeight, t = this._fitCols(l, o, h, d) + 10), this.width = Math.min(t, i.maxWidth || this.maxWidth), this.height = Math.min(e, i.maxHeight || this.maxHeight)
}
_fitRows(t, e, i, s) {
let {
ctx: a,
maxWidth: r,
options: {
labels: {
padding: n
}
}
} = this, o = this.legendHitBoxes = [], l = this.lineWidths = [0], h = s + n, d = t;
a.textAlign = "left", a.textBaseline = "middle";
let c = -1,
u = -h;
return this.legendItems.forEach((t, g) => {
let p = i + e / 2 + a.measureText(t.text).width;
(0 === g || l[l.length - 1] + p + 2 * n > r) && (d += h, l[l.length - (g > 0 ? 0 : 1)] = 0, u += h, c++), o[g] = {
left: 0,
top: u,
row: c,
width: p,
height: s
}, l[l.length - 1] += p + n
}), d
}
_fitCols(t, e, i, s) {
let {
ctx: a,
maxHeight: r,
options: {
labels: {
padding: n
}
}
} = this, o = this.legendHitBoxes = [], l = this.columnSizes = [], h = r - t, d = n, c = 0, u = 0, g = 0, p = 0;
return this.legendItems.forEach((t, r) => {
let f = i + e / 2 + a.measureText(t.text).width;
r > 0 && u + s + 2 * n > h && (d += c + n, l.push({
width: c,
height: u
}), g += c + n, p++, c = u = 0), o[r] = {
left: g,
top: u,
col: p,
width: f,
height: s
}, c = Math.max(c, f), u += s + n
}), d += c, l.push({
width: c,
height: u
}), d
}
adjustHitBoxes() {
if (!this.options.display) return;
let t = this._computeTitleHeight(),
{
legendHitBoxes: e,
options: {
align: i,
labels: {
padding: a
},
rtl: r
}
} = this,
n = (0, s.ax)(r, this.left, this.width);
if (this.isHorizontal()) {
let r = 0,
o = (0, s.a0)(i, this.left + a, this.right - this.lineWidths[r]);
for (let l of e) r !== l.row && (r = l.row, o = (0, s.a0)(i, this.left + a, this.right - this.lineWidths[r])), l.top += this.top + t + a, l.left = n.leftForLtr(n.x(o), l.width), o += l.width + a
} else {
let r = 0,
o = (0, s.a0)(i, this.top + t + a, this.bottom - this.columnSizes[r].height);
for (let l of e) l.col !== r && (r = l.col, o = (0, s.a0)(i, this.top + t + a, this.bottom - this.columnSizes[r].height)), l.top = o, l.left += this.left + a, l.left = n.leftForLtr(n.x(l.left), l.width), o += l.height + a
}
}
isHorizontal() {
return "top" === this.options.position || "bottom" === this.options.position
}
draw() {
if (this.options.display) {
let t = this.ctx;
(0, s.W)(t, this), this._draw(), (0, s.Y)(t)
}
}
_draw() {
let t;
let {
options: e,
columnSizes: i,
lineWidths: a,
ctx: r
} = this, {
align: n,
labels: o
} = e, l = s.d.color, h = (0, s.ax)(e.rtl, this.left, this.width), d = (0, s.Z)(o.font), {
color: c,
padding: u
} = o, g = d.size, p = g / 2;
this.drawTitle(), r.textAlign = h.textAlign("left"), r.textBaseline = "middle", r.lineWidth = .5, r.font = d.string;
let {
boxWidth: f,
boxHeight: m,
itemHeight: x
} = getBoxSize(o, g), drawLegendBox = function(t, e, i) {
if (isNaN(f) || f <= 0 || isNaN(m) || m < 0) return;
r.save();
let a = (0, s.v)(i.lineWidth, 1);
if (r.fillStyle = (0, s.v)(i.fillStyle, l), r.lineCap = (0, s.v)(i.lineCap, "butt"), r.lineDashOffset = (0, s.v)(i.lineDashOffset, 0), r.lineJoin = (0, s.v)(i.lineJoin, "miter"), r.lineWidth = a, r.strokeStyle = (0, s.v)(i.strokeStyle, l), r.setLineDash((0, s.v)(i.lineDash, [])), o.usePointStyle) {
let n = {
radius: f * Math.SQRT2 / 2,
pointStyle: i.pointStyle,
rotation: i.rotation,
borderWidth: a
},
o = h.xPlus(t, f / 2),
l = e + p;
(0, s.ar)(r, n, o, l)
} else {
let n = e + Math.max((g - m) / 2, 0),
o = h.leftForLtr(t, f),
l = (0, s.au)(i.borderRadius);
r.beginPath(), Object.values(l).some(t => 0 !== t) ? (0, s.as)(r, {
x: o,
y: n,
w: f,
h: m,
radius: l
}) : r.rect(o, n, f, m), r.fill(), 0 !== a && r.stroke()
}
r.restore()
}, fillText = function(t, e, i) {
(0, s.X)(r, i.text, t, e + x / 2, d, {
strikethrough: i.hidden,
textAlign: h.textAlign(i.textAlign)
})
}, b = this.isHorizontal(), _ = this._computeTitleHeight();
t = b ? {
x: (0, s.a0)(n, this.left + u, this.right - a[0]),
y: this.top + u + _,
line: 0
} : {
x: this.left + u,
y: (0, s.a0)(n, this.top + _ + u, this.bottom - i[0].height),
line: 0
}, (0, s.ay)(this.ctx, e.textDirection);
let v = x + u;
this.legendItems.forEach((l, d) => {
r.strokeStyle = l.fontColor || c, r.fillStyle = l.fontColor || c;
let g = r.measureText(l.text).width,
m = h.textAlign(l.textAlign || (l.textAlign = o.textAlign)),
x = f + p + g,
y = t.x,
k = t.y;
h.setWidth(this.width), b ? d > 0 && y + x + u > this.right && (k = t.y += v, t.line++, y = t.x = (0, s.a0)(n, this.left + u, this.right - a[t.line])) : d > 0 && k + v > this.bottom && (y = t.x = y + i[t.line].width + u, t.line++, k = t.y = (0, s.a0)(n, this.top + _ + u, this.bottom - i[t.line].height));
let M = h.x(y);
drawLegendBox(M, k, l), y = (0, s.az)(m, y + f + p, b ? y + x : this.right, e.rtl), fillText(h.x(y), k, l), b ? t.x += x + u : t.y += v
}), (0, s.aA)(this.ctx, e.textDirection)
}
drawTitle() {
let t;
let e = this.options,
i = e.title,
a = (0, s.Z)(i.font),
r = (0, s.C)(i.padding);
if (!i.display) return;
let n = (0, s.ax)(e.rtl, this.left, this.width),
o = this.ctx,
l = i.position,
h = a.size / 2,
d = r.top + h,
c = this.left,
u = this.width;
if (this.isHorizontal()) u = Math.max(...this.lineWidths), t = this.top + d, c = (0, s.a0)(e.align, c, this.right - u);
else {
let i = this.columnSizes.reduce((t, e) => Math.max(t, e.height), 0);
t = d + (0, s.a0)(e.align, this.top, this.bottom - i - e.labels.padding - this._computeTitleHeight())
}
let g = (0, s.a0)(l, c, c + u);
o.textAlign = n.textAlign((0, s.$)(l)), o.textBaseline = "middle", o.strokeStyle = i.color, o.fillStyle = i.color, o.font = a.string, (0, s.X)(o, i.text, g, t, a)
}
_computeTitleHeight() {
let t = this.options.title,
e = (0, s.Z)(t.font),
i = (0, s.C)(t.padding);
return t.display ? e.lineHeight + i.height : 0
}
_getLegendItemAt(t, e) {
let i, a, r;
if ((0, s.ah)(t, this.left, this.right) && (0, s.ah)(e, this.top, this.bottom)) {
for (i = 0, r = this.legendHitBoxes; i < r.length; ++i)
if (a = r[i], (0, s.ah)(t, a.left, a.left + a.width) && (0, s.ah)(e, a.top, a.top + a.height)) return this.legendItems[i]
}
return null
}
handleEvent(t) {
var e;
let i = this.options;
if (("mousemove" !== (e = t.type) || !i.onHover && !i.onLeave) && (!i.onClick || "click" !== e && "mouseup" !== e)) return;
let a = this._getLegendItemAt(t.x, t.y);
if ("mousemove" === t.type) {
let e = this._hoveredItem,
r = itemsEqual(e, a);
e && !r && (0, s.O)(i.onLeave, [t, e, this], this), this._hoveredItem = a, a && !r && (0, s.O)(i.onHover, [t, a, this], this)
} else a && (0, s.O)(i.onClick, [t, a, this], this)
}
};
let Title = class Title extends Element {
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) {
let i = this.options;
if (this.left = 0, this.top = 0, !i.display) {
this.width = this.height = this.right = this.bottom = 0;
return
}
this.width = this.right = t, this.height = this.bottom = e;
let a = (0, s.b)(i.text) ? i.text.length : 1;
this._padding = (0, s.C)(i.padding);
let r = a * (0, s.Z)(i.font).lineHeight + this._padding.height;
this.isHorizontal() ? this.height = r : this.width = r
}
isHorizontal() {
let t = this.options.position;
return "top" === t || "bottom" === t
}
_drawArgs(t) {
let e, i, a;
let {
top: r,
left: n,
bottom: o,
right: l,
options: h
} = this, d = h.align, c = 0;
return this.isHorizontal() ? (i = (0, s.a0)(d, n, l), a = r + t, e = l - n) : ("left" === h.position ? (i = n + t, a = (0, s.a0)(d, o, r), c = -.5 * s.P) : (i = l - t, a = (0, s.a0)(d, r, o), c = .5 * s.P), e = o - r), {
titleX: i,
titleY: a,
maxWidth: e,
rotation: c
}
}
draw() {
let t = this.ctx,
e = this.options;
if (!e.display) return;
let i = (0, s.Z)(e.font),
a = i.lineHeight,
r = a / 2 + this._padding.top,
{
titleX: n,
titleY: o,
maxWidth: l,
rotation: h
} = this._drawArgs(r);
(0, s.X)(t, e.text, 0, 0, i, {
color: e.color,
maxWidth: l,
rotation: h,
textAlign: (0, s.$)(e.align),
textBaseline: "middle",
translation: [n, o]
})
}
};
let C = new WeakMap,
P = {
average(t) {
let e, i;
if (!t.length) return !1;
let s = 0,
a = 0,
r = 0;
for (e = 0, i = t.length; e < i; ++e) {
let i = t[e].element;
if (i && i.hasValue()) {
let t = i.tooltipPosition();
s += t.x, a += t.y, ++r
}
}
return {
x: s / r,
y: a / r
}
},
nearest(t, e) {
let i, a, r;
if (!t.length) return !1;
let n = e.x,
o = e.y,
l = Number.POSITIVE_INFINITY;
for (i = 0, a = t.length; i < a; ++i) {
let a = t[i].element;
if (a && a.hasValue()) {
let t = a.getCenterPoint(),
i = (0, s.aC)(e, t);
i < l && (l = i, r = a)
}
}
if (r) {
let t = r.tooltipPosition();
n = t.x, o = t.y
}
return {
x: n,
y: o
}
}
};
function pushOrConcat(t, e) {
return e && ((0, s.b)(e) ? Array.prototype.push.apply(t, e) : t.push(e)), t
}
function splitNewlines(t) {
return ("string" == typeof t || t instanceof String) && t.indexOf("\n") > -1 ? t.split("\n") : t
}
function getTooltipSize(t, e) {
let i = t.chart.ctx,
{
body: a,
footer: r,
title: n
} = t,
{
boxWidth: o,
boxHeight: l
} = e,
h = (0, s.Z)(e.bodyFont),
d = (0, s.Z)(e.titleFont),
c = (0, s.Z)(e.footerFont),
u = n.length,
g = r.length,
p = a.length,
f = (0, s.C)(e.padding),
m = f.height,
x = 0,
b = a.reduce((t, e) => t + e.before.length + e.lines.length + e.after.length, 0);
if (b += t.beforeBody.length + t.afterBody.length, u && (m += u * d.lineHeight + (u - 1) * e.titleSpacing + e.titleMarginBottom), b) {
let t = e.displayColors ? Math.max(l, h.lineHeight) : h.lineHeight;
m += p * t + (b - p) * h.lineHeight + (b - 1) * e.bodySpacing
}
g && (m += e.footerMarginTop + g * c.lineHeight + (g - 1) * e.footerSpacing);
let _ = 0,
maxLineWidth = function(t) {
x = Math.max(x, i.measureText(t).width + _)
};
return i.save(), i.font = d.string, (0, s.D)(t.title, maxLineWidth), i.font = h.string, (0, s.D)(t.beforeBody.concat(t.afterBody), maxLineWidth), _ = e.displayColors ? o + 2 + e.boxPadding : 0, (0, s.D)(a, t => {
(0, s.D)(t.before, maxLineWidth), (0, s.D)(t.lines, maxLineWidth), (0, s.D)(t.after, maxLineWidth)
}), _ = 0, i.font = c.string, (0, s.D)(t.footer, maxLineWidth), i.restore(), {
width: x += f.width,
height: m
}
}
function determineAlignment(t, e, i) {
let s = i.yAlign || e.yAlign || function(t, e) {
let {
y: i,
height: s
} = e;
return i < s / 2 ? "top" : i > t.height - s / 2 ? "bottom" : "center"
}(t, i);
return {
xAlign: i.xAlign || e.xAlign || function(t, e, i, s) {
let {
x: a,
width: r
} = i, {
width: n,
chartArea: {
left: o,
right: l
}
} = t, h = "center";
return "center" === s ? h = a <= (o + l) / 2 ? "left" : "right" : a <= r / 2 ? h = "left" : a >= n - r / 2 && (h = "right"),
function(t, e, i, s) {
let {
x: a,
width: r
} = s, n = i.caretSize + i.caretPadding;
if ("left" === t && a + r + n > e.width || "right" === t && a - r - n < 0) return !0
}(h, t, e, i) && (h = "center"), h
}(t, e, i, s),
yAlign: s
}
}
function getBackgroundPoint(t, e, i, a) {
let {
caretSize: r,
caretPadding: n,
cornerRadius: o
} = t, {
xAlign: l,
yAlign: h
} = i, d = r + n, {
topLeft: c,
topRight: u,
bottomLeft: g,
bottomRight: p
} = (0, s.au)(o), f = function(t, e) {
let {
x: i,
width: s
} = t;
return "right" === e ? i -= s : "center" === e && (i -= s / 2), i
}(e, l), m = function(t, e, i) {
let {
y: s,
height: a
} = t;
return "top" === e ? s += i : "bottom" === e ? s -= a + i : s -= a / 2, s
}(e, h, d);
return "center" === h ? "left" === l ? f += d : "right" === l && (f -= d) : "left" === l ? f -= Math.max(c, g) + r : "right" === l && (f += Math.max(u, p) + r), {
x: (0, s.w)(f, 0, a.width - e.width),
y: (0, s.w)(m, 0, a.height - e.height)
}
}
function getAlignedX(t, e, i) {
let a = (0, s.C)(i.padding);
return "center" === e ? t.x + t.width / 2 : "right" === e ? t.x + t.width - a.right : t.x + a.left
}
function overrideCallbacks(t, e) {
let i = e && e.dataset && e.dataset.tooltip && e.dataset.tooltip.callbacks;
return i ? t.override(i) : t
}
let Tooltip = class Tooltip extends Element {
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 || t._chart, this._chart = this.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() {
let t = this._cachedAnimations;
if (t) return t;
let e = this.chart,
i = this.options.setContext(this.getContext()),
s = i.enabled && e.options.animation && i.animations,
a = new Animations(this.chart, s);
return s._cacheable && (this._cachedAnimations = Object.freeze(a)), a
}
getContext() {
var t, e;
return this.$context || (this.$context = (t = this.chart.getContext(), e = this._tooltipItems, (0, s.h)(t, {
tooltip: this,
tooltipItems: e,
type: "tooltip"
})))
}
getTitle(t, e) {
let {
callbacks: i
} = e, s = i.beforeTitle.apply(this, [t]), a = i.title.apply(this, [t]), r = i.afterTitle.apply(this, [t]), n = [];
return n = pushOrConcat(n, splitNewlines(s)), n = pushOrConcat(n, splitNewlines(a)), n = pushOrConcat(n, splitNewlines(r))
}
getBeforeBody(t, e) {
return pushOrConcat([], splitNewlines(e.callbacks.beforeBody.apply(this, [t])))
}
getBody(t, e) {
let {
callbacks: i
} = e, a = [];
return (0, s.D)(t, t => {
let e = {
before: [],
lines: [],
after: []
},
s = overrideCallbacks(i, t);
pushOrConcat(e.before, splitNewlines(s.beforeLabel.call(this, t))), pushOrConcat(e.lines, s.label.call(this, t)), pushOrConcat(e.after, splitNewlines(s.afterLabel.call(this, t))), a.push(e)
}), a
}
getAfterBody(t, e) {
return pushOrConcat([], splitNewlines(e.callbacks.afterBody.apply(this, [t])))
}
getFooter(t, e) {
let {
callbacks: i
} = e, s = i.beforeFooter.apply(this, [t]), a = i.footer.apply(this, [t]), r = i.afterFooter.apply(this, [t]), n = [];
return n = pushOrConcat(n, splitNewlines(s)), n = pushOrConcat(n, splitNewlines(a)), n = pushOrConcat(n, splitNewlines(r))
}
_createItems(t) {
let e, i;
let a = this._active,
r = this.chart.data,
n = [],
o = [],
l = [],
h = [];
for (e = 0, i = a.length; e < i; ++e) h.push(function(t, e) {
let {
element: i,
datasetIndex: s,
index: a
} = e, r = t.getDatasetMeta(s).controller, {
label: n,
value: o
} = r.getLabelAndValue(a);
return {
chart: t,
label: n,
parsed: r.getParsed(a),
raw: t.data.datasets[s].data[a],
formattedValue: o,
dataset: r.getDataset(),
dataIndex: a,
datasetIndex: s,
element: i
}
}(this.chart, a[e]));
return t.filter && (h = h.filter((e, i, s) => t.filter(e, i, s, r))), t.itemSort && (h = h.sort((e, i) => t.itemSort(e, i, r))), (0, s.D)(h, e => {
let i = overrideCallbacks(t.callbacks, e);
n.push(i.labelColor.call(this, e)), o.push(i.labelPointStyle.call(this, e)), l.push(i.labelTextColor.call(this, e))
}), this.labelColors = n, this.labelPointStyles = o, this.labelTextColors = l, this.dataPoints = h, h
}
update(t, e) {
let i;
let s = this.options.setContext(this.getContext()),
a = this._active,
r = [];
if (a.length) {
let t = P[s.position].call(this, a, 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);
let e = this._size = getTooltipSize(this, s),
n = Object.assign({}, t, e),
o = determineAlignment(this.chart, s, n),
l = getBackgroundPoint(s, n, o, this.chart);
this.xAlign = o.xAlign, this.yAlign = o.yAlign, i = {
opacity: 1,
x: l.x,
y: l.y,
width: e.width,
height: e.height,
caretX: t.x,
caretY: t.y
}
} else 0 !== this.opacity && (i = {
opacity: 0
});
this._tooltipItems = r, this.$context = void 0, i && this._resolveAnimations().update(this, i), t && s.external && s.external.call(this, {
chart: this.chart,
tooltip: this,
replay: e
})
}
drawCaret(t, e, i, s) {
let a = this.getCaretPosition(t, i, s);
e.lineTo(a.x1, a.y1), e.lineTo(a.x2, a.y2), e.lineTo(a.x3, a.y3)
}
getCaretPosition(t, e, i) {
let a, r, n, o, l, h;
let {
xAlign: d,
yAlign: c
} = this, {
caretSize: u,
cornerRadius: g
} = i, {
topLeft: p,
topRight: f,
bottomLeft: m,
bottomRight: x
} = (0, s.au)(g), {
x: b,
y: _
} = t, {
width: v,
height: y
} = e;
return "center" === c ? (l = _ + y / 2, "left" === d ? (r = (a = b) - u, o = l + u, h = l - u) : (r = (a = b + v) + u, o = l - u, h = l + u), n = a) : (r = "left" === d ? b + Math.max(p, m) + u : "right" === d ? b + v - Math.max(f, x) - u : this.caretX, "top" === c ? (l = (o = _) - u, a = r - u, n = r + u) : (l = (o = _ + y) + u, a = r + u, n = r - u), h = o), {
x1: a,
x2: r,
x3: n,
y1: o,
y2: l,
y3: h
}
}
drawTitle(t, e, i) {
let a, r, n;
let o = this.title,
l = o.length;
if (l) {
let h = (0, s.ax)(i.rtl, this.x, this.width);
for (n = 0, t.x = getAlignedX(this, i.titleAlign, i), e.textAlign = h.textAlign(i.titleAlign), e.textBaseline = "middle", a = (0, s.Z)(i.titleFont), r = i.titleSpacing, e.fillStyle = i.titleColor, e.font = a.string; n < l; ++n) e.fillText(o[n], h.x(t.x), t.y + a.lineHeight / 2), t.y += a.lineHeight + r, n + 1 === l && (t.y += i.titleMarginBottom - r)
}
}
_drawColorBox(t, e, i, a, r) {
let n = this.labelColors[i],
o = this.labelPointStyles[i],
{
boxHeight: l,
boxWidth: h,
boxPadding: d
} = r,
c = (0, s.Z)(r.bodyFont),
u = getAlignedX(this, "left", r),
g = a.x(u),
p = l < c.lineHeight ? (c.lineHeight - l) / 2 : 0,
f = e.y + p;
if (r.usePointStyle) {
let e = {
radius: Math.min(h, l) / 2,
pointStyle: o.pointStyle,
rotation: o.rotation,
borderWidth: 1
},
i = a.leftForLtr(g, h) + h / 2,
d = f + l / 2;
t.strokeStyle = r.multiKeyBackground, t.fillStyle = r.multiKeyBackground, (0, s.ar)(t, e, i, d), t.strokeStyle = n.borderColor, t.fillStyle = n.backgroundColor, (0, s.ar)(t, e, i, d)
} else {
t.lineWidth = n.borderWidth || 1, t.strokeStyle = n.borderColor, t.setLineDash(n.borderDash || []), t.lineDashOffset = n.borderDashOffset || 0;
let e = a.leftForLtr(g, h - d),
i = a.leftForLtr(a.xPlus(g, 1), h - d - 2),
o = (0, s.au)(n.borderRadius);
Object.values(o).some(t => 0 !== t) ? (t.beginPath(), t.fillStyle = r.multiKeyBackground, (0, s.as)(t, {
x: e,
y: f,
w: h,
h: l,
radius: o
}), t.fill(), t.stroke(), t.fillStyle = n.backgroundColor, t.beginPath(), (0, s.as)(t, {
x: i,
y: f + 1,
w: h - 2,
h: l - 2,
radius: o
}), t.fill()) : (t.fillStyle = r.multiKeyBackground, t.fillRect(e, f, h, l), t.strokeRect(e, f, h, l), t.fillStyle = n.backgroundColor, t.fillRect(i, f + 1, h - 2, l - 2))
}
t.fillStyle = this.labelTextColors[i]
}
drawBody(t, e, i) {
let a, r, n, o, l, h, d;
let {
body: c
} = this, {
bodySpacing: u,
bodyAlign: g,
displayColors: p,
boxHeight: f,
boxWidth: m,
boxPadding: x
} = i, b = (0, s.Z)(i.bodyFont), _ = b.lineHeight, v = 0, y = (0, s.ax)(i.rtl, this.x, this.width), fillLineOfText = function(i) {
e.fillText(i, y.x(t.x + v), t.y + _ / 2), t.y += _ + u
}, k = y.textAlign(g);
for (e.textAlign = g, e.textBaseline = "middle", e.font = b.string, t.x = getAlignedX(this, k, i), e.fillStyle = i.bodyColor, (0, s.D)(this.beforeBody, fillLineOfText), v = p && "right" !== k ? "center" === g ? m / 2 + x : m + 2 + x : 0, o = 0, h = c.length; o < h; ++o) {
for (a = c[o], r = this.labelTextColors[o], e.fillStyle = r, (0, s.D)(a.before, fillLineOfText), n = a.lines, p && n.length && (this._drawColorBox(e, t, o, y, i), _ = Math.max(b.lineHeight, f)), l = 0, d = n.length; l < d; ++l) fillLineOfText(n[l]), _ = b.lineHeight;
(0, s.D)(a.after, fillLineOfText)
}
v = 0, _ = b.lineHeight, (0, s.D)(this.afterBody, fillLineOfText), t.y -= u
}
drawFooter(t, e, i) {
let a, r;
let n = this.footer,
o = n.length;
if (o) {
let l = (0, s.ax)(i.rtl, this.x, this.width);
for (t.x = getAlignedX(this, i.footerAlign, i), t.y += i.footerMarginTop, e.textAlign = l.textAlign(i.footerAlign), e.textBaseline = "middle", a = (0, s.Z)(i.footerFont), e.fillStyle = i.footerColor, e.font = a.string, r = 0; r < o; ++r) e.fillText(n[r], l.x(t.x), t.y + a.lineHeight / 2), t.y += a.lineHeight + i.footerSpacing
}
}
drawBackground(t, e, i, a) {
let {
xAlign: r,
yAlign: n
} = this, {
x: o,
y: l
} = t, {
width: h,
height: d
} = i, {
topLeft: c,
topRight: u,
bottomLeft: g,
bottomRight: p
} = (0, s.au)(a.cornerRadius);
e.fillStyle = a.backgroundColor, e.strokeStyle = a.borderColor, e.lineWidth = a.borderWidth, e.beginPath(), e.moveTo(o + c, l), "top" === n && this.drawCaret(t, e, i, a), e.lineTo(o + h - u, l), e.quadraticCurveTo(o + h, l, o + h, l + u), "center" === n && "right" === r && this.drawCaret(t, e, i, a), e.lineTo(o + h, l + d - p), e.quadraticCurveTo(o + h, l + d, o + h - p, l + d), "bottom" === n && this.drawCaret(t, e, i, a), e.lineTo(o + g, l + d), e.quadraticCurveTo(o, l + d, o, l + d - g), "center" === n && "left" === r && this.drawCaret(t, e, i, a), e.lineTo(o, l + c), e.quadraticCurveTo(o, l, o + c, l), e.closePath(), e.fill(), a.borderWidth > 0 && e.stroke()
}
_updateAnimationTarget(t) {
let e = this.chart,
i = this.$animations,
s = i && i.x,
a = i && i.y;
if (s || a) {
let i = P[t.position].call(this, this._active, this._eventPosition);
if (!i) return;
let r = this._size = getTooltipSize(this, t),
n = Object.assign({}, i, this._size),
o = determineAlignment(e, t, n),
l = getBackgroundPoint(t, n, o, e);
(s._to !== l.x || a._to !== l.y) && (this.xAlign = o.xAlign, this.yAlign = o.yAlign, this.width = r.width, this.height = r.height, this.caretX = i.x, this.caretY = i.y, this._resolveAnimations().update(this, l))
}
}
draw(t) {
let e = this.options.setContext(this.getContext()),
i = this.opacity;
if (!i) return;
this._updateAnimationTarget(e);
let a = {
width: this.width,
height: this.height
},
r = {
x: this.x,
y: this.y
};
i = .001 > Math.abs(i) ? 0 : i;
let n = (0, s.C)(e.padding),
o = this.title.length || this.beforeBody.length || this.body.length || this.afterBody.length || this.footer.length;
e.enabled && o && (t.save(), t.globalAlpha = i, this.drawBackground(r, t, a, e), (0, s.ay)(t, e.textDirection), r.y += n.top, this.drawTitle(r, t, e), this.drawBody(r, t, e), this.drawFooter(r, t, e), (0, s.aA)(t, e.textDirection), t.restore())
}
getActiveElements() {
return this._active || []
}
setActiveElements(t, e) {
let i = this._active,
a = t.map(({
datasetIndex: t,
index: e
}) => {
let i = this.chart.getDatasetMeta(t);
if (!i) throw Error("Cannot find a dataset at index " + t);
return {
datasetIndex: t,
element: i.data[e],
index: e
}
}),
r = !(0, s.af)(i, a),
n = this._positionChanged(a, e);
(r || n) && (this._active = a, this._eventPosition = e, this._ignoreReplayEvents = !0, this.update(!0))
}
handleEvent(t, e, i = !0) {
if (e && this._ignoreReplayEvents) return !1;
this._ignoreReplayEvents = !1;
let a = this.options,
r = this._active || [],
n = this._getActiveElements(t, r, e, i),
o = this._positionChanged(n, t),
l = e || !(0, s.af)(n, r) || o;
return l && (this._active = n, (a.enabled || a.external) && (this._eventPosition = {
x: t.x,
y: t.y
}, this.update(!0, e))), l
}
_getActiveElements(t, e, i, s) {
let a = this.options;
if ("mouseout" === t.type) return [];
if (!s) return e;
let r = this.chart.getElementsAtEventForMode(t, a.mode, a, i);
return a.reverse && r.reverse(), r
}
_positionChanged(t, e) {
let {
caretX: i,
caretY: s,
options: a
} = this, r = P[a.position].call(this, t, e);
return !1 !== r && (i !== r.x || s !== r.y)
}
};
Tooltip.positioners = P;
var L = {
id: "tooltip",
_element: Tooltip,
positioners: P,
afterInit(t, e, i) {
i && (t.tooltip = new Tooltip({
chart: t,
options: i
}))
},
beforeUpdate(t, e, i) {
t.tooltip && t.tooltip.initialize(i)
},
reset(t, e, i) {
t.tooltip && t.tooltip.initialize(i)
},
afterDraw(t) {
let e = t.tooltip,
i = {
tooltip: e
};
!1 !== t.notifyPlugins("beforeTooltipDraw", i) && (e && e.draw(t.ctx), t.notifyPlugins("afterTooltipDraw", i))
},
afterEvent(t, e) {
if (t.tooltip) {
let i = e.replay;
t.tooltip.handleEvent(e.event, i, e.inChartArea) && (e.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: (t, e) => e.bodyFont.size,
boxWidth: (t, e) => e.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: {
beforeTitle: s.aB,
title(t) {
if (t.length > 0) {
let e = t[0],
i = e.chart.data.labels,
s = i ? i.length : 0;
if (this && this.options && "dataset" === this.options.mode) return e.dataset.label || "";
if (e.label) return e.label;
if (s > 0 && e.dataIndex < s) return i[e.dataIndex]
}
return ""
},
afterTitle: s.aB,
beforeBody: s.aB,
beforeLabel: s.aB,
label(t) {
if (this && this.options && "dataset" === this.options.mode) return t.label + ": " + t.formattedValue || t.formattedValue;
let e = t.dataset.label || "";
e && (e += ": ");
let i = t.formattedValue;
return (0, s.k)(i) || (e += i), e
},
labelColor(t) {
let e = t.chart.getDatasetMeta(t.datasetIndex),
i = e.controller.getStyle(t.dataIndex);
return {
borderColor: i.borderColor,
backgroundColor: i.backgroundColor,
borderWidth: i.borderWidth,
borderDash: i.borderDash,
borderDashOffset: i.borderDashOffset,
borderRadius: 0
}
},
labelTextColor() {
return this.options.bodyColor
},
labelPointStyle(t) {
let e = t.chart.getDatasetMeta(t.datasetIndex),
i = e.controller.getStyle(t.dataIndex);
return {
pointStyle: i.pointStyle,
rotation: i.rotation
}
},
afterLabel: s.aB,
afterBody: s.aB,
beforeFooter: s.aB,
footer: s.aB,
afterFooter: s.aB
}
},
defaultRoutes: {
bodyFont: "font",
footerFont: "font",
titleFont: "font"
},
descriptors: {
_scriptable: t => "filter" !== t && "itemSort" !== t && "external" !== t,
_indexable: !1,
callbacks: {
_scriptable: !1,
_indexable: !1
},
animation: {
_fallback: !1
},
animations: {
_fallback: "animation"
}
},
additionalOptionScopes: ["interaction"]
},
A = Object.freeze({
__proto__: null,
Decimation: {
id: "decimation",
defaults: {
algorithm: "min-max",
enabled: !1
},
beforeElementsUpdate: (t, e, i) => {
if (!i.enabled) {
cleanDecimatedData(t);
return
}
let a = t.width;
t.data.datasets.forEach((e, r) => {
let n;
let {
_data: o,
indexAxis: l
} = e, h = t.getDatasetMeta(r), d = o || e.data;
if ("y" === (0, s.a)([l, t.options.indexAxis]) || "line" !== h.type) return;
let c = t.scales[h.xAxisID];
if ("linear" !== c.type && "time" !== c.type || t.options.parsing) return;
let {
start: u,
count: g
} = function(t, e) {
let i = e.length,
a = 0,
{
iScale: r
} = t,
{
min: n,
max: o,
minDefined: l,
maxDefined: h
} = r.getUserBounds();
return l && (a = (0, s.w)((0, s.x)(e, r.axis, n).lo, 0, i - 1)), {
start: a,
count: h ? (0, s.w)((0, s.x)(e, r.axis, o).hi + 1, a, i) - a : i - a
}
}(h, d), p = i.threshold || 4 * a;
if (g <= p) {
cleanDecimatedDataset(e);
return
}
switch ((0, s.k)(o) && (e._data = d, delete e.data, Object.defineProperty(e, "data", {
configurable: !0,
enumerable: !0,
get: function() {
return this._decimated
},
set: function(t) {
this._data = t
}
})), i.algorithm) {
case "lttb":
n = function(t, e, i, s, a) {
let r, n, o, l, h;
let d = a.samples || s;
if (d >= i) return t.slice(e, e + i);
let c = [],
u = (i - 2) / (d - 2),
g = 0,
p = e + i - 1,
f = e;
for (r = 0, c[g++] = t[f]; r < d - 2; r++) {
let s, a = 0,
d = 0,
p = Math.floor((r + 1) * u) + 1 + e,
m = Math.min(Math.floor((r + 2) * u) + 1, i) + e,
x = m - p;
for (s = p; s < m; s++) a += t[s].x, d += t[s].y;
a /= x, d /= x;
let b = Math.floor(r * u) + 1 + e,
_ = Math.min(Math.floor((r + 1) * u) + 1, i) + e,
{
x: v,
y: y
} = t[f];
for (o = l = -1, s = b; s < _; s++)(l = .5 * Math.abs((v - a) * (t[s].y - y) - (v - t[s].x) * (d - y))) > o && (o = l, n = t[s], h = s);
c[g++] = n, f = h
}
return c[g++] = t[p], c
}(d, u, g, a, i);
break;
case "min-max":
n = function(t, e, i, a) {
let r, n, o, l, h, d, c, u, g, p, f = 0,
m = 0,
x = [],
b = t[e].x,
_ = t[e + i - 1].x,
v = _ - b;
for (r = e; r < e + i; ++r) {
o = ((n = t[r]).x - b) / v * a, l = n.y;
let e = 0 | o;
if (e === h) l < g ? (g = l, d = r) : l > p && (p = l, c = r), f = (m * f + n.x) / ++m;
else {
let i = r - 1;
if (!(0, s.k)(d) && !(0, s.k)(c)) {
let e = Math.min(d, c),
s = Math.max(d, c);
e !== u && e !== i && x.push({
...t[e],
x: f
}), s !== u && s !== i && x.push({
...t[s],
x: f
})
}
r > 0 && i !== u && x.push(t[i]), x.push(n), h = e, m = 0, g = p = l, d = c = u = r
}
}
return x
}(d, u, g, a);
break;
default:
throw Error(`Unsupported decimation algorithm '${i.algorithm}'`)
}
e._decimated = n
})
},
destroy(t) {
cleanDecimatedData(t)
}
},
Filler: {
id: "filler",
afterDatasetsUpdate(t, e, i) {
let a, r, n, o;
let l = (t.data.datasets || []).length,
h = [];
for (r = 0; r < l; ++r) n = (a = t.getDatasetMeta(r)).dataset, o = null, n && n.options && n instanceof LineElement && (o = {
visible: t.isDatasetVisible(r),
index: r,
fill: function(t, e, i) {
let a = function(t) {
let e = t.options,
i = e.fill,
a = (0, s.v)(i && i.target, i);
return void 0 === a && (a = !!e.backgroundColor), !1 !== a && null !== a && (!0 === a ? "origin" : a)
}(t);
if ((0, s.i)(a)) return !isNaN(a.value) && a;
let r = parseFloat(a);
return (0, s.g)(r) && Math.floor(r) === r ? (("-" === a[0] || "+" === a[0]) && (r = e + r), r !== e && !(r < 0) && !(r >= i) && r) : ["origin", "start", "end", "stack", "shape"].indexOf(a) >= 0 && a
}(n, r, l),
chart: t,
axis: a.controller.options.indexAxis,
scale: a.vScale,
line: n
}), a.$filler = o, h.push(o);
for (r = 0; r < l; ++r)(o = h[r]) && !1 !== o.fill && (o.fill = function(t, e, i) {
let a;
let r = t[e],
n = r.fill,
o = [e];
if (!i) return n;
for (; !1 !== n && -1 === o.indexOf(n);) {
if (!(0, s.g)(n)) return n;
if (!(a = t[n])) break;
if (a.visible) return n;
o.push(n), n = a.fill
}
return !1
}(h, r, i.propagate))
},
beforeDraw(t, e, i) {
let s = "beforeDraw" === i.drawTime,
a = t.getSortedVisibleDatasetMetas(),
r = t.chartArea;
for (let e = a.length - 1; e >= 0; --e) {
let i = a[e].$filler;
i && (i.line.updateControlPoints(r, i.axis), s && drawfill(t.ctx, i, r))
}
},
beforeDatasetsDraw(t, e, i) {
if ("beforeDatasetsDraw" !== i.drawTime) return;
let s = t.getSortedVisibleDatasetMetas();
for (let e = s.length - 1; e >= 0; --e) {
let i = s[e].$filler;
i && drawfill(t.ctx, i, t.chartArea)
}
},
beforeDatasetDraw(t, e, i) {
let s = e.meta.$filler;
s && !1 !== s.fill && "beforeDatasetDraw" === i.drawTime && drawfill(t.ctx, s, t.chartArea)
},
defaults: {
propagate: !0,
drawTime: "beforeDatasetDraw"
}
},
Legend: {
id: "legend",
_element: Legend,
start(t, e, i) {
let s = t.legend = new Legend({
ctx: t.ctx,
options: i,
chart: t
});
u.configure(t, s, i), u.addBox(t, s)
},
stop(t) {
u.removeBox(t, t.legend), delete t.legend
},
beforeUpdate(t, e, i) {
let s = t.legend;
u.configure(t, s, i), s.options = i
},
afterUpdate(t) {
let e = t.legend;
e.buildLabels(), e.adjustHitBoxes()
},
afterEvent(t, e) {
e.replay || t.legend.handleEvent(e.event)
},
defaults: {
display: !0,
position: "top",
align: "center",
fullSize: !0,
reverse: !1,
weight: 1e3,
onClick(t, e, i) {
let s = e.datasetIndex,
a = i.chart;
a.isDatasetVisible(s) ? (a.hide(s), e.hidden = !0) : (a.show(s), e.hidden = !1)
},
onHover: null,
onLeave: null,
labels: {
color: t => t.chart.options.color,
boxWidth: 40,
padding: 10,
generateLabels(t) {
let e = t.data.datasets,
{
labels: {
usePointStyle: i,
pointStyle: a,
textAlign: r,
color: n
}
} = t.legend.options;
return t._getSortedDatasetMetas().map(t => {
let o = t.controller.getStyle(i ? 0 : void 0),
l = (0, s.C)(o.borderWidth);
return {
text: e[t.index].label,
fillStyle: o.backgroundColor,
fontColor: n,
hidden: !t.visible,
lineCap: o.borderCapStyle,
lineDash: o.borderDash,
lineDashOffset: o.borderDashOffset,
lineJoin: o.borderJoinStyle,
lineWidth: (l.width + l.height) / 4,
strokeStyle: o.borderColor,
pointStyle: a || o.pointStyle,
rotation: o.rotation,
textAlign: r || o.textAlign,
borderRadius: 0,
datasetIndex: t.index
}
}, this)
}
},
title: {
color: t => t.chart.options.color,
display: !1,
position: "center",
text: ""
}
},
descriptors: {
_scriptable: t => !t.startsWith("on"),
labels: {
_scriptable: t => !["generateLabels", "filter", "sort"].includes(t)
}
}
},
SubTitle: {
id: "subtitle",
start(t, e, i) {
let s = new Title({
ctx: t.ctx,
options: i,
chart: t
});
u.configure(t, s, i), u.addBox(t, s), C.set(t, s)
},
stop(t) {
u.removeBox(t, C.get(t)), C.delete(t)
},
beforeUpdate(t, e, i) {
let s = C.get(t);
u.configure(t, s, i), s.options = i
},
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
}
},
Title: {
id: "title",
_element: Title,
start(t, e, i) {
! function(t, e) {
let i = new Title({
ctx: t.ctx,
options: e,
chart: t
});
u.configure(t, i, e), u.addBox(t, i), t.titleBlock = i
}(t, i)
},
stop(t) {
let e = t.titleBlock;
u.removeBox(t, e), delete t.titleBlock
},
beforeUpdate(t, e, i) {
let s = t.titleBlock;
u.configure(t, s, i), s.options = i
},
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
}
},
Tooltip: L
});
let addIfString = (t, e, i, s) => ("string" == typeof e ? (i = t.push(e) - 1, s.unshift({
index: i,
label: e
})) : isNaN(e) && (i = null), i),
validIndex = (t, e) => null === t ? null : (0, s.w)(Math.round(t), 0, e);
let CategoryScale = class CategoryScale extends Scale {
constructor(t) {
super(t), this._startValue = void 0, this._valueRange = 0, this._addedLabels = []
}
init(t) {
let e = this._addedLabels;
if (e.length) {
let t = this.getLabels();
for (let {
index: i,
label: s
}
of e) t[i] === s && t.splice(i, 1);
this._addedLabels = []
}
super.init(t)
}
parse(t, e) {
if ((0, s.k)(t)) return null;
let i = this.getLabels();
return validIndex(e = isFinite(e) && i[e] === t ? e : function(t, e, i, s) {
let a = t.indexOf(e);
if (-1 === a) return addIfString(t, e, i, s);
let r = t.lastIndexOf(e);
return a !== r ? i : a
}(i, t, (0, s.v)(e, t), this._addedLabels), i.length - 1)
}
determineDataLimits() {
let {
minDefined: t,
maxDefined: e
} = this.getUserBounds(), {
min: i,
max: s
} = this.getMinMax(!0);
"ticks" !== this.options.bounds || (t || (i = 0), e || (s = this.getLabels().length - 1)), this.min = i, this.max = s
}
buildTicks() {
let t = this.min,
e = this.max,
i = this.options.offset,
s = [],
a = this.getLabels();
a = 0 === t && e === a.length - 1 ? a : a.slice(t, e + 1), this._valueRange = Math.max(a.length - (i ? 0 : 1), 1), this._startValue = this.min - (i ? .5 : 0);
for (let i = t; i <= e; i++) s.push({
value: i
});
return s
}
getLabelForValue(t) {
let e = this.getLabels();
return t >= 0 && t < e.length ? e[t] : t
}
configure() {
super.configure(), this.isHorizontal() || (this._reversePixels = !this._reversePixels)
}
getPixelForValue(t) {
return "number" != typeof t && (t = this.parse(t)), null === t ? NaN : this.getPixelForDecimal((t - this._startValue) / this._valueRange)
}
getPixelForTick(t) {
let 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
}
};
function relativeLabelSize(t, e, {
horizontal: i,
minRotation: a
}) {
let r = (0, s.t)(a),
n = .75 * e * ("" + t).length;
return Math.min(e / ((i ? Math.sin(r) : Math.cos(r)) || .001), n)
}
CategoryScale.id = "category", CategoryScale.defaults = {
ticks: {
callback: CategoryScale.prototype.getLabelForValue
}
};
let LinearScaleBase = class LinearScaleBase extends Scale {
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 (0, s.k)(t) || ("number" == typeof t || t instanceof Number) && !isFinite(+t) ? null : +t
}
handleTickRangeOptions() {
let {
beginAtZero: t
} = this.options, {
minDefined: e,
maxDefined: i
} = this.getUserBounds(), {
min: a,
max: r
} = this, setMin = t => a = e ? a : t, setMax = t => r = i ? r : t;
if (t) {
let t = (0, s.s)(a),
e = (0, s.s)(r);
t < 0 && e < 0 ? setMax(0) : t > 0 && e > 0 && setMin(0)
}
if (a === r) {
let e = 1;
(r >= Number.MAX_SAFE_INTEGER || a <= Number.MIN_SAFE_INTEGER) && (e = Math.abs(.05 * r)), setMax(r + e), t || setMin(a - e)
}
this.min = a, this.max = r
}
getTickLimit() {
let t;
let e = this.options.ticks,
{
maxTicksLimit: i,
stepSize: s
} = e;
return s ? (t = Math.ceil(this.max / s) - Math.floor(this.min / s) + 1) > 1e3 && (console.warn(`scales.${this.id}.ticks.stepSize: ${s} would result generating up to ${t} ticks. Limiting to 1000.`), t = 1e3) : (t = this.computeTickLimit(), i = i || 11), i && (t = Math.min(i, t)), t
}
computeTickLimit() {
return Number.POSITIVE_INFINITY
}
buildTicks() {
let t = this.options,
e = t.ticks,
i = this.getTickLimit();
i = Math.max(2, i);
let a = {
maxTicks: i,
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: !1 !== e.includeBounds
},
r = this._range || this,
n = function(t, e) {
let i, a, r, n;
let o = [],
{
bounds: l,
step: h,
min: d,
max: c,
precision: u,
count: g,
maxTicks: p,
maxDigits: f,
includeBounds: m
} = t,
x = h || 1,
b = p - 1,
{
min: _,
max: v
} = e,
y = !(0, s.k)(d),
k = !(0, s.k)(c),
M = !(0, s.k)(g),
w = (v - _) / (f + 1),
S = (0, s.aE)((v - _) / b / x) * x;
if (S < 1e-14 && !y && !k) return [{
value: _
}, {
value: v
}];
(n = Math.ceil(v / S) - Math.floor(_ / S)) > b && (S = (0, s.aE)(n * S / b / x) * x), (0, s.k)(u) || (S = Math.ceil(S * (i = Math.pow(10, u))) / i), "ticks" === l ? (a = Math.floor(_ / S) * S, r = Math.ceil(v / S) * S) : (a = _, r = v), y && k && h && (0, s.aF)((c - d) / h, S / 1e3) ? (n = Math.round(Math.min((c - d) / S, p)), S = (c - d) / n, a = d, r = c) : M ? (a = y ? d : a, S = ((r = k ? c : r) - a) / (n = g - 1)) : (n = (r - a) / S, n = (0, s.aG)(n, Math.round(n), S / 1e3) ? Math.round(n) : Math.ceil(n));
let D = Math.max((0, s.aH)(S), (0, s.aH)(a));
a = Math.round(a * (i = Math.pow(10, (0, s.k)(u) ? D : u))) / i, r = Math.round(r * i) / i;
let C = 0;
for (y && (m && a !== d ? (o.push({
value: d
}), a < d && C++, (0, s.aG)(Math.round((a + C * S) * i) / i, d, relativeLabelSize(d, w, t)) && C++) : a < d && C++); C < n; ++C) o.push({
value: Math.round((a + C * S) * i) / i
});
return k && m && r !== c ? o.length && (0, s.aG)(o[o.length - 1].value, c, relativeLabelSize(c, w, t)) ? o[o.length - 1].value = c : o.push({
value: c
}) : k && r !== c || o.push({
value: r
}), o
}(a, r);
return "ticks" === t.bounds && (0, s.aD)(n, this, "value"), t.reverse ? (n.reverse(), this.start = this.max, this.end = this.min) : (this.start = this.min, this.end = this.max), n
}
configure() {
let t = this.ticks,
e = this.min,
i = this.max;
if (super.configure(), this.options.offset && t.length) {
let s = (i - e) / Math.max(t.length - 1, 1) / 2;
e -= s, i += s
}
this._startValue = e, this._endValue = i, this._valueRange = i - e
}
getLabelForValue(t) {
return (0, s.o)(t, this.chart.options.locale, this.options.ticks.format)
}
};
let LinearScale = class LinearScale extends LinearScaleBase {
determineDataLimits() {
let {
min: t,
max: e
} = this.getMinMax(!0);
this.min = (0, s.g)(t) ? t : 0, this.max = (0, s.g)(e) ? e : 1, this.handleTickRangeOptions()
}
computeTickLimit() {
let t = this.isHorizontal(),
e = t ? this.width : this.height,
i = (0, s.t)(this.options.ticks.minRotation),
a = this._resolveTickFontOptions(0);
return Math.ceil(e / Math.min(40, a.lineHeight / ((t ? Math.sin(i) : Math.cos(i)) || .001)))
}
getPixelForValue(t) {
return null === t ? NaN : this.getPixelForDecimal((t - this._startValue) / this._valueRange)
}
getValueForPixel(t) {
return this._startValue + this.getDecimalForPixel(t) * this._valueRange
}
};
function isMajor(t) {
let e = t / Math.pow(10, Math.floor((0, s.L)(t)));
return 1 === e
}
LinearScale.id = "linear", LinearScale.defaults = {
ticks: {
callback: _.formatters.numeric
}
};
let LogarithmicScale = class LogarithmicScale extends Scale {
constructor(t) {
super(t), this.start = void 0, this.end = void 0, this._startValue = void 0, this._valueRange = 0
}
parse(t, e) {
let i = LinearScaleBase.prototype.parse.apply(this, [t, e]);
if (0 === i) {
this._zero = !0;
return
}
return (0, s.g)(i) && i > 0 ? i : null
}
determineDataLimits() {
let {
min: t,
max: e
} = this.getMinMax(!0);
this.min = (0, s.g)(t) ? Math.max(0, t) : null, this.max = (0, s.g)(e) ? Math.max(0, e) : null, this.options.beginAtZero && (this._zero = !0), this.handleTickRangeOptions()
}
handleTickRangeOptions() {
let {
minDefined: t,
maxDefined: e
} = this.getUserBounds(), i = this.min, a = this.max, setMin = e => i = t ? i : e, setMax = t => a = e ? a : t, exp = (t, e) => Math.pow(10, Math.floor((0, s.L)(t)) + e);
i === a && (i <= 0 ? (setMin(1), setMax(10)) : (setMin(exp(i, -1)), setMax(exp(a, 1)))), i <= 0 && setMin(exp(a, -1)), a <= 0 && setMax(exp(i, 1)), this._zero && this.min !== this._suggestedMin && i === exp(this.min, 0) && setMin(exp(i, -1)), this.min = i, this.max = a
}
buildTicks() {
let t = this.options,
e = {
min: this._userMin,
max: this._userMax
},
i = function(t, e) {
let i = Math.floor((0, s.L)(e.max)),
a = Math.ceil(e.max / Math.pow(10, i)),
r = [],
n = (0, s.N)(t.min, Math.pow(10, Math.floor((0, s.L)(e.min)))),
o = Math.floor((0, s.L)(n)),
l = Math.floor(n / Math.pow(10, o)),
h = o < 0 ? Math.pow(10, Math.abs(o)) : 1;
do r.push({
value: n,
major: isMajor(n)
}), 10 == ++l && (l = 1, h = ++o >= 0 ? 1 : h), n = Math.round(l * Math.pow(10, o) * h) / h; while (o < i || o === i && l < a);
let d = (0, s.N)(t.max, n);
return r.push({
value: d,
major: isMajor(n)
}), r
}(e, this);
return "ticks" === t.bounds && (0, s.aD)(i, this, "value"), t.reverse ? (i.reverse(), this.start = this.max, this.end = this.min) : (this.start = this.min, this.end = this.max), i
}
getLabelForValue(t) {
return void 0 === t ? "0" : (0, s.o)(t, this.chart.options.locale, this.options.ticks.format)
}
configure() {
let t = this.min;
super.configure(), this._startValue = (0, s.L)(t), this._valueRange = (0, s.L)(this.max) - (0, s.L)(t)
}
getPixelForValue(t) {
return ((void 0 === t || 0 === t) && (t = this.min), null === t || isNaN(t)) ? NaN : this.getPixelForDecimal(t === this.min ? 0 : ((0, s.L)(t) - this._startValue) / this._valueRange)
}
getValueForPixel(t) {
let e = this.getDecimalForPixel(t);
return Math.pow(10, this._startValue + e * this._valueRange)
}
};
function getTickBackdropHeight(t) {
let e = t.ticks;
if (e.display && t.display) {
let t = (0, s.C)(e.backdropPadding);
return (0, s.v)(e.font && e.font.size, s.d.font.size) + t.height
}
return 0
}
function determineLimits(t, e, i, s, a) {
return t === s || t === a ? {
start: e - i / 2,
end: e + i / 2
} : t < s || t > a ? {
start: e - i,
end: e
} : {
start: e,
end: e + i
}
}
function pathRadiusLine(t, e, i, a) {
let {
ctx: r
} = t;
if (i) r.arc(t.xCenter, t.yCenter, e, 0, s.T);
else {
let i = t.getPointPosition(0, e);
r.moveTo(i.x, i.y);
for (let s = 1; s < a; s++) i = t.getPointPosition(s, e), r.lineTo(i.x, i.y)
}
}
LogarithmicScale.id = "logarithmic", LogarithmicScale.defaults = {
ticks: {
callback: _.formatters.logarithmic,
major: {
enabled: !0
}
}
};
let RadialLinearScale = class RadialLinearScale extends LinearScaleBase {
constructor(t) {
super(t), this.xCenter = void 0, this.yCenter = void 0, this.drawingArea = void 0, this._pointLabels = [], this._pointLabelItems = []
}
setDimensions() {
let t = this._padding = (0, s.C)(getTickBackdropHeight(this.options) / 2),
e = this.width = this.maxWidth - t.width,
i = this.height = this.maxHeight - t.height;
this.xCenter = Math.floor(this.left + e / 2 + t.left), this.yCenter = Math.floor(this.top + i / 2 + t.top), this.drawingArea = Math.floor(Math.min(e, i) / 2)
}
determineDataLimits() {
let {
min: t,
max: e
} = this.getMinMax(!1);
this.min = (0, s.g)(t) && !isNaN(t) ? t : 0, this.max = (0, s.g)(e) && !isNaN(e) ? e : 0, this.handleTickRangeOptions()
}
computeTickLimit() {
return Math.ceil(this.drawingArea / getTickBackdropHeight(this.options))
}
generateTickLabels(t) {
LinearScaleBase.prototype.generateTickLabels.call(this, t), this._pointLabels = this.getLabels().map((t, e) => {
let i = (0, s.O)(this.options.pointLabels.callback, [t, e], this);
return i || 0 === i ? i : ""
}).filter((t, e) => this.chart.getDataVisibility(e))
}
fit() {
let t = this.options;
t.display && t.pointLabels.display ? function(t) {
let e = {
l: t.left + t._padding.left,
r: t.right - t._padding.right,
t: t.top + t._padding.top,
b: t.bottom - t._padding.bottom
},
i = Object.assign({}, e),
a = [],
r = [],
n = t._pointLabels.length,
o = t.options.pointLabels,
l = o.centerPointLabels ? s.P / n : 0;
for (let c = 0; c < n; c++) {
var h, d;
let n = o.setContext(t.getPointLabelContext(c));
r[c] = n.padding;
let u = t.getPointPosition(c, t.drawingArea + r[c], l),
g = (0, s.Z)(n.font),
p = (h = t.ctx, d = t._pointLabels[c], d = (0, s.b)(d) ? d : [d], {
w: (0, s.aI)(h, g.string, d),
h: d.length * g.lineHeight
});
a[c] = p;
let f = (0, s.aw)(t.getIndexAngle(c) + l),
m = Math.round((0, s.R)(f)),
x = determineLimits(m, u.x, p.w, 0, 180),
b = determineLimits(m, u.y, p.h, 90, 270);
! function(t, e, i, s, a) {
let r = Math.abs(Math.sin(i)),
n = Math.abs(Math.cos(i)),
o = 0,
l = 0;
s.start < e.l ? (o = (e.l - s.start) / r, t.l = Math.min(t.l, e.l - o)) : s.end > e.r && (o = (s.end - e.r) / r, t.r = Math.max(t.r, e.r + o)), a.start < e.t ? (l = (e.t - a.start) / n, t.t = Math.min(t.t, e.t - l)) : a.end > e.b && (l = (a.end - e.b) / n, t.b = Math.max(t.b, e.b + l))
}(i, e, f, x, b)
}
t.setCenterPoint(e.l - i.l, i.r - e.r, e.t - i.t, i.b - e.b), t._pointLabelItems = function(t, e, i) {
let a = [],
r = t._pointLabels.length,
n = t.options,
o = getTickBackdropHeight(n) / 2,
l = t.drawingArea,
h = n.pointLabels.centerPointLabels ? s.P / r : 0;
for (let n = 0; n < r; n++) {
var d, c, u, g;
let r = t.getPointPosition(n, l + o + i[n], h),
p = Math.round((0, s.R)((0, s.aw)(r.angle + s.H))),
f = e[n],
m = (d = r.y, c = f.h, 90 === p || 270 === p ? d -= c / 2 : (p > 270 || p < 90) && (d -= c), d),
x = 0 === p || 180 === p ? "center" : p < 180 ? "left" : "right",
b = (u = r.x, g = f.w, "right" === x ? u -= g : "center" === x && (u -= g / 2), u);
a.push({
x: r.x,
y: m,
textAlign: x,
left: b,
top: m,
right: b + f.w,
bottom: m + f.h
})
}
return a
}(t, a, r)
}(this) : this.setCenterPoint(0, 0, 0, 0)
}
setCenterPoint(t, e, i, s) {
this.xCenter += Math.floor((t - e) / 2), this.yCenter += Math.floor((i - s) / 2), this.drawingArea -= Math.min(this.drawingArea / 2, Math.max(t, e, i, s))
}
getIndexAngle(t) {
let e = s.T / (this._pointLabels.length || 1),
i = this.options.startAngle || 0;
return (0, s.aw)(t * e + (0, s.t)(i))
}
getDistanceFromCenterForValue(t) {
if ((0, s.k)(t)) return NaN;
let e = this.drawingArea / (this.max - this.min);
return this.options.reverse ? (this.max - t) * e : (t - this.min) * e
}
getValueForDistanceFromCenter(t) {
if ((0, s.k)(t)) return NaN;
let e = t / (this.drawingArea / (this.max - this.min));
return this.options.reverse ? this.max - e : this.min + e
}
getPointLabelContext(t) {
let e = this._pointLabels || [];
if (t >= 0 && t < e.length) {
var i;
let a = e[t];
return i = this.getContext(), (0, s.h)(i, {
label: a,
index: t,
type: "pointLabel"
})
}
}
getPointPosition(t, e, i = 0) {
let a = this.getIndexAngle(t) - s.H + i;
return {
x: Math.cos(a) * e + this.xCenter,
y: Math.sin(a) * e + this.yCenter,
angle: a
}
}
getPointPositionForValue(t, e) {
return this.getPointPosition(t, this.getDistanceFromCenterForValue(e))
}
getBasePosition(t) {
return this.getPointPositionForValue(t || 0, this.getBaseValue())
}
getPointLabelPosition(t) {
let {
left: e,
top: i,
right: s,
bottom: a
} = this._pointLabelItems[t];
return {
left: e,
top: i,
right: s,
bottom: a
}
}
drawBackground() {
let {
backgroundColor: t,
grid: {
circular: e
}
} = this.options;
if (t) {
let i = this.ctx;
i.save(), i.beginPath(), pathRadiusLine(this, this.getDistanceFromCenterForValue(this._endValue), e, this._pointLabels.length), i.closePath(), i.fillStyle = t, i.fill(), i.restore()
}
}
drawGrid() {
let t, e, i;
let a = this.ctx,
r = this.options,
{
angleLines: n,
grid: o
} = r,
l = this._pointLabels.length;
if (r.pointLabels.display && function(t, e) {
let {
ctx: i,
options: {
pointLabels: a
}
} = t;
for (let r = e - 1; r >= 0; r--) {
let e = a.setContext(t.getPointLabelContext(r)),
n = (0, s.Z)(e.font),
{
x: o,
y: l,
textAlign: h,
left: d,
top: c,
right: u,
bottom: g
} = t._pointLabelItems[r],
{
backdropColor: p
} = e;
if (!(0, s.k)(p)) {
let t = (0, s.C)(e.backdropPadding);
i.fillStyle = p, i.fillRect(d - t.left, c - t.top, u - d + t.width, g - c + t.height)
}(0, s.X)(i, t._pointLabels[r], o, l + n.lineHeight / 2, n, {
color: e.color,
textAlign: h,
textBaseline: "middle"
})
}
}(this, l), o.display && this.ticks.forEach((t, i) => {
if (0 !== i) {
e = this.getDistanceFromCenterForValue(t.value);
let s = o.setContext(this.getContext(i - 1));
! function(t, e, i, s) {
let a = t.ctx,
r = e.circular,
{
color: n,
lineWidth: o
} = e;
(r || s) && n && o && !(i < 0) && (a.save(), a.strokeStyle = n, a.lineWidth = o, a.setLineDash(e.borderDash), a.lineDashOffset = e.borderDashOffset, a.beginPath(), pathRadiusLine(t, i, r, s), a.closePath(), a.stroke(), a.restore())
}(this, s, e, l)
}
}), n.display) {
for (a.save(), t = l - 1; t >= 0; t--) {
let s = n.setContext(this.getPointLabelContext(t)),
{
color: o,
lineWidth: l
} = s;
l && o && (a.lineWidth = l, a.strokeStyle = o, a.setLineDash(s.borderDash), a.lineDashOffset = s.borderDashOffset, e = this.getDistanceFromCenterForValue(r.ticks.reverse ? this.min : this.max), i = this.getPointPosition(t, e), a.beginPath(), a.moveTo(this.xCenter, this.yCenter), a.lineTo(i.x, i.y), a.stroke())
}
a.restore()
}
}
drawBorder() {}
drawLabels() {
let t, e;
let i = this.ctx,
a = this.options,
r = a.ticks;
if (!r.display) return;
let n = this.getIndexAngle(0);
i.save(), i.translate(this.xCenter, this.yCenter), i.rotate(n), i.textAlign = "center", i.textBaseline = "middle", this.ticks.forEach((n, o) => {
if (0 === o && !a.reverse) return;
let l = r.setContext(this.getContext(o)),
h = (0, s.Z)(l.font);
if (t = this.getDistanceFromCenterForValue(this.ticks[o].value), l.showLabelBackdrop) {
i.font = h.string, e = i.measureText(n.label).width, i.fillStyle = l.backdropColor;
let a = (0, s.C)(l.backdropPadding);
i.fillRect(-e / 2 - a.left, -t - h.size / 2 - a.top, e + a.width, h.size + a.height)
}(0, s.X)(i, n.label, 0, -t, h, {
color: l.color
})
}), i.restore()
}
drawTitle() {}
};
RadialLinearScale.id = "radialLinear", RadialLinearScale.defaults = {
display: !0,
animate: !0,
position: "chartArea",
angleLines: {
display: !0,
lineWidth: 1,
borderDash: [],
borderDashOffset: 0
},
grid: {
circular: !1
},
startAngle: 0,
ticks: {
showLabelBackdrop: !0,
callback: _.formatters.numeric
},
pointLabels: {
backdropColor: void 0,
backdropPadding: 2,
display: !0,
font: {
size: 10
},
callback: t => t,
padding: 5,
centerPointLabels: !1
}
}, RadialLinearScale.defaultRoutes = {
"angleLines.color": "borderColor",
"pointLabels.color": "color",
"ticks.color": "color"
}, RadialLinearScale.descriptors = {
angleLines: {
_fallback: "grid"
}
};
let O = {
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
}
},
T = Object.keys(O);
function sorter(t, e) {
return t - e
}
function parse(t, e) {
if ((0, s.k)(e)) return null;
let i = t._adapter,
{
parser: a,
round: r,
isoWeekday: n
} = t._parseOpts,
o = e;
return ("function" == typeof a && (o = a(o)), (0, s.g)(o) || (o = "string" == typeof a ? i.parse(o, a) : i.parse(o)), null === o) ? null : (r && (o = "week" === r && ((0, s.q)(n) || !0 === n) ? i.startOf(o, "isoWeek", n) : i.startOf(o, r)), +o)
}
function determineUnitForAutoTicks(t, e, i, s) {
let a = T.length;
for (let r = T.indexOf(t); r < a - 1; ++r) {
let t = O[T[r]],
a = t.steps ? t.steps : Number.MAX_SAFE_INTEGER;
if (t.common && Math.ceil((i - e) / (a * t.size)) <= s) return T[r]
}
return T[a - 1]
}
function addTick(t, e, i) {
if (i) {
if (i.length) {
let {
lo: a,
hi: r
} = (0, s.aK)(i, e), n = i[a] >= e ? i[a] : i[r];
t[n] = !0
}
} else t[e] = !0
}
function ticksFromTimestamps(t, e, i) {
let s, a;
let r = [],
n = {},
o = e.length;
for (s = 0; s < o; ++s) n[a = e[s]] = s, r.push({
value: a,
major: !1
});
return 0 !== o && i ? function(t, e, i, s) {
let a, r;
let n = t._adapter,
o = +n.startOf(e[0].value, s),
l = e[e.length - 1].value;
for (a = o; a <= l; a = +n.add(a, 1, s))(r = i[a]) >= 0 && (e[r].major = !0);
return e
}(t, r, n, i) : r
}
let TimeScale = class TimeScale extends Scale {
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) {
let i = t.time || (t.time = {}),
a = this._adapter = new h._date(t.adapters.date);
(0, s.a9)(i.displayFormats, a.formats()), this._parseOpts = {
parser: i.parser,
round: i.round,
isoWeekday: i.isoWeekday
}, super.init(t), this._normalized = e.normalized
}
parse(t, e) {
return void 0 === t ? null : parse(this, t)
}
beforeLayout() {
super.beforeLayout(), this._cache = {
data: [],
labels: [],
all: []
}
}
determineDataLimits() {
let t = this.options,
e = this._adapter,
i = t.time.unit || "day",
{
min: a,
max: r,
minDefined: n,
maxDefined: o
} = this.getUserBounds();
function _applyBounds(t) {
n || isNaN(t.min) || (a = Math.min(a, t.min)), o || isNaN(t.max) || (r = Math.max(r, t.max))
}
n && o || (_applyBounds(this._getLabelBounds()), ("ticks" !== t.bounds || "labels" !== t.ticks.source) && _applyBounds(this.getMinMax(!1))), a = (0, s.g)(a) && !isNaN(a) ? a : +e.startOf(Date.now(), i), r = (0, s.g)(r) && !isNaN(r) ? r : +e.endOf(Date.now(), i) + 1, this.min = Math.min(a, r - 1), this.max = Math.max(a + 1, r)
}
_getLabelBounds() {
let t = this.getLabelTimestamps(),
e = Number.POSITIVE_INFINITY,
i = Number.NEGATIVE_INFINITY;
return t.length && (e = t[0], i = t[t.length - 1]), {
min: e,
max: i
}
}
buildTicks() {
let t = this.options,
e = t.time,
i = t.ticks,
a = "labels" === i.source ? this.getLabelTimestamps() : this._generate();
"ticks" === t.bounds && a.length && (this.min = this._userMin || a[0], this.max = this._userMax || a[a.length - 1]);
let r = this.min,
n = this.max,
o = (0, s.aJ)(a, r, n);
return this._unit = e.unit || (i.autoSkip ? determineUnitForAutoTicks(e.minUnit, this.min, this.max, this._getLabelCapacity(r)) : function(t, e, i, s, a) {
for (let r = T.length - 1; r >= T.indexOf(i); r--) {
let i = T[r];
if (O[i].common && t._adapter.diff(a, s, i) >= e - 1) return i
}
return T[i ? T.indexOf(i) : 0]
}(this, o.length, e.minUnit, this.min, this.max)), this._majorUnit = i.major.enabled && "year" !== this._unit ? function(t) {
for (let e = T.indexOf(t) + 1, i = T.length; e < i; ++e)
if (O[T[e]].common) return T[e]
}(this._unit) : void 0, this.initOffsets(a), t.reverse && o.reverse(), ticksFromTimestamps(this, o, this._majorUnit)
}
initOffsets(t) {
let e, i, a = 0,
r = 0;
this.options.offset && t.length && (e = this.getDecimalForValue(t[0]), a = 1 === t.length ? 1 - e : (this.getDecimalForValue(t[1]) - e) / 2, i = this.getDecimalForValue(t[t.length - 1]), r = 1 === t.length ? i : (i - this.getDecimalForValue(t[t.length - 2])) / 2);
let n = t.length < 3 ? .5 : .25;
a = (0, s.w)(a, 0, n), r = (0, s.w)(r, 0, n), this._offsets = {
start: a,
end: r,
factor: 1 / (a + 1 + r)
}
}
_generate() {
let t, e;
let i = this._adapter,
a = this.min,
r = this.max,
n = this.options,
o = n.time,
l = o.unit || determineUnitForAutoTicks(o.minUnit, a, r, this._getLabelCapacity(a)),
h = (0, s.v)(o.stepSize, 1),
d = "week" === l && o.isoWeekday,
c = (0, s.q)(d) || !0 === d,
u = {},
g = a;
if (c && (g = +i.startOf(g, "isoWeek", d)), g = +i.startOf(g, c ? "day" : l), i.diff(r, a, l) > 1e5 * h) throw Error(a + " and " + r + " are too far apart with stepSize of " + h + " " + l);
let p = "data" === n.ticks.source && this.getDataTimestamps();
for (t = g, e = 0; t < r; t = +i.add(t, h, l), e++) addTick(u, t, p);
return (t === r || "ticks" === n.bounds || 1 === e) && addTick(u, t, p), Object.keys(u).sort((t, e) => t - e).map(t => +t)
}
getLabelForValue(t) {
let e = this._adapter,
i = this.options.time;
return i.tooltipFormat ? e.format(t, i.tooltipFormat) : e.format(t, i.displayFormats.datetime)
}
_tickFormatFunction(t, e, i, a) {
let r = this.options,
n = r.time.displayFormats,
o = this._unit,
l = this._majorUnit,
h = o && n[o],
d = l && n[l],
c = i[e],
u = l && d && c && c.major,
g = this._adapter.format(t, a || (u ? d : h)),
p = r.ticks.callback;
return p ? (0, s.O)(p, [g, e, i], this) : g
}
generateTickLabels(t) {
let e, i, s;
for (e = 0, i = t.length; e < i; ++e)(s = t[e]).label = this._tickFormatFunction(s.value, e, t)
}
getDecimalForValue(t) {
return null === t ? NaN : (t - this.min) / (this.max - this.min)
}
getPixelForValue(t) {
let e = this._offsets,
i = this.getDecimalForValue(t);
return this.getPixelForDecimal((e.start + i) * e.factor)
}
getValueForPixel(t) {
let e = this._offsets,
i = this.getDecimalForPixel(t) / e.factor - e.end;
return this.min + i * (this.max - this.min)
}
_getLabelSize(t) {
let e = this.options.ticks,
i = this.ctx.measureText(t).width,
a = (0, s.t)(this.isHorizontal() ? e.maxRotation : e.minRotation),
r = Math.cos(a),
n = Math.sin(a),
o = this._resolveTickFontOptions(0).size;
return {
w: i * r + o * n,
h: i * n + o * r
}
}
_getLabelCapacity(t) {
let e = this.options.time,
i = e.displayFormats,
s = i[e.unit] || i.millisecond,
a = this._tickFormatFunction(t, 0, ticksFromTimestamps(this, [t], this._majorUnit), s),
r = this._getLabelSize(a),
n = Math.floor(this.isHorizontal() ? this.width / r.w : this.height / r.h) - 1;
return n > 0 ? n : 1
}
getDataTimestamps() {
let t, e, i = this._cache.data || [];
if (i.length) return i;
let s = this.getMatchingVisibleMetas();
if (this._normalized && s.length) return this._cache.data = s[0].controller.getAllParsedValues(this);
for (t = 0, e = s.length; t < e; ++t) i = i.concat(s[t].controller.getAllParsedValues(this));
return this._cache.data = this.normalize(i)
}
getLabelTimestamps() {
let t, e;
let i = this._cache.labels || [];
if (i.length) return i;
let s = this.getLabels();
for (t = 0, e = s.length; t < e; ++t) i.push(parse(this, s[t]));
return this._cache.labels = this._normalized ? i : this.normalize(i)
}
normalize(t) {
return (0, s._)(t.sort(sorter))
}
};
function interpolate(t, e, i) {
let a, r, n, o, l = 0,
h = t.length - 1;
i ? (e >= t[l].pos && e <= t[h].pos && ({
lo: l,
hi: h
} = (0, s.x)(t, "pos", e)), {
pos: a,
time: n
} = t[l], {
pos: r,
time: o
} = t[h]) : (e >= t[l].time && e <= t[h].time && ({
lo: l,
hi: h
} = (0, s.x)(t, "time", e)), {
time: a,
pos: n
} = t[l], {
time: r,
pos: o
} = t[h]);
let d = r - a;
return d ? n + (o - n) * (e - a) / d : n
}
TimeScale.id = "time", TimeScale.defaults = {
bounds: "data",
adapters: {},
time: {
parser: !1,
unit: !1,
round: !1,
isoWeekday: !1,
minUnit: "millisecond",
displayFormats: {}
},
ticks: {
source: "auto",
major: {
enabled: !1
}
}
};
let TimeSeriesScale = class TimeSeriesScale extends TimeScale {
constructor(t) {
super(t), this._table = [], this._minPos = void 0, this._tableRange = void 0
}
initOffsets() {
let t = this._getTimestampsForTable(),
e = this._table = this.buildLookupTable(t);
this._minPos = interpolate(e, this.min), this._tableRange = interpolate(e, this.max) - this._minPos, super.initOffsets(t)
}
buildLookupTable(t) {
let e, i, s;
let {
min: a,
max: r
} = this, n = [], o = [];
for (e = 0, i = t.length; e < i; ++e)(s = t[e]) >= a && s <= r && n.push(s);
if (n.length < 2) return [{
time: a,
pos: 0
}, {
time: r,
pos: 1
}];
for (e = 0, i = n.length; e < i; ++e) Math.round((n[e + 1] + n[e - 1]) / 2) !== (s = n[e]) && o.push({
time: s,
pos: e / (i - 1)
});
return o
}
_getTimestampsForTable() {
let t = this._cache.all || [];
if (t.length) return t;
let e = this.getDataTimestamps(),
i = this.getLabelTimestamps();
return t = e.length && i.length ? this.normalize(e.concat(i)) : e.length ? e : i, t = this._cache.all = t
}
getDecimalForValue(t) {
return (interpolate(this._table, t) - this._minPos) / this._tableRange
}
getValueForPixel(t) {
let e = this._offsets,
i = this.getDecimalForPixel(t) / e.factor - e.end;
return interpolate(this._table, i * this._tableRange + this._minPos, !0)
}
};
TimeSeriesScale.id = "timeseries", TimeSeriesScale.defaults = TimeScale.defaults;
var E = Object.freeze({
__proto__: null,
CategoryScale: CategoryScale,
LinearScale: LinearScale,
LogarithmicScale: LogarithmicScale,
RadialLinearScale: RadialLinearScale,
TimeScale: TimeScale,
TimeSeriesScale: TimeSeriesScale
});
let R = [l, D, A, E]
}
}
]);