PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 1.19.0
Independent Analytics – WordPress Analytics Plugin v1.19.0
2.15.5 2.15.4 2.15.3 2.15.2 2.15.1 2.15.0 2.14.10 trunk 1.1 1.10 1.10.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.17.1 1.17.2 1.17.3 1.17.4 1.18 1.18.1 1.19.0 1.19.1 1.2 1.20.0 1.21.0 1.22.0 1.22.1 1.23.0 1.23.1 1.24.0 1.24.1 1.25.0 1.25.1 1.26.0 1.27.0 1.28.0 1.28.1 1.28.2 1.28.3 1.29.0 1.3 1.30.0 1.30.1 1.4 1.5 1.6 1.7 1.8 1.9 2.0.0 2.0.1 2.1.4 2.1.5 2.1.6 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.10 2.11.2 2.11.3 2.11.4 2.11.5 2.11.6 2.11.7 2.11.8 2.11.9 2.12.0 2.12.1 2.12.2 2.13.1 2.13.2 2.13.5 2.13.6 2.14.0 2.14.1 2.14.2 2.14.4 2.14.6 2.14.7 2.14.8 2.14.9 2.2.0 2.2.1 2.3.1 2.3.2 2.4.2 2.4.3 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.7.0 2.7.1 2.7.2 2.7.3 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7
independent-analytics / dist / js / dashboard_widget.js
independent-analytics / dist / js Last commit date
dashboard_widget.js 3 years ago dashboard_widget.js.map 3 years ago data-table.js 3 years ago data-table.js.map 3 years ago index.js 3 years ago index.js.map 3 years ago learn.js 3 years ago learn.js.map 3 years ago settings.js 3 years ago settings.js.map 3 years ago
dashboard_widget.js
20510 lines
1 // modules are defined as an array
2 // [ module function, map of requires ]
3 //
4 // map of requires is short require name -> numeric require
5 //
6 // anything defined in a previous bundle is accessed via the
7 // orig method which is the require for previous bundles
8
9 (function (modules, entry, mainEntry, parcelRequireName, globalName) {
10 /* eslint-disable no-undef */
11 var globalObject =
12 typeof globalThis !== 'undefined'
13 ? globalThis
14 : typeof self !== 'undefined'
15 ? self
16 : typeof window !== 'undefined'
17 ? window
18 : typeof global !== 'undefined'
19 ? global
20 : {};
21 /* eslint-enable no-undef */
22
23 // Save the require from previous bundle to this closure if any
24 var previousRequire =
25 typeof globalObject[parcelRequireName] === 'function' &&
26 globalObject[parcelRequireName];
27
28 var cache = previousRequire.cache || {};
29 // Do not use `require` to prevent Webpack from trying to bundle this call
30 var nodeRequire =
31 typeof module !== 'undefined' &&
32 typeof module.require === 'function' &&
33 module.require.bind(module);
34
35 function newRequire(name, jumped) {
36 if (!cache[name]) {
37 if (!modules[name]) {
38 // if we cannot find the module within our internal map or
39 // cache jump to the current global require ie. the last bundle
40 // that was added to the page.
41 var currentRequire =
42 typeof globalObject[parcelRequireName] === 'function' &&
43 globalObject[parcelRequireName];
44 if (!jumped && currentRequire) {
45 return currentRequire(name, true);
46 }
47
48 // If there are other bundles on this page the require from the
49 // previous one is saved to 'previousRequire'. Repeat this as
50 // many times as there are bundles until the module is found or
51 // we exhaust the require chain.
52 if (previousRequire) {
53 return previousRequire(name, true);
54 }
55
56 // Try the node require function if it exists.
57 if (nodeRequire && typeof name === 'string') {
58 return nodeRequire(name);
59 }
60
61 var err = new Error("Cannot find module '" + name + "'");
62 err.code = 'MODULE_NOT_FOUND';
63 throw err;
64 }
65
66 localRequire.resolve = resolve;
67 localRequire.cache = {};
68
69 var module = (cache[name] = new newRequire.Module(name));
70
71 modules[name][0].call(
72 module.exports,
73 localRequire,
74 module,
75 module.exports,
76 this
77 );
78 }
79
80 return cache[name].exports;
81
82 function localRequire(x) {
83 var res = localRequire.resolve(x);
84 return res === false ? {} : newRequire(res);
85 }
86
87 function resolve(x) {
88 var id = modules[name][1][x];
89 return id != null ? id : x;
90 }
91 }
92
93 function Module(moduleName) {
94 this.id = moduleName;
95 this.bundle = newRequire;
96 this.exports = {};
97 }
98
99 newRequire.isParcelRequire = true;
100 newRequire.Module = Module;
101 newRequire.modules = modules;
102 newRequire.cache = cache;
103 newRequire.parent = previousRequire;
104 newRequire.register = function (id, exports) {
105 modules[id] = [
106 function (require, module) {
107 module.exports = exports;
108 },
109 {},
110 ];
111 };
112
113 Object.defineProperty(newRequire, 'root', {
114 get: function () {
115 return globalObject[parcelRequireName];
116 },
117 });
118
119 globalObject[parcelRequireName] = newRequire;
120
121 for (var i = 0; i < entry.length; i++) {
122 newRequire(entry[i]);
123 }
124
125 if (mainEntry) {
126 // Expose entry point to Node, AMD or browser globals
127 // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js
128 var mainExports = newRequire(mainEntry);
129
130 // CommonJS
131 if (typeof exports === 'object' && typeof module !== 'undefined') {
132 module.exports = mainExports;
133
134 // RequireJS
135 } else if (typeof define === 'function' && define.amd) {
136 define(function () {
137 return mainExports;
138 });
139
140 // <script>
141 } else if (globalName) {
142 this[globalName] = mainExports;
143 }
144 }
145 })({"kNoSz":[function(require,module,exports) {
146 var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
147 var _stimulus = require("@hotwired/stimulus");
148 var _chartController = require("./controllers/chart_controller");
149 var _chartControllerDefault = parcelHelpers.interopDefault(_chartController);
150 window.Stimulus = (0, _stimulus.Application).start();
151 Stimulus.register("chart", (0, _chartControllerDefault.default));
152
153 },{"@hotwired/stimulus":"27q4D","./controllers/chart_controller":"hrjuy","@parcel/transformer-js/src/esmodule-helpers.js":"jIm8e"}],"27q4D":[function(require,module,exports) {
154 var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
155 parcelHelpers.defineInteropFlag(exports);
156 parcelHelpers.export(exports, "Application", function() {
157 return Application;
158 });
159 parcelHelpers.export(exports, "AttributeObserver", function() {
160 return AttributeObserver;
161 });
162 parcelHelpers.export(exports, "Context", function() {
163 return Context;
164 });
165 parcelHelpers.export(exports, "Controller", function() {
166 return Controller;
167 });
168 parcelHelpers.export(exports, "ElementObserver", function() {
169 return ElementObserver;
170 });
171 parcelHelpers.export(exports, "IndexedMultimap", function() {
172 return IndexedMultimap;
173 });
174 parcelHelpers.export(exports, "Multimap", function() {
175 return Multimap;
176 });
177 parcelHelpers.export(exports, "StringMapObserver", function() {
178 return StringMapObserver;
179 });
180 parcelHelpers.export(exports, "TokenListObserver", function() {
181 return TokenListObserver;
182 });
183 parcelHelpers.export(exports, "ValueListObserver", function() {
184 return ValueListObserver;
185 });
186 parcelHelpers.export(exports, "add", function() {
187 return add;
188 });
189 parcelHelpers.export(exports, "defaultSchema", function() {
190 return defaultSchema;
191 });
192 parcelHelpers.export(exports, "del", function() {
193 return del;
194 });
195 parcelHelpers.export(exports, "fetch", function() {
196 return fetch;
197 });
198 parcelHelpers.export(exports, "prune", function() {
199 return prune;
200 });
201 var _asyncToGeneratorJs = require("@swc/helpers/lib/_async_to_generator.js");
202 var _asyncToGeneratorJsDefault = parcelHelpers.interopDefault(_asyncToGeneratorJs);
203 var _classCallCheckJs = require("@swc/helpers/lib/_class_call_check.js");
204 var _classCallCheckJsDefault = parcelHelpers.interopDefault(_classCallCheckJs);
205 var _createClassJs = require("@swc/helpers/lib/_create_class.js");
206 var _createClassJsDefault = parcelHelpers.interopDefault(_createClassJs);
207 var _definePropertyJs = require("@swc/helpers/lib/_define_property.js");
208 var _definePropertyJsDefault = parcelHelpers.interopDefault(_definePropertyJs);
209 var _getJs = require("@swc/helpers/lib/_get.js");
210 var _getJsDefault = parcelHelpers.interopDefault(_getJs);
211 var _getPrototypeOfJs = require("@swc/helpers/lib/_get_prototype_of.js");
212 var _getPrototypeOfJsDefault = parcelHelpers.interopDefault(_getPrototypeOfJs);
213 var _inheritsJs = require("@swc/helpers/lib/_inherits.js");
214 var _inheritsJsDefault = parcelHelpers.interopDefault(_inheritsJs);
215 var _slicedToArrayJs = require("@swc/helpers/lib/_sliced_to_array.js");
216 var _slicedToArrayJsDefault = parcelHelpers.interopDefault(_slicedToArrayJs);
217 var _toConsumableArrayJs = require("@swc/helpers/lib/_to_consumable_array.js");
218 var _toConsumableArrayJsDefault = parcelHelpers.interopDefault(_toConsumableArrayJs);
219 var _typeOfJs = require("@swc/helpers/lib/_type_of.js");
220 var _typeOfJsDefault = parcelHelpers.interopDefault(_typeOfJs);
221 var _createSuperJs = require("@swc/helpers/lib/_create_super.js");
222 var _createSuperJsDefault = parcelHelpers.interopDefault(_createSuperJs);
223 var _regeneratorRuntime = require("regenerator-runtime");
224 var _regeneratorRuntimeDefault = parcelHelpers.interopDefault(_regeneratorRuntime);
225 /*
226 Stimulus 3.0.1
227 Copyright © 2021 Basecamp, LLC
228 */ var EventListener = /*#__PURE__*/ function() {
229 "use strict";
230 function EventListener(eventTarget, eventName, eventOptions) {
231 (0, _classCallCheckJsDefault.default)(this, EventListener);
232 this.eventTarget = eventTarget;
233 this.eventName = eventName;
234 this.eventOptions = eventOptions;
235 this.unorderedBindings = new Set();
236 }
237 (0, _createClassJsDefault.default)(EventListener, [
238 {
239 key: "connect",
240 value: function connect() {
241 this.eventTarget.addEventListener(this.eventName, this, this.eventOptions);
242 }
243 },
244 {
245 key: "disconnect",
246 value: function disconnect() {
247 this.eventTarget.removeEventListener(this.eventName, this, this.eventOptions);
248 }
249 },
250 {
251 key: "bindingConnected",
252 value: function bindingConnected(binding) {
253 this.unorderedBindings.add(binding);
254 }
255 },
256 {
257 key: "bindingDisconnected",
258 value: function bindingDisconnected(binding) {
259 this.unorderedBindings.delete(binding);
260 }
261 },
262 {
263 key: "handleEvent",
264 value: function handleEvent(event) {
265 var extendedEvent = extendEvent(event);
266 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
267 try {
268 for(var _iterator = this.bindings[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
269 var binding = _step.value;
270 if (extendedEvent.immediatePropagationStopped) break;
271 else binding.handleEvent(extendedEvent);
272 }
273 } catch (err) {
274 _didIteratorError = true;
275 _iteratorError = err;
276 } finally{
277 try {
278 if (!_iteratorNormalCompletion && _iterator.return != null) {
279 _iterator.return();
280 }
281 } finally{
282 if (_didIteratorError) {
283 throw _iteratorError;
284 }
285 }
286 }
287 }
288 },
289 {
290 key: "bindings",
291 get: function get() {
292 return Array.from(this.unorderedBindings).sort(function(left, right) {
293 var leftIndex = left.index, rightIndex = right.index;
294 return leftIndex < rightIndex ? -1 : leftIndex > rightIndex ? 1 : 0;
295 });
296 }
297 }
298 ]);
299 return EventListener;
300 }();
301 function extendEvent(event) {
302 if ("immediatePropagationStopped" in event) return event;
303 else {
304 var stopImmediatePropagation = event.stopImmediatePropagation;
305 return Object.assign(event, {
306 immediatePropagationStopped: false,
307 stopImmediatePropagation: function() {
308 this.immediatePropagationStopped = true;
309 stopImmediatePropagation.call(this);
310 }
311 });
312 }
313 }
314 var Dispatcher = /*#__PURE__*/ function() {
315 "use strict";
316 function Dispatcher(application) {
317 (0, _classCallCheckJsDefault.default)(this, Dispatcher);
318 this.application = application;
319 this.eventListenerMaps = new Map;
320 this.started = false;
321 }
322 (0, _createClassJsDefault.default)(Dispatcher, [
323 {
324 key: "start",
325 value: function start() {
326 if (!this.started) {
327 this.started = true;
328 this.eventListeners.forEach(function(eventListener) {
329 return eventListener.connect();
330 });
331 }
332 }
333 },
334 {
335 key: "stop",
336 value: function stop() {
337 if (this.started) {
338 this.started = false;
339 this.eventListeners.forEach(function(eventListener) {
340 return eventListener.disconnect();
341 });
342 }
343 }
344 },
345 {
346 key: "eventListeners",
347 get: function get() {
348 return Array.from(this.eventListenerMaps.values()).reduce(function(listeners, map) {
349 return listeners.concat(Array.from(map.values()));
350 }, []);
351 }
352 },
353 {
354 key: "bindingConnected",
355 value: function bindingConnected(binding) {
356 this.fetchEventListenerForBinding(binding).bindingConnected(binding);
357 }
358 },
359 {
360 key: "bindingDisconnected",
361 value: function bindingDisconnected(binding) {
362 this.fetchEventListenerForBinding(binding).bindingDisconnected(binding);
363 }
364 },
365 {
366 key: "handleError",
367 value: function handleError(error1, message) {
368 var detail = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
369 this.application.handleError(error1, "Error ".concat(message), detail);
370 }
371 },
372 {
373 key: "fetchEventListenerForBinding",
374 value: function fetchEventListenerForBinding(binding) {
375 var eventTarget = binding.eventTarget, eventName = binding.eventName, eventOptions = binding.eventOptions;
376 return this.fetchEventListener(eventTarget, eventName, eventOptions);
377 }
378 },
379 {
380 key: "fetchEventListener",
381 value: function fetchEventListener(eventTarget, eventName, eventOptions) {
382 var eventListenerMap = this.fetchEventListenerMapForEventTarget(eventTarget);
383 var cacheKey = this.cacheKey(eventName, eventOptions);
384 var eventListener = eventListenerMap.get(cacheKey);
385 if (!eventListener) {
386 eventListener = this.createEventListener(eventTarget, eventName, eventOptions);
387 eventListenerMap.set(cacheKey, eventListener);
388 }
389 return eventListener;
390 }
391 },
392 {
393 key: "createEventListener",
394 value: function createEventListener(eventTarget, eventName, eventOptions) {
395 var eventListener = new EventListener(eventTarget, eventName, eventOptions);
396 if (this.started) eventListener.connect();
397 return eventListener;
398 }
399 },
400 {
401 key: "fetchEventListenerMapForEventTarget",
402 value: function fetchEventListenerMapForEventTarget(eventTarget) {
403 var eventListenerMap = this.eventListenerMaps.get(eventTarget);
404 if (!eventListenerMap) {
405 eventListenerMap = new Map;
406 this.eventListenerMaps.set(eventTarget, eventListenerMap);
407 }
408 return eventListenerMap;
409 }
410 },
411 {
412 key: "cacheKey",
413 value: function cacheKey(eventName, eventOptions) {
414 var parts = [
415 eventName
416 ];
417 Object.keys(eventOptions).sort().forEach(function(key) {
418 parts.push("".concat(eventOptions[key] ? "" : "!").concat(key));
419 });
420 return parts.join(":");
421 }
422 }
423 ]);
424 return Dispatcher;
425 }();
426 var descriptorPattern = /^((.+?)(@(window|document))?->)?(.+?)(#([^:]+?))(:(.+))?$/;
427 function parseActionDescriptorString(descriptorString) {
428 var source = descriptorString.trim();
429 var matches = source.match(descriptorPattern) || [];
430 return {
431 eventTarget: parseEventTarget(matches[4]),
432 eventName: matches[2],
433 eventOptions: matches[9] ? parseEventOptions(matches[9]) : {},
434 identifier: matches[5],
435 methodName: matches[7]
436 };
437 }
438 function parseEventTarget(eventTargetName) {
439 if (eventTargetName == "window") return window;
440 else if (eventTargetName == "document") return document;
441 }
442 function parseEventOptions(eventOptions) {
443 return eventOptions.split(":").reduce(function(options, token) {
444 return Object.assign(options, (0, _definePropertyJsDefault.default)({}, token.replace(/^!/, ""), !/^!/.test(token)));
445 }, {});
446 }
447 function stringifyEventTarget(eventTarget) {
448 if (eventTarget == window) return "window";
449 else if (eventTarget == document) return "document";
450 }
451 function camelize(value) {
452 return value.replace(/(?:[_-])([a-z0-9])/g, function(_, char) {
453 return char.toUpperCase();
454 });
455 }
456 function capitalize(value) {
457 return value.charAt(0).toUpperCase() + value.slice(1);
458 }
459 function dasherize(value) {
460 return value.replace(/([A-Z])/g, function(_, char) {
461 return "-".concat(char.toLowerCase());
462 });
463 }
464 function tokenize(value) {
465 return value.match(/[^\s]+/g) || [];
466 }
467 var Action = /*#__PURE__*/ function() {
468 "use strict";
469 function Action(element, index, descriptor) {
470 (0, _classCallCheckJsDefault.default)(this, Action);
471 this.element = element;
472 this.index = index;
473 this.eventTarget = descriptor.eventTarget || element;
474 this.eventName = descriptor.eventName || getDefaultEventNameForElement(element) || error("missing event name");
475 this.eventOptions = descriptor.eventOptions || {};
476 this.identifier = descriptor.identifier || error("missing identifier");
477 this.methodName = descriptor.methodName || error("missing method name");
478 }
479 (0, _createClassJsDefault.default)(Action, [
480 {
481 key: "toString",
482 value: function toString() {
483 var eventNameSuffix = this.eventTargetName ? "@".concat(this.eventTargetName) : "";
484 return "".concat(this.eventName).concat(eventNameSuffix, "->").concat(this.identifier, "#").concat(this.methodName);
485 }
486 },
487 {
488 key: "params",
489 get: function get() {
490 if (this.eventTarget instanceof Element) return this.getParamsFromEventTargetAttributes(this.eventTarget);
491 else return {};
492 }
493 },
494 {
495 key: "getParamsFromEventTargetAttributes",
496 value: function getParamsFromEventTargetAttributes(eventTarget) {
497 var params = {};
498 var pattern = new RegExp("^data-".concat(this.identifier, "-(.+)-param$"));
499 var attributes = Array.from(eventTarget.attributes);
500 attributes.forEach(function(param) {
501 var name = param.name, value = param.value;
502 var match = name.match(pattern);
503 var key = match && match[1];
504 if (key) Object.assign(params, (0, _definePropertyJsDefault.default)({}, camelize(key), typecast(value)));
505 });
506 return params;
507 }
508 },
509 {
510 key: "eventTargetName",
511 get: function get() {
512 return stringifyEventTarget(this.eventTarget);
513 }
514 }
515 ], [
516 {
517 key: "forToken",
518 value: function forToken(token) {
519 return new this(token.element, token.index, parseActionDescriptorString(token.content));
520 }
521 }
522 ]);
523 return Action;
524 }();
525 var defaultEventNames = {
526 "a": function(e) {
527 return "click";
528 },
529 "button": function(e) {
530 return "click";
531 },
532 "form": function(e) {
533 return "submit";
534 },
535 "details": function(e) {
536 return "toggle";
537 },
538 "input": function(e) {
539 return e.getAttribute("type") == "submit" ? "click" : "input";
540 },
541 "select": function(e) {
542 return "change";
543 },
544 "textarea": function(e) {
545 return "input";
546 }
547 };
548 function getDefaultEventNameForElement(element) {
549 var tagName = element.tagName.toLowerCase();
550 if (tagName in defaultEventNames) return defaultEventNames[tagName](element);
551 }
552 function error(message) {
553 throw new Error(message);
554 }
555 function typecast(value) {
556 try {
557 return JSON.parse(value);
558 } catch (o_O) {
559 return value;
560 }
561 }
562 var Binding = /*#__PURE__*/ function() {
563 "use strict";
564 function Binding(context, action) {
565 (0, _classCallCheckJsDefault.default)(this, Binding);
566 this.context = context;
567 this.action = action;
568 }
569 (0, _createClassJsDefault.default)(Binding, [
570 {
571 key: "index",
572 get: function get() {
573 return this.action.index;
574 }
575 },
576 {
577 key: "eventTarget",
578 get: function get() {
579 return this.action.eventTarget;
580 }
581 },
582 {
583 key: "eventOptions",
584 get: function get() {
585 return this.action.eventOptions;
586 }
587 },
588 {
589 key: "identifier",
590 get: function get() {
591 return this.context.identifier;
592 }
593 },
594 {
595 key: "handleEvent",
596 value: function handleEvent(event) {
597 if (this.willBeInvokedByEvent(event)) this.invokeWithEvent(event);
598 }
599 },
600 {
601 key: "eventName",
602 get: function get() {
603 return this.action.eventName;
604 }
605 },
606 {
607 key: "method",
608 get: function get() {
609 var method = this.controller[this.methodName];
610 if (typeof method == "function") return method;
611 throw new Error('Action "'.concat(this.action, '" references undefined method "').concat(this.methodName, '"'));
612 }
613 },
614 {
615 key: "invokeWithEvent",
616 value: function invokeWithEvent(event) {
617 var target = event.target, currentTarget = event.currentTarget;
618 try {
619 var params = this.action.params;
620 var actionEvent = Object.assign(event, {
621 params: params
622 });
623 this.method.call(this.controller, actionEvent);
624 this.context.logDebugActivity(this.methodName, {
625 event: event,
626 target: target,
627 currentTarget: currentTarget,
628 action: this.methodName
629 });
630 } catch (error2) {
631 var ref = this, identifier = ref.identifier, controller = ref.controller, element = ref.element, index = ref.index;
632 var detail = {
633 identifier: identifier,
634 controller: controller,
635 element: element,
636 index: index,
637 event: event
638 };
639 this.context.handleError(error2, 'invoking action "'.concat(this.action, '"'), detail);
640 }
641 }
642 },
643 {
644 key: "willBeInvokedByEvent",
645 value: function willBeInvokedByEvent(event) {
646 var eventTarget = event.target;
647 if (this.element === eventTarget) return true;
648 else if (eventTarget instanceof Element && this.element.contains(eventTarget)) return this.scope.containsElement(eventTarget);
649 else return this.scope.containsElement(this.action.element);
650 }
651 },
652 {
653 key: "controller",
654 get: function get() {
655 return this.context.controller;
656 }
657 },
658 {
659 key: "methodName",
660 get: function get() {
661 return this.action.methodName;
662 }
663 },
664 {
665 key: "element",
666 get: function get() {
667 return this.scope.element;
668 }
669 },
670 {
671 key: "scope",
672 get: function get() {
673 return this.context.scope;
674 }
675 }
676 ]);
677 return Binding;
678 }();
679 var ElementObserver = /*#__PURE__*/ function() {
680 "use strict";
681 function ElementObserver(element, delegate) {
682 var _this = this;
683 (0, _classCallCheckJsDefault.default)(this, ElementObserver);
684 this.mutationObserverInit = {
685 attributes: true,
686 childList: true,
687 subtree: true
688 };
689 this.element = element;
690 this.started = false;
691 this.delegate = delegate;
692 this.elements = new Set;
693 this.mutationObserver = new MutationObserver(function(mutations) {
694 return _this.processMutations(mutations);
695 });
696 }
697 (0, _createClassJsDefault.default)(ElementObserver, [
698 {
699 key: "start",
700 value: function start() {
701 if (!this.started) {
702 this.started = true;
703 this.mutationObserver.observe(this.element, this.mutationObserverInit);
704 this.refresh();
705 }
706 }
707 },
708 {
709 key: "pause",
710 value: function pause(callback) {
711 if (this.started) {
712 this.mutationObserver.disconnect();
713 this.started = false;
714 }
715 callback();
716 if (!this.started) {
717 this.mutationObserver.observe(this.element, this.mutationObserverInit);
718 this.started = true;
719 }
720 }
721 },
722 {
723 key: "stop",
724 value: function stop() {
725 if (this.started) {
726 this.mutationObserver.takeRecords();
727 this.mutationObserver.disconnect();
728 this.started = false;
729 }
730 }
731 },
732 {
733 key: "refresh",
734 value: function refresh() {
735 if (this.started) {
736 var matches = new Set(this.matchElementsInTree());
737 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
738 try {
739 for(var _iterator = Array.from(this.elements)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
740 var element = _step.value;
741 if (!matches.has(element)) this.removeElement(element);
742 }
743 } catch (err) {
744 _didIteratorError = true;
745 _iteratorError = err;
746 } finally{
747 try {
748 if (!_iteratorNormalCompletion && _iterator.return != null) {
749 _iterator.return();
750 }
751 } finally{
752 if (_didIteratorError) {
753 throw _iteratorError;
754 }
755 }
756 }
757 var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
758 try {
759 for(var _iterator1 = Array.from(matches)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
760 var element1 = _step1.value;
761 this.addElement(element1);
762 }
763 } catch (err) {
764 _didIteratorError1 = true;
765 _iteratorError1 = err;
766 } finally{
767 try {
768 if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
769 _iterator1.return();
770 }
771 } finally{
772 if (_didIteratorError1) {
773 throw _iteratorError1;
774 }
775 }
776 }
777 }
778 }
779 },
780 {
781 key: "processMutations",
782 value: function processMutations(mutations) {
783 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
784 if (this.started) try {
785 for(var _iterator = mutations[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
786 var mutation = _step.value;
787 this.processMutation(mutation);
788 }
789 } catch (err) {
790 _didIteratorError = true;
791 _iteratorError = err;
792 } finally{
793 try {
794 if (!_iteratorNormalCompletion && _iterator.return != null) {
795 _iterator.return();
796 }
797 } finally{
798 if (_didIteratorError) {
799 throw _iteratorError;
800 }
801 }
802 }
803 }
804 },
805 {
806 key: "processMutation",
807 value: function processMutation(mutation) {
808 if (mutation.type == "attributes") this.processAttributeChange(mutation.target, mutation.attributeName);
809 else if (mutation.type == "childList") {
810 this.processRemovedNodes(mutation.removedNodes);
811 this.processAddedNodes(mutation.addedNodes);
812 }
813 }
814 },
815 {
816 key: "processAttributeChange",
817 value: function processAttributeChange(node, attributeName) {
818 var element = node;
819 if (this.elements.has(element)) {
820 if (this.delegate.elementAttributeChanged && this.matchElement(element)) this.delegate.elementAttributeChanged(element, attributeName);
821 else this.removeElement(element);
822 } else if (this.matchElement(element)) this.addElement(element);
823 }
824 },
825 {
826 key: "processRemovedNodes",
827 value: function processRemovedNodes(nodes) {
828 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
829 try {
830 for(var _iterator = Array.from(nodes)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
831 var node = _step.value;
832 var element = this.elementFromNode(node);
833 if (element) this.processTree(element, this.removeElement);
834 }
835 } catch (err) {
836 _didIteratorError = true;
837 _iteratorError = err;
838 } finally{
839 try {
840 if (!_iteratorNormalCompletion && _iterator.return != null) {
841 _iterator.return();
842 }
843 } finally{
844 if (_didIteratorError) {
845 throw _iteratorError;
846 }
847 }
848 }
849 }
850 },
851 {
852 key: "processAddedNodes",
853 value: function processAddedNodes(nodes) {
854 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
855 try {
856 for(var _iterator = Array.from(nodes)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
857 var node = _step.value;
858 var element = this.elementFromNode(node);
859 if (element && this.elementIsActive(element)) this.processTree(element, this.addElement);
860 }
861 } catch (err) {
862 _didIteratorError = true;
863 _iteratorError = err;
864 } finally{
865 try {
866 if (!_iteratorNormalCompletion && _iterator.return != null) {
867 _iterator.return();
868 }
869 } finally{
870 if (_didIteratorError) {
871 throw _iteratorError;
872 }
873 }
874 }
875 }
876 },
877 {
878 key: "matchElement",
879 value: function matchElement(element) {
880 return this.delegate.matchElement(element);
881 }
882 },
883 {
884 key: "matchElementsInTree",
885 value: function matchElementsInTree() {
886 var tree = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.element;
887 return this.delegate.matchElementsInTree(tree);
888 }
889 },
890 {
891 key: "processTree",
892 value: function processTree(tree, processor) {
893 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
894 try {
895 for(var _iterator = this.matchElementsInTree(tree)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
896 var element = _step.value;
897 processor.call(this, element);
898 }
899 } catch (err) {
900 _didIteratorError = true;
901 _iteratorError = err;
902 } finally{
903 try {
904 if (!_iteratorNormalCompletion && _iterator.return != null) {
905 _iterator.return();
906 }
907 } finally{
908 if (_didIteratorError) {
909 throw _iteratorError;
910 }
911 }
912 }
913 }
914 },
915 {
916 key: "elementFromNode",
917 value: function elementFromNode(node) {
918 if (node.nodeType == Node.ELEMENT_NODE) return node;
919 }
920 },
921 {
922 key: "elementIsActive",
923 value: function elementIsActive(element) {
924 if (element.isConnected != this.element.isConnected) return false;
925 else return this.element.contains(element);
926 }
927 },
928 {
929 key: "addElement",
930 value: function addElement(element) {
931 if (!this.elements.has(element)) {
932 if (this.elementIsActive(element)) {
933 this.elements.add(element);
934 if (this.delegate.elementMatched) this.delegate.elementMatched(element);
935 }
936 }
937 }
938 },
939 {
940 key: "removeElement",
941 value: function removeElement(element) {
942 if (this.elements.has(element)) {
943 this.elements.delete(element);
944 if (this.delegate.elementUnmatched) this.delegate.elementUnmatched(element);
945 }
946 }
947 }
948 ]);
949 return ElementObserver;
950 }();
951 var AttributeObserver = /*#__PURE__*/ function() {
952 "use strict";
953 function AttributeObserver(element, attributeName, delegate) {
954 (0, _classCallCheckJsDefault.default)(this, AttributeObserver);
955 this.attributeName = attributeName;
956 this.delegate = delegate;
957 this.elementObserver = new ElementObserver(element, this);
958 }
959 (0, _createClassJsDefault.default)(AttributeObserver, [
960 {
961 key: "element",
962 get: function get() {
963 return this.elementObserver.element;
964 }
965 },
966 {
967 key: "selector",
968 get: function get() {
969 return "[".concat(this.attributeName, "]");
970 }
971 },
972 {
973 key: "start",
974 value: function start() {
975 this.elementObserver.start();
976 }
977 },
978 {
979 key: "pause",
980 value: function pause(callback) {
981 this.elementObserver.pause(callback);
982 }
983 },
984 {
985 key: "stop",
986 value: function stop() {
987 this.elementObserver.stop();
988 }
989 },
990 {
991 key: "refresh",
992 value: function refresh() {
993 this.elementObserver.refresh();
994 }
995 },
996 {
997 key: "started",
998 get: function get() {
999 return this.elementObserver.started;
1000 }
1001 },
1002 {
1003 key: "matchElement",
1004 value: function matchElement(element) {
1005 return element.hasAttribute(this.attributeName);
1006 }
1007 },
1008 {
1009 key: "matchElementsInTree",
1010 value: function matchElementsInTree(tree) {
1011 var match = this.matchElement(tree) ? [
1012 tree
1013 ] : [];
1014 var matches = Array.from(tree.querySelectorAll(this.selector));
1015 return match.concat(matches);
1016 }
1017 },
1018 {
1019 key: "elementMatched",
1020 value: function elementMatched(element) {
1021 if (this.delegate.elementMatchedAttribute) this.delegate.elementMatchedAttribute(element, this.attributeName);
1022 }
1023 },
1024 {
1025 key: "elementUnmatched",
1026 value: function elementUnmatched(element) {
1027 if (this.delegate.elementUnmatchedAttribute) this.delegate.elementUnmatchedAttribute(element, this.attributeName);
1028 }
1029 },
1030 {
1031 key: "elementAttributeChanged",
1032 value: function elementAttributeChanged(element, attributeName) {
1033 if (this.delegate.elementAttributeValueChanged && this.attributeName == attributeName) this.delegate.elementAttributeValueChanged(element, attributeName);
1034 }
1035 }
1036 ]);
1037 return AttributeObserver;
1038 }();
1039 var StringMapObserver = /*#__PURE__*/ function() {
1040 "use strict";
1041 function StringMapObserver(element, delegate) {
1042 var _this = this;
1043 (0, _classCallCheckJsDefault.default)(this, StringMapObserver);
1044 this.element = element;
1045 this.delegate = delegate;
1046 this.started = false;
1047 this.stringMap = new Map;
1048 this.mutationObserver = new MutationObserver(function(mutations) {
1049 return _this.processMutations(mutations);
1050 });
1051 }
1052 (0, _createClassJsDefault.default)(StringMapObserver, [
1053 {
1054 key: "start",
1055 value: function start() {
1056 if (!this.started) {
1057 this.started = true;
1058 this.mutationObserver.observe(this.element, {
1059 attributes: true,
1060 attributeOldValue: true
1061 });
1062 this.refresh();
1063 }
1064 }
1065 },
1066 {
1067 key: "stop",
1068 value: function stop() {
1069 if (this.started) {
1070 this.mutationObserver.takeRecords();
1071 this.mutationObserver.disconnect();
1072 this.started = false;
1073 }
1074 }
1075 },
1076 {
1077 key: "refresh",
1078 value: function refresh() {
1079 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1080 if (this.started) try {
1081 for(var _iterator = this.knownAttributeNames[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1082 var attributeName = _step.value;
1083 this.refreshAttribute(attributeName, null);
1084 }
1085 } catch (err) {
1086 _didIteratorError = true;
1087 _iteratorError = err;
1088 } finally{
1089 try {
1090 if (!_iteratorNormalCompletion && _iterator.return != null) {
1091 _iterator.return();
1092 }
1093 } finally{
1094 if (_didIteratorError) {
1095 throw _iteratorError;
1096 }
1097 }
1098 }
1099 }
1100 },
1101 {
1102 key: "processMutations",
1103 value: function processMutations(mutations) {
1104 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1105 if (this.started) try {
1106 for(var _iterator = mutations[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1107 var mutation = _step.value;
1108 this.processMutation(mutation);
1109 }
1110 } catch (err) {
1111 _didIteratorError = true;
1112 _iteratorError = err;
1113 } finally{
1114 try {
1115 if (!_iteratorNormalCompletion && _iterator.return != null) {
1116 _iterator.return();
1117 }
1118 } finally{
1119 if (_didIteratorError) {
1120 throw _iteratorError;
1121 }
1122 }
1123 }
1124 }
1125 },
1126 {
1127 key: "processMutation",
1128 value: function processMutation(mutation) {
1129 var attributeName = mutation.attributeName;
1130 if (attributeName) this.refreshAttribute(attributeName, mutation.oldValue);
1131 }
1132 },
1133 {
1134 key: "refreshAttribute",
1135 value: function refreshAttribute(attributeName, oldValue) {
1136 var key = this.delegate.getStringMapKeyForAttribute(attributeName);
1137 if (key != null) {
1138 if (!this.stringMap.has(attributeName)) this.stringMapKeyAdded(key, attributeName);
1139 var value = this.element.getAttribute(attributeName);
1140 if (this.stringMap.get(attributeName) != value) this.stringMapValueChanged(value, key, oldValue);
1141 if (value == null) {
1142 var _$oldValue = this.stringMap.get(attributeName);
1143 this.stringMap.delete(attributeName);
1144 if (_$oldValue) this.stringMapKeyRemoved(key, attributeName, _$oldValue);
1145 } else this.stringMap.set(attributeName, value);
1146 }
1147 }
1148 },
1149 {
1150 key: "stringMapKeyAdded",
1151 value: function stringMapKeyAdded(key, attributeName) {
1152 if (this.delegate.stringMapKeyAdded) this.delegate.stringMapKeyAdded(key, attributeName);
1153 }
1154 },
1155 {
1156 key: "stringMapValueChanged",
1157 value: function stringMapValueChanged(value, key, oldValue) {
1158 if (this.delegate.stringMapValueChanged) this.delegate.stringMapValueChanged(value, key, oldValue);
1159 }
1160 },
1161 {
1162 key: "stringMapKeyRemoved",
1163 value: function stringMapKeyRemoved(key, attributeName, oldValue) {
1164 if (this.delegate.stringMapKeyRemoved) this.delegate.stringMapKeyRemoved(key, attributeName, oldValue);
1165 }
1166 },
1167 {
1168 key: "knownAttributeNames",
1169 get: function get() {
1170 return Array.from(new Set(this.currentAttributeNames.concat(this.recordedAttributeNames)));
1171 }
1172 },
1173 {
1174 key: "currentAttributeNames",
1175 get: function get() {
1176 return Array.from(this.element.attributes).map(function(attribute) {
1177 return attribute.name;
1178 });
1179 }
1180 },
1181 {
1182 key: "recordedAttributeNames",
1183 get: function get() {
1184 return Array.from(this.stringMap.keys());
1185 }
1186 }
1187 ]);
1188 return StringMapObserver;
1189 }();
1190 function add(map, key, value) {
1191 fetch(map, key).add(value);
1192 }
1193 function del(map, key, value) {
1194 fetch(map, key).delete(value);
1195 prune(map, key);
1196 }
1197 function fetch(map, key) {
1198 var values = map.get(key);
1199 if (!values) {
1200 values = new Set();
1201 map.set(key, values);
1202 }
1203 return values;
1204 }
1205 function prune(map, key) {
1206 var values = map.get(key);
1207 if (values != null && values.size == 0) map.delete(key);
1208 }
1209 var Multimap = /*#__PURE__*/ function() {
1210 "use strict";
1211 function Multimap() {
1212 (0, _classCallCheckJsDefault.default)(this, Multimap);
1213 this.valuesByKey = new Map();
1214 }
1215 (0, _createClassJsDefault.default)(Multimap, [
1216 {
1217 key: "keys",
1218 get: function get() {
1219 return Array.from(this.valuesByKey.keys());
1220 }
1221 },
1222 {
1223 key: "values",
1224 get: function get() {
1225 var sets = Array.from(this.valuesByKey.values());
1226 return sets.reduce(function(values, set) {
1227 return values.concat(Array.from(set));
1228 }, []);
1229 }
1230 },
1231 {
1232 key: "size",
1233 get: function get() {
1234 var sets = Array.from(this.valuesByKey.values());
1235 return sets.reduce(function(size, set) {
1236 return size + set.size;
1237 }, 0);
1238 }
1239 },
1240 {
1241 key: "add",
1242 value: function add1(key, value) {
1243 add(this.valuesByKey, key, value);
1244 }
1245 },
1246 {
1247 key: "delete",
1248 value: function _delete(key, value) {
1249 del(this.valuesByKey, key, value);
1250 }
1251 },
1252 {
1253 key: "has",
1254 value: function has(key, value) {
1255 var values = this.valuesByKey.get(key);
1256 return values != null && values.has(value);
1257 }
1258 },
1259 {
1260 key: "hasKey",
1261 value: function hasKey(key) {
1262 return this.valuesByKey.has(key);
1263 }
1264 },
1265 {
1266 key: "hasValue",
1267 value: function hasValue(value) {
1268 var sets = Array.from(this.valuesByKey.values());
1269 return sets.some(function(set) {
1270 return set.has(value);
1271 });
1272 }
1273 },
1274 {
1275 key: "getValuesForKey",
1276 value: function getValuesForKey(key) {
1277 var values = this.valuesByKey.get(key);
1278 return values ? Array.from(values) : [];
1279 }
1280 },
1281 {
1282 key: "getKeysForValue",
1283 value: function getKeysForValue(value) {
1284 return Array.from(this.valuesByKey).filter(function(param) {
1285 var _param = (0, _slicedToArrayJsDefault.default)(param, 2), key = _param[0], values = _param[1];
1286 return values.has(value);
1287 }).map(function(param) {
1288 var _param = (0, _slicedToArrayJsDefault.default)(param, 2), key = _param[0], values = _param[1];
1289 return key;
1290 });
1291 }
1292 }
1293 ]);
1294 return Multimap;
1295 }();
1296 var IndexedMultimap = /*#__PURE__*/ function(Multimap) {
1297 "use strict";
1298 (0, _inheritsJsDefault.default)(IndexedMultimap, Multimap);
1299 var _super = (0, _createSuperJsDefault.default)(IndexedMultimap);
1300 function IndexedMultimap() {
1301 (0, _classCallCheckJsDefault.default)(this, IndexedMultimap);
1302 var _this;
1303 _this = _super.call(this);
1304 _this.keysByValue = new Map;
1305 return _this;
1306 }
1307 (0, _createClassJsDefault.default)(IndexedMultimap, [
1308 {
1309 key: "values",
1310 get: function get() {
1311 return Array.from(this.keysByValue.keys());
1312 }
1313 },
1314 {
1315 key: "add",
1316 value: function add1(key, value) {
1317 (0, _getJsDefault.default)((0, _getPrototypeOfJsDefault.default)(IndexedMultimap.prototype), "add", this).call(this, key, value);
1318 add(this.keysByValue, value, key);
1319 }
1320 },
1321 {
1322 key: "delete",
1323 value: function _delete(key, value) {
1324 (0, _getJsDefault.default)((0, _getPrototypeOfJsDefault.default)(IndexedMultimap.prototype), "delete", this).call(this, key, value);
1325 del(this.keysByValue, value, key);
1326 }
1327 },
1328 {
1329 key: "hasValue",
1330 value: function hasValue(value) {
1331 return this.keysByValue.has(value);
1332 }
1333 },
1334 {
1335 key: "getKeysForValue",
1336 value: function getKeysForValue(value) {
1337 var set = this.keysByValue.get(value);
1338 return set ? Array.from(set) : [];
1339 }
1340 }
1341 ]);
1342 return IndexedMultimap;
1343 }(Multimap);
1344 var TokenListObserver = /*#__PURE__*/ function() {
1345 "use strict";
1346 function TokenListObserver(element, attributeName, delegate) {
1347 (0, _classCallCheckJsDefault.default)(this, TokenListObserver);
1348 this.attributeObserver = new AttributeObserver(element, attributeName, this);
1349 this.delegate = delegate;
1350 this.tokensByElement = new Multimap;
1351 }
1352 (0, _createClassJsDefault.default)(TokenListObserver, [
1353 {
1354 key: "started",
1355 get: function get() {
1356 return this.attributeObserver.started;
1357 }
1358 },
1359 {
1360 key: "start",
1361 value: function start() {
1362 this.attributeObserver.start();
1363 }
1364 },
1365 {
1366 key: "pause",
1367 value: function pause(callback) {
1368 this.attributeObserver.pause(callback);
1369 }
1370 },
1371 {
1372 key: "stop",
1373 value: function stop() {
1374 this.attributeObserver.stop();
1375 }
1376 },
1377 {
1378 key: "refresh",
1379 value: function refresh() {
1380 this.attributeObserver.refresh();
1381 }
1382 },
1383 {
1384 key: "element",
1385 get: function get() {
1386 return this.attributeObserver.element;
1387 }
1388 },
1389 {
1390 key: "attributeName",
1391 get: function get() {
1392 return this.attributeObserver.attributeName;
1393 }
1394 },
1395 {
1396 key: "elementMatchedAttribute",
1397 value: function elementMatchedAttribute(element) {
1398 this.tokensMatched(this.readTokensForElement(element));
1399 }
1400 },
1401 {
1402 key: "elementAttributeValueChanged",
1403 value: function elementAttributeValueChanged(element) {
1404 var ref = (0, _slicedToArrayJsDefault.default)(this.refreshTokensForElement(element), 2), unmatchedTokens = ref[0], matchedTokens = ref[1];
1405 this.tokensUnmatched(unmatchedTokens);
1406 this.tokensMatched(matchedTokens);
1407 }
1408 },
1409 {
1410 key: "elementUnmatchedAttribute",
1411 value: function elementUnmatchedAttribute(element) {
1412 this.tokensUnmatched(this.tokensByElement.getValuesForKey(element));
1413 }
1414 },
1415 {
1416 key: "tokensMatched",
1417 value: function tokensMatched(tokens) {
1418 var _this = this;
1419 tokens.forEach(function(token) {
1420 return _this.tokenMatched(token);
1421 });
1422 }
1423 },
1424 {
1425 key: "tokensUnmatched",
1426 value: function tokensUnmatched(tokens) {
1427 var _this = this;
1428 tokens.forEach(function(token) {
1429 return _this.tokenUnmatched(token);
1430 });
1431 }
1432 },
1433 {
1434 key: "tokenMatched",
1435 value: function tokenMatched(token) {
1436 this.delegate.tokenMatched(token);
1437 this.tokensByElement.add(token.element, token);
1438 }
1439 },
1440 {
1441 key: "tokenUnmatched",
1442 value: function tokenUnmatched(token) {
1443 this.delegate.tokenUnmatched(token);
1444 this.tokensByElement.delete(token.element, token);
1445 }
1446 },
1447 {
1448 key: "refreshTokensForElement",
1449 value: function refreshTokensForElement(element) {
1450 var previousTokens = this.tokensByElement.getValuesForKey(element);
1451 var currentTokens = this.readTokensForElement(element);
1452 var firstDifferingIndex = zip(previousTokens, currentTokens).findIndex(function(param) {
1453 var _param = (0, _slicedToArrayJsDefault.default)(param, 2), previousToken = _param[0], currentToken = _param[1];
1454 return !tokensAreEqual(previousToken, currentToken);
1455 });
1456 if (firstDifferingIndex == -1) return [
1457 [],
1458 []
1459 ];
1460 else return [
1461 previousTokens.slice(firstDifferingIndex),
1462 currentTokens.slice(firstDifferingIndex)
1463 ];
1464 }
1465 },
1466 {
1467 key: "readTokensForElement",
1468 value: function readTokensForElement(element) {
1469 var attributeName = this.attributeName;
1470 var tokenString = element.getAttribute(attributeName) || "";
1471 return parseTokenString(tokenString, element, attributeName);
1472 }
1473 }
1474 ]);
1475 return TokenListObserver;
1476 }();
1477 function parseTokenString(tokenString, element, attributeName) {
1478 return tokenString.trim().split(/\s+/).filter(function(content) {
1479 return content.length;
1480 }).map(function(content, index) {
1481 return {
1482 element: element,
1483 attributeName: attributeName,
1484 content: content,
1485 index: index
1486 };
1487 });
1488 }
1489 function zip(left, right) {
1490 var length = Math.max(left.length, right.length);
1491 return Array.from({
1492 length: length
1493 }, function(_, index) {
1494 return [
1495 left[index],
1496 right[index]
1497 ];
1498 });
1499 }
1500 function tokensAreEqual(left, right) {
1501 return left && right && left.index == right.index && left.content == right.content;
1502 }
1503 var ValueListObserver = /*#__PURE__*/ function() {
1504 "use strict";
1505 function ValueListObserver(element, attributeName, delegate) {
1506 (0, _classCallCheckJsDefault.default)(this, ValueListObserver);
1507 this.tokenListObserver = new TokenListObserver(element, attributeName, this);
1508 this.delegate = delegate;
1509 this.parseResultsByToken = new WeakMap;
1510 this.valuesByTokenByElement = new WeakMap;
1511 }
1512 (0, _createClassJsDefault.default)(ValueListObserver, [
1513 {
1514 key: "started",
1515 get: function get() {
1516 return this.tokenListObserver.started;
1517 }
1518 },
1519 {
1520 key: "start",
1521 value: function start() {
1522 this.tokenListObserver.start();
1523 }
1524 },
1525 {
1526 key: "stop",
1527 value: function stop() {
1528 this.tokenListObserver.stop();
1529 }
1530 },
1531 {
1532 key: "refresh",
1533 value: function refresh() {
1534 this.tokenListObserver.refresh();
1535 }
1536 },
1537 {
1538 key: "element",
1539 get: function get() {
1540 return this.tokenListObserver.element;
1541 }
1542 },
1543 {
1544 key: "attributeName",
1545 get: function get() {
1546 return this.tokenListObserver.attributeName;
1547 }
1548 },
1549 {
1550 key: "tokenMatched",
1551 value: function tokenMatched(token) {
1552 var element = token.element;
1553 var value = this.fetchParseResultForToken(token).value;
1554 if (value) {
1555 this.fetchValuesByTokenForElement(element).set(token, value);
1556 this.delegate.elementMatchedValue(element, value);
1557 }
1558 }
1559 },
1560 {
1561 key: "tokenUnmatched",
1562 value: function tokenUnmatched(token) {
1563 var element = token.element;
1564 var value = this.fetchParseResultForToken(token).value;
1565 if (value) {
1566 this.fetchValuesByTokenForElement(element).delete(token);
1567 this.delegate.elementUnmatchedValue(element, value);
1568 }
1569 }
1570 },
1571 {
1572 key: "fetchParseResultForToken",
1573 value: function fetchParseResultForToken(token) {
1574 var parseResult = this.parseResultsByToken.get(token);
1575 if (!parseResult) {
1576 parseResult = this.parseToken(token);
1577 this.parseResultsByToken.set(token, parseResult);
1578 }
1579 return parseResult;
1580 }
1581 },
1582 {
1583 key: "fetchValuesByTokenForElement",
1584 value: function fetchValuesByTokenForElement(element) {
1585 var valuesByToken = this.valuesByTokenByElement.get(element);
1586 if (!valuesByToken) {
1587 valuesByToken = new Map;
1588 this.valuesByTokenByElement.set(element, valuesByToken);
1589 }
1590 return valuesByToken;
1591 }
1592 },
1593 {
1594 key: "parseToken",
1595 value: function parseToken(token) {
1596 try {
1597 var value = this.delegate.parseValueForToken(token);
1598 return {
1599 value: value
1600 };
1601 } catch (error3) {
1602 return {
1603 error: error3
1604 };
1605 }
1606 }
1607 }
1608 ]);
1609 return ValueListObserver;
1610 }();
1611 var BindingObserver = /*#__PURE__*/ function() {
1612 "use strict";
1613 function BindingObserver(context, delegate) {
1614 (0, _classCallCheckJsDefault.default)(this, BindingObserver);
1615 this.context = context;
1616 this.delegate = delegate;
1617 this.bindingsByAction = new Map;
1618 }
1619 (0, _createClassJsDefault.default)(BindingObserver, [
1620 {
1621 key: "start",
1622 value: function start() {
1623 if (!this.valueListObserver) {
1624 this.valueListObserver = new ValueListObserver(this.element, this.actionAttribute, this);
1625 this.valueListObserver.start();
1626 }
1627 }
1628 },
1629 {
1630 key: "stop",
1631 value: function stop() {
1632 if (this.valueListObserver) {
1633 this.valueListObserver.stop();
1634 delete this.valueListObserver;
1635 this.disconnectAllActions();
1636 }
1637 }
1638 },
1639 {
1640 key: "element",
1641 get: function get() {
1642 return this.context.element;
1643 }
1644 },
1645 {
1646 key: "identifier",
1647 get: function get() {
1648 return this.context.identifier;
1649 }
1650 },
1651 {
1652 key: "actionAttribute",
1653 get: function get() {
1654 return this.schema.actionAttribute;
1655 }
1656 },
1657 {
1658 key: "schema",
1659 get: function get() {
1660 return this.context.schema;
1661 }
1662 },
1663 {
1664 key: "bindings",
1665 get: function get() {
1666 return Array.from(this.bindingsByAction.values());
1667 }
1668 },
1669 {
1670 key: "connectAction",
1671 value: function connectAction(action) {
1672 var binding = new Binding(this.context, action);
1673 this.bindingsByAction.set(action, binding);
1674 this.delegate.bindingConnected(binding);
1675 }
1676 },
1677 {
1678 key: "disconnectAction",
1679 value: function disconnectAction(action) {
1680 var binding = this.bindingsByAction.get(action);
1681 if (binding) {
1682 this.bindingsByAction.delete(action);
1683 this.delegate.bindingDisconnected(binding);
1684 }
1685 }
1686 },
1687 {
1688 key: "disconnectAllActions",
1689 value: function disconnectAllActions() {
1690 var _this = this;
1691 this.bindings.forEach(function(binding) {
1692 return _this.delegate.bindingDisconnected(binding);
1693 });
1694 this.bindingsByAction.clear();
1695 }
1696 },
1697 {
1698 key: "parseValueForToken",
1699 value: function parseValueForToken(token) {
1700 var action = Action.forToken(token);
1701 if (action.identifier == this.identifier) return action;
1702 }
1703 },
1704 {
1705 key: "elementMatchedValue",
1706 value: function elementMatchedValue(element, action) {
1707 this.connectAction(action);
1708 }
1709 },
1710 {
1711 key: "elementUnmatchedValue",
1712 value: function elementUnmatchedValue(element, action) {
1713 this.disconnectAction(action);
1714 }
1715 }
1716 ]);
1717 return BindingObserver;
1718 }();
1719 var ValueObserver = /*#__PURE__*/ function() {
1720 "use strict";
1721 function ValueObserver(context, receiver) {
1722 (0, _classCallCheckJsDefault.default)(this, ValueObserver);
1723 this.context = context;
1724 this.receiver = receiver;
1725 this.stringMapObserver = new StringMapObserver(this.element, this);
1726 this.valueDescriptorMap = this.controller.valueDescriptorMap;
1727 this.invokeChangedCallbacksForDefaultValues();
1728 }
1729 (0, _createClassJsDefault.default)(ValueObserver, [
1730 {
1731 key: "start",
1732 value: function start() {
1733 this.stringMapObserver.start();
1734 }
1735 },
1736 {
1737 key: "stop",
1738 value: function stop() {
1739 this.stringMapObserver.stop();
1740 }
1741 },
1742 {
1743 key: "element",
1744 get: function get() {
1745 return this.context.element;
1746 }
1747 },
1748 {
1749 key: "controller",
1750 get: function get() {
1751 return this.context.controller;
1752 }
1753 },
1754 {
1755 key: "getStringMapKeyForAttribute",
1756 value: function getStringMapKeyForAttribute(attributeName) {
1757 if (attributeName in this.valueDescriptorMap) return this.valueDescriptorMap[attributeName].name;
1758 }
1759 },
1760 {
1761 key: "stringMapKeyAdded",
1762 value: function stringMapKeyAdded(key, attributeName) {
1763 var descriptor = this.valueDescriptorMap[attributeName];
1764 if (!this.hasValue(key)) this.invokeChangedCallback(key, descriptor.writer(this.receiver[key]), descriptor.writer(descriptor.defaultValue));
1765 }
1766 },
1767 {
1768 key: "stringMapValueChanged",
1769 value: function stringMapValueChanged(value, name, oldValue) {
1770 var descriptor = this.valueDescriptorNameMap[name];
1771 if (value === null) return;
1772 if (oldValue === null) oldValue = descriptor.writer(descriptor.defaultValue);
1773 this.invokeChangedCallback(name, value, oldValue);
1774 }
1775 },
1776 {
1777 key: "stringMapKeyRemoved",
1778 value: function stringMapKeyRemoved(key, attributeName, oldValue) {
1779 var descriptor = this.valueDescriptorNameMap[key];
1780 if (this.hasValue(key)) this.invokeChangedCallback(key, descriptor.writer(this.receiver[key]), oldValue);
1781 else this.invokeChangedCallback(key, descriptor.writer(descriptor.defaultValue), oldValue);
1782 }
1783 },
1784 {
1785 key: "invokeChangedCallbacksForDefaultValues",
1786 value: function invokeChangedCallbacksForDefaultValues() {
1787 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1788 try {
1789 for(var _iterator = this.valueDescriptors[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1790 var _value = _step.value, key = _value.key, name = _value.name, defaultValue = _value.defaultValue, writer = _value.writer;
1791 if (defaultValue != undefined && !this.controller.data.has(key)) this.invokeChangedCallback(name, writer(defaultValue), undefined);
1792 }
1793 } catch (err) {
1794 _didIteratorError = true;
1795 _iteratorError = err;
1796 } finally{
1797 try {
1798 if (!_iteratorNormalCompletion && _iterator.return != null) {
1799 _iterator.return();
1800 }
1801 } finally{
1802 if (_didIteratorError) {
1803 throw _iteratorError;
1804 }
1805 }
1806 }
1807 }
1808 },
1809 {
1810 key: "invokeChangedCallback",
1811 value: function invokeChangedCallback(name, rawValue, rawOldValue) {
1812 var changedMethodName = "".concat(name, "Changed");
1813 var changedMethod = this.receiver[changedMethodName];
1814 if (typeof changedMethod == "function") {
1815 var descriptor = this.valueDescriptorNameMap[name];
1816 var value = descriptor.reader(rawValue);
1817 var oldValue = rawOldValue;
1818 if (rawOldValue) oldValue = descriptor.reader(rawOldValue);
1819 changedMethod.call(this.receiver, value, oldValue);
1820 }
1821 }
1822 },
1823 {
1824 key: "valueDescriptors",
1825 get: function get() {
1826 var valueDescriptorMap = this.valueDescriptorMap;
1827 return Object.keys(valueDescriptorMap).map(function(key) {
1828 return valueDescriptorMap[key];
1829 });
1830 }
1831 },
1832 {
1833 key: "valueDescriptorNameMap",
1834 get: function get() {
1835 var _this = this;
1836 var descriptors = {};
1837 Object.keys(this.valueDescriptorMap).forEach(function(key) {
1838 var descriptor = _this.valueDescriptorMap[key];
1839 descriptors[descriptor.name] = descriptor;
1840 });
1841 return descriptors;
1842 }
1843 },
1844 {
1845 key: "hasValue",
1846 value: function hasValue(attributeName) {
1847 var descriptor = this.valueDescriptorNameMap[attributeName];
1848 var hasMethodName = "has".concat(capitalize(descriptor.name));
1849 return this.receiver[hasMethodName];
1850 }
1851 }
1852 ]);
1853 return ValueObserver;
1854 }();
1855 var TargetObserver = /*#__PURE__*/ function() {
1856 "use strict";
1857 function TargetObserver(context, delegate) {
1858 (0, _classCallCheckJsDefault.default)(this, TargetObserver);
1859 this.context = context;
1860 this.delegate = delegate;
1861 this.targetsByName = new Multimap;
1862 }
1863 (0, _createClassJsDefault.default)(TargetObserver, [
1864 {
1865 key: "start",
1866 value: function start() {
1867 if (!this.tokenListObserver) {
1868 this.tokenListObserver = new TokenListObserver(this.element, this.attributeName, this);
1869 this.tokenListObserver.start();
1870 }
1871 }
1872 },
1873 {
1874 key: "stop",
1875 value: function stop() {
1876 if (this.tokenListObserver) {
1877 this.disconnectAllTargets();
1878 this.tokenListObserver.stop();
1879 delete this.tokenListObserver;
1880 }
1881 }
1882 },
1883 {
1884 key: "tokenMatched",
1885 value: function tokenMatched(param) {
1886 var element = param.element, name = param.content;
1887 if (this.scope.containsElement(element)) this.connectTarget(element, name);
1888 }
1889 },
1890 {
1891 key: "tokenUnmatched",
1892 value: function tokenUnmatched(param) {
1893 var element = param.element, name = param.content;
1894 this.disconnectTarget(element, name);
1895 }
1896 },
1897 {
1898 key: "connectTarget",
1899 value: function connectTarget(element, name) {
1900 var _a;
1901 if (!this.targetsByName.has(name, element)) {
1902 var _this = this;
1903 this.targetsByName.add(name, element);
1904 (_a = this.tokenListObserver) === null || _a === void 0 || _a.pause(function() {
1905 return _this.delegate.targetConnected(element, name);
1906 });
1907 }
1908 }
1909 },
1910 {
1911 key: "disconnectTarget",
1912 value: function disconnectTarget(element, name) {
1913 var _a;
1914 if (this.targetsByName.has(name, element)) {
1915 var _this = this;
1916 this.targetsByName.delete(name, element);
1917 (_a = this.tokenListObserver) === null || _a === void 0 || _a.pause(function() {
1918 return _this.delegate.targetDisconnected(element, name);
1919 });
1920 }
1921 }
1922 },
1923 {
1924 key: "disconnectAllTargets",
1925 value: function disconnectAllTargets() {
1926 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined, _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = undefined;
1927 try {
1928 for(var _iterator = this.targetsByName.keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion2 = (_step = _iterator.next()).done); _iteratorNormalCompletion2 = true){
1929 var name = _step.value;
1930 try {
1931 for(var _iterator2 = this.targetsByName.getValuesForKey(name)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion = true){
1932 var element = _step2.value;
1933 this.disconnectTarget(element, name);
1934 }
1935 } catch (err) {
1936 _didIteratorError = true;
1937 _iteratorError = err;
1938 } finally{
1939 try {
1940 if (!_iteratorNormalCompletion && _iterator2.return != null) {
1941 _iterator2.return();
1942 }
1943 } finally{
1944 if (_didIteratorError) {
1945 throw _iteratorError;
1946 }
1947 }
1948 }
1949 }
1950 } catch (err) {
1951 _didIteratorError2 = true;
1952 _iteratorError2 = err;
1953 } finally{
1954 try {
1955 if (!_iteratorNormalCompletion2 && _iterator.return != null) {
1956 _iterator.return();
1957 }
1958 } finally{
1959 if (_didIteratorError2) {
1960 throw _iteratorError2;
1961 }
1962 }
1963 }
1964 }
1965 },
1966 {
1967 key: "attributeName",
1968 get: function get() {
1969 return "data-".concat(this.context.identifier, "-target");
1970 }
1971 },
1972 {
1973 key: "element",
1974 get: function get() {
1975 return this.context.element;
1976 }
1977 },
1978 {
1979 key: "scope",
1980 get: function get() {
1981 return this.context.scope;
1982 }
1983 }
1984 ]);
1985 return TargetObserver;
1986 }();
1987 var Context = /*#__PURE__*/ function() {
1988 "use strict";
1989 function Context(module, scope) {
1990 var _this = this;
1991 (0, _classCallCheckJsDefault.default)(this, Context);
1992 this.logDebugActivity = function(functionName) {
1993 var detail = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
1994 var identifier = _this.identifier, controller = _this.controller, element = _this.element;
1995 detail = Object.assign({
1996 identifier: identifier,
1997 controller: controller,
1998 element: element
1999 }, detail);
2000 _this.application.logDebugActivity(_this.identifier, functionName, detail);
2001 };
2002 this.module = module;
2003 this.scope = scope;
2004 this.controller = new module.controllerConstructor(this);
2005 this.bindingObserver = new BindingObserver(this, this.dispatcher);
2006 this.valueObserver = new ValueObserver(this, this.controller);
2007 this.targetObserver = new TargetObserver(this, this);
2008 try {
2009 this.controller.initialize();
2010 this.logDebugActivity("initialize");
2011 } catch (error4) {
2012 this.handleError(error4, "initializing controller");
2013 }
2014 }
2015 (0, _createClassJsDefault.default)(Context, [
2016 {
2017 key: "connect",
2018 value: function connect() {
2019 this.bindingObserver.start();
2020 this.valueObserver.start();
2021 this.targetObserver.start();
2022 try {
2023 this.controller.connect();
2024 this.logDebugActivity("connect");
2025 } catch (error5) {
2026 this.handleError(error5, "connecting controller");
2027 }
2028 }
2029 },
2030 {
2031 key: "disconnect",
2032 value: function disconnect() {
2033 try {
2034 this.controller.disconnect();
2035 this.logDebugActivity("disconnect");
2036 } catch (error6) {
2037 this.handleError(error6, "disconnecting controller");
2038 }
2039 this.targetObserver.stop();
2040 this.valueObserver.stop();
2041 this.bindingObserver.stop();
2042 }
2043 },
2044 {
2045 key: "application",
2046 get: function get() {
2047 return this.module.application;
2048 }
2049 },
2050 {
2051 key: "identifier",
2052 get: function get() {
2053 return this.module.identifier;
2054 }
2055 },
2056 {
2057 key: "schema",
2058 get: function get() {
2059 return this.application.schema;
2060 }
2061 },
2062 {
2063 key: "dispatcher",
2064 get: function get() {
2065 return this.application.dispatcher;
2066 }
2067 },
2068 {
2069 key: "element",
2070 get: function get() {
2071 return this.scope.element;
2072 }
2073 },
2074 {
2075 key: "parentElement",
2076 get: function get() {
2077 return this.element.parentElement;
2078 }
2079 },
2080 {
2081 key: "handleError",
2082 value: function handleError(error7, message) {
2083 var detail = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
2084 var ref = this, identifier = ref.identifier, controller = ref.controller, element = ref.element;
2085 detail = Object.assign({
2086 identifier: identifier,
2087 controller: controller,
2088 element: element
2089 }, detail);
2090 this.application.handleError(error7, "Error ".concat(message), detail);
2091 }
2092 },
2093 {
2094 key: "targetConnected",
2095 value: function targetConnected(element, name) {
2096 this.invokeControllerMethod("".concat(name, "TargetConnected"), element);
2097 }
2098 },
2099 {
2100 key: "targetDisconnected",
2101 value: function targetDisconnected(element, name) {
2102 this.invokeControllerMethod("".concat(name, "TargetDisconnected"), element);
2103 }
2104 },
2105 {
2106 key: "invokeControllerMethod",
2107 value: function invokeControllerMethod(methodName) {
2108 for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
2109 args[_key - 1] = arguments[_key];
2110 }
2111 var _controller;
2112 var controller = this.controller;
2113 if (typeof controller[methodName] == "function") (_controller = controller)[methodName].apply(_controller, (0, _toConsumableArrayJsDefault.default)(args));
2114 }
2115 }
2116 ]);
2117 return Context;
2118 }();
2119 function readInheritableStaticArrayValues(constructor1, propertyName) {
2120 var ancestors = getAncestorsForConstructor(constructor1);
2121 return Array.from(ancestors.reduce(function(values, constructor) {
2122 getOwnStaticArrayValues(constructor, propertyName).forEach(function(name) {
2123 return values.add(name);
2124 });
2125 return values;
2126 }, new Set));
2127 }
2128 function readInheritableStaticObjectPairs(constructor2, propertyName) {
2129 var ancestors = getAncestorsForConstructor(constructor2);
2130 return ancestors.reduce(function(pairs, constructor) {
2131 var _pairs;
2132 (_pairs = pairs).push.apply(_pairs, (0, _toConsumableArrayJsDefault.default)(getOwnStaticObjectPairs(constructor, propertyName)));
2133 return pairs;
2134 }, []);
2135 }
2136 function getAncestorsForConstructor(constructor) {
2137 var ancestors = [];
2138 while(constructor){
2139 ancestors.push(constructor);
2140 constructor = Object.getPrototypeOf(constructor);
2141 }
2142 return ancestors.reverse();
2143 }
2144 function getOwnStaticArrayValues(constructor, propertyName) {
2145 var definition = constructor[propertyName];
2146 return Array.isArray(definition) ? definition : [];
2147 }
2148 function getOwnStaticObjectPairs(constructor, propertyName) {
2149 var definition = constructor[propertyName];
2150 return definition ? Object.keys(definition).map(function(key) {
2151 return [
2152 key,
2153 definition[key]
2154 ];
2155 }) : [];
2156 }
2157 function bless(constructor) {
2158 return shadow(constructor, getBlessedProperties(constructor));
2159 }
2160 function shadow(constructor, properties) {
2161 var shadowConstructor = extend(constructor);
2162 var shadowProperties = getShadowProperties(constructor.prototype, properties);
2163 Object.defineProperties(shadowConstructor.prototype, shadowProperties);
2164 return shadowConstructor;
2165 }
2166 function getBlessedProperties(constructor) {
2167 var blessings = readInheritableStaticArrayValues(constructor, "blessings");
2168 return blessings.reduce(function(blessedProperties, blessing) {
2169 var properties = blessing(constructor);
2170 for(var key in properties){
2171 var descriptor = blessedProperties[key] || {};
2172 blessedProperties[key] = Object.assign(descriptor, properties[key]);
2173 }
2174 return blessedProperties;
2175 }, {});
2176 }
2177 function getShadowProperties(prototype, properties) {
2178 return getOwnKeys(properties).reduce(function(shadowProperties, key) {
2179 var descriptor = getShadowedDescriptor(prototype, properties, key);
2180 if (descriptor) Object.assign(shadowProperties, (0, _definePropertyJsDefault.default)({}, key, descriptor));
2181 return shadowProperties;
2182 }, {});
2183 }
2184 function getShadowedDescriptor(prototype, properties, key) {
2185 var shadowingDescriptor = Object.getOwnPropertyDescriptor(prototype, key);
2186 var shadowedByValue = shadowingDescriptor && "value" in shadowingDescriptor;
2187 if (!shadowedByValue) {
2188 var descriptor = Object.getOwnPropertyDescriptor(properties, key).value;
2189 if (shadowingDescriptor) {
2190 descriptor.get = shadowingDescriptor.get || descriptor.get;
2191 descriptor.set = shadowingDescriptor.set || descriptor.set;
2192 }
2193 return descriptor;
2194 }
2195 }
2196 var getOwnKeys = function() {
2197 if (typeof Object.getOwnPropertySymbols == "function") return function(object) {
2198 return (0, _toConsumableArrayJsDefault.default)(Object.getOwnPropertyNames(object)).concat((0, _toConsumableArrayJsDefault.default)(Object.getOwnPropertySymbols(object)));
2199 };
2200 else return Object.getOwnPropertyNames;
2201 }();
2202 var extend = function _target() {
2203 var extendWithReflect = function extendWithReflect(constructor) {
2204 function extended() {
2205 return Reflect.construct(constructor, arguments, this instanceof extended ? this.constructor : void 0);
2206 }
2207 extended.prototype = Object.create(constructor.prototype, {
2208 constructor: {
2209 value: extended
2210 }
2211 });
2212 Reflect.setPrototypeOf(extended, constructor);
2213 return extended;
2214 };
2215 var testReflectExtension = function testReflectExtension() {
2216 var a = function a() {
2217 this.a.call(this);
2218 };
2219 var b = extendWithReflect(a);
2220 b.prototype.a = function() {};
2221 return new b;
2222 };
2223 try {
2224 testReflectExtension();
2225 return extendWithReflect;
2226 } catch (error) {
2227 return function(constructor3) {
2228 return /*#__PURE__*/ function(constructor) {
2229 "use strict";
2230 (0, _inheritsJsDefault.default)(extended, constructor);
2231 var _super = (0, _createSuperJsDefault.default)(extended);
2232 function extended() {
2233 (0, _classCallCheckJsDefault.default)(this, extended);
2234 return _super.apply(this, arguments);
2235 }
2236 return extended;
2237 }(constructor3);
2238 };
2239 }
2240 }();
2241 function blessDefinition(definition) {
2242 return {
2243 identifier: definition.identifier,
2244 controllerConstructor: bless(definition.controllerConstructor)
2245 };
2246 }
2247 var Module = /*#__PURE__*/ function() {
2248 "use strict";
2249 function Module(application, definition) {
2250 (0, _classCallCheckJsDefault.default)(this, Module);
2251 this.application = application;
2252 this.definition = blessDefinition(definition);
2253 this.contextsByScope = new WeakMap;
2254 this.connectedContexts = new Set;
2255 }
2256 (0, _createClassJsDefault.default)(Module, [
2257 {
2258 key: "identifier",
2259 get: function get() {
2260 return this.definition.identifier;
2261 }
2262 },
2263 {
2264 key: "controllerConstructor",
2265 get: function get() {
2266 return this.definition.controllerConstructor;
2267 }
2268 },
2269 {
2270 key: "contexts",
2271 get: function get() {
2272 return Array.from(this.connectedContexts);
2273 }
2274 },
2275 {
2276 key: "connectContextForScope",
2277 value: function connectContextForScope(scope) {
2278 var context = this.fetchContextForScope(scope);
2279 this.connectedContexts.add(context);
2280 context.connect();
2281 }
2282 },
2283 {
2284 key: "disconnectContextForScope",
2285 value: function disconnectContextForScope(scope) {
2286 var context = this.contextsByScope.get(scope);
2287 if (context) {
2288 this.connectedContexts.delete(context);
2289 context.disconnect();
2290 }
2291 }
2292 },
2293 {
2294 key: "fetchContextForScope",
2295 value: function fetchContextForScope(scope) {
2296 var context = this.contextsByScope.get(scope);
2297 if (!context) {
2298 context = new Context(this, scope);
2299 this.contextsByScope.set(scope, context);
2300 }
2301 return context;
2302 }
2303 }
2304 ]);
2305 return Module;
2306 }();
2307 var ClassMap = /*#__PURE__*/ function() {
2308 "use strict";
2309 function ClassMap(scope) {
2310 (0, _classCallCheckJsDefault.default)(this, ClassMap);
2311 this.scope = scope;
2312 }
2313 (0, _createClassJsDefault.default)(ClassMap, [
2314 {
2315 key: "has",
2316 value: function has(name) {
2317 return this.data.has(this.getDataKey(name));
2318 }
2319 },
2320 {
2321 key: "get",
2322 value: function get(name) {
2323 return this.getAll(name)[0];
2324 }
2325 },
2326 {
2327 key: "getAll",
2328 value: function getAll(name) {
2329 var tokenString = this.data.get(this.getDataKey(name)) || "";
2330 return tokenize(tokenString);
2331 }
2332 },
2333 {
2334 key: "getAttributeName",
2335 value: function getAttributeName(name) {
2336 return this.data.getAttributeNameForKey(this.getDataKey(name));
2337 }
2338 },
2339 {
2340 key: "getDataKey",
2341 value: function getDataKey(name) {
2342 return "".concat(name, "-class");
2343 }
2344 },
2345 {
2346 key: "data",
2347 get: function get() {
2348 return this.scope.data;
2349 }
2350 }
2351 ]);
2352 return ClassMap;
2353 }();
2354 var DataMap = /*#__PURE__*/ function() {
2355 "use strict";
2356 function DataMap(scope) {
2357 (0, _classCallCheckJsDefault.default)(this, DataMap);
2358 this.scope = scope;
2359 }
2360 (0, _createClassJsDefault.default)(DataMap, [
2361 {
2362 key: "element",
2363 get: function get() {
2364 return this.scope.element;
2365 }
2366 },
2367 {
2368 key: "identifier",
2369 get: function get() {
2370 return this.scope.identifier;
2371 }
2372 },
2373 {
2374 key: "get",
2375 value: function get(key) {
2376 var name = this.getAttributeNameForKey(key);
2377 return this.element.getAttribute(name);
2378 }
2379 },
2380 {
2381 key: "set",
2382 value: function set(key, value) {
2383 var name = this.getAttributeNameForKey(key);
2384 this.element.setAttribute(name, value);
2385 return this.get(key);
2386 }
2387 },
2388 {
2389 key: "has",
2390 value: function has(key) {
2391 var name = this.getAttributeNameForKey(key);
2392 return this.element.hasAttribute(name);
2393 }
2394 },
2395 {
2396 key: "delete",
2397 value: function _delete(key) {
2398 if (this.has(key)) {
2399 var name = this.getAttributeNameForKey(key);
2400 this.element.removeAttribute(name);
2401 return true;
2402 } else return false;
2403 }
2404 },
2405 {
2406 key: "getAttributeNameForKey",
2407 value: function getAttributeNameForKey(key) {
2408 return "data-".concat(this.identifier, "-").concat(dasherize(key));
2409 }
2410 }
2411 ]);
2412 return DataMap;
2413 }();
2414 var Guide = /*#__PURE__*/ function() {
2415 "use strict";
2416 function Guide(logger) {
2417 (0, _classCallCheckJsDefault.default)(this, Guide);
2418 this.warnedKeysByObject = new WeakMap;
2419 this.logger = logger;
2420 }
2421 (0, _createClassJsDefault.default)(Guide, [
2422 {
2423 key: "warn",
2424 value: function warn(object, key, message) {
2425 var warnedKeys = this.warnedKeysByObject.get(object);
2426 if (!warnedKeys) {
2427 warnedKeys = new Set;
2428 this.warnedKeysByObject.set(object, warnedKeys);
2429 }
2430 if (!warnedKeys.has(key)) {
2431 warnedKeys.add(key);
2432 this.logger.warn(message, object);
2433 }
2434 }
2435 }
2436 ]);
2437 return Guide;
2438 }();
2439 function attributeValueContainsToken(attributeName, token) {
2440 return "[".concat(attributeName, '~="').concat(token, '"]');
2441 }
2442 var TargetSet = /*#__PURE__*/ function() {
2443 "use strict";
2444 function TargetSet(scope) {
2445 (0, _classCallCheckJsDefault.default)(this, TargetSet);
2446 this.scope = scope;
2447 }
2448 (0, _createClassJsDefault.default)(TargetSet, [
2449 {
2450 key: "element",
2451 get: function get() {
2452 return this.scope.element;
2453 }
2454 },
2455 {
2456 key: "identifier",
2457 get: function get() {
2458 return this.scope.identifier;
2459 }
2460 },
2461 {
2462 key: "schema",
2463 get: function get() {
2464 return this.scope.schema;
2465 }
2466 },
2467 {
2468 key: "has",
2469 value: function has(targetName) {
2470 return this.find(targetName) != null;
2471 }
2472 },
2473 {
2474 key: "find",
2475 value: function find() {
2476 for(var _len = arguments.length, targetNames = new Array(_len), _key = 0; _key < _len; _key++){
2477 targetNames[_key] = arguments[_key];
2478 }
2479 var _this = this;
2480 return targetNames.reduce(function(target, targetName) {
2481 return target || _this.findTarget(targetName) || _this.findLegacyTarget(targetName);
2482 }, undefined);
2483 }
2484 },
2485 {
2486 key: "findAll",
2487 value: function findAll() {
2488 for(var _len = arguments.length, targetNames = new Array(_len), _key = 0; _key < _len; _key++){
2489 targetNames[_key] = arguments[_key];
2490 }
2491 var _this = this;
2492 return targetNames.reduce(function(targets, targetName) {
2493 return (0, _toConsumableArrayJsDefault.default)(targets).concat((0, _toConsumableArrayJsDefault.default)(_this.findAllTargets(targetName)), (0, _toConsumableArrayJsDefault.default)(_this.findAllLegacyTargets(targetName)));
2494 }, []);
2495 }
2496 },
2497 {
2498 key: "findTarget",
2499 value: function findTarget(targetName) {
2500 var selector = this.getSelectorForTargetName(targetName);
2501 return this.scope.findElement(selector);
2502 }
2503 },
2504 {
2505 key: "findAllTargets",
2506 value: function findAllTargets(targetName) {
2507 var selector = this.getSelectorForTargetName(targetName);
2508 return this.scope.findAllElements(selector);
2509 }
2510 },
2511 {
2512 key: "getSelectorForTargetName",
2513 value: function getSelectorForTargetName(targetName) {
2514 var attributeName = this.schema.targetAttributeForScope(this.identifier);
2515 return attributeValueContainsToken(attributeName, targetName);
2516 }
2517 },
2518 {
2519 key: "findLegacyTarget",
2520 value: function findLegacyTarget(targetName) {
2521 var selector = this.getLegacySelectorForTargetName(targetName);
2522 return this.deprecate(this.scope.findElement(selector), targetName);
2523 }
2524 },
2525 {
2526 key: "findAllLegacyTargets",
2527 value: function findAllLegacyTargets(targetName) {
2528 var _this = this;
2529 var selector = this.getLegacySelectorForTargetName(targetName);
2530 return this.scope.findAllElements(selector).map(function(element) {
2531 return _this.deprecate(element, targetName);
2532 });
2533 }
2534 },
2535 {
2536 key: "getLegacySelectorForTargetName",
2537 value: function getLegacySelectorForTargetName(targetName) {
2538 var targetDescriptor = "".concat(this.identifier, ".").concat(targetName);
2539 return attributeValueContainsToken(this.schema.targetAttribute, targetDescriptor);
2540 }
2541 },
2542 {
2543 key: "deprecate",
2544 value: function deprecate(element, targetName) {
2545 if (element) {
2546 var identifier = this.identifier;
2547 var attributeName = this.schema.targetAttribute;
2548 var revisedAttributeName = this.schema.targetAttributeForScope(identifier);
2549 this.guide.warn(element, "target:".concat(targetName), "Please replace ".concat(attributeName, '="').concat(identifier, ".").concat(targetName, '" with ').concat(revisedAttributeName, '="').concat(targetName, '". ') + "The ".concat(attributeName, " attribute is deprecated and will be removed in a future version of Stimulus."));
2550 }
2551 return element;
2552 }
2553 },
2554 {
2555 key: "guide",
2556 get: function get() {
2557 return this.scope.guide;
2558 }
2559 }
2560 ]);
2561 return TargetSet;
2562 }();
2563 var Scope = /*#__PURE__*/ function() {
2564 "use strict";
2565 function Scope(schema, element2, identifier, logger) {
2566 var _this = this;
2567 (0, _classCallCheckJsDefault.default)(this, Scope);
2568 this.targets = new TargetSet(this);
2569 this.classes = new ClassMap(this);
2570 this.data = new DataMap(this);
2571 this.containsElement = function(element) {
2572 return element.closest(_this.controllerSelector) === _this.element;
2573 };
2574 this.schema = schema;
2575 this.element = element2;
2576 this.identifier = identifier;
2577 this.guide = new Guide(logger);
2578 }
2579 (0, _createClassJsDefault.default)(Scope, [
2580 {
2581 key: "findElement",
2582 value: function findElement(selector) {
2583 return this.element.matches(selector) ? this.element : this.queryElements(selector).find(this.containsElement);
2584 }
2585 },
2586 {
2587 key: "findAllElements",
2588 value: function findAllElements(selector) {
2589 return (0, _toConsumableArrayJsDefault.default)(this.element.matches(selector) ? [
2590 this.element
2591 ] : []).concat((0, _toConsumableArrayJsDefault.default)(this.queryElements(selector).filter(this.containsElement)));
2592 }
2593 },
2594 {
2595 key: "queryElements",
2596 value: function queryElements(selector) {
2597 return Array.from(this.element.querySelectorAll(selector));
2598 }
2599 },
2600 {
2601 key: "controllerSelector",
2602 get: function get() {
2603 return attributeValueContainsToken(this.schema.controllerAttribute, this.identifier);
2604 }
2605 }
2606 ]);
2607 return Scope;
2608 }();
2609 var ScopeObserver = /*#__PURE__*/ function() {
2610 "use strict";
2611 function ScopeObserver(element, schema, delegate) {
2612 (0, _classCallCheckJsDefault.default)(this, ScopeObserver);
2613 this.element = element;
2614 this.schema = schema;
2615 this.delegate = delegate;
2616 this.valueListObserver = new ValueListObserver(this.element, this.controllerAttribute, this);
2617 this.scopesByIdentifierByElement = new WeakMap;
2618 this.scopeReferenceCounts = new WeakMap;
2619 }
2620 (0, _createClassJsDefault.default)(ScopeObserver, [
2621 {
2622 key: "start",
2623 value: function start() {
2624 this.valueListObserver.start();
2625 }
2626 },
2627 {
2628 key: "stop",
2629 value: function stop() {
2630 this.valueListObserver.stop();
2631 }
2632 },
2633 {
2634 key: "controllerAttribute",
2635 get: function get() {
2636 return this.schema.controllerAttribute;
2637 }
2638 },
2639 {
2640 key: "parseValueForToken",
2641 value: function parseValueForToken(token) {
2642 var element = token.element, identifier = token.content;
2643 var scopesByIdentifier = this.fetchScopesByIdentifierForElement(element);
2644 var scope = scopesByIdentifier.get(identifier);
2645 if (!scope) {
2646 scope = this.delegate.createScopeForElementAndIdentifier(element, identifier);
2647 scopesByIdentifier.set(identifier, scope);
2648 }
2649 return scope;
2650 }
2651 },
2652 {
2653 key: "elementMatchedValue",
2654 value: function elementMatchedValue(element, value) {
2655 var referenceCount = (this.scopeReferenceCounts.get(value) || 0) + 1;
2656 this.scopeReferenceCounts.set(value, referenceCount);
2657 if (referenceCount == 1) this.delegate.scopeConnected(value);
2658 }
2659 },
2660 {
2661 key: "elementUnmatchedValue",
2662 value: function elementUnmatchedValue(element, value) {
2663 var referenceCount = this.scopeReferenceCounts.get(value);
2664 if (referenceCount) {
2665 this.scopeReferenceCounts.set(value, referenceCount - 1);
2666 if (referenceCount == 1) this.delegate.scopeDisconnected(value);
2667 }
2668 }
2669 },
2670 {
2671 key: "fetchScopesByIdentifierForElement",
2672 value: function fetchScopesByIdentifierForElement(element) {
2673 var scopesByIdentifier = this.scopesByIdentifierByElement.get(element);
2674 if (!scopesByIdentifier) {
2675 scopesByIdentifier = new Map;
2676 this.scopesByIdentifierByElement.set(element, scopesByIdentifier);
2677 }
2678 return scopesByIdentifier;
2679 }
2680 }
2681 ]);
2682 return ScopeObserver;
2683 }();
2684 var Router = /*#__PURE__*/ function() {
2685 "use strict";
2686 function Router(application) {
2687 (0, _classCallCheckJsDefault.default)(this, Router);
2688 this.application = application;
2689 this.scopeObserver = new ScopeObserver(this.element, this.schema, this);
2690 this.scopesByIdentifier = new Multimap;
2691 this.modulesByIdentifier = new Map;
2692 }
2693 (0, _createClassJsDefault.default)(Router, [
2694 {
2695 key: "element",
2696 get: function get() {
2697 return this.application.element;
2698 }
2699 },
2700 {
2701 key: "schema",
2702 get: function get() {
2703 return this.application.schema;
2704 }
2705 },
2706 {
2707 key: "logger",
2708 get: function get() {
2709 return this.application.logger;
2710 }
2711 },
2712 {
2713 key: "controllerAttribute",
2714 get: function get() {
2715 return this.schema.controllerAttribute;
2716 }
2717 },
2718 {
2719 key: "modules",
2720 get: function get() {
2721 return Array.from(this.modulesByIdentifier.values());
2722 }
2723 },
2724 {
2725 key: "contexts",
2726 get: function get() {
2727 return this.modules.reduce(function(contexts, module) {
2728 return contexts.concat(module.contexts);
2729 }, []);
2730 }
2731 },
2732 {
2733 key: "start",
2734 value: function start() {
2735 this.scopeObserver.start();
2736 }
2737 },
2738 {
2739 key: "stop",
2740 value: function stop() {
2741 this.scopeObserver.stop();
2742 }
2743 },
2744 {
2745 key: "loadDefinition",
2746 value: function loadDefinition(definition) {
2747 this.unloadIdentifier(definition.identifier);
2748 var module = new Module(this.application, definition);
2749 this.connectModule(module);
2750 }
2751 },
2752 {
2753 key: "unloadIdentifier",
2754 value: function unloadIdentifier(identifier) {
2755 var module = this.modulesByIdentifier.get(identifier);
2756 if (module) this.disconnectModule(module);
2757 }
2758 },
2759 {
2760 key: "getContextForElementAndIdentifier",
2761 value: function getContextForElementAndIdentifier(element, identifier) {
2762 var module = this.modulesByIdentifier.get(identifier);
2763 if (module) return module.contexts.find(function(context) {
2764 return context.element == element;
2765 });
2766 }
2767 },
2768 {
2769 key: "handleError",
2770 value: function handleError(error8, message, detail) {
2771 this.application.handleError(error8, message, detail);
2772 }
2773 },
2774 {
2775 key: "createScopeForElementAndIdentifier",
2776 value: function createScopeForElementAndIdentifier(element, identifier) {
2777 return new Scope(this.schema, element, identifier, this.logger);
2778 }
2779 },
2780 {
2781 key: "scopeConnected",
2782 value: function scopeConnected(scope) {
2783 this.scopesByIdentifier.add(scope.identifier, scope);
2784 var module = this.modulesByIdentifier.get(scope.identifier);
2785 if (module) module.connectContextForScope(scope);
2786 }
2787 },
2788 {
2789 key: "scopeDisconnected",
2790 value: function scopeDisconnected(scope) {
2791 this.scopesByIdentifier.delete(scope.identifier, scope);
2792 var module = this.modulesByIdentifier.get(scope.identifier);
2793 if (module) module.disconnectContextForScope(scope);
2794 }
2795 },
2796 {
2797 key: "connectModule",
2798 value: function connectModule(module) {
2799 this.modulesByIdentifier.set(module.identifier, module);
2800 var scopes = this.scopesByIdentifier.getValuesForKey(module.identifier);
2801 scopes.forEach(function(scope) {
2802 return module.connectContextForScope(scope);
2803 });
2804 }
2805 },
2806 {
2807 key: "disconnectModule",
2808 value: function disconnectModule(module) {
2809 this.modulesByIdentifier.delete(module.identifier);
2810 var scopes = this.scopesByIdentifier.getValuesForKey(module.identifier);
2811 scopes.forEach(function(scope) {
2812 return module.disconnectContextForScope(scope);
2813 });
2814 }
2815 }
2816 ]);
2817 return Router;
2818 }();
2819 var defaultSchema = {
2820 controllerAttribute: "data-controller",
2821 actionAttribute: "data-action",
2822 targetAttribute: "data-target",
2823 targetAttributeForScope: function(identifier) {
2824 return "data-".concat(identifier, "-target");
2825 }
2826 };
2827 var Application = /*#__PURE__*/ function() {
2828 "use strict";
2829 function Application() {
2830 var element = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : document.documentElement, schema = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : defaultSchema;
2831 var _this = this;
2832 (0, _classCallCheckJsDefault.default)(this, Application);
2833 this.logger = console;
2834 this.debug = false;
2835 this.logDebugActivity = function(identifier, functionName) {
2836 var detail = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
2837 if (_this.debug) _this.logFormattedMessage(identifier, functionName, detail);
2838 };
2839 this.element = element;
2840 this.schema = schema;
2841 this.dispatcher = new Dispatcher(this);
2842 this.router = new Router(this);
2843 }
2844 (0, _createClassJsDefault.default)(Application, [
2845 {
2846 key: "start",
2847 value: function start() {
2848 var _this = this;
2849 return (0, _asyncToGeneratorJsDefault.default)((0, _regeneratorRuntimeDefault.default).mark(function _callee() {
2850 return (0, _regeneratorRuntimeDefault.default).wrap(function _callee$(_ctx) {
2851 while(1)switch(_ctx.prev = _ctx.next){
2852 case 0:
2853 _ctx.next = 2;
2854 return domReady();
2855 case 2:
2856 _this.logDebugActivity("application", "starting");
2857 _this.dispatcher.start();
2858 _this.router.start();
2859 _this.logDebugActivity("application", "start");
2860 case 6:
2861 case "end":
2862 return _ctx.stop();
2863 }
2864 }, _callee);
2865 }))();
2866 }
2867 },
2868 {
2869 key: "stop",
2870 value: function stop() {
2871 this.logDebugActivity("application", "stopping");
2872 this.dispatcher.stop();
2873 this.router.stop();
2874 this.logDebugActivity("application", "stop");
2875 }
2876 },
2877 {
2878 key: "register",
2879 value: function register(identifier, controllerConstructor) {
2880 if (controllerConstructor.shouldLoad) this.load({
2881 identifier: identifier,
2882 controllerConstructor: controllerConstructor
2883 });
2884 }
2885 },
2886 {
2887 key: "load",
2888 value: function load(head) {
2889 for(var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
2890 rest[_key - 1] = arguments[_key];
2891 }
2892 var _this = this;
2893 var definitions = Array.isArray(head) ? head : [
2894 head
2895 ].concat((0, _toConsumableArrayJsDefault.default)(rest));
2896 definitions.forEach(function(definition) {
2897 return _this.router.loadDefinition(definition);
2898 });
2899 }
2900 },
2901 {
2902 key: "unload",
2903 value: function unload(head) {
2904 for(var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
2905 rest[_key - 1] = arguments[_key];
2906 }
2907 var _this = this;
2908 var identifiers = Array.isArray(head) ? head : [
2909 head
2910 ].concat((0, _toConsumableArrayJsDefault.default)(rest));
2911 identifiers.forEach(function(identifier) {
2912 return _this.router.unloadIdentifier(identifier);
2913 });
2914 }
2915 },
2916 {
2917 key: "controllers",
2918 get: function get() {
2919 return this.router.contexts.map(function(context) {
2920 return context.controller;
2921 });
2922 }
2923 },
2924 {
2925 key: "getControllerForElementAndIdentifier",
2926 value: function getControllerForElementAndIdentifier(element, identifier) {
2927 var context = this.router.getContextForElementAndIdentifier(element, identifier);
2928 return context ? context.controller : null;
2929 }
2930 },
2931 {
2932 key: "handleError",
2933 value: function handleError(error9, message, detail) {
2934 var _a;
2935 this.logger.error("%s\n\n%o\n\n%o", message, error9, detail);
2936 (_a = window.onerror) === null || _a === void 0 || _a.call(window, message, "", 0, 0, error9);
2937 }
2938 },
2939 {
2940 key: "logFormattedMessage",
2941 value: function logFormattedMessage(identifier, functionName) {
2942 var detail = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
2943 detail = Object.assign({
2944 application: this
2945 }, detail);
2946 this.logger.groupCollapsed("".concat(identifier, " #").concat(functionName));
2947 this.logger.log("details:", Object.assign({}, detail));
2948 this.logger.groupEnd();
2949 }
2950 }
2951 ], [
2952 {
2953 key: "start",
2954 value: function start(element, schema) {
2955 var application = new Application(element, schema);
2956 application.start();
2957 return application;
2958 }
2959 }
2960 ]);
2961 return Application;
2962 }();
2963 function domReady() {
2964 return new Promise(function(resolve) {
2965 if (document.readyState == "loading") document.addEventListener("DOMContentLoaded", function() {
2966 return resolve();
2967 });
2968 else resolve();
2969 });
2970 }
2971 function ClassPropertiesBlessing(constructor) {
2972 var classes = readInheritableStaticArrayValues(constructor, "classes");
2973 return classes.reduce(function(properties, classDefinition) {
2974 return Object.assign(properties, propertiesForClassDefinition(classDefinition));
2975 }, {});
2976 }
2977 function propertiesForClassDefinition(key) {
2978 var _obj;
2979 return _obj = {}, (0, _definePropertyJsDefault.default)(_obj, "".concat(key, "Class"), {
2980 get: function() {
2981 var classes = this.classes;
2982 if (classes.has(key)) return classes.get(key);
2983 else {
2984 var attribute = classes.getAttributeName(key);
2985 throw new Error('Missing attribute "'.concat(attribute, '"'));
2986 }
2987 }
2988 }), (0, _definePropertyJsDefault.default)(_obj, "".concat(key, "Classes"), {
2989 get: function() {
2990 return this.classes.getAll(key);
2991 }
2992 }), (0, _definePropertyJsDefault.default)(_obj, "has".concat(capitalize(key), "Class"), {
2993 get: function() {
2994 return this.classes.has(key);
2995 }
2996 }), _obj;
2997 }
2998 function TargetPropertiesBlessing(constructor) {
2999 var targets = readInheritableStaticArrayValues(constructor, "targets");
3000 return targets.reduce(function(properties, targetDefinition) {
3001 return Object.assign(properties, propertiesForTargetDefinition(targetDefinition));
3002 }, {});
3003 }
3004 function propertiesForTargetDefinition(name) {
3005 var _obj;
3006 return _obj = {}, (0, _definePropertyJsDefault.default)(_obj, "".concat(name, "Target"), {
3007 get: function() {
3008 var target = this.targets.find(name);
3009 if (target) return target;
3010 else throw new Error('Missing target element "'.concat(name, '" for "').concat(this.identifier, '" controller'));
3011 }
3012 }), (0, _definePropertyJsDefault.default)(_obj, "".concat(name, "Targets"), {
3013 get: function() {
3014 return this.targets.findAll(name);
3015 }
3016 }), (0, _definePropertyJsDefault.default)(_obj, "has".concat(capitalize(name), "Target"), {
3017 get: function() {
3018 return this.targets.has(name);
3019 }
3020 }), _obj;
3021 }
3022 function ValuePropertiesBlessing(constructor) {
3023 var valueDefinitionPairs = readInheritableStaticObjectPairs(constructor, "values");
3024 var propertyDescriptorMap = {
3025 valueDescriptorMap: {
3026 get: function() {
3027 var _this = this;
3028 return valueDefinitionPairs.reduce(function(result, valueDefinitionPair) {
3029 var valueDescriptor = parseValueDefinitionPair(valueDefinitionPair);
3030 var attributeName = _this.data.getAttributeNameForKey(valueDescriptor.key);
3031 return Object.assign(result, (0, _definePropertyJsDefault.default)({}, attributeName, valueDescriptor));
3032 }, {});
3033 }
3034 }
3035 };
3036 return valueDefinitionPairs.reduce(function(properties, valueDefinitionPair) {
3037 return Object.assign(properties, propertiesForValueDefinitionPair(valueDefinitionPair));
3038 }, propertyDescriptorMap);
3039 }
3040 function propertiesForValueDefinitionPair(valueDefinitionPair) {
3041 var definition = parseValueDefinitionPair(valueDefinitionPair);
3042 var key = definition.key, name = definition.name, read = definition.reader, write = definition.writer;
3043 var _obj;
3044 return _obj = {}, (0, _definePropertyJsDefault.default)(_obj, name, {
3045 get: function() {
3046 var value = this.data.get(key);
3047 if (value !== null) return read(value);
3048 else return definition.defaultValue;
3049 },
3050 set: function(value) {
3051 if (value === undefined) this.data.delete(key);
3052 else this.data.set(key, write(value));
3053 }
3054 }), (0, _definePropertyJsDefault.default)(_obj, "has".concat(capitalize(name)), {
3055 get: function() {
3056 return this.data.has(key) || definition.hasCustomDefaultValue;
3057 }
3058 }), _obj;
3059 }
3060 function parseValueDefinitionPair(param) {
3061 var _param = (0, _slicedToArrayJsDefault.default)(param, 2), token = _param[0], typeDefinition = _param[1];
3062 return valueDescriptorForTokenAndTypeDefinition(token, typeDefinition);
3063 }
3064 function parseValueTypeConstant(constant) {
3065 switch(constant){
3066 case Array:
3067 return "array";
3068 case Boolean:
3069 return "boolean";
3070 case Number:
3071 return "number";
3072 case Object:
3073 return "object";
3074 case String:
3075 return "string";
3076 }
3077 }
3078 function parseValueTypeDefault(defaultValue) {
3079 switch(typeof defaultValue === "undefined" ? "undefined" : (0, _typeOfJsDefault.default)(defaultValue)){
3080 case "boolean":
3081 return "boolean";
3082 case "number":
3083 return "number";
3084 case "string":
3085 return "string";
3086 }
3087 if (Array.isArray(defaultValue)) return "array";
3088 if (Object.prototype.toString.call(defaultValue) === "[object Object]") return "object";
3089 }
3090 function parseValueTypeObject(typeObject) {
3091 var typeFromObject = parseValueTypeConstant(typeObject.type);
3092 if (typeFromObject) {
3093 var defaultValueType = parseValueTypeDefault(typeObject.default);
3094 if (typeFromObject !== defaultValueType) throw new Error('Type "'.concat(typeFromObject, '" must match the type of the default value. Given default value: "').concat(typeObject.default, '" as "').concat(defaultValueType, '"'));
3095 return typeFromObject;
3096 }
3097 }
3098 function parseValueTypeDefinition(typeDefinition) {
3099 var typeFromObject = parseValueTypeObject(typeDefinition);
3100 var typeFromDefaultValue = parseValueTypeDefault(typeDefinition);
3101 var typeFromConstant = parseValueTypeConstant(typeDefinition);
3102 var type = typeFromObject || typeFromDefaultValue || typeFromConstant;
3103 if (type) return type;
3104 throw new Error('Unknown value type "'.concat(typeDefinition, '"'));
3105 }
3106 function defaultValueForDefinition(typeDefinition) {
3107 var constant = parseValueTypeConstant(typeDefinition);
3108 if (constant) return defaultValuesByType[constant];
3109 var defaultValue = typeDefinition.default;
3110 if (defaultValue !== undefined) return defaultValue;
3111 return typeDefinition;
3112 }
3113 function valueDescriptorForTokenAndTypeDefinition(token, typeDefinition) {
3114 var key = "".concat(dasherize(token), "-value");
3115 var type = parseValueTypeDefinition(typeDefinition);
3116 return {
3117 type: type,
3118 key: key,
3119 name: camelize(key),
3120 get defaultValue () {
3121 return defaultValueForDefinition(typeDefinition);
3122 },
3123 get hasCustomDefaultValue () {
3124 return parseValueTypeDefault(typeDefinition) !== undefined;
3125 },
3126 reader: readers[type],
3127 writer: writers[type] || writers.default
3128 };
3129 }
3130 var defaultValuesByType = {
3131 get array () {
3132 return [];
3133 },
3134 boolean: false,
3135 number: 0,
3136 get object () {
3137 return {};
3138 },
3139 string: ""
3140 };
3141 var readers = {
3142 array: function(value) {
3143 var array = JSON.parse(value);
3144 if (!Array.isArray(array)) throw new TypeError("Expected array");
3145 return array;
3146 },
3147 boolean: function(value) {
3148 return !(value == "0" || value == "false");
3149 },
3150 number: function(value) {
3151 return Number(value);
3152 },
3153 object: function(value) {
3154 var object = JSON.parse(value);
3155 if (object === null || typeof object != "object" || Array.isArray(object)) throw new TypeError("Expected object");
3156 return object;
3157 },
3158 string: function(value) {
3159 return value;
3160 }
3161 };
3162 var writers = {
3163 default: writeString,
3164 array: writeJSON,
3165 object: writeJSON
3166 };
3167 function writeJSON(value) {
3168 return JSON.stringify(value);
3169 }
3170 function writeString(value) {
3171 return "".concat(value);
3172 }
3173 var Controller = /*#__PURE__*/ function() {
3174 "use strict";
3175 function Controller(context) {
3176 (0, _classCallCheckJsDefault.default)(this, Controller);
3177 this.context = context;
3178 }
3179 (0, _createClassJsDefault.default)(Controller, [
3180 {
3181 key: "application",
3182 get: function get() {
3183 return this.context.application;
3184 }
3185 },
3186 {
3187 key: "scope",
3188 get: function get() {
3189 return this.context.scope;
3190 }
3191 },
3192 {
3193 key: "element",
3194 get: function get() {
3195 return this.scope.element;
3196 }
3197 },
3198 {
3199 key: "identifier",
3200 get: function get() {
3201 return this.scope.identifier;
3202 }
3203 },
3204 {
3205 key: "targets",
3206 get: function get() {
3207 return this.scope.targets;
3208 }
3209 },
3210 {
3211 key: "classes",
3212 get: function get() {
3213 return this.scope.classes;
3214 }
3215 },
3216 {
3217 key: "data",
3218 get: function get() {
3219 return this.scope.data;
3220 }
3221 },
3222 {
3223 key: "initialize",
3224 value: function initialize() {}
3225 },
3226 {
3227 key: "connect",
3228 value: function connect() {}
3229 },
3230 {
3231 key: "disconnect",
3232 value: function disconnect() {}
3233 },
3234 {
3235 key: "dispatch",
3236 value: function dispatch(eventName) {
3237 var ref = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, _target = ref.target, target = _target === void 0 ? this.element : _target, _detail = ref.detail, detail = _detail === void 0 ? {} : _detail, _prefix = ref.prefix, prefix = _prefix === void 0 ? this.identifier : _prefix, _bubbles = ref.bubbles, bubbles = _bubbles === void 0 ? true : _bubbles, _cancelable = ref.cancelable, cancelable = _cancelable === void 0 ? true : _cancelable;
3238 var type = prefix ? "".concat(prefix, ":").concat(eventName) : eventName;
3239 var event = new CustomEvent(type, {
3240 detail: detail,
3241 bubbles: bubbles,
3242 cancelable: cancelable
3243 });
3244 target.dispatchEvent(event);
3245 return event;
3246 }
3247 }
3248 ], [
3249 {
3250 key: "shouldLoad",
3251 get: function get() {
3252 return true;
3253 }
3254 }
3255 ]);
3256 return Controller;
3257 }();
3258 Controller.blessings = [
3259 ClassPropertiesBlessing,
3260 TargetPropertiesBlessing,
3261 ValuePropertiesBlessing
3262 ];
3263 Controller.targets = [];
3264 Controller.values = {};
3265
3266 },{"@swc/helpers/lib/_async_to_generator.js":"fKf1r","@swc/helpers/lib/_class_call_check.js":"gNxF8","@swc/helpers/lib/_create_class.js":"iyoaN","@swc/helpers/lib/_define_property.js":"6IXzf","@swc/helpers/lib/_get.js":"5g4pb","@swc/helpers/lib/_get_prototype_of.js":"7Gb6H","@swc/helpers/lib/_inherits.js":"atvDk","@swc/helpers/lib/_sliced_to_array.js":"4IWLM","@swc/helpers/lib/_to_consumable_array.js":"cccKv","@swc/helpers/lib/_type_of.js":"9FF45","@swc/helpers/lib/_create_super.js":"5rW3S","regenerator-runtime":"7j2bv","@parcel/transformer-js/src/esmodule-helpers.js":"jIm8e"}],"fKf1r":[function(require,module,exports) {
3267 "use strict";
3268 Object.defineProperty(exports, "__esModule", {
3269 value: true
3270 });
3271 exports.default = _asyncToGenerator;
3272 function _asyncToGenerator(fn) {
3273 return function() {
3274 var self = this, args = arguments;
3275 return new Promise(function(resolve, reject) {
3276 var gen = fn.apply(self, args);
3277 function _next(value) {
3278 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
3279 }
3280 function _throw(err) {
3281 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
3282 }
3283 _next(undefined);
3284 });
3285 };
3286 }
3287 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
3288 try {
3289 var info = gen[key](arg);
3290 var value = info.value;
3291 } catch (error) {
3292 reject(error);
3293 return;
3294 }
3295 if (info.done) resolve(value);
3296 else Promise.resolve(value).then(_next, _throw);
3297 }
3298
3299 },{}],"gNxF8":[function(require,module,exports) {
3300 "use strict";
3301 Object.defineProperty(exports, "__esModule", {
3302 value: true
3303 });
3304 exports.default = _classCallCheck;
3305 function _classCallCheck(instance, Constructor) {
3306 if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
3307 }
3308
3309 },{}],"iyoaN":[function(require,module,exports) {
3310 "use strict";
3311 Object.defineProperty(exports, "__esModule", {
3312 value: true
3313 });
3314 exports.default = _createClass;
3315 function _createClass(Constructor, protoProps, staticProps) {
3316 if (protoProps) _defineProperties(Constructor.prototype, protoProps);
3317 if (staticProps) _defineProperties(Constructor, staticProps);
3318 return Constructor;
3319 }
3320 function _defineProperties(target, props) {
3321 for(var i = 0; i < props.length; i++){
3322 var descriptor = props[i];
3323 descriptor.enumerable = descriptor.enumerable || false;
3324 descriptor.configurable = true;
3325 if ("value" in descriptor) descriptor.writable = true;
3326 Object.defineProperty(target, descriptor.key, descriptor);
3327 }
3328 }
3329
3330 },{}],"6IXzf":[function(require,module,exports) {
3331 "use strict";
3332 Object.defineProperty(exports, "__esModule", {
3333 value: true
3334 });
3335 exports.default = _defineProperty;
3336 function _defineProperty(obj, key, value) {
3337 if (key in obj) Object.defineProperty(obj, key, {
3338 value: value,
3339 enumerable: true,
3340 configurable: true,
3341 writable: true
3342 });
3343 else obj[key] = value;
3344 return obj;
3345 }
3346
3347 },{}],"5g4pb":[function(require,module,exports) {
3348 "use strict";
3349 Object.defineProperty(exports, "__esModule", {
3350 value: true
3351 });
3352 exports.default = _get;
3353 var _superPropBase = _interopRequireDefault(require("./_super_prop_base"));
3354 function _get(target, property, receiver) {
3355 return get(target, property, receiver);
3356 }
3357 function _interopRequireDefault(obj) {
3358 return obj && obj.__esModule ? obj : {
3359 default: obj
3360 };
3361 }
3362 function get(target1, property1, receiver1) {
3363 if (typeof Reflect !== "undefined" && Reflect.get) get = Reflect.get;
3364 else get = function get(target, property, receiver) {
3365 var base = _superPropBase.default(target, property);
3366 if (!base) return;
3367 var desc = Object.getOwnPropertyDescriptor(base, property);
3368 if (desc.get) return desc.get.call(receiver || target);
3369 return desc.value;
3370 };
3371 return get(target1, property1, receiver1);
3372 }
3373
3374 },{"./_super_prop_base":"cT49D"}],"cT49D":[function(require,module,exports) {
3375 "use strict";
3376 Object.defineProperty(exports, "__esModule", {
3377 value: true
3378 });
3379 exports.default = _superPropBase;
3380 var _getPrototypeOf = _interopRequireDefault(require("./_get_prototype_of"));
3381 function _superPropBase(object, property) {
3382 while(!Object.prototype.hasOwnProperty.call(object, property)){
3383 object = _getPrototypeOf.default(object);
3384 if (object === null) break;
3385 }
3386 return object;
3387 }
3388 function _interopRequireDefault(obj) {
3389 return obj && obj.__esModule ? obj : {
3390 default: obj
3391 };
3392 }
3393
3394 },{"./_get_prototype_of":"7Gb6H"}],"7Gb6H":[function(require,module,exports) {
3395 "use strict";
3396 Object.defineProperty(exports, "__esModule", {
3397 value: true
3398 });
3399 exports.default = _getPrototypeOf;
3400 function _getPrototypeOf(o) {
3401 return getPrototypeOf(o);
3402 }
3403 function getPrototypeOf(o1) {
3404 getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
3405 return o.__proto__ || Object.getPrototypeOf(o);
3406 };
3407 return getPrototypeOf(o1);
3408 }
3409
3410 },{}],"atvDk":[function(require,module,exports) {
3411 "use strict";
3412 Object.defineProperty(exports, "__esModule", {
3413 value: true
3414 });
3415 exports.default = _inherits;
3416 var _setPrototypeOf = _interopRequireDefault(require("./_set_prototype_of"));
3417 function _inherits(subClass, superClass) {
3418 if (typeof superClass !== "function" && superClass !== null) throw new TypeError("Super expression must either be null or a function");
3419 subClass.prototype = Object.create(superClass && superClass.prototype, {
3420 constructor: {
3421 value: subClass,
3422 writable: true,
3423 configurable: true
3424 }
3425 });
3426 if (superClass) _setPrototypeOf.default(subClass, superClass);
3427 }
3428 function _interopRequireDefault(obj) {
3429 return obj && obj.__esModule ? obj : {
3430 default: obj
3431 };
3432 }
3433
3434 },{"./_set_prototype_of":"1rATD"}],"1rATD":[function(require,module,exports) {
3435 "use strict";
3436 Object.defineProperty(exports, "__esModule", {
3437 value: true
3438 });
3439 exports.default = _setPrototypeOf;
3440 function _setPrototypeOf(o, p) {
3441 return setPrototypeOf(o, p);
3442 }
3443 function setPrototypeOf(o1, p1) {
3444 setPrototypeOf = Object.setPrototypeOf || function setPrototypeOf(o, p) {
3445 o.__proto__ = p;
3446 return o;
3447 };
3448 return setPrototypeOf(o1, p1);
3449 }
3450
3451 },{}],"4IWLM":[function(require,module,exports) {
3452 "use strict";
3453 Object.defineProperty(exports, "__esModule", {
3454 value: true
3455 });
3456 exports.default = _slicedToArray;
3457 var _arrayWithHoles = _interopRequireDefault(require("./_array_with_holes"));
3458 var _iterableToArray = _interopRequireDefault(require("./_iterable_to_array"));
3459 var _nonIterableRest = _interopRequireDefault(require("./_non_iterable_rest"));
3460 var _unsupportedIterableToArray = _interopRequireDefault(require("./_unsupported_iterable_to_array"));
3461 function _slicedToArray(arr, i) {
3462 return _arrayWithHoles.default(arr) || _iterableToArray.default(arr, i) || _unsupportedIterableToArray.default(arr, i) || _nonIterableRest.default();
3463 }
3464 function _interopRequireDefault(obj) {
3465 return obj && obj.__esModule ? obj : {
3466 default: obj
3467 };
3468 }
3469
3470 },{"./_array_with_holes":"kAkr9","./_iterable_to_array":"d0B07","./_non_iterable_rest":"bXNgi","./_unsupported_iterable_to_array":"jhPJb"}],"kAkr9":[function(require,module,exports) {
3471 "use strict";
3472 Object.defineProperty(exports, "__esModule", {
3473 value: true
3474 });
3475 exports.default = _arrayWithHoles;
3476 function _arrayWithHoles(arr) {
3477 if (Array.isArray(arr)) return arr;
3478 }
3479
3480 },{}],"d0B07":[function(require,module,exports) {
3481 "use strict";
3482 Object.defineProperty(exports, "__esModule", {
3483 value: true
3484 });
3485 exports.default = _iterableToArray;
3486 function _iterableToArray(iter) {
3487 if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
3488 }
3489
3490 },{}],"bXNgi":[function(require,module,exports) {
3491 "use strict";
3492 Object.defineProperty(exports, "__esModule", {
3493 value: true
3494 });
3495 exports.default = _nonIterableRest;
3496 function _nonIterableRest() {
3497 throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3498 }
3499
3500 },{}],"jhPJb":[function(require,module,exports) {
3501 "use strict";
3502 Object.defineProperty(exports, "__esModule", {
3503 value: true
3504 });
3505 exports.default = _unsupportedIterableToArray;
3506 var _arrayLikeToArray = _interopRequireDefault(require("./_array_like_to_array"));
3507 function _unsupportedIterableToArray(o, minLen) {
3508 if (!o) return;
3509 if (typeof o === "string") return _arrayLikeToArray.default(o, minLen);
3510 var n = Object.prototype.toString.call(o).slice(8, -1);
3511 if (n === "Object" && o.constructor) n = o.constructor.name;
3512 if (n === "Map" || n === "Set") return Array.from(n);
3513 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray.default(o, minLen);
3514 }
3515 function _interopRequireDefault(obj) {
3516 return obj && obj.__esModule ? obj : {
3517 default: obj
3518 };
3519 }
3520
3521 },{"./_array_like_to_array":"4K9fh"}],"4K9fh":[function(require,module,exports) {
3522 "use strict";
3523 Object.defineProperty(exports, "__esModule", {
3524 value: true
3525 });
3526 exports.default = _arrayLikeToArray;
3527 function _arrayLikeToArray(arr, len) {
3528 if (len == null || len > arr.length) len = arr.length;
3529 for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
3530 return arr2;
3531 }
3532
3533 },{}],"cccKv":[function(require,module,exports) {
3534 "use strict";
3535 Object.defineProperty(exports, "__esModule", {
3536 value: true
3537 });
3538 exports.default = _toConsumableArray;
3539 var _arrayWithoutHoles = _interopRequireDefault(require("./_array_without_holes"));
3540 var _iterableToArray = _interopRequireDefault(require("./_iterable_to_array"));
3541 var _nonIterableSpread = _interopRequireDefault(require("./_non_iterable_spread"));
3542 var _unsupportedIterableToArray = _interopRequireDefault(require("./_unsupported_iterable_to_array"));
3543 function _toConsumableArray(arr) {
3544 return _arrayWithoutHoles.default(arr) || _iterableToArray.default(arr) || _unsupportedIterableToArray.default(arr) || _nonIterableSpread.default();
3545 }
3546 function _interopRequireDefault(obj) {
3547 return obj && obj.__esModule ? obj : {
3548 default: obj
3549 };
3550 }
3551
3552 },{"./_array_without_holes":"26osg","./_iterable_to_array":"d0B07","./_non_iterable_spread":"nlNPL","./_unsupported_iterable_to_array":"jhPJb"}],"26osg":[function(require,module,exports) {
3553 "use strict";
3554 Object.defineProperty(exports, "__esModule", {
3555 value: true
3556 });
3557 exports.default = _arrayWithoutHoles;
3558 var _arrayLikeToArray = _interopRequireDefault(require("./_array_like_to_array"));
3559 function _arrayWithoutHoles(arr) {
3560 if (Array.isArray(arr)) return _arrayLikeToArray.default(arr);
3561 }
3562 function _interopRequireDefault(obj) {
3563 return obj && obj.__esModule ? obj : {
3564 default: obj
3565 };
3566 }
3567
3568 },{"./_array_like_to_array":"4K9fh"}],"nlNPL":[function(require,module,exports) {
3569 "use strict";
3570 Object.defineProperty(exports, "__esModule", {
3571 value: true
3572 });
3573 exports.default = _nonIterableSpread;
3574 function _nonIterableSpread() {
3575 throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3576 }
3577
3578 },{}],"9FF45":[function(require,module,exports) {
3579 "use strict";
3580 Object.defineProperty(exports, "__esModule", {
3581 value: true
3582 });
3583 exports.default = _typeof;
3584 function _typeof(obj) {
3585 "@swc/helpers - typeof";
3586 return obj && obj.constructor === Symbol ? "symbol" : typeof obj;
3587 }
3588
3589 },{}],"5rW3S":[function(require,module,exports) {
3590 "use strict";
3591 Object.defineProperty(exports, "__esModule", {
3592 value: true
3593 });
3594 exports.default = _createSuper;
3595 var _isNativeReflectConstruct = _interopRequireDefault(require("./_is_native_reflect_construct"));
3596 var _getPrototypeOf = _interopRequireDefault(require("./_get_prototype_of"));
3597 var _possibleConstructorReturn = _interopRequireDefault(require("./_possible_constructor_return"));
3598 function _createSuper(Derived) {
3599 var hasNativeReflectConstruct = _isNativeReflectConstruct.default();
3600 return function _createSuperInternal() {
3601 var Super = _getPrototypeOf.default(Derived), result;
3602 if (hasNativeReflectConstruct) {
3603 var NewTarget = _getPrototypeOf.default(this).constructor;
3604 result = Reflect.construct(Super, arguments, NewTarget);
3605 } else result = Super.apply(this, arguments);
3606 return _possibleConstructorReturn.default(this, result);
3607 };
3608 }
3609 function _interopRequireDefault(obj) {
3610 return obj && obj.__esModule ? obj : {
3611 default: obj
3612 };
3613 }
3614
3615 },{"./_is_native_reflect_construct":"aPH71","./_get_prototype_of":"7Gb6H","./_possible_constructor_return":"hAvqf"}],"aPH71":[function(require,module,exports) {
3616 "use strict";
3617 Object.defineProperty(exports, "__esModule", {
3618 value: true
3619 });
3620 exports.default = _isNativeReflectConstruct;
3621 function _isNativeReflectConstruct() {
3622 if (typeof Reflect === "undefined" || !Reflect.construct) return false;
3623 if (Reflect.construct.sham) return false;
3624 if (typeof Proxy === "function") return true;
3625 try {
3626 Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
3627 return true;
3628 } catch (e) {
3629 return false;
3630 }
3631 }
3632
3633 },{}],"hAvqf":[function(require,module,exports) {
3634 "use strict";
3635 Object.defineProperty(exports, "__esModule", {
3636 value: true
3637 });
3638 exports.default = _possibleConstructorReturn;
3639 var _assertThisInitialized = _interopRequireDefault(require("./_assert_this_initialized"));
3640 var _typeOf = _interopRequireDefault(require("./_type_of"));
3641 function _possibleConstructorReturn(self, call) {
3642 if (call && (_typeOf.default(call) === "object" || typeof call === "function")) return call;
3643 return _assertThisInitialized.default(self);
3644 }
3645 function _interopRequireDefault(obj) {
3646 return obj && obj.__esModule ? obj : {
3647 default: obj
3648 };
3649 }
3650
3651 },{"./_assert_this_initialized":"l7nF8","./_type_of":"9FF45"}],"l7nF8":[function(require,module,exports) {
3652 "use strict";
3653 Object.defineProperty(exports, "__esModule", {
3654 value: true
3655 });
3656 exports.default = _assertThisInitialized;
3657 function _assertThisInitialized(self) {
3658 if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
3659 return self;
3660 }
3661
3662 },{}],"7j2bv":[function(require,module,exports) {
3663 /**
3664 * Copyright (c) 2014-present, Facebook, Inc.
3665 *
3666 * This source code is licensed under the MIT license found in the
3667 * LICENSE file in the root directory of this source tree.
3668 */ var runtime = function(exports) {
3669 "use strict";
3670 var define = function define(obj, key, value) {
3671 Object.defineProperty(obj, key, {
3672 value: value,
3673 enumerable: true,
3674 configurable: true,
3675 writable: true
3676 });
3677 return obj[key];
3678 };
3679 var wrap = function wrap(innerFn, outerFn, self, tryLocsList) {
3680 // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
3681 var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
3682 var generator = Object.create(protoGenerator.prototype);
3683 var context = new Context(tryLocsList || []);
3684 // The ._invoke method unifies the implementations of the .next,
3685 // .throw, and .return methods.
3686 generator._invoke = makeInvokeMethod(innerFn, self, context);
3687 return generator;
3688 };
3689 var tryCatch = // Try/catch helper to minimize deoptimizations. Returns a completion
3690 // record like context.tryEntries[i].completion. This interface could
3691 // have been (and was previously) designed to take a closure to be
3692 // invoked without arguments, but in all the cases we care about we
3693 // already have an existing method we want to call, so there's no need
3694 // to create a new function object. We can even get away with assuming
3695 // the method takes exactly one argument, since that happens to be true
3696 // in every case, so we don't have to touch the arguments object. The
3697 // only additional allocation required is the completion record, which
3698 // has a stable shape and so hopefully should be cheap to allocate.
3699 function tryCatch(fn, obj, arg) {
3700 try {
3701 return {
3702 type: "normal",
3703 arg: fn.call(obj, arg)
3704 };
3705 } catch (err) {
3706 return {
3707 type: "throw",
3708 arg: err
3709 };
3710 }
3711 };
3712 var Generator = // Dummy constructor functions that we use as the .constructor and
3713 // .constructor.prototype properties for functions that return Generator
3714 // objects. For full spec compliance, you may wish to configure your
3715 // minifier not to mangle the names of these two functions.
3716 function Generator() {};
3717 var GeneratorFunction = function GeneratorFunction() {};
3718 var GeneratorFunctionPrototype = function GeneratorFunctionPrototype() {};
3719 var defineIteratorMethods = // Helper for defining the .next, .throw, and .return methods of the
3720 // Iterator interface in terms of a single ._invoke method.
3721 function defineIteratorMethods(prototype) {
3722 [
3723 "next",
3724 "throw",
3725 "return"
3726 ].forEach(function(method) {
3727 define(prototype, method, function(arg) {
3728 return this._invoke(method, arg);
3729 });
3730 });
3731 };
3732 var AsyncIterator = function AsyncIterator(generator, PromiseImpl) {
3733 function invoke(method, arg, resolve, reject) {
3734 var record = tryCatch(generator[method], generator, arg);
3735 if (record.type === "throw") reject(record.arg);
3736 else {
3737 var result = record.arg;
3738 var value1 = result.value;
3739 if (value1 && typeof value1 === "object" && hasOwn.call(value1, "__await")) return PromiseImpl.resolve(value1.__await).then(function(value) {
3740 invoke("next", value, resolve, reject);
3741 }, function(err) {
3742 invoke("throw", err, resolve, reject);
3743 });
3744 return PromiseImpl.resolve(value1).then(function(unwrapped) {
3745 // When a yielded Promise is resolved, its final value becomes
3746 // the .value of the Promise<{value,done}> result for the
3747 // current iteration.
3748 result.value = unwrapped;
3749 resolve(result);
3750 }, function(error) {
3751 // If a rejected Promise was yielded, throw the rejection back
3752 // into the async generator function so it can be handled there.
3753 return invoke("throw", error, resolve, reject);
3754 });
3755 }
3756 }
3757 var previousPromise;
3758 function enqueue(method, arg) {
3759 function callInvokeWithMethodAndArg() {
3760 return new PromiseImpl(function(resolve, reject) {
3761 invoke(method, arg, resolve, reject);
3762 });
3763 }
3764 return previousPromise = // If enqueue has been called before, then we want to wait until
3765 // all previous Promises have been resolved before calling invoke,
3766 // so that results are always delivered in the correct order. If
3767 // enqueue has not been called before, then it is important to
3768 // call invoke immediately, without waiting on a callback to fire,
3769 // so that the async generator function has the opportunity to do
3770 // any necessary setup in a predictable way. This predictability
3771 // is why the Promise constructor synchronously invokes its
3772 // executor callback, and why async functions synchronously
3773 // execute code before the first await. Since we implement simple
3774 // async functions in terms of async generators, it is especially
3775 // important to get this right, even though it requires care.
3776 previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
3777 // invocations of the iterator.
3778 callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
3779 }
3780 // Define the unified helper method that is used to implement .next,
3781 // .throw, and .return (see defineIteratorMethods).
3782 this._invoke = enqueue;
3783 };
3784 var makeInvokeMethod = function makeInvokeMethod(innerFn, self, context) {
3785 var state = GenStateSuspendedStart;
3786 return function invoke(method, arg) {
3787 if (state === GenStateExecuting) throw new Error("Generator is already running");
3788 if (state === GenStateCompleted) {
3789 if (method === "throw") throw arg;
3790 // Be forgiving, per 25.3.3.3.3 of the spec:
3791 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
3792 return doneResult();
3793 }
3794 context.method = method;
3795 context.arg = arg;
3796 while(true){
3797 var delegate = context.delegate;
3798 if (delegate) {
3799 var delegateResult = maybeInvokeDelegate(delegate, context);
3800 if (delegateResult) {
3801 if (delegateResult === ContinueSentinel) continue;
3802 return delegateResult;
3803 }
3804 }
3805 if (context.method === "next") // Setting context._sent for legacy support of Babel's
3806 // function.sent implementation.
3807 context.sent = context._sent = context.arg;
3808 else if (context.method === "throw") {
3809 if (state === GenStateSuspendedStart) {
3810 state = GenStateCompleted;
3811 throw context.arg;
3812 }
3813 context.dispatchException(context.arg);
3814 } else if (context.method === "return") context.abrupt("return", context.arg);
3815 state = GenStateExecuting;
3816 var record = tryCatch(innerFn, self, context);
3817 if (record.type === "normal") {
3818 // If an exception is thrown from innerFn, we leave state ===
3819 // GenStateExecuting and loop back for another invocation.
3820 state = context.done ? GenStateCompleted : GenStateSuspendedYield;
3821 if (record.arg === ContinueSentinel) continue;
3822 return {
3823 value: record.arg,
3824 done: context.done
3825 };
3826 } else if (record.type === "throw") {
3827 state = GenStateCompleted;
3828 // Dispatch the exception by looping back around to the
3829 // context.dispatchException(context.arg) call above.
3830 context.method = "throw";
3831 context.arg = record.arg;
3832 }
3833 }
3834 };
3835 };
3836 var pushTryEntry = function pushTryEntry(locs) {
3837 var entry = {
3838 tryLoc: locs[0]
3839 };
3840 if (1 in locs) entry.catchLoc = locs[1];
3841 if (2 in locs) {
3842 entry.finallyLoc = locs[2];
3843 entry.afterLoc = locs[3];
3844 }
3845 this.tryEntries.push(entry);
3846 };
3847 var resetTryEntry = function resetTryEntry(entry) {
3848 var record = entry.completion || {};
3849 record.type = "normal";
3850 delete record.arg;
3851 entry.completion = record;
3852 };
3853 var Context = function Context(tryLocsList) {
3854 // The root entry object (effectively a try statement without a catch
3855 // or a finally block) gives us a place to store values thrown from
3856 // locations where there is no enclosing try statement.
3857 this.tryEntries = [
3858 {
3859 tryLoc: "root"
3860 }
3861 ];
3862 tryLocsList.forEach(pushTryEntry, this);
3863 this.reset(true);
3864 };
3865 var values = function values(iterable) {
3866 if (iterable) {
3867 var iteratorMethod = iterable[iteratorSymbol];
3868 if (iteratorMethod) return iteratorMethod.call(iterable);
3869 if (typeof iterable.next === "function") return iterable;
3870 if (!isNaN(iterable.length)) {
3871 var i = -1, next1 = function next() {
3872 while(++i < iterable.length)if (hasOwn.call(iterable, i)) {
3873 next.value = iterable[i];
3874 next.done = false;
3875 return next;
3876 }
3877 next.value = undefined;
3878 next.done = true;
3879 return next;
3880 };
3881 return next1.next = next1;
3882 }
3883 }
3884 // Return an iterator with no values.
3885 return {
3886 next: doneResult
3887 };
3888 };
3889 var doneResult = function doneResult() {
3890 return {
3891 value: undefined,
3892 done: true
3893 };
3894 };
3895 var Op = Object.prototype;
3896 var hasOwn = Op.hasOwnProperty;
3897 var undefined; // More compressible than void 0.
3898 var $Symbol = typeof Symbol === "function" ? Symbol : {};
3899 var iteratorSymbol = $Symbol.iterator || "@@iterator";
3900 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
3901 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
3902 try {
3903 // IE 8 has a broken Object.defineProperty that only works on DOM objects.
3904 define({}, "");
3905 } catch (err) {
3906 define = function define(obj, key, value) {
3907 return obj[key] = value;
3908 };
3909 }
3910 exports.wrap = wrap;
3911 var GenStateSuspendedStart = "suspendedStart";
3912 var GenStateSuspendedYield = "suspendedYield";
3913 var GenStateExecuting = "executing";
3914 var GenStateCompleted = "completed";
3915 // Returning this object from the innerFn has the same effect as
3916 // breaking out of the dispatch switch statement.
3917 var ContinueSentinel = {};
3918 // This is a polyfill for %IteratorPrototype% for environments that
3919 // don't natively support it.
3920 var IteratorPrototype = {};
3921 define(IteratorPrototype, iteratorSymbol, function() {
3922 return this;
3923 });
3924 var getProto = Object.getPrototypeOf;
3925 var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
3926 if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) // This environment has a native %IteratorPrototype%; use it instead
3927 // of the polyfill.
3928 IteratorPrototype = NativeIteratorPrototype;
3929 var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
3930 GeneratorFunction.prototype = GeneratorFunctionPrototype;
3931 define(Gp, "constructor", GeneratorFunctionPrototype);
3932 define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
3933 GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
3934 exports.isGeneratorFunction = function(genFun) {
3935 var ctor = typeof genFun === "function" && genFun.constructor;
3936 return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
3937 // do is to check its .name property.
3938 (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
3939 };
3940 exports.mark = function(genFun) {
3941 if (Object.setPrototypeOf) Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
3942 else {
3943 genFun.__proto__ = GeneratorFunctionPrototype;
3944 define(genFun, toStringTagSymbol, "GeneratorFunction");
3945 }
3946 genFun.prototype = Object.create(Gp);
3947 return genFun;
3948 };
3949 // Within the body of any async function, `await x` is transformed to
3950 // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
3951 // `hasOwn.call(value, "__await")` to determine if the yielded value is
3952 // meant to be awaited.
3953 exports.awrap = function(arg) {
3954 return {
3955 __await: arg
3956 };
3957 };
3958 defineIteratorMethods(AsyncIterator.prototype);
3959 define(AsyncIterator.prototype, asyncIteratorSymbol, function() {
3960 return this;
3961 });
3962 exports.AsyncIterator = AsyncIterator;
3963 // Note that simple async functions are implemented on top of
3964 // AsyncIterator objects; they just return a Promise for the value of
3965 // the final result produced by the iterator.
3966 exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
3967 if (PromiseImpl === void 0) PromiseImpl = Promise;
3968 var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
3969 return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
3970 : iter.next().then(function(result) {
3971 return result.done ? result.value : iter.next();
3972 });
3973 };
3974 // Call delegate.iterator[context.method](context.arg) and handle the
3975 // result, either by returning a { value, done } result from the
3976 // delegate iterator, or by modifying context.method and context.arg,
3977 // setting context.delegate to null, and returning the ContinueSentinel.
3978 function maybeInvokeDelegate(delegate, context) {
3979 var method = delegate.iterator[context.method];
3980 if (method === undefined) {
3981 // A .throw or .return when the delegate iterator has no .throw
3982 // method always terminates the yield* loop.
3983 context.delegate = null;
3984 if (context.method === "throw") {
3985 // Note: ["return"] must be used for ES3 parsing compatibility.
3986 if (delegate.iterator["return"]) {
3987 // If the delegate iterator has a return method, give it a
3988 // chance to clean up.
3989 context.method = "return";
3990 context.arg = undefined;
3991 maybeInvokeDelegate(delegate, context);
3992 if (context.method === "throw") // If maybeInvokeDelegate(context) changed context.method from
3993 // "return" to "throw", let that override the TypeError below.
3994 return ContinueSentinel;
3995 }
3996 context.method = "throw";
3997 context.arg = new TypeError("The iterator does not provide a 'throw' method");
3998 }
3999 return ContinueSentinel;
4000 }
4001 var record = tryCatch(method, delegate.iterator, context.arg);
4002 if (record.type === "throw") {
4003 context.method = "throw";
4004 context.arg = record.arg;
4005 context.delegate = null;
4006 return ContinueSentinel;
4007 }
4008 var info = record.arg;
4009 if (!info) {
4010 context.method = "throw";
4011 context.arg = new TypeError("iterator result is not an object");
4012 context.delegate = null;
4013 return ContinueSentinel;
4014 }
4015 if (info.done) {
4016 // Assign the result of the finished delegate to the temporary
4017 // variable specified by delegate.resultName (see delegateYield).
4018 context[delegate.resultName] = info.value;
4019 // Resume execution at the desired location (see delegateYield).
4020 context.next = delegate.nextLoc;
4021 // If context.method was "throw" but the delegate handled the
4022 // exception, let the outer generator proceed normally. If
4023 // context.method was "next", forget context.arg since it has been
4024 // "consumed" by the delegate iterator. If context.method was
4025 // "return", allow the original .return call to continue in the
4026 // outer generator.
4027 if (context.method !== "return") {
4028 context.method = "next";
4029 context.arg = undefined;
4030 }
4031 } else // Re-yield the result returned by the delegate method.
4032 return info;
4033 // The delegate iterator is finished, so forget it and continue with
4034 // the outer generator.
4035 context.delegate = null;
4036 return ContinueSentinel;
4037 }
4038 // Define Generator.prototype.{next,throw,return} in terms of the
4039 // unified ._invoke helper method.
4040 defineIteratorMethods(Gp);
4041 define(Gp, toStringTagSymbol, "Generator");
4042 // A Generator should always return itself as the iterator object when the
4043 // @@iterator function is called on it. Some browsers' implementations of the
4044 // iterator prototype chain incorrectly implement this, causing the Generator
4045 // object to not be returned from this call. This ensures that doesn't happen.
4046 // See https://github.com/facebook/regenerator/issues/274 for more details.
4047 define(Gp, iteratorSymbol, function() {
4048 return this;
4049 });
4050 define(Gp, "toString", function() {
4051 return "[object Generator]";
4052 });
4053 exports.keys = function(object) {
4054 var keys = [];
4055 for(var key1 in object)keys.push(key1);
4056 keys.reverse();
4057 // Rather than returning an object with a next method, we keep
4058 // things simple and return the next function itself.
4059 return function next() {
4060 while(keys.length){
4061 var key = keys.pop();
4062 if (key in object) {
4063 next.value = key;
4064 next.done = false;
4065 return next;
4066 }
4067 }
4068 // To avoid creating an additional object, we just hang the .value
4069 // and .done properties off the next function object itself. This
4070 // also ensures that the minifier will not anonymize the function.
4071 next.done = true;
4072 return next;
4073 };
4074 };
4075 exports.values = values;
4076 Context.prototype = {
4077 constructor: Context,
4078 reset: function reset(skipTempReset) {
4079 this.prev = 0;
4080 this.next = 0;
4081 // Resetting context._sent for legacy support of Babel's
4082 // function.sent implementation.
4083 this.sent = this._sent = undefined;
4084 this.done = false;
4085 this.delegate = null;
4086 this.method = "next";
4087 this.arg = undefined;
4088 this.tryEntries.forEach(resetTryEntry);
4089 if (!skipTempReset) {
4090 for(var name in this)// Not sure about the optimal order of these conditions:
4091 if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) this[name] = undefined;
4092 }
4093 },
4094 stop: function stop() {
4095 this.done = true;
4096 var rootEntry = this.tryEntries[0];
4097 var rootRecord = rootEntry.completion;
4098 if (rootRecord.type === "throw") throw rootRecord.arg;
4099 return this.rval;
4100 },
4101 dispatchException: function dispatchException(exception) {
4102 var handle = function handle(loc, caught) {
4103 record.type = "throw";
4104 record.arg = exception;
4105 context.next = loc;
4106 if (caught) {
4107 // If the dispatched exception was caught by a catch block,
4108 // then let that catch block handle the exception normally.
4109 context.method = "next";
4110 context.arg = undefined;
4111 }
4112 return !!caught;
4113 };
4114 if (this.done) throw exception;
4115 var context = this;
4116 for(var i = this.tryEntries.length - 1; i >= 0; --i){
4117 var entry = this.tryEntries[i];
4118 var record = entry.completion;
4119 if (entry.tryLoc === "root") // Exception thrown outside of any try block that could handle
4120 // it, so set the completion value of the entire function to
4121 // throw the exception.
4122 return handle("end");
4123 if (entry.tryLoc <= this.prev) {
4124 var hasCatch = hasOwn.call(entry, "catchLoc");
4125 var hasFinally = hasOwn.call(entry, "finallyLoc");
4126 if (hasCatch && hasFinally) {
4127 if (this.prev < entry.catchLoc) return handle(entry.catchLoc, true);
4128 else if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
4129 } else if (hasCatch) {
4130 if (this.prev < entry.catchLoc) return handle(entry.catchLoc, true);
4131 } else if (hasFinally) {
4132 if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
4133 } else throw new Error("try statement without catch or finally");
4134 }
4135 }
4136 },
4137 abrupt: function abrupt(type, arg) {
4138 for(var i = this.tryEntries.length - 1; i >= 0; --i){
4139 var entry = this.tryEntries[i];
4140 if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
4141 var finallyEntry = entry;
4142 break;
4143 }
4144 }
4145 if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) // Ignore the finally entry if control is not jumping to a
4146 // location outside the try/catch block.
4147 finallyEntry = null;
4148 var record = finallyEntry ? finallyEntry.completion : {};
4149 record.type = type;
4150 record.arg = arg;
4151 if (finallyEntry) {
4152 this.method = "next";
4153 this.next = finallyEntry.finallyLoc;
4154 return ContinueSentinel;
4155 }
4156 return this.complete(record);
4157 },
4158 complete: function complete(record, afterLoc) {
4159 if (record.type === "throw") throw record.arg;
4160 if (record.type === "break" || record.type === "continue") this.next = record.arg;
4161 else if (record.type === "return") {
4162 this.rval = this.arg = record.arg;
4163 this.method = "return";
4164 this.next = "end";
4165 } else if (record.type === "normal" && afterLoc) this.next = afterLoc;
4166 return ContinueSentinel;
4167 },
4168 finish: function finish(finallyLoc) {
4169 for(var i = this.tryEntries.length - 1; i >= 0; --i){
4170 var entry = this.tryEntries[i];
4171 if (entry.finallyLoc === finallyLoc) {
4172 this.complete(entry.completion, entry.afterLoc);
4173 resetTryEntry(entry);
4174 return ContinueSentinel;
4175 }
4176 }
4177 },
4178 "catch": function(tryLoc) {
4179 for(var i = this.tryEntries.length - 1; i >= 0; --i){
4180 var entry = this.tryEntries[i];
4181 if (entry.tryLoc === tryLoc) {
4182 var record = entry.completion;
4183 if (record.type === "throw") {
4184 var thrown = record.arg;
4185 resetTryEntry(entry);
4186 }
4187 return thrown;
4188 }
4189 }
4190 // The context.catch method must only be called with a location
4191 // argument that corresponds to a known catch block.
4192 throw new Error("illegal catch attempt");
4193 },
4194 delegateYield: function delegateYield(iterable, resultName, nextLoc) {
4195 this.delegate = {
4196 iterator: values(iterable),
4197 resultName: resultName,
4198 nextLoc: nextLoc
4199 };
4200 if (this.method === "next") // Deliberately forget the last sent value so that we don't
4201 // accidentally pass it on to the delegate.
4202 this.arg = undefined;
4203 return ContinueSentinel;
4204 }
4205 };
4206 // Regardless of whether this script is executing as a CommonJS module
4207 // or not, return the runtime object so that we can declare the variable
4208 // regeneratorRuntime in the outer scope, which allows this module to be
4209 // injected easily by `bin/regenerator --include-runtime script.js`.
4210 return exports;
4211 }(module.exports);
4212 try {
4213 regeneratorRuntime = runtime;
4214 } catch (accidentalStrictMode) {
4215 // This module should not be running in strict mode, so the above
4216 // assignment should always work unless something is misconfigured. Just
4217 // in case runtime.js accidentally runs in strict mode, in modern engines
4218 // we can explicitly access globalThis. In older engines we can escape
4219 // strict mode using a global Function call. This could conceivably fail
4220 // if a Content Security Policy forbids using Function, but in that case
4221 // the proper solution is to fix the accidental strict mode problem. If
4222 // you've misconfigured your bundler to force strict mode and applied a
4223 // CSP to forbid Function, and you're not willing to fix either of those
4224 // problems, please detail your unique predicament in a GitHub issue.
4225 if (typeof globalThis === "object") globalThis.regeneratorRuntime = runtime;
4226 else Function("r", "regeneratorRuntime = r")(runtime);
4227 }
4228
4229 },{}],"jIm8e":[function(require,module,exports) {
4230 exports.interopDefault = function(a) {
4231 return a && a.__esModule ? a : {
4232 default: a
4233 };
4234 };
4235 exports.defineInteropFlag = function(a) {
4236 Object.defineProperty(a, "__esModule", {
4237 value: true
4238 });
4239 };
4240 exports.exportAll = function(source, dest) {
4241 Object.keys(source).forEach(function(key) {
4242 if (key === "default" || key === "__esModule" || dest.hasOwnProperty(key)) return;
4243 Object.defineProperty(dest, key, {
4244 enumerable: true,
4245 get: function get() {
4246 return source[key];
4247 }
4248 });
4249 });
4250 return dest;
4251 };
4252 exports.export = function(dest, destName, get) {
4253 Object.defineProperty(dest, destName, {
4254 enumerable: true,
4255 get: get
4256 });
4257 };
4258
4259 },{}],"hrjuy":[function(require,module,exports) {
4260 var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
4261 parcelHelpers.defineInteropFlag(exports);
4262 parcelHelpers.export(exports, "default", function() {
4263 return _class;
4264 });
4265 var _classCallCheckJs = require("@swc/helpers/lib/_class_call_check.js");
4266 var _classCallCheckJsDefault = parcelHelpers.interopDefault(_classCallCheckJs);
4267 var _createClassJs = require("@swc/helpers/lib/_create_class.js");
4268 var _createClassJsDefault = parcelHelpers.interopDefault(_createClassJs);
4269 var _definePropertyJs = require("@swc/helpers/lib/_define_property.js");
4270 var _definePropertyJsDefault = parcelHelpers.interopDefault(_definePropertyJs);
4271 var _inheritsJs = require("@swc/helpers/lib/_inherits.js");
4272 var _inheritsJsDefault = parcelHelpers.interopDefault(_inheritsJs);
4273 var _toConsumableArrayJs = require("@swc/helpers/lib/_to_consumable_array.js");
4274 var _toConsumableArrayJsDefault = parcelHelpers.interopDefault(_toConsumableArrayJs);
4275 var _createSuperJs = require("@swc/helpers/lib/_create_super.js");
4276 var _createSuperJsDefault = parcelHelpers.interopDefault(_createSuperJs);
4277 var _stimulus = require("@hotwired/stimulus");
4278 var _corsairPlugin = require("../chart_plugins/corsair_plugin");
4279 var _corsairPluginDefault = parcelHelpers.interopDefault(_corsairPlugin);
4280 var _htmlLegendPlugin = require("../chart_plugins/html_legend_plugin");
4281 var _htmlLegendPluginDefault = parcelHelpers.interopDefault(_htmlLegendPlugin);
4282 var _chartJs = require("chart.js");
4283 var _Chart;
4284 (_Chart = (0, _chartJs.Chart)).register.apply(_Chart, (0, _toConsumableArrayJsDefault.default)((0, _chartJs.registerables)));
4285 var _class = /*#__PURE__*/ function(Controller) {
4286 "use strict";
4287 (0, _inheritsJsDefault.default)(_class, Controller);
4288 var _super = (0, _createSuperJsDefault.default)(_class);
4289 function _class() {
4290 (0, _classCallCheckJsDefault.default)(this, _class);
4291 return _super.apply(this, arguments);
4292 }
4293 (0, _createClassJsDefault.default)(_class, [
4294 {
4295 key: "connect",
4296 value: function connect() {
4297 (0, _chartJs.Chart).defaults.font.family = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"';
4298 var element = document.getElementById("myChart");
4299 var labels = this.labelsValue;
4300 var data = {
4301 labels: labels,
4302 datasets: [
4303 {
4304 label: "Visitors",
4305 data: this.visitorsValue,
4306 borderColor: "rgba(246,157,10,1)",
4307 fill: true,
4308 backgroundColor: "rgba(246,157,10,0.2)",
4309 pointBackgroundColor: "rgba(246,157,10,1)",
4310 tension: 0.4,
4311 yAxisID: "y"
4312 },
4313 {
4314 label: "Views",
4315 data: this.viewsValue,
4316 borderColor: "rgba(108,70,174,1)",
4317 fill: true,
4318 backgroundColor: "rgba(108,70,174,0.2)",
4319 pointBackgroundColor: "rgba(108,70,174,1)",
4320 tension: 0.4,
4321 yAxisID: "y"
4322 }
4323 ]
4324 };
4325 if (!this.previewValue) data.datasets.push({
4326 label: "Sessions",
4327 data: this.sessionsValue,
4328 borderColor: "rgba(217, 59, 41, 1)",
4329 fill: true,
4330 backgroundColor: "rgba(217, 59, 41, 0.2)",
4331 pointBackgroundColor: "rgba(217, 59, 41, 1)",
4332 tension: 0.4,
4333 yAxisID: "y",
4334 hidden: true
4335 });
4336 var options = {
4337 animation: {
4338 duration: 0
4339 },
4340 interaction: {
4341 intersect: false,
4342 mode: "index"
4343 },
4344 scales: {
4345 y: {
4346 title: {
4347 text: "Views / Visitors / Sessions",
4348 display: this.previewValue ? false : true
4349 },
4350 grid: {
4351 borderColor: "#DEDAE6",
4352 tickColor: "#DEDAE6",
4353 display: true,
4354 drawOnChartArea: true,
4355 borderDash: [
4356 2,
4357 4
4358 ]
4359 },
4360 beginAtZero: true,
4361 suggestedMax: 10,
4362 // grace: '26%',
4363 ticks: {
4364 color: document.body.classList.contains("iawp-dark-mode") ? "#ffffff" : "#6D6A73",
4365 font: {
4366 size: 14,
4367 weight: 400
4368 },
4369 precision: 0
4370 }
4371 },
4372 x: {
4373 grid: {
4374 borderColor: "#DEDAE6",
4375 tickColor: "#DEDAE6",
4376 display: true,
4377 drawOnChartArea: false
4378 },
4379 ticks: {
4380 color: document.body.classList.contains("iawp-dark-mode") ? "#ffffff" : "#6D6A73",
4381 autoSkip: true,
4382 autoSkipPadding: 16,
4383 maxRotation: 0,
4384 // maxTicksLimit: 20,
4385 font: {
4386 size: 14,
4387 weight: 400
4388 },
4389 callback: function callback(value, index, ticks) {
4390 var label = this.getLabelForValue(value);
4391 return label.split(" - ")[0];
4392 }
4393 }
4394 }
4395 },
4396 plugins: {
4397 mode: String,
4398 htmlLegend: {
4399 container: element.parentNode.querySelector(".legend")
4400 },
4401 legend: {
4402 display: false
4403 },
4404 corsair: {
4405 dash: [
4406 2,
4407 4
4408 ],
4409 color: "#777",
4410 width: 1
4411 },
4412 tooltip: {
4413 callbacks: {
4414 label: function(context) {
4415 if (typeof context.dataset.tooltipLabel !== "function") return context.dataset.label + ": " + context.raw;
4416 return context.dataset.tooltipLabel(context.dataset.label, context.raw);
4417 }
4418 }
4419 }
4420 },
4421 elements: {
4422 point: {
4423 radius: 4
4424 }
4425 }
4426 };
4427 if (!this.previewValue && this.usingWoocommerceValue) {
4428 data.datasets.push({
4429 label: "Orders",
4430 data: this.woocommerceOrdersValue,
4431 borderColor: "rgba(35, 125, 68, 1)",
4432 fill: true,
4433 backgroundColor: "rgba(35, 125, 68, .2)",
4434 pointBackgroundColor: "rgba(35, 125, 68, 1)",
4435 tension: 0.4,
4436 yAxisID: "y1",
4437 hidden: true
4438 });
4439 options.scales.y1 = {
4440 title: {
4441 text: "Orders",
4442 display: true,
4443 color: "rgba(35, 125, 68, 1)"
4444 },
4445 position: "right",
4446 display: "auto",
4447 grid: {
4448 borderColor: "rgba(35, 125, 68, 1)",
4449 tickColor: "rgba(35, 125, 68, 1)",
4450 display: false,
4451 drawOnChartArea: false,
4452 borderDash: [
4453 2,
4454 4
4455 ]
4456 },
4457 beginAtZero: true,
4458 suggestedMax: 10,
4459 // grace: '26%',
4460 ticks: {
4461 // color: document.body.classList.contains('iawp-dark-mode') ? '#ffffff' : '#6D6A73',
4462 color: "rgba(35, 125, 68, 1)",
4463 font: {
4464 size: 14,
4465 weight: 400
4466 },
4467 precision: 0
4468 }
4469 };
4470 }
4471 if (!this.previewValue && this.usingWoocommerceValue) {
4472 var _this = this;
4473 data.datasets.push({
4474 label: "Net Sales",
4475 data: this.woocommerceNetSalesValue,
4476 borderColor: "rgba(52, 152, 219, 1)",
4477 fill: true,
4478 backgroundColor: "rgba(52, 152, 219, 0.2)",
4479 pointBackgroundColor: "rgba(52, 152, 219, 1)",
4480 tension: 0.4,
4481 yAxisID: "y2",
4482 tooltipLabel: function(label, rawValue) {
4483 return label + ": " + _this.formatAsCurrency(rawValue);
4484 },
4485 hidden: true
4486 });
4487 options.scales.y2 = {
4488 title: {
4489 text: "Net Sales",
4490 display: true,
4491 color: "rgba(52, 152, 219, 1)"
4492 },
4493 position: "right",
4494 display: "auto",
4495 grid: {
4496 borderColor: "rgba(52, 152, 219, 1)",
4497 tickColor: "rgba(52, 152, 219, 1)",
4498 display: false,
4499 drawOnChartArea: false,
4500 borderDash: [
4501 2,
4502 4
4503 ]
4504 },
4505 beginAtZero: true,
4506 suggestedMax: 10,
4507 // grace: '26%',
4508 ticks: {
4509 // color: document.body.classList.contains('iawp-dark-mode') ? '#ffffff' : '#6D6A73',
4510 color: "rgba(52, 152, 219, 1)",
4511 font: {
4512 size: 14,
4513 weight: 400
4514 },
4515 precision: 0,
4516 callback: function(value, index, ticks) {
4517 return _this.formatAsCurrency(value);
4518 }
4519 }
4520 };
4521 }
4522 var config = {
4523 type: "line",
4524 data: data,
4525 options: options,
4526 plugins: [
4527 (0, _htmlLegendPluginDefault.default),
4528 (0, _corsairPluginDefault.default)
4529 ]
4530 };
4531 var myChart = new (0, _chartJs.Chart)(element, config);
4532 }
4533 },
4534 {
4535 key: "formatAsCurrency",
4536 value: function formatAsCurrency(value) {
4537 return new Intl.NumberFormat(this.languageValue, {
4538 style: "currency",
4539 currency: this.currencyValue,
4540 minimumFractionDigits: 0,
4541 maximumFractionDigits: 0
4542 }).format(value);
4543 }
4544 }
4545 ]);
4546 return _class;
4547 }((0, _stimulus.Controller));
4548 (0, _definePropertyJsDefault.default)(_class, "values", {
4549 preview: Boolean,
4550 usingWoocommerce: Boolean,
4551 language: String,
4552 currency: String,
4553 labels: Array,
4554 views: Array,
4555 visitors: Array,
4556 sessions: Array,
4557 woocommerceOrders: Array,
4558 woocommerceNetSales: Array
4559 });
4560
4561 },{"@swc/helpers/lib/_class_call_check.js":"gNxF8","@swc/helpers/lib/_create_class.js":"iyoaN","@swc/helpers/lib/_define_property.js":"6IXzf","@swc/helpers/lib/_inherits.js":"atvDk","@swc/helpers/lib/_to_consumable_array.js":"cccKv","@swc/helpers/lib/_create_super.js":"5rW3S","@hotwired/stimulus":"27q4D","../chart_plugins/corsair_plugin":"8YKyT","../chart_plugins/html_legend_plugin":"dVdIk","chart.js":"h4klJ","@parcel/transformer-js/src/esmodule-helpers.js":"jIm8e"}],"8YKyT":[function(require,module,exports) {
4562 module.exports = {
4563 id: "corsair",
4564 beforeInit: function(chart, _, opts) {
4565 if (opts.disabled) return;
4566 chart.corsair = {
4567 x: 0,
4568 y: 0
4569 };
4570 },
4571 afterEvent: function(chart, evt, opts) {
4572 if (opts.disabled) return;
4573 var _chartArea = chart.chartArea, top = _chartArea.top, bottom = _chartArea.bottom, left = _chartArea.left, right = _chartArea.right;
4574 var _event = evt.event, x = _event.x, y = _event.y;
4575 if (x < left || x > right || y < top || y > bottom) {
4576 chart.corsair = {
4577 x: x,
4578 y: y,
4579 draw: false
4580 };
4581 chart.draw();
4582 return;
4583 }
4584 chart.corsair = {
4585 x: x,
4586 y: y,
4587 draw: true
4588 };
4589 chart.draw();
4590 },
4591 afterDatasetsDraw: function(chart, _, opts) {
4592 if (opts.disabled) return;
4593 var ctx = chart.ctx, _chartArea = chart.chartArea, top = _chartArea.top, bottom = _chartArea.bottom, left = _chartArea.left, right = _chartArea.right;
4594 var _corsair = chart.corsair, x = _corsair.x, y = _corsair.y, draw = _corsair.draw;
4595 if (!draw) return;
4596 // console.log(chart);
4597 x = chart.tooltip.caretX;
4598 ctx.lineWidth = opts.width || 0;
4599 // // Todo - Why does dash fuck up dots?
4600 ctx.setLineDash(opts.dash || []);
4601 ctx.strokeStyle = opts.color || "black";
4602 ctx.save();
4603 ctx.beginPath();
4604 ctx.moveTo(x, bottom);
4605 ctx.lineTo(x, top);
4606 // Uncomment these 2 lines to add horizontal line
4607 // ctx.moveTo(left, y);
4608 // ctx.lineTo(right, y);
4609 ctx.stroke();
4610 ctx.restore();
4611 ctx.setLineDash([]);
4612 }
4613 };
4614
4615 },{}],"dVdIk":[function(require,module,exports) {
4616 module.exports = {
4617 id: "htmlLegend",
4618 getLegendContainer: function(options) {
4619 if (options.container instanceof HTMLElement) return options.container;
4620 else return document.getElementById(options.containerID);
4621 },
4622 afterUpdate: function(chart, args, options) {
4623 var legendContainer = this.getLegendContainer(options);
4624 var legendList = legendContainer.querySelector("ul");
4625 // Create a list as needed
4626 if (!legendList) {
4627 legendList = document.createElement("ul");
4628 legendList.classList.add("legend-list");
4629 legendContainer.appendChild(legendList);
4630 }
4631 // Remove old legend items
4632 while(legendList.firstChild)legendList.firstChild.remove();
4633 // Reuse the built-in legendItems generator
4634 var items = chart.options.plugins.legend.labels.generateLabels(chart);
4635 items.forEach(function(legendData) {
4636 var legendID = legendData.text.toLowerCase().split(" ").join("-");
4637 var li = document.createElement("li");
4638 li.onclick = function() {
4639 var type = chart.config.type;
4640 if (type === "pie" || type === "doughnut") // Pie and doughnut charts only have a single dataset and visibility is per item
4641 chart.toggleDataVisibility(legendData.index);
4642 else chart.setDatasetVisibility(legendData.datasetIndex, !chart.isDatasetVisible(legendData.datasetIndex));
4643 chart.update();
4644 };
4645 li.classList.add("legend-item", "legend-item-for-".concat(legendID));
4646 if (legendData.hidden) li.classList.add("hidden");
4647 // Color box
4648 var boxSpan = document.createElement("span");
4649 // Text
4650 var textContainer = document.createElement("p");
4651 textContainer.textContent = legendData.text;
4652 li.appendChild(boxSpan);
4653 li.appendChild(textContainer);
4654 legendList.appendChild(li);
4655 });
4656 }
4657 };
4658
4659 },{}],"h4klJ":[function(require,module,exports) {
4660 var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
4661 parcelHelpers.defineInteropFlag(exports);
4662 parcelHelpers.export(exports, "defaults", function() {
4663 return 0, _helpersSegmentJs.d;
4664 });
4665 parcelHelpers.export(exports, "Animation", function() {
4666 return Animation;
4667 });
4668 parcelHelpers.export(exports, "Animations", function() {
4669 return Animations;
4670 });
4671 parcelHelpers.export(exports, "ArcElement", function() {
4672 return ArcElement;
4673 });
4674 parcelHelpers.export(exports, "BarController", function() {
4675 return BarController;
4676 });
4677 parcelHelpers.export(exports, "BarElement", function() {
4678 return BarElement;
4679 });
4680 parcelHelpers.export(exports, "BasePlatform", function() {
4681 return BasePlatform;
4682 });
4683 parcelHelpers.export(exports, "BasicPlatform", function() {
4684 return BasicPlatform;
4685 });
4686 parcelHelpers.export(exports, "BubbleController", function() {
4687 return BubbleController;
4688 });
4689 parcelHelpers.export(exports, "CategoryScale", function() {
4690 return CategoryScale;
4691 });
4692 parcelHelpers.export(exports, "Chart", function() {
4693 return Chart;
4694 });
4695 parcelHelpers.export(exports, "DatasetController", function() {
4696 return DatasetController;
4697 });
4698 parcelHelpers.export(exports, "Decimation", function() {
4699 return plugin_decimation;
4700 });
4701 parcelHelpers.export(exports, "DomPlatform", function() {
4702 return DomPlatform;
4703 });
4704 parcelHelpers.export(exports, "DoughnutController", function() {
4705 return DoughnutController;
4706 });
4707 parcelHelpers.export(exports, "Element", function() {
4708 return Element;
4709 });
4710 parcelHelpers.export(exports, "Filler", function() {
4711 return index;
4712 });
4713 parcelHelpers.export(exports, "Interaction", function() {
4714 return Interaction;
4715 });
4716 parcelHelpers.export(exports, "Legend", function() {
4717 return plugin_legend;
4718 });
4719 parcelHelpers.export(exports, "LineController", function() {
4720 return LineController;
4721 });
4722 parcelHelpers.export(exports, "LineElement", function() {
4723 return LineElement;
4724 });
4725 parcelHelpers.export(exports, "LinearScale", function() {
4726 return LinearScale;
4727 });
4728 parcelHelpers.export(exports, "LogarithmicScale", function() {
4729 return LogarithmicScale;
4730 });
4731 parcelHelpers.export(exports, "PieController", function() {
4732 return PieController;
4733 });
4734 parcelHelpers.export(exports, "PointElement", function() {
4735 return PointElement;
4736 });
4737 parcelHelpers.export(exports, "PolarAreaController", function() {
4738 return PolarAreaController;
4739 });
4740 parcelHelpers.export(exports, "RadarController", function() {
4741 return RadarController;
4742 });
4743 parcelHelpers.export(exports, "RadialLinearScale", function() {
4744 return RadialLinearScale;
4745 });
4746 parcelHelpers.export(exports, "Scale", function() {
4747 return Scale;
4748 });
4749 parcelHelpers.export(exports, "ScatterController", function() {
4750 return ScatterController;
4751 });
4752 parcelHelpers.export(exports, "SubTitle", function() {
4753 return plugin_subtitle;
4754 });
4755 parcelHelpers.export(exports, "Ticks", function() {
4756 return Ticks;
4757 });
4758 parcelHelpers.export(exports, "TimeScale", function() {
4759 return TimeScale;
4760 });
4761 parcelHelpers.export(exports, "TimeSeriesScale", function() {
4762 return TimeSeriesScale;
4763 });
4764 parcelHelpers.export(exports, "Title", function() {
4765 return plugin_title;
4766 });
4767 parcelHelpers.export(exports, "Tooltip", function() {
4768 return plugin_tooltip;
4769 });
4770 parcelHelpers.export(exports, "_adapters", function() {
4771 return adapters;
4772 });
4773 parcelHelpers.export(exports, "_detectPlatform", function() {
4774 return _detectPlatform;
4775 });
4776 parcelHelpers.export(exports, "animator", function() {
4777 return animator;
4778 });
4779 parcelHelpers.export(exports, "controllers", function() {
4780 return controllers;
4781 });
4782 parcelHelpers.export(exports, "elements", function() {
4783 return elements;
4784 });
4785 parcelHelpers.export(exports, "layouts", function() {
4786 return layouts;
4787 });
4788 parcelHelpers.export(exports, "plugins", function() {
4789 return plugins;
4790 });
4791 parcelHelpers.export(exports, "registerables", function() {
4792 return registerables;
4793 });
4794 parcelHelpers.export(exports, "registry", function() {
4795 return registry;
4796 });
4797 parcelHelpers.export(exports, "scales", function() {
4798 return scales;
4799 });
4800 var _assertThisInitializedJs = require("@swc/helpers/lib/_assert_this_initialized.js");
4801 var _assertThisInitializedJsDefault = parcelHelpers.interopDefault(_assertThisInitializedJs);
4802 var _classCallCheckJs = require("@swc/helpers/lib/_class_call_check.js");
4803 var _classCallCheckJsDefault = parcelHelpers.interopDefault(_classCallCheckJs);
4804 var _createClassJs = require("@swc/helpers/lib/_create_class.js");
4805 var _createClassJsDefault = parcelHelpers.interopDefault(_createClassJs);
4806 var _definePropertyJs = require("@swc/helpers/lib/_define_property.js");
4807 var _definePropertyJsDefault = parcelHelpers.interopDefault(_definePropertyJs);
4808 var _getJs = require("@swc/helpers/lib/_get.js");
4809 var _getJsDefault = parcelHelpers.interopDefault(_getJs);
4810 var _getPrototypeOfJs = require("@swc/helpers/lib/_get_prototype_of.js");
4811 var _getPrototypeOfJsDefault = parcelHelpers.interopDefault(_getPrototypeOfJs);
4812 var _inheritsJs = require("@swc/helpers/lib/_inherits.js");
4813 var _inheritsJsDefault = parcelHelpers.interopDefault(_inheritsJs);
4814 var _objectSpreadJs = require("@swc/helpers/lib/_object_spread.js");
4815 var _objectSpreadJsDefault = parcelHelpers.interopDefault(_objectSpreadJs);
4816 var _slicedToArrayJs = require("@swc/helpers/lib/_sliced_to_array.js");
4817 var _slicedToArrayJsDefault = parcelHelpers.interopDefault(_slicedToArrayJs);
4818 var _toConsumableArrayJs = require("@swc/helpers/lib/_to_consumable_array.js");
4819 var _toConsumableArrayJsDefault = parcelHelpers.interopDefault(_toConsumableArrayJs);
4820 var _typeOfJs = require("@swc/helpers/lib/_type_of.js");
4821 var _typeOfJsDefault = parcelHelpers.interopDefault(_typeOfJs);
4822 var _wrapNativeSuperJs = require("@swc/helpers/lib/_wrap_native_super.js");
4823 var _wrapNativeSuperJsDefault = parcelHelpers.interopDefault(_wrapNativeSuperJs);
4824 var _createSuperJs = require("@swc/helpers/lib/_create_super.js");
4825 var _createSuperJsDefault = parcelHelpers.interopDefault(_createSuperJs);
4826 /*!
4827 * Chart.js v3.8.0
4828 * https://www.chartjs.org
4829 * (c) 2022 Chart.js Contributors
4830 * Released under the MIT License
4831 */ var _helpersSegmentJs = require("./chunks/helpers.segment.js");
4832 var Animator = /*#__PURE__*/ function() {
4833 "use strict";
4834 function Animator() {
4835 (0, _classCallCheckJsDefault.default)(this, Animator);
4836 this._request = null;
4837 this._charts = new Map();
4838 this._running = false;
4839 this._lastDate = undefined;
4840 }
4841 (0, _createClassJsDefault.default)(Animator, [
4842 {
4843 key: "_notify",
4844 value: function _notify(chart, anims, date, type) {
4845 var callbacks = anims.listeners[type];
4846 var numSteps = anims.duration;
4847 callbacks.forEach(function(fn) {
4848 return fn({
4849 chart: chart,
4850 initial: anims.initial,
4851 numSteps: numSteps,
4852 currentStep: Math.min(date - anims.start, numSteps)
4853 });
4854 });
4855 }
4856 },
4857 {
4858 key: "_refresh",
4859 value: function _refresh() {
4860 var _this = this;
4861 if (this._request) return;
4862 this._running = true;
4863 this._request = (0, _helpersSegmentJs.r).call(window, function() {
4864 _this._update();
4865 _this._request = null;
4866 if (_this._running) _this._refresh();
4867 });
4868 }
4869 },
4870 {
4871 key: "_update",
4872 value: function _update() {
4873 var date = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : Date.now();
4874 var _this = this;
4875 var remaining = 0;
4876 this._charts.forEach(function(anims, chart) {
4877 if (!anims.running || !anims.items.length) return;
4878 var items = anims.items;
4879 var i = items.length - 1;
4880 var draw1 = false;
4881 var item;
4882 for(; i >= 0; --i){
4883 item = items[i];
4884 if (item._active) {
4885 if (item._total > anims.duration) anims.duration = item._total;
4886 item.tick(date);
4887 draw1 = true;
4888 } else {
4889 items[i] = items[items.length - 1];
4890 items.pop();
4891 }
4892 }
4893 if (draw1) {
4894 chart.draw();
4895 _this._notify(chart, anims, date, "progress");
4896 }
4897 if (!items.length) {
4898 anims.running = false;
4899 _this._notify(chart, anims, date, "complete");
4900 anims.initial = false;
4901 }
4902 remaining += items.length;
4903 });
4904 this._lastDate = date;
4905 if (remaining === 0) this._running = false;
4906 }
4907 },
4908 {
4909 key: "_getAnims",
4910 value: function _getAnims(chart) {
4911 var charts = this._charts;
4912 var anims = charts.get(chart);
4913 if (!anims) {
4914 anims = {
4915 running: false,
4916 initial: true,
4917 items: [],
4918 listeners: {
4919 complete: [],
4920 progress: []
4921 }
4922 };
4923 charts.set(chart, anims);
4924 }
4925 return anims;
4926 }
4927 },
4928 {
4929 key: "listen",
4930 value: function listen(chart, event, cb) {
4931 this._getAnims(chart).listeners[event].push(cb);
4932 }
4933 },
4934 {
4935 key: "add",
4936 value: function add(chart, items) {
4937 var _items;
4938 if (!items || !items.length) return;
4939 (_items = this._getAnims(chart).items).push.apply(_items, (0, _toConsumableArrayJsDefault.default)(items));
4940 }
4941 },
4942 {
4943 key: "has",
4944 value: function has(chart) {
4945 return this._getAnims(chart).items.length > 0;
4946 }
4947 },
4948 {
4949 key: "start",
4950 value: function start(chart) {
4951 var anims = this._charts.get(chart);
4952 if (!anims) return;
4953 anims.running = true;
4954 anims.start = Date.now();
4955 anims.duration = anims.items.reduce(function(acc, cur) {
4956 return Math.max(acc, cur._duration);
4957 }, 0);
4958 this._refresh();
4959 }
4960 },
4961 {
4962 key: "running",
4963 value: function running(chart) {
4964 if (!this._running) return false;
4965 var anims = this._charts.get(chart);
4966 if (!anims || !anims.running || !anims.items.length) return false;
4967 return true;
4968 }
4969 },
4970 {
4971 key: "stop",
4972 value: function stop(chart) {
4973 var anims = this._charts.get(chart);
4974 if (!anims || !anims.items.length) return;
4975 var items = anims.items;
4976 var i = items.length - 1;
4977 for(; i >= 0; --i)items[i].cancel();
4978 anims.items = [];
4979 this._notify(chart, anims, Date.now(), "complete");
4980 }
4981 },
4982 {
4983 key: "remove",
4984 value: function remove(chart) {
4985 return this._charts.delete(chart);
4986 }
4987 }
4988 ]);
4989 return Animator;
4990 }();
4991 var animator = new Animator();
4992 var transparent = "transparent";
4993 var interpolators = {
4994 boolean: function(from, to, factor) {
4995 return factor > 0.5 ? to : from;
4996 },
4997 color: function(from, to, factor) {
4998 var c0 = (0, _helpersSegmentJs.c)(from || transparent);
4999 var c1 = c0.valid && (0, _helpersSegmentJs.c)(to || transparent);
5000 return c1 && c1.valid ? c1.mix(c0, factor).hexString() : to;
5001 },
5002 number: function(from, to, factor) {
5003 return from + (to - from) * factor;
5004 }
5005 };
5006 var Animation = /*#__PURE__*/ function() {
5007 "use strict";
5008 function Animation(cfg, target, prop, to) {
5009 (0, _classCallCheckJsDefault.default)(this, Animation);
5010 var currentValue = target[prop];
5011 to = (0, _helpersSegmentJs.a)([
5012 cfg.to,
5013 to,
5014 currentValue,
5015 cfg.from
5016 ]);
5017 var from = (0, _helpersSegmentJs.a)([
5018 cfg.from,
5019 currentValue,
5020 to
5021 ]);
5022 this._active = true;
5023 this._fn = cfg.fn || interpolators[cfg.type || (typeof from === "undefined" ? "undefined" : (0, _typeOfJsDefault.default)(from))];
5024 this._easing = (0, _helpersSegmentJs.e)[cfg.easing] || (0, _helpersSegmentJs.e).linear;
5025 this._start = Math.floor(Date.now() + (cfg.delay || 0));
5026 this._duration = this._total = Math.floor(cfg.duration);
5027 this._loop = !!cfg.loop;
5028 this._target = target;
5029 this._prop = prop;
5030 this._from = from;
5031 this._to = to;
5032 this._promises = undefined;
5033 }
5034 (0, _createClassJsDefault.default)(Animation, [
5035 {
5036 key: "active",
5037 value: function active() {
5038 return this._active;
5039 }
5040 },
5041 {
5042 key: "update",
5043 value: function update(cfg, to, date) {
5044 if (this._active) {
5045 this._notify(false);
5046 var currentValue = this._target[this._prop];
5047 var elapsed = date - this._start;
5048 var remain = this._duration - elapsed;
5049 this._start = date;
5050 this._duration = Math.floor(Math.max(remain, cfg.duration));
5051 this._total += elapsed;
5052 this._loop = !!cfg.loop;
5053 this._to = (0, _helpersSegmentJs.a)([
5054 cfg.to,
5055 to,
5056 currentValue,
5057 cfg.from
5058 ]);
5059 this._from = (0, _helpersSegmentJs.a)([
5060 cfg.from,
5061 currentValue,
5062 to
5063 ]);
5064 }
5065 }
5066 },
5067 {
5068 key: "cancel",
5069 value: function cancel() {
5070 if (this._active) {
5071 this.tick(Date.now());
5072 this._active = false;
5073 this._notify(false);
5074 }
5075 }
5076 },
5077 {
5078 key: "tick",
5079 value: function tick(date) {
5080 var elapsed = date - this._start;
5081 var duration = this._duration;
5082 var prop = this._prop;
5083 var from = this._from;
5084 var loop = this._loop;
5085 var to = this._to;
5086 var factor;
5087 this._active = from !== to && (loop || elapsed < duration);
5088 if (!this._active) {
5089 this._target[prop] = to;
5090 this._notify(true);
5091 return;
5092 }
5093 if (elapsed < 0) {
5094 this._target[prop] = from;
5095 return;
5096 }
5097 factor = elapsed / duration % 2;
5098 factor = loop && factor > 1 ? 2 - factor : factor;
5099 factor = this._easing(Math.min(1, Math.max(0, factor)));
5100 this._target[prop] = this._fn(from, to, factor);
5101 }
5102 },
5103 {
5104 key: "wait",
5105 value: function wait() {
5106 var promises = this._promises || (this._promises = []);
5107 return new Promise(function(res, rej) {
5108 promises.push({
5109 res: res,
5110 rej: rej
5111 });
5112 });
5113 }
5114 },
5115 {
5116 key: "_notify",
5117 value: function _notify(resolved) {
5118 var method = resolved ? "res" : "rej";
5119 var promises = this._promises || [];
5120 for(var i = 0; i < promises.length; i++)promises[i][method]();
5121 }
5122 }
5123 ]);
5124 return Animation;
5125 }();
5126 var numbers = [
5127 "x",
5128 "y",
5129 "borderWidth",
5130 "radius",
5131 "tension"
5132 ];
5133 var colors = [
5134 "color",
5135 "borderColor",
5136 "backgroundColor"
5137 ];
5138 (0, _helpersSegmentJs.d).set("animation", {
5139 delay: undefined,
5140 duration: 1000,
5141 easing: "easeOutQuart",
5142 fn: undefined,
5143 from: undefined,
5144 loop: undefined,
5145 to: undefined,
5146 type: undefined
5147 });
5148 var animationOptions = Object.keys((0, _helpersSegmentJs.d).animation);
5149 (0, _helpersSegmentJs.d).describe("animation", {
5150 _fallback: false,
5151 _indexable: false,
5152 _scriptable: function(name) {
5153 return name !== "onProgress" && name !== "onComplete" && name !== "fn";
5154 }
5155 });
5156 (0, _helpersSegmentJs.d).set("animations", {
5157 colors: {
5158 type: "color",
5159 properties: colors
5160 },
5161 numbers: {
5162 type: "number",
5163 properties: numbers
5164 }
5165 });
5166 (0, _helpersSegmentJs.d).describe("animations", {
5167 _fallback: "animation"
5168 });
5169 (0, _helpersSegmentJs.d).set("transitions", {
5170 active: {
5171 animation: {
5172 duration: 400
5173 }
5174 },
5175 resize: {
5176 animation: {
5177 duration: 0
5178 }
5179 },
5180 show: {
5181 animations: {
5182 colors: {
5183 from: "transparent"
5184 },
5185 visible: {
5186 type: "boolean",
5187 duration: 0
5188 }
5189 }
5190 },
5191 hide: {
5192 animations: {
5193 colors: {
5194 to: "transparent"
5195 },
5196 visible: {
5197 type: "boolean",
5198 easing: "linear",
5199 fn: function(v) {
5200 return v | 0;
5201 }
5202 }
5203 }
5204 }
5205 });
5206 var Animations = /*#__PURE__*/ function() {
5207 "use strict";
5208 function Animations(chart, config) {
5209 (0, _classCallCheckJsDefault.default)(this, Animations);
5210 this._chart = chart;
5211 this._properties = new Map();
5212 this.configure(config);
5213 }
5214 (0, _createClassJsDefault.default)(Animations, [
5215 {
5216 key: "configure",
5217 value: function configure(config) {
5218 if (!(0, _helpersSegmentJs.i)(config)) return;
5219 var animatedProps = this._properties;
5220 Object.getOwnPropertyNames(config).forEach(function(key) {
5221 var cfg = config[key];
5222 if (!(0, _helpersSegmentJs.i)(cfg)) return;
5223 var resolved = {};
5224 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
5225 try {
5226 for(var _iterator = animationOptions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
5227 var option = _step.value;
5228 resolved[option] = cfg[option];
5229 }
5230 } catch (err) {
5231 _didIteratorError = true;
5232 _iteratorError = err;
5233 } finally{
5234 try {
5235 if (!_iteratorNormalCompletion && _iterator.return != null) {
5236 _iterator.return();
5237 }
5238 } finally{
5239 if (_didIteratorError) {
5240 throw _iteratorError;
5241 }
5242 }
5243 }
5244 ((0, _helpersSegmentJs.b)(cfg.properties) && cfg.properties || [
5245 key
5246 ]).forEach(function(prop) {
5247 if (prop === key || !animatedProps.has(prop)) animatedProps.set(prop, resolved);
5248 });
5249 });
5250 }
5251 },
5252 {
5253 key: "_animateOptions",
5254 value: function _animateOptions(target, values) {
5255 var newOptions = values.options;
5256 var options = resolveTargetOptions(target, newOptions);
5257 if (!options) return [];
5258 var animations = this._createAnimations(options, newOptions);
5259 if (newOptions.$shared) awaitAll(target.options.$animations, newOptions).then(function() {
5260 target.options = newOptions;
5261 }, function() {});
5262 return animations;
5263 }
5264 },
5265 {
5266 key: "_createAnimations",
5267 value: function _createAnimations(target, values) {
5268 var animatedProps = this._properties;
5269 var animations = [];
5270 var running = target.$animations || (target.$animations = {});
5271 var props = Object.keys(values);
5272 var date = Date.now();
5273 var i;
5274 for(i = props.length - 1; i >= 0; --i){
5275 var prop = props[i];
5276 if (prop.charAt(0) === "$") continue;
5277 if (prop === "options") {
5278 var _animations;
5279 (_animations = animations).push.apply(_animations, (0, _toConsumableArrayJsDefault.default)(this._animateOptions(target, values)));
5280 continue;
5281 }
5282 var value = values[prop];
5283 var animation = running[prop];
5284 var cfg = animatedProps.get(prop);
5285 if (animation) {
5286 if (cfg && animation.active()) {
5287 animation.update(cfg, value, date);
5288 continue;
5289 } else animation.cancel();
5290 }
5291 if (!cfg || !cfg.duration) {
5292 target[prop] = value;
5293 continue;
5294 }
5295 running[prop] = animation = new Animation(cfg, target, prop, value);
5296 animations.push(animation);
5297 }
5298 return animations;
5299 }
5300 },
5301 {
5302 key: "update",
5303 value: function update(target, values) {
5304 if (this._properties.size === 0) {
5305 Object.assign(target, values);
5306 return;
5307 }
5308 var animations = this._createAnimations(target, values);
5309 if (animations.length) {
5310 animator.add(this._chart, animations);
5311 return true;
5312 }
5313 }
5314 }
5315 ]);
5316 return Animations;
5317 }();
5318 function awaitAll(animations, properties) {
5319 var running = [];
5320 var keys = Object.keys(properties);
5321 for(var i = 0; i < keys.length; i++){
5322 var anim = animations[keys[i]];
5323 if (anim && anim.active()) running.push(anim.wait());
5324 }
5325 return Promise.all(running);
5326 }
5327 function resolveTargetOptions(target, newOptions) {
5328 if (!newOptions) return;
5329 var options = target.options;
5330 if (!options) {
5331 target.options = newOptions;
5332 return;
5333 }
5334 if (options.$shared) target.options = options = Object.assign({}, options, {
5335 $shared: false,
5336 $animations: {}
5337 });
5338 return options;
5339 }
5340 function scaleClip(scale, allowedOverflow) {
5341 var opts = scale && scale.options || {};
5342 var reverse = opts.reverse;
5343 var min = opts.min === undefined ? allowedOverflow : 0;
5344 var max = opts.max === undefined ? allowedOverflow : 0;
5345 return {
5346 start: reverse ? max : min,
5347 end: reverse ? min : max
5348 };
5349 }
5350 function defaultClip(xScale, yScale, allowedOverflow) {
5351 if (allowedOverflow === false) return false;
5352 var x = scaleClip(xScale, allowedOverflow);
5353 var y = scaleClip(yScale, allowedOverflow);
5354 return {
5355 top: y.end,
5356 right: x.end,
5357 bottom: y.start,
5358 left: x.start
5359 };
5360 }
5361 function toClip(value) {
5362 var t, r, b, l;
5363 if ((0, _helpersSegmentJs.i)(value)) {
5364 t = value.top;
5365 r = value.right;
5366 b = value.bottom;
5367 l = value.left;
5368 } else t = r = b = l = value;
5369 return {
5370 top: t,
5371 right: r,
5372 bottom: b,
5373 left: l,
5374 disabled: value === false
5375 };
5376 }
5377 function getSortedDatasetIndices(chart, filterVisible) {
5378 var keys = [];
5379 var metasets = chart._getSortedDatasetMetas(filterVisible);
5380 var i, ilen;
5381 for(i = 0, ilen = metasets.length; i < ilen; ++i)keys.push(metasets[i].index);
5382 return keys;
5383 }
5384 function applyStack(stack, value, dsIndex) {
5385 var options = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
5386 var keys = stack.keys;
5387 var singleMode = options.mode === "single";
5388 var i, ilen, datasetIndex, otherValue;
5389 if (value === null) return;
5390 for(i = 0, ilen = keys.length; i < ilen; ++i){
5391 datasetIndex = +keys[i];
5392 if (datasetIndex === dsIndex) {
5393 if (options.all) continue;
5394 break;
5395 }
5396 otherValue = stack.values[datasetIndex];
5397 if ((0, _helpersSegmentJs.g)(otherValue) && (singleMode || value === 0 || (0, _helpersSegmentJs.s)(value) === (0, _helpersSegmentJs.s)(otherValue))) value += otherValue;
5398 }
5399 return value;
5400 }
5401 function convertObjectDataToArray(data) {
5402 var keys = Object.keys(data);
5403 var adata = new Array(keys.length);
5404 var i, ilen, key;
5405 for(i = 0, ilen = keys.length; i < ilen; ++i){
5406 key = keys[i];
5407 adata[i] = {
5408 x: key,
5409 y: data[key]
5410 };
5411 }
5412 return adata;
5413 }
5414 function isStacked(scale, meta) {
5415 var stacked = scale && scale.options.stacked;
5416 return stacked || stacked === undefined && meta.stack !== undefined;
5417 }
5418 function getStackKey(indexScale, valueScale, meta) {
5419 return "".concat(indexScale.id, ".").concat(valueScale.id, ".").concat(meta.stack || meta.type);
5420 }
5421 function getUserBounds(scale) {
5422 var ref = scale.getUserBounds(), min = ref.min, max = ref.max, minDefined = ref.minDefined, maxDefined = ref.maxDefined;
5423 return {
5424 min: minDefined ? min : Number.NEGATIVE_INFINITY,
5425 max: maxDefined ? max : Number.POSITIVE_INFINITY
5426 };
5427 }
5428 function getOrCreateStack(stacks, stackKey, indexValue) {
5429 var subStack = stacks[stackKey] || (stacks[stackKey] = {});
5430 return subStack[indexValue] || (subStack[indexValue] = {});
5431 }
5432 function getLastIndexInStack(stack, vScale, positive, type) {
5433 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
5434 try {
5435 for(var _iterator = vScale.getMatchingVisibleMetas(type).reverse()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
5436 var meta = _step.value;
5437 var value = stack[meta.index];
5438 if (positive && value > 0 || !positive && value < 0) return meta.index;
5439 }
5440 } catch (err) {
5441 _didIteratorError = true;
5442 _iteratorError = err;
5443 } finally{
5444 try {
5445 if (!_iteratorNormalCompletion && _iterator.return != null) {
5446 _iterator.return();
5447 }
5448 } finally{
5449 if (_didIteratorError) {
5450 throw _iteratorError;
5451 }
5452 }
5453 }
5454 return null;
5455 }
5456 function updateStacks(controller, parsed) {
5457 var chart = controller.chart, meta = controller._cachedMeta;
5458 var stacks = chart._stacks || (chart._stacks = {});
5459 var iScale = meta.iScale, vScale = meta.vScale, datasetIndex = meta.index;
5460 var iAxis = iScale.axis;
5461 var vAxis = vScale.axis;
5462 var key = getStackKey(iScale, vScale, meta);
5463 var ilen = parsed.length;
5464 var stack;
5465 for(var i = 0; i < ilen; ++i){
5466 var item = parsed[i];
5467 var index1 = item[iAxis], value = item[vAxis];
5468 var itemStacks = item._stacks || (item._stacks = {});
5469 stack = itemStacks[vAxis] = getOrCreateStack(stacks, key, index1);
5470 stack[datasetIndex] = value;
5471 stack._top = getLastIndexInStack(stack, vScale, true, meta.type);
5472 stack._bottom = getLastIndexInStack(stack, vScale, false, meta.type);
5473 }
5474 }
5475 function getFirstScaleId(chart, axis) {
5476 var scales1 = chart.scales;
5477 return Object.keys(scales1).filter(function(key) {
5478 return scales1[key].axis === axis;
5479 }).shift();
5480 }
5481 function createDatasetContext(parent, index2) {
5482 return (0, _helpersSegmentJs.h)(parent, {
5483 active: false,
5484 dataset: undefined,
5485 datasetIndex: index2,
5486 index: index2,
5487 mode: "default",
5488 type: "dataset"
5489 });
5490 }
5491 function createDataContext(parent, index3, element) {
5492 return (0, _helpersSegmentJs.h)(parent, {
5493 active: false,
5494 dataIndex: index3,
5495 parsed: undefined,
5496 raw: undefined,
5497 element: element,
5498 index: index3,
5499 mode: "default",
5500 type: "data"
5501 });
5502 }
5503 function clearStacks(meta, items) {
5504 var datasetIndex = meta.controller.index;
5505 var axis = meta.vScale && meta.vScale.axis;
5506 if (!axis) return;
5507 items = items || meta._parsed;
5508 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
5509 try {
5510 for(var _iterator = items[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
5511 var parsed = _step.value;
5512 var stacks = parsed._stacks;
5513 if (!stacks || stacks[axis] === undefined || stacks[axis][datasetIndex] === undefined) return;
5514 delete stacks[axis][datasetIndex];
5515 }
5516 } catch (err) {
5517 _didIteratorError = true;
5518 _iteratorError = err;
5519 } finally{
5520 try {
5521 if (!_iteratorNormalCompletion && _iterator.return != null) {
5522 _iterator.return();
5523 }
5524 } finally{
5525 if (_didIteratorError) {
5526 throw _iteratorError;
5527 }
5528 }
5529 }
5530 }
5531 var isDirectUpdateMode = function(mode) {
5532 return mode === "reset" || mode === "none";
5533 };
5534 var cloneIfNotShared = function(cached, shared) {
5535 return shared ? cached : Object.assign({}, cached);
5536 };
5537 var createStack = function(canStack, meta, chart) {
5538 return canStack && !meta.hidden && meta._stacked && {
5539 keys: getSortedDatasetIndices(chart, true),
5540 values: null
5541 };
5542 };
5543 var DatasetController = /*#__PURE__*/ function() {
5544 "use strict";
5545 function DatasetController(chart, datasetIndex) {
5546 (0, _classCallCheckJsDefault.default)(this, DatasetController);
5547 this.chart = chart;
5548 this._ctx = chart.ctx;
5549 this.index = datasetIndex;
5550 this._cachedDataOpts = {};
5551 this._cachedMeta = this.getMeta();
5552 this._type = this._cachedMeta.type;
5553 this.options = undefined;
5554 this._parsing = false;
5555 this._data = undefined;
5556 this._objectData = undefined;
5557 this._sharedOptions = undefined;
5558 this._drawStart = undefined;
5559 this._drawCount = undefined;
5560 this.enableOptionSharing = false;
5561 this.supportsDecimation = false;
5562 this.$context = undefined;
5563 this._syncList = [];
5564 this.initialize();
5565 }
5566 (0, _createClassJsDefault.default)(DatasetController, [
5567 {
5568 key: "initialize",
5569 value: function initialize() {
5570 var meta = this._cachedMeta;
5571 this.configure();
5572 this.linkScales();
5573 meta._stacked = isStacked(meta.vScale, meta);
5574 this.addElements();
5575 }
5576 },
5577 {
5578 key: "updateIndex",
5579 value: function updateIndex(datasetIndex) {
5580 if (this.index !== datasetIndex) clearStacks(this._cachedMeta);
5581 this.index = datasetIndex;
5582 }
5583 },
5584 {
5585 key: "linkScales",
5586 value: function linkScales() {
5587 var chart = this.chart;
5588 var meta = this._cachedMeta;
5589 var dataset = this.getDataset();
5590 var chooseId = function(axis, x, y, r) {
5591 return axis === "x" ? x : axis === "r" ? r : y;
5592 };
5593 var xid = meta.xAxisID = (0, _helpersSegmentJs.v)(dataset.xAxisID, getFirstScaleId(chart, "x"));
5594 var yid = meta.yAxisID = (0, _helpersSegmentJs.v)(dataset.yAxisID, getFirstScaleId(chart, "y"));
5595 var rid = meta.rAxisID = (0, _helpersSegmentJs.v)(dataset.rAxisID, getFirstScaleId(chart, "r"));
5596 var indexAxis = meta.indexAxis;
5597 var iid = meta.iAxisID = chooseId(indexAxis, xid, yid, rid);
5598 var vid = meta.vAxisID = chooseId(indexAxis, yid, xid, rid);
5599 meta.xScale = this.getScaleForId(xid);
5600 meta.yScale = this.getScaleForId(yid);
5601 meta.rScale = this.getScaleForId(rid);
5602 meta.iScale = this.getScaleForId(iid);
5603 meta.vScale = this.getScaleForId(vid);
5604 }
5605 },
5606 {
5607 key: "getDataset",
5608 value: function getDataset() {
5609 return this.chart.data.datasets[this.index];
5610 }
5611 },
5612 {
5613 key: "getMeta",
5614 value: function getMeta() {
5615 return this.chart.getDatasetMeta(this.index);
5616 }
5617 },
5618 {
5619 key: "getScaleForId",
5620 value: function getScaleForId(scaleID) {
5621 return this.chart.scales[scaleID];
5622 }
5623 },
5624 {
5625 key: "_getOtherScale",
5626 value: function _getOtherScale(scale) {
5627 var meta = this._cachedMeta;
5628 return scale === meta.iScale ? meta.vScale : meta.iScale;
5629 }
5630 },
5631 {
5632 key: "reset",
5633 value: function reset() {
5634 this._update("reset");
5635 }
5636 },
5637 {
5638 key: "_destroy",
5639 value: function _destroy() {
5640 var meta = this._cachedMeta;
5641 if (this._data) (0, _helpersSegmentJs.u)(this._data, this);
5642 if (meta._stacked) clearStacks(meta);
5643 }
5644 },
5645 {
5646 key: "_dataCheck",
5647 value: function _dataCheck() {
5648 var dataset = this.getDataset();
5649 var data = dataset.data || (dataset.data = []);
5650 var _data = this._data;
5651 if ((0, _helpersSegmentJs.i)(data)) this._data = convertObjectDataToArray(data);
5652 else if (_data !== data) {
5653 if (_data) {
5654 (0, _helpersSegmentJs.u)(_data, this);
5655 var meta = this._cachedMeta;
5656 clearStacks(meta);
5657 meta._parsed = [];
5658 }
5659 if (data && Object.isExtensible(data)) (0, _helpersSegmentJs.l)(data, this);
5660 this._syncList = [];
5661 this._data = data;
5662 }
5663 }
5664 },
5665 {
5666 key: "addElements",
5667 value: function addElements() {
5668 var meta = this._cachedMeta;
5669 this._dataCheck();
5670 if (this.datasetElementType) meta.dataset = new this.datasetElementType();
5671 }
5672 },
5673 {
5674 key: "buildOrUpdateElements",
5675 value: function buildOrUpdateElements(resetNewElements) {
5676 var meta = this._cachedMeta;
5677 var dataset = this.getDataset();
5678 var stackChanged = false;
5679 this._dataCheck();
5680 var oldStacked = meta._stacked;
5681 meta._stacked = isStacked(meta.vScale, meta);
5682 if (meta.stack !== dataset.stack) {
5683 stackChanged = true;
5684 clearStacks(meta);
5685 meta.stack = dataset.stack;
5686 }
5687 this._resyncElements(resetNewElements);
5688 if (stackChanged || oldStacked !== meta._stacked) updateStacks(this, meta._parsed);
5689 }
5690 },
5691 {
5692 key: "configure",
5693 value: function configure() {
5694 var config = this.chart.config;
5695 var scopeKeys = config.datasetScopeKeys(this._type);
5696 var scopes = config.getOptionScopes(this.getDataset(), scopeKeys, true);
5697 this.options = config.createResolver(scopes, this.getContext());
5698 this._parsing = this.options.parsing;
5699 this._cachedDataOpts = {};
5700 }
5701 },
5702 {
5703 key: "parse",
5704 value: function parse1(start, count) {
5705 var ref = this, meta = ref._cachedMeta, data = ref._data;
5706 var iScale = meta.iScale, _stacked = meta._stacked;
5707 var iAxis = iScale.axis;
5708 var sorted = start === 0 && count === data.length ? true : meta._sorted;
5709 var prev = start > 0 && meta._parsed[start - 1];
5710 var i, cur, parsed;
5711 if (this._parsing === false) {
5712 meta._parsed = data;
5713 meta._sorted = true;
5714 parsed = data;
5715 } else {
5716 if ((0, _helpersSegmentJs.b)(data[start])) parsed = this.parseArrayData(meta, data, start, count);
5717 else if ((0, _helpersSegmentJs.i)(data[start])) parsed = this.parseObjectData(meta, data, start, count);
5718 else parsed = this.parsePrimitiveData(meta, data, start, count);
5719 var isNotInOrderComparedToPrev = function() {
5720 return cur[iAxis] === null || prev && cur[iAxis] < prev[iAxis];
5721 };
5722 for(i = 0; i < count; ++i){
5723 meta._parsed[i + start] = cur = parsed[i];
5724 if (sorted) {
5725 if (isNotInOrderComparedToPrev()) sorted = false;
5726 prev = cur;
5727 }
5728 }
5729 meta._sorted = sorted;
5730 }
5731 if (_stacked) updateStacks(this, parsed);
5732 }
5733 },
5734 {
5735 key: "parsePrimitiveData",
5736 value: function parsePrimitiveData(meta, data, start, count) {
5737 var iScale = meta.iScale, vScale = meta.vScale;
5738 var iAxis = iScale.axis;
5739 var vAxis = vScale.axis;
5740 var labels = iScale.getLabels();
5741 var singleScale = iScale === vScale;
5742 var parsed = new Array(count);
5743 var i, ilen, index4;
5744 for(i = 0, ilen = count; i < ilen; ++i){
5745 index4 = i + start;
5746 var _obj;
5747 parsed[i] = (_obj = {}, (0, _definePropertyJsDefault.default)(_obj, iAxis, singleScale || iScale.parse(labels[index4], index4)), (0, _definePropertyJsDefault.default)(_obj, vAxis, vScale.parse(data[index4], index4)), _obj);
5748 }
5749 return parsed;
5750 }
5751 },
5752 {
5753 key: "parseArrayData",
5754 value: function parseArrayData(meta, data, start, count) {
5755 var xScale = meta.xScale, yScale = meta.yScale;
5756 var parsed = new Array(count);
5757 var i, ilen, index5, item;
5758 for(i = 0, ilen = count; i < ilen; ++i){
5759 index5 = i + start;
5760 item = data[index5];
5761 parsed[i] = {
5762 x: xScale.parse(item[0], index5),
5763 y: yScale.parse(item[1], index5)
5764 };
5765 }
5766 return parsed;
5767 }
5768 },
5769 {
5770 key: "parseObjectData",
5771 value: function parseObjectData(meta, data, start, count) {
5772 var xScale = meta.xScale, yScale = meta.yScale;
5773 var __parsing = this._parsing, _xAxisKey = __parsing.xAxisKey, xAxisKey = _xAxisKey === void 0 ? "x" : _xAxisKey, _yAxisKey = __parsing.yAxisKey, yAxisKey = _yAxisKey === void 0 ? "y" : _yAxisKey;
5774 var parsed = new Array(count);
5775 var i, ilen, index6, item;
5776 for(i = 0, ilen = count; i < ilen; ++i){
5777 index6 = i + start;
5778 item = data[index6];
5779 parsed[i] = {
5780 x: xScale.parse((0, _helpersSegmentJs.f)(item, xAxisKey), index6),
5781 y: yScale.parse((0, _helpersSegmentJs.f)(item, yAxisKey), index6)
5782 };
5783 }
5784 return parsed;
5785 }
5786 },
5787 {
5788 key: "getParsed",
5789 value: function getParsed(index7) {
5790 return this._cachedMeta._parsed[index7];
5791 }
5792 },
5793 {
5794 key: "getDataElement",
5795 value: function getDataElement(index8) {
5796 return this._cachedMeta.data[index8];
5797 }
5798 },
5799 {
5800 key: "applyStack",
5801 value: function applyStack1(scale, parsed, mode) {
5802 var chart = this.chart;
5803 var meta = this._cachedMeta;
5804 var value = parsed[scale.axis];
5805 var stack = {
5806 keys: getSortedDatasetIndices(chart, true),
5807 values: parsed._stacks[scale.axis]
5808 };
5809 return applyStack(stack, value, meta.index, {
5810 mode: mode
5811 });
5812 }
5813 },
5814 {
5815 key: "updateRangeFromParsed",
5816 value: function updateRangeFromParsed(range, scale, parsed, stack) {
5817 var parsedValue = parsed[scale.axis];
5818 var value = parsedValue === null ? NaN : parsedValue;
5819 var values = stack && parsed._stacks[scale.axis];
5820 if (stack && values) {
5821 stack.values = values;
5822 value = applyStack(stack, parsedValue, this._cachedMeta.index);
5823 }
5824 range.min = Math.min(range.min, value);
5825 range.max = Math.max(range.max, value);
5826 }
5827 },
5828 {
5829 key: "getMinMax",
5830 value: function getMinMax(scale, canStack) {
5831 var _skip = function _skip() {
5832 parsed = _parsed[i];
5833 var otherValue = parsed[otherScale.axis];
5834 return !(0, _helpersSegmentJs.g)(parsed[scale.axis]) || otherMin > otherValue || otherMax < otherValue;
5835 };
5836 var meta = this._cachedMeta;
5837 var _parsed = meta._parsed;
5838 var sorted = meta._sorted && scale === meta.iScale;
5839 var ilen = _parsed.length;
5840 var otherScale = this._getOtherScale(scale);
5841 var stack = createStack(canStack, meta, this.chart);
5842 var range = {
5843 min: Number.POSITIVE_INFINITY,
5844 max: Number.NEGATIVE_INFINITY
5845 };
5846 var ref = getUserBounds(otherScale), otherMin = ref.min, otherMax = ref.max;
5847 var i, parsed;
5848 for(i = 0; i < ilen; ++i){
5849 if (_skip()) continue;
5850 this.updateRangeFromParsed(range, scale, parsed, stack);
5851 if (sorted) break;
5852 }
5853 if (sorted) for(i = ilen - 1; i >= 0; --i){
5854 if (_skip()) continue;
5855 this.updateRangeFromParsed(range, scale, parsed, stack);
5856 break;
5857 }
5858 return range;
5859 }
5860 },
5861 {
5862 key: "getAllParsedValues",
5863 value: function getAllParsedValues(scale) {
5864 var parsed = this._cachedMeta._parsed;
5865 var values = [];
5866 var i, ilen, value;
5867 for(i = 0, ilen = parsed.length; i < ilen; ++i){
5868 value = parsed[i][scale.axis];
5869 if ((0, _helpersSegmentJs.g)(value)) values.push(value);
5870 }
5871 return values;
5872 }
5873 },
5874 {
5875 key: "getMaxOverflow",
5876 value: function getMaxOverflow() {
5877 return false;
5878 }
5879 },
5880 {
5881 key: "getLabelAndValue",
5882 value: function getLabelAndValue(index9) {
5883 var meta = this._cachedMeta;
5884 var iScale = meta.iScale;
5885 var vScale = meta.vScale;
5886 var parsed = this.getParsed(index9);
5887 return {
5888 label: iScale ? "" + iScale.getLabelForValue(parsed[iScale.axis]) : "",
5889 value: vScale ? "" + vScale.getLabelForValue(parsed[vScale.axis]) : ""
5890 };
5891 }
5892 },
5893 {
5894 key: "_update",
5895 value: function _update(mode) {
5896 var meta = this._cachedMeta;
5897 this.update(mode || "default");
5898 meta._clip = toClip((0, _helpersSegmentJs.v)(this.options.clip, defaultClip(meta.xScale, meta.yScale, this.getMaxOverflow())));
5899 }
5900 },
5901 {
5902 key: "update",
5903 value: function update(mode) {}
5904 },
5905 {
5906 key: "draw",
5907 value: function draw2() {
5908 var ctx = this._ctx;
5909 var chart = this.chart;
5910 var meta = this._cachedMeta;
5911 var elements1 = meta.data || [];
5912 var area = chart.chartArea;
5913 var active = [];
5914 var start = this._drawStart || 0;
5915 var count = this._drawCount || elements1.length - start;
5916 var drawActiveElementsOnTop = this.options.drawActiveElementsOnTop;
5917 var i;
5918 if (meta.dataset) meta.dataset.draw(ctx, area, start, count);
5919 for(i = start; i < start + count; ++i){
5920 var element = elements1[i];
5921 if (element.hidden) continue;
5922 if (element.active && drawActiveElementsOnTop) active.push(element);
5923 else element.draw(ctx, area);
5924 }
5925 for(i = 0; i < active.length; ++i)active[i].draw(ctx, area);
5926 }
5927 },
5928 {
5929 key: "getStyle",
5930 value: function getStyle(index10, active) {
5931 var mode = active ? "active" : "default";
5932 return index10 === undefined && this._cachedMeta.dataset ? this.resolveDatasetElementOptions(mode) : this.resolveDataElementOptions(index10 || 0, mode);
5933 }
5934 },
5935 {
5936 key: "getContext",
5937 value: function getContext(index11, active, mode) {
5938 var dataset = this.getDataset();
5939 var context;
5940 if (index11 >= 0 && index11 < this._cachedMeta.data.length) {
5941 var element = this._cachedMeta.data[index11];
5942 context = element.$context || (element.$context = createDataContext(this.getContext(), index11, element));
5943 context.parsed = this.getParsed(index11);
5944 context.raw = dataset.data[index11];
5945 context.index = context.dataIndex = index11;
5946 } else {
5947 context = this.$context || (this.$context = createDatasetContext(this.chart.getContext(), this.index));
5948 context.dataset = dataset;
5949 context.index = context.datasetIndex = this.index;
5950 }
5951 context.active = !!active;
5952 context.mode = mode;
5953 return context;
5954 }
5955 },
5956 {
5957 key: "resolveDatasetElementOptions",
5958 value: function resolveDatasetElementOptions(mode) {
5959 return this._resolveElementOptions(this.datasetElementType.id, mode);
5960 }
5961 },
5962 {
5963 key: "resolveDataElementOptions",
5964 value: function resolveDataElementOptions(index12, mode) {
5965 return this._resolveElementOptions(this.dataElementType.id, mode, index12);
5966 }
5967 },
5968 {
5969 key: "_resolveElementOptions",
5970 value: function _resolveElementOptions(elementType) {
5971 var mode = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "default", index13 = arguments.length > 2 ? arguments[2] : void 0;
5972 var _this = this;
5973 var active = mode === "active";
5974 var cache = this._cachedDataOpts;
5975 var cacheKey = elementType + "-" + mode;
5976 var cached = cache[cacheKey];
5977 var sharing = this.enableOptionSharing && (0, _helpersSegmentJs.j)(index13);
5978 if (cached) return cloneIfNotShared(cached, sharing);
5979 var config = this.chart.config;
5980 var scopeKeys = config.datasetElementScopeKeys(this._type, elementType);
5981 var prefixes = active ? [
5982 "".concat(elementType, "Hover"),
5983 "hover",
5984 elementType,
5985 ""
5986 ] : [
5987 elementType,
5988 ""
5989 ];
5990 var scopes = config.getOptionScopes(this.getDataset(), scopeKeys);
5991 var names = Object.keys((0, _helpersSegmentJs.d).elements[elementType]);
5992 var context = function() {
5993 return _this.getContext(index13, active);
5994 };
5995 var values = config.resolveNamedOptions(scopes, names, context, prefixes);
5996 if (values.$shared) {
5997 values.$shared = sharing;
5998 cache[cacheKey] = Object.freeze(cloneIfNotShared(values, sharing));
5999 }
6000 return values;
6001 }
6002 },
6003 {
6004 key: "_resolveAnimations",
6005 value: function _resolveAnimations(index14, transition, active) {
6006 var chart = this.chart;
6007 var cache = this._cachedDataOpts;
6008 var cacheKey = "animation-".concat(transition);
6009 var cached = cache[cacheKey];
6010 if (cached) return cached;
6011 var options;
6012 if (chart.options.animation !== false) {
6013 var config = this.chart.config;
6014 var scopeKeys = config.datasetAnimationScopeKeys(this._type, transition);
6015 var scopes = config.getOptionScopes(this.getDataset(), scopeKeys);
6016 options = config.createResolver(scopes, this.getContext(index14, active, transition));
6017 }
6018 var animations = new Animations(chart, options && options.animations);
6019 if (options && options._cacheable) cache[cacheKey] = Object.freeze(animations);
6020 return animations;
6021 }
6022 },
6023 {
6024 key: "getSharedOptions",
6025 value: function getSharedOptions(options) {
6026 if (!options.$shared) return;
6027 return this._sharedOptions || (this._sharedOptions = Object.assign({}, options));
6028 }
6029 },
6030 {
6031 key: "includeOptions",
6032 value: function includeOptions(mode, sharedOptions) {
6033 return !sharedOptions || isDirectUpdateMode(mode) || this.chart._animationsDisabled;
6034 }
6035 },
6036 {
6037 key: "updateElement",
6038 value: function updateElement(element, index15, properties, mode) {
6039 if (isDirectUpdateMode(mode)) Object.assign(element, properties);
6040 else this._resolveAnimations(index15, mode).update(element, properties);
6041 }
6042 },
6043 {
6044 key: "updateSharedOptions",
6045 value: function updateSharedOptions(sharedOptions, mode, newOptions) {
6046 if (sharedOptions && !isDirectUpdateMode(mode)) this._resolveAnimations(undefined, mode).update(sharedOptions, newOptions);
6047 }
6048 },
6049 {
6050 key: "_setStyle",
6051 value: function _setStyle(element, index16, mode, active) {
6052 element.active = active;
6053 var options = this.getStyle(index16, active);
6054 this._resolveAnimations(index16, mode, active).update(element, {
6055 options: !active && this.getSharedOptions(options) || options
6056 });
6057 }
6058 },
6059 {
6060 key: "removeHoverStyle",
6061 value: function removeHoverStyle(element, datasetIndex, index17) {
6062 this._setStyle(element, index17, "active", false);
6063 }
6064 },
6065 {
6066 key: "setHoverStyle",
6067 value: function setHoverStyle(element, datasetIndex, index18) {
6068 this._setStyle(element, index18, "active", true);
6069 }
6070 },
6071 {
6072 key: "_removeDatasetHoverStyle",
6073 value: function _removeDatasetHoverStyle() {
6074 var element = this._cachedMeta.dataset;
6075 if (element) this._setStyle(element, undefined, "active", false);
6076 }
6077 },
6078 {
6079 key: "_setDatasetHoverStyle",
6080 value: function _setDatasetHoverStyle() {
6081 var element = this._cachedMeta.dataset;
6082 if (element) this._setStyle(element, undefined, "active", true);
6083 }
6084 },
6085 {
6086 key: "_resyncElements",
6087 value: function _resyncElements(resetNewElements) {
6088 var data = this._data;
6089 var elements2 = this._cachedMeta.data;
6090 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6091 try {
6092 for(var _iterator = this._syncList[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6093 var _value = (0, _slicedToArrayJsDefault.default)(_step.value, 3), method = _value[0], arg1 = _value[1], arg2 = _value[2];
6094 this[method](arg1, arg2);
6095 }
6096 } catch (err) {
6097 _didIteratorError = true;
6098 _iteratorError = err;
6099 } finally{
6100 try {
6101 if (!_iteratorNormalCompletion && _iterator.return != null) {
6102 _iterator.return();
6103 }
6104 } finally{
6105 if (_didIteratorError) {
6106 throw _iteratorError;
6107 }
6108 }
6109 }
6110 this._syncList = [];
6111 var numMeta = elements2.length;
6112 var numData = data.length;
6113 var count = Math.min(numData, numMeta);
6114 if (count) this.parse(0, count);
6115 if (numData > numMeta) this._insertElements(numMeta, numData - numMeta, resetNewElements);
6116 else if (numData < numMeta) this._removeElements(numData, numMeta - numData);
6117 }
6118 },
6119 {
6120 key: "_insertElements",
6121 value: function _insertElements(start, count) {
6122 var resetNewElements = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
6123 var meta = this._cachedMeta;
6124 var data = meta.data;
6125 var end = start + count;
6126 var i;
6127 var move = function(arr) {
6128 arr.length += count;
6129 for(i = arr.length - 1; i >= end; i--)arr[i] = arr[i - count];
6130 };
6131 move(data);
6132 for(i = start; i < end; ++i)data[i] = new this.dataElementType();
6133 if (this._parsing) move(meta._parsed);
6134 this.parse(start, count);
6135 if (resetNewElements) this.updateElements(data, start, count, "reset");
6136 }
6137 },
6138 {
6139 key: "updateElements",
6140 value: function updateElements(element, start, count, mode) {}
6141 },
6142 {
6143 key: "_removeElements",
6144 value: function _removeElements(start, count) {
6145 var meta = this._cachedMeta;
6146 if (this._parsing) {
6147 var removed = meta._parsed.splice(start, count);
6148 if (meta._stacked) clearStacks(meta, removed);
6149 }
6150 meta.data.splice(start, count);
6151 }
6152 },
6153 {
6154 key: "_sync",
6155 value: function _sync(args) {
6156 if (this._parsing) this._syncList.push(args);
6157 else {
6158 var _args = (0, _slicedToArrayJsDefault.default)(args, 3), method = _args[0], arg1 = _args[1], arg2 = _args[2];
6159 this[method](arg1, arg2);
6160 }
6161 this.chart._dataChanges.push([
6162 this.index
6163 ].concat((0, _toConsumableArrayJsDefault.default)(args)));
6164 }
6165 },
6166 {
6167 key: "_onDataPush",
6168 value: function _onDataPush() {
6169 var count = arguments.length;
6170 this._sync([
6171 "_insertElements",
6172 this.getDataset().data.length - count,
6173 count
6174 ]);
6175 }
6176 },
6177 {
6178 key: "_onDataPop",
6179 value: function _onDataPop() {
6180 this._sync([
6181 "_removeElements",
6182 this._cachedMeta.data.length - 1,
6183 1
6184 ]);
6185 }
6186 },
6187 {
6188 key: "_onDataShift",
6189 value: function _onDataShift() {
6190 this._sync([
6191 "_removeElements",
6192 0,
6193 1
6194 ]);
6195 }
6196 },
6197 {
6198 key: "_onDataSplice",
6199 value: function _onDataSplice(start, count) {
6200 if (count) this._sync([
6201 "_removeElements",
6202 start,
6203 count
6204 ]);
6205 var newCount = arguments.length - 2;
6206 if (newCount) this._sync([
6207 "_insertElements",
6208 start,
6209 newCount
6210 ]);
6211 }
6212 },
6213 {
6214 key: "_onDataUnshift",
6215 value: function _onDataUnshift() {
6216 this._sync([
6217 "_insertElements",
6218 0,
6219 arguments.length
6220 ]);
6221 }
6222 }
6223 ]);
6224 return DatasetController;
6225 }();
6226 DatasetController.defaults = {};
6227 DatasetController.prototype.datasetElementType = null;
6228 DatasetController.prototype.dataElementType = null;
6229 function getAllScaleValues(scale, type) {
6230 if (!scale._cache.$bar) {
6231 var visibleMetas = scale.getMatchingVisibleMetas(type);
6232 var values = [];
6233 for(var i = 0, ilen = visibleMetas.length; i < ilen; i++)values = values.concat(visibleMetas[i].controller.getAllParsedValues(scale));
6234 scale._cache.$bar = (0, _helpersSegmentJs._)(values.sort(function(a, b) {
6235 return a - b;
6236 }));
6237 }
6238 return scale._cache.$bar;
6239 }
6240 function computeMinSampleSize(meta) {
6241 var scale = meta.iScale;
6242 var values = getAllScaleValues(scale, meta.type);
6243 var min = scale._length;
6244 var i, ilen, curr, prev;
6245 var updateMinAndPrev = function() {
6246 if (curr === 32767 || curr === -32768) return;
6247 if ((0, _helpersSegmentJs.j)(prev)) min = Math.min(min, Math.abs(curr - prev) || min);
6248 prev = curr;
6249 };
6250 for(i = 0, ilen = values.length; i < ilen; ++i){
6251 curr = scale.getPixelForValue(values[i]);
6252 updateMinAndPrev();
6253 }
6254 prev = undefined;
6255 for(i = 0, ilen = scale.ticks.length; i < ilen; ++i){
6256 curr = scale.getPixelForTick(i);
6257 updateMinAndPrev();
6258 }
6259 return min;
6260 }
6261 function computeFitCategoryTraits(index19, ruler, options, stackCount) {
6262 var thickness = options.barThickness;
6263 var size, ratio;
6264 if ((0, _helpersSegmentJs.k)(thickness)) {
6265 size = ruler.min * options.categoryPercentage;
6266 ratio = options.barPercentage;
6267 } else {
6268 size = thickness * stackCount;
6269 ratio = 1;
6270 }
6271 return {
6272 chunk: size / stackCount,
6273 ratio: ratio,
6274 start: ruler.pixels[index19] - size / 2
6275 };
6276 }
6277 function computeFlexCategoryTraits(index20, ruler, options, stackCount) {
6278 var pixels = ruler.pixels;
6279 var curr = pixels[index20];
6280 var prev = index20 > 0 ? pixels[index20 - 1] : null;
6281 var next = index20 < pixels.length - 1 ? pixels[index20 + 1] : null;
6282 var percent = options.categoryPercentage;
6283 if (prev === null) prev = curr - (next === null ? ruler.end - ruler.start : next - curr);
6284 if (next === null) next = curr + curr - prev;
6285 var start = curr - (curr - Math.min(prev, next)) / 2 * percent;
6286 var size = Math.abs(next - prev) / 2 * percent;
6287 return {
6288 chunk: size / stackCount,
6289 ratio: options.barPercentage,
6290 start: start
6291 };
6292 }
6293 function parseFloatBar(entry, item, vScale, i) {
6294 var startValue = vScale.parse(entry[0], i);
6295 var endValue = vScale.parse(entry[1], i);
6296 var min = Math.min(startValue, endValue);
6297 var max = Math.max(startValue, endValue);
6298 var barStart = min;
6299 var barEnd = max;
6300 if (Math.abs(min) > Math.abs(max)) {
6301 barStart = max;
6302 barEnd = min;
6303 }
6304 item[vScale.axis] = barEnd;
6305 item._custom = {
6306 barStart: barStart,
6307 barEnd: barEnd,
6308 start: startValue,
6309 end: endValue,
6310 min: min,
6311 max: max
6312 };
6313 }
6314 function parseValue(entry, item, vScale, i) {
6315 if ((0, _helpersSegmentJs.b)(entry)) parseFloatBar(entry, item, vScale, i);
6316 else item[vScale.axis] = vScale.parse(entry, i);
6317 return item;
6318 }
6319 function parseArrayOrPrimitive(meta, data, start, count) {
6320 var iScale = meta.iScale;
6321 var vScale = meta.vScale;
6322 var labels = iScale.getLabels();
6323 var singleScale = iScale === vScale;
6324 var parsed = [];
6325 var i, ilen, item, entry;
6326 for(i = start, ilen = start + count; i < ilen; ++i){
6327 entry = data[i];
6328 item = {};
6329 item[iScale.axis] = singleScale || iScale.parse(labels[i], i);
6330 parsed.push(parseValue(entry, item, vScale, i));
6331 }
6332 return parsed;
6333 }
6334 function isFloatBar(custom) {
6335 return custom && custom.barStart !== undefined && custom.barEnd !== undefined;
6336 }
6337 function barSign(size, vScale, actualBase) {
6338 if (size !== 0) return (0, _helpersSegmentJs.s)(size);
6339 return (vScale.isHorizontal() ? 1 : -1) * (vScale.min >= actualBase ? 1 : -1);
6340 }
6341 function borderProps(properties) {
6342 var reverse, start, end, top, bottom;
6343 if (properties.horizontal) {
6344 reverse = properties.base > properties.x;
6345 start = "left";
6346 end = "right";
6347 } else {
6348 reverse = properties.base < properties.y;
6349 start = "bottom";
6350 end = "top";
6351 }
6352 if (reverse) {
6353 top = "end";
6354 bottom = "start";
6355 } else {
6356 top = "start";
6357 bottom = "end";
6358 }
6359 return {
6360 start: start,
6361 end: end,
6362 reverse: reverse,
6363 top: top,
6364 bottom: bottom
6365 };
6366 }
6367 function setBorderSkipped(properties, options, stack, index21) {
6368 var edge = options.borderSkipped;
6369 var res = {};
6370 if (!edge) {
6371 properties.borderSkipped = res;
6372 return;
6373 }
6374 var ref = borderProps(properties), start = ref.start, end = ref.end, reverse = ref.reverse, top = ref.top, bottom = ref.bottom;
6375 if (edge === "middle" && stack) {
6376 properties.enableBorderRadius = true;
6377 if ((stack._top || 0) === index21) edge = top;
6378 else if ((stack._bottom || 0) === index21) edge = bottom;
6379 else {
6380 res[parseEdge(bottom, start, end, reverse)] = true;
6381 edge = top;
6382 }
6383 }
6384 res[parseEdge(edge, start, end, reverse)] = true;
6385 properties.borderSkipped = res;
6386 }
6387 function parseEdge(edge, a, b, reverse) {
6388 if (reverse) {
6389 edge = swap(edge, a, b);
6390 edge = startEnd(edge, b, a);
6391 } else edge = startEnd(edge, a, b);
6392 return edge;
6393 }
6394 function swap(orig, v1, v2) {
6395 return orig === v1 ? v2 : orig === v2 ? v1 : orig;
6396 }
6397 function startEnd(v, start, end) {
6398 return v === "start" ? start : v === "end" ? end : v;
6399 }
6400 function setInflateAmount(properties, param, ratio) {
6401 var inflateAmount = param.inflateAmount;
6402 properties.inflateAmount = inflateAmount === "auto" ? ratio === 1 ? 0.33 : 0 : inflateAmount;
6403 }
6404 var BarController = /*#__PURE__*/ function(DatasetController) {
6405 "use strict";
6406 (0, _inheritsJsDefault.default)(BarController, DatasetController);
6407 var _super = (0, _createSuperJsDefault.default)(BarController);
6408 function BarController() {
6409 (0, _classCallCheckJsDefault.default)(this, BarController);
6410 return _super.apply(this, arguments);
6411 }
6412 (0, _createClassJsDefault.default)(BarController, [
6413 {
6414 key: "parsePrimitiveData",
6415 value: function parsePrimitiveData(meta, data, start, count) {
6416 return parseArrayOrPrimitive(meta, data, start, count);
6417 }
6418 },
6419 {
6420 key: "parseArrayData",
6421 value: function parseArrayData(meta, data, start, count) {
6422 return parseArrayOrPrimitive(meta, data, start, count);
6423 }
6424 },
6425 {
6426 key: "parseObjectData",
6427 value: function parseObjectData(meta, data, start, count) {
6428 var iScale = meta.iScale, vScale = meta.vScale;
6429 var __parsing = this._parsing, _xAxisKey = __parsing.xAxisKey, xAxisKey = _xAxisKey === void 0 ? "x" : _xAxisKey, _yAxisKey = __parsing.yAxisKey, yAxisKey = _yAxisKey === void 0 ? "y" : _yAxisKey;
6430 var iAxisKey = iScale.axis === "x" ? xAxisKey : yAxisKey;
6431 var vAxisKey = vScale.axis === "x" ? xAxisKey : yAxisKey;
6432 var parsed = [];
6433 var i, ilen, item, obj;
6434 for(i = start, ilen = start + count; i < ilen; ++i){
6435 obj = data[i];
6436 item = {};
6437 item[iScale.axis] = iScale.parse((0, _helpersSegmentJs.f)(obj, iAxisKey), i);
6438 parsed.push(parseValue((0, _helpersSegmentJs.f)(obj, vAxisKey), item, vScale, i));
6439 }
6440 return parsed;
6441 }
6442 },
6443 {
6444 key: "updateRangeFromParsed",
6445 value: function updateRangeFromParsed(range, scale, parsed, stack) {
6446 (0, _getJsDefault.default)((0, _getPrototypeOfJsDefault.default)(BarController.prototype), "updateRangeFromParsed", this).call(this, range, scale, parsed, stack);
6447 var custom = parsed._custom;
6448 if (custom && scale === this._cachedMeta.vScale) {
6449 range.min = Math.min(range.min, custom.min);
6450 range.max = Math.max(range.max, custom.max);
6451 }
6452 }
6453 },
6454 {
6455 key: "getMaxOverflow",
6456 value: function getMaxOverflow() {
6457 return 0;
6458 }
6459 },
6460 {
6461 key: "getLabelAndValue",
6462 value: function getLabelAndValue(index22) {
6463 var meta = this._cachedMeta;
6464 var iScale = meta.iScale, vScale = meta.vScale;
6465 var parsed = this.getParsed(index22);
6466 var custom = parsed._custom;
6467 var value = isFloatBar(custom) ? "[" + custom.start + ", " + custom.end + "]" : "" + vScale.getLabelForValue(parsed[vScale.axis]);
6468 return {
6469 label: "" + iScale.getLabelForValue(parsed[iScale.axis]),
6470 value: value
6471 };
6472 }
6473 },
6474 {
6475 key: "initialize",
6476 value: function initialize() {
6477 this.enableOptionSharing = true;
6478 (0, _getJsDefault.default)((0, _getPrototypeOfJsDefault.default)(BarController.prototype), "initialize", this).call(this);
6479 var meta = this._cachedMeta;
6480 meta.stack = this.getDataset().stack;
6481 }
6482 },
6483 {
6484 key: "update",
6485 value: function update(mode) {
6486 var meta = this._cachedMeta;
6487 this.updateElements(meta.data, 0, meta.data.length, mode);
6488 }
6489 },
6490 {
6491 key: "updateElements",
6492 value: function updateElements(bars, start, count, mode) {
6493 var reset = mode === "reset";
6494 var ref = this, index23 = ref.index, vScale = ref._cachedMeta.vScale;
6495 var base = vScale.getBasePixel();
6496 var horizontal = vScale.isHorizontal();
6497 var ruler = this._getRuler();
6498 var firstOpts = this.resolveDataElementOptions(start, mode);
6499 var sharedOptions = this.getSharedOptions(firstOpts);
6500 var includeOptions = this.includeOptions(mode, sharedOptions);
6501 this.updateSharedOptions(sharedOptions, mode, firstOpts);
6502 for(var i = start; i < start + count; i++){
6503 var parsed = this.getParsed(i);
6504 var vpixels = reset || (0, _helpersSegmentJs.k)(parsed[vScale.axis]) ? {
6505 base: base,
6506 head: base
6507 } : this._calculateBarValuePixels(i);
6508 var ipixels = this._calculateBarIndexPixels(i, ruler);
6509 var stack = (parsed._stacks || {})[vScale.axis];
6510 var properties = {
6511 horizontal: horizontal,
6512 base: vpixels.base,
6513 enableBorderRadius: !stack || isFloatBar(parsed._custom) || index23 === stack._top || index23 === stack._bottom,
6514 x: horizontal ? vpixels.head : ipixels.center,
6515 y: horizontal ? ipixels.center : vpixels.head,
6516 height: horizontal ? ipixels.size : Math.abs(vpixels.size),
6517 width: horizontal ? Math.abs(vpixels.size) : ipixels.size
6518 };
6519 if (includeOptions) properties.options = sharedOptions || this.resolveDataElementOptions(i, bars[i].active ? "active" : mode);
6520 var options = properties.options || bars[i].options;
6521 setBorderSkipped(properties, options, stack, index23);
6522 setInflateAmount(properties, options, ruler.ratio);
6523 this.updateElement(bars[i], i, properties, mode);
6524 }
6525 }
6526 },
6527 {
6528 key: "_getStacks",
6529 value: function _getStacks(last, dataIndex) {
6530 var meta = this._cachedMeta;
6531 var iScale = meta.iScale;
6532 var metasets = iScale.getMatchingVisibleMetas(this._type);
6533 var stacked = iScale.options.stacked;
6534 var ilen = metasets.length;
6535 var stacks = [];
6536 var i, item;
6537 for(i = 0; i < ilen; ++i){
6538 item = metasets[i];
6539 if (!item.controller.options.grouped) continue;
6540 if (typeof dataIndex !== "undefined") {
6541 var val = item.controller.getParsed(dataIndex)[item.controller._cachedMeta.vScale.axis];
6542 if ((0, _helpersSegmentJs.k)(val) || isNaN(val)) continue;
6543 }
6544 if (stacked === false || stacks.indexOf(item.stack) === -1 || stacked === undefined && item.stack === undefined) stacks.push(item.stack);
6545 if (item.index === last) break;
6546 }
6547 if (!stacks.length) stacks.push(undefined);
6548 return stacks;
6549 }
6550 },
6551 {
6552 key: "_getStackCount",
6553 value: function _getStackCount(index24) {
6554 return this._getStacks(undefined, index24).length;
6555 }
6556 },
6557 {
6558 key: "_getStackIndex",
6559 value: function _getStackIndex(datasetIndex, name, dataIndex) {
6560 var stacks = this._getStacks(datasetIndex, dataIndex);
6561 var index25 = name !== undefined ? stacks.indexOf(name) : -1;
6562 return index25 === -1 ? stacks.length - 1 : index25;
6563 }
6564 },
6565 {
6566 key: "_getRuler",
6567 value: function _getRuler() {
6568 var opts = this.options;
6569 var meta = this._cachedMeta;
6570 var iScale = meta.iScale;
6571 var pixels = [];
6572 var i, ilen;
6573 for(i = 0, ilen = meta.data.length; i < ilen; ++i)pixels.push(iScale.getPixelForValue(this.getParsed(i)[iScale.axis], i));
6574 var barThickness = opts.barThickness;
6575 var min = barThickness || computeMinSampleSize(meta);
6576 return {
6577 min: min,
6578 pixels: pixels,
6579 start: iScale._startPixel,
6580 end: iScale._endPixel,
6581 stackCount: this._getStackCount(),
6582 scale: iScale,
6583 grouped: opts.grouped,
6584 ratio: barThickness ? 1 : opts.categoryPercentage * opts.barPercentage
6585 };
6586 }
6587 },
6588 {
6589 key: "_calculateBarValuePixels",
6590 value: function _calculateBarValuePixels(index26) {
6591 var ref = this, __cachedMeta = ref._cachedMeta, vScale = __cachedMeta.vScale, _stacked = __cachedMeta._stacked, _options = ref.options, baseValue = _options.base, minBarLength = _options.minBarLength;
6592 var actualBase = baseValue || 0;
6593 var parsed = this.getParsed(index26);
6594 var custom = parsed._custom;
6595 var floating = isFloatBar(custom);
6596 var value = parsed[vScale.axis];
6597 var start = 0;
6598 var length = _stacked ? this.applyStack(vScale, parsed, _stacked) : value;
6599 var head, size;
6600 if (length !== value) {
6601 start = length - value;
6602 length = value;
6603 }
6604 if (floating) {
6605 value = custom.barStart;
6606 length = custom.barEnd - custom.barStart;
6607 if (value !== 0 && (0, _helpersSegmentJs.s)(value) !== (0, _helpersSegmentJs.s)(custom.barEnd)) start = 0;
6608 start += value;
6609 }
6610 var startValue = !(0, _helpersSegmentJs.k)(baseValue) && !floating ? baseValue : start;
6611 var base = vScale.getPixelForValue(startValue);
6612 if (this.chart.getDataVisibility(index26)) head = vScale.getPixelForValue(start + length);
6613 else head = base;
6614 size = head - base;
6615 if (Math.abs(size) < minBarLength) {
6616 size = barSign(size, vScale, actualBase) * minBarLength;
6617 if (value === actualBase) base -= size / 2;
6618 var startPixel = vScale.getPixelForDecimal(0);
6619 var endPixel = vScale.getPixelForDecimal(1);
6620 var min = Math.min(startPixel, endPixel);
6621 var max = Math.max(startPixel, endPixel);
6622 base = Math.max(Math.min(base, max), min);
6623 head = base + size;
6624 }
6625 if (base === vScale.getPixelForValue(actualBase)) {
6626 var halfGrid = (0, _helpersSegmentJs.s)(size) * vScale.getLineWidthForValue(actualBase) / 2;
6627 base += halfGrid;
6628 size -= halfGrid;
6629 }
6630 return {
6631 size: size,
6632 base: base,
6633 head: head,
6634 center: head + size / 2
6635 };
6636 }
6637 },
6638 {
6639 key: "_calculateBarIndexPixels",
6640 value: function _calculateBarIndexPixels(index27, ruler) {
6641 var scale = ruler.scale;
6642 var options = this.options;
6643 var skipNull = options.skipNull;
6644 var maxBarThickness = (0, _helpersSegmentJs.v)(options.maxBarThickness, Infinity);
6645 var center, size;
6646 if (ruler.grouped) {
6647 var stackCount = skipNull ? this._getStackCount(index27) : ruler.stackCount;
6648 var range = options.barThickness === "flex" ? computeFlexCategoryTraits(index27, ruler, options, stackCount) : computeFitCategoryTraits(index27, ruler, options, stackCount);
6649 var stackIndex = this._getStackIndex(this.index, this._cachedMeta.stack, skipNull ? index27 : undefined);
6650 center = range.start + range.chunk * stackIndex + range.chunk / 2;
6651 size = Math.min(maxBarThickness, range.chunk * range.ratio);
6652 } else {
6653 center = scale.getPixelForValue(this.getParsed(index27)[scale.axis], index27);
6654 size = Math.min(maxBarThickness, ruler.min * ruler.ratio);
6655 }
6656 return {
6657 base: center - size / 2,
6658 head: center + size / 2,
6659 center: center,
6660 size: size
6661 };
6662 }
6663 },
6664 {
6665 key: "draw",
6666 value: function draw2() {
6667 var meta = this._cachedMeta;
6668 var vScale = meta.vScale;
6669 var rects = meta.data;
6670 var ilen = rects.length;
6671 var i = 0;
6672 for(; i < ilen; ++i)if (this.getParsed(i)[vScale.axis] !== null) rects[i].draw(this._ctx);
6673 }
6674 }
6675 ]);
6676 return BarController;
6677 }(DatasetController);
6678 BarController.id = "bar";
6679 BarController.defaults = {
6680 datasetElementType: false,
6681 dataElementType: "bar",
6682 categoryPercentage: 0.8,
6683 barPercentage: 0.9,
6684 grouped: true,
6685 animations: {
6686 numbers: {
6687 type: "number",
6688 properties: [
6689 "x",
6690 "y",
6691 "base",
6692 "width",
6693 "height"
6694 ]
6695 }
6696 }
6697 };
6698 BarController.overrides = {
6699 scales: {
6700 _index_: {
6701 type: "category",
6702 offset: true,
6703 grid: {
6704 offset: true
6705 }
6706 },
6707 _value_: {
6708 type: "linear",
6709 beginAtZero: true
6710 }
6711 }
6712 };
6713 var BubbleController = /*#__PURE__*/ function(DatasetController) {
6714 "use strict";
6715 (0, _inheritsJsDefault.default)(BubbleController, DatasetController);
6716 var _super = (0, _createSuperJsDefault.default)(BubbleController);
6717 function BubbleController() {
6718 (0, _classCallCheckJsDefault.default)(this, BubbleController);
6719 return _super.apply(this, arguments);
6720 }
6721 (0, _createClassJsDefault.default)(BubbleController, [
6722 {
6723 key: "initialize",
6724 value: function initialize() {
6725 this.enableOptionSharing = true;
6726 (0, _getJsDefault.default)((0, _getPrototypeOfJsDefault.default)(BubbleController.prototype), "initialize", this).call(this);
6727 }
6728 },
6729 {
6730 key: "parsePrimitiveData",
6731 value: function parsePrimitiveData(meta, data, start, count) {
6732 var parsed = (0, _getJsDefault.default)((0, _getPrototypeOfJsDefault.default)(BubbleController.prototype), "parsePrimitiveData", this).call(this, meta, data, start, count);
6733 for(var i = 0; i < parsed.length; i++)parsed[i]._custom = this.resolveDataElementOptions(i + start).radius;
6734 return parsed;
6735 }
6736 },
6737 {
6738 key: "parseArrayData",
6739 value: function parseArrayData(meta, data, start, count) {
6740 var parsed = (0, _getJsDefault.default)((0, _getPrototypeOfJsDefault.default)(BubbleController.prototype), "parseArrayData", this).call(this, meta, data, start, count);
6741 for(var i = 0; i < parsed.length; i++){
6742 var item = data[start + i];
6743 parsed[i]._custom = (0, _helpersSegmentJs.v)(item[2], this.resolveDataElementOptions(i + start).radius);
6744 }
6745 return parsed;
6746 }
6747 },
6748 {
6749 key: "parseObjectData",
6750 value: function parseObjectData(meta, data, start, count) {
6751 var parsed = (0, _getJsDefault.default)((0, _getPrototypeOfJsDefault.default)(BubbleController.prototype), "parseObjectData", this).call(this, meta, data, start, count);
6752 for(var i = 0; i < parsed.length; i++){
6753 var item = data[start + i];
6754 parsed[i]._custom = (0, _helpersSegmentJs.v)(item && item.r && +item.r, this.resolveDataElementOptions(i + start).radius);
6755 }
6756 return parsed;
6757 }
6758 },
6759 {
6760 key: "getMaxOverflow",
6761 value: function getMaxOverflow() {
6762 var data = this._cachedMeta.data;
6763 var max = 0;
6764 for(var i = data.length - 1; i >= 0; --i)max = Math.max(max, data[i].size(this.resolveDataElementOptions(i)) / 2);
6765 return max > 0 && max;
6766 }
6767 },
6768 {
6769 key: "getLabelAndValue",
6770 value: function getLabelAndValue(index28) {
6771 var meta = this._cachedMeta;
6772 var xScale = meta.xScale, yScale = meta.yScale;
6773 var parsed = this.getParsed(index28);
6774 var x = xScale.getLabelForValue(parsed.x);
6775 var y = yScale.getLabelForValue(parsed.y);
6776 var r = parsed._custom;
6777 return {
6778 label: meta.label,
6779 value: "(" + x + ", " + y + (r ? ", " + r : "") + ")"
6780 };
6781 }
6782 },
6783 {
6784 key: "update",
6785 value: function update(mode) {
6786 var points = this._cachedMeta.data;
6787 this.updateElements(points, 0, points.length, mode);
6788 }
6789 },
6790 {
6791 key: "updateElements",
6792 value: function updateElements(points, start, count, mode) {
6793 var reset = mode === "reset";
6794 var __cachedMeta = this._cachedMeta, iScale = __cachedMeta.iScale, vScale = __cachedMeta.vScale;
6795 var firstOpts = this.resolveDataElementOptions(start, mode);
6796 var sharedOptions = this.getSharedOptions(firstOpts);
6797 var includeOptions = this.includeOptions(mode, sharedOptions);
6798 var iAxis = iScale.axis;
6799 var vAxis = vScale.axis;
6800 for(var i = start; i < start + count; i++){
6801 var point = points[i];
6802 var parsed = !reset && this.getParsed(i);
6803 var properties = {};
6804 var iPixel = properties[iAxis] = reset ? iScale.getPixelForDecimal(0.5) : iScale.getPixelForValue(parsed[iAxis]);
6805 var vPixel = properties[vAxis] = reset ? vScale.getBasePixel() : vScale.getPixelForValue(parsed[vAxis]);
6806 properties.skip = isNaN(iPixel) || isNaN(vPixel);
6807 if (includeOptions) {
6808 properties.options = this.resolveDataElementOptions(i, point.active ? "active" : mode);
6809 if (reset) properties.options.radius = 0;
6810 }
6811 this.updateElement(point, i, properties, mode);
6812 }
6813 this.updateSharedOptions(sharedOptions, mode, firstOpts);
6814 }
6815 },
6816 {
6817 key: "resolveDataElementOptions",
6818 value: function resolveDataElementOptions(index29, mode) {
6819 var parsed = this.getParsed(index29);
6820 var values = (0, _getJsDefault.default)((0, _getPrototypeOfJsDefault.default)(BubbleController.prototype), "resolveDataElementOptions", this).call(this, index29, mode);
6821 if (values.$shared) values = Object.assign({}, values, {
6822 $shared: false
6823 });
6824 var radius = values.radius;
6825 if (mode !== "active") values.radius = 0;
6826 values.radius += (0, _helpersSegmentJs.v)(parsed && parsed._custom, radius);
6827 return values;
6828 }
6829 }
6830 ]);
6831 return BubbleController;
6832 }(DatasetController);
6833 BubbleController.id = "bubble";
6834 BubbleController.defaults = {
6835 datasetElementType: false,
6836 dataElementType: "point",
6837 animations: {
6838 numbers: {
6839 type: "number",
6840 properties: [
6841 "x",
6842 "y",
6843 "borderWidth",
6844 "radius"
6845 ]
6846 }
6847 }
6848 };
6849 BubbleController.overrides = {
6850 scales: {
6851 x: {
6852 type: "linear"
6853 },
6854 y: {
6855 type: "linear"
6856 }
6857 },
6858 plugins: {
6859 tooltip: {
6860 callbacks: {
6861 title: function() {
6862 return "";
6863 }
6864 }
6865 }
6866 }
6867 };
6868 function getRatioAndOffset(rotation, circumference, cutout) {
6869 var ratioX = 1;
6870 var ratioY = 1;
6871 var offsetX = 0;
6872 var offsetY = 0;
6873 if (circumference < (0, _helpersSegmentJs.T)) {
6874 var startAngle = rotation;
6875 var endAngle = startAngle + circumference;
6876 var startX = Math.cos(startAngle);
6877 var startY = Math.sin(startAngle);
6878 var endX = Math.cos(endAngle);
6879 var endY = Math.sin(endAngle);
6880 var calcMax = function(angle, a, b) {
6881 return (0, _helpersSegmentJs.p)(angle, startAngle, endAngle, true) ? 1 : Math.max(a, a * cutout, b, b * cutout);
6882 };
6883 var calcMin = function(angle, a, b) {
6884 return (0, _helpersSegmentJs.p)(angle, startAngle, endAngle, true) ? -1 : Math.min(a, a * cutout, b, b * cutout);
6885 };
6886 var maxX = calcMax(0, startX, endX);
6887 var maxY = calcMax((0, _helpersSegmentJs.H), startY, endY);
6888 var minX = calcMin((0, _helpersSegmentJs.P), startX, endX);
6889 var minY = calcMin((0, _helpersSegmentJs.P) + (0, _helpersSegmentJs.H), startY, endY);
6890 ratioX = (maxX - minX) / 2;
6891 ratioY = (maxY - minY) / 2;
6892 offsetX = -(maxX + minX) / 2;
6893 offsetY = -(maxY + minY) / 2;
6894 }
6895 return {
6896 ratioX: ratioX,
6897 ratioY: ratioY,
6898 offsetX: offsetX,
6899 offsetY: offsetY
6900 };
6901 }
6902 var DoughnutController = /*#__PURE__*/ function(DatasetController) {
6903 "use strict";
6904 (0, _inheritsJsDefault.default)(DoughnutController, DatasetController);
6905 var _super = (0, _createSuperJsDefault.default)(DoughnutController);
6906 function DoughnutController(chart, datasetIndex) {
6907 (0, _classCallCheckJsDefault.default)(this, DoughnutController);
6908 var _this;
6909 _this = _super.call(this, chart, datasetIndex);
6910 _this.enableOptionSharing = true;
6911 _this.innerRadius = undefined;
6912 _this.outerRadius = undefined;
6913 _this.offsetX = undefined;
6914 _this.offsetY = undefined;
6915 return _this;
6916 }
6917 (0, _createClassJsDefault.default)(DoughnutController, [
6918 {
6919 key: "linkScales",
6920 value: function linkScales() {}
6921 },
6922 {
6923 key: "parse",
6924 value: function parse1(start, count) {
6925 var data = this.getDataset().data;
6926 var meta = this._cachedMeta;
6927 if (this._parsing === false) meta._parsed = data;
6928 else {
6929 var getter = function(i) {
6930 return +data[i];
6931 };
6932 if ((0, _helpersSegmentJs.i)(data[start])) {
6933 var __parsing = this._parsing, _key = __parsing.key, key = _key === void 0 ? "value" : _key;
6934 getter = function(i) {
6935 return +(0, _helpersSegmentJs.f)(data[i], key);
6936 };
6937 }
6938 var i1, ilen;
6939 for(i1 = start, ilen = start + count; i1 < ilen; ++i1)meta._parsed[i1] = getter(i1);
6940 }
6941 }
6942 },
6943 {
6944 key: "_getRotation",
6945 value: function _getRotation() {
6946 return (0, _helpersSegmentJs.t)(this.options.rotation - 90);
6947 }
6948 },
6949 {
6950 key: "_getCircumference",
6951 value: function _getCircumference() {
6952 return (0, _helpersSegmentJs.t)(this.options.circumference);
6953 }
6954 },
6955 {
6956 key: "_getRotationExtents",
6957 value: function _getRotationExtents() {
6958 var min = (0, _helpersSegmentJs.T);
6959 var max = -(0, _helpersSegmentJs.T);
6960 for(var i = 0; i < this.chart.data.datasets.length; ++i)if (this.chart.isDatasetVisible(i)) {
6961 var controller = this.chart.getDatasetMeta(i).controller;
6962 var rotation = controller._getRotation();
6963 var circumference = controller._getCircumference();
6964 min = Math.min(min, rotation);
6965 max = Math.max(max, rotation + circumference);
6966 }
6967 return {
6968 rotation: min,
6969 circumference: max - min
6970 };
6971 }
6972 },
6973 {
6974 key: "update",
6975 value: function update(mode) {
6976 var chart = this.chart;
6977 var chartArea = chart.chartArea;
6978 var meta = this._cachedMeta;
6979 var arcs = meta.data;
6980 var spacing = this.getMaxBorderWidth() + this.getMaxOffset(arcs) + this.options.spacing;
6981 var maxSize = Math.max((Math.min(chartArea.width, chartArea.height) - spacing) / 2, 0);
6982 var cutout = Math.min((0, _helpersSegmentJs.m)(this.options.cutout, maxSize), 1);
6983 var chartWeight = this._getRingWeight(this.index);
6984 var ref = this._getRotationExtents(), circumference = ref.circumference, rotation = ref.rotation;
6985 var ref1 = getRatioAndOffset(rotation, circumference, cutout), ratioX = ref1.ratioX, ratioY = ref1.ratioY, offsetX = ref1.offsetX, offsetY = ref1.offsetY;
6986 var maxWidth = (chartArea.width - spacing) / ratioX;
6987 var maxHeight = (chartArea.height - spacing) / ratioY;
6988 var maxRadius = Math.max(Math.min(maxWidth, maxHeight) / 2, 0);
6989 var outerRadius = (0, _helpersSegmentJs.n)(this.options.radius, maxRadius);
6990 var innerRadius = Math.max(outerRadius * cutout, 0);
6991 var radiusLength = (outerRadius - innerRadius) / this._getVisibleDatasetWeightTotal();
6992 this.offsetX = offsetX * outerRadius;
6993 this.offsetY = offsetY * outerRadius;
6994 meta.total = this.calculateTotal();
6995 this.outerRadius = outerRadius - radiusLength * this._getRingWeightOffset(this.index);
6996 this.innerRadius = Math.max(this.outerRadius - radiusLength * chartWeight, 0);
6997 this.updateElements(arcs, 0, arcs.length, mode);
6998 }
6999 },
7000 {
7001 key: "_circumference",
7002 value: function _circumference(i, reset) {
7003 var opts = this.options;
7004 var meta = this._cachedMeta;
7005 var circumference = this._getCircumference();
7006 if (reset && opts.animation.animateRotate || !this.chart.getDataVisibility(i) || meta._parsed[i] === null || meta.data[i].hidden) return 0;
7007 return this.calculateCircumference(meta._parsed[i] * circumference / (0, _helpersSegmentJs.T));
7008 }
7009 },
7010 {
7011 key: "updateElements",
7012 value: function updateElements(arcs, start, count, mode) {
7013 var reset = mode === "reset";
7014 var chart = this.chart;
7015 var chartArea = chart.chartArea;
7016 var opts = chart.options;
7017 var animationOpts = opts.animation;
7018 var centerX = (chartArea.left + chartArea.right) / 2;
7019 var centerY = (chartArea.top + chartArea.bottom) / 2;
7020 var animateScale = reset && animationOpts.animateScale;
7021 var innerRadius = animateScale ? 0 : this.innerRadius;
7022 var outerRadius = animateScale ? 0 : this.outerRadius;
7023 var firstOpts = this.resolveDataElementOptions(start, mode);
7024 var sharedOptions = this.getSharedOptions(firstOpts);
7025 var includeOptions = this.includeOptions(mode, sharedOptions);
7026 var startAngle = this._getRotation();
7027 var i;
7028 for(i = 0; i < start; ++i)startAngle += this._circumference(i, reset);
7029 for(i = start; i < start + count; ++i){
7030 var circumference = this._circumference(i, reset);
7031 var arc = arcs[i];
7032 var properties = {
7033 x: centerX + this.offsetX,
7034 y: centerY + this.offsetY,
7035 startAngle: startAngle,
7036 endAngle: startAngle + circumference,
7037 circumference: circumference,
7038 outerRadius: outerRadius,
7039 innerRadius: innerRadius
7040 };
7041 if (includeOptions) properties.options = sharedOptions || this.resolveDataElementOptions(i, arc.active ? "active" : mode);
7042 startAngle += circumference;
7043 this.updateElement(arc, i, properties, mode);
7044 }
7045 this.updateSharedOptions(sharedOptions, mode, firstOpts);
7046 }
7047 },
7048 {
7049 key: "calculateTotal",
7050 value: function calculateTotal() {
7051 var meta = this._cachedMeta;
7052 var metaData = meta.data;
7053 var total = 0;
7054 var i;
7055 for(i = 0; i < metaData.length; i++){
7056 var value = meta._parsed[i];
7057 if (value !== null && !isNaN(value) && this.chart.getDataVisibility(i) && !metaData[i].hidden) total += Math.abs(value);
7058 }
7059 return total;
7060 }
7061 },
7062 {
7063 key: "calculateCircumference",
7064 value: function calculateCircumference(value) {
7065 var total = this._cachedMeta.total;
7066 if (total > 0 && !isNaN(value)) return (0, _helpersSegmentJs.T) * (Math.abs(value) / total);
7067 return 0;
7068 }
7069 },
7070 {
7071 key: "getLabelAndValue",
7072 value: function getLabelAndValue(index30) {
7073 var meta = this._cachedMeta;
7074 var chart = this.chart;
7075 var labels = chart.data.labels || [];
7076 var value = (0, _helpersSegmentJs.o)(meta._parsed[index30], chart.options.locale);
7077 return {
7078 label: labels[index30] || "",
7079 value: value
7080 };
7081 }
7082 },
7083 {
7084 key: "getMaxBorderWidth",
7085 value: function getMaxBorderWidth(arcs) {
7086 var max = 0;
7087 var chart = this.chart;
7088 var i, ilen, meta, controller, options;
7089 if (!arcs) {
7090 for(i = 0, ilen = chart.data.datasets.length; i < ilen; ++i)if (chart.isDatasetVisible(i)) {
7091 meta = chart.getDatasetMeta(i);
7092 arcs = meta.data;
7093 controller = meta.controller;
7094 break;
7095 }
7096 }
7097 if (!arcs) return 0;
7098 for(i = 0, ilen = arcs.length; i < ilen; ++i){
7099 options = controller.resolveDataElementOptions(i);
7100 if (options.borderAlign !== "inner") max = Math.max(max, options.borderWidth || 0, options.hoverBorderWidth || 0);
7101 }
7102 return max;
7103 }
7104 },
7105 {
7106 key: "getMaxOffset",
7107 value: function getMaxOffset(arcs) {
7108 var max = 0;
7109 for(var i = 0, ilen = arcs.length; i < ilen; ++i){
7110 var options = this.resolveDataElementOptions(i);
7111 max = Math.max(max, options.offset || 0, options.hoverOffset || 0);
7112 }
7113 return max;
7114 }
7115 },
7116 {
7117 key: "_getRingWeightOffset",
7118 value: function _getRingWeightOffset(datasetIndex) {
7119 var ringWeightOffset = 0;
7120 for(var i = 0; i < datasetIndex; ++i)if (this.chart.isDatasetVisible(i)) ringWeightOffset += this._getRingWeight(i);
7121 return ringWeightOffset;
7122 }
7123 },
7124 {
7125 key: "_getRingWeight",
7126 value: function _getRingWeight(datasetIndex) {
7127 return Math.max((0, _helpersSegmentJs.v)(this.chart.data.datasets[datasetIndex].weight, 1), 0);
7128 }
7129 },
7130 {
7131 key: "_getVisibleDatasetWeightTotal",
7132 value: function _getVisibleDatasetWeightTotal() {
7133 return this._getRingWeightOffset(this.chart.data.datasets.length) || 1;
7134 }
7135 }
7136 ]);
7137 return DoughnutController;
7138 }(DatasetController);
7139 DoughnutController.id = "doughnut";
7140 DoughnutController.defaults = {
7141 datasetElementType: false,
7142 dataElementType: "arc",
7143 animation: {
7144 animateRotate: true,
7145 animateScale: false
7146 },
7147 animations: {
7148 numbers: {
7149 type: "number",
7150 properties: [
7151 "circumference",
7152 "endAngle",
7153 "innerRadius",
7154 "outerRadius",
7155 "startAngle",
7156 "x",
7157 "y",
7158 "offset",
7159 "borderWidth",
7160 "spacing"
7161 ]
7162 }
7163 },
7164 cutout: "50%",
7165 rotation: 0,
7166 circumference: 360,
7167 radius: "100%",
7168 spacing: 0,
7169 indexAxis: "r"
7170 };
7171 DoughnutController.descriptors = {
7172 _scriptable: function(name) {
7173 return name !== "spacing";
7174 },
7175 _indexable: function(name) {
7176 return name !== "spacing";
7177 }
7178 };
7179 DoughnutController.overrides = {
7180 aspectRatio: 1,
7181 plugins: {
7182 legend: {
7183 labels: {
7184 generateLabels: function(chart) {
7185 var data = chart.data;
7186 if (data.labels.length && data.datasets.length) {
7187 var _options = chart.legend.options, pointStyle = _options.labels.pointStyle;
7188 return data.labels.map(function(label, i) {
7189 var meta = chart.getDatasetMeta(0);
7190 var style = meta.controller.getStyle(i);
7191 return {
7192 text: label,
7193 fillStyle: style.backgroundColor,
7194 strokeStyle: style.borderColor,
7195 lineWidth: style.borderWidth,
7196 pointStyle: pointStyle,
7197 hidden: !chart.getDataVisibility(i),
7198 index: i
7199 };
7200 });
7201 }
7202 return [];
7203 }
7204 },
7205 onClick: function(e, legendItem, legend) {
7206 legend.chart.toggleDataVisibility(legendItem.index);
7207 legend.chart.update();
7208 }
7209 },
7210 tooltip: {
7211 callbacks: {
7212 title: function() {
7213 return "";
7214 },
7215 label: function(tooltipItem) {
7216 var dataLabel = tooltipItem.label;
7217 var value = ": " + tooltipItem.formattedValue;
7218 if ((0, _helpersSegmentJs.b)(dataLabel)) {
7219 dataLabel = dataLabel.slice();
7220 dataLabel[0] += value;
7221 } else dataLabel += value;
7222 return dataLabel;
7223 }
7224 }
7225 }
7226 }
7227 };
7228 var LineController = /*#__PURE__*/ function(DatasetController) {
7229 "use strict";
7230 (0, _inheritsJsDefault.default)(LineController, DatasetController);
7231 var _super = (0, _createSuperJsDefault.default)(LineController);
7232 function LineController() {
7233 (0, _classCallCheckJsDefault.default)(this, LineController);
7234 return _super.apply(this, arguments);
7235 }
7236 (0, _createClassJsDefault.default)(LineController, [
7237 {
7238 key: "initialize",
7239 value: function initialize() {
7240 this.enableOptionSharing = true;
7241 this.supportsDecimation = true;
7242 (0, _getJsDefault.default)((0, _getPrototypeOfJsDefault.default)(LineController.prototype), "initialize", this).call(this);
7243 }
7244 },
7245 {
7246 key: "update",
7247 value: function update(mode) {
7248 var meta = this._cachedMeta;
7249 var line = meta.dataset, tmp = meta.data, points = tmp === void 0 ? [] : tmp, _dataset = meta._dataset;
7250 var animationsDisabled = this.chart._animationsDisabled;
7251 var ref = getStartAndCountOfVisiblePoints(meta, points, animationsDisabled), start = ref.start, count = ref.count;
7252 this._drawStart = start;
7253 this._drawCount = count;
7254 if (scaleRangesChanged(meta)) {
7255 start = 0;
7256 count = points.length;
7257 }
7258 line._chart = this.chart;
7259 line._datasetIndex = this.index;
7260 line._decimated = !!_dataset._decimated;
7261 line.points = points;
7262 var options = this.resolveDatasetElementOptions(mode);
7263 if (!this.options.showLine) options.borderWidth = 0;
7264 options.segment = this.options.segment;
7265 this.updateElement(line, undefined, {
7266 animated: !animationsDisabled,
7267 options: options
7268 }, mode);
7269 this.updateElements(points, start, count, mode);
7270 }
7271 },
7272 {
7273 key: "updateElements",
7274 value: function updateElements(points, start, count, mode) {
7275 var reset = mode === "reset";
7276 var __cachedMeta = this._cachedMeta, iScale = __cachedMeta.iScale, vScale = __cachedMeta.vScale, _stacked = __cachedMeta._stacked, _dataset = __cachedMeta._dataset;
7277 var firstOpts = this.resolveDataElementOptions(start, mode);
7278 var sharedOptions = this.getSharedOptions(firstOpts);
7279 var includeOptions = this.includeOptions(mode, sharedOptions);
7280 var iAxis = iScale.axis;
7281 var vAxis = vScale.axis;
7282 var _options = this.options, spanGaps = _options.spanGaps, segment = _options.segment;
7283 var maxGapLength = (0, _helpersSegmentJs.q)(spanGaps) ? spanGaps : Number.POSITIVE_INFINITY;
7284 var directUpdate = this.chart._animationsDisabled || reset || mode === "none";
7285 var prevParsed = start > 0 && this.getParsed(start - 1);
7286 for(var i = start; i < start + count; ++i){
7287 var point = points[i];
7288 var parsed = this.getParsed(i);
7289 var properties = directUpdate ? point : {};
7290 var nullData = (0, _helpersSegmentJs.k)(parsed[vAxis]);
7291 var iPixel = properties[iAxis] = iScale.getPixelForValue(parsed[iAxis], i);
7292 var vPixel = properties[vAxis] = reset || nullData ? vScale.getBasePixel() : vScale.getPixelForValue(_stacked ? this.applyStack(vScale, parsed, _stacked) : parsed[vAxis], i);
7293 properties.skip = isNaN(iPixel) || isNaN(vPixel) || nullData;
7294 properties.stop = i > 0 && Math.abs(parsed[iAxis] - prevParsed[iAxis]) > maxGapLength;
7295 if (segment) {
7296 properties.parsed = parsed;
7297 properties.raw = _dataset.data[i];
7298 }
7299 if (includeOptions) properties.options = sharedOptions || this.resolveDataElementOptions(i, point.active ? "active" : mode);
7300 if (!directUpdate) this.updateElement(point, i, properties, mode);
7301 prevParsed = parsed;
7302 }
7303 this.updateSharedOptions(sharedOptions, mode, firstOpts);
7304 }
7305 },
7306 {
7307 key: "getMaxOverflow",
7308 value: function getMaxOverflow() {
7309 var meta = this._cachedMeta;
7310 var dataset = meta.dataset;
7311 var border = dataset.options && dataset.options.borderWidth || 0;
7312 var data = meta.data || [];
7313 if (!data.length) return border;
7314 var firstPoint = data[0].size(this.resolveDataElementOptions(0));
7315 var lastPoint = data[data.length - 1].size(this.resolveDataElementOptions(data.length - 1));
7316 return Math.max(border, firstPoint, lastPoint) / 2;
7317 }
7318 },
7319 {
7320 key: "draw",
7321 value: function draw2() {
7322 var meta = this._cachedMeta;
7323 meta.dataset.updateControlPoints(this.chart.chartArea, meta.iScale.axis);
7324 (0, _getJsDefault.default)((0, _getPrototypeOfJsDefault.default)(LineController.prototype), "draw", this).call(this);
7325 }
7326 }
7327 ]);
7328 return LineController;
7329 }(DatasetController);
7330 LineController.id = "line";
7331 LineController.defaults = {
7332 datasetElementType: "line",
7333 dataElementType: "point",
7334 showLine: true,
7335 spanGaps: false
7336 };
7337 LineController.overrides = {
7338 scales: {
7339 _index_: {
7340 type: "category"
7341 },
7342 _value_: {
7343 type: "linear"
7344 }
7345 }
7346 };
7347 function getStartAndCountOfVisiblePoints(meta, points, animationsDisabled) {
7348 var pointCount = points.length;
7349 var start = 0;
7350 var count = pointCount;
7351 if (meta._sorted) {
7352 var iScale = meta.iScale, _parsed = meta._parsed;
7353 var axis = iScale.axis;
7354 var ref = iScale.getUserBounds(), min = ref.min, max = ref.max, minDefined = ref.minDefined, maxDefined = ref.maxDefined;
7355 if (minDefined) start = (0, _helpersSegmentJs.w)(Math.min((0, _helpersSegmentJs.x)(_parsed, iScale.axis, min).lo, animationsDisabled ? pointCount : (0, _helpersSegmentJs.x)(points, axis, iScale.getPixelForValue(min)).lo), 0, pointCount - 1);
7356 if (maxDefined) count = (0, _helpersSegmentJs.w)(Math.max((0, _helpersSegmentJs.x)(_parsed, iScale.axis, max).hi + 1, animationsDisabled ? 0 : (0, _helpersSegmentJs.x)(points, axis, iScale.getPixelForValue(max)).hi + 1), start, pointCount) - start;
7357 else count = pointCount - start;
7358 }
7359 return {
7360 start: start,
7361 count: count
7362 };
7363 }
7364 function scaleRangesChanged(meta) {
7365 var xScale = meta.xScale, yScale = meta.yScale, _scaleRanges = meta._scaleRanges;
7366 var newRanges = {
7367 xmin: xScale.min,
7368 xmax: xScale.max,
7369 ymin: yScale.min,
7370 ymax: yScale.max
7371 };
7372 if (!_scaleRanges) {
7373 meta._scaleRanges = newRanges;
7374 return true;
7375 }
7376 var changed = _scaleRanges.xmin !== xScale.min || _scaleRanges.xmax !== xScale.max || _scaleRanges.ymin !== yScale.min || _scaleRanges.ymax !== yScale.max;
7377 Object.assign(_scaleRanges, newRanges);
7378 return changed;
7379 }
7380 var PolarAreaController = /*#__PURE__*/ function(DatasetController) {
7381 "use strict";
7382 (0, _inheritsJsDefault.default)(PolarAreaController, DatasetController);
7383 var _super = (0, _createSuperJsDefault.default)(PolarAreaController);
7384 function PolarAreaController(chart, datasetIndex) {
7385 (0, _classCallCheckJsDefault.default)(this, PolarAreaController);
7386 var _this;
7387 _this = _super.call(this, chart, datasetIndex);
7388 _this.innerRadius = undefined;
7389 _this.outerRadius = undefined;
7390 return _this;
7391 }
7392 (0, _createClassJsDefault.default)(PolarAreaController, [
7393 {
7394 key: "getLabelAndValue",
7395 value: function getLabelAndValue(index31) {
7396 var meta = this._cachedMeta;
7397 var chart = this.chart;
7398 var labels = chart.data.labels || [];
7399 var value = (0, _helpersSegmentJs.o)(meta._parsed[index31].r, chart.options.locale);
7400 return {
7401 label: labels[index31] || "",
7402 value: value
7403 };
7404 }
7405 },
7406 {
7407 key: "parseObjectData",
7408 value: function parseObjectData(meta, data, start, count) {
7409 return (0, _helpersSegmentJs.y).bind(this)(meta, data, start, count);
7410 }
7411 },
7412 {
7413 key: "update",
7414 value: function update(mode) {
7415 var arcs = this._cachedMeta.data;
7416 this._updateRadius();
7417 this.updateElements(arcs, 0, arcs.length, mode);
7418 }
7419 },
7420 {
7421 key: "getMinMax",
7422 value: function getMinMax() {
7423 var _this = this;
7424 var meta = this._cachedMeta;
7425 var range = {
7426 min: Number.POSITIVE_INFINITY,
7427 max: Number.NEGATIVE_INFINITY
7428 };
7429 meta.data.forEach(function(element, index32) {
7430 var parsed = _this.getParsed(index32).r;
7431 if (!isNaN(parsed) && _this.chart.getDataVisibility(index32)) {
7432 if (parsed < range.min) range.min = parsed;
7433 if (parsed > range.max) range.max = parsed;
7434 }
7435 });
7436 return range;
7437 }
7438 },
7439 {
7440 key: "_updateRadius",
7441 value: function _updateRadius() {
7442 var chart = this.chart;
7443 var chartArea = chart.chartArea;
7444 var opts = chart.options;
7445 var minSize = Math.min(chartArea.right - chartArea.left, chartArea.bottom - chartArea.top);
7446 var outerRadius = Math.max(minSize / 2, 0);
7447 var innerRadius = Math.max(opts.cutoutPercentage ? outerRadius / 100 * opts.cutoutPercentage : 1, 0);
7448 var radiusLength = (outerRadius - innerRadius) / chart.getVisibleDatasetCount();
7449 this.outerRadius = outerRadius - radiusLength * this.index;
7450 this.innerRadius = this.outerRadius - radiusLength;
7451 }
7452 },
7453 {
7454 key: "updateElements",
7455 value: function updateElements(arcs, start, count, mode) {
7456 var reset = mode === "reset";
7457 var chart = this.chart;
7458 var opts = chart.options;
7459 var animationOpts = opts.animation;
7460 var scale = this._cachedMeta.rScale;
7461 var centerX = scale.xCenter;
7462 var centerY = scale.yCenter;
7463 var datasetStartAngle = scale.getIndexAngle(0) - 0.5 * (0, _helpersSegmentJs.P);
7464 var angle = datasetStartAngle;
7465 var i;
7466 var defaultAngle = 360 / this.countVisibleElements();
7467 for(i = 0; i < start; ++i)angle += this._computeAngle(i, mode, defaultAngle);
7468 for(i = start; i < start + count; i++){
7469 var arc = arcs[i];
7470 var startAngle = angle;
7471 var endAngle = angle + this._computeAngle(i, mode, defaultAngle);
7472 var outerRadius = chart.getDataVisibility(i) ? scale.getDistanceFromCenterForValue(this.getParsed(i).r) : 0;
7473 angle = endAngle;
7474 if (reset) {
7475 if (animationOpts.animateScale) outerRadius = 0;
7476 if (animationOpts.animateRotate) startAngle = endAngle = datasetStartAngle;
7477 }
7478 var properties = {
7479 x: centerX,
7480 y: centerY,
7481 innerRadius: 0,
7482 outerRadius: outerRadius,
7483 startAngle: startAngle,
7484 endAngle: endAngle,
7485 options: this.resolveDataElementOptions(i, arc.active ? "active" : mode)
7486 };
7487 this.updateElement(arc, i, properties, mode);
7488 }
7489 }
7490 },
7491 {
7492 key: "countVisibleElements",
7493 value: function countVisibleElements() {
7494 var _this = this;
7495 var meta = this._cachedMeta;
7496 var count = 0;
7497 meta.data.forEach(function(element, index33) {
7498 if (!isNaN(_this.getParsed(index33).r) && _this.chart.getDataVisibility(index33)) count++;
7499 });
7500 return count;
7501 }
7502 },
7503 {
7504 key: "_computeAngle",
7505 value: function _computeAngle(index34, mode, defaultAngle) {
7506 return this.chart.getDataVisibility(index34) ? (0, _helpersSegmentJs.t)(this.resolveDataElementOptions(index34, mode).angle || defaultAngle) : 0;
7507 }
7508 }
7509 ]);
7510 return PolarAreaController;
7511 }(DatasetController);
7512 PolarAreaController.id = "polarArea";
7513 PolarAreaController.defaults = {
7514 dataElementType: "arc",
7515 animation: {
7516 animateRotate: true,
7517 animateScale: true
7518 },
7519 animations: {
7520 numbers: {
7521 type: "number",
7522 properties: [
7523 "x",
7524 "y",
7525 "startAngle",
7526 "endAngle",
7527 "innerRadius",
7528 "outerRadius"
7529 ]
7530 }
7531 },
7532 indexAxis: "r",
7533 startAngle: 0
7534 };
7535 PolarAreaController.overrides = {
7536 aspectRatio: 1,
7537 plugins: {
7538 legend: {
7539 labels: {
7540 generateLabels: function(chart) {
7541 var data = chart.data;
7542 if (data.labels.length && data.datasets.length) {
7543 var _options = chart.legend.options, pointStyle = _options.labels.pointStyle;
7544 return data.labels.map(function(label, i) {
7545 var meta = chart.getDatasetMeta(0);
7546 var style = meta.controller.getStyle(i);
7547 return {
7548 text: label,
7549 fillStyle: style.backgroundColor,
7550 strokeStyle: style.borderColor,
7551 lineWidth: style.borderWidth,
7552 pointStyle: pointStyle,
7553 hidden: !chart.getDataVisibility(i),
7554 index: i
7555 };
7556 });
7557 }
7558 return [];
7559 }
7560 },
7561 onClick: function(e, legendItem, legend) {
7562 legend.chart.toggleDataVisibility(legendItem.index);
7563 legend.chart.update();
7564 }
7565 },
7566 tooltip: {
7567 callbacks: {
7568 title: function() {
7569 return "";
7570 },
7571 label: function(context) {
7572 return context.chart.data.labels[context.dataIndex] + ": " + context.formattedValue;
7573 }
7574 }
7575 }
7576 },
7577 scales: {
7578 r: {
7579 type: "radialLinear",
7580 angleLines: {
7581 display: false
7582 },
7583 beginAtZero: true,
7584 grid: {
7585 circular: true
7586 },
7587 pointLabels: {
7588 display: false
7589 },
7590 startAngle: 0
7591 }
7592 }
7593 };
7594 var PieController = /*#__PURE__*/ function(DoughnutController) {
7595 "use strict";
7596 (0, _inheritsJsDefault.default)(PieController, DoughnutController);
7597 var _super = (0, _createSuperJsDefault.default)(PieController);
7598 function PieController() {
7599 (0, _classCallCheckJsDefault.default)(this, PieController);
7600 return _super.apply(this, arguments);
7601 }
7602 return PieController;
7603 }(DoughnutController);
7604 PieController.id = "pie";
7605 PieController.defaults = {
7606 cutout: 0,
7607 rotation: 0,
7608 circumference: 360,
7609 radius: "100%"
7610 };
7611 var RadarController = /*#__PURE__*/ function(DatasetController) {
7612 "use strict";
7613 (0, _inheritsJsDefault.default)(RadarController, DatasetController);
7614 var _super = (0, _createSuperJsDefault.default)(RadarController);
7615 function RadarController() {
7616 (0, _classCallCheckJsDefault.default)(this, RadarController);
7617 return _super.apply(this, arguments);
7618 }
7619 (0, _createClassJsDefault.default)(RadarController, [
7620 {
7621 key: "getLabelAndValue",
7622 value: function getLabelAndValue(index35) {
7623 var vScale = this._cachedMeta.vScale;
7624 var parsed = this.getParsed(index35);
7625 return {
7626 label: vScale.getLabels()[index35],
7627 value: "" + vScale.getLabelForValue(parsed[vScale.axis])
7628 };
7629 }
7630 },
7631 {
7632 key: "parseObjectData",
7633 value: function parseObjectData(meta, data, start, count) {
7634 return (0, _helpersSegmentJs.y).bind(this)(meta, data, start, count);
7635 }
7636 },
7637 {
7638 key: "update",
7639 value: function update(mode) {
7640 var meta = this._cachedMeta;
7641 var line = meta.dataset;
7642 var points = meta.data || [];
7643 var labels = meta.iScale.getLabels();
7644 line.points = points;
7645 if (mode !== "resize") {
7646 var options = this.resolveDatasetElementOptions(mode);
7647 if (!this.options.showLine) options.borderWidth = 0;
7648 var properties = {
7649 _loop: true,
7650 _fullLoop: labels.length === points.length,
7651 options: options
7652 };
7653 this.updateElement(line, undefined, properties, mode);
7654 }
7655 this.updateElements(points, 0, points.length, mode);
7656 }
7657 },
7658 {
7659 key: "updateElements",
7660 value: function updateElements(points, start, count, mode) {
7661 var scale = this._cachedMeta.rScale;
7662 var reset = mode === "reset";
7663 for(var i = start; i < start + count; i++){
7664 var point = points[i];
7665 var options = this.resolveDataElementOptions(i, point.active ? "active" : mode);
7666 var pointPosition = scale.getPointPositionForValue(i, this.getParsed(i).r);
7667 var x = reset ? scale.xCenter : pointPosition.x;
7668 var y = reset ? scale.yCenter : pointPosition.y;
7669 var properties = {
7670 x: x,
7671 y: y,
7672 angle: pointPosition.angle,
7673 skip: isNaN(x) || isNaN(y),
7674 options: options
7675 };
7676 this.updateElement(point, i, properties, mode);
7677 }
7678 }
7679 }
7680 ]);
7681 return RadarController;
7682 }(DatasetController);
7683 RadarController.id = "radar";
7684 RadarController.defaults = {
7685 datasetElementType: "line",
7686 dataElementType: "point",
7687 indexAxis: "r",
7688 showLine: true,
7689 elements: {
7690 line: {
7691 fill: "start"
7692 }
7693 }
7694 };
7695 RadarController.overrides = {
7696 aspectRatio: 1,
7697 scales: {
7698 r: {
7699 type: "radialLinear"
7700 }
7701 }
7702 };
7703 var ScatterController = /*#__PURE__*/ function(LineController) {
7704 "use strict";
7705 (0, _inheritsJsDefault.default)(ScatterController, LineController);
7706 var _super = (0, _createSuperJsDefault.default)(ScatterController);
7707 function ScatterController() {
7708 (0, _classCallCheckJsDefault.default)(this, ScatterController);
7709 return _super.apply(this, arguments);
7710 }
7711 return ScatterController;
7712 }(LineController);
7713 ScatterController.id = "scatter";
7714 ScatterController.defaults = {
7715 showLine: false,
7716 fill: false
7717 };
7718 ScatterController.overrides = {
7719 interaction: {
7720 mode: "point"
7721 },
7722 plugins: {
7723 tooltip: {
7724 callbacks: {
7725 title: function() {
7726 return "";
7727 },
7728 label: function(item) {
7729 return "(" + item.label + ", " + item.formattedValue + ")";
7730 }
7731 }
7732 }
7733 },
7734 scales: {
7735 x: {
7736 type: "linear"
7737 },
7738 y: {
7739 type: "linear"
7740 }
7741 }
7742 };
7743 var controllers = /*#__PURE__*/ Object.freeze({
7744 __proto__: null,
7745 BarController: BarController,
7746 BubbleController: BubbleController,
7747 DoughnutController: DoughnutController,
7748 LineController: LineController,
7749 PolarAreaController: PolarAreaController,
7750 PieController: PieController,
7751 RadarController: RadarController,
7752 ScatterController: ScatterController
7753 });
7754 function abstract() {
7755 throw new Error("This method is not implemented: Check that a complete date adapter is provided.");
7756 }
7757 var DateAdapter = /*#__PURE__*/ function() {
7758 "use strict";
7759 function DateAdapter(options) {
7760 (0, _classCallCheckJsDefault.default)(this, DateAdapter);
7761 this.options = options || {};
7762 }
7763 (0, _createClassJsDefault.default)(DateAdapter, [
7764 {
7765 key: "formats",
7766 value: function formats() {
7767 return abstract();
7768 }
7769 },
7770 {
7771 key: "parse",
7772 value: function parse1(value, format) {
7773 return abstract();
7774 }
7775 },
7776 {
7777 key: "format",
7778 value: function format1(timestamp, format) {
7779 return abstract();
7780 }
7781 },
7782 {
7783 key: "add",
7784 value: function add(timestamp, amount, unit) {
7785 return abstract();
7786 }
7787 },
7788 {
7789 key: "diff",
7790 value: function diff(a, b, unit) {
7791 return abstract();
7792 }
7793 },
7794 {
7795 key: "startOf",
7796 value: function startOf(timestamp, unit, weekday) {
7797 return abstract();
7798 }
7799 },
7800 {
7801 key: "endOf",
7802 value: function endOf(timestamp, unit) {
7803 return abstract();
7804 }
7805 }
7806 ]);
7807 return DateAdapter;
7808 }();
7809 DateAdapter.override = function(members) {
7810 Object.assign(DateAdapter.prototype, members);
7811 };
7812 var adapters = {
7813 _date: DateAdapter
7814 };
7815 function binarySearch(metaset, axis, value, intersect) {
7816 var controller = metaset.controller, data = metaset.data, _sorted = metaset._sorted;
7817 var iScale = controller._cachedMeta.iScale;
7818 if (iScale && axis === iScale.axis && axis !== "r" && _sorted && data.length) {
7819 var lookupMethod = iScale._reversePixels ? (0, _helpersSegmentJs.A) : (0, _helpersSegmentJs.x);
7820 if (!intersect) return lookupMethod(data, axis, value);
7821 else if (controller._sharedOptions) {
7822 var el = data[0];
7823 var range = typeof el.getRange === "function" && el.getRange(axis);
7824 if (range) {
7825 var start = lookupMethod(data, axis, value - range);
7826 var end = lookupMethod(data, axis, value + range);
7827 return {
7828 lo: start.lo,
7829 hi: end.hi
7830 };
7831 }
7832 }
7833 }
7834 return {
7835 lo: 0,
7836 hi: data.length - 1
7837 };
7838 }
7839 function evaluateInteractionItems(chart, axis, position, handler, intersect) {
7840 var metasets = chart.getSortedVisibleDatasetMetas();
7841 var value = position[axis];
7842 for(var i = 0, ilen = metasets.length; i < ilen; ++i){
7843 var _i = metasets[i], index36 = _i.index, data = _i.data;
7844 var ref = binarySearch(metasets[i], axis, value, intersect), lo = ref.lo, hi = ref.hi;
7845 for(var j = lo; j <= hi; ++j){
7846 var element = data[j];
7847 if (!element.skip) handler(element, index36, j);
7848 }
7849 }
7850 }
7851 function getDistanceMetricForAxis(axis) {
7852 var useX = axis.indexOf("x") !== -1;
7853 var useY = axis.indexOf("y") !== -1;
7854 return function(pt1, pt2) {
7855 var deltaX = useX ? Math.abs(pt1.x - pt2.x) : 0;
7856 var deltaY = useY ? Math.abs(pt1.y - pt2.y) : 0;
7857 return Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2));
7858 };
7859 }
7860 function getIntersectItems(chart, position, axis, useFinalPosition, includeInvisible) {
7861 var items = [];
7862 if (!includeInvisible && !chart.isPointInArea(position)) return items;
7863 var evaluationFunc = function evaluationFunc(element, datasetIndex, index37) {
7864 if (!includeInvisible && !(0, _helpersSegmentJs.B)(element, chart.chartArea, 0)) return;
7865 if (element.inRange(position.x, position.y, useFinalPosition)) items.push({
7866 element: element,
7867 datasetIndex: datasetIndex,
7868 index: index37
7869 });
7870 };
7871 evaluateInteractionItems(chart, axis, position, evaluationFunc, true);
7872 return items;
7873 }
7874 function getNearestRadialItems(chart, position, axis, useFinalPosition) {
7875 var evaluationFunc = function evaluationFunc(element, datasetIndex, index38) {
7876 var ref = element.getProps([
7877 "startAngle",
7878 "endAngle"
7879 ], useFinalPosition), startAngle = ref.startAngle, endAngle = ref.endAngle;
7880 var angle = (0, _helpersSegmentJs.C)(element, {
7881 x: position.x,
7882 y: position.y
7883 }).angle;
7884 if ((0, _helpersSegmentJs.p)(angle, startAngle, endAngle)) items.push({
7885 element: element,
7886 datasetIndex: datasetIndex,
7887 index: index38
7888 });
7889 };
7890 var items = [];
7891 evaluateInteractionItems(chart, axis, position, evaluationFunc);
7892 return items;
7893 }
7894 function getNearestCartesianItems(chart, position, axis, intersect, useFinalPosition, includeInvisible) {
7895 var evaluationFunc = function evaluationFunc(element, datasetIndex, index39) {
7896 var inRange1 = element.inRange(position.x, position.y, useFinalPosition);
7897 if (intersect && !inRange1) return;
7898 var center = element.getCenterPoint(useFinalPosition);
7899 var pointInArea = !!includeInvisible || chart.isPointInArea(center);
7900 if (!pointInArea && !inRange1) return;
7901 var distance = distanceMetric(position, center);
7902 if (distance < minDistance) {
7903 items = [
7904 {
7905 element: element,
7906 datasetIndex: datasetIndex,
7907 index: index39
7908 }
7909 ];
7910 minDistance = distance;
7911 } else if (distance === minDistance) items.push({
7912 element: element,
7913 datasetIndex: datasetIndex,
7914 index: index39
7915 });
7916 };
7917 var items = [];
7918 var distanceMetric = getDistanceMetricForAxis(axis);
7919 var minDistance = Number.POSITIVE_INFINITY;
7920 evaluateInteractionItems(chart, axis, position, evaluationFunc);
7921 return items;
7922 }
7923 function getNearestItems(chart, position, axis, intersect, useFinalPosition, includeInvisible) {
7924 if (!includeInvisible && !chart.isPointInArea(position)) return [];
7925 return axis === "r" && !intersect ? getNearestRadialItems(chart, position, axis, useFinalPosition) : getNearestCartesianItems(chart, position, axis, intersect, useFinalPosition, includeInvisible);
7926 }
7927 function getAxisItems(chart, position, axis, intersect, useFinalPosition) {
7928 var items = [];
7929 var rangeMethod = axis === "x" ? "inXRange" : "inYRange";
7930 var intersectsItem = false;
7931 evaluateInteractionItems(chart, axis, position, function(element, datasetIndex, index40) {
7932 if (element[rangeMethod](position[axis], useFinalPosition)) {
7933 items.push({
7934 element: element,
7935 datasetIndex: datasetIndex,
7936 index: index40
7937 });
7938 intersectsItem = intersectsItem || element.inRange(position.x, position.y, useFinalPosition);
7939 }
7940 });
7941 if (intersect && !intersectsItem) return [];
7942 return items;
7943 }
7944 var Interaction = {
7945 evaluateInteractionItems: evaluateInteractionItems,
7946 modes: {
7947 index: function(chart, e, options, useFinalPosition) {
7948 var position = (0, _helpersSegmentJs.z)(e, chart);
7949 var axis = options.axis || "x";
7950 var includeInvisible = options.includeInvisible || false;
7951 var items = options.intersect ? getIntersectItems(chart, position, axis, useFinalPosition, includeInvisible) : getNearestItems(chart, position, axis, false, useFinalPosition, includeInvisible);
7952 var elements3 = [];
7953 if (!items.length) return [];
7954 chart.getSortedVisibleDatasetMetas().forEach(function(meta) {
7955 var index41 = items[0].index;
7956 var element = meta.data[index41];
7957 if (element && !element.skip) elements3.push({
7958 element: element,
7959 datasetIndex: meta.index,
7960 index: index41
7961 });
7962 });
7963 return elements3;
7964 },
7965 dataset: function(chart, e, options, useFinalPosition) {
7966 var position = (0, _helpersSegmentJs.z)(e, chart);
7967 var axis = options.axis || "xy";
7968 var includeInvisible = options.includeInvisible || false;
7969 var items = options.intersect ? getIntersectItems(chart, position, axis, useFinalPosition, includeInvisible) : getNearestItems(chart, position, axis, false, useFinalPosition, includeInvisible);
7970 if (items.length > 0) {
7971 var datasetIndex = items[0].datasetIndex;
7972 var data = chart.getDatasetMeta(datasetIndex).data;
7973 items = [];
7974 for(var i = 0; i < data.length; ++i)items.push({
7975 element: data[i],
7976 datasetIndex: datasetIndex,
7977 index: i
7978 });
7979 }
7980 return items;
7981 },
7982 point: function(chart, e, options, useFinalPosition) {
7983 var position = (0, _helpersSegmentJs.z)(e, chart);
7984 var axis = options.axis || "xy";
7985 var includeInvisible = options.includeInvisible || false;
7986 return getIntersectItems(chart, position, axis, useFinalPosition, includeInvisible);
7987 },
7988 nearest: function(chart, e, options, useFinalPosition) {
7989 var position = (0, _helpersSegmentJs.z)(e, chart);
7990 var axis = options.axis || "xy";
7991 var includeInvisible = options.includeInvisible || false;
7992 return getNearestItems(chart, position, axis, options.intersect, useFinalPosition, includeInvisible);
7993 },
7994 x: function(chart, e, options, useFinalPosition) {
7995 var position = (0, _helpersSegmentJs.z)(e, chart);
7996 return getAxisItems(chart, position, "x", options.intersect, useFinalPosition);
7997 },
7998 y: function(chart, e, options, useFinalPosition) {
7999 var position = (0, _helpersSegmentJs.z)(e, chart);
8000 return getAxisItems(chart, position, "y", options.intersect, useFinalPosition);
8001 }
8002 }
8003 };
8004 var STATIC_POSITIONS = [
8005 "left",
8006 "top",
8007 "right",
8008 "bottom"
8009 ];
8010 function filterByPosition(array, position) {
8011 return array.filter(function(v) {
8012 return v.pos === position;
8013 });
8014 }
8015 function filterDynamicPositionByAxis(array, axis) {
8016 return array.filter(function(v) {
8017 return STATIC_POSITIONS.indexOf(v.pos) === -1 && v.box.axis === axis;
8018 });
8019 }
8020 function sortByWeight(array, reverse) {
8021 return array.sort(function(a, b) {
8022 var v0 = reverse ? b : a;
8023 var v1 = reverse ? a : b;
8024 return v0.weight === v1.weight ? v0.index - v1.index : v0.weight - v1.weight;
8025 });
8026 }
8027 function wrapBoxes(boxes) {
8028 var layoutBoxes = [];
8029 var i, ilen, box, pos, stack, stackWeight;
8030 for(i = 0, ilen = (boxes || []).length; i < ilen; ++i){
8031 box = boxes[i];
8032 var ref, ref2, ref3;
8033 ref = box, pos = ref.position, ref2 = ref.options, stack = ref2.stack, ref3 = ref2.stackWeight, stackWeight = ref3 === void 0 ? 1 : ref3, ref2, ref;
8034 layoutBoxes.push({
8035 index: i,
8036 box: box,
8037 pos: pos,
8038 horizontal: box.isHorizontal(),
8039 weight: box.weight,
8040 stack: stack && pos + stack,
8041 stackWeight: stackWeight
8042 });
8043 }
8044 return layoutBoxes;
8045 }
8046 function buildStacks(layouts1) {
8047 var stacks = {};
8048 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
8049 try {
8050 for(var _iterator = layouts1[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
8051 var wrap = _step.value;
8052 var stack = wrap.stack, pos = wrap.pos, stackWeight = wrap.stackWeight;
8053 if (!stack || !STATIC_POSITIONS.includes(pos)) continue;
8054 var _stack = stacks[stack] || (stacks[stack] = {
8055 count: 0,
8056 placed: 0,
8057 weight: 0,
8058 size: 0
8059 });
8060 _stack.count++;
8061 _stack.weight += stackWeight;
8062 }
8063 } catch (err) {
8064 _didIteratorError = true;
8065 _iteratorError = err;
8066 } finally{
8067 try {
8068 if (!_iteratorNormalCompletion && _iterator.return != null) {
8069 _iterator.return();
8070 }
8071 } finally{
8072 if (_didIteratorError) {
8073 throw _iteratorError;
8074 }
8075 }
8076 }
8077 return stacks;
8078 }
8079 function setLayoutDims(layouts2, params) {
8080 var stacks = buildStacks(layouts2);
8081 var vBoxMaxWidth = params.vBoxMaxWidth, hBoxMaxHeight = params.hBoxMaxHeight;
8082 var i, ilen, layout;
8083 for(i = 0, ilen = layouts2.length; i < ilen; ++i){
8084 layout = layouts2[i];
8085 var fullSize = layout.box.fullSize;
8086 var stack = stacks[layout.stack];
8087 var factor = stack && layout.stackWeight / stack.weight;
8088 if (layout.horizontal) {
8089 layout.width = factor ? factor * vBoxMaxWidth : fullSize && params.availableWidth;
8090 layout.height = hBoxMaxHeight;
8091 } else {
8092 layout.width = vBoxMaxWidth;
8093 layout.height = factor ? factor * hBoxMaxHeight : fullSize && params.availableHeight;
8094 }
8095 }
8096 return stacks;
8097 }
8098 function buildLayoutBoxes(boxes) {
8099 var layoutBoxes = wrapBoxes(boxes);
8100 var fullSize = sortByWeight(layoutBoxes.filter(function(wrap) {
8101 return wrap.box.fullSize;
8102 }), true);
8103 var left = sortByWeight(filterByPosition(layoutBoxes, "left"), true);
8104 var right = sortByWeight(filterByPosition(layoutBoxes, "right"));
8105 var top = sortByWeight(filterByPosition(layoutBoxes, "top"), true);
8106 var bottom = sortByWeight(filterByPosition(layoutBoxes, "bottom"));
8107 var centerHorizontal = filterDynamicPositionByAxis(layoutBoxes, "x");
8108 var centerVertical = filterDynamicPositionByAxis(layoutBoxes, "y");
8109 return {
8110 fullSize: fullSize,
8111 leftAndTop: left.concat(top),
8112 rightAndBottom: right.concat(centerVertical).concat(bottom).concat(centerHorizontal),
8113 chartArea: filterByPosition(layoutBoxes, "chartArea"),
8114 vertical: left.concat(right).concat(centerVertical),
8115 horizontal: top.concat(bottom).concat(centerHorizontal)
8116 };
8117 }
8118 function getCombinedMax(maxPadding, chartArea, a, b) {
8119 return Math.max(maxPadding[a], chartArea[a]) + Math.max(maxPadding[b], chartArea[b]);
8120 }
8121 function updateMaxPadding(maxPadding, boxPadding) {
8122 maxPadding.top = Math.max(maxPadding.top, boxPadding.top);
8123 maxPadding.left = Math.max(maxPadding.left, boxPadding.left);
8124 maxPadding.bottom = Math.max(maxPadding.bottom, boxPadding.bottom);
8125 maxPadding.right = Math.max(maxPadding.right, boxPadding.right);
8126 }
8127 function updateDims(chartArea, params, layout, stacks) {
8128 var pos = layout.pos, box = layout.box;
8129 var maxPadding = chartArea.maxPadding;
8130 if (!(0, _helpersSegmentJs.i)(pos)) {
8131 if (layout.size) chartArea[pos] -= layout.size;
8132 var stack = stacks[layout.stack] || {
8133 size: 0,
8134 count: 1
8135 };
8136 stack.size = Math.max(stack.size, layout.horizontal ? box.height : box.width);
8137 layout.size = stack.size / stack.count;
8138 chartArea[pos] += layout.size;
8139 }
8140 if (box.getPadding) updateMaxPadding(maxPadding, box.getPadding());
8141 var newWidth = Math.max(0, params.outerWidth - getCombinedMax(maxPadding, chartArea, "left", "right"));
8142 var newHeight = Math.max(0, params.outerHeight - getCombinedMax(maxPadding, chartArea, "top", "bottom"));
8143 var widthChanged = newWidth !== chartArea.w;
8144 var heightChanged = newHeight !== chartArea.h;
8145 chartArea.w = newWidth;
8146 chartArea.h = newHeight;
8147 return layout.horizontal ? {
8148 same: widthChanged,
8149 other: heightChanged
8150 } : {
8151 same: heightChanged,
8152 other: widthChanged
8153 };
8154 }
8155 function handleMaxPadding(chartArea) {
8156 var updatePos = function updatePos(pos) {
8157 var change = Math.max(maxPadding[pos] - chartArea[pos], 0);
8158 chartArea[pos] += change;
8159 return change;
8160 };
8161 var maxPadding = chartArea.maxPadding;
8162 chartArea.y += updatePos("top");
8163 chartArea.x += updatePos("left");
8164 updatePos("right");
8165 updatePos("bottom");
8166 }
8167 function getMargins(horizontal, chartArea) {
8168 var marginForPositions = function marginForPositions(positions) {
8169 var margin = {
8170 left: 0,
8171 top: 0,
8172 right: 0,
8173 bottom: 0
8174 };
8175 positions.forEach(function(pos) {
8176 margin[pos] = Math.max(chartArea[pos], maxPadding[pos]);
8177 });
8178 return margin;
8179 };
8180 var maxPadding = chartArea.maxPadding;
8181 return horizontal ? marginForPositions([
8182 "left",
8183 "right"
8184 ]) : marginForPositions([
8185 "top",
8186 "bottom"
8187 ]);
8188 }
8189 function fitBoxes(boxes, chartArea, params, stacks) {
8190 var refitBoxes = [];
8191 var i, ilen, layout, box, refit, changed;
8192 for(i = 0, ilen = boxes.length, refit = 0; i < ilen; ++i){
8193 layout = boxes[i];
8194 box = layout.box;
8195 box.update(layout.width || chartArea.w, layout.height || chartArea.h, getMargins(layout.horizontal, chartArea));
8196 var ref = updateDims(chartArea, params, layout, stacks), same = ref.same, other = ref.other;
8197 refit |= same && refitBoxes.length;
8198 changed = changed || other;
8199 if (!box.fullSize) refitBoxes.push(layout);
8200 }
8201 return refit && fitBoxes(refitBoxes, chartArea, params, stacks) || changed;
8202 }
8203 function setBoxDims(box, left, top, width, height) {
8204 box.top = top;
8205 box.left = left;
8206 box.right = left + width;
8207 box.bottom = top + height;
8208 box.width = width;
8209 box.height = height;
8210 }
8211 function placeBoxes(boxes, chartArea, params, stacks) {
8212 var userPadding = params.padding;
8213 var x = chartArea.x, y = chartArea.y;
8214 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
8215 try {
8216 for(var _iterator = boxes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
8217 var layout = _step.value;
8218 var box = layout.box;
8219 var stack = stacks[layout.stack] || {
8220 count: 1,
8221 placed: 0,
8222 weight: 1
8223 };
8224 var weight = layout.stackWeight / stack.weight || 1;
8225 if (layout.horizontal) {
8226 var width = chartArea.w * weight;
8227 var height = stack.size || box.height;
8228 if ((0, _helpersSegmentJs.j)(stack.start)) y = stack.start;
8229 if (box.fullSize) setBoxDims(box, userPadding.left, y, params.outerWidth - userPadding.right - userPadding.left, height);
8230 else setBoxDims(box, chartArea.left + stack.placed, y, width, height);
8231 stack.start = y;
8232 stack.placed += width;
8233 y = box.bottom;
8234 } else {
8235 var height1 = chartArea.h * weight;
8236 var width1 = stack.size || box.width;
8237 if ((0, _helpersSegmentJs.j)(stack.start)) x = stack.start;
8238 if (box.fullSize) setBoxDims(box, x, userPadding.top, width1, params.outerHeight - userPadding.bottom - userPadding.top);
8239 else setBoxDims(box, x, chartArea.top + stack.placed, width1, height1);
8240 stack.start = x;
8241 stack.placed += height1;
8242 x = box.right;
8243 }
8244 }
8245 } catch (err) {
8246 _didIteratorError = true;
8247 _iteratorError = err;
8248 } finally{
8249 try {
8250 if (!_iteratorNormalCompletion && _iterator.return != null) {
8251 _iterator.return();
8252 }
8253 } finally{
8254 if (_didIteratorError) {
8255 throw _iteratorError;
8256 }
8257 }
8258 }
8259 chartArea.x = x;
8260 chartArea.y = y;
8261 }
8262 (0, _helpersSegmentJs.d).set("layout", {
8263 autoPadding: true,
8264 padding: {
8265 top: 0,
8266 right: 0,
8267 bottom: 0,
8268 left: 0
8269 }
8270 });
8271 var layouts = {
8272 addBox: function(chart, item) {
8273 if (!chart.boxes) chart.boxes = [];
8274 item.fullSize = item.fullSize || false;
8275 item.position = item.position || "top";
8276 item.weight = item.weight || 0;
8277 item._layers = item._layers || function() {
8278 return [
8279 {
8280 z: 0,
8281 draw: function(chartArea) {
8282 item.draw(chartArea);
8283 }
8284 }
8285 ];
8286 };
8287 chart.boxes.push(item);
8288 },
8289 removeBox: function(chart, layoutItem) {
8290 var index42 = chart.boxes ? chart.boxes.indexOf(layoutItem) : -1;
8291 if (index42 !== -1) chart.boxes.splice(index42, 1);
8292 },
8293 configure: function(chart, item, options) {
8294 item.fullSize = options.fullSize;
8295 item.position = options.position;
8296 item.weight = options.weight;
8297 },
8298 update: function(chart, width, height, minPadding) {
8299 if (!chart) return;
8300 var padding = (0, _helpersSegmentJs.D)(chart.options.layout.padding);
8301 var availableWidth = Math.max(width - padding.width, 0);
8302 var availableHeight = Math.max(height - padding.height, 0);
8303 var boxes = buildLayoutBoxes(chart.boxes);
8304 var verticalBoxes = boxes.vertical;
8305 var horizontalBoxes = boxes.horizontal;
8306 (0, _helpersSegmentJs.E)(chart.boxes, function(box) {
8307 if (typeof box.beforeLayout === "function") box.beforeLayout();
8308 });
8309 var visibleVerticalBoxCount = verticalBoxes.reduce(function(total, wrap) {
8310 return wrap.box.options && wrap.box.options.display === false ? total : total + 1;
8311 }, 0) || 1;
8312 var params = Object.freeze({
8313 outerWidth: width,
8314 outerHeight: height,
8315 padding: padding,
8316 availableWidth: availableWidth,
8317 availableHeight: availableHeight,
8318 vBoxMaxWidth: availableWidth / 2 / visibleVerticalBoxCount,
8319 hBoxMaxHeight: availableHeight / 2
8320 });
8321 var maxPadding = Object.assign({}, padding);
8322 updateMaxPadding(maxPadding, (0, _helpersSegmentJs.D)(minPadding));
8323 var chartArea = Object.assign({
8324 maxPadding: maxPadding,
8325 w: availableWidth,
8326 h: availableHeight,
8327 x: padding.left,
8328 y: padding.top
8329 }, padding);
8330 var stacks = setLayoutDims(verticalBoxes.concat(horizontalBoxes), params);
8331 fitBoxes(boxes.fullSize, chartArea, params, stacks);
8332 fitBoxes(verticalBoxes, chartArea, params, stacks);
8333 if (fitBoxes(horizontalBoxes, chartArea, params, stacks)) fitBoxes(verticalBoxes, chartArea, params, stacks);
8334 handleMaxPadding(chartArea);
8335 placeBoxes(boxes.leftAndTop, chartArea, params, stacks);
8336 chartArea.x += chartArea.w;
8337 chartArea.y += chartArea.h;
8338 placeBoxes(boxes.rightAndBottom, chartArea, params, stacks);
8339 chart.chartArea = {
8340 left: chartArea.left,
8341 top: chartArea.top,
8342 right: chartArea.left + chartArea.w,
8343 bottom: chartArea.top + chartArea.h,
8344 height: chartArea.h,
8345 width: chartArea.w
8346 };
8347 (0, _helpersSegmentJs.E)(boxes.chartArea, function(layout) {
8348 var box = layout.box;
8349 Object.assign(box, chart.chartArea);
8350 box.update(chartArea.w, chartArea.h, {
8351 left: 0,
8352 top: 0,
8353 right: 0,
8354 bottom: 0
8355 });
8356 });
8357 }
8358 };
8359 var BasePlatform = /*#__PURE__*/ function() {
8360 "use strict";
8361 function BasePlatform() {
8362 (0, _classCallCheckJsDefault.default)(this, BasePlatform);
8363 }
8364 (0, _createClassJsDefault.default)(BasePlatform, [
8365 {
8366 key: "acquireContext",
8367 value: function acquireContext(canvas, aspectRatio) {}
8368 },
8369 {
8370 key: "releaseContext",
8371 value: function releaseContext(context) {
8372 return false;
8373 }
8374 },
8375 {
8376 key: "addEventListener",
8377 value: function addEventListener(chart, type, listener) {}
8378 },
8379 {
8380 key: "removeEventListener",
8381 value: function removeEventListener(chart, type, listener) {}
8382 },
8383 {
8384 key: "getDevicePixelRatio",
8385 value: function getDevicePixelRatio() {
8386 return 1;
8387 }
8388 },
8389 {
8390 key: "getMaximumSize",
8391 value: function getMaximumSize(element, width, height, aspectRatio) {
8392 width = Math.max(0, width || element.width);
8393 height = height || element.height;
8394 return {
8395 width: width,
8396 height: Math.max(0, aspectRatio ? Math.floor(width / aspectRatio) : height)
8397 };
8398 }
8399 },
8400 {
8401 key: "isAttached",
8402 value: function isAttached(canvas) {
8403 return true;
8404 }
8405 },
8406 {
8407 key: "updateConfig",
8408 value: function updateConfig(config) {}
8409 }
8410 ]);
8411 return BasePlatform;
8412 }();
8413 var BasicPlatform = /*#__PURE__*/ function(BasePlatform) {
8414 "use strict";
8415 (0, _inheritsJsDefault.default)(BasicPlatform, BasePlatform);
8416 var _super = (0, _createSuperJsDefault.default)(BasicPlatform);
8417 function BasicPlatform() {
8418 (0, _classCallCheckJsDefault.default)(this, BasicPlatform);
8419 return _super.apply(this, arguments);
8420 }
8421 (0, _createClassJsDefault.default)(BasicPlatform, [
8422 {
8423 key: "acquireContext",
8424 value: function acquireContext(item) {
8425 return item && item.getContext && item.getContext("2d") || null;
8426 }
8427 },
8428 {
8429 key: "updateConfig",
8430 value: function updateConfig(config) {
8431 config.options.animation = false;
8432 }
8433 }
8434 ]);
8435 return BasicPlatform;
8436 }(BasePlatform);
8437 var EXPANDO_KEY = "$chartjs";
8438 var EVENT_TYPES = {
8439 touchstart: "mousedown",
8440 touchmove: "mousemove",
8441 touchend: "mouseup",
8442 pointerenter: "mouseenter",
8443 pointerdown: "mousedown",
8444 pointermove: "mousemove",
8445 pointerup: "mouseup",
8446 pointerleave: "mouseout",
8447 pointerout: "mouseout"
8448 };
8449 var isNullOrEmpty = function(value) {
8450 return value === null || value === "";
8451 };
8452 function initCanvas(canvas, aspectRatio) {
8453 var style = canvas.style;
8454 var renderHeight = canvas.getAttribute("height");
8455 var renderWidth = canvas.getAttribute("width");
8456 canvas[EXPANDO_KEY] = {
8457 initial: {
8458 height: renderHeight,
8459 width: renderWidth,
8460 style: {
8461 display: style.display,
8462 height: style.height,
8463 width: style.width
8464 }
8465 }
8466 };
8467 style.display = style.display || "block";
8468 style.boxSizing = style.boxSizing || "border-box";
8469 if (isNullOrEmpty(renderWidth)) {
8470 var displayWidth = (0, _helpersSegmentJs.I)(canvas, "width");
8471 if (displayWidth !== undefined) canvas.width = displayWidth;
8472 }
8473 if (isNullOrEmpty(renderHeight)) {
8474 if (canvas.style.height === "") canvas.height = canvas.width / (aspectRatio || 2);
8475 else {
8476 var displayHeight = (0, _helpersSegmentJs.I)(canvas, "height");
8477 if (displayHeight !== undefined) canvas.height = displayHeight;
8478 }
8479 }
8480 return canvas;
8481 }
8482 var eventListenerOptions = (0, _helpersSegmentJs.K) ? {
8483 passive: true
8484 } : false;
8485 function addListener(node, type, listener) {
8486 node.addEventListener(type, listener, eventListenerOptions);
8487 }
8488 function removeListener(chart, type, listener) {
8489 chart.canvas.removeEventListener(type, listener, eventListenerOptions);
8490 }
8491 function fromNativeEvent(event, chart) {
8492 var type = EVENT_TYPES[event.type] || event.type;
8493 var ref = (0, _helpersSegmentJs.z)(event, chart), x = ref.x, y = ref.y;
8494 return {
8495 type: type,
8496 chart: chart,
8497 native: event,
8498 x: x !== undefined ? x : null,
8499 y: y !== undefined ? y : null
8500 };
8501 }
8502 function nodeListContains(nodeList, canvas) {
8503 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
8504 try {
8505 for(var _iterator = nodeList[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
8506 var node = _step.value;
8507 if (node === canvas || node.contains(canvas)) return true;
8508 }
8509 } catch (err) {
8510 _didIteratorError = true;
8511 _iteratorError = err;
8512 } finally{
8513 try {
8514 if (!_iteratorNormalCompletion && _iterator.return != null) {
8515 _iterator.return();
8516 }
8517 } finally{
8518 if (_didIteratorError) {
8519 throw _iteratorError;
8520 }
8521 }
8522 }
8523 }
8524 function createAttachObserver(chart, type, listener) {
8525 var canvas = chart.canvas;
8526 var observer = new MutationObserver(function(entries) {
8527 var trigger = false;
8528 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
8529 try {
8530 for(var _iterator = entries[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
8531 var entry = _step.value;
8532 trigger = trigger || nodeListContains(entry.addedNodes, canvas);
8533 trigger = trigger && !nodeListContains(entry.removedNodes, canvas);
8534 }
8535 } catch (err) {
8536 _didIteratorError = true;
8537 _iteratorError = err;
8538 } finally{
8539 try {
8540 if (!_iteratorNormalCompletion && _iterator.return != null) {
8541 _iterator.return();
8542 }
8543 } finally{
8544 if (_didIteratorError) {
8545 throw _iteratorError;
8546 }
8547 }
8548 }
8549 if (trigger) listener();
8550 });
8551 observer.observe(document, {
8552 childList: true,
8553 subtree: true
8554 });
8555 return observer;
8556 }
8557 function createDetachObserver(chart, type, listener) {
8558 var canvas = chart.canvas;
8559 var observer = new MutationObserver(function(entries) {
8560 var trigger = false;
8561 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
8562 try {
8563 for(var _iterator = entries[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
8564 var entry = _step.value;
8565 trigger = trigger || nodeListContains(entry.removedNodes, canvas);
8566 trigger = trigger && !nodeListContains(entry.addedNodes, canvas);
8567 }
8568 } catch (err) {
8569 _didIteratorError = true;
8570 _iteratorError = err;
8571 } finally{
8572 try {
8573 if (!_iteratorNormalCompletion && _iterator.return != null) {
8574 _iterator.return();
8575 }
8576 } finally{
8577 if (_didIteratorError) {
8578 throw _iteratorError;
8579 }
8580 }
8581 }
8582 if (trigger) listener();
8583 });
8584 observer.observe(document, {
8585 childList: true,
8586 subtree: true
8587 });
8588 return observer;
8589 }
8590 var drpListeningCharts = new Map();
8591 var oldDevicePixelRatio = 0;
8592 function onWindowResize() {
8593 var dpr = window.devicePixelRatio;
8594 if (dpr === oldDevicePixelRatio) return;
8595 oldDevicePixelRatio = dpr;
8596 drpListeningCharts.forEach(function(resize, chart) {
8597 if (chart.currentDevicePixelRatio !== dpr) resize();
8598 });
8599 }
8600 function listenDevicePixelRatioChanges(chart, resize) {
8601 if (!drpListeningCharts.size) window.addEventListener("resize", onWindowResize);
8602 drpListeningCharts.set(chart, resize);
8603 }
8604 function unlistenDevicePixelRatioChanges(chart) {
8605 drpListeningCharts.delete(chart);
8606 if (!drpListeningCharts.size) window.removeEventListener("resize", onWindowResize);
8607 }
8608 function createResizeObserver(chart, type, listener) {
8609 var canvas = chart.canvas;
8610 var container = canvas && (0, _helpersSegmentJs.G)(canvas);
8611 if (!container) return;
8612 var resize = (0, _helpersSegmentJs.J)(function(width, height) {
8613 var w = container.clientWidth;
8614 listener(width, height);
8615 if (w < container.clientWidth) listener();
8616 }, window);
8617 var observer = new ResizeObserver(function(entries) {
8618 var entry = entries[0];
8619 var width = entry.contentRect.width;
8620 var height = entry.contentRect.height;
8621 if (width === 0 && height === 0) return;
8622 resize(width, height);
8623 });
8624 observer.observe(container);
8625 listenDevicePixelRatioChanges(chart, resize);
8626 return observer;
8627 }
8628 function releaseObserver(chart, type, observer) {
8629 if (observer) observer.disconnect();
8630 if (type === "resize") unlistenDevicePixelRatioChanges(chart);
8631 }
8632 function createProxyAndListen(chart, type, listener) {
8633 var canvas = chart.canvas;
8634 var proxy = (0, _helpersSegmentJs.J)(function(event) {
8635 if (chart.ctx !== null) listener(fromNativeEvent(event, chart));
8636 }, chart, function(args) {
8637 var event = args[0];
8638 return [
8639 event,
8640 event.offsetX,
8641 event.offsetY
8642 ];
8643 });
8644 addListener(canvas, type, proxy);
8645 return proxy;
8646 }
8647 var DomPlatform = /*#__PURE__*/ function(BasePlatform) {
8648 "use strict";
8649 (0, _inheritsJsDefault.default)(DomPlatform, BasePlatform);
8650 var _super = (0, _createSuperJsDefault.default)(DomPlatform);
8651 function DomPlatform() {
8652 (0, _classCallCheckJsDefault.default)(this, DomPlatform);
8653 return _super.apply(this, arguments);
8654 }
8655 (0, _createClassJsDefault.default)(DomPlatform, [
8656 {
8657 key: "acquireContext",
8658 value: function acquireContext(canvas, aspectRatio) {
8659 var context = canvas && canvas.getContext && canvas.getContext("2d");
8660 if (context && context.canvas === canvas) {
8661 initCanvas(canvas, aspectRatio);
8662 return context;
8663 }
8664 return null;
8665 }
8666 },
8667 {
8668 key: "releaseContext",
8669 value: function releaseContext(context) {
8670 var canvas = context.canvas;
8671 if (!canvas[EXPANDO_KEY]) return false;
8672 var initial = canvas[EXPANDO_KEY].initial;
8673 [
8674 "height",
8675 "width"
8676 ].forEach(function(prop) {
8677 var value = initial[prop];
8678 if ((0, _helpersSegmentJs.k)(value)) canvas.removeAttribute(prop);
8679 else canvas.setAttribute(prop, value);
8680 });
8681 var style = initial.style || {};
8682 Object.keys(style).forEach(function(key) {
8683 canvas.style[key] = style[key];
8684 });
8685 canvas.width = canvas.width;
8686 delete canvas[EXPANDO_KEY];
8687 return true;
8688 }
8689 },
8690 {
8691 key: "addEventListener",
8692 value: function addEventListener(chart, type, listener) {
8693 this.removeEventListener(chart, type);
8694 var proxies = chart.$proxies || (chart.$proxies = {});
8695 var handlers = {
8696 attach: createAttachObserver,
8697 detach: createDetachObserver,
8698 resize: createResizeObserver
8699 };
8700 var handler = handlers[type] || createProxyAndListen;
8701 proxies[type] = handler(chart, type, listener);
8702 }
8703 },
8704 {
8705 key: "removeEventListener",
8706 value: function removeEventListener(chart, type) {
8707 var proxies = chart.$proxies || (chart.$proxies = {});
8708 var proxy = proxies[type];
8709 if (!proxy) return;
8710 var handlers = {
8711 attach: releaseObserver,
8712 detach: releaseObserver,
8713 resize: releaseObserver
8714 };
8715 var handler = handlers[type] || removeListener;
8716 handler(chart, type, proxy);
8717 proxies[type] = undefined;
8718 }
8719 },
8720 {
8721 key: "getDevicePixelRatio",
8722 value: function getDevicePixelRatio() {
8723 return window.devicePixelRatio;
8724 }
8725 },
8726 {
8727 key: "getMaximumSize",
8728 value: function getMaximumSize(canvas, width, height, aspectRatio) {
8729 return (0, _helpersSegmentJs.F)(canvas, width, height, aspectRatio);
8730 }
8731 },
8732 {
8733 key: "isAttached",
8734 value: function isAttached(canvas) {
8735 var container = (0, _helpersSegmentJs.G)(canvas);
8736 return !!(container && container.isConnected);
8737 }
8738 }
8739 ]);
8740 return DomPlatform;
8741 }(BasePlatform);
8742 function _detectPlatform(canvas) {
8743 if (!(0, _helpersSegmentJs.L)() || typeof OffscreenCanvas !== "undefined" && canvas instanceof OffscreenCanvas) return BasicPlatform;
8744 return DomPlatform;
8745 }
8746 var Element = /*#__PURE__*/ function() {
8747 "use strict";
8748 function Element() {
8749 (0, _classCallCheckJsDefault.default)(this, Element);
8750 this.x = undefined;
8751 this.y = undefined;
8752 this.active = false;
8753 this.options = undefined;
8754 this.$animations = undefined;
8755 }
8756 (0, _createClassJsDefault.default)(Element, [
8757 {
8758 key: "tooltipPosition",
8759 value: function tooltipPosition(useFinalPosition) {
8760 var ref = this.getProps([
8761 "x",
8762 "y"
8763 ], useFinalPosition), x = ref.x, y = ref.y;
8764 return {
8765 x: x,
8766 y: y
8767 };
8768 }
8769 },
8770 {
8771 key: "hasValue",
8772 value: function hasValue() {
8773 return (0, _helpersSegmentJs.q)(this.x) && (0, _helpersSegmentJs.q)(this.y);
8774 }
8775 },
8776 {
8777 key: "getProps",
8778 value: function getProps(props, final) {
8779 var _this = this;
8780 var anims = this.$animations;
8781 if (!final || !anims) return this;
8782 var ret = {};
8783 props.forEach(function(prop) {
8784 ret[prop] = anims[prop] && anims[prop].active() ? anims[prop]._to : _this[prop];
8785 });
8786 return ret;
8787 }
8788 }
8789 ]);
8790 return Element;
8791 }();
8792 Element.defaults = {};
8793 Element.defaultRoutes = undefined;
8794 var formatters = {
8795 values: function(value) {
8796 return (0, _helpersSegmentJs.b)(value) ? value : "" + value;
8797 },
8798 numeric: function(tickValue, index, ticks) {
8799 if (tickValue === 0) return "0";
8800 var locale = this.chart.options.locale;
8801 var notation;
8802 var delta = tickValue;
8803 if (ticks.length > 1) {
8804 var maxTick = Math.max(Math.abs(ticks[0].value), Math.abs(ticks[ticks.length - 1].value));
8805 if (maxTick < 1e-4 || maxTick > 1e+15) notation = "scientific";
8806 delta = calculateDelta(tickValue, ticks);
8807 }
8808 var logDelta = (0, _helpersSegmentJs.M)(Math.abs(delta));
8809 var numDecimal = Math.max(Math.min(-1 * Math.floor(logDelta), 20), 0);
8810 var options = {
8811 notation: notation,
8812 minimumFractionDigits: numDecimal,
8813 maximumFractionDigits: numDecimal
8814 };
8815 Object.assign(options, this.options.ticks.format);
8816 return (0, _helpersSegmentJs.o)(tickValue, locale, options);
8817 },
8818 logarithmic: function(tickValue, index43, ticks) {
8819 if (tickValue === 0) return "0";
8820 var remain = tickValue / Math.pow(10, Math.floor((0, _helpersSegmentJs.M)(tickValue)));
8821 if (remain === 1 || remain === 2 || remain === 5) return formatters.numeric.call(this, tickValue, index43, ticks);
8822 return "";
8823 }
8824 };
8825 function calculateDelta(tickValue, ticks) {
8826 var delta = ticks.length > 3 ? ticks[2].value - ticks[1].value : ticks[1].value - ticks[0].value;
8827 if (Math.abs(delta) >= 1 && tickValue !== Math.floor(tickValue)) delta = tickValue - Math.floor(tickValue);
8828 return delta;
8829 }
8830 var Ticks = {
8831 formatters: formatters
8832 };
8833 (0, _helpersSegmentJs.d).set("scale", {
8834 display: true,
8835 offset: false,
8836 reverse: false,
8837 beginAtZero: false,
8838 bounds: "ticks",
8839 grace: 0,
8840 grid: {
8841 display: true,
8842 lineWidth: 1,
8843 drawBorder: true,
8844 drawOnChartArea: true,
8845 drawTicks: true,
8846 tickLength: 8,
8847 tickWidth: function(_ctx, options) {
8848 return options.lineWidth;
8849 },
8850 tickColor: function(_ctx, options) {
8851 return options.color;
8852 },
8853 offset: false,
8854 borderDash: [],
8855 borderDashOffset: 0.0,
8856 borderWidth: 1
8857 },
8858 title: {
8859 display: false,
8860 text: "",
8861 padding: {
8862 top: 4,
8863 bottom: 4
8864 }
8865 },
8866 ticks: {
8867 minRotation: 0,
8868 maxRotation: 50,
8869 mirror: false,
8870 textStrokeWidth: 0,
8871 textStrokeColor: "",
8872 padding: 3,
8873 display: true,
8874 autoSkip: true,
8875 autoSkipPadding: 3,
8876 labelOffset: 0,
8877 callback: Ticks.formatters.values,
8878 minor: {},
8879 major: {},
8880 align: "center",
8881 crossAlign: "near",
8882 showLabelBackdrop: false,
8883 backdropColor: "rgba(255, 255, 255, 0.75)",
8884 backdropPadding: 2
8885 }
8886 });
8887 (0, _helpersSegmentJs.d).route("scale.ticks", "color", "", "color");
8888 (0, _helpersSegmentJs.d).route("scale.grid", "color", "", "borderColor");
8889 (0, _helpersSegmentJs.d).route("scale.grid", "borderColor", "", "borderColor");
8890 (0, _helpersSegmentJs.d).route("scale.title", "color", "", "color");
8891 (0, _helpersSegmentJs.d).describe("scale", {
8892 _fallback: false,
8893 _scriptable: function(name) {
8894 return !name.startsWith("before") && !name.startsWith("after") && name !== "callback" && name !== "parser";
8895 },
8896 _indexable: function(name) {
8897 return name !== "borderDash" && name !== "tickBorderDash";
8898 }
8899 });
8900 (0, _helpersSegmentJs.d).describe("scales", {
8901 _fallback: "scale"
8902 });
8903 (0, _helpersSegmentJs.d).describe("scale.ticks", {
8904 _scriptable: function(name) {
8905 return name !== "backdropPadding" && name !== "callback";
8906 },
8907 _indexable: function(name) {
8908 return name !== "backdropPadding";
8909 }
8910 });
8911 function autoSkip(scale, ticks) {
8912 var tickOpts = scale.options.ticks;
8913 var ticksLimit = tickOpts.maxTicksLimit || determineMaxTicks(scale);
8914 var majorIndices = tickOpts.major.enabled ? getMajorIndices(ticks) : [];
8915 var numMajorIndices = majorIndices.length;
8916 var first = majorIndices[0];
8917 var last = majorIndices[numMajorIndices - 1];
8918 var newTicks = [];
8919 if (numMajorIndices > ticksLimit) {
8920 skipMajors(ticks, newTicks, majorIndices, numMajorIndices / ticksLimit);
8921 return newTicks;
8922 }
8923 var spacing = calculateSpacing(majorIndices, ticks, ticksLimit);
8924 if (numMajorIndices > 0) {
8925 var i, ilen;
8926 var avgMajorSpacing = numMajorIndices > 1 ? Math.round((last - first) / (numMajorIndices - 1)) : null;
8927 skip(ticks, newTicks, spacing, (0, _helpersSegmentJs.k)(avgMajorSpacing) ? 0 : first - avgMajorSpacing, first);
8928 for(i = 0, ilen = numMajorIndices - 1; i < ilen; i++)skip(ticks, newTicks, spacing, majorIndices[i], majorIndices[i + 1]);
8929 skip(ticks, newTicks, spacing, last, (0, _helpersSegmentJs.k)(avgMajorSpacing) ? ticks.length : last + avgMajorSpacing);
8930 return newTicks;
8931 }
8932 skip(ticks, newTicks, spacing);
8933 return newTicks;
8934 }
8935 function determineMaxTicks(scale) {
8936 var offset = scale.options.offset;
8937 var tickLength = scale._tickSize();
8938 var maxScale = scale._length / tickLength + (offset ? 0 : 1);
8939 var maxChart = scale._maxLength / tickLength;
8940 return Math.floor(Math.min(maxScale, maxChart));
8941 }
8942 function calculateSpacing(majorIndices, ticks, ticksLimit) {
8943 var evenMajorSpacing = getEvenSpacing(majorIndices);
8944 var spacing = ticks.length / ticksLimit;
8945 if (!evenMajorSpacing) return Math.max(spacing, 1);
8946 var factors = (0, _helpersSegmentJs.N)(evenMajorSpacing);
8947 for(var i = 0, ilen = factors.length - 1; i < ilen; i++){
8948 var factor = factors[i];
8949 if (factor > spacing) return factor;
8950 }
8951 return Math.max(spacing, 1);
8952 }
8953 function getMajorIndices(ticks) {
8954 var result = [];
8955 var i, ilen;
8956 for(i = 0, ilen = ticks.length; i < ilen; i++)if (ticks[i].major) result.push(i);
8957 return result;
8958 }
8959 function skipMajors(ticks, newTicks, majorIndices, spacing) {
8960 var count = 0;
8961 var next = majorIndices[0];
8962 var i;
8963 spacing = Math.ceil(spacing);
8964 for(i = 0; i < ticks.length; i++)if (i === next) {
8965 newTicks.push(ticks[i]);
8966 count++;
8967 next = majorIndices[count * spacing];
8968 }
8969 }
8970 function skip(ticks, newTicks, spacing, majorStart, majorEnd) {
8971 var start = (0, _helpersSegmentJs.v)(majorStart, 0);
8972 var end = Math.min((0, _helpersSegmentJs.v)(majorEnd, ticks.length), ticks.length);
8973 var count = 0;
8974 var length, i, next;
8975 spacing = Math.ceil(spacing);
8976 if (majorEnd) {
8977 length = majorEnd - majorStart;
8978 spacing = length / Math.floor(length / spacing);
8979 }
8980 next = start;
8981 while(next < 0){
8982 count++;
8983 next = Math.round(start + count * spacing);
8984 }
8985 for(i = Math.max(start, 0); i < end; i++)if (i === next) {
8986 newTicks.push(ticks[i]);
8987 count++;
8988 next = Math.round(start + count * spacing);
8989 }
8990 }
8991 function getEvenSpacing(arr) {
8992 var len = arr.length;
8993 var i, diff;
8994 if (len < 2) return false;
8995 for(diff = arr[0], i = 1; i < len; ++i){
8996 if (arr[i] - arr[i - 1] !== diff) return false;
8997 }
8998 return diff;
8999 }
9000 var reverseAlign = function(align) {
9001 return align === "left" ? "right" : align === "right" ? "left" : align;
9002 };
9003 var offsetFromEdge = function(scale, edge, offset) {
9004 return edge === "top" || edge === "left" ? scale[edge] + offset : scale[edge] - offset;
9005 };
9006 function sample(arr, numItems) {
9007 var result = [];
9008 var increment = arr.length / numItems;
9009 var len = arr.length;
9010 var i = 0;
9011 for(; i < len; i += increment)result.push(arr[Math.floor(i)]);
9012 return result;
9013 }
9014 function getPixelForGridLine(scale, index44, offsetGridLines) {
9015 var length = scale.ticks.length;
9016 var validIndex1 = Math.min(index44, length - 1);
9017 var start = scale._startPixel;
9018 var end = scale._endPixel;
9019 var epsilon = 1e-6;
9020 var lineValue = scale.getPixelForTick(validIndex1);
9021 var offset;
9022 if (offsetGridLines) {
9023 if (length === 1) offset = Math.max(lineValue - start, end - lineValue);
9024 else if (index44 === 0) offset = (scale.getPixelForTick(1) - lineValue) / 2;
9025 else offset = (lineValue - scale.getPixelForTick(validIndex1 - 1)) / 2;
9026 lineValue += validIndex1 < index44 ? offset : -offset;
9027 if (lineValue < start - epsilon || lineValue > end + epsilon) return;
9028 }
9029 return lineValue;
9030 }
9031 function garbageCollect(caches, length) {
9032 (0, _helpersSegmentJs.E)(caches, function(cache) {
9033 var gc = cache.gc;
9034 var gcLen = gc.length / 2;
9035 var i;
9036 if (gcLen > length) {
9037 for(i = 0; i < gcLen; ++i)delete cache.data[gc[i]];
9038 gc.splice(0, gcLen);
9039 }
9040 });
9041 }
9042 function getTickMarkLength(options) {
9043 return options.drawTicks ? options.tickLength : 0;
9044 }
9045 function getTitleHeight(options, fallback) {
9046 if (!options.display) return 0;
9047 var font = (0, _helpersSegmentJs.$)(options.font, fallback);
9048 var padding = (0, _helpersSegmentJs.D)(options.padding);
9049 var lines = (0, _helpersSegmentJs.b)(options.text) ? options.text.length : 1;
9050 return lines * font.lineHeight + padding.height;
9051 }
9052 function createScaleContext(parent, scale) {
9053 return (0, _helpersSegmentJs.h)(parent, {
9054 scale: scale,
9055 type: "scale"
9056 });
9057 }
9058 function createTickContext(parent, index45, tick) {
9059 return (0, _helpersSegmentJs.h)(parent, {
9060 tick: tick,
9061 index: index45,
9062 type: "tick"
9063 });
9064 }
9065 function titleAlign(align, position, reverse) {
9066 var ret = (0, _helpersSegmentJs.a0)(align);
9067 if (reverse && position !== "right" || !reverse && position === "right") ret = reverseAlign(ret);
9068 return ret;
9069 }
9070 function titleArgs(scale, offset, position, align) {
9071 var top = scale.top, left = scale.left, bottom = scale.bottom, right = scale.right, chart = scale.chart;
9072 var chartArea = chart.chartArea, scales2 = chart.scales;
9073 var rotation = 0;
9074 var maxWidth, titleX, titleY;
9075 var height = bottom - top;
9076 var width = right - left;
9077 if (scale.isHorizontal()) {
9078 titleX = (0, _helpersSegmentJs.a1)(align, left, right);
9079 if ((0, _helpersSegmentJs.i)(position)) {
9080 var positionAxisID = Object.keys(position)[0];
9081 var value = position[positionAxisID];
9082 titleY = scales2[positionAxisID].getPixelForValue(value) + height - offset;
9083 } else if (position === "center") titleY = (chartArea.bottom + chartArea.top) / 2 + height - offset;
9084 else titleY = offsetFromEdge(scale, position, offset);
9085 maxWidth = right - left;
9086 } else {
9087 if ((0, _helpersSegmentJs.i)(position)) {
9088 var positionAxisID1 = Object.keys(position)[0];
9089 var value1 = position[positionAxisID1];
9090 titleX = scales2[positionAxisID1].getPixelForValue(value1) - width + offset;
9091 } else if (position === "center") titleX = (chartArea.left + chartArea.right) / 2 - width + offset;
9092 else titleX = offsetFromEdge(scale, position, offset);
9093 titleY = (0, _helpersSegmentJs.a1)(align, bottom, top);
9094 rotation = position === "left" ? -(0, _helpersSegmentJs.H) : (0, _helpersSegmentJs.H);
9095 }
9096 return {
9097 titleX: titleX,
9098 titleY: titleY,
9099 maxWidth: maxWidth,
9100 rotation: rotation
9101 };
9102 }
9103 var Scale = /*#__PURE__*/ function(Element) {
9104 "use strict";
9105 (0, _inheritsJsDefault.default)(Scale, Element);
9106 var _super = (0, _createSuperJsDefault.default)(Scale);
9107 function Scale(cfg) {
9108 (0, _classCallCheckJsDefault.default)(this, Scale);
9109 var _this;
9110 _this = _super.call(this);
9111 _this.id = cfg.id;
9112 _this.type = cfg.type;
9113 _this.options = undefined;
9114 _this.ctx = cfg.ctx;
9115 _this.chart = cfg.chart;
9116 _this.top = undefined;
9117 _this.bottom = undefined;
9118 _this.left = undefined;
9119 _this.right = undefined;
9120 _this.width = undefined;
9121 _this.height = undefined;
9122 _this._margins = {
9123 left: 0,
9124 right: 0,
9125 top: 0,
9126 bottom: 0
9127 };
9128 _this.maxWidth = undefined;
9129 _this.maxHeight = undefined;
9130 _this.paddingTop = undefined;
9131 _this.paddingBottom = undefined;
9132 _this.paddingLeft = undefined;
9133 _this.paddingRight = undefined;
9134 _this.axis = undefined;
9135 _this.labelRotation = undefined;
9136 _this.min = undefined;
9137 _this.max = undefined;
9138 _this._range = undefined;
9139 _this.ticks = [];
9140 _this._gridLineItems = null;
9141 _this._labelItems = null;
9142 _this._labelSizes = null;
9143 _this._length = 0;
9144 _this._maxLength = 0;
9145 _this._longestTextCache = {};
9146 _this._startPixel = undefined;
9147 _this._endPixel = undefined;
9148 _this._reversePixels = false;
9149 _this._userMax = undefined;
9150 _this._userMin = undefined;
9151 _this._suggestedMax = undefined;
9152 _this._suggestedMin = undefined;
9153 _this._ticksLength = 0;
9154 _this._borderValue = 0;
9155 _this._cache = {};
9156 _this._dataLimitsCached = false;
9157 _this.$context = undefined;
9158 return _this;
9159 }
9160 (0, _createClassJsDefault.default)(Scale, [
9161 {
9162 key: "init",
9163 value: function init(options) {
9164 this.options = options.setContext(this.getContext());
9165 this.axis = options.axis;
9166 this._userMin = this.parse(options.min);
9167 this._userMax = this.parse(options.max);
9168 this._suggestedMin = this.parse(options.suggestedMin);
9169 this._suggestedMax = this.parse(options.suggestedMax);
9170 }
9171 },
9172 {
9173 key: "parse",
9174 value: function parse1(raw, index) {
9175 return raw;
9176 }
9177 },
9178 {
9179 key: "getUserBounds",
9180 value: function getUserBounds() {
9181 var ref = this, _userMin = ref._userMin, _userMax = ref._userMax, _suggestedMin = ref._suggestedMin, _suggestedMax = ref._suggestedMax;
9182 _userMin = (0, _helpersSegmentJs.O)(_userMin, Number.POSITIVE_INFINITY);
9183 _userMax = (0, _helpersSegmentJs.O)(_userMax, Number.NEGATIVE_INFINITY);
9184 _suggestedMin = (0, _helpersSegmentJs.O)(_suggestedMin, Number.POSITIVE_INFINITY);
9185 _suggestedMax = (0, _helpersSegmentJs.O)(_suggestedMax, Number.NEGATIVE_INFINITY);
9186 return {
9187 min: (0, _helpersSegmentJs.O)(_userMin, _suggestedMin),
9188 max: (0, _helpersSegmentJs.O)(_userMax, _suggestedMax),
9189 minDefined: (0, _helpersSegmentJs.g)(_userMin),
9190 maxDefined: (0, _helpersSegmentJs.g)(_userMax)
9191 };
9192 }
9193 },
9194 {
9195 key: "getMinMax",
9196 value: function getMinMax(canStack) {
9197 var ref = this.getUserBounds(), min = ref.min, max = ref.max, minDefined = ref.minDefined, maxDefined = ref.maxDefined;
9198 var range;
9199 if (minDefined && maxDefined) return {
9200 min: min,
9201 max: max
9202 };
9203 var metas = this.getMatchingVisibleMetas();
9204 for(var i = 0, ilen = metas.length; i < ilen; ++i){
9205 range = metas[i].controller.getMinMax(this, canStack);
9206 if (!minDefined) min = Math.min(min, range.min);
9207 if (!maxDefined) max = Math.max(max, range.max);
9208 }
9209 min = maxDefined && min > max ? max : min;
9210 max = minDefined && min > max ? min : max;
9211 return {
9212 min: (0, _helpersSegmentJs.O)(min, (0, _helpersSegmentJs.O)(max, min)),
9213 max: (0, _helpersSegmentJs.O)(max, (0, _helpersSegmentJs.O)(min, max))
9214 };
9215 }
9216 },
9217 {
9218 key: "getPadding",
9219 value: function getPadding() {
9220 return {
9221 left: this.paddingLeft || 0,
9222 top: this.paddingTop || 0,
9223 right: this.paddingRight || 0,
9224 bottom: this.paddingBottom || 0
9225 };
9226 }
9227 },
9228 {
9229 key: "getTicks",
9230 value: function getTicks() {
9231 return this.ticks;
9232 }
9233 },
9234 {
9235 key: "getLabels",
9236 value: function getLabels() {
9237 var data = this.chart.data;
9238 return this.options.labels || (this.isHorizontal() ? data.xLabels : data.yLabels) || data.labels || [];
9239 }
9240 },
9241 {
9242 key: "beforeLayout",
9243 value: function beforeLayout() {
9244 this._cache = {};
9245 this._dataLimitsCached = false;
9246 }
9247 },
9248 {
9249 key: "beforeUpdate",
9250 value: function beforeUpdate() {
9251 (0, _helpersSegmentJs.Q)(this.options.beforeUpdate, [
9252 this
9253 ]);
9254 }
9255 },
9256 {
9257 key: "update",
9258 value: function update(maxWidth, maxHeight, margins) {
9259 var _options = this.options, beginAtZero = _options.beginAtZero, grace = _options.grace, tickOpts = _options.ticks;
9260 var sampleSize = tickOpts.sampleSize;
9261 this.beforeUpdate();
9262 this.maxWidth = maxWidth;
9263 this.maxHeight = maxHeight;
9264 this._margins = margins = Object.assign({
9265 left: 0,
9266 right: 0,
9267 top: 0,
9268 bottom: 0
9269 }, margins);
9270 this.ticks = null;
9271 this._labelSizes = null;
9272 this._gridLineItems = null;
9273 this._labelItems = null;
9274 this.beforeSetDimensions();
9275 this.setDimensions();
9276 this.afterSetDimensions();
9277 this._maxLength = this.isHorizontal() ? this.width + margins.left + margins.right : this.height + margins.top + margins.bottom;
9278 if (!this._dataLimitsCached) {
9279 this.beforeDataLimits();
9280 this.determineDataLimits();
9281 this.afterDataLimits();
9282 this._range = (0, _helpersSegmentJs.R)(this, grace, beginAtZero);
9283 this._dataLimitsCached = true;
9284 }
9285 this.beforeBuildTicks();
9286 this.ticks = this.buildTicks() || [];
9287 this.afterBuildTicks();
9288 var samplingEnabled = sampleSize < this.ticks.length;
9289 this._convertTicksToLabels(samplingEnabled ? sample(this.ticks, sampleSize) : this.ticks);
9290 this.configure();
9291 this.beforeCalculateLabelRotation();
9292 this.calculateLabelRotation();
9293 this.afterCalculateLabelRotation();
9294 if (tickOpts.display && (tickOpts.autoSkip || tickOpts.source === "auto")) {
9295 this.ticks = autoSkip(this, this.ticks);
9296 this._labelSizes = null;
9297 this.afterAutoSkip();
9298 }
9299 if (samplingEnabled) this._convertTicksToLabels(this.ticks);
9300 this.beforeFit();
9301 this.fit();
9302 this.afterFit();
9303 this.afterUpdate();
9304 }
9305 },
9306 {
9307 key: "configure",
9308 value: function configure() {
9309 var reversePixels = this.options.reverse;
9310 var startPixel, endPixel;
9311 if (this.isHorizontal()) {
9312 startPixel = this.left;
9313 endPixel = this.right;
9314 } else {
9315 startPixel = this.top;
9316 endPixel = this.bottom;
9317 reversePixels = !reversePixels;
9318 }
9319 this._startPixel = startPixel;
9320 this._endPixel = endPixel;
9321 this._reversePixels = reversePixels;
9322 this._length = endPixel - startPixel;
9323 this._alignToPixels = this.options.alignToPixels;
9324 }
9325 },
9326 {
9327 key: "afterUpdate",
9328 value: function afterUpdate() {
9329 (0, _helpersSegmentJs.Q)(this.options.afterUpdate, [
9330 this
9331 ]);
9332 }
9333 },
9334 {
9335 key: "beforeSetDimensions",
9336 value: function beforeSetDimensions() {
9337 (0, _helpersSegmentJs.Q)(this.options.beforeSetDimensions, [
9338 this
9339 ]);
9340 }
9341 },
9342 {
9343 key: "setDimensions",
9344 value: function setDimensions() {
9345 if (this.isHorizontal()) {
9346 this.width = this.maxWidth;
9347 this.left = 0;
9348 this.right = this.width;
9349 } else {
9350 this.height = this.maxHeight;
9351 this.top = 0;
9352 this.bottom = this.height;
9353 }
9354 this.paddingLeft = 0;
9355 this.paddingTop = 0;
9356 this.paddingRight = 0;
9357 this.paddingBottom = 0;
9358 }
9359 },
9360 {
9361 key: "afterSetDimensions",
9362 value: function afterSetDimensions() {
9363 (0, _helpersSegmentJs.Q)(this.options.afterSetDimensions, [
9364 this
9365 ]);
9366 }
9367 },
9368 {
9369 key: "_callHooks",
9370 value: function _callHooks(name) {
9371 this.chart.notifyPlugins(name, this.getContext());
9372 (0, _helpersSegmentJs.Q)(this.options[name], [
9373 this
9374 ]);
9375 }
9376 },
9377 {
9378 key: "beforeDataLimits",
9379 value: function beforeDataLimits() {
9380 this._callHooks("beforeDataLimits");
9381 }
9382 },
9383 {
9384 key: "determineDataLimits",
9385 value: function determineDataLimits() {}
9386 },
9387 {
9388 key: "afterDataLimits",
9389 value: function afterDataLimits() {
9390 this._callHooks("afterDataLimits");
9391 }
9392 },
9393 {
9394 key: "beforeBuildTicks",
9395 value: function beforeBuildTicks() {
9396 this._callHooks("beforeBuildTicks");
9397 }
9398 },
9399 {
9400 key: "buildTicks",
9401 value: function buildTicks() {
9402 return [];
9403 }
9404 },
9405 {
9406 key: "afterBuildTicks",
9407 value: function afterBuildTicks() {
9408 this._callHooks("afterBuildTicks");
9409 }
9410 },
9411 {
9412 key: "beforeTickToLabelConversion",
9413 value: function beforeTickToLabelConversion() {
9414 (0, _helpersSegmentJs.Q)(this.options.beforeTickToLabelConversion, [
9415 this
9416 ]);
9417 }
9418 },
9419 {
9420 key: "generateTickLabels",
9421 value: function generateTickLabels(ticks) {
9422 var tickOpts = this.options.ticks;
9423 var i, ilen, tick;
9424 for(i = 0, ilen = ticks.length; i < ilen; i++){
9425 tick = ticks[i];
9426 tick.label = (0, _helpersSegmentJs.Q)(tickOpts.callback, [
9427 tick.value,
9428 i,
9429 ticks
9430 ], this);
9431 }
9432 }
9433 },
9434 {
9435 key: "afterTickToLabelConversion",
9436 value: function afterTickToLabelConversion() {
9437 (0, _helpersSegmentJs.Q)(this.options.afterTickToLabelConversion, [
9438 this
9439 ]);
9440 }
9441 },
9442 {
9443 key: "beforeCalculateLabelRotation",
9444 value: function beforeCalculateLabelRotation() {
9445 (0, _helpersSegmentJs.Q)(this.options.beforeCalculateLabelRotation, [
9446 this
9447 ]);
9448 }
9449 },
9450 {
9451 key: "calculateLabelRotation",
9452 value: function calculateLabelRotation() {
9453 var options = this.options;
9454 var tickOpts = options.ticks;
9455 var numTicks = this.ticks.length;
9456 var minRotation = tickOpts.minRotation || 0;
9457 var maxRotation = tickOpts.maxRotation;
9458 var labelRotation = minRotation;
9459 var tickWidth, maxHeight, maxLabelDiagonal;
9460 if (!this._isVisible() || !tickOpts.display || minRotation >= maxRotation || numTicks <= 1 || !this.isHorizontal()) {
9461 this.labelRotation = minRotation;
9462 return;
9463 }
9464 var labelSizes = this._getLabelSizes();
9465 var maxLabelWidth = labelSizes.widest.width;
9466 var maxLabelHeight = labelSizes.highest.height;
9467 var maxWidth = (0, _helpersSegmentJs.w)(this.chart.width - maxLabelWidth, 0, this.maxWidth);
9468 tickWidth = options.offset ? this.maxWidth / numTicks : maxWidth / (numTicks - 1);
9469 if (maxLabelWidth + 6 > tickWidth) {
9470 tickWidth = maxWidth / (numTicks - (options.offset ? 0.5 : 1));
9471 maxHeight = this.maxHeight - getTickMarkLength(options.grid) - tickOpts.padding - getTitleHeight(options.title, this.chart.options.font);
9472 maxLabelDiagonal = Math.sqrt(maxLabelWidth * maxLabelWidth + maxLabelHeight * maxLabelHeight);
9473 labelRotation = (0, _helpersSegmentJs.S)(Math.min(Math.asin((0, _helpersSegmentJs.w)((labelSizes.highest.height + 6) / tickWidth, -1, 1)), Math.asin((0, _helpersSegmentJs.w)(maxHeight / maxLabelDiagonal, -1, 1)) - Math.asin((0, _helpersSegmentJs.w)(maxLabelHeight / maxLabelDiagonal, -1, 1))));
9474 labelRotation = Math.max(minRotation, Math.min(maxRotation, labelRotation));
9475 }
9476 this.labelRotation = labelRotation;
9477 }
9478 },
9479 {
9480 key: "afterCalculateLabelRotation",
9481 value: function afterCalculateLabelRotation() {
9482 (0, _helpersSegmentJs.Q)(this.options.afterCalculateLabelRotation, [
9483 this
9484 ]);
9485 }
9486 },
9487 {
9488 key: "afterAutoSkip",
9489 value: function afterAutoSkip() {}
9490 },
9491 {
9492 key: "beforeFit",
9493 value: function beforeFit() {
9494 (0, _helpersSegmentJs.Q)(this.options.beforeFit, [
9495 this
9496 ]);
9497 }
9498 },
9499 {
9500 key: "fit",
9501 value: function fit() {
9502 var minSize = {
9503 width: 0,
9504 height: 0
9505 };
9506 var ref = this, chart = ref.chart, _options = ref.options, tickOpts = _options.ticks, titleOpts = _options.title, gridOpts = _options.grid;
9507 var display = this._isVisible();
9508 var isHorizontal = this.isHorizontal();
9509 if (display) {
9510 var titleHeight = getTitleHeight(titleOpts, chart.options.font);
9511 if (isHorizontal) {
9512 minSize.width = this.maxWidth;
9513 minSize.height = getTickMarkLength(gridOpts) + titleHeight;
9514 } else {
9515 minSize.height = this.maxHeight;
9516 minSize.width = getTickMarkLength(gridOpts) + titleHeight;
9517 }
9518 if (tickOpts.display && this.ticks.length) {
9519 var ref4 = this._getLabelSizes(), first = ref4.first, last = ref4.last, widest = ref4.widest, highest = ref4.highest;
9520 var tickPadding = tickOpts.padding * 2;
9521 var angleRadians = (0, _helpersSegmentJs.t)(this.labelRotation);
9522 var cos = Math.cos(angleRadians);
9523 var sin = Math.sin(angleRadians);
9524 if (isHorizontal) {
9525 var labelHeight = tickOpts.mirror ? 0 : sin * widest.width + cos * highest.height;
9526 minSize.height = Math.min(this.maxHeight, minSize.height + labelHeight + tickPadding);
9527 } else {
9528 var labelWidth = tickOpts.mirror ? 0 : cos * widest.width + sin * highest.height;
9529 minSize.width = Math.min(this.maxWidth, minSize.width + labelWidth + tickPadding);
9530 }
9531 this._calculatePadding(first, last, sin, cos);
9532 }
9533 }
9534 this._handleMargins();
9535 if (isHorizontal) {
9536 this.width = this._length = chart.width - this._margins.left - this._margins.right;
9537 this.height = minSize.height;
9538 } else {
9539 this.width = minSize.width;
9540 this.height = this._length = chart.height - this._margins.top - this._margins.bottom;
9541 }
9542 }
9543 },
9544 {
9545 key: "_calculatePadding",
9546 value: function _calculatePadding(first, last, sin, cos) {
9547 var _options = this.options, _ticks = _options.ticks, align = _ticks.align, padding = _ticks.padding, position = _options.position;
9548 var isRotated = this.labelRotation !== 0;
9549 var labelsBelowTicks = position !== "top" && this.axis === "x";
9550 if (this.isHorizontal()) {
9551 var offsetLeft = this.getPixelForTick(0) - this.left;
9552 var offsetRight = this.right - this.getPixelForTick(this.ticks.length - 1);
9553 var paddingLeft = 0;
9554 var paddingRight = 0;
9555 if (isRotated) {
9556 if (labelsBelowTicks) {
9557 paddingLeft = cos * first.width;
9558 paddingRight = sin * last.height;
9559 } else {
9560 paddingLeft = sin * first.height;
9561 paddingRight = cos * last.width;
9562 }
9563 } else if (align === "start") paddingRight = last.width;
9564 else if (align === "end") paddingLeft = first.width;
9565 else if (align !== "inner") {
9566 paddingLeft = first.width / 2;
9567 paddingRight = last.width / 2;
9568 }
9569 this.paddingLeft = Math.max((paddingLeft - offsetLeft + padding) * this.width / (this.width - offsetLeft), 0);
9570 this.paddingRight = Math.max((paddingRight - offsetRight + padding) * this.width / (this.width - offsetRight), 0);
9571 } else {
9572 var paddingTop = last.height / 2;
9573 var paddingBottom = first.height / 2;
9574 if (align === "start") {
9575 paddingTop = 0;
9576 paddingBottom = first.height;
9577 } else if (align === "end") {
9578 paddingTop = last.height;
9579 paddingBottom = 0;
9580 }
9581 this.paddingTop = paddingTop + padding;
9582 this.paddingBottom = paddingBottom + padding;
9583 }
9584 }
9585 },
9586 {
9587 key: "_handleMargins",
9588 value: function _handleMargins() {
9589 if (this._margins) {
9590 this._margins.left = Math.max(this.paddingLeft, this._margins.left);
9591 this._margins.top = Math.max(this.paddingTop, this._margins.top);
9592 this._margins.right = Math.max(this.paddingRight, this._margins.right);
9593 this._margins.bottom = Math.max(this.paddingBottom, this._margins.bottom);
9594 }
9595 }
9596 },
9597 {
9598 key: "afterFit",
9599 value: function afterFit() {
9600 (0, _helpersSegmentJs.Q)(this.options.afterFit, [
9601 this
9602 ]);
9603 }
9604 },
9605 {
9606 key: "isHorizontal",
9607 value: function isHorizontal() {
9608 var _options = this.options, axis = _options.axis, position = _options.position;
9609 return position === "top" || position === "bottom" || axis === "x";
9610 }
9611 },
9612 {
9613 key: "isFullSize",
9614 value: function isFullSize() {
9615 return this.options.fullSize;
9616 }
9617 },
9618 {
9619 key: "_convertTicksToLabels",
9620 value: function _convertTicksToLabels(ticks) {
9621 this.beforeTickToLabelConversion();
9622 this.generateTickLabels(ticks);
9623 var i, ilen;
9624 for(i = 0, ilen = ticks.length; i < ilen; i++)if ((0, _helpersSegmentJs.k)(ticks[i].label)) {
9625 ticks.splice(i, 1);
9626 ilen--;
9627 i--;
9628 }
9629 this.afterTickToLabelConversion();
9630 }
9631 },
9632 {
9633 key: "_getLabelSizes",
9634 value: function _getLabelSizes() {
9635 var labelSizes = this._labelSizes;
9636 if (!labelSizes) {
9637 var sampleSize = this.options.ticks.sampleSize;
9638 var ticks = this.ticks;
9639 if (sampleSize < ticks.length) ticks = sample(ticks, sampleSize);
9640 this._labelSizes = labelSizes = this._computeLabelSizes(ticks, ticks.length);
9641 }
9642 return labelSizes;
9643 }
9644 },
9645 {
9646 key: "_computeLabelSizes",
9647 value: function _computeLabelSizes(ticks, length) {
9648 var ref = this, ctx = ref.ctx, caches = ref._longestTextCache;
9649 var widths = [];
9650 var heights = [];
9651 var widestLabelSize = 0;
9652 var highestLabelSize = 0;
9653 var i, j, jlen, label, tickFont, fontString, cache, lineHeight, width, height, nestedLabel;
9654 for(i = 0; i < length; ++i){
9655 label = ticks[i].label;
9656 tickFont = this._resolveTickFontOptions(i);
9657 ctx.font = fontString = tickFont.string;
9658 cache = caches[fontString] = caches[fontString] || {
9659 data: {},
9660 gc: []
9661 };
9662 lineHeight = tickFont.lineHeight;
9663 width = height = 0;
9664 if (!(0, _helpersSegmentJs.k)(label) && !(0, _helpersSegmentJs.b)(label)) {
9665 width = (0, _helpersSegmentJs.U)(ctx, cache.data, cache.gc, width, label);
9666 height = lineHeight;
9667 } else if ((0, _helpersSegmentJs.b)(label)) for(j = 0, jlen = label.length; j < jlen; ++j){
9668 nestedLabel = label[j];
9669 if (!(0, _helpersSegmentJs.k)(nestedLabel) && !(0, _helpersSegmentJs.b)(nestedLabel)) {
9670 width = (0, _helpersSegmentJs.U)(ctx, cache.data, cache.gc, width, nestedLabel);
9671 height += lineHeight;
9672 }
9673 }
9674 widths.push(width);
9675 heights.push(height);
9676 widestLabelSize = Math.max(width, widestLabelSize);
9677 highestLabelSize = Math.max(height, highestLabelSize);
9678 }
9679 garbageCollect(caches, length);
9680 var widest = widths.indexOf(widestLabelSize);
9681 var highest = heights.indexOf(highestLabelSize);
9682 var valueAt = function(idx) {
9683 return {
9684 width: widths[idx] || 0,
9685 height: heights[idx] || 0
9686 };
9687 };
9688 return {
9689 first: valueAt(0),
9690 last: valueAt(length - 1),
9691 widest: valueAt(widest),
9692 highest: valueAt(highest),
9693 widths: widths,
9694 heights: heights
9695 };
9696 }
9697 },
9698 {
9699 key: "getLabelForValue",
9700 value: function getLabelForValue(value) {
9701 return value;
9702 }
9703 },
9704 {
9705 key: "getPixelForValue",
9706 value: function getPixelForValue(value, index) {
9707 return NaN;
9708 }
9709 },
9710 {
9711 key: "getValueForPixel",
9712 value: function getValueForPixel(pixel) {}
9713 },
9714 {
9715 key: "getPixelForTick",
9716 value: function getPixelForTick(index46) {
9717 var ticks = this.ticks;
9718 if (index46 < 0 || index46 > ticks.length - 1) return null;
9719 return this.getPixelForValue(ticks[index46].value);
9720 }
9721 },
9722 {
9723 key: "getPixelForDecimal",
9724 value: function getPixelForDecimal(decimal) {
9725 if (this._reversePixels) decimal = 1 - decimal;
9726 var pixel = this._startPixel + decimal * this._length;
9727 return (0, _helpersSegmentJs.V)(this._alignToPixels ? (0, _helpersSegmentJs.W)(this.chart, pixel, 0) : pixel);
9728 }
9729 },
9730 {
9731 key: "getDecimalForPixel",
9732 value: function getDecimalForPixel(pixel) {
9733 var decimal = (pixel - this._startPixel) / this._length;
9734 return this._reversePixels ? 1 - decimal : decimal;
9735 }
9736 },
9737 {
9738 key: "getBasePixel",
9739 value: function getBasePixel() {
9740 return this.getPixelForValue(this.getBaseValue());
9741 }
9742 },
9743 {
9744 key: "getBaseValue",
9745 value: function getBaseValue() {
9746 var ref = this, min = ref.min, max = ref.max;
9747 return min < 0 && max < 0 ? max : min > 0 && max > 0 ? min : 0;
9748 }
9749 },
9750 {
9751 key: "getContext",
9752 value: function getContext(index47) {
9753 var ticks = this.ticks || [];
9754 if (index47 >= 0 && index47 < ticks.length) {
9755 var tick = ticks[index47];
9756 return tick.$context || (tick.$context = createTickContext(this.getContext(), index47, tick));
9757 }
9758 return this.$context || (this.$context = createScaleContext(this.chart.getContext(), this));
9759 }
9760 },
9761 {
9762 key: "_tickSize",
9763 value: function _tickSize() {
9764 var optionTicks = this.options.ticks;
9765 var rot = (0, _helpersSegmentJs.t)(this.labelRotation);
9766 var cos = Math.abs(Math.cos(rot));
9767 var sin = Math.abs(Math.sin(rot));
9768 var labelSizes = this._getLabelSizes();
9769 var padding = optionTicks.autoSkipPadding || 0;
9770 var w = labelSizes ? labelSizes.widest.width + padding : 0;
9771 var h = labelSizes ? labelSizes.highest.height + padding : 0;
9772 return this.isHorizontal() ? h * cos > w * sin ? w / cos : h / sin : h * sin < w * cos ? h / cos : w / sin;
9773 }
9774 },
9775 {
9776 key: "_isVisible",
9777 value: function _isVisible() {
9778 var display = this.options.display;
9779 if (display !== "auto") return !!display;
9780 return this.getMatchingVisibleMetas().length > 0;
9781 }
9782 },
9783 {
9784 key: "_computeGridLineItems",
9785 value: function _computeGridLineItems(chartArea) {
9786 var axis = this.axis;
9787 var chart = this.chart;
9788 var options = this.options;
9789 var grid = options.grid, position = options.position;
9790 var offset = grid.offset;
9791 var isHorizontal = this.isHorizontal();
9792 var ticks = this.ticks;
9793 var ticksLength = ticks.length + (offset ? 1 : 0);
9794 var tl = getTickMarkLength(grid);
9795 var items = [];
9796 var borderOpts = grid.setContext(this.getContext());
9797 var axisWidth = borderOpts.drawBorder ? borderOpts.borderWidth : 0;
9798 var axisHalfWidth = axisWidth / 2;
9799 var alignBorderValue = function alignBorderValue(pixel) {
9800 return (0, _helpersSegmentJs.W)(chart, pixel, axisWidth);
9801 };
9802 var borderValue, i, lineValue, alignedLineValue;
9803 var tx1, ty1, tx2, ty2, x1, y1, x2, y2;
9804 if (position === "top") {
9805 borderValue = alignBorderValue(this.bottom);
9806 ty1 = this.bottom - tl;
9807 ty2 = borderValue - axisHalfWidth;
9808 y1 = alignBorderValue(chartArea.top) + axisHalfWidth;
9809 y2 = chartArea.bottom;
9810 } else if (position === "bottom") {
9811 borderValue = alignBorderValue(this.top);
9812 y1 = chartArea.top;
9813 y2 = alignBorderValue(chartArea.bottom) - axisHalfWidth;
9814 ty1 = borderValue + axisHalfWidth;
9815 ty2 = this.top + tl;
9816 } else if (position === "left") {
9817 borderValue = alignBorderValue(this.right);
9818 tx1 = this.right - tl;
9819 tx2 = borderValue - axisHalfWidth;
9820 x1 = alignBorderValue(chartArea.left) + axisHalfWidth;
9821 x2 = chartArea.right;
9822 } else if (position === "right") {
9823 borderValue = alignBorderValue(this.left);
9824 x1 = chartArea.left;
9825 x2 = alignBorderValue(chartArea.right) - axisHalfWidth;
9826 tx1 = borderValue + axisHalfWidth;
9827 tx2 = this.left + tl;
9828 } else if (axis === "x") {
9829 if (position === "center") borderValue = alignBorderValue((chartArea.top + chartArea.bottom) / 2 + 0.5);
9830 else if ((0, _helpersSegmentJs.i)(position)) {
9831 var positionAxisID = Object.keys(position)[0];
9832 var value = position[positionAxisID];
9833 borderValue = alignBorderValue(this.chart.scales[positionAxisID].getPixelForValue(value));
9834 }
9835 y1 = chartArea.top;
9836 y2 = chartArea.bottom;
9837 ty1 = borderValue + axisHalfWidth;
9838 ty2 = ty1 + tl;
9839 } else if (axis === "y") {
9840 if (position === "center") borderValue = alignBorderValue((chartArea.left + chartArea.right) / 2);
9841 else if ((0, _helpersSegmentJs.i)(position)) {
9842 var positionAxisID2 = Object.keys(position)[0];
9843 var value2 = position[positionAxisID2];
9844 borderValue = alignBorderValue(this.chart.scales[positionAxisID2].getPixelForValue(value2));
9845 }
9846 tx1 = borderValue - axisHalfWidth;
9847 tx2 = tx1 - tl;
9848 x1 = chartArea.left;
9849 x2 = chartArea.right;
9850 }
9851 var limit = (0, _helpersSegmentJs.v)(options.ticks.maxTicksLimit, ticksLength);
9852 var step = Math.max(1, Math.ceil(ticksLength / limit));
9853 for(i = 0; i < ticksLength; i += step){
9854 var optsAtIndex = grid.setContext(this.getContext(i));
9855 var lineWidth = optsAtIndex.lineWidth;
9856 var lineColor = optsAtIndex.color;
9857 var borderDash = grid.borderDash || [];
9858 var borderDashOffset = optsAtIndex.borderDashOffset;
9859 var tickWidth = optsAtIndex.tickWidth;
9860 var tickColor = optsAtIndex.tickColor;
9861 var tickBorderDash = optsAtIndex.tickBorderDash || [];
9862 var tickBorderDashOffset = optsAtIndex.tickBorderDashOffset;
9863 lineValue = getPixelForGridLine(this, i, offset);
9864 if (lineValue === undefined) continue;
9865 alignedLineValue = (0, _helpersSegmentJs.W)(chart, lineValue, lineWidth);
9866 if (isHorizontal) tx1 = tx2 = x1 = x2 = alignedLineValue;
9867 else ty1 = ty2 = y1 = y2 = alignedLineValue;
9868 items.push({
9869 tx1: tx1,
9870 ty1: ty1,
9871 tx2: tx2,
9872 ty2: ty2,
9873 x1: x1,
9874 y1: y1,
9875 x2: x2,
9876 y2: y2,
9877 width: lineWidth,
9878 color: lineColor,
9879 borderDash: borderDash,
9880 borderDashOffset: borderDashOffset,
9881 tickWidth: tickWidth,
9882 tickColor: tickColor,
9883 tickBorderDash: tickBorderDash,
9884 tickBorderDashOffset: tickBorderDashOffset
9885 });
9886 }
9887 this._ticksLength = ticksLength;
9888 this._borderValue = borderValue;
9889 return items;
9890 }
9891 },
9892 {
9893 key: "_computeLabelItems",
9894 value: function _computeLabelItems(chartArea) {
9895 var axis = this.axis;
9896 var options = this.options;
9897 var position = options.position, optionTicks = options.ticks;
9898 var isHorizontal = this.isHorizontal();
9899 var ticks = this.ticks;
9900 var align = optionTicks.align, crossAlign = optionTicks.crossAlign, padding = optionTicks.padding, mirror = optionTicks.mirror;
9901 var tl = getTickMarkLength(options.grid);
9902 var tickAndPadding = tl + padding;
9903 var hTickAndPadding = mirror ? -padding : tickAndPadding;
9904 var rotation = -(0, _helpersSegmentJs.t)(this.labelRotation);
9905 var items = [];
9906 var i, ilen, tick, label, x, y, textAlign, pixel, font, lineHeight, lineCount, textOffset;
9907 var textBaseline = "middle";
9908 if (position === "top") {
9909 y = this.bottom - hTickAndPadding;
9910 textAlign = this._getXAxisLabelAlignment();
9911 } else if (position === "bottom") {
9912 y = this.top + hTickAndPadding;
9913 textAlign = this._getXAxisLabelAlignment();
9914 } else if (position === "left") {
9915 var ret = this._getYAxisLabelAlignment(tl);
9916 textAlign = ret.textAlign;
9917 x = ret.x;
9918 } else if (position === "right") {
9919 var ret1 = this._getYAxisLabelAlignment(tl);
9920 textAlign = ret1.textAlign;
9921 x = ret1.x;
9922 } else if (axis === "x") {
9923 if (position === "center") y = (chartArea.top + chartArea.bottom) / 2 + tickAndPadding;
9924 else if ((0, _helpersSegmentJs.i)(position)) {
9925 var positionAxisID = Object.keys(position)[0];
9926 var value = position[positionAxisID];
9927 y = this.chart.scales[positionAxisID].getPixelForValue(value) + tickAndPadding;
9928 }
9929 textAlign = this._getXAxisLabelAlignment();
9930 } else if (axis === "y") {
9931 if (position === "center") x = (chartArea.left + chartArea.right) / 2 - tickAndPadding;
9932 else if ((0, _helpersSegmentJs.i)(position)) {
9933 var positionAxisID3 = Object.keys(position)[0];
9934 var value3 = position[positionAxisID3];
9935 x = this.chart.scales[positionAxisID3].getPixelForValue(value3);
9936 }
9937 textAlign = this._getYAxisLabelAlignment(tl).textAlign;
9938 }
9939 if (axis === "y") {
9940 if (align === "start") textBaseline = "top";
9941 else if (align === "end") textBaseline = "bottom";
9942 }
9943 var labelSizes = this._getLabelSizes();
9944 for(i = 0, ilen = ticks.length; i < ilen; ++i){
9945 tick = ticks[i];
9946 label = tick.label;
9947 var optsAtIndex = optionTicks.setContext(this.getContext(i));
9948 pixel = this.getPixelForTick(i) + optionTicks.labelOffset;
9949 font = this._resolveTickFontOptions(i);
9950 lineHeight = font.lineHeight;
9951 lineCount = (0, _helpersSegmentJs.b)(label) ? label.length : 1;
9952 var halfCount = lineCount / 2;
9953 var color = optsAtIndex.color;
9954 var strokeColor = optsAtIndex.textStrokeColor;
9955 var strokeWidth = optsAtIndex.textStrokeWidth;
9956 var tickTextAlign = textAlign;
9957 if (isHorizontal) {
9958 x = pixel;
9959 if (textAlign === "inner") {
9960 if (i === ilen - 1) tickTextAlign = !this.options.reverse ? "right" : "left";
9961 else if (i === 0) tickTextAlign = !this.options.reverse ? "left" : "right";
9962 else tickTextAlign = "center";
9963 }
9964 if (position === "top") {
9965 if (crossAlign === "near" || rotation !== 0) textOffset = -lineCount * lineHeight + lineHeight / 2;
9966 else if (crossAlign === "center") textOffset = -labelSizes.highest.height / 2 - halfCount * lineHeight + lineHeight;
9967 else textOffset = -labelSizes.highest.height + lineHeight / 2;
9968 } else {
9969 if (crossAlign === "near" || rotation !== 0) textOffset = lineHeight / 2;
9970 else if (crossAlign === "center") textOffset = labelSizes.highest.height / 2 - halfCount * lineHeight;
9971 else textOffset = labelSizes.highest.height - lineCount * lineHeight;
9972 }
9973 if (mirror) textOffset *= -1;
9974 } else {
9975 y = pixel;
9976 textOffset = (1 - lineCount) * lineHeight / 2;
9977 }
9978 var backdrop = void 0;
9979 if (optsAtIndex.showLabelBackdrop) {
9980 var labelPadding = (0, _helpersSegmentJs.D)(optsAtIndex.backdropPadding);
9981 var height = labelSizes.heights[i];
9982 var width = labelSizes.widths[i];
9983 var top = y + textOffset - labelPadding.top;
9984 var left = x - labelPadding.left;
9985 switch(textBaseline){
9986 case "middle":
9987 top -= height / 2;
9988 break;
9989 case "bottom":
9990 top -= height;
9991 break;
9992 }
9993 switch(textAlign){
9994 case "center":
9995 left -= width / 2;
9996 break;
9997 case "right":
9998 left -= width;
9999 break;
10000 }
10001 backdrop = {
10002 left: left,
10003 top: top,
10004 width: width + labelPadding.width,
10005 height: height + labelPadding.height,
10006 color: optsAtIndex.backdropColor
10007 };
10008 }
10009 items.push({
10010 rotation: rotation,
10011 label: label,
10012 font: font,
10013 color: color,
10014 strokeColor: strokeColor,
10015 strokeWidth: strokeWidth,
10016 textOffset: textOffset,
10017 textAlign: tickTextAlign,
10018 textBaseline: textBaseline,
10019 translation: [
10020 x,
10021 y
10022 ],
10023 backdrop: backdrop
10024 });
10025 }
10026 return items;
10027 }
10028 },
10029 {
10030 key: "_getXAxisLabelAlignment",
10031 value: function _getXAxisLabelAlignment() {
10032 var _options = this.options, position = _options.position, ticks = _options.ticks;
10033 var rotation = -(0, _helpersSegmentJs.t)(this.labelRotation);
10034 if (rotation) return position === "top" ? "left" : "right";
10035 var align = "center";
10036 if (ticks.align === "start") align = "left";
10037 else if (ticks.align === "end") align = "right";
10038 else if (ticks.align === "inner") align = "inner";
10039 return align;
10040 }
10041 },
10042 {
10043 key: "_getYAxisLabelAlignment",
10044 value: function _getYAxisLabelAlignment(tl) {
10045 var _options = this.options, position = _options.position, _ticks = _options.ticks, crossAlign = _ticks.crossAlign, mirror = _ticks.mirror, padding = _ticks.padding;
10046 var labelSizes = this._getLabelSizes();
10047 var tickAndPadding = tl + padding;
10048 var widest = labelSizes.widest.width;
10049 var textAlign;
10050 var x;
10051 if (position === "left") {
10052 if (mirror) {
10053 x = this.right + padding;
10054 if (crossAlign === "near") textAlign = "left";
10055 else if (crossAlign === "center") {
10056 textAlign = "center";
10057 x += widest / 2;
10058 } else {
10059 textAlign = "right";
10060 x += widest;
10061 }
10062 } else {
10063 x = this.right - tickAndPadding;
10064 if (crossAlign === "near") textAlign = "right";
10065 else if (crossAlign === "center") {
10066 textAlign = "center";
10067 x -= widest / 2;
10068 } else {
10069 textAlign = "left";
10070 x = this.left;
10071 }
10072 }
10073 } else if (position === "right") {
10074 if (mirror) {
10075 x = this.left + padding;
10076 if (crossAlign === "near") textAlign = "right";
10077 else if (crossAlign === "center") {
10078 textAlign = "center";
10079 x -= widest / 2;
10080 } else {
10081 textAlign = "left";
10082 x -= widest;
10083 }
10084 } else {
10085 x = this.left + tickAndPadding;
10086 if (crossAlign === "near") textAlign = "left";
10087 else if (crossAlign === "center") {
10088 textAlign = "center";
10089 x += widest / 2;
10090 } else {
10091 textAlign = "right";
10092 x = this.right;
10093 }
10094 }
10095 } else textAlign = "right";
10096 return {
10097 textAlign: textAlign,
10098 x: x
10099 };
10100 }
10101 },
10102 {
10103 key: "_computeLabelArea",
10104 value: function _computeLabelArea() {
10105 if (this.options.ticks.mirror) return;
10106 var chart = this.chart;
10107 var position = this.options.position;
10108 if (position === "left" || position === "right") return {
10109 top: 0,
10110 left: this.left,
10111 bottom: chart.height,
10112 right: this.right
10113 };
10114 if (position === "top" || position === "bottom") return {
10115 top: this.top,
10116 left: 0,
10117 bottom: this.bottom,
10118 right: chart.width
10119 };
10120 }
10121 },
10122 {
10123 key: "drawBackground",
10124 value: function drawBackground() {
10125 var ref = this, ctx = ref.ctx, backgroundColor = ref.options.backgroundColor, left = ref.left, top = ref.top, width = ref.width, height = ref.height;
10126 if (backgroundColor) {
10127 ctx.save();
10128 ctx.fillStyle = backgroundColor;
10129 ctx.fillRect(left, top, width, height);
10130 ctx.restore();
10131 }
10132 }
10133 },
10134 {
10135 key: "getLineWidthForValue",
10136 value: function getLineWidthForValue(value) {
10137 var grid = this.options.grid;
10138 if (!this._isVisible() || !grid.display) return 0;
10139 var ticks = this.ticks;
10140 var index48 = ticks.findIndex(function(t) {
10141 return t.value === value;
10142 });
10143 if (index48 >= 0) {
10144 var opts = grid.setContext(this.getContext(index48));
10145 return opts.lineWidth;
10146 }
10147 return 0;
10148 }
10149 },
10150 {
10151 key: "drawGrid",
10152 value: function drawGrid(chartArea) {
10153 var grid = this.options.grid;
10154 var ctx = this.ctx;
10155 var items = this._gridLineItems || (this._gridLineItems = this._computeGridLineItems(chartArea));
10156 var i, ilen;
10157 var drawLine = function(p1, p2, style) {
10158 if (!style.width || !style.color) return;
10159 ctx.save();
10160 ctx.lineWidth = style.width;
10161 ctx.strokeStyle = style.color;
10162 ctx.setLineDash(style.borderDash || []);
10163 ctx.lineDashOffset = style.borderDashOffset;
10164 ctx.beginPath();
10165 ctx.moveTo(p1.x, p1.y);
10166 ctx.lineTo(p2.x, p2.y);
10167 ctx.stroke();
10168 ctx.restore();
10169 };
10170 if (grid.display) for(i = 0, ilen = items.length; i < ilen; ++i){
10171 var item = items[i];
10172 if (grid.drawOnChartArea) drawLine({
10173 x: item.x1,
10174 y: item.y1
10175 }, {
10176 x: item.x2,
10177 y: item.y2
10178 }, item);
10179 if (grid.drawTicks) drawLine({
10180 x: item.tx1,
10181 y: item.ty1
10182 }, {
10183 x: item.tx2,
10184 y: item.ty2
10185 }, {
10186 color: item.tickColor,
10187 width: item.tickWidth,
10188 borderDash: item.tickBorderDash,
10189 borderDashOffset: item.tickBorderDashOffset
10190 });
10191 }
10192 }
10193 },
10194 {
10195 key: "drawBorder",
10196 value: function drawBorder() {
10197 var ref = this, chart = ref.chart, ctx = ref.ctx, grid = ref.options.grid;
10198 var borderOpts = grid.setContext(this.getContext());
10199 var axisWidth = grid.drawBorder ? borderOpts.borderWidth : 0;
10200 if (!axisWidth) return;
10201 var lastLineWidth = grid.setContext(this.getContext(0)).lineWidth;
10202 var borderValue = this._borderValue;
10203 var x1, x2, y1, y2;
10204 if (this.isHorizontal()) {
10205 x1 = (0, _helpersSegmentJs.W)(chart, this.left, axisWidth) - axisWidth / 2;
10206 x2 = (0, _helpersSegmentJs.W)(chart, this.right, lastLineWidth) + lastLineWidth / 2;
10207 y1 = y2 = borderValue;
10208 } else {
10209 y1 = (0, _helpersSegmentJs.W)(chart, this.top, axisWidth) - axisWidth / 2;
10210 y2 = (0, _helpersSegmentJs.W)(chart, this.bottom, lastLineWidth) + lastLineWidth / 2;
10211 x1 = x2 = borderValue;
10212 }
10213 ctx.save();
10214 ctx.lineWidth = borderOpts.borderWidth;
10215 ctx.strokeStyle = borderOpts.borderColor;
10216 ctx.beginPath();
10217 ctx.moveTo(x1, y1);
10218 ctx.lineTo(x2, y2);
10219 ctx.stroke();
10220 ctx.restore();
10221 }
10222 },
10223 {
10224 key: "drawLabels",
10225 value: function drawLabels(chartArea) {
10226 var optionTicks = this.options.ticks;
10227 if (!optionTicks.display) return;
10228 var ctx = this.ctx;
10229 var area = this._computeLabelArea();
10230 if (area) (0, _helpersSegmentJs.X)(ctx, area);
10231 var items = this._labelItems || (this._labelItems = this._computeLabelItems(chartArea));
10232 var i, ilen;
10233 for(i = 0, ilen = items.length; i < ilen; ++i){
10234 var item = items[i];
10235 var tickFont = item.font;
10236 var label = item.label;
10237 if (item.backdrop) {
10238 ctx.fillStyle = item.backdrop.color;
10239 ctx.fillRect(item.backdrop.left, item.backdrop.top, item.backdrop.width, item.backdrop.height);
10240 }
10241 var y = item.textOffset;
10242 (0, _helpersSegmentJs.Y)(ctx, label, 0, y, tickFont, item);
10243 }
10244 if (area) (0, _helpersSegmentJs.Z)(ctx);
10245 }
10246 },
10247 {
10248 key: "drawTitle",
10249 value: function drawTitle() {
10250 var ref = this, ctx = ref.ctx, _options = ref.options, position = _options.position, title = _options.title, reverse = _options.reverse;
10251 if (!title.display) return;
10252 var font = (0, _helpersSegmentJs.$)(title.font);
10253 var padding = (0, _helpersSegmentJs.D)(title.padding);
10254 var align = title.align;
10255 var offset = font.lineHeight / 2;
10256 if (position === "bottom" || position === "center" || (0, _helpersSegmentJs.i)(position)) {
10257 offset += padding.bottom;
10258 if ((0, _helpersSegmentJs.b)(title.text)) offset += font.lineHeight * (title.text.length - 1);
10259 } else offset += padding.top;
10260 var ref5 = titleArgs(this, offset, position, align), titleX = ref5.titleX, titleY = ref5.titleY, maxWidth = ref5.maxWidth, rotation = ref5.rotation;
10261 (0, _helpersSegmentJs.Y)(ctx, title.text, 0, 0, font, {
10262 color: title.color,
10263 maxWidth: maxWidth,
10264 rotation: rotation,
10265 textAlign: titleAlign(align, position, reverse),
10266 textBaseline: "middle",
10267 translation: [
10268 titleX,
10269 titleY
10270 ]
10271 });
10272 }
10273 },
10274 {
10275 key: "draw",
10276 value: function draw2(chartArea) {
10277 if (!this._isVisible()) return;
10278 this.drawBackground();
10279 this.drawGrid(chartArea);
10280 this.drawBorder();
10281 this.drawTitle();
10282 this.drawLabels(chartArea);
10283 }
10284 },
10285 {
10286 key: "_layers",
10287 value: function _layers() {
10288 var _this = this;
10289 var opts = this.options;
10290 var tz = opts.ticks && opts.ticks.z || 0;
10291 var gz = (0, _helpersSegmentJs.v)(opts.grid && opts.grid.z, -1);
10292 if (!this._isVisible() || this.draw !== Scale.prototype.draw) return [
10293 {
10294 z: tz,
10295 draw: function(chartArea) {
10296 _this.draw(chartArea);
10297 }
10298 }
10299 ];
10300 return [
10301 {
10302 z: gz,
10303 draw: function(chartArea) {
10304 _this.drawBackground();
10305 _this.drawGrid(chartArea);
10306 _this.drawTitle();
10307 }
10308 },
10309 {
10310 z: gz + 1,
10311 draw: function() {
10312 _this.drawBorder();
10313 }
10314 },
10315 {
10316 z: tz,
10317 draw: function(chartArea) {
10318 _this.drawLabels(chartArea);
10319 }
10320 }
10321 ];
10322 }
10323 },
10324 {
10325 key: "getMatchingVisibleMetas",
10326 value: function getMatchingVisibleMetas(type) {
10327 var metas = this.chart.getSortedVisibleDatasetMetas();
10328 var axisID = this.axis + "AxisID";
10329 var result = [];
10330 var i, ilen;
10331 for(i = 0, ilen = metas.length; i < ilen; ++i){
10332 var meta = metas[i];
10333 if (meta[axisID] === this.id && (!type || meta.type === type)) result.push(meta);
10334 }
10335 return result;
10336 }
10337 },
10338 {
10339 key: "_resolveTickFontOptions",
10340 value: function _resolveTickFontOptions(index49) {
10341 var opts = this.options.ticks.setContext(this.getContext(index49));
10342 return (0, _helpersSegmentJs.$)(opts.font);
10343 }
10344 },
10345 {
10346 key: "_maxDigits",
10347 value: function _maxDigits() {
10348 var fontSize = this._resolveTickFontOptions(0).lineHeight;
10349 return (this.isHorizontal() ? this.width : this.height) / fontSize;
10350 }
10351 }
10352 ]);
10353 return Scale;
10354 }((0, _wrapNativeSuperJsDefault.default)(Element));
10355 var TypedRegistry = /*#__PURE__*/ function() {
10356 "use strict";
10357 function TypedRegistry(type, scope, override) {
10358 (0, _classCallCheckJsDefault.default)(this, TypedRegistry);
10359 this.type = type;
10360 this.scope = scope;
10361 this.override = override;
10362 this.items = Object.create(null);
10363 }
10364 (0, _createClassJsDefault.default)(TypedRegistry, [
10365 {
10366 key: "isForType",
10367 value: function isForType(type) {
10368 return Object.prototype.isPrototypeOf.call(this.type.prototype, type.prototype);
10369 }
10370 },
10371 {
10372 key: "register",
10373 value: function register(item) {
10374 var proto = Object.getPrototypeOf(item);
10375 var parentScope;
10376 if (isIChartComponent(proto)) parentScope = this.register(proto);
10377 var items = this.items;
10378 var id = item.id;
10379 var scope = this.scope + "." + id;
10380 if (!id) throw new Error("class does not have id: " + item);
10381 if (id in items) return scope;
10382 items[id] = item;
10383 registerDefaults(item, scope, parentScope);
10384 if (this.override) (0, _helpersSegmentJs.d).override(item.id, item.overrides);
10385 return scope;
10386 }
10387 },
10388 {
10389 key: "get",
10390 value: function get(id) {
10391 return this.items[id];
10392 }
10393 },
10394 {
10395 key: "unregister",
10396 value: function unregister(item) {
10397 var items = this.items;
10398 var id = item.id;
10399 var scope = this.scope;
10400 if (id in items) delete items[id];
10401 if (scope && id in (0, _helpersSegmentJs.d)[scope]) {
10402 delete (0, _helpersSegmentJs.d)[scope][id];
10403 if (this.override) delete (0, _helpersSegmentJs.a2)[id];
10404 }
10405 }
10406 }
10407 ]);
10408 return TypedRegistry;
10409 }();
10410 function registerDefaults(item, scope, parentScope) {
10411 var itemDefaults = (0, _helpersSegmentJs.a3)(Object.create(null), [
10412 parentScope ? (0, _helpersSegmentJs.d).get(parentScope) : {},
10413 (0, _helpersSegmentJs.d).get(scope),
10414 item.defaults
10415 ]);
10416 (0, _helpersSegmentJs.d).set(scope, itemDefaults);
10417 if (item.defaultRoutes) routeDefaults(scope, item.defaultRoutes);
10418 if (item.descriptors) (0, _helpersSegmentJs.d).describe(scope, item.descriptors);
10419 }
10420 function routeDefaults(scope, routes) {
10421 Object.keys(routes).forEach(function(property) {
10422 var propertyParts = property.split(".");
10423 var sourceName = propertyParts.pop();
10424 var sourceScope = [
10425 scope
10426 ].concat(propertyParts).join(".");
10427 var parts = routes[property].split(".");
10428 var targetName = parts.pop();
10429 var targetScope = parts.join(".");
10430 (0, _helpersSegmentJs.d).route(sourceScope, sourceName, targetScope, targetName);
10431 });
10432 }
10433 function isIChartComponent(proto) {
10434 return "id" in proto && "defaults" in proto;
10435 }
10436 var Registry = /*#__PURE__*/ function() {
10437 "use strict";
10438 function Registry() {
10439 (0, _classCallCheckJsDefault.default)(this, Registry);
10440 this.controllers = new TypedRegistry(DatasetController, "datasets", true);
10441 this.elements = new TypedRegistry(Element, "elements");
10442 this.plugins = new TypedRegistry(Object, "plugins");
10443 this.scales = new TypedRegistry(Scale, "scales");
10444 this._typedRegistries = [
10445 this.controllers,
10446 this.scales,
10447 this.elements
10448 ];
10449 }
10450 (0, _createClassJsDefault.default)(Registry, [
10451 {
10452 key: "add",
10453 value: function add() {
10454 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
10455 args[_key] = arguments[_key];
10456 }
10457 this._each("register", args);
10458 }
10459 },
10460 {
10461 key: "remove",
10462 value: function remove() {
10463 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
10464 args[_key] = arguments[_key];
10465 }
10466 this._each("unregister", args);
10467 }
10468 },
10469 {
10470 key: "addControllers",
10471 value: function addControllers() {
10472 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
10473 args[_key] = arguments[_key];
10474 }
10475 this._each("register", args, this.controllers);
10476 }
10477 },
10478 {
10479 key: "addElements",
10480 value: function addElements() {
10481 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
10482 args[_key] = arguments[_key];
10483 }
10484 this._each("register", args, this.elements);
10485 }
10486 },
10487 {
10488 key: "addPlugins",
10489 value: function addPlugins() {
10490 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
10491 args[_key] = arguments[_key];
10492 }
10493 this._each("register", args, this.plugins);
10494 }
10495 },
10496 {
10497 key: "addScales",
10498 value: function addScales() {
10499 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
10500 args[_key] = arguments[_key];
10501 }
10502 this._each("register", args, this.scales);
10503 }
10504 },
10505 {
10506 key: "getController",
10507 value: function getController(id) {
10508 return this._get(id, this.controllers, "controller");
10509 }
10510 },
10511 {
10512 key: "getElement",
10513 value: function getElement(id) {
10514 return this._get(id, this.elements, "element");
10515 }
10516 },
10517 {
10518 key: "getPlugin",
10519 value: function getPlugin(id) {
10520 return this._get(id, this.plugins, "plugin");
10521 }
10522 },
10523 {
10524 key: "getScale",
10525 value: function getScale(id) {
10526 return this._get(id, this.scales, "scale");
10527 }
10528 },
10529 {
10530 key: "removeControllers",
10531 value: function removeControllers() {
10532 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
10533 args[_key] = arguments[_key];
10534 }
10535 this._each("unregister", args, this.controllers);
10536 }
10537 },
10538 {
10539 key: "removeElements",
10540 value: function removeElements() {
10541 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
10542 args[_key] = arguments[_key];
10543 }
10544 this._each("unregister", args, this.elements);
10545 }
10546 },
10547 {
10548 key: "removePlugins",
10549 value: function removePlugins() {
10550 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
10551 args[_key] = arguments[_key];
10552 }
10553 this._each("unregister", args, this.plugins);
10554 }
10555 },
10556 {
10557 key: "removeScales",
10558 value: function removeScales() {
10559 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
10560 args[_key] = arguments[_key];
10561 }
10562 this._each("unregister", args, this.scales);
10563 }
10564 },
10565 {
10566 key: "_each",
10567 value: function _each(method, args, typedRegistry) {
10568 var _this = this;
10569 (0, _toConsumableArrayJsDefault.default)(args).forEach(function(arg) {
10570 var _this1 = _this;
10571 var reg = typedRegistry || _this._getRegistryForType(arg);
10572 if (typedRegistry || reg.isForType(arg) || reg === _this.plugins && arg.id) _this._exec(method, reg, arg);
10573 else (0, _helpersSegmentJs.E)(arg, function(item) {
10574 var itemReg = typedRegistry || _this1._getRegistryForType(item);
10575 _this1._exec(method, itemReg, item);
10576 });
10577 });
10578 }
10579 },
10580 {
10581 key: "_exec",
10582 value: function _exec(method, registry1, component) {
10583 var camelMethod = (0, _helpersSegmentJs.a4)(method);
10584 (0, _helpersSegmentJs.Q)(component["before" + camelMethod], [], component);
10585 registry1[method](component);
10586 (0, _helpersSegmentJs.Q)(component["after" + camelMethod], [], component);
10587 }
10588 },
10589 {
10590 key: "_getRegistryForType",
10591 value: function _getRegistryForType(type) {
10592 for(var i = 0; i < this._typedRegistries.length; i++){
10593 var reg = this._typedRegistries[i];
10594 if (reg.isForType(type)) return reg;
10595 }
10596 return this.plugins;
10597 }
10598 },
10599 {
10600 key: "_get",
10601 value: function _get(id, typedRegistry, type) {
10602 var item = typedRegistry.get(id);
10603 if (item === undefined) throw new Error('"' + id + '" is not a registered ' + type + ".");
10604 return item;
10605 }
10606 }
10607 ]);
10608 return Registry;
10609 }();
10610 var registry = new Registry();
10611 var PluginService = /*#__PURE__*/ function() {
10612 "use strict";
10613 function PluginService() {
10614 (0, _classCallCheckJsDefault.default)(this, PluginService);
10615 this._init = [];
10616 }
10617 (0, _createClassJsDefault.default)(PluginService, [
10618 {
10619 key: "notify",
10620 value: function notify(chart, hook, args, filter) {
10621 if (hook === "beforeInit") {
10622 this._init = this._createDescriptors(chart, true);
10623 this._notify(this._init, chart, "install");
10624 }
10625 var descriptors = filter ? this._descriptors(chart).filter(filter) : this._descriptors(chart);
10626 var result = this._notify(descriptors, chart, hook, args);
10627 if (hook === "afterDestroy") {
10628 this._notify(descriptors, chart, "stop");
10629 this._notify(this._init, chart, "uninstall");
10630 }
10631 return result;
10632 }
10633 },
10634 {
10635 key: "_notify",
10636 value: function _notify(descriptors, chart, hook, args) {
10637 args = args || {};
10638 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
10639 try {
10640 for(var _iterator = descriptors[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
10641 var descriptor = _step.value;
10642 var plugin = descriptor.plugin;
10643 var method = plugin[hook];
10644 var params = [
10645 chart,
10646 args,
10647 descriptor.options
10648 ];
10649 if ((0, _helpersSegmentJs.Q)(method, params, plugin) === false && args.cancelable) return false;
10650 }
10651 } catch (err) {
10652 _didIteratorError = true;
10653 _iteratorError = err;
10654 } finally{
10655 try {
10656 if (!_iteratorNormalCompletion && _iterator.return != null) {
10657 _iterator.return();
10658 }
10659 } finally{
10660 if (_didIteratorError) {
10661 throw _iteratorError;
10662 }
10663 }
10664 }
10665 return true;
10666 }
10667 },
10668 {
10669 key: "invalidate",
10670 value: function invalidate() {
10671 if (!(0, _helpersSegmentJs.k)(this._cache)) {
10672 this._oldCache = this._cache;
10673 this._cache = undefined;
10674 }
10675 }
10676 },
10677 {
10678 key: "_descriptors",
10679 value: function _descriptors(chart) {
10680 if (this._cache) return this._cache;
10681 var descriptors = this._cache = this._createDescriptors(chart);
10682 this._notifyStateChanges(chart);
10683 return descriptors;
10684 }
10685 },
10686 {
10687 key: "_createDescriptors",
10688 value: function _createDescriptors(chart, all) {
10689 var config = chart && chart.config;
10690 var options = (0, _helpersSegmentJs.v)(config.options && config.options.plugins, {});
10691 var plugins1 = allPlugins(config);
10692 return options === false && !all ? [] : createDescriptors(chart, plugins1, options, all);
10693 }
10694 },
10695 {
10696 key: "_notifyStateChanges",
10697 value: function _notifyStateChanges(chart) {
10698 var previousDescriptors = this._oldCache || [];
10699 var descriptors = this._cache;
10700 var diff = function(a, b) {
10701 return a.filter(function(x) {
10702 return !b.some(function(y) {
10703 return x.plugin.id === y.plugin.id;
10704 });
10705 });
10706 };
10707 this._notify(diff(previousDescriptors, descriptors), chart, "stop");
10708 this._notify(diff(descriptors, previousDescriptors), chart, "start");
10709 }
10710 }
10711 ]);
10712 return PluginService;
10713 }();
10714 function allPlugins(config) {
10715 var plugins2 = [];
10716 var keys = Object.keys(registry.plugins.items);
10717 for(var i = 0; i < keys.length; i++)plugins2.push(registry.getPlugin(keys[i]));
10718 var local = config.plugins || [];
10719 for(var i3 = 0; i3 < local.length; i3++){
10720 var plugin = local[i3];
10721 if (plugins2.indexOf(plugin) === -1) plugins2.push(plugin);
10722 }
10723 return plugins2;
10724 }
10725 function getOpts(options, all) {
10726 if (!all && options === false) return null;
10727 if (options === true) return {};
10728 return options;
10729 }
10730 function createDescriptors(chart, plugins3, options, all) {
10731 var result = [];
10732 var context = chart.getContext();
10733 for(var i = 0; i < plugins3.length; i++){
10734 var plugin = plugins3[i];
10735 var id = plugin.id;
10736 var opts = getOpts(options[id], all);
10737 if (opts === null) continue;
10738 result.push({
10739 plugin: plugin,
10740 options: pluginOpts(chart.config, plugin, opts, context)
10741 });
10742 }
10743 return result;
10744 }
10745 function pluginOpts(config, plugin, opts, context) {
10746 var keys = config.pluginScopeKeys(plugin);
10747 var scopes = config.getOptionScopes(opts, keys);
10748 return config.createResolver(scopes, context, [
10749 ""
10750 ], {
10751 scriptable: false,
10752 indexable: false,
10753 allKeys: true
10754 });
10755 }
10756 function getIndexAxis(type, options) {
10757 var datasetDefaults = (0, _helpersSegmentJs.d).datasets[type] || {};
10758 var datasetOptions = (options.datasets || {})[type] || {};
10759 return datasetOptions.indexAxis || options.indexAxis || datasetDefaults.indexAxis || "x";
10760 }
10761 function getAxisFromDefaultScaleID(id, indexAxis) {
10762 var axis = id;
10763 if (id === "_index_") axis = indexAxis;
10764 else if (id === "_value_") axis = indexAxis === "x" ? "y" : "x";
10765 return axis;
10766 }
10767 function getDefaultScaleIDFromAxis(axis, indexAxis) {
10768 return axis === indexAxis ? "_index_" : "_value_";
10769 }
10770 function axisFromPosition(position) {
10771 if (position === "top" || position === "bottom") return "x";
10772 if (position === "left" || position === "right") return "y";
10773 }
10774 function determineAxis(id, scaleOptions) {
10775 if (id === "x" || id === "y") return id;
10776 return scaleOptions.axis || axisFromPosition(scaleOptions.position) || id.charAt(0).toLowerCase();
10777 }
10778 function mergeScaleConfig(config, options) {
10779 var chartDefaults = (0, _helpersSegmentJs.a2)[config.type] || {
10780 scales: {}
10781 };
10782 var configScales = options.scales || {};
10783 var chartIndexAxis = getIndexAxis(config.type, options);
10784 var firstIDs = Object.create(null);
10785 var scales3 = Object.create(null);
10786 Object.keys(configScales).forEach(function(id) {
10787 var scaleConf = configScales[id];
10788 if (!(0, _helpersSegmentJs.i)(scaleConf)) return console.error("Invalid scale configuration for scale: ".concat(id));
10789 if (scaleConf._proxy) return console.warn("Ignoring resolver passed as options for scale: ".concat(id));
10790 var axis = determineAxis(id, scaleConf);
10791 var defaultId = getDefaultScaleIDFromAxis(axis, chartIndexAxis);
10792 var defaultScaleOptions = chartDefaults.scales || {};
10793 firstIDs[axis] = firstIDs[axis] || id;
10794 scales3[id] = (0, _helpersSegmentJs.aa)(Object.create(null), [
10795 {
10796 axis: axis
10797 },
10798 scaleConf,
10799 defaultScaleOptions[axis],
10800 defaultScaleOptions[defaultId]
10801 ]);
10802 });
10803 config.data.datasets.forEach(function(dataset) {
10804 var type = dataset.type || config.type;
10805 var indexAxis = dataset.indexAxis || getIndexAxis(type, options);
10806 var datasetDefaults = (0, _helpersSegmentJs.a2)[type] || {};
10807 var defaultScaleOptions = datasetDefaults.scales || {};
10808 Object.keys(defaultScaleOptions).forEach(function(defaultID) {
10809 var axis = getAxisFromDefaultScaleID(defaultID, indexAxis);
10810 var id = dataset[axis + "AxisID"] || firstIDs[axis] || axis;
10811 scales3[id] = scales3[id] || Object.create(null);
10812 (0, _helpersSegmentJs.aa)(scales3[id], [
10813 {
10814 axis: axis
10815 },
10816 configScales[id],
10817 defaultScaleOptions[defaultID]
10818 ]);
10819 });
10820 });
10821 Object.keys(scales3).forEach(function(key) {
10822 var scale = scales3[key];
10823 (0, _helpersSegmentJs.aa)(scale, [
10824 (0, _helpersSegmentJs.d).scales[scale.type],
10825 (0, _helpersSegmentJs.d).scale
10826 ]);
10827 });
10828 return scales3;
10829 }
10830 function initOptions(config) {
10831 var options = config.options || (config.options = {});
10832 options.plugins = (0, _helpersSegmentJs.v)(options.plugins, {});
10833 options.scales = mergeScaleConfig(config, options);
10834 }
10835 function initData(data) {
10836 data = data || {};
10837 data.datasets = data.datasets || [];
10838 data.labels = data.labels || [];
10839 return data;
10840 }
10841 function initConfig(config) {
10842 config = config || {};
10843 config.data = initData(config.data);
10844 initOptions(config);
10845 return config;
10846 }
10847 var keyCache = new Map();
10848 var keysCached = new Set();
10849 function cachedKeys(cacheKey, generate) {
10850 var keys = keyCache.get(cacheKey);
10851 if (!keys) {
10852 keys = generate();
10853 keyCache.set(cacheKey, keys);
10854 keysCached.add(keys);
10855 }
10856 return keys;
10857 }
10858 var addIfFound = function(set, obj, key) {
10859 var opts = (0, _helpersSegmentJs.f)(obj, key);
10860 if (opts !== undefined) set.add(opts);
10861 };
10862 var Config = /*#__PURE__*/ function() {
10863 "use strict";
10864 function Config(config) {
10865 (0, _classCallCheckJsDefault.default)(this, Config);
10866 this._config = initConfig(config);
10867 this._scopeCache = new Map();
10868 this._resolverCache = new Map();
10869 }
10870 (0, _createClassJsDefault.default)(Config, [
10871 {
10872 key: "platform",
10873 get: function get() {
10874 return this._config.platform;
10875 }
10876 },
10877 {
10878 key: "type",
10879 get: function get() {
10880 return this._config.type;
10881 },
10882 set: function set(type) {
10883 this._config.type = type;
10884 }
10885 },
10886 {
10887 key: "data",
10888 get: function get() {
10889 return this._config.data;
10890 },
10891 set: function set(data) {
10892 this._config.data = initData(data);
10893 }
10894 },
10895 {
10896 key: "options",
10897 get: function get() {
10898 return this._config.options;
10899 },
10900 set: function set(options) {
10901 this._config.options = options;
10902 }
10903 },
10904 {
10905 key: "plugins",
10906 get: function get() {
10907 return this._config.plugins;
10908 }
10909 },
10910 {
10911 key: "update",
10912 value: function update() {
10913 var config = this._config;
10914 this.clearCache();
10915 initOptions(config);
10916 }
10917 },
10918 {
10919 key: "clearCache",
10920 value: function clearCache() {
10921 this._scopeCache.clear();
10922 this._resolverCache.clear();
10923 }
10924 },
10925 {
10926 key: "datasetScopeKeys",
10927 value: function datasetScopeKeys(datasetType) {
10928 return cachedKeys(datasetType, function() {
10929 return [
10930 [
10931 "datasets.".concat(datasetType),
10932 ""
10933 ]
10934 ];
10935 });
10936 }
10937 },
10938 {
10939 key: "datasetAnimationScopeKeys",
10940 value: function datasetAnimationScopeKeys(datasetType, transition) {
10941 return cachedKeys("".concat(datasetType, ".transition.").concat(transition), function() {
10942 return [
10943 [
10944 "datasets.".concat(datasetType, ".transitions.").concat(transition),
10945 "transitions.".concat(transition),
10946 ],
10947 [
10948 "datasets.".concat(datasetType),
10949 ""
10950 ]
10951 ];
10952 });
10953 }
10954 },
10955 {
10956 key: "datasetElementScopeKeys",
10957 value: function datasetElementScopeKeys(datasetType, elementType) {
10958 return cachedKeys("".concat(datasetType, "-").concat(elementType), function() {
10959 return [
10960 [
10961 "datasets.".concat(datasetType, ".elements.").concat(elementType),
10962 "datasets.".concat(datasetType),
10963 "elements.".concat(elementType),
10964 ""
10965 ]
10966 ];
10967 });
10968 }
10969 },
10970 {
10971 key: "pluginScopeKeys",
10972 value: function pluginScopeKeys(plugin) {
10973 var id = plugin.id;
10974 var type = this.type;
10975 return cachedKeys("".concat(type, "-plugin-").concat(id), function() {
10976 return [
10977 [
10978 "plugins.".concat(id),
10979 ].concat((0, _toConsumableArrayJsDefault.default)(plugin.additionalOptionScopes || []))
10980 ];
10981 });
10982 }
10983 },
10984 {
10985 key: "_cachedScopes",
10986 value: function _cachedScopes(mainScope, resetCache) {
10987 var _scopeCache = this._scopeCache;
10988 var cache = _scopeCache.get(mainScope);
10989 if (!cache || resetCache) {
10990 cache = new Map();
10991 _scopeCache.set(mainScope, cache);
10992 }
10993 return cache;
10994 }
10995 },
10996 {
10997 key: "getOptionScopes",
10998 value: function getOptionScopes(mainScope, keyLists, resetCache) {
10999 var ref = this, options = ref.options, type = ref.type;
11000 var cache = this._cachedScopes(mainScope, resetCache);
11001 var cached = cache.get(keyLists);
11002 if (cached) return cached;
11003 var scopes = new Set();
11004 keyLists.forEach(function(keys) {
11005 if (mainScope) {
11006 scopes.add(mainScope);
11007 keys.forEach(function(key) {
11008 return addIfFound(scopes, mainScope, key);
11009 });
11010 }
11011 keys.forEach(function(key) {
11012 return addIfFound(scopes, options, key);
11013 });
11014 keys.forEach(function(key) {
11015 return addIfFound(scopes, (0, _helpersSegmentJs.a2)[type] || {}, key);
11016 });
11017 keys.forEach(function(key) {
11018 return addIfFound(scopes, (0, _helpersSegmentJs.d), key);
11019 });
11020 keys.forEach(function(key) {
11021 return addIfFound(scopes, (0, _helpersSegmentJs.a5), key);
11022 });
11023 });
11024 var array = Array.from(scopes);
11025 if (array.length === 0) array.push(Object.create(null));
11026 if (keysCached.has(keyLists)) cache.set(keyLists, array);
11027 return array;
11028 }
11029 },
11030 {
11031 key: "chartOptionScopes",
11032 value: function chartOptionScopes() {
11033 var ref = this, options = ref.options, type = ref.type;
11034 return [
11035 options,
11036 (0, _helpersSegmentJs.a2)[type] || {},
11037 (0, _helpersSegmentJs.d).datasets[type] || {},
11038 {
11039 type: type
11040 },
11041 (0, _helpersSegmentJs.d),
11042 (0, _helpersSegmentJs.a5)
11043 ];
11044 }
11045 },
11046 {
11047 key: "resolveNamedOptions",
11048 value: function resolveNamedOptions(scopes, names, context) {
11049 var prefixes = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : [
11050 ""
11051 ];
11052 var result = {
11053 $shared: true
11054 };
11055 var ref = getResolver(this._resolverCache, scopes, prefixes), resolver = ref.resolver, subPrefixes = ref.subPrefixes;
11056 var options = resolver;
11057 if (needContext(resolver, names)) {
11058 result.$shared = false;
11059 context = (0, _helpersSegmentJs.a6)(context) ? context() : context;
11060 var subResolver = this.createResolver(scopes, context, subPrefixes);
11061 options = (0, _helpersSegmentJs.a7)(resolver, context, subResolver);
11062 }
11063 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
11064 try {
11065 for(var _iterator = names[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
11066 var prop = _step.value;
11067 result[prop] = options[prop];
11068 }
11069 } catch (err) {
11070 _didIteratorError = true;
11071 _iteratorError = err;
11072 } finally{
11073 try {
11074 if (!_iteratorNormalCompletion && _iterator.return != null) {
11075 _iterator.return();
11076 }
11077 } finally{
11078 if (_didIteratorError) {
11079 throw _iteratorError;
11080 }
11081 }
11082 }
11083 return result;
11084 }
11085 },
11086 {
11087 key: "createResolver",
11088 value: function createResolver(scopes, context) {
11089 var prefixes = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [
11090 ""
11091 ], descriptorDefaults = arguments.length > 3 ? arguments[3] : void 0;
11092 var resolver = getResolver(this._resolverCache, scopes, prefixes).resolver;
11093 return (0, _helpersSegmentJs.i)(context) ? (0, _helpersSegmentJs.a7)(resolver, context, undefined, descriptorDefaults) : resolver;
11094 }
11095 }
11096 ]);
11097 return Config;
11098 }();
11099 function getResolver(resolverCache, scopes, prefixes) {
11100 var cache = resolverCache.get(scopes);
11101 if (!cache) {
11102 cache = new Map();
11103 resolverCache.set(scopes, cache);
11104 }
11105 var cacheKey = prefixes.join();
11106 var cached = cache.get(cacheKey);
11107 if (!cached) {
11108 var resolver = (0, _helpersSegmentJs.a8)(scopes, prefixes);
11109 cached = {
11110 resolver: resolver,
11111 subPrefixes: prefixes.filter(function(p) {
11112 return !p.toLowerCase().includes("hover");
11113 })
11114 };
11115 cache.set(cacheKey, cached);
11116 }
11117 return cached;
11118 }
11119 var hasFunction = function(value) {
11120 return (0, _helpersSegmentJs.i)(value) && Object.getOwnPropertyNames(value).reduce(function(acc, key) {
11121 return acc || (0, _helpersSegmentJs.a6)(value[key]);
11122 }, false);
11123 };
11124 function needContext(proxy, names) {
11125 var ref = (0, _helpersSegmentJs.a9)(proxy), isScriptable = ref.isScriptable, isIndexable = ref.isIndexable;
11126 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
11127 try {
11128 for(var _iterator = names[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
11129 var prop = _step.value;
11130 var scriptable = isScriptable(prop);
11131 var indexable = isIndexable(prop);
11132 var value = (indexable || scriptable) && proxy[prop];
11133 if (scriptable && ((0, _helpersSegmentJs.a6)(value) || hasFunction(value)) || indexable && (0, _helpersSegmentJs.b)(value)) return true;
11134 }
11135 } catch (err) {
11136 _didIteratorError = true;
11137 _iteratorError = err;
11138 } finally{
11139 try {
11140 if (!_iteratorNormalCompletion && _iterator.return != null) {
11141 _iterator.return();
11142 }
11143 } finally{
11144 if (_didIteratorError) {
11145 throw _iteratorError;
11146 }
11147 }
11148 }
11149 return false;
11150 }
11151 var version = "3.8.0";
11152 var KNOWN_POSITIONS = [
11153 "top",
11154 "bottom",
11155 "left",
11156 "right",
11157 "chartArea"
11158 ];
11159 function positionIsHorizontal(position, axis) {
11160 return position === "top" || position === "bottom" || KNOWN_POSITIONS.indexOf(position) === -1 && axis === "x";
11161 }
11162 function compare2Level(l1, l2) {
11163 return function(a, b) {
11164 return a[l1] === b[l1] ? a[l2] - b[l2] : a[l1] - b[l1];
11165 };
11166 }
11167 function onAnimationsComplete(context) {
11168 var chart = context.chart;
11169 var animationOptions1 = chart.options.animation;
11170 chart.notifyPlugins("afterRender");
11171 (0, _helpersSegmentJs.Q)(animationOptions1 && animationOptions1.onComplete, [
11172 context
11173 ], chart);
11174 }
11175 function onAnimationProgress(context) {
11176 var chart = context.chart;
11177 var animationOptions2 = chart.options.animation;
11178 (0, _helpersSegmentJs.Q)(animationOptions2 && animationOptions2.onProgress, [
11179 context
11180 ], chart);
11181 }
11182 function getCanvas(item) {
11183 if ((0, _helpersSegmentJs.L)() && typeof item === "string") item = document.getElementById(item);
11184 else if (item && item.length) item = item[0];
11185 if (item && item.canvas) item = item.canvas;
11186 return item;
11187 }
11188 var instances = {};
11189 var getChart = function(key) {
11190 var canvas = getCanvas(key);
11191 return Object.values(instances).filter(function(c) {
11192 return c.canvas === canvas;
11193 }).pop();
11194 };
11195 function moveNumericKeys(obj, start, move) {
11196 var keys = Object.keys(obj);
11197 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
11198 try {
11199 for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
11200 var key = _step.value;
11201 var intKey = +key;
11202 if (intKey >= start) {
11203 var value = obj[key];
11204 delete obj[key];
11205 if (move > 0 || intKey > start) obj[intKey + move] = value;
11206 }
11207 }
11208 } catch (err) {
11209 _didIteratorError = true;
11210 _iteratorError = err;
11211 } finally{
11212 try {
11213 if (!_iteratorNormalCompletion && _iterator.return != null) {
11214 _iterator.return();
11215 }
11216 } finally{
11217 if (_didIteratorError) {
11218 throw _iteratorError;
11219 }
11220 }
11221 }
11222 }
11223 function determineLastEvent(e, lastEvent, inChartArea, isClick) {
11224 if (!inChartArea || e.type === "mouseout") return null;
11225 if (isClick) return lastEvent;
11226 return e;
11227 }
11228 var Chart = /*#__PURE__*/ function() {
11229 "use strict";
11230 function Chart(item, userConfig) {
11231 var _this = this;
11232 (0, _classCallCheckJsDefault.default)(this, Chart);
11233 var config = this.config = new Config(userConfig);
11234 var initialCanvas = getCanvas(item);
11235 var existingChart = getChart(initialCanvas);
11236 if (existingChart) throw new Error("Canvas is already in use. Chart with ID '" + existingChart.id + "'" + " must be destroyed before the canvas can be reused.");
11237 var options = config.createResolver(config.chartOptionScopes(), this.getContext());
11238 this.platform = new (config.platform || _detectPlatform(initialCanvas))();
11239 this.platform.updateConfig(config);
11240 var context = this.platform.acquireContext(initialCanvas, options.aspectRatio);
11241 var canvas = context && context.canvas;
11242 var height = canvas && canvas.height;
11243 var width = canvas && canvas.width;
11244 this.id = (0, _helpersSegmentJs.ab)();
11245 this.ctx = context;
11246 this.canvas = canvas;
11247 this.width = width;
11248 this.height = height;
11249 this._options = options;
11250 this._aspectRatio = this.aspectRatio;
11251 this._layers = [];
11252 this._metasets = [];
11253 this._stacks = undefined;
11254 this.boxes = [];
11255 this.currentDevicePixelRatio = undefined;
11256 this.chartArea = undefined;
11257 this._active = [];
11258 this._lastEvent = undefined;
11259 this._listeners = {};
11260 this._responsiveListeners = undefined;
11261 this._sortedMetasets = [];
11262 this.scales = {};
11263 this._plugins = new PluginService();
11264 this.$proxies = {};
11265 this._hiddenIndices = {};
11266 this.attached = false;
11267 this._animationsDisabled = undefined;
11268 this.$context = undefined;
11269 this._doResize = (0, _helpersSegmentJs.ac)(function(mode) {
11270 return _this.update(mode);
11271 }, options.resizeDelay || 0);
11272 this._dataChanges = [];
11273 instances[this.id] = this;
11274 if (!context || !canvas) {
11275 console.error("Failed to create chart: can't acquire context from the given item");
11276 return;
11277 }
11278 animator.listen(this, "complete", onAnimationsComplete);
11279 animator.listen(this, "progress", onAnimationProgress);
11280 this._initialize();
11281 if (this.attached) this.update();
11282 }
11283 (0, _createClassJsDefault.default)(Chart, [
11284 {
11285 key: "aspectRatio",
11286 get: function get() {
11287 var ref = this, _options = ref.options, aspectRatio = _options.aspectRatio, maintainAspectRatio = _options.maintainAspectRatio, width = ref.width, height = ref.height, _aspectRatio = ref._aspectRatio;
11288 if (!(0, _helpersSegmentJs.k)(aspectRatio)) return aspectRatio;
11289 if (maintainAspectRatio && _aspectRatio) return _aspectRatio;
11290 return height ? width / height : null;
11291 }
11292 },
11293 {
11294 key: "data",
11295 get: function get() {
11296 return this.config.data;
11297 },
11298 set: function set(data) {
11299 this.config.data = data;
11300 }
11301 },
11302 {
11303 key: "options",
11304 get: function get() {
11305 return this._options;
11306 },
11307 set: function set(options) {
11308 this.config.options = options;
11309 }
11310 },
11311 {
11312 key: "_initialize",
11313 value: function _initialize() {
11314 this.notifyPlugins("beforeInit");
11315 if (this.options.responsive) this.resize();
11316 else (0, _helpersSegmentJs.ad)(this, this.options.devicePixelRatio);
11317 this.bindEvents();
11318 this.notifyPlugins("afterInit");
11319 return this;
11320 }
11321 },
11322 {
11323 key: "clear",
11324 value: function clear() {
11325 (0, _helpersSegmentJs.ae)(this.canvas, this.ctx);
11326 return this;
11327 }
11328 },
11329 {
11330 key: "stop",
11331 value: function stop() {
11332 animator.stop(this);
11333 return this;
11334 }
11335 },
11336 {
11337 key: "resize",
11338 value: function resize(width, height) {
11339 if (!animator.running(this)) this._resize(width, height);
11340 else this._resizeBeforeDraw = {
11341 width: width,
11342 height: height
11343 };
11344 }
11345 },
11346 {
11347 key: "_resize",
11348 value: function _resize(width, height) {
11349 var options = this.options;
11350 var canvas = this.canvas;
11351 var aspectRatio = options.maintainAspectRatio && this.aspectRatio;
11352 var newSize = this.platform.getMaximumSize(canvas, width, height, aspectRatio);
11353 var newRatio = options.devicePixelRatio || this.platform.getDevicePixelRatio();
11354 var mode = this.width ? "resize" : "attach";
11355 this.width = newSize.width;
11356 this.height = newSize.height;
11357 this._aspectRatio = this.aspectRatio;
11358 if (!(0, _helpersSegmentJs.ad)(this, newRatio, true)) return;
11359 this.notifyPlugins("resize", {
11360 size: newSize
11361 });
11362 (0, _helpersSegmentJs.Q)(options.onResize, [
11363 this,
11364 newSize
11365 ], this);
11366 if (this.attached) {
11367 if (this._doResize(mode)) this.render();
11368 }
11369 }
11370 },
11371 {
11372 key: "ensureScalesHaveIDs",
11373 value: function ensureScalesHaveIDs() {
11374 var options = this.options;
11375 var scalesOptions = options.scales || {};
11376 (0, _helpersSegmentJs.E)(scalesOptions, function(axisOptions, axisID) {
11377 axisOptions.id = axisID;
11378 });
11379 }
11380 },
11381 {
11382 key: "buildOrUpdateScales",
11383 value: function buildOrUpdateScales() {
11384 var _this = this;
11385 var options = this.options;
11386 var scaleOpts = options.scales;
11387 var scales4 = this.scales;
11388 var updated = Object.keys(scales4).reduce(function(obj, id) {
11389 obj[id] = false;
11390 return obj;
11391 }, {});
11392 var items = [];
11393 if (scaleOpts) items = items.concat(Object.keys(scaleOpts).map(function(id) {
11394 var scaleOptions = scaleOpts[id];
11395 var axis = determineAxis(id, scaleOptions);
11396 var isRadial = axis === "r";
11397 var isHorizontal = axis === "x";
11398 return {
11399 options: scaleOptions,
11400 dposition: isRadial ? "chartArea" : isHorizontal ? "bottom" : "left",
11401 dtype: isRadial ? "radialLinear" : isHorizontal ? "category" : "linear"
11402 };
11403 }));
11404 (0, _helpersSegmentJs.E)(items, function(item) {
11405 var scaleOptions = item.options;
11406 var id = scaleOptions.id;
11407 var axis = determineAxis(id, scaleOptions);
11408 var scaleType = (0, _helpersSegmentJs.v)(scaleOptions.type, item.dtype);
11409 if (scaleOptions.position === undefined || positionIsHorizontal(scaleOptions.position, axis) !== positionIsHorizontal(item.dposition)) scaleOptions.position = item.dposition;
11410 updated[id] = true;
11411 var scale = null;
11412 if (id in scales4 && scales4[id].type === scaleType) scale = scales4[id];
11413 else {
11414 var scaleClass = registry.getScale(scaleType);
11415 scale = new scaleClass({
11416 id: id,
11417 type: scaleType,
11418 ctx: _this.ctx,
11419 chart: _this
11420 });
11421 scales4[scale.id] = scale;
11422 }
11423 scale.init(scaleOptions, options);
11424 });
11425 (0, _helpersSegmentJs.E)(updated, function(hasUpdated, id) {
11426 if (!hasUpdated) delete scales4[id];
11427 });
11428 (0, _helpersSegmentJs.E)(scales4, function(scale) {
11429 layouts.configure(_this, scale, scale.options);
11430 layouts.addBox(_this, scale);
11431 });
11432 }
11433 },
11434 {
11435 key: "_updateMetasets",
11436 value: function _updateMetasets() {
11437 var metasets = this._metasets;
11438 var numData = this.data.datasets.length;
11439 var numMeta = metasets.length;
11440 metasets.sort(function(a, b) {
11441 return a.index - b.index;
11442 });
11443 if (numMeta > numData) {
11444 for(var i = numData; i < numMeta; ++i)this._destroyDatasetMeta(i);
11445 metasets.splice(numData, numMeta - numData);
11446 }
11447 this._sortedMetasets = metasets.slice(0).sort(compare2Level("order", "index"));
11448 }
11449 },
11450 {
11451 key: "_removeUnreferencedMetasets",
11452 value: function _removeUnreferencedMetasets() {
11453 var _this = this;
11454 var ref = this, metasets = ref._metasets, datasets = ref.data.datasets;
11455 if (metasets.length > datasets.length) delete this._stacks;
11456 metasets.forEach(function(meta, index50) {
11457 if (datasets.filter(function(x) {
11458 return x === meta._dataset;
11459 }).length === 0) _this._destroyDatasetMeta(index50);
11460 });
11461 }
11462 },
11463 {
11464 key: "buildOrUpdateControllers",
11465 value: function buildOrUpdateControllers() {
11466 var newControllers = [];
11467 var datasets = this.data.datasets;
11468 var i, ilen;
11469 this._removeUnreferencedMetasets();
11470 for(i = 0, ilen = datasets.length; i < ilen; i++){
11471 var dataset = datasets[i];
11472 var meta = this.getDatasetMeta(i);
11473 var type = dataset.type || this.config.type;
11474 if (meta.type && meta.type !== type) {
11475 this._destroyDatasetMeta(i);
11476 meta = this.getDatasetMeta(i);
11477 }
11478 meta.type = type;
11479 meta.indexAxis = dataset.indexAxis || getIndexAxis(type, this.options);
11480 meta.order = dataset.order || 0;
11481 meta.index = i;
11482 meta.label = "" + dataset.label;
11483 meta.visible = this.isDatasetVisible(i);
11484 if (meta.controller) {
11485 meta.controller.updateIndex(i);
11486 meta.controller.linkScales();
11487 } else {
11488 var ControllerClass = registry.getController(type);
11489 var _type = (0, _helpersSegmentJs.d).datasets[type], datasetElementType = _type.datasetElementType, dataElementType = _type.dataElementType;
11490 Object.assign(ControllerClass.prototype, {
11491 dataElementType: registry.getElement(dataElementType),
11492 datasetElementType: datasetElementType && registry.getElement(datasetElementType)
11493 });
11494 meta.controller = new ControllerClass(this, i);
11495 newControllers.push(meta.controller);
11496 }
11497 }
11498 this._updateMetasets();
11499 return newControllers;
11500 }
11501 },
11502 {
11503 key: "_resetElements",
11504 value: function _resetElements() {
11505 var _this = this;
11506 (0, _helpersSegmentJs.E)(this.data.datasets, function(dataset, datasetIndex) {
11507 _this.getDatasetMeta(datasetIndex).controller.reset();
11508 }, this);
11509 }
11510 },
11511 {
11512 key: "reset",
11513 value: function reset() {
11514 this._resetElements();
11515 this.notifyPlugins("reset");
11516 }
11517 },
11518 {
11519 key: "update",
11520 value: function update(mode) {
11521 var config = this.config;
11522 config.update();
11523 var options = this._options = config.createResolver(config.chartOptionScopes(), this.getContext());
11524 var animsDisabled = this._animationsDisabled = !options.animation;
11525 this._updateScales();
11526 this._checkEventBindings();
11527 this._updateHiddenIndices();
11528 this._plugins.invalidate();
11529 if (this.notifyPlugins("beforeUpdate", {
11530 mode: mode,
11531 cancelable: true
11532 }) === false) return;
11533 var newControllers = this.buildOrUpdateControllers();
11534 this.notifyPlugins("beforeElementsUpdate");
11535 var minPadding = 0;
11536 for(var i = 0, ilen = this.data.datasets.length; i < ilen; i++){
11537 var controller = this.getDatasetMeta(i).controller;
11538 var reset = !animsDisabled && newControllers.indexOf(controller) === -1;
11539 controller.buildOrUpdateElements(reset);
11540 minPadding = Math.max(+controller.getMaxOverflow(), minPadding);
11541 }
11542 minPadding = this._minPadding = options.layout.autoPadding ? minPadding : 0;
11543 this._updateLayout(minPadding);
11544 if (!animsDisabled) (0, _helpersSegmentJs.E)(newControllers, function(controller) {
11545 controller.reset();
11546 });
11547 this._updateDatasets(mode);
11548 this.notifyPlugins("afterUpdate", {
11549 mode: mode
11550 });
11551 this._layers.sort(compare2Level("z", "_idx"));
11552 var ref = this, _active = ref._active, _lastEvent = ref._lastEvent;
11553 if (_lastEvent) this._eventHandler(_lastEvent, true);
11554 else if (_active.length) this._updateHoverStyles(_active, _active, true);
11555 this.render();
11556 }
11557 },
11558 {
11559 key: "_updateScales",
11560 value: function _updateScales() {
11561 var _this = this;
11562 (0, _helpersSegmentJs.E)(this.scales, function(scale) {
11563 layouts.removeBox(_this, scale);
11564 });
11565 this.ensureScalesHaveIDs();
11566 this.buildOrUpdateScales();
11567 }
11568 },
11569 {
11570 key: "_checkEventBindings",
11571 value: function _checkEventBindings() {
11572 var options = this.options;
11573 var existingEvents = new Set(Object.keys(this._listeners));
11574 var newEvents = new Set(options.events);
11575 if (!(0, _helpersSegmentJs.af)(existingEvents, newEvents) || !!this._responsiveListeners !== options.responsive) {
11576 this.unbindEvents();
11577 this.bindEvents();
11578 }
11579 }
11580 },
11581 {
11582 key: "_updateHiddenIndices",
11583 value: function _updateHiddenIndices() {
11584 var _hiddenIndices = this._hiddenIndices;
11585 var changes = this._getUniformDataChanges() || [];
11586 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
11587 try {
11588 for(var _iterator = changes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
11589 var _value = _step.value, method = _value.method, start = _value.start, count = _value.count;
11590 var move = method === "_removeElements" ? -count : count;
11591 moveNumericKeys(_hiddenIndices, start, move);
11592 }
11593 } catch (err) {
11594 _didIteratorError = true;
11595 _iteratorError = err;
11596 } finally{
11597 try {
11598 if (!_iteratorNormalCompletion && _iterator.return != null) {
11599 _iterator.return();
11600 }
11601 } finally{
11602 if (_didIteratorError) {
11603 throw _iteratorError;
11604 }
11605 }
11606 }
11607 }
11608 },
11609 {
11610 key: "_getUniformDataChanges",
11611 value: function _getUniformDataChanges() {
11612 var _dataChanges = this._dataChanges;
11613 if (!_dataChanges || !_dataChanges.length) return;
11614 this._dataChanges = [];
11615 var datasetCount = this.data.datasets.length;
11616 var makeSet = function(idx) {
11617 return new Set(_dataChanges.filter(function(c) {
11618 return c[0] === idx;
11619 }).map(function(c, i) {
11620 return i + "," + c.splice(1).join(",");
11621 }));
11622 };
11623 var changeSet = makeSet(0);
11624 for(var i4 = 1; i4 < datasetCount; i4++){
11625 if (!(0, _helpersSegmentJs.af)(changeSet, makeSet(i4))) return;
11626 }
11627 return Array.from(changeSet).map(function(c) {
11628 return c.split(",");
11629 }).map(function(a) {
11630 return {
11631 method: a[1],
11632 start: +a[2],
11633 count: +a[3]
11634 };
11635 });
11636 }
11637 },
11638 {
11639 key: "_updateLayout",
11640 value: function _updateLayout(minPadding) {
11641 var _this = this;
11642 if (this.notifyPlugins("beforeLayout", {
11643 cancelable: true
11644 }) === false) return;
11645 layouts.update(this, this.width, this.height, minPadding);
11646 var area = this.chartArea;
11647 var noArea = area.width <= 0 || area.height <= 0;
11648 this._layers = [];
11649 (0, _helpersSegmentJs.E)(this.boxes, function(box) {
11650 var __layers;
11651 if (noArea && box.position === "chartArea") return;
11652 if (box.configure) box.configure();
11653 (__layers = _this._layers).push.apply(__layers, (0, _toConsumableArrayJsDefault.default)(box._layers()));
11654 }, this);
11655 this._layers.forEach(function(item, index51) {
11656 item._idx = index51;
11657 });
11658 this.notifyPlugins("afterLayout");
11659 }
11660 },
11661 {
11662 key: "_updateDatasets",
11663 value: function _updateDatasets(mode) {
11664 if (this.notifyPlugins("beforeDatasetsUpdate", {
11665 mode: mode,
11666 cancelable: true
11667 }) === false) return;
11668 for(var i = 0, ilen = this.data.datasets.length; i < ilen; ++i)this.getDatasetMeta(i).controller.configure();
11669 for(var i5 = 0, ilen1 = this.data.datasets.length; i5 < ilen1; ++i5)this._updateDataset(i5, (0, _helpersSegmentJs.a6)(mode) ? mode({
11670 datasetIndex: i5
11671 }) : mode);
11672 this.notifyPlugins("afterDatasetsUpdate", {
11673 mode: mode
11674 });
11675 }
11676 },
11677 {
11678 key: "_updateDataset",
11679 value: function _updateDataset(index52, mode) {
11680 var meta = this.getDatasetMeta(index52);
11681 var args = {
11682 meta: meta,
11683 index: index52,
11684 mode: mode,
11685 cancelable: true
11686 };
11687 if (this.notifyPlugins("beforeDatasetUpdate", args) === false) return;
11688 meta.controller._update(mode);
11689 args.cancelable = false;
11690 this.notifyPlugins("afterDatasetUpdate", args);
11691 }
11692 },
11693 {
11694 key: "render",
11695 value: function render() {
11696 if (this.notifyPlugins("beforeRender", {
11697 cancelable: true
11698 }) === false) return;
11699 if (animator.has(this)) {
11700 if (this.attached && !animator.running(this)) animator.start(this);
11701 } else {
11702 this.draw();
11703 onAnimationsComplete({
11704 chart: this
11705 });
11706 }
11707 }
11708 },
11709 {
11710 key: "draw",
11711 value: function draw2() {
11712 var i;
11713 if (this._resizeBeforeDraw) {
11714 var __resizeBeforeDraw = this._resizeBeforeDraw, width = __resizeBeforeDraw.width, height = __resizeBeforeDraw.height;
11715 this._resize(width, height);
11716 this._resizeBeforeDraw = null;
11717 }
11718 this.clear();
11719 if (this.width <= 0 || this.height <= 0) return;
11720 if (this.notifyPlugins("beforeDraw", {
11721 cancelable: true
11722 }) === false) return;
11723 var layers = this._layers;
11724 for(i = 0; i < layers.length && layers[i].z <= 0; ++i)layers[i].draw(this.chartArea);
11725 this._drawDatasets();
11726 for(; i < layers.length; ++i)layers[i].draw(this.chartArea);
11727 this.notifyPlugins("afterDraw");
11728 }
11729 },
11730 {
11731 key: "_getSortedDatasetMetas",
11732 value: function _getSortedDatasetMetas(filterVisible) {
11733 var metasets = this._sortedMetasets;
11734 var result = [];
11735 var i, ilen;
11736 for(i = 0, ilen = metasets.length; i < ilen; ++i){
11737 var meta = metasets[i];
11738 if (!filterVisible || meta.visible) result.push(meta);
11739 }
11740 return result;
11741 }
11742 },
11743 {
11744 key: "getSortedVisibleDatasetMetas",
11745 value: function getSortedVisibleDatasetMetas() {
11746 return this._getSortedDatasetMetas(true);
11747 }
11748 },
11749 {
11750 key: "_drawDatasets",
11751 value: function _drawDatasets() {
11752 if (this.notifyPlugins("beforeDatasetsDraw", {
11753 cancelable: true
11754 }) === false) return;
11755 var metasets = this.getSortedVisibleDatasetMetas();
11756 for(var i = metasets.length - 1; i >= 0; --i)this._drawDataset(metasets[i]);
11757 this.notifyPlugins("afterDatasetsDraw");
11758 }
11759 },
11760 {
11761 key: "_drawDataset",
11762 value: function _drawDataset(meta) {
11763 var ctx = this.ctx;
11764 var clip = meta._clip;
11765 var useClip = !clip.disabled;
11766 var area = this.chartArea;
11767 var args = {
11768 meta: meta,
11769 index: meta.index,
11770 cancelable: true
11771 };
11772 if (this.notifyPlugins("beforeDatasetDraw", args) === false) return;
11773 if (useClip) (0, _helpersSegmentJs.X)(ctx, {
11774 left: clip.left === false ? 0 : area.left - clip.left,
11775 right: clip.right === false ? this.width : area.right + clip.right,
11776 top: clip.top === false ? 0 : area.top - clip.top,
11777 bottom: clip.bottom === false ? this.height : area.bottom + clip.bottom
11778 });
11779 meta.controller.draw();
11780 if (useClip) (0, _helpersSegmentJs.Z)(ctx);
11781 args.cancelable = false;
11782 this.notifyPlugins("afterDatasetDraw", args);
11783 }
11784 },
11785 {
11786 key: "isPointInArea",
11787 value: function isPointInArea(point) {
11788 return (0, _helpersSegmentJs.B)(point, this.chartArea, this._minPadding);
11789 }
11790 },
11791 {
11792 key: "getElementsAtEventForMode",
11793 value: function getElementsAtEventForMode(e, mode, options, useFinalPosition) {
11794 var method = Interaction.modes[mode];
11795 if (typeof method === "function") return method(this, e, options, useFinalPosition);
11796 return [];
11797 }
11798 },
11799 {
11800 key: "getDatasetMeta",
11801 value: function getDatasetMeta(datasetIndex) {
11802 var dataset = this.data.datasets[datasetIndex];
11803 var metasets = this._metasets;
11804 var meta = metasets.filter(function(x) {
11805 return x && x._dataset === dataset;
11806 }).pop();
11807 if (!meta) {
11808 meta = {
11809 type: null,
11810 data: [],
11811 dataset: null,
11812 controller: null,
11813 hidden: null,
11814 xAxisID: null,
11815 yAxisID: null,
11816 order: dataset && dataset.order || 0,
11817 index: datasetIndex,
11818 _dataset: dataset,
11819 _parsed: [],
11820 _sorted: false
11821 };
11822 metasets.push(meta);
11823 }
11824 return meta;
11825 }
11826 },
11827 {
11828 key: "getContext",
11829 value: function getContext() {
11830 return this.$context || (this.$context = (0, _helpersSegmentJs.h)(null, {
11831 chart: this,
11832 type: "chart"
11833 }));
11834 }
11835 },
11836 {
11837 key: "getVisibleDatasetCount",
11838 value: function getVisibleDatasetCount() {
11839 return this.getSortedVisibleDatasetMetas().length;
11840 }
11841 },
11842 {
11843 key: "isDatasetVisible",
11844 value: function isDatasetVisible(datasetIndex) {
11845 var dataset = this.data.datasets[datasetIndex];
11846 if (!dataset) return false;
11847 var meta = this.getDatasetMeta(datasetIndex);
11848 return typeof meta.hidden === "boolean" ? !meta.hidden : !dataset.hidden;
11849 }
11850 },
11851 {
11852 key: "setDatasetVisibility",
11853 value: function setDatasetVisibility(datasetIndex, visible) {
11854 var meta = this.getDatasetMeta(datasetIndex);
11855 meta.hidden = !visible;
11856 }
11857 },
11858 {
11859 key: "toggleDataVisibility",
11860 value: function toggleDataVisibility(index53) {
11861 this._hiddenIndices[index53] = !this._hiddenIndices[index53];
11862 }
11863 },
11864 {
11865 key: "getDataVisibility",
11866 value: function getDataVisibility(index54) {
11867 return !this._hiddenIndices[index54];
11868 }
11869 },
11870 {
11871 key: "_updateVisibility",
11872 value: function _updateVisibility(datasetIndex, dataIndex, visible) {
11873 var mode = visible ? "show" : "hide";
11874 var meta = this.getDatasetMeta(datasetIndex);
11875 var anims = meta.controller._resolveAnimations(undefined, mode);
11876 if ((0, _helpersSegmentJs.j)(dataIndex)) {
11877 meta.data[dataIndex].hidden = !visible;
11878 this.update();
11879 } else {
11880 this.setDatasetVisibility(datasetIndex, visible);
11881 anims.update(meta, {
11882 visible: visible
11883 });
11884 this.update(function(ctx) {
11885 return ctx.datasetIndex === datasetIndex ? mode : undefined;
11886 });
11887 }
11888 }
11889 },
11890 {
11891 key: "hide",
11892 value: function hide(datasetIndex, dataIndex) {
11893 this._updateVisibility(datasetIndex, dataIndex, false);
11894 }
11895 },
11896 {
11897 key: "show",
11898 value: function show(datasetIndex, dataIndex) {
11899 this._updateVisibility(datasetIndex, dataIndex, true);
11900 }
11901 },
11902 {
11903 key: "_destroyDatasetMeta",
11904 value: function _destroyDatasetMeta(datasetIndex) {
11905 var meta = this._metasets[datasetIndex];
11906 if (meta && meta.controller) meta.controller._destroy();
11907 delete this._metasets[datasetIndex];
11908 }
11909 },
11910 {
11911 key: "_stop",
11912 value: function _stop() {
11913 var i, ilen;
11914 this.stop();
11915 animator.remove(this);
11916 for(i = 0, ilen = this.data.datasets.length; i < ilen; ++i)this._destroyDatasetMeta(i);
11917 }
11918 },
11919 {
11920 key: "destroy",
11921 value: function destroy() {
11922 this.notifyPlugins("beforeDestroy");
11923 var ref = this, canvas = ref.canvas, ctx = ref.ctx;
11924 this._stop();
11925 this.config.clearCache();
11926 if (canvas) {
11927 this.unbindEvents();
11928 (0, _helpersSegmentJs.ae)(canvas, ctx);
11929 this.platform.releaseContext(ctx);
11930 this.canvas = null;
11931 this.ctx = null;
11932 }
11933 this.notifyPlugins("destroy");
11934 delete instances[this.id];
11935 this.notifyPlugins("afterDestroy");
11936 }
11937 },
11938 {
11939 key: "toBase64Image",
11940 value: function toBase64Image() {
11941 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
11942 args[_key] = arguments[_key];
11943 }
11944 var _canvas;
11945 return (_canvas = this.canvas).toDataURL.apply(_canvas, (0, _toConsumableArrayJsDefault.default)(args));
11946 }
11947 },
11948 {
11949 key: "bindEvents",
11950 value: function bindEvents() {
11951 this.bindUserEvents();
11952 if (this.options.responsive) this.bindResponsiveEvents();
11953 else this.attached = true;
11954 }
11955 },
11956 {
11957 key: "bindUserEvents",
11958 value: function bindUserEvents() {
11959 var _this = this;
11960 var listeners = this._listeners;
11961 var platform = this.platform;
11962 var _add = function(type, listener) {
11963 platform.addEventListener(_this, type, listener);
11964 listeners[type] = listener;
11965 };
11966 var listener1 = function(e, x, y) {
11967 e.offsetX = x;
11968 e.offsetY = y;
11969 _this._eventHandler(e);
11970 };
11971 (0, _helpersSegmentJs.E)(this.options.events, function(type) {
11972 return _add(type, listener1);
11973 });
11974 }
11975 },
11976 {
11977 key: "bindResponsiveEvents",
11978 value: function bindResponsiveEvents() {
11979 var _this = this;
11980 if (!this._responsiveListeners) this._responsiveListeners = {};
11981 var listeners = this._responsiveListeners;
11982 var platform = this.platform;
11983 var _add = function(type, listener) {
11984 platform.addEventListener(_this, type, listener);
11985 listeners[type] = listener;
11986 };
11987 var _remove = function(type, listener) {
11988 if (listeners[type]) {
11989 platform.removeEventListener(_this, type, listener);
11990 delete listeners[type];
11991 }
11992 };
11993 var listener2 = function(width, height) {
11994 if (_this.canvas) _this.resize(width, height);
11995 };
11996 var detached;
11997 var attached = function() {
11998 _remove("attach", attached);
11999 _this.attached = true;
12000 _this.resize();
12001 _add("resize", listener2);
12002 _add("detach", detached);
12003 };
12004 detached = function() {
12005 _this.attached = false;
12006 _remove("resize", listener2);
12007 _this._stop();
12008 _this._resize(0, 0);
12009 _add("attach", attached);
12010 };
12011 if (platform.isAttached(this.canvas)) attached();
12012 else detached();
12013 }
12014 },
12015 {
12016 key: "unbindEvents",
12017 value: function unbindEvents() {
12018 var _this = this;
12019 (0, _helpersSegmentJs.E)(this._listeners, function(listener, type) {
12020 _this.platform.removeEventListener(_this, type, listener);
12021 });
12022 this._listeners = {};
12023 (0, _helpersSegmentJs.E)(this._responsiveListeners, function(listener, type) {
12024 _this.platform.removeEventListener(_this, type, listener);
12025 });
12026 this._responsiveListeners = undefined;
12027 }
12028 },
12029 {
12030 key: "updateHoverStyle",
12031 value: function updateHoverStyle(items, mode, enabled) {
12032 var prefix = enabled ? "set" : "remove";
12033 var meta, item, i, ilen;
12034 if (mode === "dataset") {
12035 meta = this.getDatasetMeta(items[0].datasetIndex);
12036 meta.controller["_" + prefix + "DatasetHoverStyle"]();
12037 }
12038 for(i = 0, ilen = items.length; i < ilen; ++i){
12039 item = items[i];
12040 var controller = item && this.getDatasetMeta(item.datasetIndex).controller;
12041 if (controller) controller[prefix + "HoverStyle"](item.element, item.datasetIndex, item.index);
12042 }
12043 }
12044 },
12045 {
12046 key: "getActiveElements",
12047 value: function getActiveElements() {
12048 return this._active || [];
12049 }
12050 },
12051 {
12052 key: "setActiveElements",
12053 value: function setActiveElements(activeElements) {
12054 var _this = this;
12055 var lastActive = this._active || [];
12056 var active = activeElements.map(function(param) {
12057 var datasetIndex = param.datasetIndex, index55 = param.index;
12058 var meta = _this.getDatasetMeta(datasetIndex);
12059 if (!meta) throw new Error("No dataset found at index " + datasetIndex);
12060 return {
12061 datasetIndex: datasetIndex,
12062 element: meta.data[index55],
12063 index: index55
12064 };
12065 });
12066 var changed = !(0, _helpersSegmentJs.ag)(active, lastActive);
12067 if (changed) {
12068 this._active = active;
12069 this._lastEvent = null;
12070 this._updateHoverStyles(active, lastActive);
12071 }
12072 }
12073 },
12074 {
12075 key: "notifyPlugins",
12076 value: function notifyPlugins(hook, args, filter) {
12077 return this._plugins.notify(this, hook, args, filter);
12078 }
12079 },
12080 {
12081 key: "_updateHoverStyles",
12082 value: function _updateHoverStyles(active, lastActive, replay) {
12083 var hoverOptions = this.options.hover;
12084 var diff = function(a, b) {
12085 return a.filter(function(x) {
12086 return !b.some(function(y) {
12087 return x.datasetIndex === y.datasetIndex && x.index === y.index;
12088 });
12089 });
12090 };
12091 var deactivated = diff(lastActive, active);
12092 var activated = replay ? active : diff(active, lastActive);
12093 if (deactivated.length) this.updateHoverStyle(deactivated, hoverOptions.mode, false);
12094 if (activated.length && hoverOptions.mode) this.updateHoverStyle(activated, hoverOptions.mode, true);
12095 }
12096 },
12097 {
12098 key: "_eventHandler",
12099 value: function _eventHandler(e, replay) {
12100 var _this = this;
12101 var args = {
12102 event: e,
12103 replay: replay,
12104 cancelable: true,
12105 inChartArea: this.isPointInArea(e)
12106 };
12107 var eventFilter = function(plugin) {
12108 return (plugin.options.events || _this.options.events).includes(e.native.type);
12109 };
12110 if (this.notifyPlugins("beforeEvent", args, eventFilter) === false) return;
12111 var changed = this._handleEvent(e, replay, args.inChartArea);
12112 args.cancelable = false;
12113 this.notifyPlugins("afterEvent", args, eventFilter);
12114 if (changed || args.changed) this.render();
12115 return this;
12116 }
12117 },
12118 {
12119 key: "_handleEvent",
12120 value: function _handleEvent(e, replay, inChartArea) {
12121 var ref = this, tmp = ref._active, lastActive = tmp === void 0 ? [] : tmp, options = ref.options;
12122 var useFinalPosition = replay;
12123 var active = this._getActiveElements(e, lastActive, inChartArea, useFinalPosition);
12124 var isClick = (0, _helpersSegmentJs.ah)(e);
12125 var lastEvent = determineLastEvent(e, this._lastEvent, inChartArea, isClick);
12126 if (inChartArea) {
12127 this._lastEvent = null;
12128 (0, _helpersSegmentJs.Q)(options.onHover, [
12129 e,
12130 active,
12131 this
12132 ], this);
12133 if (isClick) (0, _helpersSegmentJs.Q)(options.onClick, [
12134 e,
12135 active,
12136 this
12137 ], this);
12138 }
12139 var changed = !(0, _helpersSegmentJs.ag)(active, lastActive);
12140 if (changed || replay) {
12141 this._active = active;
12142 this._updateHoverStyles(active, lastActive, replay);
12143 }
12144 this._lastEvent = lastEvent;
12145 return changed;
12146 }
12147 },
12148 {
12149 key: "_getActiveElements",
12150 value: function _getActiveElements(e, lastActive, inChartArea, useFinalPosition) {
12151 if (e.type === "mouseout") return [];
12152 if (!inChartArea) return lastActive;
12153 var hoverOptions = this.options.hover;
12154 return this.getElementsAtEventForMode(e, hoverOptions.mode, hoverOptions, useFinalPosition);
12155 }
12156 }
12157 ]);
12158 return Chart;
12159 }();
12160 var invalidatePlugins = function() {
12161 return (0, _helpersSegmentJs.E)(Chart.instances, function(chart) {
12162 return chart._plugins.invalidate();
12163 });
12164 };
12165 var enumerable = true;
12166 Object.defineProperties(Chart, {
12167 defaults: {
12168 enumerable: enumerable,
12169 value: (0, _helpersSegmentJs.d)
12170 },
12171 instances: {
12172 enumerable: enumerable,
12173 value: instances
12174 },
12175 overrides: {
12176 enumerable: enumerable,
12177 value: (0, _helpersSegmentJs.a2)
12178 },
12179 registry: {
12180 enumerable: enumerable,
12181 value: registry
12182 },
12183 version: {
12184 enumerable: enumerable,
12185 value: version
12186 },
12187 getChart: {
12188 enumerable: enumerable,
12189 value: getChart
12190 },
12191 register: {
12192 enumerable: enumerable,
12193 value: function() {
12194 for(var _len = arguments.length, items = new Array(_len), _key = 0; _key < _len; _key++){
12195 items[_key] = arguments[_key];
12196 }
12197 var _registry;
12198 (_registry = registry).add.apply(_registry, (0, _toConsumableArrayJsDefault.default)(items));
12199 invalidatePlugins();
12200 }
12201 },
12202 unregister: {
12203 enumerable: enumerable,
12204 value: function() {
12205 for(var _len = arguments.length, items = new Array(_len), _key = 0; _key < _len; _key++){
12206 items[_key] = arguments[_key];
12207 }
12208 var _registry;
12209 (_registry = registry).remove.apply(_registry, (0, _toConsumableArrayJsDefault.default)(items));
12210 invalidatePlugins();
12211 }
12212 }
12213 });
12214 function clipArc(ctx, element, endAngle) {
12215 var startAngle = element.startAngle, pixelMargin = element.pixelMargin, x = element.x, y = element.y, outerRadius = element.outerRadius, innerRadius = element.innerRadius;
12216 var angleMargin = pixelMargin / outerRadius;
12217 ctx.beginPath();
12218 ctx.arc(x, y, outerRadius, startAngle - angleMargin, endAngle + angleMargin);
12219 if (innerRadius > pixelMargin) {
12220 angleMargin = pixelMargin / innerRadius;
12221 ctx.arc(x, y, innerRadius, endAngle + angleMargin, startAngle - angleMargin, true);
12222 } else ctx.arc(x, y, pixelMargin, endAngle + (0, _helpersSegmentJs.H), startAngle - (0, _helpersSegmentJs.H));
12223 ctx.closePath();
12224 ctx.clip();
12225 }
12226 function toRadiusCorners(value) {
12227 return (0, _helpersSegmentJs.aj)(value, [
12228 "outerStart",
12229 "outerEnd",
12230 "innerStart",
12231 "innerEnd"
12232 ]);
12233 }
12234 function parseBorderRadius$1(arc, innerRadius, outerRadius, angleDelta) {
12235 var o = toRadiusCorners(arc.options.borderRadius);
12236 var halfThickness = (outerRadius - innerRadius) / 2;
12237 var innerLimit = Math.min(halfThickness, angleDelta * innerRadius / 2);
12238 var computeOuterLimit = function(val) {
12239 var outerArcLimit = (outerRadius - Math.min(halfThickness, val)) * angleDelta / 2;
12240 return (0, _helpersSegmentJs.w)(val, 0, Math.min(halfThickness, outerArcLimit));
12241 };
12242 return {
12243 outerStart: computeOuterLimit(o.outerStart),
12244 outerEnd: computeOuterLimit(o.outerEnd),
12245 innerStart: (0, _helpersSegmentJs.w)(o.innerStart, 0, innerLimit),
12246 innerEnd: (0, _helpersSegmentJs.w)(o.innerEnd, 0, innerLimit)
12247 };
12248 }
12249 function rThetaToXY(r, theta, x, y) {
12250 return {
12251 x: x + r * Math.cos(theta),
12252 y: y + r * Math.sin(theta)
12253 };
12254 }
12255 function pathArc(ctx, element, offset, spacing, end) {
12256 var x = element.x, y = element.y, start = element.startAngle, pixelMargin = element.pixelMargin, innerR = element.innerRadius;
12257 var outerRadius = Math.max(element.outerRadius + spacing + offset - pixelMargin, 0);
12258 var innerRadius = innerR > 0 ? innerR + spacing + offset + pixelMargin : 0;
12259 var spacingOffset = 0;
12260 var alpha = end - start;
12261 if (spacing) {
12262 var noSpacingInnerRadius = innerR > 0 ? innerR - spacing : 0;
12263 var noSpacingOuterRadius = outerRadius > 0 ? outerRadius - spacing : 0;
12264 var avNogSpacingRadius = (noSpacingInnerRadius + noSpacingOuterRadius) / 2;
12265 var adjustedAngle = avNogSpacingRadius !== 0 ? alpha * avNogSpacingRadius / (avNogSpacingRadius + spacing) : alpha;
12266 spacingOffset = (alpha - adjustedAngle) / 2;
12267 }
12268 var beta = Math.max(0.001, alpha * outerRadius - offset / (0, _helpersSegmentJs.P)) / outerRadius;
12269 var angleOffset = (alpha - beta) / 2;
12270 var startAngle = start + angleOffset + spacingOffset;
12271 var endAngle = end - angleOffset - spacingOffset;
12272 var ref = parseBorderRadius$1(element, innerRadius, outerRadius, endAngle - startAngle), outerStart = ref.outerStart, outerEnd = ref.outerEnd, innerStart = ref.innerStart, innerEnd = ref.innerEnd;
12273 var outerStartAdjustedRadius = outerRadius - outerStart;
12274 var outerEndAdjustedRadius = outerRadius - outerEnd;
12275 var outerStartAdjustedAngle = startAngle + outerStart / outerStartAdjustedRadius;
12276 var outerEndAdjustedAngle = endAngle - outerEnd / outerEndAdjustedRadius;
12277 var innerStartAdjustedRadius = innerRadius + innerStart;
12278 var innerEndAdjustedRadius = innerRadius + innerEnd;
12279 var innerStartAdjustedAngle = startAngle + innerStart / innerStartAdjustedRadius;
12280 var innerEndAdjustedAngle = endAngle - innerEnd / innerEndAdjustedRadius;
12281 ctx.beginPath();
12282 ctx.arc(x, y, outerRadius, outerStartAdjustedAngle, outerEndAdjustedAngle);
12283 if (outerEnd > 0) {
12284 var pCenter = rThetaToXY(outerEndAdjustedRadius, outerEndAdjustedAngle, x, y);
12285 ctx.arc(pCenter.x, pCenter.y, outerEnd, outerEndAdjustedAngle, endAngle + (0, _helpersSegmentJs.H));
12286 }
12287 var p4 = rThetaToXY(innerEndAdjustedRadius, endAngle, x, y);
12288 ctx.lineTo(p4.x, p4.y);
12289 if (innerEnd > 0) {
12290 var pCenter1 = rThetaToXY(innerEndAdjustedRadius, innerEndAdjustedAngle, x, y);
12291 ctx.arc(pCenter1.x, pCenter1.y, innerEnd, endAngle + (0, _helpersSegmentJs.H), innerEndAdjustedAngle + Math.PI);
12292 }
12293 ctx.arc(x, y, innerRadius, endAngle - innerEnd / innerRadius, startAngle + innerStart / innerRadius, true);
12294 if (innerStart > 0) {
12295 var pCenter2 = rThetaToXY(innerStartAdjustedRadius, innerStartAdjustedAngle, x, y);
12296 ctx.arc(pCenter2.x, pCenter2.y, innerStart, innerStartAdjustedAngle + Math.PI, startAngle - (0, _helpersSegmentJs.H));
12297 }
12298 var p8 = rThetaToXY(outerStartAdjustedRadius, startAngle, x, y);
12299 ctx.lineTo(p8.x, p8.y);
12300 if (outerStart > 0) {
12301 var pCenter3 = rThetaToXY(outerStartAdjustedRadius, outerStartAdjustedAngle, x, y);
12302 ctx.arc(pCenter3.x, pCenter3.y, outerStart, startAngle - (0, _helpersSegmentJs.H), outerStartAdjustedAngle);
12303 }
12304 ctx.closePath();
12305 }
12306 function drawArc(ctx, element, offset, spacing) {
12307 var fullCircles = element.fullCircles, startAngle = element.startAngle, circumference = element.circumference;
12308 var endAngle = element.endAngle;
12309 if (fullCircles) {
12310 pathArc(ctx, element, offset, spacing, startAngle + (0, _helpersSegmentJs.T));
12311 for(var i = 0; i < fullCircles; ++i)ctx.fill();
12312 if (!isNaN(circumference)) {
12313 endAngle = startAngle + circumference % (0, _helpersSegmentJs.T);
12314 if (circumference % (0, _helpersSegmentJs.T) === 0) endAngle += (0, _helpersSegmentJs.T);
12315 }
12316 }
12317 pathArc(ctx, element, offset, spacing, endAngle);
12318 ctx.fill();
12319 return endAngle;
12320 }
12321 function drawFullCircleBorders(ctx, element, inner) {
12322 var x = element.x, y = element.y, startAngle = element.startAngle, pixelMargin = element.pixelMargin, fullCircles = element.fullCircles;
12323 var outerRadius = Math.max(element.outerRadius - pixelMargin, 0);
12324 var innerRadius = element.innerRadius + pixelMargin;
12325 var i;
12326 if (inner) clipArc(ctx, element, startAngle + (0, _helpersSegmentJs.T));
12327 ctx.beginPath();
12328 ctx.arc(x, y, innerRadius, startAngle + (0, _helpersSegmentJs.T), startAngle, true);
12329 for(i = 0; i < fullCircles; ++i)ctx.stroke();
12330 ctx.beginPath();
12331 ctx.arc(x, y, outerRadius, startAngle, startAngle + (0, _helpersSegmentJs.T));
12332 for(i = 0; i < fullCircles; ++i)ctx.stroke();
12333 }
12334 function drawBorder(ctx, element, offset, spacing, endAngle) {
12335 var options = element.options;
12336 var borderWidth = options.borderWidth, borderJoinStyle = options.borderJoinStyle;
12337 var inner = options.borderAlign === "inner";
12338 if (!borderWidth) return;
12339 if (inner) {
12340 ctx.lineWidth = borderWidth * 2;
12341 ctx.lineJoin = borderJoinStyle || "round";
12342 } else {
12343 ctx.lineWidth = borderWidth;
12344 ctx.lineJoin = borderJoinStyle || "bevel";
12345 }
12346 if (element.fullCircles) drawFullCircleBorders(ctx, element, inner);
12347 if (inner) clipArc(ctx, element, endAngle);
12348 pathArc(ctx, element, offset, spacing, endAngle);
12349 ctx.stroke();
12350 }
12351 var ArcElement = /*#__PURE__*/ function(Element) {
12352 "use strict";
12353 (0, _inheritsJsDefault.default)(ArcElement, Element);
12354 var _super = (0, _createSuperJsDefault.default)(ArcElement);
12355 function ArcElement(cfg) {
12356 (0, _classCallCheckJsDefault.default)(this, ArcElement);
12357 var _this;
12358 _this = _super.call(this);
12359 _this.options = undefined;
12360 _this.circumference = undefined;
12361 _this.startAngle = undefined;
12362 _this.endAngle = undefined;
12363 _this.innerRadius = undefined;
12364 _this.outerRadius = undefined;
12365 _this.pixelMargin = 0;
12366 _this.fullCircles = 0;
12367 if (cfg) Object.assign((0, _assertThisInitializedJsDefault.default)(_this), cfg);
12368 return _this;
12369 }
12370 (0, _createClassJsDefault.default)(ArcElement, [
12371 {
12372 key: "inRange",
12373 value: function inRange2(chartX, chartY, useFinalPosition) {
12374 var point = this.getProps([
12375 "x",
12376 "y"
12377 ], useFinalPosition);
12378 var ref = (0, _helpersSegmentJs.C)(point, {
12379 x: chartX,
12380 y: chartY
12381 }), angle = ref.angle, distance = ref.distance;
12382 var ref6 = this.getProps([
12383 "startAngle",
12384 "endAngle",
12385 "innerRadius",
12386 "outerRadius",
12387 "circumference"
12388 ], useFinalPosition), startAngle = ref6.startAngle, endAngle = ref6.endAngle, innerRadius = ref6.innerRadius, outerRadius = ref6.outerRadius, circumference = ref6.circumference;
12389 var rAdjust = this.options.spacing / 2;
12390 var _circumference = (0, _helpersSegmentJs.v)(circumference, endAngle - startAngle);
12391 var betweenAngles = _circumference >= (0, _helpersSegmentJs.T) || (0, _helpersSegmentJs.p)(angle, startAngle, endAngle);
12392 var withinRadius = (0, _helpersSegmentJs.ai)(distance, innerRadius + rAdjust, outerRadius + rAdjust);
12393 return betweenAngles && withinRadius;
12394 }
12395 },
12396 {
12397 key: "getCenterPoint",
12398 value: function getCenterPoint(useFinalPosition) {
12399 var ref = this.getProps([
12400 "x",
12401 "y",
12402 "startAngle",
12403 "endAngle",
12404 "innerRadius",
12405 "outerRadius",
12406 "circumference",
12407 ], useFinalPosition), x = ref.x, y = ref.y, startAngle = ref.startAngle, endAngle = ref.endAngle, innerRadius = ref.innerRadius, outerRadius = ref.outerRadius;
12408 var _options = this.options, offset = _options.offset, spacing = _options.spacing;
12409 var halfAngle = (startAngle + endAngle) / 2;
12410 var halfRadius = (innerRadius + outerRadius + spacing + offset) / 2;
12411 return {
12412 x: x + Math.cos(halfAngle) * halfRadius,
12413 y: y + Math.sin(halfAngle) * halfRadius
12414 };
12415 }
12416 },
12417 {
12418 key: "tooltipPosition",
12419 value: function tooltipPosition(useFinalPosition) {
12420 return this.getCenterPoint(useFinalPosition);
12421 }
12422 },
12423 {
12424 key: "draw",
12425 value: function draw2(ctx) {
12426 var ref = this, options = ref.options, circumference = ref.circumference;
12427 var offset = (options.offset || 0) / 2;
12428 var spacing = (options.spacing || 0) / 2;
12429 this.pixelMargin = options.borderAlign === "inner" ? 0.33 : 0;
12430 this.fullCircles = circumference > (0, _helpersSegmentJs.T) ? Math.floor(circumference / (0, _helpersSegmentJs.T)) : 0;
12431 if (circumference === 0 || this.innerRadius < 0 || this.outerRadius < 0) return;
12432 ctx.save();
12433 var radiusOffset = 0;
12434 if (offset) {
12435 radiusOffset = offset / 2;
12436 var halfAngle = (this.startAngle + this.endAngle) / 2;
12437 ctx.translate(Math.cos(halfAngle) * radiusOffset, Math.sin(halfAngle) * radiusOffset);
12438 if (this.circumference >= (0, _helpersSegmentJs.P)) radiusOffset = offset;
12439 }
12440 ctx.fillStyle = options.backgroundColor;
12441 ctx.strokeStyle = options.borderColor;
12442 var endAngle = drawArc(ctx, this, radiusOffset, spacing);
12443 drawBorder(ctx, this, radiusOffset, spacing, endAngle);
12444 ctx.restore();
12445 }
12446 }
12447 ]);
12448 return ArcElement;
12449 }((0, _wrapNativeSuperJsDefault.default)(Element));
12450 ArcElement.id = "arc";
12451 ArcElement.defaults = {
12452 borderAlign: "center",
12453 borderColor: "#fff",
12454 borderJoinStyle: undefined,
12455 borderRadius: 0,
12456 borderWidth: 2,
12457 offset: 0,
12458 spacing: 0,
12459 angle: undefined
12460 };
12461 ArcElement.defaultRoutes = {
12462 backgroundColor: "backgroundColor"
12463 };
12464 function setStyle(ctx, options) {
12465 var style = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : options;
12466 ctx.lineCap = (0, _helpersSegmentJs.v)(style.borderCapStyle, options.borderCapStyle);
12467 ctx.setLineDash((0, _helpersSegmentJs.v)(style.borderDash, options.borderDash));
12468 ctx.lineDashOffset = (0, _helpersSegmentJs.v)(style.borderDashOffset, options.borderDashOffset);
12469 ctx.lineJoin = (0, _helpersSegmentJs.v)(style.borderJoinStyle, options.borderJoinStyle);
12470 ctx.lineWidth = (0, _helpersSegmentJs.v)(style.borderWidth, options.borderWidth);
12471 ctx.strokeStyle = (0, _helpersSegmentJs.v)(style.borderColor, options.borderColor);
12472 }
12473 function lineTo(ctx, previous, target) {
12474 ctx.lineTo(target.x, target.y);
12475 }
12476 function getLineMethod(options) {
12477 if (options.stepped) return 0, _helpersSegmentJs.aq;
12478 if (options.tension || options.cubicInterpolationMode === "monotone") return 0, _helpersSegmentJs.ar;
12479 return lineTo;
12480 }
12481 function pathVars(points, segment) {
12482 var params = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
12483 var count = points.length;
12484 var tmp = params.start, paramsStart = tmp === void 0 ? 0 : tmp, tmp1 = params.end, paramsEnd = tmp1 === void 0 ? count - 1 : tmp1;
12485 var segmentStart = segment.start, segmentEnd = segment.end;
12486 var start = Math.max(paramsStart, segmentStart);
12487 var end = Math.min(paramsEnd, segmentEnd);
12488 var outside = paramsStart < segmentStart && paramsEnd < segmentStart || paramsStart > segmentEnd && paramsEnd > segmentEnd;
12489 return {
12490 count: count,
12491 start: start,
12492 loop: segment.loop,
12493 ilen: end < start && !outside ? count + end - start : end - start
12494 };
12495 }
12496 function pathSegment(ctx, line, segment, params) {
12497 var points = line.points, options = line.options;
12498 var ref = pathVars(points, segment, params), count = ref.count, start = ref.start, loop = ref.loop, ilen = ref.ilen;
12499 var lineMethod = getLineMethod(options);
12500 var ref7 = params || {}, _move = ref7.move, move = _move === void 0 ? true : _move, reverse = ref7.reverse;
12501 var i, point, prev;
12502 for(i = 0; i <= ilen; ++i){
12503 point = points[(start + (reverse ? ilen - i : i)) % count];
12504 if (point.skip) continue;
12505 else if (move) {
12506 ctx.moveTo(point.x, point.y);
12507 move = false;
12508 } else lineMethod(ctx, prev, point, reverse, options.stepped);
12509 prev = point;
12510 }
12511 if (loop) {
12512 point = points[(start + (reverse ? ilen : 0)) % count];
12513 lineMethod(ctx, prev, point, reverse, options.stepped);
12514 }
12515 return !!loop;
12516 }
12517 function fastPathSegment(ctx, line, segment, params) {
12518 var points = line.points;
12519 var ref = pathVars(points, segment, params), count = ref.count, start = ref.start, ilen = ref.ilen;
12520 var ref8 = params || {}, _move = ref8.move, move = _move === void 0 ? true : _move, reverse = ref8.reverse;
12521 var avgX = 0;
12522 var countX = 0;
12523 var i, point, prevX, minY, maxY, lastY;
12524 var pointIndex = function(index56) {
12525 return (start + (reverse ? ilen - index56 : index56)) % count;
12526 };
12527 var drawX = function() {
12528 if (minY !== maxY) {
12529 ctx.lineTo(avgX, maxY);
12530 ctx.lineTo(avgX, minY);
12531 ctx.lineTo(avgX, lastY);
12532 }
12533 };
12534 if (move) {
12535 point = points[pointIndex(0)];
12536 ctx.moveTo(point.x, point.y);
12537 }
12538 for(i = 0; i <= ilen; ++i){
12539 point = points[pointIndex(i)];
12540 if (point.skip) continue;
12541 var x = point.x;
12542 var y = point.y;
12543 var truncX = x | 0;
12544 if (truncX === prevX) {
12545 if (y < minY) minY = y;
12546 else if (y > maxY) maxY = y;
12547 avgX = (countX * avgX + x) / ++countX;
12548 } else {
12549 drawX();
12550 ctx.lineTo(x, y);
12551 prevX = truncX;
12552 countX = 0;
12553 minY = maxY = y;
12554 }
12555 lastY = y;
12556 }
12557 drawX();
12558 }
12559 function _getSegmentMethod(line) {
12560 var opts = line.options;
12561 var borderDash = opts.borderDash && opts.borderDash.length;
12562 var useFastPath = !line._decimated && !line._loop && !opts.tension && opts.cubicInterpolationMode !== "monotone" && !opts.stepped && !borderDash;
12563 return useFastPath ? fastPathSegment : pathSegment;
12564 }
12565 function _getInterpolationMethod(options) {
12566 if (options.stepped) return 0, _helpersSegmentJs.an;
12567 if (options.tension || options.cubicInterpolationMode === "monotone") return 0, _helpersSegmentJs.ao;
12568 return 0, _helpersSegmentJs.ap;
12569 }
12570 function strokePathWithCache(ctx, line, start, count) {
12571 var path = line._path;
12572 if (!path) {
12573 path = line._path = new Path2D();
12574 if (line.path(path, start, count)) path.closePath();
12575 }
12576 setStyle(ctx, line.options);
12577 ctx.stroke(path);
12578 }
12579 function strokePathDirect(ctx, line, start, count) {
12580 var segments = line.segments, options = line.options;
12581 var segmentMethod = _getSegmentMethod(line);
12582 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
12583 try {
12584 for(var _iterator = segments[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
12585 var segment = _step.value;
12586 setStyle(ctx, options, segment.style);
12587 ctx.beginPath();
12588 if (segmentMethod(ctx, line, segment, {
12589 start: start,
12590 end: start + count - 1
12591 })) ctx.closePath();
12592 ctx.stroke();
12593 }
12594 } catch (err) {
12595 _didIteratorError = true;
12596 _iteratorError = err;
12597 } finally{
12598 try {
12599 if (!_iteratorNormalCompletion && _iterator.return != null) {
12600 _iterator.return();
12601 }
12602 } finally{
12603 if (_didIteratorError) {
12604 throw _iteratorError;
12605 }
12606 }
12607 }
12608 }
12609 var usePath2D = typeof Path2D === "function";
12610 function draw(ctx, line, start, count) {
12611 if (usePath2D && !line.options.segment) strokePathWithCache(ctx, line, start, count);
12612 else strokePathDirect(ctx, line, start, count);
12613 }
12614 var LineElement = /*#__PURE__*/ function(Element) {
12615 "use strict";
12616 (0, _inheritsJsDefault.default)(LineElement, Element);
12617 var _super = (0, _createSuperJsDefault.default)(LineElement);
12618 function LineElement(cfg) {
12619 (0, _classCallCheckJsDefault.default)(this, LineElement);
12620 var _this;
12621 _this = _super.call(this);
12622 _this.animated = true;
12623 _this.options = undefined;
12624 _this._chart = undefined;
12625 _this._loop = undefined;
12626 _this._fullLoop = undefined;
12627 _this._path = undefined;
12628 _this._points = undefined;
12629 _this._segments = undefined;
12630 _this._decimated = false;
12631 _this._pointsUpdated = false;
12632 _this._datasetIndex = undefined;
12633 if (cfg) Object.assign((0, _assertThisInitializedJsDefault.default)(_this), cfg);
12634 return _this;
12635 }
12636 (0, _createClassJsDefault.default)(LineElement, [
12637 {
12638 key: "updateControlPoints",
12639 value: function updateControlPoints(chartArea, indexAxis) {
12640 var options = this.options;
12641 if ((options.tension || options.cubicInterpolationMode === "monotone") && !options.stepped && !this._pointsUpdated) {
12642 var loop = options.spanGaps ? this._loop : this._fullLoop;
12643 (0, _helpersSegmentJs.ak)(this._points, options, chartArea, loop, indexAxis);
12644 this._pointsUpdated = true;
12645 }
12646 }
12647 },
12648 {
12649 key: "points",
12650 get: function get() {
12651 return this._points;
12652 },
12653 set: function set(points) {
12654 this._points = points;
12655 delete this._segments;
12656 delete this._path;
12657 this._pointsUpdated = false;
12658 }
12659 },
12660 {
12661 key: "segments",
12662 get: function get() {
12663 return this._segments || (this._segments = (0, _helpersSegmentJs.al)(this, this.options.segment));
12664 }
12665 },
12666 {
12667 key: "first",
12668 value: function first() {
12669 var segments = this.segments;
12670 var points = this.points;
12671 return segments.length && points[segments[0].start];
12672 }
12673 },
12674 {
12675 key: "last",
12676 value: function last() {
12677 var segments = this.segments;
12678 var points = this.points;
12679 var count = segments.length;
12680 return count && points[segments[count - 1].end];
12681 }
12682 },
12683 {
12684 key: "interpolate",
12685 value: function interpolate(point, property) {
12686 var options = this.options;
12687 var value = point[property];
12688 var points = this.points;
12689 var segments = (0, _helpersSegmentJs.am)(this, {
12690 property: property,
12691 start: value,
12692 end: value
12693 });
12694 if (!segments.length) return;
12695 var result = [];
12696 var _interpolate = _getInterpolationMethod(options);
12697 var i, ilen;
12698 for(i = 0, ilen = segments.length; i < ilen; ++i){
12699 var _i = segments[i], start = _i.start, end = _i.end;
12700 var p1 = points[start];
12701 var p2 = points[end];
12702 if (p1 === p2) {
12703 result.push(p1);
12704 continue;
12705 }
12706 var t = Math.abs((value - p1[property]) / (p2[property] - p1[property]));
12707 var interpolated = _interpolate(p1, p2, t, options.stepped);
12708 interpolated[property] = point[property];
12709 result.push(interpolated);
12710 }
12711 return result.length === 1 ? result[0] : result;
12712 }
12713 },
12714 {
12715 key: "pathSegment",
12716 value: function pathSegment(ctx, segment, params) {
12717 var segmentMethod = _getSegmentMethod(this);
12718 return segmentMethod(ctx, this, segment, params);
12719 }
12720 },
12721 {
12722 key: "path",
12723 value: function path(ctx, start, count) {
12724 var segments = this.segments;
12725 var segmentMethod = _getSegmentMethod(this);
12726 var loop = this._loop;
12727 start = start || 0;
12728 count = count || this.points.length - start;
12729 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
12730 try {
12731 for(var _iterator = segments[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
12732 var segment = _step.value;
12733 loop &= segmentMethod(ctx, this, segment, {
12734 start: start,
12735 end: start + count - 1
12736 });
12737 }
12738 } catch (err) {
12739 _didIteratorError = true;
12740 _iteratorError = err;
12741 } finally{
12742 try {
12743 if (!_iteratorNormalCompletion && _iterator.return != null) {
12744 _iterator.return();
12745 }
12746 } finally{
12747 if (_didIteratorError) {
12748 throw _iteratorError;
12749 }
12750 }
12751 }
12752 return !!loop;
12753 }
12754 },
12755 {
12756 key: "draw",
12757 value: function draw2(ctx, chartArea, start, count) {
12758 var options = this.options || {};
12759 var points = this.points || [];
12760 if (points.length && options.borderWidth) {
12761 ctx.save();
12762 draw(ctx, this, start, count);
12763 ctx.restore();
12764 }
12765 if (this.animated) {
12766 this._pointsUpdated = false;
12767 this._path = undefined;
12768 }
12769 }
12770 }
12771 ]);
12772 return LineElement;
12773 }((0, _wrapNativeSuperJsDefault.default)(Element));
12774 LineElement.id = "line";
12775 LineElement.defaults = {
12776 borderCapStyle: "butt",
12777 borderDash: [],
12778 borderDashOffset: 0,
12779 borderJoinStyle: "miter",
12780 borderWidth: 3,
12781 capBezierPoints: true,
12782 cubicInterpolationMode: "default",
12783 fill: false,
12784 spanGaps: false,
12785 stepped: false,
12786 tension: 0
12787 };
12788 LineElement.defaultRoutes = {
12789 backgroundColor: "backgroundColor",
12790 borderColor: "borderColor"
12791 };
12792 LineElement.descriptors = {
12793 _scriptable: true,
12794 _indexable: function(name) {
12795 return name !== "borderDash" && name !== "fill";
12796 }
12797 };
12798 function inRange$1(el, pos, axis, useFinalPosition) {
12799 var options = el.options;
12800 var ref = el.getProps([
12801 axis
12802 ], useFinalPosition), value = ref[axis];
12803 return Math.abs(pos - value) < options.radius + options.hitRadius;
12804 }
12805 var PointElement = /*#__PURE__*/ function(Element) {
12806 "use strict";
12807 (0, _inheritsJsDefault.default)(PointElement, Element);
12808 var _super = (0, _createSuperJsDefault.default)(PointElement);
12809 function PointElement(cfg) {
12810 (0, _classCallCheckJsDefault.default)(this, PointElement);
12811 var _this;
12812 _this = _super.call(this);
12813 _this.options = undefined;
12814 _this.parsed = undefined;
12815 _this.skip = undefined;
12816 _this.stop = undefined;
12817 if (cfg) Object.assign((0, _assertThisInitializedJsDefault.default)(_this), cfg);
12818 return _this;
12819 }
12820 (0, _createClassJsDefault.default)(PointElement, [
12821 {
12822 key: "inRange",
12823 value: function inRange2(mouseX, mouseY, useFinalPosition) {
12824 var options = this.options;
12825 var ref = this.getProps([
12826 "x",
12827 "y"
12828 ], useFinalPosition), x = ref.x, y = ref.y;
12829 return Math.pow(mouseX - x, 2) + Math.pow(mouseY - y, 2) < Math.pow(options.hitRadius + options.radius, 2);
12830 }
12831 },
12832 {
12833 key: "inXRange",
12834 value: function inXRange(mouseX, useFinalPosition) {
12835 return inRange$1(this, mouseX, "x", useFinalPosition);
12836 }
12837 },
12838 {
12839 key: "inYRange",
12840 value: function inYRange(mouseY, useFinalPosition) {
12841 return inRange$1(this, mouseY, "y", useFinalPosition);
12842 }
12843 },
12844 {
12845 key: "getCenterPoint",
12846 value: function getCenterPoint(useFinalPosition) {
12847 var ref = this.getProps([
12848 "x",
12849 "y"
12850 ], useFinalPosition), x = ref.x, y = ref.y;
12851 return {
12852 x: x,
12853 y: y
12854 };
12855 }
12856 },
12857 {
12858 key: "size",
12859 value: function size(options) {
12860 options = options || this.options || {};
12861 var radius = options.radius || 0;
12862 radius = Math.max(radius, radius && options.hoverRadius || 0);
12863 var borderWidth = radius && options.borderWidth || 0;
12864 return (radius + borderWidth) * 2;
12865 }
12866 },
12867 {
12868 key: "draw",
12869 value: function draw2(ctx, area) {
12870 var options = this.options;
12871 if (this.skip || options.radius < 0.1 || !(0, _helpersSegmentJs.B)(this, area, this.size(options) / 2)) return;
12872 ctx.strokeStyle = options.borderColor;
12873 ctx.lineWidth = options.borderWidth;
12874 ctx.fillStyle = options.backgroundColor;
12875 (0, _helpersSegmentJs.as)(ctx, options, this.x, this.y);
12876 }
12877 },
12878 {
12879 key: "getRange",
12880 value: function getRange() {
12881 var options = this.options || {};
12882 return options.radius + options.hitRadius;
12883 }
12884 }
12885 ]);
12886 return PointElement;
12887 }((0, _wrapNativeSuperJsDefault.default)(Element));
12888 PointElement.id = "point";
12889 PointElement.defaults = {
12890 borderWidth: 1,
12891 hitRadius: 1,
12892 hoverBorderWidth: 1,
12893 hoverRadius: 4,
12894 pointStyle: "circle",
12895 radius: 3,
12896 rotation: 0
12897 };
12898 PointElement.defaultRoutes = {
12899 backgroundColor: "backgroundColor",
12900 borderColor: "borderColor"
12901 };
12902 function getBarBounds(bar, useFinalPosition) {
12903 var ref = bar.getProps([
12904 "x",
12905 "y",
12906 "base",
12907 "width",
12908 "height"
12909 ], useFinalPosition), x = ref.x, y = ref.y, base = ref.base, width = ref.width, height = ref.height;
12910 var left, right, top, bottom, half;
12911 if (bar.horizontal) {
12912 half = height / 2;
12913 left = Math.min(x, base);
12914 right = Math.max(x, base);
12915 top = y - half;
12916 bottom = y + half;
12917 } else {
12918 half = width / 2;
12919 left = x - half;
12920 right = x + half;
12921 top = Math.min(y, base);
12922 bottom = Math.max(y, base);
12923 }
12924 return {
12925 left: left,
12926 top: top,
12927 right: right,
12928 bottom: bottom
12929 };
12930 }
12931 function skipOrLimit(skip1, value, min, max) {
12932 return skip1 ? 0 : (0, _helpersSegmentJs.w)(value, min, max);
12933 }
12934 function parseBorderWidth(bar, maxW, maxH) {
12935 var value = bar.options.borderWidth;
12936 var skip2 = bar.borderSkipped;
12937 var o = (0, _helpersSegmentJs.au)(value);
12938 return {
12939 t: skipOrLimit(skip2.top, o.top, 0, maxH),
12940 r: skipOrLimit(skip2.right, o.right, 0, maxW),
12941 b: skipOrLimit(skip2.bottom, o.bottom, 0, maxH),
12942 l: skipOrLimit(skip2.left, o.left, 0, maxW)
12943 };
12944 }
12945 function parseBorderRadius(bar, maxW, maxH) {
12946 var enableBorderRadius = bar.getProps([
12947 "enableBorderRadius"
12948 ]).enableBorderRadius;
12949 var value = bar.options.borderRadius;
12950 var o = (0, _helpersSegmentJs.av)(value);
12951 var maxR = Math.min(maxW, maxH);
12952 var skip3 = bar.borderSkipped;
12953 var enableBorder = enableBorderRadius || (0, _helpersSegmentJs.i)(value);
12954 return {
12955 topLeft: skipOrLimit(!enableBorder || skip3.top || skip3.left, o.topLeft, 0, maxR),
12956 topRight: skipOrLimit(!enableBorder || skip3.top || skip3.right, o.topRight, 0, maxR),
12957 bottomLeft: skipOrLimit(!enableBorder || skip3.bottom || skip3.left, o.bottomLeft, 0, maxR),
12958 bottomRight: skipOrLimit(!enableBorder || skip3.bottom || skip3.right, o.bottomRight, 0, maxR)
12959 };
12960 }
12961 function boundingRects(bar) {
12962 var bounds = getBarBounds(bar);
12963 var width = bounds.right - bounds.left;
12964 var height = bounds.bottom - bounds.top;
12965 var border = parseBorderWidth(bar, width / 2, height / 2);
12966 var radius = parseBorderRadius(bar, width / 2, height / 2);
12967 return {
12968 outer: {
12969 x: bounds.left,
12970 y: bounds.top,
12971 w: width,
12972 h: height,
12973 radius: radius
12974 },
12975 inner: {
12976 x: bounds.left + border.l,
12977 y: bounds.top + border.t,
12978 w: width - border.l - border.r,
12979 h: height - border.t - border.b,
12980 radius: {
12981 topLeft: Math.max(0, radius.topLeft - Math.max(border.t, border.l)),
12982 topRight: Math.max(0, radius.topRight - Math.max(border.t, border.r)),
12983 bottomLeft: Math.max(0, radius.bottomLeft - Math.max(border.b, border.l)),
12984 bottomRight: Math.max(0, radius.bottomRight - Math.max(border.b, border.r))
12985 }
12986 }
12987 };
12988 }
12989 function inRange(bar, x, y, useFinalPosition) {
12990 var skipX = x === null;
12991 var skipY = y === null;
12992 var skipBoth = skipX && skipY;
12993 var bounds = bar && !skipBoth && getBarBounds(bar, useFinalPosition);
12994 return bounds && (skipX || (0, _helpersSegmentJs.ai)(x, bounds.left, bounds.right)) && (skipY || (0, _helpersSegmentJs.ai)(y, bounds.top, bounds.bottom));
12995 }
12996 function hasRadius(radius) {
12997 return radius.topLeft || radius.topRight || radius.bottomLeft || radius.bottomRight;
12998 }
12999 function addNormalRectPath(ctx, rect) {
13000 ctx.rect(rect.x, rect.y, rect.w, rect.h);
13001 }
13002 function inflateRect(rect, amount) {
13003 var refRect = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
13004 var x = rect.x !== refRect.x ? -amount : 0;
13005 var y = rect.y !== refRect.y ? -amount : 0;
13006 var w = (rect.x + rect.w !== refRect.x + refRect.w ? amount : 0) - x;
13007 var h = (rect.y + rect.h !== refRect.y + refRect.h ? amount : 0) - y;
13008 return {
13009 x: rect.x + x,
13010 y: rect.y + y,
13011 w: rect.w + w,
13012 h: rect.h + h,
13013 radius: rect.radius
13014 };
13015 }
13016 var BarElement = /*#__PURE__*/ function(Element) {
13017 "use strict";
13018 (0, _inheritsJsDefault.default)(BarElement, Element);
13019 var _super = (0, _createSuperJsDefault.default)(BarElement);
13020 function BarElement(cfg) {
13021 (0, _classCallCheckJsDefault.default)(this, BarElement);
13022 var _this;
13023 _this = _super.call(this);
13024 _this.options = undefined;
13025 _this.horizontal = undefined;
13026 _this.base = undefined;
13027 _this.width = undefined;
13028 _this.height = undefined;
13029 _this.inflateAmount = undefined;
13030 if (cfg) Object.assign((0, _assertThisInitializedJsDefault.default)(_this), cfg);
13031 return _this;
13032 }
13033 (0, _createClassJsDefault.default)(BarElement, [
13034 {
13035 key: "draw",
13036 value: function draw2(ctx) {
13037 var ref = this, inflateAmount = ref.inflateAmount, _options = ref.options, borderColor = _options.borderColor, backgroundColor = _options.backgroundColor;
13038 var ref9 = boundingRects(this), inner = ref9.inner, outer = ref9.outer;
13039 var addRectPath = hasRadius(outer.radius) ? (0, _helpersSegmentJs.at) : addNormalRectPath;
13040 ctx.save();
13041 if (outer.w !== inner.w || outer.h !== inner.h) {
13042 ctx.beginPath();
13043 addRectPath(ctx, inflateRect(outer, inflateAmount, inner));
13044 ctx.clip();
13045 addRectPath(ctx, inflateRect(inner, -inflateAmount, outer));
13046 ctx.fillStyle = borderColor;
13047 ctx.fill("evenodd");
13048 }
13049 ctx.beginPath();
13050 addRectPath(ctx, inflateRect(inner, inflateAmount));
13051 ctx.fillStyle = backgroundColor;
13052 ctx.fill();
13053 ctx.restore();
13054 }
13055 },
13056 {
13057 key: "inRange",
13058 value: function inRange2(mouseX, mouseY, useFinalPosition) {
13059 return inRange(this, mouseX, mouseY, useFinalPosition);
13060 }
13061 },
13062 {
13063 key: "inXRange",
13064 value: function inXRange(mouseX, useFinalPosition) {
13065 return inRange(this, mouseX, null, useFinalPosition);
13066 }
13067 },
13068 {
13069 key: "inYRange",
13070 value: function inYRange(mouseY, useFinalPosition) {
13071 return inRange(this, null, mouseY, useFinalPosition);
13072 }
13073 },
13074 {
13075 key: "getCenterPoint",
13076 value: function getCenterPoint(useFinalPosition) {
13077 var ref = this.getProps([
13078 "x",
13079 "y",
13080 "base",
13081 "horizontal"
13082 ], useFinalPosition), x = ref.x, y = ref.y, base = ref.base, horizontal = ref.horizontal;
13083 return {
13084 x: horizontal ? (x + base) / 2 : x,
13085 y: horizontal ? y : (y + base) / 2
13086 };
13087 }
13088 },
13089 {
13090 key: "getRange",
13091 value: function getRange(axis) {
13092 return axis === "x" ? this.width / 2 : this.height / 2;
13093 }
13094 }
13095 ]);
13096 return BarElement;
13097 }((0, _wrapNativeSuperJsDefault.default)(Element));
13098 BarElement.id = "bar";
13099 BarElement.defaults = {
13100 borderSkipped: "start",
13101 borderWidth: 0,
13102 borderRadius: 0,
13103 inflateAmount: "auto",
13104 pointStyle: undefined
13105 };
13106 BarElement.defaultRoutes = {
13107 backgroundColor: "backgroundColor",
13108 borderColor: "borderColor"
13109 };
13110 var elements = /*#__PURE__*/ Object.freeze({
13111 __proto__: null,
13112 ArcElement: ArcElement,
13113 LineElement: LineElement,
13114 PointElement: PointElement,
13115 BarElement: BarElement
13116 });
13117 function lttbDecimation(data, start, count, availableWidth, options) {
13118 var samples = options.samples || availableWidth;
13119 if (samples >= count) return data.slice(start, start + count);
13120 var decimated = [];
13121 var bucketWidth = (count - 2) / (samples - 2);
13122 var sampledIndex = 0;
13123 var endIndex = start + count - 1;
13124 var a = start;
13125 var i, maxAreaPoint, maxArea, area, nextA;
13126 decimated[sampledIndex++] = data[a];
13127 for(i = 0; i < samples - 2; i++){
13128 var avgX = 0;
13129 var avgY = 0;
13130 var j = void 0;
13131 var avgRangeStart = Math.floor((i + 1) * bucketWidth) + 1 + start;
13132 var avgRangeEnd = Math.min(Math.floor((i + 2) * bucketWidth) + 1, count) + start;
13133 var avgRangeLength = avgRangeEnd - avgRangeStart;
13134 for(j = avgRangeStart; j < avgRangeEnd; j++){
13135 avgX += data[j].x;
13136 avgY += data[j].y;
13137 }
13138 avgX /= avgRangeLength;
13139 avgY /= avgRangeLength;
13140 var rangeOffs = Math.floor(i * bucketWidth) + 1 + start;
13141 var rangeTo = Math.min(Math.floor((i + 1) * bucketWidth) + 1, count) + start;
13142 var _a = data[a], pointAx = _a.x, pointAy = _a.y;
13143 maxArea = area = -1;
13144 for(j = rangeOffs; j < rangeTo; j++){
13145 area = 0.5 * Math.abs((pointAx - avgX) * (data[j].y - pointAy) - (pointAx - data[j].x) * (avgY - pointAy));
13146 if (area > maxArea) {
13147 maxArea = area;
13148 maxAreaPoint = data[j];
13149 nextA = j;
13150 }
13151 }
13152 decimated[sampledIndex++] = maxAreaPoint;
13153 a = nextA;
13154 }
13155 decimated[sampledIndex++] = data[endIndex];
13156 return decimated;
13157 }
13158 function minMaxDecimation(data, start, count, availableWidth) {
13159 var avgX = 0;
13160 var countX = 0;
13161 var i, point, x, y, prevX, minIndex, maxIndex, startIndex, minY, maxY;
13162 var decimated = [];
13163 var endIndex = start + count - 1;
13164 var xMin = data[start].x;
13165 var xMax = data[endIndex].x;
13166 var dx = xMax - xMin;
13167 for(i = start; i < start + count; ++i){
13168 point = data[i];
13169 x = (point.x - xMin) / dx * availableWidth;
13170 y = point.y;
13171 var truncX = x | 0;
13172 if (truncX === prevX) {
13173 if (y < minY) {
13174 minY = y;
13175 minIndex = i;
13176 } else if (y > maxY) {
13177 maxY = y;
13178 maxIndex = i;
13179 }
13180 avgX = (countX * avgX + point.x) / ++countX;
13181 } else {
13182 var lastIndex = i - 1;
13183 if (!(0, _helpersSegmentJs.k)(minIndex) && !(0, _helpersSegmentJs.k)(maxIndex)) {
13184 var intermediateIndex1 = Math.min(minIndex, maxIndex);
13185 var intermediateIndex2 = Math.max(minIndex, maxIndex);
13186 if (intermediateIndex1 !== startIndex && intermediateIndex1 !== lastIndex) decimated.push((0, _objectSpreadJsDefault.default)({}, data[intermediateIndex1], {
13187 x: avgX
13188 }));
13189 if (intermediateIndex2 !== startIndex && intermediateIndex2 !== lastIndex) decimated.push((0, _objectSpreadJsDefault.default)({}, data[intermediateIndex2], {
13190 x: avgX
13191 }));
13192 }
13193 if (i > 0 && lastIndex !== startIndex) decimated.push(data[lastIndex]);
13194 decimated.push(point);
13195 prevX = truncX;
13196 countX = 0;
13197 minY = maxY = y;
13198 minIndex = maxIndex = startIndex = i;
13199 }
13200 }
13201 return decimated;
13202 }
13203 function cleanDecimatedDataset(dataset) {
13204 if (dataset._decimated) {
13205 var data = dataset._data;
13206 delete dataset._decimated;
13207 delete dataset._data;
13208 Object.defineProperty(dataset, "data", {
13209 value: data
13210 });
13211 }
13212 }
13213 function cleanDecimatedData(chart) {
13214 chart.data.datasets.forEach(function(dataset) {
13215 cleanDecimatedDataset(dataset);
13216 });
13217 }
13218 function getStartAndCountOfVisiblePointsSimplified(meta, points) {
13219 var pointCount = points.length;
13220 var start = 0;
13221 var count;
13222 var iScale = meta.iScale;
13223 var ref = iScale.getUserBounds(), min = ref.min, max = ref.max, minDefined = ref.minDefined, maxDefined = ref.maxDefined;
13224 if (minDefined) start = (0, _helpersSegmentJs.w)((0, _helpersSegmentJs.x)(points, iScale.axis, min).lo, 0, pointCount - 1);
13225 if (maxDefined) count = (0, _helpersSegmentJs.w)((0, _helpersSegmentJs.x)(points, iScale.axis, max).hi + 1, start, pointCount) - start;
13226 else count = pointCount - start;
13227 return {
13228 start: start,
13229 count: count
13230 };
13231 }
13232 var plugin_decimation = {
13233 id: "decimation",
13234 defaults: {
13235 algorithm: "min-max",
13236 enabled: false
13237 },
13238 beforeElementsUpdate: function(chart, args, options) {
13239 if (!options.enabled) {
13240 cleanDecimatedData(chart);
13241 return;
13242 }
13243 var availableWidth = chart.width;
13244 chart.data.datasets.forEach(function(dataset, datasetIndex) {
13245 var _data = dataset._data, indexAxis = dataset.indexAxis;
13246 var meta = chart.getDatasetMeta(datasetIndex);
13247 var data = _data || dataset.data;
13248 if ((0, _helpersSegmentJs.a)([
13249 indexAxis,
13250 chart.options.indexAxis
13251 ]) === "y") return;
13252 if (!meta.controller.supportsDecimation) return;
13253 var xAxis = chart.scales[meta.xAxisID];
13254 if (xAxis.type !== "linear" && xAxis.type !== "time") return;
13255 if (chart.options.parsing) return;
13256 var ref = getStartAndCountOfVisiblePointsSimplified(meta, data), start = ref.start, count = ref.count;
13257 var threshold = options.threshold || 4 * availableWidth;
13258 if (count <= threshold) {
13259 cleanDecimatedDataset(dataset);
13260 return;
13261 }
13262 if ((0, _helpersSegmentJs.k)(_data)) {
13263 dataset._data = data;
13264 delete dataset.data;
13265 Object.defineProperty(dataset, "data", {
13266 configurable: true,
13267 enumerable: true,
13268 get: function get() {
13269 return this._decimated;
13270 },
13271 set: function set(d) {
13272 this._data = d;
13273 }
13274 });
13275 }
13276 var decimated;
13277 switch(options.algorithm){
13278 case "lttb":
13279 decimated = lttbDecimation(data, start, count, availableWidth, options);
13280 break;
13281 case "min-max":
13282 decimated = minMaxDecimation(data, start, count, availableWidth);
13283 break;
13284 default:
13285 throw new Error("Unsupported decimation algorithm '".concat(options.algorithm, "'"));
13286 }
13287 dataset._decimated = decimated;
13288 });
13289 },
13290 destroy: function(chart) {
13291 cleanDecimatedData(chart);
13292 }
13293 };
13294 function _segments(line, target, property) {
13295 var segments = line.segments;
13296 var points = line.points;
13297 var tpoints = target.points;
13298 var parts = [];
13299 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
13300 try {
13301 for(var _iterator = segments[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
13302 var segment = _step.value;
13303 var start = segment.start, end = segment.end;
13304 end = _findSegmentEnd(start, end, points);
13305 var bounds = _getBounds(property, points[start], points[end], segment.loop);
13306 if (!target.segments) {
13307 parts.push({
13308 source: segment,
13309 target: bounds,
13310 start: points[start],
13311 end: points[end]
13312 });
13313 continue;
13314 }
13315 var targetSegments = (0, _helpersSegmentJs.am)(target, bounds);
13316 var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
13317 try {
13318 for(var _iterator1 = targetSegments[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
13319 var tgt = _step1.value;
13320 var subBounds = _getBounds(property, tpoints[tgt.start], tpoints[tgt.end], tgt.loop);
13321 var fillSources = (0, _helpersSegmentJs.aw)(segment, points, subBounds);
13322 var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = undefined;
13323 try {
13324 for(var _iterator2 = fillSources[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true){
13325 var fillSource = _step2.value;
13326 parts.push({
13327 source: fillSource,
13328 target: tgt,
13329 start: (0, _definePropertyJsDefault.default)({}, property, _getEdge(bounds, subBounds, "start", Math.max)),
13330 end: (0, _definePropertyJsDefault.default)({}, property, _getEdge(bounds, subBounds, "end", Math.min))
13331 });
13332 }
13333 } catch (err) {
13334 _didIteratorError2 = true;
13335 _iteratorError2 = err;
13336 } finally{
13337 try {
13338 if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
13339 _iterator2.return();
13340 }
13341 } finally{
13342 if (_didIteratorError2) {
13343 throw _iteratorError2;
13344 }
13345 }
13346 }
13347 }
13348 } catch (err) {
13349 _didIteratorError1 = true;
13350 _iteratorError1 = err;
13351 } finally{
13352 try {
13353 if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
13354 _iterator1.return();
13355 }
13356 } finally{
13357 if (_didIteratorError1) {
13358 throw _iteratorError1;
13359 }
13360 }
13361 }
13362 }
13363 } catch (err) {
13364 _didIteratorError = true;
13365 _iteratorError = err;
13366 } finally{
13367 try {
13368 if (!_iteratorNormalCompletion && _iterator.return != null) {
13369 _iterator.return();
13370 }
13371 } finally{
13372 if (_didIteratorError) {
13373 throw _iteratorError;
13374 }
13375 }
13376 }
13377 return parts;
13378 }
13379 function _getBounds(property, first, last, loop) {
13380 if (loop) return;
13381 var start = first[property];
13382 var end = last[property];
13383 if (property === "angle") {
13384 start = (0, _helpersSegmentJs.ax)(start);
13385 end = (0, _helpersSegmentJs.ax)(end);
13386 }
13387 return {
13388 property: property,
13389 start: start,
13390 end: end
13391 };
13392 }
13393 function _pointsFromSegments(boundary, line) {
13394 var ref = boundary || {}, _x = ref.x, x = _x === void 0 ? null : _x, _y = ref.y, y = _y === void 0 ? null : _y;
13395 var linePoints = line.points;
13396 var points = [];
13397 line.segments.forEach(function(param) {
13398 var start = param.start, end = param.end;
13399 end = _findSegmentEnd(start, end, linePoints);
13400 var first = linePoints[start];
13401 var last = linePoints[end];
13402 if (y !== null) {
13403 points.push({
13404 x: first.x,
13405 y: y
13406 });
13407 points.push({
13408 x: last.x,
13409 y: y
13410 });
13411 } else if (x !== null) {
13412 points.push({
13413 x: x,
13414 y: first.y
13415 });
13416 points.push({
13417 x: x,
13418 y: last.y
13419 });
13420 }
13421 });
13422 return points;
13423 }
13424 function _findSegmentEnd(start, end, points) {
13425 for(; end > start; end--){
13426 var point = points[end];
13427 if (!isNaN(point.x) && !isNaN(point.y)) break;
13428 }
13429 return end;
13430 }
13431 function _getEdge(a, b, prop, fn) {
13432 if (a && b) return fn(a[prop], b[prop]);
13433 return a ? a[prop] : b ? b[prop] : 0;
13434 }
13435 function _createBoundaryLine(boundary, line) {
13436 var points = [];
13437 var _loop = false;
13438 if ((0, _helpersSegmentJs.b)(boundary)) {
13439 _loop = true;
13440 points = boundary;
13441 } else points = _pointsFromSegments(boundary, line);
13442 return points.length ? new LineElement({
13443 points: points,
13444 options: {
13445 tension: 0
13446 },
13447 _loop: _loop,
13448 _fullLoop: _loop
13449 }) : null;
13450 }
13451 function _resolveTarget(sources, index57, propagate) {
13452 var source = sources[index57];
13453 var fill1 = source.fill;
13454 var visited = [
13455 index57
13456 ];
13457 var target;
13458 if (!propagate) return fill1;
13459 while(fill1 !== false && visited.indexOf(fill1) === -1){
13460 if (!(0, _helpersSegmentJs.g)(fill1)) return fill1;
13461 target = sources[fill1];
13462 if (!target) return false;
13463 if (target.visible) return fill1;
13464 visited.push(fill1);
13465 fill1 = target.fill;
13466 }
13467 return false;
13468 }
13469 function _decodeFill(line, index58, count) {
13470 var fill2 = parseFillOption(line);
13471 if ((0, _helpersSegmentJs.i)(fill2)) return isNaN(fill2.value) ? false : fill2;
13472 var target = parseFloat(fill2);
13473 if ((0, _helpersSegmentJs.g)(target) && Math.floor(target) === target) return decodeTargetIndex(fill2[0], index58, target, count);
13474 return [
13475 "origin",
13476 "start",
13477 "end",
13478 "stack",
13479 "shape"
13480 ].indexOf(fill2) >= 0 && fill2;
13481 }
13482 function decodeTargetIndex(firstCh, index59, target, count) {
13483 if (firstCh === "-" || firstCh === "+") target = index59 + target;
13484 if (target === index59 || target < 0 || target >= count) return false;
13485 return target;
13486 }
13487 function _getTargetPixel(fill3, scale) {
13488 var pixel = null;
13489 if (fill3 === "start") pixel = scale.bottom;
13490 else if (fill3 === "end") pixel = scale.top;
13491 else if ((0, _helpersSegmentJs.i)(fill3)) pixel = scale.getPixelForValue(fill3.value);
13492 else if (scale.getBasePixel) pixel = scale.getBasePixel();
13493 return pixel;
13494 }
13495 function _getTargetValue(fill4, scale, startValue) {
13496 var value;
13497 if (fill4 === "start") value = startValue;
13498 else if (fill4 === "end") value = scale.options.reverse ? scale.min : scale.max;
13499 else if ((0, _helpersSegmentJs.i)(fill4)) value = fill4.value;
13500 else value = scale.getBaseValue();
13501 return value;
13502 }
13503 function parseFillOption(line) {
13504 var options = line.options;
13505 var fillOption = options.fill;
13506 var fill5 = (0, _helpersSegmentJs.v)(fillOption && fillOption.target, fillOption);
13507 if (fill5 === undefined) fill5 = !!options.backgroundColor;
13508 if (fill5 === false || fill5 === null) return false;
13509 if (fill5 === true) return "origin";
13510 return fill5;
13511 }
13512 function _buildStackLine(source) {
13513 var scale = source.scale, index60 = source.index, line = source.line;
13514 var points = [];
13515 var segments = line.segments;
13516 var sourcePoints = line.points;
13517 var linesBelow = getLinesBelow(scale, index60);
13518 linesBelow.push(_createBoundaryLine({
13519 x: null,
13520 y: scale.bottom
13521 }, line));
13522 for(var i = 0; i < segments.length; i++){
13523 var segment = segments[i];
13524 for(var j = segment.start; j <= segment.end; j++)addPointsBelow(points, sourcePoints[j], linesBelow);
13525 }
13526 return new LineElement({
13527 points: points,
13528 options: {}
13529 });
13530 }
13531 function getLinesBelow(scale, index61) {
13532 var below = [];
13533 var metas = scale.getMatchingVisibleMetas("line");
13534 for(var i = 0; i < metas.length; i++){
13535 var meta = metas[i];
13536 if (meta.index === index61) break;
13537 if (!meta.hidden) below.unshift(meta.dataset);
13538 }
13539 return below;
13540 }
13541 function addPointsBelow(points, sourcePoint, linesBelow) {
13542 var _points;
13543 var postponed = [];
13544 for(var j = 0; j < linesBelow.length; j++){
13545 var line = linesBelow[j];
13546 var ref = findPoint(line, sourcePoint, "x"), first = ref.first, last = ref.last, point = ref.point;
13547 if (!point || first && last) continue;
13548 if (first) postponed.unshift(point);
13549 else {
13550 points.push(point);
13551 if (!last) break;
13552 }
13553 }
13554 (_points = points).push.apply(_points, (0, _toConsumableArrayJsDefault.default)(postponed));
13555 }
13556 function findPoint(line, sourcePoint, property) {
13557 var point = line.interpolate(sourcePoint, property);
13558 if (!point) return {};
13559 var pointValue = point[property];
13560 var segments = line.segments;
13561 var linePoints = line.points;
13562 var first = false;
13563 var last = false;
13564 for(var i = 0; i < segments.length; i++){
13565 var segment = segments[i];
13566 var firstValue = linePoints[segment.start][property];
13567 var lastValue = linePoints[segment.end][property];
13568 if ((0, _helpersSegmentJs.ai)(pointValue, firstValue, lastValue)) {
13569 first = pointValue === firstValue;
13570 last = pointValue === lastValue;
13571 break;
13572 }
13573 }
13574 return {
13575 first: first,
13576 last: last,
13577 point: point
13578 };
13579 }
13580 var simpleArc = /*#__PURE__*/ function() {
13581 "use strict";
13582 function simpleArc(opts) {
13583 (0, _classCallCheckJsDefault.default)(this, simpleArc);
13584 this.x = opts.x;
13585 this.y = opts.y;
13586 this.radius = opts.radius;
13587 }
13588 (0, _createClassJsDefault.default)(simpleArc, [
13589 {
13590 key: "pathSegment",
13591 value: function pathSegment(ctx, bounds, opts) {
13592 var ref = this, x = ref.x, y = ref.y, radius = ref.radius;
13593 bounds = bounds || {
13594 start: 0,
13595 end: (0, _helpersSegmentJs.T)
13596 };
13597 ctx.arc(x, y, radius, bounds.end, bounds.start, true);
13598 return !opts.bounds;
13599 }
13600 },
13601 {
13602 key: "interpolate",
13603 value: function interpolate(point) {
13604 var ref = this, x = ref.x, y = ref.y, radius = ref.radius;
13605 var angle = point.angle;
13606 return {
13607 x: x + Math.cos(angle) * radius,
13608 y: y + Math.sin(angle) * radius,
13609 angle: angle
13610 };
13611 }
13612 }
13613 ]);
13614 return simpleArc;
13615 }();
13616 function _getTarget(source) {
13617 var chart = source.chart, fill6 = source.fill, line = source.line;
13618 if ((0, _helpersSegmentJs.g)(fill6)) return getLineByIndex(chart, fill6);
13619 if (fill6 === "stack") return _buildStackLine(source);
13620 if (fill6 === "shape") return true;
13621 var boundary = computeBoundary(source);
13622 if (boundary instanceof simpleArc) return boundary;
13623 return _createBoundaryLine(boundary, line);
13624 }
13625 function getLineByIndex(chart, index62) {
13626 var meta = chart.getDatasetMeta(index62);
13627 var visible = meta && chart.isDatasetVisible(index62);
13628 return visible ? meta.dataset : null;
13629 }
13630 function computeBoundary(source) {
13631 var scale = source.scale || {};
13632 if (scale.getPointPositionForValue) return computeCircularBoundary(source);
13633 return computeLinearBoundary(source);
13634 }
13635 function computeLinearBoundary(source) {
13636 var _scale = source.scale, scale = _scale === void 0 ? {} : _scale, fill7 = source.fill;
13637 var pixel = _getTargetPixel(fill7, scale);
13638 if ((0, _helpersSegmentJs.g)(pixel)) {
13639 var horizontal = scale.isHorizontal();
13640 return {
13641 x: horizontal ? pixel : null,
13642 y: horizontal ? null : pixel
13643 };
13644 }
13645 return null;
13646 }
13647 function computeCircularBoundary(source) {
13648 var scale = source.scale, fill8 = source.fill;
13649 var options = scale.options;
13650 var length = scale.getLabels().length;
13651 var start = options.reverse ? scale.max : scale.min;
13652 var value = _getTargetValue(fill8, scale, start);
13653 var target = [];
13654 if (options.grid.circular) {
13655 var center = scale.getPointPositionForValue(0, start);
13656 return new simpleArc({
13657 x: center.x,
13658 y: center.y,
13659 radius: scale.getDistanceFromCenterForValue(value)
13660 });
13661 }
13662 for(var i = 0; i < length; ++i)target.push(scale.getPointPositionForValue(i, value));
13663 return target;
13664 }
13665 function _drawfill(ctx, source, area) {
13666 var target = _getTarget(source);
13667 var line = source.line, scale = source.scale, axis = source.axis;
13668 var lineOpts = line.options;
13669 var fillOption = lineOpts.fill;
13670 var color = lineOpts.backgroundColor;
13671 var ref = fillOption || {}, _above = ref.above, above = _above === void 0 ? color : _above, _below = ref.below, below = _below === void 0 ? color : _below;
13672 if (target && line.points.length) {
13673 (0, _helpersSegmentJs.X)(ctx, area);
13674 doFill(ctx, {
13675 line: line,
13676 target: target,
13677 above: above,
13678 below: below,
13679 area: area,
13680 scale: scale,
13681 axis: axis
13682 });
13683 (0, _helpersSegmentJs.Z)(ctx);
13684 }
13685 }
13686 function doFill(ctx, cfg) {
13687 var line = cfg.line, target = cfg.target, above = cfg.above, below = cfg.below, area = cfg.area, scale = cfg.scale;
13688 var property = line._loop ? "angle" : cfg.axis;
13689 ctx.save();
13690 if (property === "x" && below !== above) {
13691 clipVertical(ctx, target, area.top);
13692 fill(ctx, {
13693 line: line,
13694 target: target,
13695 color: above,
13696 scale: scale,
13697 property: property
13698 });
13699 ctx.restore();
13700 ctx.save();
13701 clipVertical(ctx, target, area.bottom);
13702 }
13703 fill(ctx, {
13704 line: line,
13705 target: target,
13706 color: below,
13707 scale: scale,
13708 property: property
13709 });
13710 ctx.restore();
13711 }
13712 function clipVertical(ctx, target, clipY) {
13713 var segments = target.segments, points = target.points;
13714 var first = true;
13715 var lineLoop = false;
13716 ctx.beginPath();
13717 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
13718 try {
13719 for(var _iterator = segments[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
13720 var segment = _step.value;
13721 var start = segment.start, end = segment.end;
13722 var firstPoint = points[start];
13723 var lastPoint = points[_findSegmentEnd(start, end, points)];
13724 if (first) {
13725 ctx.moveTo(firstPoint.x, firstPoint.y);
13726 first = false;
13727 } else {
13728 ctx.lineTo(firstPoint.x, clipY);
13729 ctx.lineTo(firstPoint.x, firstPoint.y);
13730 }
13731 lineLoop = !!target.pathSegment(ctx, segment, {
13732 move: lineLoop
13733 });
13734 if (lineLoop) ctx.closePath();
13735 else ctx.lineTo(lastPoint.x, clipY);
13736 }
13737 } catch (err) {
13738 _didIteratorError = true;
13739 _iteratorError = err;
13740 } finally{
13741 try {
13742 if (!_iteratorNormalCompletion && _iterator.return != null) {
13743 _iterator.return();
13744 }
13745 } finally{
13746 if (_didIteratorError) {
13747 throw _iteratorError;
13748 }
13749 }
13750 }
13751 ctx.lineTo(target.first().x, clipY);
13752 ctx.closePath();
13753 ctx.clip();
13754 }
13755 function fill(ctx, cfg) {
13756 var line = cfg.line, target = cfg.target, property = cfg.property, color = cfg.color, scale = cfg.scale;
13757 var segments = _segments(line, target, property);
13758 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
13759 try {
13760 for(var _iterator = segments[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
13761 var _value = _step.value, src = _value.source, tgt = _value.target, start = _value.start, end = _value.end;
13762 var tmp = src.style, ref = tmp === void 0 ? {} : tmp, _backgroundColor = ref.backgroundColor, backgroundColor = _backgroundColor === void 0 ? color : _backgroundColor;
13763 var notShape = target !== true;
13764 ctx.save();
13765 ctx.fillStyle = backgroundColor;
13766 clipBounds(ctx, scale, notShape && _getBounds(property, start, end));
13767 ctx.beginPath();
13768 var lineLoop = !!line.pathSegment(ctx, src);
13769 var loop = void 0;
13770 if (notShape) {
13771 if (lineLoop) ctx.closePath();
13772 else interpolatedLineTo(ctx, target, end, property);
13773 var targetLoop = !!target.pathSegment(ctx, tgt, {
13774 move: lineLoop,
13775 reverse: true
13776 });
13777 loop = lineLoop && targetLoop;
13778 if (!loop) interpolatedLineTo(ctx, target, start, property);
13779 }
13780 ctx.closePath();
13781 ctx.fill(loop ? "evenodd" : "nonzero");
13782 ctx.restore();
13783 }
13784 } catch (err) {
13785 _didIteratorError = true;
13786 _iteratorError = err;
13787 } finally{
13788 try {
13789 if (!_iteratorNormalCompletion && _iterator.return != null) {
13790 _iterator.return();
13791 }
13792 } finally{
13793 if (_didIteratorError) {
13794 throw _iteratorError;
13795 }
13796 }
13797 }
13798 }
13799 function clipBounds(ctx, scale, bounds) {
13800 var _chartArea = scale.chart.chartArea, top = _chartArea.top, bottom = _chartArea.bottom;
13801 var ref = bounds || {}, property = ref.property, start = ref.start, end = ref.end;
13802 if (property === "x") {
13803 ctx.beginPath();
13804 ctx.rect(start, top, end - start, bottom - top);
13805 ctx.clip();
13806 }
13807 }
13808 function interpolatedLineTo(ctx, target, point, property) {
13809 var interpolatedPoint = target.interpolate(point, property);
13810 if (interpolatedPoint) ctx.lineTo(interpolatedPoint.x, interpolatedPoint.y);
13811 }
13812 var index = {
13813 id: "filler",
13814 afterDatasetsUpdate: function(chart, _args, options) {
13815 var count = (chart.data.datasets || []).length;
13816 var sources = [];
13817 var meta, i, line, source;
13818 for(i = 0; i < count; ++i){
13819 meta = chart.getDatasetMeta(i);
13820 line = meta.dataset;
13821 source = null;
13822 if (line && line.options && line instanceof LineElement) source = {
13823 visible: chart.isDatasetVisible(i),
13824 index: i,
13825 fill: _decodeFill(line, i, count),
13826 chart: chart,
13827 axis: meta.controller.options.indexAxis,
13828 scale: meta.vScale,
13829 line: line
13830 };
13831 meta.$filler = source;
13832 sources.push(source);
13833 }
13834 for(i = 0; i < count; ++i){
13835 source = sources[i];
13836 if (!source || source.fill === false) continue;
13837 source.fill = _resolveTarget(sources, i, options.propagate);
13838 }
13839 },
13840 beforeDraw: function(chart, _args, options) {
13841 var draw3 = options.drawTime === "beforeDraw";
13842 var metasets = chart.getSortedVisibleDatasetMetas();
13843 var area = chart.chartArea;
13844 for(var i = metasets.length - 1; i >= 0; --i){
13845 var source = metasets[i].$filler;
13846 if (!source) continue;
13847 source.line.updateControlPoints(area, source.axis);
13848 if (draw3) _drawfill(chart.ctx, source, area);
13849 }
13850 },
13851 beforeDatasetsDraw: function(chart, _args, options) {
13852 if (options.drawTime !== "beforeDatasetsDraw") return;
13853 var metasets = chart.getSortedVisibleDatasetMetas();
13854 for(var i = metasets.length - 1; i >= 0; --i){
13855 var source = metasets[i].$filler;
13856 if (source) _drawfill(chart.ctx, source, chart.chartArea);
13857 }
13858 },
13859 beforeDatasetDraw: function(chart, args, options) {
13860 var source = args.meta.$filler;
13861 if (!source || source.fill === false || options.drawTime !== "beforeDatasetDraw") return;
13862 _drawfill(chart.ctx, source, chart.chartArea);
13863 },
13864 defaults: {
13865 propagate: true,
13866 drawTime: "beforeDatasetDraw"
13867 }
13868 };
13869 var getBoxSize = function(labelOpts, fontSize) {
13870 var _boxHeight = labelOpts.boxHeight, boxHeight = _boxHeight === void 0 ? fontSize : _boxHeight, _boxWidth = labelOpts.boxWidth, boxWidth = _boxWidth === void 0 ? fontSize : _boxWidth;
13871 if (labelOpts.usePointStyle) {
13872 boxHeight = Math.min(boxHeight, fontSize);
13873 boxWidth = Math.min(boxWidth, fontSize);
13874 }
13875 return {
13876 boxWidth: boxWidth,
13877 boxHeight: boxHeight,
13878 itemHeight: Math.max(fontSize, boxHeight)
13879 };
13880 };
13881 var itemsEqual = function(a, b) {
13882 return a !== null && b !== null && a.datasetIndex === b.datasetIndex && a.index === b.index;
13883 };
13884 var Legend = /*#__PURE__*/ function(Element) {
13885 "use strict";
13886 (0, _inheritsJsDefault.default)(Legend, Element);
13887 var _super = (0, _createSuperJsDefault.default)(Legend);
13888 function Legend(config) {
13889 (0, _classCallCheckJsDefault.default)(this, Legend);
13890 var _this;
13891 _this = _super.call(this);
13892 _this._added = false;
13893 _this.legendHitBoxes = [];
13894 _this._hoveredItem = null;
13895 _this.doughnutMode = false;
13896 _this.chart = config.chart;
13897 _this.options = config.options;
13898 _this.ctx = config.ctx;
13899 _this.legendItems = undefined;
13900 _this.columnSizes = undefined;
13901 _this.lineWidths = undefined;
13902 _this.maxHeight = undefined;
13903 _this.maxWidth = undefined;
13904 _this.top = undefined;
13905 _this.bottom = undefined;
13906 _this.left = undefined;
13907 _this.right = undefined;
13908 _this.height = undefined;
13909 _this.width = undefined;
13910 _this._margins = undefined;
13911 _this.position = undefined;
13912 _this.weight = undefined;
13913 _this.fullSize = undefined;
13914 return _this;
13915 }
13916 (0, _createClassJsDefault.default)(Legend, [
13917 {
13918 key: "update",
13919 value: function update(maxWidth, maxHeight, margins) {
13920 this.maxWidth = maxWidth;
13921 this.maxHeight = maxHeight;
13922 this._margins = margins;
13923 this.setDimensions();
13924 this.buildLabels();
13925 this.fit();
13926 }
13927 },
13928 {
13929 key: "setDimensions",
13930 value: function setDimensions() {
13931 if (this.isHorizontal()) {
13932 this.width = this.maxWidth;
13933 this.left = this._margins.left;
13934 this.right = this.width;
13935 } else {
13936 this.height = this.maxHeight;
13937 this.top = this._margins.top;
13938 this.bottom = this.height;
13939 }
13940 }
13941 },
13942 {
13943 key: "buildLabels",
13944 value: function buildLabels() {
13945 var _this = this;
13946 var labelOpts = this.options.labels || {};
13947 var legendItems = (0, _helpersSegmentJs.Q)(labelOpts.generateLabels, [
13948 this.chart
13949 ], this) || [];
13950 if (labelOpts.filter) legendItems = legendItems.filter(function(item) {
13951 return labelOpts.filter(item, _this.chart.data);
13952 });
13953 if (labelOpts.sort) legendItems = legendItems.sort(function(a, b) {
13954 return labelOpts.sort(a, b, _this.chart.data);
13955 });
13956 if (this.options.reverse) legendItems.reverse();
13957 this.legendItems = legendItems;
13958 }
13959 },
13960 {
13961 key: "fit",
13962 value: function fit() {
13963 var ref = this, options = ref.options, ctx = ref.ctx;
13964 if (!options.display) {
13965 this.width = this.height = 0;
13966 return;
13967 }
13968 var labelOpts = options.labels;
13969 var labelFont = (0, _helpersSegmentJs.$)(labelOpts.font);
13970 var fontSize = labelFont.size;
13971 var titleHeight = this._computeTitleHeight();
13972 var ref10 = getBoxSize(labelOpts, fontSize), boxWidth = ref10.boxWidth, itemHeight = ref10.itemHeight;
13973 var width, height;
13974 ctx.font = labelFont.string;
13975 if (this.isHorizontal()) {
13976 width = this.maxWidth;
13977 height = this._fitRows(titleHeight, fontSize, boxWidth, itemHeight) + 10;
13978 } else {
13979 height = this.maxHeight;
13980 width = this._fitCols(titleHeight, fontSize, boxWidth, itemHeight) + 10;
13981 }
13982 this.width = Math.min(width, options.maxWidth || this.maxWidth);
13983 this.height = Math.min(height, options.maxHeight || this.maxHeight);
13984 }
13985 },
13986 {
13987 key: "_fitRows",
13988 value: function _fitRows(titleHeight, fontSize, boxWidth, itemHeight) {
13989 var ref = this, ctx = ref.ctx, maxWidth = ref.maxWidth, _options = ref.options, padding = _options.labels.padding;
13990 var hitboxes = this.legendHitBoxes = [];
13991 var lineWidths = this.lineWidths = [
13992 0
13993 ];
13994 var lineHeight = itemHeight + padding;
13995 var totalHeight = titleHeight;
13996 ctx.textAlign = "left";
13997 ctx.textBaseline = "middle";
13998 var row = -1;
13999 var top = -lineHeight;
14000 this.legendItems.forEach(function(legendItem, i) {
14001 var itemWidth = boxWidth + fontSize / 2 + ctx.measureText(legendItem.text).width;
14002 if (i === 0 || lineWidths[lineWidths.length - 1] + itemWidth + 2 * padding > maxWidth) {
14003 totalHeight += lineHeight;
14004 lineWidths[lineWidths.length - (i > 0 ? 0 : 1)] = 0;
14005 top += lineHeight;
14006 row++;
14007 }
14008 hitboxes[i] = {
14009 left: 0,
14010 top: top,
14011 row: row,
14012 width: itemWidth,
14013 height: itemHeight
14014 };
14015 lineWidths[lineWidths.length - 1] += itemWidth + padding;
14016 });
14017 return totalHeight;
14018 }
14019 },
14020 {
14021 key: "_fitCols",
14022 value: function _fitCols(titleHeight, fontSize, boxWidth, itemHeight) {
14023 var ref = this, ctx = ref.ctx, maxHeight = ref.maxHeight, _options = ref.options, padding = _options.labels.padding;
14024 var hitboxes = this.legendHitBoxes = [];
14025 var columnSizes = this.columnSizes = [];
14026 var heightLimit = maxHeight - titleHeight;
14027 var totalWidth = padding;
14028 var currentColWidth = 0;
14029 var currentColHeight = 0;
14030 var left = 0;
14031 var col = 0;
14032 this.legendItems.forEach(function(legendItem, i) {
14033 var itemWidth = boxWidth + fontSize / 2 + ctx.measureText(legendItem.text).width;
14034 if (i > 0 && currentColHeight + itemHeight + 2 * padding > heightLimit) {
14035 totalWidth += currentColWidth + padding;
14036 columnSizes.push({
14037 width: currentColWidth,
14038 height: currentColHeight
14039 });
14040 left += currentColWidth + padding;
14041 col++;
14042 currentColWidth = currentColHeight = 0;
14043 }
14044 hitboxes[i] = {
14045 left: left,
14046 top: currentColHeight,
14047 col: col,
14048 width: itemWidth,
14049 height: itemHeight
14050 };
14051 currentColWidth = Math.max(currentColWidth, itemWidth);
14052 currentColHeight += itemHeight + padding;
14053 });
14054 totalWidth += currentColWidth;
14055 columnSizes.push({
14056 width: currentColWidth,
14057 height: currentColHeight
14058 });
14059 return totalWidth;
14060 }
14061 },
14062 {
14063 key: "adjustHitBoxes",
14064 value: function adjustHitBoxes() {
14065 if (!this.options.display) return;
14066 var titleHeight = this._computeTitleHeight();
14067 var ref = this, hitboxes = ref.legendHitBoxes, _options = ref.options, align = _options.align, padding = _options.labels.padding, rtl = _options.rtl;
14068 var rtlHelper = (0, _helpersSegmentJs.ay)(rtl, this.left, this.width);
14069 if (this.isHorizontal()) {
14070 var row = 0;
14071 var left = (0, _helpersSegmentJs.a1)(align, this.left + padding, this.right - this.lineWidths[row]);
14072 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
14073 try {
14074 for(var _iterator = hitboxes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
14075 var hitbox = _step.value;
14076 if (row !== hitbox.row) {
14077 row = hitbox.row;
14078 left = (0, _helpersSegmentJs.a1)(align, this.left + padding, this.right - this.lineWidths[row]);
14079 }
14080 hitbox.top += this.top + titleHeight + padding;
14081 hitbox.left = rtlHelper.leftForLtr(rtlHelper.x(left), hitbox.width);
14082 left += hitbox.width + padding;
14083 }
14084 } catch (err) {
14085 _didIteratorError = true;
14086 _iteratorError = err;
14087 } finally{
14088 try {
14089 if (!_iteratorNormalCompletion && _iterator.return != null) {
14090 _iterator.return();
14091 }
14092 } finally{
14093 if (_didIteratorError) {
14094 throw _iteratorError;
14095 }
14096 }
14097 }
14098 } else {
14099 var col = 0;
14100 var top = (0, _helpersSegmentJs.a1)(align, this.top + titleHeight + padding, this.bottom - this.columnSizes[col].height);
14101 var _iteratorNormalCompletion3 = true, _didIteratorError3 = false, _iteratorError3 = undefined;
14102 try {
14103 for(var _iterator3 = hitboxes[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true){
14104 var hitbox1 = _step3.value;
14105 if (hitbox1.col !== col) {
14106 col = hitbox1.col;
14107 top = (0, _helpersSegmentJs.a1)(align, this.top + titleHeight + padding, this.bottom - this.columnSizes[col].height);
14108 }
14109 hitbox1.top = top;
14110 hitbox1.left += this.left + padding;
14111 hitbox1.left = rtlHelper.leftForLtr(rtlHelper.x(hitbox1.left), hitbox1.width);
14112 top += hitbox1.height + padding;
14113 }
14114 } catch (err) {
14115 _didIteratorError3 = true;
14116 _iteratorError3 = err;
14117 } finally{
14118 try {
14119 if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
14120 _iterator3.return();
14121 }
14122 } finally{
14123 if (_didIteratorError3) {
14124 throw _iteratorError3;
14125 }
14126 }
14127 }
14128 }
14129 }
14130 },
14131 {
14132 key: "isHorizontal",
14133 value: function isHorizontal() {
14134 return this.options.position === "top" || this.options.position === "bottom";
14135 }
14136 },
14137 {
14138 key: "draw",
14139 value: function draw2() {
14140 if (this.options.display) {
14141 var ctx = this.ctx;
14142 (0, _helpersSegmentJs.X)(ctx, this);
14143 this._draw();
14144 (0, _helpersSegmentJs.Z)(ctx);
14145 }
14146 }
14147 },
14148 {
14149 key: "_draw",
14150 value: function _draw() {
14151 var _this = this;
14152 var ref = this, opts = ref.options, columnSizes = ref.columnSizes, lineWidths = ref.lineWidths, ctx = ref.ctx;
14153 var align = opts.align, labelOpts = opts.labels;
14154 var defaultColor = (0, _helpersSegmentJs.d).color;
14155 var rtlHelper = (0, _helpersSegmentJs.ay)(opts.rtl, this.left, this.width);
14156 var labelFont = (0, _helpersSegmentJs.$)(labelOpts.font);
14157 var fontColor = labelOpts.color, padding = labelOpts.padding;
14158 var fontSize = labelFont.size;
14159 var halfFontSize = fontSize / 2;
14160 var cursor;
14161 this.drawTitle();
14162 ctx.textAlign = rtlHelper.textAlign("left");
14163 ctx.textBaseline = "middle";
14164 ctx.lineWidth = 0.5;
14165 ctx.font = labelFont.string;
14166 var ref11 = getBoxSize(labelOpts, fontSize), boxWidth = ref11.boxWidth, boxHeight = ref11.boxHeight, itemHeight = ref11.itemHeight;
14167 var drawLegendBox = function drawLegendBox(x, y, legendItem) {
14168 if (isNaN(boxWidth) || boxWidth <= 0 || isNaN(boxHeight) || boxHeight < 0) return;
14169 ctx.save();
14170 var lineWidth = (0, _helpersSegmentJs.v)(legendItem.lineWidth, 1);
14171 ctx.fillStyle = (0, _helpersSegmentJs.v)(legendItem.fillStyle, defaultColor);
14172 ctx.lineCap = (0, _helpersSegmentJs.v)(legendItem.lineCap, "butt");
14173 ctx.lineDashOffset = (0, _helpersSegmentJs.v)(legendItem.lineDashOffset, 0);
14174 ctx.lineJoin = (0, _helpersSegmentJs.v)(legendItem.lineJoin, "miter");
14175 ctx.lineWidth = lineWidth;
14176 ctx.strokeStyle = (0, _helpersSegmentJs.v)(legendItem.strokeStyle, defaultColor);
14177 ctx.setLineDash((0, _helpersSegmentJs.v)(legendItem.lineDash, []));
14178 if (labelOpts.usePointStyle) {
14179 var drawOptions = {
14180 radius: boxWidth * Math.SQRT2 / 2,
14181 pointStyle: legendItem.pointStyle,
14182 rotation: legendItem.rotation,
14183 borderWidth: lineWidth
14184 };
14185 var centerX = rtlHelper.xPlus(x, boxWidth / 2);
14186 var centerY = y + halfFontSize;
14187 (0, _helpersSegmentJs.as)(ctx, drawOptions, centerX, centerY);
14188 } else {
14189 var yBoxTop = y + Math.max((fontSize - boxHeight) / 2, 0);
14190 var xBoxLeft = rtlHelper.leftForLtr(x, boxWidth);
14191 var borderRadius = (0, _helpersSegmentJs.av)(legendItem.borderRadius);
14192 ctx.beginPath();
14193 if (Object.values(borderRadius).some(function(v) {
14194 return v !== 0;
14195 })) (0, _helpersSegmentJs.at)(ctx, {
14196 x: xBoxLeft,
14197 y: yBoxTop,
14198 w: boxWidth,
14199 h: boxHeight,
14200 radius: borderRadius
14201 });
14202 else ctx.rect(xBoxLeft, yBoxTop, boxWidth, boxHeight);
14203 ctx.fill();
14204 if (lineWidth !== 0) ctx.stroke();
14205 }
14206 ctx.restore();
14207 };
14208 var fillText = function fillText(x, y, legendItem) {
14209 (0, _helpersSegmentJs.Y)(ctx, legendItem.text, x, y + itemHeight / 2, labelFont, {
14210 strikethrough: legendItem.hidden,
14211 textAlign: rtlHelper.textAlign(legendItem.textAlign)
14212 });
14213 };
14214 var isHorizontal = this.isHorizontal();
14215 var titleHeight = this._computeTitleHeight();
14216 if (isHorizontal) cursor = {
14217 x: (0, _helpersSegmentJs.a1)(align, this.left + padding, this.right - lineWidths[0]),
14218 y: this.top + padding + titleHeight,
14219 line: 0
14220 };
14221 else cursor = {
14222 x: this.left + padding,
14223 y: (0, _helpersSegmentJs.a1)(align, this.top + titleHeight + padding, this.bottom - columnSizes[0].height),
14224 line: 0
14225 };
14226 (0, _helpersSegmentJs.az)(this.ctx, opts.textDirection);
14227 var lineHeight = itemHeight + padding;
14228 this.legendItems.forEach(function(legendItem, i) {
14229 ctx.strokeStyle = legendItem.fontColor || fontColor;
14230 ctx.fillStyle = legendItem.fontColor || fontColor;
14231 var textWidth = ctx.measureText(legendItem.text).width;
14232 var textAlign = rtlHelper.textAlign(legendItem.textAlign || (legendItem.textAlign = labelOpts.textAlign));
14233 var width = boxWidth + halfFontSize + textWidth;
14234 var x = cursor.x;
14235 var y = cursor.y;
14236 rtlHelper.setWidth(_this.width);
14237 if (isHorizontal) {
14238 if (i > 0 && x + width + padding > _this.right) {
14239 y = cursor.y += lineHeight;
14240 cursor.line++;
14241 x = cursor.x = (0, _helpersSegmentJs.a1)(align, _this.left + padding, _this.right - lineWidths[cursor.line]);
14242 }
14243 } else if (i > 0 && y + lineHeight > _this.bottom) {
14244 x = cursor.x = x + columnSizes[cursor.line].width + padding;
14245 cursor.line++;
14246 y = cursor.y = (0, _helpersSegmentJs.a1)(align, _this.top + titleHeight + padding, _this.bottom - columnSizes[cursor.line].height);
14247 }
14248 var realX = rtlHelper.x(x);
14249 drawLegendBox(realX, y, legendItem);
14250 x = (0, _helpersSegmentJs.aA)(textAlign, x + boxWidth + halfFontSize, isHorizontal ? x + width : _this.right, opts.rtl);
14251 fillText(rtlHelper.x(x), y, legendItem);
14252 if (isHorizontal) cursor.x += width + padding;
14253 else cursor.y += lineHeight;
14254 });
14255 (0, _helpersSegmentJs.aB)(this.ctx, opts.textDirection);
14256 }
14257 },
14258 {
14259 key: "drawTitle",
14260 value: function drawTitle() {
14261 var opts = this.options;
14262 var titleOpts = opts.title;
14263 var titleFont = (0, _helpersSegmentJs.$)(titleOpts.font);
14264 var titlePadding = (0, _helpersSegmentJs.D)(titleOpts.padding);
14265 if (!titleOpts.display) return;
14266 var rtlHelper = (0, _helpersSegmentJs.ay)(opts.rtl, this.left, this.width);
14267 var ctx = this.ctx;
14268 var position = titleOpts.position;
14269 var halfFontSize = titleFont.size / 2;
14270 var topPaddingPlusHalfFontSize = titlePadding.top + halfFontSize;
14271 var y;
14272 var left = this.left;
14273 var maxWidth = this.width;
14274 if (this.isHorizontal()) {
14275 var _Math;
14276 maxWidth = (_Math = Math).max.apply(_Math, (0, _toConsumableArrayJsDefault.default)(this.lineWidths));
14277 y = this.top + topPaddingPlusHalfFontSize;
14278 left = (0, _helpersSegmentJs.a1)(opts.align, left, this.right - maxWidth);
14279 } else {
14280 var maxHeight = this.columnSizes.reduce(function(acc, size) {
14281 return Math.max(acc, size.height);
14282 }, 0);
14283 y = topPaddingPlusHalfFontSize + (0, _helpersSegmentJs.a1)(opts.align, this.top, this.bottom - maxHeight - opts.labels.padding - this._computeTitleHeight());
14284 }
14285 var x = (0, _helpersSegmentJs.a1)(position, left, left + maxWidth);
14286 ctx.textAlign = rtlHelper.textAlign((0, _helpersSegmentJs.a0)(position));
14287 ctx.textBaseline = "middle";
14288 ctx.strokeStyle = titleOpts.color;
14289 ctx.fillStyle = titleOpts.color;
14290 ctx.font = titleFont.string;
14291 (0, _helpersSegmentJs.Y)(ctx, titleOpts.text, x, y, titleFont);
14292 }
14293 },
14294 {
14295 key: "_computeTitleHeight",
14296 value: function _computeTitleHeight() {
14297 var titleOpts = this.options.title;
14298 var titleFont = (0, _helpersSegmentJs.$)(titleOpts.font);
14299 var titlePadding = (0, _helpersSegmentJs.D)(titleOpts.padding);
14300 return titleOpts.display ? titleFont.lineHeight + titlePadding.height : 0;
14301 }
14302 },
14303 {
14304 key: "_getLegendItemAt",
14305 value: function _getLegendItemAt(x, y) {
14306 var i, hitBox, lh;
14307 if ((0, _helpersSegmentJs.ai)(x, this.left, this.right) && (0, _helpersSegmentJs.ai)(y, this.top, this.bottom)) {
14308 lh = this.legendHitBoxes;
14309 for(i = 0; i < lh.length; ++i){
14310 hitBox = lh[i];
14311 if ((0, _helpersSegmentJs.ai)(x, hitBox.left, hitBox.left + hitBox.width) && (0, _helpersSegmentJs.ai)(y, hitBox.top, hitBox.top + hitBox.height)) return this.legendItems[i];
14312 }
14313 }
14314 return null;
14315 }
14316 },
14317 {
14318 key: "handleEvent",
14319 value: function handleEvent(e) {
14320 var opts = this.options;
14321 if (!isListened(e.type, opts)) return;
14322 var hoveredItem = this._getLegendItemAt(e.x, e.y);
14323 if (e.type === "mousemove" || e.type === "mouseout") {
14324 var previous = this._hoveredItem;
14325 var sameItem = itemsEqual(previous, hoveredItem);
14326 if (previous && !sameItem) (0, _helpersSegmentJs.Q)(opts.onLeave, [
14327 e,
14328 previous,
14329 this
14330 ], this);
14331 this._hoveredItem = hoveredItem;
14332 if (hoveredItem && !sameItem) (0, _helpersSegmentJs.Q)(opts.onHover, [
14333 e,
14334 hoveredItem,
14335 this
14336 ], this);
14337 } else if (hoveredItem) (0, _helpersSegmentJs.Q)(opts.onClick, [
14338 e,
14339 hoveredItem,
14340 this
14341 ], this);
14342 }
14343 }
14344 ]);
14345 return Legend;
14346 }((0, _wrapNativeSuperJsDefault.default)(Element));
14347 function isListened(type, opts) {
14348 if ((type === "mousemove" || type === "mouseout") && (opts.onHover || opts.onLeave)) return true;
14349 if (opts.onClick && (type === "click" || type === "mouseup")) return true;
14350 return false;
14351 }
14352 var plugin_legend = {
14353 id: "legend",
14354 _element: Legend,
14355 start: function(chart, _args, options) {
14356 var legend = chart.legend = new Legend({
14357 ctx: chart.ctx,
14358 options: options,
14359 chart: chart
14360 });
14361 layouts.configure(chart, legend, options);
14362 layouts.addBox(chart, legend);
14363 },
14364 stop: function(chart) {
14365 layouts.removeBox(chart, chart.legend);
14366 delete chart.legend;
14367 },
14368 beforeUpdate: function(chart, _args, options) {
14369 var legend = chart.legend;
14370 layouts.configure(chart, legend, options);
14371 legend.options = options;
14372 },
14373 afterUpdate: function(chart) {
14374 var legend = chart.legend;
14375 legend.buildLabels();
14376 legend.adjustHitBoxes();
14377 },
14378 afterEvent: function(chart, args) {
14379 if (!args.replay) chart.legend.handleEvent(args.event);
14380 },
14381 defaults: {
14382 display: true,
14383 position: "top",
14384 align: "center",
14385 fullSize: true,
14386 reverse: false,
14387 weight: 1000,
14388 onClick: function(e, legendItem, legend) {
14389 var index63 = legendItem.datasetIndex;
14390 var ci = legend.chart;
14391 if (ci.isDatasetVisible(index63)) {
14392 ci.hide(index63);
14393 legendItem.hidden = true;
14394 } else {
14395 ci.show(index63);
14396 legendItem.hidden = false;
14397 }
14398 },
14399 onHover: null,
14400 onLeave: null,
14401 labels: {
14402 color: function(ctx) {
14403 return ctx.chart.options.color;
14404 },
14405 boxWidth: 40,
14406 padding: 10,
14407 generateLabels: function(chart) {
14408 var datasets = chart.data.datasets;
14409 var _options = chart.legend.options, _labels = _options.labels, usePointStyle = _labels.usePointStyle, pointStyle = _labels.pointStyle, textAlign = _labels.textAlign, color = _labels.color;
14410 return chart._getSortedDatasetMetas().map(function(meta) {
14411 var style = meta.controller.getStyle(usePointStyle ? 0 : undefined);
14412 var borderWidth = (0, _helpersSegmentJs.D)(style.borderWidth);
14413 return {
14414 text: datasets[meta.index].label,
14415 fillStyle: style.backgroundColor,
14416 fontColor: color,
14417 hidden: !meta.visible,
14418 lineCap: style.borderCapStyle,
14419 lineDash: style.borderDash,
14420 lineDashOffset: style.borderDashOffset,
14421 lineJoin: style.borderJoinStyle,
14422 lineWidth: (borderWidth.width + borderWidth.height) / 4,
14423 strokeStyle: style.borderColor,
14424 pointStyle: pointStyle || style.pointStyle,
14425 rotation: style.rotation,
14426 textAlign: textAlign || style.textAlign,
14427 borderRadius: 0,
14428 datasetIndex: meta.index
14429 };
14430 }, this);
14431 }
14432 },
14433 title: {
14434 color: function(ctx) {
14435 return ctx.chart.options.color;
14436 },
14437 display: false,
14438 position: "center",
14439 text: ""
14440 }
14441 },
14442 descriptors: {
14443 _scriptable: function(name) {
14444 return !name.startsWith("on");
14445 },
14446 labels: {
14447 _scriptable: function(name) {
14448 return ![
14449 "generateLabels",
14450 "filter",
14451 "sort"
14452 ].includes(name);
14453 }
14454 }
14455 }
14456 };
14457 var Title = /*#__PURE__*/ function(Element) {
14458 "use strict";
14459 (0, _inheritsJsDefault.default)(Title, Element);
14460 var _super = (0, _createSuperJsDefault.default)(Title);
14461 function Title(config) {
14462 (0, _classCallCheckJsDefault.default)(this, Title);
14463 var _this;
14464 _this = _super.call(this);
14465 _this.chart = config.chart;
14466 _this.options = config.options;
14467 _this.ctx = config.ctx;
14468 _this._padding = undefined;
14469 _this.top = undefined;
14470 _this.bottom = undefined;
14471 _this.left = undefined;
14472 _this.right = undefined;
14473 _this.width = undefined;
14474 _this.height = undefined;
14475 _this.position = undefined;
14476 _this.weight = undefined;
14477 _this.fullSize = undefined;
14478 return _this;
14479 }
14480 (0, _createClassJsDefault.default)(Title, [
14481 {
14482 key: "update",
14483 value: function update(maxWidth, maxHeight) {
14484 var opts = this.options;
14485 this.left = 0;
14486 this.top = 0;
14487 if (!opts.display) {
14488 this.width = this.height = this.right = this.bottom = 0;
14489 return;
14490 }
14491 this.width = this.right = maxWidth;
14492 this.height = this.bottom = maxHeight;
14493 var lineCount = (0, _helpersSegmentJs.b)(opts.text) ? opts.text.length : 1;
14494 this._padding = (0, _helpersSegmentJs.D)(opts.padding);
14495 var textSize = lineCount * (0, _helpersSegmentJs.$)(opts.font).lineHeight + this._padding.height;
14496 if (this.isHorizontal()) this.height = textSize;
14497 else this.width = textSize;
14498 }
14499 },
14500 {
14501 key: "isHorizontal",
14502 value: function isHorizontal() {
14503 var pos = this.options.position;
14504 return pos === "top" || pos === "bottom";
14505 }
14506 },
14507 {
14508 key: "_drawArgs",
14509 value: function _drawArgs(offset) {
14510 var ref = this, top = ref.top, left = ref.left, bottom = ref.bottom, right = ref.right, options = ref.options;
14511 var align = options.align;
14512 var rotation = 0;
14513 var maxWidth, titleX, titleY;
14514 if (this.isHorizontal()) {
14515 titleX = (0, _helpersSegmentJs.a1)(align, left, right);
14516 titleY = top + offset;
14517 maxWidth = right - left;
14518 } else {
14519 if (options.position === "left") {
14520 titleX = left + offset;
14521 titleY = (0, _helpersSegmentJs.a1)(align, bottom, top);
14522 rotation = (0, _helpersSegmentJs.P) * -0.5;
14523 } else {
14524 titleX = right - offset;
14525 titleY = (0, _helpersSegmentJs.a1)(align, top, bottom);
14526 rotation = (0, _helpersSegmentJs.P) * 0.5;
14527 }
14528 maxWidth = bottom - top;
14529 }
14530 return {
14531 titleX: titleX,
14532 titleY: titleY,
14533 maxWidth: maxWidth,
14534 rotation: rotation
14535 };
14536 }
14537 },
14538 {
14539 key: "draw",
14540 value: function draw2() {
14541 var ctx = this.ctx;
14542 var opts = this.options;
14543 if (!opts.display) return;
14544 var fontOpts = (0, _helpersSegmentJs.$)(opts.font);
14545 var lineHeight = fontOpts.lineHeight;
14546 var offset = lineHeight / 2 + this._padding.top;
14547 var ref = this._drawArgs(offset), titleX = ref.titleX, titleY = ref.titleY, maxWidth = ref.maxWidth, rotation = ref.rotation;
14548 (0, _helpersSegmentJs.Y)(ctx, opts.text, 0, 0, fontOpts, {
14549 color: opts.color,
14550 maxWidth: maxWidth,
14551 rotation: rotation,
14552 textAlign: (0, _helpersSegmentJs.a0)(opts.align),
14553 textBaseline: "middle",
14554 translation: [
14555 titleX,
14556 titleY
14557 ]
14558 });
14559 }
14560 }
14561 ]);
14562 return Title;
14563 }((0, _wrapNativeSuperJsDefault.default)(Element));
14564 function createTitle(chart, titleOpts) {
14565 var title = new Title({
14566 ctx: chart.ctx,
14567 options: titleOpts,
14568 chart: chart
14569 });
14570 layouts.configure(chart, title, titleOpts);
14571 layouts.addBox(chart, title);
14572 chart.titleBlock = title;
14573 }
14574 var plugin_title = {
14575 id: "title",
14576 _element: Title,
14577 start: function(chart, _args, options) {
14578 createTitle(chart, options);
14579 },
14580 stop: function(chart) {
14581 var titleBlock = chart.titleBlock;
14582 layouts.removeBox(chart, titleBlock);
14583 delete chart.titleBlock;
14584 },
14585 beforeUpdate: function(chart, _args, options) {
14586 var title = chart.titleBlock;
14587 layouts.configure(chart, title, options);
14588 title.options = options;
14589 },
14590 defaults: {
14591 align: "center",
14592 display: false,
14593 font: {
14594 weight: "bold"
14595 },
14596 fullSize: true,
14597 padding: 10,
14598 position: "top",
14599 text: "",
14600 weight: 2000
14601 },
14602 defaultRoutes: {
14603 color: "color"
14604 },
14605 descriptors: {
14606 _scriptable: true,
14607 _indexable: false
14608 }
14609 };
14610 var map = new WeakMap();
14611 var plugin_subtitle = {
14612 id: "subtitle",
14613 start: function(chart, _args, options) {
14614 var title = new Title({
14615 ctx: chart.ctx,
14616 options: options,
14617 chart: chart
14618 });
14619 layouts.configure(chart, title, options);
14620 layouts.addBox(chart, title);
14621 map.set(chart, title);
14622 },
14623 stop: function(chart) {
14624 layouts.removeBox(chart, map.get(chart));
14625 map.delete(chart);
14626 },
14627 beforeUpdate: function(chart, _args, options) {
14628 var title = map.get(chart);
14629 layouts.configure(chart, title, options);
14630 title.options = options;
14631 },
14632 defaults: {
14633 align: "center",
14634 display: false,
14635 font: {
14636 weight: "normal"
14637 },
14638 fullSize: true,
14639 padding: 0,
14640 position: "top",
14641 text: "",
14642 weight: 1500
14643 },
14644 defaultRoutes: {
14645 color: "color"
14646 },
14647 descriptors: {
14648 _scriptable: true,
14649 _indexable: false
14650 }
14651 };
14652 var positioners = {
14653 average: function(items) {
14654 if (!items.length) return false;
14655 var i, len;
14656 var x = 0;
14657 var y = 0;
14658 var count = 0;
14659 for(i = 0, len = items.length; i < len; ++i){
14660 var el = items[i].element;
14661 if (el && el.hasValue()) {
14662 var pos = el.tooltipPosition();
14663 x += pos.x;
14664 y += pos.y;
14665 ++count;
14666 }
14667 }
14668 return {
14669 x: x / count,
14670 y: y / count
14671 };
14672 },
14673 nearest: function(items, eventPosition) {
14674 if (!items.length) return false;
14675 var x = eventPosition.x;
14676 var y = eventPosition.y;
14677 var minDistance = Number.POSITIVE_INFINITY;
14678 var i, len, nearestElement;
14679 for(i = 0, len = items.length; i < len; ++i){
14680 var el = items[i].element;
14681 if (el && el.hasValue()) {
14682 var center = el.getCenterPoint();
14683 var d = (0, _helpersSegmentJs.aD)(eventPosition, center);
14684 if (d < minDistance) {
14685 minDistance = d;
14686 nearestElement = el;
14687 }
14688 }
14689 }
14690 if (nearestElement) {
14691 var tp = nearestElement.tooltipPosition();
14692 x = tp.x;
14693 y = tp.y;
14694 }
14695 return {
14696 x: x,
14697 y: y
14698 };
14699 }
14700 };
14701 function pushOrConcat(base, toPush) {
14702 if (toPush) {
14703 if ((0, _helpersSegmentJs.b)(toPush)) Array.prototype.push.apply(base, toPush);
14704 else base.push(toPush);
14705 }
14706 return base;
14707 }
14708 function splitNewlines(str) {
14709 if ((typeof str === "string" || str instanceof String) && str.indexOf("\n") > -1) return str.split("\n");
14710 return str;
14711 }
14712 function createTooltipItem(chart, item) {
14713 var element = item.element, datasetIndex = item.datasetIndex, index64 = item.index;
14714 var controller = chart.getDatasetMeta(datasetIndex).controller;
14715 var ref = controller.getLabelAndValue(index64), label = ref.label, value = ref.value;
14716 return {
14717 chart: chart,
14718 label: label,
14719 parsed: controller.getParsed(index64),
14720 raw: chart.data.datasets[datasetIndex].data[index64],
14721 formattedValue: value,
14722 dataset: controller.getDataset(),
14723 dataIndex: index64,
14724 datasetIndex: datasetIndex,
14725 element: element
14726 };
14727 }
14728 function getTooltipSize(tooltip, options) {
14729 var ctx = tooltip.chart.ctx;
14730 var body = tooltip.body, footer = tooltip.footer, title = tooltip.title;
14731 var boxWidth = options.boxWidth, boxHeight = options.boxHeight;
14732 var bodyFont = (0, _helpersSegmentJs.$)(options.bodyFont);
14733 var titleFont = (0, _helpersSegmentJs.$)(options.titleFont);
14734 var footerFont = (0, _helpersSegmentJs.$)(options.footerFont);
14735 var titleLineCount = title.length;
14736 var footerLineCount = footer.length;
14737 var bodyLineItemCount = body.length;
14738 var padding = (0, _helpersSegmentJs.D)(options.padding);
14739 var height = padding.height;
14740 var width = 0;
14741 var combinedBodyLength = body.reduce(function(count, bodyItem) {
14742 return count + bodyItem.before.length + bodyItem.lines.length + bodyItem.after.length;
14743 }, 0);
14744 combinedBodyLength += tooltip.beforeBody.length + tooltip.afterBody.length;
14745 if (titleLineCount) height += titleLineCount * titleFont.lineHeight + (titleLineCount - 1) * options.titleSpacing + options.titleMarginBottom;
14746 if (combinedBodyLength) {
14747 var bodyLineHeight = options.displayColors ? Math.max(boxHeight, bodyFont.lineHeight) : bodyFont.lineHeight;
14748 height += bodyLineItemCount * bodyLineHeight + (combinedBodyLength - bodyLineItemCount) * bodyFont.lineHeight + (combinedBodyLength - 1) * options.bodySpacing;
14749 }
14750 if (footerLineCount) height += options.footerMarginTop + footerLineCount * footerFont.lineHeight + (footerLineCount - 1) * options.footerSpacing;
14751 var widthPadding = 0;
14752 var maxLineWidth = function maxLineWidth(line) {
14753 width = Math.max(width, ctx.measureText(line).width + widthPadding);
14754 };
14755 ctx.save();
14756 ctx.font = titleFont.string;
14757 (0, _helpersSegmentJs.E)(tooltip.title, maxLineWidth);
14758 ctx.font = bodyFont.string;
14759 (0, _helpersSegmentJs.E)(tooltip.beforeBody.concat(tooltip.afterBody), maxLineWidth);
14760 widthPadding = options.displayColors ? boxWidth + 2 + options.boxPadding : 0;
14761 (0, _helpersSegmentJs.E)(body, function(bodyItem) {
14762 (0, _helpersSegmentJs.E)(bodyItem.before, maxLineWidth);
14763 (0, _helpersSegmentJs.E)(bodyItem.lines, maxLineWidth);
14764 (0, _helpersSegmentJs.E)(bodyItem.after, maxLineWidth);
14765 });
14766 widthPadding = 0;
14767 ctx.font = footerFont.string;
14768 (0, _helpersSegmentJs.E)(tooltip.footer, maxLineWidth);
14769 ctx.restore();
14770 width += padding.width;
14771 return {
14772 width: width,
14773 height: height
14774 };
14775 }
14776 function determineYAlign(chart, size) {
14777 var y = size.y, height = size.height;
14778 if (y < height / 2) return "top";
14779 else if (y > chart.height - height / 2) return "bottom";
14780 return "center";
14781 }
14782 function doesNotFitWithAlign(xAlign, chart, options, size) {
14783 var x = size.x, width = size.width;
14784 var caret = options.caretSize + options.caretPadding;
14785 if (xAlign === "left" && x + width + caret > chart.width) return true;
14786 if (xAlign === "right" && x - width - caret < 0) return true;
14787 }
14788 function determineXAlign(chart, options, size, yAlign) {
14789 var x = size.x, width = size.width;
14790 var chartWidth = chart.width, _chartArea = chart.chartArea, left = _chartArea.left, right = _chartArea.right;
14791 var xAlign = "center";
14792 if (yAlign === "center") xAlign = x <= (left + right) / 2 ? "left" : "right";
14793 else if (x <= width / 2) xAlign = "left";
14794 else if (x >= chartWidth - width / 2) xAlign = "right";
14795 if (doesNotFitWithAlign(xAlign, chart, options, size)) xAlign = "center";
14796 return xAlign;
14797 }
14798 function determineAlignment(chart, options, size) {
14799 var yAlign = size.yAlign || options.yAlign || determineYAlign(chart, size);
14800 return {
14801 xAlign: size.xAlign || options.xAlign || determineXAlign(chart, options, size, yAlign),
14802 yAlign: yAlign
14803 };
14804 }
14805 function alignX(size, xAlign) {
14806 var x = size.x, width = size.width;
14807 if (xAlign === "right") x -= width;
14808 else if (xAlign === "center") x -= width / 2;
14809 return x;
14810 }
14811 function alignY(size, yAlign, paddingAndSize) {
14812 var y = size.y, height = size.height;
14813 if (yAlign === "top") y += paddingAndSize;
14814 else if (yAlign === "bottom") y -= height + paddingAndSize;
14815 else y -= height / 2;
14816 return y;
14817 }
14818 function getBackgroundPoint(options, size, alignment, chart) {
14819 var caretSize = options.caretSize, caretPadding = options.caretPadding, cornerRadius = options.cornerRadius;
14820 var xAlign = alignment.xAlign, yAlign = alignment.yAlign;
14821 var paddingAndSize = caretSize + caretPadding;
14822 var ref = (0, _helpersSegmentJs.av)(cornerRadius), topLeft = ref.topLeft, topRight = ref.topRight, bottomLeft = ref.bottomLeft, bottomRight = ref.bottomRight;
14823 var x = alignX(size, xAlign);
14824 var y = alignY(size, yAlign, paddingAndSize);
14825 if (yAlign === "center") {
14826 if (xAlign === "left") x += paddingAndSize;
14827 else if (xAlign === "right") x -= paddingAndSize;
14828 } else if (xAlign === "left") x -= Math.max(topLeft, bottomLeft) + caretSize;
14829 else if (xAlign === "right") x += Math.max(topRight, bottomRight) + caretSize;
14830 return {
14831 x: (0, _helpersSegmentJs.w)(x, 0, chart.width - size.width),
14832 y: (0, _helpersSegmentJs.w)(y, 0, chart.height - size.height)
14833 };
14834 }
14835 function getAlignedX(tooltip, align, options) {
14836 var padding = (0, _helpersSegmentJs.D)(options.padding);
14837 return align === "center" ? tooltip.x + tooltip.width / 2 : align === "right" ? tooltip.x + tooltip.width - padding.right : tooltip.x + padding.left;
14838 }
14839 function getBeforeAfterBodyLines(callback) {
14840 return pushOrConcat([], splitNewlines(callback));
14841 }
14842 function createTooltipContext(parent, tooltip, tooltipItems) {
14843 return (0, _helpersSegmentJs.h)(parent, {
14844 tooltip: tooltip,
14845 tooltipItems: tooltipItems,
14846 type: "tooltip"
14847 });
14848 }
14849 function overrideCallbacks(callbacks, context) {
14850 var override = context && context.dataset && context.dataset.tooltip && context.dataset.tooltip.callbacks;
14851 return override ? callbacks.override(override) : callbacks;
14852 }
14853 var Tooltip = /*#__PURE__*/ function(Element) {
14854 "use strict";
14855 (0, _inheritsJsDefault.default)(Tooltip, Element);
14856 var _super = (0, _createSuperJsDefault.default)(Tooltip);
14857 function Tooltip(config) {
14858 (0, _classCallCheckJsDefault.default)(this, Tooltip);
14859 var _this;
14860 _this = _super.call(this);
14861 _this.opacity = 0;
14862 _this._active = [];
14863 _this._eventPosition = undefined;
14864 _this._size = undefined;
14865 _this._cachedAnimations = undefined;
14866 _this._tooltipItems = [];
14867 _this.$animations = undefined;
14868 _this.$context = undefined;
14869 _this.chart = config.chart || config._chart;
14870 _this._chart = _this.chart;
14871 _this.options = config.options;
14872 _this.dataPoints = undefined;
14873 _this.title = undefined;
14874 _this.beforeBody = undefined;
14875 _this.body = undefined;
14876 _this.afterBody = undefined;
14877 _this.footer = undefined;
14878 _this.xAlign = undefined;
14879 _this.yAlign = undefined;
14880 _this.x = undefined;
14881 _this.y = undefined;
14882 _this.height = undefined;
14883 _this.width = undefined;
14884 _this.caretX = undefined;
14885 _this.caretY = undefined;
14886 _this.labelColors = undefined;
14887 _this.labelPointStyles = undefined;
14888 _this.labelTextColors = undefined;
14889 return _this;
14890 }
14891 (0, _createClassJsDefault.default)(Tooltip, [
14892 {
14893 key: "initialize",
14894 value: function initialize(options) {
14895 this.options = options;
14896 this._cachedAnimations = undefined;
14897 this.$context = undefined;
14898 }
14899 },
14900 {
14901 key: "_resolveAnimations",
14902 value: function _resolveAnimations() {
14903 var cached = this._cachedAnimations;
14904 if (cached) return cached;
14905 var chart = this.chart;
14906 var options = this.options.setContext(this.getContext());
14907 var opts = options.enabled && chart.options.animation && options.animations;
14908 var animations = new Animations(this.chart, opts);
14909 if (opts._cacheable) this._cachedAnimations = Object.freeze(animations);
14910 return animations;
14911 }
14912 },
14913 {
14914 key: "getContext",
14915 value: function getContext() {
14916 return this.$context || (this.$context = createTooltipContext(this.chart.getContext(), this, this._tooltipItems));
14917 }
14918 },
14919 {
14920 key: "getTitle",
14921 value: function getTitle(context, options) {
14922 var callbacks = options.callbacks;
14923 var beforeTitle = callbacks.beforeTitle.apply(this, [
14924 context
14925 ]);
14926 var title = callbacks.title.apply(this, [
14927 context
14928 ]);
14929 var afterTitle = callbacks.afterTitle.apply(this, [
14930 context
14931 ]);
14932 var lines = [];
14933 lines = pushOrConcat(lines, splitNewlines(beforeTitle));
14934 lines = pushOrConcat(lines, splitNewlines(title));
14935 lines = pushOrConcat(lines, splitNewlines(afterTitle));
14936 return lines;
14937 }
14938 },
14939 {
14940 key: "getBeforeBody",
14941 value: function getBeforeBody(tooltipItems, options) {
14942 return getBeforeAfterBodyLines(options.callbacks.beforeBody.apply(this, [
14943 tooltipItems
14944 ]));
14945 }
14946 },
14947 {
14948 key: "getBody",
14949 value: function getBody(tooltipItems, options) {
14950 var _this = this;
14951 var callbacks = options.callbacks;
14952 var bodyItems = [];
14953 (0, _helpersSegmentJs.E)(tooltipItems, function(context) {
14954 var bodyItem = {
14955 before: [],
14956 lines: [],
14957 after: []
14958 };
14959 var scoped = overrideCallbacks(callbacks, context);
14960 pushOrConcat(bodyItem.before, splitNewlines(scoped.beforeLabel.call(_this, context)));
14961 pushOrConcat(bodyItem.lines, scoped.label.call(_this, context));
14962 pushOrConcat(bodyItem.after, splitNewlines(scoped.afterLabel.call(_this, context)));
14963 bodyItems.push(bodyItem);
14964 });
14965 return bodyItems;
14966 }
14967 },
14968 {
14969 key: "getAfterBody",
14970 value: function getAfterBody(tooltipItems, options) {
14971 return getBeforeAfterBodyLines(options.callbacks.afterBody.apply(this, [
14972 tooltipItems
14973 ]));
14974 }
14975 },
14976 {
14977 key: "getFooter",
14978 value: function getFooter(tooltipItems, options) {
14979 var callbacks = options.callbacks;
14980 var beforeFooter = callbacks.beforeFooter.apply(this, [
14981 tooltipItems
14982 ]);
14983 var footer = callbacks.footer.apply(this, [
14984 tooltipItems
14985 ]);
14986 var afterFooter = callbacks.afterFooter.apply(this, [
14987 tooltipItems
14988 ]);
14989 var lines = [];
14990 lines = pushOrConcat(lines, splitNewlines(beforeFooter));
14991 lines = pushOrConcat(lines, splitNewlines(footer));
14992 lines = pushOrConcat(lines, splitNewlines(afterFooter));
14993 return lines;
14994 }
14995 },
14996 {
14997 key: "_createItems",
14998 value: function _createItems(options) {
14999 var _this = this;
15000 var active = this._active;
15001 var data = this.chart.data;
15002 var labelColors = [];
15003 var labelPointStyles = [];
15004 var labelTextColors = [];
15005 var tooltipItems = [];
15006 var i, len;
15007 for(i = 0, len = active.length; i < len; ++i)tooltipItems.push(createTooltipItem(this.chart, active[i]));
15008 if (options.filter) tooltipItems = tooltipItems.filter(function(element, index65, array) {
15009 return options.filter(element, index65, array, data);
15010 });
15011 if (options.itemSort) tooltipItems = tooltipItems.sort(function(a, b) {
15012 return options.itemSort(a, b, data);
15013 });
15014 (0, _helpersSegmentJs.E)(tooltipItems, function(context) {
15015 var scoped = overrideCallbacks(options.callbacks, context);
15016 labelColors.push(scoped.labelColor.call(_this, context));
15017 labelPointStyles.push(scoped.labelPointStyle.call(_this, context));
15018 labelTextColors.push(scoped.labelTextColor.call(_this, context));
15019 });
15020 this.labelColors = labelColors;
15021 this.labelPointStyles = labelPointStyles;
15022 this.labelTextColors = labelTextColors;
15023 this.dataPoints = tooltipItems;
15024 return tooltipItems;
15025 }
15026 },
15027 {
15028 key: "update",
15029 value: function update(changed, replay) {
15030 var options = this.options.setContext(this.getContext());
15031 var active = this._active;
15032 var properties;
15033 var tooltipItems = [];
15034 if (!active.length) {
15035 if (this.opacity !== 0) properties = {
15036 opacity: 0
15037 };
15038 } else {
15039 var position = positioners[options.position].call(this, active, this._eventPosition);
15040 tooltipItems = this._createItems(options);
15041 this.title = this.getTitle(tooltipItems, options);
15042 this.beforeBody = this.getBeforeBody(tooltipItems, options);
15043 this.body = this.getBody(tooltipItems, options);
15044 this.afterBody = this.getAfterBody(tooltipItems, options);
15045 this.footer = this.getFooter(tooltipItems, options);
15046 var size = this._size = getTooltipSize(this, options);
15047 var positionAndSize = Object.assign({}, position, size);
15048 var alignment = determineAlignment(this.chart, options, positionAndSize);
15049 var backgroundPoint = getBackgroundPoint(options, positionAndSize, alignment, this.chart);
15050 this.xAlign = alignment.xAlign;
15051 this.yAlign = alignment.yAlign;
15052 properties = {
15053 opacity: 1,
15054 x: backgroundPoint.x,
15055 y: backgroundPoint.y,
15056 width: size.width,
15057 height: size.height,
15058 caretX: position.x,
15059 caretY: position.y
15060 };
15061 }
15062 this._tooltipItems = tooltipItems;
15063 this.$context = undefined;
15064 if (properties) this._resolveAnimations().update(this, properties);
15065 if (changed && options.external) options.external.call(this, {
15066 chart: this.chart,
15067 tooltip: this,
15068 replay: replay
15069 });
15070 }
15071 },
15072 {
15073 key: "drawCaret",
15074 value: function drawCaret(tooltipPoint, ctx, size, options) {
15075 var caretPosition = this.getCaretPosition(tooltipPoint, size, options);
15076 ctx.lineTo(caretPosition.x1, caretPosition.y1);
15077 ctx.lineTo(caretPosition.x2, caretPosition.y2);
15078 ctx.lineTo(caretPosition.x3, caretPosition.y3);
15079 }
15080 },
15081 {
15082 key: "getCaretPosition",
15083 value: function getCaretPosition(tooltipPoint, size, options) {
15084 var ref = this, xAlign = ref.xAlign, yAlign = ref.yAlign;
15085 var caretSize = options.caretSize, cornerRadius = options.cornerRadius;
15086 var ref12 = (0, _helpersSegmentJs.av)(cornerRadius), topLeft = ref12.topLeft, topRight = ref12.topRight, bottomLeft = ref12.bottomLeft, bottomRight = ref12.bottomRight;
15087 var ptX = tooltipPoint.x, ptY = tooltipPoint.y;
15088 var width = size.width, height = size.height;
15089 var x1, x2, x3, y1, y2, y3;
15090 if (yAlign === "center") {
15091 y2 = ptY + height / 2;
15092 if (xAlign === "left") {
15093 x1 = ptX;
15094 x2 = x1 - caretSize;
15095 y1 = y2 + caretSize;
15096 y3 = y2 - caretSize;
15097 } else {
15098 x1 = ptX + width;
15099 x2 = x1 + caretSize;
15100 y1 = y2 - caretSize;
15101 y3 = y2 + caretSize;
15102 }
15103 x3 = x1;
15104 } else {
15105 if (xAlign === "left") x2 = ptX + Math.max(topLeft, bottomLeft) + caretSize;
15106 else if (xAlign === "right") x2 = ptX + width - Math.max(topRight, bottomRight) - caretSize;
15107 else x2 = this.caretX;
15108 if (yAlign === "top") {
15109 y1 = ptY;
15110 y2 = y1 - caretSize;
15111 x1 = x2 - caretSize;
15112 x3 = x2 + caretSize;
15113 } else {
15114 y1 = ptY + height;
15115 y2 = y1 + caretSize;
15116 x1 = x2 + caretSize;
15117 x3 = x2 - caretSize;
15118 }
15119 y3 = y1;
15120 }
15121 return {
15122 x1: x1,
15123 x2: x2,
15124 x3: x3,
15125 y1: y1,
15126 y2: y2,
15127 y3: y3
15128 };
15129 }
15130 },
15131 {
15132 key: "drawTitle",
15133 value: function drawTitle(pt, ctx, options) {
15134 var title = this.title;
15135 var length = title.length;
15136 var titleFont, titleSpacing, i;
15137 if (length) {
15138 var rtlHelper = (0, _helpersSegmentJs.ay)(options.rtl, this.x, this.width);
15139 pt.x = getAlignedX(this, options.titleAlign, options);
15140 ctx.textAlign = rtlHelper.textAlign(options.titleAlign);
15141 ctx.textBaseline = "middle";
15142 titleFont = (0, _helpersSegmentJs.$)(options.titleFont);
15143 titleSpacing = options.titleSpacing;
15144 ctx.fillStyle = options.titleColor;
15145 ctx.font = titleFont.string;
15146 for(i = 0; i < length; ++i){
15147 ctx.fillText(title[i], rtlHelper.x(pt.x), pt.y + titleFont.lineHeight / 2);
15148 pt.y += titleFont.lineHeight + titleSpacing;
15149 if (i + 1 === length) pt.y += options.titleMarginBottom - titleSpacing;
15150 }
15151 }
15152 }
15153 },
15154 {
15155 key: "_drawColorBox",
15156 value: function _drawColorBox(ctx, pt, i, rtlHelper, options) {
15157 var labelColors = this.labelColors[i];
15158 var labelPointStyle = this.labelPointStyles[i];
15159 var boxHeight = options.boxHeight, boxWidth = options.boxWidth, boxPadding = options.boxPadding;
15160 var bodyFont = (0, _helpersSegmentJs.$)(options.bodyFont);
15161 var colorX = getAlignedX(this, "left", options);
15162 var rtlColorX = rtlHelper.x(colorX);
15163 var yOffSet = boxHeight < bodyFont.lineHeight ? (bodyFont.lineHeight - boxHeight) / 2 : 0;
15164 var colorY = pt.y + yOffSet;
15165 if (options.usePointStyle) {
15166 var drawOptions = {
15167 radius: Math.min(boxWidth, boxHeight) / 2,
15168 pointStyle: labelPointStyle.pointStyle,
15169 rotation: labelPointStyle.rotation,
15170 borderWidth: 1
15171 };
15172 var centerX = rtlHelper.leftForLtr(rtlColorX, boxWidth) + boxWidth / 2;
15173 var centerY = colorY + boxHeight / 2;
15174 ctx.strokeStyle = options.multiKeyBackground;
15175 ctx.fillStyle = options.multiKeyBackground;
15176 (0, _helpersSegmentJs.as)(ctx, drawOptions, centerX, centerY);
15177 ctx.strokeStyle = labelColors.borderColor;
15178 ctx.fillStyle = labelColors.backgroundColor;
15179 (0, _helpersSegmentJs.as)(ctx, drawOptions, centerX, centerY);
15180 } else {
15181 ctx.lineWidth = labelColors.borderWidth || 1;
15182 ctx.strokeStyle = labelColors.borderColor;
15183 ctx.setLineDash(labelColors.borderDash || []);
15184 ctx.lineDashOffset = labelColors.borderDashOffset || 0;
15185 var outerX = rtlHelper.leftForLtr(rtlColorX, boxWidth - boxPadding);
15186 var innerX = rtlHelper.leftForLtr(rtlHelper.xPlus(rtlColorX, 1), boxWidth - boxPadding - 2);
15187 var borderRadius = (0, _helpersSegmentJs.av)(labelColors.borderRadius);
15188 if (Object.values(borderRadius).some(function(v) {
15189 return v !== 0;
15190 })) {
15191 ctx.beginPath();
15192 ctx.fillStyle = options.multiKeyBackground;
15193 (0, _helpersSegmentJs.at)(ctx, {
15194 x: outerX,
15195 y: colorY,
15196 w: boxWidth,
15197 h: boxHeight,
15198 radius: borderRadius
15199 });
15200 ctx.fill();
15201 ctx.stroke();
15202 ctx.fillStyle = labelColors.backgroundColor;
15203 ctx.beginPath();
15204 (0, _helpersSegmentJs.at)(ctx, {
15205 x: innerX,
15206 y: colorY + 1,
15207 w: boxWidth - 2,
15208 h: boxHeight - 2,
15209 radius: borderRadius
15210 });
15211 ctx.fill();
15212 } else {
15213 ctx.fillStyle = options.multiKeyBackground;
15214 ctx.fillRect(outerX, colorY, boxWidth, boxHeight);
15215 ctx.strokeRect(outerX, colorY, boxWidth, boxHeight);
15216 ctx.fillStyle = labelColors.backgroundColor;
15217 ctx.fillRect(innerX, colorY + 1, boxWidth - 2, boxHeight - 2);
15218 }
15219 }
15220 ctx.fillStyle = this.labelTextColors[i];
15221 }
15222 },
15223 {
15224 key: "drawBody",
15225 value: function drawBody(pt, ctx, options) {
15226 var body = this.body;
15227 var bodySpacing = options.bodySpacing, bodyAlign = options.bodyAlign, displayColors = options.displayColors, boxHeight = options.boxHeight, boxWidth = options.boxWidth, boxPadding = options.boxPadding;
15228 var bodyFont = (0, _helpersSegmentJs.$)(options.bodyFont);
15229 var bodyLineHeight = bodyFont.lineHeight;
15230 var xLinePadding = 0;
15231 var rtlHelper = (0, _helpersSegmentJs.ay)(options.rtl, this.x, this.width);
15232 var fillLineOfText = function fillLineOfText(line) {
15233 ctx.fillText(line, rtlHelper.x(pt.x + xLinePadding), pt.y + bodyLineHeight / 2);
15234 pt.y += bodyLineHeight + bodySpacing;
15235 };
15236 var bodyAlignForCalculation = rtlHelper.textAlign(bodyAlign);
15237 var bodyItem, textColor, lines, i, j, ilen, jlen;
15238 ctx.textAlign = bodyAlign;
15239 ctx.textBaseline = "middle";
15240 ctx.font = bodyFont.string;
15241 pt.x = getAlignedX(this, bodyAlignForCalculation, options);
15242 ctx.fillStyle = options.bodyColor;
15243 (0, _helpersSegmentJs.E)(this.beforeBody, fillLineOfText);
15244 xLinePadding = displayColors && bodyAlignForCalculation !== "right" ? bodyAlign === "center" ? boxWidth / 2 + boxPadding : boxWidth + 2 + boxPadding : 0;
15245 for(i = 0, ilen = body.length; i < ilen; ++i){
15246 bodyItem = body[i];
15247 textColor = this.labelTextColors[i];
15248 ctx.fillStyle = textColor;
15249 (0, _helpersSegmentJs.E)(bodyItem.before, fillLineOfText);
15250 lines = bodyItem.lines;
15251 if (displayColors && lines.length) {
15252 this._drawColorBox(ctx, pt, i, rtlHelper, options);
15253 bodyLineHeight = Math.max(bodyFont.lineHeight, boxHeight);
15254 }
15255 for(j = 0, jlen = lines.length; j < jlen; ++j){
15256 fillLineOfText(lines[j]);
15257 bodyLineHeight = bodyFont.lineHeight;
15258 }
15259 (0, _helpersSegmentJs.E)(bodyItem.after, fillLineOfText);
15260 }
15261 xLinePadding = 0;
15262 bodyLineHeight = bodyFont.lineHeight;
15263 (0, _helpersSegmentJs.E)(this.afterBody, fillLineOfText);
15264 pt.y -= bodySpacing;
15265 }
15266 },
15267 {
15268 key: "drawFooter",
15269 value: function drawFooter(pt, ctx, options) {
15270 var footer = this.footer;
15271 var length = footer.length;
15272 var footerFont, i;
15273 if (length) {
15274 var rtlHelper = (0, _helpersSegmentJs.ay)(options.rtl, this.x, this.width);
15275 pt.x = getAlignedX(this, options.footerAlign, options);
15276 pt.y += options.footerMarginTop;
15277 ctx.textAlign = rtlHelper.textAlign(options.footerAlign);
15278 ctx.textBaseline = "middle";
15279 footerFont = (0, _helpersSegmentJs.$)(options.footerFont);
15280 ctx.fillStyle = options.footerColor;
15281 ctx.font = footerFont.string;
15282 for(i = 0; i < length; ++i){
15283 ctx.fillText(footer[i], rtlHelper.x(pt.x), pt.y + footerFont.lineHeight / 2);
15284 pt.y += footerFont.lineHeight + options.footerSpacing;
15285 }
15286 }
15287 }
15288 },
15289 {
15290 key: "drawBackground",
15291 value: function drawBackground(pt, ctx, tooltipSize, options) {
15292 var ref = this, xAlign = ref.xAlign, yAlign = ref.yAlign;
15293 var x = pt.x, y = pt.y;
15294 var width = tooltipSize.width, height = tooltipSize.height;
15295 var ref13 = (0, _helpersSegmentJs.av)(options.cornerRadius), topLeft = ref13.topLeft, topRight = ref13.topRight, bottomLeft = ref13.bottomLeft, bottomRight = ref13.bottomRight;
15296 ctx.fillStyle = options.backgroundColor;
15297 ctx.strokeStyle = options.borderColor;
15298 ctx.lineWidth = options.borderWidth;
15299 ctx.beginPath();
15300 ctx.moveTo(x + topLeft, y);
15301 if (yAlign === "top") this.drawCaret(pt, ctx, tooltipSize, options);
15302 ctx.lineTo(x + width - topRight, y);
15303 ctx.quadraticCurveTo(x + width, y, x + width, y + topRight);
15304 if (yAlign === "center" && xAlign === "right") this.drawCaret(pt, ctx, tooltipSize, options);
15305 ctx.lineTo(x + width, y + height - bottomRight);
15306 ctx.quadraticCurveTo(x + width, y + height, x + width - bottomRight, y + height);
15307 if (yAlign === "bottom") this.drawCaret(pt, ctx, tooltipSize, options);
15308 ctx.lineTo(x + bottomLeft, y + height);
15309 ctx.quadraticCurveTo(x, y + height, x, y + height - bottomLeft);
15310 if (yAlign === "center" && xAlign === "left") this.drawCaret(pt, ctx, tooltipSize, options);
15311 ctx.lineTo(x, y + topLeft);
15312 ctx.quadraticCurveTo(x, y, x + topLeft, y);
15313 ctx.closePath();
15314 ctx.fill();
15315 if (options.borderWidth > 0) ctx.stroke();
15316 }
15317 },
15318 {
15319 key: "_updateAnimationTarget",
15320 value: function _updateAnimationTarget(options) {
15321 var chart = this.chart;
15322 var anims = this.$animations;
15323 var animX = anims && anims.x;
15324 var animY = anims && anims.y;
15325 if (animX || animY) {
15326 var position = positioners[options.position].call(this, this._active, this._eventPosition);
15327 if (!position) return;
15328 var size = this._size = getTooltipSize(this, options);
15329 var positionAndSize = Object.assign({}, position, this._size);
15330 var alignment = determineAlignment(chart, options, positionAndSize);
15331 var point = getBackgroundPoint(options, positionAndSize, alignment, chart);
15332 if (animX._to !== point.x || animY._to !== point.y) {
15333 this.xAlign = alignment.xAlign;
15334 this.yAlign = alignment.yAlign;
15335 this.width = size.width;
15336 this.height = size.height;
15337 this.caretX = position.x;
15338 this.caretY = position.y;
15339 this._resolveAnimations().update(this, point);
15340 }
15341 }
15342 }
15343 },
15344 {
15345 key: "_willRender",
15346 value: function _willRender() {
15347 return !!this.opacity;
15348 }
15349 },
15350 {
15351 key: "draw",
15352 value: function draw2(ctx) {
15353 var options = this.options.setContext(this.getContext());
15354 var opacity = this.opacity;
15355 if (!opacity) return;
15356 this._updateAnimationTarget(options);
15357 var tooltipSize = {
15358 width: this.width,
15359 height: this.height
15360 };
15361 var pt = {
15362 x: this.x,
15363 y: this.y
15364 };
15365 opacity = Math.abs(opacity) < 1e-3 ? 0 : opacity;
15366 var padding = (0, _helpersSegmentJs.D)(options.padding);
15367 var hasTooltipContent = this.title.length || this.beforeBody.length || this.body.length || this.afterBody.length || this.footer.length;
15368 if (options.enabled && hasTooltipContent) {
15369 ctx.save();
15370 ctx.globalAlpha = opacity;
15371 this.drawBackground(pt, ctx, tooltipSize, options);
15372 (0, _helpersSegmentJs.az)(ctx, options.textDirection);
15373 pt.y += padding.top;
15374 this.drawTitle(pt, ctx, options);
15375 this.drawBody(pt, ctx, options);
15376 this.drawFooter(pt, ctx, options);
15377 (0, _helpersSegmentJs.aB)(ctx, options.textDirection);
15378 ctx.restore();
15379 }
15380 }
15381 },
15382 {
15383 key: "getActiveElements",
15384 value: function getActiveElements() {
15385 return this._active || [];
15386 }
15387 },
15388 {
15389 key: "setActiveElements",
15390 value: function setActiveElements(activeElements, eventPosition) {
15391 var _this = this;
15392 var lastActive = this._active;
15393 var active = activeElements.map(function(param) {
15394 var datasetIndex = param.datasetIndex, index66 = param.index;
15395 var meta = _this.chart.getDatasetMeta(datasetIndex);
15396 if (!meta) throw new Error("Cannot find a dataset at index " + datasetIndex);
15397 return {
15398 datasetIndex: datasetIndex,
15399 element: meta.data[index66],
15400 index: index66
15401 };
15402 });
15403 var changed = !(0, _helpersSegmentJs.ag)(lastActive, active);
15404 var positionChanged = this._positionChanged(active, eventPosition);
15405 if (changed || positionChanged) {
15406 this._active = active;
15407 this._eventPosition = eventPosition;
15408 this._ignoreReplayEvents = true;
15409 this.update(true);
15410 }
15411 }
15412 },
15413 {
15414 key: "handleEvent",
15415 value: function handleEvent(e, replay) {
15416 var inChartArea = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
15417 if (replay && this._ignoreReplayEvents) return false;
15418 this._ignoreReplayEvents = false;
15419 var options = this.options;
15420 var lastActive = this._active || [];
15421 var active = this._getActiveElements(e, lastActive, replay, inChartArea);
15422 var positionChanged = this._positionChanged(active, e);
15423 var changed = replay || !(0, _helpersSegmentJs.ag)(active, lastActive) || positionChanged;
15424 if (changed) {
15425 this._active = active;
15426 if (options.enabled || options.external) {
15427 this._eventPosition = {
15428 x: e.x,
15429 y: e.y
15430 };
15431 this.update(true, replay);
15432 }
15433 }
15434 return changed;
15435 }
15436 },
15437 {
15438 key: "_getActiveElements",
15439 value: function _getActiveElements(e, lastActive, replay, inChartArea) {
15440 var options = this.options;
15441 if (e.type === "mouseout") return [];
15442 if (!inChartArea) return lastActive;
15443 var active = this.chart.getElementsAtEventForMode(e, options.mode, options, replay);
15444 if (options.reverse) active.reverse();
15445 return active;
15446 }
15447 },
15448 {
15449 key: "_positionChanged",
15450 value: function _positionChanged(active, e) {
15451 var ref = this, caretX = ref.caretX, caretY = ref.caretY, options = ref.options;
15452 var position = positioners[options.position].call(this, active, e);
15453 return position !== false && (caretX !== position.x || caretY !== position.y);
15454 }
15455 }
15456 ]);
15457 return Tooltip;
15458 }((0, _wrapNativeSuperJsDefault.default)(Element));
15459 Tooltip.positioners = positioners;
15460 var plugin_tooltip = {
15461 id: "tooltip",
15462 _element: Tooltip,
15463 positioners: positioners,
15464 afterInit: function(chart, _args, options) {
15465 if (options) chart.tooltip = new Tooltip({
15466 chart: chart,
15467 options: options
15468 });
15469 },
15470 beforeUpdate: function(chart, _args, options) {
15471 if (chart.tooltip) chart.tooltip.initialize(options);
15472 },
15473 reset: function(chart, _args, options) {
15474 if (chart.tooltip) chart.tooltip.initialize(options);
15475 },
15476 afterDraw: function(chart) {
15477 var tooltip = chart.tooltip;
15478 if (tooltip && tooltip._willRender()) {
15479 var args = {
15480 tooltip: tooltip
15481 };
15482 if (chart.notifyPlugins("beforeTooltipDraw", args) === false) return;
15483 tooltip.draw(chart.ctx);
15484 chart.notifyPlugins("afterTooltipDraw", args);
15485 }
15486 },
15487 afterEvent: function(chart, args) {
15488 if (chart.tooltip) {
15489 var useFinalPosition = args.replay;
15490 if (chart.tooltip.handleEvent(args.event, useFinalPosition, args.inChartArea)) args.changed = true;
15491 }
15492 },
15493 defaults: {
15494 enabled: true,
15495 external: null,
15496 position: "average",
15497 backgroundColor: "rgba(0,0,0,0.8)",
15498 titleColor: "#fff",
15499 titleFont: {
15500 weight: "bold"
15501 },
15502 titleSpacing: 2,
15503 titleMarginBottom: 6,
15504 titleAlign: "left",
15505 bodyColor: "#fff",
15506 bodySpacing: 2,
15507 bodyFont: {},
15508 bodyAlign: "left",
15509 footerColor: "#fff",
15510 footerSpacing: 2,
15511 footerMarginTop: 6,
15512 footerFont: {
15513 weight: "bold"
15514 },
15515 footerAlign: "left",
15516 padding: 6,
15517 caretPadding: 2,
15518 caretSize: 5,
15519 cornerRadius: 6,
15520 boxHeight: function(ctx, opts) {
15521 return opts.bodyFont.size;
15522 },
15523 boxWidth: function(ctx, opts) {
15524 return opts.bodyFont.size;
15525 },
15526 multiKeyBackground: "#fff",
15527 displayColors: true,
15528 boxPadding: 0,
15529 borderColor: "rgba(0,0,0,0)",
15530 borderWidth: 0,
15531 animation: {
15532 duration: 400,
15533 easing: "easeOutQuart"
15534 },
15535 animations: {
15536 numbers: {
15537 type: "number",
15538 properties: [
15539 "x",
15540 "y",
15541 "width",
15542 "height",
15543 "caretX",
15544 "caretY"
15545 ]
15546 },
15547 opacity: {
15548 easing: "linear",
15549 duration: 200
15550 }
15551 },
15552 callbacks: {
15553 beforeTitle: (0, _helpersSegmentJs.aC),
15554 title: function(tooltipItems) {
15555 if (tooltipItems.length > 0) {
15556 var item = tooltipItems[0];
15557 var labels = item.chart.data.labels;
15558 var labelCount = labels ? labels.length : 0;
15559 if (this && this.options && this.options.mode === "dataset") return item.dataset.label || "";
15560 else if (item.label) return item.label;
15561 else if (labelCount > 0 && item.dataIndex < labelCount) return labels[item.dataIndex];
15562 }
15563 return "";
15564 },
15565 afterTitle: (0, _helpersSegmentJs.aC),
15566 beforeBody: (0, _helpersSegmentJs.aC),
15567 beforeLabel: (0, _helpersSegmentJs.aC),
15568 label: function(tooltipItem) {
15569 if (this && this.options && this.options.mode === "dataset") return tooltipItem.label + ": " + tooltipItem.formattedValue || tooltipItem.formattedValue;
15570 var label = tooltipItem.dataset.label || "";
15571 if (label) label += ": ";
15572 var value = tooltipItem.formattedValue;
15573 if (!(0, _helpersSegmentJs.k)(value)) label += value;
15574 return label;
15575 },
15576 labelColor: function(tooltipItem) {
15577 var meta = tooltipItem.chart.getDatasetMeta(tooltipItem.datasetIndex);
15578 var options = meta.controller.getStyle(tooltipItem.dataIndex);
15579 return {
15580 borderColor: options.borderColor,
15581 backgroundColor: options.backgroundColor,
15582 borderWidth: options.borderWidth,
15583 borderDash: options.borderDash,
15584 borderDashOffset: options.borderDashOffset,
15585 borderRadius: 0
15586 };
15587 },
15588 labelTextColor: function() {
15589 return this.options.bodyColor;
15590 },
15591 labelPointStyle: function(tooltipItem) {
15592 var meta = tooltipItem.chart.getDatasetMeta(tooltipItem.datasetIndex);
15593 var options = meta.controller.getStyle(tooltipItem.dataIndex);
15594 return {
15595 pointStyle: options.pointStyle,
15596 rotation: options.rotation
15597 };
15598 },
15599 afterLabel: (0, _helpersSegmentJs.aC),
15600 afterBody: (0, _helpersSegmentJs.aC),
15601 beforeFooter: (0, _helpersSegmentJs.aC),
15602 footer: (0, _helpersSegmentJs.aC),
15603 afterFooter: (0, _helpersSegmentJs.aC)
15604 }
15605 },
15606 defaultRoutes: {
15607 bodyFont: "font",
15608 footerFont: "font",
15609 titleFont: "font"
15610 },
15611 descriptors: {
15612 _scriptable: function(name) {
15613 return name !== "filter" && name !== "itemSort" && name !== "external";
15614 },
15615 _indexable: false,
15616 callbacks: {
15617 _scriptable: false,
15618 _indexable: false
15619 },
15620 animation: {
15621 _fallback: false
15622 },
15623 animations: {
15624 _fallback: "animation"
15625 }
15626 },
15627 additionalOptionScopes: [
15628 "interaction"
15629 ]
15630 };
15631 var plugins = /*#__PURE__*/ Object.freeze({
15632 __proto__: null,
15633 Decimation: plugin_decimation,
15634 Filler: index,
15635 Legend: plugin_legend,
15636 SubTitle: plugin_subtitle,
15637 Title: plugin_title,
15638 Tooltip: plugin_tooltip
15639 });
15640 var addIfString = function(labels, raw, index67, addedLabels) {
15641 if (typeof raw === "string") {
15642 index67 = labels.push(raw) - 1;
15643 addedLabels.unshift({
15644 index: index67,
15645 label: raw
15646 });
15647 } else if (isNaN(raw)) index67 = null;
15648 return index67;
15649 };
15650 function findOrAddLabel(labels, raw, index68, addedLabels) {
15651 var first = labels.indexOf(raw);
15652 if (first === -1) return addIfString(labels, raw, index68, addedLabels);
15653 var last = labels.lastIndexOf(raw);
15654 return first !== last ? index68 : first;
15655 }
15656 var validIndex = function(index69, max) {
15657 return index69 === null ? null : (0, _helpersSegmentJs.w)(Math.round(index69), 0, max);
15658 };
15659 var CategoryScale = /*#__PURE__*/ function(Scale) {
15660 "use strict";
15661 (0, _inheritsJsDefault.default)(CategoryScale, Scale);
15662 var _super = (0, _createSuperJsDefault.default)(CategoryScale);
15663 function CategoryScale(cfg) {
15664 (0, _classCallCheckJsDefault.default)(this, CategoryScale);
15665 var _this;
15666 _this = _super.call(this, cfg);
15667 _this._startValue = undefined;
15668 _this._valueRange = 0;
15669 _this._addedLabels = [];
15670 return _this;
15671 }
15672 (0, _createClassJsDefault.default)(CategoryScale, [
15673 {
15674 key: "init",
15675 value: function init(scaleOptions) {
15676 var added = this._addedLabels;
15677 if (added.length) {
15678 var labels = this.getLabels();
15679 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
15680 try {
15681 for(var _iterator = added[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
15682 var _value = _step.value, index70 = _value.index, label = _value.label;
15683 if (labels[index70] === label) labels.splice(index70, 1);
15684 }
15685 } catch (err) {
15686 _didIteratorError = true;
15687 _iteratorError = err;
15688 } finally{
15689 try {
15690 if (!_iteratorNormalCompletion && _iterator.return != null) {
15691 _iterator.return();
15692 }
15693 } finally{
15694 if (_didIteratorError) {
15695 throw _iteratorError;
15696 }
15697 }
15698 }
15699 this._addedLabels = [];
15700 }
15701 (0, _getJsDefault.default)((0, _getPrototypeOfJsDefault.default)(CategoryScale.prototype), "init", this).call(this, scaleOptions);
15702 }
15703 },
15704 {
15705 key: "parse",
15706 value: function parse1(raw, index71) {
15707 if ((0, _helpersSegmentJs.k)(raw)) return null;
15708 var labels = this.getLabels();
15709 index71 = isFinite(index71) && labels[index71] === raw ? index71 : findOrAddLabel(labels, raw, (0, _helpersSegmentJs.v)(index71, raw), this._addedLabels);
15710 return validIndex(index71, labels.length - 1);
15711 }
15712 },
15713 {
15714 key: "determineDataLimits",
15715 value: function determineDataLimits() {
15716 var ref = this.getUserBounds(), minDefined = ref.minDefined, maxDefined = ref.maxDefined;
15717 var ref14 = this.getMinMax(true), min = ref14.min, max = ref14.max;
15718 if (this.options.bounds === "ticks") {
15719 if (!minDefined) min = 0;
15720 if (!maxDefined) max = this.getLabels().length - 1;
15721 }
15722 this.min = min;
15723 this.max = max;
15724 }
15725 },
15726 {
15727 key: "buildTicks",
15728 value: function buildTicks() {
15729 var min = this.min;
15730 var max = this.max;
15731 var offset = this.options.offset;
15732 var ticks = [];
15733 var labels = this.getLabels();
15734 labels = min === 0 && max === labels.length - 1 ? labels : labels.slice(min, max + 1);
15735 this._valueRange = Math.max(labels.length - (offset ? 0 : 1), 1);
15736 this._startValue = this.min - (offset ? 0.5 : 0);
15737 for(var value = min; value <= max; value++)ticks.push({
15738 value: value
15739 });
15740 return ticks;
15741 }
15742 },
15743 {
15744 key: "getLabelForValue",
15745 value: function getLabelForValue(value) {
15746 var labels = this.getLabels();
15747 if (value >= 0 && value < labels.length) return labels[value];
15748 return value;
15749 }
15750 },
15751 {
15752 key: "configure",
15753 value: function configure() {
15754 (0, _getJsDefault.default)((0, _getPrototypeOfJsDefault.default)(CategoryScale.prototype), "configure", this).call(this);
15755 if (!this.isHorizontal()) this._reversePixels = !this._reversePixels;
15756 }
15757 },
15758 {
15759 key: "getPixelForValue",
15760 value: function getPixelForValue(value) {
15761 if (typeof value !== "number") value = this.parse(value);
15762 return value === null ? NaN : this.getPixelForDecimal((value - this._startValue) / this._valueRange);
15763 }
15764 },
15765 {
15766 key: "getPixelForTick",
15767 value: function getPixelForTick(index72) {
15768 var ticks = this.ticks;
15769 if (index72 < 0 || index72 > ticks.length - 1) return null;
15770 return this.getPixelForValue(ticks[index72].value);
15771 }
15772 },
15773 {
15774 key: "getValueForPixel",
15775 value: function getValueForPixel(pixel) {
15776 return Math.round(this._startValue + this.getDecimalForPixel(pixel) * this._valueRange);
15777 }
15778 },
15779 {
15780 key: "getBasePixel",
15781 value: function getBasePixel() {
15782 return this.bottom;
15783 }
15784 }
15785 ]);
15786 return CategoryScale;
15787 }(Scale);
15788 CategoryScale.id = "category";
15789 CategoryScale.defaults = {
15790 ticks: {
15791 callback: CategoryScale.prototype.getLabelForValue
15792 }
15793 };
15794 function generateTicks$1(generationOptions, dataRange) {
15795 var ticks = [];
15796 var MIN_SPACING = 1e-14;
15797 var bounds = generationOptions.bounds, step = generationOptions.step, min = generationOptions.min, max = generationOptions.max, precision = generationOptions.precision, count = generationOptions.count, maxTicks = generationOptions.maxTicks, maxDigits = generationOptions.maxDigits, includeBounds = generationOptions.includeBounds;
15798 var unit = step || 1;
15799 var maxSpaces = maxTicks - 1;
15800 var rmin = dataRange.min, rmax = dataRange.max;
15801 var minDefined = !(0, _helpersSegmentJs.k)(min);
15802 var maxDefined = !(0, _helpersSegmentJs.k)(max);
15803 var countDefined = !(0, _helpersSegmentJs.k)(count);
15804 var minSpacing = (rmax - rmin) / (maxDigits + 1);
15805 var spacing = (0, _helpersSegmentJs.aF)((rmax - rmin) / maxSpaces / unit) * unit;
15806 var factor, niceMin, niceMax, numSpaces;
15807 if (spacing < MIN_SPACING && !minDefined && !maxDefined) return [
15808 {
15809 value: rmin
15810 },
15811 {
15812 value: rmax
15813 }
15814 ];
15815 numSpaces = Math.ceil(rmax / spacing) - Math.floor(rmin / spacing);
15816 if (numSpaces > maxSpaces) spacing = (0, _helpersSegmentJs.aF)(numSpaces * spacing / maxSpaces / unit) * unit;
15817 if (!(0, _helpersSegmentJs.k)(precision)) {
15818 factor = Math.pow(10, precision);
15819 spacing = Math.ceil(spacing * factor) / factor;
15820 }
15821 if (bounds === "ticks") {
15822 niceMin = Math.floor(rmin / spacing) * spacing;
15823 niceMax = Math.ceil(rmax / spacing) * spacing;
15824 } else {
15825 niceMin = rmin;
15826 niceMax = rmax;
15827 }
15828 if (minDefined && maxDefined && step && (0, _helpersSegmentJs.aG)((max - min) / step, spacing / 1000)) {
15829 numSpaces = Math.round(Math.min((max - min) / spacing, maxTicks));
15830 spacing = (max - min) / numSpaces;
15831 niceMin = min;
15832 niceMax = max;
15833 } else if (countDefined) {
15834 niceMin = minDefined ? min : niceMin;
15835 niceMax = maxDefined ? max : niceMax;
15836 numSpaces = count - 1;
15837 spacing = (niceMax - niceMin) / numSpaces;
15838 } else {
15839 numSpaces = (niceMax - niceMin) / spacing;
15840 if ((0, _helpersSegmentJs.aH)(numSpaces, Math.round(numSpaces), spacing / 1000)) numSpaces = Math.round(numSpaces);
15841 else numSpaces = Math.ceil(numSpaces);
15842 }
15843 var decimalPlaces = Math.max((0, _helpersSegmentJs.aI)(spacing), (0, _helpersSegmentJs.aI)(niceMin));
15844 factor = Math.pow(10, (0, _helpersSegmentJs.k)(precision) ? decimalPlaces : precision);
15845 niceMin = Math.round(niceMin * factor) / factor;
15846 niceMax = Math.round(niceMax * factor) / factor;
15847 var j = 0;
15848 if (minDefined) {
15849 if (includeBounds && niceMin !== min) {
15850 ticks.push({
15851 value: min
15852 });
15853 if (niceMin < min) j++;
15854 if ((0, _helpersSegmentJs.aH)(Math.round((niceMin + j * spacing) * factor) / factor, min, relativeLabelSize(min, minSpacing, generationOptions))) j++;
15855 } else if (niceMin < min) j++;
15856 }
15857 for(; j < numSpaces; ++j)ticks.push({
15858 value: Math.round((niceMin + j * spacing) * factor) / factor
15859 });
15860 if (maxDefined && includeBounds && niceMax !== max) {
15861 if (ticks.length && (0, _helpersSegmentJs.aH)(ticks[ticks.length - 1].value, max, relativeLabelSize(max, minSpacing, generationOptions))) ticks[ticks.length - 1].value = max;
15862 else ticks.push({
15863 value: max
15864 });
15865 } else if (!maxDefined || niceMax === max) ticks.push({
15866 value: niceMax
15867 });
15868 return ticks;
15869 }
15870 function relativeLabelSize(value, minSpacing, param) {
15871 var horizontal = param.horizontal, minRotation = param.minRotation;
15872 var rad = (0, _helpersSegmentJs.t)(minRotation);
15873 var ratio = (horizontal ? Math.sin(rad) : Math.cos(rad)) || 0.001;
15874 var length = 0.75 * minSpacing * ("" + value).length;
15875 return Math.min(minSpacing / ratio, length);
15876 }
15877 var LinearScaleBase = /*#__PURE__*/ function(Scale) {
15878 "use strict";
15879 (0, _inheritsJsDefault.default)(LinearScaleBase, Scale);
15880 var _super = (0, _createSuperJsDefault.default)(LinearScaleBase);
15881 function LinearScaleBase(cfg) {
15882 (0, _classCallCheckJsDefault.default)(this, LinearScaleBase);
15883 var _this;
15884 _this = _super.call(this, cfg);
15885 _this.start = undefined;
15886 _this.end = undefined;
15887 _this._startValue = undefined;
15888 _this._endValue = undefined;
15889 _this._valueRange = 0;
15890 return _this;
15891 }
15892 (0, _createClassJsDefault.default)(LinearScaleBase, [
15893 {
15894 key: "parse",
15895 value: function parse1(raw, index) {
15896 if ((0, _helpersSegmentJs.k)(raw)) return null;
15897 if ((typeof raw === "number" || raw instanceof Number) && !isFinite(+raw)) return null;
15898 return +raw;
15899 }
15900 },
15901 {
15902 key: "handleTickRangeOptions",
15903 value: function handleTickRangeOptions() {
15904 var beginAtZero = this.options.beginAtZero;
15905 var ref = this.getUserBounds(), minDefined = ref.minDefined, maxDefined = ref.maxDefined;
15906 var ref15 = this, min = ref15.min, max = ref15.max;
15907 var setMin = function(v) {
15908 return min = minDefined ? min : v;
15909 };
15910 var setMax = function(v) {
15911 return max = maxDefined ? max : v;
15912 };
15913 if (beginAtZero) {
15914 var minSign = (0, _helpersSegmentJs.s)(min);
15915 var maxSign = (0, _helpersSegmentJs.s)(max);
15916 if (minSign < 0 && maxSign < 0) setMax(0);
15917 else if (minSign > 0 && maxSign > 0) setMin(0);
15918 }
15919 if (min === max) {
15920 var offset = 1;
15921 if (max >= Number.MAX_SAFE_INTEGER || min <= Number.MIN_SAFE_INTEGER) offset = Math.abs(max * 0.05);
15922 setMax(max + offset);
15923 if (!beginAtZero) setMin(min - offset);
15924 }
15925 this.min = min;
15926 this.max = max;
15927 }
15928 },
15929 {
15930 key: "getTickLimit",
15931 value: function getTickLimit() {
15932 var tickOpts = this.options.ticks;
15933 var maxTicksLimit = tickOpts.maxTicksLimit, stepSize = tickOpts.stepSize;
15934 var maxTicks;
15935 if (stepSize) {
15936 maxTicks = Math.ceil(this.max / stepSize) - Math.floor(this.min / stepSize) + 1;
15937 if (maxTicks > 1000) {
15938 console.warn("scales.".concat(this.id, ".ticks.stepSize: ").concat(stepSize, " would result generating up to ").concat(maxTicks, " ticks. Limiting to 1000."));
15939 maxTicks = 1000;
15940 }
15941 } else {
15942 maxTicks = this.computeTickLimit();
15943 maxTicksLimit = maxTicksLimit || 11;
15944 }
15945 if (maxTicksLimit) maxTicks = Math.min(maxTicksLimit, maxTicks);
15946 return maxTicks;
15947 }
15948 },
15949 {
15950 key: "computeTickLimit",
15951 value: function computeTickLimit() {
15952 return Number.POSITIVE_INFINITY;
15953 }
15954 },
15955 {
15956 key: "buildTicks",
15957 value: function buildTicks() {
15958 var opts = this.options;
15959 var tickOpts = opts.ticks;
15960 var maxTicks = this.getTickLimit();
15961 maxTicks = Math.max(2, maxTicks);
15962 var numericGeneratorOptions = {
15963 maxTicks: maxTicks,
15964 bounds: opts.bounds,
15965 min: opts.min,
15966 max: opts.max,
15967 precision: tickOpts.precision,
15968 step: tickOpts.stepSize,
15969 count: tickOpts.count,
15970 maxDigits: this._maxDigits(),
15971 horizontal: this.isHorizontal(),
15972 minRotation: tickOpts.minRotation || 0,
15973 includeBounds: tickOpts.includeBounds !== false
15974 };
15975 var dataRange = this._range || this;
15976 var ticks = generateTicks$1(numericGeneratorOptions, dataRange);
15977 if (opts.bounds === "ticks") (0, _helpersSegmentJs.aE)(ticks, this, "value");
15978 if (opts.reverse) {
15979 ticks.reverse();
15980 this.start = this.max;
15981 this.end = this.min;
15982 } else {
15983 this.start = this.min;
15984 this.end = this.max;
15985 }
15986 return ticks;
15987 }
15988 },
15989 {
15990 key: "configure",
15991 value: function configure() {
15992 var ticks = this.ticks;
15993 var start = this.min;
15994 var end = this.max;
15995 (0, _getJsDefault.default)((0, _getPrototypeOfJsDefault.default)(LinearScaleBase.prototype), "configure", this).call(this);
15996 if (this.options.offset && ticks.length) {
15997 var offset = (end - start) / Math.max(ticks.length - 1, 1) / 2;
15998 start -= offset;
15999 end += offset;
16000 }
16001 this._startValue = start;
16002 this._endValue = end;
16003 this._valueRange = end - start;
16004 }
16005 },
16006 {
16007 key: "getLabelForValue",
16008 value: function getLabelForValue(value) {
16009 return (0, _helpersSegmentJs.o)(value, this.chart.options.locale, this.options.ticks.format);
16010 }
16011 }
16012 ]);
16013 return LinearScaleBase;
16014 }(Scale);
16015 var LinearScale = /*#__PURE__*/ function(LinearScaleBase) {
16016 "use strict";
16017 (0, _inheritsJsDefault.default)(LinearScale, LinearScaleBase);
16018 var _super = (0, _createSuperJsDefault.default)(LinearScale);
16019 function LinearScale() {
16020 (0, _classCallCheckJsDefault.default)(this, LinearScale);
16021 return _super.apply(this, arguments);
16022 }
16023 (0, _createClassJsDefault.default)(LinearScale, [
16024 {
16025 key: "determineDataLimits",
16026 value: function determineDataLimits() {
16027 var ref = this.getMinMax(true), min = ref.min, max = ref.max;
16028 this.min = (0, _helpersSegmentJs.g)(min) ? min : 0;
16029 this.max = (0, _helpersSegmentJs.g)(max) ? max : 1;
16030 this.handleTickRangeOptions();
16031 }
16032 },
16033 {
16034 key: "computeTickLimit",
16035 value: function computeTickLimit() {
16036 var horizontal = this.isHorizontal();
16037 var length = horizontal ? this.width : this.height;
16038 var minRotation = (0, _helpersSegmentJs.t)(this.options.ticks.minRotation);
16039 var ratio = (horizontal ? Math.sin(minRotation) : Math.cos(minRotation)) || 0.001;
16040 var tickFont = this._resolveTickFontOptions(0);
16041 return Math.ceil(length / Math.min(40, tickFont.lineHeight / ratio));
16042 }
16043 },
16044 {
16045 key: "getPixelForValue",
16046 value: function getPixelForValue(value) {
16047 return value === null ? NaN : this.getPixelForDecimal((value - this._startValue) / this._valueRange);
16048 }
16049 },
16050 {
16051 key: "getValueForPixel",
16052 value: function getValueForPixel(pixel) {
16053 return this._startValue + this.getDecimalForPixel(pixel) * this._valueRange;
16054 }
16055 }
16056 ]);
16057 return LinearScale;
16058 }(LinearScaleBase);
16059 LinearScale.id = "linear";
16060 LinearScale.defaults = {
16061 ticks: {
16062 callback: Ticks.formatters.numeric
16063 }
16064 };
16065 function isMajor(tickVal) {
16066 var remain = tickVal / Math.pow(10, Math.floor((0, _helpersSegmentJs.M)(tickVal)));
16067 return remain === 1;
16068 }
16069 function generateTicks(generationOptions, dataRange) {
16070 var endExp = Math.floor((0, _helpersSegmentJs.M)(dataRange.max));
16071 var endSignificand = Math.ceil(dataRange.max / Math.pow(10, endExp));
16072 var ticks = [];
16073 var tickVal = (0, _helpersSegmentJs.O)(generationOptions.min, Math.pow(10, Math.floor((0, _helpersSegmentJs.M)(dataRange.min))));
16074 var exp = Math.floor((0, _helpersSegmentJs.M)(tickVal));
16075 var significand = Math.floor(tickVal / Math.pow(10, exp));
16076 var precision = exp < 0 ? Math.pow(10, Math.abs(exp)) : 1;
16077 do {
16078 ticks.push({
16079 value: tickVal,
16080 major: isMajor(tickVal)
16081 });
16082 ++significand;
16083 if (significand === 10) {
16084 significand = 1;
16085 ++exp;
16086 precision = exp >= 0 ? 1 : precision;
16087 }
16088 tickVal = Math.round(significand * Math.pow(10, exp) * precision) / precision;
16089 }while (exp < endExp || exp === endExp && significand < endSignificand);
16090 var lastTick = (0, _helpersSegmentJs.O)(generationOptions.max, tickVal);
16091 ticks.push({
16092 value: lastTick,
16093 major: isMajor(tickVal)
16094 });
16095 return ticks;
16096 }
16097 var LogarithmicScale = /*#__PURE__*/ function(Scale) {
16098 "use strict";
16099 (0, _inheritsJsDefault.default)(LogarithmicScale, Scale);
16100 var _super = (0, _createSuperJsDefault.default)(LogarithmicScale);
16101 function LogarithmicScale(cfg) {
16102 (0, _classCallCheckJsDefault.default)(this, LogarithmicScale);
16103 var _this;
16104 _this = _super.call(this, cfg);
16105 _this.start = undefined;
16106 _this.end = undefined;
16107 _this._startValue = undefined;
16108 _this._valueRange = 0;
16109 return _this;
16110 }
16111 (0, _createClassJsDefault.default)(LogarithmicScale, [
16112 {
16113 key: "parse",
16114 value: function parse1(raw, index73) {
16115 var value = LinearScaleBase.prototype.parse.apply(this, [
16116 raw,
16117 index73
16118 ]);
16119 if (value === 0) {
16120 this._zero = true;
16121 return undefined;
16122 }
16123 return (0, _helpersSegmentJs.g)(value) && value > 0 ? value : null;
16124 }
16125 },
16126 {
16127 key: "determineDataLimits",
16128 value: function determineDataLimits() {
16129 var ref = this.getMinMax(true), min = ref.min, max = ref.max;
16130 this.min = (0, _helpersSegmentJs.g)(min) ? Math.max(0, min) : null;
16131 this.max = (0, _helpersSegmentJs.g)(max) ? Math.max(0, max) : null;
16132 if (this.options.beginAtZero) this._zero = true;
16133 this.handleTickRangeOptions();
16134 }
16135 },
16136 {
16137 key: "handleTickRangeOptions",
16138 value: function handleTickRangeOptions() {
16139 var ref = this.getUserBounds(), minDefined = ref.minDefined, maxDefined = ref.maxDefined;
16140 var min = this.min;
16141 var max = this.max;
16142 var setMin = function(v) {
16143 return min = minDefined ? min : v;
16144 };
16145 var setMax = function(v) {
16146 return max = maxDefined ? max : v;
16147 };
16148 var exp = function(v, m) {
16149 return Math.pow(10, Math.floor((0, _helpersSegmentJs.M)(v)) + m);
16150 };
16151 if (min === max) {
16152 if (min <= 0) {
16153 setMin(1);
16154 setMax(10);
16155 } else {
16156 setMin(exp(min, -1));
16157 setMax(exp(max, 1));
16158 }
16159 }
16160 if (min <= 0) setMin(exp(max, -1));
16161 if (max <= 0) setMax(exp(min, 1));
16162 if (this._zero && this.min !== this._suggestedMin && min === exp(this.min, 0)) setMin(exp(min, -1));
16163 this.min = min;
16164 this.max = max;
16165 }
16166 },
16167 {
16168 key: "buildTicks",
16169 value: function buildTicks() {
16170 var opts = this.options;
16171 var generationOptions = {
16172 min: this._userMin,
16173 max: this._userMax
16174 };
16175 var ticks = generateTicks(generationOptions, this);
16176 if (opts.bounds === "ticks") (0, _helpersSegmentJs.aE)(ticks, this, "value");
16177 if (opts.reverse) {
16178 ticks.reverse();
16179 this.start = this.max;
16180 this.end = this.min;
16181 } else {
16182 this.start = this.min;
16183 this.end = this.max;
16184 }
16185 return ticks;
16186 }
16187 },
16188 {
16189 key: "getLabelForValue",
16190 value: function getLabelForValue(value) {
16191 return value === undefined ? "0" : (0, _helpersSegmentJs.o)(value, this.chart.options.locale, this.options.ticks.format);
16192 }
16193 },
16194 {
16195 key: "configure",
16196 value: function configure() {
16197 var start = this.min;
16198 (0, _getJsDefault.default)((0, _getPrototypeOfJsDefault.default)(LogarithmicScale.prototype), "configure", this).call(this);
16199 this._startValue = (0, _helpersSegmentJs.M)(start);
16200 this._valueRange = (0, _helpersSegmentJs.M)(this.max) - (0, _helpersSegmentJs.M)(start);
16201 }
16202 },
16203 {
16204 key: "getPixelForValue",
16205 value: function getPixelForValue(value) {
16206 if (value === undefined || value === 0) value = this.min;
16207 if (value === null || isNaN(value)) return NaN;
16208 return this.getPixelForDecimal(value === this.min ? 0 : ((0, _helpersSegmentJs.M)(value) - this._startValue) / this._valueRange);
16209 }
16210 },
16211 {
16212 key: "getValueForPixel",
16213 value: function getValueForPixel(pixel) {
16214 var decimal = this.getDecimalForPixel(pixel);
16215 return Math.pow(10, this._startValue + decimal * this._valueRange);
16216 }
16217 }
16218 ]);
16219 return LogarithmicScale;
16220 }(Scale);
16221 LogarithmicScale.id = "logarithmic";
16222 LogarithmicScale.defaults = {
16223 ticks: {
16224 callback: Ticks.formatters.logarithmic,
16225 major: {
16226 enabled: true
16227 }
16228 }
16229 };
16230 function getTickBackdropHeight(opts) {
16231 var tickOpts = opts.ticks;
16232 if (tickOpts.display && opts.display) {
16233 var padding = (0, _helpersSegmentJs.D)(tickOpts.backdropPadding);
16234 return (0, _helpersSegmentJs.v)(tickOpts.font && tickOpts.font.size, (0, _helpersSegmentJs.d).font.size) + padding.height;
16235 }
16236 return 0;
16237 }
16238 function measureLabelSize(ctx, font, label) {
16239 label = (0, _helpersSegmentJs.b)(label) ? label : [
16240 label
16241 ];
16242 return {
16243 w: (0, _helpersSegmentJs.aJ)(ctx, font.string, label),
16244 h: label.length * font.lineHeight
16245 };
16246 }
16247 function determineLimits(angle, pos, size, min, max) {
16248 if (angle === min || angle === max) return {
16249 start: pos - size / 2,
16250 end: pos + size / 2
16251 };
16252 else if (angle < min || angle > max) return {
16253 start: pos - size,
16254 end: pos
16255 };
16256 return {
16257 start: pos,
16258 end: pos + size
16259 };
16260 }
16261 function fitWithPointLabels(scale) {
16262 var orig = {
16263 l: scale.left + scale._padding.left,
16264 r: scale.right - scale._padding.right,
16265 t: scale.top + scale._padding.top,
16266 b: scale.bottom - scale._padding.bottom
16267 };
16268 var limits = Object.assign({}, orig);
16269 var labelSizes = [];
16270 var padding = [];
16271 var valueCount = scale._pointLabels.length;
16272 var pointLabelOpts = scale.options.pointLabels;
16273 var additionalAngle = pointLabelOpts.centerPointLabels ? (0, _helpersSegmentJs.P) / valueCount : 0;
16274 for(var i = 0; i < valueCount; i++){
16275 var opts = pointLabelOpts.setContext(scale.getPointLabelContext(i));
16276 padding[i] = opts.padding;
16277 var pointPosition = scale.getPointPosition(i, scale.drawingArea + padding[i], additionalAngle);
16278 var plFont = (0, _helpersSegmentJs.$)(opts.font);
16279 var textSize = measureLabelSize(scale.ctx, plFont, scale._pointLabels[i]);
16280 labelSizes[i] = textSize;
16281 var angleRadians = (0, _helpersSegmentJs.ax)(scale.getIndexAngle(i) + additionalAngle);
16282 var angle = Math.round((0, _helpersSegmentJs.S)(angleRadians));
16283 var hLimits = determineLimits(angle, pointPosition.x, textSize.w, 0, 180);
16284 var vLimits = determineLimits(angle, pointPosition.y, textSize.h, 90, 270);
16285 updateLimits(limits, orig, angleRadians, hLimits, vLimits);
16286 }
16287 scale.setCenterPoint(orig.l - limits.l, limits.r - orig.r, orig.t - limits.t, limits.b - orig.b);
16288 scale._pointLabelItems = buildPointLabelItems(scale, labelSizes, padding);
16289 }
16290 function updateLimits(limits, orig, angle, hLimits, vLimits) {
16291 var sin = Math.abs(Math.sin(angle));
16292 var cos = Math.abs(Math.cos(angle));
16293 var x = 0;
16294 var y = 0;
16295 if (hLimits.start < orig.l) {
16296 x = (orig.l - hLimits.start) / sin;
16297 limits.l = Math.min(limits.l, orig.l - x);
16298 } else if (hLimits.end > orig.r) {
16299 x = (hLimits.end - orig.r) / sin;
16300 limits.r = Math.max(limits.r, orig.r + x);
16301 }
16302 if (vLimits.start < orig.t) {
16303 y = (orig.t - vLimits.start) / cos;
16304 limits.t = Math.min(limits.t, orig.t - y);
16305 } else if (vLimits.end > orig.b) {
16306 y = (vLimits.end - orig.b) / cos;
16307 limits.b = Math.max(limits.b, orig.b + y);
16308 }
16309 }
16310 function buildPointLabelItems(scale, labelSizes, padding) {
16311 var items = [];
16312 var valueCount = scale._pointLabels.length;
16313 var opts = scale.options;
16314 var extra = getTickBackdropHeight(opts) / 2;
16315 var outerDistance = scale.drawingArea;
16316 var additionalAngle = opts.pointLabels.centerPointLabels ? (0, _helpersSegmentJs.P) / valueCount : 0;
16317 for(var i = 0; i < valueCount; i++){
16318 var pointLabelPosition = scale.getPointPosition(i, outerDistance + extra + padding[i], additionalAngle);
16319 var angle = Math.round((0, _helpersSegmentJs.S)((0, _helpersSegmentJs.ax)(pointLabelPosition.angle + (0, _helpersSegmentJs.H))));
16320 var size = labelSizes[i];
16321 var y = yForAngle(pointLabelPosition.y, size.h, angle);
16322 var textAlign = getTextAlignForAngle(angle);
16323 var left = leftForTextAlign(pointLabelPosition.x, size.w, textAlign);
16324 items.push({
16325 x: pointLabelPosition.x,
16326 y: y,
16327 textAlign: textAlign,
16328 left: left,
16329 top: y,
16330 right: left + size.w,
16331 bottom: y + size.h
16332 });
16333 }
16334 return items;
16335 }
16336 function getTextAlignForAngle(angle) {
16337 if (angle === 0 || angle === 180) return "center";
16338 else if (angle < 180) return "left";
16339 return "right";
16340 }
16341 function leftForTextAlign(x, w, align) {
16342 if (align === "right") x -= w;
16343 else if (align === "center") x -= w / 2;
16344 return x;
16345 }
16346 function yForAngle(y, h, angle) {
16347 if (angle === 90 || angle === 270) y -= h / 2;
16348 else if (angle > 270 || angle < 90) y -= h;
16349 return y;
16350 }
16351 function drawPointLabels(scale, labelCount) {
16352 var ctx = scale.ctx, pointLabels = scale.options.pointLabels;
16353 for(var i = labelCount - 1; i >= 0; i--){
16354 var optsAtIndex = pointLabels.setContext(scale.getPointLabelContext(i));
16355 var plFont = (0, _helpersSegmentJs.$)(optsAtIndex.font);
16356 var _i = scale._pointLabelItems[i], x = _i.x, y = _i.y, textAlign = _i.textAlign, left = _i.left, top = _i.top, right = _i.right, bottom = _i.bottom;
16357 var backdropColor = optsAtIndex.backdropColor;
16358 if (!(0, _helpersSegmentJs.k)(backdropColor)) {
16359 var borderRadius = (0, _helpersSegmentJs.av)(optsAtIndex.borderRadius);
16360 var padding = (0, _helpersSegmentJs.D)(optsAtIndex.backdropPadding);
16361 ctx.fillStyle = backdropColor;
16362 var backdropLeft = left - padding.left;
16363 var backdropTop = top - padding.top;
16364 var backdropWidth = right - left + padding.width;
16365 var backdropHeight = bottom - top + padding.height;
16366 if (Object.values(borderRadius).some(function(v) {
16367 return v !== 0;
16368 })) {
16369 ctx.beginPath();
16370 (0, _helpersSegmentJs.at)(ctx, {
16371 x: backdropLeft,
16372 y: backdropTop,
16373 w: backdropWidth,
16374 h: backdropHeight,
16375 radius: borderRadius
16376 });
16377 ctx.fill();
16378 } else ctx.fillRect(backdropLeft, backdropTop, backdropWidth, backdropHeight);
16379 }
16380 (0, _helpersSegmentJs.Y)(ctx, scale._pointLabels[i], x, y + plFont.lineHeight / 2, plFont, {
16381 color: optsAtIndex.color,
16382 textAlign: textAlign,
16383 textBaseline: "middle"
16384 });
16385 }
16386 }
16387 function pathRadiusLine(scale, radius, circular, labelCount) {
16388 var ctx = scale.ctx;
16389 if (circular) ctx.arc(scale.xCenter, scale.yCenter, radius, 0, (0, _helpersSegmentJs.T));
16390 else {
16391 var pointPosition = scale.getPointPosition(0, radius);
16392 ctx.moveTo(pointPosition.x, pointPosition.y);
16393 for(var i = 1; i < labelCount; i++){
16394 pointPosition = scale.getPointPosition(i, radius);
16395 ctx.lineTo(pointPosition.x, pointPosition.y);
16396 }
16397 }
16398 }
16399 function drawRadiusLine(scale, gridLineOpts, radius, labelCount) {
16400 var ctx = scale.ctx;
16401 var circular = gridLineOpts.circular;
16402 var color = gridLineOpts.color, lineWidth = gridLineOpts.lineWidth;
16403 if (!circular && !labelCount || !color || !lineWidth || radius < 0) return;
16404 ctx.save();
16405 ctx.strokeStyle = color;
16406 ctx.lineWidth = lineWidth;
16407 ctx.setLineDash(gridLineOpts.borderDash);
16408 ctx.lineDashOffset = gridLineOpts.borderDashOffset;
16409 ctx.beginPath();
16410 pathRadiusLine(scale, radius, circular, labelCount);
16411 ctx.closePath();
16412 ctx.stroke();
16413 ctx.restore();
16414 }
16415 function createPointLabelContext(parent, index74, label) {
16416 return (0, _helpersSegmentJs.h)(parent, {
16417 label: label,
16418 index: index74,
16419 type: "pointLabel"
16420 });
16421 }
16422 var RadialLinearScale = /*#__PURE__*/ function(LinearScaleBase1) {
16423 "use strict";
16424 (0, _inheritsJsDefault.default)(RadialLinearScale, LinearScaleBase1);
16425 var _super = (0, _createSuperJsDefault.default)(RadialLinearScale);
16426 function RadialLinearScale(cfg) {
16427 (0, _classCallCheckJsDefault.default)(this, RadialLinearScale);
16428 var _this;
16429 _this = _super.call(this, cfg);
16430 _this.xCenter = undefined;
16431 _this.yCenter = undefined;
16432 _this.drawingArea = undefined;
16433 _this._pointLabels = [];
16434 _this._pointLabelItems = [];
16435 return _this;
16436 }
16437 (0, _createClassJsDefault.default)(RadialLinearScale, [
16438 {
16439 key: "setDimensions",
16440 value: function setDimensions() {
16441 var padding = this._padding = (0, _helpersSegmentJs.D)(getTickBackdropHeight(this.options) / 2);
16442 var w = this.width = this.maxWidth - padding.width;
16443 var h = this.height = this.maxHeight - padding.height;
16444 this.xCenter = Math.floor(this.left + w / 2 + padding.left);
16445 this.yCenter = Math.floor(this.top + h / 2 + padding.top);
16446 this.drawingArea = Math.floor(Math.min(w, h) / 2);
16447 }
16448 },
16449 {
16450 key: "determineDataLimits",
16451 value: function determineDataLimits() {
16452 var ref = this.getMinMax(false), min = ref.min, max = ref.max;
16453 this.min = (0, _helpersSegmentJs.g)(min) && !isNaN(min) ? min : 0;
16454 this.max = (0, _helpersSegmentJs.g)(max) && !isNaN(max) ? max : 0;
16455 this.handleTickRangeOptions();
16456 }
16457 },
16458 {
16459 key: "computeTickLimit",
16460 value: function computeTickLimit() {
16461 return Math.ceil(this.drawingArea / getTickBackdropHeight(this.options));
16462 }
16463 },
16464 {
16465 key: "generateTickLabels",
16466 value: function generateTickLabels(ticks) {
16467 var _this = this;
16468 LinearScaleBase.prototype.generateTickLabels.call(this, ticks);
16469 this._pointLabels = this.getLabels().map(function(value, index75) {
16470 var label = (0, _helpersSegmentJs.Q)(_this.options.pointLabels.callback, [
16471 value,
16472 index75
16473 ], _this);
16474 return label || label === 0 ? label : "";
16475 }).filter(function(v, i) {
16476 return _this.chart.getDataVisibility(i);
16477 });
16478 }
16479 },
16480 {
16481 key: "fit",
16482 value: function fit() {
16483 var opts = this.options;
16484 if (opts.display && opts.pointLabels.display) fitWithPointLabels(this);
16485 else this.setCenterPoint(0, 0, 0, 0);
16486 }
16487 },
16488 {
16489 key: "setCenterPoint",
16490 value: function setCenterPoint(leftMovement, rightMovement, topMovement, bottomMovement) {
16491 this.xCenter += Math.floor((leftMovement - rightMovement) / 2);
16492 this.yCenter += Math.floor((topMovement - bottomMovement) / 2);
16493 this.drawingArea -= Math.min(this.drawingArea / 2, Math.max(leftMovement, rightMovement, topMovement, bottomMovement));
16494 }
16495 },
16496 {
16497 key: "getIndexAngle",
16498 value: function getIndexAngle(index76) {
16499 var angleMultiplier = (0, _helpersSegmentJs.T) / (this._pointLabels.length || 1);
16500 var startAngle = this.options.startAngle || 0;
16501 return (0, _helpersSegmentJs.ax)(index76 * angleMultiplier + (0, _helpersSegmentJs.t)(startAngle));
16502 }
16503 },
16504 {
16505 key: "getDistanceFromCenterForValue",
16506 value: function getDistanceFromCenterForValue(value) {
16507 if ((0, _helpersSegmentJs.k)(value)) return NaN;
16508 var scalingFactor = this.drawingArea / (this.max - this.min);
16509 if (this.options.reverse) return (this.max - value) * scalingFactor;
16510 return (value - this.min) * scalingFactor;
16511 }
16512 },
16513 {
16514 key: "getValueForDistanceFromCenter",
16515 value: function getValueForDistanceFromCenter(distance) {
16516 if ((0, _helpersSegmentJs.k)(distance)) return NaN;
16517 var scaledDistance = distance / (this.drawingArea / (this.max - this.min));
16518 return this.options.reverse ? this.max - scaledDistance : this.min + scaledDistance;
16519 }
16520 },
16521 {
16522 key: "getPointLabelContext",
16523 value: function getPointLabelContext(index77) {
16524 var pointLabels = this._pointLabels || [];
16525 if (index77 >= 0 && index77 < pointLabels.length) {
16526 var pointLabel = pointLabels[index77];
16527 return createPointLabelContext(this.getContext(), index77, pointLabel);
16528 }
16529 }
16530 },
16531 {
16532 key: "getPointPosition",
16533 value: function getPointPosition(index78, distanceFromCenter) {
16534 var additionalAngle = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0;
16535 var angle = this.getIndexAngle(index78) - (0, _helpersSegmentJs.H) + additionalAngle;
16536 return {
16537 x: Math.cos(angle) * distanceFromCenter + this.xCenter,
16538 y: Math.sin(angle) * distanceFromCenter + this.yCenter,
16539 angle: angle
16540 };
16541 }
16542 },
16543 {
16544 key: "getPointPositionForValue",
16545 value: function getPointPositionForValue(index79, value) {
16546 return this.getPointPosition(index79, this.getDistanceFromCenterForValue(value));
16547 }
16548 },
16549 {
16550 key: "getBasePosition",
16551 value: function getBasePosition(index80) {
16552 return this.getPointPositionForValue(index80 || 0, this.getBaseValue());
16553 }
16554 },
16555 {
16556 key: "getPointLabelPosition",
16557 value: function getPointLabelPosition(index81) {
16558 var _index = this._pointLabelItems[index81], left = _index.left, top = _index.top, right = _index.right, bottom = _index.bottom;
16559 return {
16560 left: left,
16561 top: top,
16562 right: right,
16563 bottom: bottom
16564 };
16565 }
16566 },
16567 {
16568 key: "drawBackground",
16569 value: function drawBackground() {
16570 var _options = this.options, backgroundColor = _options.backgroundColor, circular = _options.grid.circular;
16571 if (backgroundColor) {
16572 var ctx = this.ctx;
16573 ctx.save();
16574 ctx.beginPath();
16575 pathRadiusLine(this, this.getDistanceFromCenterForValue(this._endValue), circular, this._pointLabels.length);
16576 ctx.closePath();
16577 ctx.fillStyle = backgroundColor;
16578 ctx.fill();
16579 ctx.restore();
16580 }
16581 }
16582 },
16583 {
16584 key: "drawGrid",
16585 value: function drawGrid() {
16586 var _this = this;
16587 var ctx = this.ctx;
16588 var opts = this.options;
16589 var angleLines = opts.angleLines, grid = opts.grid;
16590 var labelCount = this._pointLabels.length;
16591 var i, offset, position;
16592 if (opts.pointLabels.display) drawPointLabels(this, labelCount);
16593 if (grid.display) this.ticks.forEach(function(tick, index82) {
16594 if (index82 !== 0) {
16595 offset = _this.getDistanceFromCenterForValue(tick.value);
16596 var optsAtIndex = grid.setContext(_this.getContext(index82 - 1));
16597 drawRadiusLine(_this, optsAtIndex, offset, labelCount);
16598 }
16599 });
16600 if (angleLines.display) {
16601 ctx.save();
16602 for(i = labelCount - 1; i >= 0; i--){
16603 var optsAtIndex1 = angleLines.setContext(this.getPointLabelContext(i));
16604 var color = optsAtIndex1.color, lineWidth = optsAtIndex1.lineWidth;
16605 if (!lineWidth || !color) continue;
16606 ctx.lineWidth = lineWidth;
16607 ctx.strokeStyle = color;
16608 ctx.setLineDash(optsAtIndex1.borderDash);
16609 ctx.lineDashOffset = optsAtIndex1.borderDashOffset;
16610 offset = this.getDistanceFromCenterForValue(opts.ticks.reverse ? this.min : this.max);
16611 position = this.getPointPosition(i, offset);
16612 ctx.beginPath();
16613 ctx.moveTo(this.xCenter, this.yCenter);
16614 ctx.lineTo(position.x, position.y);
16615 ctx.stroke();
16616 }
16617 ctx.restore();
16618 }
16619 }
16620 },
16621 {
16622 key: "drawBorder",
16623 value: function drawBorder() {}
16624 },
16625 {
16626 key: "drawLabels",
16627 value: function drawLabels() {
16628 var _this = this;
16629 var ctx = this.ctx;
16630 var opts = this.options;
16631 var tickOpts = opts.ticks;
16632 if (!tickOpts.display) return;
16633 var startAngle = this.getIndexAngle(0);
16634 var offset, width;
16635 ctx.save();
16636 ctx.translate(this.xCenter, this.yCenter);
16637 ctx.rotate(startAngle);
16638 ctx.textAlign = "center";
16639 ctx.textBaseline = "middle";
16640 this.ticks.forEach(function(tick, index83) {
16641 if (index83 === 0 && !opts.reverse) return;
16642 var optsAtIndex = tickOpts.setContext(_this.getContext(index83));
16643 var tickFont = (0, _helpersSegmentJs.$)(optsAtIndex.font);
16644 offset = _this.getDistanceFromCenterForValue(_this.ticks[index83].value);
16645 if (optsAtIndex.showLabelBackdrop) {
16646 ctx.font = tickFont.string;
16647 width = ctx.measureText(tick.label).width;
16648 ctx.fillStyle = optsAtIndex.backdropColor;
16649 var padding = (0, _helpersSegmentJs.D)(optsAtIndex.backdropPadding);
16650 ctx.fillRect(-width / 2 - padding.left, -offset - tickFont.size / 2 - padding.top, width + padding.width, tickFont.size + padding.height);
16651 }
16652 (0, _helpersSegmentJs.Y)(ctx, tick.label, 0, -offset, tickFont, {
16653 color: optsAtIndex.color
16654 });
16655 });
16656 ctx.restore();
16657 }
16658 },
16659 {
16660 key: "drawTitle",
16661 value: function drawTitle() {}
16662 }
16663 ]);
16664 return RadialLinearScale;
16665 }(LinearScaleBase);
16666 RadialLinearScale.id = "radialLinear";
16667 RadialLinearScale.defaults = {
16668 display: true,
16669 animate: true,
16670 position: "chartArea",
16671 angleLines: {
16672 display: true,
16673 lineWidth: 1,
16674 borderDash: [],
16675 borderDashOffset: 0.0
16676 },
16677 grid: {
16678 circular: false
16679 },
16680 startAngle: 0,
16681 ticks: {
16682 showLabelBackdrop: true,
16683 callback: Ticks.formatters.numeric
16684 },
16685 pointLabels: {
16686 backdropColor: undefined,
16687 backdropPadding: 2,
16688 display: true,
16689 font: {
16690 size: 10
16691 },
16692 callback: function(label) {
16693 return label;
16694 },
16695 padding: 5,
16696 centerPointLabels: false
16697 }
16698 };
16699 RadialLinearScale.defaultRoutes = {
16700 "angleLines.color": "borderColor",
16701 "pointLabels.color": "color",
16702 "ticks.color": "color"
16703 };
16704 RadialLinearScale.descriptors = {
16705 angleLines: {
16706 _fallback: "grid"
16707 }
16708 };
16709 var INTERVALS = {
16710 millisecond: {
16711 common: true,
16712 size: 1,
16713 steps: 1000
16714 },
16715 second: {
16716 common: true,
16717 size: 1000,
16718 steps: 60
16719 },
16720 minute: {
16721 common: true,
16722 size: 60000,
16723 steps: 60
16724 },
16725 hour: {
16726 common: true,
16727 size: 3600000,
16728 steps: 24
16729 },
16730 day: {
16731 common: true,
16732 size: 86400000,
16733 steps: 30
16734 },
16735 week: {
16736 common: false,
16737 size: 604800000,
16738 steps: 4
16739 },
16740 month: {
16741 common: true,
16742 size: 2.628e9,
16743 steps: 12
16744 },
16745 quarter: {
16746 common: false,
16747 size: 7.884e9,
16748 steps: 4
16749 },
16750 year: {
16751 common: true,
16752 size: 3.154e10
16753 }
16754 };
16755 var UNITS = Object.keys(INTERVALS);
16756 function sorter(a, b) {
16757 return a - b;
16758 }
16759 function parse(scale, input) {
16760 if ((0, _helpersSegmentJs.k)(input)) return null;
16761 var adapter = scale._adapter;
16762 var __parseOpts = scale._parseOpts, parser = __parseOpts.parser, round = __parseOpts.round, isoWeekday = __parseOpts.isoWeekday;
16763 var value = input;
16764 if (typeof parser === "function") value = parser(value);
16765 if (!(0, _helpersSegmentJs.g)(value)) value = typeof parser === "string" ? adapter.parse(value, parser) : adapter.parse(value);
16766 if (value === null) return null;
16767 if (round) value = round === "week" && ((0, _helpersSegmentJs.q)(isoWeekday) || isoWeekday === true) ? adapter.startOf(value, "isoWeek", isoWeekday) : adapter.startOf(value, round);
16768 return +value;
16769 }
16770 function determineUnitForAutoTicks(minUnit, min, max, capacity) {
16771 var ilen = UNITS.length;
16772 for(var i = UNITS.indexOf(minUnit); i < ilen - 1; ++i){
16773 var interval = INTERVALS[UNITS[i]];
16774 var factor = interval.steps ? interval.steps : Number.MAX_SAFE_INTEGER;
16775 if (interval.common && Math.ceil((max - min) / (factor * interval.size)) <= capacity) return UNITS[i];
16776 }
16777 return UNITS[ilen - 1];
16778 }
16779 function determineUnitForFormatting(scale, numTicks, minUnit, min, max) {
16780 for(var i = UNITS.length - 1; i >= UNITS.indexOf(minUnit); i--){
16781 var unit = UNITS[i];
16782 if (INTERVALS[unit].common && scale._adapter.diff(max, min, unit) >= numTicks - 1) return unit;
16783 }
16784 return UNITS[minUnit ? UNITS.indexOf(minUnit) : 0];
16785 }
16786 function determineMajorUnit(unit) {
16787 for(var i = UNITS.indexOf(unit) + 1, ilen = UNITS.length; i < ilen; ++i){
16788 if (INTERVALS[UNITS[i]].common) return UNITS[i];
16789 }
16790 }
16791 function addTick(ticks, time, timestamps) {
16792 if (!timestamps) ticks[time] = true;
16793 else if (timestamps.length) {
16794 var ref = (0, _helpersSegmentJs.aL)(timestamps, time), lo = ref.lo, hi = ref.hi;
16795 var timestamp = timestamps[lo] >= time ? timestamps[lo] : timestamps[hi];
16796 ticks[timestamp] = true;
16797 }
16798 }
16799 function setMajorTicks(scale, ticks, map1, majorUnit) {
16800 var adapter = scale._adapter;
16801 var first = +adapter.startOf(ticks[0].value, majorUnit);
16802 var last = ticks[ticks.length - 1].value;
16803 var major, index84;
16804 for(major = first; major <= last; major = +adapter.add(major, 1, majorUnit)){
16805 index84 = map1[major];
16806 if (index84 >= 0) ticks[index84].major = true;
16807 }
16808 return ticks;
16809 }
16810 function ticksFromTimestamps(scale, values, majorUnit) {
16811 var ticks = [];
16812 var map2 = {};
16813 var ilen = values.length;
16814 var i, value;
16815 for(i = 0; i < ilen; ++i){
16816 value = values[i];
16817 map2[value] = i;
16818 ticks.push({
16819 value: value,
16820 major: false
16821 });
16822 }
16823 return ilen === 0 || !majorUnit ? ticks : setMajorTicks(scale, ticks, map2, majorUnit);
16824 }
16825 var TimeScale = /*#__PURE__*/ function(Scale) {
16826 "use strict";
16827 (0, _inheritsJsDefault.default)(TimeScale, Scale);
16828 var _super = (0, _createSuperJsDefault.default)(TimeScale);
16829 function TimeScale(props) {
16830 (0, _classCallCheckJsDefault.default)(this, TimeScale);
16831 var _this;
16832 _this = _super.call(this, props);
16833 _this._cache = {
16834 data: [],
16835 labels: [],
16836 all: []
16837 };
16838 _this._unit = "day";
16839 _this._majorUnit = undefined;
16840 _this._offsets = {};
16841 _this._normalized = false;
16842 _this._parseOpts = undefined;
16843 return _this;
16844 }
16845 (0, _createClassJsDefault.default)(TimeScale, [
16846 {
16847 key: "init",
16848 value: function init(scaleOpts, opts) {
16849 var time = scaleOpts.time || (scaleOpts.time = {});
16850 var adapter = this._adapter = new adapters._date(scaleOpts.adapters.date);
16851 (0, _helpersSegmentJs.aa)(time.displayFormats, adapter.formats());
16852 this._parseOpts = {
16853 parser: time.parser,
16854 round: time.round,
16855 isoWeekday: time.isoWeekday
16856 };
16857 (0, _getJsDefault.default)((0, _getPrototypeOfJsDefault.default)(TimeScale.prototype), "init", this).call(this, scaleOpts);
16858 this._normalized = opts.normalized;
16859 }
16860 },
16861 {
16862 key: "parse",
16863 value: function parse1(raw, index) {
16864 if (raw === undefined) return null;
16865 return parse(this, raw);
16866 }
16867 },
16868 {
16869 key: "beforeLayout",
16870 value: function beforeLayout() {
16871 (0, _getJsDefault.default)((0, _getPrototypeOfJsDefault.default)(TimeScale.prototype), "beforeLayout", this).call(this);
16872 this._cache = {
16873 data: [],
16874 labels: [],
16875 all: []
16876 };
16877 }
16878 },
16879 {
16880 key: "determineDataLimits",
16881 value: function determineDataLimits() {
16882 var _applyBounds = function _applyBounds(bounds) {
16883 if (!minDefined && !isNaN(bounds.min)) min = Math.min(min, bounds.min);
16884 if (!maxDefined && !isNaN(bounds.max)) max = Math.max(max, bounds.max);
16885 };
16886 var options = this.options;
16887 var adapter = this._adapter;
16888 var unit = options.time.unit || "day";
16889 var ref = this.getUserBounds(), min = ref.min, max = ref.max, minDefined = ref.minDefined, maxDefined = ref.maxDefined;
16890 if (!minDefined || !maxDefined) {
16891 _applyBounds(this._getLabelBounds());
16892 if (options.bounds !== "ticks" || options.ticks.source !== "labels") _applyBounds(this.getMinMax(false));
16893 }
16894 min = (0, _helpersSegmentJs.g)(min) && !isNaN(min) ? min : +adapter.startOf(Date.now(), unit);
16895 max = (0, _helpersSegmentJs.g)(max) && !isNaN(max) ? max : +adapter.endOf(Date.now(), unit) + 1;
16896 this.min = Math.min(min, max - 1);
16897 this.max = Math.max(min + 1, max);
16898 }
16899 },
16900 {
16901 key: "_getLabelBounds",
16902 value: function _getLabelBounds() {
16903 var arr = this.getLabelTimestamps();
16904 var min = Number.POSITIVE_INFINITY;
16905 var max = Number.NEGATIVE_INFINITY;
16906 if (arr.length) {
16907 min = arr[0];
16908 max = arr[arr.length - 1];
16909 }
16910 return {
16911 min: min,
16912 max: max
16913 };
16914 }
16915 },
16916 {
16917 key: "buildTicks",
16918 value: function buildTicks() {
16919 var options = this.options;
16920 var timeOpts = options.time;
16921 var tickOpts = options.ticks;
16922 var timestamps = tickOpts.source === "labels" ? this.getLabelTimestamps() : this._generate();
16923 if (options.bounds === "ticks" && timestamps.length) {
16924 this.min = this._userMin || timestamps[0];
16925 this.max = this._userMax || timestamps[timestamps.length - 1];
16926 }
16927 var min = this.min;
16928 var max = this.max;
16929 var ticks = (0, _helpersSegmentJs.aK)(timestamps, min, max);
16930 this._unit = timeOpts.unit || (tickOpts.autoSkip ? determineUnitForAutoTicks(timeOpts.minUnit, this.min, this.max, this._getLabelCapacity(min)) : determineUnitForFormatting(this, ticks.length, timeOpts.minUnit, this.min, this.max));
16931 this._majorUnit = !tickOpts.major.enabled || this._unit === "year" ? undefined : determineMajorUnit(this._unit);
16932 this.initOffsets(timestamps);
16933 if (options.reverse) ticks.reverse();
16934 return ticksFromTimestamps(this, ticks, this._majorUnit);
16935 }
16936 },
16937 {
16938 key: "afterAutoSkip",
16939 value: function afterAutoSkip() {
16940 if (this.options.offsetAfterAutoskip) this.initOffsets(this.ticks.map(function(tick) {
16941 return +tick.value;
16942 }));
16943 }
16944 },
16945 {
16946 key: "initOffsets",
16947 value: function initOffsets(timestamps) {
16948 var start = 0;
16949 var end = 0;
16950 var first, last;
16951 if (this.options.offset && timestamps.length) {
16952 first = this.getDecimalForValue(timestamps[0]);
16953 if (timestamps.length === 1) start = 1 - first;
16954 else start = (this.getDecimalForValue(timestamps[1]) - first) / 2;
16955 last = this.getDecimalForValue(timestamps[timestamps.length - 1]);
16956 if (timestamps.length === 1) end = last;
16957 else end = (last - this.getDecimalForValue(timestamps[timestamps.length - 2])) / 2;
16958 }
16959 var limit = timestamps.length < 3 ? 0.5 : 0.25;
16960 start = (0, _helpersSegmentJs.w)(start, 0, limit);
16961 end = (0, _helpersSegmentJs.w)(end, 0, limit);
16962 this._offsets = {
16963 start: start,
16964 end: end,
16965 factor: 1 / (start + 1 + end)
16966 };
16967 }
16968 },
16969 {
16970 key: "_generate",
16971 value: function _generate() {
16972 var adapter = this._adapter;
16973 var min = this.min;
16974 var max = this.max;
16975 var options = this.options;
16976 var timeOpts = options.time;
16977 var minor = timeOpts.unit || determineUnitForAutoTicks(timeOpts.minUnit, min, max, this._getLabelCapacity(min));
16978 var stepSize = (0, _helpersSegmentJs.v)(timeOpts.stepSize, 1);
16979 var weekday = minor === "week" ? timeOpts.isoWeekday : false;
16980 var hasWeekday = (0, _helpersSegmentJs.q)(weekday) || weekday === true;
16981 var ticks = {};
16982 var first = min;
16983 var time, count;
16984 if (hasWeekday) first = +adapter.startOf(first, "isoWeek", weekday);
16985 first = +adapter.startOf(first, hasWeekday ? "day" : minor);
16986 if (adapter.diff(max, min, minor) > 100000 * stepSize) throw new Error(min + " and " + max + " are too far apart with stepSize of " + stepSize + " " + minor);
16987 var timestamps = options.ticks.source === "data" && this.getDataTimestamps();
16988 for(time = first, count = 0; time < max; time = +adapter.add(time, stepSize, minor), count++)addTick(ticks, time, timestamps);
16989 if (time === max || options.bounds === "ticks" || count === 1) addTick(ticks, time, timestamps);
16990 return Object.keys(ticks).sort(function(a, b) {
16991 return a - b;
16992 }).map(function(x) {
16993 return +x;
16994 });
16995 }
16996 },
16997 {
16998 key: "getLabelForValue",
16999 value: function getLabelForValue(value) {
17000 var adapter = this._adapter;
17001 var timeOpts = this.options.time;
17002 if (timeOpts.tooltipFormat) return adapter.format(value, timeOpts.tooltipFormat);
17003 return adapter.format(value, timeOpts.displayFormats.datetime);
17004 }
17005 },
17006 {
17007 key: "_tickFormatFunction",
17008 value: function _tickFormatFunction(time, index85, ticks, format) {
17009 var options = this.options;
17010 var formats = options.time.displayFormats;
17011 var unit = this._unit;
17012 var majorUnit = this._majorUnit;
17013 var minorFormat = unit && formats[unit];
17014 var majorFormat = majorUnit && formats[majorUnit];
17015 var tick = ticks[index85];
17016 var major = majorUnit && majorFormat && tick && tick.major;
17017 var label = this._adapter.format(time, format || (major ? majorFormat : minorFormat));
17018 var formatter = options.ticks.callback;
17019 return formatter ? (0, _helpersSegmentJs.Q)(formatter, [
17020 label,
17021 index85,
17022 ticks
17023 ], this) : label;
17024 }
17025 },
17026 {
17027 key: "generateTickLabels",
17028 value: function generateTickLabels(ticks) {
17029 var i, ilen, tick;
17030 for(i = 0, ilen = ticks.length; i < ilen; ++i){
17031 tick = ticks[i];
17032 tick.label = this._tickFormatFunction(tick.value, i, ticks);
17033 }
17034 }
17035 },
17036 {
17037 key: "getDecimalForValue",
17038 value: function getDecimalForValue(value) {
17039 return value === null ? NaN : (value - this.min) / (this.max - this.min);
17040 }
17041 },
17042 {
17043 key: "getPixelForValue",
17044 value: function getPixelForValue(value) {
17045 var offsets = this._offsets;
17046 var pos = this.getDecimalForValue(value);
17047 return this.getPixelForDecimal((offsets.start + pos) * offsets.factor);
17048 }
17049 },
17050 {
17051 key: "getValueForPixel",
17052 value: function getValueForPixel(pixel) {
17053 var offsets = this._offsets;
17054 var pos = this.getDecimalForPixel(pixel) / offsets.factor - offsets.end;
17055 return this.min + pos * (this.max - this.min);
17056 }
17057 },
17058 {
17059 key: "_getLabelSize",
17060 value: function _getLabelSize(label) {
17061 var ticksOpts = this.options.ticks;
17062 var tickLabelWidth = this.ctx.measureText(label).width;
17063 var angle = (0, _helpersSegmentJs.t)(this.isHorizontal() ? ticksOpts.maxRotation : ticksOpts.minRotation);
17064 var cosRotation = Math.cos(angle);
17065 var sinRotation = Math.sin(angle);
17066 var tickFontSize = this._resolveTickFontOptions(0).size;
17067 return {
17068 w: tickLabelWidth * cosRotation + tickFontSize * sinRotation,
17069 h: tickLabelWidth * sinRotation + tickFontSize * cosRotation
17070 };
17071 }
17072 },
17073 {
17074 key: "_getLabelCapacity",
17075 value: function _getLabelCapacity(exampleTime) {
17076 var timeOpts = this.options.time;
17077 var displayFormats = timeOpts.displayFormats;
17078 var format = displayFormats[timeOpts.unit] || displayFormats.millisecond;
17079 var exampleLabel = this._tickFormatFunction(exampleTime, 0, ticksFromTimestamps(this, [
17080 exampleTime
17081 ], this._majorUnit), format);
17082 var size = this._getLabelSize(exampleLabel);
17083 var capacity = Math.floor(this.isHorizontal() ? this.width / size.w : this.height / size.h) - 1;
17084 return capacity > 0 ? capacity : 1;
17085 }
17086 },
17087 {
17088 key: "getDataTimestamps",
17089 value: function getDataTimestamps() {
17090 var timestamps = this._cache.data || [];
17091 var i, ilen;
17092 if (timestamps.length) return timestamps;
17093 var metas = this.getMatchingVisibleMetas();
17094 if (this._normalized && metas.length) return this._cache.data = metas[0].controller.getAllParsedValues(this);
17095 for(i = 0, ilen = metas.length; i < ilen; ++i)timestamps = timestamps.concat(metas[i].controller.getAllParsedValues(this));
17096 return this._cache.data = this.normalize(timestamps);
17097 }
17098 },
17099 {
17100 key: "getLabelTimestamps",
17101 value: function getLabelTimestamps() {
17102 var timestamps = this._cache.labels || [];
17103 var i, ilen;
17104 if (timestamps.length) return timestamps;
17105 var labels = this.getLabels();
17106 for(i = 0, ilen = labels.length; i < ilen; ++i)timestamps.push(parse(this, labels[i]));
17107 return this._cache.labels = this._normalized ? timestamps : this.normalize(timestamps);
17108 }
17109 },
17110 {
17111 key: "normalize",
17112 value: function normalize(values) {
17113 return (0, _helpersSegmentJs._)(values.sort(sorter));
17114 }
17115 }
17116 ]);
17117 return TimeScale;
17118 }(Scale);
17119 TimeScale.id = "time";
17120 TimeScale.defaults = {
17121 bounds: "data",
17122 adapters: {},
17123 time: {
17124 parser: false,
17125 unit: false,
17126 round: false,
17127 isoWeekday: false,
17128 minUnit: "millisecond",
17129 displayFormats: {}
17130 },
17131 ticks: {
17132 source: "auto",
17133 major: {
17134 enabled: false
17135 }
17136 }
17137 };
17138 function interpolate(table, val, reverse) {
17139 var lo = 0;
17140 var hi = table.length - 1;
17141 var prevSource, nextSource, prevTarget, nextTarget;
17142 if (reverse) {
17143 var ref;
17144 if (val >= table[lo].pos && val <= table[hi].pos) ref = (0, _helpersSegmentJs.x)(table, "pos", val), lo = ref.lo, hi = ref.hi, ref;
17145 var ref16;
17146 ref16 = table[lo], prevSource = ref16.pos, prevTarget = ref16.time, ref16;
17147 var ref17;
17148 ref17 = table[hi], nextSource = ref17.pos, nextTarget = ref17.time, ref17;
17149 } else {
17150 var ref18;
17151 if (val >= table[lo].time && val <= table[hi].time) ref18 = (0, _helpersSegmentJs.x)(table, "time", val), lo = ref18.lo, hi = ref18.hi, ref18;
17152 var ref19;
17153 ref19 = table[lo], prevSource = ref19.time, prevTarget = ref19.pos, ref19;
17154 var ref20;
17155 ref20 = table[hi], nextSource = ref20.time, nextTarget = ref20.pos, ref20;
17156 }
17157 var span = nextSource - prevSource;
17158 return span ? prevTarget + (nextTarget - prevTarget) * (val - prevSource) / span : prevTarget;
17159 }
17160 var TimeSeriesScale = /*#__PURE__*/ function(TimeScale) {
17161 "use strict";
17162 (0, _inheritsJsDefault.default)(TimeSeriesScale, TimeScale);
17163 var _super = (0, _createSuperJsDefault.default)(TimeSeriesScale);
17164 function TimeSeriesScale(props) {
17165 (0, _classCallCheckJsDefault.default)(this, TimeSeriesScale);
17166 var _this;
17167 _this = _super.call(this, props);
17168 _this._table = [];
17169 _this._minPos = undefined;
17170 _this._tableRange = undefined;
17171 return _this;
17172 }
17173 (0, _createClassJsDefault.default)(TimeSeriesScale, [
17174 {
17175 key: "initOffsets",
17176 value: function initOffsets() {
17177 var timestamps = this._getTimestampsForTable();
17178 var table = this._table = this.buildLookupTable(timestamps);
17179 this._minPos = interpolate(table, this.min);
17180 this._tableRange = interpolate(table, this.max) - this._minPos;
17181 (0, _getJsDefault.default)((0, _getPrototypeOfJsDefault.default)(TimeSeriesScale.prototype), "initOffsets", this).call(this, timestamps);
17182 }
17183 },
17184 {
17185 key: "buildLookupTable",
17186 value: function buildLookupTable(timestamps) {
17187 var ref = this, min = ref.min, max = ref.max;
17188 var items = [];
17189 var table = [];
17190 var i, ilen, prev, curr, next;
17191 for(i = 0, ilen = timestamps.length; i < ilen; ++i){
17192 curr = timestamps[i];
17193 if (curr >= min && curr <= max) items.push(curr);
17194 }
17195 if (items.length < 2) return [
17196 {
17197 time: min,
17198 pos: 0
17199 },
17200 {
17201 time: max,
17202 pos: 1
17203 }
17204 ];
17205 for(i = 0, ilen = items.length; i < ilen; ++i){
17206 next = items[i + 1];
17207 prev = items[i - 1];
17208 curr = items[i];
17209 if (Math.round((next + prev) / 2) !== curr) table.push({
17210 time: curr,
17211 pos: i / (ilen - 1)
17212 });
17213 }
17214 return table;
17215 }
17216 },
17217 {
17218 key: "_getTimestampsForTable",
17219 value: function _getTimestampsForTable() {
17220 var timestamps = this._cache.all || [];
17221 if (timestamps.length) return timestamps;
17222 var data = this.getDataTimestamps();
17223 var label = this.getLabelTimestamps();
17224 if (data.length && label.length) timestamps = this.normalize(data.concat(label));
17225 else timestamps = data.length ? data : label;
17226 timestamps = this._cache.all = timestamps;
17227 return timestamps;
17228 }
17229 },
17230 {
17231 key: "getDecimalForValue",
17232 value: function getDecimalForValue(value) {
17233 return (interpolate(this._table, value) - this._minPos) / this._tableRange;
17234 }
17235 },
17236 {
17237 key: "getValueForPixel",
17238 value: function getValueForPixel(pixel) {
17239 var offsets = this._offsets;
17240 var decimal = this.getDecimalForPixel(pixel) / offsets.factor - offsets.end;
17241 return interpolate(this._table, decimal * this._tableRange + this._minPos, true);
17242 }
17243 }
17244 ]);
17245 return TimeSeriesScale;
17246 }(TimeScale);
17247 TimeSeriesScale.id = "timeseries";
17248 TimeSeriesScale.defaults = TimeScale.defaults;
17249 var scales = /*#__PURE__*/ Object.freeze({
17250 __proto__: null,
17251 CategoryScale: CategoryScale,
17252 LinearScale: LinearScale,
17253 LogarithmicScale: LogarithmicScale,
17254 RadialLinearScale: RadialLinearScale,
17255 TimeScale: TimeScale,
17256 TimeSeriesScale: TimeSeriesScale
17257 });
17258 var registerables = [
17259 controllers,
17260 elements,
17261 plugins,
17262 scales,
17263 ];
17264
17265 },{"@swc/helpers/lib/_assert_this_initialized.js":"l7nF8","@swc/helpers/lib/_class_call_check.js":"gNxF8","@swc/helpers/lib/_create_class.js":"iyoaN","@swc/helpers/lib/_define_property.js":"6IXzf","@swc/helpers/lib/_get.js":"5g4pb","@swc/helpers/lib/_get_prototype_of.js":"7Gb6H","@swc/helpers/lib/_inherits.js":"atvDk","@swc/helpers/lib/_object_spread.js":"d5EJT","@swc/helpers/lib/_sliced_to_array.js":"4IWLM","@swc/helpers/lib/_to_consumable_array.js":"cccKv","@swc/helpers/lib/_type_of.js":"9FF45","@swc/helpers/lib/_wrap_native_super.js":"4U7ja","@swc/helpers/lib/_create_super.js":"5rW3S","./chunks/helpers.segment.js":"eXwLh","@parcel/transformer-js/src/esmodule-helpers.js":"jIm8e"}],"d5EJT":[function(require,module,exports) {
17266 "use strict";
17267 Object.defineProperty(exports, "__esModule", {
17268 value: true
17269 });
17270 exports.default = _objectSpread;
17271 var _defineProperty = _interopRequireDefault(require("./_define_property"));
17272 function _objectSpread(target) {
17273 for(var i = 1; i < arguments.length; i++){
17274 var source = arguments[i] != null ? arguments[i] : {};
17275 var ownKeys = Object.keys(source);
17276 if (typeof Object.getOwnPropertySymbols === "function") ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
17277 return Object.getOwnPropertyDescriptor(source, sym).enumerable;
17278 }));
17279 ownKeys.forEach(function(key) {
17280 _defineProperty.default(target, key, source[key]);
17281 });
17282 }
17283 return target;
17284 }
17285 function _interopRequireDefault(obj) {
17286 return obj && obj.__esModule ? obj : {
17287 default: obj
17288 };
17289 }
17290
17291 },{"./_define_property":"6IXzf"}],"4U7ja":[function(require,module,exports) {
17292 "use strict";
17293 Object.defineProperty(exports, "__esModule", {
17294 value: true
17295 });
17296 exports.default = _wrapNativeSuper;
17297 var _construct = _interopRequireDefault(require("./_construct"));
17298 var _isNativeFunction = _interopRequireDefault(require("./_is_native_function"));
17299 var _getPrototypeOf = _interopRequireDefault(require("./_get_prototype_of"));
17300 var _setPrototypeOf = _interopRequireDefault(require("./_set_prototype_of"));
17301 function _wrapNativeSuper(Class) {
17302 return wrapNativeSuper(Class);
17303 }
17304 function _interopRequireDefault(obj) {
17305 return obj && obj.__esModule ? obj : {
17306 default: obj
17307 };
17308 }
17309 function wrapNativeSuper(Class1) {
17310 var _cache = typeof Map === "function" ? new Map() : undefined;
17311 wrapNativeSuper = function wrapNativeSuper(Class) {
17312 if (Class === null || !_isNativeFunction.default(Class)) return Class;
17313 if (typeof Class !== "function") throw new TypeError("Super expression must either be null or a function");
17314 if (typeof _cache !== "undefined") {
17315 if (_cache.has(Class)) return _cache.get(Class);
17316 _cache.set(Class, Wrapper);
17317 }
17318 function Wrapper() {
17319 return _construct.default(Class, arguments, _getPrototypeOf.default(this).constructor);
17320 }
17321 Wrapper.prototype = Object.create(Class.prototype, {
17322 constructor: {
17323 value: Wrapper,
17324 enumerable: false,
17325 writable: true,
17326 configurable: true
17327 }
17328 });
17329 return _setPrototypeOf.default(Wrapper, Class);
17330 };
17331 return wrapNativeSuper(Class1);
17332 }
17333
17334 },{"./_construct":"597Bk","./_is_native_function":"9evrd","./_get_prototype_of":"7Gb6H","./_set_prototype_of":"1rATD"}],"597Bk":[function(require,module,exports) {
17335 "use strict";
17336 Object.defineProperty(exports, "__esModule", {
17337 value: true
17338 });
17339 exports.default = _construct;
17340 var _setPrototypeOf = _interopRequireDefault(require("./_set_prototype_of"));
17341 function _construct(Parent, args, Class) {
17342 return construct.apply(null, arguments);
17343 }
17344 function _interopRequireDefault(obj) {
17345 return obj && obj.__esModule ? obj : {
17346 default: obj
17347 };
17348 }
17349 function isNativeReflectConstruct() {
17350 if (typeof Reflect === "undefined" || !Reflect.construct) return false;
17351 if (Reflect.construct.sham) return false;
17352 if (typeof Proxy === "function") return true;
17353 try {
17354 Date.prototype.toString.call(Reflect.construct(Date, [], function() {}));
17355 return true;
17356 } catch (e) {
17357 return false;
17358 }
17359 }
17360 function construct(Parent1, args1, Class1) {
17361 if (isNativeReflectConstruct()) construct = Reflect.construct;
17362 else construct = function construct(Parent, args, Class) {
17363 var a = [
17364 null
17365 ];
17366 a.push.apply(a, args);
17367 var Constructor = Function.bind.apply(Parent, a);
17368 var instance = new Constructor();
17369 if (Class) _setPrototypeOf.default(instance, Class.prototype);
17370 return instance;
17371 };
17372 return construct.apply(null, arguments);
17373 }
17374
17375 },{"./_set_prototype_of":"1rATD"}],"9evrd":[function(require,module,exports) {
17376 "use strict";
17377 Object.defineProperty(exports, "__esModule", {
17378 value: true
17379 });
17380 exports.default = _isNativeFunction;
17381 function _isNativeFunction(fn) {
17382 return Function.toString.call(fn).indexOf("[native code]") !== -1;
17383 }
17384
17385 },{}],"eXwLh":[function(require,module,exports) {
17386 var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
17387 parcelHelpers.defineInteropFlag(exports);
17388 parcelHelpers.export(exports, "$", function() {
17389 return toFont;
17390 });
17391 parcelHelpers.export(exports, "A", function() {
17392 return _rlookupByKey;
17393 });
17394 parcelHelpers.export(exports, "B", function() {
17395 return _isPointInArea;
17396 });
17397 parcelHelpers.export(exports, "C", function() {
17398 return getAngleFromPoint;
17399 });
17400 parcelHelpers.export(exports, "D", function() {
17401 return toPadding;
17402 });
17403 parcelHelpers.export(exports, "E", function() {
17404 return each;
17405 });
17406 parcelHelpers.export(exports, "F", function() {
17407 return getMaximumSize;
17408 });
17409 parcelHelpers.export(exports, "G", function() {
17410 return _getParentNode;
17411 });
17412 parcelHelpers.export(exports, "H", function() {
17413 return HALF_PI;
17414 });
17415 parcelHelpers.export(exports, "I", function() {
17416 return readUsedSize;
17417 });
17418 parcelHelpers.export(exports, "J", function() {
17419 return throttled;
17420 });
17421 parcelHelpers.export(exports, "K", function() {
17422 return supportsEventListenerOptions;
17423 });
17424 parcelHelpers.export(exports, "L", function() {
17425 return _isDomSupported;
17426 });
17427 parcelHelpers.export(exports, "M", function() {
17428 return log10;
17429 });
17430 parcelHelpers.export(exports, "N", function() {
17431 return _factorize;
17432 });
17433 parcelHelpers.export(exports, "O", function() {
17434 return finiteOrDefault;
17435 });
17436 parcelHelpers.export(exports, "P", function() {
17437 return PI;
17438 });
17439 parcelHelpers.export(exports, "Q", function() {
17440 return callback;
17441 });
17442 parcelHelpers.export(exports, "R", function() {
17443 return _addGrace;
17444 });
17445 parcelHelpers.export(exports, "S", function() {
17446 return toDegrees;
17447 });
17448 parcelHelpers.export(exports, "T", function() {
17449 return TAU;
17450 });
17451 parcelHelpers.export(exports, "U", function() {
17452 return _measureText;
17453 });
17454 parcelHelpers.export(exports, "V", function() {
17455 return _int16Range;
17456 });
17457 parcelHelpers.export(exports, "W", function() {
17458 return _alignPixel;
17459 });
17460 parcelHelpers.export(exports, "X", function() {
17461 return clipArea;
17462 });
17463 parcelHelpers.export(exports, "Y", function() {
17464 return renderText;
17465 });
17466 parcelHelpers.export(exports, "Z", function() {
17467 return unclipArea;
17468 });
17469 parcelHelpers.export(exports, "_", function() {
17470 return _arrayUnique;
17471 });
17472 parcelHelpers.export(exports, "a", function() {
17473 return resolve;
17474 });
17475 parcelHelpers.export(exports, "a$", function() {
17476 return QUARTER_PI;
17477 });
17478 parcelHelpers.export(exports, "a0", function() {
17479 return _toLeftRightCenter;
17480 });
17481 parcelHelpers.export(exports, "a1", function() {
17482 return _alignStartEnd;
17483 });
17484 parcelHelpers.export(exports, "a2", function() {
17485 return overrides;
17486 });
17487 parcelHelpers.export(exports, "a3", function() {
17488 return merge;
17489 });
17490 parcelHelpers.export(exports, "a4", function() {
17491 return _capitalize;
17492 });
17493 parcelHelpers.export(exports, "a5", function() {
17494 return descriptors;
17495 });
17496 parcelHelpers.export(exports, "a6", function() {
17497 return isFunction;
17498 });
17499 parcelHelpers.export(exports, "a7", function() {
17500 return _attachContext;
17501 });
17502 parcelHelpers.export(exports, "a8", function() {
17503 return _createResolver;
17504 });
17505 parcelHelpers.export(exports, "a9", function() {
17506 return _descriptors;
17507 });
17508 parcelHelpers.export(exports, "aA", function() {
17509 return _textX;
17510 });
17511 parcelHelpers.export(exports, "aB", function() {
17512 return restoreTextDirection;
17513 });
17514 parcelHelpers.export(exports, "aC", function() {
17515 return noop;
17516 });
17517 parcelHelpers.export(exports, "aD", function() {
17518 return distanceBetweenPoints;
17519 });
17520 parcelHelpers.export(exports, "aE", function() {
17521 return _setMinAndMaxByKey;
17522 });
17523 parcelHelpers.export(exports, "aF", function() {
17524 return niceNum;
17525 });
17526 parcelHelpers.export(exports, "aG", function() {
17527 return almostWhole;
17528 });
17529 parcelHelpers.export(exports, "aH", function() {
17530 return almostEquals;
17531 });
17532 parcelHelpers.export(exports, "aI", function() {
17533 return _decimalPlaces;
17534 });
17535 parcelHelpers.export(exports, "aJ", function() {
17536 return _longestText;
17537 });
17538 parcelHelpers.export(exports, "aK", function() {
17539 return _filterBetween;
17540 });
17541 parcelHelpers.export(exports, "aL", function() {
17542 return _lookup;
17543 });
17544 parcelHelpers.export(exports, "aM", function() {
17545 return isPatternOrGradient;
17546 });
17547 parcelHelpers.export(exports, "aN", function() {
17548 return getHoverColor;
17549 });
17550 parcelHelpers.export(exports, "aO", function() {
17551 return clone$1;
17552 });
17553 parcelHelpers.export(exports, "aP", function() {
17554 return _merger;
17555 });
17556 parcelHelpers.export(exports, "aQ", function() {
17557 return _mergerIf;
17558 });
17559 parcelHelpers.export(exports, "aR", function() {
17560 return _deprecated;
17561 });
17562 parcelHelpers.export(exports, "aS", function() {
17563 return toFontString;
17564 });
17565 parcelHelpers.export(exports, "aT", function() {
17566 return splineCurve;
17567 });
17568 parcelHelpers.export(exports, "aU", function() {
17569 return splineCurveMonotone;
17570 });
17571 parcelHelpers.export(exports, "aV", function() {
17572 return getStyle;
17573 });
17574 parcelHelpers.export(exports, "aW", function() {
17575 return fontString;
17576 });
17577 parcelHelpers.export(exports, "aX", function() {
17578 return toLineHeight;
17579 });
17580 parcelHelpers.export(exports, "aY", function() {
17581 return PITAU;
17582 });
17583 parcelHelpers.export(exports, "aZ", function() {
17584 return INFINITY;
17585 });
17586 parcelHelpers.export(exports, "a_", function() {
17587 return RAD_PER_DEG;
17588 });
17589 parcelHelpers.export(exports, "aa", function() {
17590 return mergeIf;
17591 });
17592 parcelHelpers.export(exports, "ab", function() {
17593 return uid;
17594 });
17595 parcelHelpers.export(exports, "ac", function() {
17596 return debounce;
17597 });
17598 parcelHelpers.export(exports, "ad", function() {
17599 return retinaScale;
17600 });
17601 parcelHelpers.export(exports, "ae", function() {
17602 return clearCanvas;
17603 });
17604 parcelHelpers.export(exports, "af", function() {
17605 return setsEqual;
17606 });
17607 parcelHelpers.export(exports, "ag", function() {
17608 return _elementsEqual;
17609 });
17610 parcelHelpers.export(exports, "ah", function() {
17611 return _isClickEvent;
17612 });
17613 parcelHelpers.export(exports, "ai", function() {
17614 return _isBetween;
17615 });
17616 parcelHelpers.export(exports, "aj", function() {
17617 return _readValueToProps;
17618 });
17619 parcelHelpers.export(exports, "ak", function() {
17620 return _updateBezierControlPoints;
17621 });
17622 parcelHelpers.export(exports, "al", function() {
17623 return _computeSegments;
17624 });
17625 parcelHelpers.export(exports, "am", function() {
17626 return _boundSegments;
17627 });
17628 parcelHelpers.export(exports, "an", function() {
17629 return _steppedInterpolation;
17630 });
17631 parcelHelpers.export(exports, "ao", function() {
17632 return _bezierInterpolation;
17633 });
17634 parcelHelpers.export(exports, "ap", function() {
17635 return _pointInLine;
17636 });
17637 parcelHelpers.export(exports, "aq", function() {
17638 return _steppedLineTo;
17639 });
17640 parcelHelpers.export(exports, "ar", function() {
17641 return _bezierCurveTo;
17642 });
17643 parcelHelpers.export(exports, "as", function() {
17644 return drawPoint;
17645 });
17646 parcelHelpers.export(exports, "at", function() {
17647 return addRoundedRectPath;
17648 });
17649 parcelHelpers.export(exports, "au", function() {
17650 return toTRBL;
17651 });
17652 parcelHelpers.export(exports, "av", function() {
17653 return toTRBLCorners;
17654 });
17655 parcelHelpers.export(exports, "aw", function() {
17656 return _boundSegment;
17657 });
17658 parcelHelpers.export(exports, "ax", function() {
17659 return _normalizeAngle;
17660 });
17661 parcelHelpers.export(exports, "ay", function() {
17662 return getRtlAdapter;
17663 });
17664 parcelHelpers.export(exports, "az", function() {
17665 return overrideTextDirection;
17666 });
17667 parcelHelpers.export(exports, "b", function() {
17668 return isArray;
17669 });
17670 parcelHelpers.export(exports, "b0", function() {
17671 return TWO_THIRDS_PI;
17672 });
17673 parcelHelpers.export(exports, "b1", function() {
17674 return _angleDiff;
17675 });
17676 parcelHelpers.export(exports, "c", function() {
17677 return color;
17678 });
17679 parcelHelpers.export(exports, "d", function() {
17680 return defaults;
17681 });
17682 parcelHelpers.export(exports, "e", function() {
17683 return effects;
17684 });
17685 parcelHelpers.export(exports, "f", function() {
17686 return resolveObjectKey;
17687 });
17688 parcelHelpers.export(exports, "g", function() {
17689 return isNumberFinite;
17690 });
17691 parcelHelpers.export(exports, "h", function() {
17692 return createContext;
17693 });
17694 parcelHelpers.export(exports, "i", function() {
17695 return isObject;
17696 });
17697 parcelHelpers.export(exports, "j", function() {
17698 return defined;
17699 });
17700 parcelHelpers.export(exports, "k", function() {
17701 return isNullOrUndef;
17702 });
17703 parcelHelpers.export(exports, "l", function() {
17704 return listenArrayEvents;
17705 });
17706 parcelHelpers.export(exports, "m", function() {
17707 return toPercentage;
17708 });
17709 parcelHelpers.export(exports, "n", function() {
17710 return toDimension;
17711 });
17712 parcelHelpers.export(exports, "o", function() {
17713 return formatNumber;
17714 });
17715 parcelHelpers.export(exports, "p", function() {
17716 return _angleBetween;
17717 });
17718 parcelHelpers.export(exports, "q", function() {
17719 return isNumber;
17720 });
17721 parcelHelpers.export(exports, "r", function() {
17722 return requestAnimFrame;
17723 });
17724 parcelHelpers.export(exports, "s", function() {
17725 return sign;
17726 });
17727 parcelHelpers.export(exports, "t", function() {
17728 return toRadians;
17729 });
17730 parcelHelpers.export(exports, "u", function() {
17731 return unlistenArrayEvents;
17732 });
17733 parcelHelpers.export(exports, "v", function() {
17734 return valueOrDefault;
17735 });
17736 parcelHelpers.export(exports, "w", function() {
17737 return _limitValue;
17738 });
17739 parcelHelpers.export(exports, "x", function() {
17740 return _lookupByKey;
17741 });
17742 parcelHelpers.export(exports, "y", function() {
17743 return _parseObjectDataRadialScale;
17744 });
17745 parcelHelpers.export(exports, "z", function() {
17746 return getRelativePosition;
17747 });
17748 var _classCallCheckJs = require("@swc/helpers/lib/_class_call_check.js");
17749 var _classCallCheckJsDefault = parcelHelpers.interopDefault(_classCallCheckJs);
17750 var _createClassJs = require("@swc/helpers/lib/_create_class.js");
17751 var _createClassJsDefault = parcelHelpers.interopDefault(_createClassJs);
17752 var _definePropertyJs = require("@swc/helpers/lib/_define_property.js");
17753 var _definePropertyJsDefault = parcelHelpers.interopDefault(_definePropertyJs);
17754 var _toConsumableArrayJs = require("@swc/helpers/lib/_to_consumable_array.js");
17755 var _toConsumableArrayJsDefault = parcelHelpers.interopDefault(_toConsumableArrayJs);
17756 var _typeOfJs = require("@swc/helpers/lib/_type_of.js");
17757 var _typeOfJsDefault = parcelHelpers.interopDefault(_typeOfJs);
17758 /*!
17759 * Chart.js v3.8.0
17760 * https://www.chartjs.org
17761 * (c) 2022 Chart.js Contributors
17762 * Released under the MIT License
17763 */ function fontString(pixelSize, fontStyle, fontFamily) {
17764 return fontStyle + " " + pixelSize + "px " + fontFamily;
17765 }
17766 var requestAnimFrame = function() {
17767 if (typeof window === "undefined") return function(callback1) {
17768 return callback1();
17769 };
17770 return window.requestAnimationFrame;
17771 }();
17772 function throttled(fn, thisArg, updateFn) {
17773 var updateArgs = updateFn || function(args) {
17774 return Array.prototype.slice.call(args);
17775 };
17776 var ticking = false;
17777 var args1 = [];
17778 return function() {
17779 for(var _len = arguments.length, rest = new Array(_len), _key = 0; _key < _len; _key++){
17780 rest[_key] = arguments[_key];
17781 }
17782 args1 = updateArgs(rest);
17783 if (!ticking) {
17784 ticking = true;
17785 requestAnimFrame.call(window, function() {
17786 ticking = false;
17787 fn.apply(thisArg, args1);
17788 });
17789 }
17790 };
17791 }
17792 function debounce(fn, delay) {
17793 var timeout;
17794 return function() {
17795 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
17796 args[_key] = arguments[_key];
17797 }
17798 if (delay) {
17799 clearTimeout(timeout);
17800 timeout = setTimeout(fn, delay, args);
17801 } else fn.apply(this, args);
17802 return delay;
17803 };
17804 }
17805 var _toLeftRightCenter = function(align) {
17806 return align === "start" ? "left" : align === "end" ? "right" : "center";
17807 };
17808 var _alignStartEnd = function(align, start, end) {
17809 return align === "start" ? start : align === "end" ? end : (start + end) / 2;
17810 };
17811 var _textX = function(align, left, right, rtl) {
17812 var check = rtl ? "left" : "right";
17813 return align === check ? right : align === "center" ? (left + right) / 2 : left;
17814 };
17815 function noop() {}
17816 var uid = function() {
17817 var id = 0;
17818 return function() {
17819 return id++;
17820 };
17821 }();
17822 function isNullOrUndef(value) {
17823 return value === null || typeof value === "undefined";
17824 }
17825 function isArray(value) {
17826 if (Array.isArray && Array.isArray(value)) return true;
17827 var type = Object.prototype.toString.call(value);
17828 if (type.slice(0, 7) === "[object" && type.slice(-6) === "Array]") return true;
17829 return false;
17830 }
17831 function isObject(value) {
17832 return value !== null && Object.prototype.toString.call(value) === "[object Object]";
17833 }
17834 var isNumberFinite = function(value) {
17835 return (typeof value === "number" || value instanceof Number) && isFinite(+value);
17836 };
17837 function finiteOrDefault(value, defaultValue) {
17838 return isNumberFinite(value) ? value : defaultValue;
17839 }
17840 function valueOrDefault(value, defaultValue) {
17841 return typeof value === "undefined" ? defaultValue : value;
17842 }
17843 var toPercentage = function(value, dimension) {
17844 return typeof value === "string" && value.endsWith("%") ? parseFloat(value) / 100 : value / dimension;
17845 };
17846 var toDimension = function(value, dimension) {
17847 return typeof value === "string" && value.endsWith("%") ? parseFloat(value) / 100 * dimension : +value;
17848 };
17849 function callback(fn, args, thisArg) {
17850 if (fn && typeof fn.call === "function") return fn.apply(thisArg, args);
17851 }
17852 function each(loopable, fn, thisArg, reverse) {
17853 var i, len, keys;
17854 if (isArray(loopable)) {
17855 len = loopable.length;
17856 if (reverse) for(i = len - 1; i >= 0; i--)fn.call(thisArg, loopable[i], i);
17857 else for(i = 0; i < len; i++)fn.call(thisArg, loopable[i], i);
17858 } else if (isObject(loopable)) {
17859 keys = Object.keys(loopable);
17860 len = keys.length;
17861 for(i = 0; i < len; i++)fn.call(thisArg, loopable[keys[i]], keys[i]);
17862 }
17863 }
17864 function _elementsEqual(a0, a1) {
17865 var i, ilen, v0, v1;
17866 if (!a0 || !a1 || a0.length !== a1.length) return false;
17867 for(i = 0, ilen = a0.length; i < ilen; ++i){
17868 v0 = a0[i];
17869 v1 = a1[i];
17870 if (v0.datasetIndex !== v1.datasetIndex || v0.index !== v1.index) return false;
17871 }
17872 return true;
17873 }
17874 function clone$1(source) {
17875 if (isArray(source)) return source.map(clone$1);
17876 if (isObject(source)) {
17877 var target = Object.create(null);
17878 var keys = Object.keys(source);
17879 var klen = keys.length;
17880 var k = 0;
17881 for(; k < klen; ++k)target[keys[k]] = clone$1(source[keys[k]]);
17882 return target;
17883 }
17884 return source;
17885 }
17886 function isValidKey(key) {
17887 return [
17888 "__proto__",
17889 "prototype",
17890 "constructor"
17891 ].indexOf(key) === -1;
17892 }
17893 function _merger(key, target, source, options) {
17894 if (!isValidKey(key)) return;
17895 var tval = target[key];
17896 var sval = source[key];
17897 if (isObject(tval) && isObject(sval)) merge(tval, sval, options);
17898 else target[key] = clone$1(sval);
17899 }
17900 function merge(target, source, options) {
17901 var sources = isArray(source) ? source : [
17902 source
17903 ];
17904 var ilen = sources.length;
17905 if (!isObject(target)) return target;
17906 options = options || {};
17907 var merger = options.merger || _merger;
17908 for(var i = 0; i < ilen; ++i){
17909 source = sources[i];
17910 if (!isObject(source)) continue;
17911 var keys = Object.keys(source);
17912 for(var k = 0, klen = keys.length; k < klen; ++k)merger(keys[k], target, source, options);
17913 }
17914 return target;
17915 }
17916 function mergeIf(target, source) {
17917 return merge(target, source, {
17918 merger: _mergerIf
17919 });
17920 }
17921 function _mergerIf(key, target, source) {
17922 if (!isValidKey(key)) return;
17923 var tval = target[key];
17924 var sval = source[key];
17925 if (isObject(tval) && isObject(sval)) mergeIf(tval, sval);
17926 else if (!Object.prototype.hasOwnProperty.call(target, key)) target[key] = clone$1(sval);
17927 }
17928 function _deprecated(scope, value, previous, current) {
17929 if (value !== undefined) console.warn(scope + ': "' + previous + '" is deprecated. Please use "' + current + '" instead');
17930 }
17931 var emptyString = "";
17932 var dot = ".";
17933 function indexOfDotOrLength(key, start) {
17934 var idx = key.indexOf(dot, start);
17935 return idx === -1 ? key.length : idx;
17936 }
17937 function resolveObjectKey(obj, key) {
17938 if (key === emptyString) return obj;
17939 var pos = 0;
17940 var idx = indexOfDotOrLength(key, pos);
17941 while(obj && idx > pos){
17942 obj = obj[key.slice(pos, idx)];
17943 pos = idx + 1;
17944 idx = indexOfDotOrLength(key, pos);
17945 }
17946 return obj;
17947 }
17948 function _capitalize(str) {
17949 return str.charAt(0).toUpperCase() + str.slice(1);
17950 }
17951 var defined = function(value) {
17952 return typeof value !== "undefined";
17953 };
17954 var isFunction = function(value) {
17955 return typeof value === "function";
17956 };
17957 var setsEqual = function(a, b) {
17958 if (a.size !== b.size) return false;
17959 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
17960 try {
17961 for(var _iterator = a[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
17962 var item = _step.value;
17963 if (!b.has(item)) return false;
17964 }
17965 } catch (err) {
17966 _didIteratorError = true;
17967 _iteratorError = err;
17968 } finally{
17969 try {
17970 if (!_iteratorNormalCompletion && _iterator.return != null) {
17971 _iterator.return();
17972 }
17973 } finally{
17974 if (_didIteratorError) {
17975 throw _iteratorError;
17976 }
17977 }
17978 }
17979 return true;
17980 };
17981 function _isClickEvent(e) {
17982 return e.type === "mouseup" || e.type === "click" || e.type === "contextmenu";
17983 }
17984 var PI = Math.PI;
17985 var TAU = 2 * PI;
17986 var PITAU = TAU + PI;
17987 var INFINITY = Number.POSITIVE_INFINITY;
17988 var RAD_PER_DEG = PI / 180;
17989 var HALF_PI = PI / 2;
17990 var QUARTER_PI = PI / 4;
17991 var TWO_THIRDS_PI = PI * 2 / 3;
17992 var log10 = Math.log10;
17993 var sign = Math.sign;
17994 function niceNum(range) {
17995 var roundedRange = Math.round(range);
17996 range = almostEquals(range, roundedRange, range / 1000) ? roundedRange : range;
17997 var niceRange = Math.pow(10, Math.floor(log10(range)));
17998 var fraction = range / niceRange;
17999 var niceFraction = fraction <= 1 ? 1 : fraction <= 2 ? 2 : fraction <= 5 ? 5 : 10;
18000 return niceFraction * niceRange;
18001 }
18002 function _factorize(value) {
18003 var result = [];
18004 var sqrt = Math.sqrt(value);
18005 var i;
18006 for(i = 1; i < sqrt; i++)if (value % i === 0) {
18007 result.push(i);
18008 result.push(value / i);
18009 }
18010 if (sqrt === (sqrt | 0)) result.push(sqrt);
18011 result.sort(function(a, b) {
18012 return a - b;
18013 }).pop();
18014 return result;
18015 }
18016 function isNumber(n) {
18017 return !isNaN(parseFloat(n)) && isFinite(n);
18018 }
18019 function almostEquals(x, y, epsilon) {
18020 return Math.abs(x - y) < epsilon;
18021 }
18022 function almostWhole(x, epsilon) {
18023 var rounded = Math.round(x);
18024 return rounded - epsilon <= x && rounded + epsilon >= x;
18025 }
18026 function _setMinAndMaxByKey(array, target, property) {
18027 var i, ilen, value;
18028 for(i = 0, ilen = array.length; i < ilen; i++){
18029 value = array[i][property];
18030 if (!isNaN(value)) {
18031 target.min = Math.min(target.min, value);
18032 target.max = Math.max(target.max, value);
18033 }
18034 }
18035 }
18036 function toRadians(degrees) {
18037 return degrees * (PI / 180);
18038 }
18039 function toDegrees(radians) {
18040 return radians * (180 / PI);
18041 }
18042 function _decimalPlaces(x) {
18043 if (!isNumberFinite(x)) return;
18044 var e = 1;
18045 var p = 0;
18046 while(Math.round(x * e) / e !== x){
18047 e *= 10;
18048 p++;
18049 }
18050 return p;
18051 }
18052 function getAngleFromPoint(centrePoint, anglePoint) {
18053 var distanceFromXCenter = anglePoint.x - centrePoint.x;
18054 var distanceFromYCenter = anglePoint.y - centrePoint.y;
18055 var radialDistanceFromCenter = Math.sqrt(distanceFromXCenter * distanceFromXCenter + distanceFromYCenter * distanceFromYCenter);
18056 var angle = Math.atan2(distanceFromYCenter, distanceFromXCenter);
18057 if (angle < -0.5 * PI) angle += TAU;
18058 return {
18059 angle: angle,
18060 distance: radialDistanceFromCenter
18061 };
18062 }
18063 function distanceBetweenPoints(pt1, pt2) {
18064 return Math.sqrt(Math.pow(pt2.x - pt1.x, 2) + Math.pow(pt2.y - pt1.y, 2));
18065 }
18066 function _angleDiff(a, b) {
18067 return (a - b + PITAU) % TAU - PI;
18068 }
18069 function _normalizeAngle(a) {
18070 return (a % TAU + TAU) % TAU;
18071 }
18072 function _angleBetween(angle, start, end, sameAngleIsFullCircle) {
18073 var a = _normalizeAngle(angle);
18074 var s = _normalizeAngle(start);
18075 var e = _normalizeAngle(end);
18076 var angleToStart = _normalizeAngle(s - a);
18077 var angleToEnd = _normalizeAngle(e - a);
18078 var startToAngle = _normalizeAngle(a - s);
18079 var endToAngle = _normalizeAngle(a - e);
18080 return a === s || a === e || sameAngleIsFullCircle && s === e || angleToStart > angleToEnd && startToAngle < endToAngle;
18081 }
18082 function _limitValue(value, min, max) {
18083 return Math.max(min, Math.min(max, value));
18084 }
18085 function _int16Range(value) {
18086 return _limitValue(value, -32768, 32767);
18087 }
18088 function _isBetween(value, start, end) {
18089 var epsilon = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 1e-6;
18090 return value >= Math.min(start, end) - epsilon && value <= Math.max(start, end) + epsilon;
18091 }
18092 var atEdge = function(t) {
18093 return t === 0 || t === 1;
18094 };
18095 var elasticIn = function(t, s, p) {
18096 return -(Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * TAU / p));
18097 };
18098 var elasticOut = function(t, s, p) {
18099 return Math.pow(2, -10 * t) * Math.sin((t - s) * TAU / p) + 1;
18100 };
18101 var effects = {
18102 linear: function(t) {
18103 return t;
18104 },
18105 easeInQuad: function(t) {
18106 return t * t;
18107 },
18108 easeOutQuad: function(t) {
18109 return -t * (t - 2);
18110 },
18111 easeInOutQuad: function(t) {
18112 return (t /= 0.5) < 1 ? 0.5 * t * t : -0.5 * (--t * (t - 2) - 1);
18113 },
18114 easeInCubic: function(t) {
18115 return t * t * t;
18116 },
18117 easeOutCubic: function(t) {
18118 return (t -= 1) * t * t + 1;
18119 },
18120 easeInOutCubic: function(t) {
18121 return (t /= 0.5) < 1 ? 0.5 * t * t * t : 0.5 * ((t -= 2) * t * t + 2);
18122 },
18123 easeInQuart: function(t) {
18124 return t * t * t * t;
18125 },
18126 easeOutQuart: function(t) {
18127 return -((t -= 1) * t * t * t - 1);
18128 },
18129 easeInOutQuart: function(t) {
18130 return (t /= 0.5) < 1 ? 0.5 * t * t * t * t : -0.5 * ((t -= 2) * t * t * t - 2);
18131 },
18132 easeInQuint: function(t) {
18133 return t * t * t * t * t;
18134 },
18135 easeOutQuint: function(t) {
18136 return (t -= 1) * t * t * t * t + 1;
18137 },
18138 easeInOutQuint: function(t) {
18139 return (t /= 0.5) < 1 ? 0.5 * t * t * t * t * t : 0.5 * ((t -= 2) * t * t * t * t + 2);
18140 },
18141 easeInSine: function(t) {
18142 return -Math.cos(t * HALF_PI) + 1;
18143 },
18144 easeOutSine: function(t) {
18145 return Math.sin(t * HALF_PI);
18146 },
18147 easeInOutSine: function(t) {
18148 return -0.5 * (Math.cos(PI * t) - 1);
18149 },
18150 easeInExpo: function(t) {
18151 return t === 0 ? 0 : Math.pow(2, 10 * (t - 1));
18152 },
18153 easeOutExpo: function(t) {
18154 return t === 1 ? 1 : -Math.pow(2, -10 * t) + 1;
18155 },
18156 easeInOutExpo: function(t) {
18157 return atEdge(t) ? t : t < 0.5 ? 0.5 * Math.pow(2, 10 * (t * 2 - 1)) : 0.5 * (-Math.pow(2, -10 * (t * 2 - 1)) + 2);
18158 },
18159 easeInCirc: function(t) {
18160 return t >= 1 ? t : -(Math.sqrt(1 - t * t) - 1);
18161 },
18162 easeOutCirc: function(t) {
18163 return Math.sqrt(1 - (t -= 1) * t);
18164 },
18165 easeInOutCirc: function(t) {
18166 return (t /= 0.5) < 1 ? -0.5 * (Math.sqrt(1 - t * t) - 1) : 0.5 * (Math.sqrt(1 - (t -= 2) * t) + 1);
18167 },
18168 easeInElastic: function(t) {
18169 return atEdge(t) ? t : elasticIn(t, 0.075, 0.3);
18170 },
18171 easeOutElastic: function(t) {
18172 return atEdge(t) ? t : elasticOut(t, 0.075, 0.3);
18173 },
18174 easeInOutElastic: function(t) {
18175 var s = 0.1125;
18176 var p = 0.45;
18177 return atEdge(t) ? t : t < 0.5 ? 0.5 * elasticIn(t * 2, s, p) : 0.5 + 0.5 * elasticOut(t * 2 - 1, s, p);
18178 },
18179 easeInBack: function(t) {
18180 var s = 1.70158;
18181 return t * t * ((s + 1) * t - s);
18182 },
18183 easeOutBack: function(t) {
18184 var s = 1.70158;
18185 return (t -= 1) * t * ((s + 1) * t + s) + 1;
18186 },
18187 easeInOutBack: function(t) {
18188 var s = 1.70158;
18189 if ((t /= 0.5) < 1) return 0.5 * (t * t * (((s *= 1.525) + 1) * t - s));
18190 return 0.5 * ((t -= 2) * t * (((s *= 1.525) + 1) * t + s) + 2);
18191 },
18192 easeInBounce: function(t) {
18193 return 1 - effects.easeOutBounce(1 - t);
18194 },
18195 easeOutBounce: function(t) {
18196 var m = 7.5625;
18197 var d = 2.75;
18198 if (t < 1 / d) return m * t * t;
18199 if (t < 2 / d) return m * (t -= 1.5 / d) * t + 0.75;
18200 if (t < 2.5 / d) return m * (t -= 2.25 / d) * t + 0.9375;
18201 return m * (t -= 2.625 / d) * t + 0.984375;
18202 },
18203 easeInOutBounce: function(t) {
18204 return t < 0.5 ? effects.easeInBounce(t * 2) * 0.5 : effects.easeOutBounce(t * 2 - 1) * 0.5 + 0.5;
18205 }
18206 };
18207 /*!
18208 * @kurkle/color v0.2.1
18209 * https://github.com/kurkle/color#readme
18210 * (c) 2022 Jukka Kurkela
18211 * Released under the MIT License
18212 */ function round(v) {
18213 return v + 0.5 | 0;
18214 }
18215 var lim = function(v, l, h) {
18216 return Math.max(Math.min(v, h), l);
18217 };
18218 function p2b(v) {
18219 return lim(round(v * 2.55), 0, 255);
18220 }
18221 function n2b(v) {
18222 return lim(round(v * 255), 0, 255);
18223 }
18224 function b2n(v) {
18225 return lim(round(v / 2.55) / 100, 0, 1);
18226 }
18227 function n2p(v) {
18228 return lim(round(v * 100), 0, 100);
18229 }
18230 var map$1 = {
18231 0: 0,
18232 1: 1,
18233 2: 2,
18234 3: 3,
18235 4: 4,
18236 5: 5,
18237 6: 6,
18238 7: 7,
18239 8: 8,
18240 9: 9,
18241 A: 10,
18242 B: 11,
18243 C: 12,
18244 D: 13,
18245 E: 14,
18246 F: 15,
18247 a: 10,
18248 b: 11,
18249 c: 12,
18250 d: 13,
18251 e: 14,
18252 f: 15
18253 };
18254 var hex = Array.from("0123456789ABCDEF");
18255 var h1 = function(b) {
18256 return hex[b & 0xF];
18257 };
18258 var h2 = function(b) {
18259 return hex[(b & 0xF0) >> 4] + hex[b & 0xF];
18260 };
18261 var eq = function(b) {
18262 return (b & 0xF0) >> 4 === (b & 0xF);
18263 };
18264 var isShort = function(v) {
18265 return eq(v.r) && eq(v.g) && eq(v.b) && eq(v.a);
18266 };
18267 function hexParse(str) {
18268 var len = str.length;
18269 var ret;
18270 if (str[0] === "#") {
18271 if (len === 4 || len === 5) ret = {
18272 r: 255 & map$1[str[1]] * 17,
18273 g: 255 & map$1[str[2]] * 17,
18274 b: 255 & map$1[str[3]] * 17,
18275 a: len === 5 ? map$1[str[4]] * 17 : 255
18276 };
18277 else if (len === 7 || len === 9) ret = {
18278 r: map$1[str[1]] << 4 | map$1[str[2]],
18279 g: map$1[str[3]] << 4 | map$1[str[4]],
18280 b: map$1[str[5]] << 4 | map$1[str[6]],
18281 a: len === 9 ? map$1[str[7]] << 4 | map$1[str[8]] : 255
18282 };
18283 }
18284 return ret;
18285 }
18286 var alpha = function(a, f) {
18287 return a < 255 ? f(a) : "";
18288 };
18289 function hexString(v) {
18290 var f = isShort(v) ? h1 : h2;
18291 return v ? "#" + f(v.r) + f(v.g) + f(v.b) + alpha(v.a, f) : undefined;
18292 }
18293 var HUE_RE = /^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;
18294 function hsl2rgbn(h, s, l) {
18295 var a = s * Math.min(l, 1 - l);
18296 var f = function(n) {
18297 var k = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : (n + h / 30) % 12;
18298 return l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
18299 };
18300 return [
18301 f(0),
18302 f(8),
18303 f(4)
18304 ];
18305 }
18306 function hsv2rgbn(h, s, v) {
18307 var f = function(n) {
18308 var k = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : (n + h / 60) % 6;
18309 return v - v * s * Math.max(Math.min(k, 4 - k, 1), 0);
18310 };
18311 return [
18312 f(5),
18313 f(3),
18314 f(1)
18315 ];
18316 }
18317 function hwb2rgbn(h, w, b) {
18318 var rgb = hsl2rgbn(h, 1, 0.5);
18319 var i;
18320 if (w + b > 1) {
18321 i = 1 / (w + b);
18322 w *= i;
18323 b *= i;
18324 }
18325 for(i = 0; i < 3; i++){
18326 rgb[i] *= 1 - w - b;
18327 rgb[i] += w;
18328 }
18329 return rgb;
18330 }
18331 function hueValue(r, g, b, d, max) {
18332 if (r === max) return (g - b) / d + (g < b ? 6 : 0);
18333 if (g === max) return (b - r) / d + 2;
18334 return (r - g) / d + 4;
18335 }
18336 function rgb2hsl(v) {
18337 var range = 255;
18338 var r = v.r / range;
18339 var g = v.g / range;
18340 var b = v.b / range;
18341 var max = Math.max(r, g, b);
18342 var min = Math.min(r, g, b);
18343 var l = (max + min) / 2;
18344 var h, s, d;
18345 if (max !== min) {
18346 d = max - min;
18347 s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
18348 h = hueValue(r, g, b, d, max);
18349 h = h * 60 + 0.5;
18350 }
18351 return [
18352 h | 0,
18353 s || 0,
18354 l
18355 ];
18356 }
18357 function calln(f, a, b, c) {
18358 return (Array.isArray(a) ? f(a[0], a[1], a[2]) : f(a, b, c)).map(n2b);
18359 }
18360 function hsl2rgb(h, s, l) {
18361 return calln(hsl2rgbn, h, s, l);
18362 }
18363 function hwb2rgb(h, w, b) {
18364 return calln(hwb2rgbn, h, w, b);
18365 }
18366 function hsv2rgb(h, s, v) {
18367 return calln(hsv2rgbn, h, s, v);
18368 }
18369 function hue(h) {
18370 return (h % 360 + 360) % 360;
18371 }
18372 function hueParse(str) {
18373 var m = HUE_RE.exec(str);
18374 var a = 255;
18375 var v;
18376 if (!m) return;
18377 if (m[5] !== v) a = m[6] ? p2b(+m[5]) : n2b(+m[5]);
18378 var h = hue(+m[2]);
18379 var p1 = +m[3] / 100;
18380 var p2 = +m[4] / 100;
18381 if (m[1] === "hwb") v = hwb2rgb(h, p1, p2);
18382 else if (m[1] === "hsv") v = hsv2rgb(h, p1, p2);
18383 else v = hsl2rgb(h, p1, p2);
18384 return {
18385 r: v[0],
18386 g: v[1],
18387 b: v[2],
18388 a: a
18389 };
18390 }
18391 function rotate(v, deg) {
18392 var h = rgb2hsl(v);
18393 h[0] = hue(h[0] + deg);
18394 h = hsl2rgb(h);
18395 v.r = h[0];
18396 v.g = h[1];
18397 v.b = h[2];
18398 }
18399 function hslString(v) {
18400 if (!v) return;
18401 var a = rgb2hsl(v);
18402 var h = a[0];
18403 var s = n2p(a[1]);
18404 var l = n2p(a[2]);
18405 return v.a < 255 ? "hsla(".concat(h, ", ").concat(s, "%, ").concat(l, "%, ").concat(b2n(v.a), ")") : "hsl(".concat(h, ", ").concat(s, "%, ").concat(l, "%)");
18406 }
18407 var map = {
18408 x: "dark",
18409 Z: "light",
18410 Y: "re",
18411 X: "blu",
18412 W: "gr",
18413 V: "medium",
18414 U: "slate",
18415 A: "ee",
18416 T: "ol",
18417 S: "or",
18418 B: "ra",
18419 C: "lateg",
18420 D: "ights",
18421 R: "in",
18422 Q: "turquois",
18423 E: "hi",
18424 P: "ro",
18425 O: "al",
18426 N: "le",
18427 M: "de",
18428 L: "yello",
18429 F: "en",
18430 K: "ch",
18431 G: "arks",
18432 H: "ea",
18433 I: "ightg",
18434 J: "wh"
18435 };
18436 var names$1 = {
18437 OiceXe: "f0f8ff",
18438 antiquewEte: "faebd7",
18439 aqua: "ffff",
18440 aquamarRe: "7fffd4",
18441 azuY: "f0ffff",
18442 beige: "f5f5dc",
18443 bisque: "ffe4c4",
18444 black: "0",
18445 blanKedOmond: "ffebcd",
18446 Xe: "ff",
18447 XeviTet: "8a2be2",
18448 bPwn: "a52a2a",
18449 burlywood: "deb887",
18450 caMtXe: "5f9ea0",
18451 KartYuse: "7fff00",
18452 KocTate: "d2691e",
18453 cSO: "ff7f50",
18454 cSnflowerXe: "6495ed",
18455 cSnsilk: "fff8dc",
18456 crimson: "dc143c",
18457 cyan: "ffff",
18458 xXe: "8b",
18459 xcyan: "8b8b",
18460 xgTMnPd: "b8860b",
18461 xWay: "a9a9a9",
18462 xgYF: "6400",
18463 xgYy: "a9a9a9",
18464 xkhaki: "bdb76b",
18465 xmagFta: "8b008b",
18466 xTivegYF: "556b2f",
18467 xSange: "ff8c00",
18468 xScEd: "9932cc",
18469 xYd: "8b0000",
18470 xsOmon: "e9967a",
18471 xsHgYF: "8fbc8f",
18472 xUXe: "483d8b",
18473 xUWay: "2f4f4f",
18474 xUgYy: "2f4f4f",
18475 xQe: "ced1",
18476 xviTet: "9400d3",
18477 dAppRk: "ff1493",
18478 dApskyXe: "bfff",
18479 dimWay: "696969",
18480 dimgYy: "696969",
18481 dodgerXe: "1e90ff",
18482 fiYbrick: "b22222",
18483 flSOwEte: "fffaf0",
18484 foYstWAn: "228b22",
18485 fuKsia: "ff00ff",
18486 gaRsbSo: "dcdcdc",
18487 ghostwEte: "f8f8ff",
18488 gTd: "ffd700",
18489 gTMnPd: "daa520",
18490 Way: "808080",
18491 gYF: "8000",
18492 gYFLw: "adff2f",
18493 gYy: "808080",
18494 honeyMw: "f0fff0",
18495 hotpRk: "ff69b4",
18496 RdianYd: "cd5c5c",
18497 Rdigo: "4b0082",
18498 ivSy: "fffff0",
18499 khaki: "f0e68c",
18500 lavFMr: "e6e6fa",
18501 lavFMrXsh: "fff0f5",
18502 lawngYF: "7cfc00",
18503 NmoncEffon: "fffacd",
18504 ZXe: "add8e6",
18505 ZcSO: "f08080",
18506 Zcyan: "e0ffff",
18507 ZgTMnPdLw: "fafad2",
18508 ZWay: "d3d3d3",
18509 ZgYF: "90ee90",
18510 ZgYy: "d3d3d3",
18511 ZpRk: "ffb6c1",
18512 ZsOmon: "ffa07a",
18513 ZsHgYF: "20b2aa",
18514 ZskyXe: "87cefa",
18515 ZUWay: "778899",
18516 ZUgYy: "778899",
18517 ZstAlXe: "b0c4de",
18518 ZLw: "ffffe0",
18519 lime: "ff00",
18520 limegYF: "32cd32",
18521 lRF: "faf0e6",
18522 magFta: "ff00ff",
18523 maPon: "800000",
18524 VaquamarRe: "66cdaa",
18525 VXe: "cd",
18526 VScEd: "ba55d3",
18527 VpurpN: "9370db",
18528 VsHgYF: "3cb371",
18529 VUXe: "7b68ee",
18530 VsprRggYF: "fa9a",
18531 VQe: "48d1cc",
18532 VviTetYd: "c71585",
18533 midnightXe: "191970",
18534 mRtcYam: "f5fffa",
18535 mistyPse: "ffe4e1",
18536 moccasR: "ffe4b5",
18537 navajowEte: "ffdead",
18538 navy: "80",
18539 Tdlace: "fdf5e6",
18540 Tive: "808000",
18541 TivedBb: "6b8e23",
18542 Sange: "ffa500",
18543 SangeYd: "ff4500",
18544 ScEd: "da70d6",
18545 pOegTMnPd: "eee8aa",
18546 pOegYF: "98fb98",
18547 pOeQe: "afeeee",
18548 pOeviTetYd: "db7093",
18549 papayawEp: "ffefd5",
18550 pHKpuff: "ffdab9",
18551 peru: "cd853f",
18552 pRk: "ffc0cb",
18553 plum: "dda0dd",
18554 powMrXe: "b0e0e6",
18555 purpN: "800080",
18556 YbeccapurpN: "663399",
18557 Yd: "ff0000",
18558 Psybrown: "bc8f8f",
18559 PyOXe: "4169e1",
18560 saddNbPwn: "8b4513",
18561 sOmon: "fa8072",
18562 sandybPwn: "f4a460",
18563 sHgYF: "2e8b57",
18564 sHshell: "fff5ee",
18565 siFna: "a0522d",
18566 silver: "c0c0c0",
18567 skyXe: "87ceeb",
18568 UXe: "6a5acd",
18569 UWay: "708090",
18570 UgYy: "708090",
18571 snow: "fffafa",
18572 sprRggYF: "ff7f",
18573 stAlXe: "4682b4",
18574 tan: "d2b48c",
18575 teO: "8080",
18576 tEstN: "d8bfd8",
18577 tomato: "ff6347",
18578 Qe: "40e0d0",
18579 viTet: "ee82ee",
18580 JHt: "f5deb3",
18581 wEte: "ffffff",
18582 wEtesmoke: "f5f5f5",
18583 Lw: "ffff00",
18584 LwgYF: "9acd32"
18585 };
18586 function unpack() {
18587 var unpacked = {};
18588 var keys = Object.keys(names$1);
18589 var tkeys = Object.keys(map);
18590 var i, j, k, ok, nk;
18591 for(i = 0; i < keys.length; i++){
18592 ok = nk = keys[i];
18593 for(j = 0; j < tkeys.length; j++){
18594 k = tkeys[j];
18595 nk = nk.replace(k, map[k]);
18596 }
18597 k = parseInt(names$1[ok], 16);
18598 unpacked[nk] = [
18599 k >> 16 & 0xFF,
18600 k >> 8 & 0xFF,
18601 k & 0xFF
18602 ];
18603 }
18604 return unpacked;
18605 }
18606 var names;
18607 function nameParse(str) {
18608 if (!names) {
18609 names = unpack();
18610 names.transparent = [
18611 0,
18612 0,
18613 0,
18614 0
18615 ];
18616 }
18617 var a = names[str.toLowerCase()];
18618 return a && {
18619 r: a[0],
18620 g: a[1],
18621 b: a[2],
18622 a: a.length === 4 ? a[3] : 255
18623 };
18624 }
18625 var RGB_RE = /^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;
18626 function rgbParse(str) {
18627 var m = RGB_RE.exec(str);
18628 var a = 255;
18629 var r, g, b;
18630 if (!m) return;
18631 if (m[7] !== r) {
18632 var v = +m[7];
18633 a = m[8] ? p2b(v) : lim(v * 255, 0, 255);
18634 }
18635 r = +m[1];
18636 g = +m[3];
18637 b = +m[5];
18638 r = 255 & (m[2] ? p2b(r) : lim(r, 0, 255));
18639 g = 255 & (m[4] ? p2b(g) : lim(g, 0, 255));
18640 b = 255 & (m[6] ? p2b(b) : lim(b, 0, 255));
18641 return {
18642 r: r,
18643 g: g,
18644 b: b,
18645 a: a
18646 };
18647 }
18648 function rgbString(v) {
18649 return v && (v.a < 255 ? "rgba(".concat(v.r, ", ").concat(v.g, ", ").concat(v.b, ", ").concat(b2n(v.a), ")") : "rgb(".concat(v.r, ", ").concat(v.g, ", ").concat(v.b, ")"));
18650 }
18651 var to = function(v) {
18652 return v <= 0.0031308 ? v * 12.92 : Math.pow(v, 1.0 / 2.4) * 1.055 - 0.055;
18653 };
18654 var from = function(v) {
18655 return v <= 0.04045 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);
18656 };
18657 function interpolate(rgb1, rgb2, t) {
18658 var r = from(b2n(rgb1.r));
18659 var g = from(b2n(rgb1.g));
18660 var b = from(b2n(rgb1.b));
18661 return {
18662 r: n2b(to(r + t * (from(b2n(rgb2.r)) - r))),
18663 g: n2b(to(g + t * (from(b2n(rgb2.g)) - g))),
18664 b: n2b(to(b + t * (from(b2n(rgb2.b)) - b))),
18665 a: rgb1.a + t * (rgb2.a - rgb1.a)
18666 };
18667 }
18668 function modHSL(v, i, ratio) {
18669 if (v) {
18670 var tmp = rgb2hsl(v);
18671 tmp[i] = Math.max(0, Math.min(tmp[i] + tmp[i] * ratio, i === 0 ? 360 : 1));
18672 tmp = hsl2rgb(tmp);
18673 v.r = tmp[0];
18674 v.g = tmp[1];
18675 v.b = tmp[2];
18676 }
18677 }
18678 function clone(v, proto) {
18679 return v ? Object.assign(proto || {}, v) : v;
18680 }
18681 function fromObject(input) {
18682 var v = {
18683 r: 0,
18684 g: 0,
18685 b: 0,
18686 a: 255
18687 };
18688 if (Array.isArray(input)) {
18689 if (input.length >= 3) {
18690 v = {
18691 r: input[0],
18692 g: input[1],
18693 b: input[2],
18694 a: 255
18695 };
18696 if (input.length > 3) v.a = n2b(input[3]);
18697 }
18698 } else {
18699 v = clone(input, {
18700 r: 0,
18701 g: 0,
18702 b: 0,
18703 a: 1
18704 });
18705 v.a = n2b(v.a);
18706 }
18707 return v;
18708 }
18709 function functionParse(str) {
18710 if (str.charAt(0) === "r") return rgbParse(str);
18711 return hueParse(str);
18712 }
18713 var Color = /*#__PURE__*/ function() {
18714 "use strict";
18715 function Color(input) {
18716 (0, _classCallCheckJsDefault.default)(this, Color);
18717 if (input instanceof Color) return input;
18718 var type = typeof input === "undefined" ? "undefined" : (0, _typeOfJsDefault.default)(input);
18719 var v;
18720 if (type === "object") v = fromObject(input);
18721 else if (type === "string") v = hexParse(input) || nameParse(input) || functionParse(input);
18722 this._rgb = v;
18723 this._valid = !!v;
18724 }
18725 (0, _createClassJsDefault.default)(Color, [
18726 {
18727 key: "valid",
18728 get: function get() {
18729 return this._valid;
18730 }
18731 },
18732 {
18733 key: "rgb",
18734 get: function get() {
18735 var v = clone(this._rgb);
18736 if (v) v.a = b2n(v.a);
18737 return v;
18738 },
18739 set: function set1(obj) {
18740 this._rgb = fromObject(obj);
18741 }
18742 },
18743 {
18744 key: "rgbString",
18745 value: function rgbString1() {
18746 return this._valid ? rgbString(this._rgb) : undefined;
18747 }
18748 },
18749 {
18750 key: "hexString",
18751 value: function hexString1() {
18752 return this._valid ? hexString(this._rgb) : undefined;
18753 }
18754 },
18755 {
18756 key: "hslString",
18757 value: function hslString1() {
18758 return this._valid ? hslString(this._rgb) : undefined;
18759 }
18760 },
18761 {
18762 key: "mix",
18763 value: function mix(color1, weight) {
18764 if (color1) {
18765 var c1 = this.rgb;
18766 var c2 = color1.rgb;
18767 var w2;
18768 var p = weight === w2 ? 0.5 : weight;
18769 var w = 2 * p - 1;
18770 var a = c1.a - c2.a;
18771 var w1 = ((w * a === -1 ? w : (w + a) / (1 + w * a)) + 1) / 2.0;
18772 w2 = 1 - w1;
18773 c1.r = 0xFF & w1 * c1.r + w2 * c2.r + 0.5;
18774 c1.g = 0xFF & w1 * c1.g + w2 * c2.g + 0.5;
18775 c1.b = 0xFF & w1 * c1.b + w2 * c2.b + 0.5;
18776 c1.a = p * c1.a + (1 - p) * c2.a;
18777 this.rgb = c1;
18778 }
18779 return this;
18780 }
18781 },
18782 {
18783 key: "interpolate",
18784 value: function interpolate1(color2, t) {
18785 if (color2) this._rgb = interpolate(this._rgb, color2._rgb, t);
18786 return this;
18787 }
18788 },
18789 {
18790 key: "clone",
18791 value: function clone() {
18792 return new Color(this.rgb);
18793 }
18794 },
18795 {
18796 key: "alpha",
18797 value: function alpha(a) {
18798 this._rgb.a = n2b(a);
18799 return this;
18800 }
18801 },
18802 {
18803 key: "clearer",
18804 value: function clearer(ratio) {
18805 var rgb = this._rgb;
18806 rgb.a *= 1 - ratio;
18807 return this;
18808 }
18809 },
18810 {
18811 key: "greyscale",
18812 value: function greyscale() {
18813 var rgb = this._rgb;
18814 var val = round(rgb.r * 0.3 + rgb.g * 0.59 + rgb.b * 0.11);
18815 rgb.r = rgb.g = rgb.b = val;
18816 return this;
18817 }
18818 },
18819 {
18820 key: "opaquer",
18821 value: function opaquer(ratio) {
18822 var rgb = this._rgb;
18823 rgb.a *= 1 + ratio;
18824 return this;
18825 }
18826 },
18827 {
18828 key: "negate",
18829 value: function negate() {
18830 var v = this._rgb;
18831 v.r = 255 - v.r;
18832 v.g = 255 - v.g;
18833 v.b = 255 - v.b;
18834 return this;
18835 }
18836 },
18837 {
18838 key: "lighten",
18839 value: function lighten(ratio) {
18840 modHSL(this._rgb, 2, ratio);
18841 return this;
18842 }
18843 },
18844 {
18845 key: "darken",
18846 value: function darken(ratio) {
18847 modHSL(this._rgb, 2, -ratio);
18848 return this;
18849 }
18850 },
18851 {
18852 key: "saturate",
18853 value: function saturate(ratio) {
18854 modHSL(this._rgb, 1, ratio);
18855 return this;
18856 }
18857 },
18858 {
18859 key: "desaturate",
18860 value: function desaturate(ratio) {
18861 modHSL(this._rgb, 1, -ratio);
18862 return this;
18863 }
18864 },
18865 {
18866 key: "rotate",
18867 value: function rotate1(deg) {
18868 rotate(this._rgb, deg);
18869 return this;
18870 }
18871 }
18872 ]);
18873 return Color;
18874 }();
18875 function index_esm(input) {
18876 return new Color(input);
18877 }
18878 function isPatternOrGradient(value) {
18879 if (value && typeof value === "object") {
18880 var type = value.toString();
18881 return type === "[object CanvasPattern]" || type === "[object CanvasGradient]";
18882 }
18883 return false;
18884 }
18885 function color(value) {
18886 return isPatternOrGradient(value) ? value : index_esm(value);
18887 }
18888 function getHoverColor(value) {
18889 return isPatternOrGradient(value) ? value : index_esm(value).saturate(0.5).darken(0.1).hexString();
18890 }
18891 var overrides = Object.create(null);
18892 var descriptors = Object.create(null);
18893 function getScope$1(node, key) {
18894 if (!key) return node;
18895 var keys = key.split(".");
18896 for(var i = 0, n = keys.length; i < n; ++i){
18897 var k = keys[i];
18898 node = node[k] || (node[k] = Object.create(null));
18899 }
18900 return node;
18901 }
18902 function set(root, scope, values) {
18903 if (typeof scope === "string") return merge(getScope$1(root, scope), values);
18904 return merge(getScope$1(root, ""), scope);
18905 }
18906 var Defaults = /*#__PURE__*/ function() {
18907 "use strict";
18908 function Defaults(_descriptors1) {
18909 (0, _classCallCheckJsDefault.default)(this, Defaults);
18910 this.animation = undefined;
18911 this.backgroundColor = "rgba(0,0,0,0.1)";
18912 this.borderColor = "rgba(0,0,0,0.1)";
18913 this.color = "#666";
18914 this.datasets = {};
18915 this.devicePixelRatio = function(context) {
18916 return context.chart.platform.getDevicePixelRatio();
18917 };
18918 this.elements = {};
18919 this.events = [
18920 "mousemove",
18921 "mouseout",
18922 "click",
18923 "touchstart",
18924 "touchmove"
18925 ];
18926 this.font = {
18927 family: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",
18928 size: 12,
18929 style: "normal",
18930 lineHeight: 1.2,
18931 weight: null
18932 };
18933 this.hover = {};
18934 this.hoverBackgroundColor = function(ctx, options) {
18935 return getHoverColor(options.backgroundColor);
18936 };
18937 this.hoverBorderColor = function(ctx, options) {
18938 return getHoverColor(options.borderColor);
18939 };
18940 this.hoverColor = function(ctx, options) {
18941 return getHoverColor(options.color);
18942 };
18943 this.indexAxis = "x";
18944 this.interaction = {
18945 mode: "nearest",
18946 intersect: true,
18947 includeInvisible: false
18948 };
18949 this.maintainAspectRatio = true;
18950 this.onHover = null;
18951 this.onClick = null;
18952 this.parsing = true;
18953 this.plugins = {};
18954 this.responsive = true;
18955 this.scale = undefined;
18956 this.scales = {};
18957 this.showLine = true;
18958 this.drawActiveElementsOnTop = true;
18959 this.describe(_descriptors1);
18960 }
18961 (0, _createClassJsDefault.default)(Defaults, [
18962 {
18963 key: "set",
18964 value: function set1(scope, values) {
18965 return set(this, scope, values);
18966 }
18967 },
18968 {
18969 key: "get",
18970 value: function get(scope) {
18971 return getScope$1(this, scope);
18972 }
18973 },
18974 {
18975 key: "describe",
18976 value: function describe(scope, values) {
18977 return set(descriptors, scope, values);
18978 }
18979 },
18980 {
18981 key: "override",
18982 value: function override(scope, values) {
18983 return set(overrides, scope, values);
18984 }
18985 },
18986 {
18987 key: "route",
18988 value: function route(scope, name, targetScope, targetName) {
18989 var scopeObject = getScope$1(this, scope);
18990 var targetScopeObject = getScope$1(this, targetScope);
18991 var privateName = "_" + name;
18992 var _obj;
18993 Object.defineProperties(scopeObject, (_obj = {}, (0, _definePropertyJsDefault.default)(_obj, privateName, {
18994 value: scopeObject[name],
18995 writable: true
18996 }), (0, _definePropertyJsDefault.default)(_obj, name, {
18997 enumerable: true,
18998 get: function() {
18999 var local = this[privateName];
19000 var target = targetScopeObject[targetName];
19001 if (isObject(local)) return Object.assign({}, target, local);
19002 return valueOrDefault(local, target);
19003 },
19004 set: function(value) {
19005 this[privateName] = value;
19006 }
19007 }), _obj));
19008 }
19009 }
19010 ]);
19011 return Defaults;
19012 }();
19013 var defaults = new Defaults({
19014 _scriptable: function(name) {
19015 return !name.startsWith("on");
19016 },
19017 _indexable: function(name) {
19018 return name !== "events";
19019 },
19020 hover: {
19021 _fallback: "interaction"
19022 },
19023 interaction: {
19024 _scriptable: false,
19025 _indexable: false
19026 }
19027 });
19028 function toFontString(font) {
19029 if (!font || isNullOrUndef(font.size) || isNullOrUndef(font.family)) return null;
19030 return (font.style ? font.style + " " : "") + (font.weight ? font.weight + " " : "") + font.size + "px " + font.family;
19031 }
19032 function _measureText(ctx, data, gc, longest, string) {
19033 var textWidth = data[string];
19034 if (!textWidth) {
19035 textWidth = data[string] = ctx.measureText(string).width;
19036 gc.push(string);
19037 }
19038 if (textWidth > longest) longest = textWidth;
19039 return longest;
19040 }
19041 function _longestText(ctx, font, arrayOfThings, cache) {
19042 cache = cache || {};
19043 var data = cache.data = cache.data || {};
19044 var gc = cache.garbageCollect = cache.garbageCollect || [];
19045 if (cache.font !== font) {
19046 data = cache.data = {};
19047 gc = cache.garbageCollect = [];
19048 cache.font = font;
19049 }
19050 ctx.save();
19051 ctx.font = font;
19052 var longest = 0;
19053 var ilen = arrayOfThings.length;
19054 var i, j, jlen, thing, nestedThing;
19055 for(i = 0; i < ilen; i++){
19056 thing = arrayOfThings[i];
19057 if (thing !== undefined && thing !== null && isArray(thing) !== true) longest = _measureText(ctx, data, gc, longest, thing);
19058 else if (isArray(thing)) for(j = 0, jlen = thing.length; j < jlen; j++){
19059 nestedThing = thing[j];
19060 if (nestedThing !== undefined && nestedThing !== null && !isArray(nestedThing)) longest = _measureText(ctx, data, gc, longest, nestedThing);
19061 }
19062 }
19063 ctx.restore();
19064 var gcLen = gc.length / 2;
19065 if (gcLen > arrayOfThings.length) {
19066 for(i = 0; i < gcLen; i++)delete data[gc[i]];
19067 gc.splice(0, gcLen);
19068 }
19069 return longest;
19070 }
19071 function _alignPixel(chart, pixel, width) {
19072 var devicePixelRatio = chart.currentDevicePixelRatio;
19073 var halfWidth = width !== 0 ? Math.max(width / 2, 0.5) : 0;
19074 return Math.round((pixel - halfWidth) * devicePixelRatio) / devicePixelRatio + halfWidth;
19075 }
19076 function clearCanvas(canvas, ctx) {
19077 ctx = ctx || canvas.getContext("2d");
19078 ctx.save();
19079 ctx.resetTransform();
19080 ctx.clearRect(0, 0, canvas.width, canvas.height);
19081 ctx.restore();
19082 }
19083 function drawPoint(ctx, options, x, y) {
19084 var type, xOffset, yOffset, size, cornerRadius;
19085 var style = options.pointStyle;
19086 var rotation = options.rotation;
19087 var radius = options.radius;
19088 var rad = (rotation || 0) * RAD_PER_DEG;
19089 if (style && typeof style === "object") {
19090 type = style.toString();
19091 if (type === "[object HTMLImageElement]" || type === "[object HTMLCanvasElement]") {
19092 ctx.save();
19093 ctx.translate(x, y);
19094 ctx.rotate(rad);
19095 ctx.drawImage(style, -style.width / 2, -style.height / 2, style.width, style.height);
19096 ctx.restore();
19097 return;
19098 }
19099 }
19100 if (isNaN(radius) || radius <= 0) return;
19101 ctx.beginPath();
19102 switch(style){
19103 default:
19104 ctx.arc(x, y, radius, 0, TAU);
19105 ctx.closePath();
19106 break;
19107 case "triangle":
19108 ctx.moveTo(x + Math.sin(rad) * radius, y - Math.cos(rad) * radius);
19109 rad += TWO_THIRDS_PI;
19110 ctx.lineTo(x + Math.sin(rad) * radius, y - Math.cos(rad) * radius);
19111 rad += TWO_THIRDS_PI;
19112 ctx.lineTo(x + Math.sin(rad) * radius, y - Math.cos(rad) * radius);
19113 ctx.closePath();
19114 break;
19115 case "rectRounded":
19116 cornerRadius = radius * 0.516;
19117 size = radius - cornerRadius;
19118 xOffset = Math.cos(rad + QUARTER_PI) * size;
19119 yOffset = Math.sin(rad + QUARTER_PI) * size;
19120 ctx.arc(x - xOffset, y - yOffset, cornerRadius, rad - PI, rad - HALF_PI);
19121 ctx.arc(x + yOffset, y - xOffset, cornerRadius, rad - HALF_PI, rad);
19122 ctx.arc(x + xOffset, y + yOffset, cornerRadius, rad, rad + HALF_PI);
19123 ctx.arc(x - yOffset, y + xOffset, cornerRadius, rad + HALF_PI, rad + PI);
19124 ctx.closePath();
19125 break;
19126 case "rect":
19127 if (!rotation) {
19128 size = Math.SQRT1_2 * radius;
19129 ctx.rect(x - size, y - size, 2 * size, 2 * size);
19130 break;
19131 }
19132 rad += QUARTER_PI;
19133 case "rectRot":
19134 xOffset = Math.cos(rad) * radius;
19135 yOffset = Math.sin(rad) * radius;
19136 ctx.moveTo(x - xOffset, y - yOffset);
19137 ctx.lineTo(x + yOffset, y - xOffset);
19138 ctx.lineTo(x + xOffset, y + yOffset);
19139 ctx.lineTo(x - yOffset, y + xOffset);
19140 ctx.closePath();
19141 break;
19142 case "crossRot":
19143 rad += QUARTER_PI;
19144 case "cross":
19145 xOffset = Math.cos(rad) * radius;
19146 yOffset = Math.sin(rad) * radius;
19147 ctx.moveTo(x - xOffset, y - yOffset);
19148 ctx.lineTo(x + xOffset, y + yOffset);
19149 ctx.moveTo(x + yOffset, y - xOffset);
19150 ctx.lineTo(x - yOffset, y + xOffset);
19151 break;
19152 case "star":
19153 xOffset = Math.cos(rad) * radius;
19154 yOffset = Math.sin(rad) * radius;
19155 ctx.moveTo(x - xOffset, y - yOffset);
19156 ctx.lineTo(x + xOffset, y + yOffset);
19157 ctx.moveTo(x + yOffset, y - xOffset);
19158 ctx.lineTo(x - yOffset, y + xOffset);
19159 rad += QUARTER_PI;
19160 xOffset = Math.cos(rad) * radius;
19161 yOffset = Math.sin(rad) * radius;
19162 ctx.moveTo(x - xOffset, y - yOffset);
19163 ctx.lineTo(x + xOffset, y + yOffset);
19164 ctx.moveTo(x + yOffset, y - xOffset);
19165 ctx.lineTo(x - yOffset, y + xOffset);
19166 break;
19167 case "line":
19168 xOffset = Math.cos(rad) * radius;
19169 yOffset = Math.sin(rad) * radius;
19170 ctx.moveTo(x - xOffset, y - yOffset);
19171 ctx.lineTo(x + xOffset, y + yOffset);
19172 break;
19173 case "dash":
19174 ctx.moveTo(x, y);
19175 ctx.lineTo(x + Math.cos(rad) * radius, y + Math.sin(rad) * radius);
19176 break;
19177 }
19178 ctx.fill();
19179 if (options.borderWidth > 0) ctx.stroke();
19180 }
19181 function _isPointInArea(point, area, margin) {
19182 margin = margin || 0.5;
19183 return !area || point && point.x > area.left - margin && point.x < area.right + margin && point.y > area.top - margin && point.y < area.bottom + margin;
19184 }
19185 function clipArea(ctx, area) {
19186 ctx.save();
19187 ctx.beginPath();
19188 ctx.rect(area.left, area.top, area.right - area.left, area.bottom - area.top);
19189 ctx.clip();
19190 }
19191 function unclipArea(ctx) {
19192 ctx.restore();
19193 }
19194 function _steppedLineTo(ctx, previous, target, flip, mode) {
19195 if (!previous) return ctx.lineTo(target.x, target.y);
19196 if (mode === "middle") {
19197 var midpoint = (previous.x + target.x) / 2.0;
19198 ctx.lineTo(midpoint, previous.y);
19199 ctx.lineTo(midpoint, target.y);
19200 } else if (mode === "after" !== !!flip) ctx.lineTo(previous.x, target.y);
19201 else ctx.lineTo(target.x, previous.y);
19202 ctx.lineTo(target.x, target.y);
19203 }
19204 function _bezierCurveTo(ctx, previous, target, flip) {
19205 if (!previous) return ctx.lineTo(target.x, target.y);
19206 ctx.bezierCurveTo(flip ? previous.cp1x : previous.cp2x, flip ? previous.cp1y : previous.cp2y, flip ? target.cp2x : target.cp1x, flip ? target.cp2y : target.cp1y, target.x, target.y);
19207 }
19208 function renderText(ctx, text, x, y, font) {
19209 var opts = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : {};
19210 var lines = isArray(text) ? text : [
19211 text
19212 ];
19213 var stroke = opts.strokeWidth > 0 && opts.strokeColor !== "";
19214 var i, line;
19215 ctx.save();
19216 ctx.font = font.string;
19217 setRenderOpts(ctx, opts);
19218 for(i = 0; i < lines.length; ++i){
19219 line = lines[i];
19220 if (stroke) {
19221 if (opts.strokeColor) ctx.strokeStyle = opts.strokeColor;
19222 if (!isNullOrUndef(opts.strokeWidth)) ctx.lineWidth = opts.strokeWidth;
19223 ctx.strokeText(line, x, y, opts.maxWidth);
19224 }
19225 ctx.fillText(line, x, y, opts.maxWidth);
19226 decorateText(ctx, x, y, line, opts);
19227 y += font.lineHeight;
19228 }
19229 ctx.restore();
19230 }
19231 function setRenderOpts(ctx, opts) {
19232 if (opts.translation) ctx.translate(opts.translation[0], opts.translation[1]);
19233 if (!isNullOrUndef(opts.rotation)) ctx.rotate(opts.rotation);
19234 if (opts.color) ctx.fillStyle = opts.color;
19235 if (opts.textAlign) ctx.textAlign = opts.textAlign;
19236 if (opts.textBaseline) ctx.textBaseline = opts.textBaseline;
19237 }
19238 function decorateText(ctx, x, y, line, opts) {
19239 if (opts.strikethrough || opts.underline) {
19240 var metrics = ctx.measureText(line);
19241 var left = x - metrics.actualBoundingBoxLeft;
19242 var right = x + metrics.actualBoundingBoxRight;
19243 var top = y - metrics.actualBoundingBoxAscent;
19244 var bottom = y + metrics.actualBoundingBoxDescent;
19245 var yDecoration = opts.strikethrough ? (top + bottom) / 2 : bottom;
19246 ctx.strokeStyle = ctx.fillStyle;
19247 ctx.beginPath();
19248 ctx.lineWidth = opts.decorationWidth || 2;
19249 ctx.moveTo(left, yDecoration);
19250 ctx.lineTo(right, yDecoration);
19251 ctx.stroke();
19252 }
19253 }
19254 function addRoundedRectPath(ctx, rect) {
19255 var x = rect.x, y = rect.y, w = rect.w, h = rect.h, radius = rect.radius;
19256 ctx.arc(x + radius.topLeft, y + radius.topLeft, radius.topLeft, -HALF_PI, PI, true);
19257 ctx.lineTo(x, y + h - radius.bottomLeft);
19258 ctx.arc(x + radius.bottomLeft, y + h - radius.bottomLeft, radius.bottomLeft, PI, HALF_PI, true);
19259 ctx.lineTo(x + w - radius.bottomRight, y + h);
19260 ctx.arc(x + w - radius.bottomRight, y + h - radius.bottomRight, radius.bottomRight, HALF_PI, 0, true);
19261 ctx.lineTo(x + w, y + radius.topRight);
19262 ctx.arc(x + w - radius.topRight, y + radius.topRight, radius.topRight, 0, -HALF_PI, true);
19263 ctx.lineTo(x + radius.topLeft, y);
19264 }
19265 var LINE_HEIGHT = new RegExp(/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/);
19266 var FONT_STYLE = new RegExp(/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/);
19267 function toLineHeight(value, size) {
19268 var matches = ("" + value).match(LINE_HEIGHT);
19269 if (!matches || matches[1] === "normal") return size * 1.2;
19270 value = +matches[2];
19271 switch(matches[3]){
19272 case "px":
19273 return value;
19274 case "%":
19275 value /= 100;
19276 break;
19277 }
19278 return size * value;
19279 }
19280 var numberOrZero = function(v) {
19281 return +v || 0;
19282 };
19283 function _readValueToProps(value, props) {
19284 var ret = {};
19285 var objProps = isObject(props);
19286 var keys = objProps ? Object.keys(props) : props;
19287 var read = isObject(value) ? objProps ? function(prop) {
19288 return valueOrDefault(value[prop], value[props[prop]]);
19289 } : function(prop) {
19290 return value[prop];
19291 } : function() {
19292 return value;
19293 };
19294 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
19295 try {
19296 for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
19297 var prop1 = _step.value;
19298 ret[prop1] = numberOrZero(read(prop1));
19299 }
19300 } catch (err) {
19301 _didIteratorError = true;
19302 _iteratorError = err;
19303 } finally{
19304 try {
19305 if (!_iteratorNormalCompletion && _iterator.return != null) {
19306 _iterator.return();
19307 }
19308 } finally{
19309 if (_didIteratorError) {
19310 throw _iteratorError;
19311 }
19312 }
19313 }
19314 return ret;
19315 }
19316 function toTRBL(value) {
19317 return _readValueToProps(value, {
19318 top: "y",
19319 right: "x",
19320 bottom: "y",
19321 left: "x"
19322 });
19323 }
19324 function toTRBLCorners(value) {
19325 return _readValueToProps(value, [
19326 "topLeft",
19327 "topRight",
19328 "bottomLeft",
19329 "bottomRight"
19330 ]);
19331 }
19332 function toPadding(value) {
19333 var obj = toTRBL(value);
19334 obj.width = obj.left + obj.right;
19335 obj.height = obj.top + obj.bottom;
19336 return obj;
19337 }
19338 function toFont(options, fallback) {
19339 options = options || {};
19340 fallback = fallback || defaults.font;
19341 var size = valueOrDefault(options.size, fallback.size);
19342 if (typeof size === "string") size = parseInt(size, 10);
19343 var style = valueOrDefault(options.style, fallback.style);
19344 if (style && !("" + style).match(FONT_STYLE)) {
19345 console.warn('Invalid font style specified: "' + style + '"');
19346 style = "";
19347 }
19348 var font = {
19349 family: valueOrDefault(options.family, fallback.family),
19350 lineHeight: toLineHeight(valueOrDefault(options.lineHeight, fallback.lineHeight), size),
19351 size: size,
19352 style: style,
19353 weight: valueOrDefault(options.weight, fallback.weight),
19354 string: ""
19355 };
19356 font.string = toFontString(font);
19357 return font;
19358 }
19359 function resolve(inputs, context, index, info) {
19360 var cacheable = true;
19361 var i, ilen, value;
19362 for(i = 0, ilen = inputs.length; i < ilen; ++i){
19363 value = inputs[i];
19364 if (value === undefined) continue;
19365 if (context !== undefined && typeof value === "function") {
19366 value = value(context);
19367 cacheable = false;
19368 }
19369 if (index !== undefined && isArray(value)) {
19370 value = value[index % value.length];
19371 cacheable = false;
19372 }
19373 if (value !== undefined) {
19374 if (info && !cacheable) info.cacheable = false;
19375 return value;
19376 }
19377 }
19378 }
19379 function _addGrace(minmax, grace, beginAtZero) {
19380 var min = minmax.min, max = minmax.max;
19381 var change = toDimension(grace, (max - min) / 2);
19382 var keepZero = function(value, add) {
19383 return beginAtZero && value === 0 ? 0 : value + add;
19384 };
19385 return {
19386 min: keepZero(min, -Math.abs(change)),
19387 max: keepZero(max, change)
19388 };
19389 }
19390 function createContext(parentContext, context) {
19391 return Object.assign(Object.create(parentContext), context);
19392 }
19393 function _lookup(table, value, cmp) {
19394 cmp = cmp || function(index) {
19395 return table[index] < value;
19396 };
19397 var hi = table.length - 1;
19398 var lo = 0;
19399 var mid;
19400 while(hi - lo > 1){
19401 mid = lo + hi >> 1;
19402 if (cmp(mid)) lo = mid;
19403 else hi = mid;
19404 }
19405 return {
19406 lo: lo,
19407 hi: hi
19408 };
19409 }
19410 var _lookupByKey = function(table, key, value) {
19411 return _lookup(table, value, function(index) {
19412 return table[index][key] < value;
19413 });
19414 };
19415 var _rlookupByKey = function(table, key, value) {
19416 return _lookup(table, value, function(index) {
19417 return table[index][key] >= value;
19418 });
19419 };
19420 function _filterBetween(values, min, max) {
19421 var start = 0;
19422 var end = values.length;
19423 while(start < end && values[start] < min)start++;
19424 while(end > start && values[end - 1] > max)end--;
19425 return start > 0 || end < values.length ? values.slice(start, end) : values;
19426 }
19427 var arrayEvents = [
19428 "push",
19429 "pop",
19430 "shift",
19431 "splice",
19432 "unshift"
19433 ];
19434 function listenArrayEvents(array, listener) {
19435 if (array._chartjs) {
19436 array._chartjs.listeners.push(listener);
19437 return;
19438 }
19439 Object.defineProperty(array, "_chartjs", {
19440 configurable: true,
19441 enumerable: false,
19442 value: {
19443 listeners: [
19444 listener
19445 ]
19446 }
19447 });
19448 arrayEvents.forEach(function(key) {
19449 var method = "_onData" + _capitalize(key);
19450 var base = array[key];
19451 Object.defineProperty(array, key, {
19452 configurable: true,
19453 enumerable: false,
19454 value: function() {
19455 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
19456 args[_key] = arguments[_key];
19457 }
19458 var res = base.apply(this, args);
19459 array._chartjs.listeners.forEach(function(object) {
19460 var _object;
19461 if (typeof object[method] === "function") (_object = object)[method].apply(_object, (0, _toConsumableArrayJsDefault.default)(args));
19462 });
19463 return res;
19464 }
19465 });
19466 });
19467 }
19468 function unlistenArrayEvents(array, listener) {
19469 var stub = array._chartjs;
19470 if (!stub) return;
19471 var listeners = stub.listeners;
19472 var index = listeners.indexOf(listener);
19473 if (index !== -1) listeners.splice(index, 1);
19474 if (listeners.length > 0) return;
19475 arrayEvents.forEach(function(key) {
19476 delete array[key];
19477 });
19478 delete array._chartjs;
19479 }
19480 function _arrayUnique(items) {
19481 var set2 = new Set();
19482 var i, ilen;
19483 for(i = 0, ilen = items.length; i < ilen; ++i)set2.add(items[i]);
19484 if (set2.size === ilen) return items;
19485 return Array.from(set2);
19486 }
19487 function _createResolver(scopes) {
19488 var prefixes = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [
19489 ""
19490 ], rootScopes = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : scopes, fallback = arguments.length > 3 ? arguments[3] : void 0, getTarget = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : function() {
19491 return scopes[0];
19492 };
19493 if (!defined(fallback)) fallback = _resolve("_fallback", scopes);
19494 var _obj;
19495 var cache = (_obj = {}, (0, _definePropertyJsDefault.default)(_obj, Symbol.toStringTag, "Object"), (0, _definePropertyJsDefault.default)(_obj, "_cacheable", true), (0, _definePropertyJsDefault.default)(_obj, "_scopes", scopes), (0, _definePropertyJsDefault.default)(_obj, "_rootScopes", rootScopes), (0, _definePropertyJsDefault.default)(_obj, "_fallback", fallback), (0, _definePropertyJsDefault.default)(_obj, "_getTarget", getTarget), (0, _definePropertyJsDefault.default)(_obj, "override", function(scope) {
19496 return _createResolver([
19497 scope
19498 ].concat((0, _toConsumableArrayJsDefault.default)(scopes)), prefixes, rootScopes, fallback);
19499 }), _obj);
19500 return new Proxy(cache, {
19501 deleteProperty: function(target, prop) {
19502 delete target[prop];
19503 delete target._keys;
19504 delete scopes[0][prop];
19505 return true;
19506 },
19507 get: function(target, prop) {
19508 return _cached(target, prop, function() {
19509 return _resolveWithPrefixes(prop, prefixes, scopes, target);
19510 });
19511 },
19512 getOwnPropertyDescriptor: function(target, prop) {
19513 return Reflect.getOwnPropertyDescriptor(target._scopes[0], prop);
19514 },
19515 getPrototypeOf: function() {
19516 return Reflect.getPrototypeOf(scopes[0]);
19517 },
19518 has: function(target, prop) {
19519 return getKeysFromAllScopes(target).includes(prop);
19520 },
19521 ownKeys: function(target) {
19522 return getKeysFromAllScopes(target);
19523 },
19524 set: function(target, prop, value) {
19525 var storage = target._storage || (target._storage = getTarget());
19526 target[prop] = storage[prop] = value;
19527 delete target._keys;
19528 return true;
19529 }
19530 });
19531 }
19532 function _attachContext(proxy, context, subProxy, descriptorDefaults) {
19533 var cache = {
19534 _cacheable: false,
19535 _proxy: proxy,
19536 _context: context,
19537 _subProxy: subProxy,
19538 _stack: new Set(),
19539 _descriptors: _descriptors(proxy, descriptorDefaults),
19540 setContext: function(ctx) {
19541 return _attachContext(proxy, ctx, subProxy, descriptorDefaults);
19542 },
19543 override: function(scope) {
19544 return _attachContext(proxy.override(scope), context, subProxy, descriptorDefaults);
19545 }
19546 };
19547 return new Proxy(cache, {
19548 deleteProperty: function(target, prop) {
19549 delete target[prop];
19550 delete proxy[prop];
19551 return true;
19552 },
19553 get: function(target, prop, receiver) {
19554 return _cached(target, prop, function() {
19555 return _resolveWithContext(target, prop, receiver);
19556 });
19557 },
19558 getOwnPropertyDescriptor: function(target, prop) {
19559 return target._descriptors.allKeys ? Reflect.has(proxy, prop) ? {
19560 enumerable: true,
19561 configurable: true
19562 } : undefined : Reflect.getOwnPropertyDescriptor(proxy, prop);
19563 },
19564 getPrototypeOf: function() {
19565 return Reflect.getPrototypeOf(proxy);
19566 },
19567 has: function(target, prop) {
19568 return Reflect.has(proxy, prop);
19569 },
19570 ownKeys: function() {
19571 return Reflect.ownKeys(proxy);
19572 },
19573 set: function(target, prop, value) {
19574 proxy[prop] = value;
19575 delete target[prop];
19576 return true;
19577 }
19578 });
19579 }
19580 function _descriptors(proxy) {
19581 var defaults1 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
19582 scriptable: true,
19583 indexable: true
19584 };
19585 var __scriptable = proxy._scriptable, _scriptable = __scriptable === void 0 ? defaults1.scriptable : __scriptable, __indexable = proxy._indexable, _indexable = __indexable === void 0 ? defaults1.indexable : __indexable, __allKeys = proxy._allKeys, _allKeys = __allKeys === void 0 ? defaults1.allKeys : __allKeys;
19586 return {
19587 allKeys: _allKeys,
19588 scriptable: _scriptable,
19589 indexable: _indexable,
19590 isScriptable: isFunction(_scriptable) ? _scriptable : function() {
19591 return _scriptable;
19592 },
19593 isIndexable: isFunction(_indexable) ? _indexable : function() {
19594 return _indexable;
19595 }
19596 };
19597 }
19598 var readKey = function(prefix, name) {
19599 return prefix ? prefix + _capitalize(name) : name;
19600 };
19601 var needsSubResolver = function(prop, value) {
19602 return isObject(value) && prop !== "adapters" && (Object.getPrototypeOf(value) === null || value.constructor === Object);
19603 };
19604 function _cached(target, prop, resolve1) {
19605 if (Object.prototype.hasOwnProperty.call(target, prop)) return target[prop];
19606 var value = resolve1();
19607 target[prop] = value;
19608 return value;
19609 }
19610 function _resolveWithContext(target, prop, receiver) {
19611 var _proxy = target._proxy, _context = target._context, _subProxy = target._subProxy, descriptors1 = target._descriptors;
19612 var value = _proxy[prop];
19613 if (isFunction(value) && descriptors1.isScriptable(prop)) value = _resolveScriptable(prop, value, target, receiver);
19614 if (isArray(value) && value.length) value = _resolveArray(prop, value, target, descriptors1.isIndexable);
19615 if (needsSubResolver(prop, value)) value = _attachContext(value, _context, _subProxy && _subProxy[prop], descriptors1);
19616 return value;
19617 }
19618 function _resolveScriptable(prop, value, target, receiver) {
19619 var _proxy = target._proxy, _context = target._context, _subProxy = target._subProxy, _stack = target._stack;
19620 if (_stack.has(prop)) throw new Error("Recursion detected: " + Array.from(_stack).join("->") + "->" + prop);
19621 _stack.add(prop);
19622 value = value(_context, _subProxy || receiver);
19623 _stack.delete(prop);
19624 if (needsSubResolver(prop, value)) value = createSubResolver(_proxy._scopes, _proxy, prop, value);
19625 return value;
19626 }
19627 function _resolveArray(prop, value, target, isIndexable) {
19628 var _proxy = target._proxy, _context = target._context, _subProxy = target._subProxy, descriptors2 = target._descriptors;
19629 if (defined(_context.index) && isIndexable(prop)) value = value[_context.index % value.length];
19630 else if (isObject(value[0])) {
19631 var arr = value;
19632 var scopes = _proxy._scopes.filter(function(s) {
19633 return s !== arr;
19634 });
19635 value = [];
19636 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
19637 try {
19638 for(var _iterator = arr[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
19639 var item = _step.value;
19640 var resolver = createSubResolver(scopes, _proxy, prop, item);
19641 value.push(_attachContext(resolver, _context, _subProxy && _subProxy[prop], descriptors2));
19642 }
19643 } catch (err) {
19644 _didIteratorError = true;
19645 _iteratorError = err;
19646 } finally{
19647 try {
19648 if (!_iteratorNormalCompletion && _iterator.return != null) {
19649 _iterator.return();
19650 }
19651 } finally{
19652 if (_didIteratorError) {
19653 throw _iteratorError;
19654 }
19655 }
19656 }
19657 }
19658 return value;
19659 }
19660 function resolveFallback(fallback, prop, value) {
19661 return isFunction(fallback) ? fallback(prop, value) : fallback;
19662 }
19663 var getScope = function(key, parent) {
19664 return key === true ? parent : typeof key === "string" ? resolveObjectKey(parent, key) : undefined;
19665 };
19666 function addScopes(set3, parentScopes, key, parentFallback, value) {
19667 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
19668 try {
19669 for(var _iterator = parentScopes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
19670 var parent = _step.value;
19671 var scope = getScope(key, parent);
19672 if (scope) {
19673 set3.add(scope);
19674 var fallback = resolveFallback(scope._fallback, key, value);
19675 if (defined(fallback) && fallback !== key && fallback !== parentFallback) return fallback;
19676 } else if (scope === false && defined(parentFallback) && key !== parentFallback) return null;
19677 }
19678 } catch (err) {
19679 _didIteratorError = true;
19680 _iteratorError = err;
19681 } finally{
19682 try {
19683 if (!_iteratorNormalCompletion && _iterator.return != null) {
19684 _iterator.return();
19685 }
19686 } finally{
19687 if (_didIteratorError) {
19688 throw _iteratorError;
19689 }
19690 }
19691 }
19692 return false;
19693 }
19694 function createSubResolver(parentScopes, resolver, prop, value) {
19695 var rootScopes = resolver._rootScopes;
19696 var fallback = resolveFallback(resolver._fallback, prop, value);
19697 var allScopes = (0, _toConsumableArrayJsDefault.default)(parentScopes).concat((0, _toConsumableArrayJsDefault.default)(rootScopes));
19698 var set4 = new Set();
19699 set4.add(value);
19700 var key = addScopesFromKey(set4, allScopes, prop, fallback || prop, value);
19701 if (key === null) return false;
19702 if (defined(fallback) && fallback !== prop) {
19703 key = addScopesFromKey(set4, allScopes, fallback, key, value);
19704 if (key === null) return false;
19705 }
19706 return _createResolver(Array.from(set4), [
19707 ""
19708 ], rootScopes, fallback, function() {
19709 return subGetTarget(resolver, prop, value);
19710 });
19711 }
19712 function addScopesFromKey(set5, allScopes, key, fallback, item) {
19713 while(key)key = addScopes(set5, allScopes, key, fallback, item);
19714 return key;
19715 }
19716 function subGetTarget(resolver, prop, value) {
19717 var parent = resolver._getTarget();
19718 if (!(prop in parent)) parent[prop] = {};
19719 var target = parent[prop];
19720 if (isArray(target) && isObject(value)) return value;
19721 return target;
19722 }
19723 function _resolveWithPrefixes(prop, prefixes, scopes, proxy) {
19724 var value;
19725 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
19726 try {
19727 for(var _iterator = prefixes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
19728 var prefix = _step.value;
19729 value = _resolve(readKey(prefix, prop), scopes);
19730 if (defined(value)) return needsSubResolver(prop, value) ? createSubResolver(scopes, proxy, prop, value) : value;
19731 }
19732 } catch (err) {
19733 _didIteratorError = true;
19734 _iteratorError = err;
19735 } finally{
19736 try {
19737 if (!_iteratorNormalCompletion && _iterator.return != null) {
19738 _iterator.return();
19739 }
19740 } finally{
19741 if (_didIteratorError) {
19742 throw _iteratorError;
19743 }
19744 }
19745 }
19746 }
19747 function _resolve(key, scopes) {
19748 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
19749 try {
19750 for(var _iterator = scopes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
19751 var scope = _step.value;
19752 if (!scope) continue;
19753 var value = scope[key];
19754 if (defined(value)) return value;
19755 }
19756 } catch (err) {
19757 _didIteratorError = true;
19758 _iteratorError = err;
19759 } finally{
19760 try {
19761 if (!_iteratorNormalCompletion && _iterator.return != null) {
19762 _iterator.return();
19763 }
19764 } finally{
19765 if (_didIteratorError) {
19766 throw _iteratorError;
19767 }
19768 }
19769 }
19770 }
19771 function getKeysFromAllScopes(target) {
19772 var keys = target._keys;
19773 if (!keys) keys = target._keys = resolveKeysFromAllScopes(target._scopes);
19774 return keys;
19775 }
19776 function resolveKeysFromAllScopes(scopes) {
19777 var set6 = new Set();
19778 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined, _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
19779 try {
19780 for(var _iterator = scopes[Symbol.iterator](), _step; !(_iteratorNormalCompletion1 = (_step = _iterator.next()).done); _iteratorNormalCompletion1 = true){
19781 var scope = _step.value;
19782 try {
19783 for(var _iterator1 = Object.keys(scope).filter(function(k) {
19784 return !k.startsWith("_");
19785 })[Symbol.iterator](), _step1; !(_iteratorNormalCompletion = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion = true){
19786 var key = _step1.value;
19787 set6.add(key);
19788 }
19789 } catch (err) {
19790 _didIteratorError = true;
19791 _iteratorError = err;
19792 } finally{
19793 try {
19794 if (!_iteratorNormalCompletion && _iterator1.return != null) {
19795 _iterator1.return();
19796 }
19797 } finally{
19798 if (_didIteratorError) {
19799 throw _iteratorError;
19800 }
19801 }
19802 }
19803 }
19804 } catch (err) {
19805 _didIteratorError1 = true;
19806 _iteratorError1 = err;
19807 } finally{
19808 try {
19809 if (!_iteratorNormalCompletion1 && _iterator.return != null) {
19810 _iterator.return();
19811 }
19812 } finally{
19813 if (_didIteratorError1) {
19814 throw _iteratorError1;
19815 }
19816 }
19817 }
19818 return Array.from(set6);
19819 }
19820 function _parseObjectDataRadialScale(meta, data, start, count) {
19821 var iScale = meta.iScale;
19822 var __parsing = this._parsing, _key = __parsing.key, key = _key === void 0 ? "r" : _key;
19823 var parsed = new Array(count);
19824 var i, ilen, index, item;
19825 for(i = 0, ilen = count; i < ilen; ++i){
19826 index = i + start;
19827 item = data[index];
19828 parsed[i] = {
19829 r: iScale.parse(resolveObjectKey(item, key), index)
19830 };
19831 }
19832 return parsed;
19833 }
19834 var EPSILON = Number.EPSILON || 1e-14;
19835 var getPoint = function(points, i) {
19836 return i < points.length && !points[i].skip && points[i];
19837 };
19838 var getValueAxis = function(indexAxis) {
19839 return indexAxis === "x" ? "y" : "x";
19840 };
19841 function splineCurve(firstPoint, middlePoint, afterPoint, t) {
19842 var previous = firstPoint.skip ? middlePoint : firstPoint;
19843 var current = middlePoint;
19844 var next = afterPoint.skip ? middlePoint : afterPoint;
19845 var d01 = distanceBetweenPoints(current, previous);
19846 var d12 = distanceBetweenPoints(next, current);
19847 var s01 = d01 / (d01 + d12);
19848 var s12 = d12 / (d01 + d12);
19849 s01 = isNaN(s01) ? 0 : s01;
19850 s12 = isNaN(s12) ? 0 : s12;
19851 var fa = t * s01;
19852 var fb = t * s12;
19853 return {
19854 previous: {
19855 x: current.x - fa * (next.x - previous.x),
19856 y: current.y - fa * (next.y - previous.y)
19857 },
19858 next: {
19859 x: current.x + fb * (next.x - previous.x),
19860 y: current.y + fb * (next.y - previous.y)
19861 }
19862 };
19863 }
19864 function monotoneAdjust(points, deltaK, mK) {
19865 var pointsLen = points.length;
19866 var alphaK, betaK, tauK, squaredMagnitude, pointCurrent;
19867 var pointAfter = getPoint(points, 0);
19868 for(var i = 0; i < pointsLen - 1; ++i){
19869 pointCurrent = pointAfter;
19870 pointAfter = getPoint(points, i + 1);
19871 if (!pointCurrent || !pointAfter) continue;
19872 if (almostEquals(deltaK[i], 0, EPSILON)) {
19873 mK[i] = mK[i + 1] = 0;
19874 continue;
19875 }
19876 alphaK = mK[i] / deltaK[i];
19877 betaK = mK[i + 1] / deltaK[i];
19878 squaredMagnitude = Math.pow(alphaK, 2) + Math.pow(betaK, 2);
19879 if (squaredMagnitude <= 9) continue;
19880 tauK = 3 / Math.sqrt(squaredMagnitude);
19881 mK[i] = alphaK * tauK * deltaK[i];
19882 mK[i + 1] = betaK * tauK * deltaK[i];
19883 }
19884 }
19885 function monotoneCompute(points, mK) {
19886 var indexAxis = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "x";
19887 var valueAxis = getValueAxis(indexAxis);
19888 var pointsLen = points.length;
19889 var delta, pointBefore, pointCurrent;
19890 var pointAfter = getPoint(points, 0);
19891 for(var i = 0; i < pointsLen; ++i){
19892 pointBefore = pointCurrent;
19893 pointCurrent = pointAfter;
19894 pointAfter = getPoint(points, i + 1);
19895 if (!pointCurrent) continue;
19896 var iPixel = pointCurrent[indexAxis];
19897 var vPixel = pointCurrent[valueAxis];
19898 if (pointBefore) {
19899 delta = (iPixel - pointBefore[indexAxis]) / 3;
19900 pointCurrent["cp1".concat(indexAxis)] = iPixel - delta;
19901 pointCurrent["cp1".concat(valueAxis)] = vPixel - delta * mK[i];
19902 }
19903 if (pointAfter) {
19904 delta = (pointAfter[indexAxis] - iPixel) / 3;
19905 pointCurrent["cp2".concat(indexAxis)] = iPixel + delta;
19906 pointCurrent["cp2".concat(valueAxis)] = vPixel + delta * mK[i];
19907 }
19908 }
19909 }
19910 function splineCurveMonotone(points) {
19911 var indexAxis = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "x";
19912 var valueAxis = getValueAxis(indexAxis);
19913 var pointsLen = points.length;
19914 var deltaK = Array(pointsLen).fill(0);
19915 var mK = Array(pointsLen);
19916 var i, pointBefore, pointCurrent;
19917 var pointAfter = getPoint(points, 0);
19918 for(i = 0; i < pointsLen; ++i){
19919 pointBefore = pointCurrent;
19920 pointCurrent = pointAfter;
19921 pointAfter = getPoint(points, i + 1);
19922 if (!pointCurrent) continue;
19923 if (pointAfter) {
19924 var slopeDelta = pointAfter[indexAxis] - pointCurrent[indexAxis];
19925 deltaK[i] = slopeDelta !== 0 ? (pointAfter[valueAxis] - pointCurrent[valueAxis]) / slopeDelta : 0;
19926 }
19927 mK[i] = !pointBefore ? deltaK[i] : !pointAfter ? deltaK[i - 1] : sign(deltaK[i - 1]) !== sign(deltaK[i]) ? 0 : (deltaK[i - 1] + deltaK[i]) / 2;
19928 }
19929 monotoneAdjust(points, deltaK, mK);
19930 monotoneCompute(points, mK, indexAxis);
19931 }
19932 function capControlPoint(pt, min, max) {
19933 return Math.max(Math.min(pt, max), min);
19934 }
19935 function capBezierPoints(points, area) {
19936 var i, ilen, point, inArea, inAreaPrev;
19937 var inAreaNext = _isPointInArea(points[0], area);
19938 for(i = 0, ilen = points.length; i < ilen; ++i){
19939 inAreaPrev = inArea;
19940 inArea = inAreaNext;
19941 inAreaNext = i < ilen - 1 && _isPointInArea(points[i + 1], area);
19942 if (!inArea) continue;
19943 point = points[i];
19944 if (inAreaPrev) {
19945 point.cp1x = capControlPoint(point.cp1x, area.left, area.right);
19946 point.cp1y = capControlPoint(point.cp1y, area.top, area.bottom);
19947 }
19948 if (inAreaNext) {
19949 point.cp2x = capControlPoint(point.cp2x, area.left, area.right);
19950 point.cp2y = capControlPoint(point.cp2y, area.top, area.bottom);
19951 }
19952 }
19953 }
19954 function _updateBezierControlPoints(points, options, area, loop, indexAxis) {
19955 var i, ilen, point, controlPoints;
19956 if (options.spanGaps) points = points.filter(function(pt) {
19957 return !pt.skip;
19958 });
19959 if (options.cubicInterpolationMode === "monotone") splineCurveMonotone(points, indexAxis);
19960 else {
19961 var prev = loop ? points[points.length - 1] : points[0];
19962 for(i = 0, ilen = points.length; i < ilen; ++i){
19963 point = points[i];
19964 controlPoints = splineCurve(prev, point, points[Math.min(i + 1, ilen - (loop ? 0 : 1)) % ilen], options.tension);
19965 point.cp1x = controlPoints.previous.x;
19966 point.cp1y = controlPoints.previous.y;
19967 point.cp2x = controlPoints.next.x;
19968 point.cp2y = controlPoints.next.y;
19969 prev = point;
19970 }
19971 }
19972 if (options.capBezierPoints) capBezierPoints(points, area);
19973 }
19974 function _isDomSupported() {
19975 return typeof window !== "undefined" && typeof document !== "undefined";
19976 }
19977 function _getParentNode(domNode) {
19978 var parent = domNode.parentNode;
19979 if (parent && parent.toString() === "[object ShadowRoot]") parent = parent.host;
19980 return parent;
19981 }
19982 function parseMaxStyle(styleValue, node, parentProperty) {
19983 var valueInPixels;
19984 if (typeof styleValue === "string") {
19985 valueInPixels = parseInt(styleValue, 10);
19986 if (styleValue.indexOf("%") !== -1) valueInPixels = valueInPixels / 100 * node.parentNode[parentProperty];
19987 } else valueInPixels = styleValue;
19988 return valueInPixels;
19989 }
19990 var getComputedStyle = function(element) {
19991 return window.getComputedStyle(element, null);
19992 };
19993 function getStyle(el, property) {
19994 return getComputedStyle(el).getPropertyValue(property);
19995 }
19996 var positions = [
19997 "top",
19998 "right",
19999 "bottom",
20000 "left"
20001 ];
20002 function getPositionedStyle(styles, style, suffix) {
20003 var result = {};
20004 suffix = suffix ? "-" + suffix : "";
20005 for(var i = 0; i < 4; i++){
20006 var pos = positions[i];
20007 result[pos] = parseFloat(styles[style + "-" + pos + suffix]) || 0;
20008 }
20009 result.width = result.left + result.right;
20010 result.height = result.top + result.bottom;
20011 return result;
20012 }
20013 var useOffsetPos = function(x, y, target) {
20014 return (x > 0 || y > 0) && (!target || !target.shadowRoot);
20015 };
20016 function getCanvasPosition(e, canvas) {
20017 var touches = e.touches;
20018 var source = touches && touches.length ? touches[0] : e;
20019 var offsetX = source.offsetX, offsetY = source.offsetY;
20020 var box = false;
20021 var x, y;
20022 if (useOffsetPos(offsetX, offsetY, e.target)) {
20023 x = offsetX;
20024 y = offsetY;
20025 } else {
20026 var rect = canvas.getBoundingClientRect();
20027 x = source.clientX - rect.left;
20028 y = source.clientY - rect.top;
20029 box = true;
20030 }
20031 return {
20032 x: x,
20033 y: y,
20034 box: box
20035 };
20036 }
20037 function getRelativePosition(evt, chart) {
20038 if ("native" in evt) return evt;
20039 var canvas = chart.canvas, currentDevicePixelRatio = chart.currentDevicePixelRatio;
20040 var style = getComputedStyle(canvas);
20041 var borderBox = style.boxSizing === "border-box";
20042 var paddings = getPositionedStyle(style, "padding");
20043 var borders = getPositionedStyle(style, "border", "width");
20044 var ref = getCanvasPosition(evt, canvas), x = ref.x, y = ref.y, box = ref.box;
20045 var xOffset = paddings.left + (box && borders.left);
20046 var yOffset = paddings.top + (box && borders.top);
20047 var width = chart.width, height = chart.height;
20048 if (borderBox) {
20049 width -= paddings.width + borders.width;
20050 height -= paddings.height + borders.height;
20051 }
20052 return {
20053 x: Math.round((x - xOffset) / width * canvas.width / currentDevicePixelRatio),
20054 y: Math.round((y - yOffset) / height * canvas.height / currentDevicePixelRatio)
20055 };
20056 }
20057 function getContainerSize(canvas, width, height) {
20058 var maxWidth, maxHeight;
20059 if (width === undefined || height === undefined) {
20060 var container = _getParentNode(canvas);
20061 if (!container) {
20062 width = canvas.clientWidth;
20063 height = canvas.clientHeight;
20064 } else {
20065 var rect = container.getBoundingClientRect();
20066 var containerStyle = getComputedStyle(container);
20067 var containerBorder = getPositionedStyle(containerStyle, "border", "width");
20068 var containerPadding = getPositionedStyle(containerStyle, "padding");
20069 width = rect.width - containerPadding.width - containerBorder.width;
20070 height = rect.height - containerPadding.height - containerBorder.height;
20071 maxWidth = parseMaxStyle(containerStyle.maxWidth, container, "clientWidth");
20072 maxHeight = parseMaxStyle(containerStyle.maxHeight, container, "clientHeight");
20073 }
20074 }
20075 return {
20076 width: width,
20077 height: height,
20078 maxWidth: maxWidth || INFINITY,
20079 maxHeight: maxHeight || INFINITY
20080 };
20081 }
20082 var round1 = function(v) {
20083 return Math.round(v * 10) / 10;
20084 };
20085 function getMaximumSize(canvas, bbWidth, bbHeight, aspectRatio) {
20086 var style = getComputedStyle(canvas);
20087 var margins = getPositionedStyle(style, "margin");
20088 var maxWidth = parseMaxStyle(style.maxWidth, canvas, "clientWidth") || INFINITY;
20089 var maxHeight = parseMaxStyle(style.maxHeight, canvas, "clientHeight") || INFINITY;
20090 var containerSize = getContainerSize(canvas, bbWidth, bbHeight);
20091 var width = containerSize.width, height = containerSize.height;
20092 if (style.boxSizing === "content-box") {
20093 var borders = getPositionedStyle(style, "border", "width");
20094 var paddings = getPositionedStyle(style, "padding");
20095 width -= paddings.width + borders.width;
20096 height -= paddings.height + borders.height;
20097 }
20098 width = Math.max(0, width - margins.width);
20099 height = Math.max(0, aspectRatio ? Math.floor(width / aspectRatio) : height - margins.height);
20100 width = round1(Math.min(width, maxWidth, containerSize.maxWidth));
20101 height = round1(Math.min(height, maxHeight, containerSize.maxHeight));
20102 if (width && !height) height = round1(width / 2);
20103 return {
20104 width: width,
20105 height: height
20106 };
20107 }
20108 function retinaScale(chart, forceRatio, forceStyle) {
20109 var pixelRatio = forceRatio || 1;
20110 var deviceHeight = Math.floor(chart.height * pixelRatio);
20111 var deviceWidth = Math.floor(chart.width * pixelRatio);
20112 chart.height = deviceHeight / pixelRatio;
20113 chart.width = deviceWidth / pixelRatio;
20114 var canvas = chart.canvas;
20115 if (canvas.style && (forceStyle || !canvas.style.height && !canvas.style.width)) {
20116 canvas.style.height = "".concat(chart.height, "px");
20117 canvas.style.width = "".concat(chart.width, "px");
20118 }
20119 if (chart.currentDevicePixelRatio !== pixelRatio || canvas.height !== deviceHeight || canvas.width !== deviceWidth) {
20120 chart.currentDevicePixelRatio = pixelRatio;
20121 canvas.height = deviceHeight;
20122 canvas.width = deviceWidth;
20123 chart.ctx.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0);
20124 return true;
20125 }
20126 return false;
20127 }
20128 var supportsEventListenerOptions = function() {
20129 var passiveSupported = false;
20130 try {
20131 var options = {
20132 get passive () {
20133 passiveSupported = true;
20134 return false;
20135 }
20136 };
20137 window.addEventListener("test", null, options);
20138 window.removeEventListener("test", null, options);
20139 } catch (e) {}
20140 return passiveSupported;
20141 }();
20142 function readUsedSize(element, property) {
20143 var value = getStyle(element, property);
20144 var matches = value && value.match(/^(\d+)(\.\d+)?px$/);
20145 return matches ? +matches[1] : undefined;
20146 }
20147 function _pointInLine(p1, p2, t, mode) {
20148 return {
20149 x: p1.x + t * (p2.x - p1.x),
20150 y: p1.y + t * (p2.y - p1.y)
20151 };
20152 }
20153 function _steppedInterpolation(p1, p2, t, mode) {
20154 return {
20155 x: p1.x + t * (p2.x - p1.x),
20156 y: mode === "middle" ? t < 0.5 ? p1.y : p2.y : mode === "after" ? t < 1 ? p1.y : p2.y : t > 0 ? p2.y : p1.y
20157 };
20158 }
20159 function _bezierInterpolation(p1, p2, t, mode) {
20160 var cp1 = {
20161 x: p1.cp2x,
20162 y: p1.cp2y
20163 };
20164 var cp2 = {
20165 x: p2.cp1x,
20166 y: p2.cp1y
20167 };
20168 var a = _pointInLine(p1, cp1, t);
20169 var b = _pointInLine(cp1, cp2, t);
20170 var c = _pointInLine(cp2, p2, t);
20171 var d = _pointInLine(a, b, t);
20172 var e = _pointInLine(b, c, t);
20173 return _pointInLine(d, e, t);
20174 }
20175 var intlCache = new Map();
20176 function getNumberFormat(locale, options) {
20177 options = options || {};
20178 var cacheKey = locale + JSON.stringify(options);
20179 var formatter = intlCache.get(cacheKey);
20180 if (!formatter) {
20181 formatter = new Intl.NumberFormat(locale, options);
20182 intlCache.set(cacheKey, formatter);
20183 }
20184 return formatter;
20185 }
20186 function formatNumber(num, locale, options) {
20187 return getNumberFormat(locale, options).format(num);
20188 }
20189 var getRightToLeftAdapter = function getRightToLeftAdapter(rectX, width) {
20190 return {
20191 x: function(x) {
20192 return rectX + rectX + width - x;
20193 },
20194 setWidth: function(w) {
20195 width = w;
20196 },
20197 textAlign: function(align) {
20198 if (align === "center") return align;
20199 return align === "right" ? "left" : "right";
20200 },
20201 xPlus: function(x, value) {
20202 return x - value;
20203 },
20204 leftForLtr: function(x, itemWidth) {
20205 return x - itemWidth;
20206 }
20207 };
20208 };
20209 var getLeftToRightAdapter = function getLeftToRightAdapter() {
20210 return {
20211 x: function(x) {
20212 return x;
20213 },
20214 setWidth: function(w) {},
20215 textAlign: function(align) {
20216 return align;
20217 },
20218 xPlus: function(x, value) {
20219 return x + value;
20220 },
20221 leftForLtr: function(x, _itemWidth) {
20222 return x;
20223 }
20224 };
20225 };
20226 function getRtlAdapter(rtl, rectX, width) {
20227 return rtl ? getRightToLeftAdapter(rectX, width) : getLeftToRightAdapter();
20228 }
20229 function overrideTextDirection(ctx, direction) {
20230 var style, original;
20231 if (direction === "ltr" || direction === "rtl") {
20232 style = ctx.canvas.style;
20233 original = [
20234 style.getPropertyValue("direction"),
20235 style.getPropertyPriority("direction"),
20236 ];
20237 style.setProperty("direction", direction, "important");
20238 ctx.prevTextDirection = original;
20239 }
20240 }
20241 function restoreTextDirection(ctx, original) {
20242 if (original !== undefined) {
20243 delete ctx.prevTextDirection;
20244 ctx.canvas.style.setProperty("direction", original[0], original[1]);
20245 }
20246 }
20247 function propertyFn(property) {
20248 if (property === "angle") return {
20249 between: _angleBetween,
20250 compare: _angleDiff,
20251 normalize: _normalizeAngle
20252 };
20253 return {
20254 between: _isBetween,
20255 compare: function(a, b) {
20256 return a - b;
20257 },
20258 normalize: function(x) {
20259 return x;
20260 }
20261 };
20262 }
20263 function normalizeSegment(param) {
20264 var start = param.start, end = param.end, count = param.count, loop = param.loop, style = param.style;
20265 return {
20266 start: start % count,
20267 end: end % count,
20268 loop: loop && (end - start + 1) % count === 0,
20269 style: style
20270 };
20271 }
20272 function getSegment(segment, points, bounds) {
20273 var property = bounds.property, startBound = bounds.start, endBound = bounds.end;
20274 var ref = propertyFn(property), between = ref.between, normalize = ref.normalize;
20275 var count = points.length;
20276 var start = segment.start, end = segment.end, loop = segment.loop;
20277 var i, ilen;
20278 if (loop) {
20279 start += count;
20280 end += count;
20281 for(i = 0, ilen = count; i < ilen; ++i){
20282 if (!between(normalize(points[start % count][property]), startBound, endBound)) break;
20283 start--;
20284 end--;
20285 }
20286 start %= count;
20287 end %= count;
20288 }
20289 if (end < start) end += count;
20290 return {
20291 start: start,
20292 end: end,
20293 loop: loop,
20294 style: segment.style
20295 };
20296 }
20297 function _boundSegment(segment, points, bounds) {
20298 if (!bounds) return [
20299 segment
20300 ];
20301 var property = bounds.property, startBound = bounds.start, endBound = bounds.end;
20302 var count = points.length;
20303 var ref = propertyFn(property), compare = ref.compare, between = ref.between, normalize = ref.normalize;
20304 var ref1 = getSegment(segment, points, bounds), start = ref1.start, end = ref1.end, loop = ref1.loop, style = ref1.style;
20305 var result = [];
20306 var inside = false;
20307 var subStart = null;
20308 var value, point, prevValue;
20309 var startIsBefore = function() {
20310 return between(startBound, prevValue, value) && compare(startBound, prevValue) !== 0;
20311 };
20312 var endIsBefore = function() {
20313 return compare(endBound, value) === 0 || between(endBound, prevValue, value);
20314 };
20315 var shouldStart = function() {
20316 return inside || startIsBefore();
20317 };
20318 var shouldStop = function() {
20319 return !inside || endIsBefore();
20320 };
20321 for(var i = start, prev = start; i <= end; ++i){
20322 point = points[i % count];
20323 if (point.skip) continue;
20324 value = normalize(point[property]);
20325 if (value === prevValue) continue;
20326 inside = between(value, startBound, endBound);
20327 if (subStart === null && shouldStart()) subStart = compare(value, startBound) === 0 ? i : prev;
20328 if (subStart !== null && shouldStop()) {
20329 result.push(normalizeSegment({
20330 start: subStart,
20331 end: i,
20332 loop: loop,
20333 count: count,
20334 style: style
20335 }));
20336 subStart = null;
20337 }
20338 prev = i;
20339 prevValue = value;
20340 }
20341 if (subStart !== null) result.push(normalizeSegment({
20342 start: subStart,
20343 end: end,
20344 loop: loop,
20345 count: count,
20346 style: style
20347 }));
20348 return result;
20349 }
20350 function _boundSegments(line, bounds) {
20351 var result = [];
20352 var segments = line.segments;
20353 for(var i = 0; i < segments.length; i++){
20354 var _result;
20355 var sub = _boundSegment(segments[i], line.points, bounds);
20356 if (sub.length) (_result = result).push.apply(_result, (0, _toConsumableArrayJsDefault.default)(sub));
20357 }
20358 return result;
20359 }
20360 function findStartAndEnd(points, count, loop, spanGaps) {
20361 var start = 0;
20362 var end = count - 1;
20363 if (loop && !spanGaps) while(start < count && !points[start].skip)start++;
20364 while(start < count && points[start].skip)start++;
20365 start %= count;
20366 if (loop) end += start;
20367 while(end > start && points[end % count].skip)end--;
20368 end %= count;
20369 return {
20370 start: start,
20371 end: end
20372 };
20373 }
20374 function solidSegments(points, start, max, loop) {
20375 var count = points.length;
20376 var result = [];
20377 var last = start;
20378 var prev = points[start];
20379 var end;
20380 for(end = start + 1; end <= max; ++end){
20381 var cur = points[end % count];
20382 if (cur.skip || cur.stop) {
20383 if (!prev.skip) {
20384 loop = false;
20385 result.push({
20386 start: start % count,
20387 end: (end - 1) % count,
20388 loop: loop
20389 });
20390 start = last = cur.stop ? end : null;
20391 }
20392 } else {
20393 last = end;
20394 if (prev.skip) start = end;
20395 }
20396 prev = cur;
20397 }
20398 if (last !== null) result.push({
20399 start: start % count,
20400 end: last % count,
20401 loop: loop
20402 });
20403 return result;
20404 }
20405 function _computeSegments(line, segmentOptions) {
20406 var points = line.points;
20407 var spanGaps = line.options.spanGaps;
20408 var count = points.length;
20409 if (!count) return [];
20410 var loop = !!line._loop;
20411 var ref = findStartAndEnd(points, count, loop, spanGaps), start = ref.start, end = ref.end;
20412 if (spanGaps === true) return splitByStyles(line, [
20413 {
20414 start: start,
20415 end: end,
20416 loop: loop
20417 }
20418 ], points, segmentOptions);
20419 var max = end < start ? end + count : end;
20420 var completeLoop = !!line._fullLoop && start === 0 && end === count - 1;
20421 return splitByStyles(line, solidSegments(points, start, max, completeLoop), points, segmentOptions);
20422 }
20423 function splitByStyles(line, segments, points, segmentOptions) {
20424 if (!segmentOptions || !segmentOptions.setContext || !points) return segments;
20425 return doSplitByStyles(line, segments, points, segmentOptions);
20426 }
20427 function doSplitByStyles(line, segments, points, segmentOptions) {
20428 var addStyle = function addStyle(s, e, l, st) {
20429 var dir = spanGaps ? -1 : 1;
20430 if (s === e) return;
20431 s += count;
20432 while(points[s % count].skip)s -= dir;
20433 while(points[e % count].skip)e += dir;
20434 if (s % count !== e % count) {
20435 result.push({
20436 start: s % count,
20437 end: e % count,
20438 loop: l,
20439 style: st
20440 });
20441 prevStyle = st;
20442 start = e % count;
20443 }
20444 };
20445 var chartContext = line._chart.getContext();
20446 var baseStyle = readStyle(line.options);
20447 var datasetIndex = line._datasetIndex, spanGaps = line.options.spanGaps;
20448 var count = points.length;
20449 var result = [];
20450 var prevStyle = baseStyle;
20451 var start = segments[0].start;
20452 var i = start;
20453 var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
20454 try {
20455 for(var _iterator = segments[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
20456 var segment = _step.value;
20457 start = spanGaps ? start : segment.start;
20458 var prev = points[start % count];
20459 var style = void 0;
20460 for(i = start + 1; i <= segment.end; i++){
20461 var pt = points[i % count];
20462 style = readStyle(segmentOptions.setContext(createContext(chartContext, {
20463 type: "segment",
20464 p0: prev,
20465 p1: pt,
20466 p0DataIndex: (i - 1) % count,
20467 p1DataIndex: i % count,
20468 datasetIndex: datasetIndex
20469 })));
20470 if (styleChanged(style, prevStyle)) addStyle(start, i - 1, segment.loop, prevStyle);
20471 prev = pt;
20472 prevStyle = style;
20473 }
20474 if (start < i - 1) addStyle(start, i - 1, segment.loop, prevStyle);
20475 }
20476 } catch (err) {
20477 _didIteratorError = true;
20478 _iteratorError = err;
20479 } finally{
20480 try {
20481 if (!_iteratorNormalCompletion && _iterator.return != null) {
20482 _iterator.return();
20483 }
20484 } finally{
20485 if (_didIteratorError) {
20486 throw _iteratorError;
20487 }
20488 }
20489 }
20490 return result;
20491 }
20492 function readStyle(options) {
20493 return {
20494 backgroundColor: options.backgroundColor,
20495 borderCapStyle: options.borderCapStyle,
20496 borderDash: options.borderDash,
20497 borderDashOffset: options.borderDashOffset,
20498 borderJoinStyle: options.borderJoinStyle,
20499 borderWidth: options.borderWidth,
20500 borderColor: options.borderColor
20501 };
20502 }
20503 function styleChanged(style, prevStyle) {
20504 return prevStyle && JSON.stringify(style) !== JSON.stringify(prevStyle);
20505 }
20506
20507 },{"@swc/helpers/lib/_class_call_check.js":"gNxF8","@swc/helpers/lib/_create_class.js":"iyoaN","@swc/helpers/lib/_define_property.js":"6IXzf","@swc/helpers/lib/_to_consumable_array.js":"cccKv","@swc/helpers/lib/_type_of.js":"9FF45","@parcel/transformer-js/src/esmodule-helpers.js":"jIm8e"}]},["kNoSz"], "kNoSz", "parcelRequirec571")
20508
20509 //# sourceMappingURL=dashboard_widget.js.map
20510