├── .github └── FUNDING.yml ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── composer.json ├── config └── filament-memory-tracker.php ├── package-lock.json ├── package.json ├── resources ├── dist │ ├── memory-tracker.css │ └── memory-tracker.js ├── js │ └── app.js ├── scss │ └── app.scss └── views │ └── widgets │ └── memory-tracker.blade.php ├── src ├── Concerns │ └── TracksRestart.php ├── MemoryTracker.php ├── WidgetServiceProvider.php └── Widgets │ └── MemoryTrackerWidget.php └── webpack.mix.js /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: danilopolani 2 | custom: ['https://www.buymeacoffee.com/theraloss'] 3 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Contributions are **welcome** and will be fully **credited**. 4 | 5 | Please read and understand the contribution guide before creating an issue or pull request. 6 | 7 | ## Etiquette 8 | 9 | This project is open source, and as such, the maintainers give their free time to build and maintain the source code 10 | held within. They make the code freely available in the hope that it will be of use to other developers. It would be 11 | extremely unfair for them to suffer abuse or anger for their hard work. 12 | 13 | Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the 14 | world that developers are civilized and selfless people. 15 | 16 | It's the duty of the maintainer to ensure that all submissions to the project are of sufficient 17 | quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used. 18 | 19 | ## Viability 20 | 21 | When requesting or submitting new features, first consider whether it might be useful to others. Open 22 | source projects are used by many developers, who may have entirely different needs to your own. Think about 23 | whether or not your feature is likely to be used by other users of the project. 24 | 25 | ## Procedure 26 | 27 | Before filing an issue: 28 | 29 | - Attempt to replicate the problem, to ensure that it wasn't a coincidental incident. 30 | - Check to make sure your feature suggestion isn't already present within the project. 31 | - Check the pull requests tab to ensure that the bug doesn't have a fix in progress. 32 | - Check the pull requests tab to ensure that the feature isn't already in progress. 33 | 34 | Before submitting a pull request: 35 | 36 | - Check the codebase to ensure that your feature doesn't already exist. 37 | - Check the pull requests to ensure that another person hasn't already submitted the feature or fix. 38 | 39 | ## Requirements 40 | 41 | If the project maintainer has any additional requirements, you will find them listed here. 42 | 43 | - **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer). 44 | 45 | - **Add tests!** - Your patch won't be accepted if it doesn't have tests. 46 | 47 | - **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. 48 | 49 | - **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option. 50 | 51 | - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. 52 | 53 | - **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. 54 | 55 | **Happy coding**! 56 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Danilo Polani 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Filament Memory Tracker 2 | 3 | [![Latest Stable Version](http://poser.pugx.org/danilopolani/filament-memory-tracker/v)](https://packagist.org/packages/danilopolani/filament-memory-tracker) 4 | [![Total Downloads](http://poser.pugx.org/danilopolani/filament-memory-tracker/downloads)](https://packagist.org/packages/danilopolani/filament-memory-tracker) 5 | 6 | Track the memory usage of your workers and display them in Filament. 7 | 8 |

Filament Worker Memory widget preview

9 | 10 | > If you're using Filament v1, please navigate the [1.x branch](https://github.com/danilopolani/filament-memory-tracker/tree/1.x). 11 | 12 | ## Installation 13 | 14 | Install the package via composer: 15 | 16 | ```bash 17 | composer require danilopolani/filament-memory-tracker 18 | ``` 19 | 20 | Then publish the assets and the config of the package: 21 | 22 | ```bash 23 | php artisan vendor:publish --tag=filament-memory-tracker-assets 24 | php artisan vendor:publish --tag=filament-memory-tracker-config 25 | ``` 26 | 27 | > If you're upgrading from v1 to v2 please note that the namespace changed from `\DaniloPolani\` to `\DaniloPolani\`. 28 | 29 | ### Upgrade 30 | When upgrading be sure to republish the assets: 31 | 32 | ```bash 33 | php artisan vendor:publish --tag=filament-memory-tracker-assets --force 34 | ``` 35 | 36 | ## Configuration 37 | 38 | There are a few notable configuration options for the package. 39 | 40 | Key | Type | Description 41 | ------------ | ------------- | ------------- 42 | `cache_store` | String | Define the cache store used to track memory usage. By default it will be your `CACHE_DRIVER` env value. 43 | `trackers` | Array | A list of trackers names to be displayed in the dashboard. They must be the same used in your `MemoryTracker()` instance. See **Usage** below to discover more. 44 | `date_format` | String | The [DateTime format](https://www.php.net/manual/en/datetime.format.php) to display dates. 45 | 46 | ## Usage 47 | 48 | In your Worker create a new `MemoryTracker` instance and then ping the `track()` method every time you want. There's an example with [ReactPHP Event Loop](https://reactphp.org/event-loop/). 49 | 50 | 51 | ℹ️ | The `$realUsage` flag is the same as [memory_get_usage()](https://www.php.net/manual/en/function.memory-get-usage.php). 52 | :---: | :--- 53 | 54 | ```php 55 | memoryTracker = new MemoryTracker('Worker'); 87 | } 88 | 89 | /** 90 | * Execute the console command. 91 | * 92 | * @return int 93 | */ 94 | public function handle() 95 | { 96 | // Ping every 5minutes 97 | Loop::addPeriodicTimer(60 * 5, function () { 98 | $this->memoryTracker->track(bool $realUsage = false); 99 | }); 100 | 101 | return 0; 102 | } 103 | } 104 | ``` 105 | 106 | Then don't forget to add your tracker name inside the configuration too: 107 | 108 | ```php 109 | [ 115 | 'Worker', 116 | ], 117 | 118 | ]; 119 | ``` 120 | 121 | ### Track restarts 122 | 123 | You can track the latest Worker restart date and memory usage as well! If you're working on a custom Worker, you should intercept the exit signals and then call the `$memoryTracker->trackRestart()` method. Otherwise you can use the Trait provided by the package to achieve that: 124 | 125 | 1. Include `DaniloPolani\FilamentMemoryTracker\Concerns\TracksRestart` inside your class; 126 | 2. Call `$this->trackRestartMemory(MemoryTracker $memoryTrackerInstance)` inside your constructor. 127 | 128 | ⚠️ | The `TracksRestart` requires the extension **`pcntl`** to be enabled. 129 | :---: | :--- 130 | 131 | ```php 132 | memoryTracker = new MemoryTracker('Worker'); 152 | $this->trackRestartMemory($this->memoryTracker); 153 | } 154 | 155 | // ... 156 | } 157 | ``` 158 | 159 | ### Laravel Queue 160 | 161 | You can track [Laravel Queue](laravel.com/docs/8.x/queues) too by listening to some specific events in a provider, for example your `AppServiceProvider`. 162 | 163 | ```php 164 | track(); 189 | }); 190 | 191 | // Track restarts 192 | Event::listen(WorkerStopping::class, function () use ($memoryTracker) { 193 | $memoryTracker->trackRestart(); 194 | }); 195 | } 196 | } 197 | ``` 198 | 199 | ### Additional notes 200 | 201 | - The widget will refresh every 5s automatically; 202 | - By default the widget will be shown full-width if there's more than 1 tracker; otherwise, the widget will be a single block: 203 | 204 | Memory Tracker widget single block 205 | 206 | ## APIs 207 | 208 | These are the available methods of the `MemoryTracker` class: 209 | 210 | Key | Description 211 | ------------ | ------------- 212 | `track(): void` | Track the current memory usage for the worker. 213 | `trackRestart(bool $resetPeak = true): void` | Track a restart. If `$resetPeak` is true, the memory peak will be purged as well. 214 | `getHistory(): array` | Get the worker's history of memory usage. 215 | `getPeak(): array\|null` | Get the worker's memory peak. Returns `null` if no peak found. 216 | `getLatestRestart(): array\|null` | Get the worker's latest restart data. Returns `null` if no restart found. 217 | `purge(): void` | Purge all the data of the current worker. 218 | `purgeHistory(): void` | Purge the track history only of the current worker. 219 | `purgePeak(): void` | Purge the memory peak of the current worker. 220 | `purgeRestart(): void` | Purge the latest restart data of the current worker. 221 | 222 | ## Contributing 223 | 224 | Please see [CONTRIBUTING](CONTRIBUTING.md) for details. 225 | 226 | ### Security 227 | 228 | If you discover any security related issues, please email danilo.polani@gmail.com instead of using the issue tracker. 229 | 230 | ## Credits 231 | 232 | - [Danilo Polani](https://github.com/danilopolani) 233 | - [All Contributors](../../contributors) 234 | 235 | ## License 236 | 237 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information. 238 | 239 | ## Laravel Package Boilerplate 240 | 241 | This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com). 242 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "danilopolani/filament-memory-tracker", 3 | "description": "Track the memory usage of your workers and display them in Filament", 4 | "keywords": [ 5 | "danilopolani", 6 | "filament", 7 | "filament-admin", 8 | "filament-memory-tracker" 9 | ], 10 | "homepage": "https://github.com/danilopolani/filament-memory-tracker", 11 | "license": "MIT", 12 | "type": "library", 13 | "authors": [ 14 | { 15 | "name": "Danilo Polani", 16 | "email": "danilo.polani@gmail.com", 17 | "role": "Developer" 18 | } 19 | ], 20 | "require": { 21 | "php": "^8.0", 22 | "filament/filament": "^2.5", 23 | "illuminate/support": "^8.0|^9.0|^10.0", 24 | "illuminate/contracts": "^8.0|^9.0|^10.0", 25 | "livewire/livewire": "^2.6" 26 | }, 27 | "require-dev": { 28 | "orchestra/testbench": "^6.0", 29 | "phpunit/phpunit": "^9.0" 30 | }, 31 | "autoload": { 32 | "psr-4": { 33 | "DaniloPolani\\FilamentMemoryTracker\\": "src" 34 | } 35 | }, 36 | "autoload-dev": { 37 | "psr-4": { 38 | "DaniloPolani\\FilamentMemoryTracker\\Tests\\": "tests" 39 | } 40 | }, 41 | "scripts": { 42 | "test": "vendor/bin/phpunit", 43 | "test-coverage": "vendor/bin/phpunit --coverage-html coverage" 44 | 45 | }, 46 | "config": { 47 | "sort-packages": true 48 | }, 49 | "extra": { 50 | "laravel": { 51 | "providers": [ 52 | "DaniloPolani\\FilamentMemoryTracker\\WidgetServiceProvider" 53 | ] 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /config/filament-memory-tracker.php: -------------------------------------------------------------------------------- 1 | env('CACHE_DRIVER', 'file'), 16 | 17 | /* 18 | |-------------------------------------------------------------------------- 19 | | Trackers to display 20 | |-------------------------------------------------------------------------- 21 | | 22 | | A list of trackers names to be displayed in the dashboard. 23 | | They must be the same used in your MemoryTracker() instance. 24 | | 25 | */ 26 | 27 | 'trackers' => [], 28 | 29 | /* 30 | |-------------------------------------------------------------------------- 31 | | Date format 32 | |-------------------------------------------------------------------------- 33 | | 34 | | In which format the dates (with time) will be displayed. 35 | | 36 | */ 37 | 38 | 'date_format' => 'j F Y @ H:i:s', 39 | 40 | ]; 41 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "filament-memory-tracker", 3 | "version": "1.0.0", 4 | "description": "Track the memory usage of your workers and display them in Filament", 5 | "main": "index.js", 6 | "keywords": [ 7 | "danilopolani", 8 | "filament", 9 | "filament-admin", 10 | "filament-memory-tracker" 11 | ], 12 | "author": "Danilo Polani", 13 | "devDependencies": { 14 | "laravel-mix": "^6.0.25", 15 | "postcss": "^8.3.5", 16 | "resolve-url-loader": "^4.0.0", 17 | "sass": "^1.35.2", 18 | "sass-loader": "^12.1.0" 19 | }, 20 | "scripts": { 21 | "build": "npx mix --production" 22 | }, 23 | "dependencies": { 24 | "chart.js": "^3.4.1" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /resources/dist/memory-tracker.css: -------------------------------------------------------------------------------- 1 | .memory-tracker-chart-name{display:block;font-size:1.125rem;font-weight:700;line-height:1.75rem;margin-bottom:1rem;margin-top:1.5rem;text-align:center}.memory-tracker--mb-10{margin-bottom:2.5rem}.memory-tracker--col-span-full{grid-column:1/-1}.memory-tracker--mb-2{margin-bottom:.5rem}.memory-tracker--text-sm{font-size:.875rem;line-height:1.25rem} 2 | -------------------------------------------------------------------------------- /resources/dist/memory-tracker.js: -------------------------------------------------------------------------------- 1 | (()=>{"use strict";var t,e={15:()=>{const t="undefined"==typeof window?function(t){return t()}:window.requestAnimationFrame;function e(e,i,n){const o=n||(t=>Array.prototype.slice.call(t));let s=!1,a=[];return function(...n){a=o(n),s||(s=!0,t.call(window,(()=>{s=!1,e.apply(i,a)})))}}const i=t=>"start"===t?"left":"end"===t?"right":"center",n=(t,e,i)=>"start"===t?e:"end"===t?i:(e+i)/2;function o(){}const s=function(){let t=0;return function(){return t++}}();function a(t){return null==t}function r(t){if(Array.isArray&&Array.isArray(t))return!0;const e=Object.prototype.toString.call(t);return"[object"===e.substr(0,7)&&"Array]"===e.substr(-6)}function l(t){return null!==t&&"[object Object]"===Object.prototype.toString.call(t)}const c=t=>("number"==typeof t||t instanceof Number)&&isFinite(+t);function h(t,e){return c(t)?t:e}function d(t,e){return void 0===t?e:t}const u=(t,e)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100*e:+t;function f(t,e,i){if(t&&"function"==typeof t.call)return t.apply(i,e)}function g(t,e,i,n){let o,s,a;if(r(t))if(s=t.length,n)for(o=s-1;o>=0;o--)e.call(i,t[o],o);else for(o=0;oi;)t=t[e.substr(i,n-i)],i=n+1,n=w(e,i);return t}function k(t){return t.charAt(0).toUpperCase()+t.slice(1)}const S=t=>void 0!==t,P=t=>"function"==typeof t,D=Math.PI,C=2*D,O=C+D,T=Number.POSITIVE_INFINITY,A=D/180,L=D/2,R=D/4,E=2*D/3,z=Math.log10,I=Math.sign;function F(t){const e=Math.round(t);t=B(t,e,t/1e3)?e:t;const i=Math.pow(10,Math.floor(z(t))),n=t/i;return(n<=1?1:n<=2?2:n<=5?5:10)*i}function V(t){return!isNaN(parseFloat(t))&&isFinite(t)}function B(t,e,i){return Math.abs(t-e)l&&c0===t||1===t,Z=(t,e,i)=>-Math.pow(2,10*(t-=1))*Math.sin((t-e)*C/i),G=(t,e,i)=>Math.pow(2,-10*t)*Math.sin((t-e)*C/i)+1,Q={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>-t*(t-2),easeInOutQuad:t=>(t/=.5)<1?.5*t*t:-.5*(--t*(t-2)-1),easeInCubic:t=>t*t*t,easeOutCubic:t=>(t-=1)*t*t+1,easeInOutCubic:t=>(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2),easeInQuart:t=>t*t*t*t,easeOutQuart:t=>-((t-=1)*t*t*t-1),easeInOutQuart:t=>(t/=.5)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2),easeInQuint:t=>t*t*t*t*t,easeOutQuint:t=>(t-=1)*t*t*t*t+1,easeInOutQuint:t=>(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2),easeInSine:t=>1-Math.cos(t*L),easeOutSine:t=>Math.sin(t*L),easeInOutSine:t=>-.5*(Math.cos(D*t)-1),easeInExpo:t=>0===t?0:Math.pow(2,10*(t-1)),easeOutExpo:t=>1===t?1:1-Math.pow(2,-10*t),easeInOutExpo:t=>K(t)?t:t<.5?.5*Math.pow(2,10*(2*t-1)):.5*(2-Math.pow(2,-10*(2*t-1))),easeInCirc:t=>t>=1?t:-(Math.sqrt(1-t*t)-1),easeOutCirc:t=>Math.sqrt(1-(t-=1)*t),easeInOutCirc:t=>(t/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1),easeInElastic:t=>K(t)?t:Z(t,.075,.3),easeOutElastic:t=>K(t)?t:G(t,.075,.3),easeInOutElastic(t){const e=.1125;return K(t)?t:t<.5?.5*Z(2*t,e,.45):.5+.5*G(2*t-1,e,.45)},easeInBack(t){const e=1.70158;return t*t*((e+1)*t-e)},easeOutBack(t){const e=1.70158;return(t-=1)*t*((e+1)*t+e)+1},easeInOutBack(t){let e=1.70158;return(t/=.5)<1?t*t*((1+(e*=1.525))*t-e)*.5:.5*((t-=2)*t*((1+(e*=1.525))*t+e)+2)},easeInBounce:t=>1-Q.easeOutBounce(1-t),easeOutBounce(t){const e=7.5625,i=2.75;return t<1/i?e*t*t:t<2/i?e*(t-=1.5/i)*t+.75:t<2.5/i?e*(t-=2.25/i)*t+.9375:e*(t-=2.625/i)*t+.984375},easeInOutBounce:t=>t<.5?.5*Q.easeInBounce(2*t):.5*Q.easeOutBounce(2*t-1)+.5},J={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},tt="0123456789ABCDEF",et=t=>tt[15&t],it=t=>tt[(240&t)>>4]+tt[15&t],nt=t=>(240&t)>>4==(15&t);function ot(t){var e=function(t){return nt(t.r)&&nt(t.g)&&nt(t.b)&&nt(t.a)}(t)?et:it;return t?"#"+e(t.r)+e(t.g)+e(t.b)+(t.a<255?e(t.a):""):t}function st(t){return t+.5|0}const at=(t,e,i)=>Math.max(Math.min(t,i),e);function rt(t){return at(st(2.55*t),0,255)}function lt(t){return at(st(255*t),0,255)}function ct(t){return at(st(t/2.55)/100,0,1)}function ht(t){return at(st(100*t),0,100)}const dt=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;const ut=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function ft(t,e,i){const n=e*Math.min(i,1-i),o=(e,o=(e+t/30)%12)=>i-n*Math.max(Math.min(o-3,9-o,1),-1);return[o(0),o(8),o(4)]}function gt(t,e,i){const n=(n,o=(n+t/60)%6)=>i-i*e*Math.max(Math.min(o,4-o,1),0);return[n(5),n(3),n(1)]}function pt(t,e,i){const n=ft(t,1,.5);let o;for(e+i>1&&(o=1/(e+i),e*=o,i*=o),o=0;o<3;o++)n[o]*=1-e-i,n[o]+=e;return n}function mt(t){const e=t.r/255,i=t.g/255,n=t.b/255,o=Math.max(e,i,n),s=Math.min(e,i,n),a=(o+s)/2;let r,l,c;return o!==s&&(c=o-s,l=a>.5?c/(2-o-s):c/(o+s),r=o===e?(i-n)/c+(i>16&255,s>>8&255,255&s]}return t}(),Mt.transparent=[0,0,0,0]);const e=Mt[t.toLowerCase()];return e&&{r:e[0],g:e[1],b:e[2],a:4===e.length?e[3]:255}}function St(t,e,i){if(t){let n=mt(t);n[e]=Math.max(0,Math.min(n[e]+n[e]*i,0===e?360:1)),n=bt(n),t.r=n[0],t.g=n[1],t.b=n[2]}}function Pt(t,e){return t?Object.assign(e||{},t):t}function Dt(t){var e={r:0,g:0,b:0,a:255};return Array.isArray(t)?t.length>=3&&(e={r:t[0],g:t[1],b:t[2],a:255},t.length>3&&(e.a=lt(t[3]))):(e=Pt(t,{r:0,g:0,b:0,a:1})).a=lt(e.a),e}function Ct(t){return"r"===t.charAt(0)?function(t){const e=dt.exec(t);let i,n,o,s=255;if(e){if(e[7]!==i){const t=+e[7];s=255&(e[8]?rt(t):255*t)}return i=+e[1],n=+e[3],o=+e[5],i=255&(e[2]?rt(i):i),n=255&(e[4]?rt(n):n),o=255&(e[6]?rt(o):o),{r:i,g:n,b:o,a:s}}}(t):yt(t)}class Ot{constructor(t){if(t instanceof Ot)return t;const e=typeof t;let i;var n,o,s;"object"===e?i=Dt(t):"string"===e&&(s=(n=t).length,"#"===n[0]&&(4===s||5===s?o={r:255&17*J[n[1]],g:255&17*J[n[2]],b:255&17*J[n[3]],a:5===s?17*J[n[4]]:255}:7!==s&&9!==s||(o={r:J[n[1]]<<4|J[n[2]],g:J[n[3]]<<4|J[n[4]],b:J[n[5]]<<4|J[n[6]],a:9===s?J[n[7]]<<4|J[n[8]]:255})),i=o||kt(t)||Ct(t)),this._rgb=i,this._valid=!!i}get valid(){return this._valid}get rgb(){var t=Pt(this._rgb);return t&&(t.a=ct(t.a)),t}set rgb(t){this._rgb=Dt(t)}rgbString(){return this._valid?(t=this._rgb)&&(t.a<255?`rgba(${t.r}, ${t.g}, ${t.b}, ${ct(t.a)})`:`rgb(${t.r}, ${t.g}, ${t.b})`):this._rgb;var t}hexString(){return this._valid?ot(this._rgb):this._rgb}hslString(){return this._valid?function(t){if(!t)return;const e=mt(t),i=e[0],n=ht(e[1]),o=ht(e[2]);return t.a<255?`hsla(${i}, ${n}%, ${o}%, ${ct(t.a)})`:`hsl(${i}, ${n}%, ${o}%)`}(this._rgb):this._rgb}mix(t,e){const i=this;if(t){const n=i.rgb,o=t.rgb;let s;const a=e===s?.5:e,r=2*a-1,l=n.a-o.a,c=((r*l==-1?r:(r+l)/(1+r*l))+1)/2;s=1-c,n.r=255&c*n.r+s*o.r+.5,n.g=255&c*n.g+s*o.g+.5,n.b=255&c*n.b+s*o.b+.5,n.a=a*n.a+(1-a)*o.a,i.rgb=n}return i}clone(){return new Ot(this.rgb)}alpha(t){return this._rgb.a=lt(t),this}clearer(t){return this._rgb.a*=1-t,this}greyscale(){const t=this._rgb,e=st(.3*t.r+.59*t.g+.11*t.b);return t.r=t.g=t.b=e,this}opaquer(t){return this._rgb.a*=1+t,this}negate(){const t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this}lighten(t){return St(this._rgb,2,t),this}darken(t){return St(this._rgb,2,-t),this}saturate(t){return St(this._rgb,1,t),this}desaturate(t){return St(this._rgb,1,-t),this}rotate(t){return function(t,e){var i=mt(t);i[0]=_t(i[0]+e),i=bt(i),t.r=i[0],t.g=i[1],t.b=i[2]}(this._rgb,t),this}}function Tt(t){return new Ot(t)}const At=t=>t instanceof CanvasGradient||t instanceof CanvasPattern;function Lt(t){return At(t)?t:Tt(t)}function Rt(t){return At(t)?t:Tt(t).saturate(.5).darken(.1).hexString()}const Et=Object.create(null),zt=Object.create(null);function It(t,e){if(!e)return t;const i=e.split(".");for(let e=0,n=i.length;et.chart.platform.getDevicePixelRatio(),this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.font={family:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",size:12,style:"normal",lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(t,e)=>Rt(e.backgroundColor),this.hoverBorderColor=(t,e)=>Rt(e.borderColor),this.hoverColor=(t,e)=>Rt(e.color),this.indexAxis="x",this.interaction={mode:"nearest",intersect:!0},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.describe(t)}set(t,e){return Ft(this,t,e)}get(t){return It(this,t)}describe(t,e){return Ft(zt,t,e)}override(t,e){return Ft(Et,t,e)}route(t,e,i,n){const o=It(this,t),s=It(this,i),a="_"+e;Object.defineProperties(o,{[a]:{value:o[e],writable:!0},[e]:{enumerable:!0,get(){const t=this[a],e=s[n];return l(t)?Object.assign({},e,t):d(t,e)},set(t){this[a]=t}}})}}({_scriptable:t=>!t.startsWith("on"),_indexable:t=>"events"!==t,hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}});function Bt(t,e,i,n,o){let s=e[o];return s||(s=e[o]=t.measureText(o).width,i.push(o)),s>n&&(n=s),n}function Wt(t,e,i,n){let o=(n=n||{}).data=n.data||{},s=n.garbageCollect=n.garbageCollect||[];n.font!==e&&(o=n.data={},s=n.garbageCollect=[],n.font=e),t.save(),t.font=e;let a=0;const l=i.length;let c,h,d,u,f;for(c=0;ci.length){for(c=0;c0&&t.stroke()}}function $t(t,e,i){return i=i||.5,t&&t.x>e.left-i&&t.xe.top-i&&t.y0&&""!==s.strokeColor;let h,d;for(t.save(),t.font=o.string,function(t,e){e.translation&&t.translate(e.translation[0],e.translation[1]);a(e.rotation)||t.rotate(e.rotation);e.color&&(t.fillStyle=e.color);e.textAlign&&(t.textAlign=e.textAlign);e.textBaseline&&(t.textBaseline=e.textBaseline)}(t,s),h=0;hd(t[i],t[e[i]]):e=>t[e]:()=>t;for(const t of o)i[t]=+s(t)||0;return i}function ie(t){return ee(t,{top:"y",right:"x",bottom:"y",left:"x"})}function ne(t){return ee(t,["topLeft","topRight","bottomLeft","bottomRight"])}function oe(t){const e=ie(t);return e.width=e.left+e.right,e.height=e.top+e.bottom,e}function se(t,e){t=t||{},e=e||Vt.font;let i=d(t.size,e.size);"string"==typeof i&&(i=parseInt(i,10));let n=d(t.style,e.style);n&&!(""+n).match(Jt)&&(console.warn('Invalid font style specified: "'+n+'"'),n="");const o={family:d(t.family,e.family),lineHeight:te(d(t.lineHeight,e.lineHeight),i),size:i,style:n,weight:d(t.weight,e.weight),string:""};return o.string=function(t){return!t||a(t.size)||a(t.family)?null:(t.style?t.style+" ":"")+(t.weight?t.weight+" ":"")+t.size+"px "+t.family}(o),o}function ae(t,e,i,n){let o,s,a,l=!0;for(o=0,s=t.length;ot[i]1;)n=s+o>>1,i(n)?s=n:o=n;return{lo:s,hi:o}}const le=(t,e,i)=>re(t,i,(n=>t[n][e]re(t,i,(n=>t[n][e]>=i));const he=["push","pop","shift","splice","unshift"];function de(t,e){const i=t._chartjs;if(!i)return;const n=i.listeners,o=n.indexOf(e);-1!==o&&n.splice(o,1),n.length>0||(he.forEach((e=>{delete t[e]})),delete t._chartjs)}function ue(t){const e=new Set;let i,n;for(i=0,n=t.length;it[0])){S(n)||(n=ke("_fallback",t));const s={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:t,_rootScopes:i,_fallback:n,_getTarget:o,override:o=>fe([o,...t],e,i,n)};return new Proxy(s,{deleteProperty:(e,i)=>(delete e[i],delete e._keys,delete t[0][i],!0),get:(i,n)=>be(i,n,(()=>function(t,e,i,n){let o;for(const s of e)if(o=ke(me(s,t),i),S(o))return xe(t,o)?we(i,n,t,o):o}(n,e,t,i))),getOwnPropertyDescriptor:(t,e)=>Reflect.getOwnPropertyDescriptor(t._scopes[0],e),getPrototypeOf:()=>Reflect.getPrototypeOf(t[0]),has:(t,e)=>Se(t).includes(e),ownKeys:t=>Se(t),set:(t,e,i)=>((t._storage||(t._storage=o()))[e]=i,delete t[e],delete t._keys,!0)})}function ge(t,e,i,n){const o={_cacheable:!1,_proxy:t,_context:e,_subProxy:i,_stack:new Set,_descriptors:pe(t,n),setContext:e=>ge(t,e,i,n),override:o=>ge(t.override(o),e,i,n)};return new Proxy(o,{deleteProperty:(e,i)=>(delete e[i],delete t[i],!0),get:(t,e,i)=>be(t,e,(()=>function(t,e,i){const{_proxy:n,_context:o,_subProxy:s,_descriptors:a}=t;let c=n[e];P(c)&&a.isScriptable(e)&&(c=function(t,e,i,n){const{_proxy:o,_context:s,_subProxy:a,_stack:r}=i;if(r.has(t))throw new Error("Recursion detected: "+Array.from(r).join("->")+"->"+t);r.add(t),e=e(s,a||n),r.delete(t),l(e)&&(e=we(o._scopes,o,t,e));return e}(e,c,t,i));r(c)&&c.length&&(c=function(t,e,i,n){const{_proxy:o,_context:s,_subProxy:a,_descriptors:r}=i;if(S(s.index)&&n(t))e=e[s.index%e.length];else if(l(e[0])){const i=e,n=o._scopes.filter((t=>t!==i));e=[];for(const l of i){const i=we(n,o,t,l);e.push(ge(i,s,a&&a[t],r))}}return e}(e,c,t,a.isIndexable));xe(e,c)&&(c=ge(c,o,s&&s[e],a));return c}(t,e,i))),getOwnPropertyDescriptor:(e,i)=>e._descriptors.allKeys?Reflect.has(t,i)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(t,i),getPrototypeOf:()=>Reflect.getPrototypeOf(t),has:(e,i)=>Reflect.has(t,i),ownKeys:()=>Reflect.ownKeys(t),set:(e,i,n)=>(t[i]=n,delete e[i],!0)})}function pe(t,e={scriptable:!0,indexable:!0}){const{_scriptable:i=e.scriptable,_indexable:n=e.indexable,_allKeys:o=e.allKeys}=t;return{allKeys:o,scriptable:i,indexable:n,isScriptable:P(i)?i:()=>i,isIndexable:P(n)?n:()=>n}}const me=(t,e)=>t?t+k(e):e,xe=(t,e)=>l(e)&&"adapters"!==t;function be(t,e,i){let n=t[e];return S(n)||(n=i(),S(n)&&(t[e]=n)),n}function _e(t,e,i){return P(t)?t(e,i):t}const ye=(t,e)=>!0===t?e:"string"==typeof t?M(e,t):void 0;function ve(t,e,i,n){for(const o of e){const e=ye(i,o);if(e){t.add(e);const o=_e(e._fallback,i,e);if(S(o)&&o!==i&&o!==n)return o}else if(!1===e&&S(n)&&i!==n)return null}return!1}function we(t,e,i,n){const o=e._rootScopes,s=_e(e._fallback,i,n),a=[...t,...o],c=new Set;c.add(n);let h=Me(c,a,i,s||i);return null!==h&&((!S(s)||s===i||(h=Me(c,a,s,h),null!==h))&&fe(Array.from(c),[""],o,s,(()=>function(t,e,i){const n=t._getTarget();e in n||(n[e]={});const o=n[e];if(r(o)&&l(i))return i;return o}(e,i,n))))}function Me(t,e,i,n){for(;i;)i=ve(t,e,i,n);return i}function ke(t,e){for(const i of e){if(!i)continue;const e=i[t];if(S(e))return e}}function Se(t){let e=t._keys;return e||(e=t._keys=function(t){const e=new Set;for(const i of t)for(const t of Object.keys(i).filter((t=>!t.startsWith("_"))))e.add(t);return Array.from(e)}(t._scopes)),e}const Pe=Number.EPSILON||1e-14,De=(t,e)=>e"x"===t?"y":"x";function Oe(t,e,i,n){const o=t.skip?e:t,s=e,a=i.skip?e:i,r=$(s,o),l=$(a,s);let c=r/(r+l),h=l/(r+l);c=isNaN(c)?0:c,h=isNaN(h)?0:h;const d=n*c,u=n*h;return{previous:{x:s.x-d*(a.x-o.x),y:s.y-d*(a.y-o.y)},next:{x:s.x+u*(a.x-o.x),y:s.y+u*(a.y-o.y)}}}function Te(t,e="x"){const i=Ce(e),n=t.length,o=Array(n).fill(0),s=Array(n);let a,r,l,c=De(t,0);for(a=0;a!t.skip))),"monotone"===e.cubicInterpolationMode)Te(t,o);else{let i=n?t[t.length-1]:t[0];for(s=0,a=t.length;swindow.getComputedStyle(t,null);const Ie=["top","right","bottom","left"];function Fe(t,e,i){const n={};i=i?"-"+i:"";for(let o=0;o<4;o++){const s=Ie[o];n[s]=parseFloat(t[e+"-"+s+i])||0}return n.width=n.left+n.right,n.height=n.top+n.bottom,n}function Ve(t,e){const{canvas:i,currentDevicePixelRatio:n}=e,o=ze(i),s="border-box"===o.boxSizing,a=Fe(o,"padding"),r=Fe(o,"border","width"),{x:l,y:c,box:h}=function(t,e){const i=t.native||t,n=i.touches,o=n&&n.length?n[0]:i,{offsetX:s,offsetY:a}=o;let r,l,c=!1;if(((t,e,i)=>(t>0||e>0)&&(!i||!i.shadowRoot))(s,a,i.target))r=s,l=a;else{const t=e.getBoundingClientRect();r=o.clientX-t.left,l=o.clientY-t.top,c=!0}return{x:r,y:l,box:c}}(t,i),d=a.left+(h&&r.left),u=a.top+(h&&r.top);let{width:f,height:g}=e;return s&&(f-=a.width+r.width,g-=a.height+r.height),{x:Math.round((l-d)/f*i.width/n),y:Math.round((c-u)/g*i.height/n)}}const Be=t=>Math.round(10*t)/10;function We(t,e,i,n){const o=ze(t),s=Fe(o,"margin"),a=Ee(o.maxWidth,t,"clientWidth")||T,r=Ee(o.maxHeight,t,"clientHeight")||T,l=function(t,e,i){let n,o;if(void 0===e||void 0===i){const s=Re(t);if(s){const t=s.getBoundingClientRect(),a=ze(s),r=Fe(a,"border","width"),l=Fe(a,"padding");e=t.width-l.width-r.width,i=t.height-l.height-r.height,n=Ee(a.maxWidth,s,"clientWidth"),o=Ee(a.maxHeight,s,"clientHeight")}else e=t.clientWidth,i=t.clientHeight}return{width:e,height:i,maxWidth:n||T,maxHeight:o||T}}(t,e,i);let{width:c,height:h}=l;if("content-box"===o.boxSizing){const t=Fe(o,"border","width"),e=Fe(o,"padding");c-=e.width+t.width,h-=e.height+t.height}return c=Math.max(0,c-s.width),h=Math.max(0,n?Math.floor(c/n):h-s.height),c=Be(Math.min(c,a,l.maxWidth)),h=Be(Math.min(h,r,l.maxHeight)),c&&!h&&(h=Be(c/2)),{width:c,height:h}}function He(t,e,i){const n=e||1,o=Math.floor(t.height*n),s=Math.floor(t.width*n);t.height=o/n,t.width=s/n;const a=t.canvas;return a.style&&(i||!a.style.height&&!a.style.width)&&(a.style.height=`${t.height}px`,a.style.width=`${t.width}px`),(t.currentDevicePixelRatio!==n||a.height!==o||a.width!==s)&&(t.currentDevicePixelRatio=n,a.height=o,a.width=s,t.ctx.setTransform(n,0,0,n,0,0),!0)}const Ne=function(){let t=!1;try{const e={get passive(){return t=!0,!1}};window.addEventListener("test",null,e),window.removeEventListener("test",null,e)}catch(t){}return t}();function je(t,e){const i=function(t,e){return ze(t).getPropertyValue(e)}(t,e),n=i&&i.match(/^(\d+)(\.\d+)?px$/);return n?+n[1]:void 0}function $e(t,e,i,n){return{x:t.x+i*(e.x-t.x),y:t.y+i*(e.y-t.y)}}function Ye(t,e,i,n){return{x:t.x+i*(e.x-t.x),y:"middle"===n?i<.5?t.y:e.y:"after"===n?i<1?t.y:e.y:i>0?e.y:t.y}}function Ue(t,e,i,n){const o={x:t.cp2x,y:t.cp2y},s={x:e.cp1x,y:e.cp1y},a=$e(t,o,i),r=$e(o,s,i),l=$e(s,e,i),c=$e(a,r,i),h=$e(r,l,i);return $e(c,h,i)}const Xe=new Map;function qe(t,e,i){return function(t,e){e=e||{};const i=t+JSON.stringify(e);let n=Xe.get(i);return n||(n=new Intl.NumberFormat(t,e),Xe.set(i,n)),n}(e,i).format(t)}function Ke(t,e,i){return t?function(t,e){return{x:i=>t+t+e-i,setWidth(t){e=t},textAlign:t=>"center"===t?t:"right"===t?"left":"right",xPlus:(t,e)=>t-e,leftForLtr:(t,e)=>t-e}}(e,i):{x:t=>t,setWidth(t){},textAlign:t=>t,xPlus:(t,e)=>t+e,leftForLtr:(t,e)=>t}}function Ze(t,e){let i,n;"ltr"!==e&&"rtl"!==e||(i=t.canvas.style,n=[i.getPropertyValue("direction"),i.getPropertyPriority("direction")],i.setProperty("direction",e,"important"),t.prevTextDirection=n)}function Ge(t,e){void 0!==e&&(delete t.prevTextDirection,t.canvas.style.setProperty("direction",e[0],e[1]))}function Qe(t){return"angle"===t?{between:X,compare:Y,normalize:U}:{between:(t,e,i)=>t>=Math.min(e,i)&&t<=Math.max(i,e),compare:(t,e)=>t-e,normalize:t=>t}}function Je({start:t,end:e,count:i,loop:n,style:o}){return{start:t%i,end:e%i,loop:n&&(e-t+1)%i==0,style:o}}function ti(t,e,i){if(!i)return[t];const{property:n,start:o,end:s}=i,a=e.length,{compare:r,between:l,normalize:c}=Qe(n),{start:h,end:d,loop:u,style:f}=function(t,e,i){const{property:n,start:o,end:s}=i,{between:a,normalize:r}=Qe(n),l=e.length;let c,h,{start:d,end:u,loop:f}=t;if(f){for(d+=l,u+=l,c=0,h=l;cb||l(o,x,p)&&0!==r(o,x),v=()=>!b||0===r(s,p)||l(s,x,p);for(let t=h,i=h;t<=d;++t)m=e[t%a],m.skip||(p=c(m[n]),p!==x&&(b=l(p,o,s),null===_&&y()&&(_=0===r(p,o)?t:i),null!==_&&v()&&(g.push(Je({start:_,end:t,loop:u,count:a,style:f})),_=null),i=t,x=p));return null!==_&&g.push(Je({start:_,end:d,loop:u,count:a,style:f})),g}function ei(t,e){const i=[],n=t.segments;for(let o=0;on({chart:t,initial:e.initial,numSteps:s,currentStep:Math.min(i-e.start,s)})))}_refresh(){const e=this;e._request||(e._running=!0,e._request=t.call(window,(()=>{e._update(),e._request=null,e._running&&e._refresh()})))}_update(t=Date.now()){const e=this;let i=0;e._charts.forEach(((n,o)=>{if(!n.running||!n.items.length)return;const s=n.items;let a,r=s.length-1,l=!1;for(;r>=0;--r)a=s[r],a._active?(a._total>n.duration&&(n.duration=a._total),a.tick(t),l=!0):(s[r]=s[s.length-1],s.pop());l&&(o.draw(),e._notify(o,n,t,"progress")),s.length||(n.running=!1,e._notify(o,n,t,"complete"),n.initial=!1),i+=s.length})),e._lastDate=t,0===i&&(e._running=!1)}_getAnims(t){const e=this._charts;let i=e.get(t);return i||(i={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},e.set(t,i)),i}listen(t,e,i){this._getAnims(t).listeners[e].push(i)}add(t,e){e&&e.length&&this._getAnims(t).items.push(...e)}has(t){return this._getAnims(t).items.length>0}start(t){const e=this._charts.get(t);e&&(e.running=!0,e.start=Date.now(),e.duration=e.items.reduce(((t,e)=>Math.max(t,e._duration)),0),this._refresh())}running(t){if(!this._running)return!1;const e=this._charts.get(t);return!!(e&&e.running&&e.items.length)}stop(t){const e=this._charts.get(t);if(!e||!e.items.length)return;const i=e.items;let n=i.length-1;for(;n>=0;--n)i[n].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}};const ai="transparent",ri={boolean:(t,e,i)=>i>.5?e:t,color(t,e,i){const n=Lt(t||ai),o=n.valid&&Lt(e||ai);return o&&o.valid?o.mix(n,i).hexString():e},number:(t,e,i)=>t+(e-t)*i};class li{constructor(t,e,i,n){const o=e[i];n=ae([t.to,n,o,t.from]);const s=ae([t.from,o,n]);this._active=!0,this._fn=t.fn||ri[t.type||typeof s],this._easing=Q[t.easing]||Q.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=e,this._prop=i,this._from=s,this._to=n,this._promises=void 0}active(){return this._active}update(t,e,i){const n=this;if(n._active){n._notify(!1);const o=n._target[n._prop],s=i-n._start,a=n._duration-s;n._start=i,n._duration=Math.floor(Math.max(a,t.duration)),n._total+=s,n._loop=!!t.loop,n._to=ae([t.to,e,o,t.from]),n._from=ae([t.from,o,e])}}cancel(){const t=this;t._active&&(t.tick(Date.now()),t._active=!1,t._notify(!1))}tick(t){const e=this,i=t-e._start,n=e._duration,o=e._prop,s=e._from,a=e._loop,r=e._to;let l;if(e._active=s!==r&&(a||i1?2-l:l,l=e._easing(Math.min(1,Math.max(0,l))),e._target[o]=e._fn(s,r,l))}wait(){const t=this._promises||(this._promises=[]);return new Promise(((e,i)=>{t.push({res:e,rej:i})}))}_notify(t){const e=t?"res":"rej",i=this._promises||[];for(let t=0;t"onProgress"!==t&&"onComplete"!==t&&"fn"!==t}),Vt.set("animations",{colors:{type:"color",properties:["color","borderColor","backgroundColor"]},numbers:{type:"number",properties:["x","y","borderWidth","radius","tension"]}}),Vt.describe("animations",{_fallback:"animation"}),Vt.set("transitions",{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:"transparent"},visible:{type:"boolean",duration:0}}},hide:{animations:{colors:{to:"transparent"},visible:{type:"boolean",easing:"linear",fn:t=>0|t}}}});class hi{constructor(t,e){this._chart=t,this._properties=new Map,this.configure(e)}configure(t){if(!l(t))return;const e=this._properties;Object.getOwnPropertyNames(t).forEach((i=>{const n=t[i];if(!l(n))return;const o={};for(const t of ci)o[t]=n[t];(r(n.properties)&&n.properties||[i]).forEach((t=>{t!==i&&e.has(t)||e.set(t,o)}))}))}_animateOptions(t,e){const i=e.options,n=function(t,e){if(!e)return;let i=t.options;if(!i)return void(t.options=e);i.$shared&&(t.options=i=Object.assign({},i,{$shared:!1,$animations:{}}));return i}(t,i);if(!n)return[];const o=this._createAnimations(n,i);return i.$shared&&function(t,e){const i=[],n=Object.keys(e);for(let e=0;e{t.options=i}),(()=>{})),o}_createAnimations(t,e){const i=this._properties,n=[],o=t.$animations||(t.$animations={}),s=Object.keys(e),a=Date.now();let r;for(r=s.length-1;r>=0;--r){const l=s[r];if("$"===l.charAt(0))continue;if("options"===l){n.push(...this._animateOptions(t,e));continue}const c=e[l];let h=o[l];const d=i.get(l);if(h){if(d&&h.active()){h.update(d,c,a);continue}h.cancel()}d&&d.duration?(o[l]=h=new li(d,t,l,c),n.push(h)):t[l]=c}return n}update(t,e){if(0===this._properties.size)return void Object.assign(t,e);const i=this._createAnimations(t,e);return i.length?(si.add(this._chart,i),!0):void 0}}function di(t,e){const i=t&&t.options||{},n=i.reverse,o=void 0===i.min?e:0,s=void 0===i.max?e:0;return{start:n?s:o,end:n?o:s}}function ui(t,e){const i=[],n=t._getSortedDatasetMetas(e);let o,s;for(o=0,s=n.length;o0||!i&&e<0)return n.index}return null}function xi(t,e){const{chart:i,_cachedMeta:n}=t,o=i._stacks||(i._stacks={}),{iScale:s,vScale:a,index:r}=n,l=s.axis,c=a.axis,h=function(t,e,i){return`${t.id}.${e.id}.${i.stack||i.type}`}(s,a,n),d=e.length;let u;for(let t=0;ti[t].axis===e)).shift()}function _i(t,e){const i=t.vScale&&t.vScale.axis;if(i){e=e||t._parsed;for(const n of e){const e=n._stacks;if(!e||void 0===e[i]||void 0===e[i][t.index])return;delete e[i][t.index]}}}const yi=t=>"reset"===t||"none"===t,vi=(t,e)=>e?t:Object.assign({},t);class wi{constructor(t,e){this.chart=t,this._ctx=t.ctx,this.index=e,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.$context=void 0,this._syncList=[],this.initialize()}initialize(){const t=this,e=t._cachedMeta;t.configure(),t.linkScales(),e._stacked=gi(e.vScale,e),t.addElements()}updateIndex(t){this.index!==t&&_i(this._cachedMeta),this.index=t}linkScales(){const t=this,e=t.chart,i=t._cachedMeta,n=t.getDataset(),o=(t,e,i,n)=>"x"===t?e:"r"===t?n:i,s=i.xAxisID=d(n.xAxisID,bi(e,"x")),a=i.yAxisID=d(n.yAxisID,bi(e,"y")),r=i.rAxisID=d(n.rAxisID,bi(e,"r")),l=i.indexAxis,c=i.iAxisID=o(l,s,a,r),h=i.vAxisID=o(l,a,s,r);i.xScale=t.getScaleForId(s),i.yScale=t.getScaleForId(a),i.rScale=t.getScaleForId(r),i.iScale=t.getScaleForId(c),i.vScale=t.getScaleForId(h)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){const e=this._cachedMeta;return t===e.iScale?e.vScale:e.iScale}reset(){this._update("reset")}_destroy(){const t=this._cachedMeta;this._data&&de(this._data,this),t._stacked&&_i(t)}_dataCheck(){const t=this,e=t.getDataset(),i=e.data||(e.data=[]),n=t._data;if(l(i))t._data=function(t){const e=Object.keys(t),i=new Array(e.length);let n,o,s;for(n=0,o=e.length;n{const e="_onData"+k(t),i=o[t];Object.defineProperty(o,t,{configurable:!0,enumerable:!1,value(...t){const n=i.apply(this,t);return o._chartjs.listeners.forEach((i=>{"function"==typeof i[e]&&i[e](...t)})),n}})})))),t._syncList=[],t._data=i}var o,s}addElements(){const t=this,e=t._cachedMeta;t._dataCheck(),t.datasetElementType&&(e.dataset=new t.datasetElementType)}buildOrUpdateElements(t){const e=this,i=e._cachedMeta,n=e.getDataset();let o=!1;e._dataCheck();const s=i._stacked;i._stacked=gi(i.vScale,i),i.stack!==n.stack&&(o=!0,_i(i),i.stack=n.stack),e._resyncElements(t),(o||s!==i._stacked)&&xi(e,i._parsed)}configure(){const t=this,e=t.chart.config,i=e.datasetScopeKeys(t._type),n=e.getOptionScopes(t.getDataset(),i,!0);t.options=e.createResolver(n,t.getContext()),t._parsing=t.options.parsing}parse(t,e){const i=this,{_cachedMeta:n,_data:o}=i,{iScale:s,_stacked:a}=n,c=s.axis;let h,d,u,f=0===t&&e===o.length||n._sorted,g=t>0&&n._parsed[t-1];if(!1===i._parsing)n._parsed=o,n._sorted=!0,u=o;else{u=r(o[t])?i.parseArrayData(n,o,t,e):l(o[t])?i.parseObjectData(n,o,t,e):i.parsePrimitiveData(n,o,t,e);const s=()=>null===d[c]||g&&d[c]m||u=0;--f)if(!x()){i.updateRangeFromParsed(h,t,p,l);break}return h}getAllParsedValues(t){const e=this._cachedMeta._parsed,i=[];let n,o,s;for(n=0,o=e.length;n=0&&tn.getContext(i,o)),d);return g.$shared&&(g.$shared=l,s[a]=Object.freeze(vi(g,l))),g}_resolveAnimations(t,e,i){const n=this,o=n.chart,s=n._cachedDataOpts,a=`animation-${e}`,r=s[a];if(r)return r;let l;if(!1!==o.options.animation){const o=n.chart.config,s=o.datasetAnimationScopeKeys(n._type,e),a=o.getOptionScopes(n.getDataset(),s);l=o.createResolver(a,n.getContext(t,i,e))}const c=new hi(o,l&&l.animations);return l&&l._cacheable&&(s[a]=Object.freeze(c)),c}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,e){return!e||yi(t)||this.chart._animationsDisabled}updateElement(t,e,i,n){yi(n)?Object.assign(t,i):this._resolveAnimations(e,n).update(t,i)}updateSharedOptions(t,e,i){t&&!yi(e)&&this._resolveAnimations(void 0,e).update(t,i)}_setStyle(t,e,i,n){t.active=n;const o=this.getStyle(e,n);this._resolveAnimations(e,i,n).update(t,{options:!n&&this.getSharedOptions(o)||o})}removeHoverStyle(t,e,i){this._setStyle(t,i,"active",!1)}setHoverStyle(t,e,i){this._setStyle(t,i,"active",!0)}_removeDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){const e=this,i=e._data,n=e._cachedMeta.data;for(const[t,i,n]of e._syncList)e[t](i,n);e._syncList=[];const o=n.length,s=i.length,a=Math.min(s,o);a&&e.parse(0,a),s>o?e._insertElements(o,s-o,t):s{for(t.length+=e,r=t.length-1;r>=a;r--)t[r]=t[r-e]};for(l(s),r=t;rt-e)))}return t._cache.$bar}(t);let i,n,o,s,a=t._length;const r=()=>{32767!==o&&-32768!==o&&(S(s)&&(a=Math.min(a,Math.abs(o-s)||a)),s=o)};for(i=0,n=e.length;iMath.abs(r)&&(l=r,c=a),e[i.axis]=c,e._custom={barStart:l,barEnd:c,start:o,end:s,min:a,max:r}}(t,e,i,n):e[i.axis]=i.parse(t,n),e}function Si(t,e,i,n){const o=t.iScale,s=t.vScale,a=o.getLabels(),r=o===s,l=[];let c,h,d,u;for(c=i,h=i+n;c0?(m+=t,d-=t):d<0&&(m-=t,d+=t)}return{size:d,base:m,head:h,center:h+d/2}}_calculateBarIndexPixels(t,e){const i=this,n=e.scale,o=i.options,s=o.skipNull,r=d(o.maxBarThickness,1/0);let l,c;if(e.grouped){const n=s?i._getStackCount(t):e.stackCount,h="flex"===o.barThickness?function(t,e,i,n){const o=e.pixels,s=o[t];let a=t>0?o[t-1]:null,r=t=0;--n)i=Math.max(i,t[n].size()/2,e[n]._custom);return i>0&&i}getLabelAndValue(t){const e=this._cachedMeta,{xScale:i,yScale:n}=e,o=this.getParsed(t),s=i.getLabelForValue(o.x),a=n.getLabelForValue(o.y),r=o._custom;return{label:e.label,value:"("+s+", "+a+(r?", "+r:"")+")"}}update(t){const e=this._cachedMeta.data;this.updateElements(e,0,e.length,t)}updateElements(t,e,i,n){const o=this,s="reset"===n,{iScale:a,vScale:r}=o._cachedMeta,l=o.resolveDataElementOptions(e,n),c=o.getSharedOptions(l),h=o.includeOptions(n,c),d=a.axis,u=r.axis;for(let l=e;l""}}}};class Oi extends wi{constructor(t,e){super(t,e),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(t,e){const i=this.getDataset().data,n=this._cachedMeta;let o,s;for(o=t,s=t+e;oX(t,r,l,!0)?1:Math.max(e,e*i,n,n*i),g=(t,e,n)=>X(t,r,l,!0)?-1:Math.min(e,e*i,n,n*i),p=f(0,c,d),m=f(L,h,u),x=g(D,c,d),b=g(D+L,h,u);n=(p-x)/2,o=(m-b)/2,s=-(p+x)/2,a=-(m+b)/2}return{ratioX:n,ratioY:o,offsetX:s,offsetY:a}}(g,f,l),_=(n.width-a)/p,y=(n.height-a)/m,v=Math.max(Math.min(_,y)/2,0),w=u(e.options.radius,v),M=(w-Math.max(w*l,0))/e._getVisibleDatasetWeightTotal();e.offsetX=x*w,e.offsetY=b*w,o.total=e.calculateTotal(),e.outerRadius=w-M*e._getRingWeightOffset(e.index),e.innerRadius=Math.max(e.outerRadius-M*d,0),e.updateElements(s,0,s.length,t)}_circumference(t,e){const i=this,n=i.options,o=i._cachedMeta,s=i._getCircumference();return e&&n.animation.animateRotate||!this.chart.getDataVisibility(t)||null===o._parsed[t]?0:i.calculateCircumference(o._parsed[t]*s/C)}updateElements(t,e,i,n){const o=this,s="reset"===n,a=o.chart,r=a.chartArea,l=a.options.animation,c=(r.left+r.right)/2,h=(r.top+r.bottom)/2,d=s&&l.animateScale,u=d?0:o.innerRadius,f=d?0:o.outerRadius,g=o.resolveDataElementOptions(e,n),p=o.getSharedOptions(g),m=o.includeOptions(n,p);let x,b=o._getRotation();for(x=0;x0&&!isNaN(t)?C*(Math.abs(t)/e):0}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart,n=i.data.labels||[],o=qe(e._parsed[t],i.options.locale);return{label:n[t]||"",value:o}}getMaxBorderWidth(t){const e=this;let i=0;const n=e.chart;let o,s,a,r,l;if(!t)for(o=0,s=n.data.datasets.length;o"spacing"!==t,_indexable:t=>"spacing"!==t},Oi.overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:i}}=t.legend.options;return e.labels.map(((e,n)=>{const o=t.getDatasetMeta(0).controller.getStyle(n);return{text:e,fillStyle:o.backgroundColor,strokeStyle:o.borderColor,lineWidth:o.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(n),index:n}}))}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}},tooltip:{callbacks:{title:()=>"",label(t){let e=t.label;const i=": "+t.formattedValue;return r(e)?(e=e.slice(),e[0]+=i):e+=i,e}}}}};class Ti extends wi{initialize(){this.enableOptionSharing=!0,super.initialize()}update(t){const e=this,i=e._cachedMeta,{dataset:n,data:o=[],_dataset:s}=i,a=e.chart._animationsDisabled;let{start:r,count:l}=function(t,e,i){const n=e.length;let o=0,s=n;if(t._sorted){const{iScale:a,_parsed:r}=t,l=a.axis,{min:c,max:h,minDefined:d,maxDefined:u}=a.getUserBounds();d&&(o=q(Math.min(le(r,a.axis,c).lo,i?n:le(e,l,a.getPixelForValue(c)).lo),0,n-1)),s=u?q(Math.max(le(r,a.axis,h).hi+1,i?0:le(e,l,a.getPixelForValue(h)).hi+1),o,n)-o:n-o}return{start:o,count:s}}(i,o,a);e._drawStart=r,e._drawCount=l,function(t){const{xScale:e,yScale:i,_scaleRanges:n}=t,o={xmin:e.min,xmax:e.max,ymin:i.min,ymax:i.max};if(!n)return t._scaleRanges=o,!0;const s=n.xmin!==e.min||n.xmax!==e.max||n.ymin!==i.min||n.ymax!==i.max;return Object.assign(n,o),s}(i)&&(r=0,l=o.length),n._decimated=!!s._decimated,n.points=o;const c=e.resolveDatasetElementOptions(t);e.options.showLine||(c.borderWidth=0),c.segment=e.options.segment,e.updateElement(n,void 0,{animated:!a,options:c},t),e.updateElements(o,r,l,t)}updateElements(t,e,i,n){const o=this,s="reset"===n,{iScale:r,vScale:l,_stacked:c}=o._cachedMeta,h=o.resolveDataElementOptions(e,n),d=o.getSharedOptions(h),u=o.includeOptions(n,d),f=r.axis,g=l.axis,p=o.options.spanGaps,m=V(p)?p:Number.POSITIVE_INFINITY,x=o.chart._animationsDisabled||s||"none"===n;let b=e>0&&o.getParsed(e-1);for(let h=e;h0&&i[f]-b[f]>m,p.parsed=i,u&&(p.options=d||o.resolveDataElementOptions(h,e.active?"active":n)),x||o.updateElement(e,h,p,n),b=i}o.updateSharedOptions(d,n,h)}getMaxOverflow(){const t=this,e=t._cachedMeta,i=e.dataset,n=i.options&&i.options.borderWidth||0,o=e.data||[];if(!o.length)return n;const s=o[0].size(t.resolveDataElementOptions(0)),a=o[o.length-1].size(t.resolveDataElementOptions(o.length-1));return Math.max(n,s,a)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}}Ti.id="line",Ti.defaults={datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1},Ti.overrides={scales:{_index_:{type:"category"},_value_:{type:"linear"}}};class Ai extends wi{constructor(t,e){super(t,e),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart,n=i.data.labels||[],o=qe(e._parsed[t].r,i.options.locale);return{label:n[t]||"",value:o}}update(t){const e=this._cachedMeta.data;this._updateRadius(),this.updateElements(e,0,e.length,t)}_updateRadius(){const t=this,e=t.chart,i=e.chartArea,n=e.options,o=Math.min(i.right-i.left,i.bottom-i.top),s=Math.max(o/2,0),a=(s-Math.max(n.cutoutPercentage?s/100*n.cutoutPercentage:1,0))/e.getVisibleDatasetCount();t.outerRadius=s-a*t.index,t.innerRadius=t.outerRadius-a}updateElements(t,e,i,n){const o=this,s="reset"===n,a=o.chart,r=o.getDataset(),l=a.options.animation,c=o._cachedMeta.rScale,h=c.xCenter,d=c.yCenter,u=c.getIndexAngle(0)-.5*D;let f,g=u;const p=360/o.countVisibleElements();for(f=0;f{!isNaN(t.data[n])&&this.chart.getDataVisibility(n)&&i++})),i}_computeAngle(t,e,i){return this.chart.getDataVisibility(t)?H(this.resolveDataElementOptions(t,e).angle||i):0}}Ai.id="polarArea",Ai.defaults={dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0},Ai.overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:i}}=t.legend.options;return e.labels.map(((e,n)=>{const o=t.getDatasetMeta(0).controller.getStyle(n);return{text:e,fillStyle:o.backgroundColor,strokeStyle:o.borderColor,lineWidth:o.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(n),index:n}}))}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}},tooltip:{callbacks:{title:()=>"",label:t=>t.chart.data.labels[t.dataIndex]+": "+t.formattedValue}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};class Li extends Oi{}Li.id="pie",Li.defaults={cutout:0,rotation:0,circumference:360,radius:"100%"};class Ri extends wi{getLabelAndValue(t){const e=this._cachedMeta.vScale,i=this.getParsed(t);return{label:e.getLabels()[t],value:""+e.getLabelForValue(i[e.axis])}}update(t){const e=this,i=e._cachedMeta,n=i.dataset,o=i.data||[],s=i.iScale.getLabels();if(n.points=o,"resize"!==t){const i=e.resolveDatasetElementOptions(t);e.options.showLine||(i.borderWidth=0);const a={_loop:!0,_fullLoop:s.length===o.length,options:i};e.updateElement(n,void 0,a,t)}e.updateElements(o,0,o.length,t)}updateElements(t,e,i,n){const o=this,s=o.getDataset(),a=o._cachedMeta.rScale,r="reset"===n;for(let l=e;l"",label:t=>"("+t.label+", "+t.formattedValue+")"}}},scales:{x:{type:"linear"},y:{type:"linear"}}};var zi=Object.freeze({__proto__:null,BarController:Di,BubbleController:Ci,DoughnutController:Oi,LineController:Ti,PolarAreaController:Ai,PieController:Li,RadarController:Ri,ScatterController:Ei});function Ii(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class Fi{constructor(t){this.options=t||{}}formats(){return Ii()}parse(t,e){return Ii()}format(t,e){return Ii()}add(t,e,i){return Ii()}diff(t,e,i){return Ii()}startOf(t,e,i){return Ii()}endOf(t,e){return Ii()}}Fi.override=function(t){Object.assign(Fi.prototype,t)};var Vi={_date:Fi};function Bi(t,e){return"native"in t?{x:t.x,y:t.y}:Ve(t,e)}function Wi(t,e,i,n){const{controller:o,data:s,_sorted:a}=t,r=o._cachedMeta.iScale;if(r&&e===r.axis&&a&&s.length){const t=r._reversePixels?ce:le;if(!n)return t(s,e,i);if(o._sharedOptions){const n=s[0],o="function"==typeof n.getRange&&n.getRange(e);if(o){const n=t(s,e,i-o),a=t(s,e,i+o);return{lo:n.lo,hi:a.hi}}}}return{lo:0,hi:s.length-1}}function Hi(t,e,i,n,o){const s=t.getSortedVisibleDatasetMetas(),a=i[e];for(let t=0,i=s.length;t{t[r](o[a],n)&&s.push({element:t,datasetIndex:e,index:i}),t.inRange(o.x,o.y,n)&&(l=!0)})),i.intersect&&!l?[]:s}var Yi={modes:{index(t,e,i,n){const o=Bi(e,t),s=i.axis||"x",a=i.intersect?Ni(t,o,s,n):ji(t,o,s,!1,n),r=[];return a.length?(t.getSortedVisibleDatasetMetas().forEach((t=>{const e=a[0].index,i=t.data[e];i&&!i.skip&&r.push({element:i,datasetIndex:t.index,index:e})})),r):[]},dataset(t,e,i,n){const o=Bi(e,t),s=i.axis||"xy";let a=i.intersect?Ni(t,o,s,n):ji(t,o,s,!1,n);if(a.length>0){const e=a[0].datasetIndex,i=t.getDatasetMeta(e).data;a=[];for(let t=0;tNi(t,Bi(e,t),i.axis||"xy",n),nearest:(t,e,i,n)=>ji(t,Bi(e,t),i.axis||"xy",i.intersect,n),x:(t,e,i,n)=>(i.axis="x",$i(t,e,i,n)),y:(t,e,i,n)=>(i.axis="y",$i(t,e,i,n))}};const Ui=["left","top","right","bottom"];function Xi(t,e){return t.filter((t=>t.pos===e))}function qi(t,e){return t.filter((t=>-1===Ui.indexOf(t.pos)&&t.box.axis===e))}function Ki(t,e){return t.sort(((t,i)=>{const n=e?i:t,o=e?t:i;return n.weight===o.weight?n.index-o.index:n.weight-o.weight}))}function Zi(t,e,i,n){return Math.max(t[i],e[i])+Math.max(t[n],e[n])}function Gi(t,e){t.top=Math.max(t.top,e.top),t.left=Math.max(t.left,e.left),t.bottom=Math.max(t.bottom,e.bottom),t.right=Math.max(t.right,e.right)}function Qi(t,e,i){const n=i.box,o=t.maxPadding;l(i.pos)||(i.size&&(t[i.pos]-=i.size),i.size=i.horizontal?n.height:n.width,t[i.pos]+=i.size),n.getPadding&&Gi(o,n.getPadding());const s=Math.max(0,e.outerWidth-Zi(o,t,"left","right")),a=Math.max(0,e.outerHeight-Zi(o,t,"top","bottom")),r=s!==t.w,c=a!==t.h;return t.w=s,t.h=a,i.horizontal?{same:r,other:c}:{same:c,other:r}}function Ji(t,e){const i=e.maxPadding;function n(t){const n={left:0,top:0,right:0,bottom:0};return t.forEach((t=>{n[t]=Math.max(e[t],i[t])})),n}return n(t?["left","right"]:["top","bottom"])}function tn(t,e,i){const n=[];let o,s,a,r,l,c;for(o=0,s=t.length,l=0;ot.box.fullSize)),!0),n=Ki(Xi(e,"left"),!0),o=Ki(Xi(e,"right")),s=Ki(Xi(e,"top"),!0),a=Ki(Xi(e,"bottom")),r=qi(e,"x"),l=qi(e,"y");return{fullSize:i,leftAndTop:n.concat(s),rightAndBottom:o.concat(l).concat(a).concat(r),chartArea:Xi(e,"chartArea"),vertical:n.concat(o).concat(l),horizontal:s.concat(a).concat(r)}}(t.boxes),l=r.vertical,c=r.horizontal;g(t.boxes,(t=>{"function"==typeof t.beforeLayout&&t.beforeLayout()}));const h=l.reduce(((t,e)=>e.box.options&&!1===e.box.options.display?t:t+1),0)||1,d=Object.freeze({outerWidth:e,outerHeight:i,padding:o,availableWidth:s,availableHeight:a,vBoxMaxWidth:s/2/h,hBoxMaxHeight:a/2}),u=Object.assign({},o);Gi(u,oe(n));const f=Object.assign({maxPadding:u,w:s,h:a,x:o.left,y:o.top},o);!function(t,e){let i,n,o;for(i=0,n=t.length;i{const i=e.box;Object.assign(i,t.chartArea),i.update(f.w,f.h)}))}};class on{acquireContext(t,e){}releaseContext(t){return!1}addEventListener(t,e,i){}removeEventListener(t,e,i){}getDevicePixelRatio(){return 1}getMaximumSize(t,e,i,n){return e=Math.max(0,e||t.width),i=i||t.height,{width:e,height:Math.max(0,n?Math.floor(e/n):i)}}isAttached(t){return!0}}class sn extends on{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}}const an={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},rn=t=>null===t||""===t;const ln=!!Ne&&{passive:!0};function cn(t,e,i){t.canvas.removeEventListener(e,i,ln)}function hn(t,e,i){const n=t.canvas,o=n&&Re(n)||n,s=new MutationObserver((t=>{const e=Re(o);t.forEach((t=>{for(let n=0;n{t.forEach((t=>{for(let e=0;e{i.currentDevicePixelRatio!==t&&e()})))}function pn(t,i,n){const o=t.canvas,s=o&&Re(o);if(!s)return;const a=e(((t,e)=>{const i=s.clientWidth;n(t,e),i{const e=t[0],i=e.contentRect.width,n=e.contentRect.height;0===i&&0===n||a(i,n)}));return r.observe(s),function(t,e){un.size||window.addEventListener("resize",gn),un.set(t,e)}(t,a),r}function mn(t,e,i){i&&i.disconnect(),"resize"===e&&function(t){un.delete(t),un.size||window.removeEventListener("resize",gn)}(t)}function xn(t,i,n){const o=t.canvas,s=e((e=>{null!==t.ctx&&n(function(t,e){const i=an[t.type]||t.type,{x:n,y:o}=Ve(t,e);return{type:i,chart:e,native:t,x:void 0!==n?n:null,y:void 0!==o?o:null}}(e,t))}),t,(t=>{const e=t[0];return[e,e.offsetX,e.offsetY]}));return function(t,e,i){t.addEventListener(e,i,ln)}(o,i,s),s}class bn extends on{acquireContext(t,e){const i=t&&t.getContext&&t.getContext("2d");return i&&i.canvas===t?(function(t,e){const i=t.style,n=t.getAttribute("height"),o=t.getAttribute("width");if(t.$chartjs={initial:{height:n,width:o,style:{display:i.display,height:i.height,width:i.width}}},i.display=i.display||"block",i.boxSizing=i.boxSizing||"border-box",rn(o)){const e=je(t,"width");void 0!==e&&(t.width=e)}if(rn(n))if(""===t.style.height)t.height=t.width/(e||2);else{const e=je(t,"height");void 0!==e&&(t.height=e)}}(t,e),i):null}releaseContext(t){const e=t.canvas;if(!e.$chartjs)return!1;const i=e.$chartjs.initial;["height","width"].forEach((t=>{const n=i[t];a(n)?e.removeAttribute(t):e.setAttribute(t,n)}));const n=i.style||{};return Object.keys(n).forEach((t=>{e.style[t]=n[t]})),e.width=e.width,delete e.$chartjs,!0}addEventListener(t,e,i){this.removeEventListener(t,e);const n=t.$proxies||(t.$proxies={}),o={attach:hn,detach:dn,resize:pn}[e]||xn;n[e]=o(t,e,i)}removeEventListener(t,e){const i=t.$proxies||(t.$proxies={}),n=i[e];if(!n)return;({attach:mn,detach:mn,resize:mn}[e]||cn)(t,e,n),i[e]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,i,n){return We(t,e,i,n)}isAttached(t){const e=Re(t);return!(!e||!Re(e))}}class _n{constructor(){this.x=void 0,this.y=void 0,this.active=!1,this.options=void 0,this.$animations=void 0}tooltipPosition(t){const{x:e,y:i}=this.getProps(["x","y"],t);return{x:e,y:i}}hasValue(){return V(this.x)&&V(this.y)}getProps(t,e){const i=this,n=this.$animations;if(!e||!n)return i;const o={};return t.forEach((t=>{o[t]=n[t]&&n[t].active()?n[t]._to:i[t]})),o}}_n.defaults={},_n.defaultRoutes=void 0;const yn={values:t=>r(t)?t:""+t,numeric(t,e,i){if(0===t)return"0";const n=this.chart.options.locale;let o,s=t;if(i.length>1){const e=Math.max(Math.abs(i[0].value),Math.abs(i[i.length-1].value));(e<1e-4||e>1e15)&&(o="scientific"),s=function(t,e){let i=e.length>3?e[2].value-e[1].value:e[1].value-e[0].value;Math.abs(i)>=1&&t!==Math.floor(t)&&(i=t-Math.floor(t));return i}(t,i)}const a=z(Math.abs(s)),r=Math.max(Math.min(-1*Math.floor(a),20),0),l={notation:o,minimumFractionDigits:r,maximumFractionDigits:r};return Object.assign(l,this.options.ticks.format),qe(t,n,l)},logarithmic(t,e,i){if(0===t)return"0";const n=t/Math.pow(10,Math.floor(z(t)));return 1===n||2===n||5===n?yn.numeric.call(this,t,e,i):""}};var vn={formatters:yn};function wn(t,e){const i=t.options.ticks,n=i.maxTicksLimit||function(t){const e=t.options.offset,i=t._tickSize(),n=t._length/i+(e?0:1),o=t._maxLength/i;return Math.floor(Math.min(n,o))}(t),o=i.major.enabled?function(t){const e=[];let i,n;for(i=0,n=t.length;in)return function(t,e,i,n){let o,s=0,a=i[0];for(n=Math.ceil(n),o=0;ot-e)).pop(),e}(n);for(let t=0,e=s.length-1;to)return e}return Math.max(o,1)}(o,e,n);if(s>0){let t,i;const n=s>1?Math.round((l-r)/(s-1)):null;for(Mn(e,c,h,a(n)?0:r-n,r),t=0,i=s-1;te.lineWidth,tickColor:(t,e)=>e.color,offset:!1,borderDash:[],borderDashOffset:0,borderWidth:1},title:{display:!1,text:"",padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:"",padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:vn.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),Vt.route("scale.ticks","color","","color"),Vt.route("scale.grid","color","","borderColor"),Vt.route("scale.grid","borderColor","","borderColor"),Vt.route("scale.title","color","","color"),Vt.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&"callback"!==t&&"parser"!==t,_indexable:t=>"borderDash"!==t&&"tickBorderDash"!==t}),Vt.describe("scales",{_fallback:"scale"}),Vt.describe("scale.ticks",{_scriptable:t=>"backdropPadding"!==t&&"callback"!==t,_indexable:t=>"backdropPadding"!==t});const kn=(t,e,i)=>"top"===e||"left"===e?t[e]+i:t[e]-i;function Sn(t,e){const i=[],n=t.length/e,o=t.length;let s=0;for(;sa+r)))return c}function Dn(t){return t.drawTicks?t.tickLength:0}function Cn(t,e){if(!t.display)return 0;const i=se(t.font,e),n=oe(t.padding);return(r(t.text)?t.text.length:1)*i.lineHeight+n.height}function On(t,e,n){let o=i(t);return(n&&"right"!==e||!n&&"right"===e)&&(o=(t=>"left"===t?"right":"right"===t?"left":t)(o)),o}class Tn extends _n{constructor(t){super(),this.id=t.id,this.type=t.type,this.options=void 0,this.ctx=t.ctx,this.chart=t.chart,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this._margins={left:0,right:0,top:0,bottom:0},this.maxWidth=void 0,this.maxHeight=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.axis=void 0,this.labelRotation=void 0,this.min=void 0,this.max=void 0,this._range=void 0,this.ticks=[],this._gridLineItems=null,this._labelItems=null,this._labelSizes=null,this._length=0,this._maxLength=0,this._longestTextCache={},this._startPixel=void 0,this._endPixel=void 0,this._reversePixels=!1,this._userMax=void 0,this._userMin=void 0,this._suggestedMax=void 0,this._suggestedMin=void 0,this._ticksLength=0,this._borderValue=0,this._cache={},this._dataLimitsCached=!1,this.$context=void 0}init(t){const e=this;e.options=t.setContext(e.getContext()),e.axis=t.axis,e._userMin=e.parse(t.min),e._userMax=e.parse(t.max),e._suggestedMin=e.parse(t.suggestedMin),e._suggestedMax=e.parse(t.suggestedMax)}parse(t,e){return t}getUserBounds(){let{_userMin:t,_userMax:e,_suggestedMin:i,_suggestedMax:n}=this;return t=h(t,Number.POSITIVE_INFINITY),e=h(e,Number.NEGATIVE_INFINITY),i=h(i,Number.POSITIVE_INFINITY),n=h(n,Number.NEGATIVE_INFINITY),{min:h(t,i),max:h(e,n),minDefined:c(t),maxDefined:c(e)}}getMinMax(t){const e=this;let i,{min:n,max:o,minDefined:s,maxDefined:a}=e.getUserBounds();if(s&&a)return{min:n,max:o};const r=e.getMatchingVisibleMetas();for(let l=0,c=r.length;l=s||n<=1||!t.isHorizontal())return void(t.labelRotation=o);const h=t._getLabelSizes(),d=h.widest.width,u=h.highest.height,f=q(t.chart.width-d,0,t.maxWidth);a=e.offset?t.maxWidth/n:f/(n-1),d+6>a&&(a=f/(n-(e.offset?.5:1)),r=t.maxHeight-Dn(e.grid)-i.padding-Cn(e.title,t.chart.options.font),l=Math.sqrt(d*d+u*u),c=N(Math.min(Math.asin(Math.min((h.highest.height+6)/a,1)),Math.asin(Math.min(r/l,1))-Math.asin(u/l))),c=Math.max(o,Math.min(s,c))),t.labelRotation=c}afterCalculateLabelRotation(){f(this.options.afterCalculateLabelRotation,[this])}beforeFit(){f(this.options.beforeFit,[this])}fit(){const t=this,e={width:0,height:0},{chart:i,options:{ticks:n,title:o,grid:s}}=t,a=t._isVisible(),r=t.isHorizontal();if(a){const a=Cn(o,i.options.font);if(r?(e.width=t.maxWidth,e.height=Dn(s)+a):(e.height=t.maxHeight,e.width=Dn(s)+a),n.display&&t.ticks.length){const{first:i,last:o,widest:s,highest:a}=t._getLabelSizes(),l=2*n.padding,c=H(t.labelRotation),h=Math.cos(c),d=Math.sin(c);if(r){const i=n.mirror?0:d*s.width+h*a.height;e.height=Math.min(t.maxHeight,e.height+i+l)}else{const i=n.mirror?0:h*s.width+d*a.height;e.width=Math.min(t.maxWidth,e.width+i+l)}t._calculatePadding(i,o,d,h)}}t._handleMargins(),r?(t.width=t._length=i.width-t._margins.left-t._margins.right,t.height=e.height):(t.width=e.width,t.height=t._length=i.height-t._margins.top-t._margins.bottom)}_calculatePadding(t,e,i,n){const o=this,{ticks:{align:s,padding:a},position:r}=o.options,l=0!==o.labelRotation,c="top"!==r&&"x"===o.axis;if(o.isHorizontal()){const r=o.getPixelForTick(0)-o.left,h=o.right-o.getPixelForTick(o.ticks.length-1);let d=0,u=0;l?c?(d=n*t.width,u=i*e.height):(d=i*t.height,u=n*e.width):"start"===s?u=e.width:"end"===s?d=t.width:(d=t.width/2,u=e.width/2),o.paddingLeft=Math.max((d-r+a)*o.width/(o.width-r),0),o.paddingRight=Math.max((u-h+a)*o.width/(o.width-h),0)}else{let i=e.height/2,n=t.height/2;"start"===s?(i=0,n=t.height):"end"===s&&(i=e.height,n=0),o.paddingTop=i+a,o.paddingBottom=n+a}}_handleMargins(){const t=this;t._margins&&(t._margins.left=Math.max(t.paddingLeft,t._margins.left),t._margins.top=Math.max(t.paddingTop,t._margins.top),t._margins.right=Math.max(t.paddingRight,t._margins.right),t._margins.bottom=Math.max(t.paddingBottom,t._margins.bottom))}afterFit(){f(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:e}=this.options;return"top"===e||"bottom"===e||"x"===t}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){const e=this;let i,n;for(e.beforeTickToLabelConversion(),e.generateTickLabels(t),i=0,n=t.length;i{const i=t.gc,n=i.length/2;let o;if(n>e){for(o=0;o({width:o[t]||0,height:s[t]||0});return{first:k(0),last:k(e-1),widest:k(w),highest:k(M),widths:o,heights:s}}getLabelForValue(t){return t}getPixelForValue(t,e){return NaN}getValueForPixel(t){}getPixelForTick(t){const e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getPixelForDecimal(t){const e=this;e._reversePixels&&(t=1-t);const i=e._startPixel+t*e._length;return q(e._alignToPixels?Ht(e.chart,i,0):i,-32768,32767)}getDecimalForPixel(t){const e=(t-this._startPixel)/this._length;return this._reversePixels?1-e:e}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:t,max:e}=this;return t<0&&e<0?e:t>0&&e>0?t:0}getContext(t){const e=this,i=e.ticks||[];if(t>=0&&tr*o?r/n:l/o:l*o0}_computeGridLineItems(t){const e=this,i=e.axis,n=e.chart,o=e.options,{grid:s,position:a}=o,r=s.offset,c=e.isHorizontal(),h=e.ticks.length+(r?1:0),u=Dn(s),f=[],g=s.setContext(e.getContext()),p=g.drawBorder?g.borderWidth:0,m=p/2,x=function(t){return Ht(n,t,p)};let b,_,y,v,w,M,k,S,P,D,C,O;if("top"===a)b=x(e.bottom),M=e.bottom-u,S=b-m,D=x(t.top)+m,O=t.bottom;else if("bottom"===a)b=x(e.top),D=t.top,O=x(t.bottom)-m,M=b+m,S=e.top+u;else if("left"===a)b=x(e.right),w=e.right-u,k=b-m,P=x(t.left)+m,C=t.right;else if("right"===a)b=x(e.left),P=t.left,C=x(t.right)-m,w=b+m,k=e.left+u;else if("x"===i){if("center"===a)b=x((t.top+t.bottom)/2+.5);else if(l(a)){const t=Object.keys(a)[0],i=a[t];b=x(e.chart.scales[t].getPixelForValue(i))}D=t.top,O=t.bottom,M=b+m,S=M+u}else if("y"===i){if("center"===a)b=x((t.left+t.right)/2);else if(l(a)){const t=Object.keys(a)[0],i=a[t];b=x(e.chart.scales[t].getPixelForValue(i))}w=b-m,k=w-u,P=t.left,C=t.right}const T=d(o.ticks.maxTicksLimit,h),A=Math.max(1,Math.ceil(h/T));for(_=0;_e.value===t));if(n>=0){return i.setContext(e.getContext(n)).lineWidth}return 0}drawGrid(t){const e=this,i=e.options.grid,n=e.ctx,o=e._gridLineItems||(e._gridLineItems=e._computeGridLineItems(t));let s,a;const r=(t,e,i)=>{i.width&&i.color&&(n.save(),n.lineWidth=i.width,n.strokeStyle=i.color,n.setLineDash(i.borderDash||[]),n.lineDashOffset=i.borderDashOffset,n.beginPath(),n.moveTo(t.x,t.y),n.lineTo(e.x,e.y),n.stroke(),n.restore())};if(i.display)for(s=0,a=o.length;s{const n=i.split("."),o=n.pop(),s=[t].concat(n).join("."),a=e[i].split("."),r=a.pop(),l=a.join(".");Vt.route(s,o,l,r)}))}(e,t.defaultRoutes);t.descriptors&&Vt.describe(e,t.descriptors)}(t,a,n),e.override&&Vt.override(t.id,t.overrides)),a}get(t){return this.items[t]}unregister(t){const e=this.items,i=t.id,n=this.scope;i in e&&delete e[i],n&&i in Vt[n]&&(delete Vt[n][i],this.override&&delete Et[i])}}var Ln=new class{constructor(){this.controllers=new An(wi,"datasets",!0),this.elements=new An(_n,"elements"),this.plugins=new An(Object,"plugins"),this.scales=new An(Tn,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,e,i){const n=this;[...e].forEach((e=>{const o=i||n._getRegistryForType(e);i||o.isForType(e)||o===n.plugins&&e.id?n._exec(t,o,e):g(e,(e=>{const o=i||n._getRegistryForType(e);n._exec(t,o,e)}))}))}_exec(t,e,i){const n=k(t);f(i["before"+n],[],i),e[t](i),f(i["after"+n],[],i)}_getRegistryForType(t){for(let e=0;et.filter((t=>!e.some((e=>t.plugin.id===e.plugin.id))));this._notify(n(e,i),t,"stop"),this._notify(n(i,e),t,"start")}}function En(t,e){return e||!1!==t?!0===t?{}:t:null}function zn(t,e,i,n){const o=t.pluginScopeKeys(e),s=t.getOptionScopes(i,o);return t.createResolver(s,n,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function In(t,e){const i=Vt.datasets[t]||{};return((e.datasets||{})[t]||{}).indexAxis||e.indexAxis||i.indexAxis||"x"}function Fn(t,e){return"x"===t||"y"===t?t:e.axis||("top"===(i=e.position)||"bottom"===i?"x":"left"===i||"right"===i?"y":void 0)||t.charAt(0).toLowerCase();var i}function Vn(t){const e=t.options||(t.options={});e.plugins=d(e.plugins,{}),e.scales=function(t,e){const i=Et[t.type]||{scales:{}},n=e.scales||{},o=In(t.type,e),s=Object.create(null),a=Object.create(null);return Object.keys(n).forEach((t=>{const e=n[t],r=Fn(t,e),l=function(t,e){return t===e?"_index_":"_value_"}(r,o),c=i.scales||{};s[r]=s[r]||t,a[t]=y(Object.create(null),[{axis:r},e,c[r],c[l]])})),t.data.datasets.forEach((i=>{const o=i.type||t.type,r=i.indexAxis||In(o,e),l=(Et[o]||{}).scales||{};Object.keys(l).forEach((t=>{const e=function(t,e){let i=t;return"_index_"===t?i=e:"_value_"===t&&(i="x"===e?"y":"x"),i}(t,r),o=i[e+"AxisID"]||s[e]||e;a[o]=a[o]||Object.create(null),y(a[o],[{axis:e},n[o],l[t]])}))})),Object.keys(a).forEach((t=>{const e=a[t];y(e,[Vt.scales[e.type],Vt.scale])})),a}(t,e)}function Bn(t){return(t=t||{}).datasets=t.datasets||[],t.labels=t.labels||[],t}const Wn=new Map,Hn=new Set;function Nn(t,e){let i=Wn.get(t);return i||(i=e(),Wn.set(t,i),Hn.add(i)),i}const jn=(t,e,i)=>{const n=M(e,i);void 0!==n&&t.add(n)};class $n{constructor(t){this._config=function(t){return(t=t||{}).data=Bn(t.data),Vn(t),t}(t),this._scopeCache=new Map,this._resolverCache=new Map}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=Bn(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){const t=this._config;this.clearCache(),Vn(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return Nn(t,(()=>[[`datasets.${t}`,""]]))}datasetAnimationScopeKeys(t,e){return Nn(`${t}.transition.${e}`,(()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]]))}datasetElementScopeKeys(t,e){return Nn(`${t}-${e}`,(()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]]))}pluginScopeKeys(t){const e=t.id;return Nn(`${this.type}-plugin-${e}`,(()=>[[`plugins.${e}`,...t.additionalOptionScopes||[]]]))}_cachedScopes(t,e){const i=this._scopeCache;let n=i.get(t);return n&&!e||(n=new Map,i.set(t,n)),n}getOptionScopes(t,e,i){const{options:n,type:o}=this,s=this._cachedScopes(t,i),a=s.get(e);if(a)return a;const r=new Set;e.forEach((e=>{t&&(r.add(t),e.forEach((e=>jn(r,t,e)))),e.forEach((t=>jn(r,n,t))),e.forEach((t=>jn(r,Et[o]||{},t))),e.forEach((t=>jn(r,Vt,t))),e.forEach((t=>jn(r,zt,t)))}));const l=Array.from(r);return Hn.has(e)&&s.set(e,l),l}chartOptionScopes(){const{options:t,type:e}=this;return[t,Et[e]||{},Vt.datasets[e]||{},{type:e},Vt,zt]}resolveNamedOptions(t,e,i,n=[""]){const o={$shared:!0},{resolver:s,subPrefixes:a}=Yn(this._resolverCache,t,n);let l=s;if(function(t,e){const{isScriptable:i,isIndexable:n}=pe(t);for(const o of e)if(i(o)&&P(t[o])||n(o)&&r(t[o]))return!0;return!1}(s,e)){o.$shared=!1;l=ge(s,i=P(i)?i():i,this.createResolver(t,i,a))}for(const t of e)o[t]=l[t];return o}createResolver(t,e,i=[""],n){const{resolver:o}=Yn(this._resolverCache,t,i);return l(e)?ge(o,e,void 0,n):o}}function Yn(t,e,i){let n=t.get(e);n||(n=new Map,t.set(e,n));const o=i.join();let s=n.get(o);if(!s){s={resolver:fe(e,i),subPrefixes:i.filter((t=>!t.toLowerCase().includes("hover")))},n.set(o,s)}return s}const Un=["top","bottom","left","right","chartArea"];function Xn(t,e){return"top"===t||"bottom"===t||-1===Un.indexOf(t)&&"x"===e}function qn(t,e){return function(i,n){return i[t]===n[t]?i[e]-n[e]:i[t]-n[t]}}function Kn(t){const e=t.chart,i=e.options.animation;e.notifyPlugins("afterRender"),f(i&&i.onComplete,[t],e)}function Zn(t){const e=t.chart,i=e.options.animation;f(i&&i.onProgress,[t],e)}function Gn(){return"undefined"!=typeof window&&"undefined"!=typeof document}function Qn(t){return Gn()&&"string"==typeof t?t=document.getElementById(t):t&&t.length&&(t=t[0]),t&&t.canvas&&(t=t.canvas),t}const Jn={},to=t=>{const e=Qn(t);return Object.values(Jn).filter((t=>t.canvas===e)).pop()};class eo{constructor(t,e){const i=this;this.config=e=new $n(e);const n=Qn(t),o=to(n);if(o)throw new Error("Canvas is already in use. Chart with ID '"+o.id+"' must be destroyed before the canvas can be reused.");const a=e.createResolver(e.chartOptionScopes(),i.getContext());this.platform=i._initializePlatform(n,e);const r=i.platform.acquireContext(n,a.aspectRatio),l=r&&r.canvas,c=l&&l.height,h=l&&l.width;this.id=s(),this.ctx=r,this.canvas=l,this.width=h,this.height=c,this._options=a,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this.scale=void 0,this._plugins=new Rn,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=function(t,e){let i;return function(){return e?(clearTimeout(i),i=setTimeout(t,e)):t(),e}}((()=>this.update("resize")),a.resizeDelay||0),Jn[i.id]=i,r&&l?(si.listen(i,"complete",Kn),si.listen(i,"progress",Zn),i._initialize(),i.attached&&i.update()):console.error("Failed to create chart: can't acquire context from the given item")}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:e},width:i,height:n,_aspectRatio:o}=this;return a(t)?e&&o?o:n?i/n:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}_initialize(){const t=this;return t.notifyPlugins("beforeInit"),t.options.responsive?t.resize():He(t,t.options.devicePixelRatio),t.bindEvents(),t.notifyPlugins("afterInit"),t}_initializePlatform(t,e){return e.platform?new e.platform:!Gn()||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas?new sn:new bn}clear(){return Nt(this.canvas,this.ctx),this}stop(){return si.stop(this),this}resize(t,e){si.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){const i=this,n=i.options,o=i.canvas,s=n.maintainAspectRatio&&i.aspectRatio,a=i.platform.getMaximumSize(o,t,e,s),r=n.devicePixelRatio||i.platform.getDevicePixelRatio();i.width=a.width,i.height=a.height,i._aspectRatio=i.aspectRatio,He(i,r,!0)&&(i.notifyPlugins("resize",{size:a}),f(n.onResize,[i,a],i),i.attached&&i._doResize()&&i.render())}ensureScalesHaveIDs(){g(this.options.scales||{},((t,e)=>{t.id=e}))}buildOrUpdateScales(){const t=this,e=t.options,i=e.scales,n=t.scales,o=Object.keys(n).reduce(((t,e)=>(t[e]=!1,t)),{});let s=[];i&&(s=s.concat(Object.keys(i).map((t=>{const e=i[t],n=Fn(t,e),o="r"===n,s="x"===n;return{options:e,dposition:o?"chartArea":s?"bottom":"left",dtype:o?"radialLinear":s?"category":"linear"}})))),g(s,(i=>{const s=i.options,a=s.id,r=Fn(a,s),l=d(s.type,i.dtype);void 0!==s.position&&Xn(s.position,r)===Xn(i.dposition)||(s.position=i.dposition),o[a]=!0;let c=null;if(a in n&&n[a].type===l)c=n[a];else{c=new(Ln.getScale(l))({id:a,type:l,ctx:t.ctx,chart:t}),n[c.id]=c}c.init(s,e)})),g(o,((t,e)=>{t||delete n[e]})),g(n,(e=>{nn.configure(t,e,e.options),nn.addBox(t,e)}))}_updateMetasets(){const t=this,e=t._metasets,i=t.data.datasets.length,n=e.length;if(e.sort(((t,e)=>t.index-e.index)),n>i){for(let e=i;ei.length&&delete t._stacks,e.forEach(((e,n)=>{0===i.filter((t=>t===e._dataset)).length&&t._destroyDatasetMeta(n)}))}buildOrUpdateControllers(){const t=this,e=[],i=t.data.datasets;let n,o;for(t._removeUnreferencedMetasets(),n=0,o=i.length;n{t.getDatasetMeta(i).controller.reset()}),t)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const e=this,i=e.config;i.update(),e._options=i.createResolver(i.chartOptionScopes(),e.getContext()),g(e.scales,(t=>{nn.removeBox(e,t)}));const n=e._animationsDisabled=!e.options.animation;e.ensureScalesHaveIDs(),e.buildOrUpdateScales();if(((t,e)=>{if(t.size!==e.size)return!1;for(const i of t)if(!e.has(i))return!1;return!0})(new Set(Object.keys(e._listeners)),new Set(e.options.events))&&!!this._responsiveListeners===e.options.responsive||(e.unbindEvents(),e.bindEvents()),e._plugins.invalidate(),!1===e.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0}))return;const o=e.buildOrUpdateControllers();e.notifyPlugins("beforeElementsUpdate");let s=0;for(let t=0,i=e.data.datasets.length;t{t.reset()})),e._updateDatasets(t),e.notifyPlugins("afterUpdate",{mode:t}),e._layers.sort(qn("z","_idx")),e._lastEvent&&e._eventHandler(e._lastEvent,!0),e.render()}_updateLayout(t){const e=this;if(!1===e.notifyPlugins("beforeLayout",{cancelable:!0}))return;nn.update(e,e.width,e.height,t);const i=e.chartArea,n=i.width<=0||i.height<=0;e._layers=[],g(e.boxes,(t=>{n&&"chartArea"===t.position||(t.configure&&t.configure(),e._layers.push(...t._layers()))}),e),e._layers.forEach(((t,e)=>{t._idx=e})),e.notifyPlugins("afterLayout")}_updateDatasets(t){const e=this,i="function"==typeof t;if(!1!==e.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})){for(let n=0,o=e.data.datasets.length;n=0;--i)t._drawDataset(e[i]);t.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const e=this,i=e.ctx,n=t._clip,o=!n.disabled,s=e.chartArea,a={meta:t,index:t.index,cancelable:!0};!1!==e.notifyPlugins("beforeDatasetDraw",a)&&(o&&Yt(i,{left:!1===n.left?0:s.left-n.left,right:!1===n.right?e.width:s.right+n.right,top:!1===n.top?0:s.top-n.top,bottom:!1===n.bottom?e.height:s.bottom+n.bottom}),t.controller.draw(),o&&Ut(i),a.cancelable=!1,e.notifyPlugins("afterDatasetDraw",a))}getElementsAtEventForMode(t,e,i,n){const o=Yi.modes[e];return"function"==typeof o?o(this,t,i,n):[]}getDatasetMeta(t){const e=this.data.datasets[t],i=this._metasets;let n=i.filter((t=>t&&t._dataset===e)).pop();return n||(n={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:e&&e.order||0,index:t,_dataset:e,_parsed:[],_sorted:!1},i.push(n)),n}getContext(){return this.$context||(this.$context={chart:this,type:"chart"})}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const e=this.data.datasets[t];if(!e)return!1;const i=this.getDatasetMeta(t);return"boolean"==typeof i.hidden?!i.hidden:!e.hidden}setDatasetVisibility(t,e){this.getDatasetMeta(t).hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateDatasetVisibility(t,e){const i=this,n=e?"show":"hide",o=i.getDatasetMeta(t),s=o.controller._resolveAnimations(void 0,n);i.setDatasetVisibility(t,e),s.update(o,{visible:e}),i.update((e=>e.datasetIndex===t?n:void 0))}hide(t){this._updateDatasetVisibility(t,!1)}show(t){this._updateDatasetVisibility(t,!0)}_destroyDatasetMeta(t){const e=this,i=e._metasets&&e._metasets[t];i&&i.controller&&(i.controller._destroy(),delete e._metasets[t])}destroy(){const t=this,{canvas:e,ctx:i}=t;let n,o;for(t.stop(),si.remove(t),n=0,o=t.data.datasets.length;n((n,o)=>{i.addEventListener(t,n,o),e[n]=o})(o,n)))}bindResponsiveEvents(){const t=this;t._responsiveListeners||(t._responsiveListeners={});const e=t._responsiveListeners,i=t.platform,n=(n,o)=>{i.addEventListener(t,n,o),e[n]=o},o=(n,o)=>{e[n]&&(i.removeEventListener(t,n,o),delete e[n])},s=(e,i)=>{t.canvas&&t.resize(e,i)};let a;const r=()=>{o("attach",r),t.attached=!0,t.resize(),n("resize",s),n("detach",a)};a=()=>{t.attached=!1,o("resize",s),n("attach",r)},i.isAttached(t.canvas)?r():a()}unbindEvents(){const t=this;g(t._listeners,((e,i)=>{t.platform.removeEventListener(t,i,e)})),t._listeners={},g(t._responsiveListeners,((e,i)=>{t.platform.removeEventListener(t,i,e)})),t._responsiveListeners=void 0}updateHoverStyle(t,e,i){const n=i?"set":"remove";let o,s,a,r;for("dataset"===e&&(o=this.getDatasetMeta(t[0].datasetIndex),o.controller["_"+n+"DatasetHoverStyle"]()),a=0,r=t.length;a{const n=e.getDatasetMeta(t);if(!n)throw new Error("No dataset found at index "+t);return{datasetIndex:t,element:n.data[i],index:i}}));!p(n,i)&&(e._active=n,e._updateHoverStyles(n,i))}notifyPlugins(t,e,i){return this._plugins.notify(this,t,e,i)}_updateHoverStyles(t,e,i){const n=this,o=n.options.hover,s=(t,e)=>t.filter((t=>!e.some((e=>t.datasetIndex===e.datasetIndex&&t.index===e.index)))),a=s(e,t),r=i?t:s(t,e);a.length&&n.updateHoverStyle(a,o.mode,!1),r.length&&o.mode&&n.updateHoverStyle(r,o.mode,!0)}_eventHandler(t,e){const i=this,n={event:t,replay:e,cancelable:!0},o=e=>(e.options.events||this.options.events).includes(t.type);if(!1===i.notifyPlugins("beforeEvent",n,o))return;const s=i._handleEvent(t,e);return n.cancelable=!1,i.notifyPlugins("afterEvent",n,o),(s||n.changed)&&i.render(),i}_handleEvent(t,e){const i=this,{_active:n=[],options:o}=i,s=o.hover,a=e;let r=[],l=!1,c=null;return"mouseout"!==t.type&&(r=i.getElementsAtEventForMode(t,s.mode,s,a),c="click"===t.type?i._lastEvent:t),i._lastEvent=null,$t(t,i.chartArea,i._minPadding)&&(f(o.onHover,[t,r,i],i),"mouseup"!==t.type&&"click"!==t.type&&"contextmenu"!==t.type||f(o.onClick,[t,r,i],i)),l=!p(r,n),(l||e)&&(i._active=r,i._updateHoverStyles(r,n,e)),i._lastEvent=c,l}}const io=()=>g(eo.instances,(t=>t._plugins.invalidate())),no=!0;function oo(t,e,i){const{startAngle:n,pixelMargin:o,x:s,y:a,outerRadius:r,innerRadius:l}=e;let c=o/r;t.beginPath(),t.arc(s,a,r,n-c,i+c),l>o?(c=o/l,t.arc(s,a,l,i+c,n-c,!0)):t.arc(s,a,o,i+L,n-L),t.closePath(),t.clip()}function so(t,e,i,n){const o=ee(t.options.borderRadius,["outerStart","outerEnd","innerStart","innerEnd"]);const s=(i-e)/2,a=Math.min(s,n*e/2),r=t=>{const e=(i-Math.min(s,t))*n/2;return q(t,0,Math.min(s,e))};return{outerStart:r(o.outerStart),outerEnd:r(o.outerEnd),innerStart:q(o.innerStart,0,a),innerEnd:q(o.innerEnd,0,a)}}function ao(t,e,i,n){return{x:i+t*Math.cos(e),y:n+t*Math.sin(e)}}function ro(t,e,i,n,o){const{x:s,y:a,startAngle:r,pixelMargin:l,innerRadius:c}=e,h=Math.max(e.outerRadius+n+i-l,0),d=c>0?c+n+i+l:0;let u=0;const f=o-r;if(n){const t=((c>0?c-n:0)+(h>0?h-n:0))/2;u=(f-(0!==t?f*t/(t+n):f))/2}const g=(f-Math.max(.001,f*h-i/D)/h)/2,p=r+g+u,m=o-g-u,{outerStart:x,outerEnd:b,innerStart:_,innerEnd:y}=so(e,d,h,m-p),v=h-x,w=h-b,M=p+x/v,k=m-b/w,S=d+_,P=d+y,C=p+_/S,O=m-y/P;if(t.beginPath(),t.arc(s,a,h,M,k),b>0){const e=ao(w,k,s,a);t.arc(e.x,e.y,b,k,m+L)}const T=ao(P,m,s,a);if(t.lineTo(T.x,T.y),y>0){const e=ao(P,O,s,a);t.arc(e.x,e.y,y,m+L,O+Math.PI)}if(t.arc(s,a,d,m-y/d,p+_/d,!0),_>0){const e=ao(S,C,s,a);t.arc(e.x,e.y,_,C+Math.PI,p-L)}const A=ao(v,p,s,a);if(t.lineTo(A.x,A.y),x>0){const e=ao(v,M,s,a);t.arc(e.x,e.y,x,p-L,M)}t.closePath()}function lo(t,e,i,n,o){const{options:s}=e,a="inner"===s.borderAlign;s.borderWidth&&(a?(t.lineWidth=2*s.borderWidth,t.lineJoin="round"):(t.lineWidth=s.borderWidth,t.lineJoin="bevel"),e.fullCircles&&function(t,e,i){const{x:n,y:o,startAngle:s,pixelMargin:a,fullCircles:r}=e,l=Math.max(e.outerRadius-a,0),c=e.innerRadius+a;let h;for(i&&oo(t,e,s+C),t.beginPath(),t.arc(n,o,c,s+C,s,!0),h=0;h{Ln.add(...t),io()}},unregister:{enumerable:no,value:(...t)=>{Ln.remove(...t),io()}}});class co extends _n{constructor(t){super(),this.options=void 0,this.circumference=void 0,this.startAngle=void 0,this.endAngle=void 0,this.innerRadius=void 0,this.outerRadius=void 0,this.pixelMargin=0,this.fullCircles=0,t&&Object.assign(this,t)}inRange(t,e,i){const n=this.getProps(["x","y"],i),{angle:o,distance:s}=function(t,e){const i=e.x-t.x,n=e.y-t.y,o=Math.sqrt(i*i+n*n);let s=Math.atan2(n,i);return s<-.5*D&&(s+=C),{angle:s,distance:o}}(n,{x:t,y:e}),{startAngle:a,endAngle:r,innerRadius:l,outerRadius:c,circumference:h}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],i),d=this.options.spacing/2;return(h>=C||X(o,a,r))&&(s>=l+d&&s<=c+d)}getCenterPoint(t){const{x:e,y:i,startAngle:n,endAngle:o,innerRadius:s,outerRadius:a}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius","circumference"],t),{offset:r,spacing:l}=this.options,c=(n+o)/2,h=(s+a+l+r)/2;return{x:e+Math.cos(c)*h,y:i+Math.sin(c)*h}}tooltipPosition(t){return this.getCenterPoint(t)}draw(t){const e=this,{options:i,circumference:n}=e,o=(i.offset||0)/2,s=(i.spacing||0)/2;if(e.pixelMargin="inner"===i.borderAlign?.33:0,e.fullCircles=n>C?Math.floor(n/C):0,0===n||e.innerRadius<0||e.outerRadius<0)return;t.save();let a=0;if(o){a=o/2;const i=(e.startAngle+e.endAngle)/2;t.translate(Math.cos(i)*a,Math.sin(i)*a),e.circumference>=D&&(a=o)}t.fillStyle=i.backgroundColor,t.strokeStyle=i.borderColor;const r=function(t,e,i,n){const{fullCircles:o,startAngle:s,circumference:a}=e;let r=e.endAngle;if(o){ro(t,e,i,n,s+C);for(let e=0;er&&s>r;return{count:n,start:l,loop:e.loop,ilen:c(a+(c?r-t:t))%s,_=()=>{f!==g&&(t.lineTo(m,g),t.lineTo(m,f),t.lineTo(m,p))};for(l&&(d=o[b(0)],t.moveTo(d.x,d.y)),h=0;h<=r;++h){if(d=o[b(h)],d.skip)continue;const e=d.x,i=d.y,n=0|e;n===u?(ig&&(g=i),m=(x*m+e)/++x):(_(),t.lineTo(e,i),u=n,x=0,f=g=i),p=i}_()}function mo(t){const e=t.options,i=e.borderDash&&e.borderDash.length;return!(t._decimated||t._loop||e.tension||"monotone"===e.cubicInterpolationMode||e.stepped||i)?po:go}co.id="arc",co.defaults={borderAlign:"center",borderColor:"#fff",borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0},co.defaultRoutes={backgroundColor:"backgroundColor"};const xo="function"==typeof Path2D;function bo(t,e,i,n){xo&&1===e.segments.length?function(t,e,i,n){let o=e._path;o||(o=e._path=new Path2D,e.path(o,i,n)&&o.closePath()),ho(t,e.options),t.stroke(o)}(t,e,i,n):function(t,e,i,n){const{segments:o,options:s}=e,a=mo(e);for(const r of o)ho(t,s,r.style),t.beginPath(),a(t,e,r,{start:i,end:i+n-1})&&t.closePath(),t.stroke()}(t,e,i,n)}class _o extends _n{constructor(t){super(),this.animated=!0,this.options=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,t&&Object.assign(this,t)}updateControlPoints(t,e){const i=this,n=i.options;if((n.tension||"monotone"===n.cubicInterpolationMode)&&!n.stepped&&!i._pointsUpdated){const o=n.spanGaps?i._loop:i._fullLoop;Le(i._points,n,t,o,e),i._pointsUpdated=!0}}set points(t){const e=this;e._points=t,delete e._segments,delete e._path,e._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=function(t,e){const i=t.points,n=t.options.spanGaps,o=i.length;if(!o)return[];const s=!!t._loop,{start:a,end:r}=function(t,e,i,n){let o=0,s=e-1;if(i&&!n)for(;oo&&t[s%e].skip;)s--;return s%=e,{start:o,end:s}}(i,o,s,n);return ii(!0===n?[{start:a,end:r,loop:s}]:function(t,e,i,n){const o=t.length,s=[];let a,r=e,l=t[e];for(a=e+1;a<=i;++a){const i=t[a%o];i.skip||i.stop?l.skip||(n=!1,s.push({start:e%o,end:(a-1)%o,loop:n}),e=r=i.stop?a:null):(r=a,l.skip&&(e=a)),l=i}return null!==r&&s.push({start:e%o,end:r%o,loop:n}),s}(i,a,r"borderDash"!==t&&"fill"!==t};class vo extends _n{constructor(t){super(),this.options=void 0,this.parsed=void 0,this.skip=void 0,this.stop=void 0,t&&Object.assign(this,t)}inRange(t,e,i){const n=this.options,{x:o,y:s}=this.getProps(["x","y"],i);return Math.pow(t-o,2)+Math.pow(e-s,2)t.x):ko(e,"bottom","top",t.base=a.left&&e<=a.right)&&(s||i>=a.top&&i<=a.bottom)}function Oo(t,e){t.rect(e.x,e.y,e.w,e.h)}vo.id="point",vo.defaults={borderWidth:1,hitRadius:1,hoverBorderWidth:1,hoverRadius:4,pointStyle:"circle",radius:3,rotation:0},vo.defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};class To extends _n{constructor(t){super(),this.options=void 0,this.horizontal=void 0,this.base=void 0,this.width=void 0,this.height=void 0,t&&Object.assign(this,t)}draw(t){const e=this.options,{inner:i,outer:n}=Do(this),o=(s=n.radius).topLeft||s.topRight||s.bottomLeft||s.bottomRight?Gt:Oo;var s;t.save(),n.w===i.w&&n.h===i.h||(t.beginPath(),o(t,n),t.clip(),o(t,i),t.fillStyle=e.borderColor,t.fill("evenodd")),t.beginPath(),o(t,i),t.fillStyle=e.backgroundColor,t.fill(),t.restore()}inRange(t,e,i){return Co(this,t,e,i)}inXRange(t,e){return Co(this,t,null,e)}inYRange(t,e){return Co(this,null,t,e)}getCenterPoint(t){const{x:e,y:i,base:n,horizontal:o}=this.getProps(["x","y","base","horizontal"],t);return{x:o?(e+n)/2:e,y:o?i:(i+n)/2}}getRange(t){return"x"===t?this.width/2:this.height/2}}To.id="bar",To.defaults={borderSkipped:"start",borderWidth:0,borderRadius:0,enableBorderRadius:!0,pointStyle:void 0},To.defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};var Ao=Object.freeze({__proto__:null,ArcElement:co,LineElement:_o,PointElement:vo,BarElement:To});function Lo(t){if(t._decimated){const e=t._data;delete t._decimated,delete t._data,Object.defineProperty(t,"data",{value:e})}}function Ro(t){t.data.datasets.forEach((t=>{Lo(t)}))}var Eo={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(t,e,i)=>{if(!i.enabled)return void Ro(t);const n=t.width;t.data.datasets.forEach(((e,o)=>{const{_data:s,indexAxis:r}=e,l=t.getDatasetMeta(o),c=s||e.data;if("y"===ae([r,t.options.indexAxis]))return;if("line"!==l.type)return;const h=t.scales[l.xAxisID];if("linear"!==h.type&&"time"!==h.type)return;if(t.options.parsing)return;let d,{start:u,count:f}=function(t,e){const i=e.length;let n,o=0;const{iScale:s}=t,{min:a,max:r,minDefined:l,maxDefined:c}=s.getUserBounds();return l&&(o=q(le(e,s.axis,a).lo,0,i-1)),n=c?q(le(e,s.axis,r).hi+1,o,i)-o:i-o,{start:o,count:n}}(l,c);if(f<=4*n)Lo(e);else{switch(a(s)&&(e._data=c,delete e.data,Object.defineProperty(e,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(t){this._data=t}})),i.algorithm){case"lttb":d=function(t,e,i,n,o){const s=o.samples||n;if(s>=i)return t.slice(e,e+i);const a=[],r=(i-2)/(s-2);let l=0;const c=e+i-1;let h,d,u,f,g,p=e;for(a[l++]=t[p],h=0;hu&&(u=f,d=t[n],g=n);a[l++]=d,p=g}return a[l++]=t[c],a}(c,u,f,n,i);break;case"min-max":d=function(t,e,i,n){let o,s,r,l,c,h,d,u,f,g,p=0,m=0;const x=[],b=e+i-1,_=t[e].x,y=t[b].x-_;for(o=e;og&&(g=l,d=o),p=(m*p+s.x)/++m;else{const i=o-1;if(!a(h)&&!a(d)){const e=Math.min(h,d),n=Math.max(h,d);e!==u&&e!==i&&x.push({...t[e],x:p}),n!==u&&n!==i&&x.push({...t[n],x:p})}o>0&&i!==u&&x.push(t[i]),x.push(s),c=e,m=0,f=g=l,h=d=u=o}}return x}(c,u,f,n);break;default:throw new Error(`Unsupported decimation algorithm '${i.algorithm}'`)}e._decimated=d}}))},destroy(t){Ro(t)}};function zo(t,e,i){const n=function(t){const e=t.options,i=e.fill;let n=d(i&&i.target,i);return void 0===n&&(n=!!e.backgroundColor),!1!==n&&null!==n&&(!0===n?"origin":n)}(t);if(l(n))return!isNaN(n.value)&&n;let o=parseFloat(n);return c(o)&&Math.floor(o)===o?("-"!==n[0]&&"+"!==n[0]||(o=e+o),!(o===e||o<0||o>=i)&&o):["origin","start","end","stack"].indexOf(n)>=0&&n}class Io{constructor(t){this.x=t.x,this.y=t.y,this.radius=t.radius}pathSegment(t,e,i){const{x:n,y:o,radius:s}=this;return e=e||{start:0,end:C},t.arc(n,o,s,e.end,e.start,!0),!i.bounds}interpolate(t){const{x:e,y:i,radius:n}=this,o=t.angle;return{x:e+Math.cos(o)*n,y:i+Math.sin(o)*n,angle:o}}}function Fo(t){return(t.scale||{}).getPointPositionForValue?function(t){const{scale:e,fill:i}=t,n=e.options,o=e.getLabels().length,s=[],a=n.reverse?e.max:e.min,r=n.reverse?e.min:e.max;let c,h,d;if(d="start"===i?a:"end"===i?r:l(i)?i.value:e.getBaseValue(),n.grid.circular)return h=e.getPointPositionForValue(0,a),new Io({x:h.x,y:h.y,radius:e.getDistanceFromCenterForValue(d)});for(c=0;ct;e--){const t=i[e];if(!isNaN(t.x)&&!isNaN(t.y))break}return e}function Bo(t){const{chart:e,scale:i,index:n,line:o}=t,s=[],a=o.segments,r=o.points,l=function(t,e){const i=[],n=t.getSortedVisibleDatasetMetas();for(let t=0;t"line"===t.type&&!t.hidden;function Ho(t,e,i){const n=[];for(let o=0;o=n&&o<=c){r=o===n,l=o===c;break}}return{first:r,last:l,point:n}}function jo(t,e){let i=[],n=!1;return r(t)?(n=!0,i=t):i=function(t,e){const{x:i=null,y:n=null}=t||{},o=e.points,s=[];return e.segments.forEach((({start:t,end:e})=>{e=Vo(t,e,o);const a=o[t],r=o[e];null!==n?(s.push({x:a.x,y:n}),s.push({x:r.x,y:n})):null!==i&&(s.push({x:i,y:a.y}),s.push({x:i,y:r.y}))})),s}(t,e),i.length?new _o({points:i,options:{tension:0},_loop:n,_fullLoop:n}):null}function $o(t,e,i){let n=t[e].fill;const o=[e];let s;if(!i)return n;for(;!1!==n&&-1===o.indexOf(n);){if(!c(n))return n;if(s=t[n],!s)return!1;if(s.visible)return n;o.push(n),n=s.fill}return!1}function Yo(t,e,i){t.beginPath(),e.path(t),t.lineTo(e.last().x,i),t.lineTo(e.first().x,i),t.closePath(),t.clip()}function Uo(t,e,i,n){if(n)return;let o=e[t],s=i[t];return"angle"===t&&(o=U(o),s=U(s)),{property:t,start:o,end:s}}function Xo(t,e,i,n){return t&&e?n(t[i],e[i]):t?t[i]:e?e[i]:0}function qo(t,e,i){const{top:n,bottom:o}=e.chart.chartArea,{property:s,start:a,end:r}=i||{};"x"===s&&(t.beginPath(),t.rect(a,n,r-a,o-n),t.clip())}function Ko(t,e,i,n){const o=e.interpolate(i,n);o&&t.lineTo(o.x,o.y)}function Zo(t,e){const{line:i,target:n,property:o,color:s,scale:a}=e,r=function(t,e,i){const n=t.segments,o=t.points,s=e.points,a=[];for(const t of n){let{start:n,end:r}=t;r=Vo(n,r,o);const l=Uo(i,o[n],o[r],t.loop);if(!e.segments){a.push({source:t,target:l,start:o[n],end:o[r]});continue}const c=ei(e,l);for(const e of c){const n=Uo(i,s[e.start],s[e.end],e.loop),r=ti(t,o,n);for(const t of r)a.push({source:t,target:e,start:{[i]:Xo(l,n,"start",Math.max)},end:{[i]:Xo(l,n,"end",Math.min)}})}}return a}(i,n,o);for(const{source:e,target:l,start:c,end:h}of r){const{style:{backgroundColor:r=s}={}}=e;t.save(),t.fillStyle=r,qo(t,a,Uo(o,c,h)),t.beginPath();const d=!!i.pathSegment(t,e);d?t.closePath():Ko(t,n,h,o);const u=!!n.pathSegment(t,l,{move:d,reverse:!0}),f=d&&u;f||Ko(t,n,c,o),t.closePath(),t.fill(f?"evenodd":"nonzero"),t.restore()}}function Go(t,e,i){const n=function(t){const{chart:e,fill:i,line:n}=t;if(c(i))return function(t,e){const i=t.getDatasetMeta(e);return i&&t.isDatasetVisible(e)?i.dataset:null}(e,i);if("stack"===i)return Bo(t);const o=Fo(t);return o instanceof Io?o:jo(o,n)}(e),{line:o,scale:s,axis:a}=e,r=o.options,l=r.fill,h=r.backgroundColor,{above:d=h,below:u=h}=l||{};n&&o.points.length&&(Yt(t,i),function(t,e){const{line:i,target:n,above:o,below:s,area:a,scale:r}=e,l=i._loop?"angle":e.axis;t.save(),"x"===l&&s!==o&&(Yo(t,n,a.top),Zo(t,{line:i,target:n,color:o,scale:r,property:l}),t.restore(),t.save(),Yo(t,n,a.bottom)),Zo(t,{line:i,target:n,color:s,scale:r,property:l}),t.restore()}(t,{line:o,target:n,above:d,below:u,area:i,scale:s,axis:a}),Ut(t))}var Qo={id:"filler",afterDatasetsUpdate(t,e,i){const n=(t.data.datasets||[]).length,o=[];let s,a,r,l;for(a=0;a=0;--e){const i=o[e].$filler;i&&(i.line.updateControlPoints(s,i.axis),n&&Go(t.ctx,i,s))}},beforeDatasetsDraw(t,e,i){if("beforeDatasetsDraw"!==i.drawTime)return;const n=t.getSortedVisibleDatasetMetas();for(let e=n.length-1;e>=0;--e){const i=n[e].$filler;i&&Go(t.ctx,i,t.chartArea)}},beforeDatasetDraw(t,e,i){const n=e.meta.$filler;n&&!1!==n.fill&&"beforeDatasetDraw"===i.drawTime&&Go(t.ctx,n,t.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const Jo=(t,e)=>{let{boxHeight:i=e,boxWidth:n=e}=t;return t.usePointStyle&&(i=Math.min(i,e),n=Math.min(n,e)),{boxWidth:n,boxHeight:i,itemHeight:Math.max(e,i)}};class ts extends _n{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e,i){const n=this;n.maxWidth=t,n.maxHeight=e,n._margins=i,n.setDimensions(),n.buildLabels(),n.fit()}setDimensions(){const t=this;t.isHorizontal()?(t.width=t.maxWidth,t.left=t._margins.left,t.right=t.width):(t.height=t.maxHeight,t.top=t._margins.top,t.bottom=t.height)}buildLabels(){const t=this,e=t.options.labels||{};let i=f(e.generateLabels,[t.chart],t)||[];e.filter&&(i=i.filter((i=>e.filter(i,t.chart.data)))),e.sort&&(i=i.sort(((i,n)=>e.sort(i,n,t.chart.data)))),t.options.reverse&&i.reverse(),t.legendItems=i}fit(){const t=this,{options:e,ctx:i}=t;if(!e.display)return void(t.width=t.height=0);const n=e.labels,o=se(n.font),s=o.size,a=t._computeTitleHeight(),{boxWidth:r,itemHeight:l}=Jo(n,s);let c,h;i.font=o.string,t.isHorizontal()?(c=t.maxWidth,h=t._fitRows(a,s,r,l)+10):(h=t.maxHeight,c=t._fitCols(a,s,r,l)+10),t.width=Math.min(c,e.maxWidth||t.maxWidth),t.height=Math.min(h,e.maxHeight||t.maxHeight)}_fitRows(t,e,i,n){const o=this,{ctx:s,maxWidth:a,options:{labels:{padding:r}}}=o,l=o.legendHitBoxes=[],c=o.lineWidths=[0],h=n+r;let d=t;s.textAlign="left",s.textBaseline="middle";let u=-1,f=-h;return o.legendItems.forEach(((t,o)=>{const g=i+e/2+s.measureText(t.text).width;(0===o||c[c.length-1]+g+2*r>a)&&(d+=h,c[c.length-(o>0?0:1)]=0,f+=h,u++),l[o]={left:0,top:f,row:u,width:g,height:n},c[c.length-1]+=g+r})),d}_fitCols(t,e,i,n){const o=this,{ctx:s,maxHeight:a,options:{labels:{padding:r}}}=o,l=o.legendHitBoxes=[],c=o.columnSizes=[],h=a-t;let d=r,u=0,f=0,g=0,p=0;return o.legendItems.forEach(((t,o)=>{const a=i+e/2+s.measureText(t.text).width;o>0&&f+n+2*r>h&&(d+=u+r,c.push({width:u,height:f}),g+=u+r,p++,u=f=0),l[o]={left:g,top:f,col:p,width:a,height:n},u=Math.max(u,a),f+=n+r})),d+=u,c.push({width:u,height:f}),d}adjustHitBoxes(){const t=this;if(!t.options.display)return;const e=t._computeTitleHeight(),{legendHitBoxes:i,options:{align:o,labels:{padding:s},rtl:a}}=t;if(this.isHorizontal()){let r=0,l=n(o,t.left+s,t.right-t.lineWidths[r]);for(const a of i)r!==a.row&&(r=a.row,l=n(o,t.left+s,t.right-t.lineWidths[r])),a.top+=t.top+e+s,a.left=l,l+=a.width+s;if(a){const e=i.reduce(((t,e)=>(t[e.row]=t[e.row]||[],t[e.row].push(e),t)),{}),n=[];Object.keys(e).forEach((t=>{e[t].reverse(),n.push(...e[t])})),t.legendHitBoxes=n}}else{let a=0,r=n(o,t.top+e+s,t.bottom-t.columnSizes[a].height);for(const l of i)l.col!==a&&(a=l.col,r=n(o,t.top+e+s,t.bottom-t.columnSizes[a].height)),l.top=r,l.left+=t.left+s,r+=l.height+s}}isHorizontal(){return"top"===this.options.position||"bottom"===this.options.position}draw(){const t=this;if(t.options.display){const e=t.ctx;Yt(e,t),t._draw(),Ut(e)}}_draw(){const t=this,{options:e,columnSizes:i,lineWidths:o,ctx:s}=t,{align:a,labels:r}=e,l=Vt.color,c=Ke(e.rtl,t.left,t.width),h=se(r.font),{color:u,padding:f}=r,g=h.size,p=g/2;let m;t.drawTitle(),s.textAlign=c.textAlign("left"),s.textBaseline="middle",s.lineWidth=.5,s.font=h.string;const{boxWidth:x,boxHeight:b,itemHeight:_}=Jo(r,g),y=t.isHorizontal(),v=this._computeTitleHeight();m=y?{x:n(a,t.left+f,t.right-o[0]),y:t.top+f+v,line:0}:{x:t.left+f,y:n(a,t.top+v+f,t.bottom-i[0].height),line:0},Ze(t.ctx,e.textDirection);const w=_+f;t.legendItems.forEach(((M,k)=>{s.strokeStyle=M.fontColor||u,s.fillStyle=M.fontColor||u;const S=s.measureText(M.text).width,P=c.textAlign(M.textAlign||(M.textAlign=r.textAlign)),D=x+p+S;let C=m.x,O=m.y;c.setWidth(t.width),y?k>0&&C+D+f>t.right&&(O=m.y+=w,m.line++,C=m.x=n(a,t.left+f,t.right-o[m.line])):k>0&&O+w>t.bottom&&(C=m.x=C+i[m.line].width+f,m.line++,O=m.y=n(a,t.top+v+f,t.bottom-i[m.line].height));!function(t,e,i){if(isNaN(x)||x<=0||isNaN(b)||b<0)return;s.save();const n=d(i.lineWidth,1);if(s.fillStyle=d(i.fillStyle,l),s.lineCap=d(i.lineCap,"butt"),s.lineDashOffset=d(i.lineDashOffset,0),s.lineJoin=d(i.lineJoin,"miter"),s.lineWidth=n,s.strokeStyle=d(i.strokeStyle,l),s.setLineDash(d(i.lineDash,[])),r.usePointStyle){const o={radius:x*Math.SQRT2/2,pointStyle:i.pointStyle,rotation:i.rotation,borderWidth:n},a=c.xPlus(t,x/2);jt(s,o,a,e+p)}else{const o=e+Math.max((g-b)/2,0),a=c.leftForLtr(t,x),r=ne(i.borderRadius);s.beginPath(),Object.values(r).some((t=>0!==t))?Gt(s,{x:a,y:o,w:x,h:b,radius:r}):s.rect(a,o,x,b),s.fill(),0!==n&&s.stroke()}s.restore()}(c.x(C),O,M),C=((t,e,i,n)=>t===(n?"left":"right")?i:"center"===t?(e+i)/2:e)(P,C+x+p,y?C+D:t.right,e.rtl),function(t,e,i){Kt(s,i.text,t,e+_/2,h,{strikethrough:i.hidden,textAlign:c.textAlign(i.textAlign)})}(c.x(C),O,M),y?m.x+=D+f:m.y+=w})),Ge(t.ctx,e.textDirection)}drawTitle(){const t=this,e=t.options,o=e.title,s=se(o.font),a=oe(o.padding);if(!o.display)return;const r=Ke(e.rtl,t.left,t.width),l=t.ctx,c=o.position,h=s.size/2,d=a.top+h;let u,f=t.left,g=t.width;if(this.isHorizontal())g=Math.max(...t.lineWidths),u=t.top+d,f=n(e.align,f,t.right-g);else{const i=t.columnSizes.reduce(((t,e)=>Math.max(t,e.height)),0);u=d+n(e.align,t.top,t.bottom-i-e.labels.padding-t._computeTitleHeight())}const p=n(c,f,f+g);l.textAlign=r.textAlign(i(c)),l.textBaseline="middle",l.strokeStyle=o.color,l.fillStyle=o.color,l.font=s.string,Kt(l,o.text,p,u,s)}_computeTitleHeight(){const t=this.options.title,e=se(t.font),i=oe(t.padding);return t.display?e.lineHeight+i.height:0}_getLegendItemAt(t,e){const i=this;let n,o,s;if(t>=i.left&&t<=i.right&&e>=i.top&&e<=i.bottom)for(s=i.legendHitBoxes,n=0;n=o.left&&t<=o.left+o.width&&e>=o.top&&e<=o.top+o.height)return i.legendItems[n];return null}handleEvent(t){const e=this,i=e.options;if(!function(t,e){if("mousemove"===t&&(e.onHover||e.onLeave))return!0;if(e.onClick&&("click"===t||"mouseup"===t))return!0;return!1}(t.type,i))return;const n=e._getLegendItemAt(t.x,t.y);if("mousemove"===t.type){const a=e._hoveredItem,r=(s=n,null!==(o=a)&&null!==s&&o.datasetIndex===s.datasetIndex&&o.index===s.index);a&&!r&&f(i.onLeave,[t,a,e],e),e._hoveredItem=n,n&&!r&&f(i.onHover,[t,n,e],e)}else n&&f(i.onClick,[t,n,e],e);var o,s}}var es={id:"legend",_element:ts,start(t,e,i){const n=t.legend=new ts({ctx:t.ctx,options:i,chart:t});nn.configure(t,n,i),nn.addBox(t,n)},stop(t){nn.removeBox(t,t.legend),delete t.legend},beforeUpdate(t,e,i){const n=t.legend;nn.configure(t,n,i),n.options=i},afterUpdate(t){const e=t.legend;e.buildLabels(),e.adjustHitBoxes()},afterEvent(t,e){e.replay||t.legend.handleEvent(e.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(t,e,i){const n=e.datasetIndex,o=i.chart;o.isDatasetVisible(n)?(o.hide(n),e.hidden=!0):(o.show(n),e.hidden=!1)},onHover:null,onLeave:null,labels:{color:t=>t.chart.options.color,boxWidth:40,padding:10,generateLabels(t){const e=t.data.datasets,{labels:{usePointStyle:i,pointStyle:n,textAlign:o,color:s}}=t.legend.options;return t._getSortedDatasetMetas().map((t=>{const a=t.controller.getStyle(i?0:void 0),r=oe(a.borderWidth);return{text:e[t.index].label,fillStyle:a.backgroundColor,fontColor:s,hidden:!t.visible,lineCap:a.borderCapStyle,lineDash:a.borderDash,lineDashOffset:a.borderDashOffset,lineJoin:a.borderJoinStyle,lineWidth:(r.width+r.height)/4,strokeStyle:a.borderColor,pointStyle:n||a.pointStyle,rotation:a.rotation,textAlign:o||a.textAlign,borderRadius:0,datasetIndex:t.index}}),this)}},title:{color:t=>t.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:t=>!t.startsWith("on"),labels:{_scriptable:t=>!["generateLabels","filter","sort"].includes(t)}}};class is extends _n{constructor(t){super(),this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e){const i=this,n=i.options;if(i.left=0,i.top=0,!n.display)return void(i.width=i.height=i.right=i.bottom=0);i.width=i.right=t,i.height=i.bottom=e;const o=r(n.text)?n.text.length:1;i._padding=oe(n.padding);const s=o*se(n.font).lineHeight+i._padding.height;i.isHorizontal()?i.height=s:i.width=s}isHorizontal(){const t=this.options.position;return"top"===t||"bottom"===t}_drawArgs(t){const{top:e,left:i,bottom:o,right:s,options:a}=this,r=a.align;let l,c,h,d=0;return this.isHorizontal()?(c=n(r,i,s),h=e+t,l=s-i):("left"===a.position?(c=i+t,h=n(r,o,e),d=-.5*D):(c=s-t,h=n(r,e,o),d=.5*D),l=o-e),{titleX:c,titleY:h,maxWidth:l,rotation:d}}draw(){const t=this,e=t.ctx,n=t.options;if(!n.display)return;const o=se(n.font),s=o.lineHeight/2+t._padding.top,{titleX:a,titleY:r,maxWidth:l,rotation:c}=t._drawArgs(s);Kt(e,n.text,0,0,o,{color:n.color,maxWidth:l,rotation:c,textAlign:i(n.align),textBaseline:"middle",translation:[a,r]})}}var ns={id:"title",_element:is,start(t,e,i){!function(t,e){const i=new is({ctx:t.ctx,options:e,chart:t});nn.configure(t,i,e),nn.addBox(t,i),t.titleBlock=i}(t,i)},stop(t){const e=t.titleBlock;nn.removeBox(t,e),delete t.titleBlock},beforeUpdate(t,e,i){const n=t.titleBlock;nn.configure(t,n,i),n.options=i},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const os=new WeakMap;var ss={id:"subtitle",start(t,e,i){const n=new is({ctx:t.ctx,options:i,chart:t});nn.configure(t,n,i),nn.addBox(t,n),os.set(t,n)},stop(t){nn.removeBox(t,os.get(t)),os.delete(t)},beforeUpdate(t,e,i){const n=os.get(t);nn.configure(t,n,i),n.options=i},defaults:{align:"center",display:!1,font:{weight:"normal"},fullSize:!0,padding:0,position:"top",text:"",weight:1500},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const as={average(t){if(!t.length)return!1;let e,i,n=0,o=0,s=0;for(e=0,i=t.length;e-1?t.split("\n"):t}function cs(t,e){const{element:i,datasetIndex:n,index:o}=e,s=t.getDatasetMeta(n).controller,{label:a,value:r}=s.getLabelAndValue(o);return{chart:t,label:a,parsed:s.getParsed(o),raw:t.data.datasets[n].data[o],formattedValue:r,dataset:s.getDataset(),dataIndex:o,datasetIndex:n,element:i}}function hs(t,e){const i=t._chart.ctx,{body:n,footer:o,title:s}=t,{boxWidth:a,boxHeight:r}=e,l=se(e.bodyFont),c=se(e.titleFont),h=se(e.footerFont),d=s.length,u=o.length,f=n.length,p=oe(e.padding);let m=p.height,x=0,b=n.reduce(((t,e)=>t+e.before.length+e.lines.length+e.after.length),0);if(b+=t.beforeBody.length+t.afterBody.length,d&&(m+=d*c.lineHeight+(d-1)*e.titleSpacing+e.titleMarginBottom),b){m+=f*(e.displayColors?Math.max(r,l.lineHeight):l.lineHeight)+(b-f)*l.lineHeight+(b-1)*e.bodySpacing}u&&(m+=e.footerMarginTop+u*h.lineHeight+(u-1)*e.footerSpacing);let _=0;const y=function(t){x=Math.max(x,i.measureText(t).width+_)};return i.save(),i.font=c.string,g(t.title,y),i.font=l.string,g(t.beforeBody.concat(t.afterBody),y),_=e.displayColors?a+2:0,g(n,(t=>{g(t.before,y),g(t.lines,y),g(t.after,y)})),_=0,i.font=h.string,g(t.footer,y),i.restore(),x+=p.width,{width:x,height:m}}function ds(t,e,i,n){const{x:o,width:s}=i,{width:a,chartArea:{left:r,right:l}}=t;let c="center";return"center"===n?c=o<=(r+l)/2?"left":"right":o<=s/2?c="left":o>=a-s/2&&(c="right"),function(t,e,i,n){const{x:o,width:s}=n,a=i.caretSize+i.caretPadding;return"left"===t&&o+s+a>e.width||"right"===t&&o-s-a<0||void 0}(c,t,e,i)&&(c="center"),c}function us(t,e,i){const n=e.yAlign||function(t,e){const{y:i,height:n}=e;return it.height-n/2?"bottom":"center"}(t,i);return{xAlign:e.xAlign||ds(t,e,i,n),yAlign:n}}function fs(t,e,i,n){const{caretSize:o,caretPadding:s,cornerRadius:a}=t,{xAlign:r,yAlign:l}=i,c=o+s,h=a+s;let d=function(t,e){let{x:i,width:n}=t;return"right"===e?i-=n:"center"===e&&(i-=n/2),i}(e,r);const u=function(t,e,i){let{y:n,height:o}=t;return"top"===e?n+=i:n-="bottom"===e?o+i:o/2,n}(e,l,c);return"center"===l?"left"===r?d+=c:"right"===r&&(d-=c):"left"===r?d-=h:"right"===r&&(d+=h),{x:q(d,0,n.width-e.width),y:q(u,0,n.height-e.height)}}function gs(t,e,i){const n=oe(i.padding);return"center"===e?t.x+t.width/2:"right"===e?t.x+t.width-n.right:t.x+n.left}function ps(t){return rs([],ls(t))}function ms(t,e){const i=e&&e.dataset&&e.dataset.tooltip&&e.dataset.tooltip.callbacks;return i?t.override(i):t}class xs extends _n{constructor(t){super(),this.opacity=0,this._active=[],this._chart=t._chart,this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const t=this,e=t._cachedAnimations;if(e)return e;const i=t._chart,n=t.options.setContext(t.getContext()),o=n.enabled&&i.options.animation&&n.animations,s=new hi(t._chart,o);return o._cacheable&&(t._cachedAnimations=Object.freeze(s)),s}getContext(){const t=this;return t.$context||(t.$context=(e=t._chart.getContext(),i=t,n=t._tooltipItems,Object.assign(Object.create(e),{tooltip:i,tooltipItems:n,type:"tooltip"})));var e,i,n}getTitle(t,e){const i=this,{callbacks:n}=e,o=n.beforeTitle.apply(i,[t]),s=n.title.apply(i,[t]),a=n.afterTitle.apply(i,[t]);let r=[];return r=rs(r,ls(o)),r=rs(r,ls(s)),r=rs(r,ls(a)),r}getBeforeBody(t,e){return ps(e.callbacks.beforeBody.apply(this,[t]))}getBody(t,e){const i=this,{callbacks:n}=e,o=[];return g(t,(t=>{const e={before:[],lines:[],after:[]},s=ms(n,t);rs(e.before,ls(s.beforeLabel.call(i,t))),rs(e.lines,s.label.call(i,t)),rs(e.after,ls(s.afterLabel.call(i,t))),o.push(e)})),o}getAfterBody(t,e){return ps(e.callbacks.afterBody.apply(this,[t]))}getFooter(t,e){const i=this,{callbacks:n}=e,o=n.beforeFooter.apply(i,[t]),s=n.footer.apply(i,[t]),a=n.afterFooter.apply(i,[t]);let r=[];return r=rs(r,ls(o)),r=rs(r,ls(s)),r=rs(r,ls(a)),r}_createItems(t){const e=this,i=e._active,n=e._chart.data,o=[],s=[],a=[];let r,l,c=[];for(r=0,l=i.length;rt.filter(e,i,o,n)))),t.itemSort&&(c=c.sort(((e,i)=>t.itemSort(e,i,n)))),g(c,(i=>{const n=ms(t.callbacks,i);o.push(n.labelColor.call(e,i)),s.push(n.labelPointStyle.call(e,i)),a.push(n.labelTextColor.call(e,i))})),e.labelColors=o,e.labelPointStyles=s,e.labelTextColors=a,e.dataPoints=c,c}update(t,e){const i=this,n=i.options.setContext(i.getContext()),o=i._active;let s,a=[];if(o.length){const t=as[n.position].call(i,o,i._eventPosition);a=i._createItems(n),i.title=i.getTitle(a,n),i.beforeBody=i.getBeforeBody(a,n),i.body=i.getBody(a,n),i.afterBody=i.getAfterBody(a,n),i.footer=i.getFooter(a,n);const e=i._size=hs(i,n),r=Object.assign({},t,e),l=us(i._chart,n,r),c=fs(n,r,l,i._chart);i.xAlign=l.xAlign,i.yAlign=l.yAlign,s={opacity:1,x:c.x,y:c.y,width:e.width,height:e.height,caretX:t.x,caretY:t.y}}else 0!==i.opacity&&(s={opacity:0});i._tooltipItems=a,i.$context=void 0,s&&i._resolveAnimations().update(i,s),t&&n.external&&n.external.call(i,{chart:i._chart,tooltip:i,replay:e})}drawCaret(t,e,i,n){const o=this.getCaretPosition(t,i,n);e.lineTo(o.x1,o.y1),e.lineTo(o.x2,o.y2),e.lineTo(o.x3,o.y3)}getCaretPosition(t,e,i){const{xAlign:n,yAlign:o}=this,{cornerRadius:s,caretSize:a}=i,{x:r,y:l}=t,{width:c,height:h}=e;let d,u,f,g,p,m;return"center"===o?(p=l+h/2,"left"===n?(d=r,u=d-a,g=p+a,m=p-a):(d=r+c,u=d+a,g=p-a,m=p+a),f=d):(u="left"===n?r+s+a:"right"===n?r+c-s-a:this.caretX,"top"===o?(g=l,p=g-a,d=u-a,f=u+a):(g=l+h,p=g+a,d=u+a,f=u-a),m=g),{x1:d,x2:u,x3:f,y1:g,y2:p,y3:m}}drawTitle(t,e,i){const n=this,o=n.title,s=o.length;let a,r,l;if(s){const c=Ke(i.rtl,n.x,n.width);for(t.x=gs(n,i.titleAlign,i),e.textAlign=c.textAlign(i.titleAlign),e.textBaseline="middle",a=se(i.titleFont),r=i.titleSpacing,e.fillStyle=i.titleColor,e.font=a.string,l=0;l0!==t))?(t.beginPath(),t.fillStyle=o.multiKeyBackground,Gt(t,{x:e,y:g,w:c,h:l,radius:s}),t.fill(),t.stroke(),t.fillStyle=a.backgroundColor,t.beginPath(),Gt(t,{x:i,y:g+1,w:c-2,h:l-2,radius:s}),t.fill()):(t.fillStyle=o.multiKeyBackground,t.fillRect(e,g,c,l),t.strokeRect(e,g,c,l),t.fillStyle=a.backgroundColor,t.fillRect(i,g+1,c-2,l-2))}t.fillStyle=s.labelTextColors[i]}drawBody(t,e,i){const n=this,{body:o}=n,{bodySpacing:s,bodyAlign:a,displayColors:r,boxHeight:l,boxWidth:c}=i,h=se(i.bodyFont);let d=h.lineHeight,u=0;const f=Ke(i.rtl,n.x,n.width),p=function(i){e.fillText(i,f.x(t.x+u),t.y+d/2),t.y+=d+s},m=f.textAlign(a);let x,b,_,y,v,w,M;for(e.textAlign=a,e.textBaseline="middle",e.font=h.string,t.x=gs(n,m,i),e.fillStyle=i.bodyColor,g(n.beforeBody,p),u=r&&"right"!==m?"center"===a?c/2+1:c+2:0,y=0,w=o.length;y0&&e.stroke()}_updateAnimationTarget(t){const e=this,i=e._chart,n=e.$animations,o=n&&n.x,s=n&&n.y;if(o||s){const n=as[t.position].call(e,e._active,e._eventPosition);if(!n)return;const a=e._size=hs(e,t),r=Object.assign({},n,e._size),l=us(i,t,r),c=fs(t,r,l,i);o._to===c.x&&s._to===c.y||(e.xAlign=l.xAlign,e.yAlign=l.yAlign,e.width=a.width,e.height=a.height,e.caretX=n.x,e.caretY=n.y,e._resolveAnimations().update(e,c))}}draw(t){const e=this,i=e.options.setContext(e.getContext());let n=e.opacity;if(!n)return;e._updateAnimationTarget(i);const o={width:e.width,height:e.height},s={x:e.x,y:e.y};n=Math.abs(n)<.001?0:n;const a=oe(i.padding),r=e.title.length||e.beforeBody.length||e.body.length||e.afterBody.length||e.footer.length;i.enabled&&r&&(t.save(),t.globalAlpha=n,e.drawBackground(s,t,o,i),Ze(t,i.textDirection),s.y+=a.top,e.drawTitle(s,t,i),e.drawBody(s,t,i),e.drawFooter(s,t,i),Ge(t,i.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){const i=this,n=i._active,o=t.map((({datasetIndex:t,index:e})=>{const n=i._chart.getDatasetMeta(t);if(!n)throw new Error("Cannot find a dataset at index "+t);return{datasetIndex:t,element:n.data[e],index:e}})),s=!p(n,o),a=i._positionChanged(o,e);(s||a)&&(i._active=o,i._eventPosition=e,i.update(!0))}handleEvent(t,e){const i=this,n=i.options,o=i._active||[];let s=!1,a=[];"mouseout"!==t.type&&(a=i._chart.getElementsAtEventForMode(t,n.mode,n,e),n.reverse&&a.reverse());const r=i._positionChanged(a,t);return s=e||!p(a,o)||r,s&&(i._active=a,(n.enabled||n.external)&&(i._eventPosition={x:t.x,y:t.y},i.update(!0,e))),s}_positionChanged(t,e){const{caretX:i,caretY:n,options:o}=this,s=as[o.position].call(this,t,e);return!1!==s&&(i!==s.x||n!==s.y)}}xs.positioners=as;var bs={id:"tooltip",_element:xs,positioners:as,afterInit(t,e,i){i&&(t.tooltip=new xs({_chart:t,options:i}))},beforeUpdate(t,e,i){t.tooltip&&t.tooltip.initialize(i)},reset(t,e,i){t.tooltip&&t.tooltip.initialize(i)},afterDraw(t){const e=t.tooltip,i={tooltip:e};!1!==t.notifyPlugins("beforeTooltipDraw",i)&&(e&&e.draw(t.ctx),t.notifyPlugins("afterTooltipDraw",i))},afterEvent(t,e){if(t.tooltip){const i=e.replay;t.tooltip.handleEvent(e.event,i)&&(e.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(t,e)=>e.bodyFont.size,boxWidth:(t,e)=>e.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:{beforeTitle:o,title(t){if(t.length>0){const e=t[0],i=e.chart.data.labels,n=i?i.length:0;if(this&&this.options&&"dataset"===this.options.mode)return e.dataset.label||"";if(e.label)return e.label;if(n>0&&e.dataIndex"filter"!==t&&"itemSort"!==t&&"external"!==t,_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]},_s=Object.freeze({__proto__:null,Decimation:Eo,Filler:Qo,Legend:es,SubTitle:ss,Title:ns,Tooltip:bs});function ys(t,e,i){const n=t.indexOf(e);if(-1===n)return((t,e,i)=>"string"==typeof e?t.push(e)-1:isNaN(e)?null:i)(t,e,i);return n!==t.lastIndexOf(e)?i:n}class vs extends Tn{constructor(t){super(t),this._startValue=void 0,this._valueRange=0}parse(t,e){if(a(t))return null;const i=this.getLabels();return((t,e)=>null===t?null:q(Math.round(t),0,e))(e=isFinite(e)&&i[e]===t?e:ys(i,t,d(e,t)),i.length-1)}determineDataLimits(){const t=this,{minDefined:e,maxDefined:i}=t.getUserBounds();let{min:n,max:o}=t.getMinMax(!0);"ticks"===t.options.bounds&&(e||(n=0),i||(o=t.getLabels().length-1)),t.min=n,t.max=o}buildTicks(){const t=this,e=t.min,i=t.max,n=t.options.offset,o=[];let s=t.getLabels();s=0===e&&i===s.length-1?s:s.slice(e,i+1),t._valueRange=Math.max(s.length-(n?0:1),1),t._startValue=t.min-(n?.5:0);for(let t=e;t<=i;t++)o.push({value:t});return o}getLabelForValue(t){const e=this.getLabels();return t>=0&&te.length-1?null:this.getPixelForValue(e[t].value)}getValueForPixel(t){const e=this;return Math.round(e._startValue+e.getDecimalForPixel(t)*e._valueRange)}getBasePixel(){return this.bottom}}function ws(t,e){const i=[],{bounds:n,step:o,min:s,max:r,precision:l,count:c,maxTicks:h,maxDigits:d,includeBounds:u}=t,f=o||1,g=h-1,{min:p,max:m}=e,x=!a(s),b=!a(r),_=!a(c),y=(m-p)/(d+1);let v,w,M,k,S=F((m-p)/g/f)*f;if(S<1e-14&&!x&&!b)return[{value:p},{value:m}];k=Math.ceil(m/S)-Math.floor(p/S),k>g&&(S=F(k*S/g/f)*f),a(l)||(v=Math.pow(10,l),S=Math.ceil(S*v)/v),"ticks"===n?(w=Math.floor(p/S)*S,M=Math.ceil(m/S)*S):(w=p,M=m),x&&b&&o&&function(t,e){const i=Math.round(t);return i-e<=t&&i+e>=t}((r-s)/o,S/1e3)?(k=Math.round(Math.min((r-s)/S,h)),S=(r-s)/k,w=s,M=r):_?(w=x?s:w,M=b?r:M,k=c-1,S=(M-w)/k):(k=(M-w)/S,k=B(k,Math.round(k),S/1e3)?Math.round(k):Math.ceil(k));const P=Math.max(j(S),j(w));v=Math.pow(10,a(l)?P:l),w=Math.round(w*v)/v,M=Math.round(M*v)/v;let D=0;for(x&&(u&&w!==s?(i.push({value:s}),wo=i?o:t,r=t=>s=n?s:t;if(e){const t=I(o),e=I(s);t<0&&e<0?r(0):t>0&&e>0&&a(0)}o===s&&(r(s+1),e||a(o-1)),t.min=o,t.max=s}getTickLimit(){const t=this,e=t.options.ticks;let i,{maxTicksLimit:n,stepSize:o}=e;return o?i=Math.ceil(t.max/o)-Math.floor(t.min/o)+1:(i=t.computeTickLimit(),n=n||11),n&&(i=Math.min(n,i)),i}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this,e=t.options,i=e.ticks;let n=t.getTickLimit();n=Math.max(2,n);const o=ws({maxTicks:n,bounds:e.bounds,min:e.min,max:e.max,precision:i.precision,step:i.stepSize,count:i.count,maxDigits:t._maxDigits(),horizontal:t.isHorizontal(),minRotation:i.minRotation||0,includeBounds:!1!==i.includeBounds},t._range||t);return"ticks"===e.bounds&&W(o,t,"value"),e.reverse?(o.reverse(),t.start=t.max,t.end=t.min):(t.start=t.min,t.end=t.max),o}configure(){const t=this,e=t.ticks;let i=t.min,n=t.max;if(super.configure(),t.options.offset&&e.length){const t=(n-i)/Math.max(e.length-1,1)/2;i-=t,n+=t}t._startValue=i,t._endValue=n,t._valueRange=n-i}getLabelForValue(t){return qe(t,this.chart.options.locale)}}class Ss extends ks{determineDataLimits(){const t=this,{min:e,max:i}=t.getMinMax(!0);t.min=c(e)?e:0,t.max=c(i)?i:1,t.handleTickRangeOptions()}computeTickLimit(){const t=this,e=t.isHorizontal(),i=e?t.width:t.height,n=H(t.options.ticks.minRotation),o=(e?Math.sin(n):Math.cos(n))||.001,s=t._resolveTickFontOptions(0);return Math.ceil(i/Math.min(40,s.lineHeight/o))}getPixelForValue(t){return null===t?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}function Ps(t){return 1===t/Math.pow(10,Math.floor(z(t)))}Ss.id="linear",Ss.defaults={ticks:{callback:vn.formatters.numeric}};class Ds extends Tn{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(t,e){const i=ks.prototype.parse.apply(this,[t,e]);if(0!==i)return c(i)&&i>0?i:null;this._zero=!0}determineDataLimits(){const t=this,{min:e,max:i}=t.getMinMax(!0);t.min=c(e)?Math.max(0,e):null,t.max=c(i)?Math.max(0,i):null,t.options.beginAtZero&&(t._zero=!0),t.handleTickRangeOptions()}handleTickRangeOptions(){const t=this,{minDefined:e,maxDefined:i}=t.getUserBounds();let n=t.min,o=t.max;const s=t=>n=e?n:t,a=t=>o=i?o:t,r=(t,e)=>Math.pow(10,Math.floor(z(t))+e);n===o&&(n<=0?(s(1),a(10)):(s(r(n,-1)),a(r(o,1)))),n<=0&&s(r(o,-1)),o<=0&&a(r(n,1)),t._zero&&t.min!==t._suggestedMin&&n===r(t.min,0)&&s(r(n,-1)),t.min=n,t.max=o}buildTicks(){const t=this,e=t.options,i=function(t,e){const i=Math.floor(z(e.max)),n=Math.ceil(e.max/Math.pow(10,i)),o=[];let s=h(t.min,Math.pow(10,Math.floor(z(e.min)))),a=Math.floor(z(s)),r=Math.floor(s/Math.pow(10,a)),l=a<0?Math.pow(10,Math.abs(a)):1;do{o.push({value:s,major:Ps(s)}),++r,10===r&&(r=1,++a,l=a>=0?1:l),s=Math.round(r*Math.pow(10,a)*l)/l}while(ao?{start:e-i,end:e}:{start:e,end:e+i}}function As(t){const e={l:0,r:t.width,t:0,b:t.height-t.paddingTop},i={},n=[],o=[],s=t.getLabels().length;for(let a=0;ae.r&&(e.r=u.end,i.r=h),f.starte.b&&(e.b=f.end,i.b=h)}t._setReductions(t.drawingArea,e,i),t._pointLabelItems=function(t,e,i){const n=[],o=t.getLabels().length,s=t.options,a=Cs(s),r=t.getDistanceFromCenterForValue(s.ticks.reverse?t.min:t.max);for(let s=0;s270||i<90)&&(t-=e),t}function zs(t,e,i,n){const{ctx:o}=t;if(i)o.arc(t.xCenter,t.yCenter,e,0,C);else{let i=t.getPointPosition(0,e);o.moveTo(i.x,i.y);for(let s=1;s{const n=f(e.options.pointLabels.callback,[t,i],e);return n||0===n?n:""}))}fit(){const t=this,e=t.options;e.display&&e.pointLabels.display?As(t):t.setCenterPoint(0,0,0,0)}_setReductions(t,e,i){const n=this;let o=e.l/Math.sin(i.l),s=Math.max(e.r-n.width,0)/Math.sin(i.r),a=-e.t/Math.cos(i.t),r=-Math.max(e.b-(n.height-n.paddingTop),0)/Math.cos(i.b);o=Is(o),s=Is(s),a=Is(a),r=Is(r),n.drawingArea=Math.max(t/2,Math.min(Math.floor(t-(o+s)/2),Math.floor(t-(a+r)/2))),n.setCenterPoint(o,s,a,r)}setCenterPoint(t,e,i,n){const o=this,s=o.width-e-o.drawingArea,a=t+o.drawingArea,r=i+o.drawingArea,l=o.height-o.paddingTop-n-o.drawingArea;o.xCenter=Math.floor((a+s)/2+o.left),o.yCenter=Math.floor((r+l)/2+o.top+o.paddingTop)}getIndexAngle(t){return U(t*(C/this.getLabels().length)+H(this.options.startAngle||0))}getDistanceFromCenterForValue(t){const e=this;if(a(t))return NaN;const i=e.drawingArea/(e.max-e.min);return e.options.reverse?(e.max-t)*i:(t-e.min)*i}getValueForDistanceFromCenter(t){if(a(t))return NaN;const e=this,i=t/(e.drawingArea/(e.max-e.min));return e.options.reverse?e.max-i:e.min+i}getPointPosition(t,e){const i=this,n=i.getIndexAngle(t)-L;return{x:Math.cos(n)*e+i.xCenter,y:Math.sin(n)*e+i.yCenter,angle:n}}getPointPositionForValue(t,e){return this.getPointPosition(t,this.getDistanceFromCenterForValue(e))}getBasePosition(t){return this.getPointPositionForValue(t||0,this.getBaseValue())}getPointLabelPosition(t){const{left:e,top:i,right:n,bottom:o}=this._pointLabelItems[t];return{left:e,top:i,right:n,bottom:o}}drawBackground(){const t=this,{backgroundColor:e,grid:{circular:i}}=t.options;if(e){const n=t.ctx;n.save(),n.beginPath(),zs(t,t.getDistanceFromCenterForValue(t._endValue),i,t.getLabels().length),n.closePath(),n.fillStyle=e,n.fill(),n.restore()}}drawGrid(){const t=this,e=t.ctx,i=t.options,{angleLines:n,grid:o}=i,s=t.getLabels().length;let r,l,c;if(i.pointLabels.display&&function(t,e){const{ctx:i,options:{pointLabels:n}}=t;for(let o=e-1;o>=0;o--){const e=n.setContext(t.getContext(o)),s=se(e.font),{x:r,y:l,textAlign:c,left:h,top:d,right:u,bottom:f}=t._pointLabelItems[o],{backdropColor:g}=e;if(!a(g)){const t=oe(e.backdropPadding);i.fillStyle=g,i.fillRect(h-t.left,d-t.top,u-h+t.width,f-d+t.height)}Kt(i,t._pointLabels[o],r,l+s.lineHeight/2,s,{color:e.color,textAlign:c,textBaseline:"middle"})}}(t,s),o.display&&t.ticks.forEach(((e,i)=>{if(0!==i){l=t.getDistanceFromCenterForValue(e.value);const n=o.setContext(t.getContext(i-1));!function(t,e,i,n){const o=t.ctx,s=e.circular,{color:a,lineWidth:r}=e;!s&&!n||!a||!r||i<0||(o.save(),o.strokeStyle=a,o.lineWidth=r,o.setLineDash(e.borderDash),o.lineDashOffset=e.borderDashOffset,o.beginPath(),zs(t,i,s,n),o.closePath(),o.stroke(),o.restore())}(t,n,l,s)}})),n.display){for(e.save(),r=t.getLabels().length-1;r>=0;r--){const o=n.setContext(t.getContext(r)),{color:s,lineWidth:a}=o;a&&s&&(e.lineWidth=a,e.strokeStyle=s,e.setLineDash(o.borderDash),e.lineDashOffset=o.borderDashOffset,l=t.getDistanceFromCenterForValue(i.ticks.reverse?t.min:t.max),c=t.getPointPosition(r,l),e.beginPath(),e.moveTo(t.xCenter,t.yCenter),e.lineTo(c.x,c.y),e.stroke())}e.restore()}}drawBorder(){}drawLabels(){const t=this,e=t.ctx,i=t.options,n=i.ticks;if(!n.display)return;const o=t.getIndexAngle(0);let s,a;e.save(),e.translate(t.xCenter,t.yCenter),e.rotate(o),e.textAlign="center",e.textBaseline="middle",t.ticks.forEach(((o,r)=>{if(0===r&&!i.reverse)return;const l=n.setContext(t.getContext(r)),c=se(l.font);if(s=t.getDistanceFromCenterForValue(t.ticks[r].value),l.showLabelBackdrop){e.font=c.string,a=e.measureText(o.label).width,e.fillStyle=l.backdropColor;const t=oe(l.backdropPadding);e.fillRect(-a/2-t.left,-s-c.size/2-t.top,a+t.width,c.size+t.height)}Kt(e,o.label,0,-s,c,{color:l.color})})),e.restore()}drawTitle(){}}Fs.id="radialLinear",Fs.defaults={display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:vn.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback:t=>t,padding:5}},Fs.defaultRoutes={"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"},Fs.descriptors={angleLines:{_fallback:"grid"}};const Vs={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},Bs=Object.keys(Vs);function Ws(t,e){return t-e}function Hs(t,e){if(a(e))return null;const i=t._adapter,{parser:n,round:o,isoWeekday:s}=t._parseOpts;let r=e;return"function"==typeof n&&(r=n(r)),c(r)||(r="string"==typeof n?i.parse(r,n):i.parse(r)),null===r?null:(o&&(r="week"!==o||!V(s)&&!0!==s?i.startOf(r,o):i.startOf(r,"isoWeek",s)),+r)}function Ns(t,e,i,n){const o=Bs.length;for(let s=Bs.indexOf(t);s=e?i[n]:i[o]]=!0}}else t[e]=!0}function $s(t,e,i){const n=[],o={},s=e.length;let a,r;for(a=0;a=0&&(e[l].major=!0);return e}(t,n,o,i):n}class Ys extends Tn{constructor(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(t,e){const i=t.time||(t.time={}),n=this._adapter=new Vi._date(t.adapters.date);y(i.displayFormats,n.formats()),this._parseOpts={parser:i.parser,round:i.round,isoWeekday:i.isoWeekday},super.init(t),this._normalized=e.normalized}parse(t,e){return void 0===t?null:Hs(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this,e=t.options,i=t._adapter,n=e.time.unit||"day";let{min:o,max:s,minDefined:a,maxDefined:r}=t.getUserBounds();function l(t){a||isNaN(t.min)||(o=Math.min(o,t.min)),r||isNaN(t.max)||(s=Math.max(s,t.max))}a&&r||(l(t._getLabelBounds()),"ticks"===e.bounds&&"labels"===e.ticks.source||l(t.getMinMax(!1))),o=c(o)&&!isNaN(o)?o:+i.startOf(Date.now(),n),s=c(s)&&!isNaN(s)?s:+i.endOf(Date.now(),n)+1,t.min=Math.min(o,s-1),t.max=Math.max(o+1,s)}_getLabelBounds(){const t=this.getLabelTimestamps();let e=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;return t.length&&(e=t[0],i=t[t.length-1]),{min:e,max:i}}buildTicks(){const t=this,e=t.options,i=e.time,n=e.ticks,o="labels"===n.source?t.getLabelTimestamps():t._generate();"ticks"===e.bounds&&o.length&&(t.min=t._userMin||o[0],t.max=t._userMax||o[o.length-1]);const s=t.min,a=function(t,e,i){let n=0,o=t.length;for(;nn&&t[o-1]>i;)o--;return n>0||o=Bs.indexOf(i);s--){const i=Bs[s];if(Vs[i].common&&t._adapter.diff(o,n,i)>=e-1)return i}return Bs[i?Bs.indexOf(i):0]}(t,a.length,i.minUnit,t.min,t.max)),t._majorUnit=n.major.enabled&&"year"!==t._unit?function(t){for(let e=Bs.indexOf(t)+1,i=Bs.length;e1e5*r)throw new Error(i+" and "+n+" are too far apart with stepSize of "+r+" "+a);const p="data"===o.ticks.source&&t.getDataTimestamps();for(u=g,f=0;ut-e)).map((t=>+t))}getLabelForValue(t){const e=this._adapter,i=this.options.time;return i.tooltipFormat?e.format(t,i.tooltipFormat):e.format(t,i.displayFormats.datetime)}_tickFormatFunction(t,e,i,n){const o=this,s=o.options,a=s.time.displayFormats,r=o._unit,l=o._majorUnit,c=r&&a[r],h=l&&a[l],d=i[e],u=l&&h&&d&&d.major,g=o._adapter.format(t,n||(u?h:c)),p=s.ticks.callback;return p?f(p,[g,e,i],o):g}generateTickLabels(t){let e,i,n;for(e=0,i=t.length;e0?r:1}getDataTimestamps(){const t=this;let e,i,n=t._cache.data||[];if(n.length)return n;const o=t.getMatchingVisibleMetas();if(t._normalized&&o.length)return t._cache.data=o[0].controller.getAllParsedValues(t);for(e=0,i=o.length;e=t[r].pos&&e<=t[l].pos&&({lo:r,hi:l}=le(t,"pos",e)),({pos:n,time:s}=t[r]),({pos:o,time:a}=t[l])):(e>=t[r].time&&e<=t[l].time&&({lo:r,hi:l}=le(t,"time",e)),({time:n,pos:s}=t[r]),({time:o,pos:a}=t[l]));const c=o-n;return c?s+(a-s)*(e-n)/c:s}Ys.id="time",Ys.defaults={bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",major:{enabled:!1}}};class Xs extends Ys{constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const t=this,e=t._getTimestampsForTable(),i=t._table=t.buildLookupTable(e);t._minPos=Us(i,t.min),t._tableRange=Us(i,t.max)-t._minPos,super.initOffsets(e)}buildLookupTable(t){const{min:e,max:i}=this,n=[],o=[];let s,a,r,l,c;for(s=0,a=t.length;s=e&&l<=i&&n.push(l);if(n.length<2)return[{time:e,pos:0},{time:i,pos:1}];for(s=0,a=n.length;s=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,r=!1;return{s:function(){i=i.call(t)},n:function(){var t=i.next();return a=t.done,t},e:function(t){r=!0,s=t},f:function(){try{a||null==i.return||i.return()}finally{if(r)throw s}}}}function Zs(t,e){if(t){if("string"==typeof t)return Gs(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?Gs(t,e):void 0}}function Gs(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i{}},i={};function n(t){var o=i[t];if(void 0!==o)return o.exports;var s=i[t]={exports:{}};return e[t](s,s.exports,n),s.exports}n.m=e,t=[],n.O=(e,i,o,s)=>{if(!i){var a=1/0;for(h=0;h=s)&&Object.keys(n.O).every((t=>n.O[t](i[l])))?i.splice(l--,1):(r=!1,s0&&t[h-1][2]>s;h--)t[h]=t[h-1];t[h]=[i,o,s]},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{var t={174:0,632:0};n.O.j=e=>0===t[e];var e=(e,i)=>{var o,s,[a,r,l]=i,c=0;for(o in r)n.o(r,o)&&(n.m[o]=r[o]);if(l)var h=l(n);for(e&&e(i);cn(15)));var o=n.O(void 0,[632],(()=>n(835)));o=n.O(o)})(); -------------------------------------------------------------------------------- /resources/js/app.js: -------------------------------------------------------------------------------- 1 | import { Chart, registerables } from 'chart.js'; 2 | Chart.register(...registerables); 3 | 4 | window.memoryTrackerCharts = {}; 5 | 6 | for (const trackerChart of memoryTrackerCharts) { 7 | const chartInstance = document.getElementById('memory-tracker-chart-' + trackerChart['key']); 8 | const ctx = chartInstance.getContext('2d'); 9 | 10 | window.memoryTrackerCharts[trackerChart['key']] = new Chart(ctx, { 11 | type: 'line', 12 | data: { 13 | labels: trackerChart['timeseries']['labels'], 14 | datasets: [{ 15 | borderColor: 'rgb(101, 116, 205)', 16 | borderWidth: 2, 17 | radius: 0, 18 | data: trackerChart['timeseries']['data'], 19 | label: 'Memory', 20 | }] 21 | }, 22 | options: { 23 | animation: false, 24 | interaction: { 25 | intersect: false, 26 | }, 27 | responsive: true, 28 | maintainAspectRatio: false, 29 | plugins: { 30 | legend: { 31 | display: false, 32 | }, 33 | tooltip: { 34 | displayColors: false, 35 | callbacks: { 36 | label: (ctx) => ' ' + ctx.parsed.y + ' MB', 37 | }, 38 | }, 39 | }, 40 | elements: { 41 | line: { 42 | tension: 0, 43 | }, 44 | }, 45 | scales: { 46 | x: { 47 | grid: { 48 | display: false, 49 | }, 50 | ticks: { 51 | maxTicksLimit: 15, 52 | }, 53 | }, 54 | y: { 55 | min: 0, 56 | max: trackerChart['timeseries']['max'], 57 | ticks: { 58 | stepSize: .1, 59 | } 60 | }, 61 | }, 62 | }, 63 | }); 64 | } 65 | 66 | // Listen for updates from Livewire 67 | Livewire.on('memoryTrackerUpdated', charts => { 68 | for (const trackerChart of charts) { 69 | window.memoryTrackerCharts[trackerChart['key']].data.labels = trackerChart['timeseries']['labels']; 70 | window.memoryTrackerCharts[trackerChart['key']].data.datasets[0].data = trackerChart['timeseries']['data']; 71 | window.memoryTrackerCharts[trackerChart['key']].update(); 72 | } 73 | }); 74 | -------------------------------------------------------------------------------- /resources/scss/app.scss: -------------------------------------------------------------------------------- 1 | .memory-tracker-chart-name { 2 | display: block; 3 | margin-top: 1.5rem; 4 | margin-bottom: 1.5rem; 5 | text-align: center; 6 | font-weight: bold; 7 | font-size: 1.125rem; 8 | line-height: 1.75rem; 9 | } 10 | 11 | .memory-tracker--mb-10 { 12 | margin-bottom: 2.5rem; 13 | } 14 | 15 | .memory-tracker--col-span-full { 16 | grid-column: 1 / -1; 17 | } 18 | 19 | .memory-tracker--mb-2 { 20 | margin-bottom: 0.5rem; 21 | } 22 | 23 | .memory-tracker--text-sm { 24 | font-size: 0.875rem; 25 | line-height: 1.25rem; 26 | } 27 | -------------------------------------------------------------------------------- /resources/views/widgets/memory-tracker.blade.php: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 |
5 |

6 | Memory usage 7 |

8 |
9 | 10 |
1) class="grid grid-cols-1 gap-4 lg:grid-cols-2 lg:gap-8" @endif> 11 | @foreach ($charts as $chart) 12 |
13 |

{{ $chart['name'] }}

14 | 15 | @if ($chart['latestRestart']) 16 |

17 | 🔄 Latest Restart: {{ $chart['latestRestart']['date'] }} ({{ $chart['latestRestart']['value'] }} MB) 18 |

19 | @endif 20 | 21 | @if ($chart['peak']) 22 |

23 | 📈 Memory Peak: {{ $chart['peak']['date'] }} ({{ $chart['peak']['value'] }} MB) 24 |

25 | @endif 26 | 27 |
28 | 29 |
30 |
31 | @endforeach 32 |
33 | 34 | 35 |
36 | -------------------------------------------------------------------------------- /src/Concerns/TracksRestart.php: -------------------------------------------------------------------------------- 1 | trackRestart(); 25 | 26 | exit($sigNo); 27 | }; 28 | 29 | pcntl_signal(SIGTERM, $quitCallback); 30 | pcntl_signal(SIGQUIT, $quitCallback); 31 | pcntl_signal(SIGINT, $quitCallback); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/MemoryTracker.php: -------------------------------------------------------------------------------- 1 | cache = Cache::store(Config::get('filament-memory-tracker.cache_store')); 36 | $this->memoryTrackerKey = 'memory_tracker:' . Str::slug($trackerName); 37 | $this->memoryTrackerPeakKey = 'memory_tracker_peak:' . Str::slug($trackerName); 38 | $this->memoryTrackerRestartKey = 'memory_tracker_restart:' . Str::slug($trackerName); 39 | $this->historyMaxSize = $historyMaxSize; 40 | $this->realUsage = $realUsage; 41 | } 42 | 43 | /** 44 | * Track the current memory usage of the worker. 45 | * 46 | * @return void 47 | */ 48 | public function track(): void 49 | { 50 | $currentlyTracked = $this->cache->get($this->memoryTrackerKey, []); 51 | if (!is_array($currentlyTracked)) { 52 | $currentlyTracked = []; 53 | } 54 | 55 | $currentMemory = memory_get_usage($this->realUsage); 56 | $today = Carbon::now()->toDateTimeString(); 57 | 58 | $currentlyTracked[] = [ 59 | 'date' => Carbon::now()->toDateTimeString(), 60 | 'value' => $currentMemory, 61 | ]; 62 | 63 | $this->cache->set( 64 | $this->memoryTrackerKey, 65 | // Slice the last N elements 66 | array_slice($currentlyTracked, $this->historyMaxSize * -1, $this->historyMaxSize) 67 | ); 68 | 69 | // Set or update the memory peak 70 | $currentPeak = $this->cache->get($this->memoryTrackerPeakKey); 71 | 72 | if (is_null($currentPeak) || $currentMemory > $currentPeak['value']) { 73 | $this->cache->set($this->memoryTrackerPeakKey, [ 74 | 'date' => $today, 75 | 'value' => $currentMemory, 76 | ]); 77 | } 78 | 79 | unset($currentlyTracked); 80 | unset($currentMemory); 81 | unset($today); 82 | unset($currentPeak); 83 | } 84 | 85 | /** 86 | * Track memory usage of the worker in the latest restart. 87 | * 88 | * @param bool $resetPeak 89 | * @return void 90 | */ 91 | public function trackRestart(bool $resetPeak = true): void 92 | { 93 | if ($resetPeak) { 94 | $this->purgePeak(); 95 | } 96 | 97 | $this->cache->forever( 98 | $this->memoryTrackerRestartKey, 99 | [ 100 | 'date' => Carbon::now()->toDateTimeString(), 101 | 'value' => memory_get_usage($this->realUsage), 102 | ] 103 | ); 104 | } 105 | 106 | /** 107 | * Get history of tracked memory usage. 108 | * 109 | * @return array 110 | */ 111 | public function getHistory(): array 112 | { 113 | $result = $this->cache->get($this->memoryTrackerKey); 114 | 115 | if (!is_array($result)) { 116 | $result = []; 117 | } 118 | 119 | return $result; 120 | } 121 | 122 | /** 123 | * Get peak of memory usage. 124 | * 125 | * @return array 126 | */ 127 | public function getPeak(): ?array 128 | { 129 | if (!$peak = $this->cache->get($this->memoryTrackerPeakKey)) { 130 | return null; 131 | } 132 | 133 | return [ 134 | 'date' => (new Carbon($peak['date']))->format( 135 | Config::get('filament-memory-tracker.date_format', 'j F Y @ H:i:s') 136 | ), 137 | 'value' => number_format($peak['value'] / 1024 / 1024, 3), 138 | ]; 139 | } 140 | 141 | /** 142 | * Get data about the latest restart. 143 | * 144 | * @return array|null 145 | */ 146 | public function getLatestRestart(): ?array 147 | { 148 | if (!$latestRestart = $this->cache->get($this->memoryTrackerRestartKey)) { 149 | return null; 150 | } 151 | 152 | return [ 153 | 'date' => (new Carbon($latestRestart['date']))->format( 154 | Config::get('filament-memory-tracker.date_format', 'j F Y @ H:i:s') 155 | ), 156 | 'value' => number_format($latestRestart['value'] / 1024 / 1024, 3), 157 | ]; 158 | } 159 | 160 | /** 161 | * Purge all the data of the current tracker. 162 | * 163 | * @return void 164 | */ 165 | public function purge(): void 166 | { 167 | $this->purgeHistory(); 168 | $this->purgePeak(); 169 | $this->purgeRestart(); 170 | } 171 | 172 | /** 173 | * Purge the tracker history. 174 | * 175 | * @return void 176 | */ 177 | public function purgeHistory(): void 178 | { 179 | $this->cache->forget($this->memoryTrackerKey); 180 | } 181 | 182 | /** 183 | * Purge the tracker peak. 184 | * 185 | * @return void 186 | */ 187 | public function purgePeak(): void 188 | { 189 | $this->cache->forget($this->memoryTrackerPeakKey); 190 | } 191 | 192 | /** 193 | * Purge the tracker restart data. 194 | * 195 | * @return void 196 | */ 197 | public function purgeRestart(): void 198 | { 199 | $this->cache->forget($this->memoryTrackerRestartKey); 200 | } 201 | } 202 | -------------------------------------------------------------------------------- /src/WidgetServiceProvider.php: -------------------------------------------------------------------------------- 1 | hasAssets() 23 | ->hasConfigFile(); 24 | } 25 | 26 | /** 27 | * {@inheritDoc} 28 | */ 29 | public function packageRegistered(): void 30 | { 31 | $this->app->singletonIf('filament', fn (): FilamentManager => new FilamentManager()); 32 | 33 | parent::packageRegistered(); 34 | } 35 | 36 | /** 37 | * {@inheritDoc} 38 | */ 39 | protected function getWidgets(): array 40 | { 41 | return [ 42 | MemoryTrackerWidget::class, 43 | ]; 44 | } 45 | 46 | /** 47 | * {@inheritDoc} 48 | */ 49 | protected function getStyles(): array 50 | { 51 | return [ 52 | self::$name . '-styles' => asset('/vendor/' . self::$name . '/memory-tracker.css'), 53 | ]; 54 | } 55 | 56 | /** 57 | * {@inheritDoc} 58 | */ 59 | protected function getScripts(): array 60 | { 61 | return [ 62 | self::$name . '-scripts' => asset('/vendor/' . self::$name . '/memory-tracker.js'), 63 | ]; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/Widgets/MemoryTrackerWidget.php: -------------------------------------------------------------------------------- 1 | getHistory(); 25 | 26 | // X axis 27 | $labels = array_map( 28 | fn (string $date) => (new Carbon($date))->format('H:i:s'), 29 | array_column($history, 'date') 30 | ); 31 | 32 | // Y axis 33 | $data = array_map( 34 | fn ($value) => number_format($value / 1024 / 1024, 3), 35 | array_column($history, 'value') 36 | ); 37 | 38 | $charts[] = [ 39 | 'name' => $trackerName, 40 | 'key' => Str::slug($trackerName), 41 | 'latestRestart' => $memoryTracker->getLatestRestart(), 42 | 'peak' => $memoryTracker->getPeak(), 43 | 'timeseries' => [ 44 | 'labels' => $labels, 45 | 'data' => $data, 46 | 'max' => Collection::make($data)->max() + 10, 47 | ], 48 | ]; 49 | } 50 | 51 | $this->emit('memoryTrackerUpdated', $charts); 52 | 53 | return view(static::$view, [ 54 | 'charts' => $charts, 55 | ]); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /webpack.mix.js: -------------------------------------------------------------------------------- 1 | const mix = require('laravel-mix'); 2 | 3 | // Disable manifest generation 4 | Mix.manifest.refresh = _ => void 0; 5 | 6 | mix 7 | .options({ 8 | terser: { 9 | extractComments: false, 10 | }, 11 | }) 12 | .js('resources/js/app.js', 'memory-tracker.js') 13 | .sass('resources/scss/app.scss', 'memory-tracker.css') 14 | .setPublicPath('resources/dist'); 15 | --------------------------------------------------------------------------------